From patchwork Thu Dec 10 17:05:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 66301 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nBAH4ENj020790 for ; Thu, 10 Dec 2009 17:04:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761212AbZLJREG (ORCPT ); Thu, 10 Dec 2009 12:04:06 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761214AbZLJREG (ORCPT ); Thu, 10 Dec 2009 12:04:06 -0500 Received: from mail.mellanox.co.il ([194.90.237.43]:36542 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1761212AbZLJREF (ORCPT ); Thu, 10 Dec 2009 12:04:05 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.co.il) with SMTP; 10 Dec 2009 19:13:13 +0200 Received: from localhost ([10.4.1.30]) by mtlexch01.mtl.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Dec 2009 19:04:06 +0200 Date: Thu, 10 Dec 2009 19:05:36 +0200 From: Eli Cohen To: Roland Dreier , jgunthorpe@obsidianresearch.com Cc: Linux RDMA list , ewg Subject: [PATCH] rdmaoe/libibverbs: handle binary compatibility Message-ID: <20091210170536.GA3229@mtls03> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-OriginalArrivalTime: 10 Dec 2009 17:04:07.0030 (UTC) FILETIME=[C8A03160:01CA79BA] X-TM-AS-Product-Ver: SMEX-8.0.0.1181-6.000.1038-17062.000 X-TM-AS-Result: No--14.475100-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/examples/devinfo.c b/examples/devinfo.c index 88e0557..393ec04 100644 --- a/examples/devinfo.c +++ b/examples/devinfo.c @@ -184,15 +184,14 @@ static int print_all_port_gids(struct ibv_context *ctx, uint8_t port_num, int tb return rc; } -static const char *transport_type_str(enum rdma_transport_type type) +static const char *link_layer_str(uint8_t link_layer) { - switch (type) { - case RDMA_TRANSPORT_IB: + switch (link_layer) { + case IBV_LINK_LAYER_UNSPECIFIED: + case IBV_LINK_LAYER_INFINIBAND: return "IB"; - case RDMA_TRANSPORT_IWARP: - return "IWARP"; - case RDMA_TRANSPORT_RDMAOE: - return "RDMAOE"; + case IBV_LINK_LAYER_ETHERNET: + return "Ethernet"; default: return "Unknown"; } @@ -298,7 +297,7 @@ static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port) printf("\t\t\tsm_lid:\t\t\t%d\n", port_attr.sm_lid); printf("\t\t\tport_lid:\t\t%d\n", port_attr.lid); printf("\t\t\tport_lmc:\t\t0x%02x\n", port_attr.lmc); - printf("\t\t\ttrasnport_type:\t\t%s\n", transport_type_str(port_attr.transport)); + printf("\t\t\tlink_layer:\t\t%s\n", link_layer_str(port_attr.link_layer)); if (verbose) { printf("\t\t\tmax_msg_sz:\t\t0x%x\n", port_attr.max_msg_sz); diff --git a/examples/rc_pingpong.c b/examples/rc_pingpong.c index e0cde29..4d0bd0d 100644 --- a/examples/rc_pingpong.c +++ b/examples/rc_pingpong.c @@ -653,7 +653,7 @@ int main(int argc, char *argv[]) } my_dest.lid = ctx->portinfo.lid; - if (ctx->portinfo.transport == RDMA_TRANSPORT_RDMAOE) { + if (ctx->portinfo.link_layer == IBV_LINK_LAYER_ETHERNET) { if (!grh) { fprintf(stderr, "Must supply remote gid\n"); return 1; diff --git a/examples/srq_pingpong.c b/examples/srq_pingpong.c index bd10f90..eda9013 100644 --- a/examples/srq_pingpong.c +++ b/examples/srq_pingpong.c @@ -744,7 +744,7 @@ int main(int argc, char *argv[]) for (i = 0; i < num_qp; ++i) { my_dest[i].qpn = ctx->qp[i]->qp_num; my_dest[i].psn = lrand48() & 0xffffff; - if (ctx->portinfo.transport == RDMA_TRANSPORT_RDMAOE) { + if (ctx->portinfo.link_layer == IBV_LINK_LAYER_ETHERNET) { if (!grh) { fprintf(stderr, "Must supply remote gid\n"); return 1; diff --git a/examples/uc_pingpong.c b/examples/uc_pingpong.c index 6cfffd2..2bc7da5 100644 --- a/examples/uc_pingpong.c +++ b/examples/uc_pingpong.c @@ -641,7 +641,7 @@ int main(int argc, char *argv[]) } my_dest.lid = ctx->portinfo.lid; - if (ctx->portinfo.transport == RDMA_TRANSPORT_RDMAOE) { + if (ctx->portinfo.link_layer == IBV_LINK_LAYER_ETHERNET) { if (!grh) { fprintf(stderr, "Must supply remote gid\n"); return 1; diff --git a/examples/ud_pingpong.c b/examples/ud_pingpong.c index 33601a3..e30d6d6 100644 --- a/examples/ud_pingpong.c +++ b/examples/ud_pingpong.c @@ -641,7 +641,7 @@ int main(int argc, char *argv[]) my_dest.qpn = ctx->qp->qp_num; my_dest.psn = lrand48() & 0xffffff; - if (ctx->portinfo.transport == RDMA_TRANSPORT_IB) { + if (ctx->portinfo.link_layer == IBV_LINK_LAYER_ETHERNET) { if (!my_dest.lid) { fprintf(stderr, "Couldn't get local LID\n"); return 1; diff --git a/include/infiniband/kern-abi.h b/include/infiniband/kern-abi.h index f5879db..8ef8844 100644 --- a/include/infiniband/kern-abi.h +++ b/include/infiniband/kern-abi.h @@ -224,7 +224,7 @@ struct ibv_query_port_resp { __u8 active_width; __u8 active_speed; __u8 phys_state; - __u8 transport; + __u8 link_layer; __u8 reserved[2]; }; diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h index f7fe68d..aea25fa 100644 --- a/include/infiniband/verbs.h +++ b/include/infiniband/verbs.h @@ -38,6 +38,7 @@ #include #include +#include #ifdef __cplusplus # define BEGIN_C_DECLS extern "C" { @@ -162,14 +163,10 @@ enum ibv_port_state { IBV_PORT_ACTIVE_DEFER = 5 }; -enum rdma_transport_type { - RDMA_TRANSPORT_IB, - RDMA_TRANSPORT_IWARP, - RDMA_TRANSPORT_RDMAOE -}; -enum ibv_port_link_type { - PORT_LINK_IB, - PORT_LINK_ETH +enum { + IBV_LINK_LAYER_UNSPECIFIED, + IBV_LINK_LAYER_INFINIBAND, + IBV_LINK_LAYER_ETHERNET, }; struct ibv_port_attr { @@ -192,7 +189,7 @@ struct ibv_port_attr { uint8_t active_width; uint8_t active_speed; uint8_t phys_state; - uint8_t transport; + uint8_t link_layer; }; enum ibv_event_type { @@ -705,6 +702,21 @@ struct ibv_context { void *abi_compat; }; +static inline int ___ibv_query_port(struct ibv_context *context, + uint8_t port_num, + struct ibv_port_attr *port_attr) +{ + uint8_t *padp; + int padsize; + + port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED; + padp = &port_attr->link_layer + sizeof port_attr->link_layer; + padsize = sizeof(int) - ((unsigned long)padp & (sizeof(int) - 1)); + memset(padp, 0, padsize); + + return context->ops.query_port(context, port_num, port_attr); +} + /** * ibv_get_device_list - Get list of IB devices currently available * @num_devices: optional. if non-NULL, set to the number of devices @@ -1109,4 +1121,7 @@ END_C_DECLS # undef __attribute_const +#define ibv_query_port(context, port_num, port_attr) \ + ___ibv_query_port(context, port_num, port_attr) + #endif /* INFINIBAND_VERBS_H */ diff --git a/src/cmd.c b/src/cmd.c index 2a36d91..5183d59 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -197,7 +197,7 @@ int ibv_cmd_query_port(struct ibv_context *context, uint8_t port_num, port_attr->active_width = resp.active_width; port_attr->active_speed = resp.active_speed; port_attr->phys_state = resp.phys_state; - port_attr->transport = resp.transport; + port_attr->link_layer = resp.link_layer; return 0; } diff --git a/src/verbs.c b/src/verbs.c index ba3c0a4..2b175b6 100644 --- a/src/verbs.c +++ b/src/verbs.c @@ -86,6 +86,7 @@ default_symver(__ibv_query_device, ibv_query_device); int __ibv_query_port(struct ibv_context *context, uint8_t port_num, struct ibv_port_attr *port_attr) { + port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED; return context->ops.query_port(context, port_num, port_attr); } default_symver(__ibv_query_port, ibv_query_port);