Skip to content

Commit 284ef80

Browse files
jpirkodavem330
authored andcommitted
mlxsw: core: Add devlink port splitter callbacks
Add middle layer in mlxsw core code to forward port split/unsplit calls into specific ASIC drivers. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c474550 commit 284ef80

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

drivers/net/ethernet/mellanox/mlxsw/core.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,38 @@ static void mlxsw_core_debugfs_fini(struct mlxsw_core *mlxsw_core)
785785
debugfs_remove_recursive(mlxsw_core->dbg_dir);
786786
}
787787

788+
static int mlxsw_devlink_port_split(struct devlink *devlink,
789+
unsigned int port_index,
790+
unsigned int count)
791+
{
792+
struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
793+
794+
if (port_index >= MLXSW_PORT_MAX_PORTS)
795+
return -EINVAL;
796+
if (!mlxsw_core->driver->port_split)
797+
return -EOPNOTSUPP;
798+
return mlxsw_core->driver->port_split(mlxsw_core->driver_priv,
799+
port_index, count);
800+
}
801+
802+
static int mlxsw_devlink_port_unsplit(struct devlink *devlink,
803+
unsigned int port_index)
804+
{
805+
struct mlxsw_core *mlxsw_core = devlink_priv(devlink);
806+
807+
if (port_index >= MLXSW_PORT_MAX_PORTS)
808+
return -EINVAL;
809+
if (!mlxsw_core->driver->port_unsplit)
810+
return -EOPNOTSUPP;
811+
return mlxsw_core->driver->port_unsplit(mlxsw_core->driver_priv,
812+
port_index);
813+
}
814+
815+
static const struct devlink_ops mlxsw_devlink_ops = {
816+
.port_split = mlxsw_devlink_port_split,
817+
.port_unsplit = mlxsw_devlink_port_unsplit,
818+
};
819+
788820
int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
789821
const struct mlxsw_bus *mlxsw_bus,
790822
void *bus_priv)
@@ -800,7 +832,7 @@ int mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
800832
if (!mlxsw_driver)
801833
return -EINVAL;
802834
alloc_size = sizeof(*mlxsw_core) + mlxsw_driver->priv_size;
803-
devlink = devlink_alloc(NULL, alloc_size);
835+
devlink = devlink_alloc(&mlxsw_devlink_ops, alloc_size);
804836
if (!devlink) {
805837
err = -ENOMEM;
806838
goto err_devlink_alloc;

drivers/net/ethernet/mellanox/mlxsw/core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ struct mlxsw_driver {
186186
int (*init)(void *driver_priv, struct mlxsw_core *mlxsw_core,
187187
const struct mlxsw_bus_info *mlxsw_bus_info);
188188
void (*fini)(void *driver_priv);
189+
int (*port_split)(void *driver_priv, u8 local_port, unsigned int count);
190+
int (*port_unsplit)(void *driver_priv, u8 local_port);
189191
void (*txhdr_construct)(struct sk_buff *skb,
190192
const struct mlxsw_tx_info *tx_info);
191193
u8 txhdr_len;

0 commit comments

Comments
 (0)