mlxsw: use devlink helper to generate physical port name
Since devlink knows the info needed to generate the physical port name in a generic way for all devlink users, use the helper to do the job. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
da07739248
commit
ec932fbda7
@ -1763,6 +1763,17 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(mlxsw_core_port_type_get);
|
EXPORT_SYMBOL(mlxsw_core_port_type_get);
|
||||||
|
|
||||||
|
int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core,
|
||||||
|
u8 local_port, char *name, size_t len)
|
||||||
|
{
|
||||||
|
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_get_phys_port_name(devlink_port, name, len);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(mlxsw_core_port_get_phys_port_name);
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -209,6 +209,8 @@ void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
|
|||||||
void *port_driver_priv);
|
void *port_driver_priv);
|
||||||
enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
|
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,
|
||||||
|
u8 local_port, char *name, size_t len);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -1238,21 +1238,10 @@ static int mlxsw_sp_port_get_phys_port_name(struct net_device *dev, char *name,
|
|||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
|
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
|
||||||
u8 module = mlxsw_sp_port->mapping.module;
|
|
||||||
u8 width = mlxsw_sp_port->mapping.width;
|
|
||||||
u8 lane = mlxsw_sp_port->mapping.lane;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
if (!mlxsw_sp_port->split)
|
return mlxsw_core_port_get_phys_port_name(mlxsw_sp_port->mlxsw_sp->core,
|
||||||
err = snprintf(name, len, "p%d", module + 1);
|
mlxsw_sp_port->local_port,
|
||||||
else
|
name, len);
|
||||||
err = snprintf(name, len, "p%ds%d", module + 1,
|
|
||||||
lane / width);
|
|
||||||
|
|
||||||
if (err >= len)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct mlxsw_sp_port_mall_tc_entry *
|
static struct mlxsw_sp_port_mall_tc_entry *
|
||||||
|
@ -417,13 +417,10 @@ static int mlxsw_sx_port_get_phys_port_name(struct net_device *dev, char *name,
|
|||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
|
struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev);
|
||||||
int err;
|
|
||||||
|
|
||||||
err = snprintf(name, len, "p%d", mlxsw_sx_port->mapping.module + 1);
|
return mlxsw_core_port_get_phys_port_name(mlxsw_sx_port->mlxsw_sx->core,
|
||||||
if (err >= len)
|
mlxsw_sx_port->local_port,
|
||||||
return -EINVAL;
|
name, len);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
|
static const struct net_device_ops mlxsw_sx_port_netdev_ops = {
|
||||||
|
Loading…
Reference in New Issue
Block a user