1
2
3
4
5#include "iavf.h"
6
7#include <linux/uaccess.h>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33struct iavf_stats {
34 char stat_string[ETH_GSTRING_LEN];
35 int sizeof_stat;
36 int stat_offset;
37};
38
39
40
41
42
43#define IAVF_STAT(_type, _name, _stat) { \
44 .stat_string = _name, \
45 .sizeof_stat = sizeof_field(_type, _stat), \
46 .stat_offset = offsetof(_type, _stat) \
47}
48
49
50#define IAVF_QUEUE_STAT(_name, _stat) \
51 IAVF_STAT(struct iavf_ring, _name, _stat)
52
53
54static const struct iavf_stats iavf_gstrings_queue_stats[] = {
55 IAVF_QUEUE_STAT("%s-%u.packets", stats.packets),
56 IAVF_QUEUE_STAT("%s-%u.bytes", stats.bytes),
57};
58
59
60
61
62
63
64
65
66
67
68
69static void
70iavf_add_one_ethtool_stat(u64 *data, void *pointer,
71 const struct iavf_stats *stat)
72{
73 char *p;
74
75 if (!pointer) {
76
77
78
79 *data = 0;
80 return;
81 }
82
83 p = (char *)pointer + stat->stat_offset;
84 switch (stat->sizeof_stat) {
85 case sizeof(u64):
86 *data = *((u64 *)p);
87 break;
88 case sizeof(u32):
89 *data = *((u32 *)p);
90 break;
91 case sizeof(u16):
92 *data = *((u16 *)p);
93 break;
94 case sizeof(u8):
95 *data = *((u8 *)p);
96 break;
97 default:
98 WARN_ONCE(1, "unexpected stat size for %s",
99 stat->stat_string);
100 *data = 0;
101 }
102}
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117static void
118__iavf_add_ethtool_stats(u64 **data, void *pointer,
119 const struct iavf_stats stats[],
120 const unsigned int size)
121{
122 unsigned int i;
123
124 for (i = 0; i < size; i++)
125 iavf_add_one_ethtool_stat((*data)++, pointer, &stats[i]);
126}
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141#define iavf_add_ethtool_stats(data, pointer, stats) \
142 __iavf_add_ethtool_stats(data, pointer, stats, ARRAY_SIZE(stats))
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158static void
159iavf_add_queue_stats(u64 **data, struct iavf_ring *ring)
160{
161 const unsigned int size = ARRAY_SIZE(iavf_gstrings_queue_stats);
162 const struct iavf_stats *stats = iavf_gstrings_queue_stats;
163 unsigned int start;
164 unsigned int i;
165
166
167
168
169
170
171 do {
172 start = !ring ? 0 : u64_stats_fetch_begin_irq(&ring->syncp);
173 for (i = 0; i < size; i++)
174 iavf_add_one_ethtool_stat(&(*data)[i], ring, &stats[i]);
175 } while (ring && u64_stats_fetch_retry_irq(&ring->syncp, start));
176
177
178 *data += size;
179}
180
181
182
183
184
185
186
187
188
189
190static void __iavf_add_stat_strings(u8 **p, const struct iavf_stats stats[],
191 const unsigned int size, ...)
192{
193 unsigned int i;
194
195 for (i = 0; i < size; i++) {
196 va_list args;
197
198 va_start(args, size);
199 vsnprintf(*p, ETH_GSTRING_LEN, stats[i].stat_string, args);
200 *p += ETH_GSTRING_LEN;
201 va_end(args);
202 }
203}
204
205
206
207
208
209
210
211
212
213
214
215
216
217#define iavf_add_stat_strings(p, stats, ...) \
218 __iavf_add_stat_strings(p, stats, ARRAY_SIZE(stats), ## __VA_ARGS__)
219
220#define VF_STAT(_name, _stat) \
221 IAVF_STAT(struct iavf_adapter, _name, _stat)
222
223static const struct iavf_stats iavf_gstrings_stats[] = {
224 VF_STAT("rx_bytes", current_stats.rx_bytes),
225 VF_STAT("rx_unicast", current_stats.rx_unicast),
226 VF_STAT("rx_multicast", current_stats.rx_multicast),
227 VF_STAT("rx_broadcast", current_stats.rx_broadcast),
228 VF_STAT("rx_discards", current_stats.rx_discards),
229 VF_STAT("rx_unknown_protocol", current_stats.rx_unknown_protocol),
230 VF_STAT("tx_bytes", current_stats.tx_bytes),
231 VF_STAT("tx_unicast", current_stats.tx_unicast),
232 VF_STAT("tx_multicast", current_stats.tx_multicast),
233 VF_STAT("tx_broadcast", current_stats.tx_broadcast),
234 VF_STAT("tx_discards", current_stats.tx_discards),
235 VF_STAT("tx_errors", current_stats.tx_errors),
236};
237
238#define IAVF_STATS_LEN ARRAY_SIZE(iavf_gstrings_stats)
239
240#define IAVF_QUEUE_STATS_LEN ARRAY_SIZE(iavf_gstrings_queue_stats)
241
242
243
244
245
246
247struct iavf_priv_flags {
248 char flag_string[ETH_GSTRING_LEN];
249 u32 flag;
250 bool read_only;
251};
252
253#define IAVF_PRIV_FLAG(_name, _flag, _read_only) { \
254 .flag_string = _name, \
255 .flag = _flag, \
256 .read_only = _read_only, \
257}
258
259static const struct iavf_priv_flags iavf_gstrings_priv_flags[] = {
260 IAVF_PRIV_FLAG("legacy-rx", IAVF_FLAG_LEGACY_RX, 0),
261};
262
263#define IAVF_PRIV_FLAGS_STR_LEN ARRAY_SIZE(iavf_gstrings_priv_flags)
264
265
266
267
268
269
270
271
272
273static int iavf_get_link_ksettings(struct net_device *netdev,
274 struct ethtool_link_ksettings *cmd)
275{
276 struct iavf_adapter *adapter = netdev_priv(netdev);
277
278 ethtool_link_ksettings_zero_link_mode(cmd, supported);
279 cmd->base.autoneg = AUTONEG_DISABLE;
280 cmd->base.port = PORT_NONE;
281 cmd->base.duplex = DUPLEX_FULL;
282
283 if (ADV_LINK_SUPPORT(adapter)) {
284 if (adapter->link_speed_mbps &&
285 adapter->link_speed_mbps < U32_MAX)
286 cmd->base.speed = adapter->link_speed_mbps;
287 else
288 cmd->base.speed = SPEED_UNKNOWN;
289
290 return 0;
291 }
292
293 switch (adapter->link_speed) {
294 case VIRTCHNL_LINK_SPEED_40GB:
295 cmd->base.speed = SPEED_40000;
296 break;
297 case VIRTCHNL_LINK_SPEED_25GB:
298 cmd->base.speed = SPEED_25000;
299 break;
300 case VIRTCHNL_LINK_SPEED_20GB:
301 cmd->base.speed = SPEED_20000;
302 break;
303 case VIRTCHNL_LINK_SPEED_10GB:
304 cmd->base.speed = SPEED_10000;
305 break;
306 case VIRTCHNL_LINK_SPEED_5GB:
307 cmd->base.speed = SPEED_5000;
308 break;
309 case VIRTCHNL_LINK_SPEED_2_5GB:
310 cmd->base.speed = SPEED_2500;
311 break;
312 case VIRTCHNL_LINK_SPEED_1GB:
313 cmd->base.speed = SPEED_1000;
314 break;
315 case VIRTCHNL_LINK_SPEED_100MB:
316 cmd->base.speed = SPEED_100;
317 break;
318 default:
319 break;
320 }
321
322 return 0;
323}
324
325
326
327
328
329
330
331
332static int iavf_get_sset_count(struct net_device *netdev, int sset)
333{
334 if (sset == ETH_SS_STATS)
335 return IAVF_STATS_LEN +
336 (IAVF_QUEUE_STATS_LEN * 2 * IAVF_MAX_REQ_QUEUES);
337 else if (sset == ETH_SS_PRIV_FLAGS)
338 return IAVF_PRIV_FLAGS_STR_LEN;
339 else
340 return -EINVAL;
341}
342
343
344
345
346
347
348
349
350
351static void iavf_get_ethtool_stats(struct net_device *netdev,
352 struct ethtool_stats *stats, u64 *data)
353{
354 struct iavf_adapter *adapter = netdev_priv(netdev);
355 unsigned int i;
356
357 iavf_add_ethtool_stats(&data, adapter, iavf_gstrings_stats);
358
359 rcu_read_lock();
360 for (i = 0; i < IAVF_MAX_REQ_QUEUES; i++) {
361 struct iavf_ring *ring;
362
363
364 ring = (i < adapter->num_active_queues ?
365 &adapter->tx_rings[i] : NULL);
366 iavf_add_queue_stats(&data, ring);
367
368
369 ring = (i < adapter->num_active_queues ?
370 &adapter->rx_rings[i] : NULL);
371 iavf_add_queue_stats(&data, ring);
372 }
373 rcu_read_unlock();
374}
375
376
377
378
379
380
381
382
383static void iavf_get_priv_flag_strings(struct net_device *netdev, u8 *data)
384{
385 unsigned int i;
386
387 for (i = 0; i < IAVF_PRIV_FLAGS_STR_LEN; i++) {
388 snprintf(data, ETH_GSTRING_LEN, "%s",
389 iavf_gstrings_priv_flags[i].flag_string);
390 data += ETH_GSTRING_LEN;
391 }
392}
393
394
395
396
397
398
399
400
401static void iavf_get_stat_strings(struct net_device *netdev, u8 *data)
402{
403 unsigned int i;
404
405 iavf_add_stat_strings(&data, iavf_gstrings_stats);
406
407
408
409
410 for (i = 0; i < netdev->num_tx_queues; i++) {
411 iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,
412 "tx", i);
413 iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,
414 "rx", i);
415 }
416}
417
418
419
420
421
422
423
424
425
426static void iavf_get_strings(struct net_device *netdev, u32 sset, u8 *data)
427{
428 switch (sset) {
429 case ETH_SS_STATS:
430 iavf_get_stat_strings(netdev, data);
431 break;
432 case ETH_SS_PRIV_FLAGS:
433 iavf_get_priv_flag_strings(netdev, data);
434 break;
435 default:
436 break;
437 }
438}
439
440
441
442
443
444
445
446
447
448
449
450static u32 iavf_get_priv_flags(struct net_device *netdev)
451{
452 struct iavf_adapter *adapter = netdev_priv(netdev);
453 u32 i, ret_flags = 0;
454
455 for (i = 0; i < IAVF_PRIV_FLAGS_STR_LEN; i++) {
456 const struct iavf_priv_flags *priv_flags;
457
458 priv_flags = &iavf_gstrings_priv_flags[i];
459
460 if (priv_flags->flag & adapter->flags)
461 ret_flags |= BIT(i);
462 }
463
464 return ret_flags;
465}
466
467
468
469
470
471
472static int iavf_set_priv_flags(struct net_device *netdev, u32 flags)
473{
474 struct iavf_adapter *adapter = netdev_priv(netdev);
475 u32 orig_flags, new_flags, changed_flags;
476 u32 i;
477
478 orig_flags = READ_ONCE(adapter->flags);
479 new_flags = orig_flags;
480
481 for (i = 0; i < IAVF_PRIV_FLAGS_STR_LEN; i++) {
482 const struct iavf_priv_flags *priv_flags;
483
484 priv_flags = &iavf_gstrings_priv_flags[i];
485
486 if (flags & BIT(i))
487 new_flags |= priv_flags->flag;
488 else
489 new_flags &= ~(priv_flags->flag);
490
491 if (priv_flags->read_only &&
492 ((orig_flags ^ new_flags) & ~BIT(i)))
493 return -EOPNOTSUPP;
494 }
495
496
497
498
499
500
501
502
503
504
505
506
507 if (cmpxchg(&adapter->flags, orig_flags, new_flags) != orig_flags) {
508 dev_warn(&adapter->pdev->dev,
509 "Unable to update adapter->flags as it was modified by another thread...\n");
510 return -EAGAIN;
511 }
512
513 changed_flags = orig_flags ^ new_flags;
514
515
516
517
518
519
520
521 if (changed_flags & IAVF_FLAG_LEGACY_RX) {
522 if (netif_running(netdev)) {
523 adapter->flags |= IAVF_FLAG_RESET_NEEDED;
524 queue_work(iavf_wq, &adapter->reset_task);
525 }
526 }
527
528 return 0;
529}
530
531
532
533
534
535
536
537static u32 iavf_get_msglevel(struct net_device *netdev)
538{
539 struct iavf_adapter *adapter = netdev_priv(netdev);
540
541 return adapter->msg_enable;
542}
543
544
545
546
547
548
549
550
551
552static void iavf_set_msglevel(struct net_device *netdev, u32 data)
553{
554 struct iavf_adapter *adapter = netdev_priv(netdev);
555
556 if (IAVF_DEBUG_USER & data)
557 adapter->hw.debug_mask = data;
558 adapter->msg_enable = data;
559}
560
561
562
563
564
565
566
567
568static void iavf_get_drvinfo(struct net_device *netdev,
569 struct ethtool_drvinfo *drvinfo)
570{
571 struct iavf_adapter *adapter = netdev_priv(netdev);
572
573 strlcpy(drvinfo->driver, iavf_driver_name, 32);
574 strlcpy(drvinfo->fw_version, "N/A", 4);
575 strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
576 drvinfo->n_priv_flags = IAVF_PRIV_FLAGS_STR_LEN;
577}
578
579
580
581
582
583
584
585
586
587static void iavf_get_ringparam(struct net_device *netdev,
588 struct ethtool_ringparam *ring)
589{
590 struct iavf_adapter *adapter = netdev_priv(netdev);
591
592 ring->rx_max_pending = IAVF_MAX_RXD;
593 ring->tx_max_pending = IAVF_MAX_TXD;
594 ring->rx_pending = adapter->rx_desc_count;
595 ring->tx_pending = adapter->tx_desc_count;
596}
597
598
599
600
601
602
603
604
605
606static int iavf_set_ringparam(struct net_device *netdev,
607 struct ethtool_ringparam *ring)
608{
609 struct iavf_adapter *adapter = netdev_priv(netdev);
610 u32 new_rx_count, new_tx_count;
611
612 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
613 return -EINVAL;
614
615 new_tx_count = clamp_t(u32, ring->tx_pending,
616 IAVF_MIN_TXD,
617 IAVF_MAX_TXD);
618 new_tx_count = ALIGN(new_tx_count, IAVF_REQ_DESCRIPTOR_MULTIPLE);
619
620 new_rx_count = clamp_t(u32, ring->rx_pending,
621 IAVF_MIN_RXD,
622 IAVF_MAX_RXD);
623 new_rx_count = ALIGN(new_rx_count, IAVF_REQ_DESCRIPTOR_MULTIPLE);
624
625
626 if ((new_tx_count == adapter->tx_desc_count) &&
627 (new_rx_count == adapter->rx_desc_count))
628 return 0;
629
630 adapter->tx_desc_count = new_tx_count;
631 adapter->rx_desc_count = new_rx_count;
632
633 if (netif_running(netdev)) {
634 adapter->flags |= IAVF_FLAG_RESET_NEEDED;
635 queue_work(iavf_wq, &adapter->reset_task);
636 }
637
638 return 0;
639}
640
641
642
643
644
645
646
647
648
649
650
651static int __iavf_get_coalesce(struct net_device *netdev,
652 struct ethtool_coalesce *ec, int queue)
653{
654 struct iavf_adapter *adapter = netdev_priv(netdev);
655 struct iavf_vsi *vsi = &adapter->vsi;
656 struct iavf_ring *rx_ring, *tx_ring;
657
658 ec->tx_max_coalesced_frames = vsi->work_limit;
659 ec->rx_max_coalesced_frames = vsi->work_limit;
660
661
662
663
664 if (queue < 0)
665 queue = 0;
666 else if (queue >= adapter->num_active_queues)
667 return -EINVAL;
668
669 rx_ring = &adapter->rx_rings[queue];
670 tx_ring = &adapter->tx_rings[queue];
671
672 if (ITR_IS_DYNAMIC(rx_ring->itr_setting))
673 ec->use_adaptive_rx_coalesce = 1;
674
675 if (ITR_IS_DYNAMIC(tx_ring->itr_setting))
676 ec->use_adaptive_tx_coalesce = 1;
677
678 ec->rx_coalesce_usecs = rx_ring->itr_setting & ~IAVF_ITR_DYNAMIC;
679 ec->tx_coalesce_usecs = tx_ring->itr_setting & ~IAVF_ITR_DYNAMIC;
680
681 return 0;
682}
683
684
685
686
687
688
689
690
691
692
693
694static int iavf_get_coalesce(struct net_device *netdev,
695 struct ethtool_coalesce *ec)
696{
697 return __iavf_get_coalesce(netdev, ec, -1);
698}
699
700
701
702
703
704
705
706
707
708static int iavf_get_per_queue_coalesce(struct net_device *netdev, u32 queue,
709 struct ethtool_coalesce *ec)
710{
711 return __iavf_get_coalesce(netdev, ec, queue);
712}
713
714
715
716
717
718
719
720
721
722static void iavf_set_itr_per_queue(struct iavf_adapter *adapter,
723 struct ethtool_coalesce *ec, int queue)
724{
725 struct iavf_ring *rx_ring = &adapter->rx_rings[queue];
726 struct iavf_ring *tx_ring = &adapter->tx_rings[queue];
727 struct iavf_q_vector *q_vector;
728
729 rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs);
730 tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs);
731
732 rx_ring->itr_setting |= IAVF_ITR_DYNAMIC;
733 if (!ec->use_adaptive_rx_coalesce)
734 rx_ring->itr_setting ^= IAVF_ITR_DYNAMIC;
735
736 tx_ring->itr_setting |= IAVF_ITR_DYNAMIC;
737 if (!ec->use_adaptive_tx_coalesce)
738 tx_ring->itr_setting ^= IAVF_ITR_DYNAMIC;
739
740 q_vector = rx_ring->q_vector;
741 q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting);
742
743 q_vector = tx_ring->q_vector;
744 q_vector->tx.target_itr = ITR_TO_REG(tx_ring->itr_setting);
745
746
747
748
749
750}
751
752
753
754
755
756
757
758
759
760static int __iavf_set_coalesce(struct net_device *netdev,
761 struct ethtool_coalesce *ec, int queue)
762{
763 struct iavf_adapter *adapter = netdev_priv(netdev);
764 struct iavf_vsi *vsi = &adapter->vsi;
765 int i;
766
767 if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq)
768 vsi->work_limit = ec->tx_max_coalesced_frames_irq;
769
770 if (ec->rx_coalesce_usecs == 0) {
771 if (ec->use_adaptive_rx_coalesce)
772 netif_info(adapter, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n");
773 } else if ((ec->rx_coalesce_usecs < IAVF_MIN_ITR) ||
774 (ec->rx_coalesce_usecs > IAVF_MAX_ITR)) {
775 netif_info(adapter, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n");
776 return -EINVAL;
777 } else if (ec->tx_coalesce_usecs == 0) {
778 if (ec->use_adaptive_tx_coalesce)
779 netif_info(adapter, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n");
780 } else if ((ec->tx_coalesce_usecs < IAVF_MIN_ITR) ||
781 (ec->tx_coalesce_usecs > IAVF_MAX_ITR)) {
782 netif_info(adapter, drv, netdev, "Invalid value, tx-usecs range is 0-8160\n");
783 return -EINVAL;
784 }
785
786
787
788
789 if (queue < 0) {
790 for (i = 0; i < adapter->num_active_queues; i++)
791 iavf_set_itr_per_queue(adapter, ec, i);
792 } else if (queue < adapter->num_active_queues) {
793 iavf_set_itr_per_queue(adapter, ec, queue);
794 } else {
795 netif_info(adapter, drv, netdev, "Invalid queue value, queue range is 0 - %d\n",
796 adapter->num_active_queues - 1);
797 return -EINVAL;
798 }
799
800 return 0;
801}
802
803
804
805
806
807
808
809
810static int iavf_set_coalesce(struct net_device *netdev,
811 struct ethtool_coalesce *ec)
812{
813 return __iavf_set_coalesce(netdev, ec, -1);
814}
815
816
817
818
819
820
821
822
823
824static int iavf_set_per_queue_coalesce(struct net_device *netdev, u32 queue,
825 struct ethtool_coalesce *ec)
826{
827 return __iavf_set_coalesce(netdev, ec, queue);
828}
829
830
831
832
833
834
835
836
837
838static int iavf_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
839 u32 *rule_locs)
840{
841 struct iavf_adapter *adapter = netdev_priv(netdev);
842 int ret = -EOPNOTSUPP;
843
844 switch (cmd->cmd) {
845 case ETHTOOL_GRXRINGS:
846 cmd->data = adapter->num_active_queues;
847 ret = 0;
848 break;
849 case ETHTOOL_GRXFH:
850 netdev_info(netdev,
851 "RSS hash info is not available to vf, use pf.\n");
852 break;
853 default:
854 break;
855 }
856
857 return ret;
858}
859
860
861
862
863
864
865
866
867static void iavf_get_channels(struct net_device *netdev,
868 struct ethtool_channels *ch)
869{
870 struct iavf_adapter *adapter = netdev_priv(netdev);
871
872
873 ch->max_combined = adapter->vsi_res->num_queue_pairs;
874
875 ch->max_other = NONQ_VECS;
876 ch->other_count = NONQ_VECS;
877
878 ch->combined_count = adapter->num_active_queues;
879}
880
881
882
883
884
885
886
887
888
889
890static int iavf_set_channels(struct net_device *netdev,
891 struct ethtool_channels *ch)
892{
893 struct iavf_adapter *adapter = netdev_priv(netdev);
894 u32 num_req = ch->combined_count;
895
896 if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) &&
897 adapter->num_tc) {
898 dev_info(&adapter->pdev->dev, "Cannot set channels since ADq is enabled.\n");
899 return -EINVAL;
900 }
901
902
903
904
905 if (num_req > adapter->vsi_res->num_queue_pairs)
906 return -EINVAL;
907
908 if (num_req == adapter->num_active_queues)
909 return 0;
910
911 if (ch->rx_count || ch->tx_count || ch->other_count != NONQ_VECS)
912 return -EINVAL;
913
914 adapter->num_req_queues = num_req;
915 adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
916 iavf_schedule_reset(adapter);
917 return 0;
918}
919
920
921
922
923
924
925
926static u32 iavf_get_rxfh_key_size(struct net_device *netdev)
927{
928 struct iavf_adapter *adapter = netdev_priv(netdev);
929
930 return adapter->rss_key_size;
931}
932
933
934
935
936
937
938
939static u32 iavf_get_rxfh_indir_size(struct net_device *netdev)
940{
941 struct iavf_adapter *adapter = netdev_priv(netdev);
942
943 return adapter->rss_lut_size;
944}
945
946
947
948
949
950
951
952
953
954
955static int iavf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
956 u8 *hfunc)
957{
958 struct iavf_adapter *adapter = netdev_priv(netdev);
959 u16 i;
960
961 if (hfunc)
962 *hfunc = ETH_RSS_HASH_TOP;
963 if (!indir)
964 return 0;
965
966 memcpy(key, adapter->rss_key, adapter->rss_key_size);
967
968
969 for (i = 0; i < adapter->rss_lut_size; i++)
970 indir[i] = (u32)adapter->rss_lut[i];
971
972 return 0;
973}
974
975
976
977
978
979
980
981
982
983
984
985static int iavf_set_rxfh(struct net_device *netdev, const u32 *indir,
986 const u8 *key, const u8 hfunc)
987{
988 struct iavf_adapter *adapter = netdev_priv(netdev);
989 u16 i;
990
991
992 if (key ||
993 (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
994 return -EOPNOTSUPP;
995 if (!indir)
996 return 0;
997
998 if (key)
999 memcpy(adapter->rss_key, key, adapter->rss_key_size);
1000
1001
1002 for (i = 0; i < adapter->rss_lut_size; i++)
1003 adapter->rss_lut[i] = (u8)(indir[i]);
1004
1005 return iavf_config_rss(adapter);
1006}
1007
1008static const struct ethtool_ops iavf_ethtool_ops = {
1009 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
1010 ETHTOOL_COALESCE_MAX_FRAMES |
1011 ETHTOOL_COALESCE_MAX_FRAMES_IRQ |
1012 ETHTOOL_COALESCE_USE_ADAPTIVE,
1013 .get_drvinfo = iavf_get_drvinfo,
1014 .get_link = ethtool_op_get_link,
1015 .get_ringparam = iavf_get_ringparam,
1016 .set_ringparam = iavf_set_ringparam,
1017 .get_strings = iavf_get_strings,
1018 .get_ethtool_stats = iavf_get_ethtool_stats,
1019 .get_sset_count = iavf_get_sset_count,
1020 .get_priv_flags = iavf_get_priv_flags,
1021 .set_priv_flags = iavf_set_priv_flags,
1022 .get_msglevel = iavf_get_msglevel,
1023 .set_msglevel = iavf_set_msglevel,
1024 .get_coalesce = iavf_get_coalesce,
1025 .set_coalesce = iavf_set_coalesce,
1026 .get_per_queue_coalesce = iavf_get_per_queue_coalesce,
1027 .set_per_queue_coalesce = iavf_set_per_queue_coalesce,
1028 .get_rxnfc = iavf_get_rxnfc,
1029 .get_rxfh_indir_size = iavf_get_rxfh_indir_size,
1030 .get_rxfh = iavf_get_rxfh,
1031 .set_rxfh = iavf_set_rxfh,
1032 .get_channels = iavf_get_channels,
1033 .set_channels = iavf_set_channels,
1034 .get_rxfh_key_size = iavf_get_rxfh_key_size,
1035 .get_link_ksettings = iavf_get_link_ksettings,
1036};
1037
1038
1039
1040
1041
1042
1043
1044
1045void iavf_set_ethtool_ops(struct net_device *netdev)
1046{
1047 netdev->ethtool_ops = &iavf_ethtool_ops;
1048}
1049