Skip to content

Commit f5d5921

Browse files
zhangjiarangregkh
authored andcommitted
RDMA/hns: Add check for the validity of sl configuration
[ Upstream commit 172505c ] According to the RoCE v1 specification, the sl (service level) 0-7 are mapped directly to priorities 0-7 respectively, sl 8-15 are reserved. The driver should verify whether the the value of sl is larger than 7, if so, an exception should be returned. Fixes: 926a01d ("RDMA/hns: Add QP operations support for hip08 SoC") Link: https://lore.kernel.org/r/1600509802-44382-5-git-send-email-liweihang@huawei.com Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com> Signed-off-by: Weihang Li <liweihang@huawei.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b347c17 commit f5d5921

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4259,11 +4259,19 @@ static int hns_roce_v2_set_path(struct ib_qp *ibqp,
42594259
V2_QPC_BYTE_28_FL_S, 0);
42604260
memcpy(context->dgid, grh->dgid.raw, sizeof(grh->dgid.raw));
42614261
memset(qpc_mask->dgid, 0, sizeof(grh->dgid.raw));
4262+
4263+
hr_qp->sl = rdma_ah_get_sl(&attr->ah_attr);
4264+
if (unlikely(hr_qp->sl > MAX_SERVICE_LEVEL)) {
4265+
ibdev_err(ibdev,
4266+
"failed to fill QPC, sl (%d) shouldn't be larger than %d.\n",
4267+
hr_qp->sl, MAX_SERVICE_LEVEL);
4268+
return -EINVAL;
4269+
}
4270+
42624271
roce_set_field(context->byte_28_at_fl, V2_QPC_BYTE_28_SL_M,
4263-
V2_QPC_BYTE_28_SL_S, rdma_ah_get_sl(&attr->ah_attr));
4272+
V2_QPC_BYTE_28_SL_S, hr_qp->sl);
42644273
roce_set_field(qpc_mask->byte_28_at_fl, V2_QPC_BYTE_28_SL_M,
42654274
V2_QPC_BYTE_28_SL_S, 0);
4266-
hr_qp->sl = rdma_ah_get_sl(&attr->ah_attr);
42674275

42684276
return 0;
42694277
}

drivers/infiniband/hw/hns/hns_roce_hw_v2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,8 @@ struct hns_roce_eq_context {
19411941
#define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_S 0
19421942
#define HNS_ROCE_V2_AEQE_EVENT_QUEUE_NUM_M GENMASK(23, 0)
19431943

1944+
#define MAX_SERVICE_LEVEL 0x7
1945+
19441946
struct hns_roce_wqe_atomic_seg {
19451947
__le64 fetchadd_swap_data;
19461948
__le64 cmp_data;

0 commit comments

Comments
 (0)