[Open-FCoE] [RFC PATCH 01/15] libfc: Add a callback to the fc_lport for fc_rport events

Robert Love robert.w.love at intel.com
Tue Sep 2 22:36: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 |   12 ++++++++++++
 drivers/scsi/libfc/fc_rport.c |   12 +++++-------
 include/scsi/libfc/libfc.h    |    7 +++++++
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 1cbc2b4..f9f5ce3 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -58,6 +58,15 @@ static int fc_frame_drop(struct fc_lport *lp, struct fc_frame *fp)
 	return 0;
 }
 
+static int fc_lport_event_callback(struct fc_lport *lp, struct fc_rport *rp,
+				   enum fc_lport_event event)
+{
+	if (rp == lp->dns_rp && event == LPORT_EV_RPORT_CREATED)
+		lp->tt.dns_register(lp);
+
+	return 0;
+}
+
 static const char *fc_lport_state(struct fc_lport *lp)
 {
 	const char *cp;
@@ -909,6 +918,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_callback)
+		lp->tt.lport_event_callback = fc_lport_event_callback;
+
 	return 0;
 }
 EXPORT_SYMBOL(fc_lport_init);
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index f751f0e..0d6be63 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -718,13 +718,11 @@ static void fc_rport_enter_prli(struct fc_rport *rport)
 		fc_rport_state_enter(rport, RPORT_ST_READY);
 		if (fc_rp_debug)
 			FC_DBG("remote %6x ready", rport->port_id);
-		if (rport == lp->dns_rp &&
-		    lp->state == LPORT_ST_DNS) {
-			fc_lport_lock(lp);
-			del_timer(&lp->state_timer);
-			lp->tt.dns_register(lp);
-			fc_lport_unlock(lp);
-		}
+
+		fc_lport_lock(lp);
+		del_timer(&lp->state_timer);
+		lp->tt.lport_event_callback(lp, rport, LPORT_EV_RPORT_CREATED);
+		fc_lport_unlock(lp);
 		return;
 	}
 	fp = fc_frame_alloc(lp, sizeof(*pp));
diff --git a/include/scsi/libfc/libfc.h b/include/scsi/libfc/libfc.h
index de68c44..29b11b9 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 */
@@ -314,6 +319,8 @@ struct libfc_function_template {
 	int (*lport_login)(struct fc_lport *);
 	int (*lport_reset)(struct fc_lport *);
 	int (*lport_logout)(struct fc_lport *);
+	int (*lport_event_callback)(struct fc_lport *, struct fc_rport *,
+				    enum fc_lport_event);
 
 	/**
 	 * Remote Port interfaces




More information about the devel mailing list