| .. | .. |
|---|
| 1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 2 | 1 | /* |
|---|
| 3 | 2 | * HND generic packet pool operation primitives |
|---|
| 4 | 3 | * |
|---|
| 5 | | - * Copyright (C) 1999-2019, Broadcom Corporation |
|---|
| 6 | | - * |
|---|
| 4 | + * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation |
|---|
| 5 | + * |
|---|
| 6 | + * Copyright (C) 1999-2017, Broadcom Corporation |
|---|
| 7 | + * |
|---|
| 7 | 8 | * Unless you and Broadcom execute a separate written software license |
|---|
| 8 | 9 | * agreement governing use of this software, this software is licensed to you |
|---|
| 9 | 10 | * under the terms of the GNU General Public License version 2 (the "GPL"), |
|---|
| 10 | 11 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the |
|---|
| 11 | 12 | * following added to such license: |
|---|
| 12 | | - * |
|---|
| 13 | + * |
|---|
| 13 | 14 | * As a special exception, the copyright holders of this software give you |
|---|
| 14 | 15 | * permission to link this software with independent modules, and to copy and |
|---|
| 15 | 16 | * distribute the resulting executable under terms of your choice, provided that |
|---|
| .. | .. |
|---|
| 17 | 18 | * the license of that module. An independent module is a module which is not |
|---|
| 18 | 19 | * derived from this software. The special exception does not apply to any |
|---|
| 19 | 20 | * modifications of the software. |
|---|
| 20 | | - * |
|---|
| 21 | + * |
|---|
| 21 | 22 | * Notwithstanding the above, under no circumstances may you combine this |
|---|
| 22 | 23 | * software in any way with any other Broadcom software provided under a license |
|---|
| 23 | 24 | * other than the GPL, without Broadcom's express prior written consent. |
|---|
| .. | .. |
|---|
| 25 | 26 | * |
|---|
| 26 | 27 | * <<Broadcom-WL-IPTag/Open:>> |
|---|
| 27 | 28 | * |
|---|
| 28 | | - * $Id: $ |
|---|
| 29 | + * $Id: hnd_pktpool.h 633941 2016-04-26 07:04:26Z $ |
|---|
| 29 | 30 | */ |
|---|
| 30 | 31 | |
|---|
| 31 | 32 | #ifndef _hnd_pktpool_h_ |
|---|
| .. | .. |
|---|
| 35 | 36 | |
|---|
| 36 | 37 | #ifdef __cplusplus |
|---|
| 37 | 38 | extern "C" { |
|---|
| 38 | | -#endif |
|---|
| 39 | +#endif // endif |
|---|
| 39 | 40 | |
|---|
| 40 | 41 | /* mutex macros for thread safe */ |
|---|
| 41 | 42 | #ifdef HND_PKTPOOL_THREAD_SAFE |
|---|
| 42 | 43 | #define HND_PKTPOOL_MUTEX_DECL(mutex) OSL_EXT_MUTEX_DECL(mutex) |
|---|
| 43 | 44 | #else |
|---|
| 44 | 45 | #define HND_PKTPOOL_MUTEX_DECL(mutex) |
|---|
| 45 | | -#endif |
|---|
| 46 | +#endif // endif |
|---|
| 46 | 47 | |
|---|
| 47 | 48 | #ifdef BCMPKTPOOL |
|---|
| 48 | 49 | #define POOL_ENAB(pool) ((pool) && (pool)->inited) |
|---|
| .. | .. |
|---|
| 56 | 57 | #define PKTPOOL_CB_MAX 3 |
|---|
| 57 | 58 | #define PKTPOOL_CB_MAX_AVL 4 |
|---|
| 58 | 59 | |
|---|
| 60 | +/* REMOVE_RXCPLID is an arg for pktpool callback function for removing rxcplID |
|---|
| 61 | + * and host addr associated with the rxfrag or shared pool buffer during pktpool_reclaim(). |
|---|
| 62 | + */ |
|---|
| 63 | +#define REMOVE_RXCPLID 2 |
|---|
| 59 | 64 | |
|---|
| 60 | 65 | /* forward declaration */ |
|---|
| 61 | 66 | struct pktpool; |
|---|
| .. | .. |
|---|
| 64 | 69 | typedef struct { |
|---|
| 65 | 70 | pktpool_cb_t cb; |
|---|
| 66 | 71 | void *arg; |
|---|
| 72 | + uint8 refcnt; |
|---|
| 67 | 73 | } pktpool_cbinfo_t; |
|---|
| 68 | 74 | |
|---|
| 69 | 75 | /** PCIe SPLITRX related: call back fn extension to populate host address in pool pkt */ |
|---|
| 70 | | -typedef int (*pktpool_cb_extn_t)(struct pktpool *pool, void *arg1, void* pkt, bool arg2); |
|---|
| 76 | +typedef int (*pktpool_cb_extn_t)(struct pktpool *pool, void *arg1, void* pkt, int arg2); |
|---|
| 71 | 77 | typedef struct { |
|---|
| 72 | 78 | pktpool_cb_extn_t cb; |
|---|
| 73 | 79 | void *arg; |
|---|
| 74 | 80 | } pktpool_cbextn_info_t; |
|---|
| 75 | | - |
|---|
| 76 | 81 | |
|---|
| 77 | 82 | #ifdef BCMDBG_POOL |
|---|
| 78 | 83 | /* pkt pool debug states */ |
|---|
| .. | .. |
|---|
| 111 | 116 | |
|---|
| 112 | 117 | void * freelist; /**< free list: see PKTNEXTFREE(), PKTSETNEXTFREE() */ |
|---|
| 113 | 118 | uint16 avail; /**< number of packets in pool's free list */ |
|---|
| 114 | | - uint16 len; /**< number of packets managed by pool */ |
|---|
| 119 | + uint16 n_pkts; /**< number of packets managed by pool */ |
|---|
| 115 | 120 | uint16 maxlen; /**< maximum size of pool <= PKTPOOL_LEN_MAX */ |
|---|
| 116 | | - uint16 plen; /**< size of pkt buffer, excluding lbuf|lbuf_frag */ |
|---|
| 121 | + uint16 max_pkt_bytes; /**< size of pkt buffer in [bytes], excluding lbuf|lbuf_frag */ |
|---|
| 117 | 122 | |
|---|
| 118 | 123 | bool empty; |
|---|
| 119 | 124 | uint8 cbtoggle; |
|---|
| .. | .. |
|---|
| 130 | 135 | pktpool_cbinfo_t dbg_cbs[PKTPOOL_CB_MAX]; |
|---|
| 131 | 136 | uint16 dbg_qlen; |
|---|
| 132 | 137 | pktpool_dbg_t dbg_q[PKTPOOL_LEN_MAX + 1]; |
|---|
| 133 | | -#endif |
|---|
| 138 | +#endif // endif |
|---|
| 134 | 139 | pktpool_cbinfo_t dmarxfill; |
|---|
| 135 | 140 | } pktpool_t; |
|---|
| 136 | | - |
|---|
| 137 | 141 | |
|---|
| 138 | 142 | pktpool_t *get_pktpools_registry(int id); |
|---|
| 139 | 143 | |
|---|
| .. | .. |
|---|
| 141 | 145 | extern int pktpool_attach(osl_t *osh, uint32 total_pools); |
|---|
| 142 | 146 | extern int pktpool_dettach(osl_t *osh); /* Relinquish registry */ |
|---|
| 143 | 147 | |
|---|
| 144 | | -extern int pktpool_init(osl_t *osh, pktpool_t *pktp, int *pktplen, int plen, bool istx, uint8 type); |
|---|
| 148 | +extern int pktpool_init(osl_t *osh, pktpool_t *pktp, int *n_pkts, int max_pkt_bytes, bool istx, |
|---|
| 149 | + uint8 type); |
|---|
| 145 | 150 | extern int pktpool_deinit(osl_t *osh, pktpool_t *pktp); |
|---|
| 146 | 151 | extern int pktpool_fill(osl_t *osh, pktpool_t *pktp, bool minimal); |
|---|
| 152 | +extern int pktpool_empty(osl_t *osh, pktpool_t *pktp); |
|---|
| 153 | +extern uint16 pktpool_reclaim(osl_t *osh, pktpool_t *pktp, uint16 free_cnt); |
|---|
| 147 | 154 | extern void* pktpool_get(pktpool_t *pktp); |
|---|
| 148 | 155 | extern void pktpool_free(pktpool_t *pktp, void *p); |
|---|
| 149 | 156 | extern int pktpool_add(pktpool_t *pktp, void *p); |
|---|
| 150 | 157 | extern int pktpool_avail_notify_normal(osl_t *osh, pktpool_t *pktp); |
|---|
| 151 | 158 | extern int pktpool_avail_notify_exclusive(osl_t *osh, pktpool_t *pktp, pktpool_cb_t cb); |
|---|
| 152 | 159 | extern int pktpool_avail_register(pktpool_t *pktp, pktpool_cb_t cb, void *arg); |
|---|
| 160 | +extern int pktpool_avail_deregister(pktpool_t *pktp, pktpool_cb_t cb, void *arg); |
|---|
| 153 | 161 | extern int pktpool_empty_register(pktpool_t *pktp, pktpool_cb_t cb, void *arg); |
|---|
| 154 | | -extern int pktpool_setmaxlen(pktpool_t *pktp, uint16 maxlen); |
|---|
| 155 | | -extern int pktpool_setmaxlen_strict(osl_t *osh, pktpool_t *pktp, uint16 maxlen); |
|---|
| 162 | +extern int pktpool_setmaxlen(pktpool_t *pktp, uint16 max_pkts); |
|---|
| 163 | +extern int pktpool_setmaxlen_strict(osl_t *osh, pktpool_t *pktp, uint16 max_pkts); |
|---|
| 156 | 164 | extern void pktpool_emptycb_disable(pktpool_t *pktp, bool disable); |
|---|
| 157 | 165 | extern bool pktpool_emptycb_disabled(pktpool_t *pktp); |
|---|
| 158 | 166 | extern int pktpool_hostaddr_fill_register(pktpool_t *pktp, pktpool_cb_extn_t cb, void *arg1); |
|---|
| .. | .. |
|---|
| 165 | 173 | |
|---|
| 166 | 174 | #define POOLSETID(pp, ppid) (POOLPTR(pp)->id = (ppid)) |
|---|
| 167 | 175 | |
|---|
| 168 | | -#define pktpool_len(pp) (POOLPTR(pp)->len) |
|---|
| 176 | +#define pktpool_tot_pkts(pp) (POOLPTR(pp)->n_pkts) /**< n_pkts = avail + in_use <= max_pkts */ |
|---|
| 169 | 177 | #define pktpool_avail(pp) (POOLPTR(pp)->avail) |
|---|
| 170 | | -#define pktpool_plen(pp) (POOLPTR(pp)->plen) |
|---|
| 171 | | -#define pktpool_maxlen(pp) (POOLPTR(pp)->maxlen) |
|---|
| 172 | | - |
|---|
| 178 | +#define pktpool_max_pkt_bytes(pp) (POOLPTR(pp)->max_pkt_bytes) |
|---|
| 179 | +#define pktpool_max_pkts(pp) (POOLPTR(pp)->maxlen) |
|---|
| 173 | 180 | |
|---|
| 174 | 181 | /* |
|---|
| 175 | 182 | * ---------------------------------------------------------------------------- |
|---|
| .. | .. |
|---|
| 206 | 213 | #ifdef BCMFRAGPOOL |
|---|
| 207 | 214 | #define SHARED_FRAG_POOL (pktpool_shared_lfrag) |
|---|
| 208 | 215 | extern pktpool_t *pktpool_shared_lfrag; |
|---|
| 209 | | -#endif |
|---|
| 216 | +#endif // endif |
|---|
| 217 | + |
|---|
| 218 | +#ifdef BCMRESVFRAGPOOL |
|---|
| 219 | +#define RESV_FRAG_POOL (pktpool_resv_lfrag) |
|---|
| 220 | +#define RESV_POOL_INFO (resv_pool_info) |
|---|
| 221 | +#else |
|---|
| 222 | +#define RESV_FRAG_POOL ((struct pktpool *)NULL) |
|---|
| 223 | +#define RESV_POOL_INFO (NULL) |
|---|
| 224 | +#endif /* BCMRESVFRAGPOOL */ |
|---|
| 210 | 225 | |
|---|
| 211 | 226 | /** PCIe SPLITRX related */ |
|---|
| 212 | 227 | #define SHARED_RXFRAG_POOL (pktpool_shared_rxlfrag) |
|---|
| 213 | 228 | extern pktpool_t *pktpool_shared_rxlfrag; |
|---|
| 214 | 229 | |
|---|
| 215 | | -void hnd_pktpool_init(osl_t *osh); |
|---|
| 216 | | -void hnd_pktpool_fill(pktpool_t *pktpool, bool minimal); |
|---|
| 230 | +int hnd_pktpool_init(osl_t *osh); |
|---|
| 231 | +int hnd_pktpool_fill(pktpool_t *pktpool, bool minimal); |
|---|
| 217 | 232 | void hnd_pktpool_refill(bool minimal); |
|---|
| 233 | +#ifdef BCMRESVFRAGPOOL |
|---|
| 234 | +extern pktpool_t *pktpool_resv_lfrag; |
|---|
| 235 | +extern struct resv_info *resv_pool_info; |
|---|
| 236 | +#endif /* BCMRESVFRAGPOOL */ |
|---|
| 218 | 237 | #else /* BCMPKTPOOL */ |
|---|
| 219 | 238 | #define SHARED_POOL ((struct pktpool *)NULL) |
|---|
| 220 | 239 | #endif /* BCMPKTPOOL */ |
|---|
| 221 | 240 | |
|---|
| 222 | 241 | #ifdef __cplusplus |
|---|
| 223 | 242 | } |
|---|
| 224 | | -#endif |
|---|
| 243 | +#endif // endif |
|---|
| 225 | 244 | |
|---|
| 226 | 245 | #endif /* _hnd_pktpool_h_ */ |
|---|