1219820Sjeff[PATCHv7 1/4] libibverbs: Add link layer field to ibv_port_attr
2219820Sjeff
3219820SjeffThis field can have one of the values - IBV_LINK_LAYER_UNSPECIFIED,
4219820SjeffIBV_LINK_LAYER_INFINIBAND, IBV_LINK_LAYER_ETHERNET. It can be used by
5219820Sjeffapplications to know the link layer used by the port, which can be either
6219820SjeffInfiniband or Ethernet. The addition of the new field does not change the size
7219820Sjeffof struct ibv_port_attr due to alignment of the preceding field. Binary
8219820Sjeffcompatibility is not compromised either since new apps with old libraries will
9219820Sjeffdetermine the link layer as IB while old applications with new a new library do
10219820Sjeffnot read this field.
11219820Sjeff
12219820SjeffSolution suggested by:
13219820Sjeff               Roland Dreier <rolandd@cisco.com>
14219820Sjeff               Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
15219820SjeffSigned-off-by: Eli Cohen <eli@mellanox.co.il>
16219820Sjeff---
17219820Sjeff include/infiniband/verbs.h |   21 +++++++++++++++++++++
18219820Sjeff 1 files changed, 21 insertions(+), 0 deletions(-)
19219820Sjeff
20219820SjeffIndex: libibverbs/include/infiniband/verbs.h
21219820Sjeff===================================================================
22219820Sjeff--- libibverbs.orig/include/infiniband/verbs.h	2010-06-08 11:00:05.575721000 +0300
23219820Sjeff+++ libibverbs/include/infiniband/verbs.h	2010-06-08 11:00:39.442737000 +0300
24219820Sjeff@@ -162,6 +162,12 @@ enum ibv_port_state {
25219820Sjeff 	IBV_PORT_ACTIVE_DEFER	= 5
26219820Sjeff };
27219820Sjeff 
28219820Sjeff+enum {
29219820Sjeff+	IBV_LINK_LAYER_UNSPECIFIED,
30219820Sjeff+	IBV_LINK_LAYER_INFINIBAND,
31219820Sjeff+	IBV_LINK_LAYER_ETHERNET,
32219820Sjeff+};
33219820Sjeff+
34219820Sjeff struct ibv_port_attr {
35219820Sjeff 	enum ibv_port_state	state;
36219820Sjeff 	enum ibv_mtu		max_mtu;
37219820Sjeff@@ -182,6 +188,8 @@ struct ibv_port_attr {
38219820Sjeff 	uint8_t			active_width;
39219820Sjeff 	uint8_t			active_speed;
40219820Sjeff 	uint8_t			phys_state;
41219820Sjeff+	uint8_t			link_layer;
42219820Sjeff+	uint8_t			pad;
43219820Sjeff };
44219820Sjeff 
45219820Sjeff enum ibv_event_type {
46219820Sjeff@@ -743,6 +751,16 @@ struct ibv_context {
47219820Sjeff 	struct ibv_more_ops     *more_ops;
48219820Sjeff };
49219820Sjeff 
50219820Sjeff+static inline int ___ibv_query_port(struct ibv_context *context,
51219820Sjeff+				    uint8_t port_num,
52219820Sjeff+				    struct ibv_port_attr *port_attr)
53219820Sjeff+{
54219820Sjeff+	port_attr->link_layer = IBV_LINK_LAYER_UNSPECIFIED;
55219820Sjeff+	port_attr->pad = 0;
56219820Sjeff+
57219820Sjeff+	return context->ops.query_port(context, port_num, port_attr);
58219820Sjeff+}
59219820Sjeff+
60219820Sjeff /**
61219820Sjeff  * ibv_get_device_list - Get list of IB devices currently available
62219820Sjeff  * @num_devices: optional.  if non-NULL, set to the number of devices
63219820Sjeff@@ -1304,4 +1322,7 @@ END_C_DECLS
64219820Sjeff 
65219820Sjeff #  undef __attribute_const
66219820Sjeff 
67219820Sjeff+#define ibv_query_port(context, port_num, port_attr) \
68219820Sjeff+	___ibv_query_port(context, port_num, port_attr)
69219820Sjeff+
70219820Sjeff #endif /* INFINIBAND_VERBS_H */
71