1 /*
2  * Copyright 2022, Cypress Semiconductor Corporation (an Infineon company)
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /** @file
19  *  Provides prototypes / declarations for APSTA functionality
20  */
21 #ifndef INCLUDED_WHD_AP_H
22 #define INCLUDED_WHD_AP_H
23 
24 #include "whd.h"
25 #include "cyabs_rtos.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /******************************************************
32 *                      Macros
33 ******************************************************/
34 #define AMPDU_RX_FACTOR_8K          0     /* max receive AMPDU length is 8kb */
35 #define AMPDU_RX_FACTOR_16K         1     /* max receive AMPDU length is 16kb */
36 #define AMPDU_RX_FACTOR_32K         2     /* max receive AMPDU length is 32kb */
37 #define AMPDU_RX_FACTOR_64K         3     /* max receive AMPDU length is 64kb */
38 #define AMPDU_RX_FACTOR_INVALID  0xff     /* invalid rx factor; ignore */
39 #define AMPDU_MPDU_AUTO             (-1)  /* Auto number of mpdu in ampdu */
40 
41 
42 #define BANDWIDTH_20MHZ            (20)  /* 802.11n, 802.11ac 20Mhz Bandwidth */
43 #define BANDWIDTH_40MHZ            (40)  /* 802.11n, 802.11ac 40Mhz Bandwidth */
44 #define BANDWIDTH_80MHZ            (80)  /* 802.11ac 80Mhz Bandwidth          */
45 
46 #define WHD_WIFI_CONFIG_AP_MAX_ASSOC 5
47 
48 #define CHECK_IOCTL_BUFFER_WITH_SEMAPHORE(buff, \
49                                           sema)  if (buff == \
50                                                      NULL){ WPRINT_WHD_ERROR( ("Buffer alloc failed in %s at %d \n", \
51                                                                                __func__, __LINE__) ); \
52                                                             whd_assert("Buffer alloc failed\n", 0 == 1); \
53                                                             (void)cy_rtos_deinit_semaphore(sema); \
54                                                             return WHD_BUFFER_ALLOC_FAIL; }
55 
56 #define CHECK_RETURN_WITH_SEMAPHORE(expr, sema)  { whd_result_t check_res = (expr); if (check_res != WHD_SUCCESS) \
57                                                    { WPRINT_WHD_ERROR( ("Command failed in %s at %d \n", __func__, \
58                                                                         __LINE__) ); \
59                                                      whd_assert("Command failed\n", 0 == 1); \
60                                                      (void)cy_rtos_deinit_semaphore(sema); \
61                                                      return check_res; } }
62 
63 /******************************************************
64 *             Structures
65 ******************************************************/
66 typedef struct whd_ap_int_info
67 {
68     whd_bool_t ap_is_up;
69     whd_bool_t is_waiting_event;
70     cy_semaphore_t whd_wifi_sleep_flag;
71 
72 } whd_ap_int_info_t;
73 
74 /******************************************************
75 *             Function prototypes
76 ******************************************************/
77 extern whd_result_t whd_wifi_set_block_ack_window_size_common(whd_interface_t interface, uint16_t ap_win_size,
78                                                               uint16_t sta_win_size);
79 extern whd_result_t whd_wifi_set_ampdu_parameters_common(whd_interface_t interface, uint8_t ba_window_size,
80                                                          int8_t ampdu_mpdu, uint8_t rx_factor);
81 extern void whd_wifi_set_ap_is_up(whd_driver_t whd_driver, whd_bool_t new_state);
82 extern whd_bool_t whd_wifi_get_ap_is_up(whd_driver_t whd_driver);
83 void whd_ap_info_init(whd_driver_t whd_driver);
84 whd_result_t whd_wifi_set_block_ack_window_size(whd_interface_t ifp);
85 
86 
87 /** Set the AMPDU parameters for both Soft AP and STA
88  *
89  * Sets various AMPDU parameters for Soft AP and STA to ensure that the number of buffers dedicated to AMPDUs does
90  * not exceed the resources of the chip. Both Soft AP and STA interfaces must be down.
91  *
92  * @return  WHD_SUCCESS : if the AMPDU parameters were successfully set
93  *          WHD_ERROR   : if the AMPDU parameters were not successfully set
94  */
95 extern whd_result_t whd_wifi_set_ampdu_parameters(whd_interface_t ifp);
96 
97 #ifdef __cplusplus
98 } /*extern "C" */
99 #endif
100 
101 #endif /* ifndef INCLUDED_WHD_AP_H */
102