net: dsa: hide dp->bridge_dev and dp->bridge_num in drivers behind helpers
The location of the bridge device pointer and number is going to change. It is not going to be kept individually per port, but in a common structure allocated dynamically and which will have lockdep validation. Use the helpers to access these elements so that we have a migration path to the new organization. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
36cbf39b56
commit
41fb0cf1bc
@ -1887,7 +1887,7 @@ int b53_br_join(struct dsa_switch *ds, int port, struct net_device *br)
|
|||||||
b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan);
|
b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), &pvlan);
|
||||||
|
|
||||||
b53_for_each_port(dev, i) {
|
b53_for_each_port(dev, i) {
|
||||||
if (dsa_to_port(ds, i)->bridge_dev != br)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) != br)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Add this local port to the remote port VLAN control
|
/* Add this local port to the remote port VLAN control
|
||||||
@ -1923,7 +1923,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br)
|
|||||||
|
|
||||||
b53_for_each_port(dev, i) {
|
b53_for_each_port(dev, i) {
|
||||||
/* Don't touch the remaining ports */
|
/* Don't touch the remaining ports */
|
||||||
if (dsa_to_port(ds, i)->bridge_dev != br)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) != br)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(i), ®);
|
b53_read16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(i), ®);
|
||||||
|
@ -1108,7 +1108,7 @@ static int lan9303_port_bridge_join(struct dsa_switch *ds, int port,
|
|||||||
struct lan9303 *chip = ds->priv;
|
struct lan9303 *chip = ds->priv;
|
||||||
|
|
||||||
dev_dbg(chip->dev, "%s(port %d)\n", __func__, port);
|
dev_dbg(chip->dev, "%s(port %d)\n", __func__, port);
|
||||||
if (dsa_to_port(ds, 1)->bridge_dev == dsa_to_port(ds, 2)->bridge_dev) {
|
if (dsa_port_bridge_same(dsa_to_port(ds, 1), dsa_to_port(ds, 2))) {
|
||||||
lan9303_bridge_ports(chip);
|
lan9303_bridge_ports(chip);
|
||||||
chip->is_bridged = true; /* unleash stp_state_set() */
|
chip->is_bridged = true; /* unleash stp_state_set() */
|
||||||
}
|
}
|
||||||
|
@ -759,7 +759,7 @@ static int gswip_port_vlan_filtering(struct dsa_switch *ds, int port,
|
|||||||
bool vlan_filtering,
|
bool vlan_filtering,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
struct net_device *bridge = dsa_to_port(ds, port)->bridge_dev;
|
struct net_device *bridge = dsa_port_bridge_dev_get(dsa_to_port(ds, port));
|
||||||
struct gswip_priv *priv = ds->priv;
|
struct gswip_priv *priv = ds->priv;
|
||||||
|
|
||||||
/* Do not allow changing the VLAN filtering options while in bridge */
|
/* Do not allow changing the VLAN filtering options while in bridge */
|
||||||
@ -1183,8 +1183,8 @@ static int gswip_port_vlan_prepare(struct dsa_switch *ds, int port,
|
|||||||
const struct switchdev_obj_port_vlan *vlan,
|
const struct switchdev_obj_port_vlan *vlan,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
|
struct net_device *bridge = dsa_port_bridge_dev_get(dsa_to_port(ds, port));
|
||||||
struct gswip_priv *priv = ds->priv;
|
struct gswip_priv *priv = ds->priv;
|
||||||
struct net_device *bridge = dsa_to_port(ds, port)->bridge_dev;
|
|
||||||
unsigned int max_ports = priv->hw_info->max_ports;
|
unsigned int max_ports = priv->hw_info->max_ports;
|
||||||
int pos = max_ports;
|
int pos = max_ports;
|
||||||
int i, idx = -1;
|
int i, idx = -1;
|
||||||
@ -1229,8 +1229,8 @@ static int gswip_port_vlan_add(struct dsa_switch *ds, int port,
|
|||||||
const struct switchdev_obj_port_vlan *vlan,
|
const struct switchdev_obj_port_vlan *vlan,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
|
struct net_device *bridge = dsa_port_bridge_dev_get(dsa_to_port(ds, port));
|
||||||
struct gswip_priv *priv = ds->priv;
|
struct gswip_priv *priv = ds->priv;
|
||||||
struct net_device *bridge = dsa_to_port(ds, port)->bridge_dev;
|
|
||||||
bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
|
bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED;
|
||||||
bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
|
bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
|
||||||
int err;
|
int err;
|
||||||
@ -1254,8 +1254,8 @@ static int gswip_port_vlan_add(struct dsa_switch *ds, int port,
|
|||||||
static int gswip_port_vlan_del(struct dsa_switch *ds, int port,
|
static int gswip_port_vlan_del(struct dsa_switch *ds, int port,
|
||||||
const struct switchdev_obj_port_vlan *vlan)
|
const struct switchdev_obj_port_vlan *vlan)
|
||||||
{
|
{
|
||||||
|
struct net_device *bridge = dsa_port_bridge_dev_get(dsa_to_port(ds, port));
|
||||||
struct gswip_priv *priv = ds->priv;
|
struct gswip_priv *priv = ds->priv;
|
||||||
struct net_device *bridge = dsa_to_port(ds, port)->bridge_dev;
|
|
||||||
bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
|
bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID;
|
||||||
|
|
||||||
/* We have to receive all packets on the CPU port and should not
|
/* We have to receive all packets on the CPU port and should not
|
||||||
@ -1340,8 +1340,8 @@ static void gswip_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
|
|||||||
static int gswip_port_fdb(struct dsa_switch *ds, int port,
|
static int gswip_port_fdb(struct dsa_switch *ds, int port,
|
||||||
const unsigned char *addr, u16 vid, bool add)
|
const unsigned char *addr, u16 vid, bool add)
|
||||||
{
|
{
|
||||||
|
struct net_device *bridge = dsa_port_bridge_dev_get(dsa_to_port(ds, port));
|
||||||
struct gswip_priv *priv = ds->priv;
|
struct gswip_priv *priv = ds->priv;
|
||||||
struct net_device *bridge = dsa_to_port(ds, port)->bridge_dev;
|
|
||||||
struct gswip_pce_table_entry mac_bridge = {0,};
|
struct gswip_pce_table_entry mac_bridge = {0,};
|
||||||
unsigned int cpu_port = priv->hw_info->cpu_port;
|
unsigned int cpu_port = priv->hw_info->cpu_port;
|
||||||
int fid = -1;
|
int fid = -1;
|
||||||
|
@ -43,7 +43,7 @@ void ksz_update_port_member(struct ksz_device *dev, int port)
|
|||||||
continue;
|
continue;
|
||||||
if (port == i)
|
if (port == i)
|
||||||
continue;
|
continue;
|
||||||
if (!dp->bridge_dev || dp->bridge_dev != other_dp->bridge_dev)
|
if (!dsa_port_bridge_same(dp, other_dp))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (other_p->stp_state == BR_STATE_FORWARDING &&
|
if (other_p->stp_state == BR_STATE_FORWARDING &&
|
||||||
|
@ -1204,7 +1204,7 @@ mt7530_port_bridge_join(struct dsa_switch *ds, int port,
|
|||||||
* same bridge. If the port is disabled, port matrix is kept
|
* same bridge. If the port is disabled, port matrix is kept
|
||||||
* and not being setup until the port becomes enabled.
|
* and not being setup until the port becomes enabled.
|
||||||
*/
|
*/
|
||||||
if (other_dp->bridge_dev != bridge)
|
if (dsa_port_bridge_dev_get(other_dp) != bridge)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (priv->ports[other_port].enable)
|
if (priv->ports[other_port].enable)
|
||||||
@ -1240,7 +1240,7 @@ mt7530_port_set_vlan_unaware(struct dsa_switch *ds, int port)
|
|||||||
/* This is called after .port_bridge_leave when leaving a VLAN-aware
|
/* This is called after .port_bridge_leave when leaving a VLAN-aware
|
||||||
* bridge. Don't set standalone ports to fallback mode.
|
* bridge. Don't set standalone ports to fallback mode.
|
||||||
*/
|
*/
|
||||||
if (dsa_to_port(ds, port)->bridge_dev)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, port)))
|
||||||
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK,
|
mt7530_rmw(priv, MT7530_PCR_P(port), PCR_PORT_VLAN_MASK,
|
||||||
MT7530_PORT_FALLBACK_MODE);
|
MT7530_PORT_FALLBACK_MODE);
|
||||||
|
|
||||||
@ -1320,7 +1320,7 @@ mt7530_port_bridge_leave(struct dsa_switch *ds, int port,
|
|||||||
* in the same bridge. If the port is disabled, port matrix
|
* in the same bridge. If the port is disabled, port matrix
|
||||||
* is kept and not being setup until the port becomes enabled.
|
* is kept and not being setup until the port becomes enabled.
|
||||||
*/
|
*/
|
||||||
if (other_dp->bridge_dev != bridge)
|
if (dsa_port_bridge_dev_get(other_dp) != bridge)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (priv->ports[other_port].enable)
|
if (priv->ports[other_port].enable)
|
||||||
|
@ -1247,10 +1247,12 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
|
|||||||
/* dev is a virtual bridge */
|
/* dev is a virtual bridge */
|
||||||
} else {
|
} else {
|
||||||
list_for_each_entry(dp, &dst->ports, list) {
|
list_for_each_entry(dp, &dst->ports, list) {
|
||||||
if (!dp->bridge_num)
|
unsigned int bridge_num = dsa_port_bridge_num_get(dp);
|
||||||
|
|
||||||
|
if (!bridge_num)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (dp->bridge_num + dst->last_switch != dev)
|
if (bridge_num + dst->last_switch != dev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
@ -1274,7 +1276,7 @@ static u16 mv88e6xxx_port_vlan(struct mv88e6xxx_chip *chip, int dev, int port)
|
|||||||
dsa_switch_for_each_port(other_dp, ds)
|
dsa_switch_for_each_port(other_dp, ds)
|
||||||
if (other_dp->type == DSA_PORT_TYPE_CPU ||
|
if (other_dp->type == DSA_PORT_TYPE_CPU ||
|
||||||
other_dp->type == DSA_PORT_TYPE_DSA ||
|
other_dp->type == DSA_PORT_TYPE_DSA ||
|
||||||
(dp->bridge_dev && dp->bridge_dev == other_dp->bridge_dev))
|
dsa_port_bridge_same(dp, other_dp))
|
||||||
pvlan |= BIT(other_dp->index);
|
pvlan |= BIT(other_dp->index);
|
||||||
|
|
||||||
return pvlan;
|
return pvlan;
|
||||||
@ -1659,19 +1661,21 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
dsa_switch_for_each_user_port(other_dp, ds) {
|
dsa_switch_for_each_user_port(other_dp, ds) {
|
||||||
|
struct net_device *other_br;
|
||||||
|
|
||||||
if (vlan.member[other_dp->index] ==
|
if (vlan.member[other_dp->index] ==
|
||||||
MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
|
MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (dp->bridge_dev == other_dp->bridge_dev)
|
if (dsa_port_bridge_same(dp, other_dp))
|
||||||
break; /* same bridge, check next VLAN */
|
break; /* same bridge, check next VLAN */
|
||||||
|
|
||||||
if (!other_dp->bridge_dev)
|
other_br = dsa_port_bridge_dev_get(other_dp);
|
||||||
|
if (!other_br)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
|
dev_err(ds->dev, "p%d: hw VLAN %d already used by port %d in %s\n",
|
||||||
port, vlan.vid, other_dp->index,
|
port, vlan.vid, other_dp->index, netdev_name(other_br));
|
||||||
netdev_name(other_dp->bridge_dev));
|
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1681,13 +1685,14 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
|
|||||||
static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port)
|
static int mv88e6xxx_port_commit_pvid(struct mv88e6xxx_chip *chip, int port)
|
||||||
{
|
{
|
||||||
struct dsa_port *dp = dsa_to_port(chip->ds, port);
|
struct dsa_port *dp = dsa_to_port(chip->ds, port);
|
||||||
|
struct net_device *br = dsa_port_bridge_dev_get(dp);
|
||||||
struct mv88e6xxx_port *p = &chip->ports[port];
|
struct mv88e6xxx_port *p = &chip->ports[port];
|
||||||
u16 pvid = MV88E6XXX_VID_STANDALONE;
|
u16 pvid = MV88E6XXX_VID_STANDALONE;
|
||||||
bool drop_untagged = false;
|
bool drop_untagged = false;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (dp->bridge_dev) {
|
if (br) {
|
||||||
if (br_vlan_enabled(dp->bridge_dev)) {
|
if (br_vlan_enabled(br)) {
|
||||||
pvid = p->bridge_pvid.vid;
|
pvid = p->bridge_pvid.vid;
|
||||||
drop_untagged = !p->bridge_pvid.valid;
|
drop_untagged = !p->bridge_pvid.valid;
|
||||||
} else {
|
} else {
|
||||||
@ -2413,7 +2418,7 @@ static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
|
|||||||
int err;
|
int err;
|
||||||
|
|
||||||
list_for_each_entry(dp, &dst->ports, list) {
|
list_for_each_entry(dp, &dst->ports, list) {
|
||||||
if (dp->bridge_dev == br) {
|
if (dsa_port_bridge_dev_get(dp) == br) {
|
||||||
if (dp->ds == ds) {
|
if (dp->ds == ds) {
|
||||||
/* This is a local bridge group member,
|
/* This is a local bridge group member,
|
||||||
* remap its Port VLAN Map.
|
* remap its Port VLAN Map.
|
||||||
|
@ -1823,7 +1823,7 @@ qca8k_port_bridge_join(struct dsa_switch *ds, int port, struct net_device *br)
|
|||||||
for (i = 0; i < QCA8K_NUM_PORTS; i++) {
|
for (i = 0; i < QCA8K_NUM_PORTS; i++) {
|
||||||
if (dsa_is_cpu_port(ds, i))
|
if (dsa_is_cpu_port(ds, i))
|
||||||
continue;
|
continue;
|
||||||
if (dsa_to_port(ds, i)->bridge_dev != br)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) != br)
|
||||||
continue;
|
continue;
|
||||||
/* Add this port to the portvlan mask of the other ports
|
/* Add this port to the portvlan mask of the other ports
|
||||||
* in the bridge
|
* in the bridge
|
||||||
@ -1855,7 +1855,7 @@ qca8k_port_bridge_leave(struct dsa_switch *ds, int port, struct net_device *br)
|
|||||||
for (i = 0; i < QCA8K_NUM_PORTS; i++) {
|
for (i = 0; i < QCA8K_NUM_PORTS; i++) {
|
||||||
if (dsa_is_cpu_port(ds, i))
|
if (dsa_is_cpu_port(ds, i))
|
||||||
continue;
|
continue;
|
||||||
if (dsa_to_port(ds, i)->bridge_dev != br)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) != br)
|
||||||
continue;
|
continue;
|
||||||
/* Remove this port to the portvlan mask of the other ports
|
/* Remove this port to the portvlan mask of the other ports
|
||||||
* in the bridge
|
* in the bridge
|
||||||
|
@ -1198,7 +1198,7 @@ rtl8366rb_port_bridge_join(struct dsa_switch *ds, int port,
|
|||||||
if (i == port)
|
if (i == port)
|
||||||
continue;
|
continue;
|
||||||
/* Not on this bridge */
|
/* Not on this bridge */
|
||||||
if (dsa_to_port(ds, i)->bridge_dev != bridge)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) != bridge)
|
||||||
continue;
|
continue;
|
||||||
/* Join this port to each other port on the bridge */
|
/* Join this port to each other port on the bridge */
|
||||||
ret = regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i),
|
ret = regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i),
|
||||||
@ -1230,7 +1230,7 @@ rtl8366rb_port_bridge_leave(struct dsa_switch *ds, int port,
|
|||||||
if (i == port)
|
if (i == port)
|
||||||
continue;
|
continue;
|
||||||
/* Not on this bridge */
|
/* Not on this bridge */
|
||||||
if (dsa_to_port(ds, i)->bridge_dev != bridge)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) != bridge)
|
||||||
continue;
|
continue;
|
||||||
/* Remove this port from any other port on the bridge */
|
/* Remove this port from any other port on the bridge */
|
||||||
ret = regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i),
|
ret = regmap_update_bits(smi->map, RTL8366RB_PORT_ISO(i),
|
||||||
|
@ -118,13 +118,14 @@ static int sja1105_pvid_apply(struct sja1105_private *priv, int port, u16 pvid)
|
|||||||
static int sja1105_commit_pvid(struct dsa_switch *ds, int port)
|
static int sja1105_commit_pvid(struct dsa_switch *ds, int port)
|
||||||
{
|
{
|
||||||
struct dsa_port *dp = dsa_to_port(ds, port);
|
struct dsa_port *dp = dsa_to_port(ds, port);
|
||||||
|
struct net_device *br = dsa_port_bridge_dev_get(dp);
|
||||||
struct sja1105_private *priv = ds->priv;
|
struct sja1105_private *priv = ds->priv;
|
||||||
struct sja1105_vlan_lookup_entry *vlan;
|
struct sja1105_vlan_lookup_entry *vlan;
|
||||||
bool drop_untagged = false;
|
bool drop_untagged = false;
|
||||||
int match, rc;
|
int match, rc;
|
||||||
u16 pvid;
|
u16 pvid;
|
||||||
|
|
||||||
if (dp->bridge_dev && br_vlan_enabled(dp->bridge_dev))
|
if (br && br_vlan_enabled(br))
|
||||||
pvid = priv->bridge_pvid[port];
|
pvid = priv->bridge_pvid[port];
|
||||||
else
|
else
|
||||||
pvid = priv->tag_8021q_pvid[port];
|
pvid = priv->tag_8021q_pvid[port];
|
||||||
@ -2004,7 +2005,7 @@ static int sja1105_bridge_member(struct dsa_switch *ds, int port,
|
|||||||
*/
|
*/
|
||||||
if (i == port)
|
if (i == port)
|
||||||
continue;
|
continue;
|
||||||
if (dsa_to_port(ds, i)->bridge_dev != br)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) != br)
|
||||||
continue;
|
continue;
|
||||||
sja1105_port_allow_traffic(l2_fwd, i, port, member);
|
sja1105_port_allow_traffic(l2_fwd, i, port, member);
|
||||||
sja1105_port_allow_traffic(l2_fwd, port, i, member);
|
sja1105_port_allow_traffic(l2_fwd, port, i, member);
|
||||||
@ -2587,8 +2588,9 @@ static int sja1105_prechangeupper(struct dsa_switch *ds, int port,
|
|||||||
|
|
||||||
if (netif_is_bridge_master(upper)) {
|
if (netif_is_bridge_master(upper)) {
|
||||||
list_for_each_entry(dp, &dst->ports, list) {
|
list_for_each_entry(dp, &dst->ports, list) {
|
||||||
if (dp->bridge_dev && dp->bridge_dev != upper &&
|
struct net_device *br = dsa_port_bridge_dev_get(dp);
|
||||||
br_vlan_enabled(dp->bridge_dev)) {
|
|
||||||
|
if (br && br != upper && br_vlan_enabled(br)) {
|
||||||
NL_SET_ERR_MSG_MOD(extack,
|
NL_SET_ERR_MSG_MOD(extack,
|
||||||
"Only one VLAN-aware bridge is supported");
|
"Only one VLAN-aware bridge is supported");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
@ -513,14 +513,14 @@ static int xrs700x_bridge_common(struct dsa_switch *ds, int port,
|
|||||||
|
|
||||||
cpu_mask |= BIT(i);
|
cpu_mask |= BIT(i);
|
||||||
|
|
||||||
if (dsa_to_port(ds, i)->bridge_dev == bridge)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) == bridge)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mask |= BIT(i);
|
mask |= BIT(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ds->num_ports; i++) {
|
for (i = 0; i < ds->num_ports; i++) {
|
||||||
if (dsa_to_port(ds, i)->bridge_dev != bridge)
|
if (dsa_port_bridge_dev_get(dsa_to_port(ds, i)) != bridge)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* 1 = Disable forwarding to the port */
|
/* 1 = Disable forwarding to the port */
|
||||||
|
Loading…
Reference in New Issue
Block a user