Skip to content

Commit 6ce4da8

Browse files
asverdlingregkh
authored andcommitted
staging: octeon: Drop on uncorrectable alignment or FCS error
commit 49d28eb 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: 80ff0fd ("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>
1 parent b869f6b commit 6ce4da8

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

drivers/staging/octeon/ethernet-rx.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,17 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
6969
else
7070
port = work->word1.cn38xx.ipprt;
7171

72-
if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64)) {
72+
if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64))
7373
/*
7474
* Ignore length errors on min size packets. Some
7575
* equipment incorrectly pads packets to 64+4FCS
7676
* instead of 60+4FCS. Note these packets still get
7777
* counted as frame errors.
7878
*/
79-
} else if (work->word2.snoip.err_code == 5 ||
80-
work->word2.snoip.err_code == 7) {
79+
return 0;
80+
81+
if (work->word2.snoip.err_code == 5 ||
82+
work->word2.snoip.err_code == 7) {
8183
/*
8284
* We received a packet with either an alignment error
8385
* or a FCS error. This may be signalling that we are
@@ -108,7 +110,10 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
108110
/* Port received 0xd5 preamble */
109111
work->packet_ptr.s.addr += i + 1;
110112
work->word1.len -= i + 5;
111-
} else if ((*ptr & 0xf) == 0xd) {
113+
return 0;
114+
}
115+
116+
if ((*ptr & 0xf) == 0xd) {
112117
/* Port received 0xd preamble */
113118
work->packet_ptr.s.addr += i;
114119
work->word1.len -= i + 4;
@@ -118,21 +123,20 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
118123
((*(ptr + 1) & 0xf) << 4);
119124
ptr++;
120125
}
121-
} else {
122-
printk_ratelimited("Port %d unknown preamble, packet dropped\n",
123-
port);
124-
cvm_oct_free_work(work);
125-
return 1;
126+
return 0;
126127
}
128+
129+
printk_ratelimited("Port %d unknown preamble, packet dropped\n",
130+
port);
131+
cvm_oct_free_work(work);
132+
return 1;
127133
}
128-
} else {
129-
printk_ratelimited("Port %d receive error code %d, packet dropped\n",
130-
port, work->word2.snoip.err_code);
131-
cvm_oct_free_work(work);
132-
return 1;
133134
}
134135

135-
return 0;
136+
printk_ratelimited("Port %d receive error code %d, packet dropped\n",
137+
port, work->word2.snoip.err_code);
138+
cvm_oct_free_work(work);
139+
return 1;
136140
}
137141

138142
static void copy_segments_to_skb(cvmx_wqe_t *work, struct sk_buff *skb)

0 commit comments

Comments
 (0)