This series addresses issue with the current workaround for the A050385
erratum in XDP scenarios.
The first patch makes sure the xdp_frame structure stored at the start of
new buffers isn't overwritten.
The second patch decreases the required data alignment value, thus
preventing unnecessary realignments.
The third patch moves the data in place to align it, instead of allocating
a new buffer for each frame that breaks the alignment rules, thus bringing
an up to 40% performance increase. With this change, the impact of the
erratum workaround is reduced in many cases to a single digit decrease, and
to lower double digits in single flow scenarios.
Changes in v2:
- guarantee enough tailroom is available for the shared_info in 1/3
Camelia Groza (3):
dpaa_eth: reserve space for the xdp_frame under the A050385 erratum
dpaa_eth: reduce data alignment requirements for the A050385 erratum
dpaa_eth: try to move the data in place for the A050385 erratum
.../net/ethernet/freescale/dpaa/dpaa_eth.c | 42 +++++++++++++++++--
1 file changed, 38 insertions(+), 4 deletions(-)
--
2.17.1
When the erratum workaround is triggered, the newly created xdp_frame
structure is stored at the start of the newly allocated buffer. Avoid
the structure from being overwritten by explicitly reserving enough
space in the buffer for storing it.
Account for the fact that the structure's size might increase in time by
aligning the headroom to DPAA_FD_DATA_ALIGNMENT bytes, thus guaranteeing
the data's alignment.
Fixes: ae680bcbd06a ("dpaa_eth: implement the A050385 erratum workaround for XDP")
Signed-off-by: Camelia Groza <redacted>
---
Changes in v2:
- guarantee enough tailroom is available for the shared_info
.../net/ethernet/freescale/dpaa/dpaa_eth.c | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
@@ -2182,6 +2182,7 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv,structxdp_frame*new_xdpf,*xdpf=*init_xdpf;void*new_buff;structpage*p;+intheadroom;/* Check the data alignment and make sure the headroom is large*enoughtostorethexdpfbackpointer.Useanalignedheadroom
@@ -2197,19 +2198,34 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv,return0;}+/* The new xdp_frame is stored in the new buffer. Reserve enough space+*intheheadroomforstoringitalongwiththedriver'sprivate+*info.TheheadroomneedstobealignedtoDPAA_FD_DATA_ALIGNMENTto+*guaranteethedata'salignmentinthebuffer.+*/+headroom=ALIGN(sizeof(*new_xdpf)+priv->tx_headroom,+DPAA_FD_DATA_ALIGNMENT);++/* Assure the extended headroom and data don't overflow the buffer,+*whilemaintainingthemandatorytailroom.+*/+if(headroom+xdpf->len>DPAA_BP_RAW_SIZE-+SKB_DATA_ALIGN(sizeof(structskb_shared_info)))+return-ENOMEM;+p=dev_alloc_pages(0);if(unlikely(!p))return-ENOMEM;/* Copy the data to the new buffer at a properly aligned offset */new_buff=page_address(p);-memcpy(new_buff+priv->tx_headroom,xdpf->data,xdpf->len);+memcpy(new_buff+headroom,xdpf->data,xdpf->len);/* Create an XDP frame around the new buffer in a similar fashion*toxdp_convert_buff_to_frame.*/new_xdpf=new_buff;-new_xdpf->data=new_buff+priv->tx_headroom;+new_xdpf->data=new_buff+headroom;new_xdpf->len=xdpf->len;new_xdpf->headroom=priv->tx_headroom;new_xdpf->frame_sz=DPAA_BP_RAW_SIZE;--
The 256 byte data alignment is required for preventing DMA transaction
splits when crossing 4K page boundaries. Since XDP deals only with page
sized buffers or less, this restriction isn't needed. Instead, the data
only needs to be aligned to 64 bytes to prevent DMA transaction splits.
These lessened restrictions can increase performance by widening the pool
of permitted data alignments and preventing unnecessary realignments.
Fixes: ae680bcbd06a ("dpaa_eth: implement the A050385 erratum workaround for XDP")
Signed-off-by: Camelia Groza <redacted>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 <redacted>
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
.../net/ethernet/freescale/dpaa/dpaa_eth.c | 20 ++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
@@ -2180,8 +2180,9 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv,structxdp_frame**init_xdpf){structxdp_frame*new_xdpf,*xdpf=*init_xdpf;-void*new_buff;+void*new_buff,*aligned_data;structpage*p;+u32data_shift;intheadroom;/* 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,return0;}+/* Try to move the data inside the buffer just enough to align it and+*storethexdpfbackpointer.Iftheavailableheadroomisn'tlarge+*enough,resorttoallocatinganewbufferandcopyingthedata.+*/+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+*shiftingthedataaswellasstoringthexdpfbackpointer.+*/+if(xdpf->headroom>=data_shift+priv->tx_headroom){+memmove(aligned_data,xdpf->data,xdpf->len);+xdpf->data=aligned_data;+xdpf->headroom=priv->tx_headroom;+return0;+}+/* The new xdp_frame is stored in the new buffer. Reserve enough space*intheheadroomforstoringitalongwiththedriver'sprivate*info.TheheadroomneedstobealignedtoDPAA_FD_DATA_ALIGNMENTto
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Date: 2021-02-04 19:05:23
On Thu, Feb 04, 2021 at 06:49:25PM +0200, Camelia Groza wrote:
This series addresses issue with the current workaround for the A050385
erratum in XDP scenarios.
The first patch makes sure the xdp_frame structure stored at the start of
new buffers isn't overwritten.
The second patch decreases the required data alignment value, thus
preventing unnecessary realignments.
The third patch moves the data in place to align it, instead of allocating
a new buffer for each frame that breaks the alignment rules, thus bringing
an up to 40% performance increase. With this change, the impact of the
erratum workaround is reduced in many cases to a single digit decrease, and
to lower double digits in single flow scenarios.
For series:
Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Changes in v2:
- guarantee enough tailroom is available for the shared_info in 1/3
Camelia Groza (3):
dpaa_eth: reserve space for the xdp_frame under the A050385 erratum
dpaa_eth: reduce data alignment requirements for the A050385 erratum
dpaa_eth: try to move the data in place for the A050385 erratum
.../net/ethernet/freescale/dpaa/dpaa_eth.c | 42 +++++++++++++++++--
1 file changed, 38 insertions(+), 4 deletions(-)
--
2.17.1
-----Original Message-----
From: Camelia Alexandra Groza <redacted>
Sent: 04 February 2021 18:49
To: kuba@kernel.org; davem@davemloft.net; maciej.fijalkowski@intel.com
Cc: Madalin Bucur (OSS) <redacted>;
netdev@vger.kernel.org; Camelia Alexandra Groza [off-list ref]
Subject: [PATCH net v2 0/3] dpaa_eth: A050385 erratum workaround fixes
under XDP
This series addresses issue with the current workaround for the A050385
erratum in XDP scenarios.
The first patch makes sure the xdp_frame structure stored at the start of
new buffers isn't overwritten.
The second patch decreases the required data alignment value, thus
preventing unnecessary realignments.
The third patch moves the data in place to align it, instead of allocating
a new buffer for each frame that breaks the alignment rules, thus bringing
an up to 40% performance increase. With this change, the impact of the
erratum workaround is reduced in many cases to a single digit decrease,
and
to lower double digits in single flow scenarios.
Changes in v2:
- guarantee enough tailroom is available for the shared_info in 1/3
Camelia Groza (3):
dpaa_eth: reserve space for the xdp_frame under the A050385 erratum
dpaa_eth: reduce data alignment requirements for the A050385 erratum
dpaa_eth: try to move the data in place for the A050385 erratum
.../net/ethernet/freescale/dpaa/dpaa_eth.c | 42 +++++++++++++++++--
1 file changed, 38 insertions(+), 4 deletions(-)
--
2.17.1
For the series,
Acked-by: Madalin Bucur <redacted>
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-02-06 17:49:14
On Thu, 4 Feb 2021 18:49:25 +0200 Camelia Groza wrote:
This series addresses issue with the current workaround for the A050385
erratum in XDP scenarios.
The first patch makes sure the xdp_frame structure stored at the start of
new buffers isn't overwritten.
The second patch decreases the required data alignment value, thus
preventing unnecessary realignments.
The third patch moves the data in place to align it, instead of allocating
a new buffer for each frame that breaks the alignment rules, thus bringing
an up to 40% performance increase. With this change, the impact of the
erratum workaround is reduced in many cases to a single digit decrease, and
to lower double digits in single flow scenarios.
Looks like reply bot got moody.
Applied, thanks everyone!