Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file IxOsalBufferMgt.h |
| 3 | * |
| 4 | * @brief OSAL Buffer pool management and buffer management definitions. |
| 5 | * |
| 6 | * Design Notes: |
| 7 | * |
| 8 | * @par |
| 9 | * IXP400 SW Release version 2.0 |
| 10 | * |
| 11 | * -- Copyright Notice -- |
| 12 | * |
| 13 | * @par |
| 14 | * Copyright 2001-2005, Intel Corporation. |
| 15 | * All rights reserved. |
| 16 | * |
| 17 | * @par |
| 18 | * Redistribution and use in source and binary forms, with or without |
| 19 | * modification, are permitted provided that the following conditions |
| 20 | * are met: |
| 21 | * 1. Redistributions of source code must retain the above copyright |
| 22 | * notice, this list of conditions and the following disclaimer. |
| 23 | * 2. Redistributions in binary form must reproduce the above copyright |
| 24 | * notice, this list of conditions and the following disclaimer in the |
| 25 | * documentation and/or other materials provided with the distribution. |
| 26 | * 3. Neither the name of the Intel Corporation nor the names of its contributors |
| 27 | * may be used to endorse or promote products derived from this software |
| 28 | * without specific prior written permission. |
| 29 | * |
| 30 | * @par |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' |
| 32 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 33 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 34 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 35 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 39 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 40 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 41 | * SUCH DAMAGE. |
| 42 | * |
| 43 | * @par |
| 44 | * -- End of Copyright Notice -- |
| 45 | */ |
| 46 | /* @par |
| 47 | * -- Copyright Notice -- |
| 48 | * |
| 49 | * @par |
| 50 | * Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 |
| 51 | * The Regents of the University of California. All rights reserved. |
| 52 | * |
| 53 | * @par |
| 54 | * Redistribution and use in source and binary forms, with or without |
| 55 | * modification, are permitted provided that the following conditions |
| 56 | * are met: |
| 57 | * 1. Redistributions of source code must retain the above copyright |
| 58 | * notice, this list of conditions and the following disclaimer. |
| 59 | * 2. Redistributions in binary form must reproduce the above copyright |
| 60 | * notice, this list of conditions and the following disclaimer in the |
| 61 | * documentation and/or other materials provided with the distribution. |
| 62 | * 3. Neither the name of the University nor the names of its contributors |
| 63 | * may be used to endorse or promote products derived from this software |
| 64 | * without specific prior written permission. |
| 65 | * |
| 66 | * @par |
| 67 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 68 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 69 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 70 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 71 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 72 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 73 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 74 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 75 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 76 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 77 | * SUCH DAMAGE. |
| 78 | * |
| 79 | * @par |
| 80 | * -- End of Copyright Notice -- |
| 81 | */ |
| 82 | |
| 83 | #ifndef IxOsalBufferMgt_H |
| 84 | #define IxOsalBufferMgt_H |
| 85 | |
| 86 | #include "IxOsal.h" |
| 87 | /** |
| 88 | * @defgroup IxOsalBufferMgt OSAL Buffer Management Module. |
| 89 | * |
| 90 | * @brief Buffer management module for IxOsal |
| 91 | * |
| 92 | * @{ |
| 93 | */ |
| 94 | |
| 95 | /** |
| 96 | * @ingroup IxOsalBufferMgt |
| 97 | * |
| 98 | * @def IX_OSAL_MBUF_MAX_POOLS |
| 99 | * |
| 100 | * @brief The maximum number of pools that can be allocated, must be |
| 101 | * a multiple of 32 as required by implementation logic. |
| 102 | * @note This can safely be increased if more pools are required. |
| 103 | */ |
| 104 | #define IX_OSAL_MBUF_MAX_POOLS 32 |
| 105 | |
| 106 | /** |
| 107 | * @ingroup IxOsalBufferMgt |
| 108 | * |
| 109 | * @def IX_OSAL_MBUF_POOL_NAME_LEN |
| 110 | * |
| 111 | * @brief The maximum string length of the pool name |
| 112 | */ |
| 113 | #define IX_OSAL_MBUF_POOL_NAME_LEN 64 |
| 114 | |
| 115 | |
| 116 | |
| 117 | /** |
| 118 | * Define IX_OSAL_MBUF |
| 119 | */ |
| 120 | |
| 121 | |
| 122 | /* forward declaration of internal structure */ |
| 123 | struct __IXP_BUF; |
| 124 | |
| 125 | /* |
| 126 | * OS can define it in IxOsalOs.h to skip the following |
| 127 | * definition. |
| 128 | */ |
| 129 | #ifndef IX_OSAL_ATTRIBUTE_ALIGN32 |
| 130 | #define IX_OSAL_ATTRIBUTE_ALIGN32 __attribute__ ((aligned(32))) |
| 131 | #endif |
| 132 | |
| 133 | /* release v1.4 backward compatible definitions */ |
| 134 | struct __IX_MBUF |
| 135 | { |
| 136 | struct __IXP_BUF *ix_next IX_OSAL_ATTRIBUTE_ALIGN32; |
| 137 | struct __IXP_BUF *ix_nextPacket; |
| 138 | UINT8 *ix_data; |
| 139 | UINT32 ix_len; |
| 140 | unsigned char ix_type; |
| 141 | unsigned char ix_flags; |
| 142 | unsigned short ix_reserved; |
| 143 | UINT32 ix_rsvd; |
| 144 | UINT32 ix_PktLen; |
| 145 | void *ix_priv; |
| 146 | }; |
| 147 | |
| 148 | struct __IX_CTRL |
| 149 | { |
| 150 | UINT32 ix_reserved[2]; /**< Reserved field */ |
| 151 | UINT32 ix_signature; /**< Field to indicate if buffers are allocated by the system */ |
| 152 | UINT32 ix_allocated_len; /**< Allocated buffer length */ |
| 153 | UINT32 ix_allocated_data; /**< Allocated buffer data pointer */ |
| 154 | void *ix_pool; /**< pointer to the buffer pool */ |
| 155 | struct __IXP_BUF *ix_chain; /**< chaining */ |
| 156 | void *ix_osbuf_ptr; /**< Storage for OS-specific buffer pointer */ |
| 157 | }; |
| 158 | |
| 159 | struct __IX_NE_SHARED |
| 160 | { |
| 161 | UINT32 reserved[8] IX_OSAL_ATTRIBUTE_ALIGN32; /**< Reserved area for NPE Service-specific usage */ |
| 162 | }; |
| 163 | |
| 164 | |
| 165 | /* |
| 166 | * IXP buffer structure |
| 167 | */ |
| 168 | typedef struct __IXP_BUF |
| 169 | { |
| 170 | struct __IX_MBUF ix_mbuf IX_OSAL_ATTRIBUTE_ALIGN32; /**< buffer header */ |
| 171 | struct __IX_CTRL ix_ctrl; /**< buffer management */ |
| 172 | struct __IX_NE_SHARED ix_ne; /**< Reserved area for NPE Service-specific usage*/ |
| 173 | } IXP_BUF; |
| 174 | |
| 175 | |
| 176 | |
| 177 | /** |
| 178 | * @ingroup IxOsalBufferMgt |
| 179 | * |
| 180 | * @def typedef IX_OSAL_MBUF |
| 181 | * |
| 182 | * @brief Generic IXP mbuf format. |
| 183 | */ |
| 184 | typedef IXP_BUF IX_OSAL_MBUF; |
| 185 | |
| 186 | |
| 187 | /** |
| 188 | * @ingroup IxOsalBufferMgt |
| 189 | * |
| 190 | * @def IX_OSAL_IXP_NEXT_BUFFER_IN_PKT_PTR(m_blk_ptr) |
| 191 | * |
| 192 | * @brief Return pointer to the next mbuf in a single packet |
| 193 | */ |
| 194 | #define IX_OSAL_MBUF_NEXT_BUFFER_IN_PKT_PTR(m_blk_ptr) \ |
| 195 | (m_blk_ptr)->ix_mbuf.ix_next |
| 196 | |
| 197 | |
| 198 | /** |
| 199 | * @ingroup IxOsalBufferMgt |
| 200 | * |
| 201 | * @def IX_OSAL_MBUF_NEXT_PKT_IN_CHAIN_PTR(m_blk_ptr) |
| 202 | * |
| 203 | * @brief Return pointer to the next packet in the chain |
| 204 | */ |
| 205 | #define IX_OSAL_MBUF_NEXT_PKT_IN_CHAIN_PTR(m_blk_ptr) \ |
| 206 | (m_blk_ptr)->ix_mbuf.ix_nextPacket |
| 207 | |
| 208 | |
| 209 | /** |
| 210 | * @ingroup IxOsalBufferMgt |
| 211 | * |
| 212 | * @def IX_OSAL_MBUF_MDATA(m_blk_ptr) |
| 213 | * |
| 214 | * @brief Return pointer to the data in the mbuf |
| 215 | */ |
| 216 | #define IX_OSAL_MBUF_MDATA(m_blk_ptr) (m_blk_ptr)->ix_mbuf.ix_data |
| 217 | |
| 218 | /** |
| 219 | * @ingroup IxOsalBufferMgt |
| 220 | * |
| 221 | * @def IX_OSAL_MBUF_MLEN(m_blk_ptr) |
| 222 | * |
| 223 | * @brief Return the data length |
| 224 | */ |
| 225 | #define IX_OSAL_MBUF_MLEN(m_blk_ptr) \ |
| 226 | (m_blk_ptr)->ix_mbuf.ix_len |
| 227 | |
| 228 | /** |
| 229 | * @ingroup IxOsalBufferMgt |
| 230 | * |
| 231 | * @def IX_OSAL_MBUF_MTYPE(m_blk_ptr) |
| 232 | * |
| 233 | * @brief Return the data type in the mbuf |
| 234 | */ |
| 235 | #define IX_OSAL_MBUF_MTYPE(m_blk_ptr) \ |
| 236 | (m_blk_ptr)->ix_mbuf.ix_type |
| 237 | |
| 238 | |
| 239 | /** |
| 240 | * @ingroup IxOsalBufferMgt |
| 241 | * |
| 242 | * @def IX_OSAL_MBUF_FLAGS(m_blk_ptr) |
| 243 | * |
| 244 | * @brief Return the buffer flags |
| 245 | */ |
| 246 | #define IX_OSAL_MBUF_FLAGS(m_blk_ptr) \ |
| 247 | (m_blk_ptr)->ix_mbuf.ix_flags |
| 248 | |
| 249 | |
| 250 | /** |
| 251 | * @ingroup IxOsalBufferMgt |
| 252 | * |
| 253 | * @def IX_OSAL_MBUF_NET_POOL(m_blk_ptr) |
| 254 | * |
| 255 | * @brief Return pointer to a network pool |
| 256 | */ |
| 257 | #define IX_OSAL_MBUF_NET_POOL(m_blk_ptr) \ |
| 258 | (m_blk_ptr)->ix_ctrl.ix_pool |
| 259 | |
| 260 | |
| 261 | |
| 262 | /** |
| 263 | * @ingroup IxOsalBufferMgt |
| 264 | * |
| 265 | * @def IX_OSAL_MBUF_PKT_LEN(m_blk_ptr) |
| 266 | * |
| 267 | * @brief Return the total length of all the data in |
| 268 | * the mbuf chain for this packet |
| 269 | */ |
| 270 | #define IX_OSAL_MBUF_PKT_LEN(m_blk_ptr) \ |
| 271 | (m_blk_ptr)->ix_mbuf.ix_PktLen |
| 272 | |
| 273 | |
| 274 | |
| 275 | |
| 276 | /** |
| 277 | * @ingroup IxOsalBufferMgt |
| 278 | * |
| 279 | * @def IX_OSAL_MBUF_PRIV(m_blk_ptr) |
| 280 | * |
| 281 | * @brief Return the private field |
| 282 | */ |
| 283 | #define IX_OSAL_MBUF_PRIV(m_blk_ptr) \ |
| 284 | (m_blk_ptr)->ix_mbuf.ix_priv |
| 285 | |
| 286 | |
| 287 | |
| 288 | /** |
| 289 | * @ingroup IxOsalBufferMgt |
| 290 | * |
| 291 | * @def IX_OSAL_MBUF_SIGNATURE(m_blk_ptr) |
| 292 | * |
| 293 | * @brief Return the signature field of IX_OSAL_MBUF |
| 294 | */ |
| 295 | #define IX_OSAL_MBUF_SIGNATURE(m_blk_ptr) \ |
| 296 | (m_blk_ptr)->ix_ctrl.ix_signature |
| 297 | |
| 298 | |
| 299 | /** |
| 300 | * @ingroup IxOsalBufferMgt |
| 301 | * |
| 302 | * @def IX_OSAL_MBUF_OSBUF_PTR(m_blk_ptr) |
| 303 | * |
| 304 | * @brief Return ix_osbuf_ptr field of IX_OSAL_MBUF, which is used to store OS-specific buffer pointer during a buffer conversion. |
| 305 | */ |
| 306 | #define IX_OSAL_MBUF_OSBUF_PTR(m_blk_ptr) \ |
| 307 | (m_blk_ptr)->ix_ctrl.ix_osbuf_ptr |
| 308 | |
| 309 | |
| 310 | /** |
| 311 | * @ingroup IxOsalBufferMgt |
| 312 | * |
| 313 | * @def IX_OSAL_MBUF_ALLOCATED_BUFF_LEN(m_blk_ptr) |
| 314 | * |
| 315 | * @brief Return the allocated buffer size |
| 316 | */ |
| 317 | #define IX_OSAL_MBUF_ALLOCATED_BUFF_LEN(m_blk_ptr) \ |
| 318 | (m_blk_ptr)->ix_ctrl.ix_allocated_len |
| 319 | |
| 320 | /** |
| 321 | * @ingroup IxOsalBufferMgt |
| 322 | * |
| 323 | * @def IX_OSAL_MBUF_ALLOCATED_BUFF_DATA(m_blk_ptr) |
| 324 | * |
| 325 | * @brief Return the allocated buffer pointer |
| 326 | */ |
| 327 | #define IX_OSAL_MBUF_ALLOCATED_BUFF_DATA(m_blk_ptr) \ |
| 328 | (m_blk_ptr)->ix_ctrl.ix_allocated_data |
| 329 | |
| 330 | |
| 331 | |
| 332 | /* Name length */ |
| 333 | #define IX_OSAL_MBUF_POOL_NAME_LEN 64 |
| 334 | |
| 335 | |
| 336 | /**************************************************** |
| 337 | * Macros for buffer pool management |
| 338 | ****************************************************/ |
| 339 | |
| 340 | /** |
| 341 | * @ingroup IxOsalBufferMgt |
| 342 | * |
| 343 | * @def IX_OSAL_MBUF_POOL_FREE_COUNT(m_pool_ptr |
| 344 | * |
| 345 | * @brief Return the total number of freed buffers left in the pool. |
| 346 | */ |
| 347 | #define IX_OSAL_MBUF_POOL_FREE_COUNT(m_pool_ptr) \ |
| 348 | ixOsalBuffPoolFreeCountGet(m_pool_ptr) |
| 349 | |
| 350 | /** |
| 351 | * @ingroup IxOsalBufferMgt |
| 352 | * |
| 353 | * @def IX_OSAL_MBUF_POOL_SIZE_ALIGN |
| 354 | * |
| 355 | * @brief This macro takes an integer as an argument and |
| 356 | * rounds it up to be a multiple of the memory cache-line |
| 357 | * size. |
| 358 | * |
| 359 | * @param int [in] size - the size integer to be rounded up |
| 360 | * |
| 361 | * @return int - the size, rounded up to a multiple of |
| 362 | * the cache-line size |
| 363 | */ |
| 364 | #define IX_OSAL_MBUF_POOL_SIZE_ALIGN(size) \ |
| 365 | ((((size) + (IX_OSAL_CACHE_LINE_SIZE - 1)) / \ |
| 366 | IX_OSAL_CACHE_LINE_SIZE) * \ |
| 367 | IX_OSAL_CACHE_LINE_SIZE) |
| 368 | |
| 369 | /* Don't use this directly, use macro */ |
| 370 | PUBLIC UINT32 ixOsalBuffPoolMbufAreaSizeGet (int count); |
| 371 | |
| 372 | |
| 373 | /** |
| 374 | * @ingroup IxOsalBufferMgt |
| 375 | * |
| 376 | * @def IX_OSAL_MBUF_POOL_MBUF_AREA_SIZE_ALIGNED |
| 377 | * |
| 378 | * @brief This macro calculates, from the number of mbufs required, the |
| 379 | * size of the memory area required to contain the mbuf headers for the |
| 380 | * buffers in the pool. The size to be used for each mbuf header is |
| 381 | * rounded up to a multiple of the cache-line size, to ensure |
| 382 | * each mbuf header aligns on a cache-line boundary. |
| 383 | * This macro is used by IX_OSAL_MBUF_POOL_MBUF_AREA_ALLOC() |
| 384 | * |
| 385 | * @param int [in] count - the number of buffers the pool will contain |
| 386 | * |
| 387 | * @return int - the total size required for the pool mbuf area (aligned) |
| 388 | */ |
| 389 | #define IX_OSAL_MBUF_POOL_MBUF_AREA_SIZE_ALIGNED(count) \ |
| 390 | ixOsalBuffPoolMbufAreaSizeGet(count) |
| 391 | |
| 392 | |
| 393 | /* Don't use this directly, use macro */ |
| 394 | PUBLIC UINT32 ixOsalBuffPoolDataAreaSizeGet (int count, int size); |
| 395 | |
| 396 | |
| 397 | /** |
| 398 | * @ingroup IxOsalBufferMgt |
| 399 | * |
| 400 | * @def IX_OSAL_MBUF_POOL_DATA_AREA_SIZE_ALIGNED |
| 401 | * |
| 402 | * @brief This macro calculates, from the number of mbufs required and the |
| 403 | * size of the data portion for each mbuf, the size of the data memory area |
| 404 | * required. The size is adjusted to ensure alignment on cache line boundaries. |
| 405 | * This macro is used by IX_OSAL_MBUF_POOL_DATA_AREA_ALLOC() |
| 406 | * |
| 407 | * |
| 408 | * @param int [in] count - The number of mbufs in the pool. |
| 409 | * @param int [in] size - The desired size for each mbuf data portion. |
| 410 | * This size will be rounded up to a multiple of the |
| 411 | * cache-line size to ensure alignment on cache-line |
| 412 | * boundaries for each data block. |
| 413 | * |
| 414 | * @return int - the total size required for the pool data area (aligned) |
| 415 | */ |
| 416 | #define IX_OSAL_MBUF_POOL_DATA_AREA_SIZE_ALIGNED(count, size) \ |
| 417 | ixOsalBuffPoolDataAreaSizeGet((count), (size)) |
| 418 | |
| 419 | |
| 420 | /** |
| 421 | * @ingroup IxOsalBufferMgt |
| 422 | * |
| 423 | * @def IX_OSAL_MBUF_POOL_MBUF_AREA_ALLOC |
| 424 | * |
| 425 | * @brief Allocates the memory area needed for the number of mbuf headers |
| 426 | * specified by <i>count</i>. |
| 427 | * This macro ensures the mbuf headers align on cache line boundaries. |
| 428 | * This macro evaluates to a pointer to the memory allocated. |
| 429 | * |
| 430 | * @param int [in] count - the number of mbufs the pool will contain |
| 431 | * @param int [out] memAreaSize - the total amount of memory allocated |
| 432 | * |
| 433 | * @return void * - a pointer to the allocated memory area |
| 434 | */ |
| 435 | #define IX_OSAL_MBUF_POOL_MBUF_AREA_ALLOC(count, memAreaSize) \ |
| 436 | IX_OSAL_CACHE_DMA_MALLOC((memAreaSize = \ |
| 437 | IX_OSAL_MBUF_POOL_MBUF_AREA_SIZE_ALIGNED(count))) |
| 438 | |
| 439 | /** |
| 440 | * @ingroup IxOsalBufferMgt |
| 441 | * |
| 442 | * @def IX_OSAL_MBUF_POOL_DATA_AREA_ALLOC |
| 443 | * |
| 444 | * @brief Allocates the memory pool for the data portion of the pool mbufs. |
| 445 | * The number of mbufs is specified by <i>count</i>. The size of the data |
| 446 | * portion of each mbuf is specified by <i>size</i>. |
| 447 | * This macro ensures the mbufs are aligned on cache line boundaries |
| 448 | * This macro evaluates to a pointer to the memory allocated. |
| 449 | * |
| 450 | * @param int [in] count - the number of mbufs the pool will contain |
| 451 | * @param int [in] size - the desired size (in bytes) required for the data |
| 452 | * portion of each mbuf. Note that this size may be |
| 453 | * rounded up to ensure alignment on cache-line |
| 454 | * boundaries. |
| 455 | * @param int [out] memAreaSize - the total amount of memory allocated |
| 456 | * |
| 457 | * @return void * - a pointer to the allocated memory area |
| 458 | */ |
| 459 | #define IX_OSAL_MBUF_POOL_DATA_AREA_ALLOC(count, size, memAreaSize) \ |
| 460 | IX_OSAL_CACHE_DMA_MALLOC((memAreaSize = \ |
| 461 | IX_OSAL_MBUF_POOL_DATA_AREA_SIZE_ALIGNED(count,size))) |
| 462 | |
| 463 | |
| 464 | |
| 465 | /** |
| 466 | * @ingroup IxOsalBufferMgt |
| 467 | * |
| 468 | * @def IX_OSAL_MBUF_POOL_INIT |
| 469 | * |
| 470 | * @brief Wrapper macro for ixOsalPoolInit() |
| 471 | * See function description below for details. |
| 472 | */ |
| 473 | #define IX_OSAL_MBUF_POOL_INIT(count, size, name) \ |
| 474 | ixOsalPoolInit((count), (size), (name)) |
| 475 | |
| 476 | /** |
| 477 | * @ingroup IxOsalBufferMgt |
| 478 | * |
| 479 | * @def IX_OSAL_MBUF_NO_ALLOC_POOL_INIT |
| 480 | * |
| 481 | * @return Pointer to the new pool or NULL if the initialization failed. |
| 482 | * |
| 483 | * @brief Wrapper macro for ixOsalNoAllocPoolInit() |
| 484 | * See function description below for details. |
| 485 | * |
| 486 | */ |
| 487 | #define IX_OSAL_MBUF_NO_ALLOC_POOL_INIT(bufPtr, dataPtr, count, size, name) \ |
| 488 | ixOsalNoAllocPoolInit( (bufPtr), (dataPtr), (count), (size), (name)) |
| 489 | |
| 490 | /** |
| 491 | * @ingroup IxOsalBufferMgt |
| 492 | * |
| 493 | * @def IX_OSAL_MBUF_POOL_GET |
| 494 | * |
| 495 | * @brief Wrapper macro for ixOsalMbufAlloc() |
| 496 | * See function description below for details. |
| 497 | */ |
| 498 | #define IX_OSAL_MBUF_POOL_GET(poolPtr) \ |
| 499 | ixOsalMbufAlloc(poolPtr) |
| 500 | |
| 501 | /** |
| 502 | * @ingroup IxOsalBufferMgt |
| 503 | * |
| 504 | * @def IX_OSAL_MBUF_POOL_PUT |
| 505 | * |
| 506 | * @brief Wrapper macro for ixOsalMbufFree() |
| 507 | * See function description below for details. |
| 508 | */ |
| 509 | #define IX_OSAL_MBUF_POOL_PUT(bufPtr) \ |
| 510 | ixOsalMbufFree(bufPtr) |
| 511 | |
| 512 | /** |
| 513 | * @ingroup IxOsalBufferMgt |
| 514 | * |
| 515 | * @def IX_OSAL_MBUF_POOL_PUT_CHAIN |
| 516 | * |
| 517 | * @brief Wrapper macro for ixOsalMbufChainFree() |
| 518 | * See function description below for details. |
| 519 | */ |
| 520 | #define IX_OSAL_MBUF_POOL_PUT_CHAIN(bufPtr) \ |
| 521 | ixOsalMbufChainFree(bufPtr) |
| 522 | |
| 523 | /** |
| 524 | * @ingroup IxOsalBufferMgt |
| 525 | * |
| 526 | * @def IX_OSAL_MBUF_POOL_SHOW |
| 527 | * |
| 528 | * @brief Wrapper macro for ixOsalMbufPoolShow() |
| 529 | * See function description below for details. |
| 530 | */ |
| 531 | #define IX_OSAL_MBUF_POOL_SHOW(poolPtr) \ |
| 532 | ixOsalMbufPoolShow(poolPtr) |
| 533 | |
| 534 | /** |
| 535 | * @ingroup IxOsalBufferMgt |
| 536 | * |
| 537 | * @def IX_OSAL_MBUF_POOL_MDATA_RESET |
| 538 | * |
| 539 | * @brief Wrapper macro for ixOsalMbufDataPtrReset() |
| 540 | * See function description below for details. |
| 541 | */ |
| 542 | #define IX_OSAL_MBUF_POOL_MDATA_RESET(bufPtr) \ |
| 543 | ixOsalMbufDataPtrReset(bufPtr) |
| 544 | |
| 545 | /** |
| 546 | * @ingroup IxOsalBufferMgt |
| 547 | * |
| 548 | * @def IX_OSAL_MBUF_POOL_UNINIT |
| 549 | * |
| 550 | * @brief Wrapper macro for ixOsalBuffPoolUninit() |
| 551 | * See function description below for details. |
| 552 | */ |
| 553 | #define IX_OSAL_MBUF_POOL_UNINIT(m_pool_ptr) \ |
| 554 | ixOsalBuffPoolUninit(m_pool_ptr) |
| 555 | |
| 556 | /* |
| 557 | * Include OS-specific bufferMgt definitions |
| 558 | */ |
| 559 | #include "IxOsalOsBufferMgt.h" |
| 560 | |
| 561 | |
| 562 | /** |
| 563 | * @ingroup IxOsalBufferMgt |
| 564 | * |
| 565 | * @def IX_OSAL_CONVERT_OSBUF_TO_IXPBUF( osBufPtr, ixpBufPtr) |
| 566 | * |
| 567 | * @brief Convert pre-allocated os-specific buffer format to OSAL IXP_BUF (IX_OSAL_MBUF) format. |
| 568 | * It is users' responsibility to provide pre-allocated and valid buffer pointers. |
| 569 | * @param osBufPtr (in) - a pre-allocated os-specific buffer pointer. |
| 570 | * @param ixpBufPtr (in)- a pre-allocated OSAL IXP_BUF pointer |
| 571 | * @return None |
| 572 | */ |
| 573 | #define IX_OSAL_CONVERT_OSBUF_TO_IXPBUF( osBufPtr, ixpBufPtr) \ |
| 574 | IX_OSAL_OS_CONVERT_OSBUF_TO_IXPBUF( osBufPtr, ixpBufPtr) |
| 575 | |
| 576 | |
| 577 | /** |
| 578 | * @ingroup IxOsalBufferMgt |
| 579 | * |
| 580 | * @def IX_OSAL_CONVERT_IXPBUF_TO_OSBUF( ixpBufPtr, osBufPtr) |
| 581 | * |
| 582 | * @brief Convert pre-allocated OSAL IXP_BUF (IX_OSAL_MBUF) format to os-specific buffer pointers. |
| 583 | * @param ixpBufPtr (in) - OSAL IXP_BUF pointer |
| 584 | * @param osBufPtr (out) - os-specific buffer pointer. |
| 585 | * @return None |
| 586 | */ |
| 587 | |
| 588 | #define IX_OSAL_CONVERT_IXPBUF_TO_OSBUF( ixpBufPtr, osBufPtr) \ |
| 589 | IX_OSAL_OS_CONVERT_IXPBUF_TO_OSBUF( ixpBufPtr, osBufPtr) |
| 590 | |
| 591 | |
| 592 | PUBLIC IX_OSAL_MBUF_POOL *ixOsalPoolInit (UINT32 count, |
| 593 | UINT32 size, const char *name); |
| 594 | |
| 595 | PUBLIC IX_OSAL_MBUF_POOL *ixOsalNoAllocPoolInit (void *poolBufPtr, |
| 596 | void *poolDataPtr, |
| 597 | UINT32 count, |
| 598 | UINT32 size, |
| 599 | const char *name); |
| 600 | |
| 601 | PUBLIC IX_OSAL_MBUF *ixOsalMbufAlloc (IX_OSAL_MBUF_POOL * pool); |
| 602 | |
| 603 | PUBLIC IX_OSAL_MBUF *ixOsalMbufFree (IX_OSAL_MBUF * mbuf); |
| 604 | |
| 605 | PUBLIC void ixOsalMbufChainFree (IX_OSAL_MBUF * mbuf); |
| 606 | |
| 607 | PUBLIC void ixOsalMbufDataPtrReset (IX_OSAL_MBUF * mbuf); |
| 608 | |
| 609 | PUBLIC void ixOsalMbufPoolShow (IX_OSAL_MBUF_POOL * pool); |
| 610 | |
| 611 | PUBLIC IX_STATUS ixOsalBuffPoolUninit (IX_OSAL_MBUF_POOL * pool); |
| 612 | |
| 613 | PUBLIC UINT32 ixOsalBuffPoolFreeCountGet(IX_OSAL_MBUF_POOL * pool); |
| 614 | |
| 615 | |
| 616 | /** |
| 617 | * @} IxOsalBufferMgt |
| 618 | */ |
| 619 | |
| 620 | |
| 621 | #endif /* IxOsalBufferMgt_H */ |