]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
staging: octeon: Drop on uncorrectable alignment or FCS error
authorAlexander Sverdlin <alexander.sverdlin@nokia.com>
Fri, 16 Oct 2020 14:56:30 +0000 (16:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:07:06 +0000 (11:07 +0100)
commit 49d28ebdf1e30d806410eefc7de0a7a1ca5d747c upstream.

Currently in case of alignment or FCS error if the packet cannot be
corrected it's still not dropped. Report the error properly and drop the
packet while making the code around a little bit more readable.

Fixes: 80ff0fd3ab64 ("Staging: Add octeon-ethernet driver files.")
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20201016145630.41852-1-alexander.sverdlin@nokia.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/octeon/ethernet-rx.c

index 1a44291318ee8d49d35cac6f328c93b8324afe0f..c5a8348c1df07decaeb253fc5759b15894549b60 100644 (file)
@@ -83,15 +83,17 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
        else
                port = work->word1.cn38xx.ipprt;
 
-       if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64)) {
+       if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64))
                /*
                 * Ignore length errors on min size packets. Some
                 * equipment incorrectly pads packets to 64+4FCS
                 * instead of 60+4FCS.  Note these packets still get
                 * counted as frame errors.
                 */
-       } else if (work->word2.snoip.err_code == 5 ||
-                  work->word2.snoip.err_code == 7) {
+               return 0;
+
+       if (work->word2.snoip.err_code == 5 ||
+           work->word2.snoip.err_code == 7) {
                /*
                 * We received a packet with either an alignment error
                 * or a FCS error. This may be signalling that we are
@@ -122,7 +124,10 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
                                /* Port received 0xd5 preamble */
                                work->packet_ptr.s.addr += i + 1;
                                work->word1.len -= i + 5;
-                       } else if ((*ptr & 0xf) == 0xd) {
+                               return 0;
+                       }
+
+                       if ((*ptr & 0xf) == 0xd) {
                                /* Port received 0xd preamble */
                                work->packet_ptr.s.addr += i;
                                work->word1.len -= i + 4;
@@ -132,21 +137,20 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
                                            ((*(ptr + 1) & 0xf) << 4);
                                        ptr++;
                                }
-                       } else {
-                               printk_ratelimited("Port %d unknown preamble, packet dropped\n",
-                                                  port);
-                               cvm_oct_free_work(work);
-                               return 1;
+                               return 0;
                        }
+
+                       printk_ratelimited("Port %d unknown preamble, packet dropped\n",
+                                          port);
+                       cvm_oct_free_work(work);
+                       return 1;
                }
-       } else {
-               printk_ratelimited("Port %d receive error code %d, packet dropped\n",
-                                  port, work->word2.snoip.err_code);
-               cvm_oct_free_work(work);
-               return 1;
        }
 
-       return 0;
+       printk_ratelimited("Port %d receive error code %d, packet dropped\n",
+                          port, work->word2.snoip.err_code);
+       cvm_oct_free_work(work);
+       return 1;
 }
 
 static void copy_segments_to_skb(cvmx_wqe_t *work, struct sk_buff *skb)