提交 9b651da9 编写于 作者: J Joe Eykholt 提交者: James Bottomley

[SCSI] libfcoe: add state change debugging

Enhancement: add debug messages at all state transitions.
Signed-off-by: NJoe Eykholt <jeykholt@cisco.com>
Signed-off-by: NRobert Love <robert.w.love@intel.com>
Signed-off-by: NJames Bottomley <James.Bottomley@suse.de>
上级 edcbb439
...@@ -80,6 +80,40 @@ do { \ ...@@ -80,6 +80,40 @@ do { \
printk(KERN_INFO "host%d: fip: " fmt, \ printk(KERN_INFO "host%d: fip: " fmt, \
(fip)->lp->host->host_no, ##args);) (fip)->lp->host->host_no, ##args);)
static const char *fcoe_ctlr_states[] = {
[FIP_ST_DISABLED] = "DISABLED",
[FIP_ST_LINK_WAIT] = "LINK_WAIT",
[FIP_ST_AUTO] = "AUTO",
[FIP_ST_NON_FIP] = "NON_FIP",
[FIP_ST_ENABLED] = "ENABLED",
};
static const char *fcoe_ctlr_state(enum fip_state state)
{
const char *cp = "unknown";
if (state < ARRAY_SIZE(fcoe_ctlr_states))
cp = fcoe_ctlr_states[state];
if (!cp)
cp = "unknown";
return cp;
}
/**
* fcoe_ctlr_set_state() - Set and do debug printing for the new FIP state.
* @fip: The FCoE controller
* @state: The new state
*/
static void fcoe_ctlr_set_state(struct fcoe_ctlr *fip, enum fip_state state)
{
if (state == fip->state)
return;
if (fip->lp)
LIBFCOE_FIP_DBG(fip, "state %s -> %s\n",
fcoe_ctlr_state(fip->state), fcoe_ctlr_state(state));
fip->state = state;
}
/** /**
* fcoe_ctlr_mtu_valid() - Check if a FCF's MTU is valid * fcoe_ctlr_mtu_valid() - Check if a FCF's MTU is valid
* @fcf: The FCF to check * @fcf: The FCF to check
...@@ -110,7 +144,7 @@ static inline int fcoe_ctlr_fcf_usable(struct fcoe_fcf *fcf) ...@@ -110,7 +144,7 @@ static inline int fcoe_ctlr_fcf_usable(struct fcoe_fcf *fcf)
*/ */
void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode) void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
{ {
fip->state = FIP_ST_LINK_WAIT; fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
fip->mode = mode; fip->mode = mode;
INIT_LIST_HEAD(&fip->fcfs); INIT_LIST_HEAD(&fip->fcfs);
mutex_init(&fip->ctlr_mutex); mutex_init(&fip->ctlr_mutex);
...@@ -160,7 +194,7 @@ void fcoe_ctlr_destroy(struct fcoe_ctlr *fip) ...@@ -160,7 +194,7 @@ void fcoe_ctlr_destroy(struct fcoe_ctlr *fip)
skb_queue_purge(&fip->fip_recv_list); skb_queue_purge(&fip->fip_recv_list);
mutex_lock(&fip->ctlr_mutex); mutex_lock(&fip->ctlr_mutex);
fip->state = FIP_ST_DISABLED; fcoe_ctlr_set_state(fip, FIP_ST_DISABLED);
fcoe_ctlr_reset_fcfs(fip); fcoe_ctlr_reset_fcfs(fip);
mutex_unlock(&fip->ctlr_mutex); mutex_unlock(&fip->ctlr_mutex);
del_timer_sync(&fip->timer); del_timer_sync(&fip->timer);
...@@ -260,7 +294,7 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip) ...@@ -260,7 +294,7 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
mutex_unlock(&fip->ctlr_mutex); mutex_unlock(&fip->ctlr_mutex);
fc_linkup(fip->lp); fc_linkup(fip->lp);
} else if (fip->state == FIP_ST_LINK_WAIT) { } else if (fip->state == FIP_ST_LINK_WAIT) {
fip->state = fip->mode; fcoe_ctlr_set_state(fip, fip->mode);
mutex_unlock(&fip->ctlr_mutex); mutex_unlock(&fip->ctlr_mutex);
if (fip->state == FIP_ST_AUTO) if (fip->state == FIP_ST_AUTO)
LIBFCOE_FIP_DBG(fip, "%s", "setting AUTO mode.\n"); LIBFCOE_FIP_DBG(fip, "%s", "setting AUTO mode.\n");
...@@ -303,7 +337,7 @@ int fcoe_ctlr_link_down(struct fcoe_ctlr *fip) ...@@ -303,7 +337,7 @@ int fcoe_ctlr_link_down(struct fcoe_ctlr *fip)
mutex_lock(&fip->ctlr_mutex); mutex_lock(&fip->ctlr_mutex);
fcoe_ctlr_reset(fip); fcoe_ctlr_reset(fip);
link_dropped = fip->state != FIP_ST_LINK_WAIT; link_dropped = fip->state != FIP_ST_LINK_WAIT;
fip->state = FIP_ST_LINK_WAIT; fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
mutex_unlock(&fip->ctlr_mutex); mutex_unlock(&fip->ctlr_mutex);
if (link_dropped) if (link_dropped)
...@@ -1170,7 +1204,7 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, struct sk_buff *skb) ...@@ -1170,7 +1204,7 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, struct sk_buff *skb)
state = fip->state; state = fip->state;
if (state == FIP_ST_AUTO) { if (state == FIP_ST_AUTO) {
fip->map_dest = 0; fip->map_dest = 0;
fip->state = FIP_ST_ENABLED; fcoe_ctlr_set_state(fip, FIP_ST_ENABLED);
state = FIP_ST_ENABLED; state = FIP_ST_ENABLED;
LIBFCOE_FIP_DBG(fip, "Using FIP mode\n"); LIBFCOE_FIP_DBG(fip, "Using FIP mode\n");
} }
...@@ -1401,7 +1435,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_lport *lport, ...@@ -1401,7 +1435,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_lport *lport,
mutex_unlock(&fip->ctlr_mutex); mutex_unlock(&fip->ctlr_mutex);
return -EINVAL; return -EINVAL;
} }
fip->state = FIP_ST_NON_FIP; fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
LIBFCOE_FIP_DBG(fip, LIBFCOE_FIP_DBG(fip,
"received FLOGI LS_ACC using non-FIP mode\n"); "received FLOGI LS_ACC using non-FIP mode\n");
...@@ -1431,7 +1465,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_lport *lport, ...@@ -1431,7 +1465,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_lport *lport,
if (fip->state == FIP_ST_AUTO) if (fip->state == FIP_ST_AUTO)
LIBFCOE_FIP_DBG(fip, "received non-FIP FLOGI. " LIBFCOE_FIP_DBG(fip, "received non-FIP FLOGI. "
"Setting non-FIP mode\n"); "Setting non-FIP mode\n");
fip->state = FIP_ST_NON_FIP; fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
} }
mutex_unlock(&fip->ctlr_mutex); mutex_unlock(&fip->ctlr_mutex);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册