1
2
3
4#include "iavf.h"
5#include "iavf_prototype.h"
6#include "iavf_client.h"
7
8
9#define IAVF_BUSY_WAIT_DELAY 10
10#define IAVF_BUSY_WAIT_COUNT 50
11
12
13
14
15
16
17
18
19
20
21static int iavf_send_pf_msg(struct iavf_adapter *adapter,
22 enum virtchnl_ops op, u8 *msg, u16 len)
23{
24 struct iavf_hw *hw = &adapter->hw;
25 iavf_status err;
26
27 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED)
28 return 0;
29
30 err = iavf_aq_send_msg_to_pf(hw, op, 0, msg, len, NULL);
31 if (err)
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));
35 return err;
36}
37
38
39
40
41
42
43
44
45
46int iavf_send_api_ver(struct iavf_adapter *adapter)
47{
48 struct virtchnl_version_info vvi;
49
50 vvi.major = VIRTCHNL_VERSION_MAJOR;
51 vvi.minor = VIRTCHNL_VERSION_MINOR;
52
53 return iavf_send_pf_msg(adapter, VIRTCHNL_OP_VERSION, (u8 *)&vvi,
54 sizeof(vvi));
55}
56
57
58
59
60
61
62
63
64
65
66int iavf_verify_api_ver(struct iavf_adapter *adapter)
67{
68 struct virtchnl_version_info *pf_vvi;
69 struct iavf_hw *hw = &adapter->hw;
70 struct i40e_arq_event_info event;
71 enum virtchnl_ops op;
72 iavf_status err;
73
74 event.buf_len = IAVF_MAX_AQ_BUF_SIZE;
75 event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
76 if (!event.msg_buf) {
77 err = -ENOMEM;
78 goto out;
79 }
80
81 while (1) {
82 err = iavf_clean_arq_element(hw, &event, NULL);
83
84
85
86 if (err)
87 goto out_alloc;
88 op =
89 (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
90 if (op == VIRTCHNL_OP_VERSION)
91 break;
92 }
93
94
95 err = (iavf_status)le32_to_cpu(event.desc.cookie_low);
96 if (err)
97 goto out_alloc;
98
99 if (op != VIRTCHNL_OP_VERSION) {
100 dev_info(&adapter->pdev->dev, "Invalid reply type %d from PF\n",
101 op);
102 err = -EIO;
103 goto out_alloc;
104 }
105
106 pf_vvi = (struct virtchnl_version_info *)event.msg_buf;
107 adapter->pf_version = *pf_vvi;
108
109 if ((pf_vvi->major > VIRTCHNL_VERSION_MAJOR) ||
110 ((pf_vvi->major == VIRTCHNL_VERSION_MAJOR) &&
111 (pf_vvi->minor > VIRTCHNL_VERSION_MINOR)))
112 err = -EIO;
113
114out_alloc:
115 kfree(event.msg_buf);
116out:
117 return err;
118}
119
120
121
122
123
124
125
126
127
128int iavf_send_vf_config_msg(struct iavf_adapter *adapter)
129{
130 u32 caps;
131
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;
143
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));
149 else
150 return iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_VF_RESOURCES,
151 NULL, 0);
152}
153
154
155
156
157
158
159
160
161static void iavf_validate_num_queues(struct iavf_adapter *adapter)
162{
163 if (adapter->vf_res->num_queue_pairs > IAVF_MAX_REQ_QUEUES) {
164 struct virtchnl_vsi_resource *vsi_res;
165 int i;
166
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;
176 }
177 }
178}
179
180
181
182
183
184
185
186
187
188
189int iavf_get_vf_config(struct iavf_adapter *adapter)
190{
191 struct iavf_hw *hw = &adapter->hw;
192 struct i40e_arq_event_info event;
193 enum virtchnl_ops op;
194 iavf_status err;
195 u16 len;
196
197 len = sizeof(struct virtchnl_vf_resource) +
198 IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource);
199 event.buf_len = len;
200 event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
201 if (!event.msg_buf) {
202 err = -ENOMEM;
203 goto out;
204 }
205
206 while (1) {
207
208
209
210 err = iavf_clean_arq_element(hw, &event, NULL);
211 if (err)
212 goto out_alloc;
213 op =
214 (enum virtchnl_ops)le32_to_cpu(event.desc.cookie_high);
215 if (op == VIRTCHNL_OP_GET_VF_RESOURCES)
216 break;
217 }
218
219 err = (iavf_status)le32_to_cpu(event.desc.cookie_low);
220 memcpy(adapter->vf_res, event.msg_buf, min(event.msg_len, len));
221
222
223
224
225 if (!err)
226 iavf_validate_num_queues(adapter);
227 iavf_vf_parse_hw_config(hw, adapter->vf_res);
228out_alloc:
229 kfree(event.msg_buf);
230out:
231 return err;
232}
233
234
235
236
237
238
239
240void iavf_configure_queues(struct iavf_adapter *adapter)
241{
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;
246
247 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
248
249 dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n",
250 adapter->current_op);
251 return;
252 }
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);
257 if (!vqci)
258 return;
259
260
261 if (!(adapter->flags & IAVF_FLAG_LEGACY_RX) &&
262 (adapter->netdev->mtu <= ETH_DATA_LEN))
263 max_frame = IAVF_RXBUFFER_1536 - NET_IP_ALIGN;
264
265 vqci->vsi_id = adapter->vsi_res->vsi_id;
266 vqci->num_queue_pairs = pairs;
267 vqpi = vqci->qpair;
268
269
270
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));
284 vqpi++;
285 }
286
287 adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES;
288 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
289 (u8 *)vqci, len);
290 kfree(vqci);
291}
292
293
294
295
296
297
298
299void iavf_enable_queues(struct iavf_adapter *adapter)
300{
301 struct virtchnl_queue_select vqs;
302
303 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
304
305 dev_err(&adapter->pdev->dev, "Cannot enable queues, command %d pending\n",
306 adapter->current_op);
307 return;
308 }
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));
316}
317
318
319
320
321
322
323
324void iavf_disable_queues(struct iavf_adapter *adapter)
325{
326 struct virtchnl_queue_select vqs;
327
328 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
329
330 dev_err(&adapter->pdev->dev, "Cannot disable queues, command %d pending\n",
331 adapter->current_op);
332 return;
333 }
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));
341}
342
343
344
345
346
347
348
349
350void iavf_map_queues(struct iavf_adapter *adapter)
351{
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;
356
357 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
358
359 dev_err(&adapter->pdev->dev, "Cannot map queues to vectors, command %d pending\n",
360 adapter->current_op);
361 return;
362 }
363 adapter->current_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
364
365 q_vectors = adapter->num_msix_vectors - NONQ_VECS;
366
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);
371 if (!vimi)
372 return;
373
374 vimi->num_vectors = adapter->num_msix_vectors;
375
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];
379
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;
386 }
387
388 vecmap = &vimi->vecmap[v_idx];
389 vecmap->vsi_id = adapter->vsi_res->vsi_id;
390 vecmap->vector_id = 0;
391 vecmap->txq_map = 0;
392 vecmap->rxq_map = 0;
393
394 adapter->aq_required &= ~IAVF_FLAG_AQ_MAP_VECTORS;
395 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_IRQ_MAP,
396 (u8 *)vimi, len);
397 kfree(vimi);
398}
399
400
401
402
403
404
405
406
407
408int iavf_request_queues(struct iavf_adapter *adapter, int num)
409{
410 struct virtchnl_vf_res_request vfres;
411
412 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
413
414 dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n",
415 adapter->current_op);
416 return -EBUSY;
417 }
418
419 vfres.num_queue_pairs = num;
420
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));
425}
426
427
428
429
430
431
432
433void iavf_add_ether_addrs(struct iavf_adapter *adapter)
434{
435 struct virtchnl_ether_addr_list *veal;
436 int len, i = 0, count = 0;
437 struct iavf_mac_filter *f;
438 bool more = false;
439
440 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
441
442 dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n",
443 adapter->current_op);
444 return;
445 }
446
447 spin_lock_bh(&adapter->mac_vlan_list_lock);
448
449 list_for_each_entry(f, &adapter->mac_filter_list, list) {
450 if (f->add)
451 count++;
452 }
453 if (!count) {
454 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER;
455 spin_unlock_bh(&adapter->mac_vlan_list_lock);
456 return;
457 }
458 adapter->current_op = VIRTCHNL_OP_ADD_ETH_ADDR;
459
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));
469 more = true;
470 }
471
472 veal = kzalloc(len, GFP_ATOMIC);
473 if (!veal) {
474 spin_unlock_bh(&adapter->mac_vlan_list_lock);
475 return;
476 }
477
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) {
481 if (f->add) {
482 ether_addr_copy(veal->list[i].addr, f->macaddr);
483 i++;
484 f->add = false;
485 if (i == count)
486 break;
487 }
488 }
489 if (!more)
490 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER;
491
492 spin_unlock_bh(&adapter->mac_vlan_list_lock);
493
494 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len);
495 kfree(veal);
496}
497
498
499
500
501
502
503
504void iavf_del_ether_addrs(struct iavf_adapter *adapter)
505{
506 struct virtchnl_ether_addr_list *veal;
507 struct iavf_mac_filter *f, *ftmp;
508 int len, i = 0, count = 0;
509 bool more = false;
510
511 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
512
513 dev_err(&adapter->pdev->dev, "Cannot remove filters, command %d pending\n",
514 adapter->current_op);
515 return;
516 }
517
518 spin_lock_bh(&adapter->mac_vlan_list_lock);
519
520 list_for_each_entry(f, &adapter->mac_filter_list, list) {
521 if (f->remove)
522 count++;
523 }
524 if (!count) {
525 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_MAC_FILTER;
526 spin_unlock_bh(&adapter->mac_vlan_list_lock);
527 return;
528 }
529 adapter->current_op = VIRTCHNL_OP_DEL_ETH_ADDR;
530
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));
540 more = true;
541 }
542 veal = kzalloc(len, GFP_ATOMIC);
543 if (!veal) {
544 spin_unlock_bh(&adapter->mac_vlan_list_lock);
545 return;
546 }
547
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) {
551 if (f->remove) {
552 ether_addr_copy(veal->list[i].addr, f->macaddr);
553 i++;
554 list_del(&f->list);
555 kfree(f);
556 if (i == count)
557 break;
558 }
559 }
560 if (!more)
561 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_MAC_FILTER;
562
563 spin_unlock_bh(&adapter->mac_vlan_list_lock);
564
565 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_ETH_ADDR, (u8 *)veal, len);
566 kfree(veal);
567}
568
569
570
571
572
573
574
575void iavf_add_vlans(struct iavf_adapter *adapter)
576{
577 struct virtchnl_vlan_filter_list *vvfl;
578 int len, i = 0, count = 0;
579 struct iavf_vlan_filter *f;
580 bool more = false;
581
582 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
583
584 dev_err(&adapter->pdev->dev, "Cannot add VLANs, command %d pending\n",
585 adapter->current_op);
586 return;
587 }
588
589 spin_lock_bh(&adapter->mac_vlan_list_lock);
590
591 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
592 if (f->add)
593 count++;
594 }
595 if (!count) {
596 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
597 spin_unlock_bh(&adapter->mac_vlan_list_lock);
598 return;
599 }
600 adapter->current_op = VIRTCHNL_OP_ADD_VLAN;
601
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)) /
608 sizeof(u16);
609 len = sizeof(struct virtchnl_vlan_filter_list) +
610 (count * sizeof(u16));
611 more = true;
612 }
613 vvfl = kzalloc(len, GFP_ATOMIC);
614 if (!vvfl) {
615 spin_unlock_bh(&adapter->mac_vlan_list_lock);
616 return;
617 }
618
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) {
622 if (f->add) {
623 vvfl->vlan_id[i] = f->vlan;
624 i++;
625 f->add = false;
626 if (i == count)
627 break;
628 }
629 }
630 if (!more)
631 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
632
633 spin_unlock_bh(&adapter->mac_vlan_list_lock);
634
635 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);
636 kfree(vvfl);
637}
638
639
640
641
642
643
644
645void iavf_del_vlans(struct iavf_adapter *adapter)
646{
647 struct virtchnl_vlan_filter_list *vvfl;
648 struct iavf_vlan_filter *f, *ftmp;
649 int len, i = 0, count = 0;
650 bool more = false;
651
652 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
653
654 dev_err(&adapter->pdev->dev, "Cannot remove VLANs, command %d pending\n",
655 adapter->current_op);
656 return;
657 }
658
659 spin_lock_bh(&adapter->mac_vlan_list_lock);
660
661 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
662 if (f->remove)
663 count++;
664 }
665 if (!count) {
666 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
667 spin_unlock_bh(&adapter->mac_vlan_list_lock);
668 return;
669 }
670 adapter->current_op = VIRTCHNL_OP_DEL_VLAN;
671
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)) /
678 sizeof(u16);
679 len = sizeof(struct virtchnl_vlan_filter_list) +
680 (count * sizeof(u16));
681 more = true;
682 }
683 vvfl = kzalloc(len, GFP_ATOMIC);
684 if (!vvfl) {
685 spin_unlock_bh(&adapter->mac_vlan_list_lock);
686 return;
687 }
688
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) {
692 if (f->remove) {
693 vvfl->vlan_id[i] = f->vlan;
694 i++;
695 list_del(&f->list);
696 kfree(f);
697 if (i == count)
698 break;
699 }
700 }
701 if (!more)
702 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
703
704 spin_unlock_bh(&adapter->mac_vlan_list_lock);
705
706 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len);
707 kfree(vvfl);
708}
709
710
711
712
713
714
715
716
717void iavf_set_promiscuous(struct iavf_adapter *adapter, int flags)
718{
719 struct virtchnl_promisc_info vpi;
720 int promisc_all;
721
722 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
723
724 dev_err(&adapter->pdev->dev, "Cannot set promiscuous mode, command %d pending\n",
725 adapter->current_op);
726 return;
727 }
728
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");
735 }
736
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");
741 }
742
743 if (!flags) {
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");
749 }
750
751 adapter->current_op = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
752 vpi.vsi_id = adapter->vsi_res->vsi_id;
753 vpi.flags = flags;
754 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
755 (u8 *)&vpi, sizeof(vpi));
756}
757
758
759
760
761
762
763
764void iavf_request_stats(struct iavf_adapter *adapter)
765{
766 struct virtchnl_queue_select vqs;
767
768 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
769
770 return;
771 }
772 adapter->current_op = VIRTCHNL_OP_GET_STATS;
773 vqs.vsi_id = adapter->vsi_res->vsi_id;
774
775 if (iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_STATS, (u8 *)&vqs,
776 sizeof(vqs)))
777
778 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
779}
780
781
782
783
784
785
786
787void iavf_get_hena(struct iavf_adapter *adapter)
788{
789 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
790
791 dev_err(&adapter->pdev->dev, "Cannot get RSS hash capabilities, command %d pending\n",
792 adapter->current_op);
793 return;
794 }
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);
798}
799
800
801
802
803
804
805
806void iavf_set_hena(struct iavf_adapter *adapter)
807{
808 struct virtchnl_rss_hena vrh;
809
810 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
811
812 dev_err(&adapter->pdev->dev, "Cannot set RSS hash enable, command %d pending\n",
813 adapter->current_op);
814 return;
815 }
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,
820 sizeof(vrh));
821}
822
823
824
825
826
827
828
829void iavf_set_rss_key(struct iavf_adapter *adapter)
830{
831 struct virtchnl_rss_key *vrk;
832 int len;
833
834 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
835
836 dev_err(&adapter->pdev->dev, "Cannot set RSS key, command %d pending\n",
837 adapter->current_op);
838 return;
839 }
840 len = sizeof(struct virtchnl_rss_key) +
841 (adapter->rss_key_size * sizeof(u8)) - 1;
842 vrk = kzalloc(len, GFP_KERNEL);
843 if (!vrk)
844 return;
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);
848
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);
852 kfree(vrk);
853}
854
855
856
857
858
859
860
861void iavf_set_rss_lut(struct iavf_adapter *adapter)
862{
863 struct virtchnl_rss_lut *vrl;
864 int len;
865
866 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
867
868 dev_err(&adapter->pdev->dev, "Cannot set RSS LUT, command %d pending\n",
869 adapter->current_op);
870 return;
871 }
872 len = sizeof(struct virtchnl_rss_lut) +
873 (adapter->rss_lut_size * sizeof(u8)) - 1;
874 vrl = kzalloc(len, GFP_KERNEL);
875 if (!vrl)
876 return;
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);
883 kfree(vrl);
884}
885
886
887
888
889
890
891
892void iavf_enable_vlan_stripping(struct iavf_adapter *adapter)
893{
894 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
895
896 dev_err(&adapter->pdev->dev, "Cannot enable stripping, command %d pending\n",
897 adapter->current_op);
898 return;
899 }
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);
903}
904
905
906
907
908
909
910
911void iavf_disable_vlan_stripping(struct iavf_adapter *adapter)
912{
913 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
914
915 dev_err(&adapter->pdev->dev, "Cannot disable stripping, command %d pending\n",
916 adapter->current_op);
917 return;
918 }
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);
922}
923
924
925
926
927
928
929
930static void iavf_print_link_message(struct iavf_adapter *adapter)
931{
932 struct net_device *netdev = adapter->netdev;
933 char *speed = "Unknown ";
934
935 if (!adapter->link_up) {
936 netdev_info(netdev, "NIC Link is Down\n");
937 return;
938 }
939
940 switch (adapter->link_speed) {
941 case I40E_LINK_SPEED_40GB:
942 speed = "40 G";
943 break;
944 case I40E_LINK_SPEED_25GB:
945 speed = "25 G";
946 break;
947 case I40E_LINK_SPEED_20GB:
948 speed = "20 G";
949 break;
950 case I40E_LINK_SPEED_10GB:
951 speed = "10 G";
952 break;
953 case I40E_LINK_SPEED_1GB:
954 speed = "1000 M";
955 break;
956 case I40E_LINK_SPEED_100MB:
957 speed = "100 M";
958 break;
959 default:
960 break;
961 }
962
963 netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
964}
965
966
967
968
969
970
971
972
973void iavf_enable_channels(struct iavf_adapter *adapter)
974{
975 struct virtchnl_tc_info *vti = NULL;
976 u16 len;
977 int i;
978
979 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
980
981 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
982 adapter->current_op);
983 return;
984 }
985
986 len = (adapter->num_tc * sizeof(struct virtchnl_channel_info)) +
987 sizeof(struct virtchnl_tc_info);
988
989 vti = kzalloc(len, GFP_KERNEL);
990 if (!vti)
991 return;
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;
999 }
1000
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);
1006 kfree(vti);
1007}
1008
1009
1010
1011
1012
1013
1014
1015void iavf_disable_channels(struct iavf_adapter *adapter)
1016{
1017 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1018
1019 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
1020 adapter->current_op);
1021 return;
1022 }
1023
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);
1029}
1030
1031
1032
1033
1034
1035
1036
1037
1038static void iavf_print_cloud_filter(struct iavf_adapter *adapter,
1039 struct virtchnl_filter *f)
1040{
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));
1051 break;
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));
1061 break;
1062 }
1063}
1064
1065
1066
1067
1068
1069
1070
1071
1072void iavf_add_cloud_filter(struct iavf_adapter *adapter)
1073{
1074 struct iavf_cloud_filter *cf;
1075 struct virtchnl_filter *f;
1076 int len = 0, count = 0;
1077
1078 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1079
1080 dev_err(&adapter->pdev->dev, "Cannot add cloud filter, command %d pending\n",
1081 adapter->current_op);
1082 return;
1083 }
1084 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1085 if (cf->add) {
1086 count++;
1087 break;
1088 }
1089 }
1090 if (!count) {
1091 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_CLOUD_FILTER;
1092 return;
1093 }
1094 adapter->current_op = VIRTCHNL_OP_ADD_CLOUD_FILTER;
1095
1096 len = sizeof(struct virtchnl_filter);
1097 f = kzalloc(len, GFP_KERNEL);
1098 if (!f)
1099 return;
1100
1101 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1102 if (cf->add) {
1103 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1104 cf->add = false;
1105 cf->state = __IAVF_CF_ADD_PENDING;
1106 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_CLOUD_FILTER,
1107 (u8 *)f, len);
1108 }
1109 }
1110 kfree(f);
1111}
1112
1113
1114
1115
1116
1117
1118
1119
1120void iavf_del_cloud_filter(struct iavf_adapter *adapter)
1121{
1122 struct iavf_cloud_filter *cf, *cftmp;
1123 struct virtchnl_filter *f;
1124 int len = 0, count = 0;
1125
1126 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1127
1128 dev_err(&adapter->pdev->dev, "Cannot remove cloud filter, command %d pending\n",
1129 adapter->current_op);
1130 return;
1131 }
1132 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1133 if (cf->del) {
1134 count++;
1135 break;
1136 }
1137 }
1138 if (!count) {
1139 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_CLOUD_FILTER;
1140 return;
1141 }
1142 adapter->current_op = VIRTCHNL_OP_DEL_CLOUD_FILTER;
1143
1144 len = sizeof(struct virtchnl_filter);
1145 f = kzalloc(len, GFP_KERNEL);
1146 if (!f)
1147 return;
1148
1149 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) {
1150 if (cf->del) {
1151 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1152 cf->del = false;
1153 cf->state = __IAVF_CF_DEL_PENDING;
1154 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_CLOUD_FILTER,
1155 (u8 *)f, len);
1156 }
1157 }
1158 kfree(f);
1159}
1160
1161
1162
1163
1164
1165
1166
1167void iavf_request_reset(struct iavf_adapter *adapter)
1168{
1169
1170 iavf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0);
1171 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
1172}
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186void iavf_virtchnl_completion(struct iavf_adapter *adapter,
1187 enum virtchnl_ops v_opcode, iavf_status v_retval,
1188 u8 *msg, u16 msglen)
1189{
1190 struct net_device *netdev = adapter->netdev;
1191
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;
1196
1197 switch (vpe->event) {
1198 case VIRTCHNL_EVENT_LINK_CHANGE:
1199 adapter->link_speed =
1200 vpe->event_data.link_event.link_speed;
1201
1202
1203 if (adapter->link_up == link_up)
1204 break;
1205
1206 if (link_up) {
1207
1208
1209
1210
1211
1212
1213
1214 if (adapter->state != __IAVF_RUNNING)
1215 break;
1216
1217
1218
1219
1220
1221 if (adapter->flags &
1222 IAVF_FLAG_QUEUES_DISABLED)
1223 break;
1224 }
1225
1226 adapter->link_up = link_up;
1227 if (link_up) {
1228 netif_tx_start_all_queues(netdev);
1229 netif_carrier_on(netdev);
1230 } else {
1231 netif_tx_stop_all_queues(netdev);
1232 netif_carrier_off(netdev);
1233 }
1234 iavf_print_link_message(adapter);
1235 break;
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);
1242 }
1243 break;
1244 default:
1245 dev_err(&adapter->pdev->dev, "Unknown event %d from PF\n",
1246 vpe->event);
1247 break;
1248 }
1249 return;
1250 }
1251 if (v_retval) {
1252 switch (v_opcode) {
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));
1256 break;
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));
1260 break;
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));
1264 break;
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));
1268 break;
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);
1276 break;
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);
1283 break;
1284 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1285 struct iavf_cloud_filter *cf, *cftmp;
1286
1287 list_for_each_entry_safe(cf, cftmp,
1288 &adapter->cloud_filter_list,
1289 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,
1294 v_retval));
1295 iavf_print_cloud_filter(adapter,
1296 &cf->f);
1297 list_del(&cf->list);
1298 kfree(cf);
1299 adapter->num_cloud_filters--;
1300 }
1301 }
1302 }
1303 break;
1304 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1305 struct iavf_cloud_filter *cf;
1306
1307 list_for_each_entry(cf, &adapter->cloud_filter_list,
1308 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,
1313 v_retval));
1314 iavf_print_cloud_filter(adapter,
1315 &cf->f);
1316 }
1317 }
1318 }
1319 break;
1320 default:
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),
1323 v_opcode);
1324 }
1325 }
1326 switch (v_opcode) {
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;
1342 }
1343 break;
1344 case VIRTCHNL_OP_GET_VF_RESOURCES: {
1345 u16 len = sizeof(struct virtchnl_vf_resource) +
1346 IAVF_MAX_VF_VSI *
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
1353 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
1354 } else {
1355
1356 ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
1357 ether_addr_copy(netdev->perm_addr,
1358 adapter->hw.mac.addr);
1359 }
1360 iavf_process_config(adapter);
1361 }
1362 break;
1363 case VIRTCHNL_OP_ENABLE_QUEUES:
1364
1365 iavf_irq_enable(adapter, true);
1366 adapter->flags &= ~IAVF_FLAG_QUEUES_DISABLED;
1367 break;
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);
1374 }
1375 break;
1376 case VIRTCHNL_OP_VERSION:
1377 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1378
1379
1380
1381
1382 if (v_opcode != adapter->current_op)
1383 return;
1384 break;
1385 case VIRTCHNL_OP_IWARP:
1386
1387
1388
1389
1390 if (msglen && CLIENT_ENABLED(adapter))
1391 iavf_notify_client_message(&adapter->vsi, msg, msglen);
1392 break;
1393
1394 case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
1395 adapter->client_pending &=
1396 ~(BIT(VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP));
1397 break;
1398 case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
1399 struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
1400
1401 if (msglen == sizeof(*vrh))
1402 adapter->hena = vrh->hena;
1403 else
1404 dev_warn(&adapter->pdev->dev,
1405 "Invalid message %d from PF\n", v_opcode);
1406 }
1407 break;
1408 case VIRTCHNL_OP_REQUEST_QUEUES: {
1409 struct virtchnl_vf_res_request *vfres =
1410 (struct virtchnl_vf_res_request *)msg;
1411
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;
1419 }
1420 }
1421 break;
1422 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1423 struct iavf_cloud_filter *cf;
1424
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;
1428 }
1429 }
1430 break;
1431 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1432 struct iavf_cloud_filter *cf, *cftmp;
1433
1434 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list,
1435 list) {
1436 if (cf->state == __IAVF_CF_DEL_PENDING) {
1437 cf->state = __IAVF_CF_INVALID;
1438 list_del(&cf->list);
1439 kfree(cf);
1440 adapter->num_cloud_filters--;
1441 }
1442 }
1443 }
1444 break;
1445 default:
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);
1449 break;
1450 }
1451 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
1452}
1453