1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
5 #include "iavf_prototype.h"
6 #include "iavf_client.h"
8 /* busy wait delay in msec */
9 #define IAVF_BUSY_WAIT_DELAY 10
10 #define IAVF_BUSY_WAIT_COUNT 50
14 * @adapter: adapter structure
15 * @op: virtual channel opcode
16 * @msg: pointer to message buffer
17 * @len: message length
19 * Send message to PF and print status if failure.
21 static int iavf_send_pf_msg(struct iavf_adapter *adapter,
22 enum virtchnl_ops op, u8 *msg, u16 len)
24 struct iavf_hw *hw = &adapter->hw;
27 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED)
28 return 0; /* nothing to see here, move along */
30 err = iavf_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL);
32 dev_dbg(&adapter->pdev->dev, "Unable to send opcode %d to PF, err %s, aq_err %s\n",
33 op, iavf_stat_str(hw, err),
34 iavf_aq_str(hw, hw->aq.asq_last_status));
40 * @adapter: adapter structure
42 * Send API version admin queue message to the PF. The reply is not checked
43 * in this function. Returns 0 if the message was successfully
44 * sent, or one of the IAVF_ADMIN_QUEUE_ERROR_ statuses if not.
46 int iavf_send_api_ver(struct iavf_adapter *adapter)
48 struct virtchnl_version_info vvi;
50 vvi.major = VIRTCHNL_VERSION_MAJOR;
51 vvi.minor = VIRTCHNL_VERSION_MINOR;
53 return iavf_send_pf_msg(adapter, VIRTCHNL_OP_VERSION, (u8 *)&vvi,
59 * @adapter: adapter structure
61 * Compare API versions with the PF. Must be called after admin queue is
62 * initialized. Returns 0 if API versions match, -EIO if they do not,
63 * IAVF_ERR_ADMIN_QUEUE_NO_WORK if the admin queue is empty, and any errors
64 * from the firmware are propagated.
66 int iavf_verify_api_ver(struct iavf_adapter *adapter)
68 struct virtchnl_version_info *pf_vvi;
69 struct iavf_hw *hw = &adapter->hw;
70 struct iavf_arq_event_info event;
74 event.buf_len = IAVF_MAX_AQ_BUF_SIZE;
75 event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
82 err = iavf_clean_arq_element(hw, &event, NULL);
83 /* When the AQ is empty, iavf_clean_arq_element will return
84 * nonzero and this loop will terminate.
89 (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
90 if (op == VIRTCHNL_OP_VERSION)
95 err = (enum iavf_status)le32_to_cpu(event.desc.cookie_low);
99 if (op != VIRTCHNL_OP_VERSION) {
100 dev_info(&adapter->pdev->dev, "Invalid reply type %d from PF\n",
106 pf_vvi = (struct virtchnl_version_info *)event.msg_buf;
107 adapter->pf_version = *pf_vvi;
109 if ((pf_vvi->major > VIRTCHNL_VERSION_MAJOR) ||
110 ((pf_vvi->major == VIRTCHNL_VERSION_MAJOR) &&
111 (pf_vvi->minor > VIRTCHNL_VERSION_MINOR)))
115 kfree(event.msg_buf);
121 * iavf_send_vf_config_msg
122 * @adapter: adapter structure
124 * Send VF configuration request admin queue message to the PF. The reply
125 * is not checked in this function. Returns 0 if the message was
126 * successfully sent, or one of the IAVF_ADMIN_QUEUE_ERROR_ statuses if not.
128 int iavf_send_vf_config_msg(struct iavf_adapter *adapter)
132 caps = VIRTCHNL_VF_OFFLOAD_L2 |
133 VIRTCHNL_VF_OFFLOAD_RSS_PF |
134 VIRTCHNL_VF_OFFLOAD_RSS_AQ |
135 VIRTCHNL_VF_OFFLOAD_RSS_REG |
136 VIRTCHNL_VF_OFFLOAD_VLAN |
137 VIRTCHNL_VF_OFFLOAD_WB_ON_ITR |
138 VIRTCHNL_VF_OFFLOAD_RSS_PCTYPE_V2 |
139 VIRTCHNL_VF_OFFLOAD_ENCAP |
140 VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM |
141 VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
142 VIRTCHNL_VF_OFFLOAD_ADQ;
144 adapter->current_op = VIRTCHNL_OP_GET_VF_RESOURCES;
145 adapter->aq_required &= ~IAVF_FLAG_AQ_GET_CONFIG;
146 if (PF_IS_V11(adapter))
147 return iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_VF_RESOURCES,
148 (u8 *)&caps, sizeof(caps));
150 return iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_VF_RESOURCES,
155 * iavf_validate_num_queues
156 * @adapter: adapter structure
158 * Validate that the number of queues the PF has sent in
159 * VIRTCHNL_OP_GET_VF_RESOURCES is not larger than the VF can handle.
161 static void iavf_validate_num_queues(struct iavf_adapter *adapter)
163 if (adapter->vf_res->num_queue_pairs > IAVF_MAX_REQ_QUEUES) {
164 struct virtchnl_vsi_resource *vsi_res;
167 dev_info(&adapter->pdev->dev, "Received %d queues, but can only have a max of %d\n",
168 adapter->vf_res->num_queue_pairs,
169 IAVF_MAX_REQ_QUEUES);
170 dev_info(&adapter->pdev->dev, "Fixing by reducing queues to %d\n",
171 IAVF_MAX_REQ_QUEUES);
172 adapter->vf_res->num_queue_pairs = IAVF_MAX_REQ_QUEUES;
173 for (i = 0; i < adapter->vf_res->num_vsis; i++) {
174 vsi_res = &adapter->vf_res->vsi_res[i];
175 vsi_res->num_queue_pairs = IAVF_MAX_REQ_QUEUES;
182 * @adapter: private adapter structure
184 * Get VF configuration from PF and populate hw structure. Must be called after
185 * admin queue is initialized. Busy waits until response is received from PF,
186 * with maximum timeout. Response from PF is returned in the buffer for further
187 * processing by the caller.
189 int iavf_get_vf_config(struct iavf_adapter *adapter)
191 struct iavf_hw *hw = &adapter->hw;
192 struct iavf_arq_event_info event;
193 enum virtchnl_ops op;
194 enum iavf_status err;
197 len = sizeof(struct virtchnl_vf_resource) +
198 IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource);
200 event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
201 if (!event.msg_buf) {
207 /* When the AQ is empty, iavf_clean_arq_element will return
208 * nonzero and this loop will terminate.
210 err = iavf_clean_arq_element(hw, &event, NULL);
214 (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
215 if (op == VIRTCHNL_OP_GET_VF_RESOURCES)
219 err = (enum iavf_status)le32_to_cpu(event.desc.cookie_low);
220 memcpy(adapter->vf_res, event.msg_buf, min(event.msg_len, len));
222 /* some PFs send more queues than we should have so validate that
223 * we aren't getting too many queues
226 iavf_validate_num_queues(adapter);
227 iavf_vf_parse_hw_config(hw, adapter->vf_res);
229 kfree(event.msg_buf);
235 * iavf_configure_queues
236 * @adapter: adapter structure
238 * Request that the PF set up our (previously allocated) queues.
240 void iavf_configure_queues(struct iavf_adapter *adapter)
242 struct virtchnl_vsi_queue_config_info *vqci;
243 struct virtchnl_queue_pair_info *vqpi;
244 int pairs = adapter->num_active_queues;
245 int i, max_frame = IAVF_MAX_RXBUFFER;
248 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
249 /* bail because we already have a command pending */
250 dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n",
251 adapter->current_op);
254 adapter->current_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
255 len = struct_size(vqci, qpair, pairs);
256 vqci = kzalloc(len, GFP_KERNEL);
260 /* Limit maximum frame size when jumbo frames is not enabled */
261 if (!(adapter->flags & IAVF_FLAG_LEGACY_RX) &&
262 (adapter->netdev->mtu <= ETH_DATA_LEN))
263 max_frame = IAVF_RXBUFFER_1536 - NET_IP_ALIGN;
265 vqci->vsi_id = adapter->vsi_res->vsi_id;
266 vqci->num_queue_pairs = pairs;
268 /* Size check is not needed here - HW max is 16 queue pairs, and we
269 * can fit info for 31 of them into the AQ buffer before it overflows.
271 for (i = 0; i < pairs; i++) {
272 vqpi->txq.vsi_id = vqci->vsi_id;
273 vqpi->txq.queue_id = i;
274 vqpi->txq.ring_len = adapter->tx_rings[i].count;
275 vqpi->txq.dma_ring_addr = adapter->tx_rings[i].dma;
276 vqpi->rxq.vsi_id = vqci->vsi_id;
277 vqpi->rxq.queue_id = i;
278 vqpi->rxq.ring_len = adapter->rx_rings[i].count;
279 vqpi->rxq.dma_ring_addr = adapter->rx_rings[i].dma;
280 vqpi->rxq.max_pkt_size = max_frame;
281 vqpi->rxq.databuffer_size =
282 ALIGN(adapter->rx_rings[i].rx_buf_len,
283 BIT_ULL(IAVF_RXQ_CTX_DBUFF_SHIFT));
287 adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES;
288 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
295 * @adapter: adapter structure
297 * Request that the PF enable all of our queues.
299 void iavf_enable_queues(struct iavf_adapter *adapter)
301 struct virtchnl_queue_select vqs;
303 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
304 /* bail because we already have a command pending */
305 dev_err(&adapter->pdev->dev, "Cannot enable queues, command %d pending\n",
306 adapter->current_op);
309 adapter->current_op = VIRTCHNL_OP_ENABLE_QUEUES;
310 vqs.vsi_id = adapter->vsi_res->vsi_id;
311 vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
312 vqs.rx_queues = vqs.tx_queues;
313 adapter->aq_required &= ~IAVF_FLAG_AQ_ENABLE_QUEUES;
314 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_QUEUES,
315 (u8 *)&vqs, sizeof(vqs));
319 * iavf_disable_queues
320 * @adapter: adapter structure
322 * Request that the PF disable all of our queues.
324 void iavf_disable_queues(struct iavf_adapter *adapter)
326 struct virtchnl_queue_select vqs;
328 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
329 /* bail because we already have a command pending */
330 dev_err(&adapter->pdev->dev, "Cannot disable queues, command %d pending\n",
331 adapter->current_op);
334 adapter->current_op = VIRTCHNL_OP_DISABLE_QUEUES;
335 vqs.vsi_id = adapter->vsi_res->vsi_id;
336 vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
337 vqs.rx_queues = vqs.tx_queues;
338 adapter->aq_required &= ~IAVF_FLAG_AQ_DISABLE_QUEUES;
339 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_QUEUES,
340 (u8 *)&vqs, sizeof(vqs));
345 * @adapter: adapter structure
347 * Request that the PF map queues to interrupt vectors. Misc causes, including
348 * admin queue, are always mapped to vector 0.
350 void iavf_map_queues(struct iavf_adapter *adapter)
352 struct virtchnl_irq_map_info *vimi;
353 struct virtchnl_vector_map *vecmap;
354 struct iavf_q_vector *q_vector;
355 int v_idx, q_vectors;
358 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
359 /* bail because we already have a command pending */
360 dev_err(&adapter->pdev->dev, "Cannot map queues to vectors, command %d pending\n",
361 adapter->current_op);
364 adapter->current_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
366 q_vectors = adapter->num_msix_vectors - NONQ_VECS;
368 len = struct_size(vimi, vecmap, adapter->num_msix_vectors);
369 vimi = kzalloc(len, GFP_KERNEL);
373 vimi->num_vectors = adapter->num_msix_vectors;
374 /* Queue vectors first */
375 for (v_idx = 0; v_idx < q_vectors; v_idx++) {
376 q_vector = &adapter->q_vectors[v_idx];
377 vecmap = &vimi->vecmap[v_idx];
379 vecmap->vsi_id = adapter->vsi_res->vsi_id;
380 vecmap->vector_id = v_idx + NONQ_VECS;
381 vecmap->txq_map = q_vector->ring_mask;
382 vecmap->rxq_map = q_vector->ring_mask;
383 vecmap->rxitr_idx = IAVF_RX_ITR;
384 vecmap->txitr_idx = IAVF_TX_ITR;
386 /* Misc vector last - this is only for AdminQ messages */
387 vecmap = &vimi->vecmap[v_idx];
388 vecmap->vsi_id = adapter->vsi_res->vsi_id;
389 vecmap->vector_id = 0;
393 adapter->aq_required &= ~IAVF_FLAG_AQ_MAP_VECTORS;
394 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_IRQ_MAP,
400 * iavf_request_queues
401 * @adapter: adapter structure
402 * @num: number of requested queues
404 * We get a default number of queues from the PF. This enables us to request a
405 * different number. Returns 0 on success, negative on failure
407 int iavf_request_queues(struct iavf_adapter *adapter, int num)
409 struct virtchnl_vf_res_request vfres;
411 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
412 /* bail because we already have a command pending */
413 dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n",
414 adapter->current_op);
418 vfres.num_queue_pairs = min_t(int, num, num_online_cpus());
420 adapter->current_op = VIRTCHNL_OP_REQUEST_QUEUES;
421 adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
422 return iavf_send_pf_msg(adapter, VIRTCHNL_OP_REQUEST_QUEUES,
423 (u8 *)&vfres, sizeof(vfres));
427 * iavf_add_ether_addrs
428 * @adapter: adapter structure
430 * Request that the PF add one or more addresses to our filters.
432 void iavf_add_ether_addrs(struct iavf_adapter *adapter)
434 struct virtchnl_ether_addr_list *veal;
435 struct iavf_mac_filter *f;
436 int i = 0, count = 0;
440 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
441 /* bail because we already have a command pending */
442 dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n",
443 adapter->current_op);
447 spin_lock_bh(&adapter->mac_vlan_list_lock);
449 list_for_each_entry(f, &adapter->mac_filter_list, list) {
454 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER;
455 spin_unlock_bh(&adapter->mac_vlan_list_lock);
458 adapter->current_op = VIRTCHNL_OP_ADD_ETH_ADDR;
460 len = struct_size(veal, list, count);
461 if (len > IAVF_MAX_AQ_BUF_SIZE) {
462 dev_warn(&adapter->pdev->dev, "Too many add MAC changes in one request\n");
463 count = (IAVF_MAX_AQ_BUF_SIZE -
464 sizeof(struct virtchnl_ether_addr_list)) /
465 sizeof(struct virtchnl_ether_addr);
466 len = struct_size(veal, list, count);
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 &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER;
490 spin_unlock_bh(&adapter->mac_vlan_list_lock);
492 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len);
497 * iavf_del_ether_addrs
498 * @adapter: adapter structure
500 * Request that the PF remove one or more addresses from our filters.
502 void iavf_del_ether_addrs(struct iavf_adapter *adapter)
504 struct virtchnl_ether_addr_list *veal;
505 struct iavf_mac_filter *f, *ftmp;
506 int i = 0, count = 0;
510 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
511 /* bail because we already have a command pending */
512 dev_err(&adapter->pdev->dev, "Cannot remove filters, command %d pending\n",
513 adapter->current_op);
517 spin_lock_bh(&adapter->mac_vlan_list_lock);
519 list_for_each_entry(f, &adapter->mac_filter_list, list) {
524 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_MAC_FILTER;
525 spin_unlock_bh(&adapter->mac_vlan_list_lock);
528 adapter->current_op = VIRTCHNL_OP_DEL_ETH_ADDR;
530 len = struct_size(veal, list, count);
531 if (len > IAVF_MAX_AQ_BUF_SIZE) {
532 dev_warn(&adapter->pdev->dev, "Too many delete MAC changes in one request\n");
533 count = (IAVF_MAX_AQ_BUF_SIZE -
534 sizeof(struct virtchnl_ether_addr_list)) /
535 sizeof(struct virtchnl_ether_addr);
536 len = struct_size(veal, list, count);
539 veal = kzalloc(len, GFP_ATOMIC);
541 spin_unlock_bh(&adapter->mac_vlan_list_lock);
545 veal->vsi_id = adapter->vsi_res->vsi_id;
546 veal->num_elements = count;
547 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) {
549 ether_addr_copy(veal->list[i].addr, f->macaddr);
558 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_MAC_FILTER;
560 spin_unlock_bh(&adapter->mac_vlan_list_lock);
562 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_ETH_ADDR, (u8 *)veal, len);
568 * @adapter: adapter structure
570 * Request that the PF add one or more VLAN filters to our VSI.
572 void iavf_add_vlans(struct iavf_adapter *adapter)
574 struct virtchnl_vlan_filter_list *vvfl;
575 int len, i = 0, count = 0;
576 struct iavf_vlan_filter *f;
579 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
580 /* bail because we already have a command pending */
581 dev_err(&adapter->pdev->dev, "Cannot add VLANs, command %d pending\n",
582 adapter->current_op);
586 spin_lock_bh(&adapter->mac_vlan_list_lock);
588 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
593 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
594 spin_unlock_bh(&adapter->mac_vlan_list_lock);
597 adapter->current_op = VIRTCHNL_OP_ADD_VLAN;
599 len = sizeof(struct virtchnl_vlan_filter_list) +
600 (count * sizeof(u16));
601 if (len > IAVF_MAX_AQ_BUF_SIZE) {
602 dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n");
603 count = (IAVF_MAX_AQ_BUF_SIZE -
604 sizeof(struct virtchnl_vlan_filter_list)) /
606 len = sizeof(struct virtchnl_vlan_filter_list) +
607 (count * sizeof(u16));
610 vvfl = kzalloc(len, GFP_ATOMIC);
612 spin_unlock_bh(&adapter->mac_vlan_list_lock);
616 vvfl->vsi_id = adapter->vsi_res->vsi_id;
617 vvfl->num_elements = count;
618 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
620 vvfl->vlan_id[i] = f->vlan;
628 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
630 spin_unlock_bh(&adapter->mac_vlan_list_lock);
632 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);
638 * @adapter: adapter structure
640 * Request that the PF remove one or more VLAN filters from our VSI.
642 void iavf_del_vlans(struct iavf_adapter *adapter)
644 struct virtchnl_vlan_filter_list *vvfl;
645 struct iavf_vlan_filter *f, *ftmp;
646 int len, i = 0, count = 0;
649 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
650 /* bail because we already have a command pending */
651 dev_err(&adapter->pdev->dev, "Cannot remove VLANs, command %d pending\n",
652 adapter->current_op);
656 spin_lock_bh(&adapter->mac_vlan_list_lock);
658 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
663 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
664 spin_unlock_bh(&adapter->mac_vlan_list_lock);
667 adapter->current_op = VIRTCHNL_OP_DEL_VLAN;
669 len = sizeof(struct virtchnl_vlan_filter_list) +
670 (count * sizeof(u16));
671 if (len > IAVF_MAX_AQ_BUF_SIZE) {
672 dev_warn(&adapter->pdev->dev, "Too many delete VLAN changes in one request\n");
673 count = (IAVF_MAX_AQ_BUF_SIZE -
674 sizeof(struct virtchnl_vlan_filter_list)) /
676 len = sizeof(struct virtchnl_vlan_filter_list) +
677 (count * sizeof(u16));
680 vvfl = kzalloc(len, GFP_ATOMIC);
682 spin_unlock_bh(&adapter->mac_vlan_list_lock);
686 vvfl->vsi_id = adapter->vsi_res->vsi_id;
687 vvfl->num_elements = count;
688 list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {
690 vvfl->vlan_id[i] = f->vlan;
699 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
701 spin_unlock_bh(&adapter->mac_vlan_list_lock);
703 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len);
708 * iavf_set_promiscuous
709 * @adapter: adapter structure
710 * @flags: bitmask to control unicast/multicast promiscuous.
712 * Request that the PF enable promiscuous mode for our VSI.
714 void iavf_set_promiscuous(struct iavf_adapter *adapter, int flags)
716 struct virtchnl_promisc_info vpi;
719 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
720 /* bail because we already have a command pending */
721 dev_err(&adapter->pdev->dev, "Cannot set promiscuous mode, command %d pending\n",
722 adapter->current_op);
726 promisc_all = FLAG_VF_UNICAST_PROMISC |
727 FLAG_VF_MULTICAST_PROMISC;
728 if ((flags & promisc_all) == promisc_all) {
729 adapter->flags |= IAVF_FLAG_PROMISC_ON;
730 adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_PROMISC;
731 dev_info(&adapter->pdev->dev, "Entering promiscuous mode\n");
734 if (flags & FLAG_VF_MULTICAST_PROMISC) {
735 adapter->flags |= IAVF_FLAG_ALLMULTI_ON;
736 adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_ALLMULTI;
737 dev_info(&adapter->pdev->dev, "Entering multicast promiscuous mode\n");
741 adapter->flags &= ~(IAVF_FLAG_PROMISC_ON |
742 IAVF_FLAG_ALLMULTI_ON);
743 adapter->aq_required &= ~(IAVF_FLAG_AQ_RELEASE_PROMISC |
744 IAVF_FLAG_AQ_RELEASE_ALLMULTI);
745 dev_info(&adapter->pdev->dev, "Leaving promiscuous mode\n");
748 adapter->current_op = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
749 vpi.vsi_id = adapter->vsi_res->vsi_id;
751 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
752 (u8 *)&vpi, sizeof(vpi));
757 * @adapter: adapter structure
759 * Request VSI statistics from PF.
761 void iavf_request_stats(struct iavf_adapter *adapter)
763 struct virtchnl_queue_select vqs;
765 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
766 /* no error message, this isn't crucial */
769 adapter->current_op = VIRTCHNL_OP_GET_STATS;
770 vqs.vsi_id = adapter->vsi_res->vsi_id;
771 /* queue maps are ignored for this message - only the vsi is used */
772 if (iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_STATS, (u8 *)&vqs,
774 /* if the request failed, don't lock out others */
775 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
780 * @adapter: adapter structure
782 * Request hash enable capabilities from PF
784 void iavf_get_hena(struct iavf_adapter *adapter)
786 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
787 /* bail because we already have a command pending */
788 dev_err(&adapter->pdev->dev, "Cannot get RSS hash capabilities, command %d pending\n",
789 adapter->current_op);
792 adapter->current_op = VIRTCHNL_OP_GET_RSS_HENA_CAPS;
793 adapter->aq_required &= ~IAVF_FLAG_AQ_GET_HENA;
794 iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_RSS_HENA_CAPS, NULL, 0);
799 * @adapter: adapter structure
801 * Request the PF to set our RSS hash capabilities
803 void iavf_set_hena(struct iavf_adapter *adapter)
805 struct virtchnl_rss_hena vrh;
807 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
808 /* bail because we already have a command pending */
809 dev_err(&adapter->pdev->dev, "Cannot set RSS hash enable, command %d pending\n",
810 adapter->current_op);
813 vrh.hena = adapter->hena;
814 adapter->current_op = VIRTCHNL_OP_SET_RSS_HENA;
815 adapter->aq_required &= ~IAVF_FLAG_AQ_SET_HENA;
816 iavf_send_pf_msg(adapter, VIRTCHNL_OP_SET_RSS_HENA, (u8 *)&vrh,
822 * @adapter: adapter structure
824 * Request the PF to set our RSS hash key
826 void iavf_set_rss_key(struct iavf_adapter *adapter)
828 struct virtchnl_rss_key *vrk;
831 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
832 /* bail because we already have a command pending */
833 dev_err(&adapter->pdev->dev, "Cannot set RSS key, command %d pending\n",
834 adapter->current_op);
837 len = sizeof(struct virtchnl_rss_key) +
838 (adapter->rss_key_size * sizeof(u8)) - 1;
839 vrk = kzalloc(len, GFP_KERNEL);
842 vrk->vsi_id = adapter->vsi.id;
843 vrk->key_len = adapter->rss_key_size;
844 memcpy(vrk->key, adapter->rss_key, adapter->rss_key_size);
846 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_KEY;
847 adapter->aq_required &= ~IAVF_FLAG_AQ_SET_RSS_KEY;
848 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_KEY, (u8 *)vrk, len);
854 * @adapter: adapter structure
856 * Request the PF to set our RSS lookup table
858 void iavf_set_rss_lut(struct iavf_adapter *adapter)
860 struct virtchnl_rss_lut *vrl;
863 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
864 /* bail because we already have a command pending */
865 dev_err(&adapter->pdev->dev, "Cannot set RSS LUT, command %d pending\n",
866 adapter->current_op);
869 len = sizeof(struct virtchnl_rss_lut) +
870 (adapter->rss_lut_size * sizeof(u8)) - 1;
871 vrl = kzalloc(len, GFP_KERNEL);
874 vrl->vsi_id = adapter->vsi.id;
875 vrl->lut_entries = adapter->rss_lut_size;
876 memcpy(vrl->lut, adapter->rss_lut, adapter->rss_lut_size);
877 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_LUT;
878 adapter->aq_required &= ~IAVF_FLAG_AQ_SET_RSS_LUT;
879 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_LUT, (u8 *)vrl, len);
884 * iavf_enable_vlan_stripping
885 * @adapter: adapter structure
887 * Request VLAN header stripping to be enabled
889 void iavf_enable_vlan_stripping(struct iavf_adapter *adapter)
891 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
892 /* bail because we already have a command pending */
893 dev_err(&adapter->pdev->dev, "Cannot enable stripping, command %d pending\n",
894 adapter->current_op);
897 adapter->current_op = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
898 adapter->aq_required &= ~IAVF_FLAG_AQ_ENABLE_VLAN_STRIPPING;
899 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING, NULL, 0);
903 * iavf_disable_vlan_stripping
904 * @adapter: adapter structure
906 * Request VLAN header stripping to be disabled
908 void iavf_disable_vlan_stripping(struct iavf_adapter *adapter)
910 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
911 /* bail because we already have a command pending */
912 dev_err(&adapter->pdev->dev, "Cannot disable stripping, command %d pending\n",
913 adapter->current_op);
916 adapter->current_op = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
917 adapter->aq_required &= ~IAVF_FLAG_AQ_DISABLE_VLAN_STRIPPING;
918 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING, NULL, 0);
922 * iavf_print_link_message - print link up or down
923 * @adapter: adapter structure
925 * Log a message telling the world of our wonderous link status
927 static void iavf_print_link_message(struct iavf_adapter *adapter)
929 struct net_device *netdev = adapter->netdev;
930 char *speed = "Unknown ";
932 if (!adapter->link_up) {
933 netdev_info(netdev, "NIC Link is Down\n");
937 switch (adapter->link_speed) {
938 case IAVF_LINK_SPEED_40GB:
941 case IAVF_LINK_SPEED_25GB:
944 case IAVF_LINK_SPEED_20GB:
947 case IAVF_LINK_SPEED_10GB:
950 case IAVF_LINK_SPEED_1GB:
953 case IAVF_LINK_SPEED_100MB:
960 netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
964 * iavf_enable_channel
965 * @adapter: adapter structure
967 * Request that the PF enable channels as specified by
968 * the user via tc tool.
970 void iavf_enable_channels(struct iavf_adapter *adapter)
972 struct virtchnl_tc_info *vti = NULL;
976 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
977 /* bail because we already have a command pending */
978 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
979 adapter->current_op);
983 len = struct_size(vti, list, adapter->num_tc - 1);
984 vti = kzalloc(len, GFP_KERNEL);
987 vti->num_tc = adapter->num_tc;
988 for (i = 0; i < vti->num_tc; i++) {
989 vti->list[i].count = adapter->ch_config.ch_info[i].count;
990 vti->list[i].offset = adapter->ch_config.ch_info[i].offset;
991 vti->list[i].pad = 0;
992 vti->list[i].max_tx_rate =
993 adapter->ch_config.ch_info[i].max_tx_rate;
996 adapter->ch_config.state = __IAVF_TC_RUNNING;
997 adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
998 adapter->current_op = VIRTCHNL_OP_ENABLE_CHANNELS;
999 adapter->aq_required &= ~IAVF_FLAG_AQ_ENABLE_CHANNELS;
1000 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_CHANNELS, (u8 *)vti, len);
1005 * iavf_disable_channel
1006 * @adapter: adapter structure
1008 * Request that the PF disable channels that are configured
1010 void iavf_disable_channels(struct iavf_adapter *adapter)
1012 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1013 /* bail because we already have a command pending */
1014 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
1015 adapter->current_op);
1019 adapter->ch_config.state = __IAVF_TC_INVALID;
1020 adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
1021 adapter->current_op = VIRTCHNL_OP_DISABLE_CHANNELS;
1022 adapter->aq_required &= ~IAVF_FLAG_AQ_DISABLE_CHANNELS;
1023 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_CHANNELS, NULL, 0);
1027 * iavf_print_cloud_filter
1028 * @adapter: adapter structure
1029 * @f: cloud filter to print
1031 * Print the cloud filter
1033 static void iavf_print_cloud_filter(struct iavf_adapter *adapter,
1034 struct virtchnl_filter *f)
1036 switch (f->flow_type) {
1037 case VIRTCHNL_TCP_V4_FLOW:
1038 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",
1039 &f->data.tcp_spec.dst_mac,
1040 &f->data.tcp_spec.src_mac,
1041 ntohs(f->data.tcp_spec.vlan_id),
1042 &f->data.tcp_spec.dst_ip[0],
1043 &f->data.tcp_spec.src_ip[0],
1044 ntohs(f->data.tcp_spec.dst_port),
1045 ntohs(f->data.tcp_spec.src_port));
1047 case VIRTCHNL_TCP_V6_FLOW:
1048 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",
1049 &f->data.tcp_spec.dst_mac,
1050 &f->data.tcp_spec.src_mac,
1051 ntohs(f->data.tcp_spec.vlan_id),
1052 &f->data.tcp_spec.dst_ip,
1053 &f->data.tcp_spec.src_ip,
1054 ntohs(f->data.tcp_spec.dst_port),
1055 ntohs(f->data.tcp_spec.src_port));
1061 * iavf_add_cloud_filter
1062 * @adapter: adapter structure
1064 * Request that the PF add cloud filters as specified
1065 * by the user via tc tool.
1067 void iavf_add_cloud_filter(struct iavf_adapter *adapter)
1069 struct iavf_cloud_filter *cf;
1070 struct virtchnl_filter *f;
1071 int len = 0, count = 0;
1073 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1074 /* bail because we already have a command pending */
1075 dev_err(&adapter->pdev->dev, "Cannot add cloud filter, command %d pending\n",
1076 adapter->current_op);
1079 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1086 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_CLOUD_FILTER;
1089 adapter->current_op = VIRTCHNL_OP_ADD_CLOUD_FILTER;
1091 len = sizeof(struct virtchnl_filter);
1092 f = kzalloc(len, GFP_KERNEL);
1096 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1098 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1100 cf->state = __IAVF_CF_ADD_PENDING;
1101 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_CLOUD_FILTER,
1109 * iavf_del_cloud_filter
1110 * @adapter: adapter structure
1112 * Request that the PF delete cloud filters as specified
1113 * by the user via tc tool.
1115 void iavf_del_cloud_filter(struct iavf_adapter *adapter)
1117 struct iavf_cloud_filter *cf, *cftmp;
1118 struct virtchnl_filter *f;
1119 int len = 0, count = 0;
1121 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1122 /* bail because we already have a command pending */
1123 dev_err(&adapter->pdev->dev, "Cannot remove cloud filter, command %d pending\n",
1124 adapter->current_op);
1127 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1134 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_CLOUD_FILTER;
1137 adapter->current_op = VIRTCHNL_OP_DEL_CLOUD_FILTER;
1139 len = sizeof(struct virtchnl_filter);
1140 f = kzalloc(len, GFP_KERNEL);
1144 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) {
1146 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1148 cf->state = __IAVF_CF_DEL_PENDING;
1149 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_CLOUD_FILTER,
1157 * iavf_request_reset
1158 * @adapter: adapter structure
1160 * Request that the PF reset this VF. No response is expected.
1162 void iavf_request_reset(struct iavf_adapter *adapter)
1164 /* Don't check CURRENT_OP - this is always higher priority */
1165 iavf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0);
1166 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
1170 * iavf_virtchnl_completion
1171 * @adapter: adapter structure
1172 * @v_opcode: opcode sent by PF
1173 * @v_retval: retval sent by PF
1174 * @msg: message sent by PF
1175 * @msglen: message length
1177 * Asynchronous completion function for admin queue messages. Rather than busy
1178 * wait, we fire off our requests and assume that no errors will be returned.
1179 * This function handles the reply messages.
1181 void iavf_virtchnl_completion(struct iavf_adapter *adapter,
1182 enum virtchnl_ops v_opcode,
1183 enum iavf_status v_retval, u8 *msg, u16 msglen)
1185 struct net_device *netdev = adapter->netdev;
1187 if (v_opcode == VIRTCHNL_OP_EVENT) {
1188 struct virtchnl_pf_event *vpe =
1189 (struct virtchnl_pf_event *)msg;
1190 bool link_up = vpe->event_data.link_event.link_status;
1192 switch (vpe->event) {
1193 case VIRTCHNL_EVENT_LINK_CHANGE:
1194 adapter->link_speed =
1195 vpe->event_data.link_event.link_speed;
1197 /* we've already got the right link status, bail */
1198 if (adapter->link_up == link_up)
1202 /* If we get link up message and start queues
1203 * before our queues are configured it will
1204 * trigger a TX hang. In that case, just ignore
1205 * the link status message,we'll get another one
1206 * after we enable queues and actually prepared
1209 if (adapter->state != __IAVF_RUNNING)
1212 /* For ADq enabled VF, we reconfigure VSIs and
1213 * re-allocate queues. Hence wait till all
1214 * queues are enabled.
1216 if (adapter->flags &
1217 IAVF_FLAG_QUEUES_DISABLED)
1221 adapter->link_up = link_up;
1223 netif_tx_start_all_queues(netdev);
1224 netif_carrier_on(netdev);
1226 netif_tx_stop_all_queues(netdev);
1227 netif_carrier_off(netdev);
1229 iavf_print_link_message(adapter);
1231 case VIRTCHNL_EVENT_RESET_IMPENDING:
1232 dev_info(&adapter->pdev->dev, "Reset warning received from the PF\n");
1233 if (!(adapter->flags & IAVF_FLAG_RESET_PENDING)) {
1234 adapter->flags |= IAVF_FLAG_RESET_PENDING;
1235 dev_info(&adapter->pdev->dev, "Scheduling reset task\n");
1236 queue_work(iavf_wq, &adapter->reset_task);
1240 dev_err(&adapter->pdev->dev, "Unknown event %d from PF\n",
1248 case VIRTCHNL_OP_ADD_VLAN:
1249 dev_err(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n",
1250 iavf_stat_str(&adapter->hw, v_retval));
1252 case VIRTCHNL_OP_ADD_ETH_ADDR:
1253 dev_err(&adapter->pdev->dev, "Failed to add MAC filter, error %s\n",
1254 iavf_stat_str(&adapter->hw, v_retval));
1255 /* restore administratively set MAC address */
1256 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
1258 case VIRTCHNL_OP_DEL_VLAN:
1259 dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n",
1260 iavf_stat_str(&adapter->hw, v_retval));
1262 case VIRTCHNL_OP_DEL_ETH_ADDR:
1263 dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n",
1264 iavf_stat_str(&adapter->hw, v_retval));
1266 case VIRTCHNL_OP_ENABLE_CHANNELS:
1267 dev_err(&adapter->pdev->dev, "Failed to configure queue channels, error %s\n",
1268 iavf_stat_str(&adapter->hw, v_retval));
1269 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
1270 adapter->ch_config.state = __IAVF_TC_INVALID;
1271 netdev_reset_tc(netdev);
1272 netif_tx_start_all_queues(netdev);
1274 case VIRTCHNL_OP_DISABLE_CHANNELS:
1275 dev_err(&adapter->pdev->dev, "Failed to disable queue channels, error %s\n",
1276 iavf_stat_str(&adapter->hw, v_retval));
1277 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
1278 adapter->ch_config.state = __IAVF_TC_RUNNING;
1279 netif_tx_start_all_queues(netdev);
1281 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1282 struct iavf_cloud_filter *cf, *cftmp;
1284 list_for_each_entry_safe(cf, cftmp,
1285 &adapter->cloud_filter_list,
1287 if (cf->state == __IAVF_CF_ADD_PENDING) {
1288 cf->state = __IAVF_CF_INVALID;
1289 dev_info(&adapter->pdev->dev, "Failed to add cloud filter, error %s\n",
1290 iavf_stat_str(&adapter->hw,
1292 iavf_print_cloud_filter(adapter,
1294 list_del(&cf->list);
1296 adapter->num_cloud_filters--;
1301 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1302 struct iavf_cloud_filter *cf;
1304 list_for_each_entry(cf, &adapter->cloud_filter_list,
1306 if (cf->state == __IAVF_CF_DEL_PENDING) {
1307 cf->state = __IAVF_CF_ACTIVE;
1308 dev_info(&adapter->pdev->dev, "Failed to del cloud filter, error %s\n",
1309 iavf_stat_str(&adapter->hw,
1311 iavf_print_cloud_filter(adapter,
1318 dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",
1319 v_retval, iavf_stat_str(&adapter->hw, v_retval),
1324 case VIRTCHNL_OP_ADD_ETH_ADDR: {
1325 if (!ether_addr_equal(netdev->dev_addr, adapter->hw.mac.addr))
1326 ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
1329 case VIRTCHNL_OP_GET_STATS: {
1330 struct iavf_eth_stats *stats =
1331 (struct iavf_eth_stats *)msg;
1332 netdev->stats.rx_packets = stats->rx_unicast +
1333 stats->rx_multicast +
1334 stats->rx_broadcast;
1335 netdev->stats.tx_packets = stats->tx_unicast +
1336 stats->tx_multicast +
1337 stats->tx_broadcast;
1338 netdev->stats.rx_bytes = stats->rx_bytes;
1339 netdev->stats.tx_bytes = stats->tx_bytes;
1340 netdev->stats.tx_errors = stats->tx_errors;
1341 netdev->stats.rx_dropped = stats->rx_discards;
1342 netdev->stats.tx_dropped = stats->tx_discards;
1343 adapter->current_stats = *stats;
1346 case VIRTCHNL_OP_GET_VF_RESOURCES: {
1347 u16 len = sizeof(struct virtchnl_vf_resource) +
1349 sizeof(struct virtchnl_vsi_resource);
1350 memcpy(adapter->vf_res, msg, min(msglen, len));
1351 iavf_validate_num_queues(adapter);
1352 iavf_vf_parse_hw_config(&adapter->hw, adapter->vf_res);
1353 if (is_zero_ether_addr(adapter->hw.mac.addr)) {
1354 /* restore current mac address */
1355 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
1357 /* refresh current mac address if changed */
1358 ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
1359 ether_addr_copy(netdev->perm_addr,
1360 adapter->hw.mac.addr);
1362 spin_lock_bh(&adapter->mac_vlan_list_lock);
1363 iavf_add_filter(adapter, adapter->hw.mac.addr);
1364 spin_unlock_bh(&adapter->mac_vlan_list_lock);
1365 iavf_process_config(adapter);
1368 case VIRTCHNL_OP_ENABLE_QUEUES:
1369 /* enable transmits */
1370 iavf_irq_enable(adapter, true);
1371 adapter->flags &= ~IAVF_FLAG_QUEUES_DISABLED;
1373 case VIRTCHNL_OP_DISABLE_QUEUES:
1374 iavf_free_all_tx_resources(adapter);
1375 iavf_free_all_rx_resources(adapter);
1376 if (adapter->state == __IAVF_DOWN_PENDING) {
1377 adapter->state = __IAVF_DOWN;
1378 wake_up(&adapter->down_waitqueue);
1381 case VIRTCHNL_OP_VERSION:
1382 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1383 /* Don't display an error if we get these out of sequence.
1384 * If the firmware needed to get kicked, we'll get these and
1387 if (v_opcode != adapter->current_op)
1390 case VIRTCHNL_OP_IWARP:
1391 /* Gobble zero-length replies from the PF. They indicate that
1392 * a previous message was received OK, and the client doesn't
1395 if (msglen && CLIENT_ENABLED(adapter))
1396 iavf_notify_client_message(&adapter->vsi, msg, msglen);
1399 case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
1400 adapter->client_pending &=
1401 ~(BIT(VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP));
1403 case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
1404 struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
1406 if (msglen == sizeof(*vrh))
1407 adapter->hena = vrh->hena;
1409 dev_warn(&adapter->pdev->dev,
1410 "Invalid message %d from PF\n", v_opcode);
1413 case VIRTCHNL_OP_REQUEST_QUEUES: {
1414 struct virtchnl_vf_res_request *vfres =
1415 (struct virtchnl_vf_res_request *)msg;
1417 if (vfres->num_queue_pairs != adapter->num_req_queues) {
1418 dev_info(&adapter->pdev->dev,
1419 "Requested %d queues, PF can support %d\n",
1420 adapter->num_req_queues,
1421 vfres->num_queue_pairs);
1422 adapter->num_req_queues = 0;
1423 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
1427 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1428 struct iavf_cloud_filter *cf;
1430 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1431 if (cf->state == __IAVF_CF_ADD_PENDING)
1432 cf->state = __IAVF_CF_ACTIVE;
1436 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1437 struct iavf_cloud_filter *cf, *cftmp;
1439 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list,
1441 if (cf->state == __IAVF_CF_DEL_PENDING) {
1442 cf->state = __IAVF_CF_INVALID;
1443 list_del(&cf->list);
1445 adapter->num_cloud_filters--;
1451 if (adapter->current_op && (v_opcode != adapter->current_op))
1452 dev_warn(&adapter->pdev->dev, "Expected response %d from PF, received %d\n",
1453 adapter->current_op, v_opcode);
1455 } /* switch v_opcode */
1456 adapter->current_op = VIRTCHNL_OP_UNKNOWN;