]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/staging/brcm80211/brcmsmac/channel.h
staging: brcm80211: removed superfluous forward struct declarations
[mirror_ubuntu-zesty-kernel.git] / drivers / staging / brcm80211 / brcmsmac / channel.h
1 /*
2 * Copyright (c) 2010 Broadcom Corporation
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef _BRCM_CHANNEL_H_
18 #define _BRCM_CHANNEL_H_
19
20 #define WLC_TXPWR_DB_FACTOR 4 /* conversion for phy txpwr cacluations that use .25 dB units */
21
22
23 /* maxpwr mapping to 5GHz band channels:
24 * maxpwr[0] - channels [34-48]
25 * maxpwr[1] - channels [52-60]
26 * maxpwr[2] - channels [62-64]
27 * maxpwr[3] - channels [100-140]
28 * maxpwr[4] - channels [149-165]
29 */
30 #define BAND_5G_PWR_LVLS 5 /* 5 power levels for 5G */
31
32 /* power level in group of 2.4GHz band channels:
33 * maxpwr[0] - CCK channels [1]
34 * maxpwr[1] - CCK channels [2-10]
35 * maxpwr[2] - CCK channels [11-14]
36 * maxpwr[3] - OFDM channels [1]
37 * maxpwr[4] - OFDM channels [2-10]
38 * maxpwr[5] - OFDM channels [11-14]
39 */
40
41 /* macro to get 2.4 GHz channel group index for tx power */
42 #define CHANNEL_POWER_IDX_2G_CCK(c) (((c) < 2) ? 0 : (((c) < 11) ? 1 : 2)) /* cck index */
43 #define CHANNEL_POWER_IDX_2G_OFDM(c) (((c) < 2) ? 3 : (((c) < 11) ? 4 : 5)) /* ofdm index */
44
45 /* macro to get 5 GHz channel group index for tx power */
46 #define CHANNEL_POWER_IDX_5G(c) \
47 (((c) < 52) ? 0 : (((c) < 62) ? 1 : (((c) < 100) ? 2 : (((c) < 149) ? 3 : 4))))
48
49 #define WLC_MAXPWR_TBL_SIZE 6 /* max of BAND_5G_PWR_LVLS and 6 for 2.4 GHz */
50 #define WLC_MAXPWR_MIMO_TBL_SIZE 14 /* max of BAND_5G_PWR_LVLS and 14 for 2.4 GHz */
51
52 #define NBANDS(wlc) ((wlc)->pub->_nbands)
53 #define NBANDS_PUB(pub) ((pub)->_nbands)
54 #define NBANDS_HW(hw) ((hw)->_nbands)
55
56 #define IS_SINGLEBAND_5G(device) 0
57
58 /* locale channel and power info. */
59 struct locale_info {
60 u32 valid_channels;
61 u8 radar_channels; /* List of radar sensitive channels */
62 u8 restricted_channels; /* List of channels used only if APs are detected */
63 s8 maxpwr[WLC_MAXPWR_TBL_SIZE]; /* Max tx pwr in qdBm for each sub-band */
64 s8 pub_maxpwr[BAND_5G_PWR_LVLS]; /* Country IE advertised max tx pwr in dBm
65 * per sub-band
66 */
67 u8 flags;
68 };
69
70 /* bits for locale_info flags */
71 #define WLC_PEAK_CONDUCTED 0x00 /* Peak for locals */
72 #define WLC_EIRP 0x01 /* Flag for EIRP */
73 #define WLC_DFS_TPC 0x02 /* Flag for DFS TPC */
74 #define WLC_NO_OFDM 0x04 /* Flag for No OFDM */
75 #define WLC_NO_40MHZ 0x08 /* Flag for No MIMO 40MHz */
76 #define WLC_NO_MIMO 0x10 /* Flag for No MIMO, 20 or 40 MHz */
77 #define WLC_RADAR_TYPE_EU 0x20 /* Flag for EU */
78 #define WLC_DFS_FCC WLC_DFS_TPC /* Flag for DFS FCC */
79 #define WLC_DFS_EU (WLC_DFS_TPC | WLC_RADAR_TYPE_EU) /* Flag for DFS EU */
80
81 #define ISDFS_EU(fl) (((fl) & WLC_DFS_EU) == WLC_DFS_EU)
82
83 /* locale per-channel tx power limits for MIMO frames
84 * maxpwr arrays are index by channel for 2.4 GHz limits, and
85 * by sub-band for 5 GHz limits using CHANNEL_POWER_IDX_5G(channel)
86 */
87 struct locale_mimo_info {
88 s8 maxpwr20[WLC_MAXPWR_MIMO_TBL_SIZE]; /* tx 20 MHz power limits, qdBm units */
89 s8 maxpwr40[WLC_MAXPWR_MIMO_TBL_SIZE]; /* tx 40 MHz power limits, qdBm units */
90 u8 flags;
91 };
92
93 extern const chanvec_t chanvec_all_2G;
94 extern const chanvec_t chanvec_all_5G;
95
96 /*
97 * Country names and abbreviations with locale defined from ISO 3166
98 */
99 struct country_info {
100 const u8 locale_2G; /* 2.4G band locale */
101 const u8 locale_5G; /* 5G band locale */
102 const u8 locale_mimo_2G; /* 2.4G mimo info */
103 const u8 locale_mimo_5G; /* 5G mimo info */
104 };
105
106 extern wlc_cm_info_t *wlc_channel_mgr_attach(struct brcms_c_info *wlc);
107 extern void wlc_channel_mgr_detach(wlc_cm_info_t *wlc_cm);
108
109 extern u8 wlc_channel_locale_flags_in_band(wlc_cm_info_t *wlc_cm,
110 uint bandunit);
111
112 extern bool wlc_valid_chanspec_db(wlc_cm_info_t *wlc_cm, chanspec_t chspec);
113
114 extern void wlc_channel_reg_limits(wlc_cm_info_t *wlc_cm,
115 chanspec_t chanspec,
116 struct txpwr_limits *txpwr);
117 extern void wlc_channel_set_chanspec(wlc_cm_info_t *wlc_cm,
118 chanspec_t chanspec,
119 u8 local_constraint_qdbm);
120
121 #endif /* _WLC_CHANNEL_H */