[PATCHv7 1/4] libibverbs: Add link layer field to ibv_port_attr This field can have one of the 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 field. Binary compatibility is not compromised either since new apps with old libraries will determine the link layer as IB while old applications with new a new library do not read this field. Solution suggested by: Roland Dreier Jason Gunthorpe Signed-off-by: Eli Cohen --- include/infiniband/verbs.h | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) Index: libibverbs/include/infiniband/verbs.h =================================================================== --- libibverbs.orig/include/infiniband/verbs.h 2010-06-08 11:00:05.575721000 +0300 +++ libibverbs/include/infiniband/verbs.h 2010-06-08 11:00:39.442737000 +0300 @@ -162,6 +162,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; @@ -182,6 +188,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 { @@ -743,6 +751,16 @@ struct ibv_context { struct ibv_more_ops *more_ops; }; +static inline 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; + port_attr->pad = 0; + + 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 @@ -1304,4 +1322,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 */