1/* SPDX-License-Identifier: GPL-2.0 */
2/******************************************************************************
3 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
4 *
5 * Contact Information:
6 * wlanfae <wlanfae@realtek.com>
7 ******************************************************************************/
8#ifndef __INC_DOT11D_H
9#define __INC_DOT11D_H
10
11#include "rtllib.h"
12
13struct chnl_txpow_triple {
14 u8 first_channel;
15 u8 num_channels;
16 u8 max_tx_power;
17};
18
19enum dot11d_state {
20 DOT11D_STATE_NONE = 0,
21 DOT11D_STATE_LEARNED,
22 DOT11D_STATE_DONE,
23};
24
25/**
26 * struct rt_dot11d_info * @country_len: value greater than 0 if
27 * @country_buffer contains valid country information element.
28 * @channel_map: holds channel values
29 * 0 - invalid,
30 * 1 - valid (active scan),
31 * 2 - valid (passive scan)
32 * @country_src_addr - Source AP of the country IE
33 */
34
35struct rt_dot11d_info {
36 bool enabled;
37
38 u16 country_len;
39 u8 country_buffer[MAX_IE_LEN];
40 u8 country_src_addr[6];
41 u8 country_watchdog;
42
43 u8 channel_map[MAX_CHANNEL_NUMBER + 1];
44 u8 max_tx_power_list[MAX_CHANNEL_NUMBER + 1];
45
46 enum dot11d_state state;
47};
48
49static inline void copy_mac_addr(unsigned char *des, unsigned char *src)
50{
51 memcpy(des, src, 6);
52}
53
54#define GET_DOT11D_INFO(__ieee_dev) \
55 ((struct rt_dot11d_info *)((__ieee_dev)->dot11d_info))
56
57#define IS_DOT11D_ENABLE(__ieee_dev) \
58 (GET_DOT11D_INFO(__ieee_dev)->enabled)
59#define IS_COUNTRY_IE_VALID(__ieee_dev) \
60 (GET_DOT11D_INFO(__ieee_dev)->country_len > 0)
61
62#define IS_EQUAL_CIE_SRC(__ieee_dev, __address) \
63 ether_addr_equal_unaligned( \
64 GET_DOT11D_INFO(__ieee_dev)->country_src_addr, __address)
65#define UPDATE_CIE_SRC(__ieee_dev, __address) \
66 copy_mac_addr(GET_DOT11D_INFO(__ieee_dev)->country_src_addr, __address)
67
68#define GET_CIE_WATCHDOG(__ieee_dev) \
69 (GET_DOT11D_INFO(__ieee_dev)->country_watchdog)
70static inline void RESET_CIE_WATCHDOG(struct rtllib_device *__ieee_dev)
71{
72 GET_CIE_WATCHDOG(__ieee_dev) = 0;
73}
74
75#define UPDATE_CIE_WATCHDOG(__ieee_dev) (++GET_CIE_WATCHDOG(__ieee_dev))
76
77void dot11d_init(struct rtllib_device *dev);
78void dot11d_channel_map(u8 channel_plan, struct rtllib_device *ieee);
79void dot11d_reset(struct rtllib_device *dev);
80void dot11d_update_country(struct rtllib_device *dev, u8 *address,
81 u16 country_len, u8 *country);
82void dot11d_scan_complete(struct rtllib_device *dev);
83
84#endif
85

source code of linux/drivers/staging/rtl8192e/dot11d.h