.. | .. |
---|
1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
---|
2 | 1 | /* |
---|
3 | 2 | * Misc utility routines used by kernel or app-level. |
---|
4 | 3 | * Contents are wifi-specific, used by any kernel or app-level |
---|
5 | 4 | * software that might want wifi things as it grows. |
---|
6 | 5 | * |
---|
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 | + * |
---|
9 | 10 | * Unless you and Broadcom execute a separate written software license |
---|
10 | 11 | * agreement governing use of this software, this software is licensed to you |
---|
11 | 12 | * under the terms of the GNU General Public License version 2 (the "GPL"), |
---|
12 | 13 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the |
---|
13 | 14 | * following added to such license: |
---|
14 | | - * |
---|
| 15 | + * |
---|
15 | 16 | * As a special exception, the copyright holders of this software give you |
---|
16 | 17 | * permission to link this software with independent modules, and to copy and |
---|
17 | 18 | * distribute the resulting executable under terms of your choice, provided that |
---|
.. | .. |
---|
19 | 20 | * the license of that module. An independent module is a module which is not |
---|
20 | 21 | * derived from this software. The special exception does not apply to any |
---|
21 | 22 | * modifications of the software. |
---|
22 | | - * |
---|
| 23 | + * |
---|
23 | 24 | * Notwithstanding the above, under no circumstances may you combine this |
---|
24 | 25 | * software in any way with any other Broadcom software provided under a license |
---|
25 | 26 | * other than the GPL, without Broadcom's express prior written consent. |
---|
.. | .. |
---|
27 | 28 | * |
---|
28 | 29 | * <<Broadcom-WL-IPTag/Open:>> |
---|
29 | 30 | * |
---|
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 $ |
---|
31 | 32 | */ |
---|
32 | 33 | |
---|
33 | 34 | #include <typedefs.h> |
---|
.. | .. |
---|
43 | 44 | #include <ctype.h> |
---|
44 | 45 | #ifndef ASSERT |
---|
45 | 46 | #define ASSERT(exp) |
---|
46 | | -#endif |
---|
| 47 | +#endif // endif |
---|
47 | 48 | #endif /* BCMDRIVER */ |
---|
48 | 49 | #include <bcmwifi_channels.h> |
---|
49 | 50 | |
---|
50 | 51 | #if defined(WIN32) && (defined(BCMDLL) || defined(WLMDLL)) |
---|
51 | 52 | #include <bcmstdlib.h> /* For wl/exe/GNUmakefile.brcm_wlu and GNUmakefile.wlm_dll */ |
---|
52 | | -#endif |
---|
| 53 | +#endif // endif |
---|
53 | 54 | |
---|
54 | 55 | #include <bcmutils.h> |
---|
55 | 56 | #include <wlioctl.h> |
---|
.. | .. |
---|
120 | 121 | |
---|
121 | 122 | center_ch = CHSPEC_CHANNEL(chspec); |
---|
122 | 123 | |
---|
123 | | - if (CHSPEC_IS20(chspec)) { |
---|
| 124 | + if (CHSPEC_BW_LE20(chspec)) { |
---|
124 | 125 | return center_ch; |
---|
125 | 126 | } else { |
---|
126 | 127 | /* the lower edge of the wide channel is half the bw from |
---|
.. | .. |
---|
281 | 282 | #define NUM_OF_CNT_IN_WL_CNT_VER_11_T \ |
---|
282 | 283 | ((sizeof(wl_cnt_ver_11_t) - 2 * sizeof(uint16)) / sizeof(uint32)) |
---|
283 | 284 | /* 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)) |
---|
286 | 287 | |
---|
287 | 288 | /* Index conversion table from wl_cnt_ver_6_t to wl_cnt_wlc_t */ |
---|
288 | 289 | static const uint8 wlcntver6t_to_wlcntwlct[NUM_OF_WLCCNT_IN_WL_CNT_VER_6_T] = { |
---|
.. | .. |
---|
411 | 412 | IDX_IN_WL_CNT_VER_6_T(tkipicverr_mcst), |
---|
412 | 413 | IDX_IN_WL_CNT_VER_6_T(wepexcluded_mcst) |
---|
413 | 414 | }; |
---|
| 415 | + |
---|
| 416 | +#define INVALID_IDX ((uint8)(-1)) |
---|
414 | 417 | |
---|
415 | 418 | /* Index conversion table from wl_cnt_ver_11_t to wl_cnt_wlc_t */ |
---|
416 | 419 | static const uint8 wlcntver11t_to_wlcntwlct[NUM_OF_WLCCNT_IN_WL_CNT_VER_11_T] = { |
---|
.. | .. |
---|
595 | 598 | IDX_IN_WL_CNT_VER_11_T(ampdu_wds), |
---|
596 | 599 | IDX_IN_WL_CNT_VER_11_T(txlost), |
---|
597 | 600 | 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) |
---|
599 | 613 | }; |
---|
600 | 614 | |
---|
601 | 615 | /* Index conversion table from wl_cnt_ver_11_t to |
---|
.. | .. |
---|
738 | 752 | IDX_IN_WL_CNT_VER_11_T(bphy_badplcp) |
---|
739 | 753 | }; |
---|
740 | 754 | |
---|
741 | | - |
---|
742 | 755 | /* Index conversion table from wl_cnt_ver_6_t to wl_cnt_v_le10_mcst_t */ |
---|
743 | 756 | static const uint8 wlcntver6t_to_wlcntvle10mcstt[WL_CNT_MCST_VAR_NUM] = { |
---|
744 | 757 | IDX_IN_WL_CNT_VER_6_T(txallfrm), |
---|
.. | .. |
---|
824 | 837 | if (cntver == WL_CNT_VERSION_6) { |
---|
825 | 838 | for (i = 0; i < NUM_OF_WLCCNT_IN_WL_CNT_VER_6_T; i++) { |
---|
826 | 839 | 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 */ |
---|
828 | 841 | break; |
---|
829 | 842 | } |
---|
830 | 843 | dst[i] = src[wlcntver6t_to_wlcntwlct[i]]; |
---|
.. | .. |
---|
832 | 845 | } else { |
---|
833 | 846 | for (i = 0; i < NUM_OF_WLCCNT_IN_WL_CNT_VER_11_T; i++) { |
---|
834 | 847 | 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 | + } |
---|
837 | 855 | } |
---|
838 | 856 | dst[i] = src[wlcntver11t_to_wlcntwlct[i]]; |
---|
839 | 857 | } |
---|
.. | .. |
---|
905 | 923 | uint16 mcst_xtlv_id; |
---|
906 | 924 | int res = BCME_OK; |
---|
907 | 925 | wl_cnt_info_t *cntinfo = cntbuf; |
---|
908 | | - void *xtlvbuf_p = cntinfo->data; |
---|
| 926 | + uint8 *xtlvbuf_p = cntinfo->data; |
---|
909 | 927 | uint16 ver = cntinfo->version; |
---|
910 | 928 | uint16 xtlvbuflen = (uint16)buflen; |
---|
911 | 929 | uint16 src_max_idx; |
---|
.. | .. |
---|
913 | 931 | osl_t *osh = ctx; |
---|
914 | 932 | #else |
---|
915 | 933 | BCM_REFERENCE(ctx); |
---|
916 | | -#endif |
---|
| 934 | +#endif // endif |
---|
917 | 935 | |
---|
918 | 936 | if (ver >= WL_CNT_VERSION_XTLV) { |
---|
919 | 937 | /* Already in xtlv format. */ |
---|
.. | .. |
---|
926 | 944 | #else |
---|
927 | 945 | wlccnt = (wl_cnt_wlc_t *)malloc(sizeof(*wlccnt)); |
---|
928 | 946 | macstat = (uint32 *)malloc(WL_CNT_MCST_STRUCT_SZ); |
---|
929 | | -#endif |
---|
| 947 | +#endif // endif |
---|
930 | 948 | if (!wlccnt || !macstat) { |
---|
931 | 949 | printf("%s: malloc fail!\n", __FUNCTION__); |
---|
932 | 950 | res = BCME_NOMEM; |
---|
.. | .. |
---|
944 | 962 | |
---|
945 | 963 | /* Exclude version and length fields in either wlc_cnt_ver_6_t or wlc_cnt_ver_11_t */ |
---|
946 | 964 | src_max_idx = (cntinfo->datalen - OFFSETOF(wl_cnt_info_t, data)) / sizeof(uint32); |
---|
947 | | - |
---|
948 | 965 | if (src_max_idx > (uint8)(-1)) { |
---|
949 | 966 | printf("wlcntverXXt_to_wlcntwlct and src_max_idx need" |
---|
950 | 967 | " to be of uint16 instead of uint8\n" |
---|
951 | 968 | "Try updating wl utility to the latest.\n"); |
---|
952 | | - res = BCME_ERROR; |
---|
| 969 | + src_max_idx = (uint8)(-1); |
---|
953 | 970 | } |
---|
954 | 971 | |
---|
955 | 972 | /* Copy wlc layer counters to wl_cnt_wlc_t */ |
---|
.. | .. |
---|
1012 | 1029 | if (macstat) { |
---|
1013 | 1030 | free(macstat); |
---|
1014 | 1031 | } |
---|
1015 | | -#endif |
---|
| 1032 | +#endif // endif |
---|
1016 | 1033 | return res; |
---|
1017 | 1034 | } |
---|