* Contents are wifi-specific, used by any kernel or app-level
* software that might want wifi things as it grows.
*
- * $Copyright Open Broadcom Corporation$
- * $Id: bcmwifi_channels.c 309193 2012-01-19 00:03:57Z $
+ * Copyright (C) 1999-2016, Broadcom Corporation
+ *
+ * Unless you and Broadcom execute a separate written software license
+ * agreement governing use of this software, this software is licensed to you
+ * under the terms of the GNU General Public License version 2 (the "GPL"),
+ * available at http://www.broadcom.com/licenses/GPLv2.php, with the
+ * following added to such license:
+ *
+ * As a special exception, the copyright holders of this software give you
+ * permission to link this software with independent modules, and to copy and
+ * distribute the resulting executable under terms of your choice, provided that
+ * you also meet, for each linked independent module, the terms and conditions of
+ * the license of that module. An independent module is a module which is not
+ * derived from this software. The special exception does not apply to any
+ * modifications of the software.
+ *
+ * Notwithstanding the above, under no circumstances may you combine this
+ * software in any way with any other Broadcom software provided under a license
+ * other than the GPL, without Broadcom's express prior written consent.
+ *
+ *
+ * <<Broadcom-WL-IPTag/Open:>>
+ *
+ * $Id: bcmwifi_channels.c 591285 2015-10-07 11:56:29Z $
*/
#include <bcm_cfg.h>
"80",
"160",
"80+80",
+#ifdef WL11ULB
+ "2.5"
+#else /* WL11ULB */
"na"
+#endif /* WL11ULB */
};
static const uint8 wf_chspec_bw_mhz[] =
/* parse channel num or band */
if (!read_uint(&a, &num))
return 0;
-
/* if we are looking at a 'g', then the first number was a band */
c = tolower((int)a[0]);
if (c == 'g') {
- a ++; /* consume the char */
+ a++; /* consume the char */
/* band must be "2" or "5" */
if (num == 2)
return 0;
/* convert to chspec value */
- if (bw == 20) {
+ if (bw == 2) {
+ chspec_bw = WL_CHANSPEC_BW_2P5;
+ } else if (bw == 5) {
+ chspec_bw = WL_CHANSPEC_BW_5;
+ } else if (bw == 10) {
+ chspec_bw = WL_CHANSPEC_BW_10;
+ } else if (bw == 20) {
chspec_bw = WL_CHANSPEC_BW_20;
} else if (bw == 40) {
chspec_bw = WL_CHANSPEC_BW_40;
/* So far we have <band>g<chan>/<bw>
* Can now be followed by u/l if bw = 40,
- * or '+80' if bw = 80, to make '80+80' bw.
+ * or '+80' if bw = 80, to make '80+80' bw,
+ * or '.5' if bw = 2.5 to make '2.5' bw .
*/
c = tolower((int)a[0]);
/* check for 80+80 */
if (c == '+') {
/* 80+80 */
- static const char *plus80 = "80/";
+ const char plus80[] = "80/";
/* must be looking at '+80/'
* check and consume this string.
/* consume the '80/' string */
for (i = 0; i < 3; i++) {
- if (*a++ != *plus80++) {
+ if (*a++ != plus80[i]) {
return 0;
}
}
/* read secondary 80MHz channel */
if (!read_uint(&a, &ch2))
return 0;
+ } else if (c == '.') {
+ /* 2.5 */
+ /* must be looking at '.5'
+ * check and consume this string.
+ */
+ chspec_bw = WL_CHANSPEC_BW_2P5;
+
+ a ++; /* consume the char '.' */
+
+ /* consume the '5' string */
+ if (*a++ != '5') {
+ return 0;
+ }
}
done_read:
}
}
/* if the bw is 20, center and sideband are trivial */
- else if (chspec_bw == WL_CHANSPEC_BW_20) {
+ else if (BW_LE20(chspec_bw)) {
chspec_ch = ctl_ch;
chspec_sb = WL_CHANSPEC_CTL_SB_NONE;
}
/* must be 2G or 5G band */
if (CHSPEC_IS2G(chanspec)) {
/* must be valid bandwidth */
- if (chspec_bw != WL_CHANSPEC_BW_20 &&
- chspec_bw != WL_CHANSPEC_BW_40) {
+ if (!BW_LE40(chspec_bw)) {
return TRUE;
}
} else if (CHSPEC_IS5G(chanspec)) {
if (ch1_id >= WF_NUM_5G_80M_CHANS || ch2_id >= WF_NUM_5G_80M_CHANS)
return TRUE;
- } else if (chspec_bw == WL_CHANSPEC_BW_20 || chspec_bw == WL_CHANSPEC_BW_40 ||
- chspec_bw == WL_CHANSPEC_BW_80 || chspec_bw == WL_CHANSPEC_BW_160) {
-
+ } else if (BW_LE160(chspec_bw)) {
if (chspec_ch > MAXCHANNEL) {
return TRUE;
}
}
/* side band needs to be consistent with bandwidth */
- if (chspec_bw == WL_CHANSPEC_BW_20) {
+ if (BW_LE20(chspec_bw)) {
if (CHSPEC_CTL_SB(chanspec) != WL_CHANSPEC_CTL_SB_LLL)
return TRUE;
} else if (chspec_bw == WL_CHANSPEC_BW_40) {
if (CHSPEC_IS2G(chanspec)) {
/* must be valid bandwidth and channel range */
- if (chspec_bw == WL_CHANSPEC_BW_20) {
+ if (BW_LE20(chspec_bw)) {
if (chspec_ch >= 1 && chspec_ch <= 14)
return TRUE;
} else if (chspec_bw == WL_CHANSPEC_BW_40) {
const uint8 *center_ch;
uint num_ch, i;
- if (chspec_bw == WL_CHANSPEC_BW_20 || chspec_bw == WL_CHANSPEC_BW_40) {
+ if (BW_LE40(chspec_bw)) {
center_ch = wf_5g_40m_chans;
num_ch = WF_NUM_5G_40M_CHANS;
} else if (chspec_bw == WL_CHANSPEC_BW_80) {
}
/* check for a valid center channel */
- if (chspec_bw == WL_CHANSPEC_BW_20) {
+ if (BW_LE20(chspec_bw)) {
/* We don't have an array of legal 20MHz 5G channels, but they are
* each side of the legal 40MHz channels. Check the chanspec
* channel against either side of the 40MHz channels.
ASSERT(!wf_chspec_malformed(chspec));
/* Is there a sideband ? */
- if (CHSPEC_IS20(chspec)) {
+ if (CHSPEC_BW_LE20(chspec)) {
return CHSPEC_CHANNEL(chspec);
} else {
sb = CHSPEC_CTL_SB(chspec) >> WL_CHANSPEC_CTL_SB_SHIFT;
char *
wf_chspec_to_bw_str(chanspec_t chspec)
{
- return (char *)wf_chspec_bw_str[(CHSPEC_BW(chspec) >> WL_CHANSPEC_BW_SHIFT)];
+ return (char *)wf_chspec_bw_str[(CHSPEC_BW(chspec) >> WL_CHANSPEC_BW_SHIFT)];
}
/*
ASSERT(!wf_chspec_malformed(chspec));
/* Is there a sideband ? */
- if (!CHSPEC_IS20(chspec)) {
+ if (!CHSPEC_BW_LE20(chspec)) {
ctl_chan = wf_chspec_ctlchan(chspec);
ctl_chspec = ctl_chan | WL_CHANSPEC_BW_20;
ctl_chspec |= CHSPEC_BAND(chspec);
center_ch = wf_5g_160m_chans;
num_ch = WF_NUM_5G_160M_CHANS;
bw = 160;
- } else if (bw == WL_CHANSPEC_BW_20) {
+ } else if (BW_LE20(bw)) {
chspec |= ctl_ch;
return chspec;
} else {