Re: [PATCH net-next v0] net: mvpp2: Add parser configuration for DSA tags

From: Maxime Chevallier
Date: Thu Oct 10 2024 - 10:25:13 EST


Hello,

On Thu, 10 Oct 2024 14:51:04 +1300
Aryan Srivastava <aryan.srivastava@xxxxxxxxxxxxxxxxxxx> wrote:

> Allow the header parser to consider DSA and EDSA tagging. Currently the
> parser is always configured to use the MH tag, but this results in poor
> traffic distribution across queues and sub-optimal performance (in the
> case where DSA or EDSA tags are in the header).
>
> Add mechanism to check for tag type in use and then configure the
> parser correctly for this tag. This results in proper traffic
> distribution and hash calculation.
>
> Signed-off-by: Aryan Srivastava <aryan.srivastava@xxxxxxxxxxxxxxxxxxx>

[...]

> static int mvpp2_open(struct net_device *dev)
> {
> struct mvpp2_port *port = netdev_priv(dev);
> @@ -4801,7 +4832,11 @@ static int mvpp2_open(struct net_device *dev)
> netdev_err(dev, "mvpp2_prs_mac_da_accept own addr failed\n");
> return err;
> }
> - err = mvpp2_prs_tag_mode_set(port->priv, port->id, MVPP2_TAG_TYPE_MH);
> +
> + if (netdev_uses_dsa(dev))
> + err = mvpp2_prs_tag_mode_set(port->priv, port->id, mvpp2_get_tag(dev));
> + else
> + err = mvpp2_prs_tag_mode_set(port->priv, port->id, MVPP2_TAG_TYPE_MH);

This could unfortunately break VLAN filtering. If you look at the code
for mvpp2_prs_vid_entry_add() and mvpp2_prs_vid_enable_filtering(), the
value of the tag type set in MVPP2_MH_REG is used to compute the offset
at which the VLAN tag will be located.

It might be possible that users would :

- Enable vlan filtering with :

ethtool -K ethX rx-vlan-filter on

- Add vlan interfaces with :

ip link add link ethX name ethX.Y type vlan id Y

- Set the interface up

ip link set ethX up => triggers a change in the DSA header size register

In that situation, the offset for the VLAN interface ethX.Y's header
will be incorrect, if the DSA tag type gets updated at .open() time.

So I think a solution would be to replace the read from the
MVPP2_MH_REG in the vlan filtering functions with a call your
newly-introduced mvpp2_get_tag, making sure that we use the correct tag
length for these parser entries as well.

Thanks,

Maxime