[Open-FCoE] [PATCH 01/28] libfc: Add a READY state and _enter_* function

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


I want to have one place where we know that the rport
is READY. In this state we can notifiy anyone who cares
that the rport is ready. We want to do a rport_login()
and allow the rport to either enter READY or fail. This
the success case.

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

 drivers/scsi/libfc/fc_rport.c |   66 ++++++++++++++++-------------------------
 1 files changed, 25 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 5dd0c54..6724800 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -43,6 +43,7 @@ static void fc_rport_enter_start(struct fc_rport *);
 static void fc_rport_enter_plogi(struct fc_rport *);
 static void fc_rport_enter_prli(struct fc_rport *);
 static void fc_rport_enter_rtv(struct fc_rport *);
+static void fc_rport_enter_ready(struct fc_rport *);
 static void fc_rport_enter_logo(struct fc_rport *);
 static void fc_rport_recv_plogi_req(struct fc_rport *,
 				    struct fc_seq *, struct fc_frame *);
@@ -343,6 +344,25 @@ void fc_rport_reset_list(struct fc_lport *lp)
 	spin_unlock_irqrestore(shost->host_lock, flags);
 }
 
+static void fc_rport_enter_ready(struct fc_rport *rport)
+{
+	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_lport *lport = rdata->local_port;
+
+	fc_rport_state_enter(rport, RPORT_ST_READY);
+
+	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);
+	}
+}
+
 static void fc_rport_enter_start(struct fc_rport *rport)
 {
 	struct fc_rport_libfc_priv *rp = rport->dd_data;
@@ -385,16 +405,7 @@ static void fc_rport_reject(struct fc_rport *rport)
 		}
 		break;
 	case RPORT_ST_RTV:
-		fc_rport_state_enter(rport, RPORT_ST_READY);
-		if (fc_rp_debug)
-			FC_DBG("remote %6x ready\n", 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_rport_enter_ready(rport);
 		break;
 	case RPORT_ST_LOGO:
 		fc_rport_state_enter(rport, RPORT_ST_INIT);
@@ -729,16 +740,7 @@ static void fc_rport_enter_prli(struct fc_rport *rport)
 	 * This should be made more general, possibly moved to the FCP layer.
 	 */
 	if (rport->port_id >= FC_FID_DOM_MGR) {
-		fc_rport_state_enter(rport, RPORT_ST_READY);
-		if (fc_rp_debug)
-			FC_DBG("remote %6x ready\n", 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_rport_enter_ready(rport);
 		return;
 	}
 	fp = fc_frame_alloc(lp, sizeof(*pp));
@@ -776,7 +778,6 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp,
 {
 	struct fc_rport *rport = rp_arg;
 	struct fc_rport_libfc_priv *rp = rport->dd_data;
-	struct fc_lport *lp = rp->local_port;
 	u8 op;
 
 	if (IS_ERR(fp)) {
@@ -806,17 +807,9 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp,
 			rp->e_d_tov = tov;
 		}
 	}
-	fc_rport_state_enter(rport, RPORT_ST_READY);
+
+	fc_rport_enter_ready(rport);
 	fc_rport_unlock(rport);
-	if (fc_rp_debug)
-		FC_DBG("remote %6x ready\n", 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_frame_free(fp);
 }
 
@@ -1204,16 +1197,7 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport,
 		switch (rp->rp_state) {
 		case RPORT_ST_PLOGI_RECV:
 		case RPORT_ST_PRLI:
-			fc_rport_state_enter(rport, RPORT_ST_READY);
-			if (fc_rp_debug)
-				FC_DBG("remote %6x ready\n", 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_rport_enter_ready(rport);
 			break;
 		case RPORT_ST_READY:
 			break;




More information about the devel mailing list