]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: fsl-dpaa2/eth: Cleanup TX frame freeing code
authorIoana Radulescu <ruxandra.radulescu@nxp.com>
Fri, 23 Mar 2018 13:44:11 +0000 (08:44 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Mar 2018 15:01:57 +0000 (16:01 +0100)
Cleanup code in free_tx_fd() that deals with S/G frames:
- remove local variables that aren't really needed
- in the frame sw annotation area, store the actual SG table
buffer size, which is needed on free, rather then recompute
it based on number of S/G entries

Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h

index f58c85a4a62e87b5f977c102405be1f6b286e81f..9994922db68a5a407c5cbfa28f6f1a66f97fde4c 100644 (file)
@@ -406,7 +406,7 @@ static int build_sg_fd(struct dpaa2_eth_priv *priv,
        swa->skb = skb;
        swa->scl = scl;
        swa->num_sg = num_sg;
-       swa->num_dma_bufs = num_dma_bufs;
+       swa->sgt_size = sgt_buf_size;
 
        /* Separately map the SGT buffer */
        addr = dma_map_single(dev, sgt_buf, sgt_buf_size, DMA_BIDIRECTIONAL);
@@ -489,9 +489,6 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
        dma_addr_t fd_addr;
        struct sk_buff **skbh, *skb;
        unsigned char *buffer_start;
-       int unmap_size;
-       struct scatterlist *scl;
-       int num_sg, num_dma_bufs;
        struct dpaa2_eth_swa *swa;
        u8 fd_format = dpaa2_fd_get_format(fd);
 
@@ -510,18 +507,14 @@ static void free_tx_fd(const struct dpaa2_eth_priv *priv,
        } else if (fd_format == dpaa2_fd_sg) {
                swa = (struct dpaa2_eth_swa *)skbh;
                skb = swa->skb;
-               scl = swa->scl;
-               num_sg = swa->num_sg;
-               num_dma_bufs = swa->num_dma_bufs;
 
                /* Unmap the scatterlist */
-               dma_unmap_sg(dev, scl, num_sg, DMA_BIDIRECTIONAL);
-               kfree(scl);
+               dma_unmap_sg(dev, swa->scl, swa->num_sg, DMA_BIDIRECTIONAL);
+               kfree(swa->scl);
 
                /* Unmap the SGT buffer */
-               unmap_size = priv->tx_data_offset +
-                      sizeof(struct dpaa2_sg_entry) * (1 + num_dma_bufs);
-               dma_unmap_single(dev, fd_addr, unmap_size, DMA_BIDIRECTIONAL);
+               dma_unmap_single(dev, fd_addr, swa->sgt_size,
+                                DMA_BIDIRECTIONAL);
        } else {
                netdev_dbg(priv->net_dev, "Invalid FD format\n");
                return;
index 5ac014f5833ad28084b54d94bffb60636b669dcc..fc9a25519ee67022e74cec1a2afe4c73a609653e 100644 (file)
@@ -108,7 +108,7 @@ struct dpaa2_eth_swa {
        struct sk_buff *skb;
        struct scatterlist *scl;
        int num_sg;
-       int num_dma_bufs;
+       int sgt_size;
 };
 
 /* Annotation valid bits in FD FRC */