1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35#ifdef CONFIG_CHELSIO_T4_FCOE
36
37#include <scsi/fc/fc_fs.h>
38#include <scsi/libfcoe.h>
39#include "cxgb4.h"
40
41bool cxgb_fcoe_sof_eof_supported(struct adapter *adap, struct sk_buff *skb)
42{
43 struct fcoe_hdr *fcoeh = (struct fcoe_hdr *)skb_network_header(skb);
44 u8 sof = fcoeh->fcoe_sof;
45 u8 eof = 0;
46
47 if ((sof != FC_SOF_I3) && (sof != FC_SOF_N3)) {
48 dev_err(adap->pdev_dev, "Unsupported SOF 0x%x\n", sof);
49 return false;
50 }
51
52 skb_copy_bits(skb, skb->len - 4, &eof, 1);
53
54 if ((eof != FC_EOF_N) && (eof != FC_EOF_T)) {
55 dev_err(adap->pdev_dev, "Unsupported EOF 0x%x\n", eof);
56 return false;
57 }
58
59 return true;
60}
61
62
63
64
65
66
67
68int cxgb_fcoe_enable(struct net_device *netdev)
69{
70 struct port_info *pi = netdev_priv(netdev);
71 struct adapter *adap = pi->adapter;
72 struct cxgb_fcoe *fcoe = &pi->fcoe;
73
74 if (is_t4(adap->params.chip))
75 return -EINVAL;
76
77 if (!(adap->flags & FULL_INIT_DONE))
78 return -EINVAL;
79
80 dev_info(adap->pdev_dev, "Enabling FCoE offload features\n");
81
82 netdev->features |= NETIF_F_FCOE_CRC;
83 netdev->vlan_features |= NETIF_F_FCOE_CRC;
84 netdev->features |= NETIF_F_FCOE_MTU;
85 netdev->vlan_features |= NETIF_F_FCOE_MTU;
86
87 netdev_features_change(netdev);
88
89 fcoe->flags |= CXGB_FCOE_ENABLED;
90
91 return 0;
92}
93
94
95
96
97
98
99
100int cxgb_fcoe_disable(struct net_device *netdev)
101{
102 struct port_info *pi = netdev_priv(netdev);
103 struct adapter *adap = pi->adapter;
104 struct cxgb_fcoe *fcoe = &pi->fcoe;
105
106 if (!(fcoe->flags & CXGB_FCOE_ENABLED))
107 return -EINVAL;
108
109 dev_info(adap->pdev_dev, "Disabling FCoE offload features\n");
110
111 fcoe->flags &= ~CXGB_FCOE_ENABLED;
112
113 netdev->features &= ~NETIF_F_FCOE_CRC;
114 netdev->vlan_features &= ~NETIF_F_FCOE_CRC;
115 netdev->features &= ~NETIF_F_FCOE_MTU;
116 netdev->vlan_features &= ~NETIF_F_FCOE_MTU;
117
118 netdev_features_change(netdev);
119
120 return 0;
121}
122#endif
123