@@ -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) {