blob: 56470105971eb38f175f32ec1990faf04ce9e0ca [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002 * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/* Include files */
29
30#include <wlan_hdd_includes.h>
31#include <cds_api.h>
32#include <cds_sched.h>
33#include <wni_api.h>
34#include <wlan_hdd_cfg.h>
35#include "wlan_hdd_trace.h"
36#include "cds_concurrency.h"
37#include "wlan_hdd_conc_ut.h"
38#include "cdf_types.h"
39#include "cdf_trace.h"
40#include "cds_utils.h"
41#include "cds_reg_service.h"
42#include "wma_types.h"
43#include "wma.h"
44#include "wma_api.h"
45
46#define NUMBER_OF_SCENARIO 300
47#define MAX_ALLOWED_CHAR_IN_REPORT 50
48
49/**
50 * struct report_t: Data structure to fill report
51 *
52 * @title: title of the concurrency case scenario
53 * @first_persona: device type of first persona
54 * @second_persona: device type of second persona
55 * @third_persona: device type of third persona
56 * @dbs_value: string to mention whether dbs enable or disable
57 * @system_conf: string to mention what is system's configuration
58 * @status: status field
59 * @result_code: string to mention whether test case passed or failed
60 * @reason: reason why test case failed
61 * @pcl: preferred channel list
62 *
63 * This structure will be used by unit test framework to fill
64 * report after running various concurrency scenarios.
65 */
66struct report_t {
67 char title[2 * MAX_ALLOWED_CHAR_IN_REPORT];
68 char first_persona[MAX_ALLOWED_CHAR_IN_REPORT];
69 char second_persona[MAX_ALLOWED_CHAR_IN_REPORT];
70 char third_persona[MAX_ALLOWED_CHAR_IN_REPORT];
71 char dbs_value[MAX_ALLOWED_CHAR_IN_REPORT];
72 char system_conf[MAX_ALLOWED_CHAR_IN_REPORT];
73 bool status;
74 char result_code[MAX_ALLOWED_CHAR_IN_REPORT];
75 char reason[MAX_ALLOWED_CHAR_IN_REPORT];
76 char pcl[2 * MAX_NUM_CHAN];
77};
78
79static struct report_t report[NUMBER_OF_SCENARIO];
80static uint32_t report_idx;
81
82static uint8_t wlan_hdd_valid_type_of_persona(uint32_t sub_type)
83{
84 switch (sub_type) {
85 case CDS_STA_MODE:
86 return WMI_VDEV_TYPE_STA;
87 case CDS_IBSS_MODE:
88 return WMI_VDEV_TYPE_IBSS;
89 case CDS_SAP_MODE:
90 case CDS_P2P_CLIENT_MODE:
91 case CDS_P2P_GO_MODE:
92 return WMI_VDEV_TYPE_AP;
93 default:
94 return WMI_VDEV_TYPE_STA;
95 }
96}
97
98static const char *system_config_to_string(uint8_t idx)
99{
100 switch (idx) {
101 CASE_RETURN_STRING(CDS_THROUGHPUT);
102 CASE_RETURN_STRING(CDS_POWERSAVE);
103 CASE_RETURN_STRING(CDS_LATENCY);
104 default:
105 return "Unknown";
106 }
107
108}
109
110static const char *device_mode_to_string(uint8_t idx)
111{
112 switch (idx) {
113 CASE_RETURN_STRING(CDS_STA_MODE);
114 CASE_RETURN_STRING(CDS_SAP_MODE);
115 CASE_RETURN_STRING(CDS_P2P_CLIENT_MODE);
116 CASE_RETURN_STRING(CDS_P2P_GO_MODE);
117 CASE_RETURN_STRING(CDS_IBSS_MODE);
118 default:
119 return "none";
120 }
121}
122
123static const char *pcl_type_to_string(uint8_t idx)
124{
125 switch (idx) {
126 CASE_RETURN_STRING(CDS_NONE);
127 CASE_RETURN_STRING(CDS_24G);
128 CASE_RETURN_STRING(CDS_5G);
129 CASE_RETURN_STRING(CDS_SCC_CH);
130 CASE_RETURN_STRING(CDS_MCC_CH);
131 CASE_RETURN_STRING(CDS_SCC_CH_24G);
132 CASE_RETURN_STRING(CDS_SCC_CH_5G);
133 CASE_RETURN_STRING(CDS_24G_SCC_CH);
134 CASE_RETURN_STRING(CDS_5G_SCC_CH);
135 CASE_RETURN_STRING(CDS_SCC_ON_5_SCC_ON_24_24G);
136 CASE_RETURN_STRING(CDS_SCC_ON_5_SCC_ON_24_5G);
137 CASE_RETURN_STRING(CDS_SCC_ON_24_SCC_ON_5_24G);
138 CASE_RETURN_STRING(CDS_SCC_ON_24_SCC_ON_5_5G);
139 CASE_RETURN_STRING(CDS_SCC_ON_5_SCC_ON_24);
140 CASE_RETURN_STRING(CDS_SCC_ON_24_SCC_ON_5);
141 CASE_RETURN_STRING(CDS_MCC_CH_24G);
142 CASE_RETURN_STRING(CDS_MCC_CH_5G);
143 CASE_RETURN_STRING(CDS_24G_MCC_CH);
144 CASE_RETURN_STRING(CDS_5G_MCC_CH);
145 default:
146 return "Unknown";
147 }
148}
149
150void clean_report(hdd_context_t *hdd_ctx)
151{
152 uint32_t idx = 0;
153 while (idx < NUMBER_OF_SCENARIO) {
154 cdf_mem_zero(&report[idx], sizeof(struct report_t));
155 idx++;
156 }
157 report_idx = 0;
158}
159
160void print_report(hdd_context_t *hdd_ctx)
161{
162 uint32_t idx = 0;
163 pr_info("+----------Report start -----------+\n");
164 while (idx < report_idx) {
165 pr_info("Idx:[%d]\nTitle:%s\nResult:[%s]\n\t1st_person[%s]\n\t2nd_persona[%s]\n\t3rd_persona[%s]\n\tDBS[%s]\n\tsystem_config[%s]\n\treason[%s]\n\tpcl[%s]\n",
166 idx,
167 report[idx].title, report[idx].result_code,
168 report[idx].first_persona, report[idx].second_persona,
169 report[idx].third_persona, report[idx].dbs_value,
170 report[idx].system_conf, report[idx].reason,
171 report[idx].pcl);
172 idx++;
173 }
174 pr_info("+----------Report end -----------+\n");
175}
176
177void fill_report(hdd_context_t *hdd_ctx, char *title,
178 uint32_t first_persona, uint32_t second_persona, uint32_t third_persona,
179 uint32_t chnl_1st_conn, uint32_t chnl_2nd_conn, uint32_t chnl_3rd_conn,
180 bool status, enum cds_pcl_type pcl_type, char *reason, uint8_t *pcl)
181{
182 int i;
183 char buf[4] = {0};
184
185 if (report_idx >= NUMBER_OF_SCENARIO)
186 return;
187 snprintf(report[report_idx].title,
188 2 * MAX_ALLOWED_CHAR_IN_REPORT, "pcl for[%s] pcl_type[%s]",
189 title, pcl_type_to_string(pcl_type));
190 if (chnl_1st_conn == 0)
191 snprintf(report[report_idx].first_persona,
192 MAX_ALLOWED_CHAR_IN_REPORT,
193 device_mode_to_string(first_persona));
194 else
195 snprintf(report[report_idx].first_persona,
196 MAX_ALLOWED_CHAR_IN_REPORT,
197 "%s-chnl{%d}",
198 device_mode_to_string(first_persona), chnl_1st_conn);
199 if (chnl_2nd_conn == 0)
200 snprintf(report[report_idx].second_persona,
201 MAX_ALLOWED_CHAR_IN_REPORT,
202 device_mode_to_string(second_persona));
203 else
204 snprintf(report[report_idx].second_persona,
205 MAX_ALLOWED_CHAR_IN_REPORT,
206 "%s-chnl{%d}",
207 device_mode_to_string(second_persona), chnl_2nd_conn);
208 if (chnl_3rd_conn == 0)
209 snprintf(report[report_idx].third_persona,
210 MAX_ALLOWED_CHAR_IN_REPORT,
211 device_mode_to_string(third_persona));
212 else
213 snprintf(report[report_idx].third_persona,
214 MAX_ALLOWED_CHAR_IN_REPORT,
215 "%s-chnl{%d}",
216 device_mode_to_string(third_persona), chnl_3rd_conn);
217
218 report[report_idx].status = status;
219 snprintf(report[report_idx].dbs_value,
220 MAX_ALLOWED_CHAR_IN_REPORT,
221 wma_is_hw_dbs_capable() ? "enable" : "disable");
222 snprintf(report[report_idx].system_conf,
223 MAX_ALLOWED_CHAR_IN_REPORT,
224 system_config_to_string(hdd_ctx->config->conc_system_pref));
225 snprintf(report[report_idx].result_code,
226 MAX_ALLOWED_CHAR_IN_REPORT,
227 status ? "PASS" : "FAIL");
228 snprintf(report[report_idx].reason,
229 MAX_ALLOWED_CHAR_IN_REPORT,
230 reason);
231 if (pcl) {
232 cdf_mem_zero(report[report_idx].pcl,
233 sizeof(report[report_idx].pcl));
234 for (i = 0; i < MAX_NUM_CHAN; i++) {
235 if (pcl[i] == 0)
236 break;
237 cdf_mem_zero(buf, sizeof(buf));
238 snprintf(buf, sizeof(buf), "%d ", pcl[i]);
239 strlcat(report[report_idx].pcl, buf,
240 sizeof(report[report_idx].pcl));
241 strlcat(report[report_idx].pcl, ", ",
242 sizeof(report[report_idx].pcl));
243 }
244 }
245 report_idx++;
246}
247
248static bool wlan_hdd_validate_pcl(hdd_context_t *hdd_ctx,
249 enum cds_pcl_type pcl_type, uint8_t *pcl, uint32_t pcl_len,
250 uint8_t first_connection_chnl, uint8_t second_connection_chnl,
251 char *reason, uint32_t reason_length)
252{
253 bool status = true;
254 uint32_t first_idx = 0;
255
256 if ((pcl_type != CDS_NONE) && (pcl_len == 0)) {
257 snprintf(reason, reason_length, "no of channels = 0");
258 return false;
259 }
260
261 switch (pcl_type) {
262 case CDS_NONE:
263 if (pcl_len != 0) {
264 snprintf(reason, reason_length, "no of channels>0");
265 return false;
266 }
267 break;
268 case CDS_5G:
269 for (first_idx = 0; first_idx < pcl_len; first_idx++) {
270 if (!CDS_IS_CHANNEL_5GHZ(pcl[first_idx])) {
271 snprintf(reason, reason_length,
272 "2G channel found");
273 return false;
274 }
275 }
276 break;
277 case CDS_24G:
278 for (first_idx = 0; first_idx < pcl_len; first_idx++) {
279 if (!CDS_IS_CHANNEL_24GHZ(pcl[first_idx])) {
280 snprintf(reason, reason_length,
281 "5G channel found");
282 return false;
283 }
284 }
285 break;
286 case CDS_SCC_CH:
287 if (second_connection_chnl > 0 &&
288 (first_connection_chnl != second_connection_chnl)) {
289 snprintf(reason, reason_length,
290 "invalid connections");
291 return false;
292 }
293 if (pcl[0] != first_connection_chnl) {
294 snprintf(reason, reason_length,
295 "No SCC found");
296 return false;
297 }
298 break;
299 case CDS_MCC_CH:
300 if ((pcl[0] != first_connection_chnl) &&
301 ((second_connection_chnl > 0) &&
302 (pcl[0] != second_connection_chnl))) {
303 snprintf(reason, reason_length,
304 "MCC invalid");
305 return false;
306 }
307 if ((second_connection_chnl > 0) &&
308 (pcl[1] != first_connection_chnl &&
309 pcl[1] != second_connection_chnl)) {
310 snprintf(reason, reason_length,
311 "MCC invalid");
312 return false;
313 }
314 break;
315 case CDS_SCC_CH_24G:
316 if (second_connection_chnl > 0 &&
317 (first_connection_chnl != second_connection_chnl)) {
318 snprintf(reason, reason_length,
319 "invalid connections");
320 return false;
321 }
322 if (pcl[0] != first_connection_chnl) {
323 snprintf(reason, reason_length,
324 "No SCC found");
325 return false;
326 }
327 if (!CDS_IS_CHANNEL_24GHZ(pcl[pcl_len-1])) {
328 snprintf(reason, reason_length,
329 "No 2.4Ghz chnl");
330 return false;
331 }
332 break;
333 case CDS_SCC_CH_5G:
334 if (second_connection_chnl > 0 &&
335 (first_connection_chnl != second_connection_chnl)) {
336 snprintf(reason, reason_length,
337 "invalid connections");
338 return false;
339 }
340 if (pcl[0] != first_connection_chnl) {
341 snprintf(reason, reason_length,
342 "No SCC found");
343 return false;
344 }
345 if (!CDS_IS_CHANNEL_5GHZ(pcl[pcl_len-1])) {
346 snprintf(reason, reason_length,
347 "No 5Ghz chnl");
348 return false;
349 }
350 break;
351 case CDS_24G_SCC_CH:
352 if (!CDS_IS_CHANNEL_24GHZ(pcl[0])) {
353 snprintf(reason, reason_length,
354 "No 2.4Ghz chnl");
355 return false;
356 }
357 if (second_connection_chnl > 0 &&
358 (first_connection_chnl != second_connection_chnl)) {
359 snprintf(reason, reason_length,
360 "invalid connections");
361 return false;
362 }
363 if (pcl[pcl_len-1] != first_connection_chnl) {
364 snprintf(reason, reason_length,
365 "No SCC found");
366 return false;
367 }
368 break;
369 case CDS_5G_SCC_CH:
370 if (!CDS_IS_CHANNEL_5GHZ(pcl[0])) {
371 snprintf(reason, reason_length,
372 "No 5Ghz chnl");
373 return false;
374 }
375 if (second_connection_chnl > 0 &&
376 (first_connection_chnl != second_connection_chnl)) {
377 snprintf(reason, reason_length,
378 "invalid connections");
379 return false;
380 }
381 if (pcl[pcl_len-1] != first_connection_chnl) {
382 snprintf(reason, reason_length,
383 "No SCC found");
384 return false;
385 }
386 break;
387 case CDS_MCC_CH_24G:
388 if ((pcl[0] != first_connection_chnl) &&
389 ((second_connection_chnl > 0) &&
390 (pcl[0] != second_connection_chnl))) {
391 snprintf(reason, reason_length,
392 "MCC invalid");
393 return false;
394 }
395 if ((second_connection_chnl > 0) &&
396 (pcl[1] != first_connection_chnl &&
397 pcl[1] != second_connection_chnl)) {
398 snprintf(reason, reason_length,
399 "MCC invalid");
400 return false;
401 }
402 if (!CDS_IS_CHANNEL_24GHZ(pcl[pcl_len-1])) {
403 snprintf(reason, reason_length,
404 "No 24Ghz chnl");
405 return false;
406 }
407 break;
408 case CDS_MCC_CH_5G:
409 if ((pcl[0] != first_connection_chnl) &&
410 ((second_connection_chnl > 0) &&
411 (pcl[0] != second_connection_chnl))) {
412 snprintf(reason, reason_length,
413 "MCC invalid");
414 return false;
415 }
416 if ((second_connection_chnl > 0) &&
417 (pcl[1] != first_connection_chnl &&
418 pcl[1] != second_connection_chnl)) {
419 snprintf(reason, reason_length,
420 "MCC invalid");
421 return false;
422 }
423 if (!CDS_IS_CHANNEL_5GHZ(pcl[pcl_len-1])) {
424 snprintf(reason, reason_length,
425 "No 5Ghz chnl");
426 return false;
427 }
428 break;
429 case CDS_24G_MCC_CH:
430 if (!CDS_IS_CHANNEL_24GHZ(pcl[0])) {
431 snprintf(reason, reason_length,
432 "No 24Ghz chnl");
433 return false;
434 }
435 if ((pcl[pcl_len-1] != first_connection_chnl) &&
436 ((second_connection_chnl > 0) &&
437 (pcl[pcl_len-1] != second_connection_chnl))) {
438 snprintf(reason, reason_length,
439 "MCC invalid");
440 return false;
441 }
442 if ((second_connection_chnl > 0) &&
443 (pcl[pcl_len-2] != first_connection_chnl &&
444 pcl[pcl_len-2] != second_connection_chnl)) {
445 snprintf(reason, reason_length,
446 "MCC invalid");
447 return false;
448 }
449 break;
450 case CDS_5G_MCC_CH:
451 if (!CDS_IS_CHANNEL_5GHZ(pcl[0])) {
452 snprintf(reason, reason_length,
453 "No 5Ghz chnl");
454 return false;
455 }
456 if ((pcl[pcl_len-1] != first_connection_chnl) &&
457 ((second_connection_chnl > 0) &&
458 (pcl[pcl_len-1] != second_connection_chnl))) {
459 snprintf(reason, reason_length,
460 "MCC invalid");
461 return false;
462 }
463 if ((second_connection_chnl > 0) &&
464 (pcl[pcl_len-2] != first_connection_chnl &&
465 pcl[pcl_len-2] != second_connection_chnl)) {
466 snprintf(reason, reason_length,
467 "MCC invalid");
468 return false;
469 }
470 break;
471 case CDS_SCC_ON_5_SCC_ON_24_24G:
472 if (!CDS_IS_CHANNEL_5GHZ(pcl[0]) ||
473 (pcl[0] != first_connection_chnl &&
474 pcl[0] != second_connection_chnl)) {
475 snprintf(reason, reason_length,
476 "No 5Ghz chnl/scc");
477 return false;
478 }
479 if (!CDS_IS_CHANNEL_24GHZ(pcl[1]) ||
480 (pcl[1] != first_connection_chnl &&
481 pcl[1] != second_connection_chnl)) {
482 snprintf(reason, reason_length,
483 "No 24Ghz chnl/scc");
484 return false;
485 }
486 if (!CDS_IS_CHANNEL_24GHZ(pcl[pcl_len-1])) {
487 snprintf(reason, reason_length,
488 "No 24Ghz chnls");
489 return false;
490 }
491 break;
492 case CDS_SCC_ON_5_SCC_ON_24_5G:
493 if (!CDS_IS_CHANNEL_5GHZ(pcl[0]) ||
494 (pcl[0] != first_connection_chnl &&
495 pcl[0] != second_connection_chnl)) {
496 snprintf(reason, reason_length,
497 "No 5Ghz chnl/scc");
498 return false;
499 }
500 if (!CDS_IS_CHANNEL_24GHZ(pcl[1]) ||
501 (pcl[1] != first_connection_chnl &&
502 pcl[1] != second_connection_chnl)) {
503 snprintf(reason, reason_length,
504 "No 24Ghz chnl/scc");
505 return false;
506 }
507 if (!CDS_IS_CHANNEL_5GHZ(pcl[pcl_len-1])) {
508 snprintf(reason, reason_length,
509 "No 5Ghz chnls");
510 return false;
511 }
512 break;
513 case CDS_SCC_ON_24_SCC_ON_5_24G:
514 if (!CDS_IS_CHANNEL_24GHZ(pcl[0]) ||
515 (pcl[0] != first_connection_chnl &&
516 pcl[0] != second_connection_chnl)) {
517 snprintf(reason, reason_length,
518 "No 24Ghz chnl/scc");
519 return false;
520 }
521 if (!CDS_IS_CHANNEL_5GHZ(pcl[1]) ||
522 (pcl[1] != first_connection_chnl &&
523 pcl[1] != second_connection_chnl)) {
524 snprintf(reason, reason_length,
525 "No 5Ghz chnl/scc");
526 return false;
527 }
528 if (!CDS_IS_CHANNEL_24GHZ(pcl[pcl_len-1])) {
529 snprintf(reason, reason_length,
530 "No 24Ghz chnls");
531 return false;
532 }
533 break;
534 case CDS_SCC_ON_24_SCC_ON_5_5G:
535 if (!CDS_IS_CHANNEL_24GHZ(pcl[0]) ||
536 (pcl[0] != first_connection_chnl &&
537 pcl[0] != second_connection_chnl)) {
538 snprintf(reason, reason_length,
539 "No 24Ghz chnl/scc");
540 return false;
541 }
542 if (!CDS_IS_CHANNEL_5GHZ(pcl[1]) ||
543 (pcl[1] != first_connection_chnl &&
544 pcl[1] != second_connection_chnl)) {
545 snprintf(reason, reason_length,
546 "No 5Ghz chnl/scc");
547 return false;
548 }
549 if (!CDS_IS_CHANNEL_5GHZ(pcl[pcl_len-1])) {
550 snprintf(reason, reason_length,
551 "No 5Ghz chnls");
552 return false;
553 }
554 break;
555 case CDS_SCC_ON_5_SCC_ON_24:
556 if (!CDS_IS_CHANNEL_5GHZ(pcl[0]) ||
557 (pcl[0] != first_connection_chnl &&
558 pcl[0] != second_connection_chnl)) {
559 snprintf(reason, reason_length,
560 "No 5Ghz chnl/scc");
561 return false;
562 }
563 if (!CDS_IS_CHANNEL_24GHZ(pcl[1]) ||
564 (pcl[1] != first_connection_chnl &&
565 pcl[1] != second_connection_chnl)) {
566 snprintf(reason, reason_length,
567 "No 24Ghz chnl/scc");
568 return false;
569 }
570 if (pcl_len != 2) {
571 snprintf(reason, reason_length,
572 "more than 2 chnls");
573 return false;
574 }
575 break;
576 case CDS_SCC_ON_24_SCC_ON_5:
577 if (!CDS_IS_CHANNEL_24GHZ(pcl[0]) ||
578 (pcl[0] != first_connection_chnl &&
579 pcl[0] != second_connection_chnl)) {
580 snprintf(reason, reason_length,
581 "No 24Ghz chnl/scc");
582 return false;
583 }
584 if (!CDS_IS_CHANNEL_5GHZ(pcl[1]) ||
585 (pcl[1] != first_connection_chnl &&
586 pcl[1] != second_connection_chnl)) {
587 snprintf(reason, reason_length,
588 "No 5Ghz chnl/scc");
589 return false;
590 }
591 if (pcl_len != 2) {
592 snprintf(reason, reason_length,
593 "more than 2 chnls");
594 return false;
595 }
596 break;
597 default:
598 snprintf(reason, reason_length,
599 "Unknown option");
600 status = false;
601 }
602 if (status == true) {
603 snprintf(reason, reason_length,
604 "success");
605 }
606 return status;
607}
608
609static void wlan_hdd_map_subtypes_hdd_wma(enum cds_con_mode *dst,
610 enum cds_con_mode *src)
611{
612 /*
613 * wma defined sap subtype as 0
614 * Rest of the mappings are same
615 * In future, if mapping gets changed then re-map it here
616 */
617 if (*src == CDS_SAP_MODE)
618 *dst = 0;
619 else
620 *dst = *src;
621}
622
623void wlan_hdd_one_connection_scenario(hdd_context_t *hdd_ctx)
624{
625 enum cds_con_mode sub_type;
626 enum cds_conc_priority_mode system_pref =
627 hdd_ctx->config->conc_system_pref;
628 uint8_t pcl[MAX_NUM_CHAN] = {0};
629 uint32_t pcl_len = 0;
630 bool status = false;
631 enum cds_pcl_type pcl_type;
632 char reason[20] = {0};
633 CDF_STATUS ret;
634
635 /* flush the entire table first */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800636 ret = cds_init_policy_mgr();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 if (!CDF_IS_STATUS_SUCCESS(ret)) {
638 hdd_err("Policy manager initialization failed");
639 return;
640 }
641
642 for (sub_type = 0; sub_type < CDS_MAX_NUM_OF_MODE; sub_type++) {
643 /* validate one connection is created or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800644 if (cds_get_connection_count() != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 hddLog(LOGE,
646 FL("Test failed - No. of connection is not 0"));
647 return;
648 }
649 cdf_mem_zero(pcl, sizeof(pcl));
650 pcl_len = 0;
651 pcl_type = get_pcl_from_first_conn_table(sub_type, system_pref);
652
653 /* check PCL value for second connection is correct or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800654 cds_get_pcl(sub_type, pcl, &pcl_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 status = wlan_hdd_validate_pcl(hdd_ctx,
656 pcl_type, pcl, pcl_len, 0, 0,
657 reason, sizeof(reason));
658 if ((pcl_type == CDS_MAX_PCL_TYPE) && (pcl[0] == 0))
659 continue;
660
661 fill_report(hdd_ctx, "1 connection", sub_type,
662 CDS_MAX_NUM_OF_MODE,
663 CDS_MAX_NUM_OF_MODE,
664 0, 0, 0,
665 status, pcl_type, reason, pcl);
666 }
667}
668
669void wlan_hdd_two_connections_scenario(hdd_context_t *hdd_ctx,
670 uint8_t first_chnl, enum cds_chain_mode first_chain_mask)
671{
672 uint8_t vdevid = 0, tx_stream = 2, rx_stream = 2;
673 uint8_t type = WMI_VDEV_TYPE_STA, channel_id = first_chnl, mac_id = 1;
674 uint8_t pcl[MAX_NUM_CHAN] = {0};
675 uint32_t pcl_len = 0;
676 enum cds_chain_mode chain_mask = first_chain_mask;
677 enum cds_con_mode sub_type, next_sub_type, dummy_type;
678 enum cds_conc_priority_mode system_pref =
679 hdd_ctx->config->conc_system_pref;
680 enum cds_pcl_type pcl_type;
681 enum cds_one_connection_mode second_index;
682 char reason[20] = {0};
683 bool status = false;
684 CDF_STATUS ret;
685
686 for (sub_type = CDS_STA_MODE;
687 sub_type < CDS_MAX_NUM_OF_MODE; sub_type++) {
688 type = wlan_hdd_valid_type_of_persona(sub_type);
689
690 /* flush the entire table first */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800691 ret = cds_init_policy_mgr();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 if (!CDF_IS_STATUS_SUCCESS(ret)) {
693 hdd_err("Policy manager initialization failed");
694 return;
695 }
696
697 /* sub_type mapping between HDD and WMA are different */
698 wlan_hdd_map_subtypes_hdd_wma(&dummy_type, &sub_type);
699 /* add first connection as STA */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800700 cds_incr_connection_count_utfw(vdevid, tx_stream,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701 rx_stream, chain_mask, type, dummy_type,
702 channel_id, mac_id);
703 /* validate one connection is created or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800704 if (cds_get_connection_count() != 1) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705 hddLog(LOGE,
706 FL("Test failed - No. of connection is not 1"));
707 return;
708 }
709 next_sub_type = CDS_STA_MODE;
710 while (next_sub_type < CDS_MAX_NUM_OF_MODE) {
711 /* get the PCL value & check the channels accordingly */
712 second_index =
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800713 cds_get_second_connection_pcl_table_index();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714 if (CDS_MAX_ONE_CONNECTION_MODE == second_index) {
715 /* not valid combination*/
716 hddLog(LOGE, FL("couldn't find index for 2nd connection pcl table"));
717 next_sub_type++;
718 continue;
719 }
720 cdf_mem_zero(pcl, sizeof(pcl));
721 pcl_len = 0;
722 pcl_type = get_pcl_from_second_conn_table(second_index,
723 next_sub_type, system_pref,
724 wma_is_hw_dbs_capable());
725 /* check PCL for second connection is correct or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800726 cds_get_pcl(next_sub_type, pcl, &pcl_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727 status = wlan_hdd_validate_pcl(hdd_ctx,
728 pcl_type, pcl, pcl_len, channel_id, 0,
729 reason, sizeof(reason));
730 if ((pcl_type == CDS_MAX_PCL_TYPE) && (pcl[0] == 0)) {
731 next_sub_type++;
732 continue;
733 }
734 fill_report(hdd_ctx, "2 connections", sub_type,
735 next_sub_type,
736 CDS_MAX_NUM_OF_MODE, first_chnl,
737 0, 0, status, pcl_type, reason, pcl);
738 next_sub_type++;
739 }
740 }
741}
742
743void wlan_hdd_three_connections_scenario(hdd_context_t *hdd_ctx,
744 uint8_t first_chnl, uint8_t second_chnl,
745 enum cds_chain_mode chain_mask, uint8_t use_same_mac)
746{
747 uint8_t vdevid_1 = 0, tx_stream_1 = 2, rx_stream_1 = 2;
748 uint8_t vdevid_2 = 1, tx_stream_2 = 2, rx_stream_2 = 2;
749 uint8_t channel_id_1 = first_chnl, channel_id_2 = second_chnl;
750 uint8_t mac_id_1, mac_id_2;
751 uint8_t type_1 = WMI_VDEV_TYPE_STA, type_2 = WMI_VDEV_TYPE_STA;
752 uint8_t pcl[MAX_NUM_CHAN] = {0};
753 uint32_t pcl_len = 0;
754 enum cds_chain_mode chain_mask_1;
755 enum cds_chain_mode chain_mask_2;
756 enum cds_con_mode sub_type_1, sub_type_2, next_sub_type;
757 enum cds_con_mode dummy_type_1, dummy_type_2;
758 enum cds_conc_priority_mode system_pref =
759 hdd_ctx->config->conc_system_pref;
760 enum cds_pcl_type pcl_type;
761 enum cds_two_connection_mode third_index;
762 char reason[20] = {0};
763 bool status = false;
764 CDF_STATUS ret;
765
766 /* let's set the chain_mask, mac_ids*/
767 if (chain_mask == CDS_TWO_TWO) {
768 mac_id_1 = 1;
769 mac_id_2 = 1;
770 chain_mask_1 = CDS_TWO_TWO;
771 chain_mask_2 = CDS_TWO_TWO;
772 } else if (use_same_mac == 1) {
773 mac_id_1 = 1;
774 mac_id_2 = 1;
775 chain_mask_1 = CDS_ONE_ONE;
776 chain_mask_2 = CDS_ONE_ONE;
777 } else {
778 mac_id_1 = 1;
779 mac_id_2 = 2;
780 chain_mask_1 = CDS_ONE_ONE;
781 chain_mask_2 = CDS_ONE_ONE;
782 }
783
784 for (sub_type_1 = CDS_STA_MODE;
785 sub_type_1 < CDS_MAX_NUM_OF_MODE; sub_type_1++) {
786
787 type_1 = wlan_hdd_valid_type_of_persona(sub_type_1);
788 /* flush the entire table first */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800789 ret = cds_init_policy_mgr();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 if (!CDF_IS_STATUS_SUCCESS(ret)) {
791 hdd_err("Policy manager initialization failed");
792 return;
793 }
794
795 /* sub_type mapping between HDD and WMA are different */
796 wlan_hdd_map_subtypes_hdd_wma(&dummy_type_1, &sub_type_1);
797 /* add first connection as STA */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800798 cds_incr_connection_count_utfw(vdevid_1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 tx_stream_1, rx_stream_1, chain_mask_1, type_1,
800 dummy_type_1, channel_id_1, mac_id_1);
801 /* validate one connection is created or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800802 if (cds_get_connection_count() != 1) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 hddLog(LOGE,
804 FL("Test fail - No. of connection not 1"));
805 return;
806 }
807 for (sub_type_2 = CDS_STA_MODE;
808 sub_type_2 < CDS_MAX_NUM_OF_MODE; sub_type_2++) {
809
810 type_2 = wlan_hdd_valid_type_of_persona(sub_type_2);
811 /* sub_type mapping between HDD and WMA are different */
812 wlan_hdd_map_subtypes_hdd_wma(&dummy_type_2,
813 &sub_type_2);
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800814 cds_incr_connection_count_utfw(vdevid_2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 tx_stream_2, rx_stream_2, chain_mask_2, type_2,
816 dummy_type_2, channel_id_2, mac_id_2);
817 /* validate two connections are created or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800818 if (cds_get_connection_count() != 2) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819 hddLog(LOGE,
820 FL("Test fail - No. connection not 2"));
821 return;
822 }
823 next_sub_type = CDS_STA_MODE;
824 while (next_sub_type < CDS_MAX_NUM_OF_MODE) {
825 third_index =
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800826 cds_get_third_connection_pcl_table_index();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 if (CDS_MAX_TWO_CONNECTION_MODE ==
828 third_index) {
829 /* not valid combination */
830 next_sub_type++;
831 continue;
832 }
833 cdf_mem_zero(pcl, sizeof(pcl));
834 pcl_len = 0;
835 pcl_type =
836 get_pcl_from_third_conn_table(
837 third_index, next_sub_type,
838 system_pref,
839 wma_is_hw_dbs_capable());
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800840 cds_get_pcl(next_sub_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 pcl, &pcl_len);
842 status = wlan_hdd_validate_pcl(hdd_ctx,
843 pcl_type, pcl, pcl_len,
844 channel_id_1, channel_id_2,
845 reason, sizeof(reason));
846 if ((pcl_type == CDS_MAX_PCL_TYPE) &&
847 (pcl[0] == 0)) {
848 next_sub_type++;
849 continue;
850 }
851 fill_report(hdd_ctx, "3 connections",
852 sub_type_1, sub_type_2,
853 next_sub_type, first_chnl,
854 second_chnl, 0, status,
855 pcl_type, reason, pcl);
856 next_sub_type++;
857 }
858 /* remove entry to make a room for next iteration */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800859 cds_decr_connection_count(vdevid_2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860 }
861 next_sub_type = CDS_STA_MODE;
862 }
863}