1 /** @file moal_uap_priv.c
2 *
3 * @brief This file contains standard ioctl functions
4 *
5 *
6 * Copyright 2010-2021 NXP
7 *
8 * This software file (the File) is distributed by NXP
9 * under the terms of the GNU General Public License Version 2, June 1991
10 * (the License). You may use, redistribute and/or modify the File in
11 * accordance with the terms and conditions of the License, a copy of which
12 * is available by writing to the Free Software Foundation, Inc.,
13 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
14 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
15 *
16 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
18 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
19 * this warranty disclaimer.
20 *
21 */
22
23 /************************************************************************
24 Change log:
25 08/06/2010: initial version
26 ************************************************************************/
27
28 #include "moal_main.h"
29 #include "moal_uap.h"
30 #include "moal_uap_priv.h"
31
32 /********************************************************
33 Local Variables
34 ********************************************************/
35
36 /********************************************************
37 Global Variables
38 ********************************************************/
39
40 /********************************************************
41 Local Functions
42 ********************************************************/
43
44 /********************************************************
45 Global Functions
46 ********************************************************/
47
48 /**
49 * @brief ioctl function for wireless IOCTLs
50 *
51 * @param dev A pointer to net_device structure
52 * @param req A pointer to ifreq structure
53 * @param cmd Command
54 *
55 * @return 0 --success, otherwise fail
56 */
woal_uap_do_priv_ioctl(struct net_device * dev,struct ifreq * req,int cmd)57 int woal_uap_do_priv_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
58 {
59 moal_private *priv = (moal_private *)netdev_priv(dev);
60 struct iwreq *wrq = (struct iwreq *)req;
61 int ret = 0;
62
63 ENTER();
64
65 switch (cmd) {
66 case WOAL_UAP_SETNONE_GETNONE:
67 switch (wrq->u.data.flags) {
68 case WOAL_UAP_START:
69 break;
70 case WOAL_UAP_STOP:
71 ret = woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT,
72 UAP_BSS_STOP);
73 break;
74 case WOAL_AP_BSS_START:
75 ret = woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT,
76 UAP_BSS_START);
77 break;
78 case WOAL_AP_BSS_STOP:
79 ret = woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT,
80 UAP_BSS_STOP);
81 break;
82 default:
83 ret = -EINVAL;
84 break;
85 }
86 break;
87 case WOAL_UAP_SETONEINT_GETWORDCHAR:
88 switch (wrq->u.data.flags) {
89 case WOAL_UAP_VERSION:
90 ret = woal_get_driver_version(priv, req);
91 break;
92 case WOAL_UAP_VEREXT:
93 ret = woal_get_driver_verext(priv, req);
94 break;
95 default:
96 ret = -EOPNOTSUPP;
97 break;
98 }
99 break;
100 case WOAL_UAP_SET_GET_256_CHAR:
101 switch (wrq->u.data.flags) {
102 case WOAL_WL_FW_RELOAD:
103 break;
104 case WOAL_AP_SET_CFG:
105 ret = woal_uap_set_ap_cfg(
106 priv, (t_u8 __force *)wrq->u.data.pointer,
107 wrq->u.data.length);
108 break;
109 default:
110 ret = -EINVAL;
111 break;
112 }
113 break;
114 case WOAL_UAP_SETONEINT_GETONEINT:
115 switch (wrq->u.data.flags) {
116 #ifdef WIFI_DIRECT_SUPPORT
117 #if defined(STA_SUPPORT) && defined(UAP_SUPPORT)
118 case WOAL_UAP_SET_GET_BSS_ROLE:
119 ret = woal_set_get_bss_role(priv, wrq);
120 break;
121 #endif
122 #endif
123 default:
124 ret = -EINVAL;
125 break;
126 }
127 break;
128 case WOAL_UAP_HOST_CMD:
129 ret = woal_host_command(priv, wrq);
130 break;
131 case WOAL_UAP_FROYO_START:
132 break;
133 case WOAL_UAP_FROYO_STOP:
134 ret = woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT, UAP_BSS_STOP);
135 break;
136 case WOAL_UAP_FROYO_AP_BSS_START:
137 ret = woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT, UAP_BSS_START);
138 break;
139 case WOAL_UAP_FROYO_AP_BSS_STOP:
140 ret = woal_uap_bss_ctrl(priv, MOAL_IOCTL_WAIT, UAP_BSS_STOP);
141 break;
142 case WOAL_UAP_FROYO_WL_FW_RELOAD:
143 break;
144 case WOAL_UAP_FROYO_AP_SET_CFG:
145 ret = woal_uap_set_ap_cfg(priv,
146 (t_u8 __force *)wrq->u.data.pointer,
147 wrq->u.data.length);
148 break;
149 default:
150 ret = -EINVAL;
151 break;
152 }
153
154 LEAVE();
155 return ret;
156 }
157
158 /**
159 * @brief Handle get info resp
160 *
161 * @param priv Pointer to moal_private structure
162 * @param info Pointer to mlan_ds_get_info structure
163 *
164 * @return N/A
165 */
woal_ioctl_get_uap_info_resp(moal_private * priv,mlan_ds_get_info * info)166 void woal_ioctl_get_uap_info_resp(moal_private *priv, mlan_ds_get_info *info)
167 {
168 ENTER();
169 switch (info->sub_command) {
170 case MLAN_OID_GET_STATS:
171 priv->w_stats.discard.fragment =
172 info->param.ustats.fcs_error_count;
173 priv->w_stats.discard.retries = info->param.ustats.retry_count;
174 priv->w_stats.discard.misc =
175 info->param.ustats.ack_failure_count;
176 break;
177 default:
178 break;
179 }
180 LEAVE();
181 }
182