2 ** $Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/os/linux/gl_wext_priv.c#4 $
5 /*! \file gl_wext_priv.c
6 \brief This file includes private ioctl support.
12 ** $Log: gl_wext_priv.c $
14 * 07 17 2012 yuche.tsai
16 * Let netdev bring up.
18 * 06 13 2012 yuche.tsai
20 * Update maintrunk driver.
21 * Add support for driver compose assoc request frame.
24 * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function[WCXRP00001202] [MT6628 Wi-Fi][FW] Adding the New PN init code
25 * use return to avoid the ioctl return not supported
29 * Snc CFG80211 modification for ICS migration from branch 2.2.
32 * [WCXRP00001170] [MT6620 Wi-Fi][Driver] Adding the related code for set/get band ioctl
33 * Adding the template code for set / get band IOCTL (with ICS supplicant_6)..
36 * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
37 * Adding the related ioctl / wlan oid function to set the Tx power cfg.
40 * [WCXRP00001153] [MT6620 Wi-Fi][Driver] Adding the get_ch_list and set_tx_power proto type function
41 * Adding the proto type function for set_int set_tx_power and get int get_ch_list.
44 * [WCXRP00001098] [MT6620 Wi-Fi][Driver] Replace printk by DBG LOG macros in linux porting layer
45 * 1. eliminaite direct calls to printk in porting layer.
46 * 2. replaced by DBGLOG, which would be XLOG on ALPS platforms.
48 * 11 02 2011 chinghwa.yu
49 * [WCXRP00000063] Update BCM CoEx design and settings
52 * 09 20 2011 chinglan.wang
53 * [WCXRP00000989] [WiFi Direct] [Driver] Add a new io control API to start the formation for the sigma test.
56 * 07 28 2011 chinghwa.yu
57 * [WCXRP00000063] Update BCM CoEx design and settings
58 * Add BWCS cmd and event.
60 * 07 18 2011 chinghwa.yu
61 * [WCXRP00000063] Update BCM CoEx design and settings[WCXRP00000612] [MT6620 Wi-Fi] [FW] CSD update SWRDD algorithm
62 * Add CMD/Event for RDD and BWCS.
64 * 03 17 2011 chinglan.wang
65 * [WCXRP00000570] [MT6620 Wi-Fi][Driver] Add Wi-Fi Protected Setup v2.0 feature
69 * [WCXRP00000521] [MT6620 Wi-Fi][Driver] Remove non-standard debug message
70 * Toggle non-standard debug messages to comments.
73 * [WCXRP00000402] [MT6620 Wi-Fi][Driver] Enable MCR read/write by iwpriv by default
77 * [WCXRP00000396] [MT6620 Wi-Fi][Driver] Support Sw Ctrl ioctl at linux
78 * adding the SW cmd ioctl support, use set/get structure ioctl.
80 * 01 20 2011 eddie.chen
81 * [WCXRP00000374] [MT6620 Wi-Fi][DRV] SW debug control
84 * 01 20 2011 eddie.chen
85 * [WCXRP00000374] [MT6620 Wi-Fi][DRV] SW debug control
86 * Add Oid for sw control debug command
89 * [WCXRP00000336] [MT6620 Wi-Fi][Driver] Add test mode commands in normal phone operation
90 * Add a new compiling option to control if MCR read/write is permitted
93 * [WCXRP00000336] [MT6620 Wi-Fi][Driver] Add test mode commands in normal phone operation
94 * Add some iwpriv commands to support test mode operation
96 * 12 15 2010 george.huang
97 * [WCXRP00000152] [MT6620 Wi-Fi] AP mode power saving function
98 * Support set PS profile and set WMM-PS related iwpriv.
101 * [WCXRP00000171] [MT6620 Wi-Fi][Driver] Add message check code same behavior as mt5921
102 * add the message check code from mt5921.
105 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check[WCXRP00000086] [MT6620 Wi-Fi][Driver] The mac address is all zero at android
106 * complete implementation of Android NVRAM access
109 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
110 * correct typo for NVRAM access.
113 * [WCXRP00000056] [MT6620 Wi-Fi][Driver] NVRAM implementation with Version Check
114 * add skeleton for NVRAM integration
118 * revert changelist #15371, efuse read/write access will be done by RF test approach
122 * add OID definitions for EFUSE read/write access.
126 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
128 * 06 06 2010 kevin.huang
129 * [WPD00003832][MT6620 5931] Create driver base
130 * [MT6620 5931] Create driver base
133 * [WPD00001943]Create WiFi test driver framework on WinXP
134 * enable OID_CUSTOM_MTK_WIFI_TEST for RFTest & META tool
136 * 05 29 2010 jeffrey.chang
137 * [WPD00003826]Initial import for Linux port
138 * fix private ioctl for rftest
140 * 04 21 2010 jeffrey.chang
141 * [WPD00003826]Initial import for Linux port
142 * add for private ioctl support
143 ** \main\maintrunk.MT5921\32 2009-10-08 10:33:25 GMT mtk01090
144 ** Avoid accessing private data of net_device directly. Replace with netdev_priv(). Add more checking for input parameters and pointers.
145 ** \main\maintrunk.MT5921\31 2009-09-29 16:46:21 GMT mtk01090
146 ** Remove unused functions
147 ** \main\maintrunk.MT5921\30 2009-09-29 14:46:47 GMT mtk01090
148 ** Fix compile warning
149 ** \main\maintrunk.MT5921\29 2009-09-29 14:28:48 GMT mtk01090
150 ** Fix compile warning
151 ** \main\maintrunk.MT5921\28 2009-09-28 22:21:38 GMT mtk01090
152 ** Refine lines to supress compile warning
153 ** \main\maintrunk.MT5921\27 2009-09-28 20:19:14 GMT mtk01090
154 ** Add private ioctl to carry OID structures. Restructure public/private ioctl interfaces to Linux kernel.
155 ** \main\maintrunk.MT5921\26 2009-08-18 22:56:53 GMT mtk01090
156 ** Add Linux SDIO (with mmc core) support.
157 ** Add Linux 2.6.21, 2.6.25, 2.6.26.
158 ** Fix compile warning in Linux.
159 ** \main\maintrunk.MT5921\25 2009-05-07 22:26:15 GMT mtk01089
160 ** Add mandatory and private IO control for Linux BWCS
161 ** \main\maintrunk.MT5921\24 2009-04-29 10:07:05 GMT mtk01088
162 ** fixed the compiling error at linux
163 ** \main\maintrunk.MT5921\23 2009-04-24 09:09:45 GMT mtk01088
164 ** mark the code not used at linux supplicant v0.6.7
165 ** \main\maintrunk.MT5921\22 2008-11-24 21:03:51 GMT mtk01425
166 ** 1. Add PTA_ENABLED flag
167 ** \main\maintrunk.MT5921\21 2008-08-29 14:55:59 GMT mtk01088
168 ** adjust the code for meet the coding style, and add assert check
169 ** \main\maintrunk.MT5921\20 2008-07-16 15:23:20 GMT mtk01104
170 ** Support GPIO2 mode
171 ** \main\maintrunk.MT5921\19 2008-07-15 17:43:11 GMT mtk01084
172 ** modify variable name
173 ** \main\maintrunk.MT5921\18 2008-07-14 14:37:58 GMT mtk01104
174 ** Add exception handle about length in function priv_set_struct()
175 ** \main\maintrunk.MT5921\17 2008-07-14 13:55:32 GMT mtk01104
176 ** Support PRIV_CMD_BT_COEXIST
177 ** \main\maintrunk.MT5921\16 2008-07-09 00:20:15 GMT mtk01461
178 ** Add priv oid to support WMM_PS_TEST
179 ** \main\maintrunk.MT5921\15 2008-06-02 11:15:22 GMT mtk01461
180 ** Update after wlanoidSetPowerMode changed
181 ** \main\maintrunk.MT5921\14 2008-05-30 19:31:07 GMT mtk01461
182 ** Add IOCTL for Power Mode
183 ** \main\maintrunk.MT5921\13 2008-05-30 18:57:15 GMT mtk01461
184 ** Not use wlanoidSetCSUMOffloadForLinux()
185 ** \main\maintrunk.MT5921\12 2008-05-30 15:13:18 GMT mtk01084
187 ** \main\maintrunk.MT5921\11 2008-05-29 14:16:31 GMT mtk01084
188 ** rename for wlanoidSetBeaconIntervalForLinux
189 ** \main\maintrunk.MT5921\10 2008-04-17 23:06:37 GMT mtk01461
190 ** Add iwpriv support for AdHocMode setting
191 ** \main\maintrunk.MT5921\9 2008-03-31 21:00:55 GMT mtk01461
192 ** Add priv IOCTL for VOIP setting
193 ** \main\maintrunk.MT5921\8 2008-03-31 13:49:43 GMT mtk01461
194 ** Add priv ioctl to turn on / off roaming
195 ** \main\maintrunk.MT5921\7 2008-03-26 15:35:14 GMT mtk01461
196 ** Add CSUM offload priv ioctl for Linux
197 ** \main\maintrunk.MT5921\6 2008-03-11 14:50:59 GMT mtk01461
199 ** \main\maintrunk.MT5921\5 2007-11-06 19:32:30 GMT mtk01088
201 ** \main\maintrunk.MT5921\4 2007-10-30 12:01:39 GMT MTK01425
202 ** 1. Update wlanQueryInformation and wlanSetInformation
205 /*******************************************************************************
206 * C O M P I L E R F L A G S
207 ********************************************************************************
210 /*******************************************************************************
211 * E X T E R N A L R E F E R E N C E S
212 ********************************************************************************
217 #include "gl_wext_priv.h"
221 #if CFG_ENABLE_WIFI_DIRECT
222 #include "gl_p2p_os.h"
225 /*******************************************************************************
227 ********************************************************************************
229 #define NUM_SUPPORTED_OIDS (sizeof(arWlanOidReqTable) / sizeof(WLAN_REQ_ENTRY))
230 #define CMD_START "START"
231 #define CMD_STOP "STOP"
232 #define CMD_SCAN_ACTIVE "SCAN-ACTIVE"
233 #define CMD_SCAN_PASSIVE "SCAN-PASSIVE"
234 #define CMD_RSSI "RSSI"
235 #define CMD_LINKSPEED "LINKSPEED"
236 #define CMD_RXFILTER_START "RXFILTER-START"
237 #define CMD_RXFILTER_STOP "RXFILTER-STOP"
238 #define CMD_RXFILTER_ADD "RXFILTER-ADD"
239 #define CMD_RXFILTER_REMOVE "RXFILTER-REMOVE"
240 #define CMD_BTCOEXSCAN_START "BTCOEXSCAN-START"
241 #define CMD_BTCOEXSCAN_STOP "BTCOEXSCAN-STOP"
242 #define CMD_BTCOEXMODE "BTCOEXMODE"
243 #define CMD_SETSUSPENDOPT "SETSUSPENDOPT"
244 #define CMD_SETSUSPENDMODE "SETSUSPENDMODE"
245 #define CMD_P2P_DEV_ADDR "P2P_DEV_ADDR"
246 #define CMD_SETFWPATH "SETFWPATH"
247 #define CMD_SETBAND "SETBAND"
248 #define CMD_GETBAND "GETBAND"
249 #define CMD_COUNTRY "COUNTRY"
250 #define CMD_P2P_SET_NOA "P2P_SET_NOA"
251 #define CMD_P2P_GET_NOA "P2P_GET_NOA"
252 #define CMD_P2P_SET_PS "P2P_SET_PS"
253 #define CMD_SET_AP_WPS_P2P_IE "SET_AP_WPS_P2P_IE"
254 #define CMD_SETROAMMODE "SETROAMMODE"
255 #define CMD_MIRACAST "MIRACAST"
258 #define CMD_PNOSSIDCLR_SET "PNOSSIDCLR"
259 #define CMD_PNOSETUP_SET "PNOSETUP "
260 #define CMD_PNOENABLE_SET "PNOFORCE"
261 #define CMD_PNODEBUG_SET "PNODEBUG"
262 #define CMD_WLS_BATCHING "WLS_BATCHING"
264 #define CMD_OKC_SET_PMK "SET_PMK"
265 #define CMD_OKC_ENABLE "OKC_ENABLE"
267 /* miracast related definition */
268 #define MIRACAST_MODE_OFF 0
269 #define MIRACAST_MODE_SOURCE 1
270 #define MIRACAST_MODE_SINK 2
272 #ifndef MIRACAST_AMPDU_SIZE
273 #define MIRACAST_AMPDU_SIZE 8
276 #ifndef MIRACAST_MCHAN_ALGO
277 #define MIRACAST_MCHAN_ALGO 1
280 #ifndef MIRACAST_MCHAN_BW
281 #define MIRACAST_MCHAN_BW 25
284 #define CMD_BAND_AUTO 0
285 #define CMD_BAND_5G 1
286 #define CMD_BAND_2G 2
287 #define CMD_BAND_ALL 3
289 /* Mediatek private command */
291 #define CMD_SET_SW_CTRL "SET_SW_CTRL"
292 #define CMD_GET_SW_CTRL "GET_SW_CTRL"
293 #define CMD_SET_CFG "SET_CFG"
294 #define CMD_GET_CFG "GET_CFG"
295 #define CMD_SET_CHIP "SET_CHIP"
296 #define CMD_GET_CHIP "GET_CHIP"
297 #define CMD_SET_DBG_LEVEL "SET_DBG_LEVEL"
298 #define CMD_GET_DBG_LEVEL "GET_DBG_LEVEL"
301 static UINT_8 g_ucMiracastMode
= MIRACAST_MODE_OFF
;
303 typedef struct cmd_tlv
{
310 typedef struct priv_driver_cmd_s
{
316 /*******************************************************************************
317 * F U N C T I O N D E C L A R A T I O N S
318 ********************************************************************************
323 IN
struct net_device
*prNetDev
,
324 IN NDIS_TRANSPORT_STRUCT
* prNdisReq
,
325 OUT PUINT_32 pu4OutputLen
330 IN
struct net_device
*prNetDev
,
331 IN NDIS_TRANSPORT_STRUCT
* prNdisReq
,
332 OUT PUINT_32 pu4OutputLen
335 #if 0 /* CFG_SUPPORT_WPS */
338 IN
struct net_device
*prNetDev
,
339 IN
struct iw_request_info
*prIwReqInfo
,
340 IN
union iwreq_data
*prIwReqData
,
346 IN
struct net_device
*prNetDev
,
347 IN
struct iw_request_info
*prIwReqInfo
,
348 IN
union iwreq_data
*prIwReqData
,
351 #endif /* CFG_SUPPORT_WPS */
354 reqSearchSupportedOidEntry (
356 OUT P_WLAN_REQ_ENTRY
*ppWlanReqEntry
361 reqExtQueryConfiguration (
362 IN P_GLUE_INFO_T prGlueInfo
,
363 OUT PVOID pvQueryBuffer
,
364 IN UINT_32 u4QueryBufferLen
,
365 OUT PUINT_32 pu4QueryInfoLen
369 reqExtSetConfiguration (
370 IN P_GLUE_INFO_T prGlueInfo
,
371 IN PVOID pvSetBuffer
,
372 IN UINT_32 u4SetBufferLen
,
373 OUT PUINT_32 pu4SetInfoLen
378 reqExtSetAcpiDevicePowerState (
379 IN P_GLUE_INFO_T prGlueInfo
,
380 IN PVOID pvSetBuffer
,
381 IN UINT_32 u4SetBufferLen
,
382 OUT PUINT_32 pu4SetInfoLen
385 /*******************************************************************************
386 * P R I V A T E D A T A
387 ********************************************************************************
389 static UINT_8 aucOidBuf
[4096] = {0};
391 /* OID processing table */
392 /* Order is important here because the OIDs should be in order of
393 increasing value for binary searching. */
394 static WLAN_REQ_ENTRY arWlanOidReqTable
[] = {
398 fgQryBufLenChecking, fgSetBufLenChecking, fgIsHandleInGlueLayerOnly, u4InfoBufLen,
402 /* General Operational Characteristics */
404 /* Ethernet Operational Characteristics */
405 {OID_802_3_CURRENT_ADDRESS
,
406 DISP_STRING("OID_802_3_CURRENT_ADDRESS"),
407 TRUE
, TRUE
, ENUM_OID_DRIVER_CORE
, 6,
408 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQueryCurrentAddr
,
411 /* OID_802_3_MULTICAST_LIST */
412 /* OID_802_3_MAXIMUM_LIST_SIZE */
413 /* Ethernet Statistics */
415 /* NDIS 802.11 Wireless LAN OIDs */
416 {OID_802_11_SUPPORTED_RATES
,
417 DISP_STRING("OID_802_11_SUPPORTED_RATES"),
418 TRUE
, FALSE
, ENUM_OID_DRIVER_CORE
, sizeof(PARAM_RATES_EX
),
419 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQuerySupportedRates
,
422 {OID_802_11_CONFIGURATION,
423 DISP_STRING("OID_802_11_CONFIGURATION"),
424 TRUE, TRUE, ENUM_OID_GLUE_EXTENSION, sizeof(PARAM_802_11_CONFIG_T),
425 (PFN_OID_HANDLER_FUNC_REQ)reqExtQueryConfiguration,
426 (PFN_OID_HANDLER_FUNC_REQ)reqExtSetConfiguration},
429 DISP_STRING("OID_PNP_SET_POWER"),
430 TRUE
, FALSE
, ENUM_OID_GLUE_EXTENSION
, sizeof(PARAM_DEVICE_POWER_STATE
),
432 (PFN_OID_HANDLER_FUNC_REQ
)reqExtSetAcpiDevicePowerState
},
435 {OID_CUSTOM_OID_INTERFACE_VERSION
,
436 DISP_STRING("OID_CUSTOM_OID_INTERFACE_VERSION"),
437 TRUE
, FALSE
, ENUM_OID_DRIVER_CORE
, 4,
438 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQueryOidInterfaceVersion
,
443 {OID_CUSTOM_BT_COEXIST_CTRL,
444 DISP_STRING("OID_CUSTOM_BT_COEXIST_CTRL"),
445 FALSE, TRUE, ENUM_OID_DRIVER_CORE, sizeof(PARAM_CUSTOM_BT_COEXIST_T),
447 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetBtCoexistCtrl},
452 {OID_CUSTOM_POWER_MANAGEMENT_PROFILE,
453 DISP_STRING("OID_CUSTOM_POWER_MANAGEMENT_PROFILE"),
454 FALSE, FALSE, ENUM_OID_DRIVER_CORE, 0,
455 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryPwrMgmtProfParam,
456 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetPwrMgmtProfParam},
457 {OID_CUSTOM_PATTERN_CONFIG,
458 DISP_STRING("OID_CUSTOM_PATTERN_CONFIG"),
459 TRUE, TRUE, ENUM_OID_DRIVER_CORE, sizeof(PARAM_CUSTOM_PATTERN_SEARCH_CONFIG_STRUC_T),
461 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetPatternConfig},
462 {OID_CUSTOM_BG_SSID_SEARCH_CONFIG,
463 DISP_STRING("OID_CUSTOM_BG_SSID_SEARCH_CONFIG"),
464 FALSE, FALSE, ENUM_OID_DRIVER_CORE, 0,
466 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetBgSsidParam},
467 {OID_CUSTOM_VOIP_SETUP,
468 DISP_STRING("OID_CUSTOM_VOIP_SETUP"),
469 TRUE, TRUE, ENUM_OID_DRIVER_CORE, 4,
470 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryVoipConnectionStatus,
471 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetVoipConnectionStatus},
473 DISP_STRING("OID_CUSTOM_ADD_TS"),
474 TRUE, TRUE, ENUM_OID_DRIVER_CORE, 4,
476 (PFN_OID_HANDLER_FUNC_REQ)wlanoidAddTS},
478 DISP_STRING("OID_CUSTOM_DEL_TS"),
479 TRUE, TRUE, ENUM_OID_DRIVER_CORE, 4,
481 (PFN_OID_HANDLER_FUNC_REQ)wlanoidDelTS},
485 #if CFG_LP_PATTERN_SEARCH_SLT
487 DISP_STRING("OID_CUSTOM_SLT"),
488 FALSE, FALSE, ENUM_OID_DRIVER_CORE, 0,
489 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQuerySltResult,
490 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetSltMode},
493 {OID_CUSTOM_ROAMING_EN,
494 DISP_STRING("OID_CUSTOM_ROAMING_EN"),
495 TRUE, TRUE, ENUM_OID_DRIVER_CORE, 4,
496 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryRoamingFunction,
497 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetRoamingFunction},
498 {OID_CUSTOM_WMM_PS_TEST,
499 DISP_STRING("OID_CUSTOM_WMM_PS_TEST"),
500 TRUE, TRUE, ENUM_OID_DRIVER_CORE, 4,
502 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetWiFiWmmPsTest},
503 {OID_CUSTOM_COUNTRY_STRING,
504 DISP_STRING("OID_CUSTOM_COUNTRY_STRING"),
505 FALSE, FALSE, ENUM_OID_DRIVER_CORE, 0,
506 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryCurrentCountry,
507 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetCurrentCountry},
509 #if CFG_SUPPORT_802_11D
510 {OID_CUSTOM_MULTI_DOMAIN_CAPABILITY,
511 DISP_STRING("OID_CUSTOM_MULTI_DOMAIN_CAPABILITY"),
512 FALSE, FALSE, ENUM_OID_DRIVER_CORE, 0,
513 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryMultiDomainCap,
514 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetMultiDomainCap},
517 {OID_CUSTOM_GPIO2_MODE,
518 DISP_STRING("OID_CUSTOM_GPIO2_MODE"),
519 FALSE, TRUE, ENUM_OID_DRIVER_CORE, sizeof(ENUM_PARAM_GPIO2_MODE_T),
521 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetGPIO2Mode},
522 {OID_CUSTOM_CONTINUOUS_POLL,
523 DISP_STRING("OID_CUSTOM_CONTINUOUS_POLL"),
524 FALSE, TRUE, ENUM_OID_DRIVER_CORE, sizeof(PARAM_CONTINUOUS_POLL_T),
525 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryContinuousPollInterval,
526 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetContinuousPollProfile},
527 {OID_CUSTOM_DISABLE_BEACON_DETECTION,
528 DISP_STRING("OID_CUSTOM_DISABLE_BEACON_DETECTION"),
529 FALSE, TRUE, ENUM_OID_DRIVER_CORE, 4,
530 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryDisableBeaconDetectionFunc,
531 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetDisableBeaconDetectionFunc},
536 {OID_CUSTOM_DISABLE_PRIVACY_CHECK,
537 DISP_STRING("OID_CUSTOM_DISABLE_PRIVACY_CHECK"),
538 FALSE, TRUE, ENUM_OID_DRIVER_CORE, 4,
540 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetDisablePriavcyCheck},
544 DISP_STRING("OID_CUSTOM_MCR_RW"),
545 TRUE
, TRUE
, ENUM_OID_DRIVER_CORE
, sizeof(PARAM_CUSTOM_MCR_RW_STRUC_T
),
546 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQueryMcrRead
,
547 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidSetMcrWrite
},
549 {OID_CUSTOM_EEPROM_RW
,
550 DISP_STRING("OID_CUSTOM_EEPROM_RW"),
551 TRUE
, TRUE
, ENUM_OID_DRIVER_CORE
, sizeof(PARAM_CUSTOM_EEPROM_RW_STRUC_T
),
552 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQueryEepromRead
,
553 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidSetEepromWrite
},
556 DISP_STRING("OID_CUSTOM_SW_CTRL"),
557 TRUE
, TRUE
, ENUM_OID_DRIVER_CORE
, sizeof(PARAM_CUSTOM_SW_CTRL_STRUC_T
),
558 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQuerySwCtrlRead
,
559 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidSetSwCtrlWrite
},
561 {OID_CUSTOM_MEM_DUMP
,
562 DISP_STRING("OID_CUSTOM_MEM_DUMP"),
563 TRUE
, TRUE
, ENUM_OID_DRIVER_CORE
, sizeof(PARAM_CUSTOM_MEM_DUMP_STRUC_T
),
564 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQueryMemDump
,
567 {OID_CUSTOM_TEST_MODE
,
568 DISP_STRING("OID_CUSTOM_TEST_MODE"),
569 FALSE
, FALSE
, ENUM_OID_DRIVER_CORE
, 0,
571 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidRftestSetTestMode
},
574 {OID_CUSTOM_TEST_RX_STATUS,
575 DISP_STRING("OID_CUSTOM_TEST_RX_STATUS"),
576 FALSE, TRUE, ENUM_OID_DRIVER_CORE, sizeof(PARAM_CUSTOM_RFTEST_RX_STATUS_STRUC_T),
577 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryRfTestRxStatus,
579 {OID_CUSTOM_TEST_TX_STATUS,
580 DISP_STRING("OID_CUSTOM_TEST_TX_STATUS"),
581 FALSE, TRUE, ENUM_OID_DRIVER_CORE, sizeof(PARAM_CUSTOM_RFTEST_TX_STATUS_STRUC_T),
582 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryRfTestTxStatus,
585 {OID_CUSTOM_ABORT_TEST_MODE
,
586 DISP_STRING("OID_CUSTOM_ABORT_TEST_MODE"),
587 FALSE
, FALSE
, ENUM_OID_DRIVER_CORE
, 0,
589 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidRftestSetAbortTestMode
},
590 {OID_CUSTOM_MTK_WIFI_TEST
,
591 DISP_STRING("OID_CUSTOM_MTK_WIFI_TEST"),
592 TRUE
, TRUE
, ENUM_OID_DRIVER_CORE
, sizeof(PARAM_MTK_WIFI_TEST_STRUC_T
),
593 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidRftestQueryAutoTest
,
594 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidRftestSetAutoTest
},
596 /* OID_CUSTOM_EMULATION_VERSION_CONTROL */
599 #if CFG_SUPPORT_BCM && CFG_SUPPORT_BCM_BWCS
600 {OID_CUSTOM_BWCS_CMD
,
601 DISP_STRING("OID_CUSTOM_BWCS_CMD"),
602 FALSE
, FALSE
, ENUM_OID_DRIVER_CORE
, sizeof(PTA_IPC_T
),
603 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQueryBT
,
604 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidSetBT
},
607 /* {OID_CUSTOM_SINGLE_ANTENNA,
608 DISP_STRING("OID_CUSTOM_SINGLE_ANTENNA"),
609 FALSE, FALSE, ENUM_OID_DRIVER_CORE, 4,
610 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryBtSingleAntenna,
611 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetBtSingleAntenna},
613 DISP_STRING("OID_CUSTOM_SET_PTA"),
614 FALSE, FALSE, ENUM_OID_DRIVER_CORE, 4,
615 (PFN_OID_HANDLER_FUNC_REQ)wlanoidQueryPta,
616 (PFN_OID_HANDLER_FUNC_REQ)wlanoidSetPta},
619 { OID_CUSTOM_MTK_NVRAM_RW
,
620 DISP_STRING("OID_CUSTOM_MTK_NVRAM_RW"),
621 TRUE
, TRUE
, ENUM_OID_DRIVER_CORE
, sizeof(PARAM_CUSTOM_NVRAM_RW_STRUCT_T
),
622 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQueryNvramRead
,
623 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidSetNvramWrite
},
625 { OID_CUSTOM_CFG_SRC_TYPE
,
626 DISP_STRING("OID_CUSTOM_CFG_SRC_TYPE"),
627 FALSE
, FALSE
, ENUM_OID_DRIVER_CORE
, sizeof(ENUM_CFG_SRC_TYPE_T
),
628 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQueryCfgSrcType
,
631 { OID_CUSTOM_EEPROM_TYPE
,
632 DISP_STRING("OID_CUSTOM_EEPROM_TYPE"),
633 FALSE
, FALSE
, ENUM_OID_DRIVER_CORE
, sizeof(ENUM_EEPROM_TYPE_T
),
634 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidQueryEepromType
,
638 {OID_802_11_WAPI_MODE
,
639 DISP_STRING("OID_802_11_WAPI_MODE"),
640 FALSE
, TRUE
, ENUM_OID_DRIVER_CORE
, 4,
642 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidSetWapiMode
},
643 {OID_802_11_WAPI_ASSOC_INFO
,
644 DISP_STRING("OID_802_11_WAPI_ASSOC_INFO"),
645 FALSE
, FALSE
, ENUM_OID_DRIVER_CORE
, 0,
647 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidSetWapiAssocInfo
},
648 {OID_802_11_SET_WAPI_KEY
,
649 DISP_STRING("OID_802_11_SET_WAPI_KEY"),
650 FALSE
, FALSE
, ENUM_OID_DRIVER_CORE
, sizeof(PARAM_WPI_KEY_T
),
652 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidSetWapiKey
},
656 {OID_802_11_WSC_ASSOC_INFO
,
657 DISP_STRING("OID_802_11_WSC_ASSOC_INFO"),
658 FALSE
, FALSE
, ENUM_OID_DRIVER_CORE
, 0,
660 (PFN_OID_HANDLER_FUNC_REQ
)wlanoidSetWSCAssocInfo
},
664 /*******************************************************************************
666 ********************************************************************************
669 /*----------------------------------------------------------------------------*/
671 * \brief Dispatching function for private ioctl region (SIOCIWFIRSTPRIV ~
674 * \param[in] prNetDev Net device requested.
675 * \param[in] prIfReq Pointer to ifreq structure.
676 * \param[in] i4Cmd Command ID between SIOCIWFIRSTPRIV and SIOCIWLASTPRIV.
678 * \retval 0 for success.
679 * \retval -EOPNOTSUPP If cmd is not supported.
680 * \retval -EFAULT For fail.
683 /*----------------------------------------------------------------------------*/
686 IN
struct net_device
*prNetDev
,
687 IN OUT
struct ifreq
*prIfReq
,
691 /* prIfReq is verified in the caller function wlanDoIOCTL() */
692 struct iwreq
*prIwReq
= (struct iwreq
*)prIfReq
;
693 struct iw_request_info rIwReqInfo
;
695 /* prDev is verified in the caller function wlanDoIOCTL() */
697 /* Prepare the call */
698 rIwReqInfo
.cmd
= (__u16
)i4Cmd
;
699 rIwReqInfo
.flags
= 0;
703 /* NOTE(Kevin): 1/3 INT Type <= IFNAMSIZ, so we don't need copy_from/to_user() */
704 return priv_set_int(prNetDev
, &rIwReqInfo
, &(prIwReq
->u
), (char *) &(prIwReq
->u
));
707 /* NOTE(Kevin): 1/3 INT Type <= IFNAMSIZ, so we don't need copy_from/to_user() */
708 return priv_get_int(prNetDev
, &rIwReqInfo
, &(prIwReq
->u
), (char *) &(prIwReq
->u
));
710 case IOCTL_SET_STRUCT
:
711 case IOCTL_SET_STRUCT_FOR_EM
:
712 return priv_set_struct(prNetDev
, &rIwReqInfo
, &prIwReq
->u
, (char *) &(prIwReq
->u
));
714 case IOCTL_GET_STRUCT
:
715 return priv_get_struct(prNetDev
, &rIwReqInfo
, &prIwReq
->u
, (char *) &(prIwReq
->u
));
720 } /* end of switch */
722 }/* priv_support_ioctl */
725 /*----------------------------------------------------------------------------*/
727 * \brief Private ioctl set int handler.
729 * \param[in] prNetDev Net device requested.
730 * \param[in] prIwReqInfo Pointer to iwreq structure.
731 * \param[in] prIwReqData The ioctl data structure, use the field of sub-command.
732 * \param[in] pcExtra The buffer with input value
734 * \retval 0 For success.
735 * \retval -EOPNOTSUPP If cmd is not supported.
736 * \retval -EINVAL If a value is out of range.
739 /*----------------------------------------------------------------------------*/
742 IN
struct net_device
*prNetDev
,
743 IN
struct iw_request_info
*prIwReqInfo
,
744 IN
union iwreq_data
*prIwReqData
,
750 P_NDIS_TRANSPORT_STRUCT prNdisReq
;
751 P_GLUE_INFO_T prGlueInfo
;
752 UINT_32 u4BufLen
= 0;
754 P_PTA_IPC_T prPtaIpc
;
761 if (FALSE
== GLUE_CHK_PR3(prNetDev
, prIwReqData
, pcExtra
)) {
764 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
766 u4SubCmd
= (UINT_32
) prIwReqData
->mode
;
767 pu4IntBuf
= (PUINT_32
) pcExtra
;
770 case PRIV_CMD_TEST_MODE
:
771 //printk("TestMode=%ld\n", pu4IntBuf[1]);
772 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
774 if (pu4IntBuf
[1] == PRIV_CMD_TEST_MAGIC_KEY
) {
775 prNdisReq
->ndisOidCmd
= OID_CUSTOM_TEST_MODE
;
777 else if (pu4IntBuf
[1] == 0) {
778 prNdisReq
->ndisOidCmd
= OID_CUSTOM_ABORT_TEST_MODE
;
784 prNdisReq
->inNdisOidlength
= 0;
785 prNdisReq
->outNdisOidLength
= 0;
787 /* Execute this OID */
788 status
= priv_set_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
791 case PRIV_CMD_TEST_CMD
:
792 //printk("CMD=0x%08lx, data=0x%08lx\n", pu4IntBuf[1], pu4IntBuf[2]);
793 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
795 kalMemCopy(&prNdisReq
->ndisOidContent
[0], &pu4IntBuf
[1], 8);
797 prNdisReq
->ndisOidCmd
= OID_CUSTOM_MTK_WIFI_TEST
;
798 prNdisReq
->inNdisOidlength
= 8;
799 prNdisReq
->outNdisOidLength
= 8;
801 /* Execute this OID */
802 status
= priv_set_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
805 #if CFG_SUPPORT_PRIV_MCR_RW
806 case PRIV_CMD_ACCESS_MCR
:
807 //printk("addr=0x%08lx, data=0x%08lx\n", pu4IntBuf[1], pu4IntBuf[2]);
808 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
810 if (!prGlueInfo
->fgMcrAccessAllowed
) {
811 if (pu4IntBuf
[1] == PRIV_CMD_TEST_MAGIC_KEY
&&
812 pu4IntBuf
[2] == PRIV_CMD_TEST_MAGIC_KEY
) {
813 prGlueInfo
->fgMcrAccessAllowed
= TRUE
;
819 kalMemCopy(&prNdisReq
->ndisOidContent
[0], &pu4IntBuf
[1], 8);
821 prNdisReq
->ndisOidCmd
= OID_CUSTOM_MCR_RW
;
822 prNdisReq
->inNdisOidlength
= 8;
823 prNdisReq
->outNdisOidLength
= 8;
825 /* Execute this OID */
826 status
= priv_set_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
830 case PRIV_CMD_SW_CTRL
:
831 //printk("addr=0x%08lx, data=0x%08lx\n", pu4IntBuf[1], pu4IntBuf[2]);
832 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
834 kalMemCopy(&prNdisReq
->ndisOidContent
[0], &pu4IntBuf
[1], 8);
836 prNdisReq
->ndisOidCmd
= OID_CUSTOM_SW_CTRL
;
837 prNdisReq
->inNdisOidlength
= 8;
838 prNdisReq
->outNdisOidLength
= 8;
840 /* Execute this OID */
841 status
= priv_set_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
846 case PRIV_CMD_BEACON_PERIOD
:
847 rStatus
= wlanSetInformation(prGlueInfo
->prAdapter
,
848 wlanoidSetBeaconInterval
,
849 (PVOID
)&pu4IntBuf
[1], /* pu4IntBuf[0] is used as input SubCmd */
855 #if CFG_TCP_IP_CHKSUM_OFFLOAD
856 case PRIV_CMD_CSUM_OFFLOAD
:
861 if (pu4IntBuf
[1] == 1) {
862 u4CSUMFlags
= CSUM_OFFLOAD_EN_ALL
;
864 else if (pu4IntBuf
[1] == 0) {
871 if (kalIoctl(prGlueInfo
,
872 wlanoidSetCSUMOffload
,
880 ) == WLAN_STATUS_SUCCESS
) {
881 if (pu4IntBuf
[1] == 1) {
882 prNetDev
->features
|= NETIF_F_HW_CSUM
;
883 } else if (pu4IntBuf
[1] == 0) {
884 prNetDev
->features
&= ~NETIF_F_HW_CSUM
;
889 #endif /* CFG_TCP_IP_CHKSUM_OFFLOAD */
891 case PRIV_CMD_POWER_MODE
:
893 wlanoidSet802dot11PowerSaveProfile
,
894 (PVOID
)&pu4IntBuf
[1], /* pu4IntBuf[0] is used as input SubCmd */
903 case PRIV_CMD_WMM_PS
:
905 PARAM_CUSTOM_WMM_PS_TEST_STRUC_T rWmmPsTest
;
907 rWmmPsTest
.bmfgApsdEnAc
= (UINT_8
)pu4IntBuf
[1];
908 rWmmPsTest
.ucIsEnterPsAtOnce
= (UINT_8
)pu4IntBuf
[2];
909 rWmmPsTest
.ucIsDisableUcTrigger
= (UINT_8
)pu4IntBuf
[3];
910 rWmmPsTest
.reserved
= 0;
913 wlanoidSetWiFiWmmPsTest
,
915 sizeof(PARAM_CUSTOM_WMM_PS_TEST_STRUC_T
),
925 case PRIV_CMD_ADHOC_MODE
:
926 rStatus
= wlanSetInformation(prGlueInfo
->prAdapter
,
928 (PVOID
)&pu4IntBuf
[1], /* pu4IntBuf[0] is used as input SubCmd */
934 case PRIV_CUSTOM_BWCS_CMD
:
936 DBGLOG(REQ
, INFO
, ("pu4IntBuf[1] = %x, size of PTA_IPC_T = %zu.\n",
937 pu4IntBuf
[1], sizeof(PARAM_PTA_IPC_T
)));
939 prPtaIpc
= (P_PTA_IPC_T
) aucOidBuf
;
940 prPtaIpc
->u
.aucBTPParams
[0] = (UINT_8
) (pu4IntBuf
[1] >> 24);
941 prPtaIpc
->u
.aucBTPParams
[1] = (UINT_8
) (pu4IntBuf
[1] >> 16);
942 prPtaIpc
->u
.aucBTPParams
[2] = (UINT_8
) (pu4IntBuf
[1] >> 8);
943 prPtaIpc
->u
.aucBTPParams
[3] = (UINT_8
) (pu4IntBuf
[1]);
945 DBGLOG(REQ
, INFO
, ("BCM BWCS CMD : PRIV_CUSTOM_BWCS_CMD : aucBTPParams[0] = %02x, aucBTPParams[1] = %02x, aucBTPParams[2] = %02x, aucBTPParams[3] = %02x.\n",
946 prPtaIpc
->u
.aucBTPParams
[0],
947 prPtaIpc
->u
.aucBTPParams
[1],
948 prPtaIpc
->u
.aucBTPParams
[2],
949 prPtaIpc
->u
.aucBTPParams
[3]));
952 status
= wlanSetInformation(prGlueInfo
->prAdapter
,
954 (PVOID
)&aucOidBuf
[0],
959 status
= wlanoidSetBT(prGlueInfo
->prAdapter
,
960 (PVOID
)&aucOidBuf
[0],
961 sizeof(PARAM_PTA_IPC_T
),
964 if (WLAN_STATUS_SUCCESS
!= status
) {
970 case PRIV_CMD_BAND_CONFIG
:
972 DBGLOG(INIT
, INFO
, ("CMD set_band=%u\n", (UINT_32
)pu4IntBuf
[1]));
976 #if CFG_ENABLE_WIFI_DIRECT
977 case PRIV_CMD_P2P_MODE
:
979 /* no use, move to set_p2p_mode_handler() */
980 extern int set_p2p_mode_handler(struct net_device
*netdev
, PARAM_CUSTOM_P2P_SET_STRUC_T p2pmode
);
981 PARAM_CUSTOM_P2P_SET_STRUC_T p2pmode
;
982 p2pmode
.u4Enable
= pu4IntBuf
[1];
983 p2pmode
.u4Mode
= pu4IntBuf
[2];
984 set_p2p_mode_handler(prNetDev
, p2pmode
);
986 extern BOOLEAN fgIsResetting
;
987 extern BOOLEAN g_u4HaltFlag
;
988 extern spinlock_t g_p2p_lock
;
989 extern int g_u4P2PEnding
;
990 extern int g_u4P2POnOffing
;
991 PARAM_CUSTOM_P2P_SET_STRUC_T rSetP2P
;
992 WLAN_STATUS rWlanStatus
= WLAN_STATUS_SUCCESS
;
993 BOOLEAN fgIsP2PEnding
;
994 GLUE_SPIN_LOCK_DECLARATION();
996 /* avoid remove & p2p off command simultaneously */
997 GLUE_ACQUIRE_THE_SPIN_LOCK(&g_p2p_lock
);
998 fgIsP2PEnding
= g_u4P2PEnding
;
1000 GLUE_RELEASE_THE_SPIN_LOCK(&g_p2p_lock
);
1002 if (fgIsP2PEnding
== 1)
1004 /* skip the command if we are removing */
1005 GLUE_ACQUIRE_THE_SPIN_LOCK(&g_p2p_lock
);
1006 g_u4P2POnOffing
= 0;
1007 GLUE_RELEASE_THE_SPIN_LOCK(&g_p2p_lock
);
1010 rSetP2P
.u4Enable
= pu4IntBuf
[1];
1011 rSetP2P
.u4Mode
= pu4IntBuf
[2];
1013 if(!rSetP2P
.u4Enable
) {
1014 p2pNetUnregister(prGlueInfo
, TRUE
);
1018 /* move out to caller to avoid kalIoctrl & suspend/resume deadlock problem ALPS00844864 */
1021 1. System enters suspend/resume but not yet enter wlanearlysuspend()
1022 or wlanlateresume();
1024 2. System switches to do PRIV_CMD_P2P_MODE and execute kalIoctl()
1025 and get g_halt_sem then do glRegisterEarlySuspend() or
1026 glUnregisterEarlySuspend();
1028 But system suspend/resume procedure is not yet finished so we
1031 3. System switches back to do suspend/resume procedure and execute
1032 kalIoctl(). But driver does not yet release g_halt_sem so system
1033 suspend in wlanearlysuspend() or wlanlateresume();
1035 ==> deadlock occurs.
1037 if ((!rSetP2P
.u4Enable
) && (g_u4HaltFlag
== 0) &&
1038 (fgIsResetting
== FALSE
))
1040 /* fgIsP2PRegistered == TRUE means P2P is enabled */
1041 DBGLOG(P2P
, INFO
, ("p2pEalySuspendReg\n"));
1042 p2pEalySuspendReg(prGlueInfo
, rSetP2P
.u4Enable
); /* p2p remove */
1045 DBGLOG(P2P
, INFO
, ("wlanoidSetP2pMode 0x%p %d %d\n", &rSetP2P
, rSetP2P
.u4Enable
, rSetP2P
.u4Mode
));
1046 rWlanStatus
= kalIoctl(prGlueInfo
,
1048 (PVOID
)&rSetP2P
, /* pu4IntBuf[0] is used as input SubCmd */
1049 sizeof(PARAM_CUSTOM_P2P_SET_STRUC_T
),
1055 DBGLOG(P2P
, INFO
, ("wlanoidSetP2pMode ok\n"));
1057 /* move out to caller to avoid kalIoctrl & suspend/resume deadlock problem ALPS00844864 */
1058 if ((rSetP2P
.u4Enable
) && (g_u4HaltFlag
== 0) &&
1059 (fgIsResetting
== FALSE
))
1061 /* fgIsP2PRegistered == TRUE means P2P on successfully */
1062 p2pEalySuspendReg(prGlueInfo
, rSetP2P
.u4Enable
); /* p2p on */
1065 if(rSetP2P
.u4Enable
) {
1066 p2pNetRegister(prGlueInfo
, TRUE
);
1069 GLUE_ACQUIRE_THE_SPIN_LOCK(&g_p2p_lock
);
1070 g_u4P2POnOffing
= 0;
1071 GLUE_RELEASE_THE_SPIN_LOCK(&g_p2p_lock
);
1077 #if (CFG_SUPPORT_MET_PROFILING == 1)
1078 case PRIV_CMD_MET_PROFILING
:
1080 //PARAM_CUSTOM_WFD_DEBUG_STRUC_T rWfdDebugModeInfo;
1081 //rWfdDebugModeInfo.ucWFDDebugMode=(UINT_8)pu4IntBuf[1];
1082 //rWfdDebugModeInfo.u2SNPeriod=(UINT_16)pu4IntBuf[2];
1083 //DBGLOG(REQ, INFO,("WFD Debug Mode:%d Peroid:%d\n",rWfdDebugModeInfo.ucWFDDebugMode,rWfdDebugModeInfo.u2SNPeriod));
1084 prGlueInfo
->u8MetProfEnable
= (UINT_8
)pu4IntBuf
[1];
1085 prGlueInfo
->u16MetUdpPort
= (UINT_16
)pu4IntBuf
[2];
1086 printk("MET_PROF: Enable=%d UDP_PORT=%d\n", prGlueInfo
->u8MetProfEnable
, prGlueInfo
->u16MetUdpPort
);
1101 /*----------------------------------------------------------------------------*/
1103 * \brief Private ioctl get int handler.
1105 * \param[in] pDev Net device requested.
1106 * \param[out] pIwReq Pointer to iwreq structure.
1107 * \param[in] prIwReqData The ioctl req structure, use the field of sub-command.
1108 * \param[out] pcExtra The buffer with put the return value
1110 * \retval 0 For success.
1111 * \retval -EOPNOTSUPP If cmd is not supported.
1112 * \retval -EFAULT For fail.
1115 /*----------------------------------------------------------------------------*/
1116 UINT_8 gucBufDbgCode
[1000];
1120 IN
struct net_device
*prNetDev
,
1121 IN
struct iw_request_info
*prIwReqInfo
,
1122 IN
union iwreq_data
*prIwReqData
,
1123 IN OUT
char *pcExtra
1128 P_GLUE_INFO_T prGlueInfo
;
1129 UINT_32 u4BufLen
= 0;
1131 P_NDIS_TRANSPORT_STRUCT prNdisReq
;
1135 ASSERT(prIwReqInfo
);
1136 ASSERT(prIwReqData
);
1138 if (FALSE
== GLUE_CHK_PR3(prNetDev
, prIwReqData
, pcExtra
)) {
1141 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
1143 u4SubCmd
= (UINT_32
) prIwReqData
->mode
;
1144 pu4IntBuf
= (PUINT_32
) pcExtra
;
1147 case PRIV_CMD_TEST_CMD
:
1148 //printk("CMD=0x%08lx, data=0x%08lx\n", pu4IntBuf[1], pu4IntBuf[2]);
1149 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
1151 kalMemCopy(&prNdisReq
->ndisOidContent
[0], &pu4IntBuf
[1], 8);
1153 prNdisReq
->ndisOidCmd
= OID_CUSTOM_MTK_WIFI_TEST
;
1154 prNdisReq
->inNdisOidlength
= 8;
1155 prNdisReq
->outNdisOidLength
= 8;
1157 status
= priv_get_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
1159 //printk("Result=%ld\n", *(PUINT_32)&prNdisReq->ndisOidContent[4]);
1160 prIwReqData
->mode
= *(PUINT_32
)&prNdisReq
->ndisOidContent
[4];
1162 if (copy_to_user(prIwReqData->data.pointer,
1163 &prNdisReq->ndisOidContent[4], 4)) {
1164 printk(KERN_NOTICE "priv_get_int() copy_to_user oidBuf fail(3)\n");
1171 #if CFG_SUPPORT_PRIV_MCR_RW
1172 case PRIV_CMD_ACCESS_MCR
:
1173 //printk("addr=0x%08lx\n", pu4IntBuf[1]);
1174 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
1176 if (!prGlueInfo
->fgMcrAccessAllowed
) {
1181 kalMemCopy(&prNdisReq
->ndisOidContent
[0], &pu4IntBuf
[1], 8);
1183 prNdisReq
->ndisOidCmd
= OID_CUSTOM_MCR_RW
;
1184 prNdisReq
->inNdisOidlength
= 8;
1185 prNdisReq
->outNdisOidLength
= 8;
1187 status
= priv_get_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
1189 //printk("Result=%ld\n", *(PUINT_32)&prNdisReq->ndisOidContent[4]);
1190 prIwReqData
->mode
= *(PUINT_32
)&prNdisReq
->ndisOidContent
[4];
1195 case PRIV_CMD_DUMP_MEM
:
1196 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
1199 if (!prGlueInfo
->fgMcrAccessAllowed
) {
1204 kalMemCopy(&prNdisReq
->ndisOidContent
[0], &pu4IntBuf
[1], 8);
1206 prNdisReq
->ndisOidCmd
= OID_CUSTOM_MEM_DUMP
;
1207 prNdisReq
->inNdisOidlength
= 8;
1208 prNdisReq
->outNdisOidLength
= 8;
1210 status
= priv_get_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
1212 prIwReqData
->mode
= *(PUINT_32
)&prNdisReq
->ndisOidContent
[0];
1216 case PRIV_CMD_SW_CTRL
:
1217 //printk(" addr=0x%08lx\n", pu4IntBuf[1]);
1219 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
1221 kalMemCopy(&prNdisReq
->ndisOidContent
[0], &pu4IntBuf
[1], 8);
1223 prNdisReq
->ndisOidCmd
= OID_CUSTOM_SW_CTRL
;
1224 prNdisReq
->inNdisOidlength
= 8;
1225 prNdisReq
->outNdisOidLength
= 8;
1227 status
= priv_get_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
1229 //printk("Result=%ld\n", *(PUINT_32)&prNdisReq->ndisOidContent[4]);
1230 prIwReqData
->mode
= *(PUINT_32
)&prNdisReq
->ndisOidContent
[4];
1235 case PRIV_CMD_BEACON_PERIOD
:
1236 status
= wlanQueryInformation(prGlueInfo
->prAdapter
,
1237 wlanoidQueryBeaconInterval
,
1243 case PRIV_CMD_POWER_MODE
:
1244 status
= wlanQueryInformation(prGlueInfo
->prAdapter
,
1245 wlanoidQuery802dot11PowerSaveProfile
,
1251 case PRIV_CMD_ADHOC_MODE
:
1252 status
= wlanQueryInformation(prGlueInfo
->prAdapter
,
1253 wlanoidQueryAdHocMode
,
1260 case PRIV_CMD_BAND_CONFIG
:
1261 DBGLOG(INIT
, INFO
, ("CMD get_band=\n"));
1262 prIwReqData
->mode
= 0;
1269 u4SubCmd
= (UINT_32
) prIwReqData
->data
.flags
;
1272 case PRIV_CMD_GET_CH_LIST
:
1275 UINT_8 NumOfChannel
= 50;
1276 UINT_8 ucMaxChannelNum
= 50;
1277 RF_CHANNEL_INFO_T aucChannelList
[50];
1279 kalGetChannelList(prGlueInfo
, BAND_NULL
, ucMaxChannelNum
, &NumOfChannel
, aucChannelList
);
1280 if (NumOfChannel
> 50)
1283 if (kalIsAPmode(prGlueInfo
)) {
1284 for (i
= 0; i
< NumOfChannel
; i
++) {
1285 if ((aucChannelList
[i
].ucChannelNum
<= 13) ||
1286 (aucChannelList
[i
].ucChannelNum
== 36 || aucChannelList
[i
].ucChannelNum
== 40 ||
1287 aucChannelList
[i
].ucChannelNum
== 44 || aucChannelList
[i
].ucChannelNum
== 48)) {
1288 ch
[j
] = (INT_32
)aucChannelList
[i
].ucChannelNum
;
1294 for (j
= 0; j
< NumOfChannel
; j
++) {
1295 ch
[j
] = (INT_32
)aucChannelList
[j
].ucChannelNum
;
1299 prIwReqData
->data
.length
= j
;
1300 if (copy_to_user(prIwReqData
->data
.pointer
, ch
, NumOfChannel
*sizeof(INT_32
))) {
1307 case PRIV_CMD_GET_BUILD_DATE_CODE
:
1309 UINT_8 aucBuffer
[16];
1311 if(kalIoctl(prGlueInfo
,
1312 wlanoidQueryBuildDateCode
,
1314 sizeof(UINT_8
) * 16,
1319 &u4BufLen
) == WLAN_STATUS_SUCCESS
) {
1320 prIwReqData
->data
.length
= sizeof(UINT_8
) * 16;
1322 if (copy_to_user(prIwReqData
->data
.pointer
, aucBuffer
, prIwReqData
->data
.length
)) {
1333 case PRIV_CMD_GET_DEBUG_CODE
:
1335 wlanQueryDebugCode(prGlueInfo
->prAdapter
);
1337 kalMemSet(gucBufDbgCode
, '.', sizeof(gucBufDbgCode
));
1338 u4BufLen
= prIwReqData
->data
.length
;
1339 if (u4BufLen
> sizeof(gucBufDbgCode
))
1340 u4BufLen
= sizeof(gucBufDbgCode
);
1341 if (copy_to_user(prIwReqData
->data
.pointer
, gucBufDbgCode
, u4BufLen
)) {
1353 } /* priv_get_int */
1356 /*----------------------------------------------------------------------------*/
1358 * \brief Private ioctl set int array handler.
1360 * \param[in] prNetDev Net device requested.
1361 * \param[in] prIwReqInfo Pointer to iwreq structure.
1362 * \param[in] prIwReqData The ioctl data structure, use the field of sub-command.
1363 * \param[in] pcExtra The buffer with input value
1365 * \retval 0 For success.
1366 * \retval -EOPNOTSUPP If cmd is not supported.
1367 * \retval -EINVAL If a value is out of range.
1370 /*----------------------------------------------------------------------------*/
1373 IN
struct net_device
*prNetDev
,
1374 IN
struct iw_request_info
*prIwReqInfo
,
1375 IN
union iwreq_data
*prIwReqData
,
1379 UINT_32 u4SubCmd
, u4BufLen
;
1380 P_GLUE_INFO_T prGlueInfo
;
1382 WLAN_STATUS rStatus
= WLAN_STATUS_SUCCESS
;
1383 P_SET_TXPWR_CTRL_T prTxpwr
;
1386 ASSERT(prIwReqInfo
);
1387 ASSERT(prIwReqData
);
1390 if (FALSE
== GLUE_CHK_PR3(prNetDev
, prIwReqData
, pcExtra
)) {
1393 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
1395 u4SubCmd
= (UINT_32
) prIwReqData
->data
.flags
;
1398 case PRIV_CMD_SET_TX_POWER
:
1400 INT_32
*setting
= prIwReqData
->data
.pointer
;
1404 printk("Tx power num = %d\n", prIwReqData
->data
.length
);
1406 printk("Tx power setting = %d %d %d %d\n",
1407 setting
[0], setting
[1], setting
[2], setting
[3]);
1409 prTxpwr
= &prGlueInfo
->rTxPwr
;
1410 if (setting
[0] == 0 && prIwReqData
->data
.length
== 4 /* argc num */) {
1411 /* 0 (All networks), 1 (legacy STA), 2 (Hotspot AP), 3 (P2P), 4 (BT over Wi-Fi) */
1412 if (setting
[1] == 1 || setting
[1] == 0) {
1413 if (setting
[2] == 0 || setting
[2] == 1)
1414 prTxpwr
->c2GLegacyStaPwrOffset
= setting
[3];
1415 if (setting
[2] == 0 || setting
[2] == 2)
1416 prTxpwr
->c5GLegacyStaPwrOffset
= setting
[3];
1418 if (setting
[1] == 2 || setting
[1] == 0) {
1419 if (setting
[2] == 0 || setting
[2] == 1)
1420 prTxpwr
->c2GHotspotPwrOffset
= setting
[3];
1421 if (setting
[2] == 0 || setting
[2] == 2)
1422 prTxpwr
->c5GHotspotPwrOffset
= setting
[3];
1424 if (setting
[1] == 3 || setting
[1] == 0) {
1425 if (setting
[2] == 0 || setting
[2] == 1)
1426 prTxpwr
->c2GP2pPwrOffset
= setting
[3];
1427 if (setting
[2] == 0 || setting
[2] == 2)
1428 prTxpwr
->c5GP2pPwrOffset
= setting
[3];
1430 if (setting
[1] == 4 || setting
[1] == 0) {
1431 if (setting
[2] == 0 || setting
[2] == 1)
1432 prTxpwr
->c2GBowPwrOffset
= setting
[3];
1433 if (setting
[2] == 0 || setting
[2] == 2)
1434 prTxpwr
->c5GBowPwrOffset
= setting
[3];
1437 else if (setting
[0] == 1 && prIwReqData
->data
.length
== 2) {
1438 prTxpwr
->ucConcurrencePolicy
= setting
[1];
1440 else if (setting
[0] == 2 && prIwReqData
->data
.length
== 3) {
1441 if (setting
[1] == 0) {
1442 for (i
=0; i
<14; i
++)
1443 prTxpwr
->acTxPwrLimit2G
[i
] = setting
[2];
1445 else if (setting
[1] <= 14)
1446 prTxpwr
->acTxPwrLimit2G
[setting
[1] - 1] = setting
[2];
1448 else if (setting
[0] == 3 && prIwReqData
->data
.length
== 3) {
1449 if (setting
[1] == 0) {
1451 prTxpwr
->acTxPwrLimit5G
[i
] = setting
[2];
1453 else if (setting
[1] <= 4)
1454 prTxpwr
->acTxPwrLimit5G
[setting
[1] - 1] = setting
[2];
1456 else if (setting
[0] == 4 && prIwReqData
->data
.length
== 2) {
1457 if (setting
[1] == 0) {
1458 wlanDefTxPowerCfg(prGlueInfo
->prAdapter
);
1460 rStatus
= kalIoctl(prGlueInfo
,
1463 sizeof(SET_TXPWR_CTRL_T
),
1482 /*----------------------------------------------------------------------------*/
1484 * \brief Private ioctl get int array handler.
1486 * \param[in] pDev Net device requested.
1487 * \param[out] pIwReq Pointer to iwreq structure.
1488 * \param[in] prIwReqData The ioctl req structure, use the field of sub-command.
1489 * \param[out] pcExtra The buffer with put the return value
1491 * \retval 0 For success.
1492 * \retval -EOPNOTSUPP If cmd is not supported.
1493 * \retval -EFAULT For fail.
1496 /*----------------------------------------------------------------------------*/
1499 IN
struct net_device
*prNetDev
,
1500 IN
struct iw_request_info
*prIwReqInfo
,
1501 IN
union iwreq_data
*prIwReqData
,
1502 IN OUT
char *pcExtra
1506 P_GLUE_INFO_T prGlueInfo
;
1511 ASSERT(prIwReqInfo
);
1512 ASSERT(prIwReqData
);
1514 if (FALSE
== GLUE_CHK_PR3(prNetDev
, prIwReqData
, pcExtra
)) {
1517 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
1519 u4SubCmd
= (UINT_32
) prIwReqData
->data
.flags
;
1522 case PRIV_CMD_GET_CH_LIST
:
1525 UINT_8 NumOfChannel
= 50;
1526 UINT_8 ucMaxChannelNum
= 50;
1527 RF_CHANNEL_INFO_T aucChannelList
[50];
1529 kalGetChannelList(prGlueInfo
, BAND_NULL
, ucMaxChannelNum
, &NumOfChannel
, aucChannelList
);
1530 if (NumOfChannel
> 50)
1533 for (i
= 0; i
< NumOfChannel
; i
++) {
1534 ch
[i
] = (INT_32
)aucChannelList
[i
].ucChannelNum
;
1537 prIwReqData
->data
.length
= NumOfChannel
;
1538 if (copy_to_user(prIwReqData
->data
.pointer
, ch
, NumOfChannel
*sizeof(INT_32
))) {
1549 } /* priv_get_int */
1551 /*----------------------------------------------------------------------------*/
1553 * \brief Private ioctl set structure handler.
1555 * \param[in] pDev Net device requested.
1556 * \param[in] prIwReqData Pointer to iwreq_data structure.
1558 * \retval 0 For success.
1559 * \retval -EOPNOTSUPP If cmd is not supported.
1560 * \retval -EINVAL If a value is out of range.
1563 /*----------------------------------------------------------------------------*/
1566 IN
struct net_device
*prNetDev
,
1567 IN
struct iw_request_info
*prIwReqInfo
,
1568 IN
union iwreq_data
*prIwReqData
,
1572 UINT_32 u4SubCmd
= 0;
1574 //WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
1575 UINT_32 u4CmdLen
= 0;
1576 P_NDIS_TRANSPORT_STRUCT prNdisReq
;
1577 PUINT_32 pu4IntBuf
= NULL
;
1579 P_GLUE_INFO_T prGlueInfo
= NULL
;
1580 UINT_32 u4BufLen
= 0;
1583 //ASSERT(prIwReqInfo);
1584 ASSERT(prIwReqData
);
1587 kalMemZero(&aucOidBuf
[0], sizeof(aucOidBuf
));
1589 if (FALSE
== GLUE_CHK_PR2(prNetDev
, prIwReqData
)) {
1592 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
1594 u4SubCmd
= (UINT_32
) prIwReqData
->data
.flags
;
1597 printk(KERN_INFO DRV_NAME
"priv_set_struct(): prIwReqInfo->cmd(0x%X), u4SubCmd(%ld)\n",
1605 case PRIV_CMD_BT_COEXIST
:
1606 u4CmdLen
= prIwReqData
->data
.length
* sizeof(UINT_32
);
1607 ASSERT(sizeof(PARAM_CUSTOM_BT_COEXIST_T
) >= u4CmdLen
);
1608 if (sizeof(PARAM_CUSTOM_BT_COEXIST_T
) < u4CmdLen
) {
1612 if (copy_from_user(&aucOidBuf
[0], prIwReqData
->data
.pointer
, u4CmdLen
)) {
1613 status
= -EFAULT
; //return -EFAULT;
1617 rStatus
= wlanSetInformation(prGlueInfo
->prAdapter
,
1618 wlanoidSetBtCoexistCtrl
,
1619 (PVOID
)&aucOidBuf
[0],
1622 if (WLAN_STATUS_SUCCESS
!= rStatus
) {
1628 case PRIV_CUSTOM_BWCS_CMD
:
1629 u4CmdLen
= prIwReqData
->data
.length
* sizeof(UINT_32
);
1630 ASSERT(sizeof(PARAM_PTA_IPC_T
) >= u4CmdLen
);
1631 if (sizeof(PARAM_PTA_IPC_T
) < u4CmdLen
) {
1634 #if CFG_SUPPORT_BCM && CFG_SUPPORT_BCM_BWCS && CFG_SUPPORT_BCM_BWCS_DEBUG
1635 DBGLOG(REQ
, INFO
, ("ucCmdLen = %d, size of PTA_IPC_T = %d, prIwReqData->data = 0x%x.\n", u4CmdLen
, sizeof(PARAM_PTA_IPC_T
), prIwReqData
->data
));
1637 DBGLOG(REQ
, INFO
, ("priv_set_struct(): prIwReqInfo->cmd(0x%X), u4SubCmd(%u)\n",
1642 DBGLOG(REQ
, INFO
, ("*pcExtra = 0x%x\n", *pcExtra
));
1645 if (copy_from_user(&aucOidBuf
[0], prIwReqData
->data
.pointer
, u4CmdLen
)) {
1646 status
= -EFAULT
; //return -EFAULT;
1649 #if CFG_SUPPORT_BCM && CFG_SUPPORT_BCM_BWCS && CFG_SUPPORT_BCM_BWCS_DEBUG
1650 DBGLOG(REQ
, INFO
, ("priv_set_struct(): BWCS CMD = %02x%02x%02x%02x\n",
1651 aucOidBuf
[2], aucOidBuf
[3], aucOidBuf
[4], aucOidBuf
[5]));
1655 status
= wlanSetInformation(prGlueInfo
->prAdapter
,
1657 (PVOID
)&aucOidBuf
[0],
1663 status
= wlanoidSetBT(prGlueInfo
->prAdapter
,
1664 (PVOID
)&aucOidBuf
[0],
1669 if (WLAN_STATUS_SUCCESS
!= status
) {
1675 #if CFG_SUPPORT_WPS2
1676 case PRIV_CMD_WSC_PROBE_REQ
:
1678 /* retrieve IE for Probe Request */
1679 if (prIwReqData
->data
.length
> 0) {
1680 if (copy_from_user(prGlueInfo
->aucWSCIE
, prIwReqData
->data
.pointer
,
1681 prIwReqData
->data
.length
)) {
1685 prGlueInfo
->u2WSCIELen
= prIwReqData
->data
.length
;
1688 prGlueInfo
->u2WSCIELen
= 0;
1694 if (copy_from_user(&aucOidBuf
[0],
1695 prIwReqData
->data
.pointer
,
1696 prIwReqData
->data
.length
)) {
1700 if (!kalMemCmp(&aucOidBuf
[0], pcExtra
, prIwReqData
->data
.length
)) {
1701 DBGLOG(REQ
, INFO
, ("pcExtra buffer is valid\n"));
1704 DBGLOG(REQ
, INFO
, ("pcExtra 0x%p\n", pcExtra
));
1706 /* Execute this OID */
1707 status
= priv_set_ndis(prNetDev
, (P_NDIS_TRANSPORT_STRUCT
)&aucOidBuf
[0], &u4BufLen
);
1708 /* Copy result to user space */
1709 ((P_NDIS_TRANSPORT_STRUCT
)&aucOidBuf
[0])->outNdisOidLength
= u4BufLen
;
1711 if (copy_to_user(prIwReqData
->data
.pointer
,
1713 OFFSET_OF(NDIS_TRANSPORT_STRUCT
, ndisOidContent
))) {
1714 DBGLOG(REQ
, INFO
, ("copy_to_user oidBuf fail\n"));
1720 case PRIV_CMD_SW_CTRL
:
1721 pu4IntBuf
= (PUINT_32
)prIwReqData
->data
.pointer
;
1722 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
1724 //kalMemCopy(&prNdisReq->ndisOidContent[0], prIwReqData->data.pointer, 8);
1725 if (copy_from_user(&prNdisReq
->ndisOidContent
[0],
1726 prIwReqData
->data
.pointer
,
1727 prIwReqData
->data
.length
)) {
1731 prNdisReq
->ndisOidCmd
= OID_CUSTOM_SW_CTRL
;
1732 prNdisReq
->inNdisOidlength
= 8;
1733 prNdisReq
->outNdisOidLength
= 8;
1735 /* Execute this OID */
1736 status
= priv_set_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
1746 /*----------------------------------------------------------------------------*/
1748 * \brief Private ioctl get struct handler.
1750 * \param[in] pDev Net device requested.
1751 * \param[out] pIwReq Pointer to iwreq structure.
1752 * \param[in] cmd Private sub-command.
1754 * \retval 0 For success.
1755 * \retval -EFAULT If copy from user space buffer fail.
1756 * \retval -EOPNOTSUPP Parameter "cmd" not recognized.
1759 /*----------------------------------------------------------------------------*/
1762 IN
struct net_device
*prNetDev
,
1763 IN
struct iw_request_info
*prIwReqInfo
,
1764 IN
union iwreq_data
*prIwReqData
,
1765 IN OUT
char *pcExtra
1768 UINT_32 u4SubCmd
= 0;
1769 P_NDIS_TRANSPORT_STRUCT prNdisReq
= NULL
;
1771 P_GLUE_INFO_T prGlueInfo
= NULL
;
1772 UINT_32 u4BufLen
= 0;
1773 PUINT_32 pu4IntBuf
= NULL
;
1775 UINT_32 u4CopyDataMax
= 0;
1777 kalMemZero(&aucOidBuf
[0], sizeof(aucOidBuf
));
1780 ASSERT(prIwReqData
);
1781 if (!prNetDev
|| !prIwReqData
) {
1782 DBGLOG(REQ
, INFO
, ("priv_get_struct(): invalid param(0x%p, 0x%p)\n",
1783 prNetDev
, prIwReqData
));
1787 u4SubCmd
= (UINT_32
) prIwReqData
->data
.flags
;
1788 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
1791 DBGLOG(REQ
, INFO
, ("priv_get_struct(): invalid prGlueInfo(0x%p, 0x%p)\n",
1792 prNetDev
, *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
))));
1797 printk(KERN_INFO DRV_NAME
"priv_get_struct(): prIwReqInfo->cmd(0x%X), u4SubCmd(%ld)\n",
1802 memset(aucOidBuf
, 0, sizeof(aucOidBuf
));
1806 if (copy_from_user(&aucOidBuf
[0],
1807 prIwReqData
->data
.pointer
,
1808 sizeof(NDIS_TRANSPORT_STRUCT
))) {
1809 DBGLOG(REQ
, INFO
, ("priv_get_struct() copy_from_user oidBuf fail\n"));
1813 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
)&aucOidBuf
[0];
1815 printk(KERN_NOTICE
"\n priv_get_struct cmd 0x%02x len:%d OID:0x%08x OID Len:%d\n",
1817 pIwReq
->u
.data
.length
,
1818 ndisReq
->ndisOidCmd
,
1819 ndisReq
->inNdisOidlength
);
1821 if (priv_get_ndis(prNetDev
, prNdisReq
, &u4BufLen
) == 0) {
1822 prNdisReq
->outNdisOidLength
= u4BufLen
;
1823 if (copy_to_user(prIwReqData
->data
.pointer
,
1825 u4BufLen
+ sizeof(NDIS_TRANSPORT_STRUCT
) - sizeof(prNdisReq
->ndisOidContent
))) {
1826 DBGLOG(REQ
, INFO
, ("priv_get_struct() copy_to_user oidBuf fail(1)\n"));
1832 prNdisReq
->outNdisOidLength
= u4BufLen
;
1833 if (copy_to_user(prIwReqData
->data
.pointer
,
1835 OFFSET_OF(NDIS_TRANSPORT_STRUCT
, ndisOidContent
))) {
1836 DBGLOG(REQ
, INFO
, ("priv_get_struct() copy_to_user oidBuf fail(2)\n"));
1842 case PRIV_CMD_SW_CTRL
:
1843 pu4IntBuf
= (PUINT_32
)prIwReqData
->data
.pointer
;
1844 prNdisReq
= (P_NDIS_TRANSPORT_STRUCT
) &aucOidBuf
[0];
1846 u4CopyDataMax
= sizeof(aucOidBuf
) - OFFSET_OF(NDIS_TRANSPORT_STRUCT
, ndisOidContent
);
1847 if ((prIwReqData
->data
.length
> u4CopyDataMax
)
1848 || copy_from_user(&prNdisReq
->ndisOidContent
[0],
1849 prIwReqData
->data
.pointer
,
1850 prIwReqData
->data
.length
)) {
1851 DBGLOG(REQ
, INFO
, ("priv_get_struct() copy_from_user oidBuf fail\n"));
1855 prNdisReq
->ndisOidCmd
= OID_CUSTOM_SW_CTRL
;
1856 prNdisReq
->inNdisOidlength
= 8;
1857 prNdisReq
->outNdisOidLength
= 8;
1859 status
= priv_get_ndis(prNetDev
, prNdisReq
, &u4BufLen
);
1861 prNdisReq
->outNdisOidLength
= u4BufLen
;
1862 //printk("len=%d Result=%08lx\n", u4BufLen, *(PUINT_32)&prNdisReq->ndisOidContent[4]);
1864 if (copy_to_user(prIwReqData
->data
.pointer
,
1865 &prNdisReq
->ndisOidContent
[4],
1866 4 /* OFFSET_OF(NDIS_TRANSPORT_STRUCT, ndisOidContent)*/)) {
1867 DBGLOG(REQ
, INFO
, ("priv_get_struct() copy_to_user oidBuf fail(2)\n"));
1873 DBGLOG(REQ
, WARN
, ("get struct cmd:0x%x\n", u4SubCmd
));
1876 } /* priv_get_struct */
1878 /*----------------------------------------------------------------------------*/
1880 * \brief The routine handles a set operation for a single OID.
1882 * \param[in] pDev Net device requested.
1883 * \param[in] ndisReq Ndis request OID information copy from user.
1884 * \param[out] outputLen_p If the call is successful, returns the number of
1885 * bytes written into the query buffer. If the
1886 * call failed due to invalid length of the query
1887 * buffer, returns the amount of storage needed..
1889 * \retval 0 On success.
1890 * \retval -EOPNOTSUPP If cmd is not supported.
1893 /*----------------------------------------------------------------------------*/
1896 IN
struct net_device
*prNetDev
,
1897 IN NDIS_TRANSPORT_STRUCT
* prNdisReq
,
1898 OUT PUINT_32 pu4OutputLen
1901 P_WLAN_REQ_ENTRY prWlanReqEntry
= NULL
;
1902 WLAN_STATUS status
= WLAN_STATUS_SUCCESS
;
1903 P_GLUE_INFO_T prGlueInfo
= NULL
;
1904 UINT_32 u4SetInfoLen
= 0;
1908 ASSERT(pu4OutputLen
);
1910 if (!prNetDev
|| !prNdisReq
|| !pu4OutputLen
) {
1911 DBGLOG(REQ
, INFO
, ("priv_set_ndis(): invalid param(0x%p, 0x%p, 0x%p)\n",
1912 prNetDev
, prNdisReq
, pu4OutputLen
));
1916 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
1919 DBGLOG(REQ
, INFO
, ("priv_set_ndis(): invalid prGlueInfo(0x%p, 0x%p)\n",
1920 prNetDev
, *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
))));
1925 printk(KERN_INFO DRV_NAME
"priv_set_ndis(): prNdisReq->ndisOidCmd(0x%lX)\n",
1926 prNdisReq
->ndisOidCmd
1930 if (FALSE
== reqSearchSupportedOidEntry(prNdisReq
->ndisOidCmd
,
1932 //WARNLOG(("Set OID: 0x%08lx (unknown)\n", prNdisReq->ndisOidCmd));
1936 if (NULL
== prWlanReqEntry
->pfOidSetHandler
) {
1937 //WARNLOG(("Set %s: Null set handler\n", prWlanReqEntry->pucOidName));
1942 printk(KERN_INFO DRV_NAME
"priv_set_ndis(): %s\n",
1943 prWlanReqEntry
->pucOidName
1947 if (prWlanReqEntry
->fgSetBufLenChecking
) {
1948 if (prNdisReq
->inNdisOidlength
!= prWlanReqEntry
->u4InfoBufLen
) {
1949 DBGLOG(REQ
, WARN
, ("Set %s: Invalid length (current=%u, needed=%u)\n",
1950 prWlanReqEntry
->pucOidName
,
1951 prNdisReq
->inNdisOidlength
,
1952 prWlanReqEntry
->u4InfoBufLen
));
1954 *pu4OutputLen
= prWlanReqEntry
->u4InfoBufLen
;
1959 if (prWlanReqEntry
->eOidMethod
== ENUM_OID_GLUE_ONLY
) {
1960 /* GLUE sw info only */
1961 status
= prWlanReqEntry
->pfOidSetHandler(prGlueInfo
,
1962 prNdisReq
->ndisOidContent
,
1963 prNdisReq
->inNdisOidlength
,
1966 else if (prWlanReqEntry
->eOidMethod
== ENUM_OID_GLUE_EXTENSION
) {
1967 /* multiple sw operations */
1968 status
= prWlanReqEntry
->pfOidSetHandler(prGlueInfo
,
1969 prNdisReq
->ndisOidContent
,
1970 prNdisReq
->inNdisOidlength
,
1973 else if (prWlanReqEntry
->eOidMethod
== ENUM_OID_DRIVER_CORE
) {
1976 status
= kalIoctl(prGlueInfo
,
1977 (PFN_OID_HANDLER_FUNC
)prWlanReqEntry
->pfOidSetHandler
,
1978 prNdisReq
->ndisOidContent
,
1979 prNdisReq
->inNdisOidlength
,
1987 DBGLOG(REQ
, INFO
, ("priv_set_ndis(): unsupported OID method:0x%x\n",
1988 prWlanReqEntry
->eOidMethod
));
1992 *pu4OutputLen
= u4SetInfoLen
;
1995 case WLAN_STATUS_SUCCESS
:
1998 case WLAN_STATUS_INVALID_LENGTH
:
1999 //WARNLOG(("Set %s: Invalid length (current=%ld, needed=%ld)\n",
2000 // prWlanReqEntry->pucOidName,
2001 //prNdisReq->inNdisOidlength,
2006 if (WLAN_STATUS_SUCCESS
!= status
) {
2011 } /* priv_set_ndis */
2013 /*----------------------------------------------------------------------------*/
2015 * \brief The routine handles a query operation for a single OID. Basically we
2016 * return information about the current state of the OID in question.
2018 * \param[in] pDev Net device requested.
2019 * \param[in] ndisReq Ndis request OID information copy from user.
2020 * \param[out] outputLen_p If the call is successful, returns the number of
2021 * bytes written into the query buffer. If the
2022 * call failed due to invalid length of the query
2023 * buffer, returns the amount of storage needed..
2025 * \retval 0 On success.
2026 * \retval -EOPNOTSUPP If cmd is not supported.
2027 * \retval -EINVAL invalid input parameters
2030 /*----------------------------------------------------------------------------*/
2033 IN
struct net_device
*prNetDev
,
2034 IN NDIS_TRANSPORT_STRUCT
* prNdisReq
,
2035 OUT PUINT_32 pu4OutputLen
2038 P_WLAN_REQ_ENTRY prWlanReqEntry
= NULL
;
2039 UINT_32 u4BufLen
= 0;
2040 WLAN_STATUS status
= WLAN_STATUS_SUCCESS
;
2041 P_GLUE_INFO_T prGlueInfo
= NULL
;
2045 ASSERT(pu4OutputLen
);
2047 if (!prNetDev
|| !prNdisReq
|| !pu4OutputLen
) {
2048 DBGLOG(REQ
, INFO
, ("priv_get_ndis(): invalid param(0x%p, 0x%p, 0x%p)\n",
2049 prNetDev
, prNdisReq
, pu4OutputLen
));
2053 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
2056 DBGLOG(REQ
, INFO
, ("priv_get_ndis(): invalid prGlueInfo(0x%p, 0x%p)\n",
2057 prNetDev
, *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
))));
2062 printk(KERN_INFO DRV_NAME
"priv_get_ndis(): prNdisReq->ndisOidCmd(0x%lX)\n",
2063 prNdisReq
->ndisOidCmd
2067 if (FALSE
== reqSearchSupportedOidEntry(prNdisReq
->ndisOidCmd
,
2069 //WARNLOG(("Query OID: 0x%08lx (unknown)\n", prNdisReq->ndisOidCmd));
2074 if (NULL
== prWlanReqEntry
->pfOidQueryHandler
) {
2075 //WARNLOG(("Query %s: Null query handler\n", prWlanReqEntry->pucOidName));
2080 printk(KERN_INFO DRV_NAME
"priv_get_ndis(): %s\n",
2081 prWlanReqEntry
->pucOidName
2085 if (prWlanReqEntry
->fgQryBufLenChecking
) {
2086 if (prNdisReq
->inNdisOidlength
< prWlanReqEntry
->u4InfoBufLen
) {
2087 /* Not enough room in InformationBuffer. Punt */
2088 //WARNLOG(("Query %s: Buffer too short (current=%ld, needed=%ld)\n",
2089 //prWlanReqEntry->pucOidName,
2090 //prNdisReq->inNdisOidlength,
2091 //prWlanReqEntry->u4InfoBufLen));
2093 *pu4OutputLen
= prWlanReqEntry
->u4InfoBufLen
;
2095 status
= WLAN_STATUS_INVALID_LENGTH
;
2101 if (prWlanReqEntry
->eOidMethod
== ENUM_OID_GLUE_ONLY
) {
2102 /* GLUE sw info only */
2103 status
= prWlanReqEntry
->pfOidQueryHandler(prGlueInfo
,
2104 prNdisReq
->ndisOidContent
,
2105 prNdisReq
->inNdisOidlength
,
2108 else if (prWlanReqEntry
->eOidMethod
== ENUM_OID_GLUE_EXTENSION
) {
2109 /* multiple sw operations */
2110 status
= prWlanReqEntry
->pfOidQueryHandler(prGlueInfo
,
2111 prNdisReq
->ndisOidContent
,
2112 prNdisReq
->inNdisOidlength
,
2115 else if (prWlanReqEntry
->eOidMethod
== ENUM_OID_DRIVER_CORE
) {
2118 status
= kalIoctl(prGlueInfo
,
2119 (PFN_OID_HANDLER_FUNC
)prWlanReqEntry
->pfOidQueryHandler
,
2120 prNdisReq
->ndisOidContent
,
2121 prNdisReq
->inNdisOidlength
,
2129 DBGLOG(REQ
, INFO
, ("priv_set_ndis(): unsupported OID method:0x%x\n",
2130 prWlanReqEntry
->eOidMethod
));
2134 *pu4OutputLen
= u4BufLen
;
2137 case WLAN_STATUS_SUCCESS
:
2140 case WLAN_STATUS_INVALID_LENGTH
:
2141 //WARNLOG(("Set %s: Invalid length (current=%ld, needed=%ld)\n",
2142 // prWlanReqEntry->pucOidName,
2143 //prNdisReq->inNdisOidlength,
2148 if (WLAN_STATUS_SUCCESS
!= status
) {
2153 } /* priv_get_ndis */
2156 /*----------------------------------------------------------------------------*/
2158 * @brief Parse command value in a string.
2160 * @param InStr Pointer to the string buffer.
2161 * @param OutStr Pointer to the next command value.
2162 * @param OutLen Record the resident buffer length.
2164 * @retval Command value.
2166 /*----------------------------------------------------------------------------*/
2170 OUT UINT_8
**OutStr
,
2174 unsigned char Charc
, *Buf
;
2185 Buf
= (unsigned char *)InStr
;
2193 /* check the value is decimal or hex */
2194 if ((Buf
[ReadId
] == 'x') ||
2195 ((Buf
[ReadId
] == '0') && (Buf
[ReadId
+1] == 'x')))
2198 if (Buf
[ReadId
] == 'x')
2203 /* translate the hex number */
2204 while(Maxloop
++ < 10)
2206 Charc
= Buf
[ReadId
];
2207 if ((Charc
>= 0x30) && (Charc
<= 0x39))
2209 else if ((Charc
>= 'a') && (Charc
<= 'f'))
2211 else if ((Charc
>= 'A') && (Charc
<= 'F'))
2214 break; /* exit the parsing */
2215 Num
= Num
* 16 + Charc
+ 10;
2222 /* translate the decimal number */
2223 while(Maxloop
++ < 10)
2225 Charc
= Buf
[ReadId
];
2226 if ((Charc
< 0x30) || (Charc
> 0x39))
2227 break; /* exit the parsing */
2229 Num
= Num
* 10 + Charc
;
2235 if (Buf
[ReadId
] == 0x00)
2236 *OutStr
= &Buf
[ReadId
];
2238 *OutStr
= &Buf
[ReadId
+1]; /* skip the character: _ */
2240 *OutLen
= TotalLen
-1; /* skip the character: _ */
2245 /*----------------------------------------------------------------------------*/
2247 * @brief Parse command MAC address in a string.
2249 * @param InStr Pointer to the string buffer.
2250 * @param OutStr Pointer to the next command value.
2251 * @param OutLen Record the resident buffer length.
2253 * @retval Command value.
2255 /*----------------------------------------------------------------------------*/
2259 OUT UINT_8
**OutStr
,
2260 OUT UINT_32
*OutLen
,
2264 unsigned char Charc
, *Buf
;
2275 Buf
= (unsigned char *)InStr
;
2286 Charc
= Buf
[ReadId
];
2287 if ((Charc
>= 0x30) && (Charc
<= 0x39))
2289 else if ((Charc
>= 'a') && (Charc
<= 'f'))
2290 Charc
= Charc
- 'a' + 10;
2291 else if ((Charc
>= 'A') && (Charc
<= 'F'))
2292 Charc
= Charc
- 'A' + 10;
2294 return -1; /* error, exit the parsing */
2300 Charc
= Buf
[ReadId
];
2301 if ((Charc
>= 0x30) && (Charc
<= 0x39))
2303 else if ((Charc
>= 'a') && (Charc
<= 'f'))
2304 Charc
= Charc
- 'a' + 10;
2305 else if ((Charc
>= 'A') && (Charc
<= 'F'))
2306 Charc
= Charc
- 'A' + 10;
2308 return -1; /* error, exit the parsing */
2310 Num
= Num
* 16 + Charc
;
2311 ReadId
+= 2; /* skip the character and ':' */
2314 OutMac
[Maxloop
] = Num
;
2318 *OutStr
= &Buf
[ReadId
]; /* skip the character: _ */
2319 *OutLen
= TotalLen
; /* skip the character: _ */
2324 /*----------------------------------------------------------------------------*/
2326 * \brief The routine handles a set operation for a single OID.
2328 * \param[in] pDev Net device requested.
2329 * \param[in] ndisReq Ndis request OID information copy from user.
2330 * \param[out] outputLen_p If the call is successful, returns the number of
2331 * bytes written into the query buffer. If the
2332 * call failed due to invalid length of the query
2333 * buffer, returns the amount of storage needed..
2335 * \retval 0 On success.
2336 * \retval -EOPNOTSUPP If cmd is not supported.
2339 /*----------------------------------------------------------------------------*/
2342 IN
struct net_device
*prNetDev
,
2343 IN
struct iw_request_info
*prIwReqInfo
,
2344 IN
union iwreq_data
*prIwReqData
,
2348 P_GLUE_INFO_T GlueInfo
;
2357 ASSERT(prIwReqInfo
);
2358 ASSERT(prIwReqData
);
2362 DBGLOG(REQ
, INFO
, ("priv_set_string (%s)(%d)\n",
2363 (UINT8
*)prIwReqData
->data
.pointer
, (INT32
)prIwReqData
->data
.length
));
2365 if (FALSE
== GLUE_CHK_PR3(prNetDev
, prIwReqData
, pcExtra
)) {
2368 GlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
2371 InBufLen
= prIwReqData
->data
.length
;
2374 if (copy_from_user(InBuf
,
2375 prIwReqData
->data
.pointer
,
2376 prIwReqData
->data
.length
)) {
2380 Subcmd
= CmdStringDecParse(prIwReqData
->data
.pointer
, &InBuf
, &InBufLen
);
2381 DBGLOG(REQ
, INFO
, ("priv_set_string> command = %u\n", (UINT32
)Subcmd
));
2383 /* handle the command */
2386 #if (CFG_SUPPORT_TDLS == 1)
2387 case PRIV_CMD_OTHER_TDLS
:
2388 TdlsexCmd(GlueInfo
, InBuf
, InBufLen
);
2390 #endif /* CFG_SUPPORT_TDLS */
2401 /*----------------------------------------------------------------------------*/
2403 * \brief This routine is called to search desired OID.
2405 * \param rOid[in] Desired NDIS_OID
2406 * \param ppWlanReqEntry[out] Found registered OID entry
2408 * \retval TRUE: Matched OID is found
2409 * \retval FALSE: No matched OID is found
2411 /*----------------------------------------------------------------------------*/
2413 reqSearchSupportedOidEntry (
2415 OUT P_WLAN_REQ_ENTRY
*ppWlanReqEntry
2421 j
= NUM_SUPPORTED_OIDS
- 1;
2426 if (rOid
== arWlanOidReqTable
[k
].rOid
) {
2427 *ppWlanReqEntry
= &arWlanOidReqTable
[k
];
2429 } else if (rOid
< arWlanOidReqTable
[k
].rOid
) {
2437 } /* reqSearchSupportedOidEntry */
2440 /*----------------------------------------------------------------------------*/
2442 * \brief This routine is called to query the radio configuration used in IBSS
2443 * mode and RF test mode.
2445 * \param[in] prGlueInfo Pointer to the GLUE_INFO_T structure.
2446 * \param[out] pvQueryBuffer Pointer to the buffer that holds the result of the query.
2447 * \param[in] u4QueryBufferLen The length of the query buffer.
2448 * \param[out] pu4QueryInfoLen If the call is successful, returns the number of
2449 * bytes written into the query buffer. If the call
2450 * failed due to invalid length of the query buffer,
2451 * returns the amount of storage needed.
2453 * \retval WLAN_STATUS_SUCCESS
2454 * \retval WLAN_STATUS_INVALID_LENGTH
2456 /*----------------------------------------------------------------------------*/
2458 reqExtQueryConfiguration (
2459 IN P_GLUE_INFO_T prGlueInfo
,
2460 OUT PVOID pvQueryBuffer
,
2461 IN UINT_32 u4QueryBufferLen
,
2462 OUT PUINT_32 pu4QueryInfoLen
2465 P_PARAM_802_11_CONFIG_T prQueryConfig
= (P_PARAM_802_11_CONFIG_T
)pvQueryBuffer
;
2466 WLAN_STATUS rStatus
= WLAN_STATUS_SUCCESS
;
2467 UINT_32 u4QueryInfoLen
= 0;
2469 DEBUGFUNC("wlanoidQueryConfiguration");
2473 ASSERT(pu4QueryInfoLen
);
2475 *pu4QueryInfoLen
= sizeof(PARAM_802_11_CONFIG_T
);
2476 if (u4QueryBufferLen
< sizeof(PARAM_802_11_CONFIG_T
)) {
2477 return WLAN_STATUS_INVALID_LENGTH
;
2480 ASSERT(pvQueryBuffer
);
2482 kalMemZero(prQueryConfig
, sizeof(PARAM_802_11_CONFIG_T
));
2484 /* Update the current radio configuration. */
2485 prQueryConfig
->u4Length
= sizeof(PARAM_802_11_CONFIG_T
);
2487 #if defined(_HIF_SDIO)
2488 rStatus
= sdio_io_ctrl(prGlueInfo
,
2489 wlanoidSetBeaconInterval
,
2490 &prQueryConfig
->u4BeaconPeriod
,
2496 rStatus
= wlanQueryInformation(prGlueInfo
->prAdapter
,
2497 wlanoidQueryBeaconInterval
,
2498 &prQueryConfig
->u4BeaconPeriod
,
2502 if (rStatus
!= WLAN_STATUS_SUCCESS
) {
2506 #if defined(_HIF_SDIO)
2507 rStatus
= sdio_io_ctrl(prGlueInfo
,
2508 wlanoidQueryAtimWindow
,
2509 &prQueryConfig
->u4ATIMWindow
,
2515 rStatus
= wlanQueryInformation(prGlueInfo
->prAdapter
,
2516 wlanoidQueryAtimWindow
,
2517 &prQueryConfig
->u4ATIMWindow
,
2521 if (rStatus
!= WLAN_STATUS_SUCCESS
) {
2525 #if defined(_HIF_SDIO)
2526 rStatus
= sdio_io_ctrl(prGlueInfo
,
2527 wlanoidQueryFrequency
,
2528 &prQueryConfig
->u4DSConfig
,
2534 rStatus
= wlanQueryInformation(prGlueInfo
->prAdapter
,
2535 wlanoidQueryFrequency
,
2536 &prQueryConfig
->u4DSConfig
,
2540 if (rStatus
!= WLAN_STATUS_SUCCESS
) {
2544 prQueryConfig
->rFHConfig
.u4Length
= sizeof(PARAM_802_11_CONFIG_FH_T
);
2548 } /* end of reqExtQueryConfiguration() */
2551 /*----------------------------------------------------------------------------*/
2553 * \brief This routine is called to set the radio configuration used in IBSS
2556 * \param[in] prGlueInfo Pointer to the GLUE_INFO_T structure.
2557 * \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set.
2558 * \param[in] u4SetBufferLen The length of the set buffer.
2559 * \param[out] pu4SetInfoLen If the call is successful, returns the number of
2560 * bytes read from the set buffer. If the call failed
2561 * due to invalid length of the set buffer, returns
2562 * the amount of storage needed.
2564 * \retval WLAN_STATUS_SUCCESS
2565 * \retval WLAN_STATUS_INVALID_LENGTH
2566 * \retval WLAN_STATUS_NOT_ACCEPTED
2568 /*----------------------------------------------------------------------------*/
2570 reqExtSetConfiguration (
2571 IN P_GLUE_INFO_T prGlueInfo
,
2572 IN PVOID pvSetBuffer
,
2573 IN UINT_32 u4SetBufferLen
,
2574 OUT PUINT_32 pu4SetInfoLen
2577 WLAN_STATUS rStatus
= WLAN_STATUS_SUCCESS
;
2578 P_PARAM_802_11_CONFIG_T prNewConfig
= (P_PARAM_802_11_CONFIG_T
)pvSetBuffer
;
2579 UINT_32 u4SetInfoLen
= 0;
2581 DEBUGFUNC("wlanoidSetConfiguration");
2585 ASSERT(pu4SetInfoLen
);
2587 *pu4SetInfoLen
= sizeof(PARAM_802_11_CONFIG_T
);
2589 if (u4SetBufferLen
< *pu4SetInfoLen
) {
2590 return WLAN_STATUS_INVALID_LENGTH
;
2593 /* OID_802_11_CONFIGURATION. If associated, NOT_ACCEPTED shall be returned. */
2594 if (prGlueInfo
->eParamMediaStateIndicated
== PARAM_MEDIA_STATE_CONNECTED
) {
2595 return WLAN_STATUS_NOT_ACCEPTED
;
2598 ASSERT(pvSetBuffer
);
2600 #if defined(_HIF_SDIO)
2601 rStatus
= sdio_io_ctrl(prGlueInfo
,
2602 wlanoidSetBeaconInterval
,
2603 &prNewConfig
->u4BeaconPeriod
,
2609 rStatus
= wlanSetInformation(prGlueInfo
->prAdapter
,
2610 wlanoidSetBeaconInterval
,
2611 &prNewConfig
->u4BeaconPeriod
,
2615 if (rStatus
!= WLAN_STATUS_SUCCESS
) {
2619 #if defined(_HIF_SDIO)
2620 rStatus
= sdio_io_ctrl(prGlueInfo
,
2621 wlanoidSetAtimWindow
,
2622 &prNewConfig
->u4ATIMWindow
,
2628 rStatus
= wlanSetInformation(prGlueInfo
->prAdapter
,
2629 wlanoidSetAtimWindow
,
2630 &prNewConfig
->u4ATIMWindow
,
2634 if (rStatus
!= WLAN_STATUS_SUCCESS
) {
2638 #if defined(_HIF_SDIO)
2639 rStatus
= sdio_io_ctrl(prGlueInfo
,
2640 wlanoidSetFrequency
,
2641 &prNewConfig
->u4DSConfig
,
2647 rStatus
= wlanSetInformation(prGlueInfo
->prAdapter
,
2648 wlanoidSetFrequency
,
2649 &prNewConfig
->u4DSConfig
,
2654 if (rStatus
!= WLAN_STATUS_SUCCESS
) {
2660 } /* end of reqExtSetConfiguration() */
2663 /*----------------------------------------------------------------------------*/
2665 * \brief This routine is called to set beacon detection function enable/disable state
2666 * This is mainly designed for usage under BT inquiry state (disable function).
2668 * \param[in] pvAdapter Pointer to the Adapter structure
2669 * \param[in] pvSetBuffer A pointer to the buffer that holds the data to be set
2670 * \param[in] u4SetBufferLen The length of the set buffer
2671 * \param[out] pu4SetInfoLen If the call is successful, returns the number of
2672 * bytes read from the set buffer. If the call failed due to invalid length of
2673 * the set buffer, returns the amount of storage needed.
2675 * \retval WLAN_STATUS_SUCCESS
2676 * \retval WLAN_STATUS_INVALID_DATA If new setting value is wrong.
2677 * \retval WLAN_STATUS_INVALID_LENGTH
2680 /*----------------------------------------------------------------------------*/
2682 reqExtSetAcpiDevicePowerState (
2683 IN P_GLUE_INFO_T prGlueInfo
,
2684 IN PVOID pvSetBuffer
,
2685 IN UINT_32 u4SetBufferLen
,
2686 OUT PUINT_32 pu4SetInfoLen
2689 WLAN_STATUS rStatus
= WLAN_STATUS_SUCCESS
;
2692 ASSERT(pvSetBuffer
);
2693 ASSERT(pu4SetInfoLen
);
2695 /* WIFI is enabled, when ACPI is D0 (ParamDeviceStateD0 = 1). And vice versa */
2697 //rStatus = wlanSetInformation(prGlueInfo->prAdapter,
2698 // wlanoidSetAcpiDevicePowerState,
2706 priv_driver_set_chip_config(IN
struct net_device
*prNetDev
, IN
char *pcCommand
, IN
int i4TotalLen
)
2708 WLAN_STATUS rStatus
= WLAN_STATUS_SUCCESS
;
2709 P_GLUE_INFO_T prGlueInfo
= NULL
;
2710 P_ADAPTER_T prAdapter
= NULL
;
2711 UINT_32 u4BufLen
= 0;
2712 INT_32 i4BytesWritten
= 0;
2713 UINT_32 u4CmdLen
= 0;
2714 UINT_32 u4PrefixLen
= 0;
2715 /* INT_32 i4Argc = 0; */
2716 /* PCHAR apcArgv[WLAN_CFG_ARGV_MAX] = {0}; */
2718 PARAM_CUSTOM_CHIP_CONFIG_STRUC_T rChipConfigInfo
;
2721 if (FALSE
== GLUE_CHK_PR2(prNetDev
, pcCommand
)) {
2724 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
2725 prAdapter
= prGlueInfo
->prAdapter
;
2726 DBGLOG(REQ
, INFO
, ("priv_driver_set_chip_config command is %s\n", pcCommand
));
2727 /* wlanCfgParseArgument(pcCommand, &i4Argc, apcArgv); */
2728 /* DBGLOG(REQ, LOUD,("argc is %i\n",i4Argc)); */
2730 u4CmdLen
= kalStrnLen(pcCommand
, i4TotalLen
);
2731 u4PrefixLen
= kalStrLen(CMD_SET_CHIP
) + 1 /*space */;
2733 kalMemZero(&rChipConfigInfo
, sizeof(rChipConfigInfo
));
2735 /* if(i4Argc >= 2) { */
2736 if (u4CmdLen
> u4PrefixLen
) {
2738 rChipConfigInfo
.ucType
= CHIP_CONFIG_TYPE_WO_RESPONSE
;
2739 /* rChipConfigInfo.u2MsgSize = kalStrnLen(apcArgv[1],CHIP_CONFIG_RESP_SIZE); */
2740 rChipConfigInfo
.u2MsgSize
= u4CmdLen
- u4PrefixLen
;
2741 /* kalStrnCpy(rChipConfigInfo.aucCmd,apcArgv[1],CHIP_CONFIG_RESP_SIZE); */
2742 kalStrnCpy(rChipConfigInfo
.aucCmd
, pcCommand
+ u4PrefixLen
, CHIP_CONFIG_RESP_SIZE
-u4PrefixLen
);
2744 rStatus
= kalIoctl(prGlueInfo
,
2745 wlanoidSetChipConfig
,
2747 sizeof(rChipConfigInfo
), FALSE
, FALSE
, TRUE
, TRUE
,&u4BufLen
);
2749 if (rStatus
!= WLAN_STATUS_SUCCESS
) {
2750 DBGLOG(REQ
, INFO
, ("%s: kalIoctl ret=%d\n", __func__
, rStatus
));
2751 i4BytesWritten
= -1;
2755 return i4BytesWritten
;
2759 int priv_driver_set_miracast(IN
struct net_device
*prNetDev
, IN
char *pcCommand
, IN
int i4TotalLen
)
2762 P_ADAPTER_T prAdapter
= NULL
;
2763 P_GLUE_INFO_T prGlueInfo
= NULL
;
2764 UINT_32 i4BytesWritten
= 0;
2765 /* WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS; */
2766 /* UINT_32 u4BufLen = 0; */
2769 P_WFD_CFG_SETTINGS_T prWfdCfgSettings
= (P_WFD_CFG_SETTINGS_T
) NULL
;
2770 P_MSG_WFD_CONFIG_SETTINGS_CHANGED_T prMsgWfdCfgUpdate
=
2771 (P_MSG_WFD_CONFIG_SETTINGS_CHANGED_T
) NULL
;
2772 PCHAR apcArgv
[WLAN_CFG_ARGV_MAX
];
2775 if (FALSE
== GLUE_CHK_PR2(prNetDev
, pcCommand
)) {
2781 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
2783 DBGLOG(REQ
, LOUD
, ("command is %s\n", pcCommand
));
2784 wlanCfgParseArgument(pcCommand
, &i4Argc
, apcArgv
);
2785 DBGLOG(REQ
, LOUD
, ("argc is %i\n", i4Argc
));
2788 prAdapter
= prGlueInfo
->prAdapter
;
2791 ucMode
= kalStrtoul(apcArgv
[1], NULL
, 0);
2793 if (g_ucMiracastMode
== ucMode
) {
2794 /* XXX: continue or skip */
2797 g_ucMiracastMode
= ucMode
;
2799 cnmMemAlloc(prAdapter
, RAM_TYPE_MSG
, sizeof(MSG_WFD_CONFIG_SETTINGS_CHANGED_T
));
2801 if (prMsgWfdCfgUpdate
!= NULL
) {
2803 prWfdCfgSettings
= &(prGlueInfo
->prAdapter
->rWifiVar
.prP2pFsmInfo
->rWfdConfigureSettings
);
2804 prMsgWfdCfgUpdate
->rMsgHdr
.eMsgId
= MID_MNY_P2P_WFD_CFG_UPDATE
;
2805 prMsgWfdCfgUpdate
->prWfdCfgSettings
= prWfdCfgSettings
;
2807 if (ucMode
== MIRACAST_MODE_OFF
) {
2808 prWfdCfgSettings
->ucWfdEnable
= 0;
2809 snprintf(pcCommand
, i4TotalLen
, CMD_SET_CHIP
" mira 0");
2810 } else if (ucMode
== MIRACAST_MODE_SOURCE
) {
2811 prWfdCfgSettings
->ucWfdEnable
= 1;
2812 snprintf(pcCommand
, i4TotalLen
, CMD_SET_CHIP
" mira 1");
2813 } else if (ucMode
== MIRACAST_MODE_SINK
) {
2814 prWfdCfgSettings
->ucWfdEnable
= 2;
2815 snprintf(pcCommand
, i4TotalLen
, CMD_SET_CHIP
" mira 2");
2817 prWfdCfgSettings
->ucWfdEnable
= 0;
2818 snprintf(pcCommand
, i4TotalLen
, CMD_SET_CHIP
" mira 0");
2820 mboxSendMsg(prAdapter
,
2822 (P_MSG_HDR_T
) prMsgWfdCfgUpdate
, MSG_SEND_METHOD_BUF
);
2825 priv_driver_set_chip_config(prNetDev
, pcCommand
, i4TotalLen
);
2827 } /* prMsgWfdCfgUpdate */
2830 i4BytesWritten
= -1;
2835 return i4BytesWritten
;
2839 priv_support_driver_cmd(IN
struct net_device
*prNetDev
, IN OUT
struct ifreq
*prReq
, IN
int i4Cmd
)
2841 P_GLUE_INFO_T prGlueInfo
= NULL
;
2843 char *pcCommand
= NULL
;
2844 int i4BytesWritten
= 0;
2846 priv_driver_cmd_t priv_cmd
;
2847 if (!prReq
->ifr_data
) {
2852 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
2855 DBGLOG(REQ
, WARN
, ("No glue info\n"));
2859 if (prGlueInfo
->u4ReadyFlag
== 0) {
2864 if (copy_from_user(&priv_cmd
, prReq
->ifr_data
, sizeof(priv_driver_cmd_t
))) {
2865 DBGLOG(REQ
, INFO
, ("%s: copy_from_user fail\n", __func__
));
2870 i4TotalLen
= priv_cmd
.total_len
;
2872 if (i4TotalLen
<= 0) {
2877 if (!access_ok(VERIFY_READ
, priv_cmd
.buf
, i4TotalLen
)) {
2878 DBGLOG(REQ
, INFO
, ("%s: copy_from_user fail %d\n", __func__
, i4TotalLen
));
2883 pcCommand
= kmalloc(i4TotalLen
, GFP_KERNEL
);
2886 ("%s: failed to allocate memory size %d\n", __func__
, i4TotalLen
));
2892 if (copy_from_user(pcCommand
, priv_cmd
.buf
, i4TotalLen
)) {
2898 ("%s: driver cmd \"%s\" on %s\n", __func__
, pcCommand
, prReq
->ifr_name
));
2900 i4BytesWritten
= priv_driver_cmds(prNetDev
, pcCommand
, i4TotalLen
);
2902 if (i4BytesWritten
< 0) {
2904 ("%s: command %s Written is %d\n", __func__
, pcCommand
, i4BytesWritten
));
2905 if (i4TotalLen
>= 3) {
2906 snprintf(pcCommand
, 3, "OK");
2907 i4BytesWritten
= strlen("OK");
2911 if (i4BytesWritten
>= 0) {
2912 if ((i4BytesWritten
== 0) && (i4TotalLen
> 0)) {
2913 /* Reset the command buffers */
2914 pcCommand
[0] = '\0';
2916 if (i4BytesWritten
>= i4TotalLen
) {
2918 ("%s: i4BytesWritten %d > i4TotalLen < %d\n", __func__
,
2919 i4BytesWritten
, i4TotalLen
));
2920 i4BytesWritten
= i4TotalLen
;
2922 pcCommand
[i4BytesWritten
] = '\0';
2925 priv_cmd
.used_len
= i4BytesWritten
;
2926 if (copy_to_user(priv_cmd
.buf
, pcCommand
, i4BytesWritten
)) {
2927 DBGLOG(REQ
, WARN
, ("failed to copy data to user buffer\n"));
2930 if (copy_to_user(prReq
->ifr_data
, &priv_cmd
, sizeof(priv_driver_cmd_t
))) {
2931 DBGLOG(REQ
, WARN
, ("failed to copy driver_cmd to user buffer\n"));
2945 INT_32
priv_driver_cmds(IN
struct net_device
*prNetDev
, IN PCHAR pcCommand
, IN INT_32 i4TotalLen
)
2947 P_GLUE_INFO_T prGlueInfo
= NULL
;
2948 INT_32 i4BytesWritten
= 0;
2949 INT_32 i4CmdFound
= 0;
2950 if (FALSE
== GLUE_CHK_PR2(prNetDev
, pcCommand
)) {
2953 prGlueInfo
= *((P_GLUE_INFO_T
*) netdev_priv(prNetDev
));
2955 if (i4CmdFound
== 0) {
2958 if (strnicmp(pcCommand
, CMD_MIRACAST
, strlen(CMD_MIRACAST
)) == 0) {
2959 i4BytesWritten
= priv_driver_set_miracast(prNetDev
, pcCommand
, i4TotalLen
);
2964 else if (strnicmp(pcCommand
, CMD_RSSI
, strlen(CMD_RSSI
)) == 0) {
2965 /* i4BytesWritten = wl_android_get_rssi(net, command, i4TotalLen); */
2966 } else if (strnicmp(pcCommand
, CMD_LINKSPEED
, strlen(CMD_LINKSPEED
)) == 0) {
2967 i4BytesWritten
= priv_driver_get_linkspeed(prNetDev
, pcCommand
, i4TotalLen
);
2968 } else if (strnicmp(pcCommand
, CMD_PNOSSIDCLR_SET
, strlen(CMD_PNOSSIDCLR_SET
)) == 0) {
2969 } else if (strnicmp(pcCommand
, CMD_PNOSETUP_SET
, strlen(CMD_PNOSETUP_SET
)) == 0) {
2970 } else if (strnicmp(pcCommand
, CMD_PNOENABLE_SET
, strlen(CMD_PNOENABLE_SET
)) == 0) {
2971 } else if (strnicmp(pcCommand
, CMD_SETSUSPENDOPT
, strlen(CMD_SETSUSPENDOPT
)) == 0) {
2972 /* i4BytesWritten = wl_android_set_suspendopt(net, pcCommand, i4TotalLen); */
2973 } else if (strnicmp(pcCommand
, CMD_SETSUSPENDMODE
, strlen(CMD_SETSUSPENDMODE
)) == 0) {
2975 priv_driver_set_suspend_mode(prNetDev
, pcCommand
, i4TotalLen
);
2976 } else if (strnicmp(pcCommand
, CMD_SETBAND
, strlen(CMD_SETBAND
)) == 0) {
2977 i4BytesWritten
= priv_driver_set_band(prNetDev
, pcCommand
, i4TotalLen
);
2978 } else if (strnicmp(pcCommand
, CMD_GETBAND
, strlen(CMD_GETBAND
)) == 0) {
2979 /* i4BytesWritten = wl_android_get_band(net, pcCommand, i4TotalLen); */
2980 } else if (strnicmp(pcCommand
, CMD_COUNTRY
, strlen(CMD_COUNTRY
)) == 0) {
2981 i4BytesWritten
= priv_driver_set_country(prNetDev
, pcCommand
, i4TotalLen
);
2983 /* Mediatek private command */
2984 else if (strnicmp(pcCommand
, CMD_SET_SW_CTRL
, strlen(CMD_SET_SW_CTRL
)) == 0) {
2985 i4BytesWritten
= priv_driver_set_sw_ctrl(prNetDev
, pcCommand
, i4TotalLen
);
2986 } else if (strnicmp(pcCommand
, CMD_GET_SW_CTRL
, strlen(CMD_GET_SW_CTRL
)) == 0) {
2987 i4BytesWritten
= priv_driver_get_sw_ctrl(prNetDev
, pcCommand
, i4TotalLen
);
2988 } else if (strnicmp(pcCommand
, CMD_SET_CFG
, strlen(CMD_SET_CFG
)) == 0) {
2989 i4BytesWritten
= priv_driver_set_cfg(prNetDev
, pcCommand
, i4TotalLen
);
2990 } else if (strnicmp(pcCommand
, CMD_GET_CFG
, strlen(CMD_GET_CFG
)) == 0) {
2991 i4BytesWritten
= priv_driver_get_cfg(prNetDev
, pcCommand
, i4TotalLen
);
2992 } else if (strnicmp(pcCommand
, CMD_SET_CHIP
, strlen(CMD_SET_CHIP
)) == 0) {
2994 priv_driver_set_chip_config(prNetDev
, pcCommand
, i4TotalLen
);
2995 } else if (strnicmp(pcCommand
, CMD_GET_CHIP
, strlen(CMD_GET_CHIP
)) == 0) {
2997 priv_driver_get_chip_config(prNetDev
, pcCommand
, i4TotalLen
);
2998 } else if (strnicmp(pcCommand
, CMD_SET_DBG_LEVEL
, strlen(CMD_SET_DBG_LEVEL
)) == 0) {
2999 i4BytesWritten
= priv_driver_set_dbg_level(prNetDev
, pcCommand
, i4TotalLen
);
3000 } else if (strnicmp(pcCommand
, CMD_GET_DBG_LEVEL
, strlen(CMD_GET_DBG_LEVEL
)) == 0) {
3001 i4BytesWritten
= priv_driver_get_dbg_level(prNetDev
, pcCommand
, i4TotalLen
);
3003 #if CFG_SUPPORT_BATCH_SCAN
3004 else if (strnicmp(pcCommand
, CMD_BATCH_SET
, strlen(CMD_BATCH_SET
)) == 0) {
3005 kalIoctl(prGlueInfo
,
3006 wlanoidSetBatchScanReq
,
3008 i4TotalLen
, FALSE
, FALSE
, TRUE
, &i4BytesWritten
);
3009 } else if (strnicmp(pcCommand
, CMD_BATCH_GET
, strlen(CMD_BATCH_GET
)) == 0) {
3010 /* strcpy(pcCommand, "BATCH SCAN DATA FROM FIRMWARE"); */
3011 /* i4BytesWritten = strlen("BATCH SCAN DATA FROM FIRMWARE") + 1; */
3012 /* i4BytesWritten = priv_driver_get_linkspeed (prNetDev, pcCommand, i4TotalLen); */
3018 for (i
= 0; i
< CFG_BATCH_MAX_MSCAN
; i
++) {
3019 g_rEventBatchResult
[i
].ucScanCount
= i
+ 1; /* for get which mscan */
3020 kalIoctl(prGlueInfo
,
3021 wlanoidQueryBatchScanResult
,
3022 (PVOID
) & g_rEventBatchResult
[i
],
3023 sizeof(EVENT_BATCH_RESULT_T
), TRUE
, TRUE
, TRUE
, &u4BufLen
);
3028 ("Batch Scan Results, scan count = %u\n",
3029 g_rEventBatchResult
.ucScanCount
));
3030 for (i
= 0; i
< g_rEventBatchResult
.ucScanCount
; i
++) {
3031 prEntry
= &g_rEventBatchResult
.arBatchResult
[i
];
3032 DBGLOG(SCN
, INFO
, ("Entry %u\n", i
));
3034 (" BSSID = " MACSTR
"\n",
3035 MAC2STR(prEntry
->aucBssid
)));
3036 DBGLOG(SCN
, INFO
, (" SSID = %s\n", prEntry
->aucSSID
));
3037 DBGLOG(SCN
, INFO
, (" SSID len = %u\n", prEntry
->ucSSIDLen
));
3038 DBGLOG(SCN
, INFO
, (" RSSI = %d\n", prEntry
->cRssi
));
3039 DBGLOG(SCN
, INFO
, (" Freq = %u\n", prEntry
->ucFreq
));
3043 batchConvertResult(&g_rEventBatchResult
[0], pcCommand
, i4TotalLen
,
3046 /* Dump for debug */
3047 /* print_hex_dump(KERN_INFO, "BATCH", DUMP_PREFIX_ADDRESS, 16, 1, pcCommand, i4BytesWritten, TRUE); */
3049 } else if (strnicmp(pcCommand
, CMD_BATCH_STOP
, strlen(CMD_BATCH_STOP
)) == 0) {
3050 kalIoctl(prGlueInfo
,
3051 wlanoidSetBatchScanReq
,
3053 i4TotalLen
, FALSE
, FALSE
, TRUE
, &i4BytesWritten
);
3066 if (i4CmdFound
== 0) {
3067 DBGLOG(REQ
, INFO
, ("Unknown driver command %s - ignored\n", pcCommand
));
3070 if (i4BytesWritten
>= 0) {
3071 if ((i4BytesWritten
== 0) && (i4TotalLen
> 0)) {
3072 /* reset the command buffer */
3073 pcCommand
[0] = '\0';
3076 if (i4BytesWritten
>= i4TotalLen
) {
3078 ("%s: i4BytesWritten %d > i4TotalLen < %d\n", __func__
,
3079 i4BytesWritten
, i4TotalLen
));
3080 i4BytesWritten
= i4TotalLen
;
3082 pcCommand
[i4BytesWritten
] = '\0';
3089 return i4BytesWritten
;