From: Simon Horman <simon.horman@corigine.com>
To: Stanislav Fomichev <sdf@google.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, martin.lau@linux.dev, song@kernel.org,
yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org,
haoluo@google.com, jolsa@kernel.org, kuba@kernel.org,
toke@kernel.org, willemb@google.com, dsahern@kernel.org,
magnus.karlsson@intel.com, bjorn@kernel.org,
maciej.fijalkowski@intel.com, hawk@kernel.org,
netdev@vger.kernel.org, xdp-hints@xdp-project.net
Subject: [xdp-hints] Re: [RFC net-next v4 2/8] xsk: add TX timestamp and TX checksum offload support
Date: Tue, 25 Jul 2023 21:28:34 +0200 [thread overview]
Message-ID: <ZMAiYibjYzVTBjEF@corigine.com> (raw)
In-Reply-To: <20230724235957.1953861-3-sdf@google.com>
On Mon, Jul 24, 2023 at 04:59:51PM -0700, Stanislav Fomichev wrote:
...
Hi Stan,
> diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h
> index bf71698a1e82..cf1e11c76339 100644
> --- a/include/uapi/linux/netdev.h
> +++ b/include/uapi/linux/netdev.h
> @@ -37,11 +37,26 @@ enum netdev_xdp_act {
> NETDEV_XDP_ACT_MASK = 127,
> };
>
> +/**
> + * enum netdev_xsk_flags
> + * @NETDEV_XSK_FLAGS_TX_TIMESTAMP: HW timestamping egress packets is supported
> + * by the driver.
> + * @NETDEV_XSK_FLAGS_TX_CHECKSUM: L3 checksum HW offload is supported by the
> + * driver.
> + */
> +enum netdev_xsk_flags {
> + NETDEV_XSK_FLAGS_TX_TIMESTAMP = 1,
> + NETDEV_XSK_FLAGS_TX_CHECKSUM = 2,
> +
I know that it isn't the practice in this file.
but adding the following makes kernel-doc happier
about NETDEV_XSK_FLAGS_MASK not being documented.
/* private: */
> + NETDEV_XSK_FLAGS_MASK = 3,
> +};
> +
> enum {
> NETDEV_A_DEV_IFINDEX = 1,
> NETDEV_A_DEV_PAD,
> NETDEV_A_DEV_XDP_FEATURES,
> NETDEV_A_DEV_XDP_ZC_MAX_SEGS,
> + NETDEV_A_DEV_XSK_FEATURES,
>
> __NETDEV_A_DEV_MAX,
> NETDEV_A_DEV_MAX = (__NETDEV_A_DEV_MAX - 1)
...
> diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
...
> @@ -626,6 +635,7 @@ static struct sk_buff *xsk_build_skb_zerocopy(struct xdp_sock *xs,
> static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
> struct xdp_desc *desc)
> {
> + struct xsk_tx_metadata *meta = NULL;
> struct net_device *dev = xs->dev;
> struct sk_buff *skb = xs->skb;
> int err;
> @@ -678,12 +688,40 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
>
> skb_add_rx_frag(skb, nr_frags, page, 0, len, 0);
> }
> +
> + if (desc->options & XDP_TX_METADATA) {
> + if (unlikely(xs->tx_metadata_len == 0)) {
> + err = -EINVAL;
> + goto free_err;
> + }
> +
> + meta = buffer - xs->tx_metadata_len;
> +
> + if (meta->flags & XDP_TX_METADATA_CHECKSUM) {
> + if (unlikely(meta->csum_start + meta->csum_offset +
> + sizeof(__sum16) > len)) {
> + err = -EINVAL;
> + goto free_err;
> + }
> +
> + skb->csum_start = hr + meta->csum_start;
hr seems to only be set - by earlier, existing code in this function -
if skb is NULL. Is it always safe to use it here?
Smatch flags hr as being potentially used uninitialised,
the above is my understanding of why it thinks that is so.
> + skb->csum_offset = meta->csum_offset;
> + skb->ip_summed = CHECKSUM_PARTIAL;
> +
> + if (unlikely(meta->flags & XDP_TX_METADATA_CHECKSUM_SW)) {
> + err = skb_checksum_help(skb);
> + if (err)
> + goto free_err;
> + }
> + }
> + }
> }
>
> skb->dev = dev;
> skb->priority = xs->sk.sk_priority;
> skb->mark = xs->sk.sk_mark;
> skb->destructor = xsk_destruct_skb;
> + skb_shinfo(skb)->xsk_meta = meta;
> xsk_set_destructor_arg(skb);
>
> return skb;
...
next prev parent reply other threads:[~2023-07-25 19:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 23:59 [xdp-hints] [RFC net-next v4 0/8] xsk: TX metadata Stanislav Fomichev
2023-07-24 23:59 ` [xdp-hints] [RFC net-next v4 1/8] xsk: Support XDP_TX_METADATA_LEN Stanislav Fomichev
2023-07-24 23:59 ` [xdp-hints] [RFC net-next v4 2/8] xsk: add TX timestamp and TX checksum offload support Stanislav Fomichev
2023-07-25 19:28 ` Simon Horman [this message]
2023-07-25 20:30 ` [xdp-hints] " Stanislav Fomichev
2023-07-25 21:28 ` Jakub Kicinski
2023-07-25 22:40 ` Stanislav Fomichev
2023-07-26 7:47 ` Simon Horman
2023-07-25 20:54 ` Willem de Bruijn
2023-07-25 22:39 ` Stanislav Fomichev
2023-07-25 23:10 ` Willem de Bruijn
2023-07-25 23:48 ` Stanislav Fomichev
2023-07-27 14:11 ` Jesper Dangaard Brouer
2023-07-27 16:37 ` Stanislav Fomichev
2023-07-25 20:58 ` Willem de Bruijn
2023-07-28 11:56 ` Jesper Dangaard Brouer
2023-07-28 13:19 ` Willem de Bruijn
2023-07-26 19:25 ` Jesper Dangaard Brouer
2023-07-26 21:25 ` Stanislav Fomichev
2023-07-27 13:50 ` Jesper Dangaard Brouer
2023-07-27 16:34 ` Stanislav Fomichev
2023-07-24 23:59 ` [xdp-hints] [RFC net-next v4 3/8] net/mlx5e: Implement AF_XDP TX timestamp and checksum offload Stanislav Fomichev
2023-07-24 23:59 ` [xdp-hints] [RFC net-next v4 4/8] tools: ynl: update netdev sample to dump xsk-features Stanislav Fomichev
2023-07-24 23:59 ` [xdp-hints] [RFC net-next v4 5/8] selftests/xsk: Support XDP_TX_METADATA_LEN Stanislav Fomichev
2023-07-24 23:59 ` [xdp-hints] [RFC net-next v4 6/8] selftests/bpf: Add csum helpers Stanislav Fomichev
2023-07-24 23:59 ` [xdp-hints] [RFC net-next v4 7/8] selftests/bpf: Add TX side to xdp_metadata Stanislav Fomichev
2023-07-24 23:59 ` [xdp-hints] [RFC net-next v4 8/8] selftests/bpf: Add TX side to xdp_hw_metadata Stanislav Fomichev
2023-07-25 20:59 ` [xdp-hints] " Willem de Bruijn
2023-07-25 22:36 ` Stanislav Fomichev
2023-07-25 22:55 ` Willem de Bruijn
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
List information: https://lists.xdp-project.net/postorius/lists/xdp-hints.xdp-project.net/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZMAiYibjYzVTBjEF@corigine.com \
--to=simon.horman@corigine.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dsahern@kernel.org \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=toke@kernel.org \
--cc=willemb@google.com \
--cc=xdp-hints@xdp-project.net \
--cc=yhs@fb.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