This removes some NS checks and doesn't call into
the lport code except for sending events.

Also adds a LOGO event for the rport.

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

 drivers/scsi/libfc/fc_lport.c |    1 
 drivers/scsi/libfc/fc_rport.c |  157 ++++++++++++++---------------------------
 include/scsi/libfc/libfc.h    |    3 +
 3 files changed, 55 insertions(+), 106 deletions(-)

diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index bdd2760..ec2f1f3 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -67,6 +67,7 @@ static void fc_lport_rport_event(struct fc_lport *lport, 
struct fc_rport *rport,
                case LPORT_EV_RPORT_CREATED:
                        lport->tt.dns_register(lport);
                        break;
+               case LPORT_EV_RPORT_LOGO:
                case LPORT_EV_RPORT_FAILED:
                        fc_lport_enter_reset(lport);
                        break;
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 1aeff00..df32db7 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -222,35 +222,24 @@ 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;
+       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_lport *lport = rdata->local_port;
 
        fc_rport_lock(rport);
-       if (rp->rp_state == RPORT_ST_INIT) {
+       if (rdata->rp_state == RPORT_ST_INIT) {
                fc_rport_unlock(rport);
-               if (rport == lp->dns_rp || fc_lport_test_ready(lp))
-                       fc_rport_enter_plogi(rport);
-       } else if (rp->rp_state == RPORT_ST_ERROR) {
+               fc_rport_enter_plogi(rport);
+       } else if (rdata->rp_state == RPORT_ST_ERROR) {
                fc_rport_state_enter(rport, RPORT_ST_INIT);
                fc_rport_unlock(rport);
                if (fc_rp_debug)
                        FC_DBG("remote %6x closed\n", 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 (rdata->event_callback)
+                       rdata->event_callback(lport, rport,
+                                             LPORT_EV_RPORT_FAILED);
+
+               fc_remote_port_delete(rport);
        } else
                fc_rport_unlock(rport);
 
@@ -262,11 +251,11 @@ 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;
+       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_lport *lport = rdata->local_port;
 
        fc_rport_lock(rport);
-       switch (rp->rp_state) {
+       switch (rdata->rp_state) {
        case RPORT_ST_PRLI:
        case RPORT_ST_RTV:
        case RPORT_ST_READY:
@@ -278,22 +267,12 @@ int fc_rport_logout(struct fc_rport *rport)
                fc_rport_unlock(rport);
                if (fc_rp_debug)
                        FC_DBG("remote %6x closed\n", 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);
-                       }
+
+               if (rdata->event_callback)
+                       rdata->event_callback(lport, rport,
+                                             LPORT_EV_RPORT_FAILED);
 
                        fc_remote_port_delete(rport);
-               }
                break;
        }
 
@@ -306,33 +285,23 @@ 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;
+       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_lport *lport = rdata->local_port;
 
        if (fc_rp_debug)
                FC_DBG("sess to %6x reset\n", rport->port_id);
-       fc_rport_lock(rport);
 
-       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\n", 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 (rdata->event_callback)
+               rdata->event_callback(lport, rport, LPORT_EV_RPORT_FAILED);
+
+       fc_remote_port_delete(rport);
 }
 
 /*
@@ -577,8 +546,8 @@ static void fc_rport_prli_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;
+       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_lport *lport = rdata->local_port;
        struct {
                struct fc_els_prli prli;
                struct fc_els_spp spp;
@@ -599,7 +568,7 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct 
fc_frame *fp,
                if (pp && pp->prli.prli_spp_len >= sizeof(pp->spp)) {
                        fcp_parm = ntohl(pp->spp.spp_params);
                        if (fcp_parm & FCP_SPPF_RETRY)
-                               rp->flags |= FC_RP_FLAGS_RETRY;
+                               rdata->flags |= FC_RP_FLAGS_RETRY;
                }
 
                rport->supported_classes = FC_COS_CLASS3;
@@ -608,26 +577,19 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct 
fc_frame *fp,
                if (fcp_parm & FCP_SPPF_TARG_FCN)
                        roles |= FC_RPORT_ROLE_FCP_TARGET;
 
-               rp->roles = roles;
+               rdata->roles = roles;
                fc_rport_enter_rtv(rport);
                fc_rport_unlock(rport);
        } else {
                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);
-               }
+
+               if (rdata->event_callback)
+                       rdata->event_callback(lport, rport,
+                                             LPORT_EV_RPORT_FAILED);
+
+               fc_remote_port_delete(rport);
        }
 
        fc_frame_free(fp);
@@ -643,8 +605,8 @@ 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;
+       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_lport *lport = rdata->local_port;
        u8 op;
 
        if (IS_ERR(fp)) {
@@ -661,19 +623,12 @@ 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);
-               }
+
+               if (rdata->event_callback)
+                       rdata->event_callback(lport, rport,
+                                             LPORT_EV_RPORT_LOGO);
+
+               fc_remote_port_delete(rport);
        }
 
        fc_frame_free(fp);
@@ -1193,8 +1148,8 @@ static void fc_rport_recv_logo_req(struct fc_rport 
*rport, struct fc_seq *sp,
                                   struct fc_frame *fp)
 {
        struct fc_frame_header *fh;
-       struct fc_rport_libfc_priv *rp = rport->dd_data;
-       struct fc_lport *lp = rp->local_port;
+       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_lport *lport = rdata->local_port;
 
        fh = fc_frame_header_get(fp);
        fc_rport_lock(rport);
@@ -1202,21 +1157,13 @@ 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\n", 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);
-       }
-       lp->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL);
+
+       if (rdata->event_callback)
+               rdata->event_callback(lport, rport, LPORT_EV_RPORT_LOGO);
+
+       fc_remote_port_delete(rport);
+
+       lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL);
        fc_frame_free(fp);
 }
 
diff --git a/include/scsi/libfc/libfc.h b/include/scsi/libfc/libfc.h
index 4ae64ea..d738ebc 100644
--- a/include/scsi/libfc/libfc.h
+++ b/include/scsi/libfc/libfc.h
@@ -103,7 +103,8 @@ enum fc_lport_state {
 
 enum fc_lport_event {
        LPORT_EV_RPORT_CREATED = 0,
-       LPORT_EV_RPORT_FAILED
+       LPORT_EV_RPORT_FAILED,
+       LPORT_EV_RPORT_LOGO
 };
 
 enum fc_rport_state {

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

Reply via email to