1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018, Intel Corporation. */
4 /* ethtool support for ice */
10 #include "ice_dcb_lib.h"
11 #include <net/dcbnl.h>
14 char stat_string[ETH_GSTRING_LEN];
19 #define ICE_STAT(_type, _name, _stat) { \
20 .stat_string = _name, \
21 .sizeof_stat = sizeof_field(_type, _stat), \
22 .stat_offset = offsetof(_type, _stat) \
25 #define ICE_VSI_STAT(_name, _stat) \
26 ICE_STAT(struct ice_vsi, _name, _stat)
27 #define ICE_PF_STAT(_name, _stat) \
28 ICE_STAT(struct ice_pf, _name, _stat)
30 static int ice_q_stats_len(struct net_device *netdev)
32 struct ice_netdev_priv *np = netdev_priv(netdev);
34 return ((np->vsi->alloc_txq + np->vsi->alloc_rxq) *
35 (sizeof(struct ice_q_stats) / sizeof(u64)));
38 #define ICE_PF_STATS_LEN ARRAY_SIZE(ice_gstrings_pf_stats)
39 #define ICE_VSI_STATS_LEN ARRAY_SIZE(ice_gstrings_vsi_stats)
41 #define ICE_PFC_STATS_LEN ( \
42 (sizeof_field(struct ice_pf, stats.priority_xoff_rx) + \
43 sizeof_field(struct ice_pf, stats.priority_xon_rx) + \
44 sizeof_field(struct ice_pf, stats.priority_xoff_tx) + \
45 sizeof_field(struct ice_pf, stats.priority_xon_tx)) \
47 #define ICE_ALL_STATS_LEN(n) (ICE_PF_STATS_LEN + ICE_PFC_STATS_LEN + \
48 ICE_VSI_STATS_LEN + ice_q_stats_len(n))
50 static const struct ice_stats ice_gstrings_vsi_stats[] = {
51 ICE_VSI_STAT("rx_unicast", eth_stats.rx_unicast),
52 ICE_VSI_STAT("tx_unicast", eth_stats.tx_unicast),
53 ICE_VSI_STAT("rx_multicast", eth_stats.rx_multicast),
54 ICE_VSI_STAT("tx_multicast", eth_stats.tx_multicast),
55 ICE_VSI_STAT("rx_broadcast", eth_stats.rx_broadcast),
56 ICE_VSI_STAT("tx_broadcast", eth_stats.tx_broadcast),
57 ICE_VSI_STAT("rx_bytes", eth_stats.rx_bytes),
58 ICE_VSI_STAT("tx_bytes", eth_stats.tx_bytes),
59 ICE_VSI_STAT("rx_dropped", eth_stats.rx_discards),
60 ICE_VSI_STAT("rx_unknown_protocol", eth_stats.rx_unknown_protocol),
61 ICE_VSI_STAT("rx_alloc_fail", rx_buf_failed),
62 ICE_VSI_STAT("rx_pg_alloc_fail", rx_page_failed),
63 ICE_VSI_STAT("tx_errors", eth_stats.tx_errors),
64 ICE_VSI_STAT("tx_linearize", tx_linearize),
65 ICE_VSI_STAT("tx_busy", tx_busy),
66 ICE_VSI_STAT("tx_restart", tx_restart),
69 enum ice_ethtool_test_id {
77 static const char ice_gstrings_test[][ETH_GSTRING_LEN] = {
78 "Register test (offline)",
79 "EEPROM test (offline)",
80 "Interrupt test (offline)",
81 "Loopback test (offline)",
82 "Link test (on/offline)",
85 #define ICE_TEST_LEN (sizeof(ice_gstrings_test) / ETH_GSTRING_LEN)
87 /* These PF_STATs might look like duplicates of some NETDEV_STATs,
88 * but they aren't. This device is capable of supporting multiple
89 * VSIs/netdevs on a single PF. The NETDEV_STATs are for individual
90 * netdevs whereas the PF_STATs are for the physical function that's
91 * hosting these netdevs.
93 * The PF_STATs are appended to the netdev stats only when ethtool -S
94 * is queried on the base PF netdev.
96 static const struct ice_stats ice_gstrings_pf_stats[] = {
97 ICE_PF_STAT("rx_bytes.nic", stats.eth.rx_bytes),
98 ICE_PF_STAT("tx_bytes.nic", stats.eth.tx_bytes),
99 ICE_PF_STAT("rx_unicast.nic", stats.eth.rx_unicast),
100 ICE_PF_STAT("tx_unicast.nic", stats.eth.tx_unicast),
101 ICE_PF_STAT("rx_multicast.nic", stats.eth.rx_multicast),
102 ICE_PF_STAT("tx_multicast.nic", stats.eth.tx_multicast),
103 ICE_PF_STAT("rx_broadcast.nic", stats.eth.rx_broadcast),
104 ICE_PF_STAT("tx_broadcast.nic", stats.eth.tx_broadcast),
105 ICE_PF_STAT("tx_errors.nic", stats.eth.tx_errors),
106 ICE_PF_STAT("tx_timeout.nic", tx_timeout_count),
107 ICE_PF_STAT("rx_size_64.nic", stats.rx_size_64),
108 ICE_PF_STAT("tx_size_64.nic", stats.tx_size_64),
109 ICE_PF_STAT("rx_size_127.nic", stats.rx_size_127),
110 ICE_PF_STAT("tx_size_127.nic", stats.tx_size_127),
111 ICE_PF_STAT("rx_size_255.nic", stats.rx_size_255),
112 ICE_PF_STAT("tx_size_255.nic", stats.tx_size_255),
113 ICE_PF_STAT("rx_size_511.nic", stats.rx_size_511),
114 ICE_PF_STAT("tx_size_511.nic", stats.tx_size_511),
115 ICE_PF_STAT("rx_size_1023.nic", stats.rx_size_1023),
116 ICE_PF_STAT("tx_size_1023.nic", stats.tx_size_1023),
117 ICE_PF_STAT("rx_size_1522.nic", stats.rx_size_1522),
118 ICE_PF_STAT("tx_size_1522.nic", stats.tx_size_1522),
119 ICE_PF_STAT("rx_size_big.nic", stats.rx_size_big),
120 ICE_PF_STAT("tx_size_big.nic", stats.tx_size_big),
121 ICE_PF_STAT("link_xon_rx.nic", stats.link_xon_rx),
122 ICE_PF_STAT("link_xon_tx.nic", stats.link_xon_tx),
123 ICE_PF_STAT("link_xoff_rx.nic", stats.link_xoff_rx),
124 ICE_PF_STAT("link_xoff_tx.nic", stats.link_xoff_tx),
125 ICE_PF_STAT("tx_dropped_link_down.nic", stats.tx_dropped_link_down),
126 ICE_PF_STAT("rx_undersize.nic", stats.rx_undersize),
127 ICE_PF_STAT("rx_fragments.nic", stats.rx_fragments),
128 ICE_PF_STAT("rx_oversize.nic", stats.rx_oversize),
129 ICE_PF_STAT("rx_jabber.nic", stats.rx_jabber),
130 ICE_PF_STAT("rx_csum_bad.nic", hw_csum_rx_error),
131 ICE_PF_STAT("rx_length_errors.nic", stats.rx_len_errors),
132 ICE_PF_STAT("rx_dropped.nic", stats.eth.rx_discards),
133 ICE_PF_STAT("rx_crc_errors.nic", stats.crc_errors),
134 ICE_PF_STAT("illegal_bytes.nic", stats.illegal_bytes),
135 ICE_PF_STAT("mac_local_faults.nic", stats.mac_local_faults),
136 ICE_PF_STAT("mac_remote_faults.nic", stats.mac_remote_faults),
137 ICE_PF_STAT("fdir_sb_match.nic", stats.fd_sb_match),
138 ICE_PF_STAT("fdir_sb_status.nic", stats.fd_sb_status),
141 static const u32 ice_regs_dump_list[] = {
151 struct ice_priv_flag {
152 char name[ETH_GSTRING_LEN];
153 u32 bitno; /* bit position in pf->flags */
156 #define ICE_PRIV_FLAG(_name, _bitno) { \
161 static const struct ice_priv_flag ice_gstrings_priv_flags[] = {
162 ICE_PRIV_FLAG("link-down-on-close", ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA),
163 ICE_PRIV_FLAG("fw-lldp-agent", ICE_FLAG_FW_LLDP_AGENT),
164 ICE_PRIV_FLAG("vf-true-promisc-support",
165 ICE_FLAG_VF_TRUE_PROMISC_ENA),
166 ICE_PRIV_FLAG("mdd-auto-reset-vf", ICE_FLAG_MDD_AUTO_RESET_VF),
167 ICE_PRIV_FLAG("legacy-rx", ICE_FLAG_LEGACY_RX),
170 #define ICE_PRIV_FLAG_ARRAY_SIZE ARRAY_SIZE(ice_gstrings_priv_flags)
173 ice_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
175 struct ice_netdev_priv *np = netdev_priv(netdev);
176 struct ice_vsi *vsi = np->vsi;
177 struct ice_pf *pf = vsi->back;
178 struct ice_hw *hw = &pf->hw;
179 struct ice_orom_info *orom;
180 struct ice_nvm_info *nvm;
182 nvm = &hw->flash.nvm;
183 orom = &hw->flash.orom;
185 strscpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver));
187 /* Display NVM version (from which the firmware version can be
188 * determined) which contains more pertinent information.
190 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
191 "%x.%02x 0x%x %d.%d.%d", nvm->major, nvm->minor,
192 nvm->eetrack, orom->major, orom->build, orom->patch);
194 strscpy(drvinfo->bus_info, pci_name(pf->pdev),
195 sizeof(drvinfo->bus_info));
196 drvinfo->n_priv_flags = ICE_PRIV_FLAG_ARRAY_SIZE;
199 static int ice_get_regs_len(struct net_device __always_unused *netdev)
201 return sizeof(ice_regs_dump_list);
205 ice_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p)
207 struct ice_netdev_priv *np = netdev_priv(netdev);
208 struct ice_pf *pf = np->vsi->back;
209 struct ice_hw *hw = &pf->hw;
210 u32 *regs_buf = (u32 *)p;
215 for (i = 0; i < ARRAY_SIZE(ice_regs_dump_list); ++i)
216 regs_buf[i] = rd32(hw, ice_regs_dump_list[i]);
219 static u32 ice_get_msglevel(struct net_device *netdev)
221 struct ice_netdev_priv *np = netdev_priv(netdev);
222 struct ice_pf *pf = np->vsi->back;
224 #ifndef CONFIG_DYNAMIC_DEBUG
225 if (pf->hw.debug_mask)
226 netdev_info(netdev, "hw debug_mask: 0x%llX\n",
228 #endif /* !CONFIG_DYNAMIC_DEBUG */
230 return pf->msg_enable;
233 static void ice_set_msglevel(struct net_device *netdev, u32 data)
235 struct ice_netdev_priv *np = netdev_priv(netdev);
236 struct ice_pf *pf = np->vsi->back;
238 #ifndef CONFIG_DYNAMIC_DEBUG
239 if (ICE_DBG_USER & data)
240 pf->hw.debug_mask = data;
242 pf->msg_enable = data;
244 pf->msg_enable = data;
245 #endif /* !CONFIG_DYNAMIC_DEBUG */
248 static int ice_get_eeprom_len(struct net_device *netdev)
250 struct ice_netdev_priv *np = netdev_priv(netdev);
251 struct ice_pf *pf = np->vsi->back;
253 return (int)pf->hw.flash.flash_size;
257 ice_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,
260 struct ice_netdev_priv *np = netdev_priv(netdev);
261 struct ice_vsi *vsi = np->vsi;
262 struct ice_pf *pf = vsi->back;
263 struct ice_hw *hw = &pf->hw;
264 enum ice_status status;
269 dev = ice_pf_to_dev(pf);
271 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
272 netdev_dbg(netdev, "GEEPROM cmd 0x%08x, offset 0x%08x, len 0x%08x\n",
273 eeprom->cmd, eeprom->offset, eeprom->len);
275 buf = kzalloc(eeprom->len, GFP_KERNEL);
279 status = ice_acquire_nvm(hw, ICE_RES_READ);
281 dev_err(dev, "ice_acquire_nvm failed, err %s aq_err %s\n",
282 ice_stat_str(status),
283 ice_aq_str(hw->adminq.sq_last_status));
288 status = ice_read_flat_nvm(hw, eeprom->offset, &eeprom->len, buf,
291 dev_err(dev, "ice_read_flat_nvm failed, err %s aq_err %s\n",
292 ice_stat_str(status),
293 ice_aq_str(hw->adminq.sq_last_status));
298 memcpy(bytes, buf, eeprom->len);
307 * ice_active_vfs - check if there are any active VFs
308 * @pf: board private structure
310 * Returns true if an active VF is found, otherwise returns false
312 static bool ice_active_vfs(struct ice_pf *pf)
316 ice_for_each_vf(pf, i) {
317 struct ice_vf *vf = &pf->vf[i];
319 if (test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
327 * ice_link_test - perform a link test on a given net_device
328 * @netdev: network interface device structure
330 * This function performs one of the self-tests required by ethtool.
331 * Returns 0 on success, non-zero on failure.
333 static u64 ice_link_test(struct net_device *netdev)
335 struct ice_netdev_priv *np = netdev_priv(netdev);
336 enum ice_status status;
337 bool link_up = false;
339 netdev_info(netdev, "link test\n");
340 status = ice_get_link_status(np->vsi->port_info, &link_up);
342 netdev_err(netdev, "link query error, status = %s\n",
343 ice_stat_str(status));
354 * ice_eeprom_test - perform an EEPROM test on a given net_device
355 * @netdev: network interface device structure
357 * This function performs one of the self-tests required by ethtool.
358 * Returns 0 on success, non-zero on failure.
360 static u64 ice_eeprom_test(struct net_device *netdev)
362 struct ice_netdev_priv *np = netdev_priv(netdev);
363 struct ice_pf *pf = np->vsi->back;
365 netdev_info(netdev, "EEPROM test\n");
366 return !!(ice_nvm_validate_checksum(&pf->hw));
370 * ice_reg_pattern_test
371 * @hw: pointer to the HW struct
372 * @reg: reg to be tested
373 * @mask: bits to be touched
375 static int ice_reg_pattern_test(struct ice_hw *hw, u32 reg, u32 mask)
377 struct ice_pf *pf = (struct ice_pf *)hw->back;
378 struct device *dev = ice_pf_to_dev(pf);
379 static const u32 patterns[] = {
380 0x5A5A5A5A, 0xA5A5A5A5,
381 0x00000000, 0xFFFFFFFF
386 orig_val = rd32(hw, reg);
387 for (i = 0; i < ARRAY_SIZE(patterns); ++i) {
388 u32 pattern = patterns[i] & mask;
390 wr32(hw, reg, pattern);
394 dev_err(dev, "%s: reg pattern test failed - reg 0x%08x pat 0x%08x val 0x%08x\n"
395 , __func__, reg, pattern, val);
399 wr32(hw, reg, orig_val);
401 if (val != orig_val) {
402 dev_err(dev, "%s: reg restore test failed - reg 0x%08x orig 0x%08x val 0x%08x\n"
403 , __func__, reg, orig_val, val);
411 * ice_reg_test - perform a register test on a given net_device
412 * @netdev: network interface device structure
414 * This function performs one of the self-tests required by ethtool.
415 * Returns 0 on success, non-zero on failure.
417 static u64 ice_reg_test(struct net_device *netdev)
419 struct ice_netdev_priv *np = netdev_priv(netdev);
420 struct ice_hw *hw = np->vsi->port_info->hw;
421 u32 int_elements = hw->func_caps.common_cap.num_msix_vectors ?
422 hw->func_caps.common_cap.num_msix_vectors - 1 : 1;
423 struct ice_diag_reg_test_info {
429 {GLINT_ITR(0, 0), 0x00000fff, int_elements,
430 GLINT_ITR(0, 1) - GLINT_ITR(0, 0)},
431 {GLINT_ITR(1, 0), 0x00000fff, int_elements,
432 GLINT_ITR(1, 1) - GLINT_ITR(1, 0)},
433 {GLINT_ITR(0, 0), 0x00000fff, int_elements,
434 GLINT_ITR(2, 1) - GLINT_ITR(2, 0)},
435 {GLINT_CTL, 0xffff0001, 1, 0}
439 netdev_dbg(netdev, "Register test\n");
440 for (i = 0; i < ARRAY_SIZE(ice_reg_list); ++i) {
443 for (j = 0; j < ice_reg_list[i].elem_num; ++j) {
444 u32 mask = ice_reg_list[i].mask;
445 u32 reg = ice_reg_list[i].address +
446 (j * ice_reg_list[i].elem_size);
448 /* bail on failure (non-zero return) */
449 if (ice_reg_pattern_test(hw, reg, mask))
458 * ice_lbtest_prepare_rings - configure Tx/Rx test rings
459 * @vsi: pointer to the VSI structure
461 * Function configures rings of a VSI for loopback test without
462 * enabling interrupts or informing the kernel about new queues.
464 * Returns 0 on success, negative on failure.
466 static int ice_lbtest_prepare_rings(struct ice_vsi *vsi)
470 status = ice_vsi_setup_tx_rings(vsi);
472 goto err_setup_tx_ring;
474 status = ice_vsi_setup_rx_rings(vsi);
476 goto err_setup_rx_ring;
478 status = ice_vsi_cfg(vsi);
480 goto err_setup_rx_ring;
482 status = ice_vsi_start_all_rx_rings(vsi);
484 goto err_start_rx_ring;
489 ice_vsi_free_rx_rings(vsi);
491 ice_vsi_stop_lan_tx_rings(vsi, ICE_NO_RESET, 0);
493 ice_vsi_free_tx_rings(vsi);
499 * ice_lbtest_disable_rings - disable Tx/Rx test rings after loopback test
500 * @vsi: pointer to the VSI structure
502 * Function stops and frees VSI rings after a loopback test.
503 * Returns 0 on success, negative on failure.
505 static int ice_lbtest_disable_rings(struct ice_vsi *vsi)
509 status = ice_vsi_stop_lan_tx_rings(vsi, ICE_NO_RESET, 0);
511 netdev_err(vsi->netdev, "Failed to stop Tx rings, VSI %d error %d\n",
512 vsi->vsi_num, status);
514 status = ice_vsi_stop_all_rx_rings(vsi);
516 netdev_err(vsi->netdev, "Failed to stop Rx rings, VSI %d error %d\n",
517 vsi->vsi_num, status);
519 ice_vsi_free_tx_rings(vsi);
520 ice_vsi_free_rx_rings(vsi);
526 * ice_lbtest_create_frame - create test packet
527 * @pf: pointer to the PF structure
528 * @ret_data: allocated frame buffer
529 * @size: size of the packet data
531 * Function allocates a frame with a test pattern on specific offsets.
532 * Returns 0 on success, non-zero on failure.
534 static int ice_lbtest_create_frame(struct ice_pf *pf, u8 **ret_data, u16 size)
541 data = devm_kzalloc(ice_pf_to_dev(pf), size, GFP_KERNEL);
545 /* Since the ethernet test frame should always be at least
546 * 64 bytes long, fill some octets in the payload with test data.
548 memset(data, 0xFF, size);
560 * ice_lbtest_check_frame - verify received loopback frame
561 * @frame: pointer to the raw packet data
563 * Function verifies received test frame with a pattern.
564 * Returns true if frame matches the pattern, false otherwise.
566 static bool ice_lbtest_check_frame(u8 *frame)
568 /* Validate bytes of a frame under offsets chosen earlier */
569 if (frame[32] == 0xDE &&
580 * ice_diag_send - send test frames to the test ring
581 * @tx_ring: pointer to the transmit ring
582 * @data: pointer to the raw packet data
583 * @size: size of the packet to send
585 * Function sends loopback packets on a test Tx ring.
587 static int ice_diag_send(struct ice_ring *tx_ring, u8 *data, u16 size)
589 struct ice_tx_desc *tx_desc;
590 struct ice_tx_buf *tx_buf;
594 tx_desc = ICE_TX_DESC(tx_ring, tx_ring->next_to_use);
595 tx_buf = &tx_ring->tx_buf[tx_ring->next_to_use];
597 dma = dma_map_single(tx_ring->dev, data, size, DMA_TO_DEVICE);
598 if (dma_mapping_error(tx_ring->dev, dma))
601 tx_desc->buf_addr = cpu_to_le64(dma);
603 /* These flags are required for a descriptor to be pushed out */
604 td_cmd = (u64)(ICE_TX_DESC_CMD_EOP | ICE_TX_DESC_CMD_RS);
605 tx_desc->cmd_type_offset_bsz =
606 cpu_to_le64(ICE_TX_DESC_DTYPE_DATA |
607 (td_cmd << ICE_TXD_QW1_CMD_S) |
608 ((u64)0 << ICE_TXD_QW1_OFFSET_S) |
609 ((u64)size << ICE_TXD_QW1_TX_BUF_SZ_S) |
610 ((u64)0 << ICE_TXD_QW1_L2TAG1_S));
612 tx_buf->next_to_watch = tx_desc;
614 /* Force memory write to complete before letting h/w know
615 * there are new descriptors to fetch.
619 tx_ring->next_to_use++;
620 if (tx_ring->next_to_use >= tx_ring->count)
621 tx_ring->next_to_use = 0;
623 writel_relaxed(tx_ring->next_to_use, tx_ring->tail);
625 /* Wait until the packets get transmitted to the receive queue. */
626 usleep_range(1000, 2000);
627 dma_unmap_single(tx_ring->dev, dma, size, DMA_TO_DEVICE);
632 #define ICE_LB_FRAME_SIZE 64
634 * ice_lbtest_receive_frames - receive and verify test frames
635 * @rx_ring: pointer to the receive ring
637 * Function receives loopback packets and verify their correctness.
638 * Returns number of received valid frames.
640 static int ice_lbtest_receive_frames(struct ice_ring *rx_ring)
642 struct ice_rx_buf *rx_buf;
648 for (i = 0; i < rx_ring->count; i++) {
649 union ice_32b_rx_flex_desc *rx_desc;
651 rx_desc = ICE_RX_DESC(rx_ring, i);
653 if (!(rx_desc->wb.status_error0 &
654 cpu_to_le16(ICE_TX_DESC_CMD_EOP | ICE_TX_DESC_CMD_RS)))
657 rx_buf = &rx_ring->rx_buf[i];
658 received_buf = page_address(rx_buf->page) + rx_buf->page_offset;
660 if (ice_lbtest_check_frame(received_buf))
668 * ice_loopback_test - perform a loopback test on a given net_device
669 * @netdev: network interface device structure
671 * This function performs one of the self-tests required by ethtool.
672 * Returns 0 on success, non-zero on failure.
674 static u64 ice_loopback_test(struct net_device *netdev)
676 struct ice_netdev_priv *np = netdev_priv(netdev);
677 struct ice_vsi *orig_vsi = np->vsi, *test_vsi;
678 struct ice_pf *pf = orig_vsi->back;
679 struct ice_ring *tx_ring, *rx_ring;
680 u8 broadcast[ETH_ALEN], ret = 0;
681 int num_frames, valid_frames;
686 dev = ice_pf_to_dev(pf);
687 netdev_info(netdev, "loopback test\n");
689 test_vsi = ice_lb_vsi_setup(pf, pf->hw.port_info);
691 netdev_err(netdev, "Failed to create a VSI for the loopback test\n");
695 test_vsi->netdev = netdev;
696 tx_ring = test_vsi->tx_rings[0];
697 rx_ring = test_vsi->rx_rings[0];
699 if (ice_lbtest_prepare_rings(test_vsi)) {
701 goto lbtest_vsi_close;
704 if (ice_alloc_rx_bufs(rx_ring, rx_ring->count)) {
706 goto lbtest_rings_dis;
709 /* Enable MAC loopback in firmware */
710 if (ice_aq_set_mac_loopback(&pf->hw, true, NULL)) {
715 /* Test VSI needs to receive broadcast packets */
716 eth_broadcast_addr(broadcast);
717 if (ice_fltr_add_mac(test_vsi, broadcast, ICE_FWD_TO_VSI)) {
722 if (ice_lbtest_create_frame(pf, &tx_frame, ICE_LB_FRAME_SIZE)) {
724 goto remove_mac_filters;
727 num_frames = min_t(int, tx_ring->count, 32);
728 for (i = 0; i < num_frames; i++) {
729 if (ice_diag_send(tx_ring, tx_frame, ICE_LB_FRAME_SIZE)) {
731 goto lbtest_free_frame;
735 valid_frames = ice_lbtest_receive_frames(rx_ring);
738 else if (valid_frames != num_frames)
742 devm_kfree(dev, tx_frame);
744 if (ice_fltr_remove_mac(test_vsi, broadcast, ICE_FWD_TO_VSI))
745 netdev_err(netdev, "Could not remove MAC filter for the test VSI\n");
747 /* Disable MAC loopback after the test is completed. */
748 if (ice_aq_set_mac_loopback(&pf->hw, false, NULL))
749 netdev_err(netdev, "Could not disable MAC loopback\n");
751 if (ice_lbtest_disable_rings(test_vsi))
752 netdev_err(netdev, "Could not disable test rings\n");
754 test_vsi->netdev = NULL;
755 if (ice_vsi_release(test_vsi))
756 netdev_err(netdev, "Failed to remove the test VSI\n");
762 * ice_intr_test - perform an interrupt test on a given net_device
763 * @netdev: network interface device structure
765 * This function performs one of the self-tests required by ethtool.
766 * Returns 0 on success, non-zero on failure.
768 static u64 ice_intr_test(struct net_device *netdev)
770 struct ice_netdev_priv *np = netdev_priv(netdev);
771 struct ice_pf *pf = np->vsi->back;
772 u16 swic_old = pf->sw_int_count;
774 netdev_info(netdev, "interrupt test\n");
776 wr32(&pf->hw, GLINT_DYN_CTL(pf->oicr_idx),
777 GLINT_DYN_CTL_SW_ITR_INDX_M |
778 GLINT_DYN_CTL_INTENA_MSK_M |
779 GLINT_DYN_CTL_SWINT_TRIG_M);
781 usleep_range(1000, 2000);
782 return (swic_old == pf->sw_int_count);
786 * ice_self_test - handler function for performing a self-test by ethtool
787 * @netdev: network interface device structure
788 * @eth_test: ethtool_test structure
789 * @data: required by ethtool.self_test
791 * This function is called after invoking 'ethtool -t devname' command where
792 * devname is the name of the network device on which ethtool should operate.
793 * It performs a set of self-tests to check if a device works properly.
796 ice_self_test(struct net_device *netdev, struct ethtool_test *eth_test,
799 struct ice_netdev_priv *np = netdev_priv(netdev);
800 bool if_running = netif_running(netdev);
801 struct ice_pf *pf = np->vsi->back;
804 dev = ice_pf_to_dev(pf);
806 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
807 netdev_info(netdev, "offline testing starting\n");
809 set_bit(ICE_TESTING, pf->state);
811 if (ice_active_vfs(pf)) {
812 dev_warn(dev, "Please take active VFs and Netqueues offline and restart the adapter before running NIC diagnostics\n");
813 data[ICE_ETH_TEST_REG] = 1;
814 data[ICE_ETH_TEST_EEPROM] = 1;
815 data[ICE_ETH_TEST_INTR] = 1;
816 data[ICE_ETH_TEST_LOOP] = 1;
817 data[ICE_ETH_TEST_LINK] = 1;
818 eth_test->flags |= ETH_TEST_FL_FAILED;
819 clear_bit(ICE_TESTING, pf->state);
822 /* If the device is online then take it offline */
824 /* indicate we're in test mode */
827 data[ICE_ETH_TEST_LINK] = ice_link_test(netdev);
828 data[ICE_ETH_TEST_EEPROM] = ice_eeprom_test(netdev);
829 data[ICE_ETH_TEST_INTR] = ice_intr_test(netdev);
830 data[ICE_ETH_TEST_LOOP] = ice_loopback_test(netdev);
831 data[ICE_ETH_TEST_REG] = ice_reg_test(netdev);
833 if (data[ICE_ETH_TEST_LINK] ||
834 data[ICE_ETH_TEST_EEPROM] ||
835 data[ICE_ETH_TEST_LOOP] ||
836 data[ICE_ETH_TEST_INTR] ||
837 data[ICE_ETH_TEST_REG])
838 eth_test->flags |= ETH_TEST_FL_FAILED;
840 clear_bit(ICE_TESTING, pf->state);
843 int status = ice_open(netdev);
846 dev_err(dev, "Could not open device %s, err %d\n",
847 pf->int_name, status);
852 netdev_info(netdev, "online testing starting\n");
854 data[ICE_ETH_TEST_LINK] = ice_link_test(netdev);
855 if (data[ICE_ETH_TEST_LINK])
856 eth_test->flags |= ETH_TEST_FL_FAILED;
858 /* Offline only tests, not run in online; pass by default */
859 data[ICE_ETH_TEST_REG] = 0;
860 data[ICE_ETH_TEST_EEPROM] = 0;
861 data[ICE_ETH_TEST_INTR] = 0;
862 data[ICE_ETH_TEST_LOOP] = 0;
866 netdev_info(netdev, "testing finished\n");
869 static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
871 struct ice_netdev_priv *np = netdev_priv(netdev);
872 struct ice_vsi *vsi = np->vsi;
878 for (i = 0; i < ICE_VSI_STATS_LEN; i++)
880 ice_gstrings_vsi_stats[i].stat_string);
882 ice_for_each_alloc_txq(vsi, i) {
883 ethtool_sprintf(&p, "tx_queue_%u_packets", i);
884 ethtool_sprintf(&p, "tx_queue_%u_bytes", i);
887 ice_for_each_alloc_rxq(vsi, i) {
888 ethtool_sprintf(&p, "rx_queue_%u_packets", i);
889 ethtool_sprintf(&p, "rx_queue_%u_bytes", i);
892 if (vsi->type != ICE_VSI_PF)
895 for (i = 0; i < ICE_PF_STATS_LEN; i++)
897 ice_gstrings_pf_stats[i].stat_string);
899 for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
900 ethtool_sprintf(&p, "tx_priority_%u_xon.nic", i);
901 ethtool_sprintf(&p, "tx_priority_%u_xoff.nic", i);
903 for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
904 ethtool_sprintf(&p, "rx_priority_%u_xon.nic", i);
905 ethtool_sprintf(&p, "rx_priority_%u_xoff.nic", i);
909 memcpy(data, ice_gstrings_test, ICE_TEST_LEN * ETH_GSTRING_LEN);
911 case ETH_SS_PRIV_FLAGS:
912 for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++)
913 ethtool_sprintf(&p, ice_gstrings_priv_flags[i].name);
921 ice_set_phys_id(struct net_device *netdev, enum ethtool_phys_id_state state)
923 struct ice_netdev_priv *np = netdev_priv(netdev);
927 case ETHTOOL_ID_ACTIVE:
930 case ETHTOOL_ID_INACTIVE:
937 if (ice_aq_set_port_id_led(np->vsi->port_info, !led_active, NULL))
944 * ice_set_fec_cfg - Set link FEC options
945 * @netdev: network interface device structure
946 * @req_fec: FEC mode to configure
948 static int ice_set_fec_cfg(struct net_device *netdev, enum ice_fec_mode req_fec)
950 struct ice_netdev_priv *np = netdev_priv(netdev);
951 struct ice_aqc_set_phy_cfg_data config = { 0 };
952 struct ice_vsi *vsi = np->vsi;
953 struct ice_port_info *pi;
959 /* Changing the FEC parameters is not supported if not the PF VSI */
960 if (vsi->type != ICE_VSI_PF) {
961 netdev_info(netdev, "Changing FEC parameters only supported for PF VSI\n");
965 /* Proceed only if requesting different FEC mode */
966 if (pi->phy.curr_user_fec_req == req_fec)
969 /* Copy the current user PHY configuration. The current user PHY
970 * configuration is initialized during probe from PHY capabilities
971 * software mode, and updated on set PHY configuration.
973 memcpy(&config, &pi->phy.curr_user_phy_cfg, sizeof(config));
975 ice_cfg_phy_fec(pi, &config, req_fec);
976 config.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
978 if (ice_aq_set_phy_cfg(pi->hw, pi, &config, NULL))
981 /* Save requested FEC config */
982 pi->phy.curr_user_fec_req = req_fec;
988 * ice_set_fecparam - Set FEC link options
989 * @netdev: network interface device structure
990 * @fecparam: Ethtool structure to retrieve FEC parameters
993 ice_set_fecparam(struct net_device *netdev, struct ethtool_fecparam *fecparam)
995 struct ice_netdev_priv *np = netdev_priv(netdev);
996 struct ice_vsi *vsi = np->vsi;
997 enum ice_fec_mode fec;
999 switch (fecparam->fec) {
1000 case ETHTOOL_FEC_AUTO:
1003 case ETHTOOL_FEC_RS:
1006 case ETHTOOL_FEC_BASER:
1007 fec = ICE_FEC_BASER;
1009 case ETHTOOL_FEC_OFF:
1010 case ETHTOOL_FEC_NONE:
1014 dev_warn(ice_pf_to_dev(vsi->back), "Unsupported FEC mode: %d\n",
1019 return ice_set_fec_cfg(netdev, fec);
1023 * ice_get_fecparam - Get link FEC options
1024 * @netdev: network interface device structure
1025 * @fecparam: Ethtool structure to retrieve FEC parameters
1028 ice_get_fecparam(struct net_device *netdev, struct ethtool_fecparam *fecparam)
1030 struct ice_netdev_priv *np = netdev_priv(netdev);
1031 struct ice_aqc_get_phy_caps_data *caps;
1032 struct ice_link_status *link_info;
1033 struct ice_vsi *vsi = np->vsi;
1034 struct ice_port_info *pi;
1035 enum ice_status status;
1038 pi = vsi->port_info;
1042 link_info = &pi->phy.link_info;
1044 /* Set FEC mode based on negotiated link info */
1045 switch (link_info->fec_info) {
1046 case ICE_AQ_LINK_25G_KR_FEC_EN:
1047 fecparam->active_fec = ETHTOOL_FEC_BASER;
1049 case ICE_AQ_LINK_25G_RS_528_FEC_EN:
1050 case ICE_AQ_LINK_25G_RS_544_FEC_EN:
1051 fecparam->active_fec = ETHTOOL_FEC_RS;
1054 fecparam->active_fec = ETHTOOL_FEC_OFF;
1058 caps = kzalloc(sizeof(*caps), GFP_KERNEL);
1062 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP_MEDIA,
1069 /* Set supported/configured FEC modes based on PHY capability */
1070 if (caps->caps & ICE_AQC_PHY_EN_AUTO_FEC)
1071 fecparam->fec |= ETHTOOL_FEC_AUTO;
1072 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN ||
1073 caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ ||
1074 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN ||
1075 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ)
1076 fecparam->fec |= ETHTOOL_FEC_BASER;
1077 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ ||
1078 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ ||
1079 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN)
1080 fecparam->fec |= ETHTOOL_FEC_RS;
1081 if (caps->link_fec_options == 0)
1082 fecparam->fec |= ETHTOOL_FEC_OFF;
1090 * ice_nway_reset - restart autonegotiation
1091 * @netdev: network interface device structure
1093 static int ice_nway_reset(struct net_device *netdev)
1095 struct ice_netdev_priv *np = netdev_priv(netdev);
1096 struct ice_vsi *vsi = np->vsi;
1099 /* If VSI state is up, then restart autoneg with link up */
1100 if (!test_bit(ICE_DOWN, vsi->back->state))
1101 err = ice_set_link(vsi, true);
1103 err = ice_set_link(vsi, false);
1109 * ice_get_priv_flags - report device private flags
1110 * @netdev: network interface device structure
1112 * The get string set count and the string set should be matched for each
1113 * flag returned. Add new strings for each flag to the ice_gstrings_priv_flags
1116 * Returns a u32 bitmap of flags.
1118 static u32 ice_get_priv_flags(struct net_device *netdev)
1120 struct ice_netdev_priv *np = netdev_priv(netdev);
1121 struct ice_vsi *vsi = np->vsi;
1122 struct ice_pf *pf = vsi->back;
1123 u32 i, ret_flags = 0;
1125 for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) {
1126 const struct ice_priv_flag *priv_flag;
1128 priv_flag = &ice_gstrings_priv_flags[i];
1130 if (test_bit(priv_flag->bitno, pf->flags))
1131 ret_flags |= BIT(i);
1138 * ice_set_priv_flags - set private flags
1139 * @netdev: network interface device structure
1140 * @flags: bit flags to be set
1142 static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
1144 struct ice_netdev_priv *np = netdev_priv(netdev);
1145 DECLARE_BITMAP(change_flags, ICE_PF_FLAGS_NBITS);
1146 DECLARE_BITMAP(orig_flags, ICE_PF_FLAGS_NBITS);
1147 struct ice_vsi *vsi = np->vsi;
1148 struct ice_pf *pf = vsi->back;
1153 if (flags > BIT(ICE_PRIV_FLAG_ARRAY_SIZE))
1156 dev = ice_pf_to_dev(pf);
1157 set_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags);
1159 bitmap_copy(orig_flags, pf->flags, ICE_PF_FLAGS_NBITS);
1160 for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) {
1161 const struct ice_priv_flag *priv_flag;
1163 priv_flag = &ice_gstrings_priv_flags[i];
1166 set_bit(priv_flag->bitno, pf->flags);
1168 clear_bit(priv_flag->bitno, pf->flags);
1171 bitmap_xor(change_flags, pf->flags, orig_flags, ICE_PF_FLAGS_NBITS);
1173 /* Do not allow change to link-down-on-close when Total Port Shutdown
1176 if (test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, change_flags) &&
1177 test_bit(ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags)) {
1178 dev_err(dev, "Setting link-down-on-close not supported on this port\n");
1179 set_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags);
1184 if (test_bit(ICE_FLAG_FW_LLDP_AGENT, change_flags)) {
1185 if (!test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags)) {
1186 enum ice_status status;
1188 /* Disable FW LLDP engine */
1189 status = ice_cfg_lldp_mib_change(&pf->hw, false);
1191 /* If unregistering for LLDP events fails, this is
1192 * not an error state, as there shouldn't be any
1193 * events to respond to.
1196 dev_info(dev, "Failed to unreg for LLDP events\n");
1198 /* The AQ call to stop the FW LLDP agent will generate
1199 * an error if the agent is already stopped.
1201 status = ice_aq_stop_lldp(&pf->hw, true, true, NULL);
1203 dev_warn(dev, "Fail to stop LLDP agent\n");
1204 /* Use case for having the FW LLDP agent stopped
1205 * will likely not need DCB, so failure to init is
1206 * not a concern of ethtool
1208 status = ice_init_pf_dcb(pf, true);
1210 dev_warn(dev, "Fail to init DCB\n");
1212 pf->dcbx_cap &= ~DCB_CAP_DCBX_LLD_MANAGED;
1213 pf->dcbx_cap |= DCB_CAP_DCBX_HOST;
1215 enum ice_status status;
1216 bool dcbx_agent_status;
1218 /* Remove rule to direct LLDP packets to default VSI.
1219 * The FW LLDP engine will now be consuming them.
1221 ice_cfg_sw_lldp(vsi, false, false);
1223 /* AQ command to start FW LLDP agent will return an
1224 * error if the agent is already started
1226 status = ice_aq_start_lldp(&pf->hw, true, NULL);
1228 dev_warn(dev, "Fail to start LLDP Agent\n");
1230 /* AQ command to start FW DCBX agent will fail if
1231 * the agent is already started
1233 status = ice_aq_start_stop_dcbx(&pf->hw, true,
1237 dev_dbg(dev, "Failed to start FW DCBX\n");
1239 dev_info(dev, "FW DCBX agent is %s\n",
1240 dcbx_agent_status ? "ACTIVE" : "DISABLED");
1242 /* Failure to configure MIB change or init DCB is not
1243 * relevant to ethtool. Print notification that
1244 * registration/init failed but do not return error
1247 status = ice_init_pf_dcb(pf, true);
1249 dev_dbg(dev, "Fail to init DCB\n");
1251 /* Register for MIB change events */
1252 status = ice_cfg_lldp_mib_change(&pf->hw, true);
1254 dev_dbg(dev, "Fail to enable MIB change events\n");
1256 pf->dcbx_cap &= ~DCB_CAP_DCBX_HOST;
1257 pf->dcbx_cap |= DCB_CAP_DCBX_LLD_MANAGED;
1259 ice_nway_reset(netdev);
1262 if (test_bit(ICE_FLAG_LEGACY_RX, change_flags)) {
1263 /* down and up VSI so that changes of Rx cfg are reflected. */
1267 /* don't allow modification of this flag when a single VF is in
1268 * promiscuous mode because it's not supported
1270 if (test_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, change_flags) &&
1271 ice_is_any_vf_in_promisc(pf)) {
1272 dev_err(dev, "Changing vf-true-promisc-support flag while VF(s) are in promiscuous mode not supported\n");
1273 /* toggle bit back to previous state */
1274 change_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, pf->flags);
1278 clear_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags);
1282 static int ice_get_sset_count(struct net_device *netdev, int sset)
1286 /* The number (and order) of strings reported *must* remain
1287 * constant for a given netdevice. This function must not
1288 * report a different number based on run time parameters
1289 * (such as the number of queues in use, or the setting of
1290 * a private ethtool flag). This is due to the nature of the
1291 * ethtool stats API.
1293 * Userspace programs such as ethtool must make 3 separate
1294 * ioctl requests, one for size, one for the strings, and
1295 * finally one for the stats. Since these cross into
1296 * userspace, changes to the number or size could result in
1297 * undefined memory access or incorrect string<->value
1298 * correlations for statistics.
1300 * Even if it appears to be safe, changes to the size or
1301 * order of strings will suffer from race conditions and are
1304 return ICE_ALL_STATS_LEN(netdev);
1306 return ICE_TEST_LEN;
1307 case ETH_SS_PRIV_FLAGS:
1308 return ICE_PRIV_FLAG_ARRAY_SIZE;
1315 ice_get_ethtool_stats(struct net_device *netdev,
1316 struct ethtool_stats __always_unused *stats, u64 *data)
1318 struct ice_netdev_priv *np = netdev_priv(netdev);
1319 struct ice_vsi *vsi = np->vsi;
1320 struct ice_pf *pf = vsi->back;
1321 struct ice_ring *ring;
1326 ice_update_pf_stats(pf);
1327 ice_update_vsi_stats(vsi);
1329 for (j = 0; j < ICE_VSI_STATS_LEN; j++) {
1330 p = (char *)vsi + ice_gstrings_vsi_stats[j].stat_offset;
1331 data[i++] = (ice_gstrings_vsi_stats[j].sizeof_stat ==
1332 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1335 /* populate per queue stats */
1338 ice_for_each_alloc_txq(vsi, j) {
1339 ring = READ_ONCE(vsi->tx_rings[j]);
1341 data[i++] = ring->stats.pkts;
1342 data[i++] = ring->stats.bytes;
1349 ice_for_each_alloc_rxq(vsi, j) {
1350 ring = READ_ONCE(vsi->rx_rings[j]);
1352 data[i++] = ring->stats.pkts;
1353 data[i++] = ring->stats.bytes;
1362 if (vsi->type != ICE_VSI_PF)
1365 for (j = 0; j < ICE_PF_STATS_LEN; j++) {
1366 p = (char *)pf + ice_gstrings_pf_stats[j].stat_offset;
1367 data[i++] = (ice_gstrings_pf_stats[j].sizeof_stat ==
1368 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1371 for (j = 0; j < ICE_MAX_USER_PRIORITY; j++) {
1372 data[i++] = pf->stats.priority_xon_tx[j];
1373 data[i++] = pf->stats.priority_xoff_tx[j];
1376 for (j = 0; j < ICE_MAX_USER_PRIORITY; j++) {
1377 data[i++] = pf->stats.priority_xon_rx[j];
1378 data[i++] = pf->stats.priority_xoff_rx[j];
1382 #define ICE_PHY_TYPE_LOW_MASK_MIN_1G (ICE_PHY_TYPE_LOW_100BASE_TX | \
1383 ICE_PHY_TYPE_LOW_100M_SGMII)
1385 #define ICE_PHY_TYPE_LOW_MASK_MIN_25G (ICE_PHY_TYPE_LOW_MASK_MIN_1G | \
1386 ICE_PHY_TYPE_LOW_1000BASE_T | \
1387 ICE_PHY_TYPE_LOW_1000BASE_SX | \
1388 ICE_PHY_TYPE_LOW_1000BASE_LX | \
1389 ICE_PHY_TYPE_LOW_1000BASE_KX | \
1390 ICE_PHY_TYPE_LOW_1G_SGMII | \
1391 ICE_PHY_TYPE_LOW_2500BASE_T | \
1392 ICE_PHY_TYPE_LOW_2500BASE_X | \
1393 ICE_PHY_TYPE_LOW_2500BASE_KX | \
1394 ICE_PHY_TYPE_LOW_5GBASE_T | \
1395 ICE_PHY_TYPE_LOW_5GBASE_KR | \
1396 ICE_PHY_TYPE_LOW_10GBASE_T | \
1397 ICE_PHY_TYPE_LOW_10G_SFI_DA | \
1398 ICE_PHY_TYPE_LOW_10GBASE_SR | \
1399 ICE_PHY_TYPE_LOW_10GBASE_LR | \
1400 ICE_PHY_TYPE_LOW_10GBASE_KR_CR1 | \
1401 ICE_PHY_TYPE_LOW_10G_SFI_AOC_ACC | \
1402 ICE_PHY_TYPE_LOW_10G_SFI_C2C)
1404 #define ICE_PHY_TYPE_LOW_MASK_100G (ICE_PHY_TYPE_LOW_100GBASE_CR4 | \
1405 ICE_PHY_TYPE_LOW_100GBASE_SR4 | \
1406 ICE_PHY_TYPE_LOW_100GBASE_LR4 | \
1407 ICE_PHY_TYPE_LOW_100GBASE_KR4 | \
1408 ICE_PHY_TYPE_LOW_100G_CAUI4_AOC_ACC | \
1409 ICE_PHY_TYPE_LOW_100G_CAUI4 | \
1410 ICE_PHY_TYPE_LOW_100G_AUI4_AOC_ACC | \
1411 ICE_PHY_TYPE_LOW_100G_AUI4 | \
1412 ICE_PHY_TYPE_LOW_100GBASE_CR_PAM4 | \
1413 ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4 | \
1414 ICE_PHY_TYPE_LOW_100GBASE_CP2 | \
1415 ICE_PHY_TYPE_LOW_100GBASE_SR2 | \
1416 ICE_PHY_TYPE_LOW_100GBASE_DR)
1418 #define ICE_PHY_TYPE_HIGH_MASK_100G (ICE_PHY_TYPE_HIGH_100GBASE_KR2_PAM4 | \
1419 ICE_PHY_TYPE_HIGH_100G_CAUI2_AOC_ACC |\
1420 ICE_PHY_TYPE_HIGH_100G_CAUI2 | \
1421 ICE_PHY_TYPE_HIGH_100G_AUI2_AOC_ACC | \
1422 ICE_PHY_TYPE_HIGH_100G_AUI2)
1425 * ice_mask_min_supported_speeds
1426 * @phy_types_high: PHY type high
1427 * @phy_types_low: PHY type low to apply minimum supported speeds mask
1429 * Apply minimum supported speeds mask to PHY type low. These are the speeds
1430 * for ethtool supported link mode.
1433 void ice_mask_min_supported_speeds(u64 phy_types_high, u64 *phy_types_low)
1435 /* if QSFP connection with 100G speed, minimum supported speed is 25G */
1436 if (*phy_types_low & ICE_PHY_TYPE_LOW_MASK_100G ||
1437 phy_types_high & ICE_PHY_TYPE_HIGH_MASK_100G)
1438 *phy_types_low &= ~ICE_PHY_TYPE_LOW_MASK_MIN_25G;
1440 *phy_types_low &= ~ICE_PHY_TYPE_LOW_MASK_MIN_1G;
1443 #define ice_ethtool_advertise_link_mode(aq_link_speed, ethtool_link_mode) \
1445 if (req_speeds & (aq_link_speed) || \
1447 (advert_phy_type_lo & phy_type_mask_lo || \
1448 advert_phy_type_hi & phy_type_mask_hi))) \
1449 ethtool_link_ksettings_add_link_mode(ks, advertising,\
1450 ethtool_link_mode); \
1454 * ice_phy_type_to_ethtool - convert the phy_types to ethtool link modes
1455 * @netdev: network interface device structure
1456 * @ks: ethtool link ksettings struct to fill out
1459 ice_phy_type_to_ethtool(struct net_device *netdev,
1460 struct ethtool_link_ksettings *ks)
1462 struct ice_netdev_priv *np = netdev_priv(netdev);
1463 struct ice_vsi *vsi = np->vsi;
1464 struct ice_pf *pf = vsi->back;
1465 u64 advert_phy_type_lo = 0;
1466 u64 advert_phy_type_hi = 0;
1467 u64 phy_type_mask_lo = 0;
1468 u64 phy_type_mask_hi = 0;
1469 u64 phy_types_high = 0;
1470 u64 phy_types_low = 0;
1473 req_speeds = vsi->port_info->phy.link_info.req_speeds;
1475 /* Check if lenient mode is supported and enabled, or in strict mode.
1477 * In lenient mode the Supported link modes are the PHY types without
1478 * media. The Advertising link mode is either 1. the user requested
1479 * speed, 2. the override PHY mask, or 3. the PHY types with media.
1481 * In strict mode Supported link mode are the PHY type with media,
1482 * and Advertising link modes are the media PHY type or the speed
1483 * requested by user.
1485 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) {
1486 phy_types_low = le64_to_cpu(pf->nvm_phy_type_lo);
1487 phy_types_high = le64_to_cpu(pf->nvm_phy_type_hi);
1489 ice_mask_min_supported_speeds(phy_types_high, &phy_types_low);
1490 /* determine advertised modes based on link override only
1491 * if it's supported and if the FW doesn't abstract the
1492 * driver from having to account for link overrides
1494 if (ice_fw_supports_link_override(&pf->hw) &&
1495 !ice_fw_supports_report_dflt_cfg(&pf->hw)) {
1496 struct ice_link_default_override_tlv *ldo;
1498 ldo = &pf->link_dflt_override;
1499 /* If override enabled and PHY mask set, then
1500 * Advertising link mode is the intersection of the PHY
1501 * types without media and the override PHY mask.
1503 if (ldo->options & ICE_LINK_OVERRIDE_EN &&
1504 (ldo->phy_type_low || ldo->phy_type_high)) {
1505 advert_phy_type_lo =
1506 le64_to_cpu(pf->nvm_phy_type_lo) &
1508 advert_phy_type_hi =
1509 le64_to_cpu(pf->nvm_phy_type_hi) &
1515 phy_types_low = vsi->port_info->phy.phy_type_low;
1516 phy_types_high = vsi->port_info->phy.phy_type_high;
1519 /* If Advertising link mode PHY type is not using override PHY type,
1520 * then use PHY type with media.
1522 if (!advert_phy_type_lo && !advert_phy_type_hi) {
1523 advert_phy_type_lo = vsi->port_info->phy.phy_type_low;
1524 advert_phy_type_hi = vsi->port_info->phy.phy_type_high;
1527 ethtool_link_ksettings_zero_link_mode(ks, supported);
1528 ethtool_link_ksettings_zero_link_mode(ks, advertising);
1530 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100BASE_TX |
1531 ICE_PHY_TYPE_LOW_100M_SGMII;
1532 if (phy_types_low & phy_type_mask_lo) {
1533 ethtool_link_ksettings_add_link_mode(ks, supported,
1536 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100MB,
1540 phy_type_mask_lo = ICE_PHY_TYPE_LOW_1000BASE_T |
1541 ICE_PHY_TYPE_LOW_1G_SGMII;
1542 if (phy_types_low & phy_type_mask_lo) {
1543 ethtool_link_ksettings_add_link_mode(ks, supported,
1545 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_1000MB,
1549 phy_type_mask_lo = ICE_PHY_TYPE_LOW_1000BASE_KX;
1550 if (phy_types_low & phy_type_mask_lo) {
1551 ethtool_link_ksettings_add_link_mode(ks, supported,
1553 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_1000MB,
1557 phy_type_mask_lo = ICE_PHY_TYPE_LOW_1000BASE_SX |
1558 ICE_PHY_TYPE_LOW_1000BASE_LX;
1559 if (phy_types_low & phy_type_mask_lo) {
1560 ethtool_link_ksettings_add_link_mode(ks, supported,
1562 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_1000MB,
1566 phy_type_mask_lo = ICE_PHY_TYPE_LOW_2500BASE_T;
1567 if (phy_types_low & phy_type_mask_lo) {
1568 ethtool_link_ksettings_add_link_mode(ks, supported,
1570 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_2500MB,
1574 phy_type_mask_lo = ICE_PHY_TYPE_LOW_2500BASE_X |
1575 ICE_PHY_TYPE_LOW_2500BASE_KX;
1576 if (phy_types_low & phy_type_mask_lo) {
1577 ethtool_link_ksettings_add_link_mode(ks, supported,
1579 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_2500MB,
1583 phy_type_mask_lo = ICE_PHY_TYPE_LOW_5GBASE_T |
1584 ICE_PHY_TYPE_LOW_5GBASE_KR;
1585 if (phy_types_low & phy_type_mask_lo) {
1586 ethtool_link_ksettings_add_link_mode(ks, supported,
1588 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_5GB,
1592 phy_type_mask_lo = ICE_PHY_TYPE_LOW_10GBASE_T |
1593 ICE_PHY_TYPE_LOW_10G_SFI_DA |
1594 ICE_PHY_TYPE_LOW_10G_SFI_AOC_ACC |
1595 ICE_PHY_TYPE_LOW_10G_SFI_C2C;
1596 if (phy_types_low & phy_type_mask_lo) {
1597 ethtool_link_ksettings_add_link_mode(ks, supported,
1599 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_10GB,
1603 phy_type_mask_lo = ICE_PHY_TYPE_LOW_10GBASE_KR_CR1;
1604 if (phy_types_low & phy_type_mask_lo) {
1605 ethtool_link_ksettings_add_link_mode(ks, supported,
1607 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_10GB,
1611 phy_type_mask_lo = ICE_PHY_TYPE_LOW_10GBASE_SR;
1612 if (phy_types_low & phy_type_mask_lo) {
1613 ethtool_link_ksettings_add_link_mode(ks, supported,
1615 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_10GB,
1619 phy_type_mask_lo = ICE_PHY_TYPE_LOW_10GBASE_LR;
1620 if (phy_types_low & phy_type_mask_lo) {
1621 ethtool_link_ksettings_add_link_mode(ks, supported,
1623 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_10GB,
1627 phy_type_mask_lo = ICE_PHY_TYPE_LOW_25GBASE_T |
1628 ICE_PHY_TYPE_LOW_25GBASE_CR |
1629 ICE_PHY_TYPE_LOW_25GBASE_CR_S |
1630 ICE_PHY_TYPE_LOW_25GBASE_CR1 |
1631 ICE_PHY_TYPE_LOW_25G_AUI_AOC_ACC |
1632 ICE_PHY_TYPE_LOW_25G_AUI_C2C;
1633 if (phy_types_low & phy_type_mask_lo) {
1634 ethtool_link_ksettings_add_link_mode(ks, supported,
1636 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_25GB,
1640 phy_type_mask_lo = ICE_PHY_TYPE_LOW_25GBASE_SR |
1641 ICE_PHY_TYPE_LOW_25GBASE_LR;
1642 if (phy_types_low & phy_type_mask_lo) {
1643 ethtool_link_ksettings_add_link_mode(ks, supported,
1645 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_25GB,
1649 phy_type_mask_lo = ICE_PHY_TYPE_LOW_25GBASE_KR |
1650 ICE_PHY_TYPE_LOW_25GBASE_KR_S |
1651 ICE_PHY_TYPE_LOW_25GBASE_KR1;
1652 if (phy_types_low & phy_type_mask_lo) {
1653 ethtool_link_ksettings_add_link_mode(ks, supported,
1655 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_25GB,
1659 phy_type_mask_lo = ICE_PHY_TYPE_LOW_40GBASE_KR4;
1660 if (phy_types_low & phy_type_mask_lo) {
1661 ethtool_link_ksettings_add_link_mode(ks, supported,
1663 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_40GB,
1667 phy_type_mask_lo = ICE_PHY_TYPE_LOW_40GBASE_CR4 |
1668 ICE_PHY_TYPE_LOW_40G_XLAUI_AOC_ACC |
1669 ICE_PHY_TYPE_LOW_40G_XLAUI;
1670 if (phy_types_low & phy_type_mask_lo) {
1671 ethtool_link_ksettings_add_link_mode(ks, supported,
1673 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_40GB,
1677 phy_type_mask_lo = ICE_PHY_TYPE_LOW_40GBASE_SR4;
1678 if (phy_types_low & phy_type_mask_lo) {
1679 ethtool_link_ksettings_add_link_mode(ks, supported,
1681 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_40GB,
1685 phy_type_mask_lo = ICE_PHY_TYPE_LOW_40GBASE_LR4;
1686 if (phy_types_low & phy_type_mask_lo) {
1687 ethtool_link_ksettings_add_link_mode(ks, supported,
1689 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_40GB,
1693 phy_type_mask_lo = ICE_PHY_TYPE_LOW_50GBASE_CR2 |
1694 ICE_PHY_TYPE_LOW_50G_LAUI2_AOC_ACC |
1695 ICE_PHY_TYPE_LOW_50G_LAUI2 |
1696 ICE_PHY_TYPE_LOW_50G_AUI2_AOC_ACC |
1697 ICE_PHY_TYPE_LOW_50G_AUI2 |
1698 ICE_PHY_TYPE_LOW_50GBASE_CP |
1699 ICE_PHY_TYPE_LOW_50GBASE_SR |
1700 ICE_PHY_TYPE_LOW_50G_AUI1_AOC_ACC |
1701 ICE_PHY_TYPE_LOW_50G_AUI1;
1702 if (phy_types_low & phy_type_mask_lo) {
1703 ethtool_link_ksettings_add_link_mode(ks, supported,
1705 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_50GB,
1709 phy_type_mask_lo = ICE_PHY_TYPE_LOW_50GBASE_KR2 |
1710 ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4;
1711 if (phy_types_low & phy_type_mask_lo) {
1712 ethtool_link_ksettings_add_link_mode(ks, supported,
1714 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_50GB,
1718 phy_type_mask_lo = ICE_PHY_TYPE_LOW_50GBASE_SR2 |
1719 ICE_PHY_TYPE_LOW_50GBASE_LR2 |
1720 ICE_PHY_TYPE_LOW_50GBASE_FR |
1721 ICE_PHY_TYPE_LOW_50GBASE_LR;
1722 if (phy_types_low & phy_type_mask_lo) {
1723 ethtool_link_ksettings_add_link_mode(ks, supported,
1725 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_50GB,
1729 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100GBASE_CR4 |
1730 ICE_PHY_TYPE_LOW_100G_CAUI4_AOC_ACC |
1731 ICE_PHY_TYPE_LOW_100G_CAUI4 |
1732 ICE_PHY_TYPE_LOW_100G_AUI4_AOC_ACC |
1733 ICE_PHY_TYPE_LOW_100G_AUI4 |
1734 ICE_PHY_TYPE_LOW_100GBASE_CR_PAM4 |
1735 ICE_PHY_TYPE_LOW_100GBASE_CP2;
1736 phy_type_mask_hi = ICE_PHY_TYPE_HIGH_100G_CAUI2_AOC_ACC |
1737 ICE_PHY_TYPE_HIGH_100G_CAUI2 |
1738 ICE_PHY_TYPE_HIGH_100G_AUI2_AOC_ACC |
1739 ICE_PHY_TYPE_HIGH_100G_AUI2;
1740 if (phy_types_low & phy_type_mask_lo ||
1741 phy_types_high & phy_type_mask_hi) {
1742 ethtool_link_ksettings_add_link_mode(ks, supported,
1743 100000baseCR4_Full);
1744 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB,
1745 100000baseCR4_Full);
1748 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100GBASE_SR4 |
1749 ICE_PHY_TYPE_LOW_100GBASE_SR2;
1750 if (phy_types_low & phy_type_mask_lo) {
1751 ethtool_link_ksettings_add_link_mode(ks, supported,
1752 100000baseSR4_Full);
1753 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB,
1754 100000baseSR4_Full);
1757 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100GBASE_LR4 |
1758 ICE_PHY_TYPE_LOW_100GBASE_DR;
1759 if (phy_types_low & phy_type_mask_lo) {
1760 ethtool_link_ksettings_add_link_mode(ks, supported,
1761 100000baseLR4_ER4_Full);
1762 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB,
1763 100000baseLR4_ER4_Full);
1766 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100GBASE_KR4 |
1767 ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4;
1768 phy_type_mask_hi = ICE_PHY_TYPE_HIGH_100GBASE_KR2_PAM4;
1769 if (phy_types_low & phy_type_mask_lo ||
1770 phy_types_high & phy_type_mask_hi) {
1771 ethtool_link_ksettings_add_link_mode(ks, supported,
1772 100000baseKR4_Full);
1773 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB,
1774 100000baseKR4_Full);
1778 #define TEST_SET_BITS_TIMEOUT 50
1779 #define TEST_SET_BITS_SLEEP_MAX 2000
1780 #define TEST_SET_BITS_SLEEP_MIN 1000
1783 * ice_get_settings_link_up - Get Link settings for when link is up
1784 * @ks: ethtool ksettings to fill in
1785 * @netdev: network interface device structure
1788 ice_get_settings_link_up(struct ethtool_link_ksettings *ks,
1789 struct net_device *netdev)
1791 struct ice_netdev_priv *np = netdev_priv(netdev);
1792 struct ice_port_info *pi = np->vsi->port_info;
1793 struct ice_link_status *link_info;
1794 struct ice_vsi *vsi = np->vsi;
1796 link_info = &vsi->port_info->phy.link_info;
1798 /* Get supported and advertised settings from PHY ability with media */
1799 ice_phy_type_to_ethtool(netdev, ks);
1801 switch (link_info->link_speed) {
1802 case ICE_AQ_LINK_SPEED_100GB:
1803 ks->base.speed = SPEED_100000;
1805 case ICE_AQ_LINK_SPEED_50GB:
1806 ks->base.speed = SPEED_50000;
1808 case ICE_AQ_LINK_SPEED_40GB:
1809 ks->base.speed = SPEED_40000;
1811 case ICE_AQ_LINK_SPEED_25GB:
1812 ks->base.speed = SPEED_25000;
1814 case ICE_AQ_LINK_SPEED_20GB:
1815 ks->base.speed = SPEED_20000;
1817 case ICE_AQ_LINK_SPEED_10GB:
1818 ks->base.speed = SPEED_10000;
1820 case ICE_AQ_LINK_SPEED_5GB:
1821 ks->base.speed = SPEED_5000;
1823 case ICE_AQ_LINK_SPEED_2500MB:
1824 ks->base.speed = SPEED_2500;
1826 case ICE_AQ_LINK_SPEED_1000MB:
1827 ks->base.speed = SPEED_1000;
1829 case ICE_AQ_LINK_SPEED_100MB:
1830 ks->base.speed = SPEED_100;
1833 netdev_info(netdev, "WARNING: Unrecognized link_speed (0x%x).\n",
1834 link_info->link_speed);
1837 ks->base.duplex = DUPLEX_FULL;
1839 if (link_info->an_info & ICE_AQ_AN_COMPLETED)
1840 ethtool_link_ksettings_add_link_mode(ks, lp_advertising,
1843 /* Set flow control negotiated Rx/Tx pause */
1844 switch (pi->fc.current_mode) {
1846 ethtool_link_ksettings_add_link_mode(ks, lp_advertising, Pause);
1848 case ICE_FC_TX_PAUSE:
1849 ethtool_link_ksettings_add_link_mode(ks, lp_advertising, Pause);
1850 ethtool_link_ksettings_add_link_mode(ks, lp_advertising,
1853 case ICE_FC_RX_PAUSE:
1854 ethtool_link_ksettings_add_link_mode(ks, lp_advertising,
1859 ethtool_link_ksettings_del_link_mode(ks, lp_advertising, Pause);
1860 ethtool_link_ksettings_del_link_mode(ks, lp_advertising,
1867 * ice_get_settings_link_down - Get the Link settings when link is down
1868 * @ks: ethtool ksettings to fill in
1869 * @netdev: network interface device structure
1871 * Reports link settings that can be determined when link is down
1874 ice_get_settings_link_down(struct ethtool_link_ksettings *ks,
1875 struct net_device *netdev)
1877 /* link is down and the driver needs to fall back on
1878 * supported PHY types to figure out what info to display
1880 ice_phy_type_to_ethtool(netdev, ks);
1882 /* With no link, speed and duplex are unknown */
1883 ks->base.speed = SPEED_UNKNOWN;
1884 ks->base.duplex = DUPLEX_UNKNOWN;
1888 * ice_get_link_ksettings - Get Link Speed and Duplex settings
1889 * @netdev: network interface device structure
1890 * @ks: ethtool ksettings
1892 * Reports speed/duplex settings based on media_type
1895 ice_get_link_ksettings(struct net_device *netdev,
1896 struct ethtool_link_ksettings *ks)
1898 struct ice_netdev_priv *np = netdev_priv(netdev);
1899 struct ice_aqc_get_phy_caps_data *caps;
1900 struct ice_link_status *hw_link_info;
1901 struct ice_vsi *vsi = np->vsi;
1902 enum ice_status status;
1905 ethtool_link_ksettings_zero_link_mode(ks, supported);
1906 ethtool_link_ksettings_zero_link_mode(ks, advertising);
1907 ethtool_link_ksettings_zero_link_mode(ks, lp_advertising);
1908 hw_link_info = &vsi->port_info->phy.link_info;
1910 /* set speed and duplex */
1911 if (hw_link_info->link_info & ICE_AQ_LINK_UP)
1912 ice_get_settings_link_up(ks, netdev);
1914 ice_get_settings_link_down(ks, netdev);
1916 /* set autoneg settings */
1917 ks->base.autoneg = (hw_link_info->an_info & ICE_AQ_AN_COMPLETED) ?
1918 AUTONEG_ENABLE : AUTONEG_DISABLE;
1920 /* set media type settings */
1921 switch (vsi->port_info->phy.media_type) {
1922 case ICE_MEDIA_FIBER:
1923 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE);
1924 ks->base.port = PORT_FIBRE;
1926 case ICE_MEDIA_BASET:
1927 ethtool_link_ksettings_add_link_mode(ks, supported, TP);
1928 ethtool_link_ksettings_add_link_mode(ks, advertising, TP);
1929 ks->base.port = PORT_TP;
1931 case ICE_MEDIA_BACKPLANE:
1932 ethtool_link_ksettings_add_link_mode(ks, supported, Backplane);
1933 ethtool_link_ksettings_add_link_mode(ks, advertising,
1935 ks->base.port = PORT_NONE;
1938 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE);
1939 ethtool_link_ksettings_add_link_mode(ks, advertising, FIBRE);
1940 ks->base.port = PORT_DA;
1943 ks->base.port = PORT_OTHER;
1947 /* flow control is symmetric and always supported */
1948 ethtool_link_ksettings_add_link_mode(ks, supported, Pause);
1950 caps = kzalloc(sizeof(*caps), GFP_KERNEL);
1954 status = ice_aq_get_phy_caps(vsi->port_info, false,
1955 ICE_AQC_REPORT_ACTIVE_CFG, caps, NULL);
1961 /* Set the advertised flow control based on the PHY capability */
1962 if ((caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) &&
1963 (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE)) {
1964 ethtool_link_ksettings_add_link_mode(ks, advertising, Pause);
1965 ethtool_link_ksettings_add_link_mode(ks, advertising,
1967 } else if (caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) {
1968 ethtool_link_ksettings_add_link_mode(ks, advertising,
1970 } else if (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE) {
1971 ethtool_link_ksettings_add_link_mode(ks, advertising, Pause);
1972 ethtool_link_ksettings_add_link_mode(ks, advertising,
1975 ethtool_link_ksettings_del_link_mode(ks, advertising, Pause);
1976 ethtool_link_ksettings_del_link_mode(ks, advertising,
1980 /* Set advertised FEC modes based on PHY capability */
1981 ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_NONE);
1983 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ ||
1984 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ)
1985 ethtool_link_ksettings_add_link_mode(ks, advertising,
1987 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ ||
1988 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ)
1989 ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_RS);
1991 status = ice_aq_get_phy_caps(vsi->port_info, false,
1992 ICE_AQC_REPORT_TOPO_CAP_MEDIA, caps, NULL);
1998 /* Set supported FEC modes based on PHY capability */
1999 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_NONE);
2001 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN ||
2002 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN)
2003 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER);
2004 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN)
2005 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS);
2007 /* Set supported and advertised autoneg */
2008 if (ice_is_phy_caps_an_enabled(caps)) {
2009 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
2010 ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);
2019 * ice_ksettings_find_adv_link_speed - Find advertising link speed
2020 * @ks: ethtool ksettings
2023 ice_ksettings_find_adv_link_speed(const struct ethtool_link_ksettings *ks)
2025 u16 adv_link_speed = 0;
2027 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2029 adv_link_speed |= ICE_AQ_LINK_SPEED_100MB;
2030 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2032 adv_link_speed |= ICE_AQ_LINK_SPEED_1000MB;
2033 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2035 ethtool_link_ksettings_test_link_mode(ks, advertising,
2037 adv_link_speed |= ICE_AQ_LINK_SPEED_1000MB;
2038 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2040 adv_link_speed |= ICE_AQ_LINK_SPEED_2500MB;
2041 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2043 adv_link_speed |= ICE_AQ_LINK_SPEED_2500MB;
2044 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2046 adv_link_speed |= ICE_AQ_LINK_SPEED_5GB;
2047 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2049 ethtool_link_ksettings_test_link_mode(ks, advertising,
2051 adv_link_speed |= ICE_AQ_LINK_SPEED_10GB;
2052 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2053 10000baseSR_Full) ||
2054 ethtool_link_ksettings_test_link_mode(ks, advertising,
2056 adv_link_speed |= ICE_AQ_LINK_SPEED_10GB;
2057 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2058 25000baseCR_Full) ||
2059 ethtool_link_ksettings_test_link_mode(ks, advertising,
2060 25000baseSR_Full) ||
2061 ethtool_link_ksettings_test_link_mode(ks, advertising,
2063 adv_link_speed |= ICE_AQ_LINK_SPEED_25GB;
2064 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2065 40000baseCR4_Full) ||
2066 ethtool_link_ksettings_test_link_mode(ks, advertising,
2067 40000baseSR4_Full) ||
2068 ethtool_link_ksettings_test_link_mode(ks, advertising,
2069 40000baseLR4_Full) ||
2070 ethtool_link_ksettings_test_link_mode(ks, advertising,
2072 adv_link_speed |= ICE_AQ_LINK_SPEED_40GB;
2073 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2074 50000baseCR2_Full) ||
2075 ethtool_link_ksettings_test_link_mode(ks, advertising,
2077 adv_link_speed |= ICE_AQ_LINK_SPEED_50GB;
2078 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2080 adv_link_speed |= ICE_AQ_LINK_SPEED_50GB;
2081 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2082 100000baseCR4_Full) ||
2083 ethtool_link_ksettings_test_link_mode(ks, advertising,
2084 100000baseSR4_Full) ||
2085 ethtool_link_ksettings_test_link_mode(ks, advertising,
2086 100000baseLR4_ER4_Full) ||
2087 ethtool_link_ksettings_test_link_mode(ks, advertising,
2088 100000baseKR4_Full))
2089 adv_link_speed |= ICE_AQ_LINK_SPEED_100GB;
2091 return adv_link_speed;
2097 * @ks: ethtool_link_ksettings
2098 * @config: configuration that will be sent down to FW
2099 * @autoneg_enabled: autonegotiation is enabled or not
2100 * @autoneg_changed: will there a change in autonegotiation
2101 * @netdev: network interface device structure
2103 * Setup PHY autonegotiation feature
2106 ice_setup_autoneg(struct ice_port_info *p, struct ethtool_link_ksettings *ks,
2107 struct ice_aqc_set_phy_cfg_data *config,
2108 u8 autoneg_enabled, u8 *autoneg_changed,
2109 struct net_device *netdev)
2113 *autoneg_changed = 0;
2116 if (autoneg_enabled == AUTONEG_ENABLE) {
2117 /* If autoneg was not already enabled */
2118 if (!(p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED)) {
2119 /* If autoneg is not supported, return error */
2120 if (!ethtool_link_ksettings_test_link_mode(ks,
2123 netdev_info(netdev, "Autoneg not supported on this phy.\n");
2126 /* Autoneg is allowed to change */
2127 config->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
2128 *autoneg_changed = 1;
2132 /* If autoneg is currently enabled */
2133 if (p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED) {
2134 /* If autoneg is supported 10GBASE_T is the only PHY
2135 * that can disable it, so otherwise return error
2137 if (ethtool_link_ksettings_test_link_mode(ks,
2140 netdev_info(netdev, "Autoneg cannot be disabled on this phy\n");
2143 /* Autoneg is allowed to change */
2144 config->caps &= ~ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
2145 *autoneg_changed = 1;
2154 * ice_set_link_ksettings - Set Speed and Duplex
2155 * @netdev: network interface device structure
2156 * @ks: ethtool ksettings
2158 * Set speed/duplex per media_types advertised/forced
2161 ice_set_link_ksettings(struct net_device *netdev,
2162 const struct ethtool_link_ksettings *ks)
2164 struct ice_netdev_priv *np = netdev_priv(netdev);
2165 u8 autoneg, timeout = TEST_SET_BITS_TIMEOUT;
2166 struct ethtool_link_ksettings copy_ks = *ks;
2167 struct ethtool_link_ksettings safe_ks = {};
2168 struct ice_aqc_get_phy_caps_data *phy_caps;
2169 struct ice_aqc_set_phy_cfg_data config;
2170 u16 adv_link_speed, curr_link_speed;
2171 struct ice_pf *pf = np->vsi->back;
2172 struct ice_port_info *pi;
2173 u8 autoneg_changed = 0;
2174 enum ice_status status;
2175 u64 phy_type_high = 0;
2176 u64 phy_type_low = 0;
2180 pi = np->vsi->port_info;
2185 if (pi->phy.media_type != ICE_MEDIA_BASET &&
2186 pi->phy.media_type != ICE_MEDIA_FIBER &&
2187 pi->phy.media_type != ICE_MEDIA_BACKPLANE &&
2188 pi->phy.media_type != ICE_MEDIA_DA &&
2189 pi->phy.link_info.link_info & ICE_AQ_LINK_UP)
2192 phy_caps = kzalloc(sizeof(*phy_caps), GFP_KERNEL);
2196 /* Get the PHY capabilities based on media */
2197 if (ice_fw_supports_report_dflt_cfg(pi->hw))
2198 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_DFLT_CFG,
2201 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP_MEDIA,
2208 /* save autoneg out of ksettings */
2209 autoneg = copy_ks.base.autoneg;
2211 /* Get link modes supported by hardware.*/
2212 ice_phy_type_to_ethtool(netdev, &safe_ks);
2214 /* and check against modes requested by user.
2215 * Return an error if unsupported mode was set.
2217 if (!bitmap_subset(copy_ks.link_modes.advertising,
2218 safe_ks.link_modes.supported,
2219 __ETHTOOL_LINK_MODE_MASK_NBITS)) {
2220 if (!test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags))
2221 netdev_info(netdev, "The selected speed is not supported by the current media. Please select a link speed that is supported by the current media.\n");
2226 /* get our own copy of the bits to check against */
2227 memset(&safe_ks, 0, sizeof(safe_ks));
2228 safe_ks.base.cmd = copy_ks.base.cmd;
2229 safe_ks.base.link_mode_masks_nwords =
2230 copy_ks.base.link_mode_masks_nwords;
2231 ice_get_link_ksettings(netdev, &safe_ks);
2233 /* set autoneg back to what it currently is */
2234 copy_ks.base.autoneg = safe_ks.base.autoneg;
2235 /* we don't compare the speed */
2236 copy_ks.base.speed = safe_ks.base.speed;
2238 /* If copy_ks.base and safe_ks.base are not the same now, then they are
2239 * trying to set something that we do not support.
2241 if (memcmp(©_ks.base, &safe_ks.base, sizeof(copy_ks.base))) {
2246 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) {
2252 usleep_range(TEST_SET_BITS_SLEEP_MIN, TEST_SET_BITS_SLEEP_MAX);
2255 /* Copy the current user PHY configuration. The current user PHY
2256 * configuration is initialized during probe from PHY capabilities
2257 * software mode, and updated on set PHY configuration.
2259 config = pi->phy.curr_user_phy_cfg;
2261 config.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
2264 err = ice_setup_autoneg(pi, &safe_ks, &config, autoneg, &autoneg_changed,
2270 /* Call to get the current link speed */
2271 pi->phy.get_link_info = true;
2272 status = ice_get_link_status(pi, &linkup);
2278 curr_link_speed = pi->phy.link_info.link_speed;
2279 adv_link_speed = ice_ksettings_find_adv_link_speed(ks);
2281 /* If speed didn't get set, set it to what it currently is.
2282 * This is needed because if advertise is 0 (as it is when autoneg
2283 * is disabled) then speed won't get set.
2285 if (!adv_link_speed)
2286 adv_link_speed = curr_link_speed;
2288 /* Convert the advertise link speeds to their corresponded PHY_TYPE */
2289 ice_update_phy_type(&phy_type_low, &phy_type_high, adv_link_speed);
2291 if (!autoneg_changed && adv_link_speed == curr_link_speed) {
2292 netdev_info(netdev, "Nothing changed, exiting without setting anything.\n");
2296 /* save the requested speeds */
2297 pi->phy.link_info.req_speeds = adv_link_speed;
2299 /* set link and auto negotiation so changes take effect */
2300 config.caps |= ICE_AQ_PHY_ENA_LINK;
2302 /* check if there is a PHY type for the requested advertised speed */
2303 if (!(phy_type_low || phy_type_high)) {
2304 netdev_info(netdev, "The selected speed is not supported by the current media. Please select a link speed that is supported by the current media.\n");
2309 /* intersect requested advertised speed PHY types with media PHY types
2310 * for set PHY configuration
2312 config.phy_type_high = cpu_to_le64(phy_type_high) &
2313 phy_caps->phy_type_high;
2314 config.phy_type_low = cpu_to_le64(phy_type_low) &
2315 phy_caps->phy_type_low;
2317 if (!(config.phy_type_high || config.phy_type_low)) {
2318 /* If there is no intersection and lenient mode is enabled, then
2319 * intersect the requested advertised speed with NVM media type
2322 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) {
2323 config.phy_type_high = cpu_to_le64(phy_type_high) &
2324 pf->nvm_phy_type_hi;
2325 config.phy_type_low = cpu_to_le64(phy_type_low) &
2326 pf->nvm_phy_type_lo;
2328 netdev_info(netdev, "The selected speed is not supported by the current media. Please select a link speed that is supported by the current media.\n");
2334 /* If link is up put link down */
2335 if (pi->phy.link_info.link_info & ICE_AQ_LINK_UP) {
2336 /* Tell the OS link is going down, the link will go
2337 * back up when fw says it is ready asynchronously
2339 ice_print_link_msg(np->vsi, false);
2340 netif_carrier_off(netdev);
2341 netif_tx_stop_all_queues(netdev);
2344 /* make the aq call */
2345 status = ice_aq_set_phy_cfg(&pf->hw, pi, &config, NULL);
2347 netdev_info(netdev, "Set phy config failed,\n");
2352 /* Save speed request */
2353 pi->phy.curr_user_speed_req = adv_link_speed;
2356 clear_bit(ICE_CFG_BUSY, pf->state);
2362 * ice_parse_hdrs - parses headers from RSS hash input
2363 * @nfc: ethtool rxnfc command
2365 * This function parses the rxnfc command and returns intended
2366 * header types for RSS configuration
2368 static u32 ice_parse_hdrs(struct ethtool_rxnfc *nfc)
2370 u32 hdrs = ICE_FLOW_SEG_HDR_NONE;
2372 switch (nfc->flow_type) {
2374 hdrs |= ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV4;
2377 hdrs |= ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV4;
2380 hdrs |= ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV4;
2383 hdrs |= ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV6;
2386 hdrs |= ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV6;
2389 hdrs |= ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV6;
2397 #define ICE_FLOW_HASH_FLD_IPV4_SA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)
2398 #define ICE_FLOW_HASH_FLD_IPV6_SA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)
2399 #define ICE_FLOW_HASH_FLD_IPV4_DA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)
2400 #define ICE_FLOW_HASH_FLD_IPV6_DA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)
2401 #define ICE_FLOW_HASH_FLD_TCP_SRC_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)
2402 #define ICE_FLOW_HASH_FLD_TCP_DST_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)
2403 #define ICE_FLOW_HASH_FLD_UDP_SRC_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)
2404 #define ICE_FLOW_HASH_FLD_UDP_DST_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)
2405 #define ICE_FLOW_HASH_FLD_SCTP_SRC_PORT \
2406 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)
2407 #define ICE_FLOW_HASH_FLD_SCTP_DST_PORT \
2408 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)
2411 * ice_parse_hash_flds - parses hash fields from RSS hash input
2412 * @nfc: ethtool rxnfc command
2414 * This function parses the rxnfc command and returns intended
2415 * hash fields for RSS configuration
2417 static u64 ice_parse_hash_flds(struct ethtool_rxnfc *nfc)
2419 u64 hfld = ICE_HASH_INVALID;
2421 if (nfc->data & RXH_IP_SRC || nfc->data & RXH_IP_DST) {
2422 switch (nfc->flow_type) {
2426 if (nfc->data & RXH_IP_SRC)
2427 hfld |= ICE_FLOW_HASH_FLD_IPV4_SA;
2428 if (nfc->data & RXH_IP_DST)
2429 hfld |= ICE_FLOW_HASH_FLD_IPV4_DA;
2434 if (nfc->data & RXH_IP_SRC)
2435 hfld |= ICE_FLOW_HASH_FLD_IPV6_SA;
2436 if (nfc->data & RXH_IP_DST)
2437 hfld |= ICE_FLOW_HASH_FLD_IPV6_DA;
2444 if (nfc->data & RXH_L4_B_0_1 || nfc->data & RXH_L4_B_2_3) {
2445 switch (nfc->flow_type) {
2448 if (nfc->data & RXH_L4_B_0_1)
2449 hfld |= ICE_FLOW_HASH_FLD_TCP_SRC_PORT;
2450 if (nfc->data & RXH_L4_B_2_3)
2451 hfld |= ICE_FLOW_HASH_FLD_TCP_DST_PORT;
2455 if (nfc->data & RXH_L4_B_0_1)
2456 hfld |= ICE_FLOW_HASH_FLD_UDP_SRC_PORT;
2457 if (nfc->data & RXH_L4_B_2_3)
2458 hfld |= ICE_FLOW_HASH_FLD_UDP_DST_PORT;
2462 if (nfc->data & RXH_L4_B_0_1)
2463 hfld |= ICE_FLOW_HASH_FLD_SCTP_SRC_PORT;
2464 if (nfc->data & RXH_L4_B_2_3)
2465 hfld |= ICE_FLOW_HASH_FLD_SCTP_DST_PORT;
2476 * ice_set_rss_hash_opt - Enable/Disable flow types for RSS hash
2477 * @vsi: the VSI being configured
2478 * @nfc: ethtool rxnfc command
2480 * Returns Success if the flow input set is supported.
2483 ice_set_rss_hash_opt(struct ice_vsi *vsi, struct ethtool_rxnfc *nfc)
2485 struct ice_pf *pf = vsi->back;
2486 enum ice_status status;
2491 dev = ice_pf_to_dev(pf);
2492 if (ice_is_safe_mode(pf)) {
2493 dev_dbg(dev, "Advanced RSS disabled. Package download failed, vsi num = %d\n",
2498 hashed_flds = ice_parse_hash_flds(nfc);
2499 if (hashed_flds == ICE_HASH_INVALID) {
2500 dev_dbg(dev, "Invalid hash fields, vsi num = %d\n",
2505 hdrs = ice_parse_hdrs(nfc);
2506 if (hdrs == ICE_FLOW_SEG_HDR_NONE) {
2507 dev_dbg(dev, "Header type is not valid, vsi num = %d\n",
2512 status = ice_add_rss_cfg(&pf->hw, vsi->idx, hashed_flds, hdrs);
2514 dev_dbg(dev, "ice_add_rss_cfg failed, vsi num = %d, error = %s\n",
2515 vsi->vsi_num, ice_stat_str(status));
2523 * ice_get_rss_hash_opt - Retrieve hash fields for a given flow-type
2524 * @vsi: the VSI being configured
2525 * @nfc: ethtool rxnfc command
2528 ice_get_rss_hash_opt(struct ice_vsi *vsi, struct ethtool_rxnfc *nfc)
2530 struct ice_pf *pf = vsi->back;
2535 dev = ice_pf_to_dev(pf);
2538 if (ice_is_safe_mode(pf)) {
2539 dev_dbg(dev, "Advanced RSS disabled. Package download failed, vsi num = %d\n",
2544 hdrs = ice_parse_hdrs(nfc);
2545 if (hdrs == ICE_FLOW_SEG_HDR_NONE) {
2546 dev_dbg(dev, "Header type is not valid, vsi num = %d\n",
2551 hash_flds = ice_get_rss_cfg(&pf->hw, vsi->idx, hdrs);
2552 if (hash_flds == ICE_HASH_INVALID) {
2553 dev_dbg(dev, "No hash fields found for the given header type, vsi num = %d\n",
2558 if (hash_flds & ICE_FLOW_HASH_FLD_IPV4_SA ||
2559 hash_flds & ICE_FLOW_HASH_FLD_IPV6_SA)
2560 nfc->data |= (u64)RXH_IP_SRC;
2562 if (hash_flds & ICE_FLOW_HASH_FLD_IPV4_DA ||
2563 hash_flds & ICE_FLOW_HASH_FLD_IPV6_DA)
2564 nfc->data |= (u64)RXH_IP_DST;
2566 if (hash_flds & ICE_FLOW_HASH_FLD_TCP_SRC_PORT ||
2567 hash_flds & ICE_FLOW_HASH_FLD_UDP_SRC_PORT ||
2568 hash_flds & ICE_FLOW_HASH_FLD_SCTP_SRC_PORT)
2569 nfc->data |= (u64)RXH_L4_B_0_1;
2571 if (hash_flds & ICE_FLOW_HASH_FLD_TCP_DST_PORT ||
2572 hash_flds & ICE_FLOW_HASH_FLD_UDP_DST_PORT ||
2573 hash_flds & ICE_FLOW_HASH_FLD_SCTP_DST_PORT)
2574 nfc->data |= (u64)RXH_L4_B_2_3;
2578 * ice_set_rxnfc - command to set Rx flow rules.
2579 * @netdev: network interface device structure
2580 * @cmd: ethtool rxnfc command
2582 * Returns 0 for success and negative values for errors
2584 static int ice_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
2586 struct ice_netdev_priv *np = netdev_priv(netdev);
2587 struct ice_vsi *vsi = np->vsi;
2590 case ETHTOOL_SRXCLSRLINS:
2591 return ice_add_fdir_ethtool(vsi, cmd);
2592 case ETHTOOL_SRXCLSRLDEL:
2593 return ice_del_fdir_ethtool(vsi, cmd);
2595 return ice_set_rss_hash_opt(vsi, cmd);
2603 * ice_get_rxnfc - command to get Rx flow classification rules
2604 * @netdev: network interface device structure
2605 * @cmd: ethtool rxnfc command
2606 * @rule_locs: buffer to rturn Rx flow classification rules
2608 * Returns Success if the command is supported.
2611 ice_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
2612 u32 __always_unused *rule_locs)
2614 struct ice_netdev_priv *np = netdev_priv(netdev);
2615 struct ice_vsi *vsi = np->vsi;
2616 int ret = -EOPNOTSUPP;
2619 hw = &vsi->back->hw;
2622 case ETHTOOL_GRXRINGS:
2623 cmd->data = vsi->rss_size;
2626 case ETHTOOL_GRXCLSRLCNT:
2627 cmd->rule_cnt = hw->fdir_active_fltr;
2628 /* report total rule count */
2629 cmd->data = ice_get_fdir_cnt_all(hw);
2632 case ETHTOOL_GRXCLSRULE:
2633 ret = ice_get_ethtool_fdir_entry(hw, cmd);
2635 case ETHTOOL_GRXCLSRLALL:
2636 ret = ice_get_fdir_fltr_ids(hw, cmd, (u32 *)rule_locs);
2639 ice_get_rss_hash_opt(vsi, cmd);
2650 ice_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
2652 struct ice_netdev_priv *np = netdev_priv(netdev);
2653 struct ice_vsi *vsi = np->vsi;
2655 ring->rx_max_pending = ICE_MAX_NUM_DESC;
2656 ring->tx_max_pending = ICE_MAX_NUM_DESC;
2657 ring->rx_pending = vsi->rx_rings[0]->count;
2658 ring->tx_pending = vsi->tx_rings[0]->count;
2660 /* Rx mini and jumbo rings are not supported */
2661 ring->rx_mini_max_pending = 0;
2662 ring->rx_jumbo_max_pending = 0;
2663 ring->rx_mini_pending = 0;
2664 ring->rx_jumbo_pending = 0;
2668 ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
2670 struct ice_ring *tx_rings = NULL, *rx_rings = NULL;
2671 struct ice_netdev_priv *np = netdev_priv(netdev);
2672 struct ice_ring *xdp_rings = NULL;
2673 struct ice_vsi *vsi = np->vsi;
2674 struct ice_pf *pf = vsi->back;
2675 int i, timeout = 50, err = 0;
2676 u16 new_rx_cnt, new_tx_cnt;
2678 if (ring->tx_pending > ICE_MAX_NUM_DESC ||
2679 ring->tx_pending < ICE_MIN_NUM_DESC ||
2680 ring->rx_pending > ICE_MAX_NUM_DESC ||
2681 ring->rx_pending < ICE_MIN_NUM_DESC) {
2682 netdev_err(netdev, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d] (increment %d)\n",
2683 ring->tx_pending, ring->rx_pending,
2684 ICE_MIN_NUM_DESC, ICE_MAX_NUM_DESC,
2685 ICE_REQ_DESC_MULTIPLE);
2689 new_tx_cnt = ALIGN(ring->tx_pending, ICE_REQ_DESC_MULTIPLE);
2690 if (new_tx_cnt != ring->tx_pending)
2691 netdev_info(netdev, "Requested Tx descriptor count rounded up to %d\n",
2693 new_rx_cnt = ALIGN(ring->rx_pending, ICE_REQ_DESC_MULTIPLE);
2694 if (new_rx_cnt != ring->rx_pending)
2695 netdev_info(netdev, "Requested Rx descriptor count rounded up to %d\n",
2698 /* if nothing to do return success */
2699 if (new_tx_cnt == vsi->tx_rings[0]->count &&
2700 new_rx_cnt == vsi->rx_rings[0]->count) {
2701 netdev_dbg(netdev, "Nothing to change, descriptor count is same as requested\n");
2705 /* If there is a AF_XDP UMEM attached to any of Rx rings,
2706 * disallow changing the number of descriptors -- regardless
2707 * if the netdev is running or not.
2709 if (ice_xsk_any_rx_ring_ena(vsi))
2712 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) {
2716 usleep_range(1000, 2000);
2719 /* set for the next time the netdev is started */
2720 if (!netif_running(vsi->netdev)) {
2721 for (i = 0; i < vsi->alloc_txq; i++)
2722 vsi->tx_rings[i]->count = new_tx_cnt;
2723 for (i = 0; i < vsi->alloc_rxq; i++)
2724 vsi->rx_rings[i]->count = new_rx_cnt;
2725 if (ice_is_xdp_ena_vsi(vsi))
2726 for (i = 0; i < vsi->num_xdp_txq; i++)
2727 vsi->xdp_rings[i]->count = new_tx_cnt;
2728 vsi->num_tx_desc = (u16)new_tx_cnt;
2729 vsi->num_rx_desc = (u16)new_rx_cnt;
2730 netdev_dbg(netdev, "Link is down, descriptor count change happens when link is brought up\n");
2734 if (new_tx_cnt == vsi->tx_rings[0]->count)
2737 /* alloc updated Tx resources */
2738 netdev_info(netdev, "Changing Tx descriptor count from %d to %d\n",
2739 vsi->tx_rings[0]->count, new_tx_cnt);
2741 tx_rings = kcalloc(vsi->num_txq, sizeof(*tx_rings), GFP_KERNEL);
2747 ice_for_each_txq(vsi, i) {
2748 /* clone ring and setup updated count */
2749 tx_rings[i] = *vsi->tx_rings[i];
2750 tx_rings[i].count = new_tx_cnt;
2751 tx_rings[i].desc = NULL;
2752 tx_rings[i].tx_buf = NULL;
2753 err = ice_setup_tx_ring(&tx_rings[i]);
2756 ice_clean_tx_ring(&tx_rings[i]);
2762 if (!ice_is_xdp_ena_vsi(vsi))
2765 /* alloc updated XDP resources */
2766 netdev_info(netdev, "Changing XDP descriptor count from %d to %d\n",
2767 vsi->xdp_rings[0]->count, new_tx_cnt);
2769 xdp_rings = kcalloc(vsi->num_xdp_txq, sizeof(*xdp_rings), GFP_KERNEL);
2775 for (i = 0; i < vsi->num_xdp_txq; i++) {
2776 /* clone ring and setup updated count */
2777 xdp_rings[i] = *vsi->xdp_rings[i];
2778 xdp_rings[i].count = new_tx_cnt;
2779 xdp_rings[i].desc = NULL;
2780 xdp_rings[i].tx_buf = NULL;
2781 err = ice_setup_tx_ring(&xdp_rings[i]);
2784 ice_clean_tx_ring(&xdp_rings[i]);
2788 ice_set_ring_xdp(&xdp_rings[i]);
2792 if (new_rx_cnt == vsi->rx_rings[0]->count)
2795 /* alloc updated Rx resources */
2796 netdev_info(netdev, "Changing Rx descriptor count from %d to %d\n",
2797 vsi->rx_rings[0]->count, new_rx_cnt);
2799 rx_rings = kcalloc(vsi->num_rxq, sizeof(*rx_rings), GFP_KERNEL);
2805 ice_for_each_rxq(vsi, i) {
2806 /* clone ring and setup updated count */
2807 rx_rings[i] = *vsi->rx_rings[i];
2808 rx_rings[i].count = new_rx_cnt;
2809 rx_rings[i].desc = NULL;
2810 rx_rings[i].rx_buf = NULL;
2811 /* this is to allow wr32 to have something to write to
2812 * during early allocation of Rx buffers
2814 rx_rings[i].tail = vsi->back->hw.hw_addr + PRTGEN_STATUS;
2816 err = ice_setup_rx_ring(&rx_rings[i]);
2820 /* allocate Rx buffers */
2821 err = ice_alloc_rx_bufs(&rx_rings[i],
2822 ICE_DESC_UNUSED(&rx_rings[i]));
2827 ice_free_rx_ring(&rx_rings[i]);
2836 /* Bring interface down, copy in the new ring info, then restore the
2837 * interface. if VSI is up, bring it down and then back up
2839 if (!test_and_set_bit(ICE_VSI_DOWN, vsi->state)) {
2843 ice_for_each_txq(vsi, i) {
2844 ice_free_tx_ring(vsi->tx_rings[i]);
2845 *vsi->tx_rings[i] = tx_rings[i];
2851 ice_for_each_rxq(vsi, i) {
2852 ice_free_rx_ring(vsi->rx_rings[i]);
2853 /* copy the real tail offset */
2854 rx_rings[i].tail = vsi->rx_rings[i]->tail;
2855 /* this is to fake out the allocation routine
2856 * into thinking it has to realloc everything
2857 * but the recycling logic will let us re-use
2858 * the buffers allocated above
2860 rx_rings[i].next_to_use = 0;
2861 rx_rings[i].next_to_clean = 0;
2862 rx_rings[i].next_to_alloc = 0;
2863 *vsi->rx_rings[i] = rx_rings[i];
2869 for (i = 0; i < vsi->num_xdp_txq; i++) {
2870 ice_free_tx_ring(vsi->xdp_rings[i]);
2871 *vsi->xdp_rings[i] = xdp_rings[i];
2876 vsi->num_tx_desc = new_tx_cnt;
2877 vsi->num_rx_desc = new_rx_cnt;
2883 /* error cleanup if the Rx allocations failed after getting Tx */
2885 ice_for_each_txq(vsi, i)
2886 ice_free_tx_ring(&tx_rings[i]);
2891 clear_bit(ICE_CFG_BUSY, pf->state);
2896 * ice_get_pauseparam - Get Flow Control status
2897 * @netdev: network interface device structure
2898 * @pause: ethernet pause (flow control) parameters
2900 * Get requested flow control status from PHY capability.
2901 * If autoneg is true, then ethtool will send the ETHTOOL_GSET ioctl which
2902 * is handled by ice_get_link_ksettings. ice_get_link_ksettings will report
2903 * the negotiated Rx/Tx pause via lp_advertising.
2906 ice_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
2908 struct ice_netdev_priv *np = netdev_priv(netdev);
2909 struct ice_port_info *pi = np->vsi->port_info;
2910 struct ice_aqc_get_phy_caps_data *pcaps;
2911 struct ice_dcbx_cfg *dcbx_cfg;
2912 enum ice_status status;
2914 /* Initialize pause params */
2915 pause->rx_pause = 0;
2916 pause->tx_pause = 0;
2918 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
2920 pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
2924 /* Get current PHY config */
2925 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_ACTIVE_CFG, pcaps,
2930 pause->autoneg = ice_is_phy_caps_an_enabled(pcaps) ? AUTONEG_ENABLE :
2933 if (dcbx_cfg->pfc.pfcena)
2934 /* PFC enabled so report LFC as off */
2937 if (pcaps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE)
2938 pause->tx_pause = 1;
2939 if (pcaps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE)
2940 pause->rx_pause = 1;
2947 * ice_set_pauseparam - Set Flow Control parameter
2948 * @netdev: network interface device structure
2949 * @pause: return Tx/Rx flow control status
2952 ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
2954 struct ice_netdev_priv *np = netdev_priv(netdev);
2955 struct ice_aqc_get_phy_caps_data *pcaps;
2956 struct ice_link_status *hw_link_info;
2957 struct ice_pf *pf = np->vsi->back;
2958 struct ice_dcbx_cfg *dcbx_cfg;
2959 struct ice_vsi *vsi = np->vsi;
2960 struct ice_hw *hw = &pf->hw;
2961 struct ice_port_info *pi;
2962 enum ice_status status;
2968 pi = vsi->port_info;
2969 hw_link_info = &pi->phy.link_info;
2970 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
2971 link_up = hw_link_info->link_info & ICE_AQ_LINK_UP;
2973 /* Changing the port's flow control is not supported if this isn't the
2976 if (vsi->type != ICE_VSI_PF) {
2977 netdev_info(netdev, "Changing flow control parameters only supported for PF VSI\n");
2981 /* Get pause param reports configured and negotiated flow control pause
2982 * when ETHTOOL_GLINKSETTINGS is defined. Since ETHTOOL_GLINKSETTINGS is
2983 * defined get pause param pause->autoneg reports SW configured setting,
2984 * so compare pause->autoneg with SW configured to prevent the user from
2985 * using set pause param to chance autoneg.
2987 pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
2991 /* Get current PHY config */
2992 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_ACTIVE_CFG, pcaps,
2999 is_an = ice_is_phy_caps_an_enabled(pcaps) ? AUTONEG_ENABLE :
3004 if (pause->autoneg != is_an) {
3005 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n");
3009 /* If we have link and don't have autoneg */
3010 if (!test_bit(ICE_DOWN, pf->state) &&
3011 !(hw_link_info->an_info & ICE_AQ_AN_COMPLETED)) {
3012 /* Send message that it might not necessarily work*/
3013 netdev_info(netdev, "Autoneg did not complete so changing settings may not result in an actual change.\n");
3016 if (dcbx_cfg->pfc.pfcena) {
3017 netdev_info(netdev, "Priority flow control enabled. Cannot set link flow control.\n");
3020 if (pause->rx_pause && pause->tx_pause)
3021 pi->fc.req_mode = ICE_FC_FULL;
3022 else if (pause->rx_pause && !pause->tx_pause)
3023 pi->fc.req_mode = ICE_FC_RX_PAUSE;
3024 else if (!pause->rx_pause && pause->tx_pause)
3025 pi->fc.req_mode = ICE_FC_TX_PAUSE;
3026 else if (!pause->rx_pause && !pause->tx_pause)
3027 pi->fc.req_mode = ICE_FC_NONE;
3031 /* Set the FC mode and only restart AN if link is up */
3032 status = ice_set_fc(pi, &aq_failures, link_up);
3034 if (aq_failures & ICE_SET_FC_AQ_FAIL_GET) {
3035 netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with err %s aq_err %s\n",
3036 ice_stat_str(status),
3037 ice_aq_str(hw->adminq.sq_last_status));
3039 } else if (aq_failures & ICE_SET_FC_AQ_FAIL_SET) {
3040 netdev_info(netdev, "Set fc failed on the set_phy_config call with err %s aq_err %s\n",
3041 ice_stat_str(status),
3042 ice_aq_str(hw->adminq.sq_last_status));
3044 } else if (aq_failures & ICE_SET_FC_AQ_FAIL_UPDATE) {
3045 netdev_info(netdev, "Set fc failed on the get_link_info call with err %s aq_err %s\n",
3046 ice_stat_str(status),
3047 ice_aq_str(hw->adminq.sq_last_status));
3055 * ice_get_rxfh_key_size - get the RSS hash key size
3056 * @netdev: network interface device structure
3058 * Returns the table size.
3060 static u32 ice_get_rxfh_key_size(struct net_device __always_unused *netdev)
3062 return ICE_VSIQF_HKEY_ARRAY_SIZE;
3066 * ice_get_rxfh_indir_size - get the Rx flow hash indirection table size
3067 * @netdev: network interface device structure
3069 * Returns the table size.
3071 static u32 ice_get_rxfh_indir_size(struct net_device *netdev)
3073 struct ice_netdev_priv *np = netdev_priv(netdev);
3075 return np->vsi->rss_table_size;
3079 * ice_get_rxfh - get the Rx flow hash indirection table
3080 * @netdev: network interface device structure
3081 * @indir: indirection table
3083 * @hfunc: hash function
3085 * Reads the indirection table directly from the hardware.
3088 ice_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc)
3090 struct ice_netdev_priv *np = netdev_priv(netdev);
3091 struct ice_vsi *vsi = np->vsi;
3092 struct ice_pf *pf = vsi->back;
3097 *hfunc = ETH_RSS_HASH_TOP;
3102 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
3103 /* RSS not supported return error here */
3104 netdev_warn(netdev, "RSS is not configured on this VSI!\n");
3108 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
3112 err = ice_get_rss_key(vsi, key);
3116 err = ice_get_rss_lut(vsi, lut, vsi->rss_table_size);
3120 for (i = 0; i < vsi->rss_table_size; i++)
3121 indir[i] = (u32)(lut[i]);
3129 * ice_set_rxfh - set the Rx flow hash indirection table
3130 * @netdev: network interface device structure
3131 * @indir: indirection table
3133 * @hfunc: hash function
3135 * Returns -EINVAL if the table specifies an invalid queue ID, otherwise
3136 * returns 0 after programming the table.
3139 ice_set_rxfh(struct net_device *netdev, const u32 *indir, const u8 *key,
3142 struct ice_netdev_priv *np = netdev_priv(netdev);
3143 struct ice_vsi *vsi = np->vsi;
3144 struct ice_pf *pf = vsi->back;
3148 dev = ice_pf_to_dev(pf);
3149 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
3152 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
3153 /* RSS not supported return error here */
3154 netdev_warn(netdev, "RSS is not configured on this VSI!\n");
3159 if (!vsi->rss_hkey_user) {
3160 vsi->rss_hkey_user =
3161 devm_kzalloc(dev, ICE_VSIQF_HKEY_ARRAY_SIZE,
3163 if (!vsi->rss_hkey_user)
3166 memcpy(vsi->rss_hkey_user, key, ICE_VSIQF_HKEY_ARRAY_SIZE);
3168 err = ice_set_rss_key(vsi, vsi->rss_hkey_user);
3173 if (!vsi->rss_lut_user) {
3174 vsi->rss_lut_user = devm_kzalloc(dev, vsi->rss_table_size,
3176 if (!vsi->rss_lut_user)
3180 /* Each 32 bits pointed by 'indir' is stored with a lut entry */
3184 for (i = 0; i < vsi->rss_table_size; i++)
3185 vsi->rss_lut_user[i] = (u8)(indir[i]);
3187 ice_fill_rss_lut(vsi->rss_lut_user, vsi->rss_table_size,
3191 err = ice_set_rss_lut(vsi, vsi->rss_lut_user, vsi->rss_table_size);
3199 ice_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
3201 struct ice_pf *pf = ice_netdev_to_pf(dev);
3203 /* only report timestamping if PTP is enabled */
3204 if (!test_bit(ICE_FLAG_PTP, pf->flags))
3205 return ethtool_op_get_ts_info(dev, info);
3207 info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
3208 SOF_TIMESTAMPING_RX_SOFTWARE |
3209 SOF_TIMESTAMPING_SOFTWARE |
3210 SOF_TIMESTAMPING_TX_HARDWARE |
3211 SOF_TIMESTAMPING_RX_HARDWARE |
3212 SOF_TIMESTAMPING_RAW_HARDWARE;
3214 info->phc_index = ice_get_ptp_clock_index(pf);
3216 info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON);
3218 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);
3224 * ice_get_max_txq - return the maximum number of Tx queues for in a PF
3227 static int ice_get_max_txq(struct ice_pf *pf)
3229 return min3(pf->num_lan_msix, (u16)num_online_cpus(),
3230 (u16)pf->hw.func_caps.common_cap.num_txq);
3234 * ice_get_max_rxq - return the maximum number of Rx queues for in a PF
3237 static int ice_get_max_rxq(struct ice_pf *pf)
3239 return min3(pf->num_lan_msix, (u16)num_online_cpus(),
3240 (u16)pf->hw.func_caps.common_cap.num_rxq);
3244 * ice_get_combined_cnt - return the current number of combined channels
3245 * @vsi: PF VSI pointer
3247 * Go through all queue vectors and count ones that have both Rx and Tx ring
3250 static u32 ice_get_combined_cnt(struct ice_vsi *vsi)
3255 ice_for_each_q_vector(vsi, q_idx) {
3256 struct ice_q_vector *q_vector = vsi->q_vectors[q_idx];
3258 if (q_vector->rx.ring && q_vector->tx.ring)
3266 * ice_get_channels - get the current and max supported channels
3267 * @dev: network interface device structure
3268 * @ch: ethtool channel data structure
3271 ice_get_channels(struct net_device *dev, struct ethtool_channels *ch)
3273 struct ice_netdev_priv *np = netdev_priv(dev);
3274 struct ice_vsi *vsi = np->vsi;
3275 struct ice_pf *pf = vsi->back;
3277 /* report maximum channels */
3278 ch->max_rx = ice_get_max_rxq(pf);
3279 ch->max_tx = ice_get_max_txq(pf);
3280 ch->max_combined = min_t(int, ch->max_rx, ch->max_tx);
3282 /* report current channels */
3283 ch->combined_count = ice_get_combined_cnt(vsi);
3284 ch->rx_count = vsi->num_rxq - ch->combined_count;
3285 ch->tx_count = vsi->num_txq - ch->combined_count;
3287 /* report other queues */
3288 ch->other_count = test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1 : 0;
3289 ch->max_other = ch->other_count;
3293 * ice_get_valid_rss_size - return valid number of RSS queues
3294 * @hw: pointer to the HW structure
3295 * @new_size: requested RSS queues
3297 static int ice_get_valid_rss_size(struct ice_hw *hw, int new_size)
3299 struct ice_hw_common_caps *caps = &hw->func_caps.common_cap;
3301 return min_t(int, new_size, BIT(caps->rss_table_entry_width));
3305 * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size
3306 * @vsi: VSI to reconfigure RSS LUT on
3307 * @req_rss_size: requested range of queue numbers for hashing
3309 * Set the VSI's RSS parameters, configure the RSS LUT based on these.
3311 static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)
3313 struct ice_pf *pf = vsi->back;
3319 dev = ice_pf_to_dev(pf);
3325 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
3329 /* set RSS LUT parameters */
3330 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags))
3333 vsi->rss_size = ice_get_valid_rss_size(hw, req_rss_size);
3335 /* create/set RSS LUT */
3336 ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);
3337 err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
3339 dev_err(dev, "Cannot set RSS lut, err %d aq_err %s\n", err,
3340 ice_aq_str(hw->adminq.sq_last_status));
3347 * ice_set_channels - set the number channels
3348 * @dev: network interface device structure
3349 * @ch: ethtool channel data structure
3351 static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
3353 struct ice_netdev_priv *np = netdev_priv(dev);
3354 struct ice_vsi *vsi = np->vsi;
3355 struct ice_pf *pf = vsi->back;
3356 int new_rx = 0, new_tx = 0;
3359 /* do not support changing channels in Safe Mode */
3360 if (ice_is_safe_mode(pf)) {
3361 netdev_err(dev, "Changing channel in Safe Mode is not supported\n");
3364 /* do not support changing other_count */
3365 if (ch->other_count != (test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1U : 0U))
3368 if (test_bit(ICE_FLAG_FD_ENA, pf->flags) && pf->hw.fdir_active_fltr) {
3369 netdev_err(dev, "Cannot set channels when Flow Director filters are active\n");
3373 curr_combined = ice_get_combined_cnt(vsi);
3375 /* these checks are for cases where user didn't specify a particular
3376 * value on cmd line but we get non-zero value anyway via
3377 * get_channels(); look at ethtool.c in ethtool repository (the user
3378 * space part), particularly, do_schannels() routine
3380 if (ch->rx_count == vsi->num_rxq - curr_combined)
3382 if (ch->tx_count == vsi->num_txq - curr_combined)
3384 if (ch->combined_count == curr_combined)
3385 ch->combined_count = 0;
3387 if (!(ch->combined_count || (ch->rx_count && ch->tx_count))) {
3388 netdev_err(dev, "Please specify at least 1 Rx and 1 Tx channel\n");
3392 new_rx = ch->combined_count + ch->rx_count;
3393 new_tx = ch->combined_count + ch->tx_count;
3395 if (new_rx > ice_get_max_rxq(pf)) {
3396 netdev_err(dev, "Maximum allowed Rx channels is %d\n",
3397 ice_get_max_rxq(pf));
3400 if (new_tx > ice_get_max_txq(pf)) {
3401 netdev_err(dev, "Maximum allowed Tx channels is %d\n",
3402 ice_get_max_txq(pf));
3406 ice_vsi_recfg_qs(vsi, new_rx, new_tx);
3408 if (!netif_is_rxfh_configured(dev))
3409 return ice_vsi_set_dflt_rss_lut(vsi, new_rx);
3411 /* Update rss_size due to change in Rx queues */
3412 vsi->rss_size = ice_get_valid_rss_size(&pf->hw, new_rx);
3418 * ice_get_wol - get current Wake on LAN configuration
3419 * @netdev: network interface device structure
3420 * @wol: Ethtool structure to retrieve WoL settings
3422 static void ice_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
3424 struct ice_netdev_priv *np = netdev_priv(netdev);
3425 struct ice_pf *pf = np->vsi->back;
3427 if (np->vsi->type != ICE_VSI_PF)
3428 netdev_warn(netdev, "Wake on LAN is not supported on this interface!\n");
3430 /* Get WoL settings based on the HW capability */
3431 if (ice_is_wol_supported(&pf->hw)) {
3432 wol->supported = WAKE_MAGIC;
3433 wol->wolopts = pf->wol_ena ? WAKE_MAGIC : 0;
3441 * ice_set_wol - set Wake on LAN on supported device
3442 * @netdev: network interface device structure
3443 * @wol: Ethtool structure to set WoL
3445 static int ice_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
3447 struct ice_netdev_priv *np = netdev_priv(netdev);
3448 struct ice_vsi *vsi = np->vsi;
3449 struct ice_pf *pf = vsi->back;
3451 if (vsi->type != ICE_VSI_PF || !ice_is_wol_supported(&pf->hw))
3454 /* only magic packet is supported */
3455 if (wol->wolopts && wol->wolopts != WAKE_MAGIC)
3458 /* Set WoL only if there is a new value */
3459 if (pf->wol_ena != !!wol->wolopts) {
3460 pf->wol_ena = !!wol->wolopts;
3461 device_set_wakeup_enable(ice_pf_to_dev(pf), pf->wol_ena);
3462 netdev_dbg(netdev, "WoL magic packet %sabled\n",
3463 pf->wol_ena ? "en" : "dis");
3469 enum ice_container_type {
3475 * ice_get_rc_coalesce - get ITR values for specific ring container
3476 * @ec: ethtool structure to fill with driver's coalesce settings
3477 * @c_type: container type, Rx or Tx
3478 * @rc: ring container that the ITR values will come from
3480 * Query the device for ice_ring_container specific ITR values. This is
3481 * done per ice_ring_container because each q_vector can have 1 or more rings
3482 * and all of said ring(s) will have the same ITR values.
3484 * Returns 0 on success, negative otherwise.
3487 ice_get_rc_coalesce(struct ethtool_coalesce *ec, enum ice_container_type c_type,
3488 struct ice_ring_container *rc)
3494 case ICE_RX_CONTAINER:
3495 ec->use_adaptive_rx_coalesce = ITR_IS_DYNAMIC(rc);
3496 ec->rx_coalesce_usecs = rc->itr_setting;
3497 ec->rx_coalesce_usecs_high = rc->ring->q_vector->intrl;
3499 case ICE_TX_CONTAINER:
3500 ec->use_adaptive_tx_coalesce = ITR_IS_DYNAMIC(rc);
3501 ec->tx_coalesce_usecs = rc->itr_setting;
3504 dev_dbg(ice_pf_to_dev(rc->ring->vsi->back), "Invalid c_type %d\n", c_type);
3512 * ice_get_q_coalesce - get a queue's ITR/INTRL (coalesce) settings
3513 * @vsi: VSI associated to the queue for getting ITR/INTRL (coalesce) settings
3514 * @ec: coalesce settings to program the device with
3515 * @q_num: update ITR/INTRL (coalesce) settings for this queue number/index
3517 * Return 0 on success, and negative under the following conditions:
3518 * 1. Getting Tx or Rx ITR/INTRL (coalesce) settings failed.
3519 * 2. The q_num passed in is not a valid number/index for Tx and Rx rings.
3522 ice_get_q_coalesce(struct ice_vsi *vsi, struct ethtool_coalesce *ec, int q_num)
3524 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) {
3525 if (ice_get_rc_coalesce(ec, ICE_RX_CONTAINER,
3526 &vsi->rx_rings[q_num]->q_vector->rx))
3528 if (ice_get_rc_coalesce(ec, ICE_TX_CONTAINER,
3529 &vsi->tx_rings[q_num]->q_vector->tx))
3531 } else if (q_num < vsi->num_rxq) {
3532 if (ice_get_rc_coalesce(ec, ICE_RX_CONTAINER,
3533 &vsi->rx_rings[q_num]->q_vector->rx))
3535 } else if (q_num < vsi->num_txq) {
3536 if (ice_get_rc_coalesce(ec, ICE_TX_CONTAINER,
3537 &vsi->tx_rings[q_num]->q_vector->tx))
3547 * __ice_get_coalesce - get ITR/INTRL values for the device
3548 * @netdev: pointer to the netdev associated with this query
3549 * @ec: ethtool structure to fill with driver's coalesce settings
3550 * @q_num: queue number to get the coalesce settings for
3552 * If the caller passes in a negative q_num then we return coalesce settings
3553 * based on queue number 0, else use the actual q_num passed in.
3556 __ice_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec,
3559 struct ice_netdev_priv *np = netdev_priv(netdev);
3560 struct ice_vsi *vsi = np->vsi;
3565 if (ice_get_q_coalesce(vsi, ec, q_num))
3571 static int ice_get_coalesce(struct net_device *netdev,
3572 struct ethtool_coalesce *ec,
3573 struct kernel_ethtool_coalesce *kernel_coal,
3574 struct netlink_ext_ack *extack)
3576 return __ice_get_coalesce(netdev, ec, -1);
3580 ice_get_per_q_coalesce(struct net_device *netdev, u32 q_num,
3581 struct ethtool_coalesce *ec)
3583 return __ice_get_coalesce(netdev, ec, q_num);
3587 * ice_set_rc_coalesce - set ITR values for specific ring container
3588 * @c_type: container type, Rx or Tx
3589 * @ec: ethtool structure from user to update ITR settings
3590 * @rc: ring container that the ITR values will come from
3591 * @vsi: VSI associated to the ring container
3593 * Set specific ITR values. This is done per ice_ring_container because each
3594 * q_vector can have 1 or more rings and all of said ring(s) will have the same
3597 * Returns 0 on success, negative otherwise.
3600 ice_set_rc_coalesce(enum ice_container_type c_type, struct ethtool_coalesce *ec,
3601 struct ice_ring_container *rc, struct ice_vsi *vsi)
3603 const char *c_type_str = (c_type == ICE_RX_CONTAINER) ? "rx" : "tx";
3604 u32 use_adaptive_coalesce, coalesce_usecs;
3605 struct ice_pf *pf = vsi->back;
3612 case ICE_RX_CONTAINER:
3613 if (ec->rx_coalesce_usecs_high > ICE_MAX_INTRL ||
3614 (ec->rx_coalesce_usecs_high &&
3615 ec->rx_coalesce_usecs_high < pf->hw.intrl_gran)) {
3616 netdev_info(vsi->netdev, "Invalid value, %s-usecs-high valid values are 0 (disabled), %d-%d\n",
3617 c_type_str, pf->hw.intrl_gran,
3621 if (ec->rx_coalesce_usecs_high != rc->ring->q_vector->intrl &&
3622 (ec->use_adaptive_rx_coalesce || ec->use_adaptive_tx_coalesce)) {
3623 netdev_info(vsi->netdev, "Invalid value, %s-usecs-high cannot be changed if adaptive-tx or adaptive-rx is enabled\n",
3627 if (ec->rx_coalesce_usecs_high != rc->ring->q_vector->intrl) {
3628 rc->ring->q_vector->intrl = ec->rx_coalesce_usecs_high;
3629 ice_write_intrl(rc->ring->q_vector,
3630 ec->rx_coalesce_usecs_high);
3633 use_adaptive_coalesce = ec->use_adaptive_rx_coalesce;
3634 coalesce_usecs = ec->rx_coalesce_usecs;
3637 case ICE_TX_CONTAINER:
3638 use_adaptive_coalesce = ec->use_adaptive_tx_coalesce;
3639 coalesce_usecs = ec->tx_coalesce_usecs;
3643 dev_dbg(ice_pf_to_dev(pf), "Invalid container type %d\n",
3648 itr_setting = rc->itr_setting;
3649 if (coalesce_usecs != itr_setting && use_adaptive_coalesce) {
3650 netdev_info(vsi->netdev, "%s interrupt throttling cannot be changed if adaptive-%s is enabled\n",
3651 c_type_str, c_type_str);
3655 if (coalesce_usecs > ICE_ITR_MAX) {
3656 netdev_info(vsi->netdev, "Invalid value, %s-usecs range is 0-%d\n",
3657 c_type_str, ICE_ITR_MAX);
3661 if (use_adaptive_coalesce) {
3662 rc->itr_mode = ITR_DYNAMIC;
3664 rc->itr_mode = ITR_STATIC;
3665 /* store user facing value how it was set */
3666 rc->itr_setting = coalesce_usecs;
3667 /* write the change to the register */
3668 ice_write_itr(rc, coalesce_usecs);
3669 /* force writes to take effect immediately, the flush shouldn't
3670 * be done in the functions above because the intent is for
3671 * them to do lazy writes.
3680 * ice_set_q_coalesce - set a queue's ITR/INTRL (coalesce) settings
3681 * @vsi: VSI associated to the queue that need updating
3682 * @ec: coalesce settings to program the device with
3683 * @q_num: update ITR/INTRL (coalesce) settings for this queue number/index
3685 * Return 0 on success, and negative under the following conditions:
3686 * 1. Setting Tx or Rx ITR/INTRL (coalesce) settings failed.
3687 * 2. The q_num passed in is not a valid number/index for Tx and Rx rings.
3690 ice_set_q_coalesce(struct ice_vsi *vsi, struct ethtool_coalesce *ec, int q_num)
3692 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) {
3693 if (ice_set_rc_coalesce(ICE_RX_CONTAINER, ec,
3694 &vsi->rx_rings[q_num]->q_vector->rx,
3698 if (ice_set_rc_coalesce(ICE_TX_CONTAINER, ec,
3699 &vsi->tx_rings[q_num]->q_vector->tx,
3702 } else if (q_num < vsi->num_rxq) {
3703 if (ice_set_rc_coalesce(ICE_RX_CONTAINER, ec,
3704 &vsi->rx_rings[q_num]->q_vector->rx,
3707 } else if (q_num < vsi->num_txq) {
3708 if (ice_set_rc_coalesce(ICE_TX_CONTAINER, ec,
3709 &vsi->tx_rings[q_num]->q_vector->tx,
3720 * ice_print_if_odd_usecs - print message if user tries to set odd [tx|rx]-usecs
3721 * @netdev: netdev used for print
3722 * @itr_setting: previous user setting
3723 * @use_adaptive_coalesce: if adaptive coalesce is enabled or being enabled
3724 * @coalesce_usecs: requested value of [tx|rx]-usecs
3725 * @c_type_str: either "rx" or "tx" to match user set field of [tx|rx]-usecs
3728 ice_print_if_odd_usecs(struct net_device *netdev, u16 itr_setting,
3729 u32 use_adaptive_coalesce, u32 coalesce_usecs,
3730 const char *c_type_str)
3732 if (use_adaptive_coalesce)
3735 if (itr_setting != coalesce_usecs && (coalesce_usecs % 2))
3736 netdev_info(netdev, "User set %s-usecs to %d, device only supports even values. Rounding down and attempting to set %s-usecs to %d\n",
3737 c_type_str, coalesce_usecs, c_type_str,
3738 ITR_REG_ALIGN(coalesce_usecs));
3742 * __ice_set_coalesce - set ITR/INTRL values for the device
3743 * @netdev: pointer to the netdev associated with this query
3744 * @ec: ethtool structure to fill with driver's coalesce settings
3745 * @q_num: queue number to get the coalesce settings for
3747 * If the caller passes in a negative q_num then we set the coalesce settings
3748 * for all Tx/Rx queues, else use the actual q_num passed in.
3751 __ice_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec,
3754 struct ice_netdev_priv *np = netdev_priv(netdev);
3755 struct ice_vsi *vsi = np->vsi;
3758 struct ice_q_vector *q_vector = vsi->q_vectors[0];
3762 ice_print_if_odd_usecs(netdev, q_vector->rx.itr_setting,
3763 ec->use_adaptive_rx_coalesce,
3764 ec->rx_coalesce_usecs, "rx");
3766 ice_print_if_odd_usecs(netdev, q_vector->tx.itr_setting,
3767 ec->use_adaptive_tx_coalesce,
3768 ec->tx_coalesce_usecs, "tx");
3771 ice_for_each_q_vector(vsi, v_idx) {
3772 /* In some cases if DCB is configured the num_[rx|tx]q
3773 * can be less than vsi->num_q_vectors. This check
3774 * accounts for that so we don't report a false failure
3776 if (v_idx >= vsi->num_rxq && v_idx >= vsi->num_txq)
3779 if (ice_set_q_coalesce(vsi, ec, v_idx))
3785 if (ice_set_q_coalesce(vsi, ec, q_num))
3792 static int ice_set_coalesce(struct net_device *netdev,
3793 struct ethtool_coalesce *ec,
3794 struct kernel_ethtool_coalesce *kernel_coal,
3795 struct netlink_ext_ack *extack)
3797 return __ice_set_coalesce(netdev, ec, -1);
3801 ice_set_per_q_coalesce(struct net_device *netdev, u32 q_num,
3802 struct ethtool_coalesce *ec)
3804 return __ice_set_coalesce(netdev, ec, q_num);
3807 #define ICE_I2C_EEPROM_DEV_ADDR 0xA0
3808 #define ICE_I2C_EEPROM_DEV_ADDR2 0xA2
3809 #define ICE_MODULE_TYPE_SFP 0x03
3810 #define ICE_MODULE_TYPE_QSFP_PLUS 0x0D
3811 #define ICE_MODULE_TYPE_QSFP28 0x11
3812 #define ICE_MODULE_SFF_ADDR_MODE 0x04
3813 #define ICE_MODULE_SFF_DIAG_CAPAB 0x40
3814 #define ICE_MODULE_REVISION_ADDR 0x01
3815 #define ICE_MODULE_SFF_8472_COMP 0x5E
3816 #define ICE_MODULE_SFF_8472_SWAP 0x5C
3817 #define ICE_MODULE_QSFP_MAX_LEN 640
3820 * ice_get_module_info - get SFF module type and revision information
3821 * @netdev: network interface device structure
3822 * @modinfo: module EEPROM size and layout information structure
3825 ice_get_module_info(struct net_device *netdev,
3826 struct ethtool_modinfo *modinfo)
3828 struct ice_netdev_priv *np = netdev_priv(netdev);
3829 struct ice_vsi *vsi = np->vsi;
3830 struct ice_pf *pf = vsi->back;
3831 struct ice_hw *hw = &pf->hw;
3832 enum ice_status status;
3833 u8 sff8472_comp = 0;
3834 u8 sff8472_swap = 0;
3838 status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR, 0x00, 0x00,
3839 0, &value, 1, 0, NULL);
3844 case ICE_MODULE_TYPE_SFP:
3845 status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR,
3846 ICE_MODULE_SFF_8472_COMP, 0x00, 0,
3847 &sff8472_comp, 1, 0, NULL);
3850 status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR,
3851 ICE_MODULE_SFF_8472_SWAP, 0x00, 0,
3852 &sff8472_swap, 1, 0, NULL);
3856 if (sff8472_swap & ICE_MODULE_SFF_ADDR_MODE) {
3857 modinfo->type = ETH_MODULE_SFF_8079;
3858 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
3859 } else if (sff8472_comp &&
3860 (sff8472_swap & ICE_MODULE_SFF_DIAG_CAPAB)) {
3861 modinfo->type = ETH_MODULE_SFF_8472;
3862 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
3864 modinfo->type = ETH_MODULE_SFF_8079;
3865 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
3868 case ICE_MODULE_TYPE_QSFP_PLUS:
3869 case ICE_MODULE_TYPE_QSFP28:
3870 status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR,
3871 ICE_MODULE_REVISION_ADDR, 0x00, 0,
3872 &sff8636_rev, 1, 0, NULL);
3875 /* Check revision compliance */
3876 if (sff8636_rev > 0x02) {
3877 /* Module is SFF-8636 compliant */
3878 modinfo->type = ETH_MODULE_SFF_8636;
3879 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN;
3881 modinfo->type = ETH_MODULE_SFF_8436;
3882 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN;
3886 netdev_warn(netdev, "SFF Module Type not recognized.\n");
3893 * ice_get_module_eeprom - fill buffer with SFF EEPROM contents
3894 * @netdev: network interface device structure
3895 * @ee: EEPROM dump request structure
3896 * @data: buffer to be filled with EEPROM contents
3899 ice_get_module_eeprom(struct net_device *netdev,
3900 struct ethtool_eeprom *ee, u8 *data)
3902 struct ice_netdev_priv *np = netdev_priv(netdev);
3903 #define SFF_READ_BLOCK_SIZE 8
3904 u8 value[SFF_READ_BLOCK_SIZE] = { 0 };
3905 u8 addr = ICE_I2C_EEPROM_DEV_ADDR;
3906 struct ice_vsi *vsi = np->vsi;
3907 struct ice_pf *pf = vsi->back;
3908 struct ice_hw *hw = &pf->hw;
3909 enum ice_status status;
3910 bool is_sfp = false;
3915 if (!ee || !ee->len || !data)
3918 status = ice_aq_sff_eeprom(hw, 0, addr, offset, page, 0, value, 1, 0,
3923 if (value[0] == ICE_MODULE_TYPE_SFP)
3926 memset(data, 0, ee->len);
3927 for (i = 0; i < ee->len; i += SFF_READ_BLOCK_SIZE) {
3928 offset = i + ee->offset;
3931 /* Check if we need to access the other memory page */
3933 if (offset >= ETH_MODULE_SFF_8079_LEN) {
3934 offset -= ETH_MODULE_SFF_8079_LEN;
3935 addr = ICE_I2C_EEPROM_DEV_ADDR2;
3938 while (offset >= ETH_MODULE_SFF_8436_LEN) {
3939 /* Compute memory page number and offset. */
3940 offset -= ETH_MODULE_SFF_8436_LEN / 2;
3945 /* Bit 2 of EEPROM address 0x02 declares upper
3946 * pages are disabled on QSFP modules.
3947 * SFP modules only ever use page 0.
3949 if (page == 0 || !(data[0x2] & 0x4)) {
3950 /* If i2c bus is busy due to slow page change or
3951 * link management access, call can fail. This is normal.
3952 * So we retry this a few times.
3954 for (j = 0; j < 4; j++) {
3955 status = ice_aq_sff_eeprom(hw, 0, addr, offset, page,
3957 SFF_READ_BLOCK_SIZE,
3959 netdev_dbg(netdev, "SFF %02X %02X %02X %X = %02X%02X%02X%02X.%02X%02X%02X%02X (%X)\n",
3960 addr, offset, page, is_sfp,
3961 value[0], value[1], value[2], value[3],
3962 value[4], value[5], value[6], value[7],
3965 usleep_range(1500, 2500);
3966 memset(value, 0, SFF_READ_BLOCK_SIZE);
3972 /* Make sure we have enough room for the new block */
3973 if ((i + SFF_READ_BLOCK_SIZE) < ee->len)
3974 memcpy(data + i, value, SFF_READ_BLOCK_SIZE);
3980 static const struct ethtool_ops ice_ethtool_ops = {
3981 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
3982 ETHTOOL_COALESCE_USE_ADAPTIVE |
3983 ETHTOOL_COALESCE_RX_USECS_HIGH,
3984 .get_link_ksettings = ice_get_link_ksettings,
3985 .set_link_ksettings = ice_set_link_ksettings,
3986 .get_drvinfo = ice_get_drvinfo,
3987 .get_regs_len = ice_get_regs_len,
3988 .get_regs = ice_get_regs,
3989 .get_wol = ice_get_wol,
3990 .set_wol = ice_set_wol,
3991 .get_msglevel = ice_get_msglevel,
3992 .set_msglevel = ice_set_msglevel,
3993 .self_test = ice_self_test,
3994 .get_link = ethtool_op_get_link,
3995 .get_eeprom_len = ice_get_eeprom_len,
3996 .get_eeprom = ice_get_eeprom,
3997 .get_coalesce = ice_get_coalesce,
3998 .set_coalesce = ice_set_coalesce,
3999 .get_strings = ice_get_strings,
4000 .set_phys_id = ice_set_phys_id,
4001 .get_ethtool_stats = ice_get_ethtool_stats,
4002 .get_priv_flags = ice_get_priv_flags,
4003 .set_priv_flags = ice_set_priv_flags,
4004 .get_sset_count = ice_get_sset_count,
4005 .get_rxnfc = ice_get_rxnfc,
4006 .set_rxnfc = ice_set_rxnfc,
4007 .get_ringparam = ice_get_ringparam,
4008 .set_ringparam = ice_set_ringparam,
4009 .nway_reset = ice_nway_reset,
4010 .get_pauseparam = ice_get_pauseparam,
4011 .set_pauseparam = ice_set_pauseparam,
4012 .get_rxfh_key_size = ice_get_rxfh_key_size,
4013 .get_rxfh_indir_size = ice_get_rxfh_indir_size,
4014 .get_rxfh = ice_get_rxfh,
4015 .set_rxfh = ice_set_rxfh,
4016 .get_channels = ice_get_channels,
4017 .set_channels = ice_set_channels,
4018 .get_ts_info = ice_get_ts_info,
4019 .get_per_queue_coalesce = ice_get_per_q_coalesce,
4020 .set_per_queue_coalesce = ice_set_per_q_coalesce,
4021 .get_fecparam = ice_get_fecparam,
4022 .set_fecparam = ice_set_fecparam,
4023 .get_module_info = ice_get_module_info,
4024 .get_module_eeprom = ice_get_module_eeprom,
4027 static const struct ethtool_ops ice_ethtool_safe_mode_ops = {
4028 .get_link_ksettings = ice_get_link_ksettings,
4029 .set_link_ksettings = ice_set_link_ksettings,
4030 .get_drvinfo = ice_get_drvinfo,
4031 .get_regs_len = ice_get_regs_len,
4032 .get_regs = ice_get_regs,
4033 .get_wol = ice_get_wol,
4034 .set_wol = ice_set_wol,
4035 .get_msglevel = ice_get_msglevel,
4036 .set_msglevel = ice_set_msglevel,
4037 .get_link = ethtool_op_get_link,
4038 .get_eeprom_len = ice_get_eeprom_len,
4039 .get_eeprom = ice_get_eeprom,
4040 .get_strings = ice_get_strings,
4041 .get_ethtool_stats = ice_get_ethtool_stats,
4042 .get_sset_count = ice_get_sset_count,
4043 .get_ringparam = ice_get_ringparam,
4044 .set_ringparam = ice_set_ringparam,
4045 .nway_reset = ice_nway_reset,
4046 .get_channels = ice_get_channels,
4050 * ice_set_ethtool_safe_mode_ops - setup safe mode ethtool ops
4051 * @netdev: network interface device structure
4053 void ice_set_ethtool_safe_mode_ops(struct net_device *netdev)
4055 netdev->ethtool_ops = &ice_ethtool_safe_mode_ops;
4059 * ice_set_ethtool_ops - setup netdev ethtool ops
4060 * @netdev: network interface device structure
4062 * setup netdev ethtool ops with ice specific ops
4064 void ice_set_ethtool_ops(struct net_device *netdev)
4066 netdev->ethtool_ops = &ice_ethtool_ops;