blob: b792ddfc0c30cd740b97252e2adac3064214e986 [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"
Anurag Chouhan6d760662016-02-20 16:05:43 +053038#include "qdf_types.h"
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053039#include "qdf_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#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];
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +053076 char pcl[2 * QDF_MAX_NUM_CHAN];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077};
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) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530154 qdf_mem_zero(&report[idx], sizeof(struct report_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 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,
Krunal Soni44427772016-07-21 10:44:12 -0700192 MAX_ALLOWED_CHAR_IN_REPORT, "%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 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,
Krunal Soni44427772016-07-21 10:44:12 -0700201 MAX_ALLOWED_CHAR_IN_REPORT, "%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202 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,
Krunal Soni44427772016-07-21 10:44:12 -0700210 MAX_ALLOWED_CHAR_IN_REPORT, "%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800211 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,
Krunal Soni44427772016-07-21 10:44:12 -0700220 MAX_ALLOWED_CHAR_IN_REPORT, "%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 wma_is_hw_dbs_capable() ? "enable" : "disable");
222 snprintf(report[report_idx].system_conf,
Krunal Soni44427772016-07-21 10:44:12 -0700223 MAX_ALLOWED_CHAR_IN_REPORT, "%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 system_config_to_string(hdd_ctx->config->conc_system_pref));
225 snprintf(report[report_idx].result_code,
Krunal Soni44427772016-07-21 10:44:12 -0700226 MAX_ALLOWED_CHAR_IN_REPORT, "%s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 status ? "PASS" : "FAIL");
228 snprintf(report[report_idx].reason,
229 MAX_ALLOWED_CHAR_IN_REPORT,
230 reason);
231 if (pcl) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530232 qdf_mem_zero(report[report_idx].pcl,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 sizeof(report[report_idx].pcl));
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +0530234 for (i = 0; i < QDF_MAX_NUM_CHAN; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 if (pcl[i] == 0)
236 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530237 qdf_mem_zero(buf, sizeof(buf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 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;
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +0530628 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0},
629 weight_list[QDF_MAX_NUM_CHAN] = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800630 uint32_t pcl_len = 0;
631 bool status = false;
632 enum cds_pcl_type pcl_type;
633 char reason[20] = {0};
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530634 QDF_STATUS ret;
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -0700635 struct cds_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -0700637 sme_cbacks.sme_get_valid_channels = sme_get_cfg_valid_channels;
638 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 /* flush the entire table first */
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -0700640 ret = cds_init_policy_mgr(&sme_cbacks);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530641 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 hdd_err("Policy manager initialization failed");
643 return;
644 }
645
646 for (sub_type = 0; sub_type < CDS_MAX_NUM_OF_MODE; sub_type++) {
647 /* validate one connection is created or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800648 if (cds_get_connection_count() != 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 hddLog(LOGE,
650 FL("Test failed - No. of connection is not 0"));
651 return;
652 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530653 qdf_mem_zero(pcl, sizeof(pcl));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 pcl_len = 0;
655 pcl_type = get_pcl_from_first_conn_table(sub_type, system_pref);
656
657 /* check PCL value for second connection is correct or no */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +0530658 cds_get_pcl(sub_type, pcl, &pcl_len,
659 weight_list, QDF_ARRAY_SIZE(weight_list));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 status = wlan_hdd_validate_pcl(hdd_ctx,
661 pcl_type, pcl, pcl_len, 0, 0,
662 reason, sizeof(reason));
663 if ((pcl_type == CDS_MAX_PCL_TYPE) && (pcl[0] == 0))
664 continue;
665
666 fill_report(hdd_ctx, "1 connection", sub_type,
667 CDS_MAX_NUM_OF_MODE,
668 CDS_MAX_NUM_OF_MODE,
669 0, 0, 0,
670 status, pcl_type, reason, pcl);
671 }
672}
673
674void wlan_hdd_two_connections_scenario(hdd_context_t *hdd_ctx,
675 uint8_t first_chnl, enum cds_chain_mode first_chain_mask)
676{
677 uint8_t vdevid = 0, tx_stream = 2, rx_stream = 2;
678 uint8_t type = WMI_VDEV_TYPE_STA, channel_id = first_chnl, mac_id = 1;
Manishekar Chandrasekaran1db3abe2016-06-24 03:27:07 +0530679 uint8_t pcl[QDF_MAX_NUM_CHAN] = {0},
680 weight_list[QDF_MAX_NUM_CHAN] = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 uint32_t pcl_len = 0;
682 enum cds_chain_mode chain_mask = first_chain_mask;
683 enum cds_con_mode sub_type, next_sub_type, dummy_type;
684 enum cds_conc_priority_mode system_pref =
685 hdd_ctx->config->conc_system_pref;
686 enum cds_pcl_type pcl_type;
687 enum cds_one_connection_mode second_index;
688 char reason[20] = {0};
689 bool status = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530690 QDF_STATUS ret;
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -0700691 struct cds_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692
693 for (sub_type = CDS_STA_MODE;
694 sub_type < CDS_MAX_NUM_OF_MODE; sub_type++) {
695 type = wlan_hdd_valid_type_of_persona(sub_type);
696
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -0700697 sme_cbacks.sme_get_valid_channels = sme_get_cfg_valid_channels;
698 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 /* flush the entire table first */
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -0700700 ret = cds_init_policy_mgr(&sme_cbacks);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530701 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 hdd_err("Policy manager initialization failed");
703 return;
704 }
705
706 /* sub_type mapping between HDD and WMA are different */
707 wlan_hdd_map_subtypes_hdd_wma(&dummy_type, &sub_type);
708 /* add first connection as STA */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800709 cds_incr_connection_count_utfw(vdevid, tx_stream,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 rx_stream, chain_mask, type, dummy_type,
711 channel_id, mac_id);
712 /* validate one connection is created or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800713 if (cds_get_connection_count() != 1) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714 hddLog(LOGE,
715 FL("Test failed - No. of connection is not 1"));
716 return;
717 }
718 next_sub_type = CDS_STA_MODE;
719 while (next_sub_type < CDS_MAX_NUM_OF_MODE) {
720 /* get the PCL value & check the channels accordingly */
721 second_index =
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800722 cds_get_second_connection_pcl_table_index();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 if (CDS_MAX_ONE_CONNECTION_MODE == second_index) {
724 /* not valid combination*/
725 hddLog(LOGE, FL("couldn't find index for 2nd connection pcl table"));
726 next_sub_type++;
727 continue;
728 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530729 qdf_mem_zero(pcl, sizeof(pcl));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730 pcl_len = 0;
731 pcl_type = get_pcl_from_second_conn_table(second_index,
732 next_sub_type, system_pref,
733 wma_is_hw_dbs_capable());
734 /* check PCL for second connection is correct or no */
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +0530735 cds_get_pcl(next_sub_type, pcl, &pcl_len,
736 weight_list, QDF_ARRAY_SIZE(weight_list));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 status = wlan_hdd_validate_pcl(hdd_ctx,
738 pcl_type, pcl, pcl_len, channel_id, 0,
739 reason, sizeof(reason));
740 if ((pcl_type == CDS_MAX_PCL_TYPE) && (pcl[0] == 0)) {
741 next_sub_type++;
742 continue;
743 }
744 fill_report(hdd_ctx, "2 connections", sub_type,
745 next_sub_type,
746 CDS_MAX_NUM_OF_MODE, first_chnl,
747 0, 0, status, pcl_type, reason, pcl);
748 next_sub_type++;
749 }
750 }
751}
752
753void wlan_hdd_three_connections_scenario(hdd_context_t *hdd_ctx,
754 uint8_t first_chnl, uint8_t second_chnl,
755 enum cds_chain_mode chain_mask, uint8_t use_same_mac)
756{
757 uint8_t vdevid_1 = 0, tx_stream_1 = 2, rx_stream_1 = 2;
758 uint8_t vdevid_2 = 1, tx_stream_2 = 2, rx_stream_2 = 2;
759 uint8_t channel_id_1 = first_chnl, channel_id_2 = second_chnl;
760 uint8_t mac_id_1, mac_id_2;
761 uint8_t type_1 = WMI_VDEV_TYPE_STA, type_2 = WMI_VDEV_TYPE_STA;
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +0530762 uint8_t pcl[MAX_NUM_CHAN] = {0}, weight_list[MAX_NUM_CHAN] = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763 uint32_t pcl_len = 0;
764 enum cds_chain_mode chain_mask_1;
765 enum cds_chain_mode chain_mask_2;
766 enum cds_con_mode sub_type_1, sub_type_2, next_sub_type;
767 enum cds_con_mode dummy_type_1, dummy_type_2;
768 enum cds_conc_priority_mode system_pref =
769 hdd_ctx->config->conc_system_pref;
770 enum cds_pcl_type pcl_type;
771 enum cds_two_connection_mode third_index;
772 char reason[20] = {0};
773 bool status = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530774 QDF_STATUS ret;
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -0700775 struct cds_sme_cbacks sme_cbacks;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776
777 /* let's set the chain_mask, mac_ids*/
778 if (chain_mask == CDS_TWO_TWO) {
779 mac_id_1 = 1;
780 mac_id_2 = 1;
781 chain_mask_1 = CDS_TWO_TWO;
782 chain_mask_2 = CDS_TWO_TWO;
783 } else if (use_same_mac == 1) {
784 mac_id_1 = 1;
785 mac_id_2 = 1;
786 chain_mask_1 = CDS_ONE_ONE;
787 chain_mask_2 = CDS_ONE_ONE;
788 } else {
789 mac_id_1 = 1;
790 mac_id_2 = 2;
791 chain_mask_1 = CDS_ONE_ONE;
792 chain_mask_2 = CDS_ONE_ONE;
793 }
794
795 for (sub_type_1 = CDS_STA_MODE;
796 sub_type_1 < CDS_MAX_NUM_OF_MODE; sub_type_1++) {
797
798 type_1 = wlan_hdd_valid_type_of_persona(sub_type_1);
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -0700799
800 sme_cbacks.sme_get_valid_channels = sme_get_cfg_valid_channels;
801 sme_cbacks.sme_get_nss_for_vdev = sme_get_vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 /* flush the entire table first */
Tushnim Bhattacharyyaf44a9d82016-07-05 10:52:06 -0700803 ret = cds_init_policy_mgr(&sme_cbacks);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530804 if (!QDF_IS_STATUS_SUCCESS(ret)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 hdd_err("Policy manager initialization failed");
806 return;
807 }
808
809 /* sub_type mapping between HDD and WMA are different */
810 wlan_hdd_map_subtypes_hdd_wma(&dummy_type_1, &sub_type_1);
811 /* add first connection as STA */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800812 cds_incr_connection_count_utfw(vdevid_1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 tx_stream_1, rx_stream_1, chain_mask_1, type_1,
814 dummy_type_1, channel_id_1, mac_id_1);
815 /* validate one connection is created or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800816 if (cds_get_connection_count() != 1) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 hddLog(LOGE,
818 FL("Test fail - No. of connection not 1"));
819 return;
820 }
821 for (sub_type_2 = CDS_STA_MODE;
822 sub_type_2 < CDS_MAX_NUM_OF_MODE; sub_type_2++) {
823
824 type_2 = wlan_hdd_valid_type_of_persona(sub_type_2);
825 /* sub_type mapping between HDD and WMA are different */
826 wlan_hdd_map_subtypes_hdd_wma(&dummy_type_2,
827 &sub_type_2);
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800828 cds_incr_connection_count_utfw(vdevid_2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 tx_stream_2, rx_stream_2, chain_mask_2, type_2,
830 dummy_type_2, channel_id_2, mac_id_2);
831 /* validate two connections are created or no */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800832 if (cds_get_connection_count() != 2) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800833 hddLog(LOGE,
834 FL("Test fail - No. connection not 2"));
835 return;
836 }
837 next_sub_type = CDS_STA_MODE;
838 while (next_sub_type < CDS_MAX_NUM_OF_MODE) {
839 third_index =
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800840 cds_get_third_connection_pcl_table_index();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 if (CDS_MAX_TWO_CONNECTION_MODE ==
842 third_index) {
843 /* not valid combination */
844 next_sub_type++;
845 continue;
846 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530847 qdf_mem_zero(pcl, sizeof(pcl));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 pcl_len = 0;
849 pcl_type =
850 get_pcl_from_third_conn_table(
851 third_index, next_sub_type,
852 system_pref,
853 wma_is_hw_dbs_capable());
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800854 cds_get_pcl(next_sub_type,
Manishekar Chandrasekaran7009f252016-04-21 19:14:15 +0530855 pcl, &pcl_len,
856 weight_list,
857 QDF_ARRAY_SIZE(weight_list));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 status = wlan_hdd_validate_pcl(hdd_ctx,
859 pcl_type, pcl, pcl_len,
860 channel_id_1, channel_id_2,
861 reason, sizeof(reason));
862 if ((pcl_type == CDS_MAX_PCL_TYPE) &&
863 (pcl[0] == 0)) {
864 next_sub_type++;
865 continue;
866 }
867 fill_report(hdd_ctx, "3 connections",
868 sub_type_1, sub_type_2,
869 next_sub_type, first_chnl,
870 second_chnl, 0, status,
871 pcl_type, reason, pcl);
872 next_sub_type++;
873 }
874 /* remove entry to make a room for next iteration */
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800875 cds_decr_connection_count(vdevid_2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 }
877 next_sub_type = CDS_STA_MODE;
878 }
879}