summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2018-08-28 14:45:28 +0300
committerJason Gunthorpe <jgg@mellanox.com>2018-09-06 22:35:15 +0300
commit798bba01b44b0ddf8cd6e542635b37cc9a9b739c (patch)
treeff5b83488aa1c4165f4c2037674b6c075f4b8dbf
parent2c910cb75e1fe6de52d95c8e32caedd1629a33a5 (diff)
downloadlinux-798bba01b44b0ddf8cd6e542635b37cc9a9b739c.tar.xz
RDMA/core: Fail early if unsupported QP is provided
When requested QP type is not supported for a {device, port}, return the error right away before validating all parameters during mad agent registration time. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Daniel Jurgens <danielj@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r--drivers/infiniband/core/mad.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index b8977c3db5f3..43343c4e033e 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -220,6 +220,10 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
int ret2, qpn;
u8 mgmt_class, vclass;
+ if ((qp_type == IB_QPT_SMI && !rdma_cap_ib_smi(device, port_num)) ||
+ (qp_type == IB_QPT_GSI && !rdma_cap_ib_cm(device, port_num)))
+ return ERR_PTR(-EPROTONOSUPPORT);
+
/* Validate parameters */
qpn = get_spl_qp_index(qp_type);
if (qpn == -1) {