提交 2865d42c 编写于 作者: L Larry Finger

staging: r8712u: Add the new driver to the mainline kernel

This code is for a completely new version of the Realtek 8192 USB devices
such as the D-Link DWA-130. The Realtek code, which was originally for
Linux, Windows XP and Windows CE, has been stripped of all code not needed
for Linux. In addition, only one additional configuration variable, which
enables AP mode, remains.
Signed-off-by: NLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: NFlorian Schilhabel <florian.c.schilhabel@googlemail.com>
Tested-by: NFrederic Leroy <fredo@starox.org>
上级 763008c4
......@@ -79,6 +79,8 @@ source "drivers/staging/rtl8192u/Kconfig"
source "drivers/staging/rtl8192e/Kconfig"
source "drivers/staging/rtl8712/Kconfig"
source "drivers/staging/frontier/Kconfig"
source "drivers/staging/dream/Kconfig"
......
......@@ -23,6 +23,7 @@ obj-$(CONFIG_R8187SE) += rtl8187se/
obj-$(CONFIG_RTL8192SU) += rtl8192su/
obj-$(CONFIG_RTL8192U) += rtl8192u/
obj-$(CONFIG_RTL8192E) += rtl8192e/
obj-$(CONFIG_R8712U) += rtl8712/
obj-$(CONFIG_SPECTRA) += spectra/
obj-$(CONFIG_TRANZPORT) += frontier/
obj-$(CONFIG_DREAM) += dream/
......
config R8712U
tristate "RealTek RTL8712U (RTL8192SU) Wireless LAN NIC driver"
depends on WLAN && USB
select WIRELESS_EXT
select WEXT_PRIV
default N
---help---
This option adds the Realtek RTL8712 USB device such as the D-Link DWA-130.
If built as a module, it will be called r8712u.
config R8712_AP
bool "Realtek RTL8712U AP code"
depends on R8712U
default N
---help---
This option allows the Realtek RTL8712 USB device to be an Access Point.
r8712u-objs := \
rtl871x_cmd.o \
rtl8712_cmd.o \
rtl871x_security.o \
rtl871x_eeprom.o \
rtl8712_efuse.o \
hal_init.o \
usb_halinit.o \
usb_ops.o \
usb_ops_linux.o \
rtl871x_io.o \
rtl8712_io.o \
rtl871x_ioctl_linux.o \
rtl871x_ioctl_rtl.o \
rtl871x_ioctl_set.o \
rtl8712_led.o \
rtl871x_mlme.o \
ieee80211.o \
rtl871x_mp_ioctl.o \
rtl871x_mp.o \
mlme_linux.o \
recv_linux.o \
xmit_linux.o \
usb_intf.o \
os_intfs.o \
rtl871x_pwrctrl.o \
rtl8712_recv.o \
rtl871x_recv.o \
rtl871x_sta_mgt.o \
rtl871x_xmit.o \
rtl8712_xmit.o
obj-$(CONFIG_R8712U) := r8712u.o
#ifndef __BASIC_TYPES_H__
#define __BASIC_TYPES_H__
#define SUCCESS 0
#define FAIL (-1)
#include <linux/types.h>
#define SIZE_T __kernel_size_t
#define sint signed int
#define FIELD_OFFSET(s, field) ((addr_t)&((s *)(0))->field)
/* Should we extend this to be host_addr_t and target_addr_t for case:
* host : x86_64
* target : mips64
*/
#define addr_t unsigned long
#define MEM_ALIGNMENT_OFFSET (sizeof(SIZE_T))
#define MEM_ALIGNMENT_PADDING (sizeof(SIZE_T) - 1)
#endif /*__BASIC_TYPES_H__*/
#ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H
#define _LINUX_BYTEORDER_BIG_ENDIAN_H
#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN 4321
#endif
#ifndef __BIG_ENDIAN_BITFIELD
#define __BIG_ENDIAN_BITFIELD
#endif
#include "swab.h"
#define __constant_htonl(x) ((__u32)(x))
#define __constant_ntohl(x) ((__u32)(x))
#define __constant_htons(x) ((__u16)(x))
#define __constant_ntohs(x) ((__u16)(x))
#define __constant_cpu_to_le64(x) ___constant_swab64((x))
#define __constant_le64_to_cpu(x) ___constant_swab64((x))
#define __constant_cpu_to_le32(x) ___constant_swab32((x))
#define __constant_le32_to_cpu(x) ___constant_swab32((x))
#define __constant_cpu_to_le16(x) ___constant_swab16((x))
#define __constant_le16_to_cpu(x) ___constant_swab16((x))
#define __constant_cpu_to_be64(x) ((__u64)(x))
#define __constant_be64_to_cpu(x) ((__u64)(x))
#define __constant_cpu_to_be32(x) ((__u32)(x))
#define __constant_be32_to_cpu(x) ((__u32)(x))
#define __constant_cpu_to_be16(x) ((__u16)(x))
#define __constant_be16_to_cpu(x) ((__u16)(x))
#define __cpu_to_le64(x) __swab64((x))
#define __le64_to_cpu(x) __swab64((x))
#define __cpu_to_le32(x) __swab32((x))
#define __le32_to_cpu(x) __swab32((x))
#define __cpu_to_le16(x) __swab16((x))
#define __le16_to_cpu(x) __swab16((x))
#define __cpu_to_be64(x) ((__u64)(x))
#define __be64_to_cpu(x) ((__u64)(x))
#define __cpu_to_be32(x) ((__u32)(x))
#define __be32_to_cpu(x) ((__u32)(x))
#define __cpu_to_be16(x) ((__u16)(x))
#define __be16_to_cpu(x) ((__u16)(x))
#define __cpu_to_le64p(x) __swab64p((x))
#define __le64_to_cpup(x) __swab64p((x))
#define __cpu_to_le32p(x) __swab32p((x))
#define __le32_to_cpup(x) __swab32p((x))
#define __cpu_to_le16p(x) __swab16p((x))
#define __le16_to_cpup(x) __swab16p((x))
#define __cpu_to_be64p(x) (*(__u64 *)(x))
#define __be64_to_cpup(x) (*(__u64 *)(x))
#define __cpu_to_be32p(x) (*(__u32 *)(x))
#define __be32_to_cpup(x) (*(__u32 *)(x))
#define __cpu_to_be16p(x) (*(__u16 *)(x))
#define __be16_to_cpup(x) (*(__u16 *)(x))
#define __cpu_to_le64s(x) __swab64s((x))
#define __le64_to_cpus(x) __swab64s((x))
#define __cpu_to_le32s(x) __swab32s((x))
#define __le32_to_cpus(x) __swab32s((x))
#define __cpu_to_le16s(x) __swab16s((x))
#define __le16_to_cpus(x) __swab16s((x))
#define __cpu_to_be64s(x) do {} while (0)
#define __be64_to_cpus(x) do {} while (0)
#define __cpu_to_be32s(x) do {} while (0)
#define __be32_to_cpus(x) do {} while (0)
#define __cpu_to_be16s(x) do {} while (0)
#define __be16_to_cpus(x) do {} while (0)
#include "generic.h"
#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
/*---------------------------------------------------------------------
For type defines and data structure defines
-----------------------------------------------------------------------*/
#ifndef __DRV_TYPES_H__
#define __DRV_TYPES_H__
struct _adapter;
#include "osdep_service.h"
#include "wlan_bssdef.h"
#include "rtl8712_spec.h"
#include "rtl8712_hal.h"
enum _NIC_VERSION {
RTL8711_NIC,
RTL8712_NIC,
RTL8713_NIC,
RTL8716_NIC
};
struct _adapter;
struct qos_priv {
/* bit mask option: u-apsd, s-apsd, ts, block ack... */
unsigned int qos_option;
};
#include "rtl871x_ht.h"
#include "rtl871x_cmd.h"
#include "wlan_bssdef.h"
#include "rtl871x_xmit.h"
#include "rtl871x_recv.h"
#include "rtl871x_security.h"
#include "rtl871x_pwrctrl.h"
#include "rtl871x_io.h"
#include "rtl871x_eeprom.h"
#include "sta_info.h"
#include "rtl871x_mlme.h"
#include "rtl871x_mp.h"
#include "rtl871x_debug.h"
#include "rtl871x_rf.h"
#include "rtl871x_event.h"
#include "rtl871x_led.h"
#define SPEC_DEV_ID_NONE BIT(0)
#define SPEC_DEV_ID_DISABLE_HT BIT(1)
#define SPEC_DEV_ID_ENABLE_PS BIT(2)
struct specific_device_id {
u32 flags;
u16 idVendor;
u16 idProduct;
};
struct registry_priv {
u8 chip_version;
u8 rfintfs;
u8 lbkmode;
u8 hci;
u8 network_mode; /*infra, ad-hoc, auto*/
struct ndis_802_11_ssid ssid;
u8 channel;/* ad-hoc support requirement */
u8 wireless_mode;/* A, B, G, auto */
u8 vrtl_carrier_sense; /*Enable, Disable, Auto*/
u8 vcs_type;/*RTS/CTS, CTS-to-self*/
u16 rts_thresh;
u16 frag_thresh;
u8 preamble;/*long, short, auto*/
u8 scan_mode;/*active, passive*/
u8 adhoc_tx_pwr;
u8 soft_ap;
u8 smart_ps;
u8 power_mgnt;
u8 radio_enable;
u8 long_retry_lmt;
u8 short_retry_lmt;
u16 busy_thresh;
u8 ack_policy;
u8 mp_mode;
u8 software_encrypt;
u8 software_decrypt;
/* UAPSD */
u8 wmm_enable;
u8 uapsd_enable;
u8 uapsd_max_sp;
u8 uapsd_acbk_en;
u8 uapsd_acbe_en;
u8 uapsd_acvi_en;
u8 uapsd_acvo_en;
struct wlan_bssid_ex dev_network;
u8 ht_enable;
u8 cbw40_enable;
u8 ampdu_enable;/*for tx*/
u8 rf_config ;
u8 low_power ;
};
/* For registry parameters */
#define RGTRY_OFT(field) ((addr_t)FIELD_OFFSET(struct registry_priv, field))
#define RGTRY_SZ(field) sizeof(((struct registry_priv *)0)->field)
#define BSSID_OFT(field) ((addr_t)FIELD_OFFSET(struct ndis_wlan_bssid_ex, \
field))
#define BSSID_SZ(field) sizeof(((struct ndis_wlan_bssid_ex *)0)->field)
struct dvobj_priv {
struct _adapter *padapter;
u32 nr_endpoint;
u8 ishighspeed;
uint(*inirp_init)(struct _adapter *adapter);
uint(*inirp_deinit)(struct _adapter *adapter);
struct semaphore usb_suspend_sema;
struct usb_device *pusbdev;
};
struct _adapter {
struct dvobj_priv dvobjpriv;
struct mlme_priv mlmepriv;
struct cmd_priv cmdpriv;
struct evt_priv evtpriv;
struct io_queue *pio_queue;
struct xmit_priv xmitpriv;
struct recv_priv recvpriv;
struct sta_priv stapriv;
struct security_priv securitypriv;
struct registry_priv registrypriv;
struct wlan_acl_pool acl_list;
struct pwrctrl_priv pwrctrlpriv;
struct eeprom_priv eeprompriv;
struct hal_priv halpriv;
struct led_priv ledpriv;
struct mp_priv mppriv;
s32 bDriverStopped;
s32 bSurpriseRemoved;
u32 IsrContent;
u32 ImrContent;
u8 EepromAddressSize;
u8 hw_init_completed;
struct task_struct *cmdThread;
pid_t evtThread;
struct task_struct *xmitThread;
pid_t recvThread;
uint(*dvobj_init)(struct _adapter *adapter);
void (*dvobj_deinit)(struct _adapter *adapter);
struct net_device *pnetdev;
int bup;
struct net_device_stats stats;
struct iw_statistics iwstats;
int pid; /*process id from UI*/
};
static inline u8 *myid(struct eeprom_priv *peepriv)
{
return peepriv->mac_addr;
}
u8 r8712_usb_hal_bus_init(struct _adapter *adapter);
#endif /*__DRV_TYPES_H__*/
#ifndef __INC_ETHERNET_H
#define __INC_ETHERNET_H
#define ETHERNET_ADDRESS_LENGTH 6 /*!< Ethernet Address Length*/
#define ETHERNET_HEADER_SIZE 14 /*!< Ethernet Header Length*/
#define LLC_HEADER_SIZE 6 /*!< LLC Header Length*/
#define TYPE_LENGTH_FIELD_SIZE 2 /*!< Type/Length Size*/
#define MINIMUM_ETHERNET_PACKET_SIZE 60 /*!< Min Ethernet Packet Size*/
#define MAXIMUM_ETHERNET_PACKET_SIZE 1514 /*!< Max Ethernet Packet Size*/
/*!< Is Multicast Address? */
#define RT_ETH_IS_MULTICAST(_pAddr) ((((u8 *)(_pAddr))[0]&0x01) != 0)
/*!< Is Broadcast Address? */
#define RT_ETH_IS_BROADCAST(_pAddr) ( \
((u8 *)(_pAddr))[0] == 0xff && \
((u8 *)(_pAddr))[1] == 0xff && \
((u8 *)(_pAddr))[2] == 0xff && \
((u8 *)(_pAddr))[3] == 0xff && \
((u8 *)(_pAddr))[4] == 0xff && \
((u8 *)(_pAddr))[5] == 0xff)
#endif /* #ifndef __INC_ETHERNET_H */
此差异已折叠。
#ifndef _LINUX_BYTEORDER_GENERIC_H
#define _LINUX_BYTEORDER_GENERIC_H
/*
* linux/byteorder_generic.h
* Generic Byte-reordering support
*
* Francois-Rene Rideau <fare@tunes.org> 19970707
* gathered all the good ideas from all asm-foo/byteorder.h into one file,
* cleaned them up.
* I hope it is compliant with non-GCC compilers.
* I decided to put __BYTEORDER_HAS_U64__ in byteorder.h,
* because I wasn't sure it would be ok to put it in types.h
* Upgraded it to 2.1.43
* Francois-Rene Rideau <fare@tunes.org> 19971012
* Upgraded it to 2.1.57
* to please Linus T., replaced huge #ifdef's between little/big endian
* by nestedly #include'd files.
* Francois-Rene Rideau <fare@tunes.org> 19971205
* Made it to 2.1.71; now a facelift:
* Put files under include/linux/byteorder/
* Split swab from generic support.
*
* TODO:
* = Regular kernel maintainers could also replace all these manual
* byteswap macros that remain, disseminated among drivers,
* after some grep or the sources...
* = Linus might want to rename all these macros and files to fit his taste,
* to fit his personal naming scheme.
* = it seems that a few drivers would also appreciate
* nybble swapping support...
* = every architecture could add their byteswap macro in asm/byteorder.h
* see how some architectures already do (i386, alpha, ppc, etc)
* = cpu_to_beXX and beXX_to_cpu might some day need to be well
* distinguished throughout the kernel. This is not the case currently,
* since little endian, big endian, and pdp endian machines needn't it.
* But this might be the case for, say, a port of Linux to 20/21 bit
* architectures (and F21 Linux addict around?).
*/
/*
* The following macros are to be defined by <asm/byteorder.h>:
*
* Conversion of long and short int between network and host format
* ntohl(__u32 x)
* ntohs(__u16 x)
* htonl(__u32 x)
* htons(__u16 x)
* It seems that some programs (which? where? or perhaps a standard? POSIX?)
* might like the above to be functions, not macros (why?).
* if that's true, then detect them, and take measures.
* Anyway, the measure is: define only ___ntohl as a macro instead,
* and in a separate file, have
* unsigned long inline ntohl(x){return ___ntohl(x);}
*
* The same for constant arguments
* __constant_ntohl(__u32 x)
* __constant_ntohs(__u16 x)
* __constant_htonl(__u32 x)
* __constant_htons(__u16 x)
*
* Conversion of XX-bit integers (16- 32- or 64-)
* between native CPU format and little/big endian format
* 64-bit stuff only defined for proper architectures
* cpu_to_[bl]eXX(__uXX x)
* [bl]eXX_to_cpu(__uXX x)
*
* The same, but takes a pointer to the value to convert
* cpu_to_[bl]eXXp(__uXX x)
* [bl]eXX_to_cpup(__uXX x)
*
* The same, but change in situ
* cpu_to_[bl]eXXs(__uXX x)
* [bl]eXX_to_cpus(__uXX x)
*
* See asm-foo/byteorder.h for examples of how to provide
* architecture-optimized versions
*
*/
/*
* inside the kernel, we can use nicknames;
* outside of it, we must avoid POSIX namespace pollution...
*/
#define cpu_to_le64 __cpu_to_le64
#define le64_to_cpu __le64_to_cpu
#define cpu_to_le32 __cpu_to_le32
#define le32_to_cpu __le32_to_cpu
#define cpu_to_le16 __cpu_to_le16
#define le16_to_cpu __le16_to_cpu
#define cpu_to_be64 __cpu_to_be64
#define be64_to_cpu __be64_to_cpu
#define cpu_to_be32 __cpu_to_be32
#define be32_to_cpu __be32_to_cpu
#define cpu_to_be16 __cpu_to_be16
#define be16_to_cpu __be16_to_cpu
#define cpu_to_le64p __cpu_to_le64p
#define le64_to_cpup __le64_to_cpup
#define cpu_to_le32p __cpu_to_le32p
#define le32_to_cpup __le32_to_cpup
#define cpu_to_le16p __cpu_to_le16p
#define le16_to_cpup __le16_to_cpup
#define cpu_to_be64p __cpu_to_be64p
#define be64_to_cpup __be64_to_cpup
#define cpu_to_be32p __cpu_to_be32p
#define be32_to_cpup __be32_to_cpup
#define cpu_to_be16p __cpu_to_be16p
#define be16_to_cpup __be16_to_cpup
#define cpu_to_le64s __cpu_to_le64s
#define le64_to_cpus __le64_to_cpus
#define cpu_to_le32s __cpu_to_le32s
#define le32_to_cpus __le32_to_cpus
#define cpu_to_le16s __cpu_to_le16s
#define le16_to_cpus __le16_to_cpus
#define cpu_to_be64s __cpu_to_be64s
#define be64_to_cpus __be64_to_cpus
#define cpu_to_be32s __cpu_to_be32s
#define be32_to_cpus __be32_to_cpus
#define cpu_to_be16s __cpu_to_be16s
#define be16_to_cpus __be16_to_cpus
/*
* Handle ntohl and suches. These have various compatibility
* issues - like we want to give the prototype even though we
* also have a macro for them in case some strange program
* wants to take the address of the thing or something..
*
* Note that these used to return a "long" in libc5, even though
* long is often 64-bit these days.. Thus the casts.
*
* They have to be macros in order to do the constant folding
* correctly - if the argument passed into a inline function
* it is no longer constant according to gcc..
*/
#undef ntohl
#undef ntohs
#undef htonl
#undef htons
/*
* Do the prototypes. Somebody might want to take the
* address or some such sick thing..
*/
extern __u32 ntohl(__u32);
extern __u32 htonl(__u32);
extern unsigned short int ntohs(unsigned short int);
extern unsigned short int htons(unsigned short int);
#endif /* _LINUX_BYTEORDER_GENERIC_H */
/******************************************************************************
* hal_init.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* 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
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>.
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _HAL_INIT_C_
#include "osdep_service.h"
#include "drv_types.h"
#include "rtl871x_byteorder.h"
#include "farray.h"
#define FWBUFF_ALIGN_SZ 512
#define MAX_DUMP_FWSZ 49152 /*default = 49152 (48k)*/
static u32 rtl871x_open_fw(struct _adapter *padapter, void **pphfwfile_hdl,
const u8 **ppmappedfw)
{
u32 len;
*ppmappedfw = f_array;
len = sizeof(f_array);
return len;
}
static void fill_fwpriv(struct _adapter *padapter, struct fw_priv *pfwpriv)
{
struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
struct registry_priv *pregpriv = &padapter->registrypriv;
memset(pfwpriv, 0, sizeof(struct fw_priv));
/* todo: check if needs endian conversion */
pfwpriv->hci_sel = RTL8712_HCI_TYPE_72USB;
pfwpriv->usb_ep_num = (u8)pdvobj->nr_endpoint;
pfwpriv->bw_40MHz_en = pregpriv->cbw40_enable;
switch (pregpriv->rf_config) {
case RTL8712_RF_1T1R:
pfwpriv->rf_config = RTL8712_RFC_1T1R;
break;
case RTL8712_RF_2T2R:
pfwpriv->rf_config = RTL8712_RFC_2T2R;
break;
case RTL8712_RF_1T2R:
default:
pfwpriv->rf_config = RTL8712_RFC_1T2R;
}
pfwpriv->mp_mode = (pregpriv->mp_mode == 1) ? 1 : 0;
pfwpriv->vcsType = pregpriv->vrtl_carrier_sense; /* 0:off 1:on 2:auto */
pfwpriv->vcsMode = pregpriv->vcs_type; /* 1:RTS/CTS 2:CTS to self */
pfwpriv->turboMode = 1; /* default enable it */
pfwpriv->lowPowerMode = pregpriv->low_power;
}
static void update_fwhdr(struct fw_hdr *pfwhdr, const u8 *pmappedfw)
{
pfwhdr->signature = le16_to_cpu(*(u16 *)pmappedfw);
pfwhdr->version = le16_to_cpu(*(u16 *)(pmappedfw+2));
/* define the size of boot loader */
pfwhdr->dmem_size = le32_to_cpu(*(uint *)(pmappedfw+4));
/* define the size of FW in IMEM */
pfwhdr->img_IMEM_size = le32_to_cpu(*(uint *)(pmappedfw+8));
/* define the size of FW in SRAM */
pfwhdr->img_SRAM_size = le32_to_cpu(*(uint *)(pmappedfw+12));
/* define the size of DMEM variable */
pfwhdr->fw_priv_sz = le32_to_cpu(*(uint *)(pmappedfw+16));
}
static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength)
{
u32 fwhdrsz, fw_sz;
u8 intf, rfconf;
/* check signature */
if ((pfwhdr->signature != 0x8712) && (pfwhdr->signature != 0x8192))
return _FAIL;
/* check interface */
intf = (u8)((pfwhdr->version&0x3000) >> 12);
/* check rf_conf */
rfconf = (u8)((pfwhdr->version&0xC000) >> 14);
/* check fw_priv_sze & sizeof(struct fw_priv) */
if (pfwhdr->fw_priv_sz != sizeof(struct fw_priv))
return _FAIL;
/* check fw_sz & image_fw_sz */
fwhdrsz = FIELD_OFFSET(struct fw_hdr, fwpriv) + pfwhdr->fw_priv_sz;
fw_sz = fwhdrsz + pfwhdr->img_IMEM_size + pfwhdr->img_SRAM_size +
pfwhdr->dmem_size;
if (fw_sz != ulfilelength)
return _FAIL;
return _SUCCESS;
}
static u8 rtl8712_dl_fw(struct _adapter *padapter)
{
sint i;
u8 tmp8, tmp8_a;
u16 tmp16;
u32 maxlen = 0, tmp32; /* for compare usage */
uint dump_imem_sz, imem_sz, dump_emem_sz, emem_sz; /* max = 49152; */
struct fw_hdr fwhdr;
u32 ulfilelength; /* FW file size */
void *phfwfile_hdl = NULL;
const u8 *pmappedfw = NULL;
u8 *ptmpchar = NULL, *ppayload, *ptr;
struct tx_desc *ptx_desc;
u32 txdscp_sz = sizeof(struct tx_desc);
ulfilelength = rtl871x_open_fw(padapter, &phfwfile_hdl, &pmappedfw);
if (pmappedfw && (ulfilelength > 0)) {
update_fwhdr(&fwhdr, pmappedfw);
if (chk_fwhdr(&fwhdr, ulfilelength) == _FAIL)
goto exit_fail;
fill_fwpriv(padapter, &fwhdr.fwpriv);
/* firmware check ok */
maxlen = (fwhdr.img_IMEM_size > fwhdr.img_SRAM_size) ?
fwhdr.img_IMEM_size : fwhdr.img_SRAM_size;
maxlen += txdscp_sz;
ptmpchar = _malloc(maxlen + FWBUFF_ALIGN_SZ);
if (ptmpchar == NULL)
return _FAIL;
ptx_desc = (struct tx_desc *)(ptmpchar + FWBUFF_ALIGN_SZ -
((addr_t)(ptmpchar) & (FWBUFF_ALIGN_SZ - 1)));
ppayload = (u8 *)(ptx_desc) + txdscp_sz;
ptr = (u8 *)pmappedfw + FIELD_OFFSET(struct fw_hdr, fwpriv) +
fwhdr.fw_priv_sz;
/* Download FirmWare */
/* 1. determine IMEM code size and Load IMEM Code Section */
imem_sz = fwhdr.img_IMEM_size;
do {
memset(ptx_desc, 0, TXDESC_SIZE);
if (imem_sz > MAX_DUMP_FWSZ/*49152*/)
dump_imem_sz = MAX_DUMP_FWSZ;
else {
dump_imem_sz = imem_sz;
ptx_desc->txdw0 |= cpu_to_le32(BIT(28));
}
ptx_desc->txdw0 |= cpu_to_le32(dump_imem_sz &
0x0000ffff);
memcpy(ppayload, ptr, dump_imem_sz);
r8712_write_mem(padapter, RTL8712_DMA_VOQ,
dump_imem_sz + TXDESC_SIZE,
(u8 *)ptx_desc);
ptr += dump_imem_sz;
imem_sz -= dump_imem_sz;
} while (imem_sz > 0);
i = 10;
tmp16 = r8712_read16(padapter, TCR);
while (((tmp16 & _IMEM_CODE_DONE) == 0) && (i > 0)) {
udelay(10);
tmp16 = r8712_read16(padapter, TCR);
i--;
}
if (i == 0 || (tmp16 & _IMEM_CHK_RPT) == 0)
goto exit_fail;
/* 2.Download EMEM code size and Load EMEM Code Section */
emem_sz = fwhdr.img_SRAM_size;
do {
memset(ptx_desc, 0, TXDESC_SIZE);
if (emem_sz > MAX_DUMP_FWSZ) /* max=48k */
dump_emem_sz = MAX_DUMP_FWSZ;
else {
dump_emem_sz = emem_sz;
ptx_desc->txdw0 |= cpu_to_le32(BIT(28));
}
ptx_desc->txdw0 |= cpu_to_le32(dump_emem_sz &
0x0000ffff);
memcpy(ppayload, ptr, dump_emem_sz);
r8712_write_mem(padapter, RTL8712_DMA_VOQ,
dump_emem_sz+TXDESC_SIZE, (u8 *)ptx_desc);
ptr += dump_emem_sz;
emem_sz -= dump_emem_sz;
} while (emem_sz > 0);
i = 5;
tmp16 = r8712_read16(padapter, TCR);
while (((tmp16 & _EMEM_CODE_DONE) == 0) && (i > 0)) {
udelay(10);
tmp16 = r8712_read16(padapter, TCR);
i--;
}
if (i == 0 || (tmp16 & _EMEM_CHK_RPT) == 0)
goto exit_fail;
/* 3.Enable CPU */
tmp8 = r8712_read8(padapter, SYS_CLKR);
r8712_write8(padapter, SYS_CLKR, tmp8|BIT(2));
tmp8_a = r8712_read8(padapter, SYS_CLKR);
if (tmp8_a != (tmp8|BIT(2)))
goto exit_fail;
tmp8 = r8712_read8(padapter, SYS_FUNC_EN + 1);
r8712_write8(padapter, SYS_FUNC_EN+1, tmp8|BIT(2));
tmp8_a = r8712_read8(padapter, SYS_FUNC_EN + 1);
if (tmp8_a != (tmp8|BIT(2)))
goto exit_fail;
tmp32 = r8712_read32(padapter, TCR);
/* 4.polling IMEM Ready */
i = 100;
tmp16 = r8712_read16(padapter, TCR);
while (((tmp16 & _IMEM_RDY) == 0) && (i > 0)) {
msleep(20);
tmp16 = r8712_read16(padapter, TCR);
i--;
}
if (i == 0) {
r8712_write16(padapter, 0x10250348, 0xc000);
r8712_write16(padapter, 0x10250348, 0xc001);
r8712_write16(padapter, 0x10250348, 0x2000);
r8712_write16(padapter, 0x10250348, 0x2001);
r8712_write16(padapter, 0x10250348, 0x2002);
r8712_write16(padapter, 0x10250348, 0x2003);
goto exit_fail;
}
/* 5.Download DMEM code size and Load EMEM Code Section */
memset(ptx_desc, 0, TXDESC_SIZE);
ptx_desc->txdw0 |= cpu_to_le32(fwhdr.fw_priv_sz&0x0000ffff);
ptx_desc->txdw0 |= cpu_to_le32(BIT(28));
memcpy(ppayload, &fwhdr.fwpriv, fwhdr.fw_priv_sz);
r8712_write_mem(padapter, RTL8712_DMA_VOQ,
fwhdr.fw_priv_sz + TXDESC_SIZE, (u8 *)ptx_desc);
/* polling dmem code done */
i = 100;
tmp16 = r8712_read16(padapter, TCR);
while (((tmp16 & _DMEM_CODE_DONE) == 0) && (i > 0)) {
msleep(20);
tmp16 = r8712_read16(padapter, TCR);
i--;
}
if (i == 0)
goto exit_fail;
tmp8 = r8712_read8(padapter, 0x1025000A);
if (tmp8 & BIT(4)) /* When boot from EEPROM,
& FW need more time to read EEPROM */
i = 60;
else /* boot from EFUSE */
i = 30;
tmp16 = r8712_read16(padapter, TCR);
while (((tmp16 & _FWRDY) == 0) && (i > 0)) {
msleep(100);
tmp16 = r8712_read16(padapter, TCR);
i--;
}
if (i == 0)
goto exit_fail;
} else
goto exit_fail;
return _SUCCESS;
exit_fail:
kfree(ptmpchar);
return _FAIL;
}
uint rtl8712_hal_init(struct _adapter *padapter)
{
u32 val32;
int i;
/* r8712 firmware download */
if (rtl8712_dl_fw(padapter) != _SUCCESS)
return _FAIL;
printk(KERN_INFO "r8712u: 1 RCR=0x%x\n", r8712_read32(padapter, RCR));
val32 = r8712_read32(padapter, RCR);
r8712_write32(padapter, RCR, (val32 | BIT(26))); /* Enable RX TCP
Checksum offload */
printk(KERN_INFO "r8712u: 2 RCR=0x%x\n", r8712_read32(padapter, RCR));
val32 = r8712_read32(padapter, RCR);
r8712_write32(padapter, RCR, (val32|BIT(25))); /* Append PHY status */
val32 = 0;
val32 = r8712_read32(padapter, 0x10250040);
r8712_write32(padapter, 0x10250040, (val32&0x00FFFFFF));
/* for usb rx aggregation */
r8712_write8(padapter, 0x102500B5, r8712_read8(padapter, 0x102500B5) |
BIT(0)); /* page = 128bytes */
r8712_write8(padapter, 0x102500BD, r8712_read8(padapter, 0x102500BD) |
BIT(7)); /* enable usb rx aggregation */
r8712_write8(padapter, 0x102500D9, 1); /* TH=1 => means that invalidate
* usb rx aggregation */
r8712_write8(padapter, 0x1025FE5B, 0x04); /* 1.7ms/4 */
/* Fix the RX FIFO issue(USB error) */
r8712_write8(padapter, 0x1025fe5C, r8712_read8(padapter, 0x1025fe5C)
| BIT(7));
for (i = 0; i < 6; i++)
padapter->eeprompriv.mac_addr[i] = r8712_read8(padapter,
MACID + i);
return _SUCCESS;
}
uint rtl8712_hal_deinit(struct _adapter *padapter)
{
r8712_write8(padapter, RF_CTRL, 0x00);
/* Turn off BB */
msleep(20);
/* Turn off MAC */
r8712_write8(padapter, SYS_CLKR+1, 0x38); /* Switch Control Path */
r8712_write8(padapter, SYS_FUNC_EN+1, 0x70);
r8712_write8(padapter, PMC_FSM, 0x06); /* Enable Loader Data Keep */
r8712_write8(padapter, SYS_ISO_CTRL, 0xF9); /* Isolation signals from
* CORE, PLL */
r8712_write8(padapter, SYS_ISO_CTRL+1, 0xe8); /* Enable EFUSE 1.2V */
r8712_write8(padapter, AFE_PLL_CTRL, 0x00); /* Disable AFE PLL. */
r8712_write8(padapter, LDOA15_CTRL, 0x54); /* Disable A15V */
r8712_write8(padapter, SYS_FUNC_EN+1, 0x50); /* Disable E-Fuse 1.2V */
r8712_write8(padapter, LDOV12D_CTRL, 0x24); /* Disable LDO12(for CE) */
r8712_write8(padapter, AFE_MISC, 0x30); /* Disable AFE BG&MB */
/* Option for Disable 1.6V LDO. */
r8712_write8(padapter, SPS0_CTRL, 0x56); /* Disable 1.6V LDO */
r8712_write8(padapter, SPS0_CTRL+1, 0x43); /* Set SW PFM */
return _SUCCESS;
}
uint rtl871x_hal_init(struct _adapter *padapter)
{
padapter->hw_init_completed = false;
if (padapter->halpriv.hal_bus_init == NULL)
return _FAIL;
else {
if (padapter->halpriv.hal_bus_init(padapter) != _SUCCESS)
return _FAIL;
}
if (rtl8712_hal_init(padapter) == _SUCCESS)
padapter->hw_init_completed = true;
else {
padapter->hw_init_completed = false;
return _FAIL;
}
return _SUCCESS;
}
/******************************************************************************
* ieee80211.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* 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
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>.
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _IEEE80211_C
#include "drv_types.h"
#include "ieee80211.h"
#include "wifi.h"
#include "osdep_service.h"
#include "wlan_bssdef.h"
static const u8 WPA_OUI_TYPE[] = {0x00, 0x50, 0xf2, 1};
static const u8 WPA_CIPHER_SUITE_NONE[] = {0x00, 0x50, 0xf2, 0};
static const u8 WPA_CIPHER_SUITE_WEP40[] = {0x00, 0x50, 0xf2, 1};
static const u8 WPA_CIPHER_SUITE_TKIP[] = {0x00, 0x50, 0xf2, 2};
static const u8 WPA_CIPHER_SUITE_CCMP[] = {0x00, 0x50, 0xf2, 4};
static const u8 WPA_CIPHER_SUITE_WEP104[] = {0x00, 0x50, 0xf2, 5};
static const u8 RSN_CIPHER_SUITE_NONE[] = {0x00, 0x0f, 0xac, 0};
static const u8 RSN_CIPHER_SUITE_WEP40[] = {0x00, 0x0f, 0xac, 1};
static const u8 RSN_CIPHER_SUITE_TKIP[] = {0x00, 0x0f, 0xac, 2};
static const u8 RSN_CIPHER_SUITE_CCMP[] = {0x00, 0x0f, 0xac, 4};
static const u8 RSN_CIPHER_SUITE_WEP104[] = {0x00, 0x0f, 0xac, 5};
/*-----------------------------------------------------------
* for adhoc-master to generate ie and provide supported-rate to fw
*-----------------------------------------------------------
*/
static u8 WIFI_CCKRATES[] = {
(IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK),
(IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK),
(IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK),
(IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK)
};
static u8 WIFI_OFDMRATES[] = {
(IEEE80211_OFDM_RATE_6MB),
(IEEE80211_OFDM_RATE_9MB),
(IEEE80211_OFDM_RATE_12MB),
(IEEE80211_OFDM_RATE_18MB),
(IEEE80211_OFDM_RATE_24MB),
(IEEE80211_OFDM_RATE_36MB),
(IEEE80211_OFDM_RATE_48MB),
(IEEE80211_OFDM_RATE_54MB)
};
uint r8712_is_cckrates_included(u8 *rate)
{
u32 i = 0;
while (rate[i] != 0) {
if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
(((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
return true;
i++;
}
return false;
}
uint r8712_is_cckratesonly_included(u8 *rate)
{
u32 i = 0;
while (rate[i] != 0) {
if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
(((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
return false;
i++;
}
return true;
}
/* r8712_set_ie will update frame length */
u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen)
{
*pbuf = (u8)index;
*(pbuf + 1) = (u8)len;
if (len > 0)
memcpy((void *)(pbuf + 2), (void *)source, len);
*frlen = *frlen + (len + 2);
return pbuf + len + 2;
}
/*----------------------------------------------------------------------------
index: the information element id index, limit is the limit for search
-----------------------------------------------------------------------------*/
u8 *r8712_get_ie(u8 *pbuf, sint index, sint *len, sint limit)
{
sint tmp, i;
u8 *p;
if (limit < 1)
return NULL;
p = pbuf;
i = 0;
*len = 0;
while (1) {
if (*p == index) {
*len = *(p + 1);
return p;
} else {
tmp = *(p + 1);
p += (tmp + 2);
i += (tmp + 2);
}
if (i >= limit)
break;
}
return NULL;
}
static void set_supported_rate(u8 *SupportedRates, uint mode)
{
memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX);
switch (mode) {
case WIRELESS_11B:
memcpy(SupportedRates, WIFI_CCKRATES,
IEEE80211_CCK_RATE_LEN);
break;
case WIRELESS_11G:
case WIRELESS_11A:
memcpy(SupportedRates, WIFI_OFDMRATES,
IEEE80211_NUM_OFDM_RATESLEN);
break;
case WIRELESS_11BG:
memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN);
memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES,
IEEE80211_NUM_OFDM_RATESLEN);
break;
}
}
static uint r8712_get_rateset_len(u8 *rateset)
{
uint i = 0;
while (1) {
if ((rateset[i]) == 0)
break;
if (i > 12)
break;
i++;
}
return i;
}
int r8712_generate_ie(struct registry_priv *pregistrypriv,
struct _adapter *padapter)
{
int sz = 0, rateLen;
struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network;
u8 *ie = pdev_network->IEs;
struct ieee80211_ht_cap ht_capie;
struct ieee80211_ht_addt_info ht_addt_info;
unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00};
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
/*timestamp will be inserted by hardware*/
sz += 8;
ie += sz;
/*beacon interval : 2bytes*/
*(u16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);
sz += 2;
ie += 2;
/*capability info*/
*(u16 *)ie = 0;
*(u16 *)ie |= cpu_to_le16(cap_IBSS);
if (pregistrypriv->preamble == PREAMBLE_SHORT)
*(u16 *)ie |= cpu_to_le16(cap_ShortPremble);
if (pdev_network->Privacy)
*(u16 *)ie |= cpu_to_le16(cap_Privacy);
sz += 2;
ie += 2;
/*SSID*/
ie = r8712_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength,
pdev_network->Ssid.Ssid, &sz);
/*supported rates*/
set_supported_rate(pdev_network->SupportedRates,
pregistrypriv->wireless_mode);
rateLen = r8712_get_rateset_len(pdev_network->SupportedRates);
if (rateLen > 8) {
ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_, 8,
pdev_network->SupportedRates, &sz);
ie = r8712_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8),
(pdev_network->SupportedRates + 8), &sz);
} else
ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_,
rateLen, pdev_network->SupportedRates, &sz);
/*DS parameter set*/
ie = r8712_set_ie(ie, _DSSET_IE_, 1,
(u8 *)&(pdev_network->Configuration.DSConfig), &sz);
/*IBSS Parameter Set*/
ie = r8712_set_ie(ie, _IBSS_PARA_IE_, 2,
(u8 *)&(pdev_network->Configuration.ATIMWindow), &sz);
if (pregistrypriv->ht_enable == 1) {
if (pqospriv->qos_option == 0) {
ie = r8712_set_ie(ie, _VENDOR_SPECIFIC_IE_,
_WMM_IE_Length_, WMM_IE, &sz);
pqospriv->qos_option = 1;
}
memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap));
ht_capie.cap_info = IEEE80211_HT_CAP_SUP_WIDTH |
IEEE80211_HT_CAP_SGI_20 |
IEEE80211_HT_CAP_SGI_40 |
IEEE80211_HT_CAP_TX_STBC |
IEEE80211_HT_CAP_MAX_AMSDU |
IEEE80211_HT_CAP_DSSSCCK40;
ht_capie.ampdu_params_info = (IEEE80211_HT_CAP_AMPDU_FACTOR &
0x03) | (IEEE80211_HT_CAP_AMPDU_DENSITY & 0x00);
ie = r8712_set_ie(ie, _HT_CAPABILITY_IE_,
sizeof(struct ieee80211_ht_cap),
(unsigned char *)&ht_capie, &sz);
/*add HT info ie*/
memset(&ht_addt_info, 0,
sizeof(struct ieee80211_ht_addt_info));
/*need to add the HT additional IEs*/
ht_addt_info.control_chan = pregistrypriv->channel;
ie = r8712_set_ie(ie, _HT_ADD_INFO_IE_,
sizeof(struct ieee80211_ht_addt_info),
(unsigned char *)&ht_addt_info, &sz);
}
return sz;
}
unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit)
{
int len;
u16 val16;
unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01};
u8 *pbuf = pie;
while (1) {
pbuf = r8712_get_ie(pbuf, _WPA_IE_ID_, &len, limit);
if (pbuf) {
/*check if oui matches...*/
if (memcmp((pbuf + 2), wpa_oui_type,
sizeof(wpa_oui_type)))
goto check_next_ie;
/*check version...*/
memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16));
val16 = le16_to_cpu(val16);
if (val16 != 0x0001)
goto check_next_ie;
*wpa_ie_len = *(pbuf + 1);
return pbuf;
} else {
*wpa_ie_len = 0;
return NULL;
}
check_next_ie:
limit = limit - (pbuf - pie) - 2 - len;
if (limit <= 0)
break;
pbuf += (2 + len);
}
*wpa_ie_len = 0;
return NULL;
}
unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit)
{
return r8712_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit);
}
static int r8712_get_wpa_cipher_suite(u8 *s)
{
if (!memcmp(s, (void *)WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN))
return WPA_CIPHER_NONE;
if (!memcmp(s, (void *)WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN))
return WPA_CIPHER_WEP40;
if (!memcmp(s, (void *)WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN))
return WPA_CIPHER_TKIP;
if (!memcmp(s, (void *)WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN))
return WPA_CIPHER_CCMP;
if (!memcmp(s, (void *)WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN))
return WPA_CIPHER_WEP104;
return 0;
}
static int r8712_get_wpa2_cipher_suite(u8 *s)
{
if (!memcmp(s, (void *)RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN))
return WPA_CIPHER_NONE;
if (!memcmp(s, (void *)RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN))
return WPA_CIPHER_WEP40;
if (!memcmp(s, (void *)RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN))
return WPA_CIPHER_TKIP;
if (!memcmp(s, (void *)RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN))
return WPA_CIPHER_CCMP;
if (!memcmp(s, (void *)RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN))
return WPA_CIPHER_WEP104;
return 0;
}
int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
int *pairwise_cipher)
{
int i, ret = _SUCCESS;
int left, count;
u8 *pos;
if (wpa_ie_len <= 0) {
/* No WPA IE - fail silently */
return _FAIL;
}
if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2))
|| (memcmp(wpa_ie + 2, (void *)WPA_OUI_TYPE, WPA_SELECTOR_LEN)))
return _FAIL;
pos = wpa_ie;
pos += 8;
left = wpa_ie_len - 8;
/*group_cipher*/
if (left >= WPA_SELECTOR_LEN) {
*group_cipher = r8712_get_wpa_cipher_suite(pos);
pos += WPA_SELECTOR_LEN;
left -= WPA_SELECTOR_LEN;
} else if (left > 0)
return _FAIL;
/*pairwise_cipher*/
if (left >= 2) {
count = le16_to_cpu(*(u16 *)pos);
pos += 2;
left -= 2;
if (count == 0 || left < count * WPA_SELECTOR_LEN)
return _FAIL;
for (i = 0; i < count; i++) {
*pairwise_cipher |= r8712_get_wpa_cipher_suite(pos);
pos += WPA_SELECTOR_LEN;
left -= WPA_SELECTOR_LEN;
}
} else if (left == 1)
return _FAIL;
return ret;
}
int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher,
int *pairwise_cipher)
{
int i, ret = _SUCCESS;
int left, count;
u8 *pos;
if (rsn_ie_len <= 0) {
/* No RSN IE - fail silently */
return _FAIL;
}
if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2)))
return _FAIL;
pos = rsn_ie;
pos += 4;
left = rsn_ie_len - 4;
/*group_cipher*/
if (left >= RSN_SELECTOR_LEN) {
*group_cipher = r8712_get_wpa2_cipher_suite(pos);
pos += RSN_SELECTOR_LEN;
left -= RSN_SELECTOR_LEN;
} else if (left > 0)
return _FAIL;
/*pairwise_cipher*/
if (left >= 2) {
count = le16_to_cpu(*(u16 *)pos);
pos += 2;
left -= 2;
if (count == 0 || left < count * RSN_SELECTOR_LEN)
return _FAIL;
for (i = 0; i < count; i++) {
*pairwise_cipher |= r8712_get_wpa2_cipher_suite(pos);
pos += RSN_SELECTOR_LEN;
left -= RSN_SELECTOR_LEN;
}
} else if (left == 1)
return _FAIL;
return ret;
}
int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len,
u8 *wpa_ie, u16 *wpa_len)
{
u8 authmode, sec_idx;
u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01};
uint cnt;
/*Search required WPA or WPA2 IE and copy to sec_ie[ ]*/
cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_);
sec_idx = 0;
while (cnt < in_len) {
authmode = in_ie[cnt];
if ((authmode == _WPA_IE_ID_) &&
(!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) {
memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2);
*wpa_len = in_ie[cnt+1]+2;
cnt += in_ie[cnt + 1] + 2; /*get next */
} else {
if (authmode == _WPA2_IE_ID_) {
memcpy(rsn_ie, &in_ie[cnt],
in_ie[cnt + 1] + 2);
*rsn_len = in_ie[cnt+1] + 2;
cnt += in_ie[cnt+1] + 2; /*get next*/
} else
cnt += in_ie[cnt+1] + 2; /*get next*/
}
}
return *rsn_len + *wpa_len;
}
int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen)
{
int match;
uint cnt;
u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04};
cnt = 12;
match = false;
while (cnt < in_len) {
eid = in_ie[cnt];
if ((eid == _WPA_IE_ID_) &&
(!memcmp(&in_ie[cnt+2], wps_oui, 4))) {
memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2);
*wps_ielen = in_ie[cnt+1]+2;
cnt += in_ie[cnt+1]+2;
match = true;
break;
} else
cnt += in_ie[cnt+1]+2; /* goto next */
}
return match;
}
此差异已折叠。
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Global definitions for the Ethernet IEEE 802.3 interface.
*
* Version: @(#)if_ether.h 1.0.1a 02/08/94
*
* Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Donald Becker, <becker@super.org>
* Alan Cox, <alan@redhat.com>
* Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#ifndef _LINUX_IF_ETHER_H
#define _LINUX_IF_ETHER_H
/*
* IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
* and FCS/CRC (frame check sequence).
*/
#define ETH_ALEN 6 /* Octets in one ethernet addr */
#define ETH_HLEN 14 /* Total octets in header. */
#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
#define ETH_DATA_LEN 1500 /* Max. octets in payload */
#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
/*
* These are the defined Ethernet Protocol ID's.
*/
#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */
#define ETH_P_PUP 0x0200 /* Xerox PUP packet */
#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_P_X25 0x0805 /* CCITT X.25 */
#define ETH_P_ARP 0x0806 /* Address Resolution packet */
#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet
* [ NOT AN OFFICIAL ID ] */
#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr
* Trans packet */
#define ETH_P_DEC 0x6000 /* DEC Assigned proto */
#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */
#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */
#define ETH_P_LAT 0x6004 /* DEC LAT */
#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */
#define ETH_P_CUST 0x6006 /* DEC Customer use */
#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */
#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
#define ETH_P_ATALK 0x809B /* Appletalk DDP */
#define ETH_P_AARP 0x80F3 /* Appletalk AARP */
#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
#define ETH_P_IPX 0x8137 /* IPX over DIX */
#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */
#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */
#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */
#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */
#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport
* over Ethernet
*/
/*
* Non DIX types. Won't clash for 1500 types.
*/
#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
#define ETH_P_802_2 0x0004 /* 802.2 frames */
#define ETH_P_SNAP 0x0005 /* Internal only */
#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
#define ETH_P_TR_802_2 0x0011i /* 802.2 frames */
#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
#define ETH_P_CONTROL 0x0016 /* Card specific control frames */
#define ETH_P_IRDA 0x0017 /* Linux-IrDA */
#define ETH_P_ECONET 0x0018 /* Acorn Econet */
/*
* This is an Ethernet frame header.
*/
struct ethhdr {
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
unsigned char h_source[ETH_ALEN]; /* source ether addr */
unsigned short h_proto; /* packet type ID field */
};
struct _vlan {
unsigned short h_vlan_TCI; /* Encapsulates priority and VLAN ID*/
unsigned short h_vlan_encapsulated_proto;
};
#define get_vlan_id(pvlan) ((ntohs((unsigned short)pvlan->h_vlan_TCI)) & 0xfff)
#define get_vlan_priority(pvlan) ((ntohs((unsigned short)\
pvlan->h_vlan_TCI)) >> 13)
#define get_vlan_encap_proto(pvlan) (ntohs((unsigned short)\
pvlan->h_vlan_encapsulated_proto))
#endif /* _LINUX_IF_ETHER_H */
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Definitions for the IP protocol.
*
* Version: @(#)ip.h 1.0.2 04/28/93
*
* Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#ifndef _LINUX_IP_H
#define _LINUX_IP_H
#include "rtl871x_byteorder.h"
/* SOL_IP socket options */
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK)
#define IPTOS_LOWDELAY 0x10
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_RELIABILITY 0x04
#define IPTOS_MINCOST 0x02
#define IPTOS_PREC_MASK 0xE0
#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
#define IPTOS_PREC_CRITIC_ECP 0xa0
#define IPTOS_PREC_FLASHOVERRIDE 0x80
#define IPTOS_PREC_FLASH 0x60
#define IPTOS_PREC_IMMEDIATE 0x40
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
/* IP options */
#define IPOPT_COPY 0x80
#define IPOPT_CLASS_MASK 0x60
#define IPOPT_NUMBER_MASK 0x1f
#define IPOPT_COPIED(o) ((o)&IPOPT_COPY)
#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK)
#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK)
#define IPOPT_CONTROL 0x00
#define IPOPT_RESERVED1 0x20
#define IPOPT_MEASUREMENT 0x40
#define IPOPT_RESERVED2 0x60
#define IPOPT_END (0 | IPOPT_CONTROL)
#define IPOPT_NOOP (1 | IPOPT_CONTROL)
#define IPOPT_SEC (2 | IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_LSRR (3 | IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_TIMESTAMP (4 | IPOPT_MEASUREMENT)
#define IPOPT_RR (7 | IPOPT_CONTROL)
#define IPOPT_SID (8 | IPOPT_CONTROL | IPOPT_COPY)
#define IPOPT_SSRR (9 | IPOPT_CONTROL | IPOPT_COPY)
#define IPOPT_RA (20 | IPOPT_CONTROL | IPOPT_COPY)
#define IPVERSION 4
#define MAXTTL 255
#define IPDEFTTL 64
/* struct timestamp, struct route and MAX_ROUTES are removed.
*
* REASONS: it is clear that nobody used them because:
* - MAX_ROUTES value was wrong.
* - "struct route" was wrong.
* - "struct timestamp" had fatally misaligned bitfields and was completely
* unusable.
*/
#define IPOPT_OPTVAL 0
#define IPOPT_OLEN 1
#define IPOPT_OFFSET 2
#define IPOPT_MINOFF 4
#define MAX_IPOPTLEN 40
#define IPOPT_NOP IPOPT_NOOP
#define IPOPT_EOL IPOPT_END
#define IPOPT_TS IPOPT_TIMESTAMP
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
struct ip_options {
__u32 faddr; /* Saved first hop address */
unsigned char optlen;
unsigned char srr;
unsigned char rr;
unsigned char ts;
unsigned char is_setbyuser:1, /* Set by setsockopt? */
is_data:1, /* Options in __data, rather than skb */
is_strictroute:1, /* Strict source route */
srr_is_hit:1, /* Packet destination addr was our one */
is_changed:1, /* IP checksum more not valid */
rr_needaddr:1, /* Need to record addr of outgoing dev */
ts_needtime:1, /* Need to record timestamp */
ts_needaddr:1; /* Need to record addr of outgoing dev */
unsigned char router_alert;
unsigned char __pad1;
unsigned char __pad2;
unsigned char __data[0];
};
#define optlength(opt) (sizeof(struct ip_options) + opt->optlen)
struct iphdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 ihl:4,
version:4;
#elif defined(__BIG_ENDIAN_BITFIELD)
__u8 version:4,
ihl:4;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__u8 tos;
__u16 tot_len;
__u16 id;
__u16 frag_off;
__u8 ttl;
__u8 protocol;
__u16 check;
__u32 saddr;
__u32 daddr;
/*The options start here. */
};
#endif /* _LINUX_IP_H */
#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H
#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234
#endif
#ifndef __LITTLE_ENDIAN_BITFIELD
#define __LITTLE_ENDIAN_BITFIELD
#endif
#include "swab.h"
#define __constant_htonl(x) ___constant_swab32((x))
#define __constant_ntohl(x) ___constant_swab32((x))
#define __constant_htons(x) ___constant_swab16((x))
#define __constant_ntohs(x) ___constant_swab16((x))
#define __constant_cpu_to_le64(x) ((__u64)(x))
#define __constant_le64_to_cpu(x) ((__u64)(x))
#define __constant_cpu_to_le32(x) ((__u32)(x))
#define __constant_le32_to_cpu(x) ((__u32)(x))
#define __constant_cpu_to_le16(x) ((__u16)(x))
#define __constant_le16_to_cpu(x) ((__u16)(x))
#define __constant_cpu_to_be64(x) ___constant_swab64((x))
#define __constant_be64_to_cpu(x) ___constant_swab64((x))
#define __constant_cpu_to_be32(x) ___constant_swab32((x))
#define __constant_be32_to_cpu(x) ___constant_swab32((x))
#define __constant_cpu_to_be16(x) ___constant_swab16((x))
#define __constant_be16_to_cpu(x) ___constant_swab16((x))
#define __cpu_to_le64(x) ((__u64)(x))
#define __le64_to_cpu(x) ((__u64)(x))
#define __cpu_to_le32(x) ((__u32)(x))
#define __le32_to_cpu(x) ((__u32)(x))
#define __cpu_to_le16(x) ((__u16)(x))
#define __le16_to_cpu(x) ((__u16)(x))
#define __cpu_to_be64(x) __swab64((x))
#define __be64_to_cpu(x) __swab64((x))
#define __cpu_to_be32(x) __swab32((x))
#define __be32_to_cpu(x) __swab32((x))
#define __cpu_to_be16(x) __swab16((x))
#define __be16_to_cpu(x) __swab16((x))
#define __cpu_to_le64p(x) (*(__u64 *)(x))
#define __le64_to_cpup(x) (*(__u64 *)(x))
#define __cpu_to_le32p(x) (*(__u32 *)(x))
#define __le32_to_cpup(x) (*(__u32 *)(x))
#define __cpu_to_le16p(x) (*(__u16 *)(x))
#define __le16_to_cpup(x) (*(__u16 *)(x))
#define __cpu_to_be64p(x) __swab64p((x))
#define __be64_to_cpup(x) __swab64p((x))
#define __cpu_to_be32p(x) __swab32p((x))
#define __be32_to_cpup(x) __swab32p((x))
#define __cpu_to_be16p(x) __swab16p((x))
#define __be16_to_cpup(x) __swab16p((x))
#define __cpu_to_le64s(x) do {} while (0)
#define __le64_to_cpus(x) do {} while (0)
#define __cpu_to_le32s(x) do {} while (0)
#define __le32_to_cpus(x) do {} while (0)
#define __cpu_to_le16s(x) do {} while (0)
#define __le16_to_cpus(x) do {} while (0)
#define __cpu_to_be64s(x) __swab64s((x))
#define __be64_to_cpus(x) __swab64s((x))
#define __cpu_to_be32s(x) __swab32s((x))
#define __be32_to_cpus(x) __swab32s((x))
#define __cpu_to_be16s(x) __swab16s((x))
#define __be16_to_cpus(x) __swab16s((x))
#include "generic.h"
#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
/******************************************************************************
* mlme_linux.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* 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
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>.
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _MLME_OSDEP_C_
#include "osdep_service.h"
#include "drv_types.h"
#include "mlme_osdep.h"
static void sitesurvey_ctrl_handler(void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
_r8712_sitesurvey_ctrl_handler(adapter);
_set_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
3000);
}
static void join_timeout_handler (void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
_r8712_join_timeout_handler(adapter);
}
static void _scan_timeout_handler (void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
r8712_scan_timeout_handler(adapter);
}
static void dhcp_timeout_handler (void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
_r8712_dhcp_timeout_handler(adapter);
}
static void wdg_timeout_handler (void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
_r8712_wdg_timeout_handler(adapter);
_set_timer(&adapter->mlmepriv.wdg_timer, 2000);
}
void r8712_init_mlme_timer(struct _adapter *padapter)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
_init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev,
join_timeout_handler, (pmlmepriv->nic_hdl));
_init_timer(&(pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer),
padapter->pnetdev, sitesurvey_ctrl_handler,
(u8 *)(pmlmepriv->nic_hdl));
_init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev,
_scan_timeout_handler, (pmlmepriv->nic_hdl));
_init_timer(&(pmlmepriv->dhcp_timer), padapter->pnetdev,
dhcp_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
_init_timer(&(pmlmepriv->wdg_timer), padapter->pnetdev,
wdg_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
}
void r8712_os_indicate_connect(struct _adapter *adapter)
{
r8712_indicate_wx_assoc_event(adapter);
netif_carrier_on(adapter->pnetdev);
}
static struct RT_PMKID_LIST backupPMKIDList[NUM_PMKID_CACHE];
void r8712_os_indicate_disconnect(struct _adapter *adapter)
{
u8 backupPMKIDIndex = 0;
u8 backupTKIPCountermeasure = 0x00;
r8712_indicate_wx_disassoc_event(adapter);
netif_carrier_off(adapter->pnetdev);
if (adapter->securitypriv.AuthAlgrthm == 2) { /*/802.1x*/
/* We have to backup the PMK information for WiFi PMK Caching
* test item. Backup the btkip_countermeasure information.
* When the countermeasure is trigger, the driver have to
* disconnect with AP for 60 seconds.
*/
memset(&backupPMKIDList[0], 0x00, sizeof(
struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
memcpy(&backupPMKIDList[0], &adapter->securitypriv.
PMKIDList[0], sizeof(struct RT_PMKID_LIST) *
NUM_PMKID_CACHE);
backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
backupTKIPCountermeasure = adapter->securitypriv.
btkip_countermeasure;
memset((unsigned char *)&adapter->securitypriv, 0,
sizeof(struct security_priv));
_init_timer(&(adapter->securitypriv.tkip_timer),
adapter->pnetdev, r8712_use_tkipkey_handler,
adapter);
/* Restore the PMK information to securitypriv structure
* for the following connection. */
memcpy(&adapter->securitypriv.PMKIDList[0],
&backupPMKIDList[0],
sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
adapter->securitypriv.btkip_countermeasure =
backupTKIPCountermeasure;
} else { /*reset values in securitypriv*/
struct security_priv *psec_priv = &adapter->securitypriv;
psec_priv->AuthAlgrthm = 0; /*open system*/
psec_priv->PrivacyAlgrthm = _NO_PRIVACY_;
psec_priv->PrivacyKeyIndex = 0;
psec_priv->XGrpPrivacy = _NO_PRIVACY_;
psec_priv->XGrpKeyid = 1;
psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
psec_priv->wps_phase = false;
}
}
void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie)
{
uint len;
u8 *buff, *p, i;
union iwreq_data wrqu;
buff = NULL;
if (authmode == _WPA_IE_ID_) {
buff = _malloc(IW_CUSTOM_MAX);
if (buff == NULL)
return;
memset(buff, 0, IW_CUSTOM_MAX);
p = buff;
p += sprintf(p, "ASSOCINFO(ReqIEs=");
len = sec_ie[1] + 2;
len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
for (i = 0; i < len; i++)
p += sprintf(p, "%02x", sec_ie[i]);
p += sprintf(p, ")");
memset(&wrqu, 0, sizeof(wrqu));
wrqu.data.length = p-buff;
wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
wrqu.data.length : IW_CUSTOM_MAX;
wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
kfree(buff);
}
}
#ifndef __MLME_OSDEP_H_
#define __MLME_OSDEP_H_
#include "osdep_service.h"
#include "drv_types.h"
void r8712_init_mlme_timer(struct _adapter *padapter);
void r8712_os_indicate_disconnect(struct _adapter *adapter);
void r8712_os_indicate_connect(struct _adapter *adapter);
void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie);
int r8712_recv_indicatepkts_in_order(struct _adapter *adapter,
struct recv_reorder_ctrl *precvreorder_ctrl,
int bforced);
void r8712_indicate_wx_assoc_event(struct _adapter *padapter);
void r8712_indicate_wx_disassoc_event(struct _adapter *padapter);
#endif /*_MLME_OSDEP_H_*/
#ifndef __CUSTOM_OID_H
#define __CUSTOM_OID_H
/* 0xFF818000 - 0xFF81802F RTL8180 Mass Production Kit
* 0xFF818500 - 0xFF81850F RTL8185 Setup Utility
* 0xFF818580 - 0xFF81858F RTL8185 Phy Status Utility
*
* by Owen for Production Kit
* For Production Kit with Agilent Equipments
* in order to make our custom oids hopefully somewhat unique
* we will use 0xFF (indicating implementation specific OID)
* 81(first byte of non zero Realtek unique identifier)
* 80 (second byte of non zero Realtek unique identifier)
* XX (the custom OID number - providing 255 possible custom oids)
*/
#define OID_RT_PRO_RESET_DUT 0xFF818000
#define OID_RT_PRO_SET_DATA_RATE 0xFF818001
#define OID_RT_PRO_START_TEST 0xFF818002
#define OID_RT_PRO_STOP_TEST 0xFF818003
#define OID_RT_PRO_SET_PREAMBLE 0xFF818004
#define OID_RT_PRO_SET_SCRAMBLER 0xFF818005
#define OID_RT_PRO_SET_FILTER_BB 0xFF818006
#define OID_RT_PRO_SET_MANUAL_DIVERSITY_BB 0xFF818007
#define OID_RT_PRO_SET_CHANNEL_DIRECT_CALL 0xFF818008
#define OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL 0xFF818009
#define OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL 0xFF81800A
#define OID_RT_PRO_SET_TX_ANTENNA_BB 0xFF81800D
#define OID_RT_PRO_SET_ANTENNA_BB 0xFF81800E
#define OID_RT_PRO_SET_CR_SCRAMBLER 0xFF81800F
#define OID_RT_PRO_SET_CR_NEW_FILTER 0xFF818010
#define OID_RT_PRO_SET_TX_POWER_CONTROL 0xFF818011
#define OID_RT_PRO_SET_CR_TX_CONFIG 0xFF818012
#define OID_RT_PRO_GET_TX_POWER_CONTROL 0xFF818013
#define OID_RT_PRO_GET_CR_SIGNAL_QUALITY 0xFF818014
#define OID_RT_PRO_SET_CR_SETPOINT 0xFF818015
#define OID_RT_PRO_SET_INTEGRATOR 0xFF818016
#define OID_RT_PRO_SET_SIGNAL_QUALITY 0xFF818017
#define OID_RT_PRO_GET_INTEGRATOR 0xFF818018
#define OID_RT_PRO_GET_SIGNAL_QUALITY 0xFF818019
#define OID_RT_PRO_QUERY_EEPROM_TYPE 0xFF81801A
#define OID_RT_PRO_WRITE_MAC_ADDRESS 0xFF81801B
#define OID_RT_PRO_READ_MAC_ADDRESS 0xFF81801C
#define OID_RT_PRO_WRITE_CIS_DATA 0xFF81801D
#define OID_RT_PRO_READ_CIS_DATA 0xFF81801E
#define OID_RT_PRO_WRITE_POWER_CONTROL 0xFF81801F
#define OID_RT_PRO_READ_POWER_CONTROL 0xFF818020
#define OID_RT_PRO_WRITE_EEPROM 0xFF818021
#define OID_RT_PRO_READ_EEPROM 0xFF818022
#define OID_RT_PRO_RESET_TX_PACKET_SENT 0xFF818023
#define OID_RT_PRO_QUERY_TX_PACKET_SENT 0xFF818024
#define OID_RT_PRO_RESET_RX_PACKET_RECEIVED 0xFF818025
#define OID_RT_PRO_QUERY_RX_PACKET_RECEIVED 0xFF818026
#define OID_RT_PRO_QUERY_RX_PACKET_CRC32_ERROR 0xFF818027
#define OID_RT_PRO_QUERY_CURRENT_ADDRESS 0xFF818028
#define OID_RT_PRO_QUERY_PERMANENT_ADDRESS 0xFF818029
#define OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS 0xFF81802A
#define OID_RT_PRO_RECEIVE_PACKET 0xFF81802C
#define OID_RT_PRO_WRITE_EEPROM_BYTE 0xFF81802D
#define OID_RT_PRO_READ_EEPROM_BYTE 0xFF81802E
#define OID_RT_PRO_SET_MODULATION 0xFF81802F
#define OID_RT_DRIVER_OPTION 0xFF818080
#define OID_RT_RF_OFF 0xFF818081
#define OID_RT_AUTH_STATUS 0xFF818082
#define OID_RT_PRO_SET_CONTINUOUS_TX 0xFF81800B
#define OID_RT_PRO_SET_SINGLE_CARRIER_TX 0xFF81800C
#define OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX 0xFF81802B
#define OID_RT_PRO_SET_SINGLE_TONE_TX 0xFF818043
#define OID_RT_UTILITY_FALSE_ALARM_COUNTERS 0xFF818580
#define OID_RT_UTILITY_SELECT_DEBUG_MODE 0xFF818581
#define OID_RT_UTILITY_SELECT_SUBCARRIER_NUMBER 0xFF818582
#define OID_RT_UTILITY_GET_RSSI_STATUS 0xFF818583
#define OID_RT_UTILITY_GET_FRAME_DETECTION_STATUS 0xFF818584
#define OID_RT_UTILITY_GET_AGC_AND_FREQUENCY_OFFSET_ESTIMATION_STATUS \
0xFF818585
#define OID_RT_UTILITY_GET_CHANNEL_ESTIMATION_STATUS 0xFF818586
#define OID_RT_WIRELESS_MODE 0xFF818500
#define OID_RT_SUPPORTED_RATES 0xFF818501
#define OID_RT_DESIRED_RATES 0xFF818502
#define OID_RT_WIRELESS_MODE_STARTING_ADHOC 0xFF818503
#define OID_RT_GET_CONNECT_STATE 0xFF030001
#define OID_RT_RESCAN 0xFF030002
#define OID_RT_SET_KEY_LENGTH 0xFF030003
#define OID_RT_SET_DEFAULT_KEY_ID 0xFF030004
#define OID_RT_SET_CHANNEL 0xFF010182
#define OID_RT_SET_SNIFFER_MODE 0xFF010183
#define OID_RT_GET_SIGNAL_QUALITY 0xFF010184
#define OID_RT_GET_SMALL_PACKET_CRC 0xFF010185
#define OID_RT_GET_MIDDLE_PACKET_CRC 0xFF010186
#define OID_RT_GET_LARGE_PACKET_CRC 0xFF010187
#define OID_RT_GET_TX_RETRY 0xFF010188
#define OID_RT_GET_RX_RETRY 0xFF010189
#define OID_RT_PRO_SET_FW_DIG_STATE 0xFF01018A
#define OID_RT_PRO_SET_FW_RA_STATE 0xFF01018B
#define OID_RT_GET_RX_TOTAL_PACKET 0xFF010190
#define OID_RT_GET_TX_BEACON_OK 0xFF010191
#define OID_RT_GET_TX_BEACON_ERR 0xFF010192
#define OID_RT_GET_RX_ICV_ERR 0xFF010193
#define OID_RT_SET_ENCRYPTION_ALGORITHM 0xFF010194
#define OID_RT_SET_NO_AUTO_RESCAN 0xFF010195
#define OID_RT_GET_PREAMBLE_MODE 0xFF010196
#define OID_RT_GET_DRIVER_UP_DELTA_TIME 0xFF010197
#define OID_RT_GET_AP_IP 0xFF010198
#define OID_RT_GET_CHANNELPLAN 0xFF010199
#define OID_RT_SET_PREAMBLE_MODE 0xFF01019A
#define OID_RT_SET_BCN_INTVL 0xFF01019B
#define OID_RT_GET_RF_VENDER 0xFF01019C
#define OID_RT_DEDICATE_PROBE 0xFF01019D
#define OID_RT_PRO_RX_FILTER_PATTERN 0xFF01019E
#define OID_RT_GET_DCST_CURRENT_THRESHOLD 0xFF01019F
#define OID_RT_GET_CCA_ERR 0xFF0101A0
#define OID_RT_GET_CCA_UPGRADE_THRESHOLD 0xFF0101A1
#define OID_RT_GET_CCA_FALLBACK_THRESHOLD 0xFF0101A2
#define OID_RT_GET_CCA_UPGRADE_EVALUATE_TIMES 0xFF0101A3
#define OID_RT_GET_CCA_FALLBACK_EVALUATE_TIMES 0xFF0101A4
#define OID_RT_SET_RATE_ADAPTIVE 0xFF0101A5
#define OID_RT_GET_DCST_EVALUATE_PERIOD 0xFF0101A5
#define OID_RT_GET_DCST_TIME_UNIT_INDEX 0xFF0101A6
#define OID_RT_GET_TOTAL_TX_BYTES 0xFF0101A7
#define OID_RT_GET_TOTAL_RX_BYTES 0xFF0101A8
#define OID_RT_CURRENT_TX_POWER_LEVEL 0xFF0101A9
#define OID_RT_GET_ENC_KEY_MISMATCH_COUNT 0xFF0101AA
#define OID_RT_GET_ENC_KEY_MATCH_COUNT 0xFF0101AB
#define OID_RT_GET_CHANNEL 0xFF0101AC
#define OID_RT_SET_CHANNELPLAN 0xFF0101AD
#define OID_RT_GET_HARDWARE_RADIO_OFF 0xFF0101AE
#define OID_RT_CHANNELPLAN_BY_COUNTRY 0xFF0101AF
#define OID_RT_SCAN_AVAILABLE_BSSID 0xFF0101B0
#define OID_RT_GET_HARDWARE_VERSION 0xFF0101B1
#define OID_RT_GET_IS_ROAMING 0xFF0101B2
#define OID_RT_GET_IS_PRIVACY 0xFF0101B3
#define OID_RT_GET_KEY_MISMATCH 0xFF0101B4
#define OID_RT_SET_RSSI_ROAM_TRAFFIC_TH 0xFF0101B5
#define OID_RT_SET_RSSI_ROAM_SIGNAL_TH 0xFF0101B6
#define OID_RT_RESET_LOG 0xFF0101B7
#define OID_RT_GET_LOG 0xFF0101B8
#define OID_RT_SET_INDICATE_HIDDEN_AP 0xFF0101B9
#define OID_RT_GET_HEADER_FAIL 0xFF0101BA
#define OID_RT_SUPPORTED_WIRELESS_MODE 0xFF0101BB
#define OID_RT_GET_CHANNEL_LIST 0xFF0101BC
#define OID_RT_GET_SCAN_IN_PROGRESS 0xFF0101BD
#define OID_RT_GET_TX_INFO 0xFF0101BE
#define OID_RT_RF_READ_WRITE_OFFSET 0xFF0101BF
#define OID_RT_RF_READ_WRITE 0xFF0101C0
#define OID_RT_FORCED_DATA_RATE 0xFF0101C1
#define OID_RT_WIRELESS_MODE_FOR_SCAN_LIST 0xFF0101C2
#define OID_RT_GET_BSS_WIRELESS_MODE 0xFF0101C3
#define OID_RT_SCAN_WITH_MAGIC_PACKET 0xFF0101C4
#define OID_RT_PRO_RX_FILTER 0xFF0111C0
#define OID_CE_USB_WRITE_REGISTRY 0xFF0111C1
#define OID_CE_USB_READ_REGISTRY 0xFF0111C2
#define OID_RT_PRO_SET_INITIAL_GAIN 0xFF0111C3
#define OID_RT_PRO_SET_BB_RF_STANDBY_MODE 0xFF0111C4
#define OID_RT_PRO_SET_BB_RF_SHUTDOWN_MODE 0xFF0111C5
#define OID_RT_PRO_SET_TX_CHARGE_PUMP 0xFF0111C6
#define OID_RT_PRO_SET_RX_CHARGE_PUMP 0xFF0111C7
#define OID_RT_PRO_RF_WRITE_REGISTRY 0xFF0111C8
#define OID_RT_PRO_RF_READ_REGISTRY 0xFF0111C9
#define OID_RT_PRO_QUERY_RF_TYPE 0xFF0111CA
#define OID_RT_AP_GET_ASSOCIATED_STATION_LIST 0xFF010300
#define OID_RT_AP_GET_CURRENT_TIME_STAMP 0xFF010301
#define OID_RT_AP_SWITCH_INTO_AP_MODE 0xFF010302
#define OID_RT_AP_SET_DTIM_PERIOD 0xFF010303
#define OID_RT_AP_SUPPORTED 0xFF010304
#define OID_RT_AP_SET_PASSPHRASE 0xFF010305
#define OID_RT_PRO8187_WI_POLL 0xFF818780
#define OID_RT_PRO_WRITE_BB_REG 0xFF818781
#define OID_RT_PRO_READ_BB_REG 0xFF818782
#define OID_RT_PRO_WRITE_RF_REG 0xFF818783
#define OID_RT_PRO_READ_RF_REG 0xFF818784
#define OID_RT_MH_VENDER_ID 0xFFEDC100
#define OID_RT_PRO8711_JOIN_BSS 0xFF871100
#define OID_RT_PRO_READ_REGISTER 0xFF871101
#define OID_RT_PRO_WRITE_REGISTER 0xFF871102
#define OID_RT_PRO_BURST_READ_REGISTER 0xFF871103
#define OID_RT_PRO_BURST_WRITE_REGISTER 0xFF871104
#define OID_RT_PRO_WRITE_TXCMD 0xFF871105
#define OID_RT_PRO_READ16_EEPROM 0xFF871106
#define OID_RT_PRO_WRITE16_EEPROM 0xFF871107
#define OID_RT_PRO_H2C_SET_COMMAND 0xFF871108
#define OID_RT_PRO_H2C_QUERY_RESULT 0xFF871109
#define OID_RT_PRO8711_WI_POLL 0xFF87110A
#define OID_RT_PRO8711_PKT_LOSS 0xFF87110B
#define OID_RT_RD_ATTRIB_MEM 0xFF87110C
#define OID_RT_WR_ATTRIB_MEM 0xFF87110D
/*Method 2 for H2C/C2H*/
#define OID_RT_PRO_H2C_CMD_MODE 0xFF871110
#define OID_RT_PRO_H2C_CMD_RSP_MODE 0xFF871111
#define OID_RT_PRO_H2C_CMD_EVENT_MODE 0xFF871112
#define OID_RT_PRO_WAIT_C2H_EVENT 0xFF871113
#define OID_RT_PRO_RW_ACCESS_PROTOCOL_TEST 0xFF871114
#define OID_RT_PRO_SCSI_ACCESS_TEST 0xFF871115
#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_OUT 0xFF871116
#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_IN 0xFF871117
#define OID_RT_RRO_RX_PKT_VIA_IOCTRL 0xFF871118
#define OID_RT_RRO_RX_PKTARRAY_VIA_IOCTRL 0xFF871119
#define OID_RT_RPO_SET_PWRMGT_TEST 0xFF87111A
#define OID_RT_PRO_QRY_PWRMGT_TEST 0XFF87111B
#define OID_RT_RPO_ASYNC_RWIO_TEST 0xFF87111C
#define OID_RT_RPO_ASYNC_RWIO_POLL 0xFF87111D
#define OID_RT_PRO_SET_RF_INTFS 0xFF87111E
#define OID_RT_POLL_RX_STATUS 0xFF87111F
#define OID_RT_PRO_CFG_DEBUG_MESSAGE 0xFF871120
#define OID_RT_PRO_SET_DATA_RATE_EX 0xFF871121
#define OID_RT_PRO_SET_BASIC_RATE 0xFF871122
#define OID_RT_PRO_READ_TSSI 0xFF871123
#define OID_RT_PRO_SET_POWER_TRACKING 0xFF871124
#define OID_RT_PRO_QRY_PWRSTATE 0xFF871150
#define OID_RT_PRO_SET_PWRSTATE 0xFF871151
/*Method 2 , using workitem */
#define OID_RT_SET_READ_REG 0xFF871181
#define OID_RT_SET_WRITE_REG 0xFF871182
#define OID_RT_SET_BURST_READ_REG 0xFF871183
#define OID_RT_SET_BURST_WRITE_REG 0xFF871184
#define OID_RT_SET_WRITE_TXCMD 0xFF871185
#define OID_RT_SET_READ16_EEPROM 0xFF871186
#define OID_RT_SET_WRITE16_EEPROM 0xFF871187
#define OID_RT_QRY_POLL_WKITEM 0xFF871188
/*For SDIO INTERFACE only*/
#define OID_RT_PRO_SYNCPAGERW_SRAM 0xFF8711A0
#define OID_RT_PRO_871X_DRV_EXT 0xFF8711A1
/*For USB INTERFACE only*/
#define OID_RT_PRO_USB_VENDOR_REQ 0xFF8711B0
#define OID_RT_PRO_SCSI_AUTO_TEST 0xFF8711B1
#define OID_RT_PRO_USB_MAC_AC_FIFO_WRITE 0xFF8711B2
#define OID_RT_PRO_USB_MAC_RX_FIFO_READ 0xFF8711B3
#define OID_RT_PRO_USB_MAC_RX_FIFO_POLLING 0xFF8711B4
#define OID_RT_PRO_H2C_SET_RATE_TABLE 0xFF8711FB
#define OID_RT_PRO_H2C_GET_RATE_TABLE 0xFF8711FC
#define OID_RT_PRO_H2C_C2H_LBK_TEST 0xFF8711FE
#define OID_RT_PRO_ENCRYPTION_CTRL 0xFF871200
#define OID_RT_PRO_ADD_STA_INFO 0xFF871201
#define OID_RT_PRO_DELE_STA_INFO 0xFF871202
#define OID_RT_PRO_QUERY_DR_VARIABLE 0xFF871203
#define OID_RT_PRO_RX_PACKET_TYPE 0xFF871204
#define OID_RT_PRO_READ_EFUSE 0xFF871205
#define OID_RT_PRO_WRITE_EFUSE 0xFF871206
#define OID_RT_PRO_RW_EFUSE_PGPKT 0xFF871207
#define OID_RT_GET_EFUSE_CURRENT_SIZE 0xFF871208
#define OID_RT_SET_BANDWIDTH 0xFF871209
#define OID_RT_SET_CRYSTAL_CAP 0xFF87120A
#define OID_RT_SET_RX_PACKET_TYPE 0xFF87120B
#define OID_RT_GET_EFUSE_MAX_SIZE 0xFF87120C
#define OID_RT_PRO_SET_TX_AGC_OFFSET 0xFF87120D
#define OID_RT_PRO_SET_PKT_TEST_MODE 0xFF87120E
#define OID_RT_PRO_FOR_EVM_TEST_SETTING 0xFF87120F
#define OID_RT_PRO_GET_THERMAL_METER 0xFF871210
#define OID_RT_RESET_PHY_RX_PACKET_COUNT 0xFF871211
#define OID_RT_GET_PHY_RX_PACKET_RECEIVED 0xFF871212
#define OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR 0xFF871213
#define OID_RT_SET_POWER_DOWN 0xFF871214
#define OID_RT_GET_POWER_MODE 0xFF871215
#define OID_RT_PRO_EFUSE 0xFF871216
#define OID_RT_PRO_EFUSE_MAP 0xFF871217
#endif /*#ifndef __CUSTOM_OID_H */
/******************************************************************************
* os_intfs.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* 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
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>.
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _OS_INTFS_C_
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kthread.h>
#include "osdep_service.h"
#include "drv_types.h"
#include "xmit_osdep.h"
#include "recv_osdep.h"
#include "rtl871x_ioctl.h"
#include "usb_osintf.h"
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("rtl871x wireless lan driver");
MODULE_AUTHOR("Larry Finger");
static char ifname[IFNAMSIZ] = "wlan%d";
/* module param defaults */
static int chip_version = RTL8712_2ndCUT;
static int rfintfs = HWPI;
static int lbkmode = RTL8712_AIR_TRX;
static int hci = RTL8712_USB;
static int ampdu_enable = 1;/*for enable tx_ampdu*/
/* The video_mode variable is for vedio mode.*/
/* It may be specify when inserting module with video_mode=1 parameter.*/
static int video_mode = 1; /* enable video mode*/
/*Ndis802_11Infrastructure; infra, ad-hoc, auto*/
static int network_mode = Ndis802_11IBSS;
static int channel = 1;/*ad-hoc support requirement*/
static int wireless_mode = WIRELESS_11BG;
static int vrtl_carrier_sense = AUTO_VCS;
static int vcs_type = RTS_CTS;
static int frag_thresh = 2346;
static int preamble = PREAMBLE_LONG;/*long, short, auto*/
static int scan_mode = 1;/*active, passive*/
static int adhoc_tx_pwr = 1;
static int soft_ap;
static int smart_ps = 1;
static int power_mgnt = PS_MODE_ACTIVE;
static int radio_enable = 1;
static int long_retry_lmt = 7;
static int short_retry_lmt = 7;
static int busy_thresh = 40;
static int ack_policy = NORMAL_ACK;
static int mp_mode;
static int software_encrypt;
static int software_decrypt;
static int wmm_enable;/* default is set to disable the wmm.*/
static int uapsd_enable;
static int uapsd_max_sp = NO_LIMIT;
static int uapsd_acbk_en;
static int uapsd_acbe_en;
static int uapsd_acvi_en;
static int uapsd_acvo_en;
static int ht_enable = 1;
static int cbw40_enable = 1;
static int rf_config = RTL8712_RF_1T2R; /* 1T2R*/
static int low_power;
/* mac address to use instead of the one stored in Efuse */
char *r8712_initmac;
static char *initmac;
module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR);
module_param(initmac, charp, 0644);
module_param(video_mode, int, 0644);
module_param(chip_version, int, 0644);
module_param(rfintfs, int, 0644);
module_param(lbkmode, int, 0644);
module_param(hci, int, 0644);
module_param(network_mode, int, 0644);
module_param(channel, int, 0644);
module_param(mp_mode, int, 0644);
module_param(wmm_enable, int, 0644);
module_param(vrtl_carrier_sense, int, 0644);
module_param(vcs_type, int, 0644);
module_param(busy_thresh, int, 0644);
module_param(ht_enable, int, 0644);
module_param(cbw40_enable, int, 0644);
module_param(ampdu_enable, int, 0644);
module_param(rf_config, int, 0644);
module_param(power_mgnt, int, 0644);
module_param(low_power, int, 0644);
MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default");
MODULE_PARM_DESC(initmac, "MAC-Address, default: use FUSE");
static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev);
static int netdev_open(struct net_device *pnetdev);
static int netdev_close(struct net_device *pnetdev);
static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev)
{
uint status = _SUCCESS;
struct registry_priv *registry_par = &padapter->registrypriv;
registry_par->chip_version = (u8)chip_version;
registry_par->rfintfs = (u8)rfintfs;
registry_par->lbkmode = (u8)lbkmode;
registry_par->hci = (u8)hci;
registry_par->network_mode = (u8)network_mode;
memcpy(registry_par->ssid.Ssid, "ANY", 3);
registry_par->ssid.SsidLength = 3;
registry_par->channel = (u8)channel;
registry_par->wireless_mode = (u8)wireless_mode;
registry_par->vrtl_carrier_sense = (u8)vrtl_carrier_sense ;
registry_par->vcs_type = (u8)vcs_type;
registry_par->frag_thresh = (u16)frag_thresh;
registry_par->preamble = (u8)preamble;
registry_par->scan_mode = (u8)scan_mode;
registry_par->adhoc_tx_pwr = (u8)adhoc_tx_pwr;
registry_par->soft_ap = (u8)soft_ap;
registry_par->smart_ps = (u8)smart_ps;
registry_par->power_mgnt = (u8)power_mgnt;
registry_par->radio_enable = (u8)radio_enable;
registry_par->long_retry_lmt = (u8)long_retry_lmt;
registry_par->short_retry_lmt = (u8)short_retry_lmt;
registry_par->busy_thresh = (u16)busy_thresh;
registry_par->ack_policy = (u8)ack_policy;
registry_par->mp_mode = (u8)mp_mode;
registry_par->software_encrypt = (u8)software_encrypt;
registry_par->software_decrypt = (u8)software_decrypt;
/*UAPSD*/
registry_par->wmm_enable = (u8)wmm_enable;
registry_par->uapsd_enable = (u8)uapsd_enable;
registry_par->uapsd_max_sp = (u8)uapsd_max_sp;
registry_par->uapsd_acbk_en = (u8)uapsd_acbk_en;
registry_par->uapsd_acbe_en = (u8)uapsd_acbe_en;
registry_par->uapsd_acvi_en = (u8)uapsd_acvi_en;
registry_par->uapsd_acvo_en = (u8)uapsd_acvo_en;
registry_par->ht_enable = (u8)ht_enable;
registry_par->cbw40_enable = (u8)cbw40_enable;
registry_par->ampdu_enable = (u8)ampdu_enable;
registry_par->rf_config = (u8)rf_config;
registry_par->low_power = (u8)low_power;
r8712_initmac = initmac;
return status;
}
static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p)
{
struct _adapter *padapter = (struct _adapter *)_netdev_priv(pnetdev);
struct sockaddr *addr = p;
if (padapter->bup == false)
memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN);
return 0;
}
static struct net_device_stats *r871x_net_get_stats(struct net_device *pnetdev)
{
struct _adapter *padapter = (struct _adapter *) _netdev_priv(pnetdev);
struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
struct recv_priv *precvpriv = &(padapter->recvpriv);
padapter->stats.tx_packets = pxmitpriv->tx_pkts;
padapter->stats.rx_packets = precvpriv->rx_pkts;
padapter->stats.tx_dropped = pxmitpriv->tx_drop;
padapter->stats.rx_dropped = precvpriv->rx_drop;
padapter->stats.tx_bytes = pxmitpriv->tx_bytes;
padapter->stats.rx_bytes = precvpriv->rx_bytes;
return &padapter->stats;
}
static const struct net_device_ops rtl8712_netdev_ops = {
.ndo_open = netdev_open,
.ndo_stop = netdev_close,
.ndo_start_xmit = r8712_xmit_entry,
.ndo_set_mac_address = r871x_net_set_mac_address,
.ndo_get_stats = r871x_net_get_stats,
.ndo_do_ioctl = r871x_ioctl,
};
struct net_device *r8712_init_netdev(void)
{
struct _adapter *padapter;
struct net_device *pnetdev;
pnetdev = alloc_etherdev(sizeof(struct _adapter));
if (!pnetdev)
return NULL;
if (dev_alloc_name(pnetdev, ifname) < 0) {
strcpy(ifname, "wlan%d");
dev_alloc_name(pnetdev, ifname);
}
padapter = (struct _adapter *) _netdev_priv(pnetdev);
padapter->pnetdev = pnetdev;
printk(KERN_INFO "r8712u: register rtl8712_netdev_ops to"
" netdev_ops\n");
pnetdev->netdev_ops = &rtl8712_netdev_ops;
pnetdev->watchdog_timeo = HZ; /* 1 second timeout */
pnetdev->wireless_handlers = (struct iw_handler_def *)
&r871x_handlers_def;
/*step 2.*/
loadparam(padapter, pnetdev);
netif_carrier_off(pnetdev);
padapter->pid = 0; /* Initial the PID value used for HW PBC.*/
return pnetdev;
}
static u32 start_drv_threads(struct _adapter *padapter)
{
padapter->cmdThread = kthread_run(r8712_cmd_thread, padapter,
padapter->pnetdev->name);
if (IS_ERR(padapter->cmdThread) < 0)
return _FAIL;
return _SUCCESS;
}
void r8712_stop_drv_threads(struct _adapter *padapter)
{
/*Below is to termindate r8712_cmd_thread & event_thread...*/
up(&padapter->cmdpriv.cmd_queue_sema);
if (padapter->cmdThread)
_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
padapter->cmdpriv.cmd_seq = 1;
}
static void start_drv_timers(struct _adapter *padapter)
{
_set_timer(&padapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
5000);
_set_timer(&padapter->mlmepriv.wdg_timer, 2000);
}
static void stop_drv_timers(struct _adapter *padapter)
{
_cancel_timer_ex(&padapter->mlmepriv.assoc_timer);
_cancel_timer_ex(&padapter->mlmepriv.sitesurveyctrl.
sitesurvey_ctrl_timer);
_cancel_timer_ex(&padapter->securitypriv.tkip_timer);
_cancel_timer_ex(&padapter->mlmepriv.scan_to_timer);
_cancel_timer_ex(&padapter->mlmepriv.dhcp_timer);
_cancel_timer_ex(&padapter->mlmepriv.wdg_timer);
}
static u8 init_default_value(struct _adapter *padapter)
{
u8 ret = _SUCCESS;
struct registry_priv *pregistrypriv = &padapter->registrypriv;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
/*xmit_priv*/
pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense;
pxmitpriv->vcs = pregistrypriv->vcs_type;
pxmitpriv->vcs_type = pregistrypriv->vcs_type;
pxmitpriv->rts_thresh = pregistrypriv->rts_thresh;
pxmitpriv->frag_len = pregistrypriv->frag_thresh;
/*ht_priv*/
{
int i;
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
phtpriv->ampdu_enable = false;/*set to disabled*/
for (i = 0; i < 16; i++)
phtpriv->baddbareq_issued[i] = false;
}
/*security_priv*/
psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
psecuritypriv->binstallGrpkey = _FAIL;
/*pwrctrl_priv*/
/*registry_priv*/
r8712_init_registrypriv_dev_network(padapter);
r8712_update_registrypriv_dev_network(padapter);
/*misc.*/
return ret;
}
u8 r8712_init_drv_sw(struct _adapter *padapter)
{
if ((r8712_init_cmd_priv(&padapter->cmdpriv)) == _FAIL)
return _FAIL;
padapter->cmdpriv.padapter = padapter;
if ((r8712_init_evt_priv(&padapter->evtpriv)) == _FAIL)
return _FAIL;
if (r8712_init_mlme_priv(padapter) == _FAIL)
return _FAIL;
_r8712_init_xmit_priv(&padapter->xmitpriv, padapter);
_r8712_init_recv_priv(&padapter->recvpriv, padapter);
memset((unsigned char *)&padapter->securitypriv, 0,
sizeof(struct security_priv));
_init_timer(&(padapter->securitypriv.tkip_timer), padapter->pnetdev,
r8712_use_tkipkey_handler, padapter);
_r8712_init_sta_priv(&padapter->stapriv);
padapter->stapriv.padapter = padapter;
r8712_init_bcmc_stainfo(padapter);
r8712_init_pwrctrl_priv(padapter);
sema_init(&(padapter->pwrctrlpriv.pnp_pwr_mgnt_sema), 0);
mp871xinit(padapter);
if (init_default_value(padapter) != _SUCCESS)
return _FAIL;
r8712_InitSwLeds(padapter);
return _SUCCESS;
}
u8 r8712_free_drv_sw(struct _adapter *padapter)
{
struct net_device *pnetdev = (struct net_device *)padapter->pnetdev;
r8712_free_cmd_priv(&padapter->cmdpriv);
r8712_free_evt_priv(&padapter->evtpriv);
r8712_DeInitSwLeds(padapter);
r8712_free_mlme_priv(&padapter->mlmepriv);
r8712_free_io_queue(padapter);
_free_xmit_priv(&padapter->xmitpriv);
_r8712_free_sta_priv(&padapter->stapriv);
_r8712_free_recv_priv(&padapter->recvpriv);
mp871xdeinit(padapter);
if (pnetdev)
os_free_netdev(pnetdev);
return _SUCCESS;
}
static void enable_video_mode(struct _adapter *padapter, int cbw40_value)
{
/* bit 8:
* 1 -> enable video mode to 96B AP
* 0 -> disable video mode to 96B AP
* bit 9:
* 1 -> enable 40MHz mode
* 0 -> disable 40MHz mode
* bit 10:
* 1 -> enable STBC
* 0 -> disable STBC
*/
u32 intcmd = 0xf4000500; /* enable bit8, bit10*/
if (cbw40_value) {
/* if the driver supports the 40M bandwidth,
* we can enable the bit 9.*/
intcmd |= 0x200;
}
r8712_fw_cmd(padapter, intcmd);
}
static int netdev_open(struct net_device *pnetdev)
{
struct _adapter *padapter = (struct _adapter *)_netdev_priv(pnetdev);
if (padapter->bup == false) {
padapter->bDriverStopped = false;
padapter->bSurpriseRemoved = false;
padapter->bup = true;
if (rtl871x_hal_init(padapter) != _SUCCESS)
goto netdev_open_error;
if (r8712_initmac == NULL)
/* Use the mac address stored in the Efuse */
memcpy(pnetdev->dev_addr,
padapter->eeprompriv.mac_addr, ETH_ALEN);
else {
/* We have to inform f/w to use user-supplied MAC
* address.
*/
msleep(200);
r8712_setMacAddr_cmd(padapter, (u8 *)pnetdev->dev_addr);
/*
* The "myid" function will get the wifi mac address
* from eeprompriv structure instead of netdev
* structure. So, we have to overwrite the mac_addr
* stored in the eeprompriv structure. In this case,
* the real mac address won't be used anymore. So that,
* the eeprompriv.mac_addr should store the mac which
* users specify.
*/
memcpy(padapter->eeprompriv.mac_addr,
pnetdev->dev_addr, ETH_ALEN);
}
if (start_drv_threads(padapter) != _SUCCESS)
goto netdev_open_error;
if (padapter->dvobjpriv.inirp_init == NULL)
goto netdev_open_error;
else
padapter->dvobjpriv.inirp_init(padapter);
r8712_set_ps_mode(padapter, padapter->registrypriv.power_mgnt,
padapter->registrypriv.smart_ps);
}
if (!netif_queue_stopped(pnetdev))
netif_start_queue(pnetdev);
else
netif_wake_queue(pnetdev);
if (video_mode)
enable_video_mode(padapter, cbw40_enable);
/* start driver mlme relation timer */
start_drv_timers(padapter);
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_NO_LINK);
return 0;
netdev_open_error:
padapter->bup = false;
netif_carrier_off(pnetdev);
netif_stop_queue(pnetdev);
return -1;
}
static int netdev_close(struct net_device *pnetdev)
{
struct _adapter *padapter = (struct _adapter *) _netdev_priv(pnetdev);
/* Close LED*/
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_POWER_OFF);
msleep(200);
/*s1.*/
if (pnetdev) {
if (!netif_queue_stopped(pnetdev))
netif_stop_queue(pnetdev);
}
/*s2.*/
/*s2-1. issue disassoc_cmd to fw*/
r8712_disassoc_cmd(padapter);
/*s2-2. indicate disconnect to os*/
r8712_ind_disconnect(padapter);
/*s2-3.*/
r8712_free_assoc_resources(padapter);
/*s2-4.*/
r8712_free_network_queue(padapter);
/*Stop driver mlme relation timer*/
stop_drv_timers(padapter);
return 0;
}
#include "mlme_osdep.h"
#ifndef __OSDEP_INTF_H_
#define __OSDEP_INTF_H_
#include "osdep_service.h"
#include "drv_types.h"
#define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0 : 1)) << 2)
struct intf_priv {
u8 *intf_dev;
/* when in USB, IO is through interrupt in/out endpoints */
struct usb_device *udev;
struct urb *piorw_urb;
struct semaphore io_retevt;
};
int r871x_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
#endif /*_OSDEP_INTF_H_*/
#ifndef __OSDEP_SERVICE_H_
#define __OSDEP_SERVICE_H_
#define _SUCCESS 1
#define _FAIL 0
#include "basic_types.h"
#include <linux/version.h>
#include <linux/spinlock.h>
#include <linux/semaphore.h>
#include <linux/sem.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <net/iw_handler.h>
#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/kref.h>
#include <linux/smp_lock.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/usb.h>
#include <linux/usb/ch9.h>
#include <linux/io.h>
#include <linux/circ_buf.h>
#include <linux/uaccess.h>
#include <asm/byteorder.h>
#include <asm/atomic.h>
#include <linux/wireless.h>
#include <linux/rtnetlink.h>
#include "ethernet.h"
#include <linux/if_arp.h>
#include <linux/firmware.h>
#define _usb_alloc_urb(x, y) usb_alloc_urb(x, y)
#define _usb_submit_urb(x, y) usb_submit_urb(x, y)
struct __queue {
struct list_head queue;
spinlock_t lock;
};
#define _pkt struct sk_buff
#define _buffer unsigned char
#define thread_exit() complete_and_exit(NULL, 0)
#define _workitem struct work_struct
#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
#define _init_queue(pqueue) \
do { \
_init_listhead(&((pqueue)->queue)); \
spin_lock_init(&((pqueue)->lock)); \
} while (0)
static inline void *_netdev_priv(struct net_device *dev)
{
return netdev_priv(dev);
}
static inline void os_free_netdev(struct net_device *dev)
{
free_netdev(dev);
}
static inline struct list_head *get_next(struct list_head *list)
{
return list->next;
}
static inline struct list_head *get_list_head(struct __queue *queue)
{
return &(queue->queue);
}
#define LIST_CONTAINOR(ptr, type, member) \
((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
static inline void _enter_hwio_critical(struct semaphore *prwlock,
unsigned long *pirqL)
{
down(prwlock);
}
static inline void _exit_hwio_critical(struct semaphore *prwlock,
unsigned long *pirqL)
{
up(prwlock);
}
static inline void list_delete(struct list_head *plist)
{
list_del_init(plist);
}
static inline void _init_timer(struct timer_list *ptimer,
struct net_device *padapter,
void *pfunc, void *cntx)
{
ptimer->function = pfunc;
ptimer->data = (addr_t)cntx;
init_timer(ptimer);
}
static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
{
mod_timer(ptimer, (jiffies+(delay_time*HZ/1000)));
}
static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled)
{
del_timer(ptimer);
*bcancelled = true; /*true ==1; false==0*/
}
static inline void _init_workitem(_workitem *pwork, void *pfunc, void *cntx)
{
INIT_WORK(pwork, pfunc);
}
static inline void _set_workitem(_workitem *pwork)
{
schedule_work(pwork);
}
#include "rtl871x_byteorder.h"
#ifndef BIT
#define BIT(x) (1 << (x))
#endif
/*
For the following list_xxx operations,
caller must guarantee the atomic context.
Otherwise, there will be racing condition.
*/
static inline u32 is_list_empty(struct list_head *phead)
{
if (list_empty(phead))
return true;
else
return false;
}
static inline void list_insert_tail(struct list_head *plist, struct list_head *phead)
{
list_add_tail(plist, phead);
}
static inline u32 _down_sema(struct semaphore *sema)
{
if (down_interruptible(sema))
return _FAIL;
else
return _SUCCESS;
}
static inline void _rtl_rwlock_init(struct semaphore *prwlock)
{
init_MUTEX(prwlock);
}
static inline void _init_listhead(struct list_head *list)
{
INIT_LIST_HEAD(list);
}
static inline u32 _queue_empty(struct __queue *pqueue)
{
return is_list_empty(&(pqueue->queue));
}
static inline u32 end_of_queue_search(struct list_head *head, struct list_head *plist)
{
if (head == plist)
return true;
else
return false;
}
static inline void sleep_schedulable(int ms)
{
u32 delta;
delta = (ms * HZ) / 1000;/*(ms)*/
if (delta == 0)
delta = 1;/* 1 ms */
set_current_state(TASK_INTERRUPTIBLE);
if (schedule_timeout(delta) != 0)
return ;
}
static inline u8 *_malloc(u32 sz)
{
u8 *pbuf;
pbuf = kmalloc(sz, GFP_ATOMIC);
return pbuf;
}
static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer)
{
return del_timer(ptimer);
}
static inline void thread_enter(void *context)
{
daemonize("%s", "RTKTHREAD");
allow_signal(SIGTERM);
}
static inline void flush_signals_thread(void)
{
if (signal_pending(current))
flush_signals(current);
}
static inline u32 _RND8(u32 sz)
{
u32 val;
val = ((sz >> 3) + ((sz & 7) ? 1 : 0)) << 3;
return val;
}
static inline u32 _RND128(u32 sz)
{
u32 val;
val = ((sz >> 7) + ((sz & 127) ? 1 : 0)) << 7;
return val;
}
static inline u32 _RND256(u32 sz)
{
u32 val;
val = ((sz >> 8) + ((sz & 255) ? 1 : 0)) << 8;
return val;
}
static inline u32 _RND512(u32 sz)
{
u32 val;
val = ((sz >> 9) + ((sz & 511) ? 1 : 0)) << 9;
return val;
}
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
#define STRUCT_PACKED __attribute__ ((packed))
#endif
/******************************************************************************
* recv_linux.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* 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
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>.
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _RECV_OSDEP_C_
#include "osdep_service.h"
#include "drv_types.h"
#include "wifi.h"
#include "recv_osdep.h"
#include "osdep_intf.h"
#include "usb_ops.h"
/*init os related resource in struct recv_priv*/
/*alloc os related resource in union recv_frame*/
int r8712_os_recv_resource_alloc(struct _adapter *padapter,
union recv_frame *precvframe)
{
precvframe->u.hdr.pkt_newalloc = precvframe->u.hdr.pkt = NULL;
return _SUCCESS;
}
/*alloc os related resource in struct recv_buf*/
int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
struct recv_buf *precvbuf)
{
int res = _SUCCESS;
precvbuf->irp_pending = false;
precvbuf->purb = _usb_alloc_urb(0, GFP_KERNEL);
if (precvbuf->purb == NULL)
res = _FAIL;
precvbuf->pskb = NULL;
precvbuf->reuse = false;
precvbuf->pallocated_buf = NULL;
precvbuf->pbuf = NULL;
precvbuf->pdata = NULL;
precvbuf->phead = NULL;
precvbuf->ptail = NULL;
precvbuf->pend = NULL;
precvbuf->transfer_len = 0;
precvbuf->len = 0;
return res;
}
/*free os related resource in struct recv_buf*/
int r8712_os_recvbuf_resource_free(struct _adapter *padapter,
struct recv_buf *precvbuf)
{
if (precvbuf->pskb)
dev_kfree_skb_any(precvbuf->pskb);
if (precvbuf->purb) {
usb_kill_urb(precvbuf->purb);
usb_free_urb(precvbuf->purb);
}
return _SUCCESS;
}
void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup)
{
union iwreq_data wrqu;
struct iw_michaelmicfailure ev;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
memset(&ev, 0x00, sizeof(ev));
if (bgroup)
ev.flags |= IW_MICFAILURE_GROUP;
else
ev.flags |= IW_MICFAILURE_PAIRWISE;
ev.src_addr.sa_family = ARPHRD_ETHER;
memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN);
memset(&wrqu, 0x00, sizeof(wrqu));
wrqu.data.length = sizeof(ev);
wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu,
(char *)&ev);
}
void r8712_recv_indicatepkt(struct _adapter *padapter,
union recv_frame *precv_frame)
{
struct recv_priv *precvpriv;
struct __queue *pfree_recv_queue;
_pkt *skb;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
precvpriv = &(padapter->recvpriv);
pfree_recv_queue = &(precvpriv->free_recv_queue);
skb = precv_frame->u.hdr.pkt;
if (skb == NULL)
goto _recv_indicatepkt_drop;
skb->data = precv_frame->u.hdr.rx_data;
#ifdef NET_SKBUFF_DATA_USES_OFFSET
skb->tail = (sk_buff_data_t)(precv_frame->u.hdr.rx_tail -
precv_frame->u.hdr.rx_head);
#else
skb->tail = (sk_buff_data_t)precv_frame->u.hdr.rx_tail;
#endif
skb->len = precv_frame->u.hdr.len;
if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
skb->ip_summed = CHECKSUM_UNNECESSARY;
else
skb->ip_summed = CHECKSUM_NONE;
skb->dev = padapter->pnetdev;
skb->protocol = eth_type_trans(skb, padapter->pnetdev);
netif_rx(skb);
precv_frame->u.hdr.pkt = NULL; /* pointers to NULL before
* r8712_free_recvframe() */
r8712_free_recvframe(precv_frame, pfree_recv_queue);
return;
_recv_indicatepkt_drop:
/*enqueue back to free_recv_queue*/
if (precv_frame)
r8712_free_recvframe(precv_frame, pfree_recv_queue);
precvpriv->rx_drop++;
}
void r8712_os_read_port(struct _adapter *padapter, struct recv_buf *precvbuf)
{
struct recv_priv *precvpriv = &padapter->recvpriv;
precvbuf->ref_cnt--;
/*free skb in recv_buf*/
dev_kfree_skb_any(precvbuf->pskb);
precvbuf->pskb = NULL;
precvbuf->reuse = false;
if (precvbuf->irp_pending == false)
r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
(unsigned char *)precvbuf);
}
static void _r8712_reordering_ctrl_timeout_handler (void *FunctionContext)
{
struct recv_reorder_ctrl *preorder_ctrl =
(struct recv_reorder_ctrl *)FunctionContext;
r8712_reordering_ctrl_timeout_handler(preorder_ctrl);
}
void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
{
struct _adapter *padapter = preorder_ctrl->padapter;
_init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev,
_r8712_reordering_ctrl_timeout_handler, preorder_ctrl);
}
#ifndef __RECV_OSDEP_H_
#define __RECV_OSDEP_H_
#include "osdep_service.h"
#include "drv_types.h"
#include <linux/skbuff.h>
sint _r8712_init_recv_priv(struct recv_priv *precvpriv,
struct _adapter *padapter);
void _r8712_free_recv_priv(struct recv_priv *precvpriv);
s32 r8712_recv_entry(union recv_frame *precv_frame);
void r8712_recv_indicatepkt(struct _adapter *adapter,
union recv_frame *precv_frame);
void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup);
int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter);
void r8712_free_recv_priv(struct recv_priv *precvpriv);
int r8712_os_recv_resource_alloc(struct _adapter *padapter,
union recv_frame *precvframe);
int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
struct recv_buf *precvbuf);
int r8712_os_recvbuf_resource_free(struct _adapter *padapter,
struct recv_buf *precvbuf);
void r8712_os_read_port(struct _adapter *padapter, struct recv_buf *precvbuf);
void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl);
#endif
#ifndef __RTL8712_BITDEF_H__
#define __RTL8712_BITDEF_H__
#include "rtl8712_cmdctrl_bitdef.h"
#include "rtl8712_syscfg_bitdef.h"
#include "rtl8712_macsetting_bitdef.h"
#include "rtl8712_timectrl_bitdef.h"
#include "rtl8712_fifoctrl_bitdef.h"
#include "rtl8712_ratectrl_bitdef.h"
#include "rtl8712_edcasetting_bitdef.h"
#include "rtl8712_wmac_bitdef.h"
#include "rtl8712_security_bitdef.h"
#include "rtl8712_powersave_bitdef.h"
#include "rtl8712_gp_bitdef.h"
#include "rtl8712_interrupt_bitdef.h"
#include "rtl8712_debugctrl_bitdef.h"
#endif /* __RTL8712_BITDEF_H__ */
/******************************************************************************
* rtl8712_cmd.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* 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
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>.
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _RTL8712_CMD_C_
#include "osdep_service.h"
#include "drv_types.h"
#include "recv_osdep.h"
#include "mlme_osdep.h"
#include "rtl871x_byteorder.h"
#include "rtl871x_ioctl_set.h"
static void check_hw_pbc(struct _adapter *padapter)
{
u8 tmp1byte;
r8712_write8(padapter, MAC_PINMUX_CTRL, (GPIOMUX_EN | GPIOSEL_GPIO));
tmp1byte = r8712_read8(padapter, GPIO_IO_SEL);
tmp1byte &= ~(HAL_8192S_HW_GPIO_WPS_BIT);
r8712_write8(padapter, GPIO_IO_SEL, tmp1byte);
tmp1byte = r8712_read8(padapter, GPIO_CTRL);
if (tmp1byte == 0xff)
return ;
if (tmp1byte&HAL_8192S_HW_GPIO_WPS_BIT) {
/* Here we only set bPbcPressed to true
* After trigger PBC, the variable will be set to false */
DBG_8712("CheckPbcGPIO - PBC is pressed !!!!\n");
/* 0 is the default value and it means the application monitors
* the HW PBC doesn't privde its pid to driver. */
if (padapter->pid == 0)
return;
kill_pid(find_vpid(padapter->pid), SIGUSR1, 1);
}
}
/* query rx phy status from fw.
* Adhoc mode: beacon.
* Infrastructure mode: beacon , data. */
static void query_fw_rx_phy_status(struct _adapter *padapter)
{
u32 val32 = 0;
int pollingcnts = 50;
if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == true) {
r8712_write32(padapter, IOCMD_CTRL_REG, 0xf4000001);
msleep(100);
/* Wait FW complete IO Cmd */
while ((r8712_read32(padapter, IOCMD_CTRL_REG)) &&
(pollingcnts > 0)) {
pollingcnts--;
msleep(20);
}
if (pollingcnts != 0)
val32 = r8712_read32(padapter, IOCMD_DATA_REG);
else /* time out */
val32 = 0;
val32 = val32 >> 4;
padapter->recvpriv.fw_rssi =
(u8)r8712_signal_scale_mapping(val32);
}
}
/* check mlme, hw, phy, or dynamic algorithm status. */
static void StatusWatchdogCallback(struct _adapter *padapter)
{
check_hw_pbc(padapter);
query_fw_rx_phy_status(padapter);
}
static void r871x_internal_cmd_hdl(struct _adapter *padapter, u8 *pbuf)
{
struct drvint_cmd_parm *pdrvcmd;
if (!pbuf)
return;
pdrvcmd = (struct drvint_cmd_parm *)pbuf;
switch (pdrvcmd->i_cid) {
case WDG_WK_CID:
StatusWatchdogCallback(padapter);
break;
default:
break;
}
kfree(pdrvcmd->pbuf);
}
static u8 read_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
/* invoke cmd->callback function */
pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
if (pcmd_callback == NULL)
r8712_free_cmd_obj(pcmd);
else
pcmd_callback(padapter, pcmd);
return H2C_SUCCESS;
}
static u8 write_macreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
/* invoke cmd->callback function */
pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
if (pcmd_callback == NULL)
r8712_free_cmd_obj(pcmd);
else
pcmd_callback(padapter, pcmd);
return H2C_SUCCESS;
}
static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
u32 val;
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct readBB_parm *prdbbparm;
struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
prdbbparm = (struct readBB_parm *)pcmd->parmbuf;
if (pcmd->rsp && pcmd->rspsz > 0)
memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz);
pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
if (pcmd_callback == NULL)
r8712_free_cmd_obj(pcmd);
else
pcmd_callback(padapter, pcmd);
return H2C_SUCCESS;
}
static u8 write_bbreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct writeBB_parm *pwritebbparm;
struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
pwritebbparm = (struct writeBB_parm *)pcmd->parmbuf;
pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
if (pcmd_callback == NULL)
r8712_free_cmd_obj(pcmd);
else
pcmd_callback(padapter, pcmd);
return H2C_SUCCESS;
}
static u8 read_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
u32 val;
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct readRF_parm *prdrfparm;
struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
prdrfparm = (struct readRF_parm *)pcmd->parmbuf;
if (pcmd->rsp && pcmd->rspsz > 0)
memcpy(pcmd->rsp, (u8 *)&val, pcmd->rspsz);
pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
if (pcmd_callback == NULL)
r8712_free_cmd_obj(pcmd);
else
pcmd_callback(padapter, pcmd);
return H2C_SUCCESS;
}
static u8 write_rfreg_hdl(struct _adapter *padapter, u8 *pbuf)
{
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct writeRF_parm *pwriterfparm;
struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
pwriterfparm = (struct writeRF_parm *)pcmd->parmbuf;
pcmd_callback = cmd_callback[pcmd->cmdcode].callback;
if (pcmd_callback == NULL)
r8712_free_cmd_obj(pcmd);
else
pcmd_callback(padapter, pcmd);
return H2C_SUCCESS;
}
static u8 sys_suspend_hdl(struct _adapter *padapter, u8 *pbuf)
{
struct cmd_obj *pcmd = (struct cmd_obj *)pbuf;
struct usb_suspend_parm *psetusbsuspend;
psetusbsuspend = (struct usb_suspend_parm *)pcmd->parmbuf;
r8712_free_cmd_obj(pcmd);
return H2C_SUCCESS;
}
static struct cmd_obj *cmd_hdl_filter(struct _adapter *padapter,
struct cmd_obj *pcmd)
{
struct cmd_obj *pcmd_r;
if (pcmd == NULL)
return pcmd;
pcmd_r = NULL;
switch (pcmd->cmdcode) {
case GEN_CMD_CODE(_Read_MACREG):
read_macreg_hdl(padapter, (u8 *)pcmd);
pcmd_r = pcmd;
break;
case GEN_CMD_CODE(_Write_MACREG):
write_macreg_hdl(padapter, (u8 *)pcmd);
pcmd_r = pcmd;
break;
case GEN_CMD_CODE(_Read_BBREG):
read_bbreg_hdl(padapter, (u8 *)pcmd);
break;
case GEN_CMD_CODE(_Write_BBREG):
write_bbreg_hdl(padapter, (u8 *)pcmd);
break;
case GEN_CMD_CODE(_Read_RFREG):
read_rfreg_hdl(padapter, (u8 *)pcmd);
break;
case GEN_CMD_CODE(_Write_RFREG):
write_rfreg_hdl(padapter, (u8 *)pcmd);
break;
case GEN_CMD_CODE(_SetUsbSuspend):
sys_suspend_hdl(padapter, (u8 *)pcmd);
break;
case GEN_CMD_CODE(_JoinBss):
r8712_joinbss_reset(padapter);
/* Before set JoinBss_CMD to FW, driver must ensure FW is in
* PS_MODE_ACTIVE. Directly write rpwm to radio on and assign
* new pwr_mode to Driver, instead of use workitem to change
* state. */
if (padapter->pwrctrlpriv.pwr_mode > PS_MODE_ACTIVE) {
padapter->pwrctrlpriv.pwr_mode = PS_MODE_ACTIVE;
_enter_pwrlock(&(padapter->pwrctrlpriv.lock));
r8712_set_rpwm(padapter, PS_STATE_S4);
up(&(padapter->pwrctrlpriv.lock));
}
pcmd_r = pcmd;
break;
case _DRV_INT_CMD_:
r871x_internal_cmd_hdl(padapter, pcmd->parmbuf);
r8712_free_cmd_obj(pcmd);
pcmd_r = NULL;
break;
default:
pcmd_r = pcmd;
break;
}
return pcmd_r; /* if returning pcmd_r == NULL, pcmd must be free. */
}
static u8 check_cmd_fifo(struct _adapter *padapter, uint sz)
{
u8 res = _SUCCESS;
return res;
}
u8 r8712_fw_cmd(struct _adapter *pAdapter, u32 cmd)
{
int pollingcnts = 50;
r8712_write32(pAdapter, IOCMD_CTRL_REG, cmd);
msleep(100);
while ((0 != r8712_read32(pAdapter, IOCMD_CTRL_REG)) &&
(pollingcnts > 0)) {
pollingcnts--;
msleep(20);
}
if (pollingcnts == 0)
return false;
return true;
}
void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 *value, u8 flag)
{
if (flag == 0) /* set */
r8712_write32(pAdapter, IOCMD_DATA_REG, *value);
else /* query */
*value = r8712_read32(pAdapter, IOCMD_DATA_REG);
}
int r8712_cmd_thread(void *context)
{
struct cmd_obj *pcmd;
unsigned int cmdsz, wr_sz, *pcmdbuf, *prspbuf;
struct tx_desc *pdesc;
void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd);
struct _adapter *padapter = (struct _adapter *)context;
struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
thread_enter(padapter);
while (1) {
if ((_down_sema(&(pcmdpriv->cmd_queue_sema))) == _FAIL)
break;
if ((padapter->bDriverStopped == true) ||
(padapter->bSurpriseRemoved == true))
break;
if (r8712_register_cmd_alive(padapter) != _SUCCESS)
continue;
_next:
pcmd = r8712_dequeue_cmd(&(pcmdpriv->cmd_queue));
if (!(pcmd)) {
r8712_unregister_cmd_alive(padapter);
continue;
}
pcmdbuf = (unsigned int *)pcmdpriv->cmd_buf;
prspbuf = (unsigned int *)pcmdpriv->rsp_buf;
pdesc = (struct tx_desc *)pcmdbuf;
memset(pdesc, 0, TXDESC_SIZE);
pcmd = cmd_hdl_filter(padapter, pcmd);
if (pcmd) { /* if pcmd != NULL, cmd will be handled by f/w */
struct dvobj_priv *pdvobj = (struct dvobj_priv *)
&padapter->dvobjpriv;
u8 blnPending = 0;
pcmdpriv->cmd_issued_cnt++;
cmdsz = _RND8((pcmd->cmdsz)); /* _RND8 */
wr_sz = TXDESC_SIZE + 8 + cmdsz;
pdesc->txdw0 |= cpu_to_le32((wr_sz-TXDESC_SIZE) &
0x0000ffff);
if (pdvobj->ishighspeed) {
if ((wr_sz % 512) == 0)
blnPending = 1;
} else {
if ((wr_sz % 64) == 0)
blnPending = 1;
}
if (blnPending) /* 32 bytes for TX Desc - 8 offset */
pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE +
OFFSET_SZ + 8) << OFFSET_SHT) &
0x00ff0000);
else {
pdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE +
OFFSET_SZ) <<
OFFSET_SHT) &
0x00ff0000);
}
pdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG);
pdesc->txdw1 |= cpu_to_le32((0x13 << QSEL_SHT) &
0x00001f00);
pcmdbuf += (TXDESC_SIZE >> 2);
*pcmdbuf = cpu_to_le32((cmdsz & 0x0000ffff) |
(pcmd->cmdcode << 16) |
(pcmdpriv->cmd_seq << 24));
pcmdbuf += 2 ; /* 8 bytes aligment */
memcpy((u8 *)pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
while (check_cmd_fifo(padapter, wr_sz) == _FAIL) {
if ((padapter->bDriverStopped == true) ||
(padapter->bSurpriseRemoved == true))
break;
msleep(100);
continue;
}
if (blnPending)
wr_sz += 8; /* Append 8 bytes */
r8712_write_mem(padapter, RTL8712_DMA_H2CCMD, wr_sz,
(u8 *)pdesc);
pcmdpriv->cmd_seq++;
if (pcmd->cmdcode == GEN_CMD_CODE(_CreateBss)) {
pcmd->res = H2C_SUCCESS;
pcmd_callback = cmd_callback[pcmd->
cmdcode].callback;
if (pcmd_callback)
pcmd_callback(padapter, pcmd);
continue;
}
if (pcmd->cmdcode == GEN_CMD_CODE(_SetPwrMode)) {
if (padapter->pwrctrlpriv.bSleep) {
_enter_pwrlock(&(padapter->
pwrctrlpriv.lock));
r8712_set_rpwm(padapter, PS_STATE_S2);
up(&padapter->pwrctrlpriv.lock);
}
}
r8712_free_cmd_obj(pcmd);
if (_queue_empty(&(pcmdpriv->cmd_queue))) {
r8712_unregister_cmd_alive(padapter);
continue;
} else
goto _next;
} else
goto _next;
flush_signals_thread();
}
/* free all cmd_obj resources */
do {
pcmd = r8712_dequeue_cmd(&(pcmdpriv->cmd_queue));
if (pcmd == NULL)
break;
r8712_free_cmd_obj(pcmd);
} while (1);
up(&pcmdpriv->terminate_cmdthread_sema);
thread_exit();
}
void r8712_event_handle(struct _adapter *padapter, uint *peventbuf)
{
u8 evt_code, evt_seq;
u16 evt_sz;
void (*event_callback)(struct _adapter *dev, u8 *pbuf);
struct evt_priv *pevt_priv = &(padapter->evtpriv);
if (peventbuf == NULL)
goto _abort_event_;
evt_sz = (u16)(le32_to_cpu(*peventbuf) & 0xffff);
evt_seq = (u8)((le32_to_cpu(*peventbuf) >> 24) & 0x7f);
evt_code = (u8)((le32_to_cpu(*peventbuf) >> 16) & 0xff);
/* checking event sequence... */
if ((evt_seq & 0x7f) != pevt_priv->event_seq) {
pevt_priv->event_seq = ((evt_seq + 1) & 0x7f);
goto _abort_event_;
}
/* checking if event code is valid */
if (evt_code >= MAX_C2HEVT) {
pevt_priv->event_seq = ((evt_seq+1) & 0x7f);
goto _abort_event_;
} else if ((evt_code == GEN_EVT_CODE(_Survey)) &&
(evt_sz > sizeof(struct wlan_bssid_ex))) {
pevt_priv->event_seq = ((evt_seq+1)&0x7f);
goto _abort_event_;
}
/* checking if event size match the event parm size */
if ((wlanevents[evt_code].parmsize) &&
(wlanevents[evt_code].parmsize != evt_sz)) {
pevt_priv->event_seq = ((evt_seq+1)&0x7f);
goto _abort_event_;
} else if ((evt_sz == 0) && (evt_code != GEN_EVT_CODE(_WPS_PBC))) {
pevt_priv->event_seq = ((evt_seq+1)&0x7f);
goto _abort_event_;
}
pevt_priv->event_seq++; /* update evt_seq */
if (pevt_priv->event_seq > 127)
pevt_priv->event_seq = 0;
peventbuf = peventbuf + 2; /* move to event content, 8 bytes aligment */
if (peventbuf) {
event_callback = wlanevents[evt_code].event_callback;
if (event_callback)
event_callback(padapter, (u8 *)peventbuf);
}
pevt_priv->evt_done_cnt++;
_abort_event_:
return;
}
#ifndef __RTL8712_CMD_H_
#define __RTL8712_CMD_H_
u8 r8712_fw_cmd(struct _adapter *pAdapter, u32 cmd);
void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 *value, u8 flag);
enum rtl8712_h2c_cmd {
GEN_CMD_CODE(_Read_MACREG), /*0*/
GEN_CMD_CODE(_Write_MACREG),
GEN_CMD_CODE(_Read_BBREG),
GEN_CMD_CODE(_Write_BBREG),
GEN_CMD_CODE(_Read_RFREG),
GEN_CMD_CODE(_Write_RFREG), /*5*/
GEN_CMD_CODE(_Read_EEPROM),
GEN_CMD_CODE(_Write_EEPROM),
GEN_CMD_CODE(_Read_EFUSE),
GEN_CMD_CODE(_Write_EFUSE),
GEN_CMD_CODE(_Read_CAM), /*10*/
GEN_CMD_CODE(_Write_CAM),
GEN_CMD_CODE(_setBCNITV),
GEN_CMD_CODE(_setMBIDCFG),
GEN_CMD_CODE(_JoinBss), /*14*/
GEN_CMD_CODE(_DisConnect), /*15*/
GEN_CMD_CODE(_CreateBss),
GEN_CMD_CODE(_SetOpMode),
GEN_CMD_CODE(_SiteSurvey), /*18*/
GEN_CMD_CODE(_SetAuth),
GEN_CMD_CODE(_SetKey), /*20*/
GEN_CMD_CODE(_SetStaKey),
GEN_CMD_CODE(_SetAssocSta),
GEN_CMD_CODE(_DelAssocSta),
GEN_CMD_CODE(_SetStaPwrState),
GEN_CMD_CODE(_SetBasicRate), /*25*/
GEN_CMD_CODE(_GetBasicRate),
GEN_CMD_CODE(_SetDataRate),
GEN_CMD_CODE(_GetDataRate),
GEN_CMD_CODE(_SetPhyInfo),
GEN_CMD_CODE(_GetPhyInfo), /*30*/
GEN_CMD_CODE(_SetPhy),
GEN_CMD_CODE(_GetPhy),
GEN_CMD_CODE(_readRssi),
GEN_CMD_CODE(_readGain),
GEN_CMD_CODE(_SetAtim), /*35*/
GEN_CMD_CODE(_SetPwrMode),
GEN_CMD_CODE(_JoinbssRpt),
GEN_CMD_CODE(_SetRaTable),
GEN_CMD_CODE(_GetRaTable),
GEN_CMD_CODE(_GetCCXReport), /*40*/
GEN_CMD_CODE(_GetDTMReport),
GEN_CMD_CODE(_GetTXRateStatistics),
GEN_CMD_CODE(_SetUsbSuspend),
GEN_CMD_CODE(_SetH2cLbk),
GEN_CMD_CODE(_AddBAReq), /*45*/
GEN_CMD_CODE(_SetChannel), /*46*/
/* MP_OFFLOAD Start (47~54)*/
GEN_CMD_CODE(_SetTxPower),
GEN_CMD_CODE(_SwitchAntenna),
GEN_CMD_CODE(_SetCrystalCap),
GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/
GEN_CMD_CODE(_SetSingleToneTx),
GEN_CMD_CODE(_SetCarrierSuppressionTx),
GEN_CMD_CODE(_SetContinuousTx),
GEN_CMD_CODE(_SwitchBandwidth), /*54*/
/* MP_OFFLOAD End*/
GEN_CMD_CODE(_TX_Beacon), /*55*/
GEN_CMD_CODE(_SetPowerTracking),
GEN_CMD_CODE(_AMSDU_TO_AMPDU), /*57*/
GEN_CMD_CODE(_SetMacAddress), /*58*/
MAX_H2CCMD
};
#define _GetBBReg_CMD_ _Read_BBREG_CMD_
#define _SetBBReg_CMD_ _Write_BBREG_CMD_
#define _GetRFReg_CMD_ _Read_RFREG_CMD_
#define _SetRFReg_CMD_ _Write_RFREG_CMD_
#define _DRV_INT_CMD_ (MAX_H2CCMD+1)
#define _SetRFIntFs_CMD_ (MAX_H2CCMD+2)
#ifdef _RTL8712_CMD_C_
static struct _cmd_callback cmd_callback[] = {
{GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/
{GEN_CMD_CODE(_Write_MACREG), NULL},
{GEN_CMD_CODE(_Read_BBREG), &r8712_getbbrfreg_cmdrsp_callback},
{GEN_CMD_CODE(_Write_BBREG), NULL},
{GEN_CMD_CODE(_Read_RFREG), &r8712_getbbrfreg_cmdrsp_callback},
{GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/
{GEN_CMD_CODE(_Read_EEPROM), NULL},
{GEN_CMD_CODE(_Write_EEPROM), NULL},
{GEN_CMD_CODE(_Read_EFUSE), NULL},
{GEN_CMD_CODE(_Write_EFUSE), NULL},
{GEN_CMD_CODE(_Read_CAM), NULL}, /*10*/
{GEN_CMD_CODE(_Write_CAM), NULL},
{GEN_CMD_CODE(_setBCNITV), NULL},
{GEN_CMD_CODE(_setMBIDCFG), NULL},
{GEN_CMD_CODE(_JoinBss), &r8712_joinbss_cmd_callback}, /*14*/
{GEN_CMD_CODE(_DisConnect), &r8712_disassoc_cmd_callback}, /*15*/
{GEN_CMD_CODE(_CreateBss), &r8712_createbss_cmd_callback},
{GEN_CMD_CODE(_SetOpMode), NULL},
{GEN_CMD_CODE(_SiteSurvey), &r8712_survey_cmd_callback}, /*18*/
{GEN_CMD_CODE(_SetAuth), NULL},
{GEN_CMD_CODE(_SetKey), NULL}, /*20*/
{GEN_CMD_CODE(_SetStaKey), &r8712_setstaKey_cmdrsp_callback},
{GEN_CMD_CODE(_SetAssocSta), &r8712_setassocsta_cmdrsp_callback},
{GEN_CMD_CODE(_DelAssocSta), NULL},
{GEN_CMD_CODE(_SetStaPwrState), NULL},
{GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/
{GEN_CMD_CODE(_GetBasicRate), NULL},
{GEN_CMD_CODE(_SetDataRate), NULL},
{GEN_CMD_CODE(_GetDataRate), NULL},
{GEN_CMD_CODE(_SetPhyInfo), NULL},
{GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/
{GEN_CMD_CODE(_SetPhy), NULL},
{GEN_CMD_CODE(_GetPhy), NULL},
{GEN_CMD_CODE(_readRssi), NULL},
{GEN_CMD_CODE(_readGain), NULL},
{GEN_CMD_CODE(_SetAtim), NULL}, /*35*/
{GEN_CMD_CODE(_SetPwrMode), NULL},
{GEN_CMD_CODE(_JoinbssRpt), NULL},
{GEN_CMD_CODE(_SetRaTable), NULL},
{GEN_CMD_CODE(_GetRaTable), NULL},
{GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/
{GEN_CMD_CODE(_GetDTMReport), NULL},
{GEN_CMD_CODE(_GetTXRateStatistics), NULL},
{GEN_CMD_CODE(_SetUsbSuspend), NULL},
{GEN_CMD_CODE(_SetH2cLbk), NULL},
{GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/
{GEN_CMD_CODE(_SetChannel), NULL}, /*46*/
/* MP_OFFLOAD Start (47~54)*/
{GEN_CMD_CODE(_SetTxPower), NULL},
{GEN_CMD_CODE(_SwitchAntenna), NULL},
{GEN_CMD_CODE(_SetCrystalCap), NULL},
{GEN_CMD_CODE(_SetSingleCarrierTx), NULL}, /*50*/
{GEN_CMD_CODE(_SetSingleToneTx), NULL},
{GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL},
{GEN_CMD_CODE(_SetContinuousTx), NULL},
{GEN_CMD_CODE(_SwitchBandwidth), NULL}, /*54*/
/* MP_OFFLOAD End*/
{GEN_CMD_CODE(_TX_Beacon), NULL}, /*55*/
{GEN_CMD_CODE(_SetPowerTracking), NULL},
{GEN_CMD_CODE(_AMSDU_TO_AMPDU), NULL}, /*57*/
{GEN_CMD_CODE(_SetMacAddress), NULL}, /*58*/
};
#endif
#endif
#ifndef __RTL8712_CMDCTRL_BITDEF_H__
#define __RTL8712_CMDCTRL_BITDEF_H__
/*
* 2. Command Control Registers (Offset: 0x0040 - 0x004F)*/
/*--------------------------------------------------------------------------*/
/* 8192S (CMD) command register bits (Offset 0x40, 16 bits)*/
/*--------------------------------------------------------------------------*/
#define _APSDOFF_STATUS BIT(15)
#define _APSDOFF BIT(14)
#define _BBRSTn BIT(13) /*Enable OFDM/CCK*/
#define _BB_GLB_RSTn BIT(12) /*Enable BB*/
#define _SCHEDULE_EN BIT(10) /*Enable MAC scheduler*/
#define _MACRXEN BIT(9)
#define _MACTXEN BIT(8)
#define _DDMA_EN BIT(7) /*FW off load function enable*/
#define _FW2HW_EN BIT(6) /*MAC every module reset */
#define _RXDMA_EN BIT(5)
#define _TXDMA_EN BIT(4)
#define _HCI_RXDMA_EN BIT(3)
#define _HCI_TXDMA_EN BIT(2)
/*TXPAUSE*/
#define _STOPHCCA BIT(6)
#define _STOPHIGH BIT(5)
#define _STOPMGT BIT(4)
#define _STOPVO BIT(3)
#define _STOPVI BIT(2)
#define _STOPBE BIT(1)
#define _STOPBK BIT(0)
/*TCR*/
#define _DISCW BIT(20)
#define _ICV BIT(19)
#define _CFEND_FMT BIT(17)
#define _CRC BIT(16)
#define _FWRDY BIT(7)
#define _BASECHG BIT(6)
#define _IMEM_RDY BIT(5)
#define _DMEM_CODE_DONE BIT(4)
#define _EMEM_CHK_RPT BIT(3)
#define _EMEM_CODE_DONE BIT(2)
#define _IMEM_CHK_RPT BIT(1)
#define _IMEM_CODE_DONE BIT(0)
#define _TXDMA_INIT_VALUE (_IMEM_CHK_RPT|_EMEM_CHK_RPT)
/*RCR*/
#define _ENMBID BIT(27)
#define _APP_PHYST_RXFF BIT(25)
#define _APP_PHYST_STAFF BIT(24)
#define _CBSSID BIT(23)
#define _APWRMGT BIT(22)
#define _ADD3 BIT(21)
#define _AMF BIT(20)
#define _ACF BIT(19)
#define _ADF BIT(18)
#define _APP_MIC BIT(17)
#define _APP_ICV BIT(16)
#define _RXFTH_MSK 0x0000E000
#define _RXFTH_SHT 13
#define _AICV BIT(12)
#define _RXPKTLMT_MSK 0x00000FC0
#define _RXPKTLMT_SHT 6
#define _ACRC32 BIT(5)
#define _AB BIT(3)
#define _AM BIT(2)
#define _APM BIT(1)
#define _AAP BIT(0)
/*MSR*/
#define _NETTYPE_MSK 0x03
#define _NETTYPE_SHT 0
/*BT*/
#define _BTMODE_MSK 0x06
#define _BTMODE_SHT 1
#define _ENBT BIT(0)
/*MBIDCTRL*/
#define _ENMBID_MODE BIT(15)
#define _BCNNO_MSK 0x7000
#define _BCNNO_SHT 12
#define _BCNSPACE_MSK 0x0FFF
#define _BCNSPACE_SHT 0
#endif /* __RTL8712_CMDCTRL_BITDEF_H__*/
#ifndef __RTL8712_CMDCTRL_REGDEF_H__
#define __RTL8712_CMDCTRL_REGDEF_H__
#define CR (RTL8712_CMDCTRL_ + 0x0000)
#define TXPAUSE (RTL8712_CMDCTRL_ + 0x0002)
#define TCR (RTL8712_CMDCTRL_ + 0x0004)
#define RCR (RTL8712_CMDCTRL_ + 0x0008)
#define MSR (RTL8712_CMDCTRL_ + 0x000C)
#define SYSF_CFG (RTL8712_CMDCTRL_ + 0x000D)
#define MBIDCTRL (RTL8712_CMDCTRL_ + 0x000E)
#endif /* __RTL8712_CMDCTRL_REGDEF_H__ */
#ifndef __RTL8712_DEBUGCTRL_BITDEF_H__
#define __RTL8712_DEBUGCTRL_BITDEF_H__
/*BIST*/
#define _BIST_RST BIT(0)
/*LMS*/
#define _LMS_MSK 0x03
/*WDG_CTRL*/
#define _OVSEL_MSK 0x0600
#define _OVSEL_SHT 9
#define _WDGCLR BIT(8)
#define _WDGEN_MSK 0x00FF
#define _WDGEN_SHT 0
/*INTM*/
#define _TXTIMER_MSK 0xF000
#define _TXTIMER_SHT 12
#define _TXNUM_MSK 0x0F00
#define _TXNUM_SHT 8
#define _RXTIMER_MSK 0x00F0
#define _RXTIMER_SHT 4
#define _RXNUM_MSK 0x000F
#define _RXNUM_SHT 0
/*FDLOCKTURN0*/
/*FDLOCKTURN1*/
#define _TURN1 BIT(0)
/*FDLOCKFLAG0*/
/*FDLOCKFLAG1*/
#define _LOCKFLAG1_MSK 0x03
#endif /* __RTL8712_DEBUGCTRL_BITDEF_H__ */
#ifndef __RTL8712_DEBUGCTRL_REGDEF_H__
#define __RTL8712_DEBUGCTRL_REGDEF_H__
#define BIST (RTL8712_DEBUGCTRL_ + 0x00)
#define DBS (RTL8712_DEBUGCTRL_ + 0x04)
#define LMS (RTL8712_DEBUGCTRL_ + 0x05)
#define CPUINST (RTL8712_DEBUGCTRL_ + 0x08)
#define CPUCAUSE (RTL8712_DEBUGCTRL_ + 0x0C)
#define LBUS_ERR_ADDR (RTL8712_DEBUGCTRL_ + 0x10)
#define LBUS_ERR_CMD (RTL8712_DEBUGCTRL_ + 0x14)
#define LBUS_ERR_DATA_L (RTL8712_DEBUGCTRL_ + 0x18)
#define LBUS_ERR_DATA_H (RTL8712_DEBUGCTRL_ + 0x1C)
#define LBUS_EXCEPTION_ADDR (RTL8712_DEBUGCTRL_ + 0x20)
#define WDG_CTRL (RTL8712_DEBUGCTRL_ + 0x24)
#define INTMTU (RTL8712_DEBUGCTRL_ + 0x28)
#define INTM (RTL8712_DEBUGCTRL_ + 0x2A)
#define FDLOCKTURN0 (RTL8712_DEBUGCTRL_ + 0x2C)
#define FDLOCKTURN1 (RTL8712_DEBUGCTRL_ + 0x2D)
#define FDLOCKFLAG0 (RTL8712_DEBUGCTRL_ + 0x2E)
#define FDLOCKFLAG1 (RTL8712_DEBUGCTRL_ + 0x2F)
#define TRXPKTBUF_DBG_DATA (RTL8712_DEBUGCTRL_ + 0x30)
#define TRXPKTBUF_DBG_CTRL (RTL8712_DEBUGCTRL_ + 0x38)
#define DPLL_MON (RTL8712_DEBUGCTRL_ + 0x3A)
#endif /* __RTL8712_DEBUGCTRL_REGDEF_H__ */
#ifndef __RTL8712_EDCASETTING_BITDEF_H__
#define __RTL8712_EDCASETTING_BITDEF_H__
/*EDCAPARAM*/
#define _TXOPLIMIT_MSK 0xFFFF0000
#define _TXOPLIMIT_SHT 16
#define _ECWIN_MSK 0x0000FF00
#define _ECWIN_SHT 8
#define _AIFS_MSK 0x000000FF
#define _AIFS_SHT 0
/*BCNTCFG*/
#define _BCNECW_MSK 0xFF00
#define _BCNECW_SHT 8
#define _BCNIFS_MSK 0x00FF
#define _BCNIFS_SHT 0
/*CWRR*/
#define _CWRR_MSK 0x03FF
/*ACMAVG*/
#define _AVG_TIME_UP BIT(3)
#define _AVGPERIOD_MSK 0x03
/*ACMHWCTRL*/
#define _VOQ_ACM_STATUS BIT(6)
#define _VIQ_ACM_STATUS BIT(5)
#define _BEQ_ACM_STATUS BIT(4)
#define _VOQ_ACM_EN BIT(3)
#define _VIQ_ACM_EN BIT(2)
#define _BEQ_ACM_EN BIT(1)
#define _ACMHWEN BIT(0)
/*VO_ADMTIME*/
#define _VO_ACM_RUT BIT(18)
#define _VO_ADMTIME_MSK 0x0003FFF
/*VI_ADMTIME*/
#define _VI_ACM_RUT BIT(18)
#define _VI_ADMTIME_MSK 0x0003FFF
/*BE_ADMTIME*/
#define _BE_ACM_RUT BIT(18)
#define _BE_ADMTIME_MSK 0x0003FFF
/*Retry limit reg*/
#define _SRL_MSK 0xFF00
#define _SRL_SHT 8
#define _LRL_MSK 0x00FF
#define _LRL_SHT 0
#endif /* __RTL8712_EDCASETTING_BITDEF_H__*/
#ifndef __RTL8712_EDCASETTING_REGDEF_H__
#define __RTL8712_EDCASETTING_REGDEF_H__
#define EDCA_VO_PARAM (RTL8712_EDCASETTING_ + 0x00)
#define EDCA_VI_PARAM (RTL8712_EDCASETTING_ + 0x04)
#define EDCA_BE_PARAM (RTL8712_EDCASETTING_ + 0x08)
#define EDCA_BK_PARAM (RTL8712_EDCASETTING_ + 0x0C)
#define BCNTCFG (RTL8712_EDCASETTING_ + 0x10)
#define CWRR (RTL8712_EDCASETTING_ + 0x12)
#define ACMAVG (RTL8712_EDCASETTING_ + 0x16)
#define ACMHWCTRL (RTL8712_EDCASETTING_ + 0x17)
#define VO_ADMTIME (RTL8712_EDCASETTING_ + 0x18)
#define VI_ADMTIME (RTL8712_EDCASETTING_ + 0x1C)
#define BE_ADMTIME (RTL8712_EDCASETTING_ + 0x20)
#define RL (RTL8712_EDCASETTING_ + 0x24)
#endif /* __RTL8712_EDCASETTING_REGDEF_H__ */
此差异已折叠。
#ifndef __RTL8712_EFUSE_H__
#define __RTL8712_EFUSE_H__
#include "osdep_service.h"
#define _REPEAT_THRESHOLD_ 3
#define EFUSE_MAX_SIZE 512
#define EFUSE_MAP_MAX_SIZE 128
#define PGPKG_MAX_WORDS 4
#define PGPKT_DATA_SIZE 8 /* PGPKG_MAX_WORDS*2; BYTES sizeof(u8)*8*/
#define MAX_PGPKT_SIZE 9 /* 1 + PGPKT_DATA_SIZE; header + 2 * 4 words (BYTES)*/
#define GET_EFUSE_OFFSET(header) ((header & 0xF0) >> 4)
#define GET_EFUSE_WORD_EN(header) (header & 0x0F)
#define MAKE_EFUSE_HEADER(offset, word_en) (((offset & 0x0F) << 4) | \
(word_en & 0x0F))
/*--------------------------------------------------------------------------*/
struct PGPKT_STRUCT {
u8 offset;
u8 word_en;
u8 data[PGPKT_DATA_SIZE];
};
/*--------------------------------------------------------------------------*/
u8 r8712_efuse_reg_init(struct _adapter *padapter);
void r8712_efuse_reg_uninit(struct _adapter *padapter);
u16 r8712_efuse_get_current_size(struct _adapter *padapter);
int r8712_efuse_get_max_size(struct _adapter *padapter);
void r8712_efuse_change_max_size(struct _adapter *padapter);
u8 r8712_efuse_pg_packet_read(struct _adapter *padapter,
u8 offset, u8 *data);
u8 r8712_efuse_pg_packet_write(struct _adapter *padapter,
const u8 offset, const u8 word_en,
const u8 *data);
u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead,
u16 start_addr, u16 cnts, u8 *data);
u8 r8712_efuse_map_read(struct _adapter *padapter, u16 addr,
u16 cnts, u8 *data);
u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr,
u16 cnts, u8 *data);
#endif
#ifndef _RTL8712_EVENT_H_
#define _RTL8712_EVENT_H_
void r8712_event_handle(struct _adapter *padapter, uint *peventbuf);
void r8712_got_addbareq_event_callback(struct _adapter *adapter , u8 *pbuf);
enum rtl8712_c2h_event {
GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
GEN_EVT_CODE(_Read_BBREG),
GEN_EVT_CODE(_Read_RFREG),
GEN_EVT_CODE(_Read_EEPROM),
GEN_EVT_CODE(_Read_EFUSE),
GEN_EVT_CODE(_Read_CAM), /*5*/
GEN_EVT_CODE(_Get_BasicRate),
GEN_EVT_CODE(_Get_DataRate),
GEN_EVT_CODE(_Survey), /*8*/
GEN_EVT_CODE(_SurveyDone), /*9*/
GEN_EVT_CODE(_JoinBss) , /*10*/
GEN_EVT_CODE(_AddSTA),
GEN_EVT_CODE(_DelSTA),
GEN_EVT_CODE(_AtimDone) ,
GEN_EVT_CODE(_TX_Report),
GEN_EVT_CODE(_CCX_Report), /*15*/
GEN_EVT_CODE(_DTM_Report),
GEN_EVT_CODE(_TX_Rate_Statistics),
GEN_EVT_CODE(_C2HLBK),
GEN_EVT_CODE(_FWDBG),
GEN_EVT_CODE(_C2HFEEDBACK), /*20*/
GEN_EVT_CODE(_ADDBA),
GEN_EVT_CODE(_C2HBCN),
GEN_EVT_CODE(_ReportPwrState), /*filen: only for PCIE, USB*/
GEN_EVT_CODE(_WPS_PBC), /*24*/
GEN_EVT_CODE(_ADDBAReq_Report), /*25*/
MAX_C2HEVT
};
#ifdef _RTL8712_CMD_C_
static struct fwevent wlanevents[] = {
{0, NULL}, /*0*/
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, &r8712_survey_event_callback}, /*8*/
{sizeof(struct surveydone_event), &r8712_surveydone_event_callback},/*9*/
{0, &r8712_joinbss_event_callback}, /*10*/
{sizeof(struct stassoc_event), &r8712_stassoc_event_callback},
{sizeof(struct stadel_event), &r8712_stadel_event_callback},
{0, &r8712_atimdone_event_callback},
{0, NULL},
{0, NULL}, /*15*/
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL}, /*fwdbg_event_callback},*/
{0, NULL}, /*20*/
{0, NULL},
{0, NULL},
{0, &r8712_cpwm_event_callback},
{0, &r8712_wpspbc_event_callback},
{0, &r8712_got_addbareq_event_callback},
};
#endif/*_RTL8712_CMD_C_*/
#endif
#ifndef __RTL8712_FIFOCTRL_BITDEF_H__
#define __RTL8712_FIFOCTRL_BITDEF_H__
/*PBP*/
#define _PSTX_MSK 0xF0
#define _PSTX_SHT 4
#define _PSRX_MSK 0x0F
#define _PSRX_SHT 0
/*TXFF_STATUS*/
#define _TXSTATUS_OVF BIT(15)
/*RXFF_STATUS*/
#define _STATUSFF1_OVF BIT(7)
#define _STATUSFF1_EMPTY BIT(6)
#define _STATUSFF0_OVF BIT(5)
#define _STATUSFF0_EMPTY BIT(4)
#define _RXFF1_OVF BIT(3)
#define _RXFF1_EMPTY BIT(2)
#define _RXFF0_OVF BIT(1)
#define _RXFF0_EMPTY BIT(0)
/*TXFF_EMPTY_TH*/
#define _BKQ_EMPTY_TH_MSK 0x0F0000
#define _BKQ_EMPTY_TH_SHT 16
#define _BEQ_EMPTY_TH_MSK 0x00F000
#define _BEQ_EMPTY_TH_SHT 12
#define _VIQ_EMPTY_TH_MSK 0x000F00
#define _VIQ_EMPTY_TH_SHT 8
#define _VOQ_EMPTY_TH_MSK 0x0000F0
#define _VOQ_EMPTY_TH_SHT 4
#define _BMCQ_EMPTY_TH_MSK 0x00000F
#define _BMCQ_EMPTY_TH_SHT 0
/*SDIO_RX_BLKSZ*/
#define _SDIO_RX_BLKSZ_MSK 0x07
/*RXDMA_CTRL*/
#define _C2HFF_POLL BIT(4)
#define _RXPKT_POLL BIT(0)
/*RXPKT_NUM*/
#define _RXCMD_NUM_MSK 0xFF00
#define _RXCMD_NUM_SHT 8
#define _RXFF0_NUM_MSK 0x00FF
#define _RXFF0_NUM_SHT 0
/*FIFOPAGE2*/
#define _PUB_AVAL_PG_MSK 0xFFFF0000
#define _PUB_AVAL_PG_SHT 16
#define _BCN_AVAL_PG_MSK 0x0000FFFF
#define _BCN_AVAL_PG_SHT 0
/*RX0PKTNUM*/
#define _RXFF0_DEC_POLL BIT(15)
#define _RXFF0_PKT_DEC_NUM_MSK 0x3F00
#define _RXFF0_PKT_DEC_NUM_SHT 8
#define _RXFF0_PKTNUM_RPT_MSK 0x00FF
#define _RXFF0_PKTNUM_RPT_SHT 0
/*RX1PKTNUM*/
#define _RXFF1_DEC_POLL BIT(15)
#define _RXFF1_PKT_DEC_NUM_MSK 0x3F00
#define _RXFF1_PKT_DEC_NUM_SHT 8
#define _RXFF1_PKTNUM_RPT_MSK 0x00FF
#define _RXFF1_PKTNUM_RPT_SHT 0
/*RXFLTMAP0*/
#define _MGTFLT13EN BIT(13)
#define _MGTFLT12EN BIT(12)
#define _MGTFLT11EN BIT(11)
#define _MGTFLT10EN BIT(10)
#define _MGTFLT9EN BIT(9)
#define _MGTFLT8EN BIT(8)
#define _MGTFLT5EN BIT(5)
#define _MGTFLT4EN BIT(4)
#define _MGTFLT3EN BIT(3)
#define _MGTFLT2EN BIT(2)
#define _MGTFLT1EN BIT(1)
#define _MGTFLT0EN BIT(0)
/*RXFLTMAP1*/
#define _CTRLFLT15EN BIT(15)
#define _CTRLFLT14EN BIT(14)
#define _CTRLFLT13EN BIT(13)
#define _CTRLFLT12EN BIT(12)
#define _CTRLFLT11EN BIT(11)
#define _CTRLFLT10EN BIT(10)
#define _CTRLFLT9EN BIT(9)
#define _CTRLFLT8EN BIT(8)
#define _CTRLFLT7EN BIT(7)
#define _CTRLFLT6EN BIT(6)
/*RXFLTMAP2*/
#define _DATAFLT15EN BIT(15)
#define _DATAFLT14EN BIT(14)
#define _DATAFLT13EN BIT(13)
#define _DATAFLT12EN BIT(12)
#define _DATAFLT11EN BIT(11)
#define _DATAFLT10EN BIT(10)
#define _DATAFLT9EN BIT(9)
#define _DATAFLT8EN BIT(8)
#define _DATAFLT7EN BIT(7)
#define _DATAFLT6EN BIT(6)
#define _DATAFLT5EN BIT(5)
#define _DATAFLT4EN BIT(4)
#define _DATAFLT3EN BIT(3)
#define _DATAFLT2EN BIT(2)
#define _DATAFLT1EN BIT(1)
#define _DATAFLT0EN BIT(0)
/*RXFLTMAP3*/
#define _MESHAFLT1EN BIT(1)
#define _MESHAFLT0EN BIT(0)
/*TXPKT_NUM_CTRL*/
#define _TXPKTNUM_DEC BIT(8)
#define _TXPKTNUM_MSK 0x00FF
#define _TXPKTNUM_SHT 0
/*TXFF_PG_NUM*/
#define _TXFF_PG_NUM_MSK 0x0FFF
#endif /* __RTL8712_FIFOCTRL_BITDEF_H__ */
#ifndef __RTL8712_FIFOCTRL_REGDEF_H__
#define __RTL8712_FIFOCTRL_REGDEF_H__
#define RQPN (RTL8712_FIFOCTRL_ + 0x00)
#define RXFF_BNDY (RTL8712_FIFOCTRL_ + 0x0C)
#define RXRPT_BNDY (RTL8712_FIFOCTRL_ + 0x10)
#define TXPKTBUF_PGBNDY (RTL8712_FIFOCTRL_ + 0x14)
#define PBP (RTL8712_FIFOCTRL_ + 0x15)
#define RX_DRVINFO_SZ (RTL8712_FIFOCTRL_ + 0x16)
#define TXFF_STATUS (RTL8712_FIFOCTRL_ + 0x17)
#define RXFF_STATUS (RTL8712_FIFOCTRL_ + 0x18)
#define TXFF_EMPTY_TH (RTL8712_FIFOCTRL_ + 0x19)
#define SDIO_RX_BLKSZ (RTL8712_FIFOCTRL_ + 0x1C)
#define RXDMA_RXCTRL (RTL8712_FIFOCTRL_ + 0x1D)
#define RXPKT_NUM (RTL8712_FIFOCTRL_ + 0x1E)
#define RXPKT_NUM_C2H (RTL8712_FIFOCTRL_ + 0x1F)
#define C2HCMD_UDT_SIZE (RTL8712_FIFOCTRL_ + 0x20)
#define C2HCMD_UDT_ADDR (RTL8712_FIFOCTRL_ + 0x22)
#define FIFOPAGE2 (RTL8712_FIFOCTRL_ + 0x24)
#define FIFOPAGE1 (RTL8712_FIFOCTRL_ + 0x28)
#define FW_RSVD_PG_CTRL (RTL8712_FIFOCTRL_ + 0x30)
#define TXRPTFF_RDPTR (RTL8712_FIFOCTRL_ + 0x40)
#define TXRPTFF_WTPTR (RTL8712_FIFOCTRL_ + 0x44)
#define C2HFF_RDPTR (RTL8712_FIFOCTRL_ + 0x48)
#define C2HFF_WTPTR (RTL8712_FIFOCTRL_ + 0x4C)
#define RXFF0_RDPTR (RTL8712_FIFOCTRL_ + 0x50)
#define RXFF0_WTPTR (RTL8712_FIFOCTRL_ + 0x54)
#define RXFF1_RDPTR (RTL8712_FIFOCTRL_ + 0x58)
#define RXFF1_WTPTR (RTL8712_FIFOCTRL_ + 0x5C)
#define RXRPT0FF_RDPTR (RTL8712_FIFOCTRL_ + 0x60)
#define RXRPT0FF_WTPTR (RTL8712_FIFOCTRL_ + 0x64)
#define RXRPT1FF_RDPTR (RTL8712_FIFOCTRL_ + 0x68)
#define RXRPT1FF_WTPTR (RTL8712_FIFOCTRL_ + 0x6C)
#define RX0PKTNUM (RTL8712_FIFOCTRL_ + 0x72)
#define RX1PKTNUM (RTL8712_FIFOCTRL_ + 0x74)
#define RXFLTMAP0 (RTL8712_FIFOCTRL_ + 0x76)
#define RXFLTMAP1 (RTL8712_FIFOCTRL_ + 0x78)
#define RXFLTMAP2 (RTL8712_FIFOCTRL_ + 0x7A)
#define RXFLTMAP3 (RTL8712_FIFOCTRL_ + 0x7c)
#define TBDA (RTL8712_FIFOCTRL_ + 0x84)
#define THPDA (RTL8712_FIFOCTRL_ + 0x88)
#define TCDA (RTL8712_FIFOCTRL_ + 0x8C)
#define TMDA (RTL8712_FIFOCTRL_ + 0x90)
#define HDA (RTL8712_FIFOCTRL_ + 0x94)
#define TVODA (RTL8712_FIFOCTRL_ + 0x98)
#define TVIDA (RTL8712_FIFOCTRL_ + 0x9C)
#define TBEDA (RTL8712_FIFOCTRL_ + 0xA0)
#define TBKDA (RTL8712_FIFOCTRL_ + 0xA4)
#define RCDA (RTL8712_FIFOCTRL_ + 0xA8)
#define RDSA (RTL8712_FIFOCTRL_ + 0xAC)
#define TXPKT_NUM_CTRL (RTL8712_FIFOCTRL_ + 0xB0)
#define TXQ_PGADD (RTL8712_FIFOCTRL_ + 0xB3)
#define TXFF_PG_NUM (RTL8712_FIFOCTRL_ + 0xB4)
#endif /* __RTL8712_FIFOCTRL_REGDEF_H__ */
此差异已折叠。
#ifndef __RTL8712_GP_REGDEF_H__
#define __RTL8712_GP_REGDEF_H__
#define PSTIMER (RTL8712_GP_ + 0x00)
#define TIMER1 (RTL8712_GP_ + 0x04)
#define TIMER2 (RTL8712_GP_ + 0x08)
#define GPIO_CTRL (RTL8712_GP_ + 0x0C)
#define GPIO_IO_SEL (RTL8712_GP_ + 0x0E)
#define GPIO_INTCTRL (RTL8712_GP_ + 0x10)
#define MAC_PINMUX_CTRL (RTL8712_GP_ + 0x11)
#define LEDCFG (RTL8712_GP_ + 0x12)
#define PHY_REG_RPT (RTL8712_GP_ + 0x13)
#define PHY_REG_DATA (RTL8712_GP_ + 0x14)
#endif /*__RTL8712_GP_REGDEF_H__ */
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册