From: Paolo Abeni <pabeni@redhat.com>
To: Daniel Zahka <daniel.zahka@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
Donald Hunter <donald.hunter@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Shuah Khan <shuah@kernel.org>, Boris Pismenny <borisp@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v2 3/5] psp: add stats from psp spec to driver facing api
Date: Tue, 28 Oct 2025 10:02:16 +0100 [thread overview]
Message-ID: <d4c31a2f-590a-4b83-b6b3-25f33a51193a@redhat.com> (raw)
In-Reply-To: <20251028000018.3869664-4-daniel.zahka@gmail.com>
On 10/28/25 1:00 AM, Daniel Zahka wrote:
> From: Jakub Kicinski <kuba@kernel.org>
>
> Provide a driver api for reporting device statistics required by the
> "Implementation Requirements" section of the PSP Architecture
> Specification. Use a warning to ensure drivers report stats required
> by the spec.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
> ---
> Documentation/netlink/specs/psp.yaml | 55 ++++++++++++++++++++++++++++
> include/net/psp/types.h | 26 +++++++++++++
> include/uapi/linux/psp.h | 8 ++++
> net/psp/psp_main.c | 3 +-
> net/psp/psp_nl.c | 22 ++++++++++-
> 5 files changed, 112 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/netlink/specs/psp.yaml b/Documentation/netlink/specs/psp.yaml
> index 914148221384..f3a57782d2cf 100644
> --- a/Documentation/netlink/specs/psp.yaml
> +++ b/Documentation/netlink/specs/psp.yaml
> @@ -98,6 +98,61 @@ attribute-sets:
> Number of times a socket's Rx got shut down due to using
> a key which went stale (fully rotated out).
> Kernel statistic.
> + -
> + name: rx-packets
> + type: uint
> + doc: |
> + Number of successfully processed and authenticated PSP packets.
> + Device statistic (from the PSP spec).
> + -
> + name: rx-bytes
> + type: uint
> + doc: |
> + Number of successfully authenticated PSP bytes received, counting from
> + the first byte after the IV through the last byte of payload.
> + The fixed initial portion of the PSP header (16 bytes)
> + and the PSP trailer/ICV (16 bytes) are not included in this count.
> + Device statistic (from the PSP spec).
> + -
> + name: rx-auth-fail
> + type: uint
> + doc: |
> + Number of received PSP packets with unsuccessful authentication.
> + Device statistic (from the PSP spec).
> + -
> + name: rx-error
> + type: uint
> + doc: |
> + Number of received PSP packets with length/framing errors.
> + Device statistic (from the PSP spec).
> + -
> + name: rx-bad
> + type: uint
> + doc: |
> + Number of received PSP packets with miscellaneous errors
> + (invalid master key indicated by SPI, unsupported version, etc.)
> + Device statistic (from the PSP spec).
> + -
> + name: tx-packets
> + type: uint
> + doc: |
> + Number of successfully processed PSP packets for transmission.
> + Device statistic (from the PSP spec).
> + -
> + name: tx-bytes
> + type: uint
> + doc: |
> + Number of successfully processed PSP bytes for transmit, counting from
> + the first byte after the IV through the last byte of payload.
> + The fixed initial portion of the PSP header (16 bytes)
> + and the PSP trailer/ICV (16 bytes) are not included in this count.
> + Device statistic (from the PSP spec).
> + -
> + name: tx-error
> + type: uint
> + doc: |
> + Number of PSP packets for transmission with errors.
> + Device statistic (from the PSP spec).
>
> operations:
> list:
> diff --git a/include/net/psp/types.h b/include/net/psp/types.h
> index 5b0ccaac3882..1aa3857a85c1 100644
> --- a/include/net/psp/types.h
> +++ b/include/net/psp/types.h
> @@ -150,6 +150,25 @@ struct psp_assoc {
> u8 drv_data[] __aligned(8);
> };
>
> +struct psp_dev_stats {
> + union {
> + struct {
> + u64 rx_packets;
> + u64 rx_bytes;
> + u64 rx_auth_fail;
> + u64 rx_error;
> + u64 rx_bad;
> + u64 tx_packets;
> + u64 tx_bytes;
> + u64 tx_error;
> + };
> + DECLARE_FLEX_ARRAY(u64, required);
> + };
> + char required_end[0];
This makes static checker unhappy:
/home/cocci/testing/include/net/psp/types.h:167:6-18: WARNING use
flexible-array member instead
(https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
I think/guess the warning could be avoided using something alike the
following (completely untested!!!):
struct psp_dev_stats {
struct_group(required,
union {
struct {
u64 rx_packets;
u64 rx_bytes;
u64 rx_auth_fail;
u64 rx_error;
u64 rx_bad;
u64 tx_packets;
u64 tx_bytes;
u64 tx_error;
};
DECLARE_FLEX_ARRAY(u64, required);
};
);
};
// ...
const unsigned int required_cnt = sizeof(stats.required) / sizeof(u64);
next prev parent reply other threads:[~2025-10-28 9:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 0:00 [PATCH net-next v2 0/5] psp: track stats from core and provide a driver stats api Daniel Zahka
2025-10-28 0:00 ` [PATCH net-next v2 1/5] psp: report basic stats from the core Daniel Zahka
2025-10-28 0:00 ` [PATCH net-next v2 2/5] selftests: drv-net: psp: add assertions on core-tracked psp dev stats Daniel Zahka
2025-10-28 0:00 ` [PATCH net-next v2 3/5] psp: add stats from psp spec to driver facing api Daniel Zahka
2025-10-28 9:02 ` Paolo Abeni [this message]
2025-10-28 17:30 ` Jakub Kicinski
2025-10-28 17:33 ` Jakub Kicinski
2025-10-28 0:00 ` [PATCH net-next v2 4/5] net/mlx5e: Add PSP stats support for Rx/Tx flows Daniel Zahka
2025-10-30 16:11 ` Cosmin Ratiu
2025-11-05 20:31 ` Daniel Zahka
2025-10-28 0:00 ` [PATCH net-next v2 5/5] netdevsim: implement psp device stats Daniel Zahka
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=d4c31a2f-590a-4b83-b6b3-25f33a51193a@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=borisp@nvidia.com \
--cc=daniel.zahka@gmail.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@nvidia.com \
--cc=shuah@kernel.org \
--cc=tariqt@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®