Skip to content

Commit 8e73cdb

Browse files
Knut OmangMukesh Kacker
authored andcommitted
ib_uverbs: Avoid vendor specific masking of attributes in query_qp
This commit removes the implementation and use of the modify_qp_mask helper function from the generic OFED implementation and into individual device drivers. Like with use of the ib_modify_qp_is_ok function it should be up to each device driver how to handle bits set in the attribute masks. With the modify_qp_mask function applied in the generic code, drivers would not see the bits that the user process actually sets. The restrictions imposed by the filter are also beyond what is imposed by the Infiniband standard, and would also limit future drivers or hardware from checking for unsupported or invalid settings. Orabug: 20930262 Signed-off-by: Knut Omang <[email protected]> Signed-off-by: Mukesh Kacker <[email protected]>
1 parent 0b86060 commit 8e73cdb

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,20 +2013,6 @@ ssize_t ib_uverbs_query_qp(struct ib_uverbs_file *file,
20132013
return ret ? ret : in_len;
20142014
}
20152015

2016-
/* Remove ignored fields set in the attribute mask */
2017-
static int modify_qp_mask(enum ib_qp_type qp_type, int mask)
2018-
{
2019-
switch (qp_type) {
2020-
case IB_QPT_XRC_INI:
2021-
return mask & ~(IB_QP_MAX_DEST_RD_ATOMIC | IB_QP_MIN_RNR_TIMER);
2022-
case IB_QPT_XRC_TGT:
2023-
return mask & ~(IB_QP_MAX_QP_RD_ATOMIC | IB_QP_RETRY_CNT |
2024-
IB_QP_RNR_RETRY);
2025-
default:
2026-
return mask;
2027-
}
2028-
}
2029-
20302016
ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
20312017
const char __user *buf, int in_len,
20322018
int out_len)
@@ -2103,10 +2089,9 @@ ssize_t ib_uverbs_modify_qp(struct ib_uverbs_file *file,
21032089
ret = ib_resolve_eth_l2_attrs(qp, attr, &cmd.attr_mask);
21042090
if (ret)
21052091
goto release_qp;
2106-
ret = qp->device->modify_qp(qp, attr,
2107-
modify_qp_mask(qp->qp_type, cmd.attr_mask), &udata);
2092+
ret = qp->device->modify_qp(qp, attr, cmd.attr_mask, &udata);
21082093
} else {
2109-
ret = ib_modify_qp(qp, attr, modify_qp_mask(qp->qp_type, cmd.attr_mask));
2094+
ret = ib_modify_qp(qp, attr, cmd.attr_mask);
21102095
}
21112096

21122097
if (ret)

drivers/infiniband/hw/mlx4/qp.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,20 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
19481948
return err;
19491949
}
19501950

1951+
/* filter out ignored fields set in the attribute mask */
1952+
static int modify_qp_mask(enum ib_qp_type qp_type, int mask)
1953+
{
1954+
switch (qp_type) {
1955+
case IB_QPT_XRC_INI:
1956+
return mask & ~(IB_QP_MAX_DEST_RD_ATOMIC | IB_QP_MIN_RNR_TIMER);
1957+
case IB_QPT_XRC_TGT:
1958+
return mask & ~(IB_QP_MAX_QP_RD_ATOMIC | IB_QP_RETRY_CNT |
1959+
IB_QP_RNR_RETRY);
1960+
default:
1961+
return mask;
1962+
}
1963+
}
1964+
19511965
int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
19521966
int attr_mask, struct ib_udata *udata)
19531967
{
@@ -1956,6 +1970,10 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
19561970
enum ib_qp_state cur_state, new_state;
19571971
int err = -EINVAL;
19581972
int ll;
1973+
1974+
if (udata)
1975+
attr_mask = modify_qp_mask(ibqp->qp_type, attr_mask);
1976+
19591977
mutex_lock(&qp->mutex);
19601978

19611979
cur_state = attr_mask & IB_QP_CUR_STATE ? attr->cur_qp_state : qp->state;

drivers/infiniband/hw/mlx5/qp.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,20 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
17711771
return err;
17721772
}
17731773

1774+
/* filter out ignored fields set in the attribute mask */
1775+
static int modify_qp_mask(enum ib_qp_type qp_type, int mask)
1776+
{
1777+
switch (qp_type) {
1778+
case IB_QPT_XRC_INI:
1779+
return mask & ~(IB_QP_MAX_DEST_RD_ATOMIC | IB_QP_MIN_RNR_TIMER);
1780+
case IB_QPT_XRC_TGT:
1781+
return mask & ~(IB_QP_MAX_QP_RD_ATOMIC | IB_QP_RETRY_CNT |
1782+
IB_QP_RNR_RETRY);
1783+
default:
1784+
return mask;
1785+
}
1786+
}
1787+
17741788
int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
17751789
int attr_mask, struct ib_udata *udata)
17761790
{
@@ -1781,6 +1795,9 @@ int mlx5_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
17811795
int err = -EINVAL;
17821796
int port;
17831797

1798+
if (udata)
1799+
attr_mask = modify_qp_mask(ibqp->qp_type, attr_mask);
1800+
17841801
gen = &dev->mdev->caps.gen;
17851802
mutex_lock(&qp->mutex);
17861803

0 commit comments

Comments
 (0)