[infiniband] Respect hop pointer when building directed route SMP return path

The return path in directed route SMPs lists the egress ports in order
from SM to node, rather than from node to SM.

To write to the correct offset within the return path, we need to
parse the hop pointer.  This is held within the class-specific data
portion of the MAD header, which was previously unused by us and
defined to be a uint16_t.  Define this field to be a union type; this
requires some rearrangement of ib_mad.h and corresponding changes to
ipoib.c.
This commit is contained in:
Michael Brown
2008-11-12 15:35:45 +00:00
parent 2ca2607b1b
commit 1b3edd9e11
3 changed files with 175 additions and 138 deletions

View File

@@ -10,83 +10,24 @@
#include <stdint.h>
#include <gpxe/ib_packet.h>
/** A management datagram common header
/*****************************************************************************
*
* Defined in section 13.4.2 of the IBA.
*/
struct ib_mad_hdr {
uint8_t base_version;
uint8_t mgmt_class;
uint8_t class_version;
uint8_t method;
uint16_t status;
uint16_t class_specific;
uint32_t tid[2];
uint16_t attr_id;
uint8_t reserved[2];
uint32_t attr_mod;
} __attribute__ (( packed ));
/* Management base version */
#define IB_MGMT_BASE_VERSION 1
/* 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
#define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30
#define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F
/* 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
#define IB_MGMT_METHOD_DELETE 0x15
/* Status codes */
#define IB_MGMT_STATUS_OK 0x0000
#define IB_MGMT_STATUS_BAD_VERSION 0x0001
#define IB_MGMT_STATUS_UNSUPPORTED_METHOD 0x0002
#define IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR 0x0003
#define IB_MGMT_STATUS_INVALID_VALUE 0x0004
/** A LID routed SMP header
* Subnet management MADs
*
* Defined in section 14.2.1.1 of the IBA.
*****************************************************************************
*/
struct ib_smp_lr_hdr {
uint64_t mkey;
uint8_t reserved[32];
} __attribute__ (( packed ));
/** A directed route SMP header
/** A subnet management header
*
* Defined in section 14.2.1.2 of the IBA.
* Defined in sections 14.2.1.1 and 14.2.1.2 of the IBA.
*/
struct ib_smp_dr_hdr {
struct ib_smp_hdr {
uint64_t mkey;
uint16_t slid;
uint16_t dlid;
uint8_t reserved[28];
} __attribute__ (( packed ));
/** A subnet management header */
union ib_smp_hdr {
uint64_t mkey;
struct ib_smp_lr_hdr lr;
struct ib_smp_dr_hdr dr;
} __attribute__ (( packed ));
/** Subnet management class version */
#define IB_SMP_CLASS_VERSION 1
@@ -242,17 +183,24 @@ union ib_smp_data {
/** A subnet management directed route path */
struct ib_smp_dr_path {
uint8_t reserved;
uint8_t hops[63];
uint8_t hops[64];
} __attribute__ (( packed ));
/** A subnet management MAD */
struct ib_mad_smp {
struct ib_mad_hdr mad_hdr;
union ib_smp_hdr smp_hdr;
union ib_smp_data smp_data;
struct ib_smp_dr_path initial_path;
struct ib_smp_dr_path return_path;
/** Subnet management MAD class-specific data */
struct ib_smp_class_specific {
uint8_t hop_pointer;
uint8_t hop_count;
} __attribute__ (( packed ));
/*****************************************************************************
*
* Subnet administration MADs
*
*****************************************************************************
*/
struct ib_rmpp_hdr {
uint32_t raw[3];
} __attribute__ (( packed ));
struct ib_sa_hdr {
@@ -262,14 +210,10 @@ struct ib_sa_hdr {
uint32_t comp_mask[2];
} __attribute__ (( packed ));
struct ib_rmpp_hdr {
uint32_t raw[3];
} __attribute__ (( packed ));
#define IB_SA_ATTR_MC_MEMBER_REC 0x38
#define IB_SA_ATTR_PATH_REC 0x35
struct ib_mad_path_record {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
struct ib_sa_hdr sa_hdr;
struct ib_path_record {
uint32_t reserved0[2];
struct ib_gid dgid;
struct ib_gid sgid;
@@ -285,10 +229,10 @@ struct ib_mad_path_record {
uint32_t reserved2[35];
} __attribute__ (( packed ));
struct ib_mad_mc_member_record {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
struct ib_sa_hdr sa_hdr;
#define IB_SA_PATH_REC_DGID (1<<2)
#define IB_SA_PATH_REC_SGID (1<<3)
struct ib_mc_member_record {
struct ib_gid mgid;
struct ib_gid port_gid;
uint32_t qkey;
@@ -305,9 +249,6 @@ struct ib_mad_mc_member_record {
uint32_t reserved1[37];
} __attribute__ (( packed ));
#define IB_SA_ATTR_MC_MEMBER_REC 0x38
#define IB_SA_ATTR_PATH_REC 0x35
#define IB_SA_MCMEMBER_REC_MGID (1<<0)
#define IB_SA_MCMEMBER_REC_PORT_GID (1<<1)
#define IB_SA_MCMEMBER_REC_QKEY (1<<2)
@@ -327,14 +268,96 @@ struct ib_mad_mc_member_record {
#define IB_SA_MCMEMBER_REC_JOIN_STATE (1<<16)
#define IB_SA_MCMEMBER_REC_PROXY_JOIN (1<<17)
#define IB_SA_PATH_REC_DGID (1<<2)
#define IB_SA_PATH_REC_SGID (1<<3)
union ib_sa_data {
struct ib_path_record path_record;
struct ib_mc_member_record mc_member_record;
} __attribute__ (( packed ));
/*****************************************************************************
*
* MADs
*
*****************************************************************************
*/
/** Management datagram class_specific data */
union ib_mad_class_specific {
uint16_t raw;
struct ib_smp_class_specific smp;
} __attribute__ (( packed ));
/** A management datagram common header
*
* Defined in section 13.4.2 of the IBA.
*/
struct ib_mad_hdr {
uint8_t base_version;
uint8_t mgmt_class;
uint8_t class_version;
uint8_t method;
uint16_t status;
union ib_mad_class_specific class_specific;
uint32_t tid[2];
uint16_t attr_id;
uint8_t reserved[2];
uint32_t attr_mod;
} __attribute__ (( packed ));
/* Management base version */
#define IB_MGMT_BASE_VERSION 1
/* 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
#define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30
#define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F
/* 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
#define IB_MGMT_METHOD_DELETE 0x15
/* Status codes */
#define IB_MGMT_STATUS_OK 0x0000
#define IB_MGMT_STATUS_BAD_VERSION 0x0001
#define IB_MGMT_STATUS_UNSUPPORTED_METHOD 0x0002
#define IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR 0x0003
#define IB_MGMT_STATUS_INVALID_VALUE 0x0004
/** A subnet management MAD */
struct ib_mad_smp {
struct ib_mad_hdr mad_hdr;
struct ib_smp_hdr smp_hdr;
union ib_smp_data smp_data;
struct ib_smp_dr_path initial_path;
struct ib_smp_dr_path return_path;
} __attribute__ (( packed ));
/** A subnet administration MAD */
struct ib_mad_sa {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
struct ib_sa_hdr sa_hdr;
union ib_sa_data sa_data;
} __attribute__ (( packed ));
/** A management datagram */
union ib_mad {
struct ib_mad_hdr hdr;
struct ib_mad_smp smp;
struct ib_mad_path_record path_record;
struct ib_mad_mc_member_record mc_member_record;
struct ib_mad_sa sa;
uint8_t bytes[256];
} __attribute__ (( packed ));