aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/fnic/fnic_fcs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/fnic/fnic_fcs.c')
-rw-r--r--drivers/scsi/fnic/fnic_fcs.c564
1 files changed, 562 insertions, 2 deletions
diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c
index 483eb9dbe663..006fa92a02df 100644
--- a/drivers/scsi/fnic/fnic_fcs.c
+++ b/drivers/scsi/fnic/fnic_fcs.c
@@ -31,12 +31,20 @@
31#include <scsi/libfc.h> 31#include <scsi/libfc.h>
32#include "fnic_io.h" 32#include "fnic_io.h"
33#include "fnic.h" 33#include "fnic.h"
34#include "fnic_fip.h"
34#include "cq_enet_desc.h" 35#include "cq_enet_desc.h"
35#include "cq_exch_desc.h" 36#include "cq_exch_desc.h"
36 37
38static u8 fcoe_all_fcfs[ETH_ALEN];
39struct workqueue_struct *fnic_fip_queue;
37struct workqueue_struct *fnic_event_queue; 40struct workqueue_struct *fnic_event_queue;
38 41
39static void fnic_set_eth_mode(struct fnic *); 42static void fnic_set_eth_mode(struct fnic *);
43static void fnic_fcoe_send_vlan_req(struct fnic *fnic);
44static void fnic_fcoe_start_fcf_disc(struct fnic *fnic);
45static void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct sk_buff *);
46static int fnic_fcoe_vlan_check(struct fnic *fnic, u16 flag);
47static int fnic_fcoe_handle_fip_frame(struct fnic *fnic, struct sk_buff *skb);
40 48
41void fnic_handle_link(struct work_struct *work) 49void fnic_handle_link(struct work_struct *work)
42{ 50{
@@ -69,6 +77,11 @@ void fnic_handle_link(struct work_struct *work)
69 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 77 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
70 "link down\n"); 78 "link down\n");
71 fcoe_ctlr_link_down(&fnic->ctlr); 79 fcoe_ctlr_link_down(&fnic->ctlr);
80 if (fnic->config.flags & VFCF_FIP_CAPABLE) {
81 /* start FCoE VLAN discovery */
82 fnic_fcoe_send_vlan_req(fnic);
83 return;
84 }
72 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, 85 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
73 "link up\n"); 86 "link up\n");
74 fcoe_ctlr_link_up(&fnic->ctlr); 87 fcoe_ctlr_link_up(&fnic->ctlr);
@@ -79,6 +92,11 @@ void fnic_handle_link(struct work_struct *work)
79 } else if (fnic->link_status) { 92 } else if (fnic->link_status) {
80 /* DOWN -> UP */ 93 /* DOWN -> UP */
81 spin_unlock_irqrestore(&fnic->fnic_lock, flags); 94 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
95 if (fnic->config.flags & VFCF_FIP_CAPABLE) {
96 /* start FCoE VLAN discovery */
97 fnic_fcoe_send_vlan_req(fnic);
98 return;
99 }
82 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link up\n"); 100 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link up\n");
83 fcoe_ctlr_link_up(&fnic->ctlr); 101 fcoe_ctlr_link_up(&fnic->ctlr);
84 } else { 102 } else {
@@ -128,6 +146,441 @@ void fnic_handle_frame(struct work_struct *work)
128 } 146 }
129} 147}
130 148
149void fnic_fcoe_evlist_free(struct fnic *fnic)
150{
151 struct fnic_event *fevt = NULL;
152 struct fnic_event *next = NULL;
153 unsigned long flags;
154
155 spin_lock_irqsave(&fnic->fnic_lock, flags);
156 if (list_empty(&fnic->evlist)) {
157 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
158 return;
159 }
160
161 list_for_each_entry_safe(fevt, next, &fnic->evlist, list) {
162 list_del(&fevt->list);
163 kfree(fevt);
164 }
165 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
166}
167
168void fnic_handle_event(struct work_struct *work)
169{
170 struct fnic *fnic = container_of(work, struct fnic, event_work);
171 struct fnic_event *fevt = NULL;
172 struct fnic_event *next = NULL;
173 unsigned long flags;
174
175 spin_lock_irqsave(&fnic->fnic_lock, flags);
176 if (list_empty(&fnic->evlist)) {
177 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
178 return;
179 }
180
181 list_for_each_entry_safe(fevt, next, &fnic->evlist, list) {
182 if (fnic->stop_rx_link_events) {
183 list_del(&fevt->list);
184 kfree(fevt);
185 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
186 return;
187 }
188 /*
189 * If we're in a transitional state, just re-queue and return.
190 * The queue will be serviced when we get to a stable state.
191 */
192 if (fnic->state != FNIC_IN_FC_MODE &&
193 fnic->state != FNIC_IN_ETH_MODE) {
194 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
195 return;
196 }
197
198 list_del(&fevt->list);
199 switch (fevt->event) {
200 case FNIC_EVT_START_VLAN_DISC:
201 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
202 fnic_fcoe_send_vlan_req(fnic);
203 spin_lock_irqsave(&fnic->fnic_lock, flags);
204 break;
205 case FNIC_EVT_START_FCF_DISC:
206 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
207 "Start FCF Discovery\n");
208 fnic_fcoe_start_fcf_disc(fnic);
209 break;
210 default:
211 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
212 "Unknown event 0x%x\n", fevt->event);
213 break;
214 }
215 kfree(fevt);
216 }
217 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
218}
219
220/**
221 * Check if the Received FIP FLOGI frame is rejected
222 * @fip: The FCoE controller that received the frame
223 * @skb: The received FIP frame
224 *
225 * Returns non-zero if the frame is rejected with unsupported cmd with
226 * insufficient resource els explanation.
227 */
228static inline int is_fnic_fip_flogi_reject(struct fcoe_ctlr *fip,
229 struct sk_buff *skb)
230{
231 struct fc_lport *lport = fip->lp;
232 struct fip_header *fiph;
233 struct fc_frame_header *fh = NULL;
234 struct fip_desc *desc;
235 struct fip_encaps *els;
236 enum fip_desc_type els_dtype = 0;
237 u16 op;
238 u8 els_op;
239 u8 sub;
240
241 size_t els_len = 0;
242 size_t rlen;
243 size_t dlen = 0;
244
245 if (skb_linearize(skb))
246 return 0;
247
248 if (skb->len < sizeof(*fiph))
249 return 0;
250
251 fiph = (struct fip_header *)skb->data;
252 op = ntohs(fiph->fip_op);
253 sub = fiph->fip_subcode;
254
255 if (op != FIP_OP_LS)
256 return 0;
257
258 if (sub != FIP_SC_REP)
259 return 0;
260
261 rlen = ntohs(fiph->fip_dl_len) * 4;
262 if (rlen + sizeof(*fiph) > skb->len)
263 return 0;
264
265 desc = (struct fip_desc *)(fiph + 1);
266 dlen = desc->fip_dlen * FIP_BPW;
267
268 if (desc->fip_dtype == FIP_DT_FLOGI) {
269
270 shost_printk(KERN_DEBUG, lport->host,
271 " FIP TYPE FLOGI: fab name:%llx "
272 "vfid:%d map:%x\n",
273 fip->sel_fcf->fabric_name, fip->sel_fcf->vfid,
274 fip->sel_fcf->fc_map);
275 if (dlen < sizeof(*els) + sizeof(*fh) + 1)
276 return 0;
277
278 els_len = dlen - sizeof(*els);
279 els = (struct fip_encaps *)desc;
280 fh = (struct fc_frame_header *)(els + 1);
281 els_dtype = desc->fip_dtype;
282
283 if (!fh)
284 return 0;
285
286 /*
287 * ELS command code, reason and explanation should be = Reject,
288 * unsupported command and insufficient resource
289 */
290 els_op = *(u8 *)(fh + 1);
291 if (els_op == ELS_LS_RJT) {
292 shost_printk(KERN_INFO, lport->host,
293 "Flogi Request Rejected by Switch\n");
294 return 1;
295 }
296 shost_printk(KERN_INFO, lport->host,
297 "Flogi Request Accepted by Switch\n");
298 }
299 return 0;
300}
301
302static void fnic_fcoe_send_vlan_req(struct fnic *fnic)
303{
304 struct fcoe_ctlr *fip = &fnic->ctlr;
305 struct sk_buff *skb;
306 char *eth_fr;
307 int fr_len;
308 struct fip_vlan *vlan;
309 u64 vlan_tov;
310
311 fnic_fcoe_reset_vlans(fnic);
312 fnic->set_vlan(fnic, 0);
313 FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
314 "Sending VLAN request...\n");
315 skb = dev_alloc_skb(sizeof(struct fip_vlan));
316 if (!skb)
317 return;
318
319 fr_len = sizeof(*vlan);
320 eth_fr = (char *)skb->data;
321 vlan = (struct fip_vlan *)eth_fr;
322
323 memset(vlan, 0, sizeof(*vlan));
324 memcpy(vlan->eth.h_source, fip->ctl_src_addr, ETH_ALEN);
325 memcpy(vlan->eth.h_dest, fcoe_all_fcfs, ETH_ALEN);
326 vlan->eth.h_proto = htons(ETH_P_FIP);
327
328 vlan->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
329 vlan->fip.fip_op = htons(FIP_OP_VLAN);
330 vlan->fip.fip_subcode = FIP_SC_VL_REQ;
331 vlan->fip.fip_dl_len = htons(sizeof(vlan->desc) / FIP_BPW);
332
333 vlan->desc.mac.fd_desc.fip_dtype = FIP_DT_MAC;
334 vlan->desc.mac.fd_desc.fip_dlen = sizeof(vlan->desc.mac) / FIP_BPW;
335 memcpy(&vlan->desc.mac.fd_mac, fip->ctl_src_addr, ETH_ALEN);
336
337 vlan->desc.wwnn.fd_desc.fip_dtype = FIP_DT_NAME;
338 vlan->desc.wwnn.fd_desc.fip_dlen = sizeof(vlan->desc.wwnn) / FIP_BPW;
339 put_unaligned_be64(fip->lp->wwnn, &vlan->desc.wwnn.fd_wwn);
340
341 skb_put(skb, sizeof(*vlan));
342 skb->protocol = htons(ETH_P_FIP);
343 skb_reset_mac_header(skb);
344 skb_reset_network_header(skb);
345 fip->send(fip, skb);
346
347 /* set a timer so that we can retry if there no response */
348 vlan_tov = jiffies + msecs_to_jiffies(FCOE_CTLR_FIPVLAN_TOV);
349 mod_timer(&fnic->fip_timer, round_jiffies(vlan_tov));
350}
351
352static void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct sk_buff *skb)
353{
354 struct fcoe_ctlr *fip = &fnic->ctlr;
355 struct fip_header *fiph;
356 struct fip_desc *desc;
357 u16 vid;
358 size_t rlen;
359 size_t dlen;
360 struct fcoe_vlan *vlan;
361 u64 sol_time;
362 unsigned long flags;
363
364 FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
365 "Received VLAN response...\n");
366
367 fiph = (struct fip_header *) skb->data;
368
369 FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
370 "Received VLAN response... OP 0x%x SUB_OP 0x%x\n",
371 ntohs(fiph->fip_op), fiph->fip_subcode);
372
373 rlen = ntohs(fiph->fip_dl_len) * 4;
374 fnic_fcoe_reset_vlans(fnic);
375 spin_lock_irqsave(&fnic->vlans_lock, flags);
376 desc = (struct fip_desc *)(fiph + 1);
377 while (rlen > 0) {
378 dlen = desc->fip_dlen * FIP_BPW;
379 switch (desc->fip_dtype) {
380 case FIP_DT_VLAN:
381 vid = ntohs(((struct fip_vlan_desc *)desc)->fd_vlan);
382 shost_printk(KERN_INFO, fnic->lport->host,
383 "process_vlan_resp: FIP VLAN %d\n", vid);
384 vlan = kmalloc(sizeof(*vlan),
385 GFP_ATOMIC);
386 if (!vlan) {
387 /* retry from timer */
388 spin_unlock_irqrestore(&fnic->vlans_lock,
389 flags);
390 goto out;
391 }
392 memset(vlan, 0, sizeof(struct fcoe_vlan));
393 vlan->vid = vid & 0x0fff;
394 vlan->state = FIP_VLAN_AVAIL;
395 list_add_tail(&vlan->list, &fnic->vlans);
396 break;
397 }
398 desc = (struct fip_desc *)((char *)desc + dlen);
399 rlen -= dlen;
400 }
401
402 /* any VLAN descriptors present ? */
403 if (list_empty(&fnic->vlans)) {
404 /* retry from timer */
405 FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
406 "No VLAN descriptors in FIP VLAN response\n");
407 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
408 goto out;
409 }
410
411 vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list);
412 fnic->set_vlan(fnic, vlan->vid);
413 vlan->state = FIP_VLAN_SENT; /* sent now */
414 vlan->sol_count++;
415 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
416
417 /* start the solicitation */
418 fcoe_ctlr_link_up(fip);
419
420 sol_time = jiffies + msecs_to_jiffies(FCOE_CTLR_START_DELAY);
421 mod_timer(&fnic->fip_timer, round_jiffies(sol_time));
422out:
423 return;
424}
425
426static void fnic_fcoe_start_fcf_disc(struct fnic *fnic)
427{
428 unsigned long flags;
429 struct fcoe_vlan *vlan;
430 u64 sol_time;
431
432 spin_lock_irqsave(&fnic->vlans_lock, flags);
433 vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list);
434 fnic->set_vlan(fnic, vlan->vid);
435 vlan->state = FIP_VLAN_SENT; /* sent now */
436 vlan->sol_count = 1;
437 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
438
439 /* start the solicitation */
440 fcoe_ctlr_link_up(&fnic->ctlr);
441
442 sol_time = jiffies + msecs_to_jiffies(FCOE_CTLR_START_DELAY);
443 mod_timer(&fnic->fip_timer, round_jiffies(sol_time));
444}
445
446static int fnic_fcoe_vlan_check(struct fnic *fnic, u16 flag)
447{
448 unsigned long flags;
449 struct fcoe_vlan *fvlan;
450
451 spin_lock_irqsave(&fnic->vlans_lock, flags);
452 if (list_empty(&fnic->vlans)) {
453 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
454 return -EINVAL;
455 }
456
457 fvlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list);
458 if (fvlan->state == FIP_VLAN_USED) {
459 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
460 return 0;
461 }
462
463 if (fvlan->state == FIP_VLAN_SENT) {
464 fvlan->state = FIP_VLAN_USED;
465 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
466 return 0;
467 }
468 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
469 return -EINVAL;
470}
471
472static void fnic_event_enq(struct fnic *fnic, enum fnic_evt ev)
473{
474 struct fnic_event *fevt;
475 unsigned long flags;
476
477 fevt = kmalloc(sizeof(*fevt), GFP_ATOMIC);
478 if (!fevt)
479 return;
480
481 fevt->fnic = fnic;
482 fevt->event = ev;
483
484 spin_lock_irqsave(&fnic->fnic_lock, flags);
485 list_add_tail(&fevt->list, &fnic->evlist);
486 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
487
488 schedule_work(&fnic->event_work);
489}
490
491static int fnic_fcoe_handle_fip_frame(struct fnic *fnic, struct sk_buff *skb)
492{
493 struct fip_header *fiph;
494 int ret = 1;
495 u16 op;
496 u8 sub;
497
498 if (!skb || !(skb->data))
499 return -1;
500
501 if (skb_linearize(skb))
502 goto drop;
503
504 fiph = (struct fip_header *)skb->data;
505 op = ntohs(fiph->fip_op);
506 sub = fiph->fip_subcode;
507
508 if (FIP_VER_DECAPS(fiph->fip_ver) != FIP_VER)
509 goto drop;
510
511 if (ntohs(fiph->fip_dl_len) * FIP_BPW + sizeof(*fiph) > skb->len)
512 goto drop;
513
514 if (op == FIP_OP_DISC && sub == FIP_SC_ADV) {
515 if (fnic_fcoe_vlan_check(fnic, ntohs(fiph->fip_flags)))
516 goto drop;
517 /* pass it on to fcoe */
518 ret = 1;
519 } else if (op == FIP_OP_VLAN && sub == FIP_SC_VL_REP) {
520 /* set the vlan as used */
521 fnic_fcoe_process_vlan_resp(fnic, skb);
522 ret = 0;
523 } else if (op == FIP_OP_CTRL && sub == FIP_SC_CLR_VLINK) {
524 /* received CVL request, restart vlan disc */
525 fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
526 /* pass it on to fcoe */
527 ret = 1;
528 }
529drop:
530 return ret;
531}
532
533void fnic_handle_fip_frame(struct work_struct *work)
534{
535 struct fnic *fnic = container_of(work, struct fnic, fip_frame_work);
536 unsigned long flags;
537 struct sk_buff *skb;
538 struct ethhdr *eh;
539
540 while ((skb = skb_dequeue(&fnic->fip_frame_queue))) {
541 spin_lock_irqsave(&fnic->fnic_lock, flags);
542 if (fnic->stop_rx_link_events) {
543 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
544 dev_kfree_skb(skb);
545 return;
546 }
547 /*
548 * If we're in a transitional state, just re-queue and return.
549 * The queue will be serviced when we get to a stable state.
550 */
551 if (fnic->state != FNIC_IN_FC_MODE &&
552 fnic->state != FNIC_IN_ETH_MODE) {
553 skb_queue_head(&fnic->fip_frame_queue, skb);
554 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
555 return;
556 }
557 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
558 eh = (struct ethhdr *)skb->data;
559 if (eh->h_proto == htons(ETH_P_FIP)) {
560 skb_pull(skb, sizeof(*eh));
561 if (fnic_fcoe_handle_fip_frame(fnic, skb) <= 0) {
562 dev_kfree_skb(skb);
563 continue;
564 }
565 /*
566 * If there's FLOGI rejects - clear all
567 * fcf's & restart from scratch
568 */
569 if (is_fnic_fip_flogi_reject(&fnic->ctlr, skb)) {
570 shost_printk(KERN_INFO, fnic->lport->host,
571 "Trigger a Link down - VLAN Disc\n");
572 fcoe_ctlr_link_down(&fnic->ctlr);
573 /* start FCoE VLAN discovery */
574 fnic_fcoe_send_vlan_req(fnic);
575 dev_kfree_skb(skb);
576 continue;
577 }
578 fcoe_ctlr_recv(&fnic->ctlr, skb);
579 continue;
580 }
581 }
582}
583
131/** 584/**
132 * fnic_import_rq_eth_pkt() - handle received FCoE or FIP frame. 585 * fnic_import_rq_eth_pkt() - handle received FCoE or FIP frame.
133 * @fnic: fnic instance. 586 * @fnic: fnic instance.
@@ -150,8 +603,14 @@ static inline int fnic_import_rq_eth_pkt(struct fnic *fnic, struct sk_buff *skb)
150 skb_reset_mac_header(skb); 603 skb_reset_mac_header(skb);
151 } 604 }
152 if (eh->h_proto == htons(ETH_P_FIP)) { 605 if (eh->h_proto == htons(ETH_P_FIP)) {
153 skb_pull(skb, sizeof(*eh)); 606 if (!(fnic->config.flags & VFCF_FIP_CAPABLE)) {
154 fcoe_ctlr_recv(&fnic->ctlr, skb); 607 printk(KERN_ERR "Dropped FIP frame, as firmware "
608 "uses non-FIP mode, Enable FIP "
609 "using UCSM\n");
610 goto drop;
611 }
612 skb_queue_tail(&fnic->fip_frame_queue, skb);
613 queue_work(fnic_fip_queue, &fnic->fip_frame_work);
155 return 1; /* let caller know packet was used */ 614 return 1; /* let caller know packet was used */
156 } 615 }
157 if (eh->h_proto != htons(ETH_P_FCOE)) 616 if (eh->h_proto != htons(ETH_P_FCOE))
@@ -720,3 +1179,104 @@ void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf)
720 dev_kfree_skb(fp_skb(fp)); 1179 dev_kfree_skb(fp_skb(fp));
721 buf->os_buf = NULL; 1180 buf->os_buf = NULL;
722} 1181}
1182
1183void fnic_fcoe_reset_vlans(struct fnic *fnic)
1184{
1185 unsigned long flags;
1186 struct fcoe_vlan *vlan;
1187 struct fcoe_vlan *next;
1188
1189 /*
1190 * indicate a link down to fcoe so that all fcf's are free'd
1191 * might not be required since we did this before sending vlan
1192 * discovery request
1193 */
1194 spin_lock_irqsave(&fnic->vlans_lock, flags);
1195 if (!list_empty(&fnic->vlans)) {
1196 list_for_each_entry_safe(vlan, next, &fnic->vlans, list) {
1197 list_del(&vlan->list);
1198 kfree(vlan);
1199 }
1200 }
1201 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1202}
1203
1204void fnic_handle_fip_timer(struct fnic *fnic)
1205{
1206 unsigned long flags;
1207 struct fcoe_vlan *vlan;
1208 u64 sol_time;
1209
1210 spin_lock_irqsave(&fnic->fnic_lock, flags);
1211 if (fnic->stop_rx_link_events) {
1212 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1213 return;
1214 }
1215 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1216
1217 if (fnic->ctlr.mode == FIP_ST_NON_FIP)
1218 return;
1219
1220 spin_lock_irqsave(&fnic->vlans_lock, flags);
1221 if (list_empty(&fnic->vlans)) {
1222 /* no vlans available, try again */
1223 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
1224 "Start VLAN Discovery\n");
1225 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1226 fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
1227 return;
1228 }
1229
1230 vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list);
1231 shost_printk(KERN_DEBUG, fnic->lport->host,
1232 "fip_timer: vlan %d state %d sol_count %d\n",
1233 vlan->vid, vlan->state, vlan->sol_count);
1234 switch (vlan->state) {
1235 case FIP_VLAN_USED:
1236 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
1237 "FIP VLAN is selected for FC transaction\n");
1238 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1239 break;
1240 case FIP_VLAN_FAILED:
1241 /* if all vlans are in failed state, restart vlan disc */
1242 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
1243 "Start VLAN Discovery\n");
1244 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1245 fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
1246 break;
1247 case FIP_VLAN_SENT:
1248 if (vlan->sol_count >= FCOE_CTLR_MAX_SOL) {
1249 /*
1250 * no response on this vlan, remove from the list.
1251 * Try the next vlan
1252 */
1253 shost_printk(KERN_INFO, fnic->lport->host,
1254 "Dequeue this VLAN ID %d from list\n",
1255 vlan->vid);
1256 list_del(&vlan->list);
1257 kfree(vlan);
1258 vlan = NULL;
1259 if (list_empty(&fnic->vlans)) {
1260 /* we exhausted all vlans, restart vlan disc */
1261 spin_unlock_irqrestore(&fnic->vlans_lock,
1262 flags);
1263 shost_printk(KERN_INFO, fnic->lport->host,
1264 "fip_timer: vlan list empty, "
1265 "trigger vlan disc\n");
1266 fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
1267 return;
1268 }
1269 /* check the next vlan */
1270 vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan,
1271 list);
1272 fnic->set_vlan(fnic, vlan->vid);
1273 vlan->state = FIP_VLAN_SENT; /* sent now */
1274 }
1275 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1276 vlan->sol_count++;
1277 sol_time = jiffies + msecs_to_jiffies
1278 (FCOE_CTLR_START_DELAY);
1279 mod_timer(&fnic->fip_timer, round_jiffies(sol_time));
1280 break;
1281 }
1282}