OSDN Git Service

net: mscc: ocelot: only drain extraction queue on error
authorVladimir Oltean <vladimir.oltean@nxp.com>
Sat, 13 Feb 2021 22:37:51 +0000 (00:37 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 15 Feb 2021 01:31:43 +0000 (17:31 -0800)
commitd7795f8f26d944ede937d750b1804c080edf86c3
tree9ae76b5278946ea88728b0e2900daf6c5e835fd5
parentf833ca293dd121fcc393b01b5f20364bd39a08c5
net: mscc: ocelot: only drain extraction queue on error

It appears that the intention of this snippet of code is to not exit
ocelot_xtr_irq_handler() while in the middle of extracting a frame.
The problem in extracting it word by word is that future extraction
attempts are really easy to get desynchronized, since the IRQ handler
assumes that the first 16 bytes are the IFH, which give further
information about the frame, such as frame length.

But during normal operation, "err" will not be 0, but 4, set from here:

for (i = 0; i < OCELOT_TAG_LEN / 4; i++) {
err = ocelot_rx_frame_word(ocelot, grp, true, &ifh[i]);
if (err != 4)
break;
}

if (err != 4)
break;

In that case, draining the extraction queue is a no-op. So explicitly
make this code execute only on negative err.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mscc/ocelot_vsc7514.c