Allow packet captures to see complete frames that the sun8i MAC forwards with wire errors. Mark these frames, including runts, as errored with an unverified checksum so stmmac can deliver them when rx-all is enabled. Incomplete frames and DMA errors still require a drop. Set runt forwarding from the rx-all setting at initialization and update that bit when the setting changes on a running interface. RX_CTL1 also controls DMA, but RTNL serializes the ethtool update with open, close and reset. System suspend freezes userspace before stopping DMA, and the sun8i interrupt handler does not change the RX threshold. The setter can therefore update the register directly. Keep error forwarding enabled in both modes for RX checksum handling. Signed-off-by: James Hilliard --- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c index 379108e3da32..a008ce1f7882 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c @@ -198,6 +198,7 @@ static const struct emac_variant emac_variant_h616_emac1 = { /* Used in RX_CTL1*/ #define EMAC_RX_MD BIT(1) +#define EMAC_RX_RUNT_FRM BIT(2) #define EMAC_RX_ERR_FRM BIT(3) #define EMAC_RX_TH_MASK GENMASK(5, 4) #define EMAC_RX_TH_32 0 @@ -648,7 +649,21 @@ static void sun8i_dwmac_core_init(struct mac_device_info *hw, writel(v, ioaddr + EMAC_BASIC_CTL1); /* Forward checksum failures to software before starting RX. */ - writel(EMAC_RX_ERR_FRM, ioaddr + EMAC_RX_CTL1); + v = EMAC_RX_ERR_FRM; + if (dev->features & NETIF_F_RXALL) + v |= EMAC_RX_RUNT_FRM; + writel(v, ioaddr + EMAC_RX_CTL1); +} + +static void sun8i_dwmac_set_rx_all(struct stmmac_priv *priv, bool enable) +{ + u32 v = readl(priv->ioaddr + EMAC_RX_CTL1); + + if (enable) + v |= EMAC_RX_RUNT_FRM; + else + v &= ~EMAC_RX_RUNT_FRM; + writel(v, priv->ioaddr + EMAC_RX_CTL1); } static void sun8i_dwmac_set_mac(void __iomem *ioaddr, bool enable) @@ -1053,6 +1068,7 @@ static const struct stmmac_ops sun8i_dwmac_ops = { .dump_regs = sun8i_dwmac_dump_mac_regs, .rx_ipc = sun8i_dwmac_rx_ipc, .set_filter = sun8i_dwmac_set_filter, + .set_rx_all = sun8i_dwmac_set_rx_all, .flow_ctrl = sun8i_dwmac_flow_ctrl, .set_umac_addr = sun8i_dwmac_set_umac_addr, .get_umac_addr = sun8i_dwmac_get_umac_addr, @@ -1126,7 +1142,7 @@ static int sun8i_dwmac_rx_status(struct stmmac_extra_stats *x, struct dma_desc * if (unlikely(runt || (status & wire_errors))) { if (runt && !(status & RDES0_LENGTH_ERROR)) x->rx_length++; - return discard_frame; + return rx_error_frame | csum_none; } /* Only a checked IP frame is eligible for CHECKSUM_UNNECESSARY. */ -- 2.53.0