forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/include/wlfc_proto.h
....@@ -1,13 +1,14 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
3
- * Copyright (C) 1999-2019, Broadcom Corporation
4
- *
2
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
3
+ *
4
+ * Copyright (C) 1999-2017, Broadcom Corporation
5
+ *
56 * Unless you and Broadcom execute a separate written software license
67 * agreement governing use of this software, this software is licensed to you
78 * under the terms of the GNU General Public License version 2 (the "GPL"),
89 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
910 * following added to such license:
10
- *
11
+ *
1112 * As a special exception, the copyright holders of this software give you
1213 * permission to link this software with independent modules, and to copy and
1314 * distribute the resulting executable under terms of your choice, provided that
....@@ -15,7 +16,7 @@
1516 * the license of that module. An independent module is a module which is not
1617 * derived from this software. The special exception does not apply to any
1718 * modifications of the software.
18
- *
19
+ *
1920 * Notwithstanding the above, under no circumstances may you combine this
2021 * software in any way with any other Broadcom software provided under a license
2122 * other than the GPL, without Broadcom's express prior written consent.
....@@ -23,12 +24,11 @@
2324 *
2425 * <<Broadcom-WL-IPTag/Open:>>
2526 *
26
- * $Id: wlfc_proto.h 542895 2015-03-22 14:13:12Z $
27
+ * $Id: wlfc_proto.h 692466 2017-03-28 07:48:19Z $
2728 *
2829 */
2930
3031 /** WL flow control for PROP_TXSTATUS. Related to host AMPDU reordering. */
31
-
3232
3333 #ifndef __wlfc_proto_definitions_h__
3434 #define __wlfc_proto_definitions_h__
....@@ -82,37 +82,47 @@
8282 ---------------------------------------------------------------------------
8383 */
8484
85
-#define WLFC_CTL_TYPE_MAC_OPEN 1
86
-#define WLFC_CTL_TYPE_MAC_CLOSE 2
87
-#define WLFC_CTL_TYPE_MAC_REQUEST_CREDIT 3
88
-#define WLFC_CTL_TYPE_TXSTATUS 4
89
-#define WLFC_CTL_TYPE_PKTTAG 5 /** host<->dongle */
85
+typedef enum {
86
+ WLFC_CTL_TYPE_MAC_OPEN = 1,
87
+ WLFC_CTL_TYPE_MAC_CLOSE = 2,
88
+ WLFC_CTL_TYPE_MAC_REQUEST_CREDIT = 3,
89
+ WLFC_CTL_TYPE_TXSTATUS = 4,
90
+ WLFC_CTL_TYPE_PKTTAG = 5, /** host<->dongle */
9091
91
-#define WLFC_CTL_TYPE_MACDESC_ADD 6
92
-#define WLFC_CTL_TYPE_MACDESC_DEL 7
93
-#define WLFC_CTL_TYPE_RSSI 8
92
+ WLFC_CTL_TYPE_MACDESC_ADD = 6,
93
+ WLFC_CTL_TYPE_MACDESC_DEL = 7,
94
+ WLFC_CTL_TYPE_RSSI = 8,
9495
95
-#define WLFC_CTL_TYPE_INTERFACE_OPEN 9
96
-#define WLFC_CTL_TYPE_INTERFACE_CLOSE 10
96
+ WLFC_CTL_TYPE_INTERFACE_OPEN = 9,
97
+ WLFC_CTL_TYPE_INTERFACE_CLOSE = 10,
9798
98
-#define WLFC_CTL_TYPE_FIFO_CREDITBACK 11
99
+ WLFC_CTL_TYPE_FIFO_CREDITBACK = 11,
99100
100
-#define WLFC_CTL_TYPE_PENDING_TRAFFIC_BMP 12 /** host->dongle */
101
-#define WLFC_CTL_TYPE_MAC_REQUEST_PACKET 13
102
-#define WLFC_CTL_TYPE_HOST_REORDER_RXPKTS 14
101
+ WLFC_CTL_TYPE_PENDING_TRAFFIC_BMP = 12, /** host->dongle */
102
+ WLFC_CTL_TYPE_MAC_REQUEST_PACKET = 13,
103
+ WLFC_CTL_TYPE_HOST_REORDER_RXPKTS = 14,
103104
104
-#define WLFC_CTL_TYPE_TX_ENTRY_STAMP 15
105
-#define WLFC_CTL_TYPE_RX_STAMP 16
106
-#define WLFC_CTL_TYPE_TX_STATUS_STAMP 17 /** obsolete */
105
+ WLFC_CTL_TYPE_TX_ENTRY_STAMP = 15,
106
+ WLFC_CTL_TYPE_RX_STAMP = 16,
107
+ WLFC_CTL_TYPE_TX_STATUS_STAMP = 17, /** obsolete */
107108
108
-#define WLFC_CTL_TYPE_TRANS_ID 18
109
-#define WLFC_CTL_TYPE_COMP_TXSTATUS 19
109
+ WLFC_CTL_TYPE_TRANS_ID = 18,
110
+ WLFC_CTL_TYPE_COMP_TXSTATUS = 19,
110111
111
-#define WLFC_CTL_TYPE_TID_OPEN 20
112
-#define WLFC_CTL_TYPE_TID_CLOSE 21
112
+ WLFC_CTL_TYPE_TID_OPEN = 20,
113
+ WLFC_CTL_TYPE_TID_CLOSE = 21,
114
+ WLFC_CTL_TYPE_UPD_FLR_WEIGHT = 22,
115
+ WLFC_CTL_TYPE_ENAB_FFSCH = 23,
116
+ WLFC_CTL_TYPE_UPDATE_FLAGS = 24, /* clear the flags set in flowring */
117
+ WLFC_CTL_TYPE_CLEAR_SUPPR = 25, /* free the supression info in the flowring */
113118
119
+ WLFC_CTL_TYPE_FLOWID_OPEN = 26,
120
+ WLFC_CTL_TYPE_FLOWID_CLOSE = 27,
114121
115
-#define WLFC_CTL_TYPE_FILLER 255
122
+ WLFC_CTL_TYPE_FILLER = 255
123
+} wlfc_ctl_type_t;
124
+
125
+#define WLFC_CTL_VALUE_LEN_FLOWID 2
116126
117127 #define WLFC_CTL_VALUE_LEN_MACDESC 8 /** handle, interface, MAC */
118128
....@@ -128,6 +138,14 @@
128138
129139 #define WLFC_CTL_VALUE_LEN_SEQ 2
130140
141
+/* Reset the flags set for the corresponding flowring of the SCB which is de-inited */
142
+/* FLOW_RING_FLAG_LAST_TIM | FLOW_RING_FLAG_INFORM_PKTPEND | FLOW_RING_FLAG_PKT_REQ */
143
+#define WLFC_RESET_ALL_FLAGS 0
144
+#define WLFC_CTL_VALUE_LEN_FLAGS 7 /** flags, MAC */
145
+
146
+/* free the data stored to be used for suppressed packets in future */
147
+#define WLFC_CTL_VALUE_LEN_SUPR 7 /** tid, MAC */
148
+
131149 /* The high bits of ratespec report in timestamp are used for various status */
132150 #define WLFC_TSFLAGS_RX_RETRY (1 << 31)
133151 #define WLFC_TSFLAGS_PM_ENABLED (1 << 30)
....@@ -139,9 +157,9 @@
139157 #define WLFC_CTL_VALUE_LEN_REQUEST_CREDIT 3 /* credit, MAC-handle, prec_bitmap */
140158 #define WLFC_CTL_VALUE_LEN_REQUEST_PACKET 3 /* credit, MAC-handle, prec_bitmap */
141159
142
-
143160 #define WLFC_PKTFLAG_PKTFROMHOST 0x01
144161 #define WLFC_PKTFLAG_PKT_REQUESTED 0x02
162
+#define WLFC_PKTFLAG_PKT_SENDTOHOST 0x04
145163
146164 #define WL_TXSTATUS_STATUS_MASK 0xff /* allow 8 bits */
147165 #define WL_TXSTATUS_STATUS_SHIFT 24
....@@ -206,44 +224,68 @@
206224 ((ctr) & WL_TXSTATUS_FREERUNCTR_MASK))
207225 #define WL_TXSTATUS_GET_FREERUNCTR(x) ((x)& WL_TXSTATUS_FREERUNCTR_MASK)
208226
209
-/* Seq number part of AMSDU */
227
+/* AMSDU part of d11 seq number */
210228 #define WL_SEQ_AMSDU_MASK 0x1 /* allow 1 bit */
211229 #define WL_SEQ_AMSDU_SHIFT 14
212230 #define WL_SEQ_SET_AMSDU(x, val) ((x) = \
213231 ((x) & ~(WL_SEQ_AMSDU_MASK << WL_SEQ_AMSDU_SHIFT)) | \
214
- (((val) & WL_SEQ_AMSDU_MASK) << WL_SEQ_AMSDU_SHIFT))
215
-#define WL_SEQ_GET_AMSDU(x) (((x) >> WL_SEQ_AMSDU_SHIFT) & \
216
- WL_SEQ_AMSDU_MASK)
232
+ (((val) & WL_SEQ_AMSDU_MASK) << WL_SEQ_AMSDU_SHIFT)) /**< sets a single AMSDU bit */
233
+/** returns TRUE if ring item is AMSDU (seq = d11 seq nr) */
234
+#define WL_SEQ_IS_AMSDU(x) (((x) >> WL_SEQ_AMSDU_SHIFT) & \
235
+ WL_SEQ_AMSDU_MASK)
217236
218
-/* Seq number is valid coming from FW */
237
+/* indicates last_suppr_seq is valid */
238
+#define WL_SEQ_VALIDSUPPR_MASK 0x1 /* allow 1 bit */
239
+#define WL_SEQ_VALIDSUPPR_SHIFT 12
240
+#define WL_SEQ_SET_VALIDSUPPR(x, val) ((x) = \
241
+ ((x) & ~(WL_SEQ_VALIDSUPPR_MASK << WL_SEQ_VALIDSUPPR_SHIFT)) | \
242
+ (((val) & WL_SEQ_VALIDSUPPR_MASK) << WL_SEQ_VALIDSUPPR_SHIFT))
243
+#define WL_SEQ_GET_VALIDSUPPR(x) (((x) >> WL_SEQ_VALIDSUPPR_SHIFT) & \
244
+ WL_SEQ_VALIDSUPPR_MASK)
245
+
219246 #define WL_SEQ_FROMFW_MASK 0x1 /* allow 1 bit */
220247 #define WL_SEQ_FROMFW_SHIFT 13
221248 #define WL_SEQ_SET_FROMFW(x, val) ((x) = \
222249 ((x) & ~(WL_SEQ_FROMFW_MASK << WL_SEQ_FROMFW_SHIFT)) | \
223250 (((val) & WL_SEQ_FROMFW_MASK) << WL_SEQ_FROMFW_SHIFT))
224
-#define WL_SEQ_GET_FROMFW(x) (((x) >> WL_SEQ_FROMFW_SHIFT) & \
225
- WL_SEQ_FROMFW_MASK)
251
+/** Set when firmware assigns D11 sequence number to packet */
252
+#define SET_WL_HAS_ASSIGNED_SEQ(x) WL_SEQ_SET_FROMFW((x), 1)
253
+
254
+/** returns TRUE if packet has been assigned a d11 seq number by the WL firmware layer */
255
+#define GET_WL_HAS_ASSIGNED_SEQ(x) (((x) >> WL_SEQ_FROMFW_SHIFT) & WL_SEQ_FROMFW_MASK)
226256
227257 /**
228258 * Proptxstatus related.
229259 *
230
- * Pkt from bus layer (DHD for SDIO and pciedev for PCIE)
231
- * is re-using seq number previously suppressed
232
- * so FW should not assign new one
260
+ * When a packet is suppressed by WL or the D11 core, the packet has to be retried. Assigning
261
+ * a new d11 sequence number for the packet when retrying would cause the peer to be unable to
262
+ * reorder the packets within an AMPDU. So, suppressed packet from bus layer (DHD for SDIO and
263
+ * pciedev for PCIE) is re-using d11 seq number, so FW should not assign a new one.
233264 */
234265 #define WL_SEQ_FROMDRV_MASK 0x1 /* allow 1 bit */
235266 #define WL_SEQ_FROMDRV_SHIFT 12
236
-#define WL_SEQ_SET_FROMDRV(x, val) ((x) = \
267
+
268
+/**
269
+ * Proptxstatus, host or fw PCIe layer requests WL layer to reuse d11 seq no. Bit is reset by WL
270
+ * subsystem when it reuses the seq number.
271
+ */
272
+#define WL_SEQ_SET_REUSE(x, val) ((x) = \
237273 ((x) & ~(WL_SEQ_FROMDRV_MASK << WL_SEQ_FROMDRV_SHIFT)) | \
238274 (((val) & WL_SEQ_FROMDRV_MASK) << WL_SEQ_FROMDRV_SHIFT))
239
-#define WL_SEQ_GET_FROMDRV(x) (((x) >> WL_SEQ_FROMDRV_SHIFT) & \
275
+#define SET_WL_TO_REUSE_SEQ(x) WL_SEQ_SET_REUSE((x), 1)
276
+#define RESET_WL_TO_REUSE_SEQ(x) WL_SEQ_SET_REUSE((x), 0)
277
+
278
+/** Proptxstatus, related to reuse of d11 seq numbers when retransmitting */
279
+#define IS_WL_TO_REUSE_SEQ(x) (((x) >> WL_SEQ_FROMDRV_SHIFT) & \
240280 WL_SEQ_FROMDRV_MASK)
241281
242282 #define WL_SEQ_NUM_MASK 0xfff /* allow 12 bit */
243283 #define WL_SEQ_NUM_SHIFT 0
284
+/** Proptxstatus, sets d11seq no in pkt tag, related to reuse of d11seq no when retransmitting */
244285 #define WL_SEQ_SET_NUM(x, val) ((x) = \
245286 ((x) & ~(WL_SEQ_NUM_MASK << WL_SEQ_NUM_SHIFT)) | \
246287 (((val) & WL_SEQ_NUM_MASK) << WL_SEQ_NUM_SHIFT))
288
+/** Proptxstatus, gets d11seq no from pkt tag, related to reuse of d11seq no when retransmitting */
247289 #define WL_SEQ_GET_NUM(x) (((x) >> WL_SEQ_NUM_SHIFT) & \
248290 WL_SEQ_NUM_MASK)
249291
....@@ -265,7 +307,6 @@
265307 #define WLFC_PKTFLAG_CLR_PKTREQUESTED(x) (x) &= \
266308 ~(WLFC_PKTFLAG_PKT_REQUESTED << WL_TXSTATUS_FLAGS_SHIFT)
267309
268
-
269310 #define WLFC_MAX_PENDING_DATALEN 120
270311
271312 /* host is free to discard the packet */
....@@ -282,28 +323,26 @@
282323 #define WLFC_CTL_PKTFLAG_DISCARD_NOACK 4
283324 /* Firmware wrongly reported suppressed previously,now fixing to acked */
284325 #define WLFC_CTL_PKTFLAG_SUPPRESS_ACKED 5
285
-
286
-#define WLFC_D11_STATUS_INTERPRET(txs) \
287
- ((txs)->status.was_acked ? WLFC_CTL_PKTFLAG_DISCARD : \
288
- (TXS_SUPR_MAGG_DONE((txs)->status.suppr_ind) ? \
289
- WLFC_CTL_PKTFLAG_DISCARD_NOACK : WLFC_CTL_PKTFLAG_D11SUPPRESS))
290
-
326
+/* Firmware send this packet expired, lifetime expiration */
327
+#define WLFC_CTL_PKTFLAG_EXPIRED 6
328
+/* Firmware drop this packet for any other reason */
329
+#define WLFC_CTL_PKTFLAG_DROPPED 7
330
+/* Firmware free this packet */
331
+#define WLFC_CTL_PKTFLAG_MKTFREE 8
332
+#define WLFC_CTL_PKTFLAG_MASK (0x0f) /* For 4-bit mask with one extra bit */
291333
292334 #ifdef PROP_TXSTATUS_DEBUG
293335 #define WLFC_DBGMESG(x) printf x
294336 /* wlfc-breadcrumb */
295337 #define WLFC_BREADCRUMB(x) do {if ((x) == NULL) \
296338 {printf("WLFC: %s():%d:caller:%p\n", \
297
- __FUNCTION__, __LINE__, __builtin_return_address(0));}} while (0)
298
-#define WLFC_PRINTMAC(banner, ea) do {printf("%s MAC: [%02x:%02x:%02x:%02x:%02x:%02x]\n", \
299
- banner, ea[0], ea[1], ea[2], ea[3], ea[4], ea[5]); } while (0)
339
+ __FUNCTION__, __LINE__, CALL_SITE);}} while (0)
300340 #define WLFC_WHEREIS(s) printf("WLFC: at %s():%d, %s\n", __FUNCTION__, __LINE__, (s))
301341 #else
302342 #define WLFC_DBGMESG(x)
303343 #define WLFC_BREADCRUMB(x)
304
-#define WLFC_PRINTMAC(banner, ea)
305344 #define WLFC_WHEREIS(s)
306
-#endif
345
+#endif /* PROP_TXSTATUS_DEBUG */
307346
308347 /* AMPDU host reorder packet flags */
309348 #define WLHOST_REORDERDATA_MAXFLOWS 256
....@@ -334,18 +373,43 @@
334373 #define WLFC_SET_AFQ(x, val) ((x) = \
335374 ((x) & ~(1 << WLFC_MODE_AFQ_SHIFT)) | \
336375 (((val) & 1) << WLFC_MODE_AFQ_SHIFT))
376
+/** returns TRUE if firmware supports 'at firmware queue' feature */
337377 #define WLFC_GET_AFQ(x) (((x) >> WLFC_MODE_AFQ_SHIFT) & 1)
338378
339379 #define WLFC_MODE_REUSESEQ_SHIFT 3 /* seq reuse bit */
340380 #define WLFC_SET_REUSESEQ(x, val) ((x) = \
341381 ((x) & ~(1 << WLFC_MODE_REUSESEQ_SHIFT)) | \
342382 (((val) & 1) << WLFC_MODE_REUSESEQ_SHIFT))
383
+
384
+/** returns TRUE if 'd11 sequence reuse' has been agreed upon between host and dongle */
385
+#if defined(BCMPCIEDEV_ENABLED) && !defined(ROM_ENAB_RUNTIME_CHECK)
386
+/* GET_REUSESEQ is always TRUE in pciedev */
387
+#define WLFC_GET_REUSESEQ(x) (TRUE)
388
+#else
343389 #define WLFC_GET_REUSESEQ(x) (((x) >> WLFC_MODE_REUSESEQ_SHIFT) & 1)
390
+#endif /* defined(BCMPCIEDEV_ENABLED) && !defined(ROM_ENAB_RUNTIME_CHECK) */
344391
345392 #define WLFC_MODE_REORDERSUPP_SHIFT 4 /* host reorder suppress pkt bit */
346393 #define WLFC_SET_REORDERSUPP(x, val) ((x) = \
347394 ((x) & ~(1 << WLFC_MODE_REORDERSUPP_SHIFT)) | \
348395 (((val) & 1) << WLFC_MODE_REORDERSUPP_SHIFT))
396
+/** returns TRUE if 'reorder suppress' has been agreed upon between host and dongle */
349397 #define WLFC_GET_REORDERSUPP(x) (((x) >> WLFC_MODE_REORDERSUPP_SHIFT) & 1)
350398
399
+#define FLOW_RING_CREATE 1
400
+#define FLOW_RING_DELETE 2
401
+#define FLOW_RING_FLUSH 3
402
+#define FLOW_RING_OPEN 4
403
+#define FLOW_RING_CLOSED 5
404
+#define FLOW_RING_FLUSHED 6
405
+#define FLOW_RING_TIM_SET 7
406
+#define FLOW_RING_TIM_RESET 8
407
+#define FLOW_RING_FLUSH_TXFIFO 9
408
+#define FLOW_RING_GET_PKT_MAX 10
409
+#define FLOW_RING_RESET_WEIGHT 11
410
+#define FLOW_RING_UPD_PRIOMAP 12
411
+
412
+/* bit 7, indicating if is TID(1) or AC(0) mapped info in tid field) */
413
+#define PCIEDEV_IS_AC_TID_MAP_MASK 0x80
414
+
351415 #endif /* __wlfc_proto_definitions_h__ */