Skip to content

Commit 271e015

Browse files
shimodaydavem330
authored andcommitted
net: rswitch: Add unmap_addrs instead of dma address in each desc
If the driver would like to transmit a jumbo frame like 2KiB or more, it should be split into multiple queues. In the near future, to support this, add unmap_addrs array to unmap dma mapping address instead of dma address in each TX descriptor because the descriptors may not have the top dma address. Signed-off-by: Yoshihiro Shimoda <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6a203cb commit 271e015

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

drivers/net/ethernet/renesas/rswitch.c

+11-8
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ static void rswitch_gwca_queue_free(struct net_device *ndev,
284284
gq->tx_ring = NULL;
285285
kfree(gq->skbs);
286286
gq->skbs = NULL;
287+
kfree(gq->unmap_addrs);
288+
gq->unmap_addrs = NULL;
287289
}
288290
}
289291

@@ -322,6 +324,9 @@ static int rswitch_gwca_queue_alloc(struct net_device *ndev,
322324
gq->skbs = kcalloc(gq->ring_size, sizeof(*gq->skbs), GFP_KERNEL);
323325
if (!gq->skbs)
324326
return -ENOMEM;
327+
gq->unmap_addrs = kcalloc(gq->ring_size, sizeof(*gq->unmap_addrs), GFP_KERNEL);
328+
if (!gq->unmap_addrs)
329+
goto out;
325330
gq->tx_ring = dma_alloc_coherent(ndev->dev.parent,
326331
sizeof(struct rswitch_ext_desc) *
327332
(gq->ring_size + 1), &gq->ring_dma, GFP_KERNEL);
@@ -787,9 +792,7 @@ static void rswitch_tx_free(struct net_device *ndev)
787792
struct rswitch_device *rdev = netdev_priv(ndev);
788793
struct rswitch_gwca_queue *gq = rdev->tx_queue;
789794
struct rswitch_ext_desc *desc;
790-
dma_addr_t dma_addr;
791795
struct sk_buff *skb;
792-
unsigned int size;
793796

794797
for (; rswitch_get_num_cur_queues(gq) > 0;
795798
gq->dirty = rswitch_next_queue_index(gq, false, 1)) {
@@ -798,18 +801,17 @@ static void rswitch_tx_free(struct net_device *ndev)
798801
break;
799802

800803
dma_rmb();
801-
size = le16_to_cpu(desc->desc.info_ds) & TX_DS;
802804
skb = gq->skbs[gq->dirty];
803805
if (skb) {
804-
dma_addr = rswitch_desc_get_dptr(&desc->desc);
805-
dma_unmap_single(ndev->dev.parent, dma_addr,
806-
size, DMA_TO_DEVICE);
806+
dma_unmap_single(ndev->dev.parent,
807+
gq->unmap_addrs[gq->dirty],
808+
skb->len, DMA_TO_DEVICE);
807809
dev_kfree_skb_any(gq->skbs[gq->dirty]);
808810
gq->skbs[gq->dirty] = NULL;
811+
rdev->ndev->stats.tx_packets++;
812+
rdev->ndev->stats.tx_bytes += skb->len;
809813
}
810814
desc->desc.die_dt = DT_EEMPTY;
811-
rdev->ndev->stats.tx_packets++;
812-
rdev->ndev->stats.tx_bytes += size;
813815
}
814816
}
815817

@@ -1538,6 +1540,7 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
15381540
goto err_kfree;
15391541

15401542
gq->skbs[gq->cur] = skb;
1543+
gq->unmap_addrs[gq->cur] = dma_addr;
15411544
desc = &gq->tx_ring[gq->cur];
15421545
rswitch_desc_set_dptr(&desc->desc, dma_addr);
15431546
desc->desc.info_ds = cpu_to_le16(skb->len);

drivers/net/ethernet/renesas/rswitch.h

+1
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ struct rswitch_gwca_queue {
956956
/* For TX */
957957
struct {
958958
struct sk_buff **skbs;
959+
dma_addr_t *unmap_addrs;
959960
};
960961
/* For RX */
961962
struct {

0 commit comments

Comments
 (0)