1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018, Intel Corporation. */
4 /* ethtool support for ice */
9 #include "ice_dcb_lib.h"
12 char stat_string
[ETH_GSTRING_LEN
];
17 #define ICE_STAT(_type, _name, _stat) { \
18 .stat_string = _name, \
19 .sizeof_stat = sizeof_field(_type, _stat), \
20 .stat_offset = offsetof(_type, _stat) \
23 #define ICE_VSI_STAT(_name, _stat) \
24 ICE_STAT(struct ice_vsi, _name, _stat)
25 #define ICE_PF_STAT(_name, _stat) \
26 ICE_STAT(struct ice_pf, _name, _stat)
28 static int ice_q_stats_len(struct net_device
*netdev
)
30 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
32 return ((np
->vsi
->alloc_txq
+ np
->vsi
->alloc_rxq
) *
33 (sizeof(struct ice_q_stats
) / sizeof(u64
)));
36 #define ICE_PF_STATS_LEN ARRAY_SIZE(ice_gstrings_pf_stats)
37 #define ICE_VSI_STATS_LEN ARRAY_SIZE(ice_gstrings_vsi_stats)
39 #define ICE_PFC_STATS_LEN ( \
40 (sizeof_field(struct ice_pf, stats.priority_xoff_rx) + \
41 sizeof_field(struct ice_pf, stats.priority_xon_rx) + \
42 sizeof_field(struct ice_pf, stats.priority_xoff_tx) + \
43 sizeof_field(struct ice_pf, stats.priority_xon_tx)) \
45 #define ICE_ALL_STATS_LEN(n) (ICE_PF_STATS_LEN + ICE_PFC_STATS_LEN + \
46 ICE_VSI_STATS_LEN + ice_q_stats_len(n))
48 static const struct ice_stats ice_gstrings_vsi_stats
[] = {
49 ICE_VSI_STAT("rx_unicast", eth_stats
.rx_unicast
),
50 ICE_VSI_STAT("tx_unicast", eth_stats
.tx_unicast
),
51 ICE_VSI_STAT("rx_multicast", eth_stats
.rx_multicast
),
52 ICE_VSI_STAT("tx_multicast", eth_stats
.tx_multicast
),
53 ICE_VSI_STAT("rx_broadcast", eth_stats
.rx_broadcast
),
54 ICE_VSI_STAT("tx_broadcast", eth_stats
.tx_broadcast
),
55 ICE_VSI_STAT("rx_bytes", eth_stats
.rx_bytes
),
56 ICE_VSI_STAT("tx_bytes", eth_stats
.tx_bytes
),
57 ICE_VSI_STAT("rx_dropped", eth_stats
.rx_discards
),
58 ICE_VSI_STAT("rx_unknown_protocol", eth_stats
.rx_unknown_protocol
),
59 ICE_VSI_STAT("rx_alloc_fail", rx_buf_failed
),
60 ICE_VSI_STAT("rx_pg_alloc_fail", rx_page_failed
),
61 ICE_VSI_STAT("tx_errors", eth_stats
.tx_errors
),
62 ICE_VSI_STAT("tx_linearize", tx_linearize
),
65 enum ice_ethtool_test_id
{
73 static const char ice_gstrings_test
[][ETH_GSTRING_LEN
] = {
74 "Register test (offline)",
75 "EEPROM test (offline)",
76 "Interrupt test (offline)",
77 "Loopback test (offline)",
78 "Link test (on/offline)",
81 #define ICE_TEST_LEN (sizeof(ice_gstrings_test) / ETH_GSTRING_LEN)
83 /* These PF_STATs might look like duplicates of some NETDEV_STATs,
84 * but they aren't. This device is capable of supporting multiple
85 * VSIs/netdevs on a single PF. The NETDEV_STATs are for individual
86 * netdevs whereas the PF_STATs are for the physical function that's
87 * hosting these netdevs.
89 * The PF_STATs are appended to the netdev stats only when ethtool -S
90 * is queried on the base PF netdev.
92 static const struct ice_stats ice_gstrings_pf_stats
[] = {
93 ICE_PF_STAT("rx_bytes.nic", stats
.eth
.rx_bytes
),
94 ICE_PF_STAT("tx_bytes.nic", stats
.eth
.tx_bytes
),
95 ICE_PF_STAT("rx_unicast.nic", stats
.eth
.rx_unicast
),
96 ICE_PF_STAT("tx_unicast.nic", stats
.eth
.tx_unicast
),
97 ICE_PF_STAT("rx_multicast.nic", stats
.eth
.rx_multicast
),
98 ICE_PF_STAT("tx_multicast.nic", stats
.eth
.tx_multicast
),
99 ICE_PF_STAT("rx_broadcast.nic", stats
.eth
.rx_broadcast
),
100 ICE_PF_STAT("tx_broadcast.nic", stats
.eth
.tx_broadcast
),
101 ICE_PF_STAT("tx_errors.nic", stats
.eth
.tx_errors
),
102 ICE_PF_STAT("rx_size_64.nic", stats
.rx_size_64
),
103 ICE_PF_STAT("tx_size_64.nic", stats
.tx_size_64
),
104 ICE_PF_STAT("rx_size_127.nic", stats
.rx_size_127
),
105 ICE_PF_STAT("tx_size_127.nic", stats
.tx_size_127
),
106 ICE_PF_STAT("rx_size_255.nic", stats
.rx_size_255
),
107 ICE_PF_STAT("tx_size_255.nic", stats
.tx_size_255
),
108 ICE_PF_STAT("rx_size_511.nic", stats
.rx_size_511
),
109 ICE_PF_STAT("tx_size_511.nic", stats
.tx_size_511
),
110 ICE_PF_STAT("rx_size_1023.nic", stats
.rx_size_1023
),
111 ICE_PF_STAT("tx_size_1023.nic", stats
.tx_size_1023
),
112 ICE_PF_STAT("rx_size_1522.nic", stats
.rx_size_1522
),
113 ICE_PF_STAT("tx_size_1522.nic", stats
.tx_size_1522
),
114 ICE_PF_STAT("rx_size_big.nic", stats
.rx_size_big
),
115 ICE_PF_STAT("tx_size_big.nic", stats
.tx_size_big
),
116 ICE_PF_STAT("link_xon_rx.nic", stats
.link_xon_rx
),
117 ICE_PF_STAT("link_xon_tx.nic", stats
.link_xon_tx
),
118 ICE_PF_STAT("link_xoff_rx.nic", stats
.link_xoff_rx
),
119 ICE_PF_STAT("link_xoff_tx.nic", stats
.link_xoff_tx
),
120 ICE_PF_STAT("tx_dropped_link_down.nic", stats
.tx_dropped_link_down
),
121 ICE_PF_STAT("rx_undersize.nic", stats
.rx_undersize
),
122 ICE_PF_STAT("rx_fragments.nic", stats
.rx_fragments
),
123 ICE_PF_STAT("rx_oversize.nic", stats
.rx_oversize
),
124 ICE_PF_STAT("rx_jabber.nic", stats
.rx_jabber
),
125 ICE_PF_STAT("rx_csum_bad.nic", hw_csum_rx_error
),
126 ICE_PF_STAT("rx_length_errors.nic", stats
.rx_len_errors
),
127 ICE_PF_STAT("rx_dropped.nic", stats
.eth
.rx_discards
),
128 ICE_PF_STAT("rx_crc_errors.nic", stats
.crc_errors
),
129 ICE_PF_STAT("illegal_bytes.nic", stats
.illegal_bytes
),
130 ICE_PF_STAT("mac_local_faults.nic", stats
.mac_local_faults
),
131 ICE_PF_STAT("mac_remote_faults.nic", stats
.mac_remote_faults
),
134 static const u32 ice_regs_dump_list
[] = {
147 struct ice_priv_flag
{
148 char name
[ETH_GSTRING_LEN
];
149 u32 bitno
; /* bit position in pf->flags */
152 #define ICE_PRIV_FLAG(_name, _bitno) { \
157 static const struct ice_priv_flag ice_gstrings_priv_flags
[] = {
158 ICE_PRIV_FLAG("link-down-on-close", ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA
),
159 ICE_PRIV_FLAG("fw-lldp-agent", ICE_FLAG_FW_LLDP_AGENT
),
160 ICE_PRIV_FLAG("mdd-auto-reset-vf", ICE_FLAG_MDD_AUTO_RESET_VF
),
161 ICE_PRIV_FLAG("legacy-rx", ICE_FLAG_LEGACY_RX
),
164 #define ICE_PRIV_FLAG_ARRAY_SIZE ARRAY_SIZE(ice_gstrings_priv_flags)
167 ice_get_drvinfo(struct net_device
*netdev
, struct ethtool_drvinfo
*drvinfo
)
169 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
170 struct ice_vsi
*vsi
= np
->vsi
;
171 struct ice_pf
*pf
= vsi
->back
;
172 struct ice_hw
*hw
= &pf
->hw
;
173 struct ice_orom_info
*orom
;
174 struct ice_nvm_info
*nvm
;
179 strscpy(drvinfo
->driver
, KBUILD_MODNAME
, sizeof(drvinfo
->driver
));
180 strscpy(drvinfo
->version
, ice_drv_ver
, sizeof(drvinfo
->version
));
182 /* Display NVM version (from which the firmware version can be
183 * determined) which contains more pertinent information.
185 snprintf(drvinfo
->fw_version
, sizeof(drvinfo
->fw_version
),
186 "%x.%02x 0x%x %d.%d.%d", nvm
->major_ver
, nvm
->minor_ver
,
187 nvm
->eetrack
, orom
->major
, orom
->build
, orom
->patch
);
189 strscpy(drvinfo
->bus_info
, pci_name(pf
->pdev
),
190 sizeof(drvinfo
->bus_info
));
191 drvinfo
->n_priv_flags
= ICE_PRIV_FLAG_ARRAY_SIZE
;
194 static int ice_get_regs_len(struct net_device __always_unused
*netdev
)
196 return sizeof(ice_regs_dump_list
);
200 ice_get_regs(struct net_device
*netdev
, struct ethtool_regs
*regs
, void *p
)
202 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
203 struct ice_pf
*pf
= np
->vsi
->back
;
204 struct ice_hw
*hw
= &pf
->hw
;
205 u32
*regs_buf
= (u32
*)p
;
210 for (i
= 0; i
< ARRAY_SIZE(ice_regs_dump_list
); ++i
)
211 regs_buf
[i
] = rd32(hw
, ice_regs_dump_list
[i
]);
214 static u32
ice_get_msglevel(struct net_device
*netdev
)
216 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
217 struct ice_pf
*pf
= np
->vsi
->back
;
219 #ifndef CONFIG_DYNAMIC_DEBUG
220 if (pf
->hw
.debug_mask
)
221 netdev_info(netdev
, "hw debug_mask: 0x%llX\n",
223 #endif /* !CONFIG_DYNAMIC_DEBUG */
225 return pf
->msg_enable
;
228 static void ice_set_msglevel(struct net_device
*netdev
, u32 data
)
230 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
231 struct ice_pf
*pf
= np
->vsi
->back
;
233 #ifndef CONFIG_DYNAMIC_DEBUG
234 if (ICE_DBG_USER
& data
)
235 pf
->hw
.debug_mask
= data
;
237 pf
->msg_enable
= data
;
239 pf
->msg_enable
= data
;
240 #endif /* !CONFIG_DYNAMIC_DEBUG */
243 static int ice_get_eeprom_len(struct net_device
*netdev
)
245 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
246 struct ice_pf
*pf
= np
->vsi
->back
;
248 return (int)pf
->hw
.nvm
.flash_size
;
252 ice_get_eeprom(struct net_device
*netdev
, struct ethtool_eeprom
*eeprom
,
255 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
256 struct ice_vsi
*vsi
= np
->vsi
;
257 struct ice_pf
*pf
= vsi
->back
;
258 struct ice_hw
*hw
= &pf
->hw
;
259 enum ice_status status
;
264 dev
= ice_pf_to_dev(pf
);
266 eeprom
->magic
= hw
->vendor_id
| (hw
->device_id
<< 16);
267 netdev_dbg(netdev
, "GEEPROM cmd 0x%08x, offset 0x%08x, len 0x%08x\n",
268 eeprom
->cmd
, eeprom
->offset
, eeprom
->len
);
270 buf
= kzalloc(eeprom
->len
, GFP_KERNEL
);
274 status
= ice_acquire_nvm(hw
, ICE_RES_READ
);
276 dev_err(dev
, "ice_acquire_nvm failed, err %d aq_err %d\n",
277 status
, hw
->adminq
.sq_last_status
);
282 status
= ice_read_flat_nvm(hw
, eeprom
->offset
, &eeprom
->len
, buf
,
285 dev_err(dev
, "ice_read_flat_nvm failed, err %d aq_err %d\n",
286 status
, hw
->adminq
.sq_last_status
);
291 memcpy(bytes
, buf
, eeprom
->len
);
300 * ice_active_vfs - check if there are any active VFs
301 * @pf: board private structure
303 * Returns true if an active VF is found, otherwise returns false
305 static bool ice_active_vfs(struct ice_pf
*pf
)
309 ice_for_each_vf(pf
, i
) {
310 struct ice_vf
*vf
= &pf
->vf
[i
];
312 if (test_bit(ICE_VF_STATE_ACTIVE
, vf
->vf_states
))
320 * ice_link_test - perform a link test on a given net_device
321 * @netdev: network interface device structure
323 * This function performs one of the self-tests required by ethtool.
324 * Returns 0 on success, non-zero on failure.
326 static u64
ice_link_test(struct net_device
*netdev
)
328 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
329 enum ice_status status
;
330 bool link_up
= false;
332 netdev_info(netdev
, "link test\n");
333 status
= ice_get_link_status(np
->vsi
->port_info
, &link_up
);
335 netdev_err(netdev
, "link query error, status = %d\n", status
);
346 * ice_eeprom_test - perform an EEPROM test on a given net_device
347 * @netdev: network interface device structure
349 * This function performs one of the self-tests required by ethtool.
350 * Returns 0 on success, non-zero on failure.
352 static u64
ice_eeprom_test(struct net_device
*netdev
)
354 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
355 struct ice_pf
*pf
= np
->vsi
->back
;
357 netdev_info(netdev
, "EEPROM test\n");
358 return !!(ice_nvm_validate_checksum(&pf
->hw
));
362 * ice_reg_pattern_test
363 * @hw: pointer to the HW struct
364 * @reg: reg to be tested
365 * @mask: bits to be touched
367 static int ice_reg_pattern_test(struct ice_hw
*hw
, u32 reg
, u32 mask
)
369 struct ice_pf
*pf
= (struct ice_pf
*)hw
->back
;
370 struct device
*dev
= ice_pf_to_dev(pf
);
371 static const u32 patterns
[] = {
372 0x5A5A5A5A, 0xA5A5A5A5,
373 0x00000000, 0xFFFFFFFF
378 orig_val
= rd32(hw
, reg
);
379 for (i
= 0; i
< ARRAY_SIZE(patterns
); ++i
) {
380 u32 pattern
= patterns
[i
] & mask
;
382 wr32(hw
, reg
, pattern
);
386 dev_err(dev
, "%s: reg pattern test failed - reg 0x%08x pat 0x%08x val 0x%08x\n"
387 , __func__
, reg
, pattern
, val
);
391 wr32(hw
, reg
, orig_val
);
393 if (val
!= orig_val
) {
394 dev_err(dev
, "%s: reg restore test failed - reg 0x%08x orig 0x%08x val 0x%08x\n"
395 , __func__
, reg
, orig_val
, val
);
403 * ice_reg_test - perform a register test on a given net_device
404 * @netdev: network interface device structure
406 * This function performs one of the self-tests required by ethtool.
407 * Returns 0 on success, non-zero on failure.
409 static u64
ice_reg_test(struct net_device
*netdev
)
411 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
412 struct ice_hw
*hw
= np
->vsi
->port_info
->hw
;
413 u32 int_elements
= hw
->func_caps
.common_cap
.num_msix_vectors
?
414 hw
->func_caps
.common_cap
.num_msix_vectors
- 1 : 1;
415 struct ice_diag_reg_test_info
{
421 {GLINT_ITR(0, 0), 0x00000fff, int_elements
,
422 GLINT_ITR(0, 1) - GLINT_ITR(0, 0)},
423 {GLINT_ITR(1, 0), 0x00000fff, int_elements
,
424 GLINT_ITR(1, 1) - GLINT_ITR(1, 0)},
425 {GLINT_ITR(0, 0), 0x00000fff, int_elements
,
426 GLINT_ITR(2, 1) - GLINT_ITR(2, 0)},
427 {GLINT_CTL
, 0xffff0001, 1, 0}
431 netdev_dbg(netdev
, "Register test\n");
432 for (i
= 0; i
< ARRAY_SIZE(ice_reg_list
); ++i
) {
435 for (j
= 0; j
< ice_reg_list
[i
].elem_num
; ++j
) {
436 u32 mask
= ice_reg_list
[i
].mask
;
437 u32 reg
= ice_reg_list
[i
].address
+
438 (j
* ice_reg_list
[i
].elem_size
);
440 /* bail on failure (non-zero return) */
441 if (ice_reg_pattern_test(hw
, reg
, mask
))
450 * ice_lbtest_prepare_rings - configure Tx/Rx test rings
451 * @vsi: pointer to the VSI structure
453 * Function configures rings of a VSI for loopback test without
454 * enabling interrupts or informing the kernel about new queues.
456 * Returns 0 on success, negative on failure.
458 static int ice_lbtest_prepare_rings(struct ice_vsi
*vsi
)
462 status
= ice_vsi_setup_tx_rings(vsi
);
464 goto err_setup_tx_ring
;
466 status
= ice_vsi_setup_rx_rings(vsi
);
468 goto err_setup_rx_ring
;
470 status
= ice_vsi_cfg(vsi
);
472 goto err_setup_rx_ring
;
474 status
= ice_vsi_start_all_rx_rings(vsi
);
476 goto err_start_rx_ring
;
481 ice_vsi_free_rx_rings(vsi
);
483 ice_vsi_stop_lan_tx_rings(vsi
, ICE_NO_RESET
, 0);
485 ice_vsi_free_tx_rings(vsi
);
491 * ice_lbtest_disable_rings - disable Tx/Rx test rings after loopback test
492 * @vsi: pointer to the VSI structure
494 * Function stops and frees VSI rings after a loopback test.
495 * Returns 0 on success, negative on failure.
497 static int ice_lbtest_disable_rings(struct ice_vsi
*vsi
)
501 status
= ice_vsi_stop_lan_tx_rings(vsi
, ICE_NO_RESET
, 0);
503 netdev_err(vsi
->netdev
, "Failed to stop Tx rings, VSI %d error %d\n",
504 vsi
->vsi_num
, status
);
506 status
= ice_vsi_stop_all_rx_rings(vsi
);
508 netdev_err(vsi
->netdev
, "Failed to stop Rx rings, VSI %d error %d\n",
509 vsi
->vsi_num
, status
);
511 ice_vsi_free_tx_rings(vsi
);
512 ice_vsi_free_rx_rings(vsi
);
518 * ice_lbtest_create_frame - create test packet
519 * @pf: pointer to the PF structure
520 * @ret_data: allocated frame buffer
521 * @size: size of the packet data
523 * Function allocates a frame with a test pattern on specific offsets.
524 * Returns 0 on success, non-zero on failure.
526 static int ice_lbtest_create_frame(struct ice_pf
*pf
, u8
**ret_data
, u16 size
)
533 data
= devm_kzalloc(ice_pf_to_dev(pf
), size
, GFP_KERNEL
);
537 /* Since the ethernet test frame should always be at least
538 * 64 bytes long, fill some octets in the payload with test data.
540 memset(data
, 0xFF, size
);
552 * ice_lbtest_check_frame - verify received loopback frame
553 * @frame: pointer to the raw packet data
555 * Function verifies received test frame with a pattern.
556 * Returns true if frame matches the pattern, false otherwise.
558 static bool ice_lbtest_check_frame(u8
*frame
)
560 /* Validate bytes of a frame under offsets chosen earlier */
561 if (frame
[32] == 0xDE &&
572 * ice_diag_send - send test frames to the test ring
573 * @tx_ring: pointer to the transmit ring
574 * @data: pointer to the raw packet data
575 * @size: size of the packet to send
577 * Function sends loopback packets on a test Tx ring.
579 static int ice_diag_send(struct ice_ring
*tx_ring
, u8
*data
, u16 size
)
581 struct ice_tx_desc
*tx_desc
;
582 struct ice_tx_buf
*tx_buf
;
586 tx_desc
= ICE_TX_DESC(tx_ring
, tx_ring
->next_to_use
);
587 tx_buf
= &tx_ring
->tx_buf
[tx_ring
->next_to_use
];
589 dma
= dma_map_single(tx_ring
->dev
, data
, size
, DMA_TO_DEVICE
);
590 if (dma_mapping_error(tx_ring
->dev
, dma
))
593 tx_desc
->buf_addr
= cpu_to_le64(dma
);
595 /* These flags are required for a descriptor to be pushed out */
596 td_cmd
= (u64
)(ICE_TX_DESC_CMD_EOP
| ICE_TX_DESC_CMD_RS
);
597 tx_desc
->cmd_type_offset_bsz
=
598 cpu_to_le64(ICE_TX_DESC_DTYPE_DATA
|
599 (td_cmd
<< ICE_TXD_QW1_CMD_S
) |
600 ((u64
)0 << ICE_TXD_QW1_OFFSET_S
) |
601 ((u64
)size
<< ICE_TXD_QW1_TX_BUF_SZ_S
) |
602 ((u64
)0 << ICE_TXD_QW1_L2TAG1_S
));
604 tx_buf
->next_to_watch
= tx_desc
;
606 /* Force memory write to complete before letting h/w know
607 * there are new descriptors to fetch.
611 tx_ring
->next_to_use
++;
612 if (tx_ring
->next_to_use
>= tx_ring
->count
)
613 tx_ring
->next_to_use
= 0;
615 writel_relaxed(tx_ring
->next_to_use
, tx_ring
->tail
);
617 /* Wait until the packets get transmitted to the receive queue. */
618 usleep_range(1000, 2000);
619 dma_unmap_single(tx_ring
->dev
, dma
, size
, DMA_TO_DEVICE
);
624 #define ICE_LB_FRAME_SIZE 64
626 * ice_lbtest_receive_frames - receive and verify test frames
627 * @rx_ring: pointer to the receive ring
629 * Function receives loopback packets and verify their correctness.
630 * Returns number of received valid frames.
632 static int ice_lbtest_receive_frames(struct ice_ring
*rx_ring
)
634 struct ice_rx_buf
*rx_buf
;
640 for (i
= 0; i
< rx_ring
->count
; i
++) {
641 union ice_32b_rx_flex_desc
*rx_desc
;
643 rx_desc
= ICE_RX_DESC(rx_ring
, i
);
645 if (!(rx_desc
->wb
.status_error0
&
646 cpu_to_le16(ICE_TX_DESC_CMD_EOP
| ICE_TX_DESC_CMD_RS
)))
649 rx_buf
= &rx_ring
->rx_buf
[i
];
650 received_buf
= page_address(rx_buf
->page
) + rx_buf
->page_offset
;
652 if (ice_lbtest_check_frame(received_buf
))
660 * ice_loopback_test - perform a loopback test on a given net_device
661 * @netdev: network interface device structure
663 * This function performs one of the self-tests required by ethtool.
664 * Returns 0 on success, non-zero on failure.
666 static u64
ice_loopback_test(struct net_device
*netdev
)
668 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
669 struct ice_vsi
*orig_vsi
= np
->vsi
, *test_vsi
;
670 struct ice_pf
*pf
= orig_vsi
->back
;
671 struct ice_ring
*tx_ring
, *rx_ring
;
672 u8 broadcast
[ETH_ALEN
], ret
= 0;
673 int num_frames
, valid_frames
;
679 dev
= ice_pf_to_dev(pf
);
680 netdev_info(netdev
, "loopback test\n");
682 test_vsi
= ice_lb_vsi_setup(pf
, pf
->hw
.port_info
);
684 netdev_err(netdev
, "Failed to create a VSI for the loopback test\n");
688 test_vsi
->netdev
= netdev
;
689 tx_ring
= test_vsi
->tx_rings
[0];
690 rx_ring
= test_vsi
->rx_rings
[0];
692 if (ice_lbtest_prepare_rings(test_vsi
)) {
694 goto lbtest_vsi_close
;
697 if (ice_alloc_rx_bufs(rx_ring
, rx_ring
->count
)) {
699 goto lbtest_rings_dis
;
702 /* Enable MAC loopback in firmware */
703 if (ice_aq_set_mac_loopback(&pf
->hw
, true, NULL
)) {
708 /* Test VSI needs to receive broadcast packets */
709 eth_broadcast_addr(broadcast
);
710 if (ice_add_mac_to_list(test_vsi
, &tmp_list
, broadcast
)) {
715 if (ice_add_mac(&pf
->hw
, &tmp_list
)) {
720 if (ice_lbtest_create_frame(pf
, &tx_frame
, ICE_LB_FRAME_SIZE
)) {
722 goto remove_mac_filters
;
725 num_frames
= min_t(int, tx_ring
->count
, 32);
726 for (i
= 0; i
< num_frames
; i
++) {
727 if (ice_diag_send(tx_ring
, tx_frame
, ICE_LB_FRAME_SIZE
)) {
729 goto lbtest_free_frame
;
733 valid_frames
= ice_lbtest_receive_frames(rx_ring
);
736 else if (valid_frames
!= num_frames
)
740 devm_kfree(dev
, tx_frame
);
742 if (ice_remove_mac(&pf
->hw
, &tmp_list
))
743 netdev_err(netdev
, "Could not remove MAC filter for the test VSI\n");
745 ice_free_fltr_list(dev
, &tmp_list
);
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_aqc_get_phy_caps_data
*caps
;
974 struct ice_vsi
*vsi
= np
->vsi
;
975 u8 sw_cfg_caps
, sw_cfg_fec
;
976 struct ice_port_info
*pi
;
977 enum ice_status status
;
984 /* Changing the FEC parameters is not supported if not the PF VSI */
985 if (vsi
->type
!= ICE_VSI_PF
) {
986 netdev_info(netdev
, "Changing FEC parameters only supported for PF VSI\n");
990 /* Get last SW configuration */
991 caps
= kzalloc(sizeof(*caps
), GFP_KERNEL
);
995 status
= ice_aq_get_phy_caps(pi
, false, ICE_AQC_REPORT_SW_CFG
,
1002 /* Copy SW configuration returned from PHY caps to PHY config */
1003 ice_copy_phy_caps_to_cfg(caps
, &config
);
1004 sw_cfg_caps
= caps
->caps
;
1005 sw_cfg_fec
= caps
->link_fec_options
;
1007 /* Get toloplogy caps, then copy PHY FEC topoloy caps to PHY config */
1008 memset(caps
, 0, sizeof(*caps
));
1010 status
= ice_aq_get_phy_caps(pi
, false, ICE_AQC_REPORT_TOPO_CAP
,
1017 config
.caps
|= (caps
->caps
& ICE_AQC_PHY_EN_AUTO_FEC
);
1018 config
.link_fec_opt
= caps
->link_fec_options
;
1020 ice_cfg_phy_fec(&config
, req_fec
);
1022 /* If FEC mode has changed, then set PHY configuration and enable AN. */
1023 if ((config
.caps
& ICE_AQ_PHY_ENA_AUTO_FEC
) !=
1024 (sw_cfg_caps
& ICE_AQC_PHY_EN_AUTO_FEC
) ||
1025 config
.link_fec_opt
!= sw_cfg_fec
) {
1026 if (caps
->caps
& ICE_AQC_PHY_AN_MODE
)
1027 config
.caps
|= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT
;
1029 status
= ice_aq_set_phy_cfg(pi
->hw
, pi
->lport
, &config
, NULL
);
1041 * ice_set_fecparam - Set FEC link options
1042 * @netdev: network interface device structure
1043 * @fecparam: Ethtool structure to retrieve FEC parameters
1046 ice_set_fecparam(struct net_device
*netdev
, struct ethtool_fecparam
*fecparam
)
1048 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
1049 struct ice_vsi
*vsi
= np
->vsi
;
1050 enum ice_fec_mode fec
;
1052 switch (fecparam
->fec
) {
1053 case ETHTOOL_FEC_AUTO
:
1056 case ETHTOOL_FEC_RS
:
1059 case ETHTOOL_FEC_BASER
:
1060 fec
= ICE_FEC_BASER
;
1062 case ETHTOOL_FEC_OFF
:
1063 case ETHTOOL_FEC_NONE
:
1067 dev_warn(ice_pf_to_dev(vsi
->back
), "Unsupported FEC mode: %d\n",
1072 return ice_set_fec_cfg(netdev
, fec
);
1076 * ice_get_fecparam - Get link FEC options
1077 * @netdev: network interface device structure
1078 * @fecparam: Ethtool structure to retrieve FEC parameters
1081 ice_get_fecparam(struct net_device
*netdev
, struct ethtool_fecparam
*fecparam
)
1083 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
1084 struct ice_aqc_get_phy_caps_data
*caps
;
1085 struct ice_link_status
*link_info
;
1086 struct ice_vsi
*vsi
= np
->vsi
;
1087 struct ice_port_info
*pi
;
1088 enum ice_status status
;
1091 pi
= vsi
->port_info
;
1095 link_info
= &pi
->phy
.link_info
;
1097 /* Set FEC mode based on negotiated link info */
1098 switch (link_info
->fec_info
) {
1099 case ICE_AQ_LINK_25G_KR_FEC_EN
:
1100 fecparam
->active_fec
= ETHTOOL_FEC_BASER
;
1102 case ICE_AQ_LINK_25G_RS_528_FEC_EN
:
1103 case ICE_AQ_LINK_25G_RS_544_FEC_EN
:
1104 fecparam
->active_fec
= ETHTOOL_FEC_RS
;
1107 fecparam
->active_fec
= ETHTOOL_FEC_OFF
;
1111 caps
= kzalloc(sizeof(*caps
), GFP_KERNEL
);
1115 status
= ice_aq_get_phy_caps(pi
, false, ICE_AQC_REPORT_TOPO_CAP
,
1122 /* Set supported/configured FEC modes based on PHY capability */
1123 if (caps
->caps
& ICE_AQC_PHY_EN_AUTO_FEC
)
1124 fecparam
->fec
|= ETHTOOL_FEC_AUTO
;
1125 if (caps
->link_fec_options
& ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN
||
1126 caps
->link_fec_options
& ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ
||
1127 caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN
||
1128 caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_KR_REQ
)
1129 fecparam
->fec
|= ETHTOOL_FEC_BASER
;
1130 if (caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_RS_528_REQ
||
1131 caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_RS_544_REQ
||
1132 caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN
)
1133 fecparam
->fec
|= ETHTOOL_FEC_RS
;
1134 if (caps
->link_fec_options
== 0)
1135 fecparam
->fec
|= ETHTOOL_FEC_OFF
;
1143 * ice_nway_reset - restart autonegotiation
1144 * @netdev: network interface device structure
1146 static int ice_nway_reset(struct net_device
*netdev
)
1148 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
1149 struct ice_vsi
*vsi
= np
->vsi
;
1150 struct ice_port_info
*pi
;
1151 enum ice_status status
;
1153 pi
= vsi
->port_info
;
1154 /* If VSI state is up, then restart autoneg with link up */
1155 if (!test_bit(__ICE_DOWN
, vsi
->back
->state
))
1156 status
= ice_aq_set_link_restart_an(pi
, true, NULL
);
1158 status
= ice_aq_set_link_restart_an(pi
, false, NULL
);
1161 netdev_info(netdev
, "link restart failed, err %d aq_err %d\n",
1162 status
, pi
->hw
->adminq
.sq_last_status
);
1170 * ice_get_priv_flags - report device private flags
1171 * @netdev: network interface device structure
1173 * The get string set count and the string set should be matched for each
1174 * flag returned. Add new strings for each flag to the ice_gstrings_priv_flags
1177 * Returns a u32 bitmap of flags.
1179 static u32
ice_get_priv_flags(struct net_device
*netdev
)
1181 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
1182 struct ice_vsi
*vsi
= np
->vsi
;
1183 struct ice_pf
*pf
= vsi
->back
;
1184 u32 i
, ret_flags
= 0;
1186 for (i
= 0; i
< ICE_PRIV_FLAG_ARRAY_SIZE
; i
++) {
1187 const struct ice_priv_flag
*priv_flag
;
1189 priv_flag
= &ice_gstrings_priv_flags
[i
];
1191 if (test_bit(priv_flag
->bitno
, pf
->flags
))
1192 ret_flags
|= BIT(i
);
1199 * ice_set_priv_flags - set private flags
1200 * @netdev: network interface device structure
1201 * @flags: bit flags to be set
1203 static int ice_set_priv_flags(struct net_device
*netdev
, u32 flags
)
1205 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
1206 DECLARE_BITMAP(change_flags
, ICE_PF_FLAGS_NBITS
);
1207 DECLARE_BITMAP(orig_flags
, ICE_PF_FLAGS_NBITS
);
1208 struct ice_vsi
*vsi
= np
->vsi
;
1209 struct ice_pf
*pf
= vsi
->back
;
1214 if (flags
> BIT(ICE_PRIV_FLAG_ARRAY_SIZE
))
1217 dev
= ice_pf_to_dev(pf
);
1218 set_bit(ICE_FLAG_ETHTOOL_CTXT
, pf
->flags
);
1220 bitmap_copy(orig_flags
, pf
->flags
, ICE_PF_FLAGS_NBITS
);
1221 for (i
= 0; i
< ICE_PRIV_FLAG_ARRAY_SIZE
; i
++) {
1222 const struct ice_priv_flag
*priv_flag
;
1224 priv_flag
= &ice_gstrings_priv_flags
[i
];
1227 set_bit(priv_flag
->bitno
, pf
->flags
);
1229 clear_bit(priv_flag
->bitno
, pf
->flags
);
1232 bitmap_xor(change_flags
, pf
->flags
, orig_flags
, ICE_PF_FLAGS_NBITS
);
1234 if (test_bit(ICE_FLAG_FW_LLDP_AGENT
, change_flags
)) {
1235 if (!test_bit(ICE_FLAG_FW_LLDP_AGENT
, pf
->flags
)) {
1236 enum ice_status status
;
1238 /* Disable FW LLDP engine */
1239 status
= ice_cfg_lldp_mib_change(&pf
->hw
, false);
1241 /* If unregistering for LLDP events fails, this is
1242 * not an error state, as there shouldn't be any
1243 * events to respond to.
1246 dev_info(dev
, "Failed to unreg for LLDP events\n");
1248 /* The AQ call to stop the FW LLDP agent will generate
1249 * an error if the agent is already stopped.
1251 status
= ice_aq_stop_lldp(&pf
->hw
, true, true, NULL
);
1253 dev_warn(dev
, "Fail to stop LLDP agent\n");
1254 /* Use case for having the FW LLDP agent stopped
1255 * will likely not need DCB, so failure to init is
1256 * not a concern of ethtool
1258 status
= ice_init_pf_dcb(pf
, true);
1260 dev_warn(dev
, "Fail to init DCB\n");
1262 enum ice_status status
;
1263 bool dcbx_agent_status
;
1265 /* AQ command to start FW LLDP agent will return an
1266 * error if the agent is already started
1268 status
= ice_aq_start_lldp(&pf
->hw
, true, NULL
);
1270 dev_warn(dev
, "Fail to start LLDP Agent\n");
1272 /* AQ command to start FW DCBX agent will fail if
1273 * the agent is already started
1275 status
= ice_aq_start_stop_dcbx(&pf
->hw
, true,
1279 dev_dbg(dev
, "Failed to start FW DCBX\n");
1281 dev_info(dev
, "FW DCBX agent is %s\n",
1282 dcbx_agent_status
? "ACTIVE" : "DISABLED");
1284 /* Failure to configure MIB change or init DCB is not
1285 * relevant to ethtool. Print notification that
1286 * registration/init failed but do not return error
1289 status
= ice_init_pf_dcb(pf
, true);
1291 dev_dbg(dev
, "Fail to init DCB\n");
1293 /* Remove rule to direct LLDP packets to default VSI.
1294 * The FW LLDP engine will now be consuming them.
1296 ice_cfg_sw_lldp(vsi
, false, false);
1298 /* Register for MIB change events */
1299 status
= ice_cfg_lldp_mib_change(&pf
->hw
, true);
1301 dev_dbg(dev
, "Fail to enable MIB change events\n");
1303 ice_nway_reset(netdev
);
1306 if (test_bit(ICE_FLAG_LEGACY_RX
, change_flags
)) {
1307 /* down and up VSI so that changes of Rx cfg are reflected. */
1311 clear_bit(ICE_FLAG_ETHTOOL_CTXT
, pf
->flags
);
1315 static int ice_get_sset_count(struct net_device
*netdev
, int sset
)
1319 /* The number (and order) of strings reported *must* remain
1320 * constant for a given netdevice. This function must not
1321 * report a different number based on run time parameters
1322 * (such as the number of queues in use, or the setting of
1323 * a private ethtool flag). This is due to the nature of the
1324 * ethtool stats API.
1326 * Userspace programs such as ethtool must make 3 separate
1327 * ioctl requests, one for size, one for the strings, and
1328 * finally one for the stats. Since these cross into
1329 * userspace, changes to the number or size could result in
1330 * undefined memory access or incorrect string<->value
1331 * correlations for statistics.
1333 * Even if it appears to be safe, changes to the size or
1334 * order of strings will suffer from race conditions and are
1337 return ICE_ALL_STATS_LEN(netdev
);
1339 return ICE_TEST_LEN
;
1340 case ETH_SS_PRIV_FLAGS
:
1341 return ICE_PRIV_FLAG_ARRAY_SIZE
;
1348 ice_get_ethtool_stats(struct net_device
*netdev
,
1349 struct ethtool_stats __always_unused
*stats
, u64
*data
)
1351 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
1352 struct ice_vsi
*vsi
= np
->vsi
;
1353 struct ice_pf
*pf
= vsi
->back
;
1354 struct ice_ring
*ring
;
1359 ice_update_pf_stats(pf
);
1360 ice_update_vsi_stats(vsi
);
1362 for (j
= 0; j
< ICE_VSI_STATS_LEN
; j
++) {
1363 p
= (char *)vsi
+ ice_gstrings_vsi_stats
[j
].stat_offset
;
1364 data
[i
++] = (ice_gstrings_vsi_stats
[j
].sizeof_stat
==
1365 sizeof(u64
)) ? *(u64
*)p
: *(u32
*)p
;
1368 /* populate per queue stats */
1371 ice_for_each_alloc_txq(vsi
, j
) {
1372 ring
= READ_ONCE(vsi
->tx_rings
[j
]);
1374 data
[i
++] = ring
->stats
.pkts
;
1375 data
[i
++] = ring
->stats
.bytes
;
1382 ice_for_each_alloc_rxq(vsi
, j
) {
1383 ring
= READ_ONCE(vsi
->rx_rings
[j
]);
1385 data
[i
++] = ring
->stats
.pkts
;
1386 data
[i
++] = ring
->stats
.bytes
;
1395 if (vsi
->type
!= ICE_VSI_PF
)
1398 for (j
= 0; j
< ICE_PF_STATS_LEN
; j
++) {
1399 p
= (char *)pf
+ ice_gstrings_pf_stats
[j
].stat_offset
;
1400 data
[i
++] = (ice_gstrings_pf_stats
[j
].sizeof_stat
==
1401 sizeof(u64
)) ? *(u64
*)p
: *(u32
*)p
;
1404 for (j
= 0; j
< ICE_MAX_USER_PRIORITY
; j
++) {
1405 data
[i
++] = pf
->stats
.priority_xon_tx
[j
];
1406 data
[i
++] = pf
->stats
.priority_xoff_tx
[j
];
1409 for (j
= 0; j
< ICE_MAX_USER_PRIORITY
; j
++) {
1410 data
[i
++] = pf
->stats
.priority_xon_rx
[j
];
1411 data
[i
++] = pf
->stats
.priority_xoff_rx
[j
];
1416 * ice_phy_type_to_ethtool - convert the phy_types to ethtool link modes
1417 * @netdev: network interface device structure
1418 * @ks: ethtool link ksettings struct to fill out
1421 ice_phy_type_to_ethtool(struct net_device
*netdev
,
1422 struct ethtool_link_ksettings
*ks
)
1424 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
1425 struct ice_link_status
*hw_link_info
;
1426 bool need_add_adv_mode
= false;
1427 struct ice_vsi
*vsi
= np
->vsi
;
1431 hw_link_info
= &vsi
->port_info
->phy
.link_info
;
1432 phy_types_low
= vsi
->port_info
->phy
.phy_type_low
;
1433 phy_types_high
= vsi
->port_info
->phy
.phy_type_high
;
1435 ethtool_link_ksettings_zero_link_mode(ks
, supported
);
1436 ethtool_link_ksettings_zero_link_mode(ks
, advertising
);
1438 if (phy_types_low
& ICE_PHY_TYPE_LOW_100BASE_TX
||
1439 phy_types_low
& ICE_PHY_TYPE_LOW_100M_SGMII
) {
1440 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1442 if (!hw_link_info
->req_speeds
||
1443 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_100MB
)
1444 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1447 if (phy_types_low
& ICE_PHY_TYPE_LOW_1000BASE_T
||
1448 phy_types_low
& ICE_PHY_TYPE_LOW_1G_SGMII
) {
1449 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1451 if (!hw_link_info
->req_speeds
||
1452 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_1000MB
)
1453 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1456 if (phy_types_low
& ICE_PHY_TYPE_LOW_1000BASE_KX
) {
1457 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1459 if (!hw_link_info
->req_speeds
||
1460 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_1000MB
)
1461 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1464 if (phy_types_low
& ICE_PHY_TYPE_LOW_1000BASE_SX
||
1465 phy_types_low
& ICE_PHY_TYPE_LOW_1000BASE_LX
) {
1466 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1468 if (!hw_link_info
->req_speeds
||
1469 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_1000MB
)
1470 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1473 if (phy_types_low
& ICE_PHY_TYPE_LOW_2500BASE_T
) {
1474 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1476 if (!hw_link_info
->req_speeds
||
1477 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_2500MB
)
1478 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1481 if (phy_types_low
& ICE_PHY_TYPE_LOW_2500BASE_X
||
1482 phy_types_low
& ICE_PHY_TYPE_LOW_2500BASE_KX
) {
1483 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1485 if (!hw_link_info
->req_speeds
||
1486 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_2500MB
)
1487 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1490 if (phy_types_low
& ICE_PHY_TYPE_LOW_5GBASE_T
||
1491 phy_types_low
& ICE_PHY_TYPE_LOW_5GBASE_KR
) {
1492 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1494 if (!hw_link_info
->req_speeds
||
1495 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_5GB
)
1496 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1499 if (phy_types_low
& ICE_PHY_TYPE_LOW_10GBASE_T
||
1500 phy_types_low
& ICE_PHY_TYPE_LOW_10G_SFI_DA
||
1501 phy_types_low
& ICE_PHY_TYPE_LOW_10G_SFI_AOC_ACC
||
1502 phy_types_low
& ICE_PHY_TYPE_LOW_10G_SFI_C2C
) {
1503 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1505 if (!hw_link_info
->req_speeds
||
1506 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_10GB
)
1507 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1510 if (phy_types_low
& ICE_PHY_TYPE_LOW_10GBASE_KR_CR1
) {
1511 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1513 if (!hw_link_info
->req_speeds
||
1514 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_10GB
)
1515 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1518 if (phy_types_low
& ICE_PHY_TYPE_LOW_10GBASE_SR
) {
1519 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1521 if (!hw_link_info
->req_speeds
||
1522 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_10GB
)
1523 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1526 if (phy_types_low
& ICE_PHY_TYPE_LOW_10GBASE_LR
) {
1527 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1529 if (!hw_link_info
->req_speeds
||
1530 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_10GB
)
1531 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1534 if (phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_T
||
1535 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_CR
||
1536 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_CR_S
||
1537 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_CR1
||
1538 phy_types_low
& ICE_PHY_TYPE_LOW_25G_AUI_AOC_ACC
||
1539 phy_types_low
& ICE_PHY_TYPE_LOW_25G_AUI_C2C
) {
1540 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1542 if (!hw_link_info
->req_speeds
||
1543 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_25GB
)
1544 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1547 if (phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_SR
||
1548 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_LR
) {
1549 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1551 if (!hw_link_info
->req_speeds
||
1552 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_25GB
)
1553 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1556 if (phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_KR
||
1557 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_KR_S
||
1558 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_KR1
) {
1559 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1561 if (!hw_link_info
->req_speeds
||
1562 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_25GB
)
1563 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1566 if (phy_types_low
& ICE_PHY_TYPE_LOW_40GBASE_KR4
) {
1567 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1569 if (!hw_link_info
->req_speeds
||
1570 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_40GB
)
1571 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1574 if (phy_types_low
& ICE_PHY_TYPE_LOW_40GBASE_CR4
||
1575 phy_types_low
& ICE_PHY_TYPE_LOW_40G_XLAUI_AOC_ACC
||
1576 phy_types_low
& ICE_PHY_TYPE_LOW_40G_XLAUI
) {
1577 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1579 if (!hw_link_info
->req_speeds
||
1580 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_40GB
)
1581 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1584 if (phy_types_low
& ICE_PHY_TYPE_LOW_40GBASE_SR4
) {
1585 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1587 if (!hw_link_info
->req_speeds
||
1588 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_40GB
)
1589 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1592 if (phy_types_low
& ICE_PHY_TYPE_LOW_40GBASE_LR4
) {
1593 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1595 if (!hw_link_info
->req_speeds
||
1596 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_40GB
)
1597 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1600 if (phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_CR2
||
1601 phy_types_low
& ICE_PHY_TYPE_LOW_50G_LAUI2_AOC_ACC
||
1602 phy_types_low
& ICE_PHY_TYPE_LOW_50G_LAUI2
||
1603 phy_types_low
& ICE_PHY_TYPE_LOW_50G_AUI2_AOC_ACC
||
1604 phy_types_low
& ICE_PHY_TYPE_LOW_50G_AUI2
||
1605 phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_CP
||
1606 phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_SR
||
1607 phy_types_low
& ICE_PHY_TYPE_LOW_50G_AUI1_AOC_ACC
||
1608 phy_types_low
& ICE_PHY_TYPE_LOW_50G_AUI1
) {
1609 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1611 if (!hw_link_info
->req_speeds
||
1612 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_50GB
)
1613 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1616 if (phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_KR2
||
1617 phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4
) {
1618 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1620 if (!hw_link_info
->req_speeds
||
1621 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_50GB
)
1622 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1625 if (phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_SR2
||
1626 phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_LR2
||
1627 phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_FR
||
1628 phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_LR
) {
1629 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1631 if (!hw_link_info
->req_speeds
||
1632 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_50GB
)
1633 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1636 if (phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_CR4
||
1637 phy_types_low
& ICE_PHY_TYPE_LOW_100G_CAUI4_AOC_ACC
||
1638 phy_types_low
& ICE_PHY_TYPE_LOW_100G_CAUI4
||
1639 phy_types_low
& ICE_PHY_TYPE_LOW_100G_AUI4_AOC_ACC
||
1640 phy_types_low
& ICE_PHY_TYPE_LOW_100G_AUI4
||
1641 phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_CR_PAM4
||
1642 phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_CP2
||
1643 phy_types_high
& ICE_PHY_TYPE_HIGH_100G_CAUI2_AOC_ACC
||
1644 phy_types_high
& ICE_PHY_TYPE_HIGH_100G_CAUI2
||
1645 phy_types_high
& ICE_PHY_TYPE_HIGH_100G_AUI2_AOC_ACC
||
1646 phy_types_high
& ICE_PHY_TYPE_HIGH_100G_AUI2
) {
1647 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1648 100000baseCR4_Full
);
1649 if (!hw_link_info
->req_speeds
||
1650 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_100GB
)
1651 need_add_adv_mode
= true;
1653 if (need_add_adv_mode
) {
1654 need_add_adv_mode
= false;
1655 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1656 100000baseCR4_Full
);
1658 if (phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_SR4
||
1659 phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_SR2
) {
1660 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1661 100000baseSR4_Full
);
1662 if (!hw_link_info
->req_speeds
||
1663 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_100GB
)
1664 need_add_adv_mode
= true;
1666 if (need_add_adv_mode
) {
1667 need_add_adv_mode
= false;
1668 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1669 100000baseSR4_Full
);
1671 if (phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_LR4
||
1672 phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_DR
) {
1673 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1674 100000baseLR4_ER4_Full
);
1675 if (!hw_link_info
->req_speeds
||
1676 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_100GB
)
1677 need_add_adv_mode
= true;
1679 if (need_add_adv_mode
) {
1680 need_add_adv_mode
= false;
1681 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1682 100000baseLR4_ER4_Full
);
1684 if (phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_KR4
||
1685 phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4
||
1686 phy_types_high
& ICE_PHY_TYPE_HIGH_100GBASE_KR2_PAM4
) {
1687 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1688 100000baseKR4_Full
);
1689 if (!hw_link_info
->req_speeds
||
1690 hw_link_info
->req_speeds
& ICE_AQ_LINK_SPEED_100GB
)
1691 need_add_adv_mode
= true;
1693 if (need_add_adv_mode
)
1694 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1695 100000baseKR4_Full
);
1697 /* Autoneg PHY types */
1698 if (phy_types_low
& ICE_PHY_TYPE_LOW_100BASE_TX
||
1699 phy_types_low
& ICE_PHY_TYPE_LOW_1000BASE_T
||
1700 phy_types_low
& ICE_PHY_TYPE_LOW_1000BASE_KX
||
1701 phy_types_low
& ICE_PHY_TYPE_LOW_2500BASE_T
||
1702 phy_types_low
& ICE_PHY_TYPE_LOW_2500BASE_KX
||
1703 phy_types_low
& ICE_PHY_TYPE_LOW_5GBASE_T
||
1704 phy_types_low
& ICE_PHY_TYPE_LOW_5GBASE_KR
||
1705 phy_types_low
& ICE_PHY_TYPE_LOW_10GBASE_T
||
1706 phy_types_low
& ICE_PHY_TYPE_LOW_10GBASE_KR_CR1
||
1707 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_T
||
1708 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_CR
||
1709 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_CR_S
||
1710 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_CR1
||
1711 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_KR
||
1712 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_KR_S
||
1713 phy_types_low
& ICE_PHY_TYPE_LOW_25GBASE_KR1
||
1714 phy_types_low
& ICE_PHY_TYPE_LOW_40GBASE_CR4
||
1715 phy_types_low
& ICE_PHY_TYPE_LOW_40GBASE_KR4
) {
1716 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1718 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1721 if (phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_CR2
||
1722 phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_KR2
||
1723 phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_CP
||
1724 phy_types_low
& ICE_PHY_TYPE_LOW_50GBASE_KR_PAM4
) {
1725 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1727 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1730 if (phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_CR4
||
1731 phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_KR4
||
1732 phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_KR_PAM4
||
1733 phy_types_low
& ICE_PHY_TYPE_LOW_100GBASE_CP2
) {
1734 ethtool_link_ksettings_add_link_mode(ks
, supported
,
1736 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1741 #define TEST_SET_BITS_TIMEOUT 50
1742 #define TEST_SET_BITS_SLEEP_MAX 2000
1743 #define TEST_SET_BITS_SLEEP_MIN 1000
1746 * ice_get_settings_link_up - Get Link settings for when link is up
1747 * @ks: ethtool ksettings to fill in
1748 * @netdev: network interface device structure
1751 ice_get_settings_link_up(struct ethtool_link_ksettings
*ks
,
1752 struct net_device
*netdev
)
1754 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
1755 struct ice_port_info
*pi
= np
->vsi
->port_info
;
1756 struct ice_link_status
*link_info
;
1757 struct ice_vsi
*vsi
= np
->vsi
;
1759 link_info
= &vsi
->port_info
->phy
.link_info
;
1761 /* Get supported and advertised settings from PHY ability with media */
1762 ice_phy_type_to_ethtool(netdev
, ks
);
1764 switch (link_info
->link_speed
) {
1765 case ICE_AQ_LINK_SPEED_100GB
:
1766 ks
->base
.speed
= SPEED_100000
;
1768 case ICE_AQ_LINK_SPEED_50GB
:
1769 ks
->base
.speed
= SPEED_50000
;
1771 case ICE_AQ_LINK_SPEED_40GB
:
1772 ks
->base
.speed
= SPEED_40000
;
1774 case ICE_AQ_LINK_SPEED_25GB
:
1775 ks
->base
.speed
= SPEED_25000
;
1777 case ICE_AQ_LINK_SPEED_20GB
:
1778 ks
->base
.speed
= SPEED_20000
;
1780 case ICE_AQ_LINK_SPEED_10GB
:
1781 ks
->base
.speed
= SPEED_10000
;
1783 case ICE_AQ_LINK_SPEED_5GB
:
1784 ks
->base
.speed
= SPEED_5000
;
1786 case ICE_AQ_LINK_SPEED_2500MB
:
1787 ks
->base
.speed
= SPEED_2500
;
1789 case ICE_AQ_LINK_SPEED_1000MB
:
1790 ks
->base
.speed
= SPEED_1000
;
1792 case ICE_AQ_LINK_SPEED_100MB
:
1793 ks
->base
.speed
= SPEED_100
;
1796 netdev_info(netdev
, "WARNING: Unrecognized link_speed (0x%x).\n",
1797 link_info
->link_speed
);
1800 ks
->base
.duplex
= DUPLEX_FULL
;
1802 if (link_info
->an_info
& ICE_AQ_AN_COMPLETED
)
1803 ethtool_link_ksettings_add_link_mode(ks
, lp_advertising
,
1806 /* Set flow control negotiated Rx/Tx pause */
1807 switch (pi
->fc
.current_mode
) {
1809 ethtool_link_ksettings_add_link_mode(ks
, lp_advertising
, Pause
);
1811 case ICE_FC_TX_PAUSE
:
1812 ethtool_link_ksettings_add_link_mode(ks
, lp_advertising
, Pause
);
1813 ethtool_link_ksettings_add_link_mode(ks
, lp_advertising
,
1816 case ICE_FC_RX_PAUSE
:
1817 ethtool_link_ksettings_add_link_mode(ks
, lp_advertising
,
1822 ethtool_link_ksettings_del_link_mode(ks
, lp_advertising
, Pause
);
1823 ethtool_link_ksettings_del_link_mode(ks
, lp_advertising
,
1830 * ice_get_settings_link_down - Get the Link settings when link is down
1831 * @ks: ethtool ksettings to fill in
1832 * @netdev: network interface device structure
1834 * Reports link settings that can be determined when link is down
1837 ice_get_settings_link_down(struct ethtool_link_ksettings
*ks
,
1838 struct net_device
*netdev
)
1840 /* link is down and the driver needs to fall back on
1841 * supported PHY types to figure out what info to display
1843 ice_phy_type_to_ethtool(netdev
, ks
);
1845 /* With no link, speed and duplex are unknown */
1846 ks
->base
.speed
= SPEED_UNKNOWN
;
1847 ks
->base
.duplex
= DUPLEX_UNKNOWN
;
1851 * ice_get_link_ksettings - Get Link Speed and Duplex settings
1852 * @netdev: network interface device structure
1853 * @ks: ethtool ksettings
1855 * Reports speed/duplex settings based on media_type
1858 ice_get_link_ksettings(struct net_device
*netdev
,
1859 struct ethtool_link_ksettings
*ks
)
1861 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
1862 struct ice_aqc_get_phy_caps_data
*caps
;
1863 struct ice_link_status
*hw_link_info
;
1864 struct ice_vsi
*vsi
= np
->vsi
;
1865 enum ice_status status
;
1868 ethtool_link_ksettings_zero_link_mode(ks
, supported
);
1869 ethtool_link_ksettings_zero_link_mode(ks
, advertising
);
1870 ethtool_link_ksettings_zero_link_mode(ks
, lp_advertising
);
1871 hw_link_info
= &vsi
->port_info
->phy
.link_info
;
1873 /* set speed and duplex */
1874 if (hw_link_info
->link_info
& ICE_AQ_LINK_UP
)
1875 ice_get_settings_link_up(ks
, netdev
);
1877 ice_get_settings_link_down(ks
, netdev
);
1879 /* set autoneg settings */
1880 ks
->base
.autoneg
= (hw_link_info
->an_info
& ICE_AQ_AN_COMPLETED
) ?
1881 AUTONEG_ENABLE
: AUTONEG_DISABLE
;
1883 /* set media type settings */
1884 switch (vsi
->port_info
->phy
.media_type
) {
1885 case ICE_MEDIA_FIBER
:
1886 ethtool_link_ksettings_add_link_mode(ks
, supported
, FIBRE
);
1887 ks
->base
.port
= PORT_FIBRE
;
1889 case ICE_MEDIA_BASET
:
1890 ethtool_link_ksettings_add_link_mode(ks
, supported
, TP
);
1891 ethtool_link_ksettings_add_link_mode(ks
, advertising
, TP
);
1892 ks
->base
.port
= PORT_TP
;
1894 case ICE_MEDIA_BACKPLANE
:
1895 ethtool_link_ksettings_add_link_mode(ks
, supported
, Autoneg
);
1896 ethtool_link_ksettings_add_link_mode(ks
, supported
, Backplane
);
1897 ethtool_link_ksettings_add_link_mode(ks
, advertising
, Autoneg
);
1898 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1900 ks
->base
.port
= PORT_NONE
;
1903 ethtool_link_ksettings_add_link_mode(ks
, supported
, FIBRE
);
1904 ethtool_link_ksettings_add_link_mode(ks
, advertising
, FIBRE
);
1905 ks
->base
.port
= PORT_DA
;
1908 ks
->base
.port
= PORT_OTHER
;
1912 /* flow control is symmetric and always supported */
1913 ethtool_link_ksettings_add_link_mode(ks
, supported
, Pause
);
1915 caps
= kzalloc(sizeof(*caps
), GFP_KERNEL
);
1919 status
= ice_aq_get_phy_caps(vsi
->port_info
, false,
1920 ICE_AQC_REPORT_SW_CFG
, caps
, NULL
);
1926 /* Set the advertised flow control based on the PHY capability */
1927 if ((caps
->caps
& ICE_AQC_PHY_EN_TX_LINK_PAUSE
) &&
1928 (caps
->caps
& ICE_AQC_PHY_EN_RX_LINK_PAUSE
)) {
1929 ethtool_link_ksettings_add_link_mode(ks
, advertising
, Pause
);
1930 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1932 } else if (caps
->caps
& ICE_AQC_PHY_EN_TX_LINK_PAUSE
) {
1933 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1935 } else if (caps
->caps
& ICE_AQC_PHY_EN_RX_LINK_PAUSE
) {
1936 ethtool_link_ksettings_add_link_mode(ks
, advertising
, Pause
);
1937 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1940 ethtool_link_ksettings_del_link_mode(ks
, advertising
, Pause
);
1941 ethtool_link_ksettings_del_link_mode(ks
, advertising
,
1945 /* Set advertised FEC modes based on PHY capability */
1946 ethtool_link_ksettings_add_link_mode(ks
, advertising
, FEC_NONE
);
1948 if (caps
->link_fec_options
& ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ
||
1949 caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_KR_REQ
)
1950 ethtool_link_ksettings_add_link_mode(ks
, advertising
,
1952 if (caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_RS_528_REQ
||
1953 caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_RS_544_REQ
)
1954 ethtool_link_ksettings_add_link_mode(ks
, advertising
, FEC_RS
);
1956 status
= ice_aq_get_phy_caps(vsi
->port_info
, false,
1957 ICE_AQC_REPORT_TOPO_CAP
, caps
, NULL
);
1963 /* Set supported FEC modes based on PHY capability */
1964 ethtool_link_ksettings_add_link_mode(ks
, supported
, FEC_NONE
);
1966 if (caps
->link_fec_options
& ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN
||
1967 caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN
)
1968 ethtool_link_ksettings_add_link_mode(ks
, supported
, FEC_BASER
);
1969 if (caps
->link_fec_options
& ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN
)
1970 ethtool_link_ksettings_add_link_mode(ks
, supported
, FEC_RS
);
1978 * ice_ksettings_find_adv_link_speed - Find advertising link speed
1979 * @ks: ethtool ksettings
1982 ice_ksettings_find_adv_link_speed(const struct ethtool_link_ksettings
*ks
)
1984 u16 adv_link_speed
= 0;
1986 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
1988 adv_link_speed
|= ICE_AQ_LINK_SPEED_100MB
;
1989 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
1991 adv_link_speed
|= ICE_AQ_LINK_SPEED_1000MB
;
1992 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
1994 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
1996 adv_link_speed
|= ICE_AQ_LINK_SPEED_1000MB
;
1997 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
1999 adv_link_speed
|= ICE_AQ_LINK_SPEED_2500MB
;
2000 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2002 adv_link_speed
|= ICE_AQ_LINK_SPEED_2500MB
;
2003 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2005 adv_link_speed
|= ICE_AQ_LINK_SPEED_5GB
;
2006 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2008 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2010 adv_link_speed
|= ICE_AQ_LINK_SPEED_10GB
;
2011 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2012 10000baseSR_Full
) ||
2013 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2015 adv_link_speed
|= ICE_AQ_LINK_SPEED_10GB
;
2016 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2017 25000baseCR_Full
) ||
2018 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2019 25000baseSR_Full
) ||
2020 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2022 adv_link_speed
|= ICE_AQ_LINK_SPEED_25GB
;
2023 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2024 40000baseCR4_Full
) ||
2025 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2026 40000baseSR4_Full
) ||
2027 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2028 40000baseLR4_Full
) ||
2029 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2031 adv_link_speed
|= ICE_AQ_LINK_SPEED_40GB
;
2032 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2033 50000baseCR2_Full
) ||
2034 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2036 adv_link_speed
|= ICE_AQ_LINK_SPEED_50GB
;
2037 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2039 adv_link_speed
|= ICE_AQ_LINK_SPEED_50GB
;
2040 if (ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2041 100000baseCR4_Full
) ||
2042 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2043 100000baseSR4_Full
) ||
2044 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2045 100000baseLR4_ER4_Full
) ||
2046 ethtool_link_ksettings_test_link_mode(ks
, advertising
,
2047 100000baseKR4_Full
))
2048 adv_link_speed
|= ICE_AQ_LINK_SPEED_100GB
;
2050 return adv_link_speed
;
2056 * @ks: ethtool_link_ksettings
2057 * @config: configuration that will be sent down to FW
2058 * @autoneg_enabled: autonegotiation is enabled or not
2059 * @autoneg_changed: will there a change in autonegotiation
2060 * @netdev: network interface device structure
2062 * Setup PHY autonegotiation feature
2065 ice_setup_autoneg(struct ice_port_info
*p
, struct ethtool_link_ksettings
*ks
,
2066 struct ice_aqc_set_phy_cfg_data
*config
,
2067 u8 autoneg_enabled
, u8
*autoneg_changed
,
2068 struct net_device
*netdev
)
2072 *autoneg_changed
= 0;
2075 if (autoneg_enabled
== AUTONEG_ENABLE
) {
2076 /* If autoneg was not already enabled */
2077 if (!(p
->phy
.link_info
.an_info
& ICE_AQ_AN_COMPLETED
)) {
2078 /* If autoneg is not supported, return error */
2079 if (!ethtool_link_ksettings_test_link_mode(ks
,
2082 netdev_info(netdev
, "Autoneg not supported on this phy.\n");
2085 /* Autoneg is allowed to change */
2086 config
->caps
|= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT
;
2087 *autoneg_changed
= 1;
2091 /* If autoneg is currently enabled */
2092 if (p
->phy
.link_info
.an_info
& ICE_AQ_AN_COMPLETED
) {
2093 /* If autoneg is supported 10GBASE_T is the only PHY
2094 * that can disable it, so otherwise return error
2096 if (ethtool_link_ksettings_test_link_mode(ks
,
2099 netdev_info(netdev
, "Autoneg cannot be disabled on this phy\n");
2102 /* Autoneg is allowed to change */
2103 config
->caps
&= ~ICE_AQ_PHY_ENA_AUTO_LINK_UPDT
;
2104 *autoneg_changed
= 1;
2113 * ice_set_link_ksettings - Set Speed and Duplex
2114 * @netdev: network interface device structure
2115 * @ks: ethtool ksettings
2117 * Set speed/duplex per media_types advertised/forced
2120 ice_set_link_ksettings(struct net_device
*netdev
,
2121 const struct ethtool_link_ksettings
*ks
)
2123 u8 autoneg
, timeout
= TEST_SET_BITS_TIMEOUT
, lport
= 0;
2124 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
2125 struct ethtool_link_ksettings safe_ks
, copy_ks
;
2126 struct ice_aqc_get_phy_caps_data
*abilities
;
2127 u16 adv_link_speed
, curr_link_speed
, idx
;
2128 struct ice_aqc_set_phy_cfg_data config
;
2129 struct ice_pf
*pf
= np
->vsi
->back
;
2130 struct ice_port_info
*p
;
2131 u8 autoneg_changed
= 0;
2132 enum ice_status status
;
2138 p
= np
->vsi
->port_info
;
2143 /* Check if this is LAN VSI */
2144 ice_for_each_vsi(pf
, idx
)
2145 if (pf
->vsi
[idx
]->type
== ICE_VSI_PF
) {
2146 if (np
->vsi
!= pf
->vsi
[idx
])
2151 if (p
->phy
.media_type
!= ICE_MEDIA_BASET
&&
2152 p
->phy
.media_type
!= ICE_MEDIA_FIBER
&&
2153 p
->phy
.media_type
!= ICE_MEDIA_BACKPLANE
&&
2154 p
->phy
.media_type
!= ICE_MEDIA_DA
&&
2155 p
->phy
.link_info
.link_info
& ICE_AQ_LINK_UP
)
2158 /* copy the ksettings to copy_ks to avoid modifying the original */
2159 memcpy(©_ks
, ks
, sizeof(copy_ks
));
2161 /* save autoneg out of ksettings */
2162 autoneg
= copy_ks
.base
.autoneg
;
2164 memset(&safe_ks
, 0, sizeof(safe_ks
));
2166 /* Get link modes supported by hardware.*/
2167 ice_phy_type_to_ethtool(netdev
, &safe_ks
);
2169 /* and check against modes requested by user.
2170 * Return an error if unsupported mode was set.
2172 if (!bitmap_subset(copy_ks
.link_modes
.advertising
,
2173 safe_ks
.link_modes
.supported
,
2174 __ETHTOOL_LINK_MODE_MASK_NBITS
))
2177 /* get our own copy of the bits to check against */
2178 memset(&safe_ks
, 0, sizeof(safe_ks
));
2179 safe_ks
.base
.cmd
= copy_ks
.base
.cmd
;
2180 safe_ks
.base
.link_mode_masks_nwords
=
2181 copy_ks
.base
.link_mode_masks_nwords
;
2182 ice_get_link_ksettings(netdev
, &safe_ks
);
2184 /* set autoneg back to what it currently is */
2185 copy_ks
.base
.autoneg
= safe_ks
.base
.autoneg
;
2186 /* we don't compare the speed */
2187 copy_ks
.base
.speed
= safe_ks
.base
.speed
;
2189 /* If copy_ks.base and safe_ks.base are not the same now, then they are
2190 * trying to set something that we do not support.
2192 if (memcmp(©_ks
.base
, &safe_ks
.base
, sizeof(copy_ks
.base
)))
2195 while (test_and_set_bit(__ICE_CFG_BUSY
, pf
->state
)) {
2199 usleep_range(TEST_SET_BITS_SLEEP_MIN
, TEST_SET_BITS_SLEEP_MAX
);
2202 abilities
= kzalloc(sizeof(*abilities
), GFP_KERNEL
);
2206 /* Get the current PHY config */
2207 status
= ice_aq_get_phy_caps(p
, false, ICE_AQC_REPORT_SW_CFG
, abilities
,
2214 /* Copy abilities to config in case autoneg is not set below */
2215 memset(&config
, 0, sizeof(config
));
2216 config
.caps
= abilities
->caps
& ~ICE_AQC_PHY_AN_MODE
;
2217 if (abilities
->caps
& ICE_AQC_PHY_AN_MODE
)
2218 config
.caps
|= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT
;
2221 err
= ice_setup_autoneg(p
, &safe_ks
, &config
, autoneg
, &autoneg_changed
,
2227 /* Call to get the current link speed */
2228 p
->phy
.get_link_info
= true;
2229 status
= ice_get_link_status(p
, &linkup
);
2235 curr_link_speed
= p
->phy
.link_info
.link_speed
;
2236 adv_link_speed
= ice_ksettings_find_adv_link_speed(ks
);
2238 /* If speed didn't get set, set it to what it currently is.
2239 * This is needed because if advertise is 0 (as it is when autoneg
2240 * is disabled) then speed won't get set.
2242 if (!adv_link_speed
)
2243 adv_link_speed
= curr_link_speed
;
2245 /* Convert the advertise link speeds to their corresponded PHY_TYPE */
2246 ice_update_phy_type(&phy_type_low
, &phy_type_high
, adv_link_speed
);
2248 if (!autoneg_changed
&& adv_link_speed
== curr_link_speed
) {
2249 netdev_info(netdev
, "Nothing changed, exiting without setting anything.\n");
2253 /* copy over the rest of the abilities */
2254 config
.low_power_ctrl
= abilities
->low_power_ctrl
;
2255 config
.eee_cap
= abilities
->eee_cap
;
2256 config
.eeer_value
= abilities
->eeer_value
;
2257 config
.link_fec_opt
= abilities
->link_fec_options
;
2259 /* save the requested speeds */
2260 p
->phy
.link_info
.req_speeds
= adv_link_speed
;
2262 /* set link and auto negotiation so changes take effect */
2263 config
.caps
|= ICE_AQ_PHY_ENA_LINK
;
2265 if (phy_type_low
|| phy_type_high
) {
2266 config
.phy_type_high
= cpu_to_le64(phy_type_high
) &
2267 abilities
->phy_type_high
;
2268 config
.phy_type_low
= cpu_to_le64(phy_type_low
) &
2269 abilities
->phy_type_low
;
2272 netdev_info(netdev
, "Nothing changed. No PHY_TYPE is corresponded to advertised link speed.\n");
2276 /* If link is up put link down */
2277 if (p
->phy
.link_info
.link_info
& ICE_AQ_LINK_UP
) {
2278 /* Tell the OS link is going down, the link will go
2279 * back up when fw says it is ready asynchronously
2281 ice_print_link_msg(np
->vsi
, false);
2282 netif_carrier_off(netdev
);
2283 netif_tx_stop_all_queues(netdev
);
2286 /* make the aq call */
2287 status
= ice_aq_set_phy_cfg(&pf
->hw
, lport
, &config
, NULL
);
2289 netdev_info(netdev
, "Set phy config failed,\n");
2295 clear_bit(__ICE_CFG_BUSY
, pf
->state
);
2301 * ice_parse_hdrs - parses headers from RSS hash input
2302 * @nfc: ethtool rxnfc command
2304 * This function parses the rxnfc command and returns intended
2305 * header types for RSS configuration
2307 static u32
ice_parse_hdrs(struct ethtool_rxnfc
*nfc
)
2309 u32 hdrs
= ICE_FLOW_SEG_HDR_NONE
;
2311 switch (nfc
->flow_type
) {
2313 hdrs
|= ICE_FLOW_SEG_HDR_TCP
| ICE_FLOW_SEG_HDR_IPV4
;
2316 hdrs
|= ICE_FLOW_SEG_HDR_UDP
| ICE_FLOW_SEG_HDR_IPV4
;
2319 hdrs
|= ICE_FLOW_SEG_HDR_SCTP
| ICE_FLOW_SEG_HDR_IPV4
;
2322 hdrs
|= ICE_FLOW_SEG_HDR_TCP
| ICE_FLOW_SEG_HDR_IPV6
;
2325 hdrs
|= ICE_FLOW_SEG_HDR_UDP
| ICE_FLOW_SEG_HDR_IPV6
;
2328 hdrs
|= ICE_FLOW_SEG_HDR_SCTP
| ICE_FLOW_SEG_HDR_IPV6
;
2336 #define ICE_FLOW_HASH_FLD_IPV4_SA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_SA)
2337 #define ICE_FLOW_HASH_FLD_IPV6_SA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_SA)
2338 #define ICE_FLOW_HASH_FLD_IPV4_DA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV4_DA)
2339 #define ICE_FLOW_HASH_FLD_IPV6_DA BIT_ULL(ICE_FLOW_FIELD_IDX_IPV6_DA)
2340 #define ICE_FLOW_HASH_FLD_TCP_SRC_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_SRC_PORT)
2341 #define ICE_FLOW_HASH_FLD_TCP_DST_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_TCP_DST_PORT)
2342 #define ICE_FLOW_HASH_FLD_UDP_SRC_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_SRC_PORT)
2343 #define ICE_FLOW_HASH_FLD_UDP_DST_PORT BIT_ULL(ICE_FLOW_FIELD_IDX_UDP_DST_PORT)
2344 #define ICE_FLOW_HASH_FLD_SCTP_SRC_PORT \
2345 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT)
2346 #define ICE_FLOW_HASH_FLD_SCTP_DST_PORT \
2347 BIT_ULL(ICE_FLOW_FIELD_IDX_SCTP_DST_PORT)
2350 * ice_parse_hash_flds - parses hash fields from RSS hash input
2351 * @nfc: ethtool rxnfc command
2353 * This function parses the rxnfc command and returns intended
2354 * hash fields for RSS configuration
2356 static u64
ice_parse_hash_flds(struct ethtool_rxnfc
*nfc
)
2358 u64 hfld
= ICE_HASH_INVALID
;
2360 if (nfc
->data
& RXH_IP_SRC
|| nfc
->data
& RXH_IP_DST
) {
2361 switch (nfc
->flow_type
) {
2365 if (nfc
->data
& RXH_IP_SRC
)
2366 hfld
|= ICE_FLOW_HASH_FLD_IPV4_SA
;
2367 if (nfc
->data
& RXH_IP_DST
)
2368 hfld
|= ICE_FLOW_HASH_FLD_IPV4_DA
;
2373 if (nfc
->data
& RXH_IP_SRC
)
2374 hfld
|= ICE_FLOW_HASH_FLD_IPV6_SA
;
2375 if (nfc
->data
& RXH_IP_DST
)
2376 hfld
|= ICE_FLOW_HASH_FLD_IPV6_DA
;
2383 if (nfc
->data
& RXH_L4_B_0_1
|| nfc
->data
& RXH_L4_B_2_3
) {
2384 switch (nfc
->flow_type
) {
2387 if (nfc
->data
& RXH_L4_B_0_1
)
2388 hfld
|= ICE_FLOW_HASH_FLD_TCP_SRC_PORT
;
2389 if (nfc
->data
& RXH_L4_B_2_3
)
2390 hfld
|= ICE_FLOW_HASH_FLD_TCP_DST_PORT
;
2394 if (nfc
->data
& RXH_L4_B_0_1
)
2395 hfld
|= ICE_FLOW_HASH_FLD_UDP_SRC_PORT
;
2396 if (nfc
->data
& RXH_L4_B_2_3
)
2397 hfld
|= ICE_FLOW_HASH_FLD_UDP_DST_PORT
;
2401 if (nfc
->data
& RXH_L4_B_0_1
)
2402 hfld
|= ICE_FLOW_HASH_FLD_SCTP_SRC_PORT
;
2403 if (nfc
->data
& RXH_L4_B_2_3
)
2404 hfld
|= ICE_FLOW_HASH_FLD_SCTP_DST_PORT
;
2415 * ice_set_rss_hash_opt - Enable/Disable flow types for RSS hash
2416 * @vsi: the VSI being configured
2417 * @nfc: ethtool rxnfc command
2419 * Returns Success if the flow input set is supported.
2422 ice_set_rss_hash_opt(struct ice_vsi
*vsi
, struct ethtool_rxnfc
*nfc
)
2424 struct ice_pf
*pf
= vsi
->back
;
2425 enum ice_status status
;
2430 dev
= ice_pf_to_dev(pf
);
2431 if (ice_is_safe_mode(pf
)) {
2432 dev_dbg(dev
, "Advanced RSS disabled. Package download failed, vsi num = %d\n",
2437 hashed_flds
= ice_parse_hash_flds(nfc
);
2438 if (hashed_flds
== ICE_HASH_INVALID
) {
2439 dev_dbg(dev
, "Invalid hash fields, vsi num = %d\n",
2444 hdrs
= ice_parse_hdrs(nfc
);
2445 if (hdrs
== ICE_FLOW_SEG_HDR_NONE
) {
2446 dev_dbg(dev
, "Header type is not valid, vsi num = %d\n",
2451 status
= ice_add_rss_cfg(&pf
->hw
, vsi
->idx
, hashed_flds
, hdrs
);
2453 dev_dbg(dev
, "ice_add_rss_cfg failed, vsi num = %d, error = %d\n",
2454 vsi
->vsi_num
, status
);
2462 * ice_get_rss_hash_opt - Retrieve hash fields for a given flow-type
2463 * @vsi: the VSI being configured
2464 * @nfc: ethtool rxnfc command
2467 ice_get_rss_hash_opt(struct ice_vsi
*vsi
, struct ethtool_rxnfc
*nfc
)
2469 struct ice_pf
*pf
= vsi
->back
;
2474 dev
= ice_pf_to_dev(pf
);
2477 if (ice_is_safe_mode(pf
)) {
2478 dev_dbg(dev
, "Advanced RSS disabled. Package download failed, vsi num = %d\n",
2483 hdrs
= ice_parse_hdrs(nfc
);
2484 if (hdrs
== ICE_FLOW_SEG_HDR_NONE
) {
2485 dev_dbg(dev
, "Header type is not valid, vsi num = %d\n",
2490 hash_flds
= ice_get_rss_cfg(&pf
->hw
, vsi
->idx
, hdrs
);
2491 if (hash_flds
== ICE_HASH_INVALID
) {
2492 dev_dbg(dev
, "No hash fields found for the given header type, vsi num = %d\n",
2497 if (hash_flds
& ICE_FLOW_HASH_FLD_IPV4_SA
||
2498 hash_flds
& ICE_FLOW_HASH_FLD_IPV6_SA
)
2499 nfc
->data
|= (u64
)RXH_IP_SRC
;
2501 if (hash_flds
& ICE_FLOW_HASH_FLD_IPV4_DA
||
2502 hash_flds
& ICE_FLOW_HASH_FLD_IPV6_DA
)
2503 nfc
->data
|= (u64
)RXH_IP_DST
;
2505 if (hash_flds
& ICE_FLOW_HASH_FLD_TCP_SRC_PORT
||
2506 hash_flds
& ICE_FLOW_HASH_FLD_UDP_SRC_PORT
||
2507 hash_flds
& ICE_FLOW_HASH_FLD_SCTP_SRC_PORT
)
2508 nfc
->data
|= (u64
)RXH_L4_B_0_1
;
2510 if (hash_flds
& ICE_FLOW_HASH_FLD_TCP_DST_PORT
||
2511 hash_flds
& ICE_FLOW_HASH_FLD_UDP_DST_PORT
||
2512 hash_flds
& ICE_FLOW_HASH_FLD_SCTP_DST_PORT
)
2513 nfc
->data
|= (u64
)RXH_L4_B_2_3
;
2517 * ice_set_rxnfc - command to set Rx flow rules.
2518 * @netdev: network interface device structure
2519 * @cmd: ethtool rxnfc command
2521 * Returns 0 for success and negative values for errors
2523 static int ice_set_rxnfc(struct net_device
*netdev
, struct ethtool_rxnfc
*cmd
)
2525 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
2526 struct ice_vsi
*vsi
= np
->vsi
;
2530 return ice_set_rss_hash_opt(vsi
, cmd
);
2538 * ice_get_rxnfc - command to get Rx flow classification rules
2539 * @netdev: network interface device structure
2540 * @cmd: ethtool rxnfc command
2541 * @rule_locs: buffer to rturn Rx flow classification rules
2543 * Returns Success if the command is supported.
2546 ice_get_rxnfc(struct net_device
*netdev
, struct ethtool_rxnfc
*cmd
,
2547 u32 __always_unused
*rule_locs
)
2549 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
2550 struct ice_vsi
*vsi
= np
->vsi
;
2551 int ret
= -EOPNOTSUPP
;
2554 case ETHTOOL_GRXRINGS
:
2555 cmd
->data
= vsi
->rss_size
;
2559 ice_get_rss_hash_opt(vsi
, cmd
);
2570 ice_get_ringparam(struct net_device
*netdev
, struct ethtool_ringparam
*ring
)
2572 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
2573 struct ice_vsi
*vsi
= np
->vsi
;
2575 ring
->rx_max_pending
= ICE_MAX_NUM_DESC
;
2576 ring
->tx_max_pending
= ICE_MAX_NUM_DESC
;
2577 ring
->rx_pending
= vsi
->rx_rings
[0]->count
;
2578 ring
->tx_pending
= vsi
->tx_rings
[0]->count
;
2580 /* Rx mini and jumbo rings are not supported */
2581 ring
->rx_mini_max_pending
= 0;
2582 ring
->rx_jumbo_max_pending
= 0;
2583 ring
->rx_mini_pending
= 0;
2584 ring
->rx_jumbo_pending
= 0;
2588 ice_set_ringparam(struct net_device
*netdev
, struct ethtool_ringparam
*ring
)
2590 struct ice_ring
*tx_rings
= NULL
, *rx_rings
= NULL
;
2591 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
2592 struct ice_ring
*xdp_rings
= NULL
;
2593 struct ice_vsi
*vsi
= np
->vsi
;
2594 struct ice_pf
*pf
= vsi
->back
;
2595 int i
, timeout
= 50, err
= 0;
2596 u32 new_rx_cnt
, new_tx_cnt
;
2598 if (ring
->tx_pending
> ICE_MAX_NUM_DESC
||
2599 ring
->tx_pending
< ICE_MIN_NUM_DESC
||
2600 ring
->rx_pending
> ICE_MAX_NUM_DESC
||
2601 ring
->rx_pending
< ICE_MIN_NUM_DESC
) {
2602 netdev_err(netdev
, "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d] (increment %d)\n",
2603 ring
->tx_pending
, ring
->rx_pending
,
2604 ICE_MIN_NUM_DESC
, ICE_MAX_NUM_DESC
,
2605 ICE_REQ_DESC_MULTIPLE
);
2609 new_tx_cnt
= ALIGN(ring
->tx_pending
, ICE_REQ_DESC_MULTIPLE
);
2610 if (new_tx_cnt
!= ring
->tx_pending
)
2611 netdev_info(netdev
, "Requested Tx descriptor count rounded up to %d\n",
2613 new_rx_cnt
= ALIGN(ring
->rx_pending
, ICE_REQ_DESC_MULTIPLE
);
2614 if (new_rx_cnt
!= ring
->rx_pending
)
2615 netdev_info(netdev
, "Requested Rx descriptor count rounded up to %d\n",
2618 /* if nothing to do return success */
2619 if (new_tx_cnt
== vsi
->tx_rings
[0]->count
&&
2620 new_rx_cnt
== vsi
->rx_rings
[0]->count
) {
2621 netdev_dbg(netdev
, "Nothing to change, descriptor count is same as requested\n");
2625 /* If there is a AF_XDP UMEM attached to any of Rx rings,
2626 * disallow changing the number of descriptors -- regardless
2627 * if the netdev is running or not.
2629 if (ice_xsk_any_rx_ring_ena(vsi
))
2632 while (test_and_set_bit(__ICE_CFG_BUSY
, pf
->state
)) {
2636 usleep_range(1000, 2000);
2639 /* set for the next time the netdev is started */
2640 if (!netif_running(vsi
->netdev
)) {
2641 for (i
= 0; i
< vsi
->alloc_txq
; i
++)
2642 vsi
->tx_rings
[i
]->count
= new_tx_cnt
;
2643 for (i
= 0; i
< vsi
->alloc_rxq
; i
++)
2644 vsi
->rx_rings
[i
]->count
= new_rx_cnt
;
2645 if (ice_is_xdp_ena_vsi(vsi
))
2646 for (i
= 0; i
< vsi
->num_xdp_txq
; i
++)
2647 vsi
->xdp_rings
[i
]->count
= new_tx_cnt
;
2648 vsi
->num_tx_desc
= new_tx_cnt
;
2649 vsi
->num_rx_desc
= new_rx_cnt
;
2650 netdev_dbg(netdev
, "Link is down, descriptor count change happens when link is brought up\n");
2654 if (new_tx_cnt
== vsi
->tx_rings
[0]->count
)
2657 /* alloc updated Tx resources */
2658 netdev_info(netdev
, "Changing Tx descriptor count from %d to %d\n",
2659 vsi
->tx_rings
[0]->count
, new_tx_cnt
);
2661 tx_rings
= kcalloc(vsi
->num_txq
, sizeof(*tx_rings
), GFP_KERNEL
);
2667 ice_for_each_txq(vsi
, i
) {
2668 /* clone ring and setup updated count */
2669 tx_rings
[i
] = *vsi
->tx_rings
[i
];
2670 tx_rings
[i
].count
= new_tx_cnt
;
2671 tx_rings
[i
].desc
= NULL
;
2672 tx_rings
[i
].tx_buf
= NULL
;
2673 err
= ice_setup_tx_ring(&tx_rings
[i
]);
2676 ice_clean_tx_ring(&tx_rings
[i
]);
2682 if (!ice_is_xdp_ena_vsi(vsi
))
2685 /* alloc updated XDP resources */
2686 netdev_info(netdev
, "Changing XDP descriptor count from %d to %d\n",
2687 vsi
->xdp_rings
[0]->count
, new_tx_cnt
);
2689 xdp_rings
= kcalloc(vsi
->num_xdp_txq
, sizeof(*xdp_rings
), GFP_KERNEL
);
2695 for (i
= 0; i
< vsi
->num_xdp_txq
; i
++) {
2696 /* clone ring and setup updated count */
2697 xdp_rings
[i
] = *vsi
->xdp_rings
[i
];
2698 xdp_rings
[i
].count
= new_tx_cnt
;
2699 xdp_rings
[i
].desc
= NULL
;
2700 xdp_rings
[i
].tx_buf
= NULL
;
2701 err
= ice_setup_tx_ring(&xdp_rings
[i
]);
2704 ice_clean_tx_ring(&xdp_rings
[i
]);
2708 ice_set_ring_xdp(&xdp_rings
[i
]);
2712 if (new_rx_cnt
== vsi
->rx_rings
[0]->count
)
2715 /* alloc updated Rx resources */
2716 netdev_info(netdev
, "Changing Rx descriptor count from %d to %d\n",
2717 vsi
->rx_rings
[0]->count
, new_rx_cnt
);
2719 rx_rings
= kcalloc(vsi
->num_rxq
, sizeof(*rx_rings
), GFP_KERNEL
);
2725 ice_for_each_rxq(vsi
, i
) {
2726 /* clone ring and setup updated count */
2727 rx_rings
[i
] = *vsi
->rx_rings
[i
];
2728 rx_rings
[i
].count
= new_rx_cnt
;
2729 rx_rings
[i
].desc
= NULL
;
2730 rx_rings
[i
].rx_buf
= NULL
;
2731 /* this is to allow wr32 to have something to write to
2732 * during early allocation of Rx buffers
2734 rx_rings
[i
].tail
= vsi
->back
->hw
.hw_addr
+ PRTGEN_STATUS
;
2736 err
= ice_setup_rx_ring(&rx_rings
[i
]);
2740 /* allocate Rx buffers */
2741 err
= ice_alloc_rx_bufs(&rx_rings
[i
],
2742 ICE_DESC_UNUSED(&rx_rings
[i
]));
2747 ice_free_rx_ring(&rx_rings
[i
]);
2756 /* Bring interface down, copy in the new ring info, then restore the
2757 * interface. if VSI is up, bring it down and then back up
2759 if (!test_and_set_bit(__ICE_DOWN
, vsi
->state
)) {
2763 ice_for_each_txq(vsi
, i
) {
2764 ice_free_tx_ring(vsi
->tx_rings
[i
]);
2765 *vsi
->tx_rings
[i
] = tx_rings
[i
];
2771 ice_for_each_rxq(vsi
, i
) {
2772 ice_free_rx_ring(vsi
->rx_rings
[i
]);
2773 /* copy the real tail offset */
2774 rx_rings
[i
].tail
= vsi
->rx_rings
[i
]->tail
;
2775 /* this is to fake out the allocation routine
2776 * into thinking it has to realloc everything
2777 * but the recycling logic will let us re-use
2778 * the buffers allocated above
2780 rx_rings
[i
].next_to_use
= 0;
2781 rx_rings
[i
].next_to_clean
= 0;
2782 rx_rings
[i
].next_to_alloc
= 0;
2783 *vsi
->rx_rings
[i
] = rx_rings
[i
];
2789 for (i
= 0; i
< vsi
->num_xdp_txq
; i
++) {
2790 ice_free_tx_ring(vsi
->xdp_rings
[i
]);
2791 *vsi
->xdp_rings
[i
] = xdp_rings
[i
];
2796 vsi
->num_tx_desc
= new_tx_cnt
;
2797 vsi
->num_rx_desc
= new_rx_cnt
;
2803 /* error cleanup if the Rx allocations failed after getting Tx */
2805 ice_for_each_txq(vsi
, i
)
2806 ice_free_tx_ring(&tx_rings
[i
]);
2811 clear_bit(__ICE_CFG_BUSY
, pf
->state
);
2816 * ice_get_pauseparam - Get Flow Control status
2817 * @netdev: network interface device structure
2818 * @pause: ethernet pause (flow control) parameters
2820 * Get requested flow control status from PHY capability.
2821 * If autoneg is true, then ethtool will send the ETHTOOL_GSET ioctl which
2822 * is handled by ice_get_link_ksettings. ice_get_link_ksettings will report
2823 * the negotiated Rx/Tx pause via lp_advertising.
2826 ice_get_pauseparam(struct net_device
*netdev
, struct ethtool_pauseparam
*pause
)
2828 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
2829 struct ice_port_info
*pi
= np
->vsi
->port_info
;
2830 struct ice_aqc_get_phy_caps_data
*pcaps
;
2831 struct ice_dcbx_cfg
*dcbx_cfg
;
2832 enum ice_status status
;
2834 /* Initialize pause params */
2835 pause
->rx_pause
= 0;
2836 pause
->tx_pause
= 0;
2838 dcbx_cfg
= &pi
->local_dcbx_cfg
;
2840 pcaps
= kzalloc(sizeof(*pcaps
), GFP_KERNEL
);
2844 /* Get current PHY config */
2845 status
= ice_aq_get_phy_caps(pi
, false, ICE_AQC_REPORT_SW_CFG
, pcaps
,
2850 pause
->autoneg
= ((pcaps
->caps
& ICE_AQC_PHY_AN_MODE
) ?
2851 AUTONEG_ENABLE
: AUTONEG_DISABLE
);
2853 if (dcbx_cfg
->pfc
.pfcena
)
2854 /* PFC enabled so report LFC as off */
2857 if (pcaps
->caps
& ICE_AQC_PHY_EN_TX_LINK_PAUSE
)
2858 pause
->tx_pause
= 1;
2859 if (pcaps
->caps
& ICE_AQC_PHY_EN_RX_LINK_PAUSE
)
2860 pause
->rx_pause
= 1;
2867 * ice_set_pauseparam - Set Flow Control parameter
2868 * @netdev: network interface device structure
2869 * @pause: return Tx/Rx flow control status
2872 ice_set_pauseparam(struct net_device
*netdev
, struct ethtool_pauseparam
*pause
)
2874 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
2875 struct ice_aqc_get_phy_caps_data
*pcaps
;
2876 struct ice_link_status
*hw_link_info
;
2877 struct ice_pf
*pf
= np
->vsi
->back
;
2878 struct ice_dcbx_cfg
*dcbx_cfg
;
2879 struct ice_vsi
*vsi
= np
->vsi
;
2880 struct ice_hw
*hw
= &pf
->hw
;
2881 struct ice_port_info
*pi
;
2882 enum ice_status status
;
2888 pi
= vsi
->port_info
;
2889 hw_link_info
= &pi
->phy
.link_info
;
2890 dcbx_cfg
= &pi
->local_dcbx_cfg
;
2891 link_up
= hw_link_info
->link_info
& ICE_AQ_LINK_UP
;
2893 /* Changing the port's flow control is not supported if this isn't the
2896 if (vsi
->type
!= ICE_VSI_PF
) {
2897 netdev_info(netdev
, "Changing flow control parameters only supported for PF VSI\n");
2901 /* Get pause param reports configured and negotiated flow control pause
2902 * when ETHTOOL_GLINKSETTINGS is defined. Since ETHTOOL_GLINKSETTINGS is
2903 * defined get pause param pause->autoneg reports SW configured setting,
2904 * so compare pause->autoneg with SW configured to prevent the user from
2905 * using set pause param to chance autoneg.
2907 pcaps
= kzalloc(sizeof(*pcaps
), GFP_KERNEL
);
2911 /* Get current PHY config */
2912 status
= ice_aq_get_phy_caps(pi
, false, ICE_AQC_REPORT_SW_CFG
, pcaps
,
2919 is_an
= ((pcaps
->caps
& ICE_AQC_PHY_AN_MODE
) ?
2920 AUTONEG_ENABLE
: AUTONEG_DISABLE
);
2924 if (pause
->autoneg
!= is_an
) {
2925 netdev_info(netdev
, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n");
2929 /* If we have link and don't have autoneg */
2930 if (!test_bit(__ICE_DOWN
, pf
->state
) &&
2931 !(hw_link_info
->an_info
& ICE_AQ_AN_COMPLETED
)) {
2932 /* Send message that it might not necessarily work*/
2933 netdev_info(netdev
, "Autoneg did not complete so changing settings may not result in an actual change.\n");
2936 if (dcbx_cfg
->pfc
.pfcena
) {
2937 netdev_info(netdev
, "Priority flow control enabled. Cannot set link flow control.\n");
2940 if (pause
->rx_pause
&& pause
->tx_pause
)
2941 pi
->fc
.req_mode
= ICE_FC_FULL
;
2942 else if (pause
->rx_pause
&& !pause
->tx_pause
)
2943 pi
->fc
.req_mode
= ICE_FC_RX_PAUSE
;
2944 else if (!pause
->rx_pause
&& pause
->tx_pause
)
2945 pi
->fc
.req_mode
= ICE_FC_TX_PAUSE
;
2946 else if (!pause
->rx_pause
&& !pause
->tx_pause
)
2947 pi
->fc
.req_mode
= ICE_FC_NONE
;
2951 /* Set the FC mode and only restart AN if link is up */
2952 status
= ice_set_fc(pi
, &aq_failures
, link_up
);
2954 if (aq_failures
& ICE_SET_FC_AQ_FAIL_GET
) {
2955 netdev_info(netdev
, "Set fc failed on the get_phy_capabilities call with err %d aq_err %d\n",
2956 status
, hw
->adminq
.sq_last_status
);
2958 } else if (aq_failures
& ICE_SET_FC_AQ_FAIL_SET
) {
2959 netdev_info(netdev
, "Set fc failed on the set_phy_config call with err %d aq_err %d\n",
2960 status
, hw
->adminq
.sq_last_status
);
2962 } else if (aq_failures
& ICE_SET_FC_AQ_FAIL_UPDATE
) {
2963 netdev_info(netdev
, "Set fc failed on the get_link_info call with err %d aq_err %d\n",
2964 status
, hw
->adminq
.sq_last_status
);
2968 if (!test_bit(__ICE_DOWN
, pf
->state
)) {
2969 /* Give it a little more time to try to come back. If still
2970 * down, restart autoneg link or reinitialize the interface.
2973 if (!test_bit(__ICE_DOWN
, pf
->state
))
2974 return ice_nway_reset(netdev
);
2984 * ice_get_rxfh_key_size - get the RSS hash key size
2985 * @netdev: network interface device structure
2987 * Returns the table size.
2989 static u32
ice_get_rxfh_key_size(struct net_device __always_unused
*netdev
)
2991 return ICE_VSIQF_HKEY_ARRAY_SIZE
;
2995 * ice_get_rxfh_indir_size - get the Rx flow hash indirection table size
2996 * @netdev: network interface device structure
2998 * Returns the table size.
3000 static u32
ice_get_rxfh_indir_size(struct net_device
*netdev
)
3002 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
3004 return np
->vsi
->rss_table_size
;
3008 * ice_get_rxfh - get the Rx flow hash indirection table
3009 * @netdev: network interface device structure
3010 * @indir: indirection table
3012 * @hfunc: hash function
3014 * Reads the indirection table directly from the hardware.
3017 ice_get_rxfh(struct net_device
*netdev
, u32
*indir
, u8
*key
, u8
*hfunc
)
3019 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
3020 struct ice_vsi
*vsi
= np
->vsi
;
3021 struct ice_pf
*pf
= vsi
->back
;
3026 *hfunc
= ETH_RSS_HASH_TOP
;
3031 if (!test_bit(ICE_FLAG_RSS_ENA
, pf
->flags
)) {
3032 /* RSS not supported return error here */
3033 netdev_warn(netdev
, "RSS is not configured on this VSI!\n");
3037 lut
= kzalloc(vsi
->rss_table_size
, GFP_KERNEL
);
3041 if (ice_get_rss(vsi
, key
, lut
, vsi
->rss_table_size
)) {
3046 for (i
= 0; i
< vsi
->rss_table_size
; i
++)
3047 indir
[i
] = (u32
)(lut
[i
]);
3055 * ice_set_rxfh - set the Rx flow hash indirection table
3056 * @netdev: network interface device structure
3057 * @indir: indirection table
3059 * @hfunc: hash function
3061 * Returns -EINVAL if the table specifies an invalid queue ID, otherwise
3062 * returns 0 after programming the table.
3065 ice_set_rxfh(struct net_device
*netdev
, const u32
*indir
, const u8
*key
,
3068 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
3069 struct ice_vsi
*vsi
= np
->vsi
;
3070 struct ice_pf
*pf
= vsi
->back
;
3074 dev
= ice_pf_to_dev(pf
);
3075 if (hfunc
!= ETH_RSS_HASH_NO_CHANGE
&& hfunc
!= ETH_RSS_HASH_TOP
)
3078 if (!test_bit(ICE_FLAG_RSS_ENA
, pf
->flags
)) {
3079 /* RSS not supported return error here */
3080 netdev_warn(netdev
, "RSS is not configured on this VSI!\n");
3085 if (!vsi
->rss_hkey_user
) {
3086 vsi
->rss_hkey_user
=
3087 devm_kzalloc(dev
, ICE_VSIQF_HKEY_ARRAY_SIZE
,
3089 if (!vsi
->rss_hkey_user
)
3092 memcpy(vsi
->rss_hkey_user
, key
, ICE_VSIQF_HKEY_ARRAY_SIZE
);
3093 seed
= vsi
->rss_hkey_user
;
3096 if (!vsi
->rss_lut_user
) {
3097 vsi
->rss_lut_user
= devm_kzalloc(dev
, vsi
->rss_table_size
,
3099 if (!vsi
->rss_lut_user
)
3103 /* Each 32 bits pointed by 'indir' is stored with a lut entry */
3107 for (i
= 0; i
< vsi
->rss_table_size
; i
++)
3108 vsi
->rss_lut_user
[i
] = (u8
)(indir
[i
]);
3110 ice_fill_rss_lut(vsi
->rss_lut_user
, vsi
->rss_table_size
,
3114 if (ice_set_rss(vsi
, seed
, vsi
->rss_lut_user
, vsi
->rss_table_size
))
3121 * ice_get_max_txq - return the maximum number of Tx queues for in a PF
3124 static int ice_get_max_txq(struct ice_pf
*pf
)
3126 return min_t(int, num_online_cpus(),
3127 pf
->hw
.func_caps
.common_cap
.num_txq
);
3131 * ice_get_max_rxq - return the maximum number of Rx queues for in a PF
3134 static int ice_get_max_rxq(struct ice_pf
*pf
)
3136 return min_t(int, num_online_cpus(),
3137 pf
->hw
.func_caps
.common_cap
.num_rxq
);
3141 * ice_get_combined_cnt - return the current number of combined channels
3142 * @vsi: PF VSI pointer
3144 * Go through all queue vectors and count ones that have both Rx and Tx ring
3147 static u32
ice_get_combined_cnt(struct ice_vsi
*vsi
)
3152 ice_for_each_q_vector(vsi
, q_idx
) {
3153 struct ice_q_vector
*q_vector
= vsi
->q_vectors
[q_idx
];
3155 if (q_vector
->rx
.ring
&& q_vector
->tx
.ring
)
3163 * ice_get_channels - get the current and max supported channels
3164 * @dev: network interface device structure
3165 * @ch: ethtool channel data structure
3168 ice_get_channels(struct net_device
*dev
, struct ethtool_channels
*ch
)
3170 struct ice_netdev_priv
*np
= netdev_priv(dev
);
3171 struct ice_vsi
*vsi
= np
->vsi
;
3172 struct ice_pf
*pf
= vsi
->back
;
3174 /* check to see if VSI is active */
3175 if (test_bit(__ICE_DOWN
, vsi
->state
))
3178 /* report maximum channels */
3179 ch
->max_rx
= ice_get_max_rxq(pf
);
3180 ch
->max_tx
= ice_get_max_txq(pf
);
3181 ch
->max_combined
= min_t(int, ch
->max_rx
, ch
->max_tx
);
3183 /* report current channels */
3184 ch
->combined_count
= ice_get_combined_cnt(vsi
);
3185 ch
->rx_count
= vsi
->num_rxq
- ch
->combined_count
;
3186 ch
->tx_count
= vsi
->num_txq
- ch
->combined_count
;
3190 * ice_vsi_set_dflt_rss_lut - set default RSS LUT with requested RSS size
3191 * @vsi: VSI to reconfigure RSS LUT on
3192 * @req_rss_size: requested range of queue numbers for hashing
3194 * Set the VSI's RSS parameters, configure the RSS LUT based on these.
3196 static int ice_vsi_set_dflt_rss_lut(struct ice_vsi
*vsi
, int req_rss_size
)
3198 struct ice_pf
*pf
= vsi
->back
;
3199 enum ice_status status
;
3205 dev
= ice_pf_to_dev(pf
);
3211 lut
= kzalloc(vsi
->rss_table_size
, GFP_KERNEL
);
3215 /* set RSS LUT parameters */
3216 if (!test_bit(ICE_FLAG_RSS_ENA
, pf
->flags
)) {
3219 struct ice_hw_common_caps
*caps
= &hw
->func_caps
.common_cap
;
3221 vsi
->rss_size
= min_t(int, req_rss_size
,
3222 BIT(caps
->rss_table_entry_width
));
3225 /* create/set RSS LUT */
3226 ice_fill_rss_lut(lut
, vsi
->rss_table_size
, vsi
->rss_size
);
3227 status
= ice_aq_set_rss_lut(hw
, vsi
->idx
, vsi
->rss_lut_type
, lut
,
3228 vsi
->rss_table_size
);
3230 dev_err(dev
, "Cannot set RSS lut, err %d aq_err %d\n",
3231 status
, hw
->adminq
.rq_last_status
);
3240 * ice_set_channels - set the number channels
3241 * @dev: network interface device structure
3242 * @ch: ethtool channel data structure
3244 static int ice_set_channels(struct net_device
*dev
, struct ethtool_channels
*ch
)
3246 struct ice_netdev_priv
*np
= netdev_priv(dev
);
3247 struct ice_vsi
*vsi
= np
->vsi
;
3248 struct ice_pf
*pf
= vsi
->back
;
3249 int new_rx
= 0, new_tx
= 0;
3252 /* do not support changing channels in Safe Mode */
3253 if (ice_is_safe_mode(pf
)) {
3254 netdev_err(dev
, "Changing channel in Safe Mode is not supported\n");
3257 /* do not support changing other_count */
3258 if (ch
->other_count
)
3261 curr_combined
= ice_get_combined_cnt(vsi
);
3263 /* these checks are for cases where user didn't specify a particular
3264 * value on cmd line but we get non-zero value anyway via
3265 * get_channels(); look at ethtool.c in ethtool repository (the user
3266 * space part), particularly, do_schannels() routine
3268 if (ch
->rx_count
== vsi
->num_rxq
- curr_combined
)
3270 if (ch
->tx_count
== vsi
->num_txq
- curr_combined
)
3272 if (ch
->combined_count
== curr_combined
)
3273 ch
->combined_count
= 0;
3275 if (!(ch
->combined_count
|| (ch
->rx_count
&& ch
->tx_count
))) {
3276 netdev_err(dev
, "Please specify at least 1 Rx and 1 Tx channel\n");
3280 new_rx
= ch
->combined_count
+ ch
->rx_count
;
3281 new_tx
= ch
->combined_count
+ ch
->tx_count
;
3283 if (new_rx
> ice_get_max_rxq(pf
)) {
3284 netdev_err(dev
, "Maximum allowed Rx channels is %d\n",
3285 ice_get_max_rxq(pf
));
3288 if (new_tx
> ice_get_max_txq(pf
)) {
3289 netdev_err(dev
, "Maximum allowed Tx channels is %d\n",
3290 ice_get_max_txq(pf
));
3294 ice_vsi_recfg_qs(vsi
, new_rx
, new_tx
);
3296 if (new_rx
&& !netif_is_rxfh_configured(dev
))
3297 return ice_vsi_set_dflt_rss_lut(vsi
, new_rx
);
3302 enum ice_container_type
{
3308 * ice_get_rc_coalesce - get ITR values for specific ring container
3309 * @ec: ethtool structure to fill with driver's coalesce settings
3310 * @c_type: container type, Rx or Tx
3311 * @rc: ring container that the ITR values will come from
3313 * Query the device for ice_ring_container specific ITR values. This is
3314 * done per ice_ring_container because each q_vector can have 1 or more rings
3315 * and all of said ring(s) will have the same ITR values.
3317 * Returns 0 on success, negative otherwise.
3320 ice_get_rc_coalesce(struct ethtool_coalesce
*ec
, enum ice_container_type c_type
,
3321 struct ice_ring_container
*rc
)
3328 pf
= rc
->ring
->vsi
->back
;
3331 case ICE_RX_CONTAINER
:
3332 ec
->use_adaptive_rx_coalesce
= ITR_IS_DYNAMIC(rc
->itr_setting
);
3333 ec
->rx_coalesce_usecs
= rc
->itr_setting
& ~ICE_ITR_DYNAMIC
;
3334 ec
->rx_coalesce_usecs_high
= rc
->ring
->q_vector
->intrl
;
3336 case ICE_TX_CONTAINER
:
3337 ec
->use_adaptive_tx_coalesce
= ITR_IS_DYNAMIC(rc
->itr_setting
);
3338 ec
->tx_coalesce_usecs
= rc
->itr_setting
& ~ICE_ITR_DYNAMIC
;
3341 dev_dbg(ice_pf_to_dev(pf
), "Invalid c_type %d\n", c_type
);
3349 * ice_get_q_coalesce - get a queue's ITR/INTRL (coalesce) settings
3350 * @vsi: VSI associated to the queue for getting ITR/INTRL (coalesce) settings
3351 * @ec: coalesce settings to program the device with
3352 * @q_num: update ITR/INTRL (coalesce) settings for this queue number/index
3354 * Return 0 on success, and negative under the following conditions:
3355 * 1. Getting Tx or Rx ITR/INTRL (coalesce) settings failed.
3356 * 2. The q_num passed in is not a valid number/index for Tx and Rx rings.
3359 ice_get_q_coalesce(struct ice_vsi
*vsi
, struct ethtool_coalesce
*ec
, int q_num
)
3361 if (q_num
< vsi
->num_rxq
&& q_num
< vsi
->num_txq
) {
3362 if (ice_get_rc_coalesce(ec
, ICE_RX_CONTAINER
,
3363 &vsi
->rx_rings
[q_num
]->q_vector
->rx
))
3365 if (ice_get_rc_coalesce(ec
, ICE_TX_CONTAINER
,
3366 &vsi
->tx_rings
[q_num
]->q_vector
->tx
))
3368 } else if (q_num
< vsi
->num_rxq
) {
3369 if (ice_get_rc_coalesce(ec
, ICE_RX_CONTAINER
,
3370 &vsi
->rx_rings
[q_num
]->q_vector
->rx
))
3372 } else if (q_num
< vsi
->num_txq
) {
3373 if (ice_get_rc_coalesce(ec
, ICE_TX_CONTAINER
,
3374 &vsi
->tx_rings
[q_num
]->q_vector
->tx
))
3384 * __ice_get_coalesce - get ITR/INTRL values for the device
3385 * @netdev: pointer to the netdev associated with this query
3386 * @ec: ethtool structure to fill with driver's coalesce settings
3387 * @q_num: queue number to get the coalesce settings for
3389 * If the caller passes in a negative q_num then we return coalesce settings
3390 * based on queue number 0, else use the actual q_num passed in.
3393 __ice_get_coalesce(struct net_device
*netdev
, struct ethtool_coalesce
*ec
,
3396 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
3397 struct ice_vsi
*vsi
= np
->vsi
;
3402 if (ice_get_q_coalesce(vsi
, ec
, q_num
))
3409 ice_get_coalesce(struct net_device
*netdev
, struct ethtool_coalesce
*ec
)
3411 return __ice_get_coalesce(netdev
, ec
, -1);
3415 ice_get_per_q_coalesce(struct net_device
*netdev
, u32 q_num
,
3416 struct ethtool_coalesce
*ec
)
3418 return __ice_get_coalesce(netdev
, ec
, q_num
);
3422 * ice_set_rc_coalesce - set ITR values for specific ring container
3423 * @c_type: container type, Rx or Tx
3424 * @ec: ethtool structure from user to update ITR settings
3425 * @rc: ring container that the ITR values will come from
3426 * @vsi: VSI associated to the ring container
3428 * Set specific ITR values. This is done per ice_ring_container because each
3429 * q_vector can have 1 or more rings and all of said ring(s) will have the same
3432 * Returns 0 on success, negative otherwise.
3435 ice_set_rc_coalesce(enum ice_container_type c_type
, struct ethtool_coalesce
*ec
,
3436 struct ice_ring_container
*rc
, struct ice_vsi
*vsi
)
3438 const char *c_type_str
= (c_type
== ICE_RX_CONTAINER
) ? "rx" : "tx";
3439 u32 use_adaptive_coalesce
, coalesce_usecs
;
3440 struct ice_pf
*pf
= vsi
->back
;
3447 case ICE_RX_CONTAINER
:
3448 if (ec
->rx_coalesce_usecs_high
> ICE_MAX_INTRL
||
3449 (ec
->rx_coalesce_usecs_high
&&
3450 ec
->rx_coalesce_usecs_high
< pf
->hw
.intrl_gran
)) {
3451 netdev_info(vsi
->netdev
, "Invalid value, %s-usecs-high valid values are 0 (disabled), %d-%d\n",
3452 c_type_str
, pf
->hw
.intrl_gran
,
3456 if (ec
->rx_coalesce_usecs_high
!= rc
->ring
->q_vector
->intrl
) {
3457 rc
->ring
->q_vector
->intrl
= ec
->rx_coalesce_usecs_high
;
3458 wr32(&pf
->hw
, GLINT_RATE(rc
->ring
->q_vector
->reg_idx
),
3459 ice_intrl_usec_to_reg(ec
->rx_coalesce_usecs_high
,
3460 pf
->hw
.intrl_gran
));
3463 use_adaptive_coalesce
= ec
->use_adaptive_rx_coalesce
;
3464 coalesce_usecs
= ec
->rx_coalesce_usecs
;
3467 case ICE_TX_CONTAINER
:
3468 use_adaptive_coalesce
= ec
->use_adaptive_tx_coalesce
;
3469 coalesce_usecs
= ec
->tx_coalesce_usecs
;
3473 dev_dbg(ice_pf_to_dev(pf
), "Invalid container type %d\n",
3478 itr_setting
= rc
->itr_setting
& ~ICE_ITR_DYNAMIC
;
3479 if (coalesce_usecs
!= itr_setting
&& use_adaptive_coalesce
) {
3480 netdev_info(vsi
->netdev
, "%s interrupt throttling cannot be changed if adaptive-%s is enabled\n",
3481 c_type_str
, c_type_str
);
3485 if (coalesce_usecs
> ICE_ITR_MAX
) {
3486 netdev_info(vsi
->netdev
, "Invalid value, %s-usecs range is 0-%d\n",
3487 c_type_str
, ICE_ITR_MAX
);
3491 if (use_adaptive_coalesce
) {
3492 rc
->itr_setting
|= ICE_ITR_DYNAMIC
;
3494 /* save the user set usecs */
3495 rc
->itr_setting
= coalesce_usecs
;
3496 /* device ITR granularity is in 2 usec increments */
3497 rc
->target_itr
= ITR_REG_ALIGN(rc
->itr_setting
);
3504 * ice_set_q_coalesce - set a queue's ITR/INTRL (coalesce) settings
3505 * @vsi: VSI associated to the queue that need updating
3506 * @ec: coalesce settings to program the device with
3507 * @q_num: update ITR/INTRL (coalesce) settings for this queue number/index
3509 * Return 0 on success, and negative under the following conditions:
3510 * 1. Setting Tx or Rx ITR/INTRL (coalesce) settings failed.
3511 * 2. The q_num passed in is not a valid number/index for Tx and Rx rings.
3514 ice_set_q_coalesce(struct ice_vsi
*vsi
, struct ethtool_coalesce
*ec
, int q_num
)
3516 if (q_num
< vsi
->num_rxq
&& q_num
< vsi
->num_txq
) {
3517 if (ice_set_rc_coalesce(ICE_RX_CONTAINER
, ec
,
3518 &vsi
->rx_rings
[q_num
]->q_vector
->rx
,
3522 if (ice_set_rc_coalesce(ICE_TX_CONTAINER
, ec
,
3523 &vsi
->tx_rings
[q_num
]->q_vector
->tx
,
3526 } else if (q_num
< vsi
->num_rxq
) {
3527 if (ice_set_rc_coalesce(ICE_RX_CONTAINER
, ec
,
3528 &vsi
->rx_rings
[q_num
]->q_vector
->rx
,
3531 } else if (q_num
< vsi
->num_txq
) {
3532 if (ice_set_rc_coalesce(ICE_TX_CONTAINER
, ec
,
3533 &vsi
->tx_rings
[q_num
]->q_vector
->tx
,
3544 * ice_print_if_odd_usecs - print message if user tries to set odd [tx|rx]-usecs
3545 * @netdev: netdev used for print
3546 * @itr_setting: previous user setting
3547 * @use_adaptive_coalesce: if adaptive coalesce is enabled or being enabled
3548 * @coalesce_usecs: requested value of [tx|rx]-usecs
3549 * @c_type_str: either "rx" or "tx" to match user set field of [tx|rx]-usecs
3552 ice_print_if_odd_usecs(struct net_device
*netdev
, u16 itr_setting
,
3553 u32 use_adaptive_coalesce
, u32 coalesce_usecs
,
3554 const char *c_type_str
)
3556 if (use_adaptive_coalesce
)
3559 itr_setting
= ITR_TO_REG(itr_setting
);
3561 if (itr_setting
!= coalesce_usecs
&& (coalesce_usecs
% 2))
3562 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",
3563 c_type_str
, coalesce_usecs
, c_type_str
,
3564 ITR_REG_ALIGN(coalesce_usecs
));
3568 * __ice_set_coalesce - set ITR/INTRL values for the device
3569 * @netdev: pointer to the netdev associated with this query
3570 * @ec: ethtool structure to fill with driver's coalesce settings
3571 * @q_num: queue number to get the coalesce settings for
3573 * If the caller passes in a negative q_num then we set the coalesce settings
3574 * for all Tx/Rx queues, else use the actual q_num passed in.
3577 __ice_set_coalesce(struct net_device
*netdev
, struct ethtool_coalesce
*ec
,
3580 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
3581 struct ice_vsi
*vsi
= np
->vsi
;
3584 struct ice_q_vector
*q_vector
= vsi
->q_vectors
[0];
3588 ice_print_if_odd_usecs(netdev
, q_vector
->rx
.itr_setting
,
3589 ec
->use_adaptive_rx_coalesce
,
3590 ec
->rx_coalesce_usecs
, "rx");
3592 ice_print_if_odd_usecs(netdev
, q_vector
->tx
.itr_setting
,
3593 ec
->use_adaptive_tx_coalesce
,
3594 ec
->tx_coalesce_usecs
, "tx");
3597 ice_for_each_q_vector(vsi
, v_idx
) {
3598 /* In some cases if DCB is configured the num_[rx|tx]q
3599 * can be less than vsi->num_q_vectors. This check
3600 * accounts for that so we don't report a false failure
3602 if (v_idx
>= vsi
->num_rxq
&& v_idx
>= vsi
->num_txq
)
3605 if (ice_set_q_coalesce(vsi
, ec
, v_idx
))
3611 if (ice_set_q_coalesce(vsi
, ec
, q_num
))
3620 ice_set_coalesce(struct net_device
*netdev
, struct ethtool_coalesce
*ec
)
3622 return __ice_set_coalesce(netdev
, ec
, -1);
3626 ice_set_per_q_coalesce(struct net_device
*netdev
, u32 q_num
,
3627 struct ethtool_coalesce
*ec
)
3629 return __ice_set_coalesce(netdev
, ec
, q_num
);
3632 #define ICE_I2C_EEPROM_DEV_ADDR 0xA0
3633 #define ICE_I2C_EEPROM_DEV_ADDR2 0xA2
3634 #define ICE_MODULE_TYPE_SFP 0x03
3635 #define ICE_MODULE_TYPE_QSFP_PLUS 0x0D
3636 #define ICE_MODULE_TYPE_QSFP28 0x11
3637 #define ICE_MODULE_SFF_ADDR_MODE 0x04
3638 #define ICE_MODULE_SFF_DIAG_CAPAB 0x40
3639 #define ICE_MODULE_REVISION_ADDR 0x01
3640 #define ICE_MODULE_SFF_8472_COMP 0x5E
3641 #define ICE_MODULE_SFF_8472_SWAP 0x5C
3642 #define ICE_MODULE_QSFP_MAX_LEN 640
3645 * ice_get_module_info - get SFF module type and revision information
3646 * @netdev: network interface device structure
3647 * @modinfo: module EEPROM size and layout information structure
3650 ice_get_module_info(struct net_device
*netdev
,
3651 struct ethtool_modinfo
*modinfo
)
3653 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
3654 struct ice_vsi
*vsi
= np
->vsi
;
3655 struct ice_pf
*pf
= vsi
->back
;
3656 struct ice_hw
*hw
= &pf
->hw
;
3657 enum ice_status status
;
3658 u8 sff8472_comp
= 0;
3659 u8 sff8472_swap
= 0;
3663 status
= ice_aq_sff_eeprom(hw
, 0, ICE_I2C_EEPROM_DEV_ADDR
, 0x00, 0x00,
3664 0, &value
, 1, 0, NULL
);
3669 case ICE_MODULE_TYPE_SFP
:
3670 status
= ice_aq_sff_eeprom(hw
, 0, ICE_I2C_EEPROM_DEV_ADDR
,
3671 ICE_MODULE_SFF_8472_COMP
, 0x00, 0,
3672 &sff8472_comp
, 1, 0, NULL
);
3675 status
= ice_aq_sff_eeprom(hw
, 0, ICE_I2C_EEPROM_DEV_ADDR
,
3676 ICE_MODULE_SFF_8472_SWAP
, 0x00, 0,
3677 &sff8472_swap
, 1, 0, NULL
);
3681 if (sff8472_swap
& ICE_MODULE_SFF_ADDR_MODE
) {
3682 modinfo
->type
= ETH_MODULE_SFF_8079
;
3683 modinfo
->eeprom_len
= ETH_MODULE_SFF_8079_LEN
;
3684 } else if (sff8472_comp
&&
3685 (sff8472_swap
& ICE_MODULE_SFF_DIAG_CAPAB
)) {
3686 modinfo
->type
= ETH_MODULE_SFF_8472
;
3687 modinfo
->eeprom_len
= ETH_MODULE_SFF_8472_LEN
;
3689 modinfo
->type
= ETH_MODULE_SFF_8079
;
3690 modinfo
->eeprom_len
= ETH_MODULE_SFF_8079_LEN
;
3693 case ICE_MODULE_TYPE_QSFP_PLUS
:
3694 case ICE_MODULE_TYPE_QSFP28
:
3695 status
= ice_aq_sff_eeprom(hw
, 0, ICE_I2C_EEPROM_DEV_ADDR
,
3696 ICE_MODULE_REVISION_ADDR
, 0x00, 0,
3697 &sff8636_rev
, 1, 0, NULL
);
3700 /* Check revision compliance */
3701 if (sff8636_rev
> 0x02) {
3702 /* Module is SFF-8636 compliant */
3703 modinfo
->type
= ETH_MODULE_SFF_8636
;
3704 modinfo
->eeprom_len
= ICE_MODULE_QSFP_MAX_LEN
;
3706 modinfo
->type
= ETH_MODULE_SFF_8436
;
3707 modinfo
->eeprom_len
= ICE_MODULE_QSFP_MAX_LEN
;
3711 netdev_warn(netdev
, "SFF Module Type not recognized.\n");
3718 * ice_get_module_eeprom - fill buffer with SFF EEPROM contents
3719 * @netdev: network interface device structure
3720 * @ee: EEPROM dump request structure
3721 * @data: buffer to be filled with EEPROM contents
3724 ice_get_module_eeprom(struct net_device
*netdev
,
3725 struct ethtool_eeprom
*ee
, u8
*data
)
3727 struct ice_netdev_priv
*np
= netdev_priv(netdev
);
3728 u8 addr
= ICE_I2C_EEPROM_DEV_ADDR
;
3729 struct ice_vsi
*vsi
= np
->vsi
;
3730 struct ice_pf
*pf
= vsi
->back
;
3731 struct ice_hw
*hw
= &pf
->hw
;
3732 enum ice_status status
;
3733 bool is_sfp
= false;
3739 status
= ice_aq_sff_eeprom(hw
, 0, addr
, offset
, page
, 0,
3740 &value
, 1, 0, NULL
);
3744 if (!ee
|| !ee
->len
|| !data
)
3747 if (value
== ICE_MODULE_TYPE_SFP
)
3750 for (i
= 0; i
< ee
->len
; i
++) {
3751 offset
= i
+ ee
->offset
;
3753 /* Check if we need to access the other memory page */
3755 if (offset
>= ETH_MODULE_SFF_8079_LEN
) {
3756 offset
-= ETH_MODULE_SFF_8079_LEN
;
3757 addr
= ICE_I2C_EEPROM_DEV_ADDR2
;
3760 while (offset
>= ETH_MODULE_SFF_8436_LEN
) {
3761 /* Compute memory page number and offset. */
3762 offset
-= ETH_MODULE_SFF_8436_LEN
/ 2;
3767 status
= ice_aq_sff_eeprom(hw
, 0, addr
, offset
, page
, !is_sfp
,
3768 &value
, 1, 0, NULL
);
3776 static const struct ethtool_ops ice_ethtool_ops
= {
3777 .supported_coalesce_params
= ETHTOOL_COALESCE_USECS
|
3778 ETHTOOL_COALESCE_USE_ADAPTIVE
|
3779 ETHTOOL_COALESCE_RX_USECS_HIGH
,
3780 .get_link_ksettings
= ice_get_link_ksettings
,
3781 .set_link_ksettings
= ice_set_link_ksettings
,
3782 .get_drvinfo
= ice_get_drvinfo
,
3783 .get_regs_len
= ice_get_regs_len
,
3784 .get_regs
= ice_get_regs
,
3785 .get_msglevel
= ice_get_msglevel
,
3786 .set_msglevel
= ice_set_msglevel
,
3787 .self_test
= ice_self_test
,
3788 .get_link
= ethtool_op_get_link
,
3789 .get_eeprom_len
= ice_get_eeprom_len
,
3790 .get_eeprom
= ice_get_eeprom
,
3791 .get_coalesce
= ice_get_coalesce
,
3792 .set_coalesce
= ice_set_coalesce
,
3793 .get_strings
= ice_get_strings
,
3794 .set_phys_id
= ice_set_phys_id
,
3795 .get_ethtool_stats
= ice_get_ethtool_stats
,
3796 .get_priv_flags
= ice_get_priv_flags
,
3797 .set_priv_flags
= ice_set_priv_flags
,
3798 .get_sset_count
= ice_get_sset_count
,
3799 .get_rxnfc
= ice_get_rxnfc
,
3800 .set_rxnfc
= ice_set_rxnfc
,
3801 .get_ringparam
= ice_get_ringparam
,
3802 .set_ringparam
= ice_set_ringparam
,
3803 .nway_reset
= ice_nway_reset
,
3804 .get_pauseparam
= ice_get_pauseparam
,
3805 .set_pauseparam
= ice_set_pauseparam
,
3806 .get_rxfh_key_size
= ice_get_rxfh_key_size
,
3807 .get_rxfh_indir_size
= ice_get_rxfh_indir_size
,
3808 .get_rxfh
= ice_get_rxfh
,
3809 .set_rxfh
= ice_set_rxfh
,
3810 .get_channels
= ice_get_channels
,
3811 .set_channels
= ice_set_channels
,
3812 .get_ts_info
= ethtool_op_get_ts_info
,
3813 .get_per_queue_coalesce
= ice_get_per_q_coalesce
,
3814 .set_per_queue_coalesce
= ice_set_per_q_coalesce
,
3815 .get_fecparam
= ice_get_fecparam
,
3816 .set_fecparam
= ice_set_fecparam
,
3817 .get_module_info
= ice_get_module_info
,
3818 .get_module_eeprom
= ice_get_module_eeprom
,
3821 static const struct ethtool_ops ice_ethtool_safe_mode_ops
= {
3822 .get_link_ksettings
= ice_get_link_ksettings
,
3823 .set_link_ksettings
= ice_set_link_ksettings
,
3824 .get_drvinfo
= ice_get_drvinfo
,
3825 .get_regs_len
= ice_get_regs_len
,
3826 .get_regs
= ice_get_regs
,
3827 .get_msglevel
= ice_get_msglevel
,
3828 .set_msglevel
= ice_set_msglevel
,
3829 .get_link
= ethtool_op_get_link
,
3830 .get_eeprom_len
= ice_get_eeprom_len
,
3831 .get_eeprom
= ice_get_eeprom
,
3832 .get_strings
= ice_get_strings
,
3833 .get_ethtool_stats
= ice_get_ethtool_stats
,
3834 .get_sset_count
= ice_get_sset_count
,
3835 .get_ringparam
= ice_get_ringparam
,
3836 .set_ringparam
= ice_set_ringparam
,
3837 .nway_reset
= ice_nway_reset
,
3838 .get_channels
= ice_get_channels
,
3842 * ice_set_ethtool_safe_mode_ops - setup safe mode ethtool ops
3843 * @netdev: network interface device structure
3845 void ice_set_ethtool_safe_mode_ops(struct net_device
*netdev
)
3847 netdev
->ethtool_ops
= &ice_ethtool_safe_mode_ops
;
3851 * ice_set_ethtool_ops - setup netdev ethtool ops
3852 * @netdev: network interface device structure
3854 * setup netdev ethtool ops with ice specific ops
3856 void ice_set_ethtool_ops(struct net_device
*netdev
)
3858 netdev
->ethtool_ops
= &ice_ethtool_ops
;