[Open-FCoE] [PATCH 02/28] libfc: Add a callback to the fc_lport for fc_rport events

Robert Love robert.w.love at intel.com
Tue Sep 30 18:24:57 UTC 2008


We want to know when an rport has successfully logged in
or not. The lport needs to know if the NS's rport is READY
or not. If it's not READY then the lport needs to decide
what it wants to do. The rport and NS shouldn't be
making decisions for the lport.

This patch creates a callback function for the lport and calls
it when the rport is READY.

The lport will call dns_register when it sees that the NS rport
is READY.

Signed-off-by: Robert Love <robert.w.love at intel.com>
---

 drivers/scsi/libfc/fc_lport.c |   22 ++++++++++++++++++++++
 drivers/scsi/libfc/fc_rport.c |    8 +-------
 include/scsi/libfc/libfc.h    |    8 ++++++++
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index afc0c76..1817edb 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -58,6 +58,25 @@ static int fc_frame_drop(struct fc_lport *lp, struct fc_frame *fp)
 	return 0;
 }
 
+static int fc_lport_rport_event(struct fc_lport *lport, struct fc_rport *rport,
+				enum fc_lport_event event)
+{
+	fc_lport_lock(lport);
+	if (rport->port_id == FC_FID_DIR_SERV) {
+		switch (event) {
+		case LPORT_EV_RPORT_CREATED:
+			lport->tt.dns_register(lport);
+			break;
+		case LPORT_EV_RPORT_FAILED:
+			fc_lport_enter_reset(lport);
+			break;
+		}
+	}
+	fc_lport_unlock(lport);
+
+	return 0;
+}
+
 static const char *fc_lport_state(struct fc_lport *lp)
 {
 	const char *cp;
@@ -976,6 +995,9 @@ int fc_lport_init(struct fc_lport *lp)
 	if (!lp->tt.lport_logout)
 		lp->tt.lport_logout = fc_lport_logout;
 
+	if (!lp->tt.lport_event)
+		lp->tt.lport_event = fc_lport_rport_event;
+
 	fc_host_port_type(lp->host) = FC_PORTTYPE_NPORT;
 	fc_host_node_name(lp->host) = lp->wwnn;
 	fc_host_port_name(lp->host) = lp->wwpn;
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 6724800..39eb7e4 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -354,13 +354,7 @@ static void fc_rport_enter_ready(struct fc_rport *rport)
 	if (fc_rp_debug)
 		FC_DBG("remote %6x ready\n", rport->port_id);
 
-	if (rport == lport->dns_rp &&
-	    lport->state == LPORT_ST_DNS) {
-		fc_lport_lock(lport);
-		del_timer(&lport->state_timer);
-		lport->tt.dns_register(lport);
-		fc_lport_unlock(lport);
-	}
+	lport->tt.lport_event(lport, rport, LPORT_EV_RPORT_CREATED);
 }
 
 static void fc_rport_enter_start(struct fc_rport *rport)
diff --git a/include/scsi/libfc/libfc.h b/include/scsi/libfc/libfc.h
index 0c39739..720c607 100644
--- a/include/scsi/libfc/libfc.h
+++ b/include/scsi/libfc/libfc.h
@@ -100,6 +100,11 @@ enum fc_lport_state {
 	LPORT_ST_RESET
 };
 
+enum fc_lport_event {
+	LPORT_EV_RPORT_CREATED = 0,
+	LPORT_EV_RPORT_FAILED
+};
+
 enum fc_rport_state {
 	RPORT_ST_NONE = 0,
 	RPORT_ST_INIT,		/* initialized */
@@ -325,6 +330,9 @@ struct libfc_function_template {
 	int (*lport_reset)(struct fc_lport *);
 	int (*lport_logout)(struct fc_lport *);
 
+	int (*lport_event)(struct fc_lport *, struct fc_rport *,
+			   enum fc_lport_event);
+
 	/**
 	 * Remote Port interfaces
 	 */




More information about the devel mailing list