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

 drivers/scsi/libfc/fc_lport.c |   13 +++-
 drivers/scsi/libfc/fc_rport.c |  142 ++++-------------------------------------
 2 files changed, 25 insertions(+), 130 deletions(-)

diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 5e3a0e5..dc65e76 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -66,8 +66,17 @@ static int fc_frame_drop(struct fc_lport *lp, struct 
fc_frame *fp)
 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_SUCCESS)
-               fc_lport_enter_reg_pn(lp);
+       if (rp == lp->dns_rp) {
+               switch (event) {
+               case LPORT_EV_RPORT_SUCCESS:
+                       fc_lport_enter_reg_pn(lp);                      
+                       break;
+               case LPORT_EV_RPORT_FAILURE:
+                       printk(KERN_ERR "Failed to log into the name server\n");
+                       lp->tt.lport_logout(lp);
+                       break;
+               }
+       }
 
        return 0;
 }
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 24f8837..08e7191 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -201,7 +201,7 @@ static void fc_rport_state_enter(struct fc_rport *rport,
 int fc_rport_login(struct fc_rport *rport)
 {
        struct fc_rport_libfc_priv *rp = rport->dd_data;
-       struct fc_lport *lp = rp->local_port;
+       int err = 0;
 
        fc_rport_lock(rport);
        if (rp->rp_state == RPORT_ST_INIT) {
@@ -212,26 +212,11 @@ int fc_rport_login(struct fc_rport *rport)
                fc_rport_unlock(rport);
                if (fc_rp_debug)
                        FC_DBG("remote %6x closed", rport->port_id);
-
-               if (rport == lp->dns_rp &&
-                   lp->state != LPORT_ST_RESET) {
-                       fc_lport_lock(lp);
-                       del_timer(&lp->state_timer);
-                       lp->dns_rp = NULL;
-
-                       if (lp->state == LPORT_ST_DNS_STOP) {
-                               fc_lport_unlock(lp);
-                               lp->tt.lport_logout(lp);
-                       } else {
-                               lp->tt.lport_login(lp);
-                               fc_lport_unlock(lp);
-                       }
-                       fc_remote_port_delete(rport);
-               }
+               err = -1;
        } else
                fc_rport_unlock(rport);
 
-       return 0;
+       return err;
 }
 
 /*
@@ -240,7 +225,7 @@ int fc_rport_login(struct fc_rport *rport)
 int fc_rport_logout(struct fc_rport *rport)
 {
        struct fc_rport_libfc_priv *rp = rport->dd_data;
-       struct fc_lport *lp = rp->local_port;
+       int err = 0;
 
        fc_rport_lock(rport);
        switch (rp->rp_state) {
@@ -255,26 +240,11 @@ int fc_rport_logout(struct fc_rport *rport)
                fc_rport_unlock(rport);
                if (fc_rp_debug)
                        FC_DBG("remote %6x closed", rport->port_id);
-               if (rport == lp->dns_rp &&
-                   lp->state != LPORT_ST_RESET) {
-                       fc_lport_lock(lp);
-                       del_timer(&lp->state_timer);
-                       lp->dns_rp = NULL;
-
-                       if (lp->state == LPORT_ST_DNS_STOP) {
-                               fc_lport_unlock(lp);
-                               lp->tt.lport_logout(lp);
-                       } else {
-                               lp->tt.lport_login(lp);
-                               fc_lport_unlock(lp);
-                       }
-
-                       fc_remote_port_delete(rport);
-               }
+               err = -1;
                break;
        }
 
-       return 0;
+       return err;
 }
 
 /*
@@ -283,33 +253,12 @@ int fc_rport_logout(struct fc_rport *rport)
  */
 void fc_rport_reset(struct fc_rport *rport)
 {
-       struct fc_rport_libfc_priv *rp = rport->dd_data;
-       struct fc_lport *lp;
-
        if (fc_rp_debug)
-               FC_DBG("sess to %6x reset", rport->port_id);
-       fc_rport_lock(rport);
+               FC_DBG("remote %6x reset", rport->port_id);
 
-       lp = rp->local_port;
+       fc_rport_lock(rport);
        fc_rport_state_enter(rport, RPORT_ST_INIT);
        fc_rport_unlock(rport);
-
-       if (fc_rp_debug)
-               FC_DBG("remote %6x closed", rport->port_id);
-       if (rport == lp->dns_rp &&
-           lp->state != LPORT_ST_RESET) {
-               fc_lport_lock(lp);
-               del_timer(&lp->state_timer);
-               lp->dns_rp = NULL;
-               if (lp->state == LPORT_ST_DNS_STOP) {
-                       fc_lport_unlock(lp);
-                       lp->tt.lport_logout(lp);
-               } else {
-                       lp->tt.lport_login(lp);
-                       fc_lport_unlock(lp);
-               }
-               fc_remote_port_delete(rport);
-       }
 }
 
 /*
@@ -355,19 +304,9 @@ static void fc_rport_reject(struct fc_rport *rport)
        case RPORT_ST_PLOGI:
        case RPORT_ST_PRLI:
                fc_rport_state_enter(rport, RPORT_ST_ERROR);
-               if (rport == lp->dns_rp &&
-                   lp->state != LPORT_ST_RESET) {
-                       fc_lport_lock(lp);
-                       del_timer(&lp->state_timer);
-                       lp->dns_rp = NULL;
-                       if (lp->state == LPORT_ST_DNS_STOP) {
-                               fc_lport_unlock(lp);
-                               lp->tt.lport_logout(lp);
-                       } else {
-                               lp->tt.lport_login(lp);
-                               fc_lport_unlock(lp);
-                       }
-                       fc_remote_port_delete(rport);
+               if (rport->port_id >= FC_FID_DOM_MGR) {
+                       lp->tt.lport_event_callback(lp, rport,
+                                                   LPORT_EV_RPORT_FAILURE);
                }
                break;
        case RPORT_ST_RTV:
@@ -379,20 +318,6 @@ static void fc_rport_reject(struct fc_rport *rport)
                fc_rport_state_enter(rport, RPORT_ST_INIT);
                if (fc_rp_debug)
                        FC_DBG("remote %6x closed", rport->port_id);
-               if (rport == lp->dns_rp &&
-                   lp->state != LPORT_ST_RESET) {
-                       fc_lport_lock(lp);
-                       del_timer(&lp->state_timer);
-                       lp->dns_rp = NULL;
-                       if (lp->state == LPORT_ST_DNS_STOP) {
-                               fc_lport_unlock(lp);
-                               lp->tt.lport_logout(lp);
-                       } else {
-                               lp->tt.lport_login(lp);
-                               fc_lport_unlock(lp);
-                       }
-                       fc_remote_port_delete(rport);
-               }
                break;
        case RPORT_ST_NONE:
        case RPORT_ST_READY:
@@ -605,7 +530,6 @@ static void fc_rport_prli_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;
        struct {
                struct fc_els_prli prli;
                struct fc_els_spp spp;
@@ -642,19 +566,6 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct 
fc_frame *fp,
                FC_DBG("bad ELS response\n");
                fc_rport_state_enter(rport, RPORT_ST_ERROR);
                fc_rport_unlock(rport);
-               if (rport == lp->dns_rp && lp->state != LPORT_ST_RESET) {
-                       fc_lport_lock(lp);
-                       del_timer(&lp->state_timer);
-                       lp->dns_rp = NULL;
-                       if (lp->state == LPORT_ST_DNS_STOP) {
-                               fc_lport_unlock(lp);
-                               lp->tt.lport_logout(lp);
-                       } else {
-                               lp->tt.lport_login(lp);
-                               fc_lport_unlock(lp);
-                       }
-                       fc_remote_port_delete(rport);
-               }
        }
 
        fc_frame_free(fp);
@@ -670,8 +581,6 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct 
fc_frame *fp,
                               void *rp_arg)
 {
        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)) {
@@ -688,19 +597,6 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct 
fc_frame *fp,
                FC_DBG("bad ELS response\n");
                fc_rport_state_enter(rport, RPORT_ST_ERROR);
                fc_rport_unlock(rport);
-               if (rport == lp->dns_rp && lp->state != LPORT_ST_RESET) {
-                       fc_lport_lock(lp);
-                       del_timer(&lp->state_timer);
-                       lp->dns_rp = NULL;
-                       if (lp->state == LPORT_ST_DNS_STOP) {
-                               fc_lport_unlock(lp);
-                               lp->tt.lport_logout(lp);
-                       } else {
-                               lp->tt.lport_login(lp);
-                               fc_lport_unlock(lp);
-                       }
-                       fc_remote_port_delete(rport);
-               }
        }
 
        fc_frame_free(fp);
@@ -1242,19 +1138,9 @@ static void fc_rport_recv_logo_req(struct fc_rport 
*rport, struct fc_seq *sp,
        fc_rport_unlock(rport);
        if (fc_rp_debug)
                FC_DBG("remote %6x closed", rport->port_id);
-       if (rport == lp->dns_rp &&
-           lp->state != LPORT_ST_RESET) {
-               fc_lport_lock(lp);
-               del_timer(&lp->state_timer);
-               lp->dns_rp = NULL;
-               if (lp->state == LPORT_ST_DNS_STOP) {
-                       fc_lport_unlock(lp);
-                       lp->tt.lport_logout(lp);
-               } else {
-                       lp->tt.lport_login(lp);
-                       fc_lport_unlock(lp);
-               }
-               fc_remote_port_delete(rport);
+       if (rport->port_id >= FC_FID_DOM_MGR) {
+               lp->tt.lport_event_callback(lp, rport,
+                                           LPORT_EV_RPORT_FAILURE);
        }
        lp->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL);
        fc_frame_free(fp);

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

Reply via email to