Update v3.4 driver for v3.5 rflib API
[wave300.git] / wireless / driver / shared / channels.h
blob05fe45738ab5b13109abe39f982a0a392cb59200
1 /******************************************************************************
3 Copyright (c) 2012
4 Lantiq Deutschland GmbH
6 For licensing information, see the file 'LICENSE' in the root folder of
7 this software module.
9 ******************************************************************************/
11 * $Id$
15 * Written by: Roman Sikorskyy
19 #ifndef __CHANNELS_H__
20 #define __CHANNELS_H__
22 #include "mhi_umi.h"
23 #include "mhi_mib_id.h"
24 #include "scan.h"
25 #include "aocs.h"
26 #include "mtlk_clipboard.h"
28 #define MTLK_IDEFS_ON
29 #include "mtlkidefs.h"
31 #define SCAN_ACTIVE MIB_ST_ACTIVE
32 #define SCAN_PASSIVE MIB_ST_PASSIVE
34 #define MAX_CHANNELS 50
35 #define MAX_INTERF_CHANNELS 14
37 /* Need to be synchronized with ARRAY_SIZE(country_reg_table) */
38 /* it can't be shared directly */
39 #define MAX_COUNTRIES 249
41 #define ALTERNATE_LOWER 1
42 #define ALTERNATE_UPPER 0
43 #define ALTERNATE_NONE (-1)
45 #define SPECTRUM_20MHZ MIB_SPECTRUM_20M
46 #define SPECTRUM_40MHZ MIB_SPECTRUM_40M
47 #define SPECTRUM_AUTO (SPECTRUM_40MHZ+1)
49 #define REG_LIMITS 0x01
50 #define HW_LIMITS 0x02
51 #define ANTENNA_GAIN 0x04
52 #define ALL_LIMITS (REG_LIMITS | HW_LIMITS | ANTENNA_GAIN)
54 #define MTLK_CHNLS_DOT11H_CALLER 1
55 #define MTLK_CHNLS_SCAN_CALLER 2
56 #define MTLK_CHNLS_COUNTRY_CALLER 3
58 #define MTLK_CHNLS_COUNTRY_BUFSIZE 3
60 struct reg_tx_limit;
61 struct hw_reg_tx_limit;
62 struct antenna_gain;
63 struct _mtlk_hw_cfg_t;
64 struct _mtlk_ant_cfg_t;
65 struct _mtlk_tx_power_limit_cfg_t;
67 typedef struct _tx_limit_t
69 struct reg_tx_limit *reg_lim;
70 struct hw_reg_tx_limit *hw_lim;
71 size_t num_gains;
72 struct antenna_gain *gain;
73 /* this is needed for HW limits - to load initial data */
74 uint16 vendor_id;
75 uint16 device_id;
76 uint8 hw_type;
77 uint8 hw_revision;
78 uint8 num_tx_antennas;
79 uint8 num_rx_antennas;
80 } __MTLK_IDATA tx_limit_t;
82 typedef struct _mtlk_get_channel_data_t {
83 uint8 reg_domain;
84 uint8 is_ht;
85 BOOL ap;
86 uint8 spectrum_mode;
87 uint8 bonding;
88 uint16 channel;
89 uint8 frequency_band;
90 BOOL disable_sm_channels;
91 uint8 net_mode;
92 } mtlk_get_channel_data_t;
94 typedef struct {
95 int16 tx_lim;
96 uint16 freq;
97 uint8 spectrum;
98 uint8 reg_domain;
99 } __MTLK_IDATA mtlk_hw_limits_stat_entry_t;
101 typedef struct {
102 uint16 tx_lim;
103 uint8 reg_domain;
104 uint8 reg_class;
105 uint8 spectrum;
106 uint8 channel;
107 uint8 mitigation;
108 } __MTLK_IDATA mtlk_reg_limits_stat_entry_t;
110 typedef struct {
111 uint16 freq;
112 int16 gain;
113 } __MTLK_IDATA mtlk_ant_gain_stat_entry_t;
115 typedef enum _select_channel_2ghz_ncb_e
117 NCB_2GHZ_CH_1,
118 NCB_2GHZ_CH_6,
119 NCB_2GHZ_CH_11,
120 NCB_2GHZ_CH_LAST
121 } select_channel_2ghz_ncb_e;
123 int32 __MTLK_IFUNC mtlk_get_antennas_factor (uint32 antennas_num);
124 int16 __MTLK_IFUNC mtlk_calc_tx_power_lim (tx_limit_t *lim, uint16 channel, uint8 reg_domain,
125 uint8 spectrum_mode, int8 upper_lower, uint8 num_antennas);
126 #if 0
127 int __MTLK_IFUNC mtlk_fill_freq_element (mtlk_handle_t context, FREQUENCY_ELEMENT *el, uint8 channel, uint8 band, uint8 bw, uint8 reg_domain);
128 #endif
129 int16 __MTLK_IFUNC mtlk_get_antenna_gain(tx_limit_t *lim, uint16 channel);
131 int __MTLK_IFUNC mtlk_init_tx_limit_tables (tx_limit_t *lim, uint16 vendor_id, uint16 device_id,
132 uint8 hw_type, uint8 hw_revision);
133 int __MTLK_IFUNC mtlk_cleanup_tx_limit_tables (tx_limit_t *lim);
134 int __MTLK_IFUNC mtlk_reset_tx_limit_tables (tx_limit_t *lim);
135 int __MTLK_IFUNC mtlk_update_reg_limit_table (mtlk_handle_t handle, struct country_ie_t *ie, int8 power_constraint);
137 int __MTLK_IFUNC mtlk_set_hw_limit (tx_limit_t *lim, struct _mtlk_hw_cfg_t *cfg);
138 int __MTLK_IFUNC mtlk_set_ant_gain (tx_limit_t *lim, struct _mtlk_ant_cfg_t *cfg);
139 int __MTLK_IFUNC mtlk_set_power_limit (mtlk_core_t *core);
141 int __MTLK_IFUNC mtlk_channels_get_hw_limits(tx_limit_t *lim, mtlk_clpb_t *clpb);
143 int __MTLK_IFUNC mtlk_channels_get_reg_limits(tx_limit_t *lim, mtlk_clpb_t *clpb);
145 int __MTLK_IFUNC mtlk_channels_get_ant_gain(tx_limit_t *lim, mtlk_clpb_t *clpb);
147 int __MTLK_IFUNC mtlk_set_country_mib (mtlk_txmm_t *txmm,
148 uint8 reg_domain,
149 uint8 is_ht,
150 uint8 frequency_band,
151 BOOL is_ap,
152 const char *country,
153 BOOL is_dot11d_active);
154 uint8 __MTLK_IFUNC mtlk_get_channel_mitigation(uint8 reg_domain, uint8 is_ht, uint8 spectrum_mode, uint16 channel);
155 int __MTLK_IFUNC
156 mtlk_get_avail_channels(mtlk_get_channel_data_t *param, uint8 *channels);
157 int __MTLK_IFUNC
158 mtlk_check_channel(mtlk_get_channel_data_t *param, uint8 channel);
160 int __MTLK_IFUNC mtlk_prepare_scan_vector (mtlk_handle_t context, struct mtlk_scan *scan_data, int freq, uint8 reg_domain);
161 void __MTLK_IFUNC mtlk_free_scan_vector (mtlk_scan_vector_t *vector);
163 uint8 __MTLK_IFUNC mtlk_select_reg_domain (uint16 channel);
165 uint8 __MTLK_IFUNC mtlk_get_chnl_switch_mode (uint8 spectrum_mode, uint8 bonding, uint8 is_silent_sw);
167 static __INLINE uint8 __MTLK_IFUNC
168 channel_to_band (uint16 channel)
170 #define FIRST_5_2_CHANNEL 36
171 return (channel < FIRST_5_2_CHANNEL)? MTLK_HW_BAND_2_4_GHZ : MTLK_HW_BAND_5_2_GHZ;
172 #undef FIRST_5_2_CHANNEL
175 static __INLINE uint16 __MTLK_IFUNC
176 channel_to_frequency (uint16 channel)
178 #define CHANNEL_THRESHOLD 180
179 uint16 res;
180 /* IEEE Std 802.11-2012: 20.3.15 Channel numbering and channelization
181 Channel center frequency = starting frequency + 5 * ch
183 if (channel_to_band(channel) == MTLK_HW_BAND_2_4_GHZ)
185 res = 2407 + 5*channel;
186 if(channel == 14) /* IEEE Std 802.11-2012: 17.4.6.3 Channel Numbering of operating channels */
187 res += 7;
189 else if (channel < CHANNEL_THRESHOLD)
190 res = 5000 + 5*channel;
191 else
192 res = 4000 + 5*channel;
193 #undef CHANNEL_THRESHOLD
194 return res;
197 uint8 __MTLK_IFUNC country_code_to_domain (uint8 country_code);
198 const char * __MTLK_IFUNC country_code_to_country (uint8 country_code);
199 uint8 __MTLK_IFUNC country_to_country_code (const char *country);
201 struct _mtlk_gen_core_country_name_t;
202 void __MTLK_IFUNC get_all_countries_for_domain(uint8 domain,
203 struct _mtlk_gen_core_country_name_t *countries,
204 uint32 countries_buffer_size);
206 static uint8 __INLINE __MTLK_IFUNC
207 country_to_domain (const char *country)
209 return country_code_to_domain(country_to_country_code(country));
212 BOOL __MTLK_IFUNC mtlk_channels_does_domain_exist(uint8 reg_domain);
214 void __MTLK_IFUNC mtlk_channels_fill_activate_req_ext_data(mtlk_get_channel_data_t *params,
215 mtlk_core_t *core,
216 uint8 u8SwitchMode,
217 void *data);
220 void __MTLK_IFUNC mtlk_channels_fill_mbss_pre_activate_req_ext_data(mtlk_get_channel_data_t *params,
221 mtlk_core_t *core,
222 uint8 u8SwitchMode,
223 void *data);
225 BOOL __MTLK_IFUNC mtlk_channels_find_secondary_channel_no(mtlk_vap_handle_t vap_handle, uint16 primary_channel_no, int secondary_channel_offset, uint16 *secondary_channel_no);
227 BOOL __MTLK_IFUNC mtlk_channels_find_available_channel_pair(int reg_domain, uint16 primary_channel, int secondary_channel_offset);
229 uint16 __MTLK_IFUNC mtlk_channels_get_secondary_channel_no_by_offset(uint16 primary_channel_no, uint8 secondary_channel_offset);
231 #define MTLK_IDEFS_OFF
232 #include "mtlkidefs.h"
234 #endif /* __CHANNELS_H__ */