mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-08-18 02:22:47 -07:00
Merge branches 'bart-srp', 'generic-errors', 'ira-cleanups' and 'mwang-v8' into k.o/for-4.2
This commit is contained in:
commit
175e8efe69
48 files changed
+1006
-642
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
@@ -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 ||
|
||||
@@ -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,
|
||||
@@ -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]);
|
||||
}
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -3824,11 +3831,15 @@ error1:
|
||||
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);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
+127
-156
@@ -65,6 +65,34 @@ MODULE_LICENSE("Dual BSD/GPL");
|
||||
#define CMA_CM_MRA_SETTING (IB_CM_MRA_FLAG_DELAY | 24)
|
||||
#define CMA_IBOE_PACKET_LIFETIME 18
|
||||
|
||||
static const char * const cma_events[] = {
|
||||
[RDMA_CM_EVENT_ADDR_RESOLVED] = "address resolved",
|
||||
[RDMA_CM_EVENT_ADDR_ERROR] = "address error",
|
||||
[RDMA_CM_EVENT_ROUTE_RESOLVED] = "route resolved ",
|
||||
[RDMA_CM_EVENT_ROUTE_ERROR] = "route error",
|
||||
[RDMA_CM_EVENT_CONNECT_REQUEST] = "connect request",
|
||||
[RDMA_CM_EVENT_CONNECT_RESPONSE] = "connect response",
|
||||
[RDMA_CM_EVENT_CONNECT_ERROR] = "connect error",
|
||||
[RDMA_CM_EVENT_UNREACHABLE] = "unreachable",
|
||||
[RDMA_CM_EVENT_REJECTED] = "rejected",
|
||||
[RDMA_CM_EVENT_ESTABLISHED] = "established",
|
||||
[RDMA_CM_EVENT_DISCONNECTED] = "disconnected",
|
||||
[RDMA_CM_EVENT_DEVICE_REMOVAL] = "device removal",
|
||||
[RDMA_CM_EVENT_MULTICAST_JOIN] = "multicast join",
|
||||
[RDMA_CM_EVENT_MULTICAST_ERROR] = "multicast error",
|
||||
[RDMA_CM_EVENT_ADDR_CHANGE] = "address change",
|
||||
[RDMA_CM_EVENT_TIMEWAIT_EXIT] = "timewait exit",
|
||||
};
|
||||
|
||||
const char *rdma_event_msg(enum rdma_cm_event_type event)
|
||||
{
|
||||
size_t index = event;
|
||||
|
||||
return (index < ARRAY_SIZE(cma_events) && cma_events[index]) ?
|
||||
cma_events[index] : "unrecognized event";
|
||||
}
|
||||
EXPORT_SYMBOL(rdma_event_msg);
|
||||
|
||||
static void cma_add_one(struct ib_device *device);
|
||||
static void cma_remove_one(struct ib_device *device);
|
||||
|
||||
@@ -349,18 +377,35 @@ static int cma_translate_addr(struct sockaddr *addr, struct rdma_dev_addr *dev_a
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline int cma_validate_port(struct ib_device *device, u8 port,
|
||||
union ib_gid *gid, int dev_type)
|
||||
{
|
||||
u8 found_port;
|
||||
int ret = -ENODEV;
|
||||
|
||||
if ((dev_type == ARPHRD_INFINIBAND) && !rdma_protocol_ib(device, port))
|
||||
return ret;
|
||||
|
||||
if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port))
|
||||
return ret;
|
||||
|
||||
ret = ib_find_cached_gid(device, gid, &found_port, NULL);
|
||||
if (port != found_port)
|
||||
return -ENODEV;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cma_acquire_dev(struct rdma_id_private *id_priv,
|
||||
struct rdma_id_private *listen_id_priv)
|
||||
{
|
||||
struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
|
||||
struct cma_device *cma_dev;
|
||||
union ib_gid gid, iboe_gid;
|
||||
union ib_gid gid, iboe_gid, *gidp;
|
||||
int ret = -ENODEV;
|
||||
u8 port, found_port;
|
||||
enum rdma_link_layer dev_ll = dev_addr->dev_type == ARPHRD_INFINIBAND ?
|
||||
IB_LINK_LAYER_INFINIBAND : IB_LINK_LAYER_ETHERNET;
|
||||
u8 port;
|
||||
|
||||
if (dev_ll != IB_LINK_LAYER_INFINIBAND &&
|
||||
if (dev_addr->dev_type != ARPHRD_INFINIBAND &&
|
||||
id_priv->id.ps == RDMA_PS_IPOIB)
|
||||
return -EINVAL;
|
||||
|
||||
@@ -370,41 +415,36 @@ static int cma_acquire_dev(struct rdma_id_private *id_priv,
|
||||
|
||||
memcpy(&gid, dev_addr->src_dev_addr +
|
||||
rdma_addr_gid_offset(dev_addr), sizeof gid);
|
||||
if (listen_id_priv &&
|
||||
rdma_port_get_link_layer(listen_id_priv->id.device,
|
||||
listen_id_priv->id.port_num) == dev_ll) {
|
||||
|
||||
if (listen_id_priv) {
|
||||
cma_dev = listen_id_priv->cma_dev;
|
||||
port = listen_id_priv->id.port_num;
|
||||
if (rdma_node_get_transport(cma_dev->device->node_type) == RDMA_TRANSPORT_IB &&
|
||||
rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
|
||||
ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
|
||||
&found_port, NULL);
|
||||
else
|
||||
ret = ib_find_cached_gid(cma_dev->device, &gid,
|
||||
&found_port, NULL);
|
||||
gidp = rdma_protocol_roce(cma_dev->device, port) ?
|
||||
&iboe_gid : &gid;
|
||||
|
||||
if (!ret && (port == found_port)) {
|
||||
id_priv->id.port_num = found_port;
|
||||
ret = cma_validate_port(cma_dev->device, port, gidp,
|
||||
dev_addr->dev_type);
|
||||
if (!ret) {
|
||||
id_priv->id.port_num = port;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
list_for_each_entry(cma_dev, &dev_list, list) {
|
||||
for (port = 1; port <= cma_dev->device->phys_port_cnt; ++port) {
|
||||
if (listen_id_priv &&
|
||||
listen_id_priv->cma_dev == cma_dev &&
|
||||
listen_id_priv->id.port_num == port)
|
||||
continue;
|
||||
if (rdma_port_get_link_layer(cma_dev->device, port) == dev_ll) {
|
||||
if (rdma_node_get_transport(cma_dev->device->node_type) == RDMA_TRANSPORT_IB &&
|
||||
rdma_port_get_link_layer(cma_dev->device, port) == IB_LINK_LAYER_ETHERNET)
|
||||
ret = ib_find_cached_gid(cma_dev->device, &iboe_gid, &found_port, NULL);
|
||||
else
|
||||
ret = ib_find_cached_gid(cma_dev->device, &gid, &found_port, NULL);
|
||||
|
||||
if (!ret && (port == found_port)) {
|
||||
id_priv->id.port_num = found_port;
|
||||
goto out;
|
||||
}
|
||||
gidp = rdma_protocol_roce(cma_dev->device, port) ?
|
||||
&iboe_gid : &gid;
|
||||
|
||||
ret = cma_validate_port(cma_dev->device, port, gidp,
|
||||
dev_addr->dev_type);
|
||||
if (!ret) {
|
||||
id_priv->id.port_num = port;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,10 +475,10 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
|
||||
pkey = ntohs(addr->sib_pkey);
|
||||
|
||||
list_for_each_entry(cur_dev, &dev_list, list) {
|
||||
if (rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB)
|
||||
continue;
|
||||
|
||||
for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
|
||||
if (!rdma_cap_af_ib(cur_dev->device, p))
|
||||
continue;
|
||||
|
||||
if (ib_find_cached_pkey(cur_dev->device, p, pkey, &index))
|
||||
continue;
|
||||
|
||||
@@ -633,10 +673,9 @@ static int cma_modify_qp_rtr(struct rdma_id_private *id_priv,
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (rdma_node_get_transport(id_priv->cma_dev->device->node_type)
|
||||
== RDMA_TRANSPORT_IB &&
|
||||
rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)
|
||||
== IB_LINK_LAYER_ETHERNET) {
|
||||
BUG_ON(id_priv->cma_dev->device != id_priv->id.device);
|
||||
|
||||
if (rdma_protocol_roce(id_priv->id.device, id_priv->id.port_num)) {
|
||||
ret = rdma_addr_find_smac_by_sgid(&sgid, qp_attr.smac, NULL);
|
||||
|
||||
if (ret)
|
||||
@@ -700,11 +739,10 @@ static int cma_ib_init_qp_attr(struct rdma_id_private *id_priv,
|
||||
int ret;
|
||||
u16 pkey;
|
||||
|
||||
if (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num) ==
|
||||
IB_LINK_LAYER_INFINIBAND)
|
||||
pkey = ib_addr_get_pkey(dev_addr);
|
||||
else
|
||||
if (rdma_cap_eth_ah(id_priv->id.device, id_priv->id.port_num))
|
||||
pkey = 0xffff;
|
||||
else
|
||||
pkey = ib_addr_get_pkey(dev_addr);
|
||||
|
||||
ret = ib_find_cached_pkey(id_priv->id.device, id_priv->id.port_num,
|
||||
pkey, &qp_attr->pkey_index);
|
||||
@@ -735,8 +773,7 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
|
||||
int ret = 0;
|
||||
|
||||
id_priv = container_of(id, struct rdma_id_private, id);
|
||||
switch (rdma_node_get_transport(id_priv->id.device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
if (rdma_cap_ib_cm(id->device, id->port_num)) {
|
||||
if (!id_priv->cm_id.ib || (id_priv->id.qp_type == IB_QPT_UD))
|
||||
ret = cma_ib_init_qp_attr(id_priv, qp_attr, qp_attr_mask);
|
||||
else
|
||||
@@ -745,19 +782,15 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
|
||||
|
||||
if (qp_attr->qp_state == IB_QPS_RTR)
|
||||
qp_attr->rq_psn = id_priv->seq_num;
|
||||
break;
|
||||
case RDMA_TRANSPORT_IWARP:
|
||||
} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
|
||||
if (!id_priv->cm_id.iw) {
|
||||
qp_attr->qp_access_flags = 0;
|
||||
*qp_attr_mask = IB_QP_STATE | IB_QP_ACCESS_FLAGS;
|
||||
} else
|
||||
ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr,
|
||||
qp_attr_mask);
|
||||
break;
|
||||
default:
|
||||
} else
|
||||
ret = -ENOSYS;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -935,13 +968,9 @@ static inline int cma_user_data_offset(struct rdma_id_private *id_priv)
|
||||
|
||||
static void cma_cancel_route(struct rdma_id_private *id_priv)
|
||||
{
|
||||
switch (rdma_port_get_link_layer(id_priv->id.device, id_priv->id.port_num)) {
|
||||
case IB_LINK_LAYER_INFINIBAND:
|
||||
if (rdma_cap_ib_sa(id_priv->id.device, id_priv->id.port_num)) {
|
||||
if (id_priv->query)
|
||||
ib_sa_cancel_query(id_priv->query_id, id_priv->query);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1013,17 +1042,12 @@ static void cma_leave_mc_groups(struct rdma_id_private *id_priv)
|
||||
mc = container_of(id_priv->mc_list.next,
|
||||
struct cma_multicast, list);
|
||||
list_del(&mc->list);
|
||||
switch (rdma_port_get_link_layer(id_priv->cma_dev->device, id_priv->id.port_num)) {
|
||||
case IB_LINK_LAYER_INFINIBAND:
|
||||
if (rdma_cap_ib_mcast(id_priv->cma_dev->device,
|
||||
id_priv->id.port_num)) {
|
||||
ib_sa_free_multicast(mc->multicast.ib);
|
||||
kfree(mc);
|
||||
break;
|
||||
case IB_LINK_LAYER_ETHERNET:
|
||||
} else
|
||||
kref_put(&mc->mcref, release_mc);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1044,17 +1068,12 @@ void rdma_destroy_id(struct rdma_cm_id *id)
|
||||
mutex_unlock(&id_priv->handler_mutex);
|
||||
|
||||
if (id_priv->cma_dev) {
|
||||
switch (rdma_node_get_transport(id_priv->id.device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
if (rdma_cap_ib_cm(id_priv->id.device, 1)) {
|
||||
if (id_priv->cm_id.ib)
|
||||
ib_destroy_cm_id(id_priv->cm_id.ib);
|
||||
break;
|
||||
case RDMA_TRANSPORT_IWARP:
|
||||
} else if (rdma_cap_iw_cm(id_priv->id.device, 1)) {
|
||||
if (id_priv->cm_id.iw)
|
||||
iw_destroy_cm_id(id_priv->cm_id.iw);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cma_leave_mc_groups(id_priv);
|
||||
cma_release_dev(id_priv);
|
||||
@@ -1632,8 +1651,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
|
||||
struct rdma_cm_id *id;
|
||||
int ret;
|
||||
|
||||
if (cma_family(id_priv) == AF_IB &&
|
||||
rdma_node_get_transport(cma_dev->device->node_type) != RDMA_TRANSPORT_IB)
|
||||
if (cma_family(id_priv) == AF_IB && !rdma_cap_ib_cm(cma_dev->device, 1))
|
||||
return;
|
||||
|
||||
id = rdma_create_id(cma_listen_handler, id_priv, id_priv->id.ps,
|
||||
@@ -1974,26 +1992,15 @@ int rdma_resolve_route(struct rdma_cm_id *id, int timeout_ms)
|
||||
return -EINVAL;
|
||||
|
||||
atomic_inc(&id_priv->refcount);
|
||||
switch (rdma_node_get_transport(id->device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
switch (rdma_port_get_link_layer(id->device, id->port_num)) {
|
||||
case IB_LINK_LAYER_INFINIBAND:
|
||||
ret = cma_resolve_ib_route(id_priv, timeout_ms);
|
||||
break;
|
||||
case IB_LINK_LAYER_ETHERNET:
|
||||
ret = cma_resolve_iboe_route(id_priv);
|
||||
break;
|
||||
default:
|
||||
ret = -ENOSYS;
|
||||
}
|
||||
break;
|
||||
case RDMA_TRANSPORT_IWARP:
|
||||
if (rdma_cap_ib_sa(id->device, id->port_num))
|
||||
ret = cma_resolve_ib_route(id_priv, timeout_ms);
|
||||
else if (rdma_protocol_roce(id->device, id->port_num))
|
||||
ret = cma_resolve_iboe_route(id_priv);
|
||||
else if (rdma_protocol_iwarp(id->device, id->port_num))
|
||||
ret = cma_resolve_iw_route(id_priv, timeout_ms);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
ret = -ENOSYS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
@@ -2035,7 +2042,7 @@ static int cma_bind_loopback(struct rdma_id_private *id_priv)
|
||||
mutex_lock(&lock);
|
||||
list_for_each_entry(cur_dev, &dev_list, list) {
|
||||
if (cma_family(id_priv) == AF_IB &&
|
||||
rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB)
|
||||
!rdma_cap_ib_cm(cur_dev->device, 1))
|
||||
continue;
|
||||
|
||||
if (!cma_dev)
|
||||
@@ -2067,7 +2074,7 @@ port_found:
|
||||
goto out;
|
||||
|
||||
id_priv->id.route.addr.dev_addr.dev_type =
|
||||
(rdma_port_get_link_layer(cma_dev->device, p) == IB_LINK_LAYER_INFINIBAND) ?
|
||||
(rdma_protocol_ib(cma_dev->device, p)) ?
|
||||
ARPHRD_INFINIBAND : ARPHRD_ETHER;
|
||||
|
||||
rdma_addr_set_sgid(&id_priv->id.route.addr.dev_addr, &gid);
|
||||
@@ -2544,18 +2551,15 @@ int rdma_listen(struct rdma_cm_id *id, int backlog)
|
||||
|
||||
id_priv->backlog = backlog;
|
||||
if (id->device) {
|
||||
switch (rdma_node_get_transport(id->device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
if (rdma_cap_ib_cm(id->device, 1)) {
|
||||
ret = cma_ib_listen(id_priv);
|
||||
if (ret)
|
||||
goto err;
|
||||
break;
|
||||
case RDMA_TRANSPORT_IWARP:
|
||||
} else if (rdma_cap_iw_cm(id->device, 1)) {
|
||||
ret = cma_iw_listen(id_priv, backlog);
|
||||
if (ret)
|
||||
goto err;
|
||||
break;
|
||||
default:
|
||||
} else {
|
||||
ret = -ENOSYS;
|
||||
goto err;
|
||||
}
|
||||
@@ -2891,20 +2895,15 @@ int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
|
||||
id_priv->srq = conn_param->srq;
|
||||
}
|
||||
|
||||
switch (rdma_node_get_transport(id->device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
if (rdma_cap_ib_cm(id->device, id->port_num)) {
|
||||
if (id->qp_type == IB_QPT_UD)
|
||||
ret = cma_resolve_ib_udp(id_priv, conn_param);
|
||||
else
|
||||
ret = cma_connect_ib(id_priv, conn_param);
|
||||
break;
|
||||
case RDMA_TRANSPORT_IWARP:
|
||||
} else if (rdma_cap_iw_cm(id->device, id->port_num))
|
||||
ret = cma_connect_iw(id_priv, conn_param);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
ret = -ENOSYS;
|
||||
break;
|
||||
}
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
@@ -3007,8 +3006,7 @@ int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
|
||||
id_priv->srq = conn_param->srq;
|
||||
}
|
||||
|
||||
switch (rdma_node_get_transport(id->device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
if (rdma_cap_ib_cm(id->device, id->port_num)) {
|
||||
if (id->qp_type == IB_QPT_UD) {
|
||||
if (conn_param)
|
||||
ret = cma_send_sidr_rep(id_priv, IB_SIDR_SUCCESS,
|
||||
@@ -3024,14 +3022,10 @@ int rdma_accept(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
|
||||
else
|
||||
ret = cma_rep_recv(id_priv);
|
||||
}
|
||||
break;
|
||||
case RDMA_TRANSPORT_IWARP:
|
||||
} else if (rdma_cap_iw_cm(id->device, id->port_num))
|
||||
ret = cma_accept_iw(id_priv, conn_param);
|
||||
break;
|
||||
default:
|
||||
else
|
||||
ret = -ENOSYS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret)
|
||||
goto reject;
|
||||
@@ -3075,8 +3069,7 @@ int rdma_reject(struct rdma_cm_id *id, const void *private_data,
|
||||
if (!id_priv->cm_id.ib)
|
||||
return -EINVAL;
|
||||
|
||||
switch (rdma_node_get_transport(id->device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
if (rdma_cap_ib_cm(id->device, id->port_num)) {
|
||||
if (id->qp_type == IB_QPT_UD)
|
||||
ret = cma_send_sidr_rep(id_priv, IB_SIDR_REJECT, 0,
|
||||
private_data, private_data_len);
|
||||
@@ -3084,15 +3077,12 @@ int rdma_reject(struct rdma_cm_id *id, const void *private_data,
|
||||
ret = ib_send_cm_rej(id_priv->cm_id.ib,
|
||||
IB_CM_REJ_CONSUMER_DEFINED, NULL,
|
||||
0, private_data, private_data_len);
|
||||
break;
|
||||
case RDMA_TRANSPORT_IWARP:
|
||||
} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
|
||||
ret = iw_cm_reject(id_priv->cm_id.iw,
|
||||
private_data, private_data_len);
|
||||
break;
|
||||
default:
|
||||
} else
|
||||
ret = -ENOSYS;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(rdma_reject);
|
||||
@@ -3106,22 +3096,18 @@ int rdma_disconnect(struct rdma_cm_id *id)
|
||||
if (!id_priv->cm_id.ib)
|
||||
return -EINVAL;
|
||||
|
||||
switch (rdma_node_get_transport(id->device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
if (rdma_cap_ib_cm(id->device, id->port_num)) {
|
||||
ret = cma_modify_qp_err(id_priv);
|
||||
if (ret)
|
||||
goto out;
|
||||
/* Initiate or respond to a disconnect. */
|
||||
if (ib_send_cm_dreq(id_priv->cm_id.ib, NULL, 0))
|
||||
ib_send_cm_drep(id_priv->cm_id.ib, NULL, 0);
|
||||
break;
|
||||
case RDMA_TRANSPORT_IWARP:
|
||||
} else if (rdma_cap_iw_cm(id->device, id->port_num)) {
|
||||
ret = iw_cm_disconnect(id_priv->cm_id.iw, 0);
|
||||
break;
|
||||
default:
|
||||
} else
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
@@ -3367,24 +3353,13 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr,
|
||||
list_add(&mc->list, &id_priv->mc_list);
|
||||
spin_unlock(&id_priv->lock);
|
||||
|
||||
switch (rdma_node_get_transport(id->device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
switch (rdma_port_get_link_layer(id->device, id->port_num)) {
|
||||
case IB_LINK_LAYER_INFINIBAND:
|
||||
ret = cma_join_ib_multicast(id_priv, mc);
|
||||
break;
|
||||
case IB_LINK_LAYER_ETHERNET:
|
||||
kref_init(&mc->mcref);
|
||||
ret = cma_iboe_join_multicast(id_priv, mc);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (rdma_protocol_roce(id->device, id->port_num)) {
|
||||
kref_init(&mc->mcref);
|
||||
ret = cma_iboe_join_multicast(id_priv, mc);
|
||||
} else if (rdma_cap_ib_mcast(id->device, id->port_num))
|
||||
ret = cma_join_ib_multicast(id_priv, mc);
|
||||
else
|
||||
ret = -ENOSYS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
spin_lock_irq(&id_priv->lock);
|
||||
@@ -3412,19 +3387,15 @@ void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr)
|
||||
ib_detach_mcast(id->qp,
|
||||
&mc->multicast.ib->rec.mgid,
|
||||
be16_to_cpu(mc->multicast.ib->rec.mlid));
|
||||
if (rdma_node_get_transport(id_priv->cma_dev->device->node_type) == RDMA_TRANSPORT_IB) {
|
||||
switch (rdma_port_get_link_layer(id->device, id->port_num)) {
|
||||
case IB_LINK_LAYER_INFINIBAND:
|
||||
ib_sa_free_multicast(mc->multicast.ib);
|
||||
kfree(mc);
|
||||
break;
|
||||
case IB_LINK_LAYER_ETHERNET:
|
||||
kref_put(&mc->mcref, release_mc);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BUG_ON(id_priv->cma_dev->device != id->device);
|
||||
|
||||
if (rdma_cap_ib_mcast(id->device, id->port_num)) {
|
||||
ib_sa_free_multicast(mc->multicast.ib);
|
||||
kfree(mc);
|
||||
} else if (rdma_protocol_roce(id->device, id->port_num))
|
||||
kref_put(&mc->mcref, release_mc);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,8 @@ static int ib_device_check_mandatory(struct ib_device *device)
|
||||
IB_MANDATORY_FUNC(poll_cq),
|
||||
IB_MANDATORY_FUNC(req_notify_cq),
|
||||
IB_MANDATORY_FUNC(get_dma_mr),
|
||||
IB_MANDATORY_FUNC(dereg_mr)
|
||||
IB_MANDATORY_FUNC(dereg_mr),
|
||||
IB_MANDATORY_FUNC(get_port_immutable)
|
||||
};
|
||||
int i;
|
||||
|
||||
@@ -151,18 +152,6 @@ static int alloc_name(char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int start_port(struct ib_device *device)
|
||||
{
|
||||
return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
static int end_port(struct ib_device *device)
|
||||
{
|
||||
return (device->node_type == RDMA_NODE_IB_SWITCH) ?
|
||||
0 : device->phys_port_cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* ib_alloc_device - allocate an IB device struct
|
||||
* @size:size of structure to allocate
|
||||
@@ -222,42 +211,38 @@ static int add_client_context(struct ib_device *device, struct ib_client *client
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_port_table_lengths(struct ib_device *device)
|
||||
static int read_port_immutable(struct ib_device *device)
|
||||
{
|
||||
struct ib_port_attr *tprops = NULL;
|
||||
int num_ports, ret = -ENOMEM;
|
||||
u8 port_index;
|
||||
int ret = -ENOMEM;
|
||||
u8 start_port = rdma_start_port(device);
|
||||
u8 end_port = rdma_end_port(device);
|
||||
u8 port;
|
||||
|
||||
tprops = kmalloc(sizeof *tprops, GFP_KERNEL);
|
||||
if (!tprops)
|
||||
goto out;
|
||||
|
||||
num_ports = end_port(device) - start_port(device) + 1;
|
||||
|
||||
device->pkey_tbl_len = kmalloc(sizeof *device->pkey_tbl_len * num_ports,
|
||||
GFP_KERNEL);
|
||||
device->gid_tbl_len = kmalloc(sizeof *device->gid_tbl_len * num_ports,
|
||||
GFP_KERNEL);
|
||||
if (!device->pkey_tbl_len || !device->gid_tbl_len)
|
||||
/**
|
||||
* device->port_immutable is indexed directly by the port number to make
|
||||
* access to this data as efficient as possible.
|
||||
*
|
||||
* Therefore port_immutable is declared as a 1 based array with
|
||||
* potential empty slots at the beginning.
|
||||
*/
|
||||
device->port_immutable = kzalloc(sizeof(*device->port_immutable)
|
||||
* (end_port + 1),
|
||||
GFP_KERNEL);
|
||||
if (!device->port_immutable)
|
||||
goto err;
|
||||
|
||||
for (port_index = 0; port_index < num_ports; ++port_index) {
|
||||
ret = ib_query_port(device, port_index + start_port(device),
|
||||
tprops);
|
||||
for (port = start_port; port <= end_port; ++port) {
|
||||
ret = device->get_port_immutable(device, port,
|
||||
&device->port_immutable[port]);
|
||||
if (ret)
|
||||
goto err;
|
||||
device->pkey_tbl_len[port_index] = tprops->pkey_tbl_len;
|
||||
device->gid_tbl_len[port_index] = tprops->gid_tbl_len;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
goto out;
|
||||
|
||||
err:
|
||||
kfree(device->gid_tbl_len);
|
||||
kfree(device->pkey_tbl_len);
|
||||
kfree(device->port_immutable);
|
||||
out:
|
||||
kfree(tprops);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -294,9 +279,9 @@ int ib_register_device(struct ib_device *device,
|
||||
spin_lock_init(&device->event_handler_lock);
|
||||
spin_lock_init(&device->client_data_lock);
|
||||
|
||||
ret = read_port_table_lengths(device);
|
||||
ret = read_port_immutable(device);
|
||||
if (ret) {
|
||||
printk(KERN_WARNING "Couldn't create table lengths cache for device %s\n",
|
||||
printk(KERN_WARNING "Couldn't create per port immutable data %s\n",
|
||||
device->name);
|
||||
goto out;
|
||||
}
|
||||
@@ -305,8 +290,7 @@ int ib_register_device(struct ib_device *device,
|
||||
if (ret) {
|
||||
printk(KERN_WARNING "Couldn't register device %s with driver model\n",
|
||||
device->name);
|
||||
kfree(device->gid_tbl_len);
|
||||
kfree(device->pkey_tbl_len);
|
||||
kfree(device->port_immutable);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -348,9 +332,6 @@ void ib_unregister_device(struct ib_device *device)
|
||||
|
||||
list_del(&device->core_list);
|
||||
|
||||
kfree(device->gid_tbl_len);
|
||||
kfree(device->pkey_tbl_len);
|
||||
|
||||
mutex_unlock(&device_mutex);
|
||||
|
||||
ib_device_unregister_sysfs(device);
|
||||
@@ -575,7 +556,7 @@ int ib_query_port(struct ib_device *device,
|
||||
u8 port_num,
|
||||
struct ib_port_attr *port_attr)
|
||||
{
|
||||
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;
|
||||
|
||||
return device->query_port(device, port_num, port_attr);
|
||||
@@ -653,7 +634,7 @@ int ib_modify_port(struct ib_device *device,
|
||||
if (!device->modify_port)
|
||||
return -ENOSYS;
|
||||
|
||||
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;
|
||||
|
||||
return device->modify_port(device, port_num, port_modify_mask,
|
||||
@@ -676,8 +657,8 @@ int ib_find_gid(struct ib_device *device, union ib_gid *gid,
|
||||
union ib_gid tmp_gid;
|
||||
int ret, port, i;
|
||||
|
||||
for (port = start_port(device); port <= end_port(device); ++port) {
|
||||
for (i = 0; i < device->gid_tbl_len[port - start_port(device)]; ++i) {
|
||||
for (port = rdma_start_port(device); port <= rdma_end_port(device); ++port) {
|
||||
for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) {
|
||||
ret = ib_query_gid(device, port, i, &tmp_gid);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -709,7 +690,7 @@ int ib_find_pkey(struct ib_device *device,
|
||||
u16 tmp_pkey;
|
||||
int partial_ix = -1;
|
||||
|
||||
for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) {
|
||||
for (i = 0; i < device->port_immutable[port_num].pkey_tbl_len; ++i) {
|
||||
ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -179,12 +179,12 @@ static int is_vendor_method_in_use(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ib_response_mad(struct ib_mad *mad)
|
||||
int ib_response_mad(const struct ib_mad_hdr *hdr)
|
||||
{
|
||||
return ((mad->mad_hdr.method & IB_MGMT_METHOD_RESP) ||
|
||||
(mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS) ||
|
||||
((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_BM) &&
|
||||
(mad->mad_hdr.attr_mod & IB_BM_ATTR_MOD_RESP)));
|
||||
return ((hdr->method & IB_MGMT_METHOD_RESP) ||
|
||||
(hdr->method == IB_MGMT_METHOD_TRAP_REPRESS) ||
|
||||
((hdr->mgmt_class == IB_MGMT_CLASS_BM) &&
|
||||
(hdr->attr_mod & IB_BM_ATTR_MOD_RESP)));
|
||||
}
|
||||
EXPORT_SYMBOL(ib_response_mad);
|
||||
|
||||
@@ -791,7 +791,7 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
|
||||
switch (ret)
|
||||
{
|
||||
case IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY:
|
||||
if (ib_response_mad(&mad_priv->mad.mad) &&
|
||||
if (ib_response_mad(&mad_priv->mad.mad.mad_hdr) &&
|
||||
mad_agent_priv->agent.recv_handler) {
|
||||
local->mad_priv = mad_priv;
|
||||
local->recv_mad_agent = mad_agent_priv;
|
||||
@@ -910,7 +910,7 @@ static int alloc_send_rmpp_list(struct ib_mad_send_wr_private *send_wr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ib_mad_kernel_rmpp_agent(struct ib_mad_agent *agent)
|
||||
int ib_mad_kernel_rmpp_agent(const struct ib_mad_agent *agent)
|
||||
{
|
||||
return agent->rmpp_version && !(agent->flags & IB_MAD_USER_RMPP);
|
||||
}
|
||||
@@ -1628,7 +1628,7 @@ find_mad_agent(struct ib_mad_port_private *port_priv,
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&port_priv->reg_lock, flags);
|
||||
if (ib_response_mad(mad)) {
|
||||
if (ib_response_mad(&mad->mad_hdr)) {
|
||||
u32 hi_tid;
|
||||
struct ib_mad_agent_private *entry;
|
||||
|
||||
@@ -1708,20 +1708,20 @@ out:
|
||||
return mad_agent;
|
||||
}
|
||||
|
||||
static int validate_mad(struct ib_mad *mad, u32 qp_num)
|
||||
static int validate_mad(const struct ib_mad_hdr *mad_hdr, u32 qp_num)
|
||||
{
|
||||
int valid = 0;
|
||||
|
||||
/* Make sure MAD base version is understood */
|
||||
if (mad->mad_hdr.base_version != IB_MGMT_BASE_VERSION) {
|
||||
if (mad_hdr->base_version != IB_MGMT_BASE_VERSION) {
|
||||
pr_err("MAD received with unsupported base version %d\n",
|
||||
mad->mad_hdr.base_version);
|
||||
mad_hdr->base_version);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Filter SMI packets sent to other than QP0 */
|
||||
if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
|
||||
(mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) {
|
||||
if ((mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED) ||
|
||||
(mad_hdr->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)) {
|
||||
if (qp_num == 0)
|
||||
valid = 1;
|
||||
} else {
|
||||
@@ -1734,8 +1734,8 @@ out:
|
||||
return valid;
|
||||
}
|
||||
|
||||
static int is_data_mad(struct ib_mad_agent_private *mad_agent_priv,
|
||||
struct ib_mad_hdr *mad_hdr)
|
||||
static int is_rmpp_data_mad(const struct ib_mad_agent_private *mad_agent_priv,
|
||||
const struct ib_mad_hdr *mad_hdr)
|
||||
{
|
||||
struct ib_rmpp_mad *rmpp_mad;
|
||||
|
||||
@@ -1747,16 +1747,16 @@ static int is_data_mad(struct ib_mad_agent_private *mad_agent_priv,
|
||||
(rmpp_mad->rmpp_hdr.rmpp_type == IB_MGMT_RMPP_TYPE_DATA);
|
||||
}
|
||||
|
||||
static inline int rcv_has_same_class(struct ib_mad_send_wr_private *wr,
|
||||
struct ib_mad_recv_wc *rwc)
|
||||
static inline int rcv_has_same_class(const struct ib_mad_send_wr_private *wr,
|
||||
const struct ib_mad_recv_wc *rwc)
|
||||
{
|
||||
return ((struct ib_mad *)(wr->send_buf.mad))->mad_hdr.mgmt_class ==
|
||||
return ((struct ib_mad_hdr *)(wr->send_buf.mad))->mgmt_class ==
|
||||
rwc->recv_buf.mad->mad_hdr.mgmt_class;
|
||||
}
|
||||
|
||||
static inline int rcv_has_same_gid(struct ib_mad_agent_private *mad_agent_priv,
|
||||
struct ib_mad_send_wr_private *wr,
|
||||
struct ib_mad_recv_wc *rwc )
|
||||
static inline int rcv_has_same_gid(const struct ib_mad_agent_private *mad_agent_priv,
|
||||
const struct ib_mad_send_wr_private *wr,
|
||||
const struct ib_mad_recv_wc *rwc )
|
||||
{
|
||||
struct ib_ah_attr attr;
|
||||
u8 send_resp, rcv_resp;
|
||||
@@ -1765,8 +1765,8 @@ static inline int rcv_has_same_gid(struct ib_mad_agent_private *mad_agent_priv,
|
||||
u8 port_num = mad_agent_priv->agent.port_num;
|
||||
u8 lmc;
|
||||
|
||||
send_resp = ib_response_mad((struct ib_mad *)wr->send_buf.mad);
|
||||
rcv_resp = ib_response_mad(rwc->recv_buf.mad);
|
||||
send_resp = ib_response_mad((struct ib_mad_hdr *)wr->send_buf.mad);
|
||||
rcv_resp = ib_response_mad(&rwc->recv_buf.mad->mad_hdr);
|
||||
|
||||
if (send_resp == rcv_resp)
|
||||
/* both requests, or both responses. GIDs different */
|
||||
@@ -1811,8 +1811,8 @@ static inline int is_direct(u8 class)
|
||||
}
|
||||
|
||||
struct ib_mad_send_wr_private*
|
||||
ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
|
||||
struct ib_mad_recv_wc *wc)
|
||||
ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv,
|
||||
const struct ib_mad_recv_wc *wc)
|
||||
{
|
||||
struct ib_mad_send_wr_private *wr;
|
||||
struct ib_mad *mad;
|
||||
@@ -1836,7 +1836,7 @@ ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
|
||||
* been notified that the send has completed
|
||||
*/
|
||||
list_for_each_entry(wr, &mad_agent_priv->send_list, agent_list) {
|
||||
if (is_data_mad(mad_agent_priv, wr->send_buf.mad) &&
|
||||
if (is_rmpp_data_mad(mad_agent_priv, wr->send_buf.mad) &&
|
||||
wr->tid == mad->mad_hdr.tid &&
|
||||
wr->timeout &&
|
||||
rcv_has_same_class(wr, wc) &&
|
||||
@@ -1879,7 +1879,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
|
||||
}
|
||||
|
||||
/* Complete corresponding request */
|
||||
if (ib_response_mad(mad_recv_wc->recv_buf.mad)) {
|
||||
if (ib_response_mad(&mad_recv_wc->recv_buf.mad->mad_hdr)) {
|
||||
spin_lock_irqsave(&mad_agent_priv->lock, flags);
|
||||
mad_send_wr = ib_find_send_mad(mad_agent_priv, mad_recv_wc);
|
||||
if (!mad_send_wr) {
|
||||
@@ -1979,7 +1979,7 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
|
||||
snoop_recv(qp_info, &recv->header.recv_wc, IB_MAD_SNOOP_RECVS);
|
||||
|
||||
/* Validate MAD */
|
||||
if (!validate_mad(&recv->mad.mad, qp_info->qp->qp_num))
|
||||
if (!validate_mad(&recv->mad.mad.mad_hdr, qp_info->qp->qp_num))
|
||||
goto out;
|
||||
|
||||
response = kmem_cache_alloc(ib_mad_cache, GFP_KERNEL);
|
||||
@@ -2411,7 +2411,8 @@ find_send_wr(struct ib_mad_agent_private *mad_agent_priv,
|
||||
|
||||
list_for_each_entry(mad_send_wr, &mad_agent_priv->send_list,
|
||||
agent_list) {
|
||||
if (is_data_mad(mad_agent_priv, mad_send_wr->send_buf.mad) &&
|
||||
if (is_rmpp_data_mad(mad_agent_priv,
|
||||
mad_send_wr->send_buf.mad) &&
|
||||
&mad_send_wr->send_buf == send_buf)
|
||||
return mad_send_wr;
|
||||
}
|
||||
@@ -2938,7 +2939,7 @@ static int ib_mad_port_open(struct ib_device *device,
|
||||
init_mad_qp(port_priv, &port_priv->qp_info[1]);
|
||||
|
||||
cq_size = mad_sendq_size + mad_recvq_size;
|
||||
has_smi = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_INFINIBAND;
|
||||
has_smi = rdma_cap_ib_smi(device, port_num);
|
||||
if (has_smi)
|
||||
cq_size *= 2;
|
||||
|
||||
@@ -3057,9 +3058,6 @@ static void ib_mad_init_device(struct ib_device *device)
|
||||
{
|
||||
int start, end, i;
|
||||
|
||||
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
||||
return;
|
||||
|
||||
if (device->node_type == RDMA_NODE_IB_SWITCH) {
|
||||
start = 0;
|
||||
end = 0;
|
||||
@@ -3069,6 +3067,9 @@ static void ib_mad_init_device(struct ib_device *device)
|
||||
}
|
||||
|
||||
for (i = start; i <= end; i++) {
|
||||
if (!rdma_cap_ib_mad(device, i))
|
||||
continue;
|
||||
|
||||
if (ib_mad_port_open(device, i)) {
|
||||
dev_err(&device->dev, "Couldn't open port %d\n", i);
|
||||
goto error;
|
||||
@@ -3086,40 +3087,39 @@ error_agent:
|
||||
dev_err(&device->dev, "Couldn't close port %d\n", i);
|
||||
|
||||
error:
|
||||
i--;
|
||||
while (--i >= start) {
|
||||
if (!rdma_cap_ib_mad(device, i))
|
||||
continue;
|
||||
|
||||
while (i >= start) {
|
||||
if (ib_agent_port_close(device, i))
|
||||
dev_err(&device->dev,
|
||||
"Couldn't close port %d for agents\n", i);
|
||||
if (ib_mad_port_close(device, i))
|
||||
dev_err(&device->dev, "Couldn't close port %d\n", i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
static void ib_mad_remove_device(struct ib_device *device)
|
||||
{
|
||||
int i, num_ports, cur_port;
|
||||
|
||||
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
||||
return;
|
||||
int start, end, i;
|
||||
|
||||
if (device->node_type == RDMA_NODE_IB_SWITCH) {
|
||||
num_ports = 1;
|
||||
cur_port = 0;
|
||||
start = 0;
|
||||
end = 0;
|
||||
} else {
|
||||
num_ports = device->phys_port_cnt;
|
||||
cur_port = 1;
|
||||
start = 1;
|
||||
end = device->phys_port_cnt;
|
||||
}
|
||||
for (i = 0; i < num_ports; i++, cur_port++) {
|
||||
if (ib_agent_port_close(device, cur_port))
|
||||
|
||||
for (i = start; i <= end; i++) {
|
||||
if (!rdma_cap_ib_mad(device, i))
|
||||
continue;
|
||||
|
||||
if (ib_agent_port_close(device, i))
|
||||
dev_err(&device->dev,
|
||||
"Couldn't close port %d for agents\n",
|
||||
cur_port);
|
||||
if (ib_mad_port_close(device, cur_port))
|
||||
dev_err(&device->dev, "Couldn't close port %d\n",
|
||||
cur_port);
|
||||
"Couldn't close port %d for agents\n", i);
|
||||
if (ib_mad_port_close(device, i))
|
||||
dev_err(&device->dev, "Couldn't close port %d\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -213,8 +213,8 @@ struct ib_mad_port_private {
|
||||
int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);
|
||||
|
||||
struct ib_mad_send_wr_private *
|
||||
ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv,
|
||||
struct ib_mad_recv_wc *mad_recv_wc);
|
||||
ib_find_send_mad(const struct ib_mad_agent_private *mad_agent_priv,
|
||||
const struct ib_mad_recv_wc *mad_recv_wc);
|
||||
|
||||
void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
|
||||
struct ib_mad_send_wc *mad_send_wc);
|
||||
|
||||
@@ -780,8 +780,7 @@ static void mcast_event_handler(struct ib_event_handler *handler,
|
||||
int index;
|
||||
|
||||
dev = container_of(handler, struct mcast_device, event_handler);
|
||||
if (rdma_port_get_link_layer(dev->device, event->element.port_num) !=
|
||||
IB_LINK_LAYER_INFINIBAND)
|
||||
if (WARN_ON(!rdma_cap_ib_mcast(dev->device, event->element.port_num)))
|
||||
return;
|
||||
|
||||
index = event->element.port_num - dev->start_port;
|
||||
@@ -808,9 +807,6 @@ static void mcast_add_one(struct ib_device *device)
|
||||
int i;
|
||||
int count = 0;
|
||||
|
||||
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
||||
return;
|
||||
|
||||
dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
|
||||
GFP_KERNEL);
|
||||
if (!dev)
|
||||
@@ -824,8 +820,7 @@ static void mcast_add_one(struct ib_device *device)
|
||||
}
|
||||
|
||||
for (i = 0; i <= dev->end_port - dev->start_port; i++) {
|
||||
if (rdma_port_get_link_layer(device, dev->start_port + i) !=
|
||||
IB_LINK_LAYER_INFINIBAND)
|
||||
if (!rdma_cap_ib_mcast(device, dev->start_port + i))
|
||||
continue;
|
||||
port = &dev->port[i];
|
||||
port->dev = dev;
|
||||
@@ -863,8 +858,7 @@ static void mcast_remove_one(struct ib_device *device)
|
||||
flush_workqueue(mcast_wq);
|
||||
|
||||
for (i = 0; i <= dev->end_port - dev->start_port; i++) {
|
||||
if (rdma_port_get_link_layer(device, dev->start_port + i) ==
|
||||
IB_LINK_LAYER_INFINIBAND) {
|
||||
if (rdma_cap_ib_mcast(device, dev->start_port + i)) {
|
||||
port = &dev->port[i];
|
||||
deref_port(port);
|
||||
wait_for_completion(&port->comp);
|
||||
|
||||
@@ -450,7 +450,7 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
|
||||
struct ib_sa_port *port =
|
||||
&sa_dev->port[event->element.port_num - sa_dev->start_port];
|
||||
|
||||
if (rdma_port_get_link_layer(handler->device, port->port_num) != IB_LINK_LAYER_INFINIBAND)
|
||||
if (WARN_ON(!rdma_cap_ib_sa(handler->device, port->port_num)))
|
||||
return;
|
||||
|
||||
spin_lock_irqsave(&port->ah_lock, flags);
|
||||
@@ -540,7 +540,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
|
||||
ah_attr->port_num = port_num;
|
||||
ah_attr->static_rate = rec->rate;
|
||||
|
||||
force_grh = rdma_port_get_link_layer(device, port_num) == IB_LINK_LAYER_ETHERNET;
|
||||
force_grh = rdma_cap_eth_ah(device, port_num);
|
||||
|
||||
if (rec->hop_limit > 1 || force_grh) {
|
||||
ah_attr->ah_flags = IB_AH_GRH;
|
||||
@@ -1153,9 +1153,7 @@ static void ib_sa_add_one(struct ib_device *device)
|
||||
{
|
||||
struct ib_sa_device *sa_dev;
|
||||
int s, e, i;
|
||||
|
||||
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
||||
return;
|
||||
int count = 0;
|
||||
|
||||
if (device->node_type == RDMA_NODE_IB_SWITCH)
|
||||
s = e = 0;
|
||||
@@ -1175,7 +1173,7 @@ static void ib_sa_add_one(struct ib_device *device)
|
||||
|
||||
for (i = 0; i <= e - s; ++i) {
|
||||
spin_lock_init(&sa_dev->port[i].ah_lock);
|
||||
if (rdma_port_get_link_layer(device, i + 1) != IB_LINK_LAYER_INFINIBAND)
|
||||
if (!rdma_cap_ib_sa(device, i + 1))
|
||||
continue;
|
||||
|
||||
sa_dev->port[i].sm_ah = NULL;
|
||||
@@ -1189,8 +1187,13 @@ static void ib_sa_add_one(struct ib_device *device)
|
||||
goto err;
|
||||
|
||||
INIT_WORK(&sa_dev->port[i].update_task, update_sm_ah);
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
if (!count)
|
||||
goto free;
|
||||
|
||||
ib_set_client_data(device, &sa_client, sa_dev);
|
||||
|
||||
/*
|
||||
@@ -1204,19 +1207,20 @@ static void ib_sa_add_one(struct ib_device *device)
|
||||
if (ib_register_event_handler(&sa_dev->event_handler))
|
||||
goto err;
|
||||
|
||||
for (i = 0; i <= e - s; ++i)
|
||||
if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
|
||||
for (i = 0; i <= e - s; ++i) {
|
||||
if (rdma_cap_ib_sa(device, i + 1))
|
||||
update_sm_ah(&sa_dev->port[i].update_task);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
err:
|
||||
while (--i >= 0)
|
||||
if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND)
|
||||
while (--i >= 0) {
|
||||
if (rdma_cap_ib_sa(device, i + 1))
|
||||
ib_unregister_mad_agent(sa_dev->port[i].agent);
|
||||
|
||||
}
|
||||
free:
|
||||
kfree(sa_dev);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1233,7 +1237,7 @@ static void ib_sa_remove_one(struct ib_device *device)
|
||||
flush_workqueue(ib_wq);
|
||||
|
||||
for (i = 0; i <= sa_dev->end_port - sa_dev->start_port; ++i) {
|
||||
if (rdma_port_get_link_layer(device, i + 1) == IB_LINK_LAYER_INFINIBAND) {
|
||||
if (rdma_cap_ib_sa(device, i + 1)) {
|
||||
ib_unregister_mad_agent(sa_dev->port[i].agent);
|
||||
if (sa_dev->port[i].sm_ah)
|
||||
kref_put(&sa_dev->port[i].sm_ah->ref, free_sm_ah);
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
/*
|
||||
* Fixup a directed route SMP for sending
|
||||
* Return 0 if the SMP should be discarded
|
||||
* Return IB_SMI_DISCARD if the SMP should be discarded
|
||||
*/
|
||||
enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
|
||||
u8 node_type, int port_num)
|
||||
@@ -126,7 +126,7 @@ enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
|
||||
|
||||
/*
|
||||
* Adjust information for a received SMP
|
||||
* Return 0 if the SMP should be dropped
|
||||
* Return IB_SMI_DISCARD if the SMP should be dropped
|
||||
*/
|
||||
enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type,
|
||||
int port_num, int phys_port_cnt)
|
||||
|
||||
@@ -456,6 +456,7 @@ static void ib_device_release(struct device *device)
|
||||
{
|
||||
struct ib_device *dev = container_of(device, struct ib_device, dev);
|
||||
|
||||
kfree(dev->port_immutable);
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
|
||||
@@ -1253,8 +1253,7 @@ static void ib_ucm_add_one(struct ib_device *device)
|
||||
dev_t base;
|
||||
struct ib_ucm_device *ucm_dev;
|
||||
|
||||
if (!device->alloc_ucontext ||
|
||||
rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
||||
if (!device->alloc_ucontext || !rdma_cap_ib_cm(device, 1))
|
||||
return;
|
||||
|
||||
ucm_dev = kzalloc(sizeof *ucm_dev, GFP_KERNEL);
|
||||
|
||||
@@ -722,26 +722,13 @@ static ssize_t ucma_query_route(struct ucma_file *file,
|
||||
|
||||
resp.node_guid = (__force __u64) ctx->cm_id->device->node_guid;
|
||||
resp.port_num = ctx->cm_id->port_num;
|
||||
switch (rdma_node_get_transport(ctx->cm_id->device->node_type)) {
|
||||
case RDMA_TRANSPORT_IB:
|
||||
switch (rdma_port_get_link_layer(ctx->cm_id->device,
|
||||
ctx->cm_id->port_num)) {
|
||||
case IB_LINK_LAYER_INFINIBAND:
|
||||
ucma_copy_ib_route(&resp, &ctx->cm_id->route);
|
||||
break;
|
||||
case IB_LINK_LAYER_ETHERNET:
|
||||
ucma_copy_iboe_route(&resp, &ctx->cm_id->route);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case RDMA_TRANSPORT_IWARP:
|
||||
|
||||
if (rdma_cap_ib_sa(ctx->cm_id->device, ctx->cm_id->port_num))
|
||||
ucma_copy_ib_route(&resp, &ctx->cm_id->route);
|
||||
else if (rdma_protocol_roce(ctx->cm_id->device, ctx->cm_id->port_num))
|
||||
ucma_copy_iboe_route(&resp, &ctx->cm_id->route);
|
||||
else if (rdma_protocol_iwarp(ctx->cm_id->device, ctx->cm_id->port_num))
|
||||
ucma_copy_iw_route(&resp, &ctx->cm_id->route);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
if (copy_to_user((void __user *)(unsigned long)cmd.response,
|
||||
|
||||
@@ -99,7 +99,6 @@ struct ib_umad_port {
|
||||
};
|
||||
|
||||
struct ib_umad_device {
|
||||
int start_port, end_port;
|
||||
struct kobject kobj;
|
||||
struct ib_umad_port port[0];
|
||||
};
|
||||
@@ -426,11 +425,11 @@ static int is_duplicate(struct ib_umad_file *file,
|
||||
* the same TID, reject the second as a duplicate. This is more
|
||||
* restrictive than required by the spec.
|
||||
*/
|
||||
if (!ib_response_mad((struct ib_mad *) hdr)) {
|
||||
if (!ib_response_mad((struct ib_mad *) sent_hdr))
|
||||
if (!ib_response_mad(hdr)) {
|
||||
if (!ib_response_mad(sent_hdr))
|
||||
return 1;
|
||||
continue;
|
||||
} else if (!ib_response_mad((struct ib_mad *) sent_hdr))
|
||||
} else if (!ib_response_mad(sent_hdr))
|
||||
continue;
|
||||
|
||||
if (same_destination(&packet->mad.hdr, &sent_packet->mad.hdr))
|
||||
@@ -1273,16 +1272,10 @@ static void ib_umad_add_one(struct ib_device *device)
|
||||
{
|
||||
struct ib_umad_device *umad_dev;
|
||||
int s, e, i;
|
||||
int count = 0;
|
||||
|
||||
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
|
||||
return;
|
||||
|
||||
if (device->node_type == RDMA_NODE_IB_SWITCH)
|
||||
s = e = 0;
|
||||
else {
|
||||
s = 1;
|
||||
e = device->phys_port_cnt;
|
||||
}
|
||||
s = rdma_start_port(device);
|
||||
e = rdma_end_port(device);
|
||||
|
||||
umad_dev = kzalloc(sizeof *umad_dev +
|
||||
(e - s + 1) * sizeof (struct ib_umad_port),
|
||||
@@ -1292,25 +1285,34 @@ static void ib_umad_add_one(struct ib_device *device)
|
||||
|
||||
kobject_init(&umad_dev->kobj, &ib_umad_dev_ktype);
|
||||
|
||||
umad_dev->start_port = s;
|
||||
umad_dev->end_port = e;
|
||||
|
||||
for (i = s; i <= e; ++i) {
|
||||
if (!rdma_cap_ib_mad(device, i))
|
||||
continue;
|
||||
|
||||
umad_dev->port[i - s].umad_dev = umad_dev;
|
||||
|
||||
if (ib_umad_init_port(device, i, umad_dev,
|
||||
&umad_dev->port[i - s]))
|
||||
goto err;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
if (!count)
|
||||
goto free;
|
||||
|
||||
ib_set_client_data(device, &umad_client, umad_dev);
|
||||
|
||||
return;
|
||||
|
||||
err:
|
||||
while (--i >= s)
|
||||
ib_umad_kill_port(&umad_dev->port[i - s]);
|
||||
while (--i >= s) {
|
||||
if (!rdma_cap_ib_mad(device, i))
|
||||
continue;
|
||||
|
||||
ib_umad_kill_port(&umad_dev->port[i - s]);
|
||||
}
|
||||
free:
|
||||
kobject_put(&umad_dev->kobj);
|
||||
}
|
||||
|
||||
@@ -1322,8 +1324,10 @@ static void ib_umad_remove_one(struct ib_device *device)
|
||||
if (!umad_dev)
|
||||
return;
|
||||
|
||||
for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i)
|
||||
ib_umad_kill_port(&umad_dev->port[i]);
|
||||
for (i = 0; i <= rdma_end_port(device) - rdma_start_port(device); ++i) {
|
||||
if (rdma_cap_ib_mad(device, i + rdma_start_port(device)))
|
||||
ib_umad_kill_port(&umad_dev->port[i]);
|
||||
}
|
||||
|
||||
kobject_put(&umad_dev->kobj);
|
||||
}
|
||||
|
||||
@@ -48,6 +48,71 @@
|
||||
|
||||
#include "core_priv.h"
|
||||
|
||||
static const char * const ib_events[] = {
|
||||
[IB_EVENT_CQ_ERR] = "CQ error",
|
||||
[IB_EVENT_QP_FATAL] = "QP fatal error",
|
||||
[IB_EVENT_QP_REQ_ERR] = "QP request error",
|
||||
[IB_EVENT_QP_ACCESS_ERR] = "QP access error",
|
||||
[IB_EVENT_COMM_EST] = "communication established",
|
||||
[IB_EVENT_SQ_DRAINED] = "send queue drained",
|
||||
[IB_EVENT_PATH_MIG] = "path migration successful",
|
||||
[IB_EVENT_PATH_MIG_ERR] = "path migration error",
|
||||
[IB_EVENT_DEVICE_FATAL] = "device fatal error",
|
||||
[IB_EVENT_PORT_ACTIVE] = "port active",
|
||||
[IB_EVENT_PORT_ERR] = "port error",
|
||||
[IB_EVENT_LID_CHANGE] = "LID change",
|
||||
[IB_EVENT_PKEY_CHANGE] = "P_key change",
|
||||
[IB_EVENT_SM_CHANGE] = "SM change",
|
||||
[IB_EVENT_SRQ_ERR] = "SRQ error",
|
||||
[IB_EVENT_SRQ_LIMIT_REACHED] = "SRQ limit reached",
|
||||
[IB_EVENT_QP_LAST_WQE_REACHED] = "last WQE reached",
|
||||
[IB_EVENT_CLIENT_REREGISTER] = "client reregister",
|
||||
[IB_EVENT_GID_CHANGE] = "GID changed",
|
||||
};
|
||||
|
||||
const char *ib_event_msg(enum ib_event_type event)
|
||||
{
|
||||
size_t index = event;
|
||||
|
||||
return (index < ARRAY_SIZE(ib_events) && ib_events[index]) ?
|
||||
ib_events[index] : "unrecognized event";
|
||||
}
|
||||
EXPORT_SYMBOL(ib_event_msg);
|
||||
|
||||
static const char * const wc_statuses[] = {
|
||||
[IB_WC_SUCCESS] = "success",
|
||||
[IB_WC_LOC_LEN_ERR] = "local length error",
|
||||
[IB_WC_LOC_QP_OP_ERR] = "local QP operation error",
|
||||
[IB_WC_LOC_EEC_OP_ERR] = "local EE context operation error",
|
||||
[IB_WC_LOC_PROT_ERR] = "local protection error",
|
||||
[IB_WC_WR_FLUSH_ERR] = "WR flushed",
|
||||
[IB_WC_MW_BIND_ERR] = "memory management operation error",
|
||||
[IB_WC_BAD_RESP_ERR] = "bad response error",
|
||||
[IB_WC_LOC_ACCESS_ERR] = "local access error",
|
||||
[IB_WC_REM_INV_REQ_ERR] = "invalid request error",
|
||||
[IB_WC_REM_ACCESS_ERR] = "remote access error",
|
||||
[IB_WC_REM_OP_ERR] = "remote operation error",
|
||||
[IB_WC_RETRY_EXC_ERR] = "transport retry counter exceeded",
|
||||
[IB_WC_RNR_RETRY_EXC_ERR] = "RNR retry counter exceeded",
|
||||
[IB_WC_LOC_RDD_VIOL_ERR] = "local RDD violation error",
|
||||
[IB_WC_REM_INV_RD_REQ_ERR] = "remote invalid RD request",
|
||||
[IB_WC_REM_ABORT_ERR] = "operation aborted",
|
||||
[IB_WC_INV_EECN_ERR] = "invalid EE context number",
|
||||
[IB_WC_INV_EEC_STATE_ERR] = "invalid EE context state",
|
||||
[IB_WC_FATAL_ERR] = "fatal error",
|
||||
[IB_WC_RESP_TIMEOUT_ERR] = "response timeout error",
|
||||
[IB_WC_GENERAL_ERR] = "general error",
|
||||
};
|
||||
|
||||
const char *ib_wc_status_msg(enum ib_wc_status status)
|
||||
{
|
||||
size_t index = status;
|
||||
|
||||
return (index < ARRAY_SIZE(wc_statuses) && wc_statuses[index]) ?
|
||||
wc_statuses[index] : "unrecognized status";
|
||||
}
|
||||
EXPORT_SYMBOL(ib_wc_status_msg);
|
||||
|
||||
__attribute_const__ int ib_rate_to_mult(enum ib_rate rate)
|
||||
{
|
||||
switch (rate) {
|
||||
@@ -198,11 +263,9 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, struct ib_wc *wc,
|
||||
u32 flow_class;
|
||||
u16 gid_index;
|
||||
int ret;
|
||||
int is_eth = (rdma_port_get_link_layer(device, port_num) ==
|
||||
IB_LINK_LAYER_ETHERNET);
|
||||
|
||||
memset(ah_attr, 0, sizeof *ah_attr);
|
||||
if (is_eth) {
|
||||
if (rdma_cap_eth_ah(device, port_num)) {
|
||||
if (!(wc->wc_flags & IB_WC_GRH))
|
||||
return -EPROTOTYPE;
|
||||
|
||||
@@ -871,7 +934,7 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
|
||||
union ib_gid sgid;
|
||||
|
||||
if ((*qp_attr_mask & IB_QP_AV) &&
|
||||
(rdma_port_get_link_layer(qp->device, qp_attr->ah_attr.port_num) == IB_LINK_LAYER_ETHERNET)) {
|
||||
(rdma_cap_eth_ah(qp->device, qp_attr->ah_attr.port_num))) {
|
||||
ret = ib_query_gid(qp->device, qp_attr->ah_attr.port_num,
|
||||
qp_attr->ah_attr.grh.sgid_index, &sgid);
|
||||
if (ret)
|
||||
|
||||
@@ -757,6 +757,23 @@ static struct net_device *c2_pseudo_netdev_init(struct c2_dev *c2dev)
|
||||
return netdev;
|
||||
}
|
||||
|
||||
static int c2_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
struct ib_port_immutable *immutable)
|
||||
{
|
||||
struct ib_port_attr attr;
|
||||
int err;
|
||||
|
||||
err = c2_query_port(ibdev, port_num, &attr);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
immutable->pkey_tbl_len = attr.pkey_tbl_len;
|
||||
immutable->gid_tbl_len = attr.gid_tbl_len;
|
||||
immutable->core_cap_flags = RDMA_CORE_PORT_IWARP;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int c2_register_device(struct c2_dev *dev)
|
||||
{
|
||||
int ret = -ENOMEM;
|
||||
@@ -820,6 +837,7 @@ int c2_register_device(struct c2_dev *dev)
|
||||
dev->ibdev.reg_phys_mr = c2_reg_phys_mr;
|
||||
dev->ibdev.reg_user_mr = c2_reg_user_mr;
|
||||
dev->ibdev.dereg_mr = c2_dereg_mr;
|
||||
dev->ibdev.get_port_immutable = c2_port_immutable;
|
||||
|
||||
dev->ibdev.alloc_fmr = NULL;
|
||||
dev->ibdev.unmap_fmr = NULL;
|
||||
|
||||
@@ -1343,6 +1343,23 @@ static struct device_attribute *iwch_class_attributes[] = {
|
||||
&dev_attr_board_id,
|
||||
};
|
||||
|
||||
static int iwch_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
struct ib_port_immutable *immutable)
|
||||
{
|
||||
struct ib_port_attr attr;
|
||||
int err;
|
||||
|
||||
err = iwch_query_port(ibdev, port_num, &attr);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
immutable->pkey_tbl_len = attr.pkey_tbl_len;
|
||||
immutable->gid_tbl_len = attr.gid_tbl_len;
|
||||
immutable->core_cap_flags = RDMA_CORE_PORT_IWARP;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iwch_register_device(struct iwch_dev *dev)
|
||||
{
|
||||
int ret;
|
||||
@@ -1420,6 +1437,7 @@ int iwch_register_device(struct iwch_dev *dev)
|
||||
dev->ibdev.post_recv = iwch_post_receive;
|
||||
dev->ibdev.get_protocol_stats = iwch_get_mib;
|
||||
dev->ibdev.uverbs_abi_ver = IWCH_UVERBS_ABI_VERSION;
|
||||
dev->ibdev.get_port_immutable = iwch_port_immutable;
|
||||
|
||||
dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL);
|
||||
if (!dev->ibdev.iwcm)
|
||||
|
||||
@@ -465,6 +465,23 @@ static struct device_attribute *c4iw_class_attributes[] = {
|
||||
&dev_attr_board_id,
|
||||
};
|
||||
|
||||
static int c4iw_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
struct ib_port_immutable *immutable)
|
||||
{
|
||||
struct ib_port_attr attr;
|
||||
int err;
|
||||
|
||||
err = c4iw_query_port(ibdev, port_num, &attr);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
immutable->pkey_tbl_len = attr.pkey_tbl_len;
|
||||
immutable->gid_tbl_len = attr.gid_tbl_len;
|
||||
immutable->core_cap_flags = RDMA_CORE_PORT_IWARP;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int c4iw_register_device(struct c4iw_dev *dev)
|
||||
{
|
||||
int ret;
|
||||
@@ -542,6 +559,7 @@ int c4iw_register_device(struct c4iw_dev *dev)
|
||||
dev->ibdev.post_recv = c4iw_post_receive;
|
||||
dev->ibdev.get_protocol_stats = c4iw_get_mib;
|
||||
dev->ibdev.uverbs_abi_ver = C4IW_UVERBS_ABI_VERSION;
|
||||
dev->ibdev.get_port_immutable = c4iw_port_immutable;
|
||||
|
||||
dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL);
|
||||
if (!dev->ibdev.iwcm)
|
||||
|
||||
@@ -49,6 +49,9 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props);
|
||||
int ehca_query_port(struct ib_device *ibdev, u8 port,
|
||||
struct ib_port_attr *props);
|
||||
|
||||
enum rdma_protocol_type
|
||||
ehca_query_protocol(struct ib_device *device, u8 port_num);
|
||||
|
||||
int ehca_query_sma_attr(struct ehca_shca *shca, u8 port,
|
||||
struct ehca_sma_attr *attr);
|
||||
|
||||
|
||||
@@ -431,6 +431,23 @@ init_node_guid1:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ehca_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
struct ib_port_immutable *immutable)
|
||||
{
|
||||
struct ib_port_attr attr;
|
||||
int err;
|
||||
|
||||
err = ehca_query_port(ibdev, port_num, &attr);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
immutable->pkey_tbl_len = attr.pkey_tbl_len;
|
||||
immutable->gid_tbl_len = attr.gid_tbl_len;
|
||||
immutable->core_cap_flags = RDMA_CORE_PORT_IBA_IB;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ehca_init_device(struct ehca_shca *shca)
|
||||
{
|
||||
int ret;
|
||||
@@ -510,6 +527,7 @@ static int ehca_init_device(struct ehca_shca *shca)
|
||||
shca->ib_device.process_mad = ehca_process_mad;
|
||||
shca->ib_device.mmap = ehca_mmap;
|
||||
shca->ib_device.dma_ops = &ehca_dma_mapping_ops;
|
||||
shca->ib_device.get_port_immutable = ehca_port_immutable;
|
||||
|
||||
if (EHCA_BMASK_GET(HCA_CAP_SRQ, shca->hca_cap)) {
|
||||
shca->ib_device.uverbs_cmd_mask |=
|
||||
|
||||
Loaded 20 of 48 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user