hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/staging/rtl8192e/dot11d.c
....@@ -1,13 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /******************************************************************************
23 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3
- *
4
- * This program is distributed in the hope that it will be useful, but WITHOUT
5
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
7
- * more details.
8
- *
9
- * The full GNU General Public License is included in this distribution in the
10
- * file called LICENSE.
114 *
125 * Contact Information:
136 * wlanfae <wlanfae@realtek.com>
....@@ -15,11 +8,11 @@
158 #include "dot11d.h"
169
1710 struct channel_list {
18
- u8 Channel[32];
19
- u8 Len;
11
+ u8 channel[32];
12
+ u8 len;
2013 };
2114
22
-static struct channel_list ChannelPlan[] = {
15
+static struct channel_list channel_array[] = {
2316 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64,
2417 149, 153, 157, 161, 165}, 24},
2518 {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11},
....@@ -44,130 +37,130 @@
4437
4538 void dot11d_init(struct rtllib_device *ieee)
4639 {
47
- struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee);
40
+ struct rt_dot11d_info *dot11d_info = GET_DOT11D_INFO(ieee);
4841
49
- pDot11dInfo->bEnabled = false;
42
+ dot11d_info->enabled = false;
5043
51
- pDot11dInfo->State = DOT11D_STATE_NONE;
52
- pDot11dInfo->CountryIeLen = 0;
53
- memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
54
- memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER + 1);
44
+ dot11d_info->state = DOT11D_STATE_NONE;
45
+ dot11d_info->country_len = 0;
46
+ memset(dot11d_info->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
47
+ memset(dot11d_info->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
5548 RESET_CIE_WATCHDOG(ieee);
5649 }
5750 EXPORT_SYMBOL(dot11d_init);
5851
59
-void Dot11d_Channelmap(u8 channel_plan, struct rtllib_device *ieee)
52
+void dot11d_channel_map(u8 channel_plan, struct rtllib_device *ieee)
6053 {
6154 int i, max_chan = 14, min_chan = 1;
6255
63
- ieee->bGlobalDomain = false;
56
+ ieee->global_domain = false;
6457
65
- if (ChannelPlan[channel_plan].Len != 0) {
58
+ if (channel_array[channel_plan].len != 0) {
6659 memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
6760 sizeof(GET_DOT11D_INFO(ieee)->channel_map));
68
- for (i = 0; i < ChannelPlan[channel_plan].Len; i++) {
69
- if (ChannelPlan[channel_plan].Channel[i] < min_chan ||
70
- ChannelPlan[channel_plan].Channel[i] > max_chan)
61
+ for (i = 0; i < channel_array[channel_plan].len; i++) {
62
+ if (channel_array[channel_plan].channel[i] < min_chan ||
63
+ channel_array[channel_plan].channel[i] > max_chan)
7164 break;
72
- GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan
73
- [channel_plan].Channel[i]] = 1;
65
+ GET_DOT11D_INFO(ieee)->channel_map[channel_array
66
+ [channel_plan].channel[i]] = 1;
7467 }
7568 }
7669
7770 switch (channel_plan) {
7871 case COUNTRY_CODE_GLOBAL_DOMAIN:
79
- ieee->bGlobalDomain = true;
72
+ ieee->global_domain = true;
8073 for (i = 12; i <= 14; i++)
8174 GET_DOT11D_INFO(ieee)->channel_map[i] = 2;
82
- ieee->IbssStartChnl = 10;
75
+ ieee->bss_start_channel = 10;
8376 ieee->ibss_maxjoin_chal = 11;
8477 break;
8578
8679 case COUNTRY_CODE_WORLD_WIDE_13:
8780 for (i = 12; i <= 13; i++)
8881 GET_DOT11D_INFO(ieee)->channel_map[i] = 2;
89
- ieee->IbssStartChnl = 10;
82
+ ieee->bss_start_channel = 10;
9083 ieee->ibss_maxjoin_chal = 11;
9184 break;
9285
9386 default:
94
- ieee->IbssStartChnl = 1;
87
+ ieee->bss_start_channel = 1;
9588 ieee->ibss_maxjoin_chal = 14;
9689 break;
9790 }
9891 }
99
-EXPORT_SYMBOL(Dot11d_Channelmap);
92
+EXPORT_SYMBOL(dot11d_channel_map);
10093
101
-void Dot11d_Reset(struct rtllib_device *ieee)
94
+void dot11d_reset(struct rtllib_device *ieee)
10295 {
103
- struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(ieee);
96
+ struct rt_dot11d_info *dot11d_info = GET_DOT11D_INFO(ieee);
10497 u32 i;
10598
106
- memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
107
- memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER + 1);
99
+ memset(dot11d_info->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
100
+ memset(dot11d_info->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
108101 for (i = 1; i <= 11; i++)
109
- (pDot11dInfo->channel_map)[i] = 1;
102
+ (dot11d_info->channel_map)[i] = 1;
110103 for (i = 12; i <= 14; i++)
111
- (pDot11dInfo->channel_map)[i] = 2;
112
- pDot11dInfo->State = DOT11D_STATE_NONE;
113
- pDot11dInfo->CountryIeLen = 0;
104
+ (dot11d_info->channel_map)[i] = 2;
105
+ dot11d_info->state = DOT11D_STATE_NONE;
106
+ dot11d_info->country_len = 0;
114107 RESET_CIE_WATCHDOG(ieee);
115108 }
116109
117
-void Dot11d_UpdateCountryIe(struct rtllib_device *dev, u8 *pTaddr,
118
- u16 CoutryIeLen, u8 *pCoutryIe)
110
+void dot11d_update_country(struct rtllib_device *dev, u8 *address,
111
+ u16 country_len, u8 *country)
119112 {
120
- struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev);
121
- u8 i, j, NumTriples, MaxChnlNum;
122
- struct chnl_txpow_triple *pTriple;
113
+ struct rt_dot11d_info *dot11d_info = GET_DOT11D_INFO(dev);
114
+ u8 i, j, number_of_triples, max_channel_number;
115
+ struct chnl_txpow_triple *triple;
123116
124
- memset(pDot11dInfo->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
125
- memset(pDot11dInfo->MaxTxPwrDbmList, 0xFF, MAX_CHANNEL_NUMBER + 1);
126
- MaxChnlNum = 0;
127
- NumTriples = (CoutryIeLen - 3) / 3;
128
- pTriple = (struct chnl_txpow_triple *)(pCoutryIe + 3);
129
- for (i = 0; i < NumTriples; i++) {
130
- if (MaxChnlNum >= pTriple->FirstChnl) {
117
+ memset(dot11d_info->channel_map, 0, MAX_CHANNEL_NUMBER + 1);
118
+ memset(dot11d_info->max_tx_power_list, 0xFF, MAX_CHANNEL_NUMBER + 1);
119
+ max_channel_number = 0;
120
+ number_of_triples = (country_len - 3) / 3;
121
+ triple = (struct chnl_txpow_triple *)(country + 3);
122
+ for (i = 0; i < number_of_triples; i++) {
123
+ if (max_channel_number >= triple->first_channel) {
131124 netdev_info(dev->dev,
132125 "%s: Invalid country IE, skip it......1\n",
133126 __func__);
134127 return;
135128 }
136
- if (MAX_CHANNEL_NUMBER < (pTriple->FirstChnl +
137
- pTriple->NumChnls)) {
129
+ if (MAX_CHANNEL_NUMBER < (triple->first_channel +
130
+ triple->num_channels)) {
138131 netdev_info(dev->dev,
139132 "%s: Invalid country IE, skip it......2\n",
140133 __func__);
141134 return;
142135 }
143136
144
- for (j = 0; j < pTriple->NumChnls; j++) {
145
- pDot11dInfo->channel_map[pTriple->FirstChnl + j] = 1;
146
- pDot11dInfo->MaxTxPwrDbmList[pTriple->FirstChnl + j] =
147
- pTriple->MaxTxPowerInDbm;
148
- MaxChnlNum = pTriple->FirstChnl + j;
137
+ for (j = 0; j < triple->num_channels; j++) {
138
+ dot11d_info->channel_map[triple->first_channel + j] = 1;
139
+ dot11d_info->max_tx_power_list[triple->first_channel + j] =
140
+ triple->max_tx_power;
141
+ max_channel_number = triple->first_channel + j;
149142 }
150143
151
- pTriple = (struct chnl_txpow_triple *)((u8 *)pTriple + 3);
144
+ triple = (struct chnl_txpow_triple *)((u8 *)triple + 3);
152145 }
153146
154
- UPDATE_CIE_SRC(dev, pTaddr);
147
+ UPDATE_CIE_SRC(dev, address);
155148
156
- pDot11dInfo->CountryIeLen = CoutryIeLen;
157
- memcpy(pDot11dInfo->CountryIeBuf, pCoutryIe, CoutryIeLen);
158
- pDot11dInfo->State = DOT11D_STATE_LEARNED;
149
+ dot11d_info->country_len = country_len;
150
+ memcpy(dot11d_info->country_buffer, country, country_len);
151
+ dot11d_info->state = DOT11D_STATE_LEARNED;
159152 }
160153
161
-void DOT11D_ScanComplete(struct rtllib_device *dev)
154
+void dot11d_scan_complete(struct rtllib_device *dev)
162155 {
163
- struct rt_dot11d_info *pDot11dInfo = GET_DOT11D_INFO(dev);
156
+ struct rt_dot11d_info *dot11d_info = GET_DOT11D_INFO(dev);
164157
165
- switch (pDot11dInfo->State) {
158
+ switch (dot11d_info->state) {
166159 case DOT11D_STATE_LEARNED:
167
- pDot11dInfo->State = DOT11D_STATE_DONE;
160
+ dot11d_info->state = DOT11D_STATE_DONE;
168161 break;
169162 case DOT11D_STATE_DONE:
170
- Dot11d_Reset(dev);
163
+ dot11d_reset(dev);
171164 break;
172165 case DOT11D_STATE_NONE:
173166 break;