xref: /wlan-driver/qcacld-3.0/core/mac/src/sys/legacy/src/utils/src/utils_parser.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2011-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /*
20  *
21  * This file utils_parser.cc contains the code for parsing
22  * 802.11 messages.
23  * Author:        Pierre Vandwalle
24  * Date:          03/18/02
25  * History:-
26  * Date           Modified by    Modification Information
27  * --------------------------------------------------------------------
28  *
29  */
30 
31 #include "ani_global.h"
32 #include "utils_parser.h"
33 #include "lim_ser_des_utils.h"
34 
convert_ssid(struct mac_context * mac,tSirMacSSid * pOld,tDot11fIESSID * pNew)35 void convert_ssid(struct mac_context *mac, tSirMacSSid *pOld, tDot11fIESSID *pNew)
36 {
37 	pOld->length = pNew->num_ssid;
38 	qdf_mem_copy(pOld->ssId, pNew->ssid, pNew->num_ssid);
39 }
40 
convert_supp_rates(struct mac_context * mac,tSirMacRateSet * pOld,tDot11fIESuppRates * pNew)41 void convert_supp_rates(struct mac_context *mac,
42 			tSirMacRateSet *pOld, tDot11fIESuppRates *pNew)
43 {
44 	pOld->numRates = pNew->num_rates;
45 	qdf_mem_copy(pOld->rate, pNew->rates, pNew->num_rates);
46 }
47 
convert_ext_supp_rates(struct mac_context * mac,tSirMacRateSet * pOld,tDot11fIEExtSuppRates * pNew)48 void convert_ext_supp_rates(struct mac_context *mac,
49 			    tSirMacRateSet *pOld, tDot11fIEExtSuppRates *pNew)
50 {
51 	pOld->numRates = pNew->num_rates;
52 	qdf_mem_copy(pOld->rate, pNew->rates, pNew->num_rates);
53 }
54 
convert_qos_caps(struct mac_context * mac,tSirMacQosCapabilityIE * pOld,tDot11fIEQOSCapsAp * pNew)55 void convert_qos_caps(struct mac_context *mac,
56 		      tSirMacQosCapabilityIE *pOld, tDot11fIEQOSCapsAp *pNew)
57 {
58 	pOld->type = 46;
59 	pOld->length = 1;
60 
61 	pOld->qosInfo.count = pNew->count;
62 }
63 
convert_qos_caps_station(struct mac_context * mac,tSirMacQosCapabilityStaIE * pOld,tDot11fIEQOSCapsStation * pNew)64 void convert_qos_caps_station(struct mac_context *mac,
65 			      tSirMacQosCapabilityStaIE *pOld,
66 			      tDot11fIEQOSCapsStation *pNew)
67 {
68 	pOld->type = 46;
69 	pOld->length = 1;
70 
71 	pOld->qosInfo.moreDataAck = pNew->more_data_ack;
72 	pOld->qosInfo.maxSpLen = pNew->max_sp_length;
73 	pOld->qosInfo.qack = pNew->qack;
74 	pOld->qosInfo.acbe_uapsd = pNew->acbe_uapsd;
75 	pOld->qosInfo.acbk_uapsd = pNew->acbk_uapsd;
76 	pOld->qosInfo.acvi_uapsd = pNew->acvi_uapsd;
77 	pOld->qosInfo.acvo_uapsd = pNew->acvo_uapsd;
78 }
79 
convert_wpa(struct mac_context * mac,tSirMacWpaInfo * pOld,tDot11fIEWPA * pNew)80 QDF_STATUS convert_wpa(struct mac_context *mac,
81 		       tSirMacWpaInfo *pOld, tDot11fIEWPA *pNew)
82 {
83 	/* This is awful, I know, but the old code just rammed the IE into an */
84 	/* array... */
85 	uint8_t buffer[257];
86 	uint32_t status, written = 0, nbuffer = 257;
87 
88 	status = dot11f_pack_ie_wpa(mac, pNew, buffer, nbuffer, &written);
89 	if (DOT11F_FAILED(status)) {
90 		pe_err("Failed to re-pack the WPA IE (0x%0x8)", status);
91 		return QDF_STATUS_E_FAILURE;
92 	}
93 
94 	pOld->length = (uint8_t) written - 2;
95 	qdf_mem_copy(pOld->info, buffer + 2, pOld->length);
96 
97 	return QDF_STATUS_SUCCESS;
98 }
99 
convert_wpa_opaque(struct mac_context * mac,tSirMacWpaInfo * pOld,tDot11fIEWPAOpaque * pNew)100 QDF_STATUS convert_wpa_opaque(struct mac_context *mac,
101 			      tSirMacWpaInfo *pOld, tDot11fIEWPAOpaque *pNew)
102 {
103 	/* This is awful, I know, but the old code just rammed the IE into */
104 	/* an opaque array.  Note that we need to explicitly add the OUI! */
105 	pOld->length = pNew->num_data + 4;
106 	pOld->info[0] = 0x00;
107 	pOld->info[1] = 0x50;
108 	pOld->info[2] = 0xf2;
109 	pOld->info[3] = 0x01;
110 	qdf_mem_copy(pOld->info + 4, pNew->data, pNew->num_data);
111 
112 	return QDF_STATUS_SUCCESS;
113 }
114 
115 #ifdef FEATURE_WLAN_WAPI
convert_wapi_opaque(struct mac_context * mac,tSirMacWapiInfo * pOld,tDot11fIEWAPIOpaque * pNew)116 QDF_STATUS convert_wapi_opaque(struct mac_context *mac,
117 			       tSirMacWapiInfo *pOld,
118 			       tDot11fIEWAPIOpaque *pNew)
119 {
120 	/* This is awful, I know, but the old code just rammed the IE into */
121 	/* an opaque array.  Note that we need to explicitly add the OUI! */
122 	pOld->length = pNew->num_data;
123 	qdf_mem_copy(pOld->info, pNew->data, pNew->num_data);
124 
125 	return QDF_STATUS_SUCCESS;
126 }
127 #endif
128 
convert_wsc_opaque(struct mac_context * mac,tSirAddie * pOld,tDot11fIEWscIEOpaque * pNew)129 QDF_STATUS convert_wsc_opaque(struct mac_context *mac,
130 			      tSirAddie *pOld, tDot11fIEWscIEOpaque *pNew)
131 {
132 	/* This is awful, I know, but the old code just rammed the IE into */
133 	/* an opaque array.  Note that we need to explicitly add the vendorIE and OUI ! */
134 	uint16_t curAddIELen = pOld->length;
135 
136 	pOld->length = curAddIELen + pNew->num_data + 6;
137 	pOld->addIEdata[curAddIELen++] = 0xdd;
138 	pOld->addIEdata[curAddIELen++] = pNew->num_data + 4;
139 	pOld->addIEdata[curAddIELen++] = 0x00;
140 	pOld->addIEdata[curAddIELen++] = 0x50;
141 	pOld->addIEdata[curAddIELen++] = 0xf2;
142 	pOld->addIEdata[curAddIELen++] = 0x04;
143 	qdf_mem_copy(pOld->addIEdata + curAddIELen, pNew->data, pNew->num_data);
144 
145 	return QDF_STATUS_SUCCESS;
146 }
147 
convert_p2p_opaque(struct mac_context * mac,tSirAddie * pOld,tDot11fIEP2PIEOpaque * pNew)148 QDF_STATUS convert_p2p_opaque(struct mac_context *mac,
149 			      tSirAddie *pOld, tDot11fIEP2PIEOpaque *pNew)
150 {
151 	/* This is awful, I know, but the old code just rammed the IE into */
152 	/* an opaque array.  Note that we need to explicitly add the vendorIE and OUI ! */
153 	uint16_t curAddIELen = pOld->length;
154 
155 	pOld->length = curAddIELen + pNew->num_data + 6;
156 	pOld->addIEdata[curAddIELen++] = 0xdd;
157 	pOld->addIEdata[curAddIELen++] = pNew->num_data + 4;
158 	pOld->addIEdata[curAddIELen++] = 0x50;
159 	pOld->addIEdata[curAddIELen++] = 0x6f;
160 	pOld->addIEdata[curAddIELen++] = 0x9A;
161 	pOld->addIEdata[curAddIELen++] = 0x09;
162 	qdf_mem_copy(pOld->addIEdata + curAddIELen, pNew->data, pNew->num_data);
163 
164 	return QDF_STATUS_SUCCESS;
165 }
166 
167 #ifdef WLAN_FEATURE_WFD
convert_wfd_opaque(struct mac_context * mac,tSirAddie * pOld,tDot11fIEWFDIEOpaque * pNew)168 QDF_STATUS convert_wfd_opaque(struct mac_context *mac,
169 			      tSirAddie *pOld, tDot11fIEWFDIEOpaque *pNew)
170 {
171 	/* This is awful, I know, but the old code just rammed the IE into */
172 	/* an opaque array.  Note that we need to explicitly add the vendorIE and OUI ! */
173 	uint16_t curAddIELen = pOld->length;
174 
175 	pOld->length = curAddIELen + pNew->num_data + 6;
176 	pOld->addIEdata[curAddIELen++] = 0xdd;
177 	pOld->addIEdata[curAddIELen++] = pNew->num_data + 4;
178 	pOld->addIEdata[curAddIELen++] = 0x50;
179 	pOld->addIEdata[curAddIELen++] = 0x6f;
180 	pOld->addIEdata[curAddIELen++] = 0x9A;
181 	pOld->addIEdata[curAddIELen++] = 0x0a;
182 	qdf_mem_copy(pOld->addIEdata + curAddIELen, pNew->data, pNew->num_data);
183 
184 	return QDF_STATUS_SUCCESS;
185 }
186 #endif
187 
convert_rsn(struct mac_context * mac,tSirMacRsnInfo * pOld,tDot11fIERSN * pNew)188 QDF_STATUS convert_rsn(struct mac_context *mac,
189 		       tSirMacRsnInfo *pOld, tDot11fIERSN *pNew)
190 {
191 	uint8_t buffer[257];
192 	uint32_t status, written = 0, nbuffer = 257;
193 
194 	status = dot11f_pack_ie_rsn(mac, pNew, buffer, nbuffer, &written);
195 	if (DOT11F_FAILED(status)) {
196 		pe_err("Failed to re-pack the RSN IE (0x%0x8)", status);
197 		return QDF_STATUS_E_FAILURE;
198 	}
199 
200 	pOld->length = (uint8_t) written - 2;
201 	qdf_mem_copy(pOld->info, buffer + 2, pOld->length);
202 
203 	return QDF_STATUS_SUCCESS;
204 }
205 
convert_rsn_opaque(struct mac_context * mac,tSirMacRsnInfo * pOld,tDot11fIERSNOpaque * pNew)206 QDF_STATUS convert_rsn_opaque(struct mac_context *mac,
207 			      tSirMacRsnInfo *pOld, tDot11fIERSNOpaque *pNew)
208 {
209 	/* This is awful, I know, but the old code just rammed the IE into */
210 	/* an opaque array. */
211 	pOld->length = pNew->num_data;
212 	qdf_mem_copy(pOld->info, pNew->data, pOld->length);
213 
214 	return QDF_STATUS_SUCCESS;
215 }
216 
convert_power_caps(struct mac_context * mac,tSirMacPowerCapabilityIE * pOld,tDot11fIEPowerCaps * pNew)217 void convert_power_caps(struct mac_context *mac,
218 			tSirMacPowerCapabilityIE *pOld,
219 			tDot11fIEPowerCaps *pNew)
220 {
221 	pOld->type = 33;
222 	pOld->length = 2;
223 	pOld->minTxPower = pNew->minTxPower;
224 	pOld->maxTxPower = pNew->maxTxPower;
225 }
226 
convert_supp_channels(struct mac_context * mac,tSirMacSupportedChannelIE * pOld,tDot11fIESuppChannels * pNew)227 void convert_supp_channels(struct mac_context *mac,
228 			   tSirMacSupportedChannelIE *pOld,
229 			   tDot11fIESuppChannels *pNew)
230 {
231 	pOld->type = 36;
232 	pOld->length = (pNew->num_bands * 2);
233 	qdf_mem_copy((uint8_t *) pOld->supportedChannels,
234 		     (uint8_t *) pNew->bands, pOld->length);
235 }
236 
convert_cf_params(struct mac_context * mac,tSirMacCfParamSet * pOld,tDot11fIECFParams * pNew)237 void convert_cf_params(struct mac_context *mac,
238 		       tSirMacCfParamSet *pOld, tDot11fIECFParams *pNew)
239 {
240 	pOld->cfpCount = pNew->cfp_count;
241 	pOld->cfpPeriod = pNew->cfp_period;
242 	pOld->cfpMaxDuration = pNew->cfp_maxduration;
243 	pOld->cfpDurRemaining = pNew->cfp_durremaining;
244 }
245 
convert_fh_params(struct mac_context * mac,tSirMacFHParamSet * pOld,tDot11fIEFHParamSet * pNew)246 void convert_fh_params(struct mac_context *mac,
247 		       tSirMacFHParamSet *pOld, tDot11fIEFHParamSet *pNew)
248 {
249 	pOld->dwellTime = pNew->dwell_time;
250 	pOld->hopSet = pNew->hop_set;
251 	pOld->hopPattern = pNew->hop_pattern;
252 	pOld->hopIndex = pNew->hop_index;
253 }
254 
convert_tim(struct mac_context * mac,tSirMacTim * pOld,tDot11fIETIM * pNew)255 void convert_tim(struct mac_context *mac, tSirMacTim *pOld, tDot11fIETIM *pNew)
256 {
257 	pOld->dtimCount = pNew->dtim_count;
258 	pOld->dtimPeriod = pNew->dtim_period;
259 	pOld->bitmapControl = pNew->bmpctl;
260 	pOld->bitmapLength = pNew->num_vbmp;
261 
262 	qdf_mem_copy(pOld->bitmap, pNew->vbmp, pNew->num_vbmp);
263 }
264 
convert_country(struct mac_context * mac,tSirCountryInformation * pOld,tDot11fIECountry * pNew)265 void convert_country(struct mac_context *mac,
266 		     tSirCountryInformation *pOld, tDot11fIECountry *pNew)
267 {
268 	uint8_t i = 0;
269 
270 	qdf_mem_copy(pOld->countryString, pNew->country, COUNTRY_STRING_LENGTH);
271 
272 	pOld->numIntervals = pNew->num_more_triplets;
273 
274 	pOld->channelTransmitPower[i].channelNumber = pNew->first_triplet[0];
275 	pOld->channelTransmitPower[i].numChannel = pNew->first_triplet[1];
276 	pOld->channelTransmitPower[i].maxTransmitPower = pNew->first_triplet[2];
277 
278 	for (i = 0; i < pNew->num_more_triplets; i++) {
279 		pOld->channelTransmitPower[i+1].channelNumber =
280 				pNew->more_triplets[i][0];
281 		pOld->channelTransmitPower[i+1].numChannel =
282 				pNew->more_triplets[i][1];
283 		pOld->channelTransmitPower[i+1].maxTransmitPower =
284 				pNew->more_triplets[i][2];
285 	}
286 }
287 
convert_wmm_params(struct mac_context * mac,tSirMacEdcaParamSetIE * pOld,tDot11fIEWMMParams * pNew)288 void convert_wmm_params(struct mac_context *mac,
289 			tSirMacEdcaParamSetIE *pOld, tDot11fIEWMMParams *pNew)
290 {
291 	pOld->type = 221;
292 	pOld->length = 24;
293 
294 	qdf_mem_copy((uint8_t *) &pOld->qosInfo, (uint8_t *) &pNew->qosInfo,
295 		     1);
296 
297 	pOld->acbe.aci.aifsn = pNew->acbe_aifsn;
298 	pOld->acbe.aci.acm = pNew->acbe_acm;
299 	pOld->acbe.aci.aci = pNew->acbe_aci;
300 	pOld->acbe.cw.min = pNew->acbe_acwmin;
301 	pOld->acbe.cw.max = pNew->acbe_acwmax;
302 	pOld->acbe.txoplimit = pNew->acbe_txoplimit;
303 
304 	pOld->acbk.aci.aifsn = pNew->acbk_aifsn;
305 	pOld->acbk.aci.acm = pNew->acbk_acm;
306 	pOld->acbk.aci.aci = pNew->acbk_aci;
307 	pOld->acbk.cw.min = pNew->acbk_acwmin;
308 	pOld->acbk.cw.max = pNew->acbk_acwmax;
309 	pOld->acbk.txoplimit = pNew->acbk_txoplimit;
310 
311 	pOld->acvi.aci.aifsn = pNew->acvi_aifsn;
312 	pOld->acvi.aci.acm = pNew->acvi_acm;
313 	pOld->acvi.aci.aci = pNew->acvi_aci;
314 	pOld->acvi.cw.min = pNew->acvi_acwmin;
315 	pOld->acvi.cw.max = pNew->acvi_acwmax;
316 	pOld->acvi.txoplimit = pNew->acvi_txoplimit;
317 
318 	pOld->acvo.aci.aifsn = pNew->acvo_aifsn;
319 	pOld->acvo.aci.acm = pNew->acvo_acm;
320 	pOld->acvo.aci.aci = pNew->acvo_aci;
321 	pOld->acvo.cw.min = pNew->acvo_acwmin;
322 	pOld->acvo.cw.max = pNew->acvo_acwmax;
323 	pOld->acvo.txoplimit = pNew->acvo_txoplimit;
324 }
325 
convert_erp_info(struct mac_context * mac,tSirMacErpInfo * pOld,tDot11fIEERPInfo * pNew)326 void convert_erp_info(struct mac_context *mac,
327 		      tSirMacErpInfo *pOld, tDot11fIEERPInfo *pNew)
328 {
329 	pOld->nonErpPresent = pNew->non_erp_present;
330 	pOld->useProtection = pNew->use_prot;
331 	pOld->barkerPreambleMode = pNew->barker_preamble;
332 }
333 
convert_edca_param(struct mac_context * mac,tSirMacEdcaParamSetIE * pOld,tDot11fIEEDCAParamSet * pNew)334 void convert_edca_param(struct mac_context *mac,
335 			tSirMacEdcaParamSetIE *pOld,
336 			tDot11fIEEDCAParamSet *pNew)
337 {
338 	pOld->type = 12;
339 	pOld->length = 20;
340 
341 	qdf_mem_copy((uint8_t *) &pOld->qosInfo, (uint8_t *) &pNew->qos, 1);
342 
343 	pOld->acbe.aci.aifsn = pNew->acbe_aifsn;
344 	pOld->acbe.aci.acm = pNew->acbe_acm;
345 	pOld->acbe.aci.aci = pNew->acbe_aci;
346 	pOld->acbe.cw.min = pNew->acbe_acwmin;
347 	pOld->acbe.cw.max = pNew->acbe_acwmax;
348 	pOld->acbe.txoplimit = pNew->acbe_txoplimit;
349 
350 	pOld->acbk.aci.aifsn = pNew->acbk_aifsn;
351 	pOld->acbk.aci.acm = pNew->acbk_acm;
352 	pOld->acbk.aci.aci = pNew->acbk_aci;
353 	pOld->acbk.cw.min = pNew->acbk_acwmin;
354 	pOld->acbk.cw.max = pNew->acbk_acwmax;
355 	pOld->acbk.txoplimit = pNew->acbk_txoplimit;
356 
357 	pOld->acvi.aci.aifsn = pNew->acvi_aifsn;
358 	pOld->acvi.aci.acm = pNew->acvi_acm;
359 	pOld->acvi.aci.aci = pNew->acvi_aci;
360 	pOld->acvi.cw.min = pNew->acvi_acwmin;
361 	pOld->acvi.cw.max = pNew->acvi_acwmax;
362 	pOld->acvi.txoplimit = pNew->acvi_txoplimit;
363 
364 	pOld->acvo.aci.aifsn = pNew->acvo_aifsn;
365 	pOld->acvo.aci.acm = pNew->acvo_acm;
366 	pOld->acvo.aci.aci = pNew->acvo_aci;
367 	pOld->acvo.cw.min = pNew->acvo_acwmin;
368 	pOld->acvo.cw.max = pNew->acvo_acwmax;
369 	pOld->acvo.txoplimit = pNew->acvo_txoplimit;
370 
371 }
372 
convert_mu_edca_param(struct mac_context * mac_ctx,tSirMacEdcaParamSetIE * mu_edca,tDot11fIEmu_edca_param_set * ie)373 void convert_mu_edca_param(struct mac_context *mac_ctx,
374 			tSirMacEdcaParamSetIE *mu_edca,
375 			tDot11fIEmu_edca_param_set *ie)
376 {
377 	qdf_mem_copy((uint8_t *) &mu_edca->qosInfo, (uint8_t *) &ie->qos, 1);
378 
379 	mu_edca->acbe.aci.aifsn = ie->acbe_aifsn;
380 	mu_edca->acbe.aci.acm = ie->acbe_acm;
381 	mu_edca->acbe.aci.aci = ie->acbe_aci;
382 	mu_edca->acbe.cw.min = ie->acbe_acwmin;
383 	mu_edca->acbe.cw.max = ie->acbe_acwmax;
384 	mu_edca->acbe.mu_edca_timer = ie->acbe_muedca_timer;
385 
386 	mu_edca->acbk.aci.aifsn = ie->acbk_aifsn;
387 	mu_edca->acbk.aci.acm = ie->acbk_acm;
388 	mu_edca->acbk.aci.aci = ie->acbk_aci;
389 	mu_edca->acbk.cw.min = ie->acbk_acwmin;
390 	mu_edca->acbk.cw.max = ie->acbk_acwmax;
391 	mu_edca->acbk.mu_edca_timer = ie->acbk_muedca_timer;
392 
393 	mu_edca->acvi.aci.aifsn = ie->acvi_aifsn;
394 	mu_edca->acvi.aci.acm = ie->acvi_acm;
395 	mu_edca->acvi.aci.aci = ie->acvi_aci;
396 	mu_edca->acvi.cw.min = ie->acvi_acwmin;
397 	mu_edca->acvi.cw.max = ie->acvi_acwmax;
398 	mu_edca->acvi.mu_edca_timer = ie->acvi_muedca_timer;
399 
400 	mu_edca->acvo.aci.aifsn = ie->acvo_aifsn;
401 	mu_edca->acvo.aci.acm = ie->acvo_acm;
402 	mu_edca->acvo.aci.aci = ie->acvo_aci;
403 	mu_edca->acvo.cw.min = ie->acvo_acwmin;
404 	mu_edca->acvo.cw.max = ie->acvo_acwmax;
405 	mu_edca->acvo.mu_edca_timer = ie->acvo_muedca_timer;
406 
407 }
408 
convert_tspec(struct mac_context * mac,struct mac_tspec_ie * pOld,tDot11fIETSPEC * pNew)409 void convert_tspec(struct mac_context *mac,
410 		   struct mac_tspec_ie *pOld, tDot11fIETSPEC *pNew)
411 {
412 	pOld->tsinfo.traffic.trafficType = (uint16_t) pNew->traffic_type;
413 	pOld->tsinfo.traffic.tsid = (uint16_t) pNew->tsid;
414 	pOld->tsinfo.traffic.direction = (uint16_t) pNew->direction;
415 	pOld->tsinfo.traffic.accessPolicy = (uint16_t) pNew->access_policy;
416 	pOld->tsinfo.traffic.aggregation = (uint16_t) pNew->aggregation;
417 	pOld->tsinfo.traffic.psb = (uint16_t) pNew->psb;
418 	pOld->tsinfo.traffic.userPrio = (uint16_t) pNew->user_priority;
419 	pOld->tsinfo.traffic.ackPolicy = (uint16_t) pNew->tsinfo_ack_pol;
420 
421 	pOld->tsinfo.schedule.schedule = (uint8_t) pNew->schedule;
422 
423 	pOld->nomMsduSz = pNew->size;
424 	pOld->maxMsduSz = pNew->max_msdu_size;
425 	pOld->minSvcInterval = pNew->min_service_int;
426 	pOld->maxSvcInterval = pNew->max_service_int;
427 	pOld->inactInterval = pNew->inactivity_int;
428 	pOld->suspendInterval = pNew->suspension_int;
429 	pOld->svcStartTime = pNew->service_start_time;
430 	pOld->minDataRate = pNew->min_data_rate;
431 	pOld->meanDataRate = pNew->mean_data_rate;
432 	pOld->peakDataRate = pNew->peak_data_rate;
433 	pOld->maxBurstSz = pNew->burst_size;
434 	pOld->delayBound = pNew->delay_bound;
435 	pOld->minPhyRate = pNew->min_phy_rate;
436 	pOld->surplusBw = pNew->surplus_bw_allowance;
437 	pOld->mediumTime = pNew->medium_time;
438 }
439 
convert_tclas(struct mac_context * mac,tSirTclasInfo * pOld,tDot11fIETCLAS * pNew)440 QDF_STATUS convert_tclas(struct mac_context *mac,
441 			 tSirTclasInfo *pOld, tDot11fIETCLAS *pNew)
442 {
443 	uint32_t length = 0;
444 
445 	if (DOT11F_FAILED(dot11f_get_packed_ietclas(mac, pNew, &length))) {
446 		return QDF_STATUS_E_FAILURE;
447 	}
448 
449 	pOld->tclas.type = DOT11F_EID_TCLAS;
450 	pOld->tclas.length = (uint8_t) length;
451 	pOld->tclas.userPrio = pNew->user_priority;
452 	pOld->tclas.classifierType = pNew->classifier_type;
453 	pOld->tclas.classifierMask = pNew->classifier_mask;
454 
455 	switch (pNew->classifier_type) {
456 	case 0:
457 		qdf_mem_copy(pOld->tclasParams.eth.srcAddr,
458 			     pNew->info.EthParams.source, 6);
459 		qdf_mem_copy(pOld->tclasParams.eth.dstAddr,
460 			     pNew->info.EthParams.dest, 6);
461 		pOld->tclasParams.eth.type = pNew->info.EthParams.type;
462 		break;
463 	case 1:
464 		pOld->version = pNew->info.IpParams.version;
465 		if (4 == pNew->info.IpParams.version) {
466 			pOld->tclasParams.ipv4.version = 4;
467 			qdf_mem_copy(pOld->tclasParams.ipv4.srcIpAddr,
468 				     pNew->info.IpParams.params.IpV4Params.
469 				     source, 4);
470 			qdf_mem_copy(pOld->tclasParams.ipv4.dstIpAddr,
471 				     pNew->info.IpParams.params.IpV4Params.dest,
472 				     4);
473 			pOld->tclasParams.ipv4.srcPort =
474 				pNew->info.IpParams.params.IpV4Params.src_port;
475 			pOld->tclasParams.ipv4.dstPort =
476 				pNew->info.IpParams.params.IpV4Params.dest_port;
477 			pOld->tclasParams.ipv4.dscp =
478 				pNew->info.IpParams.params.IpV4Params.DSCP;
479 			pOld->tclasParams.ipv4.protocol =
480 				pNew->info.IpParams.params.IpV4Params.proto;
481 			pOld->tclasParams.ipv4.rsvd =
482 				pNew->info.IpParams.params.IpV4Params.reserved;
483 		} else if (6 == pNew->info.IpParams.version) {
484 			pOld->tclasParams.ipv6.version = 6;
485 			qdf_mem_copy((uint8_t *) pOld->tclasParams.ipv6.
486 				     srcIpAddr,
487 				     (uint8_t *) pNew->info.IpParams.params.
488 				     IpV6Params.source, 16);
489 			qdf_mem_copy((uint8_t *) pOld->tclasParams.ipv6.
490 				     dstIpAddr,
491 				     (uint8_t *) pNew->info.IpParams.params.
492 				     IpV6Params.dest, 16);
493 			pOld->tclasParams.ipv6.srcPort =
494 				pNew->info.IpParams.params.IpV6Params.src_port;
495 			pOld->tclasParams.ipv6.dstPort =
496 				pNew->info.IpParams.params.IpV6Params.dest_port;
497 			qdf_mem_copy((uint8_t *) pOld->tclasParams.ipv6.
498 				     flowLabel,
499 				     (uint8_t *) pNew->info.IpParams.params.
500 				     IpV6Params.flow_label, 3);
501 		} else {
502 			return QDF_STATUS_E_FAILURE;
503 		}
504 		break;
505 	case 2:
506 		pOld->tclasParams.t8021dq.tag =
507 			pNew->info.Params8021dq.tag_type;
508 		break;
509 	default:
510 		return QDF_STATUS_E_FAILURE;
511 	}
512 
513 	return QDF_STATUS_SUCCESS;
514 }
515 
convert_wmmtspec(struct mac_context * mac,struct mac_tspec_ie * pOld,tDot11fIEWMMTSPEC * pNew)516 void convert_wmmtspec(struct mac_context *mac,
517 		      struct mac_tspec_ie *pOld, tDot11fIEWMMTSPEC *pNew)
518 {
519 	pOld->tsinfo.traffic.trafficType = (uint16_t) pNew->traffic_type;
520 	pOld->tsinfo.traffic.tsid = (uint16_t) pNew->tsid;
521 	pOld->tsinfo.traffic.direction = (uint16_t) pNew->direction;
522 	pOld->tsinfo.traffic.accessPolicy = (uint16_t) pNew->access_policy;
523 	pOld->tsinfo.traffic.aggregation = (uint16_t) pNew->aggregation;
524 	pOld->tsinfo.traffic.psb = (uint16_t) pNew->psb;
525 	pOld->tsinfo.traffic.userPrio = (uint16_t) pNew->user_priority;
526 	pOld->tsinfo.traffic.ackPolicy = (uint16_t) pNew->tsinfo_ack_pol;
527 	pOld->nomMsduSz = (pNew->fixed << 15) | pNew->size;
528 	pOld->maxMsduSz = pNew->max_msdu_size;
529 	pOld->minSvcInterval = pNew->min_service_int;
530 	pOld->maxSvcInterval = pNew->max_service_int;
531 	pOld->inactInterval = pNew->inactivity_int;
532 	pOld->suspendInterval = pNew->suspension_int;
533 	pOld->svcStartTime = pNew->service_start_time;
534 	pOld->minDataRate = pNew->min_data_rate;
535 	pOld->meanDataRate = pNew->mean_data_rate;
536 	pOld->peakDataRate = pNew->peak_data_rate;
537 	pOld->maxBurstSz = pNew->burst_size;
538 	pOld->delayBound = pNew->delay_bound;
539 	pOld->minPhyRate = pNew->min_phy_rate;
540 	pOld->surplusBw = pNew->surplus_bw_allowance;
541 	pOld->mediumTime = pNew->medium_time;
542 }
543 
convert_wmmtclas(struct mac_context * mac,tSirTclasInfo * pOld,tDot11fIEWMMTCLAS * pNew)544 QDF_STATUS convert_wmmtclas(struct mac_context *mac,
545 			    tSirTclasInfo *pOld, tDot11fIEWMMTCLAS *pNew)
546 {
547 	uint32_t length = 0;
548 
549 	if (DOT11F_FAILED(dot11f_get_packed_iewmmtclas(mac, pNew, &length))) {
550 		return QDF_STATUS_E_FAILURE;
551 	}
552 
553 	pOld->tclas.type = DOT11F_EID_WMMTCLAS;
554 	pOld->tclas.length = (uint8_t) length;
555 	pOld->tclas.userPrio = pNew->user_priority;
556 	pOld->tclas.classifierType = pNew->classifier_type;
557 	pOld->tclas.classifierMask = pNew->classifier_mask;
558 
559 	switch (pNew->classifier_type) {
560 	case 0:
561 		qdf_mem_copy(pOld->tclasParams.eth.srcAddr,
562 			     pNew->info.EthParams.source, 6);
563 		qdf_mem_copy(pOld->tclasParams.eth.dstAddr,
564 			     pNew->info.EthParams.dest, 6);
565 		pOld->tclasParams.eth.type = pNew->info.EthParams.type;
566 		break;
567 	case 1:
568 		pOld->version = pNew->info.IpParams.version;
569 		if (4 == pNew->info.IpParams.version) {
570 			pOld->tclasParams.ipv4.version = 4;
571 			qdf_mem_copy(pOld->tclasParams.ipv4.srcIpAddr,
572 				     pNew->info.IpParams.params.IpV4Params.
573 				     source, 4);
574 			qdf_mem_copy(pOld->tclasParams.ipv4.dstIpAddr,
575 				     pNew->info.IpParams.params.IpV4Params.dest,
576 				     4);
577 			pOld->tclasParams.ipv4.srcPort =
578 				pNew->info.IpParams.params.IpV4Params.src_port;
579 			pOld->tclasParams.ipv4.dstPort =
580 				pNew->info.IpParams.params.IpV4Params.dest_port;
581 			pOld->tclasParams.ipv4.dscp =
582 				pNew->info.IpParams.params.IpV4Params.DSCP;
583 			pOld->tclasParams.ipv4.protocol =
584 				pNew->info.IpParams.params.IpV4Params.proto;
585 			pOld->tclasParams.ipv4.rsvd =
586 				pNew->info.IpParams.params.IpV4Params.reserved;
587 		} else if (6 == pNew->info.IpParams.version) {
588 			pOld->tclasParams.ipv6.version = 6;
589 			qdf_mem_copy((uint8_t *) pOld->tclasParams.ipv6.
590 				     srcIpAddr,
591 				     (uint8_t *) pNew->info.IpParams.params.
592 				     IpV6Params.source, 16);
593 			qdf_mem_copy((uint8_t *) pOld->tclasParams.ipv6.
594 				     dstIpAddr,
595 				     (uint8_t *) pNew->info.IpParams.params.
596 				     IpV6Params.dest, 16);
597 			pOld->tclasParams.ipv6.srcPort =
598 				pNew->info.IpParams.params.IpV6Params.src_port;
599 			pOld->tclasParams.ipv6.dstPort =
600 				pNew->info.IpParams.params.IpV6Params.dest_port;
601 			qdf_mem_copy((uint8_t *) pOld->tclasParams.ipv6.
602 				     flowLabel,
603 				     (uint8_t *) pNew->info.IpParams.params.
604 				     IpV6Params.flow_label, 3);
605 		} else {
606 			return QDF_STATUS_E_FAILURE;
607 		}
608 		break;
609 	case 2:
610 		pOld->tclasParams.t8021dq.tag =
611 			pNew->info.Params8021dq.tag_type;
612 		break;
613 	default:
614 		return QDF_STATUS_E_FAILURE;
615 	}
616 
617 	return QDF_STATUS_SUCCESS;
618 }
619 
convert_ts_delay(struct mac_context * mac,tSirMacTsDelayIE * pOld,tDot11fIETSDelay * pNew)620 void convert_ts_delay(struct mac_context *mac,
621 		      tSirMacTsDelayIE *pOld, tDot11fIETSDelay *pNew)
622 {
623 	pOld->type = DOT11F_EID_TSDELAY;
624 	pOld->length = 4U;
625 	pOld->delay = pNew->delay;
626 }
627 
convert_schedule(struct mac_context * mac,tSirMacScheduleIE * pOld,tDot11fIESchedule * pNew)628 void convert_schedule(struct mac_context *mac,
629 		      tSirMacScheduleIE *pOld, tDot11fIESchedule *pNew)
630 {
631 	pOld->type = DOT11F_EID_SCHEDULE;
632 	pOld->length = DOT11F_IE_SCHEDULE_MIN_LEN;
633 
634 	pOld->info.aggregation = pNew->aggregation;
635 	pOld->info.tsid = pNew->tsid;
636 	pOld->info.direction = pNew->direction;
637 
638 	pOld->svcStartTime = pNew->service_start_time;
639 	pOld->svcInterval = pNew->service_interval;
640 	pOld->specInterval = pNew->spec_interval;
641 }
642 
convert_wmm_schedule(struct mac_context * mac,tSirMacScheduleIE * pOld,tDot11fIEWMMSchedule * pNew)643 void convert_wmm_schedule(struct mac_context *mac,
644 			  tSirMacScheduleIE *pOld, tDot11fIEWMMSchedule *pNew)
645 {
646 	pOld->type = DOT11F_EID_WMMSCHEDULE;
647 	pOld->length = DOT11F_IE_WMMSCHEDULE_MIN_LEN;
648 
649 	pOld->info.aggregation = pNew->aggregation;
650 	pOld->info.tsid = pNew->tsid;
651 	pOld->info.direction = pNew->direction;
652 
653 	pOld->svcStartTime = pNew->service_start_time;
654 	pOld->svcInterval = pNew->service_interval;
655 	pOld->specInterval = pNew->spec_interval;
656 }
657 
convert_qos_mapset_frame(struct mac_context * mac,struct qos_map_set * qos,tDot11fIEQosMapSet * dot11f_ie)658 void convert_qos_mapset_frame(struct mac_context *mac, struct qos_map_set *qos,
659 			      tDot11fIEQosMapSet *dot11f_ie)
660 {
661 	uint8_t i, j = 0;
662 	uint8_t dot11_dscp_exception_sz;
663 
664 	if (dot11f_ie->num_dscp_exceptions < DOT11F_IE_QOSMAPSET_MIN_LEN ||
665 	    dot11f_ie->num_dscp_exceptions % 2) {
666 		pe_debug("Invalid num_dscp_exceptions %d",
667 			 dot11f_ie->num_dscp_exceptions);
668 		return;
669 	}
670 
671 	dot11_dscp_exception_sz = dot11f_ie->num_dscp_exceptions -
672 				  DOT11F_IE_QOSMAPSET_MIN_LEN;
673 	qos->num_dscp_exceptions = dot11_dscp_exception_sz / 2;
674 	if (qos->num_dscp_exceptions > QOS_MAP_MAX_EX)
675 		qos->num_dscp_exceptions = QOS_MAP_MAX_EX;
676 
677 	for (i = 0; i < qos->num_dscp_exceptions &&
678 	     j < dot11_dscp_exception_sz - 1; i++) {
679 		qos->dscp_exceptions[i][0] = dot11f_ie->dscp_exceptions[j++];
680 		qos->dscp_exceptions[i][1] = dot11f_ie->dscp_exceptions[j++];
681 	}
682 
683 	for (i = 0; i < QOS_MAP_RANGE_NUM &&
684 	     j < dot11f_ie->num_dscp_exceptions - 1; i++) {
685 		qos->dscp_range[i][0] = dot11f_ie->dscp_exceptions[j++];
686 		qos->dscp_range[i][1] = dot11f_ie->dscp_exceptions[j++];
687 	}
688 }
689 
690 /* utils_parser.c ends here. */
691