i40evf_virtchnl.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. /*******************************************************************************
  2. *
  3. * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
  4. * Copyright(c) 2013 - 2014 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * The full GNU General Public License is included in this distribution in
  19. * the file called "COPYING".
  20. *
  21. * Contact Information:
  22. * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. ******************************************************************************/
  26. #include "i40evf.h"
  27. #include "i40e_prototype.h"
  28. #include "i40evf_client.h"
  29. /* busy wait delay in msec */
  30. #define I40EVF_BUSY_WAIT_DELAY 10
  31. #define I40EVF_BUSY_WAIT_COUNT 50
  32. /**
  33. * i40evf_send_pf_msg
  34. * @adapter: adapter structure
  35. * @op: virtual channel opcode
  36. * @msg: pointer to message buffer
  37. * @len: message length
  38. *
  39. * Send message to PF and print status if failure.
  40. **/
  41. static int i40evf_send_pf_msg(struct i40evf_adapter *adapter,
  42. enum virtchnl_ops op, u8 *msg, u16 len)
  43. {
  44. struct i40e_hw *hw = &adapter->hw;
  45. i40e_status err;
  46. if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED)
  47. return 0; /* nothing to see here, move along */
  48. err = i40e_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL);
  49. if (err)
  50. dev_dbg(&adapter->pdev->dev, "Unable to send opcode %d to PF, err %s, aq_err %s\n",
  51. op, i40evf_stat_str(hw, err),
  52. i40evf_aq_str(hw, hw->aq.asq_last_status));
  53. return err;
  54. }
  55. /**
  56. * i40evf_send_api_ver
  57. * @adapter: adapter structure
  58. *
  59. * Send API version admin queue message to the PF. The reply is not checked
  60. * in this function. Returns 0 if the message was successfully
  61. * sent, or one of the I40E_ADMIN_QUEUE_ERROR_ statuses if not.
  62. **/
  63. int i40evf_send_api_ver(struct i40evf_adapter *adapter)
  64. {
  65. struct virtchnl_version_info vvi;
  66. vvi.major = VIRTCHNL_VERSION_MAJOR;
  67. vvi.minor = VIRTCHNL_VERSION_MINOR;
  68. return i40evf_send_pf_msg(adapter, VIRTCHNL_OP_VERSION, (u8 *)&vvi,
  69. sizeof(vvi));
  70. }
  71. /**
  72. * i40evf_verify_api_ver
  73. * @adapter: adapter structure
  74. *
  75. * Compare API versions with the PF. Must be called after admin queue is
  76. * initialized. Returns 0 if API versions match, -EIO if they do not,
  77. * I40E_ERR_ADMIN_QUEUE_NO_WORK if the admin queue is empty, and any errors
  78. * from the firmware are propagated.
  79. **/
  80. int i40evf_verify_api_ver(struct i40evf_adapter *adapter)
  81. {
  82. struct virtchnl_version_info *pf_vvi;
  83. struct i40e_hw *hw = &adapter->hw;
  84. struct i40e_arq_event_info event;
  85. enum virtchnl_ops op;
  86. i40e_status err;
  87. event.buf_len = I40EVF_MAX_AQ_BUF_SIZE;
  88. event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
  89. if (!event.msg_buf) {
  90. err = -ENOMEM;
  91. goto out;
  92. }
  93. while (1) {
  94. err = i40evf_clean_arq_element(hw, &event, NULL);
  95. /* When the AQ is empty, i40evf_clean_arq_element will return
  96. * nonzero and this loop will terminate.
  97. */
  98. if (err)
  99. goto out_alloc;
  100. op =
  101. (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
  102. if (op == VIRTCHNL_OP_VERSION)
  103. break;
  104. }
  105. err = (i40e_status)le32_to_cpu(event.desc.cookie_low);
  106. if (err)
  107. goto out_alloc;
  108. if (op != VIRTCHNL_OP_VERSION) {
  109. dev_info(&adapter->pdev->dev, "Invalid reply type %d from PF\n",
  110. op);
  111. err = -EIO;
  112. goto out_alloc;
  113. }
  114. pf_vvi = (struct virtchnl_version_info *)event.msg_buf;
  115. adapter->pf_version = *pf_vvi;
  116. if ((pf_vvi->major > VIRTCHNL_VERSION_MAJOR) ||
  117. ((pf_vvi->major == VIRTCHNL_VERSION_MAJOR) &&
  118. (pf_vvi->minor > VIRTCHNL_VERSION_MINOR)))
  119. err = -EIO;
  120. out_alloc:
  121. kfree(event.msg_buf);
  122. out:
  123. return err;
  124. }
  125. /**
  126. * i40evf_send_vf_config_msg
  127. * @adapter: adapter structure
  128. *
  129. * Send VF configuration request admin queue message to the PF. The reply
  130. * is not checked in this function. Returns 0 if the message was
  131. * successfully sent, or one of the I40E_ADMIN_QUEUE_ERROR_ statuses if not.
  132. **/
  133. int i40evf_send_vf_config_msg(struct i40evf_adapter *adapter)
  134. {
  135. u32 caps;
  136. caps = VIRTCHNL_VF_OFFLOAD_L2 |
  137. VIRTCHNL_VF_OFFLOAD_RSS_PF |
  138. VIRTCHNL_VF_OFFLOAD_RSS_AQ |
  139. VIRTCHNL_VF_OFFLOAD_RSS_REG |
  140. VIRTCHNL_VF_OFFLOAD_VLAN |
  141. VIRTCHNL_VF_OFFLOAD_WB_ON_ITR |
  142. VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 |
  143. VIRTCHNL_VF_OFFLOAD_ENCAP |
  144. VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM |
  145. VIRTCHNL_VF_OFFLOAD_REQ_QUEUES;
  146. adapter->current_op = VIRTCHNL_OP_GET_VF_RESOURCES;
  147. adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_CONFIG;
  148. if (PF_IS_V11(adapter))
  149. return i40evf_send_pf_msg(adapter,
  150. VIRTCHNL_OP_GET_VF_RESOURCES,
  151. (u8 *)&caps, sizeof(caps));
  152. else
  153. return i40evf_send_pf_msg(adapter,
  154. VIRTCHNL_OP_GET_VF_RESOURCES,
  155. NULL, 0);
  156. }
  157. /**
  158. * i40evf_get_vf_config
  159. * @hw: pointer to the hardware structure
  160. * @len: length of buffer
  161. *
  162. * Get VF configuration from PF and populate hw structure. Must be called after
  163. * admin queue is initialized. Busy waits until response is received from PF,
  164. * with maximum timeout. Response from PF is returned in the buffer for further
  165. * processing by the caller.
  166. **/
  167. int i40evf_get_vf_config(struct i40evf_adapter *adapter)
  168. {
  169. struct i40e_hw *hw = &adapter->hw;
  170. struct i40e_arq_event_info event;
  171. enum virtchnl_ops op;
  172. i40e_status err;
  173. u16 len;
  174. len = sizeof(struct virtchnl_vf_resource) +
  175. I40E_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource);
  176. event.buf_len = len;
  177. event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
  178. if (!event.msg_buf) {
  179. err = -ENOMEM;
  180. goto out;
  181. }
  182. while (1) {
  183. /* When the AQ is empty, i40evf_clean_arq_element will return
  184. * nonzero and this loop will terminate.
  185. */
  186. err = i40evf_clean_arq_element(hw, &event, NULL);
  187. if (err)
  188. goto out_alloc;
  189. op =
  190. (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
  191. if (op == VIRTCHNL_OP_GET_VF_RESOURCES)
  192. break;
  193. }
  194. err = (i40e_status)le32_to_cpu(event.desc.cookie_low);
  195. memcpy(adapter->vf_res, event.msg_buf, min(event.msg_len, len));
  196. i40e_vf_parse_hw_config(hw, adapter->vf_res);
  197. out_alloc:
  198. kfree(event.msg_buf);
  199. out:
  200. return err;
  201. }
  202. /**
  203. * i40evf_configure_queues
  204. * @adapter: adapter structure
  205. *
  206. * Request that the PF set up our (previously allocated) queues.
  207. **/
  208. void i40evf_configure_queues(struct i40evf_adapter *adapter)
  209. {
  210. struct virtchnl_vsi_queue_config_info *vqci;
  211. struct virtchnl_queue_pair_info *vqpi;
  212. int pairs = adapter->num_active_queues;
  213. int i, len, max_frame = I40E_MAX_RXBUFFER;
  214. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  215. /* bail because we already have a command pending */
  216. dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n",
  217. adapter->current_op);
  218. return;
  219. }
  220. adapter->current_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
  221. len = sizeof(struct virtchnl_vsi_queue_config_info) +
  222. (sizeof(struct virtchnl_queue_pair_info) * pairs);
  223. vqci = kzalloc(len, GFP_KERNEL);
  224. if (!vqci)
  225. return;
  226. /* Limit maximum frame size when jumbo frames is not enabled */
  227. if (!(adapter->flags & I40EVF_FLAG_LEGACY_RX) &&
  228. (adapter->netdev->mtu <= ETH_DATA_LEN))
  229. max_frame = I40E_RXBUFFER_1536 - NET_IP_ALIGN;
  230. vqci->vsi_id = adapter->vsi_res->vsi_id;
  231. vqci->num_queue_pairs = pairs;
  232. vqpi = vqci->qpair;
  233. /* Size check is not needed here - HW max is 16 queue pairs, and we
  234. * can fit info for 31 of them into the AQ buffer before it overflows.
  235. */
  236. for (i = 0; i < pairs; i++) {
  237. vqpi->txq.vsi_id = vqci->vsi_id;
  238. vqpi->txq.queue_id = i;
  239. vqpi->txq.ring_len = adapter->tx_rings[i].count;
  240. vqpi->txq.dma_ring_addr = adapter->tx_rings[i].dma;
  241. vqpi->rxq.vsi_id = vqci->vsi_id;
  242. vqpi->rxq.queue_id = i;
  243. vqpi->rxq.ring_len = adapter->rx_rings[i].count;
  244. vqpi->rxq.dma_ring_addr = adapter->rx_rings[i].dma;
  245. vqpi->rxq.max_pkt_size = max_frame;
  246. vqpi->rxq.databuffer_size =
  247. ALIGN(adapter->rx_rings[i].rx_buf_len,
  248. BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));
  249. vqpi++;
  250. }
  251. adapter->aq_required &= ~I40EVF_FLAG_AQ_CONFIGURE_QUEUES;
  252. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
  253. (u8 *)vqci, len);
  254. kfree(vqci);
  255. }
  256. /**
  257. * i40evf_enable_queues
  258. * @adapter: adapter structure
  259. *
  260. * Request that the PF enable all of our queues.
  261. **/
  262. void i40evf_enable_queues(struct i40evf_adapter *adapter)
  263. {
  264. struct virtchnl_queue_select vqs;
  265. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  266. /* bail because we already have a command pending */
  267. dev_err(&adapter->pdev->dev, "Cannot enable queues, command %d pending\n",
  268. adapter->current_op);
  269. return;
  270. }
  271. adapter->current_op = VIRTCHNL_OP_ENABLE_QUEUES;
  272. vqs.vsi_id = adapter->vsi_res->vsi_id;
  273. vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
  274. vqs.rx_queues = vqs.tx_queues;
  275. adapter->aq_required &= ~I40EVF_FLAG_AQ_ENABLE_QUEUES;
  276. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_QUEUES,
  277. (u8 *)&vqs, sizeof(vqs));
  278. }
  279. /**
  280. * i40evf_disable_queues
  281. * @adapter: adapter structure
  282. *
  283. * Request that the PF disable all of our queues.
  284. **/
  285. void i40evf_disable_queues(struct i40evf_adapter *adapter)
  286. {
  287. struct virtchnl_queue_select vqs;
  288. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  289. /* bail because we already have a command pending */
  290. dev_err(&adapter->pdev->dev, "Cannot disable queues, command %d pending\n",
  291. adapter->current_op);
  292. return;
  293. }
  294. adapter->current_op = VIRTCHNL_OP_DISABLE_QUEUES;
  295. vqs.vsi_id = adapter->vsi_res->vsi_id;
  296. vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
  297. vqs.rx_queues = vqs.tx_queues;
  298. adapter->aq_required &= ~I40EVF_FLAG_AQ_DISABLE_QUEUES;
  299. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_QUEUES,
  300. (u8 *)&vqs, sizeof(vqs));
  301. }
  302. /**
  303. * i40evf_map_queues
  304. * @adapter: adapter structure
  305. *
  306. * Request that the PF map queues to interrupt vectors. Misc causes, including
  307. * admin queue, are always mapped to vector 0.
  308. **/
  309. void i40evf_map_queues(struct i40evf_adapter *adapter)
  310. {
  311. struct virtchnl_irq_map_info *vimi;
  312. int v_idx, q_vectors, len;
  313. struct i40e_q_vector *q_vector;
  314. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  315. /* bail because we already have a command pending */
  316. dev_err(&adapter->pdev->dev, "Cannot map queues to vectors, command %d pending\n",
  317. adapter->current_op);
  318. return;
  319. }
  320. adapter->current_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
  321. q_vectors = adapter->num_msix_vectors - NONQ_VECS;
  322. len = sizeof(struct virtchnl_irq_map_info) +
  323. (adapter->num_msix_vectors *
  324. sizeof(struct virtchnl_vector_map));
  325. vimi = kzalloc(len, GFP_KERNEL);
  326. if (!vimi)
  327. return;
  328. vimi->num_vectors = adapter->num_msix_vectors;
  329. /* Queue vectors first */
  330. for (v_idx = 0; v_idx < q_vectors; v_idx++) {
  331. q_vector = adapter->q_vectors + v_idx;
  332. vimi->vecmap[v_idx].vsi_id = adapter->vsi_res->vsi_id;
  333. vimi->vecmap[v_idx].vector_id = v_idx + NONQ_VECS;
  334. vimi->vecmap[v_idx].txq_map = q_vector->ring_mask;
  335. vimi->vecmap[v_idx].rxq_map = q_vector->ring_mask;
  336. }
  337. /* Misc vector last - this is only for AdminQ messages */
  338. vimi->vecmap[v_idx].vsi_id = adapter->vsi_res->vsi_id;
  339. vimi->vecmap[v_idx].vector_id = 0;
  340. vimi->vecmap[v_idx].txq_map = 0;
  341. vimi->vecmap[v_idx].rxq_map = 0;
  342. adapter->aq_required &= ~I40EVF_FLAG_AQ_MAP_VECTORS;
  343. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_IRQ_MAP,
  344. (u8 *)vimi, len);
  345. kfree(vimi);
  346. }
  347. /**
  348. * i40evf_request_queues
  349. * @adapter: adapter structure
  350. * @num: number of requested queues
  351. *
  352. * We get a default number of queues from the PF. This enables us to request a
  353. * different number. Returns 0 on success, negative on failure
  354. **/
  355. int i40evf_request_queues(struct i40evf_adapter *adapter, int num)
  356. {
  357. struct virtchnl_vf_res_request vfres;
  358. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  359. /* bail because we already have a command pending */
  360. dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n",
  361. adapter->current_op);
  362. return -EBUSY;
  363. }
  364. vfres.num_queue_pairs = num;
  365. adapter->current_op = VIRTCHNL_OP_REQUEST_QUEUES;
  366. adapter->flags |= I40EVF_FLAG_REINIT_ITR_NEEDED;
  367. return i40evf_send_pf_msg(adapter, VIRTCHNL_OP_REQUEST_QUEUES,
  368. (u8 *)&vfres, sizeof(vfres));
  369. }
  370. /**
  371. * i40evf_add_ether_addrs
  372. * @adapter: adapter structure
  373. * @addrs: the MAC address filters to add (contiguous)
  374. * @count: number of filters
  375. *
  376. * Request that the PF add one or more addresses to our filters.
  377. **/
  378. void i40evf_add_ether_addrs(struct i40evf_adapter *adapter)
  379. {
  380. struct virtchnl_ether_addr_list *veal;
  381. int len, i = 0, count = 0;
  382. struct i40evf_mac_filter *f;
  383. bool more = false;
  384. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  385. /* bail because we already have a command pending */
  386. dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n",
  387. adapter->current_op);
  388. return;
  389. }
  390. list_for_each_entry(f, &adapter->mac_filter_list, list) {
  391. if (f->add)
  392. count++;
  393. }
  394. if (!count) {
  395. adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER;
  396. return;
  397. }
  398. adapter->current_op = VIRTCHNL_OP_ADD_ETH_ADDR;
  399. len = sizeof(struct virtchnl_ether_addr_list) +
  400. (count * sizeof(struct virtchnl_ether_addr));
  401. if (len > I40EVF_MAX_AQ_BUF_SIZE) {
  402. dev_warn(&adapter->pdev->dev, "Too many add MAC changes in one request\n");
  403. count = (I40EVF_MAX_AQ_BUF_SIZE -
  404. sizeof(struct virtchnl_ether_addr_list)) /
  405. sizeof(struct virtchnl_ether_addr);
  406. len = sizeof(struct virtchnl_ether_addr_list) +
  407. (count * sizeof(struct virtchnl_ether_addr));
  408. more = true;
  409. }
  410. veal = kzalloc(len, GFP_KERNEL);
  411. if (!veal)
  412. return;
  413. veal->vsi_id = adapter->vsi_res->vsi_id;
  414. veal->num_elements = count;
  415. list_for_each_entry(f, &adapter->mac_filter_list, list) {
  416. if (f->add) {
  417. ether_addr_copy(veal->list[i].addr, f->macaddr);
  418. i++;
  419. f->add = false;
  420. if (i == count)
  421. break;
  422. }
  423. }
  424. if (!more)
  425. adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER;
  426. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR,
  427. (u8 *)veal, len);
  428. kfree(veal);
  429. }
  430. /**
  431. * i40evf_del_ether_addrs
  432. * @adapter: adapter structure
  433. * @addrs: the MAC address filters to remove (contiguous)
  434. * @count: number of filtes
  435. *
  436. * Request that the PF remove one or more addresses from our filters.
  437. **/
  438. void i40evf_del_ether_addrs(struct i40evf_adapter *adapter)
  439. {
  440. struct virtchnl_ether_addr_list *veal;
  441. struct i40evf_mac_filter *f, *ftmp;
  442. int len, i = 0, count = 0;
  443. bool more = false;
  444. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  445. /* bail because we already have a command pending */
  446. dev_err(&adapter->pdev->dev, "Cannot remove filters, command %d pending\n",
  447. adapter->current_op);
  448. return;
  449. }
  450. list_for_each_entry(f, &adapter->mac_filter_list, list) {
  451. if (f->remove)
  452. count++;
  453. }
  454. if (!count) {
  455. adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER;
  456. return;
  457. }
  458. adapter->current_op = VIRTCHNL_OP_DEL_ETH_ADDR;
  459. len = sizeof(struct virtchnl_ether_addr_list) +
  460. (count * sizeof(struct virtchnl_ether_addr));
  461. if (len > I40EVF_MAX_AQ_BUF_SIZE) {
  462. dev_warn(&adapter->pdev->dev, "Too many delete MAC changes in one request\n");
  463. count = (I40EVF_MAX_AQ_BUF_SIZE -
  464. sizeof(struct virtchnl_ether_addr_list)) /
  465. sizeof(struct virtchnl_ether_addr);
  466. len = sizeof(struct virtchnl_ether_addr_list) +
  467. (count * sizeof(struct virtchnl_ether_addr));
  468. more = true;
  469. }
  470. veal = kzalloc(len, GFP_KERNEL);
  471. if (!veal)
  472. return;
  473. veal->vsi_id = adapter->vsi_res->vsi_id;
  474. veal->num_elements = count;
  475. list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) {
  476. if (f->remove) {
  477. ether_addr_copy(veal->list[i].addr, f->macaddr);
  478. i++;
  479. list_del(&f->list);
  480. kfree(f);
  481. if (i == count)
  482. break;
  483. }
  484. }
  485. if (!more)
  486. adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER;
  487. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_ETH_ADDR,
  488. (u8 *)veal, len);
  489. kfree(veal);
  490. }
  491. /**
  492. * i40evf_add_vlans
  493. * @adapter: adapter structure
  494. * @vlans: the VLANs to add
  495. * @count: number of VLANs
  496. *
  497. * Request that the PF add one or more VLAN filters to our VSI.
  498. **/
  499. void i40evf_add_vlans(struct i40evf_adapter *adapter)
  500. {
  501. struct virtchnl_vlan_filter_list *vvfl;
  502. int len, i = 0, count = 0;
  503. struct i40evf_vlan_filter *f;
  504. bool more = false;
  505. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  506. /* bail because we already have a command pending */
  507. dev_err(&adapter->pdev->dev, "Cannot add VLANs, command %d pending\n",
  508. adapter->current_op);
  509. return;
  510. }
  511. list_for_each_entry(f, &adapter->vlan_filter_list, list) {
  512. if (f->add)
  513. count++;
  514. }
  515. if (!count) {
  516. adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER;
  517. return;
  518. }
  519. adapter->current_op = VIRTCHNL_OP_ADD_VLAN;
  520. len = sizeof(struct virtchnl_vlan_filter_list) +
  521. (count * sizeof(u16));
  522. if (len > I40EVF_MAX_AQ_BUF_SIZE) {
  523. dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n");
  524. count = (I40EVF_MAX_AQ_BUF_SIZE -
  525. sizeof(struct virtchnl_vlan_filter_list)) /
  526. sizeof(u16);
  527. len = sizeof(struct virtchnl_vlan_filter_list) +
  528. (count * sizeof(u16));
  529. more = true;
  530. }
  531. vvfl = kzalloc(len, GFP_KERNEL);
  532. if (!vvfl)
  533. return;
  534. vvfl->vsi_id = adapter->vsi_res->vsi_id;
  535. vvfl->num_elements = count;
  536. list_for_each_entry(f, &adapter->vlan_filter_list, list) {
  537. if (f->add) {
  538. vvfl->vlan_id[i] = f->vlan;
  539. i++;
  540. f->add = false;
  541. if (i == count)
  542. break;
  543. }
  544. }
  545. if (!more)
  546. adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER;
  547. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);
  548. kfree(vvfl);
  549. }
  550. /**
  551. * i40evf_del_vlans
  552. * @adapter: adapter structure
  553. * @vlans: the VLANs to remove
  554. * @count: number of VLANs
  555. *
  556. * Request that the PF remove one or more VLAN filters from our VSI.
  557. **/
  558. void i40evf_del_vlans(struct i40evf_adapter *adapter)
  559. {
  560. struct virtchnl_vlan_filter_list *vvfl;
  561. struct i40evf_vlan_filter *f, *ftmp;
  562. int len, i = 0, count = 0;
  563. bool more = false;
  564. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  565. /* bail because we already have a command pending */
  566. dev_err(&adapter->pdev->dev, "Cannot remove VLANs, command %d pending\n",
  567. adapter->current_op);
  568. return;
  569. }
  570. list_for_each_entry(f, &adapter->vlan_filter_list, list) {
  571. if (f->remove)
  572. count++;
  573. }
  574. if (!count) {
  575. adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER;
  576. return;
  577. }
  578. adapter->current_op = VIRTCHNL_OP_DEL_VLAN;
  579. len = sizeof(struct virtchnl_vlan_filter_list) +
  580. (count * sizeof(u16));
  581. if (len > I40EVF_MAX_AQ_BUF_SIZE) {
  582. dev_warn(&adapter->pdev->dev, "Too many delete VLAN changes in one request\n");
  583. count = (I40EVF_MAX_AQ_BUF_SIZE -
  584. sizeof(struct virtchnl_vlan_filter_list)) /
  585. sizeof(u16);
  586. len = sizeof(struct virtchnl_vlan_filter_list) +
  587. (count * sizeof(u16));
  588. more = true;
  589. }
  590. vvfl = kzalloc(len, GFP_KERNEL);
  591. if (!vvfl)
  592. return;
  593. vvfl->vsi_id = adapter->vsi_res->vsi_id;
  594. vvfl->num_elements = count;
  595. list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {
  596. if (f->remove) {
  597. vvfl->vlan_id[i] = f->vlan;
  598. i++;
  599. list_del(&f->list);
  600. kfree(f);
  601. if (i == count)
  602. break;
  603. }
  604. }
  605. if (!more)
  606. adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER;
  607. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len);
  608. kfree(vvfl);
  609. }
  610. /**
  611. * i40evf_set_promiscuous
  612. * @adapter: adapter structure
  613. * @flags: bitmask to control unicast/multicast promiscuous.
  614. *
  615. * Request that the PF enable promiscuous mode for our VSI.
  616. **/
  617. void i40evf_set_promiscuous(struct i40evf_adapter *adapter, int flags)
  618. {
  619. struct virtchnl_promisc_info vpi;
  620. int promisc_all;
  621. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  622. /* bail because we already have a command pending */
  623. dev_err(&adapter->pdev->dev, "Cannot set promiscuous mode, command %d pending\n",
  624. adapter->current_op);
  625. return;
  626. }
  627. promisc_all = FLAG_VF_UNICAST_PROMISC |
  628. FLAG_VF_MULTICAST_PROMISC;
  629. if ((flags & promisc_all) == promisc_all) {
  630. adapter->flags |= I40EVF_FLAG_PROMISC_ON;
  631. adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_PROMISC;
  632. dev_info(&adapter->pdev->dev, "Entering promiscuous mode\n");
  633. }
  634. if (flags & FLAG_VF_MULTICAST_PROMISC) {
  635. adapter->flags |= I40EVF_FLAG_ALLMULTI_ON;
  636. adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_ALLMULTI;
  637. dev_info(&adapter->pdev->dev, "Entering multicast promiscuous mode\n");
  638. }
  639. if (!flags) {
  640. adapter->flags &= ~I40EVF_FLAG_PROMISC_ON;
  641. adapter->aq_required &= ~I40EVF_FLAG_AQ_RELEASE_PROMISC;
  642. dev_info(&adapter->pdev->dev, "Leaving promiscuous mode\n");
  643. }
  644. adapter->current_op = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
  645. vpi.vsi_id = adapter->vsi_res->vsi_id;
  646. vpi.flags = flags;
  647. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
  648. (u8 *)&vpi, sizeof(vpi));
  649. }
  650. /**
  651. * i40evf_request_stats
  652. * @adapter: adapter structure
  653. *
  654. * Request VSI statistics from PF.
  655. **/
  656. void i40evf_request_stats(struct i40evf_adapter *adapter)
  657. {
  658. struct virtchnl_queue_select vqs;
  659. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  660. /* no error message, this isn't crucial */
  661. return;
  662. }
  663. adapter->current_op = VIRTCHNL_OP_GET_STATS;
  664. vqs.vsi_id = adapter->vsi_res->vsi_id;
  665. /* queue maps are ignored for this message - only the vsi is used */
  666. if (i40evf_send_pf_msg(adapter, VIRTCHNL_OP_GET_STATS,
  667. (u8 *)&vqs, sizeof(vqs)))
  668. /* if the request failed, don't lock out others */
  669. adapter->current_op = VIRTCHNL_OP_UNKNOWN;
  670. }
  671. /**
  672. * i40evf_get_hena
  673. * @adapter: adapter structure
  674. *
  675. * Request hash enable capabilities from PF
  676. **/
  677. void i40evf_get_hena(struct i40evf_adapter *adapter)
  678. {
  679. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  680. /* bail because we already have a command pending */
  681. dev_err(&adapter->pdev->dev, "Cannot get RSS hash capabilities, command %d pending\n",
  682. adapter->current_op);
  683. return;
  684. }
  685. adapter->current_op = VIRTCHNL_OP_GET_RSS_HENA_CAPS;
  686. adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_HENA;
  687. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_GET_RSS_HENA_CAPS,
  688. NULL, 0);
  689. }
  690. /**
  691. * i40evf_set_hena
  692. * @adapter: adapter structure
  693. *
  694. * Request the PF to set our RSS hash capabilities
  695. **/
  696. void i40evf_set_hena(struct i40evf_adapter *adapter)
  697. {
  698. struct virtchnl_rss_hena vrh;
  699. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  700. /* bail because we already have a command pending */
  701. dev_err(&adapter->pdev->dev, "Cannot set RSS hash enable, command %d pending\n",
  702. adapter->current_op);
  703. return;
  704. }
  705. vrh.hena = adapter->hena;
  706. adapter->current_op = VIRTCHNL_OP_SET_RSS_HENA;
  707. adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_HENA;
  708. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_SET_RSS_HENA,
  709. (u8 *)&vrh, sizeof(vrh));
  710. }
  711. /**
  712. * i40evf_set_rss_key
  713. * @adapter: adapter structure
  714. *
  715. * Request the PF to set our RSS hash key
  716. **/
  717. void i40evf_set_rss_key(struct i40evf_adapter *adapter)
  718. {
  719. struct virtchnl_rss_key *vrk;
  720. int len;
  721. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  722. /* bail because we already have a command pending */
  723. dev_err(&adapter->pdev->dev, "Cannot set RSS key, command %d pending\n",
  724. adapter->current_op);
  725. return;
  726. }
  727. len = sizeof(struct virtchnl_rss_key) +
  728. (adapter->rss_key_size * sizeof(u8)) - 1;
  729. vrk = kzalloc(len, GFP_KERNEL);
  730. if (!vrk)
  731. return;
  732. vrk->vsi_id = adapter->vsi.id;
  733. vrk->key_len = adapter->rss_key_size;
  734. memcpy(vrk->key, adapter->rss_key, adapter->rss_key_size);
  735. adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_KEY;
  736. adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_KEY;
  737. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_KEY,
  738. (u8 *)vrk, len);
  739. kfree(vrk);
  740. }
  741. /**
  742. * i40evf_set_rss_lut
  743. * @adapter: adapter structure
  744. *
  745. * Request the PF to set our RSS lookup table
  746. **/
  747. void i40evf_set_rss_lut(struct i40evf_adapter *adapter)
  748. {
  749. struct virtchnl_rss_lut *vrl;
  750. int len;
  751. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  752. /* bail because we already have a command pending */
  753. dev_err(&adapter->pdev->dev, "Cannot set RSS LUT, command %d pending\n",
  754. adapter->current_op);
  755. return;
  756. }
  757. len = sizeof(struct virtchnl_rss_lut) +
  758. (adapter->rss_lut_size * sizeof(u8)) - 1;
  759. vrl = kzalloc(len, GFP_KERNEL);
  760. if (!vrl)
  761. return;
  762. vrl->vsi_id = adapter->vsi.id;
  763. vrl->lut_entries = adapter->rss_lut_size;
  764. memcpy(vrl->lut, adapter->rss_lut, adapter->rss_lut_size);
  765. adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_LUT;
  766. adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_LUT;
  767. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_LUT,
  768. (u8 *)vrl, len);
  769. kfree(vrl);
  770. }
  771. /**
  772. * i40evf_enable_vlan_stripping
  773. * @adapter: adapter structure
  774. *
  775. * Request VLAN header stripping to be enabled
  776. **/
  777. void i40evf_enable_vlan_stripping(struct i40evf_adapter *adapter)
  778. {
  779. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  780. /* bail because we already have a command pending */
  781. dev_err(&adapter->pdev->dev, "Cannot enable stripping, command %d pending\n",
  782. adapter->current_op);
  783. return;
  784. }
  785. adapter->current_op = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
  786. adapter->aq_required &= ~I40EVF_FLAG_AQ_ENABLE_VLAN_STRIPPING;
  787. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING,
  788. NULL, 0);
  789. }
  790. /**
  791. * i40evf_disable_vlan_stripping
  792. * @adapter: adapter structure
  793. *
  794. * Request VLAN header stripping to be disabled
  795. **/
  796. void i40evf_disable_vlan_stripping(struct i40evf_adapter *adapter)
  797. {
  798. if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
  799. /* bail because we already have a command pending */
  800. dev_err(&adapter->pdev->dev, "Cannot disable stripping, command %d pending\n",
  801. adapter->current_op);
  802. return;
  803. }
  804. adapter->current_op = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
  805. adapter->aq_required &= ~I40EVF_FLAG_AQ_DISABLE_VLAN_STRIPPING;
  806. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING,
  807. NULL, 0);
  808. }
  809. /**
  810. * i40evf_print_link_message - print link up or down
  811. * @adapter: adapter structure
  812. *
  813. * Log a message telling the world of our wonderous link status
  814. */
  815. static void i40evf_print_link_message(struct i40evf_adapter *adapter)
  816. {
  817. struct net_device *netdev = adapter->netdev;
  818. char *speed = "Unknown ";
  819. if (!adapter->link_up) {
  820. netdev_info(netdev, "NIC Link is Down\n");
  821. return;
  822. }
  823. switch (adapter->link_speed) {
  824. case I40E_LINK_SPEED_40GB:
  825. speed = "40 G";
  826. break;
  827. case I40E_LINK_SPEED_25GB:
  828. speed = "25 G";
  829. break;
  830. case I40E_LINK_SPEED_20GB:
  831. speed = "20 G";
  832. break;
  833. case I40E_LINK_SPEED_10GB:
  834. speed = "10 G";
  835. break;
  836. case I40E_LINK_SPEED_1GB:
  837. speed = "1000 M";
  838. break;
  839. case I40E_LINK_SPEED_100MB:
  840. speed = "100 M";
  841. break;
  842. default:
  843. break;
  844. }
  845. netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
  846. }
  847. /**
  848. * i40evf_request_reset
  849. * @adapter: adapter structure
  850. *
  851. * Request that the PF reset this VF. No response is expected.
  852. **/
  853. void i40evf_request_reset(struct i40evf_adapter *adapter)
  854. {
  855. /* Don't check CURRENT_OP - this is always higher priority */
  856. i40evf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0);
  857. adapter->current_op = VIRTCHNL_OP_UNKNOWN;
  858. }
  859. /**
  860. * i40evf_virtchnl_completion
  861. * @adapter: adapter structure
  862. * @v_opcode: opcode sent by PF
  863. * @v_retval: retval sent by PF
  864. * @msg: message sent by PF
  865. * @msglen: message length
  866. *
  867. * Asynchronous completion function for admin queue messages. Rather than busy
  868. * wait, we fire off our requests and assume that no errors will be returned.
  869. * This function handles the reply messages.
  870. **/
  871. void i40evf_virtchnl_completion(struct i40evf_adapter *adapter,
  872. enum virtchnl_ops v_opcode,
  873. i40e_status v_retval,
  874. u8 *msg, u16 msglen)
  875. {
  876. struct net_device *netdev = adapter->netdev;
  877. if (v_opcode == VIRTCHNL_OP_EVENT) {
  878. struct virtchnl_pf_event *vpe =
  879. (struct virtchnl_pf_event *)msg;
  880. switch (vpe->event) {
  881. case VIRTCHNL_EVENT_LINK_CHANGE:
  882. adapter->link_speed =
  883. vpe->event_data.link_event.link_speed;
  884. if (adapter->link_up !=
  885. vpe->event_data.link_event.link_status) {
  886. adapter->link_up =
  887. vpe->event_data.link_event.link_status;
  888. if (adapter->link_up) {
  889. netif_tx_start_all_queues(netdev);
  890. netif_carrier_on(netdev);
  891. } else {
  892. netif_tx_stop_all_queues(netdev);
  893. netif_carrier_off(netdev);
  894. }
  895. i40evf_print_link_message(adapter);
  896. }
  897. break;
  898. case VIRTCHNL_EVENT_RESET_IMPENDING:
  899. dev_info(&adapter->pdev->dev, "PF reset warning received\n");
  900. if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING)) {
  901. adapter->flags |= I40EVF_FLAG_RESET_PENDING;
  902. dev_info(&adapter->pdev->dev, "Scheduling reset task\n");
  903. schedule_work(&adapter->reset_task);
  904. }
  905. break;
  906. default:
  907. dev_err(&adapter->pdev->dev, "Unknown event %d from PF\n",
  908. vpe->event);
  909. break;
  910. }
  911. return;
  912. }
  913. if (v_retval) {
  914. switch (v_opcode) {
  915. case VIRTCHNL_OP_ADD_VLAN:
  916. dev_err(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n",
  917. i40evf_stat_str(&adapter->hw, v_retval));
  918. break;
  919. case VIRTCHNL_OP_ADD_ETH_ADDR:
  920. dev_err(&adapter->pdev->dev, "Failed to add MAC filter, error %s\n",
  921. i40evf_stat_str(&adapter->hw, v_retval));
  922. break;
  923. case VIRTCHNL_OP_DEL_VLAN:
  924. dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n",
  925. i40evf_stat_str(&adapter->hw, v_retval));
  926. break;
  927. case VIRTCHNL_OP_DEL_ETH_ADDR:
  928. dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n",
  929. i40evf_stat_str(&adapter->hw, v_retval));
  930. break;
  931. default:
  932. dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",
  933. v_retval,
  934. i40evf_stat_str(&adapter->hw, v_retval),
  935. v_opcode);
  936. }
  937. }
  938. switch (v_opcode) {
  939. case VIRTCHNL_OP_GET_STATS: {
  940. struct i40e_eth_stats *stats =
  941. (struct i40e_eth_stats *)msg;
  942. netdev->stats.rx_packets = stats->rx_unicast +
  943. stats->rx_multicast +
  944. stats->rx_broadcast;
  945. netdev->stats.tx_packets = stats->tx_unicast +
  946. stats->tx_multicast +
  947. stats->tx_broadcast;
  948. netdev->stats.rx_bytes = stats->rx_bytes;
  949. netdev->stats.tx_bytes = stats->tx_bytes;
  950. netdev->stats.tx_errors = stats->tx_errors;
  951. netdev->stats.rx_dropped = stats->rx_discards;
  952. netdev->stats.tx_dropped = stats->tx_discards;
  953. adapter->current_stats = *stats;
  954. }
  955. break;
  956. case VIRTCHNL_OP_GET_VF_RESOURCES: {
  957. u16 len = sizeof(struct virtchnl_vf_resource) +
  958. I40E_MAX_VF_VSI *
  959. sizeof(struct virtchnl_vsi_resource);
  960. memcpy(adapter->vf_res, msg, min(msglen, len));
  961. i40e_vf_parse_hw_config(&adapter->hw, adapter->vf_res);
  962. /* restore current mac address */
  963. ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
  964. i40evf_process_config(adapter);
  965. }
  966. break;
  967. case VIRTCHNL_OP_ENABLE_QUEUES:
  968. /* enable transmits */
  969. i40evf_irq_enable(adapter, true);
  970. break;
  971. case VIRTCHNL_OP_DISABLE_QUEUES:
  972. i40evf_free_all_tx_resources(adapter);
  973. i40evf_free_all_rx_resources(adapter);
  974. if (adapter->state == __I40EVF_DOWN_PENDING) {
  975. adapter->state = __I40EVF_DOWN;
  976. wake_up(&adapter->down_waitqueue);
  977. }
  978. break;
  979. case VIRTCHNL_OP_VERSION:
  980. case VIRTCHNL_OP_CONFIG_IRQ_MAP:
  981. /* Don't display an error if we get these out of sequence.
  982. * If the firmware needed to get kicked, we'll get these and
  983. * it's no problem.
  984. */
  985. if (v_opcode != adapter->current_op)
  986. return;
  987. break;
  988. case VIRTCHNL_OP_IWARP:
  989. /* Gobble zero-length replies from the PF. They indicate that
  990. * a previous message was received OK, and the client doesn't
  991. * care about that.
  992. */
  993. if (msglen && CLIENT_ENABLED(adapter))
  994. i40evf_notify_client_message(&adapter->vsi,
  995. msg, msglen);
  996. break;
  997. case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
  998. adapter->client_pending &=
  999. ~(BIT(VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP));
  1000. break;
  1001. case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
  1002. struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
  1003. if (msglen == sizeof(*vrh))
  1004. adapter->hena = vrh->hena;
  1005. else
  1006. dev_warn(&adapter->pdev->dev,
  1007. "Invalid message %d from PF\n", v_opcode);
  1008. }
  1009. break;
  1010. case VIRTCHNL_OP_REQUEST_QUEUES: {
  1011. struct virtchnl_vf_res_request *vfres =
  1012. (struct virtchnl_vf_res_request *)msg;
  1013. if (vfres->num_queue_pairs != adapter->num_req_queues) {
  1014. dev_info(&adapter->pdev->dev,
  1015. "Requested %d queues, PF can support %d\n",
  1016. adapter->num_req_queues,
  1017. vfres->num_queue_pairs);
  1018. adapter->num_req_queues = 0;
  1019. adapter->flags &= ~I40EVF_FLAG_REINIT_ITR_NEEDED;
  1020. }
  1021. }
  1022. break;
  1023. default:
  1024. if (adapter->current_op && (v_opcode != adapter->current_op))
  1025. dev_warn(&adapter->pdev->dev, "Expected response %d from PF, received %d\n",
  1026. adapter->current_op, v_opcode);
  1027. break;
  1028. } /* switch v_opcode */
  1029. adapter->current_op = VIRTCHNL_OP_UNKNOWN;
  1030. }