From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
To: <gregkh@linuxfoundation.org>
Cc: <devel@driverdev.osuosl.org>, <linux-kernel@vger.kernel.org>,
<bogdan.purcareata@nxp.com>
Subject: [PATCH 5/6] staging: fsl-dpaa2/eth: Compute needed headroom per frame
Date: Fri, 8 Dec 2017 06:47:57 -0600 [thread overview]
Message-ID: <20171208124758.2732-6-ruxandra.radulescu@nxp.com> (raw)
In-Reply-To: <20171208124758.2732-1-ruxandra.radulescu@nxp.com>
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>
---
drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 9 ++++++---
drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 11 ++++++++---
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 2c12859..8edb7c1 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -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;
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
index 546a862..4ea41d8 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h
@@ -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)
--
2.7.4
next prev parent reply other threads:[~2017-12-08 12:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-08 12:47 [PATCH 0/6] staging: fsl-dpaa2/eth: Frame buffer optimizations Ioana Radulescu
2017-12-08 12:47 ` [PATCH 1/6] staging: fsl-dpaa2/eth: Fix access to FAS field Ioana Radulescu
2017-12-08 12:47 ` [PATCH 2/6] staging: fsl-dpaa2/eth: Don't set netdev->needed_headroom Ioana Radulescu
2017-12-08 12:47 ` [PATCH 3/6] staging: fsl-dpaa2/eth: Add counter for skb reallocs Ioana Radulescu
2017-12-08 12:47 ` [PATCH 4/6] staging: fsl-dpaa2/eth: Don't enable FAS on Tx Ioana Radulescu
2017-12-08 12:47 ` Ioana Radulescu [this message]
2017-12-08 12:47 ` [PATCH 6/6] staging: fsl-dpaa2/eth: Make Tx buffer alignment optional Ioana Radulescu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171208124758.2732-6-ruxandra.radulescu@nxp.com \
--to=ruxandra.radulescu@nxp.com \
--cc=bogdan.purcareata@nxp.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®