From 302ff541d981e58cd455fdbd6a90bd74d0f2109b Mon Sep 17 00:00:00 2001 From: Yi Zou Date: Wed, 27 Jul 2011 15:10:23 -0700 Subject: [SCSI] fcoe: remove unused ptype field in fcoe_rcv_info There is no need to cache the ptype in fcoe_rcv_info struct as it is never used anywhere. Signed-off-by: Yi Zou Tested-by: Ross Brattain Signed-off-by: Robert Love Signed-off-by: James Bottomley --- drivers/scsi/fcoe/fcoe.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/scsi/fcoe') diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 204fa8d4b4ab..f7547fb000c0 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1350,7 +1350,6 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, fr = fcoe_dev_from_skb(skb); fr->fr_dev = lport; - fr->ptype = ptype; /* * In case the incoming frame's exchange is originated from -- cgit v1.2.2 From 324f667833d7ddd9501ed8c0e3ec5754ddb1b695 Mon Sep 17 00:00:00 2001 From: Vasu Dev Date: Wed, 27 Jul 2011 15:10:39 -0700 Subject: [SCSI] libfc, fcoe: ignore rx frame with wrong xid info Drop the rx frame having xid with wrong cpu info or received with xid not matching to our xid. Not dropping such frame is causing panic as that causes accessing data struct beyond their bounds. Signed-off-by: Vasu Dev Tested-by: Ross Brattain Signed-off-by: Robert Love Signed-off-by: James Bottomley --- drivers/scsi/fcoe/fcoe.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/scsi/fcoe') diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index f7547fb000c0..945df21ac017 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1373,6 +1373,10 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, } else cpu = smp_processor_id(); } + + if (cpu >= nr_cpu_ids) + goto err; + fps = &per_cpu(fcoe_percpu, cpu); spin_lock_bh(&fps->fcoe_rx_list.lock); if (unlikely(!fps->thread)) { -- cgit v1.2.2 From 980f5156ab2d75e0462f3811e8a92acd06b0577b Mon Sep 17 00:00:00 2001 From: Vasu Dev Date: Wed, 27 Jul 2011 15:11:05 -0700 Subject: [SCSI] fcoe: add fip retry to avoid missing critical keep alive Use pending queue to retry FIP frame in case its tx fails and use common pending queue for both fcoe and fip frames using fcoe_port_send. Signed-off-by: Vasu Dev Tested-by: Ross Brattain Signed-off-by: Robert Love Signed-off-by: James Bottomley --- drivers/scsi/fcoe/fcoe.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/fcoe') diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 945df21ac017..528b86bca491 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -486,6 +486,19 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *netdev, return 0; } +/** + * fcoe_port_send() - Send an Ethernet-encapsulated FIP/FCoE frame + * @port: The FCoE port + * @skb: The FIP/FCoE packet to be sent + */ +static void fcoe_port_send(struct fcoe_port *port, struct sk_buff *skb) +{ + if (port->fcoe_pending_queue.qlen) + fcoe_check_wait_queue(port->lport, skb); + else if (fcoe_start_io(skb)) + fcoe_check_wait_queue(port->lport, skb); +} + /** * fcoe_fip_send() - Send an Ethernet-encapsulated FIP frame * @fip: The FCoE controller @@ -494,7 +507,7 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *netdev, static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb) { skb->dev = fcoe_from_ctlr(fip)->netdev; - dev_queue_xmit(skb); + fcoe_port_send(lport_priv(fip->lp), skb); } /** @@ -1575,11 +1588,7 @@ int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) /* send down to lld */ fr_dev(fp) = lport; - if (port->fcoe_pending_queue.qlen) - fcoe_check_wait_queue(lport, skb); - else if (fcoe_start_io(skb)) - fcoe_check_wait_queue(lport, skb); - + fcoe_port_send(port, skb); return 0; } -- cgit v1.2.2 From d272281c390eb6c3f1e70ed0337c9e619d99cd9c Mon Sep 17 00:00:00 2001 From: Vasu Dev Date: Wed, 27 Jul 2011 15:11:10 -0700 Subject: [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 Tested-by: Kiran Patil Tested-by: Ross Brattain Signed-off-by: Robert Love Signed-off-by: James Bottomley --- drivers/scsi/fcoe/fcoe.c | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'drivers/scsi/fcoe') 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, /** * fcoe_select_cpu() - Selects CPU to handle post-processing of incoming * command. - * @curr_cpu: CPU which received request * - * This routine selects next CPU based on cpumask. + * This routine selects next CPU based on cpumask to distribute + * incoming requests in round robin. * - * Returns: int (CPU number). Caller to verify if returned CPU is online or not. + * Returns: int CPU number */ -static unsigned int fcoe_select_cpu(unsigned int curr_cpu) +static inline unsigned int fcoe_select_cpu(void) { static unsigned int selected_cpu; - if (num_online_cpus() == 1) - return curr_cpu; - /* - * Doing following check, to skip "curr_cpu (smp_processor_id)" - * from selection of CPU is intentional. This is to avoid same CPU - * doing post-processing of command. "curr_cpu" to just receive - * incoming request in case where rx_id is UNKNOWN and all other - * CPU to actually process the command(s) - */ - do { - selected_cpu = cpumask_next(selected_cpu, cpu_online_mask); - if (selected_cpu >= nr_cpu_ids) - selected_cpu = cpumask_first(cpu_online_mask); - } while (selected_cpu == curr_cpu); + selected_cpu = cpumask_next(selected_cpu, cpu_online_mask); + if (selected_cpu >= nr_cpu_ids) + selected_cpu = cpumask_first(cpu_online_mask); + return selected_cpu; } @@ -1368,23 +1358,16 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, * In case the incoming frame's exchange is originated from * the initiator, then received frame's exchange id is ANDed * with fc_cpu_mask bits to get the same cpu on which exchange - * was originated, otherwise just use the current cpu. + * was originated, otherwise select cpu using rx exchange id + * or fcoe_select_cpu(). */ if (ntoh24(fh->fh_f_ctl) & FC_FC_EX_CTX) cpu = ntohs(fh->fh_ox_id) & fc_cpu_mask; else { - cpu = smp_processor_id(); - - if ((fh->fh_type == FC_TYPE_FCP) && - (ntohs(fh->fh_rx_id) == FC_XID_UNKNOWN)) { - do { - cpu = fcoe_select_cpu(cpu); - } while (!cpu_online(cpu)); - } else if ((fh->fh_type == FC_TYPE_FCP) && - (ntohs(fh->fh_rx_id) != FC_XID_UNKNOWN)) { + if (ntohs(fh->fh_rx_id) == FC_XID_UNKNOWN) + cpu = fcoe_select_cpu(); + else cpu = ntohs(fh->fh_rx_id) & fc_cpu_mask; - } else - cpu = smp_processor_id(); } if (cpu >= nr_cpu_ids) -- cgit v1.2.2