From: Dimitri Daskalakis <dimitri.daskalakis1@gmail.com>
To: Fan Gong <gongfan1@huawei.com>, Wu Di <wudi234@huawei.com>,
Teng Peisen <tengpeisen@huawei.com>,
netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Mohsin Bashir <mohsin.bashr@gmail.com>,
Harshitha Ramamurthy <hramamurthy@google.com>,
Larysa Zaremba <larysa.zaremba@intel.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
Zhou Shuai <zhoushuai28@huawei.com>, Wu Like <wulike1@huawei.com>
Subject: Re: [PATCH net-next v16 1/2] hinic3: Add ethtool statistic ops part1
Date: Fri, 16 Oct 2026 16:52:50 -0700 [thread overview]
Message-ID: <a0eb0511-fe0f-419c-adec-159dc16913ae@gmail.com> (raw)
In-Reply-To: <3cda990995ccb002019f147b7a0c004c542229aa.1792149958.git.gongfan1@huawei.com>
On 10/16/26 4:13 AM, Fan Gong wrote:
> This commit adds per-queue TX/RX software counters and firmware-backed
> vport and physical port statistics to the hinic3 driver. It implements
> the .get_strings, .get_sset_count and .get_ethtool_stats callbacks so
> these can be read with ethtool -S, and adds packet/byte accounting to
> the RX and TX hot paths.
>
> Co-developed-by: Wu Di <wudi234@huawei.com>
> Signed-off-by: Wu Di <wudi234@huawei.com>
> Co-developed-by: Teng Peisen <tengpeisen@huawei.com>
> Signed-off-by: Teng Peisen <tengpeisen@huawei.com>
> Signed-off-by: Fan Gong <gongfan1@huawei.com>
> ---
> .../ethernet/huawei/hinic3/hinic3_ethtool.c | 294 ++++++++++++++++++
> .../ethernet/huawei/hinic3/hinic3_hw_intf.h | 11 +
> .../huawei/hinic3/hinic3_mgmt_interface.h | 37 +++
> .../ethernet/huawei/hinic3/hinic3_nic_cfg.c | 64 ++++
> .../ethernet/huawei/hinic3/hinic3_nic_cfg.h | 108 +++++++
> .../net/ethernet/huawei/hinic3/hinic3_rx.c | 64 +++-
> .../net/ethernet/huawei/hinic3/hinic3_rx.h | 8 +-
> .../net/ethernet/huawei/hinic3/hinic3_tx.c | 70 ++++-
> .../net/ethernet/huawei/hinic3/hinic3_tx.h | 5 +-
> 9 files changed, 649 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c b/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c
> index 90fc16288de9..bb6094d61196 100644
> --- a/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c
> +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c
> @@ -13,8 +13,11 @@
[...]
> +static u16 hinic3_get_hw_stats_strings(struct hinic3_nic_dev *nic_dev, char *p)
> +{
> + u16 i, cnt = 0;
> +
> + for (i = 0; i < ARRAY_SIZE(hinic3_function_stats); i++) {
> + memcpy(p, hinic3_function_stats[i].name, ETH_GSTRING_LEN);
> + p += ETH_GSTRING_LEN;
> + cnt++;
> + }
Do you need to manually add/track the offset? Couldn't you let
ethtool_puts()/ethtool_sprintf() do the hard work?
> +
> + if (!HINIC3_IS_VF(nic_dev->hwdev)) {
> + for (i = 0; i < ARRAY_SIZE(hinic3_port_stats); i++) {
> + memcpy(p, hinic3_port_stats[i].name, ETH_GSTRING_LEN);
> + p += ETH_GSTRING_LEN;
> + cnt++;
> + }
> + }
> +
> + return cnt;
> +}
> +
> +static void hinic3_get_qp_stats_strings(struct hinic3_nic_dev *nic_dev, char *p)
> +{
> + u8 *data = p;
> + u16 i, j;
> +
> + for (i = 0; i < nic_dev->q_params.num_qps; i++) {
> + for (j = 0; j < ARRAY_SIZE(hinic3_tx_queue_stats); j++)
> + ethtool_sprintf(&data,
> + hinic3_tx_queue_stats[j].name, i);
> + }
> +
> + for (i = 0; i < nic_dev->q_params.num_qps; i++) {
> + for (j = 0; j < ARRAY_SIZE(hinic3_rx_queue_stats); j++)
> + ethtool_sprintf(&data,
> + hinic3_rx_queue_stats[j].name, i);
> + }
> +}
> +
> +static void hinic3_get_strings(struct net_device *netdev,
> + u32 stringset, u8 *data)
> +{
> + struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
> + char *p = (char *)data;
What's the purpose of casting here and throughout the patch?
> + u16 offset;
> +
> + switch (stringset) {
> + case ETH_SS_STATS:
> + offset = hinic3_get_hw_stats_strings(nic_dev, p);
> + hinic3_get_qp_stats_strings(nic_dev,
> + p + offset * ETH_GSTRING_LEN);
> +
> + break;
[...]
next prev parent reply other threads:[~2026-10-16 23:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 11:13 [PATCH net-next v16 0/2] net: hinic3: Support ethtool ops Fan Gong
2026-10-16 11:13 ` [PATCH net-next v16 1/2] hinic3: Add ethtool statistic ops part1 Fan Gong
2026-10-16 23:52 ` Dimitri Daskalakis [this message]
2026-10-16 11:13 ` [PATCH net-next v16 2/2] hinic3: Add ethtool statistic ops part2 Fan Gong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a0eb0511-fe0f-419c-adec-159dc16913ae@gmail.com \
--to=dimitri.daskalakis1@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gongfan1@huawei.com \
--cc=horms@kernel.org \
--cc=hramamurthy@google.com \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.org \
--cc=larysa.zaremba@intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=mohsin.bashr@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tengpeisen@huawei.com \
--cc=vadim.fedorenko@linux.dev \
--cc=wudi234@huawei.com \
--cc=wulike1@huawei.com \
--cc=zhoushuai28@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.