ixgbe_lib.c 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  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. 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, 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. /* disable ATR as it is not supported when multiple TCs are enabled */
  387. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  388. #ifdef IXGBE_FCOE
  389. /* FCoE enabled queues require special configuration indexed
  390. * by feature specific indices and offset. Here we map FCoE
  391. * indices onto the DCB queue pairs allowing FCoE to own
  392. * configuration later.
  393. */
  394. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  395. u8 tc = ixgbe_fcoe_get_tc(adapter);
  396. f = &adapter->ring_feature[RING_F_FCOE];
  397. f->indices = min_t(u16, rss_i, f->limit);
  398. f->offset = rss_i * tc;
  399. }
  400. #endif /* IXGBE_FCOE */
  401. for (i = 0; i < tcs; i++)
  402. netdev_set_tc_queue(dev, i, rss_i, rss_i * i);
  403. adapter->num_tx_queues = rss_i * tcs;
  404. adapter->num_rx_queues = rss_i * tcs;
  405. return true;
  406. }
  407. #endif
  408. /**
  409. * ixgbe_set_sriov_queues - Allocate queues for SR-IOV devices
  410. * @adapter: board private structure to initialize
  411. *
  412. * When SR-IOV (Single Root IO Virtualiztion) is enabled, allocate queues
  413. * and VM pools where appropriate. If RSS is available, then also try and
  414. * enable RSS and map accordingly.
  415. *
  416. **/
  417. static bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)
  418. {
  419. u16 vmdq_i = adapter->ring_feature[RING_F_VMDQ].limit;
  420. u16 vmdq_m = 0;
  421. u16 rss_i = adapter->ring_feature[RING_F_RSS].limit;
  422. u16 rss_m = IXGBE_RSS_DISABLED_MASK;
  423. #ifdef IXGBE_FCOE
  424. u16 fcoe_i = 0;
  425. #endif
  426. /* only proceed if SR-IOV is enabled */
  427. if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
  428. return false;
  429. /* Add starting offset to total pool count */
  430. vmdq_i += adapter->ring_feature[RING_F_VMDQ].offset;
  431. /* double check we are limited to maximum pools */
  432. vmdq_i = min_t(u16, IXGBE_MAX_VMDQ_INDICES, vmdq_i);
  433. /* 64 pool mode with 2 queues per pool */
  434. if ((vmdq_i > 32) || (rss_i < 4)) {
  435. vmdq_m = IXGBE_82599_VMDQ_2Q_MASK;
  436. rss_m = IXGBE_RSS_2Q_MASK;
  437. rss_i = min_t(u16, rss_i, 2);
  438. /* 32 pool mode with 4 queues per pool */
  439. } else {
  440. vmdq_m = IXGBE_82599_VMDQ_4Q_MASK;
  441. rss_m = IXGBE_RSS_4Q_MASK;
  442. rss_i = 4;
  443. }
  444. #ifdef IXGBE_FCOE
  445. /* queues in the remaining pools are available for FCoE */
  446. fcoe_i = 128 - (vmdq_i * __ALIGN_MASK(1, ~vmdq_m));
  447. #endif
  448. /* remove the starting offset from the pool count */
  449. vmdq_i -= adapter->ring_feature[RING_F_VMDQ].offset;
  450. /* save features for later use */
  451. adapter->ring_feature[RING_F_VMDQ].indices = vmdq_i;
  452. adapter->ring_feature[RING_F_VMDQ].mask = vmdq_m;
  453. /* limit RSS based on user input and save for later use */
  454. adapter->ring_feature[RING_F_RSS].indices = rss_i;
  455. adapter->ring_feature[RING_F_RSS].mask = rss_m;
  456. adapter->num_rx_pools = vmdq_i;
  457. adapter->num_rx_queues_per_pool = rss_i;
  458. adapter->num_rx_queues = vmdq_i * rss_i;
  459. adapter->num_tx_queues = vmdq_i * rss_i;
  460. /* disable ATR as it is not supported when VMDq is enabled */
  461. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  462. #ifdef IXGBE_FCOE
  463. /*
  464. * FCoE can use rings from adjacent buffers to allow RSS
  465. * like behavior. To account for this we need to add the
  466. * FCoE indices to the total ring count.
  467. */
  468. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  469. struct ixgbe_ring_feature *fcoe;
  470. fcoe = &adapter->ring_feature[RING_F_FCOE];
  471. /* limit ourselves based on feature limits */
  472. fcoe_i = min_t(u16, fcoe_i, fcoe->limit);
  473. if (vmdq_i > 1 && fcoe_i) {
  474. /* reserve no more than number of CPUs */
  475. fcoe_i = min_t(u16, fcoe_i, num_online_cpus());
  476. /* alloc queues for FCoE separately */
  477. fcoe->indices = fcoe_i;
  478. fcoe->offset = vmdq_i * rss_i;
  479. } else {
  480. /* merge FCoE queues with RSS queues */
  481. fcoe_i = min_t(u16, fcoe_i + rss_i, num_online_cpus());
  482. /* limit indices to rss_i if MSI-X is disabled */
  483. if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
  484. fcoe_i = rss_i;
  485. /* attempt to reserve some queues for just FCoE */
  486. fcoe->indices = min_t(u16, fcoe_i, fcoe->limit);
  487. fcoe->offset = fcoe_i - fcoe->indices;
  488. fcoe_i -= rss_i;
  489. }
  490. /* add queues to adapter */
  491. adapter->num_tx_queues += fcoe_i;
  492. adapter->num_rx_queues += fcoe_i;
  493. }
  494. #endif
  495. return true;
  496. }
  497. /**
  498. * ixgbe_set_rss_queues - Allocate queues for RSS
  499. * @adapter: board private structure to initialize
  500. *
  501. * This is our "base" multiqueue mode. RSS (Receive Side Scaling) will try
  502. * to allocate one Rx queue per CPU, and if available, one Tx queue per CPU.
  503. *
  504. **/
  505. static bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter)
  506. {
  507. struct ixgbe_ring_feature *f;
  508. u16 rss_i;
  509. /* set mask for 16 queue limit of RSS */
  510. f = &adapter->ring_feature[RING_F_RSS];
  511. rss_i = f->limit;
  512. f->indices = rss_i;
  513. f->mask = IXGBE_RSS_16Q_MASK;
  514. /* disable ATR by default, it will be configured below */
  515. adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
  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 (rss_i > 1 && adapter->atr_sample_rate) {
  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. if (!(adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE))
  526. adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE;
  527. }
  528. #ifdef IXGBE_FCOE
  529. /*
  530. * FCoE can exist on the same rings as standard network traffic
  531. * however it is preferred to avoid that if possible. In order
  532. * to get the best performance we allocate as many FCoE queues
  533. * as we can and we place them at the end of the ring array to
  534. * avoid sharing queues with standard RSS on systems with 24 or
  535. * more CPUs.
  536. */
  537. if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
  538. struct net_device *dev = adapter->netdev;
  539. u16 fcoe_i;
  540. f = &adapter->ring_feature[RING_F_FCOE];
  541. /* merge FCoE queues with RSS queues */
  542. fcoe_i = min_t(u16, f->limit + rss_i, num_online_cpus());
  543. fcoe_i = min_t(u16, fcoe_i, dev->num_tx_queues);
  544. /* limit indices to rss_i if MSI-X is disabled */
  545. if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
  546. fcoe_i = rss_i;
  547. /* attempt to reserve some queues for just FCoE */
  548. f->indices = min_t(u16, fcoe_i, f->limit);
  549. f->offset = fcoe_i - f->indices;
  550. rss_i = max_t(u16, fcoe_i, rss_i);
  551. }
  552. #endif /* IXGBE_FCOE */
  553. adapter->num_rx_queues = rss_i;
  554. adapter->num_tx_queues = rss_i;
  555. return true;
  556. }
  557. /**
  558. * ixgbe_set_num_queues - Allocate queues for device, feature dependent
  559. * @adapter: board private structure to initialize
  560. *
  561. * This is the top level queue allocation routine. The order here is very
  562. * important, starting with the "most" number of features turned on at once,
  563. * and ending with the smallest set of features. This way large combinations
  564. * can be allocated if they're turned on, and smaller combinations are the
  565. * fallthrough conditions.
  566. *
  567. **/
  568. static void ixgbe_set_num_queues(struct ixgbe_adapter *adapter)
  569. {
  570. /* Start with base case */
  571. adapter->num_rx_queues = 1;
  572. adapter->num_tx_queues = 1;
  573. adapter->num_rx_pools = adapter->num_rx_queues;
  574. adapter->num_rx_queues_per_pool = 1;
  575. #ifdef CONFIG_IXGBE_DCB
  576. if (ixgbe_set_dcb_sriov_queues(adapter))
  577. return;
  578. if (ixgbe_set_dcb_queues(adapter))
  579. return;
  580. #endif
  581. if (ixgbe_set_sriov_queues(adapter))
  582. return;
  583. ixgbe_set_rss_queues(adapter);
  584. }
  585. static void ixgbe_acquire_msix_vectors(struct ixgbe_adapter *adapter,
  586. int vectors)
  587. {
  588. int err, vector_threshold;
  589. /* We'll want at least 2 (vector_threshold):
  590. * 1) TxQ[0] + RxQ[0] handler
  591. * 2) Other (Link Status Change, etc.)
  592. */
  593. vector_threshold = MIN_MSIX_COUNT;
  594. /*
  595. * The more we get, the more we will assign to Tx/Rx Cleanup
  596. * for the separate queues...where Rx Cleanup >= Tx Cleanup.
  597. * Right now, we simply care about how many we'll get; we'll
  598. * set them up later while requesting irq's.
  599. */
  600. while (vectors >= vector_threshold) {
  601. err = pci_enable_msix(adapter->pdev, adapter->msix_entries,
  602. vectors);
  603. if (!err) /* Success in acquiring all requested vectors. */
  604. break;
  605. else if (err < 0)
  606. vectors = 0; /* Nasty failure, quit now */
  607. else /* err == number of vectors we should try again with */
  608. vectors = err;
  609. }
  610. if (vectors < vector_threshold) {
  611. /* Can't allocate enough MSI-X interrupts? Oh well.
  612. * This just means we'll go with either a single MSI
  613. * vector or fall back to legacy interrupts.
  614. */
  615. netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev,
  616. "Unable to allocate MSI-X interrupts\n");
  617. adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED;
  618. kfree(adapter->msix_entries);
  619. adapter->msix_entries = NULL;
  620. } else {
  621. adapter->flags |= IXGBE_FLAG_MSIX_ENABLED; /* Woot! */
  622. /*
  623. * Adjust for only the vectors we'll use, which is minimum
  624. * of max_msix_q_vectors + NON_Q_VECTORS, or the number of
  625. * vectors we were allocated.
  626. */
  627. vectors -= NON_Q_VECTORS;
  628. adapter->num_q_vectors = min(vectors, adapter->max_q_vectors);
  629. }
  630. }
  631. static void ixgbe_add_ring(struct ixgbe_ring *ring,
  632. struct ixgbe_ring_container *head)
  633. {
  634. ring->next = head->ring;
  635. head->ring = ring;
  636. head->count++;
  637. }
  638. /**
  639. * ixgbe_alloc_q_vector - Allocate memory for a single interrupt vector
  640. * @adapter: board private structure to initialize
  641. * @v_count: q_vectors allocated on adapter, used for ring interleaving
  642. * @v_idx: index of vector in adapter struct
  643. * @txr_count: total number of Tx rings to allocate
  644. * @txr_idx: index of first Tx ring to allocate
  645. * @rxr_count: total number of Rx rings to allocate
  646. * @rxr_idx: index of first Rx ring to allocate
  647. *
  648. * We allocate one q_vector. If allocation fails we return -ENOMEM.
  649. **/
  650. static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,
  651. int v_count, int v_idx,
  652. int txr_count, int txr_idx,
  653. int rxr_count, int rxr_idx)
  654. {
  655. struct ixgbe_q_vector *q_vector;
  656. struct ixgbe_ring *ring;
  657. int node = -1;
  658. int cpu = -1;
  659. int ring_count, size;
  660. ring_count = txr_count + rxr_count;
  661. size = sizeof(struct ixgbe_q_vector) +
  662. (sizeof(struct ixgbe_ring) * ring_count);
  663. /* customize cpu for Flow Director mapping */
  664. if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) {
  665. if (cpu_online(v_idx)) {
  666. cpu = v_idx;
  667. node = cpu_to_node(cpu);
  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. while (txr_count) {
  696. /* assign generic ring traits */
  697. ring->dev = &adapter->pdev->dev;
  698. ring->netdev = adapter->netdev;
  699. /* configure backlink on ring */
  700. ring->q_vector = q_vector;
  701. /* update q_vector Tx values */
  702. ixgbe_add_ring(ring, &q_vector->tx);
  703. /* apply Tx specific ring traits */
  704. ring->count = adapter->tx_ring_count;
  705. ring->queue_index = txr_idx;
  706. /* assign ring to adapter */
  707. adapter->tx_ring[txr_idx] = ring;
  708. /* update count and index */
  709. txr_count--;
  710. txr_idx += v_count;
  711. /* push pointer to next ring */
  712. ring++;
  713. }
  714. while (rxr_count) {
  715. /* assign generic ring traits */
  716. ring->dev = &adapter->pdev->dev;
  717. ring->netdev = adapter->netdev;
  718. /* configure backlink on ring */
  719. ring->q_vector = q_vector;
  720. /* update q_vector Rx values */
  721. ixgbe_add_ring(ring, &q_vector->rx);
  722. /*
  723. * 82599 errata, UDP frames with a 0 checksum
  724. * can be marked as checksum errors.
  725. */
  726. if (adapter->hw.mac.type == ixgbe_mac_82599EB)
  727. set_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state);
  728. #ifdef IXGBE_FCOE
  729. if (adapter->netdev->features & NETIF_F_FCOE_MTU) {
  730. struct ixgbe_ring_feature *f;
  731. f = &adapter->ring_feature[RING_F_FCOE];
  732. if ((rxr_idx >= f->offset) &&
  733. (rxr_idx < f->offset + f->indices))
  734. set_bit(__IXGBE_RX_FCOE, &ring->state);
  735. }
  736. #endif /* IXGBE_FCOE */
  737. /* apply Rx specific ring traits */
  738. ring->count = adapter->rx_ring_count;
  739. ring->queue_index = rxr_idx;
  740. /* assign ring to adapter */
  741. adapter->rx_ring[rxr_idx] = ring;
  742. /* update count and index */
  743. rxr_count--;
  744. rxr_idx += v_count;
  745. /* push pointer to next ring */
  746. ring++;
  747. }
  748. return 0;
  749. }
  750. /**
  751. * ixgbe_free_q_vector - Free memory allocated for specific interrupt vector
  752. * @adapter: board private structure to initialize
  753. * @v_idx: Index of vector to be freed
  754. *
  755. * This function frees the memory allocated to the q_vector. In addition if
  756. * NAPI is enabled it will delete any references to the NAPI struct prior
  757. * to freeing the q_vector.
  758. **/
  759. static void ixgbe_free_q_vector(struct ixgbe_adapter *adapter, int v_idx)
  760. {
  761. struct ixgbe_q_vector *q_vector = adapter->q_vector[v_idx];
  762. struct ixgbe_ring *ring;
  763. ixgbe_for_each_ring(ring, q_vector->tx)
  764. adapter->tx_ring[ring->queue_index] = NULL;
  765. ixgbe_for_each_ring(ring, q_vector->rx)
  766. adapter->rx_ring[ring->queue_index] = NULL;
  767. adapter->q_vector[v_idx] = NULL;
  768. netif_napi_del(&q_vector->napi);
  769. /*
  770. * ixgbe_get_stats64() might access the rings on this vector,
  771. * we must wait a grace period before freeing it.
  772. */
  773. kfree_rcu(q_vector, rcu);
  774. }
  775. /**
  776. * ixgbe_alloc_q_vectors - Allocate memory for interrupt vectors
  777. * @adapter: board private structure to initialize
  778. *
  779. * We allocate one q_vector per queue interrupt. If allocation fails we
  780. * return -ENOMEM.
  781. **/
  782. static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter)
  783. {
  784. int q_vectors = adapter->num_q_vectors;
  785. int rxr_remaining = adapter->num_rx_queues;
  786. int txr_remaining = adapter->num_tx_queues;
  787. int rxr_idx = 0, txr_idx = 0, v_idx = 0;
  788. int err;
  789. /* only one q_vector if MSI-X is disabled. */
  790. if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED))
  791. q_vectors = 1;
  792. if (q_vectors >= (rxr_remaining + txr_remaining)) {
  793. for (; rxr_remaining; v_idx++) {
  794. err = ixgbe_alloc_q_vector(adapter, q_vectors, v_idx,
  795. 0, 0, 1, rxr_idx);
  796. if (err)
  797. goto err_out;
  798. /* update counts and index */
  799. rxr_remaining--;
  800. rxr_idx++;
  801. }
  802. }
  803. for (; v_idx < q_vectors; v_idx++) {
  804. int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors - v_idx);
  805. int tqpv = DIV_ROUND_UP(txr_remaining, q_vectors - v_idx);
  806. err = ixgbe_alloc_q_vector(adapter, q_vectors, v_idx,
  807. tqpv, txr_idx,
  808. rqpv, rxr_idx);
  809. if (err)
  810. goto err_out;
  811. /* update counts and index */
  812. rxr_remaining -= rqpv;
  813. txr_remaining -= tqpv;
  814. rxr_idx++;
  815. txr_idx++;
  816. }
  817. return 0;
  818. err_out:
  819. adapter->num_tx_queues = 0;
  820. adapter->num_rx_queues = 0;
  821. adapter->num_q_vectors = 0;
  822. while (v_idx--)
  823. ixgbe_free_q_vector(adapter, v_idx);
  824. return -ENOMEM;
  825. }
  826. /**
  827. * ixgbe_free_q_vectors - Free memory allocated for interrupt vectors
  828. * @adapter: board private structure to initialize
  829. *
  830. * This function frees the memory allocated to the q_vectors. In addition if
  831. * NAPI is enabled it will delete any references to the NAPI struct prior
  832. * to freeing the q_vector.
  833. **/
  834. static void ixgbe_free_q_vectors(struct ixgbe_adapter *adapter)
  835. {
  836. int v_idx = adapter->num_q_vectors;
  837. adapter->num_tx_queues = 0;
  838. adapter->num_rx_queues = 0;
  839. adapter->num_q_vectors = 0;
  840. while (v_idx--)
  841. ixgbe_free_q_vector(adapter, v_idx);
  842. }
  843. static void ixgbe_reset_interrupt_capability(struct ixgbe_adapter *adapter)
  844. {
  845. if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
  846. adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED;
  847. pci_disable_msix(adapter->pdev);
  848. kfree(adapter->msix_entries);
  849. adapter->msix_entries = NULL;
  850. } else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) {
  851. adapter->flags &= ~IXGBE_FLAG_MSI_ENABLED;
  852. pci_disable_msi(adapter->pdev);
  853. }
  854. }
  855. /**
  856. * ixgbe_set_interrupt_capability - set MSI-X or MSI if supported
  857. * @adapter: board private structure to initialize
  858. *
  859. * Attempt to configure the interrupts using the best available
  860. * capabilities of the hardware and the kernel.
  861. **/
  862. static void ixgbe_set_interrupt_capability(struct ixgbe_adapter *adapter)
  863. {
  864. struct ixgbe_hw *hw = &adapter->hw;
  865. int vector, v_budget, err;
  866. /*
  867. * It's easy to be greedy for MSI-X vectors, but it really
  868. * doesn't do us much good if we have a lot more vectors
  869. * than CPU's. So let's be conservative and only ask for
  870. * (roughly) the same number of vectors as there are CPU's.
  871. * The default is to use pairs of vectors.
  872. */
  873. v_budget = max(adapter->num_rx_queues, adapter->num_tx_queues);
  874. v_budget = min_t(int, v_budget, num_online_cpus());
  875. v_budget += NON_Q_VECTORS;
  876. /*
  877. * At the same time, hardware can only support a maximum of
  878. * hw.mac->max_msix_vectors vectors. With features
  879. * such as RSS and VMDq, we can easily surpass the number of Rx and Tx
  880. * descriptor queues supported by our device. Thus, we cap it off in
  881. * those rare cases where the cpu count also exceeds our vector limit.
  882. */
  883. v_budget = min_t(int, v_budget, hw->mac.max_msix_vectors);
  884. /* A failure in MSI-X entry allocation isn't fatal, but it does
  885. * mean we disable MSI-X capabilities of the adapter. */
  886. adapter->msix_entries = kcalloc(v_budget,
  887. sizeof(struct msix_entry), GFP_KERNEL);
  888. if (adapter->msix_entries) {
  889. for (vector = 0; vector < v_budget; vector++)
  890. adapter->msix_entries[vector].entry = vector;
  891. ixgbe_acquire_msix_vectors(adapter, v_budget);
  892. if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED)
  893. return;
  894. }
  895. /* disable DCB if number of TCs exceeds 1 */
  896. if (netdev_get_num_tc(adapter->netdev) > 1) {
  897. e_err(probe, "num TCs exceeds number of queues - disabling DCB\n");
  898. netdev_reset_tc(adapter->netdev);
  899. if (adapter->hw.mac.type == ixgbe_mac_82598EB)
  900. adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
  901. adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED;
  902. adapter->temp_dcb_cfg.pfc_mode_enable = false;
  903. adapter->dcb_cfg.pfc_mode_enable = false;
  904. }
  905. adapter->dcb_cfg.num_tcs.pg_tcs = 1;
  906. adapter->dcb_cfg.num_tcs.pfc_tcs = 1;
  907. /* disable SR-IOV */
  908. ixgbe_disable_sriov(adapter);
  909. /* disable RSS */
  910. adapter->ring_feature[RING_F_RSS].limit = 1;
  911. ixgbe_set_num_queues(adapter);
  912. adapter->num_q_vectors = 1;
  913. err = pci_enable_msi(adapter->pdev);
  914. if (err) {
  915. netif_printk(adapter, hw, KERN_DEBUG, adapter->netdev,
  916. "Unable to allocate MSI interrupt, "
  917. "falling back to legacy. Error: %d\n", err);
  918. return;
  919. }
  920. adapter->flags |= IXGBE_FLAG_MSI_ENABLED;
  921. }
  922. /**
  923. * ixgbe_init_interrupt_scheme - Determine proper interrupt scheme
  924. * @adapter: board private structure to initialize
  925. *
  926. * We determine which interrupt scheme to use based on...
  927. * - Kernel support (MSI, MSI-X)
  928. * - which can be user-defined (via MODULE_PARAM)
  929. * - Hardware queue count (num_*_queues)
  930. * - defined by miscellaneous hardware support/features (RSS, etc.)
  931. **/
  932. int ixgbe_init_interrupt_scheme(struct ixgbe_adapter *adapter)
  933. {
  934. int err;
  935. /* Number of supported queues */
  936. ixgbe_set_num_queues(adapter);
  937. /* Set interrupt mode */
  938. ixgbe_set_interrupt_capability(adapter);
  939. err = ixgbe_alloc_q_vectors(adapter);
  940. if (err) {
  941. e_dev_err("Unable to allocate memory for queue vectors\n");
  942. goto err_alloc_q_vectors;
  943. }
  944. ixgbe_cache_ring_register(adapter);
  945. e_dev_info("Multiqueue %s: Rx Queue count = %u, Tx Queue count = %u\n",
  946. (adapter->num_rx_queues > 1) ? "Enabled" : "Disabled",
  947. adapter->num_rx_queues, adapter->num_tx_queues);
  948. set_bit(__IXGBE_DOWN, &adapter->state);
  949. return 0;
  950. err_alloc_q_vectors:
  951. ixgbe_reset_interrupt_capability(adapter);
  952. return err;
  953. }
  954. /**
  955. * ixgbe_clear_interrupt_scheme - Clear the current interrupt scheme settings
  956. * @adapter: board private structure to clear interrupt scheme on
  957. *
  958. * We go through and clear interrupt specific resources and reset the structure
  959. * to pre-load conditions
  960. **/
  961. void ixgbe_clear_interrupt_scheme(struct ixgbe_adapter *adapter)
  962. {
  963. adapter->num_tx_queues = 0;
  964. adapter->num_rx_queues = 0;
  965. ixgbe_free_q_vectors(adapter);
  966. ixgbe_reset_interrupt_capability(adapter);
  967. }
  968. void ixgbe_tx_ctxtdesc(struct ixgbe_ring *tx_ring, u32 vlan_macip_lens,
  969. u32 fcoe_sof_eof, u32 type_tucmd, u32 mss_l4len_idx)
  970. {
  971. struct ixgbe_adv_tx_context_desc *context_desc;
  972. u16 i = tx_ring->next_to_use;
  973. context_desc = IXGBE_TX_CTXTDESC(tx_ring, i);
  974. i++;
  975. tx_ring->next_to_use = (i < tx_ring->count) ? i : 0;
  976. /* set bits to identify this as an advanced context descriptor */
  977. type_tucmd |= IXGBE_TXD_CMD_DEXT | IXGBE_ADVTXD_DTYP_CTXT;
  978. context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens);
  979. context_desc->seqnum_seed = cpu_to_le32(fcoe_sof_eof);
  980. context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd);
  981. context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx);
  982. }