Extend QP creation to get uar page index from user space, this mode can be used with the UAR dynamic mode APIs to allocate/destroy a UAR object. As part of enabling this option blocked the weird/un-supported cross channel option which uses index 0 hard-coded. This QP flag wasn't exposed to user space as part of any formal upstream release, the dynamic option can allow having valid UAR page index instead.
Unified · Split
| @@ -919,6 +919,7 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd, · 918 unmodified lines | |||
| 919 | void *qpc; | 919 | void *qpc; |
| 920 | int err; | 920 | int err; |
| 921 | u16 uid; | 921 | u16 uid; |
| 922 | u32 uar_flags; | ||
| 922 | 923 | ||
| 923 | err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd)); | 924 | err = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd)); |
| 924 | if (err) { | 925 | if (err) { |
| @@ -928,24 +929,29 @@ static int create_user_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd, · 3 unmodified lines | |||
| 928 | 929 | ||
| 929 | context = rdma_udata_to_drv_context(udata, struct mlx5_ib_ucontext, | 930 | context = rdma_udata_to_drv_context(udata, struct mlx5_ib_ucontext, |
| 930 | ibucontext); | 931 | ibucontext); |
| 931 | if (ucmd.flags & MLX5_QP_FLAG_BFREG_INDEX) { | 932 | uar_flags = ucmd.flags & (MLX5_QP_FLAG_UAR_PAGE_INDEX | |
| 933 | MLX5_QP_FLAG_BFREG_INDEX); | ||
| 934 | switch (uar_flags) { | ||
| 935 | case MLX5_QP_FLAG_UAR_PAGE_INDEX: | ||
| 936 | uar_index = ucmd.bfreg_index; | ||
| 937 | bfregn = MLX5_IB_INVALID_BFREG; | ||
| 938 | break; | ||
| 939 | case MLX5_QP_FLAG_BFREG_INDEX: | ||
| 932 | uar_index = bfregn_to_uar_index(dev, &context->bfregi, | 940 | uar_index = bfregn_to_uar_index(dev, &context->bfregi, |
| 933 | ucmd.bfreg_index, true); | 941 | ucmd.bfreg_index, true); |
| 934 | if (uar_index < 0) | 942 | if (uar_index < 0) |
| 935 | return uar_index; | 943 | return uar_index; |
| 936 | |||
| 937 | bfregn = MLX5_IB_INVALID_BFREG; | 944 | bfregn = MLX5_IB_INVALID_BFREG; |
| 938 | } else if (qp->flags & MLX5_IB_QP_CROSS_CHANNEL) { | 945 | break; |
| 939 | /* | 946 | case 0: |
| 940 | * TBD: should come from the verbs when we have the API | 947 | if (qp->flags & MLX5_IB_QP_CROSS_CHANNEL) |
| 941 | */ | 948 | return -EINVAL; |
| 942 | /* In CROSS_CHANNEL CQ and QP must use the same UAR */ | ||
| 943 | bfregn = MLX5_CROSS_CHANNEL_BFREG; | ||
| 944 | } | ||
| 945 | else { | ||
| 946 | bfregn = alloc_bfreg(dev, &context->bfregi); | 949 | bfregn = alloc_bfreg(dev, &context->bfregi); |
| 947 | if (bfregn < 0) | 950 | if (bfregn < 0) |
| 948 | return bfregn; | 951 | return bfregn; |
| 952 | break; | ||
| 953 | default: | ||
| 954 | return -EINVAL; | ||
| 949 | } | 955 | } |
| 950 | 956 | ||
| 951 | mlx5_ib_dbg(dev, "bfregn 0x%x, uar_index 0x%x\n", bfregn, uar_index); | 957 | mlx5_ib_dbg(dev, "bfregn 0x%x, uar_index 0x%x\n", bfregn, uar_index); |
| @@ -2100,6 +2106,7 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, · 1148 unmodified lines | |||
| 2100 | MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_MC | | 2106 | MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_MC | |
| 2101 | MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_UC | | 2107 | MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_UC | |
| 2102 | MLX5_QP_FLAG_TUNNEL_OFFLOADS | | 2108 | MLX5_QP_FLAG_TUNNEL_OFFLOADS | |
| 2109 | MLX5_QP_FLAG_UAR_PAGE_INDEX | | ||
| 2103 | MLX5_QP_FLAG_TYPE_DCI | | 2110 | MLX5_QP_FLAG_TYPE_DCI | |
| 2104 | MLX5_QP_FLAG_TYPE_DCT)) | 2111 | MLX5_QP_FLAG_TYPE_DCT)) |
| 2105 | return -EINVAL; | 2112 | return -EINVAL; |
| @@ -49,6 +49,7 @@ enum { · 48 unmodified lines | |||
| 49 | MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_MC = 1 << 7, | 49 | MLX5_QP_FLAG_TIR_ALLOW_SELF_LB_MC = 1 << 7, |
| 50 | MLX5_QP_FLAG_ALLOW_SCATTER_CQE = 1 << 8, | 50 | MLX5_QP_FLAG_ALLOW_SCATTER_CQE = 1 << 8, |
| 51 | MLX5_QP_FLAG_PACKET_BASED_CREDIT_MODE = 1 << 9, | 51 | MLX5_QP_FLAG_PACKET_BASED_CREDIT_MODE = 1 << 9, |
| 52 | MLX5_QP_FLAG_UAR_PAGE_INDEX = 1 << 10, | ||
| 52 | }; | 53 | }; |
| 53 | 54 | ||
| 54 | enum { | 55 | enum { |