[ofa-general] enabling invalidate operations in libibverbs API

Roland Dreier rdreier at cisco.com
Mon Jun 9 13:48:24 PDT 2008


I'm thinking about how to add support for the various invalidate
operations to libibverbs (ie send with invalidate, RDMA read with inv,
local inv, and receive completions with an invalidated key in them).

My current feeling is that using unnamed unions is the way to go -- it
preserves source and binary compatibility, and pretty much any compiler
that anyone is ever going to use will support them.  I feel a little bad
about using non-standard C, but I don't see a better way -- there's room
in the ibv_send_wr structure, but I don't see any way to squeeze another
32 bits into struct ibv_wc.

ie I'm proposing the change below (of course I'm leaving out the new
opcode etc definitions, this is just the part I don't feel confident
about).  Any suggestions of a better way or comments pro or con would
be nice to get...

Thanks

diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
index acc1b82..fcf587e 100644
--- a/include/infiniband/verbs.h
+++ b/include/infiniband/verbs.h
@@ -265,7 +265,10 @@ struct ibv_wc {
 	enum ibv_wc_opcode	opcode;
 	uint32_t		vendor_err;
 	uint32_t		byte_len;
-	uint32_t		imm_data;	/* in network byte order */
+	union {
+		uint32_t	imm_data;	/* in network byte order */
+		uint32_t	invalidate_rkey;
+	};
 	uint32_t		qp_num;
 	uint32_t		src_qp;
 	enum ibv_wc_flags	wc_flags;
@@ -508,7 +511,10 @@ struct ibv_send_wr {
 	int			num_sge;
 	enum ibv_wr_opcode	opcode;
 	enum ibv_send_flags	send_flags;
-	uint32_t		imm_data;	/* in network byte order */
+	union {
+		uint32_t	imm_data;	/* in network byte order */
+		uint32_t	invalidate_rkey;
+	};
 	union {
 		struct {
 			uint64_t	remote_addr;



More information about the general mailing list