blob: c97e0e154d285d8b638dc5adb7a1bd4ac764d586 [file] [log] [blame]
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001/*******************************************************************************
2 * Agere Systems Inc.
3 * Wireless device driver for Linux (wlags49).
4 *
5 * Copyright (c) 1998-2003 Agere Systems Inc.
6 * All rights reserved.
7 * http://www.agere.com
8 *
9 * Initially developed by TriplePoint, Inc.
10 * http://www.triplepoint.com
11 *
12 *------------------------------------------------------------------------------
13 *
14 * This file defines handling routines for the private IOCTLs
15 *
16 *------------------------------------------------------------------------------
17 *
18 * SOFTWARE LICENSE
19 *
20 * This software is provided subject to the following terms and conditions,
21 * which you should read carefully before using the software. Using this
22 * software indicates your acceptance of these terms and conditions. If you do
23 * not agree with these terms and conditions, do not use the software.
24 *
Al Virod36b6912011-12-29 17:09:01 -050025 * Copyright © 2003 Agere Systems Inc.
Henk de Groot68c0bdf2009-09-27 11:12:52 +020026 * All rights reserved.
27 *
28 * Redistribution and use in source or binary forms, with or without
29 * modifications, are permitted provided that the following conditions are met:
30 *
31 * . Redistributions of source code must retain the above copyright notice, this
32 * list of conditions and the following Disclaimer as comments in the code as
33 * well as in the documentation and/or other materials provided with the
34 * distribution.
35 *
36 * . Redistributions in binary form must reproduce the above copyright notice,
37 * this list of conditions and the following Disclaimer in the documentation
38 * and/or other materials provided with the distribution.
39 *
40 * . Neither the name of Agere Systems Inc. nor the names of the contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
43 *
44 * Disclaimer
45 *
Al Virod36b6912011-12-29 17:09:01 -050046 * THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
Henk de Groot68c0bdf2009-09-27 11:12:52 +020047 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
48 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
49 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
50 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
51 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
55 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
56 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
57 * DAMAGE.
58 *
59 ******************************************************************************/
60
Henk de Groot68c0bdf2009-09-27 11:12:52 +020061/*******************************************************************************
62 * include files
63 ******************************************************************************/
64#include <wl_version.h>
65
66#include <linux/if_arp.h>
67#include <linux/ioport.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090068#include <linux/slab.h>
Henk de Groot68c0bdf2009-09-27 11:12:52 +020069#include <linux/delay.h>
Johan Meiringc54a6392012-11-30 18:58:50 +020070#include <linux/uaccess.h>
Henk de Groot68c0bdf2009-09-27 11:12:52 +020071
72#include <debug.h>
73#include <hcf.h>
74#include <hcfdef.h>
75
76#include <wl_if.h>
77#include <wl_internal.h>
78#include <wl_enc.h>
79#include <wl_main.h>
80#include <wl_priv.h>
81#include <wl_util.h>
82#include <wl_netdev.h>
83
Johan Meiringceb121a2012-11-30 18:58:48 +020084int wvlan_uil_connect(struct uilreq *urq, struct wl_private *lp);
85int wvlan_uil_disconnect(struct uilreq *urq, struct wl_private *lp);
86int wvlan_uil_action(struct uilreq *urq, struct wl_private *lp);
87int wvlan_uil_block(struct uilreq *urq, struct wl_private *lp);
88int wvlan_uil_unblock(struct uilreq *urq, struct wl_private *lp);
89int wvlan_uil_send_diag_msg(struct uilreq *urq, struct wl_private *lp);
90int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp);
91int wvlan_uil_get_info(struct uilreq *urq, struct wl_private *lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +020092
Johan Meiringceb121a2012-11-30 18:58:48 +020093int cfg_driver_info(struct uilreq *urq, struct wl_private *lp);
94int cfg_driver_identity(struct uilreq *urq, struct wl_private *lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +020095
96
97/*******************************************************************************
98 * global variables
99 ******************************************************************************/
100#if DBG
101extern dbg_info_t *DbgInfo;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200102#endif /* DBG */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200103
104
105
106
107/* If USE_UIL is not defined, then none of the UIL Interface code below will
108 be included in the build */
109#ifdef USE_UIL
110
111/*******************************************************************************
112 * wvlan_uil()
113 *******************************************************************************
114 *
115 * DESCRIPTION:
116 *
117 * The handler function for the UIL interface.
118 *
119 * PARAMETERS:
120 *
121 * urq - a pointer to the UIL request buffer
122 * lp - a pointer to the device's private adapter structure
123 *
124 * RETURNS:
125 *
126 * 0 on success
127 * errno value otherwise
128 *
129 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +0200130int wvlan_uil(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200131{
132 int ioctl_ret = 0;
133 /*------------------------------------------------------------------------*/
134
Johan Meiringceb121a2012-11-30 18:58:48 +0200135 DBG_FUNC("wvlan_uil");
136 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200137
Johan Meiring0af2d462012-11-30 18:58:49 +0200138 switch (urq->command) {
Johan Meiringac6cf1b2012-11-30 18:58:51 +0200139 case UIL_FUN_CONNECT:
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200140 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_CONNECT\n");
Johan Meiringceb121a2012-11-30 18:58:48 +0200141 ioctl_ret = wvlan_uil_connect(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200142 break;
Johan Meiringac6cf1b2012-11-30 18:58:51 +0200143 case UIL_FUN_DISCONNECT:
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200144 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_DISCONNECT\n");
Johan Meiringceb121a2012-11-30 18:58:48 +0200145 ioctl_ret = wvlan_uil_disconnect(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200146 break;
Johan Meiringac6cf1b2012-11-30 18:58:51 +0200147 case UIL_FUN_ACTION:
Johan Meiringceb121a2012-11-30 18:58:48 +0200148 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_ACTION\n");
149 ioctl_ret = wvlan_uil_action(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200150 break;
Johan Meiringac6cf1b2012-11-30 18:58:51 +0200151 case UIL_FUN_SEND_DIAG_MSG:
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200152 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_SEND_DIAG_MSG\n");
Johan Meiringceb121a2012-11-30 18:58:48 +0200153 ioctl_ret = wvlan_uil_send_diag_msg(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200154 break;
Johan Meiringac6cf1b2012-11-30 18:58:51 +0200155 case UIL_FUN_GET_INFO:
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200156 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_GET_INFO\n");
Johan Meiringceb121a2012-11-30 18:58:48 +0200157 ioctl_ret = wvlan_uil_get_info(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200158 break;
Johan Meiringac6cf1b2012-11-30 18:58:51 +0200159 case UIL_FUN_PUT_INFO:
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200160 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- WVLAN2_UIL_PUT_INFO\n");
Johan Meiringceb121a2012-11-30 18:58:48 +0200161 ioctl_ret = wvlan_uil_put_info(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200162 break;
163 default:
Johan Meiringceb121a2012-11-30 18:58:48 +0200164 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL -- UNSUPPORTED UIL CODE: 0x%X", urq->command);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200165 ioctl_ret = -EOPNOTSUPP;
166 break;
167 }
Johan Meiringceb121a2012-11-30 18:58:48 +0200168 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200169 return ioctl_ret;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200170} /* wvlan_uil */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200171/*============================================================================*/
172
173
174
175
176/*******************************************************************************
177 * wvlan_uil_connect()
178 *******************************************************************************
179 *
180 * DESCRIPTION:
181 *
182 * Connect to the UIL in order to make a request.
183 *
184 * PARAMETERS:
185 *
186 * urq - a pointer to the UIL request buffer
187 * lp - a pointer to the device's private adapter structure
188 *
189 * RETURNS:
190 *
191 * UIL_SUCCESS
192 * UIL_ERR_xxx value otherwise
193 *
194 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +0200195int wvlan_uil_connect(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200196{
197 int result = 0;
198 /*------------------------------------------------------------------------*/
199
200
Johan Meiringceb121a2012-11-30 18:58:48 +0200201 DBG_FUNC("wvlan_uil_connect");
202 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200203
204
Johan Meiring0af2d462012-11-30 18:58:49 +0200205 if (!(lp->flags & WVLAN2_UIL_CONNECTED)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200206 lp->flags |= WVLAN2_UIL_CONNECTED;
Johan Meiringceb121a2012-11-30 18:58:48 +0200207 urq->hcfCtx = &(lp->hcfCtx);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200208 urq->result = UIL_SUCCESS;
209 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200210 DBG_WARNING(DbgInfo, "UIL_ERR_IN_USE\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200211 urq->result = UIL_ERR_IN_USE;
212 }
213
Johan Meiringceb121a2012-11-30 18:58:48 +0200214 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200215 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200216} /* wvlan_uil_connect */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200217/*============================================================================*/
218
219
220
221
222/*******************************************************************************
223 * wvlan_uil_disconnect()
224 *******************************************************************************
225 *
226 * DESCRIPTION:
227 *
Masanari Iidacb154c12012-08-27 23:21:13 +0900228 * Disconnect from the UIL after a request has been completed.
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200229 *
230 * PARAMETERS:
231 *
232 * urq - a pointer to the UIL request buffer
233 * lp - a pointer to the device's private adapter structure
234 *
235 * RETURNS:
236 *
237 * UIL_SUCCESS
238 * UIL_ERR_xxx value otherwise
239 *
240 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +0200241int wvlan_uil_disconnect(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200242{
243 int result = 0;
244 /*------------------------------------------------------------------------*/
245
246
Johan Meiringceb121a2012-11-30 18:58:48 +0200247 DBG_FUNC("wvlan_uil_disconnect");
248 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200249
250
Johan Meiring0af2d462012-11-30 18:58:49 +0200251 if (urq->hcfCtx == &(lp->hcfCtx)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200252 if (lp->flags & WVLAN2_UIL_CONNECTED) {
253 lp->flags &= ~WVLAN2_UIL_CONNECTED;
254 /*
255 if (lp->flags & WVLAN2_UIL_BUSY) {
256 lp->flags &= ~WVLAN2_UIL_BUSY;
257 netif_start_queue(lp->dev);
258 }
259 */
260 }
261
262 urq->hcfCtx = NULL;
263 urq->result = UIL_SUCCESS;
264 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200265 DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200266 urq->result = UIL_ERR_WRONG_IFB;
267 }
268
Johan Meiringceb121a2012-11-30 18:58:48 +0200269 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200270 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200271} /* wvlan_uil_disconnect */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200272/*============================================================================*/
273
274
275
276
277/*******************************************************************************
278 * wvlan_uil_action()
279 *******************************************************************************
280 *
281 * DESCRIPTION:
282 *
283 * Handler for the UIL_ACT_xxx subcodes associated with UIL_FUN_ACTION
284 *
285 * PARAMETERS:
286 *
287 * urq - a pointer to the UIL request buffer
288 * lp - a pointer to the device's private adapter structure
289 *
290 * RETURNS:
291 *
292 * UIL_SUCCESS
293 * UIL_ERR_xxx value otherwise
294 *
295 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +0200296int wvlan_uil_action(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200297{
298 int result = 0;
299 ltv_t *ltv;
300 /*------------------------------------------------------------------------*/
301
302
Johan Meiringceb121a2012-11-30 18:58:48 +0200303 DBG_FUNC("wvlan_uil_action");
304 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200305
306
Johan Meiring0af2d462012-11-30 18:58:49 +0200307 if (urq->hcfCtx == &(lp->hcfCtx)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200308 /* Make sure there's an LTV in the request buffer */
309 ltv = (ltv_t *)urq->data;
Johan Meiring0af2d462012-11-30 18:58:49 +0200310 if (ltv != NULL) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200311 /* Switch on the Type field of the LTV contained in the request
312 buffer */
Johan Meiring0af2d462012-11-30 18:58:49 +0200313 switch (ltv->typ) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200314 case UIL_ACT_BLOCK:
Johan Meiringceb121a2012-11-30 18:58:48 +0200315 DBG_TRACE(DbgInfo, "UIL_ACT_BLOCK\n");
316 result = wvlan_uil_block(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200317 break;
318 case UIL_ACT_UNBLOCK:
Johan Meiringceb121a2012-11-30 18:58:48 +0200319 DBG_TRACE(DbgInfo, "UIL_ACT_UNBLOCK\n");
320 result = wvlan_uil_unblock(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200321 break;
322 case UIL_ACT_SCAN:
Johan Meiringceb121a2012-11-30 18:58:48 +0200323 DBG_TRACE(DbgInfo, "UIL_ACT_SCAN\n");
324 urq->result = hcf_action(&(lp->hcfCtx), MDD_ACT_SCAN);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200325 break;
326 case UIL_ACT_APPLY:
Johan Meiringceb121a2012-11-30 18:58:48 +0200327 DBG_TRACE(DbgInfo, "UIL_ACT_APPLY\n");
328 urq->result = wl_apply(lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200329 break;
330 case UIL_ACT_RESET:
Johan Meiringceb121a2012-11-30 18:58:48 +0200331 DBG_TRACE(DbgInfo, "UIL_ACT_RESET\n");
332 urq->result = wl_go(lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200333 break;
334 default:
Johan Meiringceb121a2012-11-30 18:58:48 +0200335 DBG_WARNING(DbgInfo, "Unknown action code: 0x%x\n", ltv->typ);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200336 break;
337 }
338 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200339 DBG_ERROR(DbgInfo, "Bad LTV for this action\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200340 urq->result = UIL_ERR_LEN;
341 }
342 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200343 DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200344 urq->result = UIL_ERR_WRONG_IFB;
345 }
346
Johan Meiringceb121a2012-11-30 18:58:48 +0200347 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200348 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200349} /* wvlan_uil_action */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200350/*============================================================================*/
351
352
353
354
355/*******************************************************************************
356 * wvlan_uil_block()
357 *******************************************************************************
358 *
359 * DESCRIPTION:
360 *
361 * Sets a block in the driver to prevent access to the card by other
362 * processes.
363 *
364 * PARAMETERS:
365 *
366 * urq - a pointer to the UIL request buffer
367 * lp - a pointer to the device's private adapter structure
368 *
369 * RETURNS:
370 *
371 * UIL_SUCCESS
372 * UIL_ERR_xxx value otherwise
373 *
374 ******************************************************************************/
375
Johan Meiringceb121a2012-11-30 18:58:48 +0200376int wvlan_uil_block(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200377{
378 int result = 0;
379 /*------------------------------------------------------------------------*/
380
381
Johan Meiringceb121a2012-11-30 18:58:48 +0200382 DBG_FUNC("wvlan_uil_block");
383 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200384
Johan Meiring0af2d462012-11-30 18:58:49 +0200385 if (urq->hcfCtx == &(lp->hcfCtx)) {
386 if (capable(CAP_NET_ADMIN)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200387 lp->flags |= WVLAN2_UIL_BUSY;
388 netif_stop_queue(lp->dev);
Johan Meiringceb121a2012-11-30 18:58:48 +0200389 WL_WDS_NETIF_STOP_QUEUE(lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200390 urq->result = UIL_SUCCESS;
391 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200392 DBG_ERROR(DbgInfo, "EPERM\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200393 urq->result = UIL_FAILURE;
394 result = -EPERM;
395 }
396 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200397 DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200398 urq->result = UIL_ERR_WRONG_IFB;
399 }
400
Johan Meiringceb121a2012-11-30 18:58:48 +0200401 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200402 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200403} /* wvlan_uil_block */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200404/*============================================================================*/
405
406
407
408
409/*******************************************************************************
410 * wvlan_uil_unblock()
411 *******************************************************************************
412 *
413 * DESCRIPTION:
414 *
415 * Unblocks the driver to restore access to the card by other processes.
416 *
417 * PARAMETERS:
418 *
419 * urq - a pointer to the UIL request buffer
420 * lp - a pointer to the device's private adapter structure
421 *
422 * RETURNS:
423 *
424 * UIL_SUCCESS
425 * UIL_ERR_xxx value otherwise
426 *
427 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +0200428int wvlan_uil_unblock(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200429{
430 int result = 0;
431 /*------------------------------------------------------------------------*/
432
433
Johan Meiringceb121a2012-11-30 18:58:48 +0200434 DBG_FUNC("wvlan_uil_unblock");
435 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200436
Johan Meiring0af2d462012-11-30 18:58:49 +0200437 if (urq->hcfCtx == &(lp->hcfCtx)) {
438 if (capable(CAP_NET_ADMIN)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200439 if (lp->flags & WVLAN2_UIL_BUSY) {
440 lp->flags &= ~WVLAN2_UIL_BUSY;
441 netif_wake_queue(lp->dev);
Johan Meiringceb121a2012-11-30 18:58:48 +0200442 WL_WDS_NETIF_WAKE_QUEUE(lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200443 }
444 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200445 DBG_ERROR(DbgInfo, "EPERM\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200446 urq->result = UIL_FAILURE;
447 result = -EPERM;
448 }
449 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200450 DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200451 urq->result = UIL_ERR_WRONG_IFB;
452 }
453
Johan Meiringceb121a2012-11-30 18:58:48 +0200454 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200455 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200456} /* wvlan_uil_unblock */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200457/*============================================================================*/
458
459
460
461
462/*******************************************************************************
463 * wvlan_uil_send_diag_msg()
464 *******************************************************************************
465 *
466 * DESCRIPTION:
467 *
468 * Sends a diagnostic message to the card.
469 *
470 * PARAMETERS:
471 *
472 * urq - a pointer to the UIL request buffer
473 * lp - a pointer to the device's private adapter structure
474 *
475 * RETURNS:
476 *
477 * UIL_SUCCESS
478 * UIL_ERR_xxx value otherwise
479 *
480 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +0200481int wvlan_uil_send_diag_msg(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200482{
483 int result = 0;
484 DESC_STRCT Descp[1];
485 /*------------------------------------------------------------------------*/
486
487
Johan Meiringceb121a2012-11-30 18:58:48 +0200488 DBG_FUNC("wvlan_uil_send_diag_msg");
489 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200490
Johan Meiring0af2d462012-11-30 18:58:49 +0200491 if (urq->hcfCtx == &(lp->hcfCtx)) {
492 if (capable(CAP_NET_ADMIN)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200493 if ((urq->data != NULL) && (urq->len != 0)) {
494 if (lp->hcfCtx.IFB_RscInd != 0) {
495 u_char *data;
496
Johan Meiringa52a2e12012-11-30 18:58:54 +0200497 /* Verify the user buffer */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200498 result = verify_area(VERIFY_READ, urq->data, urq->len);
499 if (result != 0) {
Johan Meiringceb121a2012-11-30 18:58:48 +0200500 DBG_ERROR(DbgInfo, "verify_area failed, result: %d\n", result);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200501 urq->result = UIL_FAILURE;
Johan Meiringceb121a2012-11-30 18:58:48 +0200502 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200503 return result;
504 }
505
Joe Perches491dbc82010-03-24 22:17:07 -0700506 data = kmalloc(urq->len, GFP_KERNEL);
507 if (data != NULL) {
Johan Meiringceb121a2012-11-30 18:58:48 +0200508 memset(Descp, 0, sizeof(DESC_STRCT));
509 memcpy(data, urq->data, urq->len);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200510
511 Descp[0].buf_addr = (wci_bufp)data;
512 Descp[0].BUF_CNT = urq->len;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200513 Descp[0].next_desc_addr = 0; /* terminate list */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200514
Johan Meiringceb121a2012-11-30 18:58:48 +0200515 hcf_send_msg(&(lp->hcfCtx), &Descp[0], HCF_PORT_0);
516 kfree(data);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200517 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200518 DBG_ERROR(DbgInfo, "ENOMEM\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200519 urq->result = UIL_FAILURE;
520 result = -ENOMEM;
Johan Meiringceb121a2012-11-30 18:58:48 +0200521 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200522 return result;
523 }
524
525 } else {
526 urq->result = UIL_ERR_BUSY;
527 }
528
529 } else {
530 urq->result = UIL_FAILURE;
531 }
532 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200533 DBG_ERROR(DbgInfo, "EPERM\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200534 urq->result = UIL_FAILURE;
535 result = -EPERM;
536 }
537 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200538 DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200539 urq->result = UIL_ERR_WRONG_IFB;
540 }
541
Johan Meiringceb121a2012-11-30 18:58:48 +0200542 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200543 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200544} /* wvlan_uil_send_diag_msg */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200545/*============================================================================*/
546
547
548/*******************************************************************************
549 * wvlan_uil_put_info()
550 *******************************************************************************
551 *
552 * DESCRIPTION:
553 *
554 * Sends a specific RID directly to the driver to set configuration info.
555 *
556 * PARAMETERS:
557 *
558 * urq - a pointer to the UIL request buffer
559 * lp - a pointer to the device's private adapter structure
560 *
561 * RETURNS:
562 *
563 * UIL_SUCCESS
564 * UIL_ERR_xxx value otherwise
565 *
566 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +0200567int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200568{
569 int result = 0;
570 ltv_t *pLtv;
571 bool_t ltvAllocated = FALSE;
572 ENCSTRCT sEncryption;
573
574#ifdef USE_WDS
575 hcf_16 hcfPort = HCF_PORT_0;
576#endif /* USE_WDS */
577 /*------------------------------------------------------------------------*/
Johan Meiringceb121a2012-11-30 18:58:48 +0200578 DBG_FUNC("wvlan_uil_put_info");
579 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200580
581
Johan Meiring0af2d462012-11-30 18:58:49 +0200582 if (urq->hcfCtx == &(lp->hcfCtx)) {
583 if (capable(CAP_NET_ADMIN)) {
584 if ((urq->data != NULL) && (urq->len != 0)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200585 /* Make sure that we have at least a command and length to send. */
Johan Meiring0af2d462012-11-30 18:58:49 +0200586 if (urq->len < (sizeof(hcf_16) * 2)) {
Johan Meiringceb121a2012-11-30 18:58:48 +0200587 urq->len = sizeof(lp->ltvRecord);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200588 urq->result = UIL_ERR_LEN;
Johan Meiringceb121a2012-11-30 18:58:48 +0200589 DBG_ERROR(DbgInfo, "No Length/Type in LTV!!!\n");
590 DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n");
591 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200592 return result;
593 }
594
595 /* Verify the user buffer */
Johan Meiringceb121a2012-11-30 18:58:48 +0200596 result = verify_area(VERIFY_READ, urq->data, urq->len);
Johan Meiring0af2d462012-11-30 18:58:49 +0200597 if (result != 0) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200598 urq->result = UIL_FAILURE;
Johan Meiringceb121a2012-11-30 18:58:48 +0200599 DBG_ERROR(DbgInfo, "verify_area(), VERIFY_READ FAILED\n");
600 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200601 return result;
602 }
603
604 /* Get only the command and length information. */
Johan Meiringceb121a2012-11-30 18:58:48 +0200605 copy_from_user(&(lp->ltvRecord), urq->data, sizeof(hcf_16) * 2);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200606
607 /* Make sure the incoming LTV record length is within the bounds of the
608 IOCTL length */
Johan Meiring0af2d462012-11-30 18:58:49 +0200609 if (((lp->ltvRecord.len + 1) * sizeof(hcf_16)) > urq->len) {
Johan Meiringceb121a2012-11-30 18:58:48 +0200610 urq->len = sizeof(lp->ltvRecord);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200611 urq->result = UIL_ERR_LEN;
Johan Meiringceb121a2012-11-30 18:58:48 +0200612 DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n");
613 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200614 return result;
615 }
616
617 /* If the requested length is greater than the size of our local
618 LTV record, try to allocate it from the kernel stack.
619 Otherwise, we just use our local LTV record. */
Johan Meiring0af2d462012-11-30 18:58:49 +0200620 if (urq->len > sizeof(lp->ltvRecord)) {
Julia Lawall32414872010-05-11 20:26:57 +0200621 pLtv = kmalloc(urq->len, GFP_KERNEL);
Joe Perches491dbc82010-03-24 22:17:07 -0700622 if (pLtv != NULL) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200623 ltvAllocated = TRUE;
624 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200625 DBG_ERROR(DbgInfo, "Alloc FAILED\n");
626 urq->len = sizeof(lp->ltvRecord);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200627 urq->result = UIL_ERR_LEN;
628 result = -ENOMEM;
Johan Meiringceb121a2012-11-30 18:58:48 +0200629 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200630 return result;
631 }
632 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +0200633 pLtv = &(lp->ltvRecord);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200634 }
635
636 /* Copy the data from the user's buffer into the local LTV
637 record data area. */
Johan Meiringceb121a2012-11-30 18:58:48 +0200638 copy_from_user(pLtv, urq->data, urq->len);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200639
640
641 /* We need to snoop the commands to see if there is anything we
642 need to store for the purposes of a reset or start/stop
643 sequence. Perform endian translation as needed */
Johan Meiring0af2d462012-11-30 18:58:49 +0200644 switch (pLtv->typ) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200645 case CFG_CNF_PORT_TYPE:
646 lp->PortType = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200647 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200648 break;
649 case CFG_CNF_OWN_MAC_ADDR:
650 /* TODO: determine if we are going to store anything based on this */
651 break;
652 case CFG_CNF_OWN_CHANNEL:
653 lp->Channel = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200654 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200655 break;
656 /* CFG_CNF_OWN_SSID currently same as CNF_DESIRED_SSID. Do we
Anand Gadiyar935e99f2010-05-12 13:03:13 +0530657 need separate storage for this? */
Johan Meiringa52a2e12012-11-30 18:58:54 +0200658 /* case CFG_CNF_OWN_SSID: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200659 case CFG_CNF_OWN_ATIM_WINDOW:
660 lp->atimWindow = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200661 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200662 break;
663 case CFG_CNF_SYSTEM_SCALE:
664 lp->DistanceBetweenAPs = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200665 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200666
667 case CFG_CNF_MAX_DATA_LEN:
668 /* TODO: determine if we are going to store anything based
669 on this */
670 break;
671 case CFG_CNF_PM_ENABLED:
672 lp->PMEnabled = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200673 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200674 break;
675 case CFG_CNF_MCAST_RX:
676 lp->MulticastReceive = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200677 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200678 break;
679 case CFG_CNF_MAX_SLEEP_DURATION:
680 lp->MaxSleepDuration = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200681 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200682 break;
683 case CFG_CNF_HOLDOVER_DURATION:
684 lp->holdoverDuration = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200685 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200686 break;
687 case CFG_CNF_OWN_NAME:
Johan Meiringceb121a2012-11-30 18:58:48 +0200688 memset(lp->StationName, 0, sizeof(lp->StationName));
689 memcpy((void *)lp->StationName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
690 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200691 break;
692 case CFG_CNF_LOAD_BALANCING:
693 lp->loadBalancing = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200694 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200695 break;
696 case CFG_CNF_MEDIUM_DISTRIBUTION:
697 lp->mediumDistribution = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200698 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200699 break;
700#ifdef WARP
701 case CFG_CNF_TX_POW_LVL:
702 lp->txPowLevel = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200703 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200704 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200705 /* case CFG_CNF_SHORT_RETRY_LIMIT: */ /* Short Retry Limit */
706 /* case 0xFC33: */ /* Long Retry Limit */
707 case CFG_SUPPORTED_RATE_SET_CNTL: /* Supported Rate Set Control */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200708 lp->srsc[0] = pLtv->u.u16[0];
709 lp->srsc[1] = pLtv->u.u16[1];
Johan Meiringceb121a2012-11-30 18:58:48 +0200710 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
711 pLtv->u.u16[1] = CNV_INT_TO_LITTLE(pLtv->u.u16[1]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200712 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200713 case CFG_BASIC_RATE_SET_CNTL: /* Basic Rate Set Control */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200714 lp->brsc[0] = pLtv->u.u16[0];
715 lp->brsc[1] = pLtv->u.u16[1];
Johan Meiringceb121a2012-11-30 18:58:48 +0200716 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
717 pLtv->u.u16[1] = CNV_INT_TO_LITTLE(pLtv->u.u16[1]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200718 break;
719 case CFG_CNF_CONNECTION_CNTL:
720 lp->connectionControl = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200721 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200722 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200723 /* case CFG_PROBE_DATA_RATE: */
724#endif /* HERMES25 */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200725
Johan Meiringa52a2e12012-11-30 18:58:54 +0200726#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */
727 /* ;?should we restore this to allow smaller memory footprint */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200728
729 case CFG_CNF_OWN_DTIM_PERIOD:
730 lp->DTIMPeriod = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200731 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200732 break;
733#ifdef WARP
Johan Meiringa52a2e12012-11-30 18:58:54 +0200734 case CFG_CNF_OWN_BEACON_INTERVAL: /* Own Beacon Interval */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200735 lp->ownBeaconInterval = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200736 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200737 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200738#endif /* WARP */
739 case CFG_COEXISTENSE_BEHAVIOUR: /* Coexistence behavior */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200740 lp->coexistence = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200741 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200742 break;
743#ifdef USE_WDS
744 case CFG_CNF_WDS_ADDR1:
Johan Meiringceb121a2012-11-30 18:58:48 +0200745 memcpy(&lp->wds_port[0].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200746 hcfPort = HCF_PORT_1;
747 break;
748 case CFG_CNF_WDS_ADDR2:
Johan Meiringceb121a2012-11-30 18:58:48 +0200749 memcpy(&lp->wds_port[1].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200750 hcfPort = HCF_PORT_2;
751 break;
752 case CFG_CNF_WDS_ADDR3:
Johan Meiringceb121a2012-11-30 18:58:48 +0200753 memcpy(&lp->wds_port[2].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200754 hcfPort = HCF_PORT_3;
755 break;
756 case CFG_CNF_WDS_ADDR4:
Johan Meiringceb121a2012-11-30 18:58:48 +0200757 memcpy(&lp->wds_port[3].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200758 hcfPort = HCF_PORT_4;
759 break;
760 case CFG_CNF_WDS_ADDR5:
Johan Meiringceb121a2012-11-30 18:58:48 +0200761 memcpy(&lp->wds_port[4].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200762 hcfPort = HCF_PORT_5;
763 break;
764 case CFG_CNF_WDS_ADDR6:
Johan Meiringceb121a2012-11-30 18:58:48 +0200765 memcpy(&lp->wds_port[5].wdsAddress, &pLtv->u.u8[0], ETH_ALEN);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200766 hcfPort = HCF_PORT_6;
767 break;
768#endif /* USE_WDS */
769
770 case CFG_CNF_MCAST_PM_BUF:
771 lp->multicastPMBuffering = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200772 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200773 break;
774 case CFG_CNF_REJECT_ANY:
775 lp->RejectAny = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200776 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200777 break;
778#endif
779
780 case CFG_CNF_ENCRYPTION:
781 lp->EnableEncryption = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200782 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200783 break;
784 case CFG_CNF_AUTHENTICATION:
785 lp->authentication = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200786 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200787 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200788#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */
789 /* ;?should we restore this to allow smaller memory footprint */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200790
Johan Meiringa52a2e12012-11-30 18:58:54 +0200791 /* case CFG_CNF_EXCL_UNENCRYPTED:
792 lp->ExcludeUnencrypted = pLtv->u.u16[0];
793 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
794 break; */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200795 case CFG_CNF_MCAST_RATE:
796 /* TODO: determine if we are going to store anything based on this */
797 break;
798 case CFG_CNF_INTRA_BSS_RELAY:
799 lp->intraBSSRelay = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200800 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200801 break;
802#endif
803
804 case CFG_CNF_MICRO_WAVE:
805 /* TODO: determine if we are going to store anything based on this */
806 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200807 /*case CFG_CNF_LOAD_BALANCING:*/
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200808 /* TODO: determine if we are going to store anything based on this */
Johan Meiringa52a2e12012-11-30 18:58:54 +0200809 /* break; */
810 /* case CFG_CNF_MEDIUM_DISTRIBUTION: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200811 /* TODO: determine if we are going to store anything based on this */
Johan Meiringa52a2e12012-11-30 18:58:54 +0200812 /* break; */
813 /* case CFG_CNF_RX_ALL_GROUP_ADDRESS: */
814 /* TODO: determine if we are going to store anything based on this */
815 /* break; */
816 /* case CFG_CNF_COUNTRY_INFO: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200817 /* TODO: determine if we are going to store anything based on this */
Johan Meiringa52a2e12012-11-30 18:58:54 +0200818 /* break; */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200819 case CFG_CNF_OWN_SSID:
Johan Meiringa52a2e12012-11-30 18:58:54 +0200820 /* case CNF_DESIRED_SSID: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200821 case CFG_DESIRED_SSID:
Johan Meiringceb121a2012-11-30 18:58:48 +0200822 memset(lp->NetworkName, 0, sizeof(lp->NetworkName));
823 memcpy((void *)lp->NetworkName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
824 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200825
826 /* take care of the special network name "ANY" case */
Johan Meiring0af2d462012-11-30 18:58:49 +0200827 if ((strlen(&pLtv->u.u8[2]) == 0) ||
Johan Meiringceb121a2012-11-30 18:58:48 +0200828 (strcmp(&pLtv->u.u8[2], "ANY") == 0) ||
829 (strcmp(&pLtv->u.u8[2], "any") == 0)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200830 /* set the SSID_STRCT llen field (u16[0]) to zero, and the
831 effectually null the string u8[2] */
832 pLtv->u.u16[0] = 0;
833 pLtv->u.u8[2] = 0;
834 }
835 break;
836 case CFG_GROUP_ADDR:
837 /* TODO: determine if we are going to store anything based on this */
838 break;
839 case CFG_CREATE_IBSS:
840 lp->CreateIBSS = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200841 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200842 break;
843 case CFG_RTS_THRH:
844 lp->RTSThreshold = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200845 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200846 break;
847 case CFG_TX_RATE_CNTL:
848 lp->TxRateControl[0] = pLtv->u.u16[0];
849 lp->TxRateControl[1] = pLtv->u.u16[1];
Johan Meiringceb121a2012-11-30 18:58:48 +0200850 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
851 pLtv->u.u16[1] = CNV_INT_TO_LITTLE(pLtv->u.u16[1]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200852 break;
853 case CFG_PROMISCUOUS_MODE:
854 /* TODO: determine if we are going to store anything based on this */
855 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +0200856 /* case CFG_WAKE_ON_LAN: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200857 /* TODO: determine if we are going to store anything based on this */
Johan Meiringa52a2e12012-11-30 18:58:54 +0200858 /* break; */
859#if 1 /* ;? #if (HCF_TYPE) & HCF_TYPE_AP */
860 /* ;?should we restore this to allow smaller memory footprint */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200861 case CFG_RTS_THRH0:
862 lp->RTSThreshold = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200863 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200864 break;
865 case CFG_TX_RATE_CNTL0:
Johan Meiringa52a2e12012-11-30 18:58:54 +0200866/*;?no idea what this should be, get going so comment it out lp->TxRateControl = pLtv->u.u16[0];*/
Johan Meiringceb121a2012-11-30 18:58:48 +0200867 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200868 break;
869#ifdef USE_WDS
870 case CFG_RTS_THRH1:
871 lp->wds_port[0].rtsThreshold = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200872 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200873 hcfPort = HCF_PORT_1;
874 break;
875 case CFG_RTS_THRH2:
876 lp->wds_port[1].rtsThreshold = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200877 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200878 hcfPort = HCF_PORT_2;
879 break;
880 case CFG_RTS_THRH3:
881 lp->wds_port[2].rtsThreshold = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200882 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200883 hcfPort = HCF_PORT_3;
884 break;
885 case CFG_RTS_THRH4:
886 lp->wds_port[3].rtsThreshold = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200887 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200888 hcfPort = HCF_PORT_4;
889 break;
890 case CFG_RTS_THRH5:
891 lp->wds_port[4].rtsThreshold = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200892 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200893 hcfPort = HCF_PORT_5;
894 break;
895 case CFG_RTS_THRH6:
896 lp->wds_port[5].rtsThreshold = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200897 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200898 hcfPort = HCF_PORT_6;
899 break;
900 case CFG_TX_RATE_CNTL1:
901 lp->wds_port[0].txRateCntl = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200902 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200903 hcfPort = HCF_PORT_1;
904 break;
905 case CFG_TX_RATE_CNTL2:
906 lp->wds_port[1].txRateCntl = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200907 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200908 hcfPort = HCF_PORT_2;
909 break;
910 case CFG_TX_RATE_CNTL3:
911 lp->wds_port[2].txRateCntl = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200912 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200913 hcfPort = HCF_PORT_3;
914 break;
915 case CFG_TX_RATE_CNTL4:
916 lp->wds_port[3].txRateCntl = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200917 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200918 hcfPort = HCF_PORT_4;
919 break;
920 case CFG_TX_RATE_CNTL5:
921 lp->wds_port[4].txRateCntl = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200922 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200923 hcfPort = HCF_PORT_5;
924 break;
925 case CFG_TX_RATE_CNTL6:
926 lp->wds_port[5].txRateCntl = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200927 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200928 hcfPort = HCF_PORT_6;
929 break;
930#endif /* USE_WDS */
931#endif /* (HCF_TYPE) & HCF_TYPE_AP */
932
933 case CFG_DEFAULT_KEYS:
934 {
935 CFG_DEFAULT_KEYS_STRCT *pKeys = (CFG_DEFAULT_KEYS_STRCT *)pLtv;
936
Johan Meiringceb121a2012-11-30 18:58:48 +0200937 pKeys->key[0].len = CNV_INT_TO_LITTLE(pKeys->key[0].len);
938 pKeys->key[1].len = CNV_INT_TO_LITTLE(pKeys->key[1].len);
939 pKeys->key[2].len = CNV_INT_TO_LITTLE(pKeys->key[2].len);
940 pKeys->key[3].len = CNV_INT_TO_LITTLE(pKeys->key[3].len);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200941
Johan Meiringceb121a2012-11-30 18:58:48 +0200942 memcpy((void *)&(lp->DefaultKeys), (void *)pKeys,
943 sizeof(CFG_DEFAULT_KEYS_STRCT));
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200944 }
945 break;
946 case CFG_TX_KEY_ID:
947 lp->TransmitKeyID = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +0200948 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200949 break;
950 case CFG_SCAN_SSID:
951 /* TODO: determine if we are going to store anything based on this */
952 break;
953 case CFG_TICK_TIME:
954 /* TODO: determine if we are going to store anything based on this */
955 break;
956 /* these RIDS are Info RIDs, and should they be allowed for puts??? */
957 case CFG_MAX_LOAD_TIME:
958 case CFG_DL_BUF:
Johan Meiringa52a2e12012-11-30 18:58:54 +0200959 /* case CFG_HSI_SUP_RANGE: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200960 case CFG_NIC_SERIAL_NUMBER:
961 case CFG_NIC_IDENTITY:
962 case CFG_NIC_MFI_SUP_RANGE:
963 case CFG_NIC_CFI_SUP_RANGE:
964 case CFG_NIC_TEMP_TYPE:
965 case CFG_NIC_PROFILE:
966 case CFG_FW_IDENTITY:
967 case CFG_FW_SUP_RANGE:
968 case CFG_MFI_ACT_RANGES_STA:
969 case CFG_CFI_ACT_RANGES_STA:
970 case CFG_PORT_STAT:
971 case CFG_CUR_SSID:
972 case CFG_CUR_BSSID:
973 case CFG_COMMS_QUALITY:
974 case CFG_CUR_TX_RATE:
975 case CFG_CUR_BEACON_INTERVAL:
976 case CFG_CUR_SCALE_THRH:
977 case CFG_PROTOCOL_RSP_TIME:
978 case CFG_CUR_SHORT_RETRY_LIMIT:
979 case CFG_CUR_LONG_RETRY_LIMIT:
980 case CFG_MAX_TX_LIFETIME:
981 case CFG_MAX_RX_LIFETIME:
982 case CFG_CF_POLLABLE:
983 case CFG_AUTHENTICATION_ALGORITHMS:
984 case CFG_PRIVACY_OPT_IMPLEMENTED:
Johan Meiringa52a2e12012-11-30 18:58:54 +0200985 /* case CFG_CURRENT_REMOTE_RATES: */
986 /* case CFG_CURRENT_USED_RATES: */
987 /* case CFG_CURRENT_SYSTEM_SCALE: */
988 /* case CFG_CURRENT_TX_RATE1: */
989 /* case CFG_CURRENT_TX_RATE2: */
990 /* case CFG_CURRENT_TX_RATE3: */
991 /* case CFG_CURRENT_TX_RATE4: */
992 /* case CFG_CURRENT_TX_RATE5: */
993 /* case CFG_CURRENT_TX_RATE6: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200994 case CFG_NIC_MAC_ADDR:
995 case CFG_PCF_INFO:
Johan Meiringa52a2e12012-11-30 18:58:54 +0200996 /* case CFG_CURRENT_COUNTRY_INFO: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +0200997 case CFG_PHY_TYPE:
998 case CFG_CUR_CHANNEL:
Johan Meiringa52a2e12012-11-30 18:58:54 +0200999 /* case CFG_CURRENT_POWER_STATE: */
1000 /* case CFG_CCAMODE: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001001 case CFG_SUPPORTED_DATA_RATES:
1002 break;
1003 case CFG_AP_MODE:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001004/*;? lp->DownloadFirmware = (pLtv->u.u16[0]) + 1; */
Johan Meiringceb121a2012-11-30 18:58:48 +02001005 DBG_ERROR(DbgInfo, "set CFG_AP_MODE no longer supported\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001006 break;
1007 case CFG_ENCRYPT_STRING:
1008 /* TODO: ENDIAN TRANSLATION HERE??? */
Johan Meiringceb121a2012-11-30 18:58:48 +02001009 memset(lp->szEncryption, 0, sizeof(lp->szEncryption));
1010 memcpy((void *)lp->szEncryption, (void *)&pLtv->u.u8[0],
1011 (pLtv->len * sizeof(hcf_16)));
1012 wl_wep_decode(CRYPT_CODE, &sEncryption,
1013 lp->szEncryption);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001014
1015 /* the Linux driver likes to use 1-4 for the key IDs, and then
1016 convert to 0-3 when sending to the card. The Windows code
1017 base used 0-3 in the API DLL, which was ported to Linux. For
1018 the sake of the user experience, we decided to keep 0-3 as the
1019 numbers used in the DLL; and will perform the +1 conversion here.
1020 We could have converted the entire Linux driver, but this is
1021 less obtrusive. This may be a "todo" to convert the whole driver */
1022 lp->TransmitKeyID = sEncryption.wTxKeyID + 1;
1023 lp->EnableEncryption = sEncryption.wEnabled;
1024
Johan Meiringceb121a2012-11-30 18:58:48 +02001025 memcpy(&lp->DefaultKeys, &sEncryption.EncStr,
1026 sizeof(CFG_DEFAULT_KEYS_STRCT));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001027 break;
1028 /*case CFG_COUNTRY_STRING:
Johan Meiringceb121a2012-11-30 18:58:48 +02001029 memset(lp->countryString, 0, sizeof(lp->countryString));
1030 memcpy((void *)lp->countryString, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001031 break;
1032 */
1033
1034 case CFG_DRIVER_ENABLE:
1035 lp->driverEnable = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +02001036 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001037 break;
1038 case CFG_WOLAS_ENABLE:
1039 lp->wolasEnable = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +02001040 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001041 break;
1042 case CFG_SET_WPA_AUTH_KEY_MGMT_SUITE:
1043 lp->AuthKeyMgmtSuite = pLtv->u.u16[0];
Johan Meiringceb121a2012-11-30 18:58:48 +02001044 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001045 break;
1046 case CFG_DISASSOCIATE_ADDR:
Johan Meiringceb121a2012-11-30 18:58:48 +02001047 pLtv->u.u16[ETH_ALEN / 2] = CNV_INT_TO_LITTLE(pLtv->u.u16[ETH_ALEN / 2]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001048 break;
1049 case CFG_ADD_TKIP_DEFAULT_KEY:
1050 case CFG_REMOVE_TKIP_DEFAULT_KEY:
1051 /* Endian convert the Tx Key Information */
Johan Meiringceb121a2012-11-30 18:58:48 +02001052 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001053 break;
1054 case CFG_ADD_TKIP_MAPPED_KEY:
1055 break;
1056 case CFG_REMOVE_TKIP_MAPPED_KEY:
1057 break;
1058 /* some RIDs just can't be put */
1059 case CFG_MB_INFO:
1060 case CFG_IFB:
1061 default:
1062 break;
1063 }
1064
1065 /* This code will prevent Static Configuration Entities from
1066 being sent to the card, as they require a call to
1067 UIL_ACT_APPLY to take effect. Dynamic Entities will be sent
1068 immediately */
Johan Meiring0af2d462012-11-30 18:58:49 +02001069 switch (pLtv->typ) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001070 case CFG_CNF_PORT_TYPE:
1071 case CFG_CNF_OWN_MAC_ADDR:
1072 case CFG_CNF_OWN_CHANNEL:
1073 case CFG_CNF_OWN_SSID:
1074 case CFG_CNF_OWN_ATIM_WINDOW:
1075 case CFG_CNF_SYSTEM_SCALE:
1076 case CFG_CNF_MAX_DATA_LEN:
1077 case CFG_CNF_PM_ENABLED:
1078 case CFG_CNF_MCAST_RX:
1079 case CFG_CNF_MAX_SLEEP_DURATION:
1080 case CFG_CNF_HOLDOVER_DURATION:
1081 case CFG_CNF_OWN_NAME:
1082 case CFG_CNF_LOAD_BALANCING:
1083 case CFG_CNF_MEDIUM_DISTRIBUTION:
1084#ifdef WARP
1085 case CFG_CNF_TX_POW_LVL:
1086 case CFG_CNF_CONNECTION_CNTL:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001087 /*case CFG_PROBE_DATA_RATE: */
1088#endif /* HERMES25 */
1089#if 1 /*;? (HCF_TYPE) & HCF_TYPE_AP */
1090 /*;?should we restore this to allow smaller memory footprint */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001091 case CFG_CNF_OWN_DTIM_PERIOD:
1092#ifdef WARP
Johan Meiringa52a2e12012-11-30 18:58:54 +02001093 case CFG_CNF_OWN_BEACON_INTERVAL: /* Own Beacon Interval */
1094#endif /* WARP */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001095#ifdef USE_WDS
1096 case CFG_CNF_WDS_ADDR1:
1097 case CFG_CNF_WDS_ADDR2:
1098 case CFG_CNF_WDS_ADDR3:
1099 case CFG_CNF_WDS_ADDR4:
1100 case CFG_CNF_WDS_ADDR5:
1101 case CFG_CNF_WDS_ADDR6:
1102#endif
1103 case CFG_CNF_MCAST_PM_BUF:
1104 case CFG_CNF_REJECT_ANY:
1105#endif
1106
1107 case CFG_CNF_ENCRYPTION:
1108 case CFG_CNF_AUTHENTICATION:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001109#if 1 /* ;? (HCF_TYPE) & HCF_TYPE_AP */
1110 /* ;?should we restore this to allow smaller memory footprint */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001111
1112 case CFG_CNF_EXCL_UNENCRYPTED:
1113 case CFG_CNF_MCAST_RATE:
1114 case CFG_CNF_INTRA_BSS_RELAY:
1115#endif
1116
1117 case CFG_CNF_MICRO_WAVE:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001118 /* case CFG_CNF_LOAD_BALANCING: */
1119 /* case CFG_CNF_MEDIUM_DISTRIBUTION: */
1120 /* case CFG_CNF_RX_ALL_GROUP_ADDRESS: */
1121 /* case CFG_CNF_COUNTRY_INFO: */
1122 /* case CFG_COUNTRY_STRING: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001123 case CFG_AP_MODE:
1124 case CFG_ENCRYPT_STRING:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001125 /* case CFG_DRIVER_ENABLE: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001126 case CFG_WOLAS_ENABLE:
1127 case CFG_MB_INFO:
1128 case CFG_IFB:
1129 break;
1130 /* Deal with this dynamic MSF RID, as it's required for WPA */
1131 case CFG_DRIVER_ENABLE:
Johan Meiring0af2d462012-11-30 18:58:49 +02001132 if (lp->driverEnable) {
Johan Meiringceb121a2012-11-30 18:58:48 +02001133 hcf_cntl(&(lp->hcfCtx), HCF_CNTL_ENABLE | HCF_PORT_0);
1134 hcf_cntl(&(lp->hcfCtx), HCF_CNTL_CONNECT);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001135 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +02001136 hcf_cntl(&(lp->hcfCtx), HCF_CNTL_DISABLE | HCF_PORT_0);
1137 hcf_cntl(&(lp->hcfCtx), HCF_CNTL_DISCONNECT);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001138 }
1139 break;
1140 default:
Johan Meiringfdd9e862012-11-30 18:58:53 +02001141 wl_act_int_off(lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001142 urq->result = hcf_put_info(&(lp->hcfCtx), (LTVP) pLtv);
Johan Meiringfdd9e862012-11-30 18:58:53 +02001143 wl_act_int_on(lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001144 break;
1145 }
1146
Johan Meiring7f622482012-11-30 18:58:52 +02001147 if (ltvAllocated)
Johan Meiringceb121a2012-11-30 18:58:48 +02001148 kfree(pLtv);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001149 } else {
1150 urq->result = UIL_FAILURE;
1151 }
1152 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +02001153 DBG_ERROR(DbgInfo, "EPERM\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001154 urq->result = UIL_FAILURE;
1155 result = -EPERM;
1156 }
1157 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +02001158 DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001159 urq->result = UIL_ERR_WRONG_IFB;
1160 }
1161
Johan Meiringceb121a2012-11-30 18:58:48 +02001162 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001163 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001164} /* wvlan_uil_put_info */
1165
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001166/*============================================================================*/
1167
1168/*******************************************************************************
1169 * wvlan_uil_get_info()
1170 *******************************************************************************
1171 *
1172 * DESCRIPTION:
1173 *
1174 * Sends a specific RID directly to the driver to retrieve configuration
1175 * info.
1176 *
1177 * PARAMETERS:
1178 *
1179 * urq - a pointer to the UIL request buffer
1180 * lp - a pointer to the device's private adapter structure
1181 *
1182 * RETURNS:
1183 *
1184 * UIL_SUCCESS
1185 * UIL_ERR_xxx value otherwise
1186 *
1187 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +02001188int wvlan_uil_get_info(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001189{
1190 int result = 0;
1191 int i;
1192 /*------------------------------------------------------------------------*/
1193
Johan Meiringceb121a2012-11-30 18:58:48 +02001194 DBG_FUNC("wvlan_uil_get_info");
1195 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001196
Johan Meiring0af2d462012-11-30 18:58:49 +02001197 if (urq->hcfCtx == &(lp->hcfCtx)) {
1198 if ((urq->data != NULL) && (urq->len != 0)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001199 ltv_t *pLtv;
1200 bool_t ltvAllocated = FALSE;
1201
1202 /* Make sure that we have at least a command and length */
Johan Meiring0af2d462012-11-30 18:58:49 +02001203 if (urq->len < (sizeof(hcf_16) * 2)) {
Johan Meiringceb121a2012-11-30 18:58:48 +02001204 urq->len = sizeof(lp->ltvRecord);
1205 DBG_ERROR(DbgInfo, "No Length/Type in LTV!!!\n");
1206 DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001207 urq->result = UIL_ERR_LEN;
Johan Meiringceb121a2012-11-30 18:58:48 +02001208 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001209 return result;
1210 }
1211
1212 /* Verify the user's LTV record header. */
Johan Meiringceb121a2012-11-30 18:58:48 +02001213 result = verify_area(VERIFY_READ, urq->data, sizeof(hcf_16) * 2);
Johan Meiring0af2d462012-11-30 18:58:49 +02001214 if (result != 0) {
Johan Meiringceb121a2012-11-30 18:58:48 +02001215 DBG_ERROR(DbgInfo, "verify_area(), VERIFY_READ FAILED\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001216 urq->result = UIL_FAILURE;
Johan Meiringceb121a2012-11-30 18:58:48 +02001217 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001218 return result;
1219 }
1220
1221 /* Get only the command and length information. */
Johan Meiringceb121a2012-11-30 18:58:48 +02001222 result = copy_from_user(&(lp->ltvRecord), urq->data, sizeof(hcf_16) * 2);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001223
1224 /* Make sure the incoming LTV record length is within the bounds of
1225 the IOCTL length. */
Johan Meiring0af2d462012-11-30 18:58:49 +02001226 if (((lp->ltvRecord.len + 1) * sizeof(hcf_16)) > urq->len) {
Johan Meiringceb121a2012-11-30 18:58:48 +02001227 DBG_ERROR(DbgInfo, "Incoming LTV too big\n");
1228 urq->len = sizeof(lp->ltvRecord);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001229 urq->result = UIL_ERR_LEN;
Johan Meiringceb121a2012-11-30 18:58:48 +02001230 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001231 return result;
1232 }
1233
1234 /* Determine if hcf_get_info() is needed or not */
Johan Meiringceb121a2012-11-30 18:58:48 +02001235 switch (lp->ltvRecord.typ) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001236 case CFG_NIC_IDENTITY:
Johan Meiringceb121a2012-11-30 18:58:48 +02001237 memcpy(&lp->ltvRecord.u.u8[0], &lp->NICIdentity, sizeof(lp->NICIdentity));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001238 break;
1239 case CFG_PRI_IDENTITY:
Johan Meiringceb121a2012-11-30 18:58:48 +02001240 memcpy(&lp->ltvRecord.u.u8[0], &lp->PrimaryIdentity, sizeof(lp->PrimaryIdentity));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001241 break;
1242 case CFG_AP_MODE:
Johan Meiringceb121a2012-11-30 18:58:48 +02001243 DBG_ERROR(DbgInfo, "set CFG_AP_MODE no longer supported, so is get useful ????\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001244 lp->ltvRecord.u.u16[0] =
Johan Meiringceb121a2012-11-30 18:58:48 +02001245 CNV_INT_TO_LITTLE(lp->hcfCtx.IFB_FWIdentity.comp_id) == COMP_ID_FW_AP;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001246 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001247 /* case CFG_DRV_INFO: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001248 case CFG_ENCRYPT_STRING:
1249 case CFG_COUNTRY_STRING:
1250 case CFG_DRIVER_ENABLE:
1251 case CFG_WOLAS_ENABLE:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001252 /* TODO: determine if we're going to support these */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001253 urq->result = UIL_FAILURE;
1254 break;
1255 case CFG_DRV_INFO:
Johan Meiringceb121a2012-11-30 18:58:48 +02001256 DBG_TRACE(DbgInfo, "Intercept CFG_DRV_INFO\n");
1257 result = cfg_driver_info(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001258 break;
1259 case CFG_DRV_IDENTITY:
Johan Meiringceb121a2012-11-30 18:58:48 +02001260 DBG_TRACE(DbgInfo, "Intercept CFG_DRV_IDENTITY\n");
1261 result = cfg_driver_identity(urq, lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001262 break;
1263 case CFG_IFB:
1264 /* IFB can be a security hole */
Johan Meiring0af2d462012-11-30 18:58:49 +02001265 if (!capable(CAP_NET_ADMIN)) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001266 result = -EPERM;
1267 break;
1268 }
1269
1270 /* Else fall through to the default */
1271
Johan Meiringa52a2e12012-11-30 18:58:54 +02001272 case CFG_FW_IDENTITY: /* For Hermes-1, this is cached */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001273 default:
1274
1275 /* Verify the user buffer */
Johan Meiringceb121a2012-11-30 18:58:48 +02001276 result = verify_area(VERIFY_WRITE, urq->data, urq->len);
Johan Meiring0af2d462012-11-30 18:58:49 +02001277 if (result != 0) {
Johan Meiringceb121a2012-11-30 18:58:48 +02001278 DBG_ERROR(DbgInfo, "verify_area(), VERIFY_WRITE FAILED\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001279 urq->result = UIL_FAILURE;
1280 break;
1281 }
1282
1283 /* If the requested length is greater than the size of our local
1284 LTV record, try to allocate it from the kernel stack.
1285 Otherwise, we just use our local LTV record. */
Johan Meiring0af2d462012-11-30 18:58:49 +02001286 if (urq->len > sizeof(lp->ltvRecord)) {
Julia Lawall32414872010-05-11 20:26:57 +02001287 pLtv = kmalloc(urq->len, GFP_KERNEL);
Joe Perches491dbc82010-03-24 22:17:07 -07001288 if (pLtv != NULL) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001289 ltvAllocated = TRUE;
1290
1291 /* Copy the command/length information into the new buffer. */
Johan Meiringceb121a2012-11-30 18:58:48 +02001292 memcpy(pLtv, &(lp->ltvRecord), sizeof(hcf_16) * 2);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001293 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +02001294 urq->len = sizeof(lp->ltvRecord);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001295 urq->result = UIL_ERR_LEN;
Johan Meiringceb121a2012-11-30 18:58:48 +02001296 DBG_ERROR(DbgInfo, "kmalloc FAILED\n");
1297 DBG_ERROR(DbgInfo, "UIL_ERR_LEN\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001298 result = -ENOMEM;
1299 break;
1300 }
1301 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +02001302 pLtv = &(lp->ltvRecord);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001303 }
1304
Johan Meiringfdd9e862012-11-30 18:58:53 +02001305 wl_act_int_off(lp);
Johan Meiringceb121a2012-11-30 18:58:48 +02001306 urq->result = hcf_get_info(&(lp->hcfCtx), (LTVP) pLtv);
Johan Meiringfdd9e862012-11-30 18:58:53 +02001307 wl_act_int_on(lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001308
Johan Meiringa52a2e12012-11-30 18:58:54 +02001309 /* Copy the LTV into the user's buffer. */
1310 /*copy_to_user(urq->data, pLtv, urq->len); */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001311
Johan Meiringa52a2e12012-11-30 18:58:54 +02001312 /*if(ltvAllocated)
1313 {
1314 kfree(pLtv);
1315 }*/
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001316
Johan Meiringa52a2e12012-11-30 18:58:54 +02001317 /* urq->result = UIL_SUCCESS; */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001318 break;
1319 }
1320
1321 /* Handle endian conversion of special fields */
Johan Meiring0af2d462012-11-30 18:58:49 +02001322 switch (lp->ltvRecord.typ) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001323 /* simple int gets just need the first hcf_16 byte flipped */
1324 case CFG_CNF_PORT_TYPE:
1325 case CFG_CNF_OWN_CHANNEL:
1326 case CFG_CNF_OWN_ATIM_WINDOW:
1327 case CFG_CNF_SYSTEM_SCALE:
1328 case CFG_CNF_MAX_DATA_LEN:
1329 case CFG_CNF_PM_ENABLED:
1330 case CFG_CNF_MCAST_RX:
1331 case CFG_CNF_MAX_SLEEP_DURATION:
1332 case CFG_CNF_HOLDOVER_DURATION:
1333 case CFG_CNF_OWN_DTIM_PERIOD:
1334 case CFG_CNF_MCAST_PM_BUF:
1335 case CFG_CNF_REJECT_ANY:
1336 case CFG_CNF_ENCRYPTION:
1337 case CFG_CNF_AUTHENTICATION:
1338 case CFG_CNF_EXCL_UNENCRYPTED:
1339 case CFG_CNF_INTRA_BSS_RELAY:
1340 case CFG_CNF_MICRO_WAVE:
1341 case CFG_CNF_LOAD_BALANCING:
1342 case CFG_CNF_MEDIUM_DISTRIBUTION:
1343#ifdef WARP
1344 case CFG_CNF_TX_POW_LVL:
1345 case CFG_CNF_CONNECTION_CNTL:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001346 case CFG_CNF_OWN_BEACON_INTERVAL: /* Own Beacon Interval */
1347 case CFG_COEXISTENSE_BEHAVIOUR: /* Coexistence Behavior */
1348 /*case CFG_CNF_RX_ALL_GROUP_ADDRESS: */
1349#endif /* HERMES25 */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001350 case CFG_CREATE_IBSS:
1351 case CFG_RTS_THRH:
1352 case CFG_PROMISCUOUS_MODE:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001353 /*case CFG_WAKE_ON_LAN: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001354 case CFG_RTS_THRH0:
1355 case CFG_RTS_THRH1:
1356 case CFG_RTS_THRH2:
1357 case CFG_RTS_THRH3:
1358 case CFG_RTS_THRH4:
1359 case CFG_RTS_THRH5:
1360 case CFG_RTS_THRH6:
1361 case CFG_TX_RATE_CNTL0:
1362 case CFG_TX_RATE_CNTL1:
1363 case CFG_TX_RATE_CNTL2:
1364 case CFG_TX_RATE_CNTL3:
1365 case CFG_TX_RATE_CNTL4:
1366 case CFG_TX_RATE_CNTL5:
1367 case CFG_TX_RATE_CNTL6:
1368 case CFG_TX_KEY_ID:
1369 case CFG_TICK_TIME:
1370 case CFG_MAX_LOAD_TIME:
1371 case CFG_NIC_TEMP_TYPE:
1372 case CFG_PORT_STAT:
1373 case CFG_CUR_TX_RATE:
1374 case CFG_CUR_BEACON_INTERVAL:
1375 case CFG_PROTOCOL_RSP_TIME:
1376 case CFG_CUR_SHORT_RETRY_LIMIT:
1377 case CFG_CUR_LONG_RETRY_LIMIT:
1378 case CFG_MAX_TX_LIFETIME:
1379 case CFG_MAX_RX_LIFETIME:
1380 case CFG_CF_POLLABLE:
1381 case CFG_PRIVACY_OPT_IMPLEMENTED:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001382 /* case CFG_CURRENT_REMOTE_RATES: */
1383 /* case CFG_CURRENT_USED_RATES: */
1384 /* case CFG_CURRENT_SYSTEM_SCALE: */
1385 /* case CFG_CURRENT_TX_RATE1: */
1386 /* case CFG_CURRENT_TX_RATE2: */
1387 /* case CFG_CURRENT_TX_RATE3: */
1388 /* case CFG_CURRENT_TX_RATE4: */
1389 /* case CFG_CURRENT_TX_RATE5: */
1390 /* case CFG_CURRENT_TX_RATE6: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001391 case CFG_PHY_TYPE:
1392 case CFG_CUR_CHANNEL:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001393 /* case CFG_CURRENT_POWER_STATE: */
1394 /* case CFG_CCAMODE: */
1395 /* lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]); */
1396 /* break; */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001397 /* name string gets just need the first hcf_16 byte flipped (length of string) */
1398 case CFG_CNF_OWN_SSID:
1399 case CFG_CNF_OWN_NAME:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001400 /* case CNF_DESIRED_SSID: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001401 case CFG_DESIRED_SSID:
1402 case CFG_SCAN_SSID:
1403 case CFG_CUR_SSID:
Johan Meiringceb121a2012-11-30 18:58:48 +02001404 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001405 break;
1406 /* non-length counted strings need no byte flipping */
1407 case CFG_CNF_OWN_MAC_ADDR:
1408 /* this case is no longer valid: CFG_CNF_WDS_ADDR */
1409 case CFG_CNF_WDS_ADDR1:
1410 case CFG_CNF_WDS_ADDR2:
1411 case CFG_CNF_WDS_ADDR3:
1412 case CFG_CNF_WDS_ADDR4:
1413 case CFG_CNF_WDS_ADDR5:
1414 case CFG_CNF_WDS_ADDR6:
1415 case CFG_GROUP_ADDR:
1416 case CFG_NIC_SERIAL_NUMBER:
1417 case CFG_CUR_BSSID:
1418 case CFG_NIC_MAC_ADDR:
1419 case CFG_SUPPORTED_DATA_RATES: /* need to ensure we can treat this as a string */
1420 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001421 /* case CFG_CNF_COUNTRY_INFO: */ /* special case, see page 75 of 022486, Rev C. */
1422 /* case CFG_CURRENT_COUNTRY_INFO: */ /* special case, see page 101 of 022486, Rev C. */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001423 /*
Johan Meiringceb121a2012-11-30 18:58:48 +02001424 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
1425 lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[3]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001426
Johan Meiringceb121a2012-11-30 18:58:48 +02001427 for(i = 4; i < lp->ltvRecord.len; i++) {
1428 lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[i]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001429 }
1430 break;
1431 */
1432
1433 case CFG_DEFAULT_KEYS:
1434 {
1435 CFG_DEFAULT_KEYS_STRCT *pKeys = (CFG_DEFAULT_KEYS_STRCT *)&lp->ltvRecord.u.u8[0];
1436
Johan Meiringceb121a2012-11-30 18:58:48 +02001437 pKeys[0].len = CNV_INT_TO_LITTLE(pKeys[0].len);
1438 pKeys[1].len = CNV_INT_TO_LITTLE(pKeys[1].len);
1439 pKeys[2].len = CNV_INT_TO_LITTLE(pKeys[2].len);
1440 pKeys[3].len = CNV_INT_TO_LITTLE(pKeys[3].len);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001441 }
1442 break;
1443 case CFG_CNF_MCAST_RATE:
1444 case CFG_TX_RATE_CNTL:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001445 case CFG_SUPPORTED_RATE_SET_CNTL: /* Supported Rate Set Control */
1446 case CFG_BASIC_RATE_SET_CNTL: /* Basic Rate Set Control */
Johan Meiringceb121a2012-11-30 18:58:48 +02001447 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
1448 lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001449 break;
1450 case CFG_DL_BUF:
1451 case CFG_NIC_IDENTITY:
1452 case CFG_COMMS_QUALITY:
1453 case CFG_PCF_INFO:
Johan Meiringceb121a2012-11-30 18:58:48 +02001454 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
1455 lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]);
1456 lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[2]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001457 break;
1458 case CFG_FW_IDENTITY:
Johan Meiringceb121a2012-11-30 18:58:48 +02001459 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
1460 lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]);
1461 lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[2]);
1462 lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[3]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001463 break;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001464 /* case CFG_HSI_SUP_RANGE: */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001465 case CFG_NIC_MFI_SUP_RANGE:
1466 case CFG_NIC_CFI_SUP_RANGE:
1467 case CFG_NIC_PROFILE:
1468 case CFG_FW_SUP_RANGE:
Johan Meiringceb121a2012-11-30 18:58:48 +02001469 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[0]);
1470 lp->ltvRecord.u.u16[1] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[1]);
1471 lp->ltvRecord.u.u16[2] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[2]);
1472 lp->ltvRecord.u.u16[3] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[3]);
1473 lp->ltvRecord.u.u16[4] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[4]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001474 break;
1475 case CFG_MFI_ACT_RANGES_STA:
1476 case CFG_CFI_ACT_RANGES_STA:
1477 case CFG_CUR_SCALE_THRH:
1478 case CFG_AUTHENTICATION_ALGORITHMS:
Johan Meiring7f622482012-11-30 18:58:52 +02001479 for (i = 0; i < (lp->ltvRecord.len - 1); i++)
Johan Meiringceb121a2012-11-30 18:58:48 +02001480 lp->ltvRecord.u.u16[i] = CNV_INT_TO_LITTLE(lp->ltvRecord.u.u16[i]);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001481 break;
1482 /* done at init time, and endian handled then */
1483 case CFG_PRI_IDENTITY:
1484 break;
1485 case CFG_MB_INFO:
Johan Meiringa52a2e12012-11-30 18:58:54 +02001486 /* wvlanEndianTranslateMailbox(pLtv); */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001487 break;
1488 /* MSF and HCF RIDS */
1489 case CFG_IFB:
1490 case CFG_DRV_INFO:
1491 case CFG_AP_MODE:
1492 case CFG_ENCRYPT_STRING:
1493 case CFG_COUNTRY_STRING:
1494 case CFG_DRIVER_ENABLE:
1495 case CFG_WOLAS_ENABLE:
1496 default:
1497 break;
1498 }
1499
Johan Meiringa52a2e12012-11-30 18:58:54 +02001500 /* Copy the LTV into the user's buffer. */
Johan Meiringceb121a2012-11-30 18:58:48 +02001501 copy_to_user(urq->data, &(lp->ltvRecord), urq->len);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001502
Johan Meiring7f622482012-11-30 18:58:52 +02001503 if (ltvAllocated)
Johan Meiringceb121a2012-11-30 18:58:48 +02001504 kfree(&(lp->ltvRecord));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001505 urq->result = UIL_SUCCESS;
1506 } else {
1507 urq->result = UIL_FAILURE;
1508 }
1509 } else {
Johan Meiringceb121a2012-11-30 18:58:48 +02001510 DBG_ERROR(DbgInfo, "UIL_ERR_WRONG_IFB\n");
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001511 urq->result = UIL_ERR_WRONG_IFB;
1512 }
1513
Johan Meiringceb121a2012-11-30 18:58:48 +02001514 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001515 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001516} /* wvlan_uil_get_info */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001517/*============================================================================*/
1518
1519
1520
1521
1522
1523/*******************************************************************************
1524 * cfg_driver_info()
1525 *******************************************************************************
1526 *
1527 * DESCRIPTION:
1528 *
1529 * Retrieves driver information.
1530 *
1531 * PARAMETERS:
1532 *
1533 * urq - a pointer to the UIL request buffer
1534 * lp - a pointer to the device's private adapter structure
1535 *
1536 * RETURNS:
1537 *
1538 * UIL_SUCCESS
1539 * UIL_ERR_xxx value otherwise
1540 *
1541 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +02001542int cfg_driver_info(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001543{
1544 int result = 0;
1545 /*------------------------------------------------------------------------*/
1546
1547
Johan Meiringceb121a2012-11-30 18:58:48 +02001548 DBG_FUNC("cfg_driver_info");
1549 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001550
1551
1552 /* Make sure that user buffer can handle the driver information buffer */
Johan Meiring0af2d462012-11-30 18:58:49 +02001553 if (urq->len < sizeof(lp->driverInfo)) {
Johan Meiringceb121a2012-11-30 18:58:48 +02001554 urq->len = sizeof(lp->driverInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001555 urq->result = UIL_ERR_LEN;
Johan Meiringceb121a2012-11-30 18:58:48 +02001556 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001557 return result;
1558 }
1559
1560 /* Verify the user buffer. */
Johan Meiringceb121a2012-11-30 18:58:48 +02001561 result = verify_area(VERIFY_WRITE, urq->data, sizeof(lp->driverInfo));
Johan Meiring0af2d462012-11-30 18:58:49 +02001562 if (result != 0) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001563 urq->result = UIL_FAILURE;
Johan Meiringceb121a2012-11-30 18:58:48 +02001564 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001565 return result;
1566 }
1567
1568 lp->driverInfo.card_stat = lp->hcfCtx.IFB_CardStat;
1569
Johan Meiringa52a2e12012-11-30 18:58:54 +02001570 /* Copy the driver information into the user's buffer. */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001571 urq->result = UIL_SUCCESS;
Johan Meiringceb121a2012-11-30 18:58:48 +02001572 copy_to_user(urq->data, &(lp->driverInfo), sizeof(lp->driverInfo));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001573
Johan Meiringceb121a2012-11-30 18:58:48 +02001574 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001575 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001576} /* cfg_driver_info */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001577/*============================================================================*/
1578
1579
1580
1581
1582/*******************************************************************************
1583 * cfg_driver_identity()
1584 *******************************************************************************
1585 *
1586 * DESCRIPTION:
1587 *
1588 * Retrieves ID information from the card.
1589 *
1590 * PARAMETERS:
1591 *
1592 * urq - a pointer to the UIL request buffer
1593 * lp - a pointer to the device's private adapter structure
1594 *
1595 * RETURNS:
1596 *
1597 * UIL_SUCCESS
1598 * UIL_ERR_xxx value otherwise
1599 *
1600 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +02001601int cfg_driver_identity(struct uilreq *urq, struct wl_private *lp)
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001602{
1603 int result = 0;
1604 /*------------------------------------------------------------------------*/
1605
1606
Johan Meiringceb121a2012-11-30 18:58:48 +02001607 DBG_FUNC("wvlan_driver_identity");
1608 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001609
1610
1611 /* Make sure that user buffer can handle the driver identity structure. */
Johan Meiring0af2d462012-11-30 18:58:49 +02001612 if (urq->len < sizeof(lp->driverIdentity)) {
Johan Meiringceb121a2012-11-30 18:58:48 +02001613 urq->len = sizeof(lp->driverIdentity);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001614 urq->result = UIL_ERR_LEN;
Johan Meiringceb121a2012-11-30 18:58:48 +02001615 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001616 return result;
1617 }
1618
1619 /* Verify the user buffer. */
Johan Meiringceb121a2012-11-30 18:58:48 +02001620 result = verify_area(VERIFY_WRITE, urq->data, sizeof(lp->driverIdentity));
Johan Meiring0af2d462012-11-30 18:58:49 +02001621 if (result != 0) {
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001622 urq->result = UIL_FAILURE;
Johan Meiringceb121a2012-11-30 18:58:48 +02001623 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001624 return result;
1625 }
1626
1627 /* Copy the driver identity into the user's buffer. */
1628 urq->result = UIL_SUCCESS;
Johan Meiringceb121a2012-11-30 18:58:48 +02001629 copy_to_user(urq->data, &(lp->driverIdentity), sizeof(lp->driverIdentity));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001630
Johan Meiringceb121a2012-11-30 18:58:48 +02001631 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001632 return result;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001633} /* cfg_driver_identity */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001634/*============================================================================*/
1635
1636
1637#endif /* USE_UIL */
1638
1639
1640/* If WIRELESS_EXT is not defined, then the functions that follow will not be
1641 included in the build. */
1642/* NOTE: Are these still even needed? */
1643#ifdef WIRELESS_EXT
1644
1645
1646/*******************************************************************************
1647 * wvlan_set_netname()
1648 *******************************************************************************
1649 *
1650 * DESCRIPTION:
1651 *
1652 * Set the ESSID of the card.
1653 *
1654 * PARAMETERS:
1655 *
1656 * wrq - a pointer to the wireless request buffer
1657 * lp - a pointer to the device's private adapter structure
1658 *
1659 * RETURNS:
1660 *
1661 * 0 on success
1662 * errno value otherwise
1663 *
1664 ******************************************************************************/
1665int wvlan_set_netname(struct net_device *dev,
1666 struct iw_request_info *info,
1667 union iwreq_data *wrqu,
1668 char *extra)
1669{
Johan Meiringfdd9e862012-11-30 18:58:53 +02001670 struct wl_private *lp = wl_priv(dev);
1671 unsigned long flags;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001672 int ret = 0;
1673 /*------------------------------------------------------------------------*/
1674
1675
Johan Meiringceb121a2012-11-30 18:58:48 +02001676 DBG_FUNC("wvlan_set_netname");
1677 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001678
Johan Meiringfdd9e862012-11-30 18:58:53 +02001679 wl_lock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001680
Johan Meiringfdd9e862012-11-30 18:58:53 +02001681 memset(lp->NetworkName, 0, sizeof(lp->NetworkName));
1682 memcpy(lp->NetworkName, extra, wrqu->data.length);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001683
1684 /* Commit the adapter parameters */
1685 wl_apply(lp);
Johan Meiringfdd9e862012-11-30 18:58:53 +02001686 wl_unlock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001687
Johan Meiringceb121a2012-11-30 18:58:48 +02001688 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001689 return ret;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001690} /* wvlan_set_netname */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001691/*============================================================================*/
1692
1693
1694
1695
1696/*******************************************************************************
1697 * wvlan_get_netname()
1698 *******************************************************************************
1699 *
1700 * DESCRIPTION:
1701 *
1702 * Get the ESSID of the card.
1703 *
1704 * PARAMETERS:
1705 *
1706 * wrq - a pointer to the wireless request buffer
1707 * lp - a pointer to the device's private adapter structure
1708 *
1709 * RETURNS:
1710 *
1711 * 0 on success
1712 * errno value otherwise
1713 *
1714 ******************************************************************************/
1715int wvlan_get_netname(struct net_device *dev,
1716 struct iw_request_info *info,
1717 union iwreq_data *wrqu,
1718 char *extra)
1719{
Johan Meiringfdd9e862012-11-30 18:58:53 +02001720 struct wl_private *lp = wl_priv(dev);
1721 unsigned long flags;
1722 int ret = 0;
1723 int status = -1;
1724 wvName_t *pName;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001725 /*------------------------------------------------------------------------*/
1726
1727
Johan Meiringfdd9e862012-11-30 18:58:53 +02001728 DBG_FUNC("wvlan_get_netname");
1729 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001730
Johan Meiringfdd9e862012-11-30 18:58:53 +02001731 wl_lock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001732
Johan Meiringfdd9e862012-11-30 18:58:53 +02001733 /* Get the current network name */
1734 lp->ltvRecord.len = 1 + (sizeof(*pName) / sizeof(hcf_16));
1735 lp->ltvRecord.typ = CFG_CUR_SSID;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001736
Johan Meiringfdd9e862012-11-30 18:58:53 +02001737 status = hcf_get_info(&(lp->hcfCtx), (LTVP)&(lp->ltvRecord));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001738
Johan Meiringfdd9e862012-11-30 18:58:53 +02001739 if (status == HCF_SUCCESS) {
1740 pName = (wvName_t *)&(lp->ltvRecord.u.u32);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001741
1742 memset(extra, '\0', HCF_MAX_NAME_LEN);
1743 wrqu->data.length = pName->length;
1744
Johan Meiringfdd9e862012-11-30 18:58:53 +02001745 memcpy(extra, pName->name, pName->length);
1746 } else {
1747 ret = -EFAULT;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001748 }
1749
Johan Meiringfdd9e862012-11-30 18:58:53 +02001750 wl_unlock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001751
Johan Meiringfdd9e862012-11-30 18:58:53 +02001752 DBG_LEAVE(DbgInfo);
1753 return ret;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001754} /* wvlan_get_netname */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001755/*============================================================================*/
1756
1757
1758
1759
1760/*******************************************************************************
1761 * wvlan_set_station_nickname()
1762 *******************************************************************************
1763 *
1764 * DESCRIPTION:
1765 *
1766 * Set the card's station nickname.
1767 *
1768 * PARAMETERS:
1769 *
1770 * wrq - a pointer to the wireless request buffer
1771 * lp - a pointer to the device's private adapter structure
1772 *
1773 * RETURNS:
1774 *
1775 * 0 on success
1776 * errno value otherwise
1777 *
1778 ******************************************************************************/
1779int wvlan_set_station_nickname(struct net_device *dev,
1780 struct iw_request_info *info,
1781 union iwreq_data *wrqu,
1782 char *extra)
1783{
Johan Meiringfdd9e862012-11-30 18:58:53 +02001784 struct wl_private *lp = wl_priv(dev);
1785 unsigned long flags;
1786 int ret = 0;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001787 /*------------------------------------------------------------------------*/
1788
1789
Johan Meiringfdd9e862012-11-30 18:58:53 +02001790 DBG_FUNC("wvlan_set_station_nickname");
1791 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001792
Johan Meiringfdd9e862012-11-30 18:58:53 +02001793 wl_lock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001794
Johan Meiringfdd9e862012-11-30 18:58:53 +02001795 memset(lp->StationName, 0, sizeof(lp->StationName));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001796
Johan Meiringfdd9e862012-11-30 18:58:53 +02001797 memcpy(lp->StationName, extra, wrqu->data.length);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001798
Johan Meiringfdd9e862012-11-30 18:58:53 +02001799 /* Commit the adapter parameters */
1800 wl_apply(lp);
1801 wl_unlock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001802
Johan Meiringfdd9e862012-11-30 18:58:53 +02001803 DBG_LEAVE(DbgInfo);
1804 return ret;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001805} /* wvlan_set_station_nickname */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001806/*============================================================================*/
1807
1808
1809
1810
1811/*******************************************************************************
1812 * wvlan_get_station_nickname()
1813 *******************************************************************************
1814 *
1815 * DESCRIPTION:
1816 *
1817 * Get the card's station nickname.
1818 *
1819 * PARAMETERS:
1820 *
1821 * wrq - a pointer to the wireless request buffer
1822 * lp - a pointer to the device's private adapter structure
1823 *
1824 * RETURNS:
1825 *
1826 * 0 on success
1827 * errno value otherwise
1828 *
1829 ******************************************************************************/
1830int wvlan_get_station_nickname(struct net_device *dev,
1831 struct iw_request_info *info,
1832 union iwreq_data *wrqu,
1833 char *extra)
1834{
Johan Meiringfdd9e862012-11-30 18:58:53 +02001835 struct wl_private *lp = wl_priv(dev);
1836 unsigned long flags;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001837 int ret = 0;
1838 int status = -1;
1839 wvName_t *pName;
1840 /*------------------------------------------------------------------------*/
1841
1842
Johan Meiringfdd9e862012-11-30 18:58:53 +02001843 DBG_FUNC("wvlan_get_station_nickname");
1844 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001845
Johan Meiringfdd9e862012-11-30 18:58:53 +02001846 wl_lock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001847
Johan Meiringfdd9e862012-11-30 18:58:53 +02001848 /* Get the current station name */
1849 lp->ltvRecord.len = 1 + (sizeof(*pName) / sizeof(hcf_16));
1850 lp->ltvRecord.typ = CFG_CNF_OWN_NAME;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001851
Johan Meiringfdd9e862012-11-30 18:58:53 +02001852 status = hcf_get_info(&(lp->hcfCtx), (LTVP)&(lp->ltvRecord));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001853
Johan Meiringfdd9e862012-11-30 18:58:53 +02001854 if (status == HCF_SUCCESS) {
1855 pName = (wvName_t *)&(lp->ltvRecord.u.u32);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001856
1857 memset(extra, '\0', HCF_MAX_NAME_LEN);
1858 wrqu->data.length = pName->length;
1859 memcpy(extra, pName->name, pName->length);
Johan Meiringfdd9e862012-11-30 18:58:53 +02001860 } else {
1861 ret = -EFAULT;
1862 }
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001863
Johan Meiringfdd9e862012-11-30 18:58:53 +02001864 wl_unlock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001865
Johan Meiringa52a2e12012-11-30 18:58:54 +02001866/* out: */
Johan Meiringfdd9e862012-11-30 18:58:53 +02001867 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001868 return ret;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001869} /* wvlan_get_station_nickname */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001870/*============================================================================*/
1871
1872
1873
1874
1875/*******************************************************************************
1876 * wvlan_set_porttype()
1877 *******************************************************************************
1878 *
1879 * DESCRIPTION:
1880 *
1881 * Set the card's porttype
1882 *
1883 * PARAMETERS:
1884 *
1885 * wrq - a pointer to the wireless request buffer
1886 * lp - a pointer to the device's private adapter structure
1887 *
1888 * RETURNS:
1889 *
1890 * 0 on success
1891 * errno value otherwise
1892 *
1893 ******************************************************************************/
1894int wvlan_set_porttype(struct net_device *dev,
1895 struct iw_request_info *info,
1896 union iwreq_data *wrqu,
1897 char *extra)
1898{
Johan Meiringfdd9e862012-11-30 18:58:53 +02001899 struct wl_private *lp = wl_priv(dev);
1900 unsigned long flags;
1901 int ret = 0;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001902 hcf_16 portType;
1903 /*------------------------------------------------------------------------*/
1904
1905
Johan Meiringfdd9e862012-11-30 18:58:53 +02001906 DBG_FUNC("wvlan_set_porttype");
1907 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001908
Johan Meiringfdd9e862012-11-30 18:58:53 +02001909 wl_lock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001910
Johan Meiringfdd9e862012-11-30 18:58:53 +02001911 /* Validate the new value */
1912 portType = *((__u32 *)extra);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001913
Johan Meiringfdd9e862012-11-30 18:58:53 +02001914 if (!((portType == 1) || (portType == 3))) {
1915 ret = -EINVAL;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001916 goto out_unlock;
Johan Meiringfdd9e862012-11-30 18:58:53 +02001917 }
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001918
Johan Meiringfdd9e862012-11-30 18:58:53 +02001919 lp->PortType = portType;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001920
Johan Meiringfdd9e862012-11-30 18:58:53 +02001921 /* Commit the adapter parameters */
1922 wl_apply(lp);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001923
1924out_unlock:
Johan Meiringfdd9e862012-11-30 18:58:53 +02001925 wl_unlock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001926
Johan Meiringa52a2e12012-11-30 18:58:54 +02001927/* out: */
Johan Meiringfdd9e862012-11-30 18:58:53 +02001928 DBG_LEAVE(DbgInfo);
1929 return ret;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001930}
1931
1932/*============================================================================*/
1933
1934
1935/*******************************************************************************
1936 * wvlan_get_porttype()
1937 *******************************************************************************
1938 *
1939 * DESCRIPTION:
1940 *
1941 * Get the card's porttype
1942 *
1943 * PARAMETERS:
1944 *
1945 * wrq - a pointer to the wireless request buffer
1946 * lp - a pointer to the device's private adapter structure
1947 *
1948 * RETURNS:
1949 *
1950 * 0 on success
1951 * errno value otherwise
1952 *
1953 ******************************************************************************/
1954int wvlan_get_porttype(struct net_device *dev,
1955 struct iw_request_info *info,
1956 union iwreq_data *wrqu,
1957 char *extra)
1958{
Johan Meiringfdd9e862012-11-30 18:58:53 +02001959 struct wl_private *lp = wl_priv(dev);
1960 unsigned long flags;
1961 int ret = 0;
1962 int status = -1;
1963 hcf_16 *pPortType;
1964 __u32 *pData = (__u32 *)extra;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001965 /*------------------------------------------------------------------------*/
1966
1967
Johan Meiringfdd9e862012-11-30 18:58:53 +02001968 DBG_FUNC("wvlan_get_porttype");
1969 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001970
Johan Meiringfdd9e862012-11-30 18:58:53 +02001971 wl_lock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001972
Johan Meiringfdd9e862012-11-30 18:58:53 +02001973 /* Get the current port type */
1974 lp->ltvRecord.len = 1 + (sizeof(*pPortType) / sizeof(hcf_16));
1975 lp->ltvRecord.typ = CFG_CNF_PORT_TYPE;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001976
Johan Meiringfdd9e862012-11-30 18:58:53 +02001977 status = hcf_get_info(&(lp->hcfCtx), (LTVP)&(lp->ltvRecord));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001978
Johan Meiringfdd9e862012-11-30 18:58:53 +02001979 if (status == HCF_SUCCESS) {
1980 pPortType = (hcf_16 *)&(lp->ltvRecord.u.u32);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001981
Johan Meiringfdd9e862012-11-30 18:58:53 +02001982 *pData = CNV_LITTLE_TO_INT(*pPortType);
1983 } else {
1984 ret = -EFAULT;
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001985 }
1986
Johan Meiringfdd9e862012-11-30 18:58:53 +02001987 wl_unlock(lp, &flags);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001988
Johan Meiringa52a2e12012-11-30 18:58:54 +02001989/* out: */
Johan Meiringfdd9e862012-11-30 18:58:53 +02001990 DBG_LEAVE(DbgInfo);
1991 return ret;
Johan Meiringa52a2e12012-11-30 18:58:54 +02001992} /* wvlan_get_porttype */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001993/*============================================================================*/
1994
Johan Meiringa52a2e12012-11-30 18:58:54 +02001995#endif /* WIRELESS_EXT */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02001996
1997
1998
1999
2000#ifdef USE_RTS
2001/*******************************************************************************
2002 * wvlan_rts()
2003 *******************************************************************************
2004 *
2005 * DESCRIPTION:
2006 *
2007 * IOCTL handler for RTS commands
2008 *
2009 * PARAMETERS:
2010 *
2011 * rrq - a pointer to the rts request buffer
2012 * lp - a pointer to the device's private adapter structure
2013 *
2014 * RETURNS:
2015 *
2016 * 0 on success
2017 * errno value otherwise
2018 *
2019 ******************************************************************************/
Johan Meiringceb121a2012-11-30 18:58:48 +02002020int wvlan_rts(struct rtsreq *rrq, __u32 io_base)
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002021{
2022 int ioctl_ret = 0;
2023 /*------------------------------------------------------------------------*/
2024
2025
Johan Meiringceb121a2012-11-30 18:58:48 +02002026 DBG_FUNC("wvlan_rts");
2027 DBG_ENTER(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002028
2029
Johan Meiringceb121a2012-11-30 18:58:48 +02002030 DBG_PRINT("io_base: 0x%08x\n", io_base);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002031
Johan Meiring0af2d462012-11-30 18:58:49 +02002032 switch (rrq->typ) {
Johan Meiringac6cf1b2012-11-30 18:58:51 +02002033 case WL_IOCTL_RTS_READ:
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002034 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_READ\n");
Johan Meiringceb121a2012-11-30 18:58:48 +02002035 rrq->data[0] = IN_PORT_WORD(io_base + rrq->reg);
2036 DBG_TRACE(DbgInfo, " reg 0x%04x ==> 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT(rrq->data[0]));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002037 break;
Johan Meiringac6cf1b2012-11-30 18:58:51 +02002038 case WL_IOCTL_RTS_WRITE:
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002039 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_WRITE\n");
Johan Meiringceb121a2012-11-30 18:58:48 +02002040 OUT_PORT_WORD(io_base + rrq->reg, rrq->data[0]);
2041 DBG_TRACE(DbgInfo, " reg 0x%04x <== 0x%04x\n", rrq->reg, CNV_LITTLE_TO_SHORT(rrq->data[0]));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002042 break;
Johan Meiringac6cf1b2012-11-30 18:58:51 +02002043 case WL_IOCTL_RTS_BATCH_READ:
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002044 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_BATCH_READ\n");
Johan Meiringceb121a2012-11-30 18:58:48 +02002045 IN_PORT_STRING_16(io_base + rrq->reg, rrq->data, rrq->len);
Johan Meiring0af2d462012-11-30 18:58:49 +02002046 DBG_TRACE(DbgInfo, " reg 0x%04x ==> %d bytes\n", rrq->reg, rrq->len * sizeof(__u16));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002047 break;
Johan Meiringac6cf1b2012-11-30 18:58:51 +02002048 case WL_IOCTL_RTS_BATCH_WRITE:
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002049 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- WL_IOCTL_RTS_BATCH_WRITE\n");
Johan Meiringceb121a2012-11-30 18:58:48 +02002050 OUT_PORT_STRING_16(io_base + rrq->reg, rrq->data, rrq->len);
Johan Meiring0af2d462012-11-30 18:58:49 +02002051 DBG_TRACE(DbgInfo, " reg 0x%04x <== %d bytes\n", rrq->reg, rrq->len * sizeof(__u16));
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002052 break;
2053 default:
2054
Johan Meiringceb121a2012-11-30 18:58:48 +02002055 DBG_TRACE(DbgInfo, "IOCTL: WVLAN2_IOCTL_RTS -- UNSUPPORTED RTS CODE: 0x%X", rrq->typ);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002056 ioctl_ret = -EOPNOTSUPP;
2057 break;
2058 }
2059
Johan Meiringceb121a2012-11-30 18:58:48 +02002060 DBG_LEAVE(DbgInfo);
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002061 return ioctl_ret;
Johan Meiringa52a2e12012-11-30 18:58:54 +02002062} /* wvlan_rts */
Henk de Groot68c0bdf2009-09-27 11:12:52 +02002063/*============================================================================*/
2064
2065#endif /* USE_RTS */