forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/osl.h
....@@ -1,15 +1,16 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * OS Abstraction Layer
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: osl.h 585315 2015-09-10 06:02:11Z $
29
+ * $Id: osl.h 673906 2016-12-05 19:59:39Z $
2930 */
3031
3132 #ifndef _osl_h_
....@@ -33,7 +34,13 @@
3334
3435 #include <osl_decl.h>
3536
36
-#define OSL_PKTTAG_SZ 32 /* Size of PktTag */
37
+enum {
38
+ TAIL_BYTES_TYPE_FCS = 1,
39
+ TAIL_BYTES_TYPE_ICV = 2,
40
+ TAIL_BYTES_TYPE_MIC = 3
41
+};
42
+
43
+#define OSL_PKTTAG_SZ 48 /* standard linux pkttag size is 48 bytes */
3744
3845 /* Drivers use PKTFREESETCB to register a callback function when a packet is freed by OSL */
3946 typedef void (*pktfree_cb_fn_t)(void *ctx, void *pkt, unsigned int status);
....@@ -42,17 +49,16 @@
4249 typedef unsigned int (*osl_rreg_fn_t)(void *ctx, volatile void *reg, unsigned int size);
4350 typedef void (*osl_wreg_fn_t)(void *ctx, volatile void *reg, unsigned int val, unsigned int size);
4451
45
-
46
-
4752 #if defined(WL_UNITTEST)
4853 #include <utest_osl.h>
4954 #else
5055 #include <linux_osl.h>
51
-#endif
56
+#include <linux_pkt.h>
57
+#endif // endif
5258
5359 #ifndef PKTDBG_TRACE
5460 #define PKTDBG_TRACE(osh, pkt, bit) BCM_REFERENCE(osh)
55
-#endif
61
+#endif // endif
5662
5763 #define PKTCTFMAP(osh, p) BCM_REFERENCE(osh)
5864
....@@ -72,20 +78,63 @@
7278
7379 #if !defined(OSL_SYSUPTIME)
7480 #define OSL_SYSUPTIME() (0)
81
+#define OSL_SYSUPTIME_NOT_DEFINED 1
82
+#endif /* !defined(OSL_SYSUPTIME) */
83
+
84
+#if !defined(OSL_SYSUPTIME_US)
85
+#define OSL_SYSUPTIME_US() (0)
86
+#define OSL_SYSUPTIME_US_NOT_DEFINED 1
87
+#endif /* !defined(OSL_SYSUPTIME) */
88
+
89
+#if defined(OSL_SYSUPTIME_NOT_DEFINED) && defined(OSL_SYSUPTIME_US_NOT_DEFINED)
7590 #define OSL_SYSUPTIME_SUPPORT FALSE
7691 #else
7792 #define OSL_SYSUPTIME_SUPPORT TRUE
7893 #endif /* OSL_SYSUPTIME */
7994
95
+#ifndef OSL_GET_LOCALTIME
96
+#define OSL_GET_LOCALTIME(sec, usec) \
97
+ do { \
98
+ BCM_REFERENCE(sec); \
99
+ BCM_REFERENCE(usec); \
100
+ } while (0)
101
+#endif /* OSL_GET_LOCALTIME */
102
+
103
+#ifndef OSL_LOCALTIME_NS
104
+#define OSL_LOCALTIME_NS() (OSL_SYSUPTIME_US() * NSEC_PER_USEC)
105
+#endif /* OSL_LOCALTIME_NS */
106
+
107
+#ifndef OSL_SYSTZTIME_US
108
+#define OSL_SYSTZTIME_US() OSL_SYSUPTIME_US()
109
+#endif /* OSL_GET_SYSTZTIME */
110
+
80111 #ifndef OSL_SYS_HALT
81112 #define OSL_SYS_HALT() do {} while (0)
82
-#endif
113
+#endif // endif
114
+
115
+#ifndef DMB
116
+#if defined(STB)
117
+#define DMB() mb();
118
+#else /* STB */
119
+#define DMB() do {} while (0)
120
+#endif /* STB */
121
+#endif /* DMB */
83122
84123 #ifndef OSL_MEM_AVAIL
85124 #define OSL_MEM_AVAIL() (0xffffffff)
86
-#endif
125
+#endif // endif
87126
88
-#if !defined(PKTC) && !defined(PKTC_DONGLE)
127
+#ifndef OSL_OBFUSCATE_BUF
128
+/* For security reasons printing pointers is not allowed.
129
+ * Some OSLs implement OSL_OBFUSCATE_BUF to OS specific obfuscate API.
130
+ * If OSL_OBFUSCATE_BUF() is not implemented in OSL, then default to
131
+ * printing the input pointer
132
+ */
133
+#define OSL_OBFUSCATE_BUF(x) (x)
134
+#endif /* OSL_OBFUSCATE_BUF */
135
+
136
+#if !defined(PKTC_DONGLE)
137
+
89138 #define PKTCGETATTR(skb) (0)
90139 #define PKTCSETATTR(skb, f, p, b) BCM_REFERENCE(skb)
91140 #define PKTCCLRATTR(skb) BCM_REFERENCE(skb)
....@@ -113,67 +162,218 @@
113162 (h) = (t) = (p); \
114163 } \
115164 } while (0)
116
-#endif /* !linux || !PKTC */
165
+#endif // endif
117166
118
-#if !defined(HNDCTF) && !defined(PKTC_TX_DONGLE)
167
+#ifndef PKTSETCHAINED
119168 #define PKTSETCHAINED(osh, skb) BCM_REFERENCE(osh)
169
+#endif // endif
170
+#ifndef PKTCLRCHAINED
120171 #define PKTCLRCHAINED(osh, skb) BCM_REFERENCE(osh)
172
+#endif // endif
173
+#ifndef PKTISCHAINED
121174 #define PKTISCHAINED(skb) FALSE
122
-#endif
175
+#endif // endif
123176
124177 /* Lbuf with fraglist */
178
+#ifndef PKTFRAGPKTID
125179 #define PKTFRAGPKTID(osh, lb) (0)
180
+#endif // endif
181
+#ifndef PKTSETFRAGPKTID
126182 #define PKTSETFRAGPKTID(osh, lb, id) BCM_REFERENCE(osh)
183
+#endif // endif
184
+#ifndef PKTFRAGTOTNUM
127185 #define PKTFRAGTOTNUM(osh, lb) (0)
186
+#endif // endif
187
+#ifndef PKTSETFRAGTOTNUM
128188 #define PKTSETFRAGTOTNUM(osh, lb, tot) BCM_REFERENCE(osh)
189
+#endif // endif
190
+#ifndef PKTFRAGTOTLEN
129191 #define PKTFRAGTOTLEN(osh, lb) (0)
192
+#endif // endif
193
+#ifndef PKTSETFRAGTOTLEN
130194 #define PKTSETFRAGTOTLEN(osh, lb, len) BCM_REFERENCE(osh)
195
+#endif // endif
196
+#ifndef PKTIFINDEX
131197 #define PKTIFINDEX(osh, lb) (0)
198
+#endif // endif
199
+#ifndef PKTSETIFINDEX
132200 #define PKTSETIFINDEX(osh, lb, idx) BCM_REFERENCE(osh)
201
+#endif // endif
202
+#ifndef PKTGETLF
133203 #define PKTGETLF(osh, len, send, lbuf_type) (0)
204
+#endif // endif
134205
135206 /* in rx path, reuse totlen as used len */
207
+#ifndef PKTFRAGUSEDLEN
136208 #define PKTFRAGUSEDLEN(osh, lb) (0)
209
+#endif // endif
210
+#ifndef PKTSETFRAGUSEDLEN
137211 #define PKTSETFRAGUSEDLEN(osh, lb, len) BCM_REFERENCE(osh)
138
-
212
+#endif // endif
213
+#ifndef PKTFRAGLEN
139214 #define PKTFRAGLEN(osh, lb, ix) (0)
215
+#endif // endif
216
+#ifndef PKTSETFRAGLEN
140217 #define PKTSETFRAGLEN(osh, lb, ix, len) BCM_REFERENCE(osh)
218
+#endif // endif
219
+#ifndef PKTFRAGDATA_LO
141220 #define PKTFRAGDATA_LO(osh, lb, ix) (0)
221
+#endif // endif
222
+#ifndef PKTSETFRAGDATA_LO
142223 #define PKTSETFRAGDATA_LO(osh, lb, ix, addr) BCM_REFERENCE(osh)
224
+#endif // endif
225
+#ifndef PKTFRAGDATA_HI
143226 #define PKTFRAGDATA_HI(osh, lb, ix) (0)
227
+#endif // endif
228
+#ifndef PKTSETFRAGDATA_HI
144229 #define PKTSETFRAGDATA_HI(osh, lb, ix, addr) BCM_REFERENCE(osh)
230
+#endif // endif
145231
146232 /* RX FRAG */
233
+#ifndef PKTISRXFRAG
147234 #define PKTISRXFRAG(osh, lb) (0)
235
+#endif // endif
236
+#ifndef PKTSETRXFRAG
148237 #define PKTSETRXFRAG(osh, lb) BCM_REFERENCE(osh)
238
+#endif // endif
239
+#ifndef PKTRESETRXFRAG
149240 #define PKTRESETRXFRAG(osh, lb) BCM_REFERENCE(osh)
241
+#endif // endif
150242
151243 /* TX FRAG */
244
+#ifndef PKTISTXFRAG
152245 #define PKTISTXFRAG(osh, lb) (0)
246
+#endif // endif
247
+#ifndef PKTSETTXFRAG
153248 #define PKTSETTXFRAG(osh, lb) BCM_REFERENCE(osh)
249
+#endif // endif
154250
155251 /* Need Rx completion used for AMPDU reordering */
252
+#ifndef PKTNEEDRXCPL
156253 #define PKTNEEDRXCPL(osh, lb) (TRUE)
254
+#endif // endif
255
+#ifndef PKTSETNORXCPL
157256 #define PKTSETNORXCPL(osh, lb) BCM_REFERENCE(osh)
257
+#endif // endif
258
+#ifndef PKTRESETNORXCPL
158259 #define PKTRESETNORXCPL(osh, lb) BCM_REFERENCE(osh)
159
-
260
+#endif // endif
261
+#ifndef PKTISFRAG
160262 #define PKTISFRAG(osh, lb) (0)
263
+#endif // endif
264
+#ifndef PKTFRAGISCHAINED
161265 #define PKTFRAGISCHAINED(osh, i) (0)
266
+#endif // endif
162267 /* TRIM Tail bytes from lfrag */
268
+#ifndef PKTFRAG_TRIM_TAILBYTES
163269 #define PKTFRAG_TRIM_TAILBYTES(osh, p, len, type) PKTSETLEN(osh, p, PKTLEN(osh, p) - len)
270
+#endif // endif
271
+#ifndef PKTISHDRCONVTD
272
+#define PKTISHDRCONVTD(osh, lb) (0)
273
+#endif // endif
274
+
275
+/* Forwarded pkt indication */
276
+#ifndef PKTISFRWDPKT
277
+#define PKTISFRWDPKT(osh, lb) 0
278
+#endif // endif
279
+#ifndef PKTSETFRWDPKT
280
+#define PKTSETFRWDPKT(osh, lb) BCM_REFERENCE(osh)
281
+#endif // endif
282
+#ifndef PKTRESETFRWDPKT
283
+#define PKTRESETFRWDPKT(osh, lb) BCM_REFERENCE(osh)
284
+#endif // endif
285
+
286
+/* SFD Frame */
287
+#ifndef PKTISSFDFRAME
288
+#define PKTISSFDFRAME(osh, lb) (0)
289
+#endif // endif
290
+#ifndef PKTSETSFDFRAME
291
+#define PKTSETSFDFRAME(osh, lb) BCM_REFERENCE(osh)
292
+#endif // endif
293
+#ifndef PKTRESETSFDFRAME
294
+#define PKTRESETSFDFRAME(osh, lb) BCM_REFERENCE(osh)
295
+#endif // endif
296
+#ifndef PKTISSFDTXC
297
+#define PKTISSFDTXC(osh, lb) (0)
298
+#endif // endif
299
+#ifndef PKTSETSFDTXC
300
+#define PKTSETSFDTXC(osh, lb) BCM_REFERENCE(osh)
301
+#endif // endif
302
+#ifndef PKTRESETSFDTXC
303
+#define PKTRESETSFDTXC(osh, lb) BCM_REFERENCE(osh)
304
+#endif // endif
164305
165306 #ifdef BCM_SECURE_DMA
166307 #define SECURE_DMA_ENAB(osh) (1)
167308 #else
168309
169310 #define SECURE_DMA_ENAB(osh) (0)
170
-#define SECURE_DMA_MAP(osh, va, size, direction, p, dmah, pcma, offset) ((dmaaddr_t) {(0)})
311
+#ifndef BCMDMA64OSL
312
+#define SECURE_DMA_MAP(osh, va, size, direction, p, dmah, pcma, offset) ((dmaaddr_t) ((0)))
313
+#else
314
+#define SECURE_DMA_MAP(osh, va, size, direction, p, dmah, pcma, offset) \
315
+ ((dmaaddr_t) {.hiaddr = 0, .loaddr = 0})
316
+#endif // endif
171317 #define SECURE_DMA_DD_MAP(osh, va, size, direction, p, dmah) 0
172
-#define SECURE_DMA_MAP_TXMETA(osh, va, size, direction, p, dmah, pcma) ((dmaaddr_t) {(0)})
318
+#ifndef BCMDMA64OSL
319
+#define SECURE_DMA_MAP_TXMETA(osh, va, size, direction, p, dmah, pcma) ((dmaaddr_t) ((0)))
320
+#else
321
+#define SECURE_DMA_MAP_TXMETA(osh, va, size, direction, p, dmah, pcma) \
322
+ ((dmaaddr_t) {.hiaddr = 0, .loaddr = 0})
323
+#endif // endif
173324 #define SECURE_DMA_UNMAP(osh, pa, size, direction, p, dmah, pcma, offset)
174325 #define SECURE_DMA_UNMAP_ALL(osh, pcma)
175326
176
-#endif
327
+#endif /* BCMDMA64OSL */
177328
329
+#ifndef ROMMABLE_ASSERT
330
+#define ROMMABLE_ASSERT(exp) ASSERT(exp)
331
+#endif /* ROMMABLE_ASSERT */
332
+
333
+#ifndef MALLOC_NOPERSIST
334
+ #define MALLOC_NOPERSIST MALLOC
335
+#endif /* !MALLOC_NOPERSIST */
336
+
337
+#ifndef MALLOC_PERSIST
338
+ #define MALLOC_PERSIST MALLOC
339
+#endif /* !MALLOC_PERSIST */
340
+
341
+#ifndef MALLOC_NOPERSIST
342
+ #define MALLOC_NOPERSIST MALLOC
343
+#endif /* !MALLOC_NOPERSIST */
344
+
345
+#ifndef MALLOC_PERSIST_ATTACH
346
+ #define MALLOC_PERSIST_ATTACH MALLOC
347
+#endif /* !MALLOC_PERSIST_ATTACH */
348
+
349
+#ifndef MALLOCZ_PERSIST_ATTACH
350
+ #define MALLOCZ_PERSIST_ATTACH MALLOCZ
351
+#endif /* !MALLOCZ_PERSIST_ATTACH */
352
+
353
+#ifndef MALLOCZ_NOPERSIST
354
+ #define MALLOCZ_NOPERSIST MALLOCZ
355
+#endif /* !MALLOCZ_NOPERSIST */
356
+
357
+#ifndef MALLOCZ_PERSIST
358
+ #define MALLOCZ_PERSIST MALLOCZ
359
+#endif /* !MALLOCZ_PERSIST */
360
+
361
+#ifndef MFREE_PERSIST
362
+ #define MFREE_PERSIST MFREE
363
+#endif /* !MFREE_PERSIST */
364
+
365
+#ifndef MALLOC_SET_NOPERSIST
366
+ #define MALLOC_SET_NOPERSIST(osh) do { } while (0)
367
+#endif /* !MALLOC_SET_NOPERSIST */
368
+
369
+#ifndef MALLOC_CLEAR_NOPERSIST
370
+ #define MALLOC_CLEAR_NOPERSIST(osh) do { } while (0)
371
+#endif /* !MALLOC_CLEAR_NOPERSIST */
372
+
373
+#if defined(OSL_MEMCHECK)
374
+#define MEMCHECK(f, l) osl_memcheck(f, l)
375
+#else
376
+#define MEMCHECK(f, l)
377
+#endif /* OSL_MEMCHECK */
178378
179379 #endif /* _osl_h_ */