# Re: \[PATCH v2 net-next 02/12\] net: mscc: ocelot: only drain extraction queue on error

- From: Florian Fainelli \<f.fainelli@gmail.com\>
- Date: 2021-02-14 01:20:45 
- List: netdev
- Page: https://ratatoskr.run/netdev/2021/02/11196785
- Thread: https://ratatoskr.run/netdev/2021/02/11196765/t.md

```text


On 2/13/2021 14:37, Vladimir Oltean wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> 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>
-- 
Florian
```
