From: Ira Weiny <ira.we...@intel.com> If the registration specifies an OPA MAD class version and the device does not support jumbo MADs, fail the MAD registration.
Signed-off-by: Ira Weiny <ira.we...@intel.com> --- drivers/infiniband/core/mad.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index a3ba37f..0ddfbd7 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c @@ -238,6 +238,14 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, goto error1; } + /* Validate device and port */ + port_priv = ib_get_mad_port(device, port_num); + if (!port_priv) { + dev_notice(&device->dev, "ib_register_mad_agent: Invalid port\n"); + ret = ERR_PTR(-ENODEV); + goto error1; + } + /* Validate MAD registration request if supplied */ if (mad_reg_req) { if (mad_reg_req->mgmt_class_version >= MAX_MGMT_VERSION) { @@ -246,6 +254,12 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, mad_reg_req->mgmt_class_version); goto error1; } + if (mad_reg_req->mgmt_class_version >= OPA_MIN_CLASS_VERSION + && !port_priv->qp_info[qpn].supports_jumbo_mads) { + dev_notice(&device->dev, + "ib_register_mad_agent: OPA class Version specified on a device which does not support jumbo MAD's\n"); + goto error1; + } if (!recv_handler) { dev_notice(&device->dev, "ib_register_mad_agent: no recv_handler\n"); @@ -323,14 +337,6 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, goto error1; } - /* Validate device and port */ - port_priv = ib_get_mad_port(device, port_num); - if (!port_priv) { - dev_notice(&device->dev, "ib_register_mad_agent: Invalid port\n"); - ret = ERR_PTR(-ENODEV); - goto error1; - } - /* Verify the QP requested is supported. For example, Ethernet devices * will not have QP0 */ if (!port_priv->qp_info[qpn].qp) { -- 1.8.2 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html