i40e_fcoe.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Driver
  4. * Copyright(c) 2013 - 2014 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * The full GNU General Public License is included in this distribution in
  19. * the file called "COPYING".
  20. *
  21. * Contact Information:
  22. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. ******************************************************************************/
  26. #include <linux/if_ether.h>
  27. #include <scsi/scsi_cmnd.h>
  28. #include <scsi/scsi_device.h>
  29. #include <scsi/fc/fc_fs.h>
  30. #include <scsi/fc/fc_fip.h>
  31. #include <scsi/fc/fc_fcoe.h>
  32. #include <scsi/libfc.h>
  33. #include <scsi/libfcoe.h>
  34. #include <uapi/linux/dcbnl.h>
  35. #include "i40e.h"
  36. #include "i40e_fcoe.h"
  37. /**
  38. * i40e_rx_is_fcoe - returns true if the rx packet type is FCoE
  39. * @ptype: the packet type field from rx descriptor write-back
  40. **/
  41. static inline bool i40e_rx_is_fcoe(u16 ptype)
  42. {
  43. return (ptype >= I40E_RX_PTYPE_L2_FCOE_PAY3) &&
  44. (ptype <= I40E_RX_PTYPE_L2_FCOE_VFT_FCOTHER);
  45. }
  46. /**
  47. * i40e_fcoe_sof_is_class2 - returns true if this is a FC Class 2 SOF
  48. * @sof: the FCoE start of frame delimiter
  49. **/
  50. static inline bool i40e_fcoe_sof_is_class2(u8 sof)
  51. {
  52. return (sof == FC_SOF_I2) || (sof == FC_SOF_N2);
  53. }
  54. /**
  55. * i40e_fcoe_sof_is_class3 - returns true if this is a FC Class 3 SOF
  56. * @sof: the FCoE start of frame delimiter
  57. **/
  58. static inline bool i40e_fcoe_sof_is_class3(u8 sof)
  59. {
  60. return (sof == FC_SOF_I3) || (sof == FC_SOF_N3);
  61. }
  62. /**
  63. * i40e_fcoe_sof_is_supported - returns true if the FC SOF is supported by HW
  64. * @sof: the input SOF value from the frame
  65. **/
  66. static inline bool i40e_fcoe_sof_is_supported(u8 sof)
  67. {
  68. return i40e_fcoe_sof_is_class2(sof) ||
  69. i40e_fcoe_sof_is_class3(sof);
  70. }
  71. /**
  72. * i40e_fcoe_fc_sof - pull the SOF from FCoE header in the frame
  73. * @skb: the frame whose EOF is to be pulled from
  74. **/
  75. static inline int i40e_fcoe_fc_sof(struct sk_buff *skb, u8 *sof)
  76. {
  77. *sof = ((struct fcoe_hdr *)skb_network_header(skb))->fcoe_sof;
  78. if (!i40e_fcoe_sof_is_supported(*sof))
  79. return -EINVAL;
  80. return 0;
  81. }
  82. /**
  83. * i40e_fcoe_eof_is_supported - returns true if the EOF is supported by HW
  84. * @eof: the input EOF value from the frame
  85. **/
  86. static inline bool i40e_fcoe_eof_is_supported(u8 eof)
  87. {
  88. return (eof == FC_EOF_N) || (eof == FC_EOF_T) ||
  89. (eof == FC_EOF_NI) || (eof == FC_EOF_A);
  90. }
  91. /**
  92. * i40e_fcoe_fc_eof - pull EOF from FCoE trailer in the frame
  93. * @skb: the frame whose EOF is to be pulled from
  94. **/
  95. static inline int i40e_fcoe_fc_eof(struct sk_buff *skb, u8 *eof)
  96. {
  97. /* the first byte of the last dword is EOF */
  98. skb_copy_bits(skb, skb->len - 4, eof, 1);
  99. if (!i40e_fcoe_eof_is_supported(*eof))
  100. return -EINVAL;
  101. return 0;
  102. }
  103. /**
  104. * i40e_fcoe_ctxt_eof - convert input FC EOF for descriptor programming
  105. * @eof: the input eof value from the frame
  106. *
  107. * The FC EOF is converted to the value understood by HW for descriptor
  108. * programming. Never call this w/o calling i40e_fcoe_eof_is_supported()
  109. * first.
  110. **/
  111. static inline u32 i40e_fcoe_ctxt_eof(u8 eof)
  112. {
  113. switch (eof) {
  114. case FC_EOF_N:
  115. return I40E_TX_DESC_CMD_L4T_EOFT_EOF_N;
  116. case FC_EOF_T:
  117. return I40E_TX_DESC_CMD_L4T_EOFT_EOF_T;
  118. case FC_EOF_NI:
  119. return I40E_TX_DESC_CMD_L4T_EOFT_EOF_NI;
  120. case FC_EOF_A:
  121. return I40E_TX_DESC_CMD_L4T_EOFT_EOF_A;
  122. default:
  123. /* FIXME: still returns 0 */
  124. pr_err("Unrecognized EOF %x\n", eof);
  125. return 0;
  126. }
  127. }
  128. /**
  129. * i40e_fcoe_xid_is_valid - returns true if the exchange id is valid
  130. * @xid: the exchange id
  131. **/
  132. static inline bool i40e_fcoe_xid_is_valid(u16 xid)
  133. {
  134. return (xid != FC_XID_UNKNOWN) && (xid < I40E_FCOE_DDP_MAX);
  135. }
  136. /**
  137. * i40e_fcoe_ddp_unmap - unmap the mapped sglist associated
  138. * @pf: pointer to pf
  139. * @ddp: sw DDP context
  140. *
  141. * Unmap the scatter-gather list associated with the given SW DDP context
  142. *
  143. * Returns: data length already ddp-ed in bytes
  144. *
  145. **/
  146. static inline void i40e_fcoe_ddp_unmap(struct i40e_pf *pf,
  147. struct i40e_fcoe_ddp *ddp)
  148. {
  149. if (test_and_set_bit(__I40E_FCOE_DDP_UNMAPPED, &ddp->flags))
  150. return;
  151. if (ddp->sgl) {
  152. dma_unmap_sg(&pf->pdev->dev, ddp->sgl, ddp->sgc,
  153. DMA_FROM_DEVICE);
  154. ddp->sgl = NULL;
  155. ddp->sgc = 0;
  156. }
  157. if (ddp->pool) {
  158. dma_pool_free(ddp->pool, ddp->udl, ddp->udp);
  159. ddp->pool = NULL;
  160. }
  161. }
  162. /**
  163. * i40e_fcoe_ddp_clear - clear the given SW DDP context
  164. * @ddp - SW DDP context
  165. **/
  166. static inline void i40e_fcoe_ddp_clear(struct i40e_fcoe_ddp *ddp)
  167. {
  168. memset(ddp, 0, sizeof(struct i40e_fcoe_ddp));
  169. ddp->xid = FC_XID_UNKNOWN;
  170. ddp->flags = __I40E_FCOE_DDP_NONE;
  171. }
  172. /**
  173. * i40e_fcoe_progid_is_fcoe - check if the prog_id is for FCoE
  174. * @id: the prog id for the programming status Rx descriptor write-back
  175. **/
  176. static inline bool i40e_fcoe_progid_is_fcoe(u8 id)
  177. {
  178. return (id == I40E_RX_PROG_STATUS_DESC_FCOE_CTXT_PROG_STATUS) ||
  179. (id == I40E_RX_PROG_STATUS_DESC_FCOE_CTXT_INVL_STATUS);
  180. }
  181. /**
  182. * i40e_fcoe_fc_get_xid - get xid from the frame header
  183. * @fh: the fc frame header
  184. *
  185. * In case the incoming frame's exchange is originated from
  186. * the initiator, then received frame's exchange id is ANDed
  187. * with fc_cpu_mask bits to get the same cpu on which exchange
  188. * was originated, otherwise just use the current cpu.
  189. *
  190. * Returns ox_id if exchange originator, rx_id if responder
  191. **/
  192. static inline u16 i40e_fcoe_fc_get_xid(struct fc_frame_header *fh)
  193. {
  194. u32 f_ctl = ntoh24(fh->fh_f_ctl);
  195. return (f_ctl & FC_FC_EX_CTX) ?
  196. be16_to_cpu(fh->fh_ox_id) :
  197. be16_to_cpu(fh->fh_rx_id);
  198. }
  199. /**
  200. * i40e_fcoe_fc_frame_header - get fc frame header from skb
  201. * @skb: packet
  202. *
  203. * This checks if there is a VLAN header and returns the data
  204. * pointer to the start of the fc_frame_header.
  205. *
  206. * Returns pointer to the fc_frame_header
  207. **/
  208. static inline struct fc_frame_header *i40e_fcoe_fc_frame_header(
  209. struct sk_buff *skb)
  210. {
  211. void *fh = skb->data + sizeof(struct fcoe_hdr);
  212. if (eth_hdr(skb)->h_proto == htons(ETH_P_8021Q))
  213. fh += sizeof(struct vlan_hdr);
  214. return (struct fc_frame_header *)fh;
  215. }
  216. /**
  217. * i40e_fcoe_ddp_put - release the DDP context for a given exchange id
  218. * @netdev: the corresponding net_device
  219. * @xid: the exchange id that corresponding DDP context will be released
  220. *
  221. * This is the implementation of net_device_ops.ndo_fcoe_ddp_done
  222. * and it is expected to be called by ULD, i.e., FCP layer of libfc
  223. * to release the corresponding ddp context when the I/O is done.
  224. *
  225. * Returns : data length already ddp-ed in bytes
  226. **/
  227. static int i40e_fcoe_ddp_put(struct net_device *netdev, u16 xid)
  228. {
  229. struct i40e_netdev_priv *np = netdev_priv(netdev);
  230. struct i40e_pf *pf = np->vsi->back;
  231. struct i40e_fcoe *fcoe = &pf->fcoe;
  232. int len = 0;
  233. struct i40e_fcoe_ddp *ddp = &fcoe->ddp[xid];
  234. if (!fcoe || !ddp)
  235. goto out;
  236. if (test_bit(__I40E_FCOE_DDP_DONE, &ddp->flags))
  237. len = ddp->len;
  238. i40e_fcoe_ddp_unmap(pf, ddp);
  239. out:
  240. return len;
  241. }
  242. /**
  243. * i40e_fcoe_sw_init - sets up the HW for FCoE
  244. * @pf: pointer to pf
  245. *
  246. * Returns 0 if FCoE is supported otherwise the error code
  247. **/
  248. int i40e_init_pf_fcoe(struct i40e_pf *pf)
  249. {
  250. struct i40e_hw *hw = &pf->hw;
  251. u32 val;
  252. pf->flags &= ~I40E_FLAG_FCOE_ENABLED;
  253. pf->num_fcoe_qps = 0;
  254. pf->fcoe_hmc_cntx_num = 0;
  255. pf->fcoe_hmc_filt_num = 0;
  256. if (!pf->hw.func_caps.fcoe) {
  257. dev_info(&pf->pdev->dev, "FCoE capability is disabled\n");
  258. return 0;
  259. }
  260. if (!pf->hw.func_caps.dcb) {
  261. dev_warn(&pf->pdev->dev,
  262. "Hardware is not DCB capable not enabling FCoE.\n");
  263. return 0;
  264. }
  265. /* enable FCoE hash filter */
  266. val = rd32(hw, I40E_PFQF_HENA(1));
  267. val |= 1 << (I40E_FILTER_PCTYPE_FCOE_OX - 32);
  268. val |= 1 << (I40E_FILTER_PCTYPE_FCOE_RX - 32);
  269. val &= I40E_PFQF_HENA_PTYPE_ENA_MASK;
  270. wr32(hw, I40E_PFQF_HENA(1), val);
  271. /* enable flag */
  272. pf->flags |= I40E_FLAG_FCOE_ENABLED;
  273. pf->num_fcoe_qps = I40E_DEFAULT_FCOE;
  274. /* Reserve 4K DDP contexts and 20K filter size for FCoE */
  275. pf->fcoe_hmc_cntx_num = (1 << I40E_DMA_CNTX_SIZE_4K) *
  276. I40E_DMA_CNTX_BASE_SIZE;
  277. pf->fcoe_hmc_filt_num = pf->fcoe_hmc_cntx_num +
  278. (1 << I40E_HASH_FILTER_SIZE_16K) *
  279. I40E_HASH_FILTER_BASE_SIZE;
  280. /* FCoE object: max 16K filter buckets and 4K DMA contexts */
  281. pf->filter_settings.fcoe_filt_num = I40E_HASH_FILTER_SIZE_16K;
  282. pf->filter_settings.fcoe_cntx_num = I40E_DMA_CNTX_SIZE_4K;
  283. /* Setup max frame with FCoE_MTU plus L2 overheads */
  284. val = rd32(hw, I40E_GLFCOE_RCTL);
  285. val &= ~I40E_GLFCOE_RCTL_MAX_SIZE_MASK;
  286. val |= ((FCOE_MTU + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN)
  287. << I40E_GLFCOE_RCTL_MAX_SIZE_SHIFT);
  288. wr32(hw, I40E_GLFCOE_RCTL, val);
  289. dev_info(&pf->pdev->dev, "FCoE is supported.\n");
  290. return 0;
  291. }
  292. /**
  293. * i40e_get_fcoe_tc_map - Return TC map for FCoE APP
  294. * @pf: pointer to pf
  295. *
  296. **/
  297. u8 i40e_get_fcoe_tc_map(struct i40e_pf *pf)
  298. {
  299. struct i40e_dcb_app_priority_table app;
  300. struct i40e_hw *hw = &pf->hw;
  301. u8 enabled_tc = 0;
  302. u8 tc, i;
  303. /* Get the FCoE APP TLV */
  304. struct i40e_dcbx_config *dcbcfg = &hw->local_dcbx_config;
  305. for (i = 0; i < dcbcfg->numapps; i++) {
  306. app = dcbcfg->app[i];
  307. if (app.selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
  308. app.protocolid == ETH_P_FCOE) {
  309. tc = dcbcfg->etscfg.prioritytable[app.priority];
  310. enabled_tc |= (1 << tc);
  311. break;
  312. }
  313. }
  314. /* TC0 if there is no TC defined for FCoE APP TLV */
  315. enabled_tc = enabled_tc ? enabled_tc : 0x1;
  316. return enabled_tc;
  317. }
  318. /**
  319. * i40e_fcoe_vsi_init - prepares the VSI context for creating a FCoE VSI
  320. * @vsi: pointer to the associated VSI struct
  321. * @ctxt: pointer to the associated VSI context to be passed to HW
  322. *
  323. * Returns 0 on success or < 0 on error
  324. **/
  325. int i40e_fcoe_vsi_init(struct i40e_vsi *vsi, struct i40e_vsi_context *ctxt)
  326. {
  327. struct i40e_aqc_vsi_properties_data *info = &ctxt->info;
  328. struct i40e_pf *pf = vsi->back;
  329. struct i40e_hw *hw = &pf->hw;
  330. u8 enabled_tc = 0;
  331. if (!(pf->flags & I40E_FLAG_FCOE_ENABLED)) {
  332. dev_err(&pf->pdev->dev,
  333. "FCoE is not enabled for this device\n");
  334. return -EPERM;
  335. }
  336. /* initialize the hardware for FCoE */
  337. ctxt->pf_num = hw->pf_id;
  338. ctxt->vf_num = 0;
  339. ctxt->uplink_seid = vsi->uplink_seid;
  340. ctxt->connection_type = 0x1;
  341. ctxt->flags = I40E_AQ_VSI_TYPE_PF;
  342. /* FCoE VSI would need the following sections */
  343. info->valid_sections |= cpu_to_le16(I40E_AQ_VSI_PROP_SWITCH_VALID |
  344. I40E_AQ_VSI_PROP_QUEUE_OPT_VALID);
  345. /* FCoE VSI does not need these sections */
  346. info->valid_sections &= cpu_to_le16(~(I40E_AQ_VSI_PROP_SECURITY_VALID |
  347. I40E_AQ_VSI_PROP_VLAN_VALID |
  348. I40E_AQ_VSI_PROP_CAS_PV_VALID |
  349. I40E_AQ_VSI_PROP_INGRESS_UP_VALID |
  350. I40E_AQ_VSI_PROP_EGRESS_UP_VALID));
  351. info->switch_id = cpu_to_le16(I40E_AQ_VSI_SW_ID_FLAG_ALLOW_LB);
  352. enabled_tc = i40e_get_fcoe_tc_map(pf);
  353. i40e_vsi_setup_queue_map(vsi, ctxt, enabled_tc, true);
  354. /* set up queue option section: only enable FCoE */
  355. info->queueing_opt_flags = I40E_AQ_VSI_QUE_OPT_FCOE_ENA;
  356. return 0;
  357. }
  358. /**
  359. * i40e_fcoe_enable - this is the implementation of ndo_fcoe_enable,
  360. * indicating the upper FCoE protocol stack is ready to use FCoE
  361. * offload features.
  362. *
  363. * @netdev: pointer to the netdev that FCoE is created on
  364. *
  365. * Returns 0 on success
  366. *
  367. * in RTNL
  368. *
  369. **/
  370. int i40e_fcoe_enable(struct net_device *netdev)
  371. {
  372. struct i40e_netdev_priv *np = netdev_priv(netdev);
  373. struct i40e_vsi *vsi = np->vsi;
  374. struct i40e_pf *pf = vsi->back;
  375. struct i40e_fcoe *fcoe = &pf->fcoe;
  376. if (!(pf->flags & I40E_FLAG_FCOE_ENABLED)) {
  377. netdev_err(netdev, "HW does not support FCoE.\n");
  378. return -ENODEV;
  379. }
  380. if (vsi->type != I40E_VSI_FCOE) {
  381. netdev_err(netdev, "interface does not support FCoE.\n");
  382. return -EBUSY;
  383. }
  384. atomic_inc(&fcoe->refcnt);
  385. return 0;
  386. }
  387. /**
  388. * i40e_fcoe_disable- disables FCoE for upper FCoE protocol stack.
  389. * @dev: pointer to the netdev that FCoE is created on
  390. *
  391. * Returns 0 on success
  392. *
  393. **/
  394. int i40e_fcoe_disable(struct net_device *netdev)
  395. {
  396. struct i40e_netdev_priv *np = netdev_priv(netdev);
  397. struct i40e_vsi *vsi = np->vsi;
  398. struct i40e_pf *pf = vsi->back;
  399. struct i40e_fcoe *fcoe = &pf->fcoe;
  400. if (!(pf->flags & I40E_FLAG_FCOE_ENABLED)) {
  401. netdev_err(netdev, "device does not support FCoE\n");
  402. return -ENODEV;
  403. }
  404. if (vsi->type != I40E_VSI_FCOE)
  405. return -EBUSY;
  406. if (!atomic_dec_and_test(&fcoe->refcnt))
  407. return -EINVAL;
  408. netdev_info(netdev, "FCoE disabled\n");
  409. return 0;
  410. }
  411. /**
  412. * i40e_fcoe_dma_pool_free - free the per cpu pool for FCoE DDP
  413. * @fcoe: the FCoE sw object
  414. * @dev: the device that the pool is associated with
  415. * @cpu: the cpu for this pool
  416. *
  417. **/
  418. static void i40e_fcoe_dma_pool_free(struct i40e_fcoe *fcoe,
  419. struct device *dev,
  420. unsigned int cpu)
  421. {
  422. struct i40e_fcoe_ddp_pool *ddp_pool;
  423. ddp_pool = per_cpu_ptr(fcoe->ddp_pool, cpu);
  424. if (!ddp_pool->pool) {
  425. dev_warn(dev, "DDP pool already freed for cpu %d\n", cpu);
  426. return;
  427. }
  428. dma_pool_destroy(ddp_pool->pool);
  429. ddp_pool->pool = NULL;
  430. }
  431. /**
  432. * i40e_fcoe_dma_pool_create - per cpu pool for FCoE DDP
  433. * @fcoe: the FCoE sw object
  434. * @dev: the device that the pool is associated with
  435. * @cpu: the cpu for this pool
  436. *
  437. * Returns 0 on successful or non zero on failure
  438. *
  439. **/
  440. static int i40e_fcoe_dma_pool_create(struct i40e_fcoe *fcoe,
  441. struct device *dev,
  442. unsigned int cpu)
  443. {
  444. struct i40e_fcoe_ddp_pool *ddp_pool;
  445. struct dma_pool *pool;
  446. char pool_name[32];
  447. ddp_pool = per_cpu_ptr(fcoe->ddp_pool, cpu);
  448. if (ddp_pool && ddp_pool->pool) {
  449. dev_warn(dev, "DDP pool already allocated for cpu %d\n", cpu);
  450. return 0;
  451. }
  452. snprintf(pool_name, sizeof(pool_name), "i40e_fcoe_ddp_%d", cpu);
  453. pool = dma_pool_create(pool_name, dev, I40E_FCOE_DDP_PTR_MAX,
  454. I40E_FCOE_DDP_PTR_ALIGN, PAGE_SIZE);
  455. if (!pool) {
  456. dev_err(dev, "dma_pool_create %s failed\n", pool_name);
  457. return -ENOMEM;
  458. }
  459. ddp_pool->pool = pool;
  460. return 0;
  461. }
  462. /**
  463. * i40e_fcoe_free_ddp_resources - release FCoE DDP resources
  464. * @vsi: the vsi FCoE is associated with
  465. *
  466. **/
  467. void i40e_fcoe_free_ddp_resources(struct i40e_vsi *vsi)
  468. {
  469. struct i40e_pf *pf = vsi->back;
  470. struct i40e_fcoe *fcoe = &pf->fcoe;
  471. int cpu, i;
  472. /* do nothing if not FCoE VSI */
  473. if (vsi->type != I40E_VSI_FCOE)
  474. return;
  475. /* do nothing if no DDP pools were allocated */
  476. if (!fcoe->ddp_pool)
  477. return;
  478. for (i = 0; i < I40E_FCOE_DDP_MAX; i++)
  479. i40e_fcoe_ddp_put(vsi->netdev, i);
  480. for_each_possible_cpu(cpu)
  481. i40e_fcoe_dma_pool_free(fcoe, &pf->pdev->dev, cpu);
  482. free_percpu(fcoe->ddp_pool);
  483. fcoe->ddp_pool = NULL;
  484. netdev_info(vsi->netdev, "VSI %d,%d FCoE DDP resources released\n",
  485. vsi->id, vsi->seid);
  486. }
  487. /**
  488. * i40e_fcoe_setup_ddp_resources - allocate per cpu DDP resources
  489. * @vsi: the VSI FCoE is associated with
  490. *
  491. * Returns 0 on successful or non zero on failure
  492. *
  493. **/
  494. int i40e_fcoe_setup_ddp_resources(struct i40e_vsi *vsi)
  495. {
  496. struct i40e_pf *pf = vsi->back;
  497. struct device *dev = &pf->pdev->dev;
  498. struct i40e_fcoe *fcoe = &pf->fcoe;
  499. unsigned int cpu;
  500. int i;
  501. if (vsi->type != I40E_VSI_FCOE)
  502. return -ENODEV;
  503. /* do nothing if no DDP pools were allocated */
  504. if (fcoe->ddp_pool)
  505. return -EEXIST;
  506. /* allocate per CPU memory to track DDP pools */
  507. fcoe->ddp_pool = alloc_percpu(struct i40e_fcoe_ddp_pool);
  508. if (!fcoe->ddp_pool) {
  509. dev_err(&pf->pdev->dev, "failed to allocate percpu DDP\n");
  510. return -ENOMEM;
  511. }
  512. /* allocate pci pool for each cpu */
  513. for_each_possible_cpu(cpu) {
  514. if (!i40e_fcoe_dma_pool_create(fcoe, dev, cpu))
  515. continue;
  516. dev_err(dev, "failed to alloc DDP pool on cpu:%d\n", cpu);
  517. i40e_fcoe_free_ddp_resources(vsi);
  518. return -ENOMEM;
  519. }
  520. /* initialize the sw context */
  521. for (i = 0; i < I40E_FCOE_DDP_MAX; i++)
  522. i40e_fcoe_ddp_clear(&fcoe->ddp[i]);
  523. netdev_info(vsi->netdev, "VSI %d,%d FCoE DDP resources allocated\n",
  524. vsi->id, vsi->seid);
  525. return 0;
  526. }
  527. /**
  528. * i40e_fcoe_handle_status - check the Programming Status for FCoE
  529. * @rx_ring: the Rx ring for this descriptor
  530. * @rx_desc: the Rx descriptor for Programming Status, not a packet descriptor.
  531. *
  532. * Check if this is the Rx Programming Status descriptor write-back for FCoE.
  533. * This is used to verify if the context/filter programming or invalidation
  534. * requested by SW to the HW is successful or not and take actions accordingly.
  535. **/
  536. void i40e_fcoe_handle_status(struct i40e_ring *rx_ring,
  537. union i40e_rx_desc *rx_desc, u8 prog_id)
  538. {
  539. struct i40e_pf *pf = rx_ring->vsi->back;
  540. struct i40e_fcoe *fcoe = &pf->fcoe;
  541. struct i40e_fcoe_ddp *ddp;
  542. u32 error;
  543. u16 xid;
  544. u64 qw;
  545. /* we only care for FCoE here */
  546. if (!i40e_fcoe_progid_is_fcoe(prog_id))
  547. return;
  548. xid = le32_to_cpu(rx_desc->wb.qword0.hi_dword.fcoe_param) &
  549. (I40E_FCOE_DDP_MAX - 1);
  550. if (!i40e_fcoe_xid_is_valid(xid))
  551. return;
  552. ddp = &fcoe->ddp[xid];
  553. WARN_ON(xid != ddp->xid);
  554. qw = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
  555. error = (qw & I40E_RX_PROG_STATUS_DESC_QW1_ERROR_MASK) >>
  556. I40E_RX_PROG_STATUS_DESC_QW1_ERROR_SHIFT;
  557. /* DDP context programming status: failure or success */
  558. if (prog_id == I40E_RX_PROG_STATUS_DESC_FCOE_CTXT_PROG_STATUS) {
  559. if (I40E_RX_PROG_FCOE_ERROR_TBL_FULL(error)) {
  560. dev_err(&pf->pdev->dev, "xid %x ddp->xid %x TABLE FULL\n",
  561. xid, ddp->xid);
  562. ddp->prerr |= I40E_RX_PROG_FCOE_ERROR_TBL_FULL_BIT;
  563. }
  564. if (I40E_RX_PROG_FCOE_ERROR_CONFLICT(error)) {
  565. dev_err(&pf->pdev->dev, "xid %x ddp->xid %x CONFLICT\n",
  566. xid, ddp->xid);
  567. ddp->prerr |= I40E_RX_PROG_FCOE_ERROR_CONFLICT_BIT;
  568. }
  569. }
  570. /* DDP context invalidation status: failure or success */
  571. if (prog_id == I40E_RX_PROG_STATUS_DESC_FCOE_CTXT_INVL_STATUS) {
  572. if (I40E_RX_PROG_FCOE_ERROR_INVLFAIL(error)) {
  573. dev_err(&pf->pdev->dev, "xid %x ddp->xid %x INVALIDATION FAILURE\n",
  574. xid, ddp->xid);
  575. ddp->prerr |= I40E_RX_PROG_FCOE_ERROR_INVLFAIL_BIT;
  576. }
  577. /* clear the flag so we can retry invalidation */
  578. clear_bit(__I40E_FCOE_DDP_ABORTED, &ddp->flags);
  579. }
  580. /* unmap DMA */
  581. i40e_fcoe_ddp_unmap(pf, ddp);
  582. i40e_fcoe_ddp_clear(ddp);
  583. }
  584. /**
  585. * i40e_fcoe_handle_offload - check ddp status and mark it done
  586. * @adapter: i40e adapter
  587. * @rx_desc: advanced rx descriptor
  588. * @skb: the skb holding the received data
  589. *
  590. * This checks ddp status.
  591. *
  592. * Returns : < 0 indicates an error or not a FCOE ddp, 0 indicates
  593. * not passing the skb to ULD, > 0 indicates is the length of data
  594. * being ddped.
  595. *
  596. **/
  597. int i40e_fcoe_handle_offload(struct i40e_ring *rx_ring,
  598. union i40e_rx_desc *rx_desc,
  599. struct sk_buff *skb)
  600. {
  601. struct i40e_pf *pf = rx_ring->vsi->back;
  602. struct i40e_fcoe *fcoe = &pf->fcoe;
  603. struct fc_frame_header *fh = NULL;
  604. struct i40e_fcoe_ddp *ddp = NULL;
  605. u32 status, fltstat;
  606. u32 error, fcerr;
  607. int rc = -EINVAL;
  608. u16 ptype;
  609. u16 xid;
  610. u64 qw;
  611. /* check this rxd is for programming status */
  612. qw = le64_to_cpu(rx_desc->wb.qword1.status_error_len);
  613. /* packet descriptor, check packet type */
  614. ptype = (qw & I40E_RXD_QW1_PTYPE_MASK) >> I40E_RXD_QW1_PTYPE_SHIFT;
  615. if (!i40e_rx_is_fcoe(ptype))
  616. goto out_no_ddp;
  617. error = (qw & I40E_RXD_QW1_ERROR_MASK) >> I40E_RXD_QW1_ERROR_SHIFT;
  618. fcerr = (error >> I40E_RX_DESC_ERROR_L3L4E_SHIFT) &
  619. I40E_RX_DESC_FCOE_ERROR_MASK;
  620. /* check stateless offload error */
  621. if (unlikely(fcerr == I40E_RX_DESC_ERROR_L3L4E_PROT)) {
  622. dev_err(&pf->pdev->dev, "Protocol Error\n");
  623. skb->ip_summed = CHECKSUM_NONE;
  624. } else {
  625. skb->ip_summed = CHECKSUM_UNNECESSARY;
  626. }
  627. /* check hw status on ddp */
  628. status = (qw & I40E_RXD_QW1_STATUS_MASK) >> I40E_RXD_QW1_STATUS_SHIFT;
  629. fltstat = (status >> I40E_RX_DESC_STATUS_FLTSTAT_SHIFT) &
  630. I40E_RX_DESC_FLTSTAT_FCMASK;
  631. /* now we are ready to check DDP */
  632. fh = i40e_fcoe_fc_frame_header(skb);
  633. xid = i40e_fcoe_fc_get_xid(fh);
  634. if (!i40e_fcoe_xid_is_valid(xid))
  635. goto out_no_ddp;
  636. /* non DDP normal receive, return to the protocol stack */
  637. if (fltstat == I40E_RX_DESC_FLTSTAT_NOMTCH)
  638. goto out_no_ddp;
  639. /* do we have a sw ddp context setup ? */
  640. ddp = &fcoe->ddp[xid];
  641. if (!ddp->sgl)
  642. goto out_no_ddp;
  643. /* fetch xid from hw rxd wb, which should match up the sw ctxt */
  644. xid = le16_to_cpu(rx_desc->wb.qword0.lo_dword.mirr_fcoe.fcoe_ctx_id);
  645. if (ddp->xid != xid) {
  646. dev_err(&pf->pdev->dev, "xid 0x%x does not match ctx_xid 0x%x\n",
  647. ddp->xid, xid);
  648. goto out_put_ddp;
  649. }
  650. /* the same exchange has already errored out */
  651. if (ddp->fcerr) {
  652. dev_err(&pf->pdev->dev, "xid 0x%x fcerr 0x%x reported fcer 0x%x\n",
  653. xid, ddp->fcerr, fcerr);
  654. goto out_put_ddp;
  655. }
  656. /* fcoe param is valid by now with correct DDPed length */
  657. ddp->len = le32_to_cpu(rx_desc->wb.qword0.hi_dword.fcoe_param);
  658. ddp->fcerr = fcerr;
  659. /* header posting only, useful only for target mode and debugging */
  660. if (fltstat == I40E_RX_DESC_FLTSTAT_DDP) {
  661. /* For target mode, we get header of the last packet but it
  662. * does not have the FCoE trailer field, i.e., CRC and EOF
  663. * Ordered Set since they are offloaded by the HW, so fill
  664. * it up correspondingly to allow the packet to pass through
  665. * to the upper protocol stack.
  666. */
  667. u32 f_ctl = ntoh24(fh->fh_f_ctl);
  668. if ((f_ctl & FC_FC_END_SEQ) &&
  669. (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA)) {
  670. struct fcoe_crc_eof *crc = NULL;
  671. crc = (struct fcoe_crc_eof *)skb_put(skb, sizeof(*crc));
  672. crc->fcoe_eof = FC_EOF_T;
  673. } else {
  674. /* otherwise, drop the header only frame */
  675. rc = 0;
  676. goto out_no_ddp;
  677. }
  678. }
  679. out_put_ddp:
  680. /* either we got RSP or we have an error, unmap DMA in both cases */
  681. i40e_fcoe_ddp_unmap(pf, ddp);
  682. if (ddp->len && !ddp->fcerr) {
  683. int pkts;
  684. rc = ddp->len;
  685. i40e_fcoe_ddp_clear(ddp);
  686. ddp->len = rc;
  687. pkts = DIV_ROUND_UP(rc, 2048);
  688. rx_ring->stats.bytes += rc;
  689. rx_ring->stats.packets += pkts;
  690. rx_ring->q_vector->rx.total_bytes += rc;
  691. rx_ring->q_vector->rx.total_packets += pkts;
  692. set_bit(__I40E_FCOE_DDP_DONE, &ddp->flags);
  693. }
  694. out_no_ddp:
  695. return rc;
  696. }
  697. /**
  698. * i40e_fcoe_ddp_setup - called to set up ddp context
  699. * @netdev: the corresponding net_device
  700. * @xid: the exchange id requesting ddp
  701. * @sgl: the scatter-gather list for this request
  702. * @sgc: the number of scatter-gather items
  703. * @target_mode: indicates this is a DDP request for target
  704. *
  705. * Returns : 1 for success and 0 for no DDP on this I/O
  706. **/
  707. static int i40e_fcoe_ddp_setup(struct net_device *netdev, u16 xid,
  708. struct scatterlist *sgl, unsigned int sgc,
  709. int target_mode)
  710. {
  711. static const unsigned int bufflen = I40E_FCOE_DDP_BUF_MIN;
  712. struct i40e_netdev_priv *np = netdev_priv(netdev);
  713. struct i40e_fcoe_ddp_pool *ddp_pool;
  714. struct i40e_pf *pf = np->vsi->back;
  715. struct i40e_fcoe *fcoe = &pf->fcoe;
  716. unsigned int i, j, dmacount;
  717. struct i40e_fcoe_ddp *ddp;
  718. unsigned int firstoff = 0;
  719. unsigned int thisoff = 0;
  720. unsigned int thislen = 0;
  721. struct scatterlist *sg;
  722. dma_addr_t addr = 0;
  723. unsigned int len;
  724. if (xid >= I40E_FCOE_DDP_MAX) {
  725. dev_warn(&pf->pdev->dev, "xid=0x%x out-of-range\n", xid);
  726. return 0;
  727. }
  728. /* no DDP if we are already down or resetting */
  729. if (test_bit(__I40E_DOWN, &pf->state) ||
  730. test_bit(__I40E_NEEDS_RESTART, &pf->state)) {
  731. dev_info(&pf->pdev->dev, "xid=0x%x device in reset/down\n",
  732. xid);
  733. return 0;
  734. }
  735. ddp = &fcoe->ddp[xid];
  736. if (ddp->sgl) {
  737. dev_info(&pf->pdev->dev, "xid 0x%x w/ non-null sgl=%p nents=%d\n",
  738. xid, ddp->sgl, ddp->sgc);
  739. return 0;
  740. }
  741. i40e_fcoe_ddp_clear(ddp);
  742. if (!fcoe->ddp_pool) {
  743. dev_info(&pf->pdev->dev, "No DDP pool, xid 0x%x\n", xid);
  744. return 0;
  745. }
  746. ddp_pool = per_cpu_ptr(fcoe->ddp_pool, get_cpu());
  747. if (!ddp_pool->pool) {
  748. dev_info(&pf->pdev->dev, "No percpu ddp pool, xid 0x%x\n", xid);
  749. goto out_noddp;
  750. }
  751. /* setup dma from scsi command sgl */
  752. dmacount = dma_map_sg(&pf->pdev->dev, sgl, sgc, DMA_FROM_DEVICE);
  753. if (dmacount == 0) {
  754. dev_info(&pf->pdev->dev, "dma_map_sg for sgl %p, sgc %d failed\n",
  755. sgl, sgc);
  756. goto out_noddp_unmap;
  757. }
  758. /* alloc the udl from our ddp pool */
  759. ddp->udl = dma_pool_alloc(ddp_pool->pool, GFP_ATOMIC, &ddp->udp);
  760. if (!ddp->udl) {
  761. dev_info(&pf->pdev->dev,
  762. "Failed allocated ddp context, xid 0x%x\n", xid);
  763. goto out_noddp_unmap;
  764. }
  765. j = 0;
  766. ddp->len = 0;
  767. for_each_sg(sgl, sg, dmacount, i) {
  768. addr = sg_dma_address(sg);
  769. len = sg_dma_len(sg);
  770. ddp->len += len;
  771. while (len) {
  772. /* max number of buffers allowed in one DDP context */
  773. if (j >= I40E_FCOE_DDP_BUFFCNT_MAX) {
  774. dev_info(&pf->pdev->dev,
  775. "xid=%x:%d,%d,%d:addr=%llx not enough descriptors\n",
  776. xid, i, j, dmacount, (u64)addr);
  777. goto out_noddp_free;
  778. }
  779. /* get the offset of length of current buffer */
  780. thisoff = addr & ((dma_addr_t)bufflen - 1);
  781. thislen = min_t(unsigned int, (bufflen - thisoff), len);
  782. /* all but the 1st buffer (j == 0)
  783. * must be aligned on bufflen
  784. */
  785. if ((j != 0) && (thisoff))
  786. goto out_noddp_free;
  787. /* all but the last buffer
  788. * ((i == (dmacount - 1)) && (thislen == len))
  789. * must end at bufflen
  790. */
  791. if (((i != (dmacount - 1)) || (thislen != len)) &&
  792. ((thislen + thisoff) != bufflen))
  793. goto out_noddp_free;
  794. ddp->udl[j] = (u64)(addr - thisoff);
  795. /* only the first buffer may have none-zero offset */
  796. if (j == 0)
  797. firstoff = thisoff;
  798. len -= thislen;
  799. addr += thislen;
  800. j++;
  801. }
  802. }
  803. /* only the last buffer may have non-full bufflen */
  804. ddp->lastsize = thisoff + thislen;
  805. ddp->firstoff = firstoff;
  806. ddp->list_len = j;
  807. ddp->pool = ddp_pool->pool;
  808. ddp->sgl = sgl;
  809. ddp->sgc = sgc;
  810. ddp->xid = xid;
  811. if (target_mode)
  812. set_bit(__I40E_FCOE_DDP_TARGET, &ddp->flags);
  813. set_bit(__I40E_FCOE_DDP_INITALIZED, &ddp->flags);
  814. put_cpu();
  815. return 1; /* Success */
  816. out_noddp_free:
  817. dma_pool_free(ddp->pool, ddp->udl, ddp->udp);
  818. i40e_fcoe_ddp_clear(ddp);
  819. out_noddp_unmap:
  820. dma_unmap_sg(&pf->pdev->dev, sgl, sgc, DMA_FROM_DEVICE);
  821. out_noddp:
  822. put_cpu();
  823. return 0;
  824. }
  825. /**
  826. * i40e_fcoe_ddp_get - called to set up ddp context in initiator mode
  827. * @netdev: the corresponding net_device
  828. * @xid: the exchange id requesting ddp
  829. * @sgl: the scatter-gather list for this request
  830. * @sgc: the number of scatter-gather items
  831. *
  832. * This is the implementation of net_device_ops.ndo_fcoe_ddp_setup
  833. * and is expected to be called from ULD, e.g., FCP layer of libfc
  834. * to set up ddp for the corresponding xid of the given sglist for
  835. * the corresponding I/O.
  836. *
  837. * Returns : 1 for success and 0 for no ddp
  838. **/
  839. static int i40e_fcoe_ddp_get(struct net_device *netdev, u16 xid,
  840. struct scatterlist *sgl, unsigned int sgc)
  841. {
  842. return i40e_fcoe_ddp_setup(netdev, xid, sgl, sgc, 0);
  843. }
  844. /**
  845. * i40e_fcoe_ddp_target - called to set up ddp context in target mode
  846. * @netdev: the corresponding net_device
  847. * @xid: the exchange id requesting ddp
  848. * @sgl: the scatter-gather list for this request
  849. * @sgc: the number of scatter-gather items
  850. *
  851. * This is the implementation of net_device_ops.ndo_fcoe_ddp_target
  852. * and is expected to be called from ULD, e.g., FCP layer of libfc
  853. * to set up ddp for the corresponding xid of the given sglist for
  854. * the corresponding I/O. The DDP in target mode is a write I/O request
  855. * from the initiator.
  856. *
  857. * Returns : 1 for success and 0 for no ddp
  858. **/
  859. static int i40e_fcoe_ddp_target(struct net_device *netdev, u16 xid,
  860. struct scatterlist *sgl, unsigned int sgc)
  861. {
  862. return i40e_fcoe_ddp_setup(netdev, xid, sgl, sgc, 1);
  863. }
  864. /**
  865. * i40e_fcoe_program_ddp - programs the HW DDP related descriptors
  866. * @tx_ring: transmit ring for this packet
  867. * @skb: the packet to be sent out
  868. * @sof: the SOF to indicate class of service
  869. *
  870. * Determine if it is READ/WRITE command, and finds out if there is
  871. * a matching SW DDP context for this command. DDP is applicable
  872. * only in case of READ if initiator or WRITE in case of
  873. * responder (via checking XFER_RDY).
  874. *
  875. * Note: caller checks sof and ddp sw context
  876. *
  877. * Returns : none
  878. *
  879. **/
  880. static void i40e_fcoe_program_ddp(struct i40e_ring *tx_ring,
  881. struct sk_buff *skb,
  882. struct i40e_fcoe_ddp *ddp, u8 sof)
  883. {
  884. struct i40e_fcoe_filter_context_desc *filter_desc = NULL;
  885. struct i40e_fcoe_queue_context_desc *queue_desc = NULL;
  886. struct i40e_fcoe_ddp_context_desc *ddp_desc = NULL;
  887. struct i40e_pf *pf = tx_ring->vsi->back;
  888. u16 i = tx_ring->next_to_use;
  889. struct fc_frame_header *fh;
  890. u64 flags_rsvd_lanq = 0;
  891. bool target_mode;
  892. /* check if abort is still pending */
  893. if (test_bit(__I40E_FCOE_DDP_ABORTED, &ddp->flags)) {
  894. dev_warn(&pf->pdev->dev,
  895. "DDP abort is still pending xid:%hx and ddp->flags:%lx:\n",
  896. ddp->xid, ddp->flags);
  897. return;
  898. }
  899. /* set the flag to indicate this is programmed */
  900. if (test_and_set_bit(__I40E_FCOE_DDP_PROGRAMMED, &ddp->flags)) {
  901. dev_warn(&pf->pdev->dev,
  902. "DDP is already programmed for xid:%hx and ddp->flags:%lx:\n",
  903. ddp->xid, ddp->flags);
  904. return;
  905. }
  906. /* Prepare the DDP context descriptor */
  907. ddp_desc = I40E_DDP_CONTEXT_DESC(tx_ring, i);
  908. i++;
  909. if (i == tx_ring->count)
  910. i = 0;
  911. ddp_desc->type_cmd_foff_lsize =
  912. cpu_to_le64(I40E_TX_DESC_DTYPE_DDP_CTX |
  913. ((u64)I40E_FCOE_DDP_CTX_DESC_BSIZE_4K <<
  914. I40E_FCOE_DDP_CTX_QW1_CMD_SHIFT) |
  915. ((u64)ddp->firstoff <<
  916. I40E_FCOE_DDP_CTX_QW1_FOFF_SHIFT) |
  917. ((u64)ddp->lastsize <<
  918. I40E_FCOE_DDP_CTX_QW1_LSIZE_SHIFT));
  919. ddp_desc->rsvd = cpu_to_le64(0);
  920. /* target mode needs last packet in the sequence */
  921. target_mode = test_bit(__I40E_FCOE_DDP_TARGET, &ddp->flags);
  922. if (target_mode)
  923. ddp_desc->type_cmd_foff_lsize |=
  924. cpu_to_le64(I40E_FCOE_DDP_CTX_DESC_LASTSEQH);
  925. /* Prepare queue_context descriptor */
  926. queue_desc = I40E_QUEUE_CONTEXT_DESC(tx_ring, i++);
  927. if (i == tx_ring->count)
  928. i = 0;
  929. queue_desc->dmaindx_fbase = cpu_to_le64(ddp->xid | ((u64)ddp->udp));
  930. queue_desc->flen_tph = cpu_to_le64(ddp->list_len |
  931. ((u64)(I40E_FCOE_QUEUE_CTX_DESC_TPHRDESC |
  932. I40E_FCOE_QUEUE_CTX_DESC_TPHDATA) <<
  933. I40E_FCOE_QUEUE_CTX_QW1_TPH_SHIFT));
  934. /* Prepare filter_context_desc */
  935. filter_desc = I40E_FILTER_CONTEXT_DESC(tx_ring, i);
  936. i++;
  937. if (i == tx_ring->count)
  938. i = 0;
  939. fh = (struct fc_frame_header *)skb_transport_header(skb);
  940. filter_desc->param = cpu_to_le32(ntohl(fh->fh_parm_offset));
  941. filter_desc->seqn = cpu_to_le16(ntohs(fh->fh_seq_cnt));
  942. filter_desc->rsvd_dmaindx = cpu_to_le16(ddp->xid <<
  943. I40E_FCOE_FILTER_CTX_QW0_DMAINDX_SHIFT);
  944. flags_rsvd_lanq = I40E_FCOE_FILTER_CTX_DESC_CTYP_DDP;
  945. flags_rsvd_lanq |= (u64)(target_mode ?
  946. I40E_FCOE_FILTER_CTX_DESC_ENODE_RSP :
  947. I40E_FCOE_FILTER_CTX_DESC_ENODE_INIT);
  948. flags_rsvd_lanq |= (u64)((sof == FC_SOF_I2 || sof == FC_SOF_N2) ?
  949. I40E_FCOE_FILTER_CTX_DESC_FC_CLASS2 :
  950. I40E_FCOE_FILTER_CTX_DESC_FC_CLASS3);
  951. flags_rsvd_lanq |= ((u64)skb->queue_mapping <<
  952. I40E_FCOE_FILTER_CTX_QW1_LANQINDX_SHIFT);
  953. filter_desc->flags_rsvd_lanq = cpu_to_le64(flags_rsvd_lanq);
  954. /* By this time, all offload related descriptors has been programmed */
  955. tx_ring->next_to_use = i;
  956. }
  957. /**
  958. * i40e_fcoe_invalidate_ddp - invalidates DDP in case of abort
  959. * @tx_ring: transmit ring for this packet
  960. * @skb: the packet associated w/ this DDP invalidation, i.e., ABTS
  961. * @ddp: the SW DDP context for this DDP
  962. *
  963. * Programs the Tx context descriptor to do DDP invalidation.
  964. **/
  965. static void i40e_fcoe_invalidate_ddp(struct i40e_ring *tx_ring,
  966. struct sk_buff *skb,
  967. struct i40e_fcoe_ddp *ddp)
  968. {
  969. struct i40e_tx_context_desc *context_desc;
  970. int i;
  971. if (test_and_set_bit(__I40E_FCOE_DDP_ABORTED, &ddp->flags))
  972. return;
  973. i = tx_ring->next_to_use;
  974. context_desc = I40E_TX_CTXTDESC(tx_ring, i);
  975. i++;
  976. if (i == tx_ring->count)
  977. i = 0;
  978. context_desc->tunneling_params = cpu_to_le32(0);
  979. context_desc->l2tag2 = cpu_to_le16(0);
  980. context_desc->rsvd = cpu_to_le16(0);
  981. context_desc->type_cmd_tso_mss = cpu_to_le64(
  982. I40E_TX_DESC_DTYPE_FCOE_CTX |
  983. (I40E_FCOE_TX_CTX_DESC_OPCODE_DDP_CTX_INVL <<
  984. I40E_TXD_CTX_QW1_CMD_SHIFT) |
  985. (I40E_FCOE_TX_CTX_DESC_OPCODE_SINGLE_SEND <<
  986. I40E_TXD_CTX_QW1_CMD_SHIFT));
  987. tx_ring->next_to_use = i;
  988. }
  989. /**
  990. * i40e_fcoe_handle_ddp - check we should setup or invalidate DDP
  991. * @tx_ring: transmit ring for this packet
  992. * @skb: the packet to be sent out
  993. * @sof: the SOF to indicate class of service
  994. *
  995. * Determine if it is ABTS/READ/XFER_RDY, and finds out if there is
  996. * a matching SW DDP context for this command. DDP is applicable
  997. * only in case of READ if initiator or WRITE in case of
  998. * responder (via checking XFER_RDY). In case this is an ABTS, send
  999. * just invalidate the context.
  1000. **/
  1001. static void i40e_fcoe_handle_ddp(struct i40e_ring *tx_ring,
  1002. struct sk_buff *skb, u8 sof)
  1003. {
  1004. struct i40e_pf *pf = tx_ring->vsi->back;
  1005. struct i40e_fcoe *fcoe = &pf->fcoe;
  1006. struct fc_frame_header *fh;
  1007. struct i40e_fcoe_ddp *ddp;
  1008. u32 f_ctl;
  1009. u8 r_ctl;
  1010. u16 xid;
  1011. fh = (struct fc_frame_header *)skb_transport_header(skb);
  1012. f_ctl = ntoh24(fh->fh_f_ctl);
  1013. r_ctl = fh->fh_r_ctl;
  1014. ddp = NULL;
  1015. if ((r_ctl == FC_RCTL_DD_DATA_DESC) && (f_ctl & FC_FC_EX_CTX)) {
  1016. /* exchange responder? if so, XFER_RDY for write */
  1017. xid = ntohs(fh->fh_rx_id);
  1018. if (i40e_fcoe_xid_is_valid(xid)) {
  1019. ddp = &fcoe->ddp[xid];
  1020. if ((ddp->xid == xid) &&
  1021. (test_bit(__I40E_FCOE_DDP_TARGET, &ddp->flags)))
  1022. i40e_fcoe_program_ddp(tx_ring, skb, ddp, sof);
  1023. }
  1024. } else if (r_ctl == FC_RCTL_DD_UNSOL_CMD) {
  1025. /* exchange originator, check READ cmd */
  1026. xid = ntohs(fh->fh_ox_id);
  1027. if (i40e_fcoe_xid_is_valid(xid)) {
  1028. ddp = &fcoe->ddp[xid];
  1029. if ((ddp->xid == xid) &&
  1030. (!test_bit(__I40E_FCOE_DDP_TARGET, &ddp->flags)))
  1031. i40e_fcoe_program_ddp(tx_ring, skb, ddp, sof);
  1032. }
  1033. } else if (r_ctl == FC_RCTL_BA_ABTS) {
  1034. /* exchange originator, check ABTS */
  1035. xid = ntohs(fh->fh_ox_id);
  1036. if (i40e_fcoe_xid_is_valid(xid)) {
  1037. ddp = &fcoe->ddp[xid];
  1038. if ((ddp->xid == xid) &&
  1039. (!test_bit(__I40E_FCOE_DDP_TARGET, &ddp->flags)))
  1040. i40e_fcoe_invalidate_ddp(tx_ring, skb, ddp);
  1041. }
  1042. }
  1043. }
  1044. /**
  1045. * i40e_fcoe_tso - set up FCoE TSO
  1046. * @tx_ring: ring to send buffer on
  1047. * @skb: send buffer
  1048. * @tx_flags: collected send information
  1049. * @hdr_len: the tso header length
  1050. * @sof: the SOF to indicate class of service
  1051. *
  1052. * Note must already have sof checked to be either class 2 or class 3 before
  1053. * calling this function.
  1054. *
  1055. * Returns 1 to indicate sequence segmentation offload is properly setup
  1056. * or returns 0 to indicate no tso is needed, otherwise returns error
  1057. * code to drop the frame.
  1058. **/
  1059. static int i40e_fcoe_tso(struct i40e_ring *tx_ring,
  1060. struct sk_buff *skb,
  1061. u32 tx_flags, u8 *hdr_len, u8 sof)
  1062. {
  1063. struct i40e_tx_context_desc *context_desc;
  1064. u32 cd_type, cd_cmd, cd_tso_len, cd_mss;
  1065. struct fc_frame_header *fh;
  1066. u64 cd_type_cmd_tso_mss;
  1067. /* must match gso type as FCoE */
  1068. if (!skb_is_gso(skb))
  1069. return 0;
  1070. /* is it the expected gso type for FCoE ?*/
  1071. if (skb_shinfo(skb)->gso_type != SKB_GSO_FCOE) {
  1072. netdev_err(skb->dev,
  1073. "wrong gso type %d:expecting SKB_GSO_FCOE\n",
  1074. skb_shinfo(skb)->gso_type);
  1075. return -EINVAL;
  1076. }
  1077. /* header and trailer are inserted by hw */
  1078. *hdr_len = skb_transport_offset(skb) + sizeof(struct fc_frame_header) +
  1079. sizeof(struct fcoe_crc_eof);
  1080. /* check sof to decide a class 2 or 3 TSO */
  1081. if (likely(i40e_fcoe_sof_is_class3(sof)))
  1082. cd_cmd = I40E_FCOE_TX_CTX_DESC_OPCODE_TSO_FC_CLASS3;
  1083. else
  1084. cd_cmd = I40E_FCOE_TX_CTX_DESC_OPCODE_TSO_FC_CLASS2;
  1085. /* param field valid? */
  1086. fh = (struct fc_frame_header *)skb_transport_header(skb);
  1087. if (fh->fh_f_ctl[2] & FC_FC_REL_OFF)
  1088. cd_cmd |= I40E_FCOE_TX_CTX_DESC_RELOFF;
  1089. /* fill the field values */
  1090. cd_type = I40E_TX_DESC_DTYPE_FCOE_CTX;
  1091. cd_tso_len = skb->len - *hdr_len;
  1092. cd_mss = skb_shinfo(skb)->gso_size;
  1093. cd_type_cmd_tso_mss =
  1094. ((u64)cd_type << I40E_TXD_CTX_QW1_DTYPE_SHIFT) |
  1095. ((u64)cd_cmd << I40E_TXD_CTX_QW1_CMD_SHIFT) |
  1096. ((u64)cd_tso_len << I40E_TXD_CTX_QW1_TSO_LEN_SHIFT) |
  1097. ((u64)cd_mss << I40E_TXD_CTX_QW1_MSS_SHIFT);
  1098. /* grab the next descriptor */
  1099. context_desc = I40E_TX_CTXTDESC(tx_ring, tx_ring->next_to_use);
  1100. tx_ring->next_to_use++;
  1101. if (tx_ring->next_to_use == tx_ring->count)
  1102. tx_ring->next_to_use = 0;
  1103. context_desc->tunneling_params = 0;
  1104. context_desc->l2tag2 = cpu_to_le16((tx_flags & I40E_TX_FLAGS_VLAN_MASK)
  1105. >> I40E_TX_FLAGS_VLAN_SHIFT);
  1106. context_desc->type_cmd_tso_mss = cpu_to_le64(cd_type_cmd_tso_mss);
  1107. return 1;
  1108. }
  1109. /**
  1110. * i40e_fcoe_tx_map - build the tx descriptor
  1111. * @tx_ring: ring to send buffer on
  1112. * @skb: send buffer
  1113. * @first: first buffer info buffer to use
  1114. * @tx_flags: collected send information
  1115. * @hdr_len: ptr to the size of the packet header
  1116. * @eof: the frame eof value
  1117. *
  1118. * Note, for FCoE, sof and eof are already checked
  1119. **/
  1120. static void i40e_fcoe_tx_map(struct i40e_ring *tx_ring,
  1121. struct sk_buff *skb,
  1122. struct i40e_tx_buffer *first,
  1123. u32 tx_flags, u8 hdr_len, u8 eof)
  1124. {
  1125. u32 td_offset = 0;
  1126. u32 td_cmd = 0;
  1127. u32 maclen;
  1128. /* insert CRC */
  1129. td_cmd = I40E_TX_DESC_CMD_ICRC;
  1130. /* setup MACLEN */
  1131. maclen = skb_network_offset(skb);
  1132. if (tx_flags & I40E_TX_FLAGS_SW_VLAN)
  1133. maclen += sizeof(struct vlan_hdr);
  1134. if (skb->protocol == htons(ETH_P_FCOE)) {
  1135. /* for FCoE, maclen should exclude ether type */
  1136. maclen -= 2;
  1137. /* setup type as FCoE and EOF insertion */
  1138. td_cmd |= (I40E_TX_DESC_CMD_FCOET | i40e_fcoe_ctxt_eof(eof));
  1139. /* setup FCoELEN and FCLEN */
  1140. td_offset |= ((((sizeof(struct fcoe_hdr) + 2) >> 2) <<
  1141. I40E_TX_DESC_LENGTH_IPLEN_SHIFT) |
  1142. ((sizeof(struct fc_frame_header) >> 2) <<
  1143. I40E_TX_DESC_LENGTH_L4_FC_LEN_SHIFT));
  1144. /* trim to exclude trailer */
  1145. pskb_trim(skb, skb->len - sizeof(struct fcoe_crc_eof));
  1146. }
  1147. /* MACLEN is ether header length in words not bytes */
  1148. td_offset |= (maclen >> 1) << I40E_TX_DESC_LENGTH_MACLEN_SHIFT;
  1149. return i40e_tx_map(tx_ring, skb, first, tx_flags, hdr_len,
  1150. td_cmd, td_offset);
  1151. }
  1152. /**
  1153. * i40e_fcoe_set_skb_header - adjust skb header point for FIP/FCoE/FC
  1154. * @skb: the skb to be adjusted
  1155. *
  1156. * Returns true if this skb is a FCoE/FIP or VLAN carried FCoE/FIP and then
  1157. * adjusts the skb header pointers correspondingly. Otherwise, returns false.
  1158. **/
  1159. static inline int i40e_fcoe_set_skb_header(struct sk_buff *skb)
  1160. {
  1161. __be16 protocol = skb->protocol;
  1162. skb_reset_mac_header(skb);
  1163. skb->mac_len = sizeof(struct ethhdr);
  1164. if (protocol == htons(ETH_P_8021Q)) {
  1165. struct vlan_ethhdr *veth = (struct vlan_ethhdr *)eth_hdr(skb);
  1166. protocol = veth->h_vlan_encapsulated_proto;
  1167. skb->mac_len += sizeof(struct vlan_hdr);
  1168. }
  1169. /* FCoE or FIP only */
  1170. if ((protocol != htons(ETH_P_FIP)) &&
  1171. (protocol != htons(ETH_P_FCOE)))
  1172. return -EINVAL;
  1173. /* set header to L2 of FCoE/FIP */
  1174. skb_set_network_header(skb, skb->mac_len);
  1175. if (protocol == htons(ETH_P_FIP))
  1176. return 0;
  1177. /* set header to L3 of FC */
  1178. skb_set_transport_header(skb, skb->mac_len + sizeof(struct fcoe_hdr));
  1179. return 0;
  1180. }
  1181. /**
  1182. * i40e_fcoe_xmit_frame - transmit buffer
  1183. * @skb: send buffer
  1184. * @netdev: the fcoe netdev
  1185. *
  1186. * Returns 0 if sent, else an error code
  1187. **/
  1188. static netdev_tx_t i40e_fcoe_xmit_frame(struct sk_buff *skb,
  1189. struct net_device *netdev)
  1190. {
  1191. struct i40e_netdev_priv *np = netdev_priv(skb->dev);
  1192. struct i40e_vsi *vsi = np->vsi;
  1193. struct i40e_ring *tx_ring = vsi->tx_rings[skb->queue_mapping];
  1194. struct i40e_tx_buffer *first;
  1195. u32 tx_flags = 0;
  1196. u8 hdr_len = 0;
  1197. u8 sof = 0;
  1198. u8 eof = 0;
  1199. int fso;
  1200. if (i40e_fcoe_set_skb_header(skb))
  1201. goto out_drop;
  1202. if (!i40e_xmit_descriptor_count(skb, tx_ring))
  1203. return NETDEV_TX_BUSY;
  1204. /* prepare the xmit flags */
  1205. if (i40e_tx_prepare_vlan_flags(skb, tx_ring, &tx_flags))
  1206. goto out_drop;
  1207. /* record the location of the first descriptor for this packet */
  1208. first = &tx_ring->tx_bi[tx_ring->next_to_use];
  1209. /* FIP is a regular L2 traffic w/o offload */
  1210. if (skb->protocol == htons(ETH_P_FIP))
  1211. goto out_send;
  1212. /* check sof and eof, only supports FC Class 2 or 3 */
  1213. if (i40e_fcoe_fc_sof(skb, &sof) || i40e_fcoe_fc_eof(skb, &eof)) {
  1214. netdev_err(netdev, "SOF/EOF error:%02x - %02x\n", sof, eof);
  1215. goto out_drop;
  1216. }
  1217. /* always do FCCRC for FCoE */
  1218. tx_flags |= I40E_TX_FLAGS_FCCRC;
  1219. /* check we should do sequence offload */
  1220. fso = i40e_fcoe_tso(tx_ring, skb, tx_flags, &hdr_len, sof);
  1221. if (fso < 0)
  1222. goto out_drop;
  1223. else if (fso)
  1224. tx_flags |= I40E_TX_FLAGS_FSO;
  1225. else
  1226. i40e_fcoe_handle_ddp(tx_ring, skb, sof);
  1227. out_send:
  1228. /* send out the packet */
  1229. i40e_fcoe_tx_map(tx_ring, skb, first, tx_flags, hdr_len, eof);
  1230. i40e_maybe_stop_tx(tx_ring, DESC_NEEDED);
  1231. return NETDEV_TX_OK;
  1232. out_drop:
  1233. dev_kfree_skb_any(skb);
  1234. return NETDEV_TX_OK;
  1235. }
  1236. /**
  1237. * i40e_fcoe_change_mtu - NDO callback to change the Maximum Transfer Unit
  1238. * @netdev: network interface device structure
  1239. * @new_mtu: new value for maximum frame size
  1240. *
  1241. * Returns error as operation not permitted
  1242. *
  1243. **/
  1244. static int i40e_fcoe_change_mtu(struct net_device *netdev, int new_mtu)
  1245. {
  1246. netdev_warn(netdev, "MTU change is not supported on FCoE interfaces\n");
  1247. return -EPERM;
  1248. }
  1249. /**
  1250. * i40e_fcoe_set_features - set the netdev feature flags
  1251. * @netdev: ptr to the netdev being adjusted
  1252. * @features: the feature set that the stack is suggesting
  1253. *
  1254. **/
  1255. static int i40e_fcoe_set_features(struct net_device *netdev,
  1256. netdev_features_t features)
  1257. {
  1258. struct i40e_netdev_priv *np = netdev_priv(netdev);
  1259. struct i40e_vsi *vsi = np->vsi;
  1260. if (features & NETIF_F_HW_VLAN_CTAG_RX)
  1261. i40e_vlan_stripping_enable(vsi);
  1262. else
  1263. i40e_vlan_stripping_disable(vsi);
  1264. return 0;
  1265. }
  1266. static const struct net_device_ops i40e_fcoe_netdev_ops = {
  1267. .ndo_open = i40e_open,
  1268. .ndo_stop = i40e_close,
  1269. .ndo_get_stats64 = i40e_get_netdev_stats_struct,
  1270. .ndo_set_rx_mode = i40e_set_rx_mode,
  1271. .ndo_validate_addr = eth_validate_addr,
  1272. .ndo_set_mac_address = i40e_set_mac,
  1273. .ndo_change_mtu = i40e_fcoe_change_mtu,
  1274. .ndo_do_ioctl = i40e_ioctl,
  1275. .ndo_tx_timeout = i40e_tx_timeout,
  1276. .ndo_vlan_rx_add_vid = i40e_vlan_rx_add_vid,
  1277. .ndo_vlan_rx_kill_vid = i40e_vlan_rx_kill_vid,
  1278. .ndo_setup_tc = i40e_setup_tc,
  1279. #ifdef CONFIG_NET_POLL_CONTROLLER
  1280. .ndo_poll_controller = i40e_netpoll,
  1281. #endif
  1282. .ndo_start_xmit = i40e_fcoe_xmit_frame,
  1283. .ndo_fcoe_enable = i40e_fcoe_enable,
  1284. .ndo_fcoe_disable = i40e_fcoe_disable,
  1285. .ndo_fcoe_ddp_setup = i40e_fcoe_ddp_get,
  1286. .ndo_fcoe_ddp_done = i40e_fcoe_ddp_put,
  1287. .ndo_fcoe_ddp_target = i40e_fcoe_ddp_target,
  1288. .ndo_set_features = i40e_fcoe_set_features,
  1289. };
  1290. /**
  1291. * i40e_fcoe_config_netdev - prepares the VSI context for creating a FCoE VSI
  1292. * @vsi: pointer to the associated VSI struct
  1293. * @ctxt: pointer to the associated VSI context to be passed to HW
  1294. *
  1295. * Returns 0 on success or < 0 on error
  1296. **/
  1297. void i40e_fcoe_config_netdev(struct net_device *netdev, struct i40e_vsi *vsi)
  1298. {
  1299. struct i40e_hw *hw = &vsi->back->hw;
  1300. struct i40e_pf *pf = vsi->back;
  1301. if (vsi->type != I40E_VSI_FCOE)
  1302. return;
  1303. netdev->features = (NETIF_F_HW_VLAN_CTAG_TX |
  1304. NETIF_F_HW_VLAN_CTAG_RX |
  1305. NETIF_F_HW_VLAN_CTAG_FILTER);
  1306. netdev->vlan_features = netdev->features;
  1307. netdev->vlan_features &= ~(NETIF_F_HW_VLAN_CTAG_TX |
  1308. NETIF_F_HW_VLAN_CTAG_RX |
  1309. NETIF_F_HW_VLAN_CTAG_FILTER);
  1310. netdev->fcoe_ddp_xid = I40E_FCOE_DDP_MAX - 1;
  1311. netdev->features |= NETIF_F_ALL_FCOE;
  1312. netdev->vlan_features |= NETIF_F_ALL_FCOE;
  1313. netdev->hw_features |= netdev->features;
  1314. netdev->priv_flags |= IFF_UNICAST_FLT;
  1315. netdev->priv_flags |= IFF_SUPP_NOFCS;
  1316. strlcpy(netdev->name, "fcoe%d", IFNAMSIZ-1);
  1317. netdev->mtu = FCOE_MTU;
  1318. SET_NETDEV_DEV(netdev, &pf->pdev->dev);
  1319. /* set different dev_port value 1 for FCoE netdev than the default
  1320. * zero dev_port value for PF netdev, this helps biosdevname user
  1321. * tool to differentiate them correctly while both attached to the
  1322. * same PCI function.
  1323. */
  1324. netdev->dev_port = 1;
  1325. i40e_add_filter(vsi, hw->mac.san_addr, 0, false, false);
  1326. i40e_add_filter(vsi, (u8[6]) FC_FCOE_FLOGI_MAC, 0, false, false);
  1327. i40e_add_filter(vsi, FIP_ALL_FCOE_MACS, 0, false, false);
  1328. i40e_add_filter(vsi, FIP_ALL_ENODE_MACS, 0, false, false);
  1329. /* use san mac */
  1330. ether_addr_copy(netdev->dev_addr, hw->mac.san_addr);
  1331. ether_addr_copy(netdev->perm_addr, hw->mac.san_addr);
  1332. /* fcoe netdev ops */
  1333. netdev->netdev_ops = &i40e_fcoe_netdev_ops;
  1334. }
  1335. /**
  1336. * i40e_fcoe_vsi_setup - allocate and set up FCoE VSI
  1337. * @pf: the pf that VSI is associated with
  1338. *
  1339. **/
  1340. void i40e_fcoe_vsi_setup(struct i40e_pf *pf)
  1341. {
  1342. struct i40e_vsi *vsi;
  1343. u16 seid;
  1344. int i;
  1345. if (!(pf->flags & I40E_FLAG_FCOE_ENABLED))
  1346. return;
  1347. BUG_ON(!pf->vsi[pf->lan_vsi]);
  1348. for (i = 0; i < pf->num_alloc_vsi; i++) {
  1349. vsi = pf->vsi[i];
  1350. if (vsi && vsi->type == I40E_VSI_FCOE) {
  1351. dev_warn(&pf->pdev->dev,
  1352. "FCoE VSI already created\n");
  1353. return;
  1354. }
  1355. }
  1356. seid = pf->vsi[pf->lan_vsi]->seid;
  1357. vsi = i40e_vsi_setup(pf, I40E_VSI_FCOE, seid, 0);
  1358. if (vsi) {
  1359. dev_dbg(&pf->pdev->dev,
  1360. "Successfully created FCoE VSI seid %d id %d uplink_seid %d pf seid %d\n",
  1361. vsi->seid, vsi->id, vsi->uplink_seid, seid);
  1362. } else {
  1363. dev_info(&pf->pdev->dev, "Failed to create FCoE VSI\n");
  1364. }
  1365. }