1 /*************************************************************************** 2 * 3 * BSD LICENSE 4 * 5 * Copyright(c) 2007-2022 Intel Corporation. All rights reserved. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * * Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in 16 * the documentation and/or other materials provided with the 17 * distribution. 18 * * Neither the name of Intel Corporation nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 * 35 ***************************************************************************/ 36 37 /* 38 ***************************************************************************** 39 * Doxygen group definitions 40 ****************************************************************************/ 41 42 /** 43 ***************************************************************************** 44 * @file cpa_types.h 45 * 46 * @defgroup cpa_Types CPA Type Definition 47 * 48 * @ingroup cpa 49 * 50 * @description 51 * This is the CPA Type Definitions. 52 * 53 *****************************************************************************/ 54 55 #ifndef CPA_TYPES_H 56 #define CPA_TYPES_H 57 58 #ifdef __cplusplus 59 extern "C" { 60 #endif 61 62 #if defined (__FreeBSD__) && defined (_KERNEL) 63 64 /* FreeBSD kernel mode */ 65 #include <sys/types.h> 66 #include <sys/param.h> 67 #include <sys/kernel.h> 68 69 #else 70 71 /* Linux, FreeBSD, or Windows user mode */ 72 #include <stdio.h> 73 #include <stddef.h> 74 #include <stdint.h> 75 76 #endif 77 78 #if defined (WIN32) || defined (_WIN64) 79 /* nonstandard extension used : zero-sized array in struct/union */ 80 #pragma warning (disable: 4200) 81 #endif 82 83 typedef uint8_t Cpa8U; 84 /**< 85 * @file cpa_types.h 86 * @ingroup cpa_Types 87 * Unsigned byte base type. */ 88 typedef int8_t Cpa8S; 89 /**< 90 * @file cpa_types.h 91 * @ingroup cpa_Types 92 * Signed byte base type. */ 93 typedef uint16_t Cpa16U; 94 /**< 95 * @file cpa_types.h 96 * @ingroup cpa_Types 97 * Unsigned double-byte base type. */ 98 typedef int16_t Cpa16S; 99 /**< 100 * @file cpa_types.h 101 * @ingroup cpa_Types 102 * Signed double-byte base type. */ 103 typedef uint32_t Cpa32U; 104 /**< 105 * @file cpa_types.h 106 * @ingroup cpa_Types 107 * Unsigned quad-byte base type. */ 108 typedef int32_t Cpa32S; 109 /**< 110 * @file cpa_types.h 111 * @ingroup cpa_Types 112 * Signed quad-byte base type. */ 113 typedef uint64_t Cpa64U; 114 /**< 115 * @file cpa_types.h 116 * @ingroup cpa_Types 117 * Unsigned double-quad-byte base type. */ 118 typedef int64_t Cpa64S; 119 /**< 120 * @file cpa_types.h 121 * @ingroup cpa_Types 122 * Signed double-quad-byte base type. */ 123 124 /***************************************************************************** 125 * Generic Base Data Type definitions 126 *****************************************************************************/ 127 #ifndef NULL 128 #define NULL (0) 129 /**< 130 * @file cpa_types.h 131 * @ingroup cpa_Types 132 * NULL definition. */ 133 #endif 134 135 #ifndef TRUE 136 #define TRUE (1==1) 137 /**< 138 * @file cpa_types.h 139 * @ingroup cpa_Types 140 * True value definition. */ 141 #endif 142 #ifndef FALSE 143 #define FALSE (0==1) 144 /**< 145 * @file cpa_types.h 146 * @ingroup cpa_Types 147 * False value definition. */ 148 #endif 149 150 /** 151 ***************************************************************************** 152 * @ingroup cpa_Types 153 * Boolean type. 154 * 155 * @description 156 * Functions in this API use this type for Boolean variables that take 157 * true or false values. 158 * 159 *****************************************************************************/ 160 typedef enum _CpaBoolean 161 { 162 CPA_FALSE = FALSE, /**< False value */ 163 CPA_TRUE = TRUE /**< True value */ 164 } CpaBoolean; 165 166 167 /** 168 ***************************************************************************** 169 * @ingroup cpa_Types 170 * Declare a bitmap of specified size (in bits). 171 * 172 * @description 173 * This macro is used to declare a bitmap of arbitrary size. 174 * 175 * To test whether a bit in the bitmap is set, use @ref 176 * CPA_BITMAP_BIT_TEST. 177 * 178 * While most uses of bitmaps on the API are read-only, macros are also 179 * provided to set (see @ref CPA_BITMAP_BIT_SET) and clear (see @ref 180 * CPA_BITMAP_BIT_CLEAR) bits in the bitmap. 181 *****************************************************************************/ 182 #define CPA_BITMAP(name, sizeInBits) \ 183 Cpa32U name[((sizeInBits)+31)/32] 184 185 #define CPA_BITMAP_BIT_TEST(bitmask, bit) \ 186 ((bitmask[(bit)/32]) & (0x1 << ((bit)%32))) 187 /**< 188 * @ingroup cpa_Types 189 * Test a specified bit in the specified bitmap. The bitmap may have been 190 * declared using @ref CPA_BITMAP. Returns a Boolean (true if the bit is 191 * set, false otherwise). */ 192 193 #define CPA_BITMAP_BIT_SET(bitmask, bit) \ 194 (bitmask[(bit)/32] |= (0x1 << ((bit)%32))) 195 /**< 196 * @file cpa_types.h 197 * @ingroup cpa_Types 198 * Set a specified bit in the specified bitmap. The bitmap may have been 199 * declared using @ref CPA_BITMAP. */ 200 201 #define CPA_BITMAP_BIT_CLEAR(bitmask, bit) \ 202 (bitmask[(bit)/32] &= ~(0x1 << ((bit)%32))) 203 /**< 204 * @ingroup cpa_Types 205 * Clear a specified bit in the specified bitmap. The bitmap may have been 206 * declared using @ref CPA_BITMAP. */ 207 208 209 /** 210 ********************************************************************** 211 * 212 * @ingroup cpa_Types 213 * 214 * @description 215 * Declare a function or type and mark it as deprecated so that 216 * usages get flagged with a warning. 217 * 218 ********************************************************************** 219 */ 220 #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(_WIN64) 221 /* 222 * gcc and icc support the __attribute__ ((deprecated)) syntax for marking 223 * functions and other constructs as deprecated. 224 */ 225 /* 226 * Uncomment the deprecated macro if you need to see which structs are deprecated 227 */ 228 #define CPA_DEPRECATED 229 /*#define CPA_DEPRECATED __attribute__ ((deprecated)) */ 230 #else 231 /* 232 * for all other compilers, define deprecated to do nothing 233 * 234 */ 235 /* #define CPA_DEPRECATED_FUNC(func) func; #pragma deprecated(func) */ 236 #pragma message("WARNING: You need to implement the CPA_DEPRECATED macro for this compiler") 237 #define CPA_DEPRECATED 238 #endif 239 240 #ifdef __cplusplus 241 } /* close the extern "C" { */ 242 #endif 243 244 #endif /* CPA_TYPES_H */ 245