diff mbox series

stating: octeon: Drop on uncorrectable alignment or FCS error

Message ID 20201009094605.1525-2-alexander.sverdlin@nokia.com
State New
Headers show
Series stating: octeon: Drop on uncorrectable alignment or FCS error | expand

Commit Message

Alexander A Sverdlin Oct. 9, 2020, 9:46 a.m. UTC
From: Alexander Sverdlin <alexander.sverdlin@nokia.com>

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.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Fixes: 80ff0fd3ab ("Staging: Add octeon-ethernet driver files.")

Change-Id: Ie1fadcc57cb5e221cf3e83c169b53a5533b8edff
---
 drivers/staging/octeon/ethernet-rx.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Dan Carpenter Oct. 9, 2020, 12:24 p.m. UTC | #1
On Fri, Oct 09, 2020 at 11:46:05AM +0200, Alexander A Sverdlin wrote:
> --- a/drivers/staging/octeon/ethernet-rx.c
> +++ b/drivers/staging/octeon/ethernet-rx.c
> @@ -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) {

This line is indented to match the old code and it no longer matches.
(Please update the whitespace).

>  		/*
>  		 * We received a packet with either an alignment error

regards,
dan carpenter
Alexander A Sverdlin Oct. 12, 2020, 12:23 p.m. UTC | #2
Hello Dan,

On 09/10/2020 14:24, Dan Carpenter wrote:
> On Fri, Oct 09, 2020 at 11:46:05AM +0200, Alexander A Sverdlin wrote:
>> --- a/drivers/staging/octeon/ethernet-rx.c
>> +++ b/drivers/staging/octeon/ethernet-rx.c
>> @@ -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) {
> This line is indented to match the old code and it no longer matches.
> (Please update the whitespace).

thanks to your comment I took a fresh look onto the patch and found a logic error
in the change. Please ignore the whole patch for now.
 
>>  		/*
>>  		 * We received a packet with either an alignment error
diff mbox series

Patch

diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
index 2c16230..b22f7be 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -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
@@ -125,14 +127,12 @@  static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *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(struct cvmx_wqe *work, struct sk_buff *skb)