[openib-general] [PATCH v3] extend ib_device node_type to include iWarp
Sean Hefty
sean.hefty at intel.com
Tue Jan 31 16:39:45 PST 2006
Here's an updated version of the patch based on Roland's comments.
Patch includes updates to mthca, ipath, and ehca drivers.
I did not update any userspace verbs support code.
Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Index: ulp/ipoib/ipoib_main.c
===================================================================
--- ulp/ipoib/ipoib_main.c (revision 5240)
+++ ulp/ipoib/ipoib_main.c (working copy)
@@ -1078,13 +1078,16 @@ static void ipoib_add_one(struct ib_devi
struct ipoib_dev_priv *priv;
int s, e, p;
+ if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ return;
+
dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
if (!dev_list)
return;
INIT_LIST_HEAD(dev_list);
- if (device->node_type == IB_NODE_SWITCH) {
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
s = 0;
e = 0;
} else {
Index: ulp/srp/ib_srp.c
===================================================================
--- ulp/srp/ib_srp.c (revision 5240)
+++ ulp/srp/ib_srp.c (working copy)
@@ -1581,13 +1581,16 @@ static void srp_add_one(struct ib_device
struct srp_host *host;
int s, e, p;
+ if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ return;
+
dev_list = kmalloc(sizeof *dev_list, GFP_KERNEL);
if (!dev_list)
return;
INIT_LIST_HEAD(dev_list);
- if (device->node_type == IB_NODE_SWITCH) {
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
s = 0;
e = 0;
} else {
Index: ulp/kdapl/ib/dapl_provider.c
===================================================================
--- ulp/kdapl/ib/dapl_provider.c (revision 5240)
+++ ulp/kdapl/ib/dapl_provider.c (working copy)
@@ -331,7 +331,7 @@ static void dapl_add_dev(struct ib_devic
dapl_dbg_log(DAPL_DBG_TYPE_UTIL, "dapl_add_dev called for %s\n",
device->name);
- if (IB_NODE_CA == device->node_type)
+ if (RDMA_NODE_IB_CA == device->node_type)
for (i = 1; i <= device->phys_port_cnt; i++)
dapl_add_port(device, i);
}
Index: include/rdma/ib_verbs.h
===================================================================
--- include/rdma/ib_verbs.h (revision 5240)
+++ include/rdma/ib_verbs.h (working copy)
@@ -56,12 +56,34 @@ union ib_gid {
} global;
};
-enum ib_node_type {
- IB_NODE_CA = 1,
- IB_NODE_SWITCH,
- IB_NODE_ROUTER
+enum rdma_node_type {
+ /* IB values map to NodeInfo:NodeType. */
+ RDMA_NODE_IB_CA = 1,
+ RDMA_NODE_IB_SWITCH,
+ RDMA_NODE_IB_ROUTER,
+ RDMA_NODE_RNIC
};
+enum rdma_transport_type {
+ RDMA_TRANSPORT_IB,
+ RDMA_TRANSPORT_IWARP
+};
+
+static inline enum rdma_transport_type
+rdma_node_get_transport(enum rdma_node_type node_type)
+{
+ switch (node_type) {
+ case RDMA_NODE_IB_CA:
+ case RDMA_NODE_IB_SWITCH:
+ case RDMA_NODE_IB_ROUTER:
+ return RDMA_TRANSPORT_IB;
+ case RDMA_NODE_RNIC:
+ return RDMA_TRANSPORT_IWARP;
+ default:
+ BUG();
+ }
+}
+
enum ib_device_cap_flags {
IB_DEVICE_RESIZE_MAX_WR = 1,
IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
Index: include/rdma/ib_addr.h
===================================================================
--- include/rdma/ib_addr.h (revision 5240)
+++ include/rdma/ib_addr.h (working copy)
@@ -42,7 +42,7 @@ struct rdma_dev_addr {
unsigned char src_dev_addr[MAX_ADDR_LEN];
unsigned char dst_dev_addr[MAX_ADDR_LEN];
unsigned char broadcast[MAX_ADDR_LEN];
- enum ib_node_type dev_type;
+ enum rdma_node_type dev_type;
};
/**
Index: core/cm.c
===================================================================
--- core/cm.c (revision 5240)
+++ core/cm.c (working copy)
@@ -3245,6 +3245,9 @@ static void cm_add_one(struct ib_device
int ret;
u8 i;
+ if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ return;
+
cm_dev = kmalloc(sizeof(*cm_dev) + sizeof(*port) *
device->phys_port_cnt, GFP_KERNEL);
if (!cm_dev)
Index: core/addr.c
===================================================================
--- core/addr.c (revision 5240)
+++ core/addr.c (working copy)
@@ -63,7 +63,7 @@ static int copy_addr(struct rdma_dev_add
{
switch (dev->type) {
case ARPHRD_INFINIBAND:
- dev_addr->dev_type = IB_NODE_CA;
+ dev_addr->dev_type = RDMA_NODE_IB_CA;
break;
default:
return -EADDRNOTAVAIL;
Index: core/local_sa.c
===================================================================
--- core/local_sa.c (revision 5240)
+++ core/local_sa.c (working copy)
@@ -362,6 +362,9 @@ static void sa_db_add_one(struct ib_devi
struct sa_db_port *port;
int i;
+ 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)
Index: core/sa_query.c
===================================================================
--- core/sa_query.c (revision 5240)
+++ core/sa_query.c (working copy)
@@ -912,7 +912,10 @@ static void ib_sa_add_one(struct ib_devi
struct ib_sa_device *sa_dev;
int s, e, i;
- if (device->node_type == IB_NODE_SWITCH)
+ 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;
Index: core/device.c
===================================================================
--- core/device.c (revision 5240)
+++ core/device.c (working copy)
@@ -514,7 +514,7 @@ int ib_query_port(struct ib_device *devi
u8 port_num,
struct ib_port_attr *port_attr)
{
- if (device->node_type == IB_NODE_SWITCH) {
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
if (port_num)
return -EINVAL;
} else if (port_num < 1 || port_num > device->phys_port_cnt)
@@ -589,7 +589,7 @@ int ib_modify_port(struct ib_device *dev
u8 port_num, int port_modify_mask,
struct ib_port_modify *port_modify)
{
- if (device->node_type == IB_NODE_SWITCH) {
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
if (port_num)
return -EINVAL;
} else if (port_num < 1 || port_num > device->phys_port_cnt)
Index: core/user_mad.c
===================================================================
--- core/user_mad.c (revision 5240)
+++ core/user_mad.c (working copy)
@@ -936,7 +936,10 @@ static void ib_umad_add_one(struct ib_de
struct ib_umad_device *umad_dev;
int s, e, i;
- if (device->node_type == IB_NODE_SWITCH)
+ 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;
Index: core/cma.c
===================================================================
--- core/cma.c (revision 5240)
+++ core/cma.c (working copy)
@@ -244,8 +244,10 @@ static int cma_acquire_ib_dev(struct rdm
static int cma_acquire_dev(struct rdma_id_private *id_priv)
{
- switch (id_priv->id.route.addr.dev_addr.dev_type) {
- case IB_NODE_CA:
+ enum rdma_node_type dev_type = id_priv->id.route.addr.dev_addr.dev_type;
+
+ switch (rdma_node_get_transport(dev_type)) {
+ case RDMA_TRANSPORT_IB:
return cma_acquire_ib_dev(id_priv);
default:
return -ENODEV;
@@ -324,8 +326,8 @@ int rdma_create_qp(struct rdma_cm_id *id
if (IS_ERR(qp))
return PTR_ERR(qp);
- switch (id->device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id->device->node_type)) {
+ case RDMA_TRANSPORT_IB:
ret = cma_init_ib_qp(id_priv, qp);
break;
default:
@@ -413,8 +415,8 @@ int rdma_init_qp_attr(struct rdma_cm_id
int ret;
id_priv = container_of(id, struct rdma_id_private, id);
- switch (id_priv->id.device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id_priv->id.device->node_type)) {
+ case RDMA_TRANSPORT_IB:
ret = ib_cm_init_qp_attr(id_priv->cm_id.ib, qp_attr,
qp_attr_mask);
if (qp_attr->qp_state == IB_QPS_RTR)
@@ -540,8 +542,8 @@ static int cma_notify_user(struct rdma_i
static void cma_cancel_addr(struct rdma_id_private *id_priv)
{
- switch (id_priv->id.device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id_priv->id.device->node_type)) {
+ case RDMA_TRANSPORT_IB:
rdma_addr_cancel(&id_priv->id.route.addr.dev_addr);
break;
default:
@@ -560,8 +562,8 @@ static void cma_destroy_listen(struct rd
cma_exch(id_priv, CMA_DESTROYING);
if (id_priv->cma_dev) {
- switch (id_priv->id.device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id_priv->id.device->node_type)) {
+ case RDMA_TRANSPORT_IB:
if (id_priv->cm_id.ib && !IS_ERR(id_priv->cm_id.ib))
ib_destroy_cm_id(id_priv->cm_id.ib);
break;
@@ -620,8 +622,8 @@ void rdma_destroy_id(struct rdma_cm_id *
cma_cancel_operation(id_priv, state);
if (id_priv->cma_dev) {
- switch (id->device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id->device->node_type)) {
+ case RDMA_TRANSPORT_IB:
if (id_priv->cm_id.ib && !IS_ERR(id_priv->cm_id.ib))
ib_destroy_cm_id(id_priv->cm_id.ib);
break;
@@ -782,7 +784,7 @@ static struct rdma_id_private* cma_new_i
ib_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
ib_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid);
ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey));
- rt->addr.dev_addr.dev_type = IB_NODE_CA;
+ rt->addr.dev_addr.dev_type = RDMA_NODE_IB_CA;
id_priv = container_of(id, struct rdma_id_private, id);
id_priv->state = CMA_CONNECT;
@@ -984,8 +986,8 @@ int rdma_listen(struct rdma_cm_id *id, i
return -EINVAL;
if (id->device) {
- switch (id->device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id->device->node_type)) {
+ case RDMA_TRANSPORT_IB:
ret = cma_ib_listen(id_priv);
break;
default:
@@ -1077,8 +1079,8 @@ int rdma_resolve_route(struct rdma_cm_id
return -EINVAL;
atomic_inc(&id_priv->refcount);
- switch (id->device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id->device->node_type)) {
+ case RDMA_TRANSPORT_IB:
ret = cma_resolve_ib_route(id_priv, timeout_ms);
break;
default:
@@ -1372,8 +1374,8 @@ int rdma_connect(struct rdma_cm_id *id,
id_priv->srq = conn_param->srq;
}
- switch (id->device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id->device->node_type)) {
+ case RDMA_TRANSPORT_IB:
ret = cma_connect_ib(id_priv, conn_param);
break;
default:
@@ -1431,8 +1433,8 @@ int rdma_accept(struct rdma_cm_id *id, s
id_priv->srq = conn_param->srq;
}
- switch (id->device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id->device->node_type)) {
+ case RDMA_TRANSPORT_IB:
if (conn_param)
ret = cma_accept_ib(id_priv, conn_param);
else
@@ -1464,8 +1466,8 @@ int rdma_reject(struct rdma_cm_id *id, c
if (!cma_comp(id_priv, CMA_CONNECT))
return -EINVAL;
- switch (id->device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id->device->node_type)) {
+ case RDMA_TRANSPORT_IB:
ret = ib_send_cm_rej(id_priv->cm_id.ib,
IB_CM_REJ_CONSUMER_DEFINED, NULL, 0,
private_data, private_data_len);
@@ -1491,8 +1493,8 @@ int rdma_disconnect(struct rdma_cm_id *i
if (ret)
goto out;
- switch (id->device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(id->device->node_type)) {
+ case RDMA_TRANSPORT_IB:
/* 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);
Index: core/mad.c
===================================================================
--- core/mad.c (revision 5240)
+++ core/mad.c (working copy)
@@ -2661,7 +2661,10 @@ static void ib_mad_init_device(struct ib
{
int start, end, i;
- if (device->node_type == IB_NODE_SWITCH) {
+ if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ return;
+
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
start = 0;
end = 0;
} else {
@@ -2708,7 +2711,7 @@ static void ib_mad_remove_device(struct
{
int i, num_ports, cur_port;
- if (device->node_type == IB_NODE_SWITCH) {
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
num_ports = 1;
cur_port = 0;
} else {
Index: core/cache.c
===================================================================
--- core/cache.c (revision 5240)
+++ core/cache.c (working copy)
@@ -61,12 +61,13 @@ struct ib_update_work {
static inline int start_port(struct ib_device *device)
{
- return device->node_type == IB_NODE_SWITCH ? 0 : 1;
+ return (device->node_type == RDMA_NODE_IB_SWITCH) ? 0 : 1;
}
static inline int end_port(struct ib_device *device)
{
- return device->node_type == IB_NODE_SWITCH ? 0 : device->phys_port_cnt;
+ return (device->node_type == RDMA_NODE_IB_SWITCH) ?
+ 0 : device->phys_port_cnt;
}
int ib_get_cached_gid(struct ib_device *device,
Index: core/sysfs.c
===================================================================
--- core/sysfs.c (revision 5240)
+++ core/sysfs.c (working copy)
@@ -591,10 +591,14 @@ static ssize_t show_node_type(struct cla
return -ENODEV;
switch (dev->node_type) {
- case IB_NODE_CA: return sprintf(buf, "%d: CA\n", dev->node_type);
- case IB_NODE_SWITCH: return sprintf(buf, "%d: switch\n", dev->node_type);
- case IB_NODE_ROUTER: return sprintf(buf, "%d: router\n", dev->node_type);
- default: return sprintf(buf, "%d: <unknown>\n", dev->node_type);
+ case RDMA_NODE_IB_CA:
+ return sprintf(buf, "%d: CA\n", dev->node_type);
+ case RDMA_NODE_IB_SWITCH:
+ return sprintf(buf, "%d: switch\n", dev->node_type);
+ case RDMA_NODE_IB_ROUTER:
+ return sprintf(buf, "%d: router\n", dev->node_type);
+ default:
+ return sprintf(buf, "%d: <unknown>\n", dev->node_type);
}
}
@@ -687,7 +691,7 @@ int ib_device_register_sysfs(struct ib_d
if (ret)
goto err_put;
- if (device->node_type == IB_NODE_SWITCH) {
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
ret = add_port(device, 0);
if (ret)
goto err_put;
Index: core/ucm.c
===================================================================
--- core/ucm.c (revision 5240)
+++ core/ucm.c (working copy)
@@ -1255,7 +1255,8 @@ static void ib_ucm_add_one(struct ib_dev
{
struct ib_ucm_device *ucm_dev;
- if (!device->alloc_ucontext)
+ if (!device->alloc_ucontext ||
+ rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
return;
ucm_dev = kzalloc(sizeof *ucm_dev, GFP_KERNEL);
Index: core/ucma.c
===================================================================
--- core/ucma.c (revision 5240)
+++ core/ucma.c (working copy)
@@ -479,8 +479,8 @@ static ssize_t ucma_query_route(struct u
sizeof(struct sockaddr_in6));
resp.node_guid = ctx->cm_id->device->node_guid;
resp.port_num = ctx->cm_id->port_num;
- switch (ctx->cm_id->device->node_type) {
- case IB_NODE_CA:
+ switch (rdma_node_get_transport(ctx->cm_id->device->node_type)) {
+ case RDMA_TRANSPORT_IB:
ucma_copy_ib_route(&resp, &ctx->cm_id->route);
default:
break;
Index: core/smi.c
===================================================================
--- core/smi.c (revision 5240)
+++ core/smi.c (working copy)
@@ -64,7 +64,7 @@ int smi_handle_dr_smp_send(struct ib_smp
/* C14-9:2 */
if (hop_ptr && hop_ptr < hop_cnt) {
- if (node_type != IB_NODE_SWITCH)
+ if (node_type != RDMA_NODE_IB_SWITCH)
return 0;
/* smp->return_path set when received */
@@ -77,7 +77,7 @@ int smi_handle_dr_smp_send(struct ib_smp
if (hop_ptr == hop_cnt) {
/* smp->return_path set when received */
smp->hop_ptr++;
- return (node_type == IB_NODE_SWITCH ||
+ return (node_type == RDMA_NODE_IB_SWITCH ||
smp->dr_dlid == IB_LID_PERMISSIVE);
}
@@ -95,7 +95,7 @@ int smi_handle_dr_smp_send(struct ib_smp
/* C14-13:2 */
if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
- if (node_type != IB_NODE_SWITCH)
+ if (node_type != RDMA_NODE_IB_SWITCH)
return 0;
smp->hop_ptr--;
@@ -107,7 +107,7 @@ int smi_handle_dr_smp_send(struct ib_smp
if (hop_ptr == 1) {
smp->hop_ptr--;
/* C14-13:3 -- SMPs destined for SM shouldn't be here */
- return (node_type == IB_NODE_SWITCH ||
+ return (node_type == RDMA_NODE_IB_SWITCH ||
smp->dr_slid == IB_LID_PERMISSIVE);
}
@@ -142,7 +142,7 @@ int smi_handle_dr_smp_recv(struct ib_smp
/* C14-9:2 -- intermediate hop */
if (hop_ptr && hop_ptr < hop_cnt) {
- if (node_type != IB_NODE_SWITCH)
+ if (node_type != RDMA_NODE_IB_SWITCH)
return 0;
smp->return_path[hop_ptr] = port_num;
@@ -156,7 +156,7 @@ int smi_handle_dr_smp_recv(struct ib_smp
smp->return_path[hop_ptr] = port_num;
/* smp->hop_ptr updated when sending */
- return (node_type == IB_NODE_SWITCH ||
+ return (node_type == RDMA_NODE_IB_SWITCH ||
smp->dr_dlid == IB_LID_PERMISSIVE);
}
@@ -175,7 +175,7 @@ int smi_handle_dr_smp_recv(struct ib_smp
/* C14-13:2 */
if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
- if (node_type != IB_NODE_SWITCH)
+ if (node_type != RDMA_NODE_IB_SWITCH)
return 0;
/* smp->hop_ptr updated when sending */
@@ -190,7 +190,7 @@ int smi_handle_dr_smp_recv(struct ib_smp
return 1;
}
/* smp->hop_ptr updated when sending */
- return (node_type == IB_NODE_SWITCH);
+ return (node_type == RDMA_NODE_IB_SWITCH);
}
/* C14-13:4 -- hop_ptr = 0 -> give to SM */
Index: core/ping.c
===================================================================
--- core/ping.c (revision 5240)
+++ core/ping.c (working copy)
@@ -247,7 +247,10 @@ static void ib_ping_init_device(struct i
{
int num_ports, cur_port, i;
- if (device->node_type == IB_NODE_SWITCH) {
+ if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ return;
+
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
num_ports = 1;
cur_port = 0;
} else {
@@ -278,7 +281,7 @@ static void ib_ping_remove_device(struct
{
int i, num_ports, cur_port;
- if (device->node_type == IB_NODE_SWITCH) {
+ if (device->node_type == RDMA_NODE_IB_SWITCH) {
num_ports = 1;
cur_port = 0;
} else {
Index: hw/ehca/ehca_main.c
===================================================================
--- hw/ehca/ehca_main.c (revision 5240)
+++ hw/ehca/ehca_main.c (working copy)
@@ -382,7 +382,7 @@ int ehca_register_device(struct ehca_shc
(1ull << IB_USER_VERBS_CMD_ATTACH_MCAST) |
(1ull << IB_USER_VERBS_CMD_DETACH_MCAST);
- shca->ib_device.node_type = IB_NODE_CA;
+ shca->ib_device.node_type = RDMA_NODE_IB_CA;
shca->ib_device.phys_port_cnt = shca->num_ports;
shca->ib_device.dma_device = &shca->ibmebus_dev->ofdev.dev;
shca->ib_device.query_device = ehca_query_device;
Index: hw/ipath/ipath_verbs.c
===================================================================
--- hw/ipath/ipath_verbs.c (revision 5240)
+++ hw/ipath/ipath_verbs.c (working copy)
@@ -6034,7 +6034,7 @@ static int ipath_register_ib_device(cons
(1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
(1ull << IB_USER_VERBS_CMD_DESTROY_SRQ) |
(1ull << IB_USER_VERBS_CMD_POST_SRQ_RECV);
- dev->node_type = IB_NODE_CA;
+ dev->node_type = RDMA_NODE_IB_CA;
dev->phys_port_cnt = 1;
dev->dma_device = ipath_layer_get_pcidev(t);
dev->class_dev.dev = dev->dma_device;
Index: hw/mthca/mthca_provider.c
===================================================================
--- hw/mthca/mthca_provider.c (revision 5240)
+++ hw/mthca/mthca_provider.c (working copy)
@@ -1240,7 +1240,7 @@ int mthca_register_device(struct mthca_d
(1ull << IB_USER_VERBS_CMD_CREATE_SRQ) |
(1ull << IB_USER_VERBS_CMD_MODIFY_SRQ) |
(1ull << IB_USER_VERBS_CMD_DESTROY_SRQ);
- dev->ib_dev.node_type = IB_NODE_CA;
+ dev->ib_dev.node_type = RDMA_NODE_IB_CA;
dev->ib_dev.phys_port_cnt = dev->limits.num_ports;
dev->ib_dev.dma_device = &dev->pdev->dev;
dev->ib_dev.class_dev.dev = &dev->pdev->dev;
More information about the general
mailing list