Re: [PATCH net-next v3 1/2] net: dsa: tag_rtl8_4: add rtl8_4t trailing variant

Vladimir Oltean
2022-02-24T00:04:29Z

On Tue, Feb 22, 2022 at 07:47:57PM -0300, Luiz Angelo Daros de Luca wrote:
> diff --git a/net/dsa/tag_rtl8_4.c b/net/dsa/tag_rtl8_4.c
> index 02686ad4045d..2e81ab49d928 100644
> --- a/net/dsa/tag_rtl8_4.c
> +++ b/net/dsa/tag_rtl8_4.c
> @@ -9,11 +9,6 @@
> *
> * This tag header has the following format:
> *
> - * -------------------------------------------
> - * | MAC DA | MAC SA | 8 byte tag | Type | ...
> - * -------------------------------------------
> - * _______________/ \______________________________________
> - * / \
> * 0 7|8 15
> * |-----------------------------------+-----------------------------------|---
> * | (16-bit) | ^
> @@ -58,6 +53,28 @@
> * TX/RX | TX (switch->CPU): port number the packet was received on
> * | RX (CPU->switch): forwarding port mask (if ALLOW=0)
> * | allowance port mask (if ALLOW=1)
> + *
> + * The tag can be positioned before Ethertype, using tag "rtl8_4":
> + *
> + * +--------+--------+------------+------+-----
> + * | MAC DA | MAC SA | 8 byte tag | Type | ...
> + * +--------+--------+------------+------+-----
> + *
> + * If checksum offload is enabled for CPU port device, it might break if the
> + * driver does not use csum_start/csum_offset.

Please. This is true of any DSA header. If you feel you have something
to add on this topic please do so in Documentation/networking/dsa/dsa.rst
under "Switch tagging protocols".

Also, s/CPU port device/DSA master/.

> + *
> + * The tag can also appear between the end of the payload and before the CRC,
> + * using tag "rtl8_4t":
> + *
> + * +--------+--------+------+-----+---------+------------+-----+
> + * | MAC DA | MAC SA | TYPE | ... | payload | 8-byte tag | CRC |
> + * +--------+--------+------+-----+---------+------------+-----+
> + *
> + * The added bytes after the payload will break most checksums, either in
> + * software or hardware. To avoid this issue, if the checksum is still pending,
> + * this tagger checksum the packet before adding the tag, rendering any

s/checksum/checksums/

> + * checksum offload useless.

If you're adding a tail tagging driver to work around checksum offload
issues, this solution is about as bad as it gets. You're literally not
gaining anything in performance over fixing your DSA master driver to
turn off checksum offloading for unrecognized DSA tagging protocols.
And on top of that, you're requiring your users to be aware of this
issue and make changes to their configuration, for something that can be
done automatically.

Do you have another use case as well?