Main Page | Modules | Directories | File List | Globals | Related Pages

gm.h

Go to the documentation of this file.
00001 /******************************************************************-*-c-*-
00002  * Myricom GM networking software and documentation                      *
00003  * Copyright (c) 1999 by Myricom, Inc.                                   *
00004  * All rights reserved.  See the file `COPYING' for copyright notice.    *
00005  *************************************************************************/
00006 
00014 #ifndef _gm_h_
00015 #define _gm_h_
00016 
00017 /* This file includes the minimum amount needed to support the GM API.
00018    It should not include any other header file or depend on any macro
00019    definitions that are not automatically set by the compiler. */
00020 
00021 /************************************************************************
00022  * Begin Prologue
00023  ************************************************************************/
00024 
00025 #ifdef  __cplusplus
00026 extern "C"
00027 {
00028 #if 0
00029 }                               /* indent hack */
00030 #endif
00031 #endif
00032 
00033 #if GM_BUILDING_FIRMWARE
00034 #include "gm_config.h"
00035 #else
00036 /* There must be no includes for user (a.k.a.: "GM client") compilations. */
00037 #endif
00038 
00039 /************************************************************************
00040  * End Prologue
00041  ************************************************************************/
00042 
00046 #define GM_API_VERSION_1_0 0x100
00047 
00048 #define GM_API_VERSION_1_1 0x101
00049 
00050 #define GM_API_VERSION_1_2 0x102
00051 
00052 #define GM_API_VERSION_1_3 0x103
00053 
00054 #define GM_API_VERSION_1_4 0x104
00055 
00056 #define GM_API_VERSION_1_5 0x105
00057 
00058 #define GM_API_VERSION_1_6 0x106
00059 
00062 #ifndef GM_API_VERSION
00063 #define GM_API_VERSION GM_API_VERSION_1_6
00064 #endif
00065 
00066 /* Check that the user has selected an API version compatible with this
00067    header file. */
00068 
00069 #if GM_API_VERSION < GM_API_VERSION_1_0
00070 #error GM_API_VERSION is too small.
00071 #elif GM_API_VERSION > GM_API_VERSION_1_6
00072 #error GM_API_VERSION is too large.
00073 #endif
00074 
00075 /****************************************************************
00076  * Prevent direct access to these functions in GM intself, so that we
00077  * can check for memory leaks.
00078  ****************************************************************/
00079 
00080 #if GM_BUILDING_GM
00081 #include "gm_debug_malloc.h"
00082 #endif
00083 
00086 /****
00087  * Constants
00088  ****/
00089 
00091 #define GM_MAX_HOST_NAME_LEN 128
00092 
00093 #define GM_MAX_PORT_NAME_LEN 32
00094 
00095 #define GM_NO_SUCH_NODE_ID 0
00096 
00097 /************
00098  * Determine CPU based on what compiler is being used.
00099  ************/
00100 
00101 #if GM_CPU_alpha
00102 #  define GM_CPU_DEFINED 1
00103 #elif GM_CPU_lanai
00104 #  define GM_CPU_DEFINED 1
00105 #elif GM_CPU_mips
00106 #  define GM_CPU_DEFINED 1
00107 #elif GM_CPU_powerpc
00108 #  define GM_CPU_DEFINED 1
00109 #elif GM_CPU_sparc
00110 #  define GM_CPU_DEFINED 1
00111 #elif GM_CPU_sparc64
00112 #  define GM_CPU_DEFINED 1
00113 #elif GM_CPU_x86
00114 #  define GM_CPU_DEFINED 1
00115 #elif GM_CPU_hppa
00116 #  define GM_CPU_DEFINED 1
00117 #elif GM_CPU_ia64
00118 #  define GM_CPU_DEFINED 1
00119 #else
00120 #  define GM_CPU_DEFINED 0
00121 #endif
00122 
00123 #if !GM_CPU_DEFINED
00124 #  if defined _MSC_VER          /* Microsoft compiler */
00125 #    if defined _M_IX86
00126 #      define GM_CPU_x86 1
00127 #    elif defined _M_IA64
00128 #      define GM_CPU_ia64 1
00129 #    elif defined _M_ALPHA
00130 #      define GM_CPU_alpha 1
00131 #    else
00132 #      error Could not determine CPU type.  You need to modify gm.h.
00133 #    endif
00134 #  elif defined __APPLE_CC__    /* Apple OSX compiler defines __GNUC__ */
00135 #    if defined __ppc__         /* but doesn't support #cpu syntax     */
00136 #      define GM_CPU_powerpc 1
00137 #    elif define __i386__
00138 #      define GM_CPU_x86 1
00139 #    else
00140 #      error Could not determine CPU type.  You need to modify gm.h.
00141 #    endif
00142 #  elif defined mips
00143 #    define GM_CPU_mips 1
00144 #  elif defined(__GNUC__)
00145 #    if #cpu(alpha)
00146 #      define GM_CPU_alpha 1
00147 #    elif #cpu(hppa)
00148 #      define GM_CPU_hppa 1
00149 #    elif defined lanai
00150 #      define GM_CPU_lanai 1
00151 #    elif defined lanai3
00152 #      define GM_CPU_lanai 1
00153 #    elif defined lanai7
00154 #      define GM_CPU_lanai 1
00155 #    elif defined(powerpc)
00156 #      define GM_CPU_powerpc 1
00157 #    elif defined(_POWER)
00158 #      define GM_CPU_powerpc 1
00159 #    elif defined(_IBMR2)
00160 #      define GM_CPU_powerpc 1
00161 #    elif #cpu(ia64)
00162 #      define GM_CPU_ia64 1
00163 #    elif #cpu(sparc64)
00164 #      define GM_CPU_sparc64 1
00165 #    elif defined sparc
00166 #      define GM_CPU_sparc 1
00167 #    elif defined i386
00168 #      define GM_CPU_x86 1
00169 #    elif defined(CPU)   /* This is how vxWorks defines their CPUs */
00170 #      if (CPU==PPC603)
00171 #        define GM_CPU_powerpc 1
00172 #      elif (CPU==PPC604)
00173 #        define GM_CPU_powerpc 1
00174 #      elif (CPU==PPC405)
00175 #        define GM_CPU_powerpc 1
00176 #      else
00177 #        error Could not determine CPU type.  If this is VxWorks, you will need to modify gm.h to add your cpu type.
00178 #      endif
00179 #    else
00180 #      error Could not determine CPU type.  You need to modify gm.h.
00181 #    endif
00182 #  elif (defined (_POWER) && defined(_AIX))
00183 #      define GM_CPU_powerpc 1
00184 #  elif (defined (__DECC) || defined (__DECCXX)) && defined(__alpha)
00185 #      define GM_CPU_alpha 1
00186 #  elif (defined (__SUNPRO_C) || defined(__SUNPRO_CC)) && (defined(sparc64) || defined(__sparcv9))
00187 #      define GM_CPU_sparc64 1
00188 #  elif (defined (__SUNPRO_C) || defined(__SUNPRO_CC)) && defined(sparc)
00189 #      define GM_CPU_sparc 1
00190 #  elif (defined (__SUNPRO_C) || defined(__SUNPRO_CC)) && defined i386
00191 #      define GM_CPU_x86 1
00192 #  elif defined __PGI 
00193 #      define GM_CPU_x86 1
00194 #  elif defined __linux__       /* Portland Group Compiler */
00195 #    if defined __i386__
00196 #      define GM_CPU_x86 1
00197 #    elif defined __ia64__
00198 #      define GM_CPU_ia64 1
00199 #    else
00200 #      error Could not determine CPU type.  You need to modify gm.h.
00201 #    endif
00202 #  elif defined(__hppa) || defined(_PA_RISC1_1)
00203 #      define GM_CPU_hppa 1
00204 #  else
00205 #    error Could not determine CPU type.  You need to modify gm.h.
00206 #  endif
00207 #  undef GM_CPU_DEFINED
00208 #  define GM_CPU_DEFINED 1
00209 #endif
00210 
00214 #ifndef GM_CPU_alpha
00215 #define GM_CPU_alpha 0
00216 #endif
00217 #ifndef GM_CPU_ia64
00218 #define GM_CPU_ia64 0
00219 #endif
00220 #ifndef GM_CPU_hppa
00221 #define GM_CPU_hppa 0
00222 #endif
00223 #ifndef GM_CPU_lanai
00224 #define GM_CPU_lanai 0
00225 #endif
00226 #ifndef GM_CPU_mips
00227 #define GM_CPU_mips 0
00228 #endif
00229 #ifndef GM_CPU_powerpc
00230 #define GM_CPU_powerpc 0
00231 #endif
00232 #ifndef GM_CPU_sparc
00233 #define GM_CPU_sparc 0
00234 #endif
00235 #ifndef GM_CPU_sparc64
00236 #define GM_CPU_sparc64 0
00237 #endif
00238 #ifndef GM_CPU_x86
00239 #define GM_CPU_x86 0
00240 #endif
00241 
00242 /************
00243  * Enable inlining if and only if we know it won't crash the compiler.
00244  ************/
00245 
00246 
00247 #ifndef gm_inline
00248 #  if defined _MSC_VER
00249 #    define gm_inline __inline
00250 #  elif defined __GNUC__
00251 #    define gm_inline __inline__
00252 #  elif GM_CPU_mips
00253 #    define gm_inline __inline
00254 #    define inline __inline
00255 #  elif defined __DECC
00256 #    define gm_inline __inline
00257 #  elif defined __DECCXX
00258 #    define gm_inline
00259 #  else
00260 #    define gm_inline
00261 #  endif
00262 #endif
00263 
00264 /************
00265  * Define sized types
00266  ************/
00267 
00268 /* gm_s64_t   64-bit signed   integer
00269    gm_s32_t   32-bit signed   integer
00270    gm_s16_t   16-bit signed   integer
00271    gm_s8_t     8-bit signed   integer
00272    gm_u64_t   64-bit unsigned integer
00273    gm_u32_t   32-bit unsigned integer
00274    gm_u16_t   16-bit unsigned integer
00275    gm_u8_t     8-bit unsigned integer */
00276 
00277 #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__DECC) || defined(__DECCXX)
00278 #if (GM_CPU_sparc64 && defined(__linux__)) && !GM_MCP
00279 #if GM_KERNEL
00280 typedef signed long gm_s64_t;
00281 typedef unsigned long gm_u64_t;
00282 #else
00283 typedef signed long long gm_s64_t;
00284 typedef unsigned long long gm_u64_t;
00285 #endif /* GM_KERNEL */
00286 #else
00287 #if (GM_CPU_alpha || GM_CPU_sparc64) && !GM_MCP
00288 typedef signed long gm_s64_t;
00289 typedef unsigned long gm_u64_t;
00290 #else
00291 typedef signed long long gm_s64_t;
00292 typedef unsigned long long gm_u64_t;
00293 #endif
00294 #endif
00295 
00297 typedef signed int gm_s32_t;
00299 typedef signed short gm_s16_t;
00301 typedef signed char gm_s8_t;
00303 typedef unsigned int gm_u32_t;
00305 typedef unsigned short gm_u16_t;
00307 typedef unsigned char gm_u8_t;
00308 #elif defined _MSC_VER
00309 typedef signed __int64 gm_s64_t;
00310 typedef unsigned __int64 gm_u64_t;
00311 typedef signed __int32 gm_s32_t;
00312 typedef signed __int16 gm_s16_t;
00313 typedef signed __int8 gm_s8_t;
00314 typedef unsigned __int32 gm_u32_t;
00315 typedef unsigned __int16 gm_u16_t;
00316 typedef unsigned __int8 gm_u8_t;
00317 #elif GM_CPU_mips               /* see /usr/include/sgidefs.h */
00318 #if (_MIPS_SZLONG == 64)
00319 typedef long gm_s64_t;
00320 typedef unsigned long gm_u64_t;
00321 #elif defined(_LONGLONG)
00322 typedef long long gm_s64_t;
00323 typedef unsigned long long gm_u64_t;
00324 #else
00325 /* __long_long is a hidden builtin, ansi-compliant 64-bit type.  It
00326    should be used only here; henceforward, the gm_ types should be used. */
00327 typedef __long_long gm_s64_t;
00328 typedef unsigned __long_long gm_u64_t;
00329 #endif
00330 typedef int gm_s32_t;
00331 typedef signed short gm_s16_t;
00332 typedef signed char gm_s8_t;
00333 typedef unsigned gm_u32_t;
00334 typedef unsigned short gm_u16_t;
00335 typedef unsigned char gm_u8_t;
00336 #elif defined __PGI || defined(i386) || defined(__i386)         /* Need cpu macros? */
00337 typedef signed long long gm_s64_t;
00338 typedef signed int gm_s32_t;
00339 typedef signed short gm_s16_t;
00340 typedef signed char gm_s8_t;
00341 typedef unsigned long long gm_u64_t;
00342 typedef unsigned int gm_u32_t;
00343 typedef unsigned short gm_u16_t;
00344 typedef unsigned char gm_u8_t;
00345 #elif (defined (__SUNPRO_C) || defined (__SUNPRO_CC)) && (defined(sparc64) || defined(__sparcv9))
00346 typedef signed long gm_s64_t;
00347 typedef signed int gm_s32_t;
00348 typedef signed short gm_s16_t;
00349 typedef signed char gm_s8_t;
00350 typedef unsigned long gm_u64_t;
00351 typedef unsigned int gm_u32_t;
00352 typedef unsigned short gm_u16_t;
00353 typedef unsigned char gm_u8_t;
00354 #elif (defined (__SUNPRO_C) || defined (__SUNPRO_CC)) && defined(__sparc)
00355 typedef signed long long gm_s64_t;
00356 typedef signed int gm_s32_t;
00357 typedef signed short gm_s16_t;
00358 typedef signed char gm_s8_t;
00359 typedef unsigned long long gm_u64_t;
00360 typedef unsigned int gm_u32_t;
00361 typedef unsigned short gm_u16_t;
00362 typedef unsigned char gm_u8_t;
00363 #elif (defined (__SUNPRO_C) || defined (__SUNPRO_CC)) && defined i386
00364 typedef signed long long gm_s64_t;
00365 typedef signed int gm_s32_t;
00366 typedef signed short gm_s16_t;
00367 typedef signed char gm_s8_t;
00368 typedef unsigned long long gm_u64_t;
00369 typedef unsigned int gm_u32_t;
00370 typedef unsigned short gm_u16_t;
00371 typedef unsigned char gm_u8_t;
00372 #elif defined(__hpux)
00373 typedef signed long gm_s64_t;
00374 typedef signed int gm_s32_t;
00375 typedef signed short gm_s16_t;
00376 typedef signed char gm_s8_t;
00377 typedef unsigned long gm_u64_t;
00378 typedef unsigned int gm_u32_t;
00379 typedef unsigned short gm_u16_t;
00380 typedef unsigned char gm_u8_t;
00381 #elif defined(__AIX__) || defined(_AIX)
00382 typedef signed long long gm_s64_t;
00383 typedef signed int gm_s32_t;
00384 typedef signed short gm_s16_t;
00385 typedef signed char gm_s8_t;
00386 typedef unsigned long long gm_u64_t;
00387 typedef unsigned int gm_u32_t;
00388 typedef unsigned short gm_u16_t;
00389 typedef unsigned char gm_u8_t;
00390 #else
00391 #  error Could not define sized types.  You need to modify gm.h.
00392 #endif
00393 
00394 /************
00395  * LANai-compatible host-side pointer representation
00396  ************/
00397 
00398 /* Define size of host pointers */
00399 
00400 #if GM_MCP
00401 #  define GM_SIZEOF_VOID_P 4
00402 #else
00403 #  if GM_CPU_sparc64 && defined(__linux__) && !GM_KERNEL
00404 #    define GM_SIZEOF_VOID_P 4
00405 #  elif GM_CPU_sparc64
00406 #    define GM_SIZEOF_VOID_P 8
00407 #  elif GM_CPU_sparc
00408 #    define GM_SIZEOF_VOID_P 4
00409 #  elif GM_CPU_x86
00410 #    define GM_SIZEOF_VOID_P 4
00411 #  elif GM_CPU_ia64
00412 #    define GM_SIZEOF_VOID_P 8
00413 #  elif GM_CPU_alpha
00414 #    define GM_SIZEOF_VOID_P 8
00415 #  elif GM_CPU_mips
00416 #    ifdef _MIPS_SZPTR
00417 #      define GM_SIZEOF_VOID_P (_MIPS_SZPTR / 8)
00418 #    else
00419 #      error Failed to define _MIPS_SZPTR
00420 #    endif
00421 #  elif GM_CPU_powerpc
00422 #    define GM_SIZEOF_VOID_P 4
00423 #  elif GM_CPU_hppa
00424 #    define GM_SIZEOF_VOID_P 8
00425 #  else
00426 #    error Could not determine host pointer size.  You need to modify gm.h.
00427 #  endif
00428 #endif
00429 
00430 /* GM_SIZEOF_UP_T */
00431 
00432 /****************
00433  * GM_SIZEOF_UP_T: GM user pointers
00434  *
00435  * This is a tricky definition.  From the point of view of the GM
00436  * internals (the firmware, libgm, the driver, and certain debug
00437  * programs) all user pointers are the maximum size supported on the
00438  * system, and GM_SIZEOF_UP_T is defined by the build environment.
00439  *
00440  * From the point of view of the GM client application, gm_up_t's are
00441  * the same size as a "void *" in that application by default.
00442  *
00443  * Note that in structure in the GM API, there is a 32-bit pad before
00444  * any 32-bit user pointer to make GM's internal and external layouts
00445  * for these structures be compatible.
00446  ****************/
00447 
00448 #ifndef GM_BUILDING_INTERNALS
00449 #define GM_BUILDING_INTERNALS 0
00450 #endif
00451 
00452 #if GM_BUILDING_INTERNALS
00453 
00454 #ifndef GM_SIZEOF_UP_T
00455 #error GM_SIZEOF_UP_T should be defined on the compiler command line
00456 #endif
00457 
00458 #else  /* ndef GM_BUILDING_INTERNALS */
00459 
00460 #define GM_SIZEOF_UP_T GM_SIZEOF_VOID_P
00461 
00462 #endif /* ndef GM_BUILDING_INTERNALS */
00463 
00473 /* Define host pointer types 
00474 
00475    gm_up_t   unsigned int the size of a user pointer */
00476 
00477 #if GM_SIZEOF_UP_T == 4
00478 typedef gm_u32_t gm_up_t;
00479 #elif GM_SIZEOF_UP_T == 8
00480 typedef gm_u64_t gm_up_t;
00481 #else
00482 #  error Host pointer size is not supported.
00483 #endif
00484 
00485 typedef gm_u64_t gm_remote_ptr_t;       /* assume remote pointers are large */
00486 
00487 /****************************************************************
00488  * Endianess
00489  ****************************************************************/
00490 
00491 /* Determine endianness */
00492 
00493 #if GM_CPU_alpha
00494 #  define GM_CPU_BIGENDIAN 0
00495 #elif GM_CPU_lanai
00496 #  define GM_CPU_BIGENDIAN 1
00497 #elif GM_CPU_mips
00498 #  define GM_CPU_BIGENDIAN 1
00499 #elif GM_CPU_powerpc
00500 #  define GM_CPU_BIGENDIAN 1
00501 #elif GM_CPU_sparc
00502 #  define GM_CPU_BIGENDIAN 1
00503 #elif GM_CPU_sparc64
00504 #  define GM_CPU_BIGENDIAN 1
00505 #elif GM_CPU_hppa
00506 #  define GM_CPU_BIGENDIAN 1
00507 #elif GM_CPU_x86
00508 #  define GM_CPU_BIGENDIAN 0
00509 #elif GM_CPU_ia64
00510 #  define GM_CPU_BIGENDIAN 0
00511 #else
00512 #  error Could not determine endianness.  You need to modify gm.h.
00513 #endif
00514 
00515 /****************
00516  * Network-order types, strongly typed on the host
00517  ****************/
00518 
00519 /* The default behaviour is to turn on strong typing, except when
00520    using 64-bit Solaris compilers, which will pad the strong types,
00521    breaking this feature.
00522    loic: SUN compiler generates call to .stretx for functions returning
00523    structures, that leads to undefined symbols for kernel code,
00524    so I disabled strong typing even for 32bit with SUN compilers */
00525 
00526 #ifndef GM_STRONG_TYPES
00527 #if (defined __SUNPRO_C || defined __SUNPRO_CC) && (defined __sparc || defined __sparcv9)
00528 #define GM_STRONG_TYPES 0
00529 #else
00530 #define GM_STRONG_TYPES 1
00531 #endif
00532 #endif /* ndef GM_STRONG_TYPES */
00533 
00534 /* Prevent usage of strong types on 64-bit Solaris machines.  These are
00535    big-endian anyway, so no one should need it there. */
00536 
00537 #if GM_STRONG_TYPES && (defined __SUNPRO_C || defined __SUNPRO_CC) && (defined __sparc || defined __sparcv9)
00538 #error GM_STRONG_TYPES is incompatible with Solaris compilers
00539 #endif
00540 
00541 #if !GM_MCP && GM_STRONG_TYPES
00542 
00543 typedef struct
00544 {
00545   gm_remote_ptr_t n;
00546 }
00547 gm_remote_ptr_n_t;
00548 typedef struct
00549 {
00550   gm_s16_t n;
00551 }
00552 gm_s16_n_t;
00553 typedef struct
00554 {
00555   gm_s32_t n;
00556 }
00557 gm_s32_n_t;
00558 typedef struct
00559 {
00560   gm_s64_t n;
00561 }
00562 gm_s64_n_t;
00563 typedef struct
00564 {
00565   gm_s8_t n;
00566 }
00567 gm_s8_n_t;
00568 typedef struct
00569 {
00570   gm_u16_t n;
00571 }
00572 gm_u16_n_t;
00573 typedef struct
00574 {
00575   gm_u32_t n;
00576 }
00577 gm_u32_n_t;
00578 typedef struct
00579 {
00580   gm_u64_t n;
00581 }
00582 gm_u64_n_t;
00583 typedef struct
00584 {
00585   gm_u8_t n;
00586 }
00587 gm_u8_n_t;
00588 typedef struct
00589 {
00590   gm_up_t n;
00591 }
00592 gm_up_n_t;
00593 typedef gm_up_n_t gm_up_n_up_n_t;
00594 #define GM_N(x) ((x).n)
00595 
00596 #else /* GM_MCP || !GM_STRONG_TYPES */
00597 
00598 typedef gm_remote_ptr_t gm_remote_ptr_n_t;
00599 typedef gm_s16_t gm_s16_n_t;
00600 typedef gm_s32_t gm_s32_n_t;
00601 typedef gm_s64_t gm_s64_n_t;
00602 typedef gm_s8_t gm_s8_n_t;
00603 typedef gm_u16_t gm_u16_n_t;
00604 typedef gm_u32_t gm_u32_n_t;
00605 typedef gm_u64_t gm_u64_n_t;
00606 typedef gm_u8_t gm_u8_n_t;
00607 typedef gm_up_t gm_up_n_t;
00608 typedef gm_up_t gm_up_n_up_n_t;
00609 #define GM_N(x) (x)
00610 
00611 #endif /* GM_MCP || !GM_STRONG_TYPES*/
00612 
00613 /****************************************************************
00614  * Byte order conversion
00615  ****************************************************************/
00616 
00617 /********************************
00618  * Unconditional conversion
00619  ********************************/
00620 
00621 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00622 
00623 /* Define __gm_swap* macros, which always reverse the order of bytes. */
00624 
00625 gm_inline static gm_u16_t
00626 __gm_swap_u8 (gm_u8_t x)
00627 {
00628   return x;
00629 }
00630 
00631 gm_inline static gm_u16_t
00632 __gm_swap_u16 (gm_u16_t x)
00633 {
00634   return (((x >> 8) & 0xff) | ((x & 0xff) << 8));
00635 }
00636 
00637 /* Architecture-independent C implementation. */
00638 
00639 gm_inline static gm_u32_t
00640 __gm_swap_u32_C (gm_u32_t x)
00641 {
00642   return (((x >> 24) & 0xff)
00643           | ((x >> 8) & 0xff00) | ((x & 0xff00) << 8) | ((x & 0xff) << 24));
00644 }
00645 
00646 /* Architecture-specific assembly implementations */
00647 
00648 gm_inline static gm_u32_t
00649 __gm_swap_u32_asm (gm_u32_t x)
00650 {
00651 #if defined __GNUC__ && GM_CPU_x86 && __OPTIMIZE__ && 0
00652 __asm__ ("bswap %0": "=r" (x):"0" (x));
00653   return x;
00654 #else
00655   return __gm_swap_u32_C (x);
00656 #endif
00657 }
00658 
00659 gm_inline static gm_u32_t
00660 __gm_swap_u32 (gm_u32_t x)
00661 {
00662 #ifdef __GNUC__
00663   /* Use C implementation for constants to allow compile-time swapping.
00664      Otherwise, use fast assembly implementation. */
00665   return __builtin_constant_p (x) ? __gm_swap_u32_C (x) :
00666     __gm_swap_u32_asm (x);
00667 #else
00668   return __gm_swap_u32_C (x);
00669 #endif
00670 }
00671 
00672 /* These unconditional conversion macros are used by the conditional
00673    conversion macros below */
00674 
00675 gm_inline static gm_u64_t
00676 __gm_swap_u64 (gm_u64_t x)
00677 {
00678   volatile union
00679   {
00680     gm_u64_t u64;
00681     gm_u32_t u32[2];
00682   }
00683   ret, old;
00684 
00685   old.u64 = x;
00686   ret.u32[0] = __gm_swap_u32 (old.u32[1]);
00687   ret.u32[1] = __gm_swap_u32 (old.u32[0]);
00688   return ret.u64;
00689 }
00690 
00691 /****************************************************************
00692  * Strongly typed conversion
00693  ****************************************************************/
00694 
00695 /********************************
00696  * Conditional conversion
00697  ********************************/
00698 
00699 #if GM_CPU_BIGENDIAN || GM_MCP
00700 #define GM_NET_SWAP 0
00701 #else
00702 #define GM_NET_SWAP 1
00703 #endif
00704 
00705 /* These gm_ntoh* macros perform strong type checking, allowing the
00706    compiler to ensure that no network-ordered fields are used by host
00707    code without first being converted to host byte order by these
00708    functions.  The only way to circumvent this strong checking is
00709    using memory copies or complicated casts.  The compiler will catch
00710    simple casts. */
00711 
00712 /****************
00713  * network to host
00714  ****************/
00715 
00716 /* Macro to define gm_ntoh_u8(), etc. */
00717 
00718 #define _GM_NTOH(type, size)                                            \
00719                                                                         \
00720 /* swap using weak typing */                                            \
00721                                                                         \
00722 gm_inline static                                                        \
00723 gm_##type##size##_t                                                     \
00724 __gm_ntoh_##type##size (gm_##type##size##_t x)                          \
00725 {                                                                       \
00726   if (GM_NET_SWAP)                                                      \
00727     {                                                                   \
00728       return ((gm_##type##size##_t)                                     \
00729               __gm_swap_u##size ((gm_u##size##_t) x));                  \
00730     }                                                                   \
00731   else                                                                  \
00732     {                                                                   \
00733       return x;                                                         \
00734     }                                                                   \
00735 }                                                                       \
00736                                                                         \
00737 /* swap using strong typing */                                          \
00738                                                                         \
00739 gm_inline static                                                        \
00740 gm_##type##size##_t                                                     \
00741 _gm_ntoh_##type##size (gm_##type##size##_n_t x)                         \
00742 {                                                                       \
00743   return __gm_ntoh_##type##size (GM_N (x));                             \
00744 }
00745 
00746 _GM_NTOH (u, 8)
00747 _GM_NTOH (u, 16)
00748 _GM_NTOH (u, 32)
00749 _GM_NTOH (u, 64)
00750 
00751 _GM_NTOH (s, 8)
00752 _GM_NTOH (s, 16)
00753 _GM_NTOH (s, 32)
00754 _GM_NTOH (s, 64)
00755 
00756 /****************
00757  * host to network
00758  ****************/
00759 
00760 /* Macro to define gm_hton_u8(), etc. */
00761 
00762 #define _GM_HTON(type, size)                                            \
00763                                                                         \
00764 /* swap using weak typing */                                            \
00765                                                                         \
00766 gm_inline static                                                        \
00767 gm_##type##size##_t                                                     \
00768 __gm_hton_##type##size (gm_##type##size##_t x)                          \
00769 {                                                                       \
00770   if (GM_NET_SWAP)                                                      \
00771     {                                                                   \
00772       return ((gm_##type##size##_t)                                     \
00773               __gm_swap_u##size ((gm_u##size##_t) x));                  \
00774     }                                                                   \
00775   else                                                                  \
00776     {                                                                   \
00777       return x;                                                         \
00778     }                                                                   \
00779 }                                                                       \
00780                                                                         \
00781 /* swap using strong typing */                                          \
00782                                                                         \
00783 gm_inline static                                                        \
00784 gm_##type##size##_n_t                                                   \
00785 _gm_hton_##type##size (gm_##type##size##_t x)                           \
00786 {                                                                       \
00787   gm_##type##size##_n_t ret;                                            \
00788                                                                         \
00789   GM_N (ret) = __gm_hton_##type##size (x);                              \
00790   return ret;                                                           \
00791 }
00792 
00793 _GM_HTON (u, 8)
00794 _GM_HTON (u, 16)
00795 _GM_HTON (u, 32)
00796 _GM_HTON (u, 64)
00797 
00798 _GM_HTON (s, 8)
00799 _GM_HTON (s, 16)
00800 _GM_HTON (s, 32)
00801 _GM_HTON (s, 64)
00802 
00803 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 
00804 
00805 /********************************
00806  * host/network conversion macros.
00807  ********************************/
00808 
00809 /* These are just like the "^_gm" versions above, but exist to give
00810    etags something to jump to.  The "_gm" versions above are in a macro
00811    to avoid code replication. */
00812 
00813 gm_inline static gm_u64_t
00814 gm_ntoh_u64 (gm_u64_n_t x)
00815 {
00816   return _gm_ntoh_u64 (x);
00817 }
00818 gm_inline static gm_s64_t
00819 gm_ntoh_s64 (gm_s64_n_t x)
00820 {
00821   return _gm_ntoh_s64 (x);
00822 }
00823 gm_inline static gm_u32_t
00824 gm_ntoh_u32 (gm_u32_n_t x)
00825 {
00826   return _gm_ntoh_u32 (x);
00827 }
00828 gm_inline static gm_s32_t
00829 gm_ntoh_s32 (gm_s32_n_t x)
00830 {
00831   return _gm_ntoh_s32 (x);
00832 }
00833 gm_inline static gm_u16_t
00834 gm_ntoh_u16 (gm_u16_n_t x)
00835 {
00836   return _gm_ntoh_u16 (x);
00837 }
00838 gm_inline static gm_s16_t
00839 gm_ntoh_s16 (gm_s16_n_t x)
00840 {
00841   return _gm_ntoh_s16 (x);
00842 }
00843 gm_inline static gm_u8_t
00844 gm_ntoh_u8 (gm_u8_n_t x)
00845 {
00846   return _gm_ntoh_u8 (x);
00847 }
00848 gm_inline static gm_s8_t
00849 gm_ntoh_s8 (gm_s8_n_t x)
00850 {
00851   return _gm_ntoh_s8 (x);
00852 }
00853 
00854 gm_inline static gm_u64_n_t
00855 gm_hton_u64 (gm_u64_t s)
00856 {
00857   return _gm_hton_u64 (s);
00858 }
00859 gm_inline static gm_s64_n_t
00860 gm_hton_s64 (gm_s64_t s)
00861 {
00862   return _gm_hton_s64 (s);
00863 }
00864 gm_inline static gm_u32_n_t
00865 gm_hton_u32 (gm_u32_t s)
00866 {
00867   return _gm_hton_u32 (s);
00868 }
00869 gm_inline static gm_s32_n_t
00870 gm_hton_s32 (gm_s32_t s)
00871 {
00872   return _gm_hton_s32 (s);
00873 }
00874 gm_inline static gm_u16_n_t
00875 gm_hton_u16 (gm_u16_t s)
00876 {
00877   return _gm_hton_u16 (s);
00878 }
00879 gm_inline static gm_s16_n_t
00880 gm_hton_s16 (gm_s16_t s)
00881 {
00882   return _gm_hton_s16 (s);
00883 }
00884 gm_inline static gm_u8_n_t
00885 gm_hton_u8 (gm_u8_t c)
00886 {
00887   return _gm_hton_u8 (c);
00888 }
00889 gm_inline static gm_s8_n_t
00890 gm_hton_s8 (gm_s8_t c)
00891 {
00892   return _gm_hton_s8 (c);
00893 }
00894 
00895 /* Macro for accessing words in the little endian PCI config space */
00896 
00897 gm_inline static gm_u32_t
00898 gm_htopci_u32 (gm_u32_t x)
00899 {
00900   if (GM_NET_SWAP)
00901     {
00902       return x;
00903     }
00904   else
00905     {
00906       return __gm_swap_u32 (x);
00907     }
00908 }
00909 
00910 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00911 
00912 #if !GM_MCP
00913 gm_inline static void *
00914 gm_ntohp (gm_up_n_t x)
00915 {
00916 #if GM_SIZEOF_UP_T == 8
00917   return (void *) __gm_ntoh_u64 (GM_N (x));
00918 #elif GM_SIZEOF_UP_T == 4
00919   return (void *) __gm_ntoh_u32 (GM_N (x));
00920 #endif
00921 }
00922 #endif
00923 
00924 /****************
00925  * backwards compatibility
00926  ****************/
00927 
00937 #if !GM_BUILDING_GM
00938 
00939 /* These aliases are for client use only */
00940 
00941 gm_inline static gm_u8_t
00942 gm_ntohc (gm_u8_n_t x)
00943 {
00944   return gm_ntoh_u8 (x);
00945 }
00946 gm_inline static gm_u16_t
00947 gm_ntohs (gm_u16_n_t x)
00948 {
00949   return gm_ntoh_u16 (x);
00950 }
00951 gm_inline static gm_u32_t
00952 gm_ntohl (gm_u32_n_t x)
00953 {
00954   return gm_ntoh_u32 (x);
00955 }
00956 gm_inline static gm_u64_t
00957 gm_ntohll (gm_u64_n_t x)
00958 {
00959   return gm_ntoh_u64 (x);
00960 }
00961 
00962 gm_inline static gm_u8_n_t
00963 gm_htonc (gm_u8_t x)
00964 {
00965   return gm_hton_u8 (x);
00966 }
00967 gm_inline static gm_u16_n_t
00968 gm_htons (gm_u16_t x)
00969 {
00970   return gm_hton_u16 (x);
00971 }
00972 gm_inline static gm_u32_n_t
00973 gm_htonl (gm_u32_t x)
00974 {
00975   return gm_hton_u32 (x);
00976 }
00977 gm_inline static gm_u64_n_t
00978 gm_htonll (gm_u64_t x)
00979 {
00980   return gm_hton_u64 (x);
00981 }
00982 
00983 #define gm_assert_p(a) gm_assert (a)
00984 
00985 #endif /* !GM_BUILDING_GM */
00986 
00987 /************
00988  * GM_ENTRY_POINT definition
00989  ************/
00990 
00991 #ifndef GM_ENTRY_POINT          /* need to override in NT4 make-os.in */
00992 
00993 #if defined _MSC_VER            /* microsoft compiler */
00994 #  if GM_KERNEL
00995 #    define GM_ENTRY_POINT
00996 #  elif GM_BUILDING_GM_LIB
00997 #    define GM_ENTRY_POINT __declspec (dllexport)
00998 #  else
00999 #    define GM_ENTRY_POINT __declspec (dllimport)
01000 #  endif
01001 #else
01002 #  define GM_ENTRY_POINT
01003 #endif
01004 
01005 #endif /* ndef GM_ENTRY_POINT */
01006 
01007 /* Debugging */
01008 
01009 #ifndef GM_DEBUG
01010 #  ifndef GM_BUILDING_GM
01011 #    define GM_DEBUG 0
01012 #  else  /* GM_BUILDING_GM */
01013 #    error GM_DEBUG must be defined for internal GM builds.
01014 #  endif /* GM_BUILDING_GM */
01015 #endif /* !GM_DEBUG */
01016 
01017 /* A macro like "gm_assert()", only causing an error at compile-time
01018    rather than run time.  The expression A must be a constant
01019    expression.  */
01020 
01021 #ifdef __GNUC__
01022 #define __GM_COMPILE_TIME_ASSERT(a) do {                                \
01023   char (*__GM_COMPILE_TIME_ASSERT)[(a) ? 1 : -1] = 0;                   \
01024   (void) __GM_COMPILE_TIME_ASSERT; /* prevent unused var warning */     \
01025 } while (0)
01026 #else
01027 #define __GM_COMPILE_TIME_ASSERT(a)
01028 #endif
01029 
01030 /****************
01031  * gm_always_assert() and gm_assert()
01032  ****************/
01033 
01034 /* Macro for determining if X is a constant that can be evaluated at
01035    compile time.  This macro is used by gm_always_assert*() to perform as many
01036    compile-time checks as possible. */
01037 
01038 #ifdef __GNUC__
01039 #define __gm_builtin_constant_p(x) __builtin_constant_p (x)
01040 #else
01041 #define __gm_builtin_constant_p(x) 0
01042 #endif
01043 
01044 /* gm_assert() Assert iff debugging turned on. */
01045 
01046 #if GM_DEBUG
01047 #define gm_assert(a) _gm_always_assert (a, #a)
01048 #else
01049 #define gm_assert(a) do {if (0) (void) (a);} while (0) /* allow syntax check */
01050 #endif
01051 
01052 #if GM_MCP
01053 #define __GM_ASSERTION_FAILED(txt, line, file) do {                     \
01054   /*LOG_DISPATCH(0,"__GM_ASSERTION_FAILED");*/                          \
01055   _gm_assertion_failed (txt, line, file);                               \
01056 } while (0)
01057 #else
01058 #define __GM_ASSERTION_FAILED(txt, line, file) do {                     \
01059   _gm_assertion_failed (txt, line, file);                               \
01060 } while (0)
01061 #endif
01062 
01063 /* gm_always_assert(): Always assert, even if debugging is turned off,
01064    unless we are able to to the check at compile-time. */
01065 
01066 #define _gm_always_assert(a,txt) do {                                   \
01067   __GM_COMPILE_TIME_ASSERT (!__gm_builtin_constant_p (a) || (a));       \
01068   if (!(a))                                                             \
01069     {                                                                   \
01070       __GM_ASSERTION_FAILED (txt, __LINE__, __GM_FILE__);               \
01071     }                                                                   \
01072 } while (0)
01073 #define gm_always_assert(a) _gm_always_assert (a, #a)
01074 
01075 #define GM_ABORT() __GM_ASSERTION_FAILED ("0", __LINE__, __FILE__)
01076 
01077 /****************
01078  * Compiler warning supression macros
01079  ****************/
01080 
01081 #define GM_PARAMETER_MAY_BE_UNUSED(p) ((void)(p))
01082 #define GM_VAR_MAY_BE_UNUSED(v) ((void)(v))
01083 
01084 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01085 
01086 /****************************************************************
01087  * typedefs
01088  ****************************************************************/
01089 
01091 typedef enum gm_status
01092 {
01094   GM_SUCCESS = 0,
01096   GM_FAILURE = 1,
01098   GM_INPUT_BUFFER_TOO_SMALL = 2,
01100   GM_OUTPUT_BUFFER_TOO_SMALL = 3,
01102   GM_TRY_AGAIN = 4,
01104   GM_BUSY = 5,
01106   GM_MEMORY_FAULT = 6,
01108   GM_INTERRUPTED = 7,
01110   GM_INVALID_PARAMETER = 8,
01112   GM_OUT_OF_MEMORY = 9,
01114   GM_INVALID_COMMAND = 10,
01116   GM_PERMISSION_DENIED = 11,
01118   GM_INTERNAL_ERROR = 12,
01120   GM_UNATTACHED = 13,
01122   GM_UNSUPPORTED_DEVICE = 14,
01131   GM_SEND_TIMED_OUT = 15,
01135   GM_SEND_REJECTED = 16,
01138   GM_SEND_TARGET_PORT_CLOSED = 17,
01143   GM_SEND_TARGET_NODE_UNREACHABLE = 18,
01146   GM_SEND_DROPPED = 19,
01148   GM_SEND_PORT_CLOSED = 20,
01150   GM_NODE_ID_NOT_YET_SET = 21,
01152   GM_STILL_SHUTTING_DOWN = 22,
01154   GM_CLONE_BUSY = 23,
01156   GM_NO_SUCH_DEVICE = 24,
01158   GM_ABORTED = 25,
01159 #if GM_API_VERSION >= GM_API_VERSION_1_5
01160 
01161   GM_INCOMPATIBLE_LIB_AND_DRIVER = 26,
01163   GM_UNTRANSLATED_SYSTEM_ERROR = 27,
01165   GM_ACCESS_DENIED = 28,
01166 #endif
01167 
01168   GM_DEV_NOT_FOUND = 29,
01169   /* If you add error codes, also update libgm/gm_strerror.c. --Glenn */
01170 
01171   GM_NUM_STATUS_CODES           /* may change in value */
01172 #if !GM_BUILDING_GM
01173     /* DEPRECATED */ , GM_NUM_ERROR_CODES = GM_NUM_STATUS_CODES
01174 #endif
01175     /* Do not add new codes here. */
01176 }
01177 gm_status_t;
01178 
01180 enum gm_priority
01181 {
01183   GM_LOW_PRIORITY = 0,
01185   GM_HIGH_PRIORITY = 1,
01187   GM_NUM_PRIORITIES = 2
01188 };
01189 
01190 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01191 
01192 enum gm_buf_status
01193 {
01194   gm_in_send = 0,
01195   gm_in_recv,
01196   gm_in_app,
01197   gm_invalid_status
01198 };
01199 
01200 struct gm_buf_handle
01201 {
01202   void *addr;
01203   int size;
01204   enum gm_buf_status status;
01205   struct gm_buf_handle *next;
01206 };
01207 
01208 
01209 typedef struct gm_alarm
01210 {
01211   struct gm_alarm *next;
01212   enum
01213   {
01214     GM_ALARM_FREE = 0,
01215     GM_ALARM_SET
01216   }
01217   state;
01218   struct gm_port *port;
01219   void (*callback) (void *context);
01220   void *context;
01221   gm_u64_t deadline;
01222 }
01223 gm_alarm_t;
01224 
01225 /* This is a list of GM API versions supported by this version of GM. */
01226 
01227 enum gm_api_version
01228 {
01229   /* symbolic versions for C code to allow symbolic debugging. */
01230   _GM_API_VERSION_1_0 = GM_API_VERSION_1_0,
01231 #if GM_API_VERSION >= GM_API_VERSION_1_1
01232   _GM_API_VERSION_1_1 = GM_API_VERSION_1_1,
01233 #endif
01234 #if GM_API_VERSION >= GM_API_VERSION_1_2
01235   _GM_API_VERSION_1_2 = GM_API_VERSION_1_2,
01236 #endif
01237 #if GM_API_VERSION >= GM_API_VERSION_1_3
01238   _GM_API_VERSION_1_3 = GM_API_VERSION_1_3,
01239 #endif
01240 #if GM_API_VERSION >= GM_API_VERSION_1_4
01241   _GM_API_VERSION_1_4 = GM_API_VERSION_1_4,
01242 #endif
01243 #if GM_API_VERSION >= GM_API_VERSION_1_5
01244   _GM_API_VERSION_1_5 = GM_API_VERSION_1_5,
01245 #endif
01246 #if GM_API_VERSION >= GM_API_VERSION_1_6
01247   _GM_API_VERSION_1_6 = GM_API_VERSION_1_6,
01248 #endif
01249   __GM_API_VERSION_IGNORE_COMMA
01250 };
01251 
01252 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01253 
01254 /************************************************************************
01255  * Macros
01256  ************************************************************************/
01257 
01258 /* Determine if N is aligned on an M-byte boundary, where M is a power
01259    of 2 */
01260 
01261 #define __GM_MISALIGNMENT(n,m) ((gm_size_t)(n) & ((gm_size_t)(m) - 1))
01262 #define GM_ALIGNED(n,m) (__GM_MISALIGNMENT(n,m) == 0)
01263 
01264 /* NOTE: all GM alignment requirements will be lifted */
01265 
01267 #define GM_RDMA_GRANULARITY 64
01268 
01269 #define GM_MAX_DMA_GRANULARITY 8
01270 #if GM_RDMA_GRANULARITY % GM_MAX_DMA_GRANULARITY
01271 #  error GM_RDMA_GRANULARITY must be a multiple of GM_MAX_DMA_GRANULARITY
01272 #endif
01273 
01274 #if !GM_MCP
01275 #define GM_DMA_GRANULARITY GM_MAX_DMA_GRANULARITY
01276 #endif
01277 
01278 #define GM_DMA_ALIGNED(p)       GM_ALIGNED (p, GM_DMA_GRANULARITY)
01279 
01280 /************************************************************************
01281  * Recv event type
01282  ************************************************************************/
01283 
01285 enum gm_recv_event_type
01286 {
01287 #if !GM_MCP                     /* don't use these in the MCP */
01288 
01289   GM_NO_RECV_EVENT = 0,
01291   GM_SENDS_FAILED_EVENT = 1,
01294   GM_ALARM_EVENT = 2,
01296   GM_SENT_EVENT = 3,
01298   _GM_SLEEP_EVENT = 4,
01300   GM_RAW_RECV_EVENT = 5,
01302   GM_BAD_SEND_DETECTED_EVENT = 6,
01304   GM_SEND_TOKEN_VIOLATION_EVENT = 7,
01306   GM_RECV_TOKEN_VIOLATION_EVENT = 8,
01308   GM_BAD_RECV_TOKEN_EVENT = 9,
01310   GM_ALARM_VIOLATION_EVENT = 10,
01313   GM_RECV_EVENT = 11,
01316   GM_HIGH_RECV_EVENT = 12,
01320   GM_PEER_RECV_EVENT = 13,
01324   GM_HIGH_PEER_RECV_EVENT = 14,
01328   GM_FAST_RECV_EVENT = 15,
01332   GM_FAST_HIGH_RECV_EVENT = 16,
01337   GM_FAST_PEER_RECV_EVENT = 17,
01342   GM_FAST_HIGH_PEER_RECV_EVENT = 18,
01344   GM_REJECTED_SEND_EVENT = 19,
01346   GM_ORPHANED_SEND_EVENT = 20,
01350   _GM_DIRECTED_SEND_NOTIFICATION_EVENT = 21,
01351   /* GM_FREE_SEND_TOKEN_EVENT = 22, */
01352   /* GM_FREE_HIGH_SEND_TOKEN_EVENT = 23, */
01354   GM_BAD_RESEND_DETECTED_EVENT = 24,
01356   GM_DROPPED_SEND_EVENT = 25,
01358   GM_BAD_SEND_VMA_EVENT = 26,
01360   GM_BAD_RECV_VMA_EVENT = 27,
01362   _GM_FLUSHED_ALARM_EVENT = 28,
01364   GM_SENT_TOKENS_EVENT = 29,
01366   GM_IGNORE_RECV_EVENT = 30,
01367 #endif                          /* GM_MCP not defined */
01368   /****** Types used to make a new event in the queue. ******/
01370   GM_NEW_NO_RECV_EVENT = 128,
01372   GM_NEW_SENDS_FAILED_EVENT = 129,
01374   GM_NEW_ALARM_EVENT = 130,
01376   GM_NEW_SENT_EVENT = 131,
01378   _GM_NEW_SLEEP_EVENT = 132,
01380   GM_NEW_RAW_RECV_EVENT = 133,
01382   GM_NEW_BAD_SEND_DETECTED_EVENT = 134,
01384   GM_NEW_SEND_TOKEN_VIOLATION_EVENT = 135,
01386   GM_NEW_RECV_TOKEN_VIOLATION_EVENT = 136,
01388   GM_NEW_BAD_RECV_TOKEN_EVENT = 137,
01390   GM_NEW_ALARM_VIOLATION_EVENT = 138,
01392   GM_NEW_RECV_EVENT = 139,
01394   GM_NEW_HIGH_RECV_EVENT = 140,
01396   GM_NEW_PEER_RECV_EVENT = 141,
01398   GM_NEW_HIGH_PEER_RECV_EVENT = 142,
01400   GM_NEW_FAST_RECV_EVENT = 143,
01402   GM_NEW_FAST_HIGH_RECV_EVENT = 144,
01404   GM_NEW_FAST_PEER_RECV_EVENT = 145,
01406   GM_NEW_FAST_HIGH_PEER_RECV_EVENT = 146,
01408   GM_NEW_REJECTED_SEND_EVENT = 147,
01410   GM_NEW_ORPHANED_SEND_EVENT = 148,
01412   _GM_NEW_DIRECTED_SEND_NOTIFICATION_EVENT = 149,
01414   GM_NEW_FREE_SEND_TOKEN_EVENT = 150,
01416   GM_NEW_FREE_HIGH_SEND_TOKEN_EVENT = 151,
01418   GM_NEW_BAD_RESEND_DETECTED_EVENT = 152,
01420   GM_NEW_DROPPED_SEND_EVENT = 153,
01422   GM_NEW_BAD_SEND_VMA_EVENT = 154,
01424   GM_NEW_BAD_RECV_VMA_EVENT = 155,
01426   _GM_NEW_FLUSHED_ALARM_EVENT = 156,
01428   GM_NEW_SENT_TOKENS_EVENT = 157,
01430   GM_NEW_IGNORE_RECV_EVENT = 158,
01433   GM_NUM_RECV_EVENT_TYPES
01435 };
01436 
01437 /****************
01438  * recv
01439  ****************/
01440 
01441 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01442 
01443 typedef struct gm_recv
01444 {
01445   /* Pad to GM_RDMA_GRANULARITY bytes */
01446 #if (32 % GM_RDMA_GRANULARITY)
01447   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01448 #endif
01449   /* 8 */
01450 #if GM_SIZEOF_UP_T == 4
01451   gm_u32_n_t message_pad;
01452 #endif
01453   gm_up_n_t message;
01454   /* 8 */
01455 #if GM_SIZEOF_UP_T == 4
01456   gm_u32_n_t buffer_pad;
01457 #endif
01458   gm_up_n_t buffer;
01459   /* 8 */
01460   gm_u16_n_t ip_checksum;       /* only used for GALVANTECH_WORKAROUND */
01461   gm_u16_n_t reserved_after_ip_checksum;
01462   gm_u32_n_t length;
01463   /* 8 */
01464   gm_u16_n_t sender_node_id;
01465   gm_u16_n_t reserved_after_sender_node_id;
01466   gm_u8_n_t tag;
01467   gm_u8_n_t size;
01468   gm_u8_n_t sender_port_id;
01469   gm_u8_n_t type;
01470 }
01471 gm_recv_t;
01472 
01473 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 
01474 
01475 /****************
01476  * sent token report
01477  ****************/
01478 
01479 #ifndef DOXYGEN_SHOULD_SKIP_THIS 
01480 
01481 struct _gm_sent_token_report
01482 {
01483   gm_u8_n_t token;
01484   gm_u8_n_t status;
01485 };
01486 
01487 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01488 
01489 #define GM_MAX_SENT_TOKEN_REPORTS_PER_EVENT ((GM_RDMA_GRANULARITY-2) / 2)
01490 
01491 /****************
01492  * tokens sent
01493  ****************/
01494 
01495 #ifndef DOXYGEN_SHOULD_SKIP_THIS  
01496 
01497 typedef struct gm_tokens_sent
01498 {
01499   struct _gm_sent_token_report report[31];
01500   gm_u8_n_t reserved_before_type;
01501   gm_u8_n_t type;
01502 }
01503 gm_tokens_sent_t;
01504 
01505 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 
01506 
01507 /****************
01508  * sent
01509  ****************/
01510 
01511 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01512 
01513 #define GM_TOKENS_SENT_EVENT__FIRST (ts) ((gm_u8_t *) (ts + 1) - 2)
01514 
01515 typedef struct gm_sent
01516 {
01517   /* Pad to GM_RDMA_GRANULARITY bytes */
01518 #if (32 % GM_RDMA_GRANULARITY)
01519   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01520 #endif
01521   /* Pad to 32 bytes */
01522 #if (2 * GM_SIZEOF_UP_T) % 32
01523   gm_u8_n_t _reserved[32 - (2 * GM_SIZEOF_UP_T) % 32];
01524 #endif
01525   gm_up_n_up_n_t message_list;
01526   gm_u8_n_t _reserved_after_message_list[GM_SIZEOF_UP_T - 1];
01527   gm_u8_n_t type;
01528 }
01529 gm_sent_t;
01530 
01531 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01532 
01533 /****************
01534  * failed send
01535  ****************/
01536 
01537 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01538 
01539                                 /* Struct of GM_RDMA_GRANULARITY for
01540                                    reporting rejected sends. */
01541 typedef struct gm_failed_send_event
01542 {
01543   /* Pad to GM_RDMA_GRANULARITY bytes */
01544 #if (32 % GM_RDMA_GRANULARITY)
01545   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01546 #endif
01547   /* Pad to 32 bytes */
01548   gm_u8_n_t _reserved[16];
01549   /* 8 */
01550 #if GM_SIZEOF_UP_T == 4
01551   gm_u32_n_t message_pad;
01552 #endif
01553   gm_up_n_t message;
01554   /* 8 */
01555   gm_u32_n_t reserved_after_message;
01556   gm_u16_n_t target_node_id;
01557   gm_u8_n_t target_subport_id;
01558   gm_u8_n_t type;
01559 }
01560 gm_failed_send_event_t;
01561 
01562 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01563 
01564 /****************
01565  * directed send notification
01566  ****************/
01567 
01568 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01569 
01570 typedef struct gm_directed_send_notification
01571 {
01572   /* Pad to GM_RDMA_GRANULARITY bytes */
01573 #if (32 % GM_RDMA_GRANULARITY)
01574   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01575 #endif
01576   /* 8 */
01577 #if GM_SIZEOF_UP_T == 4
01578   gm_u32_t buffer_pad;
01579 #endif
01580   gm_up_n_t buffer;
01581   /* 8 */
01582 #if GM_MAX_DMA_GRANULARITY != 8
01583 #error
01584 #endif
01585   gm_u8_n_t sender_port_id;
01586   gm_u8_n_t start_copy_bytes[GM_MAX_DMA_GRANULARITY - 1];
01587   /* 8 */
01588   gm_u8_n_t end_copy_bytes[GM_MAX_DMA_GRANULARITY];
01589   /* 8 */
01590   gm_u32_n_t length;
01591   gm_u16_n_t sender_node_id;
01592   gm_u8_n_t size;
01593   gm_u8_n_t type;
01594 }
01595 gm_directed_send_notification_t;
01596 
01597 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01598 
01599 /****************
01600  * flushed alarm
01601  ****************/
01602 
01603 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01604 
01605 typedef struct gm_flushed_alarm
01606 {
01607   /* Pad to GM_RDMA_GRANULARITY bytes */
01608 #if (32 % GM_RDMA_GRANULARITY)
01609   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01610 #endif
01611   /* Pad to 32 bytes */
01612   gm_u8_n_t _reserved[32 - 8];
01613   /* 8 */
01614   gm_u32_n_t usecs_remaining;
01615   gm_u8_n_t reserved_after_usecs_remaining[3];
01616   gm_u8_n_t type;
01617 }
01618 gm_flushed_alarm_t;
01619 
01620 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01621 
01622 /****************
01623  * recv event
01624  ****************/
01625 
01626 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01627 
01628 typedef