mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
net: dsa: sja1105: Use correct dsa_8021q VIDs for FDB commands
A FDB entry means that "frames that match this VID and DMAC must be
forwarded to this port".
In the case of dsa_8021q however, the VID is not a single one (and
neither two, as my previous patch assumed). The VID can be set either by
the CPU port (1 tx_vid), or by any of the other front-panel port (n-1
rx_vid's).
Fixes: 93647594d8
("net: dsa: sja1105: Hide the dsa_8021q VLANs from the bridge fdb command")
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
17ae655540
commit
b3ee526a88
@ -1126,44 +1126,60 @@ static int sja1105_fdb_add(struct dsa_switch *ds, int port,
|
|||||||
const unsigned char *addr, u16 vid)
|
const unsigned char *addr, u16 vid)
|
||||||
{
|
{
|
||||||
struct sja1105_private *priv = ds->priv;
|
struct sja1105_private *priv = ds->priv;
|
||||||
int rc;
|
u16 rx_vid, tx_vid;
|
||||||
|
int rc, i;
|
||||||
|
|
||||||
|
if (dsa_port_is_vlan_filtering(&ds->ports[port]))
|
||||||
|
return priv->info->fdb_add_cmd(ds, port, addr, vid);
|
||||||
|
|
||||||
/* Since we make use of VLANs even when the bridge core doesn't tell us
|
/* Since we make use of VLANs even when the bridge core doesn't tell us
|
||||||
* to, translate these FDB entries into the correct dsa_8021q ones.
|
* to, translate these FDB entries into the correct dsa_8021q ones.
|
||||||
|
* The basic idea (also repeats for removal below) is:
|
||||||
|
* - Each of the other front-panel ports needs to be able to forward a
|
||||||
|
* pvid-tagged (aka tagged with their rx_vid) frame that matches this
|
||||||
|
* DMAC.
|
||||||
|
* - The CPU port (aka the tx_vid of this port) needs to be able to
|
||||||
|
* send a frame matching this DMAC to the specified port.
|
||||||
|
* For a better picture see net/dsa/tag_8021q.c.
|
||||||
*/
|
*/
|
||||||
if (!dsa_port_is_vlan_filtering(&ds->ports[port])) {
|
for (i = 0; i < SJA1105_NUM_PORTS; i++) {
|
||||||
unsigned int upstream = dsa_upstream_port(priv->ds, port);
|
if (i == port)
|
||||||
u16 tx_vid = dsa_8021q_tx_vid(ds, port);
|
continue;
|
||||||
u16 rx_vid = dsa_8021q_rx_vid(ds, port);
|
if (i == dsa_upstream_port(priv->ds, port))
|
||||||
|
continue;
|
||||||
|
|
||||||
rc = priv->info->fdb_add_cmd(ds, port, addr, tx_vid);
|
rx_vid = dsa_8021q_rx_vid(ds, i);
|
||||||
|
rc = priv->info->fdb_add_cmd(ds, port, addr, rx_vid);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
return rc;
|
||||||
return priv->info->fdb_add_cmd(ds, upstream, addr, rx_vid);
|
|
||||||
}
|
}
|
||||||
return priv->info->fdb_add_cmd(ds, port, addr, vid);
|
tx_vid = dsa_8021q_tx_vid(ds, port);
|
||||||
|
return priv->info->fdb_add_cmd(ds, port, addr, tx_vid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sja1105_fdb_del(struct dsa_switch *ds, int port,
|
static int sja1105_fdb_del(struct dsa_switch *ds, int port,
|
||||||
const unsigned char *addr, u16 vid)
|
const unsigned char *addr, u16 vid)
|
||||||
{
|
{
|
||||||
struct sja1105_private *priv = ds->priv;
|
struct sja1105_private *priv = ds->priv;
|
||||||
int rc;
|
u16 rx_vid, tx_vid;
|
||||||
|
int rc, i;
|
||||||
|
|
||||||
/* Since we make use of VLANs even when the bridge core doesn't tell us
|
if (dsa_port_is_vlan_filtering(&ds->ports[port]))
|
||||||
* to, translate these FDB entries into the correct dsa_8021q ones.
|
return priv->info->fdb_del_cmd(ds, port, addr, vid);
|
||||||
*/
|
|
||||||
if (!dsa_port_is_vlan_filtering(&ds->ports[port])) {
|
|
||||||
unsigned int upstream = dsa_upstream_port(priv->ds, port);
|
|
||||||
u16 tx_vid = dsa_8021q_tx_vid(ds, port);
|
|
||||||
u16 rx_vid = dsa_8021q_rx_vid(ds, port);
|
|
||||||
|
|
||||||
rc = priv->info->fdb_del_cmd(ds, port, addr, tx_vid);
|
for (i = 0; i < SJA1105_NUM_PORTS; i++) {
|
||||||
|
if (i == port)
|
||||||
|
continue;
|
||||||
|
if (i == dsa_upstream_port(priv->ds, port))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
rx_vid = dsa_8021q_rx_vid(ds, i);
|
||||||
|
rc = priv->info->fdb_del_cmd(ds, port, addr, rx_vid);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return rc;
|
return rc;
|
||||||
return priv->info->fdb_del_cmd(ds, upstream, addr, rx_vid);
|
|
||||||
}
|
}
|
||||||
return priv->info->fdb_del_cmd(ds, port, addr, vid);
|
tx_vid = dsa_8021q_tx_vid(ds, port);
|
||||||
|
return priv->info->fdb_del_cmd(ds, port, addr, tx_vid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sja1105_fdb_dump(struct dsa_switch *ds, int port,
|
static int sja1105_fdb_dump(struct dsa_switch *ds, int port,
|
||||||
@ -1171,8 +1187,12 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port,
|
|||||||
{
|
{
|
||||||
struct sja1105_private *priv = ds->priv;
|
struct sja1105_private *priv = ds->priv;
|
||||||
struct device *dev = ds->dev;
|
struct device *dev = ds->dev;
|
||||||
|
u16 rx_vid, tx_vid;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
rx_vid = dsa_8021q_rx_vid(ds, port);
|
||||||
|
tx_vid = dsa_8021q_tx_vid(ds, port);
|
||||||
|
|
||||||
for (i = 0; i < SJA1105_MAX_L2_LOOKUP_COUNT; i++) {
|
for (i = 0; i < SJA1105_MAX_L2_LOOKUP_COUNT; i++) {
|
||||||
struct sja1105_l2_lookup_entry l2_lookup = {0};
|
struct sja1105_l2_lookup_entry l2_lookup = {0};
|
||||||
u8 macaddr[ETH_ALEN];
|
u8 macaddr[ETH_ALEN];
|
||||||
@ -1198,14 +1218,24 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port,
|
|||||||
continue;
|
continue;
|
||||||
u64_to_ether_addr(l2_lookup.macaddr, macaddr);
|
u64_to_ether_addr(l2_lookup.macaddr, macaddr);
|
||||||
|
|
||||||
/* We need to hide the dsa_8021q VLAN from the user.
|
/* We need to hide the dsa_8021q VLANs from the user. This
|
||||||
* Convert the TX VID into the pvid that is active in
|
* basically means hiding the duplicates and only showing
|
||||||
* standalone and non-vlan_filtering modes, aka 1.
|
* the pvid that is supposed to be active in standalone and
|
||||||
* The RX VID is applied on the CPU port, which is not seen by
|
* non-vlan_filtering modes (aka 1).
|
||||||
* the bridge core anyway, so there's nothing to hide.
|
* - For statically added FDB entries (bridge fdb add), we
|
||||||
|
* can convert the TX VID (coming from the CPU port) into the
|
||||||
|
* pvid and ignore the RX VIDs of the other ports.
|
||||||
|
* - For dynamically learned FDB entries, a single entry with
|
||||||
|
* no duplicates is learned - that which has the real port's
|
||||||
|
* pvid, aka RX VID.
|
||||||
*/
|
*/
|
||||||
if (!dsa_port_is_vlan_filtering(&ds->ports[port]))
|
if (!dsa_port_is_vlan_filtering(&ds->ports[port])) {
|
||||||
l2_lookup.vlanid = 1;
|
if (l2_lookup.vlanid == tx_vid ||
|
||||||
|
l2_lookup.vlanid == rx_vid)
|
||||||
|
l2_lookup.vlanid = 1;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
cb(macaddr, l2_lookup.vlanid, l2_lookup.lockeds, data);
|
cb(macaddr, l2_lookup.vlanid, l2_lookup.lockeds, data);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user