From: Camelia Groza <camelia.groza@nxp.com>
To: kuba@kernel.org, davem@davemloft.net, maciej.fijalkowski@intel.com
Cc: madalin.bucur@oss.nxp.com, netdev@vger.kernel.org,
Camelia Groza <camelia.groza@nxp.com>
Subject: [PATCH net v2 3/3] dpaa_eth: try to move the data in place for the A050385 erratum
Date: Thu, 4 Feb 2021 18:49:28 +0200 [thread overview]
Message-ID: <883f775dabac981c0f46b6296b134a87cc74ca83.1612456902.git.camelia.groza@nxp.com> (raw)
In-Reply-To: <cover.1612456902.git.camelia.groza@nxp.com>
The XDP frame's headroom might be large enough to accommodate the
xdpf backpointer as well as shifting the data to an aligned address.
Try this first before resorting to allocating a new buffer and copying
the data.
Suggested-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
.../net/ethernet/freescale/dpaa/dpaa_eth.c | 20 ++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 2a2c7db23407..6faa20bed488 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2180,8 +2180,9 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv,
struct xdp_frame **init_xdpf)
{
struct xdp_frame *new_xdpf, *xdpf = *init_xdpf;
- void *new_buff;
+ void *new_buff, *aligned_data;
struct page *p;
+ u32 data_shift;
int headroom;
/* Check the data alignment and make sure the headroom is large
@@ -2198,6 +2199,23 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv,
return 0;
}
+ /* Try to move the data inside the buffer just enough to align it and
+ * store the xdpf backpointer. If the available headroom isn't large
+ * enough, resort to allocating a new buffer and copying the data.
+ */
+ aligned_data = PTR_ALIGN_DOWN(xdpf->data, DPAA_FD_DATA_ALIGNMENT);
+ data_shift = xdpf->data - aligned_data;
+
+ /* The XDP frame's headroom needs to be large enough to accommodate
+ * shifting the data as well as storing the xdpf backpointer.
+ */
+ if (xdpf->headroom >= data_shift + priv->tx_headroom) {
+ memmove(aligned_data, xdpf->data, xdpf->len);
+ xdpf->data = aligned_data;
+ xdpf->headroom = priv->tx_headroom;
+ return 0;
+ }
+
/* The new xdp_frame is stored in the new buffer. Reserve enough space
* in the headroom for storing it along with the driver's private
* info. The headroom needs to be aligned to DPAA_FD_DATA_ALIGNMENT to
--
2.17.1
next prev parent reply other threads:[~2021-02-04 16:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-04 16:49 [PATCH net v2 0/3] dpaa_eth: A050385 erratum workaround fixes under XDP Camelia Groza
2021-02-04 16:49 ` [PATCH net v2 1/3] dpaa_eth: reserve space for the xdp_frame under the A050385 erratum Camelia Groza
2021-02-04 16:49 ` [PATCH net v2 2/3] dpaa_eth: reduce data alignment requirements for " Camelia Groza
2021-02-04 16:49 ` Camelia Groza [this message]
2021-02-04 18:54 ` [PATCH net v2 0/3] dpaa_eth: A050385 erratum workaround fixes under XDP Maciej Fijalkowski
2021-02-05 8:29 ` Madalin Bucur (OSS)
2021-02-06 17:48 ` Jakub Kicinski
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=883f775dabac981c0f46b6296b134a87cc74ca83.1612456902.git.camelia.groza@nxp.com \
--to=camelia.groza@nxp.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=madalin.bucur@oss.nxp.com \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).