]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mlxsw: Implement ndo_get_devlink_port
authorJiri Pirko <jiri@mellanox.com>
Thu, 28 Mar 2019 12:56:38 +0000 (13:56 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 Mar 2019 19:55:30 +0000 (12:55 -0700)
In order for devlink compat functions to work, implement
ndo_get_devlink_port.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/mellanox/mlxsw/core.h
drivers/net/ethernet/mellanox/mlxsw/minimal.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/switchx2.c

index e70bb673eeecf35327ecf321517ba87a51781dad..aa71aeb44101996152935814f284fe05589e11a7 100644 (file)
@@ -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);
 
+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,
                                    const char *buf, size_t size)
 {
index 74e95e943b242c0f69978c79900d467b600e033b..cb870502f04c31252da4a3ecd2d54dc7476be985 100644 (file)
@@ -178,6 +178,9 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
                                                u8 local_port);
 int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core,
                                       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);
 bool mlxsw_core_schedule_work(struct work_struct *work);
index 0ee1656609f53284e33817104480a8a80d0436a7..d6e6042223f98391604bb1b793ce17583048e56c 100644 (file)
@@ -73,11 +73,22 @@ static int mlxsw_m_port_get_port_parent_id(struct net_device *dev,
        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 = {
        .ndo_open               = 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_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,
index eaf86c4c2f6c9313121598000ef8c7031d0b30ed..1225fa50f36f3dcfdf3c141be7db445e142a3b0c 100644 (file)
@@ -1726,6 +1726,16 @@ static int mlxsw_sp_port_get_port_parent_id(struct net_device *dev,
        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 = {
        .ndo_open               = mlxsw_sp_port_open,
        .ndo_stop               = mlxsw_sp_port_stop,
@@ -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_set_features       = mlxsw_sp_set_features,
        .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,
index 568883fc40df8f0b8939152da5df396121a322de..696b8c8547bc95781bec1cff7b08fbfd7f7f18ae 100644 (file)
@@ -401,6 +401,16 @@ static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev,
        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 = {
        .ndo_open               = mlxsw_sx_port_open,
        .ndo_stop               = mlxsw_sx_port_stop,
@@ -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_phys_port_name = mlxsw_sx_port_get_phys_port_name,
        .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,