2 ** $Id: @(#) gl_p2p_cfg80211.c@@
5 /*! \file gl_p2p_cfg80211.c
6 \brief Main routines of Linux driver interface for Wi-Fi Direct
7 using cfg80211 interface
9 This file contains the main routines of Linux driver for MediaTek Inc. 802.11
10 Wireless LAN Adapters.
13 /*******************************************************************************
14 * Copyright (c) 2007 MediaTek Inc.
16 * All rights reserved. Copying, compilation, modification, distribution
17 * or any other use whatsoever of this material is strictly prohibited
18 * except in accordance with a Software License Agreement with
20 ********************************************************************************
23 /*******************************************************************************
26 * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND
27 * AGREES THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK
28 * SOFTWARE") RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
29 * PROVIDED TO BUYER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY
30 * DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
31 * LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
32 * PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE
33 * ANY WARRANTY WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY
34 * WHICH MAY BE USED BY, INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK
35 * SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY
36 * WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE
37 * FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION OR TO
38 * CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
40 * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
41 * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL
42 * BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT
43 * ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
44 * BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
46 * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
47 * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT
48 * OF LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING
49 * THEREOF AND RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN
50 * FRANCISCO, CA, UNDER THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE
52 ********************************************************************************
56 ** $Log: gl_p2p_cfg80211.c $
58 ** 08 30 2012 yuche.tsai
60 ** Fix disconnect issue possible leads KE.
63 ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
67 ** [WCXRP00001269] [MT6620 Wi-Fi][Driver] cfg80211 porting merge back to DaVinci
68 ** cfg80211 support merge back from ALPS.JB to DaVinci - MT6620 Driver v2.3 branch.
70 ** 08 24 2012 yuche.tsai
72 ** Fix bug of invitation request.
74 ** 08 20 2012 yuche.tsai
76 ** Try to fix frame register KE issue.
78 ** 08 17 2012 yuche.tsai
80 ** Fix compile warning.
82 ** 08 16 2012 yuche.tsai
84 ** Fix compile warning.
86 ** 08 08 2012 yuche.tsai
88 ** Fix bug of hard scan p2p device sometimes
91 ** [WCXRP00001246] [MT6620 Wi-Fi][Driver][P2P] Do more filed check for avoid not copy the STA mac address for add key[WCXRP00001262] [MT6620 Wi-Fi][Driver] Fixed the update assoc info pkt length issue
94 ** 08 06 2012 yuche.tsai
95 ** [WCXRP00001119] [Volunteer Patch][WiFi Direct][Driver] Connection Policy Set for WFD SIGMA test
96 ** Fix P2P reset would not reset QoS BSS info issue.
98 ** 07 31 2012 yuche.tsai
100 ** Update Active/Deactive network policy for P2P network.
101 ** Highly related to power saving.
103 ** 07 25 2012 yuche.tsai
105 ** Add support for null mac address del station.
107 ** 07 25 2012 yuche.tsai
111 ** 07 25 2012 yuche.tsai
113 ** Bug fix for TX mgmt frame.
115 ** 07 24 2012 yuche.tsai
119 ** 07 19 2012 yuche.tsai
121 ** Code update for JB.
123 * 07 17 2012 yuche.tsai
125 * Fix compile error for JB.
127 * 07 17 2012 yuche.tsai
129 * Compile no error before trial run.
131 * 09 21 2010 kevin.huang
132 * [WCXRP00000054] [MT6620 Wi-Fi][Driver] Restructure driver for second Interface
133 * Isolate P2P related function for Hardware Software Bundle
137 * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
139 * 06 06 2010 kevin.huang
140 * [WPD00003832][MT6620 5931] Create driver base
141 * [MT6620 5931] Create driver base
144 * [WPD00003831][MT6620 Wi-Fi] Add framework for Wi-Fi Direct support
145 * add cfg80211 interface, which is to replace WE, for further extension
150 /*******************************************************************************
151 * C O M P I L E R F L A G S
152 ********************************************************************************
155 /*******************************************************************************
156 * E X T E R N A L R E F E R E N C E S
157 ********************************************************************************
162 #if CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_WIFI_DIRECT_CFG_80211
163 #include <linux/kernel.h>
164 #include <linux/netdevice.h>
165 #include <linux/wireless.h>
166 #include <linux/ieee80211.h>
167 #include <net/cfg80211.h>
170 #ifdef CFG_DUAL_ANTENNA
171 #include "mtk_porting.h"
172 #include "dual_ant_bwcs.h"
177 /*******************************************************************************
179 ********************************************************************************
182 /*******************************************************************************
184 ********************************************************************************
187 /*******************************************************************************
188 * P U B L I C D A T A
189 ********************************************************************************
192 /*******************************************************************************
193 * P R I V A T E D A T A
194 ********************************************************************************
197 /*******************************************************************************
199 ********************************************************************************
202 /*******************************************************************************
203 * F U N C T I O N D E C L A R A T I O N S
204 ********************************************************************************
209 mtk_p2p_cfg80211func_channel_format_switch(
210 IN struct ieee80211_channel *channel,
211 IN enum nl80211_channel_type channel_type,
212 IN P_RF_CHANNEL_INFO_T prRfChnlInfo,
213 IN P_ENUM_CHNL_EXT_T prChnlSco
216 /*******************************************************************************
218 ********************************************************************************
221 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
222 int mtk_p2p_cfg80211_add_key(
224 struct net_device *ndev,
228 struct key_params *params
231 P_GLUE_INFO_T prGlueInfo = NULL;
232 INT_32 i4Rslt = -EINVAL;
233 WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
234 UINT_32 u4BufLen = 0;
235 P2P_PARAM_KEY_T rKey;
239 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
241 kalMemZero(&rKey, sizeof(P2P_PARAM_KEY_T));
243 rKey.u4KeyIndex = key_index;
245 memcpy(rKey.arBSSID, mac_addr, ETH_ALEN);
246 if ((rKey.arBSSID[0] == 0x00) && (rKey.arBSSID[1] == 0x00) && (rKey.arBSSID[2] == 0x00) &&
247 (rKey.arBSSID[3] == 0x00) && (rKey.arBSSID[4] == 0x00) && (rKey.arBSSID[5] == 0x00)) {
248 rKey.arBSSID[0] = 0xff;
249 rKey.arBSSID[1] = 0xff;
250 rKey.arBSSID[2] = 0xff;
251 rKey.arBSSID[3] = 0xff;
252 rKey.arBSSID[4] = 0xff;
253 rKey.arBSSID[5] = 0xff;
255 if (rKey.arBSSID[0] != 0xFF) {
256 rKey.u4KeyIndex |= BIT(31);
257 if ((rKey.arBSSID[0] != 0x00) || (rKey.arBSSID[1] != 0x00) || (rKey.arBSSID[2] != 0x00) ||
258 (rKey.arBSSID[3] != 0x00) || (rKey.arBSSID[4] != 0x00) || (rKey.arBSSID[5] != 0x00))
259 rKey.u4KeyIndex |= BIT(30);
262 rKey.u4KeyIndex |= BIT(31);
266 rKey.arBSSID[0] = 0xff;
267 rKey.arBSSID[1] = 0xff;
268 rKey.arBSSID[2] = 0xff;
269 rKey.arBSSID[3] = 0xff;
270 rKey.arBSSID[4] = 0xff;
271 rKey.arBSSID[5] = 0xff;
272 rKey.u4KeyIndex |= BIT(31); //????
276 //rKey.aucKeyMaterial[0] = kalMemAlloc(params->key_len, VIR_MEM_TYPE);
277 kalMemCopy(rKey.aucKeyMaterial, params->key, params->key_len);
279 rKey.u4KeyLength = params->key_len;
280 rKey.u4Length = ((UINT_32)&(((P_P2P_PARAM_KEY_T)0)->aucKeyMaterial)) + rKey.u4KeyLength;
282 rStatus = kalIoctl(prGlueInfo,
291 if (rStatus == WLAN_STATUS_SUCCESS)
298 int mtk_p2p_cfg80211_get_key(
300 struct net_device *ndev,
305 void (*callback)(void *cookie, struct key_params*)
308 P_GLUE_INFO_T prGlueInfo = NULL;
312 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
314 // not implemented yet
319 int mtk_p2p_cfg80211_del_key(
321 struct net_device *ndev,
327 P_GLUE_INFO_T prGlueInfo = NULL;
328 PARAM_REMOVE_KEY_T prRemoveKey;
329 INT_32 i4Rslt = -EINVAL;
330 WLAN_STATUS rStatus = WLAN_STATUS_SUCCESS;
331 UINT_32 u4BufLen = 0;
335 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
337 kalMemZero(&prRemoveKey, sizeof(PARAM_REMOVE_KEY_T));
339 memcpy(prRemoveKey.arBSSID, mac_addr, PARAM_MAC_ADDR_LEN);
340 prRemoveKey.u4KeyIndex = key_index;
341 prRemoveKey.u4Length = sizeof(PARAM_REMOVE_KEY_T);
343 rStatus = kalIoctl(prGlueInfo,
344 wlanoidSetRemoveP2PKey,
346 prRemoveKey.u4Length,
353 if (rStatus == WLAN_STATUS_SUCCESS)
361 mtk_p2p_cfg80211_set_default_key (
363 struct net_device *netdev,
369 P_GLUE_INFO_T prGlueInfo = NULL;
373 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
375 // not implemented yet
380 int mtk_p2p_cfg80211_get_station(
382 struct net_device *ndev,
384 struct station_info *sinfo
387 INT_32 i4RetRslt = -EINVAL;
388 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
389 P_GL_P2P_INFO_T prP2pGlueInfo = (P_GL_P2P_INFO_T)NULL;
390 P2P_STATION_INFO_T rP2pStaInfo;
395 if ((wiphy == NULL) ||
402 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_get_station\n"));
404 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
405 prP2pGlueInfo = prGlueInfo->prP2PInfo;
409 /* Get station information. */
410 /* 1. Inactive time? */
411 p2pFuncGetStationInfo(prGlueInfo->prAdapter,
416 sinfo->filled |= STATION_INFO_INACTIVE_TIME;
417 sinfo->inactive_time = rP2pStaInfo.u4InactiveTime;
418 sinfo->generation = prP2pGlueInfo->i4Generation;
427 mtk_p2p_cfg80211_scan (
429 struct net_device *ndev,
430 struct cfg80211_scan_request *request
433 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
434 P_GL_P2P_INFO_T prP2pGlueInfo = (P_GL_P2P_INFO_T)NULL;
435 P_MSG_P2P_SCAN_REQUEST_T prMsgScanRequest = (P_MSG_P2P_SCAN_REQUEST_T)NULL;
436 UINT_32 u4MsgSize = 0, u4Idx = 0;
437 INT_32 i4RetRslt = -EINVAL;
438 P_RF_CHANNEL_INFO_T prRfChannelInfo = (P_RF_CHANNEL_INFO_T)NULL;
439 P_P2P_SSID_STRUCT_T prSsidStruct = (P_P2P_SSID_STRUCT_T)NULL;
440 struct ieee80211_channel *prChannel = NULL;
441 struct cfg80211_ssid *prSsid = NULL;
443 /* [---------Channel---------] [---------SSID---------][---------IE---------] */
447 if ((wiphy == NULL) || (request == NULL)) {
451 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
453 prP2pGlueInfo = prGlueInfo->prP2PInfo;
455 if (prP2pGlueInfo == NULL) {
460 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_scan.\n"));
463 if (prP2pGlueInfo->prScanRequest != NULL) {
464 /* There have been a scan request on-going processing. */
465 DBGLOG(P2P, TRACE, ("There have been a scan request on-going processing.\n"));
469 prP2pGlueInfo->prScanRequest = request;
471 /* Should find out why the n_channels so many? */
472 if (request->n_channels > MAXIMUM_OPERATION_CHANNEL_LIST) {
473 request->n_channels = MAXIMUM_OPERATION_CHANNEL_LIST;
474 DBGLOG(P2P, TRACE, ("Channel list exceed the maximun support.\n"));
477 u4MsgSize = sizeof(MSG_P2P_SCAN_REQUEST_T) +
478 (request->n_channels * sizeof(RF_CHANNEL_INFO_T)) +
479 (request->n_ssids * sizeof(PARAM_SSID_T)) +
482 prMsgScanRequest = cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, u4MsgSize);
484 if (prMsgScanRequest == NULL) {
490 DBGLOG(P2P, TRACE, ("Generating scan request message.\n"));
492 prMsgScanRequest->rMsgHdr.eMsgId = MID_MNY_P2P_DEVICE_DISCOVERY;
496 DBGLOG(P2P, TRACE, ("Requesting channel number:%d.\n", request->n_channels));
498 for (u4Idx = 0; u4Idx < request->n_channels; u4Idx++) {
499 /* Translate Freq from MHz to channel number. */
500 prRfChannelInfo = &(prMsgScanRequest->arChannelListInfo[u4Idx]);
501 prChannel = request->channels[u4Idx];
503 prRfChannelInfo->ucChannelNum = nicFreq2ChannelNum(prChannel->center_freq * 1000);
504 DBGLOG(P2P, TRACE, ("Scanning Channel:%d, freq: %d\n",
505 prRfChannelInfo->ucChannelNum,
506 prChannel->center_freq));
507 switch (prChannel->band) {
508 case IEEE80211_BAND_2GHZ:
509 prRfChannelInfo->eBand = BAND_2G4;
511 case IEEE80211_BAND_5GHZ:
512 prRfChannelInfo->eBand = BAND_5G;
515 DBGLOG(P2P, TRACE, ("UNKNOWN Band info from supplicant\n"));
516 prRfChannelInfo->eBand = BAND_NULL;
523 prMsgScanRequest->u4NumChannel = request->n_channels;
525 DBGLOG(P2P, TRACE, ("Finish channel list.\n"));
528 prSsid = request->ssids;
529 prSsidStruct = (P_P2P_SSID_STRUCT_T)prRfChannelInfo;
530 if (request->n_ssids) {
531 ASSERT(prSsidStruct == &(prMsgScanRequest->arChannelListInfo[u4Idx]));
532 prMsgScanRequest->prSSID = prSsidStruct;
535 for (u4Idx = 0; u4Idx < request->n_ssids; u4Idx++) {
536 COPY_SSID(prSsidStruct->aucSsid,
537 prSsidStruct->ucSsidLen,
538 request->ssids->ssid,
539 request->ssids->ssid_len);
545 prMsgScanRequest->i4SsidNum = request->n_ssids;
547 DBGLOG(P2P, TRACE, ("Finish SSID list:%d.\n", request->n_ssids));
550 prMsgScanRequest->pucIEBuf = (PUINT_8)prSsidStruct;
551 if (request->ie_len) {
552 kalMemCopy(prMsgScanRequest->pucIEBuf, request->ie, request->ie_len);
553 prMsgScanRequest->u4IELen = request->ie_len;
556 DBGLOG(P2P, TRACE, ("Finish IE Buffer.\n"));
559 mboxSendMsg(prGlueInfo->prAdapter,
561 (P_MSG_HDR_T)prMsgScanRequest,
562 MSG_SEND_METHOD_BUF);
568 } /* mtk_p2p_cfg80211_scan */
570 int mtk_p2p_cfg80211_set_wiphy_params(
575 INT_32 i4Rslt = -EINVAL;
576 P_GLUE_INFO_T prGlueInfo = NULL;
584 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_set_wiphy_params\n"));
585 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
587 if (changed & WIPHY_PARAM_RETRY_SHORT) {
589 DBGLOG(P2P, TRACE, ("The RETRY short param is changed.\n"));
592 if (changed & WIPHY_PARAM_RETRY_LONG) {
594 DBGLOG(P2P, TRACE, ("The RETRY long param is changed.\n"));
598 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
600 DBGLOG(P2P, TRACE, ("The RETRY fragmentation threshold is changed.\n"));
603 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
605 DBGLOG(P2P, TRACE, ("The RETRY RTS threshold is changed.\n"));
608 if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
610 DBGLOG(P2P, TRACE, ("The coverage class is changed???\n"));
620 } /* mtk_p2p_cfg80211_set_wiphy_params */
625 mtk_p2p_cfg80211_join_ibss(
627 struct net_device *dev,
628 struct cfg80211_ibss_params *params
631 P_GLUE_INFO_T prGlueInfo = NULL;
635 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
637 // not implemented yet
643 mtk_p2p_cfg80211_leave_ibss(
645 struct net_device *dev
648 P_GLUE_INFO_T prGlueInfo = NULL;
652 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
654 // not implemented yet
660 mtk_p2p_cfg80211_set_txpower(
662 enum nl80211_tx_power_setting type,
666 P_GLUE_INFO_T prGlueInfo = NULL;
670 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
672 // not implemented yet
678 mtk_p2p_cfg80211_get_txpower(
683 P_GLUE_INFO_T prGlueInfo = NULL;
687 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
689 // not implemented yet
695 mtk_p2p_cfg80211_set_power_mgmt(
697 struct net_device *dev,
702 P_GLUE_INFO_T prGlueInfo = NULL;
703 PARAM_POWER_MODE ePowerMode;
707 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
709 INT_32 value = enabled;
714 ePowerMode = Param_PowerModeFast_PSP;
717 ePowerMode = Param_PowerModeMAX_PSP;
721 ePowerMode = Param_PowerModeCAM;
724 rStatus = kalIoctl(prGlueInfo,
725 wlanoidSetP2pPowerSaveProfile,
734 if (rStatus != WLAN_STATUS_SUCCESS) {
735 DBGLOG(REQ, WARN, ("p2p set_power_mgmt error:%lx\n", rStatus));
744 //&&&&&&&&&&&&&&&&&&&&&&&&&& Add for ICS Wi-Fi Direct Support. &&&&&&&&&&&&&&&&&&&&&&&
745 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
747 mtk_p2p_cfg80211_start_ap (
749 struct net_device *dev,
750 struct cfg80211_ap_settings *settings
753 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
754 INT_32 i4Rslt = -EINVAL;
755 P_MSG_P2P_BEACON_UPDATE_T prP2pBcnUpdateMsg = (P_MSG_P2P_BEACON_UPDATE_T)NULL;
756 P_MSG_P2P_START_AP_T prP2pStartAPMsg = (P_MSG_P2P_START_AP_T)NULL;
757 PUINT_8 pucBuffer = (PUINT_8)NULL;
758 // P_IE_SSID_T prSsidIE = (P_IE_SSID_T)NULL;
762 if ((wiphy == NULL) || (settings == NULL)) {
766 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_start_ap.\n"));
767 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
769 prP2pBcnUpdateMsg = (P_MSG_P2P_BEACON_UPDATE_T)cnmMemAlloc(
770 prGlueInfo->prAdapter,
772 (sizeof(MSG_P2P_BEACON_UPDATE_T) + settings->beacon.head_len + settings->beacon.tail_len));
774 if (prP2pBcnUpdateMsg == NULL) {
781 prP2pBcnUpdateMsg->rMsgHdr.eMsgId = MID_MNY_P2P_BEACON_UPDATE;
782 pucBuffer = prP2pBcnUpdateMsg->aucBuffer;
784 if (settings->beacon.head_len != 0) {
785 kalMemCopy(pucBuffer, settings->beacon.head, settings->beacon.head_len);
787 prP2pBcnUpdateMsg->u4BcnHdrLen = settings->beacon.head_len;
789 prP2pBcnUpdateMsg->pucBcnHdr = pucBuffer;
791 pucBuffer = (PUINT_8)((UINT_32)pucBuffer + (UINT_32)settings->beacon.head_len);
794 prP2pBcnUpdateMsg->u4BcnHdrLen = 0;
796 prP2pBcnUpdateMsg->pucBcnHdr = NULL;
799 if (settings->beacon.tail_len != 0) {
800 UINT_8 ucLen = settings->beacon.tail_len;
802 prP2pBcnUpdateMsg->pucBcnBody = pucBuffer;
805 // IEEE 802.11 2007 - 7.3.2.6
806 TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
807 TIM_IE(pucBuffer)->ucLength = (3 + MAX_LEN_TIM_PARTIAL_BMP)/*((u4N2 - u4N1) + 4)*/; // NOTE: fixed PVB length (AID is allocated from 8 ~ 15 only)
808 TIM_IE(pucBuffer)->ucDTIMCount = 0/*prBssInfo->ucDTIMCount*/; // will be overwrite by FW
809 TIM_IE(pucBuffer)->ucDTIMPeriod = 1;
810 TIM_IE(pucBuffer)->ucBitmapControl = 0/*ucBitmapControl | (UINT_8)u4N1*/; // will be overwrite by FW
811 ucLen += IE_SIZE(pucBuffer);
812 pucBuffer += IE_SIZE(pucBuffer);
814 kalMemCopy(pucBuffer, settings->beacon.tail, settings->beacon.tail_len);
816 prP2pBcnUpdateMsg->u4BcnBodyLen = ucLen;
819 prP2pBcnUpdateMsg->u4BcnBodyLen = 0;
821 prP2pBcnUpdateMsg->pucBcnBody = NULL;
825 mboxSendMsg(prGlueInfo->prAdapter,
827 (P_MSG_HDR_T)prP2pBcnUpdateMsg,
828 MSG_SEND_METHOD_BUF);
831 prP2pStartAPMsg = (P_MSG_P2P_START_AP_T)cnmMemAlloc(
832 prGlueInfo->prAdapter,
834 sizeof(MSG_P2P_START_AP_T));
836 if (prP2pStartAPMsg == NULL) {
842 prP2pStartAPMsg->rMsgHdr.eMsgId = MID_MNY_P2P_START_AP;
844 prP2pStartAPMsg->fgIsPrivacy = settings->privacy;
846 prP2pStartAPMsg->u4BcnInterval = settings->beacon_interval;
848 prP2pStartAPMsg->u4DtimPeriod = settings->dtim_period;
851 prP2pStartAPMsg->ucHiddenSsidType = settings->hidden_ssid;
853 COPY_SSID(prP2pStartAPMsg->aucSsid,
854 prP2pStartAPMsg->u2SsidLen,
858 mboxSendMsg(prGlueInfo->prAdapter,
860 (P_MSG_HDR_T)prP2pStartAPMsg,
861 MSG_SEND_METHOD_BUF);
871 /////////////////////////
873 * struct cfg80211_ap_settings - AP configuration
875 * Used to configure an AP interface.
877 * @beacon: beacon data
878 * @beacon_interval: beacon interval
879 * @dtim_period: DTIM period
880 * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from
882 * @ssid_len: length of @ssid
883 * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames
884 * @crypto: crypto settings
885 * @privacy: the BSS uses privacy
886 * @auth_type: Authentication type (algorithm)
887 * @inactivity_timeout: time in seconds to determine station's inactivity.
889 // struct cfg80211_ap_settings {
890 // struct cfg80211_beacon_data beacon;
892 // int beacon_interval, dtim_period;
895 // enum nl80211_hidden_ssid hidden_ssid;
896 // struct cfg80211_crypto_settings crypto;
898 // enum nl80211_auth_type auth_type;
899 // int inactivity_timeout;
904 } /* mtk_p2p_cfg80211_start_ap */
908 mtk_p2p_cfg80211_change_beacon (
910 struct net_device *dev,
911 struct cfg80211_beacon_data *info
914 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
915 INT_32 i4Rslt = -EINVAL;
916 P_MSG_P2P_BEACON_UPDATE_T prP2pBcnUpdateMsg = (P_MSG_P2P_BEACON_UPDATE_T)NULL;
917 PUINT_8 pucBuffer = (PUINT_8)NULL;
918 start_beacon = false;
921 if ((wiphy == NULL) || (info == NULL)) {
925 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_change_beacon.\n"));
926 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
928 prP2pBcnUpdateMsg = (P_MSG_P2P_BEACON_UPDATE_T)cnmMemAlloc(
929 prGlueInfo->prAdapter,
931 (sizeof(MSG_P2P_BEACON_UPDATE_T) + info->head_len + info->tail_len));
934 if (prP2pBcnUpdateMsg == NULL) {
940 prP2pBcnUpdateMsg->rMsgHdr.eMsgId = MID_MNY_P2P_BEACON_UPDATE;
941 pucBuffer = prP2pBcnUpdateMsg->aucBuffer;
943 if (info->head_len != 0) {
944 kalMemCopy(pucBuffer, info->head, info->head_len);
946 prP2pBcnUpdateMsg->u4BcnHdrLen = info->head_len;
948 prP2pBcnUpdateMsg->pucBcnHdr = pucBuffer;
950 pucBuffer = (PUINT_8)((UINT_32)pucBuffer + (UINT_32)info->head_len);
953 prP2pBcnUpdateMsg->u4BcnHdrLen = 0;
955 prP2pBcnUpdateMsg->pucBcnHdr = NULL;
958 if (info->tail_len != 0) {
959 UINT_8 ucLen = info->tail_len;
961 prP2pBcnUpdateMsg->pucBcnBody = pucBuffer;
964 // IEEE 802.11 2007 - 7.3.2.6
965 TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
966 TIM_IE(pucBuffer)->ucLength = (3 + MAX_LEN_TIM_PARTIAL_BMP)/*((u4N2 - u4N1) + 4)*/; // NOTE: fixed PVB length (AID is allocated from 8 ~ 15 only)
967 TIM_IE(pucBuffer)->ucDTIMCount = 0/*prBssInfo->ucDTIMCount*/; // will be overwrite by FW
968 TIM_IE(pucBuffer)->ucDTIMPeriod = 1;
969 TIM_IE(pucBuffer)->ucBitmapControl = 0/*ucBitmapControl | (UINT_8)u4N1*/; // will be overwrite by FW
970 ucLen += IE_SIZE(pucBuffer);
971 pucBuffer += IE_SIZE(pucBuffer);
973 kalMemCopy(pucBuffer, info->tail, info->tail_len);
975 prP2pBcnUpdateMsg->u4BcnBodyLen = ucLen;
978 prP2pBcnUpdateMsg->u4BcnBodyLen = 0;
980 prP2pBcnUpdateMsg->pucBcnBody = NULL;
984 mboxSendMsg(prGlueInfo->prAdapter,
986 (P_MSG_HDR_T)prP2pBcnUpdateMsg,
987 MSG_SEND_METHOD_BUF);
989 ////////////////////////////
991 * struct cfg80211_beacon_data - beacon data
992 * @head: head portion of beacon (before TIM IE)
993 * or %NULL if not changed
994 * @tail: tail portion of beacon (after TIM IE)
995 * or %NULL if not changed
996 * @head_len: length of @head
997 * @tail_len: length of @tail
998 * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL
999 * @beacon_ies_len: length of beacon_ies in octets
1000 * @proberesp_ies: extra information element(s) to add into Probe Response
1002 * @proberesp_ies_len: length of proberesp_ies in octets
1003 * @assocresp_ies: extra information element(s) to add into (Re)Association
1004 * Response frames or %NULL
1005 * @assocresp_ies_len: length of assocresp_ies in octets
1006 * @probe_resp_len: length of probe response template (@probe_resp)
1007 * @probe_resp: probe response template (AP mode only)
1009 //struct cfg80211_beacon_data {
1010 // const u8 *head, *tail;
1011 // const u8 *beacon_ies;
1012 // const u8 *proberesp_ies;
1013 // const u8 *assocresp_ies;
1014 // const u8 *probe_resp;
1016 // size_t head_len, tail_len;
1017 // size_t beacon_ies_len;
1018 // size_t proberesp_ies_len;
1019 // size_t assocresp_ies_len;
1020 // size_t probe_resp_len;
1023 ////////////////////////////
1028 } /* mtk_p2p_cfg80211_change_beacon */
1032 mtk_p2p_cfg80211_add_set_beacon (
1033 struct wiphy *wiphy,
1034 struct net_device *dev,
1035 struct beacon_parameters *info
1038 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1039 INT_32 i4Rslt = -EINVAL;
1040 P_MSG_P2P_BEACON_UPDATE_T prP2pBcnUpdateMsg = (P_MSG_P2P_BEACON_UPDATE_T)NULL;
1041 P_MSG_P2P_START_AP_T prP2pStartAPMsg = (P_MSG_P2P_START_AP_T)NULL;
1042 PUINT_8 pucBuffer = (PUINT_8)NULL;
1043 P_IE_SSID_T prSsidIE = (P_IE_SSID_T)NULL;
1044 start_beacon = true;
1047 if ((wiphy == NULL) || (info == NULL)) {
1051 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_add_set_beacon.\n"));
1052 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1054 prP2pBcnUpdateMsg = (P_MSG_P2P_BEACON_UPDATE_T)cnmMemAlloc(
1055 prGlueInfo->prAdapter,
1057 (sizeof(MSG_P2P_BEACON_UPDATE_T) + info->head_len + info->tail_len));
1059 if (prP2pBcnUpdateMsg == NULL) {
1064 kalMemZero(prP2pBcnUpdateMsg, (sizeof(MSG_P2P_BEACON_UPDATE_T) + info->head_len + info->tail_len));
1066 prP2pBcnUpdateMsg->rMsgHdr.eMsgId = MID_MNY_P2P_BEACON_UPDATE;
1067 pucBuffer = prP2pBcnUpdateMsg->aucBuffer;
1069 if (info->head_len != 0) {
1070 kalMemCopy(pucBuffer, info->head, info->head_len);
1072 prP2pBcnUpdateMsg->u4BcnHdrLen = info->head_len;
1074 prP2pBcnUpdateMsg->pucBcnHdr = pucBuffer;
1076 pucBuffer = (PUINT_8)((UINT_32)pucBuffer + (UINT_32)info->head_len);
1079 prP2pBcnUpdateMsg->u4BcnHdrLen = 0;
1081 prP2pBcnUpdateMsg->pucBcnHdr = NULL;
1084 if (info->tail_len != 0) {
1085 UINT_8 ucLen = info->tail_len;
1087 prP2pBcnUpdateMsg->pucBcnBody = pucBuffer;
1090 // IEEE 802.11 2007 - 7.3.2.6
1091 TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
1092 TIM_IE(pucBuffer)->ucLength = (3 + MAX_LEN_TIM_PARTIAL_BMP)/*((u4N2 - u4N1) + 4)*/; // NOTE: fixed PVB length (AID is allocated from 8 ~ 15 only)
1093 TIM_IE(pucBuffer)->ucDTIMCount = 0/*prBssInfo->ucDTIMCount*/; // will be overwrite by FW
1094 TIM_IE(pucBuffer)->ucDTIMPeriod = 1;
1095 TIM_IE(pucBuffer)->ucBitmapControl = 0/*ucBitmapControl | (UINT_8)u4N1*/; // will be overwrite by FW
1096 ucLen += IE_SIZE(pucBuffer);
1097 pucBuffer += IE_SIZE(pucBuffer);
1099 kalMemCopy(pucBuffer, info->tail, info->tail_len);
1101 prP2pBcnUpdateMsg->u4BcnBodyLen = ucLen;
1104 prP2pBcnUpdateMsg->u4BcnBodyLen = 0;
1106 prP2pBcnUpdateMsg->pucBcnBody = NULL;
1110 mboxSendMsg(prGlueInfo->prAdapter,
1112 (P_MSG_HDR_T)prP2pBcnUpdateMsg,
1113 MSG_SEND_METHOD_BUF);
1116 prP2pStartAPMsg = (P_MSG_P2P_START_AP_T)cnmMemAlloc(
1117 prGlueInfo->prAdapter,
1119 sizeof(MSG_P2P_START_AP_T));
1121 if (prP2pStartAPMsg == NULL) {
1126 kalMemZero(prP2pStartAPMsg, sizeof(MSG_P2P_START_AP_T));
1128 prP2pStartAPMsg->rMsgHdr.eMsgId = MID_MNY_P2P_START_AP;
1129 printk("mtk_p2p_cfg80211_add_set_beacon MID_MNY_P2P_START_AP");
1131 prP2pStartAPMsg->fgIsPrivacy = FALSE;
1133 prP2pStartAPMsg->u4BcnInterval = info->interval;
1135 prP2pStartAPMsg->u4DtimPeriod = info->dtim_period;
1138 prP2pStartAPMsg->ucHiddenSsidType = ENUM_HIDDEN_SSID_NONE;
1141 if (info->head_len > OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem)) {
1142 P_WLAN_BEACON_FRAME_T prWlanBcnFrame = info->head;
1144 prSsidIE = (P_IE_HDR_T)p2pFuncGetSpecIE(prGlueInfo->prAdapter,
1145 (PUINT_8)prWlanBcnFrame->aucInfoElem,
1146 (info->head_len - OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem)),
1150 kalMemCopy(prP2pStartAPMsg->aucSsid, SSID_IE(prSsidIE)->aucSSID, IE_LEN(prSsidIE));
1155 mboxSendMsg(prGlueInfo->prAdapter,
1157 (P_MSG_HDR_T)prP2pStartAPMsg,
1158 MSG_SEND_METHOD_BUF);
1166 /* mtk_p2p_cfg80211_add_set_beacon */
1168 mtk_p2p_cfg80211_add_set_beacon_1 (
1169 struct wiphy *wiphy,
1170 struct net_device *dev,
1171 struct beacon_parameters *info
1174 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1175 INT_32 i4Rslt = -EINVAL;
1176 P_MSG_P2P_BEACON_UPDATE_T prP2pBcnUpdateMsg = (P_MSG_P2P_BEACON_UPDATE_T)NULL;
1177 P_MSG_P2P_START_AP_T prP2pStartAPMsg = (P_MSG_P2P_START_AP_T)NULL;
1178 PUINT_8 pucBuffer = (PUINT_8)NULL;
1179 P_IE_SSID_T prSsidIE = (P_IE_SSID_T)NULL;
1180 start_beacon = false;
1183 if ((wiphy == NULL) || (info == NULL)) {
1187 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_add_set_beacon_1.\n"));
1188 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1190 prP2pBcnUpdateMsg = (P_MSG_P2P_BEACON_UPDATE_T)cnmMemAlloc(
1191 prGlueInfo->prAdapter,
1193 (sizeof(MSG_P2P_BEACON_UPDATE_T) + info->head_len + info->tail_len));
1195 if (prP2pBcnUpdateMsg == NULL) {
1200 kalMemZero(prP2pBcnUpdateMsg, (sizeof(MSG_P2P_BEACON_UPDATE_T) + info->head_len + info->tail_len));
1202 prP2pBcnUpdateMsg->rMsgHdr.eMsgId = MID_MNY_P2P_BEACON_UPDATE;
1203 pucBuffer = prP2pBcnUpdateMsg->aucBuffer;
1205 if (info->head_len != 0) {
1206 kalMemCopy(pucBuffer, info->head, info->head_len);
1208 prP2pBcnUpdateMsg->u4BcnHdrLen = info->head_len;
1210 prP2pBcnUpdateMsg->pucBcnHdr = pucBuffer;
1212 pucBuffer = (PUINT_8)((UINT_32)pucBuffer + (UINT_32)info->head_len);
1215 prP2pBcnUpdateMsg->u4BcnHdrLen = 0;
1217 prP2pBcnUpdateMsg->pucBcnHdr = NULL;
1220 if (info->tail_len != 0) {
1221 UINT_8 ucLen = info->tail_len;
1223 prP2pBcnUpdateMsg->pucBcnBody = pucBuffer;
1226 // IEEE 802.11 2007 - 7.3.2.6
1227 TIM_IE(pucBuffer)->ucId = ELEM_ID_TIM;
1228 TIM_IE(pucBuffer)->ucLength = (3 + MAX_LEN_TIM_PARTIAL_BMP)/*((u4N2 - u4N1) + 4)*/; // NOTE: fixed PVB length (AID is allocated from 8 ~ 15 only)
1229 TIM_IE(pucBuffer)->ucDTIMCount = 0/*prBssInfo->ucDTIMCount*/; // will be overwrite by FW
1230 TIM_IE(pucBuffer)->ucDTIMPeriod = 1;
1231 TIM_IE(pucBuffer)->ucBitmapControl = 0/*ucBitmapControl | (UINT_8)u4N1*/; // will be overwrite by FW
1232 ucLen += IE_SIZE(pucBuffer);
1233 pucBuffer += IE_SIZE(pucBuffer);
1235 kalMemCopy(pucBuffer, info->tail, info->tail_len);
1237 prP2pBcnUpdateMsg->u4BcnBodyLen = ucLen;
1240 prP2pBcnUpdateMsg->u4BcnBodyLen = 0;
1242 prP2pBcnUpdateMsg->pucBcnBody = NULL;
1246 mboxSendMsg(prGlueInfo->prAdapter,
1248 (P_MSG_HDR_T)prP2pBcnUpdateMsg,
1249 MSG_SEND_METHOD_BUF);
1252 prP2pStartAPMsg = (P_MSG_P2P_START_AP_T)cnmMemAlloc(
1253 prGlueInfo->prAdapter,
1255 sizeof(MSG_P2P_START_AP_T));
1257 if (prP2pStartAPMsg == NULL) {
1262 kalMemZero(prP2pStartAPMsg, sizeof(MSG_P2P_START_AP_T));
1264 prP2pStartAPMsg->rMsgHdr.eMsgId = MID_MNY_P2P_START_AP;
1265 printk("mtk_p2p_cfg80211_add_set_beacon_1 MID_MNY_P2P_START_AP");
1267 prP2pStartAPMsg->fgIsPrivacy = FALSE;
1269 prP2pStartAPMsg->u4BcnInterval = info->interval;
1271 prP2pStartAPMsg->u4DtimPeriod = info->dtim_period;
1274 prP2pStartAPMsg->ucHiddenSsidType = ENUM_HIDDEN_SSID_NONE;
1277 if (info->head_len > OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem)) {
1278 P_WLAN_BEACON_FRAME_T prWlanBcnFrame = info->head;
1280 prSsidIE = (P_IE_HDR_T)p2pFuncGetSpecIE(prGlueInfo->prAdapter,
1281 (PUINT_8)prWlanBcnFrame->aucInfoElem,
1282 (info->head_len - OFFSET_OF(WLAN_BEACON_FRAME_T, aucInfoElem)),
1286 kalMemCopy(prP2pStartAPMsg->aucSsid, SSID_IE(prSsidIE)->aucSSID, IE_LEN(prSsidIE));
1291 mboxSendMsg(prGlueInfo->prAdapter,
1293 (P_MSG_HDR_T)prP2pStartAPMsg,
1294 MSG_SEND_METHOD_BUF);
1302 /* mtk_p2p_cfg80211_add_set_beacon */
1307 mtk_p2p_cfg80211_stop_ap (
1308 struct wiphy *wiphy,
1309 struct net_device *dev
1312 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1313 INT_32 i4Rslt = -EINVAL;
1314 P_MSG_P2P_SWITCH_OP_MODE_T prP2pSwitchMode = (P_MSG_P2P_SWITCH_OP_MODE_T)NULL;
1317 if (wiphy == NULL) {
1322 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_stop_ap.\n"));
1323 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1326 prP2pSwitchMode = cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_SWITCH_OP_MODE_T));
1328 if (prP2pSwitchMode == NULL) {
1334 prP2pSwitchMode->rMsgHdr.eMsgId = MID_MNY_P2P_STOP_AP;
1336 mboxSendMsg(prGlueInfo->prAdapter,
1338 (P_MSG_HDR_T)prP2pSwitchMode,
1339 MSG_SEND_METHOD_BUF);
1344 #ifdef CFG_DUAL_ANTENNA
1345 if(p2pFuncIsAPMode(prGlueInfo->prAdapter->rWifiVar.prP2pFsmInfo))
1346 wifi2bwcs_connection_event_ind_handler(prGlueInfo->prAdapter->prGlueInfo, WIFI_EVENT_SOFTAP_CONN_DEL);
1348 wifi2bwcs_connection_event_ind_handler(prGlueInfo->prAdapter->prGlueInfo, WIFI_EVENT_P2P_GO_CONN_DEL);
1353 } /* mtk_p2p_cfg80211_stop_ap */
1357 mtk_p2p_cfg80211_deauth (
1358 struct wiphy *wiphy,
1359 struct net_device *dev,
1360 struct cfg80211_deauth_request *req
1361 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
1366 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1370 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1372 // not implemented yet
1373 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_deauth.\n"));
1376 } /* mtk_p2p_cfg80211_deauth */
1381 mtk_p2p_cfg80211_disassoc (
1382 struct wiphy *wiphy,
1383 struct net_device *dev,
1384 struct cfg80211_disassoc_request *req
1385 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
1390 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1394 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1396 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_disassoc.\n"));
1398 // not implemented yet
1401 } /* mtk_p2p_cfg80211_disassoc */
1404 #if 0//LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
1406 mtk_p2p_cfg80211_remain_on_channel2 (
1407 struct wiphy *wiphy,
1408 struct net_device *dev,
1409 struct ieee80211_channel *chan,
1410 enum nl80211_channel_type channel_type,
1411 unsigned int duration,
1416 INT_32 i4Rslt = -EINVAL;
1417 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1418 P_GL_P2P_INFO_T prGlueP2pInfo = (P_GL_P2P_INFO_T)NULL;
1419 P_MSG_P2P_CHNL_REQUEST_T prMsgChnlReq = (P_MSG_P2P_CHNL_REQUEST_T)NULL;
1423 if ((wiphy == NULL) ||
1429 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1430 prGlueP2pInfo = prGlueInfo->prP2PInfo;
1432 //*cookie = prGlueP2pInfo->u8Cookie++;
1434 prMsgChnlReq = cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_CHNL_REQUEST_T));
1436 if (prMsgChnlReq == NULL) {
1442 //DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_remain_on_channel\n"));
1444 prMsgChnlReq->rMsgHdr.eMsgId = MID_MNY_P2P_CHNL_REQ;
1445 prMsgChnlReq->u8Cookie = *cookie;
1446 prMsgChnlReq->u4Duration = duration;
1447 prMsgChnlReq->fgNeedIndSupp = fgNeedIndSupp;
1450 mtk_p2p_cfg80211func_channel_format_switch(chan,
1452 &prMsgChnlReq->rChannelInfo,
1453 &prMsgChnlReq->eChnlSco);
1456 mboxSendMsg(prGlueInfo->prAdapter,
1458 (P_MSG_HDR_T)prMsgChnlReq,
1459 MSG_SEND_METHOD_BUF);
1467 /* mtk_p2p_cfg80211_remain_on_channel */
1470 mtk_p2p_cfg80211_remain_on_channel (
1471 struct wiphy *wiphy,
1472 struct net_device *dev,
1473 struct ieee80211_channel *chan,
1474 enum nl80211_channel_type channel_type,
1475 unsigned int duration,
1480 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1481 P_GL_P2P_INFO_T prGlueP2pInfo = (P_GL_P2P_INFO_T)NULL;
1483 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1484 prGlueP2pInfo = prGlueInfo->prP2PInfo;
1485 *cookie = prGlueP2pInfo->u8Cookie++;
1487 if(atomic_read(&prGlueInfo->rMgmtTxAto) == 1) {
1488 ret = wait_for_completion_timeout(&prGlueInfo->rMgmtTxComp, 500*HZ/1000);
1491 ret = mtk_p2p_cfg80211_remain_on_channel2(wiphy, dev, chan, channel_type, duration, cookie, true);
1497 mtk_p2p_cfg80211_remain_on_channel (
1498 struct wiphy *wiphy,
1499 struct net_device *dev,
1500 struct ieee80211_channel *chan,
1501 enum nl80211_channel_type channel_type,
1502 unsigned int duration,
1506 INT_32 i4Rslt = -EINVAL;
1507 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1508 P_GL_P2P_INFO_T prGlueP2pInfo = (P_GL_P2P_INFO_T)NULL;
1509 P_MSG_P2P_CHNL_REQUEST_T prMsgChnlReq = (P_MSG_P2P_CHNL_REQUEST_T)NULL;
1513 if ((wiphy == NULL) ||
1519 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1520 prGlueP2pInfo = prGlueInfo->prP2PInfo;
1522 *cookie = prGlueP2pInfo->u8Cookie++;
1524 prMsgChnlReq = cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_CHNL_REQUEST_T));
1526 if (prMsgChnlReq == NULL) {
1532 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_remain_on_channel\n"));
1534 prMsgChnlReq->rMsgHdr.eMsgId = MID_MNY_P2P_CHNL_REQ;
1535 prMsgChnlReq->u8Cookie = *cookie;
1536 prMsgChnlReq->u4Duration = duration;
1539 mtk_p2p_cfg80211func_channel_format_switch(chan,
1541 &prMsgChnlReq->rChannelInfo,
1542 &prMsgChnlReq->eChnlSco);
1544 mboxSendMsg(prGlueInfo->prAdapter,
1546 (P_MSG_HDR_T)prMsgChnlReq,
1547 MSG_SEND_METHOD_BUF);
1557 /* mtk_p2p_cfg80211_remain_on_channel */
1563 mtk_p2p_cfg80211_cancel_remain_on_channel (
1564 struct wiphy *wiphy,
1565 struct net_device *dev,
1569 INT_32 i4Rslt = -EINVAL;
1570 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1571 P_MSG_P2P_CHNL_ABORT_T prMsgChnlAbort = (P_MSG_P2P_CHNL_ABORT_T)NULL;
1574 if ((wiphy == NULL) || (dev == NULL)) {
1579 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1581 prMsgChnlAbort = cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_CHNL_ABORT_T));
1583 if (prMsgChnlAbort == NULL) {
1589 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_cancel_remain_on_channel\n"));
1591 prMsgChnlAbort->rMsgHdr.eMsgId = MID_MNY_P2P_CHNL_ABORT;
1592 prMsgChnlAbort->u8Cookie = cookie;
1595 mboxSendMsg(prGlueInfo->prAdapter,
1597 (P_MSG_HDR_T)prMsgChnlAbort,
1598 MSG_SEND_METHOD_BUF);
1604 } /* mtk_p2p_cfg80211_cancel_remain_on_channel */
1606 #if 0 //LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)
1608 mtk_p2p_cfg80211_mgmt_tx (
1609 struct wiphy *wiphy, struct net_device *dev,
1610 struct ieee80211_channel *chan, bool offchan,
1611 enum nl80211_channel_type channel_type,
1612 bool channel_type_valid, unsigned int wait,
1615 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
1617 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
1618 bool dont_wait_for_ack,
1625 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1626 P_GL_P2P_INFO_T prGlueP2pInfo = (P_GL_P2P_INFO_T)NULL;
1627 INT_32 i4Rslt = -EINVAL;
1628 INT_32 channel_time= 0;
1629 P_MSG_P2P_MGMT_TX_REQUEST_T prMsgTxReq = (P_MSG_P2P_MGMT_TX_REQUEST_T)NULL;
1630 P_MSDU_INFO_T prMgmtFrame = (P_MSDU_INFO_T)NULL;
1631 PUINT_8 pucFrameBuf = (PUINT_8)NULL;
1632 P_P2P_FSM_INFO_T prP2pFsmInfo = (P_P2P_FSM_INFO_T)NULL;
1633 RF_CHANNEL_INFO_T ChnlInfo;
1634 ENUM_CHNL_EXT_T ChnlSco;
1636 if ((wiphy == NULL) ||
1643 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1644 prGlueP2pInfo = prGlueInfo->prP2PInfo;
1645 prP2pFsmInfo = prGlueInfo->prAdapter->rWifiVar.prP2pFsmInfo;
1646 P_P2P_CHNL_REQ_INFO_T prChnlReqInfo = &(prP2pFsmInfo->rChnlReqInfo);
1648 mtk_p2p_cfg80211func_channel_format_switch(chan,
1652 if (prChnlReqInfo->prMsgTxReq!=NULL){
1657 //buffer mgmt frame into driver
1658 *cookie = prGlueP2pInfo->u8Cookie++;
1660 /* Channel & Channel Type & Wait time are ignored. */
1661 prMsgTxReq = cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_MGMT_TX_REQUEST_T));
1663 if (prMsgTxReq == NULL) {
1669 prMsgTxReq->fgNoneCckRate = FALSE;
1670 prMsgTxReq->fgIsWaitRsp = TRUE;
1672 prMgmtFrame = cnmMgtPktAlloc(prGlueInfo->prAdapter, (UINT_32)(len + MAC_TX_RESERVED_FIELD));
1674 if ((prMsgTxReq->prMgmtMsduInfo = prMgmtFrame) == NULL) {
1680 prMsgTxReq->u8Cookie = *cookie;
1681 prMsgTxReq->rMsgHdr.eMsgId = MID_MNY_P2P_MGMT_TX;
1683 pucFrameBuf = (PUINT_8)((UINT_32)prMgmtFrame->prPacket + MAC_TX_RESERVED_FIELD);
1685 kalMemCopy(pucFrameBuf, buf, len);
1687 prMgmtFrame->u2FrameLength = len;
1689 if (wait==0&&prChnlReqInfo->ucReqChnlNum==ChnlInfo.ucChannelNum&&
1690 prChnlReqInfo->eBand==ChnlInfo.eBand&&
1691 prChnlReqInfo->eChnlSco==ChnlSco){
1692 mboxSendMsg(prGlueInfo->prAdapter,
1694 (P_MSG_HDR_T)prMsgTxReq,
1695 MSG_SEND_METHOD_BUF);
1700 prChnlReqInfo->prMsgTxReq=prMsgTxReq;
1702 atomic_set(&prGlueInfo->rMgmtTxAto, 1);
1703 i4Rslt=mtk_p2p_cfg80211_remain_on_channel2(wiphy,dev,chan,channel_type,channel_time, cookie, false);
1707 } /* mtk_p2p_cfg80211_mgmt_tx */
1710 mtk_p2p_cfg80211_mgmt_tx (
1711 struct wiphy *wiphy, struct net_device *dev,
1712 struct ieee80211_channel *chan, bool offchan,
1713 enum nl80211_channel_type channel_type,
1714 bool channel_type_valid, unsigned int wait,
1717 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
1719 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
1720 bool dont_wait_for_ack,
1727 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1728 P_GL_P2P_INFO_T prGlueP2pInfo = (P_GL_P2P_INFO_T)NULL;
1729 INT_32 i4Rslt = -EINVAL;
1730 P_MSG_P2P_MGMT_TX_REQUEST_T prMsgTxReq = (P_MSG_P2P_MGMT_TX_REQUEST_T)NULL;
1731 P_MSDU_INFO_T prMgmtFrame = (P_MSDU_INFO_T)NULL;
1732 PUINT_8 pucFrameBuf = (PUINT_8)NULL;
1735 if ((wiphy == NULL) ||
1743 //DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_mgmt_tx\n"));
1745 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1746 prGlueP2pInfo = prGlueInfo->prP2PInfo;
1748 *cookie = prGlueP2pInfo->u8Cookie++;
1750 /* Channel & Channel Type & Wait time are ignored. */
1751 prMsgTxReq = cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_MGMT_TX_REQUEST_T));
1753 if (prMsgTxReq == NULL) {
1759 prMsgTxReq->fgNoneCckRate = FALSE;
1760 prMsgTxReq->fgIsWaitRsp = TRUE;
1762 prMgmtFrame = cnmMgtPktAlloc(prGlueInfo->prAdapter, (UINT_32)(len + MAC_TX_RESERVED_FIELD));
1764 if ((prMsgTxReq->prMgmtMsduInfo = prMgmtFrame) == NULL) {
1770 prMsgTxReq->u8Cookie = *cookie;
1771 prMsgTxReq->rMsgHdr.eMsgId = MID_MNY_P2P_MGMT_TX;
1773 pucFrameBuf = (PUINT_8)((UINT_32)prMgmtFrame->prPacket + MAC_TX_RESERVED_FIELD);
1775 kalMemCopy(pucFrameBuf, buf, len);
1777 prMgmtFrame->u2FrameLength = len;
1779 mboxSendMsg(prGlueInfo->prAdapter,
1781 (P_MSG_HDR_T)prMsgTxReq,
1782 MSG_SEND_METHOD_BUF);
1787 if ((i4Rslt != 0) && (prMsgTxReq != NULL)) {
1788 if (prMsgTxReq->prMgmtMsduInfo != NULL) {
1789 cnmMgtPktFree(prGlueInfo->prAdapter, prMsgTxReq->prMgmtMsduInfo);
1792 cnmMemFree(prGlueInfo->prAdapter, prMsgTxReq);
1796 } /* mtk_p2p_cfg80211_mgmt_tx */
1801 /*----------------------------------------------------------------------------*/
1803 * @brief This routine is responsible for requesting to cancel the wait time
1804 * from transmitting a management frame on another channel
1808 * @retval 0: successful
1811 /*----------------------------------------------------------------------------*/
1813 mtk_p2p_cfg80211_mgmt_tx_cancel_wait (
1814 struct wiphy *wiphy,
1815 struct net_device *ndev,
1819 P_GLUE_INFO_T prGlueInfo = NULL;
1821 prGlueInfo = (P_GLUE_INFO_T) wiphy_priv(wiphy);
1825 printk("--> %s()\n", __func__);
1828 /* not implemented */
1835 mtk_p2p_cfg80211_change_bss (
1836 struct wiphy *wiphy,
1837 struct net_device *dev,
1838 struct bss_parameters *params
1841 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1842 INT_32 i4Rslt = -EINVAL;
1846 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1849 switch (params->use_cts_prot) {
1851 DBGLOG(P2P, TRACE, ("CTS protection no change\n"));
1854 DBGLOG(P2P, TRACE, ("CTS protection disable.\n"));
1857 DBGLOG(P2P, TRACE, ("CTS protection enable\n"));
1860 DBGLOG(P2P, TRACE, ("CTS protection unknown\n"));
1866 switch (params->use_short_preamble) {
1868 DBGLOG(P2P, TRACE, ("Short prreamble no change\n"));
1871 DBGLOG(P2P, TRACE, ("Short prreamble disable.\n"));
1874 DBGLOG(P2P, TRACE, ("Short prreamble enable\n"));
1877 DBGLOG(P2P, TRACE, ("Short prreamble unknown\n"));
1884 // not implemented yet
1885 p2pFuncChangeBssParam(prGlueInfo->prAdapter,
1886 prBssInfo->fgIsProtection,
1887 prBssInfo->fgIsShortPreambleAllowed,
1888 prBssInfo->fgUseShortSlotTime,
1899 } /* mtk_p2p_cfg80211_change_bss */
1904 mtk_p2p_cfg80211_del_station (
1905 struct wiphy *wiphy,
1906 struct net_device *dev,
1910 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
1911 INT_32 i4Rslt = -EINVAL;
1912 P_MSG_P2P_CONNECTION_ABORT_T prDisconnectMsg = (P_MSG_P2P_CONNECTION_ABORT_T)NULL;
1913 UINT_8 aucBcMac[] = BC_MAC_ADDR;
1917 if ((wiphy == NULL) ||
1926 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_del_station.\n"));
1928 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1930 //prDisconnectMsg = (P_MSG_P2P_CONNECTION_ABORT_T)kalMemAlloc(sizeof(MSG_P2P_CONNECTION_ABORT_T), VIR_MEM_TYPE);
1931 prDisconnectMsg = (P_MSG_P2P_CONNECTION_ABORT_T)cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_CONNECTION_ABORT_T));
1933 if (prDisconnectMsg == NULL) {
1939 prDisconnectMsg->rMsgHdr.eMsgId = MID_MNY_P2P_CONNECTION_ABORT;
1940 COPY_MAC_ADDR(prDisconnectMsg->aucTargetID, mac);
1941 prDisconnectMsg->u2ReasonCode = REASON_CODE_UNSPECIFIED;
1943 mboxSendMsg(prGlueInfo->prAdapter,
1945 (P_MSG_HDR_T)prDisconnectMsg,
1946 MSG_SEND_METHOD_BUF);
1953 } /* mtk_p2p_cfg80211_del_station */
1957 mtk_p2p_cfg80211_connect (
1958 struct wiphy *wiphy,
1959 struct net_device *dev,
1960 struct cfg80211_connect_params *sme
1963 INT_32 i4Rslt = -EINVAL;
1964 P_GLUE_INFO_T prGlueInfo = NULL;
1965 P_MSG_P2P_CONNECTION_REQUEST_T prConnReqMsg = (P_MSG_P2P_CONNECTION_REQUEST_T)NULL;
1969 if ((wiphy == NULL) ||
1975 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_connect.\n"));
1977 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
1979 prConnReqMsg = (P_MSG_P2P_CONNECTION_REQUEST_T)cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, (sizeof(MSG_P2P_CONNECTION_REQUEST_T) + sme->ie_len));
1981 if (prConnReqMsg == NULL) {
1987 prConnReqMsg->rMsgHdr.eMsgId = MID_MNY_P2P_CONNECTION_REQ;
1989 COPY_SSID(prConnReqMsg->rSsid.aucSsid,
1990 prConnReqMsg->rSsid.ucSsidLen,
1994 COPY_MAC_ADDR(prConnReqMsg->aucBssid, sme->bssid);
1996 DBGLOG(P2P, TRACE, ("Assoc Req IE Buffer Length:%d\n", sme->ie_len));
1997 kalMemCopy(prConnReqMsg->aucIEBuf, sme->ie, sme->ie_len);
1998 prConnReqMsg->u4IELen = sme->ie_len;
2000 mtk_p2p_cfg80211func_channel_format_switch(sme->channel,
2002 &prConnReqMsg->rChannelInfo,
2003 &prConnReqMsg->eChnlSco);
2005 mboxSendMsg(prGlueInfo->prAdapter,
2007 (P_MSG_HDR_T)prConnReqMsg,
2008 MSG_SEND_METHOD_BUF);
2015 } /* mtk_p2p_cfg80211_connect */
2018 mtk_p2p_cfg80211_disconnect (
2019 struct wiphy *wiphy,
2020 struct net_device *dev,
2024 INT_32 i4Rslt = -EINVAL;
2025 P_GLUE_INFO_T prGlueInfo = NULL;
2026 P_MSG_P2P_CONNECTION_ABORT_T prDisconnMsg = (P_MSG_P2P_CONNECTION_ABORT_T)NULL;
2027 UINT_8 aucBCAddr[] = BC_MAC_ADDR;
2030 if ((wiphy == NULL) ||
2035 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_disconnect.\n"));
2037 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2039 // prDisconnMsg = (P_MSG_P2P_CONNECTION_ABORT_T)kalMemAlloc(sizeof(P_MSG_P2P_CONNECTION_ABORT_T), VIR_MEM_TYPE);
2040 prDisconnMsg = (P_MSG_P2P_CONNECTION_ABORT_T)cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_CONNECTION_ABORT_T));
2042 if (prDisconnMsg == NULL) {
2048 prDisconnMsg->rMsgHdr.eMsgId = MID_MNY_P2P_CONNECTION_ABORT;
2049 prDisconnMsg->u2ReasonCode = reason_code;
2050 prDisconnMsg->fgSendDeauth = TRUE;
2051 COPY_MAC_ADDR(prDisconnMsg->aucTargetID, aucBCAddr);
2053 mboxSendMsg(prGlueInfo->prAdapter,
2055 (P_MSG_HDR_T)prDisconnMsg,
2056 MSG_SEND_METHOD_UNBUF);
2062 } /* mtk_p2p_cfg80211_disconnect */
2066 mtk_p2p_cfg80211_change_iface (
2067 IN struct wiphy *wiphy,
2068 IN struct net_device *ndev,
2069 IN enum nl80211_iftype type,
2071 IN struct vif_params *params
2074 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
2075 INT_32 i4Rslt = -EINVAL;
2076 P_MSG_P2P_SWITCH_OP_MODE_T prSwitchModeMsg = (P_MSG_P2P_SWITCH_OP_MODE_T)NULL;
2079 if ((wiphy == NULL) ||
2084 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_change_iface.\n"));
2086 if (ndev->ieee80211_ptr) {
2087 ndev->ieee80211_ptr->iftype = type;
2090 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2094 prSwitchModeMsg = (P_MSG_P2P_SWITCH_OP_MODE_T)cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_P2P_SWITCH_OP_MODE_T));
2096 if (prSwitchModeMsg == NULL) {
2102 prSwitchModeMsg->rMsgHdr.eMsgId = MID_MNY_P2P_FUN_SWITCH;
2105 case NL80211_IFTYPE_P2P_CLIENT:
2106 DBGLOG(P2P, TRACE, ("NL80211_IFTYPE_P2P_CLIENT.\n"));
2107 case NL80211_IFTYPE_STATION:
2108 if (type == NL80211_IFTYPE_STATION) {
2109 DBGLOG(P2P, TRACE, ("NL80211_IFTYPE_STATION.\n"));
2111 prSwitchModeMsg->eOpMode = OP_MODE_INFRASTRUCTURE;
2113 case NL80211_IFTYPE_AP:
2114 DBGLOG(P2P, TRACE, ("NL80211_IFTYPE_AP.\n"));
2115 case NL80211_IFTYPE_P2P_GO:
2116 if (type == NL80211_IFTYPE_P2P_GO) {
2117 DBGLOG(P2P, TRACE, ("NL80211_IFTYPE_P2P_GO not AP.\n"));
2119 prSwitchModeMsg->eOpMode = OP_MODE_ACCESS_POINT;
2122 DBGLOG(P2P, TRACE, ("Other type :%d .\n", type));
2123 prSwitchModeMsg->eOpMode = OP_MODE_P2P_DEVICE;
2128 mboxSendMsg(prGlueInfo->prAdapter,
2130 (P_MSG_HDR_T)prSwitchModeMsg,
2131 MSG_SEND_METHOD_BUF);
2139 } /* mtk_p2p_cfg80211_change_iface */
2143 mtk_p2p_cfg80211_set_channel (
2144 IN struct wiphy *wiphy,
2145 IN struct net_device *dev,
2146 IN struct ieee80211_channel *chan,
2147 IN enum nl80211_channel_type channel_type)
2149 INT_32 i4Rslt = -EINVAL;
2150 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
2151 RF_CHANNEL_INFO_T rRfChnlInfo;
2154 if ((wiphy == NULL) ||
2160 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_set_channel.\n"));
2162 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2164 mtk_p2p_cfg80211func_channel_format_switch(chan,
2169 p2pFuncSetChannel(prGlueInfo->prAdapter, &rRfChnlInfo);
2178 /* mtk_p2p_cfg80211_set_channel */
2181 mtk_p2p_cfg80211_set_bitrate_mask (
2182 IN struct wiphy *wiphy,
2183 IN struct net_device *dev,
2185 IN const struct cfg80211_bitrate_mask *mask
2188 INT_32 i4Rslt = -EINVAL;
2189 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
2192 if ((wiphy == NULL) ||
2198 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_set_bitrate_mask\n"));
2200 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2202 // TODO: Set bitrate mask of the peer?
2209 } /* mtk_p2p_cfg80211_set_bitrate_mask */
2213 mtk_p2p_cfg80211_mgmt_frame_register (
2214 IN struct wiphy *wiphy,
2215 IN struct net_device *dev,
2221 P_MSG_P2P_MGMT_FRAME_REGISTER_T prMgmtFrameRegister = (P_MSG_P2P_MGMT_FRAME_REGISTER_T)NULL;
2223 P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T)NULL;
2226 if ((wiphy == NULL) ||
2231 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2233 prMgmtFrameRegister = kmalloc(sizeof(MSG_P2P_MGMT_FRAME_REGISTER_T),GFP_ATOMIC);
2234 /* this function is used to set HW filter to RX package, but if we use oringnal method, we may face wrong
2235 cmd sequence to firmware (supplicant request 1. set probe request fiter 2. remain on channel but for driver 1. send channel request
2236 first 2. then set RX filter). This wrong schedule sequence will cause other device can not find this DUT
2238 1. use mail box to handle set RX filter request
2239 2. use kmalloc to avoid sleep in atomic contex, if alloc mem fail, use oringal method
2243 if(prMgmtFrameRegister == NULL){
2245 printk("p2p set fitler error,can not alloc mem from kernel, use tx thread to set rx filter\n");
2246 switch (frame_type) {
2247 case MAC_FRAME_PROBE_REQ:
2249 prGlueInfo->prP2PInfo->u4OsMgmtFrameFilter |= PARAM_PACKET_FILTER_PROBE_REQ;
2250 DBGLOG(P2P, TRACE, ("Open packet filer probe request\n"));
2253 prGlueInfo->prP2PInfo->u4OsMgmtFrameFilter &= ~PARAM_PACKET_FILTER_PROBE_REQ;
2254 DBGLOG(P2P, TRACE, ("Close packet filer probe request\n"));
2257 case MAC_FRAME_ACTION:
2259 prGlueInfo->prP2PInfo->u4OsMgmtFrameFilter |= PARAM_PACKET_FILTER_ACTION_FRAME;
2260 DBGLOG(P2P, TRACE, ("Open packet filer action frame.\n"));
2263 prGlueInfo->prP2PInfo->u4OsMgmtFrameFilter &= ~PARAM_PACKET_FILTER_ACTION_FRAME;
2264 DBGLOG(P2P, TRACE, ("Close packet filer action frame.\n"));
2268 DBGLOG(P2P, ERROR, ("Ask frog to add code for mgmt:%x\n", frame_type));
2274 if((prGlueInfo->prAdapter != NULL) && (prGlueInfo->prAdapter->fgIsP2PRegistered == TRUE)){
2276 //prGlueInfo->u4Flag |= GLUE_FLAG_FRAME_FILTER;
2277 set_bit(GLUE_FLAG_FRAME_FILTER_BIT, &prGlueInfo->u4Flag);
2279 /* wake up main thread */
2280 wake_up_interruptible(&prGlueInfo->waitq);
2282 if (in_interrupt()) {
2283 DBGLOG(P2P, TRACE, ("It is in interrupt level\n"));
2290 prMgmtFrameRegister = (P_MSG_P2P_MGMT_FRAME_REGISTER_T)cnmMemAlloc(prGlueInfo->prAdapter,
2292 sizeof(MSG_P2P_MGMT_FRAME_REGISTER_T));
2294 if (prMgmtFrameRegister == NULL) {
2299 prMgmtFrameRegister->rMsgHdr.eMsgId = MID_MNY_P2P_MGMT_FRAME_REGISTER;
2301 prMgmtFrameRegister->u2FrameType = frame_type;
2302 prMgmtFrameRegister->fgIsRegister = reg;
2304 mboxSendMsg(prGlueInfo->prAdapter,
2306 (P_MSG_HDR_T)prMgmtFrameRegister,
2307 MSG_SEND_METHOD_BUF);
2314 } /* mtk_p2p_cfg80211_mgmt_frame_register */
2318 mtk_p2p_cfg80211func_channel_format_switch (
2319 IN struct ieee80211_channel *channel,
2320 IN enum nl80211_channel_type channel_type,
2321 IN P_RF_CHANNEL_INFO_T prRfChnlInfo,
2322 IN P_ENUM_CHNL_EXT_T prChnlSco
2325 BOOLEAN fgIsValid = FALSE;
2328 if (channel == NULL) {
2333 prRfChnlInfo->ucChannelNum = nicFreq2ChannelNum(channel->center_freq * 1000);
2335 switch (channel->band) {
2336 case IEEE80211_BAND_2GHZ:
2337 prRfChnlInfo->eBand = BAND_2G4;
2339 case IEEE80211_BAND_5GHZ:
2340 prRfChnlInfo->eBand = BAND_5G;
2343 prRfChnlInfo->eBand = BAND_2G4;
2352 switch (channel_type) {
2353 case NL80211_CHAN_NO_HT:
2354 *prChnlSco = CHNL_EXT_SCN;
2356 case NL80211_CHAN_HT20:
2357 *prChnlSco = CHNL_EXT_SCN;
2359 case NL80211_CHAN_HT40MINUS:
2360 *prChnlSco = CHNL_EXT_SCA;
2362 case NL80211_CHAN_HT40PLUS:
2363 *prChnlSco = CHNL_EXT_SCB;
2367 *prChnlSco = CHNL_EXT_SCN;
2378 /* mtk_p2p_cfg80211func_channel_format_switch */
2381 #if CONFIG_NL80211_TESTMODE
2382 int mtk_p2p_cfg80211_testmode_cmd(
2383 IN struct wiphy *wiphy,
2388 P_GLUE_INFO_T prGlueInfo = NULL;
2389 P_NL80211_DRIVER_TEST_PARAMS prParams = (P_NL80211_DRIVER_TEST_PARAMS)NULL;
2390 BOOLEAN fgIsValid = FALSE;
2394 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2396 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_testmode_cmd\n"));
2399 prParams = (P_NL80211_DRIVER_TEST_PARAMS)data;
2401 if(prParams->index >> 24 == 0x01) {
2403 prParams->index = prParams->index & ~ BITS(24,31);
2407 mtk_p2p_cfg80211_testmode_p2p_sigma_pre_cmd(wiphy, data, len);
2412 /* Clear the version byte */
2413 prParams->index = prParams->index & ~ BITS(24,31);
2416 switch(prParams->index){
2417 case 1: /* P2P Simga */
2418 if(mtk_p2p_cfg80211_testmode_p2p_sigma_cmd(wiphy, data, len))
2423 if(mtk_p2p_cfg80211_testmode_wfd_update_cmd(wiphy, data, len))
2427 case 3: /* Hotspot Client Management */
2428 if(mtk_p2p_cfg80211_testmode_hotspot_block_list_cmd(wiphy, data, len))
2442 int mtk_p2p_cfg80211_testmode_p2p_sigma_pre_cmd(
2443 IN struct wiphy *wiphy,
2448 P_GLUE_INFO_T prGlueInfo = NULL;
2449 NL80211_DRIVER_TEST_PRE_PARAMS rParams;
2450 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL;
2451 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T)NULL;
2460 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2462 kalMemZero(&rParams, sizeof(NL80211_DRIVER_TEST_PRE_PARAMS));
2464 prP2pSpecificBssInfo = prGlueInfo->prAdapter->rWifiVar.prP2pSpecificBssInfo;
2465 prP2pConnSettings = prGlueInfo->prAdapter->rWifiVar.prP2PConnSettings;
2467 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_testmode_p2p_sigma_pre_cmd\n"));
2470 memcpy(&rParams, data, len);
2472 DBGLOG(P2P, TRACE, ("NL80211_ATTR_TESTDATA,idx_mode=%d idx=%d value=%lu\n",
2473 (INT_16)rParams.idx_mode, (INT_16)rParams.idx, rParams.value));
2475 index_mode = rParams.idx_mode;
2476 index = rParams.idx;
2477 value = rParams.value;
2480 case 0: /* Listen CH */
2482 case 1: /* P2p mode */
2484 case 4: /* Noa duration */
2485 prP2pSpecificBssInfo->rNoaParam.u4NoaDurationMs = value;
2486 // only to apply setting when setting NOA count
2487 //status = mtk_p2p_wext_set_noa_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rNoaParam);
2489 case 5: /* Noa interval */
2490 prP2pSpecificBssInfo->rNoaParam.u4NoaIntervalMs = value;
2491 // only to apply setting when setting NOA count
2492 //status = mtk_p2p_wext_set_noa_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rNoaParam);
2494 case 6: /* Noa count */
2495 prP2pSpecificBssInfo->rNoaParam.u4NoaCount = value;
2496 //status = mtk_p2p_wext_set_noa_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rNoaParam);
2498 case 100: /* Oper CH */
2499 // 20110920 - frog: User configurations are placed in ConnSettings.
2500 // prP2pConnSettings->ucOperatingChnl = value;
2502 case 101: /* Local config Method, for P2P SDK */
2503 prP2pConnSettings->u2LocalConfigMethod = value;
2505 case 102: /* Sigma P2p reset */
2506 //kalMemZero(prP2pConnSettings->aucTargetDevAddr, MAC_ADDR_LEN);
2507 //prP2pConnSettings->eConnectionPolicy = ENUM_P2P_CONNECTION_POLICY_AUTO;
2508 p2pFsmUninit(prGlueInfo->prAdapter);
2509 p2pFsmInit(prGlueInfo->prAdapter);
2511 case 103: /* WPS MODE */
2512 kalP2PSetWscMode(prGlueInfo, value);
2514 case 104: /* P2p send persence, duration */
2516 case 105: /* P2p send persence, interval */
2518 case 106: /* P2P set sleep */
2520 kalIoctl(prGlueInfo,
2521 wlanoidSetP2pPowerSaveProfile,
2530 case 107: /* P2P set opps, CTWindowl */
2531 prP2pSpecificBssInfo->rOppPsParam.u4CTwindowMs = value;
2532 //status = mtk_p2p_wext_set_oppps_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rOppPsParam);
2534 case 108: /* p2p_set_power_save */
2535 kalIoctl(prGlueInfo,
2536 wlanoidSetP2pPowerSaveProfile,
2556 mtk_p2p_cfg80211_testmode_p2p_sigma_cmd(
2557 IN struct wiphy *wiphy,
2561 P_GLUE_INFO_T prGlueInfo = NULL;
2562 P_NL80211_DRIVER_P2P_SIGMA_PARAMS prParams = (P_NL80211_DRIVER_P2P_SIGMA_PARAMS)NULL;
2563 P_P2P_SPECIFIC_BSS_INFO_T prP2pSpecificBssInfo = (P_P2P_SPECIFIC_BSS_INFO_T)NULL;
2564 P_P2P_CONNECTION_SETTINGS_T prP2pConnSettings = (P_P2P_CONNECTION_SETTINGS_T)NULL;
2572 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2574 prP2pSpecificBssInfo = prGlueInfo->prAdapter->rWifiVar.prP2pSpecificBssInfo;
2575 prP2pConnSettings = prGlueInfo->prAdapter->rWifiVar.prP2PConnSettings;
2577 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_testmode_p2p_sigma_cmd\n"));
2580 prParams = (P_NL80211_DRIVER_P2P_SIGMA_PARAMS)data;
2582 index = (INT_32)prParams->idx;
2583 value = (INT_32)prParams->value;
2585 DBGLOG(P2P, TRACE, ("NL80211_ATTR_TESTDATA, idx=%lu value=%lu\n",
2586 (INT_32)prParams->idx, (INT_32)prParams->value));
2589 case 0: /* Listen CH */
2591 case 1: /* P2p mode */
2593 case 4: /* Noa duration */
2594 prP2pSpecificBssInfo->rNoaParam.u4NoaDurationMs = value;
2595 // only to apply setting when setting NOA count
2596 //status = mtk_p2p_wext_set_noa_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rNoaParam);
2598 case 5: /* Noa interval */
2599 prP2pSpecificBssInfo->rNoaParam.u4NoaIntervalMs = value;
2600 // only to apply setting when setting NOA count
2601 //status = mtk_p2p_wext_set_noa_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rNoaParam);
2603 case 6: /* Noa count */
2604 prP2pSpecificBssInfo->rNoaParam.u4NoaCount = value;
2605 //status = mtk_p2p_wext_set_noa_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rNoaParam);
2607 case 100: /* Oper CH */
2608 // 20110920 - frog: User configurations are placed in ConnSettings.
2609 // prP2pConnSettings->ucOperatingChnl = value;
2611 case 101: /* Local config Method, for P2P SDK */
2612 prP2pConnSettings->u2LocalConfigMethod = value;
2614 case 102: /* Sigma P2p reset */
2615 //kalMemZero(prP2pConnSettings->aucTargetDevAddr, MAC_ADDR_LEN);
2616 //prP2pConnSettings->eConnectionPolicy = ENUM_P2P_CONNECTION_POLICY_AUTO;
2618 case 103: /* WPS MODE */
2619 kalP2PSetWscMode(prGlueInfo, value);
2621 case 104: /* P2p send persence, duration */
2623 case 105: /* P2p send persence, interval */
2625 case 106: /* P2P set sleep */
2627 kalIoctl(prGlueInfo,
2628 wlanoidSetP2pPowerSaveProfile,
2637 case 107: /* P2P set opps, CTWindowl */
2638 prP2pSpecificBssInfo->rOppPsParam.u4CTwindowMs = value;
2639 //status = mtk_p2p_wext_set_oppps_param(prDev, info, wrqu, (char *)&prP2pSpecificBssInfo->rOppPsParam);
2641 case 108: /* p2p_set_power_save */
2642 kalIoctl(prGlueInfo,
2643 wlanoidSetP2pPowerSaveProfile,
2653 case 109: /* Max Clients*/
2654 kalP2PSetMaxClients(prGlueInfo, value);
2666 mtk_p2p_cfg80211_testmode_wfd_update_cmd(
2667 IN struct wiphy *wiphy,
2671 P_GLUE_INFO_T prGlueInfo = NULL;
2672 P_NL80211_DRIVER_WFD_PARAMS prParams = (P_NL80211_DRIVER_WFD_PARAMS)NULL;
2674 P_WFD_CFG_SETTINGS_T prWfdCfgSettings = (P_WFD_CFG_SETTINGS_T)NULL;
2675 P_MSG_WFD_CONFIG_SETTINGS_CHANGED_T prMsgWfdCfgUpdate = (P_MSG_WFD_CONFIG_SETTINGS_CHANGED_T)NULL;
2679 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2681 prParams = (P_NL80211_DRIVER_WFD_PARAMS)data;
2684 DBGLOG(P2P, INFO, ("mtk_p2p_cfg80211_testmode_wfd_update_cmd\n"));
2688 DBGLOG(P2P, INFO,("WFD Enable:%x\n", prParams->WfdEnable));
2689 DBGLOG(P2P, INFO,("WFD Session Available:%x\n", prParams->WfdSessionAvailable));
2690 DBGLOG(P2P, INFO,("WFD Couple Sink Status:%x\n", prParams->WfdCoupleSinkStatus));
2692 DBGLOG(P2P, INFO,("WFD Device Info:%x\n", prParams->WfdDevInfo));
2693 DBGLOG(P2P, INFO,("WFD Control Port:%x\n", prParams->WfdControlPort));
2694 DBGLOG(P2P, INFO,("WFD Maximum Throughput:%x\n", prParams->WfdMaximumTp));
2695 DBGLOG(P2P, INFO,("WFD Extend Capability:%x\n", prParams->WfdExtendCap));
2696 DBGLOG(P2P, INFO,("WFD Couple Sink Addr "MACSTR" \n", MAC2STR(prParams->WfdCoupleSinkAddress)));
2697 DBGLOG(P2P, INFO,("WFD Associated BSSID "MACSTR" \n", MAC2STR(prParams->WfdAssociatedBssid)));
2698 //UINT_8 aucVideolp[4];
2699 //UINT_8 aucAudiolp[4];
2700 DBGLOG(P2P, INFO,("WFD Video Port:%x\n", prParams->WfdVideoPort));
2701 DBGLOG(P2P, INFO,("WFD Audio Port:%x\n", prParams->WfdAudioPort));
2702 DBGLOG(P2P, INFO,("WFD Flag:%x\n", prParams->WfdFlag));
2703 DBGLOG(P2P, INFO,("WFD Policy:%x\n", prParams->WfdPolicy));
2704 DBGLOG(P2P, INFO,("WFD State:%x\n", prParams->WfdState));
2705 //UINT_8 aucWfdSessionInformationIE[24*8];
2706 DBGLOG(P2P, INFO,("WFD Session Info Length:%x\n", prParams->WfdSessionInformationIELen));
2707 //UINT_8 aucReserved1[2];
2708 DBGLOG(P2P, INFO,("WFD Primary Sink Addr "MACSTR" \n", MAC2STR(prParams->aucWfdPrimarySinkMac)));
2709 DBGLOG(P2P, INFO,("WFD Secondary Sink Addr "MACSTR" \n", MAC2STR(prParams->aucWfdSecondarySinkMac)));
2710 DBGLOG(P2P, INFO,("WFD Advanced Flag:%x\n", prParams->WfdAdvanceFlag));
2711 DBGLOG(P2P, INFO,("WFD Sigma mode:%x\n", prParams->WfdSigmaMode));
2712 //UINT_8 aucReserved2[64];
2713 //UINT_8 aucReserved3[64];
2714 //UINT_8 aucReserved4[64];
2718 prWfdCfgSettings = &(prGlueInfo->prAdapter->rWifiVar.prP2pFsmInfo->rWfdConfigureSettings);
2720 kalMemCopy(&prWfdCfgSettings->u4WfdCmdType, &prParams->WfdCmdType, sizeof(WFD_CFG_SETTINGS_T));
2722 prMsgWfdCfgUpdate = cnmMemAlloc(prGlueInfo->prAdapter, RAM_TYPE_MSG, sizeof(MSG_WFD_CONFIG_SETTINGS_CHANGED_T));
2724 if (prMsgWfdCfgUpdate == NULL) {
2729 prMsgWfdCfgUpdate->rMsgHdr.eMsgId = MID_MNY_P2P_WFD_CFG_UPDATE;
2730 prMsgWfdCfgUpdate->prWfdCfgSettings = prWfdCfgSettings;
2733 mboxSendMsg(prGlueInfo->prAdapter,
2735 (P_MSG_HDR_T)prMsgWfdCfgUpdate,
2736 MSG_SEND_METHOD_BUF);
2738 // prWfdCfgSettings->ucWfdEnable = 1;
2739 // prWfdCfgSettings->u4WfdFlag |= WFD_FLAGS_DEV_INFO_VALID;
2740 prWfdCfgSettings->u4WfdFlag |= WFD_FLAGS_DEV_INFO_VALID;
2741 prWfdCfgSettings->u2WfdDevInfo = 123;
2742 prWfdCfgSettings->u2WfdControlPort = 456;
2743 prWfdCfgSettings->u2WfdMaximumTp = 789;
2746 prWfdCfgSettings->u4WfdFlag |= WFD_FLAGS_SINK_INFO_VALID;
2747 prWfdCfgSettings->ucWfdCoupleSinkStatus = 0xAB;
2749 UINT_8 aucTestAddr[MAC_ADDR_LEN] = {0x77, 0x66, 0x55, 0x44, 0x33, 0x22};
2750 COPY_MAC_ADDR(prWfdCfgSettings->aucWfdCoupleSinkAddress, aucTestAddr);
2753 prWfdCfgSettings->u4WfdFlag |= WFD_FLAGS_EXT_CAPABILITY_VALID;
2754 prWfdCfgSettings->u2WfdExtendCap = 0xCDE;
2761 #endif /* CFG_SUPPORT_WFD */
2766 mtk_p2p_cfg80211_testmode_hotspot_block_list_cmd(
2767 IN struct wiphy *wiphy,
2771 P_GLUE_INFO_T prGlueInfo = NULL;
2772 P_NL80211_DRIVER_hotspot_block_PARAMS prParams = (P_NL80211_DRIVER_hotspot_block_PARAMS)NULL;
2777 prGlueInfo = *((P_GLUE_INFO_T *) wiphy_priv(wiphy));
2780 prParams = (P_NL80211_DRIVER_hotspot_block_PARAMS)data;
2782 DBGLOG(P2P, TRACE, ("mtk_p2p_cfg80211_testmode_hotspot_block_list_cmd\n"));
2784 fgIsValid = kalP2PSetBlackList(prGlueInfo, prParams->aucBssid, prParams->ucblocked);
2793 #endif // LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
2795 #endif // CFG_ENABLE_WIFI_DIRECT && CFG_ENABLE_WIFI_DIRECT_CFG_80211