Skip to content

Commit

Permalink
net: dsa: add slave to port helper
Browse files Browse the repository at this point in the history
Many portions of DSA core code require to get the dsa_port structure
corresponding to a slave net_device. For this purpose, introduce a
dsa_slave_to_port() helper.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
vivien authored and davem330 committed Oct 18, 2017
1 parent 6158eaa commit d945097
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 115 deletions.
7 changes: 7 additions & 0 deletions net/dsa/dsa_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ int dsa_slave_resume(struct net_device *slave_dev);
int dsa_slave_register_notifier(void);
void dsa_slave_unregister_notifier(void);

static inline struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
{
struct dsa_slave_priv *p = netdev_priv(dev);

return p->dp;
}

/* switch.c */
int dsa_switch_register_notifier(struct dsa_switch *ds);
void dsa_switch_unregister_notifier(struct dsa_switch *ds);
Expand Down
6 changes: 2 additions & 4 deletions net/dsa/legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,8 +740,7 @@ int dsa_legacy_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
const unsigned char *addr, u16 vid,
u16 flags)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
struct dsa_port *dp = dsa_slave_to_port(dev);

return dsa_port_fdb_add(dp, addr, vid);
}
Expand All @@ -750,8 +749,7 @@ int dsa_legacy_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],
struct net_device *dev,
const unsigned char *addr, u16 vid)
{
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
struct dsa_port *dp = dsa_slave_to_port(dev);

return dsa_port_fdb_del(dp, addr, vid);
}
Expand Down
Loading

0 comments on commit d945097

Please sign in to comment.