On Thu, 17 Sep 2009 23:09:22 -0700 "Sean Hefty" <[email protected]> wrote:
> >Although not a fit IMO, the pragmatic solution is to move ib_types,h into > >libibumad. I think it is better there than OpenSM which was never quite right > >either. That can at least start to eliminate the duplications in this area. > > ib_types.h includes complib header files... > Rough hack. Does windows have stdint.h, byteswap.h, and endian.h? To do this right I would remove the "IN" and "OUT" stuff. Ira From: Ira Weiny <[email protected]> Date: Fri, 18 Sep 2009 14:29:12 -0700 Subject: [PATCH] Quick hack... Remove CL compatiblity from ib_types.h use stdint.h convert boolean_t typedef int boolean_t FALSE == 0 TRUE == 1 use byteswap.h and endian.h and Copy byte swap macros define "IN", "OUT", and "OPTIONAL" Signed-off-by: Ira Weiny <[email protected]> --- opensm/include/iba/ib_types.h | 277 ++++++++++++++++++++++++++-------------- 1 files changed, 180 insertions(+), 97 deletions(-) diff --git a/opensm/include/iba/ib_types.h b/opensm/include/iba/ib_types.h index c9d81cb..c0ce5cd 100644 --- a/opensm/include/iba/ib_types.h +++ b/opensm/include/iba/ib_types.h @@ -38,8 +38,9 @@ #define __IB_TYPES_H__ #include <string.h> -#include <complib/cl_types.h> -#include <complib/cl_byteswap.h> +#include <stdint.h> +#include <byteswap.h> +#include <endian.h> #ifdef __cplusplus # define BEGIN_C_DECLS extern "C" { @@ -49,6 +50,88 @@ # define END_C_DECLS #endif /* __cplusplus */ +/** ========================================================================= + * complib stuff + */ +#ifndef IN +#define IN /* Function input parameter */ +#endif +#ifndef OUT +#define OUT /* Function output parameter */ +#endif +#ifndef OPTIONAL +#define OPTIONAL /* Optional function parameter - NULL if not used */ +#endif + +#ifndef __BYTE_ORDER +#error "__BYTE_ORDER macro undefined. Missing in endian.h?" +#endif + +/* 16bit */ +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define CL_NTOH16( x ) (uint16_t)( \ + (((uint16_t)(x) & 0x00FF) << 8) | \ + (((uint16_t)(x) & 0xFF00) >> 8) ) +#else +#define CL_NTOH16( x ) (x) +#endif +#define CL_HTON16 CL_NTOH16 + +/* 32bit */ +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define CL_NTOH32( x ) (uint32_t)( \ + (((uint32_t)(x) & 0x000000FF) << 24) | \ + (((uint32_t)(x) & 0x0000FF00) << 8) | \ + (((uint32_t)(x) & 0x00FF0000) >> 8) | \ + (((uint32_t)(x) & 0xFF000000) >> 24) ) +#else +#define CL_NTOH32( x ) (x) +#endif +#define CL_HTON32 CL_NTOH32 + +/* 64bit */ +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define CL_NTOH64( x ) (uint64_t)( \ + (((uint64_t)(x) & 0x00000000000000FFULL) << 56) | \ + (((uint64_t)(x) & 0x000000000000FF00ULL) << 40) | \ + (((uint64_t)(x) & 0x0000000000FF0000ULL) << 24) | \ + (((uint64_t)(x) & 0x00000000FF000000ULL) << 8 ) | \ + (((uint64_t)(x) & 0x000000FF00000000ULL) >> 8 ) | \ + (((uint64_t)(x) & 0x0000FF0000000000ULL) >> 24) | \ + (((uint64_t)(x) & 0x00FF000000000000ULL) >> 40) | \ + (((uint64_t)(x) & 0xFF00000000000000ULL) >> 56) ) +#else +#define CL_NTOH64( x ) (x) +#endif +#define CL_HTON64 CL_NTOH64 + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define cl_ntoh16(x) bswap_16(x) +#define cl_hton16(x) bswap_16(x) +#define cl_ntoh32(x) bswap_32(x) +#define cl_hton32(x) bswap_32(x) +#define cl_ntoh64(x) (uint64_t)bswap_64(x) +#define cl_hton64(x) (uint64_t)bswap_64(x) +#else /* Big Endian */ +#define cl_ntoh16(x) (x) +#define cl_hton16(x) (x) +#define cl_ntoh32(x) (x) +#define cl_hton32(x) (x) +#define cl_ntoh64(x) (x) +#define cl_hton64(x) (x) +#endif + +#if defined (_DEBUG_) +#include <assert.h> +#define CL_ASSERT assert +#else /* _DEBUG_ */ +#define CL_ASSERT( __exp__ ) +#endif /* _DEBUG_ */ + +/** ========================================================================= + * end complib stuff + */ + BEGIN_C_DECLS #if defined( WIN32 ) || defined( _WIN64 ) #if defined( EXPORT_AL_SYMBOLS ) @@ -564,7 +647,7 @@ BEGIN_C_DECLS * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_class_is_vendor_specific_low(IN const uint8_t class_code) { return ((class_code >= IB_MCLASS_VENDOR_LOW_RANGE_MIN) && @@ -577,8 +660,8 @@ ib_class_is_vendor_specific_low(IN const uint8_t class_code) * [in] The Management Datagram Class Code * * RETURN VALUE -* TRUE if the class is in the Low range of Vendor Specific MADs -* FALSE otherwise. +* 1 if the class is in the Low range of Vendor Specific MADs +* 0 otherwise. * * NOTES * @@ -596,7 +679,7 @@ ib_class_is_vendor_specific_low(IN const uint8_t class_code) * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_class_is_vendor_specific_high(IN const uint8_t class_code) { return ((class_code >= IB_MCLASS_VENDOR_HIGH_RANGE_MIN) && @@ -609,8 +692,8 @@ ib_class_is_vendor_specific_high(IN const uint8_t class_code) * [in] The Management Datagram Class Code * * RETURN VALUE -* TRUE if the class is in the High range of Vendor Specific MADs -* FALSE otherwise. +* 1 if the class is in the High range of Vendor Specific MADs +* 0 otherwise. * * NOTES * @@ -627,7 +710,7 @@ ib_class_is_vendor_specific_high(IN const uint8_t class_code) * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_class_is_vendor_specific(IN const uint8_t class_code) { return (ib_class_is_vendor_specific_low(class_code) || @@ -640,8 +723,8 @@ ib_class_is_vendor_specific(IN const uint8_t class_code) * [in] The Management Datagram Class Code * * RETURN VALUE -* TRUE if the class is a Vendor Specific MAD -* FALSE otherwise. +* 1 if the class is a Vendor Specific MAD +* 0 otherwise. * * NOTES * @@ -658,7 +741,7 @@ ib_class_is_vendor_specific(IN const uint8_t class_code) * * SYNOPSIS */ -static inline boolean_t OSM_API ib_class_is_rmpp(IN const uint8_t class_code) +static inline int OSM_API ib_class_is_rmpp(IN const uint8_t class_code) { return ((class_code == IB_MCLASS_SUBN_ADM) || (class_code == IB_MCLASS_DEV_MGMT) || @@ -673,8 +756,8 @@ static inline boolean_t OSM_API ib_class_is_rmpp(IN const uint8_t class_code) * [in] The Management Datagram Class Code * * RETURN VALUE -* TRUE if the class supports RMPP -* FALSE otherwise. +* 1 if the class supports RMPP +* 0 otherwise. * * NOTES * @@ -2077,7 +2160,7 @@ static inline ib_net16_t OSM_API ib_pkey_get_base(IN const ib_net16_t pkey) * * SYNOPSIS */ -static inline boolean_t OSM_API ib_pkey_is_full_member(IN const ib_net16_t pkey) +static inline int OSM_API ib_pkey_is_full_member(IN const ib_net16_t pkey) { return ((pkey & IB_PKEY_TYPE_MASK) == IB_PKEY_TYPE_MASK); } @@ -2088,8 +2171,8 @@ static inline boolean_t OSM_API ib_pkey_is_full_member(IN const ib_net16_t pkey) * [in] P_Key value * * RETURN VALUE -* TRUE if the port is a full member of the partition. -* FALSE otherwise. +* 1 if the port is a full member of the partition. +* 0 otherwise. * * NOTES * @@ -2102,15 +2185,15 @@ static inline boolean_t OSM_API ib_pkey_is_full_member(IN const ib_net16_t pkey) * ib_pkey_is_invalid * * DESCRIPTION -* Returns TRUE if the given P_Key is an invalid P_Key +* Returns 1 if the given P_Key is an invalid P_Key * C10-116: the CI shall regard a P_Key as invalid if its low-order * 15 bits are all zero... * * SYNOPSIS */ -static inline boolean_t OSM_API ib_pkey_is_invalid(IN const ib_net16_t pkey) +static inline int OSM_API ib_pkey_is_invalid(IN const ib_net16_t pkey) { - return ib_pkey_get_base(pkey) == 0x0000 ? TRUE : FALSE; + return ib_pkey_get_base(pkey) == 0x0000 ? 1 : 0; } /* @@ -2167,11 +2250,11 @@ typedef union _ib_gid { * ib_gid_is_multicast * * DESCRIPTION -* Returns a boolean indicating whether a GID is a multicast GID. +* Returns a int indicating whether a GID is a multicast GID. * * SYNOPSIS */ -static inline boolean_t OSM_API ib_gid_is_multicast(IN const ib_gid_t * p_gid) +static inline int OSM_API ib_gid_is_multicast(IN const ib_gid_t * p_gid) { return (p_gid->raw[0] == 0xFF); } @@ -2273,12 +2356,12 @@ ib_gid_get_subnet_prefix(IN const ib_gid_t * const p_gid) * ib_gid_is_link_local * * DESCRIPTION -* Returns TRUE if the unicast GID scoping indicates link local, -* FALSE otherwise. +* Returns 1 if the unicast GID scoping indicates link local, +* 0 otherwise. * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_gid_is_link_local(IN const ib_gid_t * const p_gid) { return ((ib_gid_get_subnet_prefix(p_gid) & @@ -2291,8 +2374,8 @@ ib_gid_is_link_local(IN const ib_gid_t * const p_gid) * [in] Pointer to the GID object. * * RETURN VALUES -* Returns TRUE if the unicast GID scoping indicates link local, -* FALSE otherwise. +* Returns 1 if the unicast GID scoping indicates link local, +* 0 otherwise. * * NOTES * @@ -2305,12 +2388,12 @@ ib_gid_is_link_local(IN const ib_gid_t * const p_gid) * ib_gid_is_site_local * * DESCRIPTION -* Returns TRUE if the unicast GID scoping indicates site local, -* FALSE otherwise. +* Returns 1 if the unicast GID scoping indicates site local, +* 0 otherwise. * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_gid_is_site_local(IN const ib_gid_t * const p_gid) { return ((ib_gid_get_subnet_prefix(p_gid) & @@ -2324,8 +2407,8 @@ ib_gid_is_site_local(IN const ib_gid_t * const p_gid) * [in] Pointer to the GID object. * * RETURN VALUES -* Returns TRUE if the unicast GID scoping indicates site local, -* FALSE otherwise. +* Returns 1 if the unicast GID scoping indicates site local, +* 0 otherwise. * * NOTES * @@ -3779,13 +3862,13 @@ ib_mad_init_response(IN const ib_mad_t * const p_req_mad, * ib_mad_is_response * * DESCRIPTION -* Returns TRUE if the MAD is a response ('R' bit set) +* Returns 1 if the MAD is a response ('R' bit set) * or if the MAD is a TRAP REPRESS, -* FALSE otherwise. +* 0 otherwise. * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_mad_is_response(IN const ib_mad_t * const p_mad) { CL_ASSERT(p_mad); @@ -3799,8 +3882,8 @@ ib_mad_is_response(IN const ib_mad_t * const p_mad) * [in] Pointer to the MAD. * * RETURN VALUES -* Returns TRUE if the MAD is a response ('R' bit set), -* FALSE otherwise. +* Returns 1 if the MAD is a response ('R' bit set), +* 0 otherwise. * * NOTES * @@ -3836,11 +3919,11 @@ ib_mad_is_response(IN const ib_mad_t * const p_mad) * ib_rmpp_is_flag_set * * DESCRIPTION -* Returns TRUE if the MAD has the given RMPP flag set. +* Returns 1 if the MAD has the given RMPP flag set. * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_rmpp_is_flag_set(IN const ib_rmpp_mad_t * const p_rmpp_mad, IN const uint8_t flag) { @@ -3857,7 +3940,7 @@ ib_rmpp_is_flag_set(IN const ib_rmpp_mad_t * const p_rmpp_mad, * [in] The RMPP flag being examined. * * RETURN VALUES -* Returns TRUE if the MAD has the given RMPP flag set. +* Returns 1 if the MAD has the given RMPP flag set. * * NOTES * @@ -4031,11 +4114,11 @@ ib_smp_get_status(IN const ib_smp_t * const p_smp) * ib_smp_is_response * * DESCRIPTION -* Returns TRUE if the SMP is a response MAD, FALSE otherwise. +* Returns 1 if the SMP is a response MAD, 0 otherwise. * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_smp_is_response(IN const ib_smp_t * const p_smp) { return (ib_mad_is_response((const ib_mad_t *)p_smp)); @@ -4047,7 +4130,7 @@ ib_smp_is_response(IN const ib_smp_t * const p_smp) * [in] Pointer to the SMP packet. * * RETURN VALUES -* Returns TRUE if the SMP is a response MAD, FALSE otherwise. +* Returns 1 if the SMP is a response MAD, 0 otherwise. * * NOTES * @@ -4060,11 +4143,11 @@ ib_smp_is_response(IN const ib_smp_t * const p_smp) * ib_smp_is_d * * DESCRIPTION -* Returns TRUE if the SMP 'D' (direction) bit is set. +* Returns 1 if the SMP 'D' (direction) bit is set. * * SYNOPSIS */ -static inline boolean_t OSM_API ib_smp_is_d(IN const ib_smp_t * const p_smp) +static inline int OSM_API ib_smp_is_d(IN const ib_smp_t * const p_smp) { return ((p_smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION); } @@ -4075,7 +4158,7 @@ static inline boolean_t OSM_API ib_smp_is_d(IN const ib_smp_t * const p_smp) * [in] Pointer to the SMP packet. * * RETURN VALUES -* Returns TRUE if the SMP 'D' (direction) bit is set. +* Returns 1 if the SMP 'D' (direction) bit is set. * * NOTES * @@ -4306,7 +4389,7 @@ ib_sa_mad_get_payload_ptr(IN const ib_sa_mad_t * const p_sa_mad) #define IB_NODE_INFO_PORT_NUM_MASK (CL_HTON32(0xFF000000)) #define IB_NODE_INFO_VEND_ID_MASK (CL_HTON32(0x00FFFFFF)) -#if CPU_LE +#if __BYTE_ORDER == __LITTLE_ENDIAN #define IB_NODE_INFO_PORT_NUM_SHIFT 0 #else #define IB_NODE_INFO_PORT_NUM_SHIFT 24 @@ -5924,7 +6007,7 @@ typedef struct _ib_switch_info_record { * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_switch_info_get_state_change(IN const ib_switch_info_t * const p_si) { return ((p_si->life_state & IB_SWITCH_PSC) == IB_SWITCH_PSC); @@ -5980,7 +6063,7 @@ ib_switch_info_clear_state_change(IN ib_switch_info_t * const p_si) * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_switch_info_get_opt_sl2vlmapping(IN const ib_switch_info_t * const p_si) { return ((p_si->life_state & 0x01) == 0x01); @@ -6004,13 +6087,13 @@ ib_switch_info_get_opt_sl2vlmapping(IN const ib_switch_info_t * const p_si) * ib_switch_info_is_enhanced_port0 * * DESCRIPTION -* Returns TRUE if the enhancedPort0 bit is on (meaning the switch +* Returns 1 if the enhancedPort0 bit is on (meaning the switch * port zero supports enhanced functions). -* Returns FALSE otherwise. +* Returns 0 otherwise. * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_switch_info_is_enhanced_port0(IN const ib_switch_info_t * const p_si) { return ((p_si->flags & 0x08) == 0x08); @@ -6022,7 +6105,7 @@ ib_switch_info_is_enhanced_port0(IN const ib_switch_info_t * const p_si) * [in] Pointer to a SwitchInfo attribute. * * RETURN VALUES -* Returns TRUE if the switch supports enhanced port 0. FALSE otherwise. +* Returns 1 if the switch supports enhanced port 0. 0 otherwise. * * NOTES * @@ -7257,7 +7340,7 @@ typedef struct _ib_mad_notice_attr // Total Size calc Accumulated * * SYNOPSIS */ -static inline boolean_t OSM_API +static inline int OSM_API ib_notice_is_generic(IN const ib_mad_notice_attr_t * p_ntc) { return (p_ntc->generic_type & 0x80); @@ -7269,7 +7352,7 @@ ib_notice_is_generic(IN const ib_mad_notice_attr_t * p_ntc) * [in] Pointer to the notice MAD attribute * * RETURN VALUES -* TRUE if mad is generic +* 1 if mad is generic * * SEE ALSO * ib_mad_notice_attr_t @@ -7296,7 +7379,7 @@ ib_notice_get_type(IN const ib_mad_notice_attr_t * p_ntc) * [in] Pointer to the notice MAD attribute * * RETURN VALUES -* TRUE if mad is generic +* 1 if mad is generic * * SEE ALSO * ib_mad_notice_attr_t @@ -8687,27 +8770,27 @@ typedef enum _ib_atomic_t { * SYNOPSIS */ typedef struct _ib_port_cap { - boolean_t cm; - boolean_t snmp; - boolean_t dev_mgmt; - boolean_t vend; - boolean_t sm; - boolean_t sm_disable; - boolean_t qkey_ctr; - boolean_t pkey_ctr; - boolean_t notice; - boolean_t trap; - boolean_t apm; - boolean_t slmap; - boolean_t pkey_nvram; - boolean_t mkey_nvram; - boolean_t sysguid; - boolean_t dr_notice; - boolean_t boot_mgmt; - boolean_t capm_notice; - boolean_t reinit; - boolean_t ledinfo; - boolean_t port_active; + int cm; + int snmp; + int dev_mgmt; + int vend; + int sm; + int sm_disable; + int qkey_ctr; + int pkey_ctr; + int notice; + int trap; + int apm; + int slmap; + int pkey_nvram; + int mkey_nvram; + int sysguid; + int dr_notice; + int boot_mgmt; + int capm_notice; + int reinit; + int ledinfo; + int port_active; } ib_port_cap_t; /*****/ @@ -8858,19 +8941,19 @@ typedef struct _ib_ca_attr { * timeout = 4.096 microseconds * 2^local_ack_delay */ uint8_t local_ack_delay; - boolean_t bad_pkey_ctr_support; - boolean_t bad_qkey_ctr_support; - boolean_t raw_mcast_support; - boolean_t apm_support; - boolean_t av_port_check; - boolean_t change_primary_port; - boolean_t modify_wr_depth; - boolean_t current_qp_state_support; - boolean_t shutdown_port_capability; - boolean_t init_type_support; - boolean_t port_active_event_support; - boolean_t system_image_guid_support; - boolean_t hw_agents; + int bad_pkey_ctr_support; + int bad_qkey_ctr_support; + int raw_mcast_support; + int apm_support; + int av_port_check; + int change_primary_port; + int modify_wr_depth; + int current_qp_state_support; + int shutdown_port_capability; + int init_type_support; + int port_active_event_support; + int system_image_guid_support; + int hw_agents; ib_net64_t system_image_guid; uint32_t num_page_sizes; uint8_t num_ports; @@ -9091,7 +9174,7 @@ typedef struct _ib_av_attr { uint8_t port_num; uint8_t sl; ib_net16_t dlid; - boolean_t grh_valid; + int grh_valid; ib_grh_t grh; uint8_t static_rate; uint8_t path_bits; @@ -9252,7 +9335,7 @@ typedef struct _ib_qp_create { uint32_t rq_sge; ib_cq_handle_t h_sq_cq; ib_cq_handle_t h_rq_cq; - boolean_t sq_signaled; + int sq_signaled; } ib_qp_create_t; /* * FIELDS @@ -9301,8 +9384,8 @@ typedef struct _ib_qp_create { * sq_signaled * A flag that is used to indicate whether the queue pair will signal * an event upon completion of a send work request. If set to -* TRUE, send work requests will always generate a completion -* event. If set to FALSE, a completion event will only be +* 1, send work requests will always generate a completion +* event. If set to 0, a completion event will only be * generated if the send_opt field of the send work request has the * IB_SEND_OPT_SIGNALED flag set. * @@ -9333,7 +9416,7 @@ typedef struct _ib_qp_attr { ib_cq_handle_t h_sq_cq; ib_cq_handle_t h_rq_cq; ib_rdd_handle_t h_rdd; - boolean_t sq_signaled; + int sq_signaled; ib_qp_state_t state; ib_net32_t num; ib_net32_t dest_num; @@ -9452,7 +9535,7 @@ typedef struct _ib_qp_mod { uint16_t pkey_index; } rts; struct _qp_sqd { - boolean_t sqd_event; + int sqd_event; } sqd; } state; } ib_qp_mod_t; @@ -9555,7 +9638,7 @@ typedef struct _ib_eec_mod { uint8_t primary_port; } rts; struct _eec_sqd { - boolean_t sqd_event; + int sqd_event; } sqd; } state; } ib_eec_mod_t; -- 1.5.4.5 _______________________________________________ ofw mailing list [email protected] http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw
