sysfs: Remove support for tagged directories with untagged members (again)
[linux-btrfs-devel.git] / drivers / staging / brcm80211 / brcmsmac / channel.h
blobd22f2f5f592daafa7c98c33fea122d92f6f16138
1 /*
2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
17 #ifndef _BRCM_CHANNEL_H_
18 #define _BRCM_CHANNEL_H_
20 /* conversion for phy txpwr calculations that use .25 dB units */
21 #define BRCMS_TXPWR_DB_FACTOR 4
24 /* maxpwr mapping to 5GHz band channels:
25 * maxpwr[0] - channels [34-48]
26 * maxpwr[1] - channels [52-60]
27 * maxpwr[2] - channels [62-64]
28 * maxpwr[3] - channels [100-140]
29 * maxpwr[4] - channels [149-165]
31 #define BAND_5G_PWR_LVLS 5 /* 5 power levels for 5G */
33 /* power level in group of 2.4GHz band channels:
34 * maxpwr[0] - CCK channels [1]
35 * maxpwr[1] - CCK channels [2-10]
36 * maxpwr[2] - CCK channels [11-14]
37 * maxpwr[3] - OFDM channels [1]
38 * maxpwr[4] - OFDM channels [2-10]
39 * maxpwr[5] - OFDM channels [11-14]
42 /* macro to get 2.4 GHz channel group index for tx power */
43 #define CHANNEL_POWER_IDX_2G_CCK(c) (((c) < 2) ? 0 : (((c) < 11) ? 1 : 2)) /* cck index */
44 #define CHANNEL_POWER_IDX_2G_OFDM(c) (((c) < 2) ? 3 : (((c) < 11) ? 4 : 5)) /* ofdm index */
46 /* macro to get 5 GHz channel group index for tx power */
47 #define CHANNEL_POWER_IDX_5G(c) \
48 (((c) < 52) ? 0 : (((c) < 62) ? 1 : (((c) < 100) ? 2 : (((c) < 149) ? 3 : 4))))
50 /* max of BAND_5G_PWR_LVLS and 6 for 2.4 GHz */
51 #define BRCMS_MAXPWR_TBL_SIZE 6
52 /* max of BAND_5G_PWR_LVLS and 14 for 2.4 GHz */
53 #define BRCMS_MAXPWR_MIMO_TBL_SIZE 14
55 #define NBANDS(wlc) ((wlc)->pub->_nbands)
56 #define NBANDS_PUB(pub) ((pub)->_nbands)
57 #define NBANDS_HW(hw) ((hw)->_nbands)
59 #define IS_SINGLEBAND_5G(device) 0
61 /* locale channel and power info. */
62 struct locale_info {
63 u32 valid_channels;
64 /* List of radar sensitive channels */
65 u8 radar_channels;
66 /* List of channels used only if APs are detected */
67 u8 restricted_channels;
68 /* Max tx pwr in qdBm for each sub-band */
69 s8 maxpwr[BRCMS_MAXPWR_TBL_SIZE];
70 s8 pub_maxpwr[BAND_5G_PWR_LVLS]; /* Country IE advertised max tx pwr in dBm
71 * per sub-band
73 u8 flags;
76 /* bits for locale_info flags */
77 #define BRCMS_PEAK_CONDUCTED 0x00 /* Peak for locals */
78 #define BRCMS_EIRP 0x01 /* Flag for EIRP */
79 #define BRCMS_DFS_TPC 0x02 /* Flag for DFS TPC */
80 #define BRCMS_NO_OFDM 0x04 /* Flag for No OFDM */
81 #define BRCMS_NO_40MHZ 0x08 /* Flag for No MIMO 40MHz */
82 #define BRCMS_NO_MIMO 0x10 /* Flag for No MIMO, 20 or 40 MHz */
83 #define BRCMS_RADAR_TYPE_EU 0x20 /* Flag for EU */
84 #define BRCMS_DFS_FCC BRCMS_DFS_TPC /* Flag for DFS FCC */
85 #define BRCMS_DFS_EU (BRCMS_DFS_TPC | BRCMS_RADAR_TYPE_EU) /* Flag for DFS EU */
87 #define ISDFS_EU(fl) (((fl) & BRCMS_DFS_EU) == BRCMS_DFS_EU)
89 /* locale per-channel tx power limits for MIMO frames
90 * maxpwr arrays are index by channel for 2.4 GHz limits, and
91 * by sub-band for 5 GHz limits using CHANNEL_POWER_IDX_5G(channel)
93 struct locale_mimo_info {
94 /* tx 20 MHz power limits, qdBm units */
95 s8 maxpwr20[BRCMS_MAXPWR_MIMO_TBL_SIZE];
96 /* tx 40 MHz power limits, qdBm units */
97 s8 maxpwr40[BRCMS_MAXPWR_MIMO_TBL_SIZE];
98 u8 flags;
101 extern const chanvec_t chanvec_all_2G;
102 extern const chanvec_t chanvec_all_5G;
105 * Country names and abbreviations with locale defined from ISO 3166
107 struct country_info {
108 const u8 locale_2G; /* 2.4G band locale */
109 const u8 locale_5G; /* 5G band locale */
110 const u8 locale_mimo_2G; /* 2.4G mimo info */
111 const u8 locale_mimo_5G; /* 5G mimo info */
114 extern struct brcms_cm_info *
115 brcms_c_channel_mgr_attach(struct brcms_c_info *wlc);
117 extern void brcms_c_channel_mgr_detach(struct brcms_cm_info *wlc_cm);
119 extern u8 brcms_c_channel_locale_flags_in_band(struct brcms_cm_info *wlc_cm,
120 uint bandunit);
122 extern bool brcms_c_valid_chanspec_db(struct brcms_cm_info *wlc_cm,
123 chanspec_t chspec);
125 extern void brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm,
126 chanspec_t chanspec,
127 struct txpwr_limits *txpwr);
128 extern void brcms_c_channel_set_chanspec(struct brcms_cm_info *wlc_cm,
129 chanspec_t chanspec,
130 u8 local_constraint_qdbm);
132 #endif /* _WLC_CHANNEL_H */