linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net 0/2] DPAA fixes
@ 2018-06-28 12:26 Madalin Bucur
  2018-06-28 12:26 ` [net 1/2] fsl/fman: fix parser reporting bad checksum on short frames Madalin Bucur
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Madalin Bucur @ 2018-06-28 12:26 UTC (permalink / raw)
  To: davem, netdev; +Cc: linux-kernel, Madalin Bucur

A couple of fixes for the DPAA drivers, addressing an issue
with short UDP or TCP frames (with padding) that were marked
as having a wrong checksum and dropped by the FMan hardware
and a problem with the buffer used for the scatter-gather
table being too small as per the hardware requirements.

Madalin Bucur (2):
  fsl/fman: fix parser reporting bad checksum on short frames
  dpaa_eth: DPAA SGT needs to be 256B

 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c  | 15 ++++++++-------
 drivers/net/ethernet/freescale/fman/fman_port.c |  8 ++++++++
 2 files changed, 16 insertions(+), 7 deletions(-)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [net 1/2] fsl/fman: fix parser reporting bad checksum on short frames
  2018-06-28 12:26 [net 0/2] DPAA fixes Madalin Bucur
@ 2018-06-28 12:26 ` Madalin Bucur
  2018-06-28 12:26 ` [net 2/2] dpaa_eth: DPAA SGT needs to be 256B Madalin Bucur
  2018-06-30  9:51 ` [net 0/2] DPAA fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Madalin Bucur @ 2018-06-28 12:26 UTC (permalink / raw)
  To: davem, netdev; +Cc: linux-kernel, Madalin Bucur

The FMan hardware parser needs to be configured to remove the
short frame padding from the checksum calculation, otherwise
short UDP and TCP frames are likely to be marked as having a
bad checksum.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/net/ethernet/freescale/fman/fman_port.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
index 4a2d960..ee82ee1 100644
--- a/drivers/net/ethernet/freescale/fman/fman_port.c
+++ b/drivers/net/ethernet/freescale/fman/fman_port.c
@@ -324,6 +324,10 @@ struct fman_port_qmi_regs {
 #define HWP_HXS_PHE_REPORT 0x00000800
 #define HWP_HXS_PCAC_PSTAT 0x00000100
 #define HWP_HXS_PCAC_PSTOP 0x00000001
+#define HWP_HXS_TCP_OFFSET 0xA
+#define HWP_HXS_UDP_OFFSET 0xB
+#define HWP_HXS_SH_PAD_REM 0x80000000
+
 struct fman_port_hwp_regs {
 	struct {
 		u32 ssa; /* Soft Sequence Attachment */
@@ -728,6 +732,10 @@ static void init_hwp(struct fman_port *port)
 		iowrite32be(0xffffffff, &regs->pmda[i].lcv);
 	}
 
+	/* Short packet padding removal from checksum calculation */
+	iowrite32be(HWP_HXS_SH_PAD_REM, &regs->pmda[HWP_HXS_TCP_OFFSET].ssa);
+	iowrite32be(HWP_HXS_SH_PAD_REM, &regs->pmda[HWP_HXS_UDP_OFFSET].ssa);
+
 	start_port_hwp(port);
 }
 
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [net 2/2] dpaa_eth: DPAA SGT needs to be 256B
  2018-06-28 12:26 [net 0/2] DPAA fixes Madalin Bucur
  2018-06-28 12:26 ` [net 1/2] fsl/fman: fix parser reporting bad checksum on short frames Madalin Bucur
@ 2018-06-28 12:26 ` Madalin Bucur
  2018-06-30  9:51 ` [net 0/2] DPAA fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Madalin Bucur @ 2018-06-28 12:26 UTC (permalink / raw)
  To: davem, netdev; +Cc: linux-kernel, Madalin Bucur

The DPAA HW requires that at least 256 bytes from the start of the
first scatter-gather table entry are allocated and accessible. The
hardware reads the maximum size the table can have in one access,
thus requiring that the allocation and mapping to be done for the
maximum size of 256B even if there is a smaller number of entries
in the table.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
index 52f4a6b..65a22cd 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
@@ -125,6 +125,9 @@ MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms");
 /* Default alignment for start of data in an Rx FD */
 #define DPAA_FD_DATA_ALIGNMENT  16
 
+/* The DPAA requires 256 bytes reserved and mapped for the SGT */
+#define DPAA_SGT_SIZE 256
+
 /* Values for the L3R field of the FM Parse Results
  */
 /* L3 Type field: First IP Present IPv4 */
@@ -1631,8 +1634,8 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,
 
 	if (unlikely(qm_fd_get_format(fd) == qm_fd_sg)) {
 		nr_frags = skb_shinfo(skb)->nr_frags;
-		dma_unmap_single(dev, addr, qm_fd_get_offset(fd) +
-				 sizeof(struct qm_sg_entry) * (1 + nr_frags),
+		dma_unmap_single(dev, addr,
+				 qm_fd_get_offset(fd) + DPAA_SGT_SIZE,
 				 dma_dir);
 
 		/* The sgt buffer has been allocated with netdev_alloc_frag(),
@@ -1917,8 +1920,7 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
 	void *sgt_buf;
 
 	/* get a page frag to store the SGTable */
-	sz = SKB_DATA_ALIGN(priv->tx_headroom +
-		sizeof(struct qm_sg_entry) * (1 + nr_frags));
+	sz = SKB_DATA_ALIGN(priv->tx_headroom + DPAA_SGT_SIZE);
 	sgt_buf = netdev_alloc_frag(sz);
 	if (unlikely(!sgt_buf)) {
 		netdev_err(net_dev, "netdev_alloc_frag() failed for size %d\n",
@@ -1986,9 +1988,8 @@ static int skb_to_sg_fd(struct dpaa_priv *priv,
 	skbh = (struct sk_buff **)buffer_start;
 	*skbh = skb;
 
-	addr = dma_map_single(dev, buffer_start, priv->tx_headroom +
-			      sizeof(struct qm_sg_entry) * (1 + nr_frags),
-			      dma_dir);
+	addr = dma_map_single(dev, buffer_start,
+			      priv->tx_headroom + DPAA_SGT_SIZE, dma_dir);
 	if (unlikely(dma_mapping_error(dev, addr))) {
 		dev_err(dev, "DMA mapping failed");
 		err = -EINVAL;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [net 0/2] DPAA fixes
  2018-06-28 12:26 [net 0/2] DPAA fixes Madalin Bucur
  2018-06-28 12:26 ` [net 1/2] fsl/fman: fix parser reporting bad checksum on short frames Madalin Bucur
  2018-06-28 12:26 ` [net 2/2] dpaa_eth: DPAA SGT needs to be 256B Madalin Bucur
@ 2018-06-30  9:51 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-06-30  9:51 UTC (permalink / raw)
  To: madalin.bucur; +Cc: netdev, linux-kernel

From: Madalin Bucur <madalin.bucur@nxp.com>
Date: Thu, 28 Jun 2018 15:26:49 +0300

> A couple of fixes for the DPAA drivers, addressing an issue
> with short UDP or TCP frames (with padding) that were marked
> as having a wrong checksum and dropped by the FMan hardware
> and a problem with the buffer used for the scatter-gather
> table being too small as per the hardware requirements.

Series applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-30  9:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28 12:26 [net 0/2] DPAA fixes Madalin Bucur
2018-06-28 12:26 ` [net 1/2] fsl/fman: fix parser reporting bad checksum on short frames Madalin Bucur
2018-06-28 12:26 ` [net 2/2] dpaa_eth: DPAA SGT needs to be 256B Madalin Bucur
2018-06-30  9:51 ` [net 0/2] DPAA fixes David Miller

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).