From: Nicolai Buchwitz <nb@tipi-net.de>
To: Subbaraya Sundeep <sbhatta@marvell.com>
Cc: "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>,
"Doug Berger" <opendmb@gmail.com>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Broadcom internal kernel review list"
<bcm-kernel-feedback-list@broadcom.com>,
"Vikas Gupta" <vikas.gupta@broadcom.com>,
"Bhargava Marreddy" <bhargava.marreddy@broadcom.com>,
"Rajashekar Hudumula" <rajashekar.hudumula@broadcom.com>,
"Eric Biggers" <ebiggers@kernel.org>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Markus Blöchl" <mbloch@rooftopnetworks.de>,
"Arnd Bergmann" <arnd@arndb.de>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 4/6] net: bcmgenet: add XDP_TX support
Date: Fri, 13 Mar 2026 13:45:33 +0100 [thread overview]
Message-ID: <5cb0916bdb19ea33e11ea93f7174fd76@tipi-net.de> (raw)
In-Reply-To: <20260313113737.GA209052@kernel-ep2>
On 13.3.2026 12:37, Subbaraya Sundeep wrote:
> Hi,
Hi Sundeep
>
> On 2026-03-13 at 14:50:59, Nicolai Buchwitz (nb@tipi-net.de) wrote:
>> Implement XDP_TX by submitting XDP frames through the default TX ring
>> (DESC_INDEX). The frame is DMA-mapped and placed into a single TX
>> descriptor with SOP|EOP|APPEND_CRC flags.
>>
>> The xdp_frame pointer is stored in the TX control block so that
>> bcmgenet_free_tx_cb() can call xdp_return_frame() on TX completion,
>> returning the page to the originating page_pool.
>>
>> The page_pool DMA direction is changed from DMA_FROM_DEVICE to
>> DMA_BIDIRECTIONAL to support the TX DMA mapping of received pages.
>>
>> Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
>> ---
>> .../net/ethernet/broadcom/genet/bcmgenet.c | 73
>> ++++++++++++++++++-
>> .../net/ethernet/broadcom/genet/bcmgenet.h | 1 +
>> 2 files changed, 71 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
>> b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
>> index d43729fc2b1b..373ba5878ca1 100644
>> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
>> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
>> @@ -1893,6 +1893,12 @@ static struct sk_buff
>> *bcmgenet_free_tx_cb(struct device *dev,
>> if (cb == GENET_CB(skb)->last_cb)
>> return skb;
>>
>> + } else if (cb->xdpf) {
>> + dma_unmap_single(dev, dma_unmap_addr(cb, dma_addr),
>> + dma_unmap_len(cb, dma_len), DMA_TO_DEVICE);
>> + dma_unmap_addr_set(cb, dma_addr, 0);
>> + xdp_return_frame(cb->xdpf);
>> + cb->xdpf = NULL;
>> } else if (dma_unmap_addr(cb, dma_addr)) {
>> dma_unmap_page(dev,
>> dma_unmap_addr(cb, dma_addr),
>> @@ -2299,10 +2305,62 @@ static struct sk_buff
>> *bcmgenet_xdp_build_skb(struct bcmgenet_rx_ring *ring,
>> return skb;
>> }
>>
>> +static bool bcmgenet_xdp_xmit_frame(struct bcmgenet_priv *priv,
>> + struct xdp_frame *xdpf)
>> +{
>> + struct bcmgenet_tx_ring *ring = &priv->tx_rings[DESC_INDEX];
>> + struct device *kdev = &priv->pdev->dev;
>> + struct enet_cb *tx_cb_ptr;
>> + dma_addr_t mapping;
>> + u32 len_stat;
>> +
>> + spin_lock(&ring->lock);
>> +
>> + if (ring->free_bds < 1) {
>> + spin_unlock(&ring->lock);
>> + return false;
>> + }
>> +
>> + tx_cb_ptr = bcmgenet_get_txcb(priv, ring);
>> +
>> + mapping = dma_map_single(kdev, xdpf->data, xdpf->len,
>> DMA_TO_DEVICE);
>
> AFAIU you are transmitting the frame received on a RQ which is from the
> page pool
> and already dma mapped. Do you have to do dma_map again?
>
> Thanks,
> Sundeep
>
You're right. Since the page_pool is configured with DMA_BIDIRECTIONAL,
the pages are already mapped and we can reuse the existing mapping for
XDP_TX frames. The initial implementation took the simple route of
mapping everything uniformly, but that's unnecessary overhead for the
local XDP_TX case.
In v2 I'll add a bool dma_map parameter to bcmgenet_xdp_xmit_frame()
(following the mvneta/stmmac pattern): XDP_TX will reuse the page_pool
mapping via page_pool_get_dma_addr() + dma_sync_single_for_device(),
while ndo_xdp_xmit will keep dma_map_single() for foreign frames. The
cleanup path will be split accordingly.
Regards
Nicolai
>> [...]
next prev parent reply other threads:[~2026-03-13 12:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 9:20 [PATCH net-next 0/6] net: bcmgenet: add XDP support Nicolai Buchwitz
2026-03-13 9:20 ` [PATCH net-next 1/6] net: bcmgenet: convert RX path to page_pool Nicolai Buchwitz
2026-03-13 9:20 ` [PATCH net-next 2/6] net: bcmgenet: register xdp_rxq_info for each RX ring Nicolai Buchwitz
2026-03-13 9:20 ` [PATCH net-next 3/6] net: bcmgenet: add basic XDP support (PASS/DROP) Nicolai Buchwitz
2026-03-13 22:48 ` Florian Fainelli
2026-03-14 19:48 ` Nicolai Buchwitz
2026-03-13 9:20 ` [PATCH net-next 4/6] net: bcmgenet: add XDP_TX support Nicolai Buchwitz
2026-03-13 11:37 ` Subbaraya Sundeep
2026-03-13 12:45 ` Nicolai Buchwitz [this message]
2026-03-13 9:21 ` [PATCH net-next 5/6] net: bcmgenet: add XDP_REDIRECT and ndo_xdp_xmit support Nicolai Buchwitz
2026-03-13 9:21 ` [PATCH net-next 6/6] net: bcmgenet: add XDP statistics counters Nicolai Buchwitz
2026-03-13 23:01 ` [PATCH net-next 0/6] net: bcmgenet: add XDP support Florian Fainelli
2026-03-14 0:13 ` Florian Fainelli
2026-03-14 19:51 ` Nicolai Buchwitz
2026-03-14 15:52 ` Jakub Kicinski
2026-03-14 19:52 ` Nicolai Buchwitz
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=5cb0916bdb19ea33e11ea93f7174fd76@tipi-net.de \
--to=nb@tipi-net.de \
--cc=andrew+netdev@lunn.ch \
--cc=arnd@arndb.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhargava.marreddy@broadcom.com \
--cc=davem@davemloft.net \
--cc=ebiggers@kernel.org \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbloch@rooftopnetworks.de \
--cc=netdev@vger.kernel.org \
--cc=opendmb@gmail.com \
--cc=pabeni@redhat.com \
--cc=rajashekar.hudumula@broadcom.com \
--cc=sbhatta@marvell.com \
--cc=vikas.gupta@broadcom.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