Commit 732ef5ad authored by Saeed Mahameed's avatar Saeed Mahameed Committed by Leon Romanovsky

net/mlx5: PD and UAR commands via mlx5 ifc

Remove old representation of manually created PD/UAR commands layouts
and use mlx5_ifc canonical structures and defines.
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent 20ed51c6
...@@ -36,66 +36,32 @@ ...@@ -36,66 +36,32 @@
#include <linux/mlx5/cmd.h> #include <linux/mlx5/cmd.h>
#include "mlx5_core.h" #include "mlx5_core.h"
struct mlx5_alloc_pd_mbox_in {
struct mlx5_inbox_hdr hdr;
u8 rsvd[8];
};
struct mlx5_alloc_pd_mbox_out {
struct mlx5_outbox_hdr hdr;
__be32 pdn;
u8 rsvd[4];
};
struct mlx5_dealloc_pd_mbox_in {
struct mlx5_inbox_hdr hdr;
__be32 pdn;
u8 rsvd[4];
};
struct mlx5_dealloc_pd_mbox_out {
struct mlx5_outbox_hdr hdr;
u8 rsvd[8];
};
int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn) int mlx5_core_alloc_pd(struct mlx5_core_dev *dev, u32 *pdn)
{ {
struct mlx5_alloc_pd_mbox_in in; u32 out[MLX5_ST_SZ_DW(alloc_pd_out)] = {0};
struct mlx5_alloc_pd_mbox_out out; u32 in[MLX5_ST_SZ_DW(alloc_pd_in)] = {0};
int err; int err;
memset(&in, 0, sizeof(in)); MLX5_SET(alloc_pd_in, in, opcode, MLX5_CMD_OP_ALLOC_PD);
memset(&out, 0, sizeof(out)); err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ALLOC_PD); err = err ? : mlx5_cmd_status_to_err_v2(out);
err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
if (err) if (err)
return err; return err;
if (out.hdr.status) *pdn = MLX5_GET(alloc_pd_out, out, pd);
return mlx5_cmd_status_to_err(&out.hdr);
*pdn = be32_to_cpu(out.pdn) & 0xffffff;
return err; return err;
} }
EXPORT_SYMBOL(mlx5_core_alloc_pd); EXPORT_SYMBOL(mlx5_core_alloc_pd);
int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn) int mlx5_core_dealloc_pd(struct mlx5_core_dev *dev, u32 pdn)
{ {
struct mlx5_dealloc_pd_mbox_in in; u32 out[MLX5_ST_SZ_DW(dealloc_pd_out)] = {0};
struct mlx5_dealloc_pd_mbox_out out; u32 in[MLX5_ST_SZ_DW(dealloc_pd_in)] = {0};
int err; int err;
memset(&in, 0, sizeof(in)); MLX5_SET(dealloc_pd_in, in, opcode, MLX5_CMD_OP_DEALLOC_PD);
memset(&out, 0, sizeof(out)); MLX5_SET(dealloc_pd_in, in, pd, pdn);
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DEALLOC_PD); err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
in.pdn = cpu_to_be32(pdn); return err ? : mlx5_cmd_status_to_err_v2(out);
err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
if (err)
return err;
if (out.hdr.status)
return mlx5_cmd_status_to_err(&out.hdr);
return err;
} }
EXPORT_SYMBOL(mlx5_core_dealloc_pd); EXPORT_SYMBOL(mlx5_core_dealloc_pd);
...@@ -42,73 +42,33 @@ enum { ...@@ -42,73 +42,33 @@ enum {
NUM_LOW_LAT_UUARS = 4, NUM_LOW_LAT_UUARS = 4,
}; };
struct mlx5_alloc_uar_mbox_in {
struct mlx5_inbox_hdr hdr;
u8 rsvd[8];
};
struct mlx5_alloc_uar_mbox_out {
struct mlx5_outbox_hdr hdr;
__be32 uarn;
u8 rsvd[4];
};
struct mlx5_free_uar_mbox_in {
struct mlx5_inbox_hdr hdr;
__be32 uarn;
u8 rsvd[4];
};
struct mlx5_free_uar_mbox_out {
struct mlx5_outbox_hdr hdr;
u8 rsvd[8];
};
int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn) int mlx5_cmd_alloc_uar(struct mlx5_core_dev *dev, u32 *uarn)
{ {
struct mlx5_alloc_uar_mbox_in in; u32 out[MLX5_ST_SZ_DW(alloc_uar_out)] = {0};
struct mlx5_alloc_uar_mbox_out out; u32 in[MLX5_ST_SZ_DW(alloc_uar_in)] = {0};
int err; int err;
memset(&in, 0, sizeof(in)); MLX5_SET(alloc_uar_in, in, opcode, MLX5_CMD_OP_ALLOC_UAR);
memset(&out, 0, sizeof(out)); err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_ALLOC_UAR); err = err ? : mlx5_cmd_status_to_err_v2(out);
err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
if (err) if (err)
goto ex; return err;
if (out.hdr.status) {
err = mlx5_cmd_status_to_err(&out.hdr);
goto ex;
}
*uarn = be32_to_cpu(out.uarn) & 0xffffff;
ex: *uarn = MLX5_GET(alloc_uar_out, out, uar);
return err; return err;
} }
EXPORT_SYMBOL(mlx5_cmd_alloc_uar); EXPORT_SYMBOL(mlx5_cmd_alloc_uar);
int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn) int mlx5_cmd_free_uar(struct mlx5_core_dev *dev, u32 uarn)
{ {
struct mlx5_free_uar_mbox_in in; u32 out[MLX5_ST_SZ_DW(dealloc_uar_out)] = {0};
struct mlx5_free_uar_mbox_out out; u32 in[MLX5_ST_SZ_DW(dealloc_uar_in)] = {0};
int err; int err;
memset(&in, 0, sizeof(in)); MLX5_SET(dealloc_uar_in, in, opcode, MLX5_CMD_OP_DEALLOC_UAR);
memset(&out, 0, sizeof(out)); MLX5_SET(dealloc_uar_in, in, uar, uarn);
in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DEALLOC_UAR); err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
in.uarn = cpu_to_be32(uarn); return err ? : mlx5_cmd_status_to_err_v2(out);
err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out));
if (err)
goto ex;
if (out.hdr.status)
err = mlx5_cmd_status_to_err(&out.hdr);
ex:
return err;
} }
EXPORT_SYMBOL(mlx5_cmd_free_uar); EXPORT_SYMBOL(mlx5_cmd_free_uar);
......
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