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

Robert Love robert.w.love at intel.com
Thu Sep 11 23:35:10 UTC 2008


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 6d0c970..c7360db 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 *);
@@ -329,6 +330,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;
@@ -371,16 +391,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);
@@ -715,16 +726,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));
@@ -762,7 +764,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)) {
@@ -792,17 +793,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);
 }
 
@@ -1190,16 +1183,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