Skip to content

Commit

Permalink
Merge branches 'bart-srp', 'generic-errors', 'ira-cleanups' and 'mwan…
Browse files Browse the repository at this point in the history
…g-v8' into k.o/for-4.2
  • Loading branch information
Doug Ledford committed May 20, 2015
4 parents 985aa49 + 3c88f3d + f766c58 + 5d9fb04 commit 175e8ef
Show file tree
Hide file tree
Showing 48 changed files with 1,008 additions and 644 deletions.
2 changes: 1 addition & 1 deletion drivers/infiniband/core/agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int ib_agent_port_open(struct ib_device *device, int port_num)
goto error1;
}

if (rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND) {
if (rdma_cap_ib_smi(device, port_num)) {
/* Obtain send only MAD agent for SMI QP */
port_priv->agent[0] = ib_register_mad_agent(device, port_num,
IB_QPT_SMI, NULL, 0,
Expand Down
61 changes: 25 additions & 36 deletions drivers/infiniband/core/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,6 @@ struct ib_update_work {
u8 port_num;
};

static inline int start_port(struct ib_device *device)
{
return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
}

static inline int end_port(struct ib_device *device)
{
return (device->node_type == RDMA_NODE_IB_SWITCH) ?
0 : device->phys_port_cnt;
}

int ib_get_cached_gid(struct ib_device *device,
u8 port_num,
int index,
Expand All @@ -78,12 +67,12 @@ int ib_get_cached_gid(struct ib_device *device,
unsigned long flags;
int ret = 0;

if (port_num < start_port(device) || port_num > end_port(device))
if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
return -EINVAL;

read_lock_irqsave(&device->cache.lock, flags);

cache = device->cache.gid_cache[port_num - start_port(device)];
cache = device->cache.gid_cache[port_num - rdma_start_port(device)];

if (index < 0 || index >= cache->table_len)
ret = -EINVAL;
Expand Down Expand Up @@ -112,11 +101,11 @@ int ib_find_cached_gid(struct ib_device *device,

read_lock_irqsave(&device->cache.lock, flags);

for (p = 0; p <= end_port(device) - start_port(device); ++p) {
for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) {
cache = device->cache.gid_cache[p];
for (i = 0; i < cache->table_len; ++i) {
if (!memcmp(gid, &cache->table[i], sizeof *gid)) {
*port_num = p + start_port(device);
*port_num = p + rdma_start_port(device);
if (index)
*index = i;
ret = 0;
Expand All @@ -140,12 +129,12 @@ int ib_get_cached_pkey(struct ib_device *device,
unsigned long flags;
int ret = 0;

if (port_num < start_port(device) || port_num > end_port(device))
if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
return -EINVAL;

read_lock_irqsave(&device->cache.lock, flags);

cache = device->cache.pkey_cache[port_num - start_port(device)];
cache = device->cache.pkey_cache[port_num - rdma_start_port(device)];

if (index < 0 || index >= cache->table_len)
ret = -EINVAL;
Expand All @@ -169,12 +158,12 @@ int ib_find_cached_pkey(struct ib_device *device,
int ret = -ENOENT;
int partial_ix = -1;

if (port_num < start_port(device) || port_num > end_port(device))
if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
return -EINVAL;

read_lock_irqsave(&device->cache.lock, flags);

cache = device->cache.pkey_cache[port_num - start_port(device)];
cache = device->cache.pkey_cache[port_num - rdma_start_port(device)];

*index = -1;

Expand Down Expand Up @@ -209,12 +198,12 @@ int ib_find_exact_cached_pkey(struct ib_device *device,
int i;
int ret = -ENOENT;

if (port_num < start_port(device) || port_num > end_port(device))
if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
return -EINVAL;

read_lock_irqsave(&device->cache.lock, flags);

cache = device->cache.pkey_cache[port_num - start_port(device)];
cache = device->cache.pkey_cache[port_num - rdma_start_port(device)];

*index = -1;

Expand All @@ -238,11 +227,11 @@ int ib_get_cached_lmc(struct ib_device *device,
unsigned long flags;
int ret = 0;

if (port_num < start_port(device) || port_num > end_port(device))
if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
return -EINVAL;

read_lock_irqsave(&device->cache.lock, flags);
*lmc = device->cache.lmc_cache[port_num - start_port(device)];
*lmc = device->cache.lmc_cache[port_num - rdma_start_port(device)];
read_unlock_irqrestore(&device->cache.lock, flags);

return ret;
Expand Down Expand Up @@ -303,13 +292,13 @@ static void ib_cache_update(struct ib_device *device,

write_lock_irq(&device->cache.lock);

old_pkey_cache = device->cache.pkey_cache[port - start_port(device)];
old_gid_cache = device->cache.gid_cache [port - start_port(device)];
old_pkey_cache = device->cache.pkey_cache[port - rdma_start_port(device)];
old_gid_cache = device->cache.gid_cache [port - rdma_start_port(device)];

device->cache.pkey_cache[port - start_port(device)] = pkey_cache;
device->cache.gid_cache [port - start_port(device)] = gid_cache;
device->cache.pkey_cache[port - rdma_start_port(device)] = pkey_cache;
device->cache.gid_cache [port - rdma_start_port(device)] = gid_cache;

device->cache.lmc_cache[port - start_port(device)] = tprops->lmc;
device->cache.lmc_cache[port - rdma_start_port(device)] = tprops->lmc;

write_unlock_irq(&device->cache.lock);

Expand Down Expand Up @@ -363,14 +352,14 @@ static void ib_cache_setup_one(struct ib_device *device)

device->cache.pkey_cache =
kmalloc(sizeof *device->cache.pkey_cache *
(end_port(device) - start_port(device) + 1), GFP_KERNEL);
(rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL);
device->cache.gid_cache =
kmalloc(sizeof *device->cache.gid_cache *
(end_port(device) - start_port(device) + 1), GFP_KERNEL);
(rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL);

device->cache.lmc_cache = kmalloc(sizeof *device->cache.lmc_cache *
(end_port(device) -
start_port(device) + 1),
(rdma_end_port(device) -
rdma_start_port(device) + 1),
GFP_KERNEL);

if (!device->cache.pkey_cache || !device->cache.gid_cache ||
Expand All @@ -380,10 +369,10 @@ static void ib_cache_setup_one(struct ib_device *device)
goto err;
}

for (p = 0; p <= end_port(device) - start_port(device); ++p) {
for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) {
device->cache.pkey_cache[p] = NULL;
device->cache.gid_cache [p] = NULL;
ib_cache_update(device, p + start_port(device));
ib_cache_update(device, p + rdma_start_port(device));
}

INIT_IB_EVENT_HANDLER(&device->cache.event_handler,
Expand All @@ -394,7 +383,7 @@ static void ib_cache_setup_one(struct ib_device *device)
return;

err_cache:
for (p = 0; p <= end_port(device) - start_port(device); ++p) {
for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) {
kfree(device->cache.pkey_cache[p]);
kfree(device->cache.gid_cache[p]);
}
Expand All @@ -412,7 +401,7 @@ static void ib_cache_cleanup_one(struct ib_device *device)
ib_unregister_event_handler(&device->cache.event_handler);
flush_workqueue(ib_wq);

for (p = 0; p <= end_port(device) - start_port(device); ++p) {
for (p = 0; p <= rdma_end_port(device) - rdma_start_port(device); ++p) {
kfree(device->cache.pkey_cache[p]);
kfree(device->cache.gid_cache[p]);
}
Expand Down
20 changes: 17 additions & 3 deletions drivers/infiniband/core/cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3759,11 +3759,9 @@ static void cm_add_one(struct ib_device *ib_device)
};
unsigned long flags;
int ret;
int count = 0;
u8 i;

if (rdma_node_get_transport(ib_device->node_type) != RDMA_TRANSPORT_IB)
return;

cm_dev = kzalloc(sizeof(*cm_dev) + sizeof(*port) *
ib_device->phys_port_cnt, GFP_KERNEL);
if (!cm_dev)
Expand All @@ -3782,6 +3780,9 @@ static void cm_add_one(struct ib_device *ib_device)

set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask);
for (i = 1; i <= ib_device->phys_port_cnt; i++) {
if (!rdma_cap_ib_cm(ib_device, i))
continue;

port = kzalloc(sizeof *port, GFP_KERNEL);
if (!port)
goto error1;
Expand All @@ -3808,7 +3809,13 @@ static void cm_add_one(struct ib_device *ib_device)
ret = ib_modify_port(ib_device, i, 0, &port_modify);
if (ret)
goto error3;

count++;
}

if (!count)
goto free;

ib_set_client_data(ib_device, &cm_client, cm_dev);

write_lock_irqsave(&cm.device_lock, flags);
Expand All @@ -3824,11 +3831,15 @@ static void cm_add_one(struct ib_device *ib_device)
port_modify.set_port_cap_mask = 0;
port_modify.clr_port_cap_mask = IB_PORT_CM_SUP;
while (--i) {
if (!rdma_cap_ib_cm(ib_device, i))
continue;

port = cm_dev->port[i-1];
ib_modify_port(ib_device, port->port_num, 0, &port_modify);
ib_unregister_mad_agent(port->mad_agent);
cm_remove_port_fs(port);
}
free:
device_unregister(cm_dev->device);
kfree(cm_dev);
}
Expand All @@ -3852,6 +3863,9 @@ static void cm_remove_one(struct ib_device *ib_device)
write_unlock_irqrestore(&cm.device_lock, flags);

for (i = 1; i <= ib_device->phys_port_cnt; i++) {
if (!rdma_cap_ib_cm(ib_device, i))
continue;

port = cm_dev->port[i-1];
ib_modify_port(ib_device, port->port_num, 0, &port_modify);
ib_unregister_mad_agent(port->mad_agent);
Expand Down
Loading

0 comments on commit 175e8ef

Please sign in to comment.