2 * Copyright 2008 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 * This program is free software; you may redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 #include <linux/errno.h>
19 #include <linux/pci.h>
20 #include <linux/slab.h>
21 #include <linux/skbuff.h>
22 #include <linux/interrupt.h>
23 #include <linux/spinlock.h>
24 #include <linux/if_ether.h>
25 #include <linux/if_vlan.h>
26 #include <linux/workqueue.h>
27 #include <scsi/fc/fc_fip.h>
28 #include <scsi/fc/fc_els.h>
29 #include <scsi/fc/fc_fcoe.h>
30 #include <scsi/fc_frame.h>
31 #include <scsi/libfc.h>
35 #include "cq_enet_desc.h"
36 #include "cq_exch_desc.h"
38 static u8 fcoe_all_fcfs[ETH_ALEN] = FIP_ALL_FCF_MACS;
39 struct workqueue_struct *fnic_fip_queue;
40 struct workqueue_struct *fnic_event_queue;
42 static void fnic_set_eth_mode(struct fnic *);
43 static void fnic_fcoe_send_vlan_req(struct fnic *fnic);
44 static void fnic_fcoe_start_fcf_disc(struct fnic *fnic);
45 static void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct sk_buff *);
46 static int fnic_fcoe_vlan_check(struct fnic *fnic, u16 flag);
47 static int fnic_fcoe_handle_fip_frame(struct fnic *fnic, struct sk_buff *skb);
49 void fnic_handle_link(struct work_struct *work)
51 struct fnic *fnic = container_of(work, struct fnic, link_work);
54 u32 old_link_down_cnt;
55 u64 old_port_speed, new_port_speed;
57 spin_lock_irqsave(&fnic->fnic_lock, flags);
59 if (fnic->stop_rx_link_events) {
60 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
64 old_link_down_cnt = fnic->link_down_cnt;
65 old_link_status = fnic->link_status;
66 old_port_speed = atomic64_read(
67 &fnic->fnic_stats.misc_stats.current_port_speed);
69 fnic->link_status = vnic_dev_link_status(fnic->vdev);
70 fnic->link_down_cnt = vnic_dev_link_down_cnt(fnic->vdev);
72 new_port_speed = vnic_dev_port_speed(fnic->vdev);
73 atomic64_set(&fnic->fnic_stats.misc_stats.current_port_speed,
75 if (old_port_speed != new_port_speed)
76 shost_printk(KERN_INFO, fnic->lport->host,
77 "Current vnic speed set to : %llu\n",
80 switch (vnic_dev_port_speed(fnic->vdev)) {
81 case DCEM_PORTSPEED_10G:
82 fc_host_speed(fnic->lport->host) = FC_PORTSPEED_10GBIT;
83 fnic->lport->link_supported_speeds = FC_PORTSPEED_10GBIT;
85 case DCEM_PORTSPEED_20G:
86 fc_host_speed(fnic->lport->host) = FC_PORTSPEED_20GBIT;
87 fnic->lport->link_supported_speeds = FC_PORTSPEED_20GBIT;
89 case DCEM_PORTSPEED_25G:
90 fc_host_speed(fnic->lport->host) = FC_PORTSPEED_25GBIT;
91 fnic->lport->link_supported_speeds = FC_PORTSPEED_25GBIT;
93 case DCEM_PORTSPEED_40G:
94 case DCEM_PORTSPEED_4x10G:
95 fc_host_speed(fnic->lport->host) = FC_PORTSPEED_40GBIT;
96 fnic->lport->link_supported_speeds = FC_PORTSPEED_40GBIT;
98 case DCEM_PORTSPEED_100G:
99 fc_host_speed(fnic->lport->host) = FC_PORTSPEED_100GBIT;
100 fnic->lport->link_supported_speeds = FC_PORTSPEED_100GBIT;
103 fc_host_speed(fnic->lport->host) = FC_PORTSPEED_UNKNOWN;
104 fnic->lport->link_supported_speeds = FC_PORTSPEED_UNKNOWN;
108 if (old_link_status == fnic->link_status) {
109 if (!fnic->link_status) {
111 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
112 fnic_fc_trace_set_data(fnic->lport->host->host_no,
113 FNIC_FC_LE, "Link Status: DOWN->DOWN",
114 strlen("Link Status: DOWN->DOWN"));
116 if (old_link_down_cnt != fnic->link_down_cnt) {
117 /* UP -> DOWN -> UP */
118 fnic->lport->host_stats.link_failure_count++;
119 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
120 fnic_fc_trace_set_data(
121 fnic->lport->host->host_no,
123 "Link Status:UP_DOWN_UP",
124 strlen("Link_Status:UP_DOWN_UP")
126 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
128 fcoe_ctlr_link_down(&fnic->ctlr);
129 if (fnic->config.flags & VFCF_FIP_CAPABLE) {
130 /* start FCoE VLAN discovery */
131 fnic_fc_trace_set_data(
132 fnic->lport->host->host_no,
134 "Link Status: UP_DOWN_UP_VLAN",
136 "Link Status: UP_DOWN_UP_VLAN")
138 fnic_fcoe_send_vlan_req(fnic);
141 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
143 fcoe_ctlr_link_up(&fnic->ctlr);
146 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
147 fnic_fc_trace_set_data(
148 fnic->lport->host->host_no, FNIC_FC_LE,
149 "Link Status: UP_UP",
150 strlen("Link Status: UP_UP"));
153 } else if (fnic->link_status) {
155 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
156 if (fnic->config.flags & VFCF_FIP_CAPABLE) {
157 /* start FCoE VLAN discovery */
158 fnic_fc_trace_set_data(
159 fnic->lport->host->host_no,
160 FNIC_FC_LE, "Link Status: DOWN_UP_VLAN",
161 strlen("Link Status: DOWN_UP_VLAN"));
162 fnic_fcoe_send_vlan_req(fnic);
165 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link up\n");
166 fnic_fc_trace_set_data(fnic->lport->host->host_no, FNIC_FC_LE,
167 "Link Status: DOWN_UP", strlen("Link Status: DOWN_UP"));
168 fcoe_ctlr_link_up(&fnic->ctlr);
171 fnic->lport->host_stats.link_failure_count++;
172 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
173 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "link down\n");
174 fnic_fc_trace_set_data(
175 fnic->lport->host->host_no, FNIC_FC_LE,
176 "Link Status: UP_DOWN",
177 strlen("Link Status: UP_DOWN"));
178 if (fnic->config.flags & VFCF_FIP_CAPABLE) {
179 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
180 "deleting fip-timer during link-down\n");
181 del_timer_sync(&fnic->fip_timer);
183 fcoe_ctlr_link_down(&fnic->ctlr);
189 * This function passes incoming fabric frames to libFC
191 void fnic_handle_frame(struct work_struct *work)
193 struct fnic *fnic = container_of(work, struct fnic, frame_work);
194 struct fc_lport *lp = fnic->lport;
199 while ((skb = skb_dequeue(&fnic->frame_queue))) {
201 spin_lock_irqsave(&fnic->fnic_lock, flags);
202 if (fnic->stop_rx_link_events) {
203 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
207 fp = (struct fc_frame *)skb;
210 * If we're in a transitional state, just re-queue and return.
211 * The queue will be serviced when we get to a stable state.
213 if (fnic->state != FNIC_IN_FC_MODE &&
214 fnic->state != FNIC_IN_ETH_MODE) {
215 skb_queue_head(&fnic->frame_queue, skb);
216 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
219 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
221 fc_exch_recv(lp, fp);
225 void fnic_fcoe_evlist_free(struct fnic *fnic)
227 struct fnic_event *fevt = NULL;
228 struct fnic_event *next = NULL;
231 spin_lock_irqsave(&fnic->fnic_lock, flags);
232 if (list_empty(&fnic->evlist)) {
233 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
237 list_for_each_entry_safe(fevt, next, &fnic->evlist, list) {
238 list_del(&fevt->list);
241 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
244 void fnic_handle_event(struct work_struct *work)
246 struct fnic *fnic = container_of(work, struct fnic, event_work);
247 struct fnic_event *fevt = NULL;
248 struct fnic_event *next = NULL;
251 spin_lock_irqsave(&fnic->fnic_lock, flags);
252 if (list_empty(&fnic->evlist)) {
253 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
257 list_for_each_entry_safe(fevt, next, &fnic->evlist, list) {
258 if (fnic->stop_rx_link_events) {
259 list_del(&fevt->list);
261 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
265 * If we're in a transitional state, just re-queue and return.
266 * The queue will be serviced when we get to a stable state.
268 if (fnic->state != FNIC_IN_FC_MODE &&
269 fnic->state != FNIC_IN_ETH_MODE) {
270 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
274 list_del(&fevt->list);
275 switch (fevt->event) {
276 case FNIC_EVT_START_VLAN_DISC:
277 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
278 fnic_fcoe_send_vlan_req(fnic);
279 spin_lock_irqsave(&fnic->fnic_lock, flags);
281 case FNIC_EVT_START_FCF_DISC:
282 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
283 "Start FCF Discovery\n");
284 fnic_fcoe_start_fcf_disc(fnic);
287 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
288 "Unknown event 0x%x\n", fevt->event);
293 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
297 * Check if the Received FIP FLOGI frame is rejected
298 * @fip: The FCoE controller that received the frame
299 * @skb: The received FIP frame
301 * Returns non-zero if the frame is rejected with unsupported cmd with
302 * insufficient resource els explanation.
304 static inline int is_fnic_fip_flogi_reject(struct fcoe_ctlr *fip,
307 struct fc_lport *lport = fip->lp;
308 struct fip_header *fiph;
309 struct fc_frame_header *fh = NULL;
310 struct fip_desc *desc;
311 struct fip_encaps *els;
319 if (skb_linearize(skb))
322 if (skb->len < sizeof(*fiph))
325 fiph = (struct fip_header *)skb->data;
326 op = ntohs(fiph->fip_op);
327 sub = fiph->fip_subcode;
332 if (sub != FIP_SC_REP)
335 rlen = ntohs(fiph->fip_dl_len) * 4;
336 if (rlen + sizeof(*fiph) > skb->len)
339 desc = (struct fip_desc *)(fiph + 1);
340 dlen = desc->fip_dlen * FIP_BPW;
342 if (desc->fip_dtype == FIP_DT_FLOGI) {
344 if (dlen < sizeof(*els) + sizeof(*fh) + 1)
347 els = (struct fip_encaps *)desc;
348 fh = (struct fc_frame_header *)(els + 1);
354 * ELS command code, reason and explanation should be = Reject,
355 * unsupported command and insufficient resource
357 els_op = *(u8 *)(fh + 1);
358 if (els_op == ELS_LS_RJT) {
359 shost_printk(KERN_INFO, lport->host,
360 "Flogi Request Rejected by Switch\n");
363 shost_printk(KERN_INFO, lport->host,
364 "Flogi Request Accepted by Switch\n");
369 static void fnic_fcoe_send_vlan_req(struct fnic *fnic)
371 struct fcoe_ctlr *fip = &fnic->ctlr;
372 struct fnic_stats *fnic_stats = &fnic->fnic_stats;
375 struct fip_vlan *vlan;
378 fnic_fcoe_reset_vlans(fnic);
379 fnic->set_vlan(fnic, 0);
381 if (printk_ratelimit())
382 FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
383 "Sending VLAN request...\n");
385 skb = dev_alloc_skb(sizeof(struct fip_vlan));
389 eth_fr = (char *)skb->data;
390 vlan = (struct fip_vlan *)eth_fr;
392 memset(vlan, 0, sizeof(*vlan));
393 memcpy(vlan->eth.h_source, fip->ctl_src_addr, ETH_ALEN);
394 memcpy(vlan->eth.h_dest, fcoe_all_fcfs, ETH_ALEN);
395 vlan->eth.h_proto = htons(ETH_P_FIP);
397 vlan->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
398 vlan->fip.fip_op = htons(FIP_OP_VLAN);
399 vlan->fip.fip_subcode = FIP_SC_VL_REQ;
400 vlan->fip.fip_dl_len = htons(sizeof(vlan->desc) / FIP_BPW);
402 vlan->desc.mac.fd_desc.fip_dtype = FIP_DT_MAC;
403 vlan->desc.mac.fd_desc.fip_dlen = sizeof(vlan->desc.mac) / FIP_BPW;
404 memcpy(&vlan->desc.mac.fd_mac, fip->ctl_src_addr, ETH_ALEN);
406 vlan->desc.wwnn.fd_desc.fip_dtype = FIP_DT_NAME;
407 vlan->desc.wwnn.fd_desc.fip_dlen = sizeof(vlan->desc.wwnn) / FIP_BPW;
408 put_unaligned_be64(fip->lp->wwnn, &vlan->desc.wwnn.fd_wwn);
409 atomic64_inc(&fnic_stats->vlan_stats.vlan_disc_reqs);
411 skb_put(skb, sizeof(*vlan));
412 skb->protocol = htons(ETH_P_FIP);
413 skb_reset_mac_header(skb);
414 skb_reset_network_header(skb);
417 /* set a timer so that we can retry if there no response */
418 vlan_tov = jiffies + msecs_to_jiffies(FCOE_CTLR_FIPVLAN_TOV);
419 mod_timer(&fnic->fip_timer, round_jiffies(vlan_tov));
422 static void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct sk_buff *skb)
424 struct fcoe_ctlr *fip = &fnic->ctlr;
425 struct fip_header *fiph;
426 struct fip_desc *desc;
427 struct fnic_stats *fnic_stats = &fnic->fnic_stats;
431 struct fcoe_vlan *vlan;
435 FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
436 "Received VLAN response...\n");
438 fiph = (struct fip_header *) skb->data;
440 FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
441 "Received VLAN response... OP 0x%x SUB_OP 0x%x\n",
442 ntohs(fiph->fip_op), fiph->fip_subcode);
444 rlen = ntohs(fiph->fip_dl_len) * 4;
445 fnic_fcoe_reset_vlans(fnic);
446 spin_lock_irqsave(&fnic->vlans_lock, flags);
447 desc = (struct fip_desc *)(fiph + 1);
449 dlen = desc->fip_dlen * FIP_BPW;
450 switch (desc->fip_dtype) {
452 vid = ntohs(((struct fip_vlan_desc *)desc)->fd_vlan);
453 shost_printk(KERN_INFO, fnic->lport->host,
454 "process_vlan_resp: FIP VLAN %d\n", vid);
455 vlan = kzalloc(sizeof(*vlan), GFP_ATOMIC);
457 /* retry from timer */
458 spin_unlock_irqrestore(&fnic->vlans_lock,
462 vlan->vid = vid & 0x0fff;
463 vlan->state = FIP_VLAN_AVAIL;
464 list_add_tail(&vlan->list, &fnic->vlans);
467 desc = (struct fip_desc *)((char *)desc + dlen);
471 /* any VLAN descriptors present ? */
472 if (list_empty(&fnic->vlans)) {
473 /* retry from timer */
474 atomic64_inc(&fnic_stats->vlan_stats.resp_withno_vlanID);
475 FNIC_FCS_DBG(KERN_INFO, fnic->lport->host,
476 "No VLAN descriptors in FIP VLAN response\n");
477 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
481 vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list);
482 fnic->set_vlan(fnic, vlan->vid);
483 vlan->state = FIP_VLAN_SENT; /* sent now */
485 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
487 /* start the solicitation */
488 fcoe_ctlr_link_up(fip);
490 sol_time = jiffies + msecs_to_jiffies(FCOE_CTLR_START_DELAY);
491 mod_timer(&fnic->fip_timer, round_jiffies(sol_time));
496 static void fnic_fcoe_start_fcf_disc(struct fnic *fnic)
499 struct fcoe_vlan *vlan;
502 spin_lock_irqsave(&fnic->vlans_lock, flags);
503 vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list);
504 fnic->set_vlan(fnic, vlan->vid);
505 vlan->state = FIP_VLAN_SENT; /* sent now */
507 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
509 /* start the solicitation */
510 fcoe_ctlr_link_up(&fnic->ctlr);
512 sol_time = jiffies + msecs_to_jiffies(FCOE_CTLR_START_DELAY);
513 mod_timer(&fnic->fip_timer, round_jiffies(sol_time));
516 static int fnic_fcoe_vlan_check(struct fnic *fnic, u16 flag)
519 struct fcoe_vlan *fvlan;
521 spin_lock_irqsave(&fnic->vlans_lock, flags);
522 if (list_empty(&fnic->vlans)) {
523 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
527 fvlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list);
528 if (fvlan->state == FIP_VLAN_USED) {
529 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
533 if (fvlan->state == FIP_VLAN_SENT) {
534 fvlan->state = FIP_VLAN_USED;
535 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
538 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
542 static void fnic_event_enq(struct fnic *fnic, enum fnic_evt ev)
544 struct fnic_event *fevt;
547 fevt = kmalloc(sizeof(*fevt), GFP_ATOMIC);
554 spin_lock_irqsave(&fnic->fnic_lock, flags);
555 list_add_tail(&fevt->list, &fnic->evlist);
556 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
558 schedule_work(&fnic->event_work);
561 static int fnic_fcoe_handle_fip_frame(struct fnic *fnic, struct sk_buff *skb)
563 struct fip_header *fiph;
568 if (!skb || !(skb->data))
571 if (skb_linearize(skb))
574 fiph = (struct fip_header *)skb->data;
575 op = ntohs(fiph->fip_op);
576 sub = fiph->fip_subcode;
578 if (FIP_VER_DECAPS(fiph->fip_ver) != FIP_VER)
581 if (ntohs(fiph->fip_dl_len) * FIP_BPW + sizeof(*fiph) > skb->len)
584 if (op == FIP_OP_DISC && sub == FIP_SC_ADV) {
585 if (fnic_fcoe_vlan_check(fnic, ntohs(fiph->fip_flags)))
587 /* pass it on to fcoe */
589 } else if (op == FIP_OP_VLAN && sub == FIP_SC_VL_NOTE) {
590 /* set the vlan as used */
591 fnic_fcoe_process_vlan_resp(fnic, skb);
593 } else if (op == FIP_OP_CTRL && sub == FIP_SC_CLR_VLINK) {
594 /* received CVL request, restart vlan disc */
595 fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
596 /* pass it on to fcoe */
603 void fnic_handle_fip_frame(struct work_struct *work)
605 struct fnic *fnic = container_of(work, struct fnic, fip_frame_work);
606 struct fnic_stats *fnic_stats = &fnic->fnic_stats;
611 while ((skb = skb_dequeue(&fnic->fip_frame_queue))) {
612 spin_lock_irqsave(&fnic->fnic_lock, flags);
613 if (fnic->stop_rx_link_events) {
614 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
619 * If we're in a transitional state, just re-queue and return.
620 * The queue will be serviced when we get to a stable state.
622 if (fnic->state != FNIC_IN_FC_MODE &&
623 fnic->state != FNIC_IN_ETH_MODE) {
624 skb_queue_head(&fnic->fip_frame_queue, skb);
625 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
628 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
629 eh = (struct ethhdr *)skb->data;
630 if (eh->h_proto == htons(ETH_P_FIP)) {
631 skb_pull(skb, sizeof(*eh));
632 if (fnic_fcoe_handle_fip_frame(fnic, skb) <= 0) {
637 * If there's FLOGI rejects - clear all
638 * fcf's & restart from scratch
640 if (is_fnic_fip_flogi_reject(&fnic->ctlr, skb)) {
642 &fnic_stats->vlan_stats.flogi_rejects);
643 shost_printk(KERN_INFO, fnic->lport->host,
644 "Trigger a Link down - VLAN Disc\n");
645 fcoe_ctlr_link_down(&fnic->ctlr);
646 /* start FCoE VLAN discovery */
647 fnic_fcoe_send_vlan_req(fnic);
651 fcoe_ctlr_recv(&fnic->ctlr, skb);
658 * fnic_import_rq_eth_pkt() - handle received FCoE or FIP frame.
659 * @fnic: fnic instance.
660 * @skb: Ethernet Frame.
662 static inline int fnic_import_rq_eth_pkt(struct fnic *fnic, struct sk_buff *skb)
666 struct fcoe_hdr *fcoe_hdr;
667 struct fcoe_crc_eof *ft;
670 * Undo VLAN encapsulation if present.
672 eh = (struct ethhdr *)skb->data;
673 if (eh->h_proto == htons(ETH_P_8021Q)) {
674 memmove((u8 *)eh + VLAN_HLEN, eh, ETH_ALEN * 2);
675 eh = skb_pull(skb, VLAN_HLEN);
676 skb_reset_mac_header(skb);
678 if (eh->h_proto == htons(ETH_P_FIP)) {
679 if (!(fnic->config.flags & VFCF_FIP_CAPABLE)) {
680 printk(KERN_ERR "Dropped FIP frame, as firmware "
681 "uses non-FIP mode, Enable FIP "
685 if ((fnic_fc_trace_set_data(fnic->lport->host->host_no,
686 FNIC_FC_RECV|0x80, (char *)skb->data, skb->len)) != 0) {
687 printk(KERN_ERR "fnic ctlr frame trace error!!!");
689 skb_queue_tail(&fnic->fip_frame_queue, skb);
690 queue_work(fnic_fip_queue, &fnic->fip_frame_work);
691 return 1; /* let caller know packet was used */
693 if (eh->h_proto != htons(ETH_P_FCOE))
695 skb_set_network_header(skb, sizeof(*eh));
696 skb_pull(skb, sizeof(*eh));
698 fcoe_hdr = (struct fcoe_hdr *)skb->data;
699 if (FC_FCOE_DECAPS_VER(fcoe_hdr) != FC_FCOE_VER)
702 fp = (struct fc_frame *)skb;
704 fr_sof(fp) = fcoe_hdr->fcoe_sof;
705 skb_pull(skb, sizeof(struct fcoe_hdr));
706 skb_reset_transport_header(skb);
708 ft = (struct fcoe_crc_eof *)(skb->data + skb->len - sizeof(*ft));
709 fr_eof(fp) = ft->fcoe_eof;
710 skb_trim(skb, skb->len - sizeof(*ft));
713 dev_kfree_skb_irq(skb);
718 * fnic_update_mac_locked() - set data MAC address and filters.
719 * @fnic: fnic instance.
720 * @new: newly-assigned FCoE MAC address.
722 * Called with the fnic lock held.
724 void fnic_update_mac_locked(struct fnic *fnic, u8 *new)
726 u8 *ctl = fnic->ctlr.ctl_src_addr;
727 u8 *data = fnic->data_src_addr;
729 if (is_zero_ether_addr(new))
731 if (ether_addr_equal(data, new))
733 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host, "update_mac %pM\n", new);
734 if (!is_zero_ether_addr(data) && !ether_addr_equal(data, ctl))
735 vnic_dev_del_addr(fnic->vdev, data);
736 memcpy(data, new, ETH_ALEN);
737 if (!ether_addr_equal(new, ctl))
738 vnic_dev_add_addr(fnic->vdev, new);
742 * fnic_update_mac() - set data MAC address and filters.
743 * @lport: local port.
744 * @new: newly-assigned FCoE MAC address.
746 void fnic_update_mac(struct fc_lport *lport, u8 *new)
748 struct fnic *fnic = lport_priv(lport);
750 spin_lock_irq(&fnic->fnic_lock);
751 fnic_update_mac_locked(fnic, new);
752 spin_unlock_irq(&fnic->fnic_lock);
756 * fnic_set_port_id() - set the port_ID after successful FLOGI.
757 * @lport: local port.
758 * @port_id: assigned FC_ID.
759 * @fp: received frame containing the FLOGI accept or NULL.
761 * This is called from libfc when a new FC_ID has been assigned.
762 * This causes us to reset the firmware to FC_MODE and setup the new MAC
765 * It is also called with FC_ID 0 when we're logged off.
767 * If the FC_ID is due to point-to-point, fp may be NULL.
769 void fnic_set_port_id(struct fc_lport *lport, u32 port_id, struct fc_frame *fp)
771 struct fnic *fnic = lport_priv(lport);
775 FNIC_FCS_DBG(KERN_DEBUG, lport->host, "set port_id %x fp %p\n",
779 * If we're clearing the FC_ID, change to use the ctl_src_addr.
780 * Set ethernet mode to send FLOGI.
783 fnic_update_mac(lport, fnic->ctlr.ctl_src_addr);
784 fnic_set_eth_mode(fnic);
789 mac = fr_cb(fp)->granted_mac;
790 if (is_zero_ether_addr(mac)) {
791 /* non-FIP - FLOGI already accepted - ignore return */
792 fcoe_ctlr_recv_flogi(&fnic->ctlr, lport, fp);
794 fnic_update_mac(lport, mac);
797 /* Change state to reflect transition to FC mode */
798 spin_lock_irq(&fnic->fnic_lock);
799 if (fnic->state == FNIC_IN_ETH_MODE || fnic->state == FNIC_IN_FC_MODE)
800 fnic->state = FNIC_IN_ETH_TRANS_FC_MODE;
802 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
803 "Unexpected fnic state %s while"
804 " processing flogi resp\n",
805 fnic_state_to_str(fnic->state));
806 spin_unlock_irq(&fnic->fnic_lock);
809 spin_unlock_irq(&fnic->fnic_lock);
812 * Send FLOGI registration to firmware to set up FC mode.
813 * The new address will be set up when registration completes.
815 ret = fnic_flogi_reg_handler(fnic, port_id);
818 spin_lock_irq(&fnic->fnic_lock);
819 if (fnic->state == FNIC_IN_ETH_TRANS_FC_MODE)
820 fnic->state = FNIC_IN_ETH_MODE;
821 spin_unlock_irq(&fnic->fnic_lock);
825 static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc
826 *cq_desc, struct vnic_rq_buf *buf,
827 int skipped __attribute__((unused)),
830 struct fnic *fnic = vnic_dev_priv(rq->vdev);
833 struct fnic_stats *fnic_stats = &fnic->fnic_stats;
834 u8 type, color, eop, sop, ingress_port, vlan_stripped;
835 u8 fcoe = 0, fcoe_sof, fcoe_eof;
836 u8 fcoe_fc_crc_ok = 1, fcoe_enc_error = 0;
837 u8 tcp_udp_csum_ok, udp, tcp, ipv4_csum_ok;
838 u8 ipv6, ipv4, ipv4_fragment, rss_type, csum_not_calc;
839 u8 fcs_ok = 1, packet_error = 0;
840 u16 q_number, completed_index, bytes_written = 0, vlan, checksum;
842 u16 exchange_id, tmpl;
845 u32 fcp_bytes_written = 0;
848 dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len,
851 fp = (struct fc_frame *)skb;
854 cq_desc_dec(cq_desc, &type, &color, &q_number, &completed_index);
855 if (type == CQ_DESC_TYPE_RQ_FCP) {
856 cq_fcp_rq_desc_dec((struct cq_fcp_rq_desc *)cq_desc,
857 &type, &color, &q_number, &completed_index,
858 &eop, &sop, &fcoe_fc_crc_ok, &exchange_id,
859 &tmpl, &fcp_bytes_written, &sof, &eof,
860 &ingress_port, &packet_error,
861 &fcoe_enc_error, &fcs_ok, &vlan_stripped,
863 skb_trim(skb, fcp_bytes_written);
867 } else if (type == CQ_DESC_TYPE_RQ_ENET) {
868 cq_enet_rq_desc_dec((struct cq_enet_rq_desc *)cq_desc,
869 &type, &color, &q_number, &completed_index,
870 &ingress_port, &fcoe, &eop, &sop,
871 &rss_type, &csum_not_calc, &rss_hash,
872 &bytes_written, &packet_error,
873 &vlan_stripped, &vlan, &checksum,
874 &fcoe_sof, &fcoe_fc_crc_ok,
875 &fcoe_enc_error, &fcoe_eof,
876 &tcp_udp_csum_ok, &udp, &tcp,
877 &ipv4_csum_ok, &ipv6, &ipv4,
878 &ipv4_fragment, &fcs_ok);
879 skb_trim(skb, bytes_written);
881 atomic64_inc(&fnic_stats->misc_stats.frame_errors);
882 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
883 "fcs error. dropping packet.\n");
886 if (fnic_import_rq_eth_pkt(fnic, skb))
891 shost_printk(KERN_ERR, fnic->lport->host,
892 "fnic rq_cmpl wrong cq type x%x\n", type);
896 if (!fcs_ok || packet_error || !fcoe_fc_crc_ok || fcoe_enc_error) {
897 atomic64_inc(&fnic_stats->misc_stats.frame_errors);
898 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
899 "fnic rq_cmpl fcoe x%x fcsok x%x"
900 " pkterr x%x fcoe_fc_crc_ok x%x, fcoe_enc_err"
902 fcoe, fcs_ok, packet_error,
903 fcoe_fc_crc_ok, fcoe_enc_error);
907 spin_lock_irqsave(&fnic->fnic_lock, flags);
908 if (fnic->stop_rx_link_events) {
909 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
912 fr_dev(fp) = fnic->lport;
913 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
914 if ((fnic_fc_trace_set_data(fnic->lport->host->host_no, FNIC_FC_RECV,
915 (char *)skb->data, skb->len)) != 0) {
916 printk(KERN_ERR "fnic ctlr frame trace error!!!");
919 skb_queue_tail(&fnic->frame_queue, skb);
920 queue_work(fnic_event_queue, &fnic->frame_work);
924 dev_kfree_skb_irq(skb);
927 static int fnic_rq_cmpl_handler_cont(struct vnic_dev *vdev,
928 struct cq_desc *cq_desc, u8 type,
929 u16 q_number, u16 completed_index,
932 struct fnic *fnic = vnic_dev_priv(vdev);
934 vnic_rq_service(&fnic->rq[q_number], cq_desc, completed_index,
935 VNIC_RQ_RETURN_DESC, fnic_rq_cmpl_frame_recv,
940 int fnic_rq_cmpl_handler(struct fnic *fnic, int rq_work_to_do)
942 unsigned int tot_rq_work_done = 0, cur_work_done;
946 for (i = 0; i < fnic->rq_count; i++) {
947 cur_work_done = vnic_cq_service(&fnic->cq[i], rq_work_to_do,
948 fnic_rq_cmpl_handler_cont,
951 err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame);
953 shost_printk(KERN_ERR, fnic->lport->host,
954 "fnic_alloc_rq_frame can't alloc"
957 tot_rq_work_done += cur_work_done;
960 return tot_rq_work_done;
964 * This function is called once at init time to allocate and fill RQ
965 * buffers. Subsequently, it is called in the interrupt context after RQ
966 * buffer processing to replenish the buffers in the RQ
968 int fnic_alloc_rq_frame(struct vnic_rq *rq)
970 struct fnic *fnic = vnic_dev_priv(rq->vdev);
976 len = FC_FRAME_HEADROOM + FC_MAX_FRAME + FC_FRAME_TAILROOM;
977 skb = dev_alloc_skb(len);
979 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
980 "Unable to allocate RQ sk_buff\n");
983 skb_reset_mac_header(skb);
984 skb_reset_transport_header(skb);
985 skb_reset_network_header(skb);
987 pa = dma_map_single(&fnic->pdev->dev, skb->data, len, DMA_FROM_DEVICE);
988 if (dma_mapping_error(&fnic->pdev->dev, pa)) {
990 printk(KERN_ERR "PCI mapping failed with error %d\n", r);
994 fnic_queue_rq_desc(rq, skb, pa, len);
1002 void fnic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf)
1004 struct fc_frame *fp = buf->os_buf;
1005 struct fnic *fnic = vnic_dev_priv(rq->vdev);
1007 dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len,
1010 dev_kfree_skb(fp_skb(fp));
1015 * fnic_eth_send() - Send Ethernet frame.
1016 * @fip: fcoe_ctlr instance.
1017 * @skb: Ethernet Frame, FIP, without VLAN encapsulation.
1019 void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
1021 struct fnic *fnic = fnic_from_ctlr(fip);
1022 struct vnic_wq *wq = &fnic->wq[0];
1024 struct ethhdr *eth_hdr;
1025 struct vlan_ethhdr *vlan_hdr;
1026 unsigned long flags;
1028 if (!fnic->vlan_hw_insert) {
1029 eth_hdr = (struct ethhdr *)skb_mac_header(skb);
1030 vlan_hdr = skb_push(skb, sizeof(*vlan_hdr) - sizeof(*eth_hdr));
1031 memcpy(vlan_hdr, eth_hdr, 2 * ETH_ALEN);
1032 vlan_hdr->h_vlan_proto = htons(ETH_P_8021Q);
1033 vlan_hdr->h_vlan_encapsulated_proto = eth_hdr->h_proto;
1034 vlan_hdr->h_vlan_TCI = htons(fnic->vlan_id);
1035 if ((fnic_fc_trace_set_data(fnic->lport->host->host_no,
1036 FNIC_FC_SEND|0x80, (char *)eth_hdr, skb->len)) != 0) {
1037 printk(KERN_ERR "fnic ctlr frame trace error!!!");
1040 if ((fnic_fc_trace_set_data(fnic->lport->host->host_no,
1041 FNIC_FC_SEND|0x80, (char *)skb->data, skb->len)) != 0) {
1042 printk(KERN_ERR "fnic ctlr frame trace error!!!");
1046 pa = dma_map_single(&fnic->pdev->dev, skb->data, skb->len,
1048 if (dma_mapping_error(&fnic->pdev->dev, pa)) {
1049 printk(KERN_ERR "DMA mapping failed\n");
1053 spin_lock_irqsave(&fnic->wq_lock[0], flags);
1054 if (!vnic_wq_desc_avail(wq))
1057 fnic_queue_wq_eth_desc(wq, skb, pa, skb->len,
1058 0 /* hw inserts cos value */,
1060 spin_unlock_irqrestore(&fnic->wq_lock[0], flags);
1064 spin_unlock_irqrestore(&fnic->wq_lock[0], flags);
1065 dma_unmap_single(&fnic->pdev->dev, pa, skb->len, DMA_TO_DEVICE);
1073 static int fnic_send_frame(struct fnic *fnic, struct fc_frame *fp)
1075 struct vnic_wq *wq = &fnic->wq[0];
1076 struct sk_buff *skb;
1078 struct ethhdr *eth_hdr;
1079 struct vlan_ethhdr *vlan_hdr;
1080 struct fcoe_hdr *fcoe_hdr;
1081 struct fc_frame_header *fh;
1082 u32 tot_len, eth_hdr_len;
1084 unsigned long flags;
1086 fh = fc_frame_header_get(fp);
1089 if (unlikely(fh->fh_r_ctl == FC_RCTL_ELS_REQ) &&
1090 fcoe_ctlr_els_send(&fnic->ctlr, fnic->lport, skb))
1093 if (!fnic->vlan_hw_insert) {
1094 eth_hdr_len = sizeof(*vlan_hdr) + sizeof(*fcoe_hdr);
1095 vlan_hdr = skb_push(skb, eth_hdr_len);
1096 eth_hdr = (struct ethhdr *)vlan_hdr;
1097 vlan_hdr->h_vlan_proto = htons(ETH_P_8021Q);
1098 vlan_hdr->h_vlan_encapsulated_proto = htons(ETH_P_FCOE);
1099 vlan_hdr->h_vlan_TCI = htons(fnic->vlan_id);
1100 fcoe_hdr = (struct fcoe_hdr *)(vlan_hdr + 1);
1102 eth_hdr_len = sizeof(*eth_hdr) + sizeof(*fcoe_hdr);
1103 eth_hdr = skb_push(skb, eth_hdr_len);
1104 eth_hdr->h_proto = htons(ETH_P_FCOE);
1105 fcoe_hdr = (struct fcoe_hdr *)(eth_hdr + 1);
1108 if (fnic->ctlr.map_dest)
1109 fc_fcoe_set_mac(eth_hdr->h_dest, fh->fh_d_id);
1111 memcpy(eth_hdr->h_dest, fnic->ctlr.dest_addr, ETH_ALEN);
1112 memcpy(eth_hdr->h_source, fnic->data_src_addr, ETH_ALEN);
1115 BUG_ON(tot_len % 4);
1117 memset(fcoe_hdr, 0, sizeof(*fcoe_hdr));
1118 fcoe_hdr->fcoe_sof = fr_sof(fp);
1120 FC_FCOE_ENCAPS_VER(fcoe_hdr, FC_FCOE_VER);
1122 pa = dma_map_single(&fnic->pdev->dev, eth_hdr, tot_len, DMA_TO_DEVICE);
1123 if (dma_mapping_error(&fnic->pdev->dev, pa)) {
1125 printk(KERN_ERR "DMA map failed with error %d\n", ret);
1126 goto free_skb_on_err;
1129 if ((fnic_fc_trace_set_data(fnic->lport->host->host_no, FNIC_FC_SEND,
1130 (char *)eth_hdr, tot_len)) != 0) {
1131 printk(KERN_ERR "fnic ctlr frame trace error!!!");
1134 spin_lock_irqsave(&fnic->wq_lock[0], flags);
1136 if (!vnic_wq_desc_avail(wq)) {
1137 dma_unmap_single(&fnic->pdev->dev, pa, tot_len, DMA_TO_DEVICE);
1142 fnic_queue_wq_desc(wq, skb, pa, tot_len, fr_eof(fp),
1143 0 /* hw inserts cos value */,
1144 fnic->vlan_id, 1, 1, 1);
1147 spin_unlock_irqrestore(&fnic->wq_lock[0], flags);
1151 dev_kfree_skb_any(fp_skb(fp));
1158 * Routine to send a raw frame
1160 int fnic_send(struct fc_lport *lp, struct fc_frame *fp)
1162 struct fnic *fnic = lport_priv(lp);
1163 unsigned long flags;
1165 if (fnic->in_remove) {
1166 dev_kfree_skb(fp_skb(fp));
1171 * Queue frame if in a transitional state.
1172 * This occurs while registering the Port_ID / MAC address after FLOGI.
1174 spin_lock_irqsave(&fnic->fnic_lock, flags);
1175 if (fnic->state != FNIC_IN_FC_MODE && fnic->state != FNIC_IN_ETH_MODE) {
1176 skb_queue_tail(&fnic->tx_queue, fp_skb(fp));
1177 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1180 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1182 return fnic_send_frame(fnic, fp);
1186 * fnic_flush_tx() - send queued frames.
1187 * @fnic: fnic device
1189 * Send frames that were waiting to go out in FC or Ethernet mode.
1190 * Whenever changing modes we purge queued frames, so these frames should
1191 * be queued for the stable mode that we're in, either FC or Ethernet.
1193 * Called without fnic_lock held.
1195 void fnic_flush_tx(struct fnic *fnic)
1197 struct sk_buff *skb;
1198 struct fc_frame *fp;
1200 while ((skb = skb_dequeue(&fnic->tx_queue))) {
1201 fp = (struct fc_frame *)skb;
1202 fnic_send_frame(fnic, fp);
1207 * fnic_set_eth_mode() - put fnic into ethernet mode.
1208 * @fnic: fnic device
1210 * Called without fnic lock held.
1212 static void fnic_set_eth_mode(struct fnic *fnic)
1214 unsigned long flags;
1215 enum fnic_state old_state;
1218 spin_lock_irqsave(&fnic->fnic_lock, flags);
1220 old_state = fnic->state;
1221 switch (old_state) {
1222 case FNIC_IN_FC_MODE:
1223 case FNIC_IN_ETH_TRANS_FC_MODE:
1225 fnic->state = FNIC_IN_FC_TRANS_ETH_MODE;
1226 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1228 ret = fnic_fw_reset_handler(fnic);
1230 spin_lock_irqsave(&fnic->fnic_lock, flags);
1231 if (fnic->state != FNIC_IN_FC_TRANS_ETH_MODE)
1234 fnic->state = old_state;
1237 case FNIC_IN_FC_TRANS_ETH_MODE:
1238 case FNIC_IN_ETH_MODE:
1241 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1244 static void fnic_wq_complete_frame_send(struct vnic_wq *wq,
1245 struct cq_desc *cq_desc,
1246 struct vnic_wq_buf *buf, void *opaque)
1248 struct sk_buff *skb = buf->os_buf;
1249 struct fc_frame *fp = (struct fc_frame *)skb;
1250 struct fnic *fnic = vnic_dev_priv(wq->vdev);
1252 dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len,
1254 dev_kfree_skb_irq(fp_skb(fp));
1258 static int fnic_wq_cmpl_handler_cont(struct vnic_dev *vdev,
1259 struct cq_desc *cq_desc, u8 type,
1260 u16 q_number, u16 completed_index,
1263 struct fnic *fnic = vnic_dev_priv(vdev);
1264 unsigned long flags;
1266 spin_lock_irqsave(&fnic->wq_lock[q_number], flags);
1267 vnic_wq_service(&fnic->wq[q_number], cq_desc, completed_index,
1268 fnic_wq_complete_frame_send, NULL);
1269 spin_unlock_irqrestore(&fnic->wq_lock[q_number], flags);
1274 int fnic_wq_cmpl_handler(struct fnic *fnic, int work_to_do)
1276 unsigned int wq_work_done = 0;
1279 for (i = 0; i < fnic->raw_wq_count; i++) {
1280 wq_work_done += vnic_cq_service(&fnic->cq[fnic->rq_count+i],
1282 fnic_wq_cmpl_handler_cont,
1286 return wq_work_done;
1290 void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf)
1292 struct fc_frame *fp = buf->os_buf;
1293 struct fnic *fnic = vnic_dev_priv(wq->vdev);
1295 dma_unmap_single(&fnic->pdev->dev, buf->dma_addr, buf->len,
1298 dev_kfree_skb(fp_skb(fp));
1302 void fnic_fcoe_reset_vlans(struct fnic *fnic)
1304 unsigned long flags;
1305 struct fcoe_vlan *vlan;
1306 struct fcoe_vlan *next;
1309 * indicate a link down to fcoe so that all fcf's are free'd
1310 * might not be required since we did this before sending vlan
1313 spin_lock_irqsave(&fnic->vlans_lock, flags);
1314 if (!list_empty(&fnic->vlans)) {
1315 list_for_each_entry_safe(vlan, next, &fnic->vlans, list) {
1316 list_del(&vlan->list);
1320 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1323 void fnic_handle_fip_timer(struct fnic *fnic)
1325 unsigned long flags;
1326 struct fcoe_vlan *vlan;
1327 struct fnic_stats *fnic_stats = &fnic->fnic_stats;
1330 spin_lock_irqsave(&fnic->fnic_lock, flags);
1331 if (fnic->stop_rx_link_events) {
1332 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1335 spin_unlock_irqrestore(&fnic->fnic_lock, flags);
1337 if (fnic->ctlr.mode == FIP_MODE_NON_FIP)
1340 spin_lock_irqsave(&fnic->vlans_lock, flags);
1341 if (list_empty(&fnic->vlans)) {
1342 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1343 /* no vlans available, try again */
1344 if (printk_ratelimit())
1345 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
1346 "Start VLAN Discovery\n");
1347 fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
1351 vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list);
1352 shost_printk(KERN_DEBUG, fnic->lport->host,
1353 "fip_timer: vlan %d state %d sol_count %d\n",
1354 vlan->vid, vlan->state, vlan->sol_count);
1355 switch (vlan->state) {
1357 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
1358 "FIP VLAN is selected for FC transaction\n");
1359 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1361 case FIP_VLAN_FAILED:
1362 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1363 /* if all vlans are in failed state, restart vlan disc */
1364 if (printk_ratelimit())
1365 FNIC_FCS_DBG(KERN_DEBUG, fnic->lport->host,
1366 "Start VLAN Discovery\n");
1367 fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
1370 if (vlan->sol_count >= FCOE_CTLR_MAX_SOL) {
1372 * no response on this vlan, remove from the list.
1375 shost_printk(KERN_INFO, fnic->lport->host,
1376 "Dequeue this VLAN ID %d from list\n",
1378 list_del(&vlan->list);
1381 if (list_empty(&fnic->vlans)) {
1382 /* we exhausted all vlans, restart vlan disc */
1383 spin_unlock_irqrestore(&fnic->vlans_lock,
1385 shost_printk(KERN_INFO, fnic->lport->host,
1386 "fip_timer: vlan list empty, "
1387 "trigger vlan disc\n");
1388 fnic_event_enq(fnic, FNIC_EVT_START_VLAN_DISC);
1391 /* check the next vlan */
1392 vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan,
1394 fnic->set_vlan(fnic, vlan->vid);
1395 vlan->state = FIP_VLAN_SENT; /* sent now */
1397 spin_unlock_irqrestore(&fnic->vlans_lock, flags);
1398 atomic64_inc(&fnic_stats->vlan_stats.sol_expiry_count);
1400 sol_time = jiffies + msecs_to_jiffies
1401 (FCOE_CTLR_START_DELAY);
1402 mod_timer(&fnic->fip_timer, round_jiffies(sol_time));