public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Love <robert.w.love@intel.com>
To: James.Bottomley@HansenPartnership.com, linux-scsi@vger.kernel.org
Cc: Joe Eykholt <jeykholt@cisco.com>, Robert Love <robert.w.love@intel.com>
Subject: [PATCH 05/24] libfcoe: FIP should report link to libfc whether selected or not
Date: Fri, 18 Sep 2009 15:49:14 -0700	[thread overview]
Message-ID: <20090918224914.5928.38324.stgit@localhost.localdomain> (raw)
In-Reply-To: <20090918224847.5928.52092.stgit@localhost.localdomain>

From: Joe Eykholt <jeykholt@cisco.com>

The fnic driver with FIP is reporting link up, even though it's down.

When the interface is shut down by the switch, we receive a clear
virtual link, and set the state reported to libfc as down, although
we still report it up.  Clearly wrong.  That causes the subsequent
link down event not to be reported, and /sys shows the host "Online".

Currently, in FIP mode, if an FCF times out, then link to libfc
is reported as down, to stop FLOGIs.  That interferes with the LLD
link down being reported.

Users really need to know the physical link information, to diagnose
cabling issues, so physical link status should be reported to libfc.

If the selected FCF needs to be reported, that should be done
separately, in a later patch.

Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
---

 drivers/scsi/fcoe/libfcoe.c |   60 ++++++++++++++++++++++---------------------
 include/scsi/libfcoe.h      |    1 +
 2 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c
index 6480dcf..1ee2350 100644
--- a/drivers/scsi/fcoe/libfcoe.c
+++ b/drivers/scsi/fcoe/libfcoe.c
@@ -278,38 +278,16 @@ EXPORT_SYMBOL(fcoe_ctlr_link_up);
 /**
  * fcoe_ctlr_reset() - Reset a FCoE controller
  * @fip:       The FCoE controller to reset
- * @new_state: The FIP state to be entered
- *
- * Returns non-zero if the link was up and now isn't.
  */
-static int fcoe_ctlr_reset(struct fcoe_ctlr *fip, enum fip_state new_state)
+static void fcoe_ctlr_reset(struct fcoe_ctlr *fip)
 {
-	struct fc_lport *lport = fip->lp;
-	int link_dropped;
-
-	spin_lock_bh(&fip->lock);
 	fcoe_ctlr_reset_fcfs(fip);
 	del_timer(&fip->timer);
-	fip->state = new_state;
 	fip->ctlr_ka_time = 0;
 	fip->port_ka_time = 0;
 	fip->sol_time = 0;
 	fip->flogi_oxid = FC_XID_UNKNOWN;
 	fip->map_dest = 0;
-	fip->last_link = 0;
-	link_dropped = fip->link;
-	fip->link = 0;
-	spin_unlock_bh(&fip->lock);
-
-	if (link_dropped)
-		fc_linkdown(lport);
-
-	if (new_state == FIP_ST_ENABLED) {
-		fcoe_ctlr_solicit(fip, NULL);
-		fc_linkup(lport);
-		link_dropped = 0;
-	}
-	return link_dropped;
 }
 
 /**
@@ -323,7 +301,20 @@ static int fcoe_ctlr_reset(struct fcoe_ctlr *fip, enum fip_state new_state)
  */
 int fcoe_ctlr_link_down(struct fcoe_ctlr *fip)
 {
-	return fcoe_ctlr_reset(fip, FIP_ST_LINK_WAIT);
+	int link_dropped;
+
+	LIBFCOE_FIP_DBG(fip, "link down.\n");
+	spin_lock_bh(&fip->lock);
+	fcoe_ctlr_reset(fip);
+	link_dropped = fip->link;
+	fip->link = 0;
+	fip->last_link = 0;
+	fip->state = FIP_ST_LINK_WAIT;
+	spin_unlock_bh(&fip->lock);
+
+	if (link_dropped)
+		fc_linkdown(fip->lp);
+	return link_dropped;
 }
 EXPORT_SYMBOL(fcoe_ctlr_link_down);
 
@@ -995,7 +986,13 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
 				desc_mask);
 	} else {
 		LIBFCOE_FIP_DBG(fip, "performing Clear Virtual Link\n");
-		fcoe_ctlr_reset(fip, FIP_ST_ENABLED);
+
+		spin_lock_bh(&fip->lock);
+		fcoe_ctlr_reset(fip);
+		spin_unlock_bh(&fip->lock);
+
+		fc_lport_reset(fip->lp);
+		fcoe_ctlr_solicit(fip, NULL);
 	}
 }
 
@@ -1153,15 +1150,14 @@ static void fcoe_ctlr_timeout(unsigned long arg)
 			fip->port_ka_time = jiffies +
 				msecs_to_jiffies(FIP_VN_KA_PERIOD);
 			fip->ctlr_ka_time = jiffies + sel->fka_period;
-			fip->link = 1;
 		} else {
 			printk(KERN_NOTICE "libfcoe: host%d: "
 			       "FIP Fibre-Channel Forwarder timed out.	"
 			       "Starting FCF discovery.\n",
 			       fip->lp->host->host_no);
-			fip->link = 0;
+			fip->reset_req = 1;
+			schedule_work(&fip->link_work);
 		}
-		schedule_work(&fip->link_work);
 	}
 
 	if (sel) {
@@ -1206,20 +1202,24 @@ static void fcoe_ctlr_link_work(struct work_struct *work)
 	u8 *mac;
 	int link;
 	int last_link;
+	int reset;
 
 	fip = container_of(work, struct fcoe_ctlr, link_work);
 	spin_lock_bh(&fip->lock);
 	last_link = fip->last_link;
 	link = fip->link;
 	fip->last_link = link;
+	reset = fip->reset_req;
+	fip->reset_req = 0;
 	spin_unlock_bh(&fip->lock);
 
 	if (last_link != link) {
 		if (link)
 			fc_linkup(fip->lp);
 		else
-			fcoe_ctlr_reset(fip, FIP_ST_LINK_WAIT);
-	}
+			fc_linkdown(fip->lp);
+	} else if (reset && link)
+		fc_lport_reset(fip->lp);
 
 	if (fip->send_ctlr_ka) {
 		fip->send_ctlr_ka = 0;
diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
index 2344a00..e38ffa0 100644
--- a/include/scsi/libfcoe.h
+++ b/include/scsi/libfcoe.h
@@ -108,6 +108,7 @@ struct fcoe_ctlr {
 	u8 flogi_count;
 	u8 link;
 	u8 last_link;
+	u8 reset_req;
 	u8 map_dest;
 	u8 spma;
 	u8 send_ctlr_ka;


  parent reply	other threads:[~2009-09-18 22:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-18 22:48 [PATCH 00/24] libfc, libfcoe, fcoe and fnic updates for 2.6.32 Robert Love
2009-09-18 22:48 ` [PATCH 01/24] libfc: lport: fix minor documentation errors Robert Love
2009-09-18 22:48 ` [PATCH 02/24] libfcoe: Allow FIP to be disabled by the driver Robert Love
2009-09-18 22:49 ` [PATCH 03/24] libfcoe: fip: use SCSI host number to identify debug messages Robert Love
2009-09-18 22:49 ` [PATCH 04/24] libfcoe: fip: allow FIP receive to be called from IRQ Robert Love
2009-09-18 22:49 ` Robert Love [this message]
2009-09-18 22:49 ` [PATCH 06/24] libfc: don't WARN_ON in lport_timeout for RESET state Robert Love
2009-09-18 22:49 ` [PATCH 07/24] libfcoe: don't send ELS in FIP mode if no FCF selected Robert Love
2009-09-18 22:49 ` [PATCH 08/24] fcoe: remove extra function decalrations Robert Love
2009-09-18 22:49 ` [PATCH 09/24] libfc: removes initializing fc_cpu_order and fc_cpu_mask per lport Robert Love
2009-09-18 22:49 ` [PATCH 10/24] libfc: adds missing exch release for accepted RRQ Robert Love
2009-09-18 22:49 ` [PATCH 11/24] libfc: removes unused disc_work and ex_list Robert Love
2009-09-18 22:50 ` [PATCH 12/24] fcoe: Use NETIF_F_FCOE_MTU flag to set up max frame size (lport->mfs) Robert Love
2009-09-18 22:50 ` [PATCH 13/24] fcoe: Call ndo_fcoe_enable/disable to turn FCoE feature on/off in LLD Robert Love
2009-09-18 22:50 ` [PATCH 14/24] fcoe: initialize return value in fcoe_destroy Robert Love
2009-09-18 22:50 ` [PATCH 15/24] fcoe: add check to fail gracefully in bonding mode Robert Love
2009-09-18 22:50 ` [PATCH 16/24] libfc: fix RNN_ID smashing skb payload Robert Love
2009-09-18 22:50 ` [PATCH 17/24] libfc: fix symbolic name registrations smashing skb data Robert Love
2009-09-18 22:50 ` [PATCH 18/24] libfc: fix fc_els_resp_type to correct display of CT responses Robert Love
2009-09-18 22:50 ` [PATCH 19/24] libfc: add set_fid function to libfc template Robert Love
2009-09-18 22:50 ` [PATCH 20/24] libfc: add host number to lport link up/down messages Robert Love
2009-09-18 22:50 ` [PATCH 21/24] libfcoe: fcoe: simplify receive FLOGI response Robert Love
2009-09-18 22:50 ` [PATCH 22/24] fnic: Add FIP support to the fnic driver Robert Love
2009-09-18 22:51 ` [PATCH 23/24] libfc: register FC4 features with the FC switch Robert Love
2009-09-18 22:51 ` [PATCH 24/24] MAINTAINERS: Update for libfc, libfcoe, fcoe Robert Love

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090918224914.5928.38324.stgit@localhost.localdomain \
    --to=robert.w.love@intel.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=jeykholt@cisco.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox