1 // SPDX-License-Identifier: GPL-2.0
2 /*******************************************************************************
4 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
5 * Copyright(c) 2013 - 2014 Intel Corporation.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 * The full GNU General Public License is included in this distribution in
20 * the file called "COPYING".
22 * Contact Information:
23 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26 ******************************************************************************/
29 #include "i40e_prototype.h"
30 #include "i40evf_client.h"
32 /* busy wait delay in msec */
33 #define I40EVF_BUSY_WAIT_DELAY 10
34 #define I40EVF_BUSY_WAIT_COUNT 50
38 * @adapter: adapter structure
39 * @op: virtual channel opcode
40 * @msg: pointer to message buffer
41 * @len: message length
43 * Send message to PF and print status if failure.
45 static int i40evf_send_pf_msg(struct i40evf_adapter *adapter,
46 enum virtchnl_ops op, u8 *msg, u16 len)
48 struct i40e_hw *hw = &adapter->hw;
51 if (adapter->flags & I40EVF_FLAG_PF_COMMS_FAILED)
52 return 0; /* nothing to see here, move along */
54 err = i40e_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL);
56 dev_dbg(&adapter->pdev->dev, "Unable to send opcode %d to PF, err %s, aq_err %s\n",
57 op, i40evf_stat_str(hw, err),
58 i40evf_aq_str(hw, hw->aq.asq_last_status));
64 * @adapter: adapter structure
66 * Send API version admin queue message to the PF. The reply is not checked
67 * in this function. Returns 0 if the message was successfully
68 * sent, or one of the I40E_ADMIN_QUEUE_ERROR_ statuses if not.
70 int i40evf_send_api_ver(struct i40evf_adapter *adapter)
72 struct virtchnl_version_info vvi;
74 vvi.major = VIRTCHNL_VERSION_MAJOR;
75 vvi.minor = VIRTCHNL_VERSION_MINOR;
77 return i40evf_send_pf_msg(adapter, VIRTCHNL_OP_VERSION, (u8 *)&vvi,
82 * i40evf_verify_api_ver
83 * @adapter: adapter structure
85 * Compare API versions with the PF. Must be called after admin queue is
86 * initialized. Returns 0 if API versions match, -EIO if they do not,
87 * I40E_ERR_ADMIN_QUEUE_NO_WORK if the admin queue is empty, and any errors
88 * from the firmware are propagated.
90 int i40evf_verify_api_ver(struct i40evf_adapter *adapter)
92 struct virtchnl_version_info *pf_vvi;
93 struct i40e_hw *hw = &adapter->hw;
94 struct i40e_arq_event_info event;
98 event.buf_len = I40EVF_MAX_AQ_BUF_SIZE;
99 event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
100 if (!event.msg_buf) {
106 err = i40evf_clean_arq_element(hw, &event, NULL);
107 /* When the AQ is empty, i40evf_clean_arq_element will return
108 * nonzero and this loop will terminate.
113 (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
114 if (op == VIRTCHNL_OP_VERSION)
119 err = (i40e_status)le32_to_cpu(event.desc.cookie_low);
123 if (op != VIRTCHNL_OP_VERSION) {
124 dev_info(&adapter->pdev->dev, "Invalid reply type %d from PF\n",
130 pf_vvi = (struct virtchnl_version_info *)event.msg_buf;
131 adapter->pf_version = *pf_vvi;
133 if ((pf_vvi->major > VIRTCHNL_VERSION_MAJOR) ||
134 ((pf_vvi->major == VIRTCHNL_VERSION_MAJOR) &&
135 (pf_vvi->minor > VIRTCHNL_VERSION_MINOR)))
139 kfree(event.msg_buf);
145 * i40evf_send_vf_config_msg
146 * @adapter: adapter structure
148 * Send VF configuration request admin queue message to the PF. The reply
149 * is not checked in this function. Returns 0 if the message was
150 * successfully sent, or one of the I40E_ADMIN_QUEUE_ERROR_ statuses if not.
152 int i40evf_send_vf_config_msg(struct i40evf_adapter *adapter)
156 caps = VIRTCHNL_VF_OFFLOAD_L2 |
157 VIRTCHNL_VF_OFFLOAD_RSS_PF |
158 VIRTCHNL_VF_OFFLOAD_RSS_AQ |
159 VIRTCHNL_VF_OFFLOAD_RSS_REG |
160 VIRTCHNL_VF_OFFLOAD_VLAN |
161 VIRTCHNL_VF_OFFLOAD_WB_ON_ITR |
162 VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 |
163 VIRTCHNL_VF_OFFLOAD_ENCAP |
164 VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM |
165 VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
166 VIRTCHNL_VF_OFFLOAD_ADQ;
168 adapter->current_op = VIRTCHNL_OP_GET_VF_RESOURCES;
169 adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_CONFIG;
170 if (PF_IS_V11(adapter))
171 return i40evf_send_pf_msg(adapter,
172 VIRTCHNL_OP_GET_VF_RESOURCES,
173 (u8 *)&caps, sizeof(caps));
175 return i40evf_send_pf_msg(adapter,
176 VIRTCHNL_OP_GET_VF_RESOURCES,
181 * i40evf_get_vf_config
182 * @hw: pointer to the hardware structure
183 * @len: length of buffer
185 * Get VF configuration from PF and populate hw structure. Must be called after
186 * admin queue is initialized. Busy waits until response is received from PF,
187 * with maximum timeout. Response from PF is returned in the buffer for further
188 * processing by the caller.
190 int i40evf_get_vf_config(struct i40evf_adapter *adapter)
192 struct i40e_hw *hw = &adapter->hw;
193 struct i40e_arq_event_info event;
194 enum virtchnl_ops op;
198 len = sizeof(struct virtchnl_vf_resource) +
199 I40E_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource);
201 event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
202 if (!event.msg_buf) {
208 /* When the AQ is empty, i40evf_clean_arq_element will return
209 * nonzero and this loop will terminate.
211 err = i40evf_clean_arq_element(hw, &event, NULL);
215 (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
216 if (op == VIRTCHNL_OP_GET_VF_RESOURCES)
220 err = (i40e_status)le32_to_cpu(event.desc.cookie_low);
221 memcpy(adapter->vf_res, event.msg_buf, min(event.msg_len, len));
223 i40e_vf_parse_hw_config(hw, adapter->vf_res);
225 kfree(event.msg_buf);
231 * i40evf_configure_queues
232 * @adapter: adapter structure
234 * Request that the PF set up our (previously allocated) queues.
236 void i40evf_configure_queues(struct i40evf_adapter *adapter)
238 struct virtchnl_vsi_queue_config_info *vqci;
239 struct virtchnl_queue_pair_info *vqpi;
240 int pairs = adapter->num_active_queues;
241 int i, len, max_frame = I40E_MAX_RXBUFFER;
243 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
244 /* bail because we already have a command pending */
245 dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n",
246 adapter->current_op);
249 adapter->current_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
250 len = sizeof(struct virtchnl_vsi_queue_config_info) +
251 (sizeof(struct virtchnl_queue_pair_info) * pairs);
252 vqci = kzalloc(len, GFP_KERNEL);
256 /* Limit maximum frame size when jumbo frames is not enabled */
257 if (!(adapter->flags & I40EVF_FLAG_LEGACY_RX) &&
258 (adapter->netdev->mtu <= ETH_DATA_LEN))
259 max_frame = I40E_RXBUFFER_1536 - NET_IP_ALIGN;
261 vqci->vsi_id = adapter->vsi_res->vsi_id;
262 vqci->num_queue_pairs = pairs;
264 /* Size check is not needed here - HW max is 16 queue pairs, and we
265 * can fit info for 31 of them into the AQ buffer before it overflows.
267 for (i = 0; i < pairs; i++) {
268 vqpi->txq.vsi_id = vqci->vsi_id;
269 vqpi->txq.queue_id = i;
270 vqpi->txq.ring_len = adapter->tx_rings[i].count;
271 vqpi->txq.dma_ring_addr = adapter->tx_rings[i].dma;
272 vqpi->rxq.vsi_id = vqci->vsi_id;
273 vqpi->rxq.queue_id = i;
274 vqpi->rxq.ring_len = adapter->rx_rings[i].count;
275 vqpi->rxq.dma_ring_addr = adapter->rx_rings[i].dma;
276 vqpi->rxq.max_pkt_size = max_frame;
277 vqpi->rxq.databuffer_size =
278 ALIGN(adapter->rx_rings[i].rx_buf_len,
279 BIT_ULL(I40E_RXQ_CTX_DBUFF_SHIFT));
283 adapter->aq_required &= ~I40EVF_FLAG_AQ_CONFIGURE_QUEUES;
284 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
290 * i40evf_enable_queues
291 * @adapter: adapter structure
293 * Request that the PF enable all of our queues.
295 void i40evf_enable_queues(struct i40evf_adapter *adapter)
297 struct virtchnl_queue_select vqs;
299 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
300 /* bail because we already have a command pending */
301 dev_err(&adapter->pdev->dev, "Cannot enable queues, command %d pending\n",
302 adapter->current_op);
305 adapter->current_op = VIRTCHNL_OP_ENABLE_QUEUES;
306 vqs.vsi_id = adapter->vsi_res->vsi_id;
307 vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
308 vqs.rx_queues = vqs.tx_queues;
309 adapter->aq_required &= ~I40EVF_FLAG_AQ_ENABLE_QUEUES;
310 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_QUEUES,
311 (u8 *)&vqs, sizeof(vqs));
315 * i40evf_disable_queues
316 * @adapter: adapter structure
318 * Request that the PF disable all of our queues.
320 void i40evf_disable_queues(struct i40evf_adapter *adapter)
322 struct virtchnl_queue_select vqs;
324 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
325 /* bail because we already have a command pending */
326 dev_err(&adapter->pdev->dev, "Cannot disable queues, command %d pending\n",
327 adapter->current_op);
330 adapter->current_op = VIRTCHNL_OP_DISABLE_QUEUES;
331 vqs.vsi_id = adapter->vsi_res->vsi_id;
332 vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
333 vqs.rx_queues = vqs.tx_queues;
334 adapter->aq_required &= ~I40EVF_FLAG_AQ_DISABLE_QUEUES;
335 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_QUEUES,
336 (u8 *)&vqs, sizeof(vqs));
341 * @adapter: adapter structure
343 * Request that the PF map queues to interrupt vectors. Misc causes, including
344 * admin queue, are always mapped to vector 0.
346 void i40evf_map_queues(struct i40evf_adapter *adapter)
348 struct virtchnl_irq_map_info *vimi;
349 struct virtchnl_vector_map *vecmap;
350 int v_idx, q_vectors, len;
351 struct i40e_q_vector *q_vector;
353 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
354 /* bail because we already have a command pending */
355 dev_err(&adapter->pdev->dev, "Cannot map queues to vectors, command %d pending\n",
356 adapter->current_op);
359 adapter->current_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
361 q_vectors = adapter->num_msix_vectors - NONQ_VECS;
363 len = sizeof(struct virtchnl_irq_map_info) +
364 (adapter->num_msix_vectors *
365 sizeof(struct virtchnl_vector_map));
366 vimi = kzalloc(len, GFP_KERNEL);
370 vimi->num_vectors = adapter->num_msix_vectors;
371 /* Queue vectors first */
372 for (v_idx = 0; v_idx < q_vectors; v_idx++) {
373 q_vector = &adapter->q_vectors[v_idx];
374 vecmap = &vimi->vecmap[v_idx];
376 vecmap->vsi_id = adapter->vsi_res->vsi_id;
377 vecmap->vector_id = v_idx + NONQ_VECS;
378 vecmap->txq_map = q_vector->ring_mask;
379 vecmap->rxq_map = q_vector->ring_mask;
380 vecmap->rxitr_idx = I40E_RX_ITR;
381 vecmap->txitr_idx = I40E_TX_ITR;
383 /* Misc vector last - this is only for AdminQ messages */
384 vecmap = &vimi->vecmap[v_idx];
385 vecmap->vsi_id = adapter->vsi_res->vsi_id;
386 vecmap->vector_id = 0;
390 adapter->aq_required &= ~I40EVF_FLAG_AQ_MAP_VECTORS;
391 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_IRQ_MAP,
397 * i40evf_request_queues
398 * @adapter: adapter structure
399 * @num: number of requested queues
401 * We get a default number of queues from the PF. This enables us to request a
402 * different number. Returns 0 on success, negative on failure
404 int i40evf_request_queues(struct i40evf_adapter *adapter, int num)
406 struct virtchnl_vf_res_request vfres;
408 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
409 /* bail because we already have a command pending */
410 dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n",
411 adapter->current_op);
415 vfres.num_queue_pairs = num;
417 adapter->current_op = VIRTCHNL_OP_REQUEST_QUEUES;
418 adapter->flags |= I40EVF_FLAG_REINIT_ITR_NEEDED;
419 return i40evf_send_pf_msg(adapter, VIRTCHNL_OP_REQUEST_QUEUES,
420 (u8 *)&vfres, sizeof(vfres));
424 * i40evf_add_ether_addrs
425 * @adapter: adapter structure
426 * @addrs: the MAC address filters to add (contiguous)
427 * @count: number of filters
429 * Request that the PF add one or more addresses to our filters.
431 void i40evf_add_ether_addrs(struct i40evf_adapter *adapter)
433 struct virtchnl_ether_addr_list *veal;
434 int len, i = 0, count = 0;
435 struct i40evf_mac_filter *f;
438 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
439 /* bail because we already have a command pending */
440 dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n",
441 adapter->current_op);
445 spin_lock_bh(&adapter->mac_vlan_list_lock);
447 list_for_each_entry(f, &adapter->mac_filter_list, list) {
452 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER;
453 spin_unlock_bh(&adapter->mac_vlan_list_lock);
456 adapter->current_op = VIRTCHNL_OP_ADD_ETH_ADDR;
458 len = sizeof(struct virtchnl_ether_addr_list) +
459 (count * sizeof(struct virtchnl_ether_addr));
460 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
461 dev_warn(&adapter->pdev->dev, "Too many add MAC changes in one request\n");
462 count = (I40EVF_MAX_AQ_BUF_SIZE -
463 sizeof(struct virtchnl_ether_addr_list)) /
464 sizeof(struct virtchnl_ether_addr);
465 len = sizeof(struct virtchnl_ether_addr_list) +
466 (count * sizeof(struct virtchnl_ether_addr));
470 veal = kzalloc(len, GFP_ATOMIC);
472 spin_unlock_bh(&adapter->mac_vlan_list_lock);
476 veal->vsi_id = adapter->vsi_res->vsi_id;
477 veal->num_elements = count;
478 list_for_each_entry(f, &adapter->mac_filter_list, list) {
480 ether_addr_copy(veal->list[i].addr, f->macaddr);
488 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_MAC_FILTER;
490 spin_unlock_bh(&adapter->mac_vlan_list_lock);
492 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR,
498 * i40evf_del_ether_addrs
499 * @adapter: adapter structure
500 * @addrs: the MAC address filters to remove (contiguous)
501 * @count: number of filtes
503 * Request that the PF remove one or more addresses from our filters.
505 void i40evf_del_ether_addrs(struct i40evf_adapter *adapter)
507 struct virtchnl_ether_addr_list *veal;
508 struct i40evf_mac_filter *f, *ftmp;
509 int len, i = 0, count = 0;
512 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
513 /* bail because we already have a command pending */
514 dev_err(&adapter->pdev->dev, "Cannot remove filters, command %d pending\n",
515 adapter->current_op);
519 spin_lock_bh(&adapter->mac_vlan_list_lock);
521 list_for_each_entry(f, &adapter->mac_filter_list, list) {
526 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER;
527 spin_unlock_bh(&adapter->mac_vlan_list_lock);
530 adapter->current_op = VIRTCHNL_OP_DEL_ETH_ADDR;
532 len = sizeof(struct virtchnl_ether_addr_list) +
533 (count * sizeof(struct virtchnl_ether_addr));
534 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
535 dev_warn(&adapter->pdev->dev, "Too many delete MAC changes in one request\n");
536 count = (I40EVF_MAX_AQ_BUF_SIZE -
537 sizeof(struct virtchnl_ether_addr_list)) /
538 sizeof(struct virtchnl_ether_addr);
539 len = sizeof(struct virtchnl_ether_addr_list) +
540 (count * sizeof(struct virtchnl_ether_addr));
543 veal = kzalloc(len, GFP_ATOMIC);
545 spin_unlock_bh(&adapter->mac_vlan_list_lock);
549 veal->vsi_id = adapter->vsi_res->vsi_id;
550 veal->num_elements = count;
551 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) {
553 ether_addr_copy(veal->list[i].addr, f->macaddr);
562 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_MAC_FILTER;
564 spin_unlock_bh(&adapter->mac_vlan_list_lock);
566 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_ETH_ADDR,
573 * @adapter: adapter structure
574 * @vlans: the VLANs to add
575 * @count: number of VLANs
577 * Request that the PF add one or more VLAN filters to our VSI.
579 void i40evf_add_vlans(struct i40evf_adapter *adapter)
581 struct virtchnl_vlan_filter_list *vvfl;
582 int len, i = 0, count = 0;
583 struct i40evf_vlan_filter *f;
586 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
587 /* bail because we already have a command pending */
588 dev_err(&adapter->pdev->dev, "Cannot add VLANs, command %d pending\n",
589 adapter->current_op);
593 spin_lock_bh(&adapter->mac_vlan_list_lock);
595 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
600 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER;
601 spin_unlock_bh(&adapter->mac_vlan_list_lock);
604 adapter->current_op = VIRTCHNL_OP_ADD_VLAN;
606 len = sizeof(struct virtchnl_vlan_filter_list) +
607 (count * sizeof(u16));
608 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
609 dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n");
610 count = (I40EVF_MAX_AQ_BUF_SIZE -
611 sizeof(struct virtchnl_vlan_filter_list)) /
613 len = sizeof(struct virtchnl_vlan_filter_list) +
614 (count * sizeof(u16));
617 vvfl = kzalloc(len, GFP_ATOMIC);
619 spin_unlock_bh(&adapter->mac_vlan_list_lock);
623 vvfl->vsi_id = adapter->vsi_res->vsi_id;
624 vvfl->num_elements = count;
625 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
627 vvfl->vlan_id[i] = f->vlan;
635 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_VLAN_FILTER;
637 spin_unlock_bh(&adapter->mac_vlan_list_lock);
639 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);
645 * @adapter: adapter structure
646 * @vlans: the VLANs to remove
647 * @count: number of VLANs
649 * Request that the PF remove one or more VLAN filters from our VSI.
651 void i40evf_del_vlans(struct i40evf_adapter *adapter)
653 struct virtchnl_vlan_filter_list *vvfl;
654 struct i40evf_vlan_filter *f, *ftmp;
655 int len, i = 0, count = 0;
658 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
659 /* bail because we already have a command pending */
660 dev_err(&adapter->pdev->dev, "Cannot remove VLANs, command %d pending\n",
661 adapter->current_op);
665 spin_lock_bh(&adapter->mac_vlan_list_lock);
667 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
672 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER;
673 spin_unlock_bh(&adapter->mac_vlan_list_lock);
676 adapter->current_op = VIRTCHNL_OP_DEL_VLAN;
678 len = sizeof(struct virtchnl_vlan_filter_list) +
679 (count * sizeof(u16));
680 if (len > I40EVF_MAX_AQ_BUF_SIZE) {
681 dev_warn(&adapter->pdev->dev, "Too many delete VLAN changes in one request\n");
682 count = (I40EVF_MAX_AQ_BUF_SIZE -
683 sizeof(struct virtchnl_vlan_filter_list)) /
685 len = sizeof(struct virtchnl_vlan_filter_list) +
686 (count * sizeof(u16));
689 vvfl = kzalloc(len, GFP_ATOMIC);
691 spin_unlock_bh(&adapter->mac_vlan_list_lock);
695 vvfl->vsi_id = adapter->vsi_res->vsi_id;
696 vvfl->num_elements = count;
697 list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {
699 vvfl->vlan_id[i] = f->vlan;
708 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_VLAN_FILTER;
710 spin_unlock_bh(&adapter->mac_vlan_list_lock);
712 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len);
717 * i40evf_set_promiscuous
718 * @adapter: adapter structure
719 * @flags: bitmask to control unicast/multicast promiscuous.
721 * Request that the PF enable promiscuous mode for our VSI.
723 void i40evf_set_promiscuous(struct i40evf_adapter *adapter, int flags)
725 struct virtchnl_promisc_info vpi;
728 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
729 /* bail because we already have a command pending */
730 dev_err(&adapter->pdev->dev, "Cannot set promiscuous mode, command %d pending\n",
731 adapter->current_op);
735 promisc_all = FLAG_VF_UNICAST_PROMISC |
736 FLAG_VF_MULTICAST_PROMISC;
737 if ((flags & promisc_all) == promisc_all) {
738 adapter->flags |= I40EVF_FLAG_PROMISC_ON;
739 adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_PROMISC;
740 dev_info(&adapter->pdev->dev, "Entering promiscuous mode\n");
743 if (flags & FLAG_VF_MULTICAST_PROMISC) {
744 adapter->flags |= I40EVF_FLAG_ALLMULTI_ON;
745 adapter->aq_required &= ~I40EVF_FLAG_AQ_REQUEST_ALLMULTI;
746 dev_info(&adapter->pdev->dev, "Entering multicast promiscuous mode\n");
750 adapter->flags &= ~(I40EVF_FLAG_PROMISC_ON |
751 I40EVF_FLAG_ALLMULTI_ON);
752 adapter->aq_required &= ~(I40EVF_FLAG_AQ_RELEASE_PROMISC |
753 I40EVF_FLAG_AQ_RELEASE_ALLMULTI);
754 dev_info(&adapter->pdev->dev, "Leaving promiscuous mode\n");
757 adapter->current_op = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
758 vpi.vsi_id = adapter->vsi_res->vsi_id;
760 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
761 (u8 *)&vpi, sizeof(vpi));
765 * i40evf_request_stats
766 * @adapter: adapter structure
768 * Request VSI statistics from PF.
770 void i40evf_request_stats(struct i40evf_adapter *adapter)
772 struct virtchnl_queue_select vqs;
774 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
775 /* no error message, this isn't crucial */
778 adapter->current_op = VIRTCHNL_OP_GET_STATS;
779 vqs.vsi_id = adapter->vsi_res->vsi_id;
780 /* queue maps are ignored for this message - only the vsi is used */
781 if (i40evf_send_pf_msg(adapter, VIRTCHNL_OP_GET_STATS,
782 (u8 *)&vqs, sizeof(vqs)))
783 /* if the request failed, don't lock out others */
784 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
789 * @adapter: adapter structure
791 * Request hash enable capabilities from PF
793 void i40evf_get_hena(struct i40evf_adapter *adapter)
795 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
796 /* bail because we already have a command pending */
797 dev_err(&adapter->pdev->dev, "Cannot get RSS hash capabilities, command %d pending\n",
798 adapter->current_op);
801 adapter->current_op = VIRTCHNL_OP_GET_RSS_HENA_CAPS;
802 adapter->aq_required &= ~I40EVF_FLAG_AQ_GET_HENA;
803 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_GET_RSS_HENA_CAPS,
809 * @adapter: adapter structure
811 * Request the PF to set our RSS hash capabilities
813 void i40evf_set_hena(struct i40evf_adapter *adapter)
815 struct virtchnl_rss_hena vrh;
817 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
818 /* bail because we already have a command pending */
819 dev_err(&adapter->pdev->dev, "Cannot set RSS hash enable, command %d pending\n",
820 adapter->current_op);
823 vrh.hena = adapter->hena;
824 adapter->current_op = VIRTCHNL_OP_SET_RSS_HENA;
825 adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_HENA;
826 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_SET_RSS_HENA,
827 (u8 *)&vrh, sizeof(vrh));
832 * @adapter: adapter structure
834 * Request the PF to set our RSS hash key
836 void i40evf_set_rss_key(struct i40evf_adapter *adapter)
838 struct virtchnl_rss_key *vrk;
841 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
842 /* bail because we already have a command pending */
843 dev_err(&adapter->pdev->dev, "Cannot set RSS key, command %d pending\n",
844 adapter->current_op);
847 len = sizeof(struct virtchnl_rss_key) +
848 (adapter->rss_key_size * sizeof(u8)) - 1;
849 vrk = kzalloc(len, GFP_KERNEL);
852 vrk->vsi_id = adapter->vsi.id;
853 vrk->key_len = adapter->rss_key_size;
854 memcpy(vrk->key, adapter->rss_key, adapter->rss_key_size);
856 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_KEY;
857 adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_KEY;
858 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_KEY,
865 * @adapter: adapter structure
867 * Request the PF to set our RSS lookup table
869 void i40evf_set_rss_lut(struct i40evf_adapter *adapter)
871 struct virtchnl_rss_lut *vrl;
874 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
875 /* bail because we already have a command pending */
876 dev_err(&adapter->pdev->dev, "Cannot set RSS LUT, command %d pending\n",
877 adapter->current_op);
880 len = sizeof(struct virtchnl_rss_lut) +
881 (adapter->rss_lut_size * sizeof(u8)) - 1;
882 vrl = kzalloc(len, GFP_KERNEL);
885 vrl->vsi_id = adapter->vsi.id;
886 vrl->lut_entries = adapter->rss_lut_size;
887 memcpy(vrl->lut, adapter->rss_lut, adapter->rss_lut_size);
888 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_LUT;
889 adapter->aq_required &= ~I40EVF_FLAG_AQ_SET_RSS_LUT;
890 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_LUT,
896 * i40evf_enable_vlan_stripping
897 * @adapter: adapter structure
899 * Request VLAN header stripping to be enabled
901 void i40evf_enable_vlan_stripping(struct i40evf_adapter *adapter)
903 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
904 /* bail because we already have a command pending */
905 dev_err(&adapter->pdev->dev, "Cannot enable stripping, command %d pending\n",
906 adapter->current_op);
909 adapter->current_op = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
910 adapter->aq_required &= ~I40EVF_FLAG_AQ_ENABLE_VLAN_STRIPPING;
911 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING,
916 * i40evf_disable_vlan_stripping
917 * @adapter: adapter structure
919 * Request VLAN header stripping to be disabled
921 void i40evf_disable_vlan_stripping(struct i40evf_adapter *adapter)
923 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
924 /* bail because we already have a command pending */
925 dev_err(&adapter->pdev->dev, "Cannot disable stripping, command %d pending\n",
926 adapter->current_op);
929 adapter->current_op = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
930 adapter->aq_required &= ~I40EVF_FLAG_AQ_DISABLE_VLAN_STRIPPING;
931 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING,
936 * i40evf_print_link_message - print link up or down
937 * @adapter: adapter structure
939 * Log a message telling the world of our wonderous link status
941 static void i40evf_print_link_message(struct i40evf_adapter *adapter)
943 struct net_device *netdev = adapter->netdev;
944 char *speed = "Unknown ";
946 if (!adapter->link_up) {
947 netdev_info(netdev, "NIC Link is Down\n");
951 switch (adapter->link_speed) {
952 case I40E_LINK_SPEED_40GB:
955 case I40E_LINK_SPEED_25GB:
958 case I40E_LINK_SPEED_20GB:
961 case I40E_LINK_SPEED_10GB:
964 case I40E_LINK_SPEED_1GB:
967 case I40E_LINK_SPEED_100MB:
974 netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
978 * i40evf_enable_channel
979 * @adapter: adapter structure
981 * Request that the PF enable channels as specified by
982 * the user via tc tool.
984 void i40evf_enable_channels(struct i40evf_adapter *adapter)
986 struct virtchnl_tc_info *vti = NULL;
990 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
991 /* bail because we already have a command pending */
992 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
993 adapter->current_op);
997 len = (adapter->num_tc * sizeof(struct virtchnl_channel_info)) +
998 sizeof(struct virtchnl_tc_info);
1000 vti = kzalloc(len, GFP_KERNEL);
1003 vti->num_tc = adapter->num_tc;
1004 for (i = 0; i < vti->num_tc; i++) {
1005 vti->list[i].count = adapter->ch_config.ch_info[i].count;
1006 vti->list[i].offset = adapter->ch_config.ch_info[i].offset;
1007 vti->list[i].pad = 0;
1008 vti->list[i].max_tx_rate =
1009 adapter->ch_config.ch_info[i].max_tx_rate;
1012 adapter->ch_config.state = __I40EVF_TC_RUNNING;
1013 adapter->flags |= I40EVF_FLAG_REINIT_ITR_NEEDED;
1014 adapter->current_op = VIRTCHNL_OP_ENABLE_CHANNELS;
1015 adapter->aq_required &= ~I40EVF_FLAG_AQ_ENABLE_CHANNELS;
1016 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_CHANNELS,
1022 * i40evf_disable_channel
1023 * @adapter: adapter structure
1025 * Request that the PF disable channels that are configured
1027 void i40evf_disable_channels(struct i40evf_adapter *adapter)
1029 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1030 /* bail because we already have a command pending */
1031 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
1032 adapter->current_op);
1036 adapter->ch_config.state = __I40EVF_TC_INVALID;
1037 adapter->flags |= I40EVF_FLAG_REINIT_ITR_NEEDED;
1038 adapter->current_op = VIRTCHNL_OP_DISABLE_CHANNELS;
1039 adapter->aq_required &= ~I40EVF_FLAG_AQ_DISABLE_CHANNELS;
1040 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_CHANNELS,
1045 * i40evf_print_cloud_filter
1046 * @adapter: adapter structure
1047 * @f: cloud filter to print
1049 * Print the cloud filter
1051 static void i40evf_print_cloud_filter(struct i40evf_adapter *adapter,
1052 struct virtchnl_filter *f)
1054 switch (f->flow_type) {
1055 case VIRTCHNL_TCP_V4_FLOW:
1056 dev_info(&adapter->pdev->dev, "dst_mac: %pM src_mac: %pM vlan_id: %hu dst_ip: %pI4 src_ip %pI4 dst_port %hu src_port %hu\n",
1057 &f->data.tcp_spec.dst_mac,
1058 &f->data.tcp_spec.src_mac,
1059 ntohs(f->data.tcp_spec.vlan_id),
1060 &f->data.tcp_spec.dst_ip[0],
1061 &f->data.tcp_spec.src_ip[0],
1062 ntohs(f->data.tcp_spec.dst_port),
1063 ntohs(f->data.tcp_spec.src_port));
1065 case VIRTCHNL_TCP_V6_FLOW:
1066 dev_info(&adapter->pdev->dev, "dst_mac: %pM src_mac: %pM vlan_id: %hu dst_ip: %pI6 src_ip %pI6 dst_port %hu src_port %hu\n",
1067 &f->data.tcp_spec.dst_mac,
1068 &f->data.tcp_spec.src_mac,
1069 ntohs(f->data.tcp_spec.vlan_id),
1070 &f->data.tcp_spec.dst_ip,
1071 &f->data.tcp_spec.src_ip,
1072 ntohs(f->data.tcp_spec.dst_port),
1073 ntohs(f->data.tcp_spec.src_port));
1079 * i40evf_add_cloud_filter
1080 * @adapter: adapter structure
1082 * Request that the PF add cloud filters as specified
1083 * by the user via tc tool.
1085 void i40evf_add_cloud_filter(struct i40evf_adapter *adapter)
1087 struct i40evf_cloud_filter *cf;
1088 struct virtchnl_filter *f;
1089 int len = 0, count = 0;
1091 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1092 /* bail because we already have a command pending */
1093 dev_err(&adapter->pdev->dev, "Cannot add cloud filter, command %d pending\n",
1094 adapter->current_op);
1097 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1104 adapter->aq_required &= ~I40EVF_FLAG_AQ_ADD_CLOUD_FILTER;
1107 adapter->current_op = VIRTCHNL_OP_ADD_CLOUD_FILTER;
1109 len = sizeof(struct virtchnl_filter);
1110 f = kzalloc(len, GFP_KERNEL);
1114 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1116 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1118 cf->state = __I40EVF_CF_ADD_PENDING;
1119 i40evf_send_pf_msg(adapter,
1120 VIRTCHNL_OP_ADD_CLOUD_FILTER,
1128 * i40evf_del_cloud_filter
1129 * @adapter: adapter structure
1131 * Request that the PF delete cloud filters as specified
1132 * by the user via tc tool.
1134 void i40evf_del_cloud_filter(struct i40evf_adapter *adapter)
1136 struct i40evf_cloud_filter *cf, *cftmp;
1137 struct virtchnl_filter *f;
1138 int len = 0, count = 0;
1140 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1141 /* bail because we already have a command pending */
1142 dev_err(&adapter->pdev->dev, "Cannot remove cloud filter, command %d pending\n",
1143 adapter->current_op);
1146 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1153 adapter->aq_required &= ~I40EVF_FLAG_AQ_DEL_CLOUD_FILTER;
1156 adapter->current_op = VIRTCHNL_OP_DEL_CLOUD_FILTER;
1158 len = sizeof(struct virtchnl_filter);
1159 f = kzalloc(len, GFP_KERNEL);
1163 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) {
1165 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1167 cf->state = __I40EVF_CF_DEL_PENDING;
1168 i40evf_send_pf_msg(adapter,
1169 VIRTCHNL_OP_DEL_CLOUD_FILTER,
1177 * i40evf_request_reset
1178 * @adapter: adapter structure
1180 * Request that the PF reset this VF. No response is expected.
1182 void i40evf_request_reset(struct i40evf_adapter *adapter)
1184 /* Don't check CURRENT_OP - this is always higher priority */
1185 i40evf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0);
1186 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
1190 * i40evf_virtchnl_completion
1191 * @adapter: adapter structure
1192 * @v_opcode: opcode sent by PF
1193 * @v_retval: retval sent by PF
1194 * @msg: message sent by PF
1195 * @msglen: message length
1197 * Asynchronous completion function for admin queue messages. Rather than busy
1198 * wait, we fire off our requests and assume that no errors will be returned.
1199 * This function handles the reply messages.
1201 void i40evf_virtchnl_completion(struct i40evf_adapter *adapter,
1202 enum virtchnl_ops v_opcode,
1203 i40e_status v_retval,
1204 u8 *msg, u16 msglen)
1206 struct net_device *netdev = adapter->netdev;
1208 if (v_opcode == VIRTCHNL_OP_EVENT) {
1209 struct virtchnl_pf_event *vpe =
1210 (struct virtchnl_pf_event *)msg;
1211 bool link_up = vpe->event_data.link_event.link_status;
1212 switch (vpe->event) {
1213 case VIRTCHNL_EVENT_LINK_CHANGE:
1214 adapter->link_speed =
1215 vpe->event_data.link_event.link_speed;
1217 /* we've already got the right link status, bail */
1218 if (adapter->link_up == link_up)
1222 /* If we get link up message and start queues
1223 * before our queues are configured it will
1224 * trigger a TX hang. In that case, just ignore
1225 * the link status message,we'll get another one
1226 * after we enable queues and actually prepared
1229 if (adapter->state != __I40EVF_RUNNING)
1232 /* For ADq enabled VF, we reconfigure VSIs and
1233 * re-allocate queues. Hence wait till all
1234 * queues are enabled.
1236 if (adapter->flags &
1237 I40EVF_FLAG_QUEUES_DISABLED)
1241 adapter->link_up = link_up;
1243 netif_tx_start_all_queues(netdev);
1244 netif_carrier_on(netdev);
1246 netif_tx_stop_all_queues(netdev);
1247 netif_carrier_off(netdev);
1249 i40evf_print_link_message(adapter);
1251 case VIRTCHNL_EVENT_RESET_IMPENDING:
1252 dev_info(&adapter->pdev->dev, "Reset warning received from the PF\n");
1253 if (!(adapter->flags & I40EVF_FLAG_RESET_PENDING)) {
1254 adapter->flags |= I40EVF_FLAG_RESET_PENDING;
1255 dev_info(&adapter->pdev->dev, "Scheduling reset task\n");
1256 schedule_work(&adapter->reset_task);
1260 dev_err(&adapter->pdev->dev, "Unknown event %d from PF\n",
1268 case VIRTCHNL_OP_ADD_VLAN:
1269 dev_err(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n",
1270 i40evf_stat_str(&adapter->hw, v_retval));
1272 case VIRTCHNL_OP_ADD_ETH_ADDR:
1273 dev_err(&adapter->pdev->dev, "Failed to add MAC filter, error %s\n",
1274 i40evf_stat_str(&adapter->hw, v_retval));
1276 case VIRTCHNL_OP_DEL_VLAN:
1277 dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n",
1278 i40evf_stat_str(&adapter->hw, v_retval));
1280 case VIRTCHNL_OP_DEL_ETH_ADDR:
1281 dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n",
1282 i40evf_stat_str(&adapter->hw, v_retval));
1284 case VIRTCHNL_OP_ENABLE_CHANNELS:
1285 dev_err(&adapter->pdev->dev, "Failed to configure queue channels, error %s\n",
1286 i40evf_stat_str(&adapter->hw, v_retval));
1287 adapter->flags &= ~I40EVF_FLAG_REINIT_ITR_NEEDED;
1288 adapter->ch_config.state = __I40EVF_TC_INVALID;
1289 netdev_reset_tc(netdev);
1290 netif_tx_start_all_queues(netdev);
1292 case VIRTCHNL_OP_DISABLE_CHANNELS:
1293 dev_err(&adapter->pdev->dev, "Failed to disable queue channels, error %s\n",
1294 i40evf_stat_str(&adapter->hw, v_retval));
1295 adapter->flags &= ~I40EVF_FLAG_REINIT_ITR_NEEDED;
1296 adapter->ch_config.state = __I40EVF_TC_RUNNING;
1297 netif_tx_start_all_queues(netdev);
1299 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1300 struct i40evf_cloud_filter *cf, *cftmp;
1302 list_for_each_entry_safe(cf, cftmp,
1303 &adapter->cloud_filter_list,
1305 if (cf->state == __I40EVF_CF_ADD_PENDING) {
1306 cf->state = __I40EVF_CF_INVALID;
1307 dev_info(&adapter->pdev->dev, "Failed to add cloud filter, error %s\n",
1308 i40evf_stat_str(&adapter->hw,
1310 i40evf_print_cloud_filter(adapter,
1312 list_del(&cf->list);
1314 adapter->num_cloud_filters--;
1319 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1320 struct i40evf_cloud_filter *cf;
1322 list_for_each_entry(cf, &adapter->cloud_filter_list,
1324 if (cf->state == __I40EVF_CF_DEL_PENDING) {
1325 cf->state = __I40EVF_CF_ACTIVE;
1326 dev_info(&adapter->pdev->dev, "Failed to del cloud filter, error %s\n",
1327 i40evf_stat_str(&adapter->hw,
1329 i40evf_print_cloud_filter(adapter,
1336 dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",
1338 i40evf_stat_str(&adapter->hw, v_retval),
1343 case VIRTCHNL_OP_GET_STATS: {
1344 struct i40e_eth_stats *stats =
1345 (struct i40e_eth_stats *)msg;
1346 netdev->stats.rx_packets = stats->rx_unicast +
1347 stats->rx_multicast +
1348 stats->rx_broadcast;
1349 netdev->stats.tx_packets = stats->tx_unicast +
1350 stats->tx_multicast +
1351 stats->tx_broadcast;
1352 netdev->stats.rx_bytes = stats->rx_bytes;
1353 netdev->stats.tx_bytes = stats->tx_bytes;
1354 netdev->stats.tx_errors = stats->tx_errors;
1355 netdev->stats.rx_dropped = stats->rx_discards;
1356 netdev->stats.tx_dropped = stats->tx_discards;
1357 adapter->current_stats = *stats;
1360 case VIRTCHNL_OP_GET_VF_RESOURCES: {
1361 u16 len = sizeof(struct virtchnl_vf_resource) +
1363 sizeof(struct virtchnl_vsi_resource);
1364 memcpy(adapter->vf_res, msg, min(msglen, len));
1365 i40e_vf_parse_hw_config(&adapter->hw, adapter->vf_res);
1366 /* restore current mac address */
1367 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
1368 i40evf_process_config(adapter);
1371 case VIRTCHNL_OP_ENABLE_QUEUES:
1372 /* enable transmits */
1373 i40evf_irq_enable(adapter, true);
1374 adapter->flags &= ~I40EVF_FLAG_QUEUES_DISABLED;
1376 case VIRTCHNL_OP_DISABLE_QUEUES:
1377 i40evf_free_all_tx_resources(adapter);
1378 i40evf_free_all_rx_resources(adapter);
1379 if (adapter->state == __I40EVF_DOWN_PENDING) {
1380 adapter->state = __I40EVF_DOWN;
1381 wake_up(&adapter->down_waitqueue);
1384 case VIRTCHNL_OP_VERSION:
1385 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1386 /* Don't display an error if we get these out of sequence.
1387 * If the firmware needed to get kicked, we'll get these and
1390 if (v_opcode != adapter->current_op)
1393 case VIRTCHNL_OP_IWARP:
1394 /* Gobble zero-length replies from the PF. They indicate that
1395 * a previous message was received OK, and the client doesn't
1398 if (msglen && CLIENT_ENABLED(adapter))
1399 i40evf_notify_client_message(&adapter->vsi,
1403 case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
1404 adapter->client_pending &=
1405 ~(BIT(VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP));
1407 case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
1408 struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
1409 if (msglen == sizeof(*vrh))
1410 adapter->hena = vrh->hena;
1412 dev_warn(&adapter->pdev->dev,
1413 "Invalid message %d from PF\n", v_opcode);
1416 case VIRTCHNL_OP_REQUEST_QUEUES: {
1417 struct virtchnl_vf_res_request *vfres =
1418 (struct virtchnl_vf_res_request *)msg;
1419 if (vfres->num_queue_pairs != adapter->num_req_queues) {
1420 dev_info(&adapter->pdev->dev,
1421 "Requested %d queues, PF can support %d\n",
1422 adapter->num_req_queues,
1423 vfres->num_queue_pairs);
1424 adapter->num_req_queues = 0;
1425 adapter->flags &= ~I40EVF_FLAG_REINIT_ITR_NEEDED;
1429 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1430 struct i40evf_cloud_filter *cf;
1432 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1433 if (cf->state == __I40EVF_CF_ADD_PENDING)
1434 cf->state = __I40EVF_CF_ACTIVE;
1438 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1439 struct i40evf_cloud_filter *cf, *cftmp;
1441 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list,
1443 if (cf->state == __I40EVF_CF_DEL_PENDING) {
1444 cf->state = __I40EVF_CF_INVALID;
1445 list_del(&cf->list);
1447 adapter->num_cloud_filters--;
1453 if (adapter->current_op && (v_opcode != adapter->current_op))
1454 dev_warn(&adapter->pdev->dev, "Expected response %d from PF, received %d\n",
1455 adapter->current_op, v_opcode);
1457 } /* switch v_opcode */
1458 adapter->current_op = VIRTCHNL_OP_UNKNOWN;