1 /* QLogic qede NIC Driver
2 * Copyright (c) 2015-2017 QLogic Corporation
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and /or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 #include <linux/version.h>
33 #include <linux/types.h>
34 #include <linux/netdevice.h>
35 #include <linux/etherdevice.h>
36 #include <linux/ethtool.h>
37 #include <linux/string.h>
38 #include <linux/pci.h>
39 #include <linux/capability.h>
40 #include <linux/vmalloc.h>
44 #define QEDE_RQSTAT_OFFSET(stat_name) \
45 (offsetof(struct qede_rx_queue, stat_name))
46 #define QEDE_RQSTAT_STRING(stat_name) (#stat_name)
47 #define QEDE_RQSTAT(stat_name) \
48 {QEDE_RQSTAT_OFFSET(stat_name), QEDE_RQSTAT_STRING(stat_name)}
50 #define QEDE_SELFTEST_POLL_COUNT 100
54 char string[ETH_GSTRING_LEN];
55 } qede_rqstats_arr[] = {
56 QEDE_RQSTAT(rcv_pkts),
57 QEDE_RQSTAT(rx_hw_errors),
58 QEDE_RQSTAT(rx_alloc_errors),
59 QEDE_RQSTAT(rx_ip_frags),
60 QEDE_RQSTAT(xdp_no_pass),
63 #define QEDE_NUM_RQSTATS ARRAY_SIZE(qede_rqstats_arr)
64 #define QEDE_TQSTAT_OFFSET(stat_name) \
65 (offsetof(struct qede_tx_queue, stat_name))
66 #define QEDE_TQSTAT_STRING(stat_name) (#stat_name)
67 #define QEDE_TQSTAT(stat_name) \
68 {QEDE_TQSTAT_OFFSET(stat_name), QEDE_TQSTAT_STRING(stat_name)}
69 #define QEDE_NUM_TQSTATS ARRAY_SIZE(qede_tqstats_arr)
72 char string[ETH_GSTRING_LEN];
73 } qede_tqstats_arr[] = {
74 QEDE_TQSTAT(xmit_pkts),
75 QEDE_TQSTAT(stopped_cnt),
76 QEDE_TQSTAT(tx_mem_alloc_err),
79 #define QEDE_STAT_OFFSET(stat_name, type, base) \
80 (offsetof(type, stat_name) + (base))
81 #define QEDE_STAT_STRING(stat_name) (#stat_name)
82 #define _QEDE_STAT(stat_name, type, base, attr) \
83 {QEDE_STAT_OFFSET(stat_name, type, base), \
84 QEDE_STAT_STRING(stat_name), \
86 #define QEDE_STAT(stat_name) \
87 _QEDE_STAT(stat_name, struct qede_stats_common, 0, 0x0)
88 #define QEDE_PF_STAT(stat_name) \
89 _QEDE_STAT(stat_name, struct qede_stats_common, 0, \
90 BIT(QEDE_STAT_PF_ONLY))
91 #define QEDE_PF_BB_STAT(stat_name) \
92 _QEDE_STAT(stat_name, struct qede_stats_bb, \
93 offsetof(struct qede_stats, bb), \
94 BIT(QEDE_STAT_PF_ONLY) | BIT(QEDE_STAT_BB_ONLY))
95 #define QEDE_PF_AH_STAT(stat_name) \
96 _QEDE_STAT(stat_name, struct qede_stats_ah, \
97 offsetof(struct qede_stats, ah), \
98 BIT(QEDE_STAT_PF_ONLY) | BIT(QEDE_STAT_AH_ONLY))
101 char string[ETH_GSTRING_LEN];
103 #define QEDE_STAT_PF_ONLY 0
104 #define QEDE_STAT_BB_ONLY 1
105 #define QEDE_STAT_AH_ONLY 2
106 } qede_stats_arr[] = {
107 QEDE_STAT(rx_ucast_bytes),
108 QEDE_STAT(rx_mcast_bytes),
109 QEDE_STAT(rx_bcast_bytes),
110 QEDE_STAT(rx_ucast_pkts),
111 QEDE_STAT(rx_mcast_pkts),
112 QEDE_STAT(rx_bcast_pkts),
114 QEDE_STAT(tx_ucast_bytes),
115 QEDE_STAT(tx_mcast_bytes),
116 QEDE_STAT(tx_bcast_bytes),
117 QEDE_STAT(tx_ucast_pkts),
118 QEDE_STAT(tx_mcast_pkts),
119 QEDE_STAT(tx_bcast_pkts),
121 QEDE_PF_STAT(rx_64_byte_packets),
122 QEDE_PF_STAT(rx_65_to_127_byte_packets),
123 QEDE_PF_STAT(rx_128_to_255_byte_packets),
124 QEDE_PF_STAT(rx_256_to_511_byte_packets),
125 QEDE_PF_STAT(rx_512_to_1023_byte_packets),
126 QEDE_PF_STAT(rx_1024_to_1518_byte_packets),
127 QEDE_PF_BB_STAT(rx_1519_to_1522_byte_packets),
128 QEDE_PF_BB_STAT(rx_1519_to_2047_byte_packets),
129 QEDE_PF_BB_STAT(rx_2048_to_4095_byte_packets),
130 QEDE_PF_BB_STAT(rx_4096_to_9216_byte_packets),
131 QEDE_PF_BB_STAT(rx_9217_to_16383_byte_packets),
132 QEDE_PF_AH_STAT(rx_1519_to_max_byte_packets),
133 QEDE_PF_STAT(tx_64_byte_packets),
134 QEDE_PF_STAT(tx_65_to_127_byte_packets),
135 QEDE_PF_STAT(tx_128_to_255_byte_packets),
136 QEDE_PF_STAT(tx_256_to_511_byte_packets),
137 QEDE_PF_STAT(tx_512_to_1023_byte_packets),
138 QEDE_PF_STAT(tx_1024_to_1518_byte_packets),
139 QEDE_PF_BB_STAT(tx_1519_to_2047_byte_packets),
140 QEDE_PF_BB_STAT(tx_2048_to_4095_byte_packets),
141 QEDE_PF_BB_STAT(tx_4096_to_9216_byte_packets),
142 QEDE_PF_BB_STAT(tx_9217_to_16383_byte_packets),
143 QEDE_PF_AH_STAT(tx_1519_to_max_byte_packets),
144 QEDE_PF_STAT(rx_mac_crtl_frames),
145 QEDE_PF_STAT(tx_mac_ctrl_frames),
146 QEDE_PF_STAT(rx_pause_frames),
147 QEDE_PF_STAT(tx_pause_frames),
148 QEDE_PF_STAT(rx_pfc_frames),
149 QEDE_PF_STAT(tx_pfc_frames),
151 QEDE_PF_STAT(rx_crc_errors),
152 QEDE_PF_STAT(rx_align_errors),
153 QEDE_PF_STAT(rx_carrier_errors),
154 QEDE_PF_STAT(rx_oversize_packets),
155 QEDE_PF_STAT(rx_jabbers),
156 QEDE_PF_STAT(rx_undersize_packets),
157 QEDE_PF_STAT(rx_fragments),
158 QEDE_PF_BB_STAT(tx_lpi_entry_count),
159 QEDE_PF_BB_STAT(tx_total_collisions),
160 QEDE_PF_STAT(brb_truncates),
161 QEDE_PF_STAT(brb_discards),
162 QEDE_STAT(no_buff_discards),
163 QEDE_PF_STAT(mftag_filter_discards),
164 QEDE_PF_STAT(mac_filter_discards),
165 QEDE_PF_STAT(gft_filter_drop),
166 QEDE_STAT(tx_err_drop_pkts),
167 QEDE_STAT(ttl0_discard),
168 QEDE_STAT(packet_too_big_discard),
170 QEDE_STAT(coalesced_pkts),
171 QEDE_STAT(coalesced_events),
172 QEDE_STAT(coalesced_aborts_num),
173 QEDE_STAT(non_coalesced_pkts),
174 QEDE_STAT(coalesced_bytes),
176 QEDE_STAT(link_change_count),
177 QEDE_STAT(ptp_skip_txts),
180 #define QEDE_NUM_STATS ARRAY_SIZE(qede_stats_arr)
181 #define QEDE_STAT_IS_PF_ONLY(i) \
182 test_bit(QEDE_STAT_PF_ONLY, &qede_stats_arr[i].attr)
183 #define QEDE_STAT_IS_BB_ONLY(i) \
184 test_bit(QEDE_STAT_BB_ONLY, &qede_stats_arr[i].attr)
185 #define QEDE_STAT_IS_AH_ONLY(i) \
186 test_bit(QEDE_STAT_AH_ONLY, &qede_stats_arr[i].attr)
190 QEDE_PRI_FLAG_SMART_AN_SUPPORT, /* MFW supports SmartAN */
194 static const char qede_private_arr[QEDE_PRI_FLAG_LEN][ETH_GSTRING_LEN] = {
199 enum qede_ethtool_tests {
200 QEDE_ETHTOOL_INT_LOOPBACK,
201 QEDE_ETHTOOL_INTERRUPT_TEST,
202 QEDE_ETHTOOL_MEMORY_TEST,
203 QEDE_ETHTOOL_REGISTER_TEST,
204 QEDE_ETHTOOL_CLOCK_TEST,
205 QEDE_ETHTOOL_NVRAM_TEST,
206 QEDE_ETHTOOL_TEST_MAX
209 static const char qede_tests_str_arr[QEDE_ETHTOOL_TEST_MAX][ETH_GSTRING_LEN] = {
210 "Internal loopback (offline)",
211 "Interrupt (online)\t",
212 "Memory (online)\t\t",
213 "Register (online)\t",
214 "Clock (online)\t\t",
215 "Nvram (online)\t\t",
218 static void qede_get_strings_stats_txq(struct qede_dev *edev,
219 struct qede_tx_queue *txq, u8 **buf)
223 for (i = 0; i < QEDE_NUM_TQSTATS; i++) {
225 sprintf(*buf, "%d [XDP]: %s",
226 QEDE_TXQ_XDP_TO_IDX(edev, txq),
227 qede_tqstats_arr[i].string);
229 sprintf(*buf, "%d_%d: %s", txq->index, txq->cos,
230 qede_tqstats_arr[i].string);
231 *buf += ETH_GSTRING_LEN;
235 static void qede_get_strings_stats_rxq(struct qede_dev *edev,
236 struct qede_rx_queue *rxq, u8 **buf)
240 for (i = 0; i < QEDE_NUM_RQSTATS; i++) {
241 sprintf(*buf, "%d: %s", rxq->rxq_id,
242 qede_rqstats_arr[i].string);
243 *buf += ETH_GSTRING_LEN;
247 static bool qede_is_irrelevant_stat(struct qede_dev *edev, int stat_index)
249 return (IS_VF(edev) && QEDE_STAT_IS_PF_ONLY(stat_index)) ||
250 (QEDE_IS_BB(edev) && QEDE_STAT_IS_AH_ONLY(stat_index)) ||
251 (QEDE_IS_AH(edev) && QEDE_STAT_IS_BB_ONLY(stat_index));
254 static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf)
256 struct qede_fastpath *fp;
259 /* Account for queue statistics */
260 for (i = 0; i < QEDE_QUEUE_CNT(edev); i++) {
261 fp = &edev->fp_array[i];
263 if (fp->type & QEDE_FASTPATH_RX)
264 qede_get_strings_stats_rxq(edev, fp->rxq, &buf);
266 if (fp->type & QEDE_FASTPATH_XDP)
267 qede_get_strings_stats_txq(edev, fp->xdp_tx, &buf);
269 if (fp->type & QEDE_FASTPATH_TX) {
272 for_each_cos_in_txq(edev, cos)
273 qede_get_strings_stats_txq(edev,
274 &fp->txq[cos], &buf);
278 /* Account for non-queue statistics */
279 for (i = 0; i < QEDE_NUM_STATS; i++) {
280 if (qede_is_irrelevant_stat(edev, i))
282 strcpy(buf, qede_stats_arr[i].string);
283 buf += ETH_GSTRING_LEN;
287 static void qede_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
289 struct qede_dev *edev = netdev_priv(dev);
293 qede_get_strings_stats(edev, buf);
295 case ETH_SS_PRIV_FLAGS:
296 memcpy(buf, qede_private_arr,
297 ETH_GSTRING_LEN * QEDE_PRI_FLAG_LEN);
300 memcpy(buf, qede_tests_str_arr,
301 ETH_GSTRING_LEN * QEDE_ETHTOOL_TEST_MAX);
304 DP_VERBOSE(edev, QED_MSG_DEBUG,
305 "Unsupported stringset 0x%08x\n", stringset);
309 static void qede_get_ethtool_stats_txq(struct qede_tx_queue *txq, u64 **buf)
313 for (i = 0; i < QEDE_NUM_TQSTATS; i++) {
314 **buf = *((u64 *)(((void *)txq) + qede_tqstats_arr[i].offset));
319 static void qede_get_ethtool_stats_rxq(struct qede_rx_queue *rxq, u64 **buf)
323 for (i = 0; i < QEDE_NUM_RQSTATS; i++) {
324 **buf = *((u64 *)(((void *)rxq) + qede_rqstats_arr[i].offset));
329 static void qede_get_ethtool_stats(struct net_device *dev,
330 struct ethtool_stats *stats, u64 *buf)
332 struct qede_dev *edev = netdev_priv(dev);
333 struct qede_fastpath *fp;
336 qede_fill_by_demand_stats(edev);
338 /* Need to protect the access to the fastpath array */
341 for (i = 0; i < QEDE_QUEUE_CNT(edev); i++) {
342 fp = &edev->fp_array[i];
344 if (fp->type & QEDE_FASTPATH_RX)
345 qede_get_ethtool_stats_rxq(fp->rxq, &buf);
347 if (fp->type & QEDE_FASTPATH_XDP)
348 qede_get_ethtool_stats_txq(fp->xdp_tx, &buf);
350 if (fp->type & QEDE_FASTPATH_TX) {
353 for_each_cos_in_txq(edev, cos)
354 qede_get_ethtool_stats_txq(&fp->txq[cos], &buf);
358 for (i = 0; i < QEDE_NUM_STATS; i++) {
359 if (qede_is_irrelevant_stat(edev, i))
361 *buf = *((u64 *)(((void *)&edev->stats) +
362 qede_stats_arr[i].offset));
370 static int qede_get_sset_count(struct net_device *dev, int stringset)
372 struct qede_dev *edev = netdev_priv(dev);
373 int num_stats = QEDE_NUM_STATS, i;
377 for (i = 0; i < QEDE_NUM_STATS; i++)
378 if (qede_is_irrelevant_stat(edev, i))
381 /* Account for the Regular Tx statistics */
382 num_stats += QEDE_TSS_COUNT(edev) * QEDE_NUM_TQSTATS *
383 edev->dev_info.num_tc;
385 /* Account for the Regular Rx statistics */
386 num_stats += QEDE_RSS_COUNT(edev) * QEDE_NUM_RQSTATS;
388 /* Account for XDP statistics [if needed] */
390 num_stats += QEDE_RSS_COUNT(edev) * QEDE_NUM_TQSTATS;
393 case ETH_SS_PRIV_FLAGS:
394 return QEDE_PRI_FLAG_LEN;
397 return QEDE_ETHTOOL_TEST_MAX;
401 DP_VERBOSE(edev, QED_MSG_DEBUG,
402 "Unsupported stringset 0x%08x\n", stringset);
407 static u32 qede_get_priv_flags(struct net_device *dev)
409 struct qede_dev *edev = netdev_priv(dev);
412 if (edev->dev_info.common.num_hwfns > 1)
413 flags |= BIT(QEDE_PRI_FLAG_CMT);
415 if (edev->dev_info.common.smart_an)
416 flags |= BIT(QEDE_PRI_FLAG_SMART_AN_SUPPORT);
421 struct qede_link_mode_mapping {
423 u32 ethtool_link_mode;
426 static const struct qede_link_mode_mapping qed_lm_map[] = {
427 {QED_LM_Autoneg_BIT, ETHTOOL_LINK_MODE_Autoneg_BIT},
428 {QED_LM_Asym_Pause_BIT, ETHTOOL_LINK_MODE_Asym_Pause_BIT},
429 {QED_LM_Pause_BIT, ETHTOOL_LINK_MODE_Pause_BIT},
430 {QED_LM_1000baseT_Full_BIT, ETHTOOL_LINK_MODE_1000baseT_Full_BIT},
431 {QED_LM_10000baseT_Full_BIT, ETHTOOL_LINK_MODE_10000baseT_Full_BIT},
432 {QED_LM_2500baseX_Full_BIT, ETHTOOL_LINK_MODE_2500baseX_Full_BIT},
433 {QED_LM_Backplane_BIT, ETHTOOL_LINK_MODE_Backplane_BIT},
434 {QED_LM_1000baseKX_Full_BIT, ETHTOOL_LINK_MODE_1000baseKX_Full_BIT},
435 {QED_LM_10000baseKX4_Full_BIT, ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT},
436 {QED_LM_10000baseKR_Full_BIT, ETHTOOL_LINK_MODE_10000baseKR_Full_BIT},
437 {QED_LM_10000baseKR_Full_BIT, ETHTOOL_LINK_MODE_10000baseKR_Full_BIT},
438 {QED_LM_10000baseR_FEC_BIT, ETHTOOL_LINK_MODE_10000baseR_FEC_BIT},
439 {QED_LM_20000baseKR2_Full_BIT, ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT},
440 {QED_LM_40000baseKR4_Full_BIT, ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT},
441 {QED_LM_40000baseCR4_Full_BIT, ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT},
442 {QED_LM_40000baseSR4_Full_BIT, ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT},
443 {QED_LM_40000baseLR4_Full_BIT, ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT},
444 {QED_LM_25000baseCR_Full_BIT, ETHTOOL_LINK_MODE_25000baseCR_Full_BIT},
445 {QED_LM_25000baseKR_Full_BIT, ETHTOOL_LINK_MODE_25000baseKR_Full_BIT},
446 {QED_LM_25000baseSR_Full_BIT, ETHTOOL_LINK_MODE_25000baseSR_Full_BIT},
447 {QED_LM_50000baseCR2_Full_BIT, ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT},
448 {QED_LM_50000baseKR2_Full_BIT, ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT},
449 {QED_LM_100000baseKR4_Full_BIT,
450 ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT},
451 {QED_LM_100000baseSR4_Full_BIT,
452 ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT},
453 {QED_LM_100000baseCR4_Full_BIT,
454 ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT},
455 {QED_LM_100000baseLR4_ER4_Full_BIT,
456 ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT},
457 {QED_LM_50000baseSR2_Full_BIT, ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT},
458 {QED_LM_1000baseX_Full_BIT, ETHTOOL_LINK_MODE_1000baseX_Full_BIT},
459 {QED_LM_10000baseCR_Full_BIT, ETHTOOL_LINK_MODE_10000baseCR_Full_BIT},
460 {QED_LM_10000baseSR_Full_BIT, ETHTOOL_LINK_MODE_10000baseSR_Full_BIT},
461 {QED_LM_10000baseLR_Full_BIT, ETHTOOL_LINK_MODE_10000baseLR_Full_BIT},
462 {QED_LM_10000baseLRM_Full_BIT, ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT},
465 #define QEDE_DRV_TO_ETHTOOL_CAPS(caps, lk_ksettings, name) \
469 for (i = 0; i < ARRAY_SIZE(qed_lm_map); i++) { \
470 if ((caps) & (qed_lm_map[i].qed_link_mode)) \
471 __set_bit(qed_lm_map[i].ethtool_link_mode,\
472 lk_ksettings->link_modes.name); \
476 #define QEDE_ETHTOOL_TO_DRV_CAPS(caps, lk_ksettings, name) \
480 for (i = 0; i < ARRAY_SIZE(qed_lm_map); i++) { \
481 if (test_bit(qed_lm_map[i].ethtool_link_mode, \
482 lk_ksettings->link_modes.name)) \
483 caps |= qed_lm_map[i].qed_link_mode; \
487 static int qede_get_link_ksettings(struct net_device *dev,
488 struct ethtool_link_ksettings *cmd)
490 struct ethtool_link_settings *base = &cmd->base;
491 struct qede_dev *edev = netdev_priv(dev);
492 struct qed_link_output current_link;
496 memset(¤t_link, 0, sizeof(current_link));
497 edev->ops->common->get_link(edev->cdev, ¤t_link);
499 ethtool_link_ksettings_zero_link_mode(cmd, supported);
500 QEDE_DRV_TO_ETHTOOL_CAPS(current_link.supported_caps, cmd, supported)
502 ethtool_link_ksettings_zero_link_mode(cmd, advertising);
503 QEDE_DRV_TO_ETHTOOL_CAPS(current_link.advertised_caps, cmd, advertising)
505 ethtool_link_ksettings_zero_link_mode(cmd, lp_advertising);
506 QEDE_DRV_TO_ETHTOOL_CAPS(current_link.lp_caps, cmd, lp_advertising)
508 if ((edev->state == QEDE_STATE_OPEN) && (current_link.link_up)) {
509 base->speed = current_link.speed;
510 base->duplex = current_link.duplex;
512 base->speed = SPEED_UNKNOWN;
513 base->duplex = DUPLEX_UNKNOWN;
518 base->port = current_link.port;
519 base->autoneg = (current_link.autoneg) ? AUTONEG_ENABLE :
525 static int qede_set_link_ksettings(struct net_device *dev,
526 const struct ethtool_link_ksettings *cmd)
528 const struct ethtool_link_settings *base = &cmd->base;
529 struct qede_dev *edev = netdev_priv(dev);
530 struct qed_link_output current_link;
531 struct qed_link_params params;
534 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
535 DP_INFO(edev, "Link settings are not allowed to be changed\n");
538 memset(¤t_link, 0, sizeof(current_link));
539 memset(¶ms, 0, sizeof(params));
540 edev->ops->common->get_link(edev->cdev, ¤t_link);
542 params.override_flags |= QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS;
543 params.override_flags |= QED_LINK_OVERRIDE_SPEED_AUTONEG;
544 if (base->autoneg == AUTONEG_ENABLE) {
545 if (!(current_link.supported_caps & QED_LM_Autoneg_BIT)) {
546 DP_INFO(edev, "Auto negotiation is not supported\n");
550 params.autoneg = true;
551 params.forced_speed = 0;
552 QEDE_ETHTOOL_TO_DRV_CAPS(params.adv_speeds, cmd, advertising)
553 } else { /* forced speed */
554 params.override_flags |= QED_LINK_OVERRIDE_SPEED_FORCED_SPEED;
555 params.autoneg = false;
556 params.forced_speed = base->speed;
557 switch (base->speed) {
559 sup_caps = QED_LM_1000baseT_Full_BIT |
560 QED_LM_1000baseKX_Full_BIT |
561 QED_LM_1000baseX_Full_BIT;
562 if (!(current_link.supported_caps & sup_caps)) {
563 DP_INFO(edev, "1G speed not supported\n");
566 params.adv_speeds = current_link.supported_caps &
570 sup_caps = QED_LM_10000baseT_Full_BIT |
571 QED_LM_10000baseKR_Full_BIT |
572 QED_LM_10000baseKX4_Full_BIT |
573 QED_LM_10000baseR_FEC_BIT |
574 QED_LM_10000baseCR_Full_BIT |
575 QED_LM_10000baseSR_Full_BIT |
576 QED_LM_10000baseLR_Full_BIT |
577 QED_LM_10000baseLRM_Full_BIT;
578 if (!(current_link.supported_caps & sup_caps)) {
579 DP_INFO(edev, "10G speed not supported\n");
582 params.adv_speeds = current_link.supported_caps &
586 if (!(current_link.supported_caps &
587 QED_LM_20000baseKR2_Full_BIT)) {
588 DP_INFO(edev, "20G speed not supported\n");
591 params.adv_speeds = QED_LM_20000baseKR2_Full_BIT;
594 sup_caps = QED_LM_25000baseKR_Full_BIT |
595 QED_LM_25000baseCR_Full_BIT |
596 QED_LM_25000baseSR_Full_BIT;
597 if (!(current_link.supported_caps & sup_caps)) {
598 DP_INFO(edev, "25G speed not supported\n");
601 params.adv_speeds = current_link.supported_caps &
605 sup_caps = QED_LM_40000baseLR4_Full_BIT |
606 QED_LM_40000baseKR4_Full_BIT |
607 QED_LM_40000baseCR4_Full_BIT |
608 QED_LM_40000baseSR4_Full_BIT;
609 if (!(current_link.supported_caps & sup_caps)) {
610 DP_INFO(edev, "40G speed not supported\n");
613 params.adv_speeds = current_link.supported_caps &
617 sup_caps = QED_LM_50000baseKR2_Full_BIT |
618 QED_LM_50000baseCR2_Full_BIT |
619 QED_LM_50000baseSR2_Full_BIT;
620 if (!(current_link.supported_caps & sup_caps)) {
621 DP_INFO(edev, "50G speed not supported\n");
624 params.adv_speeds = current_link.supported_caps &
628 sup_caps = QED_LM_100000baseKR4_Full_BIT |
629 QED_LM_100000baseSR4_Full_BIT |
630 QED_LM_100000baseCR4_Full_BIT |
631 QED_LM_100000baseLR4_ER4_Full_BIT;
632 if (!(current_link.supported_caps & sup_caps)) {
633 DP_INFO(edev, "100G speed not supported\n");
636 params.adv_speeds = current_link.supported_caps &
640 DP_INFO(edev, "Unsupported speed %u\n", base->speed);
645 params.link_up = true;
646 edev->ops->common->set_link(edev->cdev, ¶ms);
651 static void qede_get_drvinfo(struct net_device *ndev,
652 struct ethtool_drvinfo *info)
654 char mfw[ETHTOOL_FWVERS_LEN], storm[ETHTOOL_FWVERS_LEN];
655 struct qede_dev *edev = netdev_priv(ndev);
656 char mbi[ETHTOOL_FWVERS_LEN];
658 strlcpy(info->driver, "qede", sizeof(info->driver));
660 snprintf(storm, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
661 edev->dev_info.common.fw_major,
662 edev->dev_info.common.fw_minor,
663 edev->dev_info.common.fw_rev,
664 edev->dev_info.common.fw_eng);
666 snprintf(mfw, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
667 (edev->dev_info.common.mfw_rev >> 24) & 0xFF,
668 (edev->dev_info.common.mfw_rev >> 16) & 0xFF,
669 (edev->dev_info.common.mfw_rev >> 8) & 0xFF,
670 edev->dev_info.common.mfw_rev & 0xFF);
672 if ((strlen(storm) + strlen(DRV_MODULE_VERSION) + strlen("[storm] ")) <
673 sizeof(info->version))
674 snprintf(info->version, sizeof(info->version),
675 "%s [storm %s]", DRV_MODULE_VERSION, storm);
677 snprintf(info->version, sizeof(info->version),
678 "%s %s", DRV_MODULE_VERSION, storm);
680 if (edev->dev_info.common.mbi_version) {
681 snprintf(mbi, ETHTOOL_FWVERS_LEN, "%d.%d.%d",
682 (edev->dev_info.common.mbi_version &
683 QED_MBI_VERSION_2_MASK) >> QED_MBI_VERSION_2_OFFSET,
684 (edev->dev_info.common.mbi_version &
685 QED_MBI_VERSION_1_MASK) >> QED_MBI_VERSION_1_OFFSET,
686 (edev->dev_info.common.mbi_version &
687 QED_MBI_VERSION_0_MASK) >> QED_MBI_VERSION_0_OFFSET);
688 snprintf(info->fw_version, sizeof(info->fw_version),
689 "mbi %s [mfw %s]", mbi, mfw);
691 snprintf(info->fw_version, sizeof(info->fw_version),
695 strlcpy(info->bus_info, pci_name(edev->pdev), sizeof(info->bus_info));
698 static void qede_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
700 struct qede_dev *edev = netdev_priv(ndev);
702 if (edev->dev_info.common.wol_support) {
703 wol->supported = WAKE_MAGIC;
704 wol->wolopts = edev->wol_enabled ? WAKE_MAGIC : 0;
708 static int qede_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
710 struct qede_dev *edev = netdev_priv(ndev);
714 if (wol->wolopts & ~WAKE_MAGIC) {
716 "Can't support WoL options other than magic-packet\n");
720 wol_requested = !!(wol->wolopts & WAKE_MAGIC);
721 if (wol_requested == edev->wol_enabled)
724 /* Need to actually change configuration */
725 if (!edev->dev_info.common.wol_support) {
726 DP_INFO(edev, "Device doesn't support WoL\n");
730 rc = edev->ops->common->update_wol(edev->cdev, wol_requested);
732 edev->wol_enabled = wol_requested;
737 static u32 qede_get_msglevel(struct net_device *ndev)
739 struct qede_dev *edev = netdev_priv(ndev);
741 return ((u32)edev->dp_level << QED_LOG_LEVEL_SHIFT) | edev->dp_module;
744 static void qede_set_msglevel(struct net_device *ndev, u32 level)
746 struct qede_dev *edev = netdev_priv(ndev);
750 qede_config_debug(level, &dp_module, &dp_level);
752 edev->dp_level = dp_level;
753 edev->dp_module = dp_module;
754 edev->ops->common->update_msglvl(edev->cdev,
755 dp_module, dp_level);
758 static int qede_nway_reset(struct net_device *dev)
760 struct qede_dev *edev = netdev_priv(dev);
761 struct qed_link_output current_link;
762 struct qed_link_params link_params;
764 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
765 DP_INFO(edev, "Link settings are not allowed to be changed\n");
769 if (!netif_running(dev))
772 memset(¤t_link, 0, sizeof(current_link));
773 edev->ops->common->get_link(edev->cdev, ¤t_link);
774 if (!current_link.link_up)
777 /* Toggle the link */
778 memset(&link_params, 0, sizeof(link_params));
779 link_params.link_up = false;
780 edev->ops->common->set_link(edev->cdev, &link_params);
781 link_params.link_up = true;
782 edev->ops->common->set_link(edev->cdev, &link_params);
787 static u32 qede_get_link(struct net_device *dev)
789 struct qede_dev *edev = netdev_priv(dev);
790 struct qed_link_output current_link;
792 memset(¤t_link, 0, sizeof(current_link));
793 edev->ops->common->get_link(edev->cdev, ¤t_link);
795 return current_link.link_up;
798 static int qede_flash_device(struct net_device *dev,
799 struct ethtool_flash *flash)
801 struct qede_dev *edev = netdev_priv(dev);
803 return edev->ops->common->nvm_flash(edev->cdev, flash->data);
806 static int qede_get_coalesce(struct net_device *dev,
807 struct ethtool_coalesce *coal)
809 void *rx_handle = NULL, *tx_handle = NULL;
810 struct qede_dev *edev = netdev_priv(dev);
811 u16 rx_coal, tx_coal, i, rc = 0;
812 struct qede_fastpath *fp;
814 rx_coal = QED_DEFAULT_RX_USECS;
815 tx_coal = QED_DEFAULT_TX_USECS;
817 memset(coal, 0, sizeof(struct ethtool_coalesce));
820 if (edev->state == QEDE_STATE_OPEN) {
822 fp = &edev->fp_array[i];
824 if (fp->type & QEDE_FASTPATH_RX) {
825 rx_handle = fp->rxq->handle;
830 rc = edev->ops->get_coalesce(edev->cdev, &rx_coal, rx_handle);
832 DP_INFO(edev, "Read Rx coalesce error\n");
837 struct qede_tx_queue *txq;
839 fp = &edev->fp_array[i];
841 /* All TX queues of given fastpath uses same
842 * coalescing value, so no need to iterate over
843 * all TCs, TC0 txq should suffice.
845 if (fp->type & QEDE_FASTPATH_TX) {
846 txq = QEDE_FP_TC0_TXQ(fp);
847 tx_handle = txq->handle;
852 rc = edev->ops->get_coalesce(edev->cdev, &tx_coal, tx_handle);
854 DP_INFO(edev, "Read Tx coalesce error\n");
860 coal->rx_coalesce_usecs = rx_coal;
861 coal->tx_coalesce_usecs = tx_coal;
866 static int qede_set_coalesce(struct net_device *dev,
867 struct ethtool_coalesce *coal)
869 struct qede_dev *edev = netdev_priv(dev);
870 struct qede_fastpath *fp;
874 if (!netif_running(dev)) {
875 DP_INFO(edev, "Interface is down\n");
879 if (coal->rx_coalesce_usecs > QED_COALESCE_MAX ||
880 coal->tx_coalesce_usecs > QED_COALESCE_MAX) {
882 "Can't support requested %s coalesce value [max supported value %d]\n",
883 coal->rx_coalesce_usecs > QED_COALESCE_MAX ? "rx" :
884 "tx", QED_COALESCE_MAX);
888 rxc = (u16)coal->rx_coalesce_usecs;
889 txc = (u16)coal->tx_coalesce_usecs;
891 fp = &edev->fp_array[i];
893 if (edev->fp_array[i].type & QEDE_FASTPATH_RX) {
894 rc = edev->ops->common->set_coalesce(edev->cdev,
899 "Set RX coalesce error, rc = %d\n", rc);
904 if (edev->fp_array[i].type & QEDE_FASTPATH_TX) {
905 struct qede_tx_queue *txq;
907 /* All TX queues of given fastpath uses same
908 * coalescing value, so no need to iterate over
909 * all TCs, TC0 txq should suffice.
911 txq = QEDE_FP_TC0_TXQ(fp);
913 rc = edev->ops->common->set_coalesce(edev->cdev,
918 "Set TX coalesce error, rc = %d\n", rc);
927 static void qede_get_ringparam(struct net_device *dev,
928 struct ethtool_ringparam *ering)
930 struct qede_dev *edev = netdev_priv(dev);
932 ering->rx_max_pending = NUM_RX_BDS_MAX;
933 ering->rx_pending = edev->q_num_rx_buffers;
934 ering->tx_max_pending = NUM_TX_BDS_MAX;
935 ering->tx_pending = edev->q_num_tx_buffers;
938 static int qede_set_ringparam(struct net_device *dev,
939 struct ethtool_ringparam *ering)
941 struct qede_dev *edev = netdev_priv(dev);
943 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
944 "Set ring params command parameters: rx_pending = %d, tx_pending = %d\n",
945 ering->rx_pending, ering->tx_pending);
947 /* Validate legality of configuration */
948 if (ering->rx_pending > NUM_RX_BDS_MAX ||
949 ering->rx_pending < NUM_RX_BDS_MIN ||
950 ering->tx_pending > NUM_TX_BDS_MAX ||
951 ering->tx_pending < NUM_TX_BDS_MIN) {
952 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
953 "Can only support Rx Buffer size [0%08x,...,0x%08x] and Tx Buffer size [0x%08x,...,0x%08x]\n",
954 NUM_RX_BDS_MIN, NUM_RX_BDS_MAX,
955 NUM_TX_BDS_MIN, NUM_TX_BDS_MAX);
959 /* Change ring size and re-load */
960 edev->q_num_rx_buffers = ering->rx_pending;
961 edev->q_num_tx_buffers = ering->tx_pending;
963 qede_reload(edev, NULL, false);
968 static void qede_get_pauseparam(struct net_device *dev,
969 struct ethtool_pauseparam *epause)
971 struct qede_dev *edev = netdev_priv(dev);
972 struct qed_link_output current_link;
974 memset(¤t_link, 0, sizeof(current_link));
975 edev->ops->common->get_link(edev->cdev, ¤t_link);
977 if (current_link.pause_config & QED_LINK_PAUSE_AUTONEG_ENABLE)
978 epause->autoneg = true;
979 if (current_link.pause_config & QED_LINK_PAUSE_RX_ENABLE)
980 epause->rx_pause = true;
981 if (current_link.pause_config & QED_LINK_PAUSE_TX_ENABLE)
982 epause->tx_pause = true;
984 DP_VERBOSE(edev, QED_MSG_DEBUG,
985 "ethtool_pauseparam: cmd %d autoneg %d rx_pause %d tx_pause %d\n",
986 epause->cmd, epause->autoneg, epause->rx_pause,
990 static int qede_set_pauseparam(struct net_device *dev,
991 struct ethtool_pauseparam *epause)
993 struct qede_dev *edev = netdev_priv(dev);
994 struct qed_link_params params;
995 struct qed_link_output current_link;
997 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
999 "Pause settings are not allowed to be changed\n");
1003 memset(¤t_link, 0, sizeof(current_link));
1004 edev->ops->common->get_link(edev->cdev, ¤t_link);
1006 memset(¶ms, 0, sizeof(params));
1007 params.override_flags |= QED_LINK_OVERRIDE_PAUSE_CONFIG;
1008 if (epause->autoneg) {
1009 if (!(current_link.supported_caps & QED_LM_Autoneg_BIT)) {
1010 DP_INFO(edev, "autoneg not supported\n");
1013 params.pause_config |= QED_LINK_PAUSE_AUTONEG_ENABLE;
1015 if (epause->rx_pause)
1016 params.pause_config |= QED_LINK_PAUSE_RX_ENABLE;
1017 if (epause->tx_pause)
1018 params.pause_config |= QED_LINK_PAUSE_TX_ENABLE;
1020 params.link_up = true;
1021 edev->ops->common->set_link(edev->cdev, ¶ms);
1026 static void qede_get_regs(struct net_device *ndev,
1027 struct ethtool_regs *regs, void *buffer)
1029 struct qede_dev *edev = netdev_priv(ndev);
1032 memset(buffer, 0, regs->len);
1034 if (edev->ops && edev->ops->common)
1035 edev->ops->common->dbg_all_data(edev->cdev, buffer);
1038 static int qede_get_regs_len(struct net_device *ndev)
1040 struct qede_dev *edev = netdev_priv(ndev);
1042 if (edev->ops && edev->ops->common)
1043 return edev->ops->common->dbg_all_data_size(edev->cdev);
1048 static void qede_update_mtu(struct qede_dev *edev,
1049 struct qede_reload_args *args)
1051 edev->ndev->mtu = args->u.mtu;
1054 /* Netdevice NDOs */
1055 int qede_change_mtu(struct net_device *ndev, int new_mtu)
1057 struct qede_dev *edev = netdev_priv(ndev);
1058 struct qede_reload_args args;
1060 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1061 "Configuring MTU size of %d\n", new_mtu);
1063 if (new_mtu > PAGE_SIZE)
1064 ndev->features &= ~NETIF_F_GRO_HW;
1066 /* Set the mtu field and re-start the interface if needed */
1067 args.u.mtu = new_mtu;
1068 args.func = &qede_update_mtu;
1069 qede_reload(edev, &args, false);
1071 edev->ops->common->update_mtu(edev->cdev, new_mtu);
1076 static void qede_get_channels(struct net_device *dev,
1077 struct ethtool_channels *channels)
1079 struct qede_dev *edev = netdev_priv(dev);
1081 channels->max_combined = QEDE_MAX_RSS_CNT(edev);
1082 channels->max_rx = QEDE_MAX_RSS_CNT(edev);
1083 channels->max_tx = QEDE_MAX_RSS_CNT(edev);
1084 channels->combined_count = QEDE_QUEUE_CNT(edev) - edev->fp_num_tx -
1086 channels->tx_count = edev->fp_num_tx;
1087 channels->rx_count = edev->fp_num_rx;
1090 static int qede_set_channels(struct net_device *dev,
1091 struct ethtool_channels *channels)
1093 struct qede_dev *edev = netdev_priv(dev);
1096 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1097 "set-channels command parameters: rx = %d, tx = %d, other = %d, combined = %d\n",
1098 channels->rx_count, channels->tx_count,
1099 channels->other_count, channels->combined_count);
1101 count = channels->rx_count + channels->tx_count +
1102 channels->combined_count;
1104 /* We don't support `other' channels */
1105 if (channels->other_count) {
1106 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1107 "command parameters not supported\n");
1111 if (!(channels->combined_count || (channels->rx_count &&
1112 channels->tx_count))) {
1113 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1114 "need to request at least one transmit and one receive channel\n");
1118 if (count > QEDE_MAX_RSS_CNT(edev)) {
1119 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1120 "requested channels = %d max supported channels = %d\n",
1121 count, QEDE_MAX_RSS_CNT(edev));
1125 /* Check if there was a change in the active parameters */
1126 if ((count == QEDE_QUEUE_CNT(edev)) &&
1127 (channels->tx_count == edev->fp_num_tx) &&
1128 (channels->rx_count == edev->fp_num_rx)) {
1129 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1130 "No change in active parameters\n");
1134 /* We need the number of queues to be divisible between the hwfns */
1135 if ((count % edev->dev_info.common.num_hwfns) ||
1136 (channels->tx_count % edev->dev_info.common.num_hwfns) ||
1137 (channels->rx_count % edev->dev_info.common.num_hwfns)) {
1138 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1139 "Number of channels must be divisible by %04x\n",
1140 edev->dev_info.common.num_hwfns);
1144 /* Set number of queues and reload if necessary */
1145 edev->req_queues = count;
1146 edev->req_num_tx = channels->tx_count;
1147 edev->req_num_rx = channels->rx_count;
1148 /* Reset the indirection table if rx queue count is updated */
1149 if ((edev->req_queues - edev->req_num_tx) != QEDE_RSS_COUNT(edev)) {
1150 edev->rss_params_inited &= ~QEDE_RSS_INDIR_INITED;
1151 memset(edev->rss_ind_table, 0, sizeof(edev->rss_ind_table));
1154 qede_reload(edev, NULL, false);
1159 static int qede_get_ts_info(struct net_device *dev,
1160 struct ethtool_ts_info *info)
1162 struct qede_dev *edev = netdev_priv(dev);
1164 return qede_ptp_get_ts_info(edev, info);
1167 static int qede_set_phys_id(struct net_device *dev,
1168 enum ethtool_phys_id_state state)
1170 struct qede_dev *edev = netdev_priv(dev);
1174 case ETHTOOL_ID_ACTIVE:
1175 return 1; /* cycle on/off once per second */
1178 led_state = QED_LED_MODE_ON;
1181 case ETHTOOL_ID_OFF:
1182 led_state = QED_LED_MODE_OFF;
1185 case ETHTOOL_ID_INACTIVE:
1186 led_state = QED_LED_MODE_RESTORE;
1190 edev->ops->common->set_led(edev->cdev, led_state);
1195 static int qede_get_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
1197 info->data = RXH_IP_SRC | RXH_IP_DST;
1199 switch (info->flow_type) {
1202 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1205 if (edev->rss_caps & QED_RSS_IPV4_UDP)
1206 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1209 if (edev->rss_caps & QED_RSS_IPV6_UDP)
1210 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1223 static int qede_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
1226 struct qede_dev *edev = netdev_priv(dev);
1229 switch (info->cmd) {
1230 case ETHTOOL_GRXRINGS:
1231 info->data = QEDE_RSS_COUNT(edev);
1234 rc = qede_get_rss_flags(edev, info);
1236 case ETHTOOL_GRXCLSRLCNT:
1237 info->rule_cnt = qede_get_arfs_filter_count(edev);
1238 info->data = QEDE_RFS_MAX_FLTR;
1240 case ETHTOOL_GRXCLSRULE:
1241 rc = qede_get_cls_rule_entry(edev, info);
1243 case ETHTOOL_GRXCLSRLALL:
1244 rc = qede_get_cls_rule_all(edev, info, rule_locs);
1247 DP_ERR(edev, "Command parameters not supported\n");
1254 static int qede_set_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
1256 struct qed_update_vport_params *vport_update_params;
1257 u8 set_caps = 0, clr_caps = 0;
1260 DP_VERBOSE(edev, QED_MSG_DEBUG,
1261 "Set rss flags command parameters: flow type = %d, data = %llu\n",
1262 info->flow_type, info->data);
1264 switch (info->flow_type) {
1267 /* For TCP only 4-tuple hash is supported */
1268 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST |
1269 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1270 DP_INFO(edev, "Command parameters not supported\n");
1275 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
1276 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
1277 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1278 set_caps = QED_RSS_IPV4_UDP;
1279 DP_VERBOSE(edev, QED_MSG_DEBUG,
1280 "UDP 4-tuple enabled\n");
1281 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
1282 clr_caps = QED_RSS_IPV4_UDP;
1283 DP_VERBOSE(edev, QED_MSG_DEBUG,
1284 "UDP 4-tuple disabled\n");
1290 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
1291 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
1292 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1293 set_caps = QED_RSS_IPV6_UDP;
1294 DP_VERBOSE(edev, QED_MSG_DEBUG,
1295 "UDP 4-tuple enabled\n");
1296 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
1297 clr_caps = QED_RSS_IPV6_UDP;
1298 DP_VERBOSE(edev, QED_MSG_DEBUG,
1299 "UDP 4-tuple disabled\n");
1306 /* For IP only 2-tuple hash is supported */
1307 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST)) {
1308 DP_INFO(edev, "Command parameters not supported\n");
1313 case AH_ESP_V4_FLOW:
1317 case AH_ESP_V6_FLOW:
1322 /* RSS is not supported for these protocols */
1324 DP_INFO(edev, "Command parameters not supported\n");
1332 /* No action is needed if there is no change in the rss capability */
1333 if (edev->rss_caps == ((edev->rss_caps & ~clr_caps) | set_caps))
1336 /* Update internal configuration */
1337 edev->rss_caps = ((edev->rss_caps & ~clr_caps) | set_caps);
1338 edev->rss_params_inited |= QEDE_RSS_CAPS_INITED;
1340 /* Re-configure if possible */
1342 if (edev->state == QEDE_STATE_OPEN) {
1343 vport_update_params = vzalloc(sizeof(*vport_update_params));
1344 if (!vport_update_params) {
1345 __qede_unlock(edev);
1348 qede_fill_rss_params(edev, &vport_update_params->rss_params,
1349 &vport_update_params->update_rss_flg);
1350 rc = edev->ops->vport_update(edev->cdev, vport_update_params);
1351 vfree(vport_update_params);
1353 __qede_unlock(edev);
1358 static int qede_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info)
1360 struct qede_dev *edev = netdev_priv(dev);
1363 switch (info->cmd) {
1365 rc = qede_set_rss_flags(edev, info);
1367 case ETHTOOL_SRXCLSRLINS:
1368 rc = qede_add_cls_rule(edev, info);
1370 case ETHTOOL_SRXCLSRLDEL:
1371 rc = qede_delete_flow_filter(edev, info->fs.location);
1374 DP_INFO(edev, "Command parameters not supported\n");
1381 static u32 qede_get_rxfh_indir_size(struct net_device *dev)
1383 return QED_RSS_IND_TABLE_SIZE;
1386 static u32 qede_get_rxfh_key_size(struct net_device *dev)
1388 struct qede_dev *edev = netdev_priv(dev);
1390 return sizeof(edev->rss_key);
1393 static int qede_get_rxfh(struct net_device *dev, u32 *indir, u8 *key, u8 *hfunc)
1395 struct qede_dev *edev = netdev_priv(dev);
1399 *hfunc = ETH_RSS_HASH_TOP;
1404 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
1405 indir[i] = edev->rss_ind_table[i];
1408 memcpy(key, edev->rss_key, qede_get_rxfh_key_size(dev));
1413 static int qede_set_rxfh(struct net_device *dev, const u32 *indir,
1414 const u8 *key, const u8 hfunc)
1416 struct qed_update_vport_params *vport_update_params;
1417 struct qede_dev *edev = netdev_priv(dev);
1420 if (edev->dev_info.common.num_hwfns > 1) {
1422 "RSS configuration is not supported for 100G devices\n");
1426 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1433 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
1434 edev->rss_ind_table[i] = indir[i];
1435 edev->rss_params_inited |= QEDE_RSS_INDIR_INITED;
1439 memcpy(&edev->rss_key, key, qede_get_rxfh_key_size(dev));
1440 edev->rss_params_inited |= QEDE_RSS_KEY_INITED;
1444 if (edev->state == QEDE_STATE_OPEN) {
1445 vport_update_params = vzalloc(sizeof(*vport_update_params));
1446 if (!vport_update_params) {
1447 __qede_unlock(edev);
1450 qede_fill_rss_params(edev, &vport_update_params->rss_params,
1451 &vport_update_params->update_rss_flg);
1452 rc = edev->ops->vport_update(edev->cdev, vport_update_params);
1453 vfree(vport_update_params);
1455 __qede_unlock(edev);
1460 /* This function enables the interrupt generation and the NAPI on the device */
1461 static void qede_netif_start(struct qede_dev *edev)
1465 if (!netif_running(edev->ndev))
1469 /* Update and reenable interrupts */
1470 qed_sb_ack(edev->fp_array[i].sb_info, IGU_INT_ENABLE, 1);
1471 napi_enable(&edev->fp_array[i].napi);
1475 /* This function disables the NAPI and the interrupt generation on the device */
1476 static void qede_netif_stop(struct qede_dev *edev)
1481 napi_disable(&edev->fp_array[i].napi);
1482 /* Disable interrupts */
1483 qed_sb_ack(edev->fp_array[i].sb_info, IGU_INT_DISABLE, 0);
1487 static int qede_selftest_transmit_traffic(struct qede_dev *edev,
1488 struct sk_buff *skb)
1490 struct qede_tx_queue *txq = NULL;
1491 struct eth_tx_1st_bd *first_bd;
1497 struct qede_fastpath *fp = &edev->fp_array[i];
1499 if (fp->type & QEDE_FASTPATH_TX) {
1500 txq = QEDE_FP_TC0_TXQ(fp);
1506 DP_NOTICE(edev, "Tx path is not available\n");
1510 /* Fill the entry in the SW ring and the BDs in the FW ring */
1511 idx = txq->sw_tx_prod;
1512 txq->sw_tx_ring.skbs[idx].skb = skb;
1513 first_bd = qed_chain_produce(&txq->tx_pbl);
1514 memset(first_bd, 0, sizeof(*first_bd));
1515 val = 1 << ETH_TX_1ST_BD_FLAGS_START_BD_SHIFT;
1516 first_bd->data.bd_flags.bitfields = val;
1517 val = skb->len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK;
1518 val = val << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT;
1519 first_bd->data.bitfields |= cpu_to_le16(val);
1521 /* Map skb linear data for DMA and set in the first BD */
1522 mapping = dma_map_single(&edev->pdev->dev, skb->data,
1523 skb_headlen(skb), DMA_TO_DEVICE);
1524 if (unlikely(dma_mapping_error(&edev->pdev->dev, mapping))) {
1525 DP_NOTICE(edev, "SKB mapping failed\n");
1528 BD_SET_UNMAP_ADDR_LEN(first_bd, mapping, skb_headlen(skb));
1530 /* update the first BD with the actual num BDs */
1531 first_bd->data.nbds = 1;
1532 txq->sw_tx_prod = (txq->sw_tx_prod + 1) % txq->num_tx_buffers;
1533 /* 'next page' entries are counted in the producer value */
1534 val = qed_chain_get_prod_idx(&txq->tx_pbl);
1535 txq->tx_db.data.bd_prod = cpu_to_le16(val);
1537 /* wmb makes sure that the BDs data is updated before updating the
1538 * producer, otherwise FW may read old data from the BDs.
1542 writel(txq->tx_db.raw, txq->doorbell_addr);
1544 for (i = 0; i < QEDE_SELFTEST_POLL_COUNT; i++) {
1545 if (qede_txq_has_work(txq))
1547 usleep_range(100, 200);
1550 if (!qede_txq_has_work(txq)) {
1551 DP_NOTICE(edev, "Tx completion didn't happen\n");
1555 first_bd = (struct eth_tx_1st_bd *)qed_chain_consume(&txq->tx_pbl);
1556 dma_unmap_single(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd),
1557 BD_UNMAP_LEN(first_bd), DMA_TO_DEVICE);
1558 txq->sw_tx_cons = (txq->sw_tx_cons + 1) % txq->num_tx_buffers;
1559 txq->sw_tx_ring.skbs[idx].skb = NULL;
1564 static int qede_selftest_receive_traffic(struct qede_dev *edev)
1566 u16 hw_comp_cons, sw_comp_cons, sw_rx_index, len;
1567 struct eth_fast_path_rx_reg_cqe *fp_cqe;
1568 struct qede_rx_queue *rxq = NULL;
1569 struct sw_rx_data *sw_rx_data;
1570 union eth_rx_cqe *cqe;
1571 int i, iter, rc = 0;
1575 if (edev->fp_array[i].type & QEDE_FASTPATH_RX) {
1576 rxq = edev->fp_array[i].rxq;
1582 DP_NOTICE(edev, "Rx path is not available\n");
1586 /* The packet is expected to receive on rx-queue 0 even though RSS is
1587 * enabled. This is because the queue 0 is configured as the default
1588 * queue and that the loopback traffic is not IP.
1590 for (iter = 0; iter < QEDE_SELFTEST_POLL_COUNT; iter++) {
1591 if (!qede_has_rx_work(rxq)) {
1592 usleep_range(100, 200);
1596 hw_comp_cons = le16_to_cpu(*rxq->hw_cons_ptr);
1597 sw_comp_cons = qed_chain_get_cons_idx(&rxq->rx_comp_ring);
1599 /* Memory barrier to prevent the CPU from doing speculative
1600 * reads of CQE/BD before reading hw_comp_cons. If the CQE is
1601 * read before it is written by FW, then FW writes CQE and SB,
1602 * and then the CPU reads the hw_comp_cons, it will use an old
1607 /* Get the CQE from the completion ring */
1608 cqe = (union eth_rx_cqe *)qed_chain_consume(&rxq->rx_comp_ring);
1610 /* Get the data from the SW ring */
1611 sw_rx_index = rxq->sw_rx_cons & NUM_RX_BDS_MAX;
1612 sw_rx_data = &rxq->sw_rx_ring[sw_rx_index];
1613 fp_cqe = &cqe->fast_path_regular;
1614 len = le16_to_cpu(fp_cqe->len_on_first_bd);
1615 data_ptr = (u8 *)(page_address(sw_rx_data->data) +
1616 fp_cqe->placement_offset +
1617 sw_rx_data->page_offset +
1619 if (ether_addr_equal(data_ptr, edev->ndev->dev_addr) &&
1620 ether_addr_equal(data_ptr + ETH_ALEN,
1621 edev->ndev->dev_addr)) {
1622 for (i = ETH_HLEN; i < len; i++)
1623 if (data_ptr[i] != (unsigned char)(i & 0xff)) {
1628 qede_recycle_rx_bd_ring(rxq, 1);
1629 qed_chain_recycle_consumed(&rxq->rx_comp_ring);
1633 DP_INFO(edev, "Not the transmitted packet\n");
1634 qede_recycle_rx_bd_ring(rxq, 1);
1635 qed_chain_recycle_consumed(&rxq->rx_comp_ring);
1638 if (iter == QEDE_SELFTEST_POLL_COUNT) {
1639 DP_NOTICE(edev, "Failed to receive the traffic\n");
1643 qede_update_rx_prod(edev, rxq);
1648 static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode)
1650 struct qed_link_params link_params;
1651 struct sk_buff *skb = NULL;
1656 if (!netif_running(edev->ndev)) {
1657 DP_NOTICE(edev, "Interface is down\n");
1661 qede_netif_stop(edev);
1663 /* Bring up the link in Loopback mode */
1664 memset(&link_params, 0, sizeof(link_params));
1665 link_params.link_up = true;
1666 link_params.override_flags = QED_LINK_OVERRIDE_LOOPBACK_MODE;
1667 link_params.loopback_mode = loopback_mode;
1668 edev->ops->common->set_link(edev->cdev, &link_params);
1670 /* Wait for loopback configuration to apply */
1671 msleep_interruptible(500);
1673 /* Setting max packet size to 1.5K to avoid data being split over
1674 * multiple BDs in cases where MTU > PAGE_SIZE.
1676 pkt_size = (((edev->ndev->mtu < ETH_DATA_LEN) ?
1677 edev->ndev->mtu : ETH_DATA_LEN) + ETH_HLEN);
1679 skb = netdev_alloc_skb(edev->ndev, pkt_size);
1681 DP_INFO(edev, "Can't allocate skb\n");
1683 goto test_loopback_exit;
1685 packet = skb_put(skb, pkt_size);
1686 ether_addr_copy(packet, edev->ndev->dev_addr);
1687 ether_addr_copy(packet + ETH_ALEN, edev->ndev->dev_addr);
1688 memset(packet + (2 * ETH_ALEN), 0x77, (ETH_HLEN - (2 * ETH_ALEN)));
1689 for (i = ETH_HLEN; i < pkt_size; i++)
1690 packet[i] = (unsigned char)(i & 0xff);
1692 rc = qede_selftest_transmit_traffic(edev, skb);
1694 goto test_loopback_exit;
1696 rc = qede_selftest_receive_traffic(edev);
1698 goto test_loopback_exit;
1700 DP_VERBOSE(edev, NETIF_MSG_RX_STATUS, "Loopback test successful\n");
1705 /* Bring up the link in Normal mode */
1706 memset(&link_params, 0, sizeof(link_params));
1707 link_params.link_up = true;
1708 link_params.override_flags = QED_LINK_OVERRIDE_LOOPBACK_MODE;
1709 link_params.loopback_mode = QED_LINK_LOOPBACK_NONE;
1710 edev->ops->common->set_link(edev->cdev, &link_params);
1712 /* Wait for loopback configuration to apply */
1713 msleep_interruptible(500);
1715 qede_netif_start(edev);
1720 static void qede_self_test(struct net_device *dev,
1721 struct ethtool_test *etest, u64 *buf)
1723 struct qede_dev *edev = netdev_priv(dev);
1725 DP_VERBOSE(edev, QED_MSG_DEBUG,
1726 "Self-test command parameters: offline = %d, external_lb = %d\n",
1727 (etest->flags & ETH_TEST_FL_OFFLINE),
1728 (etest->flags & ETH_TEST_FL_EXTERNAL_LB) >> 2);
1730 memset(buf, 0, sizeof(u64) * QEDE_ETHTOOL_TEST_MAX);
1732 if (etest->flags & ETH_TEST_FL_OFFLINE) {
1733 if (qede_selftest_run_loopback(edev,
1734 QED_LINK_LOOPBACK_INT_PHY)) {
1735 buf[QEDE_ETHTOOL_INT_LOOPBACK] = 1;
1736 etest->flags |= ETH_TEST_FL_FAILED;
1740 if (edev->ops->common->selftest->selftest_interrupt(edev->cdev)) {
1741 buf[QEDE_ETHTOOL_INTERRUPT_TEST] = 1;
1742 etest->flags |= ETH_TEST_FL_FAILED;
1745 if (edev->ops->common->selftest->selftest_memory(edev->cdev)) {
1746 buf[QEDE_ETHTOOL_MEMORY_TEST] = 1;
1747 etest->flags |= ETH_TEST_FL_FAILED;
1750 if (edev->ops->common->selftest->selftest_register(edev->cdev)) {
1751 buf[QEDE_ETHTOOL_REGISTER_TEST] = 1;
1752 etest->flags |= ETH_TEST_FL_FAILED;
1755 if (edev->ops->common->selftest->selftest_clock(edev->cdev)) {
1756 buf[QEDE_ETHTOOL_CLOCK_TEST] = 1;
1757 etest->flags |= ETH_TEST_FL_FAILED;
1760 if (edev->ops->common->selftest->selftest_nvram(edev->cdev)) {
1761 buf[QEDE_ETHTOOL_NVRAM_TEST] = 1;
1762 etest->flags |= ETH_TEST_FL_FAILED;
1766 static int qede_set_tunable(struct net_device *dev,
1767 const struct ethtool_tunable *tuna,
1770 struct qede_dev *edev = netdev_priv(dev);
1774 case ETHTOOL_RX_COPYBREAK:
1776 if (val < QEDE_MIN_PKT_LEN || val > QEDE_RX_HDR_SIZE) {
1777 DP_VERBOSE(edev, QED_MSG_DEBUG,
1778 "Invalid rx copy break value, range is [%u, %u]",
1779 QEDE_MIN_PKT_LEN, QEDE_RX_HDR_SIZE);
1783 edev->rx_copybreak = *(u32 *)data;
1792 static int qede_get_tunable(struct net_device *dev,
1793 const struct ethtool_tunable *tuna, void *data)
1795 struct qede_dev *edev = netdev_priv(dev);
1798 case ETHTOOL_RX_COPYBREAK:
1799 *(u32 *)data = edev->rx_copybreak;
1808 static int qede_get_eee(struct net_device *dev, struct ethtool_eee *edata)
1810 struct qede_dev *edev = netdev_priv(dev);
1811 struct qed_link_output current_link;
1813 memset(¤t_link, 0, sizeof(current_link));
1814 edev->ops->common->get_link(edev->cdev, ¤t_link);
1816 if (!current_link.eee_supported) {
1817 DP_INFO(edev, "EEE is not supported\n");
1821 if (current_link.eee.adv_caps & QED_EEE_1G_ADV)
1822 edata->advertised = ADVERTISED_1000baseT_Full;
1823 if (current_link.eee.adv_caps & QED_EEE_10G_ADV)
1824 edata->advertised |= ADVERTISED_10000baseT_Full;
1825 if (current_link.sup_caps & QED_EEE_1G_ADV)
1826 edata->supported = ADVERTISED_1000baseT_Full;
1827 if (current_link.sup_caps & QED_EEE_10G_ADV)
1828 edata->supported |= ADVERTISED_10000baseT_Full;
1829 if (current_link.eee.lp_adv_caps & QED_EEE_1G_ADV)
1830 edata->lp_advertised = ADVERTISED_1000baseT_Full;
1831 if (current_link.eee.lp_adv_caps & QED_EEE_10G_ADV)
1832 edata->lp_advertised |= ADVERTISED_10000baseT_Full;
1834 edata->tx_lpi_timer = current_link.eee.tx_lpi_timer;
1835 edata->eee_enabled = current_link.eee.enable;
1836 edata->tx_lpi_enabled = current_link.eee.tx_lpi_enable;
1837 edata->eee_active = current_link.eee_active;
1842 static int qede_set_eee(struct net_device *dev, struct ethtool_eee *edata)
1844 struct qede_dev *edev = netdev_priv(dev);
1845 struct qed_link_output current_link;
1846 struct qed_link_params params;
1848 if (!edev->ops->common->can_link_change(edev->cdev)) {
1849 DP_INFO(edev, "Link settings are not allowed to be changed\n");
1853 memset(¤t_link, 0, sizeof(current_link));
1854 edev->ops->common->get_link(edev->cdev, ¤t_link);
1856 if (!current_link.eee_supported) {
1857 DP_INFO(edev, "EEE is not supported\n");
1861 memset(¶ms, 0, sizeof(params));
1862 params.override_flags |= QED_LINK_OVERRIDE_EEE_CONFIG;
1864 if (!(edata->advertised & (ADVERTISED_1000baseT_Full |
1865 ADVERTISED_10000baseT_Full)) ||
1866 ((edata->advertised & (ADVERTISED_1000baseT_Full |
1867 ADVERTISED_10000baseT_Full)) !=
1868 edata->advertised)) {
1869 DP_VERBOSE(edev, QED_MSG_DEBUG,
1870 "Invalid advertised capabilities %d\n",
1875 if (edata->advertised & ADVERTISED_1000baseT_Full)
1876 params.eee.adv_caps = QED_EEE_1G_ADV;
1877 if (edata->advertised & ADVERTISED_10000baseT_Full)
1878 params.eee.adv_caps |= QED_EEE_10G_ADV;
1879 params.eee.enable = edata->eee_enabled;
1880 params.eee.tx_lpi_enable = edata->tx_lpi_enabled;
1881 params.eee.tx_lpi_timer = edata->tx_lpi_timer;
1883 params.link_up = true;
1884 edev->ops->common->set_link(edev->cdev, ¶ms);
1889 static int qede_get_module_info(struct net_device *dev,
1890 struct ethtool_modinfo *modinfo)
1892 struct qede_dev *edev = netdev_priv(dev);
1896 /* Read first 4 bytes to find the sfp type */
1897 rc = edev->ops->common->read_module_eeprom(edev->cdev, buf,
1898 QED_I2C_DEV_ADDR_A0, 0, 4);
1900 DP_ERR(edev, "Failed reading EEPROM data %d\n", rc);
1905 case 0x3: /* SFP, SFP+, SFP-28 */
1906 modinfo->type = ETH_MODULE_SFF_8472;
1907 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
1909 case 0xc: /* QSFP */
1910 case 0xd: /* QSFP+ */
1911 modinfo->type = ETH_MODULE_SFF_8436;
1912 modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
1914 case 0x11: /* QSFP-28 */
1915 modinfo->type = ETH_MODULE_SFF_8636;
1916 modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN;
1919 DP_ERR(edev, "Unknown transceiver type 0x%x\n", buf[0]);
1926 static int qede_get_module_eeprom(struct net_device *dev,
1927 struct ethtool_eeprom *ee, u8 *data)
1929 struct qede_dev *edev = netdev_priv(dev);
1930 u32 start_addr = ee->offset, size = 0;
1934 /* Read A0 section */
1935 if (ee->offset < ETH_MODULE_SFF_8079_LEN) {
1936 /* Limit transfer size to the A0 section boundary */
1937 if (ee->offset + ee->len > ETH_MODULE_SFF_8079_LEN)
1938 size = ETH_MODULE_SFF_8079_LEN - ee->offset;
1942 rc = edev->ops->common->read_module_eeprom(edev->cdev, buf,
1943 QED_I2C_DEV_ADDR_A0,
1946 DP_ERR(edev, "Failed reading A0 section %d\n", rc);
1954 /* Read A2 section */
1955 if (start_addr >= ETH_MODULE_SFF_8079_LEN &&
1956 start_addr < ETH_MODULE_SFF_8472_LEN) {
1957 size = ee->len - size;
1958 /* Limit transfer size to the A2 section boundary */
1959 if (start_addr + size > ETH_MODULE_SFF_8472_LEN)
1960 size = ETH_MODULE_SFF_8472_LEN - start_addr;
1961 start_addr -= ETH_MODULE_SFF_8079_LEN;
1962 rc = edev->ops->common->read_module_eeprom(edev->cdev, buf,
1963 QED_I2C_DEV_ADDR_A2,
1966 DP_VERBOSE(edev, QED_MSG_DEBUG,
1967 "Failed reading A2 section %d\n", rc);
1975 static const struct ethtool_ops qede_ethtool_ops = {
1976 .get_link_ksettings = qede_get_link_ksettings,
1977 .set_link_ksettings = qede_set_link_ksettings,
1978 .get_drvinfo = qede_get_drvinfo,
1979 .get_regs_len = qede_get_regs_len,
1980 .get_regs = qede_get_regs,
1981 .get_wol = qede_get_wol,
1982 .set_wol = qede_set_wol,
1983 .get_msglevel = qede_get_msglevel,
1984 .set_msglevel = qede_set_msglevel,
1985 .nway_reset = qede_nway_reset,
1986 .get_link = qede_get_link,
1987 .get_coalesce = qede_get_coalesce,
1988 .set_coalesce = qede_set_coalesce,
1989 .get_ringparam = qede_get_ringparam,
1990 .set_ringparam = qede_set_ringparam,
1991 .get_pauseparam = qede_get_pauseparam,
1992 .set_pauseparam = qede_set_pauseparam,
1993 .get_strings = qede_get_strings,
1994 .set_phys_id = qede_set_phys_id,
1995 .get_ethtool_stats = qede_get_ethtool_stats,
1996 .get_priv_flags = qede_get_priv_flags,
1997 .get_sset_count = qede_get_sset_count,
1998 .get_rxnfc = qede_get_rxnfc,
1999 .set_rxnfc = qede_set_rxnfc,
2000 .get_rxfh_indir_size = qede_get_rxfh_indir_size,
2001 .get_rxfh_key_size = qede_get_rxfh_key_size,
2002 .get_rxfh = qede_get_rxfh,
2003 .set_rxfh = qede_set_rxfh,
2004 .get_ts_info = qede_get_ts_info,
2005 .get_channels = qede_get_channels,
2006 .set_channels = qede_set_channels,
2007 .self_test = qede_self_test,
2008 .get_module_info = qede_get_module_info,
2009 .get_module_eeprom = qede_get_module_eeprom,
2010 .get_eee = qede_get_eee,
2011 .set_eee = qede_set_eee,
2013 .get_tunable = qede_get_tunable,
2014 .set_tunable = qede_set_tunable,
2015 .flash_device = qede_flash_device,
2018 static const struct ethtool_ops qede_vf_ethtool_ops = {
2019 .get_link_ksettings = qede_get_link_ksettings,
2020 .get_drvinfo = qede_get_drvinfo,
2021 .get_msglevel = qede_get_msglevel,
2022 .set_msglevel = qede_set_msglevel,
2023 .get_link = qede_get_link,
2024 .get_coalesce = qede_get_coalesce,
2025 .set_coalesce = qede_set_coalesce,
2026 .get_ringparam = qede_get_ringparam,
2027 .set_ringparam = qede_set_ringparam,
2028 .get_strings = qede_get_strings,
2029 .get_ethtool_stats = qede_get_ethtool_stats,
2030 .get_priv_flags = qede_get_priv_flags,
2031 .get_sset_count = qede_get_sset_count,
2032 .get_rxnfc = qede_get_rxnfc,
2033 .set_rxnfc = qede_set_rxnfc,
2034 .get_rxfh_indir_size = qede_get_rxfh_indir_size,
2035 .get_rxfh_key_size = qede_get_rxfh_key_size,
2036 .get_rxfh = qede_get_rxfh,
2037 .set_rxfh = qede_set_rxfh,
2038 .get_channels = qede_get_channels,
2039 .set_channels = qede_set_channels,
2040 .get_tunable = qede_get_tunable,
2041 .set_tunable = qede_set_tunable,
2044 void qede_set_ethtool_ops(struct net_device *dev)
2046 struct qede_dev *edev = netdev_priv(dev);
2049 dev->ethtool_ops = &qede_vf_ethtool_ops;
2051 dev->ethtool_ops = &qede_ethtool_ops;