From patchwork Wed Jul 20 19:37:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 992952 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6KJbuCF001078 for ; Wed, 20 Jul 2011 19:37:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751309Ab1GTThz (ORCPT ); Wed, 20 Jul 2011 15:37:55 -0400 Received: from mail.mellanox.co.il ([194.90.237.43]:55173 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751178Ab1GTThy (ORCPT ); Wed, 20 Jul 2011 15:37:54 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from ogerlitz@mellanox.com) with SMTP; 20 Jul 2011 22:37:51 +0300 Received: from MTRCASDAG01.mtl.com (172.25.0.174) by MTLCAS01.mtl.com (10.0.8.71) with Microsoft SMTP Server (TLS) id 14.1.289.1; Wed, 20 Jul 2011 22:37:51 +0300 Received: from host217 (172.25.5.217) by MTRCASDAG01.mtl.com (172.25.0.174) with Microsoft SMTP Server (TLS) id 14.1.289.1; Wed, 20 Jul 2011 22:37:50 +0300 Date: Wed, 20 Jul 2011 22:37:24 +0300 From: Or Gerlitz X-X-Sender: ogerlitz@ogerlitz.voltaire.com To: Roland Dreier CC: linux-rdma , Jason Gunthorpe , Sean Hefty Subject: [PATCH V1 1/7] libibverbs: Add link layer field port attribute In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (LRH 1167 2008-08-23) MIME-Version: 1.0 X-Originating-IP: [172.25.5.217] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Wed, 20 Jul 2011 19:37:57 +0000 (UTC) The new field has one of three values - IBV_LINK_LAYER_UNSPECIFIED, IBV_LINK_LAYER_INFINIBAND, IBV_LINK_LAYER_ETHERNET. It can be used by applications to know the link layer used by the port, which can be either Infiniband or Ethernet. The addition of the new field does not change the size of struct ibv_port_attr due to alignment of the preceding fields. As such binary compatibility between the library to applications is kept, since old apps running over new library do not read this field, and new apps running over old library will determine the link layer as unspecified and hence take their IB code path. The solution was suggested by: Roland Dreier and Jason Gunthorpe Signed-off-by: Or Gerlitz Signed-off-by: Eli Cohen --- changes from V0: - applied feedback from Jason, made the ___ibv_query_port trick clearer to header file readers include/infiniband/verbs.h | 23 +++++++++++++++++++++++ man/ibv_query_port.3 | 4 ++++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h index 0f1cb2e..d1a3e47 100644 --- a/include/infiniband/verbs.h +++ b/include/infiniband/verbs.h @@ -161,6 +161,12 @@ enum ibv_port_state { IBV_PORT_ACTIVE_DEFER = 5 }; +enum { + IBV_LINK_LAYER_UNSPECIFIED, + IBV_LINK_LAYER_INFINIBAND, + IBV_LINK_LAYER_ETHERNET, +}; + struct ibv_port_attr { enum ibv_port_state state; enum ibv_mtu max_mtu; @@ -181,6 +187,8 @@ struct ibv_port_attr { uint8_t active_width; uint8_t active_speed; uint8_t phys_state; + uint8_t link_layer; + uint8_t pad; }; enum ibv_event_type { @@ -767,6 +775,20 @@ int ibv_query_device(struct ibv_context *context, int ibv_query_port(struct ibv_context *context, uint8_t port_num, struct ibv_port_attr *port_attr); +static inline int ___ibv_query_port(struct ibv_context *context, + uint8_t port_num, + struct ibv_port_attr *port_attr) +{ + /* For compatability linking with old libibverbs */ + port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED; + port_attr->pad = 0; + + return ibv_query_port(context, port_num, port_attr); +} + +#define ibv_query_port(context, port_num, port_attr) \ + ___ibv_query_port(context, port_num, port_attr) + /** * ibv_query_gid - Get a GID table entry */ @@ -1097,4 +1119,5 @@ END_C_DECLS # undef __attribute_const + #endif /* INFINIBAND_VERBS_H */ diff --git a/man/ibv_query_port.3 b/man/ibv_query_port.3 index 882470d..9bedd90 100644 --- a/man/ibv_query_port.3 +++ b/man/ibv_query_port.3 @@ -44,9 +44,13 @@ uint8_t init_type_reply;/* Type of initialization performed by S uint8_t active_width; /* Currently active link width */ uint8_t active_speed; /* Currently active link speed */ uint8_t phys_state; /* Physical port state */ +uint8_t link_layer; /* link layer protocol of the port */ .in -8 }; .sp +possible values for the link layer field are IBV_LINK_LAYER_INFINIBAND, +IBV_LINK_LAYER_ETHERNET, or IBV_LINK_LAYER_UNSPECIFIED. +.sp .fi .SH "RETURN VALUE" .B ibv_query_port()