Commit e58df56c authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

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: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7026b8a6
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <net/netlink.h> #include <net/netlink.h>
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
#include <net/rtnetlink.h> #include <net/rtnetlink.h>
#include <net/switchdev.h>
#include "netdevsim.h" #include "netdevsim.h"
...@@ -148,26 +147,16 @@ static struct device_type nsim_dev_type = { ...@@ -148,26 +147,16 @@ static struct device_type nsim_dev_type = {
.release = nsim_dev_release, .release = nsim_dev_release,
}; };
static int static int nsim_get_port_parent_id(struct net_device *dev,
nsim_port_attr_get(struct net_device *dev, struct switchdev_attr *attr) struct netdev_phys_item_id *ppid)
{ {
struct netdevsim *ns = netdev_priv(dev); struct netdevsim *ns = netdev_priv(dev);
switch (attr->id) { ppid->id_len = sizeof(ns->sdev->switch_id);
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: memcpy(&ppid->id, &ns->sdev->switch_id, ppid->id_len);
attr->u.ppid.id_len = sizeof(ns->sdev->switch_id); return 0;
memcpy(&attr->u.ppid.id, &ns->sdev->switch_id,
attr->u.ppid.id_len);
return 0;
default:
return -EOPNOTSUPP;
}
} }
static const struct switchdev_ops nsim_switchdev_ops = {
.switchdev_port_attr_get = nsim_port_attr_get,
};
static int nsim_init(struct net_device *dev) static int nsim_init(struct net_device *dev)
{ {
char sdev_ddir_name[10], sdev_link_name[32]; char sdev_ddir_name[10], sdev_link_name[32];
...@@ -214,7 +203,6 @@ static int nsim_init(struct net_device *dev) ...@@ -214,7 +203,6 @@ static int nsim_init(struct net_device *dev)
goto err_bpf_uninit; goto err_bpf_uninit;
SET_NETDEV_DEV(dev, &ns->dev); SET_NETDEV_DEV(dev, &ns->dev);
SWITCHDEV_SET_OPS(dev, &nsim_switchdev_ops);
err = nsim_devlink_setup(ns); err = nsim_devlink_setup(ns);
if (err) if (err)
...@@ -493,6 +481,7 @@ static const struct net_device_ops nsim_netdev_ops = { ...@@ -493,6 +481,7 @@ static const struct net_device_ops nsim_netdev_ops = {
.ndo_setup_tc = nsim_setup_tc, .ndo_setup_tc = nsim_setup_tc,
.ndo_set_features = nsim_set_features, .ndo_set_features = nsim_set_features,
.ndo_bpf = nsim_bpf, .ndo_bpf = nsim_bpf,
.ndo_get_port_parent_id = nsim_get_port_parent_id,
}; };
static void nsim_setup(struct net_device *dev) static void nsim_setup(struct net_device *dev)
......
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