From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: "Marek Behún" <kabel@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [PATCH net-next 3/5] net: mvneta: use buf->type to determine whether to dma-unmap
Date: Wed, 10 May 2023 11:15:53 +0100 [thread overview]
Message-ID: <E1pwgrR-001XDy-8S@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <ZFtuhJOC03qpASt2@shell.armlinux.org.uk>
Now that we use a different buffer type for TSO headers, we can use
buf->type to determine whether the original buffer was DMA-mapped or
not. The rules are:
MVNETA_TYPE_XDP_TX - from a DMA pool, no unmap is required
MVNETA_TYPE_XDP_NDO - dma_map_single()'d
MVNETA_TYPE_SKB - normal skbuff, dma_map_single()'d
MVNETA_TYPE_TSO - from the TSO buffer area
This means we only need to call dma_unmap_single() on the XDP_NDO and
SKB types of buffer, and we no longer need the private IS_TSO_HEADER()
which relies on the TSO region being contiguously allocated.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/ethernet/marvell/mvneta.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index c05649f33d18..c23d75af65ee 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -364,10 +364,6 @@
MVNETA_SKB_HEADROOM))
#define MVNETA_MAX_RX_BUF_SIZE (PAGE_SIZE - MVNETA_SKB_PAD)
-#define IS_TSO_HEADER(txq, addr) \
- ((addr >= txq->tso_hdrs_phys) && \
- (addr < txq->tso_hdrs_phys + txq->size * TSO_HEADER_SIZE))
-
#define MVNETA_RX_GET_BM_POOL_ID(rxd) \
(((rxd)->status & MVNETA_RXD_BM_POOL_MASK) >> MVNETA_RXD_BM_POOL_SHIFT)
@@ -1879,8 +1875,8 @@ static void mvneta_txq_bufs_free(struct mvneta_port *pp,
mvneta_txq_inc_get(txq);
- if (!IS_TSO_HEADER(txq, tx_desc->buf_phys_addr) &&
- buf->type != MVNETA_TYPE_XDP_TX)
+ if (buf->type == MVNETA_TYPE_XDP_NDO ||
+ buf->type == MVNETA_TYPE_SKB)
dma_unmap_single(pp->dev->dev.parent,
tx_desc->buf_phys_addr,
tx_desc->data_size, DMA_TO_DEVICE);
@@ -2728,8 +2724,9 @@ static void mvneta_release_descs(struct mvneta_port *pp,
for (i = num; i >= 0; i--) {
struct mvneta_tx_desc *tx_desc = txq->descs + desc_idx;
+ struct mvneta_tx_buf *buf = &txq->buf[desc_idx];
- if (!IS_TSO_HEADER(txq, tx_desc->buf_phys_addr))
+ if (buf->type == MVNETA_TYPE_SKB)
dma_unmap_single(pp->dev->dev.parent,
tx_desc->buf_phys_addr,
tx_desc->data_size,
--
2.30.2
next prev parent reply other threads:[~2023-05-10 10:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 10:14 [PATCH net-next 0/6] net: mvneta: reduce size of TSO header allocation Russell King (Oracle)
2023-05-10 10:15 ` [PATCH net-next 1/5] net: mvneta: fix transmit path dma-unmapping on error Russell King (Oracle)
2023-05-10 11:33 ` Eric Dumazet
2023-05-10 10:15 ` [PATCH net-next 2/5] net: mvneta: mark mapped and tso buffers separately Russell King (Oracle)
2023-05-10 11:34 ` Eric Dumazet
2023-05-10 10:15 ` Russell King (Oracle) [this message]
2023-05-10 11:34 ` [PATCH net-next 3/5] net: mvneta: use buf->type to determine whether to dma-unmap Eric Dumazet
2023-05-10 10:15 ` [PATCH net-next 4/5] net: mvneta: move tso_build_hdr() into mvneta_tso_put_hdr() Russell King (Oracle)
2023-05-10 11:34 ` Eric Dumazet
2023-05-10 10:16 ` [PATCH net-next 5/5] net: mvneta: allocate TSO header DMA memory in chunks Russell King (Oracle)
2023-05-10 11:38 ` Eric Dumazet
2023-05-10 11:48 ` Russell King (Oracle)
2023-05-10 12:00 ` Thomas Petazzoni
2023-05-10 10:36 ` [PATCH net-next 0/6] net: mvneta: reduce size of TSO header allocation Russell King (Oracle)
2023-05-11 11:10 ` patchwork-bot+netdevbpf
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=E1pwgrR-001XDy-8S@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kabel@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=thomas.petazzoni@bootlin.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;
as well as URLs for NNTP newsgroup(s).