netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Troy Kisky <troy.kisky@boundarydevices.com>
To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com
Cc: fabio.estevam@freescale.com, l.stach@pengutronix.de,
	andrew@lunn.ch, tremyfr@gmail.com, linux@arm.linux.org.uk,
	linux-arm-kernel@lists.infradead.org, laci@boundarydevices.com,
	shawnguo@kernel.org, johannes@sipsolutions.net, arnd@arndb.de,
	Troy Kisky <troy.kisky@boundarydevices.com>
Subject: [PATCH net-next V2 2/8] net: fec: fix rx error counts
Date: Fri,  5 Feb 2016 14:52:44 -0700	[thread overview]
Message-ID: <1454709170-19527-3-git-send-email-troy.kisky@boundarydevices.com> (raw)
In-Reply-To: <1454709170-19527-1-git-send-email-troy.kisky@boundarydevices.com>

On an overrun, the other flags are not
valid, so don't check them.

Also, don't pass bad frames up the stack.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 36 +++++++++++++------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 3e5b24a..162fa59 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1408,37 +1408,31 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
 			break;
 		pkt_received++;
 
-		/* Since we have allocated space to hold a complete frame,
-		 * the last indicator should be set.
-		 */
-		if ((status & BD_ENET_RX_LAST) == 0)
-			netdev_err(ndev, "rcv is not +last\n");
-
 		writel(FEC_ENET_RXF, fep->hwp + FEC_IEVENT);
 
 		/* Check for errors. */
+		status ^= BD_ENET_RX_LAST;
 		if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO |
-			   BD_ENET_RX_CR | BD_ENET_RX_OV)) {
+			   BD_ENET_RX_CR | BD_ENET_RX_OV | BD_ENET_RX_LAST |
+			   BD_ENET_RX_CL)) {
 			ndev->stats.rx_errors++;
-			if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) {
+			if (status & BD_ENET_RX_OV) {
+				/* FIFO overrun */
+				ndev->stats.rx_fifo_errors++;
+				goto rx_processing_done;
+			}
+			if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH
+						| BD_ENET_RX_LAST)) {
 				/* Frame too long or too short. */
 				ndev->stats.rx_length_errors++;
+				if (status & BD_ENET_RX_LAST)
+					netdev_err(ndev, "rcv is not +last\n");
 			}
-			if (status & BD_ENET_RX_NO)	/* Frame alignment */
-				ndev->stats.rx_frame_errors++;
 			if (status & BD_ENET_RX_CR)	/* CRC Error */
 				ndev->stats.rx_crc_errors++;
-			if (status & BD_ENET_RX_OV)	/* FIFO overrun */
-				ndev->stats.rx_fifo_errors++;
-		}
-
-		/* Report late collisions as a frame error.
-		 * On this error, the BD is closed, but we don't know what we
-		 * have in the buffer.  So, just drop this frame on the floor.
-		 */
-		if (status & BD_ENET_RX_CL) {
-			ndev->stats.rx_errors++;
-			ndev->stats.rx_frame_errors++;
+			/* Report late collisions as a frame error. */
+			if (status & (BD_ENET_RX_NO | BD_ENET_RX_CL))
+				ndev->stats.rx_frame_errors++;
 			goto rx_processing_done;
 		}
 
-- 
2.5.0

  parent reply	other threads:[~2016-02-05 21:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05 21:52 [PATCH net-next V2 0/8] net: fec: cleanup/fixes Troy Kisky
2016-02-05 21:52 ` [PATCH net-next V2 1/8] net: fec: stop the "rcv is not +last, " error messages Troy Kisky
2016-02-05 21:52 ` Troy Kisky [this message]
2016-02-05 21:52 ` [PATCH net-next V2 3/8] net: fec: fix fec_enet_get_free_txdesc_num Troy Kisky
2016-02-05 21:52 ` [PATCH net-next V2 4/8] net: fec: add struct bufdesc_prop Troy Kisky
2016-02-05 21:52 ` [PATCH net-next V2 5/8] net: fec: add variable reg_desc_active to speed things up Troy Kisky
2016-02-05 21:52 ` [PATCH net-next V2 6/8] net: fec: don't disable FEC_ENET_TS_TIMER interrupt Troy Kisky
2016-02-05 21:52 ` [PATCH net-next V2 7/8] net: fec: don't transfer ownership until descriptor write is complete Troy Kisky
2016-02-06  1:03   ` Joshua Clayton
2016-02-24 20:38     ` Troy Kisky
2016-02-06 11:52   ` Sergei Shtylyov
2016-02-24 20:39     ` Troy Kisky
2016-02-05 21:52 ` [PATCH net-next V2 8/8] net: fec: improve error handling Troy Kisky
2016-02-11 11:15 ` [PATCH net-next V2 0/8] net: fec: cleanup/fixes David Miller

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=1454709170-19527-3-git-send-email-troy.kisky@boundarydevices.com \
    --to=troy.kisky@boundarydevices.com \
    --cc=B38611@freescale.com \
    --cc=andrew@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=fabio.estevam@freescale.com \
    --cc=johannes@sipsolutions.net \
    --cc=l.stach@pengutronix.de \
    --cc=laci@boundarydevices.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux@arm.linux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=tremyfr@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).