net: dsa: hide dp->bridge_dev and dp->bridge_num in the core 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.

Create 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:
Vladimir Oltean 2021-12-06 18:57:52 +02:00 committed by Jakub Kicinski
parent 65144067d3
commit 36cbf39b56
9 changed files with 62 additions and 37 deletions

View file

@ -599,6 +599,27 @@ struct net_device *dsa_port_to_bridge_port(const struct dsa_port *dp)
return dp->slave;
}
static inline struct net_device *
dsa_port_bridge_dev_get(const struct dsa_port *dp)
{
return dp->bridge_dev;
}
static inline unsigned int dsa_port_bridge_num_get(struct dsa_port *dp)
{
return dp->bridge_num;
}
static inline bool dsa_port_bridge_same(const struct dsa_port *a,
const struct dsa_port *b)
{
struct net_device *br_a = dsa_port_bridge_dev_get(a);
struct net_device *br_b = dsa_port_bridge_dev_get(b);
/* Standalone ports are not in the same bridge with one another */
return (!br_a || !br_b) ? false : (br_a == br_b);
}
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
bool is_static, void *data);
struct dsa_switch_ops {