Skip to content

Commit

Permalink
RDMA/srpt: Fix handling of SR-IOV and iWARP ports
Browse files Browse the repository at this point in the history
Management datagrams (MADs) are not supported by SR-IOV VFs nor by iWARP
ports. Support SR-IOV VFs and iWARP ports by only logging an error message
if MAD handler registration fails.

Link: https://lore.kernel.org/r/20190930231707.48259-10-bvanassche@acm.org
Cc: Honggang LI <honli@redhat.com>
Cc: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Bart Van Assche authored and Jason Gunthorpe committed Oct 4, 2019
1 parent fdbcf5c commit 09f8a14
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions drivers/infiniband/ulp/srpt/ib_srpt.c
Original file line number Diff line number Diff line change
@@ -556,24 +556,16 @@ static int srpt_refresh_port(struct srpt_port *sport)
struct ib_port_attr port_attr;
int ret;

memset(&port_modify, 0, sizeof(port_modify));
port_modify.set_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP;
port_modify.clr_port_cap_mask = 0;

ret = ib_modify_port(sport->sdev->device, sport->port, 0, &port_modify);
if (ret)
goto err_mod_port;

ret = ib_query_port(sport->sdev->device, sport->port, &port_attr);
if (ret)
goto err_query_port;
return ret;

sport->sm_lid = port_attr.sm_lid;
sport->lid = port_attr.lid;

ret = rdma_query_gid(sport->sdev->device, sport->port, 0, &sport->gid);
if (ret)
goto err_query_port;
return ret;

sport->port_guid_wwn.priv = sport;
srpt_format_guid(sport->port_guid, sizeof(sport->port_guid),
@@ -584,6 +576,20 @@ static int srpt_refresh_port(struct srpt_port *sport)
be64_to_cpu(sport->gid.global.subnet_prefix),
be64_to_cpu(sport->gid.global.interface_id));

if (rdma_protocol_iwarp(sport->sdev->device, sport->port))
return 0;

memset(&port_modify, 0, sizeof(port_modify));
port_modify.set_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP;
port_modify.clr_port_cap_mask = 0;

ret = ib_modify_port(sport->sdev->device, sport->port, 0, &port_modify);
if (ret) {
pr_warn("%s-%d: enabling device management failed (%d). Note: this is expected if SR-IOV is enabled.\n",
dev_name(&sport->sdev->device->dev), sport->port, ret);
return 0;
}

if (!sport->mad_agent) {
memset(&reg_req, 0, sizeof(reg_req));
reg_req.mgmt_class = IB_MGMT_CLASS_DEVICE_MGMT;
@@ -599,23 +605,14 @@ static int srpt_refresh_port(struct srpt_port *sport)
srpt_mad_recv_handler,
sport, 0);
if (IS_ERR(sport->mad_agent)) {
ret = PTR_ERR(sport->mad_agent);
pr_err("%s-%d: MAD agent registration failed (%ld). Note: this is expected if SR-IOV is enabled.\n",
dev_name(&sport->sdev->device->dev), sport->port,
PTR_ERR(sport->mad_agent));
sport->mad_agent = NULL;
goto err_query_port;
}
}

return 0;

err_query_port:

port_modify.set_port_cap_mask = 0;
port_modify.clr_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP;
ib_modify_port(sport->sdev->device, sport->port, 0, &port_modify);

err_mod_port:

return ret;
}

/**

0 comments on commit 09f8a14

Please sign in to comment.