37511ff1dd75e463419cea6240d97f7a864e0867
[openwrt/staging/xback.git] /
1 From fe2abc1abc0dfc6c13fe8f189216f00dbbb33044 Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Mon, 3 Apr 2023 19:30:30 +0100
4 Subject: [PATCH 3/5] net: mvneta: use buf->type to determine whether to
5 dma-unmap
6
7 Now that we use a different buffer type for TSO headers, we can use
8 buf->type to determine whether the original buffer was DMA-mapped or
9 not. The rules are:
10
11 MVNETA_TYPE_XDP_TX - from a DMA pool, no unmap is required
12 MVNETA_TYPE_XDP_NDO - dma_map_single()'d
13 MVNETA_TYPE_SKB - normal skbuff, dma_map_single()'d
14 MVNETA_TYPE_TSO - from the TSO buffer area
15
16 This means we only need to call dma_unmap_single() on the XDP_NDO and
17 SKB types of buffer, and we no longer need the private IS_TSO_HEADER()
18 which relies on the TSO region being contiguously allocated.
19
20 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
21 ---
22 drivers/net/ethernet/marvell/mvneta.c | 11 ++++-------
23 1 file changed, 4 insertions(+), 7 deletions(-)
24
25 --- a/drivers/net/ethernet/marvell/mvneta.c
26 +++ b/drivers/net/ethernet/marvell/mvneta.c
27 @@ -334,10 +334,6 @@
28 MVNETA_SKB_HEADROOM))
29 #define MVNETA_MAX_RX_BUF_SIZE (PAGE_SIZE - MVNETA_SKB_PAD)
30
31 -#define IS_TSO_HEADER(txq, addr) \
32 - ((addr >= txq->tso_hdrs_phys) && \
33 - (addr < txq->tso_hdrs_phys + txq->size * TSO_HEADER_SIZE))
34 -
35 #define MVNETA_RX_GET_BM_POOL_ID(rxd) \
36 (((rxd)->status & MVNETA_RXD_BM_POOL_MASK) >> MVNETA_RXD_BM_POOL_SHIFT)
37
38 @@ -1848,8 +1844,8 @@ static void mvneta_txq_bufs_free(struct
39
40 mvneta_txq_inc_get(txq);
41
42 - if (!IS_TSO_HEADER(txq, tx_desc->buf_phys_addr) &&
43 - buf->type != MVNETA_TYPE_XDP_TX)
44 + if (buf->type == MVNETA_TYPE_XDP_NDO ||
45 + buf->type == MVNETA_TYPE_SKB)
46 dma_unmap_single(pp->dev->dev.parent,
47 tx_desc->buf_phys_addr,
48 tx_desc->data_size, DMA_TO_DEVICE);
49 @@ -2661,8 +2657,9 @@ static void mvneta_release_descs(struct
50
51 for (i = num; i >= 0; i--) {
52 struct mvneta_tx_desc *tx_desc = txq->descs + desc_idx;
53 + struct mvneta_tx_buf *buf = &txq->buf[desc_idx];
54
55 - if (!IS_TSO_HEADER(txq, tx_desc->buf_phys_addr))
56 + if (buf->type == MVNETA_TYPE_SKB)
57 dma_unmap_single(pp->dev->dev.parent,
58 tx_desc->buf_phys_addr,
59 tx_desc->data_size,