From: Jakub Kicinski <kuba@kernel.org>
To: Vadim Fedorenko <vadfed@meta.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Michael Chan <michael.chan@broadcom.com>,
Pavan Chebbi <pavan.chebbi@broadcom.com>,
Tariq Toukan <tariqt@nvidia.com>, Gal Pressman <gal@nvidia.com>,
<intel-wired-lan@lists.osuosl.org>,
Donald Hunter <donald.hunter@gmail.com>,
Carolina Jubran <cjubran@nvidia.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
<netdev@vger.kernel.org>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>
Subject: Re: [RFC PATCH v4] ethtool: add FEC bins histogramm report
Date: Fri, 8 Aug 2025 13:15:22 -0700 [thread overview]
Message-ID: <20250808131522.0dc26de4@kernel.org> (raw)
In-Reply-To: <20250807155924.2272507-1-vadfed@meta.com>
On Thu, 7 Aug 2025 08:59:24 -0700 Vadim Fedorenko wrote:
> + /* add FEC bins information */
> + len += (nla_total_size(0) + /* _A_FEC_HIST */
> + nla_total_size(4) + /* _A_FEC_HIST_BIN_LOW */
> + nla_total_size(4) + /* _A_FEC_HIST_BIN_HI */
> + /* _A_FEC_HIST_BIN_VAL + per-lane values */
> + nla_total_size_64bit(sizeof(u64) *
> + (1 + ETHTOOL_MAX_LANES))) *
That's the calculation for basic stats because they are reported as a
raw array. Each nla_put() should correspond to a nla_total_size().
This patch nla_put()s things individually.
> + ETHTOOL_FEC_HIST_MAX;
> + }
>
> return len;
> }
>
> +static int fec_put_hist(struct sk_buff *skb, const struct ethtool_fec_hist *hist)
> +{
> + const struct ethtool_fec_hist_range *ranges = hist->ranges;
> + const struct ethtool_fec_hist_value *values = hist->values;
> + struct nlattr *nest;
> + int i, j;
> +
> + if (!ranges)
> + return 0;
> +
> + for (i = 0; i < ETHTOOL_FEC_HIST_MAX; i++) {
> + if (i && !ranges[i].low && !ranges[i].high)
> + break;
> +
> + if (WARN_ON_ONCE(values[i].bin_value == ETHTOOL_STAT_NOT_SET))
> + break;
> +
> + nest = nla_nest_start(skb, ETHTOOL_A_FEC_STAT_HIST);
> + if (!nest)
> + return -EMSGSIZE;
> +
> + if (nla_put_u32(skb, ETHTOOL_A_FEC_HIST_BIN_LOW,
> + ranges[i].low) ||
> + nla_put_u32(skb, ETHTOOL_A_FEC_HIST_BIN_HIGH,
> + ranges[i].high) ||
> + nla_put_uint(skb, ETHTOOL_A_FEC_HIST_BIN_VAL,
> + values[i].bin_value))
> + goto err_cancel_hist;
> + for (j = 0; j < ETHTOOL_MAX_LANES; j++) {
> + if (values[i].bin_value_per_lane[j] == ETHTOOL_STAT_NOT_SET)
> + break;
> + nla_put_uint(skb, ETHTOOL_A_FEC_HIST_BIN_VAL_PER_LANE,
> + values[i].bin_value_per_lane[j]);
TBH I'm a bit unsure if this is really worth breaking out into
individual nla_puts(). We generally recommend that, but here it's
an array of simple ints.. maybe we're better of with a binary / C
array of u64. Like the existing FEC stats but without also folding
the total value into index 0.
next prev parent reply other threads:[~2025-08-08 20:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-07 15:59 [RFC PATCH v4] ethtool: add FEC bins histogramm report Vadim Fedorenko
2025-08-08 20:15 ` Jakub Kicinski [this message]
2025-08-10 10:52 ` Vadim Fedorenko
2025-08-11 15:41 ` Jakub Kicinski
2025-08-11 16:08 ` Vadim Fedorenko
2025-08-11 16:21 ` Jakub Kicinski
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=20250808131522.0dc26de4@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=cjubran@nvidia.com \
--cc=donald.hunter@gmail.com \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=tariqt@nvidia.com \
--cc=vadfed@meta.com \
--cc=vadim.fedorenko@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).