1 /***************************************************************************/ /** 2 * @file rsi_pkt_mgmt.h 3 ******************************************************************************* 4 * # License 5 * <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b> 6 ******************************************************************************* 7 * 8 * SPDX-License-Identifier: Zlib 9 * 10 * The licensor of this software is Silicon Laboratories Inc. 11 * 12 * This software is provided 'as-is', without any express or implied 13 * warranty. In no event will the authors be held liable for any damages 14 * arising from the use of this software. 15 * 16 * Permission is granted to anyone to use this software for any purpose, 17 * including commercial applications, and to alter it and redistribute it 18 * freely, subject to the following restrictions: 19 * 20 * 1. The origin of this software must not be misrepresented; you must not 21 * claim that you wrote the original software. If you use this software 22 * in a product, an acknowledgment in the product documentation would be 23 * appreciated but is not required. 24 * 2. Altered source versions must be plainly marked as such, and must not be 25 * misrepresented as being the original software. 26 * 3. This notice may not be removed or altered from any source distribution. 27 * 28 ******************************************************************************/ 29 30 #ifndef RSI_PKT_MGMT_H 31 #define RSI_PKT_MGMT_H 32 33 #include "rsi_os.h" 34 #include <stdint.h> 35 #if ((defined RSI_SDIO_INTERFACE) && (defined SLI_SI917)) 36 #define SIZE_OF_HEADROOM 216 37 #else 38 #define SIZE_OF_HEADROOM 0 39 #endif 40 /****************************************************** 41 * * Macros 42 * ******************************************************/ 43 /****************************************************** 44 * * Constants 45 * ******************************************************/ 46 /****************************************************** 47 * * Enumerations 48 * ******************************************************/ 49 /****************************************************** 50 * * Type Definitions 51 * ******************************************************/ 52 // driver TX/RX packet structure 53 typedef struct rsi_pkt_s { 54 // next packet pointer 55 struct rsi_pkt_s *next; 56 57 #if ((defined RSI_SDIO_INTERFACE) && (defined SLI_SI917)) 58 uint8_t headroom[SIZE_OF_HEADROOM]; 59 #endif 60 61 // host descriptor 62 uint8_t desc[16]; 63 64 // payload 65 uint8_t data[1]; 66 } rsi_pkt_t; 67 68 // packet pool structure 69 typedef struct rsi_pkt_pool_s { 70 // Pool total packets count 71 uint16_t size; 72 73 // Pool avaialble packets count 74 uint16_t avail; 75 76 // Pool pointer 77 void **pool; 78 79 rsi_semaphore_handle_t pkt_sem; 80 81 } rsi_pkt_pool_t; 82 83 /****************************************************** 84 * * Structures 85 * ******************************************************/ 86 /****************************************************** 87 * * Global Variables 88 * ******************************************************/ 89 /****************************************************** 90 * * Function Declarations 91 * ******************************************************/ 92 int32_t rsi_pkt_pool_init(rsi_pkt_pool_t *pool_cb, uint8_t *buffer, uint32_t total_size, uint32_t pkt_size); 93 rsi_pkt_t *rsi_pkt_alloc(rsi_pkt_pool_t *pool_cb); 94 int32_t rsi_pkt_free(rsi_pkt_pool_t *pool_cb, rsi_pkt_t *pkt); 95 uint32_t rsi_is_pkt_available(rsi_pkt_pool_t *pool_cb); 96 #endif 97