[openib-general] [PATCH] Update MAD header fields to new API

Roland Dreier roland at topspin.com
Mon Sep 13 21:34:18 PDT 2004


This rather giant diff updates struct ib_mad in my tree's
ts_ib_mad_types.h to have the same member names as in ib_mad.h.  This
means that it should now be possible to build and use the new SMI code
(once it's ready) with mthca.

 - R.

Index: infiniband/include/ts_ib_mad_smi_types.h
===================================================================
--- infiniband/include/ts_ib_mad_smi_types.h	(revision 803)
+++ infiniband/include/ts_ib_mad_smi_types.h	(working copy)
@@ -30,7 +30,7 @@
 #define TS_IB_MAD_SMP_PAYLOAD(mad) ((struct ib_mad_payload_smp *)(mad)->payload)
 /* Directed route payload */
 #define TS_IB_MAD_SMP_DR_PAYLOAD(mad) \
-  ((struct ib_mad_payload_smp_dr *)(mad)->payload)
+  ((struct ib_mad_payload_smp_dr *)(mad)->data)
 
 /* Macro to get the SMP DATA field from a MAD payload
  * (Same for LID or Directed Route SMPs.)
Index: infiniband/include/ts_ib_mad_types.h
===================================================================
--- infiniband/include/ts_ib_mad_types.h	(revision 803)
+++ infiniband/include/ts_ib_mad_types.h	(working copy)
@@ -46,34 +46,9 @@
 #define TS_IB_MAD_DR_DIRECTION_RETURN  0x8000
 
 #define TS_IB_MAD_DR_RETURNING(mad)                         \
-  ((mad)->status & cpu_to_be16(TS_IB_MAD_DR_DIRECTION_RETURN))
+  ((mad)->mad_hdr.status & cpu_to_be16(TS_IB_MAD_DR_DIRECTION_RETURN))
 #define TS_IB_MAD_DR_OUTGOING(mad) (!(TS_IB_MAD_DR_RETURNING(mad)))
 
-/* 13.4.4 */
-typedef enum ib_mgmt_class {
-	IB_MGMT_CLASS_SUBN_LID_ROUTED     = 0x01,
-	IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE = 0x81,
-	IB_MGMT_CLASS_SUBN_ADM            = 0x03,
-	IB_MGMT_CLASS_PERF                = 0x04,
-	IB_MGMT_CLASS_BM                  = 0x05,
-	IB_MGMT_CLASS_DEV_MGT             = 0x06,
-	IB_MGMT_CLASS_COMM_MGT            = 0x07,
-	IB_MGMT_CLASS_SNMP                = 0x08,
-	IB_MGMT_CLASS_VENDOR_TOPSPIN      = 0x30
-} tTS_IB_MGMT_CLASS;
-
-/* 13.4.5 */
-typedef enum ib_mgmt_method {
-	IB_MGMT_METHOD_GET             = 0x01,
-	IB_MGMT_METHOD_SET             = 0x02,
-	IB_MGMT_METHOD_GET_RESPONSE    = 0x81,
-	IB_MGMT_METHOD_SEND            = 0x03,
-	IB_MGMT_METHOD_TRAP            = 0x05,
-	IB_MGMT_METHOD_REPORT          = 0x06,
-	IB_MGMT_METHOD_REPORT_RESPONSE = 0x86,
-	IB_MGMT_METHOD_TRAP_REPRESS    = 0x07
-} tTS_IB_MGMT_METHOD;
-
 typedef enum ib_mad_filter_mask {
 	TS_IB_MAD_FILTER_DEVICE       = 1 << 0,
 	TS_IB_MAD_FILTER_PORT         = 1 << 1,
@@ -89,6 +64,26 @@
 	TS_IB_MAD_DIRECTION_OUT
 } tTS_IB_MAD_DIRECTION;
 
+/* Management classes */
+#define IB_MGMT_CLASS_SUBN_LID_ROUTED		0x01
+#define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE	0x81
+#define IB_MGMT_CLASS_SUBN_ADM			0x03
+#define IB_MGMT_CLASS_PERF_MGMT			0x04
+#define IB_MGMT_CLASS_BM			0x05
+#define IB_MGMT_CLASS_DEVICE_MGMT		0x06
+#define IB_MGMT_CLASS_CM			0x07
+#define IB_MGMT_CLASS_SNMP			0x08
+
+/* Management methods */
+#define IB_MGMT_METHOD_GET			0x01
+#define IB_MGMT_METHOD_SET			0x02
+#define IB_MGMT_METHOD_GET_RESP			0x81
+#define IB_MGMT_METHOD_SEND			0x03
+#define IB_MGMT_METHOD_TRAP			0x05
+#define IB_MGMT_METHOD_REPORT			0x06
+#define IB_MGMT_METHOD_REPORT_RESP		0x86
+#define IB_MGMT_METHOD_TRAP_REPRESS		0x07
+
 /* function types */
 
 typedef void (*ib_mad_completion_func)(int result,
@@ -96,26 +91,22 @@
 
 /* structs */
 
+struct ib_mad_hdr {
+	u8	base_version;
+	u8	mgmt_class;
+	u8	class_version;
+	u8	method;
+	u16	status;
+	u16	class_specific;
+	u64	tid;
+	u16	attr_id;
+	u16	resv;
+	u32	attr_mod;
+};
+
 struct ib_mad {
-	uint8_t                        format_version     __attribute__((packed));
-	uint8_t                        mgmt_class         __attribute__((packed));
-	uint8_t                        class_version      __attribute__((packed));
-	uint8_t                        r_method           __attribute__((packed));
-	uint16_t                       status             __attribute__((packed));
-	union {
-		struct {
-			uint8_t        hop_pointer        __attribute__((packed));
-			uint8_t        hop_count          __attribute__((packed));
-		}                      directed           __attribute__((packed));
-		struct {
-			uint16_t       class_specific     __attribute__((packed));
-		}                      lid                __attribute__((packed));
-	}                              route              __attribute__((packed));
-	uint64_t                       transaction_id     __attribute__((packed));
-	uint16_t                       attribute_id       __attribute__((packed));
-	uint16_t                       reserved           __attribute__((packed));
-	uint32_t                       attribute_modifier __attribute__((packed));
-	uint8_t                        payload[232]       __attribute__((packed));
+        struct ib_mad_hdr              mad_hdr;
+        u8                             data[232];
 
 	struct ib_device              *device;
 	tTS_IB_PORT                    port;
Index: infiniband/core/dm_client_svc_entries.c
===================================================================
--- infiniband/core/dm_client_svc_entries.c	(revision 803)
+++ infiniband/core/dm_client_svc_entries.c	(working copy)
@@ -67,10 +67,10 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_dm_svc_entries *svc_entries_ptr =
-			    (struct ib_dm_svc_entries *) & packet->payload;
+				(struct ib_dm_svc_entries *) & packet->data;
 			struct ib_svc_entries svc_entries;
 			u32 attribute_modifier =
-			    be32_to_cpu(packet->attribute_modifier);
+				be32_to_cpu(packet->mad_hdr.attr_mod);
 			int i;
 
 			svc_entries.controller_id =
@@ -124,7 +124,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_DM, T_VERBOSE, TRACE_KERNEL_IB_DM_GEN,
 			 "DM client Svc Entries MAD slid= 0x%04x, status 0x%04x",
-			 packet->slid, be16_to_cpu(packet->status));
+			 packet->slid, be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -185,12 +185,12 @@
 			    TS_IB_DM_METHOD_GET, TS_IB_DM_ATTRIBUTE_SVC_ENTRIES,
 			    attrib_mod);
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->dlid = dst_port_lid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	ib_client_query(&mad, timeout_jiffies, ib_svc_entries_response, query);
 
Index: infiniband/core/dm_client_main.c
===================================================================
--- infiniband/core/dm_client_main.c	(revision 803)
+++ infiniband/core/dm_client_main.c	(working copy)
@@ -52,7 +52,7 @@
 		return -EINVAL;
 	}
 
-	ib_client_mad_handler_register(IB_MGMT_CLASS_DEV_MGT,
+	ib_client_mad_handler_register(IB_MGMT_CLASS_DEVICE_MGMT,
 				     ib_dm_async_notify_handler, NULL);
 
 	return 0;
@@ -60,7 +60,7 @@
 
 static void __exit ib_dm_client_cleanup_module(void)
 {
-	ib_client_mad_handler_register(IB_MGMT_CLASS_DEV_MGT, NULL, NULL);
+	ib_client_mad_handler_register(IB_MGMT_CLASS_DEVICE_MGMT, NULL, NULL);
 
 	ib_dm_client_query_cleanup();
 }
Index: infiniband/core/cm_main.c
===================================================================
--- infiniband/core/cm_main.c	(revision 803)
+++ infiniband/core/cm_main.c	(working copy)
@@ -152,7 +152,7 @@
 
 	ib_cm_count_receive(packet);
 
-	attribute_id = be16_to_cpu(packet->attribute_id);
+	attribute_id = be16_to_cpu(packet->mad_hdr.attr_id);
 
 	if (attribute_id >= ARRAY_SIZE(dispatch_table)) {
 		TS_REPORT_WARN(MOD_IB_CM,
@@ -199,7 +199,7 @@
 		struct ib_mad_filter filter = { NULL };
 
 		filter.qpn        = 1;
-		filter.mgmt_class = IB_MGMT_CLASS_COMM_MGT;
+		filter.mgmt_class = IB_MGMT_CLASS_CM;
 		filter.direction  = TS_IB_MAD_DIRECTION_IN;
 		filter.mask       = (TS_IB_MAD_FILTER_QPN        |
 				     TS_IB_MAD_FILTER_MGMT_CLASS |
Index: infiniband/core/cm_common.c
===================================================================
--- infiniband/core/cm_common.c	(revision 803)
+++ infiniband/core/cm_common.c	(working copy)
@@ -40,23 +40,23 @@
 
 void ib_mad_build_header(struct ib_mad *packet)
 {
-	packet->format_version           = 1;
-	packet->mgmt_class               = IB_MGMT_CLASS_COMM_MGT;
-	packet->class_version            = 2; /* IB Spec version 1.1 */
-	packet->r_method                 = IB_MGMT_METHOD_SEND;
-	packet->status                   = 0;
-	packet->route.lid.class_specific = 0;
+	packet->mad_hdr.base_version     = 1;
+	packet->mad_hdr.mgmt_class       = IB_MGMT_CLASS_CM;
+	packet->mad_hdr.class_version    = 2; /* IB Spec version 1.1 */
+	packet->mad_hdr.method           = IB_MGMT_METHOD_SEND;
+	packet->mad_hdr.status           = 0;
+	packet->mad_hdr.class_specific   = 0;
 
 	/* caller will fill in */
 	packet->sl                 = 0;
-	packet->attribute_id       = 0;
-	packet->transaction_id     = 0;
+	packet->mad_hdr.attr_id    = 0;
+	packet->mad_hdr.tid        = 0;
 
-	packet->reserved           = 0;
-	packet->attribute_modifier = 0;
+	packet->mad_hdr.resv       = 0;
+	packet->mad_hdr.attr_mod   = 0;
 
 	/* clear the payload */
-	memset(packet->payload, 0, sizeof packet->payload);
+	memset(packet->data, 0, sizeof packet->data);
 
 	return;
 }
@@ -347,8 +347,8 @@
 
 	ib_mad_build_header(&connection->mad);
 
-	connection->mad.attribute_id   = cpu_to_be16(IB_COM_MGT_MRA);
-	connection->mad.transaction_id = cpu_to_be64(connection->transaction_id);
+	connection->mad.mad_hdr.attr_id = cpu_to_be16(IB_COM_MGT_MRA);
+	connection->mad.mad_hdr.tid     = cpu_to_be64(connection->transaction_id);
 
 	connection->mad.device     = connection->local_cm_device;
 	connection->mad.port       = connection->local_cm_port;
@@ -403,8 +403,8 @@
 	if (reply_data && reply_size > 0)
 		memcpy(ib_cm_rej_private_data_get(packet), reply_data, reply_size);
 
-	packet->attribute_id   = cpu_to_be16(IB_COM_MGT_REJ);
-	packet->transaction_id = cpu_to_be64(transaction_id);
+	packet->mad_hdr.attr_id = cpu_to_be16(IB_COM_MGT_REJ);
+	packet->mad_hdr.tid     = cpu_to_be64(transaction_id);
 
 	ib_cm_rej_local_comm_id_set (packet, local_comm_id);
 	ib_cm_rej_remote_comm_id_set(packet, remote_comm_id);
@@ -479,8 +479,8 @@
 
 	ib_mad_build_header(&connection->mad);
 
-	connection->mad.attribute_id   = cpu_to_be16(IB_COM_MGT_DREQ);
-	connection->mad.transaction_id = ib_cm_tid_generate();
+	connection->mad.mad_hdr.attr_id = cpu_to_be16(IB_COM_MGT_DREQ);
+	connection->mad.mad_hdr.tid     = ib_cm_tid_generate();
 
 	ib_cm_dreq_local_comm_id_set (&connection->mad, connection->local_comm_id);
 	ib_cm_dreq_remote_comm_id_set(&connection->mad, connection->remote_comm_id);
@@ -703,8 +703,8 @@
 
 			ib_mad_build_header(drep);
 
-			drep->attribute_id   = cpu_to_be16(IB_COM_MGT_DREP);
-			drep->transaction_id = packet->transaction_id;
+			drep->mad_hdr.attr_id = cpu_to_be16(IB_COM_MGT_DREP);
+			drep->mad_hdr.tid     = packet->mad_hdr.tid;
 
 			ib_cm_drep_local_comm_id_set (drep, ib_cm_dreq_remote_comm_id_get(packet));
 			ib_cm_drep_remote_comm_id_set(drep, ib_cm_drep_local_comm_id_get (packet));
@@ -741,8 +741,8 @@
 
 	ib_mad_build_header(&connection->mad);
 
-	connection->mad.attribute_id   = cpu_to_be16(IB_COM_MGT_DREP);
-	connection->mad.transaction_id = packet->transaction_id;
+	connection->mad.mad_hdr.attr_id = cpu_to_be16(IB_COM_MGT_DREP);
+	connection->mad.mad_hdr.tid     = packet->mad_hdr.tid;
 
 	ib_cm_drep_local_comm_id_set (&connection->mad, connection->local_comm_id);
 	ib_cm_drep_remote_comm_id_set(&connection->mad, connection->remote_comm_id);
Index: infiniband/core/sa_client_service.c
===================================================================
--- infiniband/core/sa_client_service.c	(revision 803)
+++ infiniband/core/sa_client_service.c	(working copy)
@@ -88,9 +88,9 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_sa_payload *sa_payload =
-			    (struct ib_sa_payload *) & packet->payload;
+				(struct ib_sa_payload *) & packet->data;
 			struct ib_sa_service *mad_service =
-			    (struct ib_sa_service *) sa_payload->admin_data;
+				(struct ib_sa_service *) sa_payload->admin_data;
 			struct ib_common_attrib_service service;
 
 			TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
@@ -120,7 +120,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 			 "SA client service  MAD status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func)
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -171,14 +171,14 @@
 		return -ENOMEM;
 	}
 
-	sa_payload = (struct ib_sa_payload *) & mad->payload;
+	sa_payload = (struct ib_sa_payload *) & mad->data;
 	mad_service = (struct ib_sa_service *) sa_payload->admin_data;
 
 	/* MAD initialization */
 	tsIbSaClientMadInit(mad, device, port);
-	mad->r_method = method;
-	mad->attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_SERVICE_RECORD);
-	mad->attribute_modifier = 0;
+	mad->mad_hdr.method = method;
+	mad->mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_SERVICE_RECORD);
+	mad->mad_hdr.attr_mod = 0;
 
 	/* SA header */
 	sa_payload->sa_header.component_mask = cpu_to_be64(comp_mask);
@@ -196,9 +196,9 @@
 	memcpy(mad_service->service_data32, service->service_data32, 16);
 	memcpy(mad_service->service_data64, service->service_data64, 16);
 
-	*transaction_id = mad->transaction_id;
+	*transaction_id = mad->mad_hdr.tid;
 
-	query->transaction_id = mad->transaction_id;
+	query->transaction_id = mad->mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
@@ -269,9 +269,9 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_sa_payload *sa_payload =
-			    (struct ib_sa_payload *) & packet->payload;
+				(struct ib_sa_payload *) & packet->data;
 			struct ib_sa_service *mad_service =
-			    (struct ib_sa_service *) sa_payload->admin_data;
+				(struct ib_sa_service *) sa_payload->admin_data;
 
 			TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 				 "SA client tsIbServiceAtsGetGidResponse() status OK\n");
@@ -290,7 +290,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 			 "SA client tsIbServiceAtsGetGidResponse status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -333,9 +333,9 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_sa_payload *sa_payload =
-			    (struct ib_sa_payload *) & packet->payload;
+				(struct ib_sa_payload *) & packet->data;
 			struct ib_sa_service *mad_service =
-			    (struct ib_sa_service *) sa_payload->admin_data;
+				(struct ib_sa_service *) sa_payload->admin_data;
 
 			TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 				 "SA client tsIbServiceAtsGetIpResponse() status OK\n");
@@ -355,7 +355,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 			 "SA client tsIbServiceAtsGetIpResponse status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -397,9 +397,9 @@
 {
 	struct ib_mad mad;
 	struct ib_sa_payload *sa_payload =
-	    (struct ib_sa_payload *) & mad.payload;
+		(struct ib_sa_payload *) & mad.data;
 	struct ib_sa_service *service =
-				(struct ib_sa_service *) sa_payload->admin_data;
+		(struct ib_sa_service *) sa_payload->admin_data;
 	struct ib_sa_service_query *query;
 
 	TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
@@ -417,9 +417,9 @@
 
 	/* MAD initialization */
 	tsIbSaClientMadInit(&mad, device, port);
-	mad.r_method = IB_MGMT_METHOD_SET;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_SERVICE_RECORD);
-	mad.attribute_modifier = 0;
+	mad.mad_hdr.method = IB_MGMT_METHOD_SET;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_SERVICE_RECORD);
+	mad.mad_hdr.attr_mod = 0;
 
 	/* SA header */
 	sa_payload->sa_header.component_mask =
@@ -439,12 +439,12 @@
 	if (!query) {
 		return -ENOMEM;
 	}
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
 	/* Subscribe/unsubscribe to SA */
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 	ib_client_query(&mad, timeout_jiffies, ib_service_response, query);
 
 	return 0;
@@ -461,9 +461,9 @@
 {
 	struct ib_mad mad;
 	struct ib_sa_payload *sa_payload =
-				(struct ib_sa_payload *) & mad.payload;
+		(struct ib_sa_payload *) & mad.data;
 	struct ib_sa_service *service =
-				(struct ib_sa_service *) sa_payload->admin_data;
+		(struct ib_sa_service *) sa_payload->admin_data;
 	struct ib_sa_service_get_gid_query *query;
 
 	TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
@@ -477,9 +477,9 @@
 
 	/* MAD initialization */
 	tsIbSaClientMadInit(&mad, device, port);
-	mad.r_method = IB_MGMT_METHOD_GET;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_SERVICE_RECORD);
-	mad.attribute_modifier = 0;
+	mad.mad_hdr.method = IB_MGMT_METHOD_GET;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_SERVICE_RECORD);
+	mad.mad_hdr.attr_mod = 0;
 
 	/* SA header */
 	sa_payload->sa_header.component_mask =
@@ -496,12 +496,12 @@
 	if (!query) {
 		return -ENOMEM;
 	}
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
 	/* Subscribe/unsubscribe to SA */
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 	ib_client_query(&mad, timeout_jiffies, _tsIbServiceAtsGetGidResponse,
 			query);
 
@@ -519,9 +519,9 @@
 {
 	struct ib_mad mad;
 	struct ib_sa_payload *sa_payload =
-				(struct ib_sa_payload *) & mad.payload;
+		(struct ib_sa_payload *) & mad.data;
 	struct ib_sa_service *service =
-				(struct ib_sa_service *) sa_payload->admin_data;
+		(struct ib_sa_service *) sa_payload->admin_data;
 	struct ib_sa_service_get_ip_query *query;
 
 	TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
@@ -534,9 +534,9 @@
 
 	/* MAD initialization */
 	tsIbSaClientMadInit(&mad, device, port);
-	mad.r_method = IB_MGMT_METHOD_GET;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_SERVICE_RECORD);
-	mad.attribute_modifier = 0;
+	mad.mad_hdr.method = IB_MGMT_METHOD_GET;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_SERVICE_RECORD);
+	mad.mad_hdr.attr_mod = 0;
 
 	/* SA header */
 	sa_payload->sa_header.component_mask =
@@ -553,12 +553,12 @@
 	if (!query) {
 		return -ENOMEM;
 	}
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
 	/* Subscribe/unsubscribe to SA */
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 	ib_client_query(&mad, timeout_jiffies, _tsIbServiceAtsGetIpResponse,
 			query);
 
Index: infiniband/core/dm_client_async_notify.c
===================================================================
--- infiniband/core/dm_client_async_notify.c	(revision 803)
+++ infiniband/core/dm_client_async_notify.c	(working copy)
@@ -75,7 +75,7 @@
 void ib_dm_async_notify_handler(struct ib_mad *packet, void *arg)
 {
 	struct ib_dm_notice *mad_notice =
-				(struct ib_dm_notice *) packet->payload;
+		(struct ib_dm_notice *) packet->data;
 	struct ib_common_attrib_notice notice;
 
 	/* Convert to host order */
Index: infiniband/core/cm_path_migration.c
===================================================================
--- infiniband/core/cm_path_migration.c	(revision 803)
+++ infiniband/core/cm_path_migration.c	(working copy)
@@ -145,8 +145,8 @@
 
 	ib_mad_build_header(&connection->mad);
 
-	connection->mad.attribute_id   = cpu_to_be16(IB_COM_MGT_LAP);
-	connection->mad.transaction_id = ib_cm_tid_generate();
+	connection->mad.mad_hdr.attr_id = cpu_to_be16(IB_COM_MGT_LAP);
+	connection->mad.mad_hdr.tid     = ib_cm_tid_generate();
 
 	connection->mad.device     = connection->local_cm_device;
 	connection->mad.port       = connection->local_cm_port;
@@ -282,8 +282,8 @@
  out_send_apr:
 	ib_mad_build_header(&connection->mad);
 
-	connection->mad.attribute_id   = cpu_to_be16(IB_COM_MGT_APR);
-	connection->mad.transaction_id = packet->transaction_id;
+	connection->mad.mad_hdr.attr_id = cpu_to_be16(IB_COM_MGT_APR);
+	connection->mad.mad_hdr.tid     = packet->mad_hdr.tid;
 
 	connection->mad.device     = connection->local_cm_device;
 	connection->mad.port       = connection->local_cm_port;
Index: infiniband/core/dm_client_iou_info.c
===================================================================
--- infiniband/core/dm_client_iou_info.c	(revision 803)
+++ infiniband/core/dm_client_iou_info.c	(working copy)
@@ -60,7 +60,7 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_dm_iou_info *iou_info_ptr =
-			    (struct ib_dm_iou_info *) & packet->payload;
+				(struct ib_dm_iou_info *) & packet->data;
 			struct ib_iou_info iou_info;
 
 			iou_info.lid = packet->slid;
@@ -92,7 +92,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_DM, T_VERBOSE, TRACE_KERNEL_IB_DM_GEN,
 			 "DM client IOU Info MAD status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -145,12 +145,12 @@
 			    TS_IB_DM_METHOD_GET, TS_IB_DM_ATTRIBUTE_IOU_INFO,
 			    0);
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->dlid = dst_port_lid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	ib_client_query(&mad, timeout_jiffies, ib_iou_info_response, query);
 
Index: infiniband/core/sa_client_multicast.c
===================================================================
--- infiniband/core/sa_client_multicast.c	(revision 803)
+++ infiniband/core/sa_client_multicast.c	(working copy)
@@ -73,7 +73,7 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_sa_payload *sa_payload =
-			    (struct ib_sa_payload *) & packet->payload;
+				(struct ib_sa_payload *) & packet->data;
 			struct ib_sa_multicast_member *mc_ptr =
 			    (struct ib_sa_multicast_member *)
 			    sa_payload->admin_data;
@@ -122,7 +122,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 			 "SA client multicast member MAD status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -285,9 +285,9 @@
 {
 	struct ib_mad mad;
 	struct ib_sa_payload *sa_payload =
-	    (struct ib_sa_payload *) & mad.payload;
+		(struct ib_sa_payload *) & mad.data;
 	struct ib_sa_multicast_member *mc_member =
-	    (struct ib_sa_multicast_member *) sa_payload->admin_data;
+		(struct ib_sa_multicast_member *) sa_payload->admin_data;
 	struct ib_sa_multicast_member_query *query;
 
 	query = kmalloc(sizeof *query, GFP_ATOMIC);
@@ -296,11 +296,11 @@
 	}
 
 	tsIbSaClientMadInit(&mad, device, port);
-	mad.r_method = IB_MGMT_METHOD_SET;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_MC_MEMBER_RECORD);
-	mad.attribute_modifier = 0xffffffff;	/* match attributes */
+	mad.mad_hdr.method = IB_MGMT_METHOD_SET;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_MC_MEMBER_RECORD);
+	mad.mad_hdr.attr_mod = 0xffffffff;	/* match attributes */
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
@@ -354,7 +354,7 @@
 	ib_client_query(&mad, timeout_jiffies, _tsIbMulticastJoinResponse,
 			query);
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	return 0;
 }
@@ -378,9 +378,9 @@
 {
 	struct ib_mad mad;
 	struct ib_sa_payload *sa_payload =
-	    (struct ib_sa_payload *) & mad.payload;
+		(struct ib_sa_payload *) & mad.data;
 	struct ib_sa_multicast_member *mc_member =
-	    (struct ib_sa_multicast_member *) sa_payload->admin_data;
+		(struct ib_sa_multicast_member *) sa_payload->admin_data;
 	struct ib_sa_multicast_group_table_query *query;
 	struct ib_client_rmpp_mad *rmpp_mad;
 
@@ -390,16 +390,16 @@
 	}
 
 	tsIbSaClientMadInit(&mad, device, port);
-	mad.r_method = TS_IB_SA_METHOD_GET_TABLE;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_MC_MEMBER_RECORD);
-	mad.attribute_modifier = 0;
+	mad.mad_hdr.method = TS_IB_SA_METHOD_GET_TABLE;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_MC_MEMBER_RECORD);
+	mad.mad_hdr.attr_mod = 0;
 
 	/* rmpp header init */
 	rmpp_mad = (struct ib_client_rmpp_mad *) & mad;
 	rmpp_mad->version = 1;
 	rmpp_mad->type = TS_IB_CLIENT_RMPP_TYPE_DATA;
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
@@ -407,7 +407,7 @@
 	sa_payload->sa_header.component_mask = cpu_to_be64(0x1ULL << 7);
 	mc_member->pkey = cpu_to_be16(partition);
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	ib_rmpp_client_query(&mad, timeout_jiffies, sizeof(struct ib_sa_header),
 			     _tsIbMcastGroupTableResponse, query);
Index: infiniband/core/mad_thread.c
===================================================================
--- infiniband/core/mad_thread.c	(revision 812)
+++ infiniband/core/mad_thread.c	(working copy)
@@ -42,7 +42,7 @@
 
 static inline int ib_mad_smp_is_outgoing(struct ib_mad *mad)
 {
-	return !(be16_to_cpu(mad->status) & 0x8000);
+	return !(be16_to_cpu(mad->mad_hdr.status) & 0x8000);
 }
 
 static inline int ib_mad_smp_send(struct ib_device   *device,
@@ -52,7 +52,11 @@
 	struct ib_mad_private *priv = device->mad;
 	struct ib_mad         *mad  = work->buf;
 	enum ib_mad_result     result;
+	u8 hop_pointer, hop_count;
 
+	hop_pointer = be16_to_cpu(mad->mad_hdr.class_specific) >> 8;
+	hop_count   = be16_to_cpu(mad->mad_hdr.class_specific) & 0xf;
+
 	if (ib_mad_smp_is_outgoing(mad)) {
 
 		/* If this is an outgoing 0-hop SMP, we have a
@@ -60,7 +64,7 @@
 		   to use QP0 for this, just process the MAD directly. */
 		if (device->process_mad &&
 		    !(device->flags & IB_MAD_LOCAL_USE_QP) &&
-		    !mad->route.directed.hop_count) {
+		    !hop_count) {
 			void *response_buf = kmalloc(sizeof (struct ib_mad) +
 						     IB_MAD_GRH_SIZE,
 						     GFP_KERNEL);
@@ -111,16 +115,16 @@
 
 			return 1;
 		} else {
-			if (!mad->route.directed.hop_pointer) {
+			if (!hop_pointer) {
 				/* Some devices (eg Anafa2) do the hop
 				   pointer increment themselves. */
 				if (!(device->flags & IB_MAD_NO_HOP_POINTER_INCR))
-					++mad->route.directed.hop_pointer;
+					++hop_pointer;
 			} else {
 				/* Discard (IB Spec 14.2.2.2 #2) */
 				TS_REPORT_WARN(MOD_KERNEL_IB,
 					       "Discarding outgoing DR SMP with hop_pointer %d",
-					       mad->route.directed.hop_pointer);
+					       hop_pointer);
 				work->type   = IB_MAD_WORK_SEND_DONE;
 				work->status = -EINVAL;
 				work->index  = -1;
@@ -130,11 +134,13 @@
 		}
 	} else {
 		/* Process returning SMP: (IB Spec 14.2.2.4 is relevant) */
-		if (mad->route.directed.hop_count &&
-		    mad->route.directed.hop_pointer > 1)
-			--mad->route.directed.hop_pointer;
+		if (hop_count &&
+		    hop_pointer > 1)
+			--hop_pointer;
 	}
 
+	mad->mad_hdr.class_specific = cpu_to_be16(hop_count | (hop_pointer << 8));
+
 	return 0;
 }
 
@@ -215,9 +221,9 @@
 		ib_mad_invoke_filters(mad, TS_IB_MAD_DIRECTION_OUT);
 
 		/* Handle directed route SMPs */
-		if (mad->dqpn       == 0                    &&
-		    mad->dlid       == IB_LID_PERMISSIVE    &&
-		    mad->mgmt_class == IB_SM_DIRECTED_ROUTE)
+		if (mad->dqpn == 0                 &&
+		    mad->dlid == IB_LID_PERMISSIVE &&
+		    mad->mad_hdr.mgmt_class == IB_SM_DIRECTED_ROUTE)
 			if (ib_mad_smp_send(device, work, &reuse))
 				break;
 
Index: infiniband/core/generate_cm_packet.pl
===================================================================
--- infiniband/core/generate_cm_packet.pl	(revision 803)
+++ infiniband/core/generate_cm_packet.pl	(working copy)
@@ -75,23 +75,23 @@
 	  if ($offset == 0) {
 	    print <<"END_DEF_SHORT";
 static inline $type ib_cm_${packet_type}_${name}_get(const struct ib_mad *packet) {
-	return packet->payload[$byte] & $mask;
+	return packet->data[$byte] & $mask;
 }
 
 static inline void ib_cm_${packet_type}_${name}_set(struct ib_mad *packet, ${type} value) {
-	packet->payload[$byte] = value | (packet->payload[$byte] & ~$mask);
+	packet->data[$byte] = value | (packet->data[$byte] & ~$mask);
 }
 
 END_DEF_SHORT
 	  } else {
 	    print <<"END_DEF_SHORT_OFFSET";
 static inline $type ib_cm_${packet_type}_${name}_get(const struct ib_mad *packet) {
-	return (packet->payload[$byte] >> $offset) & $mask;
+	return (packet->data[$byte] >> $offset) & $mask;
 }
 
 static inline void ib_cm_${packet_type}_${name}_set(struct ib_mad *packet, ${type} value) {
-	packet->payload[$byte] = (value << $offset) |
-			         (packet->payload[$byte] & ~($mask << $offset));
+	packet->data[$byte] = (value << $offset) |
+			         (packet->data[$byte] & ~($mask << $offset));
 }
 
 END_DEF_SHORT_OFFSET
@@ -103,11 +103,11 @@
 	if ($linelist[2] == 8) {
 	  print <<"END_DEF8";
 static inline $type ib_cm_${packet_type}_${name}_get(const struct ib_mad *packet) {
-	return packet->payload[$linelist[1]];
+	return packet->data[$linelist[1]];
 }
 
 static inline void ib_cm_${packet_type}_${name}_set(struct ib_mad *packet, ${type} value) {
-	packet->payload[$linelist[1]] = value;
+	packet->data[$linelist[1]] = value;
 }
 
 END_DEF8
@@ -119,11 +119,11 @@
 
 	  print <<"END_DEF16";
 static inline $type ib_cm_${packet_type}_${name}_get(const struct ib_mad *packet) {
-	return be16_to_cpu(*(($type *) &packet->payload[$linelist[1]]));
+	return be16_to_cpu(*(($type *) &packet->data[$linelist[1]]));
 }
 
 static inline void ib_cm_${packet_type}_${name}_set(struct ib_mad *packet, ${type} value) {
-	*(($type *) &packet->payload[$linelist[1]]) = cpu_to_be16(value);
+	*(($type *) &packet->data[$linelist[1]]) = cpu_to_be16(value);
 }
 
 END_DEF16
@@ -135,13 +135,13 @@
 
 	  print <<"END_DEF20";
 static inline $type ib_cm_${packet_type}_${name}_get(const struct ib_mad *packet) {
-	return be32_to_cpu(*(($type *) &packet->payload[$linelist[1]])) >> 12;
+	return be32_to_cpu(*(($type *) &packet->data[$linelist[1]])) >> 12;
 }
 
 static inline void ib_cm_${packet_type}_${name}_set(struct ib_mad *packet, ${type} value) {
-	*(($type *) &packet->payload[$linelist[1]]) =
+	*(($type *) &packet->data[$linelist[1]]) =
 		cpu_to_be32((value << 12) | 
-			    (*(($type *) &packet->payload[$linelist[1]]) & 0x00000fff));
+			    (*(($type *) &packet->data[$linelist[1]]) & 0x00000fff));
 }
 
 END_DEF20
@@ -153,12 +153,12 @@
 
 	  print <<"END_DEF24";
 static inline $type ib_cm_${packet_type}_${name}_get(const struct ib_mad *packet) {
-	return be32_to_cpu(*(($type *) &packet->payload[$linelist[1]])) >> 8;
+	return be32_to_cpu(*(($type *) &packet->data[$linelist[1]])) >> 8;
 }
 
 static inline void ib_cm_${packet_type}_${name}_set(struct ib_mad *packet, ${type} value) {
-	*(($type *) &packet->payload[$linelist[1]]) =
-		cpu_to_be32((value << 8) | packet->payload[$linelist[1] + 3]);
+	*(($type *) &packet->data[$linelist[1]]) =
+		cpu_to_be32((value << 8) | packet->data[$linelist[1] + 3]);
 }
 
 END_DEF24
@@ -170,11 +170,11 @@
 
 	  print <<"END_DEF32";
 static inline $type ib_cm_${packet_type}_${name}_get(const struct ib_mad *packet) {
-	return be32_to_cpu(*(($type *) &packet->payload[$linelist[1]]));
+	return be32_to_cpu(*(($type *) &packet->data[$linelist[1]]));
 }
 
 static inline void ib_cm_${packet_type}_${name}_set(struct ib_mad *packet, ${type} value) {
-	*(($type *) &packet->payload[$linelist[1]]) = cpu_to_be32(value);
+	*(($type *) &packet->data[$linelist[1]]) = cpu_to_be32(value);
 }
 
 END_DEF32
@@ -186,7 +186,7 @@
 
 	  print <<"END_DEFPOINTER";
 static inline void *ib_cm_${packet_type}_${name}_get(struct ib_mad *packet) {
-	return &packet->payload[$linelist[1]];
+	return &packet->data[$linelist[1]];
 }
 
 static inline int ib_cm_${packet_type}_${name}_get_length(void) {
Index: infiniband/core/dm_client_class_port_info.c
===================================================================
--- infiniband/core/dm_client_class_port_info.c	(revision 803)
+++ infiniband/core/dm_client_class_port_info.c	(working copy)
@@ -73,7 +73,7 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_dm_class_port_info *cpi_ptr =
-			    (struct ib_dm_class_port_info *) & packet->payload;
+			    (struct ib_dm_class_port_info *) & packet->data;
 			struct ib_common_attrib_cpi cpi;
 
 			cpi.base_version = cpi_ptr->base_version;
@@ -134,7 +134,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_DM, T_VERBOSE, TRACE_KERNEL_IB_DM_GEN,
 			 "DM client Class Port Info query status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -193,18 +193,18 @@
 			      TS_IB_DM_ATTRIBUTE_CLASS_PORTINFO, 0);
 
 	/* Set trap LID to notify TS SRP Mgr to forward trap info */
-	cpi = (struct ib_dm_class_port_info *) mad.payload;
+	cpi = (struct ib_dm_class_port_info *) mad.data;
 	ib_cached_lid_get(device, port, &lid_info);
 	cpi->trap_lid = cpu_to_be16(lid_info.lid);
 	ib_cached_gid_get(device, port, 0, gid);
 	memcpy(cpi->trap_gid, gid, sizeof(tTS_IB_GID));
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->dlid = dst_port_lid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	ib_client_query(&mad, timeout_jiffies, ib_dm_class_port_info_response,
 			query);
Index: infiniband/core/sa_client_notice.c
===================================================================
--- infiniband/core/sa_client_notice.c	(revision 803)
+++ infiniband/core/sa_client_notice.c	(working copy)
@@ -216,9 +216,9 @@
 void tsIbSaNoticeHandler(struct ib_mad *mad, void *arg)
 {
 	struct ib_sa_payload *sa_payload =
-				(struct ib_sa_payload *) mad->payload;
+		(struct ib_sa_payload *) mad->data;
 	struct ib_sa_notice *mad_notice =
-				(struct ib_sa_notice *) sa_payload->admin_data;
+		(struct ib_sa_notice *) sa_payload->admin_data;
 	struct ib_common_attrib_notice notice;
 	tTS_IB_SA_NOTICE_HANDLER_FUNC handler;
 	void *handler_arg;
Index: infiniband/core/client_query.c
===================================================================
--- infiniband/core/client_query.c	(revision 803)
+++ infiniband/core/client_query.c	(working copy)
@@ -239,8 +239,8 @@
 
 	query->callback_running = 0;
 
-	query->transaction_id = packet->transaction_id;
-	query->r_method = packet->r_method;
+	query->transaction_id = packet->mad_hdr.tid;
+	query->r_method       = packet->mad_hdr.method;
 	query->timeout_jiffies = timeout_jiffies;
 	query->callback.function = function;
 	query->arg = arg;
@@ -278,8 +278,8 @@
 		 "ib_client_rmpp_query_new()\n");
 
 	query->callback_running = 0;
-	query->transaction_id = packet->transaction_id;
-	query->r_method = packet->r_method;
+	query->transaction_id = packet->mad_hdr.tid;
+	query->r_method       = packet->mad_hdr.method;
 	query->timeout_jiffies = timeout_jiffies;
 	query->callback.rmpp_function = function;
 	query->arg = arg;
@@ -346,9 +346,9 @@
 	int bytes_to_copy;
 
 	/* Convert to host format */
-	status = be16_to_cpu(mad->status);
-	attribute_id = be16_to_cpu(mad->attribute_id);
-	attribute_modifier = be32_to_cpu(mad->attribute_modifier);
+	status = be16_to_cpu(mad->mad_hdr.status);
+	attribute_id = be16_to_cpu(mad->mad_hdr.attr_id);
+	attribute_modifier = be32_to_cpu(mad->mad_hdr.attr_mod);
 	flag = rmpp_mad->resp_time__flags & 0x0F;
 
 	TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
@@ -488,22 +488,22 @@
 static void ib_client_get_response(struct ib_mad *mad)
 {
 	struct ib_client_query *query =
-				ib_client_query_find(mad->transaction_id);
+		ib_client_query_find(mad->mad_hdr.tid);
 	tTS_IB_CLIENT_RESPONSE_STATUS resp_status;
 
 	if (!query) {
 		TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 			 "packet received for unknown TID 0x%016" TS_U64_FMT
-			 "x", mad->transaction_id);
+			 "x", mad->mad_hdr.tid);
 		return;
 	}
 
-	if (query->r_method == mad->r_method) {
+	if (query->r_method == mad->mad_hdr.method) {
 		ib_client_query_put(query);
 		return;
 	}
 
-	if (mad->status) {
+	if (mad->mad_hdr.status) {
 		resp_status = TS_IB_CLIENT_RESPONSE_ERROR;
 	} else {
 		resp_status = TS_IB_CLIENT_RESPONSE_OK;
@@ -547,8 +547,9 @@
 			}
 		}
 	}
+
 	/* Send out MAD */
-	tsIbMadSend(packet);
+	ib_mad_send(packet);
 
 	return 0;
 }
@@ -586,7 +587,7 @@
 {
 	TS_TRACE(MOD_KERNEL_IB, T_VERY_VERBOSE, TRACE_KERNEL_IB_GEN,
 		 "query packet received, TID 0x%016" TS_U64_FMT "x",
-		 mad->transaction_id);
+		 mad->mad_hdr.tid);
 	if (0) {
 		int i;
 
@@ -602,15 +603,15 @@
 			}
 		}
 	}
-	switch (mad->r_method) {
+	switch (mad->mad_hdr.method) {
 	case IB_MGMT_METHOD_REPORT:
 		{
 			/* Send back REPORT RESPONSE */
 			struct ib_mad report_resp;
 
 			memcpy(&report_resp, mad, sizeof(report_resp));
-			report_resp.r_method =
-                                IB_MGMT_METHOD_REPORT_RESPONSE;
+			report_resp.mad_hdr.method =
+                                IB_MGMT_METHOD_REPORT_RESP;
 			report_resp.slid = mad->dlid;
 			report_resp.dlid = mad->slid;
 			report_resp.sqpn = mad->dqpn;
@@ -626,12 +627,11 @@
 	case IB_MGMT_METHOD_TRAP_REPRESS:
 		{
 			ib_mad_dispatch_func dispatch =
-			    ib_client_async_mad_handler_get(mad->mgmt_class);
+			    ib_client_async_mad_handler_get(mad->mad_hdr.mgmt_class);
 
 			if (dispatch)
 				dispatch(mad,
-					 ib_client_async_mad_handler_arg_get(mad->
-									mgmt_class));
+					 ib_client_async_mad_handler_arg_get(mad->mad_hdr.mgmt_class));
 			return;
 		}
 
@@ -700,7 +700,7 @@
 
 	ib_client_query_put(query);
 
-	tsIbMadSend(packet);
+	ib_mad_send(packet);
 
 	return 0;
 }
Index: infiniband/core/mad_filter.c
===================================================================
--- infiniband/core/mad_filter.c	(revision 812)
+++ infiniband/core/mad_filter.c	(working copy)
@@ -55,13 +55,13 @@
 		 filter->qpn          == qpn)                               &&
 
 		(!(filter->mask & TS_IB_MAD_FILTER_MGMT_CLASS)   ||
-		 filter->mgmt_class   == mad->mgmt_class)                   &&
+		 filter->mgmt_class   == mad->mad_hdr.mgmt_class)           &&
 
 		(!(filter->mask & TS_IB_MAD_FILTER_R_METHOD)     ||
-		 filter->r_method     == mad->r_method)                     &&
+		 filter->r_method     == mad->mad_hdr.method)               &&
 
 		(!(filter->mask & TS_IB_MAD_FILTER_ATTRIBUTE_ID) ||
-		 filter->attribute_id == be16_to_cpu(mad->attribute_id))    &&
+		 filter->attribute_id == be16_to_cpu(mad->mad_hdr.attr_id)) &&
 
 		(!(filter->mask & TS_IB_MAD_FILTER_DIRECTION)    ||
 		 filter->direction    == direction);
@@ -115,8 +115,8 @@
 {
 	u8 hop_pointer, hop_count;
 
-	hop_pointer = mad->route.directed.hop_pointer;
-	hop_count   = mad->route.directed.hop_count;
+	hop_pointer = be16_to_cpu(mad->mad_hdr.class_specific) >> 8;
+	hop_count   = be16_to_cpu(mad->mad_hdr.class_specific) & 0xf;
 
 	/*
 	 * Outgoing MAD processing.  "Outgoing" means from initiator to responder.
@@ -146,7 +146,9 @@
 		if (hop_pointer == hop_count) {
 			if (hop_count != 0)
 				(TS_IB_MAD_SMP_DR_PAYLOAD(mad))->return_path[hop_pointer] = mad->port;
-			++mad->route.directed.hop_pointer;
+			++hop_pointer;
+			mad->mad_hdr.class_specific =
+				cpu_to_be16(hop_count | (hop_pointer << 8));
 
 			if (device->node_type == IB_NODE_SWITCH) {
 				/* XXX switch */
@@ -210,7 +212,9 @@
 
 		/* C14-13:3 -- We're at the end of the DR segment of path */
 		if (hop_pointer == 1) {
-			--mad->route.directed.hop_pointer;
+			--hop_pointer;
+			mad->mad_hdr.class_specific =
+				cpu_to_be16(hop_count | (hop_pointer << 8));
 
 			if (device->node_type == IB_NODE_SWITCH) {
 				/* XXX switch */
@@ -242,7 +246,7 @@
 			return 1;
 
 		/* Check for unreasonable hop pointer.  (C14-13:5) */
-		if (mad->route.directed.hop_pointer > mad->route.directed.hop_count + 1)
+		if (hop_pointer > hop_count + 1)
 			return 0;
 	}
 	return 1;
@@ -280,7 +284,7 @@
 	}
 
 	/* If MAD is Directed Route, we need to validate it and fix it up. */
-	if ((mad->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
+	if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
 	    !ib_mad_validate_dr_smp(mad, device))
 		ret = IB_MAD_RESULT_SUCCESS; // As if device ignored packet.
 	else
@@ -294,8 +298,8 @@
 			       device->name,
 			       mad->port,
 			       mad->dqpn,
-			       mad->mgmt_class,
-			       be16_to_cpu(mad->attribute_id));
+			       mad->mad_hdr.mgmt_class,
+			       be16_to_cpu(mad->mad_hdr.attr_id));
 
 	/* If the packet was consumed, we don't want to let anyone else look at it.
 	 * This is a special case for hardware (tavor) which uses the input queue
Index: infiniband/core/dm_client_ioc_profile.c
===================================================================
--- infiniband/core/dm_client_ioc_profile.c	(revision 803)
+++ infiniband/core/dm_client_ioc_profile.c	(working copy)
@@ -81,13 +81,12 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_dm_ioc_profile *ioc_profile_ptr =
-			    (struct ib_dm_ioc_profile *) & packet->payload;
+			    (struct ib_dm_ioc_profile *) & packet->data;
 			struct ib_ioc_profile ioc_profile;
 
 			ioc_profile.controller_id =
 			    TS_IB_DM_IOCPROFILE_GET_CONTROLLER_ID(be32_to_cpu
-								  (packet->
-								   attribute_modifier));
+								  (packet->mad_hdr.attr_mod));
 			memcpy(ioc_profile.guid, ioc_profile_ptr->guid,
 			       sizeof(tTS_IB_GUID));
 			ioc_profile.vendor_id =
@@ -153,7 +152,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_DM, T_VERBOSE, TRACE_KERNEL_IB_DM_GEN,
 			 "DM client IOU Info MAD status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -208,12 +207,12 @@
 			    TS_IB_DM_IOCPROFILE_GET_CONTROLLER_ID
 			    (controller_id));
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->dlid = dst_port_lid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	ib_client_query(&mad, timeout_jiffies, ib_ioc_profile_response, query);
 
Index: infiniband/core/mad_static.c
===================================================================
--- infiniband/core/mad_static.c	(revision 812)
+++ infiniband/core/mad_static.c	(working copy)
@@ -126,11 +126,11 @@
 	}
 
 	memset(mad_in, 0, sizeof *mad_in);
-	mad_in->format_version = 1;
-	mad_in->mgmt_class     = IB_MGMT_CLASS_SUBN_LID_ROUTED;
-	mad_in->class_version  = 1;
-	mad_in->r_method       = IB_MGMT_METHOD_GET;
-	mad_in->attribute_id   = cpu_to_be16(IB_SMP_ATTRIB_PORT_INFO);
+	mad_in->mad_hdr.base_version = 1;
+	mad_in->mad_hdr.mgmt_class     = IB_MGMT_CLASS_SUBN_LID_ROUTED;
+	mad_in->mad_hdr.class_version  = 1;
+	mad_in->mad_hdr.method         = IB_MGMT_METHOD_GET;
+	mad_in->mad_hdr.attr_id        = cpu_to_be16(IB_SMP_ATTRIB_PORT_INFO);
 
 	/* Request port info from the device */
 	if ((device->process_mad(device, IB_MAD_IGNORE_MKEY, port, 0xffff, mad_in, mad_out) &
@@ -144,7 +144,7 @@
 	/* Edit the lid field in the returned port info. */
 	ib_smp_port_info_lid_set(IB_MAD_TO_SMP_DATA(mad_out), lid_base);
 	++lid_base;
-	mad_out->r_method = IB_MGMT_METHOD_SET;
+	mad_out->mad_hdr.method = IB_MGMT_METHOD_SET;
 
 	/* Update the port info on the device */
 	if (!(device->process_mad(device, IB_MAD_IGNORE_MKEY, port, 0xffff, mad_out, mad_in) &
Index: infiniband/core/sa_client_path_record.c
===================================================================
--- infiniband/core/sa_client_path_record.c	(revision 803)
+++ infiniband/core/sa_client_path_record.c	(working copy)
@@ -68,7 +68,7 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_sa_payload *sa_payload =
-			    (struct ib_sa_payload *) & packet->payload;
+			    (struct ib_sa_payload *) & packet->data;
 			struct ib_sa_path_record *path_ptr =
 			    (struct ib_sa_path_record *) sa_payload->admin_data;
 			struct ib_path_record path_rec;
@@ -107,7 +107,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 			 "SA client path record MAD status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -152,7 +152,7 @@
 {
 	struct ib_mad mad;
 	struct ib_sa_payload *sa_payload =
-	    (struct ib_sa_payload *) & mad.payload;
+	    (struct ib_sa_payload *) & mad.data;
 	struct ib_sa_path_record *path_rec =
 	    (struct ib_sa_path_record *) sa_payload->admin_data;
 	struct ib_sa_path_record_query *query;
@@ -164,11 +164,11 @@
 
 	tsIbSaClientMadInit(&mad, device, port);
 
-	mad.r_method = IB_MGMT_METHOD_GET;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_PATH_RECORD);
-	mad.attribute_modifier = 0xffffffff;	/* match attributes */
+	mad.mad_hdr.method = IB_MGMT_METHOD_GET;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_PATH_RECORD);
+	mad.mad_hdr.attr_mod = 0xffffffff;	/* match attributes */
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
@@ -184,7 +184,7 @@
 
 	ib_client_query(&mad, timeout_jiffies, _tsIbPathRecordResponse, query);
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	return 0;
 }
Index: infiniband/core/sa_client_inform.c
===================================================================
--- infiniband/core/sa_client_inform.c	(revision 803)
+++ infiniband/core/sa_client_inform.c	(working copy)
@@ -82,9 +82,9 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_sa_payload *sa_payload =
-			    (struct ib_sa_payload *) & packet->payload;
+				(struct ib_sa_payload *) & packet->data;
 			struct ib_sa_inform_info *mad_inform_info =
-			    (struct ib_sa_inform_info *) sa_payload->admin_data;
+				(struct ib_sa_inform_info *) sa_payload->admin_data;
 			struct ib_common_attrib_inform inform_info;
 
 			TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
@@ -133,7 +133,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 			 "SA client inform info MAD status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -174,9 +174,9 @@
 {
 	struct ib_mad mad;
 	struct ib_sa_payload *sa_payload =
-	    (struct ib_sa_payload *) & mad.payload;
+		(struct ib_sa_payload *) & mad.data;
 	struct ib_sa_inform_info *mad_inform_info =
-	    (struct ib_sa_inform_info *) sa_payload->admin_data;
+		(struct ib_sa_inform_info *) sa_payload->admin_data;
 	struct ib_sa_inform_info_query *query;
 
 	query = kmalloc(sizeof *query, GFP_ATOMIC);
@@ -185,11 +185,11 @@
 	}
 
 	tsIbSaClientMadInit(&mad, device, port);
-	mad.r_method = IB_MGMT_METHOD_SET;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_INFORM_INFO);
-	mad.attribute_modifier = 0;
+	mad.mad_hdr.method = IB_MGMT_METHOD_SET;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_INFORM_INFO);
+	mad.mad_hdr.attr_mod = 0;
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
@@ -218,7 +218,7 @@
 		    cpu_to_be32(inform_info->define.vendor.vendor_id);
 	}
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	ib_client_query(&mad, timeout_jiffies, _tsIbInformResponse, query);
 
Index: infiniband/core/sa_client_port_info.c
===================================================================
--- infiniband/core/sa_client_port_info.c	(revision 803)
+++ infiniband/core/sa_client_port_info.c	(working copy)
@@ -88,9 +88,9 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_sa_payload *sa_payload =
-			    (struct ib_sa_payload *) & packet->payload;
+				(struct ib_sa_payload *) & packet->data;
 			struct ib_sa_port_info *port_info_ptr =
-			    (struct ib_sa_port_info *) sa_payload->admin_data;
+				(struct ib_sa_port_info *) sa_payload->admin_data;
 			struct ib_port_info port_info;
 
 			memcpy(port_info.mkey, port_info_ptr->mkey, 8);
@@ -199,7 +199,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 			 "SA client port info MAD status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -466,9 +466,9 @@
 {
 	struct ib_mad mad;
 	struct ib_sa_payload *sa_payload =
-	    (struct ib_sa_payload *) & mad.payload;
+		(struct ib_sa_payload *) & mad.data;
 	struct ib_sa_port_info *port_info =
-	    (struct ib_sa_port_info *) sa_payload->admin_data;
+		(struct ib_sa_port_info *) sa_payload->admin_data;
 	struct ib_sa_port_info_query *query;
 
 	query = kmalloc(sizeof *query, GFP_ATOMIC);
@@ -477,19 +477,19 @@
 	}
 
 	tsIbSaClientMadInit(&mad, device, port);
-	mad.r_method = IB_MGMT_METHOD_GET;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_PORT_INFO_RECORD);
-	mad.attribute_modifier = 0;
+	mad.mad_hdr.method = IB_MGMT_METHOD_GET;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_PORT_INFO_RECORD);
+	mad.mad_hdr.attr_mod = 0;
 
 	sa_payload->sa_header.component_mask = cpu_to_be64(0x1ULL);	/* port LID  */
 
 	port_info->port_lid = cpu_to_be16(port_lid);
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	ib_client_query(&mad, timeout_jiffies, _tsIbPortInfoResponse, query);
 
@@ -514,20 +514,20 @@
 	}
 
 	tsIbSaClientMadInit(&mad, device, port);
-	mad.r_method = TS_IB_SA_METHOD_GET_TABLE;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_PORT_INFO_RECORD);
-	mad.attribute_modifier = 0;
+	mad.mad_hdr.method = TS_IB_SA_METHOD_GET_TABLE;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_PORT_INFO_RECORD);
+	mad.mad_hdr.attr_mod = 0;
 
 	/* rmpp header init */
 	rmpp_mad = (struct ib_client_rmpp_mad *) & mad;
 	rmpp_mad->version = 1;
 	rmpp_mad->type = TS_IB_CLIENT_RMPP_TYPE_DATA;
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	ib_rmpp_client_query(&mad, timeout_jiffies, sizeof(struct ib_sa_header),
 			     _tsIbPortInfoTblResponse, query);
Index: infiniband/core/sa_client_node_info.c
===================================================================
--- infiniband/core/sa_client_node_info.c	(revision 803)
+++ infiniband/core/sa_client_node_info.c	(working copy)
@@ -70,9 +70,9 @@
 	case TS_IB_CLIENT_RESPONSE_OK:
 		{
 			struct ib_sa_payload *sa_payload =
-			    (struct ib_sa_payload *) & packet->payload;
+				(struct ib_sa_payload *) & packet->data;
 			struct ib_sa_node_info *node_info_ptr =
-			    (struct ib_sa_node_info *) sa_payload->admin_data;
+				(struct ib_sa_node_info *) sa_payload->admin_data;
 			struct ib_node_info node_info;
 
 			memset(&node_info, 0, sizeof(node_info));
@@ -115,7 +115,7 @@
 	case TS_IB_CLIENT_RESPONSE_ERROR:
 		TS_TRACE(MOD_KERNEL_IB, T_VERBOSE, TRACE_KERNEL_IB_GEN,
 			 "SA client node info MAD status 0x%04x",
-			 be16_to_cpu(packet->status));
+			 be16_to_cpu(packet->mad_hdr.status));
 		if (query->completion_func) {
 			query->completion_func(query->transaction_id,
 					       -EINVAL,
@@ -156,9 +156,9 @@
 {
 	struct ib_mad mad;
 	struct ib_sa_payload *sa_payload =
-	    (struct ib_sa_payload *) & mad.payload;
+		(struct ib_sa_payload *) & mad.data;
 	struct ib_sa_node_info *node_info =
-	    (struct ib_sa_node_info *) sa_payload->admin_data;
+		(struct ib_sa_node_info *) sa_payload->admin_data;
 	struct ib_sa_node_info_query *query;
 
 	query = kmalloc(sizeof *query, GFP_ATOMIC);
@@ -167,11 +167,11 @@
 	}
 
 	tsIbSaClientMadInit(&mad, device, port);
-	mad.r_method = IB_MGMT_METHOD_GET;
-	mad.attribute_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_NODE_RECORD);
-	mad.attribute_modifier = 0;
+	mad.mad_hdr.method = IB_MGMT_METHOD_GET;
+	mad.mad_hdr.attr_id = cpu_to_be16(TS_IB_SA_ATTRIBUTE_NODE_RECORD);
+	mad.mad_hdr.attr_mod = 0;
 
-	query->transaction_id = mad.transaction_id;
+	query->transaction_id = mad.mad_hdr.tid;
 	query->completion_func = completion_func;
 	query->completion_arg = completion_arg;
 
@@ -179,7 +179,7 @@
 
 	node_info->port_lid = port_lid;
 
-	*transaction_id = mad.transaction_id;
+	*transaction_id = mad.mad_hdr.tid;
 
 	ib_client_query(&mad, timeout_jiffies, _tsIbNodeInfoResponse, query);
 
Index: infiniband/core/useraccess_mad.c
===================================================================
--- infiniband/core/useraccess_mad.c	(revision 803)
+++ infiniband/core/useraccess_mad.c	(working copy)
@@ -185,8 +185,8 @@
 		 mad->slid,
 		 mad->port,
 		 mad->dqpn,
-		 mad->mgmt_class,
-		 mad->r_method, be16_to_cpu(mad->attribute_id));
+		 mad->mad_hdr.mgmt_class,
+		 mad->mad_hdr.method, be16_to_cpu(mad->mad_hdr.attr_id));
 
 	down(&filter->priv->mad_sem);
 	if (filter->priv->mad_queue_length < filter->priv->max_mad_queue_length) {
Index: infiniband/core/cm_proc.c
===================================================================
--- infiniband/core/cm_proc.c	(revision 803)
+++ infiniband/core/cm_proc.c	(working copy)
@@ -60,21 +60,21 @@
 
 void ib_cm_count_receive(struct ib_mad *packet)
 {
-	u16 attribute_id = be16_to_cpu(packet->attribute_id);
+	u16 attribute_id = be16_to_cpu(packet->mad_hdr.attr_id);
 	if (attribute_id < max_id)
 		atomic_inc(&cm_packet_count[attribute_id].received);
 }
 
 void ib_cm_count_send(struct ib_mad *packet)
 {
-	u16 attribute_id = be16_to_cpu(packet->attribute_id);
+	u16 attribute_id = be16_to_cpu(packet->mad_hdr.attr_id);
 	if (attribute_id < max_id)
 		atomic_inc(&cm_packet_count[attribute_id].sent);
 }
 
 void ib_cm_count_resend(struct ib_mad *packet)
 {
-	u16 attribute_id = be16_to_cpu(packet->attribute_id);
+	u16 attribute_id = be16_to_cpu(packet->mad_hdr.attr_id);
 	if (attribute_id < max_id) {
 		atomic_inc(&cm_packet_count[attribute_id].sent);
 		atomic_inc(&cm_packet_count[attribute_id].resent);
Index: infiniband/core/generate_pkt_access.pl
===================================================================
--- infiniband/core/generate_pkt_access.pl	(revision 803)
+++ infiniband/core/generate_pkt_access.pl	(working copy)
@@ -132,7 +132,7 @@
 };
 #endif // _IB_PRINTER_DEFINED_
 
-#define IB_MAD_TO_${class_type}_DATA(mad) (&(mad)->payload[$payload_offset])
+#define IB_MAD_TO_${class_type}_DATA(mad) (&(mad)->data[$payload_offset])
 
 HEADER_TOP
 
@@ -1184,7 +1184,7 @@
   print "\n";
   print "void $func_name(struct ib_printer *printer, struct ib_mad *mad)\n";
   print "{\n";
-  print "	__u16 attribute = be16_to_cpu(mad->attribute_id);\n\n";
+  print "	__u16 attribute = be16_to_cpu(mad->mad_hdr.attr_id);\n\n";
 
   print "	switch (attribute) {\n";
   foreach $attrib_num (sort numerically keys(%known_attributes)) {
Index: infiniband/core/dm_client_query.c
===================================================================
--- infiniband/core/dm_client_query.c	(revision 803)
+++ infiniband/core/dm_client_query.c	(working copy)
@@ -42,10 +42,10 @@
 {
 	memset(packet, 0, sizeof *packet);
 
-	packet->format_version = 1;
-	packet->mgmt_class = IB_MGMT_CLASS_DEV_MGT;
-	packet->class_version = TS_IB_DM_CLASS_VERSION;
-	packet->transaction_id = ib_client_alloc_tid();
+	packet->mad_hdr.base_version = 1;
+	packet->mad_hdr.mgmt_class = IB_MGMT_CLASS_DEVICE_MGMT;
+	packet->mad_hdr.class_version = TS_IB_DM_CLASS_VERSION;
+	packet->mad_hdr.tid = ib_client_alloc_tid();
 
 	packet->device = device;
 	packet->pkey_index = 0;
@@ -55,9 +55,9 @@
 	packet->sl = 0;
 	packet->sqpn = 1;
 	packet->dqpn = dst_qpn;
-	packet->r_method = r_method;
-	packet->attribute_id = cpu_to_be16(attribute_id);
-	packet->attribute_modifier = cpu_to_be32(attribute_modifier);
+	packet->mad_hdr.method = r_method;
+	packet->mad_hdr.attr_id = cpu_to_be16(attribute_id);
+	packet->mad_hdr.attr_mod = cpu_to_be32(attribute_modifier);
 
 	packet->has_grh = 0;
 
Index: infiniband/core/sa_client_query.c
===================================================================
--- infiniband/core/sa_client_query.c	(revision 803)
+++ infiniband/core/sa_client_query.c	(working copy)
@@ -44,11 +44,11 @@
 
 	memset(packet, 0, sizeof *packet);
 
-	packet->format_version = 1;
-	packet->mgmt_class = IB_MGMT_CLASS_SUBN_ADM;
-	packet->class_version = TS_IB_SA_CLASS_VERSION;
-	packet->transaction_id = ib_client_alloc_tid();
-	packet->attribute_modifier = 0xffffffff;
+	packet->mad_hdr.base_version = 1;
+	packet->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_ADM;
+	packet->mad_hdr.class_version = TS_IB_SA_CLASS_VERSION;
+	packet->mad_hdr.tid = ib_client_alloc_tid();
+	packet->mad_hdr.attr_mod = 0xffffffff;
 
 	packet->device = device;
 	packet->port = port;
Index: infiniband/core/cm_passive.c
===================================================================
--- infiniband/core/cm_passive.c	(revision 803)
+++ infiniband/core/cm_passive.c	(working copy)
@@ -60,8 +60,8 @@
 	if (reply_data && reply_size > 0)
 		memcpy(ib_cm_rep_private_data_get(&connection->mad), reply_data, reply_size);
 
-	connection->mad.attribute_id   = cpu_to_be16(IB_COM_MGT_REP);
-	connection->mad.transaction_id = cpu_to_be64(connection->transaction_id);
+	connection->mad.mad_hdr.attr_id   = cpu_to_be16(IB_COM_MGT_REP);
+	connection->mad.mad_hdr.tid = cpu_to_be64(connection->transaction_id);
 
 	ib_cm_rep_local_comm_id_set     (&connection->mad, connection->local_comm_id);
 	ib_cm_rep_remote_comm_id_set    (&connection->mad, connection->remote_comm_id);
@@ -372,7 +372,7 @@
 	connection->state                    = IB_CM_STATE_REQ_RECEIVED;
 	connection->cm_retry_count           = 0;
 
-	connection->transaction_id           = be64_to_cpu(packet->transaction_id);
+	connection->transaction_id           = be64_to_cpu(packet->mad_hdr.tid);
 
 	ib_cm_connection_insert_remote(connection);
 }
@@ -395,7 +395,7 @@
 				packet->pkey_index,
 				packet->slid,
 				packet->sqpn,
-				be64_to_cpu(packet->transaction_id),
+				be64_to_cpu(packet->mad_hdr.tid),
 				0,
 				ib_cm_req_local_comm_id_get(packet),
 				IB_REJ_REQ,
@@ -483,7 +483,7 @@
 		   then treat this REQ as a resend.  Otherwise our connection is a
 		   stale connection.  (See section 12.9.8.3.1 of the IB spec) */
 		if (ib_cm_req_local_comm_id_get(packet) == connection->remote_comm_id &&
-		    be16_to_cpu(connection->mad.attribute_id) == IB_COM_MGT_REP &&
+		    be16_to_cpu(connection->mad.mad_hdr.attr_id) == IB_COM_MGT_REP &&
 		    time_after(connection->establish_jiffies +
 			       ib_cm_timeout_to_jiffies(connection->cm_response_timeout),
 			       jiffies)) {
Index: infiniband/core/cm_active.c
===================================================================
--- infiniband/core/cm_active.c	(revision 803)
+++ infiniband/core/cm_active.c	(working copy)
@@ -59,8 +59,8 @@
 
 	ib_mad_build_header(&connection->mad);
 
-	connection->mad.attribute_id   = cpu_to_be16(IB_COM_MGT_REQ);
-	connection->mad.transaction_id = cpu_to_be64(connection->transaction_id);
+	connection->mad.mad_hdr.attr_id   = cpu_to_be16(IB_COM_MGT_REQ);
+	connection->mad.mad_hdr.tid       = cpu_to_be64(connection->transaction_id);
 
 	/* Fields are in order of the IB spec. 12.6.5 */
 
@@ -237,8 +237,8 @@
 
 	ib_mad_build_header(&connection->mad);
 
-	connection->mad.attribute_id = cpu_to_be16(IB_COM_MGT_RTU);
-	connection->mad.transaction_id = cpu_to_be64(connection->transaction_id);
+	connection->mad.mad_hdr.attr_id = cpu_to_be16(IB_COM_MGT_RTU);
+	connection->mad.mad_hdr.tid     = cpu_to_be64(connection->transaction_id);
 
 	ib_cm_rtu_local_comm_id_set (&connection->mad, connection->local_comm_id);
 	ib_cm_rtu_remote_comm_id_set(&connection->mad, connection->remote_comm_id);
@@ -374,7 +374,7 @@
 	if (connection->state == IB_CM_STATE_ESTABLISHED) {
 		/* Resend RTU if connection is established, but make sure we
 		   haven't already sent some other kind of CM packet. */
-		if (connection->mad.attribute_id == cpu_to_be16(IB_COM_MGT_RTU)) {
+		if (connection->mad.mad_hdr.attr_id == cpu_to_be16(IB_COM_MGT_RTU)) {
 			ib_cm_count_resend(&connection->mad);
 			result = ib_mad_send(&connection->mad);
 			if (result) {
@@ -484,7 +484,7 @@
 				packet->pkey_index,
 				packet->slid,
 				packet->sqpn,
-				be64_to_cpu(packet->transaction_id),
+				be64_to_cpu(packet->mad_hdr.tid),
 				ib_cm_rep_remote_comm_id_get(packet),
 				ib_cm_rep_local_comm_id_get(packet),
 				IB_REJ_REP,
Index: infiniband/hw/mthca/mthca_provider.c
===================================================================
--- infiniband/hw/mthca/mthca_provider.c	(revision 812)
+++ infiniband/hw/mthca/mthca_provider.c	(working copy)
@@ -51,11 +51,11 @@
 	props->fw_ver        = to_mdev(ibdev)->fw_ver;
 
 	memset(in_mad, 0, sizeof *in_mad);
-	in_mad->format_version     = 1;
-	in_mad->mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
-	in_mad->class_version  	   = 1;
-	in_mad->r_method       	   = IB_MGMT_METHOD_GET;
-	in_mad->attribute_id   	   = cpu_to_be16(IB_SMP_ATTRIB_NODE_INFO);
+	in_mad->mad_hdr.base_version       = 1;
+	in_mad->mad_hdr.mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
+	in_mad->mad_hdr.class_version  	   = 1;
+	in_mad->mad_hdr.method         	   = IB_MGMT_METHOD_GET;
+	in_mad->mad_hdr.attr_id   	   = cpu_to_be16(IB_SMP_ATTRIB_NODE_INFO);
 
 	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
 			    1, in_mad, out_mad,
@@ -67,12 +67,12 @@
 		goto out;
 	}
 
-	props->vendor_id      = be32_to_cpup((u32 *) (out_mad->payload + 76)) &
+	props->vendor_id      = be32_to_cpup((u32 *) (out_mad->data + 76)) &
 		0xffffff;
-	props->vendor_part_id = be16_to_cpup((u16 *) (out_mad->payload + 70));
-	props->hw_ver         = be16_to_cpup((u16 *) (out_mad->payload + 72));
-	memcpy(&props->sys_image_guid, out_mad->payload + 44, 8);
-	memcpy(&props->node_guid,      out_mad->payload + 52, 8);
+	props->vendor_part_id = be16_to_cpup((u16 *) (out_mad->data + 70));
+	props->hw_ver         = be16_to_cpup((u16 *) (out_mad->data + 72));
+	memcpy(&props->sys_image_guid, out_mad->data + 44, 8);
+	memcpy(&props->node_guid,      out_mad->data + 52, 8);
 
 	err = 0;
  out:
@@ -95,12 +95,12 @@
 		goto out;
 
 	memset(in_mad, 0, sizeof *in_mad);
-	in_mad->format_version     = 1;
-	in_mad->mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
-	in_mad->class_version  	   = 1;
-	in_mad->r_method       	   = IB_MGMT_METHOD_GET;
-	in_mad->attribute_id   	   = cpu_to_be16(IB_SMP_ATTRIB_PORT_INFO);
-	in_mad->attribute_modifier = cpu_to_be32(port);
+	in_mad->mad_hdr.base_version       = 1;
+	in_mad->mad_hdr.mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
+	in_mad->mad_hdr.class_version  	   = 1;
+	in_mad->mad_hdr.method         	   = IB_MGMT_METHOD_GET;
+	in_mad->mad_hdr.attr_id   	   = cpu_to_be16(IB_SMP_ATTRIB_PORT_INFO);
+	in_mad->mad_hdr.attr_mod           = cpu_to_be32(port);
 
 	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
 			    port, in_mad, out_mad,
@@ -112,15 +112,15 @@
 		goto out;
 	}
 
-	props->lid               = be16_to_cpup((u16 *) (out_mad->payload + 56));
-	props->lmc               = (*(u8 *) (out_mad->payload + 74)) & 0x7;
-	props->sm_lid            = be16_to_cpup((u16 *) (out_mad->payload + 58));
-	props->sm_sl             = (*(u8 *) (out_mad->payload + 76)) & 0xf;
-	props->state             = (*(u8 *) (out_mad->payload + 72)) & 0xf;
-	props->port_cap_flags    = be32_to_cpup((u32 *) (out_mad->payload + 60));
+	props->lid               = be16_to_cpup((u16 *) (out_mad->data + 56));
+	props->lmc               = (*(u8 *) (out_mad->data + 74)) & 0x7;
+	props->sm_lid            = be16_to_cpup((u16 *) (out_mad->data + 58));
+	props->sm_sl             = (*(u8 *) (out_mad->data + 76)) & 0xf;
+	props->state             = (*(u8 *) (out_mad->data + 72)) & 0xf;
+	props->port_cap_flags    = be32_to_cpup((u32 *) (out_mad->data + 60));
 	props->gid_tbl_len       = to_mdev(ibdev)->limits.gid_table_len;
 	props->pkey_tbl_len      = to_mdev(ibdev)->limits.pkey_table_len;
-	props->qkey_viol_cntr    = be16_to_cpup((u16 *) (out_mad->payload + 88));
+	props->qkey_viol_cntr    = be16_to_cpup((u16 *) (out_mad->data + 88));
 
  out:
 	kfree(in_mad);
@@ -149,12 +149,12 @@
 		goto out;
 
 	memset(in_mad, 0, sizeof *in_mad);
-	in_mad->format_version     = 1;
-	in_mad->mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
-	in_mad->class_version  	   = 1;
-	in_mad->r_method       	   = IB_MGMT_METHOD_GET;
-	in_mad->attribute_id   	   = cpu_to_be16(IB_SMP_ATTRIB_PKEY_TABLE);
-	in_mad->attribute_modifier = cpu_to_be32(index / 32);
+	in_mad->mad_hdr.base_version       = 1;
+	in_mad->mad_hdr.mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
+	in_mad->mad_hdr.class_version  	   = 1;
+	in_mad->mad_hdr.method         	   = IB_MGMT_METHOD_GET;
+	in_mad->mad_hdr.attr_id   	   = cpu_to_be16(IB_SMP_ATTRIB_PKEY_TABLE);
+	in_mad->mad_hdr.attr_mod           = cpu_to_be32(index / 32);
 
 	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
 			    port, in_mad, out_mad,
@@ -166,7 +166,7 @@
 		goto out;
 	}
 
-	*pkey = ((u16 *) (out_mad->payload + 40))[index % 32];
+	*pkey = ((u16 *) (out_mad->data + 40))[index % 32];
 
  out:
 	kfree(in_mad);
@@ -188,12 +188,12 @@
 		goto out;
 
 	memset(in_mad, 0, sizeof *in_mad);
-	in_mad->format_version     = 1;
-	in_mad->mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
-	in_mad->class_version  	   = 1;
-	in_mad->r_method       	   = IB_MGMT_METHOD_GET;
-	in_mad->attribute_id   	   = cpu_to_be16(IB_SMP_ATTRIB_PORT_INFO);
-	in_mad->attribute_modifier = cpu_to_be32(port);
+	in_mad->mad_hdr.base_version       = 1;
+	in_mad->mad_hdr.mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
+	in_mad->mad_hdr.class_version  	   = 1;
+	in_mad->mad_hdr.method         	   = IB_MGMT_METHOD_GET;
+	in_mad->mad_hdr.attr_id   	   = cpu_to_be16(IB_SMP_ATTRIB_PORT_INFO);
+	in_mad->mad_hdr.attr_mod           = cpu_to_be32(port);
 
 	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
 			    port, in_mad, out_mad,
@@ -205,15 +205,15 @@
 		goto out;
 	}
 
-	memcpy(gid->raw, out_mad->payload + 48, 8);
+	memcpy(gid->raw, out_mad->data + 48, 8);
 
 	memset(in_mad, 0, sizeof *in_mad);
-	in_mad->format_version     = 1;
-	in_mad->mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
-	in_mad->class_version  	   = 1;
-	in_mad->r_method       	   = IB_MGMT_METHOD_GET;
-	in_mad->attribute_id   	   = cpu_to_be16(IB_SMP_ATTRIB_GUID_INFO);
-	in_mad->attribute_modifier = cpu_to_be32(index / 8);
+	in_mad->mad_hdr.base_version       = 1;
+	in_mad->mad_hdr.mgmt_class     	   = IB_MGMT_CLASS_SUBN_LID_ROUTED;
+	in_mad->mad_hdr.class_version  	   = 1;
+	in_mad->mad_hdr.method         	   = IB_MGMT_METHOD_GET;
+	in_mad->mad_hdr.attr_id   	   = cpu_to_be16(IB_SMP_ATTRIB_GUID_INFO);
+	in_mad->mad_hdr.attr_mod           = cpu_to_be32(index / 8);
 
 	err = mthca_MAD_IFC(to_mdev(ibdev), 1,
 			    port, in_mad, out_mad,
@@ -225,7 +225,7 @@
 		goto out;
 	}
 
-	memcpy(gid->raw + 8, out_mad->payload + 40 + (index % 8) * 16, 8);
+	memcpy(gid->raw + 8, out_mad->data + 40 + (index % 8) * 16, 8);
 
  out:
 	kfree(in_mad);
Index: infiniband/hw/mthca/mthca_mad.c
===================================================================
--- infiniband/hw/mthca/mthca_mad.c	(revision 812)
+++ infiniband/hw/mthca/mthca_mad.c	(working copy)
@@ -50,17 +50,17 @@
 	struct ib_event event;
 
 	if (mad->dqpn         == 0 &&
-	    (mad->mgmt_class  == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
-	     mad->mgmt_class  == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
-	    mad->r_method     == IB_MGMT_METHOD_SET) {
-		if (mad->attribute_id == cpu_to_be16(IB_SM_PORT_INFO)) {
+	    (mad->mad_hdr.mgmt_class  == IB_MGMT_CLASS_SUBN_LID_ROUTED ||
+	     mad->mad_hdr.mgmt_class  == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) &&
+	    mad->mad_hdr.method     == IB_MGMT_METHOD_SET) {
+		if (mad->mad_hdr.attr_id == cpu_to_be16(IB_SM_PORT_INFO)) {
 			event.device           = ibdev;
 			event.event            = IB_EVENT_LID_CHANGE;
 			event.element.port_num = port_num;
 			ib_dispatch_event(&event);
 		}
 
-		if (mad->attribute_id == cpu_to_be16(IB_SM_PKEY_TABLE)) {
+		if (mad->mad_hdr.attr_id == cpu_to_be16(IB_SM_PKEY_TABLE)) {
 			event.device           = ibdev;
 			event.event            = IB_EVENT_PKEY_CHANGE;
 			event.element.port_num = port_num;
@@ -80,8 +80,8 @@
 	u8 status;
 
 	/* Forward locally generated traps to the SM */
-	if (in_mad->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED &&
-	    in_mad->r_method   == IB_MGMT_METHOD_TRAP           &&
+	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED &&
+	    in_mad->mad_hdr.method   == IB_MGMT_METHOD_TRAP           &&
 	    slid               == 0) {
 		struct ib_sm_path sm_path;
 
@@ -102,25 +102,25 @@
 	 * Only handle PMA and Mellanox vendor-specific class gets and
 	 * sets for other classes.
 	 */
-	if (in_mad->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED || 
-	    in_mad->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
-		if (in_mad->r_method   != IB_MGMT_METHOD_GET &&
-		    in_mad->r_method   != IB_MGMT_METHOD_SET &&
-		    in_mad->r_method   != IB_MGMT_METHOD_TRAP_REPRESS)
+	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED || 
+	    in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
+		if (in_mad->mad_hdr.method   != IB_MGMT_METHOD_GET &&
+		    in_mad->mad_hdr.method   != IB_MGMT_METHOD_SET &&
+		    in_mad->mad_hdr.method   != IB_MGMT_METHOD_TRAP_REPRESS)
 			return IB_MAD_RESULT_SUCCESS;
 
 		/* 
 		 * Don't process SMInfo queries or vendor-specific
 		 * MADs -- the SMA can't handle them.
 		 */
-		if (be16_to_cpu(in_mad->attribute_id) == IB_SM_SM_INFO ||
-		    be16_to_cpu(in_mad->attribute_id) >= IB_SM_VENDOR_START)
+		if (be16_to_cpu(in_mad->mad_hdr.attr_id) == IB_SM_SM_INFO ||
+		    be16_to_cpu(in_mad->mad_hdr.attr_id) >= IB_SM_VENDOR_START)
 			return IB_MAD_RESULT_SUCCESS;
-	} else if (in_mad->mgmt_class == IB_MGMT_CLASS_PERF  ||
-		   in_mad->mgmt_class == MTHCA_VENDOR_CLASS1 || 
-		   in_mad->mgmt_class == MTHCA_VENDOR_CLASS2) {
-		if (in_mad->r_method  != IB_MGMT_METHOD_GET &&
-		    in_mad->r_method  != IB_MGMT_METHOD_SET)
+	} else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
+		   in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS1     || 
+		   in_mad->mad_hdr.mgmt_class == MTHCA_VENDOR_CLASS2) {
+		if (in_mad->mad_hdr.method  != IB_MGMT_METHOD_GET &&
+		    in_mad->mad_hdr.method  != IB_MGMT_METHOD_SET)
 			return IB_MAD_RESULT_SUCCESS;
 	} else
 		return IB_MAD_RESULT_SUCCESS;
@@ -144,10 +144,10 @@
 	smp_snoop(ibdev, in_mad, port_num);
 
 	/* set return bit in status of directed route responses */
-	if (in_mad->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
-		out_mad->status |= cpu_to_be16(1 << 15);
+	if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
+		out_mad->mad_hdr.status |= cpu_to_be16(1 << 15);
 
-	if (in_mad->r_method == IB_MGMT_METHOD_TRAP_REPRESS)
+	if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP_REPRESS)
 		/* no response for trap repress */
 		return IB_MAD_RESULT_SUCCESS;
 



More information about the general mailing list