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 I40E_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 * I40E_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 i40e_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 = (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 I40E_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 i40e_arq_event_info event;
193 enum virtchnl_ops op;
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 = (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, len, max_frame = IAVF_MAX_RXBUFFER;
247 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
248 /* bail because we already have a command pending */
249 dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n",
250 adapter->current_op);
253 adapter->current_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
254 len = sizeof(struct virtchnl_vsi_queue_config_info) +
255 (sizeof(struct virtchnl_queue_pair_info) * 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 int v_idx, q_vectors, len;
355 struct iavf_q_vector *q_vector;
357 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
358 /* bail because we already have a command pending */
359 dev_err(&adapter->pdev->dev, "Cannot map queues to vectors, command %d pending\n",
360 adapter->current_op);
363 adapter->current_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
365 q_vectors = adapter->num_msix_vectors - NONQ_VECS;
367 len = sizeof(struct virtchnl_irq_map_info) +
368 (adapter->num_msix_vectors *
369 sizeof(struct virtchnl_vector_map));
370 vimi = kzalloc(len, GFP_KERNEL);
374 vimi->num_vectors = adapter->num_msix_vectors;
375 /* Queue vectors first */
376 for (v_idx = 0; v_idx < q_vectors; v_idx++) {
377 q_vector = &adapter->q_vectors[v_idx];
378 vecmap = &vimi->vecmap[v_idx];
380 vecmap->vsi_id = adapter->vsi_res->vsi_id;
381 vecmap->vector_id = v_idx + NONQ_VECS;
382 vecmap->txq_map = q_vector->ring_mask;
383 vecmap->rxq_map = q_vector->ring_mask;
384 vecmap->rxitr_idx = IAVF_RX_ITR;
385 vecmap->txitr_idx = IAVF_TX_ITR;
387 /* Misc vector last - this is only for AdminQ messages */
388 vecmap = &vimi->vecmap[v_idx];
389 vecmap->vsi_id = adapter->vsi_res->vsi_id;
390 vecmap->vector_id = 0;
394 adapter->aq_required &= ~IAVF_FLAG_AQ_MAP_VECTORS;
395 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_IRQ_MAP,
401 * iavf_request_queues
402 * @adapter: adapter structure
403 * @num: number of requested queues
405 * We get a default number of queues from the PF. This enables us to request a
406 * different number. Returns 0 on success, negative on failure
408 int iavf_request_queues(struct iavf_adapter *adapter, int num)
410 struct virtchnl_vf_res_request vfres;
412 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
413 /* bail because we already have a command pending */
414 dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n",
415 adapter->current_op);
419 vfres.num_queue_pairs = num;
421 adapter->current_op = VIRTCHNL_OP_REQUEST_QUEUES;
422 adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
423 return iavf_send_pf_msg(adapter, VIRTCHNL_OP_REQUEST_QUEUES,
424 (u8 *)&vfres, sizeof(vfres));
428 * iavf_add_ether_addrs
429 * @adapter: adapter structure
431 * Request that the PF add one or more addresses to our filters.
433 void iavf_add_ether_addrs(struct iavf_adapter *adapter)
435 struct virtchnl_ether_addr_list *veal;
436 int len, i = 0, count = 0;
437 struct iavf_mac_filter *f;
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 = sizeof(struct virtchnl_ether_addr_list) +
461 (count * sizeof(struct virtchnl_ether_addr));
462 if (len > IAVF_MAX_AQ_BUF_SIZE) {
463 dev_warn(&adapter->pdev->dev, "Too many add MAC changes in one request\n");
464 count = (IAVF_MAX_AQ_BUF_SIZE -
465 sizeof(struct virtchnl_ether_addr_list)) /
466 sizeof(struct virtchnl_ether_addr);
467 len = sizeof(struct virtchnl_ether_addr_list) +
468 (count * sizeof(struct virtchnl_ether_addr));
472 veal = kzalloc(len, GFP_ATOMIC);
474 spin_unlock_bh(&adapter->mac_vlan_list_lock);
478 veal->vsi_id = adapter->vsi_res->vsi_id;
479 veal->num_elements = count;
480 list_for_each_entry(f, &adapter->mac_filter_list, list) {
482 ether_addr_copy(veal->list[i].addr, f->macaddr);
490 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER;
492 spin_unlock_bh(&adapter->mac_vlan_list_lock);
494 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len);
499 * iavf_del_ether_addrs
500 * @adapter: adapter structure
502 * Request that the PF remove one or more addresses from our filters.
504 void iavf_del_ether_addrs(struct iavf_adapter *adapter)
506 struct virtchnl_ether_addr_list *veal;
507 struct iavf_mac_filter *f, *ftmp;
508 int len, i = 0, count = 0;
511 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
512 /* bail because we already have a command pending */
513 dev_err(&adapter->pdev->dev, "Cannot remove filters, command %d pending\n",
514 adapter->current_op);
518 spin_lock_bh(&adapter->mac_vlan_list_lock);
520 list_for_each_entry(f, &adapter->mac_filter_list, list) {
525 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_MAC_FILTER;
526 spin_unlock_bh(&adapter->mac_vlan_list_lock);
529 adapter->current_op = VIRTCHNL_OP_DEL_ETH_ADDR;
531 len = sizeof(struct virtchnl_ether_addr_list) +
532 (count * sizeof(struct virtchnl_ether_addr));
533 if (len > IAVF_MAX_AQ_BUF_SIZE) {
534 dev_warn(&adapter->pdev->dev, "Too many delete MAC changes in one request\n");
535 count = (IAVF_MAX_AQ_BUF_SIZE -
536 sizeof(struct virtchnl_ether_addr_list)) /
537 sizeof(struct virtchnl_ether_addr);
538 len = sizeof(struct virtchnl_ether_addr_list) +
539 (count * sizeof(struct virtchnl_ether_addr));
542 veal = kzalloc(len, GFP_ATOMIC);
544 spin_unlock_bh(&adapter->mac_vlan_list_lock);
548 veal->vsi_id = adapter->vsi_res->vsi_id;
549 veal->num_elements = count;
550 list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) {
552 ether_addr_copy(veal->list[i].addr, f->macaddr);
561 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_MAC_FILTER;
563 spin_unlock_bh(&adapter->mac_vlan_list_lock);
565 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_ETH_ADDR, (u8 *)veal, len);
571 * @adapter: adapter structure
573 * Request that the PF add one or more VLAN filters to our VSI.
575 void iavf_add_vlans(struct iavf_adapter *adapter)
577 struct virtchnl_vlan_filter_list *vvfl;
578 int len, i = 0, count = 0;
579 struct iavf_vlan_filter *f;
582 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
583 /* bail because we already have a command pending */
584 dev_err(&adapter->pdev->dev, "Cannot add VLANs, command %d pending\n",
585 adapter->current_op);
589 spin_lock_bh(&adapter->mac_vlan_list_lock);
591 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
596 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
597 spin_unlock_bh(&adapter->mac_vlan_list_lock);
600 adapter->current_op = VIRTCHNL_OP_ADD_VLAN;
602 len = sizeof(struct virtchnl_vlan_filter_list) +
603 (count * sizeof(u16));
604 if (len > IAVF_MAX_AQ_BUF_SIZE) {
605 dev_warn(&adapter->pdev->dev, "Too many add VLAN changes in one request\n");
606 count = (IAVF_MAX_AQ_BUF_SIZE -
607 sizeof(struct virtchnl_vlan_filter_list)) /
609 len = sizeof(struct virtchnl_vlan_filter_list) +
610 (count * sizeof(u16));
613 vvfl = kzalloc(len, GFP_ATOMIC);
615 spin_unlock_bh(&adapter->mac_vlan_list_lock);
619 vvfl->vsi_id = adapter->vsi_res->vsi_id;
620 vvfl->num_elements = count;
621 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
623 vvfl->vlan_id[i] = f->vlan;
631 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
633 spin_unlock_bh(&adapter->mac_vlan_list_lock);
635 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);
641 * @adapter: adapter structure
643 * Request that the PF remove one or more VLAN filters from our VSI.
645 void iavf_del_vlans(struct iavf_adapter *adapter)
647 struct virtchnl_vlan_filter_list *vvfl;
648 struct iavf_vlan_filter *f, *ftmp;
649 int len, i = 0, count = 0;
652 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
653 /* bail because we already have a command pending */
654 dev_err(&adapter->pdev->dev, "Cannot remove VLANs, command %d pending\n",
655 adapter->current_op);
659 spin_lock_bh(&adapter->mac_vlan_list_lock);
661 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
666 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
667 spin_unlock_bh(&adapter->mac_vlan_list_lock);
670 adapter->current_op = VIRTCHNL_OP_DEL_VLAN;
672 len = sizeof(struct virtchnl_vlan_filter_list) +
673 (count * sizeof(u16));
674 if (len > IAVF_MAX_AQ_BUF_SIZE) {
675 dev_warn(&adapter->pdev->dev, "Too many delete VLAN changes in one request\n");
676 count = (IAVF_MAX_AQ_BUF_SIZE -
677 sizeof(struct virtchnl_vlan_filter_list)) /
679 len = sizeof(struct virtchnl_vlan_filter_list) +
680 (count * sizeof(u16));
683 vvfl = kzalloc(len, GFP_ATOMIC);
685 spin_unlock_bh(&adapter->mac_vlan_list_lock);
689 vvfl->vsi_id = adapter->vsi_res->vsi_id;
690 vvfl->num_elements = count;
691 list_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {
693 vvfl->vlan_id[i] = f->vlan;
702 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
704 spin_unlock_bh(&adapter->mac_vlan_list_lock);
706 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len);
711 * iavf_set_promiscuous
712 * @adapter: adapter structure
713 * @flags: bitmask to control unicast/multicast promiscuous.
715 * Request that the PF enable promiscuous mode for our VSI.
717 void iavf_set_promiscuous(struct iavf_adapter *adapter, int flags)
719 struct virtchnl_promisc_info vpi;
722 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
723 /* bail because we already have a command pending */
724 dev_err(&adapter->pdev->dev, "Cannot set promiscuous mode, command %d pending\n",
725 adapter->current_op);
729 promisc_all = FLAG_VF_UNICAST_PROMISC |
730 FLAG_VF_MULTICAST_PROMISC;
731 if ((flags & promisc_all) == promisc_all) {
732 adapter->flags |= IAVF_FLAG_PROMISC_ON;
733 adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_PROMISC;
734 dev_info(&adapter->pdev->dev, "Entering promiscuous mode\n");
737 if (flags & FLAG_VF_MULTICAST_PROMISC) {
738 adapter->flags |= IAVF_FLAG_ALLMULTI_ON;
739 adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_ALLMULTI;
740 dev_info(&adapter->pdev->dev, "Entering multicast promiscuous mode\n");
744 adapter->flags &= ~(IAVF_FLAG_PROMISC_ON |
745 IAVF_FLAG_ALLMULTI_ON);
746 adapter->aq_required &= ~(IAVF_FLAG_AQ_RELEASE_PROMISC |
747 IAVF_FLAG_AQ_RELEASE_ALLMULTI);
748 dev_info(&adapter->pdev->dev, "Leaving promiscuous mode\n");
751 adapter->current_op = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
752 vpi.vsi_id = adapter->vsi_res->vsi_id;
754 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
755 (u8 *)&vpi, sizeof(vpi));
760 * @adapter: adapter structure
762 * Request VSI statistics from PF.
764 void iavf_request_stats(struct iavf_adapter *adapter)
766 struct virtchnl_queue_select vqs;
768 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
769 /* no error message, this isn't crucial */
772 adapter->current_op = VIRTCHNL_OP_GET_STATS;
773 vqs.vsi_id = adapter->vsi_res->vsi_id;
774 /* queue maps are ignored for this message - only the vsi is used */
775 if (iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_STATS, (u8 *)&vqs,
777 /* if the request failed, don't lock out others */
778 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
783 * @adapter: adapter structure
785 * Request hash enable capabilities from PF
787 void iavf_get_hena(struct iavf_adapter *adapter)
789 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
790 /* bail because we already have a command pending */
791 dev_err(&adapter->pdev->dev, "Cannot get RSS hash capabilities, command %d pending\n",
792 adapter->current_op);
795 adapter->current_op = VIRTCHNL_OP_GET_RSS_HENA_CAPS;
796 adapter->aq_required &= ~IAVF_FLAG_AQ_GET_HENA;
797 iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_RSS_HENA_CAPS, NULL, 0);
802 * @adapter: adapter structure
804 * Request the PF to set our RSS hash capabilities
806 void iavf_set_hena(struct iavf_adapter *adapter)
808 struct virtchnl_rss_hena vrh;
810 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
811 /* bail because we already have a command pending */
812 dev_err(&adapter->pdev->dev, "Cannot set RSS hash enable, command %d pending\n",
813 adapter->current_op);
816 vrh.hena = adapter->hena;
817 adapter->current_op = VIRTCHNL_OP_SET_RSS_HENA;
818 adapter->aq_required &= ~IAVF_FLAG_AQ_SET_HENA;
819 iavf_send_pf_msg(adapter, VIRTCHNL_OP_SET_RSS_HENA, (u8 *)&vrh,
825 * @adapter: adapter structure
827 * Request the PF to set our RSS hash key
829 void iavf_set_rss_key(struct iavf_adapter *adapter)
831 struct virtchnl_rss_key *vrk;
834 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
835 /* bail because we already have a command pending */
836 dev_err(&adapter->pdev->dev, "Cannot set RSS key, command %d pending\n",
837 adapter->current_op);
840 len = sizeof(struct virtchnl_rss_key) +
841 (adapter->rss_key_size * sizeof(u8)) - 1;
842 vrk = kzalloc(len, GFP_KERNEL);
845 vrk->vsi_id = adapter->vsi.id;
846 vrk->key_len = adapter->rss_key_size;
847 memcpy(vrk->key, adapter->rss_key, adapter->rss_key_size);
849 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_KEY;
850 adapter->aq_required &= ~IAVF_FLAG_AQ_SET_RSS_KEY;
851 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_KEY, (u8 *)vrk, len);
857 * @adapter: adapter structure
859 * Request the PF to set our RSS lookup table
861 void iavf_set_rss_lut(struct iavf_adapter *adapter)
863 struct virtchnl_rss_lut *vrl;
866 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
867 /* bail because we already have a command pending */
868 dev_err(&adapter->pdev->dev, "Cannot set RSS LUT, command %d pending\n",
869 adapter->current_op);
872 len = sizeof(struct virtchnl_rss_lut) +
873 (adapter->rss_lut_size * sizeof(u8)) - 1;
874 vrl = kzalloc(len, GFP_KERNEL);
877 vrl->vsi_id = adapter->vsi.id;
878 vrl->lut_entries = adapter->rss_lut_size;
879 memcpy(vrl->lut, adapter->rss_lut, adapter->rss_lut_size);
880 adapter->current_op = VIRTCHNL_OP_CONFIG_RSS_LUT;
881 adapter->aq_required &= ~IAVF_FLAG_AQ_SET_RSS_LUT;
882 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_RSS_LUT, (u8 *)vrl, len);
887 * iavf_enable_vlan_stripping
888 * @adapter: adapter structure
890 * Request VLAN header stripping to be enabled
892 void iavf_enable_vlan_stripping(struct iavf_adapter *adapter)
894 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
895 /* bail because we already have a command pending */
896 dev_err(&adapter->pdev->dev, "Cannot enable stripping, command %d pending\n",
897 adapter->current_op);
900 adapter->current_op = VIRTCHNL_OP_ENABLE_VLAN_STRIPPING;
901 adapter->aq_required &= ~IAVF_FLAG_AQ_ENABLE_VLAN_STRIPPING;
902 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING, NULL, 0);
906 * iavf_disable_vlan_stripping
907 * @adapter: adapter structure
909 * Request VLAN header stripping to be disabled
911 void iavf_disable_vlan_stripping(struct iavf_adapter *adapter)
913 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
914 /* bail because we already have a command pending */
915 dev_err(&adapter->pdev->dev, "Cannot disable stripping, command %d pending\n",
916 adapter->current_op);
919 adapter->current_op = VIRTCHNL_OP_DISABLE_VLAN_STRIPPING;
920 adapter->aq_required &= ~IAVF_FLAG_AQ_DISABLE_VLAN_STRIPPING;
921 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING, NULL, 0);
925 * iavf_print_link_message - print link up or down
926 * @adapter: adapter structure
928 * Log a message telling the world of our wonderous link status
930 static void iavf_print_link_message(struct iavf_adapter *adapter)
932 struct net_device *netdev = adapter->netdev;
933 char *speed = "Unknown ";
935 if (!adapter->link_up) {
936 netdev_info(netdev, "NIC Link is Down\n");
940 switch (adapter->link_speed) {
941 case I40E_LINK_SPEED_40GB:
944 case I40E_LINK_SPEED_25GB:
947 case I40E_LINK_SPEED_20GB:
950 case I40E_LINK_SPEED_10GB:
953 case I40E_LINK_SPEED_1GB:
956 case I40E_LINK_SPEED_100MB:
963 netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
967 * iavf_enable_channel
968 * @adapter: adapter structure
970 * Request that the PF enable channels as specified by
971 * the user via tc tool.
973 void iavf_enable_channels(struct iavf_adapter *adapter)
975 struct virtchnl_tc_info *vti = NULL;
979 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
980 /* bail because we already have a command pending */
981 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
982 adapter->current_op);
986 len = (adapter->num_tc * sizeof(struct virtchnl_channel_info)) +
987 sizeof(struct virtchnl_tc_info);
989 vti = kzalloc(len, GFP_KERNEL);
992 vti->num_tc = adapter->num_tc;
993 for (i = 0; i < vti->num_tc; i++) {
994 vti->list[i].count = adapter->ch_config.ch_info[i].count;
995 vti->list[i].offset = adapter->ch_config.ch_info[i].offset;
996 vti->list[i].pad = 0;
997 vti->list[i].max_tx_rate =
998 adapter->ch_config.ch_info[i].max_tx_rate;
1001 adapter->ch_config.state = __IAVF_TC_RUNNING;
1002 adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
1003 adapter->current_op = VIRTCHNL_OP_ENABLE_CHANNELS;
1004 adapter->aq_required &= ~IAVF_FLAG_AQ_ENABLE_CHANNELS;
1005 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_CHANNELS, (u8 *)vti, len);
1010 * iavf_disable_channel
1011 * @adapter: adapter structure
1013 * Request that the PF disable channels that are configured
1015 void iavf_disable_channels(struct iavf_adapter *adapter)
1017 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1018 /* bail because we already have a command pending */
1019 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
1020 adapter->current_op);
1024 adapter->ch_config.state = __IAVF_TC_INVALID;
1025 adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
1026 adapter->current_op = VIRTCHNL_OP_DISABLE_CHANNELS;
1027 adapter->aq_required &= ~IAVF_FLAG_AQ_DISABLE_CHANNELS;
1028 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_CHANNELS, NULL, 0);
1032 * iavf_print_cloud_filter
1033 * @adapter: adapter structure
1034 * @f: cloud filter to print
1036 * Print the cloud filter
1038 static void iavf_print_cloud_filter(struct iavf_adapter *adapter,
1039 struct virtchnl_filter *f)
1041 switch (f->flow_type) {
1042 case VIRTCHNL_TCP_V4_FLOW:
1043 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",
1044 &f->data.tcp_spec.dst_mac,
1045 &f->data.tcp_spec.src_mac,
1046 ntohs(f->data.tcp_spec.vlan_id),
1047 &f->data.tcp_spec.dst_ip[0],
1048 &f->data.tcp_spec.src_ip[0],
1049 ntohs(f->data.tcp_spec.dst_port),
1050 ntohs(f->data.tcp_spec.src_port));
1052 case VIRTCHNL_TCP_V6_FLOW:
1053 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",
1054 &f->data.tcp_spec.dst_mac,
1055 &f->data.tcp_spec.src_mac,
1056 ntohs(f->data.tcp_spec.vlan_id),
1057 &f->data.tcp_spec.dst_ip,
1058 &f->data.tcp_spec.src_ip,
1059 ntohs(f->data.tcp_spec.dst_port),
1060 ntohs(f->data.tcp_spec.src_port));
1066 * iavf_add_cloud_filter
1067 * @adapter: adapter structure
1069 * Request that the PF add cloud filters as specified
1070 * by the user via tc tool.
1072 void iavf_add_cloud_filter(struct iavf_adapter *adapter)
1074 struct iavf_cloud_filter *cf;
1075 struct virtchnl_filter *f;
1076 int len = 0, count = 0;
1078 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1079 /* bail because we already have a command pending */
1080 dev_err(&adapter->pdev->dev, "Cannot add cloud filter, command %d pending\n",
1081 adapter->current_op);
1084 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1091 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_CLOUD_FILTER;
1094 adapter->current_op = VIRTCHNL_OP_ADD_CLOUD_FILTER;
1096 len = sizeof(struct virtchnl_filter);
1097 f = kzalloc(len, GFP_KERNEL);
1101 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1103 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1105 cf->state = __IAVF_CF_ADD_PENDING;
1106 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_CLOUD_FILTER,
1114 * iavf_del_cloud_filter
1115 * @adapter: adapter structure
1117 * Request that the PF delete cloud filters as specified
1118 * by the user via tc tool.
1120 void iavf_del_cloud_filter(struct iavf_adapter *adapter)
1122 struct iavf_cloud_filter *cf, *cftmp;
1123 struct virtchnl_filter *f;
1124 int len = 0, count = 0;
1126 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1127 /* bail because we already have a command pending */
1128 dev_err(&adapter->pdev->dev, "Cannot remove cloud filter, command %d pending\n",
1129 adapter->current_op);
1132 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1139 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_CLOUD_FILTER;
1142 adapter->current_op = VIRTCHNL_OP_DEL_CLOUD_FILTER;
1144 len = sizeof(struct virtchnl_filter);
1145 f = kzalloc(len, GFP_KERNEL);
1149 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) {
1151 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1153 cf->state = __IAVF_CF_DEL_PENDING;
1154 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_CLOUD_FILTER,
1162 * iavf_request_reset
1163 * @adapter: adapter structure
1165 * Request that the PF reset this VF. No response is expected.
1167 void iavf_request_reset(struct iavf_adapter *adapter)
1169 /* Don't check CURRENT_OP - this is always higher priority */
1170 iavf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0);
1171 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
1175 * iavf_virtchnl_completion
1176 * @adapter: adapter structure
1177 * @v_opcode: opcode sent by PF
1178 * @v_retval: retval sent by PF
1179 * @msg: message sent by PF
1180 * @msglen: message length
1182 * Asynchronous completion function for admin queue messages. Rather than busy
1183 * wait, we fire off our requests and assume that no errors will be returned.
1184 * This function handles the reply messages.
1186 void iavf_virtchnl_completion(struct iavf_adapter *adapter,
1187 enum virtchnl_ops v_opcode, iavf_status v_retval,
1188 u8 *msg, u16 msglen)
1190 struct net_device *netdev = adapter->netdev;
1192 if (v_opcode == VIRTCHNL_OP_EVENT) {
1193 struct virtchnl_pf_event *vpe =
1194 (struct virtchnl_pf_event *)msg;
1195 bool link_up = vpe->event_data.link_event.link_status;
1197 switch (vpe->event) {
1198 case VIRTCHNL_EVENT_LINK_CHANGE:
1199 adapter->link_speed =
1200 vpe->event_data.link_event.link_speed;
1202 /* we've already got the right link status, bail */
1203 if (adapter->link_up == link_up)
1207 /* If we get link up message and start queues
1208 * before our queues are configured it will
1209 * trigger a TX hang. In that case, just ignore
1210 * the link status message,we'll get another one
1211 * after we enable queues and actually prepared
1214 if (adapter->state != __IAVF_RUNNING)
1217 /* For ADq enabled VF, we reconfigure VSIs and
1218 * re-allocate queues. Hence wait till all
1219 * queues are enabled.
1221 if (adapter->flags &
1222 IAVF_FLAG_QUEUES_DISABLED)
1226 adapter->link_up = link_up;
1228 netif_tx_start_all_queues(netdev);
1229 netif_carrier_on(netdev);
1231 netif_tx_stop_all_queues(netdev);
1232 netif_carrier_off(netdev);
1234 iavf_print_link_message(adapter);
1236 case VIRTCHNL_EVENT_RESET_IMPENDING:
1237 dev_info(&adapter->pdev->dev, "Reset warning received from the PF\n");
1238 if (!(adapter->flags & IAVF_FLAG_RESET_PENDING)) {
1239 adapter->flags |= IAVF_FLAG_RESET_PENDING;
1240 dev_info(&adapter->pdev->dev, "Scheduling reset task\n");
1241 schedule_work(&adapter->reset_task);
1245 dev_err(&adapter->pdev->dev, "Unknown event %d from PF\n",
1253 case VIRTCHNL_OP_ADD_VLAN:
1254 dev_err(&adapter->pdev->dev, "Failed to add VLAN filter, error %s\n",
1255 iavf_stat_str(&adapter->hw, v_retval));
1257 case VIRTCHNL_OP_ADD_ETH_ADDR:
1258 dev_err(&adapter->pdev->dev, "Failed to add MAC filter, error %s\n",
1259 iavf_stat_str(&adapter->hw, v_retval));
1261 case VIRTCHNL_OP_DEL_VLAN:
1262 dev_err(&adapter->pdev->dev, "Failed to delete VLAN filter, error %s\n",
1263 iavf_stat_str(&adapter->hw, v_retval));
1265 case VIRTCHNL_OP_DEL_ETH_ADDR:
1266 dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n",
1267 iavf_stat_str(&adapter->hw, v_retval));
1269 case VIRTCHNL_OP_ENABLE_CHANNELS:
1270 dev_err(&adapter->pdev->dev, "Failed to configure queue channels, error %s\n",
1271 iavf_stat_str(&adapter->hw, v_retval));
1272 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
1273 adapter->ch_config.state = __IAVF_TC_INVALID;
1274 netdev_reset_tc(netdev);
1275 netif_tx_start_all_queues(netdev);
1277 case VIRTCHNL_OP_DISABLE_CHANNELS:
1278 dev_err(&adapter->pdev->dev, "Failed to disable queue channels, error %s\n",
1279 iavf_stat_str(&adapter->hw, v_retval));
1280 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
1281 adapter->ch_config.state = __IAVF_TC_RUNNING;
1282 netif_tx_start_all_queues(netdev);
1284 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1285 struct iavf_cloud_filter *cf, *cftmp;
1287 list_for_each_entry_safe(cf, cftmp,
1288 &adapter->cloud_filter_list,
1290 if (cf->state == __IAVF_CF_ADD_PENDING) {
1291 cf->state = __IAVF_CF_INVALID;
1292 dev_info(&adapter->pdev->dev, "Failed to add cloud filter, error %s\n",
1293 iavf_stat_str(&adapter->hw,
1295 iavf_print_cloud_filter(adapter,
1297 list_del(&cf->list);
1299 adapter->num_cloud_filters--;
1304 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1305 struct iavf_cloud_filter *cf;
1307 list_for_each_entry(cf, &adapter->cloud_filter_list,
1309 if (cf->state == __IAVF_CF_DEL_PENDING) {
1310 cf->state = __IAVF_CF_ACTIVE;
1311 dev_info(&adapter->pdev->dev, "Failed to del cloud filter, error %s\n",
1312 iavf_stat_str(&adapter->hw,
1314 iavf_print_cloud_filter(adapter,
1321 dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",
1322 v_retval, iavf_stat_str(&adapter->hw, v_retval),
1327 case VIRTCHNL_OP_GET_STATS: {
1328 struct iavf_eth_stats *stats =
1329 (struct iavf_eth_stats *)msg;
1330 netdev->stats.rx_packets = stats->rx_unicast +
1331 stats->rx_multicast +
1332 stats->rx_broadcast;
1333 netdev->stats.tx_packets = stats->tx_unicast +
1334 stats->tx_multicast +
1335 stats->tx_broadcast;
1336 netdev->stats.rx_bytes = stats->rx_bytes;
1337 netdev->stats.tx_bytes = stats->tx_bytes;
1338 netdev->stats.tx_errors = stats->tx_errors;
1339 netdev->stats.rx_dropped = stats->rx_discards;
1340 netdev->stats.tx_dropped = stats->tx_discards;
1341 adapter->current_stats = *stats;
1344 case VIRTCHNL_OP_GET_VF_RESOURCES: {
1345 u16 len = sizeof(struct virtchnl_vf_resource) +
1347 sizeof(struct virtchnl_vsi_resource);
1348 memcpy(adapter->vf_res, msg, min(msglen, len));
1349 iavf_validate_num_queues(adapter);
1350 iavf_vf_parse_hw_config(&adapter->hw, adapter->vf_res);
1351 if (is_zero_ether_addr(adapter->hw.mac.addr)) {
1352 /* restore current mac address */
1353 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
1355 /* refresh current mac address if changed */
1356 ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
1357 ether_addr_copy(netdev->perm_addr,
1358 adapter->hw.mac.addr);
1360 iavf_process_config(adapter);
1363 case VIRTCHNL_OP_ENABLE_QUEUES:
1364 /* enable transmits */
1365 iavf_irq_enable(adapter, true);
1366 adapter->flags &= ~IAVF_FLAG_QUEUES_DISABLED;
1368 case VIRTCHNL_OP_DISABLE_QUEUES:
1369 iavf_free_all_tx_resources(adapter);
1370 iavf_free_all_rx_resources(adapter);
1371 if (adapter->state == __IAVF_DOWN_PENDING) {
1372 adapter->state = __IAVF_DOWN;
1373 wake_up(&adapter->down_waitqueue);
1376 case VIRTCHNL_OP_VERSION:
1377 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1378 /* Don't display an error if we get these out of sequence.
1379 * If the firmware needed to get kicked, we'll get these and
1382 if (v_opcode != adapter->current_op)
1385 case VIRTCHNL_OP_IWARP:
1386 /* Gobble zero-length replies from the PF. They indicate that
1387 * a previous message was received OK, and the client doesn't
1390 if (msglen && CLIENT_ENABLED(adapter))
1391 iavf_notify_client_message(&adapter->vsi, msg, msglen);
1394 case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
1395 adapter->client_pending &=
1396 ~(BIT(VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP));
1398 case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
1399 struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
1401 if (msglen == sizeof(*vrh))
1402 adapter->hena = vrh->hena;
1404 dev_warn(&adapter->pdev->dev,
1405 "Invalid message %d from PF\n", v_opcode);
1408 case VIRTCHNL_OP_REQUEST_QUEUES: {
1409 struct virtchnl_vf_res_request *vfres =
1410 (struct virtchnl_vf_res_request *)msg;
1412 if (vfres->num_queue_pairs != adapter->num_req_queues) {
1413 dev_info(&adapter->pdev->dev,
1414 "Requested %d queues, PF can support %d\n",
1415 adapter->num_req_queues,
1416 vfres->num_queue_pairs);
1417 adapter->num_req_queues = 0;
1418 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
1422 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1423 struct iavf_cloud_filter *cf;
1425 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1426 if (cf->state == __IAVF_CF_ADD_PENDING)
1427 cf->state = __IAVF_CF_ACTIVE;
1431 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1432 struct iavf_cloud_filter *cf, *cftmp;
1434 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list,
1436 if (cf->state == __IAVF_CF_DEL_PENDING) {
1437 cf->state = __IAVF_CF_INVALID;
1438 list_del(&cf->list);
1440 adapter->num_cloud_filters--;
1446 if (adapter->current_op && (v_opcode != adapter->current_op))
1447 dev_warn(&adapter->pdev->dev, "Expected response %d from PF, received %d\n",
1448 adapter->current_op, v_opcode);
1450 } /* switch v_opcode */
1451 adapter->current_op = VIRTCHNL_OP_UNKNOWN;