ixgbe_lib.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  1. /*******************************************************************************
  2. Intel 10 Gigabit PCI Express Linux driver
  3. Copyright(c) 1999 - 2013 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. for (i = 0; i < adapter->num_rx_queues; i++)
  232. adapter->rx_ring[i]->reg_idx = i;
  233. for (i = 0; i < adapter->num_tx_queues; i++)
  234. adapter->tx_ring[i]->reg_idx = i;
  235. return true;
  236. }
  237. /**
  238. * ixgbe_cache_ring_register - Descriptor ring to register mapping
  239. * @adapter: board private structure to initialize
  240. *
  241. * Once we know the feature-set enabled for the device, we'll cache
  242. * the register offset the descriptor ring is assigned to.
  243. *
  244. * Note, the order the various feature calls is important. It must start with
  245. * the "most" features enabled at the same time, then trickle down to the
  246. * least amount of features turned on at once.
  247. **/
  248. static void ixgbe_cache_ring_register(struct ixgbe_adapter *adapter)
  249. {
  250. /* start with default case */
  251. adapter->rx_ring[0]->reg_idx = 0;
  252. adapter->tx_ring[0]->reg_idx = 0;
  253. #ifdef CONFIG_IXGBE_DCB
  254. if (ixgbe_cache_ring_dcb_sriov(adapter))
  255. return;
  256. if (ixgbe_cache_ring_dcb(adapter))
  257. return;
  258. #endif
  259. if (ixgbe_cache_ring_sriov(adapter))
  260. return;
  261. ixgbe_cache_ring_rss(adapter);
  262. }
  263. #define IXGBE_RSS_16Q_MASK 0xF
  264. #define IXGBE_RSS_8Q_MASK 0x7
  265. #define IXGBE_RSS_4Q_MASK 0x3
  266. #define IXGBE_RSS_2Q_MASK 0x1
  267. #define IXGBE_RSS_DISABLED_MASK 0x0
  268. #ifdef CONFIG_IXGBE_DCB
  269. /**
  270. * ixgbe_set_dcb_sriov_queues: Allocate queues for SR-IOV devices w/ DCB
  271. * @adapter: board private structure to initialize
  272. *
  273. * When SR-IOV (Single Root IO Virtualiztion) is enabled, allocate queues
  274. * and VM pools where appropriate. Also assign queues based on DCB
  275. * priorities and map accordingly..
  276. *
  277. **/
  278. static bool ixgbe_set_dcb_sriov_queues(struct ixgbe_adapter *adapter)
  279. {
  280. int i;
  281. u16 vmdq_i = adapter->ring_feature[RING_F_VMDQ].limit;
  282. u16 vmdq_m = 0;
  283. #ifdef IXGBE_FCOE
  284. u16 fcoe_i = 0;
  285. #endif
  286. u8 tcs = netdev_get_num_tc(adapter->netdev);
  287. /* verify we have DCB queueing enabled before proceeding */
  288. if (tcs <= 1)
  289. return false;
  290. /* verify we have VMDq enabled before proceeding */
  291. if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
  292. return false;
  293. /* Add starting offset to total pool count */
  294. vmdq_i += adapter->ring_feature[RING_F_VMDQ].offset;
  295. /* 16 pools w/ 8 TC per pool */
  296. if (tcs > 4) {
  297. vmdq_i = min_t(u16, vmdq_i, 16);
  298. vmdq_m = IXGBE_82599_VMDQ_8Q_MASK;
  299. /* 32 pools w/ 4 TC per pool */
  300. } else {
  301. vmdq_i = min_t(u16, vmdq_i, 32);
  302. vmdq_m = IXGBE_82599_VMDQ_4Q_MASK;
  303. }
  304. #ifdef IXGBE_FCOE
  305. /* queues in the remaining pools are available for FCoE */
  306. fcoe_i = (128 / __ALIGN_MASK(1, ~vmdq_m)) - vmdq_i;
  307. #endif
  308. /* remove the starting offset from the pool count */
  309. vmdq_i -= adapter->ring_feature[RING_F_VMDQ].offset;
  310. /* save features for later use */
  311. adapter->ring_feature[RING_F_VMDQ].indices = vmdq_i;
  312. adapter->ring_feature[RING_F_VMDQ].mask = vmdq_m;
  313. /*
  314. * We do not support DCB, VMDq, and RSS all simultaneously
  315. * so we will disable RSS since it is the lowest priority
  316. */
  317. adapter->ring_feature[RING_F_RSS].indices = 1;
  318. adapter->ring_feature[RING_F_RSS].mask = IXGBE_RSS_DISABLED_MASK;
  319. /* disable ATR as it is not supported when VMDq is enabled */
  320. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  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, fcoe->limit);
  331. if (fcoe_i) {
  332. /* alloc queues for FCoE separately */
  333. fcoe->indices = fcoe_i;
  334. fcoe->offset = vmdq_i * tcs;
  335. /* add queues to adapter */
  336. adapter->num_tx_queues += fcoe_i;
  337. adapter->num_rx_queues += fcoe_i;
  338. } else if (tcs > 1) {
  339. /* use queue belonging to FcoE TC */
  340. fcoe->indices = 1;
  341. fcoe->offset = ixgbe_fcoe_get_tc(adapter);
  342. } else {
  343. adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED;
  344. fcoe->indices = 0;
  345. fcoe->offset = 0;
  346. }
  347. }
  348. #endif /* IXGBE_FCOE */
  349. /* configure TC to queue mapping */
  350. for (i = 0; i < tcs; i++)
  351. netdev_set_tc_queue(adapter->netdev, i, 1, i);
  352. return true;
  353. }
  354. static bool ixgbe_set_dcb_queues(struct ixgbe_adapter *adapter)
  355. {
  356. struct net_device *dev = adapter->netdev;
  357. struct ixgbe_ring_feature *f;
  358. int rss_i, rss_m, i;
  359. int tcs;
  360. /* Map queue offset and counts onto allocated tx queues */
  361. tcs = netdev_get_num_tc(dev);
  362. /* verify we have DCB queueing enabled before proceeding */
  363. if (tcs <= 1)
  364. return false;
  365. /* determine the upper limit for our current DCB mode */
  366. rss_i = dev->num_tx_queues / tcs;
  367. if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
  368. /* 8 TC w/ 4 queues per TC */
  369. rss_i = min_t(u16, rss_i, 4);
  370. rss_m = IXGBE_RSS_4Q_MASK;
  371. } else if (tcs > 4) {
  372. /* 8 TC w/ 8 queues per TC */
  373. rss_i = min_t(u16, rss_i, 8);
  374. rss_m = IXGBE_RSS_8Q_MASK;
  375. } else {
  376. /* 4 TC w/ 16 queues per TC */
  377. rss_i = min_t(u16, rss_i, 16);
  378. rss_m = IXGBE_RSS_16Q_MASK;
  379. }
  380. /* set RSS mask and indices */
  381. f = &adapter->ring_feature[RING_F_RSS];
  382. rss_i = min_t(int, rss_i, f->limit);
  383. f->indices = rss_i;
  384. f->mask = rss_m;
  385. /* disable ATR as it is not supported when multiple TCs are enabled */
  386. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  387. #ifdef IXGBE_FCOE
  388. /* FCoE enabled queues require special configuration indexed
  389. * by feature specific indices and offset. Here we map FCoE
  390. * indices onto the DCB queue pairs allowing FCoE to own
  391. * configuration later.
  392. */
  393. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  394. u8 tc = ixgbe_fcoe_get_tc(adapter);
  395. f = &adapter->ring_feature[RING_F_FCOE];
  396. f->indices = min_t(u16, rss_i, f->limit);
  397. f->offset = rss_i * tc;
  398. }
  399. #endif /* IXGBE_FCOE */
  400. for (i = 0; i < tcs; i++)
  401. netdev_set_tc_queue(dev, i, rss_i, rss_i * i);
  402. adapter->num_tx_queues = rss_i * tcs;
  403. adapter->num_rx_queues = rss_i * tcs;
  404. return true;
  405. }
  406. #endif
  407. /**
  408. * ixgbe_set_sriov_queues - Allocate queues for SR-IOV devices
  409. * @adapter: board private structure to initialize
  410. *
  411. * When SR-IOV (Single Root IO Virtualiztion) is enabled, allocate queues
  412. * and VM pools where appropriate. If RSS is available, then also try and
  413. * enable RSS and map accordingly.
  414. *
  415. **/
  416. static bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)
  417. {
  418. u16 vmdq_i = adapter->ring_feature[RING_F_VMDQ].limit;
  419. u16 vmdq_m = 0;
  420. u16 rss_i = adapter->ring_feature[RING_F_RSS].limit;
  421. u16 rss_m = IXGBE_RSS_DISABLED_MASK;
  422. #ifdef IXGBE_FCOE
  423. u16 fcoe_i = 0;
  424. #endif
  425. /* only proceed if SR-IOV is enabled */
  426. if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
  427. return false;
  428. /* Add starting offset to total pool count */
  429. vmdq_i += adapter->ring_feature[RING_F_VMDQ].offset;
  430. /* double check we are limited to maximum pools */
  431. vmdq_i = min_t(u16, IXGBE_MAX_VMDQ_INDICES, vmdq_i);
  432. /* 64 pool mode with 2 queues per pool */
  433. if ((vmdq_i > 32) || (rss_i < 4)) {
  434. vmdq_m = IXGBE_82599_VMDQ_2Q_MASK;
  435. rss_m = IXGBE_RSS_2Q_MASK;
  436. rss_i = min_t(u16, rss_i, 2);
  437. /* 32 pool mode with 4 queues per pool */
  438. } else {
  439. vmdq_m = IXGBE_82599_VMDQ_4Q_MASK;
  440. rss_m = IXGBE_RSS_4Q_MASK;
  441. rss_i = 4;
  442. }
  443. #ifdef IXGBE_FCOE
  444. /* queues in the remaining pools are available for FCoE */
  445. fcoe_i = 128 - (vmdq_i * __ALIGN_MASK(1, ~vmdq_m));
  446. #endif
  447. /* remove the starting offset from the pool count */
  448. vmdq_i -= adapter->ring_feature[RING_F_VMDQ].offset;
  449. /* save features for later use */
  450. adapter->ring_feature[RING_F_VMDQ].indices = vmdq_i;
  451. adapter->ring_feature[RING_F_VMDQ].mask = vmdq_m;
  452. /* limit RSS based on user input and save for later use */
  453. adapter->ring_feature[RING_F_RSS].indices = rss_i;
  454. adapter->ring_feature[RING_F_RSS].mask = rss_m;
  455. adapter->num_rx_pools = vmdq_i;
  456. adapter->num_rx_queues_per_pool = rss_i;
  457. adapter->num_rx_queues = vmdq_i * rss_i;
  458. adapter->num_tx_queues = vmdq_i * rss_i;
  459. /* disable ATR as it is not supported when VMDq is enabled */
  460. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  461. #ifdef IXGBE_FCOE
  462. /*
  463. * FCoE can use rings from adjacent buffers to allow RSS
  464. * like behavior. To account for this we need to add the
  465. * FCoE indices to the total ring count.
  466. */
  467. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  468. struct ixgbe_ring_feature *fcoe;
  469. fcoe = &adapter->ring_feature[RING_F_FCOE];
  470. /* limit ourselves based on feature limits */
  471. fcoe_i = min_t(u16, fcoe_i, fcoe->limit);
  472. if (vmdq_i > 1 && fcoe_i) {
  473. /* alloc queues for FCoE separately */
  474. fcoe->indices = fcoe_i;
  475. fcoe->offset = vmdq_i * rss_i;
  476. } else {
  477. /* merge FCoE queues with RSS queues */
  478. fcoe_i = min_t(u16, fcoe_i + rss_i, num_online_cpus());
  479. /* limit indices to rss_i if MSI-X is disabled */
  480. if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
  481. fcoe_i = rss_i;
  482. /* attempt to reserve some queues for just FCoE */
  483. fcoe->indices = min_t(u16, fcoe_i, fcoe->limit);
  484. fcoe->offset = fcoe_i - fcoe->indices;
  485. fcoe_i -= rss_i;
  486. }
  487. /* add queues to adapter */
  488. adapter->num_tx_queues += fcoe_i;
  489. adapter->num_rx_queues += fcoe_i;
  490. }
  491. #endif
  492. return true;
  493. }
  494. /**
  495. * ixgbe_set_rss_queues - Allocate queues for RSS
  496. * @adapter: board private structure to initialize
  497. *
  498. * This is our "base" multiqueue mode. RSS (Receive Side Scaling) will try
  499. * to allocate one Rx queue per CPU, and if available, one Tx queue per CPU.
  500. *
  501. **/
  502. static bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter)
  503. {
  504. struct ixgbe_ring_feature *f;
  505. u16 rss_i;
  506. /* set mask for 16 queue limit of RSS */
  507. f = &adapter->ring_feature[RING_F_RSS];
  508. rss_i = f->limit;
  509. f->indices = rss_i;
  510. f->mask = IXGBE_RSS_16Q_MASK;
  511. /* disable ATR by default, it will be configured below */
  512. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  513. /*
  514. * Use Flow Director in addition to RSS to ensure the best
  515. * distribution of flows across cores, even when an FDIR flow
  516. * isn't matched.
  517. */
  518. if (rss_i > 1 && adapter->atr_sample_rate) {
  519. f = &adapter->ring_feature[RING_F_FDIR];
  520. rss_i = f->indices = f->limit;
  521. if (!(adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE))
  522. adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE;
  523. }
  524. #ifdef IXGBE_FCOE
  525. /*
  526. * FCoE can exist on the same rings as standard network traffic
  527. * however it is preferred to avoid that if possible. In order
  528. * to get the best performance we allocate as many FCoE queues
  529. * as we can and we place them at the end of the ring array to
  530. * avoid sharing queues with standard RSS on systems with 24 or
  531. * more CPUs.
  532. */
  533. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  534. struct net_device *dev = adapter->netdev;
  535. u16 fcoe_i;
  536. f = &adapter->ring_feature[RING_F_FCOE];
  537. /* merge FCoE queues with RSS queues */
  538. fcoe_i = min_t(u16, f->limit + rss_i, num_online_cpus());
  539. fcoe_i = min_t(u16, fcoe_i, dev->num_tx_queues);
  540. /* limit indices to rss_i if MSI-X is disabled */
  541. if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
  542. fcoe_i = rss_i;
  543. /* attempt to reserve some queues for just FCoE */
  544. f->indices = min_t(u16, fcoe_i, f->limit);
  545. f->offset = fcoe_i - f->indices;
  546. rss_i = max_t(u16, fcoe_i, rss_i);
  547. }
  548. #endif /* IXGBE_FCOE */
  549. adapter->num_rx_queues = rss_i;
  550. adapter->num_tx_queues = rss_i;
  551. return true;
  552. }
  553. /**
  554. * ixgbe_set_num_queues - Allocate queues for device, feature dependent
  555. * @adapter: board private structure to initialize
  556. *
  557. * This is the top level queue allocation routine. The order here is very
  558. * important, starting with the "most" number of features turned on at once,
  559. * and ending with the smallest set of features. This way large combinations
  560. * can be allocated if they're turned on, and smaller combinations are the
  561. * fallthrough conditions.
  562. *
  563. **/
  564. static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
  565. {
  566. /* Start with base case */
  567. adapter->num_rx_queues = 1;
  568. adapter->num_tx_queues = 1;
  569. adapter->num_rx_pools = adapter->num_rx_queues;
  570. adapter->num_rx_queues_per_pool = 1;
  571. #ifdef CONFIG_IXGBE_DCB
  572. if (ixgbe_set_dcb_sriov_queues(adapter))
  573. return;
  574. if (ixgbe_set_dcb_queues(adapter))
  575. return;
  576. #endif
  577. if (ixgbe_set_sriov_queues(adapter))
  578. return;
  579. ixgbe_set_rss_queues(adapter);
  580. }
  581. static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
  582. int vectors)
  583. {
  584. int err, vector_threshold;
  585. /* We'll want at least 2 (vector_threshold):
  586. * 1) TxQ[0] + RxQ[0] handler
  587. * 2) Other (Link Status Change, etc.)
  588. */
  589. vector_threshold = MIN_MSIX_COUNT;
  590. /*
  591. * The more we get, the more we will assign to Tx/Rx Cleanup
  592. * for the separate queues...where Rx Cleanup >= Tx Cleanup.
  593. * Right now, we simply care about how many we'll get; we'll
  594. * set them up later while requesting irq's.
  595. */
  596. while (vectors >= vector_threshold) {
  597. err = pci_enable_msix(adapter->pdev, adapter->msix_entries,
  598. vectors);
  599. if (!err) /* Success in acquiring all requested vectors. */
  600. break;
  601. else if (err < 0)
  602. vectors = 0; /* Nasty failure, quit now */
  603. else /* err == number of vectors we should try again with */
  604. vectors = err;
  605. }
  606. if (vectors < vector_threshold) {
  607. /* Can't allocate enough MSI-X interrupts? Oh well.
  608. * This just means we'll go with either a single MSI
  609. * vector or fall back to legacy interrupts.
  610. */
  611. netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev,
  612. "Unable to allocate MSI-X interrupts\n");
  613. adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED;
  614. kfree(adapter->msix_entries);
  615. adapter->msix_entries = NULL;
  616. } else {
  617. adapter->flags |= IXGBE_FLAG_MSIX_ENABLED; /* Woot! */
  618. /*
  619. * Adjust for only the vectors we'll use, which is minimum
  620. * of max_msix_q_vectors + NON_Q_VECTORS, or the number of
  621. * vectors we were allocated.
  622. */
  623. vectors -= NON_Q_VECTORS;
  624. adapter->num_q_vectors = min(vectors, adapter->max_q_vectors);
  625. }
  626. }
  627. static void ixgbe_add_ring(struct ixgbe_ring *ring,
  628. struct ixgbe_ring_container *head)
  629. {
  630. ring->next = head->ring;
  631. head->ring = ring;
  632. head->count++;
  633. }
  634. /**
  635. * ixgbe_alloc_q_vector - Allocate memory for a single interrupt vector
  636. * @adapter: board private structure to initialize
  637. * @v_count: q_vectors allocated on adapter, used for ring interleaving
  638. * @v_idx: index of vector in adapter struct
  639. * @txr_count: total number of Tx rings to allocate
  640. * @txr_idx: index of first Tx ring to allocate
  641. * @rxr_count: total number of Rx rings to allocate
  642. * @rxr_idx: index of first Rx ring to allocate
  643. *
  644. * We allocate one q_vector. If allocation fails we return -ENOMEM.
  645. **/
  646. static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,
  647. int v_count, int v_idx,
  648. int txr_count, int txr_idx,
  649. int rxr_count, int rxr_idx)
  650. {
  651. struct ixgbe_q_vector *q_vector;
  652. struct ixgbe_ring *ring;
  653. int node = NUMA_NO_NODE;
  654. int cpu = -1;
  655. int ring_count, size;
  656. u8 tcs = netdev_get_num_tc(adapter->netdev);
  657. ring_count = txr_count + rxr_count;
  658. size = sizeof(struct ixgbe_q_vector) +
  659. (sizeof(struct ixgbe_ring) * ring_count);
  660. /* customize cpu for Flow Director mapping */
  661. if ((tcs <= 1) && !(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) {
  662. u16 rss_i = adapter->ring_feature[RING_F_RSS].indices;
  663. if (rss_i > 1 && adapter->atr_sample_rate) {
  664. if (cpu_online(v_idx)) {
  665. cpu = v_idx;
  666. node = cpu_to_node(cpu);
  667. }
  668. }
  669. }
  670. /* allocate q_vector and rings */
  671. q_vector = kzalloc_node(size, GFP_KERNEL, node);
  672. if (!q_vector)
  673. q_vector = kzalloc(size, GFP_KERNEL);
  674. if (!q_vector)
  675. return -ENOMEM;
  676. /* setup affinity mask and node */
  677. if (cpu != -1)
  678. cpumask_set_cpu(cpu, &q_vector->affinity_mask);
  679. q_vector->numa_node = node;
  680. #ifdef CONFIG_IXGBE_DCA
  681. /* initialize CPU for DCA */
  682. q_vector->cpu = -1;
  683. #endif
  684. /* initialize NAPI */
  685. netif_napi_add(adapter->netdev, &q_vector->napi,
  686. ixgbe_poll, 64);
  687. /* tie q_vector and adapter together */
  688. adapter->q_vector[v_idx] = q_vector;
  689. q_vector->adapter = adapter;
  690. q_vector->v_idx = v_idx;
  691. /* initialize work limits */
  692. q_vector->tx.work_limit = adapter->tx_work_limit;
  693. /* initialize pointer to rings */
  694. ring = q_vector->ring;
  695. /* intialize ITR */
  696. if (txr_count && !rxr_count) {
  697. /* tx only vector */
  698. if (adapter->tx_itr_setting == 1)
  699. q_vector->itr = IXGBE_10K_ITR;
  700. else
  701. q_vector->itr = adapter->tx_itr_setting;
  702. } else {
  703. /* rx or rx/tx vector */
  704. if (adapter->rx_itr_setting == 1)
  705. q_vector->itr = IXGBE_20K_ITR;
  706. else
  707. q_vector->itr = adapter->rx_itr_setting;
  708. }
  709. while (txr_count) {
  710. /* assign generic ring traits */
  711. ring->dev = &adapter->pdev->dev;
  712. ring->netdev = adapter->netdev;
  713. /* configure backlink on ring */
  714. ring->q_vector = q_vector;
  715. /* update q_vector Tx values */
  716. ixgbe_add_ring(ring, &q_vector->tx);
  717. /* apply Tx specific ring traits */
  718. ring->count = adapter->tx_ring_count;
  719. ring->queue_index = txr_idx;
  720. /* assign ring to adapter */
  721. adapter->tx_ring[txr_idx] = ring;
  722. /* update count and index */
  723. txr_count--;
  724. txr_idx += v_count;
  725. /* push pointer to next ring */
  726. ring++;
  727. }
  728. while (rxr_count) {
  729. /* assign generic ring traits */
  730. ring->dev = &adapter->pdev->dev;
  731. ring->netdev = adapter->netdev;
  732. /* configure backlink on ring */
  733. ring->q_vector = q_vector;
  734. /* update q_vector Rx values */
  735. ixgbe_add_ring(ring, &q_vector->rx);
  736. /*
  737. * 82599 errata, UDP frames with a 0 checksum
  738. * can be marked as checksum errors.
  739. */
  740. if (adapter->hw.mac.type == ixgbe_mac_82599EB)
  741. set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state);
  742. #ifdef IXGBE_FCOE
  743. if (adapter->netdev->features & NETIF_F_FCOE_MTU) {
  744. struct ixgbe_ring_feature *f;
  745. f = &adapter->ring_feature[RING_F_FCOE];
  746. if ((rxr_idx >= f->offset) &&
  747. (rxr_idx < f->offset + f->indices))
  748. set_bit(__IXGBE_RX_FCOE, &ring->state);
  749. }
  750. #endif /* IXGBE_FCOE */
  751. /* apply Rx specific ring traits */
  752. ring->count = adapter->rx_ring_count;
  753. ring->queue_index = rxr_idx;
  754. /* assign ring to adapter */
  755. adapter->rx_ring[rxr_idx] = ring;
  756. /* update count and index */
  757. rxr_count--;
  758. rxr_idx += v_count;
  759. /* push pointer to next ring */
  760. ring++;
  761. }
  762. return 0;
  763. }
  764. /**
  765. * ixgbe_free_q_vector - Free memory allocated for specific interrupt vector
  766. * @adapter: board private structure to initialize
  767. * @v_idx: Index of vector to be freed
  768. *
  769. * This function frees the memory allocated to the q_vector. In addition if
  770. * NAPI is enabled it will delete any references to the NAPI struct prior
  771. * to freeing the q_vector.
  772. **/
  773. static void ixgbe_free_q_vector(struct ixgbe_adapter *adapter, int v_idx)
  774. {
  775. struct ixgbe_q_vector *q_vector = adapter->q_vector[v_idx];
  776. struct ixgbe_ring *ring;
  777. ixgbe_for_each_ring(ring, q_vector->tx)
  778. adapter->tx_ring[ring->queue_index] = NULL;
  779. ixgbe_for_each_ring(ring, q_vector->rx)
  780. adapter->rx_ring[ring->queue_index] = NULL;
  781. adapter->q_vector[v_idx] = NULL;
  782. netif_napi_del(&q_vector->napi);
  783. /*
  784. * ixgbe_get_stats64() might access the rings on this vector,
  785. * we must wait a grace period before freeing it.
  786. */
  787. kfree_rcu(q_vector, rcu);
  788. }
  789. /**
  790. * ixgbe_alloc_q_vectors - Allocate memory for interrupt vectors
  791. * @adapter: board private structure to initialize
  792. *
  793. * We allocate one q_vector per queue interrupt. If allocation fails we
  794. * return -ENOMEM.
  795. **/
  796. static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter)
  797. {
  798. int q_vectors = adapter->num_q_vectors;
  799. int rxr_remaining = adapter->num_rx_queues;
  800. int txr_remaining = adapter->num_tx_queues;
  801. int rxr_idx = 0, txr_idx = 0, v_idx = 0;
  802. int err;
  803. /* only one q_vector if MSI-X is disabled. */
  804. if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
  805. q_vectors = 1;
  806. if (q_vectors >= (rxr_remaining + txr_remaining)) {
  807. for (; rxr_remaining; v_idx++) {
  808. err = ixgbe_alloc_q_vector(adapter, q_vectors, v_idx,
  809. 0, 0, 1, rxr_idx);
  810. if (err)
  811. goto err_out;
  812. /* update counts and index */
  813. rxr_remaining--;
  814. rxr_idx++;
  815. }
  816. }
  817. for (; v_idx < q_vectors; v_idx++) {
  818. int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors - v_idx);
  819. int tqpv = DIV_ROUND_UP(txr_remaining, q_vectors - v_idx);
  820. err = ixgbe_alloc_q_vector(adapter, q_vectors, v_idx,
  821. tqpv, txr_idx,
  822. rqpv, rxr_idx);
  823. if (err)
  824. goto err_out;
  825. /* update counts and index */
  826. rxr_remaining -= rqpv;
  827. txr_remaining -= tqpv;
  828. rxr_idx++;
  829. txr_idx++;
  830. }
  831. return 0;
  832. err_out:
  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. return -ENOMEM;
  839. }
  840. /**
  841. * ixgbe_free_q_vectors - Free memory allocated for interrupt vectors
  842. * @adapter: board private structure to initialize
  843. *
  844. * This function frees the memory allocated to the q_vectors. In addition if
  845. * NAPI is enabled it will delete any references to the NAPI struct prior
  846. * to freeing the q_vector.
  847. **/
  848. static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter)
  849. {
  850. int v_idx = adapter->num_q_vectors;
  851. adapter->num_tx_queues = 0;
  852. adapter->num_rx_queues = 0;
  853. adapter->num_q_vectors = 0;
  854. while (v_idx--)
  855. ixgbe_free_q_vector(adapter, v_idx);
  856. }
  857. static void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter)
  858. {
  859. if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
  860. adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED;
  861. pci_disable_msix(adapter->pdev);
  862. kfree(adapter->msix_entries);
  863. adapter->msix_entries = NULL;
  864. } else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) {
  865. adapter->flags &= ~IXGBE_FLAG_MSI_ENABLED;
  866. pci_disable_msi(adapter->pdev);
  867. }
  868. }
  869. /**
  870. * ixgbe_set_interrupt_capability - set MSI-X or MSI if supported
  871. * @adapter: board private structure to initialize
  872. *
  873. * Attempt to configure the interrupts using the best available
  874. * capabilities of the hardware and the kernel.
  875. **/
  876. static void ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter)
  877. {
  878. struct ixgbe_hw *hw = &adapter->hw;
  879. int vector, v_budget, err;
  880. /*
  881. * It's easy to be greedy for MSI-X vectors, but it really
  882. * doesn't do us much good if we have a lot more vectors
  883. * than CPU's. So let's be conservative and only ask for
  884. * (roughly) the same number of vectors as there are CPU's.
  885. * The default is to use pairs of vectors.
  886. */
  887. v_budget = max(adapter->num_rx_queues, adapter->num_tx_queues);
  888. v_budget = min_t(int, v_budget, num_online_cpus());
  889. v_budget += NON_Q_VECTORS;
  890. /*
  891. * At the same time, hardware can only support a maximum of
  892. * hw.mac->max_msix_vectors vectors. With features
  893. * such as RSS and VMDq, we can easily surpass the number of Rx and Tx
  894. * descriptor queues supported by our device. Thus, we cap it off in
  895. * those rare cases where the cpu count also exceeds our vector limit.
  896. */
  897. v_budget = min_t(int, v_budget, hw->mac.max_msix_vectors);
  898. /* A failure in MSI-X entry allocation isn't fatal, but it does
  899. * mean we disable MSI-X capabilities of the adapter. */
  900. adapter->msix_entries = kcalloc(v_budget,
  901. sizeof(struct msix_entry), GFP_KERNEL);
  902. if (adapter->msix_entries) {
  903. for (vector = 0; vector < v_budget; vector++)
  904. adapter->msix_entries[vector].entry = vector;
  905. ixgbe_acquire_msix_vectors(adapter, v_budget);
  906. if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED)
  907. return;
  908. }
  909. /* disable DCB if number of TCs exceeds 1 */
  910. if (netdev_get_num_tc(adapter->netdev) > 1) {
  911. e_err(probe, "num TCs exceeds number of queues - disabling DCB\n");
  912. netdev_reset_tc(adapter->netdev);
  913. if (adapter->hw.mac.type == ixgbe_mac_82598EB)
  914. adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
  915. adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
  916. adapter->temp_dcb_cfg.pfc_mode_enable = false;
  917. adapter->dcb_cfg.pfc_mode_enable = false;
  918. }
  919. adapter->dcb_cfg.num_tcs.pg_tcs = 1;
  920. adapter->dcb_cfg.num_tcs.pfc_tcs = 1;
  921. /* disable SR-IOV */
  922. ixgbe_disable_sriov(adapter);
  923. /* disable RSS */
  924. adapter->ring_feature[RING_F_RSS].limit = 1;
  925. ixgbe_set_num_queues(adapter);
  926. adapter->num_q_vectors = 1;
  927. err = pci_enable_msi(adapter->pdev);
  928. if (err) {
  929. netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev,
  930. "Unable to allocate MSI interrupt, "
  931. "falling back to legacy. Error: %d\n", err);
  932. return;
  933. }
  934. adapter->flags |= IXGBE_FLAG_MSI_ENABLED;
  935. }
  936. /**
  937. * ixgbe_init_interrupt_scheme - Determine proper interrupt scheme
  938. * @adapter: board private structure to initialize
  939. *
  940. * We determine which interrupt scheme to use based on...
  941. * - Kernel support (MSI, MSI-X)
  942. * - which can be user-defined (via MODULE_PARAM)
  943. * - Hardware queue count (num_*_queues)
  944. * - defined by miscellaneous hardware support/features (RSS, etc.)
  945. **/
  946. int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter)
  947. {
  948. int err;
  949. /* Number of supported queues */
  950. ixgbe_set_num_queues(adapter);
  951. /* Set interrupt mode */
  952. ixgbe_set_interrupt_capability(adapter);
  953. err = ixgbe_alloc_q_vectors(adapter);
  954. if (err) {
  955. e_dev_err("Unable to allocate memory for queue vectors\n");
  956. goto err_alloc_q_vectors;
  957. }
  958. ixgbe_cache_ring_register(adapter);
  959. e_dev_info("Multiqueue %s: Rx Queue count = %u, Tx Queue count = %u\n",
  960. (adapter->num_rx_queues > 1) ? "Enabled" : "Disabled",
  961. adapter->num_rx_queues, adapter->num_tx_queues);
  962. set_bit(__IXGBE_DOWN, &adapter->state);
  963. return 0;
  964. err_alloc_q_vectors:
  965. ixgbe_reset_interrupt_capability(adapter);
  966. return err;
  967. }
  968. /**
  969. * ixgbe_clear_interrupt_scheme - Clear the current interrupt scheme settings
  970. * @adapter: board private structure to clear interrupt scheme on
  971. *
  972. * We go through and clear interrupt specific resources and reset the structure
  973. * to pre-load conditions
  974. **/
  975. void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter)
  976. {
  977. adapter->num_tx_queues = 0;
  978. adapter->num_rx_queues = 0;
  979. ixgbe_free_q_vectors(adapter);
  980. ixgbe_reset_interrupt_capability(adapter);
  981. }
  982. void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 vlan_macip_lens,
  983. u32 fcoe_sof_eof, u32 type_tucmd, u32 mss_l4len_idx)
  984. {
  985. struct ixgbe_adv_tx_context_desc *context_desc;
  986. u16 i = tx_ring->next_to_use;
  987. context_desc = IXGBE_TX_CTXTDESC(tx_ring, i);
  988. i++;
  989. tx_ring->next_to_use = (i < tx_ring->count) ? i : 0;
  990. /* set bits to identify this as an advanced context descriptor */
  991. type_tucmd |= IXGBE_TXD_CMD_DEXT | IXGBE_ADVTXD_DTYP_CTXT;
  992. context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens);
  993. context_desc->seqnum_seed = cpu_to_le32(fcoe_sof_eof);
  994. context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd);
  995. context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx);
  996. }