]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
staging: fsl-dpaa2/eth: Compute needed headroom per frame
authorIoana Radulescu <ruxandra.radulescu@nxp.com>
Fri, 8 Dec 2017 12:47:57 +0000 (06:47 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Dec 2017 15:33:29 +0000 (16:33 +0100)
For non-linear skbs we build scatter-gather frames and allocate
a new buffer for the S/G table in which we reserve the required
headroom, so the actual skb headroom size doesn't matter.

Rather than use a one-size-fits-all approach, decide when to
enforce headroom requirements on a frame by frame basis.

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 2c12859d3ff0f28d64acc02fc8d350ade39f3729..8edb7c10f978cd0768a71761aff7646100a1f3b4 100644 (file)
@@ -437,7 +437,8 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
        struct sk_buff **skbh;
        dma_addr_t addr;
 
-       buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv),
+       buffer_start = PTR_ALIGN(skb->data -
+                                dpaa2_eth_needed_headroom(priv, skb),
                                 DPAA2_ETH_TX_BUF_ALIGN);
 
        /* Store a backpointer to the skb at the beginning of the buffer
@@ -532,15 +533,17 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
        struct dpaa2_eth_drv_stats *percpu_extras;
        struct dpaa2_eth_fq *fq;
        u16 queue_mapping;
+       unsigned int needed_headroom;
        int err, i;
 
        percpu_stats = this_cpu_ptr(priv->percpu_stats);
        percpu_extras = this_cpu_ptr(priv->percpu_extras);
 
-       if (skb_headroom(skb) < dpaa2_eth_needed_headroom(priv)) {
+       needed_headroom = dpaa2_eth_needed_headroom(priv, skb);
+       if (skb_headroom(skb) < needed_headroom) {
                struct sk_buff *ns;
 
-               ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv));
+               ns = skb_realloc_headroom(skb, needed_headroom);
                if (unlikely(!ns)) {
                        percpu_stats->tx_dropped++;
                        goto err_alloc_headroom;
index 546a8624ac2f77b9562fc39b8a4682cc7ba8b8dc..4ea41d85c231803fe2f1658c7fb3759023347e05 100644 (file)
@@ -364,9 +364,13 @@ static inline unsigned int dpaa2_eth_buf_raw_size(struct dpaa2_eth_priv *priv)
 }
 
 static inline
-unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv)
+unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv,
+                                      struct sk_buff *skb)
 {
-       return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN;
+       if (skb_is_nonlinear(skb))
+               return 0;
+
+       return DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN;
 }
 
 /* Extra headroom space requested to hardware, in order to make sure there's
@@ -374,7 +378,8 @@ unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv)
  */
 static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv)
 {
-       return dpaa2_eth_needed_headroom(priv) - DPAA2_ETH_RX_HWA_SIZE;
+       return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN -
+              DPAA2_ETH_RX_HWA_SIZE;
 }
 
 static int dpaa2_eth_queue_count(struct dpaa2_eth_priv *priv)