[openib-general] [PATCH] extend ib_device node_type to include iWarp
Sean Hefty
sean.hefty at intel.com
Mon Jan 30 12:07:50 PST 2006
The following patch extends the node_type associated with an ib_device
to support iWarp without breaking the ABI. Comments on this approach?
Signed-off-by: Sean Hefty <sean.hefty at intel.com>
---
Index: ulp/ipoib/ipoib_main.c
===================================================================
--- ulp/ipoib/ipoib_main.c (revision 5098)
+++ 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 ((device->node_type & IB_NODE_IB) != IB_NODE_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 & IB_NODE_SWITCH) == IB_NODE_SWITCH) {
s = 0;
e = 0;
} else {
Index: ulp/srp/ib_srp.c
===================================================================
--- ulp/srp/ib_srp.c (revision 5098)
+++ 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 ((device->node_type & IB_NODE_IB) != IB_NODE_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 & IB_NODE_SWITCH) == IB_NODE_SWITCH) {
s = 0;
e = 0;
} else {
Index: include/rdma/ib_verbs.h
===================================================================
--- include/rdma/ib_verbs.h (revision 5098)
+++ include/rdma/ib_verbs.h (working copy)
@@ -56,7 +56,17 @@ union ib_gid {
} global;
};
-enum ib_node_type {
+/*
+ * 8-bit node type - for IB this maps to NodeInfo:NodeType.
+ */
+enum {
+ /* bits 7:4 - transport type */
+ IB_NODE_TRANSPORT_MASK = 0xF0,
+ IB_NODE_IB = (0<<4),
+ IB_NODE_IWARP = (1<<4),
+
+ /* bits 3:0 - device type */
+ IB_NODE_DEVICE_MASK = 0x0F,
IB_NODE_CA = 1,
IB_NODE_SWITCH,
IB_NODE_ROUTER
Index: include/rdma/ib_addr.h
===================================================================
--- include/rdma/ib_addr.h (revision 5098)
+++ 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;
+ u8 dev_type;
};
/**
Index: core/cm.c
===================================================================
--- core/cm.c (revision 5098)
+++ core/cm.c (working copy)
@@ -3245,6 +3245,9 @@ static void cm_add_one(struct ib_device
int ret;
u8 i;
+ if ((device->node_type & IB_NODE_IB) != IB_NODE_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 5098)
+++ 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 = IB_NODE_IB | IB_NODE_CA;
break;
default:
return -EADDRNOTAVAIL;
Index: core/local_sa.c
===================================================================
--- core/local_sa.c (revision 5194)
+++ 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 ((device->node_type & IB_NODE_IB) != IB_NODE_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 5194)
+++ 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 ((device->node_type & IB_NODE_IB) != IB_NODE_IB)
+ return;
+
+ if ((device->node_type & IB_NODE_SWITCH) == IB_NODE_SWITCH)
s = e = 0;
else {
s = 1;
Index: core/user_mad.c
===================================================================
--- core/user_mad.c (revision 5098)
+++ 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 ((device->node_type & IB_NODE_IB) != IB_NODE_IB)
+ return;
+
+ if ((device->node_type & IB_NODE_SWITCH) == IB_NODE_SWITCH)
s = e = 0;
else {
s = 1;
Index: core/cma.c
===================================================================
--- core/cma.c (revision 5194)
+++ core/cma.c (working copy)
@@ -244,8 +244,9 @@ 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:
+ switch (id_priv->id.route.addr.dev_addr.dev_type &
+ IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_IB:
return cma_acquire_ib_dev(id_priv);
default:
return -ENODEV;
@@ -324,8 +325,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 (id->device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_IB:
ret = cma_init_ib_qp(id_priv, qp);
break;
default:
@@ -413,8 +414,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 (id_priv->id.device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_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 +541,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 (id_priv->id.device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_IB:
rdma_addr_cancel(&id_priv->id.route.addr.dev_addr);
break;
default:
@@ -560,8 +561,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 (id_priv->id.device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_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 +621,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 (id->device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_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 +783,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 = IB_NODE_IB | IB_NODE_CA;
id_priv = container_of(id, struct rdma_id_private, id);
id_priv->state = CMA_CONNECT;
@@ -984,8 +985,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 (id->device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_IB:
ret = cma_ib_listen(id_priv);
break;
default:
@@ -1077,8 +1078,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 (id->device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_IB:
ret = cma_resolve_ib_route(id_priv, timeout_ms);
break;
default:
@@ -1372,8 +1373,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 (id->device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_IB:
ret = cma_connect_ib(id_priv, conn_param);
break;
default:
@@ -1431,8 +1432,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 (id->device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_IB:
if (conn_param)
ret = cma_accept_ib(id_priv, conn_param);
else
@@ -1464,8 +1465,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 (id->device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_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 +1492,8 @@ int rdma_disconnect(struct rdma_cm_id *i
if (ret)
goto out;
- switch (id->device->node_type) {
- case IB_NODE_CA:
+ switch (id->device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_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 5098)
+++ 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 ((device->node_type & IB_NODE_IB) != IB_NODE_IB)
+ return;
+
+ if ((device->node_type & IB_NODE_SWITCH) == IB_NODE_SWITCH) {
start = 0;
end = 0;
} else {
Index: core/sysfs.c
===================================================================
--- core/sysfs.c (revision 5098)
+++ core/sysfs.c (working copy)
@@ -590,7 +590,7 @@ static ssize_t show_node_type(struct cla
if (!ibdev_is_alive(dev))
return -ENODEV;
- switch (dev->node_type) {
+ switch (dev->node_type & IB_NODE_DEVICE_MASK) {
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);
@@ -687,7 +687,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 & IB_NODE_SWITCH) == IB_NODE_SWITCH) {
ret = add_port(device, 0);
if (ret)
goto err_put;
Index: core/ucm.c
===================================================================
--- core/ucm.c (revision 5117)
+++ 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 ||
+ (device->node_type & IB_NODE_IB) != IB_NODE_IB)
return;
ucm_dev = kzalloc(sizeof *ucm_dev, GFP_KERNEL);
Index: core/ucma.c
===================================================================
--- core/ucma.c (revision 5098)
+++ 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 (ctx->cm_id->device->node_type & IB_NODE_TRANSPORT_MASK) {
+ case IB_NODE_IB:
ucma_copy_ib_route(&resp, &ctx->cm_id->route);
default:
break;
Index: core/ping.c
===================================================================
--- core/ping.c (revision 5098)
+++ 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 ((device->node_type & IB_NODE_IB) != IB_NODE_IB)
+ return;
+
+ if ((device->node_type & IB_NODE_SWITCH) == IB_NODE_SWITCH) {
num_ports = 1;
cur_port = 0;
} else {
More information about the general
mailing list