Re: [PATCH 1/7] libibverbs: Add link layer field port attribute

Jason Gunthorpe
2011-07-20T18:33:27Z

On Wed, Jul 20, 2011 at 09:20:41PM +0300, Or Gerlitz wrote:
> Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote:

> > Looks like! Sorry for the confusion
>
> Jason, thanks for your detailed review && feedback, just to recap,
> the patches are okay except the missing entry for the new GID change
> event in ibv_event_type_str which I will add, correct?

Yes, that was the only important thing I saw.

I assume Roland was happy with the #define trick for compatibility
last time it came up?

Looking at the diff, maybe re-shuffle the order of the #define trick
so it is easier to follow, and call ibv_query_port rather than short
cut through the context for better future compatibility.

diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
index 0f1cb2e..40e8802 100644
@@ -766,6 +774,18 @@ 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