rocee_link_layer.patch revision 219820
1115705Sobrien[PATCHv7 1/4] libibverbs: Add link layer field to ibv_port_attr 2115705Sobrien 328762SbdeThis field can have one of the values - IBV_LINK_LAYER_UNSPECIFIED, 455626SbdeIBV_LINK_LAYER_INFINIBAND, IBV_LINK_LAYER_ETHERNET. It can be used by 555062Smarcelapplications to know the link layer used by the port, which can be either 6102964SbdeInfiniband or Ethernet. The addition of the new field does not change the size 728762Sbdeof struct ibv_port_attr due to alignment of the preceding field. Binary 814331Spetercompatibility is not compromised either since new apps with old libraries will 914331Speterdetermine the link layer as IB while old applications with new a new library do 1083221Smarcelnot read this field. 1183221Smarcel 1283221SmarcelSolution suggested by: 1383221Smarcel Roland Dreier <rolandd@cisco.com> 1483221Smarcel Jason Gunthorpe <jgunthorpe@obsidianresearch.com> 1583221SmarcelSigned-off-by: Eli Cohen <eli@mellanox.co.il> 16182849Skib--- 17 include/infiniband/verbs.h | 21 +++++++++++++++++++++ 18 1 files changed, 21 insertions(+), 0 deletions(-) 19 20Index: libibverbs/include/infiniband/verbs.h 21=================================================================== 22--- libibverbs.orig/include/infiniband/verbs.h 2010-06-08 11:00:05.575721000 +0300 23+++ libibverbs/include/infiniband/verbs.h 2010-06-08 11:00:39.442737000 +0300 24@@ -162,6 +162,12 @@ enum ibv_port_state { 25 IBV_PORT_ACTIVE_DEFER = 5 26 }; 27 28+enum { 29+ IBV_LINK_LAYER_UNSPECIFIED, 30+ IBV_LINK_LAYER_INFINIBAND, 31+ IBV_LINK_LAYER_ETHERNET, 32+}; 33+ 34 struct ibv_port_attr { 35 enum ibv_port_state state; 36 enum ibv_mtu max_mtu; 37@@ -182,6 +188,8 @@ struct ibv_port_attr { 38 uint8_t active_width; 39 uint8_t active_speed; 40 uint8_t phys_state; 41+ uint8_t link_layer; 42+ uint8_t pad; 43 }; 44 45 enum ibv_event_type { 46@@ -743,6 +751,16 @@ struct ibv_context { 47 struct ibv_more_ops *more_ops; 48 }; 49 50+static inline int ___ibv_query_port(struct ibv_context *context, 51+ uint8_t port_num, 52+ struct ibv_port_attr *port_attr) 53+{ 54+ port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED; 55+ port_attr->pad = 0; 56+ 57+ return context->ops.query_port(context, port_num, port_attr); 58+} 59+ 60 /** 61 * ibv_get_device_list - Get list of IB devices currently available 62 * @num_devices: optional. if non-NULL, set to the number of devices 63@@ -1304,4 +1322,7 @@ END_C_DECLS 64 65 # undef __attribute_const 66 67+#define ibv_query_port(context, port_num, port_attr) \ 68+ ___ibv_query_port(context, port_num, port_attr) 69+ 70 #endif /* INFINIBAND_VERBS_H */ 71