Skip to content

Commit 0b10710

Browse files
Eli Cohendavem330
authored andcommitted
net/mlx5_core: Modify enable/disable hca functions
Modify these functions to have func_id argument to state which device we are referring to. This is done as a preparation for SRIOV support where a PF driver needs to control its virtual functions. Signed-off-by: Eli Cohen <eli@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 24e2416 commit 0b10710

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -462,42 +462,39 @@ static int set_hca_ctrl(struct mlx5_core_dev *dev)
462462
return err;
463463
}
464464

465-
static int mlx5_core_enable_hca(struct mlx5_core_dev *dev)
465+
int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id)
466466
{
467+
u32 out[MLX5_ST_SZ_DW(enable_hca_out)];
468+
u32 in[MLX5_ST_SZ_DW(enable_hca_in)];
467469
int err;
468-
struct mlx5_enable_hca_mbox_in in;
469-
struct mlx5_enable_hca_mbox_out out;
470470

471-
memset(&in, 0, sizeof(in));
472-
memset(&out, 0, sizeof(out));
473-
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ENABLE_HCA);
471+
memset(in, 0, sizeof(in));
472+
MLX5_SET(enable_hca_in, in, opcode, MLX5_CMD_OP_ENABLE_HCA);
473+
MLX5_SET(enable_hca_in, in, function_id, func_id);
474+
memset(out, 0, sizeof(out));
475+
474476
err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
475477
if (err)
476478
return err;
477479

478-
if (out.hdr.status)
479-
return mlx5_cmd_status_to_err(&out.hdr);
480-
481-
return 0;
480+
return mlx5_cmd_status_to_err_v2(out);
482481
}
483482

484-
static int mlx5_core_disable_hca(struct mlx5_core_dev *dev)
483+
int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id)
485484
{
485+
u32 out[MLX5_ST_SZ_DW(disable_hca_out)];
486+
u32 in[MLX5_ST_SZ_DW(disable_hca_in)];
486487
int err;
487-
struct mlx5_disable_hca_mbox_in in;
488-
struct mlx5_disable_hca_mbox_out out;
489488

490-
memset(&in, 0, sizeof(in));
491-
memset(&out, 0, sizeof(out));
492-
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DISABLE_HCA);
493-
err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
489+
memset(in, 0, sizeof(in));
490+
MLX5_SET(disable_hca_in, in, opcode, MLX5_CMD_OP_DISABLE_HCA);
491+
MLX5_SET(disable_hca_in, in, function_id, func_id);
492+
memset(out, 0, sizeof(out));
493+
err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
494494
if (err)
495495
return err;
496496

497-
if (out.hdr.status)
498-
return mlx5_cmd_status_to_err(&out.hdr);
499-
500-
return 0;
497+
return mlx5_cmd_status_to_err_v2(out);
501498
}
502499

503500
static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
@@ -942,7 +939,7 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
942939

943940
mlx5_pagealloc_init(dev);
944941

945-
err = mlx5_core_enable_hca(dev);
942+
err = mlx5_core_enable_hca(dev, 0);
946943
if (err) {
947944
dev_err(&pdev->dev, "enable hca failed\n");
948945
goto err_pagealloc_cleanup;
@@ -1106,7 +1103,7 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
11061103
mlx5_reclaim_startup_pages(dev);
11071104

11081105
err_disable_hca:
1109-
mlx5_core_disable_hca(dev);
1106+
mlx5_core_disable_hca(dev, 0);
11101107

11111108
err_pagealloc_cleanup:
11121109
mlx5_pagealloc_cleanup(dev);
@@ -1149,7 +1146,7 @@ static int mlx5_unload_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
11491146
}
11501147
mlx5_pagealloc_stop(dev);
11511148
mlx5_reclaim_startup_pages(dev);
1152-
mlx5_core_disable_hca(dev);
1149+
mlx5_core_disable_hca(dev, 0);
11531150
mlx5_pagealloc_cleanup(dev);
11541151
mlx5_cmd_cleanup(dev);
11551152

drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ void mlx5_core_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event,
9090
unsigned long param);
9191
void mlx5_enter_error_state(struct mlx5_core_dev *dev);
9292
void mlx5_disable_device(struct mlx5_core_dev *dev);
93+
int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id);
94+
int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id);
9395

9496
void mlx5e_init(void);
9597
void mlx5e_cleanup(void);

0 commit comments

Comments
 (0)