1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
2 /* QLogic qede NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
7 #include <linux/version.h>
8 #include <linux/types.h>
9 #include <linux/netdevice.h>
10 #include <linux/etherdevice.h>
11 #include <linux/ethtool.h>
12 #include <linux/string.h>
13 #include <linux/pci.h>
14 #include <linux/capability.h>
15 #include <linux/vmalloc.h>
16 #include <linux/phylink.h>
21 #define QEDE_RQSTAT_OFFSET(stat_name) \
22 (offsetof(struct qede_rx_queue, stat_name))
23 #define QEDE_RQSTAT_STRING(stat_name) (#stat_name)
24 #define QEDE_RQSTAT(stat_name) \
25 {QEDE_RQSTAT_OFFSET(stat_name), QEDE_RQSTAT_STRING(stat_name)}
27 #define QEDE_SELFTEST_POLL_COUNT 100
28 #define QEDE_DUMP_VERSION 0x1
29 #define QEDE_DUMP_NVM_ARG_COUNT 2
33 char string[ETH_GSTRING_LEN];
34 } qede_rqstats_arr[] = {
35 QEDE_RQSTAT(rcv_pkts),
36 QEDE_RQSTAT(rx_hw_errors),
37 QEDE_RQSTAT(rx_alloc_errors),
38 QEDE_RQSTAT(rx_ip_frags),
39 QEDE_RQSTAT(xdp_no_pass),
42 #define QEDE_NUM_RQSTATS ARRAY_SIZE(qede_rqstats_arr)
43 #define QEDE_TQSTAT_OFFSET(stat_name) \
44 (offsetof(struct qede_tx_queue, stat_name))
45 #define QEDE_TQSTAT_STRING(stat_name) (#stat_name)
46 #define QEDE_TQSTAT(stat_name) \
47 {QEDE_TQSTAT_OFFSET(stat_name), QEDE_TQSTAT_STRING(stat_name)}
48 #define QEDE_NUM_TQSTATS ARRAY_SIZE(qede_tqstats_arr)
51 char string[ETH_GSTRING_LEN];
52 } qede_tqstats_arr[] = {
53 QEDE_TQSTAT(xmit_pkts),
54 QEDE_TQSTAT(stopped_cnt),
55 QEDE_TQSTAT(tx_mem_alloc_err),
58 #define QEDE_STAT_OFFSET(stat_name, type, base) \
59 (offsetof(type, stat_name) + (base))
60 #define QEDE_STAT_STRING(stat_name) (#stat_name)
61 #define _QEDE_STAT(stat_name, type, base, attr) \
62 {QEDE_STAT_OFFSET(stat_name, type, base), \
63 QEDE_STAT_STRING(stat_name), \
65 #define QEDE_STAT(stat_name) \
66 _QEDE_STAT(stat_name, struct qede_stats_common, 0, 0x0)
67 #define QEDE_PF_STAT(stat_name) \
68 _QEDE_STAT(stat_name, struct qede_stats_common, 0, \
69 BIT(QEDE_STAT_PF_ONLY))
70 #define QEDE_PF_BB_STAT(stat_name) \
71 _QEDE_STAT(stat_name, struct qede_stats_bb, \
72 offsetof(struct qede_stats, bb), \
73 BIT(QEDE_STAT_PF_ONLY) | BIT(QEDE_STAT_BB_ONLY))
74 #define QEDE_PF_AH_STAT(stat_name) \
75 _QEDE_STAT(stat_name, struct qede_stats_ah, \
76 offsetof(struct qede_stats, ah), \
77 BIT(QEDE_STAT_PF_ONLY) | BIT(QEDE_STAT_AH_ONLY))
80 char string[ETH_GSTRING_LEN];
82 #define QEDE_STAT_PF_ONLY 0
83 #define QEDE_STAT_BB_ONLY 1
84 #define QEDE_STAT_AH_ONLY 2
85 } qede_stats_arr[] = {
86 QEDE_STAT(rx_ucast_bytes),
87 QEDE_STAT(rx_mcast_bytes),
88 QEDE_STAT(rx_bcast_bytes),
89 QEDE_STAT(rx_ucast_pkts),
90 QEDE_STAT(rx_mcast_pkts),
91 QEDE_STAT(rx_bcast_pkts),
93 QEDE_STAT(tx_ucast_bytes),
94 QEDE_STAT(tx_mcast_bytes),
95 QEDE_STAT(tx_bcast_bytes),
96 QEDE_STAT(tx_ucast_pkts),
97 QEDE_STAT(tx_mcast_pkts),
98 QEDE_STAT(tx_bcast_pkts),
100 QEDE_PF_STAT(rx_64_byte_packets),
101 QEDE_PF_STAT(rx_65_to_127_byte_packets),
102 QEDE_PF_STAT(rx_128_to_255_byte_packets),
103 QEDE_PF_STAT(rx_256_to_511_byte_packets),
104 QEDE_PF_STAT(rx_512_to_1023_byte_packets),
105 QEDE_PF_STAT(rx_1024_to_1518_byte_packets),
106 QEDE_PF_BB_STAT(rx_1519_to_1522_byte_packets),
107 QEDE_PF_BB_STAT(rx_1519_to_2047_byte_packets),
108 QEDE_PF_BB_STAT(rx_2048_to_4095_byte_packets),
109 QEDE_PF_BB_STAT(rx_4096_to_9216_byte_packets),
110 QEDE_PF_BB_STAT(rx_9217_to_16383_byte_packets),
111 QEDE_PF_AH_STAT(rx_1519_to_max_byte_packets),
112 QEDE_PF_STAT(tx_64_byte_packets),
113 QEDE_PF_STAT(tx_65_to_127_byte_packets),
114 QEDE_PF_STAT(tx_128_to_255_byte_packets),
115 QEDE_PF_STAT(tx_256_to_511_byte_packets),
116 QEDE_PF_STAT(tx_512_to_1023_byte_packets),
117 QEDE_PF_STAT(tx_1024_to_1518_byte_packets),
118 QEDE_PF_BB_STAT(tx_1519_to_2047_byte_packets),
119 QEDE_PF_BB_STAT(tx_2048_to_4095_byte_packets),
120 QEDE_PF_BB_STAT(tx_4096_to_9216_byte_packets),
121 QEDE_PF_BB_STAT(tx_9217_to_16383_byte_packets),
122 QEDE_PF_AH_STAT(tx_1519_to_max_byte_packets),
123 QEDE_PF_STAT(rx_mac_crtl_frames),
124 QEDE_PF_STAT(tx_mac_ctrl_frames),
125 QEDE_PF_STAT(rx_pause_frames),
126 QEDE_PF_STAT(tx_pause_frames),
127 QEDE_PF_STAT(rx_pfc_frames),
128 QEDE_PF_STAT(tx_pfc_frames),
130 QEDE_PF_STAT(rx_crc_errors),
131 QEDE_PF_STAT(rx_align_errors),
132 QEDE_PF_STAT(rx_carrier_errors),
133 QEDE_PF_STAT(rx_oversize_packets),
134 QEDE_PF_STAT(rx_jabbers),
135 QEDE_PF_STAT(rx_undersize_packets),
136 QEDE_PF_STAT(rx_fragments),
137 QEDE_PF_BB_STAT(tx_lpi_entry_count),
138 QEDE_PF_BB_STAT(tx_total_collisions),
139 QEDE_PF_STAT(brb_truncates),
140 QEDE_PF_STAT(brb_discards),
141 QEDE_STAT(no_buff_discards),
142 QEDE_PF_STAT(mftag_filter_discards),
143 QEDE_PF_STAT(mac_filter_discards),
144 QEDE_PF_STAT(gft_filter_drop),
145 QEDE_STAT(tx_err_drop_pkts),
146 QEDE_STAT(ttl0_discard),
147 QEDE_STAT(packet_too_big_discard),
149 QEDE_STAT(coalesced_pkts),
150 QEDE_STAT(coalesced_events),
151 QEDE_STAT(coalesced_aborts_num),
152 QEDE_STAT(non_coalesced_pkts),
153 QEDE_STAT(coalesced_bytes),
155 QEDE_STAT(link_change_count),
156 QEDE_STAT(ptp_skip_txts),
159 #define QEDE_NUM_STATS ARRAY_SIZE(qede_stats_arr)
160 #define QEDE_STAT_IS_PF_ONLY(i) \
161 test_bit(QEDE_STAT_PF_ONLY, &qede_stats_arr[i].attr)
162 #define QEDE_STAT_IS_BB_ONLY(i) \
163 test_bit(QEDE_STAT_BB_ONLY, &qede_stats_arr[i].attr)
164 #define QEDE_STAT_IS_AH_ONLY(i) \
165 test_bit(QEDE_STAT_AH_ONLY, &qede_stats_arr[i].attr)
169 QEDE_PRI_FLAG_SMART_AN_SUPPORT, /* MFW supports SmartAN */
170 QEDE_PRI_FLAG_RECOVER_ON_ERROR,
174 static const char qede_private_arr[QEDE_PRI_FLAG_LEN][ETH_GSTRING_LEN] = {
180 enum qede_ethtool_tests {
181 QEDE_ETHTOOL_INT_LOOPBACK,
182 QEDE_ETHTOOL_INTERRUPT_TEST,
183 QEDE_ETHTOOL_MEMORY_TEST,
184 QEDE_ETHTOOL_REGISTER_TEST,
185 QEDE_ETHTOOL_CLOCK_TEST,
186 QEDE_ETHTOOL_NVRAM_TEST,
187 QEDE_ETHTOOL_TEST_MAX
190 static const char qede_tests_str_arr[QEDE_ETHTOOL_TEST_MAX][ETH_GSTRING_LEN] = {
191 "Internal loopback (offline)",
192 "Interrupt (online)\t",
193 "Memory (online)\t\t",
194 "Register (online)\t",
195 "Clock (online)\t\t",
196 "Nvram (online)\t\t",
199 /* Forced speed capabilities maps */
201 struct qede_forced_speed_map {
203 __ETHTOOL_DECLARE_LINK_MODE_MASK(caps);
209 #define QEDE_FORCED_SPEED_MAP(value) \
211 .speed = SPEED_##value, \
212 .cap_arr = qede_forced_speed_##value, \
213 .arr_size = ARRAY_SIZE(qede_forced_speed_##value), \
216 static const u32 qede_forced_speed_1000[] __initconst = {
217 ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
218 ETHTOOL_LINK_MODE_1000baseKX_Full_BIT,
219 ETHTOOL_LINK_MODE_1000baseX_Full_BIT,
222 static const u32 qede_forced_speed_10000[] __initconst = {
223 ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
224 ETHTOOL_LINK_MODE_10000baseKR_Full_BIT,
225 ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT,
226 ETHTOOL_LINK_MODE_10000baseR_FEC_BIT,
227 ETHTOOL_LINK_MODE_10000baseCR_Full_BIT,
228 ETHTOOL_LINK_MODE_10000baseSR_Full_BIT,
229 ETHTOOL_LINK_MODE_10000baseLR_Full_BIT,
230 ETHTOOL_LINK_MODE_10000baseLRM_Full_BIT,
233 static const u32 qede_forced_speed_20000[] __initconst = {
234 ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT,
237 static const u32 qede_forced_speed_25000[] __initconst = {
238 ETHTOOL_LINK_MODE_25000baseKR_Full_BIT,
239 ETHTOOL_LINK_MODE_25000baseCR_Full_BIT,
240 ETHTOOL_LINK_MODE_25000baseSR_Full_BIT,
243 static const u32 qede_forced_speed_40000[] __initconst = {
244 ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT,
245 ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT,
246 ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT,
247 ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT,
250 static const u32 qede_forced_speed_50000[] __initconst = {
251 ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT,
252 ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT,
253 ETHTOOL_LINK_MODE_50000baseSR2_Full_BIT,
256 static const u32 qede_forced_speed_100000[] __initconst = {
257 ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT,
258 ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT,
259 ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT,
260 ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT,
263 static struct qede_forced_speed_map qede_forced_speed_maps[] __ro_after_init = {
264 QEDE_FORCED_SPEED_MAP(1000),
265 QEDE_FORCED_SPEED_MAP(10000),
266 QEDE_FORCED_SPEED_MAP(20000),
267 QEDE_FORCED_SPEED_MAP(25000),
268 QEDE_FORCED_SPEED_MAP(40000),
269 QEDE_FORCED_SPEED_MAP(50000),
270 QEDE_FORCED_SPEED_MAP(100000),
273 void __init qede_forced_speed_maps_init(void)
275 struct qede_forced_speed_map *map;
278 for (i = 0; i < ARRAY_SIZE(qede_forced_speed_maps); i++) {
279 map = qede_forced_speed_maps + i;
281 linkmode_set_bit_array(map->cap_arr, map->arr_size, map->caps);
287 /* Ethtool callbacks */
289 static void qede_get_strings_stats_txq(struct qede_dev *edev,
290 struct qede_tx_queue *txq, u8 **buf)
294 for (i = 0; i < QEDE_NUM_TQSTATS; i++) {
296 sprintf(*buf, "%d [XDP]: %s",
297 QEDE_TXQ_XDP_TO_IDX(edev, txq),
298 qede_tqstats_arr[i].string);
300 sprintf(*buf, "%d_%d: %s", txq->index, txq->cos,
301 qede_tqstats_arr[i].string);
302 *buf += ETH_GSTRING_LEN;
306 static void qede_get_strings_stats_rxq(struct qede_dev *edev,
307 struct qede_rx_queue *rxq, u8 **buf)
311 for (i = 0; i < QEDE_NUM_RQSTATS; i++) {
312 sprintf(*buf, "%d: %s", rxq->rxq_id,
313 qede_rqstats_arr[i].string);
314 *buf += ETH_GSTRING_LEN;
318 static bool qede_is_irrelevant_stat(struct qede_dev *edev, int stat_index)
320 return (IS_VF(edev) && QEDE_STAT_IS_PF_ONLY(stat_index)) ||
321 (QEDE_IS_BB(edev) && QEDE_STAT_IS_AH_ONLY(stat_index)) ||
322 (QEDE_IS_AH(edev) && QEDE_STAT_IS_BB_ONLY(stat_index));
325 static void qede_get_strings_stats(struct qede_dev *edev, u8 *buf)
327 struct qede_fastpath *fp;
330 /* Account for queue statistics */
331 for (i = 0; i < QEDE_QUEUE_CNT(edev); i++) {
332 fp = &edev->fp_array[i];
334 if (fp->type & QEDE_FASTPATH_RX)
335 qede_get_strings_stats_rxq(edev, fp->rxq, &buf);
337 if (fp->type & QEDE_FASTPATH_XDP)
338 qede_get_strings_stats_txq(edev, fp->xdp_tx, &buf);
340 if (fp->type & QEDE_FASTPATH_TX) {
343 for_each_cos_in_txq(edev, cos)
344 qede_get_strings_stats_txq(edev,
345 &fp->txq[cos], &buf);
349 /* Account for non-queue statistics */
350 for (i = 0; i < QEDE_NUM_STATS; i++) {
351 if (qede_is_irrelevant_stat(edev, i))
353 strcpy(buf, qede_stats_arr[i].string);
354 buf += ETH_GSTRING_LEN;
358 static void qede_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
360 struct qede_dev *edev = netdev_priv(dev);
364 qede_get_strings_stats(edev, buf);
366 case ETH_SS_PRIV_FLAGS:
367 memcpy(buf, qede_private_arr,
368 ETH_GSTRING_LEN * QEDE_PRI_FLAG_LEN);
371 memcpy(buf, qede_tests_str_arr,
372 ETH_GSTRING_LEN * QEDE_ETHTOOL_TEST_MAX);
375 DP_VERBOSE(edev, QED_MSG_DEBUG,
376 "Unsupported stringset 0x%08x\n", stringset);
380 static void qede_get_ethtool_stats_txq(struct qede_tx_queue *txq, u64 **buf)
384 for (i = 0; i < QEDE_NUM_TQSTATS; i++) {
385 **buf = *((u64 *)(((void *)txq) + qede_tqstats_arr[i].offset));
390 static void qede_get_ethtool_stats_rxq(struct qede_rx_queue *rxq, u64 **buf)
394 for (i = 0; i < QEDE_NUM_RQSTATS; i++) {
395 **buf = *((u64 *)(((void *)rxq) + qede_rqstats_arr[i].offset));
400 static void qede_get_ethtool_stats(struct net_device *dev,
401 struct ethtool_stats *stats, u64 *buf)
403 struct qede_dev *edev = netdev_priv(dev);
404 struct qede_fastpath *fp;
407 qede_fill_by_demand_stats(edev);
409 /* Need to protect the access to the fastpath array */
412 for (i = 0; i < QEDE_QUEUE_CNT(edev); i++) {
413 fp = &edev->fp_array[i];
415 if (fp->type & QEDE_FASTPATH_RX)
416 qede_get_ethtool_stats_rxq(fp->rxq, &buf);
418 if (fp->type & QEDE_FASTPATH_XDP)
419 qede_get_ethtool_stats_txq(fp->xdp_tx, &buf);
421 if (fp->type & QEDE_FASTPATH_TX) {
424 for_each_cos_in_txq(edev, cos)
425 qede_get_ethtool_stats_txq(&fp->txq[cos], &buf);
429 spin_lock(&edev->stats_lock);
431 for (i = 0; i < QEDE_NUM_STATS; i++) {
432 if (qede_is_irrelevant_stat(edev, i))
434 *buf = *((u64 *)(((void *)&edev->stats) +
435 qede_stats_arr[i].offset));
440 spin_unlock(&edev->stats_lock);
445 static int qede_get_sset_count(struct net_device *dev, int stringset)
447 struct qede_dev *edev = netdev_priv(dev);
448 int num_stats = QEDE_NUM_STATS, i;
452 for (i = 0; i < QEDE_NUM_STATS; i++)
453 if (qede_is_irrelevant_stat(edev, i))
456 /* Account for the Regular Tx statistics */
457 num_stats += QEDE_TSS_COUNT(edev) * QEDE_NUM_TQSTATS *
458 edev->dev_info.num_tc;
460 /* Account for the Regular Rx statistics */
461 num_stats += QEDE_RSS_COUNT(edev) * QEDE_NUM_RQSTATS;
463 /* Account for XDP statistics [if needed] */
465 num_stats += QEDE_RSS_COUNT(edev) * QEDE_NUM_TQSTATS;
468 case ETH_SS_PRIV_FLAGS:
469 return QEDE_PRI_FLAG_LEN;
472 return QEDE_ETHTOOL_TEST_MAX;
476 DP_VERBOSE(edev, QED_MSG_DEBUG,
477 "Unsupported stringset 0x%08x\n", stringset);
482 static u32 qede_get_priv_flags(struct net_device *dev)
484 struct qede_dev *edev = netdev_priv(dev);
487 if (edev->dev_info.common.num_hwfns > 1)
488 flags |= BIT(QEDE_PRI_FLAG_CMT);
490 if (edev->dev_info.common.smart_an)
491 flags |= BIT(QEDE_PRI_FLAG_SMART_AN_SUPPORT);
493 if (edev->err_flags & BIT(QEDE_ERR_IS_RECOVERABLE))
494 flags |= BIT(QEDE_PRI_FLAG_RECOVER_ON_ERROR);
499 static int qede_set_priv_flags(struct net_device *dev, u32 flags)
501 struct qede_dev *edev = netdev_priv(dev);
502 u32 cflags = qede_get_priv_flags(dev);
503 u32 dflags = flags ^ cflags;
505 /* can only change RECOVER_ON_ERROR flag */
506 if (dflags & ~BIT(QEDE_PRI_FLAG_RECOVER_ON_ERROR))
509 if (flags & BIT(QEDE_PRI_FLAG_RECOVER_ON_ERROR))
510 set_bit(QEDE_ERR_IS_RECOVERABLE, &edev->err_flags);
512 clear_bit(QEDE_ERR_IS_RECOVERABLE, &edev->err_flags);
517 static int qede_get_link_ksettings(struct net_device *dev,
518 struct ethtool_link_ksettings *cmd)
520 typeof(cmd->link_modes) *link_modes = &cmd->link_modes;
521 struct ethtool_link_settings *base = &cmd->base;
522 struct qede_dev *edev = netdev_priv(dev);
523 struct qed_link_output current_link;
527 memset(¤t_link, 0, sizeof(current_link));
528 edev->ops->common->get_link(edev->cdev, ¤t_link);
530 linkmode_copy(link_modes->supported, current_link.supported_caps);
531 linkmode_copy(link_modes->advertising, current_link.advertised_caps);
532 linkmode_copy(link_modes->lp_advertising, current_link.lp_caps);
534 if ((edev->state == QEDE_STATE_OPEN) && (current_link.link_up)) {
535 base->speed = current_link.speed;
536 base->duplex = current_link.duplex;
538 base->speed = SPEED_UNKNOWN;
539 base->duplex = DUPLEX_UNKNOWN;
544 base->port = current_link.port;
545 base->autoneg = (current_link.autoneg) ? AUTONEG_ENABLE :
551 static int qede_set_link_ksettings(struct net_device *dev,
552 const struct ethtool_link_ksettings *cmd)
554 const struct ethtool_link_settings *base = &cmd->base;
555 struct qede_dev *edev = netdev_priv(dev);
556 const struct qede_forced_speed_map *map;
557 struct qed_link_output current_link;
558 struct qed_link_params params;
561 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
562 DP_INFO(edev, "Link settings are not allowed to be changed\n");
565 memset(¤t_link, 0, sizeof(current_link));
566 memset(¶ms, 0, sizeof(params));
567 edev->ops->common->get_link(edev->cdev, ¤t_link);
569 params.override_flags |= QED_LINK_OVERRIDE_SPEED_ADV_SPEEDS;
570 params.override_flags |= QED_LINK_OVERRIDE_SPEED_AUTONEG;
572 if (base->autoneg == AUTONEG_ENABLE) {
573 if (!phylink_test(current_link.supported_caps, Autoneg)) {
574 DP_INFO(edev, "Auto negotiation is not supported\n");
578 params.autoneg = true;
579 params.forced_speed = 0;
581 linkmode_copy(params.adv_speeds, cmd->link_modes.advertising);
582 } else { /* forced speed */
583 params.override_flags |= QED_LINK_OVERRIDE_SPEED_FORCED_SPEED;
584 params.autoneg = false;
585 params.forced_speed = base->speed;
587 for (i = 0; i < ARRAY_SIZE(qede_forced_speed_maps); i++) {
588 map = qede_forced_speed_maps + i;
590 if (base->speed != map->speed ||
591 !linkmode_intersects(current_link.supported_caps,
595 linkmode_and(params.adv_speeds,
596 current_link.supported_caps, map->caps);
600 DP_INFO(edev, "Unsupported speed %u\n", base->speed);
605 params.link_up = true;
606 edev->ops->common->set_link(edev->cdev, ¶ms);
611 static void qede_get_drvinfo(struct net_device *ndev,
612 struct ethtool_drvinfo *info)
614 char mfw[ETHTOOL_FWVERS_LEN], storm[ETHTOOL_FWVERS_LEN];
615 struct qede_dev *edev = netdev_priv(ndev);
616 char mbi[ETHTOOL_FWVERS_LEN];
618 strlcpy(info->driver, "qede", sizeof(info->driver));
620 snprintf(storm, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
621 edev->dev_info.common.fw_major,
622 edev->dev_info.common.fw_minor,
623 edev->dev_info.common.fw_rev,
624 edev->dev_info.common.fw_eng);
626 snprintf(mfw, ETHTOOL_FWVERS_LEN, "%d.%d.%d.%d",
627 (edev->dev_info.common.mfw_rev >> 24) & 0xFF,
628 (edev->dev_info.common.mfw_rev >> 16) & 0xFF,
629 (edev->dev_info.common.mfw_rev >> 8) & 0xFF,
630 edev->dev_info.common.mfw_rev & 0xFF);
632 if ((strlen(storm) + strlen(DRV_MODULE_VERSION) + strlen("[storm] ")) <
633 sizeof(info->version))
634 snprintf(info->version, sizeof(info->version),
635 "%s [storm %s]", DRV_MODULE_VERSION, storm);
637 snprintf(info->version, sizeof(info->version),
638 "%s %s", DRV_MODULE_VERSION, storm);
640 if (edev->dev_info.common.mbi_version) {
641 snprintf(mbi, ETHTOOL_FWVERS_LEN, "%d.%d.%d",
642 (edev->dev_info.common.mbi_version &
643 QED_MBI_VERSION_2_MASK) >> QED_MBI_VERSION_2_OFFSET,
644 (edev->dev_info.common.mbi_version &
645 QED_MBI_VERSION_1_MASK) >> QED_MBI_VERSION_1_OFFSET,
646 (edev->dev_info.common.mbi_version &
647 QED_MBI_VERSION_0_MASK) >> QED_MBI_VERSION_0_OFFSET);
648 snprintf(info->fw_version, sizeof(info->fw_version),
649 "mbi %s [mfw %s]", mbi, mfw);
651 snprintf(info->fw_version, sizeof(info->fw_version),
655 strlcpy(info->bus_info, pci_name(edev->pdev), sizeof(info->bus_info));
658 static void qede_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
660 struct qede_dev *edev = netdev_priv(ndev);
662 if (edev->dev_info.common.wol_support) {
663 wol->supported = WAKE_MAGIC;
664 wol->wolopts = edev->wol_enabled ? WAKE_MAGIC : 0;
668 static int qede_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
670 struct qede_dev *edev = netdev_priv(ndev);
674 if (wol->wolopts & ~WAKE_MAGIC) {
676 "Can't support WoL options other than magic-packet\n");
680 wol_requested = !!(wol->wolopts & WAKE_MAGIC);
681 if (wol_requested == edev->wol_enabled)
684 /* Need to actually change configuration */
685 if (!edev->dev_info.common.wol_support) {
686 DP_INFO(edev, "Device doesn't support WoL\n");
690 rc = edev->ops->common->update_wol(edev->cdev, wol_requested);
692 edev->wol_enabled = wol_requested;
697 static u32 qede_get_msglevel(struct net_device *ndev)
699 struct qede_dev *edev = netdev_priv(ndev);
701 return ((u32)edev->dp_level << QED_LOG_LEVEL_SHIFT) | edev->dp_module;
704 static void qede_set_msglevel(struct net_device *ndev, u32 level)
706 struct qede_dev *edev = netdev_priv(ndev);
710 qede_config_debug(level, &dp_module, &dp_level);
712 edev->dp_level = dp_level;
713 edev->dp_module = dp_module;
714 edev->ops->common->update_msglvl(edev->cdev,
715 dp_module, dp_level);
718 static int qede_nway_reset(struct net_device *dev)
720 struct qede_dev *edev = netdev_priv(dev);
721 struct qed_link_output current_link;
722 struct qed_link_params link_params;
724 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
725 DP_INFO(edev, "Link settings are not allowed to be changed\n");
729 if (!netif_running(dev))
732 memset(¤t_link, 0, sizeof(current_link));
733 edev->ops->common->get_link(edev->cdev, ¤t_link);
734 if (!current_link.link_up)
737 /* Toggle the link */
738 memset(&link_params, 0, sizeof(link_params));
739 link_params.link_up = false;
740 edev->ops->common->set_link(edev->cdev, &link_params);
741 link_params.link_up = true;
742 edev->ops->common->set_link(edev->cdev, &link_params);
747 static u32 qede_get_link(struct net_device *dev)
749 struct qede_dev *edev = netdev_priv(dev);
750 struct qed_link_output current_link;
752 memset(¤t_link, 0, sizeof(current_link));
753 edev->ops->common->get_link(edev->cdev, ¤t_link);
755 return current_link.link_up;
758 static int qede_flash_device(struct net_device *dev,
759 struct ethtool_flash *flash)
761 struct qede_dev *edev = netdev_priv(dev);
763 return edev->ops->common->nvm_flash(edev->cdev, flash->data);
766 static int qede_get_coalesce(struct net_device *dev,
767 struct ethtool_coalesce *coal)
769 void *rx_handle = NULL, *tx_handle = NULL;
770 struct qede_dev *edev = netdev_priv(dev);
771 u16 rx_coal, tx_coal, i, rc = 0;
772 struct qede_fastpath *fp;
774 rx_coal = QED_DEFAULT_RX_USECS;
775 tx_coal = QED_DEFAULT_TX_USECS;
777 memset(coal, 0, sizeof(struct ethtool_coalesce));
780 if (edev->state == QEDE_STATE_OPEN) {
782 fp = &edev->fp_array[i];
784 if (fp->type & QEDE_FASTPATH_RX) {
785 rx_handle = fp->rxq->handle;
790 rc = edev->ops->get_coalesce(edev->cdev, &rx_coal, rx_handle);
792 DP_INFO(edev, "Read Rx coalesce error\n");
797 struct qede_tx_queue *txq;
799 fp = &edev->fp_array[i];
801 /* All TX queues of given fastpath uses same
802 * coalescing value, so no need to iterate over
803 * all TCs, TC0 txq should suffice.
805 if (fp->type & QEDE_FASTPATH_TX) {
806 txq = QEDE_FP_TC0_TXQ(fp);
807 tx_handle = txq->handle;
812 rc = edev->ops->get_coalesce(edev->cdev, &tx_coal, tx_handle);
814 DP_INFO(edev, "Read Tx coalesce error\n");
820 coal->rx_coalesce_usecs = rx_coal;
821 coal->tx_coalesce_usecs = tx_coal;
822 coal->stats_block_coalesce_usecs = edev->stats_coal_usecs;
827 static int qede_set_coalesce(struct net_device *dev,
828 struct ethtool_coalesce *coal)
830 struct qede_dev *edev = netdev_priv(dev);
831 struct qede_fastpath *fp;
835 if (edev->stats_coal_usecs != coal->stats_block_coalesce_usecs) {
836 edev->stats_coal_usecs = coal->stats_block_coalesce_usecs;
837 if (edev->stats_coal_usecs) {
838 edev->stats_coal_ticks = usecs_to_jiffies(edev->stats_coal_usecs);
839 schedule_delayed_work(&edev->periodic_task, 0);
841 DP_INFO(edev, "Configured stats coal ticks=%lu jiffies\n",
842 edev->stats_coal_ticks);
844 cancel_delayed_work_sync(&edev->periodic_task);
848 if (!netif_running(dev)) {
849 DP_INFO(edev, "Interface is down\n");
853 if (coal->rx_coalesce_usecs > QED_COALESCE_MAX ||
854 coal->tx_coalesce_usecs > QED_COALESCE_MAX) {
856 "Can't support requested %s coalesce value [max supported value %d]\n",
857 coal->rx_coalesce_usecs > QED_COALESCE_MAX ? "rx" :
858 "tx", QED_COALESCE_MAX);
862 rxc = (u16)coal->rx_coalesce_usecs;
863 txc = (u16)coal->tx_coalesce_usecs;
865 fp = &edev->fp_array[i];
867 if (edev->fp_array[i].type & QEDE_FASTPATH_RX) {
868 rc = edev->ops->common->set_coalesce(edev->cdev,
873 "Set RX coalesce error, rc = %d\n", rc);
878 if (edev->fp_array[i].type & QEDE_FASTPATH_TX) {
879 struct qede_tx_queue *txq;
881 /* All TX queues of given fastpath uses same
882 * coalescing value, so no need to iterate over
883 * all TCs, TC0 txq should suffice.
885 txq = QEDE_FP_TC0_TXQ(fp);
887 rc = edev->ops->common->set_coalesce(edev->cdev,
892 "Set TX coalesce error, rc = %d\n", rc);
901 static void qede_get_ringparam(struct net_device *dev,
902 struct ethtool_ringparam *ering)
904 struct qede_dev *edev = netdev_priv(dev);
906 ering->rx_max_pending = NUM_RX_BDS_MAX;
907 ering->rx_pending = edev->q_num_rx_buffers;
908 ering->tx_max_pending = NUM_TX_BDS_MAX;
909 ering->tx_pending = edev->q_num_tx_buffers;
912 static int qede_set_ringparam(struct net_device *dev,
913 struct ethtool_ringparam *ering)
915 struct qede_dev *edev = netdev_priv(dev);
917 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
918 "Set ring params command parameters: rx_pending = %d, tx_pending = %d\n",
919 ering->rx_pending, ering->tx_pending);
921 /* Validate legality of configuration */
922 if (ering->rx_pending > NUM_RX_BDS_MAX ||
923 ering->rx_pending < NUM_RX_BDS_MIN ||
924 ering->tx_pending > NUM_TX_BDS_MAX ||
925 ering->tx_pending < NUM_TX_BDS_MIN) {
926 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
927 "Can only support Rx Buffer size [0%08x,...,0x%08x] and Tx Buffer size [0x%08x,...,0x%08x]\n",
928 NUM_RX_BDS_MIN, NUM_RX_BDS_MAX,
929 NUM_TX_BDS_MIN, NUM_TX_BDS_MAX);
933 /* Change ring size and re-load */
934 edev->q_num_rx_buffers = ering->rx_pending;
935 edev->q_num_tx_buffers = ering->tx_pending;
937 qede_reload(edev, NULL, false);
942 static void qede_get_pauseparam(struct net_device *dev,
943 struct ethtool_pauseparam *epause)
945 struct qede_dev *edev = netdev_priv(dev);
946 struct qed_link_output current_link;
948 memset(¤t_link, 0, sizeof(current_link));
949 edev->ops->common->get_link(edev->cdev, ¤t_link);
951 if (current_link.pause_config & QED_LINK_PAUSE_AUTONEG_ENABLE)
952 epause->autoneg = true;
953 if (current_link.pause_config & QED_LINK_PAUSE_RX_ENABLE)
954 epause->rx_pause = true;
955 if (current_link.pause_config & QED_LINK_PAUSE_TX_ENABLE)
956 epause->tx_pause = true;
958 DP_VERBOSE(edev, QED_MSG_DEBUG,
959 "ethtool_pauseparam: cmd %d autoneg %d rx_pause %d tx_pause %d\n",
960 epause->cmd, epause->autoneg, epause->rx_pause,
964 static int qede_set_pauseparam(struct net_device *dev,
965 struct ethtool_pauseparam *epause)
967 struct qede_dev *edev = netdev_priv(dev);
968 struct qed_link_params params;
969 struct qed_link_output current_link;
971 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
973 "Pause settings are not allowed to be changed\n");
977 memset(¤t_link, 0, sizeof(current_link));
978 edev->ops->common->get_link(edev->cdev, ¤t_link);
980 memset(¶ms, 0, sizeof(params));
981 params.override_flags |= QED_LINK_OVERRIDE_PAUSE_CONFIG;
983 if (epause->autoneg) {
984 if (!phylink_test(current_link.supported_caps, Autoneg)) {
985 DP_INFO(edev, "autoneg not supported\n");
989 params.pause_config |= QED_LINK_PAUSE_AUTONEG_ENABLE;
992 if (epause->rx_pause)
993 params.pause_config |= QED_LINK_PAUSE_RX_ENABLE;
994 if (epause->tx_pause)
995 params.pause_config |= QED_LINK_PAUSE_TX_ENABLE;
997 params.link_up = true;
998 edev->ops->common->set_link(edev->cdev, ¶ms);
1003 static void qede_get_regs(struct net_device *ndev,
1004 struct ethtool_regs *regs, void *buffer)
1006 struct qede_dev *edev = netdev_priv(ndev);
1009 memset(buffer, 0, regs->len);
1011 if (edev->ops && edev->ops->common)
1012 edev->ops->common->dbg_all_data(edev->cdev, buffer);
1015 static int qede_get_regs_len(struct net_device *ndev)
1017 struct qede_dev *edev = netdev_priv(ndev);
1019 if (edev->ops && edev->ops->common)
1020 return edev->ops->common->dbg_all_data_size(edev->cdev);
1025 static void qede_update_mtu(struct qede_dev *edev,
1026 struct qede_reload_args *args)
1028 edev->ndev->mtu = args->u.mtu;
1031 /* Netdevice NDOs */
1032 int qede_change_mtu(struct net_device *ndev, int new_mtu)
1034 struct qede_dev *edev = netdev_priv(ndev);
1035 struct qede_reload_args args;
1037 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1038 "Configuring MTU size of %d\n", new_mtu);
1040 if (new_mtu > PAGE_SIZE)
1041 ndev->features &= ~NETIF_F_GRO_HW;
1043 /* Set the mtu field and re-start the interface if needed */
1044 args.u.mtu = new_mtu;
1045 args.func = &qede_update_mtu;
1046 qede_reload(edev, &args, false);
1047 #if IS_ENABLED(CONFIG_QED_RDMA)
1048 qede_rdma_event_change_mtu(edev);
1050 edev->ops->common->update_mtu(edev->cdev, new_mtu);
1055 static void qede_get_channels(struct net_device *dev,
1056 struct ethtool_channels *channels)
1058 struct qede_dev *edev = netdev_priv(dev);
1060 channels->max_combined = QEDE_MAX_RSS_CNT(edev);
1061 channels->max_rx = QEDE_MAX_RSS_CNT(edev);
1062 channels->max_tx = QEDE_MAX_RSS_CNT(edev);
1063 channels->combined_count = QEDE_QUEUE_CNT(edev) - edev->fp_num_tx -
1065 channels->tx_count = edev->fp_num_tx;
1066 channels->rx_count = edev->fp_num_rx;
1069 static int qede_set_channels(struct net_device *dev,
1070 struct ethtool_channels *channels)
1072 struct qede_dev *edev = netdev_priv(dev);
1075 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1076 "set-channels command parameters: rx = %d, tx = %d, other = %d, combined = %d\n",
1077 channels->rx_count, channels->tx_count,
1078 channels->other_count, channels->combined_count);
1080 count = channels->rx_count + channels->tx_count +
1081 channels->combined_count;
1083 /* We don't support `other' channels */
1084 if (channels->other_count) {
1085 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1086 "command parameters not supported\n");
1090 if (!(channels->combined_count || (channels->rx_count &&
1091 channels->tx_count))) {
1092 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1093 "need to request at least one transmit and one receive channel\n");
1097 if (count > QEDE_MAX_RSS_CNT(edev)) {
1098 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1099 "requested channels = %d max supported channels = %d\n",
1100 count, QEDE_MAX_RSS_CNT(edev));
1104 /* Check if there was a change in the active parameters */
1105 if ((count == QEDE_QUEUE_CNT(edev)) &&
1106 (channels->tx_count == edev->fp_num_tx) &&
1107 (channels->rx_count == edev->fp_num_rx)) {
1108 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1109 "No change in active parameters\n");
1113 /* We need the number of queues to be divisible between the hwfns */
1114 if ((count % edev->dev_info.common.num_hwfns) ||
1115 (channels->tx_count % edev->dev_info.common.num_hwfns) ||
1116 (channels->rx_count % edev->dev_info.common.num_hwfns)) {
1117 DP_VERBOSE(edev, (NETIF_MSG_IFUP | NETIF_MSG_IFDOWN),
1118 "Number of channels must be divisible by %04x\n",
1119 edev->dev_info.common.num_hwfns);
1123 /* Set number of queues and reload if necessary */
1124 edev->req_queues = count;
1125 edev->req_num_tx = channels->tx_count;
1126 edev->req_num_rx = channels->rx_count;
1127 /* Reset the indirection table if rx queue count is updated */
1128 if ((edev->req_queues - edev->req_num_tx) != QEDE_RSS_COUNT(edev)) {
1129 edev->rss_params_inited &= ~QEDE_RSS_INDIR_INITED;
1130 memset(edev->rss_ind_table, 0, sizeof(edev->rss_ind_table));
1133 qede_reload(edev, NULL, false);
1138 static int qede_get_ts_info(struct net_device *dev,
1139 struct ethtool_ts_info *info)
1141 struct qede_dev *edev = netdev_priv(dev);
1143 return qede_ptp_get_ts_info(edev, info);
1146 static int qede_set_phys_id(struct net_device *dev,
1147 enum ethtool_phys_id_state state)
1149 struct qede_dev *edev = netdev_priv(dev);
1153 case ETHTOOL_ID_ACTIVE:
1154 return 1; /* cycle on/off once per second */
1157 led_state = QED_LED_MODE_ON;
1160 case ETHTOOL_ID_OFF:
1161 led_state = QED_LED_MODE_OFF;
1164 case ETHTOOL_ID_INACTIVE:
1165 led_state = QED_LED_MODE_RESTORE;
1169 edev->ops->common->set_led(edev->cdev, led_state);
1174 static int qede_get_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
1176 info->data = RXH_IP_SRC | RXH_IP_DST;
1178 switch (info->flow_type) {
1181 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1184 if (edev->rss_caps & QED_RSS_IPV4_UDP)
1185 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1188 if (edev->rss_caps & QED_RSS_IPV6_UDP)
1189 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
1202 static int qede_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
1205 struct qede_dev *edev = netdev_priv(dev);
1208 switch (info->cmd) {
1209 case ETHTOOL_GRXRINGS:
1210 info->data = QEDE_RSS_COUNT(edev);
1213 rc = qede_get_rss_flags(edev, info);
1215 case ETHTOOL_GRXCLSRLCNT:
1216 info->rule_cnt = qede_get_arfs_filter_count(edev);
1217 info->data = QEDE_RFS_MAX_FLTR;
1219 case ETHTOOL_GRXCLSRULE:
1220 rc = qede_get_cls_rule_entry(edev, info);
1222 case ETHTOOL_GRXCLSRLALL:
1223 rc = qede_get_cls_rule_all(edev, info, rule_locs);
1226 DP_ERR(edev, "Command parameters not supported\n");
1233 static int qede_set_rss_flags(struct qede_dev *edev, struct ethtool_rxnfc *info)
1235 struct qed_update_vport_params *vport_update_params;
1236 u8 set_caps = 0, clr_caps = 0;
1239 DP_VERBOSE(edev, QED_MSG_DEBUG,
1240 "Set rss flags command parameters: flow type = %d, data = %llu\n",
1241 info->flow_type, info->data);
1243 switch (info->flow_type) {
1246 /* For TCP only 4-tuple hash is supported */
1247 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST |
1248 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1249 DP_INFO(edev, "Command parameters not supported\n");
1254 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
1255 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
1256 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1257 set_caps = QED_RSS_IPV4_UDP;
1258 DP_VERBOSE(edev, QED_MSG_DEBUG,
1259 "UDP 4-tuple enabled\n");
1260 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
1261 clr_caps = QED_RSS_IPV4_UDP;
1262 DP_VERBOSE(edev, QED_MSG_DEBUG,
1263 "UDP 4-tuple disabled\n");
1269 /* For UDP either 2-tuple hash or 4-tuple hash is supported */
1270 if (info->data == (RXH_IP_SRC | RXH_IP_DST |
1271 RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
1272 set_caps = QED_RSS_IPV6_UDP;
1273 DP_VERBOSE(edev, QED_MSG_DEBUG,
1274 "UDP 4-tuple enabled\n");
1275 } else if (info->data == (RXH_IP_SRC | RXH_IP_DST)) {
1276 clr_caps = QED_RSS_IPV6_UDP;
1277 DP_VERBOSE(edev, QED_MSG_DEBUG,
1278 "UDP 4-tuple disabled\n");
1285 /* For IP only 2-tuple hash is supported */
1286 if (info->data ^ (RXH_IP_SRC | RXH_IP_DST)) {
1287 DP_INFO(edev, "Command parameters not supported\n");
1292 case AH_ESP_V4_FLOW:
1296 case AH_ESP_V6_FLOW:
1301 /* RSS is not supported for these protocols */
1303 DP_INFO(edev, "Command parameters not supported\n");
1311 /* No action is needed if there is no change in the rss capability */
1312 if (edev->rss_caps == ((edev->rss_caps & ~clr_caps) | set_caps))
1315 /* Update internal configuration */
1316 edev->rss_caps = ((edev->rss_caps & ~clr_caps) | set_caps);
1317 edev->rss_params_inited |= QEDE_RSS_CAPS_INITED;
1319 /* Re-configure if possible */
1321 if (edev->state == QEDE_STATE_OPEN) {
1322 vport_update_params = vzalloc(sizeof(*vport_update_params));
1323 if (!vport_update_params) {
1324 __qede_unlock(edev);
1327 qede_fill_rss_params(edev, &vport_update_params->rss_params,
1328 &vport_update_params->update_rss_flg);
1329 rc = edev->ops->vport_update(edev->cdev, vport_update_params);
1330 vfree(vport_update_params);
1332 __qede_unlock(edev);
1337 static int qede_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info)
1339 struct qede_dev *edev = netdev_priv(dev);
1342 switch (info->cmd) {
1344 rc = qede_set_rss_flags(edev, info);
1346 case ETHTOOL_SRXCLSRLINS:
1347 rc = qede_add_cls_rule(edev, info);
1349 case ETHTOOL_SRXCLSRLDEL:
1350 rc = qede_delete_flow_filter(edev, info->fs.location);
1353 DP_INFO(edev, "Command parameters not supported\n");
1360 static u32 qede_get_rxfh_indir_size(struct net_device *dev)
1362 return QED_RSS_IND_TABLE_SIZE;
1365 static u32 qede_get_rxfh_key_size(struct net_device *dev)
1367 struct qede_dev *edev = netdev_priv(dev);
1369 return sizeof(edev->rss_key);
1372 static int qede_get_rxfh(struct net_device *dev, u32 *indir, u8 *key, u8 *hfunc)
1374 struct qede_dev *edev = netdev_priv(dev);
1378 *hfunc = ETH_RSS_HASH_TOP;
1383 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
1384 indir[i] = edev->rss_ind_table[i];
1387 memcpy(key, edev->rss_key, qede_get_rxfh_key_size(dev));
1392 static int qede_set_rxfh(struct net_device *dev, const u32 *indir,
1393 const u8 *key, const u8 hfunc)
1395 struct qed_update_vport_params *vport_update_params;
1396 struct qede_dev *edev = netdev_priv(dev);
1399 if (edev->dev_info.common.num_hwfns > 1) {
1401 "RSS configuration is not supported for 100G devices\n");
1405 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
1412 for (i = 0; i < QED_RSS_IND_TABLE_SIZE; i++)
1413 edev->rss_ind_table[i] = indir[i];
1414 edev->rss_params_inited |= QEDE_RSS_INDIR_INITED;
1418 memcpy(&edev->rss_key, key, qede_get_rxfh_key_size(dev));
1419 edev->rss_params_inited |= QEDE_RSS_KEY_INITED;
1423 if (edev->state == QEDE_STATE_OPEN) {
1424 vport_update_params = vzalloc(sizeof(*vport_update_params));
1425 if (!vport_update_params) {
1426 __qede_unlock(edev);
1429 qede_fill_rss_params(edev, &vport_update_params->rss_params,
1430 &vport_update_params->update_rss_flg);
1431 rc = edev->ops->vport_update(edev->cdev, vport_update_params);
1432 vfree(vport_update_params);
1434 __qede_unlock(edev);
1439 /* This function enables the interrupt generation and the NAPI on the device */
1440 static void qede_netif_start(struct qede_dev *edev)
1444 if (!netif_running(edev->ndev))
1448 /* Update and reenable interrupts */
1449 qed_sb_ack(edev->fp_array[i].sb_info, IGU_INT_ENABLE, 1);
1450 napi_enable(&edev->fp_array[i].napi);
1454 /* This function disables the NAPI and the interrupt generation on the device */
1455 static void qede_netif_stop(struct qede_dev *edev)
1460 napi_disable(&edev->fp_array[i].napi);
1461 /* Disable interrupts */
1462 qed_sb_ack(edev->fp_array[i].sb_info, IGU_INT_DISABLE, 0);
1466 static int qede_selftest_transmit_traffic(struct qede_dev *edev,
1467 struct sk_buff *skb)
1469 struct qede_tx_queue *txq = NULL;
1470 struct eth_tx_1st_bd *first_bd;
1476 struct qede_fastpath *fp = &edev->fp_array[i];
1478 if (fp->type & QEDE_FASTPATH_TX) {
1479 txq = QEDE_FP_TC0_TXQ(fp);
1485 DP_NOTICE(edev, "Tx path is not available\n");
1489 /* Fill the entry in the SW ring and the BDs in the FW ring */
1490 idx = txq->sw_tx_prod;
1491 txq->sw_tx_ring.skbs[idx].skb = skb;
1492 first_bd = qed_chain_produce(&txq->tx_pbl);
1493 memset(first_bd, 0, sizeof(*first_bd));
1494 val = 1 << ETH_TX_1ST_BD_FLAGS_START_BD_SHIFT;
1495 first_bd->data.bd_flags.bitfields = val;
1496 val = skb->len & ETH_TX_DATA_1ST_BD_PKT_LEN_MASK;
1497 val = val << ETH_TX_DATA_1ST_BD_PKT_LEN_SHIFT;
1498 first_bd->data.bitfields |= cpu_to_le16(val);
1500 /* Map skb linear data for DMA and set in the first BD */
1501 mapping = dma_map_single(&edev->pdev->dev, skb->data,
1502 skb_headlen(skb), DMA_TO_DEVICE);
1503 if (unlikely(dma_mapping_error(&edev->pdev->dev, mapping))) {
1504 DP_NOTICE(edev, "SKB mapping failed\n");
1507 BD_SET_UNMAP_ADDR_LEN(first_bd, mapping, skb_headlen(skb));
1509 /* update the first BD with the actual num BDs */
1510 first_bd->data.nbds = 1;
1511 txq->sw_tx_prod = (txq->sw_tx_prod + 1) % txq->num_tx_buffers;
1512 /* 'next page' entries are counted in the producer value */
1513 val = qed_chain_get_prod_idx(&txq->tx_pbl);
1514 txq->tx_db.data.bd_prod = cpu_to_le16(val);
1516 /* wmb makes sure that the BDs data is updated before updating the
1517 * producer, otherwise FW may read old data from the BDs.
1521 writel(txq->tx_db.raw, txq->doorbell_addr);
1523 for (i = 0; i < QEDE_SELFTEST_POLL_COUNT; i++) {
1524 if (qede_txq_has_work(txq))
1526 usleep_range(100, 200);
1529 if (!qede_txq_has_work(txq)) {
1530 DP_NOTICE(edev, "Tx completion didn't happen\n");
1534 first_bd = (struct eth_tx_1st_bd *)qed_chain_consume(&txq->tx_pbl);
1535 dma_unmap_single(&edev->pdev->dev, BD_UNMAP_ADDR(first_bd),
1536 BD_UNMAP_LEN(first_bd), DMA_TO_DEVICE);
1537 txq->sw_tx_cons = (txq->sw_tx_cons + 1) % txq->num_tx_buffers;
1538 txq->sw_tx_ring.skbs[idx].skb = NULL;
1543 static int qede_selftest_receive_traffic(struct qede_dev *edev)
1545 u16 sw_rx_index, len;
1546 struct eth_fast_path_rx_reg_cqe *fp_cqe;
1547 struct qede_rx_queue *rxq = NULL;
1548 struct sw_rx_data *sw_rx_data;
1549 union eth_rx_cqe *cqe;
1550 int i, iter, rc = 0;
1554 if (edev->fp_array[i].type & QEDE_FASTPATH_RX) {
1555 rxq = edev->fp_array[i].rxq;
1561 DP_NOTICE(edev, "Rx path is not available\n");
1565 /* The packet is expected to receive on rx-queue 0 even though RSS is
1566 * enabled. This is because the queue 0 is configured as the default
1567 * queue and that the loopback traffic is not IP.
1569 for (iter = 0; iter < QEDE_SELFTEST_POLL_COUNT; iter++) {
1570 if (!qede_has_rx_work(rxq)) {
1571 usleep_range(100, 200);
1575 /* Get the CQE from the completion ring */
1576 cqe = (union eth_rx_cqe *)qed_chain_consume(&rxq->rx_comp_ring);
1578 /* Get the data from the SW ring */
1579 sw_rx_index = rxq->sw_rx_cons & NUM_RX_BDS_MAX;
1580 sw_rx_data = &rxq->sw_rx_ring[sw_rx_index];
1581 fp_cqe = &cqe->fast_path_regular;
1582 len = le16_to_cpu(fp_cqe->len_on_first_bd);
1583 data_ptr = (u8 *)(page_address(sw_rx_data->data) +
1584 fp_cqe->placement_offset +
1585 sw_rx_data->page_offset +
1587 if (ether_addr_equal(data_ptr, edev->ndev->dev_addr) &&
1588 ether_addr_equal(data_ptr + ETH_ALEN,
1589 edev->ndev->dev_addr)) {
1590 for (i = ETH_HLEN; i < len; i++)
1591 if (data_ptr[i] != (unsigned char)(i & 0xff)) {
1596 qede_recycle_rx_bd_ring(rxq, 1);
1597 qed_chain_recycle_consumed(&rxq->rx_comp_ring);
1601 DP_INFO(edev, "Not the transmitted packet\n");
1602 qede_recycle_rx_bd_ring(rxq, 1);
1603 qed_chain_recycle_consumed(&rxq->rx_comp_ring);
1606 if (iter == QEDE_SELFTEST_POLL_COUNT) {
1607 DP_NOTICE(edev, "Failed to receive the traffic\n");
1611 qede_update_rx_prod(edev, rxq);
1616 static int qede_selftest_run_loopback(struct qede_dev *edev, u32 loopback_mode)
1618 struct qed_link_params link_params;
1619 struct sk_buff *skb = NULL;
1624 if (!netif_running(edev->ndev)) {
1625 DP_NOTICE(edev, "Interface is down\n");
1629 qede_netif_stop(edev);
1631 /* Bring up the link in Loopback mode */
1632 memset(&link_params, 0, sizeof(link_params));
1633 link_params.link_up = true;
1634 link_params.override_flags = QED_LINK_OVERRIDE_LOOPBACK_MODE;
1635 link_params.loopback_mode = loopback_mode;
1636 edev->ops->common->set_link(edev->cdev, &link_params);
1638 /* Wait for loopback configuration to apply */
1639 msleep_interruptible(500);
1641 /* Setting max packet size to 1.5K to avoid data being split over
1642 * multiple BDs in cases where MTU > PAGE_SIZE.
1644 pkt_size = (((edev->ndev->mtu < ETH_DATA_LEN) ?
1645 edev->ndev->mtu : ETH_DATA_LEN) + ETH_HLEN);
1647 skb = netdev_alloc_skb(edev->ndev, pkt_size);
1649 DP_INFO(edev, "Can't allocate skb\n");
1651 goto test_loopback_exit;
1653 packet = skb_put(skb, pkt_size);
1654 ether_addr_copy(packet, edev->ndev->dev_addr);
1655 ether_addr_copy(packet + ETH_ALEN, edev->ndev->dev_addr);
1656 memset(packet + (2 * ETH_ALEN), 0x77, (ETH_HLEN - (2 * ETH_ALEN)));
1657 for (i = ETH_HLEN; i < pkt_size; i++)
1658 packet[i] = (unsigned char)(i & 0xff);
1660 rc = qede_selftest_transmit_traffic(edev, skb);
1662 goto test_loopback_exit;
1664 rc = qede_selftest_receive_traffic(edev);
1666 goto test_loopback_exit;
1668 DP_VERBOSE(edev, NETIF_MSG_RX_STATUS, "Loopback test successful\n");
1673 /* Bring up the link in Normal mode */
1674 memset(&link_params, 0, sizeof(link_params));
1675 link_params.link_up = true;
1676 link_params.override_flags = QED_LINK_OVERRIDE_LOOPBACK_MODE;
1677 link_params.loopback_mode = QED_LINK_LOOPBACK_NONE;
1678 edev->ops->common->set_link(edev->cdev, &link_params);
1680 /* Wait for loopback configuration to apply */
1681 msleep_interruptible(500);
1683 qede_netif_start(edev);
1688 static void qede_self_test(struct net_device *dev,
1689 struct ethtool_test *etest, u64 *buf)
1691 struct qede_dev *edev = netdev_priv(dev);
1693 DP_VERBOSE(edev, QED_MSG_DEBUG,
1694 "Self-test command parameters: offline = %d, external_lb = %d\n",
1695 (etest->flags & ETH_TEST_FL_OFFLINE),
1696 (etest->flags & ETH_TEST_FL_EXTERNAL_LB) >> 2);
1698 memset(buf, 0, sizeof(u64) * QEDE_ETHTOOL_TEST_MAX);
1700 if (etest->flags & ETH_TEST_FL_OFFLINE) {
1701 if (qede_selftest_run_loopback(edev,
1702 QED_LINK_LOOPBACK_INT_PHY)) {
1703 buf[QEDE_ETHTOOL_INT_LOOPBACK] = 1;
1704 etest->flags |= ETH_TEST_FL_FAILED;
1708 if (edev->ops->common->selftest->selftest_interrupt(edev->cdev)) {
1709 buf[QEDE_ETHTOOL_INTERRUPT_TEST] = 1;
1710 etest->flags |= ETH_TEST_FL_FAILED;
1713 if (edev->ops->common->selftest->selftest_memory(edev->cdev)) {
1714 buf[QEDE_ETHTOOL_MEMORY_TEST] = 1;
1715 etest->flags |= ETH_TEST_FL_FAILED;
1718 if (edev->ops->common->selftest->selftest_register(edev->cdev)) {
1719 buf[QEDE_ETHTOOL_REGISTER_TEST] = 1;
1720 etest->flags |= ETH_TEST_FL_FAILED;
1723 if (edev->ops->common->selftest->selftest_clock(edev->cdev)) {
1724 buf[QEDE_ETHTOOL_CLOCK_TEST] = 1;
1725 etest->flags |= ETH_TEST_FL_FAILED;
1728 if (edev->ops->common->selftest->selftest_nvram(edev->cdev)) {
1729 buf[QEDE_ETHTOOL_NVRAM_TEST] = 1;
1730 etest->flags |= ETH_TEST_FL_FAILED;
1734 static int qede_set_tunable(struct net_device *dev,
1735 const struct ethtool_tunable *tuna,
1738 struct qede_dev *edev = netdev_priv(dev);
1742 case ETHTOOL_RX_COPYBREAK:
1744 if (val < QEDE_MIN_PKT_LEN || val > QEDE_RX_HDR_SIZE) {
1745 DP_VERBOSE(edev, QED_MSG_DEBUG,
1746 "Invalid rx copy break value, range is [%u, %u]",
1747 QEDE_MIN_PKT_LEN, QEDE_RX_HDR_SIZE);
1751 edev->rx_copybreak = *(u32 *)data;
1760 static int qede_get_tunable(struct net_device *dev,
1761 const struct ethtool_tunable *tuna, void *data)
1763 struct qede_dev *edev = netdev_priv(dev);
1766 case ETHTOOL_RX_COPYBREAK:
1767 *(u32 *)data = edev->rx_copybreak;
1776 static int qede_get_eee(struct net_device *dev, struct ethtool_eee *edata)
1778 struct qede_dev *edev = netdev_priv(dev);
1779 struct qed_link_output current_link;
1781 memset(¤t_link, 0, sizeof(current_link));
1782 edev->ops->common->get_link(edev->cdev, ¤t_link);
1784 if (!current_link.eee_supported) {
1785 DP_INFO(edev, "EEE is not supported\n");
1789 if (current_link.eee.adv_caps & QED_EEE_1G_ADV)
1790 edata->advertised = ADVERTISED_1000baseT_Full;
1791 if (current_link.eee.adv_caps & QED_EEE_10G_ADV)
1792 edata->advertised |= ADVERTISED_10000baseT_Full;
1793 if (current_link.sup_caps & QED_EEE_1G_ADV)
1794 edata->supported = ADVERTISED_1000baseT_Full;
1795 if (current_link.sup_caps & QED_EEE_10G_ADV)
1796 edata->supported |= ADVERTISED_10000baseT_Full;
1797 if (current_link.eee.lp_adv_caps & QED_EEE_1G_ADV)
1798 edata->lp_advertised = ADVERTISED_1000baseT_Full;
1799 if (current_link.eee.lp_adv_caps & QED_EEE_10G_ADV)
1800 edata->lp_advertised |= ADVERTISED_10000baseT_Full;
1802 edata->tx_lpi_timer = current_link.eee.tx_lpi_timer;
1803 edata->eee_enabled = current_link.eee.enable;
1804 edata->tx_lpi_enabled = current_link.eee.tx_lpi_enable;
1805 edata->eee_active = current_link.eee_active;
1810 static int qede_set_eee(struct net_device *dev, struct ethtool_eee *edata)
1812 struct qede_dev *edev = netdev_priv(dev);
1813 struct qed_link_output current_link;
1814 struct qed_link_params params;
1816 if (!edev->ops->common->can_link_change(edev->cdev)) {
1817 DP_INFO(edev, "Link settings are not allowed to be changed\n");
1821 memset(¤t_link, 0, sizeof(current_link));
1822 edev->ops->common->get_link(edev->cdev, ¤t_link);
1824 if (!current_link.eee_supported) {
1825 DP_INFO(edev, "EEE is not supported\n");
1829 memset(¶ms, 0, sizeof(params));
1830 params.override_flags |= QED_LINK_OVERRIDE_EEE_CONFIG;
1832 if (!(edata->advertised & (ADVERTISED_1000baseT_Full |
1833 ADVERTISED_10000baseT_Full)) ||
1834 ((edata->advertised & (ADVERTISED_1000baseT_Full |
1835 ADVERTISED_10000baseT_Full)) !=
1836 edata->advertised)) {
1837 DP_VERBOSE(edev, QED_MSG_DEBUG,
1838 "Invalid advertised capabilities %d\n",
1843 if (edata->advertised & ADVERTISED_1000baseT_Full)
1844 params.eee.adv_caps = QED_EEE_1G_ADV;
1845 if (edata->advertised & ADVERTISED_10000baseT_Full)
1846 params.eee.adv_caps |= QED_EEE_10G_ADV;
1847 params.eee.enable = edata->eee_enabled;
1848 params.eee.tx_lpi_enable = edata->tx_lpi_enabled;
1849 params.eee.tx_lpi_timer = edata->tx_lpi_timer;
1851 params.link_up = true;
1852 edev->ops->common->set_link(edev->cdev, ¶ms);
1857 static u32 qede_link_to_ethtool_fec(u32 link_fec)
1861 if (link_fec & QED_FEC_MODE_NONE)
1862 eth_fec |= ETHTOOL_FEC_OFF;
1863 if (link_fec & QED_FEC_MODE_FIRECODE)
1864 eth_fec |= ETHTOOL_FEC_BASER;
1865 if (link_fec & QED_FEC_MODE_RS)
1866 eth_fec |= ETHTOOL_FEC_RS;
1867 if (link_fec & QED_FEC_MODE_AUTO)
1868 eth_fec |= ETHTOOL_FEC_AUTO;
1869 if (link_fec & QED_FEC_MODE_UNSUPPORTED)
1870 eth_fec |= ETHTOOL_FEC_NONE;
1875 static u32 qede_ethtool_to_link_fec(u32 eth_fec)
1879 if (eth_fec & ETHTOOL_FEC_OFF)
1880 link_fec |= QED_FEC_MODE_NONE;
1881 if (eth_fec & ETHTOOL_FEC_BASER)
1882 link_fec |= QED_FEC_MODE_FIRECODE;
1883 if (eth_fec & ETHTOOL_FEC_RS)
1884 link_fec |= QED_FEC_MODE_RS;
1885 if (eth_fec & ETHTOOL_FEC_AUTO)
1886 link_fec |= QED_FEC_MODE_AUTO;
1887 if (eth_fec & ETHTOOL_FEC_NONE)
1888 link_fec |= QED_FEC_MODE_UNSUPPORTED;
1893 static int qede_get_fecparam(struct net_device *dev,
1894 struct ethtool_fecparam *fecparam)
1896 struct qede_dev *edev = netdev_priv(dev);
1897 struct qed_link_output curr_link;
1899 memset(&curr_link, 0, sizeof(curr_link));
1900 edev->ops->common->get_link(edev->cdev, &curr_link);
1902 fecparam->active_fec = qede_link_to_ethtool_fec(curr_link.active_fec);
1903 fecparam->fec = qede_link_to_ethtool_fec(curr_link.sup_fec);
1908 static int qede_set_fecparam(struct net_device *dev,
1909 struct ethtool_fecparam *fecparam)
1911 struct qede_dev *edev = netdev_priv(dev);
1912 struct qed_link_params params;
1914 if (!edev->ops || !edev->ops->common->can_link_change(edev->cdev)) {
1915 DP_INFO(edev, "Link settings are not allowed to be changed\n");
1919 memset(¶ms, 0, sizeof(params));
1920 params.override_flags |= QED_LINK_OVERRIDE_FEC_CONFIG;
1921 params.fec = qede_ethtool_to_link_fec(fecparam->fec);
1922 params.link_up = true;
1924 edev->ops->common->set_link(edev->cdev, ¶ms);
1929 static int qede_get_module_info(struct net_device *dev,
1930 struct ethtool_modinfo *modinfo)
1932 struct qede_dev *edev = netdev_priv(dev);
1936 /* Read first 4 bytes to find the sfp type */
1937 rc = edev->ops->common->read_module_eeprom(edev->cdev, buf,
1938 QED_I2C_DEV_ADDR_A0, 0, 4);
1940 DP_ERR(edev, "Failed reading EEPROM data %d\n", rc);
1945 case 0x3: /* SFP, SFP+, SFP-28 */
1946 modinfo->type = ETH_MODULE_SFF_8472;
1947 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
1949 case 0xc: /* QSFP */
1950 case 0xd: /* QSFP+ */
1951 modinfo->type = ETH_MODULE_SFF_8436;
1952 modinfo->eeprom_len = ETH_MODULE_SFF_8436_LEN;
1954 case 0x11: /* QSFP-28 */
1955 modinfo->type = ETH_MODULE_SFF_8636;
1956 modinfo->eeprom_len = ETH_MODULE_SFF_8636_LEN;
1959 DP_ERR(edev, "Unknown transceiver type 0x%x\n", buf[0]);
1966 static int qede_get_module_eeprom(struct net_device *dev,
1967 struct ethtool_eeprom *ee, u8 *data)
1969 struct qede_dev *edev = netdev_priv(dev);
1970 u32 start_addr = ee->offset, size = 0;
1974 /* Read A0 section */
1975 if (ee->offset < ETH_MODULE_SFF_8079_LEN) {
1976 /* Limit transfer size to the A0 section boundary */
1977 if (ee->offset + ee->len > ETH_MODULE_SFF_8079_LEN)
1978 size = ETH_MODULE_SFF_8079_LEN - ee->offset;
1982 rc = edev->ops->common->read_module_eeprom(edev->cdev, buf,
1983 QED_I2C_DEV_ADDR_A0,
1986 DP_ERR(edev, "Failed reading A0 section %d\n", rc);
1994 /* Read A2 section */
1995 if (start_addr >= ETH_MODULE_SFF_8079_LEN &&
1996 start_addr < ETH_MODULE_SFF_8472_LEN) {
1997 size = ee->len - size;
1998 /* Limit transfer size to the A2 section boundary */
1999 if (start_addr + size > ETH_MODULE_SFF_8472_LEN)
2000 size = ETH_MODULE_SFF_8472_LEN - start_addr;
2001 start_addr -= ETH_MODULE_SFF_8079_LEN;
2002 rc = edev->ops->common->read_module_eeprom(edev->cdev, buf,
2003 QED_I2C_DEV_ADDR_A2,
2006 DP_VERBOSE(edev, QED_MSG_DEBUG,
2007 "Failed reading A2 section %d\n", rc);
2015 static int qede_set_dump(struct net_device *dev, struct ethtool_dump *val)
2017 struct qede_dev *edev = netdev_priv(dev);
2020 if (edev->dump_info.cmd == QEDE_DUMP_CMD_NONE) {
2021 if (val->flag > QEDE_DUMP_CMD_MAX) {
2022 DP_ERR(edev, "Invalid command %d\n", val->flag);
2025 edev->dump_info.cmd = val->flag;
2026 edev->dump_info.num_args = 0;
2030 if (edev->dump_info.num_args == QEDE_DUMP_MAX_ARGS) {
2031 DP_ERR(edev, "Arg count = %d\n", edev->dump_info.num_args);
2035 switch (edev->dump_info.cmd) {
2036 case QEDE_DUMP_CMD_NVM_CFG:
2037 edev->dump_info.args[edev->dump_info.num_args] = val->flag;
2038 edev->dump_info.num_args++;
2040 case QEDE_DUMP_CMD_GRCDUMP:
2041 rc = edev->ops->common->set_grc_config(edev->cdev,
2051 static int qede_get_dump_flag(struct net_device *dev,
2052 struct ethtool_dump *dump)
2054 struct qede_dev *edev = netdev_priv(dev);
2056 if (!edev->ops || !edev->ops->common) {
2057 DP_ERR(edev, "Edev ops not populated\n");
2061 dump->version = QEDE_DUMP_VERSION;
2062 switch (edev->dump_info.cmd) {
2063 case QEDE_DUMP_CMD_NVM_CFG:
2064 dump->flag = QEDE_DUMP_CMD_NVM_CFG;
2065 dump->len = edev->ops->common->read_nvm_cfg_len(edev->cdev,
2066 edev->dump_info.args[0]);
2068 case QEDE_DUMP_CMD_GRCDUMP:
2069 dump->flag = QEDE_DUMP_CMD_GRCDUMP;
2070 dump->len = edev->ops->common->dbg_all_data_size(edev->cdev);
2073 DP_ERR(edev, "Invalid cmd = %d\n", edev->dump_info.cmd);
2077 DP_VERBOSE(edev, QED_MSG_DEBUG,
2078 "dump->version = 0x%x dump->flag = %d dump->len = %d\n",
2079 dump->version, dump->flag, dump->len);
2083 static int qede_get_dump_data(struct net_device *dev,
2084 struct ethtool_dump *dump, void *buf)
2086 struct qede_dev *edev = netdev_priv(dev);
2089 if (!edev->ops || !edev->ops->common) {
2090 DP_ERR(edev, "Edev ops not populated\n");
2095 switch (edev->dump_info.cmd) {
2096 case QEDE_DUMP_CMD_NVM_CFG:
2097 if (edev->dump_info.num_args != QEDE_DUMP_NVM_ARG_COUNT) {
2098 DP_ERR(edev, "Arg count = %d required = %d\n",
2099 edev->dump_info.num_args,
2100 QEDE_DUMP_NVM_ARG_COUNT);
2104 rc = edev->ops->common->read_nvm_cfg(edev->cdev, (u8 **)&buf,
2105 edev->dump_info.args[0],
2106 edev->dump_info.args[1]);
2108 case QEDE_DUMP_CMD_GRCDUMP:
2109 memset(buf, 0, dump->len);
2110 rc = edev->ops->common->dbg_all_data(edev->cdev, buf);
2113 DP_ERR(edev, "Invalid cmd = %d\n", edev->dump_info.cmd);
2119 edev->dump_info.cmd = QEDE_DUMP_CMD_NONE;
2120 edev->dump_info.num_args = 0;
2121 memset(edev->dump_info.args, 0, sizeof(edev->dump_info.args));
2126 static const struct ethtool_ops qede_ethtool_ops = {
2127 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
2128 ETHTOOL_COALESCE_STATS_BLOCK_USECS,
2129 .get_link_ksettings = qede_get_link_ksettings,
2130 .set_link_ksettings = qede_set_link_ksettings,
2131 .get_drvinfo = qede_get_drvinfo,
2132 .get_regs_len = qede_get_regs_len,
2133 .get_regs = qede_get_regs,
2134 .get_wol = qede_get_wol,
2135 .set_wol = qede_set_wol,
2136 .get_msglevel = qede_get_msglevel,
2137 .set_msglevel = qede_set_msglevel,
2138 .nway_reset = qede_nway_reset,
2139 .get_link = qede_get_link,
2140 .get_coalesce = qede_get_coalesce,
2141 .set_coalesce = qede_set_coalesce,
2142 .get_ringparam = qede_get_ringparam,
2143 .set_ringparam = qede_set_ringparam,
2144 .get_pauseparam = qede_get_pauseparam,
2145 .set_pauseparam = qede_set_pauseparam,
2146 .get_strings = qede_get_strings,
2147 .set_phys_id = qede_set_phys_id,
2148 .get_ethtool_stats = qede_get_ethtool_stats,
2149 .get_priv_flags = qede_get_priv_flags,
2150 .set_priv_flags = qede_set_priv_flags,
2151 .get_sset_count = qede_get_sset_count,
2152 .get_rxnfc = qede_get_rxnfc,
2153 .set_rxnfc = qede_set_rxnfc,
2154 .get_rxfh_indir_size = qede_get_rxfh_indir_size,
2155 .get_rxfh_key_size = qede_get_rxfh_key_size,
2156 .get_rxfh = qede_get_rxfh,
2157 .set_rxfh = qede_set_rxfh,
2158 .get_ts_info = qede_get_ts_info,
2159 .get_channels = qede_get_channels,
2160 .set_channels = qede_set_channels,
2161 .self_test = qede_self_test,
2162 .get_module_info = qede_get_module_info,
2163 .get_module_eeprom = qede_get_module_eeprom,
2164 .get_eee = qede_get_eee,
2165 .set_eee = qede_set_eee,
2166 .get_fecparam = qede_get_fecparam,
2167 .set_fecparam = qede_set_fecparam,
2168 .get_tunable = qede_get_tunable,
2169 .set_tunable = qede_set_tunable,
2170 .flash_device = qede_flash_device,
2171 .get_dump_flag = qede_get_dump_flag,
2172 .get_dump_data = qede_get_dump_data,
2173 .set_dump = qede_set_dump,
2176 static const struct ethtool_ops qede_vf_ethtool_ops = {
2177 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
2178 ETHTOOL_COALESCE_STATS_BLOCK_USECS,
2179 .get_link_ksettings = qede_get_link_ksettings,
2180 .get_drvinfo = qede_get_drvinfo,
2181 .get_msglevel = qede_get_msglevel,
2182 .set_msglevel = qede_set_msglevel,
2183 .get_link = qede_get_link,
2184 .get_coalesce = qede_get_coalesce,
2185 .set_coalesce = qede_set_coalesce,
2186 .get_ringparam = qede_get_ringparam,
2187 .set_ringparam = qede_set_ringparam,
2188 .get_strings = qede_get_strings,
2189 .get_ethtool_stats = qede_get_ethtool_stats,
2190 .get_priv_flags = qede_get_priv_flags,
2191 .get_sset_count = qede_get_sset_count,
2192 .get_rxnfc = qede_get_rxnfc,
2193 .set_rxnfc = qede_set_rxnfc,
2194 .get_rxfh_indir_size = qede_get_rxfh_indir_size,
2195 .get_rxfh_key_size = qede_get_rxfh_key_size,
2196 .get_rxfh = qede_get_rxfh,
2197 .set_rxfh = qede_set_rxfh,
2198 .get_channels = qede_get_channels,
2199 .set_channels = qede_set_channels,
2200 .get_tunable = qede_get_tunable,
2201 .set_tunable = qede_set_tunable,
2204 void qede_set_ethtool_ops(struct net_device *dev)
2206 struct qede_dev *edev = netdev_priv(dev);
2209 dev->ethtool_ops = &qede_vf_ethtool_ops;
2211 dev->ethtool_ops = &qede_ethtool_ops;