18 #include <linux/errno.h>
19 #include <linux/pci.h>
20 #include <linux/slab.h>
24 #include <linux/if_ether.h>
25 #include <linux/if_vlan.h>
39 static void fnic_set_eth_mode(
struct fnic *);
46 u32 old_link_down_cnt;
51 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
63 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
67 fnic->
lport->host_stats.link_failure_count++;
68 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
77 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
81 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
86 fnic->
lport->host_stats.link_failure_count++;
87 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
109 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
122 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
125 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
150 skb_reset_mac_header(skb);
159 skb_set_network_header(skb,
sizeof(*eh));
162 fcoe_hdr = (
struct fcoe_hdr *)skb->
data;
169 skb_pull(skb,
sizeof(
struct fcoe_hdr));
170 skb_reset_transport_header(skb);
193 if (is_zero_ether_addr(
new))
195 if (!compare_ether_addr(data,
new))
198 if (!is_zero_ether_addr(data) && compare_ether_addr(data, ctl))
201 if (compare_ether_addr(
new, ctl))
212 struct fnic *fnic = lport_priv(lport);
235 struct fnic *fnic = lport_priv(lport);
248 fnic_set_eth_mode(fnic);
253 mac =
fr_cb(fp)->granted_mac;
254 if (is_zero_ether_addr(mac)) {
267 "Unexpected fnic state %s while"
268 " processing flogi resp\n",
297 unsigned int eth_hdrs_stripped;
298 u8 type,
color, eop, sop, ingress_port, vlan_stripped;
300 u8 fcoe_fc_crc_ok = 1, fcoe_enc_error = 0;
301 u8 tcp_udp_csum_ok, udp, tcp, ipv4_csum_ok;
302 u8 ipv6, ipv4, ipv4_fragment, rss_type, csum_not_calc;
303 u8 fcs_ok = 1, packet_error = 0;
309 u32 fcp_bytes_written = 0;
318 cq_desc_dec(cq_desc, &type, &color, &q_number, &completed_index);
321 &type, &color, &q_number, &completed_index,
322 &eop, &sop, &fcoe_fc_crc_ok, &exchange_id,
323 &tmpl, &fcp_bytes_written, &sof, &eof,
324 &ingress_port, &packet_error,
325 &fcoe_enc_error, &fcs_ok, &vlan_stripped,
327 eth_hdrs_stripped = 1;
334 &type, &color, &q_number, &completed_index,
335 &ingress_port, &fcoe, &eop, &sop,
336 &rss_type, &csum_not_calc, &rss_hash,
337 &bytes_written, &packet_error,
338 &vlan_stripped, &
vlan, &checksum,
339 &fcoe_sof, &fcoe_fc_crc_ok,
340 &fcoe_enc_error, &fcoe_eof,
341 &tcp_udp_csum_ok, &udp, &tcp,
342 &ipv4_csum_ok, &ipv6, &ipv4,
343 &ipv4_fragment, &fcs_ok);
344 eth_hdrs_stripped = 0;
348 "fcs error. dropping packet.\n");
351 if (fnic_import_rq_eth_pkt(fnic, skb))
357 "fnic rq_cmpl wrong cq type x%x\n", type);
361 if (!fcs_ok || packet_error || !fcoe_fc_crc_ok || fcoe_enc_error) {
363 "fnic rq_cmpl fcoe x%x fcsok x%x"
364 " pkterr x%x fcoe_fc_crc_ok x%x, fcoe_enc_err"
366 fcoe, fcs_ok, packet_error,
367 fcoe_fc_crc_ok, fcoe_enc_error);
373 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
377 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
387 static int fnic_rq_cmpl_handler_cont(
struct vnic_dev *vdev,
388 struct cq_desc *cq_desc,
u8 type,
389 u16 q_number,
u16 completed_index,
402 unsigned int tot_rq_work_done = 0, cur_work_done;
406 for (i = 0; i < fnic->
rq_count; i++) {
408 fnic_rq_cmpl_handler_cont,
414 "fnic_alloc_rq_frame can't alloc"
417 tot_rq_work_done += cur_work_done;
420 return tot_rq_work_done;
436 skb = dev_alloc_skb(len);
439 "Unable to allocate RQ sk_buff\n");
442 skb_reset_mac_header(skb);
443 skb_reset_transport_header(skb);
444 skb_reset_network_header(skb);
447 fnic_queue_rq_desc(rq, skb, pa, len);
459 dev_kfree_skb(
fp_skb(fp));
470 struct fnic *fnic = fnic_from_ctlr(fip);
478 eth_hdr = (
struct ethhdr *)skb_mac_header(skb);
480 sizeof(*vlan_hdr) -
sizeof(*eth_hdr));
492 spin_unlock_irqrestore(&fnic->
wq_lock[0], flags);
497 fnic_queue_wq_eth_desc(wq, skb, pa, skb->
len,
499 spin_unlock_irqrestore(&fnic->
wq_lock[0], flags);
505 static int fnic_send_frame(
struct fnic *fnic,
struct fc_frame *fp)
512 struct fcoe_hdr *fcoe_hdr;
514 u32 tot_len, eth_hdr_len;
518 fh = fc_frame_header_get(fp);
526 eth_hdr_len =
sizeof(*vlan_hdr) +
sizeof(*fcoe_hdr);
528 eth_hdr = (
struct ethhdr *)vlan_hdr;
532 fcoe_hdr = (
struct fcoe_hdr *)(vlan_hdr + 1);
534 eth_hdr_len =
sizeof(*eth_hdr) +
sizeof(*fcoe_hdr);
537 fcoe_hdr = (
struct fcoe_hdr *)(eth_hdr + 1);
540 if (fnic->
ctlr.map_dest)
549 memset(fcoe_hdr, 0,
sizeof(*fcoe_hdr));
550 fcoe_hdr->fcoe_sof =
fr_sof(fp);
559 pci_unmap_single(fnic->
pdev, pa,
562 goto fnic_send_frame_end;
565 fnic_queue_wq_desc(wq, skb, pa, tot_len,
fr_eof(fp),
568 spin_unlock_irqrestore(&fnic->
wq_lock[0], flags);
582 struct fnic *fnic = lport_priv(lp);
586 dev_kfree_skb(
fp_skb(fp));
597 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
600 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
602 return fnic_send_frame(fnic, fp);
622 fnic_send_frame(fnic, fp);
632 static void fnic_set_eth_mode(
struct fnic *fnic)
640 old_state = fnic->
state;
646 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
654 fnic->
state = old_state;
661 spin_unlock_irqrestore(&fnic->
fnic_lock, flags);
664 static void fnic_wq_complete_frame_send(
struct vnic_wq *wq,
665 struct cq_desc *cq_desc,
678 static int fnic_wq_cmpl_handler_cont(
struct vnic_dev *
vdev,
679 struct cq_desc *cq_desc,
u8 type,
680 u16 q_number,
u16 completed_index,
688 fnic_wq_complete_frame_send,
NULL);
689 spin_unlock_irqrestore(&fnic->
wq_lock[q_number], flags);
696 unsigned int wq_work_done = 0;
702 fnic_wq_cmpl_handler_cont,
718 dev_kfree_skb(
fp_skb(fp));