gianfar: Only process completed frames
authorAndy Fleming <afleming@freescale.com>
Mon, 24 Mar 2008 15:53:27 +0000 (10:53 -0500)
committerJeff Garzik <jeff@garzik.org>
Wed, 26 Mar 2008 04:44:39 +0000 (00:44 -0400)
If the LAST bit is not set in the RxBD, it's possible we're processing
an incomplete frame, which is bad.  While we're at it, add a constant
for the error bitmask, so the whole if-clause fits on one line,
and is more legible.

Signed-off-by: Dai Haruki <dai.haruki@freescale.com>
Signed-off-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/net/gianfar.c
drivers/net/gianfar.h

index 0ab4b26c79a569b933b1e0d31562b7a0b0301640..a59edf7eacdccc44ad025801770525e8454dcc78 100644 (file)
@@ -1526,9 +1526,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
                rmb();
                skb = priv->rx_skbuff[priv->skb_currx];
 
-               if (!(bdp->status &
-                     (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET
-                      | RXBD_CRCERR | RXBD_OVERRUN | RXBD_TRUNCATED))) {
+               if ((bdp->status & RXBD_LAST) && !(bdp->status & RXBD_ERR)) {
                        /* Increment the number of packets */
                        dev->stats.rx_packets++;
                        howmany++;
index 5b8991d822fca5e7e8f1e80154b4e76795f0627a..fcfa1bd57280988f4879f55b4acfbfc6d0900fd7 100644 (file)
@@ -340,6 +340,9 @@ extern const char gfar_driver_version[];
 #define RXBD_OVERRUN           0x0002
 #define RXBD_TRUNCATED         0x0001
 #define RXBD_STATS             0x01ff
+#define RXBD_ERR               (RXBD_LARGE | RXBD_SHORT | RXBD_NONOCTET        \
+                               | RXBD_CRCERR | RXBD_OVERRUN                    \
+                               | RXBD_TRUNCATED)
 
 /* Rx FCB status field bits */
 #define RXFCB_VLN              0x8000