提交 18f1f202 编写于 作者: Z zhaoweibo 提交者: zhangchangzhong

RDMA/hns: Add check for user-configured max_inline_data value

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I51UWX
CVE: NA

-------------------------------------------------------------

When the user-configured max_inline_data value exceeds the hardware
specification, an err needs to be returned.

Fixes: 87d3b87b ("RDMA/hns: Optimize qp param setup flow")
Signed-off-by: Nzhaoweibo <zhaoweibo3@huawei.com>
Reviewed-by: NChunzhi Hu <huchunzhi@huawei.com>
Signed-off-by: NZhang Changzhong <zhangchangzhong@huawei.com>
上级 5f77c283
......@@ -756,6 +756,22 @@ static void free_qp_buf(struct hns_roce_qp *hr_qp, struct ib_pd *ib_pd)
hns_roce_free_recv_inline_buffer(hr_qp);
}
static int set_max_inline_data(struct hns_roce_dev *hr_dev,
struct ib_qp_init_attr *init_attr)
{
if (init_attr->cap.max_inline_data > hr_dev->caps.max_sq_inline)
return -EINVAL;
if (init_attr->qp_type == IB_QPT_UD)
init_attr->cap.max_inline_data = 0;
if (init_attr->cap.max_inline_data)
init_attr->cap.max_inline_data = roundup_pow_of_two(
init_attr->cap.max_inline_data);
return 0;
}
static int set_qp_param(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
struct ib_qp_init_attr *init_attr,
struct ib_udata *udata,
......@@ -763,6 +779,10 @@ static int set_qp_param(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
{
int ret;
ret = set_max_inline_data(hr_dev, init_attr);
if (ret != 0)
return -EINVAL;
hr_qp->ibqp.qp_type = init_attr->qp_type;
if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册