forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/bcm_ring.h
....@@ -1,20 +1,41 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
2
-#ifndef __bcm_ring_included__
3
-#define __bcm_ring_included__
4
-
51 /*
6
- * +----------------------------------------------------------------------------
7
- *
82 * bcm_ring.h : Ring context abstraction
9
- *
103 * The ring context tracks the WRITE and READ indices where elements may be
114 * produced and consumed respectively. All elements in the ring need to be
125 * fixed size.
136 *
147 * NOTE: A ring of size N, may only hold N-1 elements.
158 *
16
- * +----------------------------------------------------------------------------
9
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
1710 *
11
+ * Copyright (C) 1999-2017, Broadcom Corporation
12
+ *
13
+ * Unless you and Broadcom execute a separate written software license
14
+ * agreement governing use of this software, this software is licensed to you
15
+ * under the terms of the GNU General Public License version 2 (the "GPL"),
16
+ * available at http://www.broadcom.com/licenses/GPLv2.php, with the
17
+ * following added to such license:
18
+ *
19
+ * As a special exception, the copyright holders of this software give you
20
+ * permission to link this software with independent modules, and to copy and
21
+ * distribute the resulting executable under terms of your choice, provided that
22
+ * you also meet, for each linked independent module, the terms and conditions of
23
+ * the license of that module. An independent module is a module which is not
24
+ * derived from this software. The special exception does not apply to any
25
+ * modifications of the software.
26
+ *
27
+ * Notwithstanding the above, under no circumstances may you combine this
28
+ * software in any way with any other Broadcom software provided under a license
29
+ * other than the GPL, without Broadcom's express prior written consent.
30
+ *
31
+ *
32
+ * <<Broadcom-WL-IPTag/Open:>>
33
+ *
34
+ * $Id: bcm_ring.h 700321 2017-05-18 16:09:07Z $
35
+ */
36
+#ifndef __bcm_ring_included__
37
+#define __bcm_ring_included__
38
+/*
1839 * API Notes:
1940 *
2041 * Ring manipulation API allows for:
....@@ -82,14 +103,16 @@
82103 * private L1 data cache.
83104 * +----------------------------------------------------------------------------
84105 *
85
- * Copyright (C) 1999-2019, Broadcom Corporation
86
- *
106
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
107
+ *
108
+ * Copyright (C) 1999-2017, Broadcom Corporation
109
+ *
87110 * Unless you and Broadcom execute a separate written software license
88111 * agreement governing use of this software, this software is licensed to you
89112 * under the terms of the GNU General Public License version 2 (the "GPL"),
90113 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
91114 * following added to such license:
92
- *
115
+ *
93116 * As a special exception, the copyright holders of this software give you
94117 * permission to link this software with independent modules, and to copy and
95118 * distribute the resulting executable under terms of your choice, provided that
....@@ -97,12 +120,12 @@
97120 * the license of that module. An independent module is a module which is not
98121 * derived from this software. The special exception does not apply to any
99122 * modifications of the software.
100
- *
123
+ *
101124 * Notwithstanding the above, under no circumstances may you combine this
102125 * software in any way with any other Broadcom software provided under a license
103126 * other than the GPL, without Broadcom's express prior written consent.
104127 *
105
- * $Id$
128
+ * $Id: bcm_ring.h 700321 2017-05-18 16:09:07Z $
106129 *
107130 * -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
108131 * vim: set ts=4 noet sw=4 tw=80:
....@@ -114,7 +137,7 @@
114137 #define __ring_aligned ____cacheline_aligned
115138 #else
116139 #define __ring_aligned
117
-#endif
140
+#endif // endif
118141
119142 /* Conditional compile for debug */
120143 /* #define BCM_RING_DEBUG */
....@@ -147,7 +170,6 @@
147170 int read __ring_aligned; /* READ index in a circular ring */
148171 } bcm_ring_t;
149172
150
-
151173 static INLINE void bcm_ring_init(bcm_ring_t *ring);
152174 static INLINE void bcm_ring_copy(bcm_ring_t *to, bcm_ring_t *from);
153175 static INLINE bool bcm_ring_is_empty(bcm_ring_t *ring);
....@@ -175,7 +197,6 @@
175197 static INLINE int bcm_ring_cons_avail(const bcm_ring_t *ring,
176198 const int ring_size);
177199 static INLINE void bcm_ring_cons_all(bcm_ring_t *ring);
178
-
179200
180201 /**
181202 * bcm_ring_init - initialize a ring context.
....@@ -219,7 +240,6 @@
219240 return (ring->read == ring->write);
220241 }
221242
222
-
223243 /**
224244 * __bcm_ring_next_write - determine the index where the next write may occur
225245 * (with wrap-around).
....@@ -235,7 +255,6 @@
235255 return ((ring->write + 1) % ring_size);
236256 }
237257
238
-
239258 /**
240259 * __bcm_ring_full - support function for ring full test.
241260 * @ring: pointer to a ring context
....@@ -248,7 +267,6 @@
248267 {
249268 return (next_write == ring->read);
250269 }
251
-
252270
253271 /**
254272 * bcm_ring_is_full - "Boolean" test whether a ring is full.
....@@ -266,7 +284,6 @@
266284 return __bcm_ring_full(ring, next_write);
267285 }
268286
269
-
270287 /**
271288 * bcm_ring_prod_done - commit a previously pending index where production
272289 * was requested.
....@@ -280,7 +297,6 @@
280297 RING_ASSERT(BCM_RING_IS_VALID(ring));
281298 ring->write = write;
282299 }
283
-
284300
285301 /**
286302 * bcm_ring_prod_pend - Fetch in "pend" mode, the index where an element may be
....@@ -305,7 +321,6 @@
305321 return rtn;
306322 }
307323
308
-
309324 /**
310325 * bcm_ring_prod - Fetch and "commit" the next index where a ring element may
311326 * be produced.
....@@ -328,7 +343,6 @@
328343 return prod_write;
329344 }
330345
331
-
332346 /**
333347 * bcm_ring_cons_done - commit a previously pending read
334348 * @ring: pointer to a ring context
....@@ -340,7 +354,6 @@
340354 RING_ASSERT(BCM_RING_IS_VALID(ring));
341355 ring->read = read;
342356 }
343
-
344357
345358 /**
346359 * bcm_ring_cons_pend - fetch in "pend" mode, the next index where a ring
....@@ -365,7 +378,6 @@
365378 return rtn;
366379 }
367380
368
-
369381 /**
370382 * bcm_ring_cons - fetch and "commit" the next index where a ring element may
371383 * be consumed.
....@@ -386,7 +398,6 @@
386398 return cons_read;
387399 }
388400
389
-
390401 /**
391402 * bcm_ring_sync_read - on consumption, update peer's read index.
392403 * @peer: pointer to peer's producer ring context
....@@ -400,7 +411,6 @@
400411 peer->read = self->read; /* flush read update to peer producer */
401412 }
402413
403
-
404414 /**
405415 * bcm_ring_sync_write - on consumption, update peer's write index.
406416 * @peer: pointer to peer's consumer ring context
....@@ -413,7 +423,6 @@
413423 RING_ASSERT(BCM_RING_IS_VALID(self));
414424 peer->write = self->write; /* flush write update to peer consumer */
415425 }
416
-
417426
418427 /**
419428 * bcm_ring_prod_avail - fetch total number of available empty slots in the
....@@ -434,7 +443,6 @@
434443 ASSERT(prod_avail < ring_size);
435444 return prod_avail;
436445 }
437
-
438446
439447 /**
440448 * bcm_ring_cons_avail - fetch total number of available elements for consumption.
....@@ -457,7 +465,6 @@
457465 return cons_avail;
458466 }
459467
460
-
461468 /**
462469 * bcm_ring_cons_all - set ring in state where all elements are consumed.
463470 * @ring: pointer to a ring context
....@@ -467,7 +474,6 @@
467474 {
468475 ring->read = ring->write;
469476 }
470
-
471477
472478 /**
473479 * Work Queue
....@@ -484,7 +490,6 @@
484490 } __ring_aligned;
485491
486492 typedef struct bcm_workq bcm_workq_t;
487
-
488493
489494 /* #define BCM_WORKQ_DEBUG */
490495 #if defined(BCM_WORKQ_DEBUG)
....@@ -510,7 +515,6 @@
510515 WORKQ_ASSERT((__index) < ((__workq)->ring_size)); \
511516 ((__elem_type *)((__workq)->buffer)) + (__index); \
512517 })
513
-
514518
515519 static INLINE void bcm_workq_init(bcm_workq_t *workq, bcm_workq_t *workq_peer,
516520 void *buffer, int ring_size);
....@@ -584,7 +588,6 @@
584588 bcm_ring_sync_read(WORKQ_PEER_RING(workq_cons), WORKQ_RING(workq_cons));
585589 }
586590
587
-
588591 /**
589592 * bcm_workq_prod_refresh - Fetch the updated consumer's read index
590593 * @workq_prod: producer's workq whose read index must be refreshed from peer
....@@ -610,6 +613,5 @@
610613 /* cons::write <--- prod::write */
611614 bcm_ring_sync_write(WORKQ_RING(workq_cons), WORKQ_PEER_RING(workq_cons));
612615 }
613
-
614616
615617 #endif /* ! __bcm_ring_h_included__ */