hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/bcm_app_utils.c
....@@ -1,17 +1,18 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * Misc utility routines used by kernel or app-level.
43 * Contents are wifi-specific, used by any kernel or app-level
54 * software that might want wifi things as it grows.
65 *
7
- * Copyright (C) 1999-2019, Broadcom Corporation
8
- *
6
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
7
+ *
8
+ * Copyright (C) 1999-2017, Broadcom Corporation
9
+ *
910 * Unless you and Broadcom execute a separate written software license
1011 * agreement governing use of this software, this software is licensed to you
1112 * under the terms of the GNU General Public License version 2 (the "GPL"),
1213 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1314 * following added to such license:
14
- *
15
+ *
1516 * As a special exception, the copyright holders of this software give you
1617 * permission to link this software with independent modules, and to copy and
1718 * distribute the resulting executable under terms of your choice, provided that
....@@ -19,7 +20,7 @@
1920 * the license of that module. An independent module is a module which is not
2021 * derived from this software. The special exception does not apply to any
2122 * modifications of the software.
22
- *
23
+ *
2324 * Notwithstanding the above, under no circumstances may you combine this
2425 * software in any way with any other Broadcom software provided under a license
2526 * other than the GPL, without Broadcom's express prior written consent.
....@@ -27,7 +28,7 @@
2728 *
2829 * <<Broadcom-WL-IPTag/Open:>>
2930 *
30
- * $Id: bcm_app_utils.c 599883 2015-11-17 04:55:57Z $
31
+ * $Id: bcm_app_utils.c 667243 2016-10-26 11:37:48Z $
3132 */
3233
3334 #include <typedefs.h>
....@@ -43,13 +44,13 @@
4344 #include <ctype.h>
4445 #ifndef ASSERT
4546 #define ASSERT(exp)
46
-#endif
47
+#endif // endif
4748 #endif /* BCMDRIVER */
4849 #include <bcmwifi_channels.h>
4950
5051 #if defined(WIN32) && (defined(BCMDLL) || defined(WLMDLL))
5152 #include <bcmstdlib.h> /* For wl/exe/GNUmakefile.brcm_wlu and GNUmakefile.wlm_dll */
52
-#endif
53
+#endif // endif
5354
5455 #include <bcmutils.h>
5556 #include <wlioctl.h>
....@@ -120,7 +121,7 @@
120121
121122 center_ch = CHSPEC_CHANNEL(chspec);
122123
123
- if (CHSPEC_IS20(chspec)) {
124
+ if (CHSPEC_BW_LE20(chspec)) {
124125 return center_ch;
125126 } else {
126127 /* the lower edge of the wide channel is half the bw from
....@@ -281,8 +282,8 @@
281282 #define NUM_OF_CNT_IN_WL_CNT_VER_11_T \
282283 ((sizeof(wl_cnt_ver_11_t) - 2 * sizeof(uint16)) / sizeof(uint32))
283284 /* Exclude 64 macstat cnt variables. */
284
-#define NUM_OF_WLCCNT_IN_WL_CNT_VER_11_T \
285
- (NUM_OF_CNT_IN_WL_CNT_VER_11_T - WL_CNT_MCST_VAR_NUM)
285
+#define NUM_OF_WLCCNT_IN_WL_CNT_VER_11_T \
286
+ ((sizeof(wl_cnt_wlc_t)) / sizeof(uint32))
286287
287288 /* Index conversion table from wl_cnt_ver_6_t to wl_cnt_wlc_t */
288289 static const uint8 wlcntver6t_to_wlcntwlct[NUM_OF_WLCCNT_IN_WL_CNT_VER_6_T] = {
....@@ -411,6 +412,8 @@
411412 IDX_IN_WL_CNT_VER_6_T(tkipicverr_mcst),
412413 IDX_IN_WL_CNT_VER_6_T(wepexcluded_mcst)
413414 };
415
+
416
+#define INVALID_IDX ((uint8)(-1))
414417
415418 /* Index conversion table from wl_cnt_ver_11_t to wl_cnt_wlc_t */
416419 static const uint8 wlcntver11t_to_wlcntwlct[NUM_OF_WLCCNT_IN_WL_CNT_VER_11_T] = {
....@@ -595,7 +598,18 @@
595598 IDX_IN_WL_CNT_VER_11_T(ampdu_wds),
596599 IDX_IN_WL_CNT_VER_11_T(txlost),
597600 IDX_IN_WL_CNT_VER_11_T(txdatamcast),
598
- IDX_IN_WL_CNT_VER_11_T(txdatabcast)
601
+ IDX_IN_WL_CNT_VER_11_T(txdatabcast),
602
+ INVALID_IDX,
603
+ IDX_IN_WL_CNT_VER_11_T(rxback),
604
+ IDX_IN_WL_CNT_VER_11_T(txback),
605
+ INVALID_IDX,
606
+ INVALID_IDX,
607
+ INVALID_IDX,
608
+ INVALID_IDX,
609
+ IDX_IN_WL_CNT_VER_11_T(txbcast),
610
+ IDX_IN_WL_CNT_VER_11_T(txdropped),
611
+ IDX_IN_WL_CNT_VER_11_T(rxbcast),
612
+ IDX_IN_WL_CNT_VER_11_T(rxdropped)
599613 };
600614
601615 /* Index conversion table from wl_cnt_ver_11_t to
....@@ -738,7 +752,6 @@
738752 IDX_IN_WL_CNT_VER_11_T(bphy_badplcp)
739753 };
740754
741
-
742755 /* Index conversion table from wl_cnt_ver_6_t to wl_cnt_v_le10_mcst_t */
743756 static const uint8 wlcntver6t_to_wlcntvle10mcstt[WL_CNT_MCST_VAR_NUM] = {
744757 IDX_IN_WL_CNT_VER_6_T(txallfrm),
....@@ -824,7 +837,7 @@
824837 if (cntver == WL_CNT_VERSION_6) {
825838 for (i = 0; i < NUM_OF_WLCCNT_IN_WL_CNT_VER_6_T; i++) {
826839 if (wlcntver6t_to_wlcntwlct[i] >= src_max_idx) {
827
- /* src buffer does not have counters from here */
840
+ /* src buffer does not have counters from here */
828841 break;
829842 }
830843 dst[i] = src[wlcntver6t_to_wlcntwlct[i]];
....@@ -832,8 +845,13 @@
832845 } else {
833846 for (i = 0; i < NUM_OF_WLCCNT_IN_WL_CNT_VER_11_T; i++) {
834847 if (wlcntver11t_to_wlcntwlct[i] >= src_max_idx) {
835
- /* src buffer does not have counters from here */
836
- break;
848
+ if (wlcntver11t_to_wlcntwlct[i] == INVALID_IDX) {
849
+ continue;
850
+ }
851
+ else {
852
+ /* src buffer does not have counters from here */
853
+ break;
854
+ }
837855 }
838856 dst[i] = src[wlcntver11t_to_wlcntwlct[i]];
839857 }
....@@ -905,7 +923,7 @@
905923 uint16 mcst_xtlv_id;
906924 int res = BCME_OK;
907925 wl_cnt_info_t *cntinfo = cntbuf;
908
- void *xtlvbuf_p = cntinfo->data;
926
+ uint8 *xtlvbuf_p = cntinfo->data;
909927 uint16 ver = cntinfo->version;
910928 uint16 xtlvbuflen = (uint16)buflen;
911929 uint16 src_max_idx;
....@@ -913,7 +931,7 @@
913931 osl_t *osh = ctx;
914932 #else
915933 BCM_REFERENCE(ctx);
916
-#endif
934
+#endif // endif
917935
918936 if (ver >= WL_CNT_VERSION_XTLV) {
919937 /* Already in xtlv format. */
....@@ -926,7 +944,7 @@
926944 #else
927945 wlccnt = (wl_cnt_wlc_t *)malloc(sizeof(*wlccnt));
928946 macstat = (uint32 *)malloc(WL_CNT_MCST_STRUCT_SZ);
929
-#endif
947
+#endif // endif
930948 if (!wlccnt || !macstat) {
931949 printf("%s: malloc fail!\n", __FUNCTION__);
932950 res = BCME_NOMEM;
....@@ -944,12 +962,11 @@
944962
945963 /* Exclude version and length fields in either wlc_cnt_ver_6_t or wlc_cnt_ver_11_t */
946964 src_max_idx = (cntinfo->datalen - OFFSETOF(wl_cnt_info_t, data)) / sizeof(uint32);
947
-
948965 if (src_max_idx > (uint8)(-1)) {
949966 printf("wlcntverXXt_to_wlcntwlct and src_max_idx need"
950967 " to be of uint16 instead of uint8\n"
951968 "Try updating wl utility to the latest.\n");
952
- res = BCME_ERROR;
969
+ src_max_idx = (uint8)(-1);
953970 }
954971
955972 /* Copy wlc layer counters to wl_cnt_wlc_t */
....@@ -1012,6 +1029,6 @@
10121029 if (macstat) {
10131030 free(macstat);
10141031 }
1015
-#endif
1032
+#endif // endif
10161033 return res;
10171034 }