forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/hnd_pktpool.h
....@@ -1,15 +1,16 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * HND generic packet pool operation primitives
43 *
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
+ *
78 * Unless you and Broadcom execute a separate written software license
89 * agreement governing use of this software, this software is licensed to you
910 * under the terms of the GNU General Public License version 2 (the "GPL"),
1011 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1112 * following added to such license:
12
- *
13
+ *
1314 * As a special exception, the copyright holders of this software give you
1415 * permission to link this software with independent modules, and to copy and
1516 * distribute the resulting executable under terms of your choice, provided that
....@@ -17,7 +18,7 @@
1718 * the license of that module. An independent module is a module which is not
1819 * derived from this software. The special exception does not apply to any
1920 * modifications of the software.
20
- *
21
+ *
2122 * Notwithstanding the above, under no circumstances may you combine this
2223 * software in any way with any other Broadcom software provided under a license
2324 * other than the GPL, without Broadcom's express prior written consent.
....@@ -25,7 +26,7 @@
2526 *
2627 * <<Broadcom-WL-IPTag/Open:>>
2728 *
28
- * $Id: $
29
+ * $Id: hnd_pktpool.h 633941 2016-04-26 07:04:26Z $
2930 */
3031
3132 #ifndef _hnd_pktpool_h_
....@@ -35,14 +36,14 @@
3536
3637 #ifdef __cplusplus
3738 extern "C" {
38
-#endif
39
+#endif // endif
3940
4041 /* mutex macros for thread safe */
4142 #ifdef HND_PKTPOOL_THREAD_SAFE
4243 #define HND_PKTPOOL_MUTEX_DECL(mutex) OSL_EXT_MUTEX_DECL(mutex)
4344 #else
4445 #define HND_PKTPOOL_MUTEX_DECL(mutex)
45
-#endif
46
+#endif // endif
4647
4748 #ifdef BCMPKTPOOL
4849 #define POOL_ENAB(pool) ((pool) && (pool)->inited)
....@@ -56,6 +57,10 @@
5657 #define PKTPOOL_CB_MAX 3
5758 #define PKTPOOL_CB_MAX_AVL 4
5859
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
5964
6065 /* forward declaration */
6166 struct pktpool;
....@@ -64,15 +69,15 @@
6469 typedef struct {
6570 pktpool_cb_t cb;
6671 void *arg;
72
+ uint8 refcnt;
6773 } pktpool_cbinfo_t;
6874
6975 /** 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);
7177 typedef struct {
7278 pktpool_cb_extn_t cb;
7379 void *arg;
7480 } pktpool_cbextn_info_t;
75
-
7681
7782 #ifdef BCMDBG_POOL
7883 /* pkt pool debug states */
....@@ -111,9 +116,9 @@
111116
112117 void * freelist; /**< free list: see PKTNEXTFREE(), PKTSETNEXTFREE() */
113118 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 */
115120 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 */
117122
118123 bool empty;
119124 uint8 cbtoggle;
....@@ -130,10 +135,9 @@
130135 pktpool_cbinfo_t dbg_cbs[PKTPOOL_CB_MAX];
131136 uint16 dbg_qlen;
132137 pktpool_dbg_t dbg_q[PKTPOOL_LEN_MAX + 1];
133
-#endif
138
+#endif // endif
134139 pktpool_cbinfo_t dmarxfill;
135140 } pktpool_t;
136
-
137141
138142 pktpool_t *get_pktpools_registry(int id);
139143
....@@ -141,18 +145,22 @@
141145 extern int pktpool_attach(osl_t *osh, uint32 total_pools);
142146 extern int pktpool_dettach(osl_t *osh); /* Relinquish registry */
143147
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);
145150 extern int pktpool_deinit(osl_t *osh, pktpool_t *pktp);
146151 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);
147154 extern void* pktpool_get(pktpool_t *pktp);
148155 extern void pktpool_free(pktpool_t *pktp, void *p);
149156 extern int pktpool_add(pktpool_t *pktp, void *p);
150157 extern int pktpool_avail_notify_normal(osl_t *osh, pktpool_t *pktp);
151158 extern int pktpool_avail_notify_exclusive(osl_t *osh, pktpool_t *pktp, pktpool_cb_t cb);
152159 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);
153161 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);
156164 extern void pktpool_emptycb_disable(pktpool_t *pktp, bool disable);
157165 extern bool pktpool_emptycb_disabled(pktpool_t *pktp);
158166 extern int pktpool_hostaddr_fill_register(pktpool_t *pktp, pktpool_cb_extn_t cb, void *arg1);
....@@ -165,11 +173,10 @@
165173
166174 #define POOLSETID(pp, ppid) (POOLPTR(pp)->id = (ppid))
167175
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 */
169177 #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)
173180
174181 /*
175182 * ----------------------------------------------------------------------------
....@@ -206,21 +213,33 @@
206213 #ifdef BCMFRAGPOOL
207214 #define SHARED_FRAG_POOL (pktpool_shared_lfrag)
208215 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 */
210225
211226 /** PCIe SPLITRX related */
212227 #define SHARED_RXFRAG_POOL (pktpool_shared_rxlfrag)
213228 extern pktpool_t *pktpool_shared_rxlfrag;
214229
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);
217232 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 */
218237 #else /* BCMPKTPOOL */
219238 #define SHARED_POOL ((struct pktpool *)NULL)
220239 #endif /* BCMPKTPOOL */
221240
222241 #ifdef __cplusplus
223242 }
224
-#endif
243
+#endif // endif
225244
226245 #endif /* _hnd_pktpool_h_ */