net: dsa: sja1105: fix VL lookup command packing for P/Q/R/S
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 24 May 2021 09:25:22 +0000 (12:25 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Jun 2021 07:00:38 +0000 (09:00 +0200)
commit935c9443f81c89dce04683c73d0f136d2d89351c
tree58797eb05edbb25e8adc12d87c48c7451879f9e8
parent83999bf40c78ec344b7c1066dc50f21ac2519bdf
net: dsa: sja1105: fix VL lookup command packing for P/Q/R/S

commit ba61cf167cb77e54c1ec5adb7aa49a22ab3c9b28 upstream.

At the beginning of the sja1105_dynamic_config.c file there is a diagram
of the dynamic config interface layout:

 packed_buf

 |
 V
 +-----------------------------------------+------------------+
 |              ENTRY BUFFER               |  COMMAND BUFFER  |
 +-----------------------------------------+------------------+

 <----------------------- packed_size ------------------------>

So in order to pack/unpack the command bits into the buffer,
sja1105_vl_lookup_cmd_packing must first advance the buffer pointer by
the length of the entry. This is similar to what the other *cmd_packing
functions do.

This bug exists because the command packing function for P/Q/R/S was
copied from the E/T generation, and on E/T, the command was actually
embedded within the entry buffer itself.

Fixes: 94f94d4acfb2 ("net: dsa: sja1105: add static tables for virtual links")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/dsa/sja1105/sja1105_dynamic_config.c