Commit a9e546e7 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

IB/mlx5: Change debugfs to have per port contents

When there are multiple ports for single IB(RoCE) device, support
debugfs entries to be available for each port.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent b3cbd6f0
...@@ -247,21 +247,30 @@ static void mlx5_ib_set_cc_param_mask_val(void *field, int offset, ...@@ -247,21 +247,30 @@ static void mlx5_ib_set_cc_param_mask_val(void *field, int offset,
} }
} }
static int mlx5_ib_get_cc_params(struct mlx5_ib_dev *dev, int offset, u32 *var) static int mlx5_ib_get_cc_params(struct mlx5_ib_dev *dev, u8 port_num,
int offset, u32 *var)
{ {
int outlen = MLX5_ST_SZ_BYTES(query_cong_params_out); int outlen = MLX5_ST_SZ_BYTES(query_cong_params_out);
void *out; void *out;
void *field; void *field;
int err; int err;
enum mlx5_ib_cong_node_type node; enum mlx5_ib_cong_node_type node;
struct mlx5_core_dev *mdev;
/* Takes a 1-based port number */
mdev = mlx5_ib_get_native_port_mdev(dev, port_num + 1, NULL);
if (!mdev)
return -ENODEV;
out = kvzalloc(outlen, GFP_KERNEL); out = kvzalloc(outlen, GFP_KERNEL);
if (!out) if (!out) {
return -ENOMEM; err = -ENOMEM;
goto alloc_err;
}
node = mlx5_ib_param_to_node(offset); node = mlx5_ib_param_to_node(offset);
err = mlx5_cmd_query_cong_params(dev->mdev, node, out, outlen); err = mlx5_cmd_query_cong_params(mdev, node, out, outlen);
if (err) if (err)
goto free; goto free;
...@@ -270,21 +279,32 @@ static int mlx5_ib_get_cc_params(struct mlx5_ib_dev *dev, int offset, u32 *var) ...@@ -270,21 +279,32 @@ static int mlx5_ib_get_cc_params(struct mlx5_ib_dev *dev, int offset, u32 *var)
free: free:
kvfree(out); kvfree(out);
alloc_err:
mlx5_ib_put_native_port_mdev(dev, port_num + 1);
return err; return err;
} }
static int mlx5_ib_set_cc_params(struct mlx5_ib_dev *dev, int offset, u32 var) static int mlx5_ib_set_cc_params(struct mlx5_ib_dev *dev, u8 port_num,
int offset, u32 var)
{ {
int inlen = MLX5_ST_SZ_BYTES(modify_cong_params_in); int inlen = MLX5_ST_SZ_BYTES(modify_cong_params_in);
void *in; void *in;
void *field; void *field;
enum mlx5_ib_cong_node_type node; enum mlx5_ib_cong_node_type node;
struct mlx5_core_dev *mdev;
u32 attr_mask = 0; u32 attr_mask = 0;
int err; int err;
/* Takes a 1-based port number */
mdev = mlx5_ib_get_native_port_mdev(dev, port_num + 1, NULL);
if (!mdev)
return -ENODEV;
in = kvzalloc(inlen, GFP_KERNEL); in = kvzalloc(inlen, GFP_KERNEL);
if (!in) if (!in) {
return -ENOMEM; err = -ENOMEM;
goto alloc_err;
}
MLX5_SET(modify_cong_params_in, in, opcode, MLX5_SET(modify_cong_params_in, in, opcode,
MLX5_CMD_OP_MODIFY_CONG_PARAMS); MLX5_CMD_OP_MODIFY_CONG_PARAMS);
...@@ -299,8 +319,10 @@ static int mlx5_ib_set_cc_params(struct mlx5_ib_dev *dev, int offset, u32 var) ...@@ -299,8 +319,10 @@ static int mlx5_ib_set_cc_params(struct mlx5_ib_dev *dev, int offset, u32 var)
MLX5_SET(field_select_r_roce_rp, field, field_select_r_roce_rp, MLX5_SET(field_select_r_roce_rp, field, field_select_r_roce_rp,
attr_mask); attr_mask);
err = mlx5_cmd_modify_cong_params(dev->mdev, in, inlen); err = mlx5_cmd_modify_cong_params(mdev, in, inlen);
kvfree(in); kvfree(in);
alloc_err:
mlx5_ib_put_native_port_mdev(dev, port_num + 1);
return err; return err;
} }
...@@ -324,7 +346,7 @@ static ssize_t set_param(struct file *filp, const char __user *buf, ...@@ -324,7 +346,7 @@ static ssize_t set_param(struct file *filp, const char __user *buf,
if (kstrtou32(lbuf, 0, &var)) if (kstrtou32(lbuf, 0, &var))
return -EINVAL; return -EINVAL;
ret = mlx5_ib_set_cc_params(param->dev, offset, var); ret = mlx5_ib_set_cc_params(param->dev, param->port_num, offset, var);
return ret ? ret : count; return ret ? ret : count;
} }
...@@ -340,7 +362,7 @@ static ssize_t get_param(struct file *filp, char __user *buf, size_t count, ...@@ -340,7 +362,7 @@ static ssize_t get_param(struct file *filp, char __user *buf, size_t count,
if (*pos) if (*pos)
return 0; return 0;
ret = mlx5_ib_get_cc_params(param->dev, offset, &var); ret = mlx5_ib_get_cc_params(param->dev, param->port_num, offset, &var);
if (ret) if (ret)
return ret; return ret;
...@@ -362,44 +384,51 @@ static const struct file_operations dbg_cc_fops = { ...@@ -362,44 +384,51 @@ static const struct file_operations dbg_cc_fops = {
.read = get_param, .read = get_param,
}; };
void mlx5_ib_cleanup_cong_debugfs(struct mlx5_ib_dev *dev) void mlx5_ib_cleanup_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num)
{ {
if (!mlx5_debugfs_root || if (!mlx5_debugfs_root ||
!dev->dbg_cc_params || !dev->port[port_num].dbg_cc_params ||
!dev->dbg_cc_params->root) !dev->port[port_num].dbg_cc_params->root)
return; return;
debugfs_remove_recursive(dev->dbg_cc_params->root); debugfs_remove_recursive(dev->port[port_num].dbg_cc_params->root);
kfree(dev->dbg_cc_params); kfree(dev->port[port_num].dbg_cc_params);
dev->dbg_cc_params = NULL; dev->port[port_num].dbg_cc_params = NULL;
} }
int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev) int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num)
{ {
struct mlx5_ib_dbg_cc_params *dbg_cc_params; struct mlx5_ib_dbg_cc_params *dbg_cc_params;
struct mlx5_core_dev *mdev;
int i; int i;
if (!mlx5_debugfs_root) if (!mlx5_debugfs_root)
goto out; goto out;
if (!MLX5_CAP_GEN(dev->mdev, cc_query_allowed) || /* Takes a 1-based port number */
!MLX5_CAP_GEN(dev->mdev, cc_modify_allowed)) mdev = mlx5_ib_get_native_port_mdev(dev, port_num + 1, NULL);
if (!mdev)
goto out; goto out;
if (!MLX5_CAP_GEN(mdev, cc_query_allowed) ||
!MLX5_CAP_GEN(mdev, cc_modify_allowed))
goto put_mdev;
dbg_cc_params = kzalloc(sizeof(*dbg_cc_params), GFP_KERNEL); dbg_cc_params = kzalloc(sizeof(*dbg_cc_params), GFP_KERNEL);
if (!dbg_cc_params) if (!dbg_cc_params)
goto out; goto err;
dev->dbg_cc_params = dbg_cc_params; dev->port[port_num].dbg_cc_params = dbg_cc_params;
dbg_cc_params->root = debugfs_create_dir("cc_params", dbg_cc_params->root = debugfs_create_dir("cc_params",
dev->mdev->priv.dbg_root); mdev->priv.dbg_root);
if (!dbg_cc_params->root) if (!dbg_cc_params->root)
goto err; goto err;
for (i = 0; i < MLX5_IB_DBG_CC_MAX; i++) { for (i = 0; i < MLX5_IB_DBG_CC_MAX; i++) {
dbg_cc_params->params[i].offset = i; dbg_cc_params->params[i].offset = i;
dbg_cc_params->params[i].dev = dev; dbg_cc_params->params[i].dev = dev;
dbg_cc_params->params[i].port_num = port_num;
dbg_cc_params->params[i].dentry = dbg_cc_params->params[i].dentry =
debugfs_create_file(mlx5_ib_dbg_cc_name[i], debugfs_create_file(mlx5_ib_dbg_cc_name[i],
0600, dbg_cc_params->root, 0600, dbg_cc_params->root,
...@@ -408,11 +437,17 @@ int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev) ...@@ -408,11 +437,17 @@ int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev)
if (!dbg_cc_params->params[i].dentry) if (!dbg_cc_params->params[i].dentry)
goto err; goto err;
} }
out: return 0;
put_mdev:
mlx5_ib_put_native_port_mdev(dev, port_num + 1);
out:
return 0;
err: err:
mlx5_ib_warn(dev, "cong debugfs failure\n"); mlx5_ib_warn(dev, "cong debugfs failure\n");
mlx5_ib_cleanup_cong_debugfs(dev); mlx5_ib_cleanup_cong_debugfs(dev, port_num);
mlx5_ib_put_native_port_mdev(dev, port_num + 1);
/* /*
* We don't want to fail driver if debugfs failed to initialize, * We don't want to fail driver if debugfs failed to initialize,
* so we are not forwarding error to the user. * so we are not forwarding error to the user.
......
...@@ -4254,6 +4254,8 @@ static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev, ...@@ -4254,6 +4254,8 @@ static void mlx5_ib_unbind_slave_port(struct mlx5_ib_dev *ibdev,
int err; int err;
int i; int i;
mlx5_ib_cleanup_cong_debugfs(ibdev, port_num);
spin_lock(&port->mp.mpi_lock); spin_lock(&port->mp.mpi_lock);
if (!mpi->ibdev) { if (!mpi->ibdev) {
spin_unlock(&port->mp.mpi_lock); spin_unlock(&port->mp.mpi_lock);
...@@ -4331,6 +4333,10 @@ static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev, ...@@ -4331,6 +4333,10 @@ static bool mlx5_ib_bind_slave_port(struct mlx5_ib_dev *ibdev,
goto unbind; goto unbind;
} }
err = mlx5_ib_init_cong_debugfs(ibdev, port_num);
if (err)
goto unbind;
return true; return true;
unbind: unbind:
...@@ -4748,12 +4754,14 @@ static void mlx5_ib_stage_counters_cleanup(struct mlx5_ib_dev *dev) ...@@ -4748,12 +4754,14 @@ static void mlx5_ib_stage_counters_cleanup(struct mlx5_ib_dev *dev)
static int mlx5_ib_stage_cong_debugfs_init(struct mlx5_ib_dev *dev) static int mlx5_ib_stage_cong_debugfs_init(struct mlx5_ib_dev *dev)
{ {
return mlx5_ib_init_cong_debugfs(dev); return mlx5_ib_init_cong_debugfs(dev,
mlx5_core_native_port_num(dev->mdev) - 1);
} }
static void mlx5_ib_stage_cong_debugfs_cleanup(struct mlx5_ib_dev *dev) static void mlx5_ib_stage_cong_debugfs_cleanup(struct mlx5_ib_dev *dev)
{ {
mlx5_ib_cleanup_cong_debugfs(dev); mlx5_ib_cleanup_cong_debugfs(dev,
mlx5_core_native_port_num(dev->mdev) - 1);
} }
static int mlx5_ib_stage_uar_init(struct mlx5_ib_dev *dev) static int mlx5_ib_stage_uar_init(struct mlx5_ib_dev *dev)
......
...@@ -665,6 +665,7 @@ struct mlx5_ib_multiport { ...@@ -665,6 +665,7 @@ struct mlx5_ib_multiport {
struct mlx5_ib_port { struct mlx5_ib_port {
struct mlx5_ib_counters cnts; struct mlx5_ib_counters cnts;
struct mlx5_ib_multiport mp; struct mlx5_ib_multiport mp;
struct mlx5_ib_dbg_cc_params *dbg_cc_params;
}; };
struct mlx5_roce { struct mlx5_roce {
...@@ -684,6 +685,7 @@ struct mlx5_ib_dbg_param { ...@@ -684,6 +685,7 @@ struct mlx5_ib_dbg_param {
int offset; int offset;
struct mlx5_ib_dev *dev; struct mlx5_ib_dev *dev;
struct dentry *dentry; struct dentry *dentry;
u8 port_num;
}; };
enum mlx5_ib_dbg_cc_types { enum mlx5_ib_dbg_cc_types {
...@@ -813,7 +815,6 @@ struct mlx5_ib_dev { ...@@ -813,7 +815,6 @@ struct mlx5_ib_dev {
struct mlx5_sq_bfreg bfreg; struct mlx5_sq_bfreg bfreg;
struct mlx5_sq_bfreg fp_bfreg; struct mlx5_sq_bfreg fp_bfreg;
struct mlx5_ib_delay_drop delay_drop; struct mlx5_ib_delay_drop delay_drop;
struct mlx5_ib_dbg_cc_params *dbg_cc_params;
const struct mlx5_ib_profile *profile; const struct mlx5_ib_profile *profile;
/* protect the user_td */ /* protect the user_td */
...@@ -1071,8 +1072,8 @@ __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num, ...@@ -1071,8 +1072,8 @@ __be16 mlx5_get_roce_udp_sport(struct mlx5_ib_dev *dev, u8 port_num,
int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port_num, int mlx5_get_roce_gid_type(struct mlx5_ib_dev *dev, u8 port_num,
int index, enum ib_gid_type *gid_type); int index, enum ib_gid_type *gid_type);
void mlx5_ib_cleanup_cong_debugfs(struct mlx5_ib_dev *dev); void mlx5_ib_cleanup_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num);
int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev); int mlx5_ib_init_cong_debugfs(struct mlx5_ib_dev *dev, u8 port_num);
/* GSI QP helper functions */ /* GSI QP helper functions */
struct ib_qp *mlx5_ib_gsi_create_qp(struct ib_pd *pd, struct ib_qp *mlx5_ib_gsi_create_qp(struct ib_pd *pd,
......
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