ixgbe_lib.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. /*******************************************************************************
  2. Intel 10 Gigabit PCI Express Linux driver
  3. Copyright(c) 1999 - 2012 Intel Corporation.
  4. This program is free software; you can redistribute it and/or modify it
  5. under the terms and conditions of the GNU General Public License,
  6. version 2, as published by the Free Software Foundation.
  7. This program is distributed in the hope it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  10. more details.
  11. You should have received a copy of the GNU General Public License along with
  12. this program; if not, write to the Free Software Foundation, Inc.,
  13. 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  14. The full GNU General Public License is included in this distribution in
  15. the file called "COPYING".
  16. Contact Information:
  17. e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  18. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  19. *******************************************************************************/
  20. #include "ixgbe.h"
  21. #include "ixgbe_sriov.h"
  22. #ifdef CONFIG_IXGBE_DCB
  23. /**
  24. * ixgbe_cache_ring_dcb_sriov - Descriptor ring to register mapping for SR-IOV
  25. * @adapter: board private structure to initialize
  26. *
  27. * Cache the descriptor ring offsets for SR-IOV to the assigned rings. It
  28. * will also try to cache the proper offsets if RSS/FCoE are enabled along
  29. * with VMDq.
  30. *
  31. **/
  32. static bool ixgbe_cache_ring_dcb_sriov(struct ixgbe_adapter *adapter)
  33. {
  34. #ifdef IXGBE_FCOE
  35. struct ixgbe_ring_feature *fcoe = &adapter->ring_feature[RING_F_FCOE];
  36. #endif /* IXGBE_FCOE */
  37. struct ixgbe_ring_feature *vmdq = &adapter->ring_feature[RING_F_VMDQ];
  38. int i;
  39. u16 reg_idx;
  40. u8 tcs = netdev_get_num_tc(adapter->netdev);
  41. /* verify we have DCB queueing enabled before proceeding */
  42. if (tcs <= 1)
  43. return false;
  44. /* verify we have VMDq enabled before proceeding */
  45. if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
  46. return false;
  47. /* start at VMDq register offset for SR-IOV enabled setups */
  48. reg_idx = vmdq->offset * __ALIGN_MASK(1, ~vmdq->mask);
  49. for (i = 0; i < adapter->num_rx_queues; i++, reg_idx++) {
  50. /* If we are greater than indices move to next pool */
  51. if ((reg_idx & ~vmdq->mask) >= tcs)
  52. reg_idx = __ALIGN_MASK(reg_idx, ~vmdq->mask);
  53. adapter->rx_ring[i]->reg_idx = reg_idx;
  54. }
  55. reg_idx = vmdq->offset * __ALIGN_MASK(1, ~vmdq->mask);
  56. for (i = 0; i < adapter->num_tx_queues; i++, reg_idx++) {
  57. /* If we are greater than indices move to next pool */
  58. if ((reg_idx & ~vmdq->mask) >= tcs)
  59. reg_idx = __ALIGN_MASK(reg_idx, ~vmdq->mask);
  60. adapter->tx_ring[i]->reg_idx = reg_idx;
  61. }
  62. #ifdef IXGBE_FCOE
  63. /* nothing to do if FCoE is disabled */
  64. if (!(adapter->flags & IXGBE_FLAG_FCOE_ENABLED))
  65. return true;
  66. /* The work is already done if the FCoE ring is shared */
  67. if (fcoe->offset < tcs)
  68. return true;
  69. /* The FCoE rings exist separately, we need to move their reg_idx */
  70. if (fcoe->indices) {
  71. u16 queues_per_pool = __ALIGN_MASK(1, ~vmdq->mask);
  72. u8 fcoe_tc = ixgbe_fcoe_get_tc(adapter);
  73. reg_idx = (vmdq->offset + vmdq->indices) * queues_per_pool;
  74. for (i = fcoe->offset; i < adapter->num_rx_queues; i++) {
  75. reg_idx = __ALIGN_MASK(reg_idx, ~vmdq->mask) + fcoe_tc;
  76. adapter->rx_ring[i]->reg_idx = reg_idx;
  77. reg_idx++;
  78. }
  79. reg_idx = (vmdq->offset + vmdq->indices) * queues_per_pool;
  80. for (i = fcoe->offset; i < adapter->num_tx_queues; i++) {
  81. reg_idx = __ALIGN_MASK(reg_idx, ~vmdq->mask) + fcoe_tc;
  82. adapter->tx_ring[i]->reg_idx = reg_idx;
  83. reg_idx++;
  84. }
  85. }
  86. #endif /* IXGBE_FCOE */
  87. return true;
  88. }
  89. /* ixgbe_get_first_reg_idx - Return first register index associated with ring */
  90. static void ixgbe_get_first_reg_idx(struct ixgbe_adapter *adapter, u8 tc,
  91. unsigned int *tx, unsigned int *rx)
  92. {
  93. struct net_device *dev = adapter->netdev;
  94. struct ixgbe_hw *hw = &adapter->hw;
  95. u8 num_tcs = netdev_get_num_tc(dev);
  96. *tx = 0;
  97. *rx = 0;
  98. switch (hw->mac.type) {
  99. case ixgbe_mac_82598EB:
  100. /* TxQs/TC: 4 RxQs/TC: 8 */
  101. *tx = tc << 2; /* 0, 4, 8, 12, 16, 20, 24, 28 */
  102. *rx = tc << 3; /* 0, 8, 16, 24, 32, 40, 48, 56 */
  103. break;
  104. case ixgbe_mac_82599EB:
  105. case ixgbe_mac_X540:
  106. if (num_tcs > 4) {
  107. /*
  108. * TCs : TC0/1 TC2/3 TC4-7
  109. * TxQs/TC: 32 16 8
  110. * RxQs/TC: 16 16 16
  111. */
  112. *rx = tc << 4;
  113. if (tc < 3)
  114. *tx = tc << 5; /* 0, 32, 64 */
  115. else if (tc < 5)
  116. *tx = (tc + 2) << 4; /* 80, 96 */
  117. else
  118. *tx = (tc + 8) << 3; /* 104, 112, 120 */
  119. } else {
  120. /*
  121. * TCs : TC0 TC1 TC2/3
  122. * TxQs/TC: 64 32 16
  123. * RxQs/TC: 32 32 32
  124. */
  125. *rx = tc << 5;
  126. if (tc < 2)
  127. *tx = tc << 6; /* 0, 64 */
  128. else
  129. *tx = (tc + 4) << 4; /* 96, 112 */
  130. }
  131. default:
  132. break;
  133. }
  134. }
  135. /**
  136. * ixgbe_cache_ring_dcb - Descriptor ring to register mapping for DCB
  137. * @adapter: board private structure to initialize
  138. *
  139. * Cache the descriptor ring offsets for DCB to the assigned rings.
  140. *
  141. **/
  142. static bool ixgbe_cache_ring_dcb(struct ixgbe_adapter *adapter)
  143. {
  144. struct net_device *dev = adapter->netdev;
  145. unsigned int tx_idx, rx_idx;
  146. int tc, offset, rss_i, i;
  147. u8 num_tcs = netdev_get_num_tc(dev);
  148. /* verify we have DCB queueing enabled before proceeding */
  149. if (num_tcs <= 1)
  150. return false;
  151. rss_i = adapter->ring_feature[RING_F_RSS].indices;
  152. for (tc = 0, offset = 0; tc < num_tcs; tc++, offset += rss_i) {
  153. ixgbe_get_first_reg_idx(adapter, tc, &tx_idx, &rx_idx);
  154. for (i = 0; i < rss_i; i++, tx_idx++, rx_idx++) {
  155. adapter->tx_ring[offset + i]->reg_idx = tx_idx;
  156. adapter->rx_ring[offset + i]->reg_idx = rx_idx;
  157. adapter->tx_ring[offset + i]->dcb_tc = tc;
  158. adapter->rx_ring[offset + i]->dcb_tc = tc;
  159. }
  160. }
  161. return true;
  162. }
  163. #endif
  164. /**
  165. * ixgbe_cache_ring_sriov - Descriptor ring to register mapping for sriov
  166. * @adapter: board private structure to initialize
  167. *
  168. * SR-IOV doesn't use any descriptor rings but changes the default if
  169. * no other mapping is used.
  170. *
  171. */
  172. static bool ixgbe_cache_ring_sriov(struct ixgbe_adapter *adapter)
  173. {
  174. #ifdef IXGBE_FCOE
  175. struct ixgbe_ring_feature *fcoe = &adapter->ring_feature[RING_F_FCOE];
  176. #endif /* IXGBE_FCOE */
  177. struct ixgbe_ring_feature *vmdq = &adapter->ring_feature[RING_F_VMDQ];
  178. struct ixgbe_ring_feature *rss = &adapter->ring_feature[RING_F_RSS];
  179. int i;
  180. u16 reg_idx;
  181. /* only proceed if VMDq is enabled */
  182. if (!(adapter->flags & IXGBE_FLAG_VMDQ_ENABLED))
  183. return false;
  184. /* start at VMDq register offset for SR-IOV enabled setups */
  185. reg_idx = vmdq->offset * __ALIGN_MASK(1, ~vmdq->mask);
  186. for (i = 0; i < adapter->num_rx_queues; i++, reg_idx++) {
  187. #ifdef IXGBE_FCOE
  188. /* Allow first FCoE queue to be mapped as RSS */
  189. if (fcoe->offset && (i > fcoe->offset))
  190. break;
  191. #endif
  192. /* If we are greater than indices move to next pool */
  193. if ((reg_idx & ~vmdq->mask) >= rss->indices)
  194. reg_idx = __ALIGN_MASK(reg_idx, ~vmdq->mask);
  195. adapter->rx_ring[i]->reg_idx = reg_idx;
  196. }
  197. #ifdef IXGBE_FCOE
  198. /* FCoE uses a linear block of queues so just assigning 1:1 */
  199. for (; i < adapter->num_rx_queues; i++, reg_idx++)
  200. adapter->rx_ring[i]->reg_idx = reg_idx;
  201. #endif
  202. reg_idx = vmdq->offset * __ALIGN_MASK(1, ~vmdq->mask);
  203. for (i = 0; i < adapter->num_tx_queues; i++, reg_idx++) {
  204. #ifdef IXGBE_FCOE
  205. /* Allow first FCoE queue to be mapped as RSS */
  206. if (fcoe->offset && (i > fcoe->offset))
  207. break;
  208. #endif
  209. /* If we are greater than indices move to next pool */
  210. if ((reg_idx & rss->mask) >= rss->indices)
  211. reg_idx = __ALIGN_MASK(reg_idx, ~vmdq->mask);
  212. adapter->tx_ring[i]->reg_idx = reg_idx;
  213. }
  214. #ifdef IXGBE_FCOE
  215. /* FCoE uses a linear block of queues so just assigning 1:1 */
  216. for (; i < adapter->num_tx_queues; i++, reg_idx++)
  217. adapter->tx_ring[i]->reg_idx = reg_idx;
  218. #endif
  219. return true;
  220. }
  221. /**
  222. * ixgbe_cache_ring_rss - Descriptor ring to register mapping for RSS
  223. * @adapter: board private structure to initialize
  224. *
  225. * Cache the descriptor ring offsets for RSS to the assigned rings.
  226. *
  227. **/
  228. static bool ixgbe_cache_ring_rss(struct ixgbe_adapter *adapter)
  229. {
  230. int i;
  231. if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED))
  232. return false;
  233. for (i = 0; i < adapter->num_rx_queues; i++)
  234. adapter->rx_ring[i]->reg_idx = i;
  235. for (i = 0; i < adapter->num_tx_queues; i++)
  236. adapter->tx_ring[i]->reg_idx = i;
  237. return true;
  238. }
  239. /**
  240. * ixgbe_cache_ring_register - Descriptor ring to register mapping
  241. * @adapter: board private structure to initialize
  242. *
  243. * Once we know the feature-set enabled for the device, we'll cache
  244. * the register offset the descriptor ring is assigned to.
  245. *
  246. * Note, the order the various feature calls is important. It must start with
  247. * the "most" features enabled at the same time, then trickle down to the
  248. * least amount of features turned on at once.
  249. **/
  250. static void ixgbe_cache_ring_register(struct ixgbe_adapter *adapter)
  251. {
  252. /* start with default case */
  253. adapter->rx_ring[0]->reg_idx = 0;
  254. adapter->tx_ring[0]->reg_idx = 0;
  255. #ifdef CONFIG_IXGBE_DCB
  256. if (ixgbe_cache_ring_dcb_sriov(adapter))
  257. return;
  258. if (ixgbe_cache_ring_dcb(adapter))
  259. return;
  260. #endif
  261. if (ixgbe_cache_ring_sriov(adapter))
  262. return;
  263. ixgbe_cache_ring_rss(adapter);
  264. }
  265. #define IXGBE_RSS_16Q_MASK 0xF
  266. #define IXGBE_RSS_8Q_MASK 0x7
  267. #define IXGBE_RSS_4Q_MASK 0x3
  268. #define IXGBE_RSS_2Q_MASK 0x1
  269. #define IXGBE_RSS_DISABLED_MASK 0x0
  270. #ifdef CONFIG_IXGBE_DCB
  271. /**
  272. * ixgbe_set_dcb_sriov_queues: Allocate queues for SR-IOV devices w/ DCB
  273. * @adapter: board private structure to initialize
  274. *
  275. * When SR-IOV (Single Root IO Virtualiztion) is enabled, allocate queues
  276. * and VM pools where appropriate. Also assign queues based on DCB
  277. * priorities and map accordingly..
  278. *
  279. **/
  280. static bool ixgbe_set_dcb_sriov_queues(struct ixgbe_adapter *adapter)
  281. {
  282. int i;
  283. u16 vmdq_i = adapter->ring_feature[RING_F_VMDQ].limit;
  284. u16 vmdq_m = 0;
  285. #ifdef IXGBE_FCOE
  286. u16 fcoe_i = 0;
  287. #endif
  288. u8 tcs = netdev_get_num_tc(adapter->netdev);
  289. /* verify we have DCB queueing enabled before proceeding */
  290. if (tcs <= 1)
  291. return false;
  292. /* verify we have VMDq enabled before proceeding */
  293. if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
  294. return false;
  295. /* Add starting offset to total pool count */
  296. vmdq_i += adapter->ring_feature[RING_F_VMDQ].offset;
  297. /* 16 pools w/ 8 TC per pool */
  298. if (tcs > 4) {
  299. vmdq_i = min_t(u16, vmdq_i, 16);
  300. vmdq_m = IXGBE_82599_VMDQ_8Q_MASK;
  301. /* 32 pools w/ 4 TC per pool */
  302. } else {
  303. vmdq_i = min_t(u16, vmdq_i, 32);
  304. vmdq_m = IXGBE_82599_VMDQ_4Q_MASK;
  305. }
  306. #ifdef IXGBE_FCOE
  307. /* queues in the remaining pools are available for FCoE */
  308. fcoe_i = (128 / __ALIGN_MASK(1, ~vmdq_m)) - vmdq_i;
  309. #endif
  310. /* remove the starting offset from the pool count */
  311. vmdq_i -= adapter->ring_feature[RING_F_VMDQ].offset;
  312. /* save features for later use */
  313. adapter->ring_feature[RING_F_VMDQ].indices = vmdq_i;
  314. adapter->ring_feature[RING_F_VMDQ].mask = vmdq_m;
  315. /*
  316. * We do not support DCB, VMDq, and RSS all simultaneously
  317. * so we will disable RSS since it is the lowest priority
  318. */
  319. adapter->ring_feature[RING_F_RSS].indices = 1;
  320. adapter->ring_feature[RING_F_RSS].mask = IXGBE_RSS_DISABLED_MASK;
  321. adapter->num_rx_pools = vmdq_i;
  322. adapter->num_rx_queues_per_pool = tcs;
  323. adapter->num_tx_queues = vmdq_i * tcs;
  324. adapter->num_rx_queues = vmdq_i * tcs;
  325. #ifdef IXGBE_FCOE
  326. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  327. struct ixgbe_ring_feature *fcoe;
  328. fcoe = &adapter->ring_feature[RING_F_FCOE];
  329. /* limit ourselves based on feature limits */
  330. fcoe_i = min_t(u16, fcoe_i, num_online_cpus());
  331. fcoe_i = min_t(u16, fcoe_i, fcoe->limit);
  332. if (fcoe_i) {
  333. /* alloc queues for FCoE separately */
  334. fcoe->indices = fcoe_i;
  335. fcoe->offset = vmdq_i * tcs;
  336. /* add queues to adapter */
  337. adapter->num_tx_queues += fcoe_i;
  338. adapter->num_rx_queues += fcoe_i;
  339. } else if (tcs > 1) {
  340. /* use queue belonging to FcoE TC */
  341. fcoe->indices = 1;
  342. fcoe->offset = ixgbe_fcoe_get_tc(adapter);
  343. } else {
  344. adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED;
  345. fcoe->indices = 0;
  346. fcoe->offset = 0;
  347. }
  348. }
  349. #endif /* IXGBE_FCOE */
  350. /* configure TC to queue mapping */
  351. for (i = 0; i < tcs; i++)
  352. netdev_set_tc_queue(adapter->netdev, i, 1, i);
  353. return true;
  354. }
  355. static bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter)
  356. {
  357. struct net_device *dev = adapter->netdev;
  358. struct ixgbe_ring_feature *f;
  359. int rss_i, rss_m, i;
  360. int tcs;
  361. /* Map queue offset and counts onto allocated tx queues */
  362. tcs = netdev_get_num_tc(dev);
  363. /* verify we have DCB queueing enabled before proceeding */
  364. if (tcs <= 1)
  365. return false;
  366. /* determine the upper limit for our current DCB mode */
  367. rss_i = dev->num_tx_queues / tcs;
  368. if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
  369. /* 8 TC w/ 4 queues per TC */
  370. rss_i = min_t(u16, rss_i, 4);
  371. rss_m = IXGBE_RSS_4Q_MASK;
  372. } else if (tcs > 4) {
  373. /* 8 TC w/ 8 queues per TC */
  374. rss_i = min_t(u16, rss_i, 8);
  375. rss_m = IXGBE_RSS_8Q_MASK;
  376. } else {
  377. /* 4 TC w/ 16 queues per TC */
  378. rss_i = min_t(u16, rss_i, 16);
  379. rss_m = IXGBE_RSS_16Q_MASK;
  380. }
  381. /* set RSS mask and indices */
  382. f = &adapter->ring_feature[RING_F_RSS];
  383. rss_i = min_t(int, rss_i, f->limit);
  384. f->indices = rss_i;
  385. f->mask = rss_m;
  386. #ifdef IXGBE_FCOE
  387. /* FCoE enabled queues require special configuration indexed
  388. * by feature specific indices and offset. Here we map FCoE
  389. * indices onto the DCB queue pairs allowing FCoE to own
  390. * configuration later.
  391. */
  392. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  393. u8 tc = ixgbe_fcoe_get_tc(adapter);
  394. f = &adapter->ring_feature[RING_F_FCOE];
  395. f->indices = min_t(u16, rss_i, f->limit);
  396. f->offset = rss_i * tc;
  397. }
  398. #endif /* IXGBE_FCOE */
  399. for (i = 0; i < tcs; i++)
  400. netdev_set_tc_queue(dev, i, rss_i, rss_i * i);
  401. adapter->num_tx_queues = rss_i * tcs;
  402. adapter->num_rx_queues = rss_i * tcs;
  403. return true;
  404. }
  405. #endif
  406. /**
  407. * ixgbe_set_sriov_queues - Allocate queues for SR-IOV devices
  408. * @adapter: board private structure to initialize
  409. *
  410. * When SR-IOV (Single Root IO Virtualiztion) is enabled, allocate queues
  411. * and VM pools where appropriate. If RSS is available, then also try and
  412. * enable RSS and map accordingly.
  413. *
  414. **/
  415. static bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)
  416. {
  417. u16 vmdq_i = adapter->ring_feature[RING_F_VMDQ].limit;
  418. u16 vmdq_m = 0;
  419. u16 rss_i = adapter->ring_feature[RING_F_RSS].limit;
  420. u16 rss_m = IXGBE_RSS_DISABLED_MASK;
  421. #ifdef IXGBE_FCOE
  422. u16 fcoe_i = 0;
  423. #endif
  424. /* only proceed if SR-IOV is enabled */
  425. if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
  426. return false;
  427. /* Add starting offset to total pool count */
  428. vmdq_i += adapter->ring_feature[RING_F_VMDQ].offset;
  429. /* double check we are limited to maximum pools */
  430. vmdq_i = min_t(u16, IXGBE_MAX_VMDQ_INDICES, vmdq_i);
  431. /* 64 pool mode with 2 queues per pool */
  432. if ((vmdq_i > 32) || (rss_i < 4)) {
  433. vmdq_m = IXGBE_82599_VMDQ_2Q_MASK;
  434. rss_m = IXGBE_RSS_2Q_MASK;
  435. rss_i = min_t(u16, rss_i, 2);
  436. /* 32 pool mode with 4 queues per pool */
  437. } else {
  438. vmdq_m = IXGBE_82599_VMDQ_4Q_MASK;
  439. rss_m = IXGBE_RSS_4Q_MASK;
  440. rss_i = 4;
  441. }
  442. #ifdef IXGBE_FCOE
  443. /* queues in the remaining pools are available for FCoE */
  444. fcoe_i = 128 - (vmdq_i * __ALIGN_MASK(1, ~vmdq_m));
  445. #endif
  446. /* remove the starting offset from the pool count */
  447. vmdq_i -= adapter->ring_feature[RING_F_VMDQ].offset;
  448. /* save features for later use */
  449. adapter->ring_feature[RING_F_VMDQ].indices = vmdq_i;
  450. adapter->ring_feature[RING_F_VMDQ].mask = vmdq_m;
  451. /* limit RSS based on user input and save for later use */
  452. adapter->ring_feature[RING_F_RSS].indices = rss_i;
  453. adapter->ring_feature[RING_F_RSS].mask = rss_m;
  454. adapter->num_rx_pools = vmdq_i;
  455. adapter->num_rx_queues_per_pool = rss_i;
  456. adapter->num_rx_queues = vmdq_i * rss_i;
  457. adapter->num_tx_queues = vmdq_i * rss_i;
  458. /* disable ATR as it is not supported when VMDq is enabled */
  459. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  460. #ifdef IXGBE_FCOE
  461. /*
  462. * FCoE can use rings from adjacent buffers to allow RSS
  463. * like behavior. To account for this we need to add the
  464. * FCoE indices to the total ring count.
  465. */
  466. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  467. struct ixgbe_ring_feature *fcoe;
  468. fcoe = &adapter->ring_feature[RING_F_FCOE];
  469. /* limit ourselves based on feature limits */
  470. fcoe_i = min_t(u16, fcoe_i, fcoe->limit);
  471. if (vmdq_i > 1 && fcoe_i) {
  472. /* reserve no more than number of CPUs */
  473. fcoe_i = min_t(u16, fcoe_i, num_online_cpus());
  474. /* alloc queues for FCoE separately */
  475. fcoe->indices = fcoe_i;
  476. fcoe->offset = vmdq_i * rss_i;
  477. } else {
  478. /* merge FCoE queues with RSS queues */
  479. fcoe_i = min_t(u16, fcoe_i + rss_i, num_online_cpus());
  480. /* limit indices to rss_i if MSI-X is disabled */
  481. if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
  482. fcoe_i = rss_i;
  483. /* attempt to reserve some queues for just FCoE */
  484. fcoe->indices = min_t(u16, fcoe_i, fcoe->limit);
  485. fcoe->offset = fcoe_i - fcoe->indices;
  486. fcoe_i -= rss_i;
  487. }
  488. /* add queues to adapter */
  489. adapter->num_tx_queues += fcoe_i;
  490. adapter->num_rx_queues += fcoe_i;
  491. }
  492. #endif
  493. return true;
  494. }
  495. /**
  496. * ixgbe_set_rss_queues - Allocate queues for RSS
  497. * @adapter: board private structure to initialize
  498. *
  499. * This is our "base" multiqueue mode. RSS (Receive Side Scaling) will try
  500. * to allocate one Rx queue per CPU, and if available, one Tx queue per CPU.
  501. *
  502. **/
  503. static bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter)
  504. {
  505. struct ixgbe_ring_feature *f;
  506. u16 rss_i;
  507. if (!(adapter->flags & IXGBE_FLAG_RSS_ENABLED)) {
  508. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  509. return false;
  510. }
  511. /* set mask for 16 queue limit of RSS */
  512. f = &adapter->ring_feature[RING_F_RSS];
  513. rss_i = f->limit;
  514. f->indices = rss_i;
  515. f->mask = IXGBE_RSS_16Q_MASK;
  516. /*
  517. * Use Flow Director in addition to RSS to ensure the best
  518. * distribution of flows across cores, even when an FDIR flow
  519. * isn't matched.
  520. */
  521. if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) {
  522. f = &adapter->ring_feature[RING_F_FDIR];
  523. f->indices = min_t(u16, num_online_cpus(), f->limit);
  524. rss_i = max_t(u16, rss_i, f->indices);
  525. }
  526. #ifdef IXGBE_FCOE
  527. /*
  528. * FCoE can exist on the same rings as standard network traffic
  529. * however it is preferred to avoid that if possible. In order
  530. * to get the best performance we allocate as many FCoE queues
  531. * as we can and we place them at the end of the ring array to
  532. * avoid sharing queues with standard RSS on systems with 24 or
  533. * more CPUs.
  534. */
  535. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  536. struct net_device *dev = adapter->netdev;
  537. u16 fcoe_i;
  538. f = &adapter->ring_feature[RING_F_FCOE];
  539. /* merge FCoE queues with RSS queues */
  540. fcoe_i = min_t(u16, f->limit + rss_i, num_online_cpus());
  541. fcoe_i = min_t(u16, fcoe_i, dev->num_tx_queues);
  542. /* limit indices to rss_i if MSI-X is disabled */
  543. if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
  544. fcoe_i = rss_i;
  545. /* attempt to reserve some queues for just FCoE */
  546. f->indices = min_t(u16, fcoe_i, f->limit);
  547. f->offset = fcoe_i - f->indices;
  548. rss_i = max_t(u16, fcoe_i, rss_i);
  549. }
  550. #endif /* IXGBE_FCOE */
  551. adapter->num_rx_queues = rss_i;
  552. adapter->num_tx_queues = rss_i;
  553. return true;
  554. }
  555. /**
  556. * ixgbe_set_num_queues - Allocate queues for device, feature dependent
  557. * @adapter: board private structure to initialize
  558. *
  559. * This is the top level queue allocation routine. The order here is very
  560. * important, starting with the "most" number of features turned on at once,
  561. * and ending with the smallest set of features. This way large combinations
  562. * can be allocated if they're turned on, and smaller combinations are the
  563. * fallthrough conditions.
  564. *
  565. **/
  566. static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
  567. {
  568. /* Start with base case */
  569. adapter->num_rx_queues = 1;
  570. adapter->num_tx_queues = 1;
  571. adapter->num_rx_pools = adapter->num_rx_queues;
  572. adapter->num_rx_queues_per_pool = 1;
  573. #ifdef CONFIG_IXGBE_DCB
  574. if (ixgbe_set_dcb_sriov_queues(adapter))
  575. return;
  576. if (ixgbe_set_dcb_queues(adapter))
  577. return;
  578. #endif
  579. if (ixgbe_set_sriov_queues(adapter))
  580. return;
  581. ixgbe_set_rss_queues(adapter);
  582. }
  583. static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
  584. int vectors)
  585. {
  586. int err, vector_threshold;
  587. /* We'll want at least 2 (vector_threshold):
  588. * 1) TxQ[0] + RxQ[0] handler
  589. * 2) Other (Link Status Change, etc.)
  590. */
  591. vector_threshold = MIN_MSIX_COUNT;
  592. /*
  593. * The more we get, the more we will assign to Tx/Rx Cleanup
  594. * for the separate queues...where Rx Cleanup >= Tx Cleanup.
  595. * Right now, we simply care about how many we'll get; we'll
  596. * set them up later while requesting irq's.
  597. */
  598. while (vectors >= vector_threshold) {
  599. err = pci_enable_msix(adapter->pdev, adapter->msix_entries,
  600. vectors);
  601. if (!err) /* Success in acquiring all requested vectors. */
  602. break;
  603. else if (err < 0)
  604. vectors = 0; /* Nasty failure, quit now */
  605. else /* err == number of vectors we should try again with */
  606. vectors = err;
  607. }
  608. if (vectors < vector_threshold) {
  609. /* Can't allocate enough MSI-X interrupts? Oh well.
  610. * This just means we'll go with either a single MSI
  611. * vector or fall back to legacy interrupts.
  612. */
  613. netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev,
  614. "Unable to allocate MSI-X interrupts\n");
  615. adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED;
  616. kfree(adapter->msix_entries);
  617. adapter->msix_entries = NULL;
  618. } else {
  619. adapter->flags |= IXGBE_FLAG_MSIX_ENABLED; /* Woot! */
  620. /*
  621. * Adjust for only the vectors we'll use, which is minimum
  622. * of max_msix_q_vectors + NON_Q_VECTORS, or the number of
  623. * vectors we were allocated.
  624. */
  625. vectors -= NON_Q_VECTORS;
  626. adapter->num_q_vectors = min(vectors, adapter->max_q_vectors);
  627. }
  628. }
  629. static void ixgbe_add_ring(struct ixgbe_ring *ring,
  630. struct ixgbe_ring_container *head)
  631. {
  632. ring->next = head->ring;
  633. head->ring = ring;
  634. head->count++;
  635. }
  636. /**
  637. * ixgbe_alloc_q_vector - Allocate memory for a single interrupt vector
  638. * @adapter: board private structure to initialize
  639. * @v_count: q_vectors allocated on adapter, used for ring interleaving
  640. * @v_idx: index of vector in adapter struct
  641. * @txr_count: total number of Tx rings to allocate
  642. * @txr_idx: index of first Tx ring to allocate
  643. * @rxr_count: total number of Rx rings to allocate
  644. * @rxr_idx: index of first Rx ring to allocate
  645. *
  646. * We allocate one q_vector. If allocation fails we return -ENOMEM.
  647. **/
  648. static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,
  649. int v_count, int v_idx,
  650. int txr_count, int txr_idx,
  651. int rxr_count, int rxr_idx)
  652. {
  653. struct ixgbe_q_vector *q_vector;
  654. struct ixgbe_ring *ring;
  655. int node = -1;
  656. int cpu = -1;
  657. int ring_count, size;
  658. ring_count = txr_count + rxr_count;
  659. size = sizeof(struct ixgbe_q_vector) +
  660. (sizeof(struct ixgbe_ring) * ring_count);
  661. /* customize cpu for Flow Director mapping */
  662. if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) {
  663. if (cpu_online(v_idx)) {
  664. cpu = v_idx;
  665. node = cpu_to_node(cpu);
  666. }
  667. }
  668. /* allocate q_vector and rings */
  669. q_vector = kzalloc_node(size, GFP_KERNEL, node);
  670. if (!q_vector)
  671. q_vector = kzalloc(size, GFP_KERNEL);
  672. if (!q_vector)
  673. return -ENOMEM;
  674. /* setup affinity mask and node */
  675. if (cpu != -1)
  676. cpumask_set_cpu(cpu, &q_vector->affinity_mask);
  677. else
  678. cpumask_copy(&q_vector->affinity_mask, cpu_online_mask);
  679. q_vector->numa_node = node;
  680. /* initialize NAPI */
  681. netif_napi_add(adapter->netdev, &q_vector->napi,
  682. ixgbe_poll, 64);
  683. /* tie q_vector and adapter together */
  684. adapter->q_vector[v_idx] = q_vector;
  685. q_vector->adapter = adapter;
  686. q_vector->v_idx = v_idx;
  687. /* initialize work limits */
  688. q_vector->tx.work_limit = adapter->tx_work_limit;
  689. /* initialize pointer to rings */
  690. ring = q_vector->ring;
  691. while (txr_count) {
  692. /* assign generic ring traits */
  693. ring->dev = &adapter->pdev->dev;
  694. ring->netdev = adapter->netdev;
  695. /* configure backlink on ring */
  696. ring->q_vector = q_vector;
  697. /* update q_vector Tx values */
  698. ixgbe_add_ring(ring, &q_vector->tx);
  699. /* apply Tx specific ring traits */
  700. ring->count = adapter->tx_ring_count;
  701. ring->queue_index = txr_idx;
  702. /* assign ring to adapter */
  703. adapter->tx_ring[txr_idx] = ring;
  704. /* update count and index */
  705. txr_count--;
  706. txr_idx += v_count;
  707. /* push pointer to next ring */
  708. ring++;
  709. }
  710. while (rxr_count) {
  711. /* assign generic ring traits */
  712. ring->dev = &adapter->pdev->dev;
  713. ring->netdev = adapter->netdev;
  714. /* configure backlink on ring */
  715. ring->q_vector = q_vector;
  716. /* update q_vector Rx values */
  717. ixgbe_add_ring(ring, &q_vector->rx);
  718. /*
  719. * 82599 errata, UDP frames with a 0 checksum
  720. * can be marked as checksum errors.
  721. */
  722. if (adapter->hw.mac.type == ixgbe_mac_82599EB)
  723. set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state);
  724. #ifdef IXGBE_FCOE
  725. if (adapter->netdev->features & NETIF_F_FCOE_MTU) {
  726. struct ixgbe_ring_feature *f;
  727. f = &adapter->ring_feature[RING_F_FCOE];
  728. if ((rxr_idx >= f->offset) &&
  729. (rxr_idx < f->offset + f->indices))
  730. set_bit(__IXGBE_RX_FCOE, &ring->state);
  731. }
  732. #endif /* IXGBE_FCOE */
  733. /* apply Rx specific ring traits */
  734. ring->count = adapter->rx_ring_count;
  735. ring->queue_index = rxr_idx;
  736. /* assign ring to adapter */
  737. adapter->rx_ring[rxr_idx] = ring;
  738. /* update count and index */
  739. rxr_count--;
  740. rxr_idx += v_count;
  741. /* push pointer to next ring */
  742. ring++;
  743. }
  744. return 0;
  745. }
  746. /**
  747. * ixgbe_free_q_vector - Free memory allocated for specific interrupt vector
  748. * @adapter: board private structure to initialize
  749. * @v_idx: Index of vector to be freed
  750. *
  751. * This function frees the memory allocated to the q_vector. In addition if
  752. * NAPI is enabled it will delete any references to the NAPI struct prior
  753. * to freeing the q_vector.
  754. **/
  755. static void ixgbe_free_q_vector(struct ixgbe_adapter *adapter, int v_idx)
  756. {
  757. struct ixgbe_q_vector *q_vector = adapter->q_vector[v_idx];
  758. struct ixgbe_ring *ring;
  759. ixgbe_for_each_ring(ring, q_vector->tx)
  760. adapter->tx_ring[ring->queue_index] = NULL;
  761. ixgbe_for_each_ring(ring, q_vector->rx)
  762. adapter->rx_ring[ring->queue_index] = NULL;
  763. adapter->q_vector[v_idx] = NULL;
  764. netif_napi_del(&q_vector->napi);
  765. /*
  766. * ixgbe_get_stats64() might access the rings on this vector,
  767. * we must wait a grace period before freeing it.
  768. */
  769. kfree_rcu(q_vector, rcu);
  770. }
  771. /**
  772. * ixgbe_alloc_q_vectors - Allocate memory for interrupt vectors
  773. * @adapter: board private structure to initialize
  774. *
  775. * We allocate one q_vector per queue interrupt. If allocation fails we
  776. * return -ENOMEM.
  777. **/
  778. static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter)
  779. {
  780. int q_vectors = adapter->num_q_vectors;
  781. int rxr_remaining = adapter->num_rx_queues;
  782. int txr_remaining = adapter->num_tx_queues;
  783. int rxr_idx = 0, txr_idx = 0, v_idx = 0;
  784. int err;
  785. /* only one q_vector if MSI-X is disabled. */
  786. if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
  787. q_vectors = 1;
  788. if (q_vectors >= (rxr_remaining + txr_remaining)) {
  789. for (; rxr_remaining; v_idx++) {
  790. err = ixgbe_alloc_q_vector(adapter, q_vectors, v_idx,
  791. 0, 0, 1, rxr_idx);
  792. if (err)
  793. goto err_out;
  794. /* update counts and index */
  795. rxr_remaining--;
  796. rxr_idx++;
  797. }
  798. }
  799. for (; v_idx < q_vectors; v_idx++) {
  800. int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors - v_idx);
  801. int tqpv = DIV_ROUND_UP(txr_remaining, q_vectors - v_idx);
  802. err = ixgbe_alloc_q_vector(adapter, q_vectors, v_idx,
  803. tqpv, txr_idx,
  804. rqpv, rxr_idx);
  805. if (err)
  806. goto err_out;
  807. /* update counts and index */
  808. rxr_remaining -= rqpv;
  809. txr_remaining -= tqpv;
  810. rxr_idx++;
  811. txr_idx++;
  812. }
  813. return 0;
  814. err_out:
  815. adapter->num_tx_queues = 0;
  816. adapter->num_rx_queues = 0;
  817. adapter->num_q_vectors = 0;
  818. while (v_idx--)
  819. ixgbe_free_q_vector(adapter, v_idx);
  820. return -ENOMEM;
  821. }
  822. /**
  823. * ixgbe_free_q_vectors - Free memory allocated for interrupt vectors
  824. * @adapter: board private structure to initialize
  825. *
  826. * This function frees the memory allocated to the q_vectors. In addition if
  827. * NAPI is enabled it will delete any references to the NAPI struct prior
  828. * to freeing the q_vector.
  829. **/
  830. static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter)
  831. {
  832. int v_idx = adapter->num_q_vectors;
  833. adapter->num_tx_queues = 0;
  834. adapter->num_rx_queues = 0;
  835. adapter->num_q_vectors = 0;
  836. while (v_idx--)
  837. ixgbe_free_q_vector(adapter, v_idx);
  838. }
  839. static void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter)
  840. {
  841. if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
  842. adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED;
  843. pci_disable_msix(adapter->pdev);
  844. kfree(adapter->msix_entries);
  845. adapter->msix_entries = NULL;
  846. } else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) {
  847. adapter->flags &= ~IXGBE_FLAG_MSI_ENABLED;
  848. pci_disable_msi(adapter->pdev);
  849. }
  850. }
  851. /**
  852. * ixgbe_set_interrupt_capability - set MSI-X or MSI if supported
  853. * @adapter: board private structure to initialize
  854. *
  855. * Attempt to configure the interrupts using the best available
  856. * capabilities of the hardware and the kernel.
  857. **/
  858. static void ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter)
  859. {
  860. struct ixgbe_hw *hw = &adapter->hw;
  861. int vector, v_budget, err;
  862. /*
  863. * It's easy to be greedy for MSI-X vectors, but it really
  864. * doesn't do us much good if we have a lot more vectors
  865. * than CPU's. So let's be conservative and only ask for
  866. * (roughly) the same number of vectors as there are CPU's.
  867. * The default is to use pairs of vectors.
  868. */
  869. v_budget = max(adapter->num_rx_queues, adapter->num_tx_queues);
  870. v_budget = min_t(int, v_budget, num_online_cpus());
  871. v_budget += NON_Q_VECTORS;
  872. /*
  873. * At the same time, hardware can only support a maximum of
  874. * hw.mac->max_msix_vectors vectors. With features
  875. * such as RSS and VMDq, we can easily surpass the number of Rx and Tx
  876. * descriptor queues supported by our device. Thus, we cap it off in
  877. * those rare cases where the cpu count also exceeds our vector limit.
  878. */
  879. v_budget = min_t(int, v_budget, hw->mac.max_msix_vectors);
  880. /* A failure in MSI-X entry allocation isn't fatal, but it does
  881. * mean we disable MSI-X capabilities of the adapter. */
  882. adapter->msix_entries = kcalloc(v_budget,
  883. sizeof(struct msix_entry), GFP_KERNEL);
  884. if (adapter->msix_entries) {
  885. for (vector = 0; vector < v_budget; vector++)
  886. adapter->msix_entries[vector].entry = vector;
  887. ixgbe_acquire_msix_vectors(adapter, v_budget);
  888. if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED)
  889. return;
  890. }
  891. adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
  892. adapter->flags &= ~IXGBE_FLAG_RSS_ENABLED;
  893. if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) {
  894. e_err(probe,
  895. "ATR is not supported while multiple "
  896. "queues are disabled. Disabling Flow Director\n");
  897. }
  898. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  899. adapter->atr_sample_rate = 0;
  900. if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)
  901. ixgbe_disable_sriov(adapter);
  902. ixgbe_set_num_queues(adapter);
  903. adapter->num_q_vectors = 1;
  904. err = pci_enable_msi(adapter->pdev);
  905. if (err) {
  906. netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev,
  907. "Unable to allocate MSI interrupt, "
  908. "falling back to legacy. Error: %d\n", err);
  909. return;
  910. }
  911. adapter->flags |= IXGBE_FLAG_MSI_ENABLED;
  912. }
  913. /**
  914. * ixgbe_init_interrupt_scheme - Determine proper interrupt scheme
  915. * @adapter: board private structure to initialize
  916. *
  917. * We determine which interrupt scheme to use based on...
  918. * - Kernel support (MSI, MSI-X)
  919. * - which can be user-defined (via MODULE_PARAM)
  920. * - Hardware queue count (num_*_queues)
  921. * - defined by miscellaneous hardware support/features (RSS, etc.)
  922. **/
  923. int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter)
  924. {
  925. int err;
  926. /* Number of supported queues */
  927. ixgbe_set_num_queues(adapter);
  928. /* Set interrupt mode */
  929. ixgbe_set_interrupt_capability(adapter);
  930. err = ixgbe_alloc_q_vectors(adapter);
  931. if (err) {
  932. e_dev_err("Unable to allocate memory for queue vectors\n");
  933. goto err_alloc_q_vectors;
  934. }
  935. ixgbe_cache_ring_register(adapter);
  936. e_dev_info("Multiqueue %s: Rx Queue count = %u, Tx Queue count = %u\n",
  937. (adapter->num_rx_queues > 1) ? "Enabled" : "Disabled",
  938. adapter->num_rx_queues, adapter->num_tx_queues);
  939. set_bit(__IXGBE_DOWN, &adapter->state);
  940. return 0;
  941. err_alloc_q_vectors:
  942. ixgbe_reset_interrupt_capability(adapter);
  943. return err;
  944. }
  945. /**
  946. * ixgbe_clear_interrupt_scheme - Clear the current interrupt scheme settings
  947. * @adapter: board private structure to clear interrupt scheme on
  948. *
  949. * We go through and clear interrupt specific resources and reset the structure
  950. * to pre-load conditions
  951. **/
  952. void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter)
  953. {
  954. adapter->num_tx_queues = 0;
  955. adapter->num_rx_queues = 0;
  956. ixgbe_free_q_vectors(adapter);
  957. ixgbe_reset_interrupt_capability(adapter);
  958. }
  959. void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 vlan_macip_lens,
  960. u32 fcoe_sof_eof, u32 type_tucmd, u32 mss_l4len_idx)
  961. {
  962. struct ixgbe_adv_tx_context_desc *context_desc;
  963. u16 i = tx_ring->next_to_use;
  964. context_desc = IXGBE_TX_CTXTDESC(tx_ring, i);
  965. i++;
  966. tx_ring->next_to_use = (i < tx_ring->count) ? i : 0;
  967. /* set bits to identify this as an advanced context descriptor */
  968. type_tucmd |= IXGBE_TXD_CMD_DEXT | IXGBE_ADVTXD_DTYP_CTXT;
  969. context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens);
  970. context_desc->seqnum_seed = cpu_to_le32(fcoe_sof_eof);
  971. context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd);
  972. context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx);
  973. }