1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018, Intel Corporation. */
4 /* ethtool support for ice */
10 #include "ice_dcb_lib.h"
13 char stat_string[ETH_GSTRING_LEN];
18 #define ICE_STAT(_type, _name, _stat) { \
19 .stat_string = _name, \
20 .sizeof_stat = sizeof_field(_type, _stat), \
21 .stat_offset = offsetof(_type, _stat) \
24 #define ICE_VSI_STAT(_name, _stat) \
25 ICE_STAT(struct ice_vsi, _name, _stat)
26 #define ICE_PF_STAT(_name, _stat) \
27 ICE_STAT(struct ice_pf, _name, _stat)
29 static int ice_q_stats_len(struct net_device *netdev)
31 struct ice_netdev_priv *np = netdev_priv(netdev);
33 return ((np->vsi->alloc_txq + np->vsi->alloc_rxq) *
34 (sizeof(struct ice_q_stats) / sizeof(u64)));
37 #define ICE_PF_STATS_LEN ARRAY_SIZE(ice_gstrings_pf_stats)
38 #define ICE_VSI_STATS_LEN ARRAY_SIZE(ice_gstrings_vsi_stats)
40 #define ICE_PFC_STATS_LEN ( \
41 (sizeof_field(struct ice_pf, stats.priority_xoff_rx) + \
42 sizeof_field(struct ice_pf, stats.priority_xon_rx) + \
43 sizeof_field(struct ice_pf, stats.priority_xoff_tx) + \
44 sizeof_field(struct ice_pf, stats.priority_xon_tx)) \
46 #define ICE_ALL_STATS_LEN(n) (ICE_PF_STATS_LEN + ICE_PFC_STATS_LEN + \
47 ICE_VSI_STATS_LEN + ice_q_stats_len(n))
49 static const struct ice_stats ice_gstrings_vsi_stats[] = {
50 ICE_VSI_STAT("rx_unicast", eth_stats.rx_unicast),
51 ICE_VSI_STAT("tx_unicast", eth_stats.tx_unicast),
52 ICE_VSI_STAT("rx_multicast", eth_stats.rx_multicast),
53 ICE_VSI_STAT("tx_multicast", eth_stats.tx_multicast),
54 ICE_VSI_STAT("rx_broadcast", eth_stats.rx_broadcast),
55 ICE_VSI_STAT("tx_broadcast", eth_stats.tx_broadcast),
56 ICE_VSI_STAT("rx_bytes", eth_stats.rx_bytes),
57 ICE_VSI_STAT("tx_bytes", eth_stats.tx_bytes),
58 ICE_VSI_STAT("rx_dropped", eth_stats.rx_discards),
59 ICE_VSI_STAT("rx_unknown_protocol", eth_stats.rx_unknown_protocol),
60 ICE_VSI_STAT("rx_alloc_fail", rx_buf_failed),
61 ICE_VSI_STAT("rx_pg_alloc_fail", rx_page_failed),
62 ICE_VSI_STAT("rx_gro_dropped", rx_gro_dropped),
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;
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_ver, nvm->minor_ver,
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.nvm.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;
873 char *p = (char *)data;
878 for (i = 0; i < ICE_VSI_STATS_LEN; i++) {
879 snprintf(p, ETH_GSTRING_LEN, "%s",
880 ice_gstrings_vsi_stats[i].stat_string);
881 p += ETH_GSTRING_LEN;
884 ice_for_each_alloc_txq(vsi, i) {
885 snprintf(p, ETH_GSTRING_LEN,
886 "tx_queue_%u_packets", i);
887 p += ETH_GSTRING_LEN;
888 snprintf(p, ETH_GSTRING_LEN, "tx_queue_%u_bytes", i);
889 p += ETH_GSTRING_LEN;
892 ice_for_each_alloc_rxq(vsi, i) {
893 snprintf(p, ETH_GSTRING_LEN,
894 "rx_queue_%u_packets", i);
895 p += ETH_GSTRING_LEN;
896 snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_bytes", i);
897 p += ETH_GSTRING_LEN;
900 if (vsi->type != ICE_VSI_PF)
903 for (i = 0; i < ICE_PF_STATS_LEN; i++) {
904 snprintf(p, ETH_GSTRING_LEN, "%s",
905 ice_gstrings_pf_stats[i].stat_string);
906 p += ETH_GSTRING_LEN;
909 for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
910 snprintf(p, ETH_GSTRING_LEN,
911 "tx_priority_%u_xon.nic", i);
912 p += ETH_GSTRING_LEN;
913 snprintf(p, ETH_GSTRING_LEN,
914 "tx_priority_%u_xoff.nic", i);
915 p += ETH_GSTRING_LEN;
917 for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
918 snprintf(p, ETH_GSTRING_LEN,
919 "rx_priority_%u_xon.nic", i);
920 p += ETH_GSTRING_LEN;
921 snprintf(p, ETH_GSTRING_LEN,
922 "rx_priority_%u_xoff.nic", i);
923 p += ETH_GSTRING_LEN;
927 memcpy(data, ice_gstrings_test, ICE_TEST_LEN * ETH_GSTRING_LEN);
929 case ETH_SS_PRIV_FLAGS:
930 for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) {
931 snprintf(p, ETH_GSTRING_LEN, "%s",
932 ice_gstrings_priv_flags[i].name);
933 p += ETH_GSTRING_LEN;
942 ice_set_phys_id(struct net_device *netdev, enum ethtool_phys_id_state state)
944 struct ice_netdev_priv *np = netdev_priv(netdev);
948 case ETHTOOL_ID_ACTIVE:
951 case ETHTOOL_ID_INACTIVE:
958 if (ice_aq_set_port_id_led(np->vsi->port_info, !led_active, NULL))
965 * ice_set_fec_cfg - Set link FEC options
966 * @netdev: network interface device structure
967 * @req_fec: FEC mode to configure
969 static int ice_set_fec_cfg(struct net_device *netdev, enum ice_fec_mode req_fec)
971 struct ice_netdev_priv *np = netdev_priv(netdev);
972 struct ice_aqc_set_phy_cfg_data config = { 0 };
973 struct ice_vsi *vsi = np->vsi;
974 struct ice_port_info *pi;
980 /* Changing the FEC parameters is not supported if not the PF VSI */
981 if (vsi->type != ICE_VSI_PF) {
982 netdev_info(netdev, "Changing FEC parameters only supported for PF VSI\n");
986 /* Proceed only if requesting different FEC mode */
987 if (pi->phy.curr_user_fec_req == req_fec)
990 /* Copy the current user PHY configuration. The current user PHY
991 * configuration is initialized during probe from PHY capabilities
992 * software mode, and updated on set PHY configuration.
994 memcpy(&config, &pi->phy.curr_user_phy_cfg, sizeof(config));
996 ice_cfg_phy_fec(pi, &config, req_fec);
997 config.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
999 if (ice_aq_set_phy_cfg(pi->hw, pi, &config, NULL))
1002 /* Save requested FEC config */
1003 pi->phy.curr_user_fec_req = req_fec;
1009 * ice_set_fecparam - Set FEC link options
1010 * @netdev: network interface device structure
1011 * @fecparam: Ethtool structure to retrieve FEC parameters
1014 ice_set_fecparam(struct net_device *netdev, struct ethtool_fecparam *fecparam)
1016 struct ice_netdev_priv *np = netdev_priv(netdev);
1017 struct ice_vsi *vsi = np->vsi;
1018 enum ice_fec_mode fec;
1020 switch (fecparam->fec) {
1021 case ETHTOOL_FEC_AUTO:
1024 case ETHTOOL_FEC_RS:
1027 case ETHTOOL_FEC_BASER:
1028 fec = ICE_FEC_BASER;
1030 case ETHTOOL_FEC_OFF:
1031 case ETHTOOL_FEC_NONE:
1035 dev_warn(ice_pf_to_dev(vsi->back), "Unsupported FEC mode: %d\n",
1040 return ice_set_fec_cfg(netdev, fec);
1044 * ice_get_fecparam - Get link FEC options
1045 * @netdev: network interface device structure
1046 * @fecparam: Ethtool structure to retrieve FEC parameters
1049 ice_get_fecparam(struct net_device *netdev, struct ethtool_fecparam *fecparam)
1051 struct ice_netdev_priv *np = netdev_priv(netdev);
1052 struct ice_aqc_get_phy_caps_data *caps;
1053 struct ice_link_status *link_info;
1054 struct ice_vsi *vsi = np->vsi;
1055 struct ice_port_info *pi;
1056 enum ice_status status;
1059 pi = vsi->port_info;
1063 link_info = &pi->phy.link_info;
1065 /* Set FEC mode based on negotiated link info */
1066 switch (link_info->fec_info) {
1067 case ICE_AQ_LINK_25G_KR_FEC_EN:
1068 fecparam->active_fec = ETHTOOL_FEC_BASER;
1070 case ICE_AQ_LINK_25G_RS_528_FEC_EN:
1071 case ICE_AQ_LINK_25G_RS_544_FEC_EN:
1072 fecparam->active_fec = ETHTOOL_FEC_RS;
1075 fecparam->active_fec = ETHTOOL_FEC_OFF;
1079 caps = kzalloc(sizeof(*caps), GFP_KERNEL);
1083 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP,
1090 /* Set supported/configured FEC modes based on PHY capability */
1091 if (caps->caps & ICE_AQC_PHY_EN_AUTO_FEC)
1092 fecparam->fec |= ETHTOOL_FEC_AUTO;
1093 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN ||
1094 caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ ||
1095 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN ||
1096 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ)
1097 fecparam->fec |= ETHTOOL_FEC_BASER;
1098 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ ||
1099 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ ||
1100 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN)
1101 fecparam->fec |= ETHTOOL_FEC_RS;
1102 if (caps->link_fec_options == 0)
1103 fecparam->fec |= ETHTOOL_FEC_OFF;
1111 * ice_nway_reset - restart autonegotiation
1112 * @netdev: network interface device structure
1114 static int ice_nway_reset(struct net_device *netdev)
1116 struct ice_netdev_priv *np = netdev_priv(netdev);
1117 struct ice_vsi *vsi = np->vsi;
1118 struct ice_port_info *pi;
1119 enum ice_status status;
1121 pi = vsi->port_info;
1122 /* If VSI state is up, then restart autoneg with link up */
1123 if (!test_bit(__ICE_DOWN, vsi->back->state))
1124 status = ice_aq_set_link_restart_an(pi, true, NULL);
1126 status = ice_aq_set_link_restart_an(pi, false, NULL);
1129 netdev_info(netdev, "link restart failed, err %s aq_err %s\n",
1130 ice_stat_str(status),
1131 ice_aq_str(pi->hw->adminq.sq_last_status));
1139 * ice_get_priv_flags - report device private flags
1140 * @netdev: network interface device structure
1142 * The get string set count and the string set should be matched for each
1143 * flag returned. Add new strings for each flag to the ice_gstrings_priv_flags
1146 * Returns a u32 bitmap of flags.
1148 static u32 ice_get_priv_flags(struct net_device *netdev)
1150 struct ice_netdev_priv *np = netdev_priv(netdev);
1151 struct ice_vsi *vsi = np->vsi;
1152 struct ice_pf *pf = vsi->back;
1153 u32 i, ret_flags = 0;
1155 for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) {
1156 const struct ice_priv_flag *priv_flag;
1158 priv_flag = &ice_gstrings_priv_flags[i];
1160 if (test_bit(priv_flag->bitno, pf->flags))
1161 ret_flags |= BIT(i);
1168 * ice_set_priv_flags - set private flags
1169 * @netdev: network interface device structure
1170 * @flags: bit flags to be set
1172 static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
1174 struct ice_netdev_priv *np = netdev_priv(netdev);
1175 DECLARE_BITMAP(change_flags, ICE_PF_FLAGS_NBITS);
1176 DECLARE_BITMAP(orig_flags, ICE_PF_FLAGS_NBITS);
1177 struct ice_vsi *vsi = np->vsi;
1178 struct ice_pf *pf = vsi->back;
1183 if (flags > BIT(ICE_PRIV_FLAG_ARRAY_SIZE))
1186 dev = ice_pf_to_dev(pf);
1187 set_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags);
1189 bitmap_copy(orig_flags, pf->flags, ICE_PF_FLAGS_NBITS);
1190 for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) {
1191 const struct ice_priv_flag *priv_flag;
1193 priv_flag = &ice_gstrings_priv_flags[i];
1196 set_bit(priv_flag->bitno, pf->flags);
1198 clear_bit(priv_flag->bitno, pf->flags);
1201 bitmap_xor(change_flags, pf->flags, orig_flags, ICE_PF_FLAGS_NBITS);
1203 /* Do not allow change to link-down-on-close when Total Port Shutdown
1206 if (test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, change_flags) &&
1207 test_bit(ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags)) {
1208 dev_err(dev, "Setting link-down-on-close not supported on this port\n");
1209 set_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags);
1214 if (test_bit(ICE_FLAG_FW_LLDP_AGENT, change_flags)) {
1215 if (!test_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags)) {
1216 enum ice_status status;
1218 /* Disable FW LLDP engine */
1219 status = ice_cfg_lldp_mib_change(&pf->hw, false);
1221 /* If unregistering for LLDP events fails, this is
1222 * not an error state, as there shouldn't be any
1223 * events to respond to.
1226 dev_info(dev, "Failed to unreg for LLDP events\n");
1228 /* The AQ call to stop the FW LLDP agent will generate
1229 * an error if the agent is already stopped.
1231 status = ice_aq_stop_lldp(&pf->hw, true, true, NULL);
1233 dev_warn(dev, "Fail to stop LLDP agent\n");
1234 /* Use case for having the FW LLDP agent stopped
1235 * will likely not need DCB, so failure to init is
1236 * not a concern of ethtool
1238 status = ice_init_pf_dcb(pf, true);
1240 dev_warn(dev, "Fail to init DCB\n");
1242 enum ice_status status;
1243 bool dcbx_agent_status;
1245 /* AQ command to start FW LLDP agent will return an
1246 * error if the agent is already started
1248 status = ice_aq_start_lldp(&pf->hw, true, NULL);
1250 dev_warn(dev, "Fail to start LLDP Agent\n");
1252 /* AQ command to start FW DCBX agent will fail if
1253 * the agent is already started
1255 status = ice_aq_start_stop_dcbx(&pf->hw, true,
1259 dev_dbg(dev, "Failed to start FW DCBX\n");
1261 dev_info(dev, "FW DCBX agent is %s\n",
1262 dcbx_agent_status ? "ACTIVE" : "DISABLED");
1264 /* Failure to configure MIB change or init DCB is not
1265 * relevant to ethtool. Print notification that
1266 * registration/init failed but do not return error
1269 status = ice_init_pf_dcb(pf, true);
1271 dev_dbg(dev, "Fail to init DCB\n");
1273 /* Remove rule to direct LLDP packets to default VSI.
1274 * The FW LLDP engine will now be consuming them.
1276 ice_cfg_sw_lldp(vsi, false, false);
1278 /* Register for MIB change events */
1279 status = ice_cfg_lldp_mib_change(&pf->hw, true);
1281 dev_dbg(dev, "Fail to enable MIB change events\n");
1283 ice_nway_reset(netdev);
1286 if (test_bit(ICE_FLAG_LEGACY_RX, change_flags)) {
1287 /* down and up VSI so that changes of Rx cfg are reflected. */
1291 /* don't allow modification of this flag when a single VF is in
1292 * promiscuous mode because it's not supported
1294 if (test_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, change_flags) &&
1295 ice_is_any_vf_in_promisc(pf)) {
1296 dev_err(dev, "Changing vf-true-promisc-support flag while VF(s) are in promiscuous mode not supported\n");
1297 /* toggle bit back to previous state */
1298 change_bit(ICE_FLAG_VF_TRUE_PROMISC_ENA, pf->flags);
1302 clear_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags);
1306 static int ice_get_sset_count(struct net_device *netdev, int sset)
1310 /* The number (and order) of strings reported *must* remain
1311 * constant for a given netdevice. This function must not
1312 * report a different number based on run time parameters
1313 * (such as the number of queues in use, or the setting of
1314 * a private ethtool flag). This is due to the nature of the
1315 * ethtool stats API.
1317 * Userspace programs such as ethtool must make 3 separate
1318 * ioctl requests, one for size, one for the strings, and
1319 * finally one for the stats. Since these cross into
1320 * userspace, changes to the number or size could result in
1321 * undefined memory access or incorrect string<->value
1322 * correlations for statistics.
1324 * Even if it appears to be safe, changes to the size or
1325 * order of strings will suffer from race conditions and are
1328 return ICE_ALL_STATS_LEN(netdev);
1330 return ICE_TEST_LEN;
1331 case ETH_SS_PRIV_FLAGS:
1332 return ICE_PRIV_FLAG_ARRAY_SIZE;
1339 ice_get_ethtool_stats(struct net_device *netdev,
1340 struct ethtool_stats __always_unused *stats, u64 *data)
1342 struct ice_netdev_priv *np = netdev_priv(netdev);
1343 struct ice_vsi *vsi = np->vsi;
1344 struct ice_pf *pf = vsi->back;
1345 struct ice_ring *ring;
1350 ice_update_pf_stats(pf);
1351 ice_update_vsi_stats(vsi);
1353 for (j = 0; j < ICE_VSI_STATS_LEN; j++) {
1354 p = (char *)vsi + ice_gstrings_vsi_stats[j].stat_offset;
1355 data[i++] = (ice_gstrings_vsi_stats[j].sizeof_stat ==
1356 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1359 /* populate per queue stats */
1362 ice_for_each_alloc_txq(vsi, j) {
1363 ring = READ_ONCE(vsi->tx_rings[j]);
1365 data[i++] = ring->stats.pkts;
1366 data[i++] = ring->stats.bytes;
1373 ice_for_each_alloc_rxq(vsi, j) {
1374 ring = READ_ONCE(vsi->rx_rings[j]);
1376 data[i++] = ring->stats.pkts;
1377 data[i++] = ring->stats.bytes;
1386 if (vsi->type != ICE_VSI_PF)
1389 for (j = 0; j < ICE_PF_STATS_LEN; j++) {
1390 p = (char *)pf + ice_gstrings_pf_stats[j].stat_offset;
1391 data[i++] = (ice_gstrings_pf_stats[j].sizeof_stat ==
1392 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1395 for (j = 0; j < ICE_MAX_USER_PRIORITY; j++) {
1396 data[i++] = pf->stats.priority_xon_tx[j];
1397 data[i++] = pf->stats.priority_xoff_tx[j];
1400 for (j = 0; j < ICE_MAX_USER_PRIORITY; j++) {
1401 data[i++] = pf->stats.priority_xon_rx[j];
1402 data[i++] = pf->stats.priority_xoff_rx[j];
1406 #define ICE_PHY_TYPE_LOW_MASK_MIN_1G (ICE_PHY_TYPE_LOW_100BASE_TX | \
1407 ICE_PHY_TYPE_LOW_100M_SGMII)
1409 #define ICE_PHY_TYPE_LOW_MASK_MIN_25G (ICE_PHY_TYPE_LOW_MASK_MIN_1G | \
1410 ICE_PHY_TYPE_LOW_1000BASE_T | \
1411 ICE_PHY_TYPE_LOW_1000BASE_SX | \
1412 ICE_PHY_TYPE_LOW_1000BASE_LX | \
1413 ICE_PHY_TYPE_LOW_1000BASE_KX | \
1414 ICE_PHY_TYPE_LOW_1G_SGMII | \
1415 ICE_PHY_TYPE_LOW_2500BASE_T | \
1416 ICE_PHY_TYPE_LOW_2500BASE_X | \
1417 ICE_PHY_TYPE_LOW_2500BASE_KX | \
1418 ICE_PHY_TYPE_LOW_5GBASE_T | \
1419 ICE_PHY_TYPE_LOW_5GBASE_KR | \
1420 ICE_PHY_TYPE_LOW_10GBASE_T | \
1421 ICE_PHY_TYPE_LOW_10G_SFI_DA | \
1422 ICE_PHY_TYPE_LOW_10GBASE_SR | \
1423 ICE_PHY_TYPE_LOW_10GBASE_LR | \
1424 ICE_PHY_TYPE_LOW_10GBASE_KR_CR1 | \
1425 ICE_PHY_TYPE_LOW_10G_SFI_AOC_ACC | \
1426 ICE_PHY_TYPE_LOW_10G_SFI_C2C)
1428 #define ICE_PHY_TYPE_LOW_MASK_100G (ICE_PHY_TYPE_LOW_100GBASE_CR4 | \
1429 ICE_PHY_TYPE_LOW_100GBASE_SR4 | \
1430 ICE_PHY_TYPE_LOW_100GBASE_LR4 | \
1431 ICE_PHY_TYPE_LOW_100GBASE_KR4 | \
1432 ICE_PHY_TYPE_LOW_100G_CAUI4_AOC_ACC | \
1433 ICE_PHY_TYPE_LOW_100G_CAUI4 | \
1434 ICE_PHY_TYPE_LOW_100G_AUI4_AOC_ACC | \
1435 ICE_PHY_TYPE_LOW_100G_AUI4 | \
1436 ICE_PHY_TYPE_LOW_100GBASE_CR_PAM4 | \
1437 ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4 | \
1438 ICE_PHY_TYPE_LOW_100GBASE_CP2 | \
1439 ICE_PHY_TYPE_LOW_100GBASE_SR2 | \
1440 ICE_PHY_TYPE_LOW_100GBASE_DR)
1442 #define ICE_PHY_TYPE_HIGH_MASK_100G (ICE_PHY_TYPE_HIGH_100GBASE_KR2_PAM4 | \
1443 ICE_PHY_TYPE_HIGH_100G_CAUI2_AOC_ACC |\
1444 ICE_PHY_TYPE_HIGH_100G_CAUI2 | \
1445 ICE_PHY_TYPE_HIGH_100G_AUI2_AOC_ACC | \
1446 ICE_PHY_TYPE_HIGH_100G_AUI2)
1449 * ice_mask_min_supported_speeds
1450 * @phy_types_high: PHY type high
1451 * @phy_types_low: PHY type low to apply minimum supported speeds mask
1453 * Apply minimum supported speeds mask to PHY type low. These are the speeds
1454 * for ethtool supported link mode.
1457 void ice_mask_min_supported_speeds(u64 phy_types_high, u64 *phy_types_low)
1459 /* if QSFP connection with 100G speed, minimum supported speed is 25G */
1460 if (*phy_types_low & ICE_PHY_TYPE_LOW_MASK_100G ||
1461 phy_types_high & ICE_PHY_TYPE_HIGH_MASK_100G)
1462 *phy_types_low &= ~ICE_PHY_TYPE_LOW_MASK_MIN_25G;
1464 *phy_types_low &= ~ICE_PHY_TYPE_LOW_MASK_MIN_1G;
1467 #define ice_ethtool_advertise_link_mode(aq_link_speed, ethtool_link_mode) \
1469 if (req_speeds & (aq_link_speed) || \
1471 (adv_phy_type_lo & phy_type_mask_lo || \
1472 adv_phy_type_hi & phy_type_mask_hi))) \
1473 ethtool_link_ksettings_add_link_mode(ks, advertising,\
1474 ethtool_link_mode); \
1478 * ice_phy_type_to_ethtool - convert the phy_types to ethtool link modes
1479 * @netdev: network interface device structure
1480 * @ks: ethtool link ksettings struct to fill out
1483 ice_phy_type_to_ethtool(struct net_device *netdev,
1484 struct ethtool_link_ksettings *ks)
1486 struct ice_netdev_priv *np = netdev_priv(netdev);
1487 struct ice_vsi *vsi = np->vsi;
1488 struct ice_pf *pf = vsi->back;
1489 u64 phy_type_mask_lo = 0;
1490 u64 phy_type_mask_hi = 0;
1491 u64 adv_phy_type_lo = 0;
1492 u64 adv_phy_type_hi = 0;
1493 u64 phy_types_high = 0;
1494 u64 phy_types_low = 0;
1497 req_speeds = vsi->port_info->phy.link_info.req_speeds;
1499 /* Check if lenient mode is supported and enabled, or in strict mode.
1501 * In lenient mode the Supported link modes are the PHY types without
1502 * media. The Advertising link mode is either 1. the user requested
1503 * speed, 2. the override PHY mask, or 3. the PHY types with media.
1505 * In strict mode Supported link mode are the PHY type with media,
1506 * and Advertising link modes are the media PHY type or the speed
1507 * requested by user.
1509 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) {
1510 struct ice_link_default_override_tlv *ldo;
1512 ldo = &pf->link_dflt_override;
1513 phy_types_low = le64_to_cpu(pf->nvm_phy_type_lo);
1514 phy_types_high = le64_to_cpu(pf->nvm_phy_type_hi);
1516 ice_mask_min_supported_speeds(phy_types_high, &phy_types_low);
1518 /* If override enabled and PHY mask set, then
1519 * Advertising link mode is the intersection of the PHY
1520 * types without media and the override PHY mask.
1522 if (ldo->options & ICE_LINK_OVERRIDE_EN &&
1523 (ldo->phy_type_low || ldo->phy_type_high)) {
1525 le64_to_cpu(pf->nvm_phy_type_lo) &
1528 le64_to_cpu(pf->nvm_phy_type_hi) &
1532 phy_types_low = vsi->port_info->phy.phy_type_low;
1533 phy_types_high = vsi->port_info->phy.phy_type_high;
1536 /* If Advertising link mode PHY type is not using override PHY type,
1537 * then use PHY type with media.
1539 if (!adv_phy_type_lo && !adv_phy_type_hi) {
1540 adv_phy_type_lo = vsi->port_info->phy.phy_type_low;
1541 adv_phy_type_hi = vsi->port_info->phy.phy_type_high;
1544 ethtool_link_ksettings_zero_link_mode(ks, supported);
1545 ethtool_link_ksettings_zero_link_mode(ks, advertising);
1547 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100BASE_TX |
1548 ICE_PHY_TYPE_LOW_100M_SGMII;
1549 if (phy_types_low & phy_type_mask_lo) {
1550 ethtool_link_ksettings_add_link_mode(ks, supported,
1553 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100MB,
1557 phy_type_mask_lo = ICE_PHY_TYPE_LOW_1000BASE_T |
1558 ICE_PHY_TYPE_LOW_1G_SGMII;
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_1000BASE_KX;
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_1000MB,
1574 phy_type_mask_lo = ICE_PHY_TYPE_LOW_1000BASE_SX |
1575 ICE_PHY_TYPE_LOW_1000BASE_LX;
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_1000MB,
1583 phy_type_mask_lo = ICE_PHY_TYPE_LOW_2500BASE_T;
1584 if (phy_types_low & phy_type_mask_lo) {
1585 ethtool_link_ksettings_add_link_mode(ks, supported,
1587 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_2500MB,
1591 phy_type_mask_lo = ICE_PHY_TYPE_LOW_2500BASE_X |
1592 ICE_PHY_TYPE_LOW_2500BASE_KX;
1593 if (phy_types_low & phy_type_mask_lo) {
1594 ethtool_link_ksettings_add_link_mode(ks, supported,
1596 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_2500MB,
1600 phy_type_mask_lo = ICE_PHY_TYPE_LOW_5GBASE_T |
1601 ICE_PHY_TYPE_LOW_5GBASE_KR;
1602 if (phy_types_low & phy_type_mask_lo) {
1603 ethtool_link_ksettings_add_link_mode(ks, supported,
1605 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_5GB,
1609 phy_type_mask_lo = ICE_PHY_TYPE_LOW_10GBASE_T |
1610 ICE_PHY_TYPE_LOW_10G_SFI_DA |
1611 ICE_PHY_TYPE_LOW_10G_SFI_AOC_ACC |
1612 ICE_PHY_TYPE_LOW_10G_SFI_C2C;
1613 if (phy_types_low & phy_type_mask_lo) {
1614 ethtool_link_ksettings_add_link_mode(ks, supported,
1616 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_10GB,
1620 phy_type_mask_lo = ICE_PHY_TYPE_LOW_10GBASE_KR_CR1;
1621 if (phy_types_low & phy_type_mask_lo) {
1622 ethtool_link_ksettings_add_link_mode(ks, supported,
1624 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_10GB,
1628 phy_type_mask_lo = ICE_PHY_TYPE_LOW_10GBASE_SR;
1629 if (phy_types_low & phy_type_mask_lo) {
1630 ethtool_link_ksettings_add_link_mode(ks, supported,
1632 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_10GB,
1636 phy_type_mask_lo = ICE_PHY_TYPE_LOW_10GBASE_LR;
1637 if (phy_types_low & phy_type_mask_lo) {
1638 ethtool_link_ksettings_add_link_mode(ks, supported,
1640 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_10GB,
1644 phy_type_mask_lo = ICE_PHY_TYPE_LOW_25GBASE_T |
1645 ICE_PHY_TYPE_LOW_25GBASE_CR |
1646 ICE_PHY_TYPE_LOW_25GBASE_CR_S |
1647 ICE_PHY_TYPE_LOW_25GBASE_CR1 |
1648 ICE_PHY_TYPE_LOW_25G_AUI_AOC_ACC |
1649 ICE_PHY_TYPE_LOW_25G_AUI_C2C;
1650 if (phy_types_low & phy_type_mask_lo) {
1651 ethtool_link_ksettings_add_link_mode(ks, supported,
1653 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_25GB,
1657 phy_type_mask_lo = ICE_PHY_TYPE_LOW_25GBASE_SR |
1658 ICE_PHY_TYPE_LOW_25GBASE_LR;
1659 if (phy_types_low & phy_type_mask_lo) {
1660 ethtool_link_ksettings_add_link_mode(ks, supported,
1662 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_25GB,
1666 phy_type_mask_lo = ICE_PHY_TYPE_LOW_25GBASE_KR |
1667 ICE_PHY_TYPE_LOW_25GBASE_KR_S |
1668 ICE_PHY_TYPE_LOW_25GBASE_KR1;
1669 if (phy_types_low & phy_type_mask_lo) {
1670 ethtool_link_ksettings_add_link_mode(ks, supported,
1672 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_25GB,
1676 phy_type_mask_lo = ICE_PHY_TYPE_LOW_40GBASE_KR4;
1677 if (phy_types_low & phy_type_mask_lo) {
1678 ethtool_link_ksettings_add_link_mode(ks, supported,
1680 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_40GB,
1684 phy_type_mask_lo = ICE_PHY_TYPE_LOW_40GBASE_CR4 |
1685 ICE_PHY_TYPE_LOW_40G_XLAUI_AOC_ACC |
1686 ICE_PHY_TYPE_LOW_40G_XLAUI;
1687 if (phy_types_low & phy_type_mask_lo) {
1688 ethtool_link_ksettings_add_link_mode(ks, supported,
1690 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_40GB,
1694 phy_type_mask_lo = ICE_PHY_TYPE_LOW_40GBASE_SR4;
1695 if (phy_types_low & phy_type_mask_lo) {
1696 ethtool_link_ksettings_add_link_mode(ks, supported,
1698 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_40GB,
1702 phy_type_mask_lo = ICE_PHY_TYPE_LOW_40GBASE_LR4;
1703 if (phy_types_low & phy_type_mask_lo) {
1704 ethtool_link_ksettings_add_link_mode(ks, supported,
1706 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_40GB,
1710 phy_type_mask_lo = ICE_PHY_TYPE_LOW_50GBASE_CR2 |
1711 ICE_PHY_TYPE_LOW_50G_LAUI2_AOC_ACC |
1712 ICE_PHY_TYPE_LOW_50G_LAUI2 |
1713 ICE_PHY_TYPE_LOW_50G_AUI2_AOC_ACC |
1714 ICE_PHY_TYPE_LOW_50G_AUI2 |
1715 ICE_PHY_TYPE_LOW_50GBASE_CP |
1716 ICE_PHY_TYPE_LOW_50GBASE_SR |
1717 ICE_PHY_TYPE_LOW_50G_AUI1_AOC_ACC |
1718 ICE_PHY_TYPE_LOW_50G_AUI1;
1719 if (phy_types_low & phy_type_mask_lo) {
1720 ethtool_link_ksettings_add_link_mode(ks, supported,
1722 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_50GB,
1726 phy_type_mask_lo = ICE_PHY_TYPE_LOW_50GBASE_KR2 |
1727 ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4;
1728 if (phy_types_low & phy_type_mask_lo) {
1729 ethtool_link_ksettings_add_link_mode(ks, supported,
1731 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_50GB,
1735 phy_type_mask_lo = ICE_PHY_TYPE_LOW_50GBASE_SR2 |
1736 ICE_PHY_TYPE_LOW_50GBASE_LR2 |
1737 ICE_PHY_TYPE_LOW_50GBASE_FR |
1738 ICE_PHY_TYPE_LOW_50GBASE_LR;
1739 if (phy_types_low & phy_type_mask_lo) {
1740 ethtool_link_ksettings_add_link_mode(ks, supported,
1742 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_50GB,
1746 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100GBASE_CR4 |
1747 ICE_PHY_TYPE_LOW_100G_CAUI4_AOC_ACC |
1748 ICE_PHY_TYPE_LOW_100G_CAUI4 |
1749 ICE_PHY_TYPE_LOW_100G_AUI4_AOC_ACC |
1750 ICE_PHY_TYPE_LOW_100G_AUI4 |
1751 ICE_PHY_TYPE_LOW_100GBASE_CR_PAM4 |
1752 ICE_PHY_TYPE_LOW_100GBASE_CP2;
1753 phy_type_mask_hi = ICE_PHY_TYPE_HIGH_100G_CAUI2_AOC_ACC |
1754 ICE_PHY_TYPE_HIGH_100G_CAUI2 |
1755 ICE_PHY_TYPE_HIGH_100G_AUI2_AOC_ACC |
1756 ICE_PHY_TYPE_HIGH_100G_AUI2;
1757 if (phy_types_low & phy_type_mask_lo ||
1758 phy_types_high & phy_type_mask_hi) {
1759 ethtool_link_ksettings_add_link_mode(ks, supported,
1760 100000baseCR4_Full);
1761 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB,
1762 100000baseCR4_Full);
1765 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100GBASE_SR4 |
1766 ICE_PHY_TYPE_LOW_100GBASE_SR2;
1767 if (phy_types_low & phy_type_mask_lo) {
1768 ethtool_link_ksettings_add_link_mode(ks, supported,
1769 100000baseSR4_Full);
1770 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB,
1771 100000baseSR4_Full);
1774 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100GBASE_LR4 |
1775 ICE_PHY_TYPE_LOW_100GBASE_DR;
1776 if (phy_types_low & phy_type_mask_lo) {
1777 ethtool_link_ksettings_add_link_mode(ks, supported,
1778 100000baseLR4_ER4_Full);
1779 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB,
1780 100000baseLR4_ER4_Full);
1783 phy_type_mask_lo = ICE_PHY_TYPE_LOW_100GBASE_KR4 |
1784 ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4;
1785 phy_type_mask_hi = ICE_PHY_TYPE_HIGH_100GBASE_KR2_PAM4;
1786 if (phy_types_low & phy_type_mask_lo ||
1787 phy_types_high & phy_type_mask_hi) {
1788 ethtool_link_ksettings_add_link_mode(ks, supported,
1789 100000baseKR4_Full);
1790 ice_ethtool_advertise_link_mode(ICE_AQ_LINK_SPEED_100GB,
1791 100000baseKR4_Full);
1794 /* Autoneg PHY types */
1795 if (phy_types_low & ICE_PHY_TYPE_LOW_100BASE_TX ||
1796 phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_T ||
1797 phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_KX ||
1798 phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_T ||
1799 phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_KX ||
1800 phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_T ||
1801 phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_KR ||
1802 phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_T ||
1803 phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_KR_CR1 ||
1804 phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_T ||
1805 phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR ||
1806 phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR_S ||
1807 phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR1 ||
1808 phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR ||
1809 phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR_S ||
1810 phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR1 ||
1811 phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_CR4 ||
1812 phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_KR4) {
1813 ethtool_link_ksettings_add_link_mode(ks, supported,
1815 ethtool_link_ksettings_add_link_mode(ks, advertising,
1818 if (phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_CR2 ||
1819 phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_KR2 ||
1820 phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_CP ||
1821 phy_types_low & ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4) {
1822 ethtool_link_ksettings_add_link_mode(ks, supported,
1824 ethtool_link_ksettings_add_link_mode(ks, advertising,
1827 if (phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_CR4 ||
1828 phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_KR4 ||
1829 phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4 ||
1830 phy_types_low & ICE_PHY_TYPE_LOW_100GBASE_CP2) {
1831 ethtool_link_ksettings_add_link_mode(ks, supported,
1833 ethtool_link_ksettings_add_link_mode(ks, advertising,
1838 #define TEST_SET_BITS_TIMEOUT 50
1839 #define TEST_SET_BITS_SLEEP_MAX 2000
1840 #define TEST_SET_BITS_SLEEP_MIN 1000
1843 * ice_get_settings_link_up - Get Link settings for when link is up
1844 * @ks: ethtool ksettings to fill in
1845 * @netdev: network interface device structure
1848 ice_get_settings_link_up(struct ethtool_link_ksettings *ks,
1849 struct net_device *netdev)
1851 struct ice_netdev_priv *np = netdev_priv(netdev);
1852 struct ice_port_info *pi = np->vsi->port_info;
1853 struct ice_link_status *link_info;
1854 struct ice_vsi *vsi = np->vsi;
1856 link_info = &vsi->port_info->phy.link_info;
1858 /* Get supported and advertised settings from PHY ability with media */
1859 ice_phy_type_to_ethtool(netdev, ks);
1861 switch (link_info->link_speed) {
1862 case ICE_AQ_LINK_SPEED_100GB:
1863 ks->base.speed = SPEED_100000;
1865 case ICE_AQ_LINK_SPEED_50GB:
1866 ks->base.speed = SPEED_50000;
1868 case ICE_AQ_LINK_SPEED_40GB:
1869 ks->base.speed = SPEED_40000;
1871 case ICE_AQ_LINK_SPEED_25GB:
1872 ks->base.speed = SPEED_25000;
1874 case ICE_AQ_LINK_SPEED_20GB:
1875 ks->base.speed = SPEED_20000;
1877 case ICE_AQ_LINK_SPEED_10GB:
1878 ks->base.speed = SPEED_10000;
1880 case ICE_AQ_LINK_SPEED_5GB:
1881 ks->base.speed = SPEED_5000;
1883 case ICE_AQ_LINK_SPEED_2500MB:
1884 ks->base.speed = SPEED_2500;
1886 case ICE_AQ_LINK_SPEED_1000MB:
1887 ks->base.speed = SPEED_1000;
1889 case ICE_AQ_LINK_SPEED_100MB:
1890 ks->base.speed = SPEED_100;
1893 netdev_info(netdev, "WARNING: Unrecognized link_speed (0x%x).\n",
1894 link_info->link_speed);
1897 ks->base.duplex = DUPLEX_FULL;
1899 if (link_info->an_info & ICE_AQ_AN_COMPLETED)
1900 ethtool_link_ksettings_add_link_mode(ks, lp_advertising,
1903 /* Set flow control negotiated Rx/Tx pause */
1904 switch (pi->fc.current_mode) {
1906 ethtool_link_ksettings_add_link_mode(ks, lp_advertising, Pause);
1908 case ICE_FC_TX_PAUSE:
1909 ethtool_link_ksettings_add_link_mode(ks, lp_advertising, Pause);
1910 ethtool_link_ksettings_add_link_mode(ks, lp_advertising,
1913 case ICE_FC_RX_PAUSE:
1914 ethtool_link_ksettings_add_link_mode(ks, lp_advertising,
1919 ethtool_link_ksettings_del_link_mode(ks, lp_advertising, Pause);
1920 ethtool_link_ksettings_del_link_mode(ks, lp_advertising,
1927 * ice_get_settings_link_down - Get the Link settings when link is down
1928 * @ks: ethtool ksettings to fill in
1929 * @netdev: network interface device structure
1931 * Reports link settings that can be determined when link is down
1934 ice_get_settings_link_down(struct ethtool_link_ksettings *ks,
1935 struct net_device *netdev)
1937 /* link is down and the driver needs to fall back on
1938 * supported PHY types to figure out what info to display
1940 ice_phy_type_to_ethtool(netdev, ks);
1942 /* With no link, speed and duplex are unknown */
1943 ks->base.speed = SPEED_UNKNOWN;
1944 ks->base.duplex = DUPLEX_UNKNOWN;
1948 * ice_get_link_ksettings - Get Link Speed and Duplex settings
1949 * @netdev: network interface device structure
1950 * @ks: ethtool ksettings
1952 * Reports speed/duplex settings based on media_type
1955 ice_get_link_ksettings(struct net_device *netdev,
1956 struct ethtool_link_ksettings *ks)
1958 struct ice_netdev_priv *np = netdev_priv(netdev);
1959 struct ice_aqc_get_phy_caps_data *caps;
1960 struct ice_link_status *hw_link_info;
1961 struct ice_vsi *vsi = np->vsi;
1962 enum ice_status status;
1965 ethtool_link_ksettings_zero_link_mode(ks, supported);
1966 ethtool_link_ksettings_zero_link_mode(ks, advertising);
1967 ethtool_link_ksettings_zero_link_mode(ks, lp_advertising);
1968 hw_link_info = &vsi->port_info->phy.link_info;
1970 /* set speed and duplex */
1971 if (hw_link_info->link_info & ICE_AQ_LINK_UP)
1972 ice_get_settings_link_up(ks, netdev);
1974 ice_get_settings_link_down(ks, netdev);
1976 /* set autoneg settings */
1977 ks->base.autoneg = (hw_link_info->an_info & ICE_AQ_AN_COMPLETED) ?
1978 AUTONEG_ENABLE : AUTONEG_DISABLE;
1980 /* set media type settings */
1981 switch (vsi->port_info->phy.media_type) {
1982 case ICE_MEDIA_FIBER:
1983 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE);
1984 ks->base.port = PORT_FIBRE;
1986 case ICE_MEDIA_BASET:
1987 ethtool_link_ksettings_add_link_mode(ks, supported, TP);
1988 ethtool_link_ksettings_add_link_mode(ks, advertising, TP);
1989 ks->base.port = PORT_TP;
1991 case ICE_MEDIA_BACKPLANE:
1992 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);
1993 ethtool_link_ksettings_add_link_mode(ks, supported, Backplane);
1994 ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);
1995 ethtool_link_ksettings_add_link_mode(ks, advertising,
1997 ks->base.port = PORT_NONE;
2000 ethtool_link_ksettings_add_link_mode(ks, supported, FIBRE);
2001 ethtool_link_ksettings_add_link_mode(ks, advertising, FIBRE);
2002 ks->base.port = PORT_DA;
2005 ks->base.port = PORT_OTHER;
2009 /* flow control is symmetric and always supported */
2010 ethtool_link_ksettings_add_link_mode(ks, supported, Pause);
2012 caps = kzalloc(sizeof(*caps), GFP_KERNEL);
2016 status = ice_aq_get_phy_caps(vsi->port_info, false,
2017 ICE_AQC_REPORT_SW_CFG, caps, NULL);
2023 /* Set the advertised flow control based on the PHY capability */
2024 if ((caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) &&
2025 (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE)) {
2026 ethtool_link_ksettings_add_link_mode(ks, advertising, Pause);
2027 ethtool_link_ksettings_add_link_mode(ks, advertising,
2029 } else if (caps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) {
2030 ethtool_link_ksettings_add_link_mode(ks, advertising,
2032 } else if (caps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE) {
2033 ethtool_link_ksettings_add_link_mode(ks, advertising, Pause);
2034 ethtool_link_ksettings_add_link_mode(ks, advertising,
2037 ethtool_link_ksettings_del_link_mode(ks, advertising, Pause);
2038 ethtool_link_ksettings_del_link_mode(ks, advertising,
2042 /* Set advertised FEC modes based on PHY capability */
2043 ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_NONE);
2045 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ ||
2046 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ)
2047 ethtool_link_ksettings_add_link_mode(ks, advertising,
2049 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ ||
2050 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ)
2051 ethtool_link_ksettings_add_link_mode(ks, advertising, FEC_RS);
2053 status = ice_aq_get_phy_caps(vsi->port_info, false,
2054 ICE_AQC_REPORT_TOPO_CAP, caps, NULL);
2060 /* Set supported FEC modes based on PHY capability */
2061 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_NONE);
2063 if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN ||
2064 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN)
2065 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER);
2066 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN)
2067 ethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS);
2075 * ice_ksettings_find_adv_link_speed - Find advertising link speed
2076 * @ks: ethtool ksettings
2079 ice_ksettings_find_adv_link_speed(const struct ethtool_link_ksettings *ks)
2081 u16 adv_link_speed = 0;
2083 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2085 adv_link_speed |= ICE_AQ_LINK_SPEED_100MB;
2086 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2088 adv_link_speed |= ICE_AQ_LINK_SPEED_1000MB;
2089 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2091 ethtool_link_ksettings_test_link_mode(ks, advertising,
2093 adv_link_speed |= ICE_AQ_LINK_SPEED_1000MB;
2094 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2096 adv_link_speed |= ICE_AQ_LINK_SPEED_2500MB;
2097 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2099 adv_link_speed |= ICE_AQ_LINK_SPEED_2500MB;
2100 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2102 adv_link_speed |= ICE_AQ_LINK_SPEED_5GB;
2103 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2105 ethtool_link_ksettings_test_link_mode(ks, advertising,
2107 adv_link_speed |= ICE_AQ_LINK_SPEED_10GB;
2108 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2109 10000baseSR_Full) ||
2110 ethtool_link_ksettings_test_link_mode(ks, advertising,
2112 adv_link_speed |= ICE_AQ_LINK_SPEED_10GB;
2113 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2114 25000baseCR_Full) ||
2115 ethtool_link_ksettings_test_link_mode(ks, advertising,
2116 25000baseSR_Full) ||
2117 ethtool_link_ksettings_test_link_mode(ks, advertising,
2119 adv_link_speed |= ICE_AQ_LINK_SPEED_25GB;
2120 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2121 40000baseCR4_Full) ||
2122 ethtool_link_ksettings_test_link_mode(ks, advertising,
2123 40000baseSR4_Full) ||
2124 ethtool_link_ksettings_test_link_mode(ks, advertising,
2125 40000baseLR4_Full) ||
2126 ethtool_link_ksettings_test_link_mode(ks, advertising,
2128 adv_link_speed |= ICE_AQ_LINK_SPEED_40GB;
2129 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2130 50000baseCR2_Full) ||
2131 ethtool_link_ksettings_test_link_mode(ks, advertising,
2133 adv_link_speed |= ICE_AQ_LINK_SPEED_50GB;
2134 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2136 adv_link_speed |= ICE_AQ_LINK_SPEED_50GB;
2137 if (ethtool_link_ksettings_test_link_mode(ks, advertising,
2138 100000baseCR4_Full) ||
2139 ethtool_link_ksettings_test_link_mode(ks, advertising,
2140 100000baseSR4_Full) ||
2141 ethtool_link_ksettings_test_link_mode(ks, advertising,
2142 100000baseLR4_ER4_Full) ||
2143 ethtool_link_ksettings_test_link_mode(ks, advertising,
2144 100000baseKR4_Full))
2145 adv_link_speed |= ICE_AQ_LINK_SPEED_100GB;
2147 return adv_link_speed;
2153 * @ks: ethtool_link_ksettings
2154 * @config: configuration that will be sent down to FW
2155 * @autoneg_enabled: autonegotiation is enabled or not
2156 * @autoneg_changed: will there a change in autonegotiation
2157 * @netdev: network interface device structure
2159 * Setup PHY autonegotiation feature
2162 ice_setup_autoneg(struct ice_port_info *p, struct ethtool_link_ksettings *ks,
2163 struct ice_aqc_set_phy_cfg_data *config,
2164 u8 autoneg_enabled, u8 *autoneg_changed,
2165 struct net_device *netdev)
2169 *autoneg_changed = 0;
2172 if (autoneg_enabled == AUTONEG_ENABLE) {
2173 /* If autoneg was not already enabled */
2174 if (!(p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED)) {
2175 /* If autoneg is not supported, return error */
2176 if (!ethtool_link_ksettings_test_link_mode(ks,
2179 netdev_info(netdev, "Autoneg not supported on this phy.\n");
2182 /* Autoneg is allowed to change */
2183 config->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
2184 *autoneg_changed = 1;
2188 /* If autoneg is currently enabled */
2189 if (p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED) {
2190 /* If autoneg is supported 10GBASE_T is the only PHY
2191 * that can disable it, so otherwise return error
2193 if (ethtool_link_ksettings_test_link_mode(ks,
2196 netdev_info(netdev, "Autoneg cannot be disabled on this phy\n");
2199 /* Autoneg is allowed to change */
2200 config->caps &= ~ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
2201 *autoneg_changed = 1;
2210 * ice_set_link_ksettings - Set Speed and Duplex
2211 * @netdev: network interface device structure
2212 * @ks: ethtool ksettings
2214 * Set speed/duplex per media_types advertised/forced
2217 ice_set_link_ksettings(struct net_device *netdev,
2218 const struct ethtool_link_ksettings *ks)
2220 struct ice_netdev_priv *np = netdev_priv(netdev);
2221 struct ethtool_link_ksettings safe_ks, copy_ks;
2222 struct ice_aqc_get_phy_caps_data *abilities;
2223 u8 autoneg, timeout = TEST_SET_BITS_TIMEOUT;
2224 u16 adv_link_speed, curr_link_speed, idx;
2225 struct ice_aqc_set_phy_cfg_data config;
2226 struct ice_pf *pf = np->vsi->back;
2227 struct ice_port_info *p;
2228 u8 autoneg_changed = 0;
2229 enum ice_status status;
2230 u64 phy_type_high = 0;
2231 u64 phy_type_low = 0;
2235 p = np->vsi->port_info;
2240 /* Check if this is LAN VSI */
2241 ice_for_each_vsi(pf, idx)
2242 if (pf->vsi[idx]->type == ICE_VSI_PF) {
2243 if (np->vsi != pf->vsi[idx])
2248 if (p->phy.media_type != ICE_MEDIA_BASET &&
2249 p->phy.media_type != ICE_MEDIA_FIBER &&
2250 p->phy.media_type != ICE_MEDIA_BACKPLANE &&
2251 p->phy.media_type != ICE_MEDIA_DA &&
2252 p->phy.link_info.link_info & ICE_AQ_LINK_UP)
2255 abilities = kzalloc(sizeof(*abilities), GFP_KERNEL);
2259 /* Get the PHY capabilities based on media */
2260 status = ice_aq_get_phy_caps(p, false, ICE_AQC_REPORT_TOPO_CAP,
2267 /* copy the ksettings to copy_ks to avoid modifying the original */
2268 memcpy(©_ks, ks, sizeof(copy_ks));
2270 /* save autoneg out of ksettings */
2271 autoneg = copy_ks.base.autoneg;
2273 memset(&safe_ks, 0, sizeof(safe_ks));
2275 /* Get link modes supported by hardware.*/
2276 ice_phy_type_to_ethtool(netdev, &safe_ks);
2278 /* and check against modes requested by user.
2279 * Return an error if unsupported mode was set.
2281 if (!bitmap_subset(copy_ks.link_modes.advertising,
2282 safe_ks.link_modes.supported,
2283 __ETHTOOL_LINK_MODE_MASK_NBITS)) {
2284 if (!test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags))
2285 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");
2290 /* get our own copy of the bits to check against */
2291 memset(&safe_ks, 0, sizeof(safe_ks));
2292 safe_ks.base.cmd = copy_ks.base.cmd;
2293 safe_ks.base.link_mode_masks_nwords =
2294 copy_ks.base.link_mode_masks_nwords;
2295 ice_get_link_ksettings(netdev, &safe_ks);
2297 /* set autoneg back to what it currently is */
2298 copy_ks.base.autoneg = safe_ks.base.autoneg;
2299 /* we don't compare the speed */
2300 copy_ks.base.speed = safe_ks.base.speed;
2302 /* If copy_ks.base and safe_ks.base are not the same now, then they are
2303 * trying to set something that we do not support.
2305 if (memcmp(©_ks.base, &safe_ks.base, sizeof(copy_ks.base))) {
2310 while (test_and_set_bit(__ICE_CFG_BUSY, pf->state)) {
2316 usleep_range(TEST_SET_BITS_SLEEP_MIN, TEST_SET_BITS_SLEEP_MAX);
2319 /* Copy the current user PHY configuration. The current user PHY
2320 * configuration is initialized during probe from PHY capabilities
2321 * software mode, and updated on set PHY configuration.
2323 memcpy(&config, &p->phy.curr_user_phy_cfg, sizeof(config));
2325 config.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;
2328 err = ice_setup_autoneg(p, &safe_ks, &config, autoneg, &autoneg_changed,
2334 /* Call to get the current link speed */
2335 p->phy.get_link_info = true;
2336 status = ice_get_link_status(p, &linkup);
2342 curr_link_speed = p->phy.link_info.link_speed;
2343 adv_link_speed = ice_ksettings_find_adv_link_speed(ks);
2345 /* If speed didn't get set, set it to what it currently is.
2346 * This is needed because if advertise is 0 (as it is when autoneg
2347 * is disabled) then speed won't get set.
2349 if (!adv_link_speed)
2350 adv_link_speed = curr_link_speed;
2352 /* Convert the advertise link speeds to their corresponded PHY_TYPE */
2353 ice_update_phy_type(&phy_type_low, &phy_type_high, adv_link_speed);
2355 if (!autoneg_changed && adv_link_speed == curr_link_speed) {
2356 netdev_info(netdev, "Nothing changed, exiting without setting anything.\n");
2360 /* save the requested speeds */
2361 p->phy.link_info.req_speeds = adv_link_speed;
2363 /* set link and auto negotiation so changes take effect */
2364 config.caps |= ICE_AQ_PHY_ENA_LINK;
2366 /* check if there is a PHY type for the requested advertised speed */
2367 if (!(phy_type_low || phy_type_high)) {
2368 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");
2373 /* intersect requested advertised speed PHY types with media PHY types
2374 * for set PHY configuration
2376 config.phy_type_high = cpu_to_le64(phy_type_high) &
2377 abilities->phy_type_high;
2378 config.phy_type_low = cpu_to_le64(phy_type_low) &
2379 abilities->phy_type_low;
2381 if (!(config.phy_type_high || config.phy_type_low)) {
2382 /* If there is no intersection and lenient mode is enabled, then
2383 * intersect the requested advertised speed with NVM media type
2386 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags)) {
2387 config.phy_type_high = cpu_to_le64(phy_type_high) &
2388 pf->nvm_phy_type_hi;
2389 config.phy_type_low = cpu_to_le64(phy_type_low) &
2390 pf->nvm_phy_type_lo;
2392 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");
2398 /* If link is up put link down */
2399 if (p->phy.link_info.link_info & ICE_AQ_LINK_UP) {
2400 /* Tell the OS link is going down, the link will go
2401 * back up when fw says it is ready asynchronously
2403 ice_print_link_msg(np->vsi, false);
2404 netif_carrier_off(netdev);
2405 netif_tx_stop_all_queues(netdev);
2408 /* make the aq call */
2409 status = ice_aq_set_phy_cfg(&pf->hw, p, &config, NULL);
2411 netdev_info(netdev, "Set phy config failed,\n");
2416 /* Save speed request */
2417 p->phy.curr_user_speed_req = adv_link_speed;
2420 clear_bit(__ICE_CFG_BUSY, pf->state);
2426 * ice_parse_hdrs - parses headers from RSS hash input
2427 * @nfc: ethtool rxnfc command
2429 * This function parses the rxnfc command and returns intended
2430 * header types for RSS configuration
2432 static u32 ice_parse_hdrs(struct ethtool_rxnfc *nfc)
2434 u32 hdrs = ICE_FLOW_SEG_HDR_NONE;
2436 switch (nfc->flow_type) {
2438 hdrs |= ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV4;
2441 hdrs |= ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV4;
2444 hdrs |= ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV4;
2447 hdrs |= ICE_FLOW_SEG_HDR_TCP | ICE_FLOW_SEG_HDR_IPV6;
2450 hdrs |= ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV6;
2453 hdrs |= ICE_FLOW_SEG_HDR_SCTP | ICE_FLOW_SEG_HDR_IPV6;
2461 #define ICE_FLOW_HASH_FLD_IPV4_SA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)
2462 #define ICE_FLOW_HASH_FLD_IPV6_SA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)
2463 #define ICE_FLOW_HASH_FLD_IPV4_DA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)
2464 #define ICE_FLOW_HASH_FLD_IPV6_DA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)
2465 #define ICE_FLOW_HASH_FLD_TCP_SRC_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)
2466 #define ICE_FLOW_HASH_FLD_TCP_DST_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)
2467 #define ICE_FLOW_HASH_FLD_UDP_SRC_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)
2468 #define ICE_FLOW_HASH_FLD_UDP_DST_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)
2469 #define ICE_FLOW_HASH_FLD_SCTP_SRC_PORT \
2470 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)
2471 #define ICE_FLOW_HASH_FLD_SCTP_DST_PORT \
2472 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)
2475 * ice_parse_hash_flds - parses hash fields from RSS hash input
2476 * @nfc: ethtool rxnfc command
2478 * This function parses the rxnfc command and returns intended
2479 * hash fields for RSS configuration
2481 static u64 ice_parse_hash_flds(struct ethtool_rxnfc *nfc)
2483 u64 hfld = ICE_HASH_INVALID;
2485 if (nfc->data & RXH_IP_SRC || nfc->data & RXH_IP_DST) {
2486 switch (nfc->flow_type) {
2490 if (nfc->data & RXH_IP_SRC)
2491 hfld |= ICE_FLOW_HASH_FLD_IPV4_SA;
2492 if (nfc->data & RXH_IP_DST)
2493 hfld |= ICE_FLOW_HASH_FLD_IPV4_DA;
2498 if (nfc->data & RXH_IP_SRC)
2499 hfld |= ICE_FLOW_HASH_FLD_IPV6_SA;
2500 if (nfc->data & RXH_IP_DST)
2501 hfld |= ICE_FLOW_HASH_FLD_IPV6_DA;
2508 if (nfc->data & RXH_L4_B_0_1 || nfc->data & RXH_L4_B_2_3) {
2509 switch (nfc->flow_type) {
2512 if (nfc->data & RXH_L4_B_0_1)
2513 hfld |= ICE_FLOW_HASH_FLD_TCP_SRC_PORT;
2514 if (nfc->data & RXH_L4_B_2_3)
2515 hfld |= ICE_FLOW_HASH_FLD_TCP_DST_PORT;
2519 if (nfc->data & RXH_L4_B_0_1)
2520 hfld |= ICE_FLOW_HASH_FLD_UDP_SRC_PORT;
2521 if (nfc->data & RXH_L4_B_2_3)
2522 hfld |= ICE_FLOW_HASH_FLD_UDP_DST_PORT;
2526 if (nfc->data & RXH_L4_B_0_1)
2527 hfld |= ICE_FLOW_HASH_FLD_SCTP_SRC_PORT;
2528 if (nfc->data & RXH_L4_B_2_3)
2529 hfld |= ICE_FLOW_HASH_FLD_SCTP_DST_PORT;
2540 * ice_set_rss_hash_opt - Enable/Disable flow types for RSS hash
2541 * @vsi: the VSI being configured
2542 * @nfc: ethtool rxnfc command
2544 * Returns Success if the flow input set is supported.
2547 ice_set_rss_hash_opt(struct ice_vsi *vsi, struct ethtool_rxnfc *nfc)
2549 struct ice_pf *pf = vsi->back;
2550 enum ice_status status;
2555 dev = ice_pf_to_dev(pf);
2556 if (ice_is_safe_mode(pf)) {
2557 dev_dbg(dev, "Advanced RSS disabled. Package download failed, vsi num = %d\n",
2562 hashed_flds = ice_parse_hash_flds(nfc);
2563 if (hashed_flds == ICE_HASH_INVALID) {
2564 dev_dbg(dev, "Invalid hash fields, vsi num = %d\n",
2569 hdrs = ice_parse_hdrs(nfc);
2570 if (hdrs == ICE_FLOW_SEG_HDR_NONE) {
2571 dev_dbg(dev, "Header type is not valid, vsi num = %d\n",
2576 status = ice_add_rss_cfg(&pf->hw, vsi->idx, hashed_flds, hdrs);
2578 dev_dbg(dev, "ice_add_rss_cfg failed, vsi num = %d, error = %s\n",
2579 vsi->vsi_num, ice_stat_str(status));
2587 * ice_get_rss_hash_opt - Retrieve hash fields for a given flow-type
2588 * @vsi: the VSI being configured
2589 * @nfc: ethtool rxnfc command
2592 ice_get_rss_hash_opt(struct ice_vsi *vsi, struct ethtool_rxnfc *nfc)
2594 struct ice_pf *pf = vsi->back;
2599 dev = ice_pf_to_dev(pf);
2602 if (ice_is_safe_mode(pf)) {
2603 dev_dbg(dev, "Advanced RSS disabled. Package download failed, vsi num = %d\n",
2608 hdrs = ice_parse_hdrs(nfc);
2609 if (hdrs == ICE_FLOW_SEG_HDR_NONE) {
2610 dev_dbg(dev, "Header type is not valid, vsi num = %d\n",
2615 hash_flds = ice_get_rss_cfg(&pf->hw, vsi->idx, hdrs);
2616 if (hash_flds == ICE_HASH_INVALID) {
2617 dev_dbg(dev, "No hash fields found for the given header type, vsi num = %d\n",
2622 if (hash_flds & ICE_FLOW_HASH_FLD_IPV4_SA ||
2623 hash_flds & ICE_FLOW_HASH_FLD_IPV6_SA)
2624 nfc->data |= (u64)RXH_IP_SRC;
2626 if (hash_flds & ICE_FLOW_HASH_FLD_IPV4_DA ||
2627 hash_flds & ICE_FLOW_HASH_FLD_IPV6_DA)
2628 nfc->data |= (u64)RXH_IP_DST;
2630 if (hash_flds & ICE_FLOW_HASH_FLD_TCP_SRC_PORT ||
2631 hash_flds & ICE_FLOW_HASH_FLD_UDP_SRC_PORT ||
2632 hash_flds & ICE_FLOW_HASH_FLD_SCTP_SRC_PORT)
2633 nfc->data |= (u64)RXH_L4_B_0_1;
2635 if (hash_flds & ICE_FLOW_HASH_FLD_TCP_DST_PORT ||
2636 hash_flds & ICE_FLOW_HASH_FLD_UDP_DST_PORT ||
2637 hash_flds & ICE_FLOW_HASH_FLD_SCTP_DST_PORT)
2638 nfc->data |= (u64)RXH_L4_B_2_3;
2642 * ice_set_rxnfc - command to set Rx flow rules.
2643 * @netdev: network interface device structure
2644 * @cmd: ethtool rxnfc command
2646 * Returns 0 for success and negative values for errors
2648 static int ice_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
2650 struct ice_netdev_priv *np = netdev_priv(netdev);
2651 struct ice_vsi *vsi = np->vsi;
2654 case ETHTOOL_SRXCLSRLINS:
2655 return ice_add_fdir_ethtool(vsi, cmd);
2656 case ETHTOOL_SRXCLSRLDEL:
2657 return ice_del_fdir_ethtool(vsi, cmd);
2659 return ice_set_rss_hash_opt(vsi, cmd);
2667 * ice_get_rxnfc - command to get Rx flow classification rules
2668 * @netdev: network interface device structure
2669 * @cmd: ethtool rxnfc command
2670 * @rule_locs: buffer to rturn Rx flow classification rules
2672 * Returns Success if the command is supported.
2675 ice_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
2676 u32 __always_unused *rule_locs)
2678 struct ice_netdev_priv *np = netdev_priv(netdev);
2679 struct ice_vsi *vsi = np->vsi;
2680 int ret = -EOPNOTSUPP;
2683 hw = &vsi->back->hw;
2686 case ETHTOOL_GRXRINGS:
2687 cmd->data = vsi->rss_size;
2690 case ETHTOOL_GRXCLSRLCNT:
2691 cmd->rule_cnt = hw->fdir_active_fltr;
2692 /* report total rule count */
2693 cmd->data = ice_get_fdir_cnt_all(hw);
2696 case ETHTOOL_GRXCLSRULE:
2697 ret = ice_get_ethtool_fdir_entry(hw, cmd);
2699 case ETHTOOL_GRXCLSRLALL:
2700 ret = ice_get_fdir_fltr_ids(hw, cmd, (u32 *)rule_locs);
2703 ice_get_rss_hash_opt(vsi, cmd);
2714 ice_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
2716 struct ice_netdev_priv *np = netdev_priv(netdev);
2717 struct ice_vsi *vsi = np->vsi;
2719 ring->rx_max_pending = ICE_MAX_NUM_DESC;
2720 ring->tx_max_pending = ICE_MAX_NUM_DESC;
2721 ring->rx_pending = vsi->rx_rings[0]->count;
2722 ring->tx_pending = vsi->tx_rings[0]->count;
2724 /* Rx mini and jumbo rings are not supported */
2725 ring->rx_mini_max_pending = 0;
2726 ring->rx_jumbo_max_pending = 0;
2727 ring->rx_mini_pending = 0;
2728 ring->rx_jumbo_pending = 0;
2732 ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)
2734 struct ice_ring *tx_rings = NULL, *rx_rings = NULL;
2735 struct ice_netdev_priv *np = netdev_priv(netdev);
2736 struct ice_ring *xdp_rings = NULL;
2737 struct ice_vsi *vsi = np->vsi;
2738 struct ice_pf *pf = vsi->back;
2739 int i, timeout = 50, err = 0;
2740 u16 new_rx_cnt, new_tx_cnt;
2742 if (ring->tx_pending > ICE_MAX_NUM_DESC ||
2743 ring->tx_pending < ICE_MIN_NUM_DESC ||
2744 ring->rx_pending > ICE_MAX_NUM_DESC ||
2745 ring->rx_pending < ICE_MIN_NUM_DESC) {
2746 netdev_err(netdev, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d] (increment %d)\n",
2747 ring->tx_pending, ring->rx_pending,
2748 ICE_MIN_NUM_DESC, ICE_MAX_NUM_DESC,
2749 ICE_REQ_DESC_MULTIPLE);
2753 new_tx_cnt = ALIGN(ring->tx_pending, ICE_REQ_DESC_MULTIPLE);
2754 if (new_tx_cnt != ring->tx_pending)
2755 netdev_info(netdev, "Requested Tx descriptor count rounded up to %d\n",
2757 new_rx_cnt = ALIGN(ring->rx_pending, ICE_REQ_DESC_MULTIPLE);
2758 if (new_rx_cnt != ring->rx_pending)
2759 netdev_info(netdev, "Requested Rx descriptor count rounded up to %d\n",
2762 /* if nothing to do return success */
2763 if (new_tx_cnt == vsi->tx_rings[0]->count &&
2764 new_rx_cnt == vsi->rx_rings[0]->count) {
2765 netdev_dbg(netdev, "Nothing to change, descriptor count is same as requested\n");
2769 /* If there is a AF_XDP UMEM attached to any of Rx rings,
2770 * disallow changing the number of descriptors -- regardless
2771 * if the netdev is running or not.
2773 if (ice_xsk_any_rx_ring_ena(vsi))
2776 while (test_and_set_bit(__ICE_CFG_BUSY, pf->state)) {
2780 usleep_range(1000, 2000);
2783 /* set for the next time the netdev is started */
2784 if (!netif_running(vsi->netdev)) {
2785 for (i = 0; i < vsi->alloc_txq; i++)
2786 vsi->tx_rings[i]->count = new_tx_cnt;
2787 for (i = 0; i < vsi->alloc_rxq; i++)
2788 vsi->rx_rings[i]->count = new_rx_cnt;
2789 if (ice_is_xdp_ena_vsi(vsi))
2790 for (i = 0; i < vsi->num_xdp_txq; i++)
2791 vsi->xdp_rings[i]->count = new_tx_cnt;
2792 vsi->num_tx_desc = (u16)new_tx_cnt;
2793 vsi->num_rx_desc = (u16)new_rx_cnt;
2794 netdev_dbg(netdev, "Link is down, descriptor count change happens when link is brought up\n");
2798 if (new_tx_cnt == vsi->tx_rings[0]->count)
2801 /* alloc updated Tx resources */
2802 netdev_info(netdev, "Changing Tx descriptor count from %d to %d\n",
2803 vsi->tx_rings[0]->count, new_tx_cnt);
2805 tx_rings = kcalloc(vsi->num_txq, sizeof(*tx_rings), GFP_KERNEL);
2811 ice_for_each_txq(vsi, i) {
2812 /* clone ring and setup updated count */
2813 tx_rings[i] = *vsi->tx_rings[i];
2814 tx_rings[i].count = new_tx_cnt;
2815 tx_rings[i].desc = NULL;
2816 tx_rings[i].tx_buf = NULL;
2817 err = ice_setup_tx_ring(&tx_rings[i]);
2820 ice_clean_tx_ring(&tx_rings[i]);
2826 if (!ice_is_xdp_ena_vsi(vsi))
2829 /* alloc updated XDP resources */
2830 netdev_info(netdev, "Changing XDP descriptor count from %d to %d\n",
2831 vsi->xdp_rings[0]->count, new_tx_cnt);
2833 xdp_rings = kcalloc(vsi->num_xdp_txq, sizeof(*xdp_rings), GFP_KERNEL);
2839 for (i = 0; i < vsi->num_xdp_txq; i++) {
2840 /* clone ring and setup updated count */
2841 xdp_rings[i] = *vsi->xdp_rings[i];
2842 xdp_rings[i].count = new_tx_cnt;
2843 xdp_rings[i].desc = NULL;
2844 xdp_rings[i].tx_buf = NULL;
2845 err = ice_setup_tx_ring(&xdp_rings[i]);
2848 ice_clean_tx_ring(&xdp_rings[i]);
2852 ice_set_ring_xdp(&xdp_rings[i]);
2856 if (new_rx_cnt == vsi->rx_rings[0]->count)
2859 /* alloc updated Rx resources */
2860 netdev_info(netdev, "Changing Rx descriptor count from %d to %d\n",
2861 vsi->rx_rings[0]->count, new_rx_cnt);
2863 rx_rings = kcalloc(vsi->num_rxq, sizeof(*rx_rings), GFP_KERNEL);
2869 ice_for_each_rxq(vsi, i) {
2870 /* clone ring and setup updated count */
2871 rx_rings[i] = *vsi->rx_rings[i];
2872 rx_rings[i].count = new_rx_cnt;
2873 rx_rings[i].desc = NULL;
2874 rx_rings[i].rx_buf = NULL;
2875 /* this is to allow wr32 to have something to write to
2876 * during early allocation of Rx buffers
2878 rx_rings[i].tail = vsi->back->hw.hw_addr + PRTGEN_STATUS;
2880 err = ice_setup_rx_ring(&rx_rings[i]);
2884 /* allocate Rx buffers */
2885 err = ice_alloc_rx_bufs(&rx_rings[i],
2886 ICE_DESC_UNUSED(&rx_rings[i]));
2891 ice_free_rx_ring(&rx_rings[i]);
2900 /* Bring interface down, copy in the new ring info, then restore the
2901 * interface. if VSI is up, bring it down and then back up
2903 if (!test_and_set_bit(__ICE_DOWN, vsi->state)) {
2907 ice_for_each_txq(vsi, i) {
2908 ice_free_tx_ring(vsi->tx_rings[i]);
2909 *vsi->tx_rings[i] = tx_rings[i];
2915 ice_for_each_rxq(vsi, i) {
2916 ice_free_rx_ring(vsi->rx_rings[i]);
2917 /* copy the real tail offset */
2918 rx_rings[i].tail = vsi->rx_rings[i]->tail;
2919 /* this is to fake out the allocation routine
2920 * into thinking it has to realloc everything
2921 * but the recycling logic will let us re-use
2922 * the buffers allocated above
2924 rx_rings[i].next_to_use = 0;
2925 rx_rings[i].next_to_clean = 0;
2926 rx_rings[i].next_to_alloc = 0;
2927 *vsi->rx_rings[i] = rx_rings[i];
2933 for (i = 0; i < vsi->num_xdp_txq; i++) {
2934 ice_free_tx_ring(vsi->xdp_rings[i]);
2935 *vsi->xdp_rings[i] = xdp_rings[i];
2940 vsi->num_tx_desc = new_tx_cnt;
2941 vsi->num_rx_desc = new_rx_cnt;
2947 /* error cleanup if the Rx allocations failed after getting Tx */
2949 ice_for_each_txq(vsi, i)
2950 ice_free_tx_ring(&tx_rings[i]);
2955 clear_bit(__ICE_CFG_BUSY, pf->state);
2960 * ice_get_pauseparam - Get Flow Control status
2961 * @netdev: network interface device structure
2962 * @pause: ethernet pause (flow control) parameters
2964 * Get requested flow control status from PHY capability.
2965 * If autoneg is true, then ethtool will send the ETHTOOL_GSET ioctl which
2966 * is handled by ice_get_link_ksettings. ice_get_link_ksettings will report
2967 * the negotiated Rx/Tx pause via lp_advertising.
2970 ice_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
2972 struct ice_netdev_priv *np = netdev_priv(netdev);
2973 struct ice_port_info *pi = np->vsi->port_info;
2974 struct ice_aqc_get_phy_caps_data *pcaps;
2975 struct ice_dcbx_cfg *dcbx_cfg;
2976 enum ice_status status;
2978 /* Initialize pause params */
2979 pause->rx_pause = 0;
2980 pause->tx_pause = 0;
2982 dcbx_cfg = &pi->local_dcbx_cfg;
2984 pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
2988 /* Get current PHY config */
2989 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_SW_CFG, pcaps,
2994 pause->autoneg = ice_is_phy_caps_an_enabled(pcaps) ? AUTONEG_ENABLE :
2997 if (dcbx_cfg->pfc.pfcena)
2998 /* PFC enabled so report LFC as off */
3001 if (pcaps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE)
3002 pause->tx_pause = 1;
3003 if (pcaps->caps & ICE_AQC_PHY_EN_RX_LINK_PAUSE)
3004 pause->rx_pause = 1;
3011 * ice_set_pauseparam - Set Flow Control parameter
3012 * @netdev: network interface device structure
3013 * @pause: return Tx/Rx flow control status
3016 ice_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
3018 struct ice_netdev_priv *np = netdev_priv(netdev);
3019 struct ice_aqc_get_phy_caps_data *pcaps;
3020 struct ice_link_status *hw_link_info;
3021 struct ice_pf *pf = np->vsi->back;
3022 struct ice_dcbx_cfg *dcbx_cfg;
3023 struct ice_vsi *vsi = np->vsi;
3024 struct ice_hw *hw = &pf->hw;
3025 struct ice_port_info *pi;
3026 enum ice_status status;
3032 pi = vsi->port_info;
3033 hw_link_info = &pi->phy.link_info;
3034 dcbx_cfg = &pi->local_dcbx_cfg;
3035 link_up = hw_link_info->link_info & ICE_AQ_LINK_UP;
3037 /* Changing the port's flow control is not supported if this isn't the
3040 if (vsi->type != ICE_VSI_PF) {
3041 netdev_info(netdev, "Changing flow control parameters only supported for PF VSI\n");
3045 /* Get pause param reports configured and negotiated flow control pause
3046 * when ETHTOOL_GLINKSETTINGS is defined. Since ETHTOOL_GLINKSETTINGS is
3047 * defined get pause param pause->autoneg reports SW configured setting,
3048 * so compare pause->autoneg with SW configured to prevent the user from
3049 * using set pause param to chance autoneg.
3051 pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
3055 /* Get current PHY config */
3056 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_SW_CFG, pcaps,
3063 is_an = ice_is_phy_caps_an_enabled(pcaps) ? AUTONEG_ENABLE :
3068 if (pause->autoneg != is_an) {
3069 netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n");
3073 /* If we have link and don't have autoneg */
3074 if (!test_bit(__ICE_DOWN, pf->state) &&
3075 !(hw_link_info->an_info & ICE_AQ_AN_COMPLETED)) {
3076 /* Send message that it might not necessarily work*/
3077 netdev_info(netdev, "Autoneg did not complete so changing settings may not result in an actual change.\n");
3080 if (dcbx_cfg->pfc.pfcena) {
3081 netdev_info(netdev, "Priority flow control enabled. Cannot set link flow control.\n");
3084 if (pause->rx_pause && pause->tx_pause)
3085 pi->fc.req_mode = ICE_FC_FULL;
3086 else if (pause->rx_pause && !pause->tx_pause)
3087 pi->fc.req_mode = ICE_FC_RX_PAUSE;
3088 else if (!pause->rx_pause && pause->tx_pause)
3089 pi->fc.req_mode = ICE_FC_TX_PAUSE;
3090 else if (!pause->rx_pause && !pause->tx_pause)
3091 pi->fc.req_mode = ICE_FC_NONE;
3095 /* Set the FC mode and only restart AN if link is up */
3096 status = ice_set_fc(pi, &aq_failures, link_up);
3098 if (aq_failures & ICE_SET_FC_AQ_FAIL_GET) {
3099 netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with err %s aq_err %s\n",
3100 ice_stat_str(status),
3101 ice_aq_str(hw->adminq.sq_last_status));
3103 } else if (aq_failures & ICE_SET_FC_AQ_FAIL_SET) {
3104 netdev_info(netdev, "Set fc failed on the set_phy_config call with err %s aq_err %s\n",
3105 ice_stat_str(status),
3106 ice_aq_str(hw->adminq.sq_last_status));
3108 } else if (aq_failures & ICE_SET_FC_AQ_FAIL_UPDATE) {
3109 netdev_info(netdev, "Set fc failed on the get_link_info call with err %s aq_err %s\n",
3110 ice_stat_str(status),
3111 ice_aq_str(hw->adminq.sq_last_status));
3119 * ice_get_rxfh_key_size - get the RSS hash key size
3120 * @netdev: network interface device structure
3122 * Returns the table size.
3124 static u32 ice_get_rxfh_key_size(struct net_device __always_unused *netdev)
3126 return ICE_VSIQF_HKEY_ARRAY_SIZE;
3130 * ice_get_rxfh_indir_size - get the Rx flow hash indirection table size
3131 * @netdev: network interface device structure
3133 * Returns the table size.
3135 static u32 ice_get_rxfh_indir_size(struct net_device *netdev)
3137 struct ice_netdev_priv *np = netdev_priv(netdev);
3139 return np->vsi->rss_table_size;
3143 * ice_get_rxfh - get the Rx flow hash indirection table
3144 * @netdev: network interface device structure
3145 * @indir: indirection table
3147 * @hfunc: hash function
3149 * Reads the indirection table directly from the hardware.
3152 ice_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc)
3154 struct ice_netdev_priv *np = netdev_priv(netdev);
3155 struct ice_vsi *vsi = np->vsi;
3156 struct ice_pf *pf = vsi->back;
3161 *hfunc = ETH_RSS_HASH_TOP;
3166 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
3167 /* RSS not supported return error here */
3168 netdev_warn(netdev, "RSS is not configured on this VSI!\n");
3172 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
3176 if (ice_get_rss(vsi, key, lut, vsi->rss_table_size)) {
3181 for (i = 0; i < vsi->rss_table_size; i++)
3182 indir[i] = (u32)(lut[i]);
3190 * ice_set_rxfh - set the Rx flow hash indirection table
3191 * @netdev: network interface device structure
3192 * @indir: indirection table
3194 * @hfunc: hash function
3196 * Returns -EINVAL if the table specifies an invalid queue ID, otherwise
3197 * returns 0 after programming the table.
3200 ice_set_rxfh(struct net_device *netdev, const u32 *indir, const u8 *key,
3203 struct ice_netdev_priv *np = netdev_priv(netdev);
3204 struct ice_vsi *vsi = np->vsi;
3205 struct ice_pf *pf = vsi->back;
3209 dev = ice_pf_to_dev(pf);
3210 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
3213 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
3214 /* RSS not supported return error here */
3215 netdev_warn(netdev, "RSS is not configured on this VSI!\n");
3220 if (!vsi->rss_hkey_user) {
3221 vsi->rss_hkey_user =
3222 devm_kzalloc(dev, ICE_VSIQF_HKEY_ARRAY_SIZE,
3224 if (!vsi->rss_hkey_user)
3227 memcpy(vsi->rss_hkey_user, key, ICE_VSIQF_HKEY_ARRAY_SIZE);
3228 seed = vsi->rss_hkey_user;
3231 if (!vsi->rss_lut_user) {
3232 vsi->rss_lut_user = devm_kzalloc(dev, vsi->rss_table_size,
3234 if (!vsi->rss_lut_user)
3238 /* Each 32 bits pointed by 'indir' is stored with a lut entry */
3242 for (i = 0; i < vsi->rss_table_size; i++)
3243 vsi->rss_lut_user[i] = (u8)(indir[i]);
3245 ice_fill_rss_lut(vsi->rss_lut_user, vsi->rss_table_size,
3249 if (ice_set_rss(vsi, seed, vsi->rss_lut_user, vsi->rss_table_size))
3256 * ice_get_max_txq - return the maximum number of Tx queues for in a PF
3259 static int ice_get_max_txq(struct ice_pf *pf)
3261 return min_t(int, num_online_cpus(),
3262 pf->hw.func_caps.common_cap.num_txq);
3266 * ice_get_max_rxq - return the maximum number of Rx queues for in a PF
3269 static int ice_get_max_rxq(struct ice_pf *pf)
3271 return min_t(int, num_online_cpus(),
3272 pf->hw.func_caps.common_cap.num_rxq);
3276 * ice_get_combined_cnt - return the current number of combined channels
3277 * @vsi: PF VSI pointer
3279 * Go through all queue vectors and count ones that have both Rx and Tx ring
3282 static u32 ice_get_combined_cnt(struct ice_vsi *vsi)
3287 ice_for_each_q_vector(vsi, q_idx) {
3288 struct ice_q_vector *q_vector = vsi->q_vectors[q_idx];
3290 if (q_vector->rx.ring && q_vector->tx.ring)
3298 * ice_get_channels - get the current and max supported channels
3299 * @dev: network interface device structure
3300 * @ch: ethtool channel data structure
3303 ice_get_channels(struct net_device *dev, struct ethtool_channels *ch)
3305 struct ice_netdev_priv *np = netdev_priv(dev);
3306 struct ice_vsi *vsi = np->vsi;
3307 struct ice_pf *pf = vsi->back;
3309 /* report maximum channels */
3310 ch->max_rx = ice_get_max_rxq(pf);
3311 ch->max_tx = ice_get_max_txq(pf);
3312 ch->max_combined = min_t(int, ch->max_rx, ch->max_tx);
3314 /* report current channels */
3315 ch->combined_count = ice_get_combined_cnt(vsi);
3316 ch->rx_count = vsi->num_rxq - ch->combined_count;
3317 ch->tx_count = vsi->num_txq - ch->combined_count;
3319 /* report other queues */
3320 ch->other_count = test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1 : 0;
3321 ch->max_other = ch->other_count;
3325 * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size
3326 * @vsi: VSI to reconfigure RSS LUT on
3327 * @req_rss_size: requested range of queue numbers for hashing
3329 * Set the VSI's RSS parameters, configure the RSS LUT based on these.
3331 static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)
3333 struct ice_pf *pf = vsi->back;
3334 enum ice_status status;
3340 dev = ice_pf_to_dev(pf);
3346 lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
3350 /* set RSS LUT parameters */
3351 if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
3354 struct ice_hw_common_caps *caps = &hw->func_caps.common_cap;
3356 vsi->rss_size = min_t(int, req_rss_size,
3357 BIT(caps->rss_table_entry_width));
3360 /* create/set RSS LUT */
3361 ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);
3362 status = ice_aq_set_rss_lut(hw, vsi->idx, vsi->rss_lut_type, lut,
3363 vsi->rss_table_size);
3365 dev_err(dev, "Cannot set RSS lut, err %s aq_err %s\n",
3366 ice_stat_str(status),
3367 ice_aq_str(hw->adminq.sq_last_status));
3376 * ice_set_channels - set the number channels
3377 * @dev: network interface device structure
3378 * @ch: ethtool channel data structure
3380 static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
3382 struct ice_netdev_priv *np = netdev_priv(dev);
3383 struct ice_vsi *vsi = np->vsi;
3384 struct ice_pf *pf = vsi->back;
3385 int new_rx = 0, new_tx = 0;
3388 /* do not support changing channels in Safe Mode */
3389 if (ice_is_safe_mode(pf)) {
3390 netdev_err(dev, "Changing channel in Safe Mode is not supported\n");
3393 /* do not support changing other_count */
3394 if (ch->other_count != (test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1U : 0U))
3397 if (test_bit(ICE_FLAG_FD_ENA, pf->flags) && pf->hw.fdir_active_fltr) {
3398 netdev_err(dev, "Cannot set channels when Flow Director filters are active\n");
3402 curr_combined = ice_get_combined_cnt(vsi);
3404 /* these checks are for cases where user didn't specify a particular
3405 * value on cmd line but we get non-zero value anyway via
3406 * get_channels(); look at ethtool.c in ethtool repository (the user
3407 * space part), particularly, do_schannels() routine
3409 if (ch->rx_count == vsi->num_rxq - curr_combined)
3411 if (ch->tx_count == vsi->num_txq - curr_combined)
3413 if (ch->combined_count == curr_combined)
3414 ch->combined_count = 0;
3416 if (!(ch->combined_count || (ch->rx_count && ch->tx_count))) {
3417 netdev_err(dev, "Please specify at least 1 Rx and 1 Tx channel\n");
3421 new_rx = ch->combined_count + ch->rx_count;
3422 new_tx = ch->combined_count + ch->tx_count;
3424 if (new_rx > ice_get_max_rxq(pf)) {
3425 netdev_err(dev, "Maximum allowed Rx channels is %d\n",
3426 ice_get_max_rxq(pf));
3429 if (new_tx > ice_get_max_txq(pf)) {
3430 netdev_err(dev, "Maximum allowed Tx channels is %d\n",
3431 ice_get_max_txq(pf));
3435 ice_vsi_recfg_qs(vsi, new_rx, new_tx);
3437 if (new_rx && !netif_is_rxfh_configured(dev))
3438 return ice_vsi_set_dflt_rss_lut(vsi, new_rx);
3444 * ice_get_wol - get current Wake on LAN configuration
3445 * @netdev: network interface device structure
3446 * @wol: Ethtool structure to retrieve WoL settings
3448 static void ice_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
3450 struct ice_netdev_priv *np = netdev_priv(netdev);
3451 struct ice_pf *pf = np->vsi->back;
3453 if (np->vsi->type != ICE_VSI_PF)
3454 netdev_warn(netdev, "Wake on LAN is not supported on this interface!\n");
3456 /* Get WoL settings based on the HW capability */
3457 if (ice_is_wol_supported(pf)) {
3458 wol->supported = WAKE_MAGIC;
3459 wol->wolopts = pf->wol_ena ? WAKE_MAGIC : 0;
3467 * ice_set_wol - set Wake on LAN on supported device
3468 * @netdev: network interface device structure
3469 * @wol: Ethtool structure to set WoL
3471 static int ice_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
3473 struct ice_netdev_priv *np = netdev_priv(netdev);
3474 struct ice_vsi *vsi = np->vsi;
3475 struct ice_pf *pf = vsi->back;
3477 if (vsi->type != ICE_VSI_PF || !ice_is_wol_supported(pf))
3480 /* only magic packet is supported */
3481 if (wol->wolopts && wol->wolopts != WAKE_MAGIC)
3484 /* Set WoL only if there is a new value */
3485 if (pf->wol_ena != !!wol->wolopts) {
3486 pf->wol_ena = !!wol->wolopts;
3487 device_set_wakeup_enable(ice_pf_to_dev(pf), pf->wol_ena);
3488 netdev_dbg(netdev, "WoL magic packet %sabled\n",
3489 pf->wol_ena ? "en" : "dis");
3495 enum ice_container_type {
3501 * ice_get_rc_coalesce - get ITR values for specific ring container
3502 * @ec: ethtool structure to fill with driver's coalesce settings
3503 * @c_type: container type, Rx or Tx
3504 * @rc: ring container that the ITR values will come from
3506 * Query the device for ice_ring_container specific ITR values. This is
3507 * done per ice_ring_container because each q_vector can have 1 or more rings
3508 * and all of said ring(s) will have the same ITR values.
3510 * Returns 0 on success, negative otherwise.
3513 ice_get_rc_coalesce(struct ethtool_coalesce *ec, enum ice_container_type c_type,
3514 struct ice_ring_container *rc)
3521 pf = rc->ring->vsi->back;
3524 case ICE_RX_CONTAINER:
3525 ec->use_adaptive_rx_coalesce = ITR_IS_DYNAMIC(rc->itr_setting);
3526 ec->rx_coalesce_usecs = rc->itr_setting & ~ICE_ITR_DYNAMIC;
3527 ec->rx_coalesce_usecs_high = rc->ring->q_vector->intrl;
3529 case ICE_TX_CONTAINER:
3530 ec->use_adaptive_tx_coalesce = ITR_IS_DYNAMIC(rc->itr_setting);
3531 ec->tx_coalesce_usecs = rc->itr_setting & ~ICE_ITR_DYNAMIC;
3534 dev_dbg(ice_pf_to_dev(pf), "Invalid c_type %d\n", c_type);
3542 * ice_get_q_coalesce - get a queue's ITR/INTRL (coalesce) settings
3543 * @vsi: VSI associated to the queue for getting ITR/INTRL (coalesce) settings
3544 * @ec: coalesce settings to program the device with
3545 * @q_num: update ITR/INTRL (coalesce) settings for this queue number/index
3547 * Return 0 on success, and negative under the following conditions:
3548 * 1. Getting Tx or Rx ITR/INTRL (coalesce) settings failed.
3549 * 2. The q_num passed in is not a valid number/index for Tx and Rx rings.
3552 ice_get_q_coalesce(struct ice_vsi *vsi, struct ethtool_coalesce *ec, int q_num)
3554 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) {
3555 if (ice_get_rc_coalesce(ec, ICE_RX_CONTAINER,
3556 &vsi->rx_rings[q_num]->q_vector->rx))
3558 if (ice_get_rc_coalesce(ec, ICE_TX_CONTAINER,
3559 &vsi->tx_rings[q_num]->q_vector->tx))
3561 } else if (q_num < vsi->num_rxq) {
3562 if (ice_get_rc_coalesce(ec, ICE_RX_CONTAINER,
3563 &vsi->rx_rings[q_num]->q_vector->rx))
3565 } else if (q_num < vsi->num_txq) {
3566 if (ice_get_rc_coalesce(ec, ICE_TX_CONTAINER,
3567 &vsi->tx_rings[q_num]->q_vector->tx))
3577 * __ice_get_coalesce - get ITR/INTRL values for the device
3578 * @netdev: pointer to the netdev associated with this query
3579 * @ec: ethtool structure to fill with driver's coalesce settings
3580 * @q_num: queue number to get the coalesce settings for
3582 * If the caller passes in a negative q_num then we return coalesce settings
3583 * based on queue number 0, else use the actual q_num passed in.
3586 __ice_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec,
3589 struct ice_netdev_priv *np = netdev_priv(netdev);
3590 struct ice_vsi *vsi = np->vsi;
3595 if (ice_get_q_coalesce(vsi, ec, q_num))
3602 ice_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec)
3604 return __ice_get_coalesce(netdev, ec, -1);
3608 ice_get_per_q_coalesce(struct net_device *netdev, u32 q_num,
3609 struct ethtool_coalesce *ec)
3611 return __ice_get_coalesce(netdev, ec, q_num);
3615 * ice_set_rc_coalesce - set ITR values for specific ring container
3616 * @c_type: container type, Rx or Tx
3617 * @ec: ethtool structure from user to update ITR settings
3618 * @rc: ring container that the ITR values will come from
3619 * @vsi: VSI associated to the ring container
3621 * Set specific ITR values. This is done per ice_ring_container because each
3622 * q_vector can have 1 or more rings and all of said ring(s) will have the same
3625 * Returns 0 on success, negative otherwise.
3628 ice_set_rc_coalesce(enum ice_container_type c_type, struct ethtool_coalesce *ec,
3629 struct ice_ring_container *rc, struct ice_vsi *vsi)
3631 const char *c_type_str = (c_type == ICE_RX_CONTAINER) ? "rx" : "tx";
3632 u32 use_adaptive_coalesce, coalesce_usecs;
3633 struct ice_pf *pf = vsi->back;
3640 case ICE_RX_CONTAINER:
3641 if (ec->rx_coalesce_usecs_high > ICE_MAX_INTRL ||
3642 (ec->rx_coalesce_usecs_high &&
3643 ec->rx_coalesce_usecs_high < pf->hw.intrl_gran)) {
3644 netdev_info(vsi->netdev, "Invalid value, %s-usecs-high valid values are 0 (disabled), %d-%d\n",
3645 c_type_str, pf->hw.intrl_gran,
3649 if (ec->rx_coalesce_usecs_high != rc->ring->q_vector->intrl) {
3650 rc->ring->q_vector->intrl = ec->rx_coalesce_usecs_high;
3651 wr32(&pf->hw, GLINT_RATE(rc->ring->q_vector->reg_idx),
3652 ice_intrl_usec_to_reg(ec->rx_coalesce_usecs_high,
3653 pf->hw.intrl_gran));
3656 use_adaptive_coalesce = ec->use_adaptive_rx_coalesce;
3657 coalesce_usecs = ec->rx_coalesce_usecs;
3660 case ICE_TX_CONTAINER:
3661 use_adaptive_coalesce = ec->use_adaptive_tx_coalesce;
3662 coalesce_usecs = ec->tx_coalesce_usecs;
3666 dev_dbg(ice_pf_to_dev(pf), "Invalid container type %d\n",
3671 itr_setting = rc->itr_setting & ~ICE_ITR_DYNAMIC;
3672 if (coalesce_usecs != itr_setting && use_adaptive_coalesce) {
3673 netdev_info(vsi->netdev, "%s interrupt throttling cannot be changed if adaptive-%s is enabled\n",
3674 c_type_str, c_type_str);
3678 if (coalesce_usecs > ICE_ITR_MAX) {
3679 netdev_info(vsi->netdev, "Invalid value, %s-usecs range is 0-%d\n",
3680 c_type_str, ICE_ITR_MAX);
3684 if (use_adaptive_coalesce) {
3685 rc->itr_setting |= ICE_ITR_DYNAMIC;
3687 /* save the user set usecs */
3688 rc->itr_setting = coalesce_usecs;
3689 /* device ITR granularity is in 2 usec increments */
3690 rc->target_itr = ITR_REG_ALIGN(rc->itr_setting);
3697 * ice_set_q_coalesce - set a queue's ITR/INTRL (coalesce) settings
3698 * @vsi: VSI associated to the queue that need updating
3699 * @ec: coalesce settings to program the device with
3700 * @q_num: update ITR/INTRL (coalesce) settings for this queue number/index
3702 * Return 0 on success, and negative under the following conditions:
3703 * 1. Setting Tx or Rx ITR/INTRL (coalesce) settings failed.
3704 * 2. The q_num passed in is not a valid number/index for Tx and Rx rings.
3707 ice_set_q_coalesce(struct ice_vsi *vsi, struct ethtool_coalesce *ec, int q_num)
3709 if (q_num < vsi->num_rxq && q_num < vsi->num_txq) {
3710 if (ice_set_rc_coalesce(ICE_RX_CONTAINER, ec,
3711 &vsi->rx_rings[q_num]->q_vector->rx,
3715 if (ice_set_rc_coalesce(ICE_TX_CONTAINER, ec,
3716 &vsi->tx_rings[q_num]->q_vector->tx,
3719 } else if (q_num < vsi->num_rxq) {
3720 if (ice_set_rc_coalesce(ICE_RX_CONTAINER, ec,
3721 &vsi->rx_rings[q_num]->q_vector->rx,
3724 } else if (q_num < vsi->num_txq) {
3725 if (ice_set_rc_coalesce(ICE_TX_CONTAINER, ec,
3726 &vsi->tx_rings[q_num]->q_vector->tx,
3737 * ice_print_if_odd_usecs - print message if user tries to set odd [tx|rx]-usecs
3738 * @netdev: netdev used for print
3739 * @itr_setting: previous user setting
3740 * @use_adaptive_coalesce: if adaptive coalesce is enabled or being enabled
3741 * @coalesce_usecs: requested value of [tx|rx]-usecs
3742 * @c_type_str: either "rx" or "tx" to match user set field of [tx|rx]-usecs
3745 ice_print_if_odd_usecs(struct net_device *netdev, u16 itr_setting,
3746 u32 use_adaptive_coalesce, u32 coalesce_usecs,
3747 const char *c_type_str)
3749 if (use_adaptive_coalesce)
3752 itr_setting = ITR_TO_REG(itr_setting);
3754 if (itr_setting != coalesce_usecs && (coalesce_usecs % 2))
3755 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",
3756 c_type_str, coalesce_usecs, c_type_str,
3757 ITR_REG_ALIGN(coalesce_usecs));
3761 * __ice_set_coalesce - set ITR/INTRL values for the device
3762 * @netdev: pointer to the netdev associated with this query
3763 * @ec: ethtool structure to fill with driver's coalesce settings
3764 * @q_num: queue number to get the coalesce settings for
3766 * If the caller passes in a negative q_num then we set the coalesce settings
3767 * for all Tx/Rx queues, else use the actual q_num passed in.
3770 __ice_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec,
3773 struct ice_netdev_priv *np = netdev_priv(netdev);
3774 struct ice_vsi *vsi = np->vsi;
3777 struct ice_q_vector *q_vector = vsi->q_vectors[0];
3781 ice_print_if_odd_usecs(netdev, q_vector->rx.itr_setting,
3782 ec->use_adaptive_rx_coalesce,
3783 ec->rx_coalesce_usecs, "rx");
3785 ice_print_if_odd_usecs(netdev, q_vector->tx.itr_setting,
3786 ec->use_adaptive_tx_coalesce,
3787 ec->tx_coalesce_usecs, "tx");
3790 ice_for_each_q_vector(vsi, v_idx) {
3791 /* In some cases if DCB is configured the num_[rx|tx]q
3792 * can be less than vsi->num_q_vectors. This check
3793 * accounts for that so we don't report a false failure
3795 if (v_idx >= vsi->num_rxq && v_idx >= vsi->num_txq)
3798 if (ice_set_q_coalesce(vsi, ec, v_idx))
3804 if (ice_set_q_coalesce(vsi, ec, q_num))
3813 ice_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ec)
3815 return __ice_set_coalesce(netdev, ec, -1);
3819 ice_set_per_q_coalesce(struct net_device *netdev, u32 q_num,
3820 struct ethtool_coalesce *ec)
3822 return __ice_set_coalesce(netdev, ec, q_num);
3825 #define ICE_I2C_EEPROM_DEV_ADDR 0xA0
3826 #define ICE_I2C_EEPROM_DEV_ADDR2 0xA2
3827 #define ICE_MODULE_TYPE_SFP 0x03
3828 #define ICE_MODULE_TYPE_QSFP_PLUS 0x0D
3829 #define ICE_MODULE_TYPE_QSFP28 0x11
3830 #define ICE_MODULE_SFF_ADDR_MODE 0x04
3831 #define ICE_MODULE_SFF_DIAG_CAPAB 0x40
3832 #define ICE_MODULE_REVISION_ADDR 0x01
3833 #define ICE_MODULE_SFF_8472_COMP 0x5E
3834 #define ICE_MODULE_SFF_8472_SWAP 0x5C
3835 #define ICE_MODULE_QSFP_MAX_LEN 640
3838 * ice_get_module_info - get SFF module type and revision information
3839 * @netdev: network interface device structure
3840 * @modinfo: module EEPROM size and layout information structure
3843 ice_get_module_info(struct net_device *netdev,
3844 struct ethtool_modinfo *modinfo)
3846 struct ice_netdev_priv *np = netdev_priv(netdev);
3847 struct ice_vsi *vsi = np->vsi;
3848 struct ice_pf *pf = vsi->back;
3849 struct ice_hw *hw = &pf->hw;
3850 enum ice_status status;
3851 u8 sff8472_comp = 0;
3852 u8 sff8472_swap = 0;
3856 status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR, 0x00, 0x00,
3857 0, &value, 1, 0, NULL);
3862 case ICE_MODULE_TYPE_SFP:
3863 status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR,
3864 ICE_MODULE_SFF_8472_COMP, 0x00, 0,
3865 &sff8472_comp, 1, 0, NULL);
3868 status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR,
3869 ICE_MODULE_SFF_8472_SWAP, 0x00, 0,
3870 &sff8472_swap, 1, 0, NULL);
3874 if (sff8472_swap & ICE_MODULE_SFF_ADDR_MODE) {
3875 modinfo->type = ETH_MODULE_SFF_8079;
3876 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
3877 } else if (sff8472_comp &&
3878 (sff8472_swap & ICE_MODULE_SFF_DIAG_CAPAB)) {
3879 modinfo->type = ETH_MODULE_SFF_8472;
3880 modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
3882 modinfo->type = ETH_MODULE_SFF_8079;
3883 modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
3886 case ICE_MODULE_TYPE_QSFP_PLUS:
3887 case ICE_MODULE_TYPE_QSFP28:
3888 status = ice_aq_sff_eeprom(hw, 0, ICE_I2C_EEPROM_DEV_ADDR,
3889 ICE_MODULE_REVISION_ADDR, 0x00, 0,
3890 &sff8636_rev, 1, 0, NULL);
3893 /* Check revision compliance */
3894 if (sff8636_rev > 0x02) {
3895 /* Module is SFF-8636 compliant */
3896 modinfo->type = ETH_MODULE_SFF_8636;
3897 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN;
3899 modinfo->type = ETH_MODULE_SFF_8436;
3900 modinfo->eeprom_len = ICE_MODULE_QSFP_MAX_LEN;
3904 netdev_warn(netdev, "SFF Module Type not recognized.\n");
3911 * ice_get_module_eeprom - fill buffer with SFF EEPROM contents
3912 * @netdev: network interface device structure
3913 * @ee: EEPROM dump request structure
3914 * @data: buffer to be filled with EEPROM contents
3917 ice_get_module_eeprom(struct net_device *netdev,
3918 struct ethtool_eeprom *ee, u8 *data)
3920 struct ice_netdev_priv *np = netdev_priv(netdev);
3921 u8 addr = ICE_I2C_EEPROM_DEV_ADDR;
3922 struct ice_vsi *vsi = np->vsi;
3923 struct ice_pf *pf = vsi->back;
3924 struct ice_hw *hw = &pf->hw;
3925 enum ice_status status;
3926 bool is_sfp = false;
3932 status = ice_aq_sff_eeprom(hw, 0, addr, offset, page, 0,
3933 &value, 1, 0, NULL);
3937 if (!ee || !ee->len || !data)
3940 if (value == ICE_MODULE_TYPE_SFP)
3943 for (i = 0; i < ee->len; i++) {
3944 offset = i + ee->offset;
3946 /* Check if we need to access the other memory page */
3948 if (offset >= ETH_MODULE_SFF_8079_LEN) {
3949 offset -= ETH_MODULE_SFF_8079_LEN;
3950 addr = ICE_I2C_EEPROM_DEV_ADDR2;
3953 while (offset >= ETH_MODULE_SFF_8436_LEN) {
3954 /* Compute memory page number and offset. */
3955 offset -= ETH_MODULE_SFF_8436_LEN / 2;
3960 status = ice_aq_sff_eeprom(hw, 0, addr, offset, page, !is_sfp,
3961 &value, 1, 0, NULL);
3969 static const struct ethtool_ops ice_ethtool_ops = {
3970 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
3971 ETHTOOL_COALESCE_USE_ADAPTIVE |
3972 ETHTOOL_COALESCE_RX_USECS_HIGH,
3973 .get_link_ksettings = ice_get_link_ksettings,
3974 .set_link_ksettings = ice_set_link_ksettings,
3975 .get_drvinfo = ice_get_drvinfo,
3976 .get_regs_len = ice_get_regs_len,
3977 .get_regs = ice_get_regs,
3978 .get_wol = ice_get_wol,
3979 .set_wol = ice_set_wol,
3980 .get_msglevel = ice_get_msglevel,
3981 .set_msglevel = ice_set_msglevel,
3982 .self_test = ice_self_test,
3983 .get_link = ethtool_op_get_link,
3984 .get_eeprom_len = ice_get_eeprom_len,
3985 .get_eeprom = ice_get_eeprom,
3986 .get_coalesce = ice_get_coalesce,
3987 .set_coalesce = ice_set_coalesce,
3988 .get_strings = ice_get_strings,
3989 .set_phys_id = ice_set_phys_id,
3990 .get_ethtool_stats = ice_get_ethtool_stats,
3991 .get_priv_flags = ice_get_priv_flags,
3992 .set_priv_flags = ice_set_priv_flags,
3993 .get_sset_count = ice_get_sset_count,
3994 .get_rxnfc = ice_get_rxnfc,
3995 .set_rxnfc = ice_set_rxnfc,
3996 .get_ringparam = ice_get_ringparam,
3997 .set_ringparam = ice_set_ringparam,
3998 .nway_reset = ice_nway_reset,
3999 .get_pauseparam = ice_get_pauseparam,
4000 .set_pauseparam = ice_set_pauseparam,
4001 .get_rxfh_key_size = ice_get_rxfh_key_size,
4002 .get_rxfh_indir_size = ice_get_rxfh_indir_size,
4003 .get_rxfh = ice_get_rxfh,
4004 .set_rxfh = ice_set_rxfh,
4005 .get_channels = ice_get_channels,
4006 .set_channels = ice_set_channels,
4007 .get_ts_info = ethtool_op_get_ts_info,
4008 .get_per_queue_coalesce = ice_get_per_q_coalesce,
4009 .set_per_queue_coalesce = ice_set_per_q_coalesce,
4010 .get_fecparam = ice_get_fecparam,
4011 .set_fecparam = ice_set_fecparam,
4012 .get_module_info = ice_get_module_info,
4013 .get_module_eeprom = ice_get_module_eeprom,
4016 static const struct ethtool_ops ice_ethtool_safe_mode_ops = {
4017 .get_link_ksettings = ice_get_link_ksettings,
4018 .set_link_ksettings = ice_set_link_ksettings,
4019 .get_drvinfo = ice_get_drvinfo,
4020 .get_regs_len = ice_get_regs_len,
4021 .get_regs = ice_get_regs,
4022 .get_wol = ice_get_wol,
4023 .set_wol = ice_set_wol,
4024 .get_msglevel = ice_get_msglevel,
4025 .set_msglevel = ice_set_msglevel,
4026 .get_link = ethtool_op_get_link,
4027 .get_eeprom_len = ice_get_eeprom_len,
4028 .get_eeprom = ice_get_eeprom,
4029 .get_strings = ice_get_strings,
4030 .get_ethtool_stats = ice_get_ethtool_stats,
4031 .get_sset_count = ice_get_sset_count,
4032 .get_ringparam = ice_get_ringparam,
4033 .set_ringparam = ice_set_ringparam,
4034 .nway_reset = ice_nway_reset,
4035 .get_channels = ice_get_channels,
4039 * ice_set_ethtool_safe_mode_ops - setup safe mode ethtool ops
4040 * @netdev: network interface device structure
4042 void ice_set_ethtool_safe_mode_ops(struct net_device *netdev)
4044 netdev->ethtool_ops = &ice_ethtool_safe_mode_ops;
4048 * ice_set_ethtool_ops - setup netdev ethtool ops
4049 * @netdev: network interface device structure
4051 * setup netdev ethtool ops with ice specific ops
4053 void ice_set_ethtool_ops(struct net_device *netdev)
4055 netdev->ethtool_ops = &ice_ethtool_ops;