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

mlxsw: Implement ndo_get_devlink_port

In order for devlink compat functions to work, implement
ndo_get_devlink_port.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent af3836df
...@@ -1807,6 +1807,18 @@ int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core, ...@@ -1807,6 +1807,18 @@ int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core,
} }
EXPORT_SYMBOL(mlxsw_core_port_get_phys_port_name); EXPORT_SYMBOL(mlxsw_core_port_get_phys_port_name);
struct devlink_port *
mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
u8 local_port)
{
struct mlxsw_core_port *mlxsw_core_port =
&mlxsw_core->ports[local_port];
struct devlink_port *devlink_port = &mlxsw_core_port->devlink_port;
return devlink_port;
}
EXPORT_SYMBOL(mlxsw_core_port_devlink_port_get);
static void mlxsw_core_buf_dump_dbg(struct mlxsw_core *mlxsw_core, static void mlxsw_core_buf_dump_dbg(struct mlxsw_core *mlxsw_core,
const char *buf, size_t size) const char *buf, size_t size)
{ {
......
...@@ -178,6 +178,9 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core, ...@@ -178,6 +178,9 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
u8 local_port); u8 local_port);
int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core, int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core,
u8 local_port, char *name, size_t len); u8 local_port, char *name, size_t len);
struct devlink_port *
mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core,
u8 local_port);
int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay); int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay);
bool mlxsw_core_schedule_work(struct work_struct *work); bool mlxsw_core_schedule_work(struct work_struct *work);
......
...@@ -73,11 +73,22 @@ static int mlxsw_m_port_get_port_parent_id(struct net_device *dev, ...@@ -73,11 +73,22 @@ static int mlxsw_m_port_get_port_parent_id(struct net_device *dev,
return 0; return 0;
} }
static struct devlink_port *
mlxsw_m_port_get_devlink_port(struct net_device *dev)
{
struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev);
struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m;
return mlxsw_core_port_devlink_port_get(mlxsw_m->core,
mlxsw_m_port->local_port);
}
static const struct net_device_ops mlxsw_m_port_netdev_ops = { static const struct net_device_ops mlxsw_m_port_netdev_ops = {
.ndo_open = mlxsw_m_port_dummy_open_stop, .ndo_open = mlxsw_m_port_dummy_open_stop,
.ndo_stop = mlxsw_m_port_dummy_open_stop, .ndo_stop = mlxsw_m_port_dummy_open_stop,
.ndo_get_phys_port_name = mlxsw_m_port_get_phys_port_name, .ndo_get_phys_port_name = mlxsw_m_port_get_phys_port_name,
.ndo_get_port_parent_id = mlxsw_m_port_get_port_parent_id, .ndo_get_port_parent_id = mlxsw_m_port_get_port_parent_id,
.ndo_get_devlink_port = mlxsw_m_port_get_devlink_port,
}; };
static int mlxsw_m_get_module_info(struct net_device *netdev, static int mlxsw_m_get_module_info(struct net_device *netdev,
......
...@@ -1726,6 +1726,16 @@ static int mlxsw_sp_port_get_port_parent_id(struct net_device *dev, ...@@ -1726,6 +1726,16 @@ static int mlxsw_sp_port_get_port_parent_id(struct net_device *dev,
return 0; return 0;
} }
static struct devlink_port *
mlxsw_sp_port_get_devlink_port(struct net_device *dev)
{
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
return mlxsw_core_port_devlink_port_get(mlxsw_sp->core,
mlxsw_sp_port->local_port);
}
static const struct net_device_ops mlxsw_sp_port_netdev_ops = { static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
.ndo_open = mlxsw_sp_port_open, .ndo_open = mlxsw_sp_port_open,
.ndo_stop = mlxsw_sp_port_stop, .ndo_stop = mlxsw_sp_port_stop,
...@@ -1742,6 +1752,7 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = { ...@@ -1742,6 +1752,7 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = {
.ndo_get_phys_port_name = mlxsw_sp_port_get_phys_port_name, .ndo_get_phys_port_name = mlxsw_sp_port_get_phys_port_name,
.ndo_set_features = mlxsw_sp_set_features, .ndo_set_features = mlxsw_sp_set_features,
.ndo_get_port_parent_id = mlxsw_sp_port_get_port_parent_id, .ndo_get_port_parent_id = mlxsw_sp_port_get_port_parent_id,
.ndo_get_devlink_port = mlxsw_sp_port_get_devlink_port,
}; };
static void mlxsw_sp_port_get_drvinfo(struct net_device *dev, static void mlxsw_sp_port_get_drvinfo(struct net_device *dev,
......
...@@ -401,6 +401,16 @@ static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev, ...@@ -401,6 +401,16 @@ static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev,
return 0; return 0;
} }
static struct devlink_port *
mlxsw_sx_port_get_devlink_port(struct net_device *dev)
{
struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx;
return mlxsw_core_port_devlink_port_get(mlxsw_sx->core,
mlxsw_sx_port->local_port);
}
static const struct net_device_ops mlxsw_sx_port_netdev_ops = { static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
.ndo_open = mlxsw_sx_port_open, .ndo_open = mlxsw_sx_port_open,
.ndo_stop = mlxsw_sx_port_stop, .ndo_stop = mlxsw_sx_port_stop,
...@@ -409,6 +419,7 @@ static const struct net_device_ops mlxsw_sx_port_netdev_ops = { ...@@ -409,6 +419,7 @@ static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
.ndo_get_stats64 = mlxsw_sx_port_get_stats64, .ndo_get_stats64 = mlxsw_sx_port_get_stats64,
.ndo_get_phys_port_name = mlxsw_sx_port_get_phys_port_name, .ndo_get_phys_port_name = mlxsw_sx_port_get_phys_port_name,
.ndo_get_port_parent_id = mlxsw_sx_port_get_port_parent_id, .ndo_get_port_parent_id = mlxsw_sx_port_get_port_parent_id,
.ndo_get_devlink_port = mlxsw_sx_port_get_devlink_port,
}; };
static void mlxsw_sx_port_get_drvinfo(struct net_device *dev, static void mlxsw_sx_port_get_drvinfo(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