Re: [PATCH net-next v01 11/15] hinic3: Add ethtool statistic ops

From: Ioana Ciornei

Date: Tue Feb 24 2026 - 09:39:40 EST


On Tue, Feb 24, 2026 at 09:15:48PM +0800, Fan Gong wrote:
> Co-developed-by: Zhu Yikai <zhuyikai1@xxxxxxxxxxxxxx>
> Signed-off-by: Zhu Yikai <zhuyikai1@xxxxxxxxxxxxxx>
> Signed-off-by: Fan Gong <gongfan1@xxxxxxxxxx>
> ---
> .../ethernet/huawei/hinic3/hinic3_ethtool.c | 414 ++++++++++++++++++
> .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 13 +-
> .../huawei/hinic3/hinic3_mgmt_interface.h | 37 ++
> .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 64 +++
> .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 109 +++++
> .../ethernet/huawei/hinic3/hinic3_nic_dev.h | 15 +
> .../net/ethernet/huawei/hinic3/hinic3_rx.c | 58 ++-
> .../net/ethernet/huawei/hinic3/hinic3_rx.h | 14 +
> .../net/ethernet/huawei/hinic3/hinic3_tx.c | 72 ++-
> .../net/ethernet/huawei/hinic3/hinic3_tx.h | 2 +
> 10 files changed, 789 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c b/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c
> index d155d8c533c7..ea0b2df73e9f 100644
> --- a/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c
> +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c

(...)

> +
> +static struct hinic3_stats hinic3_port_stats[] = {
> + HINIC3_PORT_STAT(mac_tx_fragment_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_undersize_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_undermin_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_64_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_65_127_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_128_255_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_256_511_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_512_1023_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_1024_1518_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_1519_2047_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_2048_4095_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_4096_8191_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_8192_9216_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_9217_12287_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_12288_16383_oct_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_1519_max_bad_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_1519_max_good_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_oversize_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_jabber_pkt_num),

These look like rmon statistics that should be exported through the
ethtool .get_rmon_stats() callback.

> + HINIC3_PORT_STAT(mac_tx_bad_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_bad_oct_num),
> + HINIC3_PORT_STAT(mac_tx_good_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_good_oct_num),
> + HINIC3_PORT_STAT(mac_tx_total_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_total_oct_num),
> + HINIC3_PORT_STAT(mac_tx_uni_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_multi_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_broad_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_pause_num),
> + HINIC3_PORT_STAT(mac_tx_pfc_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_pfc_pri0_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_pfc_pri1_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_pfc_pri2_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_pfc_pri3_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_pfc_pri4_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_pfc_pri5_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_pfc_pri6_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_pfc_pri7_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_control_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_err_all_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_from_app_good_pkt_num),
> + HINIC3_PORT_STAT(mac_tx_from_app_bad_pkt_num),

Please have a look also at the following ethtool callbacks and see if
you can export any other counters through the standardized method.

* @get_pause_stats: Report pause frame statistics. Drivers must not zero
* statistics which they don't report. The stats structure is initialized
* to ETHTOOL_STAT_NOT_SET indicating driver does not report statistics.
* @get_eth_phy_stats: Query some of the IEEE 802.3 PHY statistics.
* @get_eth_mac_stats: Query some of the IEEE 802.3 MAC statistics.
* @get_eth_ctrl_stats: Query some of the IEEE 802.3 MAC Ctrl statistics.

Ioana