diff mbox series

[net,v2,2/2] dpaa_eth: fix the RX headroom size alignment

Message ID 5b077d5853123db0c8794af1ed061850b94eae37.1603899392.git.camelia.groza@nxp.com
State New
Headers show
Series dpaa_eth: buffer layout fixes | expand

Commit Message

Camelia Alexandra Groza Oct. 28, 2020, 4:41 p.m. UTC
The headroom reserved for received frames needs to be aligned to an
RX specific value. There is currently a discrepancy between the values
used in the Ethernet driver and the values passed to the FMan.
Coincidentally, the resulting aligned values are identical.

Fixes: 3c68b8fffb48 ("dpaa_eth: FMan erratum A050385 workaround")
Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
---
Changes in v2:
- make the returned value for TX ports explicit
- simplify the buf_layout reference

 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

--
1.9.1

Comments

Willem de Bruijn Oct. 28, 2020, 8:45 p.m. UTC | #1
On Wed, Oct 28, 2020 at 12:41 PM Camelia Groza <camelia.groza@nxp.com> wrote:
>
> The headroom reserved for received frames needs to be aligned to an
> RX specific value. There is currently a discrepancy between the values
> used in the Ethernet driver and the values passed to the FMan.
> Coincidentally, the resulting aligned values are identical.
>
> Fixes: 3c68b8fffb48 ("dpaa_eth: FMan erratum A050385 workaround")
> Signed-off-by: Camelia Groza <camelia.groza@nxp.com>

Acked-by: Willem de Bruijn <willemb@google.com>
Jakub Kicinski Oct. 31, 2020, 1:43 a.m. UTC | #2
On Wed, 28 Oct 2020 18:41:00 +0200 Camelia Groza wrote:
> @@ -2842,7 +2842,8 @@ static int dpaa_ingress_cgr_init(struct dpaa_priv *priv)

>  	return err;

>  }

> 

> -static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl)

> +static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl,

> +				    enum port_type port)


Please drop the "inline" while you're touching this definition.

The compiler will make the right inlining decision here.
Camelia Alexandra Groza Nov. 2, 2020, 5:09 p.m. UTC | #3
> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Saturday, October 31, 2020 03:44
> To: Camelia Alexandra Groza <camelia.groza@nxp.com>
> Cc: willemdebruijn.kernel@gmail.com; Madalin Bucur (OSS)
> <madalin.bucur@oss.nxp.com>; davem@davemloft.net;
> netdev@vger.kernel.org
> Subject: Re: [PATCH net v2 2/2] dpaa_eth: fix the RX headroom size
> alignment
> 
> On Wed, 28 Oct 2020 18:41:00 +0200 Camelia Groza wrote:
> > @@ -2842,7 +2842,8 @@ static int dpaa_ingress_cgr_init(struct dpaa_priv
> *priv)
> >  	return err;
> >  }
> >
> > -static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl)
> > +static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl,
> > +				    enum port_type port)
> 
> Please drop the "inline" while you're touching this definition.
> 
> The compiler will make the right inlining decision here.

Sure, I'll drop it.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 1aac0b6..278a684 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -2842,7 +2842,8 @@  static int dpaa_ingress_cgr_init(struct dpaa_priv *priv)
 	return err;
 }

-static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl)
+static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl,
+				    enum port_type port)
 {
 	u16 headroom;

@@ -2856,10 +2857,13 @@  static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl)
 	 *
 	 * Also make sure the headroom is a multiple of data_align bytes
 	 */
-	headroom = (u16)(bl->priv_data_size + DPAA_PARSE_RESULTS_SIZE +
+	headroom = (u16)(bl[port].priv_data_size + DPAA_PARSE_RESULTS_SIZE +
 		DPAA_TIME_STAMP_SIZE + DPAA_HASH_RESULTS_SIZE);

-	return ALIGN(headroom, DPAA_FD_DATA_ALIGNMENT);
+	if (port == RX)
+		return ALIGN(headroom, DPAA_FD_RX_DATA_ALIGNMENT);
+	else
+		return ALIGN(headroom, DPAA_FD_DATA_ALIGNMENT);
 }

 static int dpaa_eth_probe(struct platform_device *pdev)
@@ -3027,8 +3031,8 @@  static int dpaa_eth_probe(struct platform_device *pdev)
 			goto free_dpaa_fqs;
 	}

-	priv->tx_headroom = dpaa_get_headroom(&priv->buf_layout[TX]);
-	priv->rx_headroom = dpaa_get_headroom(&priv->buf_layout[RX]);
+	priv->tx_headroom = dpaa_get_headroom(priv->buf_layout, TX);
+	priv->rx_headroom = dpaa_get_headroom(priv->buf_layout, RX);

 	/* All real interfaces need their ports initialized */
 	err = dpaa_eth_init_ports(mac_dev, dpaa_bp, &port_fqs,