Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38912bdb authored by Deepak SIKRI's avatar Deepak SIKRI Committed by David S. Miller
Browse files

stmmac: sanitize the rx coe and add the type-1 csum (v2)



This patch sanities the RX coe and adds the Type-1 Rx checksum offload engine (COE).

So the RX COE can be passed through the platform but can be fixed
at run-time in case of the core has the HW capability register.

Also to support the Type-1 Rx COE the driver must append the
HW checksum at the end of payload in case the Rx checksum
engine was used to  offload the HW checksum.

This v2 version also fixes the IPC that has to be enabled and verified.

Signed-off-by: default avatarDeepak Sikri <deepak.sikri@st.com>
Hacked-by: default avatarGiuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 55f9a4d6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ struct stmmac_desc_ops {
	int (*get_rx_owner) (struct dma_desc *p);
	void (*set_rx_owner) (struct dma_desc *p);
	/* Get the receive frame size */
	int (*get_rx_frame_len) (struct dma_desc *p);
	int (*get_rx_frame_len) (struct dma_desc *p, int rx_coe_type);
	/* Return the reception status looking at the RDES1 */
	int (*rx_status) (void *data, struct stmmac_extra_stats *x,
			  struct dma_desc *p);
@@ -261,8 +261,8 @@ struct stmmac_dma_ops {
struct stmmac_ops {
	/* MAC core initialization */
	void (*core_init) (void __iomem *ioaddr) ____cacheline_aligned;
	/* Support checksum offload engine */
	int  (*rx_coe) (void __iomem *ioaddr);
	/* Enable and verify that the IPC module is supported */
	int (*rx_ipc) (void __iomem *ioaddr);
	/* Dump MAC registers */
	void (*dump_regs) (void __iomem *ioaddr);
	/* Handle extra events on specific interrupts hw dependent */
+2 −2
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ static void dwmac1000_core_init(void __iomem *ioaddr)
#endif
}

static int dwmac1000_rx_coe_supported(void __iomem *ioaddr)
static int dwmac1000_rx_ipc_enable(void __iomem *ioaddr)
{
	u32 value = readl(ioaddr + GMAC_CONTROL);

@@ -211,7 +211,7 @@ static void dwmac1000_irq_status(void __iomem *ioaddr)

static const struct stmmac_ops dwmac1000_ops = {
	.core_init = dwmac1000_core_init,
	.rx_coe = dwmac1000_rx_coe_supported,
	.rx_ipc = dwmac1000_rx_ipc_enable,
	.dump_regs = dwmac1000_dump_regs,
	.host_irq_status = dwmac1000_irq_status,
	.set_filter = dwmac1000_set_filter,
+6 −6
Original line number Diff line number Diff line
@@ -43,11 +43,6 @@ static void dwmac100_core_init(void __iomem *ioaddr)
#endif
}

static int dwmac100_rx_coe_supported(void __iomem *ioaddr)
{
	return 0;
}

static void dwmac100_dump_mac_regs(void __iomem *ioaddr)
{
	pr_info("\t----------------------------------------------\n"
@@ -72,6 +67,11 @@ static void dwmac100_dump_mac_regs(void __iomem *ioaddr)
		readl(ioaddr + MAC_VLAN2));
}

static int dwmac100_rx_ipc_enable(void __iomem *ioaddr)
{
	return 0;
}

static void dwmac100_irq_status(void __iomem *ioaddr)
{
	return;
@@ -160,7 +160,7 @@ static void dwmac100_pmt(void __iomem *ioaddr, unsigned long mode)

static const struct stmmac_ops dwmac100_ops = {
	.core_init = dwmac100_core_init,
	.rx_coe = dwmac100_rx_coe_supported,
	.rx_ipc = dwmac100_rx_ipc_enable,
	.dump_regs = dwmac100_dump_mac_regs,
	.host_irq_status = dwmac100_irq_status,
	.set_filter = dwmac100_set_filter,
+11 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
  Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
*******************************************************************************/

#include <linux/stmmac.h>
#include "common.h"
#include "descs_com.h"

@@ -309,8 +310,16 @@ static void enh_desc_close_tx_desc(struct dma_desc *p)
	p->des01.etx.interrupt = 1;
}

static int enh_desc_get_rx_frame_len(struct dma_desc *p)
static int enh_desc_get_rx_frame_len(struct dma_desc *p, int rx_coe_type)
{
	/* The type-1 checksum offload engines append the checksum at
	 * the end of frame and the two bytes of checksum are added in
	 * the length.
	 * Adjust for that in the framelen for type-1 checksum offload
	 * engines. */
	if (rx_coe_type == STMMAC_RX_COE_TYPE1)
		return p->des01.erx.frame_length - 2;
	else
		return p->des01.erx.frame_length;
}

+11 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
  Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
*******************************************************************************/

#include <linux/stmmac.h>
#include "common.h"
#include "descs_com.h"

@@ -201,8 +202,16 @@ static void ndesc_close_tx_desc(struct dma_desc *p)
	p->des01.tx.interrupt = 1;
}

static int ndesc_get_rx_frame_len(struct dma_desc *p)
static int ndesc_get_rx_frame_len(struct dma_desc *p, int rx_coe_type)
{
	/* The type-1 checksum offload engines append the checksum at
	 * the end of frame and the two bytes of checksum are added in
	 * the length.
	 * Adjust for that in the framelen for type-1 checksum offload
	 * engines. */
	if (rx_coe_type == STMMAC_RX_COE_TYPE1)
		return p->des01.rx.frame_length - 2;
	else
		return p->des01.rx.frame_length;
}

Loading