From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ian Abbott <abbotti@mev.co.uk>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] net: designware: drop bad RX frames
Date: Tue, 5 Feb 2019 12:44:52 +0100 [thread overview]
Message-ID: <20190205114452.c22umd6nx3zqrjjk@pengutronix.de> (raw)
In-Reply-To: <20190201125948.15480-1-abbotti@mev.co.uk>
On Fri, Feb 01, 2019 at 12:59:48PM +0000, Ian Abbott wrote:
> In dwc_ether_rx(), check the RX descriptor status for various error
> conditions. On error, issue a warning with the error status bits and
> drop the received frame.
>
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> ---
> drivers/net/designware.c | 42 +++++++++++++++++++++++++++++++---------
> 1 file changed, 33 insertions(+), 9 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/net/designware.c b/drivers/net/designware.c
> index ad70967e8..21134cd5a 100644
> --- a/drivers/net/designware.c
> +++ b/drivers/net/designware.c
> @@ -326,24 +326,48 @@ static int dwc_ether_rx(struct eth_device *dev)
>
> u32 status = desc_p->txrx_status;
> int length = 0;
> + int ret = 0;
>
> /* Check if the owner is the CPU */
> if (status & DESC_RXSTS_OWNBYDMA)
> return 0;
>
> - length = (status & DESC_RXSTS_FRMLENMSK) >>
> - DESC_RXSTS_FRMLENSHFT;
> + if ((status & (DESC_RXSTS_ERROR | DESC_RXSTS_DAFILTERFAIL |
> + DESC_RXSTS_SAFILTERFAIL)) ||
> + (status & (DESC_RXSTS_RXIPC_GIANTFRAME |
> + DESC_RXSTS_RXFRAMEETHER)) ==
> + DESC_RXSTS_RXIPC_GIANTFRAME) {
> + /* Error in packet - discard it */
> + dev_warn(&dev->dev, "Rx error status (%x)\n",
> + status & (DESC_RXSTS_DAFILTERFAIL |
> + DESC_RXSTS_ERROR |
> + DESC_RXSTS_RXTRUNCATED |
> + DESC_RXSTS_SAFILTERFAIL |
> + DESC_RXSTS_RXIPC_GIANTFRAME |
> + DESC_RXSTS_RXDAMAGED |
> + DESC_RXSTS_RXIPC_GIANT |
> + DESC_RXSTS_RXCOLLISION |
> + DESC_RXSTS_RXFRAMEETHER |
> + DESC_RXSTS_RXWATCHDOG |
> + DESC_RXSTS_RXMIIERROR |
> + DESC_RXSTS_RXCRC));
> + ret = -EIO;
> + } else {
> + length = (status & DESC_RXSTS_FRMLENMSK) >>
> + DESC_RXSTS_FRMLENSHFT;
> +
> + dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr,
> + length, DMA_FROM_DEVICE);
> + net_receive(dev, desc_p->dmamac_addr, length);
> + dma_sync_single_for_device((unsigned long)desc_p->dmamac_addr,
> + length, DMA_FROM_DEVICE);
> + ret = length;
> + }
>
> /*
> * Make the current descriptor valid again and go to
> * the next one
> */
> - dma_sync_single_for_cpu((unsigned long)desc_p->dmamac_addr, length,
> - DMA_FROM_DEVICE);
> - net_receive(dev, desc_p->dmamac_addr, length);
> - dma_sync_single_for_device((unsigned long)desc_p->dmamac_addr, length,
> - DMA_FROM_DEVICE);
> -
> desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
>
> /* Test the wrap-around condition. */
> @@ -352,7 +376,7 @@ static int dwc_ether_rx(struct eth_device *dev)
>
> priv->rx_currdescnum = desc_num;
>
> - return length;
> + return ret;
> }
>
> static void dwc_ether_halt (struct eth_device *dev)
> --
> 2.20.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2019-02-05 11:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-01 12:59 Ian Abbott
2019-02-05 11:44 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190205114452.c22umd6nx3zqrjjk@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=abbotti@mev.co.uk \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox