Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 18303
b: refs/heads/master
c: cf311cd
h: refs/heads/master
i:
  18301: b419e5e
  18299: 42138c3
  18295: 152ae50
  18287: d463094
  18271: 08b2406
  18239: 75b5304
  18175: 5b44cf7
v: v3
  • Loading branch information
Sean Hefty authored and Roland Dreier committed Jan 10, 2006
1 parent 237d58e commit 8e33995
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 65 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 87635b71b544563f29050a9cecaa12b5d2a3e34a
refs/heads/master: cf311cd49a78f1e431787068cc31d29d06a415e6
29 changes: 5 additions & 24 deletions trunk/drivers/infiniband/core/cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3163,22 +3163,6 @@ int ib_cm_init_qp_attr(struct ib_cm_id *cm_id,
}
EXPORT_SYMBOL(ib_cm_init_qp_attr);

static __be64 cm_get_ca_guid(struct ib_device *device)
{
struct ib_device_attr *device_attr;
__be64 guid;
int ret;

device_attr = kmalloc(sizeof *device_attr, GFP_KERNEL);
if (!device_attr)
return 0;

ret = ib_query_device(device, device_attr);
guid = ret ? 0 : device_attr->node_guid;
kfree(device_attr);
return guid;
}

static void cm_add_one(struct ib_device *device)
{
struct cm_device *cm_dev;
Expand All @@ -3200,9 +3184,7 @@ static void cm_add_one(struct ib_device *device)
return;

cm_dev->device = device;
cm_dev->ca_guid = cm_get_ca_guid(device);
if (!cm_dev->ca_guid)
goto error1;
cm_dev->ca_guid = device->node_guid;

set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
for (i = 1; i <= device->phys_port_cnt; i++) {
Expand All @@ -3217,11 +3199,11 @@ static void cm_add_one(struct ib_device *device)
cm_recv_handler,
port);
if (IS_ERR(port->mad_agent))
goto error2;
goto error1;

ret = ib_modify_port(device, i, 0, &port_modify);
if (ret)
goto error3;
goto error2;
}
ib_set_client_data(device, &cm_client, cm_dev);

Expand All @@ -3230,17 +3212,16 @@ static void cm_add_one(struct ib_device *device)
write_unlock_irqrestore(&cm.device_lock, flags);
return;

error3:
ib_unregister_mad_agent(port->mad_agent);
error2:
ib_unregister_mad_agent(port->mad_agent);
error1:
port_modify.set_port_cap_mask = 0;
port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
while (--i) {
port = &cm_dev->port[i-1];
ib_modify_port(device, port->port_num, 0, &port_modify);
ib_unregister_mad_agent(port->mad_agent);
}
error1:
kfree(cm_dev);
}

Expand Down
22 changes: 5 additions & 17 deletions trunk/drivers/infiniband/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,7 @@ static int ib_device_uevent(struct class_device *cdev, char **envp,
return -ENOMEM;

/*
* It might be nice to pass the node GUID with the event, but
* right now the only way to get it is to query the device
* provider, and this can crash during device removal because
* we are will be running after driver removal has started.
* We could add a node_guid field to struct ib_device, or we
* could just let userspace read the node GUID from sysfs when
* devices are added.
* It would be nice to pass the node GUID with the event...
*/

envp[i] = NULL;
Expand Down Expand Up @@ -623,21 +617,15 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
static ssize_t show_node_guid(struct class_device *cdev, char *buf)
{
struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
struct ib_device_attr attr;
ssize_t ret;

if (!ibdev_is_alive(dev))
return -ENODEV;

ret = ib_query_device(dev, &attr);
if (ret)
return ret;

return sprintf(buf, "%04x:%04x:%04x:%04x\n",
be16_to_cpu(((__be16 *) &attr.node_guid)[0]),
be16_to_cpu(((__be16 *) &attr.node_guid)[1]),
be16_to_cpu(((__be16 *) &attr.node_guid)[2]),
be16_to_cpu(((__be16 *) &attr.node_guid)[3]));
be16_to_cpu(((__be16 *) &dev->node_guid)[0]),
be16_to_cpu(((__be16 *) &dev->node_guid)[1]),
be16_to_cpu(((__be16 *) &dev->node_guid)[2]),
be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
}

static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/infiniband/core/uverbs_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file,
memset(&resp, 0, sizeof resp);

resp.fw_ver = attr.fw_ver;
resp.node_guid = attr.node_guid;
resp.node_guid = file->device->ib_dev->node_guid;
resp.sys_image_guid = attr.sys_image_guid;
resp.max_mr_size = attr.max_mr_size;
resp.page_size_cap = attr.page_size_cap;
Expand Down
40 changes: 38 additions & 2 deletions trunk/drivers/infiniband/hw/mthca/mthca_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* $Id: mthca_provider.c 1397 2004-12-28 05:09:00Z roland $
* $Id: mthca_provider.c 4859 2006-01-09 21:55:10Z roland $
*/

#include <rdma/ib_smi.h>
Expand Down Expand Up @@ -91,7 +91,6 @@ static int mthca_query_device(struct ib_device *ibdev,
props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30));
props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32));
memcpy(&props->sys_image_guid, out_mad->data + 4, 8);
memcpy(&props->node_guid, out_mad->data + 12, 8);

props->max_mr_size = ~0ull;
props->page_size_cap = mdev->limits.page_size_cap;
Expand Down Expand Up @@ -1054,11 +1053,48 @@ static struct class_device_attribute *mthca_class_attributes[] = {
&class_device_attr_board_id
};

static int mthca_init_node_data(struct mthca_dev *dev)
{
struct ib_smp *in_mad = NULL;
struct ib_smp *out_mad = NULL;
int err = -ENOMEM;
u8 status;

in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL);
out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
if (!in_mad || !out_mad)
goto out;

init_query_mad(in_mad);
in_mad->attr_id = IB_SMP_ATTR_NODE_INFO;

err = mthca_MAD_IFC(dev, 1, 1,
1, NULL, NULL, in_mad, out_mad,
&status);
if (err)
goto out;
if (status) {
err = -EINVAL;
goto out;
}

memcpy(&dev->ib_dev.node_guid, out_mad->data + 12, 8);

out:
kfree(in_mad);
kfree(out_mad);
return err;
}

int mthca_register_device(struct mthca_dev *dev)
{
int ret;
int i;

ret = mthca_init_node_data(dev);
if (ret)
return ret;

strlcpy(dev->ib_dev.name, "mthca%d", IB_DEVICE_NAME_MAX);
dev->ib_dev.owner = THIS_MODULE;

Expand Down
23 changes: 4 additions & 19 deletions trunk/drivers/infiniband/ulp/srp/ib_srp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1516,8 +1516,7 @@ static ssize_t show_port(struct class_device *class_dev, char *buf)

static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL);

static struct srp_host *srp_add_port(struct ib_device *device,
__be64 node_guid, u8 port)
static struct srp_host *srp_add_port(struct ib_device *device, u8 port)
{
struct srp_host *host;

Expand All @@ -1532,7 +1531,7 @@ static struct srp_host *srp_add_port(struct ib_device *device,
host->port = port;

host->initiator_port_id[7] = port;
memcpy(host->initiator_port_id + 8, &node_guid, 8);
memcpy(host->initiator_port_id + 8, &device->node_guid, 8);

host->pd = ib_alloc_pd(device);
if (IS_ERR(host->pd))
Expand Down Expand Up @@ -1580,22 +1579,11 @@ static void srp_add_one(struct ib_device *device)
{
struct list_head *dev_list;
struct srp_host *host;
struct ib_device_attr *dev_attr;
int s, e, p;

dev_attr = kmalloc(sizeof *dev_attr, GFP_KERNEL);
if (!dev_attr)
return;

if (ib_query_device(device, dev_attr)) {
printk(KERN_WARNING PFX "Couldn't query node GUID for %s.\n",
device->name);
goto out;
}

dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
if (!dev_list)
goto out;
return;

INIT_LIST_HEAD(dev_list);

Expand All @@ -1608,15 +1596,12 @@ static void srp_add_one(struct ib_device *device)
}

for (p = s; p <= e; ++p) {
host = srp_add_port(device, dev_attr->node_guid, p);
host = srp_add_port(device, p);
if (host)
list_add_tail(&host->list, dev_list);
}

ib_set_client_data(device, &srp_client, dev_list);

out:
kfree(dev_attr);
}

static void srp_remove_one(struct ib_device *device)
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/rdma/ib_verbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ enum ib_atomic_cap {

struct ib_device_attr {
u64 fw_ver;
__be64 node_guid;
__be64 sys_image_guid;
u64 max_mr_size;
u64 page_size_cap;
Expand Down Expand Up @@ -951,6 +950,7 @@ struct ib_device {
u64 uverbs_cmd_mask;
int uverbs_abi_ver;

__be64 node_guid;
u8 node_type;
u8 phys_port_cnt;
};
Expand Down

0 comments on commit 8e33995

Please sign in to comment.