diff options
| author | Florian Fainelli <f.fainelli@gmail.com> | 2019-02-06 12:45:43 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2019-02-06 17:17:03 -0500 |
| commit | e58df56c8564b701491236381fc1e75202952736 (patch) | |
| tree | 20090a36c3d816623fa9625a33767ede5571dda6 /drivers/net/netdevsim | |
| parent | 7026b8a6fbe1061863a25495d4dc1fa115c8708e (diff) | |
netdevsim: Implement ndo_get_port_parent_id()
netdevsim only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a
great candidate to be converted to use the ndo_get_port_parent_id() NDO
instead of implementing switchdev_port_attr_get().
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netdevsim')
| -rw-r--r-- | drivers/net/netdevsim/netdev.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c index 8d8e2b3f263e..75a50b59cb8f 100644 --- a/drivers/net/netdevsim/netdev.c +++ b/drivers/net/netdevsim/netdev.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <net/netlink.h> | 22 | #include <net/netlink.h> |
| 23 | #include <net/pkt_cls.h> | 23 | #include <net/pkt_cls.h> |
| 24 | #include <net/rtnetlink.h> | 24 | #include <net/rtnetlink.h> |
| 25 | #include <net/switchdev.h> | ||
| 26 | 25 | ||
| 27 | #include "netdevsim.h" | 26 | #include "netdevsim.h" |
| 28 | 27 | ||
| @@ -148,26 +147,16 @@ static struct device_type nsim_dev_type = { | |||
| 148 | .release = nsim_dev_release, | 147 | .release = nsim_dev_release, |
| 149 | }; | 148 | }; |
| 150 | 149 | ||
| 151 | static int | 150 | static int nsim_get_port_parent_id(struct net_device *dev, |
| 152 | nsim_port_attr_get(struct net_device *dev, struct switchdev_attr *attr) | 151 | struct netdev_phys_item_id *ppid) |
| 153 | { | 152 | { |
| 154 | struct netdevsim *ns = netdev_priv(dev); | 153 | struct netdevsim *ns = netdev_priv(dev); |
| 155 | 154 | ||
| 156 | switch (attr->id) { | 155 | ppid->id_len = sizeof(ns->sdev->switch_id); |
| 157 | case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: | 156 | memcpy(&ppid->id, &ns->sdev->switch_id, ppid->id_len); |
| 158 | attr->u.ppid.id_len = sizeof(ns->sdev->switch_id); | 157 | return 0; |
| 159 | memcpy(&attr->u.ppid.id, &ns->sdev->switch_id, | ||
| 160 | attr->u.ppid.id_len); | ||
| 161 | return 0; | ||
| 162 | default: | ||
| 163 | return -EOPNOTSUPP; | ||
| 164 | } | ||
| 165 | } | 158 | } |
| 166 | 159 | ||
| 167 | static const struct switchdev_ops nsim_switchdev_ops = { | ||
| 168 | .switchdev_port_attr_get = nsim_port_attr_get, | ||
| 169 | }; | ||
| 170 | |||
| 171 | static int nsim_init(struct net_device *dev) | 160 | static int nsim_init(struct net_device *dev) |
| 172 | { | 161 | { |
| 173 | char sdev_ddir_name[10], sdev_link_name[32]; | 162 | char sdev_ddir_name[10], sdev_link_name[32]; |
| @@ -214,7 +203,6 @@ static int nsim_init(struct net_device *dev) | |||
| 214 | goto err_bpf_uninit; | 203 | goto err_bpf_uninit; |
| 215 | 204 | ||
| 216 | SET_NETDEV_DEV(dev, &ns->dev); | 205 | SET_NETDEV_DEV(dev, &ns->dev); |
| 217 | SWITCHDEV_SET_OPS(dev, &nsim_switchdev_ops); | ||
| 218 | 206 | ||
| 219 | err = nsim_devlink_setup(ns); | 207 | err = nsim_devlink_setup(ns); |
| 220 | if (err) | 208 | if (err) |
| @@ -493,6 +481,7 @@ static const struct net_device_ops nsim_netdev_ops = { | |||
| 493 | .ndo_setup_tc = nsim_setup_tc, | 481 | .ndo_setup_tc = nsim_setup_tc, |
| 494 | .ndo_set_features = nsim_set_features, | 482 | .ndo_set_features = nsim_set_features, |
| 495 | .ndo_bpf = nsim_bpf, | 483 | .ndo_bpf = nsim_bpf, |
| 484 | .ndo_get_port_parent_id = nsim_get_port_parent_id, | ||
| 496 | }; | 485 | }; |
| 497 | 486 | ||
| 498 | static void nsim_setup(struct net_device *dev) | 487 | static void nsim_setup(struct net_device *dev) |
