Commit 441851b4 authored by Ioana Radulescu's avatar Ioana Radulescu Committed by Greg Kroah-Hartman

staging: fsl-dpaa2/eth: Don't set netdev->needed_headroom

Commit 4b2d9fe8 ("staging: fsl-dpaa2/eth: Extra headroom in RX
buffers") tried to avoid the performance penalty of doing skb
reallocations in the network stack for IP forwarded frames between
two DPAA2 Ethernet interfaces. This led to a (too) complicated
formula that relies on the stack's internal implementation.

Instead, it's safer and easier to just not request any guarantee
from the stack. We already double check in the driver the required
headroom size of egress frames and realloc the skb if needed, so
we don't need to add any extra code.

On forwarding between two of our own interfaces, there is no
functional change; for traffic forwarded from a different device or
generated on the core, skb realloc operations are moved from the stack
to our driver, with no visible impact on performance.
Signed-off-by: default avatarIoana Radulescu <ruxandra.radulescu@nxp.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 54ce8917
...@@ -449,8 +449,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv, ...@@ -449,8 +449,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv,
struct sk_buff **skbh; struct sk_buff **skbh;
dma_addr_t addr; dma_addr_t addr;
buffer_start = PTR_ALIGN(skb->data - priv->tx_data_offset - buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv),
DPAA2_ETH_TX_BUF_ALIGN,
DPAA2_ETH_TX_BUF_ALIGN); DPAA2_ETH_TX_BUF_ALIGN);
/* PTA from egress side is passed as is to the confirmation side so /* PTA from egress side is passed as is to the confirmation side so
...@@ -571,7 +570,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) ...@@ -571,7 +570,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
percpu_stats = this_cpu_ptr(priv->percpu_stats); percpu_stats = this_cpu_ptr(priv->percpu_stats);
percpu_extras = this_cpu_ptr(priv->percpu_extras); percpu_extras = this_cpu_ptr(priv->percpu_extras);
if (unlikely(skb_headroom(skb) < dpaa2_eth_needed_headroom(priv))) { if (skb_headroom(skb) < dpaa2_eth_needed_headroom(priv)) {
struct sk_buff *ns; struct sk_buff *ns;
ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv)); ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv));
...@@ -2273,7 +2272,6 @@ static int netdev_init(struct net_device *net_dev) ...@@ -2273,7 +2272,6 @@ static int netdev_init(struct net_device *net_dev)
{ {
struct device *dev = net_dev->dev.parent; struct device *dev = net_dev->dev.parent;
struct dpaa2_eth_priv *priv = netdev_priv(net_dev); struct dpaa2_eth_priv *priv = netdev_priv(net_dev);
u16 rx_headroom, req_headroom;
u8 bcast_addr[ETH_ALEN]; u8 bcast_addr[ETH_ALEN];
u8 num_queues; u8 num_queues;
int err; int err;
...@@ -2292,24 +2290,6 @@ static int netdev_init(struct net_device *net_dev) ...@@ -2292,24 +2290,6 @@ static int netdev_init(struct net_device *net_dev)
return err; return err;
} }
/* Reserve enough space to align buffer as per hardware requirement;
* NOTE: priv->tx_data_offset MUST be initialized at this point.
*/
net_dev->needed_headroom = dpaa2_eth_needed_headroom(priv);
/* If headroom guaranteed by hardware in the Rx frame buffer is
* smaller than the Tx headroom required by the stack, issue a
* one time warning. This will most likely mean skbs forwarded to
* another DPAA2 network interface will get reallocated, with a
* significant performance impact.
*/
req_headroom = LL_RESERVED_SPACE(net_dev) - ETH_HLEN;
rx_headroom = ALIGN(DPAA2_ETH_RX_HWA_SIZE +
dpaa2_eth_rx_head_room(priv), priv->rx_buf_align);
if (req_headroom > rx_headroom)
dev_info_once(dev, "Required headroom (%d) greater than available (%d)\n",
req_headroom, rx_headroom);
/* Set MTU limits */ /* Set MTU limits */
net_dev->min_mtu = 68; net_dev->min_mtu = 68;
net_dev->max_mtu = DPAA2_ETH_MAX_MTU; net_dev->max_mtu = DPAA2_ETH_MAX_MTU;
......
...@@ -371,7 +371,7 @@ static inline unsigned int dpaa2_eth_buf_raw_size(struct dpaa2_eth_priv *priv) ...@@ -371,7 +371,7 @@ static inline unsigned int dpaa2_eth_buf_raw_size(struct dpaa2_eth_priv *priv)
static inline static inline
unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv) unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv)
{ {
return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN - HH_DATA_MOD; return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN;
} }
/* Extra headroom space requested to hardware, in order to make sure there's /* Extra headroom space requested to hardware, in order to make sure there's
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment