OSDN Git Service

nfp: copy only the relevant part of the TX descriptor for frags
authorJakub Kicinski <jakub.kicinski@netronome.com>
Wed, 28 Nov 2018 06:24:48 +0000 (22:24 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 30 Nov 2018 21:30:44 +0000 (13:30 -0800)
Chained descriptors for fragments need to duplicate all the descriptor
fields of the skb head, so we copy the descriptor and then modify the
relevant fields.  This is wasteful, because the top half of the descriptor
will get overwritten entirely while the bottom half is not modified at all.
Copy only the bottom half.  This saves us 0.3% of CPU in a GSO test.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_net.h
drivers/net/ethernet/netronome/nfp/nfp_net_common.c

index bb3dbd7..5a9a617 100644 (file)
@@ -158,6 +158,7 @@ struct nfp_net_tx_desc {
                        __le16 data_len; /* Length of frame + meta data */
                } __packed;
                __le32 vals[4];
+               __le64 vals8[2];
        };
 };
 
index 9aa6265..b54c6e4 100644 (file)
@@ -786,11 +786,11 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
 {
        struct nfp_net *nn = netdev_priv(netdev);
        const struct skb_frag_struct *frag;
-       struct nfp_net_tx_desc *txd, txdg;
        int f, nr_frags, wr_idx, md_bytes;
        struct nfp_net_tx_ring *tx_ring;
        struct nfp_net_r_vector *r_vec;
        struct nfp_net_tx_buf *txbuf;
+       struct nfp_net_tx_desc *txd;
        struct netdev_queue *nd_q;
        struct nfp_net_dp *dp;
        dma_addr_t dma_addr;
@@ -860,8 +860,10 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
 
        /* Gather DMA */
        if (nr_frags > 0) {
+               __le64 second_half;
+
                /* all descs must match except for in addr, length and eop */
-               txdg = *txd;
+               second_half = txd->vals8[1];
 
                for (f = 0; f < nr_frags; f++) {
                        frag = &skb_shinfo(skb)->frags[f];
@@ -878,11 +880,11 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
                        tx_ring->txbufs[wr_idx].fidx = f;
 
                        txd = &tx_ring->txds[wr_idx];
-                       *txd = txdg;
                        txd->dma_len = cpu_to_le16(fsize);
                        nfp_desc_set_dma_addr(txd, dma_addr);
-                       txd->offset_eop |=
-                               (f == nr_frags - 1) ? PCIE_DESC_TX_EOP : 0;
+                       txd->offset_eop = md_bytes |
+                               ((f == nr_frags - 1) ? PCIE_DESC_TX_EOP : 0);
+                       txd->vals8[1] = second_half;
                }
 
                u64_stats_update_begin(&r_vec->tx_sync);