• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __INC_DOT11D_H
3 #define __INC_DOT11D_H
4 
5 #include "ieee80211.h"
6 
7 struct chnl_txpower_triple {
8 	u8  first_channel;
9 	u8  num_channels;
10 	u8  max_tx_pwr_dbm;
11 };
12 
13 enum dot11d_state {
14 	DOT11D_STATE_NONE = 0,
15 	DOT11D_STATE_LEARNED,
16 	DOT11D_STATE_DONE,
17 };
18 
19 struct rt_dot11d_info {
20 	u16 country_ie_len; /* > 0 if country_ie_buf[] contains valid country information element. */
21 
22 	/*  country_ie_src_addr u16 aligned for comparison and copy */
23 	u8  country_ie_src_addr[ETH_ALEN]; /* Source AP of the country IE. */
24 	u8  country_ie_buf[MAX_IE_LEN];
25 	u8  country_ie_watchdog;
26 
27 	u8  channel_map[MAX_CHANNEL_NUMBER + 1];  /* !Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) */
28 	u8  max_tx_pwr_dbm_list[MAX_CHANNEL_NUMBER + 1];
29 
30 	enum dot11d_state state;
31 	u8  dot11d_enabled; /* dot11MultiDomainCapabilityEnabled */
32 };
33 
34 #define GET_DOT11D_INFO(ieee_dev) ((struct rt_dot11d_info *)((ieee_dev)->dot11d_info))
35 
36 #define IS_DOT11D_ENABLE(ieee_dev) (GET_DOT11D_INFO(ieee_dev)->dot11d_enabled)
37 #define IS_COUNTRY_IE_VALID(ieee_dev) (GET_DOT11D_INFO(ieee_dev)->country_ie_len > 0)
38 
39 #define IS_EQUAL_CIE_SRC(ieee_dev, addr) ether_addr_equal(GET_DOT11D_INFO(ieee_dev)->country_ie_src_addr, addr)
40 #define UPDATE_CIE_SRC(ieee_dev, addr) ether_addr_copy(GET_DOT11D_INFO(ieee_dev)->country_ie_src_addr, addr)
41 
42 #define GET_CIE_WATCHDOG(ieee_dev) (GET_DOT11D_INFO(ieee_dev)->country_ie_watchdog)
43 #define RESET_CIE_WATCHDOG(ieee_dev) (GET_CIE_WATCHDOG(ieee_dev) = 0)
44 #define UPDATE_CIE_WATCHDOG(ieee_dev) (++GET_CIE_WATCHDOG(ieee_dev))
45 
46 void rtl8192u_dot11d_init(struct ieee80211_device *dev);
47 void dot11d_reset(struct ieee80211_device *dev);
48 void dot11d_update_country_ie(struct ieee80211_device *dev,
49 			      u8 *addr,
50 			      u16 coutry_ie_len,
51 			      u8 *coutry_ie);
52 u8 dot11d_get_max_tx_pwr_in_dbm(struct ieee80211_device *dev, u8 channel);
53 void dot11d_scan_complete(struct ieee80211_device *dev);
54 int is_legal_channel(struct ieee80211_device *dev, u8 channel);
55 int to_legal_channel(struct ieee80211_device *dev, u8 channel);
56 
57 #endif /* #ifndef __INC_DOT11D_H */
58