public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	alexne-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 7/7] libibumad: Define data type to indicate values are in big-endian
Date: Mon, 28 Jan 2013 13:38:55 -0800	[thread overview]
Message-ID: <1359409135-559-7-git-send-email-sean.hefty@intel.com> (raw)
In-Reply-To: <1359409135-559-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

From: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

The ib management interfaces require that the user specify
certain values in network-byte order.  To clarify which values
should be in big endian format, introduce a new data type
at the libibumad level.

Signed-off-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 include/infiniband/umad.h       |   17 +++++++++++------
 include/infiniband/umad_sa.h    |   13 ++++++++-----
 include/infiniband/umad_sm.h    |   16 ++++++++--------
 include/infiniband/umad_types.h |   23 ++++++++++++-----------
 4 files changed, 39 insertions(+), 30 deletions(-)

diff --git a/include/infiniband/umad.h b/include/infiniband/umad.h
index 08fff71..b3f00e7 100644
--- a/include/infiniband/umad.h
+++ b/include/infiniband/umad.h
@@ -47,21 +47,26 @@
 #endif				/* __cplusplus */
 
 BEGIN_C_DECLS
+
+typedef uint16_t be16_t;
+typedef uint32_t be32_t;
+typedef uint64_t be64_t;
+
 #define UMAD_MAX_DEVICES 32
 #define UMAD_ANY_PORT	0
 typedef struct ib_mad_addr {
-	uint32_t qpn;
-	uint32_t qkey;
-	uint16_t lid;
+	be32_t qpn;
+	be32_t qkey;
+	be16_t lid;
 	uint8_t sl;
 	uint8_t path_bits;
 	uint8_t grh_present;
 	uint8_t gid_index;
 	uint8_t hop_limit;
 	uint8_t traffic_class;
-	uint8_t gid[16];
-	uint32_t flow_label;
-	uint16_t pkey_index;
+	uint8_t gid[16]; /* network-byte order */
+	be32_t flow_label;
+	be16_t pkey_index;
 	uint8_t reserved[6];
 } ib_mad_addr_t;
 
diff --git a/include/infiniband/umad_sa.h b/include/infiniband/umad_sa.h
index f3e161e..92248de 100755
--- a/include/infiniband/umad_sa.h
+++ b/include/infiniband/umad_sa.h
@@ -87,14 +87,17 @@ enum {
 	UMAD_LEN_SA_DATA		= 200
 };
 
+/*
+ *  sm_key is not aligned on an 8-byte boundary, so is defined as a byte array
+ */
 struct umad_sa_packet {
 	struct umad_hdr		mad_hdr;
 	struct umad_rmpp_hdr	rmpp_hdr;
-	uint8_t			sm_key[8];
-	uint16_t		attr_offset;
-	uint16_t		reserved;
-	uint64_t		comp_mask;
-	uint8_t 		data[UMAD_LEN_SA_DATA];
+	uint8_t			sm_key[8]; /* network-byte order */
+	be16_t			attr_offset;
+	be16_t			reserved;
+	be64_t			comp_mask;
+	uint8_t 		data[UMAD_LEN_SA_DATA]; /* network-byte order */
 };
 
 END_C_DECLS
diff --git a/include/infiniband/umad_sm.h b/include/infiniband/umad_sm.h
index 62c75da..10348d4 100755
--- a/include/infiniband/umad_sm.h
+++ b/include/infiniband/umad_sm.h
@@ -82,16 +82,16 @@ struct umad_smp {
 	uint8_t	 mgmt_class;
 	uint8_t	 class_version;
 	uint8_t	 method;
-	uint16_t status;
+	be16_t   status;
 	uint8_t  hop_ptr;
 	uint8_t  hop_cnt;
-	uint64_t tid;
-	uint16_t attr_id;
-	uint16_t resv;
-	uint32_t attr_mod;
-	uint64_t mkey;
-	uint16_t dr_slid;
-	uint16_t dr_dlid;
+	be64_t   tid;
+	be16_t   attr_id;
+	be16_t   resv;
+	be32_t   attr_mod;
+	be64_t   mkey;
+	be16_t   dr_slid;
+	be16_t   dr_dlid;
 	uint8_t  reserved[28];
 	uint8_t  data[UMAD_LEN_SMP_DATA];
 	uint8_t  initial_path[UMAD_SMP_MAX_HOPS];
diff --git a/include/infiniband/umad_types.h b/include/infiniband/umad_types.h
index 54b7e72..bf93add 100755
--- a/include/infiniband/umad_types.h
+++ b/include/infiniband/umad_types.h
@@ -38,6 +38,7 @@
 #define _UMAD_TYPES_H
 
 #include <stdint.h>
+#include <infiniband/umad.h>
 
 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
@@ -149,11 +150,11 @@ struct umad_hdr {
 	uint8_t	 class_version;
 	uint8_t	 method;
 	uint16_t status;
-	uint16_t class_specific;
-	uint64_t tid;
-	uint16_t attr_id;
-	uint16_t resv;
-	uint32_t attr_mod;
+	be16_t   class_specific;
+	be64_t   tid;
+	be16_t   attr_id;
+	be16_t   resv;
+	be32_t   attr_mod;
 };
 
 struct umad_rmpp_hdr {
@@ -161,27 +162,27 @@ struct umad_rmpp_hdr {
 	uint8_t	 rmpp_type;
 	uint8_t	 rmpp_rtime_flags;
 	uint8_t	 rmpp_status;
-	uint32_t seg_num;
-	uint32_t paylen_newwin;
+	be32_t   seg_num;
+	be32_t   paylen_newwin;
 };
 
 struct umad_packet {
 	struct umad_hdr		mad_hdr;
-	uint8_t			data[UMAD_LEN_DATA];
+	uint8_t			data[UMAD_LEN_DATA]; /* network-byte order */
 };
 
 struct umad_rmpp_packet {
 	struct umad_hdr		mad_hdr;
 	struct umad_rmpp_hdr	rmpp_hdr;
-	uint8_t			data[UMAD_LEN_RMPP_DATA];
+	uint8_t			data[UMAD_LEN_RMPP_DATA]; /* network-byte order */
 };
 
 struct umad_vendor_packet {
 	struct umad_hdr		mad_hdr;
 	struct umad_rmpp_hdr	rmpp_hdr;
 	uint8_t			reserved;
-	uint8_t			oui[3];
-	uint8_t			data[UMAD_LEN_VENDOR_DATA];
+	uint8_t			oui[3];	/* network-byte order */
+	uint8_t			data[UMAD_LEN_VENDOR_DATA]; /* network-byte order */
 };
 
 enum {
-- 
1.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-01-28 21:38 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-28 21:38 [PATCH 1/7] libibumad: Provide MAD definitions with libibumad sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found] ` <1359409135-559-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-01-28 21:38   ` [PATCH 2/7] libibumad: Add SA MAD definitions to umad sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found]     ` <1359409135-559-2-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-02-20 22:40       ` Hal Rosenstock
2013-01-28 21:38   ` [PATCH 3/7] libibumad: Add basic SM " sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found]     ` <1359409135-559-3-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-02-20 22:40       ` Hal Rosenstock
2013-01-28 21:38   ` [PATCH 4/7] libibumad: Add CM " sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found]     ` <1359409135-559-4-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-02-20 22:40       ` Hal Rosenstock
2013-01-28 21:38   ` [PATCH 5/7] libibumad: Add new umad header files to release sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found]     ` <1359409135-559-5-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-02-20 22:40       ` Hal Rosenstock
2013-01-28 21:38   ` [PATCH 6/7] libibumad: Define ntohll/htonll sean.hefty-ral2JQCrhuEAvxtiuMwx3w
     [not found]     ` <1359409135-559-6-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-02-20 22:40       ` Hal Rosenstock
2013-01-28 21:38   ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w [this message]
     [not found]     ` <1359409135-559-7-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-02-21 16:03       ` [PATCH 7/7] libibumad: Define data type to indicate values are in big-endian Hal Rosenstock
2013-02-20 15:56   ` [PATCH 1/7] libibumad: Provide MAD definitions with libibumad Hal Rosenstock
     [not found]     ` <5124F212.2060503-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2013-02-20 16:07       ` Hefty, Sean
     [not found]         ` <1828884A29C6694DAF28B7E6B8A823736F34E958-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2013-02-20 16:29           ` Hefty, Sean
     [not found]             ` <1828884A29C6694DAF28B7E6B8A823736F34E976-P5GAC/sN6hmkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2013-02-20 16:39               ` Hal Rosenstock
     [not found]                 ` <5124FC59.2070602-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2013-02-20 17:42                   ` Ira Weiny
     [not found]                     ` <20130220094219.19f80f5c0b65c50a48b29c96-i2BcT+NCU+M@public.gmane.org>
2013-02-20 19:12                       ` Hal Rosenstock
2013-02-20 19:15                   ` Hal Rosenstock
     [not found]                     ` <512520CF.8000902-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2013-02-20 21:06                       ` Hefty, Sean
2013-02-20 22:39   ` Hal Rosenstock
  -- strict thread matches above, loose matches on Subject: below --
2011-04-28 23:05 [PATCH 7/7] libibumad: Define data type to indicate values are in big-endian Hefty, Sean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1359409135-559-7-git-send-email-sean.hefty@intel.com \
    --to=sean.hefty-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=alexne-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox