From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Cc: <intel-wired-lan@lists.osuosl.org>,
Michal Kubiak <michal.kubiak@intel.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
"Przemek Kitszel" <przemyslaw.kitszel@intel.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Alexei Starovoitov" <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Simon Horman <horms@kernel.org>, <bpf@vger.kernel.org>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH iwl-next 03/16] libeth: xdp: add XDP_TX buffers sending
Date: Tue, 13 May 2025 16:58:46 +0200 [thread overview]
Message-ID: <25e39e3f-7a3d-4902-b000-0d7f969089c5@intel.com> (raw)
In-Reply-To: <aAozJ5Twq7GidhHr@boxer>
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Date: Thu, 24 Apr 2025 14:48:39 +0200
> On Tue, Apr 15, 2025 at 07:28:12PM +0200, Alexander Lobakin wrote:
>> Start adding XDP-specific code to libeth, namely handling XDP_TX buffers
>> (only sending).
[...]
>> +static __always_inline u32
>> +libeth_xdp_tx_xmit_bulk(const struct libeth_xdp_tx_frame *bulk, void *xdpsq,
>> + u32 n, bool unroll, u64 priv,
>> + u32 (*prep)(void *xdpsq, struct libeth_xdpsq *sq),
>> + struct libeth_xdp_tx_desc
>> + (*fill)(struct libeth_xdp_tx_frame frm, u32 i,
>> + const struct libeth_xdpsq *sq, u64 priv),
>> + void (*xmit)(struct libeth_xdp_tx_desc desc, u32 i,
>> + const struct libeth_xdpsq *sq, u64 priv))
>> +{
>> + u32 this, batched, off = 0;
>> + struct libeth_xdpsq sq;
>> + u32 ntu, i = 0;
>> +
>> + n = min(n, prep(xdpsq, &sq));
>> + if (unlikely(!n))
>> + return 0;
>> +
>> + ntu = *sq.ntu;
>> +
>> + this = sq.count - ntu;
>
> maybe something more self-descriptive than 'this'? :)
> this is available space in sq, right?
'this' means "this batch", IOW what we'll send for sure this iteration.
>
>> + if (likely(this > n))
>> + this = n;
>> +
>> +again:
>> + if (!unroll)
>
> who takes this decision? a caller or is this dependent on some constraints
> of underlying system? when would you like to not unroll?
XDP_TX, ndo_xdp_xmit, XSk XDP_TX wrappers pass `false` here, only XSk
xmit passes `true`. In cases other than XSk xmit, I had no positive
impact, while the object code bloat was huge -- XSk xmit doesn't fill
&libeth_sqe, only a Tx descriptor, while all the rest do.
>
>> + goto linear;
>> +
>> + batched = ALIGN_DOWN(this, LIBETH_XDP_TX_BATCH);
>> +
>> + for ( ; i < off + batched; i += LIBETH_XDP_TX_BATCH) {
>> + u32 base = ntu + i - off;
>> +
>> + unrolled_count(LIBETH_XDP_TX_BATCH)
>> + for (u32 j = 0; j < LIBETH_XDP_TX_BATCH; j++)
>> + xmit(fill(bulk[i + j], base + j, &sq, priv),
>> + base + j, &sq, priv);
>> + }
>> +
>> + if (batched < this) {
>> +linear:
>> + for ( ; i < off + this; i++)
>> + xmit(fill(bulk[i], ntu + i - off, &sq, priv),
>> + ntu + i - off, &sq, priv);
>> + }
>> +
>> + ntu += this;
>> + if (likely(ntu < sq.count))
>> + goto out;
>> +
>> + ntu = 0;
>> +
>> + if (i < n) {
>> + this = n - i;
>> + off = i;
>> +
>> + goto again;
>> + }
>> +
>> +out:
>> + *sq.ntu = ntu;
>> + *sq.pending += n;
>> + if (sq.xdp_tx)
>> + *sq.xdp_tx += n;
>> +
>> + return n;
>> +}
[...]
>> +/**
>> + * __libeth_xdp_tx_flush_bulk - internal helper to flush one XDP Tx bulk
>> + * @bq: bulk to flush
>> + * @flags: XDP TX flags
>> + * @prep: driver-specific callback to prepare the queue for sending
>> + * @fill: libeth_xdp callback to fill &libeth_sqe and &libeth_xdp_tx_desc
>
> Could you explain why this has to be implemented as a callback? for now
> this might just be directly called within libeth_xdp_tx_xmit_bulk() ?
>
> What I currently understand is this is not something that driver would
> provide. If its libeth internal routine then call this directly and
> simplify the code.
XSk XDP_TX passes a different callback here :> Anyway, all callbacks
within libeth_xdp get inlined or (sometimes) converted to direct calls,
no indirections.
>
> Besides, thanks a lot for this series and split up! I think we're on a
> good path.
Thanks,
Olek
next prev parent reply other threads:[~2025-05-13 14:59 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 17:28 [PATCH iwl-next 00/16] libeth: add libeth_xdp helper lib Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 01/16] libeth: convert to netmem Alexander Lobakin
2025-04-16 6:54 ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-04-17 12:26 ` Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 02/16] libeth: support native XDP and register memory model Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 03/16] libeth: xdp: add XDP_TX buffers sending Alexander Lobakin
2025-04-24 12:48 ` Maciej Fijalkowski
2025-05-13 14:58 ` Alexander Lobakin [this message]
2025-04-15 17:28 ` [PATCH iwl-next 04/16] libeth: xdp: add .ndo_xdp_xmit() helpers Alexander Lobakin
2025-04-24 13:06 ` Maciej Fijalkowski
2025-04-15 17:28 ` [PATCH iwl-next 05/16] libeth: xdp: add XDPSQE completion helpers Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 06/16] libeth: xdp: add XDPSQ locking helpers Alexander Lobakin
2025-04-24 15:27 ` Maciej Fijalkowski
2025-04-15 17:28 ` [PATCH iwl-next 07/16] libeth: xdp: add XDPSQ cleanup timers Alexander Lobakin
2025-04-24 15:33 ` Maciej Fijalkowski
2025-04-15 17:28 ` [PATCH iwl-next 08/16] libeth: xdp: add helpers for preparing/processing &libeth_xdp_buff Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 09/16] libeth: xdp: add XDP prog run and verdict result handling Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 10/16] libeth: xdp: add templates for building driver-side callbacks Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 11/16] libeth: xdp: add RSS hash hint and XDP features setup helpers Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 12/16] libeth: xsk: add XSk XDP_TX sending helpers Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 13/16] libeth: xsk: add XSk xmit functions Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 14/16] libeth: xsk: add XSk Rx processing support Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 15/16] libeth: xsk: add XSkFQ refill and XSk wakeup helpers Alexander Lobakin
2025-04-15 17:28 ` [PATCH iwl-next 16/16] libeth: xdp, xsk: access adjacent u32s as u64 where applicable Alexander Lobakin
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=25e39e3f-7a3d-4902-b000-0d7f969089c5@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=michal.kubiak@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.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®