#ifndef _SYS_IB_MGT_IB_MAD_H
#define _SYS_IB_MGT_IB_MAD_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/ib/ib_types.h>
#define MAD_SIZE_IN_BYTES 256
typedef struct _ib_mad_hdr_t {
uint8_t BaseVersion;
uint8_t MgmtClass;
uint8_t ClassVersion;
uint8_t R_Method;
uint16_t Status;
uint16_t ClassSpecific;
uint64_t TransactionID;
uint16_t AttributeID;
uint16_t Reserved;
uint32_t AttributeModifier;
} ib_mad_hdr_t;
#define MAD_CLASS_BASE_VERS_1 1
#define MAD_MGMT_CLASS_SUBN_LID_ROUTED 0x01
#define MAD_MGMT_CLASS_SUBN_DIRECT_ROUTE 0x81
#define MAD_MGMT_CLASS_SUBN_ADM 0x03
#define MAD_MGMT_CLASS_PERF 0x04
#define MAD_MGMT_CLASS_BM 0x05
#define MAD_MGMT_CLASS_DEV_MGT 0x06
#define MAD_MGMT_CLASS_COMM_MGT 0x07
#define MAD_MGMT_CLASS_SNMP 0x08
#define MAD_MGMT_CLASS_VENDOR_START 0x09
#define MAD_MGMT_CLASS_VENDOR_END 0x0F
#define MAD_MGMT_CLASS_VENDOR2_START 0x30
#define MAD_MGMT_CLASS_VENDOR2_END 0x4F
#define MAD_MGMT_CLASS_APPLICATION_START 0x10
#define MAD_MGMT_CLASS_APPLICATION_END 0x2F
#define MAD_RESPONSE_BIT 0x80
#define MAD_RESPONSE_BIT_MASK 0x80
#define MAD_METHOD_MASK 0x7F
#define MAD_METHOD_GET 0x01
#define MAD_METHOD_SET 0x02
#define MAD_METHOD_GET_RESPONSE 0x81
#define MAD_METHOD_SEND 0x03
#define MAD_METHOD_TRAP 0x05
#define MAD_METHOD_REPORT 0x06
#define MAD_METHOD_REPORT_RESPONSE 0x86
#define MAD_METHOD_TRAP_REPRESS 0x07
#define MAD_STATUS_BUSY 0x01
#define MAD_STATUS_REDIRECT_REQUIRED 0x02
#define MAD_STATUS_NO_INVALID_FIELDS 0x00
#define MAD_STATUS_BAD_VERSION 0x04
#define MAD_STATUS_UNSUPP_METHOD 0x08
#define MAD_STATUS_UNSUPP_METHOD_ATTR 0x0C
#define MAD_STATUS_INVALID_FIELD 0x1C
#define MAD_ATTR_ID_CLASSPORTINFO 0x01
#define MAD_ATTR_ID_NOTICE 0x02
#define MAD_ATTR_ID_INFORMINFO 0x03
#if defined(_BIT_FIELDS_HTOL)
typedef struct ib_mad_classportinfo_s {
uint8_t BaseVersion;
uint8_t ClassVersion;
uint16_t CapabilityMask;
uint32_t RespTimeValue;
uint64_t RedirectGID_hi;
uint64_t RedirectGID_lo;
uint32_t RedirectTC :8;
uint32_t RedirectSL :4;
uint32_t RedirectFL :20;
ib_lid_t RedirectLID;
ib_pkey_t RedirectP_Key;
uint32_t Reserved2 :8;
uint32_t RedirectQP :24;
ib_qkey_t RedirectQ_Key;
uint64_t TrapGID_hi;
uint64_t TrapGID_lo;
uint32_t TrapTC :8;
uint32_t TrapSL :4;
uint32_t TrapFL :20;
ib_lid_t TrapLID;
ib_pkey_t TrapP_Key;
uint32_t TrapHL :8;
uint32_t TrapQP :24;
ib_qkey_t TrapQ_Key;
} ib_mad_classportinfo_t;
#elif defined(_BIT_FIELDS_LTOH)
typedef struct ib_mad_classportinfo_s {
uint8_t BaseVersion;
uint8_t ClassVersion;
uint16_t CapabilityMask;
uint32_t RespTimeValue;
uint64_t RedirectGID_hi;
uint64_t RedirectGID_lo;
uint32_t RedirectFL :20;
uint32_t RedirectSL :4;
uint32_t RedirectTC :8;
ib_lid_t RedirectLID;
ib_pkey_t RedirectP_Key;
uint32_t RedirectQP :24;
uint32_t Reserved2 :8;
ib_qkey_t RedirectQ_Key;
uint64_t TrapGID_hi;
uint64_t TrapGID_lo;
uint32_t TrapFL :20;
uint32_t TrapSL :4;
uint32_t TrapTC :8;
ib_lid_t TrapLID;
ib_pkey_t TrapP_Key;
uint32_t TrapQP :24;
uint32_t TrapHL :8;
ib_qkey_t TrapQ_Key;
} ib_mad_classportinfo_t;
#else
#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
#endif
#define MAD_CLASSPORTINFO_CAP_MASK_TRAPS 0x01
#define MAD_CLASSPORTINFO_CAP_MASK_NOTICES 0x02
#if defined(_BIT_FIELDS_HTOL)
typedef struct ib_mad_notice_s {
uint32_t IsGeneric :1;
uint32_t Type :7;
uint32_t ProducerType_VendorID:24;
uint16_t TrapNumber_DeviceID;
uint16_t IssuerLID;
uint16_t NoticeToggle :1;
uint16_t NoticeCount :15;
uint8_t DataDetails[54];
ib_gid_t IssuerGID;
} ib_mad_notice_t;
#elif defined(_BIT_FIELDS_LTOH)
typedef struct ib_mad_notice_s {
uint32_t ProducerType_VendorID:24;
uint32_t Type :7;
uint32_t IsGeneric :1;
uint16_t TrapNumber_DeviceID;
uint16_t IssuerLID;
uint16_t NoticeCount :15;
uint16_t NoticeToggle :1;
uint8_t DataDetails[54];
ib_gid_t IssuerGID;
} ib_mad_notice_t;
#else
#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
#endif
#define MAD_NOTICE_IS_GENERIC 0x1
#define MAD_NOTICE_TYPE_FATAL 0x0
#define MAD_NOTICE_TYPE_URGENT 0x1
#define MAD_NOTICE_TYPE_SECURITY 0x2
#define MAD_NOTICE_TYPE_SUBNET_MGMT 0x3
#define MAD_NOTICE_TYPE_INFO 0x4
#define MAD_NOTICE_NODETYPE_CA 0x1
#define MAD_NOTICE_NODETYPE_SWITCH 0x2
#define MAD_NOTICE_NODETYPE_ROUTER 0x3
#define MAD_NOTICE_NODETYPE_SUBNET_MANAGEMENT 0x4
#define MAD_NOTICE_TRAP_NUMBER_RESERVED 0xFFFF
#if defined(_BIT_FIELDS_HTOL)
typedef struct ib_mad_informinfo_s {
ib_gid_t GID;
ib_lid_t LIDRangeBegin;
ib_lid_t LIDRangeEnd;
uint16_t Reserved;
uint8_t IsGeneric;
uint8_t Subscribe;
uint16_t Type;
uint16_t TrapNumber_DeviceID;
uint32_t QPN :24;
uint32_t Reserved2 :3;
uint32_t RespTimeValue :5;
uint32_t Reserved3 :8;
uint32_t ProducerType_VendorID:24;
} ib_mad_informinfo_t;
#elif defined(_BIT_FIELDS_LTOH)
typedef struct ib_mad_informinfo_s {
ib_gid_t GID;
ib_lid_t LIDRangeBegin;
ib_lid_t LIDRangeEnd;
uint16_t Reserved;
uint8_t IsGeneric;
uint8_t Subscribe;
uint16_t Type;
uint16_t TrapNumber_DeviceID;
uint32_t RespTimeValue :5;
uint32_t Reserved2 :3;
uint32_t QPN :24;
uint32_t ProducerType_VendorID:24;
uint32_t Reserved3 :8;
} ib_mad_informinfo_t;
#else
#error One of _BIT_FIELDS_HTOL or _BIT_FIELDS_LTOH must be defined
#endif
#define MAD_INFORMINFO_ALL_ENDPORTS_RANGE 0xFFFF
#define MAD_INFORMINFO_FORWARD_GENERIC 0x1
#define MAD_INFORMINFO_FORWARD_VENDOR_SPECIFIC 0x0
#define MAD_INFORMINFO_SUBSCRIBE 0x1
#define MAD_INFORMINFO_UNSUBSCRIBE 0x0
#define MAD_INFORMINFO_TRAP_NUMBER_FORWARD_ALL 0xFFFF
#define MAD_INFORMINFO_TRAP_TYPE_FATAL 0x0
#define MAD_INFORMINFO_TRAP_TYPE_URGENT 0x1
#define MAD_INFORMINFO_TRAP_TYPE_SECURITY 0x2
#define MAD_INFORMINFO_TRAP_TYPE_SUBNET_MGMT 0x3
#define MAD_INFORMINFO_TRAP_TYPE_INFORM 0x4
#define MAD_INFORMINFO_TRAP_TYPE_FORWARD_ALL 0xFFFF
#define MAD_INFORMINFO_NODETYPE_CA 0x1
#define MAD_INFORMINFO_NODETYPE_SWITCH 0x2
#define MAD_INFORMINFO_NODETYPE_ROUTER 0x3
#define MAD_INFORMINFO_NODETYPE_SUBNET_MANAGEMENT 0x4
#ifdef __cplusplus
}
#endif
#endif