[SCSI] libfc: change interface for rport_create
[deliverable/linux.git] / drivers / scsi / libfc / fc_rport.c
index 7bfbff7e0efb256656d1ef6ce8a5e8ac68fa9c69..2fbc94aaf343e1d42af78cabd6c0b10118e60ba5 100644 (file)
 #include <scsi/libfc.h>
 #include <scsi/fc_encode.h>
 
-static int fc_rport_debug;
-
-#define FC_DEBUG_RPORT(fmt...)                 \
-       do {                                    \
-               if (fc_rport_debug)             \
-                       FC_DBG(fmt);            \
-       } while (0)
-
 struct workqueue_struct *rport_event_queue;
 
 static void fc_rport_enter_plogi(struct fc_rport *);
@@ -85,26 +77,27 @@ static void fc_rport_error_retry(struct fc_rport *, struct fc_frame *);
 static void fc_rport_work(struct work_struct *);
 
 static const char *fc_rport_state_names[] = {
-       [RPORT_ST_NONE] = "None",
        [RPORT_ST_INIT] = "Init",
        [RPORT_ST_PLOGI] = "PLOGI",
        [RPORT_ST_PRLI] = "PRLI",
        [RPORT_ST_RTV] = "RTV",
        [RPORT_ST_READY] = "Ready",
        [RPORT_ST_LOGO] = "LOGO",
+       [RPORT_ST_DELETE] = "Delete",
 };
 
 static void fc_rport_rogue_destroy(struct device *dev)
 {
        struct fc_rport *rport = dev_to_rport(dev);
-       FC_DEBUG_RPORT("Destroying rogue rport (%6x)\n", rport->port_id);
+       FC_RPORT_DBG(rport, "Destroying rogue rport\n");
        kfree(rport);
 }
 
-struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
+struct fc_rport *fc_rport_rogue_create(struct fc_lport *lport,
+                                      struct fc_rport_identifiers *ids)
 {
        struct fc_rport *rport;
-       struct fc_rport_libfc_priv *rdata;
+       struct fc_rport_priv *rdata;
        rport = kzalloc(sizeof(*rport) + sizeof(*rdata), GFP_KERNEL);
 
        if (!rport)
@@ -113,10 +106,10 @@ struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
        rdata = RPORT_TO_PRIV(rport);
 
        rport->dd_data = rdata;
-       rport->port_id = dp->ids.port_id;
-       rport->port_name = dp->ids.port_name;
-       rport->node_name = dp->ids.node_name;
-       rport->roles = dp->ids.roles;
+       rport->port_id = ids->port_id;
+       rport->port_name = ids->port_name;
+       rport->node_name = ids->node_name;
+       rport->roles = ids->roles;
        rport->maxframe_size = FC_MIN_MAX_PAYLOAD;
        /*
         * Note: all this libfc rogue rport code will be removed for
@@ -126,14 +119,14 @@ struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
        rport->dev.release = fc_rport_rogue_destroy;
 
        mutex_init(&rdata->rp_mutex);
-       rdata->local_port = dp->lp;
+       rdata->local_port = lport;
        rdata->trans_state = FC_PORTSTATE_ROGUE;
        rdata->rp_state = RPORT_ST_INIT;
        rdata->event = RPORT_EV_NONE;
        rdata->flags = FC_RP_FLAGS_REC_SUPPORTED;
        rdata->ops = NULL;
-       rdata->e_d_tov = dp->lp->e_d_tov;
-       rdata->r_a_tov = dp->lp->r_a_tov;
+       rdata->e_d_tov = lport->e_d_tov;
+       rdata->r_a_tov = lport->r_a_tov;
        INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout);
        INIT_WORK(&rdata->event_work, fc_rport_work);
        /*
@@ -152,7 +145,7 @@ struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
 static const char *fc_rport_state(struct fc_rport *rport)
 {
        const char *cp;
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
 
        cp = fc_rport_state_names[rdata->rp_state];
        if (!cp)
@@ -207,7 +200,7 @@ static unsigned int fc_plogi_get_maxframe(struct fc_els_flogi *flp,
 static void fc_rport_state_enter(struct fc_rport *rport,
                                 enum fc_rport_state new)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        if (rdata->rp_state != new)
                rdata->retries = 0;
        rdata->rp_state = new;
@@ -216,8 +209,8 @@ static void fc_rport_state_enter(struct fc_rport *rport,
 static void fc_rport_work(struct work_struct *work)
 {
        u32 port_id;
-       struct fc_rport_libfc_priv *rdata =
-               container_of(work, struct fc_rport_libfc_priv, event_work);
+       struct fc_rport_priv *rdata =
+               container_of(work, struct fc_rport_priv, event_work);
        enum fc_rport_event event;
        enum fc_rport_trans_state trans_state;
        struct fc_lport *lport = rdata->local_port;
@@ -230,7 +223,7 @@ static void fc_rport_work(struct work_struct *work)
 
        if (event == RPORT_EV_CREATED) {
                struct fc_rport *new_rport;
-               struct fc_rport_libfc_priv *new_rdata;
+               struct fc_rport_priv *new_rdata;
                struct fc_rport_identifiers ids;
 
                ids.port_id = rport->port_id;
@@ -238,6 +231,7 @@ static void fc_rport_work(struct work_struct *work)
                ids.port_name = rport->port_name;
                ids.node_name = rport->node_name;
 
+               rdata->event = RPORT_EV_NONE;
                mutex_unlock(&rdata->rp_mutex);
 
                new_rport = fc_remote_port_add(lport->host, 0, &ids);
@@ -263,8 +257,8 @@ static void fc_rport_work(struct work_struct *work)
 
                        fc_rport_state_enter(new_rport, RPORT_ST_READY);
                } else {
-                       FC_DBG("Failed to create the rport for port "
-                              "(%6x).\n", ids.port_id);
+                       printk(KERN_WARNING "libfc: Failed to allocate "
+                              " memory for rport (%6x)\n", ids.port_id);
                        event = RPORT_EV_FAILED;
                }
                if (rport->port_id != FC_FID_DIR_SERV)
@@ -283,6 +277,7 @@ static void fc_rport_work(struct work_struct *work)
                mutex_unlock(&rdata->rp_mutex);
                if (rport_ops->event_callback)
                        rport_ops->event_callback(lport, rport, event);
+               cancel_delayed_work_sync(&rdata->retry_work);
                if (trans_state == FC_PORTSTATE_ROGUE)
                        put_device(&rport->dev);
                else {
@@ -305,11 +300,11 @@ static void fc_rport_work(struct work_struct *work)
  */
 int fc_rport_login(struct fc_rport *rport)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
 
        mutex_lock(&rdata->rp_mutex);
 
-       FC_DEBUG_RPORT("Login to port (%6x)\n", rport->port_id);
+       FC_RPORT_DBG(rport, "Login to port\n");
 
        fc_rport_enter_plogi(rport);
 
@@ -318,6 +313,37 @@ int fc_rport_login(struct fc_rport *rport)
        return 0;
 }
 
+/**
+ * fc_rport_enter_delete() - schedule a remote port to be deleted.
+ * @rport: Fibre Channel remote port
+ * @event: event to report as the reason for deletion
+ *
+ * Locking Note: Called with the rport lock held.
+ *
+ * Allow state change into DELETE only once.
+ *
+ * Call queue_work only if there's no event already pending.
+ * Set the new event so that the old pending event will not occur.
+ * Since we have the mutex, even if fc_rport_work() is already started,
+ * it'll see the new event.
+ */
+static void fc_rport_enter_delete(struct fc_rport *rport,
+                                 enum fc_rport_event event)
+{
+       struct fc_rport_priv *rdata = rport->dd_data;
+
+       if (rdata->rp_state == RPORT_ST_DELETE)
+               return;
+
+       FC_RPORT_DBG(rport, "Delete port\n");
+
+       fc_rport_state_enter(rport, RPORT_ST_DELETE);
+
+       if (rdata->event == RPORT_EV_NONE)
+               queue_work(rport_event_queue, &rdata->event_work);
+       rdata->event = event;
+}
+
 /**
  * fc_rport_logoff() - Logoff and remove an rport
  * @rport: Fibre Channel remote port to be removed
@@ -328,17 +354,14 @@ int fc_rport_login(struct fc_rport *rport)
  */
 int fc_rport_logoff(struct fc_rport *rport)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
-       struct fc_lport *lport = rdata->local_port;
+       struct fc_rport_priv *rdata = rport->dd_data;
 
        mutex_lock(&rdata->rp_mutex);
 
-       FC_DEBUG_RPORT("Remove port (%6x)\n", rport->port_id);
+       FC_RPORT_DBG(rport, "Remove port\n");
 
-       if (rdata->rp_state == RPORT_ST_NONE) {
-               FC_DEBUG_RPORT("(%6x): Port (%6x) in NONE state,"
-                              " not removing", fc_host_port_id(lport->host),
-                              rport->port_id);
+       if (rdata->rp_state == RPORT_ST_DELETE) {
+               FC_RPORT_DBG(rport, "Port in Delete state, not removing\n");
                mutex_unlock(&rdata->rp_mutex);
                goto out;
        }
@@ -346,20 +369,10 @@ int fc_rport_logoff(struct fc_rport *rport)
        fc_rport_enter_logo(rport);
 
        /*
-        * Change the state to NONE so that we discard
+        * Change the state to Delete so that we discard
         * the response.
         */
-       fc_rport_state_enter(rport, RPORT_ST_NONE);
-
-       mutex_unlock(&rdata->rp_mutex);
-
-       cancel_delayed_work_sync(&rdata->retry_work);
-
-       mutex_lock(&rdata->rp_mutex);
-
-       rdata->event = RPORT_EV_STOP;
-       queue_work(rport_event_queue, &rdata->event_work);
-
+       fc_rport_enter_delete(rport, RPORT_EV_STOP);
        mutex_unlock(&rdata->rp_mutex);
 
 out:
@@ -375,19 +388,20 @@ out:
  */
 static void fc_rport_enter_ready(struct fc_rport *rport)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
 
        fc_rport_state_enter(rport, RPORT_ST_READY);
 
-       FC_DEBUG_RPORT("Port (%6x) is Ready\n", rport->port_id);
+       FC_RPORT_DBG(rport, "Port is Ready\n");
 
+       if (rdata->event == RPORT_EV_NONE)
+               queue_work(rport_event_queue, &rdata->event_work);
        rdata->event = RPORT_EV_CREATED;
-       queue_work(rport_event_queue, &rdata->event_work);
 }
 
 /**
  * fc_rport_timeout() - Handler for the retry_work timer.
- * @work: The work struct of the fc_rport_libfc_priv
+ * @work: The work struct of the fc_rport_priv
  *
  * Locking Note: Called without the rport lock held. This
  * function will hold the rport lock, call an _enter_*
@@ -395,8 +409,8 @@ static void fc_rport_enter_ready(struct fc_rport *rport)
  */
 static void fc_rport_timeout(struct work_struct *work)
 {
-       struct fc_rport_libfc_priv *rdata =
-               container_of(work, struct fc_rport_libfc_priv, retry_work.work);
+       struct fc_rport_priv *rdata =
+               container_of(work, struct fc_rport_priv, retry_work.work);
        struct fc_rport *rport = PRIV_TO_RPORT(rdata);
 
        mutex_lock(&rdata->rp_mutex);
@@ -416,12 +430,11 @@ static void fc_rport_timeout(struct work_struct *work)
                break;
        case RPORT_ST_READY:
        case RPORT_ST_INIT:
-       case RPORT_ST_NONE:
+       case RPORT_ST_DELETE:
                break;
        }
 
        mutex_unlock(&rdata->rp_mutex);
-       put_device(&rport->dev);
 }
 
 /**
@@ -434,24 +447,21 @@ static void fc_rport_timeout(struct work_struct *work)
  */
 static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
 
-       FC_DEBUG_RPORT("Error %ld in state %s, retries %d\n",
-                      PTR_ERR(fp), fc_rport_state(rport), rdata->retries);
+       FC_RPORT_DBG(rport, "Error %ld in state %s, retries %d\n",
+                    PTR_ERR(fp), fc_rport_state(rport), rdata->retries);
 
        switch (rdata->rp_state) {
        case RPORT_ST_PLOGI:
        case RPORT_ST_PRLI:
        case RPORT_ST_LOGO:
-               rdata->event = RPORT_EV_FAILED;
-               fc_rport_state_enter(rport, RPORT_ST_NONE);
-               queue_work(rport_event_queue,
-                          &rdata->event_work);
+               fc_rport_enter_delete(rport, RPORT_EV_FAILED);
                break;
        case RPORT_ST_RTV:
                fc_rport_enter_ready(rport);
                break;
-       case RPORT_ST_NONE:
+       case RPORT_ST_DELETE:
        case RPORT_ST_READY:
        case RPORT_ST_INIT:
                break;
@@ -471,7 +481,7 @@ static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp)
  */
 static void fc_rport_error_retry(struct fc_rport *rport, struct fc_frame *fp)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        unsigned long delay = FC_DEF_E_D_TOV;
 
        /* make sure this isn't an FC_EX_CLOSED error, never retry those */
@@ -479,13 +489,12 @@ static void fc_rport_error_retry(struct fc_rport *rport, struct fc_frame *fp)
                return fc_rport_error(rport, fp);
 
        if (rdata->retries < rdata->local_port->max_rport_retry_count) {
-               FC_DEBUG_RPORT("Error %ld in state %s, retrying\n",
-                              PTR_ERR(fp), fc_rport_state(rport));
+               FC_RPORT_DBG(rport, "Error %ld in state %s, retrying\n",
+                            PTR_ERR(fp), fc_rport_state(rport));
                rdata->retries++;
                /* no additional delay on exchange timeouts */
                if (PTR_ERR(fp) == -FC_EX_TIMEOUT)
                        delay = 0;
-               get_device(&rport->dev);
                schedule_delayed_work(&rdata->retry_work, delay);
                return;
        }
@@ -507,7 +516,7 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp,
                                void *rp_arg)
 {
        struct fc_rport *rport = rp_arg;
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
        struct fc_els_flogi *plp = NULL;
        unsigned int tov;
@@ -517,12 +526,11 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp,
 
        mutex_lock(&rdata->rp_mutex);
 
-       FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n",
-                      rport->port_id);
+       FC_RPORT_DBG(rport, "Received a PLOGI response\n");
 
        if (rdata->rp_state != RPORT_ST_PLOGI) {
-               FC_DBG("Received a PLOGI response, but in state %s\n",
-                      fc_rport_state(rport));
+               FC_RPORT_DBG(rport, "Received a PLOGI response, but in state "
+                            "%s\n", fc_rport_state(rport));
                if (IS_ERR(fp))
                        goto err;
                goto out;
@@ -579,12 +587,12 @@ err:
  */
 static void fc_rport_enter_plogi(struct fc_rport *rport)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
        struct fc_frame *fp;
 
-       FC_DEBUG_RPORT("Port (%6x) entered PLOGI state from %s state\n",
-                      rport->port_id, fc_rport_state(rport));
+       FC_RPORT_DBG(rport, "Port entered PLOGI state from %s state\n",
+                    fc_rport_state(rport));
 
        fc_rport_state_enter(rport, RPORT_ST_PLOGI);
 
@@ -617,7 +625,7 @@ 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 *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct {
                struct fc_els_prli prli;
                struct fc_els_spp spp;
@@ -628,12 +636,11 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp,
 
        mutex_lock(&rdata->rp_mutex);
 
-       FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n",
-                      rport->port_id);
+       FC_RPORT_DBG(rport, "Received a PRLI response\n");
 
        if (rdata->rp_state != RPORT_ST_PRLI) {
-               FC_DBG("Received a PRLI response, but in state %s\n",
-                      fc_rport_state(rport));
+               FC_RPORT_DBG(rport, "Received a PRLI response, but in state "
+                            "%s\n", fc_rport_state(rport));
                if (IS_ERR(fp))
                        goto err;
                goto out;
@@ -663,10 +670,8 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp,
                fc_rport_enter_rtv(rport);
 
        } else {
-               FC_DBG("Bad ELS response\n");
-               rdata->event = RPORT_EV_FAILED;
-               fc_rport_state_enter(rport, RPORT_ST_NONE);
-               queue_work(rport_event_queue, &rdata->event_work);
+               FC_RPORT_DBG(rport, "Bad ELS response for PRLI command\n");
+               fc_rport_enter_delete(rport, RPORT_EV_FAILED);
        }
 
 out:
@@ -690,17 +695,16 @@ 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 *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        u8 op;
 
        mutex_lock(&rdata->rp_mutex);
 
-       FC_DEBUG_RPORT("Received a LOGO response from port (%6x)\n",
-                      rport->port_id);
+       FC_RPORT_DBG(rport, "Received a LOGO response\n");
 
        if (rdata->rp_state != RPORT_ST_LOGO) {
-               FC_DEBUG_RPORT("Received a LOGO response, but in state %s\n",
-                              fc_rport_state(rport));
+               FC_RPORT_DBG(rport, "Received a LOGO response, but in state "
+                            "%s\n", fc_rport_state(rport));
                if (IS_ERR(fp))
                        goto err;
                goto out;
@@ -715,10 +719,8 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
        if (op == ELS_LS_ACC) {
                fc_rport_enter_rtv(rport);
        } else {
-               FC_DBG("Bad ELS response\n");
-               rdata->event = RPORT_EV_LOGO;
-               fc_rport_state_enter(rport, RPORT_ST_NONE);
-               queue_work(rport_event_queue, &rdata->event_work);
+               FC_RPORT_DBG(rport, "Bad ELS response for LOGO command\n");
+               fc_rport_enter_delete(rport, RPORT_EV_LOGO);
        }
 
 out:
@@ -737,7 +739,7 @@ err:
  */
 static void fc_rport_enter_prli(struct fc_rport *rport)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
        struct {
                struct fc_els_prli prli;
@@ -745,8 +747,8 @@ static void fc_rport_enter_prli(struct fc_rport *rport)
        } *pp;
        struct fc_frame *fp;
 
-       FC_DEBUG_RPORT("Port (%6x) entered PRLI state from %s state\n",
-                      rport->port_id, fc_rport_state(rport));
+       FC_RPORT_DBG(rport, "Port entered PRLI state from %s state\n",
+                    fc_rport_state(rport));
 
        fc_rport_state_enter(rport, RPORT_ST_PRLI);
 
@@ -779,17 +781,16 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp,
                              void *rp_arg)
 {
        struct fc_rport *rport = rp_arg;
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        u8 op;
 
        mutex_lock(&rdata->rp_mutex);
 
-       FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n",
-                      rport->port_id);
+       FC_RPORT_DBG(rport, "Received a RTV response\n");
 
        if (rdata->rp_state != RPORT_ST_RTV) {
-               FC_DBG("Received a RTV response, but in state %s\n",
-                      fc_rport_state(rport));
+               FC_RPORT_DBG(rport, "Received a RTV response, but in state "
+                            "%s\n", fc_rport_state(rport));
                if (IS_ERR(fp))
                        goto err;
                goto out;
@@ -841,11 +842,11 @@ err:
 static void fc_rport_enter_rtv(struct fc_rport *rport)
 {
        struct fc_frame *fp;
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
 
-       FC_DEBUG_RPORT("Port (%6x) entered RTV state from %s state\n",
-                      rport->port_id, fc_rport_state(rport));
+       FC_RPORT_DBG(rport, "Port entered RTV state from %s state\n",
+                    fc_rport_state(rport));
 
        fc_rport_state_enter(rport, RPORT_ST_RTV);
 
@@ -871,12 +872,12 @@ static void fc_rport_enter_rtv(struct fc_rport *rport)
  */
 static void fc_rport_enter_logo(struct fc_rport *rport)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
        struct fc_frame *fp;
 
-       FC_DEBUG_RPORT("Port (%6x) entered LOGO state from %s state\n",
-                      rport->port_id, fc_rport_state(rport));
+       FC_RPORT_DBG(rport, "Port entered LOGO state from %s state\n",
+                    fc_rport_state(rport));
 
        fc_rport_state_enter(rport, RPORT_ST_LOGO);
 
@@ -907,7 +908,7 @@ static void fc_rport_enter_logo(struct fc_rport *rport)
 void fc_rport_recv_req(struct fc_seq *sp, struct fc_frame *fp,
                       struct fc_rport *rport)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
 
        struct fc_frame_header *fh;
@@ -967,7 +968,7 @@ void fc_rport_recv_req(struct fc_seq *sp, struct fc_frame *fp,
 static void fc_rport_recv_plogi_req(struct fc_rport *rport,
                                    struct fc_seq *sp, struct fc_frame *rx_fp)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
        struct fc_frame *fp = rx_fp;
        struct fc_exch *ep;
@@ -983,14 +984,13 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
 
        fh = fc_frame_header_get(fp);
 
-       FC_DEBUG_RPORT("Received PLOGI request from port (%6x) "
-                      "while in state %s\n", ntoh24(fh->fh_s_id),
-                      fc_rport_state(rport));
+       FC_RPORT_DBG(rport, "Received PLOGI request while in state %s\n",
+                    fc_rport_state(rport));
 
        sid = ntoh24(fh->fh_s_id);
        pl = fc_frame_payload_get(fp, sizeof(*pl));
        if (!pl) {
-               FC_DBG("incoming PLOGI from %x too short\n", sid);
+               FC_RPORT_DBG(rport, "Received PLOGI too short\n");
                WARN_ON(1);
                /* XXX TBD: send reject? */
                fc_frame_free(fp);
@@ -1012,26 +1012,26 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
         */
        switch (rdata->rp_state) {
        case RPORT_ST_INIT:
-               FC_DEBUG_RPORT("incoming PLOGI from %6x wwpn %llx state INIT "
-                              "- reject\n", sid, (unsigned long long)wwpn);
+               FC_RPORT_DBG(rport, "Received PLOGI, wwpn %llx state INIT "
+                            "- reject\n", (unsigned long long)wwpn);
                reject = ELS_RJT_UNSUP;
                break;
        case RPORT_ST_PLOGI:
-               FC_DEBUG_RPORT("incoming PLOGI from %x in PLOGI state %d\n",
-                              sid, rdata->rp_state);
+               FC_RPORT_DBG(rport, "Received PLOGI in PLOGI state %d\n",
+                            rdata->rp_state);
                if (wwpn < lport->wwpn)
                        reject = ELS_RJT_INPROG;
                break;
        case RPORT_ST_PRLI:
        case RPORT_ST_READY:
-               FC_DEBUG_RPORT("incoming PLOGI from %x in logged-in state %d "
-                              "- ignored for now\n", sid, rdata->rp_state);
+               FC_RPORT_DBG(rport, "Received PLOGI in logged-in state %d "
+                            "- ignored for now\n", rdata->rp_state);
                /* XXX TBD - should reset */
                break;
-       case RPORT_ST_NONE:
+       case RPORT_ST_DELETE:
        default:
-               FC_DEBUG_RPORT("incoming PLOGI from %x in unexpected "
-                              "state %d\n", sid, rdata->rp_state);
+               FC_RPORT_DBG(rport, "Received PLOGI in unexpected "
+                            "state %d\n", rdata->rp_state);
                fc_frame_free(fp);
                return;
                break;
@@ -1091,7 +1091,7 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
 static void fc_rport_recv_prli_req(struct fc_rport *rport,
                                   struct fc_seq *sp, struct fc_frame *rx_fp)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
        struct fc_exch *ep;
        struct fc_frame *fp;
@@ -1115,9 +1115,8 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport,
 
        fh = fc_frame_header_get(rx_fp);
 
-       FC_DEBUG_RPORT("Received PRLI request from port (%6x) "
-                      "while in state %s\n", ntoh24(fh->fh_s_id),
-                      fc_rport_state(rport));
+       FC_RPORT_DBG(rport, "Received PRLI request while in state %s\n",
+                    fc_rport_state(rport));
 
        switch (rdata->rp_state) {
        case RPORT_ST_PRLI:
@@ -1244,7 +1243,7 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport,
 static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp,
                                   struct fc_frame *fp)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
 
        struct fc_frame_header *fh;
@@ -1252,11 +1251,10 @@ static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp,
 
        fh = fc_frame_header_get(fp);
 
-       FC_DEBUG_RPORT("Received PRLO request from port (%6x) "
-                      "while in state %s\n", ntoh24(fh->fh_s_id),
-                      fc_rport_state(rport));
+       FC_RPORT_DBG(rport, "Received PRLO request while in state %s\n",
+                    fc_rport_state(rport));
 
-       if (rdata->rp_state == RPORT_ST_NONE) {
+       if (rdata->rp_state == RPORT_ST_DELETE) {
                fc_frame_free(fp);
                return;
        }
@@ -1281,22 +1279,21 @@ 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 *rdata = rport->dd_data;
+       struct fc_rport_priv *rdata = rport->dd_data;
        struct fc_lport *lport = rdata->local_port;
 
        fh = fc_frame_header_get(fp);
 
-       FC_DEBUG_RPORT("Received LOGO request from port (%6x) "
-                      "while in state %s\n", ntoh24(fh->fh_s_id),
-                      fc_rport_state(rport));
+       FC_RPORT_DBG(rport, "Received LOGO request while in state %s\n",
+                    fc_rport_state(rport));
 
-       if (rdata->rp_state == RPORT_ST_NONE) {
+       if (rdata->rp_state == RPORT_ST_DELETE) {
                fc_frame_free(fp);
                return;
        }
 
        rdata->event = RPORT_EV_LOGO;
-       fc_rport_state_enter(rport, RPORT_ST_NONE);
+       fc_rport_state_enter(rport, RPORT_ST_DELETE);
        queue_work(rport_event_queue, &rdata->event_work);
 
        lport->tt.seq_els_rsp_send(sp, ELS_LS_ACC, NULL);
@@ -1308,7 +1305,6 @@ static void fc_rport_flush_queue(void)
        flush_workqueue(rport_event_queue);
 }
 
-
 int fc_rport_init(struct fc_lport *lport)
 {
        if (!lport->tt.rport_create)
@@ -1347,8 +1343,8 @@ EXPORT_SYMBOL(fc_destroy_rport);
 
 void fc_rport_terminate_io(struct fc_rport *rport)
 {
-       struct fc_rport_libfc_priv *rdata = rport->dd_data;
-       struct fc_lport *lport = rdata->local_port;
+       struct fc_rport_libfc_priv *rp = rport->dd_data;
+       struct fc_lport *lport = rp->local_port;
 
        lport->tt.exch_mgr_reset(lport, 0, rport->port_id);
        lport->tt.exch_mgr_reset(lport, rport->port_id, 0);
This page took 0.035751 seconds and 5 git commands to generate.