This source file includes following definitions.
- iavf_send_pf_msg
- iavf_send_api_ver
- iavf_verify_api_ver
- iavf_send_vf_config_msg
- iavf_validate_num_queues
- iavf_get_vf_config
- iavf_configure_queues
- iavf_enable_queues
- iavf_disable_queues
- iavf_map_queues
- iavf_request_queues
- iavf_add_ether_addrs
- iavf_del_ether_addrs
- iavf_add_vlans
- iavf_del_vlans
- iavf_set_promiscuous
- iavf_request_stats
- iavf_get_hena
- iavf_set_hena
- iavf_set_rss_key
- iavf_set_rss_lut
- iavf_enable_vlan_stripping
- iavf_disable_vlan_stripping
- iavf_print_link_message
- iavf_enable_channels
- iavf_disable_channels
- iavf_print_cloud_filter
- iavf_add_cloud_filter
- iavf_del_cloud_filter
- iavf_request_reset
- iavf_virtchnl_completion
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
21 static 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 enum 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
46 int 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
66 int 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 iavf_arq_event_info event;
71 enum virtchnl_ops op;
72 enum 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 = (enum 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
114 out_alloc:
115 kfree(event.msg_buf);
116 out:
117 return err;
118 }
119
120
121
122
123
124
125
126
127
128 int 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
161 static 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
189 int iavf_get_vf_config(struct iavf_adapter *adapter)
190 {
191 struct iavf_hw *hw = &adapter->hw;
192 struct iavf_arq_event_info event;
193 enum virtchnl_ops op;
194 enum 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 = (enum 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);
228 out_alloc:
229 kfree(event.msg_buf);
230 out:
231 return err;
232 }
233
234
235
236
237
238
239
240 void 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, max_frame = IAVF_MAX_RXBUFFER;
246 size_t len;
247
248 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
249
250 dev_err(&adapter->pdev->dev, "Cannot configure queues, command %d pending\n",
251 adapter->current_op);
252 return;
253 }
254 adapter->current_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
255 len = struct_size(vqci, qpair, 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
299 void 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
324 void 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
350 void iavf_map_queues(struct iavf_adapter *adapter)
351 {
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;
356 size_t len;
357
358 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
359
360 dev_err(&adapter->pdev->dev, "Cannot map queues to vectors, command %d pending\n",
361 adapter->current_op);
362 return;
363 }
364 adapter->current_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
365
366 q_vectors = adapter->num_msix_vectors - NONQ_VECS;
367
368 len = struct_size(vimi, vecmap, adapter->num_msix_vectors);
369 vimi = kzalloc(len, GFP_KERNEL);
370 if (!vimi)
371 return;
372
373 vimi->num_vectors = adapter->num_msix_vectors;
374
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];
378
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;
385 }
386
387 vecmap = &vimi->vecmap[v_idx];
388 vecmap->vsi_id = adapter->vsi_res->vsi_id;
389 vecmap->vector_id = 0;
390 vecmap->txq_map = 0;
391 vecmap->rxq_map = 0;
392
393 adapter->aq_required &= ~IAVF_FLAG_AQ_MAP_VECTORS;
394 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_IRQ_MAP,
395 (u8 *)vimi, len);
396 kfree(vimi);
397 }
398
399
400
401
402
403
404
405
406
407 int iavf_request_queues(struct iavf_adapter *adapter, int num)
408 {
409 struct virtchnl_vf_res_request vfres;
410
411 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
412
413 dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n",
414 adapter->current_op);
415 return -EBUSY;
416 }
417
418 vfres.num_queue_pairs = min_t(int, num, num_online_cpus());
419
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));
424 }
425
426
427
428
429
430
431
432 void iavf_add_ether_addrs(struct iavf_adapter *adapter)
433 {
434 struct virtchnl_ether_addr_list *veal;
435 struct iavf_mac_filter *f;
436 int i = 0, count = 0;
437 bool more = false;
438 size_t len;
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 = 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);
467 more = true;
468 }
469
470 veal = kzalloc(len, GFP_ATOMIC);
471 if (!veal) {
472 spin_unlock_bh(&adapter->mac_vlan_list_lock);
473 return;
474 }
475
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) {
479 if (f->add) {
480 ether_addr_copy(veal->list[i].addr, f->macaddr);
481 i++;
482 f->add = false;
483 if (i == count)
484 break;
485 }
486 }
487 if (!more)
488 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER;
489
490 spin_unlock_bh(&adapter->mac_vlan_list_lock);
491
492 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len);
493 kfree(veal);
494 }
495
496
497
498
499
500
501
502 void iavf_del_ether_addrs(struct iavf_adapter *adapter)
503 {
504 struct virtchnl_ether_addr_list *veal;
505 struct iavf_mac_filter *f, *ftmp;
506 int i = 0, count = 0;
507 bool more = false;
508 size_t len;
509
510 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
511
512 dev_err(&adapter->pdev->dev, "Cannot remove filters, command %d pending\n",
513 adapter->current_op);
514 return;
515 }
516
517 spin_lock_bh(&adapter->mac_vlan_list_lock);
518
519 list_for_each_entry(f, &adapter->mac_filter_list, list) {
520 if (f->remove)
521 count++;
522 }
523 if (!count) {
524 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_MAC_FILTER;
525 spin_unlock_bh(&adapter->mac_vlan_list_lock);
526 return;
527 }
528 adapter->current_op = VIRTCHNL_OP_DEL_ETH_ADDR;
529
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);
537 more = true;
538 }
539 veal = kzalloc(len, GFP_ATOMIC);
540 if (!veal) {
541 spin_unlock_bh(&adapter->mac_vlan_list_lock);
542 return;
543 }
544
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) {
548 if (f->remove) {
549 ether_addr_copy(veal->list[i].addr, f->macaddr);
550 i++;
551 list_del(&f->list);
552 kfree(f);
553 if (i == count)
554 break;
555 }
556 }
557 if (!more)
558 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_MAC_FILTER;
559
560 spin_unlock_bh(&adapter->mac_vlan_list_lock);
561
562 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_ETH_ADDR, (u8 *)veal, len);
563 kfree(veal);
564 }
565
566
567
568
569
570
571
572 void iavf_add_vlans(struct iavf_adapter *adapter)
573 {
574 struct virtchnl_vlan_filter_list *vvfl;
575 int len, i = 0, count = 0;
576 struct iavf_vlan_filter *f;
577 bool more = false;
578
579 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
580
581 dev_err(&adapter->pdev->dev, "Cannot add VLANs, command %d pending\n",
582 adapter->current_op);
583 return;
584 }
585
586 spin_lock_bh(&adapter->mac_vlan_list_lock);
587
588 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
589 if (f->add)
590 count++;
591 }
592 if (!count) {
593 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
594 spin_unlock_bh(&adapter->mac_vlan_list_lock);
595 return;
596 }
597 adapter->current_op = VIRTCHNL_OP_ADD_VLAN;
598
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)) /
605 sizeof(u16);
606 len = sizeof(struct virtchnl_vlan_filter_list) +
607 (count * sizeof(u16));
608 more = true;
609 }
610 vvfl = kzalloc(len, GFP_ATOMIC);
611 if (!vvfl) {
612 spin_unlock_bh(&adapter->mac_vlan_list_lock);
613 return;
614 }
615
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) {
619 if (f->add) {
620 vvfl->vlan_id[i] = f->vlan;
621 i++;
622 f->add = false;
623 if (i == count)
624 break;
625 }
626 }
627 if (!more)
628 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_VLAN_FILTER;
629
630 spin_unlock_bh(&adapter->mac_vlan_list_lock);
631
632 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_VLAN, (u8 *)vvfl, len);
633 kfree(vvfl);
634 }
635
636
637
638
639
640
641
642 void iavf_del_vlans(struct iavf_adapter *adapter)
643 {
644 struct virtchnl_vlan_filter_list *vvfl;
645 struct iavf_vlan_filter *f, *ftmp;
646 int len, i = 0, count = 0;
647 bool more = false;
648
649 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
650
651 dev_err(&adapter->pdev->dev, "Cannot remove VLANs, command %d pending\n",
652 adapter->current_op);
653 return;
654 }
655
656 spin_lock_bh(&adapter->mac_vlan_list_lock);
657
658 list_for_each_entry(f, &adapter->vlan_filter_list, list) {
659 if (f->remove)
660 count++;
661 }
662 if (!count) {
663 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
664 spin_unlock_bh(&adapter->mac_vlan_list_lock);
665 return;
666 }
667 adapter->current_op = VIRTCHNL_OP_DEL_VLAN;
668
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)) /
675 sizeof(u16);
676 len = sizeof(struct virtchnl_vlan_filter_list) +
677 (count * sizeof(u16));
678 more = true;
679 }
680 vvfl = kzalloc(len, GFP_ATOMIC);
681 if (!vvfl) {
682 spin_unlock_bh(&adapter->mac_vlan_list_lock);
683 return;
684 }
685
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) {
689 if (f->remove) {
690 vvfl->vlan_id[i] = f->vlan;
691 i++;
692 list_del(&f->list);
693 kfree(f);
694 if (i == count)
695 break;
696 }
697 }
698 if (!more)
699 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_VLAN_FILTER;
700
701 spin_unlock_bh(&adapter->mac_vlan_list_lock);
702
703 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_VLAN, (u8 *)vvfl, len);
704 kfree(vvfl);
705 }
706
707
708
709
710
711
712
713
714 void iavf_set_promiscuous(struct iavf_adapter *adapter, int flags)
715 {
716 struct virtchnl_promisc_info vpi;
717 int promisc_all;
718
719 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
720
721 dev_err(&adapter->pdev->dev, "Cannot set promiscuous mode, command %d pending\n",
722 adapter->current_op);
723 return;
724 }
725
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");
732 }
733
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");
738 }
739
740 if (!flags) {
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");
746 }
747
748 adapter->current_op = VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE;
749 vpi.vsi_id = adapter->vsi_res->vsi_id;
750 vpi.flags = flags;
751 iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE,
752 (u8 *)&vpi, sizeof(vpi));
753 }
754
755
756
757
758
759
760
761 void iavf_request_stats(struct iavf_adapter *adapter)
762 {
763 struct virtchnl_queue_select vqs;
764
765 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
766
767 return;
768 }
769 adapter->current_op = VIRTCHNL_OP_GET_STATS;
770 vqs.vsi_id = adapter->vsi_res->vsi_id;
771
772 if (iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_STATS, (u8 *)&vqs,
773 sizeof(vqs)))
774
775 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
776 }
777
778
779
780
781
782
783
784 void iavf_get_hena(struct iavf_adapter *adapter)
785 {
786 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
787
788 dev_err(&adapter->pdev->dev, "Cannot get RSS hash capabilities, command %d pending\n",
789 adapter->current_op);
790 return;
791 }
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);
795 }
796
797
798
799
800
801
802
803 void iavf_set_hena(struct iavf_adapter *adapter)
804 {
805 struct virtchnl_rss_hena vrh;
806
807 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
808
809 dev_err(&adapter->pdev->dev, "Cannot set RSS hash enable, command %d pending\n",
810 adapter->current_op);
811 return;
812 }
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,
817 sizeof(vrh));
818 }
819
820
821
822
823
824
825
826 void iavf_set_rss_key(struct iavf_adapter *adapter)
827 {
828 struct virtchnl_rss_key *vrk;
829 int len;
830
831 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
832
833 dev_err(&adapter->pdev->dev, "Cannot set RSS key, command %d pending\n",
834 adapter->current_op);
835 return;
836 }
837 len = sizeof(struct virtchnl_rss_key) +
838 (adapter->rss_key_size * sizeof(u8)) - 1;
839 vrk = kzalloc(len, GFP_KERNEL);
840 if (!vrk)
841 return;
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);
845
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);
849 kfree(vrk);
850 }
851
852
853
854
855
856
857
858 void iavf_set_rss_lut(struct iavf_adapter *adapter)
859 {
860 struct virtchnl_rss_lut *vrl;
861 int len;
862
863 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
864
865 dev_err(&adapter->pdev->dev, "Cannot set RSS LUT, command %d pending\n",
866 adapter->current_op);
867 return;
868 }
869 len = sizeof(struct virtchnl_rss_lut) +
870 (adapter->rss_lut_size * sizeof(u8)) - 1;
871 vrl = kzalloc(len, GFP_KERNEL);
872 if (!vrl)
873 return;
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);
880 kfree(vrl);
881 }
882
883
884
885
886
887
888
889 void iavf_enable_vlan_stripping(struct iavf_adapter *adapter)
890 {
891 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
892
893 dev_err(&adapter->pdev->dev, "Cannot enable stripping, command %d pending\n",
894 adapter->current_op);
895 return;
896 }
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);
900 }
901
902
903
904
905
906
907
908 void iavf_disable_vlan_stripping(struct iavf_adapter *adapter)
909 {
910 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
911
912 dev_err(&adapter->pdev->dev, "Cannot disable stripping, command %d pending\n",
913 adapter->current_op);
914 return;
915 }
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);
919 }
920
921
922
923
924
925
926
927 static void iavf_print_link_message(struct iavf_adapter *adapter)
928 {
929 struct net_device *netdev = adapter->netdev;
930 char *speed = "Unknown ";
931
932 if (!adapter->link_up) {
933 netdev_info(netdev, "NIC Link is Down\n");
934 return;
935 }
936
937 switch (adapter->link_speed) {
938 case IAVF_LINK_SPEED_40GB:
939 speed = "40 G";
940 break;
941 case IAVF_LINK_SPEED_25GB:
942 speed = "25 G";
943 break;
944 case IAVF_LINK_SPEED_20GB:
945 speed = "20 G";
946 break;
947 case IAVF_LINK_SPEED_10GB:
948 speed = "10 G";
949 break;
950 case IAVF_LINK_SPEED_1GB:
951 speed = "1000 M";
952 break;
953 case IAVF_LINK_SPEED_100MB:
954 speed = "100 M";
955 break;
956 default:
957 break;
958 }
959
960 netdev_info(netdev, "NIC Link is Up %sbps Full Duplex\n", speed);
961 }
962
963
964
965
966
967
968
969
970 void iavf_enable_channels(struct iavf_adapter *adapter)
971 {
972 struct virtchnl_tc_info *vti = NULL;
973 size_t len;
974 int i;
975
976 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
977
978 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
979 adapter->current_op);
980 return;
981 }
982
983 len = struct_size(vti, list, adapter->num_tc - 1);
984 vti = kzalloc(len, GFP_KERNEL);
985 if (!vti)
986 return;
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;
994 }
995
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);
1001 kfree(vti);
1002 }
1003
1004
1005
1006
1007
1008
1009
1010 void iavf_disable_channels(struct iavf_adapter *adapter)
1011 {
1012 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1013
1014 dev_err(&adapter->pdev->dev, "Cannot configure mqprio, command %d pending\n",
1015 adapter->current_op);
1016 return;
1017 }
1018
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);
1024 }
1025
1026
1027
1028
1029
1030
1031
1032
1033 static void iavf_print_cloud_filter(struct iavf_adapter *adapter,
1034 struct virtchnl_filter *f)
1035 {
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));
1046 break;
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));
1056 break;
1057 }
1058 }
1059
1060
1061
1062
1063
1064
1065
1066
1067 void iavf_add_cloud_filter(struct iavf_adapter *adapter)
1068 {
1069 struct iavf_cloud_filter *cf;
1070 struct virtchnl_filter *f;
1071 int len = 0, count = 0;
1072
1073 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1074
1075 dev_err(&adapter->pdev->dev, "Cannot add cloud filter, command %d pending\n",
1076 adapter->current_op);
1077 return;
1078 }
1079 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1080 if (cf->add) {
1081 count++;
1082 break;
1083 }
1084 }
1085 if (!count) {
1086 adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_CLOUD_FILTER;
1087 return;
1088 }
1089 adapter->current_op = VIRTCHNL_OP_ADD_CLOUD_FILTER;
1090
1091 len = sizeof(struct virtchnl_filter);
1092 f = kzalloc(len, GFP_KERNEL);
1093 if (!f)
1094 return;
1095
1096 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1097 if (cf->add) {
1098 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1099 cf->add = false;
1100 cf->state = __IAVF_CF_ADD_PENDING;
1101 iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_CLOUD_FILTER,
1102 (u8 *)f, len);
1103 }
1104 }
1105 kfree(f);
1106 }
1107
1108
1109
1110
1111
1112
1113
1114
1115 void iavf_del_cloud_filter(struct iavf_adapter *adapter)
1116 {
1117 struct iavf_cloud_filter *cf, *cftmp;
1118 struct virtchnl_filter *f;
1119 int len = 0, count = 0;
1120
1121 if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
1122
1123 dev_err(&adapter->pdev->dev, "Cannot remove cloud filter, command %d pending\n",
1124 adapter->current_op);
1125 return;
1126 }
1127 list_for_each_entry(cf, &adapter->cloud_filter_list, list) {
1128 if (cf->del) {
1129 count++;
1130 break;
1131 }
1132 }
1133 if (!count) {
1134 adapter->aq_required &= ~IAVF_FLAG_AQ_DEL_CLOUD_FILTER;
1135 return;
1136 }
1137 adapter->current_op = VIRTCHNL_OP_DEL_CLOUD_FILTER;
1138
1139 len = sizeof(struct virtchnl_filter);
1140 f = kzalloc(len, GFP_KERNEL);
1141 if (!f)
1142 return;
1143
1144 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) {
1145 if (cf->del) {
1146 memcpy(f, &cf->f, sizeof(struct virtchnl_filter));
1147 cf->del = false;
1148 cf->state = __IAVF_CF_DEL_PENDING;
1149 iavf_send_pf_msg(adapter, VIRTCHNL_OP_DEL_CLOUD_FILTER,
1150 (u8 *)f, len);
1151 }
1152 }
1153 kfree(f);
1154 }
1155
1156
1157
1158
1159
1160
1161
1162 void iavf_request_reset(struct iavf_adapter *adapter)
1163 {
1164
1165 iavf_send_pf_msg(adapter, VIRTCHNL_OP_RESET_VF, NULL, 0);
1166 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
1167 }
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
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)
1184 {
1185 struct net_device *netdev = adapter->netdev;
1186
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;
1191
1192 switch (vpe->event) {
1193 case VIRTCHNL_EVENT_LINK_CHANGE:
1194 adapter->link_speed =
1195 vpe->event_data.link_event.link_speed;
1196
1197
1198 if (adapter->link_up == link_up)
1199 break;
1200
1201 if (link_up) {
1202
1203
1204
1205
1206
1207
1208
1209 if (adapter->state != __IAVF_RUNNING)
1210 break;
1211
1212
1213
1214
1215
1216 if (adapter->flags &
1217 IAVF_FLAG_QUEUES_DISABLED)
1218 break;
1219 }
1220
1221 adapter->link_up = link_up;
1222 if (link_up) {
1223 netif_tx_start_all_queues(netdev);
1224 netif_carrier_on(netdev);
1225 } else {
1226 netif_tx_stop_all_queues(netdev);
1227 netif_carrier_off(netdev);
1228 }
1229 iavf_print_link_message(adapter);
1230 break;
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);
1237 }
1238 break;
1239 default:
1240 dev_err(&adapter->pdev->dev, "Unknown event %d from PF\n",
1241 vpe->event);
1242 break;
1243 }
1244 return;
1245 }
1246 if (v_retval) {
1247 switch (v_opcode) {
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));
1251 break;
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
1256 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
1257 break;
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));
1261 break;
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));
1265 break;
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);
1273 break;
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);
1280 break;
1281 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1282 struct iavf_cloud_filter *cf, *cftmp;
1283
1284 list_for_each_entry_safe(cf, cftmp,
1285 &adapter->cloud_filter_list,
1286 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,
1291 v_retval));
1292 iavf_print_cloud_filter(adapter,
1293 &cf->f);
1294 list_del(&cf->list);
1295 kfree(cf);
1296 adapter->num_cloud_filters--;
1297 }
1298 }
1299 }
1300 break;
1301 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1302 struct iavf_cloud_filter *cf;
1303
1304 list_for_each_entry(cf, &adapter->cloud_filter_list,
1305 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,
1310 v_retval));
1311 iavf_print_cloud_filter(adapter,
1312 &cf->f);
1313 }
1314 }
1315 }
1316 break;
1317 default:
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),
1320 v_opcode);
1321 }
1322 }
1323 switch (v_opcode) {
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);
1327 }
1328 break;
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;
1344 }
1345 break;
1346 case VIRTCHNL_OP_GET_VF_RESOURCES: {
1347 u16 len = sizeof(struct virtchnl_vf_resource) +
1348 IAVF_MAX_VF_VSI *
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
1355 ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);
1356 } else {
1357
1358 ether_addr_copy(netdev->dev_addr, adapter->hw.mac.addr);
1359 ether_addr_copy(netdev->perm_addr,
1360 adapter->hw.mac.addr);
1361 }
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);
1366 }
1367 break;
1368 case VIRTCHNL_OP_ENABLE_QUEUES:
1369
1370 iavf_irq_enable(adapter, true);
1371 adapter->flags &= ~IAVF_FLAG_QUEUES_DISABLED;
1372 break;
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);
1379 }
1380 break;
1381 case VIRTCHNL_OP_VERSION:
1382 case VIRTCHNL_OP_CONFIG_IRQ_MAP:
1383
1384
1385
1386
1387 if (v_opcode != adapter->current_op)
1388 return;
1389 break;
1390 case VIRTCHNL_OP_IWARP:
1391
1392
1393
1394
1395 if (msglen && CLIENT_ENABLED(adapter))
1396 iavf_notify_client_message(&adapter->vsi, msg, msglen);
1397 break;
1398
1399 case VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP:
1400 adapter->client_pending &=
1401 ~(BIT(VIRTCHNL_OP_CONFIG_IWARP_IRQ_MAP));
1402 break;
1403 case VIRTCHNL_OP_GET_RSS_HENA_CAPS: {
1404 struct virtchnl_rss_hena *vrh = (struct virtchnl_rss_hena *)msg;
1405
1406 if (msglen == sizeof(*vrh))
1407 adapter->hena = vrh->hena;
1408 else
1409 dev_warn(&adapter->pdev->dev,
1410 "Invalid message %d from PF\n", v_opcode);
1411 }
1412 break;
1413 case VIRTCHNL_OP_REQUEST_QUEUES: {
1414 struct virtchnl_vf_res_request *vfres =
1415 (struct virtchnl_vf_res_request *)msg;
1416
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;
1424 }
1425 }
1426 break;
1427 case VIRTCHNL_OP_ADD_CLOUD_FILTER: {
1428 struct iavf_cloud_filter *cf;
1429
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;
1433 }
1434 }
1435 break;
1436 case VIRTCHNL_OP_DEL_CLOUD_FILTER: {
1437 struct iavf_cloud_filter *cf, *cftmp;
1438
1439 list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list,
1440 list) {
1441 if (cf->state == __IAVF_CF_DEL_PENDING) {
1442 cf->state = __IAVF_CF_INVALID;
1443 list_del(&cf->list);
1444 kfree(cf);
1445 adapter->num_cloud_filters--;
1446 }
1447 }
1448 }
1449 break;
1450 default:
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);
1454 break;
1455 }
1456 adapter->current_op = VIRTCHNL_OP_UNKNOWN;
1457 }