Message ID | ADC95B5F-C8B0-4360-B757-78DED5B86C9C@cisco.com (mailing list archive) |
---|---|
State | Rejected |
Headers | show |
On Fri, Dec 20, 2013 at 1:39 PM, Upinder Malhi (umalhi) <umalhi@cisco.com> wrote: > @@ -67,7 +67,7 @@ struct usnic_ib_create_qp_resp { > u32 rq_idx[USNIC_QP_GRP_MAX_RQS]; > u32 cq_idx[USNIC_QP_GRP_MAX_CQS]; > u32 transport; > - u64 reserved; > + u32 reserved[8]; > }; Making your struct be an odd number of 4-byte words seems like a bad idea. It might be padded differently on different architectures. for example: $ cat a.c #include <stdio.h> #include <stdint.h> int main(int argc, char *argv[]) { struct foo { uint64_t a; uint32_t b[3]; }; printf("%zd\n", sizeof (struct foo)); return 0; } $ gcc -m32 -o a ~/a.c $ ./a 20 $ gcc -o a ~/a.c $ ./a 24 I would suggest writing a little test harness and making sure that sizeof and offsetof give the same outputs for all your structs on both 32-bit and 64-bit x86 at the very least. - R. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/infiniband/hw/usnic/usnic_abi.h b/drivers/infiniband/hw/usnic/usnic_abi.h index 730a371..6c56fbf 100644 --- a/drivers/infiniband/hw/usnic/usnic_abi.h +++ b/drivers/infiniband/hw/usnic/usnic_abi.h @@ -21,7 +21,7 @@ #define USNIC_ABI_H /* ABI between userspace and kernel */ -#define USNIC_UVERBS_ABI_VERSION 3 +#define USNIC_UVERBS_ABI_VERSION 4 #define USNIC_QP_GRP_MAX_WQS 8 #define USNIC_QP_GRP_MAX_RQS 8 @@ -67,7 +67,7 @@ struct usnic_ib_create_qp_resp { u32 rq_idx[USNIC_QP_GRP_MAX_RQS]; u32 cq_idx[USNIC_QP_GRP_MAX_CQS]; u32 transport; - u64 reserved; + u32 reserved[8]; }; #endif /* USNIC_ABI_H */
This patch depends on http://www.spinics.net/lists/linux-rdma/msg18193.html. Change the type of the reserve field to u32 from u64 in usnic_ib_create_qp_resp bc u64 will align differently for 32 and 64 bit archs. And reserve even more space for future expansion. Signed-off-by: Upinder Malhi <umalhi@cisco.com> --- drivers/infiniband/hw/usnic/usnic_abi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ---- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html