2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#define _IOCTL_LINUX_C_
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#include <drv_conf.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <osdep_service.h>
|
|
|
|
#include <drv_types.h>
|
|
|
|
#include <wlan_bssdef.h>
|
|
|
|
#include <rtw_debug.h>
|
|
|
|
#include <wifi.h>
|
|
|
|
#include <rtw_mlme.h>
|
|
|
|
#include <rtw_mlme_ext.h>
|
|
|
|
#include <rtw_ioctl.h>
|
|
|
|
#include <rtw_ioctl_set.h>
|
2014-12-17 01:03:30 +00:00
|
|
|
#include <rtw_ioctl_query.h>
|
2014-12-19 19:49:35 +00:00
|
|
|
#include <mlme_osdep.h>
|
2013-06-03 19:52:18 +00:00
|
|
|
#include <rtw_mp_ioctl.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <usb_ops.h>
|
|
|
|
#include <rtw_version.h>
|
2013-07-13 01:51:15 +00:00
|
|
|
#include <rtl8188e_hal.h>
|
2015-03-01 16:36:23 +00:00
|
|
|
#include <rtw_iol.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
|
|
|
|
#define iwe_stream_add_event(a, b, c, d, e) iwe_stream_add_event(b, c, d, e)
|
|
|
|
#define iwe_stream_add_point(a, b, c, d, e) iwe_stream_add_point(b, c, d, e)
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
#define SCAN_ITEM_SIZE 768
|
|
|
|
#define MAX_CUSTOM_LEN 64
|
|
|
|
#define RATE_COUNT 4
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* combo scan */
|
2013-05-08 21:45:39 +00:00
|
|
|
#define WEXT_CSCAN_AMOUNT 9
|
|
|
|
#define WEXT_CSCAN_BUF_LEN 360
|
|
|
|
#define WEXT_CSCAN_HEADER "CSCAN S\x01\x00\x00S\x00"
|
|
|
|
#define WEXT_CSCAN_HEADER_SIZE 12
|
|
|
|
#define WEXT_CSCAN_SSID_SECTION 'S'
|
|
|
|
#define WEXT_CSCAN_CHANNEL_SECTION 'C'
|
|
|
|
#define WEXT_CSCAN_NPROBE_SECTION 'N'
|
|
|
|
#define WEXT_CSCAN_ACTV_DWELL_SECTION 'A'
|
|
|
|
#define WEXT_CSCAN_PASV_DWELL_SECTION 'P'
|
|
|
|
#define WEXT_CSCAN_HOME_DWELL_SECTION 'H'
|
|
|
|
#define WEXT_CSCAN_TYPE_SECTION 'T'
|
|
|
|
|
2013-09-06 16:20:37 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
extern u8 key_2char2num(u8 hch, u8 lch);
|
|
|
|
extern u8 str_2char2num(u8 hch, u8 lch);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-26 18:18:57 +00:00
|
|
|
static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000,
|
|
|
|
6000000, 9000000, 12000000, 18000000, 24000000, 36000000,
|
|
|
|
48000000, 54000000};
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-26 18:18:57 +00:00
|
|
|
static const char *const iw_operation_mode[] =
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
|
|
|
"Auto", "Ad-Hoc", "Managed", "Master", "Repeater", "Secondary", "Monitor"
|
2013-05-08 21:45:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int hex2num_i(char c)
|
|
|
|
{
|
|
|
|
if (c >= '0' && c <= '9')
|
|
|
|
return c - '0';
|
|
|
|
if (c >= 'a' && c <= 'f')
|
|
|
|
return c - 'a' + 10;
|
|
|
|
if (c >= 'A' && c <= 'F')
|
|
|
|
return c - 'A' + 10;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int hex2byte_i(const char *hex)
|
|
|
|
{
|
|
|
|
int a, b;
|
|
|
|
a = hex2num_i(*hex++);
|
|
|
|
if (a < 0)
|
|
|
|
return -1;
|
|
|
|
b = hex2num_i(*hex++);
|
|
|
|
if (b < 0)
|
|
|
|
return -1;
|
|
|
|
return (a << 4) | b;
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
/**
|
|
|
|
* hwaddr_aton - Convert ASCII string to MAC address
|
|
|
|
* @txt: MAC address as a string (e.g., "00:11:22:33:44:55")
|
|
|
|
* @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes)
|
|
|
|
* Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
|
|
|
|
*/
|
|
|
|
static int hwaddr_aton_i(const char *txt, u8 *addr)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
int a, b;
|
|
|
|
|
|
|
|
a = hex2num_i(*txt++);
|
|
|
|
if (a < 0)
|
|
|
|
return -1;
|
|
|
|
b = hex2num_i(*txt++);
|
|
|
|
if (b < 0)
|
|
|
|
return -1;
|
|
|
|
*addr++ = (a << 4) | b;
|
|
|
|
if (i < 5 && *txt++ != ':')
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void indicate_wx_custom_event(struct adapter *padapter, char *msg)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 *buff, *p;
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data wrqu;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (strlen(msg) > IW_CUSTOM_MAX) {
|
|
|
|
DBG_871X("%s strlen(msg):%zu > IW_CUSTOM_MAX:%u\n", __FUNCTION__ , strlen(msg), IW_CUSTOM_MAX);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
buff = rtw_zmalloc(IW_CUSTOM_MAX+1);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!buff)
|
2014-12-17 01:03:30 +00:00
|
|
|
return;
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(buff, msg, strlen(msg));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&wrqu,0,sizeof(wrqu));
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu.data.length = strlen(msg);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("%s %s\n", __FUNCTION__, buff);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
rtw_mfree(buff, IW_CUSTOM_MAX+1);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void request_wps_pbc_event(struct adapter *padapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 *buff, *p;
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data wrqu;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
buff = rtw_malloc(IW_CUSTOM_MAX);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!buff)
|
2014-12-17 01:03:30 +00:00
|
|
|
return;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(buff, 0, IW_CUSTOM_MAX);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
p=buff;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-02 23:25:27 +00:00
|
|
|
p+=sprintf(p, "WPS_PBC_START.request=true");
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&wrqu,0,sizeof(wrqu));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu.data.length = p-buff;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu.data.length = (wrqu.data.length<IW_CUSTOM_MAX) ? wrqu.data.length:IW_CUSTOM_MAX;
|
|
|
|
|
|
|
|
DBG_871X("%s\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (buff)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
rtw_mfree(buff, IW_CUSTOM_MAX);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void indicate_wx_scan_complete_event(struct adapter *padapter)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
union iwreq_data wrqu;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&wrqu, 0, sizeof(union iwreq_data));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("+rtw_indicate_wx_scan_complete_event\n"); */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void rtw_indicate_wx_assoc_event(struct adapter *padapter)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
union iwreq_data wrqu;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex*)(&(pmlmeinfo->network));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&wrqu, 0, sizeof(union iwreq_data));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)==true )
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(wrqu.ap_addr.sa_data, pnetwork->MacAddress, ETH_ALEN);
|
2014-12-17 01:03:30 +00:00
|
|
|
else
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.MacAddress, ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X_LEVEL(_drv_always_, "assoc success\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void rtw_indicate_wx_disassoc_event(struct adapter *padapter)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data wrqu;
|
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&wrqu, 0, sizeof(union iwreq_data));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
wrqu.ap_addr.sa_family = ARPHRD_ETHER;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static char *translate_scan(struct adapter *padapter,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info* info, struct wlan_network *pnetwork,
|
|
|
|
char *start, char *stop)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
u8 ss, sq;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct iw_event iwe;
|
|
|
|
u16 cap;
|
2014-12-17 01:03:30 +00:00
|
|
|
__le16 le_cap;
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 ht_ielen = 0;
|
|
|
|
char custom[MAX_CUSTOM_LEN];
|
|
|
|
char *p;
|
2014-12-29 02:13:24 +00:00
|
|
|
u16 max_rate=0, rate, ht_cap=false;
|
2014-12-19 06:59:46 +00:00
|
|
|
u32 i = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
char *current_val;
|
|
|
|
long rssi;
|
|
|
|
u8 bw_40MHz=0, short_GI=0;
|
|
|
|
u16 mcs_rate=0;
|
|
|
|
struct registry_priv *pregpriv = &padapter->registrypriv;
|
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
struct wifidirect_info *pwdinfo = &padapter->wdinfo;
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_P2P
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( SCAN_RESULT_ALL == pwdinfo->wfd_info->scan_result_type )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
else if ( ( SCAN_RESULT_P2P_ONLY == pwdinfo->wfd_info->scan_result_type ) ||
|
2014-12-17 01:03:30 +00:00
|
|
|
( SCAN_RESULT_WFD_TYPE == pwdinfo->wfd_info->scan_result_type ) )
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
u32 blnGotP2PIE = false;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* User is doing the P2P device discovery */
|
|
|
|
/* The prefix of SSID should be "DIRECT-" and the IE should contains the P2P IE. */
|
|
|
|
/* If not, the driver should ignore this AP and go to the next AP. */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Verifying the SSID */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( pnetwork->network.Ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN ) )
|
|
|
|
{
|
|
|
|
u32 p2pielen = 0;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */
|
|
|
|
/* Verifying the P2P IE */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( rtw_get_p2p_ie( pnetwork->network.IEs, pnetwork->network.IELength, NULL, &p2pielen) )
|
2014-12-29 02:13:24 +00:00
|
|
|
blnGotP2PIE = true;
|
2015-02-20 04:11:26 +00:00
|
|
|
} else { /* Beacon or Probe Respones */
|
|
|
|
/* Verifying the P2P IE */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( rtw_get_p2p_ie( &pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen) )
|
2014-12-29 02:13:24 +00:00
|
|
|
blnGotP2PIE = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ( blnGotP2PIE == false )
|
2014-12-17 01:03:30 +00:00
|
|
|
return start;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( SCAN_RESULT_WFD_TYPE == pwdinfo->wfd_info->scan_result_type )
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
u32 blnGotWFD = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 wfd_ie[ 128 ] = { 0x00 };
|
|
|
|
uint wfd_ielen = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( rtw_get_wfd_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, wfd_ie, &wfd_ielen, pnetwork->network.Reserved[0]) )
|
|
|
|
{
|
|
|
|
u8 wfd_devinfo[ 6 ] = { 0x00 };
|
|
|
|
uint wfd_devlen = 6;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( rtw_get_wfd_attr_content( wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, wfd_devinfo, &wfd_devlen) )
|
|
|
|
{
|
|
|
|
if ( pwdinfo->wfd_info->wfd_device_type == WFD_DEVINFO_PSINK )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* the first two bits will indicate the WFD device type */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( ( wfd_devinfo[ 1 ] & 0x03 ) == WFD_DEVINFO_SOURCE )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* If this device is Miracast PSink device, the scan reuslt should just provide the Miracast source. */
|
2014-12-29 02:13:24 +00:00
|
|
|
blnGotWFD = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( pwdinfo->wfd_info->wfd_device_type == WFD_DEVINFO_SOURCE )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* the first two bits will indicate the WFD device type */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( ( wfd_devinfo[ 1 ] & 0x03 ) == WFD_DEVINFO_PSINK )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* If this device is Miracast source device, the scan reuslt should just provide the Miracast PSink. */
|
|
|
|
/* Todo: How about the SSink?! */
|
2014-12-29 02:13:24 +00:00
|
|
|
blnGotWFD = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ( blnGotWFD == false )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return start;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* AP MAC address */
|
|
|
|
iwe.cmd = SIOCGIWAP;
|
|
|
|
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress, ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN);
|
|
|
|
|
|
|
|
/* Add the ESSID */
|
|
|
|
iwe.cmd = SIOCGIWESSID;
|
2014-12-19 06:59:46 +00:00
|
|
|
iwe.u.data.flags = 1;
|
2014-12-17 01:03:30 +00:00
|
|
|
iwe.u.data.length = min((u16)pnetwork->network.Ssid.SsidLength, (u16)32);
|
2013-05-08 21:45:39 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid);
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* parsing HT_CAP_IE */
|
2013-05-08 21:45:39 +00:00
|
|
|
p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (p && ht_ielen>0) {
|
2015-04-08 18:43:40 +00:00
|
|
|
struct ieee80211_ht_cap *pht_capie;
|
2014-12-29 02:13:24 +00:00
|
|
|
ht_cap = true;
|
2015-04-08 18:43:40 +00:00
|
|
|
pht_capie = (struct ieee80211_ht_cap *)(p+2);
|
|
|
|
memcpy(&mcs_rate , pht_capie->mcs.rx_mask, 2);
|
2014-12-19 19:49:35 +00:00
|
|
|
bw_40MHz = (le16_to_cpu(pht_capie->cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0;
|
|
|
|
short_GI = (le16_to_cpu(pht_capie->cap_info) & (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) ? 1 : 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the protocol name */
|
|
|
|
iwe.cmd = SIOCGIWNAME;
|
2014-12-29 02:13:24 +00:00
|
|
|
if ((rtw_is_cckratesonly_included((u8*)&pnetwork->network.SupportedRates)) == true) {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ht_cap == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn");
|
|
|
|
else
|
2014-12-19 19:49:35 +00:00
|
|
|
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
|
2014-12-29 02:13:24 +00:00
|
|
|
} else if ((rtw_is_cckrates_included((u8*)&pnetwork->network.SupportedRates)) == true) {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ht_cap == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn");
|
|
|
|
else
|
2013-08-10 16:56:55 +00:00
|
|
|
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg");
|
2014-12-19 19:49:35 +00:00
|
|
|
} else {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pnetwork->network.Configuration.DSConfig > 14) {
|
|
|
|
if (ht_cap == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an");
|
|
|
|
else
|
|
|
|
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a");
|
2014-12-19 19:49:35 +00:00
|
|
|
} else {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ht_cap == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn");
|
|
|
|
else
|
|
|
|
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g");
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN);
|
|
|
|
|
|
|
|
/* Add mode */
|
2014-12-17 01:03:30 +00:00
|
|
|
iwe.cmd = SIOCGIWMODE;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy((u8 *)&le_cap, rtw_get_capability_from_ie(pnetwork->network.IEs), 2);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
cap = le16_to_cpu(le_cap);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (cap & (WLAN_CAPABILITY_IBSS |WLAN_CAPABILITY_BSS)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (cap & WLAN_CAPABILITY_BSS)
|
|
|
|
iwe.u.mode = IW_MODE_MASTER;
|
|
|
|
else
|
|
|
|
iwe.u.mode = IW_MODE_ADHOC;
|
|
|
|
|
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN);
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pnetwork->network.Configuration.DSConfig<1 /*|| pnetwork->network.Configuration.DSConfig>14*/)
|
2013-05-08 21:45:39 +00:00
|
|
|
pnetwork->network.Configuration.DSConfig = 1;
|
|
|
|
|
|
|
|
/* Add frequency/channel */
|
|
|
|
iwe.cmd = SIOCGIWFREQ;
|
|
|
|
iwe.u.freq.m = rtw_ch2freq(pnetwork->network.Configuration.DSConfig) * 100000;
|
|
|
|
iwe.u.freq.e = 1;
|
|
|
|
iwe.u.freq.i = pnetwork->network.Configuration.DSConfig;
|
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN);
|
|
|
|
|
|
|
|
/* Add encryption capability */
|
|
|
|
iwe.cmd = SIOCGIWENCODE;
|
|
|
|
if (cap & WLAN_CAPABILITY_PRIVACY)
|
|
|
|
iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
|
|
|
|
else
|
|
|
|
iwe.u.data.flags = IW_ENCODE_DISABLED;
|
|
|
|
iwe.u.data.length = 0;
|
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid);
|
|
|
|
|
|
|
|
/*Add basic and extended rates */
|
|
|
|
max_rate = 0;
|
|
|
|
p = custom;
|
|
|
|
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): ");
|
2015-08-15 18:04:12 +00:00
|
|
|
while (pnetwork->network.SupportedRates[i]!=0) {
|
2014-12-19 06:59:46 +00:00
|
|
|
rate = pnetwork->network.SupportedRates[i]&0x7F;
|
2013-05-08 21:45:39 +00:00
|
|
|
if (rate > max_rate)
|
|
|
|
max_rate = rate;
|
|
|
|
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
|
|
|
|
"%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
|
|
|
|
i++;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ht_cap == true) {
|
|
|
|
if (mcs_rate&0x8000) { /* MCS15 */
|
2014-12-17 01:03:30 +00:00
|
|
|
max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
} else if (mcs_rate&0x0080) { /* MCS7 */
|
2014-12-17 01:03:30 +00:00
|
|
|
max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65);
|
2015-02-20 04:11:26 +00:00
|
|
|
} else { /* default MCS7 */
|
|
|
|
/* DBG_871X("wx_get_scan, mcs_rate_bitmap=0x%x\n", mcs_rate); */
|
2014-12-17 01:03:30 +00:00
|
|
|
max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65);
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
max_rate = max_rate*2;/* Mbps/2; */
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
iwe.cmd = SIOCGIWRATE;
|
2014-12-17 01:03:30 +00:00
|
|
|
iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
iwe.u.bitrate.value = max_rate * 500000;
|
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN);
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* parsing WPA/WPA2 IE */
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 buf[MAX_WPA_IE_LEN];
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 wpa_ie[255],rsn_ie[255];
|
|
|
|
u16 wpa_len=0,rsn_len=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *p;
|
2014-12-17 01:03:30 +00:00
|
|
|
sint out_len=0;
|
|
|
|
out_len=rtw_get_sec_ie(pnetwork->network.IEs ,pnetwork->network.IELength,rsn_ie,&rsn_len,wpa_ie,&wpa_len);
|
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_scan: ssid=%s\n",pnetwork->network.Ssid.Ssid));
|
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_scan: wpa_len=%d rsn_len=%d\n",wpa_len,rsn_len));
|
2013-06-21 18:41:29 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (wpa_len > 0)
|
|
|
|
{
|
|
|
|
p=buf;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(buf, 0, MAX_WPA_IE_LEN);
|
2014-12-17 01:03:30 +00:00
|
|
|
p += sprintf(p, "wpa_ie=");
|
|
|
|
for (i = 0; i < wpa_len; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
p += sprintf(p, "%02x", wpa_ie[i]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&iwe, 0, sizeof(iwe));
|
2013-05-08 21:45:39 +00:00
|
|
|
iwe.cmd = IWEVCUSTOM;
|
|
|
|
iwe.u.data.length = strlen(buf);
|
2014-12-17 01:03:30 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe,buf);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&iwe, 0, sizeof(iwe));
|
2014-12-17 01:03:30 +00:00
|
|
|
iwe.cmd =IWEVGENIE;
|
2013-05-08 21:45:39 +00:00
|
|
|
iwe.u.data.length = wpa_len;
|
2014-12-19 06:59:46 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, wpa_ie);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rsn_len > 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
p = buf;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(buf, 0, MAX_WPA_IE_LEN);
|
2014-12-17 01:03:30 +00:00
|
|
|
p += sprintf(p, "rsn_ie=");
|
|
|
|
for (i = 0; i < rsn_len; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
p += sprintf(p, "%02x", rsn_ie[i]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&iwe, 0, sizeof(iwe));
|
2013-05-08 21:45:39 +00:00
|
|
|
iwe.cmd = IWEVCUSTOM;
|
|
|
|
iwe.u.data.length = strlen(buf);
|
2014-12-17 01:03:30 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe,buf);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&iwe, 0, sizeof(iwe));
|
2014-12-17 01:03:30 +00:00
|
|
|
iwe.cmd =IWEVGENIE;
|
2013-05-08 21:45:39 +00:00
|
|
|
iwe.u.data.length = rsn_len;
|
2014-12-19 06:59:46 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
{ /* parsing WPS IE */
|
2014-12-19 06:59:46 +00:00
|
|
|
uint cnt = 0,total_ielen;
|
2015-08-15 18:31:56 +00:00
|
|
|
u8 *wpsie_ptr= NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
uint wps_ielen = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 *ie_ptr = pnetwork->network.IEs +_FIXED_IE_LENGTH_;
|
|
|
|
total_ielen= pnetwork->network.IELength - _FIXED_IE_LENGTH_;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
if (pnetwork->network.Reserved[0] == 2) /* Probe Request */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
ie_ptr = pnetwork->network.IEs;
|
|
|
|
total_ielen = pnetwork->network.IELength;
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
else /* Beacon or Probe Respones */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
ie_ptr = pnetwork->network.IEs + _FIXED_IE_LENGTH_;
|
|
|
|
total_ielen = pnetwork->network.IELength - _FIXED_IE_LENGTH_;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while (cnt < total_ielen)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen>2))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
wpsie_ptr = &ie_ptr[cnt];
|
2014-12-17 01:03:30 +00:00
|
|
|
iwe.cmd =IWEVGENIE;
|
2013-05-08 21:45:39 +00:00
|
|
|
iwe.u.data.length = (u16)wps_ielen;
|
2014-12-19 06:59:46 +00:00
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr);
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
cnt+=ie_ptr[cnt+1]+2; /* goto next */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
/* Add quality statistics */
|
|
|
|
iwe.cmd = IWEVQUAL;
|
2015-03-07 00:58:36 +00:00
|
|
|
iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ( check_fwstate(pmlmepriv, _FW_LINKED)== true &&
|
2014-12-17 01:03:30 +00:00
|
|
|
is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network, 0)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ss = padapter->recvpriv.signal_strength;
|
|
|
|
sq = padapter->recvpriv.signal_qual;
|
|
|
|
} else {
|
|
|
|
ss = pnetwork->network.PhyInfo.SignalStrength;
|
|
|
|
sq = pnetwork->network.PhyInfo.SignalQuality;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
iwe.u.qual.level = (u8)ss;/* */
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_BT_COEXIST
|
|
|
|
BT_SignalCompensation(padapter, &iwe.u.qual.level, NULL);
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_BT_COEXIST */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
iwe.u.qual.qual = (u8)sq; /* signal quality */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
iwe.u.qual.noise = 0; /* noise level */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
u8 buf[MAX_WPA_IE_LEN];
|
|
|
|
u8 * p,*pos;
|
|
|
|
int len;
|
|
|
|
p = buf;
|
|
|
|
pos = pnetwork->network.Reserved;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(buf, 0, MAX_WPA_IE_LEN);
|
2014-12-17 01:03:30 +00:00
|
|
|
p += sprintf(p, "fm=%02X%02X", pos[1], pos[0]);
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&iwe, 0, sizeof(iwe));
|
2014-12-17 01:03:30 +00:00
|
|
|
iwe.cmd = IWEVCUSTOM;
|
|
|
|
iwe.u.data.length = strlen(buf);
|
|
|
|
start = iwe_stream_add_point(info, start, stop, &iwe, buf);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
return start;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wpa_set_auth_algs(struct net_device *dev, u32 value)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *) rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((value & AUTH_ALG_SHARED_KEY)&&(value & AUTH_ALG_OPEN_SYSTEM))
|
|
|
|
{
|
|
|
|
DBG_871X("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY and AUTH_ALG_OPEN_SYSTEM [value:0x%x]\n",value);
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
|
|
|
|
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch;
|
|
|
|
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
else if (value & AUTH_ALG_SHARED_KEY)
|
|
|
|
{
|
|
|
|
DBG_871X("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY [value:0x%x]\n",value);
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
|
|
|
|
|
|
|
|
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared;
|
|
|
|
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (value & AUTH_ALG_OPEN_SYSTEM)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("wpa_set_auth_algs, AUTH_ALG_OPEN_SYSTEM\n");
|
2015-02-20 04:11:26 +00:00
|
|
|
/* padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
|
2014-12-19 06:59:46 +00:00
|
|
|
padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (value & AUTH_ALG_LEAP)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("wpa_set_auth_algs, AUTH_ALG_LEAP\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X("wpa_set_auth_algs, error!\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u32 wep_key_idx, wep_key_len,wep_total_len;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_wep *pwep = NULL;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
struct wifidirect_info* pwdinfo = &padapter->wdinfo;
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
param->u.crypt.err = 0;
|
|
|
|
param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (param_len < (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
|
|
|
|
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
|
2014-12-19 06:59:46 +00:00
|
|
|
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (param->u.crypt.idx >= WEP_KEYS
|
|
|
|
#ifdef CONFIG_IEEE80211W
|
|
|
|
&& param->u.crypt.idx > BIP_MAX_KEYID
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_IEEE80211W */
|
2014-12-17 01:03:30 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2015-03-02 17:12:58 +00:00
|
|
|
} else {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 17:12:58 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "WEP") == 0) {
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,("wpa_set_encryption, crypt.alg = WEP\n"));
|
|
|
|
DBG_871X("wpa_set_encryption, crypt.alg = WEP\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_WEP40_;
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_WEP40_;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
wep_key_idx = param->u.crypt.idx;
|
|
|
|
wep_key_len = param->u.crypt.key_len;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("(1)wep_key_idx=%d\n", wep_key_idx));
|
|
|
|
DBG_871X("(1)wep_key_idx=%d\n", wep_key_idx);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (wep_key_idx > WEP_KEYS)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("(2)wep_key_idx=%d\n", wep_key_idx));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
if (wep_key_len > 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
wep_key_len = wep_key_len <= 5 ? 5 : 13;
|
2015-03-14 23:14:05 +00:00
|
|
|
wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
|
|
|
|
pwep =(struct ndis_802_11_wep *) rtw_malloc(wep_total_len);
|
2015-08-15 18:24:16 +00:00
|
|
|
if (pwep == NULL) {
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,(" wpa_set_encryption: pwep allocate fail !!!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(pwep, 0, wep_total_len);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
pwep->KeyLength = wep_key_len;
|
2013-05-08 21:45:39 +00:00
|
|
|
pwep->Length = wep_total_len;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (wep_key_len==13)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_WEP104_;
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_WEP104_;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
else {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pwep->KeyIndex = wep_key_idx;
|
|
|
|
pwep->KeyIndex |= 0x80000000;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param->u.crypt.set_tx)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("wep, set_tx=1\n");
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
ret = -EOPNOTSUPP ;
|
|
|
|
}
|
2015-02-26 18:18:57 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("wep, set_tx=0\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (wep_key_idx >= WEP_KEYS) {
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -EOPNOTSUPP ;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2015-03-10 16:18:03 +00:00
|
|
|
memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength);
|
2014-12-19 06:59:46 +00:00
|
|
|
psecuritypriv->dot11DefKeylen[wep_key_idx]=pwep->KeyLength;
|
2014-12-29 02:13:24 +00:00
|
|
|
rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0,true);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
goto exit;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) /* 802_1x */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
struct sta_info * psta,*pbcmc_sta;
|
|
|
|
struct sta_priv * pstapriv = &padapter->stapriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE) == true) /* sta mode */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv));
|
2013-05-08 21:45:39 +00:00
|
|
|
if (psta == NULL) {
|
2015-08-15 18:00:19 +00:00
|
|
|
/* DEBUG_ERR( ("Set wpa_set_encryption: Obtain Sta_info fail\n")); */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Jeff: don't disable ieee8021x_blocked while clearing key */
|
2014-12-19 06:59:46 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "none") != 0)
|
2014-12-29 02:13:24 +00:00
|
|
|
psta->ieee8021x_blocked = false;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled)||
|
2014-12-17 01:03:30 +00:00
|
|
|
(padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param->u.crypt.set_tx ==1)/* pairwise key */
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "TKIP") == 0)/* set mic key */
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8);
|
|
|
|
memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
padapter->securitypriv.busetkipkey=false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X(" ~~~~set sta key:unicastkey\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
rtw_setstakey_cmd(padapter, (unsigned char *)psta, true, true);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
else/* group key */
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "TKIP") == 0 || strcmp(param->u.crypt.alg, "CCMP") == 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
printk("[%s] GTK key_len=%d @@@@@@@@@@@@@@@@@@\n", param->u.crypt.alg, param->u.crypt.key_len);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key,(param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2015-02-20 04:11:26 +00:00
|
|
|
/* only TKIP group key need to install this */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param->u.crypt.key_len > 16)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey,&(param->u.crypt.key[16]),8);
|
|
|
|
memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey,&(param->u.crypt.key[24]),8);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-29 02:13:24 +00:00
|
|
|
padapter->securitypriv.binstallGrpkey = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X(" ~~~~set sta key:groupkey\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
rtw_set_key(padapter,&padapter->securitypriv,param->u.crypt.idx, 1,true);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
#ifdef CONFIG_IEEE80211W
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (strcmp(param->u.crypt.alg, "BIP") == 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
int no;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* save the IGTK key, length 16 bytes */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(padapter->securitypriv.dot11wBIPKey[param->u.crypt.idx].skey, param->u.crypt.key,(param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.dot11wBIPKeyid = param->u.crypt.idx;
|
2014-12-29 02:13:24 +00:00
|
|
|
padapter->securitypriv.binstallBIPkey = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X(" ~~~~set sta key:IGKT\n");
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_IEEE80211W */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING))
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_DONE);
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pbcmc_sta=rtw_get_bcmc_stainfo(padapter);
|
2015-08-15 18:22:58 +00:00
|
|
|
if (pbcmc_sta== NULL)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:00:19 +00:00
|
|
|
/* DEBUG_ERR( ("Set OID_802_11_ADD_KEY: bcmc stainfo is null\n")); */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Jeff: don't disable ieee8021x_blocked while clearing key */
|
2014-12-19 06:59:46 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "none") != 0)
|
2014-12-29 02:13:24 +00:00
|
|
|
pbcmc_sta->ieee8021x_blocked = false;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled)||
|
2014-12-17 01:03:30 +00:00
|
|
|
(padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled))
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-26 18:18:57 +00:00
|
|
|
if (pwep)
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_mfree((u8 *)pwep, wep_total_len);
|
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ielen)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-08-15 18:31:56 +00:00
|
|
|
u8 *buf= NULL, *pos= NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
u32 left;
|
2013-05-08 21:45:39 +00:00
|
|
|
int group_cipher = 0, pairwise_cipher = 0;
|
|
|
|
int ret = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 null_addr[]= {0,0,0,0,0,0};
|
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
struct wifidirect_info* pwdinfo = &padapter->wdinfo;
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
_clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pie == NULL)
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ielen) {
|
2013-05-08 21:45:39 +00:00
|
|
|
buf = rtw_zmalloc(ielen);
|
2015-08-15 18:24:16 +00:00
|
|
|
if (buf == NULL) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(buf, pie , ielen);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* dump */
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("\n wpa_ie(length:%d):\n", ielen);
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0;i<ielen;i=i+8)
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n",buf[i],buf[i+1],buf[i+2],buf[i+3],buf[i+4],buf[i+5],buf[i+6],buf[i+7]);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pos = buf;
|
2015-08-15 18:24:16 +00:00
|
|
|
if (ielen < RSN_HEADER_LEN) {
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,("Ie len too short %d\n", ielen));
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_parse_wpa_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_8021X;
|
|
|
|
padapter->securitypriv.ndisauthtype=Ndis802_11AuthModeWPAPSK;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_8021X;
|
2014-12-19 06:59:46 +00:00
|
|
|
padapter->securitypriv.ndisauthtype=Ndis802_11AuthModeWPA2PSK;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (group_cipher == 0)
|
|
|
|
{
|
|
|
|
group_cipher = WPA_CIPHER_NONE;
|
|
|
|
}
|
|
|
|
if (pairwise_cipher == 0)
|
|
|
|
{
|
|
|
|
pairwise_cipher = WPA_CIPHER_NONE;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (group_cipher)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
case WPA_CIPHER_NONE:
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus=Ndis802_11EncryptionDisabled;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_WEP40:
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_WEP40_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_TKIP:
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_TKIP_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_CCMP:
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_AES_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
case WPA_CIPHER_WEP104:
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_WEP104_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (pairwise_cipher)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
case WPA_CIPHER_NONE:
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus=Ndis802_11EncryptionDisabled;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_WEP40:
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_WEP40_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_TKIP:
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_TKIP_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled;
|
|
|
|
break;
|
|
|
|
case WPA_CIPHER_CCMP:
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_AES_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
case WPA_CIPHER_WEP104:
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_WEP104_;
|
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
|
|
|
|
break;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
_clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS);
|
2015-02-20 04:11:26 +00:00
|
|
|
{/* set wps_ie */
|
2014-12-19 06:59:46 +00:00
|
|
|
u16 cnt = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 eid, wps_oui[4]={0x0,0x50,0xf2,0x04};
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while ( cnt < ielen )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
eid = buf[cnt];
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((eid==_VENDOR_SPECIFIC_IE_)&&(_rtw_memcmp(&buf[cnt+2], wps_oui, 4)==true))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("SET WPS_IE\n");
|
|
|
|
|
|
|
|
padapter->securitypriv.wps_ie_len = ( (buf[cnt+1]+2) < (MAX_WPA_IE_LEN<<2)) ? (buf[cnt+1]+2):(MAX_WPA_IE_LEN<<2);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_OK))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_ING);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
cnt += buf[cnt+1]+2;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
} else {
|
2015-02-20 04:11:26 +00:00
|
|
|
cnt += buf[cnt+1]+2; /* goto next */
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* TKIP and AES disallow multicast packets until installing group key */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_
|
2014-12-17 01:03:30 +00:00
|
|
|
|| padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_
|
|
|
|
|| padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)
|
2015-02-20 04:11:26 +00:00
|
|
|
/* WPS open need to enable multicast */
|
|
|
|
/* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
|
2014-12-17 01:03:30 +00:00
|
|
|
("rtw_set_wpa_ie: pairwise_cipher=0x%08x padapter->securitypriv.ndisencryptstatus=%d padapter->securitypriv.ndisauthtype=%d\n",
|
|
|
|
pairwise_cipher, padapter->securitypriv.ndisencryptstatus, padapter->securitypriv.ndisauthtype));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
if (buf) rtw_mfree(buf, ielen);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_name(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
u16 cap;
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 ht_ielen = 0;
|
|
|
|
char *p;
|
2014-12-29 02:13:24 +00:00
|
|
|
u8 ht_cap=false;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
|
2015-03-14 23:14:05 +00:00
|
|
|
u8 *prates;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("cmd_code=%x\n", info->cmd));
|
2015-03-14 23:14:05 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
|
2015-02-20 04:11:26 +00:00
|
|
|
/* parsing HT_CAP_IE */
|
2013-05-08 21:45:39 +00:00
|
|
|
p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (p && ht_ielen>0)
|
2014-12-29 02:13:24 +00:00
|
|
|
ht_cap = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
prates = pcur_bss->SupportedRates;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
if (rtw_is_cckratesonly_included((u8*)prates)) {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ht_cap == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn");
|
|
|
|
else
|
|
|
|
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b");
|
2015-03-14 23:14:05 +00:00
|
|
|
} else if ((rtw_is_cckrates_included((u8*)prates))) {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ht_cap == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn");
|
|
|
|
else
|
|
|
|
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg");
|
2015-03-14 23:14:05 +00:00
|
|
|
} else {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pcur_bss->Configuration.DSConfig > 14) {
|
|
|
|
if (ht_cap == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an");
|
|
|
|
else
|
|
|
|
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a");
|
2015-03-14 23:14:05 +00:00
|
|
|
} else {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ht_cap == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn");
|
|
|
|
else
|
|
|
|
snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g");
|
|
|
|
}
|
|
|
|
}
|
2015-03-14 23:14:05 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
snprintf(wrqu->name, IFNAMSIZ, "unassociated");
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_freq(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_wx_set_freq\n"));
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_freq(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000;
|
|
|
|
wrqu->freq.e = 1;
|
|
|
|
wrqu->freq.i = pcur_bss->Configuration.DSConfig;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
}
|
2015-08-15 18:27:00 +00:00
|
|
|
else {
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000;
|
|
|
|
wrqu->freq.e = 1;
|
|
|
|
wrqu->freq.i = padapter->mlmeextpriv.cur_channel;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2015-03-14 23:14:05 +00:00
|
|
|
enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType ;
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_FAIL == rtw_pwr_wakeup(padapter)) {
|
2014-12-17 01:03:30 +00:00
|
|
|
ret= -EPERM;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (padapter->hw_init_completed==false) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EPERM;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (wrqu->mode)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
case IW_MODE_AUTO:
|
|
|
|
networkType = Ndis802_11AutoUnknown;
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("set_mode = IW_MODE_AUTO\n");
|
|
|
|
break;
|
|
|
|
case IW_MODE_ADHOC:
|
2014-12-17 01:03:30 +00:00
|
|
|
networkType = Ndis802_11IBSS;
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("set_mode = IW_MODE_ADHOC\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
case IW_MODE_MASTER:
|
2014-12-17 01:03:30 +00:00
|
|
|
networkType = Ndis802_11APMode;
|
|
|
|
DBG_871X("set_mode = IW_MODE_MASTER\n");
|
2015-02-20 04:11:26 +00:00
|
|
|
/* rtw_setopmode_cmd(padapter, networkType,true); */
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case IW_MODE_INFRA:
|
|
|
|
networkType = Ndis802_11Infrastructure;
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("set_mode = IW_MODE_INFRA\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
default :
|
|
|
|
ret = -EINVAL;;
|
2015-08-15 18:00:19 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,("\n Mode: %s is not supported \n", iw_operation_mode[wrqu->mode]));
|
2014-12-17 01:03:30 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (rtw_set_802_11_infrastructure_mode(padapter, networkType) ==false) {
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EPERM;
|
|
|
|
goto exit;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
rtw_setopmode_cmd(padapter, networkType,true);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:00:19 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,(" rtw_wx_get_mode\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->mode = IW_MODE_INFRA;
|
2014-12-29 02:13:24 +00:00
|
|
|
else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true))
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->mode = IW_MODE_ADHOC;
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->mode = IW_MODE_MASTER;
|
|
|
|
else
|
|
|
|
wrqu->mode = IW_MODE_AUTO;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_set_pmkid(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-29 02:13:24 +00:00
|
|
|
u8 j,blInserted = false;
|
|
|
|
int intReturn = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_pmksa* pPMK = ( struct iw_pmksa* ) extra;
|
|
|
|
u8 strZeroMacAddress[ ETH_ALEN ] = { 0x00 };
|
|
|
|
u8 strIssueBssid[ ETH_ALEN ] = { 0x00 };
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy( strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN);
|
2015-03-10 16:18:03 +00:00
|
|
|
if ( pPMK->cmd == IW_PMKSA_ADD ) {
|
|
|
|
DBG_871X( "[rtw_wx_set_pmkid] IW_PMKSA_ADD!\n" );
|
|
|
|
if ( _rtw_memcmp( strIssueBssid, strZeroMacAddress, ETH_ALEN ) == true )
|
|
|
|
return( intReturn );
|
|
|
|
else
|
|
|
|
intReturn = true;
|
2014-12-29 02:13:24 +00:00
|
|
|
blInserted = false;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* overwrite PMKID */
|
2015-08-15 18:06:32 +00:00
|
|
|
for (j=0 ; j<NUM_PMKID_CACHE; j++) {
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( _rtw_memcmp( psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN) ==true )
|
2015-02-20 04:11:26 +00:00
|
|
|
{ /* BSSID is matched, the same AP => rewrite with new PMKID. */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n" );
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy( psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN);
|
2014-12-29 02:13:24 +00:00
|
|
|
psecuritypriv->PMKIDList[ j ].bUsed = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->PMKIDIndex = j+1;
|
2014-12-29 02:13:24 +00:00
|
|
|
blInserted = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!blInserted) {
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Find a new entry */
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[rtw_wx_set_pmkid] Use the new entry index = %d for this PMKID.\n",
|
|
|
|
psecuritypriv->PMKIDIndex );
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN);
|
|
|
|
memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
psecuritypriv->PMKIDList[ psecuritypriv->PMKIDIndex ].bUsed = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
psecuritypriv->PMKIDIndex++ ;
|
2015-08-15 18:02:34 +00:00
|
|
|
if (psecuritypriv->PMKIDIndex==16)
|
2014-12-17 01:03:30 +00:00
|
|
|
psecuritypriv->PMKIDIndex =0;
|
|
|
|
}
|
2015-03-10 16:18:03 +00:00
|
|
|
} else if ( pPMK->cmd == IW_PMKSA_REMOVE ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n" );
|
2014-12-29 02:13:24 +00:00
|
|
|
intReturn = true;
|
2015-08-15 18:06:32 +00:00
|
|
|
for (j=0 ; j<NUM_PMKID_CACHE; j++) {
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( _rtw_memcmp( psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN) ==true )
|
2015-02-20 04:11:26 +00:00
|
|
|
{ /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */
|
2015-02-19 20:58:09 +00:00
|
|
|
memset( psecuritypriv->PMKIDList[ j ].Bssid, 0x00, ETH_ALEN );
|
2014-12-29 02:13:24 +00:00
|
|
|
psecuritypriv->PMKIDList[ j ].bUsed = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-03-10 16:18:03 +00:00
|
|
|
} else if ( pPMK->cmd == IW_PMKSA_FLUSH ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n" );
|
2015-02-19 20:58:09 +00:00
|
|
|
memset( &psecuritypriv->PMKIDList[ 0 ], 0x00, sizeof( RT_PMKID_LIST ) * NUM_PMKID_CACHE );
|
2014-12-17 01:03:30 +00:00
|
|
|
psecuritypriv->PMKIDIndex = 0;
|
2014-12-29 02:13:24 +00:00
|
|
|
intReturn = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-03-10 16:18:03 +00:00
|
|
|
return( intReturn );
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_sens(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-07 01:00:36 +00:00
|
|
|
wrqu->sens.value = 0;
|
|
|
|
wrqu->sens.fixed = 0; /* no auto select */
|
|
|
|
wrqu->sens.disabled = 1;
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_range(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
struct iw_range *range = (struct iw_range *)extra;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
|
|
|
|
u16 val;
|
|
|
|
int i;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_range. cmd_code=%x\n", info->cmd));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
wrqu->data.length = sizeof(*range);
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(range, 0, sizeof(*range));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* Let's try to keep this struct in the same order as in
|
|
|
|
* linux/include/wireless.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* TODO: See what values we can set, and remove the ones we can't
|
|
|
|
* set, or fill them with some default data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ~5 Mb/s real (802.11b) */
|
2014-12-19 06:59:46 +00:00
|
|
|
range->throughput = 5 * 1000 * 1000;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* signal level threshold range */
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* percent values between 0 and 100. */
|
2014-12-19 06:59:46 +00:00
|
|
|
range->max_qual.qual = 100;
|
2013-05-08 21:45:39 +00:00
|
|
|
range->max_qual.level = 100;
|
|
|
|
range->max_qual.noise = 100;
|
|
|
|
range->max_qual.updated = 7; /* Updated all three */
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
|
|
|
|
/* TODO: Find real 'good' to 'bad' threshol value for RSSI */
|
2015-03-10 16:18:03 +00:00
|
|
|
range->avg_qual.level = 178; /* equals -78 */
|
2013-05-08 21:45:39 +00:00
|
|
|
range->avg_qual.noise = 0;
|
|
|
|
range->avg_qual.updated = 7; /* Updated all three */
|
|
|
|
|
|
|
|
range->num_bitrates = RATE_COUNT;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
range->bitrate[i] = rtw_rates[i];
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
range->min_frag = MIN_FRAG_THRESHOLD;
|
|
|
|
range->max_frag = MAX_FRAG_THRESHOLD;
|
|
|
|
|
|
|
|
range->pm_capa = 0;
|
|
|
|
|
|
|
|
range->we_version_compiled = WIRELESS_EXT;
|
|
|
|
range->we_version_source = 16;
|
|
|
|
|
|
|
|
for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) {
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Include only legal frequencies for some countries */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmeext->channel_set[i].ChannelNum != 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
range->freq[val].i = pmlmeext->channel_set[i].ChannelNum;
|
|
|
|
range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000;
|
|
|
|
range->freq[val].e = 1;
|
|
|
|
val++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val == IW_MAX_FREQUENCIES)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
range->num_channels = val;
|
|
|
|
range->num_frequency = val;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 2009/10/13 */
|
|
|
|
/* The following code will proivde the security capability to network manager. */
|
|
|
|
/* If the driver doesn't provide this capability to network manager, */
|
|
|
|
/* the WPA/WPA2 routers can't be choosen in the network manager. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
#define IW_SCAN_CAPA_NONE 0x00
|
|
|
|
#define IW_SCAN_CAPA_ESSID 0x01
|
|
|
|
#define IW_SCAN_CAPA_BSSID 0x02
|
2014-12-17 01:03:30 +00:00
|
|
|
#define IW_SCAN_CAPA_CHANNEL 0x04
|
2013-05-08 21:45:39 +00:00
|
|
|
#define IW_SCAN_CAPA_MODE 0x08
|
|
|
|
#define IW_SCAN_CAPA_RATE 0x10
|
|
|
|
#define IW_SCAN_CAPA_TYPE 0x20
|
|
|
|
#define IW_SCAN_CAPA_TIME 0x40
|
|
|
|
*/
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#if WIRELESS_EXT > 17
|
|
|
|
range->enc_capa = IW_ENC_CAPA_WPA|IW_ENC_CAPA_WPA2|
|
|
|
|
IW_ENC_CAPA_CIPHER_TKIP|IW_ENC_CAPA_CIPHER_CCMP;
|
|
|
|
#endif
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
#ifdef IW_SCAN_CAPA_ESSID /* WIRELESS_EXT > 21 */
|
2014-12-17 01:03:30 +00:00
|
|
|
range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE |IW_SCAN_CAPA_BSSID|
|
|
|
|
IW_SCAN_CAPA_CHANNEL|IW_SCAN_CAPA_MODE|IW_SCAN_CAPA_RATE;
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* set bssid flow */
|
|
|
|
/* s1. rtw_set_802_11_infrastructure_mode() */
|
|
|
|
/* s2. rtw_set_802_11_authentication_mode() */
|
|
|
|
/* s3. set_802_11_encryption_mode() */
|
|
|
|
/* s4. rtw_set_802_11_bssid() */
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_wx_set_wap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *awrq,
|
|
|
|
char *extra)
|
|
|
|
{
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2013-05-08 21:45:39 +00:00
|
|
|
uint ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sockaddr *temp = (struct sockaddr *)awrq;
|
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2015-03-16 13:54:18 +00:00
|
|
|
struct list_head *phead;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *dst_bssid, *src_bssid;
|
2015-03-16 13:54:18 +00:00
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
2015-03-14 23:14:05 +00:00
|
|
|
enum NDIS_802_11_AUTHENTICATION_MODE authmode;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_FAIL == rtw_pwr_wakeup(padapter))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
ret= -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (!padapter->bup) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (temp->sa_family != ARPHRD_ETHER) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
authmode = padapter->securitypriv.ndisauthtype;
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&queue->lock);
|
2015-03-10 16:18:03 +00:00
|
|
|
phead = get_list_head(queue);
|
|
|
|
pmlmepriv->pscanned = get_next(phead);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-29 02:00:11 +00:00
|
|
|
while (1) {
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ((rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) == true)
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list);
|
|
|
|
|
|
|
|
pmlmepriv->pscanned = get_next(pmlmepriv->pscanned);
|
|
|
|
|
|
|
|
dst_bssid = pnetwork->network.MacAddress;
|
|
|
|
|
|
|
|
src_bssid = temp->sa_data;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ((_rtw_memcmp(dst_bssid, src_bssid, ETH_ALEN)) == true)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&queue->lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_set_802_11_authentication_mode(padapter, authmode);
|
2015-02-20 04:11:26 +00:00
|
|
|
/* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_set_802_11_bssid(padapter, temp->sa_data) == false) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
2014-12-19 06:59:46 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
return ret;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_wap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_wap\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ( ((check_fwstate(pmlmepriv, _FW_LINKED)) == true) ||
|
|
|
|
((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) ||
|
|
|
|
((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true) )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_mlme(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2015-02-16 19:00:49 +00:00
|
|
|
u16 reason;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_mlme *mlme = (struct iw_mlme *) extra;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if (mlme== NULL)
|
2014-12-17 01:03:30 +00:00
|
|
|
return -1;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-16 19:00:49 +00:00
|
|
|
reason = mlme->reason_code;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, cmd=%d, reason=%d\n", __FUNCTION__, mlme->cmd, reason);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-06-20 15:13:14 +00:00
|
|
|
switch (mlme->cmd) {
|
|
|
|
case IW_MLME_DEAUTH:
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!rtw_set_802_11_disassociate(padapter))
|
2013-06-20 15:13:14 +00:00
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
case IW_MLME_DISASSOC:
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!rtw_set_802_11_disassociate(padapter))
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -1;
|
2013-06-20 15:13:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
u8 _status = false;
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_priv *pmlmepriv= &padapter->mlmepriv;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-19 06:59:46 +00:00
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_set_scan\n"));
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
#ifdef DBG_IOCTL
|
|
|
|
DBG_871X("DBG_IOCTL %s:%d\n",__FUNCTION__, __LINE__);
|
|
|
|
#endif
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_FAIL == rtw_pwr_wakeup(padapter))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
ret= -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
if (padapter->bDriverStopped) {
|
|
|
|
DBG_871X("bDriverStopped=%d\n", padapter->bDriverStopped);
|
2014-12-17 01:03:30 +00:00
|
|
|
ret= -1;
|
|
|
|
goto exit;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (!padapter->bup) {
|
2013-08-10 16:56:55 +00:00
|
|
|
ret = -1;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (padapter->hw_init_completed==false) {
|
2013-08-10 16:56:55 +00:00
|
|
|
ret = -1;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* When Busy Traffic, driver do not site survey. So driver return success. */
|
|
|
|
/* wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */
|
|
|
|
/* modify by thomas 2011-02-22. */
|
2015-02-15 20:31:30 +00:00
|
|
|
if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) {
|
2014-12-17 01:03:30 +00:00
|
|
|
indicate_wx_scan_complete_event(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
indicate_wx_scan_complete_event(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_BT_COEXIST
|
|
|
|
{
|
|
|
|
u32 curr_time, delta_time;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* under DHCP(Special packet) */
|
2015-08-15 21:34:17 +00:00
|
|
|
curr_time = jiffies;
|
2014-12-17 01:03:30 +00:00
|
|
|
delta_time = curr_time - adapter_to_pwrctl(padapter)->DelayLPSLastTimeStamp;
|
|
|
|
delta_time = rtw_systime_to_ms(delta_time);
|
2015-02-20 04:11:26 +00:00
|
|
|
if (delta_time < 500) /* 500ms */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s: send DHCP pkt before %d ms, Skip scan\n", __FUNCTION__, delta_time);
|
|
|
|
ret = -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Mareded by Albert 20101103 */
|
|
|
|
/* For the DMP WiFi Display project, the driver won't to scan because */
|
|
|
|
/* the pmlmepriv->scan_interval is always equal to 3. */
|
|
|
|
/* So, the wpa_supplicant won't find out the WPS SoftAP. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
if ( pwdinfo->p2p_state != P2P_STATE_NONE )
|
|
|
|
{
|
|
|
|
rtw_p2p_set_pre_state( pwdinfo, rtw_p2p_state( pwdinfo ) );
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH);
|
|
|
|
rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_FULL);
|
2014-12-29 02:13:24 +00:00
|
|
|
rtw_free_network_queue(padapter, true);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#if WIRELESS_EXT >= 17
|
2014-12-19 06:59:46 +00:00
|
|
|
if (wrqu->data.length == sizeof(struct iw_scan_req))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
struct iw_scan_req *req = (struct iw_scan_req *)extra;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (wrqu->data.flags & IW_SCAN_THIS_ESSID)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE);
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(ssid[0].Ssid, req->essid, len);
|
2014-12-19 06:59:46 +00:00
|
|
|
ssid[0].SsidLength = len;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("IW_SCAN_THIS_ESSID, ssid=%s, len=%d\n", req->essid, req->essid_len);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pmlmepriv->lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
_status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pmlmepriv->lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
else if (req->scan_type == IW_SCAN_TYPE_PASSIVE)
|
|
|
|
{
|
|
|
|
DBG_871X("rtw_wx_set_scan, req->scan_type == IW_SCAN_TYPE_PASSIVE\n");
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE
|
2014-12-29 02:13:24 +00:00
|
|
|
&& _rtw_memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE) == true
|
2014-12-17 01:03:30 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
int len = wrqu->data.length -WEXT_CSCAN_HEADER_SIZE;
|
|
|
|
char *pos = extra+WEXT_CSCAN_HEADER_SIZE;
|
|
|
|
char section;
|
|
|
|
char sec_len;
|
|
|
|
int ssid_index = 0;
|
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while (len >= 1) {
|
2014-12-17 01:03:30 +00:00
|
|
|
section = *(pos++); len-=1;
|
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (section) {
|
2013-10-19 17:45:47 +00:00
|
|
|
case WEXT_CSCAN_SSID_SECTION:
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("WEXT_CSCAN_SSID_SECTION\n"); */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (len < 1) {
|
2013-10-19 17:45:47 +00:00
|
|
|
len = 0;
|
|
|
|
break;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
sec_len = *(pos++); len-=1;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (sec_len>0 && sec_len<=len) {
|
2013-10-19 17:45:47 +00:00
|
|
|
ssid[ssid_index].SsidLength = sec_len;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength);
|
2013-10-19 17:45:47 +00:00
|
|
|
ssid_index++;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pos+=sec_len; len-=sec_len;
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
case WEXT_CSCAN_CHANNEL_SECTION:
|
2014-12-17 01:03:30 +00:00
|
|
|
pos+=1; len-=1;
|
|
|
|
break;
|
|
|
|
case WEXT_CSCAN_ACTV_DWELL_SECTION:
|
|
|
|
pos+=2; len-=2;
|
2013-10-19 17:45:47 +00:00
|
|
|
break;
|
|
|
|
case WEXT_CSCAN_PASV_DWELL_SECTION:
|
2014-12-19 06:59:46 +00:00
|
|
|
pos+=2; len-=2;
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2013-10-19 17:45:47 +00:00
|
|
|
case WEXT_CSCAN_HOME_DWELL_SECTION:
|
2014-12-17 01:03:30 +00:00
|
|
|
pos+=2; len-=2;
|
|
|
|
break;
|
|
|
|
case WEXT_CSCAN_TYPE_SECTION:
|
|
|
|
pos+=1; len-=1;
|
|
|
|
break;
|
2013-10-19 17:45:47 +00:00
|
|
|
default:
|
2015-02-20 04:11:26 +00:00
|
|
|
len = 0; /* stop parsing */
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* jeff: it has still some scan paramater to parse, we only do this now... */
|
2014-12-17 01:03:30 +00:00
|
|
|
_status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
} else
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
_status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_status == false)
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
exit:
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef DBG_IOCTL
|
|
|
|
DBG_871X("DBG_IOCTL %s:%d return %d\n",__FUNCTION__, __LINE__, ret);
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return ret;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
|
|
|
struct list_head *plist, *phead;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2015-03-16 13:54:18 +00:00
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
|
|
|
char *ev = extra;
|
|
|
|
char *stop = ev + wrqu->data.length;
|
|
|
|
u32 ret = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u32 cnt=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 wait_for_surveydone;
|
2014-12-17 01:03:30 +00:00
|
|
|
sint wait_status;
|
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
struct wifidirect_info* pwdinfo = &padapter->wdinfo;
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_scan\n"));
|
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_, (" Start of Query SIOCGIWSCAN .\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef DBG_IOCTL
|
|
|
|
DBG_871X("DBG_IOCTL %s:%d\n",__FUNCTION__, __LINE__);
|
|
|
|
#endif
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (adapter_to_pwrctl(padapter)->brfoffbyhw && padapter->bDriverStopped)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* P2P is enabled */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( padapter->chip_type == RTL8192D )
|
2015-02-20 04:11:26 +00:00
|
|
|
wait_for_surveydone = 300; /* Because the 8192du supports more channels. */
|
2014-12-17 01:03:30 +00:00
|
|
|
else
|
|
|
|
wait_for_surveydone = 200;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* P2P is disabled */
|
2013-05-08 21:45:39 +00:00
|
|
|
wait_for_surveydone = 100;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
{
|
|
|
|
wait_for_surveydone = 100;
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
wait_status = _FW_UNDER_SURVEY
|
|
|
|
#ifndef CONFIG_ANDROID
|
|
|
|
| _FW_UNDER_LINKING
|
|
|
|
#endif
|
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
if (check_fwstate(pmlmepriv, wait_status))
|
2014-12-17 01:03:30 +00:00
|
|
|
return -EAGAIN;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while (1)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead,plist)== true)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((stop - ev) < SCAN_ITEM_SIZE) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -E2BIG;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* report network only if the current channel set contains the channel to which this network belongs */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0
|
2014-12-29 02:13:24 +00:00
|
|
|
&& true == rtw_validate_ssid(&(pnetwork->network.Ssid))
|
2014-12-17 01:03:30 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ev=translate_scan(padapter, a, pnetwork, ev, stop);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
plist = get_next(plist);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
wrqu->data.length = ev-extra;
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->data.flags = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef DBG_IOCTL
|
|
|
|
DBG_871X("DBG_IOCTL %s:%d return %d\n",__FUNCTION__, __LINE__, ret);
|
|
|
|
#endif
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret ;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* set ssid flow */
|
|
|
|
/* s1. rtw_set_802_11_infrastructure_mode() */
|
|
|
|
/* s2. set_802_11_authenticaion_mode() */
|
|
|
|
/* s3. set_802_11_encryption_mode() */
|
|
|
|
/* s4. rtw_set_802_11_ssid() */
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_essid(struct net_device *dev,
|
2013-05-08 21:45:39 +00:00
|
|
|
struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
struct __queue *queue = &pmlmepriv->scanned_queue;
|
|
|
|
struct list_head *phead;
|
2014-12-29 02:13:24 +00:00
|
|
|
s8 status = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
2015-03-14 23:14:05 +00:00
|
|
|
enum NDIS_802_11_AUTHENTICATION_MODE authmode;
|
|
|
|
struct ndis_802_11_ssid ndis_ssid;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *dst_ssid, *src_ssid;
|
|
|
|
|
|
|
|
uint ret = 0, len;
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef DBG_IOCTL
|
|
|
|
DBG_871X("DBG_IOCTL %s:%d\n",__FUNCTION__, __LINE__);
|
|
|
|
#endif
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
|
|
|
|
("+rtw_wx_set_essid: fw_state=0x%08x\n", get_fwstate(pmlmepriv)));
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_FAIL == rtw_pwr_wakeup(padapter))
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -1;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (!padapter->bup) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
goto exit;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#if WIRELESS_EXT <= 20
|
2015-08-15 18:24:16 +00:00
|
|
|
if ((wrqu->essid.length-1) > IW_ESSID_MAX_SIZE) {
|
2014-12-17 01:03:30 +00:00
|
|
|
#else
|
2015-08-15 18:24:16 +00:00
|
|
|
if (wrqu->essid.length > IW_ESSID_MAX_SIZE) {
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
|
|
|
ret= -E2BIG;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -1;
|
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
authmode = padapter->securitypriv.ndisauthtype;
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("=>%s\n",__FUNCTION__);
|
|
|
|
if (wrqu->essid.flags && wrqu->essid.length)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20100519 */
|
|
|
|
/* We got the codes in "set_info" function of iwconfig source code. */
|
|
|
|
/* ========================================= */
|
|
|
|
/* wrq.u.essid.length = strlen(essid) + 1; */
|
2015-08-15 18:02:34 +00:00
|
|
|
/* if (we_kernel_version > 20) */
|
2015-02-20 04:11:26 +00:00
|
|
|
/* wrq.u.essid.length--; */
|
|
|
|
/* ========================================= */
|
|
|
|
/* That means, if the WIRELESS_EXT less than or equal to 20, the correct ssid len should subtract 1. */
|
2014-12-17 01:03:30 +00:00
|
|
|
#if WIRELESS_EXT <= 20
|
|
|
|
len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;
|
|
|
|
#else
|
2013-05-08 21:45:39 +00:00
|
|
|
len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE;
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( wrqu->essid.length != 33 )
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("ssid=%s, len=%d\n", extra, wrqu->essid.length);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid));
|
2013-05-08 21:45:39 +00:00
|
|
|
ndis_ssid.SsidLength = len;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(ndis_ssid.Ssid, extra, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
src_ssid = ndis_ssid.Ssid;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid=[%s]\n", src_ssid));
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&queue->lock);
|
2015-03-10 16:18:03 +00:00
|
|
|
phead = get_list_head(queue);
|
|
|
|
pmlmepriv->pscanned = get_next(phead);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:00:11 +00:00
|
|
|
while (1) {
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead, pmlmepriv->pscanned) == true) {
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_,
|
2013-05-08 21:45:39 +00:00
|
|
|
("rtw_wx_set_essid: scan_q is empty, set ssid to check if scanning again!\n"));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list);
|
|
|
|
|
|
|
|
pmlmepriv->pscanned = get_next(pmlmepriv->pscanned);
|
|
|
|
|
|
|
|
dst_ssid = pnetwork->network.Ssid.Ssid;
|
|
|
|
|
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
|
2014-12-17 01:03:30 +00:00
|
|
|
("rtw_wx_set_essid: dst_ssid=%s\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
pnetwork->network.Ssid.Ssid));
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ((_rtw_memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength) == true) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
(pnetwork->network.Ssid.SsidLength==ndis_ssid.SsidLength))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
|
|
|
|
("rtw_wx_set_essid: find match, set infra mode\n"));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode)
|
2013-05-08 21:45:39 +00:00
|
|
|
continue;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode) == false)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
|
2014-12-17 01:03:30 +00:00
|
|
|
("set ssid: set_802_11_auth. mode=%d\n", authmode));
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_set_802_11_authentication_mode(padapter, authmode);
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("<=%s, ret %d\n",__FUNCTION__, ret);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef DBG_IOCTL
|
|
|
|
DBG_871X("DBG_IOCTL %s:%d return %d\n",__FUNCTION__, __LINE__, ret);
|
|
|
|
#endif
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
return ret;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_essid(struct net_device *dev,
|
2013-05-08 21:45:39 +00:00
|
|
|
struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
u32 len,ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_wx_get_essid\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ( (check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
len = pcur_bss->Ssid.SsidLength;
|
|
|
|
|
|
|
|
wrqu->essid.length = len;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(extra, pcur_bss->Ssid.Ssid, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
wrqu->essid.flags = 1;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_rate(struct net_device *dev,
|
2013-05-08 21:45:39 +00:00
|
|
|
struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int i, ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 datarates[NumRates];
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 target_rate = wrqu->bitrate.value;
|
|
|
|
u32 fixed = wrqu->bitrate.fixed;
|
|
|
|
u32 ratevalue = 0;
|
2015-03-10 16:18:03 +00:00
|
|
|
u8 mpdatarate[NumRates]={11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff};
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:00:19 +00:00
|
|
|
RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,(" rtw_wx_set_rate\n"));
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("target_rate = %d, fixed = %d\n",target_rate,fixed));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (target_rate == -1) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ratevalue = 11;
|
|
|
|
goto set_rate;
|
|
|
|
}
|
|
|
|
target_rate = target_rate/100000;
|
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
switch (target_rate) {
|
2014-12-17 01:03:30 +00:00
|
|
|
case 10:
|
|
|
|
ratevalue = 0;
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
ratevalue = 1;
|
|
|
|
break;
|
|
|
|
case 55:
|
|
|
|
ratevalue = 2;
|
|
|
|
break;
|
|
|
|
case 60:
|
|
|
|
ratevalue = 3;
|
|
|
|
break;
|
|
|
|
case 90:
|
|
|
|
ratevalue = 4;
|
|
|
|
break;
|
|
|
|
case 110:
|
|
|
|
ratevalue = 5;
|
|
|
|
break;
|
|
|
|
case 120:
|
|
|
|
ratevalue = 6;
|
|
|
|
break;
|
|
|
|
case 180:
|
|
|
|
ratevalue = 7;
|
|
|
|
break;
|
|
|
|
case 240:
|
|
|
|
ratevalue = 8;
|
|
|
|
break;
|
|
|
|
case 360:
|
|
|
|
ratevalue = 9;
|
|
|
|
break;
|
|
|
|
case 480:
|
|
|
|
ratevalue = 10;
|
|
|
|
break;
|
|
|
|
case 540:
|
|
|
|
ratevalue = 11;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ratevalue = 11;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_rate:
|
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0; i<NumRates; i++)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ratevalue==mpdatarate[i])
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
datarates[i] = mpdatarate[i];
|
2015-08-15 18:02:34 +00:00
|
|
|
if (fixed == 0)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:27:00 +00:00
|
|
|
else {
|
2013-05-08 21:45:39 +00:00
|
|
|
datarates[i] = 0xff;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("datarate_inx=%d\n",datarates[i]));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if ( rtw_setdatarate_cmd(padapter, datarates) !=_SUCCESS) {
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,("rtw_wx_set_rate Fail!!!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_rate(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u16 max_rate = 0;
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
max_rate = rtw_get_cur_max_rate((struct adapter *)rtw_netdev_priv(dev));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (max_rate == 0)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EPERM;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->bitrate.fixed = 0; /* no auto select */
|
|
|
|
wrqu->bitrate.value = max_rate * 100000;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_rts(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (wrqu->rts.disabled)
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->registrypriv.rts_thresh = 2347;
|
2014-12-17 01:03:30 +00:00
|
|
|
else {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (wrqu->rts.value < 0 ||
|
|
|
|
wrqu->rts.value > 2347)
|
|
|
|
return -EINVAL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->registrypriv.rts_thresh = wrqu->rts.value;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, rts_thresh=%d\n", __func__, padapter->registrypriv.rts_thresh);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_rts(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("%s, rts_thresh=%d\n", __func__, padapter->registrypriv.rts_thresh);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->rts.value = padapter->registrypriv.rts_thresh;
|
|
|
|
wrqu->rts.fixed = 0; /* no auto select */
|
2015-02-20 04:11:26 +00:00
|
|
|
/* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_frag(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (wrqu->frag.disabled)
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD;
|
2014-12-17 01:03:30 +00:00
|
|
|
else {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
|
|
|
|
wrqu->frag.value > MAX_FRAG_THRESHOLD)
|
|
|
|
return -EINVAL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, frag_len=%d\n", __func__, padapter->xmitpriv.frag_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_frag(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, frag_len=%d\n", __func__, padapter->xmitpriv.frag_len);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->frag.value = padapter->xmitpriv.frag_len;
|
|
|
|
wrqu->frag.fixed = 0; /* no auto select */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_retry(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
wrqu->retry.value = 7;
|
|
|
|
wrqu->retry.fixed = 0; /* no auto select */
|
|
|
|
wrqu->retry.disabled = 1;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_enc(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *keybuf)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 key, ret = 0;
|
|
|
|
u32 keyindex_provided;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_wep wep;
|
|
|
|
enum NDIS_802_11_AUTHENTICATION_MODE authmode;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
struct iw_point *erq = &(wrqu->encoding);
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
|
|
|
|
DBG_871X("+rtw_wx_set_enc, flags=0x%x\n", erq->flags);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
memset(&wep, 0, sizeof(struct ndis_802_11_wep));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
key = erq->flags & IW_ENCODE_INDEX;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-26 18:18:57 +00:00
|
|
|
if (erq->flags & IW_ENCODE_DISABLED) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("EncryptionDisabled\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_;
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_;
|
2015-02-20 04:11:26 +00:00
|
|
|
padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Open; /* open system */
|
2014-12-19 06:59:46 +00:00
|
|
|
authmode = Ndis802_11AuthModeOpen;
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.ndisauthtype=authmode;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key) {
|
|
|
|
if (key > WEP_KEYS)
|
|
|
|
return -EINVAL;
|
|
|
|
key--;
|
|
|
|
keyindex_provided = 1;
|
2015-02-26 18:18:57 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
keyindex_provided = 0;
|
|
|
|
key = padapter->securitypriv.dot11PrivacyKeyIndex;
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw_wx_set_enc, key=%d\n", key);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* set authentication mode */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (erq->flags & IW_ENCODE_OPEN) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw_wx_set_enc():IW_ENCODE_OPEN\n");
|
2015-02-20 04:11:26 +00:00
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Open;
|
|
|
|
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_;
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_;
|
2014-12-19 06:59:46 +00:00
|
|
|
authmode = Ndis802_11AuthModeOpen;
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.ndisauthtype=authmode;
|
2015-08-15 18:02:34 +00:00
|
|
|
} else if (erq->flags & IW_ENCODE_RESTRICTED) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw_wx_set_enc():IW_ENCODE_RESTRICTED\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Shared;
|
|
|
|
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_WEP40_;
|
2014-12-19 06:59:46 +00:00
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_WEP40_;
|
2014-12-17 01:03:30 +00:00
|
|
|
authmode = Ndis802_11AuthModeShared;
|
|
|
|
padapter->securitypriv.ndisauthtype=authmode;
|
2015-02-26 18:18:57 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw_wx_set_enc():erq->flags=0x%x\n", erq->flags);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */
|
|
|
|
padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Open; /* open system */
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_;
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_;
|
2014-12-19 06:59:46 +00:00
|
|
|
authmode = Ndis802_11AuthModeOpen;
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.ndisauthtype=authmode;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
wep.KeyIndex = key;
|
2015-02-26 18:18:57 +00:00
|
|
|
if (erq->length > 0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
wep.KeyLength = erq->length <= 5 ? 5 : 13;
|
|
|
|
|
2015-03-14 23:14:05 +00:00
|
|
|
wep.Length = wep.KeyLength + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
|
2015-02-26 18:18:57 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
wep.KeyLength = 0 ;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if (keyindex_provided == 1)/* set key_id only, no given KeyMaterial(erq->length== 0). */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->securitypriv.dot11PrivacyKeyIndex = key;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("(keyindex_provided == 1), keyid=%d, key_len=%d\n", key, padapter->securitypriv.dot11DefKeylen[key]);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (padapter->securitypriv.dot11DefKeylen[key]) {
|
2015-02-26 18:18:57 +00:00
|
|
|
case 5:
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_WEP40_;
|
|
|
|
break;
|
|
|
|
case 13:
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_WEP104_;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wep.KeyIndex |= 0x80000000;
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(wep.KeyMaterial, keybuf, wep.KeyLength);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_set_802_11_add_wep(padapter, &wep) == false) {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rf_on == pwrpriv->rf_pwrstate )
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_enc(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *keybuf)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
uint key, ret =0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct iw_point *erq = &(wrqu->encoding);
|
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED) != true)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) != true)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
erq->length = 0;
|
|
|
|
erq->flags |= IW_ENCODE_DISABLED;
|
|
|
|
return 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
key = erq->flags & IW_ENCODE_INDEX;
|
|
|
|
|
|
|
|
if (key) {
|
|
|
|
if (key > WEP_KEYS)
|
|
|
|
return -EINVAL;
|
|
|
|
key--;
|
2014-12-17 01:03:30 +00:00
|
|
|
} else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
key = padapter->securitypriv.dot11PrivacyKeyIndex;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
erq->flags = key + 1;
|
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (padapter->securitypriv.ndisencryptstatus) {
|
2015-02-26 18:18:57 +00:00
|
|
|
case Ndis802_11EncryptionNotSupported:
|
|
|
|
case Ndis802_11EncryptionDisabled:
|
2013-05-08 21:45:39 +00:00
|
|
|
erq->length = 0;
|
|
|
|
erq->flags |= IW_ENCODE_DISABLED;
|
|
|
|
break;
|
2015-02-26 18:18:57 +00:00
|
|
|
case Ndis802_11Encryption1Enabled:
|
2014-12-19 06:59:46 +00:00
|
|
|
erq->length = padapter->securitypriv.dot11DefKeylen[key];
|
2015-08-15 18:02:34 +00:00
|
|
|
if (erq->length) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-26 18:18:57 +00:00
|
|
|
erq->flags |= IW_ENCODE_ENABLED;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen)
|
2014-12-19 06:59:46 +00:00
|
|
|
erq->flags |= IW_ENCODE_OPEN;
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared)
|
2015-02-26 18:18:57 +00:00
|
|
|
erq->flags |= IW_ENCODE_RESTRICTED;
|
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
erq->length = 0;
|
|
|
|
erq->flags |= IW_ENCODE_DISABLED;
|
|
|
|
}
|
|
|
|
break;
|
2015-02-26 18:18:57 +00:00
|
|
|
case Ndis802_11Encryption2Enabled:
|
|
|
|
case Ndis802_11Encryption3Enabled:
|
2013-05-08 21:45:39 +00:00
|
|
|
erq->length = 16;
|
|
|
|
erq->flags |= (IW_ENCODE_ENABLED | IW_ENCODE_OPEN | IW_ENCODE_NOKEY);
|
|
|
|
break;
|
2015-02-26 18:18:57 +00:00
|
|
|
default:
|
2013-05-08 21:45:39 +00:00
|
|
|
erq->length = 0;
|
|
|
|
erq->flags |= IW_ENCODE_DISABLED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_get_power(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
wrqu->power.value = 0;
|
|
|
|
wrqu->power.fixed = 0; /* no auto select */
|
|
|
|
wrqu->power.disabled = 1;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_gen_ie(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
return rtw_set_wpa_ie(padapter, extra, wrqu->data.length);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_auth(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_param *param = (struct iw_param*)&(wrqu->param);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
u32 value = param->value;
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
switch (param->flags & IW_AUTH_INDEX) {
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
case IW_AUTH_WPA_VERSION:
|
|
|
|
break;
|
|
|
|
case IW_AUTH_CIPHER_PAIRWISE:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
case IW_AUTH_CIPHER_GROUP:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
case IW_AUTH_KEY_MGMT:
|
|
|
|
/*
|
|
|
|
* ??? does not use these parameters
|
|
|
|
*/
|
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
case IW_AUTH_TKIP_COUNTERMEASURES:
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
if ( param->value )
|
2015-02-20 04:11:26 +00:00
|
|
|
{ /* wpa_supplicant is enabling the tkip countermeasure. */
|
2014-12-29 02:13:24 +00:00
|
|
|
padapter->securitypriv.btkip_countermeasure = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
2015-02-20 04:11:26 +00:00
|
|
|
{ /* wpa_supplicant is disabling the tkip countermeasure. */
|
2014-12-29 02:13:24 +00:00
|
|
|
padapter->securitypriv.btkip_countermeasure = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
case IW_AUTH_DROP_UNENCRYPTED:
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
/* HACK:
|
|
|
|
*
|
|
|
|
* wpa_supplicant calls set_wpa_enabled when the driver
|
|
|
|
* is loaded and unloaded, regardless of if WPA is being
|
|
|
|
* used. No other calls are made which can be used to
|
|
|
|
* determine if encryption will be used or not prior to
|
|
|
|
* association being expected. If encryption is not being
|
|
|
|
* used, drop_unencrypted is set to false, else true -- we
|
|
|
|
* can use this to determine if the CAP_PRIVACY_ON bit should
|
|
|
|
* be set.
|
|
|
|
*/
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
break;/* it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, */
|
|
|
|
/* then it needn't reset it; */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (param->value) {
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
|
|
|
|
padapter->securitypriv.dot11PrivacyAlgrthm=_NO_PRIVACY_;
|
|
|
|
padapter->securitypriv.dot118021XGrpPrivacy=_NO_PRIVACY_;
|
2015-02-20 04:11:26 +00:00
|
|
|
padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_Open; /* open system */
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->securitypriv.ndisauthtype=Ndis802_11AuthModeOpen;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case IW_AUTH_80211_AUTH_ALG:
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_ANDROID) || 1
|
2013-05-08 21:45:39 +00:00
|
|
|
/*
|
|
|
|
* It's the starting point of a link layer connection using wpa_supplicant
|
|
|
|
*/
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
LeaveAllPowerSaveMode(padapter);
|
2014-12-29 02:13:24 +00:00
|
|
|
rtw_disassoc_cmd(padapter, 500, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s...call rtw_indicate_disconnect\n ",__FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_indicate_disconnect(padapter);
|
|
|
|
rtw_free_assoc_resources(padapter, 1);
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = wpa_set_auth_algs(dev, (u32)param->value);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
case IW_AUTH_WPA_ENABLED:
|
|
|
|
break;
|
|
|
|
case IW_AUTH_RX_UNENCRYPTED_EAPOL:
|
|
|
|
break;
|
|
|
|
case IW_AUTH_PRIVACY_INVOKED:
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
default:
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_set_enc_ext(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2013-05-08 21:45:39 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
char *alg_name;
|
|
|
|
u32 param_len;
|
|
|
|
struct ieee_param *param = NULL;
|
|
|
|
struct iw_point *pencoding = &wrqu->encoding;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct iw_encode_ext *pext = (struct iw_encode_ext *)extra;
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
param_len = sizeof(struct ieee_param) + pext->key_len;
|
|
|
|
param = (struct ieee_param *)rtw_malloc(param_len);
|
|
|
|
if (param == NULL)
|
|
|
|
return -1;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(param, 0, param_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
param->cmd = IEEE_CMD_SET_ENCRYPTION;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(param->sta_addr, 0xff, ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
switch (pext->alg) {
|
|
|
|
case IW_ENCODE_ALG_NONE:
|
2015-02-20 04:11:26 +00:00
|
|
|
/* todo: remove key */
|
|
|
|
/* remove = 1; */
|
2013-05-08 21:45:39 +00:00
|
|
|
alg_name = "none";
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_WEP:
|
|
|
|
alg_name = "WEP";
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_TKIP:
|
|
|
|
alg_name = "TKIP";
|
|
|
|
break;
|
|
|
|
case IW_ENCODE_ALG_CCMP:
|
|
|
|
alg_name = "CCMP";
|
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_IEEE80211W
|
|
|
|
case IW_ENCODE_ALG_AES_CMAC:
|
|
|
|
alg_name = "BIP";
|
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_IEEE80211W */
|
2013-05-08 21:45:39 +00:00
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
|
|
|
|
|
|
|
|
if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
param->u.crypt.set_tx = 1;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* cliW: WEP does not have group key
|
2014-12-19 06:59:46 +00:00
|
|
|
* just not checking GROUP key setting
|
2013-05-08 21:45:39 +00:00
|
|
|
*/
|
|
|
|
if ((pext->alg != IW_ENCODE_ALG_WEP) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
((pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
|
|
|
|
#ifdef CONFIG_IEEE80211W
|
|
|
|
|| (pext->ext_flags & IW_ENCODE_ALG_AES_CMAC)
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_IEEE80211W */
|
2014-12-17 01:03:30 +00:00
|
|
|
))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
param->u.crypt.set_tx = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
param->u.crypt.idx = (pencoding->flags&0x00FF) -1 ;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID)
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(param->u.crypt.seq, pext->rx_seq, 8);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pext->key_len) {
|
2013-05-08 21:45:39 +00:00
|
|
|
param->u.crypt.key_len = pext->key_len;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* memcpy(param + 1, pext + 1, pext->key_len); */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(param->u.crypt.key, pext + 1, pext->key_len);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pencoding->flags & IW_ENCODE_DISABLED)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* todo: remove key */
|
|
|
|
/* remove = 1; */
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = wpa_set_encryption(dev, param, param_len);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
rtw_mfree((u8*)param, param_len);
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static int rtw_wx_get_nick(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
2014-12-17 01:03:30 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (extra) {
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->data.length = 14;
|
|
|
|
wrqu->data.flags = 1;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(extra, "<WIFI@REALTEK>", 14);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_read32(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct iw_point *p;
|
|
|
|
u16 len;
|
|
|
|
u32 addr;
|
|
|
|
u32 data32;
|
|
|
|
u32 bytes;
|
|
|
|
u8 *ptmp;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
p = &wrqu->data;
|
|
|
|
len = p->length;
|
2014-12-17 01:03:30 +00:00
|
|
|
ptmp = (u8*)rtw_malloc(len);
|
2013-05-08 21:45:39 +00:00
|
|
|
if (NULL == ptmp)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (copy_from_user(ptmp, p->pointer, len)) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_mfree(ptmp, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
bytes = 0;
|
|
|
|
addr = 0;
|
|
|
|
sscanf(ptmp, "%d,%x", &bytes, &addr);
|
|
|
|
|
|
|
|
switch (bytes) {
|
2014-12-17 01:03:30 +00:00
|
|
|
case 1:
|
|
|
|
data32 = rtw_read8(padapter, addr);
|
|
|
|
sprintf(extra, "0x%02X", data32);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
data32 = rtw_read16(padapter, addr);
|
|
|
|
sprintf(extra, "0x%04X", data32);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
data32 = rtw_read32(padapter, addr);
|
|
|
|
sprintf(extra, "0x%08X", data32);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DBG_871X(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__);
|
|
|
|
return -EINVAL;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X(KERN_INFO "%s: addr=0x%08X data=%s\n", __func__, addr, extra);
|
|
|
|
|
|
|
|
rtw_mfree(ptmp, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_write32(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
u32 addr;
|
|
|
|
u32 data32;
|
|
|
|
u32 bytes;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
bytes = 0;
|
|
|
|
addr = 0;
|
|
|
|
data32 = 0;
|
|
|
|
sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32);
|
|
|
|
|
|
|
|
switch (bytes) {
|
2014-12-17 01:03:30 +00:00
|
|
|
case 1:
|
|
|
|
rtw_write8(padapter, addr, (u8)data32);
|
|
|
|
DBG_871X(KERN_INFO "%s: addr=0x%08X data=0x%02X\n", __func__, addr, (u8)data32);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
rtw_write16(padapter, addr, (u16)data32);
|
|
|
|
DBG_871X(KERN_INFO "%s: addr=0x%08X data=0x%04X\n", __func__, addr, (u16)data32);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
rtw_write32(padapter, addr, data32);
|
|
|
|
DBG_871X(KERN_INFO "%s: addr=0x%08X data=0x%08X\n", __func__, addr, data32);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DBG_871X(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__);
|
|
|
|
return -EINVAL;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_read_rf(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 path, addr, data32;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
path = *(u32*)extra;
|
|
|
|
addr = *((u32*)extra + 1);
|
2013-05-08 21:45:39 +00:00
|
|
|
data32 = rtw_hal_read_rfreg(padapter, path, addr, 0xFFFFF);
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%s: path=%d addr=0x%02x data=0x%05x\n", __func__, path, addr, data32); */
|
2013-05-08 21:45:39 +00:00
|
|
|
/*
|
|
|
|
* IMPORTANT!!
|
|
|
|
* Only when wireless private ioctl is at odd order,
|
|
|
|
* "extra" would be copied to user space.
|
|
|
|
*/
|
|
|
|
sprintf(extra, "0x%05x", data32);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_write_rf(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 path, addr, data32;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
path = *(u32*)extra;
|
|
|
|
addr = *((u32*)extra + 1);
|
|
|
|
data32 = *((u32*)extra + 2);
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%s: path=%d addr=0x%02x data=0x%05x\n", __func__, path, addr, data32); */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_write_rfreg(padapter, path, addr, 0xFFFFF, data32);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_priv_null(struct net_device *dev, struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dummy(struct net_device *dev, struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_set_channel_plan(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2014-12-17 01:03:30 +00:00
|
|
|
extern int rtw_channel_plan;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 channel_plan_req = (u8) (*((int *)wrqu));
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( _SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1) )
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s set channel_plan = 0x%02X\n", __func__, pmlmepriv->ChannelPlan);
|
2014-12-29 02:00:11 +00:00
|
|
|
else
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EPERM;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_set_mtk_wps_probe_ie(struct net_device *dev,
|
|
|
|
struct iw_request_info *a,
|
|
|
|
union iwreq_data *wrqu, char *b)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_get_sensitivity(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *buf)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wx_set_mtk_wps_ie(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For all data larger than 16 octets, we need to use a
|
|
|
|
* pointer to memory allocated in user space.
|
|
|
|
*/
|
|
|
|
static int rtw_drvext_hdl(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_DRVEXT_MODULE
|
|
|
|
u8 res;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct drvext_handler *phandler;
|
|
|
|
struct drvext_oidparam *poidparam;
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret;
|
|
|
|
u16 len;
|
|
|
|
u8 *pparmbuf, bset;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *p = &wrqu->data;
|
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if ( (!p->length) || (!p->pointer)) {
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto _rtw_drvext_hdl_exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
bset = (u8)(p->flags&0xFFFF);
|
|
|
|
len = p->length;
|
|
|
|
pparmbuf = (u8*)rtw_malloc(len);
|
2015-08-15 18:24:16 +00:00
|
|
|
if (pparmbuf == NULL) {
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto _rtw_drvext_hdl_exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (bset)/* set info */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
if (copy_from_user(pparmbuf, p->pointer,len)) {
|
|
|
|
rtw_mfree(pparmbuf, len);
|
|
|
|
ret = -EFAULT;
|
|
|
|
goto _rtw_drvext_hdl_exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
else/* query info */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* */
|
2014-12-19 06:59:46 +00:00
|
|
|
poidparam = (struct drvext_oidparam *)pparmbuf;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("drvext set oid subcode [%d], len[%d], InformationBufferLength[%d]\r\n",
|
2014-12-19 06:59:46 +00:00
|
|
|
poidparam->subcode, poidparam->len, len));
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* check subcode */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( poidparam->subcode >= MAX_DRVEXT_HANDLERS)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,("no matching drvext handlers\r\n"));
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto _rtw_drvext_hdl_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( poidparam->subcode >= MAX_DRVEXT_OID_SUBCODES)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,("no matching drvext subcodes\r\n"));
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto _rtw_drvext_hdl_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
phandler = drvextoidhandlers + poidparam->subcode;
|
|
|
|
|
|
|
|
if (poidparam->len != phandler->parmsize)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_err_,("no matching drvext param size %d vs %d\r\n",
|
|
|
|
poidparam->len , phandler->parmsize));
|
|
|
|
ret = -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
goto _rtw_drvext_hdl_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
res = phandler->handler(&padapter->drvextpriv, bset, poidparam->data);
|
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if (res== 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
ret = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
if (bset == 0x00) {/* query info */
|
|
|
|
/* memcpy(p->pointer, pparmbuf, len); */
|
2014-12-17 01:03:30 +00:00
|
|
|
if (copy_to_user(p->pointer, pparmbuf, len))
|
|
|
|
ret = -EFAULT;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
else
|
|
|
|
ret = -EFAULT;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
_rtw_drvext_hdl_exit:
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void rtw_dbg_mode_hdl(struct adapter *padapter, u32 id, u8 *pdata, u32 len)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-03-17 01:24:53 +00:00
|
|
|
struct mp_rw_reg * RegRWStruct;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct rf_reg_param *prfreg;
|
|
|
|
u8 path;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 offset;
|
|
|
|
u32 value;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s\n", __FUNCTION__);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (id)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
case GEN_MP_IOCTL_SUBCODE(MP_START):
|
|
|
|
DBG_871X("871x_driver is only for normal mode, can't enter mp mode\n");
|
2013-08-10 16:56:55 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case GEN_MP_IOCTL_SUBCODE(READ_REG):
|
2015-03-17 01:24:53 +00:00
|
|
|
RegRWStruct = (struct mp_rw_reg *)pdata;
|
2014-12-17 01:03:30 +00:00
|
|
|
switch (RegRWStruct->width)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
RegRWStruct->value = rtw_read8(padapter, RegRWStruct->offset);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
RegRWStruct->value = rtw_read16(padapter, RegRWStruct->offset);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
RegRWStruct->value = rtw_read32(padapter, RegRWStruct->offset);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-08-10 16:56:55 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case GEN_MP_IOCTL_SUBCODE(WRITE_REG):
|
2015-03-17 01:24:53 +00:00
|
|
|
RegRWStruct = (struct mp_rw_reg *)pdata;
|
2014-12-17 01:03:30 +00:00
|
|
|
switch (RegRWStruct->width)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
rtw_write8(padapter, RegRWStruct->offset, (u8)RegRWStruct->value);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
rtw_write16(padapter, RegRWStruct->offset, (u16)RegRWStruct->value);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
rtw_write32(padapter, RegRWStruct->offset, (u32)RegRWStruct->value);
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
default:
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case GEN_MP_IOCTL_SUBCODE(READ_RF_REG):
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
prfreg = (struct rf_reg_param *)pdata;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
path = (u8)prfreg->path;
|
|
|
|
offset = (u8)prfreg->offset;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
value = rtw_hal_read_rfreg(padapter, path, offset, 0xffffffff);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
prfreg->value = value;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG):
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
prfreg = (struct rf_reg_param *)pdata;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
path = (u8)prfreg->path;
|
2014-12-19 06:59:46 +00:00
|
|
|
offset = (u8)prfreg->offset;
|
2014-12-17 01:03:30 +00:00
|
|
|
value = prfreg->value;
|
2013-08-10 16:56:55 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_hal_write_rfreg(padapter, path, offset, 0xffffffff, value);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case GEN_MP_IOCTL_SUBCODE(TRIGGER_GPIO):
|
|
|
|
DBG_871X("==> trigger gpio 0\n");
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_TRIGGER_GPIO_0, NULL);
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_BT_COEXIST
|
2014-12-19 06:59:46 +00:00
|
|
|
case GEN_MP_IOCTL_SUBCODE(SET_DM_BT):
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("==> set dm_bt_coexist:%x\n",*(u8 *)pdata);
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_BT_SET_COEXIST, pdata);
|
|
|
|
break;
|
|
|
|
case GEN_MP_IOCTL_SUBCODE(DEL_BA):
|
|
|
|
DBG_871X("==> delete ba:%x\n",*(u8 *)pdata);
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_BT_ISSUE_DELBA, pdata);
|
|
|
|
break;
|
|
|
|
#endif
|
2014-12-19 06:59:46 +00:00
|
|
|
case GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS):
|
|
|
|
*pdata = rtw_hal_sreset_get_wifi_status(padapter);
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
u32 BytesRead, BytesWritten, BytesNeeded;
|
|
|
|
struct oid_par_priv oid_par;
|
|
|
|
struct mp_ioctl_handler *phandler;
|
|
|
|
struct mp_ioctl_param *poidparam;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint status=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
u16 len;
|
|
|
|
u8 *pparmbuf = NULL, bset;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct iw_point *p = &wrqu->data;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("+rtw_mp_ioctl_hdl\n"); */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* mutex_lock(&ioctl_mutex); */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((!p->length) || (!p->pointer)) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto _rtw_mp_ioctl_hdl_exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pparmbuf = NULL;
|
|
|
|
bset = (u8)(p->flags & 0xFFFF);
|
|
|
|
len = p->length;
|
2014-12-17 01:03:30 +00:00
|
|
|
pparmbuf = (u8*)rtw_malloc(len);
|
2015-08-15 18:24:16 +00:00
|
|
|
if (pparmbuf == NULL) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto _rtw_mp_ioctl_hdl_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_from_user(pparmbuf, p->pointer, len)) {
|
|
|
|
ret = -EFAULT;
|
|
|
|
goto _rtw_mp_ioctl_hdl_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
poidparam = (struct mp_ioctl_param *)pparmbuf;
|
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_,
|
|
|
|
("rtw_mp_ioctl_hdl: subcode [%d], len[%d], buffer_len[%d]\r\n",
|
|
|
|
poidparam->subcode, poidparam->len, len));
|
|
|
|
|
|
|
|
if (poidparam->subcode >= MAX_MP_IOCTL_SUBCODE) {
|
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("no matching drvext subcodes\r\n"));
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto _rtw_mp_ioctl_hdl_exit;
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%s: %d\n", __func__, poidparam->subcode); */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_dbg_mode_hdl(padapter, poidparam->subcode, poidparam->data, poidparam->len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
if (bset == 0x00) {/* query info */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (copy_to_user(p->pointer, pparmbuf, len))
|
|
|
|
ret = -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
ret = -EFAULT;
|
|
|
|
goto _rtw_mp_ioctl_hdl_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
_rtw_mp_ioctl_hdl_exit:
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (pparmbuf)
|
|
|
|
rtw_mfree(pparmbuf, len);
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* mutex_unlock(&ioctl_mutex); */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_get_ap_info(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int bssid_match, ret = 0;
|
|
|
|
u32 cnt=0, wpa_ielen;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
|
|
|
struct list_head *plist, *phead;
|
2013-05-08 21:45:39 +00:00
|
|
|
unsigned char *pbuf;
|
|
|
|
u8 bssid[ETH_ALEN];
|
|
|
|
char data[32];
|
|
|
|
struct wlan_network *pnetwork = NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2015-03-16 13:54:18 +00:00
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("+rtw_get_aplist_info\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((padapter->bDriverStopped) || (pdata== NULL))
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
ret= -EINVAL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING))) == true)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_msleep_os(30);
|
|
|
|
cnt++;
|
2015-08-15 18:02:34 +00:00
|
|
|
if (cnt > 100)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* pdata->length = 0; */
|
2013-05-08 21:45:39 +00:00
|
|
|
pdata->flags = 0;
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pdata->length>=32)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (copy_from_user(data, pdata->pointer, 32))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
ret= -EINVAL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ret= -EINVAL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while (1)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead,plist)== true)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
/* if (hwaddr_aton_i(pdata->pointer, bssid)) */
|
|
|
|
if (hwaddr_aton_i(data, bssid))
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("Invalid BSSID '%s'.\n", (u8*)data);
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_rtw_memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN) == true)/* BSSID match, then check if supporting wpa/wpa2 */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("BSSID:" MAC_FMT "\n", MAC_ARG(bssid));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pbuf && (wpa_ielen>0))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pdata->flags = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pbuf && (wpa_ielen>0))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pdata->flags = 2;
|
|
|
|
break;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
plist = get_next(plist);
|
|
|
|
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 00:35:20 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pdata->length>=34) {
|
|
|
|
if (copy_to_user((u8 __user *)pdata->pointer+32, (u8*)&pdata->flags, 1)) {
|
2014-12-17 01:03:30 +00:00
|
|
|
ret= -EINVAL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_set_pid(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
int *pdata = (int *)wrqu;
|
|
|
|
int selector;
|
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((padapter->bDriverStopped) || (pdata== NULL))
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
ret= -EINVAL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
selector = *pdata;
|
2015-08-15 18:02:34 +00:00
|
|
|
if (selector < 3 && selector >=0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->pid[selector] = *(pdata+1);
|
|
|
|
ui_pid[selector] = *(pdata+1);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s set pid[%d]=%d\n", __FUNCTION__, selector ,padapter->pid[selector]);
|
2015-03-02 16:35:25 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s selector %d error\n", __FUNCTION__, selector);
|
2015-03-02 16:35:25 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_wps_start(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
u32 u32wps_start = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
unsigned int uintRet = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
uintRet = copy_from_user( ( void* ) &u32wps_start, pdata->pointer, 4 );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((padapter->bDriverStopped) || (pdata== NULL))
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
ret= -EINVAL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( u32wps_start == 0 )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u32wps_start = *extra;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] wps_start = %d\n", __FUNCTION__, u32wps_start );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
if ( u32wps_start == 1 ) /* WPS Start */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_led_control(padapter, LED_CTL_START_WPS);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
else if ( u32wps_start == 2 ) /* WPS Stop because of wps success */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_led_control(padapter, LED_CTL_STOP_WPS);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
else if ( u32wps_start == 3 ) /* WPS Stop because of wps fail */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_led_control(padapter, LED_CTL_STOP_WPS_FAIL);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_wext_p2p_enable(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
enum P2P_ROLE init_role = P2P_ROLE_DISABLE;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (*extra == '0' )
|
2013-05-08 21:45:39 +00:00
|
|
|
init_role = P2P_ROLE_DISABLE;
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (*extra == '1')
|
2013-05-08 21:45:39 +00:00
|
|
|
init_role = P2P_ROLE_DEVICE;
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (*extra == '2')
|
2013-05-08 21:45:39 +00:00
|
|
|
init_role = P2P_ROLE_CLIENT;
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (*extra == '3')
|
2013-05-08 21:45:39 +00:00
|
|
|
init_role = P2P_ROLE_GO;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_FAIL == rtw_p2p_enable(padapter, init_role))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* set channel/bandwidth */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (init_role != P2P_ROLE_DISABLE)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 channel, ch_offset;
|
|
|
|
u16 bwmode;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Stay at the listen state and wait for discovery. */
|
2013-05-08 21:45:39 +00:00
|
|
|
channel = pwdinfo->listen_channel;
|
|
|
|
pwdinfo->operating_channel = pwdinfo->listen_channel;
|
|
|
|
ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE;
|
|
|
|
bwmode = HT_CHANNEL_WIDTH_20;
|
2015-02-15 20:31:30 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->operating_channel = pmlmeext->cur_channel;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
channel = pwdinfo->operating_channel;
|
|
|
|
ch_offset = pmlmeext->cur_ch_offset;
|
2014-12-19 06:59:46 +00:00
|
|
|
bwmode = pmlmeext->cur_bwmode;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_channel_bwmode(padapter, channel, ch_offset, bwmode);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_set_go_nego_ssid(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] ssid = %s, len = %zu\n", __FUNCTION__, extra, strlen( extra ) );
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy( pwdinfo->nego_ssid, extra, strlen( extra ) );
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->nego_ssidlen = strlen( extra );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_p2p_set_intent(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 intent = pwdinfo->intent;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
extra[ wrqu->data.length ] = 0x00;
|
|
|
|
|
|
|
|
intent = rtw_atoi( extra );
|
|
|
|
|
|
|
|
if ( intent <= 15 )
|
|
|
|
{
|
|
|
|
pwdinfo->intent= intent;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
else
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] intent = %d\n", __FUNCTION__, intent);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_set_listen_ch(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
2015-02-20 04:11:26 +00:00
|
|
|
u8 listen_ch = pwdinfo->listen_channel; /* Listen channel number */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
extra[ wrqu->data.length ] = 0x00;
|
|
|
|
listen_ch = rtw_atoi( extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( ( listen_ch == 1 ) || ( listen_ch == 6 ) || ( listen_ch == 11 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->listen_channel = listen_ch;
|
|
|
|
set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] listen_ch = %d\n", __FUNCTION__, pwdinfo->listen_channel );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_set_op_ch(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20110524 */
|
|
|
|
/* This function is used to set the operating channel if the driver will become the group owner */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
2015-02-20 04:11:26 +00:00
|
|
|
u8 op_ch = pwdinfo->operating_channel; /* Operating channel number */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
extra[ wrqu->data.length ] = 0x00;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
op_ch = ( u8 ) rtw_atoi( extra );
|
|
|
|
if ( op_ch > 0 )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->operating_channel = op_ch;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] op_ch = %d\n", __FUNCTION__, pwdinfo->operating_channel );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static int rtw_p2p_profilefound(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Comment by Albert 2010/10/13 */
|
|
|
|
/* Input data format: */
|
|
|
|
/* Ex: 0 */
|
|
|
|
/* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */
|
|
|
|
/* 0 => Reflush the profile record list. */
|
|
|
|
/* 1 => Add the profile list */
|
|
|
|
/* XX:XX:XX:XX:XX:XX => peer's MAC Address ( ex: 00:E0:4C:00:00:01 ) */
|
|
|
|
/* YY => SSID Length */
|
|
|
|
/* SSID => SSID for persistence group */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X( "[%s] In value = %s, len = %d\n", __FUNCTION__, extra, wrqu->data.length -1);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* The upper application should pass the SSID to driver by using this rtw_p2p_profilefound function. */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
if ( extra[ 0 ] == '0' )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Remove all the profile information of wifidirect_info structure. */
|
2015-02-19 20:58:09 +00:00
|
|
|
memset( &pwdinfo->profileinfo[ 0 ], 0x00, sizeof( struct profile_info ) * P2P_MAX_PERSISTENT_GROUP_NUM );
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->profileindex = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( pwdinfo->profileindex >= P2P_MAX_PERSISTENT_GROUP_NUM )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
int jj, kk;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Add this profile information into pwdinfo->profileinfo */
|
|
|
|
/* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */
|
2015-08-15 18:06:32 +00:00
|
|
|
for ( jj = 0, kk = 1; jj < ETH_ALEN; jj++, kk += 3 )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pwdinfo->profileinfo[ pwdinfo->profileindex ].peermac[ jj ] = key_2char2num(extra[ kk ], extra[ kk+ 1 ]);
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* pwdinfo->profileinfo[ pwdinfo->profileindex ].ssidlen = ( extra[18] - '0' ) * 10 + ( extra[ 19 ] - '0' ); */
|
|
|
|
/* memcpy( pwdinfo->profileinfo[ pwdinfo->profileindex ].ssid, &extra[ 20 ], pwdinfo->profileinfo[ pwdinfo->profileindex ].ssidlen ); */
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->profileindex++;
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_setDN(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
DBG_871X( "[%s] %s %d\n", __FUNCTION__, extra, wrqu->data.length -1 );
|
2015-02-19 20:58:09 +00:00
|
|
|
memset( pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN );
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy( pwdinfo->device_name, extra, wrqu->data.length - 1 );
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->device_name_len = wrqu->data.length - 1;
|
|
|
|
|
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_p2p_get_status(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( padapter->bShowGetP2PState )
|
|
|
|
{
|
|
|
|
DBG_871X( "[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __FUNCTION__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo),
|
|
|
|
pwdinfo->p2p_peer_interface_addr[ 0 ], pwdinfo->p2p_peer_interface_addr[ 1 ], pwdinfo->p2p_peer_interface_addr[ 2 ],
|
|
|
|
pwdinfo->p2p_peer_interface_addr[ 3 ], pwdinfo->p2p_peer_interface_addr[ 4 ], pwdinfo->p2p_peer_interface_addr[ 5 ]);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 2010/10/12 */
|
|
|
|
/* Because of the output size limitation, I had removed the "Role" information. */
|
|
|
|
/* About the "Role" information, we will use the new private IOCTL to get the "Role" information. */
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf( extra, "\n\nStatus=%.2d\n", rtw_p2p_state(pwdinfo) );
|
|
|
|
wrqu->data.length = strlen( extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20110520 */
|
|
|
|
/* This function will return the config method description */
|
|
|
|
/* This config method description will show us which config method the remote P2P device is intented to use */
|
|
|
|
/* by sending the provisioning discovery request frame. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static int rtw_p2p_get_req_cm(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf( extra, "\n\nCM=%s\n", pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req );
|
|
|
|
wrqu->data.length = strlen( extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_p2p_get_role(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __FUNCTION__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo),
|
|
|
|
pwdinfo->p2p_peer_interface_addr[ 0 ], pwdinfo->p2p_peer_interface_addr[ 1 ], pwdinfo->p2p_peer_interface_addr[ 2 ],
|
|
|
|
pwdinfo->p2p_peer_interface_addr[ 3 ], pwdinfo->p2p_peer_interface_addr[ 4 ], pwdinfo->p2p_peer_interface_addr[ 5 ]);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf( extra, "\n\nRole=%.2d\n", rtw_p2p_role(pwdinfo) );
|
|
|
|
wrqu->data.length = strlen( extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_p2p_get_peer_ifaddr(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
|
|
|
|
|
|
|
|
DBG_871X( "[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __FUNCTION__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo),
|
|
|
|
pwdinfo->p2p_peer_interface_addr[ 0 ], pwdinfo->p2p_peer_interface_addr[ 1 ], pwdinfo->p2p_peer_interface_addr[ 2 ],
|
|
|
|
pwdinfo->p2p_peer_interface_addr[ 3 ], pwdinfo->p2p_peer_interface_addr[ 4 ], pwdinfo->p2p_peer_interface_addr[ 5 ]);
|
|
|
|
|
|
|
|
sprintf( extra, "\nMAC %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
|
|
|
|
pwdinfo->p2p_peer_interface_addr[ 0 ], pwdinfo->p2p_peer_interface_addr[ 1 ], pwdinfo->p2p_peer_interface_addr[ 2 ],
|
|
|
|
pwdinfo->p2p_peer_interface_addr[ 3 ], pwdinfo->p2p_peer_interface_addr[ 4 ], pwdinfo->p2p_peer_interface_addr[ 5 ]);
|
|
|
|
wrqu->data.length = strlen( extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_peer_devaddr(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
|
|
|
|
DBG_871X( "[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __FUNCTION__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo),
|
2014-12-19 06:59:46 +00:00
|
|
|
pwdinfo->rx_prov_disc_info.peerDevAddr[ 0 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 1 ],
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->rx_prov_disc_info.peerDevAddr[ 2 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 3 ],
|
|
|
|
pwdinfo->rx_prov_disc_info.peerDevAddr[ 4 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 5 ]);
|
|
|
|
sprintf( extra, "\n%.2X%.2X%.2X%.2X%.2X%.2X",
|
2014-12-19 06:59:46 +00:00
|
|
|
pwdinfo->rx_prov_disc_info.peerDevAddr[ 0 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 1 ],
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->rx_prov_disc_info.peerDevAddr[ 2 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 3 ],
|
|
|
|
pwdinfo->rx_prov_disc_info.peerDevAddr[ 4 ], pwdinfo->rx_prov_disc_info.peerDevAddr[ 5 ]);
|
2014-12-19 06:59:46 +00:00
|
|
|
wrqu->data.length = strlen( extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_peer_devaddr_by_invitation(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
|
|
|
|
DBG_871X( "[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __FUNCTION__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo),
|
2014-12-19 06:59:46 +00:00
|
|
|
pwdinfo->p2p_peer_device_addr[ 0 ], pwdinfo->p2p_peer_device_addr[ 1 ],
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->p2p_peer_device_addr[ 2 ], pwdinfo->p2p_peer_device_addr[ 3 ],
|
|
|
|
pwdinfo->p2p_peer_device_addr[ 4 ], pwdinfo->p2p_peer_device_addr[ 5 ]);
|
|
|
|
sprintf( extra, "\nMAC %.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
|
2014-12-19 06:59:46 +00:00
|
|
|
pwdinfo->p2p_peer_device_addr[ 0 ], pwdinfo->p2p_peer_device_addr[ 1 ],
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->p2p_peer_device_addr[ 2 ], pwdinfo->p2p_peer_device_addr[ 3 ],
|
|
|
|
pwdinfo->p2p_peer_device_addr[ 4 ], pwdinfo->p2p_peer_device_addr[ 5 ]);
|
2014-12-19 06:59:46 +00:00
|
|
|
wrqu->data.length = strlen( extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_groupid(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
|
|
|
|
sprintf( extra, "\n%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s",
|
2014-12-19 06:59:46 +00:00
|
|
|
pwdinfo->groupid_info.go_device_addr[ 0 ], pwdinfo->groupid_info.go_device_addr[ 1 ],
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->groupid_info.go_device_addr[ 2 ], pwdinfo->groupid_info.go_device_addr[ 3 ],
|
|
|
|
pwdinfo->groupid_info.go_device_addr[ 4 ], pwdinfo->groupid_info.go_device_addr[ 5 ],
|
|
|
|
pwdinfo->groupid_info.ssid);
|
2014-12-19 06:59:46 +00:00
|
|
|
wrqu->data.length = strlen( extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_op_ch(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] Op_ch = %02x\n", __FUNCTION__, pwdinfo->operating_channel);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf( extra, "\n\nOp_ch=%.2d\n", pwdinfo->operating_channel );
|
|
|
|
wrqu->data.length = strlen( extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
inline static void macstr2num(u8 *dst, u8 *src)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int jj, kk;
|
|
|
|
for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3)
|
|
|
|
{
|
|
|
|
dst[jj] = key_2char2num(src[kk], src[kk + 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_wps_configmethod(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra, char *subcmd)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 peerMAC[ETH_ALEN] = { 0x00 };
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
|
|
|
struct list_head *plist,*phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
2013-08-10 16:56:55 +00:00
|
|
|
u8 blnMatch = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
__be16 be_attr_content = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
u16 attr_content = 0;
|
2013-08-10 16:56:55 +00:00
|
|
|
uint attr_contentlen = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 attr_content_str[P2P_PRIVATE_IOCTL_SET_LEN] = { 0x00 };
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20110727 */
|
|
|
|
/* The input data is the MAC address which the application wants to know its WPS config method. */
|
|
|
|
/* After knowing its WPS config method, the application can decide the config method for provisioning discovery. */
|
|
|
|
/* Format: iwpriv wlanx p2p_get_wpsCM 00:E0:4C:00:00:05 */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("[%s] data = %s\n", __FUNCTION__, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
macstr2num(peerMAC, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead, plist) == true) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (_rtw_memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *wpsie;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint wpsie_len = 0;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* The mac address is matched. */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( (wpsie=rtw_get_wps_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, NULL, &wpsie_len, pnetwork->network.Reserved[0])) )
|
|
|
|
{
|
|
|
|
rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8 *)&be_attr_content, &attr_contentlen);
|
2013-06-20 15:13:14 +00:00
|
|
|
if (attr_contentlen) {
|
2014-12-17 01:03:30 +00:00
|
|
|
attr_content = be16_to_cpu(be_attr_content);
|
|
|
|
sprintf(attr_content_str, "\n\nM=%.4d", attr_content);
|
2013-05-08 21:45:39 +00:00
|
|
|
blnMatch = 1;
|
|
|
|
}
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2013-06-20 15:13:14 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
plist = get_next(plist);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 21:00:41 +00:00
|
|
|
if (!blnMatch)
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(attr_content_str, "\n\nM=0000");
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length = strlen(attr_content_str);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(extra, attr_content_str, wrqu->data.length);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_p2p_get_peer_wfd_port(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
|
|
|
|
DBG_871X( "[%s] p2p_state = %d\n", __FUNCTION__, rtw_p2p_state(pwdinfo) );
|
|
|
|
|
|
|
|
sprintf( extra, "\n\nPort=%d\n", pwdinfo->wfd_info->peer_rtsp_ctrlport );
|
|
|
|
DBG_871X( "[%s] remote port = %d\n", __FUNCTION__, pwdinfo->wfd_info->peer_rtsp_ctrlport );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length = strlen( extra );
|
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_peer_wfd_preferred_connection(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
|
|
|
|
sprintf( extra, "\n\nwfd_pc=%d\n", pwdinfo->wfd_info->wfd_pc );
|
|
|
|
DBG_871X( "[%s] wfd_pc = %d\n", __FUNCTION__, pwdinfo->wfd_info->wfd_pc );
|
|
|
|
|
|
|
|
wrqu->data.length = strlen( extra );
|
2015-02-20 04:11:26 +00:00
|
|
|
pwdinfo->wfd_info->wfd_pc = false; /* Reset the WFD preferred connection to P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_peer_wfd_session_available(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
|
|
|
|
sprintf( extra, "\n\nwfd_sa=%d\n", pwdinfo->wfd_info->peer_session_avail );
|
|
|
|
DBG_871X( "[%s] wfd_sa = %d\n", __FUNCTION__, pwdinfo->wfd_info->peer_session_avail );
|
|
|
|
|
|
|
|
wrqu->data.length = strlen( extra );
|
2015-02-20 04:11:26 +00:00
|
|
|
pwdinfo->wfd_info->peer_session_avail = true; /* Reset the WFD session available */
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_p2p_get_go_device_address(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra, char *subcmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 peerMAC[ETH_ALEN] = { 0x00 };
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
|
|
|
struct list_head *plist, *phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
2013-08-10 16:56:55 +00:00
|
|
|
u8 blnMatch = 0;
|
|
|
|
u8 *p2pie;
|
|
|
|
uint p2pielen = 0, attr_contentlen = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 attr_content[100] = { 0x00 };
|
|
|
|
u8 go_devadd_str[P2P_PRIVATE_IOCTL_SET_LEN] = { 0x00 };
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20121209 */
|
|
|
|
/* The input data is the GO's interface address which the application wants to know its device address. */
|
|
|
|
/* Format: iwpriv wlanx p2p_get2 go_devadd=00:E0:4C:00:00:05 */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("[%s] data = %s\n", __FUNCTION__, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
macstr2num(peerMAC, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead, plist) == true) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (_rtw_memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN))
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 2011/05/18 */
|
|
|
|
/* Match the device address located in the P2P IE */
|
|
|
|
/* This is for the case that the P2P device address is not the same as the P2P interface address. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((p2pie = rtw_get_p2p_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, NULL, &p2pielen, pnetwork->network.Reserved[0])))
|
|
|
|
{
|
|
|
|
while (p2pie)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* The P2P Device ID attribute is included in the Beacon frame. */
|
|
|
|
/* The P2P Device Info attribute is included in the probe response frame. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(attr_content, 0x00, 100);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen))
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Handle the P2P Device ID attribute of Beacon first */
|
2013-05-08 21:45:39 +00:00
|
|
|
blnMatch = 1;
|
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
} else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen))
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Handle the P2P Device Info attribute of probe response */
|
2013-05-08 21:45:39 +00:00
|
|
|
blnMatch = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Get the next P2P IE */
|
2014-12-17 01:03:30 +00:00
|
|
|
p2pie = rtw_get_p2p_ie(p2pie + p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
plist = get_next(plist);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 00:35:20 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
if (!blnMatch) {
|
2015-08-15 18:31:56 +00:00
|
|
|
sprintf(go_devadd_str, "\n\ndev_add= NULL");
|
2015-03-06 17:54:48 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(go_devadd_str, "\n\ndev_add=%.2X:%.2X:%.2X:%.2X:%.2X:%.2X",
|
|
|
|
attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length = strlen(go_devadd_str);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(extra, go_devadd_str, wrqu->data.length);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return ret;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_device_type(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra, char *subcmd)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 peerMAC[ETH_ALEN] = { 0x00 };
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
|
|
|
struct list_head *plist, *phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
2013-08-10 16:56:55 +00:00
|
|
|
u8 blnMatch = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 dev_type[8] = { 0x00 };
|
2013-08-10 16:56:55 +00:00
|
|
|
uint dev_type_len = 0;
|
2015-02-20 04:11:26 +00:00
|
|
|
u8 dev_type_str[P2P_PRIVATE_IOCTL_SET_LEN] = { 0x00 }; /* +9 is for the str "dev_type=", we have to clear it at wrqu->data.pointer */
|
2013-08-10 16:56:55 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20121209 */
|
|
|
|
/* The input data is the MAC address which the application wants to know its device type. */
|
|
|
|
/* Such user interface could know the device type. */
|
|
|
|
/* Format: iwpriv wlanx p2p_get2 dev_type=00:E0:4C:00:00:05 */
|
2013-08-10 16:56:55 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("[%s] data = %s\n", __FUNCTION__, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
macstr2num(peerMAC, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead, plist) == true) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (_rtw_memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *wpsie;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint wpsie_len = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* The mac address is matched. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( (wpsie=rtw_get_wps_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, NULL, &wpsie_len, pnetwork->network.Reserved[0])) )
|
|
|
|
{
|
2013-05-09 21:00:41 +00:00
|
|
|
rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_PRIMARY_DEV_TYPE, dev_type, &dev_type_len);
|
2013-06-03 19:52:18 +00:00
|
|
|
if (dev_type_len) {
|
2014-12-17 01:03:30 +00:00
|
|
|
__be16 be_type;
|
|
|
|
u16 type;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&be_type, dev_type, 2);
|
2014-12-17 01:03:30 +00:00
|
|
|
type = be16_to_cpu(be_type);
|
|
|
|
sprintf(dev_type_str, "\n\nN=%.2d", type);
|
2013-05-08 21:45:39 +00:00
|
|
|
blnMatch = 1;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
plist = get_next(plist);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 21:00:41 +00:00
|
|
|
if (!blnMatch)
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(dev_type_str, "\n\nN=00");
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length = strlen(dev_type_str);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(extra, dev_type_str, wrqu->data.length);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return ret;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_device_name(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra, char *subcmd)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 peerMAC[ETH_ALEN] = { 0x00 };
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
|
|
|
struct list_head *plist, *phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
2013-08-10 16:56:55 +00:00
|
|
|
u8 blnMatch = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 dev_name[WPS_MAX_DEVICE_NAME_LEN] = { 0x00 };
|
2013-08-10 16:56:55 +00:00
|
|
|
uint dev_len = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 dev_name_str[P2P_PRIVATE_IOCTL_SET_LEN] = { 0x00 };
|
2013-08-10 16:56:55 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20121225 */
|
|
|
|
/* The input data is the MAC address which the application wants to know its device name. */
|
|
|
|
/* Such user interface could show peer device's device name instead of ssid. */
|
|
|
|
/* Format: iwpriv wlanx p2p_get2 devN=00:E0:4C:00:00:05 */
|
2013-08-10 16:56:55 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("[%s] data = %s\n", __FUNCTION__, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
macstr2num(peerMAC, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead, plist) == true) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (_rtw_memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *wpsie;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint wpsie_len = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* The mac address is matched. */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
if ( (wpsie=rtw_get_wps_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, NULL, &wpsie_len, pnetwork->network.Reserved[0])) )
|
|
|
|
{
|
2013-05-09 21:00:41 +00:00
|
|
|
rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_DEVICE_NAME, dev_name, &dev_len);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (dev_len)
|
|
|
|
{
|
|
|
|
sprintf(dev_name_str, "\n\nN=%s", dev_name);
|
2013-05-08 21:45:39 +00:00
|
|
|
blnMatch = 1;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2013-08-10 16:56:55 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
plist = get_next(plist);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 00:35:20 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 21:00:41 +00:00
|
|
|
if (!blnMatch)
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(dev_name_str, "\n\nN=0000");
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length = strlen(dev_name_str);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(extra, dev_name_str, wrqu->data.length);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return ret;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get_invitation_procedure(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra, char *subcmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 peerMAC[ETH_ALEN] = { 0x00 };
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
|
|
|
struct list_head *plist, *phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
2013-08-10 16:56:55 +00:00
|
|
|
u8 blnMatch = 0;
|
|
|
|
u8 *p2pie;
|
|
|
|
uint p2pielen = 0, attr_contentlen = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 attr_content[2] = { 0x00 };
|
|
|
|
u8 inv_proc_str[P2P_PRIVATE_IOCTL_SET_LEN] = { 0x00 };
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Ouden 20121226 */
|
|
|
|
/* The application wants to know P2P initation procedure is support or not. */
|
|
|
|
/* Format: iwpriv wlanx p2p_get2 InvProc=00:E0:4C:00:00:05 */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("[%s] data = %s\n", __FUNCTION__, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
macstr2num(peerMAC, subcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead, plist) == true) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (_rtw_memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN))
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20121226 */
|
|
|
|
/* Match the device address located in the P2P IE */
|
|
|
|
/* This is for the case that the P2P device address is not the same as the P2P interface address. */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
if ((p2pie = rtw_get_p2p_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, NULL, &p2pielen, pnetwork->network.Reserved[0])))
|
|
|
|
{
|
|
|
|
while (p2pie)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* memset( attr_content, 0x00, 2); */
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_CAPABILITY, attr_content, &attr_contentlen))
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Handle the P2P capability attribute */
|
2013-05-08 21:45:39 +00:00
|
|
|
blnMatch = 1;
|
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Get the next P2P IE */
|
2014-12-17 01:03:30 +00:00
|
|
|
p2pie = rtw_get_p2p_ie(p2pie + p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
plist = get_next(plist);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 00:35:20 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
if (!blnMatch) {
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(inv_proc_str, "\nIP=-1");
|
2015-03-06 17:54:48 +00:00
|
|
|
} else {
|
2015-03-10 16:18:03 +00:00
|
|
|
if (attr_content[0] & 0x20)
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(inv_proc_str, "\nIP=1");
|
2015-03-06 17:54:48 +00:00
|
|
|
else
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(inv_proc_str, "\nIP=0");
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
wrqu->data.length = strlen(inv_proc_str);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(extra, inv_proc_str, wrqu->data.length);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return ret;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_connect(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
u8 peerMAC[ ETH_ALEN ] = { 0x00 };
|
2014-12-19 06:59:46 +00:00
|
|
|
int jj,kk;
|
|
|
|
u8 peerMACStr[ ETH_ALEN * 2 ] = { 0x00 };
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
|
|
|
struct list_head *plist, *phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint uintPeerChannel = 0;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20110304 */
|
|
|
|
/* The input data contains two informations. */
|
|
|
|
/* 1. First information is the MAC address which wants to formate with */
|
|
|
|
/* 2. Second information is the WPS PINCode or "pbc" string for push button method */
|
|
|
|
/* Format: 00:E0:4C:00:00:05 */
|
|
|
|
/* Format: 00:E0:4C:00:00:05 */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
DBG_871X( "[%s] data = %s\n", __FUNCTION__, extra );
|
|
|
|
|
|
|
|
if ( pwdinfo->p2p_state == P2P_STATE_NONE )
|
|
|
|
{
|
|
|
|
DBG_871X( "[%s] WiFi Direct is disable!\n", __FUNCTION__ );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
return -1;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for ( jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3 )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
peerMAC[ jj ] = key_2char2num( extra[kk], extra[kk+ 1] );
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while (1)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead,plist)== true)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( pnetwork->network.MacAddress, peerMAC, ETH_ALEN ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
uintPeerChannel = pnetwork->network.Configuration.DSConfig;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
plist = get_next(plist);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-15 20:31:30 +00:00
|
|
|
if ( uintPeerChannel ) {
|
2015-02-19 20:58:09 +00:00
|
|
|
memset( &pwdinfo->nego_req_info, 0x00, sizeof( struct tx_nego_req_info ) );
|
|
|
|
memset( &pwdinfo->groupid_info, 0x00, sizeof( struct group_id_info ) );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->nego_req_info.peer_channel_num[ 0 ] = uintPeerChannel;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy( pwdinfo->nego_req_info.peerDevAddr, pnetwork->network.MacAddress, ETH_ALEN );
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->nego_req_info.benable = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
_cancel_timer_ex( &pwdinfo->restore_p2p_state_timer );
|
|
|
|
if ( rtw_p2p_state(pwdinfo) != P2P_STATE_GONEGO_OK )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Restore to the listen state if the current p2p state is not nego OK */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN );
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
|
|
|
|
rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING);
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] Start PreTx Procedure!\n", __FUNCTION__ );
|
|
|
|
_set_timer( &pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT );
|
|
|
|
_set_timer( &pwdinfo->restore_p2p_state_timer, P2P_GO_NEGO_TIMEOUT );
|
2015-02-15 20:31:30 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] Not Found in Scanning Queue~\n", __FUNCTION__ );
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
exit:
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_invite_req(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct iw_point *pdata = &wrqu->data;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
2014-12-19 06:59:46 +00:00
|
|
|
int jj,kk;
|
|
|
|
u8 peerMACStr[ ETH_ALEN * 2 ] = { 0x00 };
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
struct list_head *plist, *phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
|
|
|
uint uintPeerChannel = 0;
|
|
|
|
u8 attr_content[50] = { 0x00 }, _status = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
u8 *p2pie;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint p2pielen = 0, attr_contentlen = 0;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct tx_invite_req_info* pinvite_req_info = &pwdinfo->invitereq_info;
|
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifi_display_info* pwfd_info = pwdinfo->wfd_info;
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20120321 */
|
|
|
|
/* The input data contains two informations. */
|
|
|
|
/* 1. First information is the P2P device address which you want to send to. */
|
|
|
|
/* 2. Second information is the group id which combines with GO's mac address, space and GO's ssid. */
|
|
|
|
/* Command line sample: iwpriv wlan0 p2p_set invite="00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy" */
|
|
|
|
/* Format: 00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] data = %s\n", __FUNCTION__, extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( wrqu->data.length <= 37 )
|
|
|
|
{
|
|
|
|
DBG_871X( "[%s] Wrong format!\n", __FUNCTION__ );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X( "[%s] WiFi Direct is disable!\n", __FUNCTION__ );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Reset the content of struct tx_invite_req_info */
|
2014-12-29 02:13:24 +00:00
|
|
|
pinvite_req_info->benable = false;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset( pinvite_req_info->go_bssid, 0x00, ETH_ALEN );
|
|
|
|
memset( pinvite_req_info->go_ssid, 0x00, WLAN_SSID_MAXLEN );
|
2013-05-08 21:45:39 +00:00
|
|
|
pinvite_req_info->ssidlen = 0x00;
|
|
|
|
pinvite_req_info->operating_ch = pwdinfo->operating_channel;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset( pinvite_req_info->peer_macaddr, 0x00, ETH_ALEN );
|
2013-05-08 21:45:39 +00:00
|
|
|
pinvite_req_info->token = 3;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for ( jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3 )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pinvite_req_info->peer_macaddr[ jj ] = key_2char2num( extra[kk], extra[kk+ 1] );
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while (1)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead,plist)== true)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 2011/05/18 */
|
|
|
|
/* Match the device address located in the P2P IE */
|
|
|
|
/* This is for the case that the P2P device address is not the same as the P2P interface address. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( (p2pie=rtw_get_p2p_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, NULL, &p2pielen, pnetwork->network.Reserved[0])))
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* The P2P Device ID attribute is included in the Beacon frame. */
|
|
|
|
/* The P2P Device Info attribute is included in the probe response frame. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( rtw_get_p2p_attr_content( p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Handle the P2P Device ID attribute of Beacon first */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
uintPeerChannel = pnetwork->network.Configuration.DSConfig;
|
|
|
|
break;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if ( rtw_get_p2p_attr_content( p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Handle the P2P Device Info attribute of probe response */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
uintPeerChannel = pnetwork->network.Configuration.DSConfig;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
plist = get_next(plist);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( uintPeerChannel )
|
|
|
|
{
|
|
|
|
u8 wfd_ie[ 128 ] = { 0x00 };
|
|
|
|
uint wfd_ielen = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( rtw_get_wfd_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, wfd_ie, &wfd_ielen, pnetwork->network.Reserved[0]) )
|
|
|
|
{
|
|
|
|
u8 wfd_devinfo[ 6 ] = { 0x00 };
|
|
|
|
uint wfd_devlen = 6;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] Found WFD IE!\n", __FUNCTION__ );
|
|
|
|
if ( rtw_get_wfd_attr_content( wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, wfd_devinfo, &wfd_devlen ) )
|
|
|
|
{
|
|
|
|
u16 wfd_devinfo_field = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20120319 */
|
|
|
|
/* The first two bytes are the WFD device information field of WFD device information subelement. */
|
|
|
|
/* In big endian format. */
|
2014-12-17 01:03:30 +00:00
|
|
|
wfd_devinfo_field = RTW_GET_BE16(wfd_devinfo);
|
|
|
|
if ( wfd_devinfo_field & WFD_DEVINFO_SESSION_AVAIL )
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwfd_info->peer_session_avail = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwfd_info->peer_session_avail = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ( false == pwfd_info->peer_session_avail )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X( "[%s] WFD Session not avaiable!\n", __FUNCTION__ );
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-15 20:31:30 +00:00
|
|
|
if ( uintPeerChannel ) {
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Store the GO's bssid */
|
2015-08-15 18:06:32 +00:00
|
|
|
for ( jj = 0, kk = 18; jj < ETH_ALEN; jj++, kk += 3 )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pinvite_req_info->go_bssid[ jj ] = key_2char2num( extra[kk], extra[kk+ 1] );
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Store the GO's ssid */
|
2013-05-08 21:45:39 +00:00
|
|
|
pinvite_req_info->ssidlen = wrqu->data.length - 36;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy( pinvite_req_info->go_ssid, &extra[ 36 ], (u32) pinvite_req_info->ssidlen );
|
2014-12-29 02:13:24 +00:00
|
|
|
pinvite_req_info->benable = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
pinvite_req_info->peer_ch = uintPeerChannel;
|
|
|
|
|
|
|
|
rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
|
|
|
|
rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INVITE_REQ);
|
|
|
|
|
|
|
|
set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
_set_timer( &pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
_set_timer( &pwdinfo->restore_p2p_state_timer, P2P_INVITE_TIMEOUT );
|
2015-02-15 20:31:30 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] NOT Found in the Scanning Queue!\n", __FUNCTION__ );
|
|
|
|
}
|
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_set_persistent(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct iw_point *pdata = &wrqu->data;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
2014-12-19 06:59:46 +00:00
|
|
|
int jj,kk;
|
|
|
|
u8 peerMACStr[ ETH_ALEN * 2 ] = { 0x00 };
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
struct list_head *plist, *phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
|
|
|
uint uintPeerChannel = 0;
|
|
|
|
u8 attr_content[50] = { 0x00 }, _status = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
u8 *p2pie;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint p2pielen = 0, attr_contentlen = 0;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct tx_invite_req_info* pinvite_req_info = &pwdinfo->invitereq_info;
|
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifi_display_info* pwfd_info = pwdinfo->wfd_info;
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20120328 */
|
|
|
|
/* The input data is 0 or 1 */
|
|
|
|
/* 0: disable persistent group functionality */
|
|
|
|
/* 1: enable persistent group founctionality */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] data = %s\n", __FUNCTION__, extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X( "[%s] WiFi Direct is disable!\n", __FUNCTION__ );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
if ( extra[ 0 ] == '0' ) /* Disable the persistent group function. */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->persistent_supported = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
else if ( extra[ 0 ] == '1' ) /* Enable the persistent group function. */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->persistent_supported = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->persistent_supported = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
printk( "[%s] persistent_supported = %d\n", __FUNCTION__, pwdinfo->persistent_supported );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int hexstr2bin(const char *hex, u8 *buf, size_t len)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
int a;
|
|
|
|
const char *ipos = hex;
|
|
|
|
u8 *opos = buf;
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
a = hex2byte_i(ipos);
|
|
|
|
if (a < 0)
|
|
|
|
return -1;
|
|
|
|
*opos++ = a;
|
|
|
|
ipos += 2;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uuid_str2bin(const char *str, u8 *bin)
|
|
|
|
{
|
|
|
|
const char *pos;
|
|
|
|
u8 *opos;
|
|
|
|
|
|
|
|
pos = str;
|
|
|
|
opos = bin;
|
|
|
|
|
|
|
|
if (hexstr2bin(pos, opos, 4))
|
|
|
|
return -1;
|
|
|
|
pos += 8;
|
|
|
|
opos += 4;
|
|
|
|
|
|
|
|
if (*pos++ != '-' || hexstr2bin(pos, opos, 2))
|
|
|
|
return -1;
|
|
|
|
pos += 4;
|
|
|
|
opos += 2;
|
|
|
|
|
|
|
|
if (*pos++ != '-' || hexstr2bin(pos, opos, 2))
|
|
|
|
return -1;
|
|
|
|
pos += 4;
|
|
|
|
opos += 2;
|
|
|
|
|
|
|
|
if (*pos++ != '-' || hexstr2bin(pos, opos, 2))
|
|
|
|
return -1;
|
|
|
|
pos += 4;
|
|
|
|
opos += 2;
|
|
|
|
|
|
|
|
if (*pos++ != '-' || hexstr2bin(pos, opos, 6))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_set_wps_uuid(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
|
|
|
|
|
|
|
|
DBG_871X("[%s] data = %s\n", __FUNCTION__, extra);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
if ((36 == strlen(extra)) && (uuid_str2bin(extra, pwdinfo->uuid) == 0))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pwdinfo->external_uuid = 1;
|
|
|
|
} else {
|
|
|
|
pwdinfo->external_uuid = 0;
|
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_p2p_set_pc(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct iw_point *pdata = &wrqu->data;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
u8 peerMAC[ ETH_ALEN ] = { 0x00 };
|
2014-12-19 06:59:46 +00:00
|
|
|
int jj,kk;
|
|
|
|
u8 peerMACStr[ ETH_ALEN * 2 ] = { 0x00 };
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
struct list_head *plist, *phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 attr_content[50] = { 0x00 }, _status = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *p2pie;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint p2pielen = 0, attr_contentlen = 0;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint uintPeerChannel = 0;
|
|
|
|
struct wifi_display_info* pwfd_info = pwdinfo->wfd_info;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20120512 */
|
|
|
|
/* 1. Input information is the MAC address which wants to know the Preferred Connection bit (PC bit) */
|
|
|
|
/* Format: 00:E0:4C:00:00:05 */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
DBG_871X( "[%s] data = %s\n", __FUNCTION__, extra );
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X( "[%s] WiFi Direct is disable!\n", __FUNCTION__ );
|
|
|
|
return ret;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for ( jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3 )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
peerMAC[ jj ] = key_2char2num( extra[kk], extra[kk+ 1] );
|
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while (1)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead,plist)== true)
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 2011/05/18 */
|
|
|
|
/* Match the device address located in the P2P IE */
|
|
|
|
/* This is for the case that the P2P device address is not the same as the P2P interface address. */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
if ( (p2pie=rtw_get_p2p_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, NULL, &p2pielen, pnetwork->network.Reserved[0])))
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* The P2P Device ID attribute is included in the Beacon frame. */
|
|
|
|
/* The P2P Device Info attribute is included in the probe response frame. */
|
2014-12-17 01:03:30 +00:00
|
|
|
printk( "[%s] Got P2P IE\n", __FUNCTION__ );
|
|
|
|
if ( rtw_get_p2p_attr_content( p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Handle the P2P Device ID attribute of Beacon first */
|
2015-08-15 18:00:19 +00:00
|
|
|
printk( "[%s] P2P_ATTR_DEVICE_ID\n", __FUNCTION__ );
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( attr_content, peerMAC, ETH_ALEN ) )
|
|
|
|
{
|
|
|
|
uintPeerChannel = pnetwork->network.Configuration.DSConfig;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( rtw_get_p2p_attr_content( p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Handle the P2P Device Info attribute of probe response */
|
2015-08-15 18:00:19 +00:00
|
|
|
printk( "[%s] P2P_ATTR_DEVICE_INFO\n", __FUNCTION__ );
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( attr_content, peerMAC, ETH_ALEN ) )
|
|
|
|
{
|
|
|
|
uintPeerChannel = pnetwork->network.Configuration.DSConfig;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
plist = get_next(plist);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2014-12-17 01:03:30 +00:00
|
|
|
printk( "[%s] channel = %d\n", __FUNCTION__, uintPeerChannel );
|
|
|
|
|
|
|
|
if ( uintPeerChannel )
|
|
|
|
{
|
|
|
|
u8 wfd_ie[ 128 ] = { 0x00 };
|
|
|
|
uint wfd_ielen = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( rtw_get_wfd_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, wfd_ie, &wfd_ielen, pnetwork->network.Reserved[0]) )
|
|
|
|
{
|
|
|
|
u8 wfd_devinfo[ 6 ] = { 0x00 };
|
|
|
|
uint wfd_devlen = 6;
|
|
|
|
|
|
|
|
DBG_871X( "[%s] Found WFD IE!\n", __FUNCTION__ );
|
|
|
|
if ( rtw_get_wfd_attr_content( wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, wfd_devinfo, &wfd_devlen ) )
|
|
|
|
{
|
|
|
|
u16 wfd_devinfo_field = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20120319 */
|
|
|
|
/* The first two bytes are the WFD device information field of WFD device information subelement. */
|
|
|
|
/* In big endian format. */
|
2014-12-17 01:03:30 +00:00
|
|
|
wfd_devinfo_field = RTW_GET_BE16(wfd_devinfo);
|
|
|
|
if ( wfd_devinfo_field & WFD_DEVINFO_PC_TDLS )
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwfd_info->wfd_pc = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwfd_info->wfd_pc = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X( "[%s] NOT Found in the Scanning Queue!\n", __FUNCTION__ );
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_set_wfd_device_type(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct iw_point *pdata = &wrqu->data;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
struct wifi_display_info* pwfd_info = pwdinfo->wfd_info;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20120328 */
|
|
|
|
/* The input data is 0 or 1 */
|
|
|
|
/* 0: specify to Miracast source device */
|
|
|
|
/* 1 or others: specify to Miracast sink device (display device) */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] data = %s\n", __FUNCTION__, extra );
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
if ( extra[ 0 ] == '0' ) /* Set to Miracast source device. */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pwfd_info->wfd_device_type = WFD_DEVINFO_SOURCE;
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
else /* Set to Miracast sink device. */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pwfd_info->wfd_device_type = WFD_DEVINFO_PSINK;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_set_scan_result_type(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct iw_point *pdata = &wrqu->data;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
struct wifi_display_info *pwfd_info = pwdinfo->wfd_info;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20120328 */
|
|
|
|
/* The input data is 0 , 1 , 2 */
|
|
|
|
/* 0: when the P2P is enabled, the scan result will return all the found P2P device. */
|
|
|
|
/* 1: when the P2P is enabled, the scan result will return all the found P2P device and AP. */
|
|
|
|
/* 2: when the P2P is enabled, the scan result will show up the found Miracast devices base on... */
|
|
|
|
/* It will show up all the Miracast source device if this device is sink. */
|
|
|
|
/* It will show up all the Miracast sink device if this device is source. */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] data = %s\n", __FUNCTION__, extra );
|
|
|
|
|
|
|
|
if ( extra[ 0 ] == '0' )
|
|
|
|
{
|
|
|
|
pwfd_info->scan_result_type = SCAN_RESULT_P2P_ONLY;
|
|
|
|
}
|
|
|
|
else if ( extra[ 0 ] == '1' )
|
|
|
|
{
|
|
|
|
pwfd_info->scan_result_type = SCAN_RESULT_ALL;
|
|
|
|
}
|
|
|
|
else if ( extra[ 0 ] == '2' )
|
|
|
|
{
|
|
|
|
pwfd_info->scan_result_type = SCAN_RESULT_WFD_TYPE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pwfd_info->scan_result_type = SCAN_RESULT_P2P_ONLY;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_p2p_set_wfd_enable(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Kurt 20121206 */
|
|
|
|
/* This function is used to set wfd enabled */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (*extra == '0' )
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->wfd_info->wfd_enable = false;
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (*extra == '1')
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->wfd_info->wfd_enable = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] wfd_enable = %d\n", __FUNCTION__, pwdinfo->wfd_info->wfd_enable );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_set_driver_iface(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Kurt 20121206 */
|
|
|
|
/* This function is used to set driver iface is WEXT or CFG80211 */
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (*extra == '1' )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pwdinfo->driver_interface = DRIVER_WEXT;
|
|
|
|
DBG_871X( "[%s] driver_interface = WEXT\n", __FUNCTION__);
|
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (*extra == '2')
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pwdinfo->driver_interface = DRIVER_CFG80211;
|
|
|
|
DBG_871X( "[%s] driver_interface = CFG80211\n", __FUNCTION__);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* To set the WFD session available to enable or disable */
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_p2p_set_sa(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct iw_point *pdata = &wrqu->data;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
struct wifi_display_info *pwfd_info = pwdinfo->wfd_info;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] data = %s\n", __FUNCTION__, extra );
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( 0 )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X( "[%s] WiFi Direct is disable!\n", __FUNCTION__ );
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
else
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
if ( extra[ 0 ] == '0' ) /* Disable the session available. */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->session_available = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
else if ( extra[ 0 ] == '1' ) /* Enable the session available. */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->session_available = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->session_available = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
printk( "[%s] session available = %d\n", __FUNCTION__, pwdinfo->session_available );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_p2p_prov_disc(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
|
|
|
u8 peerMAC[ ETH_ALEN ] = { 0x00 };
|
2014-12-19 06:59:46 +00:00
|
|
|
int jj,kk;
|
|
|
|
u8 peerMACStr[ ETH_ALEN * 2 ] = { 0x00 };
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-03-16 13:54:18 +00:00
|
|
|
struct list_head *plist, *phead;
|
|
|
|
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pnetwork = NULL;
|
|
|
|
uint uintPeerChannel = 0;
|
|
|
|
u8 attr_content[100] = { 0x00 }, _status = 0;
|
|
|
|
u8 *p2pie;
|
|
|
|
uint p2pielen = 0, attr_contentlen = 0;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2014-12-19 06:59:46 +00:00
|
|
|
u8 ie_offset;
|
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifi_display_info* pwfd_info = pwdinfo->wfd_info;
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20110301 */
|
|
|
|
/* The input data contains two informations. */
|
|
|
|
/* 1. First information is the MAC address which wants to issue the provisioning discovery request frame. */
|
|
|
|
/* 2. Second information is the WPS configuration method which wants to discovery */
|
|
|
|
/* Format: 00:E0:4C:00:00:05_display */
|
|
|
|
/* Format: 00:E0:4C:00:00:05_keypad */
|
|
|
|
/* Format: 00:E0:4C:00:00:05_pbc */
|
|
|
|
/* Format: 00:E0:4C:00:00:05_label */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
DBG_871X( "[%s] data = %s\n", __FUNCTION__, extra );
|
|
|
|
|
2015-03-02 16:54:45 +00:00
|
|
|
if ( pwdinfo->p2p_state == P2P_STATE_NONE ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] WiFi Direct is disable!\n", __FUNCTION__ );
|
|
|
|
return ret;
|
2015-03-02 16:54:45 +00:00
|
|
|
} else {
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Reset the content of struct tx_provdisc_req_info excluded the wps_config_method_request. */
|
2015-02-19 20:58:09 +00:00
|
|
|
memset( pwdinfo->tx_prov_disc_info.peerDevAddr, 0x00, ETH_ALEN );
|
|
|
|
memset( pwdinfo->tx_prov_disc_info.peerIFAddr, 0x00, ETH_ALEN );
|
2015-03-14 23:14:05 +00:00
|
|
|
memset( &pwdinfo->tx_prov_disc_info.ssid, 0x00, sizeof( struct ndis_802_11_ssid ) );
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->tx_prov_disc_info.peer_channel_num[ 0 ] = 0;
|
|
|
|
pwdinfo->tx_prov_disc_info.peer_channel_num[ 1 ] = 0;
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->tx_prov_disc_info.benable = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for ( jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3 )
|
2014-12-17 01:03:30 +00:00
|
|
|
peerMAC[ jj ] = key_2char2num( extra[kk], extra[kk+ 1] );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( &extra[ 18 ], "display", 7 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_DISPLYA;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( &extra[ 18 ], "keypad", 7 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_KEYPAD;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( &extra[ 18 ], "pbc", 3 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_PUSH_BUTTON;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( &extra[ 18 ], "label", 5 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_LABEL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X( "[%s] Unknown WPS config methodn", __FUNCTION__ );
|
|
|
|
return( ret );
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pmlmepriv->scanned_queue.lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:04:12 +00:00
|
|
|
while (1)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_end_of_queue_search(phead,plist)== true)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( uintPeerChannel != 0 )
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 2011/05/18 */
|
|
|
|
/* Match the device address located in the P2P IE */
|
|
|
|
/* This is for the case that the P2P device address is not the same as the P2P interface address. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */
|
2014-12-17 01:03:30 +00:00
|
|
|
ie_offset = 0;
|
2015-02-20 04:11:26 +00:00
|
|
|
} else { /* Beacon or Probe Respones */
|
2014-12-17 01:03:30 +00:00
|
|
|
ie_offset = 12;
|
|
|
|
}
|
|
|
|
if ( (p2pie=rtw_get_p2p_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, NULL, &p2pielen, pnetwork->network.Reserved[0])))
|
|
|
|
{
|
|
|
|
while ( p2pie )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* The P2P Device ID attribute is included in the Beacon frame. */
|
|
|
|
/* The P2P Device Info attribute is included in the probe response frame. */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
if ( rtw_get_p2p_attr_content( p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Handle the P2P Device ID attribute of Beacon first */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( attr_content, peerMAC, ETH_ALEN ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
uintPeerChannel = pnetwork->network.Configuration.DSConfig;
|
|
|
|
break;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if ( rtw_get_p2p_attr_content( p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Handle the P2P Device Info attribute of probe response */
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( attr_content, peerMAC, ETH_ALEN ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
uintPeerChannel = pnetwork->network.Configuration.DSConfig;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Get the next P2P IE */
|
2014-12-17 01:03:30 +00:00
|
|
|
p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - ie_offset -(p2pie -&pnetwork->network.IEs[ie_offset] + p2pielen), NULL, &p2pielen);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
plist = get_next(plist);
|
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&(pmlmepriv->scanned_queue.lock));
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
if ( uintPeerChannel )
|
|
|
|
{
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u8 wfd_ie[ 128 ] = { 0x00 };
|
|
|
|
uint wfd_ielen = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( rtw_get_wfd_ie_from_scan_queue( &pnetwork->network.IEs[0], pnetwork->network.IELength, wfd_ie, &wfd_ielen, pnetwork->network.Reserved[0]) )
|
|
|
|
{
|
|
|
|
u8 wfd_devinfo[ 6 ] = { 0x00 };
|
|
|
|
uint wfd_devlen = 6;
|
|
|
|
|
|
|
|
DBG_871X( "[%s] Found WFD IE!\n", __FUNCTION__ );
|
|
|
|
if ( rtw_get_wfd_attr_content( wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, wfd_devinfo, &wfd_devlen ) )
|
|
|
|
{
|
|
|
|
u16 wfd_devinfo_field = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 20120319 */
|
|
|
|
/* The first two bytes are the WFD device information field of WFD device information subelement. */
|
|
|
|
/* In big endian format. */
|
2014-12-17 01:03:30 +00:00
|
|
|
wfd_devinfo_field = RTW_GET_BE16(wfd_devinfo);
|
|
|
|
if ( wfd_devinfo_field & WFD_DEVINFO_SESSION_AVAIL )
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwfd_info->peer_session_avail = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pwfd_info->peer_session_avail = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ( false == pwfd_info->peer_session_avail )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X( "[%s] WFD Session not avaiable!\n", __FUNCTION__ );
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] peer channel: %d!\n", __FUNCTION__, uintPeerChannel );
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy( pwdinfo->tx_prov_disc_info.peerIFAddr, pnetwork->network.MacAddress, ETH_ALEN );
|
|
|
|
memcpy( pwdinfo->tx_prov_disc_info.peerDevAddr, peerMAC, ETH_ALEN );
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->tx_prov_disc_info.peer_channel_num[0] = ( u16 ) uintPeerChannel;
|
2014-12-29 02:13:24 +00:00
|
|
|
pwdinfo->tx_prov_disc_info.benable = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo));
|
|
|
|
rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
memcpy( &pwdinfo->tx_prov_disc_info.ssid, &pnetwork->network.Ssid, sizeof( struct ndis_802_11_ssid ) );
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy( pwdinfo->tx_prov_disc_info.ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN );
|
2014-12-17 01:03:30 +00:00
|
|
|
pwdinfo->tx_prov_disc_info.ssid.SsidLength= P2P_WILDCARD_SSID_LEN;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
_set_timer( &pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
_set_timer( &pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT );
|
2015-02-15 20:31:30 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] NOT Found in the Scanning Queue!\n", __FUNCTION__ );
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
exit:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Added by Albert 20110328 */
|
|
|
|
/* This function is used to inform the driver the user had specified the pin code value or pbc */
|
|
|
|
/* to application. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static int rtw_p2p_got_wpsinfo(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &( padapter->wdinfo );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] data = %s\n", __FUNCTION__, extra );
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Added by Albert 20110328 */
|
|
|
|
/* if the input data is P2P_NO_WPSINFO -> reset the wpsinfo */
|
|
|
|
/* if the input data is P2P_GOT_WPSINFO_PEER_DISPLAY_PIN -> the utility just input the PIN code got from the peer P2P device. */
|
|
|
|
/* if the input data is P2P_GOT_WPSINFO_SELF_DISPLAY_PIN -> the utility just got the PIN code from itself. */
|
|
|
|
/* if the input data is P2P_GOT_WPSINFO_PBC -> the utility just determine to use the PBC */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( *extra == '0' )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if ( *extra == '1' )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PEER_DISPLAY_PIN;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if ( *extra == '2' )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_SELF_DISPLAY_PIN;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if ( *extra == '3' )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PBC;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static int rtw_p2p_set(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
|
|
|
|
DBG_871X( "[%s] extra = %s\n", __FUNCTION__, extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( extra, "enable=", 7 ) )
|
|
|
|
{
|
|
|
|
rtw_wext_p2p_enable( dev, info, wrqu, &extra[7] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "setDN=", 6 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->data.length -= 6;
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_setDN( dev, info, wrqu, &extra[6] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "profilefound=", 13 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->data.length -= 13;
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_profilefound( dev, info, wrqu, &extra[13] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "prov_disc=", 10 ) )
|
|
|
|
{
|
|
|
|
wrqu->data.length -= 10;
|
|
|
|
rtw_p2p_prov_disc( dev, info, wrqu, &extra[10] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "nego=", 5 ) )
|
|
|
|
{
|
|
|
|
wrqu->data.length -= 5;
|
|
|
|
rtw_p2p_connect( dev, info, wrqu, &extra[5] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "intent=", 7 ) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 2011/03/23 */
|
|
|
|
/* The wrqu->data.length will include the null character */
|
|
|
|
/* So, we will decrease 7 + 1 */
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length -= 8;
|
|
|
|
rtw_p2p_set_intent( dev, info, wrqu, &extra[7] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "ssid=", 5 ) )
|
|
|
|
{
|
|
|
|
wrqu->data.length -= 5;
|
|
|
|
rtw_p2p_set_go_nego_ssid( dev, info, wrqu, &extra[5] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "got_wpsinfo=", 12 ) )
|
|
|
|
{
|
|
|
|
wrqu->data.length -= 12;
|
|
|
|
rtw_p2p_got_wpsinfo( dev, info, wrqu, &extra[12] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "listen_ch=", 10 ) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 2011/05/24 */
|
|
|
|
/* The wrqu->data.length will include the null character */
|
|
|
|
/* So, we will decrease (10 + 1) */
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length -= 11;
|
|
|
|
rtw_p2p_set_listen_ch( dev, info, wrqu, &extra[10] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "op_ch=", 6 ) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Commented by Albert 2011/05/24 */
|
|
|
|
/* The wrqu->data.length will include the null character */
|
|
|
|
/* So, we will decrease (6 + 1) */
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length -= 7;
|
|
|
|
rtw_p2p_set_op_ch( dev, info, wrqu, &extra[6] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "invite=", 7 ) )
|
|
|
|
{
|
|
|
|
wrqu->data.length -= 8;
|
|
|
|
rtw_p2p_invite_req( dev, info, wrqu, &extra[7] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "persistent=", 11 ) )
|
|
|
|
{
|
|
|
|
wrqu->data.length -= 11;
|
|
|
|
rtw_p2p_set_persistent( dev, info, wrqu, &extra[11] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp ( extra, "uuid=", 5) )
|
|
|
|
{
|
|
|
|
wrqu->data.length -= 5;
|
|
|
|
ret = rtw_p2p_set_wps_uuid( dev, info, wrqu, &extra[5] );
|
|
|
|
}
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2014-12-17 01:03:30 +00:00
|
|
|
else if ( _rtw_memcmp( extra, "sa=", 3 ) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* sa: WFD Session Available information */
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length -= 3;
|
|
|
|
rtw_p2p_set_sa( dev, info, wrqu, &extra[3] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "pc=", 3 ) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* pc: WFD Preferred Connection */
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length -= 3;
|
|
|
|
rtw_p2p_set_pc( dev, info, wrqu, &extra[3] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "wfd_type=", 9 ) )
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Specify this device is Mircast source or sink */
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu->data.length -= 9;
|
|
|
|
rtw_p2p_set_wfd_device_type( dev, info, wrqu, &extra[9] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "scan_type=", 10 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->data.length -= 10;
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_set_scan_result_type( dev, info, wrqu, &extra[10] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "wfd_enable=", 11 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
wrqu->data.length -= 11;
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_set_wfd_enable( dev, info, wrqu, &extra[11] );
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "driver_iface=", 13 ) )
|
|
|
|
{
|
|
|
|
wrqu->data.length -= 13;
|
|
|
|
rtw_p2p_set_driver_iface( dev, info, wrqu, &extra[13] );
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
int ret = 0;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *pdata = &wrqu->data;
|
|
|
|
struct wifidirect_info *pwdinfo= &(padapter->wdinfo);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
|
|
|
|
if ( padapter->bShowGetP2PState )
|
2015-01-29 21:27:28 +00:00
|
|
|
DBG_871X( "[%s] extra = %s\n", __FUNCTION__, (__force char *)wrqu->data.pointer );
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-29 21:27:28 +00:00
|
|
|
if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "status", 6 ) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_get_status( dev, info, wrqu, extra );
|
2015-01-29 21:27:28 +00:00
|
|
|
} else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "role", 4 ) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_get_role( dev, info, wrqu, extra);
|
2015-01-29 21:27:28 +00:00
|
|
|
} else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "peer_ifa", 8 ) ) {
|
|
|
|
rtw_p2p_get_peer_ifaddr(dev, info, wrqu, extra);
|
|
|
|
} else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "req_cm", 6 ) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_get_req_cm( dev, info, wrqu, extra);
|
2015-01-29 21:27:28 +00:00
|
|
|
} else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "peer_deva", 9 ) ) {
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Get the P2P device address when receiving the provision discovery request frame. */
|
2015-01-29 21:27:28 +00:00
|
|
|
rtw_p2p_get_peer_devaddr((__force void *)dev, info, wrqu, extra);
|
|
|
|
} else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "group_id", 8 ) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_get_groupid( dev, info, wrqu, extra);
|
2015-01-29 21:27:28 +00:00
|
|
|
} else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "inv_peer_deva", 13 ) ) {
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Get the P2P device address when receiving the P2P Invitation request frame. */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_get_peer_devaddr_by_invitation( dev, info, wrqu, extra);
|
2015-01-29 21:27:28 +00:00
|
|
|
} else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "op_ch", 5 ) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_get_op_ch( dev, info, wrqu, extra);
|
|
|
|
}
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2015-01-29 21:27:28 +00:00
|
|
|
else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "peer_port", 9 ) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_get_peer_wfd_port( dev, info, wrqu, extra );
|
2015-01-29 21:27:28 +00:00
|
|
|
} else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "wfd_sa", 6 ) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_get_peer_wfd_session_available( dev, info, wrqu, extra );
|
2015-01-29 21:27:28 +00:00
|
|
|
} else if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "wfd_pc", 6 ) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_p2p_get_peer_wfd_preferred_connection( dev, info, wrqu, extra );
|
|
|
|
}
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_p2p_get2(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
|
|
|
|
int length = wrqu->data.length;
|
|
|
|
char *buffer = (u8 *)rtw_malloc(length);
|
|
|
|
|
|
|
|
if (buffer == NULL)
|
|
|
|
{
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_from_user(buffer, wrqu->data.pointer, wrqu->data.length))
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
ret = -EFAULT;
|
2014-12-17 01:03:30 +00:00
|
|
|
goto bad;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_871X("[%s] buffer = %s\n", __FUNCTION__, buffer);
|
|
|
|
|
|
|
|
if (_rtw_memcmp(buffer, "wpsCM=", 6))
|
|
|
|
{
|
|
|
|
ret = rtw_p2p_get_wps_configmethod(dev, info, wrqu, extra, &buffer[6]);
|
|
|
|
} else if (_rtw_memcmp(buffer, "devN=", 5))
|
|
|
|
{
|
|
|
|
ret = rtw_p2p_get_device_name(dev, info, wrqu, extra, &buffer[5]);
|
|
|
|
} else if (_rtw_memcmp(buffer, "dev_type=", 9))
|
|
|
|
{
|
|
|
|
ret = rtw_p2p_get_device_type(dev, info, wrqu, extra, &buffer[9]);
|
|
|
|
} else if (_rtw_memcmp(buffer, "go_devadd=", 10))
|
|
|
|
{
|
|
|
|
ret = rtw_p2p_get_go_device_address(dev, info, wrqu, extra, &buffer[10]);
|
|
|
|
} else if (_rtw_memcmp(buffer, "InvProc=", 8))
|
|
|
|
{
|
|
|
|
ret = rtw_p2p_get_invitation_procedure(dev, info, wrqu, extra, &buffer[8]);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
snprintf(extra, sizeof("Command not found."), "Command not found.");
|
|
|
|
wrqu->data.length = strlen(extra);
|
|
|
|
}
|
|
|
|
|
|
|
|
bad:
|
|
|
|
if (buffer)
|
|
|
|
{
|
|
|
|
rtw_mfree(buffer, length);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_cta_test_start(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s %s\n", __func__, extra);
|
2013-05-08 21:45:39 +00:00
|
|
|
if (!strcmp(extra, "1"))
|
|
|
|
padapter->in_cta_test = 1;
|
|
|
|
else
|
|
|
|
padapter->in_cta_test = 0;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (padapter->in_cta_test)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 v = rtw_read32(padapter, REG_RCR);
|
2015-02-20 04:11:26 +00:00
|
|
|
v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN );/* RCR_ADF */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_write32(padapter, REG_RCR, v);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("enable RCR_ADF\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 v = rtw_read32(padapter, REG_RCR);
|
2015-02-20 04:11:26 +00:00
|
|
|
v |= RCR_CBSSID_DATA | RCR_CBSSID_BCN ;/* RCR_ADF */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_write32(padapter, REG_RCR, v);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("disable RCR_ADF\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
extern int rtw_change_ifname(struct adapter *padapter, const char *ifname);
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_rereg_nd_name(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct rereg_nd_name_data *rereg_priv = &padapter->rereg_nd_name_priv;
|
|
|
|
char new_ifname[IFNAMSIZ];
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rereg_priv->old_ifname[0] == 0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
char *reg_ifname;
|
|
|
|
reg_ifname = padapter->registrypriv.if2name;
|
|
|
|
|
|
|
|
strncpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ);
|
|
|
|
rereg_priv->old_ifname[IFNAMSIZ-1] = 0;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (wrqu->data.length > IFNAMSIZ)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EFAULT;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ) ) {
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EFAULT;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( 0 == strcmp(rereg_priv->old_ifname, new_ifname) ) {
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s new_ifname:%s\n", __FUNCTION__, new_ifname);
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( 0 != (ret = rtw_change_ifname(padapter, new_ifname)) ) {
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_rtw_memcmp(rereg_priv->old_ifname, "disable%d", 9) == true) {
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->ledpriv.bRegUseLed= rereg_priv->old_bRegUseLed;
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_sw_led_init(padapter);
|
2014-12-17 01:03:30 +00:00
|
|
|
/* rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode); */
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ);
|
|
|
|
rereg_priv->old_ifname[IFNAMSIZ-1] = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_rtw_memcmp(new_ifname, "disable%d", 9) == true) {
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s disable\n", __FUNCTION__);
|
2015-02-20 04:11:26 +00:00
|
|
|
/* free network queue for Android's timming issue */
|
2014-12-29 02:13:24 +00:00
|
|
|
rtw_free_network_queue(padapter, true);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* close led */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_led_control(padapter, LED_CTL_POWER_OFF);
|
|
|
|
rereg_priv->old_bRegUseLed = padapter->ledpriv.bRegUseLed;
|
2014-12-29 02:13:24 +00:00
|
|
|
padapter->ledpriv.bRegUseLed= false;
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_sw_led_deinit(padapter);
|
|
|
|
}
|
|
|
|
exit:
|
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void mac_reg_dump(struct adapter *padapter)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
int i,j=1;
|
2014-12-17 01:03:30 +00:00
|
|
|
printk("\n======= MAC REG =======\n");
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0x0;i<0x300;i+=4)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (j%4==1) printk("0x%02x",i);
|
2014-12-19 06:59:46 +00:00
|
|
|
printk(" 0x%08x ",rtw_read32(padapter,i));
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((j++)%4 == 0) printk("\n");
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0x400;i<0x800;i+=4)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (j%4==1) printk("0x%02x",i);
|
2014-12-19 06:59:46 +00:00
|
|
|
printk(" 0x%08x ",rtw_read32(padapter,i));
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((j++)%4 == 0) printk("\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 19:49:35 +00:00
|
|
|
|
|
|
|
static void bb_reg_dump(struct adapter *padapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
int i,j=1;
|
2014-12-17 01:03:30 +00:00
|
|
|
printk("\n======= BB REG =======\n");
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0x800;i<0x1000;i+=4)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (j%4==1) printk("0x%02x",i);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
printk(" 0x%08x ",rtw_read32(padapter,i));
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((j++)%4 == 0) printk("\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 19:49:35 +00:00
|
|
|
|
|
|
|
static void rf_reg_dump(struct adapter *padapter)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int i,j=1,path;
|
2014-12-19 06:59:46 +00:00
|
|
|
u32 value;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 rf_type,path_nums = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
printk("\n======= RF REG =======\n");
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((RF_1T2R == rf_type) ||(RF_1T1R ==rf_type ))
|
2013-05-08 21:45:39 +00:00
|
|
|
path_nums = 1;
|
2014-12-19 06:59:46 +00:00
|
|
|
else
|
2013-05-08 21:45:39 +00:00
|
|
|
path_nums = 2;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (path=0;path<path_nums;path++)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
printk("\nRF_Path(%x)\n",path);
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0;i<0x100;i++)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* value = PHY_QueryRFReg(padapter, (RF_RADIO_PATH_E)path,i, bMaskDWord); */
|
2013-05-08 21:45:39 +00:00
|
|
|
value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (j%4==1) printk("0x%02x ",i);
|
2014-12-17 01:03:30 +00:00
|
|
|
printk(" 0x%08x ",value);
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((j++)%4== 0) printk("\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_dbg_port(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = 0;
|
|
|
|
u8 major_cmd, minor_cmd;
|
|
|
|
u16 arg;
|
2014-12-17 01:03:30 +00:00
|
|
|
u32 extra_arg, *pdata, val32;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct sta_info *psta;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
|
|
|
struct wlan_network *cur_network = &(pmlmepriv->cur_network);
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
pdata = (u32*)&wrqu->data;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
val32 = *pdata;
|
2014-12-17 01:03:30 +00:00
|
|
|
arg = (u16)(val32&0x0000ffff);
|
|
|
|
major_cmd = (u8)(val32>>24);
|
|
|
|
minor_cmd = (u8)((val32>>16)&0x00ff);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
extra_arg = *(pdata+1);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (major_cmd)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x70:/* read_reg */
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (minor_cmd)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
DBG_871X("rtw_read8(0x%x)=0x%02x\n", arg, rtw_read8(padapter, arg));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
DBG_871X("rtw_read16(0x%x)=0x%04x\n", arg, rtw_read16(padapter, arg));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
DBG_871X("rtw_read32(0x%x)=0x%08x\n", arg, rtw_read32(padapter, arg));
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-08-10 16:56:55 +00:00
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x71:/* write_reg */
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (minor_cmd)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
rtw_write8(padapter, arg, extra_arg);
|
|
|
|
DBG_871X("rtw_write8(0x%x)=0x%02x\n", arg, rtw_read8(padapter, arg));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
rtw_write16(padapter, arg, extra_arg);
|
|
|
|
DBG_871X("rtw_write16(0x%x)=0x%04x\n", arg, rtw_read16(padapter, arg));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
rtw_write32(padapter, arg, extra_arg);
|
|
|
|
DBG_871X("rtw_write32(0x%x)=0x%08x\n", arg, rtw_read32(padapter, arg));
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-08-10 16:56:55 +00:00
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x72:/* read_bb */
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("read_bbreg(0x%x)=0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff));
|
2013-08-10 16:56:55 +00:00
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x73:/* write_bb */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_hal_write_bbreg(padapter, arg, 0xffffffff, extra_arg);
|
|
|
|
DBG_871X("write_bbreg(0x%x)=0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff));
|
2013-08-10 16:56:55 +00:00
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x74:/* read_rf */
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("read RF_reg path(0x%02x),offset(0x%x),value(0x%08x)\n",minor_cmd,arg,rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff));
|
2013-08-10 16:56:55 +00:00
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x75:/* write_rf */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_hal_write_rfreg(padapter, minor_cmd, arg, 0xffffffff, extra_arg);
|
|
|
|
DBG_871X("write RF_reg path(0x%02x),offset(0x%x),value(0x%08x)\n",minor_cmd,arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff));
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case 0x76:
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (minor_cmd) {
|
2015-03-10 16:18:03 +00:00
|
|
|
case 0x00: /* normal mode, */
|
|
|
|
padapter->recvpriv.is_signal_dbg = 0;
|
|
|
|
break;
|
|
|
|
case 0x01: /* dbg mode */
|
|
|
|
padapter->recvpriv.is_signal_dbg = 1;
|
|
|
|
extra_arg = extra_arg > 100 ? 100 : extra_arg;
|
|
|
|
padapter->recvpriv.signal_strength_dbg=extra_arg;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x78: /* IOL test */
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (minor_cmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x04: /* LLT table initialization test */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u8 page_boundary = 0xf9;
|
|
|
|
{
|
|
|
|
struct xmit_frame *xmit_frame;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((xmit_frame=rtw_IOL_accquire_xmit_frame(padapter)) == NULL) {
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = -ENOMEM;
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_IOL_append_LLT_cmd(xmit_frame, page_boundary);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 500,0) )
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -EPERM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x05: /* blink LED test */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u16 reg = 0x4c;
|
|
|
|
u32 blink_num = 50;
|
|
|
|
u32 blink_delay_ms = 200;
|
|
|
|
int i;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
struct xmit_frame *xmit_frame;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((xmit_frame=rtw_IOL_accquire_xmit_frame(padapter)) == NULL) {
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = -ENOMEM;
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
for (i=0;i<blink_num;i++) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x00,0xff);
|
|
|
|
rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms);
|
|
|
|
rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x08,0xff);
|
|
|
|
rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, (blink_delay_ms*blink_num*2)+200,0) )
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -EPERM;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x06: /* continuous wirte byte test */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u16 reg = arg;
|
|
|
|
u16 start_value = 0;
|
|
|
|
u32 write_num = extra_arg;
|
|
|
|
int i;
|
|
|
|
u8 final;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
struct xmit_frame *xmit_frame;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((xmit_frame=rtw_IOL_accquire_xmit_frame(padapter)) == NULL) {
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = -ENOMEM;
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
for (i=0;i<write_num;i++) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_IOL_append_WB_cmd(xmit_frame, reg, i+start_value,0xFF);
|
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000,0))
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -EPERM;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (start_value+write_num-1 == (final=rtw_read8(padapter, reg)) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("continuous IOL_CMD_WB_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final);
|
|
|
|
} else {
|
|
|
|
DBG_871X("continuous IOL_CMD_WB_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x07: /* continuous wirte word test */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u16 reg = arg;
|
|
|
|
u16 start_value = 200;
|
|
|
|
u32 write_num = extra_arg;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
int i;
|
|
|
|
u16 final;
|
|
|
|
|
|
|
|
{
|
|
|
|
struct xmit_frame *xmit_frame;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((xmit_frame=rtw_IOL_accquire_xmit_frame(padapter)) == NULL) {
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = -ENOMEM;
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
for (i=0;i<write_num;i++) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_IOL_append_WW_cmd(xmit_frame, reg, i+start_value,0xFFFF);
|
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_SUCCESS !=rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000,0))
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -EPERM;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (start_value+write_num-1 == (final=rtw_read16(padapter, reg)) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("continuous IOL_CMD_WW_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final);
|
|
|
|
} else {
|
|
|
|
DBG_871X("continuous IOL_CMD_WW_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x08: /* continuous wirte dword test */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u16 reg = arg;
|
|
|
|
u32 start_value = 0x110000c7;
|
|
|
|
u32 write_num = extra_arg;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
int i;
|
|
|
|
u32 final;
|
|
|
|
|
|
|
|
{
|
|
|
|
struct xmit_frame *xmit_frame;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((xmit_frame=rtw_IOL_accquire_xmit_frame(padapter)) == NULL) {
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = -ENOMEM;
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
for (i=0;i<write_num;i++) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_IOL_append_WD_cmd(xmit_frame, reg, i+start_value,0xFFFFFFFF);
|
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
if (_SUCCESS !=rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000,0))
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = -EPERM;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (start_value+write_num-1 == (final=rtw_read32(padapter, reg)) ) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("continuous IOL_CMD_WD_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final);
|
|
|
|
} else {
|
|
|
|
DBG_871X("continuous IOL_CMD_WD_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final);
|
|
|
|
}
|
2013-08-10 16:56:55 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2013-08-10 16:56:55 +00:00
|
|
|
}
|
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case 0x79:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* dbg 0x79000000 [value], set RESP_TXAGC to + value, value:0~15
|
|
|
|
* dbg 0x79010000 [value], set RESP_TXAGC to - value, value:0~15
|
|
|
|
*/
|
|
|
|
u8 value = extra_arg & 0x0f;
|
|
|
|
u8 sign = minor_cmd;
|
|
|
|
u16 write_value = 0;
|
|
|
|
|
|
|
|
DBG_871X("%s set RESP_TXAGC to %s %u\n", __func__, sign?"minus":"plus", value);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (sign)
|
|
|
|
value = value | 0x10;
|
|
|
|
|
|
|
|
write_value = value | (value << 5);
|
|
|
|
rtw_write16(padapter, 0x6d9, write_value);
|
|
|
|
}
|
2013-08-10 16:56:55 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case 0x7a:
|
|
|
|
receive_disconnect(padapter, pmlmeinfo->network.MacAddress
|
|
|
|
, WLAN_REASON_EXPIRATION_CHK);
|
2013-08-10 16:56:55 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case 0x7F:
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (minor_cmd)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
case 0x0:
|
|
|
|
DBG_871X("fwstate=0x%x\n", get_fwstate(pmlmepriv));
|
|
|
|
break;
|
|
|
|
case 0x01:
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("auth_alg=0x%x, enc_alg=0x%x, auth_type=0x%x, enc_type=0x%x\n",
|
2014-12-17 01:03:30 +00:00
|
|
|
psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm,
|
|
|
|
psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus);
|
|
|
|
break;
|
|
|
|
case 0x02:
|
|
|
|
DBG_871X("pmlmeinfo->state=0x%x\n", pmlmeinfo->state);
|
|
|
|
break;
|
|
|
|
case 0x03:
|
|
|
|
DBG_871X("qos_option=%d\n", pmlmepriv->qospriv.qos_option);
|
|
|
|
DBG_871X("ht_option=%d\n", pmlmepriv->htpriv.ht_option);
|
|
|
|
break;
|
|
|
|
case 0x04:
|
|
|
|
DBG_871X("cur_ch=%d\n", pmlmeext->cur_channel);
|
|
|
|
DBG_871X("cur_bw=%d\n", pmlmeext->cur_bwmode);
|
|
|
|
DBG_871X("cur_ch_off=%d\n", pmlmeext->cur_ch_offset);
|
|
|
|
break;
|
|
|
|
case 0x05:
|
|
|
|
psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (psta)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct recv_reorder_ctrl *preorder_ctrl;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("SSID=%s\n", cur_network->network.Ssid.Ssid);
|
|
|
|
DBG_871X("sta's macaddr:" MAC_FMT "\n", MAC_ARG(psta->hwaddr));
|
|
|
|
DBG_871X("cur_channel=%d, cur_bwmode=%d, cur_ch_offset=%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset);
|
|
|
|
DBG_871X("rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self);
|
|
|
|
DBG_871X("state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid);
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate);
|
|
|
|
DBG_871X("bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi);
|
|
|
|
DBG_871X("ampdu_enable = %d\n", psta->htpriv.ampdu_enable);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0;i<16;i++)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
preorder_ctrl = &psta->recvreorder_ctrl[i];
|
2015-08-15 18:02:34 +00:00
|
|
|
if (preorder_ctrl->enable)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("tid=%d, indicate_seq=%d\n", i, preorder_ctrl->indicate_seq);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("can't get sta's macaddr, cur_network's macaddr:" MAC_FMT "\n", MAC_ARG(cur_network->network.MacAddress));
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
case 0x06:
|
|
|
|
{
|
|
|
|
u32 ODMFlag;
|
|
|
|
rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8*)(&ODMFlag));
|
|
|
|
DBG_871X("(B)DMFlag=0x%x, arg=0x%x\n", ODMFlag, arg);
|
|
|
|
ODMFlag = (u32)(0x0f&arg);
|
|
|
|
DBG_871X("(A)DMFlag=0x%x\n", ODMFlag);
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x07:
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("bSurpriseRemoved=%d, bDriverStopped=%d\n",
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->bSurpriseRemoved, padapter->bDriverStopped);
|
|
|
|
break;
|
|
|
|
case 0x08:
|
|
|
|
{
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct recv_priv *precvpriv = &padapter->recvpriv;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("free_xmitbuf_cnt=%d, free_xmitframe_cnt=%d"
|
|
|
|
", free_xmit_extbuf_cnt=%d, free_xframe_ext_cnt=%d"
|
|
|
|
", free_recvframe_cnt=%d\n",
|
|
|
|
pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt,
|
|
|
|
pxmitpriv->free_xmit_extbuf_cnt, pxmitpriv->free_xframe_ext_cnt,
|
|
|
|
precvpriv->free_recvframe_cnt);
|
|
|
|
DBG_871X("rx_urb_pending_cn=%d\n", precvpriv->rx_pending_cnt);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
case 0x09:
|
|
|
|
{
|
|
|
|
int i, j;
|
2015-03-16 13:54:18 +00:00
|
|
|
struct list_head *plist, *phead;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct recv_reorder_ctrl *preorder_ctrl;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_AP_MODE
|
|
|
|
DBG_871X("sta_dz_bitmap=0x%x, tim_bitmap=0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap);
|
2014-12-19 06:59:46 +00:00
|
|
|
#endif
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pstapriv->sta_hash_lock);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0; i< NUM_STA; i++)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
phead = &(pstapriv->sta_hash[i]);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
while ((rtw_end_of_queue_search(phead, plist)) == false)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
|
|
|
|
|
|
|
|
plist = get_next(plist);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (extra_arg == psta->aid)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("sta's macaddr:" MAC_FMT "\n", MAC_ARG(psta->hwaddr));
|
|
|
|
DBG_871X("rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self);
|
|
|
|
DBG_871X("state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid);
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate);
|
|
|
|
DBG_871X("bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi);
|
|
|
|
DBG_871X("ampdu_enable = %d\n", psta->htpriv.ampdu_enable);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_AP_MODE
|
|
|
|
DBG_871X("capability=0x%x\n", psta->capability);
|
|
|
|
DBG_871X("flags=0x%x\n", psta->flags);
|
|
|
|
DBG_871X("wpa_psk=0x%x\n", psta->wpa_psk);
|
|
|
|
DBG_871X("wpa2_group_cipher=0x%x\n", psta->wpa2_group_cipher);
|
|
|
|
DBG_871X("wpa2_pairwise_cipher=0x%x\n", psta->wpa2_pairwise_cipher);
|
|
|
|
DBG_871X("qos_info=0x%x\n", psta->qos_info);
|
|
|
|
#endif
|
|
|
|
DBG_871X("dot118021XPrivacy=0x%x\n", psta->dot118021XPrivacy);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (j=0;j<16;j++)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
preorder_ctrl = &psta->recvreorder_ctrl[j];
|
2015-08-15 18:02:34 +00:00
|
|
|
if (preorder_ctrl->enable)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("tid=%d, indicate_seq=%d\n", j, preorder_ctrl->indicate_seq);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pstapriv->sta_hash_lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0a:
|
|
|
|
{
|
|
|
|
#ifdef DBG_TRX_STA_PKTS
|
|
|
|
int i, j;
|
2015-03-16 13:54:18 +00:00
|
|
|
struct list_head *plist, *phead;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pstapriv->sta_hash_lock);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:06:32 +00:00
|
|
|
for (i=0; i< NUM_STA; i++)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
phead = &(pstapriv->sta_hash[i]);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
while ((rtw_end_of_queue_search(phead, plist)) == false)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
|
|
|
|
|
|
|
|
plist = get_next(plist);
|
2015-08-15 18:24:16 +00:00
|
|
|
if (arg == 0xff) {
|
2014-12-17 01:03:30 +00:00
|
|
|
psta->rx_bk_cnt =0;
|
|
|
|
psta->rx_be_cnt =0;
|
|
|
|
psta->rx_vo_cnt =0;
|
|
|
|
psta->rx_vi_cnt =0;
|
|
|
|
psta->tx_bk_cnt =0;
|
|
|
|
psta->tx_be_cnt =0;
|
|
|
|
psta->tx_vo_cnt =0;
|
2014-12-19 06:59:46 +00:00
|
|
|
psta->tx_vi_cnt =0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:27:00 +00:00
|
|
|
else {
|
2015-08-15 18:02:34 +00:00
|
|
|
if (extra_arg == psta->mac_id)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("=== sta's macaddr:" MAC_FMT "===\n", MAC_ARG(psta->hwaddr));
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rx_bk_cnt =%d\n", psta->rx_bk_cnt);
|
|
|
|
DBG_871X("rx_be_cnt =%d\n", psta->rx_be_cnt);
|
|
|
|
DBG_871X("rx_vo_cnt =%d\n", psta->rx_vo_cnt);
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("rx_vi_cnt =%d\n\n", psta->rx_vi_cnt);
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("tx_bk_cnt =%d\n", psta->tx_bk_cnt);
|
|
|
|
DBG_871X("tx_be_cnt =%d\n", psta->tx_be_cnt);
|
|
|
|
DBG_871X("tx_vo_cnt =%d\n", psta->tx_vo_cnt);
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("tx_vi_cnt =%dn\n", psta->tx_vi_cnt);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pstapriv->sta_hash_lock);
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x0c:/* dump rx/tx packet */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:24:16 +00:00
|
|
|
if (arg == 0) {
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("dump rx packet (%d)\n",extra_arg);
|
2015-02-20 04:11:26 +00:00
|
|
|
/* pHalData->bDumpRxPkt =extra_arg; */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg));
|
|
|
|
}
|
2015-08-15 18:24:16 +00:00
|
|
|
else if (arg==1) {
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("dump tx packet (%d)\n",extra_arg);
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0f:
|
|
|
|
{
|
2015-08-15 18:24:16 +00:00
|
|
|
if (extra_arg == 0) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("###### silent reset test.......#####\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_hal_sreset_reset(padapter);
|
2014-12-17 01:03:30 +00:00
|
|
|
} else {
|
|
|
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter);
|
|
|
|
struct sreset_priv *psrtpriv = &pHalData->srestpriv;
|
|
|
|
psrtpriv->dbg_trigger_point = extra_arg;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x15:
|
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
|
|
|
|
DBG_871X("==>silent resete cnts:%d\n",pwrpriv->ips_enter_cnts);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x10:/* driver version display */
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw driver version=%s\n", DRIVERVERSION);
|
|
|
|
break;
|
|
|
|
case 0x11:
|
2015-03-12 01:21:04 +00:00
|
|
|
DBG_871X("turn %s Rx RSSI display function\n",(extra_arg==1)?"on":"off");
|
|
|
|
padapter->bRxRSSIDisplay = extra_arg;
|
|
|
|
rtw_hal_set_def_var(padapter, HW_DEF_FA_CNT_DUMP, &(padapter->bRxRSSIDisplay));
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x12: /* set rx_stbc */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
struct registry_priv *pregpriv = &padapter->registrypriv;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */
|
|
|
|
/* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( pregpriv && (extra_arg == 0 || extra_arg == 1|| extra_arg == 2 || extra_arg == 3))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pregpriv->rx_stbc= extra_arg;
|
|
|
|
DBG_871X("set rx_stbc=%d\n",pregpriv->rx_stbc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DBG_871X("get rx_stbc=%d\n",pregpriv->rx_stbc);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x13: /* set ampdu_enable */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
struct registry_priv *pregpriv = &padapter->registrypriv;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( pregpriv && extra_arg >= 0 && extra_arg < 3 )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
pregpriv->ampdu_enable= extra_arg;
|
|
|
|
DBG_871X("set ampdu_enable=%d\n",pregpriv->ampdu_enable);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DBG_871X("get ampdu_enable=%d\n",pregpriv->ampdu_enable);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0x14: /* get wifi_spec */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
struct registry_priv *pregpriv = &padapter->registrypriv;
|
|
|
|
DBG_871X("get wifi_spec=%d\n",pregpriv->wifi_spec);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x16:
|
|
|
|
{
|
2015-08-15 18:24:16 +00:00
|
|
|
if (arg == 0xff) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_odm_dbg_comp_msg(padapter);
|
|
|
|
}
|
2015-08-15 18:27:00 +00:00
|
|
|
else {
|
2014-12-17 01:03:30 +00:00
|
|
|
u64 dbg_comp = (u64)extra_arg;
|
|
|
|
rtw_odm_dbg_comp_set(padapter, dbg_comp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#ifdef DBG_FIXED_CHAN
|
|
|
|
case 0x17:
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
|
2015-08-15 18:00:19 +00:00
|
|
|
printk("===> Fixed channel to %d\n",extra_arg);
|
2014-12-19 06:59:46 +00:00
|
|
|
pmlmeext->fixed_chan = extra_arg;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case 0x20:
|
|
|
|
{
|
|
|
|
rtw_hal_get_hwreg(padapter, HW_VAR_READ_LLT_TAB,(u8 *)&extra_arg);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
case 0x23:
|
|
|
|
{
|
|
|
|
DBG_871X("turn %s the bNotifyChannelChange Variable\n",(extra_arg==1)?"on":"off");
|
|
|
|
padapter->bNotifyChannelChange = extra_arg;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 0x24:
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_P2P
|
|
|
|
DBG_871X("turn %s the bShowGetP2PState Variable\n",(extra_arg==1)?"on":"off");
|
|
|
|
padapter->bShowGetP2PState = extra_arg;
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
case 0xaa:
|
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (extra_arg> 0x13) extra_arg = 0xFF;
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("chang data rate to :0x%02x\n",extra_arg);
|
|
|
|
padapter->fix_rate = extra_arg;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0xdd:/* registers dump , 0 for mac reg,1 for bb reg, 2 for rf reg */
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-08-15 18:24:16 +00:00
|
|
|
if (extra_arg== 0) {
|
2014-12-17 01:03:30 +00:00
|
|
|
mac_reg_dump(padapter);
|
|
|
|
}
|
2015-08-15 18:24:16 +00:00
|
|
|
else if (extra_arg==1) {
|
2014-12-17 01:03:30 +00:00
|
|
|
bb_reg_dump(padapter);
|
|
|
|
}
|
2015-08-15 18:24:16 +00:00
|
|
|
else if (extra_arg==2) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rf_reg_dump(padapter);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
case 0xee:/* turn on/off dynamic funcs */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u32 odm_flag;
|
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (0xf==extra_arg) {
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC,&odm_flag);
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X(" === DMFlag(0x%08x) ===\n",odm_flag);
|
|
|
|
DBG_871X("extra_arg = 0 - disable all dynamic func\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("extra_arg = 1 - disable DIG- BIT(0)\n");
|
|
|
|
DBG_871X("extra_arg = 2 - disable High power - BIT(1)\n");
|
|
|
|
DBG_871X("extra_arg = 3 - disable tx power tracking - BIT(2)\n");
|
|
|
|
DBG_871X("extra_arg = 4 - disable BT coexistence - BIT(3)\n");
|
|
|
|
DBG_871X("extra_arg = 5 - disable antenna diversity - BIT(4)\n");
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X("extra_arg = 6 - enable all dynamic func\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:27:00 +00:00
|
|
|
else {
|
2014-12-17 01:03:30 +00:00
|
|
|
/* extra_arg = 0 - disable all dynamic func
|
|
|
|
extra_arg = 1 - disable DIG
|
|
|
|
extra_arg = 2 - disable tx power tracking
|
|
|
|
extra_arg = 3 - turn on all dynamic func
|
2014-12-19 06:59:46 +00:00
|
|
|
*/
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &(extra_arg));
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC,&odm_flag);
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X(" === DMFlag(0x%08x) ===\n",odm_flag);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
case 0xfd:
|
|
|
|
rtw_write8(padapter, 0xc50, arg);
|
|
|
|
DBG_871X("wr(0xc50)=0x%x\n", rtw_read8(padapter, 0xc50));
|
|
|
|
rtw_write8(padapter, 0xc58, arg);
|
|
|
|
DBG_871X("wr(0xc58)=0x%x\n", rtw_read8(padapter, 0xc58));
|
|
|
|
break;
|
|
|
|
case 0xfe:
|
|
|
|
DBG_871X("rd(0xc50)=0x%x\n", rtw_read8(padapter, 0xc50));
|
|
|
|
DBG_871X("rd(0xc58)=0x%x\n", rtw_read8(padapter, 0xc58));
|
|
|
|
break;
|
|
|
|
case 0xff:
|
|
|
|
{
|
|
|
|
DBG_871X("dbg(0x210)=0x%x\n", rtw_read32(padapter, 0x210));
|
|
|
|
DBG_871X("dbg(0x608)=0x%x\n", rtw_read32(padapter, 0x608));
|
|
|
|
DBG_871X("dbg(0x280)=0x%x\n", rtw_read32(padapter, 0x280));
|
|
|
|
DBG_871X("dbg(0x284)=0x%x\n", rtw_read32(padapter, 0x284));
|
|
|
|
DBG_871X("dbg(0x288)=0x%x\n", rtw_read32(padapter, 0x288));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("dbg(0x664)=0x%x\n", rtw_read32(padapter, 0x664));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("dbg(0x430)=0x%x\n", rtw_read32(padapter, 0x430));
|
|
|
|
DBG_871X("dbg(0x438)=0x%x\n", rtw_read32(padapter, 0x438));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("dbg(0x440)=0x%x\n", rtw_read32(padapter, 0x440));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("dbg(0x458)=0x%x\n", rtw_read32(padapter, 0x458));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("dbg(0x484)=0x%x\n", rtw_read32(padapter, 0x484));
|
|
|
|
DBG_871X("dbg(0x488)=0x%x\n", rtw_read32(padapter, 0x488));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("dbg(0x444)=0x%x\n", rtw_read32(padapter, 0x444));
|
|
|
|
DBG_871X("dbg(0x448)=0x%x\n", rtw_read32(padapter, 0x448));
|
|
|
|
DBG_871X("dbg(0x44c)=0x%x\n", rtw_read32(padapter, 0x44c));
|
|
|
|
DBG_871X("dbg(0x450)=0x%x\n", rtw_read32(padapter, 0x450));
|
|
|
|
}
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
default:
|
|
|
|
DBG_871X("error dbg cmd!\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
uint ret=0;
|
|
|
|
u32 flags;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
switch (name) {
|
2013-05-08 21:45:39 +00:00
|
|
|
case IEEE_PARAM_WPA_ENABLED:
|
2015-02-20 04:11:26 +00:00
|
|
|
padapter->securitypriv.dot11AuthAlgrthm= dot11AuthAlgrthm_8021X; /* 802.1x */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch ((value)&0xff) {
|
2015-03-10 16:18:03 +00:00
|
|
|
case 1 : /* WPA */
|
2015-02-20 04:11:26 +00:00
|
|
|
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled;
|
2015-03-10 16:18:03 +00:00
|
|
|
break;
|
|
|
|
case 2: /* WPA2 */
|
2015-02-20 04:11:26 +00:00
|
|
|
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; /* WPA2_PSK */
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled;
|
2015-03-10 16:18:03 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
RT_TRACE(_module_rtl871x_ioctl_os_c,_drv_info_,("wpa_set_param:padapter->securitypriv.ndisauthtype=%d\n", padapter->securitypriv.ndisauthtype));
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
case IEEE_PARAM_TKIP_COUNTERMEASURES:
|
2015-02-20 04:11:26 +00:00
|
|
|
/* ieee->tkip_countermeasures=value; */
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
case IEEE_PARAM_DROP_UNENCRYPTED:
|
2013-05-08 21:45:39 +00:00
|
|
|
/* HACK:
|
|
|
|
*
|
|
|
|
* wpa_supplicant calls set_wpa_enabled when the driver
|
|
|
|
* is loaded and unloaded, regardless of if WPA is being
|
|
|
|
* used. No other calls are made which can be used to
|
|
|
|
* determine if encryption will be used or not prior to
|
|
|
|
* association being expected. If encryption is not being
|
|
|
|
* used, drop_unencrypted is set to false, else true -- we
|
|
|
|
* can use this to determine if the CAP_PRIVACY_ON bit should
|
|
|
|
* be set.
|
|
|
|
*/
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
case IEEE_PARAM_PRIVACY_INVOKED:
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
case IEEE_PARAM_AUTH_ALGS:
|
|
|
|
ret = wpa_set_auth_algs(dev, value);
|
|
|
|
break;
|
|
|
|
case IEEE_PARAM_IEEE_802_1X:
|
|
|
|
break;
|
|
|
|
case IEEE_PARAM_WPAX_SELECT:
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
default:
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wpa_mlme(struct net_device *dev, u32 command, u32 reason)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
switch (command)
|
|
|
|
{
|
|
|
|
case IEEE_MLME_STA_DEAUTH:
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!rtw_set_802_11_disassociate(padapter))
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = -1;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IEEE_MLME_STA_DISASSOC:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!rtw_set_802_11_disassociate(padapter))
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = -1;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p)
|
|
|
|
{
|
|
|
|
struct ieee_param *param;
|
2014-12-17 01:03:30 +00:00
|
|
|
uint ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* down(&ieee->wx_sem); */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (p->length < sizeof(struct ieee_param) || !p->pointer) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
param = (struct ieee_param *)rtw_malloc(p->length);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (param == NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (copy_from_user(param, p->pointer, p->length))
|
|
|
|
{
|
|
|
|
rtw_mfree((u8*)param, p->length);
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EFAULT;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (param->cmd) {
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
case IEEE_CMD_SET_WPA_PARAM:
|
|
|
|
ret = wpa_set_param(dev, param->u.wpa_param.name, param->u.wpa_param.value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEEE_CMD_SET_WPA_IE:
|
2015-02-20 04:11:26 +00:00
|
|
|
/* ret = wpa_set_wpa_ie(dev, param, p->length); */
|
2014-12-17 23:13:53 +00:00
|
|
|
ret = rtw_set_wpa_ie((struct adapter *)rtw_netdev_priv(dev), (char*)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len);
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IEEE_CMD_SET_ENCRYPTION:
|
|
|
|
ret = wpa_set_encryption(dev, param, p->length);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEEE_CMD_MLME:
|
|
|
|
ret = wpa_mlme(dev, param->u.mlme.command, param->u.mlme.reason_code);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("Unknown WPA supplicant request: %d\n", param->cmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret == 0 && copy_to_user(p->pointer, param, p->length))
|
|
|
|
ret = -EFAULT;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_mfree((u8 *)param, p->length);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
out:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* up(&ieee->wx_sem); */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_AP_MODE
|
2014-12-17 23:13:53 +00:00
|
|
|
static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
struct cmd_obj* ph2c;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct set_stakey_parm *psetstakey_para;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct cmd_priv *pcmdpriv=&padapter->cmdpriv;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 res=_SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj));
|
2015-08-15 18:24:16 +00:00
|
|
|
if ( ph2c == NULL) {
|
2014-12-17 01:03:30 +00:00
|
|
|
res= _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
psetstakey_para = (struct set_stakey_parm*)rtw_zmalloc(sizeof(struct set_stakey_parm));
|
2015-08-15 18:24:16 +00:00
|
|
|
if (psetstakey_para== NULL) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_mfree((u8 *) ph2c, sizeof(struct cmd_obj));
|
|
|
|
res=_FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
|
|
|
|
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
psetstakey_para->algorithm = (u8)psta->dot118021XPrivacy;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psetstakey_para->key, &psta->dot118021x_UncstKey, 16);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 keylen;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct cmd_obj* pcmd;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct setkey_parm *psetkeyparm;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct cmd_priv *pcmdpriv=&(padapter->cmdpriv);
|
2014-12-17 01:03:30 +00:00
|
|
|
int res=_SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pcmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj));
|
2015-08-15 18:24:16 +00:00
|
|
|
if (pcmd== NULL) {
|
2014-12-17 01:03:30 +00:00
|
|
|
res= _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
psetkeyparm=(struct setkey_parm*)rtw_zmalloc(sizeof(struct setkey_parm));
|
2015-08-15 18:24:16 +00:00
|
|
|
if (psetkeyparm== NULL) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_mfree((unsigned char *)pcmd, sizeof(struct cmd_obj));
|
|
|
|
res= _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(psetkeyparm, 0, sizeof(struct setkey_parm));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
psetkeyparm->keyid=(u8)keyid;
|
|
|
|
if (is_wep_enc(alg))
|
|
|
|
padapter->securitypriv.key_mask |= BIT(psetkeyparm->keyid);
|
2013-05-08 21:45:39 +00:00
|
|
|
psetkeyparm->algorithm = alg;
|
|
|
|
|
|
|
|
psetkeyparm->set_tx = 1;
|
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (alg)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
case _WEP40_:
|
2014-12-17 01:03:30 +00:00
|
|
|
keylen = 5;
|
|
|
|
break;
|
|
|
|
case _WEP104_:
|
2014-12-19 06:59:46 +00:00
|
|
|
keylen = 13;
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
case _TKIP_:
|
2014-12-19 06:59:46 +00:00
|
|
|
case _TKIP_WTMIC_:
|
2014-12-17 01:03:30 +00:00
|
|
|
case _AES_:
|
|
|
|
default:
|
2014-12-19 06:59:46 +00:00
|
|
|
keylen = 16;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&(psetkeyparm->key[0]), key, keylen);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmd->cmdcode = _SetKey_CMD_;
|
2014-12-19 06:59:46 +00:00
|
|
|
pcmd->parmbuf = (u8 *)psetkeyparm;
|
|
|
|
pcmd->cmdsz = (sizeof(struct setkey_parm));
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmd->rsp = NULL;
|
|
|
|
pcmd->rspsz = 0;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_listhead(&pcmd->list);
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, pcmd);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static int set_wep_key(struct adapter *padapter, u8 *key, u8 keylen, int keyid)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 alg;
|
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (keylen)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
case 5:
|
2014-12-19 06:59:46 +00:00
|
|
|
alg =_WEP40_;
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
case 13:
|
2014-12-19 06:59:46 +00:00
|
|
|
alg =_WEP104_;
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-12-19 06:59:46 +00:00
|
|
|
alg =_NO_PRIVACY_;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return set_group_key(padapter, key, alg, keyid);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u32 wep_key_idx, wep_key_len,wep_total_len;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_wep *pwep = NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct sta_info *psta = NULL, *pbcmc_sta = NULL;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct security_priv* psecuritypriv=&(padapter->securitypriv);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s\n", __FUNCTION__);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
param->u.crypt.err = 0;
|
|
|
|
param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0';
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* sizeof(struct ieee_param) = 64 bytes; */
|
|
|
|
/* if (param_len != (u32) ((u8 *) param->u.crypt.key - (u8 *) param) + param->u.crypt.key_len) */
|
2014-12-17 01:03:30 +00:00
|
|
|
if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
|
|
|
|
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
|
2014-12-19 06:59:46 +00:00
|
|
|
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
if (param->u.crypt.idx >= WEP_KEYS)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!psta)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* ret = -EINVAL; */
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw_set_encryption(), sta has already been removed or never been added\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "none") == 0 && (psta== NULL))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* todo:clear default encryption keys */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("clear default encryption keys, keyid=%d\n", param->u.crypt.idx);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
|
2015-08-15 18:22:58 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta== NULL))
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("r871x_set_encryption, crypt.alg = WEP\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
wep_key_idx = param->u.crypt.idx;
|
|
|
|
wep_key_len = param->u.crypt.key_len;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("r871x_set_encryption, wep_key_idx=%d, len=%d\n", wep_key_idx, wep_key_len);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((wep_key_idx >= WEP_KEYS) || (wep_key_len<=0))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
if (wep_key_len > 0)
|
|
|
|
{
|
|
|
|
wep_key_len = wep_key_len <= 5 ? 5 : 13;
|
2015-03-14 23:14:05 +00:00
|
|
|
wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial);
|
|
|
|
pwep =(struct ndis_802_11_wep *)rtw_malloc(wep_total_len);
|
2015-08-15 18:24:16 +00:00
|
|
|
if (pwep == NULL) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X(" r871x_set_encryption: pwep allocate fail !!!\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(pwep, 0, wep_total_len);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
pwep->KeyLength = wep_key_len;
|
2013-05-08 21:45:39 +00:00
|
|
|
pwep->Length = wep_total_len;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pwep->KeyIndex = wep_key_idx;
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param->u.crypt.set_tx)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("wep, set_tx=1\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled;
|
2014-12-17 01:03:30 +00:00
|
|
|
psecuritypriv->dot11PrivacyAlgrthm=_WEP40_;
|
|
|
|
psecuritypriv->dot118021XGrpPrivacy=_WEP40_;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
if (pwep->KeyLength==13) {
|
2014-12-17 01:03:30 +00:00
|
|
|
psecuritypriv->dot11PrivacyAlgrthm=_WEP104_;
|
|
|
|
psecuritypriv->dot118021XGrpPrivacy=_WEP104_;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
psecuritypriv->dot11DefKeylen[wep_key_idx]=pwep->KeyLength;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx);
|
2015-03-10 16:18:03 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("wep, set_tx=0\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */
|
|
|
|
/* psecuritypriv->dot11PrivacyKeyIndex=keyid", but can rtw_set_key to cam */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-08-10 16:56:55 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) /* group key */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param->u.crypt.set_tx ==1)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "WEP") == 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s, set group_key, WEP\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param->u.crypt.key_len==13)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, set group_key, TKIP\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DEBUG_ERR("set key length :param->u.crypt.key_len=%d\n", param->u.crypt.key_len); */
|
|
|
|
/* set mic key */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8);
|
|
|
|
memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
psecuritypriv->busetkipkey = true;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (strcmp(param->u.crypt.alg, "CCMP") == 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s, set group_key, CCMP\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _AES_;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X("%s, set group_key, none\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
psecuritypriv->binstallGrpkey = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pbcmc_sta=rtw_get_bcmc_stainfo(padapter);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pbcmc_sta)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pbcmc_sta->ieee8021x_blocked = false;
|
2015-02-20 04:11:26 +00:00
|
|
|
pbcmc_sta->dot118021XPrivacy= psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) /* psk/802_1x */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param->u.crypt.set_tx ==1)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "WEP") == 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s, set pairwise key, WEP\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->dot118021XPrivacy = _WEP40_;
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param->u.crypt.key_len==13)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->dot118021XPrivacy = _WEP104_;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, set pairwise key, TKIP\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->dot118021XPrivacy = _TKIP_;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DEBUG_ERR("set key length :param->u.crypt.key_len=%d\n", param->u.crypt.key_len); */
|
|
|
|
/* set mic key */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8);
|
|
|
|
memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
psecuritypriv->busetkipkey = true;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (strcmp(param->u.crypt.alg, "CCMP") == 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, set pairwise key, CCMP\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->dot118021XPrivacy = _AES_;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X("%s, set pairwise key, none\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->dot118021XPrivacy = _NO_PRIVACY_;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
set_pairwise_key(padapter, psta);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
psta->ieee8021x_blocked = false;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
else/* group key??? */
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if (strcmp(param->u.crypt.alg, "WEP") == 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
|
2015-08-15 18:02:34 +00:00
|
|
|
if (param->u.crypt.key_len==13)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (strcmp(param->u.crypt.alg, "TKIP") == 0)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DEBUG_ERR("set key length :param->u.crypt.key_len=%d\n", param->u.crypt.key_len); */
|
|
|
|
/* set mic key */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8);
|
|
|
|
memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
psecuritypriv->busetkipkey = true;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:02:34 +00:00
|
|
|
else if (strcmp(param->u.crypt.alg, "CCMP") == 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _AES_;
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len>16 ?16:param->u.crypt.key_len));
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
|
|
|
|
}
|
|
|
|
|
|
|
|
psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
psecuritypriv->binstallGrpkey = true;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pbcmc_sta=rtw_get_bcmc_stainfo(padapter);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pbcmc_sta)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pbcmc_sta->ieee8021x_blocked = false;
|
2015-02-20 04:11:26 +00:00
|
|
|
pbcmc_sta->dot118021XPrivacy= psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pwep)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_mfree((u8 *)pwep, wep_total_len);
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret=0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
unsigned char *pbuf = param->u.bcn_ie.buf;
|
|
|
|
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, len=%d\n", __FUNCTION__, len);
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&pstapriv->max_num_sta, param->u.bcn_ie.reserved, 2);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((pstapriv->max_num_sta>NUM_STA) || (pstapriv->max_num_sta<=0))
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv->max_num_sta = NUM_STA;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_check_beacon_data(padapter, pbuf, (len-12-2)) == _SUCCESS)/* 12 = param header, 2:no packed */
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = 0;
|
|
|
|
else
|
|
|
|
ret = -EINVAL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_hostapd_sta_flush(struct net_device *dev)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2015-03-16 13:54:18 +00:00
|
|
|
int ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
flush_all_cam_entry(padapter); /* clear CAM */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = rtw_sta_flush(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_add_sta(struct net_device *dev, struct ieee_param *param)
|
|
|
|
{
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta = NULL;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw_add_sta(aid=%d)=" MAC_FMT "\n", param->u.add_sta.aid, MAC_ARG(param->sta_addr));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
|
|
|
|
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
|
2014-12-19 06:59:46 +00:00
|
|
|
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (psta)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
int flags = param->u.add_sta.flags;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
psta->aid = param->u.add_sta.aid;/* aid=1~2007 */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* check wmm cap. */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (WLAN_STA_WME&flags)
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->qos_option = 1;
|
|
|
|
else
|
|
|
|
psta->qos_option = 0;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmepriv->qospriv.qos_option == 0)
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->qos_option = 0;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* chec 802.11n ht cap. */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (WLAN_STA_HT&flags)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
psta->htpriv.ht_option = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->qos_option = 1;
|
2015-04-08 18:43:40 +00:00
|
|
|
memcpy((void*)&psta->htpriv.ht_cap, (void*)¶m->u.add_sta.ht_cap, sizeof(struct ieee80211_ht_cap));
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
else
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
psta->htpriv.ht_option = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmepriv->htpriv.ht_option == false)
|
2014-12-29 02:13:24 +00:00
|
|
|
psta->htpriv.ht_option = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
update_sta_info_apmode(padapter, psta);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = -ENOMEM;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_del_sta(struct net_device *dev, struct ieee_param *param)
|
|
|
|
{
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta = NULL;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw_del_sta=" MAC_FMT "\n", MAC_ARG(param->sta_addr));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
|
|
|
|
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
|
2014-12-19 06:59:46 +00:00
|
|
|
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (psta)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u8 updated;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pstapriv->asoc_list_lock);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (rtw_is_list_empty(&psta->asoc_list)==false)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_delete(&psta->asoc_list);
|
|
|
|
pstapriv->asoc_list_cnt--;
|
2014-12-29 02:13:24 +00:00
|
|
|
updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2015-08-15 00:35:20 +00:00
|
|
|
spin_unlock_bh(&pstapriv->asoc_list_lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
associated_clients_update(padapter, updated);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X("rtw_del_sta(), sta has already been removed or never been added\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* ret = -1; */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *param, int len)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta = NULL;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param;
|
|
|
|
struct sta_data *psta_data = (struct sta_data *)param_ex->data;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw_ioctl_get_sta_info, sta_addr: " MAC_FMT "\n", MAC_ARG(param_ex->sta_addr));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff &&
|
|
|
|
param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff &&
|
2014-12-19 06:59:46 +00:00
|
|
|
param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (psta)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psta_data->aid = (u16)psta->aid;
|
|
|
|
psta_data->capability = psta->capability;
|
|
|
|
psta_data->flags = psta->flags;
|
2014-12-17 01:03:30 +00:00
|
|
|
psta_data->sta_set =((psta->nonerp_set) |
|
2014-12-29 02:00:11 +00:00
|
|
|
(psta->no_short_slot_time_set <<1) |
|
|
|
|
(psta->no_short_preamble_set <<2) |
|
|
|
|
(psta->no_ht_gf_set <<3) |
|
|
|
|
(psta->no_ht_set <<4) |
|
|
|
|
(psta->ht_20mhz_set <<5));
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta_data->tx_supp_rates_len = psta->bssratelen;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(psta_data->tx_supp_rates, psta->bssrateset, psta->bssratelen);
|
2015-04-08 18:43:40 +00:00
|
|
|
memcpy(&psta_data->ht_cap, &psta->htpriv.ht_cap, sizeof(struct ieee80211_ht_cap));
|
2013-05-08 21:45:39 +00:00
|
|
|
psta_data->rx_pkts = psta->sta_stats.rx_data_pkts;
|
|
|
|
psta_data->rx_bytes = psta->sta_stats.rx_bytes;
|
|
|
|
psta_data->rx_drops = psta->sta_stats.rx_drops;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta_data->tx_pkts = psta->sta_stats.tx_pkts;
|
|
|
|
psta_data->tx_bytes = psta->sta_stats.tx_bytes;
|
|
|
|
psta_data->tx_drops = psta->sta_stats.tx_drops;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
int ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta = NULL;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("rtw_get_sta_wpaie, sta_addr: " MAC_FMT "\n", MAC_ARG(param->sta_addr));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
|
|
|
|
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
|
2014-12-19 06:59:46 +00:00
|
|
|
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
|
2015-08-15 18:02:34 +00:00
|
|
|
if (psta)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
int wpa_ie_len;
|
|
|
|
int copy_len;
|
|
|
|
|
|
|
|
wpa_ie_len = psta->wpa_ie[1];
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
copy_len = ((wpa_ie_len+2) > sizeof(psta->wpa_ie)) ? (sizeof(psta->wpa_ie)):(wpa_ie_len+2);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
param->u.wpa_ie.len = copy_len;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
else
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* ret = -1; */
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("sta's wpa_ie is NONE\n");
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
|
|
|
unsigned char wps_oui[4]={0x0,0x50,0xf2,0x04};
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
2013-05-08 21:45:39 +00:00
|
|
|
int ie_len;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, len=%d\n", __FUNCTION__, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
ie_len = len-12-2;/* 12 = param header, 2:no packed */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmepriv->wps_beacon_ie)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
rtw_mfree(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len);
|
2014-12-19 06:59:46 +00:00
|
|
|
pmlmepriv->wps_beacon_ie = NULL;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ie_len>0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len);
|
|
|
|
pmlmepriv->wps_beacon_ie_len = ie_len;
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( pmlmepriv->wps_beacon_ie == NULL) {
|
|
|
|
DBG_871X("%s()-%d: rtw_malloc() ERROR!\n", __FUNCTION__, __LINE__);
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pmlmepriv->wps_beacon_ie, param->u.bcn_ie.buf, ie_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
pmlmeext->bstart_bss = true;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
int ie_len;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, len=%d\n", __FUNCTION__, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
ie_len = len-12-2;/* 12 = param header, 2:no packed */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmepriv->wps_probe_resp_ie)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
rtw_mfree(pmlmepriv->wps_probe_resp_ie, pmlmepriv->wps_probe_resp_ie_len);
|
2014-12-19 06:59:46 +00:00
|
|
|
pmlmepriv->wps_probe_resp_ie = NULL;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ie_len>0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len);
|
|
|
|
pmlmepriv->wps_probe_resp_ie_len = ie_len;
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( pmlmepriv->wps_probe_resp_ie == NULL) {
|
|
|
|
DBG_871X("%s()-%d: rtw_malloc() ERROR!\n", __FUNCTION__, __LINE__);
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pmlmepriv->wps_probe_resp_ie, param->u.bcn_ie.buf, ie_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
int ie_len;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s, len=%d\n", __FUNCTION__, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
ie_len = len-12-2;/* 12 = param header, 2:no packed */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmepriv->wps_assoc_resp_ie)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
rtw_mfree(pmlmepriv->wps_assoc_resp_ie, pmlmepriv->wps_assoc_resp_ie_len);
|
2014-12-19 06:59:46 +00:00
|
|
|
pmlmepriv->wps_assoc_resp_ie = NULL;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (ie_len>0)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len);
|
|
|
|
pmlmepriv->wps_assoc_resp_ie_len = ie_len;
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( pmlmepriv->wps_assoc_resp_ie == NULL) {
|
|
|
|
DBG_871X("%s()-%d: rtw_malloc() ERROR!\n", __FUNCTION__, __LINE__);
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_priv *mlmepriv = &(adapter->mlmepriv);
|
|
|
|
struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv);
|
|
|
|
struct mlme_ext_info *mlmeinfo = &(mlmeext->mlmext_info);
|
|
|
|
int ie_len;
|
|
|
|
u8 *ssid_ie;
|
|
|
|
char ssid[NDIS_802_11_LENGTH_SSID + 1];
|
|
|
|
sint ssid_len;
|
|
|
|
u8 ignore_broadcast_ssid;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(mlmepriv, WIFI_AP_STATE) != true)
|
2014-12-17 01:03:30 +00:00
|
|
|
return -EPERM;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (param->u.bcn_ie.reserved[0] != 0xea)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
mlmeinfo->hidden_ssid_mode = ignore_broadcast_ssid = param->u.bcn_ie.reserved[1];
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
ie_len = len-12-2;/* 12 = param header, 2:no packed */
|
2014-12-17 01:03:30 +00:00
|
|
|
ssid_ie = rtw_get_ie(param->u.bcn_ie.buf, WLAN_EID_SSID, &ssid_len, ie_len);
|
|
|
|
|
|
|
|
if (ssid_ie && ssid_len) {
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *pbss_network = &mlmepriv->cur_network.network;
|
|
|
|
struct wlan_bssid_ex *pbss_network_ext = &mlmeinfo->network;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(ssid, ssid_ie+2, ssid_len);
|
2014-12-17 01:03:30 +00:00
|
|
|
ssid[ssid_len>NDIS_802_11_LENGTH_SSID?NDIS_802_11_LENGTH_SSID:ssid_len] = 0x0;
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pbss_network->Ssid.Ssid, (void *)ssid, ssid_len);
|
2014-12-17 01:03:30 +00:00
|
|
|
pbss_network->Ssid.SsidLength = ssid_len;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pbss_network_ext->Ssid.Ssid, (void *)ssid, ssid_len);
|
2014-12-17 01:03:30 +00:00
|
|
|
pbss_network_ext->Ssid.SsidLength = ssid_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG_871X(FUNC_ADPT_FMT" ignore_broadcast_ssid:%d, %s,%d\n", FUNC_ADPT_ARG(adapter),
|
|
|
|
ignore_broadcast_ssid, ssid, ssid_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
return ret;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
|
|
|
|
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
|
2014-12-19 06:59:46 +00:00
|
|
|
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = rtw_acl_remove_sta(padapter, param->sta_addr);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
|
|
|
|
param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
|
2014-12-19 06:59:46 +00:00
|
|
|
param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
ret = rtw_acl_add_sta(padapter, param->sta_addr);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return ret;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
|
2014-12-19 06:59:46 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
rtw_set_macaddr_acl(padapter, param->u.mlme.command);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p)
|
|
|
|
{
|
|
|
|
struct ieee_param *param;
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%s\n", __FUNCTION__); */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* this function is expect to call in master mode, which allows no power saving
|
|
|
|
* so, we just check hw_init_completed
|
|
|
|
*/
|
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (padapter->hw_init_completed==false) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EPERM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
/* if (p->length < sizeof(struct ieee_param) || !p->pointer) { */
|
|
|
|
if (!p->pointer) {
|
2013-08-10 16:56:55 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-08-10 16:56:55 +00:00
|
|
|
param = (struct ieee_param *)rtw_malloc(p->length);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (param == NULL)
|
|
|
|
{
|
2013-08-10 16:56:55 +00:00
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (copy_from_user(param, p->pointer, p->length))
|
|
|
|
{
|
|
|
|
rtw_mfree((u8*)param, p->length);
|
2013-08-10 16:56:55 +00:00
|
|
|
ret = -EFAULT;
|
|
|
|
goto out;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%s, cmd=%d\n", __FUNCTION__, param->cmd); */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
switch (param->cmd)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
case RTL871X_HOSTAPD_FLUSH:
|
|
|
|
|
|
|
|
ret = rtw_hostapd_sta_flush(dev);
|
|
|
|
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
case RTL871X_HOSTAPD_ADD_STA:
|
|
|
|
|
|
|
|
ret = rtw_add_sta(dev, param);
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RTL871X_HOSTAPD_REMOVE_STA:
|
|
|
|
|
|
|
|
ret = rtw_del_sta(dev, param);
|
|
|
|
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
case RTL871X_HOSTAPD_SET_BEACON:
|
|
|
|
|
|
|
|
ret = rtw_set_beacon(dev, param, p->length);
|
|
|
|
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
case RTL871X_SET_ENCRYPTION:
|
|
|
|
|
|
|
|
ret = rtw_set_encryption(dev, param, p->length);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
case RTL871X_HOSTAPD_GET_WPAIE_STA:
|
|
|
|
|
|
|
|
ret = rtw_get_sta_wpaie(dev, param);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
case RTL871X_HOSTAPD_SET_WPS_BEACON:
|
|
|
|
|
|
|
|
ret = rtw_set_wps_beacon(dev, param, p->length);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP:
|
|
|
|
|
|
|
|
ret = rtw_set_wps_probe_resp(dev, param, p->length);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP:
|
|
|
|
|
|
|
|
ret = rtw_set_wps_assoc_resp(dev, param, p->length);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
break;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
case RTL871X_HOSTAPD_SET_HIDDEN_SSID:
|
|
|
|
|
|
|
|
ret = rtw_set_hidden_ssid(dev, param, p->length);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RTL871X_HOSTAPD_GET_INFO_STA:
|
|
|
|
|
|
|
|
ret = rtw_ioctl_get_sta_data(dev, param, p->length);
|
|
|
|
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
case RTL871X_HOSTAPD_SET_MACADDR_ACL:
|
|
|
|
|
|
|
|
ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RTL871X_HOSTAPD_ACL_ADD_STA:
|
|
|
|
|
|
|
|
ret = rtw_ioctl_acl_add_sta(dev, param, p->length);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RTL871X_HOSTAPD_ACL_REMOVE_STA:
|
|
|
|
|
|
|
|
ret = rtw_ioctl_acl_remove_sta(dev, param, p->length);
|
|
|
|
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
default:
|
|
|
|
DBG_871X("Unknown hostapd request: %d\n", param->cmd);
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ret == 0 && copy_to_user(p->pointer, param, p->length))
|
|
|
|
ret = -EFAULT;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
rtw_mfree((u8 *)param, p->length);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
out:
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <rtw_android.h>
|
|
|
|
static int rtw_wx_set_priv(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *awrq,
|
|
|
|
char *extra)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_RTW_WX_SET_PRIV
|
|
|
|
char *ext_dbg;
|
|
|
|
#endif
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = 0;
|
|
|
|
int len = 0;
|
|
|
|
char *ext;
|
2014-12-17 01:03:30 +00:00
|
|
|
int i;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *dwrq = (struct iw_point*)awrq;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_notice_, ("+rtw_wx_set_priv\n")); */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (dwrq->length == 0)
|
2014-12-17 01:03:30 +00:00
|
|
|
return -EFAULT;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
len = dwrq->length;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (!(ext = rtw_vmalloc(len)))
|
2013-05-08 21:45:39 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (copy_from_user(ext, dwrq->pointer, len)) {
|
|
|
|
rtw_vmfree(ext, len);
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_notice_, */
|
|
|
|
/* ("rtw_wx_set_priv: %s req=%s\n", */
|
|
|
|
/* dev->name, ext)); */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
#ifdef CONFIG_DEBUG_RTW_WX_SET_PRIV
|
2014-12-17 01:03:30 +00:00
|
|
|
if (!(ext_dbg = rtw_vmalloc(len)))
|
|
|
|
{
|
|
|
|
rtw_vmfree(ext, len);
|
|
|
|
return -ENOMEM;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(ext_dbg, ext, len);
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* added for wps2.0 @20110524 */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (dwrq->flags == 0x8766 && len > 8)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
u32 cp_sz;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
u8 *probereq_wpsie = ext;
|
|
|
|
int probereq_wpsie_len = len;
|
2014-12-19 06:59:46 +00:00
|
|
|
u8 wps_oui[4]={0x0,0x50,0xf2,0x04};
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) &&
|
2014-12-29 02:13:24 +00:00
|
|
|
(_rtw_memcmp(&probereq_wpsie[2], wps_oui, 4) ==true))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
cp_sz = probereq_wpsie_len>MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN:probereq_wpsie_len;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* memcpy(pmlmepriv->probereq_wpsie, probereq_wpsie, cp_sz); */
|
|
|
|
/* pmlmepriv->probereq_wpsie_len = cp_sz; */
|
2015-08-15 18:02:34 +00:00
|
|
|
if (pmlmepriv->wps_probe_req_ie)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u32 free_len = pmlmepriv->wps_probe_req_ie_len;
|
|
|
|
pmlmepriv->wps_probe_req_ie_len = 0;
|
|
|
|
rtw_mfree(pmlmepriv->wps_probe_req_ie, free_len);
|
2014-12-19 06:59:46 +00:00
|
|
|
pmlmepriv->wps_probe_req_ie = NULL;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz);
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( pmlmepriv->wps_probe_req_ie == NULL) {
|
|
|
|
printk("%s()-%d: rtw_malloc() ERROR!\n", __FUNCTION__, __LINE__);
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto FREE_EXT;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz);
|
2014-12-19 06:59:46 +00:00
|
|
|
pmlmepriv->wps_probe_req_ie_len = cp_sz;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
goto FREE_EXT;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if ( len >= WEXT_CSCAN_HEADER_SIZE
|
2014-12-29 02:13:24 +00:00
|
|
|
&& _rtw_memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE) == true
|
2015-08-15 18:24:16 +00:00
|
|
|
) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = rtw_wx_set_scan(dev, info, awrq, ext);
|
|
|
|
goto FREE_EXT;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_ANDROID
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("rtw_wx_set_priv: %s req=%s\n", dev->name, ext); */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
i = rtw_android_cmdstr_to_num(ext);
|
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
switch (i) {
|
2014-12-17 01:03:30 +00:00
|
|
|
case ANDROID_WIFI_CMD_START :
|
|
|
|
indicate_wx_custom_event(padapter, "START");
|
|
|
|
break;
|
|
|
|
case ANDROID_WIFI_CMD_STOP :
|
|
|
|
indicate_wx_custom_event(padapter, "STOP");
|
|
|
|
break;
|
|
|
|
case ANDROID_WIFI_CMD_RSSI :
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pcur_network = &pmlmepriv->cur_network;
|
|
|
|
|
2015-08-15 18:02:34 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(ext, "%s rssi %d", pcur_network->network.Ssid.Ssid, padapter->recvpriv.rssi);
|
|
|
|
} else {
|
|
|
|
sprintf(ext, "OK");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ANDROID_WIFI_CMD_LINKSPEED :
|
|
|
|
{
|
|
|
|
u16 mbps = rtw_get_cur_max_rate(padapter)/10;
|
|
|
|
sprintf(ext, "LINKSPEED %d", mbps);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ANDROID_WIFI_CMD_MACADDR :
|
|
|
|
sprintf(ext, "MACADDR = " MAC_FMT, MAC_ARG(dev->dev_addr));
|
|
|
|
break;
|
|
|
|
case ANDROID_WIFI_CMD_SCAN_ACTIVE :
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* rtw_set_scan_mode(padapter, SCAN_ACTIVE); */
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(ext, "OK");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ANDROID_WIFI_CMD_SCAN_PASSIVE :
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* rtw_set_scan_mode(padapter, SCAN_PASSIVE); */
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(ext, "OK");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ANDROID_WIFI_CMD_COUNTRY :
|
|
|
|
{
|
|
|
|
char country_code[10];
|
|
|
|
sscanf(ext, "%*s %s", country_code);
|
|
|
|
rtw_set_country(padapter, country_code);
|
|
|
|
sprintf(ext, "OK");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
#ifdef CONFIG_DEBUG_RTW_WX_SET_PRIV
|
|
|
|
DBG_871X("%s: %s unknowned req=%s\n", __FUNCTION__,
|
|
|
|
dev->name, ext_dbg);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
sprintf(ext, "OK");
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_to_user(dwrq->pointer, ext, min(dwrq->length, (u16)(strlen(ext)+1)) ) )
|
|
|
|
ret = -EFAULT;
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_RTW_WX_SET_PRIV
|
|
|
|
DBG_871X("%s: %s req=%s rep=%s dwrq->length=%d, strlen(ext)+1=%d\n", __FUNCTION__,
|
|
|
|
dev->name, ext_dbg ,ext, dwrq->length, (u16)(strlen(ext)+1));
|
|
|
|
#endif
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* end of CONFIG_ANDROID */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
FREE_EXT:
|
|
|
|
|
|
|
|
rtw_vmfree(ext, len);
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_DEBUG_RTW_WX_SET_PRIV
|
|
|
|
rtw_vmfree(ext_dbg, len);
|
|
|
|
#endif
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("rtw_wx_set_priv: (SIOCSIWPRIV) %s ret=%d\n", */
|
|
|
|
/* dev->name, ret); */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
static int rtw_pm_set(struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
unsigned mode = 0;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X( "[%s] extra = %s\n", __FUNCTION__, extra );
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ( _rtw_memcmp( extra, "lps=", 4 ) )
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
sscanf(extra+4, "%u", &mode);
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = rtw_pm_set_lps(padapter,mode);
|
|
|
|
}
|
|
|
|
else if ( _rtw_memcmp( extra, "ips=", 4 ) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sscanf(extra+4, "%u", &mode);
|
2014-12-17 01:03:30 +00:00
|
|
|
ret = rtw_pm_set_ips(padapter,mode);
|
|
|
|
}
|
2015-08-15 18:27:00 +00:00
|
|
|
else {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_mp_efuse_get(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wdata, char *extra)
|
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = rtw_netdev_priv(dev);
|
2015-03-17 15:31:25 +00:00
|
|
|
struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter);
|
2014-12-17 01:03:30 +00:00
|
|
|
PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter);
|
|
|
|
PEFUSE_HAL pEfuseHal;
|
|
|
|
struct iw_point *wrqu;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 *PROMContent = pEEPROM->efuse_eeprom_data;
|
|
|
|
struct pwrctrl_priv *pwrctrlpriv ;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *data = NULL;
|
|
|
|
u8 *rawdata = NULL;
|
2014-12-17 01:03:30 +00:00
|
|
|
char *pch, *ptmp, *token, *tmp[3]={NULL, NULL, NULL};
|
|
|
|
u8 ips_mode,lps_mode;
|
|
|
|
u16 i=0, j=0, mapLen=0, addr=0, cnts=0;
|
|
|
|
u16 max_available_size=0, raw_cursize=0, raw_maxsize=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
int err;
|
2015-02-20 04:11:26 +00:00
|
|
|
u8 org_fw_iol = padapter->registrypriv.fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
wrqu = (struct iw_point*)wdata;
|
2014-12-19 06:59:46 +00:00
|
|
|
pwrctrlpriv = adapter_to_pwrctl(padapter);
|
2014-12-17 01:03:30 +00:00
|
|
|
pEfuseHal = &pHalData->EfuseHal;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
err = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
data = rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN);
|
|
|
|
if (data == NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
rawdata = rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN);
|
|
|
|
if (rawdata == NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (copy_from_user(extra, wrqu->pointer, wrqu->length))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_pm_set_lps(padapter,PS_MODE_ACTIVE);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
ips_mode = pwrctrlpriv->ips_mode;/* keep org value */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_pm_set_ips(padapter,IPS_NONE);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pch = extra;
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: in=%s\n", __FUNCTION__, extra);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
i = 0;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* mac 16 "00e04c871200" rmap,00,2 */
|
2014-12-17 01:03:30 +00:00
|
|
|
while ((token = strsep(&pch, ",")) != NULL)
|
|
|
|
{
|
|
|
|
if (i > 2) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
tmp[i] = token;
|
|
|
|
i++;
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
padapter->registrypriv.fw_iol = 0;/* 0:Disable, 1:enable, 2:by usb speed */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-08-15 18:24:16 +00:00
|
|
|
if (strcmp(tmp[0], "status") == 0) {
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(extra, "Load File efuse=%s,Load File MAC=%s",(pEEPROM->bloadfile_fail_flag? "FAIL" : "OK"),(pEEPROM->bloadmac_fail_flag? "FAIL" : "OK"));
|
2015-03-10 16:18:03 +00:00
|
|
|
goto exit;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "drvmap") == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
mapLen = EFUSE_MAP_SIZE;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i = 0; i < EFUSE_MAP_SIZE; i += 16)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s0x%02x\t", extra, i);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (j=0; j<8; j++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, PROMContent[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\t", extra);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (; j<16; j++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, PROMContent[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
sprintf(extra,"%s\n",extra);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "realmap") == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
mapLen = EFUSE_MAP_SIZE;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_efuse_map_read(padapter, 0, mapLen, pEfuseHal->fakeEfuseInitMap) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: read realmap Fail!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(extra, "\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i = 0; i < EFUSE_MAP_SIZE; i += 16)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s0x%02x\t", extra, i);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (j=0; j<8; j++) {
|
|
|
|
if (i + j >= EFUSE_MAX_MAP_LEN)
|
|
|
|
continue;
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\t", extra);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (; j<16; j++) {
|
|
|
|
if (i + j >= EFUSE_MAX_MAP_LEN)
|
|
|
|
continue;
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
sprintf(extra,"%s\n",extra);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "rmap") == 0)
|
|
|
|
{
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((tmp[1]== NULL) || (tmp[2]== NULL))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s: rmap Fail!! Parameters error!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* rmap addr cnts */
|
2013-05-08 21:45:39 +00:00
|
|
|
addr = simple_strtoul(tmp[1], &ptmp, 16);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr=%x\n", __FUNCTION__, addr);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
cnts = simple_strtoul(tmp[2], &ptmp, 10);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts == 0)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rmap Fail!! cnts error!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((addr + cnts) > max_available_size)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: addr(0x%X)+cnts(%d) parameter error!\n", __FUNCTION__, addr, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_efuse_map_read error!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
*extra = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i=0; i<cnts; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s0x%02X ", extra, data[i]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "realraw") == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
addr = 0;
|
|
|
|
mapLen = EFUSE_MAX_SIZE;
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_efuse_access(padapter, false, addr, mapLen, rawdata) == _FAIL)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_efuse_access Fail!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(extra, "\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i=0; i<mapLen; i++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X", extra, rawdata[i]);
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((i & 0xF) == 0xF) {
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\n", extra);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-08-15 18:24:16 +00:00
|
|
|
else if ((i & 0x7) == 0x7) {
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\t", extra);
|
2014-12-17 01:03:30 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s ", extra);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "mac") == 0)
|
|
|
|
{
|
2014-12-28 17:13:03 +00:00
|
|
|
addr = EEPROM_MAC_ADDR_88EU;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
cnts = 6;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((addr + cnts) > max_available_size) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __FUNCTION__, addr, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_efuse_map_read error!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
*extra = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i=0; i<cnts; i++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X", extra, data[i]);
|
|
|
|
if (i != (cnts-1))
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(extra,"%s:",extra);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "vidpid") == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
cnts = 4;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((addr + cnts) > max_available_size)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __FUNCTION__, addr, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_efuse_access error!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
*extra = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i=0; i<cnts; i++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s0x%02X", extra, data[i]);
|
|
|
|
if (i != (cnts-1))
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(extra,"%s,",extra);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "ableraw") == 0)
|
|
|
|
{
|
|
|
|
efuse_GetCurrentSize(padapter,&raw_cursize);
|
2013-05-08 21:45:39 +00:00
|
|
|
raw_maxsize = efuse_GetMaxSize(padapter);
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(extra, "[available raw size]= %d bytes", raw_maxsize-raw_cursize);
|
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "btfmap") == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
mapLen = EFUSE_BT_MAX_MAP_LEN;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_BT_efuse_map_read Fail!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(extra, "\n");
|
2015-02-20 04:11:26 +00:00
|
|
|
for (i=0; i<512; i+=16) /* set 512 because the iwpriv's extra size have limit 0x7FF */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s0x%03x\t", extra, i);
|
2015-03-10 16:18:03 +00:00
|
|
|
for (j=0; j<8; j++)
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(extra,"%s\t",extra);
|
2015-03-10 16:18:03 +00:00
|
|
|
for (; j<16; j++)
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
|
|
|
|
sprintf(extra, "%s\n", extra);
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0],"btbmap") == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
mapLen = EFUSE_BT_MAX_MAP_LEN;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_BT_efuse_map_read Fail!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(extra, "\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i=512; i<1024 ; i+=16)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s0x%03x\t", extra, i);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (j=0; j<8; j++)
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(extra,"%s\t",extra);
|
2015-03-10 16:18:03 +00:00
|
|
|
for (; j<16; j++)
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
|
|
|
|
sprintf(extra, "%s\n", extra);
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0],"btrmap") == 0)
|
|
|
|
{
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((tmp[1]== NULL) || (tmp[2]== NULL))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* rmap addr cnts */
|
2013-05-08 21:45:39 +00:00
|
|
|
addr = simple_strtoul(tmp[1], &ptmp, 16);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr=0x%X\n", __FUNCTION__, addr);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
cnts = simple_strtoul(tmp[2], &ptmp, 10);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts == 0)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: btrmap Fail!! cnts error!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((addr + cnts) > max_available_size)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: addr(0x%X)+cnts(%d) parameter error!\n", __FUNCTION__, addr, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
if (rtw_BT_efuse_map_read(padapter, addr, cnts, data) == _FAIL)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_BT_efuse_map_read error!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
*extra = 0;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%s: bt efuse data={", __FUNCTION__); */
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i=0; i<cnts; i++)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("0x%02x ", data[i]); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s 0x%02X ", extra, data[i]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("}\n"); */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "btffake") == 0)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("OFFSET\tVALUE(hex)\n"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i=0; i<512; i+=16)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("0x%03x\t", i); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s0x%03x\t", extra, i);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (j=0; j<8; j++) {
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\t"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\t", extra);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (; j<16; j++) {
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\n"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\n", extra);
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\n"); */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0],"btbfake") == 0)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("OFFSET\tVALUE(hex)\n"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "\n");
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i=512; i<1024; i+=16)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("0x%03x\t", i); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s0x%03x\t", extra, i);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (j=0; j<8; j++) {
|
|
|
|
if (i + j >= EFUSE_BT_MAX_MAP_LEN)
|
|
|
|
continue;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\t"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\t", extra);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (; j<16; j++) {
|
|
|
|
if (i + j >= EFUSE_BT_MAX_MAP_LEN)
|
|
|
|
continue;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\n"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\n", extra);
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\n"); */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0],"wlrfkmap")== 0)
|
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("OFFSET\tVALUE(hex)\n"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "\n");
|
2013-08-10 16:56:55 +00:00
|
|
|
for (i = 0; i < EFUSE_MAP_SIZE; i += 16) {
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\t0x%02x\t", i); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s0x%02x\t", extra, i);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (j=0; j<8; j++) {
|
|
|
|
if (i + j >= EFUSE_MAX_MAP_LEN)
|
|
|
|
continue;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\t"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\t", extra);
|
2014-12-17 01:03:30 +00:00
|
|
|
for (; j<16; j++) {
|
|
|
|
if (i + j >= EFUSE_MAX_MAP_LEN)
|
|
|
|
continue;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\n"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "%s\n", extra);
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* DBG_871X("\n"); */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
} else if (strcmp(tmp[0],"wlrfkrmap")== 0) {
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((tmp[1]== NULL) || (tmp[2]== NULL)) {
|
2015-03-10 16:18:03 +00:00
|
|
|
DBG_871X("%s: rmap Fail!! Parameters error!\n", __FUNCTION__);
|
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
/* rmap addr cnts */
|
|
|
|
addr = simple_strtoul(tmp[1], &ptmp, 16);
|
|
|
|
DBG_871X("%s: addr=%x\n", __FUNCTION__, addr);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
cnts = simple_strtoul(tmp[2], &ptmp, 10);
|
|
|
|
if (cnts == 0) {
|
|
|
|
DBG_871X("%s: rmap Fail!! cnts error!\n", __FUNCTION__);
|
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
*extra = 0;
|
|
|
|
for (i=0; i<cnts; i++) {
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X("wlrfkrmap = 0x%02x\n", pEfuseHal->fakeEfuseModifiedMap[addr+i]);
|
2015-03-10 16:18:03 +00:00
|
|
|
sprintf(extra, "%s0x%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[addr+i]);
|
|
|
|
}
|
|
|
|
} else if (strcmp(tmp[0],"btrfkrmap")== 0) {
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((tmp[1]== NULL) || (tmp[2]== NULL)) {
|
2015-03-10 16:18:03 +00:00
|
|
|
DBG_871X("%s: rmap Fail!! Parameters error!\n", __FUNCTION__);
|
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
/* rmap addr cnts */
|
|
|
|
addr = simple_strtoul(tmp[1], &ptmp, 16);
|
|
|
|
DBG_871X("%s: addr=%x\n", __FUNCTION__, addr);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
cnts = simple_strtoul(tmp[2], &ptmp, 10);
|
|
|
|
if (cnts == 0) {
|
|
|
|
DBG_871X("%s: rmap Fail!! cnts error!\n", __FUNCTION__);
|
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
*extra = 0;
|
|
|
|
for (i=0; i<cnts; i++) {
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X("wlrfkrmap = 0x%02x\n", pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
|
2015-03-10 16:18:03 +00:00
|
|
|
sprintf(extra, "%s0x%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
|
|
|
|
}
|
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
sprintf(extra, "Command not found!");
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2014-12-17 01:03:30 +00:00
|
|
|
if (data)
|
|
|
|
rtw_mfree(data, EFUSE_BT_MAX_MAP_LEN);
|
|
|
|
if (rawdata)
|
|
|
|
rtw_mfree(rawdata, EFUSE_BT_MAX_MAP_LEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
if (!err)
|
|
|
|
wrqu->length = strlen(extra);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_pm_set_ips(padapter, ips_mode);
|
|
|
|
rtw_pm_set_lps(padapter, lps_mode);
|
2015-02-20 04:11:26 +00:00
|
|
|
padapter->registrypriv.fw_iol = org_fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */
|
2013-05-08 21:45:39 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_mp_efuse_set(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wdata, char *extra)
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_point *wrqu;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct pwrctrl_priv *pwrctrlpriv ;
|
|
|
|
PHAL_DATA_TYPE pHalData;
|
|
|
|
PEFUSE_HAL pEfuseHal;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 ips_mode,lps_mode;
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 i, jj, kk;
|
|
|
|
u8 *setdata = NULL;
|
|
|
|
u8 *ShadowMapBT = NULL;
|
|
|
|
u8 *ShadowMapWiFi = NULL;
|
|
|
|
u8 *setrawdata = NULL;
|
2014-12-17 01:03:30 +00:00
|
|
|
char *pch, *ptmp, *token, *tmp[3]={NULL, NULL, NULL};
|
|
|
|
u16 addr=0, cnts=0, max_available_size=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
int err;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
wrqu = (struct iw_point*)wdata;
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter = rtw_netdev_priv(dev);
|
2014-12-17 01:03:30 +00:00
|
|
|
pwrctrlpriv = adapter_to_pwrctl(padapter);
|
|
|
|
pHalData = GET_HAL_DATA(padapter);
|
|
|
|
pEfuseHal = &pHalData->EfuseHal;
|
2013-05-08 21:45:39 +00:00
|
|
|
err = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
setdata = rtw_zmalloc(1024);
|
|
|
|
if (setdata == NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
ShadowMapBT = rtw_malloc(EFUSE_BT_MAX_MAP_LEN);
|
|
|
|
if (ShadowMapBT == NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
ShadowMapWiFi = rtw_malloc(EFUSE_MAP_SIZE);
|
|
|
|
if (ShadowMapWiFi == NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
setrawdata = rtw_malloc(EFUSE_MAX_SIZE);
|
|
|
|
if (setrawdata == NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_pm_set_lps(padapter,PS_MODE_ACTIVE);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
ips_mode = pwrctrlpriv->ips_mode;/* keep org value */
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_pm_set_ips(padapter,IPS_NONE);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pch = extra;
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: in=%s\n", __FUNCTION__, extra);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
i = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
while ((token = strsep(&pch, ",")) != NULL)
|
|
|
|
{
|
|
|
|
if (i > 2) break;
|
2013-05-08 21:45:39 +00:00
|
|
|
tmp[i] = token;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* tmp[0],[1],[2] */
|
|
|
|
/* wmap,addr,00e04c871200 */
|
2014-12-17 01:03:30 +00:00
|
|
|
if (strcmp(tmp[0], "wmap") == 0)
|
|
|
|
{
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((tmp[1]== NULL) || (tmp[2]== NULL))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = simple_strtoul(tmp[1], &ptmp, 16);
|
|
|
|
addr &= 0xFFF;
|
|
|
|
|
|
|
|
cnts = strlen(tmp[2]);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts%2)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
cnts /= 2;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr=0x%X\n", __FUNCTION__, addr);
|
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
|
|
|
DBG_871X("%s: map data=%s\n", __FUNCTION__, tmp[2]);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
for (jj=0, kk=0; jj<cnts; jj++, kk+=2)
|
|
|
|
{
|
|
|
|
setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk+1]);
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Change to check TYPE_EFUSE_MAP_LEN ,beacuse 8188E raw 256,logic map over 256. */
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((addr+cnts) > max_available_size)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: addr(0x%X)+cnts(%d) parameter error!\n", __FUNCTION__, addr, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_efuse_map_write error!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "wraw") == 0)
|
|
|
|
{
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((tmp[1]== NULL) || (tmp[2]== NULL))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
addr = simple_strtoul( tmp[1], &ptmp, 16 );
|
2013-05-08 21:45:39 +00:00
|
|
|
addr &= 0xFFF;
|
|
|
|
|
|
|
|
cnts = strlen(tmp[2]);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts%2)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
cnts /= 2;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr=0x%X\n", __FUNCTION__, addr);
|
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
|
|
|
DBG_871X("%s: raw data=%s\n", __FUNCTION__, tmp[2]);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
for (jj=0, kk=0; jj<cnts; jj++, kk+=2)
|
|
|
|
{
|
|
|
|
setrawdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk+1]);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_efuse_access(padapter, true, addr, cnts, setrawdata) == _FAIL)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_efuse_access error!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "mac") == 0)
|
|
|
|
{
|
2015-08-15 18:22:58 +00:00
|
|
|
if (tmp[1]== NULL)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-28 17:13:03 +00:00
|
|
|
addr = EEPROM_MAC_ADDR_88EU;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
cnts = strlen(tmp[1]);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts%2)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
cnts /= 2;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts > 6)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: error data for mac addr=\"%s\"\n", __FUNCTION__, tmp[1]);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr=0x%X\n", __FUNCTION__, addr);
|
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
|
|
|
DBG_871X("%s: MAC address=%s\n", __FUNCTION__, tmp[1]);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
for (jj=0, kk=0; jj<cnts; jj++, kk+=2)
|
|
|
|
{
|
|
|
|
setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk+1]);
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Change to check TYPE_EFUSE_MAP_LEN ,beacuse 8188E raw 256,logic map over 256. */
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((addr+cnts) > max_available_size)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: addr(0x%X)+cnts(%d) parameter error!\n", __FUNCTION__, addr, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_efuse_map_write error!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "vidpid") == 0)
|
|
|
|
{
|
2015-08-15 18:22:58 +00:00
|
|
|
if (tmp[1]== NULL)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-28 17:13:03 +00:00
|
|
|
addr = EEPROM_VID_88EE;
|
2013-05-08 21:45:39 +00:00
|
|
|
cnts = strlen(tmp[1]);
|
2014-12-28 17:13:03 +00:00
|
|
|
if (cnts%2) {
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
cnts /= 2;
|
2014-12-28 17:13:03 +00:00
|
|
|
if (cnts == 0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr=0x%X\n", __FUNCTION__, addr);
|
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
|
|
|
DBG_871X("%s: VID/PID=%s\n", __FUNCTION__, tmp[1]);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
for (jj=0, kk=0; jj<cnts; jj++, kk+=2)
|
|
|
|
{
|
|
|
|
setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk+1]);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((addr+cnts) > max_available_size)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: addr(0x%X)+cnts(%d) parameter error!\n", __FUNCTION__, addr, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_efuse_map_write error!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "wldumpfake") == 0)
|
|
|
|
{
|
|
|
|
if (rtw_efuse_map_read(padapter, 0, EFUSE_MAP_SIZE, pEfuseHal->fakeEfuseModifiedMap) == _SUCCESS) {
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X("%s: WiFi hw efuse dump to Fake map success\n", __FUNCTION__);
|
2014-12-17 01:03:30 +00:00
|
|
|
} else {
|
2015-08-15 18:00:19 +00:00
|
|
|
DBG_871X("%s: WiFi hw efuse dump to Fake map Fail\n", __FUNCTION__);
|
2014-12-17 01:03:30 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "btwmap") == 0)
|
|
|
|
{
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((tmp[1]== NULL) || (tmp[2]== NULL))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = simple_strtoul(tmp[1], &ptmp, 16);
|
|
|
|
addr &= 0xFFF;
|
|
|
|
|
|
|
|
cnts = strlen(tmp[2]);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts%2)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
cnts /= 2;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr=0x%X\n", __FUNCTION__, addr);
|
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
|
|
|
DBG_871X("%s: BT data=%s\n", __FUNCTION__, tmp[2]);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
for (jj=0, kk=0; jj<cnts; jj++, kk+=2)
|
|
|
|
{
|
|
|
|
setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk+1]);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
if ((addr+cnts) > max_available_size)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: addr(0x%X)+cnts(%d) parameter error!\n", __FUNCTION__, addr, cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_BT_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_BT_efuse_map_write error!!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "btwfake") == 0)
|
|
|
|
{
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((tmp[1]== NULL) || (tmp[2]== NULL))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = simple_strtoul(tmp[1], &ptmp, 16);
|
|
|
|
addr &= 0xFFF;
|
|
|
|
|
|
|
|
cnts = strlen(tmp[2]);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts%2)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
cnts /= 2;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr=0x%X\n", __FUNCTION__, addr);
|
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
|
|
|
DBG_871X("%s: BT tmp data=%s\n", __FUNCTION__, tmp[2]);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
for (jj=0, kk=0; jj<cnts; jj++, kk+=2)
|
|
|
|
{
|
|
|
|
pEfuseHal->fakeBTEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk+1]);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "btdumpfake") == 0)
|
|
|
|
{
|
|
|
|
if (rtw_BT_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _SUCCESS) {
|
|
|
|
DBG_871X("%s: BT read all map success\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: BT read all map Fail!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "btfk2map") == 0)
|
|
|
|
{
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pEfuseHal->BTEfuseModifiedMap, pEfuseHal->fakeBTEfuseModifiedMap, EFUSE_BT_MAX_MAP_LEN);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (max_available_size < 1)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_BT_efuse_map_write(padapter, 0x00, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_BT_efuse_map_write error!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "wlfk2map") == 0)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (max_available_size < 1)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (rtw_efuse_map_write(padapter, 0x00, EFUSE_MAP_SIZE, pEfuseHal->fakeEfuseModifiedMap) == _FAIL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s: rtw_efuse_map_write fakeEfuseModifiedMap error!\n", __FUNCTION__);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else if (strcmp(tmp[0], "wlwfake") == 0)
|
|
|
|
{
|
2015-08-15 18:22:58 +00:00
|
|
|
if ((tmp[1]== NULL) || (tmp[2]== NULL))
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = simple_strtoul(tmp[1], &ptmp, 16);
|
|
|
|
addr &= 0xFFF;
|
|
|
|
|
|
|
|
cnts = strlen(tmp[2]);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts%2)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
cnts /= 2;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (cnts == 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: addr=0x%X\n", __FUNCTION__, addr);
|
|
|
|
DBG_871X("%s: cnts=%d\n", __FUNCTION__, cnts);
|
|
|
|
DBG_871X("%s: map tmp data=%s\n", __FUNCTION__, tmp[2]);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
for (jj=0, kk=0; jj<cnts; jj++, kk+=2)
|
|
|
|
{
|
|
|
|
pEfuseHal->fakeEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk+1]);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2014-12-17 01:03:30 +00:00
|
|
|
if (setdata)
|
|
|
|
rtw_mfree(setdata, 1024);
|
|
|
|
if (ShadowMapBT)
|
|
|
|
rtw_mfree(ShadowMapBT, EFUSE_BT_MAX_MAP_LEN);
|
|
|
|
if (ShadowMapWiFi)
|
|
|
|
rtw_mfree(ShadowMapWiFi, EFUSE_MAP_SIZE);
|
|
|
|
if (setrawdata)
|
|
|
|
rtw_mfree(setrawdata, EFUSE_MAX_SIZE);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_pm_set_ips(padapter, ips_mode);
|
|
|
|
rtw_pm_set_lps(padapter, lps_mode);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_wfd_tdls_enable(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_tdls_weaksec(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int rtw_tdls_enable(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_tdls_setup(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_tdls_teardown(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_tdls_discovery(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
|
2015-08-15 18:05:44 +00:00
|
|
|
static int rtw_tdls_ch_switch (struct net_device *dev,
|
2014-12-17 01:03:30 +00:00
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_tdls_pson(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_tdls_psoff(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_tdls_setip(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_tdls_getip(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_tdls_getport(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* WFDTDLS, for sigma test */
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_tdls_dis_result(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* WFDTDLS, for sigma test */
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_wfd_tdls_status(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_tdls_ch_switch_off(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static int rtw_tdls(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
static int rtw_tdls_get(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#ifdef CONFIG_P2P
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-01-29 21:27:28 +00:00
|
|
|
DBG_871X( "[%s] extra = %s\n", __FUNCTION__, (__force char *)wrqu->data.pointer );
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-01-29 21:27:28 +00:00
|
|
|
if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "ip", 2 ) )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
rtw_tdls_getip( dev, info, wrqu, extra );
|
|
|
|
}
|
2015-01-29 21:27:28 +00:00
|
|
|
if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "port", 4 ) )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
rtw_tdls_getport( dev, info, wrqu, extra );
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* WFDTDLS, for sigma test */
|
2015-01-29 21:27:28 +00:00
|
|
|
if ( _rtw_memcmp((__force void *)wrqu->data.pointer, "dis", 3 ) )
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
rtw_tdls_dis_result( dev, info, wrqu, extra );
|
|
|
|
}
|
2015-01-29 21:27:28 +00:00
|
|
|
if (_rtw_memcmp((__force void *)wrqu->data.pointer, "status", 6))
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_wfd_tdls_status( dev, info, wrqu, extra );
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-03-02 04:48:40 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_MAC_LOOPBACK_DRIVER
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#include <rtl8188e_hal.h>
|
|
|
|
extern void rtl8188e_cal_txdesc_chksum(struct tx_desc *ptxdesc);
|
|
|
|
#define cal_txdesc_chksum rtl8188e_cal_txdesc_chksum
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static s32 initLoopback(struct adapter *padapter)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
PLOOPBACKDATA ploopback;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (padapter->ploopback == NULL) {
|
|
|
|
ploopback = (PLOOPBACKDATA)rtw_zmalloc(sizeof(LOOPBACKDATA));
|
|
|
|
if (ploopback == NULL) return -ENOMEM;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
_rtw_init_sema(&ploopback->sema, 0);
|
2014-12-29 02:13:24 +00:00
|
|
|
ploopback->bstop = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
ploopback->cnt = 0;
|
|
|
|
ploopback->size = 300;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(ploopback->msg, 0, sizeof(ploopback->msg));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
padapter->ploopback = ploopback;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void freeLoopback(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
PLOOPBACKDATA ploopback;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
ploopback = padapter->ploopback;
|
|
|
|
if (ploopback) {
|
|
|
|
rtw_mfree((u8*)ploopback, sizeof(LOOPBACKDATA));
|
|
|
|
padapter->ploopback = NULL;
|
2013-05-27 22:32:24 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static s32 initpseudoadhoc(struct adapter *padapter)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType;
|
2014-12-17 01:03:30 +00:00
|
|
|
s32 err;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
networkType = Ndis802_11IBSS;
|
|
|
|
err = rtw_set_802_11_infrastructure_mode(padapter, networkType);
|
2014-12-29 02:13:24 +00:00
|
|
|
if (err == false) return _FAIL;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
err = rtw_setopmode_cmd(padapter, networkType,true);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (err == _FAIL) return _FAIL;
|
|
|
|
|
|
|
|
return _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static s32 createpseudoadhoc(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2015-03-14 23:14:05 +00:00
|
|
|
enum NDIS_802_11_AUTHENTICATION_MODE authmode;
|
2014-12-17 01:03:30 +00:00
|
|
|
struct mlme_priv *pmlmepriv;
|
2015-03-14 23:14:05 +00:00
|
|
|
struct ndis_802_11_ssid *passoc_ssid;
|
2015-03-07 00:26:23 +00:00
|
|
|
struct wlan_bssid_ex *pdev_network;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 *pibss;
|
|
|
|
u8 ssid[] = "pseduo_ad-hoc";
|
|
|
|
s32 err;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
authmode = Ndis802_11AuthModeOpen;
|
|
|
|
err = rtw_set_802_11_authentication_mode(padapter, authmode);
|
2014-12-29 02:13:24 +00:00
|
|
|
if (err == false) return _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
passoc_ssid = &pmlmepriv->assoc_ssid;
|
2015-03-14 23:14:05 +00:00
|
|
|
memset(passoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
|
2014-12-17 01:03:30 +00:00
|
|
|
passoc_ssid->SsidLength = sizeof(ssid) - 1;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(passoc_ssid->Ssid, ssid, passoc_ssid->SsidLength);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pdev_network = &padapter->registrypriv.dev_network;
|
|
|
|
pibss = padapter->registrypriv.dev_network.MacAddress;
|
2015-03-14 23:14:05 +00:00
|
|
|
memcpy(&pdev_network->Ssid, passoc_ssid, sizeof(struct ndis_802_11_ssid));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_update_registrypriv_dev_network(padapter);
|
|
|
|
rtw_generate_random_ibss(pibss);
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pmlmepriv->lock);
|
2014-12-17 01:03:30 +00:00
|
|
|
pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pmlmepriv->lock);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
struct wlan_network *pcur_network;
|
|
|
|
struct sta_info *psta;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 3 create a new psta */
|
2014-12-17 01:03:30 +00:00
|
|
|
pcur_network = &pmlmepriv->cur_network;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* clear psta in the cur_network, if any */
|
2014-12-17 01:03:30 +00:00
|
|
|
psta = rtw_get_stainfo(&padapter->stapriv, pcur_network->network.MacAddress);
|
|
|
|
if (psta) rtw_free_stainfo(padapter, psta);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
psta = rtw_alloc_stainfo(&padapter->stapriv, pibss);
|
|
|
|
if (psta == NULL) return _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 3 join psudo AdHoc */
|
2014-12-17 01:03:30 +00:00
|
|
|
pcur_network->join_res = 1;
|
|
|
|
pcur_network->aid = psta->aid = 1;
|
2015-03-07 00:01:31 +00:00
|
|
|
memcpy(&pcur_network->network, pdev_network, get_wlan_bssid_ex_sz(pdev_network));
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u8 val8;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
val8 = rtw_read8(padapter, MSR);
|
2015-02-20 04:11:26 +00:00
|
|
|
val8 &= 0xFC; /* clear NETYPE0 */
|
2014-12-17 01:03:30 +00:00
|
|
|
val8 |= WIFI_FW_ADHOC_STATE & 0x3;
|
|
|
|
rtw_write8(padapter, MSR, val8);
|
|
|
|
}
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static struct xmit_frame* createloopbackpkt(struct adapter *padapter, u32 size)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
struct xmit_priv *pxmitpriv;
|
|
|
|
struct xmit_frame *pframe;
|
|
|
|
struct xmit_buf *pxmitbuf;
|
|
|
|
struct pkt_attrib *pattrib;
|
|
|
|
struct tx_desc *desc;
|
|
|
|
u8 *pkt_start, *pkt_end, *ptr;
|
|
|
|
struct rtw_ieee80211_hdr *hdr;
|
|
|
|
s32 bmcast;
|
2015-03-16 13:54:18 +00:00
|
|
|
unsigned long irqL;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
if ((TXDESC_SIZE + WLANHDR_OFFSET + size) > MAX_XMITBUF_SZ) return NULL;
|
|
|
|
|
|
|
|
pxmitpriv = &padapter->xmitpriv;
|
|
|
|
pframe = NULL;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 2 1. allocate xmit frame */
|
2014-12-17 01:03:30 +00:00
|
|
|
pframe = rtw_alloc_xmitframe(pxmitpriv);
|
|
|
|
if (pframe == NULL) return NULL;
|
|
|
|
pframe->padapter = padapter;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 2 2. allocate xmit buffer */
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pxmitpriv->lock);
|
2014-12-17 01:03:30 +00:00
|
|
|
pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv);
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2014-12-17 01:03:30 +00:00
|
|
|
if (pxmitbuf == NULL) {
|
|
|
|
rtw_free_xmitframe(pxmitpriv, pframe);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pframe->pxmitbuf = pxmitbuf;
|
|
|
|
pframe->buf_addr = pxmitbuf->pbuf;
|
|
|
|
pxmitbuf->priv_data = pframe;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 2 3. update_attrib() */
|
2014-12-17 01:03:30 +00:00
|
|
|
pattrib = &pframe->attrib;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* init xmitframe attribute */
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(pattrib, 0, sizeof(struct pkt_attrib));
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
pattrib->ether_type = 0x8723;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pattrib->src, padapter->eeprompriv.mac_addr, ETH_ALEN);
|
|
|
|
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(pattrib->dst, 0xFF, ETH_ALEN);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
|
2015-02-20 04:11:26 +00:00
|
|
|
/* pattrib->pctrl = 0; */
|
|
|
|
/* pattrib->dhcp_pkt = 0; */
|
|
|
|
/* pattrib->pktlen = 0; */
|
2014-12-17 01:03:30 +00:00
|
|
|
pattrib->ack_policy = 0;
|
2015-02-20 04:11:26 +00:00
|
|
|
/* pattrib->pkt_hdrlen = ETH_HLEN; */
|
2014-12-17 01:03:30 +00:00
|
|
|
pattrib->hdrlen = WLAN_HDR_A3_LEN;
|
|
|
|
pattrib->subtype = WIFI_DATA;
|
|
|
|
pattrib->priority = 0;
|
|
|
|
pattrib->qsel = pattrib->priority;
|
|
|
|
pattrib->nr_frags = 1;
|
|
|
|
pattrib->encrypt = 0;
|
2014-12-29 02:13:24 +00:00
|
|
|
pattrib->bswenc = false;
|
|
|
|
pattrib->qos_en = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
bmcast = IS_MCAST(pattrib->ra);
|
|
|
|
if (bmcast) {
|
|
|
|
pattrib->mac_id = 1;
|
|
|
|
pattrib->psta = rtw_get_bcmc_stainfo(padapter);
|
|
|
|
} else {
|
|
|
|
pattrib->mac_id = 0;
|
|
|
|
pattrib->psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv));
|
|
|
|
}
|
|
|
|
|
|
|
|
pattrib->pktlen = size;
|
|
|
|
pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->pktlen;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 2 4. fill TX descriptor */
|
2014-12-17 01:03:30 +00:00
|
|
|
desc = (struct tx_desc*)pframe->buf_addr;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(desc, 0, TXDESC_SIZE);
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
fill_default_txdesc(pframe, (u8*)desc);
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* Hw set sequence number */
|
|
|
|
((PTXDESC)desc)->hwseq_en = 0; /* HWSEQ_EN, 0:disable, 1:enable */
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
((PTXDESC)desc)->disdatafb = 1;
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* convert to little endian */
|
2014-12-17 01:03:30 +00:00
|
|
|
desc->txdw0 = cpu_to_le32(desc->txdw0);
|
|
|
|
desc->txdw1 = cpu_to_le32(desc->txdw1);
|
|
|
|
desc->txdw2 = cpu_to_le32(desc->txdw2);
|
|
|
|
desc->txdw3 = cpu_to_le32(desc->txdw3);
|
|
|
|
desc->txdw4 = cpu_to_le32(desc->txdw4);
|
|
|
|
desc->txdw5 = cpu_to_le32(desc->txdw5);
|
|
|
|
desc->txdw6 = cpu_to_le32(desc->txdw6);
|
|
|
|
desc->txdw7 = cpu_to_le32(desc->txdw7);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
cal_txdesc_chksum(desc);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 2 5. coalesce */
|
2014-12-17 01:03:30 +00:00
|
|
|
pkt_start = pframe->buf_addr + TXDESC_SIZE;
|
|
|
|
pkt_end = pkt_start + pattrib->last_txcmdsz;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 3 5.1. make wlan header, make_wlanhdr() */
|
2014-12-17 01:03:30 +00:00
|
|
|
hdr = (struct rtw_ieee80211_hdr *)pkt_start;
|
|
|
|
SetFrameSubType(&hdr->frame_ctl, pattrib->subtype);
|
2015-02-20 04:11:26 +00:00
|
|
|
memcpy(hdr->addr1, pattrib->dst, ETH_ALEN); /* DA */
|
|
|
|
memcpy(hdr->addr2, pattrib->src, ETH_ALEN); /* SA */
|
|
|
|
memcpy(hdr->addr3, get_bssid(&padapter->mlmepriv), ETH_ALEN); /* RA, BSSID */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* 3 5.2. make payload */
|
2014-12-17 01:03:30 +00:00
|
|
|
ptr = pkt_start + pattrib->hdrlen;
|
|
|
|
get_random_bytes(ptr, pkt_end - ptr);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pxmitbuf->len = TXDESC_SIZE + pattrib->last_txcmdsz;
|
|
|
|
pxmitbuf->ptail += pxmitbuf->len;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return pframe;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void freeloopbackpkt(struct adapter *padapter, struct xmit_frame *pframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
struct xmit_priv *pxmitpriv;
|
|
|
|
struct xmit_buf *pxmitbuf;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pxmitpriv = &padapter->xmitpriv;
|
|
|
|
pxmitbuf = pframe->pxmitbuf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_free_xmitframe(pxmitpriv, pframe);
|
|
|
|
rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static void printdata(u8 *pbuf, u32 len)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
u32 i, val;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
for (i = 0; (i+4) <= len; i+=4) {
|
|
|
|
printk("%08X", *(u32*)(pbuf + i));
|
|
|
|
if ((i+4) & 0x1F) printk(" ");
|
|
|
|
else printk("\n");
|
2013-05-27 22:32:24 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (i < len)
|
|
|
|
{
|
2015-01-26 22:45:43 +00:00
|
|
|
#ifdef __BIG_ENDIAN
|
2014-12-17 01:03:30 +00:00
|
|
|
for (; i < len, i++)
|
|
|
|
printk("%02X", pbuf+i);
|
2015-02-20 04:11:26 +00:00
|
|
|
#else /* __LITTLE_ENDIAN */
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 str[9];
|
|
|
|
u8 n;
|
|
|
|
val = 0;
|
|
|
|
n = len - i;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&val, pbuf+i, n);
|
2014-12-17 01:03:30 +00:00
|
|
|
sprintf(str, "%08X", val);
|
|
|
|
n = (4 - n) * 2;
|
|
|
|
printk("%8s", str+n);
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* __LITTLE_ENDIAN */
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
printk("\n");
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static u8 pktcmp(struct adapter *padapter, u8 *txbuf, u32 txsz, u8 *rxbuf, u32 rxsz)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
PHAL_DATA_TYPE phal;
|
|
|
|
struct recv_stat *prxstat;
|
|
|
|
struct recv_stat report;
|
|
|
|
PRXREPORT prxreport;
|
|
|
|
u32 drvinfosize;
|
|
|
|
u32 rxpktsize;
|
|
|
|
u8 fcssize;
|
2014-12-29 02:13:24 +00:00
|
|
|
u8 ret = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
prxstat = (struct recv_stat*)rxbuf;
|
|
|
|
report.rxdw0 = le32_to_cpu(prxstat->rxdw0);
|
|
|
|
report.rxdw1 = le32_to_cpu(prxstat->rxdw1);
|
|
|
|
report.rxdw2 = le32_to_cpu(prxstat->rxdw2);
|
|
|
|
report.rxdw3 = le32_to_cpu(prxstat->rxdw3);
|
|
|
|
report.rxdw4 = le32_to_cpu(prxstat->rxdw4);
|
|
|
|
report.rxdw5 = le32_to_cpu(prxstat->rxdw5);
|
|
|
|
|
|
|
|
prxreport = (PRXREPORT)&report;
|
|
|
|
drvinfosize = prxreport->drvinfosize << 3;
|
|
|
|
rxpktsize = prxreport->pktlen;
|
|
|
|
|
|
|
|
phal = GET_HAL_DATA(padapter);
|
|
|
|
if (phal->ReceiveConfig & RCR_APPFCS) fcssize = IEEE80211_FCS_LEN;
|
|
|
|
else fcssize = 0;
|
|
|
|
|
|
|
|
if ((txsz - TXDESC_SIZE) != (rxpktsize - fcssize)) {
|
|
|
|
DBG_8192C("%s: ERROR! size not match tx/rx=%d/%d !\n",
|
|
|
|
__func__, txsz - TXDESC_SIZE, rxpktsize - fcssize);
|
2014-12-29 02:13:24 +00:00
|
|
|
ret = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
} else {
|
|
|
|
ret = _rtw_memcmp(txbuf + TXDESC_SIZE,\
|
|
|
|
rxbuf + RXDESC_SIZE + drvinfosize,\
|
|
|
|
txsz - TXDESC_SIZE);
|
2014-12-29 02:13:24 +00:00
|
|
|
if (ret == false) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_8192C("%s: ERROR! pkt content mismatch!\n", __func__);
|
|
|
|
}
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (ret == false)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
DBG_8192C("\n%s: TX PKT total=%d, desc=%d, content=%d\n",
|
|
|
|
__func__, txsz, TXDESC_SIZE, txsz - TXDESC_SIZE);
|
|
|
|
DBG_8192C("%s: TX DESC size=%d\n", __func__, TXDESC_SIZE);
|
|
|
|
printdata(txbuf, TXDESC_SIZE);
|
|
|
|
DBG_8192C("%s: TX content size=%d\n", __func__, txsz - TXDESC_SIZE);
|
|
|
|
printdata(txbuf + TXDESC_SIZE, txsz - TXDESC_SIZE);
|
|
|
|
|
|
|
|
DBG_8192C("\n%s: RX PKT read=%d offset=%d(%d,%d) content=%d\n",
|
|
|
|
__func__, rxsz, RXDESC_SIZE + drvinfosize, RXDESC_SIZE, drvinfosize, rxpktsize);
|
|
|
|
if (rxpktsize != 0)
|
|
|
|
{
|
|
|
|
DBG_8192C("%s: RX DESC size=%d\n", __func__, RXDESC_SIZE);
|
|
|
|
printdata(rxbuf, RXDESC_SIZE);
|
|
|
|
DBG_8192C("%s: RX drvinfo size=%d\n", __func__, drvinfosize);
|
|
|
|
printdata(rxbuf + RXDESC_SIZE, drvinfosize);
|
|
|
|
DBG_8192C("%s: RX content size=%d\n", __func__, rxpktsize);
|
|
|
|
printdata(rxbuf + RXDESC_SIZE + drvinfosize, rxpktsize);
|
|
|
|
} else {
|
|
|
|
DBG_8192C("%s: RX data size=%d\n", __func__, rxsz);
|
|
|
|
printdata(rxbuf, rxsz);
|
|
|
|
}
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return ret;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-16 13:54:18 +00:00
|
|
|
int lbk_thread(void * context)
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
s32 err;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter;
|
2014-12-17 01:03:30 +00:00
|
|
|
PLOOPBACKDATA ploopback;
|
|
|
|
struct xmit_frame *pxmitframe;
|
|
|
|
u32 cnt, ok, fail, headerlen;
|
|
|
|
u32 pktsize;
|
|
|
|
u32 ff_hwaddr;
|
|
|
|
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
padapter = (struct adapter *)context;
|
2014-12-17 01:03:30 +00:00
|
|
|
ploopback = padapter->ploopback;
|
|
|
|
if (ploopback == NULL) return -1;
|
|
|
|
cnt = 0;
|
|
|
|
ok = 0;
|
|
|
|
fail = 0;
|
|
|
|
|
|
|
|
daemonize("%s", "RTW_LBK_THREAD");
|
|
|
|
allow_signal(SIGTERM);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if (ploopback->size == 0) {
|
|
|
|
get_random_bytes(&pktsize, 4);
|
2015-02-20 04:11:26 +00:00
|
|
|
pktsize = (pktsize % 1535) + 1; /* 1~1535 */
|
2014-12-17 01:03:30 +00:00
|
|
|
} else
|
|
|
|
pktsize = ploopback->size;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pxmitframe = createloopbackpkt(padapter, pktsize);
|
|
|
|
if (pxmitframe == NULL) {
|
|
|
|
sprintf(ploopback->msg, "loopback FAIL! 3. create Packet FAIL!");
|
|
|
|
break;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
ploopback->txsize = TXDESC_SIZE + pxmitframe->attrib.last_txcmdsz;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(ploopback->txbuf, pxmitframe->buf_addr, ploopback->txsize);
|
2014-12-17 01:03:30 +00:00
|
|
|
ff_hwaddr = rtw_get_ff_hwaddr(pxmitframe);
|
|
|
|
cnt++;
|
|
|
|
DBG_8192C("%s: wirte port cnt=%d size=%d\n", __func__, cnt, ploopback->txsize);
|
|
|
|
pxmitframe->pxmitbuf->pdata = ploopback->txbuf;
|
|
|
|
rtw_write_port(padapter, ff_hwaddr, ploopback->txsize, (u8 *)pxmitframe->pxmitbuf);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* wait for rx pkt */
|
2014-12-17 01:03:30 +00:00
|
|
|
_rtw_down_sema(&ploopback->sema);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
err = pktcmp(padapter, ploopback->txbuf, ploopback->txsize, ploopback->rxbuf, ploopback->rxsize);
|
2014-12-29 02:13:24 +00:00
|
|
|
if (err == true)
|
2014-12-17 01:03:30 +00:00
|
|
|
ok++;
|
|
|
|
else
|
|
|
|
fail++;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
ploopback->txsize = 0;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(ploopback->txbuf, 0, 0x8000);
|
2014-12-17 01:03:30 +00:00
|
|
|
ploopback->rxsize = 0;
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(ploopback->rxbuf, 0, 0x8000);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
freeloopbackpkt(padapter, pxmitframe);
|
|
|
|
pxmitframe = NULL;
|
2013-05-27 22:32:24 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
if (signal_pending(current)) {
|
|
|
|
flush_signals(current);
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ((ploopback->bstop == true) ||
|
2014-12-17 01:03:30 +00:00
|
|
|
((ploopback->cnt != 0) && (ploopback->cnt == cnt)))
|
|
|
|
{
|
|
|
|
u32 ok_rate, fail_rate, all;
|
|
|
|
all = cnt;
|
|
|
|
ok_rate = (ok*100)/all;
|
|
|
|
fail_rate = (fail*100)/all;
|
|
|
|
sprintf(ploopback->msg,\
|
|
|
|
"loopback result: ok=%d%%(%d/%d),error=%d%%(%d/%d)",\
|
|
|
|
ok_rate, ok, all, fail_rate, fail, all);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (1);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
ploopback->bstop = true;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
thread_exit();
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void loopbackTest(struct adapter *padapter, u32 cnt, u32 size, u8* pmsg)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
PLOOPBACKDATA ploopback;
|
|
|
|
u32 len;
|
|
|
|
s32 err;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
ploopback = padapter->ploopback;
|
|
|
|
|
|
|
|
if (ploopback)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if (ploopback->bstop == false) {
|
|
|
|
ploopback->bstop = true;
|
2014-12-17 01:03:30 +00:00
|
|
|
_rtw_up_sema(&ploopback->sema);
|
|
|
|
}
|
|
|
|
len = 0;
|
|
|
|
do {
|
|
|
|
len = strlen(ploopback->msg);
|
|
|
|
if (len) break;
|
|
|
|
rtw_msleep_os(1);
|
|
|
|
} while (1);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pmsg, ploopback->msg, len+1);
|
2014-12-17 01:03:30 +00:00
|
|
|
freeLoopback(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
return;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* disable dynamic algorithm */
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
u32 DMFlag = DYNAMIC_FUNC_DISABLE;
|
|
|
|
rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8*)&DMFlag);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* create pseudo ad-hoc connection */
|
2014-12-17 01:03:30 +00:00
|
|
|
err = initpseudoadhoc(padapter);
|
|
|
|
if (err == _FAIL) {
|
|
|
|
sprintf(pmsg, "loopback FAIL! 1.1 init ad-hoc FAIL!");
|
|
|
|
return;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
err = createpseudoadhoc(padapter);
|
|
|
|
if (err == _FAIL) {
|
|
|
|
sprintf(pmsg, "loopback FAIL! 1.2 create ad-hoc master FAIL!");
|
|
|
|
return;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
err = initLoopback(padapter);
|
|
|
|
if (err) {
|
|
|
|
sprintf(pmsg, "loopback FAIL! 2. init FAIL! error code=%d", err);
|
|
|
|
return;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
ploopback = padapter->ploopback;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
ploopback->bstop = false;
|
2014-12-17 01:03:30 +00:00
|
|
|
ploopback->cnt = cnt;
|
|
|
|
ploopback->size = size;
|
|
|
|
ploopback->lbkthread = kthread_run(lbk_thread, padapter, "RTW_LBK_THREAD");
|
|
|
|
if (IS_ERR(padapter->lbkthread))
|
|
|
|
{
|
|
|
|
freeLoopback(padapter);
|
|
|
|
sprintf(pmsg, "loopback start FAIL! cnt=%d", cnt);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(pmsg, "loopback start! cnt=%d", cnt);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_MAC_LOOPBACK_DRIVER */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static int rtw_test(
|
|
|
|
struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
|
|
|
u32 len;
|
|
|
|
u8 *pbuf, *pch;
|
|
|
|
char *ptmp;
|
|
|
|
u8 *delim = ",";
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = rtw_netdev_priv(dev);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
DBG_871X("+%s\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
len = wrqu->data.length;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
pbuf = (u8*)rtw_zmalloc(len);
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pbuf == NULL) {
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: no memory!\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_from_user(pbuf, wrqu->data.pointer, len)) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_mfree(pbuf, len);
|
|
|
|
DBG_871X("%s: copy from user fail!\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_871X("%s: string=\"%s\"\n", __func__, pbuf);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
ptmp = (char*)pbuf;
|
2013-05-08 21:45:39 +00:00
|
|
|
pch = strsep(&ptmp, delim);
|
|
|
|
if ((pch == NULL) || (strlen(pch) == 0)) {
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_mfree(pbuf, len);
|
|
|
|
DBG_871X("%s: parameter error(level 1)!\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_MAC_LOOPBACK_DRIVER
|
|
|
|
if (strcmp(pch, "loopback") == 0)
|
|
|
|
{
|
|
|
|
s32 cnt = 0;
|
|
|
|
u32 size = 64;
|
|
|
|
|
|
|
|
pch = strsep(&ptmp, delim);
|
|
|
|
if ((pch == NULL) || (strlen(pch) == 0)) {
|
|
|
|
rtw_mfree(pbuf, len);
|
|
|
|
DBG_871X("%s: parameter error(level 2)!\n", __func__);
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
sscanf(pch, "%d", &cnt);
|
|
|
|
DBG_871X("%s: loopback cnt=%d\n", __func__, cnt);
|
|
|
|
|
|
|
|
pch = strsep(&ptmp, delim);
|
|
|
|
if ((pch == NULL) || (strlen(pch) == 0)) {
|
|
|
|
rtw_mfree(pbuf, len);
|
|
|
|
DBG_871X("%s: parameter error(level 2)!\n", __func__);
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
sscanf(pch, "%d", &size);
|
|
|
|
DBG_871X("%s: loopback size=%d\n", __func__, size);
|
|
|
|
|
|
|
|
loopbackTest(padapter, cnt, size, extra);
|
|
|
|
wrqu->data.length = strlen(extra) + 1;
|
|
|
|
|
|
|
|
rtw_mfree(pbuf, len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rtw_mfree(pbuf, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
static iw_handler rtw_handlers[] =
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
NULL, /* SIOCSIWCOMMIT */
|
|
|
|
rtw_wx_get_name, /* SIOCGIWNAME */
|
|
|
|
dummy, /* SIOCSIWNWID */
|
|
|
|
dummy, /* SIOCGIWNWID */
|
|
|
|
rtw_wx_set_freq, /* SIOCSIWFREQ */
|
|
|
|
rtw_wx_get_freq, /* SIOCGIWFREQ */
|
|
|
|
rtw_wx_set_mode, /* SIOCSIWMODE */
|
|
|
|
rtw_wx_get_mode, /* SIOCGIWMODE */
|
|
|
|
dummy, /* SIOCSIWSENS */
|
|
|
|
rtw_wx_get_sens, /* SIOCGIWSENS */
|
|
|
|
NULL, /* SIOCSIWRANGE */
|
|
|
|
rtw_wx_get_range, /* SIOCGIWRANGE */
|
|
|
|
rtw_wx_set_priv, /* SIOCSIWPRIV */
|
|
|
|
NULL, /* SIOCGIWPRIV */
|
|
|
|
NULL, /* SIOCSIWSTATS */
|
|
|
|
NULL, /* SIOCGIWSTATS */
|
|
|
|
dummy, /* SIOCSIWSPY */
|
|
|
|
dummy, /* SIOCGIWSPY */
|
|
|
|
NULL, /* SIOCGIWTHRSPY */
|
|
|
|
NULL, /* SIOCWIWTHRSPY */
|
|
|
|
rtw_wx_set_wap, /* SIOCSIWAP */
|
|
|
|
rtw_wx_get_wap, /* SIOCGIWAP */
|
|
|
|
rtw_wx_set_mlme, /* request MLME operation; uses struct iw_mlme */
|
|
|
|
dummy, /* SIOCGIWAPLIST -- depricated */
|
|
|
|
rtw_wx_set_scan, /* SIOCSIWSCAN */
|
|
|
|
rtw_wx_get_scan, /* SIOCGIWSCAN */
|
|
|
|
rtw_wx_set_essid, /* SIOCSIWESSID */
|
|
|
|
rtw_wx_get_essid, /* SIOCGIWESSID */
|
|
|
|
dummy, /* SIOCSIWNICKN */
|
|
|
|
rtw_wx_get_nick, /* SIOCGIWNICKN */
|
|
|
|
NULL, /* -- hole -- */
|
|
|
|
NULL, /* -- hole -- */
|
|
|
|
rtw_wx_set_rate, /* SIOCSIWRATE */
|
|
|
|
rtw_wx_get_rate, /* SIOCGIWRATE */
|
|
|
|
rtw_wx_set_rts, /* SIOCSIWRTS */
|
|
|
|
rtw_wx_get_rts, /* SIOCGIWRTS */
|
|
|
|
rtw_wx_set_frag, /* SIOCSIWFRAG */
|
|
|
|
rtw_wx_get_frag, /* SIOCGIWFRAG */
|
|
|
|
dummy, /* SIOCSIWTXPOW */
|
|
|
|
dummy, /* SIOCGIWTXPOW */
|
|
|
|
dummy, /* SIOCSIWRETRY */
|
|
|
|
rtw_wx_get_retry, /* SIOCGIWRETRY */
|
|
|
|
rtw_wx_set_enc, /* SIOCSIWENCODE */
|
|
|
|
rtw_wx_get_enc, /* SIOCGIWENCODE */
|
|
|
|
dummy, /* SIOCSIWPOWER */
|
|
|
|
rtw_wx_get_power, /* SIOCGIWPOWER */
|
|
|
|
NULL, /*---hole---*/
|
|
|
|
NULL, /*---hole---*/
|
|
|
|
rtw_wx_set_gen_ie, /* SIOCSIWGENIE */
|
|
|
|
NULL, /* SIOCGWGENIE */
|
|
|
|
rtw_wx_set_auth, /* SIOCSIWAUTH */
|
|
|
|
NULL, /* SIOCGIWAUTH */
|
|
|
|
rtw_wx_set_enc_ext, /* SIOCSIWENCODEEXT */
|
|
|
|
NULL, /* SIOCGIWENCODEEXT */
|
|
|
|
rtw_wx_set_pmkid, /* SIOCSIWPMKSA */
|
|
|
|
NULL, /*---hole---*/
|
2014-12-19 06:59:46 +00:00
|
|
|
};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static const struct iw_priv_args rtw_private_args[] = {
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x0,
|
|
|
|
IW_PRIV_TYPE_CHAR | 0x7FF, 0, "write"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x1,
|
|
|
|
IW_PRIV_TYPE_CHAR | 0x7FF,
|
|
|
|
IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "read"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x2, 0, 0, "driver_ext"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x3, 0, 0, "mp_ioctl"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x4,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x5,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setpid"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x6,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_start"
|
|
|
|
},
|
2015-02-20 04:11:26 +00:00
|
|
|
/* for PLATFORM_MT53XX */
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x7,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "get_sensitivity"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x8,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_prob_req_ie"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x9,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_assoc_req_ie"
|
|
|
|
},
|
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* for RTK_DMP_PLATFORM */
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0xA,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "channel_plan"
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0xB,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "dbg"
|
2014-12-19 06:59:46 +00:00
|
|
|
},
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0xC,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "rfw"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0xD,
|
|
|
|
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "rfr"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x10,
|
2014-12-17 01:03:30 +00:00
|
|
|
IW_PRIV_TYPE_CHAR | 1024, 0, "p2p_set"
|
2013-05-08 21:45:39 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x11,
|
2014-12-17 01:03:30 +00:00
|
|
|
IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK , "p2p_get"
|
2013-05-08 21:45:39 +00:00
|
|
|
},
|
|
|
|
{
|
2014-12-17 01:03:30 +00:00
|
|
|
SIOCIWFIRSTPRIV + 0x12, 0, 0, "NULL"
|
2013-05-19 04:28:07 +00:00
|
|
|
},
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x13,
|
|
|
|
IW_PRIV_TYPE_CHAR | 64, IW_PRIV_TYPE_CHAR | 64 , "p2p_get2"
|
2014-12-19 06:59:46 +00:00
|
|
|
},
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x14,
|
|
|
|
IW_PRIV_TYPE_CHAR | 64, 0, "tdls"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x15,
|
2014-12-17 01:03:30 +00:00
|
|
|
IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN , "tdls_get"
|
2014-12-19 06:59:46 +00:00
|
|
|
},
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x16,
|
|
|
|
IW_PRIV_TYPE_CHAR | 64, 0, "pm_set"
|
|
|
|
},
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
{SIOCIWFIRSTPRIV + 0x18, IW_PRIV_TYPE_CHAR | IFNAMSIZ , 0 , "rereg_nd_name"},
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
{SIOCIWFIRSTPRIV + 0x1A, IW_PRIV_TYPE_CHAR | 1024, 0, "efuse_set"},
|
|
|
|
{SIOCIWFIRSTPRIV + 0x1B, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"},
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
|
|
|
SIOCIWFIRSTPRIV + 0x1D,
|
|
|
|
IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test"
|
2013-05-08 21:45:39 +00:00
|
|
|
},
|
2014-12-17 01:03:30 +00:00
|
|
|
};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
static iw_handler rtw_private_handler[] =
|
2014-12-17 01:03:30 +00:00
|
|
|
{
|
2015-02-20 04:11:26 +00:00
|
|
|
rtw_wx_write32, /* 0x00 */
|
|
|
|
rtw_wx_read32, /* 0x01 */
|
|
|
|
rtw_drvext_hdl, /* 0x02 */
|
|
|
|
rtw_mp_ioctl_hdl, /* 0x03 */
|
|
|
|
|
|
|
|
/* for MM DTV platform */
|
|
|
|
rtw_get_ap_info, /* 0x04 */
|
|
|
|
|
|
|
|
rtw_set_pid, /* 0x05 */
|
|
|
|
rtw_wps_start, /* 0x06 */
|
|
|
|
|
|
|
|
/* for PLATFORM_MT53XX */
|
|
|
|
rtw_wx_get_sensitivity, /* 0x07 */
|
|
|
|
rtw_wx_set_mtk_wps_probe_ie, /* 0x08 */
|
|
|
|
rtw_wx_set_mtk_wps_ie, /* 0x09 */
|
|
|
|
|
|
|
|
/* for RTK_DMP_PLATFORM */
|
|
|
|
/* Set Channel depend on the country code */
|
|
|
|
rtw_wx_set_channel_plan, /* 0x0A */
|
|
|
|
|
|
|
|
rtw_dbg_port, /* 0x0B */
|
|
|
|
rtw_wx_write_rf, /* 0x0C */
|
|
|
|
rtw_wx_read_rf, /* 0x0D */
|
|
|
|
|
|
|
|
rtw_wx_priv_null, /* 0x0E */
|
|
|
|
rtw_wx_priv_null, /* 0x0F */
|
|
|
|
rtw_p2p_set, /* 0x10 */
|
|
|
|
rtw_p2p_get, /* 0x11 */
|
|
|
|
NULL, /* 0x12 */
|
|
|
|
rtw_p2p_get2, /* 0x13 */
|
|
|
|
|
|
|
|
rtw_tdls, /* 0x14 */
|
|
|
|
rtw_tdls_get, /* 0x15 */
|
|
|
|
|
|
|
|
rtw_pm_set, /* 0x16 */
|
|
|
|
rtw_wx_priv_null, /* 0x17 */
|
|
|
|
rtw_rereg_nd_name, /* 0x18 */
|
|
|
|
rtw_wx_priv_null, /* 0x19 */
|
|
|
|
|
|
|
|
rtw_mp_efuse_set, /* 0x1A */
|
|
|
|
rtw_mp_efuse_get, /* 0x1B */
|
|
|
|
NULL, /* 0x1C is reserved for hostapd */
|
|
|
|
rtw_test, /* 0x1D */
|
2013-05-08 21:45:39 +00:00
|
|
|
};
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
#if WIRELESS_EXT >= 17
|
2013-05-08 21:45:39 +00:00
|
|
|
static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev)
|
|
|
|
{
|
2015-03-10 16:18:03 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
|
|
|
|
struct iw_statistics *piwstats=&padapter->iwstats;
|
2014-12-17 01:03:30 +00:00
|
|
|
int tmp_level = 0;
|
|
|
|
int tmp_qual = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
int tmp_noise = 0;
|
|
|
|
|
2015-03-10 16:18:03 +00:00
|
|
|
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) != true) {
|
2013-05-08 21:45:39 +00:00
|
|
|
piwstats->qual.qual = 0;
|
|
|
|
piwstats->qual.level = 0;
|
|
|
|
piwstats->qual.noise = 0;
|
2015-03-10 16:18:03 +00:00
|
|
|
} else {
|
2014-12-17 01:03:30 +00:00
|
|
|
tmp_level = padapter->recvpriv.signal_strength;
|
|
|
|
#ifdef CONFIG_BT_COEXIST
|
|
|
|
{
|
|
|
|
u8 signal = (u8)tmp_level;
|
|
|
|
BT_SignalCompensation(padapter, &signal, NULL);
|
|
|
|
tmp_level= signal;
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_BT_COEXIST */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
tmp_qual = padapter->recvpriv.signal_qual;
|
2014-12-19 06:59:46 +00:00
|
|
|
tmp_noise =padapter->recvpriv.noise;
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
piwstats->qual.level = tmp_level;
|
|
|
|
piwstats->qual.qual = tmp_qual;
|
2013-05-08 21:45:39 +00:00
|
|
|
piwstats->qual.noise = tmp_noise;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14))
|
2015-02-20 04:11:26 +00:00
|
|
|
piwstats->qual.updated = IW_QUAL_ALL_UPDATED ;/* IW_QUAL_DBM; */
|
2014-12-17 01:03:30 +00:00
|
|
|
#else
|
|
|
|
piwstats->qual.updated = 0x0f;
|
|
|
|
#endif
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return &padapter->iwstats;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
#ifdef CONFIG_WIRELESS_EXT
|
|
|
|
struct iw_handler_def rtw_handlers_def =
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
.standard = rtw_handlers,
|
|
|
|
.num_standard = sizeof(rtw_handlers) / sizeof(iw_handler),
|
2014-12-17 01:03:30 +00:00
|
|
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) || defined(CONFIG_WEXT_PRIV)
|
2013-05-08 21:45:39 +00:00
|
|
|
.private = rtw_private_handler,
|
|
|
|
.private_args = (struct iw_priv_args *)rtw_private_args,
|
|
|
|
.num_private = sizeof(rtw_private_handler) / sizeof(iw_handler),
|
2014-12-19 06:59:46 +00:00
|
|
|
.num_private_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args),
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
|
|
|
#if WIRELESS_EXT >= 17
|
2013-05-08 21:45:39 +00:00
|
|
|
.get_wireless_stats = rtw_get_wireless_stats,
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
};
|
2014-12-17 01:03:30 +00:00
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* copy from net/wireless/wext.c start */
|
2013-05-08 21:45:39 +00:00
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
/*
|
|
|
|
* Calculate size of private arguments
|
|
|
|
*/
|
|
|
|
static const char iw_priv_type_size[] = {
|
2014-12-17 01:03:30 +00:00
|
|
|
0, /* IW_PRIV_TYPE_NONE */
|
|
|
|
1, /* IW_PRIV_TYPE_BYTE */
|
|
|
|
1, /* IW_PRIV_TYPE_CHAR */
|
|
|
|
0, /* Not defined */
|
|
|
|
sizeof(__u32), /* IW_PRIV_TYPE_INT */
|
|
|
|
sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */
|
|
|
|
sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */
|
|
|
|
0, /* Not defined */
|
2013-05-08 21:45:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int get_priv_size(__u16 args)
|
|
|
|
{
|
|
|
|
int num = args & IW_PRIV_SIZE_MASK;
|
|
|
|
int type = (args & IW_PRIV_TYPE_MASK) >> 12;
|
|
|
|
|
|
|
|
return num * iw_priv_type_size[type];
|
|
|
|
}
|
2015-02-20 04:11:26 +00:00
|
|
|
/* copy from net/wireless/wext.c end */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_data)
|
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
u8 *input = NULL;
|
|
|
|
u32 input_len = 0;
|
|
|
|
const char delim[] = " ";
|
|
|
|
u8 *output = NULL;
|
|
|
|
u32 output_len = 0;
|
|
|
|
u32 count = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
u8 *buffer= NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 buffer_len = 0;
|
|
|
|
char *ptr = NULL;
|
2015-02-20 04:11:26 +00:00
|
|
|
u8 cmdname[17] = {0}; /* IFNAMSIZ+1 */
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 cmdlen;
|
|
|
|
s32 len;
|
|
|
|
u8 *extra = NULL;
|
|
|
|
u32 extra_size = 0;
|
|
|
|
|
|
|
|
s32 k;
|
|
|
|
const iw_handler *priv; /* Private ioctl */
|
|
|
|
const struct iw_priv_args *priv_args; /* Private ioctl description */
|
2014-12-17 01:03:30 +00:00
|
|
|
u32 num_priv; /* Number of ioctl */
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 num_priv_args; /* Number of descriptions */
|
|
|
|
iw_handler handler;
|
|
|
|
int temp;
|
|
|
|
int subcmd = 0; /* sub-ioctl index */
|
|
|
|
int offset = 0; /* Space for sub-ioctl index */
|
|
|
|
|
|
|
|
union iwreq_data wdata;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&wdata, wrq_data, sizeof(wdata));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
input_len = wdata.data.length;
|
2015-05-15 20:20:51 +00:00
|
|
|
if (input_len == 0)
|
|
|
|
return -EFAULT;
|
2013-05-08 21:45:39 +00:00
|
|
|
input = rtw_zmalloc(input_len);
|
|
|
|
if (NULL == input)
|
|
|
|
return -ENOMEM;
|
|
|
|
if (copy_from_user(input, wdata.data.pointer, input_len)) {
|
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
ptr = input;
|
|
|
|
len = input_len;
|
|
|
|
|
|
|
|
sscanf(ptr, "%16s", cmdname);
|
|
|
|
cmdlen = strlen(cmdname);
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_8192C("%s: cmd=%s\n", __func__, cmdname);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-20 04:11:26 +00:00
|
|
|
/* skip command string */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (cmdlen > 0)
|
2015-02-20 04:11:26 +00:00
|
|
|
cmdlen += 1; /* skip one space */
|
2013-05-08 21:45:39 +00:00
|
|
|
ptr += cmdlen;
|
|
|
|
len -= cmdlen;
|
2014-12-17 01:03:30 +00:00
|
|
|
DBG_8192C("%s: parameters=%s\n", __func__, ptr);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
priv = rtw_private_handler;
|
|
|
|
priv_args = rtw_private_args;
|
2014-12-17 01:03:30 +00:00
|
|
|
num_priv = sizeof(rtw_private_handler) / sizeof(iw_handler);
|
2013-05-08 21:45:39 +00:00
|
|
|
num_priv_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args);
|
|
|
|
|
|
|
|
if (num_priv_args == 0) {
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Search the correct ioctl */
|
|
|
|
k = -1;
|
2015-08-15 18:04:12 +00:00
|
|
|
while ((++k < num_priv_args) && strcmp(priv_args[k].name, cmdname));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* If not found... */
|
|
|
|
if (k == num_priv_args) {
|
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Watch out for sub-ioctls ! */
|
2014-12-17 01:03:30 +00:00
|
|
|
if (priv_args[k].cmd < SIOCDEVPRIVATE)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
int j = -1;
|
|
|
|
|
|
|
|
/* Find the matching *real* ioctl */
|
|
|
|
while ((++j < num_priv_args) && ((priv_args[j].name[0] != '\0') ||
|
|
|
|
(priv_args[j].set_args != priv_args[k].set_args) ||
|
|
|
|
(priv_args[j].get_args != priv_args[k].get_args)));
|
|
|
|
|
|
|
|
/* If not found... */
|
|
|
|
if (j == num_priv_args) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save sub-ioctl number */
|
|
|
|
subcmd = priv_args[k].cmd;
|
|
|
|
/* Reserve one int (simplify alignment issues) */
|
|
|
|
offset = sizeof(__u32);
|
|
|
|
/* Use real ioctl definition from now on */
|
|
|
|
k = j;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer = rtw_zmalloc(4096);
|
|
|
|
if (NULL == buffer) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we have to set some data */
|
|
|
|
if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
(priv_args[k].set_args & IW_PRIV_SIZE_MASK))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *str;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK)
|
|
|
|
{
|
|
|
|
case IW_PRIV_TYPE_BYTE:
|
|
|
|
/* Fetch args */
|
|
|
|
count = 0;
|
|
|
|
do {
|
|
|
|
str = strsep(&ptr, delim);
|
|
|
|
if (NULL == str) break;
|
|
|
|
sscanf(str, "%i", &temp);
|
|
|
|
buffer[count++] = (u8)temp;
|
|
|
|
} while (1);
|
|
|
|
buffer_len = count;
|
|
|
|
|
|
|
|
/* Number of args to fetch */
|
|
|
|
wdata.data.length = count;
|
2013-05-08 21:45:39 +00:00
|
|
|
if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK))
|
|
|
|
wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK;
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IW_PRIV_TYPE_INT:
|
|
|
|
/* Fetch args */
|
|
|
|
count = 0;
|
|
|
|
do {
|
|
|
|
str = strsep(&ptr, delim);
|
|
|
|
if (NULL == str) break;
|
|
|
|
sscanf(str, "%i", &temp);
|
|
|
|
((s32*)buffer)[count++] = (s32)temp;
|
|
|
|
} while (1);
|
|
|
|
buffer_len = count * sizeof(s32);
|
|
|
|
|
|
|
|
/* Number of args to fetch */
|
|
|
|
wdata.data.length = count;
|
|
|
|
if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK))
|
|
|
|
wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IW_PRIV_TYPE_CHAR:
|
|
|
|
if (len > 0)
|
|
|
|
{
|
|
|
|
/* Size of the string to fetch */
|
|
|
|
wdata.data.length = len;
|
|
|
|
if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK))
|
|
|
|
wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK;
|
|
|
|
|
|
|
|
/* Fetch string */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(buffer, ptr, wdata.data.length);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wdata.data.length = 1;
|
|
|
|
buffer[0] = '\0';
|
|
|
|
}
|
|
|
|
buffer_len = wdata.data.length;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DBG_8192C("%s: Not yet implemented...\n", __func__);
|
|
|
|
err = -1;
|
|
|
|
goto exit;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
(wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK)))
|
|
|
|
{
|
|
|
|
DBG_8192C("%s: The command %s needs exactly %d argument(s)...\n",
|
|
|
|
__func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK);
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -EINVAL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
} /* if args to set */
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
wdata.data.length = 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Those two tests are important. They define how the driver
|
|
|
|
* will have to handle the data */
|
|
|
|
if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
/* First case : all SET args fit within wrq */
|
|
|
|
if (offset)
|
|
|
|
wdata.mode = subcmd;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset);
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
if ((priv_args[k].set_args == 0) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
(priv_args[k].get_args & IW_PRIV_SIZE_FIXED) &&
|
|
|
|
(get_priv_size(priv_args[k].get_args) <= IFNAMSIZ))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
/* Second case : no SET args, GET args fit within wrq */
|
|
|
|
if (offset)
|
|
|
|
wdata.mode = subcmd;
|
2014-12-17 01:03:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
/* Third case : args won't fit in wrq, or variable number of args */
|
|
|
|
if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) {
|
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
wdata.data.flags = subcmd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
rtw_mfree(input, input_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
input = NULL;
|
|
|
|
|
|
|
|
extra_size = 0;
|
2014-12-17 01:03:30 +00:00
|
|
|
if (IW_IS_SET(priv_args[k].cmd))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
/* Size of set arguments */
|
|
|
|
extra_size = get_priv_size(priv_args[k].set_args);
|
|
|
|
|
|
|
|
/* Does it fits in iwr ? */
|
|
|
|
if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
((extra_size + offset) <= IFNAMSIZ))
|
2013-05-08 21:45:39 +00:00
|
|
|
extra_size = 0;
|
|
|
|
} else {
|
|
|
|
/* Size of get arguments */
|
|
|
|
extra_size = get_priv_size(priv_args[k].get_args);
|
|
|
|
|
|
|
|
/* Does it fits in iwr ? */
|
|
|
|
if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
(extra_size <= IFNAMSIZ))
|
2013-05-08 21:45:39 +00:00
|
|
|
extra_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (extra_size == 0) {
|
2014-12-17 01:03:30 +00:00
|
|
|
extra = (u8*)&wdata;
|
|
|
|
rtw_mfree(buffer, 4096);
|
2013-05-08 21:45:39 +00:00
|
|
|
buffer = NULL;
|
2014-12-17 01:03:30 +00:00
|
|
|
} else
|
2013-05-08 21:45:39 +00:00
|
|
|
extra = buffer;
|
|
|
|
|
|
|
|
handler = priv[priv_args[k].cmd - SIOCIWFIRSTPRIV];
|
|
|
|
err = handler(dev, NULL, &wdata, extra);
|
|
|
|
|
|
|
|
/* If we have to get some data */
|
|
|
|
if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
(priv_args[k].get_args & IW_PRIV_SIZE_MASK))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
int j;
|
|
|
|
int n = 0; /* number of args */
|
|
|
|
u8 str[20] = {0};
|
|
|
|
|
|
|
|
/* Check where is the returned data */
|
|
|
|
if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) &&
|
2014-12-17 01:03:30 +00:00
|
|
|
(get_priv_size(priv_args[k].get_args) <= IFNAMSIZ))
|
2013-05-08 21:45:39 +00:00
|
|
|
n = priv_args[k].get_args & IW_PRIV_SIZE_MASK;
|
|
|
|
else
|
|
|
|
n = wdata.data.length;
|
|
|
|
|
|
|
|
output = rtw_zmalloc(4096);
|
|
|
|
if (NULL == output) {
|
|
|
|
err = -ENOMEM;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
|
|
|
switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK)
|
|
|
|
{
|
|
|
|
case IW_PRIV_TYPE_BYTE:
|
|
|
|
/* Display args */
|
|
|
|
for (j = 0; j < n; j++)
|
|
|
|
{
|
|
|
|
sprintf(str, "%d ", extra[j]);
|
|
|
|
len = strlen(str);
|
|
|
|
output_len = strlen(output);
|
|
|
|
if ((output_len + len + 1) > 4096) {
|
|
|
|
err = -E2BIG;
|
|
|
|
goto exit;
|
|
|
|
}
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(output+output_len, str, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IW_PRIV_TYPE_INT:
|
|
|
|
/* Display args */
|
|
|
|
for (j = 0; j < n; j++)
|
|
|
|
{
|
|
|
|
sprintf(str, "%d ", ((__s32*)extra)[j]);
|
|
|
|
len = strlen(str);
|
|
|
|
output_len = strlen(output);
|
|
|
|
if ((output_len + len + 1) > 4096) {
|
|
|
|
err = -E2BIG;
|
|
|
|
goto exit;
|
|
|
|
}
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(output+output_len, str, len);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IW_PRIV_TYPE_CHAR:
|
|
|
|
/* Display args */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(output, extra, n);
|
2014-12-17 01:03:30 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DBG_8192C("%s: Not yet implemented...\n", __func__);
|
|
|
|
err = -1;
|
|
|
|
goto exit;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
output_len = strlen(output) + 1;
|
|
|
|
wrq_data->data.length = output_len;
|
|
|
|
if (copy_to_user(wrq_data->data.pointer, output, output_len)) {
|
|
|
|
err = -EFAULT;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
} /* if args to set */
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
wrq_data->data.length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2014-12-17 01:03:30 +00:00
|
|
|
if (input)
|
|
|
|
rtw_mfree(input, input_len);
|
|
|
|
if (buffer)
|
|
|
|
rtw_mfree(buffer, 4096);
|
|
|
|
if (output)
|
|
|
|
rtw_mfree(output, 4096);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <rtw_android.h>
|
|
|
|
int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
|
|
|
{
|
|
|
|
struct iwreq *wrq = (struct iwreq *)rq;
|
2014-12-17 01:03:30 +00:00
|
|
|
int ret=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-17 01:03:30 +00:00
|
|
|
switch (cmd)
|
|
|
|
{
|
|
|
|
case RTL_IOCTL_WPA_SUPPLICANT:
|
|
|
|
ret = wpa_supplicant_ioctl(dev, &wrq->u.data);
|
|
|
|
break;
|
|
|
|
#ifdef CONFIG_AP_MODE
|
|
|
|
case RTL_IOCTL_HOSTAPD:
|
|
|
|
ret = rtw_hostapd_ioctl(dev, &wrq->u.data);
|
|
|
|
break;
|
|
|
|
#ifdef CONFIG_NO_WIRELESS_HANDLERS
|
|
|
|
case SIOCSIWMODE:
|
|
|
|
ret = rtw_wx_set_mode(dev, NULL, &wrq->u, NULL);
|
|
|
|
break;
|
|
|
|
#endif
|
2015-02-20 04:11:26 +00:00
|
|
|
#endif /* CONFIG_AP_MODE */
|
2014-12-17 01:03:30 +00:00
|
|
|
case SIOCDEVPRIVATE:
|
|
|
|
ret = rtw_ioctl_wext_private(dev, &wrq->u);
|
|
|
|
break;
|
|
|
|
case (SIOCDEVPRIVATE+1):
|
|
|
|
ret = rtw_android_priv_cmd(dev, rq, cmd);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-17 01:03:30 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|