1 /** 2 * Copyright (C) Mellanox Technologies Ltd. 2001-2019. ALL RIGHTS RESERVED. 3 * 4 * See file LICENSE for terms. 5 */ 6 7 #ifndef UCS_CONFIG_TYPES_H 8 #define UCS_CONFIG_TYPES_H 9 10 #include <ucs/sys/compiler_def.h> 11 #include <sys/socket.h> 12 13 /** 14 * Logging levels. 15 */ 16 typedef enum { 17 UCS_LOG_LEVEL_FATAL, /* Immediate termination */ 18 UCS_LOG_LEVEL_ERROR, /* Error is returned to the user */ 19 UCS_LOG_LEVEL_WARN, /* Something's wrong, but we continue */ 20 UCS_LOG_LEVEL_DIAG, /* Diagnostics, silent adjustments or internal error handling */ 21 UCS_LOG_LEVEL_INFO, /* Information */ 22 UCS_LOG_LEVEL_DEBUG, /* Low-volume debugging */ 23 UCS_LOG_LEVEL_TRACE, /* High-volume debugging */ 24 UCS_LOG_LEVEL_TRACE_REQ, /* Every send/receive request */ 25 UCS_LOG_LEVEL_TRACE_DATA, /* Data sent/received on the transport */ 26 UCS_LOG_LEVEL_TRACE_ASYNC, /* Asynchronous progress engine */ 27 UCS_LOG_LEVEL_TRACE_FUNC, /* Function calls */ 28 UCS_LOG_LEVEL_TRACE_POLL, /* Polling functions */ 29 UCS_LOG_LEVEL_LAST, 30 UCS_LOG_LEVEL_PRINT /* Temporary output */ 31 } ucs_log_level_t; 32 33 34 /** 35 * Async progress mode. 36 */ 37 typedef enum { 38 UCS_ASYNC_MODE_SIGNAL, 39 UCS_ASYNC_MODE_THREAD, /* Deprecated, keep for backward compatibility */ 40 UCS_ASYNC_MODE_THREAD_SPINLOCK = UCS_ASYNC_MODE_THREAD, 41 UCS_ASYNC_MODE_THREAD_MUTEX, 42 UCS_ASYNC_MODE_POLL, /* TODO keep only in debug version */ 43 UCS_ASYNC_MODE_LAST 44 } ucs_async_mode_t; 45 46 47 extern const char *ucs_async_mode_names[]; 48 49 50 /** 51 * Ternary logic value. 52 */ 53 typedef enum ucs_ternary_value { 54 UCS_NO = 0, 55 UCS_YES = 1, 56 UCS_TRY = 2, 57 UCS_TERNARY_LAST 58 } ucs_ternary_value_t; 59 60 61 /** 62 * On/Off/Auto logic value. 63 */ 64 typedef enum ucs_on_off_auto_value { 65 UCS_CONFIG_OFF = 0, 66 UCS_CONFIG_ON = 1, 67 UCS_CONFIG_AUTO = 2, 68 UCS_CONFIG_ON_OFF_LAST 69 } ucs_on_off_auto_value_t; 70 71 72 /** 73 * Error handling modes 74 */ 75 typedef enum { 76 UCS_HANDLE_ERROR_BACKTRACE, /* Print backtrace */ 77 UCS_HANDLE_ERROR_FREEZE, /* Freeze and wait for a debugger */ 78 UCS_HANDLE_ERROR_DEBUG, /* Attach debugger */ 79 UCS_HANDLE_ERROR_LAST 80 } ucs_handle_error_t; 81 82 83 /** 84 * Configuration printing flags 85 */ 86 typedef enum { 87 UCS_CONFIG_PRINT_CONFIG = UCS_BIT(0), 88 UCS_CONFIG_PRINT_HEADER = UCS_BIT(1), 89 UCS_CONFIG_PRINT_DOC = UCS_BIT(2), 90 UCS_CONFIG_PRINT_HIDDEN = UCS_BIT(3) 91 } ucs_config_print_flags_t; 92 93 94 /** 95 * Structure type for array configuration. Should be used inside the configuration 96 * structure declaration. 97 */ 98 #define UCS_CONFIG_ARRAY_FIELD(_type, _array_name) \ 99 struct { \ 100 _type *_array_name; \ 101 unsigned count; \ 102 unsigned pad; \ 103 } 104 105 106 /* Specific structure for an array of strings */ 107 #define UCS_CONFIG_STRING_ARRAY_FIELD(_array_name) \ 108 UCS_CONFIG_ARRAY_FIELD(char*, _array_name) 109 110 111 typedef UCS_CONFIG_STRING_ARRAY_FIELD(names) ucs_config_names_array_t; 112 113 /** 114 * @ingroup UCS_RESOURCE 115 * BSD socket address specification. 116 */ 117 typedef struct ucs_sock_addr { 118 const struct sockaddr *addr; /**< Pointer to socket address */ 119 socklen_t addrlen; /**< Address length */ 120 } ucs_sock_addr_t; 121 122 /** 123 * Logging component. 124 */ 125 typedef struct ucs_log_component_config { 126 ucs_log_level_t log_level; 127 char name[16]; 128 } ucs_log_component_config_t; 129 130 #endif /* TYPES_H_ */ 131