we just need one routine that checks for errors and retries.

Signed-off-by: Robert Love <[EMAIL PROTECTED]>
---

 drivers/scsi/libfc/fc_rport.c |   99 ++++++++++++-----------------------------
 1 files changed, 28 insertions(+), 71 deletions(-)

diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index f6966d8..3f55587 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -40,7 +40,6 @@ static int fc_rp_debug;
  * static functions.
  */
 static void fc_rport_gpn_id_resp(struct fc_seq *, struct fc_frame *, void *);
-static void fc_rport_ns_error(struct fc_rport *, struct fc_frame *);
 static void fc_rport_gnn_id_resp(struct fc_seq *, struct fc_frame *, void *);
 
 static void fc_rport_enter_gpn_id(struct fc_rport *);
@@ -58,6 +57,7 @@ static void fc_rport_recv_prlo_req(struct fc_rport *,
 static void fc_rport_recv_logo_req(struct fc_rport *,
                                   struct fc_seq *, struct fc_frame *);
 static void fc_rport_timeout(struct work_struct *);
+static void fc_rport_error(struct fc_rport *, struct fc_frame *);
 
 static struct fc_rport *fc_remote_port_create(struct fc_lport *,
                                              struct fc_rport_identifiers *);
@@ -202,12 +202,13 @@ void fc_rport_enter_gpn_id(struct fc_rport *rp)
        WARN_ON(!fc_lport_test_ready(lp));
 
        fc_frame_setup(fp, FC_RCTL_DD_UNSOL_CTL, FC_TYPE_CT);
-       lp->tt.exch_seq_send(lp, fp,
-                            fc_rport_gpn_id_resp,
-                            rp, lp->e_d_tov,
-                            lp->fid,
-                            lp->dns_rp->port_id,
-                            FC_FC_SEQ_INIT | FC_FC_END_SEQ);
+       if (!lp->tt.exch_seq_send(lp, fp,
+                                 fc_rport_gpn_id_resp,
+                                 rp, lp->e_d_tov,
+                                 lp->fid,
+                                 lp->dns_rp->port_id,
+                                 FC_FC_SEQ_INIT | FC_FC_END_SEQ))
+               fc_rport_error(rp, fp);
 }
 
 /**
@@ -230,7 +231,7 @@ static void fc_rport_gpn_id_resp(struct fc_seq *sp, struct 
fc_frame *fp,
        unsigned int cmd;
 
        if (IS_ERR(fp)) {
-               fc_rport_ns_error(rp, fp);
+               fc_rport_error(rp, fp);
                return;
        }
 
@@ -303,12 +304,13 @@ void fc_rport_enter_gnn_id(struct fc_rport *rp)
        WARN_ON(!fc_lport_test_ready(lp));
 
        fc_frame_setup(fp, FC_RCTL_DD_UNSOL_CTL, FC_TYPE_CT);
-       lp->tt.exch_seq_send(lp, fp,
-                            fc_rport_gnn_id_resp,
-                            rp, lp->e_d_tov,
-                            lp->fid,
-                            lp->dns_rp->port_id,
-                            FC_FC_SEQ_INIT | FC_FC_END_SEQ);
+       if (!lp->tt.exch_seq_send(lp, fp,
+                                 fc_rport_gnn_id_resp,
+                                 rp, lp->e_d_tov,
+                                 lp->fid,
+                                 lp->dns_rp->port_id,
+                                 FC_FC_SEQ_INIT | FC_FC_END_SEQ))
+               fc_rport_error(rp, fp);
 }
 
 /**
@@ -334,7 +336,7 @@ static void fc_rport_gnn_id_resp(struct fc_seq *sp, struct 
fc_frame *fp,
        rpp = rp->dd_data;
 
        if (IS_ERR(fp)) {
-               fc_rport_ns_error(rp, fp);
+               fc_rport_error(rp, fp);
                return;
        }
 
@@ -396,27 +398,6 @@ static void fc_rport_gnn_id_resp(struct fc_seq *sp, struct 
fc_frame *fp,
 }
 
 /**
- * fc_rport_ns_error - Handle error from GNN_ID
- * @dp: Temporary discovery port for holding IDs and world wide names
- * @fp: response frame
- */
-static void fc_rport_ns_error(struct fc_rport *rp, struct fc_frame *fp)
-{
-       struct fc_rport_libfc_priv *rpp = rp->dd_data;
-       struct fc_lport *lp = rpp->local_port;
-
-       switch (PTR_ERR(fp)) {
-       case -FC_EX_TIMEOUT:
-               lp->tt.lport_event_callback(lp, rp, LPORT_EV_RPORT_FAILED);
-               fc_rport_destroy_dummy(rp);
-               break;
-       case -FC_EX_CLOSED:
-       default:
-               break;
-       }
-}
-
-/**
  * fc_plogi_get_maxframe - Get max payload from the common service parameters
  * @flp: FLOGI payload structure
  * @maxval: upper limit, may be less than what is in the service parameters
@@ -711,45 +692,21 @@ static void fc_rport_timeout(struct work_struct *work)
 }
 
 /*
- * Handle retry for allocation failure via timeout.
- */
-static void fc_rport_retry(struct fc_rport *rport)
-{
-       struct fc_rport_libfc_priv *rp = rport->dd_data;
-       struct fc_lport *lp = rp->local_port;
-
-       if (rp->retries < lp->max_retry_count) {
-               rp->retries++;
-               get_device(&rport->dev);
-               schedule_delayed_work(&rp->retry_work,
-                                     msecs_to_jiffies(rp->e_d_tov));
-       } else {
-               FC_DBG("sess %6x alloc failure in state %d, "
-                      "retries exhausted\n",
-                      rport->port_id, rp->rp_state);
-               fc_rport_reject(rport);
-       }
-}
-
-/*
  * Handle error from a sequence issued by the rport state machine.
  */
 static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp)
 {
        struct fc_rport_libfc_priv *rp = rport->dd_data;
-       fc_rport_lock(rport);
        if (fc_rp_debug)
                FC_DBG("state %d error %ld retries %d\n",
                       rp->rp_state, PTR_ERR(fp), rp->retries);
 
-       if (PTR_ERR(fp) == -FC_EX_TIMEOUT &&
-           rp->retries++ >= rp->local_port->max_retry_count) {
+       if (((!fp) || (PTR_ERR(fp) == -FC_EX_TIMEOUT)) &&
+           rp->retries < rp->local_port->max_retry_count) {
                get_device(&rport->dev);
                schedule_delayed_work(&rp->retry_work, 0);
        } else
                fc_rport_reject(rport);
-
-       fc_rport_unlock(rport);
 }
 
 /**
@@ -801,7 +758,7 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct 
fc_frame *fp,
                        rjp = fc_frame_payload_get(fp, sizeof(*rjp));
                        if (op == ELS_LS_RJT && rjp != NULL &&
                            rjp->er_reason == ELS_RJT_INPROG)
-                               fc_rport_retry(rport);    /* try again */
+                               fc_rport_error(rport, fp);    /* try again */
                        else
                                fc_rport_reject(rport);   /* error */
                }
@@ -831,7 +788,7 @@ static void fc_rport_enter_plogi(struct fc_rport *rport)
        rport->maxframe_size = FC_MIN_MAX_PAYLOAD;
        fp = fc_frame_alloc(lp, sizeof(*plogi));
        if (!fp)
-               return fc_rport_retry(rport);
+               return fc_rport_error(rport, fp);
        plogi = fc_frame_payload_get(fp, sizeof(*plogi));
        WARN_ON(!plogi);
        fc_lport_plogi_fill(rp->local_port, plogi, ELS_PLOGI);
@@ -843,7 +800,7 @@ static void fc_rport_enter_plogi(struct fc_rport *rport)
                                  rp->local_port->fid,
                                  rport->port_id,
                                  FC_FC_SEQ_INIT | FC_FC_END_SEQ))
-               fc_rport_retry(rport);
+               fc_rport_error(rport, fp);
 }
 
 /**
@@ -996,7 +953,7 @@ static void fc_rport_enter_prli(struct fc_rport *rport)
        }
        fp = fc_frame_alloc(lp, sizeof(*pp));
        if (!fp)
-               return fc_rport_retry(rport);
+               return fc_rport_error(rport, fp);
        pp = fc_frame_payload_get(fp, sizeof(*pp));
        WARN_ON(!pp);
        memset(pp, 0, sizeof(*pp));
@@ -1013,7 +970,7 @@ static void fc_rport_enter_prli(struct fc_rport *rport)
                                  rp->local_port->fid,
                                  rport->port_id,
                                  FC_FC_SEQ_INIT | FC_FC_END_SEQ))
-               fc_rport_retry(rport);
+               fc_rport_error(rport, fp);
 }
 
 /**
@@ -1085,7 +1042,7 @@ static void fc_rport_enter_rtv(struct fc_rport *rport)
 
        fp = fc_frame_alloc(lp, sizeof(*rtv));
        if (!fp)
-               return fc_rport_retry(rport);
+               return fc_rport_error(rport, fp);
        rtv = fc_frame_payload_get(fp, sizeof(*rtv));
        WARN_ON(!rtv);
        memset(rtv, 0, sizeof(*rtv));
@@ -1097,7 +1054,7 @@ static void fc_rport_enter_rtv(struct fc_rport *rport)
                                  rp->local_port->fid,
                                  rport->port_id,
                                  FC_FC_SEQ_INIT | FC_FC_END_SEQ))
-               fc_rport_retry(rport);
+               fc_rport_error(rport, fp);
 }
 
 /**
@@ -1119,7 +1076,7 @@ static void fc_rport_enter_logo(struct fc_rport *rport)
        lp = rp->local_port;
        fp = fc_frame_alloc(lp, sizeof(*logo));
        if (!fp)
-               return fc_rport_retry(rport);
+               return fc_rport_error(rport, fp);
        logo = fc_frame_payload_get(fp, sizeof(*logo));
        memset(logo, 0, sizeof(*logo));
        logo->fl_cmd = ELS_LOGO;
@@ -1133,7 +1090,7 @@ static void fc_rport_enter_logo(struct fc_rport *rport)
                                  rp->local_port->fid,
                                  rport->port_id,
                                  FC_FC_SEQ_INIT | FC_FC_END_SEQ))
-               fc_rport_retry(rport);
+               fc_rport_error(rport, fp);
 }
 
 /*

_______________________________________________
devel mailing list
[email protected]
http://www.open-fcoe.org/mailman/listinfo/devel

Reply via email to