1 /** 2 * @file status.h 3 * @date 2014-2019 4 * @copyright Mellanox Technologies Ltd. All rights reserved. 5 * @copyright The University of Tennessee and the University of Tennessee research foundation. All rights reserved. 6 * @brief Unified Communication Services 7 */ 8 9 #ifndef UCS_TYPES_STATUS_H_ 10 #define UCS_TYPES_STATUS_H_ 11 12 #include <ucs/sys/compiler_def.h> 13 14 BEGIN_C_DECLS 15 16 /** @file status.h */ 17 18 /** 19 * @defgroup UCS_API Unified Communication Services (UCS) API 20 * @{ 21 * This section describes UCS API. 22 * @} 23 */ 24 25 /** 26 * @defgroup UCS_RESOURCE UCS Communication Resource 27 * @ingroup UCS_API 28 * @{ 29 * This section describes a concept of the Communication Resource and routines 30 * associated with the concept. 31 * @} 32 */ 33 34 /** 35 * @ingroup UCS_RESOURCE 36 * @brief Status codes 37 * 38 * @note In order to evaluate the necessary steps to recover from a certain 39 * error, all error codes which can be returned by the external API are grouped 40 * by the largest entity permanently effected by the error. Each group ranges 41 * between its UCS_ERR_FIRST_<name> and UCS_ERR_LAST_<name> enum values. 42 * For example, if a link fails it may be sufficient to destroy (and possibly 43 * replace) it, in contrast to an endpoint-level error. 44 */ 45 typedef enum { 46 /* Operation completed successfully */ 47 UCS_OK = 0, 48 49 /* Operation is queued and still in progress */ 50 UCS_INPROGRESS = 1, 51 52 /* Failure codes */ 53 UCS_ERR_NO_MESSAGE = -1, 54 UCS_ERR_NO_RESOURCE = -2, 55 UCS_ERR_IO_ERROR = -3, 56 UCS_ERR_NO_MEMORY = -4, 57 UCS_ERR_INVALID_PARAM = -5, 58 UCS_ERR_UNREACHABLE = -6, 59 UCS_ERR_INVALID_ADDR = -7, 60 UCS_ERR_NOT_IMPLEMENTED = -8, 61 UCS_ERR_MESSAGE_TRUNCATED = -9, 62 UCS_ERR_NO_PROGRESS = -10, 63 UCS_ERR_BUFFER_TOO_SMALL = -11, 64 UCS_ERR_NO_ELEM = -12, 65 UCS_ERR_SOME_CONNECTS_FAILED = -13, 66 UCS_ERR_NO_DEVICE = -14, 67 UCS_ERR_BUSY = -15, 68 UCS_ERR_CANCELED = -16, 69 UCS_ERR_SHMEM_SEGMENT = -17, 70 UCS_ERR_ALREADY_EXISTS = -18, 71 UCS_ERR_OUT_OF_RANGE = -19, 72 UCS_ERR_TIMED_OUT = -20, 73 UCS_ERR_EXCEEDS_LIMIT = -21, 74 UCS_ERR_UNSUPPORTED = -22, 75 UCS_ERR_REJECTED = -23, 76 UCS_ERR_NOT_CONNECTED = -24, 77 UCS_ERR_CONNECTION_RESET = -25, 78 79 UCS_ERR_FIRST_LINK_FAILURE = -40, 80 UCS_ERR_LAST_LINK_FAILURE = -59, 81 UCS_ERR_FIRST_ENDPOINT_FAILURE = -60, 82 UCS_ERR_LAST_ENDPOINT_FAILURE = -79, 83 UCS_ERR_ENDPOINT_TIMEOUT = -80, 84 85 UCS_ERR_LAST = -100 86 } UCS_S_PACKED ucs_status_t; 87 88 89 #define UCS_IS_LINK_ERROR(_code) \ 90 (((_code) <= UCS_ERR_FIRST_LINK_FAILURE) && \ 91 ((_code) >= UCS_ERR_LAST_LINK_FAILURE) 92 93 #define UCS_IS_ENDPOINT_ERROR(_code) \ 94 (((_code) <= UCS_ERR_FIRST_ENDPOINT_FAILURE) && \ 95 ((_code) >= UCS_ERR_LAST_ENDPOINT_FAILURE) 96 97 /** 98 * @ingroup UCS_RESOURCE 99 * @brief Status pointer 100 * 101 * A pointer can represent one of these values: 102 * - NULL / UCS_OK 103 * - Error code pointer (UCS_ERR_xx) 104 * - Valid pointer 105 */ 106 typedef void *ucs_status_ptr_t; 107 108 #define UCS_PTR_IS_ERR(_ptr) (((uintptr_t)(_ptr)) >= ((uintptr_t)UCS_ERR_LAST)) 109 #define UCS_PTR_IS_PTR(_ptr) (((uintptr_t)(_ptr) - 1) < ((uintptr_t)UCS_ERR_LAST - 1)) 110 #define UCS_PTR_RAW_STATUS(_ptr) ((ucs_status_t)(intptr_t)(_ptr)) 111 #define UCS_PTR_STATUS(_ptr) (UCS_PTR_IS_PTR(_ptr) ? UCS_INPROGRESS : UCS_PTR_RAW_STATUS(_ptr)) 112 #define UCS_STATUS_PTR(_status) ((void*)(intptr_t)(_status)) 113 #define UCS_STATUS_IS_ERR(_status) ((_status) < 0) 114 115 116 /** 117 * @param status UCS status code. 118 * 119 * @return Verbose status message. 120 */ 121 const char *ucs_status_string(ucs_status_t status); 122 123 END_C_DECLS 124 125 #endif 126