Commit ebb9a03a authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

switchdev: s/netdev_switch_/switchdev_/ and s/NETDEV_SWITCH_/SWITCHDEV_/

Turned out that "switchdev" sticks. So just unify all related terms to use
this prefix.
Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarScott Feldman <sfeldma@gmail.com>
Acked-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: default avatarAndy Gospodarek <gospo@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a3eb95f8
...@@ -4039,8 +4039,8 @@ static const struct net_device_ops bond_netdev_ops = { ...@@ -4039,8 +4039,8 @@ static const struct net_device_ops bond_netdev_ops = {
.ndo_add_slave = bond_enslave, .ndo_add_slave = bond_enslave,
.ndo_del_slave = bond_release, .ndo_del_slave = bond_release,
.ndo_fix_features = bond_fix_features, .ndo_fix_features = bond_fix_features,
.ndo_bridge_setlink = ndo_dflt_netdev_switch_port_bridge_setlink, .ndo_bridge_setlink = ndo_dflt_switchdev_port_bridge_setlink,
.ndo_bridge_dellink = ndo_dflt_netdev_switch_port_bridge_dellink, .ndo_bridge_dellink = ndo_dflt_switchdev_port_bridge_dellink,
.ndo_features_check = passthru_features_check, .ndo_features_check = passthru_features_check,
}; };
......
...@@ -3377,16 +3377,16 @@ static void rocker_port_fdb_learn_work(struct work_struct *work) ...@@ -3377,16 +3377,16 @@ static void rocker_port_fdb_learn_work(struct work_struct *work)
container_of(work, struct rocker_fdb_learn_work, work); container_of(work, struct rocker_fdb_learn_work, work);
bool removing = (lw->flags & ROCKER_OP_FLAG_REMOVE); bool removing = (lw->flags & ROCKER_OP_FLAG_REMOVE);
bool learned = (lw->flags & ROCKER_OP_FLAG_LEARNED); bool learned = (lw->flags & ROCKER_OP_FLAG_LEARNED);
struct netdev_switch_notifier_fdb_info info; struct switchdev_notifier_fdb_info info;
info.addr = lw->addr; info.addr = lw->addr;
info.vid = lw->vid; info.vid = lw->vid;
if (learned && removing) if (learned && removing)
call_netdev_switch_notifiers(NETDEV_SWITCH_FDB_DEL, call_switchdev_notifiers(SWITCHDEV_FDB_DEL,
lw->dev, &info.info); lw->dev, &info.info);
else if (learned && !removing) else if (learned && !removing)
call_netdev_switch_notifiers(NETDEV_SWITCH_FDB_ADD, call_switchdev_notifiers(SWITCHDEV_FDB_ADD,
lw->dev, &info.info); lw->dev, &info.info);
kfree(work); kfree(work);
......
...@@ -1977,8 +1977,8 @@ static const struct net_device_ops team_netdev_ops = { ...@@ -1977,8 +1977,8 @@ static const struct net_device_ops team_netdev_ops = {
.ndo_del_slave = team_del_slave, .ndo_del_slave = team_del_slave,
.ndo_fix_features = team_fix_features, .ndo_fix_features = team_fix_features,
.ndo_change_carrier = team_change_carrier, .ndo_change_carrier = team_change_carrier,
.ndo_bridge_setlink = ndo_dflt_netdev_switch_port_bridge_setlink, .ndo_bridge_setlink = ndo_dflt_switchdev_port_bridge_setlink,
.ndo_bridge_dellink = ndo_dflt_netdev_switch_port_bridge_dellink, .ndo_bridge_dellink = ndo_dflt_switchdev_port_bridge_dellink,
.ndo_features_check = passthru_features_check, .ndo_features_check = passthru_features_check,
}; };
......
...@@ -43,109 +43,110 @@ struct swdev_ops { ...@@ -43,109 +43,110 @@ struct swdev_ops {
u8 tos, u8 type, u32 tb_id); u8 tos, u8 type, u32 tb_id);
}; };
enum netdev_switch_notifier_type { enum switchdev_notifier_type {
NETDEV_SWITCH_FDB_ADD = 1, SWITCHDEV_FDB_ADD = 1,
NETDEV_SWITCH_FDB_DEL, SWITCHDEV_FDB_DEL,
}; };
struct netdev_switch_notifier_info { struct switchdev_notifier_info {
struct net_device *dev; struct net_device *dev;
}; };
struct netdev_switch_notifier_fdb_info { struct switchdev_notifier_fdb_info {
struct netdev_switch_notifier_info info; /* must be first */ struct switchdev_notifier_info info; /* must be first */
const unsigned char *addr; const unsigned char *addr;
u16 vid; u16 vid;
}; };
static inline struct net_device * static inline struct net_device *
netdev_switch_notifier_info_to_dev(const struct netdev_switch_notifier_info *info) switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info)
{ {
return info->dev; return info->dev;
} }
#ifdef CONFIG_NET_SWITCHDEV #ifdef CONFIG_NET_SWITCHDEV
int netdev_switch_parent_id_get(struct net_device *dev, int switchdev_parent_id_get(struct net_device *dev,
struct netdev_phys_item_id *psid); struct netdev_phys_item_id *psid);
int netdev_switch_port_stp_update(struct net_device *dev, u8 state); int switchdev_port_stp_update(struct net_device *dev, u8 state);
int register_netdev_switch_notifier(struct notifier_block *nb); int register_switchdev_notifier(struct notifier_block *nb);
int unregister_netdev_switch_notifier(struct notifier_block *nb); int unregister_switchdev_notifier(struct notifier_block *nb);
int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev, int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
struct netdev_switch_notifier_info *info); struct switchdev_notifier_info *info);
int netdev_switch_port_bridge_setlink(struct net_device *dev, int switchdev_port_bridge_setlink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags); struct nlmsghdr *nlh, u16 flags);
int netdev_switch_port_bridge_dellink(struct net_device *dev, int switchdev_port_bridge_dellink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags); struct nlmsghdr *nlh, u16 flags);
int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev, int ndo_dflt_switchdev_port_bridge_dellink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags); struct nlmsghdr *nlh, u16 flags);
int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev, int ndo_dflt_switchdev_port_bridge_setlink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags); struct nlmsghdr *nlh, u16 flags);
int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
u8 tos, u8 type, u32 nlflags, u32 tb_id); u8 tos, u8 type, u32 nlflags, u32 tb_id);
int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
u8 tos, u8 type, u32 tb_id); u8 tos, u8 type, u32 tb_id);
void netdev_switch_fib_ipv4_abort(struct fib_info *fi); void switchdev_fib_ipv4_abort(struct fib_info *fi);
#else #else
static inline int netdev_switch_parent_id_get(struct net_device *dev, static inline int switchdev_parent_id_get(struct net_device *dev,
struct netdev_phys_item_id *psid) struct netdev_phys_item_id *psid)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int netdev_switch_port_stp_update(struct net_device *dev, static inline int switchdev_port_stp_update(struct net_device *dev,
u8 state) u8 state)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int register_netdev_switch_notifier(struct notifier_block *nb) static inline int register_switchdev_notifier(struct notifier_block *nb)
{ {
return 0; return 0;
} }
static inline int unregister_netdev_switch_notifier(struct notifier_block *nb) static inline int unregister_switchdev_notifier(struct notifier_block *nb)
{ {
return 0; return 0;
} }
static inline int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev, static inline int call_switchdev_notifiers(unsigned long val,
struct netdev_switch_notifier_info *info) struct net_device *dev,
struct switchdev_notifier_info *info)
{ {
return NOTIFY_DONE; return NOTIFY_DONE;
} }
static inline int netdev_switch_port_bridge_setlink(struct net_device *dev, static inline int switchdev_port_bridge_setlink(struct net_device *dev,
struct nlmsghdr *nlh, struct nlmsghdr *nlh,
u16 flags) u16 flags)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int netdev_switch_port_bridge_dellink(struct net_device *dev, static inline int switchdev_port_bridge_dellink(struct net_device *dev,
struct nlmsghdr *nlh, struct nlmsghdr *nlh,
u16 flags) u16 flags)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev, static inline int ndo_dflt_switchdev_port_bridge_dellink(struct net_device *dev,
struct nlmsghdr *nlh, struct nlmsghdr *nlh,
u16 flags) u16 flags)
{ {
return 0; return 0;
} }
static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev, static inline int ndo_dflt_switchdev_port_bridge_setlink(struct net_device *dev,
struct nlmsghdr *nlh, struct nlmsghdr *nlh,
u16 flags) u16 flags)
{ {
return 0; return 0;
} }
static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, static inline int switchdev_fib_ipv4_add(u32 dst, int dst_len,
struct fib_info *fi, struct fib_info *fi,
u8 tos, u8 type, u8 tos, u8 type,
u32 nlflags, u32 tb_id) u32 nlflags, u32 tb_id)
...@@ -153,14 +154,14 @@ static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, ...@@ -153,14 +154,14 @@ static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len,
return 0; return 0;
} }
static inline int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, static inline int switchdev_fib_ipv4_del(u32 dst, int dst_len,
struct fib_info *fi, struct fib_info *fi,
u8 tos, u8 type, u32 tb_id) u8 tos, u8 type, u32 tb_id)
{ {
return 0; return 0;
} }
static inline void netdev_switch_fib_ipv4_abort(struct fib_info *fi) static inline void switchdev_fib_ipv4_abort(struct fib_info *fi)
{ {
} }
......
...@@ -121,13 +121,13 @@ static struct notifier_block br_device_notifier = { ...@@ -121,13 +121,13 @@ static struct notifier_block br_device_notifier = {
.notifier_call = br_device_event .notifier_call = br_device_event
}; };
static int br_netdev_switch_event(struct notifier_block *unused, static int br_switchdev_event(struct notifier_block *unused,
unsigned long event, void *ptr) unsigned long event, void *ptr)
{ {
struct net_device *dev = netdev_switch_notifier_info_to_dev(ptr); struct net_device *dev = switchdev_notifier_info_to_dev(ptr);
struct net_bridge_port *p; struct net_bridge_port *p;
struct net_bridge *br; struct net_bridge *br;
struct netdev_switch_notifier_fdb_info *fdb_info; struct switchdev_notifier_fdb_info *fdb_info;
int err = NOTIFY_DONE; int err = NOTIFY_DONE;
rtnl_lock(); rtnl_lock();
...@@ -138,14 +138,14 @@ static int br_netdev_switch_event(struct notifier_block *unused, ...@@ -138,14 +138,14 @@ static int br_netdev_switch_event(struct notifier_block *unused,
br = p->br; br = p->br;
switch (event) { switch (event) {
case NETDEV_SWITCH_FDB_ADD: case SWITCHDEV_FDB_ADD:
fdb_info = ptr; fdb_info = ptr;
err = br_fdb_external_learn_add(br, p, fdb_info->addr, err = br_fdb_external_learn_add(br, p, fdb_info->addr,
fdb_info->vid); fdb_info->vid);
if (err) if (err)
err = notifier_from_errno(err); err = notifier_from_errno(err);
break; break;
case NETDEV_SWITCH_FDB_DEL: case SWITCHDEV_FDB_DEL:
fdb_info = ptr; fdb_info = ptr;
err = br_fdb_external_learn_del(br, p, fdb_info->addr, err = br_fdb_external_learn_del(br, p, fdb_info->addr,
fdb_info->vid); fdb_info->vid);
...@@ -159,8 +159,8 @@ static int br_netdev_switch_event(struct notifier_block *unused, ...@@ -159,8 +159,8 @@ static int br_netdev_switch_event(struct notifier_block *unused,
return err; return err;
} }
static struct notifier_block br_netdev_switch_notifier = { static struct notifier_block br_switchdev_notifier = {
.notifier_call = br_netdev_switch_event, .notifier_call = br_switchdev_event,
}; };
static void __net_exit br_net_exit(struct net *net) static void __net_exit br_net_exit(struct net *net)
...@@ -214,7 +214,7 @@ static int __init br_init(void) ...@@ -214,7 +214,7 @@ static int __init br_init(void)
if (err) if (err)
goto err_out3; goto err_out3;
err = register_netdev_switch_notifier(&br_netdev_switch_notifier); err = register_switchdev_notifier(&br_switchdev_notifier);
if (err) if (err)
goto err_out4; goto err_out4;
...@@ -235,7 +235,7 @@ static int __init br_init(void) ...@@ -235,7 +235,7 @@ static int __init br_init(void)
return 0; return 0;
err_out5: err_out5:
unregister_netdev_switch_notifier(&br_netdev_switch_notifier); unregister_switchdev_notifier(&br_switchdev_notifier);
err_out4: err_out4:
unregister_netdevice_notifier(&br_device_notifier); unregister_netdevice_notifier(&br_device_notifier);
err_out3: err_out3:
...@@ -253,7 +253,7 @@ static void __exit br_deinit(void) ...@@ -253,7 +253,7 @@ static void __exit br_deinit(void)
{ {
stp_proto_unregister(&br_stp_proto); stp_proto_unregister(&br_stp_proto);
br_netlink_fini(); br_netlink_fini();
unregister_netdev_switch_notifier(&br_netdev_switch_notifier); unregister_switchdev_notifier(&br_switchdev_notifier);
unregister_netdevice_notifier(&br_device_notifier); unregister_netdevice_notifier(&br_device_notifier);
brioctl_set(NULL); brioctl_set(NULL);
unregister_pernet_subsys(&br_net_ops); unregister_pernet_subsys(&br_net_ops);
......
...@@ -631,8 +631,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) ...@@ -631,8 +631,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
if (p && !(flags & BRIDGE_FLAGS_SELF)) { if (p && !(flags & BRIDGE_FLAGS_SELF)) {
/* set bridge attributes in hardware if supported /* set bridge attributes in hardware if supported
*/ */
ret_offload = netdev_switch_port_bridge_setlink(dev, nlh, ret_offload = switchdev_port_bridge_setlink(dev, nlh, flags);
flags);
if (ret_offload && ret_offload != -EOPNOTSUPP) if (ret_offload && ret_offload != -EOPNOTSUPP)
br_warn(p->br, "error setting attrs on port %u(%s)\n", br_warn(p->br, "error setting attrs on port %u(%s)\n",
(unsigned int)p->port_no, p->dev->name); (unsigned int)p->port_no, p->dev->name);
...@@ -671,8 +670,7 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) ...@@ -671,8 +670,7 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
if (p && !(flags & BRIDGE_FLAGS_SELF)) { if (p && !(flags & BRIDGE_FLAGS_SELF)) {
/* del bridge attributes in hardware /* del bridge attributes in hardware
*/ */
ret_offload = netdev_switch_port_bridge_dellink(dev, nlh, ret_offload = switchdev_port_bridge_dellink(dev, nlh, flags);
flags);
if (ret_offload && ret_offload != -EOPNOTSUPP) if (ret_offload && ret_offload != -EOPNOTSUPP)
br_warn(p->br, "error deleting attrs on port %u (%s)\n", br_warn(p->br, "error deleting attrs on port %u (%s)\n",
(unsigned int)p->port_no, p->dev->name); (unsigned int)p->port_no, p->dev->name);
......
...@@ -42,7 +42,7 @@ void br_set_state(struct net_bridge_port *p, unsigned int state) ...@@ -42,7 +42,7 @@ void br_set_state(struct net_bridge_port *p, unsigned int state)
int err; int err;
p->state = state; p->state = state;
err = netdev_switch_port_stp_update(p->dev, state); err = switchdev_port_stp_update(p->dev, state);
if (err && err != -EOPNOTSUPP) if (err && err != -EOPNOTSUPP)
br_warn(p->br, "error setting offload STP state on port %u(%s)\n", br_warn(p->br, "error setting offload STP state on port %u(%s)\n",
(unsigned int) p->port_no, p->dev->name); (unsigned int) p->port_no, p->dev->name);
......
...@@ -460,7 +460,7 @@ static ssize_t phys_switch_id_show(struct device *dev, ...@@ -460,7 +460,7 @@ static ssize_t phys_switch_id_show(struct device *dev,
if (dev_isalive(netdev)) { if (dev_isalive(netdev)) {
struct netdev_phys_item_id ppid; struct netdev_phys_item_id ppid;
ret = netdev_switch_parent_id_get(netdev, &ppid); ret = switchdev_parent_id_get(netdev, &ppid);
if (!ret) if (!ret)
ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id); ret = sprintf(buf, "%*phN\n", ppid.id_len, ppid.id);
} }
......
...@@ -1006,7 +1006,7 @@ static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev) ...@@ -1006,7 +1006,7 @@ static int rtnl_phys_switch_id_fill(struct sk_buff *skb, struct net_device *dev)
int err; int err;
struct netdev_phys_item_id psid; struct netdev_phys_item_id psid;
err = netdev_switch_parent_id_get(dev, &psid); err = switchdev_parent_id_get(dev, &psid);
if (err) { if (err) {
if (err == -EOPNOTSUPP) if (err == -EOPNOTSUPP)
return 0; return 0;
......
...@@ -1165,13 +1165,13 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) ...@@ -1165,13 +1165,13 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
new_fa->fa_state = state & ~FA_S_ACCESSED; new_fa->fa_state = state & ~FA_S_ACCESSED;
new_fa->fa_slen = fa->fa_slen; new_fa->fa_slen = fa->fa_slen;
err = netdev_switch_fib_ipv4_add(key, plen, fi, err = switchdev_fib_ipv4_add(key, plen, fi,
new_fa->fa_tos, new_fa->fa_tos,
cfg->fc_type, cfg->fc_type,
cfg->fc_nlflags, cfg->fc_nlflags,
tb->tb_id); tb->tb_id);
if (err) { if (err) {
netdev_switch_fib_ipv4_abort(fi); switchdev_fib_ipv4_abort(fi);
kmem_cache_free(fn_alias_kmem, new_fa); kmem_cache_free(fn_alias_kmem, new_fa);
goto out; goto out;
} }
...@@ -1215,12 +1215,10 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) ...@@ -1215,12 +1215,10 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
new_fa->tb_id = tb->tb_id; new_fa->tb_id = tb->tb_id;
/* (Optionally) offload fib entry to switch hardware. */ /* (Optionally) offload fib entry to switch hardware. */
err = netdev_switch_fib_ipv4_add(key, plen, fi, tos, err = switchdev_fib_ipv4_add(key, plen, fi, tos, cfg->fc_type,
cfg->fc_type, cfg->fc_nlflags, tb->tb_id);
cfg->fc_nlflags,
tb->tb_id);
if (err) { if (err) {
netdev_switch_fib_ipv4_abort(fi); switchdev_fib_ipv4_abort(fi);
goto out_free_new_fa; goto out_free_new_fa;
} }
...@@ -1239,7 +1237,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg) ...@@ -1239,7 +1237,7 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
return 0; return 0;
out_sw_fib_del: out_sw_fib_del:
netdev_switch_fib_ipv4_del(key, plen, fi, tos, cfg->fc_type, tb->tb_id); switchdev_fib_ipv4_del(key, plen, fi, tos, cfg->fc_type, tb->tb_id);
out_free_new_fa: out_free_new_fa:
kmem_cache_free(fn_alias_kmem, new_fa); kmem_cache_free(fn_alias_kmem, new_fa);
out: out:
...@@ -1517,7 +1515,7 @@ int fib_table_delete(struct fib_table *tb, struct fib_config *cfg) ...@@ -1517,7 +1515,7 @@ int fib_table_delete(struct fib_table *tb, struct fib_config *cfg)
if (!fa_to_delete) if (!fa_to_delete)
return -ESRCH; return -ESRCH;
netdev_switch_fib_ipv4_del(key, plen, fa_to_delete->fa_info, tos, switchdev_fib_ipv4_del(key, plen, fa_to_delete->fa_info, tos,
cfg->fc_type, tb->tb_id); cfg->fc_type, tb->tb_id);
rtmsg_fib(RTM_DELROUTE, htonl(key), fa_to_delete, plen, tb->tb_id, rtmsg_fib(RTM_DELROUTE, htonl(key), fa_to_delete, plen, tb->tb_id,
...@@ -1767,10 +1765,9 @@ void fib_table_flush_external(struct fib_table *tb) ...@@ -1767,10 +1765,9 @@ void fib_table_flush_external(struct fib_table *tb)
if (!fi || !(fi->fib_flags & RTNH_F_EXTERNAL)) if (!fi || !(fi->fib_flags & RTNH_F_EXTERNAL))
continue; continue;
netdev_switch_fib_ipv4_del(n->key, switchdev_fib_ipv4_del(n->key, KEYLENGTH - fa->fa_slen,
KEYLENGTH - fa->fa_slen, fi, fa->fa_tos, fa->fa_type,
fi, fa->fa_tos, tb->tb_id);
fa->fa_type, tb->tb_id);
} }
/* update leaf slen */ /* update leaf slen */
...@@ -1835,10 +1832,9 @@ int fib_table_flush(struct fib_table *tb) ...@@ -1835,10 +1832,9 @@ int fib_table_flush(struct fib_table *tb)
continue; continue;
} }
netdev_switch_fib_ipv4_del(n->key, switchdev_fib_ipv4_del(n->key, KEYLENGTH - fa->fa_slen,
KEYLENGTH - fa->fa_slen, fi, fa->fa_tos, fa->fa_type,
fi, fa->fa_tos, tb->tb_id);
fa->fa_type, tb->tb_id);
hlist_del_rcu(&fa->fa_list); hlist_del_rcu(&fa->fa_list);
fib_release_info(fa->fa_info); fib_release_info(fa->fa_info);
alias_free_mem_rcu(fa); alias_free_mem_rcu(fa);
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
#include <net/switchdev.h> #include <net/switchdev.h>
/** /**
* netdev_switch_parent_id_get - Get ID of a switch * switchdev_parent_id_get - Get ID of a switch
* @dev: port device * @dev: port device
* @psid: switch ID * @psid: switch ID
* *
* Get ID of a switch this port is part of. * Get ID of a switch this port is part of.
*/ */
int netdev_switch_parent_id_get(struct net_device *dev, int switchdev_parent_id_get(struct net_device *dev,
struct netdev_phys_item_id *psid) struct netdev_phys_item_id *psid)
{ {
const struct swdev_ops *ops = dev->swdev_ops; const struct swdev_ops *ops = dev->swdev_ops;
...@@ -34,17 +34,17 @@ int netdev_switch_parent_id_get(struct net_device *dev, ...@@ -34,17 +34,17 @@ int netdev_switch_parent_id_get(struct net_device *dev,
return -EOPNOTSUPP; return -EOPNOTSUPP;
return ops->swdev_parent_id_get(dev, psid); return ops->swdev_parent_id_get(dev, psid);
} }
EXPORT_SYMBOL_GPL(netdev_switch_parent_id_get); EXPORT_SYMBOL_GPL(switchdev_parent_id_get);
/** /**
* netdev_switch_port_stp_update - Notify switch device port of STP * switchdev_port_stp_update - Notify switch device port of STP
* state change * state change
* @dev: port device * @dev: port device
* @state: port STP state * @state: port STP state
* *
* Notify switch device port of bridge port STP state change. * Notify switch device port of bridge port STP state change.
*/ */
int netdev_switch_port_stp_update(struct net_device *dev, u8 state) int switchdev_port_stp_update(struct net_device *dev, u8 state)
{ {
const struct swdev_ops *ops = dev->swdev_ops; const struct swdev_ops *ops = dev->swdev_ops;
struct net_device *lower_dev; struct net_device *lower_dev;
...@@ -55,57 +55,57 @@ int netdev_switch_port_stp_update(struct net_device *dev, u8 state) ...@@ -55,57 +55,57 @@ int netdev_switch_port_stp_update(struct net_device *dev, u8 state)
return ops->swdev_port_stp_update(dev, state); return ops->swdev_port_stp_update(dev, state);
netdev_for_each_lower_dev(dev, lower_dev, iter) { netdev_for_each_lower_dev(dev, lower_dev, iter) {
err = netdev_switch_port_stp_update(lower_dev, state); err = switchdev_port_stp_update(lower_dev, state);
if (err && err != -EOPNOTSUPP) if (err && err != -EOPNOTSUPP)
return err; return err;
} }
return err; return err;
} }
EXPORT_SYMBOL_GPL(netdev_switch_port_stp_update); EXPORT_SYMBOL_GPL(switchdev_port_stp_update);
static DEFINE_MUTEX(netdev_switch_mutex); static DEFINE_MUTEX(switchdev_mutex);
static RAW_NOTIFIER_HEAD(netdev_switch_notif_chain); static RAW_NOTIFIER_HEAD(switchdev_notif_chain);
/** /**
* register_netdev_switch_notifier - Register notifier * register_switchdev_notifier - Register notifier
* @nb: notifier_block * @nb: notifier_block
* *
* Register switch device notifier. This should be used by code * Register switch device notifier. This should be used by code
* which needs to monitor events happening in particular device. * which needs to monitor events happening in particular device.
* Return values are same as for atomic_notifier_chain_register(). * Return values are same as for atomic_notifier_chain_register().
*/ */
int register_netdev_switch_notifier(struct notifier_block *nb) int register_switchdev_notifier(struct notifier_block *nb)
{ {
int err; int err;
mutex_lock(&netdev_switch_mutex); mutex_lock(&switchdev_mutex);
err = raw_notifier_chain_register(&netdev_switch_notif_chain, nb); err = raw_notifier_chain_register(&switchdev_notif_chain, nb);
mutex_unlock(&netdev_switch_mutex); mutex_unlock(&switchdev_mutex);
return err; return err;
} }
EXPORT_SYMBOL_GPL(register_netdev_switch_notifier); EXPORT_SYMBOL_GPL(register_switchdev_notifier);
/** /**
* unregister_netdev_switch_notifier - Unregister notifier * unregister_switchdev_notifier - Unregister notifier
* @nb: notifier_block * @nb: notifier_block
* *
* Unregister switch device notifier. * Unregister switch device notifier.
* Return values are same as for atomic_notifier_chain_unregister(). * Return values are same as for atomic_notifier_chain_unregister().
*/ */
int unregister_netdev_switch_notifier(struct notifier_block *nb) int unregister_switchdev_notifier(struct notifier_block *nb)
{ {
int err; int err;
mutex_lock(&netdev_switch_mutex); mutex_lock(&switchdev_mutex);
err = raw_notifier_chain_unregister(&netdev_switch_notif_chain, nb); err = raw_notifier_chain_unregister(&switchdev_notif_chain, nb);
mutex_unlock(&netdev_switch_mutex); mutex_unlock(&switchdev_mutex);
return err; return err;
} }
EXPORT_SYMBOL_GPL(unregister_netdev_switch_notifier); EXPORT_SYMBOL_GPL(unregister_switchdev_notifier);
/** /**
* call_netdev_switch_notifiers - Call notifiers * call_switchdev_notifiers - Call notifiers
* @val: value passed unmodified to notifier function * @val: value passed unmodified to notifier function
* @dev: port device * @dev: port device
* @info: notifier information data * @info: notifier information data
...@@ -114,21 +114,21 @@ EXPORT_SYMBOL_GPL(unregister_netdev_switch_notifier); ...@@ -114,21 +114,21 @@ EXPORT_SYMBOL_GPL(unregister_netdev_switch_notifier);
* when it needs to propagate hardware event. * when it needs to propagate hardware event.
* Return values are same as for atomic_notifier_call_chain(). * Return values are same as for atomic_notifier_call_chain().
*/ */
int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev, int call_switchdev_notifiers(unsigned long val, struct net_device *dev,
struct netdev_switch_notifier_info *info) struct switchdev_notifier_info *info)
{ {
int err; int err;
info->dev = dev; info->dev = dev;
mutex_lock(&netdev_switch_mutex); mutex_lock(&switchdev_mutex);
err = raw_notifier_call_chain(&netdev_switch_notif_chain, val, info); err = raw_notifier_call_chain(&switchdev_notif_chain, val, info);
mutex_unlock(&netdev_switch_mutex); mutex_unlock(&switchdev_mutex);
return err; return err;
} }
EXPORT_SYMBOL_GPL(call_netdev_switch_notifiers); EXPORT_SYMBOL_GPL(call_switchdev_notifiers);
/** /**
* netdev_switch_port_bridge_setlink - Notify switch device port of bridge * switchdev_port_bridge_setlink - Notify switch device port of bridge
* port attributes * port attributes
* *
* @dev: port device * @dev: port device
...@@ -137,7 +137,7 @@ EXPORT_SYMBOL_GPL(call_netdev_switch_notifiers); ...@@ -137,7 +137,7 @@ EXPORT_SYMBOL_GPL(call_netdev_switch_notifiers);
* *
* Notify switch device port of bridge port attributes * Notify switch device port of bridge port attributes
*/ */
int netdev_switch_port_bridge_setlink(struct net_device *dev, int switchdev_port_bridge_setlink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags) struct nlmsghdr *nlh, u16 flags)
{ {
const struct net_device_ops *ops = dev->netdev_ops; const struct net_device_ops *ops = dev->netdev_ops;
...@@ -150,10 +150,10 @@ int netdev_switch_port_bridge_setlink(struct net_device *dev, ...@@ -150,10 +150,10 @@ int netdev_switch_port_bridge_setlink(struct net_device *dev,
return ops->ndo_bridge_setlink(dev, nlh, flags); return ops->ndo_bridge_setlink(dev, nlh, flags);
} }
EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_setlink); EXPORT_SYMBOL_GPL(switchdev_port_bridge_setlink);
/** /**
* netdev_switch_port_bridge_dellink - Notify switch device port of bridge * switchdev_port_bridge_dellink - Notify switch device port of bridge
* port attribute delete * port attribute delete
* *
* @dev: port device * @dev: port device
...@@ -162,7 +162,7 @@ EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_setlink); ...@@ -162,7 +162,7 @@ EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_setlink);
* *
* Notify switch device port of bridge port attribute delete * Notify switch device port of bridge port attribute delete
*/ */
int netdev_switch_port_bridge_dellink(struct net_device *dev, int switchdev_port_bridge_dellink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags) struct nlmsghdr *nlh, u16 flags)
{ {
const struct net_device_ops *ops = dev->netdev_ops; const struct net_device_ops *ops = dev->netdev_ops;
...@@ -175,10 +175,10 @@ int netdev_switch_port_bridge_dellink(struct net_device *dev, ...@@ -175,10 +175,10 @@ int netdev_switch_port_bridge_dellink(struct net_device *dev,
return ops->ndo_bridge_dellink(dev, nlh, flags); return ops->ndo_bridge_dellink(dev, nlh, flags);
} }
EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_dellink); EXPORT_SYMBOL_GPL(switchdev_port_bridge_dellink);
/** /**
* ndo_dflt_netdev_switch_port_bridge_setlink - default ndo bridge setlink * ndo_dflt_switchdev_port_bridge_setlink - default ndo bridge setlink
* op for master devices * op for master devices
* *
* @dev: port device * @dev: port device
...@@ -187,7 +187,7 @@ EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_dellink); ...@@ -187,7 +187,7 @@ EXPORT_SYMBOL_GPL(netdev_switch_port_bridge_dellink);
* *
* Notify master device slaves of bridge port attributes * Notify master device slaves of bridge port attributes
*/ */
int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev, int ndo_dflt_switchdev_port_bridge_setlink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags) struct nlmsghdr *nlh, u16 flags)
{ {
struct net_device *lower_dev; struct net_device *lower_dev;
...@@ -198,17 +198,17 @@ int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev, ...@@ -198,17 +198,17 @@ int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
return ret; return ret;
netdev_for_each_lower_dev(dev, lower_dev, iter) { netdev_for_each_lower_dev(dev, lower_dev, iter) {
err = netdev_switch_port_bridge_setlink(lower_dev, nlh, flags); err = switchdev_port_bridge_setlink(lower_dev, nlh, flags);
if (err && err != -EOPNOTSUPP) if (err && err != -EOPNOTSUPP)
ret = err; ret = err;
} }
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_bridge_setlink); EXPORT_SYMBOL_GPL(ndo_dflt_switchdev_port_bridge_setlink);
/** /**
* ndo_dflt_netdev_switch_port_bridge_dellink - default ndo bridge dellink * ndo_dflt_switchdev_port_bridge_dellink - default ndo bridge dellink
* op for master devices * op for master devices
* *
* @dev: port device * @dev: port device
...@@ -217,7 +217,7 @@ EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_bridge_setlink); ...@@ -217,7 +217,7 @@ EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_bridge_setlink);
* *
* Notify master device slaves of bridge port attribute deletes * Notify master device slaves of bridge port attribute deletes
*/ */
int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev, int ndo_dflt_switchdev_port_bridge_dellink(struct net_device *dev,
struct nlmsghdr *nlh, u16 flags) struct nlmsghdr *nlh, u16 flags)
{ {
struct net_device *lower_dev; struct net_device *lower_dev;
...@@ -228,16 +228,16 @@ int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev, ...@@ -228,16 +228,16 @@ int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
return ret; return ret;
netdev_for_each_lower_dev(dev, lower_dev, iter) { netdev_for_each_lower_dev(dev, lower_dev, iter) {
err = netdev_switch_port_bridge_dellink(lower_dev, nlh, flags); err = switchdev_port_bridge_dellink(lower_dev, nlh, flags);
if (err && err != -EOPNOTSUPP) if (err && err != -EOPNOTSUPP)
ret = err; ret = err;
} }
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(ndo_dflt_netdev_switch_port_bridge_dellink); EXPORT_SYMBOL_GPL(ndo_dflt_switchdev_port_bridge_dellink);
static struct net_device *netdev_switch_get_lowest_dev(struct net_device *dev) static struct net_device *switchdev_get_lowest_dev(struct net_device *dev)
{ {
const struct swdev_ops *ops = dev->swdev_ops; const struct swdev_ops *ops = dev->swdev_ops;
struct net_device *lower_dev; struct net_device *lower_dev;
...@@ -253,7 +253,7 @@ static struct net_device *netdev_switch_get_lowest_dev(struct net_device *dev) ...@@ -253,7 +253,7 @@ static struct net_device *netdev_switch_get_lowest_dev(struct net_device *dev)
return dev; return dev;
netdev_for_each_lower_dev(dev, lower_dev, iter) { netdev_for_each_lower_dev(dev, lower_dev, iter) {
port_dev = netdev_switch_get_lowest_dev(lower_dev); port_dev = switchdev_get_lowest_dev(lower_dev);
if (port_dev) if (port_dev)
return port_dev; return port_dev;
} }
...@@ -261,7 +261,7 @@ static struct net_device *netdev_switch_get_lowest_dev(struct net_device *dev) ...@@ -261,7 +261,7 @@ static struct net_device *netdev_switch_get_lowest_dev(struct net_device *dev)
return NULL; return NULL;
} }
static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi) static struct net_device *switchdev_get_dev_by_nhs(struct fib_info *fi)
{ {
struct netdev_phys_item_id psid; struct netdev_phys_item_id psid;
struct netdev_phys_item_id prev_psid; struct netdev_phys_item_id prev_psid;
...@@ -276,11 +276,11 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi) ...@@ -276,11 +276,11 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi)
if (!nh->nh_dev) if (!nh->nh_dev)
return NULL; return NULL;
dev = netdev_switch_get_lowest_dev(nh->nh_dev); dev = switchdev_get_lowest_dev(nh->nh_dev);
if (!dev) if (!dev)
return NULL; return NULL;
if (netdev_switch_parent_id_get(dev, &psid)) if (switchdev_parent_id_get(dev, &psid))
return NULL; return NULL;
if (nhsel > 0) { if (nhsel > 0) {
...@@ -297,7 +297,7 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi) ...@@ -297,7 +297,7 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi)
} }
/** /**
* netdev_switch_fib_ipv4_add - Add IPv4 route entry to switch * switchdev_fib_ipv4_add - Add IPv4 route entry to switch
* *
* @dst: route's IPv4 destination address * @dst: route's IPv4 destination address
* @dst_len: destination address length (prefix length) * @dst_len: destination address length (prefix length)
...@@ -309,7 +309,7 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi) ...@@ -309,7 +309,7 @@ static struct net_device *netdev_switch_get_dev_by_nhs(struct fib_info *fi)
* *
* Add IPv4 route entry to switch device. * Add IPv4 route entry to switch device.
*/ */
int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
u8 tos, u8 type, u32 nlflags, u32 tb_id) u8 tos, u8 type, u32 nlflags, u32 tb_id)
{ {
struct net_device *dev; struct net_device *dev;
...@@ -328,7 +328,7 @@ int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, ...@@ -328,7 +328,7 @@ int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
if (fi->fib_net->ipv4.fib_offload_disabled) if (fi->fib_net->ipv4.fib_offload_disabled)
return 0; return 0;
dev = netdev_switch_get_dev_by_nhs(fi); dev = switchdev_get_dev_by_nhs(fi);
if (!dev) if (!dev)
return 0; return 0;
ops = dev->swdev_ops; ops = dev->swdev_ops;
...@@ -343,10 +343,10 @@ int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, ...@@ -343,10 +343,10 @@ int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
return err; return err;
} }
EXPORT_SYMBOL_GPL(netdev_switch_fib_ipv4_add); EXPORT_SYMBOL_GPL(switchdev_fib_ipv4_add);
/** /**
* netdev_switch_fib_ipv4_del - Delete IPv4 route entry from switch * switchdev_fib_ipv4_del - Delete IPv4 route entry from switch
* *
* @dst: route's IPv4 destination address * @dst: route's IPv4 destination address
* @dst_len: destination address length (prefix length) * @dst_len: destination address length (prefix length)
...@@ -357,7 +357,7 @@ EXPORT_SYMBOL_GPL(netdev_switch_fib_ipv4_add); ...@@ -357,7 +357,7 @@ EXPORT_SYMBOL_GPL(netdev_switch_fib_ipv4_add);
* *
* Delete IPv4 route entry from switch device. * Delete IPv4 route entry from switch device.
*/ */
int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
u8 tos, u8 type, u32 tb_id) u8 tos, u8 type, u32 tb_id)
{ {
struct net_device *dev; struct net_device *dev;
...@@ -367,7 +367,7 @@ int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, ...@@ -367,7 +367,7 @@ int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
if (!(fi->fib_flags & RTNH_F_EXTERNAL)) if (!(fi->fib_flags & RTNH_F_EXTERNAL))
return 0; return 0;
dev = netdev_switch_get_dev_by_nhs(fi); dev = switchdev_get_dev_by_nhs(fi);
if (!dev) if (!dev)
return 0; return 0;
ops = dev->swdev_ops; ops = dev->swdev_ops;
...@@ -381,14 +381,14 @@ int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, ...@@ -381,14 +381,14 @@ int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
return err; return err;
} }
EXPORT_SYMBOL_GPL(netdev_switch_fib_ipv4_del); EXPORT_SYMBOL_GPL(switchdev_fib_ipv4_del);
/** /**
* netdev_switch_fib_ipv4_abort - Abort an IPv4 FIB operation * switchdev_fib_ipv4_abort - Abort an IPv4 FIB operation
* *
* @fi: route FIB info structure * @fi: route FIB info structure
*/ */
void netdev_switch_fib_ipv4_abort(struct fib_info *fi) void switchdev_fib_ipv4_abort(struct fib_info *fi)
{ {
/* There was a problem installing this route to the offload /* There was a problem installing this route to the offload
* device. For now, until we come up with more refined * device. For now, until we come up with more refined
...@@ -401,4 +401,4 @@ void netdev_switch_fib_ipv4_abort(struct fib_info *fi) ...@@ -401,4 +401,4 @@ void netdev_switch_fib_ipv4_abort(struct fib_info *fi)
fib_flush_external(fi->fib_net); fib_flush_external(fi->fib_net);
fi->fib_net->ipv4.fib_offload_disabled = true; fi->fib_net->ipv4.fib_offload_disabled = true;
} }
EXPORT_SYMBOL_GPL(netdev_switch_fib_ipv4_abort); EXPORT_SYMBOL_GPL(switchdev_fib_ipv4_abort);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment