aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/fcoe
diff options
context:
space:
mode:
authorVasu Dev <vasu.dev@intel.com>2011-07-27 18:11:10 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-07-28 04:14:29 -0400
commitd272281c390eb6c3f1e70ed0337c9e619d99cd9c (patch)
tree020ba7b16f20599c9d7cf1cca0aa4d11d22c494c /drivers/scsi/fcoe
parent980f5156ab2d75e0462f3811e8a92acd06b0577b (diff)
[SCSI] fcoe: cleanup cpu selection for incoming requests
Cleanup to: - have selection for all types of frames, not just FCP. - remove redundant cpu_online check once fcoe_select_cpu called as this is not required since later code flow check for offlined cpu. - Simplify fcoe_select_cpu() by removing unnecessary checks to skip curr_cpu, this also fixes possibly infinite loop in case of curr_cpu is the only cpu while iterating in the loop. This cleanup mainly applies to target as incoming request are mostly for target, therefore Kiran has verified the patch with target also. Signed-off-by: Vasu Dev <vasu.dev@intel.com> Tested-by: Kiran Patil <kiran.patil@intel.com> Tested-by: Ross Brattain <ross.b.brattain@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/fcoe')
-rw-r--r--drivers/scsi/fcoe/fcoe.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 528b86bca491..ba710e350ac5 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1270,30 +1270,20 @@ static int fcoe_cpu_callback(struct notifier_block *nfb,
1270/** 1270/**
1271 * fcoe_select_cpu() - Selects CPU to handle post-processing of incoming 1271 * fcoe_select_cpu() - Selects CPU to handle post-processing of incoming
1272 * command. 1272 * command.
1273 * @curr_cpu: CPU which received request
1274 * 1273 *
1275 * This routine selects next CPU based on cpumask. 1274 * This routine selects next CPU based on cpumask to distribute
1275 * incoming requests in round robin.
1276 * 1276 *
1277 * Returns: int (CPU number). Caller to verify if returned CPU is online or not. 1277 * Returns: int CPU number
1278 */ 1278 */
1279static unsigned int fcoe_select_cpu(unsigned int curr_cpu) 1279static inline unsigned int fcoe_select_cpu(void)
1280{ 1280{
1281 static unsigned int selected_cpu; 1281 static unsigned int selected_cpu;
1282 1282
1283 if (num_online_cpus() == 1) 1283 selected_cpu = cpumask_next(selected_cpu, cpu_online_mask);
1284 return curr_cpu; 1284 if (selected_cpu >= nr_cpu_ids)
1285 /* 1285 selected_cpu = cpumask_first(cpu_online_mask);
1286 * Doing following check, to skip "curr_cpu (smp_processor_id)" 1286
1287 * from selection of CPU is intentional. This is to avoid same CPU
1288 * doing post-processing of command. "curr_cpu" to just receive
1289 * incoming request in case where rx_id is UNKNOWN and all other
1290 * CPU to actually process the command(s)
1291 */
1292 do {
1293 selected_cpu = cpumask_next(selected_cpu, cpu_online_mask);
1294 if (selected_cpu >= nr_cpu_ids)
1295 selected_cpu = cpumask_first(cpu_online_mask);
1296 } while (selected_cpu == curr_cpu);
1297 return selected_cpu; 1287 return selected_cpu;
1298} 1288}
1299 1289
@@ -1368,23 +1358,16 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
1368 * In case the incoming frame's exchange is originated from 1358 * In case the incoming frame's exchange is originated from
1369 * the initiator, then received frame's exchange id is ANDed 1359 * the initiator, then received frame's exchange id is ANDed
1370 * with fc_cpu_mask bits to get the same cpu on which exchange 1360 * with fc_cpu_mask bits to get the same cpu on which exchange
1371 * was originated, otherwise just use the current cpu. 1361 * was originated, otherwise select cpu using rx exchange id
1362 * or fcoe_select_cpu().
1372 */ 1363 */
1373 if (ntoh24(fh->fh_f_ctl) & FC_FC_EX_CTX) 1364 if (ntoh24(fh->fh_f_ctl) & FC_FC_EX_CTX)
1374 cpu = ntohs(fh->fh_ox_id) & fc_cpu_mask; 1365 cpu = ntohs(fh->fh_ox_id) & fc_cpu_mask;
1375 else { 1366 else {
1376 cpu = smp_processor_id(); 1367 if (ntohs(fh->fh_rx_id) == FC_XID_UNKNOWN)
1377 1368 cpu = fcoe_select_cpu();
1378 if ((fh->fh_type == FC_TYPE_FCP) && 1369 else
1379 (ntohs(fh->fh_rx_id) == FC_XID_UNKNOWN)) {
1380 do {
1381 cpu = fcoe_select_cpu(cpu);
1382 } while (!cpu_online(cpu));
1383 } else if ((fh->fh_type == FC_TYPE_FCP) &&
1384 (ntohs(fh->fh_rx_id) != FC_XID_UNKNOWN)) {
1385 cpu = ntohs(fh->fh_rx_id) & fc_cpu_mask; 1370 cpu = ntohs(fh->fh_rx_id) & fc_cpu_mask;
1386 } else
1387 cpu = smp_processor_id();
1388 } 1371 }
1389 1372
1390 if (cpu >= nr_cpu_ids) 1373 if (cpu >= nr_cpu_ids)