diff options
author | Joe Eykholt <jeykholt@cisco.com> | 2010-07-20 18:20:24 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-07-28 10:05:55 -0400 |
commit | 9b651da900ccfe5581befb46eb06ef781a1d7e74 (patch) | |
tree | f83bfce55fdda3d021526a1db608cfa195f0c69d /drivers/scsi | |
parent | edcbb4395ecd2f2731fbf38ecbff5be0316513cb (diff) |
[SCSI] libfcoe: add state change debugging
Enhancement: add debug messages at all state transitions.
Signed-off-by: Joe Eykholt <jeykholt@cisco.com>
Signed-off-by: Robert Love <robert.w.love@intel.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/fcoe/libfcoe.c | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/drivers/scsi/fcoe/libfcoe.c b/drivers/scsi/fcoe/libfcoe.c index 76056e4c9297..11f3db5e506b 100644 --- a/drivers/scsi/fcoe/libfcoe.c +++ b/drivers/scsi/fcoe/libfcoe.c | |||
@@ -80,6 +80,40 @@ do { \ | |||
80 | printk(KERN_INFO "host%d: fip: " fmt, \ | 80 | printk(KERN_INFO "host%d: fip: " fmt, \ |
81 | (fip)->lp->host->host_no, ##args);) | 81 | (fip)->lp->host->host_no, ##args);) |
82 | 82 | ||
83 | static const char *fcoe_ctlr_states[] = { | ||
84 | [FIP_ST_DISABLED] = "DISABLED", | ||
85 | [FIP_ST_LINK_WAIT] = "LINK_WAIT", | ||
86 | [FIP_ST_AUTO] = "AUTO", | ||
87 | [FIP_ST_NON_FIP] = "NON_FIP", | ||
88 | [FIP_ST_ENABLED] = "ENABLED", | ||
89 | }; | ||
90 | |||
91 | static const char *fcoe_ctlr_state(enum fip_state state) | ||
92 | { | ||
93 | const char *cp = "unknown"; | ||
94 | |||
95 | if (state < ARRAY_SIZE(fcoe_ctlr_states)) | ||
96 | cp = fcoe_ctlr_states[state]; | ||
97 | if (!cp) | ||
98 | cp = "unknown"; | ||
99 | return cp; | ||
100 | } | ||
101 | |||
102 | /** | ||
103 | * fcoe_ctlr_set_state() - Set and do debug printing for the new FIP state. | ||
104 | * @fip: The FCoE controller | ||
105 | * @state: The new state | ||
106 | */ | ||
107 | static void fcoe_ctlr_set_state(struct fcoe_ctlr *fip, enum fip_state state) | ||
108 | { | ||
109 | if (state == fip->state) | ||
110 | return; | ||
111 | if (fip->lp) | ||
112 | LIBFCOE_FIP_DBG(fip, "state %s -> %s\n", | ||
113 | fcoe_ctlr_state(fip->state), fcoe_ctlr_state(state)); | ||
114 | fip->state = state; | ||
115 | } | ||
116 | |||
83 | /** | 117 | /** |
84 | * fcoe_ctlr_mtu_valid() - Check if a FCF's MTU is valid | 118 | * fcoe_ctlr_mtu_valid() - Check if a FCF's MTU is valid |
85 | * @fcf: The FCF to check | 119 | * @fcf: The FCF to check |
@@ -110,7 +144,7 @@ static inline int fcoe_ctlr_fcf_usable(struct fcoe_fcf *fcf) | |||
110 | */ | 144 | */ |
111 | void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode) | 145 | void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode) |
112 | { | 146 | { |
113 | fip->state = FIP_ST_LINK_WAIT; | 147 | fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT); |
114 | fip->mode = mode; | 148 | fip->mode = mode; |
115 | INIT_LIST_HEAD(&fip->fcfs); | 149 | INIT_LIST_HEAD(&fip->fcfs); |
116 | mutex_init(&fip->ctlr_mutex); | 150 | mutex_init(&fip->ctlr_mutex); |
@@ -160,7 +194,7 @@ void fcoe_ctlr_destroy(struct fcoe_ctlr *fip) | |||
160 | skb_queue_purge(&fip->fip_recv_list); | 194 | skb_queue_purge(&fip->fip_recv_list); |
161 | 195 | ||
162 | mutex_lock(&fip->ctlr_mutex); | 196 | mutex_lock(&fip->ctlr_mutex); |
163 | fip->state = FIP_ST_DISABLED; | 197 | fcoe_ctlr_set_state(fip, FIP_ST_DISABLED); |
164 | fcoe_ctlr_reset_fcfs(fip); | 198 | fcoe_ctlr_reset_fcfs(fip); |
165 | mutex_unlock(&fip->ctlr_mutex); | 199 | mutex_unlock(&fip->ctlr_mutex); |
166 | del_timer_sync(&fip->timer); | 200 | del_timer_sync(&fip->timer); |
@@ -260,7 +294,7 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip) | |||
260 | mutex_unlock(&fip->ctlr_mutex); | 294 | mutex_unlock(&fip->ctlr_mutex); |
261 | fc_linkup(fip->lp); | 295 | fc_linkup(fip->lp); |
262 | } else if (fip->state == FIP_ST_LINK_WAIT) { | 296 | } else if (fip->state == FIP_ST_LINK_WAIT) { |
263 | fip->state = fip->mode; | 297 | fcoe_ctlr_set_state(fip, fip->mode); |
264 | mutex_unlock(&fip->ctlr_mutex); | 298 | mutex_unlock(&fip->ctlr_mutex); |
265 | if (fip->state == FIP_ST_AUTO) | 299 | if (fip->state == FIP_ST_AUTO) |
266 | LIBFCOE_FIP_DBG(fip, "%s", "setting AUTO mode.\n"); | 300 | LIBFCOE_FIP_DBG(fip, "%s", "setting AUTO mode.\n"); |
@@ -303,7 +337,7 @@ int fcoe_ctlr_link_down(struct fcoe_ctlr *fip) | |||
303 | mutex_lock(&fip->ctlr_mutex); | 337 | mutex_lock(&fip->ctlr_mutex); |
304 | fcoe_ctlr_reset(fip); | 338 | fcoe_ctlr_reset(fip); |
305 | link_dropped = fip->state != FIP_ST_LINK_WAIT; | 339 | link_dropped = fip->state != FIP_ST_LINK_WAIT; |
306 | fip->state = FIP_ST_LINK_WAIT; | 340 | fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT); |
307 | mutex_unlock(&fip->ctlr_mutex); | 341 | mutex_unlock(&fip->ctlr_mutex); |
308 | 342 | ||
309 | if (link_dropped) | 343 | if (link_dropped) |
@@ -1170,7 +1204,7 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, struct sk_buff *skb) | |||
1170 | state = fip->state; | 1204 | state = fip->state; |
1171 | if (state == FIP_ST_AUTO) { | 1205 | if (state == FIP_ST_AUTO) { |
1172 | fip->map_dest = 0; | 1206 | fip->map_dest = 0; |
1173 | fip->state = FIP_ST_ENABLED; | 1207 | fcoe_ctlr_set_state(fip, FIP_ST_ENABLED); |
1174 | state = FIP_ST_ENABLED; | 1208 | state = FIP_ST_ENABLED; |
1175 | LIBFCOE_FIP_DBG(fip, "Using FIP mode\n"); | 1209 | LIBFCOE_FIP_DBG(fip, "Using FIP mode\n"); |
1176 | } | 1210 | } |
@@ -1401,7 +1435,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_lport *lport, | |||
1401 | mutex_unlock(&fip->ctlr_mutex); | 1435 | mutex_unlock(&fip->ctlr_mutex); |
1402 | return -EINVAL; | 1436 | return -EINVAL; |
1403 | } | 1437 | } |
1404 | fip->state = FIP_ST_NON_FIP; | 1438 | fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP); |
1405 | LIBFCOE_FIP_DBG(fip, | 1439 | LIBFCOE_FIP_DBG(fip, |
1406 | "received FLOGI LS_ACC using non-FIP mode\n"); | 1440 | "received FLOGI LS_ACC using non-FIP mode\n"); |
1407 | 1441 | ||
@@ -1431,7 +1465,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *fip, struct fc_lport *lport, | |||
1431 | if (fip->state == FIP_ST_AUTO) | 1465 | if (fip->state == FIP_ST_AUTO) |
1432 | LIBFCOE_FIP_DBG(fip, "received non-FIP FLOGI. " | 1466 | LIBFCOE_FIP_DBG(fip, "received non-FIP FLOGI. " |
1433 | "Setting non-FIP mode\n"); | 1467 | "Setting non-FIP mode\n"); |
1434 | fip->state = FIP_ST_NON_FIP; | 1468 | fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP); |
1435 | } | 1469 | } |
1436 | mutex_unlock(&fip->ctlr_mutex); | 1470 | mutex_unlock(&fip->ctlr_mutex); |
1437 | } | 1471 | } |