Commit 49d28ebd authored by Alexander Sverdlin's avatar Alexander Sverdlin Committed by Greg Kroah-Hartman
Browse files

staging: octeon: Drop on uncorrectable alignment or FCS error



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: 80ff0fd3 ("Staging: Add octeon-ethernet driver files.")
Signed-off-by: default avatarAlexander 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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 179f5dc3
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -69,14 +69,16 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *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 ||
		return 0;

	if (work->word2.snoip.err_code == 5 ||
	    work->word2.snoip.err_code == 7) {
		/*
		 * We received a packet with either an alignment error
@@ -108,7 +110,10 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *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;
@@ -118,23 +123,22 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *work)
					    ((*(ptr + 1) & 0xf) << 4);
					ptr++;
				}
			} else {
				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;
}

static void copy_segments_to_skb(struct cvmx_wqe *work, struct sk_buff *skb)
{
	int segments = work->word2.s.bufs;