Commit 1d045aa7 authored by Jason Gunthorpe's avatar Jason Gunthorpe

Merge branch 'mlx5_tir_icm' into rdma.git for-next

Ariel Levkovich says:

====================
The series exposes the ICM address of the receive transport
interface (TIR) of Raw Packet and RSS QPs to the user since they are
required to properly create and insert steering rules that direct flows to
these QPs.
====================

For dependencies this branch is based on mlx5-next from
git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux

* branch 'mlx5_tir_icm':
  IB/mlx5: Expose TIR ICM address to user space
  net/mlx5: Introduce new TIR creation core API
  net/mlx5: Expose TIR ICM address in command outbox
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parents 449a224c 1f1d6abb
...@@ -1403,7 +1403,8 @@ static void destroy_raw_packet_qp_tir(struct mlx5_ib_dev *dev, ...@@ -1403,7 +1403,8 @@ static void destroy_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev, static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
struct mlx5_ib_rq *rq, u32 tdn, struct mlx5_ib_rq *rq, u32 tdn,
u32 *qp_flags_en, u32 *qp_flags_en,
struct ib_pd *pd) struct ib_pd *pd,
u32 *out, int outlen)
{ {
u8 lb_flag = 0; u8 lb_flag = 0;
u32 *in; u32 *in;
...@@ -1437,8 +1438,9 @@ static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev, ...@@ -1437,8 +1438,9 @@ static int create_raw_packet_qp_tir(struct mlx5_ib_dev *dev,
MLX5_SET(tirc, tirc, self_lb_block, lb_flag); MLX5_SET(tirc, tirc, self_lb_block, lb_flag);
err = mlx5_core_create_tir(dev->mdev, in, inlen, &rq->tirn); err = mlx5_core_create_tir_out(dev->mdev, in, inlen, out, outlen);
rq->tirn = MLX5_GET(create_tir_out, out, tirn);
if (!err && MLX5_GET(tirc, tirc, self_lb_block)) { if (!err && MLX5_GET(tirc, tirc, self_lb_block)) {
err = mlx5_ib_enable_lb(dev, false, true); err = mlx5_ib_enable_lb(dev, false, true);
...@@ -1464,6 +1466,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1464,6 +1466,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
int err; int err;
u32 tdn = mucontext->tdn; u32 tdn = mucontext->tdn;
u16 uid = to_mpd(pd)->uid; u16 uid = to_mpd(pd)->uid;
u32 out[MLX5_ST_SZ_DW(create_tir_out)] = {};
if (qp->sq.wqe_cnt) { if (qp->sq.wqe_cnt) {
err = create_raw_packet_qp_tis(dev, qp, sq, tdn, pd); err = create_raw_packet_qp_tis(dev, qp, sq, tdn, pd);
...@@ -1496,7 +1499,9 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1496,7 +1499,9 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
if (err) if (err)
goto err_destroy_sq; goto err_destroy_sq;
err = create_raw_packet_qp_tir(dev, rq, tdn, &qp->flags_en, pd); err = create_raw_packet_qp_tir(
dev, rq, tdn, &qp->flags_en, pd, out,
MLX5_ST_SZ_BYTES(create_tir_out));
if (err) if (err)
goto err_destroy_rq; goto err_destroy_rq;
...@@ -1505,6 +1510,20 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1505,6 +1510,20 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
resp->comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_RQN; resp->comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_RQN;
resp->tirn = rq->tirn; resp->tirn = rq->tirn;
resp->comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_TIRN; resp->comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_TIRN;
if (MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev, sw_owner)) {
resp->tir_icm_addr = MLX5_GET(
create_tir_out, out, icm_address_31_0);
resp->tir_icm_addr |=
(u64)MLX5_GET(create_tir_out, out,
icm_address_39_32)
<< 32;
resp->tir_icm_addr |=
(u64)MLX5_GET(create_tir_out, out,
icm_address_63_40)
<< 40;
resp->comp_mask |=
MLX5_IB_CREATE_QP_RESP_MASK_TIR_ICM_ADDR;
}
} }
} }
...@@ -1578,8 +1597,10 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1578,8 +1597,10 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
udata, struct mlx5_ib_ucontext, ibucontext); udata, struct mlx5_ib_ucontext, ibucontext);
struct mlx5_ib_create_qp_resp resp = {}; struct mlx5_ib_create_qp_resp resp = {};
int inlen; int inlen;
int outlen;
int err; int err;
u32 *in; u32 *in;
u32 *out;
void *tirc; void *tirc;
void *hfso; void *hfso;
u32 selected_fields = 0; u32 selected_fields = 0;
...@@ -1659,10 +1680,12 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1659,10 +1680,12 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
} }
inlen = MLX5_ST_SZ_BYTES(create_tir_in); inlen = MLX5_ST_SZ_BYTES(create_tir_in);
in = kvzalloc(inlen, GFP_KERNEL); outlen = MLX5_ST_SZ_BYTES(create_tir_out);
in = kvzalloc(inlen + outlen, GFP_KERNEL);
if (!in) if (!in)
return -ENOMEM; return -ENOMEM;
out = in + MLX5_ST_SZ_DW(create_tir_in);
MLX5_SET(create_tir_in, in, uid, to_mpd(pd)->uid); MLX5_SET(create_tir_in, in, uid, to_mpd(pd)->uid);
tirc = MLX5_ADDR_OF(create_tir_in, in, ctx); tirc = MLX5_ADDR_OF(create_tir_in, in, ctx);
MLX5_SET(tirc, tirc, disp_type, MLX5_SET(tirc, tirc, disp_type,
...@@ -1774,8 +1797,9 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1774,8 +1797,9 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
MLX5_SET(rx_hash_field_select, hfso, selected_fields, selected_fields); MLX5_SET(rx_hash_field_select, hfso, selected_fields, selected_fields);
create_tir: create_tir:
err = mlx5_core_create_tir(dev->mdev, in, inlen, &qp->rss_qp.tirn); err = mlx5_core_create_tir_out(dev->mdev, in, inlen, out, outlen);
qp->rss_qp.tirn = MLX5_GET(create_tir_out, out, tirn);
if (!err && MLX5_GET(tirc, tirc, self_lb_block)) { if (!err && MLX5_GET(tirc, tirc, self_lb_block)) {
err = mlx5_ib_enable_lb(dev, false, true); err = mlx5_ib_enable_lb(dev, false, true);
...@@ -1790,6 +1814,18 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, ...@@ -1790,6 +1814,18 @@ static int create_rss_raw_qp_tir(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,
if (mucontext->devx_uid) { if (mucontext->devx_uid) {
resp.comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_TIRN; resp.comp_mask |= MLX5_IB_CREATE_QP_RESP_MASK_TIRN;
resp.tirn = qp->rss_qp.tirn; resp.tirn = qp->rss_qp.tirn;
if (MLX5_CAP_FLOWTABLE_NIC_RX(dev->mdev, sw_owner)) {
resp.tir_icm_addr =
MLX5_GET(create_tir_out, out, icm_address_31_0);
resp.tir_icm_addr |= (u64)MLX5_GET(create_tir_out, out,
icm_address_39_32)
<< 32;
resp.tir_icm_addr |= (u64)MLX5_GET(create_tir_out, out,
icm_address_63_40)
<< 40;
resp.comp_mask |=
MLX5_IB_CREATE_QP_RESP_MASK_TIR_ICM_ADDR;
}
} }
err = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp))); err = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp)));
......
...@@ -182,16 +182,24 @@ int mlx5_core_query_sq_state(struct mlx5_core_dev *dev, u32 sqn, u8 *state) ...@@ -182,16 +182,24 @@ int mlx5_core_query_sq_state(struct mlx5_core_dev *dev, u32 sqn, u8 *state)
} }
EXPORT_SYMBOL_GPL(mlx5_core_query_sq_state); EXPORT_SYMBOL_GPL(mlx5_core_query_sq_state);
int mlx5_core_create_tir_out(struct mlx5_core_dev *dev,
u32 *in, int inlen,
u32 *out, int outlen)
{
MLX5_SET(create_tir_in, in, opcode, MLX5_CMD_OP_CREATE_TIR);
return mlx5_cmd_exec(dev, in, inlen, out, outlen);
}
EXPORT_SYMBOL(mlx5_core_create_tir_out);
int mlx5_core_create_tir(struct mlx5_core_dev *dev, u32 *in, int inlen, int mlx5_core_create_tir(struct mlx5_core_dev *dev, u32 *in, int inlen,
u32 *tirn) u32 *tirn)
{ {
u32 out[MLX5_ST_SZ_DW(create_tir_out)] = {0}; u32 out[MLX5_ST_SZ_DW(create_tir_out)] = {};
int err; int err;
MLX5_SET(create_tir_in, in, opcode, MLX5_CMD_OP_CREATE_TIR); err = mlx5_core_create_tir_out(dev, in, inlen,
out, sizeof(out));
memset(out, 0, sizeof(out));
err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
if (!err) if (!err)
*tirn = MLX5_GET(create_tir_out, out, tirn); *tirn = MLX5_GET(create_tir_out, out, tirn);
......
...@@ -80,6 +80,14 @@ enum { ...@@ -80,6 +80,14 @@ enum {
MLX5_SHARED_RESOURCE_UID = 0xffff, MLX5_SHARED_RESOURCE_UID = 0xffff,
}; };
enum {
MLX5_OBJ_TYPE_SW_ICM = 0x0008,
};
enum {
MLX5_GENERAL_OBJ_TYPES_CAP_SW_ICM = (1ULL << MLX5_OBJ_TYPE_SW_ICM),
};
enum { enum {
MLX5_CMD_OP_QUERY_HCA_CAP = 0x100, MLX5_CMD_OP_QUERY_HCA_CAP = 0x100,
MLX5_CMD_OP_QUERY_ADAPTER = 0x101, MLX5_CMD_OP_QUERY_ADAPTER = 0x101,
...@@ -357,7 +365,8 @@ struct mlx5_ifc_flow_table_prop_layout_bits { ...@@ -357,7 +365,8 @@ struct mlx5_ifc_flow_table_prop_layout_bits {
u8 pop_vlan_2[0x1]; u8 pop_vlan_2[0x1];
u8 push_vlan_2[0x1]; u8 push_vlan_2[0x1];
u8 reformat_and_vlan_action[0x1]; u8 reformat_and_vlan_action[0x1];
u8 reserved_at_10[0x2]; u8 reserved_at_10[0x1];
u8 sw_owner[0x1];
u8 reformat_l3_tunnel_to_l2[0x1]; u8 reformat_l3_tunnel_to_l2[0x1];
u8 reformat_l2_to_l3_tunnel[0x1]; u8 reformat_l2_to_l3_tunnel[0x1];
u8 reformat_and_modify_action[0x1]; u8 reformat_and_modify_action[0x1];
...@@ -770,7 +779,19 @@ struct mlx5_ifc_device_mem_cap_bits { ...@@ -770,7 +779,19 @@ struct mlx5_ifc_device_mem_cap_bits {
u8 max_memic_size[0x20]; u8 max_memic_size[0x20];
u8 reserved_at_c0[0x740]; u8 steering_sw_icm_start_address[0x40];
u8 reserved_at_100[0x8];
u8 log_header_modify_sw_icm_size[0x8];
u8 reserved_at_110[0x2];
u8 log_sw_icm_alloc_granularity[0x6];
u8 log_steering_sw_icm_size[0x8];
u8 reserved_at_120[0x20];
u8 header_modify_sw_icm_start_address[0x40];
u8 reserved_at_180[0x680];
}; };
enum { enum {
...@@ -919,6 +940,7 @@ enum { ...@@ -919,6 +940,7 @@ enum {
enum { enum {
MLX5_UCTX_CAP_RAW_TX = 1UL << 0, MLX5_UCTX_CAP_RAW_TX = 1UL << 0,
MLX5_UCTX_CAP_INTERNAL_DEV_RES = 1UL << 1,
}; };
struct mlx5_ifc_cmd_hca_cap_bits { struct mlx5_ifc_cmd_hca_cap_bits {
...@@ -2920,6 +2942,7 @@ enum { ...@@ -2920,6 +2942,7 @@ enum {
MLX5_MKC_ACCESS_MODE_MTT = 0x1, MLX5_MKC_ACCESS_MODE_MTT = 0x1,
MLX5_MKC_ACCESS_MODE_KLMS = 0x2, MLX5_MKC_ACCESS_MODE_KLMS = 0x2,
MLX5_MKC_ACCESS_MODE_KSM = 0x3, MLX5_MKC_ACCESS_MODE_KSM = 0x3,
MLX5_MKC_ACCESS_MODE_SW_ICM = 0x4,
MLX5_MKC_ACCESS_MODE_MEMIC = 0x5, MLX5_MKC_ACCESS_MODE_MEMIC = 0x5,
}; };
...@@ -6874,14 +6897,14 @@ struct mlx5_ifc_create_tis_in_bits { ...@@ -6874,14 +6897,14 @@ struct mlx5_ifc_create_tis_in_bits {
struct mlx5_ifc_create_tir_out_bits { struct mlx5_ifc_create_tir_out_bits {
u8 status[0x8]; u8 status[0x8];
u8 reserved_at_8[0x18]; u8 icm_address_63_40[0x18];
u8 syndrome[0x20]; u8 syndrome[0x20];
u8 reserved_at_40[0x8]; u8 icm_address_39_32[0x8];
u8 tirn[0x18]; u8 tirn[0x18];
u8 reserved_at_60[0x20]; u8 icm_address_31_0[0x20];
}; };
struct mlx5_ifc_create_tir_in_bits { struct mlx5_ifc_create_tir_in_bits {
...@@ -9491,6 +9514,19 @@ struct mlx5_ifc_uctx_bits { ...@@ -9491,6 +9514,19 @@ struct mlx5_ifc_uctx_bits {
u8 reserved_at_20[0x160]; u8 reserved_at_20[0x160];
}; };
struct mlx5_ifc_sw_icm_bits {
u8 modify_field_select[0x40];
u8 reserved_at_40[0x18];
u8 log_sw_icm_size[0x8];
u8 reserved_at_60[0x20];
u8 sw_icm_start_addr[0x40];
u8 reserved_at_c0[0x140];
};
struct mlx5_ifc_create_umem_in_bits { struct mlx5_ifc_create_umem_in_bits {
u8 opcode[0x10]; u8 opcode[0x10];
u8 uid[0x10]; u8 uid[0x10];
...@@ -9528,6 +9564,11 @@ struct mlx5_ifc_destroy_uctx_in_bits { ...@@ -9528,6 +9564,11 @@ struct mlx5_ifc_destroy_uctx_in_bits {
u8 reserved_at_60[0x20]; u8 reserved_at_60[0x20];
}; };
struct mlx5_ifc_create_sw_icm_in_bits {
struct mlx5_ifc_general_obj_in_cmd_hdr_bits hdr;
struct mlx5_ifc_sw_icm_bits sw_icm;
};
struct mlx5_ifc_mtrc_string_db_param_bits { struct mlx5_ifc_mtrc_string_db_param_bits {
u8 string_db_base_address[0x20]; u8 string_db_base_address[0x20];
......
...@@ -50,6 +50,9 @@ int mlx5_core_query_sq(struct mlx5_core_dev *dev, u32 sqn, u32 *out); ...@@ -50,6 +50,9 @@ int mlx5_core_query_sq(struct mlx5_core_dev *dev, u32 sqn, u32 *out);
int mlx5_core_query_sq_state(struct mlx5_core_dev *dev, u32 sqn, u8 *state); int mlx5_core_query_sq_state(struct mlx5_core_dev *dev, u32 sqn, u8 *state);
int mlx5_core_create_tir(struct mlx5_core_dev *dev, u32 *in, int inlen, int mlx5_core_create_tir(struct mlx5_core_dev *dev, u32 *in, int inlen,
u32 *tirn); u32 *tirn);
int mlx5_core_create_tir_out(struct mlx5_core_dev *dev,
u32 *in, int inlen,
u32 *out, int outlen);
int mlx5_core_modify_tir(struct mlx5_core_dev *dev, u32 tirn, u32 *in, int mlx5_core_modify_tir(struct mlx5_core_dev *dev, u32 tirn, u32 *in,
int inlen); int inlen);
void mlx5_core_destroy_tir(struct mlx5_core_dev *dev, u32 tirn); void mlx5_core_destroy_tir(struct mlx5_core_dev *dev, u32 tirn);
......
...@@ -360,6 +360,7 @@ enum mlx5_ib_create_qp_resp_mask { ...@@ -360,6 +360,7 @@ enum mlx5_ib_create_qp_resp_mask {
MLX5_IB_CREATE_QP_RESP_MASK_TISN = 1UL << 1, MLX5_IB_CREATE_QP_RESP_MASK_TISN = 1UL << 1,
MLX5_IB_CREATE_QP_RESP_MASK_RQN = 1UL << 2, MLX5_IB_CREATE_QP_RESP_MASK_RQN = 1UL << 2,
MLX5_IB_CREATE_QP_RESP_MASK_SQN = 1UL << 3, MLX5_IB_CREATE_QP_RESP_MASK_SQN = 1UL << 3,
MLX5_IB_CREATE_QP_RESP_MASK_TIR_ICM_ADDR = 1UL << 4,
}; };
struct mlx5_ib_create_qp_resp { struct mlx5_ib_create_qp_resp {
...@@ -371,6 +372,7 @@ struct mlx5_ib_create_qp_resp { ...@@ -371,6 +372,7 @@ struct mlx5_ib_create_qp_resp {
__u32 rqn; __u32 rqn;
__u32 sqn; __u32 sqn;
__u32 reserved1; __u32 reserved1;
__u64 tir_icm_addr;
}; };
struct mlx5_ib_alloc_mw { struct mlx5_ib_alloc_mw {
......
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