mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 20:48:49 +08:00
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: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Florian Schilhabel <florian.c.schilhabel@googlemail.com> Tested-by: Frederic Leroy <fredo@starox.org>
This commit is contained in:
parent
763008c435
commit
2865d42c78
@ -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/
|
||||
|
18
drivers/staging/rtl8712/Kconfig
Normal file
18
drivers/staging/rtl8712/Kconfig
Normal file
@ -0,0 +1,18 @@
|
||||
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.
|
||||
|
||||
|
34
drivers/staging/rtl8712/Makefile
Normal file
34
drivers/staging/rtl8712/Makefile
Normal file
@ -0,0 +1,34 @@
|
||||
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
|
||||
|
23
drivers/staging/rtl8712/basic_types.h
Normal file
23
drivers/staging/rtl8712/basic_types.h
Normal file
@ -0,0 +1,23 @@
|
||||
#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__*/
|
||||
|
69
drivers/staging/rtl8712/big_endian.h
Normal file
69
drivers/staging/rtl8712/big_endian.h
Normal file
@ -0,0 +1,69 @@
|
||||
#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 */
|
||||
|
164
drivers/staging/rtl8712/drv_types.h
Normal file
164
drivers/staging/rtl8712/drv_types.h
Normal file
@ -0,0 +1,164 @@
|
||||
/*---------------------------------------------------------------------
|
||||
|
||||
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__*/
|
||||
|
23
drivers/staging/rtl8712/ethernet.h
Normal file
23
drivers/staging/rtl8712/ethernet.h
Normal file
@ -0,0 +1,23 @@
|
||||
#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 */
|
||||
|
10197
drivers/staging/rtl8712/farray.h
Normal file
10197
drivers/staging/rtl8712/farray.h
Normal file
File diff suppressed because it is too large
Load Diff
153
drivers/staging/rtl8712/generic.h
Normal file
153
drivers/staging/rtl8712/generic.h
Normal file
@ -0,0 +1,153 @@
|
||||
#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 */
|
||||
|
356
drivers/staging/rtl8712/hal_init.c
Normal file
356
drivers/staging/rtl8712/hal_init.c
Normal file
@ -0,0 +1,356 @@
|
||||
/******************************************************************************
|
||||
* 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;
|
||||
}
|
454
drivers/staging/rtl8712/ieee80211.c
Normal file
454
drivers/staging/rtl8712/ieee80211.c
Normal file
@ -0,0 +1,454 @@
|
||||
/******************************************************************************
|
||||
* 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;
|
||||
}
|
770
drivers/staging/rtl8712/ieee80211.h
Normal file
770
drivers/staging/rtl8712/ieee80211.h
Normal file
@ -0,0 +1,770 @@
|
||||
#ifndef __IEEE80211_H
|
||||
#define __IEEE80211_H
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "wifi.h"
|
||||
#include <linux/wireless.h>
|
||||
|
||||
#define MGMT_QUEUE_NUM 5
|
||||
#define ETH_ALEN 6
|
||||
#define IEEE_CMD_SET_WPA_PARAM 1
|
||||
#define IEEE_CMD_SET_WPA_IE 2
|
||||
#define IEEE_CMD_SET_ENCRYPTION 3
|
||||
#define IEEE_CMD_MLME 4
|
||||
|
||||
#define IEEE_PARAM_WPA_ENABLED 1
|
||||
#define IEEE_PARAM_TKIP_COUNTERMEASURES 2
|
||||
#define IEEE_PARAM_DROP_UNENCRYPTED 3
|
||||
#define IEEE_PARAM_PRIVACY_INVOKED 4
|
||||
#define IEEE_PARAM_AUTH_ALGS 5
|
||||
#define IEEE_PARAM_IEEE_802_1X 6
|
||||
#define IEEE_PARAM_WPAX_SELECT 7
|
||||
|
||||
#define AUTH_ALG_OPEN_SYSTEM 0x1
|
||||
#define AUTH_ALG_SHARED_KEY 0x2
|
||||
#define AUTH_ALG_LEAP 0x00000004
|
||||
|
||||
#define IEEE_MLME_STA_DEAUTH 1
|
||||
#define IEEE_MLME_STA_DISASSOC 2
|
||||
|
||||
#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
|
||||
#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
|
||||
#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
|
||||
#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
|
||||
#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
|
||||
#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
|
||||
|
||||
|
||||
#define IEEE_CRYPT_ALG_NAME_LEN 16
|
||||
|
||||
#define WPA_CIPHER_NONE BIT(0)
|
||||
#define WPA_CIPHER_WEP40 BIT(1)
|
||||
#define WPA_CIPHER_WEP104 BIT(2)
|
||||
#define WPA_CIPHER_TKIP BIT(3)
|
||||
#define WPA_CIPHER_CCMP BIT(4)
|
||||
|
||||
|
||||
|
||||
#define WPA_SELECTOR_LEN 4
|
||||
#define RSN_HEADER_LEN 4
|
||||
|
||||
#define RSN_SELECTOR_LEN 4
|
||||
|
||||
enum NETWORK_TYPE {
|
||||
WIRELESS_INVALID = 0,
|
||||
WIRELESS_11B = 1,
|
||||
WIRELESS_11G = 2,
|
||||
WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G),
|
||||
WIRELESS_11A = 4,
|
||||
WIRELESS_11N = 8,
|
||||
WIRELESS_11GN = (WIRELESS_11G | WIRELESS_11N),
|
||||
WIRELESS_11BGN = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11N),
|
||||
};
|
||||
|
||||
|
||||
struct ieee_param {
|
||||
u32 cmd;
|
||||
u8 sta_addr[ETH_ALEN];
|
||||
union {
|
||||
struct {
|
||||
u8 name;
|
||||
u32 value;
|
||||
} wpa_param;
|
||||
struct {
|
||||
u32 len;
|
||||
u8 reserved[32];
|
||||
u8 data[0];
|
||||
} wpa_ie;
|
||||
struct{
|
||||
int command;
|
||||
int reason_code;
|
||||
} mlme;
|
||||
struct {
|
||||
u8 alg[IEEE_CRYPT_ALG_NAME_LEN];
|
||||
u8 set_tx;
|
||||
u32 err;
|
||||
u8 idx;
|
||||
u8 seq[8]; /* sequence counter (set: RX, get: TX) */
|
||||
u16 key_len;
|
||||
u8 key[0];
|
||||
} crypt;
|
||||
} u;
|
||||
};
|
||||
|
||||
#define IEEE80211_DATA_LEN 2304
|
||||
/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
|
||||
6.2.1.1.2.
|
||||
|
||||
The figure in section 7.1.2 suggests a body size of up to 2312
|
||||
bytes is allowed, which is a bit confusing, I suspect this
|
||||
represents the 2304 bytes of real data, plus a possible 8 bytes of
|
||||
WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
|
||||
|
||||
#define IEEE80211_HLEN 30
|
||||
#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
|
||||
|
||||
/* this is stolen from ipw2200 driver */
|
||||
#define IEEE_IBSS_MAC_HASH_SIZE 31
|
||||
|
||||
struct ieee_ibss_seq {
|
||||
u8 mac[ETH_ALEN];
|
||||
u16 seq_num;
|
||||
u16 frag_num;
|
||||
unsigned int packet_time;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
struct ieee80211_hdr {
|
||||
u16 frame_ctl;
|
||||
u16 duration_id;
|
||||
u8 addr1[ETH_ALEN];
|
||||
u8 addr2[ETH_ALEN];
|
||||
u8 addr3[ETH_ALEN];
|
||||
u16 seq_ctl;
|
||||
u8 addr4[ETH_ALEN];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_hdr_3addr {
|
||||
u16 frame_ctl;
|
||||
u16 duration_id;
|
||||
u8 addr1[ETH_ALEN];
|
||||
u8 addr2[ETH_ALEN];
|
||||
u8 addr3[ETH_ALEN];
|
||||
u16 seq_ctl;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
struct ieee80211_hdr_qos {
|
||||
u16 frame_ctl;
|
||||
u16 duration_id;
|
||||
u8 addr1[ETH_ALEN];
|
||||
u8 addr2[ETH_ALEN];
|
||||
u8 addr3[ETH_ALEN];
|
||||
u16 seq_ctl;
|
||||
u8 addr4[ETH_ALEN];
|
||||
u16 qc;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_hdr_3addr_qos {
|
||||
u16 frame_ctl;
|
||||
u16 duration_id;
|
||||
u8 addr1[ETH_ALEN];
|
||||
u8 addr2[ETH_ALEN];
|
||||
u8 addr3[ETH_ALEN];
|
||||
u16 seq_ctl;
|
||||
u16 qc;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct eapol {
|
||||
u8 snap[6];
|
||||
u16 ethertype;
|
||||
u8 version;
|
||||
u8 type;
|
||||
u16 length;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
enum eap_type {
|
||||
EAP_PACKET = 0,
|
||||
EAPOL_START,
|
||||
EAPOL_LOGOFF,
|
||||
EAPOL_KEY,
|
||||
EAPOL_ENCAP_ASF_ALERT
|
||||
};
|
||||
|
||||
#define IEEE80211_3ADDR_LEN 24
|
||||
#define IEEE80211_4ADDR_LEN 30
|
||||
#define IEEE80211_FCS_LEN 4
|
||||
|
||||
#define MIN_FRAG_THRESHOLD 256U
|
||||
#define MAX_FRAG_THRESHOLD 2346U
|
||||
|
||||
/* Frame control field constants */
|
||||
#define IEEE80211_FCTL_VERS 0x0002
|
||||
#define IEEE80211_FCTL_FTYPE 0x000c
|
||||
#define IEEE80211_FCTL_STYPE 0x00f0
|
||||
#define IEEE80211_FCTL_TODS 0x0100
|
||||
#define IEEE80211_FCTL_FROMDS 0x0200
|
||||
#define IEEE80211_FCTL_MOREFRAGS 0x0400
|
||||
#define IEEE80211_FCTL_RETRY 0x0800
|
||||
#define IEEE80211_FCTL_PM 0x1000
|
||||
#define IEEE80211_FCTL_MOREDATA 0x2000
|
||||
#define IEEE80211_FCTL_WEP 0x4000
|
||||
#define IEEE80211_FCTL_ORDER 0x8000
|
||||
|
||||
#define IEEE80211_FTYPE_MGMT 0x0000
|
||||
#define IEEE80211_FTYPE_CTL 0x0004
|
||||
#define IEEE80211_FTYPE_DATA 0x0008
|
||||
|
||||
/* management */
|
||||
#define IEEE80211_STYPE_ASSOC_REQ 0x0000
|
||||
#define IEEE80211_STYPE_ASSOC_RESP 0x0010
|
||||
#define IEEE80211_STYPE_REASSOC_REQ 0x0020
|
||||
#define IEEE80211_STYPE_REASSOC_RESP 0x0030
|
||||
#define IEEE80211_STYPE_PROBE_REQ 0x0040
|
||||
#define IEEE80211_STYPE_PROBE_RESP 0x0050
|
||||
#define IEEE80211_STYPE_BEACON 0x0080
|
||||
#define IEEE80211_STYPE_ATIM 0x0090
|
||||
#define IEEE80211_STYPE_DISASSOC 0x00A0
|
||||
#define IEEE80211_STYPE_AUTH 0x00B0
|
||||
#define IEEE80211_STYPE_DEAUTH 0x00C0
|
||||
|
||||
/* control */
|
||||
#define IEEE80211_STYPE_PSPOLL 0x00A0
|
||||
#define IEEE80211_STYPE_RTS 0x00B0
|
||||
#define IEEE80211_STYPE_CTS 0x00C0
|
||||
#define IEEE80211_STYPE_ACK 0x00D0
|
||||
#define IEEE80211_STYPE_CFEND 0x00E0
|
||||
#define IEEE80211_STYPE_CFENDACK 0x00F0
|
||||
|
||||
/* data */
|
||||
#define IEEE80211_STYPE_DATA 0x0000
|
||||
#define IEEE80211_STYPE_DATA_CFACK 0x0010
|
||||
#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
|
||||
#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
|
||||
#define IEEE80211_STYPE_NULLFUNC 0x0040
|
||||
#define IEEE80211_STYPE_CFACK 0x0050
|
||||
#define IEEE80211_STYPE_CFPOLL 0x0060
|
||||
#define IEEE80211_STYPE_CFACKPOLL 0x0070
|
||||
#define IEEE80211_QOS_DATAGRP 0x0080
|
||||
#define IEEE80211_QoS_DATAGRP IEEE80211_QOS_DATAGRP
|
||||
|
||||
#define IEEE80211_SCTL_FRAG 0x000F
|
||||
#define IEEE80211_SCTL_SEQ 0xFFF0
|
||||
|
||||
/* QoS,QOS */
|
||||
#define NORMAL_ACK 0
|
||||
#define NO_ACK 1
|
||||
#define NON_EXPLICIT_ACK 2
|
||||
#define BLOCK_ACK 3
|
||||
|
||||
#ifndef ETH_P_PAE
|
||||
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
|
||||
#endif /* ETH_P_PAE */
|
||||
|
||||
#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
|
||||
|
||||
#define ETH_P_ECONET 0x0018
|
||||
|
||||
#ifndef ETH_P_80211_RAW
|
||||
#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
|
||||
#endif
|
||||
|
||||
/* IEEE 802.11 defines */
|
||||
|
||||
#define P80211_OUI_LEN 3
|
||||
|
||||
struct ieee80211_snap_hdr {
|
||||
u8 dsap; /* always 0xAA */
|
||||
u8 ssap; /* always 0xAA */
|
||||
u8 ctrl; /* always 0x03 */
|
||||
u8 oui[P80211_OUI_LEN]; /* organizational universal id */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
|
||||
|
||||
#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
|
||||
#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
|
||||
|
||||
#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f)
|
||||
|
||||
#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
|
||||
#define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
|
||||
|
||||
/* Authentication algorithms */
|
||||
#define WLAN_AUTH_OPEN 0
|
||||
#define WLAN_AUTH_SHARED_KEY 1
|
||||
|
||||
#define WLAN_AUTH_CHALLENGE_LEN 128
|
||||
|
||||
#define WLAN_CAPABILITY_BSS (1<<0)
|
||||
#define WLAN_CAPABILITY_IBSS (1<<1)
|
||||
#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
|
||||
#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
|
||||
#define WLAN_CAPABILITY_PRIVACY (1<<4)
|
||||
#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
|
||||
#define WLAN_CAPABILITY_PBCC (1<<6)
|
||||
#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
|
||||
#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
|
||||
|
||||
/* Status codes */
|
||||
#define WLAN_STATUS_SUCCESS 0
|
||||
#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
|
||||
#define WLAN_STATUS_CAPS_UNSUPPORTED 10
|
||||
#define WLAN_STATUS_REASSOC_NO_ASSOC 11
|
||||
#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
|
||||
#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
|
||||
#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
|
||||
#define WLAN_STATUS_CHALLENGE_FAIL 15
|
||||
#define WLAN_STATUS_AUTH_TIMEOUT 16
|
||||
#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
|
||||
#define WLAN_STATUS_ASSOC_DENIED_RATES 18
|
||||
/* 802.11b */
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
|
||||
|
||||
/* Reason codes */
|
||||
#define WLAN_REASON_UNSPECIFIED 1
|
||||
#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
|
||||
#define WLAN_REASON_DEAUTH_LEAVING 3
|
||||
#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
|
||||
#define WLAN_REASON_DISASSOC_AP_BUSY 5
|
||||
#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
|
||||
#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
|
||||
#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
|
||||
#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
|
||||
|
||||
|
||||
/* Information Element IDs */
|
||||
#define WLAN_EID_SSID 0
|
||||
#define WLAN_EID_SUPP_RATES 1
|
||||
#define WLAN_EID_FH_PARAMS 2
|
||||
#define WLAN_EID_DS_PARAMS 3
|
||||
#define WLAN_EID_CF_PARAMS 4
|
||||
#define WLAN_EID_TIM 5
|
||||
#define WLAN_EID_IBSS_PARAMS 6
|
||||
#define WLAN_EID_CHALLENGE 16
|
||||
#define WLAN_EID_RSN 48
|
||||
#define WLAN_EID_GENERIC 221
|
||||
|
||||
#define IEEE80211_MGMT_HDR_LEN 24
|
||||
#define IEEE80211_DATA_HDR3_LEN 24
|
||||
#define IEEE80211_DATA_HDR4_LEN 30
|
||||
|
||||
|
||||
#define IEEE80211_STATMASK_SIGNAL (1<<0)
|
||||
#define IEEE80211_STATMASK_RSSI (1<<1)
|
||||
#define IEEE80211_STATMASK_NOISE (1<<2)
|
||||
#define IEEE80211_STATMASK_RATE (1<<3)
|
||||
#define IEEE80211_STATMASK_WEMASK 0x7
|
||||
|
||||
|
||||
#define IEEE80211_CCK_MODULATION (1<<0)
|
||||
#define IEEE80211_OFDM_MODULATION (1<<1)
|
||||
|
||||
#define IEEE80211_24GHZ_BAND (1<<0)
|
||||
#define IEEE80211_52GHZ_BAND (1<<1)
|
||||
|
||||
#define IEEE80211_CCK_RATE_LEN 4
|
||||
#define IEEE80211_NUM_OFDM_RATESLEN 8
|
||||
|
||||
|
||||
#define IEEE80211_CCK_RATE_1MB 0x02
|
||||
#define IEEE80211_CCK_RATE_2MB 0x04
|
||||
#define IEEE80211_CCK_RATE_5MB 0x0B
|
||||
#define IEEE80211_CCK_RATE_11MB 0x16
|
||||
#define IEEE80211_OFDM_RATE_LEN 8
|
||||
#define IEEE80211_OFDM_RATE_6MB 0x0C
|
||||
#define IEEE80211_OFDM_RATE_9MB 0x12
|
||||
#define IEEE80211_OFDM_RATE_12MB 0x18
|
||||
#define IEEE80211_OFDM_RATE_18MB 0x24
|
||||
#define IEEE80211_OFDM_RATE_24MB 0x30
|
||||
#define IEEE80211_OFDM_RATE_36MB 0x48
|
||||
#define IEEE80211_OFDM_RATE_48MB 0x60
|
||||
#define IEEE80211_OFDM_RATE_54MB 0x6C
|
||||
#define IEEE80211_BASIC_RATE_MASK 0x80
|
||||
|
||||
#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
|
||||
#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
|
||||
#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
|
||||
#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
|
||||
#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
|
||||
#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
|
||||
#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
|
||||
#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
|
||||
#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
|
||||
#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
|
||||
#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
|
||||
#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
|
||||
|
||||
#define IEEE80211_CCK_RATES_MASK 0x0000000F
|
||||
#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
|
||||
IEEE80211_CCK_RATE_2MB_MASK)
|
||||
#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
|
||||
IEEE80211_CCK_RATE_5MB_MASK | \
|
||||
IEEE80211_CCK_RATE_11MB_MASK)
|
||||
|
||||
#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
|
||||
#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_12MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_24MB_MASK)
|
||||
#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
|
||||
IEEE80211_OFDM_RATE_9MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_18MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_36MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_48MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_54MB_MASK)
|
||||
#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
|
||||
IEEE80211_CCK_DEFAULT_RATES_MASK)
|
||||
|
||||
#define IEEE80211_NUM_OFDM_RATES 8
|
||||
#define IEEE80211_NUM_CCK_RATES 4
|
||||
#define IEEE80211_OFDM_SHIFT_MASK_A 4
|
||||
|
||||
|
||||
|
||||
|
||||
/* NOTE: This data is for statistical purposes; not all hardware provides this
|
||||
* information for frames received. Not setting these will not cause
|
||||
* any adverse affects. */
|
||||
struct ieee80211_rx_stats {
|
||||
s8 rssi;
|
||||
u8 signal;
|
||||
u8 noise;
|
||||
u8 received_channel;
|
||||
u16 rate; /* in 100 kbps */
|
||||
u8 mask;
|
||||
u8 freq;
|
||||
u16 len;
|
||||
};
|
||||
|
||||
/* IEEE 802.11 requires that STA supports concurrent reception of at least
|
||||
* three fragmented frames. This define can be increased to support more
|
||||
* concurrent frames, but it should be noted that each entry can consume about
|
||||
* 2 kB of RAM and increasing cache size will slow down frame reassembly. */
|
||||
#define IEEE80211_FRAG_CACHE_LEN 4
|
||||
|
||||
struct ieee80211_frag_entry {
|
||||
u32 first_frag_time;
|
||||
uint seq;
|
||||
uint last_frag;
|
||||
uint qos; /*jackson*/
|
||||
uint tid; /*jackson*/
|
||||
struct sk_buff *skb;
|
||||
u8 src_addr[ETH_ALEN];
|
||||
u8 dst_addr[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct ieee80211_stats {
|
||||
uint tx_unicast_frames;
|
||||
uint tx_multicast_frames;
|
||||
uint tx_fragments;
|
||||
uint tx_unicast_octets;
|
||||
uint tx_multicast_octets;
|
||||
uint tx_deferred_transmissions;
|
||||
uint tx_single_retry_frames;
|
||||
uint tx_multiple_retry_frames;
|
||||
uint tx_retry_limit_exceeded;
|
||||
uint tx_discards;
|
||||
uint rx_unicast_frames;
|
||||
uint rx_multicast_frames;
|
||||
uint rx_fragments;
|
||||
uint rx_unicast_octets;
|
||||
uint rx_multicast_octets;
|
||||
uint rx_fcs_errors;
|
||||
uint rx_discards_no_buffer;
|
||||
uint tx_discards_wrong_sa;
|
||||
uint rx_discards_undecryptable;
|
||||
uint rx_message_in_msg_fragments;
|
||||
uint rx_message_in_bad_msg_fragments;
|
||||
};
|
||||
|
||||
struct ieee80211_softmac_stats{
|
||||
uint rx_ass_ok;
|
||||
uint rx_ass_err;
|
||||
uint rx_probe_rq;
|
||||
uint tx_probe_rs;
|
||||
uint tx_beacons;
|
||||
uint rx_auth_rq;
|
||||
uint rx_auth_rs_ok;
|
||||
uint rx_auth_rs_err;
|
||||
uint tx_auth_rq;
|
||||
uint no_auth_rs;
|
||||
uint no_ass_rs;
|
||||
uint tx_ass_rq;
|
||||
uint rx_ass_rq;
|
||||
uint tx_probe_rq;
|
||||
uint reassoc;
|
||||
uint swtxstop;
|
||||
uint swtxawake;
|
||||
};
|
||||
|
||||
#define SEC_KEY_1 (1<<0)
|
||||
#define SEC_KEY_2 (1<<1)
|
||||
#define SEC_KEY_3 (1<<2)
|
||||
#define SEC_KEY_4 (1<<3)
|
||||
#define SEC_ACTIVE_KEY (1<<4)
|
||||
#define SEC_AUTH_MODE (1<<5)
|
||||
#define SEC_UNICAST_GROUP (1<<6)
|
||||
#define SEC_LEVEL (1<<7)
|
||||
#define SEC_ENABLED (1<<8)
|
||||
|
||||
#define SEC_LEVEL_0 0 /* None */
|
||||
#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
|
||||
#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
|
||||
#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
|
||||
#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
|
||||
|
||||
#define WEP_KEYS 4
|
||||
#define WEP_KEY_LEN 13
|
||||
|
||||
struct ieee80211_security {
|
||||
u16 active_key:2,
|
||||
enabled:1,
|
||||
auth_mode:2,
|
||||
auth_algo:4,
|
||||
unicast_uses_group:1;
|
||||
u8 key_sizes[WEP_KEYS];
|
||||
u8 keys[WEP_KEYS][WEP_KEY_LEN];
|
||||
u8 level;
|
||||
u16 flags;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
|
||||
802.11 data frame from AP
|
||||
|
||||
,-------------------------------------------------------------------.
|
||||
Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
|
||||
|------|------|---------|---------|---------|------|---------|------|
|
||||
Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
|
||||
| | tion | (BSSID) | | | ence | data | |
|
||||
`-------------------------------------------------------------------'
|
||||
|
||||
Total: 28-2340 bytes
|
||||
|
||||
*/
|
||||
|
||||
struct ieee80211_header_data {
|
||||
u16 frame_ctl;
|
||||
u16 duration_id;
|
||||
u8 addr1[6];
|
||||
u8 addr2[6];
|
||||
u8 addr3[6];
|
||||
u16 seq_ctrl;
|
||||
};
|
||||
|
||||
#define BEACON_PROBE_SSID_ID_POSITION 12
|
||||
|
||||
/* Management Frame Information Element Types */
|
||||
#define MFIE_TYPE_SSID 0
|
||||
#define MFIE_TYPE_RATES 1
|
||||
#define MFIE_TYPE_FH_SET 2
|
||||
#define MFIE_TYPE_DS_SET 3
|
||||
#define MFIE_TYPE_CF_SET 4
|
||||
#define MFIE_TYPE_TIM 5
|
||||
#define MFIE_TYPE_IBSS_SET 6
|
||||
#define MFIE_TYPE_CHALLENGE 16
|
||||
#define MFIE_TYPE_ERP 42
|
||||
#define MFIE_TYPE_RSN 48
|
||||
#define MFIE_TYPE_RATES_EX 50
|
||||
#define MFIE_TYPE_GENERIC 221
|
||||
|
||||
struct ieee80211_info_element_hdr {
|
||||
u8 id;
|
||||
u8 len;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_info_element {
|
||||
u8 id;
|
||||
u8 len;
|
||||
u8 data[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* These are the data types that can make up management packets
|
||||
*
|
||||
u16 auth_algorithm;
|
||||
u16 auth_sequence;
|
||||
u16 beacon_interval;
|
||||
u16 capability;
|
||||
u8 current_ap[ETH_ALEN];
|
||||
u16 listen_interval;
|
||||
struct {
|
||||
u16 association_id:14, reserved:2;
|
||||
} __attribute__ ((packed));
|
||||
u32 time_stamp[2];
|
||||
u16 reason;
|
||||
u16 status;
|
||||
*/
|
||||
|
||||
#define IEEE80211_DEFAULT_TX_ESSID "Penguin"
|
||||
#define IEEE80211_DEFAULT_BASIC_RATE 10
|
||||
|
||||
struct ieee80211_authentication {
|
||||
struct ieee80211_header_data header;
|
||||
u16 algorithm;
|
||||
u16 transaction;
|
||||
u16 status;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_probe_response {
|
||||
struct ieee80211_header_data header;
|
||||
u32 time_stamp[2];
|
||||
u16 beacon_interval;
|
||||
u16 capability;
|
||||
struct ieee80211_info_element info_element;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_probe_request {
|
||||
struct ieee80211_header_data header;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_assoc_request_frame {
|
||||
struct ieee80211_hdr_3addr header;
|
||||
u16 capability;
|
||||
u16 listen_interval;
|
||||
struct ieee80211_info_element_hdr info_element;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_assoc_response_frame {
|
||||
struct ieee80211_hdr_3addr header;
|
||||
u16 capability;
|
||||
u16 status;
|
||||
u16 aid;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_txb {
|
||||
u8 nr_frags;
|
||||
u8 encrypted;
|
||||
u16 reserved;
|
||||
u16 frag_size;
|
||||
u16 payload_size;
|
||||
struct sk_buff *fragments[0];
|
||||
};
|
||||
|
||||
/* SWEEP TABLE ENTRIES NUMBER*/
|
||||
#define MAX_SWEEP_TAB_ENTRIES 42
|
||||
#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
|
||||
/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
|
||||
* only use 8, and then use extended rates for the remaining supported
|
||||
* rates. Other APs, however, stick all of their supported rates on the
|
||||
* main rates information element... */
|
||||
#define MAX_RATES_LENGTH ((u8)12)
|
||||
#define MAX_RATES_EX_LENGTH ((u8)16)
|
||||
#define MAX_NETWORK_COUNT 128
|
||||
#define MAX_CHANNEL_NUMBER 161
|
||||
#define IEEE80211_SOFTMAC_SCAN_TIME 400
|
||||
/*(HZ / 2)*/
|
||||
#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
|
||||
|
||||
#define CRC_LENGTH 4U
|
||||
|
||||
#define MAX_WPA_IE_LEN 128
|
||||
#define MAX_WPS_IE_LEN 512
|
||||
|
||||
#define NETWORK_EMPTY_ESSID (1<<0)
|
||||
#define NETWORK_HAS_OFDM (1<<1)
|
||||
#define NETWORK_HAS_CCK (1<<2)
|
||||
|
||||
#define IEEE80211_DTIM_MBCAST 4
|
||||
#define IEEE80211_DTIM_UCAST 2
|
||||
#define IEEE80211_DTIM_VALID 1
|
||||
#define IEEE80211_DTIM_INVALID 0
|
||||
|
||||
#define IEEE80211_PS_DISABLED 0
|
||||
#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST
|
||||
#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST
|
||||
#define IW_ESSID_MAX_SIZE 32
|
||||
/*
|
||||
* join_res:
|
||||
* -1: authentication fail
|
||||
* -2: association fail
|
||||
* > 0: TID
|
||||
*/
|
||||
|
||||
enum ieee80211_state {
|
||||
/* the card is not linked at all */
|
||||
IEEE80211_NOLINK = 0,
|
||||
/* IEEE80211_ASSOCIATING* are for BSS client mode
|
||||
* the driver shall not perform RX filtering unless
|
||||
* the state is LINKED.
|
||||
* The driver shall just check for the state LINKED and
|
||||
* defaults to NOLINK for ALL the other states (including
|
||||
* LINKED_SCANNING)
|
||||
*/
|
||||
/* the association procedure will start (wq scheduling)*/
|
||||
IEEE80211_ASSOCIATING,
|
||||
IEEE80211_ASSOCIATING_RETRY,
|
||||
/* the association procedure is sending AUTH request*/
|
||||
IEEE80211_ASSOCIATING_AUTHENTICATING,
|
||||
/* the association procedure has successfully authentcated
|
||||
* and is sending association request
|
||||
*/
|
||||
IEEE80211_ASSOCIATING_AUTHENTICATED,
|
||||
/* the link is ok. the card associated to a BSS or linked
|
||||
* to a ibss cell or acting as an AP and creating the bss
|
||||
*/
|
||||
IEEE80211_LINKED,
|
||||
/* same as LINKED, but the driver shall apply RX filter
|
||||
* rules as we are in NO_LINK mode. As the card is still
|
||||
* logically linked, but it is doing a syncro site survey
|
||||
* then it will be back to LINKED state.
|
||||
*/
|
||||
IEEE80211_LINKED_SCANNING,
|
||||
};
|
||||
|
||||
#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
|
||||
#define DEFAULT_FTS 2346
|
||||
|
||||
#define CFG_IEEE80211_RESERVE_FCS (1<<0)
|
||||
#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
|
||||
|
||||
#define MAXTID 16
|
||||
|
||||
#define IEEE_A (1<<0)
|
||||
#define IEEE_B (1<<1)
|
||||
#define IEEE_G (1<<2)
|
||||
#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
|
||||
|
||||
extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
|
||||
{
|
||||
/* Single white space is for Linksys APs */
|
||||
if (essid_len == 1 && essid[0] == ' ')
|
||||
return 1;
|
||||
/* Otherwise, if the entire essid is 0, we assume it is hidden */
|
||||
while (essid_len) {
|
||||
essid_len--;
|
||||
if (essid[essid_len] != '\0')
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern inline int ieee80211_get_hdrlen(u16 fc)
|
||||
{
|
||||
int hdrlen = 24;
|
||||
|
||||
switch (WLAN_FC_GET_TYPE(fc)) {
|
||||
case IEEE80211_FTYPE_DATA:
|
||||
if (fc & IEEE80211_QOS_DATAGRP)
|
||||
hdrlen += 2;
|
||||
if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
|
||||
hdrlen += 6; /* Addr4 */
|
||||
break;
|
||||
case IEEE80211_FTYPE_CTL:
|
||||
switch (WLAN_FC_GET_STYPE(fc)) {
|
||||
case IEEE80211_STYPE_CTS:
|
||||
case IEEE80211_STYPE_ACK:
|
||||
hdrlen = 10;
|
||||
break;
|
||||
default:
|
||||
hdrlen = 16;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return hdrlen;
|
||||
}
|
||||
|
||||
struct registry_priv;
|
||||
|
||||
u8 *r8712_set_ie(u8 *pbuf, sint index, uint len, u8 *source, uint *frlen);
|
||||
u8 *r8712_get_ie(u8*pbuf, sint index, sint *len, sint limit);
|
||||
unsigned char *r8712_get_wpa_ie(unsigned char *pie, int *rsn_ie_len, int limit);
|
||||
unsigned char *r8712_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit);
|
||||
int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
|
||||
int *pairwise_cipher);
|
||||
int r8712_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher,
|
||||
int *pairwise_cipher);
|
||||
int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie,
|
||||
u16 *wpa_len);
|
||||
int r8712_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen);
|
||||
int r8712_generate_ie(struct registry_priv *pregistrypriv, struct _adapter *padapter);
|
||||
uint r8712_is_cckrates_included(u8 *rate);
|
||||
uint r8712_is_cckratesonly_included(u8 *rate);
|
||||
|
||||
#endif /* IEEE80211_H */
|
||||
|
116
drivers/staging/rtl8712/if_ether.h
Normal file
116
drivers/staging/rtl8712/if_ether.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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 */
|
||||
|
137
drivers/staging/rtl8712/ip.h
Normal file
137
drivers/staging/rtl8712/ip.h
Normal file
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* 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 */
|
||||
|
69
drivers/staging/rtl8712/little_endian.h
Normal file
69
drivers/staging/rtl8712/little_endian.h
Normal file
@ -0,0 +1,69 @@
|
||||
#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 */
|
||||
|
170
drivers/staging/rtl8712/mlme_linux.c
Normal file
170
drivers/staging/rtl8712/mlme_linux.c
Normal file
@ -0,0 +1,170 @@
|
||||
/******************************************************************************
|
||||
* 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);
|
||||
}
|
||||
}
|
18
drivers/staging/rtl8712/mlme_osdep.h
Normal file
18
drivers/staging/rtl8712/mlme_osdep.h
Normal file
@ -0,0 +1,18 @@
|
||||
#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_*/
|
||||
|
274
drivers/staging/rtl8712/mp_custom_oid.h
Normal file
274
drivers/staging/rtl8712/mp_custom_oid.h
Normal file
@ -0,0 +1,274 @@
|
||||
#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 */
|
||||
|
458
drivers/staging/rtl8712/os_intfs.c
Normal file
458
drivers/staging/rtl8712/os_intfs.c
Normal file
@ -0,0 +1,458 @@
|
||||
/******************************************************************************
|
||||
* 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"
|
19
drivers/staging/rtl8712/osdep_intf.h
Normal file
19
drivers/staging/rtl8712/osdep_intf.h
Normal file
@ -0,0 +1,19 @@
|
||||
#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_*/
|
260
drivers/staging/rtl8712/osdep_service.h
Normal file
260
drivers/staging/rtl8712/osdep_service.h
Normal file
@ -0,0 +1,260 @@
|
||||
#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
|
||||
|
169
drivers/staging/rtl8712/recv_linux.c
Normal file
169
drivers/staging/rtl8712/recv_linux.c
Normal file
@ -0,0 +1,169 @@
|
||||
/******************************************************************************
|
||||
* 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);
|
||||
}
|
27
drivers/staging/rtl8712/recv_osdep.h
Normal file
27
drivers/staging/rtl8712/recv_osdep.h
Normal file
@ -0,0 +1,27 @@
|
||||
#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
|
||||
|
19
drivers/staging/rtl8712/rtl8712_bitdef.h
Normal file
19
drivers/staging/rtl8712/rtl8712_bitdef.h
Normal file
@ -0,0 +1,19 @@
|
||||
#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__ */
|
||||
|
465
drivers/staging/rtl8712/rtl8712_cmd.c
Normal file
465
drivers/staging/rtl8712/rtl8712_cmd.c
Normal file
@ -0,0 +1,465 @@
|
||||
/******************************************************************************
|
||||
* 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;
|
||||
}
|
157
drivers/staging/rtl8712/rtl8712_cmd.h
Normal file
157
drivers/staging/rtl8712/rtl8712_cmd.h
Normal file
@ -0,0 +1,157 @@
|
||||
#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
|
89
drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h
Normal file
89
drivers/staging/rtl8712/rtl8712_cmdctrl_bitdef.h
Normal file
@ -0,0 +1,89 @@
|
||||
#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__*/
|
||||
|
15
drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h
Normal file
15
drivers/staging/rtl8712/rtl8712_cmdctrl_regdef.h
Normal file
@ -0,0 +1,15 @@
|
||||
#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__ */
|
||||
|
36
drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h
Normal file
36
drivers/staging/rtl8712/rtl8712_debugctrl_bitdef.h
Normal file
@ -0,0 +1,36 @@
|
||||
#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__ */
|
28
drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h
Normal file
28
drivers/staging/rtl8712/rtl8712_debugctrl_regdef.h
Normal file
@ -0,0 +1,28 @@
|
||||
#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__ */
|
||||
|
52
drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h
Normal file
52
drivers/staging/rtl8712/rtl8712_edcasetting_bitdef.h
Normal file
@ -0,0 +1,52 @@
|
||||
#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__*/
|
18
drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h
Normal file
18
drivers/staging/rtl8712/rtl8712_edcasetting_regdef.h
Normal file
@ -0,0 +1,18 @@
|
||||
#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__ */
|
||||
|
568
drivers/staging/rtl8712/rtl8712_efuse.c
Normal file
568
drivers/staging/rtl8712/rtl8712_efuse.c
Normal file
@ -0,0 +1,568 @@
|
||||
/*
|
||||
* rtl8712_efuse.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_EFUSE_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "rtl8712_efuse.h"
|
||||
|
||||
/* reserve 3 bytes for HW stop read */
|
||||
static int efuse_available_max_size = EFUSE_MAX_SIZE - 3 /*0x1FD*/;
|
||||
|
||||
static void efuse_reg_ctrl(struct _adapter *padapter, u8 bPowerOn)
|
||||
{
|
||||
u8 tmpu8 = 0;
|
||||
|
||||
if (true == bPowerOn) {
|
||||
/* -----------------e-fuse pwr & clk reg ctrl ---------------
|
||||
* Enable LDOE25 Macro Block
|
||||
*/
|
||||
tmpu8 = r8712_read8(padapter, EFUSE_TEST + 3);
|
||||
tmpu8 |= 0x80;
|
||||
r8712_write8(padapter, EFUSE_TEST + 3, tmpu8);
|
||||
msleep(20); /* for some platform , need some delay time */
|
||||
/* Change Efuse Clock for write action to 40MHZ */
|
||||
r8712_write8(padapter, EFUSE_CLK_CTRL, 0x03);
|
||||
msleep(20); /* for some platform , need some delay time */
|
||||
} else {
|
||||
/* -----------------e-fuse pwr & clk reg ctrl -----------------
|
||||
* Disable LDOE25 Macro Block
|
||||
*/
|
||||
tmpu8 = r8712_read8(padapter, EFUSE_TEST + 3);
|
||||
tmpu8 &= 0x7F;
|
||||
r8712_write8(padapter, EFUSE_TEST + 3, tmpu8);
|
||||
/* Change Efuse Clock for write action to 500K */
|
||||
r8712_write8(padapter, EFUSE_CLK_CTRL, 0x02);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Before write E-Fuse, this function must be called.
|
||||
*/
|
||||
u8 r8712_efuse_reg_init(struct _adapter *padapter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void r8712_efuse_reg_uninit(struct _adapter *padapter)
|
||||
{
|
||||
efuse_reg_ctrl(padapter, false);
|
||||
}
|
||||
|
||||
static u8 efuse_one_byte_read(struct _adapter *padapter, u16 addr, u8 *data)
|
||||
{
|
||||
u8 tmpidx = 0, bResult;
|
||||
|
||||
/* -----------------e-fuse reg ctrl --------------------------------- */
|
||||
r8712_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xFF)); /* address */
|
||||
r8712_write8(padapter, EFUSE_CTRL+2, ((u8)((addr>>8)&0x03)) |
|
||||
(r8712_read8(padapter, EFUSE_CTRL+2)&0xFC));
|
||||
r8712_write8(padapter, EFUSE_CTRL+3, 0x72); /* read cmd */
|
||||
/* wait for complete */
|
||||
while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) && (tmpidx < 100))
|
||||
tmpidx++;
|
||||
if (tmpidx < 100) {
|
||||
*data = r8712_read8(padapter, EFUSE_CTRL);
|
||||
bResult = true;
|
||||
} else {
|
||||
*data = 0xff;
|
||||
bResult = false;
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
static u8 efuse_one_byte_write(struct _adapter *padapter, u16 addr, u8 data)
|
||||
{
|
||||
u8 tmpidx = 0, bResult;
|
||||
|
||||
/* -----------------e-fuse reg ctrl -------------------------------- */
|
||||
r8712_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xFF)); /* address */
|
||||
r8712_write8(padapter, EFUSE_CTRL+2, ((u8)((addr>>8)&0x03)) |
|
||||
(r8712_read8(padapter, EFUSE_CTRL+2)&0xFC));
|
||||
r8712_write8(padapter, EFUSE_CTRL, data); /* data */
|
||||
r8712_write8(padapter, EFUSE_CTRL+3, 0xF2); /* write cmd */
|
||||
/* wait for complete */
|
||||
while ((0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) && (tmpidx < 100))
|
||||
tmpidx++;
|
||||
if (tmpidx < 100)
|
||||
bResult = true;
|
||||
else
|
||||
bResult = false;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
static u8 efuse_one_byte_rw(struct _adapter *padapter, u8 bRead, u16 addr,
|
||||
u8 *data)
|
||||
{
|
||||
u8 tmpidx = 0, tmpv8 = 0, bResult;
|
||||
|
||||
/* -----------------e-fuse reg ctrl --------------------------------- */
|
||||
r8712_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xFF)); /* address */
|
||||
tmpv8 = ((u8)((addr >> 8) & 0x03)) |
|
||||
(r8712_read8(padapter, EFUSE_CTRL + 2) & 0xFC);
|
||||
r8712_write8(padapter, EFUSE_CTRL+2, tmpv8);
|
||||
if (true == bRead) {
|
||||
r8712_write8(padapter, EFUSE_CTRL+3, 0x72); /* read cmd */
|
||||
while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) &&
|
||||
(tmpidx < 100))
|
||||
tmpidx++;
|
||||
if (tmpidx < 100) {
|
||||
*data = r8712_read8(padapter, EFUSE_CTRL);
|
||||
bResult = true;
|
||||
} else {
|
||||
*data = 0;
|
||||
bResult = false;
|
||||
}
|
||||
} else {
|
||||
r8712_write8(padapter, EFUSE_CTRL, *data); /* data */
|
||||
r8712_write8(padapter, EFUSE_CTRL+3, 0xF2); /* write cmd */
|
||||
while ((0x80 & r8712_read8(padapter, EFUSE_CTRL+3)) &&
|
||||
(tmpidx < 100))
|
||||
tmpidx++;
|
||||
if (tmpidx < 100)
|
||||
bResult = true;
|
||||
else
|
||||
bResult = false;
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
static u8 efuse_is_empty(struct _adapter *padapter, u8 *empty)
|
||||
{
|
||||
u8 value, ret = true;
|
||||
|
||||
/* read one byte to check if E-Fuse is empty */
|
||||
if (efuse_one_byte_rw(padapter, true, 0, &value) == true) {
|
||||
if (0xFF == value)
|
||||
*empty = true;
|
||||
else
|
||||
*empty = false;
|
||||
} else
|
||||
ret = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void r8712_efuse_change_max_size(struct _adapter *padapter)
|
||||
{
|
||||
u16 pre_pg_data_saddr = 0x1FB;
|
||||
u16 i;
|
||||
u16 pre_pg_data_size = 5;
|
||||
u8 pre_pg_data[5];
|
||||
|
||||
for (i = 0; i < pre_pg_data_size; i++)
|
||||
efuse_one_byte_read(padapter, pre_pg_data_saddr + i,
|
||||
&pre_pg_data[i]);
|
||||
if ((pre_pg_data[0] == 0x03) && (pre_pg_data[1] == 0x00) &&
|
||||
(pre_pg_data[2] == 0x00) && (pre_pg_data[3] == 0x00) &&
|
||||
(pre_pg_data[4] == 0x0C))
|
||||
efuse_available_max_size -= pre_pg_data_size;
|
||||
}
|
||||
|
||||
int r8712_efuse_get_max_size(struct _adapter *padapter)
|
||||
{
|
||||
return efuse_available_max_size;
|
||||
}
|
||||
|
||||
static u8 calculate_word_cnts(const u8 word_en)
|
||||
{
|
||||
u8 word_cnts = 0;
|
||||
u8 word_idx;
|
||||
|
||||
for (word_idx = 0; word_idx < PGPKG_MAX_WORDS; word_idx++)
|
||||
if (!(word_en & BIT(word_idx)))
|
||||
word_cnts++; /* 0 : write enable */
|
||||
return word_cnts;
|
||||
}
|
||||
|
||||
static void pgpacket_copy_data(const u8 word_en, const u8 *sourdata,
|
||||
u8 *targetdata)
|
||||
{
|
||||
u8 tmpindex = 0;
|
||||
u8 word_idx, byte_idx;
|
||||
|
||||
for (word_idx = 0; word_idx < PGPKG_MAX_WORDS; word_idx++) {
|
||||
if (!(word_en&BIT(word_idx))) {
|
||||
byte_idx = word_idx * 2;
|
||||
targetdata[byte_idx] = sourdata[tmpindex++];
|
||||
targetdata[byte_idx + 1] = sourdata[tmpindex++];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u16 r8712_efuse_get_current_size(struct _adapter *padapter)
|
||||
{
|
||||
int bContinual = true;
|
||||
u16 efuse_addr = 0;
|
||||
u8 hoffset = 0, hworden = 0;
|
||||
u8 efuse_data, word_cnts = 0;
|
||||
|
||||
while (bContinual && efuse_one_byte_read(padapter, efuse_addr,
|
||||
&efuse_data) && (efuse_addr < efuse_available_max_size)) {
|
||||
if (efuse_data != 0xFF) {
|
||||
hoffset = (efuse_data >> 4) & 0x0F;
|
||||
hworden = efuse_data & 0x0F;
|
||||
word_cnts = calculate_word_cnts(hworden);
|
||||
/* read next header */
|
||||
efuse_addr = efuse_addr + (word_cnts * 2) + 1;
|
||||
} else
|
||||
bContinual = false ;
|
||||
}
|
||||
return efuse_addr;
|
||||
}
|
||||
|
||||
u8 r8712_efuse_pg_packet_read(struct _adapter *padapter, u8 offset, u8 *data)
|
||||
{
|
||||
u8 hoffset = 0, hworden = 0, word_cnts = 0;
|
||||
u16 efuse_addr = 0;
|
||||
u8 efuse_data;
|
||||
u8 tmpidx = 0;
|
||||
u8 tmpdata[PGPKT_DATA_SIZE];
|
||||
u8 ret = true;
|
||||
|
||||
if (data == NULL)
|
||||
return false;
|
||||
if (offset > 0x0f)
|
||||
return false;
|
||||
memset(data, 0xFF, sizeof(u8)*PGPKT_DATA_SIZE);
|
||||
while (efuse_addr < efuse_available_max_size) {
|
||||
if (efuse_one_byte_read(padapter, efuse_addr, &efuse_data) ==
|
||||
true) {
|
||||
if (efuse_data == 0xFF)
|
||||
break;
|
||||
hoffset = (efuse_data >> 4) & 0x0F;
|
||||
hworden = efuse_data & 0x0F;
|
||||
word_cnts = calculate_word_cnts(hworden);
|
||||
if (hoffset == offset) {
|
||||
memset(tmpdata, 0xFF, PGPKT_DATA_SIZE);
|
||||
for (tmpidx = 0; tmpidx < word_cnts * 2;
|
||||
tmpidx++) {
|
||||
if (efuse_one_byte_read(padapter,
|
||||
efuse_addr+1+tmpidx, &efuse_data) ==
|
||||
true) {
|
||||
tmpdata[tmpidx] = efuse_data;
|
||||
} else
|
||||
ret = false;
|
||||
}
|
||||
pgpacket_copy_data(hworden, tmpdata, data);
|
||||
}
|
||||
efuse_addr += 1 + (word_cnts*2);
|
||||
} else {
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr)
|
||||
{
|
||||
struct PGPKT_STRUCT pkt;
|
||||
u8 offset, word_en, value;
|
||||
u16 addr;
|
||||
int i;
|
||||
u8 ret = true;
|
||||
|
||||
pkt.offset = GET_EFUSE_OFFSET(header);
|
||||
pkt.word_en = GET_EFUSE_WORD_EN(header);
|
||||
addr = header_addr + 1 + calculate_word_cnts(pkt.word_en) * 2;
|
||||
if (addr > efuse_available_max_size)
|
||||
return false;
|
||||
/* retrieve original data */
|
||||
addr = 0;
|
||||
while (addr < header_addr) {
|
||||
if (efuse_one_byte_read(padapter, addr++, &value) == false) {
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
offset = GET_EFUSE_OFFSET(value);
|
||||
word_en = GET_EFUSE_WORD_EN(value);
|
||||
if (pkt.offset != offset) {
|
||||
addr += calculate_word_cnts(word_en)*2;
|
||||
continue;
|
||||
}
|
||||
for (i = 0; i < PGPKG_MAX_WORDS; i++) {
|
||||
if (BIT(i) & word_en)
|
||||
continue;
|
||||
if (!(BIT(i) & pkt.word_en)) {
|
||||
if (efuse_one_byte_read(padapter, addr,
|
||||
&value) == true)
|
||||
pkt.data[i*2] = value;
|
||||
else
|
||||
return false;
|
||||
if (efuse_one_byte_read(padapter, addr + 1,
|
||||
&value) == true)
|
||||
pkt.data[i*2 + 1] = value;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
addr += 2;
|
||||
}
|
||||
}
|
||||
if (addr != header_addr)
|
||||
return false;
|
||||
addr++;
|
||||
/* fill original data */
|
||||
for (i = 0; i < PGPKG_MAX_WORDS; i++) {
|
||||
if (BIT(i) & pkt.word_en)
|
||||
continue;
|
||||
efuse_one_byte_write(padapter, addr, pkt.data[i*2]);
|
||||
efuse_one_byte_write(padapter, addr+1, pkt.data[i*2 + 1]);
|
||||
/* additional check */
|
||||
if (efuse_one_byte_read(padapter, addr, &value) == false)
|
||||
ret = false;
|
||||
else if (pkt.data[i*2] != value) {
|
||||
ret = false;
|
||||
if (0xFF == value) /* write again */
|
||||
efuse_one_byte_write(padapter, addr,
|
||||
pkt.data[i * 2]);
|
||||
}
|
||||
if (efuse_one_byte_read(padapter, addr+1, &value) == false)
|
||||
ret = false;
|
||||
else if (pkt.data[i*2 + 1] != value) {
|
||||
ret = false;
|
||||
if (0xFF == value) /* write again */
|
||||
efuse_one_byte_write(padapter, addr+1,
|
||||
pkt.data[i*2 + 1]);
|
||||
}
|
||||
addr += 2;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset,
|
||||
const u8 word_en, const u8 *data)
|
||||
{
|
||||
u8 pg_header = 0;
|
||||
u16 efuse_addr = 0, curr_size = 0;
|
||||
u8 efuse_data, target_word_cnts = 0;
|
||||
static int repeat_times;
|
||||
int sub_repeat;
|
||||
u8 bResult = true;
|
||||
|
||||
/* check if E-Fuse Clock Enable and E-Fuse Clock is 40M */
|
||||
efuse_data = r8712_read8(padapter, EFUSE_CLK_CTRL);
|
||||
if (efuse_data != 0x03)
|
||||
return false;
|
||||
pg_header = MAKE_EFUSE_HEADER(offset, word_en);
|
||||
target_word_cnts = calculate_word_cnts(word_en);
|
||||
repeat_times = 0;
|
||||
efuse_addr = 0;
|
||||
while (efuse_addr < efuse_available_max_size) {
|
||||
curr_size = r8712_efuse_get_current_size(padapter);
|
||||
if ((curr_size + 1 + target_word_cnts * 2) >
|
||||
efuse_available_max_size)
|
||||
return false; /*target_word_cnts + pg header(1 byte)*/
|
||||
efuse_addr = curr_size; /* current size is also the last addr*/
|
||||
efuse_one_byte_write(padapter, efuse_addr, pg_header); /*hdr*/
|
||||
sub_repeat = 0;
|
||||
/* check if what we read is what we write */
|
||||
while (efuse_one_byte_read(padapter, efuse_addr,
|
||||
&efuse_data) == false) {
|
||||
if (++sub_repeat > _REPEAT_THRESHOLD_) {
|
||||
bResult = false; /* continue to blind write */
|
||||
break; /* continue to blind write */
|
||||
}
|
||||
}
|
||||
if ((sub_repeat > _REPEAT_THRESHOLD_) ||
|
||||
(pg_header == efuse_data)) {
|
||||
/* write header ok OR can't check header(creep) */
|
||||
u8 i;
|
||||
|
||||
/* go to next address */
|
||||
efuse_addr++;
|
||||
for (i = 0; i < target_word_cnts*2; i++) {
|
||||
efuse_one_byte_write(padapter,
|
||||
efuse_addr + i,
|
||||
*(data + i));
|
||||
if (efuse_one_byte_read(padapter,
|
||||
efuse_addr + i, &efuse_data) == false)
|
||||
bResult = false;
|
||||
else if (*(data+i) != efuse_data) /* fail */
|
||||
bResult = false;
|
||||
}
|
||||
break;
|
||||
} else { /* write header fail */
|
||||
bResult = false;
|
||||
if (0xFF == efuse_data)
|
||||
return bResult; /* not thing damaged. */
|
||||
/* call rescue procedure */
|
||||
if (fix_header(padapter, efuse_data, efuse_addr) ==
|
||||
false)
|
||||
return false; /* rescue fail */
|
||||
|
||||
if (++repeat_times > _REPEAT_THRESHOLD_) /* fail */
|
||||
break;
|
||||
/* otherwise, take another risk... */
|
||||
}
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
|
||||
u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead, u16 start_addr,
|
||||
u16 cnts, u8 *data)
|
||||
{
|
||||
int i;
|
||||
u8 res = true;;
|
||||
|
||||
if (start_addr > EFUSE_MAX_SIZE)
|
||||
return false;
|
||||
if ((bRead == false) && ((start_addr + cnts) >
|
||||
efuse_available_max_size))
|
||||
return false;
|
||||
if ((false == bRead) && (r8712_efuse_reg_init(padapter) == false))
|
||||
return false;
|
||||
/* -----------------e-fuse one byte read / write ---------------------*/
|
||||
for (i = 0; i < cnts; i++) {
|
||||
if ((start_addr + i) > EFUSE_MAX_SIZE) {
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
res = efuse_one_byte_rw(padapter, bRead, start_addr + i,
|
||||
data + i);
|
||||
if ((false == bRead) && (false == res))
|
||||
break;
|
||||
}
|
||||
if (false == bRead)
|
||||
r8712_efuse_reg_uninit(padapter);
|
||||
return res;
|
||||
}
|
||||
|
||||
u8 r8712_efuse_map_read(struct _adapter *padapter, u16 addr, u16 cnts, u8 *data)
|
||||
{
|
||||
u8 offset, ret = true;
|
||||
u8 pktdata[PGPKT_DATA_SIZE];
|
||||
int i, idx;
|
||||
|
||||
if ((addr + cnts) > EFUSE_MAP_MAX_SIZE)
|
||||
return false;
|
||||
if ((efuse_is_empty(padapter, &offset) == true) && (offset ==
|
||||
true)) {
|
||||
for (i = 0; i < cnts; i++)
|
||||
data[i] = 0xFF;
|
||||
return ret;
|
||||
}
|
||||
offset = (addr >> 3) & 0xF;
|
||||
ret = r8712_efuse_pg_packet_read(padapter, offset, pktdata);
|
||||
i = addr & 0x7; /* pktdata index */
|
||||
idx = 0; /* data index */
|
||||
|
||||
do {
|
||||
for (; i < PGPKT_DATA_SIZE; i++) {
|
||||
data[idx++] = pktdata[i];
|
||||
if (idx == cnts)
|
||||
return ret;
|
||||
}
|
||||
offset++;
|
||||
if (!r8712_efuse_pg_packet_read(padapter, offset, pktdata))
|
||||
ret = false;
|
||||
i = 0;
|
||||
} while (1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts,
|
||||
u8 *data)
|
||||
{
|
||||
u8 offset, word_en, empty;
|
||||
u8 pktdata[PGPKT_DATA_SIZE], newdata[PGPKT_DATA_SIZE];
|
||||
int i, j, idx;
|
||||
|
||||
if ((addr + cnts) > EFUSE_MAP_MAX_SIZE)
|
||||
return false;
|
||||
/* check if E-Fuse Clock Enable and E-Fuse Clock is 40M */
|
||||
empty = r8712_read8(padapter, EFUSE_CLK_CTRL);
|
||||
if (empty != 0x03)
|
||||
return false;
|
||||
if (efuse_is_empty(padapter, &empty) == true) {
|
||||
if (true == empty)
|
||||
memset(pktdata, 0xFF, PGPKT_DATA_SIZE);
|
||||
} else
|
||||
return false;
|
||||
offset = (addr >> 3) & 0xF;
|
||||
if (empty == false)
|
||||
if (!r8712_efuse_pg_packet_read(padapter, offset, pktdata))
|
||||
return false;
|
||||
word_en = 0xF;
|
||||
memset(newdata, 0xFF, PGPKT_DATA_SIZE);
|
||||
i = addr & 0x7; /* pktdata index */
|
||||
j = 0; /* newdata index */
|
||||
idx = 0; /* data index */
|
||||
|
||||
if (i & 0x1) {
|
||||
/* odd start */
|
||||
if (data[idx] != pktdata[i]) {
|
||||
word_en &= ~BIT(i >> 1);
|
||||
newdata[j++] = pktdata[i - 1];
|
||||
newdata[j++] = data[idx];
|
||||
}
|
||||
i++;
|
||||
idx++;
|
||||
}
|
||||
do {
|
||||
for (; i < PGPKT_DATA_SIZE; i += 2) {
|
||||
if ((cnts - idx) == 1) {
|
||||
if (data[idx] != pktdata[i]) {
|
||||
word_en &= ~BIT(i >> 1);
|
||||
newdata[j++] = data[idx];
|
||||
newdata[j++] = pktdata[1 + 1];
|
||||
}
|
||||
idx++;
|
||||
break;
|
||||
} else {
|
||||
if ((data[idx] != pktdata[i]) || (data[idx+1] !=
|
||||
pktdata[i+1])) {
|
||||
word_en &= ~BIT(i >> 1);
|
||||
newdata[j++] = data[idx];
|
||||
newdata[j++] = data[idx + 1];
|
||||
}
|
||||
idx += 2;
|
||||
}
|
||||
if (idx == cnts)
|
||||
break;
|
||||
}
|
||||
|
||||
if (word_en != 0xF)
|
||||
if (r8712_efuse_pg_packet_write(padapter, offset,
|
||||
word_en, newdata) == false)
|
||||
return false;
|
||||
if (idx == cnts)
|
||||
break;
|
||||
offset++;
|
||||
if (empty == false)
|
||||
if (!r8712_efuse_pg_packet_read(padapter, offset,
|
||||
pktdata))
|
||||
return false;
|
||||
i = 0;
|
||||
j = 0;
|
||||
word_en = 0xF;
|
||||
memset(newdata, 0xFF, PGPKT_DATA_SIZE);
|
||||
} while (1);
|
||||
|
||||
return true;
|
||||
}
|
43
drivers/staging/rtl8712/rtl8712_efuse.h
Normal file
43
drivers/staging/rtl8712/rtl8712_efuse.h
Normal file
@ -0,0 +1,43 @@
|
||||
#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
|
73
drivers/staging/rtl8712/rtl8712_event.h
Normal file
73
drivers/staging/rtl8712/rtl8712_event.h
Normal file
@ -0,0 +1,73 @@
|
||||
#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
|
126
drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h
Normal file
126
drivers/staging/rtl8712/rtl8712_fifoctrl_bitdef.h
Normal file
@ -0,0 +1,126 @@
|
||||
#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__ */
|
||||
|
57
drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h
Normal file
57
drivers/staging/rtl8712/rtl8712_fifoctrl_regdef.h
Normal file
@ -0,0 +1,57 @@
|
||||
#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__ */
|
54
drivers/staging/rtl8712/rtl8712_gp_bitdef.h
Normal file
54
drivers/staging/rtl8712/rtl8712_gp_bitdef.h
Normal file
@ -0,0 +1,54 @@
|
||||
#ifndef __RTL8712_GP_BITDEF_H__
|
||||
#define __RTL8712_GP_BITDEF_H__
|
||||
|
||||
/*GPIO_CTRL*/
|
||||
#define _GPIO_MOD_MSK 0xFF000000
|
||||
#define _GPIO_MOD_SHT 24
|
||||
#define _GPIO_IO_SEL_MSK 0x00FF0000
|
||||
#define _GPIO_IO_SEL_SHT 16
|
||||
#define _GPIO_OUT_MSK 0x0000FF00
|
||||
#define _GPIO_OUT_SHT 8
|
||||
#define _GPIO_IN_MSK 0x000000FF
|
||||
#define _GPIO_IN_SHT 0
|
||||
|
||||
/*SYS_PINMUX_CFG*/
|
||||
#define _GPIOSEL_MSK 0x0003
|
||||
#define _GPIOSEL_SHT 0
|
||||
|
||||
/*LED_CFG*/
|
||||
#define _LED1SV BIT(7)
|
||||
#define _LED1CM_MSK 0x0070
|
||||
#define _LED1CM_SHT 4
|
||||
#define _LED0SV BIT(3)
|
||||
#define _LED0CM_MSK 0x0007
|
||||
#define _LED0CM_SHT 0
|
||||
|
||||
/*PHY_REG*/
|
||||
#define _HST_RDRDY_SHT 0
|
||||
#define _HST_RDRDY_MSK 0xFF
|
||||
#define _HST_RDRDY BIT(_HST_RDRDY_SHT)
|
||||
#define _CPU_WTBUSY_SHT 1
|
||||
#define _CPU_WTBUSY_MSK 0xFF
|
||||
#define _CPU_WTBUSY BIT(_CPU_WTBUSY_SHT)
|
||||
|
||||
/* 11. General Purpose Registers (Offset: 0x02E0 - 0x02FF)*/
|
||||
|
||||
/* 8192S GPIO Config Setting (offset 0x2F1, 1 byte)*/
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#define GPIOMUX_EN BIT(3) /* When this bit is set to "1",
|
||||
* GPIO PINs will switch to MAC
|
||||
* GPIO Function*/
|
||||
#define GPIOSEL_GPIO 0 /* UART or JTAG or pure GPIO*/
|
||||
#define GPIOSEL_PHYDBG 1 /* PHYDBG*/
|
||||
#define GPIOSEL_BT 2 /* BT_coex*/
|
||||
#define GPIOSEL_WLANDBG 3 /* WLANDBG*/
|
||||
#define GPIOSEL_GPIO_MASK (~(BIT(0)|BIT(1)))
|
||||
/* HW Readio OFF switch (GPIO BIT) */
|
||||
#define HAL_8192S_HW_GPIO_OFF_BIT BIT(3)
|
||||
#define HAL_8192S_HW_GPIO_OFF_MASK 0xF7
|
||||
#define HAL_8192S_HW_GPIO_WPS_BIT BIT(4)
|
||||
|
||||
#endif /*__RTL8712_GP_BITDEF_H__*/
|
||||
|
17
drivers/staging/rtl8712/rtl8712_gp_regdef.h
Normal file
17
drivers/staging/rtl8712/rtl8712_gp_regdef.h
Normal file
@ -0,0 +1,17 @@
|
||||
#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__ */
|
||||
|
124
drivers/staging/rtl8712/rtl8712_hal.h
Normal file
124
drivers/staging/rtl8712/rtl8712_hal.h
Normal file
@ -0,0 +1,124 @@
|
||||
#ifndef __RTL8712_HAL_H__
|
||||
#define __RTL8712_HAL_H__
|
||||
|
||||
enum _HW_VERSION {
|
||||
RTL8712_FPGA,
|
||||
RTL8712_1stCUT, /*A Cut (RTL8712_ASIC)*/
|
||||
RTL8712_2ndCUT, /*B Cut*/
|
||||
RTL8712_3rdCUT, /*C Cut*/
|
||||
};
|
||||
|
||||
enum _LOOPBACK_TYPE {
|
||||
RTL8712_AIR_TRX = 0,
|
||||
RTL8712_MAC_LBK,
|
||||
RTL8712_BB_LBK,
|
||||
RTL8712_MAC_FW_LBK = 4,
|
||||
RTL8712_BB_FW_LBK = 8,
|
||||
};
|
||||
|
||||
enum RTL871X_HCI_TYPE {
|
||||
RTL8712_SDIO,
|
||||
RTL8712_USB,
|
||||
};
|
||||
|
||||
enum RTL8712_RF_CONFIG{
|
||||
RTL8712_RF_1T1R,
|
||||
RTL8712_RF_1T2R,
|
||||
RTL8712_RF_2T2R
|
||||
};
|
||||
|
||||
enum _RTL8712_HCI_TYPE_{
|
||||
RTL8712_HCI_TYPE_PCIE = 0x01,
|
||||
RTL8712_HCI_TYPE_AP_PCIE = 0x81,
|
||||
RTL8712_HCI_TYPE_USB = 0x02,
|
||||
RTL8712_HCI_TYPE_92USB = 0x02,
|
||||
RTL8712_HCI_TYPE_AP_USB = 0x82,
|
||||
RTL8712_HCI_TYPE_72USB = 0x12,
|
||||
RTL8712_HCI_TYPE_SDIO = 0x04,
|
||||
RTL8712_HCI_TYPE_72SDIO = 0x14
|
||||
};
|
||||
|
||||
struct fw_priv { /*8-bytes alignment required*/
|
||||
/*--- long word 0 ----*/
|
||||
unsigned char signature_0; /*0x12: CE product, 0x92: IT product*/
|
||||
unsigned char signature_1; /*0x87: CE product, 0x81: IT product*/
|
||||
unsigned char hci_sel; /*0x81: PCI-AP, 01:PCIe, 02: 92S-U, 0x82: USB-AP,
|
||||
* 0x12: 72S-U, 03:SDIO*/
|
||||
unsigned char chip_version; /*the same value as register value*/
|
||||
unsigned char customer_ID_0; /*customer ID low byte*/
|
||||
unsigned char customer_ID_1; /*customer ID high byte*/
|
||||
unsigned char rf_config; /*0x11: 1T1R, 0x12: 1T2R, 0x92: 1T2R turbo,
|
||||
* 0x22: 2T2R*/
|
||||
unsigned char usb_ep_num; /* 4: 4EP, 6: 6EP, 11: 11EP*/
|
||||
/*--- long word 1 ----*/
|
||||
unsigned char regulatory_class_0; /*regulatory class bit map 0*/
|
||||
unsigned char regulatory_class_1; /*regulatory class bit map 1*/
|
||||
unsigned char regulatory_class_2; /*regulatory class bit map 2*/
|
||||
unsigned char regulatory_class_3; /*regulatory class bit map 3*/
|
||||
unsigned char rfintfs; /* 0:SWSI, 1:HWSI, 2:HWPI*/
|
||||
unsigned char def_nettype;
|
||||
unsigned char turboMode;
|
||||
unsigned char lowPowerMode;/* 0: noral mode, 1: low power mode*/
|
||||
/*--- long word 2 ----*/
|
||||
unsigned char lbk_mode; /*0x00: normal, 0x03: MACLBK, 0x01: PHYLBK*/
|
||||
unsigned char mp_mode; /* 1: for MP use, 0: for normal driver */
|
||||
unsigned char vcsType; /* 0:off 1:on 2:auto */
|
||||
unsigned char vcsMode; /* 1:RTS/CTS 2:CTS to self */
|
||||
unsigned char rsvd022;
|
||||
unsigned char rsvd023;
|
||||
unsigned char rsvd024;
|
||||
unsigned char rsvd025;
|
||||
/*--- long word 3 ----*/
|
||||
unsigned char qos_en; /*1: QoS enable*/
|
||||
unsigned char bw_40MHz_en; /*1: 40MHz BW enable*/
|
||||
unsigned char AMSDU2AMPDU_en; /*1: 4181 convert AMSDU to AMPDU,
|
||||
* 0: disable*/
|
||||
unsigned char AMPDU_en; /*1: 11n AMPDU enable*/
|
||||
unsigned char rate_control_offload; /*1: FW offloads, 0: driver handles*/
|
||||
unsigned char aggregation_offload; /*1: FW offloads, 0: driver handles*/
|
||||
unsigned char rsvd030;
|
||||
unsigned char rsvd031;
|
||||
/*--- long word 4 ----*/
|
||||
unsigned char beacon_offload; /* 1. FW offloads, 0: driver handles*/
|
||||
unsigned char MLME_offload; /* 2. FW offloads, 0: driver handles*/
|
||||
unsigned char hwpc_offload; /* 3. FW offloads, 0: driver handles*/
|
||||
unsigned char tcp_checksum_offload; /* 4. FW offloads, 0: driver handles*/
|
||||
unsigned char tcp_offload; /* 5. FW offloads, 0: driver handles*/
|
||||
unsigned char ps_control_offload; /* 6. FW offloads, 0: driver handles*/
|
||||
unsigned char WWLAN_offload; /* 7. FW offloads, 0: driver handles*/
|
||||
unsigned char rsvd040;
|
||||
/*--- long word 5 ----*/
|
||||
unsigned char tcp_tx_frame_len_L; /*tcp tx packet length low byte*/
|
||||
unsigned char tcp_tx_frame_len_H; /*tcp tx packet length high byte*/
|
||||
unsigned char tcp_rx_frame_len_L; /*tcp rx packet length low byte*/
|
||||
unsigned char tcp_rx_frame_len_H; /*tcp rx packet length high byte*/
|
||||
unsigned char rsvd050;
|
||||
unsigned char rsvd051;
|
||||
unsigned char rsvd052;
|
||||
unsigned char rsvd053;
|
||||
};
|
||||
|
||||
struct fw_hdr {/*8-byte alinment required*/
|
||||
unsigned short signature;
|
||||
unsigned short version; /*0x8000 ~ 0x8FFF for FPGA version,
|
||||
*0x0000 ~ 0x7FFF for ASIC version,*/
|
||||
unsigned int dmem_size; /*define the size of boot loader*/
|
||||
unsigned int img_IMEM_size; /*define the size of FW in IMEM*/
|
||||
unsigned int img_SRAM_size; /*define the size of FW in SRAM*/
|
||||
unsigned int fw_priv_sz; /*define the size of DMEM variable*/
|
||||
unsigned short efuse_addr;
|
||||
unsigned short h2ccnd_resp_addr;
|
||||
unsigned int SVNRevision;
|
||||
unsigned int release_time; /*Mon:Day:Hr:Min*/
|
||||
struct fw_priv fwpriv;
|
||||
};
|
||||
|
||||
struct hal_priv{
|
||||
/*Endpoint handles*/
|
||||
struct net_device *pipehdls_r8712[10];
|
||||
u8 (*hal_bus_init)(struct _adapter *adapter);
|
||||
};
|
||||
|
||||
uint rtl8712_hal_init(struct _adapter *padapter);
|
||||
|
||||
#endif
|
39
drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h
Normal file
39
drivers/staging/rtl8712/rtl8712_interrupt_bitdef.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef __RTL8712_INTERRUPT_BITDEF_H__
|
||||
#define __RTL8712_INTERRUPT_BITDEF_H__
|
||||
|
||||
/*HIMR*/
|
||||
/*HISR*/
|
||||
#define _CPUERR BIT(29)
|
||||
#define _ATIMEND BIT(28)
|
||||
#define _TXBCNOK BIT(27)
|
||||
#define _TXBCNERR BIT(26)
|
||||
#define _BCNDMAINT4 BIT(25)
|
||||
#define _BCNDMAINT3 BIT(24)
|
||||
#define _BCNDMAINT2 BIT(23)
|
||||
#define _BCNDMAINT1 BIT(22)
|
||||
#define _BCNDOK4 BIT(21)
|
||||
#define _BCNDOK3 BIT(20)
|
||||
#define _BCNDOK2 BIT(19)
|
||||
#define _BCNDOK1 BIT(18)
|
||||
#define _TIMEOUT2 BIT(17)
|
||||
#define _TIMEOUT1 BIT(16)
|
||||
#define _TXFOVW BIT(15)
|
||||
#define _PSTIMEOUT BIT(14)
|
||||
#define _BCNDMAINT0 BIT(13)
|
||||
#define _FOVW BIT(12)
|
||||
#define _RDU BIT(11)
|
||||
#define _RXCMDOK BIT(10)
|
||||
#define _BCNDOK0 BIT(9)
|
||||
#define _HIGHDOK BIT(8)
|
||||
#define _COMDOK BIT(7)
|
||||
#define _MGTDOK BIT(6)
|
||||
#define _HCCADOK BIT(5)
|
||||
#define _BKDOK BIT(4)
|
||||
#define _BEDOK BIT(3)
|
||||
#define _VIDOK BIT(2)
|
||||
#define _VODOK BIT(1)
|
||||
#define _RXOK BIT(0)
|
||||
|
||||
|
||||
#endif /*__RTL8712_INTERRUPT_BITDEF_H__*/
|
||||
|
151
drivers/staging/rtl8712/rtl8712_io.c
Normal file
151
drivers/staging/rtl8712/rtl8712_io.c
Normal file
@ -0,0 +1,151 @@
|
||||
/******************************************************************************
|
||||
* rtl8712_io.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_IO_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "rtl871x_io.h"
|
||||
#include "osdep_intf.h"
|
||||
#include "usb_ops.h"
|
||||
|
||||
u8 r8712_read8(struct _adapter *adapter, u32 addr)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = &(pio_queue->intf);
|
||||
u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
|
||||
u8 r_val;
|
||||
|
||||
_read8 = pintfhdl->io_ops._read8;
|
||||
r_val = _read8(pintfhdl, addr);
|
||||
return r_val;
|
||||
}
|
||||
|
||||
u16 r8712_read16(struct _adapter *adapter, u32 addr)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = &(pio_queue->intf);
|
||||
u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
|
||||
u16 r_val;
|
||||
|
||||
_read16 = pintfhdl->io_ops._read16;
|
||||
r_val = _read16(pintfhdl, addr);
|
||||
return r_val;
|
||||
}
|
||||
|
||||
u32 r8712_read32(struct _adapter *adapter, u32 addr)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = &(pio_queue->intf);
|
||||
u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
|
||||
u32 r_val;
|
||||
|
||||
_read32 = pintfhdl->io_ops._read32;
|
||||
r_val = _read32(pintfhdl, addr);
|
||||
return r_val;
|
||||
}
|
||||
|
||||
void r8712_write8(struct _adapter *adapter, u32 addr, u8 val)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = &(pio_queue->intf);
|
||||
void (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
|
||||
|
||||
_write8 = pintfhdl->io_ops._write8;
|
||||
_write8(pintfhdl, addr, val);
|
||||
}
|
||||
|
||||
void r8712_write16(struct _adapter *adapter, u32 addr, u16 val)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = &(pio_queue->intf);
|
||||
|
||||
void (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
|
||||
_write16 = pintfhdl->io_ops._write16;
|
||||
_write16(pintfhdl, addr, val);
|
||||
}
|
||||
|
||||
void r8712_write32(struct _adapter *adapter, u32 addr, u32 val)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_queue->intf));
|
||||
|
||||
void (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
|
||||
_write32 = pintfhdl->io_ops._write32;
|
||||
_write32(pintfhdl, addr, val);
|
||||
}
|
||||
|
||||
void r8712_read_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = &(pio_queue->intf);
|
||||
|
||||
void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
|
||||
u8 *pmem);
|
||||
if ((adapter->bDriverStopped == true) ||
|
||||
(adapter->bSurpriseRemoved == true))
|
||||
return;
|
||||
_read_mem = pintfhdl->io_ops._read_mem;
|
||||
_read_mem(pintfhdl, addr, cnt, pmem);
|
||||
}
|
||||
|
||||
void r8712_write_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = &(pio_queue->intf);
|
||||
void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
|
||||
u8 *pmem);
|
||||
|
||||
_write_mem = pintfhdl->io_ops._write_mem;
|
||||
_write_mem(pintfhdl, addr, cnt, pmem);
|
||||
}
|
||||
|
||||
void r8712_read_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = &(pio_queue->intf);
|
||||
|
||||
u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
|
||||
u8 *pmem);
|
||||
if ((adapter->bDriverStopped == true) ||
|
||||
(adapter->bSurpriseRemoved == true))
|
||||
return;
|
||||
_read_port = pintfhdl->io_ops._read_port;
|
||||
_read_port(pintfhdl, addr, cnt, pmem);
|
||||
}
|
||||
|
||||
void r8712_write_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue;
|
||||
struct intf_hdl *pintfhdl = &(pio_queue->intf);
|
||||
|
||||
u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
|
||||
u8 *pmem);
|
||||
_write_port = pintfhdl->io_ops._write_port;
|
||||
_write_port(pintfhdl, addr, cnt, pmem);
|
||||
}
|
1815
drivers/staging/rtl8712/rtl8712_led.c
Normal file
1815
drivers/staging/rtl8712/rtl8712_led.c
Normal file
File diff suppressed because it is too large
Load Diff
28
drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h
Normal file
28
drivers/staging/rtl8712/rtl8712_macsetting_bitdef.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef __RTL8712_MACSETTING_BITDEF_H__
|
||||
#define __RTL8712_MACSETTING_BITDEF_H__
|
||||
|
||||
|
||||
/*MACID*/
|
||||
/*BSSID*/
|
||||
|
||||
/*HWVID*/
|
||||
#define _HWVID_MSK 0x0F
|
||||
|
||||
/*MAR*/
|
||||
/*MBIDCANCONTENT*/
|
||||
|
||||
/*MBIDCANCFG*/
|
||||
#define _POOLING BIT(31)
|
||||
#define _WRITE_EN BIT(16)
|
||||
#define _CAM_ADDR_MSK 0x001F
|
||||
#define _CAM_ADDR_SHT 0
|
||||
|
||||
/*BUILDTIME*/
|
||||
#define _BUILDTIME_MSK 0x3FFFFFFF
|
||||
|
||||
/*BUILDUSER*/
|
||||
|
||||
|
||||
|
||||
#endif /* __RTL8712_MACSETTING_BITDEF_H__*/
|
||||
|
16
drivers/staging/rtl8712/rtl8712_macsetting_regdef.h
Normal file
16
drivers/staging/rtl8712/rtl8712_macsetting_regdef.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef __RTL8712_MACSETTING_REGDEF_H__
|
||||
#define __RTL8712_MACSETTING_REGDEF_H__
|
||||
|
||||
#define MACID (RTL8712_MACIDSETTING_ + 0x0000)
|
||||
#define BSSIDR (RTL8712_MACIDSETTING_ + 0x0008)
|
||||
#define HWVID (RTL8712_MACIDSETTING_ + 0x000E)
|
||||
#define MAR (RTL8712_MACIDSETTING_ + 0x0010)
|
||||
#define MBIDCANCONTENT (RTL8712_MACIDSETTING_ + 0x0018)
|
||||
#define MBIDCANCFG (RTL8712_MACIDSETTING_ + 0x0020)
|
||||
#define BUILDTIME (RTL8712_MACIDSETTING_ + 0x0024)
|
||||
#define BUILDUSER (RTL8712_MACIDSETTING_ + 0x0028)
|
||||
|
||||
|
||||
|
||||
#endif /*__RTL8712_MACSETTING_REGDEF_H__*/
|
||||
|
33
drivers/staging/rtl8712/rtl8712_powersave_bitdef.h
Normal file
33
drivers/staging/rtl8712/rtl8712_powersave_bitdef.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef __RTL8712_POWERSAVE_BITDEF_H__
|
||||
#define __RTL8712_POWERSAVE_BITDEF_H__
|
||||
|
||||
/*WOWCTRL*/
|
||||
#define _UWF BIT(3)
|
||||
#define _MAGIC BIT(2)
|
||||
#define _WOW_EN BIT(1)
|
||||
#define _PMEN BIT(0)
|
||||
|
||||
/*PSSTATUS*/
|
||||
#define _PSSTATUS_SEL_MSK 0x0F
|
||||
|
||||
/*PSSWITCH*/
|
||||
#define _PSSWITCH_ACT BIT(7)
|
||||
#define _PSSWITCH_SEL_MSK 0x0F
|
||||
#define _PSSWITCH_SEL_SHT 0
|
||||
|
||||
/*LPNAV_CTRL*/
|
||||
#define _LPNAV_EN BIT(31)
|
||||
#define _LPNAV_EARLY_MSK 0x7FFF0000
|
||||
#define _LPNAV_EARLY_SHT 16
|
||||
#define _LPNAV_TH_MSK 0x0000FFFF
|
||||
#define _LPNAV_TH_SHT 0
|
||||
|
||||
/*RPWM*/
|
||||
/*CPWM*/
|
||||
#define _TOGGLING BIT(7)
|
||||
#define _WWLAN BIT(3)
|
||||
#define _RPS_ST BIT(2)
|
||||
#define _WLAN_TRX BIT(1)
|
||||
#define _SYS_CLK BIT(0)
|
||||
|
||||
#endif /* __RTL8712_POWERSAVE_BITDEF_H__*/
|
20
drivers/staging/rtl8712/rtl8712_powersave_regdef.h
Normal file
20
drivers/staging/rtl8712/rtl8712_powersave_regdef.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef __RTL8712_POWERSAVE_REGDEF_H__
|
||||
#define __RTL8712_POWERSAVE_REGDEF_H__
|
||||
|
||||
#define WOWCTRL (RTL8712_POWERSAVE_ + 0x00)
|
||||
#define PSSTATUS (RTL8712_POWERSAVE_ + 0x01)
|
||||
#define PSSWITCH (RTL8712_POWERSAVE_ + 0x02)
|
||||
#define MIMOPS_WAITPERIOD (RTL8712_POWERSAVE_ + 0x03)
|
||||
#define LPNAV_CTRL (RTL8712_POWERSAVE_ + 0x04)
|
||||
#define WFM0 (RTL8712_POWERSAVE_ + 0x10)
|
||||
#define WFM1 (RTL8712_POWERSAVE_ + 0x20)
|
||||
#define WFM2 (RTL8712_POWERSAVE_ + 0x30)
|
||||
#define WFM3 (RTL8712_POWERSAVE_ + 0x40)
|
||||
#define WFM4 (RTL8712_POWERSAVE_ + 0x50)
|
||||
#define WFM5 (RTL8712_POWERSAVE_ + 0x60)
|
||||
#define WFCRC (RTL8712_POWERSAVE_ + 0x70)
|
||||
#define RPWM (RTL8712_POWERSAVE_ + 0x7C)
|
||||
#define CPWM (RTL8712_POWERSAVE_ + 0x7D)
|
||||
|
||||
#endif /* __RTL8712_POWERSAVE_REGDEF_H__ */
|
||||
|
30
drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h
Normal file
30
drivers/staging/rtl8712/rtl8712_ratectrl_bitdef.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __RTL8712_RATECTRL_BITDEF_H__
|
||||
#define __RTL8712_RATECTRL_BITDEF_H__
|
||||
|
||||
/*INIRTSMCS_SEL*/
|
||||
#define _INIRTSMCS_SEL_MSK 0x3F
|
||||
|
||||
/* RRSR*/
|
||||
#define _RRSR_SHORT BIT(23)
|
||||
#define _RRSR_RSC_MSK 0x600000
|
||||
#define _RRSR_RSC_SHT 21
|
||||
#define _RRSR_BITMAP_MSK 0x0FFFFF
|
||||
#define _RRSR_BITMAP_SHT 0
|
||||
|
||||
/* AGGLEN_LMT_H*/
|
||||
#define _AGGLMT_MCS32_MSK 0xF0
|
||||
#define _AGGLMT_MCS32_SHT 4
|
||||
#define _AGGLMT_MCS15_SGI_MSK 0x0F
|
||||
#define _AGGLMT_MCS15_SGI_SHT 0
|
||||
|
||||
/* DARFRC*/
|
||||
/* RARFRC*/
|
||||
/* MCS_TXAGC*/
|
||||
/* CCK_TXAGC*/
|
||||
#define _CCK_MSK 0xFF00
|
||||
#define _CCK_SHT 8
|
||||
#define _BARKER_MSK 0x00FF
|
||||
#define _BARKER_SHT 0
|
||||
|
||||
#endif /* __RTL8712_RATECTRL_BITDEF_H__*/
|
||||
|
31
drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h
Normal file
31
drivers/staging/rtl8712/rtl8712_ratectrl_regdef.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef __RTL8712_RATECTRL_REGDEF_H__
|
||||
#define __RTL8712_RATECTRL_REGDEF_H__
|
||||
|
||||
#define INIMCS_SEL (RTL8712_RATECTRL_ + 0x00)
|
||||
#define INIRTSMCS_SEL (RTL8712_RATECTRL_ + 0x20)
|
||||
#define RRSR (RTL8712_RATECTRL_ + 0x21)
|
||||
#define ARFR0 (RTL8712_RATECTRL_ + 0x24)
|
||||
#define ARFR1 (RTL8712_RATECTRL_ + 0x28)
|
||||
#define ARFR2 (RTL8712_RATECTRL_ + 0x2C)
|
||||
#define ARFR3 (RTL8712_RATECTRL_ + 0x30)
|
||||
#define ARFR4 (RTL8712_RATECTRL_ + 0x34)
|
||||
#define ARFR5 (RTL8712_RATECTRL_ + 0x38)
|
||||
#define ARFR6 (RTL8712_RATECTRL_ + 0x3C)
|
||||
#define ARFR7 (RTL8712_RATECTRL_ + 0x40)
|
||||
#define AGGLEN_LMT_H (RTL8712_RATECTRL_ + 0x47)
|
||||
#define AGGLEN_LMT_L (RTL8712_RATECTRL_ + 0x48)
|
||||
#define DARFRC (RTL8712_RATECTRL_ + 0x50)
|
||||
#define RARFRC (RTL8712_RATECTRL_ + 0x58)
|
||||
#define MCS_TXAGC0 (RTL8712_RATECTRL_ + 0x60)
|
||||
#define MCS_TXAGC1 (RTL8712_RATECTRL_ + 0x61)
|
||||
#define MCS_TXAGC2 (RTL8712_RATECTRL_ + 0x62)
|
||||
#define MCS_TXAGC3 (RTL8712_RATECTRL_ + 0x63)
|
||||
#define MCS_TXAGC4 (RTL8712_RATECTRL_ + 0x64)
|
||||
#define MCS_TXAGC5 (RTL8712_RATECTRL_ + 0x65)
|
||||
#define MCS_TXAGC6 (RTL8712_RATECTRL_ + 0x66)
|
||||
#define MCS_TXAGC7 (RTL8712_RATECTRL_ + 0x67)
|
||||
#define CCK_TXAGC (RTL8712_RATECTRL_ + 0x68)
|
||||
|
||||
|
||||
#endif /*__RTL8712_RATECTRL_REGDEF_H__*/
|
||||
|
1145
drivers/staging/rtl8712/rtl8712_recv.c
Normal file
1145
drivers/staging/rtl8712/rtl8712_recv.c
Normal file
File diff suppressed because it is too large
Load Diff
128
drivers/staging/rtl8712/rtl8712_recv.h
Normal file
128
drivers/staging/rtl8712/rtl8712_recv.h
Normal file
@ -0,0 +1,128 @@
|
||||
#ifndef _RTL8712_RECV_H_
|
||||
#define _RTL8712_RECV_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
|
||||
#define NR_RECVBUFF (8)
|
||||
#define NR_PREALLOC_RECV_SKB (8)
|
||||
#define RXDESC_SIZE 24
|
||||
#define RXDESC_OFFSET RXDESC_SIZE
|
||||
#define RECV_BLK_SZ 512
|
||||
#define RECV_BLK_CNT 16
|
||||
#define RECV_BLK_TH RECV_BLK_CNT
|
||||
#define MAX_RECVBUF_SZ (30720) /* 30K */
|
||||
#define RECVBUFF_ALIGN_SZ 512
|
||||
#define RSVD_ROOM_SZ (0)
|
||||
/*These definition is used for Rx packet reordering.*/
|
||||
#define SN_LESS(a, b) (((a-b) & 0x800) != 0)
|
||||
#define SN_EQUAL(a, b) (a == b)
|
||||
#define REORDER_WAIT_TIME 30 /* (ms)*/
|
||||
|
||||
struct recv_stat {
|
||||
unsigned int rxdw0;
|
||||
unsigned int rxdw1;
|
||||
unsigned int rxdw2;
|
||||
unsigned int rxdw3;
|
||||
unsigned int rxdw4;
|
||||
unsigned int rxdw5;
|
||||
};
|
||||
|
||||
struct phy_cck_rx_status {
|
||||
/* For CCK rate descriptor. This is a unsigned 8:1 variable.
|
||||
* LSB bit present 0.5. And MSB 7 bts present a signed value.
|
||||
* Range from -64~+63.5. */
|
||||
u8 adc_pwdb_X[4];
|
||||
u8 sq_rpt;
|
||||
u8 cck_agc_rpt;
|
||||
};
|
||||
|
||||
struct phy_stat {
|
||||
unsigned int phydw0;
|
||||
unsigned int phydw1;
|
||||
unsigned int phydw2;
|
||||
unsigned int phydw3;
|
||||
unsigned int phydw4;
|
||||
unsigned int phydw5;
|
||||
unsigned int phydw6;
|
||||
unsigned int phydw7;
|
||||
};
|
||||
#define PHY_STAT_GAIN_TRSW_SHT 0
|
||||
#define PHY_STAT_PWDB_ALL_SHT 4
|
||||
#define PHY_STAT_CFOSHO_SHT 5
|
||||
#define PHY_STAT_CCK_AGC_RPT_SHT 5
|
||||
#define PHY_STAT_CFOTAIL_SHT 9
|
||||
#define PHY_STAT_RXEVM_SHT 13
|
||||
#define PHY_STAT_RXSNR_SHT 15
|
||||
#define PHY_STAT_PDSNR_SHT 19
|
||||
#define PHY_STAT_CSI_CURRENT_SHT 21
|
||||
#define PHY_STAT_CSI_TARGET_SHT 23
|
||||
#define PHY_STAT_SIGEVM_SHT 25
|
||||
#define PHY_STAT_MAX_EX_PWR_SHT 26
|
||||
|
||||
union recvstat {
|
||||
struct recv_stat recv_stat;
|
||||
unsigned int value[RXDESC_SIZE>>2];
|
||||
};
|
||||
|
||||
|
||||
struct recv_buf {
|
||||
struct list_head list;
|
||||
spinlock_t recvbuf_lock;
|
||||
u32 ref_cnt;
|
||||
struct _adapter *adapter;
|
||||
struct urb *purb;
|
||||
_pkt *pskb;
|
||||
u8 reuse;
|
||||
u8 irp_pending;
|
||||
u32 transfer_len;
|
||||
uint len;
|
||||
u8 *phead;
|
||||
u8 *pdata;
|
||||
u8 *ptail;
|
||||
u8 *pend;
|
||||
u8 *pbuf;
|
||||
u8 *pallocated_buf;
|
||||
};
|
||||
|
||||
/*
|
||||
head ----->
|
||||
data ----->
|
||||
payload
|
||||
tail ----->
|
||||
end ----->
|
||||
len = (unsigned int )(tail - data);
|
||||
*/
|
||||
struct recv_frame_hdr{
|
||||
struct list_head list;
|
||||
_pkt *pkt;
|
||||
_pkt *pkt_newalloc;
|
||||
struct _adapter *adapter;
|
||||
u8 fragcnt;
|
||||
struct rx_pkt_attrib attrib;
|
||||
uint len;
|
||||
u8 *rx_head;
|
||||
u8 *rx_data;
|
||||
u8 *rx_tail;
|
||||
u8 *rx_end;
|
||||
void *precvbuf;
|
||||
struct sta_info *psta;
|
||||
/*for A-MPDU Rx reordering buffer control*/
|
||||
struct recv_reorder_ctrl *preorder_ctrl;
|
||||
};
|
||||
|
||||
union recv_frame {
|
||||
union {
|
||||
struct list_head list;
|
||||
struct recv_frame_hdr hdr;
|
||||
addr_t mem[RECVFRAME_HDR_ALIGN>>2];
|
||||
} u;
|
||||
};
|
||||
|
||||
int r8712_init_recvbuf(struct _adapter *padapter, struct recv_buf *precvbuf);
|
||||
void r8712_rxcmd_event_hdl(struct _adapter *padapter, void *prxcmdbuf);
|
||||
s32 r8712_signal_scale_mapping(s32 cur_sig);
|
||||
void r8712_reordering_ctrl_timeout_handler(void *pcontext);
|
||||
|
||||
#endif
|
||||
|
19
drivers/staging/rtl8712/rtl8712_regdef.h
Normal file
19
drivers/staging/rtl8712/rtl8712_regdef.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef __RTL8712_REGDEF_H__
|
||||
#define __RTL8712_REGDEF_H__
|
||||
|
||||
#include "rtl8712_syscfg_regdef.h"
|
||||
#include "rtl8712_cmdctrl_regdef.h"
|
||||
#include "rtl8712_macsetting_regdef.h"
|
||||
#include "rtl8712_timectrl_regdef.h"
|
||||
#include "rtl8712_fifoctrl_regdef.h"
|
||||
#include "rtl8712_ratectrl_regdef.h"
|
||||
#include "rtl8712_edcasetting_regdef.h"
|
||||
#include "rtl8712_wmac_regdef.h"
|
||||
#include "rtl8712_powersave_regdef.h"
|
||||
#include "rtl8712_gp_regdef.h"
|
||||
#include "rtl8712_debugctrl_regdef.h"
|
||||
|
||||
#define HIMR (RTL8712_INTERRUPT_ + 0x08)
|
||||
|
||||
#endif /* __RTL8712_REGDEF_H__*/
|
||||
|
29
drivers/staging/rtl8712/rtl8712_security_bitdef.h
Normal file
29
drivers/staging/rtl8712/rtl8712_security_bitdef.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef __RTL8712_SECURITY_BITDEF_H__
|
||||
#define __RTL8712_SECURITY_BITDEF_H__
|
||||
|
||||
/*CAMCMD*/
|
||||
#define _SECCAM_POLLING BIT(31)
|
||||
#define _SECCAM_CLR BIT(30)
|
||||
#define _SECCAM_WE BIT(16)
|
||||
#define _SECCAM_ADR_MSK 0x000000FF
|
||||
#define _SECCAM_ADR_SHT 0
|
||||
|
||||
/*CAMDBG*/
|
||||
#define _SECCAM_INFO BIT(31)
|
||||
#define _SEC_KEYFOUND BIT(30)
|
||||
#define _SEC_CONFIG_MSK 0x3F000000
|
||||
#define _SEC_CONFIG_SHT 24
|
||||
#define _SEC_KEYCONTENT_MSK 0x00FFFFFF
|
||||
#define _SEC_KEYCONTENT_SHT 0
|
||||
|
||||
/*SECCFG*/
|
||||
#define _NOSKMC BIT(5)
|
||||
#define _SKBYA2 BIT(4)
|
||||
#define _RXDEC BIT(3)
|
||||
#define _TXENC BIT(2)
|
||||
#define _RXUSEDK BIT(1)
|
||||
#define _TXUSEDK BIT(0)
|
||||
|
||||
|
||||
#endif /*__RTL8712_SECURITY_BITDEF_H__*/
|
||||
|
110
drivers/staging/rtl8712/rtl8712_spec.h
Normal file
110
drivers/staging/rtl8712/rtl8712_spec.h
Normal file
@ -0,0 +1,110 @@
|
||||
#ifndef __RTL8712_SPEC_H__
|
||||
#define __RTL8712_SPEC_H__
|
||||
|
||||
#define RTL8712_IOBASE_TXPKT 0x10200000 /*IOBASE_TXPKT*/
|
||||
#define RTL8712_IOBASE_RXPKT 0x10210000 /*IOBASE_RXPKT*/
|
||||
#define RTL8712_IOBASE_RXCMD 0x10220000 /*IOBASE_RXCMD*/
|
||||
#define RTL8712_IOBASE_TXSTATUS 0x10230000 /*IOBASE_TXSTATUS*/
|
||||
#define RTL8712_IOBASE_RXSTATUS 0x10240000 /*IOBASE_RXSTATUS*/
|
||||
#define RTL8712_IOBASE_IOREG 0x10250000 /*IOBASE_IOREG ADDR*/
|
||||
#define RTL8712_IOBASE_SCHEDULER 0x10260000 /*IOBASE_SCHEDULE*/
|
||||
|
||||
#define RTL8712_IOBASE_TRXDMA 0x10270000 /*IOBASE_TRXDMA*/
|
||||
#define RTL8712_IOBASE_TXLLT 0x10280000 /*IOBASE_TXLLT*/
|
||||
#define RTL8712_IOBASE_WMAC 0x10290000 /*IOBASE_WMAC*/
|
||||
#define RTL8712_IOBASE_FW2HW 0x102A0000 /*IOBASE_FW2HW*/
|
||||
#define RTL8712_IOBASE_ACCESS_PHYREG 0x102B0000 /*IOBASE_ACCESS_PHYREG*/
|
||||
|
||||
#define RTL8712_IOBASE_FF 0x10300000 /*IOBASE_FIFO 0x1031000~0x103AFFFF*/
|
||||
|
||||
|
||||
/*IOREG Offset for 8712*/
|
||||
#define RTL8712_SYSCFG_ RTL8712_IOBASE_IOREG
|
||||
#define RTL8712_CMDCTRL_ (RTL8712_IOBASE_IOREG + 0x40)
|
||||
#define RTL8712_MACIDSETTING_ (RTL8712_IOBASE_IOREG + 0x50)
|
||||
#define RTL8712_TIMECTRL_ (RTL8712_IOBASE_IOREG + 0x80)
|
||||
#define RTL8712_FIFOCTRL_ (RTL8712_IOBASE_IOREG + 0xA0)
|
||||
#define RTL8712_RATECTRL_ (RTL8712_IOBASE_IOREG + 0x160)
|
||||
#define RTL8712_EDCASETTING_ (RTL8712_IOBASE_IOREG + 0x1D0)
|
||||
#define RTL8712_WMAC_ (RTL8712_IOBASE_IOREG + 0x200)
|
||||
#define RTL8712_SECURITY_ (RTL8712_IOBASE_IOREG + 0x240)
|
||||
#define RTL8712_POWERSAVE_ (RTL8712_IOBASE_IOREG + 0x260)
|
||||
#define RTL8712_GP_ (RTL8712_IOBASE_IOREG + 0x2E0)
|
||||
#define RTL8712_INTERRUPT_ (RTL8712_IOBASE_IOREG + 0x300)
|
||||
#define RTL8712_DEBUGCTRL_ (RTL8712_IOBASE_IOREG + 0x310)
|
||||
#define RTL8712_OFFLOAD_ (RTL8712_IOBASE_IOREG + 0x2D0)
|
||||
|
||||
|
||||
/*FIFO for 8712*/
|
||||
#define RTL8712_DMA_BCNQ (RTL8712_IOBASE_FF + 0x10000)
|
||||
#define RTL8712_DMA_MGTQ (RTL8712_IOBASE_FF + 0x20000)
|
||||
#define RTL8712_DMA_BMCQ (RTL8712_IOBASE_FF + 0x30000)
|
||||
#define RTL8712_DMA_VOQ (RTL8712_IOBASE_FF + 0x40000)
|
||||
#define RTL8712_DMA_VIQ (RTL8712_IOBASE_FF + 0x50000)
|
||||
#define RTL8712_DMA_BEQ (RTL8712_IOBASE_FF + 0x60000)
|
||||
#define RTL8712_DMA_BKQ (RTL8712_IOBASE_FF + 0x70000)
|
||||
#define RTL8712_DMA_RX0FF (RTL8712_IOBASE_FF + 0x80000)
|
||||
#define RTL8712_DMA_H2CCMD (RTL8712_IOBASE_FF + 0x90000)
|
||||
#define RTL8712_DMA_C2HCMD (RTL8712_IOBASE_FF + 0xA0000)
|
||||
|
||||
|
||||
/*------------------------------*/
|
||||
|
||||
/*BIT 16 15*/
|
||||
#define DID_SDIO_LOCAL 0 /* 0 0*/
|
||||
#define DID_WLAN_IOREG 1 /* 0 1*/
|
||||
#define DID_WLAN_FIFO 3 /* 1 1*/
|
||||
#define DID_UNDEFINE (-1)
|
||||
|
||||
#define CMD_ADDR_MAPPING_SHIFT 2 /*SDIO CMD ADDR MAPPING,
|
||||
*shift 2 bit for match
|
||||
* offset[14:2]*/
|
||||
|
||||
/*Offset for SDIO LOCAL*/
|
||||
#define OFFSET_SDIO_LOCAL 0x0FFF
|
||||
|
||||
/*Offset for WLAN IOREG*/
|
||||
#define OFFSET_WLAN_IOREG 0x0FFF
|
||||
|
||||
/*Offset for WLAN FIFO*/
|
||||
#define OFFSET_TX_BCNQ 0x0300
|
||||
#define OFFSET_TX_HIQ 0x0310
|
||||
#define OFFSET_TX_CMDQ 0x0320
|
||||
#define OFFSET_TX_MGTQ 0x0330
|
||||
#define OFFSET_TX_HCCAQ 0x0340
|
||||
#define OFFSET_TX_VOQ 0x0350
|
||||
#define OFFSET_TX_VIQ 0x0360
|
||||
#define OFFSET_TX_BEQ 0x0370
|
||||
#define OFFSET_TX_BKQ 0x0380
|
||||
#define OFFSET_RX_RX0FFQ 0x0390
|
||||
#define OFFSET_RX_C2HFFQ 0x03A0
|
||||
|
||||
#define BK_QID_01 1
|
||||
#define BK_QID_02 2
|
||||
#define BE_QID_01 0
|
||||
#define BE_QID_02 3
|
||||
#define VI_QID_01 4
|
||||
#define VI_QID_02 5
|
||||
#define VO_QID_01 6
|
||||
#define VO_QID_02 7
|
||||
#define HCCA_QID_01 8
|
||||
#define HCCA_QID_02 9
|
||||
#define HCCA_QID_03 10
|
||||
#define HCCA_QID_04 11
|
||||
#define HCCA_QID_05 12
|
||||
#define HCCA_QID_06 13
|
||||
#define HCCA_QID_07 14
|
||||
#define HCCA_QID_08 15
|
||||
#define HI_QID 17
|
||||
#define CMD_QID 19
|
||||
#define MGT_QID 18
|
||||
#define BCN_QID 16
|
||||
|
||||
#include "rtl8712_regdef.h"
|
||||
|
||||
#include "rtl8712_bitdef.h"
|
||||
|
||||
#include "basic_types.h"
|
||||
|
||||
#endif /* __RTL8712_SPEC_H__ */
|
||||
|
145
drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h
Normal file
145
drivers/staging/rtl8712/rtl8712_syscfg_bitdef.h
Normal file
@ -0,0 +1,145 @@
|
||||
#ifndef __RTL8712_SYSCFG_BITDEF_H__
|
||||
#define __RTL8712_SYSCFG_BITDEF_H__
|
||||
|
||||
/*SYS_PWR_CTRL*/
|
||||
/*SRCTRL0*/
|
||||
/*SRCTRL1*/
|
||||
/*SYS_CLKR*/
|
||||
|
||||
/*SYS_IOS_CTRL*/
|
||||
#define iso_LDR2RP_SHT 8 /* EE Loader to Retention Path*/
|
||||
#define iso_LDR2RP BIT(iso_LDR2RP_SHT) /* 1:isolation, 0:attach*/
|
||||
|
||||
/*SYS_CTRL*/
|
||||
#define FEN_DIO_SDIO_SHT 0
|
||||
#define FEN_DIO_SDIO BIT(FEN_DIO_SDIO_SHT)
|
||||
#define FEN_SDIO_SHT 1
|
||||
#define FEN_SDIO BIT(FEN_SDIO_SHT)
|
||||
#define FEN_USBA_SHT 2
|
||||
#define FEN_USBA BIT(FEN_USBA_SHT)
|
||||
#define FEN_UPLL_SHT 3
|
||||
#define FEN_UPLL BIT(FEN_UPLL_SHT)
|
||||
#define FEN_USBD_SHT 4
|
||||
#define FEN_USBD BIT(FEN_USBD_SHT)
|
||||
#define FEN_DIO_PCIE_SHT 5
|
||||
#define FEN_DIO_PCIE BIT(FEN_DIO_PCIE_SHT)
|
||||
#define FEN_PCIEA_SHT 6
|
||||
#define FEN_PCIEA BIT(FEN_PCIEA_SHT)
|
||||
#define FEN_PPLL_SHT 7
|
||||
#define FEN_PPLL BIT(FEN_PPLL_SHT)
|
||||
#define FEN_PCIED_SHT 8
|
||||
#define FEN_PCIED BIT(FEN_PCIED_SHT)
|
||||
#define FEN_CPUEN_SHT 10
|
||||
#define FEN_CPUEN BIT(FEN_CPUEN_SHT)
|
||||
#define FEN_DCORE_SHT 11
|
||||
#define FEN_DCORE BIT(FEN_DCORE_SHT)
|
||||
#define FEN_ELDR_SHT 12
|
||||
#define FEN_ELDR BIT(FEN_ELDR_SHT)
|
||||
#define PWC_DV2LDR_SHT 13
|
||||
#define PWC_DV2LDR BIT(PWC_DV2LDR_SHT) /* Loader Power Enable*/
|
||||
|
||||
/*=== SYS_CLKR ===*/
|
||||
#define SYS_CLKSEL_SHT 0
|
||||
#define SYS_CLKSEL BIT(SYS_CLKSEL_SHT) /* System Clock 80MHz*/
|
||||
#define PS_CLKSEL_SHT 1
|
||||
#define PS_CLKSEL BIT(PS_CLKSEL_SHT) /*System power save
|
||||
* clock select.*/
|
||||
#define CPU_CLKSEL_SHT 2
|
||||
#define CPU_CLKSEL BIT(CPU_CLKSEL_SHT) /* System Clock select,
|
||||
* 1: AFE source,
|
||||
* 0: System clock(L-Bus)*/
|
||||
#define INT32K_EN_SHT 3
|
||||
#define INT32K_EN BIT(INT32K_EN_SHT)
|
||||
#define MACSLP_SHT 4
|
||||
#define MACSLP BIT(MACSLP_SHT)
|
||||
#define MAC_CLK_EN_SHT 11
|
||||
#define MAC_CLK_EN BIT(MAC_CLK_EN_SHT) /* MAC Clock Enable.*/
|
||||
#define SYS_CLK_EN_SHT 12
|
||||
#define SYS_CLK_EN BIT(SYS_CLK_EN_SHT)
|
||||
#define RING_CLK_EN_SHT 13
|
||||
#define RING_CLK_EN BIT(RING_CLK_EN_SHT)
|
||||
#define SWHW_SEL_SHT 14
|
||||
#define SWHW_SEL BIT(SWHW_SEL_SHT) /* Load done,
|
||||
* control path switch.*/
|
||||
#define FWHW_SEL_SHT 15
|
||||
#define FWHW_SEL BIT(FWHW_SEL_SHT) /* Sleep exit,
|
||||
* control path switch.*/
|
||||
|
||||
/*9346CR*/
|
||||
#define _VPDIDX_MSK 0xFF00
|
||||
#define _VPDIDX_SHT 8
|
||||
#define _EEM_MSK 0x00C0
|
||||
#define _EEM_SHT 6
|
||||
#define _EEM0 BIT(6)
|
||||
#define _EEM1 BIT(7)
|
||||
#define _EEPROM_EN BIT(5)
|
||||
#define _9356SEL BIT(4)
|
||||
#define _EECS BIT(3)
|
||||
#define _EESK BIT(2)
|
||||
#define _EEDI BIT(1)
|
||||
#define _EEDO BIT(0)
|
||||
|
||||
/*AFE_MISC*/
|
||||
#define AFE_MISC_USB_MBEN_SHT 7
|
||||
#define AFE_MISC_USB_MBEN BIT(AFE_MISC_USB_MBEN_SHT)
|
||||
#define AFE_MISC_USB_BGEN_SHT 6
|
||||
#define AFE_MISC_USB_BGEN BIT(AFE_MISC_USB_BGEN_SHT)
|
||||
#define AFE_MISC_LD12_VDAJ_SHT 4
|
||||
#define AFE_MISC_LD12_VDAJ_MSK 0X0030
|
||||
#define AFE_MISC_LD12_VDAJ BIT(AFE_MISC_LD12_VDAJ_SHT)
|
||||
#define AFE_MISC_I32_EN_SHT 3
|
||||
#define AFE_MISC_I32_EN BIT(AFE_MISC_I32_EN_SHT)
|
||||
#define AFE_MISC_E32_EN_SHT 2
|
||||
#define AFE_MISC_E32_EN BIT(AFE_MISC_E32_EN_SHT)
|
||||
#define AFE_MISC_MBEN_SHT 1
|
||||
#define AFE_MISC_MBEN BIT(AFE_MISC_MBEN_SHT)/* Enable AFE Macro
|
||||
* Block's Mbias.*/
|
||||
#define AFE_MISC_BGEN_SHT 0
|
||||
#define AFE_MISC_BGEN BIT(AFE_MISC_BGEN_SHT)/* Enable AFE Macro
|
||||
* Block's Bandgap.*/
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* SPS1_CTRL bits (Offset 0x18-1E, 56bits)*/
|
||||
/*--------------------------------------------------------------------------*/
|
||||
#define SPS1_SWEN BIT(1) /* Enable vsps18 SW Macro Block.*/
|
||||
#define SPS1_LDEN BIT(0) /* Enable VSPS12 LDO Macro block.*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* LDOA15_CTRL bits (Offset 0x20, 8bits)*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#define LDA15_EN BIT(0) /* Enable LDOA15 Macro Block*/
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* 8192S LDOV12D_CTRL bit (Offset 0x21, 8bits)*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
#define LDV12_EN BIT(0) /* Enable LDOVD12 Macro Block*/
|
||||
#define LDV12_SDBY BIT(1) /* LDOVD12 standby mode*/
|
||||
|
||||
/*CLK_PS_CTRL*/
|
||||
#define _CLK_GATE_EN BIT(0)
|
||||
|
||||
|
||||
/* EFUSE_CTRL*/
|
||||
#define EF_FLAG BIT(31) /* Access Flag, Write:1;
|
||||
* Read:0*/
|
||||
#define EF_PGPD 0x70000000 /* E-fuse Program time*/
|
||||
#define EF_RDT 0x0F000000 /* E-fuse read time: in the
|
||||
* unit of cycle time*/
|
||||
#define EF_PDN_EN BIT(19) /* EFuse Power down enable*/
|
||||
#define ALD_EN BIT(18) /* Autoload Enable*/
|
||||
#define EF_ADDR 0x0003FF00 /* Access Address*/
|
||||
#define EF_DATA 0x000000FF /* Access Data*/
|
||||
|
||||
/* EFUSE_TEST*/
|
||||
#define LDOE25_EN BIT(31) /* Enable LDOE25 Macro Block*/
|
||||
|
||||
/* EFUSE_CLK_CTRL*/
|
||||
#define EFUSE_CLK_EN BIT(1) /* E-Fuse Clock Enable*/
|
||||
#define EFUSE_CLK_SEL BIT(0) /* E-Fuse Clock Select,
|
||||
* 0:500K, 1:40M*/
|
||||
|
||||
#endif /*__RTL8712_SYSCFG_BITDEF_H__*/
|
||||
|
31
drivers/staging/rtl8712/rtl8712_syscfg_regdef.h
Normal file
31
drivers/staging/rtl8712/rtl8712_syscfg_regdef.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef __RTL8712_SYSCFG_REGDEF_H__
|
||||
#define __RTL8712_SYSCFG_REGDEF_H__
|
||||
|
||||
|
||||
#define SYS_ISO_CTRL (RTL8712_SYSCFG_ + 0x0000)
|
||||
#define SYS_FUNC_EN (RTL8712_SYSCFG_ + 0x0002)
|
||||
#define PMC_FSM (RTL8712_SYSCFG_ + 0x0004)
|
||||
#define SYS_CLKR (RTL8712_SYSCFG_ + 0x0008)
|
||||
#define EE_9346CR (RTL8712_SYSCFG_ + 0x000A)
|
||||
#define EE_VPD (RTL8712_SYSCFG_ + 0x000C)
|
||||
#define AFE_MISC (RTL8712_SYSCFG_ + 0x0010)
|
||||
#define SPS0_CTRL (RTL8712_SYSCFG_ + 0x0011)
|
||||
#define SPS1_CTRL (RTL8712_SYSCFG_ + 0x0018)
|
||||
#define RF_CTRL (RTL8712_SYSCFG_ + 0x001F)
|
||||
#define LDOA15_CTRL (RTL8712_SYSCFG_ + 0x0020)
|
||||
#define LDOV12D_CTRL (RTL8712_SYSCFG_ + 0x0021)
|
||||
#define LDOHCI12_CTRL (RTL8712_SYSCFG_ + 0x0022)
|
||||
#define LDO_USB_CTRL (RTL8712_SYSCFG_ + 0x0023)
|
||||
#define LPLDO_CTRL (RTL8712_SYSCFG_ + 0x0024)
|
||||
#define AFE_XTAL_CTRL (RTL8712_SYSCFG_ + 0x0026)
|
||||
#define AFE_PLL_CTRL (RTL8712_SYSCFG_ + 0x0028)
|
||||
#define EFUSE_CTRL (RTL8712_SYSCFG_ + 0x0030)
|
||||
#define EFUSE_TEST (RTL8712_SYSCFG_ + 0x0034)
|
||||
#define PWR_DATA (RTL8712_SYSCFG_ + 0x0038)
|
||||
#define DPS_TIMER (RTL8712_SYSCFG_ + 0x003C)
|
||||
#define RCLK_MON (RTL8712_SYSCFG_ + 0x003E)
|
||||
#define EFUSE_CLK_CTRL (RTL8712_SYSCFG_ + 0x02F8)
|
||||
|
||||
|
||||
#endif /*__RTL8712_SYSCFG_REGDEF_H__*/
|
||||
|
44
drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h
Normal file
44
drivers/staging/rtl8712/rtl8712_timectrl_bitdef.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef __RTL8712_TIMECTRL_BITDEF_H__
|
||||
#define __RTL8712_TIMECTRL_BITDEF_H__
|
||||
|
||||
/*TSFTR*/
|
||||
/*SLOT*/
|
||||
/*USTIME*/
|
||||
|
||||
/*TUBASE*/
|
||||
#define _TUBASE_MSK 0x07FF
|
||||
|
||||
/*SIFS_CCK*/
|
||||
#define _SIFS_CCK_TRX_MSK 0xFF00
|
||||
#define _SIFS_CCK_TRX_SHT 0x8
|
||||
#define _SIFS_CCK_CTX_MSK 0x00FF
|
||||
#define _SIFS_CCK_CTX_SHT 0
|
||||
|
||||
/*SIFS_OFDM*/
|
||||
#define _SIFS_OFDM_TRX_MSK 0xFF00
|
||||
#define _SIFS_OFDM_TRX_SHT 0x8
|
||||
#define _SIFS_OFDM_CTX_MSK 0x00FF
|
||||
#define _SIFS_OFDM_CTX_SHT 0
|
||||
|
||||
/*PIFS*/
|
||||
/*ACKTO*/
|
||||
/*EIFS*/
|
||||
/*BCNITV*/
|
||||
/*ATIMWND*/
|
||||
|
||||
/*DRVERLYINT*/
|
||||
#define _ENSWBCN BIT(15)
|
||||
#define _DRVERLY_TU_MSK 0x0FF0
|
||||
#define _DRVERLY_TU_SHT 4
|
||||
#define _DRVERLY_US_MSK 0x000F
|
||||
#define _DRVERLY_US_SHT 0
|
||||
|
||||
/*BCNDMATIM*/
|
||||
#define _BCNDMATIM_MSK 0x03FF
|
||||
|
||||
/*BCNERRTH*/
|
||||
/*MLT*/
|
||||
|
||||
|
||||
#endif /* __RTL8712_TIMECTRL_BITDEF_H__*/
|
||||
|
20
drivers/staging/rtl8712/rtl8712_timectrl_regdef.h
Normal file
20
drivers/staging/rtl8712/rtl8712_timectrl_regdef.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef __RTL8712_TIMECTRL_REGDEF_H__
|
||||
#define __RTL8712_TIMECTRL_REGDEF_H__
|
||||
|
||||
#define TSFTR (RTL8712_TIMECTRL_ + 0x00)
|
||||
#define USTIME (RTL8712_TIMECTRL_ + 0x08)
|
||||
#define SLOT (RTL8712_TIMECTRL_ + 0x09)
|
||||
#define TUBASE (RTL8712_TIMECTRL_ + 0x0A)
|
||||
#define SIFS_CCK (RTL8712_TIMECTRL_ + 0x0C)
|
||||
#define SIFS_OFDM (RTL8712_TIMECTRL_ + 0x0E)
|
||||
#define PIFS (RTL8712_TIMECTRL_ + 0x10)
|
||||
#define ACKTO (RTL8712_TIMECTRL_ + 0x11)
|
||||
#define EIFS (RTL8712_TIMECTRL_ + 0x12)
|
||||
#define BCNITV (RTL8712_TIMECTRL_ + 0x14)
|
||||
#define ATIMWND (RTL8712_TIMECTRL_ + 0x16)
|
||||
#define DRVERLYINT (RTL8712_TIMECTRL_ + 0x18)
|
||||
#define BCNDMATIM (RTL8712_TIMECTRL_ + 0x1A)
|
||||
#define BCNERRTH (RTL8712_TIMECTRL_ + 0x1C)
|
||||
#define MLT (RTL8712_TIMECTRL_ + 0x1D)
|
||||
|
||||
#endif /* __RTL8712_TIMECTRL_REGDEF_H__ */
|
37
drivers/staging/rtl8712/rtl8712_wmac_bitdef.h
Normal file
37
drivers/staging/rtl8712/rtl8712_wmac_bitdef.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef __RTL8712_WMAC_BITDEF_H__
|
||||
#define __RTL8712_WMAC_BITDEF_H__
|
||||
|
||||
/*NAVCTRL*/
|
||||
#define _NAV_UPPER_EN BIT(18)
|
||||
#define _NAV_MTO_EN BIT(17)
|
||||
#define _NAV_UPPER BIT(16)
|
||||
#define _NAV_MTO_MSK 0xFF00
|
||||
#define _NAV_MTO_SHT 8
|
||||
#define _RTSRST_MSK 0x00FF
|
||||
#define _RTSRST_SHT 0
|
||||
|
||||
/*BWOPMODE*/
|
||||
#define _20MHZBW BIT(2)
|
||||
|
||||
/*BACAMCMD*/
|
||||
#define _BACAM_POLL BIT(31)
|
||||
#define _BACAM_RST BIT(17)
|
||||
#define _BACAM_RW BIT(16)
|
||||
#define _BACAM_ADDR_MSK 0x0000007F
|
||||
#define _BACAM_ADDR_SHT 0
|
||||
|
||||
/*LBDLY*/
|
||||
#define _LBDLY_MSK 0x1F
|
||||
|
||||
/*FWDLY*/
|
||||
#define _FWDLY_MSK 0x0F
|
||||
|
||||
/*RXERR_RPT*/
|
||||
#define _RXERR_RPT_SEL_MSK 0xF0000000
|
||||
#define _RXERR_RPT_SEL_SHT 28
|
||||
#define _RPT_CNT_MSK 0x000FFFFF
|
||||
#define _RPT_CNT_SHT 0
|
||||
|
||||
|
||||
#endif /*__RTL8712_WMAC_BITDEF_H__*/
|
||||
|
24
drivers/staging/rtl8712/rtl8712_wmac_regdef.h
Normal file
24
drivers/staging/rtl8712/rtl8712_wmac_regdef.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef __RTL8712_WMAC_REGDEF_H__
|
||||
#define __RTL8712_WMAC_REGDEF_H__
|
||||
|
||||
#define NAVCTRL (RTL8712_WMAC_ + 0x00)
|
||||
#define BWOPMODE (RTL8712_WMAC_ + 0x03)
|
||||
#define BACAMCMD (RTL8712_WMAC_ + 0x04)
|
||||
#define BACAMCONTENT (RTL8712_WMAC_ + 0x08)
|
||||
#define LBDLY (RTL8712_WMAC_ + 0x10)
|
||||
#define FWDLY (RTL8712_WMAC_ + 0x11)
|
||||
#define HWPC_RX_CTRL (RTL8712_WMAC_ + 0x18)
|
||||
#define MQ (RTL8712_WMAC_ + 0x20)
|
||||
#define MA (RTL8712_WMAC_ + 0x22)
|
||||
#define MS (RTL8712_WMAC_ + 0x24)
|
||||
#define CLM_RESULT (RTL8712_WMAC_ + 0x27)
|
||||
#define NHM_RPI_CNT (RTL8712_WMAC_ + 0x28)
|
||||
#define RXERR_RPT (RTL8712_WMAC_ + 0x30)
|
||||
#define NAV_PROT_LEN (RTL8712_WMAC_ + 0x34)
|
||||
#define CFEND_TH (RTL8712_WMAC_ + 0x36)
|
||||
#define AMPDU_MIN_SPACE (RTL8712_WMAC_ + 0x37)
|
||||
#define TXOP_STALL_CTRL (RTL8712_WMAC_ + 0x38)
|
||||
|
||||
|
||||
#endif /*__RTL8712_WMAC_REGDEF_H__*/
|
||||
|
509
drivers/staging/rtl8712/rtl8712_xmit.c
Normal file
509
drivers/staging/rtl8712/rtl8712_xmit.c
Normal file
@ -0,0 +1,509 @@
|
||||
/******************************************************************************
|
||||
* rtl8712_xmit.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_XMIT_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "rtl871x_byteorder.h"
|
||||
#include "wifi.h"
|
||||
#include "osdep_intf.h"
|
||||
#include "usb_ops.h"
|
||||
|
||||
static void dump_xframe(struct _adapter *padapter,
|
||||
struct xmit_frame *pxmitframe);
|
||||
|
||||
sint _r8712_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag)
|
||||
{
|
||||
phw_txqueue->ac_tag = ac_tag;
|
||||
switch (ac_tag) {
|
||||
case BE_QUEUE_INX:
|
||||
phw_txqueue->ff_hwaddr = RTL8712_DMA_BEQ;
|
||||
break;
|
||||
case BK_QUEUE_INX:
|
||||
phw_txqueue->ff_hwaddr = RTL8712_DMA_BKQ;
|
||||
break;
|
||||
case VI_QUEUE_INX:
|
||||
phw_txqueue->ff_hwaddr = RTL8712_DMA_VIQ;
|
||||
break;
|
||||
case VO_QUEUE_INX:
|
||||
phw_txqueue->ff_hwaddr = RTL8712_DMA_VOQ;
|
||||
break;
|
||||
case BMC_QUEUE_INX:
|
||||
phw_txqueue->ff_hwaddr = RTL8712_DMA_BEQ;
|
||||
break;
|
||||
}
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
int r8712_txframes_sta_ac_pending(struct _adapter *padapter,
|
||||
struct pkt_attrib *pattrib)
|
||||
{
|
||||
struct sta_info *psta;
|
||||
struct tx_servq *ptxservq;
|
||||
int priority = pattrib->priority;
|
||||
|
||||
psta = pattrib->psta;
|
||||
switch (priority) {
|
||||
case 1:
|
||||
case 2:
|
||||
ptxservq = &(psta->sta_xmitpriv.bk_q);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
ptxservq = &(psta->sta_xmitpriv.vi_q);
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
ptxservq = &(psta->sta_xmitpriv.vo_q);
|
||||
break;
|
||||
case 0:
|
||||
case 3:
|
||||
default:
|
||||
ptxservq = &(psta->sta_xmitpriv.be_q);
|
||||
break;
|
||||
}
|
||||
return ptxservq->qcnt;
|
||||
}
|
||||
|
||||
static u32 get_ff_hwaddr(struct xmit_frame *pxmitframe)
|
||||
{
|
||||
u32 addr = 0;
|
||||
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
||||
struct _adapter *padapter = pxmitframe->padapter;
|
||||
struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
|
||||
|
||||
if (pxmitframe->frame_tag == TXAGG_FRAMETAG)
|
||||
addr = RTL8712_DMA_H2CCMD;
|
||||
else if (pxmitframe->frame_tag == MGNT_FRAMETAG)
|
||||
addr = RTL8712_DMA_MGTQ;
|
||||
else if (pdvobj->nr_endpoint == 6) {
|
||||
switch (pattrib->priority) {
|
||||
case 0:
|
||||
case 3:
|
||||
addr = RTL8712_DMA_BEQ;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
addr = RTL8712_DMA_BKQ;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
addr = RTL8712_DMA_VIQ;
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
addr = RTL8712_DMA_VOQ;
|
||||
break;
|
||||
case 0x10:
|
||||
case 0x11:
|
||||
case 0x12:
|
||||
case 0x13:
|
||||
addr = RTL8712_DMA_H2CCMD;
|
||||
break;
|
||||
default:
|
||||
addr = RTL8712_DMA_BEQ;
|
||||
break;
|
||||
}
|
||||
} else if (pdvobj->nr_endpoint == 4) {
|
||||
switch (pattrib->qsel) {
|
||||
case 0:
|
||||
case 3:
|
||||
case 1:
|
||||
case 2:
|
||||
addr = RTL8712_DMA_BEQ;/*RTL8712_EP_LO;*/
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
addr = RTL8712_DMA_VOQ;/*RTL8712_EP_HI;*/
|
||||
break;
|
||||
case 0x10:
|
||||
case 0x11:
|
||||
case 0x12:
|
||||
case 0x13:
|
||||
addr = RTL8712_DMA_H2CCMD;;
|
||||
break;
|
||||
default:
|
||||
addr = RTL8712_DMA_BEQ;/*RTL8712_EP_LO;*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv,
|
||||
struct hw_xmit *phwxmit,
|
||||
struct tx_servq *ptxservq,
|
||||
struct __queue *pframe_queue)
|
||||
{
|
||||
struct list_head *xmitframe_plist, *xmitframe_phead;
|
||||
struct xmit_frame *pxmitframe = NULL;
|
||||
|
||||
xmitframe_phead = get_list_head(pframe_queue);
|
||||
xmitframe_plist = get_next(xmitframe_phead);
|
||||
if ((end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false) {
|
||||
pxmitframe = LIST_CONTAINOR(xmitframe_plist,
|
||||
struct xmit_frame, list);
|
||||
list_delete(&pxmitframe->list);
|
||||
ptxservq->qcnt--;
|
||||
phwxmit->txcmdcnt++;
|
||||
}
|
||||
return pxmitframe;
|
||||
}
|
||||
|
||||
static struct xmit_frame *dequeue_xframe_ex(struct xmit_priv *pxmitpriv,
|
||||
struct hw_xmit *phwxmit_i, sint entry)
|
||||
{
|
||||
unsigned long irqL0;
|
||||
struct list_head *sta_plist, *sta_phead;
|
||||
struct hw_xmit *phwxmit;
|
||||
struct tx_servq *ptxservq = NULL;
|
||||
struct __queue *pframe_queue = NULL;
|
||||
struct xmit_frame *pxmitframe = NULL;
|
||||
int i, inx[4];
|
||||
int j, tmp, acirp_cnt[4];
|
||||
|
||||
/*entry indx: 0->vo, 1->vi, 2->be, 3->bk.*/
|
||||
inx[0] = 0; acirp_cnt[0] = pxmitpriv->voq_cnt;
|
||||
inx[1] = 1; acirp_cnt[1] = pxmitpriv->viq_cnt;
|
||||
inx[2] = 2; acirp_cnt[2] = pxmitpriv->beq_cnt;
|
||||
inx[3] = 3; acirp_cnt[3] = pxmitpriv->bkq_cnt;
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = i + 1; j < 4; j++) {
|
||||
if (acirp_cnt[j] < acirp_cnt[i]) {
|
||||
tmp = acirp_cnt[i];
|
||||
acirp_cnt[i] = acirp_cnt[j];
|
||||
acirp_cnt[j] = tmp;
|
||||
tmp = inx[i];
|
||||
inx[i] = inx[j];
|
||||
inx[j] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
spin_lock_irqsave(&pxmitpriv->lock, irqL0);
|
||||
for (i = 0; i < entry; i++) {
|
||||
phwxmit = phwxmit_i + inx[i];
|
||||
sta_phead = get_list_head(phwxmit->sta_queue);
|
||||
sta_plist = get_next(sta_phead);
|
||||
while ((end_of_queue_search(sta_phead, sta_plist)) == false) {
|
||||
ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq,
|
||||
tx_pending);
|
||||
pframe_queue = &ptxservq->sta_pending;
|
||||
pxmitframe = dequeue_one_xmitframe(pxmitpriv, phwxmit,
|
||||
ptxservq, pframe_queue);
|
||||
if (pxmitframe) {
|
||||
phwxmit->accnt--;
|
||||
goto exit_dequeue_xframe_ex;
|
||||
}
|
||||
sta_plist = get_next(sta_plist);
|
||||
/*Remove sta node when there are no pending packets.*/
|
||||
if (_queue_empty(pframe_queue)) {
|
||||
/*must be done after get_next and before break*/
|
||||
list_delete(&ptxservq->tx_pending);
|
||||
}
|
||||
}
|
||||
}
|
||||
exit_dequeue_xframe_ex:
|
||||
spin_unlock_irqrestore(&pxmitpriv->lock, irqL0);
|
||||
return pxmitframe;
|
||||
}
|
||||
|
||||
void r8712_do_queue_select(struct _adapter *padapter,
|
||||
struct pkt_attrib *pattrib)
|
||||
{
|
||||
u8 qsel = 0;
|
||||
struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
|
||||
|
||||
if (pdvobj->nr_endpoint == 6)
|
||||
qsel = pattrib->priority;
|
||||
else if (pdvobj->nr_endpoint == 4)
|
||||
qsel = pattrib->priority;
|
||||
pattrib->qsel = qsel;
|
||||
}
|
||||
|
||||
static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz)
|
||||
{
|
||||
uint qsel;
|
||||
struct _adapter *padapter = pxmitframe->padapter;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
|
||||
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
||||
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
||||
struct tx_desc *ptxdesc = (struct tx_desc *)pmem;
|
||||
struct dvobj_priv *pdvobj = (struct dvobj_priv *)&padapter->dvobjpriv;
|
||||
u8 blnSetTxDescOffset;
|
||||
sint bmcst = IS_MCAST(pattrib->ra);
|
||||
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
||||
struct tx_desc txdesc_mp;
|
||||
|
||||
memcpy(&txdesc_mp, ptxdesc, sizeof(struct tx_desc));
|
||||
memset(ptxdesc, 0, sizeof(struct tx_desc));
|
||||
/* offset 0 */
|
||||
ptxdesc->txdw0 |= cpu_to_le32(sz&0x0000ffff);
|
||||
if (pdvobj->ishighspeed) {
|
||||
if (((sz + TXDESC_SIZE) % 512) == 0)
|
||||
blnSetTxDescOffset = 1;
|
||||
else
|
||||
blnSetTxDescOffset = 0;
|
||||
} else {
|
||||
if (((sz + TXDESC_SIZE) % 64) == 0)
|
||||
blnSetTxDescOffset = 1;
|
||||
else
|
||||
blnSetTxDescOffset = 0;
|
||||
}
|
||||
if (blnSetTxDescOffset) {
|
||||
/* 32 bytes for TX Desc + 8 bytes pending */
|
||||
ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ + 8) <<
|
||||
OFFSET_SHT) & 0x00ff0000);
|
||||
} else {
|
||||
/* default = 32 bytes for TX Desc */
|
||||
ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ) <<
|
||||
OFFSET_SHT) & 0x00ff0000);
|
||||
}
|
||||
ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG);
|
||||
if (pxmitframe->frame_tag == DATA_FRAMETAG) {
|
||||
/* offset 4 */
|
||||
ptxdesc->txdw1 |= cpu_to_le32((pattrib->mac_id)&0x1f);
|
||||
qsel = (uint)(pattrib->qsel & 0x0000001f);
|
||||
ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
|
||||
if (!pqospriv->qos_option)
|
||||
ptxdesc->txdw1 |= cpu_to_le32(BIT(16));/*Non-QoS*/
|
||||
if ((pattrib->encrypt > 0) && !pattrib->bswenc) {
|
||||
switch (pattrib->encrypt) { /*SEC_TYPE*/
|
||||
case _WEP40_:
|
||||
case _WEP104_:
|
||||
ptxdesc->txdw1 |= cpu_to_le32((0x01 << 22) &
|
||||
0x00c00000);
|
||||
/*KEY_ID when WEP is used;*/
|
||||
ptxdesc->txdw1 |= cpu_to_le32((psecuritypriv->
|
||||
PrivacyKeyIndex << 17) &
|
||||
0x00060000);
|
||||
break;
|
||||
case _TKIP_:
|
||||
case _TKIP_WTMIC_:
|
||||
ptxdesc->txdw1 |= cpu_to_le32((0x02 << 22) &
|
||||
0x00c00000);
|
||||
break;
|
||||
case _AES_:
|
||||
ptxdesc->txdw1 |= cpu_to_le32((0x03 << 22) &
|
||||
0x00c00000);
|
||||
break;
|
||||
case _NO_PRIVACY_:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*offset 8*/
|
||||
if (bmcst)
|
||||
ptxdesc->txdw2 |= cpu_to_le32(BMC);
|
||||
|
||||
/*offset 12*/
|
||||
/* f/w will increase the seqnum by itself, driver pass the
|
||||
* correct priority to fw
|
||||
* fw will check the correct priority for increasing the
|
||||
* seqnum per tid. about usb using 4-endpoint, qsel points out
|
||||
* the correct mapping between AC&Endpoint,
|
||||
* the purpose is that correct mapping lets the MAC release
|
||||
* the AC Queue list correctly. */
|
||||
ptxdesc->txdw3 = cpu_to_le32((pattrib->priority << SEQ_SHT) &
|
||||
0x0fff0000);
|
||||
if ((pattrib->ether_type != 0x888e) &&
|
||||
(pattrib->ether_type != 0x0806) &&
|
||||
(pattrib->dhcp_pkt != 1)) {
|
||||
/*Not EAP & ARP type data packet*/
|
||||
if (phtpriv->ht_option == 1) { /*B/G/N Mode*/
|
||||
if (phtpriv->ampdu_enable != true)
|
||||
ptxdesc->txdw2 |= cpu_to_le32(BK);
|
||||
}
|
||||
} else {
|
||||
/* EAP data packet and ARP packet.
|
||||
* Use the 1M data rate to send the EAP/ARP packet.
|
||||
* This will maybe make the handshake smooth.
|
||||
*/
|
||||
/*driver uses data rate*/
|
||||
ptxdesc->txdw4 = cpu_to_le32(0x80000000);
|
||||
ptxdesc->txdw5 = cpu_to_le32(0x001f8000);/*1M*/
|
||||
}
|
||||
if (pattrib->pctrl == 1) { /* mp tx packets */
|
||||
struct tx_desc *ptxdesc_mp;
|
||||
ptxdesc_mp = &txdesc_mp;
|
||||
/* offset 8 */
|
||||
ptxdesc->txdw2 = cpu_to_le32(ptxdesc_mp->txdw2);
|
||||
if (bmcst)
|
||||
ptxdesc->txdw2 |= cpu_to_le32(BMC);
|
||||
ptxdesc->txdw2 |= cpu_to_le32(BK);
|
||||
/* offset 16 */
|
||||
ptxdesc->txdw4 = cpu_to_le32(ptxdesc_mp->txdw4);
|
||||
/* offset 20 */
|
||||
ptxdesc->txdw5 = cpu_to_le32(ptxdesc_mp->txdw5);
|
||||
pattrib->pctrl = 0;/* reset to zero; */
|
||||
}
|
||||
} else if (pxmitframe->frame_tag == MGNT_FRAMETAG) {
|
||||
/* offset 4 */
|
||||
ptxdesc->txdw1 |= (0x05) & 0x1f;/*CAM_ID(MAC_ID), default=5;*/
|
||||
qsel = (uint)(pattrib->qsel & 0x0000001f);
|
||||
ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
|
||||
ptxdesc->txdw1 |= cpu_to_le32(BIT(16));/* Non-QoS */
|
||||
/* offset 8 */
|
||||
if (bmcst)
|
||||
ptxdesc->txdw2 |= cpu_to_le32(BMC);
|
||||
/* offset 12 */
|
||||
/* f/w will increase the seqnum by itself, driver pass the
|
||||
* correct priority to fw
|
||||
* fw will check the correct priority for increasing the seqnum
|
||||
* per tid. about usb using 4-endpoint, qsel points out the
|
||||
* correct mapping between AC&Endpoint,
|
||||
* the purpose is that correct mapping let the MAC releases
|
||||
* the AC Queue list correctly. */
|
||||
ptxdesc->txdw3 = cpu_to_le32((pattrib->priority << SEQ_SHT) &
|
||||
0x0fff0000);
|
||||
/* offset 16 */
|
||||
ptxdesc->txdw4 = cpu_to_le32(0x80002040);/*gtest*/
|
||||
/* offset 20 */
|
||||
ptxdesc->txdw5 = cpu_to_le32(0x001f8000);/* gtest 1M */
|
||||
} else if (pxmitframe->frame_tag == TXAGG_FRAMETAG) {
|
||||
/* offset 4 */
|
||||
qsel = 0x13;
|
||||
ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
|
||||
} else {
|
||||
/* offset 4 */
|
||||
qsel = (uint)(pattrib->priority&0x0000001f);
|
||||
ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00);
|
||||
/*offset 8*/
|
||||
/*offset 12*/
|
||||
ptxdesc->txdw3 = cpu_to_le32((pattrib->seqnum << SEQ_SHT) &
|
||||
0x0fff0000);
|
||||
/*offset 16*/
|
||||
ptxdesc->txdw4 = cpu_to_le32(0x80002040);/*gtest*/
|
||||
/*offset 20*/
|
||||
ptxdesc->txdw5 = cpu_to_le32(0x001f9600);/*gtest*/
|
||||
}
|
||||
}
|
||||
|
||||
int r8712_xmitframe_complete(struct _adapter *padapter,
|
||||
struct xmit_priv *pxmitpriv,
|
||||
struct xmit_buf *pxmitbuf)
|
||||
{
|
||||
struct hw_xmit *phwxmits;
|
||||
sint hwentry;
|
||||
struct xmit_frame *pxmitframe = NULL;
|
||||
int res = _SUCCESS, xcnt = 0;
|
||||
|
||||
phwxmits = pxmitpriv->hwxmits;
|
||||
hwentry = pxmitpriv->hwxmit_entry;
|
||||
if (pxmitbuf == NULL) {
|
||||
pxmitbuf = r8712_alloc_xmitbuf(pxmitpriv);
|
||||
if (!pxmitbuf)
|
||||
return false;
|
||||
}
|
||||
do {
|
||||
pxmitframe = dequeue_xframe_ex(pxmitpriv, phwxmits, hwentry);
|
||||
if (pxmitframe) {
|
||||
pxmitframe->pxmitbuf = pxmitbuf;
|
||||
pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0];
|
||||
pxmitframe->buf_addr = pxmitbuf->pbuf;
|
||||
if (pxmitframe->frame_tag == DATA_FRAMETAG) {
|
||||
if (pxmitframe->attrib.priority <= 15)
|
||||
res = r8712_xmitframe_coalesce(padapter,
|
||||
pxmitframe->pkt, pxmitframe);
|
||||
/* always return ndis_packet after
|
||||
* r8712_xmitframe_coalesce */
|
||||
r8712_xmit_complete(padapter, pxmitframe);
|
||||
}
|
||||
if (res == _SUCCESS)
|
||||
dump_xframe(padapter, pxmitframe);
|
||||
else
|
||||
r8712_free_xmitframe_ex(pxmitpriv, pxmitframe);
|
||||
xcnt++;
|
||||
} else {
|
||||
r8712_free_xmitbuf(pxmitpriv, pxmitbuf);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
} while (0);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void dump_xframe(struct _adapter *padapter,
|
||||
struct xmit_frame *pxmitframe)
|
||||
{
|
||||
int t, sz, w_sz;
|
||||
u8 *mem_addr;
|
||||
u32 ff_hwaddr;
|
||||
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
||||
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
||||
|
||||
if (pxmitframe->attrib.ether_type != 0x0806) {
|
||||
if (pxmitframe->attrib.ether_type != 0x888e)
|
||||
r8712_issue_addbareq_cmd(padapter, pattrib->priority);
|
||||
}
|
||||
mem_addr = pxmitframe->buf_addr;
|
||||
for (t = 0; t < pattrib->nr_frags; t++) {
|
||||
if (t != (pattrib->nr_frags - 1)) {
|
||||
sz = pxmitpriv->frag_len;
|
||||
sz = sz - 4 - (psecuritypriv->sw_encrypt ? 0 :
|
||||
pattrib->icv_len);
|
||||
pxmitframe->last[t] = 0;
|
||||
} else {
|
||||
sz = pattrib->last_txcmdsz;
|
||||
pxmitframe->last[t] = 1;
|
||||
}
|
||||
update_txdesc(pxmitframe, (uint *)mem_addr, sz);
|
||||
w_sz = sz + TXDESC_SIZE;
|
||||
pxmitframe->mem_addr = mem_addr;
|
||||
pxmitframe->bpending[t] = false;
|
||||
ff_hwaddr = get_ff_hwaddr(pxmitframe);
|
||||
r8712_write_port(padapter, ff_hwaddr, w_sz,
|
||||
(unsigned char *)pxmitframe);
|
||||
mem_addr += w_sz;
|
||||
mem_addr = (u8 *)RND4(((addr_t)(mem_addr)));
|
||||
}
|
||||
}
|
||||
|
||||
int r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe)
|
||||
{
|
||||
int res = _SUCCESS;
|
||||
|
||||
res = r8712_xmitframe_coalesce(padapter, pxmitframe->pkt, pxmitframe);
|
||||
pxmitframe->pkt = NULL;
|
||||
if (res == _SUCCESS)
|
||||
dump_xframe(padapter, pxmitframe);
|
||||
return res;
|
||||
}
|
||||
|
||||
int r8712_xmit_enqueue(struct _adapter *padapter, struct xmit_frame *pxmitframe)
|
||||
{
|
||||
if (r8712_xmit_classifier(padapter, pxmitframe) == _FAIL) {
|
||||
pxmitframe->pkt = NULL;
|
||||
return _FAIL;
|
||||
}
|
||||
return _SUCCESS;
|
||||
}
|
95
drivers/staging/rtl8712/rtl8712_xmit.h
Normal file
95
drivers/staging/rtl8712/rtl8712_xmit.h
Normal file
@ -0,0 +1,95 @@
|
||||
#ifndef _RTL8712_XMIT_H_
|
||||
#define _RTL8712_XMIT_H_
|
||||
|
||||
#define HWXMIT_ENTRY 4
|
||||
|
||||
#define VO_QUEUE_INX 0
|
||||
#define VI_QUEUE_INX 1
|
||||
#define BE_QUEUE_INX 2
|
||||
#define BK_QUEUE_INX 3
|
||||
#define TS_QUEUE_INX 4
|
||||
#define MGT_QUEUE_INX 5
|
||||
#define BMC_QUEUE_INX 6
|
||||
#define BCN_QUEUE_INX 7
|
||||
|
||||
#define HW_QUEUE_ENTRY 8
|
||||
|
||||
#define TXDESC_SIZE 32
|
||||
#define TXDESC_OFFSET TXDESC_SIZE
|
||||
|
||||
#define NR_AMSDU_XMITFRAME 8
|
||||
#define NR_TXAGG_XMITFRAME 8
|
||||
|
||||
#define MAX_AMSDU_XMITBUF_SZ 8704
|
||||
#define MAX_TXAGG_XMITBUF_SZ 16384 /*16k*/
|
||||
|
||||
|
||||
#define tx_cmd tx_desc
|
||||
|
||||
|
||||
/*
|
||||
*defined for TX DESC Operation
|
||||
*/
|
||||
|
||||
#define MAX_TID (15)
|
||||
|
||||
/*OFFSET 0*/
|
||||
#define OFFSET_SZ (0)
|
||||
#define OFFSET_SHT (16)
|
||||
#define OWN BIT(31)
|
||||
#define FSG BIT(27)
|
||||
#define LSG BIT(26)
|
||||
|
||||
/*OFFSET 4*/
|
||||
#define PKT_OFFSET_SZ (0)
|
||||
#define QSEL_SHT (8)
|
||||
#define HWPC BIT(31)
|
||||
|
||||
/*OFFSET 8*/
|
||||
#define BMC BIT(7)
|
||||
#define BK BIT(30)
|
||||
#define AGG_EN BIT(29)
|
||||
|
||||
/*OFFSET 12*/
|
||||
#define SEQ_SHT (16)
|
||||
|
||||
/*OFFSET 16*/
|
||||
#define TXBW BIT(18)
|
||||
|
||||
/*OFFSET 20*/
|
||||
#define DISFB BIT(15)
|
||||
|
||||
struct tx_desc{
|
||||
|
||||
/*DWORD 0*/
|
||||
unsigned int txdw0;
|
||||
|
||||
unsigned int txdw1;
|
||||
|
||||
unsigned int txdw2;
|
||||
|
||||
unsigned int txdw3;
|
||||
|
||||
unsigned int txdw4;
|
||||
|
||||
unsigned int txdw5;
|
||||
|
||||
unsigned int txdw6;
|
||||
|
||||
unsigned int txdw7;
|
||||
|
||||
};
|
||||
|
||||
|
||||
union txdesc {
|
||||
struct tx_desc txdesc;
|
||||
unsigned int value[TXDESC_SIZE>>2];
|
||||
};
|
||||
|
||||
int r8712_xmitframe_complete(struct _adapter *padapter,
|
||||
struct xmit_priv *pxmitpriv,
|
||||
struct xmit_buf *pxmitbuf);
|
||||
void r8712_do_queue_select(struct _adapter *padapter,
|
||||
struct pkt_attrib *pattrib);
|
||||
|
||||
#endif
|
13
drivers/staging/rtl8712/rtl871x_byteorder.h
Normal file
13
drivers/staging/rtl8712/rtl871x_byteorder.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef _RTL871X_BYTEORDER_H_
|
||||
#define _RTL871X_BYTEORDER_H_
|
||||
|
||||
#if defined(__LITTLE_ENDIAN)
|
||||
# include "little_endian.h"
|
||||
#elif defined(__BIG_ENDIAN)
|
||||
# include "big_endian.h"
|
||||
#else
|
||||
# error "Must be LITTLE/BIG Endian Host"
|
||||
#endif
|
||||
|
||||
#endif /* _RTL871X_BYTEORDER_H_ */
|
||||
|
918
drivers/staging/rtl8712/rtl871x_cmd.c
Normal file
918
drivers/staging/rtl8712/rtl871x_cmd.c
Normal file
@ -0,0 +1,918 @@
|
||||
/******************************************************************************
|
||||
* rtl871x_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 _RTL871X_CMD_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "recv_osdep.h"
|
||||
#include "mlme_osdep.h"
|
||||
#include "rtl871x_byteorder.h"
|
||||
|
||||
/*
|
||||
Caller and the r8712_cmd_thread can protect cmd_q by spin_lock.
|
||||
No irqsave is necessary.
|
||||
*/
|
||||
|
||||
static sint _init_cmd_priv(struct cmd_priv *pcmdpriv)
|
||||
{
|
||||
sema_init(&(pcmdpriv->cmd_queue_sema), 0);
|
||||
sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
|
||||
|
||||
_init_queue(&(pcmdpriv->cmd_queue));
|
||||
|
||||
/* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
|
||||
pcmdpriv->cmd_seq = 1;
|
||||
pcmdpriv->cmd_allocated_buf = _malloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ);
|
||||
if (pcmdpriv->cmd_allocated_buf == NULL)
|
||||
return _FAIL;
|
||||
pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ -
|
||||
((addr_t)(pcmdpriv->cmd_allocated_buf) &
|
||||
(CMDBUFF_ALIGN_SZ-1));
|
||||
pcmdpriv->rsp_allocated_buf = _malloc(MAX_RSPSZ + 4);
|
||||
if (pcmdpriv->rsp_allocated_buf == NULL)
|
||||
return _FAIL;
|
||||
pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 -
|
||||
((addr_t)(pcmdpriv->rsp_allocated_buf) & 3);
|
||||
pcmdpriv->cmd_issued_cnt = 0;
|
||||
pcmdpriv->cmd_done_cnt = 0;
|
||||
pcmdpriv->rsp_cnt = 0;
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
static sint _init_evt_priv(struct evt_priv *pevtpriv)
|
||||
{
|
||||
/* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
|
||||
pevtpriv->event_seq = 0;
|
||||
pevtpriv->evt_allocated_buf = _malloc(MAX_EVTSZ + 4);
|
||||
|
||||
if (pevtpriv->evt_allocated_buf == NULL)
|
||||
return _FAIL;
|
||||
pevtpriv->evt_buf = pevtpriv->evt_allocated_buf + 4 -
|
||||
((addr_t)(pevtpriv->evt_allocated_buf) & 3);
|
||||
pevtpriv->evt_done_cnt = 0;
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
static void _free_evt_priv(struct evt_priv *pevtpriv)
|
||||
{
|
||||
kfree(pevtpriv->evt_allocated_buf);
|
||||
}
|
||||
|
||||
static void _free_cmd_priv(struct cmd_priv *pcmdpriv)
|
||||
{
|
||||
if (pcmdpriv) {
|
||||
kfree(pcmdpriv->cmd_allocated_buf);
|
||||
kfree(pcmdpriv->rsp_allocated_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Calling Context:
|
||||
|
||||
_enqueue_cmd can only be called between kernel thread,
|
||||
since only spin_lock is used.
|
||||
|
||||
ISR/Call-Back functions can't call this sub-function.
|
||||
|
||||
*/
|
||||
|
||||
static sint _enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)
|
||||
{
|
||||
unsigned long irqL;
|
||||
|
||||
if (obj == NULL)
|
||||
return _SUCCESS;
|
||||
spin_lock_irqsave(&queue->lock, irqL);
|
||||
list_insert_tail(&obj->list, &queue->queue);
|
||||
spin_unlock_irqrestore(&queue->lock, irqL);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
static struct cmd_obj *_dequeue_cmd(struct __queue *queue)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct cmd_obj *obj;
|
||||
|
||||
spin_lock_irqsave(&(queue->lock), irqL);
|
||||
if (is_list_empty(&(queue->queue)))
|
||||
obj = NULL;
|
||||
else {
|
||||
obj = LIST_CONTAINOR(get_next(&(queue->queue)),
|
||||
struct cmd_obj, list);
|
||||
list_delete(&obj->list);
|
||||
}
|
||||
spin_unlock_irqrestore(&(queue->lock), irqL);
|
||||
return obj;
|
||||
}
|
||||
|
||||
u32 r8712_init_cmd_priv(struct cmd_priv *pcmdpriv)
|
||||
{
|
||||
return _init_cmd_priv(pcmdpriv);
|
||||
}
|
||||
|
||||
u32 r8712_init_evt_priv(struct evt_priv *pevtpriv)
|
||||
{
|
||||
return _init_evt_priv(pevtpriv);
|
||||
}
|
||||
|
||||
void r8712_free_evt_priv(struct evt_priv *pevtpriv)
|
||||
{
|
||||
_free_evt_priv(pevtpriv);
|
||||
}
|
||||
|
||||
void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv)
|
||||
{
|
||||
_free_cmd_priv(pcmdpriv);
|
||||
}
|
||||
|
||||
u32 r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj)
|
||||
{
|
||||
int res;
|
||||
|
||||
if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag == true)
|
||||
return _FAIL;
|
||||
res = _enqueue_cmd(&pcmdpriv->cmd_queue, obj);
|
||||
up(&pcmdpriv->cmd_queue_sema);
|
||||
return res;
|
||||
}
|
||||
|
||||
u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct __queue *queue;
|
||||
|
||||
if (obj == NULL)
|
||||
return _SUCCESS;
|
||||
if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag == true)
|
||||
return _FAIL;
|
||||
queue = &pcmdpriv->cmd_queue;
|
||||
spin_lock_irqsave(&queue->lock, irqL);
|
||||
list_insert_tail(&obj->list, &queue->queue);
|
||||
spin_unlock_irqrestore(&queue->lock, irqL);
|
||||
up(&pcmdpriv->cmd_queue_sema);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue)
|
||||
{
|
||||
return _dequeue_cmd(queue);
|
||||
}
|
||||
|
||||
void r8712_free_cmd_obj(struct cmd_obj *pcmd)
|
||||
{
|
||||
if ((pcmd->cmdcode != _JoinBss_CMD_) &&
|
||||
(pcmd->cmdcode != _CreateBss_CMD_))
|
||||
kfree((unsigned char *)pcmd->parmbuf);
|
||||
if (pcmd->rsp != NULL) {
|
||||
if (pcmd->rspsz != 0)
|
||||
kfree((unsigned char *)pcmd->rsp);
|
||||
}
|
||||
kfree((unsigned char *)pcmd);
|
||||
}
|
||||
|
||||
/*
|
||||
r8712_sitesurvey_cmd(~)
|
||||
### NOTE:#### (!!!!)
|
||||
MUST TAKE CARE THAT BEFORE CALLING THIS FUNC,
|
||||
YOU SHOULD HAVE LOCKED pmlmepriv->lock
|
||||
*/
|
||||
u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
|
||||
struct ndis_802_11_ssid *pssid)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct sitesurvey_parm *psurveyPara;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
psurveyPara = (struct sitesurvey_parm *)_malloc(
|
||||
sizeof(struct sitesurvey_parm));
|
||||
if (psurveyPara == NULL) {
|
||||
kfree((unsigned char *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara,
|
||||
GEN_CMD_CODE(_SiteSurvey));
|
||||
psurveyPara->bsslimit = cpu_to_le32(48);
|
||||
psurveyPara->passive_mode = cpu_to_le32(1);
|
||||
psurveyPara->ss_ssidlen = 0;
|
||||
memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1);
|
||||
if ((pssid != NULL) && (pssid->SsidLength)) {
|
||||
memcpy(psurveyPara->ss_ssid, pssid->Ssid, pssid->SsidLength);
|
||||
psurveyPara->ss_ssidlen = cpu_to_le32(pssid->SsidLength);
|
||||
}
|
||||
set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
_set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT);
|
||||
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_SITE_SURVEY);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct setdatarate_parm *pbsetdataratepara;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
pbsetdataratepara = (struct setdatarate_parm *)_malloc(
|
||||
sizeof(struct setdatarate_parm));
|
||||
if (pbsetdataratepara == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara,
|
||||
GEN_CMD_CODE(_SetDataRate));
|
||||
pbsetdataratepara->mac_id = 5;
|
||||
memcpy(pbsetdataratepara->datarates, rateset, NumRates);
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct setbasicrate_parm *pssetbasicratepara;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
pssetbasicratepara = (struct setbasicrate_parm *)_malloc(
|
||||
sizeof(struct setbasicrate_parm));
|
||||
if (pssetbasicratepara == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara,
|
||||
_SetBasicRate_CMD_);
|
||||
memcpy(pssetbasicratepara->basicrates, rateset, NumRates);
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
/* power tracking mechanism setting */
|
||||
u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct PT_param *pptparm;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
pptparm = (struct PT_param *)_malloc(sizeof(struct PT_param));
|
||||
if (pptparm == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, pptparm,
|
||||
GEN_CMD_CODE(_SetPowerTracking));
|
||||
pptparm->PT_En = type;
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct writeRF_parm *pwriterfparm;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
pwriterfparm = (struct writeRF_parm *)_malloc(
|
||||
sizeof(struct writeRF_parm));
|
||||
if (pwriterfparm == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, pwriterfparm, GEN_CMD_CODE(_SetRFReg));
|
||||
pwriterfparm->offset = offset;
|
||||
pwriterfparm->value = val;
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct readRF_parm *prdrfparm;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
prdrfparm = (struct readRF_parm *)_malloc(sizeof(struct readRF_parm));
|
||||
if (prdrfparm == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
_init_listhead(&ph2c->list);
|
||||
ph2c->cmdcode = GEN_CMD_CODE(_GetRFReg);
|
||||
ph2c->parmbuf = (unsigned char *)prdrfparm;
|
||||
ph2c->cmdsz = sizeof(struct readRF_parm);
|
||||
ph2c->rsp = pval;
|
||||
ph2c->rspsz = sizeof(struct readRF_rsp);
|
||||
prdrfparm->offset = offset;
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd)
|
||||
{
|
||||
kfree((unsigned char *) pcmd->parmbuf);
|
||||
kfree((unsigned char *) pcmd);
|
||||
padapter->mppriv.workparam.bcompleted = true;
|
||||
}
|
||||
|
||||
u8 r8712_createbss_cmd(struct _adapter *padapter)
|
||||
{
|
||||
struct cmd_obj *pcmd;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
struct wlan_bssid_ex *pdev_network =
|
||||
&padapter->registrypriv.dev_network;
|
||||
|
||||
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK);
|
||||
pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (pcmd == NULL)
|
||||
return _FAIL;
|
||||
_init_listhead(&pcmd->list);
|
||||
pcmd->cmdcode = _CreateBss_CMD_;
|
||||
pcmd->parmbuf = (unsigned char *)pdev_network;
|
||||
pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz((
|
||||
struct ndis_wlan_bssid_ex *)
|
||||
pdev_network);
|
||||
pcmd->rsp = NULL;
|
||||
pcmd->rspsz = 0;
|
||||
/* notes: translate IELength & Length after assign to cmdsz; */
|
||||
pdev_network->Length = cpu_to_le32(pcmd->cmdsz);
|
||||
pdev_network->IELength = cpu_to_le32(pdev_network->IELength);
|
||||
pdev_network->Ssid.SsidLength = cpu_to_le32(
|
||||
pdev_network->Ssid.SsidLength);
|
||||
r8712_enqueue_cmd(pcmdpriv, pcmd);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork)
|
||||
{
|
||||
u8 *auth;
|
||||
uint t_len = 0;
|
||||
struct ndis_wlan_bssid_ex *psecnetwork;
|
||||
struct cmd_obj *pcmd;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
|
||||
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
||||
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
||||
enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode = pnetwork->
|
||||
network.InfrastructureMode;
|
||||
|
||||
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK);
|
||||
pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (pcmd == NULL)
|
||||
return _FAIL;
|
||||
t_len = sizeof(u32) + 6 * sizeof(unsigned char) + 2 +
|
||||
sizeof(struct ndis_802_11_ssid) + sizeof(u32) +
|
||||
sizeof(s32) +
|
||||
sizeof(enum NDIS_802_11_NETWORK_TYPE) +
|
||||
sizeof(struct NDIS_802_11_CONFIGURATION) +
|
||||
sizeof(enum NDIS_802_11_NETWORK_INFRASTRUCTURE) +
|
||||
sizeof(NDIS_802_11_RATES_EX) +
|
||||
sizeof(u32) + MAX_IE_SZ;
|
||||
|
||||
/* for hidden ap to set fw_state here */
|
||||
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) !=
|
||||
true) {
|
||||
switch (ndis_network_mode) {
|
||||
case Ndis802_11IBSS:
|
||||
pmlmepriv->fw_state |= WIFI_ADHOC_STATE;
|
||||
break;
|
||||
case Ndis802_11Infrastructure:
|
||||
pmlmepriv->fw_state |= WIFI_STATION_STATE;
|
||||
break;
|
||||
case Ndis802_11APMode:
|
||||
case Ndis802_11AutoUnknown:
|
||||
case Ndis802_11InfrastructureMax:
|
||||
break;
|
||||
}
|
||||
}
|
||||
psecnetwork = (struct ndis_wlan_bssid_ex *)&psecuritypriv->sec_bss;
|
||||
if (psecnetwork == NULL) {
|
||||
if (pcmd != NULL)
|
||||
kfree((unsigned char *)pcmd);
|
||||
return _FAIL;
|
||||
}
|
||||
memset(psecnetwork, 0, t_len);
|
||||
memcpy(psecnetwork, &pnetwork->network, t_len);
|
||||
auth = &psecuritypriv->authenticator_ie[0];
|
||||
psecuritypriv->authenticator_ie[0] = (unsigned char)
|
||||
psecnetwork->IELength;
|
||||
if ((psecnetwork->IELength-12) < (256 - 1))
|
||||
memcpy(&psecuritypriv->authenticator_ie[1],
|
||||
&psecnetwork->IEs[12], psecnetwork->IELength-12);
|
||||
else
|
||||
memcpy(&psecuritypriv->authenticator_ie[1],
|
||||
&psecnetwork->IEs[12], (256-1));
|
||||
psecnetwork->IELength = 0;
|
||||
/* If the the driver wants to use the bssid to create the connection.
|
||||
* If not, we copy the connecting AP's MAC address to it so that
|
||||
* the driver just has the bssid information for PMKIDList searching.
|
||||
*/
|
||||
if (pmlmepriv->assoc_by_bssid == false)
|
||||
memcpy(&pmlmepriv->assoc_bssid[0],
|
||||
&pnetwork->network.MacAddress[0], ETH_ALEN);
|
||||
psecnetwork->IELength = r8712_restruct_sec_ie(padapter,
|
||||
&pnetwork->network.IEs[0],
|
||||
&psecnetwork->IEs[0],
|
||||
pnetwork->network.IELength);
|
||||
pqospriv->qos_option = 0;
|
||||
if (pregistrypriv->wmm_enable) {
|
||||
u32 tmp_len;
|
||||
|
||||
tmp_len = r8712_restruct_wmm_ie(padapter,
|
||||
&pnetwork->network.IEs[0],
|
||||
&psecnetwork->IEs[0],
|
||||
pnetwork->network.IELength,
|
||||
psecnetwork->IELength);
|
||||
if (psecnetwork->IELength != tmp_len) {
|
||||
psecnetwork->IELength = tmp_len;
|
||||
pqospriv->qos_option = 1; /* WMM IE in beacon */
|
||||
} else
|
||||
pqospriv->qos_option = 0; /* no WMM IE in beacon */
|
||||
}
|
||||
if (pregistrypriv->ht_enable) {
|
||||
/* r8712_restructure_ht_ie */
|
||||
r8712_restructure_ht_ie(padapter, &pnetwork->network.IEs[0],
|
||||
&psecnetwork->IEs[0],
|
||||
pnetwork->network.IELength,
|
||||
&psecnetwork->IELength);
|
||||
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)
|
||||
r8712_add_ht_addt_info(padapter,
|
||||
&pnetwork->network.IEs[0],
|
||||
&psecnetwork->IEs[0],
|
||||
pnetwork->network.IELength,
|
||||
&psecnetwork->IELength);
|
||||
}
|
||||
psecuritypriv->supplicant_ie[0] = (u8)psecnetwork->IELength;
|
||||
if (psecnetwork->IELength < 255)
|
||||
memcpy(&psecuritypriv->supplicant_ie[1], &psecnetwork->IEs[0],
|
||||
psecnetwork->IELength);
|
||||
else
|
||||
memcpy(&psecuritypriv->supplicant_ie[1], &psecnetwork->IEs[0],
|
||||
255);
|
||||
/* get cmdsz before endian conversion */
|
||||
pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz(psecnetwork);
|
||||
#ifdef __BIG_ENDIAN
|
||||
/* wlan_network endian conversion */
|
||||
psecnetwork->Length = cpu_to_le32(psecnetwork->Length);
|
||||
psecnetwork->Ssid.SsidLength = cpu_to_le32(
|
||||
psecnetwork->Ssid.SsidLength);
|
||||
psecnetwork->Privacy = cpu_to_le32(psecnetwork->Privacy);
|
||||
psecnetwork->Rssi = cpu_to_le32(psecnetwork->Rssi);
|
||||
psecnetwork->NetworkTypeInUse = cpu_to_le32(
|
||||
psecnetwork->NetworkTypeInUse);
|
||||
psecnetwork->Configuration.ATIMWindow = cpu_to_le32(
|
||||
psecnetwork->Configuration.ATIMWindow);
|
||||
psecnetwork->Configuration.BeaconPeriod = cpu_to_le32(
|
||||
psecnetwork->Configuration.BeaconPeriod);
|
||||
psecnetwork->Configuration.DSConfig = cpu_to_le32(
|
||||
psecnetwork->Configuration.DSConfig);
|
||||
psecnetwork->Configuration.FHConfig.DwellTime = cpu_to_le32(
|
||||
psecnetwork->Configuration.FHConfig.DwellTime);
|
||||
psecnetwork->Configuration.FHConfig.HopPattern = cpu_to_le32(
|
||||
psecnetwork->Configuration.FHConfig.HopPattern);
|
||||
psecnetwork->Configuration.FHConfig.HopSet = cpu_to_le32(
|
||||
psecnetwork->Configuration.FHConfig.HopSet);
|
||||
psecnetwork->Configuration.FHConfig.Length = cpu_to_le32(
|
||||
psecnetwork->Configuration.FHConfig.Length);
|
||||
psecnetwork->Configuration.Length = cpu_to_le32(
|
||||
psecnetwork->Configuration.Length);
|
||||
psecnetwork->InfrastructureMode = cpu_to_le32(
|
||||
psecnetwork->InfrastructureMode);
|
||||
psecnetwork->IELength = cpu_to_le32(psecnetwork->IELength);
|
||||
#endif
|
||||
_init_listhead(&pcmd->list);
|
||||
pcmd->cmdcode = _JoinBss_CMD_;
|
||||
pcmd->parmbuf = (unsigned char *)psecnetwork;
|
||||
pcmd->rsp = NULL;
|
||||
pcmd->rspsz = 0;
|
||||
r8712_enqueue_cmd(pcmdpriv, pcmd);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */
|
||||
{
|
||||
struct cmd_obj *pdisconnect_cmd;
|
||||
struct disconnect_parm *pdisconnect;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
pdisconnect_cmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (pdisconnect_cmd == NULL)
|
||||
return _FAIL;
|
||||
pdisconnect = (struct disconnect_parm *)_malloc(
|
||||
sizeof(struct disconnect_parm));
|
||||
if (pdisconnect == NULL) {
|
||||
kfree((u8 *)pdisconnect_cmd);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(pdisconnect_cmd, pdisconnect,
|
||||
_DisConnect_CMD_);
|
||||
r8712_enqueue_cmd(pcmdpriv, pdisconnect_cmd);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_setopmode_cmd(struct _adapter *padapter,
|
||||
enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct setopmode_parm *psetop;
|
||||
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
psetop = (struct setopmode_parm *)_malloc(
|
||||
sizeof(struct setopmode_parm));
|
||||
if (psetop == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_);
|
||||
psetop->mode = (u8)networktype;
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct set_stakey_parm *psetstakey_para;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
struct set_stakey_rsp *psetstakey_rsp = NULL;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
||||
struct sta_info *sta = (struct sta_info *)psta;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
psetstakey_para = (struct set_stakey_parm *)_malloc(
|
||||
sizeof(struct set_stakey_parm));
|
||||
if (psetstakey_para == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
psetstakey_rsp = (struct set_stakey_rsp *)_malloc(
|
||||
sizeof(struct set_stakey_rsp));
|
||||
if (psetstakey_rsp == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
kfree((u8 *) psetstakey_para);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
|
||||
ph2c->rsp = (u8 *) psetstakey_rsp;
|
||||
ph2c->rspsz = sizeof(struct set_stakey_rsp);
|
||||
memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);
|
||||
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
|
||||
psetstakey_para->algorithm = (unsigned char)
|
||||
psecuritypriv->PrivacyAlgrthm;
|
||||
else
|
||||
GET_ENCRY_ALGO(psecuritypriv, sta,
|
||||
psetstakey_para->algorithm, false);
|
||||
if (unicast_key == true)
|
||||
memcpy(&psetstakey_para->key, &sta->x_UncstKey, 16);
|
||||
else
|
||||
memcpy(&psetstakey_para->key,
|
||||
&psecuritypriv->XGrpKey[
|
||||
psecuritypriv->XGrpKeyid - 1]. skey, 16);
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct setrfintfs_parm *psetrfintfsparm;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
psetrfintfsparm = (struct setrfintfs_parm *)_malloc(
|
||||
sizeof(struct setrfintfs_parm));
|
||||
if (psetrfintfsparm == NULL) {
|
||||
kfree((unsigned char *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, psetrfintfsparm,
|
||||
GEN_CMD_CODE(_SetRFIntFs));
|
||||
psetrfintfsparm->rfintfs = mode;
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_setrttbl_cmd(struct _adapter *padapter,
|
||||
struct setratable_parm *prate_table)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct setratable_parm *psetrttblparm;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
psetrttblparm = (struct setratable_parm *)_malloc(
|
||||
sizeof(struct setratable_parm));
|
||||
if (psetrttblparm == NULL) {
|
||||
kfree((unsigned char *)ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm,
|
||||
GEN_CMD_CODE(_SetRaTable));
|
||||
memcpy(psetrttblparm, prate_table, sizeof(struct setratable_parm));
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr)
|
||||
{
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
struct cmd_obj *ph2c;
|
||||
struct SetMacAddr_param *psetMacAddr_para;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
psetMacAddr_para = (struct SetMacAddr_param *)_malloc(
|
||||
sizeof(struct SetMacAddr_param));
|
||||
if (psetMacAddr_para == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, psetMacAddr_para,
|
||||
_SetMacAddress_CMD_);
|
||||
memcpy(psetMacAddr_para->MacAddr, mac_addr, ETH_ALEN);
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr)
|
||||
{
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
struct cmd_obj *ph2c;
|
||||
struct set_assocsta_parm *psetassocsta_para;
|
||||
struct set_stakey_rsp *psetassocsta_rsp = NULL;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
psetassocsta_para = (struct set_assocsta_parm *)
|
||||
_malloc(sizeof(struct set_assocsta_parm));
|
||||
if (psetassocsta_para == NULL) {
|
||||
kfree((u8 *) ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
psetassocsta_rsp = (struct set_stakey_rsp *)_malloc(
|
||||
sizeof(struct set_assocsta_rsp));
|
||||
if (psetassocsta_rsp == NULL) {
|
||||
kfree((u8 *)ph2c);
|
||||
kfree((u8 *)psetassocsta_para);
|
||||
return _FAIL;
|
||||
}
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_);
|
||||
ph2c->rsp = (u8 *) psetassocsta_rsp;
|
||||
ph2c->rspsz = sizeof(struct set_assocsta_rsp);
|
||||
memcpy(psetassocsta_para->addr, mac_addr, ETH_ALEN);
|
||||
r8712_enqueue_cmd(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid)
|
||||
{
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
struct cmd_obj *ph2c;
|
||||
struct addBaReq_parm *paddbareq_parm;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
paddbareq_parm = (struct addBaReq_parm *)_malloc(
|
||||
sizeof(struct addBaReq_parm));
|
||||
if (paddbareq_parm == NULL) {
|
||||
kfree((unsigned char *)ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
paddbareq_parm->tid = tid;
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm,
|
||||
GEN_CMD_CODE(_AddBAReq));
|
||||
r8712_enqueue_cmd_ex(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
u8 r8712_wdg_wk_cmd(struct _adapter *padapter)
|
||||
{
|
||||
struct cmd_obj *ph2c;
|
||||
struct drvint_cmd_parm *pdrvintcmd_param;
|
||||
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
||||
|
||||
ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (ph2c == NULL)
|
||||
return _FAIL;
|
||||
pdrvintcmd_param = (struct drvint_cmd_parm *)_malloc(
|
||||
sizeof(struct drvint_cmd_parm));
|
||||
if (pdrvintcmd_param == NULL) {
|
||||
kfree((unsigned char *)ph2c);
|
||||
return _FAIL;
|
||||
}
|
||||
pdrvintcmd_param->i_cid = WDG_WK_CID;
|
||||
pdrvintcmd_param->sz = 0;
|
||||
pdrvintcmd_param->pbuf = NULL;
|
||||
init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvintcmd_param, _DRV_INT_CMD_);
|
||||
r8712_enqueue_cmd_ex(pcmdpriv, ph2c);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
void r8712_survey_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd)
|
||||
{
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
|
||||
if (pcmd->res != H2C_SUCCESS)
|
||||
clr_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
|
||||
r8712_free_cmd_obj(pcmd);
|
||||
}
|
||||
|
||||
void r8712_disassoc_cmd_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
|
||||
if (pcmd->res != H2C_SUCCESS) {
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
set_fwstate(pmlmepriv, _FW_LINKED);
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
return;
|
||||
}
|
||||
r8712_free_cmd_obj(pcmd);
|
||||
}
|
||||
|
||||
void r8712_joinbss_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd)
|
||||
{
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
|
||||
if ((pcmd->res != H2C_SUCCESS))
|
||||
_set_timer(&pmlmepriv->assoc_timer, 1);
|
||||
r8712_free_cmd_obj(pcmd);
|
||||
}
|
||||
|
||||
void r8712_createbss_cmd_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd)
|
||||
{
|
||||
unsigned long irqL;
|
||||
u8 timer_cancelled;
|
||||
struct sta_info *psta = NULL;
|
||||
struct wlan_network *pwlan = NULL;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
struct ndis_wlan_bssid_ex *pnetwork = (struct ndis_wlan_bssid_ex *)
|
||||
pcmd->parmbuf;
|
||||
struct wlan_network *tgt_network = &(pmlmepriv->cur_network);
|
||||
|
||||
if ((pcmd->res != H2C_SUCCESS))
|
||||
_set_timer(&pmlmepriv->assoc_timer, 1);
|
||||
_cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled);
|
||||
#ifdef __BIG_ENDIAN
|
||||
/* endian_convert */
|
||||
pnetwork->Length = le32_to_cpu(pnetwork->Length);
|
||||
pnetwork->Ssid.SsidLength = le32_to_cpu(pnetwork->Ssid.SsidLength);
|
||||
pnetwork->Privacy = le32_to_cpu(pnetwork->Privacy);
|
||||
pnetwork->Rssi = le32_to_cpu(pnetwork->Rssi);
|
||||
pnetwork->NetworkTypeInUse = le32_to_cpu(pnetwork->NetworkTypeInUse);
|
||||
pnetwork->Configuration.ATIMWindow = le32_to_cpu(pnetwork->
|
||||
Configuration.ATIMWindow);
|
||||
pnetwork->Configuration.DSConfig = le32_to_cpu(pnetwork->
|
||||
Configuration.DSConfig);
|
||||
pnetwork->Configuration.FHConfig.DwellTime = le32_to_cpu(pnetwork->
|
||||
Configuration.FHConfig.DwellTime);
|
||||
pnetwork->Configuration.FHConfig.HopPattern = le32_to_cpu(pnetwork->
|
||||
Configuration.FHConfig.HopPattern);
|
||||
pnetwork->Configuration.FHConfig.HopSet = le32_to_cpu(pnetwork->
|
||||
Configuration.FHConfig.HopSet);
|
||||
pnetwork->Configuration.FHConfig.Length = le32_to_cpu(pnetwork->
|
||||
Configuration.FHConfig.Length);
|
||||
pnetwork->Configuration.Length = le32_to_cpu(pnetwork->
|
||||
Configuration.Length);
|
||||
pnetwork->InfrastructureMode = le32_to_cpu(pnetwork->
|
||||
InfrastructureMode);
|
||||
pnetwork->IELength = le32_to_cpu(pnetwork->IELength);
|
||||
#endif
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
if ((pmlmepriv->fw_state) & WIFI_AP_STATE) {
|
||||
psta = r8712_get_stainfo(&padapter->stapriv,
|
||||
pnetwork->MacAddress);
|
||||
if (!psta) {
|
||||
psta = r8712_alloc_stainfo(&padapter->stapriv,
|
||||
pnetwork->MacAddress);
|
||||
if (psta == NULL)
|
||||
goto createbss_cmd_fail ;
|
||||
}
|
||||
r8712_indicate_connect(padapter);
|
||||
} else {
|
||||
pwlan = _r8712_alloc_network(pmlmepriv);
|
||||
if (pwlan == NULL) {
|
||||
pwlan = r8712_get_oldest_wlan_network(
|
||||
&pmlmepriv->scanned_queue);
|
||||
if (pwlan == NULL)
|
||||
goto createbss_cmd_fail;
|
||||
pwlan->last_scanned = jiffies;
|
||||
} else
|
||||
list_insert_tail(&(pwlan->list),
|
||||
&pmlmepriv->scanned_queue.queue);
|
||||
pnetwork->Length = r8712_get_ndis_wlan_bssid_ex_sz(pnetwork);
|
||||
memcpy(&(pwlan->network), pnetwork, pnetwork->Length);
|
||||
pwlan->fixed = true;
|
||||
memcpy(&tgt_network->network, pnetwork,
|
||||
(r8712_get_ndis_wlan_bssid_ex_sz(pnetwork)));
|
||||
if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
|
||||
pmlmepriv->fw_state ^= _FW_UNDER_LINKING;
|
||||
/* we will set _FW_LINKED when there is one more sat to
|
||||
* join us (stassoc_event_callback) */
|
||||
}
|
||||
createbss_cmd_fail:
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
r8712_free_cmd_obj(pcmd);
|
||||
}
|
||||
|
||||
void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd)
|
||||
{
|
||||
struct sta_priv *pstapriv = &padapter->stapriv;
|
||||
struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)
|
||||
(pcmd->rsp);
|
||||
struct sta_info *psta = r8712_get_stainfo(pstapriv,
|
||||
psetstakey_rsp->addr);
|
||||
|
||||
if (psta == NULL)
|
||||
goto exit;
|
||||
psta->aid = psta->mac_id = psetstakey_rsp->keyid; /*CAM_ID(CAM_ENTRY)*/
|
||||
exit:
|
||||
r8712_free_cmd_obj(pcmd);
|
||||
}
|
||||
|
||||
void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct sta_priv *pstapriv = &padapter->stapriv;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
struct set_assocsta_parm *passocsta_parm =
|
||||
(struct set_assocsta_parm *)(pcmd->parmbuf);
|
||||
struct set_assocsta_rsp *passocsta_rsp =
|
||||
(struct set_assocsta_rsp *) (pcmd->rsp);
|
||||
struct sta_info *psta = r8712_get_stainfo(pstapriv,
|
||||
passocsta_parm->addr);
|
||||
|
||||
if (psta == NULL)
|
||||
return;
|
||||
psta->aid = psta->mac_id = passocsta_rsp->cam_id;
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
if ((check_fwstate(pmlmepriv, WIFI_MP_STATE)) &&
|
||||
(check_fwstate(pmlmepriv, _FW_UNDER_LINKING)))
|
||||
pmlmepriv->fw_state ^= _FW_UNDER_LINKING;
|
||||
set_fwstate(pmlmepriv, _FW_LINKED);
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
r8712_free_cmd_obj(pcmd);
|
||||
}
|
719
drivers/staging/rtl8712/rtl871x_cmd.h
Normal file
719
drivers/staging/rtl8712/rtl871x_cmd.h
Normal file
@ -0,0 +1,719 @@
|
||||
#ifndef __RTL871X_CMD_H_
|
||||
#define __RTL871X_CMD_H_
|
||||
|
||||
#include "wlan_bssdef.h"
|
||||
#include "rtl871x_rf.h"
|
||||
#define C2H_MEM_SZ (16*1024)
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "ieee80211.h"
|
||||
|
||||
#define FREE_CMDOBJ_SZ 128
|
||||
#define MAX_CMDSZ 512
|
||||
#define MAX_RSPSZ 512
|
||||
#define MAX_EVTSZ 1024
|
||||
#define CMDBUFF_ALIGN_SZ 512
|
||||
|
||||
struct cmd_obj {
|
||||
u16 cmdcode;
|
||||
u8 res;
|
||||
u8 *parmbuf;
|
||||
u32 cmdsz;
|
||||
u8 *rsp;
|
||||
u32 rspsz;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
struct cmd_priv {
|
||||
struct semaphore cmd_queue_sema;
|
||||
struct semaphore terminate_cmdthread_sema;
|
||||
struct __queue cmd_queue;
|
||||
u8 cmd_seq;
|
||||
u8 *cmd_buf; /*shall be non-paged, and 4 bytes aligned*/
|
||||
u8 *cmd_allocated_buf;
|
||||
u8 *rsp_buf; /*shall be non-paged, and 4 bytes aligned*/
|
||||
u8 *rsp_allocated_buf;
|
||||
u32 cmd_issued_cnt;
|
||||
u32 cmd_done_cnt;
|
||||
u32 rsp_cnt;
|
||||
struct _adapter *padapter;
|
||||
};
|
||||
|
||||
struct evt_obj {
|
||||
u16 evtcode;
|
||||
u8 res;
|
||||
u8 *parmbuf;
|
||||
u32 evtsz;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
struct evt_priv {
|
||||
struct __queue evt_queue;
|
||||
u8 event_seq;
|
||||
u8 *evt_buf; /*shall be non-paged, and 4 bytes aligned*/
|
||||
u8 *evt_allocated_buf;
|
||||
u32 evt_done_cnt;
|
||||
struct tasklet_struct event_tasklet;
|
||||
};
|
||||
|
||||
#define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
|
||||
do {\
|
||||
_init_listhead(&pcmd->list);\
|
||||
pcmd->cmdcode = code;\
|
||||
pcmd->parmbuf = (u8 *)(pparm);\
|
||||
pcmd->cmdsz = sizeof(*pparm);\
|
||||
pcmd->rsp = NULL;\
|
||||
pcmd->rspsz = 0;\
|
||||
} while (0)
|
||||
|
||||
u32 r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
|
||||
u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
|
||||
struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue);
|
||||
void r8712_free_cmd_obj(struct cmd_obj *pcmd);
|
||||
int r8712_cmd_thread(void *context);
|
||||
u32 r8712_init_cmd_priv(struct cmd_priv *pcmdpriv);
|
||||
void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv);
|
||||
u32 r8712_init_evt_priv(struct evt_priv *pevtpriv);
|
||||
void r8712_free_evt_priv(struct evt_priv *pevtpriv);
|
||||
|
||||
enum rtl871x_drvint_cid {
|
||||
NONE_WK_CID,
|
||||
WDG_WK_CID,
|
||||
MAX_WK_CID
|
||||
};
|
||||
|
||||
enum RFINTFS {
|
||||
SWSI,
|
||||
HWSI,
|
||||
HWPI,
|
||||
};
|
||||
|
||||
/*
|
||||
* Caller Mode: Infra, Ad-HoC(C)
|
||||
* Notes: To enter USB suspend mode
|
||||
* Command Mode
|
||||
*/
|
||||
struct usb_suspend_parm {
|
||||
u32 action; /* 1: sleep, 0:resume */
|
||||
};
|
||||
|
||||
/*
|
||||
* Caller Mode: Infra, Ad-Hoc
|
||||
* Notes: To join the specified bss
|
||||
* Command Event Mode
|
||||
*/
|
||||
struct joinbss_parm {
|
||||
struct ndis_wlan_bssid_ex network;
|
||||
};
|
||||
|
||||
/*
|
||||
* Caller Mode: Infra, Ad-HoC(C)
|
||||
* Notes: To disconnect the current associated BSS
|
||||
* Command Mode
|
||||
*/
|
||||
struct disconnect_parm {
|
||||
u32 rsvd;
|
||||
};
|
||||
|
||||
/*
|
||||
* Caller Mode: AP, Ad-HoC(M)
|
||||
* Notes: To create a BSS
|
||||
* Command Mode
|
||||
*/
|
||||
struct createbss_parm {
|
||||
struct ndis_wlan_bssid_ex network;
|
||||
};
|
||||
|
||||
/*
|
||||
* Caller Mode: AP, Ad-HoC, Infra
|
||||
* Notes: To set the NIC mode of RTL8711
|
||||
* Command Mode
|
||||
* The definition of mode:
|
||||
*
|
||||
* #define IW_MODE_AUTO 0 // Let the driver decides which AP to join
|
||||
* #define IW_MODE_ADHOC 1 // Single cell network (Ad-Hoc Clients)
|
||||
* #define IW_MODE_INFRA 2 // Multi cell network, roaming, ..
|
||||
* #define IW_MODE_MASTER 3 // Synchronisation master or AP
|
||||
* #define IW_MODE_REPEAT 4 // Wireless Repeater (forwarder)
|
||||
* #define IW_MODE_SECOND 5 // Secondary master/repeater (backup)
|
||||
* #define IW_MODE_MONITOR 6 // Passive monitor (listen only)
|
||||
*/
|
||||
struct setopmode_parm {
|
||||
u8 mode;
|
||||
u8 rsvd[3];
|
||||
};
|
||||
|
||||
/*
|
||||
* Caller Mode: AP, Ad-HoC, Infra
|
||||
* Notes: To ask RTL8711 performing site-survey
|
||||
* Command-Event Mode
|
||||
*/
|
||||
struct sitesurvey_parm {
|
||||
sint passive_mode; /*active: 1, passive: 0 */
|
||||
sint bsslimit; /* 1 ~ 48 */
|
||||
sint ss_ssidlen;
|
||||
u8 ss_ssid[IW_ESSID_MAX_SIZE + 1];
|
||||
};
|
||||
|
||||
/*
|
||||
* Caller Mode: Any
|
||||
* Notes: To set the auth type of RTL8711. open/shared/802.1x
|
||||
* Command Mode
|
||||
*/
|
||||
struct setauth_parm {
|
||||
u8 mode; /*0: legacy open, 1: legacy shared 2: 802.1x*/
|
||||
u8 _1x; /*0: PSK, 1: TLS*/
|
||||
u8 rsvd[2];
|
||||
};
|
||||
|
||||
/*
|
||||
* Caller Mode: Infra
|
||||
* a. algorithm: wep40, wep104, tkip & aes
|
||||
* b. keytype: grp key/unicast key
|
||||
* c. key contents
|
||||
*
|
||||
* when shared key ==> keyid is the camid
|
||||
* when 802.1x ==> keyid [0:1] ==> grp key
|
||||
* when 802.1x ==> keyid > 2 ==> unicast key
|
||||
*/
|
||||
struct setkey_parm {
|
||||
u8 algorithm; /* encryption algorithm, could be none, wep40,
|
||||
* TKIP, CCMP, wep104 */
|
||||
u8 keyid;
|
||||
u8 grpkey; /* 1: this is the grpkey for 802.1x.
|
||||
* 0: this is the unicast key for 802.1x */
|
||||
u8 key[16]; /* this could be 40 or 104 */
|
||||
};
|
||||
|
||||
/*
|
||||
* When in AP or Ad-Hoc mode, this is used to
|
||||
* allocate an sw/hw entry for a newly associated sta.
|
||||
* Command
|
||||
* when shared key ==> algorithm/keyid
|
||||
*/
|
||||
struct set_stakey_parm {
|
||||
u8 addr[ETH_ALEN];
|
||||
u8 algorithm;
|
||||
u8 key[16];
|
||||
};
|
||||
|
||||
struct set_stakey_rsp {
|
||||
u8 addr[ETH_ALEN];
|
||||
u8 keyid;
|
||||
u8 rsvd;
|
||||
};
|
||||
|
||||
struct SetMacAddr_param {
|
||||
u8 MacAddr[ETH_ALEN];
|
||||
};
|
||||
|
||||
/*
|
||||
Caller Ad-Hoc/AP
|
||||
|
||||
Command -Rsp(AID == CAMID) mode
|
||||
|
||||
This is to force fw to add an sta_data entry per driver's request.
|
||||
|
||||
FW will write an cam entry associated with it.
|
||||
|
||||
*/
|
||||
struct set_assocsta_parm {
|
||||
u8 addr[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct set_assocsta_rsp {
|
||||
u8 cam_id;
|
||||
u8 rsvd[3];
|
||||
};
|
||||
|
||||
/*
|
||||
Caller Ad-Hoc/AP
|
||||
|
||||
Command mode
|
||||
|
||||
This is to force fw to del an sta_data entry per driver's request
|
||||
|
||||
FW will invalidate the cam entry associated with it.
|
||||
|
||||
*/
|
||||
struct del_assocsta_parm {
|
||||
u8 addr[ETH_ALEN];
|
||||
};
|
||||
|
||||
/*
|
||||
Caller Mode: AP/Ad-HoC(M)
|
||||
|
||||
Notes: To notify fw that given staid has changed its power state
|
||||
|
||||
Command Mode
|
||||
|
||||
*/
|
||||
struct setstapwrstate_parm {
|
||||
u8 staid;
|
||||
u8 status;
|
||||
u8 hwaddr[6];
|
||||
};
|
||||
|
||||
/*
|
||||
Caller Mode: Any
|
||||
|
||||
Notes: To setup the basic rate of RTL8711
|
||||
|
||||
Command Mode
|
||||
|
||||
*/
|
||||
struct setbasicrate_parm {
|
||||
u8 basicrates[NumRates];
|
||||
};
|
||||
|
||||
/*
|
||||
Caller Mode: Any
|
||||
|
||||
Notes: To read the current basic rate
|
||||
|
||||
Command-Rsp Mode
|
||||
|
||||
*/
|
||||
struct getbasicrate_parm {
|
||||
u32 rsvd;
|
||||
};
|
||||
|
||||
struct getbasicrate_rsp {
|
||||
u8 basicrates[NumRates];
|
||||
};
|
||||
|
||||
/*
|
||||
Caller Mode: Any
|
||||
|
||||
Notes: To setup the data rate of RTL8711
|
||||
|
||||
Command Mode
|
||||
|
||||
*/
|
||||
struct setdatarate_parm {
|
||||
u8 mac_id;
|
||||
u8 datarates[NumRates];
|
||||
};
|
||||
|
||||
/*
|
||||
Caller Mode: Any
|
||||
|
||||
Notes: To read the current data rate
|
||||
|
||||
Command-Rsp Mode
|
||||
|
||||
*/
|
||||
struct getdatarate_parm {
|
||||
u32 rsvd;
|
||||
|
||||
};
|
||||
struct getdatarate_rsp {
|
||||
u8 datarates[NumRates];
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Caller Mode: Any
|
||||
AP: AP can use the info for the contents of beacon frame
|
||||
Infra: STA can use the info when sitesurveying
|
||||
Ad-HoC(M): Like AP
|
||||
Ad-HoC(C): Like STA
|
||||
|
||||
|
||||
Notes: To set the phy capability of the NIC
|
||||
|
||||
Command Mode
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Caller Mode: Any
|
||||
|
||||
Notes: To set the channel/modem/band
|
||||
This command will be used when channel/modem/band is changed.
|
||||
|
||||
Command Mode
|
||||
|
||||
*/
|
||||
/*
|
||||
Caller Mode: Any
|
||||
|
||||
Notes: To get the current setting of channel/modem/band
|
||||
|
||||
Command-Rsp Mode
|
||||
|
||||
*/
|
||||
struct getphy_rsp {
|
||||
u8 rfchannel;
|
||||
u8 modem;
|
||||
};
|
||||
|
||||
struct readBB_parm {
|
||||
u8 offset;
|
||||
};
|
||||
struct readBB_rsp {
|
||||
u8 value;
|
||||
};
|
||||
|
||||
struct readTSSI_parm {
|
||||
u8 offset;
|
||||
};
|
||||
struct readTSSI_rsp {
|
||||
u8 value;
|
||||
};
|
||||
|
||||
struct writeBB_parm {
|
||||
u8 offset;
|
||||
u8 value;
|
||||
};
|
||||
|
||||
struct readRF_parm {
|
||||
u8 offset;
|
||||
};
|
||||
struct readRF_rsp {
|
||||
u32 value;
|
||||
};
|
||||
|
||||
struct writeRF_parm {
|
||||
u32 offset;
|
||||
u32 value;
|
||||
};
|
||||
|
||||
struct setrfintfs_parm {
|
||||
u8 rfintfs;
|
||||
};
|
||||
|
||||
struct getrfintfs_parm {
|
||||
u8 rfintfs;
|
||||
};
|
||||
|
||||
/*
|
||||
Notes: This command is used for H2C/C2H loopback testing
|
||||
|
||||
mac[0] == 0
|
||||
==> CMD mode, return H2C_SUCCESS.
|
||||
The following condition must be ture under CMD mode
|
||||
mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
|
||||
s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
|
||||
s2 == (b1 << 8 | b0);
|
||||
|
||||
mac[0] == 1
|
||||
==> CMD_RSP mode, return H2C_SUCCESS_RSP
|
||||
|
||||
The rsp layout shall be:
|
||||
rsp: parm:
|
||||
mac[0] = mac[5];
|
||||
mac[1] = mac[4];
|
||||
mac[2] = mac[3];
|
||||
mac[3] = mac[2];
|
||||
mac[4] = mac[1];
|
||||
mac[5] = mac[0];
|
||||
s0 = s1;
|
||||
s1 = swap16(s0);
|
||||
w0 = swap32(w1);
|
||||
b0 = b1
|
||||
s2 = s0 + s1
|
||||
b1 = b0
|
||||
w1 = w0
|
||||
|
||||
mac[0] == 2
|
||||
==> CMD_EVENT mode, return H2C_SUCCESS
|
||||
The event layout shall be:
|
||||
event: parm:
|
||||
mac[0] = mac[5];
|
||||
mac[1] = mac[4];
|
||||
mac[2] = event's sequence number, starting from 1 to parm's marc[3]
|
||||
mac[3] = mac[2];
|
||||
mac[4] = mac[1];
|
||||
mac[5] = mac[0];
|
||||
s0 = swap16(s0) - event.mac[2];
|
||||
s1 = s1 + event.mac[2];
|
||||
w0 = swap32(w0);
|
||||
b0 = b1
|
||||
s2 = s0 + event.mac[2]
|
||||
b1 = b0
|
||||
w1 = swap32(w1) - event.mac[2];
|
||||
|
||||
parm->mac[3] is the total event counts that host requested.
|
||||
|
||||
|
||||
event will be the same with the cmd's param.
|
||||
|
||||
*/
|
||||
|
||||
/* CMD param Formart for DRV INTERNAL CMD HDL*/
|
||||
struct drvint_cmd_parm {
|
||||
int i_cid; /*internal cmd id*/
|
||||
int sz; /* buf sz*/
|
||||
unsigned char *pbuf;
|
||||
};
|
||||
|
||||
/*------------------- Below are used for RF/BB tunning ---------------------*/
|
||||
|
||||
struct setantenna_parm {
|
||||
u8 tx_antset;
|
||||
u8 rx_antset;
|
||||
u8 tx_antenna;
|
||||
u8 rx_antenna;
|
||||
};
|
||||
|
||||
struct enrateadaptive_parm {
|
||||
u32 en;
|
||||
};
|
||||
|
||||
struct settxagctbl_parm {
|
||||
u32 txagc[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct gettxagctbl_parm {
|
||||
u32 rsvd;
|
||||
};
|
||||
struct gettxagctbl_rsp {
|
||||
u32 txagc[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct setagcctrl_parm {
|
||||
u32 agcctrl; /* 0: pure hw, 1: fw */
|
||||
};
|
||||
|
||||
struct setssup_parm {
|
||||
u32 ss_ForceUp[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct getssup_parm {
|
||||
u32 rsvd;
|
||||
};
|
||||
struct getssup_rsp {
|
||||
u8 ss_ForceUp[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct setssdlevel_parm {
|
||||
u8 ss_DLevel[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct getssdlevel_parm {
|
||||
u32 rsvd;
|
||||
};
|
||||
struct getssdlevel_rsp {
|
||||
u8 ss_DLevel[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct setssulevel_parm {
|
||||
u8 ss_ULevel[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct getssulevel_parm {
|
||||
u32 rsvd;
|
||||
};
|
||||
struct getssulevel_rsp {
|
||||
u8 ss_ULevel[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct setcountjudge_parm {
|
||||
u8 count_judge[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct getcountjudge_parm {
|
||||
u32 rsvd;
|
||||
};
|
||||
|
||||
struct getcountjudge_rsp {
|
||||
u8 count_judge[MAX_RATES_LENGTH];
|
||||
};
|
||||
|
||||
struct setpwrmode_parm {
|
||||
u8 mode;
|
||||
u8 flag_low_traffic_en;
|
||||
u8 flag_lpnav_en;
|
||||
u8 flag_rf_low_snr_en;
|
||||
u8 flag_dps_en; /* 1: dps, 0: 32k */
|
||||
u8 bcn_rx_en;
|
||||
u8 bcn_pass_cnt; /* fw report one beacon information to
|
||||
* driver when it receives bcn_pass_cnt
|
||||
* beacons. */
|
||||
u8 bcn_to; /* beacon TO (ms). ¡§=0¡¨ no limit.*/
|
||||
u16 bcn_itv;
|
||||
u8 app_itv; /* only for VOIP mode. */
|
||||
u8 awake_bcn_itv;
|
||||
u8 smart_ps;
|
||||
u8 bcn_pass_time; /* unit: 100ms */
|
||||
};
|
||||
|
||||
struct setatim_parm {
|
||||
u8 op; /*0: add, 1:del*/
|
||||
u8 txid; /* id of dest station.*/
|
||||
};
|
||||
|
||||
struct setratable_parm {
|
||||
u8 ss_ForceUp[NumRates];
|
||||
u8 ss_ULevel[NumRates];
|
||||
u8 ss_DLevel[NumRates];
|
||||
u8 count_judge[NumRates];
|
||||
};
|
||||
|
||||
struct getratable_parm {
|
||||
uint rsvd;
|
||||
};
|
||||
struct getratable_rsp {
|
||||
u8 ss_ForceUp[NumRates];
|
||||
u8 ss_ULevel[NumRates];
|
||||
u8 ss_DLevel[NumRates];
|
||||
u8 count_judge[NumRates];
|
||||
};
|
||||
|
||||
/*to get TX,RX retry count*/
|
||||
struct gettxretrycnt_parm{
|
||||
unsigned int rsvd;
|
||||
};
|
||||
|
||||
struct gettxretrycnt_rsp{
|
||||
unsigned long tx_retrycnt;
|
||||
};
|
||||
|
||||
struct getrxretrycnt_parm{
|
||||
unsigned int rsvd;
|
||||
};
|
||||
|
||||
struct getrxretrycnt_rsp{
|
||||
unsigned long rx_retrycnt;
|
||||
};
|
||||
|
||||
/*to get BCNOK,BCNERR count*/
|
||||
struct getbcnokcnt_parm{
|
||||
unsigned int rsvd;
|
||||
};
|
||||
|
||||
struct getbcnokcnt_rsp{
|
||||
unsigned long bcnokcnt;
|
||||
};
|
||||
|
||||
struct getbcnerrcnt_parm{
|
||||
unsigned int rsvd;
|
||||
};
|
||||
struct getbcnerrcnt_rsp{
|
||||
unsigned long bcnerrcnt;
|
||||
};
|
||||
|
||||
/* to get current TX power level*/
|
||||
struct getcurtxpwrlevel_parm{
|
||||
unsigned int rsvd;
|
||||
};
|
||||
|
||||
struct getcurtxpwrlevel_rsp{
|
||||
unsigned short tx_power;
|
||||
};
|
||||
|
||||
/*dynamic on/off DIG*/
|
||||
struct setdig_parm{
|
||||
unsigned char dig_on; /* 1:on , 0:off */
|
||||
};
|
||||
|
||||
/*dynamic on/off RA*/
|
||||
struct setra_parm{
|
||||
unsigned char ra_on; /* 1:on , 0:off */
|
||||
};
|
||||
|
||||
struct setprobereqextraie_parm {
|
||||
unsigned char e_id;
|
||||
unsigned char ie_len;
|
||||
unsigned char ie[0];
|
||||
};
|
||||
|
||||
struct setassocreqextraie_parm {
|
||||
unsigned char e_id;
|
||||
unsigned char ie_len;
|
||||
unsigned char ie[0];
|
||||
};
|
||||
|
||||
struct setproberspextraie_parm {
|
||||
unsigned char e_id;
|
||||
unsigned char ie_len;
|
||||
unsigned char ie[0];
|
||||
};
|
||||
|
||||
struct setassocrspextraie_parm {
|
||||
unsigned char e_id;
|
||||
unsigned char ie_len;
|
||||
unsigned char ie[0];
|
||||
};
|
||||
|
||||
struct addBaReq_parm {
|
||||
unsigned int tid;
|
||||
};
|
||||
|
||||
/*H2C Handler index: 46 */
|
||||
struct SetChannel_parm {
|
||||
u32 curr_ch;
|
||||
};
|
||||
|
||||
/*H2C Handler index: 56 */
|
||||
struct PT_param {
|
||||
u8 PT_En;
|
||||
};
|
||||
|
||||
#define GEN_CMD_CODE(cmd) cmd ## _CMD_
|
||||
|
||||
/*
|
||||
* Result:
|
||||
* 0x00: success
|
||||
* 0x01: sucess, and check Response.
|
||||
* 0x02: cmd ignored due to duplicated sequcne number
|
||||
* 0x03: cmd dropped due to invalid cmd code
|
||||
* 0x04: reserved.
|
||||
*/
|
||||
|
||||
#define H2C_RSP_OFFSET 512
|
||||
#define H2C_SUCCESS 0x00
|
||||
#define H2C_SUCCESS_RSP 0x01
|
||||
#define H2C_DUPLICATED 0x02
|
||||
#define H2C_DROPPED 0x03
|
||||
#define H2C_PARAMETERS_ERROR 0x04
|
||||
#define H2C_REJECTED 0x05
|
||||
#define H2C_CMD_OVERFLOW 0x06
|
||||
#define H2C_RESERVED 0x07
|
||||
|
||||
u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr);
|
||||
u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr);
|
||||
u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
|
||||
struct ndis_802_11_ssid *pssid);
|
||||
u8 r8712_createbss_cmd(struct _adapter *padapter);
|
||||
u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key);
|
||||
u8 r8712_joinbss_cmd(struct _adapter *padapter,
|
||||
struct wlan_network *pnetwork);
|
||||
u8 r8712_disassoc_cmd(struct _adapter *padapter);
|
||||
u8 r8712_setopmode_cmd(struct _adapter *padapter,
|
||||
enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
|
||||
u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset);
|
||||
u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset);
|
||||
u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 * pval);
|
||||
u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode);
|
||||
u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val);
|
||||
u8 r8712_setrttbl_cmd(struct _adapter *padapter,
|
||||
struct setratable_parm *prate_table);
|
||||
u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type);
|
||||
u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid);
|
||||
u8 r8712_wdg_wk_cmd(struct _adapter *padapter);
|
||||
void r8712_survey_cmd_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd);
|
||||
void r8712_disassoc_cmd_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd);
|
||||
void r8712_joinbss_cmd_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd);
|
||||
void r8712_createbss_cmd_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd);
|
||||
void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd);
|
||||
void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd);
|
||||
void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter,
|
||||
struct cmd_obj *pcmd);
|
||||
|
||||
struct _cmd_callback {
|
||||
u32 cmd_code;
|
||||
void (*callback)(struct _adapter *padapter, struct cmd_obj *cmd);
|
||||
};
|
||||
|
||||
#include "rtl8712_cmd.h"
|
||||
|
||||
#endif /* _CMD_H_ */
|
||||
|
142
drivers/staging/rtl8712/rtl871x_debug.h
Normal file
142
drivers/staging/rtl8712/rtl871x_debug.h
Normal file
@ -0,0 +1,142 @@
|
||||
#ifndef __RTL871X_DEBUG_H__
|
||||
#define __RTL871X_DEBUG_H__
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
|
||||
|
||||
#define _drv_emerg_ 1
|
||||
#define _drv_alert_ 2
|
||||
#define _drv_crit_ 3
|
||||
#define _drv_err_ 4
|
||||
#define _drv_warning_ 5
|
||||
#define _drv_notice_ 6
|
||||
#define _drv_info_ 7
|
||||
#define _drv_dump_ 8
|
||||
#define _drv_debug_ 9
|
||||
|
||||
|
||||
#define _module_rtl871x_xmit_c_ BIT(0)
|
||||
#define _module_xmit_osdep_c_ BIT(1)
|
||||
#define _module_rtl871x_recv_c_ BIT(2)
|
||||
#define _module_recv_osdep_c_ BIT(3)
|
||||
#define _module_rtl871x_mlme_c_ BIT(4)
|
||||
#define _module_mlme_osdep_c_ BIT(5)
|
||||
#define _module_rtl871x_sta_mgt_c_ BIT(6)
|
||||
#define _module_rtl871x_cmd_c_ BIT(7)
|
||||
#define _module_cmd_osdep_c_ BIT(8)
|
||||
#define _module_rtl871x_io_c_ BIT(9)
|
||||
#define _module_io_osdep_c_ BIT(10)
|
||||
#define _module_os_intfs_c_ BIT(11)
|
||||
#define _module_rtl871x_security_c_ BIT(12)
|
||||
#define _module_rtl871x_eeprom_c_ BIT(13)
|
||||
#define _module_hal_init_c_ BIT(14)
|
||||
#define _module_hci_hal_init_c_ BIT(15)
|
||||
#define _module_rtl871x_ioctl_c_ BIT(16)
|
||||
#define _module_rtl871x_ioctl_set_c_ BIT(17)
|
||||
#define _module_rtl871x_pwrctrl_c_ BIT(19)
|
||||
#define _module_hci_intfs_c_ BIT(20)
|
||||
#define _module_hci_ops_c_ BIT(21)
|
||||
#define _module_osdep_service_c_ BIT(22)
|
||||
#define _module_rtl871x_mp_ioctl_c_ BIT(23)
|
||||
#define _module_hci_ops_os_c_ BIT(24)
|
||||
#define _module_rtl871x_ioctl_os_c BIT(25)
|
||||
#define _module_rtl8712_cmd_c_ BIT(26)
|
||||
#define _module_rtl871x_mp_c_ BIT(27)
|
||||
#define _module_rtl8712_xmit_c_ BIT(28)
|
||||
#define _module_rtl8712_efuse_c_ BIT(29)
|
||||
#define _module_rtl8712_recv_c_ BIT(30)
|
||||
#define _module_rtl8712_led_c_ BIT(31)
|
||||
|
||||
#undef _MODULE_DEFINE_
|
||||
|
||||
#if defined _RTL871X_XMIT_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_xmit_c_
|
||||
#elif defined _XMIT_OSDEP_C_
|
||||
#define _MODULE_DEFINE_ _module_xmit_osdep_c_
|
||||
#elif defined _RTL871X_RECV_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_recv_c_
|
||||
#elif defined _RECV_OSDEP_C_
|
||||
#define _MODULE_DEFINE_ _module_recv_osdep_c_
|
||||
#elif defined _RTL871X_MLME_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_mlme_c_
|
||||
#elif defined _MLME_OSDEP_C_
|
||||
#define _MODULE_DEFINE_ _module_mlme_osdep_c_
|
||||
#elif defined _RTL871X_STA_MGT_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_sta_mgt_c_
|
||||
#elif defined _RTL871X_CMD_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_cmd_c_
|
||||
#elif defined _CMD_OSDEP_C_
|
||||
#define _MODULE_DEFINE_ _module_cmd_osdep_c_
|
||||
#elif defined _RTL871X_IO_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_io_c_
|
||||
#elif defined _IO_OSDEP_C_
|
||||
#define _MODULE_DEFINE_ _module_io_osdep_c_
|
||||
#elif defined _OS_INTFS_C_
|
||||
#define _MODULE_DEFINE_ _module_os_intfs_c_
|
||||
#elif defined _RTL871X_SECURITY_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_security_c_
|
||||
#elif defined _RTL871X_EEPROM_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_eeprom_c_
|
||||
#elif defined _HAL_INIT_C_
|
||||
#define _MODULE_DEFINE_ _module_hal_init_c_
|
||||
#elif defined _HCI_HAL_INIT_C_
|
||||
#define _MODULE_DEFINE_ _module_hci_hal_init_c_
|
||||
#elif defined _RTL871X_IOCTL_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_ioctl_c_
|
||||
#elif defined _RTL871X_IOCTL_SET_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_ioctl_set_c_
|
||||
#elif defined _RTL871X_PWRCTRL_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_pwrctrl_c_
|
||||
#elif defined _HCI_INTF_C_
|
||||
#define _MODULE_DEFINE_ _module_hci_intfs_c_
|
||||
#elif defined _HCI_OPS_C_
|
||||
#define _MODULE_DEFINE_ _module_hci_ops_c_
|
||||
#elif defined _OSDEP_HCI_INTF_C_
|
||||
#define _MODULE_DEFINE_ _module_hci_intfs_c_
|
||||
#elif defined _OSDEP_SERVICE_C_
|
||||
#define _MODULE_DEFINE_ _module_osdep_service_c_
|
||||
#elif defined _RTL871X_MP_IOCTL_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_mp_ioctl_c_
|
||||
#elif defined _HCI_OPS_OS_C_
|
||||
#define _MODULE_DEFINE_ _module_hci_ops_os_c_
|
||||
#elif defined _RTL871X_IOCTL_LINUX_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_ioctl_os_c
|
||||
#elif defined _RTL871X_MP_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl871x_mp_c_
|
||||
#elif defined _RTL8712_CMD_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl8712_cmd_c_
|
||||
#elif defined _RTL8712_XMIT_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl8712_xmit_c_
|
||||
#elif defined _RTL8712_EFUSE_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl8712_efuse_c_
|
||||
#elif defined _RTL8712_RECV_C_
|
||||
#define _MODULE_DEFINE_ _module_rtl8712_recv_c_
|
||||
#else
|
||||
#undef _MODULE_DEFINE_
|
||||
#endif
|
||||
|
||||
#define _dbgdump printk
|
||||
|
||||
#define MSG_8712(x, ...) {}
|
||||
|
||||
#define DBG_8712(x, ...) {}
|
||||
|
||||
#define WRN_8712(x, ...) {}
|
||||
|
||||
#define ERR_8712(x, ...) {}
|
||||
|
||||
#undef MSG_8712
|
||||
#define MSG_8712 _dbgdump
|
||||
|
||||
#undef DBG_8712
|
||||
#define DBG_8712 _dbgdump
|
||||
|
||||
#undef WRN_8712
|
||||
#define WRN_8712 _dbgdump
|
||||
|
||||
#undef ERR_8712
|
||||
#define ERR_8712 _dbgdump
|
||||
|
||||
#endif /*__RTL871X_DEBUG_H__*/
|
||||
|
233
drivers/staging/rtl8712/rtl871x_eeprom.c
Normal file
233
drivers/staging/rtl8712/rtl871x_eeprom.c
Normal file
@ -0,0 +1,233 @@
|
||||
/******************************************************************************
|
||||
* rtl871x_eeprom.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 _RTL871X_EEPROM_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
|
||||
static void up_clk(struct _adapter *padapter, u16 *x)
|
||||
{
|
||||
*x = *x | _EESK;
|
||||
r8712_write8(padapter, EE_9346CR, (u8)*x);
|
||||
udelay(CLOCK_RATE);
|
||||
}
|
||||
|
||||
static void down_clk(struct _adapter *padapter, u16 *x)
|
||||
{
|
||||
*x = *x & ~_EESK;
|
||||
r8712_write8(padapter, EE_9346CR, (u8)*x);
|
||||
udelay(CLOCK_RATE);
|
||||
}
|
||||
|
||||
static void shift_out_bits(struct _adapter *padapter, u16 data, u16 count)
|
||||
{
|
||||
u16 x, mask;
|
||||
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
goto out;
|
||||
mask = 0x01 << (count - 1);
|
||||
x = r8712_read8(padapter, EE_9346CR);
|
||||
x &= ~(_EEDO | _EEDI);
|
||||
do {
|
||||
x &= ~_EEDI;
|
||||
if (data & mask)
|
||||
x |= _EEDI;
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
goto out;
|
||||
r8712_write8(padapter, EE_9346CR, (u8)x);
|
||||
udelay(CLOCK_RATE);
|
||||
up_clk(padapter, &x);
|
||||
down_clk(padapter, &x);
|
||||
mask = mask >> 1;
|
||||
} while (mask);
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
goto out;
|
||||
x &= ~_EEDI;
|
||||
r8712_write8(padapter, EE_9346CR, (u8)x);
|
||||
out:;
|
||||
}
|
||||
|
||||
static u16 shift_in_bits(struct _adapter *padapter)
|
||||
{
|
||||
u16 x, d = 0, i;
|
||||
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
goto out;
|
||||
x = r8712_read8(padapter, EE_9346CR);
|
||||
x &= ~(_EEDO | _EEDI);
|
||||
d = 0;
|
||||
for (i = 0; i < 16; i++) {
|
||||
d = d << 1;
|
||||
up_clk(padapter, &x);
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
goto out;
|
||||
x = r8712_read8(padapter, EE_9346CR);
|
||||
x &= ~(_EEDI);
|
||||
if (x & _EEDO)
|
||||
d |= 1;
|
||||
down_clk(padapter, &x);
|
||||
}
|
||||
out:
|
||||
return d;
|
||||
}
|
||||
|
||||
static void standby(struct _adapter *padapter)
|
||||
{
|
||||
u8 x;
|
||||
|
||||
x = r8712_read8(padapter, EE_9346CR);
|
||||
x &= ~(_EECS | _EESK);
|
||||
r8712_write8(padapter, EE_9346CR, x);
|
||||
udelay(CLOCK_RATE);
|
||||
x |= _EECS;
|
||||
r8712_write8(padapter, EE_9346CR, x);
|
||||
udelay(CLOCK_RATE);
|
||||
}
|
||||
|
||||
static u16 wait_eeprom_cmd_done(struct _adapter *padapter)
|
||||
{
|
||||
u8 x;
|
||||
u16 i;
|
||||
|
||||
standby(padapter);
|
||||
for (i = 0; i < 200; i++) {
|
||||
x = r8712_read8(padapter, EE_9346CR);
|
||||
if (x & _EEDO)
|
||||
return true;
|
||||
udelay(CLOCK_RATE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void eeprom_clean(struct _adapter *padapter)
|
||||
{
|
||||
u16 x;
|
||||
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
return;
|
||||
x = r8712_read8(padapter, EE_9346CR);
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
return;
|
||||
x &= ~(_EECS | _EEDI);
|
||||
r8712_write8(padapter, EE_9346CR, (u8)x);
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
return;
|
||||
up_clk(padapter, &x);
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
return;
|
||||
down_clk(padapter, &x);
|
||||
}
|
||||
|
||||
void r8712_eeprom_write16(struct _adapter *padapter, u16 reg, u16 data)
|
||||
{
|
||||
u8 x;
|
||||
u8 tmp8_ori, tmp8_new, tmp8_clk_ori, tmp8_clk_new;
|
||||
|
||||
tmp8_ori = r8712_read8(padapter, 0x102502f1);
|
||||
tmp8_new = tmp8_ori & 0xf7;
|
||||
if (tmp8_ori != tmp8_new)
|
||||
r8712_write8(padapter, 0x102502f1, tmp8_new);
|
||||
tmp8_clk_ori = r8712_read8(padapter, 0x10250003);
|
||||
tmp8_clk_new = tmp8_clk_ori | 0x20;
|
||||
if (tmp8_clk_new != tmp8_clk_ori)
|
||||
r8712_write8(padapter, 0x10250003, tmp8_clk_new);
|
||||
x = r8712_read8(padapter, EE_9346CR);
|
||||
x &= ~(_EEDI | _EEDO | _EESK | _EEM0);
|
||||
x |= _EEM1 | _EECS;
|
||||
r8712_write8(padapter, EE_9346CR, x);
|
||||
shift_out_bits(padapter, EEPROM_EWEN_OPCODE, 5);
|
||||
if (padapter->EepromAddressSize == 8) /*CF+ and SDIO*/
|
||||
shift_out_bits(padapter, 0, 6);
|
||||
else /* USB */
|
||||
shift_out_bits(padapter, 0, 4);
|
||||
standby(padapter);
|
||||
/* Erase this particular word. Write the erase opcode and register
|
||||
* number in that order. The opcode is 3bits in length; reg is 6
|
||||
* bits long.
|
||||
*/
|
||||
standby(padapter);
|
||||
/* write the new word to the EEPROM
|
||||
* send the write opcode the EEPORM
|
||||
*/
|
||||
shift_out_bits(padapter, EEPROM_WRITE_OPCODE, 3);
|
||||
/* select which word in the EEPROM that we are writing to. */
|
||||
shift_out_bits(padapter, reg, padapter->EepromAddressSize);
|
||||
/* write the data to the selected EEPROM word. */
|
||||
shift_out_bits(padapter, data, 16);
|
||||
if (wait_eeprom_cmd_done(padapter)) {
|
||||
standby(padapter);
|
||||
shift_out_bits(padapter, EEPROM_EWDS_OPCODE, 5);
|
||||
shift_out_bits(padapter, reg, 4);
|
||||
eeprom_clean(padapter);
|
||||
}
|
||||
if (tmp8_clk_new != tmp8_clk_ori)
|
||||
r8712_write8(padapter, 0x10250003, tmp8_clk_ori);
|
||||
if (tmp8_new != tmp8_ori)
|
||||
r8712_write8(padapter, 0x102502f1, tmp8_ori);
|
||||
}
|
||||
|
||||
u16 r8712_eeprom_read16(struct _adapter *padapter, u16 reg) /*ReadEEprom*/
|
||||
{
|
||||
u16 x;
|
||||
u16 data = 0;
|
||||
u8 tmp8_ori, tmp8_new, tmp8_clk_ori, tmp8_clk_new;
|
||||
|
||||
tmp8_ori = r8712_read8(padapter, 0x102502f1);
|
||||
tmp8_new = tmp8_ori & 0xf7;
|
||||
if (tmp8_ori != tmp8_new)
|
||||
r8712_write8(padapter, 0x102502f1, tmp8_new);
|
||||
tmp8_clk_ori = r8712_read8(padapter, 0x10250003);
|
||||
tmp8_clk_new = tmp8_clk_ori | 0x20;
|
||||
if (tmp8_clk_new != tmp8_clk_ori)
|
||||
r8712_write8(padapter, 0x10250003, tmp8_clk_new);
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
goto out;
|
||||
/* select EEPROM, reset bits, set _EECS */
|
||||
x = r8712_read8(padapter, EE_9346CR);
|
||||
if (padapter->bSurpriseRemoved == true)
|
||||
goto out;
|
||||
x &= ~(_EEDI | _EEDO | _EESK | _EEM0);
|
||||
x |= _EEM1 | _EECS;
|
||||
r8712_write8(padapter, EE_9346CR, (unsigned char)x);
|
||||
/* write the read opcode and register number in that order
|
||||
* The opcode is 3bits in length, reg is 6 bits long
|
||||
*/
|
||||
shift_out_bits(padapter, EEPROM_READ_OPCODE, 3);
|
||||
shift_out_bits(padapter, reg, padapter->EepromAddressSize);
|
||||
/* Now read the data (16 bits) in from the selected EEPROM word */
|
||||
data = shift_in_bits(padapter);
|
||||
eeprom_clean(padapter);
|
||||
out:
|
||||
if (tmp8_clk_new != tmp8_clk_ori)
|
||||
r8712_write8(padapter, 0x10250003, tmp8_clk_ori);
|
||||
if (tmp8_new != tmp8_ori)
|
||||
r8712_write8(padapter, 0x102502f1, tmp8_ori);
|
||||
return data;
|
||||
}
|
||||
|
82
drivers/staging/rtl8712/rtl871x_eeprom.h
Normal file
82
drivers/staging/rtl8712/rtl871x_eeprom.h
Normal file
@ -0,0 +1,82 @@
|
||||
#ifndef __RTL871X_EEPROM_H__
|
||||
#define __RTL871X_EEPROM_H__
|
||||
|
||||
#include "osdep_service.h"
|
||||
|
||||
#define RTL8712_EEPROM_ID 0x8712
|
||||
#define EEPROM_MAX_SIZE 256
|
||||
#define CLOCK_RATE 50 /*100us*/
|
||||
|
||||
/*- EEPROM opcodes*/
|
||||
#define EEPROM_READ_OPCODE 06
|
||||
#define EEPROM_WRITE_OPCODE 05
|
||||
#define EEPROM_ERASE_OPCODE 07
|
||||
#define EEPROM_EWEN_OPCODE 19 /* Erase/write enable*/
|
||||
#define EEPROM_EWDS_OPCODE 16 /* Erase/write disable*/
|
||||
|
||||
#define EEPROM_CID_DEFAULT 0x0
|
||||
#define EEPROM_CID_ALPHA 0x1
|
||||
#define EEPROM_CID_Senao 0x3
|
||||
#define EEPROM_CID_NetCore 0x5
|
||||
#define EEPROM_CID_CAMEO 0X8
|
||||
#define EEPROM_CID_SITECOM 0x9
|
||||
#define EEPROM_CID_COREGA 0xB
|
||||
#define EEPROM_CID_EDIMAX_BELKIN 0xC
|
||||
#define EEPROM_CID_SERCOMM_BELKIN 0xE
|
||||
#define EEPROM_CID_CAMEO1 0xF
|
||||
#define EEPROM_CID_WNC_COREGA 0x12
|
||||
#define EEPROM_CID_CLEVO 0x13
|
||||
#define EEPROM_CID_WHQL 0xFE
|
||||
|
||||
enum RT_CUSTOMER_ID {
|
||||
RT_CID_DEFAULT = 0,
|
||||
RT_CID_8187_ALPHA0 = 1,
|
||||
RT_CID_8187_SERCOMM_PS = 2,
|
||||
RT_CID_8187_HW_LED = 3,
|
||||
RT_CID_8187_NETGEAR = 4,
|
||||
RT_CID_WHQL = 5,
|
||||
RT_CID_819x_CAMEO = 6,
|
||||
RT_CID_819x_RUNTOP = 7,
|
||||
RT_CID_819x_Senao = 8,
|
||||
RT_CID_TOSHIBA = 9,
|
||||
RT_CID_819x_Netcore = 10,
|
||||
RT_CID_Nettronix = 11,
|
||||
RT_CID_DLINK = 12,
|
||||
RT_CID_PRONET = 13,
|
||||
RT_CID_COREGA = 14,
|
||||
RT_CID_819x_ALPHA = 15,
|
||||
RT_CID_819x_Sitecom = 16,
|
||||
RT_CID_CCX = 17,
|
||||
RT_CID_819x_Lenovo = 18,
|
||||
RT_CID_819x_QMI = 19,
|
||||
RT_CID_819x_Edimax_Belkin = 20,
|
||||
RT_CID_819x_Sercomm_Belkin = 21,
|
||||
RT_CID_819x_CAMEO1 = 22,
|
||||
RT_CID_819x_MSI = 23,
|
||||
RT_CID_819x_Acer = 24,
|
||||
RT_CID_819x_AzWave_ASUS = 25,
|
||||
RT_CID_819x_AzWave = 26,
|
||||
RT_CID_819x_WNC_COREGA = 27,
|
||||
RT_CID_819x_CLEVO = 28,
|
||||
};
|
||||
|
||||
struct eeprom_priv {
|
||||
u8 bautoload_fail_flag;
|
||||
u8 bempty;
|
||||
u8 sys_config;
|
||||
u8 mac_addr[6];
|
||||
u8 config0;
|
||||
u16 channel_plan;
|
||||
u8 country_string[3];
|
||||
u8 tx_power_b[15];
|
||||
u8 tx_power_g[15];
|
||||
u8 tx_power_a[201];
|
||||
u8 efuse_eeprom_data[EEPROM_MAX_SIZE];
|
||||
enum RT_CUSTOMER_ID CustomerID;
|
||||
};
|
||||
|
||||
void r8712_eeprom_write16(struct _adapter *padapter, u16 reg, u16 data);
|
||||
u16 r8712_eeprom_read16(struct _adapter *padapter, u16 reg);
|
||||
|
||||
#endif /*__RTL871X_EEPROM_H__*/
|
||||
|
95
drivers/staging/rtl8712/rtl871x_event.h
Normal file
95
drivers/staging/rtl8712/rtl871x_event.h
Normal file
@ -0,0 +1,95 @@
|
||||
#ifndef _RTL871x_EVENT_H_
|
||||
#define _RTL871x_EVENT_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
|
||||
#include "wlan_bssdef.h"
|
||||
#include <linux/semaphore.h>
|
||||
#include <linux/sem.h>
|
||||
|
||||
/*
|
||||
* Used to report a bss has been scanned
|
||||
*/
|
||||
struct survey_event {
|
||||
struct ndis_wlan_bssid_ex bss;
|
||||
};
|
||||
|
||||
/*
|
||||
* Used to report that the requested site survey has been done.
|
||||
* bss_cnt indicates the number of bss that has been reported.
|
||||
*/
|
||||
struct surveydone_event {
|
||||
unsigned int bss_cnt;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Used to report the link result of joinning the given bss
|
||||
* join_res:
|
||||
* -1: authentication fail
|
||||
* -2: association fail
|
||||
* > 0: TID
|
||||
*/
|
||||
struct joinbss_event {
|
||||
struct wlan_network network;
|
||||
};
|
||||
|
||||
/*
|
||||
* Used to report a given STA has joinned the created BSS.
|
||||
* It is used in AP/Ad-HoC(M) mode.
|
||||
*/
|
||||
struct stassoc_event {
|
||||
unsigned char macaddr[6];
|
||||
unsigned char rsvd[2];
|
||||
int cam_id;
|
||||
};
|
||||
|
||||
struct stadel_event {
|
||||
unsigned char macaddr[6];
|
||||
unsigned char rsvd[2];
|
||||
};
|
||||
|
||||
struct addba_event {
|
||||
unsigned int tid;
|
||||
};
|
||||
|
||||
#define GEN_EVT_CODE(event) event ## _EVT_
|
||||
|
||||
struct fwevent {
|
||||
u32 parmsize;
|
||||
void (*event_callback)(struct _adapter *dev, u8 *pbuf);
|
||||
};
|
||||
|
||||
#define C2HEVENT_SZ 32
|
||||
struct event_node{
|
||||
unsigned char *node;
|
||||
unsigned char evt_code;
|
||||
unsigned short evt_sz;
|
||||
/*volatile*/ int *caller_ff_tail;
|
||||
int caller_ff_sz;
|
||||
};
|
||||
|
||||
struct c2hevent_queue {
|
||||
/*volatile*/ int head;
|
||||
/*volatile*/ int tail;
|
||||
struct event_node nodes[C2HEVENT_SZ];
|
||||
unsigned char seq;
|
||||
};
|
||||
|
||||
#define NETWORK_QUEUE_SZ 4
|
||||
|
||||
struct network_queue {
|
||||
/*volatile*/ int head;
|
||||
/*volatile*/ int tail;
|
||||
struct wlan_bssid_ex networks[NETWORK_QUEUE_SZ];
|
||||
};
|
||||
|
||||
struct ADDBA_Req_Report_parm {
|
||||
unsigned char MacAddress[ETH_ALEN];
|
||||
unsigned short StartSeqNum;
|
||||
unsigned char tid;
|
||||
};
|
||||
#include "rtl8712_event.h"
|
||||
|
||||
#endif /* _WLANEVENT_H_ */
|
||||
|
19
drivers/staging/rtl8712/rtl871x_ht.h
Normal file
19
drivers/staging/rtl8712/rtl871x_ht.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef _RTL871X_HT_H_
|
||||
#define _RTL871X_HT_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "wifi.h"
|
||||
|
||||
struct ht_priv {
|
||||
unsigned int ht_option;
|
||||
unsigned int ampdu_enable;/*for enable Tx A-MPDU*/
|
||||
unsigned char baddbareq_issued[16];
|
||||
unsigned int tx_amsdu_enable;/*for enable Tx A-MSDU */
|
||||
unsigned int tx_amdsu_maxlen; /* 1: 8k, 0:4k ; default:8k, for tx */
|
||||
unsigned int rx_ampdu_maxlen; /* for rx reordering ctrl win_sz,
|
||||
* updated when join_callback. */
|
||||
struct ieee80211_ht_cap ht_cap;
|
||||
};
|
||||
|
||||
#endif /*_RTL871X_HT_H_ */
|
||||
|
163
drivers/staging/rtl8712/rtl871x_io.c
Normal file
163
drivers/staging/rtl8712/rtl871x_io.c
Normal file
@ -0,0 +1,163 @@
|
||||
/******************************************************************************
|
||||
* rtl871x_io.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>
|
||||
*
|
||||
******************************************************************************/
|
||||
/*
|
||||
*
|
||||
* The purpose of rtl871x_io.c
|
||||
*
|
||||
* a. provides the API
|
||||
* b. provides the protocol engine
|
||||
* c. provides the software interface between caller and the hardware interface
|
||||
*
|
||||
* For r8712u, both sync/async operations are provided.
|
||||
*
|
||||
* Only sync read/write_mem operations are provided.
|
||||
*
|
||||
*/
|
||||
|
||||
#define _RTL871X_IO_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "rtl871x_io.h"
|
||||
#include "osdep_intf.h"
|
||||
#include "usb_ops.h"
|
||||
|
||||
static uint _init_intf_hdl(struct _adapter *padapter,
|
||||
struct intf_hdl *pintf_hdl)
|
||||
{
|
||||
struct intf_priv *pintf_priv;
|
||||
void (*set_intf_option)(u32 *poption) = NULL;
|
||||
void (*set_intf_funs)(struct intf_hdl *pintf_hdl);
|
||||
void (*set_intf_ops)(struct _io_ops *pops);
|
||||
uint (*init_intf_priv)(struct intf_priv *pintfpriv);
|
||||
|
||||
set_intf_option = &(r8712_usb_set_intf_option);
|
||||
set_intf_funs = &(r8712_usb_set_intf_funs);
|
||||
set_intf_ops = &r8712_usb_set_intf_ops;
|
||||
init_intf_priv = &r8712_usb_init_intf_priv;
|
||||
pintf_priv = pintf_hdl->pintfpriv = (struct intf_priv *)
|
||||
_malloc(sizeof(struct intf_priv));
|
||||
if (pintf_priv == NULL)
|
||||
goto _init_intf_hdl_fail;
|
||||
pintf_hdl->adapter = (u8 *)padapter;
|
||||
set_intf_option(&pintf_hdl->intf_option);
|
||||
set_intf_funs(pintf_hdl);
|
||||
set_intf_ops(&pintf_hdl->io_ops);
|
||||
pintf_priv->intf_dev = (u8 *)&(padapter->dvobjpriv);
|
||||
if (init_intf_priv(pintf_priv) == _FAIL)
|
||||
goto _init_intf_hdl_fail;
|
||||
return _SUCCESS;
|
||||
_init_intf_hdl_fail:
|
||||
if (pintf_priv)
|
||||
kfree((u8 *)pintf_priv);
|
||||
return _FAIL;
|
||||
}
|
||||
|
||||
static void _unload_intf_hdl(struct intf_priv *pintfpriv)
|
||||
{
|
||||
void (*unload_intf_priv)(struct intf_priv *pintfpriv);
|
||||
|
||||
unload_intf_priv = &r8712_usb_unload_intf_priv;
|
||||
unload_intf_priv(pintfpriv);
|
||||
if (pintfpriv)
|
||||
kfree((u8 *)pintfpriv);
|
||||
}
|
||||
|
||||
static uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl)
|
||||
{
|
||||
struct _adapter *adapter = (struct _adapter *)dev;
|
||||
|
||||
pintfhdl->intf_option = 0;
|
||||
pintfhdl->adapter = dev;
|
||||
pintfhdl->intf_dev = (u8 *)&(adapter->dvobjpriv);
|
||||
if (_init_intf_hdl(adapter, pintfhdl) == false)
|
||||
goto register_intf_hdl_fail;
|
||||
return _SUCCESS;
|
||||
register_intf_hdl_fail:
|
||||
return false;
|
||||
}
|
||||
|
||||
static void unregister_intf_hdl(struct intf_hdl *pintfhdl)
|
||||
{
|
||||
_unload_intf_hdl(pintfhdl->pintfpriv);
|
||||
memset((u8 *)pintfhdl, 0, sizeof(struct intf_hdl));
|
||||
}
|
||||
|
||||
uint r8712_alloc_io_queue(struct _adapter *adapter)
|
||||
{
|
||||
u32 i;
|
||||
struct io_queue *pio_queue;
|
||||
struct io_req *pio_req;
|
||||
|
||||
pio_queue = (struct io_queue *)_malloc(sizeof(struct io_queue));
|
||||
if (pio_queue == NULL)
|
||||
goto alloc_io_queue_fail;
|
||||
_init_listhead(&pio_queue->free_ioreqs);
|
||||
_init_listhead(&pio_queue->processing);
|
||||
_init_listhead(&pio_queue->pending);
|
||||
spin_lock_init(&pio_queue->lock);
|
||||
pio_queue->pallocated_free_ioreqs_buf = (u8 *)_malloc(NUM_IOREQ *
|
||||
(sizeof(struct io_req)) + 4);
|
||||
if ((pio_queue->pallocated_free_ioreqs_buf) == NULL)
|
||||
goto alloc_io_queue_fail;
|
||||
memset(pio_queue->pallocated_free_ioreqs_buf, 0,
|
||||
(NUM_IOREQ * (sizeof(struct io_req)) + 4));
|
||||
pio_queue->free_ioreqs_buf = pio_queue->pallocated_free_ioreqs_buf + 4
|
||||
- ((addr_t)(pio_queue->pallocated_free_ioreqs_buf)
|
||||
& 3);
|
||||
pio_req = (struct io_req *)(pio_queue->free_ioreqs_buf);
|
||||
for (i = 0; i < NUM_IOREQ; i++) {
|
||||
_init_listhead(&pio_req->list);
|
||||
sema_init(&pio_req->sema, 0);
|
||||
list_insert_tail(&pio_req->list, &pio_queue->free_ioreqs);
|
||||
pio_req++;
|
||||
}
|
||||
if ((register_intf_hdl((u8 *)adapter, &(pio_queue->intf))) == _FAIL)
|
||||
goto alloc_io_queue_fail;
|
||||
adapter->pio_queue = pio_queue;
|
||||
return _SUCCESS;
|
||||
alloc_io_queue_fail:
|
||||
if (pio_queue) {
|
||||
kfree(pio_queue->pallocated_free_ioreqs_buf);
|
||||
kfree((u8 *)pio_queue);
|
||||
}
|
||||
adapter->pio_queue = NULL;
|
||||
return _FAIL;
|
||||
}
|
||||
|
||||
void r8712_free_io_queue(struct _adapter *adapter)
|
||||
{
|
||||
struct io_queue *pio_queue = (struct io_queue *)(adapter->pio_queue);
|
||||
|
||||
if (pio_queue) {
|
||||
kfree(pio_queue->pallocated_free_ioreqs_buf);
|
||||
adapter->pio_queue = NULL;
|
||||
unregister_intf_hdl(&pio_queue->intf);
|
||||
kfree((u8 *)pio_queue);
|
||||
}
|
||||
}
|
233
drivers/staging/rtl8712/rtl871x_io.h
Normal file
233
drivers/staging/rtl8712/rtl871x_io.h
Normal file
@ -0,0 +1,233 @@
|
||||
#ifndef _IO_H_
|
||||
#define _IO_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "osdep_intf.h"
|
||||
|
||||
#define NUM_IOREQ 8
|
||||
|
||||
#define MAX_PROT_SZ (64-16)
|
||||
|
||||
#define _IOREADY 0
|
||||
#define _IO_WAIT_COMPLETE 1
|
||||
#define _IO_WAIT_RSP 2
|
||||
|
||||
/* IO COMMAND TYPE */
|
||||
#define _IOSZ_MASK_ (0x7F)
|
||||
#define _IO_WRITE_ BIT(7)
|
||||
#define _IO_FIXED_ BIT(8)
|
||||
#define _IO_BURST_ BIT(9)
|
||||
#define _IO_BYTE_ BIT(10)
|
||||
#define _IO_HW_ BIT(11)
|
||||
#define _IO_WORD_ BIT(12)
|
||||
#define _IO_SYNC_ BIT(13)
|
||||
#define _IO_CMDMASK_ (0x1F80)
|
||||
|
||||
/*
|
||||
For prompt mode accessing, caller shall free io_req
|
||||
Otherwise, io_handler will free io_req
|
||||
*/
|
||||
/* IO STATUS TYPE */
|
||||
#define _IO_ERR_ BIT(2)
|
||||
#define _IO_SUCCESS_ BIT(1)
|
||||
#define _IO_DONE_ BIT(0)
|
||||
#define IO_RD32 (_IO_SYNC_ | _IO_WORD_)
|
||||
#define IO_RD16 (_IO_SYNC_ | _IO_HW_)
|
||||
#define IO_RD8 (_IO_SYNC_ | _IO_BYTE_)
|
||||
#define IO_RD32_ASYNC (_IO_WORD_)
|
||||
#define IO_RD16_ASYNC (_IO_HW_)
|
||||
#define IO_RD8_ASYNC (_IO_BYTE_)
|
||||
#define IO_WR32 (_IO_WRITE_ | _IO_SYNC_ | _IO_WORD_)
|
||||
#define IO_WR16 (_IO_WRITE_ | _IO_SYNC_ | _IO_HW_)
|
||||
#define IO_WR8 (_IO_WRITE_ | _IO_SYNC_ | _IO_BYTE_)
|
||||
#define IO_WR32_ASYNC (_IO_WRITE_ | _IO_WORD_)
|
||||
#define IO_WR16_ASYNC (_IO_WRITE_ | _IO_HW_)
|
||||
#define IO_WR8_ASYNC (_IO_WRITE_ | _IO_BYTE_)
|
||||
/*
|
||||
Only Sync. burst accessing is provided.
|
||||
*/
|
||||
#define IO_WR_BURST(x) (IO_WRITE_ | _IO_SYNC_ | _IO_BURST_ | \
|
||||
((x) & _IOSZ_MASK_))
|
||||
#define IO_RD_BURST(x) (_IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_))
|
||||
/*below is for the intf_option bit defition...*/
|
||||
#define _INTF_ASYNC_ BIT(0) /*support async io*/
|
||||
struct intf_priv;
|
||||
struct intf_hdl;
|
||||
struct io_queue;
|
||||
struct _io_ops {
|
||||
uint (*_sdbus_read_bytes_to_membuf)(struct intf_priv *pintfpriv,
|
||||
u32 addr, u32 cnt, u8 *pbuf);
|
||||
uint (*_sdbus_read_blocks_to_membuf)(struct intf_priv *pintfpriv,
|
||||
u32 addr, u32 cnt, u8 *pbuf);
|
||||
u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr);
|
||||
u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr);
|
||||
u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr);
|
||||
uint (*_sdbus_write_blocks_from_membuf)(struct intf_priv *pintfpriv,
|
||||
u32 addr, u32 cnt, u8 *pbuf,
|
||||
u8 async);
|
||||
uint (*_sdbus_write_bytes_from_membuf)(struct intf_priv *pintfpriv,
|
||||
u32 addr, u32 cnt, u8 *pbuf);
|
||||
u8 (*_cmd52r)(struct intf_priv *pintfpriv, u32 addr);
|
||||
void (*_cmd52w)(struct intf_priv *pintfpriv, u32 addr, u8 val8);
|
||||
u8 (*_cmdfunc152r)(struct intf_priv *pintfpriv, u32 addr);
|
||||
void (*_cmdfunc152w)(struct intf_priv *pintfpriv, u32 addr, u8 val8);
|
||||
void (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val);
|
||||
void (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val);
|
||||
void (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val);
|
||||
void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
|
||||
u8 *pmem);
|
||||
void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
|
||||
u8 *pmem);
|
||||
void (*_sync_irp_protocol_rw)(struct io_queue *pio_q);
|
||||
u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
|
||||
u8 *pmem);
|
||||
u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
|
||||
u8 *pmem);
|
||||
};
|
||||
|
||||
struct io_req {
|
||||
struct list_head list;
|
||||
u32 addr;
|
||||
/*volatile*/ u32 val;
|
||||
u32 command;
|
||||
u32 status;
|
||||
u8 *pbuf;
|
||||
struct semaphore sema;
|
||||
void (*_async_io_callback)(struct _adapter *padater,
|
||||
struct io_req *pio_req, u8 *cnxt);
|
||||
u8 *cnxt;
|
||||
};
|
||||
|
||||
struct intf_hdl {
|
||||
u32 intf_option;
|
||||
u8 *adapter;
|
||||
u8 *intf_dev;
|
||||
struct intf_priv *pintfpriv;
|
||||
void (*intf_hdl_init)(u8 *priv);
|
||||
void (*intf_hdl_unload)(u8 *priv);
|
||||
void (*intf_hdl_open)(u8 *priv);
|
||||
void (*intf_hdl_close)(u8 *priv);
|
||||
struct _io_ops io_ops;
|
||||
};
|
||||
|
||||
struct reg_protocol_rd {
|
||||
|
||||
#ifdef __LITTLE_ENDIAN
|
||||
/* DW1 */
|
||||
u32 NumOfTrans:4;
|
||||
u32 Reserved1:4;
|
||||
u32 Reserved2:24;
|
||||
/* DW2 */
|
||||
u32 ByteCount:7;
|
||||
u32 WriteEnable:1; /*0:read, 1:write*/
|
||||
u32 FixOrContinuous:1; /*0:continuous, 1: Fix*/
|
||||
u32 BurstMode:1;
|
||||
u32 Byte1Access:1;
|
||||
u32 Byte2Access:1;
|
||||
u32 Byte4Access:1;
|
||||
u32 Reserved3:3;
|
||||
u32 Reserved4:16;
|
||||
/*DW3*/
|
||||
u32 BusAddress;
|
||||
/*DW4*/
|
||||
#else
|
||||
/*DW1*/
|
||||
u32 Reserved1:4;
|
||||
u32 NumOfTrans:4;
|
||||
u32 Reserved2:24;
|
||||
/*DW2*/
|
||||
u32 WriteEnable:1;
|
||||
u32 ByteCount:7;
|
||||
u32 Reserved3:3;
|
||||
u32 Byte4Access:1;
|
||||
u32 Byte2Access:1;
|
||||
u32 Byte1Access:1;
|
||||
u32 BurstMode:1 ;
|
||||
u32 FixOrContinuous:1;
|
||||
u32 Reserved4:16;
|
||||
/*DW3*/
|
||||
u32 BusAddress;
|
||||
/*DW4*/
|
||||
#endif
|
||||
};
|
||||
|
||||
struct reg_protocol_wt {
|
||||
#ifdef __LITTLE_ENDIAN
|
||||
/*DW1*/
|
||||
u32 NumOfTrans:4;
|
||||
u32 Reserved1:4;
|
||||
u32 Reserved2:24;
|
||||
/*DW2*/
|
||||
u32 ByteCount:7;
|
||||
u32 WriteEnable:1; /*0:read, 1:write*/
|
||||
u32 FixOrContinuous:1; /*0:continuous, 1: Fix*/
|
||||
u32 BurstMode:1;
|
||||
u32 Byte1Access:1;
|
||||
u32 Byte2Access:1;
|
||||
u32 Byte4Access:1;
|
||||
u32 Reserved3:3;
|
||||
u32 Reserved4:16;
|
||||
/*DW3*/
|
||||
u32 BusAddress;
|
||||
/*DW4*/
|
||||
u32 Value;
|
||||
#else
|
||||
/*DW1*/
|
||||
u32 Reserved1:4;
|
||||
u32 NumOfTrans:4;
|
||||
u32 Reserved2:24;
|
||||
/*DW2*/
|
||||
u32 WriteEnable:1;
|
||||
u32 ByteCount:7;
|
||||
u32 Reserved3:3;
|
||||
u32 Byte4Access:1;
|
||||
u32 Byte2Access:1;
|
||||
u32 Byte1Access:1;
|
||||
u32 BurstMode:1;
|
||||
u32 FixOrContinuous:1;
|
||||
u32 Reserved4:16;
|
||||
/*DW3*/
|
||||
u32 BusAddress;
|
||||
/*DW4*/
|
||||
u32 Value;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
Below is the data structure used by _io_handler
|
||||
*/
|
||||
|
||||
struct io_queue {
|
||||
spinlock_t lock;
|
||||
struct list_head free_ioreqs;
|
||||
/*The io_req list that will be served in the single protocol r/w.*/
|
||||
struct list_head pending;
|
||||
struct list_head processing;
|
||||
u8 *free_ioreqs_buf; /* 4-byte aligned */
|
||||
u8 *pallocated_free_ioreqs_buf;
|
||||
struct intf_hdl intf;
|
||||
};
|
||||
|
||||
static inline u32 _RND4(u32 sz)
|
||||
{
|
||||
u32 val;
|
||||
val = ((sz >> 2) + ((sz & 3) ? 1 : 0)) << 2;
|
||||
return val;
|
||||
}
|
||||
|
||||
u8 r8712_read8(struct _adapter *adapter, u32 addr);
|
||||
u16 r8712_read16(struct _adapter *adapter, u32 addr);
|
||||
u32 r8712_read32(struct _adapter *adapter, u32 addr);
|
||||
void r8712_read_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
|
||||
void r8712_read_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
|
||||
void r8712_write8(struct _adapter *adapter, u32 addr, u8 val);
|
||||
void r8712_write16(struct _adapter *adapter, u32 addr, u16 val);
|
||||
void r8712_write32(struct _adapter *adapter, u32 addr, u32 val);
|
||||
void r8712_write_mem(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
|
||||
void r8712_write_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem);
|
||||
/*ioreq */
|
||||
uint r8712_alloc_io_queue(struct _adapter *adapter);
|
||||
void r8712_free_io_queue(struct _adapter *adapter);
|
||||
|
||||
#endif /*_RTL8711_IO_H_*/
|
||||
|
97
drivers/staging/rtl8712/rtl871x_ioctl.h
Normal file
97
drivers/staging/rtl8712/rtl871x_ioctl.h
Normal file
@ -0,0 +1,97 @@
|
||||
#ifndef __IOCTL_H
|
||||
#define __IOCTL_H
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
|
||||
#ifndef OID_802_11_CAPABILITY
|
||||
#define OID_802_11_CAPABILITY 0x0d010122
|
||||
#endif
|
||||
|
||||
#ifndef OID_802_11_PMKID
|
||||
#define OID_802_11_PMKID 0x0d010123
|
||||
#endif
|
||||
|
||||
|
||||
/* For DDK-defined OIDs*/
|
||||
#define OID_NDIS_SEG1 0x00010100
|
||||
#define OID_NDIS_SEG2 0x00010200
|
||||
#define OID_NDIS_SEG3 0x00020100
|
||||
#define OID_NDIS_SEG4 0x01010100
|
||||
#define OID_NDIS_SEG5 0x01020100
|
||||
#define OID_NDIS_SEG6 0x01020200
|
||||
#define OID_NDIS_SEG7 0xFD010100
|
||||
#define OID_NDIS_SEG8 0x0D010100
|
||||
#define OID_NDIS_SEG9 0x0D010200
|
||||
#define OID_NDIS_SEG10 0x0D020200
|
||||
#define SZ_OID_NDIS_SEG1 23
|
||||
#define SZ_OID_NDIS_SEG2 3
|
||||
#define SZ_OID_NDIS_SEG3 6
|
||||
#define SZ_OID_NDIS_SEG4 6
|
||||
#define SZ_OID_NDIS_SEG5 4
|
||||
#define SZ_OID_NDIS_SEG6 8
|
||||
#define SZ_OID_NDIS_SEG7 7
|
||||
#define SZ_OID_NDIS_SEG8 36
|
||||
#define SZ_OID_NDIS_SEG9 24
|
||||
#define SZ_OID_NDIS_SEG10 19
|
||||
|
||||
/* For Realtek-defined OIDs*/
|
||||
#define OID_MP_SEG1 0xFF871100
|
||||
#define OID_MP_SEG2 0xFF818000
|
||||
#define OID_MP_SEG3 0xFF818700
|
||||
#define OID_MP_SEG4 0xFF011100
|
||||
|
||||
enum oid_type {
|
||||
QUERY_OID,
|
||||
SET_OID
|
||||
};
|
||||
|
||||
struct oid_funs_node {
|
||||
unsigned int oid_start; /*the starting number for OID*/
|
||||
unsigned int oid_end; /*the ending number for OID*/
|
||||
struct oid_obj_priv *node_array;
|
||||
unsigned int array_sz; /*the size of node_array*/
|
||||
int query_counter; /*count the number of query hits for this segment*/
|
||||
int set_counter; /*count the number of set hits for this segment*/
|
||||
};
|
||||
|
||||
struct oid_par_priv {
|
||||
void *adapter_context;
|
||||
uint oid;
|
||||
void *information_buf;
|
||||
unsigned long information_buf_len;
|
||||
unsigned long *bytes_rw;
|
||||
unsigned long *bytes_needed;
|
||||
enum oid_type type_of_oid;
|
||||
unsigned int dbg;
|
||||
};
|
||||
|
||||
struct oid_obj_priv {
|
||||
unsigned char dbg; /* 0: without OID debug message
|
||||
* 1: with OID debug message */
|
||||
uint(*oidfuns)(struct oid_par_priv *poid_par_priv);
|
||||
};
|
||||
|
||||
uint oid_null_function(struct oid_par_priv *poid_par_priv);
|
||||
|
||||
extern struct iw_handler_def r871x_handlers_def;
|
||||
|
||||
extern uint drv_query_info(
|
||||
struct net_device *MiniportAdapterContext,
|
||||
uint Oid,
|
||||
void *InformationBuffer,
|
||||
u32 InformationBufferLength,
|
||||
u32 *BytesWritten,
|
||||
u32 *BytesNeeded
|
||||
);
|
||||
|
||||
extern uint drv_set_info(
|
||||
struct net_device *MiniportAdapterContext,
|
||||
uint Oid,
|
||||
void *InformationBuffer,
|
||||
u32 InformationBufferLength,
|
||||
u32 *BytesRead,
|
||||
u32 *BytesNeeded
|
||||
);
|
||||
|
||||
#endif
|
2256
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
Normal file
2256
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
Normal file
File diff suppressed because it is too large
Load Diff
535
drivers/staging/rtl8712/rtl871x_ioctl_rtl.c
Normal file
535
drivers/staging/rtl8712/rtl871x_ioctl_rtl.c
Normal file
@ -0,0 +1,535 @@
|
||||
/******************************************************************************
|
||||
* rtl871x_ioctl_rtl.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 _RTL871X_IOCTL_RTL_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "wlan_bssdef.h"
|
||||
#include "wifi.h"
|
||||
#include "rtl871x_ioctl.h"
|
||||
#include "rtl871x_ioctl_set.h"
|
||||
#include "rtl871x_ioctl_rtl.h"
|
||||
#include "mp_custom_oid.h"
|
||||
#include "rtl871x_mp.h"
|
||||
#include "rtl871x_mp_ioctl.h"
|
||||
|
||||
uint oid_rt_get_signal_quality_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
*(u32 *)poid_par_priv->information_buf =
|
||||
padapter->recvpriv.rx_smallpacket_crcerr;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
*(u32 *)poid_par_priv->information_buf =
|
||||
padapter->recvpriv.rx_middlepacket_crcerr;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
*(u32 *)poid_par_priv->information_buf =
|
||||
padapter->recvpriv.rx_largepacket_crcerr;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_tx_retry_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_rx_retry_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
*(u32 *)poid_par_priv->information_buf =
|
||||
padapter->recvpriv.rx_pkts +
|
||||
padapter->recvpriv.rx_drop;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_tx_beacon_ok_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_tx_beacon_err_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
*(uint *)poid_par_priv->information_buf =
|
||||
padapter->recvpriv.rx_icv_err;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH ;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_set_encryption_algorithm_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != SET_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
u32 preamblemode = 0 ;
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
if (padapter->registrypriv.preamble == PREAMBLE_LONG)
|
||||
preamblemode = 0;
|
||||
else if (padapter->registrypriv.preamble == PREAMBLE_AUTO)
|
||||
preamblemode = 1;
|
||||
else if (padapter->registrypriv.preamble == PREAMBLE_SHORT)
|
||||
preamblemode = 2;
|
||||
*(u32 *)poid_par_priv->information_buf = preamblemode;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_ap_ip_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_channelplan_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
struct eeprom_priv *peeprompriv = &padapter->eeprompriv;
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
*(u16 *)poid_par_priv->information_buf = peeprompriv->channel_plan;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_set_channelplan_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
struct eeprom_priv *peeprompriv = &padapter->eeprompriv;
|
||||
|
||||
if (poid_par_priv->type_of_oid != SET_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
peeprompriv->channel_plan = *(u16 *)poid_par_priv->information_buf;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_set_preamble_mode_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
u32 preamblemode = 0;
|
||||
|
||||
if (poid_par_priv->type_of_oid != SET_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
preamblemode = *(u32 *)poid_par_priv->information_buf;
|
||||
if (preamblemode == 0)
|
||||
padapter->registrypriv.preamble = PREAMBLE_LONG;
|
||||
else if (preamblemode == 1)
|
||||
padapter->registrypriv.preamble = PREAMBLE_AUTO;
|
||||
else if (preamblemode == 2)
|
||||
padapter->registrypriv.preamble = PREAMBLE_SHORT;
|
||||
*(u32 *)poid_par_priv->information_buf = preamblemode;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_set_bcn_intvl_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != SET_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_dedicate_probe_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
*(u32 *)poid_par_priv->information_buf =
|
||||
padapter->xmitpriv.tx_bytes;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
*(u32 *)poid_par_priv->information_buf =
|
||||
padapter->recvpriv.rx_bytes;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->
|
||||
information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_current_tx_power_level_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_enc_key_mismatch_count_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_enc_key_match_count_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
struct NDIS_802_11_CONFIGURATION *pnic_Config;
|
||||
u32 channelnum;
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
|
||||
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true))
|
||||
pnic_Config = &pmlmepriv->cur_network.network.Configuration;
|
||||
else
|
||||
pnic_Config = &padapter->registrypriv.dev_network.
|
||||
Configuration;
|
||||
channelnum = pnic_Config->DSConfig;
|
||||
*(u32 *)poid_par_priv->information_buf = channelnum;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_hardware_radio_off_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_key_mismatch_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_supported_wireless_mode_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
u32 ulInfo = 0;
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len >= sizeof(u32)) {
|
||||
ulInfo |= 0x0100; /* WIRELESS_MODE_B */
|
||||
ulInfo |= 0x0200; /* WIRELESS_MODE_G */
|
||||
ulInfo |= 0x0400; /* WIRELESS_MODE_A */
|
||||
*(u32 *) poid_par_priv->information_buf = ulInfo;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
} else
|
||||
return NDIS_STATUS_INVALID_LENGTH;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_channel_list_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_scan_in_progress_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
uint oid_rt_forced_data_rate_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_wireless_mode_for_scan_list_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_get_bss_wireless_mode_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_scan_with_magic_packet_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_ap_get_associated_station_list_hdl(struct oid_par_priv
|
||||
*poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_ap_switch_into_ap_mode_hdl(struct oid_par_priv*
|
||||
poid_par_priv)
|
||||
{
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_ap_supported_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_ap_set_passphrase_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != SET_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_pro_rf_write_registry_hdl(struct oid_par_priv*
|
||||
poid_par_priv)
|
||||
{
|
||||
uint status = NDIS_STATUS_SUCCESS;
|
||||
struct _adapter *Adapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
|
||||
if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len ==
|
||||
(sizeof(unsigned long) * 3)) {
|
||||
if (!r8712_setrfreg_cmd(Adapter,
|
||||
*(unsigned char *)poid_par_priv->information_buf,
|
||||
(unsigned long)(*((unsigned long *)
|
||||
poid_par_priv->information_buf + 2))))
|
||||
status = NDIS_STATUS_NOT_ACCEPTED;
|
||||
} else
|
||||
status = NDIS_STATUS_INVALID_LENGTH;
|
||||
return status;
|
||||
}
|
||||
|
||||
uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
uint status = NDIS_STATUS_SUCCESS;
|
||||
struct _adapter *Adapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
|
||||
if (poid_par_priv->type_of_oid != SET_OID) /* QUERY_OID */
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
if (poid_par_priv->information_buf_len == (sizeof(unsigned long)*3)) {
|
||||
if (Adapter->mppriv.act_in_progress == true)
|
||||
status = NDIS_STATUS_NOT_ACCEPTED;
|
||||
else {
|
||||
/* init workparam */
|
||||
Adapter->mppriv.act_in_progress = true;
|
||||
Adapter->mppriv.workparam.bcompleted = false;
|
||||
Adapter->mppriv.workparam.act_type = MPT_READ_RF;
|
||||
Adapter->mppriv.workparam.io_offset = *(unsigned long *)
|
||||
poid_par_priv->information_buf;
|
||||
Adapter->mppriv.workparam.io_value = 0xcccccccc;
|
||||
|
||||
/* RegOffsetValue - The offset of RF register to read.
|
||||
* RegDataWidth - The data width of RF register to read.
|
||||
* RegDataValue - The value to read.
|
||||
* RegOffsetValue = *((unsigned long *)InformationBuffer);
|
||||
* RegDataWidth = *((unsigned long *)InformationBuffer+1);
|
||||
* RegDataValue = *((unsigned long *)InformationBuffer+2);
|
||||
*/
|
||||
if (!r8712_getrfreg_cmd(Adapter,
|
||||
*(unsigned char *)poid_par_priv->information_buf,
|
||||
(unsigned char *)&Adapter->mppriv.workparam.
|
||||
io_value))
|
||||
status = NDIS_STATUS_NOT_ACCEPTED;
|
||||
}
|
||||
} else
|
||||
status = NDIS_STATUS_INVALID_LENGTH;
|
||||
return status;
|
||||
}
|
||||
|
||||
enum _CONNECT_STATE_{
|
||||
CHECKINGSTATUS,
|
||||
ASSOCIATED,
|
||||
ADHOCMODE,
|
||||
NOTASSOCIATED
|
||||
};
|
||||
|
||||
uint oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
struct _adapter *padapter = (struct _adapter *)
|
||||
(poid_par_priv->adapter_context);
|
||||
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
||||
u32 ulInfo;
|
||||
|
||||
if (poid_par_priv->type_of_oid != QUERY_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
/* nStatus==0 CheckingStatus
|
||||
* nStatus==1 Associated
|
||||
* nStatus==2 AdHocMode
|
||||
* nStatus==3 NotAssociated
|
||||
*/
|
||||
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)
|
||||
ulInfo = CHECKINGSTATUS;
|
||||
else if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
|
||||
ulInfo = ASSOCIATED;
|
||||
else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)
|
||||
ulInfo = ADHOCMODE;
|
||||
else
|
||||
ulInfo = NOTASSOCIATED ;
|
||||
*(u32 *)poid_par_priv->information_buf = ulInfo;
|
||||
*poid_par_priv->bytes_rw = poid_par_priv->information_buf_len;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint oid_rt_set_default_key_id_hdl(struct oid_par_priv *poid_par_priv)
|
||||
{
|
||||
if (poid_par_priv->type_of_oid != SET_OID)
|
||||
return NDIS_STATUS_NOT_ACCEPTED;
|
||||
return NDIS_STATUS_SUCCESS;
|
||||
}
|
96
drivers/staging/rtl8712/rtl871x_ioctl_rtl.h
Normal file
96
drivers/staging/rtl8712/rtl871x_ioctl_rtl.h
Normal file
@ -0,0 +1,96 @@
|
||||
#ifndef _RTL871X_IOCTL_RTL_H
|
||||
#define _RTL871X_IOCTL_RTL_H
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
|
||||
/*************** oid_rtl_seg_01_01 **************/
|
||||
uint oid_rt_get_signal_quality_hdl(
|
||||
struct oid_par_priv *poid_par_priv);/*84*/
|
||||
uint oid_rt_get_small_packet_crc_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_middle_packet_crc_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_large_packet_crc_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_tx_retry_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_rx_retry_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_rx_total_packet_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_tx_beacon_ok_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_tx_beacon_err_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_rx_icv_err_hdl(
|
||||
struct oid_par_priv *poid_par_priv);/*93*/
|
||||
uint oid_rt_set_encryption_algorithm_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_preamble_mode_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_ap_ip_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_channelplan_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_set_channelplan_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_set_preamble_mode_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_set_bcn_intvl_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_dedicate_probe_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_total_tx_bytes_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_total_rx_bytes_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_current_tx_power_level_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_enc_key_mismatch_count_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_enc_key_match_count_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_channel_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_hardware_radio_off_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_key_mismatch_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_supported_wireless_mode_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_channel_list_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_scan_in_progress_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_forced_data_rate_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_wireless_mode_for_scan_list_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_bss_wireless_mode_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_scan_with_magic_packet_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
|
||||
/************** oid_rtl_seg_01_03 section start **************/
|
||||
uint oid_rt_ap_get_associated_station_list_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_ap_switch_into_ap_mode_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_ap_supported_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_ap_set_passphrase_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
/* oid_rtl_seg_01_11 */
|
||||
uint oid_rt_pro_rf_write_registry_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_rf_read_registry_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
/*************** oid_rtl_seg_03_00 section start **************/
|
||||
uint oid_rt_get_connect_state_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_set_default_key_id_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
|
||||
#endif
|
||||
|
379
drivers/staging/rtl8712/rtl871x_ioctl_set.c
Normal file
379
drivers/staging/rtl8712/rtl871x_ioctl_set.c
Normal file
@ -0,0 +1,379 @@
|
||||
/******************************************************************************
|
||||
* rtl871x_ioctl_set.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 _RTL871X_IOCTL_SET_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "rtl871x_ioctl_set.h"
|
||||
#include "usb_osintf.h"
|
||||
#include "usb_ops.h"
|
||||
|
||||
#define IS_MAC_ADDRESS_BROADCAST(addr) \
|
||||
( \
|
||||
((addr[0] == 0xff) && (addr[1] == 0xff) && \
|
||||
(addr[2] == 0xff) && (addr[3] == 0xff) && \
|
||||
(addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \
|
||||
)
|
||||
|
||||
static u8 validate_ssid(struct ndis_802_11_ssid *ssid)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
if (ssid->SsidLength > 32)
|
||||
return false;
|
||||
for (i = 0; i < ssid->SsidLength; i++) {
|
||||
/* wifi, printable ascii code must be supported */
|
||||
if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static u8 do_join(struct _adapter *padapter)
|
||||
{
|
||||
struct list_head *plist, *phead;
|
||||
u8 *pibss = NULL;
|
||||
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
||||
struct __queue *queue = &(pmlmepriv->scanned_queue);
|
||||
|
||||
phead = get_list_head(queue);
|
||||
plist = get_next(phead);
|
||||
pmlmepriv->cur_network.join_res = -2;
|
||||
pmlmepriv->fw_state |= _FW_UNDER_LINKING;
|
||||
pmlmepriv->pscanned = plist;
|
||||
pmlmepriv->to_join = true;
|
||||
if (_queue_empty(queue) == true) {
|
||||
if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
|
||||
pmlmepriv->fw_state ^= _FW_UNDER_LINKING;
|
||||
/* when set_ssid/set_bssid for do_join(), but scanning queue
|
||||
* is empty we try to issue sitesurvey firstly
|
||||
*/
|
||||
if (pmlmepriv->sitesurveyctrl.traffic_busy == false)
|
||||
r8712_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid);
|
||||
return true;
|
||||
} else {
|
||||
int ret;
|
||||
|
||||
ret = r8712_select_and_join_from_scan(pmlmepriv);
|
||||
if (ret == _SUCCESS)
|
||||
_set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT);
|
||||
else {
|
||||
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) {
|
||||
/* submit r8712_createbss_cmd to change to an
|
||||
* ADHOC_MASTER pmlmepriv->lock has been
|
||||
* acquired by caller...
|
||||
*/
|
||||
struct wlan_bssid_ex *pdev_network =
|
||||
&(padapter->registrypriv.dev_network);
|
||||
pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE;
|
||||
pibss = padapter->registrypriv.dev_network.
|
||||
MacAddress;
|
||||
memset(&pdev_network->Ssid, 0,
|
||||
sizeof(struct ndis_802_11_ssid));
|
||||
memcpy(&pdev_network->Ssid,
|
||||
&pmlmepriv->assoc_ssid,
|
||||
sizeof(struct ndis_802_11_ssid));
|
||||
r8712_update_registrypriv_dev_network(padapter);
|
||||
r8712_generate_random_ibss(pibss);
|
||||
if (r8712_createbss_cmd(padapter) != _SUCCESS)
|
||||
return false;
|
||||
pmlmepriv->to_join = false;
|
||||
} else {
|
||||
/* can't associate ; reset under-linking */
|
||||
if (pmlmepriv->fw_state & _FW_UNDER_LINKING)
|
||||
pmlmepriv->fw_state ^=
|
||||
_FW_UNDER_LINKING;
|
||||
/* when set_ssid/set_bssid for do_join(), but
|
||||
* there are no desired bss in scanning queue
|
||||
* we try to issue sitesurvey first
|
||||
*/
|
||||
if (!pmlmepriv->sitesurveyctrl.traffic_busy)
|
||||
r8712_sitesurvey_cmd(padapter,
|
||||
&pmlmepriv->assoc_ssid);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid)
|
||||
{
|
||||
unsigned long irqL;
|
||||
u8 status = true;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
|
||||
if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 &&
|
||||
bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) ||
|
||||
(bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF &&
|
||||
bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) {
|
||||
status = false;
|
||||
return status;
|
||||
}
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY |
|
||||
_FW_UNDER_LINKING) == true) {
|
||||
status = check_fwstate(pmlmepriv, _FW_UNDER_LINKING);
|
||||
goto _Abort_Set_BSSID;
|
||||
}
|
||||
if (check_fwstate(pmlmepriv,
|
||||
_FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) {
|
||||
if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid,
|
||||
ETH_ALEN)) {
|
||||
if (check_fwstate(pmlmepriv,
|
||||
WIFI_STATION_STATE) == false)
|
||||
goto _Abort_Set_BSSID; /* driver is in
|
||||
* WIFI_ADHOC_MASTER_STATE */
|
||||
} else {
|
||||
r8712_disassoc_cmd(padapter);
|
||||
if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
|
||||
r8712_ind_disconnect(padapter);
|
||||
r8712_free_assoc_resources(padapter);
|
||||
if ((check_fwstate(pmlmepriv,
|
||||
WIFI_ADHOC_MASTER_STATE))) {
|
||||
_clr_fwstate_(pmlmepriv,
|
||||
WIFI_ADHOC_MASTER_STATE);
|
||||
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN);
|
||||
pmlmepriv->assoc_by_bssid = true;
|
||||
status = do_join(padapter);
|
||||
goto done;
|
||||
_Abort_Set_BSSID:
|
||||
done:
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
return status;
|
||||
}
|
||||
|
||||
void r8712_set_802_11_ssid(struct _adapter *padapter,
|
||||
struct ndis_802_11_ssid *ssid)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
struct wlan_network *pnetwork = &pmlmepriv->cur_network;
|
||||
|
||||
if (padapter->hw_init_completed == false)
|
||||
return;
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) {
|
||||
check_fwstate(pmlmepriv, _FW_UNDER_LINKING);
|
||||
goto _Abort_Set_SSID;
|
||||
}
|
||||
if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
|
||||
if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) &&
|
||||
(!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid,
|
||||
ssid->SsidLength))) {
|
||||
if ((check_fwstate(pmlmepriv,
|
||||
WIFI_STATION_STATE) == false)) {
|
||||
if (r8712_is_same_ibss(padapter,
|
||||
pnetwork) == false) {
|
||||
/* if in WIFI_ADHOC_MASTER_STATE or
|
||||
* WIFI_ADHOC_STATE, create bss or
|
||||
* rejoin again
|
||||
*/
|
||||
r8712_disassoc_cmd(padapter);
|
||||
if (check_fwstate(pmlmepriv,
|
||||
_FW_LINKED) == true)
|
||||
r8712_ind_disconnect(padapter);
|
||||
r8712_free_assoc_resources(padapter);
|
||||
if (check_fwstate(pmlmepriv,
|
||||
WIFI_ADHOC_MASTER_STATE)) {
|
||||
_clr_fwstate_(pmlmepriv,
|
||||
WIFI_ADHOC_MASTER_STATE);
|
||||
set_fwstate(pmlmepriv,
|
||||
WIFI_ADHOC_STATE);
|
||||
}
|
||||
} else
|
||||
goto _Abort_Set_SSID; /* driver is in
|
||||
* WIFI_ADHOC_MASTER_STATE */
|
||||
}
|
||||
} else {
|
||||
r8712_disassoc_cmd(padapter);
|
||||
if (check_fwstate(pmlmepriv, _FW_LINKED) == true)
|
||||
r8712_ind_disconnect(padapter);
|
||||
r8712_free_assoc_resources(padapter);
|
||||
if (check_fwstate(pmlmepriv,
|
||||
WIFI_ADHOC_MASTER_STATE) == true) {
|
||||
_clr_fwstate_(pmlmepriv,
|
||||
WIFI_ADHOC_MASTER_STATE);
|
||||
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (padapter->securitypriv.btkip_countermeasure == true)
|
||||
goto _Abort_Set_SSID;
|
||||
if (validate_ssid(ssid) == false)
|
||||
goto _Abort_Set_SSID;
|
||||
memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid));
|
||||
pmlmepriv->assoc_by_bssid = false;
|
||||
do_join(padapter);
|
||||
goto done;
|
||||
_Abort_Set_SSID:
|
||||
done:
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
}
|
||||
|
||||
u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter,
|
||||
enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
struct wlan_network *cur_network = &pmlmepriv->cur_network;
|
||||
enum NDIS_802_11_NETWORK_INFRASTRUCTURE *pold_state =
|
||||
&(cur_network->network.InfrastructureMode);
|
||||
|
||||
if (*pold_state != networktype) {
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
|
||||
(*pold_state == Ndis802_11IBSS))
|
||||
r8712_disassoc_cmd(padapter);
|
||||
if (check_fwstate(pmlmepriv,
|
||||
_FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true)
|
||||
r8712_free_assoc_resources(padapter);
|
||||
if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||
|
||||
(*pold_state == Ndis802_11Infrastructure) ||
|
||||
(*pold_state == Ndis802_11IBSS)) {
|
||||
/* will clr Linked_state before this function,
|
||||
* we must have chked whether issue dis-assoc_cmd or
|
||||
* not */
|
||||
r8712_ind_disconnect(padapter);
|
||||
}
|
||||
*pold_state = networktype;
|
||||
/* clear WIFI_STATION_STATE; WIFI_AP_STATE; WIFI_ADHOC_STATE;
|
||||
* WIFI_ADHOC_MASTER_STATE */
|
||||
_clr_fwstate_(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE |
|
||||
WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE |
|
||||
WIFI_AP_STATE);
|
||||
switch (networktype) {
|
||||
case Ndis802_11IBSS:
|
||||
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
|
||||
break;
|
||||
case Ndis802_11Infrastructure:
|
||||
set_fwstate(pmlmepriv, WIFI_STATION_STATE);
|
||||
break;
|
||||
case Ndis802_11APMode:
|
||||
set_fwstate(pmlmepriv, WIFI_AP_STATE);
|
||||
break;
|
||||
case Ndis802_11AutoUnknown:
|
||||
case Ndis802_11InfrastructureMax:
|
||||
break;
|
||||
}
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
u8 r8712_set_802_11_disassociate(struct _adapter *padapter)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
|
||||
r8712_disassoc_cmd(padapter);
|
||||
r8712_ind_disconnect(padapter);
|
||||
r8712_free_assoc_resources(padapter);
|
||||
}
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
return true;
|
||||
}
|
||||
|
||||
u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter)
|
||||
{
|
||||
struct mlme_priv *pmlmepriv = NULL;
|
||||
unsigned long irqL;
|
||||
u8 ret = true;
|
||||
|
||||
if (padapter == NULL)
|
||||
return false;
|
||||
pmlmepriv = &padapter->mlmepriv;
|
||||
if (padapter->hw_init_completed == false)
|
||||
return false;
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) ||
|
||||
(pmlmepriv->sitesurveyctrl.traffic_busy == true)) {
|
||||
/* Scan or linking is in progress, do nothing. */
|
||||
ret = (u8)check_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
|
||||
} else {
|
||||
r8712_free_network_queue(padapter);
|
||||
ret = r8712_sitesurvey_cmd(padapter, NULL);
|
||||
}
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
u8 r8712_set_802_11_authentication_mode(struct _adapter *padapter,
|
||||
enum NDIS_802_11_AUTHENTICATION_MODE authmode)
|
||||
{
|
||||
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
||||
u8 ret;
|
||||
|
||||
psecuritypriv->ndisauthtype = authmode;
|
||||
if (psecuritypriv->ndisauthtype > 3)
|
||||
psecuritypriv->AuthAlgrthm = 2; /* 802.1x */
|
||||
if (r8712_set_auth(padapter, psecuritypriv) == _SUCCESS)
|
||||
ret = true;
|
||||
else
|
||||
ret = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
u8 r8712_set_802_11_add_wep(struct _adapter *padapter,
|
||||
struct NDIS_802_11_WEP *wep)
|
||||
{
|
||||
u8 bdefaultkey;
|
||||
u8 btransmitkey;
|
||||
sint keyid;
|
||||
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
||||
|
||||
bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true;
|
||||
btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false;
|
||||
keyid = wep->KeyIndex & 0x3fffffff;
|
||||
if (keyid >= WEP_KEYS)
|
||||
return false;
|
||||
switch (wep->KeyLength) {
|
||||
case 5:
|
||||
psecuritypriv->PrivacyAlgrthm = _WEP40_;
|
||||
break;
|
||||
case 13:
|
||||
psecuritypriv->PrivacyAlgrthm = _WEP104_;
|
||||
break;
|
||||
default:
|
||||
psecuritypriv->PrivacyAlgrthm = _NO_PRIVACY_;
|
||||
break;
|
||||
}
|
||||
memcpy(psecuritypriv->DefKey[keyid].skey, &wep->KeyMaterial,
|
||||
wep->KeyLength);
|
||||
psecuritypriv->DefKeylen[keyid] = wep->KeyLength;
|
||||
psecuritypriv->PrivacyKeyIndex = keyid;
|
||||
if (r8712_set_key(padapter, psecuritypriv, keyid) == _FAIL)
|
||||
return false;
|
||||
return _SUCCESS;
|
||||
}
|
24
drivers/staging/rtl8712/rtl871x_ioctl_set.h
Normal file
24
drivers/staging/rtl8712/rtl871x_ioctl_set.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef __IOCTL_SET_H
|
||||
#define __IOCTL_SET_H
|
||||
|
||||
#include "drv_types.h"
|
||||
|
||||
typedef u8 NDIS_802_11_PMKID_VALUE[16];
|
||||
|
||||
struct BSSIDInfo {
|
||||
unsigned char BSSID[6];
|
||||
NDIS_802_11_PMKID_VALUE PMKID;
|
||||
};
|
||||
|
||||
u8 r8712_set_802_11_authentication_mode(struct _adapter *pdapter,
|
||||
enum NDIS_802_11_AUTHENTICATION_MODE authmode);
|
||||
u8 r8712_set_802_11_bssid(struct _adapter *padapter, u8 *bssid);
|
||||
u8 r8712_set_802_11_add_wep(struct _adapter *padapter, struct NDIS_802_11_WEP *wep);
|
||||
u8 r8712_set_802_11_disassociate(struct _adapter *padapter);
|
||||
u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter);
|
||||
u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter,
|
||||
enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
|
||||
void r8712_set_802_11_ssid(struct _adapter *padapter, struct ndis_802_11_ssid *ssid);
|
||||
|
||||
#endif
|
||||
|
99
drivers/staging/rtl8712/rtl871x_led.h
Normal file
99
drivers/staging/rtl8712/rtl871x_led.h
Normal file
@ -0,0 +1,99 @@
|
||||
#ifndef __RTL8712_LED_H
|
||||
#define __RTL8712_LED_H
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
|
||||
/*===========================================================================
|
||||
* LED customization.
|
||||
*===========================================================================
|
||||
*/
|
||||
enum LED_CTL_MODE {
|
||||
LED_CTL_POWER_ON = 1,
|
||||
LED_CTL_LINK = 2,
|
||||
LED_CTL_NO_LINK = 3,
|
||||
LED_CTL_TX = 4,
|
||||
LED_CTL_RX = 5,
|
||||
LED_CTL_SITE_SURVEY = 6,
|
||||
LED_CTL_POWER_OFF = 7,
|
||||
LED_CTL_START_TO_LINK = 8,
|
||||
LED_CTL_START_WPS = 9,
|
||||
LED_CTL_STOP_WPS = 10,
|
||||
LED_CTL_START_WPS_BOTTON = 11,
|
||||
LED_CTL_STOP_WPS_FAIL = 12,
|
||||
LED_CTL_STOP_WPS_FAIL_OVERLAP = 13,
|
||||
};
|
||||
|
||||
#define IS_LED_WPS_BLINKING(_LED_871x) \
|
||||
(((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS \
|
||||
|| ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP \
|
||||
|| ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress)
|
||||
|
||||
#define IS_LED_BLINKING(_LED_871x) \
|
||||
(((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress \
|
||||
|| ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress)
|
||||
|
||||
enum LED_PIN_871x {
|
||||
LED_PIN_GPIO0,
|
||||
LED_PIN_LED0,
|
||||
LED_PIN_LED1
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
* LED customization.
|
||||
*===========================================================================
|
||||
*/
|
||||
enum LED_STRATEGY_871x {
|
||||
SW_LED_MODE0, /* SW control 1 LED via GPIO0. It is default option. */
|
||||
SW_LED_MODE1, /* 2 LEDs, through LED0 and LED1. For ALPHA. */
|
||||
SW_LED_MODE2, /* SW control 1 LED via GPIO0,
|
||||
* custom for AzWave 8187 minicard. */
|
||||
SW_LED_MODE3, /* SW control 1 LED via GPIO0,
|
||||
* customized for Sercomm Printer Server case.*/
|
||||
SW_LED_MODE4, /*for Edimax / Belkin*/
|
||||
SW_LED_MODE5, /*for Sercomm / Belkin*/
|
||||
SW_LED_MODE6, /*for WNC / Corega*/
|
||||
HW_LED, /* HW control 2 LEDs, LED0 and LED1 (there are 4 different
|
||||
* control modes, see MAC.CONFIG1 for details.)*/
|
||||
};
|
||||
|
||||
struct LED_871x {
|
||||
struct _adapter *padapter;
|
||||
enum LED_PIN_871x LedPin; /* Implementation for this SW led. */
|
||||
u32 CurrLedState; /* Current LED state. */
|
||||
u8 bLedOn; /* true if LED is ON */
|
||||
u8 bSWLedCtrl;
|
||||
u8 bLedBlinkInProgress; /*true if blinking */
|
||||
u8 bLedNoLinkBlinkInProgress;
|
||||
u8 bLedLinkBlinkInProgress;
|
||||
u8 bLedStartToLinkBlinkInProgress;
|
||||
u8 bLedScanBlinkInProgress;
|
||||
u8 bLedWPSBlinkInProgress;
|
||||
u32 BlinkTimes; /* No. times to toggle for blink.*/
|
||||
u32 BlinkingLedState; /* Next state for blinking,
|
||||
* either LED_ON or OFF.*/
|
||||
|
||||
struct timer_list BlinkTimer; /* Timer object for led blinking.*/
|
||||
_workitem BlinkWorkItem; /* Workitem used by BlinkTimer */
|
||||
};
|
||||
|
||||
struct led_priv {
|
||||
/* add for led controll */
|
||||
struct LED_871x SwLed0;
|
||||
struct LED_871x SwLed1;
|
||||
enum LED_STRATEGY_871x LedStrategy;
|
||||
u8 bRegUseLed;
|
||||
void (*LedControlHandler)(struct _adapter *padapter,
|
||||
enum LED_CTL_MODE LedAction);
|
||||
/* add for led controll */
|
||||
};
|
||||
|
||||
/*===========================================================================
|
||||
* Interface to manipulate LED objects.
|
||||
*===========================================================================*/
|
||||
void r8712_InitSwLeds(struct _adapter *padapter);
|
||||
void r8712_DeInitSwLeds(struct _adapter *padapter);
|
||||
void LedControl871x(struct _adapter *padapter, enum LED_CTL_MODE LedAction);
|
||||
|
||||
#endif
|
||||
|
1842
drivers/staging/rtl8712/rtl871x_mlme.c
Normal file
1842
drivers/staging/rtl8712/rtl871x_mlme.c
Normal file
File diff suppressed because it is too large
Load Diff
208
drivers/staging/rtl8712/rtl871x_mlme.h
Normal file
208
drivers/staging/rtl8712/rtl871x_mlme.h
Normal file
@ -0,0 +1,208 @@
|
||||
#ifndef __RTL871X_MLME_H_
|
||||
#define __RTL871X_MLME_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "wlan_bssdef.h"
|
||||
|
||||
#define MAX_BSS_CNT 64
|
||||
#define MAX_JOIN_TIMEOUT 6000
|
||||
|
||||
#define SCANNING_TIMEOUT 4500
|
||||
|
||||
#define SCANQUEUE_LIFETIME 20 /* unit:sec */
|
||||
|
||||
#define WIFI_NULL_STATE 0x00000000
|
||||
#define WIFI_ASOC_STATE 0x00000001 /* Under Linked state...*/
|
||||
#define WIFI_REASOC_STATE 0x00000002
|
||||
#define WIFI_SLEEP_STATE 0x00000004
|
||||
#define WIFI_STATION_STATE 0x00000008
|
||||
#define WIFI_AP_STATE 0x00000010
|
||||
#define WIFI_ADHOC_STATE 0x00000020
|
||||
#define WIFI_ADHOC_MASTER_STATE 0x00000040
|
||||
#define WIFI_UNDER_LINKING 0x00000080
|
||||
#define WIFI_SITE_MONITOR 0x00000800 /* to indicate the station
|
||||
* is under site surveying*/
|
||||
#define WIFI_MP_STATE 0x00010000
|
||||
#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in cont. tx background*/
|
||||
#define WIFI_MP_CTX_ST 0x00040000 /* in cont. tx with
|
||||
* single-tone*/
|
||||
#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in cont, tx
|
||||
* background due to out of skb*/
|
||||
#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continous tx*/
|
||||
#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in cont, tx with carrier
|
||||
* suppression*/
|
||||
#define WIFI_MP_LPBK_STATE 0x00400000
|
||||
|
||||
#define _FW_UNDER_LINKING WIFI_UNDER_LINKING
|
||||
#define _FW_LINKED WIFI_ASOC_STATE
|
||||
#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
|
||||
|
||||
/*
|
||||
there are several "locks" in mlme_priv,
|
||||
since mlme_priv is a shared resource between many threads,
|
||||
like ISR/Call-Back functions, the OID handlers, and even timer functions.
|
||||
Each _queue has its own locks, already.
|
||||
Other items are protected by mlme_priv.lock.
|
||||
To avoid possible dead lock, any thread trying to modifiying mlme_priv
|
||||
SHALL not lock up more than one locks at a time!
|
||||
*/
|
||||
|
||||
#define traffic_threshold 10
|
||||
#define traffic_scan_period 500
|
||||
|
||||
struct sitesurvey_ctrl {
|
||||
u64 last_tx_pkts;
|
||||
uint last_rx_pkts;
|
||||
sint traffic_busy;
|
||||
struct timer_list sitesurvey_ctrl_timer;
|
||||
};
|
||||
|
||||
struct mlme_priv {
|
||||
|
||||
spinlock_t lock;
|
||||
spinlock_t lock2;
|
||||
sint fw_state; /*shall we protect this variable? */
|
||||
u8 to_join; /*flag*/
|
||||
u8 *nic_hdl;
|
||||
struct list_head *pscanned;
|
||||
struct __queue free_bss_pool;
|
||||
struct __queue scanned_queue;
|
||||
u8 *free_bss_buf;
|
||||
unsigned long num_of_scanned;
|
||||
struct ndis_802_11_ssid assoc_ssid;
|
||||
u8 assoc_bssid[6];
|
||||
struct wlan_network cur_network;
|
||||
struct sitesurvey_ctrl sitesurveyctrl;
|
||||
struct timer_list assoc_timer;
|
||||
uint assoc_by_bssid;
|
||||
uint assoc_by_rssi;
|
||||
struct timer_list scan_to_timer; /* driver handles scan_timeout.*/
|
||||
struct timer_list dhcp_timer; /* set dhcp to if driver in ps mode.*/
|
||||
struct qos_priv qospriv;
|
||||
struct ht_priv htpriv;
|
||||
struct timer_list wdg_timer; /*watchdog periodic timer*/
|
||||
};
|
||||
|
||||
static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
|
||||
{
|
||||
return pmlmepriv->cur_network.network.MacAddress;
|
||||
}
|
||||
|
||||
static inline u8 check_fwstate(struct mlme_priv *pmlmepriv, sint state)
|
||||
{
|
||||
if (pmlmepriv->fw_state & state)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
|
||||
{
|
||||
return pmlmepriv->fw_state;
|
||||
}
|
||||
|
||||
/*
|
||||
* No Limit on the calling context,
|
||||
* therefore set it to be the critical section...
|
||||
*
|
||||
* ### NOTE:#### (!!!!)
|
||||
* TAKE CARE THAT BEFORE CALLING THIS FUNC, LOCK pmlmepriv->lock
|
||||
*/
|
||||
static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
|
||||
{
|
||||
pmlmepriv->fw_state |= state;
|
||||
}
|
||||
|
||||
static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
|
||||
{
|
||||
pmlmepriv->fw_state &= ~state;
|
||||
}
|
||||
|
||||
/*
|
||||
* No Limit on the calling context,
|
||||
* therefore set it to be the critical section...
|
||||
*/
|
||||
static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
|
||||
{
|
||||
unsigned long irqL;
|
||||
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
if (check_fwstate(pmlmepriv, state) == true)
|
||||
pmlmepriv->fw_state ^= state;
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
}
|
||||
|
||||
static inline void up_scanned_network(struct mlme_priv *pmlmepriv)
|
||||
{
|
||||
unsigned long irqL;
|
||||
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
pmlmepriv->num_of_scanned++;
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
}
|
||||
|
||||
static inline void down_scanned_network(struct mlme_priv *pmlmepriv)
|
||||
{
|
||||
unsigned long irqL;
|
||||
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
pmlmepriv->num_of_scanned--;
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
}
|
||||
|
||||
static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv,
|
||||
sint val)
|
||||
{
|
||||
unsigned long irqL;
|
||||
|
||||
spin_lock_irqsave(&pmlmepriv->lock, irqL);
|
||||
pmlmepriv->num_of_scanned = val;
|
||||
spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
|
||||
}
|
||||
|
||||
void r8712_survey_event_callback(struct _adapter *adapter, u8 *pbuf);
|
||||
void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf);
|
||||
void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf);
|
||||
void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf);
|
||||
void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf);
|
||||
void r8712_atimdone_event_callback(struct _adapter *adapter, u8 *pbuf);
|
||||
void r8712_cpwm_event_callback(struct _adapter *adapter, u8 *pbuf);
|
||||
void r8712_wpspbc_event_callback(struct _adapter *adapter, u8 *pbuf);
|
||||
void r8712_free_network_queue(struct _adapter *adapter);
|
||||
int r8712_init_mlme_priv(struct _adapter *adapter);
|
||||
void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv);
|
||||
sint r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv);
|
||||
sint r8712_set_key(struct _adapter *adapter,
|
||||
struct security_priv *psecuritypriv, sint keyid);
|
||||
sint r8712_set_auth(struct _adapter *adapter,
|
||||
struct security_priv *psecuritypriv);
|
||||
uint r8712_get_ndis_wlan_bssid_ex_sz(struct ndis_wlan_bssid_ex *bss);
|
||||
void r8712_generate_random_ibss(u8 *pibss);
|
||||
u8 *r8712_get_capability_from_ie(u8 *ie);
|
||||
struct wlan_network *r8712_get_oldest_wlan_network(
|
||||
struct __queue *scanned_queue);
|
||||
void r8712_free_assoc_resources(struct _adapter *adapter);
|
||||
void r8712_ind_disconnect(struct _adapter *adapter);
|
||||
void r8712_indicate_connect(struct _adapter *adapter);
|
||||
int r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
|
||||
u8 *out_ie, uint in_len);
|
||||
int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie,
|
||||
u8 *out_ie, uint in_len, uint initial_out_len);
|
||||
void r8712_init_registrypriv_dev_network(struct _adapter *adapter);
|
||||
void r8712_update_registrypriv_dev_network(struct _adapter *adapter);
|
||||
void _r8712_sitesurvey_ctrl_handler(struct _adapter *adapter);
|
||||
void _r8712_join_timeout_handler(struct _adapter *adapter);
|
||||
void r8712_scan_timeout_handler(struct _adapter *adapter);
|
||||
void _r8712_dhcp_timeout_handler(struct _adapter *adapter);
|
||||
void _r8712_wdg_timeout_handler(struct _adapter *adapter);
|
||||
struct wlan_network *_r8712_alloc_network(struct mlme_priv *pmlmepriv);
|
||||
sint r8712_if_up(struct _adapter *padapter);
|
||||
void r8712_joinbss_reset(struct _adapter *padapter);
|
||||
unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
|
||||
u8 *out_ie, uint in_len, uint *pout_len);
|
||||
void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority);
|
||||
unsigned int r8712_add_ht_addt_info(struct _adapter *padapter, u8 *in_ie,
|
||||
u8 *out_ie, uint in_len, uint *pout_len);
|
||||
int r8712_is_same_ibss(struct _adapter *adapter, struct wlan_network *pnetwork);
|
||||
|
||||
#endif /*__RTL871X_MLME_H_*/
|
736
drivers/staging/rtl8712/rtl871x_mp.c
Normal file
736
drivers/staging/rtl8712/rtl871x_mp.c
Normal file
@ -0,0 +1,736 @@
|
||||
/******************************************************************************
|
||||
* rtl871x_mp.c
|
||||
*
|
||||
* Description :
|
||||
*
|
||||
* Author :
|
||||
*
|
||||
* History :
|
||||
*
|
||||
* Copyright 2007, Realtek Corp.
|
||||
*
|
||||
* The contents of this file is the sole property of Realtek Corp. It can not be
|
||||
* be used, copied or modified without written permission from Realtek Corp.
|
||||
*
|
||||
*******************************************************************************/
|
||||
#define _RTL871X_MP_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "rtl871x_mp_phy_regdef.h"
|
||||
#include "rtl8712_cmd.h"
|
||||
|
||||
static void _init_mp_priv_(struct mp_priv *pmp_priv)
|
||||
{
|
||||
pmp_priv->mode = _LOOPBOOK_MODE_;
|
||||
pmp_priv->curr_ch = 1;
|
||||
pmp_priv->curr_modem = MIXED_PHY;
|
||||
pmp_priv->curr_rateidx = 0;
|
||||
pmp_priv->curr_txpoweridx = 0x14;
|
||||
pmp_priv->antenna_tx = ANTENNA_A;
|
||||
pmp_priv->antenna_rx = ANTENNA_AB;
|
||||
pmp_priv->check_mp_pkt = 0;
|
||||
pmp_priv->tx_pktcount = 0;
|
||||
pmp_priv->rx_pktcount = 0;
|
||||
pmp_priv->rx_crcerrpktcount = 0;
|
||||
}
|
||||
|
||||
static int init_mp_priv(struct mp_priv *pmp_priv)
|
||||
{
|
||||
int i, res;
|
||||
struct mp_xmit_frame *pmp_xmitframe;
|
||||
|
||||
_init_mp_priv_(pmp_priv);
|
||||
_init_queue(&pmp_priv->free_mp_xmitqueue);
|
||||
pmp_priv->pallocated_mp_xmitframe_buf = NULL;
|
||||
pmp_priv->pallocated_mp_xmitframe_buf = _malloc(NR_MP_XMITFRAME *
|
||||
sizeof(struct mp_xmit_frame) + 4);
|
||||
if (pmp_priv->pallocated_mp_xmitframe_buf == NULL) {
|
||||
res = _FAIL;
|
||||
goto _exit_init_mp_priv;
|
||||
}
|
||||
pmp_priv->pmp_xmtframe_buf = pmp_priv->pallocated_mp_xmitframe_buf +
|
||||
4 -
|
||||
((addr_t)(pmp_priv->pallocated_mp_xmitframe_buf) & 3);
|
||||
pmp_xmitframe = (struct mp_xmit_frame *)pmp_priv->pmp_xmtframe_buf;
|
||||
for (i = 0; i < NR_MP_XMITFRAME; i++) {
|
||||
_init_listhead(&(pmp_xmitframe->list));
|
||||
list_insert_tail(&(pmp_xmitframe->list),
|
||||
&(pmp_priv->free_mp_xmitqueue.queue));
|
||||
pmp_xmitframe->pkt = NULL;
|
||||
pmp_xmitframe->frame_tag = MP_FRAMETAG;
|
||||
pmp_xmitframe->padapter = pmp_priv->papdater;
|
||||
pmp_xmitframe++;
|
||||
}
|
||||
pmp_priv->free_mp_xmitframe_cnt = NR_MP_XMITFRAME;
|
||||
res = _SUCCESS;
|
||||
_exit_init_mp_priv:
|
||||
return res;
|
||||
}
|
||||
|
||||
static int free_mp_priv(struct mp_priv *pmp_priv)
|
||||
{
|
||||
int res = 0;
|
||||
kfree(pmp_priv->pallocated_mp_xmitframe_buf);
|
||||
return res;
|
||||
}
|
||||
|
||||
void mp871xinit(struct _adapter *padapter)
|
||||
{
|
||||
struct mp_priv *pmppriv = &padapter->mppriv;
|
||||
|
||||
pmppriv->papdater = padapter;
|
||||
init_mp_priv(pmppriv);
|
||||
}
|
||||
|
||||
void mp871xdeinit(struct _adapter *padapter)
|
||||
{
|
||||
struct mp_priv *pmppriv = &padapter->mppriv;
|
||||
|
||||
free_mp_priv(pmppriv);
|
||||
}
|
||||
|
||||
/*
|
||||
* Special for bb and rf reg read/write
|
||||
*/
|
||||
static u32 fw_iocmd_read(struct _adapter *pAdapter, struct IOCMD_STRUCT iocmd)
|
||||
{
|
||||
u32 cmd32 = 0, val32 = 0;
|
||||
u8 iocmd_class = iocmd.cmdclass;
|
||||
u16 iocmd_value = iocmd.value;
|
||||
u8 iocmd_idx = iocmd.index;
|
||||
|
||||
cmd32 = (iocmd_class << 24) | (iocmd_value << 8) | iocmd_idx ;
|
||||
if (r8712_fw_cmd(pAdapter, cmd32))
|
||||
r8712_fw_cmd_data(pAdapter, &val32, 1);
|
||||
else
|
||||
val32 = 0;
|
||||
return val32;
|
||||
}
|
||||
|
||||
static u8 fw_iocmd_write(struct _adapter *pAdapter,
|
||||
struct IOCMD_STRUCT iocmd, u32 value)
|
||||
{
|
||||
u32 cmd32 = 0;
|
||||
u8 iocmd_class = iocmd.cmdclass;
|
||||
u32 iocmd_value = iocmd.value;
|
||||
u8 iocmd_idx = iocmd.index;
|
||||
|
||||
r8712_fw_cmd_data(pAdapter, &value, 0);
|
||||
msleep(100);
|
||||
cmd32 = (iocmd_class << 24) | (iocmd_value << 8) | iocmd_idx ;
|
||||
return r8712_fw_cmd(pAdapter, cmd32);
|
||||
}
|
||||
|
||||
/* offset : 0X800~0XFFF */
|
||||
u32 r8712_bb_reg_read(struct _adapter *pAdapter, u16 offset)
|
||||
{
|
||||
u8 shift = offset & 0x0003; /* 4 byte access */
|
||||
u16 bb_addr = offset & 0x0FFC; /* 4 byte access */
|
||||
u32 bb_val = 0;
|
||||
struct IOCMD_STRUCT iocmd;
|
||||
|
||||
iocmd.cmdclass = IOCMD_CLASS_BB_RF;
|
||||
iocmd.value = bb_addr;
|
||||
iocmd.index = IOCMD_BB_READ_IDX;
|
||||
bb_val = fw_iocmd_read(pAdapter, iocmd);
|
||||
if (shift != 0) {
|
||||
u32 bb_val2 = 0;
|
||||
bb_val >>= (shift * 8);
|
||||
iocmd.value += 4;
|
||||
bb_val2 = fw_iocmd_read(pAdapter, iocmd);
|
||||
bb_val2 <<= ((4 - shift) * 8);
|
||||
bb_val |= bb_val2;
|
||||
}
|
||||
return bb_val;
|
||||
}
|
||||
|
||||
/* offset : 0X800~0XFFF */
|
||||
u8 r8712_bb_reg_write(struct _adapter *pAdapter, u16 offset, u32 value)
|
||||
{
|
||||
u8 shift = offset & 0x0003; /* 4 byte access */
|
||||
u16 bb_addr = offset & 0x0FFC; /* 4 byte access */
|
||||
struct IOCMD_STRUCT iocmd;
|
||||
|
||||
iocmd.cmdclass = IOCMD_CLASS_BB_RF;
|
||||
iocmd.value = bb_addr;
|
||||
iocmd.index = IOCMD_BB_WRITE_IDX;
|
||||
if (shift != 0) {
|
||||
u32 oldValue = 0;
|
||||
u32 newValue = value;
|
||||
|
||||
oldValue = r8712_bb_reg_read(pAdapter, iocmd.value);
|
||||
oldValue &= (0xFFFFFFFF >> ((4 - shift) * 8));
|
||||
value = oldValue | (newValue << (shift * 8));
|
||||
if (fw_iocmd_write(pAdapter, iocmd, value) == false)
|
||||
return false;
|
||||
iocmd.value += 4;
|
||||
oldValue = r8712_bb_reg_read(pAdapter, iocmd.value);
|
||||
oldValue &= (0xFFFFFFFF << (shift * 8));
|
||||
value = oldValue | (newValue >> ((4 - shift) * 8));
|
||||
}
|
||||
return fw_iocmd_write(pAdapter, iocmd, value);
|
||||
}
|
||||
|
||||
/* offset : 0x00 ~ 0xFF */
|
||||
u32 r8712_rf_reg_read(struct _adapter *pAdapter, u8 path, u8 offset)
|
||||
{
|
||||
u16 rf_addr = (path << 8) | offset;
|
||||
u32 rf_data;
|
||||
struct IOCMD_STRUCT iocmd;
|
||||
|
||||
iocmd.cmdclass = IOCMD_CLASS_BB_RF ;
|
||||
iocmd.value = rf_addr ;
|
||||
iocmd.index = IOCMD_RF_READ_IDX;
|
||||
rf_data = fw_iocmd_read(pAdapter, iocmd);
|
||||
return rf_data;
|
||||
}
|
||||
|
||||
u8 r8712_rf_reg_write(struct _adapter *pAdapter, u8 path, u8 offset, u32 value)
|
||||
{
|
||||
u16 rf_addr = (path << 8) | offset;
|
||||
struct IOCMD_STRUCT iocmd;
|
||||
|
||||
iocmd.cmdclass = IOCMD_CLASS_BB_RF;
|
||||
iocmd.value = rf_addr;
|
||||
iocmd.index = IOCMD_RF_WRIT_IDX;
|
||||
return fw_iocmd_write(pAdapter, iocmd, value);
|
||||
}
|
||||
|
||||
static u32 bitshift(u32 bitmask)
|
||||
{
|
||||
u32 i;
|
||||
|
||||
for (i = 0; i <= 31; i++)
|
||||
if (((bitmask>>i) & 0x1) == 1)
|
||||
break;
|
||||
return i;
|
||||
}
|
||||
|
||||
u32 get_bb_reg(struct _adapter *pAdapter, u16 offset, u32 bitmask)
|
||||
{
|
||||
u32 org_value, bit_shift, new_value;
|
||||
|
||||
org_value = r8712_bb_reg_read(pAdapter, offset);
|
||||
bit_shift = bitshift(bitmask);
|
||||
new_value = (org_value & bitmask) >> bit_shift;
|
||||
return new_value;
|
||||
}
|
||||
|
||||
u8 set_bb_reg(struct _adapter *pAdapter, u16 offset, u32 bitmask, u32 value)
|
||||
{
|
||||
u32 org_value, bit_shift, new_value;
|
||||
|
||||
if (bitmask != bMaskDWord) {
|
||||
org_value = r8712_bb_reg_read(pAdapter, offset);
|
||||
bit_shift = bitshift(bitmask);
|
||||
new_value = ((org_value & (~bitmask)) | (value << bit_shift));
|
||||
} else
|
||||
new_value = value;
|
||||
return r8712_bb_reg_write(pAdapter, offset, new_value);
|
||||
}
|
||||
|
||||
static u32 get_rf_reg(struct _adapter *pAdapter, u8 path, u8 offset,
|
||||
u32 bitmask)
|
||||
{
|
||||
u32 org_value, bit_shift, new_value;
|
||||
|
||||
org_value = r8712_rf_reg_read(pAdapter, path, offset);
|
||||
bit_shift = bitshift(bitmask);
|
||||
new_value = (org_value & bitmask) >> bit_shift;
|
||||
return new_value;
|
||||
}
|
||||
|
||||
static u8 set_rf_reg(struct _adapter *pAdapter, u8 path, u8 offset, u32 bitmask,
|
||||
u32 value)
|
||||
{
|
||||
u32 org_value, bit_shift, new_value;
|
||||
|
||||
if (bitmask != bMaskDWord) {
|
||||
org_value = r8712_rf_reg_read(pAdapter, path, offset);
|
||||
bit_shift = bitshift(bitmask);
|
||||
new_value = ((org_value & (~bitmask)) | (value << bit_shift));
|
||||
} else
|
||||
new_value = value;
|
||||
return r8712_rf_reg_write(pAdapter, path, offset, new_value);
|
||||
}
|
||||
|
||||
/*
|
||||
* SetChannel
|
||||
* Description
|
||||
* Use H2C command to change channel,
|
||||
* not only modify rf register, but also other setting need to be done.
|
||||
*/
|
||||
void r8712_SetChannel(struct _adapter *pAdapter)
|
||||
{
|
||||
struct cmd_priv *pcmdpriv = &pAdapter->cmdpriv;
|
||||
struct cmd_obj *pcmd = NULL;
|
||||
struct SetChannel_parm *pparm = NULL;
|
||||
u16 code = GEN_CMD_CODE(_SetChannel);
|
||||
|
||||
pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj));
|
||||
if (pcmd == NULL)
|
||||
return;
|
||||
pparm = (struct SetChannel_parm *)_malloc(sizeof(struct
|
||||
SetChannel_parm));
|
||||
if (pparm == NULL) {
|
||||
if (pcmd != NULL)
|
||||
kfree((u8 *)pcmd);
|
||||
return;
|
||||
}
|
||||
pparm->curr_ch = pAdapter->mppriv.curr_ch;
|
||||
init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code);
|
||||
r8712_enqueue_cmd(pcmdpriv, pcmd);
|
||||
}
|
||||
|
||||
static void SetCCKTxPower(struct _adapter *pAdapter, u8 TxPower)
|
||||
{
|
||||
u16 TxAGC = 0;
|
||||
|
||||
TxAGC = TxPower;
|
||||
set_bb_reg(pAdapter, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
|
||||
}
|
||||
|
||||
static void SetOFDMTxPower(struct _adapter *pAdapter, u8 TxPower)
|
||||
{
|
||||
u32 TxAGC = 0;
|
||||
|
||||
TxAGC |= ((TxPower<<24)|(TxPower<<16)|(TxPower<<8)|TxPower);
|
||||
set_bb_reg(pAdapter, rTxAGC_Rate18_06, bTxAGCRate18_06, TxAGC);
|
||||
set_bb_reg(pAdapter, rTxAGC_Rate54_24, bTxAGCRate54_24, TxAGC);
|
||||
set_bb_reg(pAdapter, rTxAGC_Mcs03_Mcs00, bTxAGCRateMCS3_MCS0, TxAGC);
|
||||
set_bb_reg(pAdapter, rTxAGC_Mcs07_Mcs04, bTxAGCRateMCS7_MCS4, TxAGC);
|
||||
set_bb_reg(pAdapter, rTxAGC_Mcs11_Mcs08, bTxAGCRateMCS11_MCS8, TxAGC);
|
||||
set_bb_reg(pAdapter, rTxAGC_Mcs15_Mcs12, bTxAGCRateMCS15_MCS12, TxAGC);
|
||||
}
|
||||
|
||||
void r8712_SetTxPower(struct _adapter *pAdapter)
|
||||
{
|
||||
u8 TxPower = pAdapter->mppriv.curr_txpoweridx;
|
||||
SetCCKTxPower(pAdapter, TxPower);
|
||||
SetOFDMTxPower(pAdapter, TxPower);
|
||||
}
|
||||
|
||||
void r8712_SetTxAGCOffset(struct _adapter *pAdapter, u32 ulTxAGCOffset)
|
||||
{
|
||||
u32 TxAGCOffset_B, TxAGCOffset_C, TxAGCOffset_D, tmpAGC;
|
||||
|
||||
TxAGCOffset_B = (ulTxAGCOffset&0x000000ff);
|
||||
TxAGCOffset_C = ((ulTxAGCOffset&0x0000ff00)>>8);
|
||||
TxAGCOffset_D = ((ulTxAGCOffset&0x00ff0000)>>16);
|
||||
tmpAGC = (TxAGCOffset_D<<8 | TxAGCOffset_C<<4 | TxAGCOffset_B);
|
||||
set_bb_reg(pAdapter, rFPGA0_TxGainStage,
|
||||
(bXBTxAGC|bXCTxAGC|bXDTxAGC), tmpAGC);
|
||||
}
|
||||
|
||||
void r8712_SetDataRate(struct _adapter *pAdapter)
|
||||
{
|
||||
u8 path = RF_PATH_A;
|
||||
u8 offset = RF_SYN_G2;
|
||||
u32 value;
|
||||
|
||||
value = (pAdapter->mppriv.curr_rateidx < 4) ? 0x4440 : 0xF200;
|
||||
r8712_rf_reg_write(pAdapter, path, offset, value);
|
||||
}
|
||||
|
||||
void r8712_SwitchBandwidth(struct _adapter *pAdapter)
|
||||
{
|
||||
/* 3 1.Set MAC register : BWOPMODE bit2:1 20MhzBW */
|
||||
u8 regBwOpMode = 0;
|
||||
u8 Bandwidth = pAdapter->mppriv.curr_bandwidth;
|
||||
|
||||
regBwOpMode = r8712_read8(pAdapter, 0x10250203);
|
||||
if (Bandwidth == HT_CHANNEL_WIDTH_20)
|
||||
regBwOpMode |= BIT(2);
|
||||
else
|
||||
regBwOpMode &= ~(BIT(2));
|
||||
r8712_write8(pAdapter, 0x10250203, regBwOpMode);
|
||||
/* 3 2.Set PHY related register */
|
||||
switch (Bandwidth) {
|
||||
/* 20 MHz channel*/
|
||||
case HT_CHANNEL_WIDTH_20:
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bRFMOD, 0x0);
|
||||
set_bb_reg(pAdapter, rFPGA1_RFMOD, bRFMOD, 0x0);
|
||||
/* Use PHY_REG.txt default value. Do not need to change.
|
||||
* Correct the tx power for CCK rate in 40M.
|
||||
* It is set in Tx descriptor for 8192x series
|
||||
*/
|
||||
set_bb_reg(pAdapter, rFPGA0_AnalogParameter2, bMaskDWord, 0x58);
|
||||
break;
|
||||
/* 40 MHz channel*/
|
||||
case HT_CHANNEL_WIDTH_40:
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bRFMOD, 0x1);
|
||||
set_bb_reg(pAdapter, rFPGA1_RFMOD, bRFMOD, 0x1);
|
||||
/* Use PHY_REG.txt default value. Do not need to change.
|
||||
* Correct the tx power for CCK rate in 40M.
|
||||
* Set Control channel to upper or lower. These settings are
|
||||
* required only for 40MHz */
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKSideBand,
|
||||
(HAL_PRIME_CHNL_OFFSET_DONT_CARE>>1));
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, 0xC00,
|
||||
HAL_PRIME_CHNL_OFFSET_DONT_CARE);
|
||||
set_bb_reg(pAdapter, rFPGA0_AnalogParameter2, bMaskDWord, 0x18);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* 3 3.Set RF related register */
|
||||
switch (Bandwidth) {
|
||||
case HT_CHANNEL_WIDTH_20:
|
||||
set_rf_reg(pAdapter, RF_PATH_A, RF_CHNLBW,
|
||||
BIT(10) | BIT(11), 0x01);
|
||||
break;
|
||||
case HT_CHANNEL_WIDTH_40:
|
||||
set_rf_reg(pAdapter, RF_PATH_A, RF_CHNLBW,
|
||||
BIT(10) | BIT(11), 0x00);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*------------------------------Define structure----------------------------*/
|
||||
struct R_ANTENNA_SELECT_OFDM {
|
||||
u32 r_tx_antenna:4;
|
||||
u32 r_ant_l:4;
|
||||
u32 r_ant_non_ht:4;
|
||||
u32 r_ant_ht1:4;
|
||||
u32 r_ant_ht2:4;
|
||||
u32 r_ant_ht_s1:4;
|
||||
u32 r_ant_non_ht_s1:4;
|
||||
u32 OFDM_TXSC:2;
|
||||
u32 Reserved:2;
|
||||
};
|
||||
|
||||
struct R_ANTENNA_SELECT_CCK {
|
||||
u8 r_cckrx_enable_2:2;
|
||||
u8 r_cckrx_enable:2;
|
||||
u8 r_ccktx_enable:4;
|
||||
};
|
||||
|
||||
void r8712_SwitchAntenna(struct _adapter *pAdapter)
|
||||
{
|
||||
u32 ofdm_tx_en_val = 0, ofdm_tx_ant_sel_val = 0;
|
||||
u8 ofdm_rx_ant_sel_val = 0;
|
||||
u8 cck_ant_select_val = 0;
|
||||
u32 cck_ant_sel_val = 0;
|
||||
struct R_ANTENNA_SELECT_CCK *p_cck_txrx;
|
||||
|
||||
p_cck_txrx = (struct R_ANTENNA_SELECT_CCK *)&cck_ant_select_val;
|
||||
|
||||
switch (pAdapter->mppriv.antenna_tx) {
|
||||
case ANTENNA_A:
|
||||
/* From SD3 Willis suggestion !!! Set RF A=TX and B as standby*/
|
||||
set_bb_reg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2);
|
||||
set_bb_reg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 1);
|
||||
ofdm_tx_en_val = 0x3;
|
||||
ofdm_tx_ant_sel_val = 0x11111111;/* Power save */
|
||||
p_cck_txrx->r_ccktx_enable = 0x8;
|
||||
break;
|
||||
case ANTENNA_B:
|
||||
set_bb_reg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 1);
|
||||
set_bb_reg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2);
|
||||
ofdm_tx_en_val = 0x3;
|
||||
ofdm_tx_ant_sel_val = 0x22222222;/* Power save */
|
||||
p_cck_txrx->r_ccktx_enable = 0x4;
|
||||
break;
|
||||
case ANTENNA_AB: /* For 8192S */
|
||||
set_bb_reg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2);
|
||||
set_bb_reg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2);
|
||||
ofdm_tx_en_val = 0x3;
|
||||
ofdm_tx_ant_sel_val = 0x3321333; /* Disable Power save */
|
||||
p_cck_txrx->r_ccktx_enable = 0xC;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/*OFDM Tx*/
|
||||
set_bb_reg(pAdapter, rFPGA1_TxInfo, 0xffffffff, ofdm_tx_ant_sel_val);
|
||||
/*OFDM Tx*/
|
||||
set_bb_reg(pAdapter, rFPGA0_TxInfo, 0x0000000f, ofdm_tx_en_val);
|
||||
switch (pAdapter->mppriv.antenna_rx) {
|
||||
case ANTENNA_A:
|
||||
ofdm_rx_ant_sel_val = 0x1; /* A */
|
||||
p_cck_txrx->r_cckrx_enable = 0x0; /* default: A */
|
||||
p_cck_txrx->r_cckrx_enable_2 = 0x0; /* option: A */
|
||||
break;
|
||||
case ANTENNA_B:
|
||||
ofdm_rx_ant_sel_val = 0x2; /* B */
|
||||
p_cck_txrx->r_cckrx_enable = 0x1; /* default: B */
|
||||
p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option: B */
|
||||
break;
|
||||
case ANTENNA_AB:
|
||||
ofdm_rx_ant_sel_val = 0x3; /* AB */
|
||||
p_cck_txrx->r_cckrx_enable = 0x0; /* default:A */
|
||||
p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option:B */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/*OFDM Rx*/
|
||||
set_bb_reg(pAdapter, rOFDM0_TRxPathEnable, 0x0000000f,
|
||||
ofdm_rx_ant_sel_val);
|
||||
/*OFDM Rx*/
|
||||
set_bb_reg(pAdapter, rOFDM1_TRxPathEnable, 0x0000000f,
|
||||
ofdm_rx_ant_sel_val);
|
||||
|
||||
cck_ant_sel_val = cck_ant_select_val;
|
||||
/*CCK TxRx*/
|
||||
set_bb_reg(pAdapter, rCCK0_AFESetting, bMaskByte3, cck_ant_sel_val);
|
||||
}
|
||||
|
||||
void r8712_SetCrystalCap(struct _adapter *pAdapter)
|
||||
{
|
||||
set_bb_reg(pAdapter, rFPGA0_AnalogParameter1, bXtalCap,
|
||||
pAdapter->mppriv.curr_crystalcap);
|
||||
}
|
||||
|
||||
static void TriggerRFThermalMeter(struct _adapter *pAdapter)
|
||||
{
|
||||
/* 0x24: RF Reg[6:5] */
|
||||
set_rf_reg(pAdapter, RF_PATH_A, RF_T_METER, bRFRegOffsetMask, 0x60);
|
||||
}
|
||||
|
||||
static u32 ReadRFThermalMeter(struct _adapter *pAdapter)
|
||||
{
|
||||
u32 ThermalValue = 0;
|
||||
|
||||
/* 0x24: RF Reg[4:0] */
|
||||
ThermalValue = get_rf_reg(pAdapter, RF_PATH_A, RF_T_METER, 0x1F);
|
||||
return ThermalValue;
|
||||
}
|
||||
|
||||
void r8712_GetThermalMeter(struct _adapter *pAdapter, u32 *value)
|
||||
{
|
||||
TriggerRFThermalMeter(pAdapter);
|
||||
msleep(1000);
|
||||
*value = ReadRFThermalMeter(pAdapter);
|
||||
}
|
||||
|
||||
void r8712_SetSingleCarrierTx(struct _adapter *pAdapter, u8 bStart)
|
||||
{
|
||||
if (bStart) { /* Start Single Carrier. */
|
||||
/* 1. if OFDM block on? */
|
||||
if (!get_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn))
|
||||
/*set OFDM block on*/
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);
|
||||
/* 2. set CCK test mode off, set to CCK normal mode */
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, bDisable);
|
||||
/* 3. turn on scramble setting */
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
|
||||
/* 4. Turn On Single Carrier Tx and off the other test modes. */
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bEnable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
|
||||
} else { /* Stop Single Carrier.*/
|
||||
/* Turn off all test modes.*/
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier,
|
||||
bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
|
||||
msleep(20);
|
||||
/*BB Reset*/
|
||||
set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
|
||||
set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
|
||||
}
|
||||
}
|
||||
|
||||
void r8712_SetSingleToneTx(struct _adapter *pAdapter, u8 bStart)
|
||||
{
|
||||
u8 rfPath = pAdapter->mppriv.curr_rfpath;
|
||||
switch (pAdapter->mppriv.antenna_tx) {
|
||||
case ANTENNA_B:
|
||||
rfPath = RF_PATH_B;
|
||||
break;
|
||||
case ANTENNA_A:
|
||||
default:
|
||||
rfPath = RF_PATH_A;
|
||||
break;
|
||||
}
|
||||
if (bStart) { /* Start Single Tone.*/
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn, bDisable);
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bDisable);
|
||||
set_rf_reg(pAdapter, rfPath, RF_TX_G2, bRFRegOffsetMask,
|
||||
0xd4000);
|
||||
msleep(100);
|
||||
/* PAD all on.*/
|
||||
set_rf_reg(pAdapter, rfPath, RF_AC, bRFRegOffsetMask, 0x2001f);
|
||||
msleep(100);
|
||||
} else { /* Stop Single Tone.*/
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);
|
||||
set_rf_reg(pAdapter, rfPath, RF_TX_G2, bRFRegOffsetMask,
|
||||
0x54000);
|
||||
msleep(100);
|
||||
/* PAD all on.*/
|
||||
set_rf_reg(pAdapter, rfPath, RF_AC, bRFRegOffsetMask, 0x30000);
|
||||
msleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
void r8712_SetCarrierSuppressionTx(struct _adapter *pAdapter, u8 bStart)
|
||||
{
|
||||
if (bStart) { /* Start Carrier Suppression.*/
|
||||
if (pAdapter->mppriv.curr_rateidx <= MPT_RATE_11M) {
|
||||
/* 1. if CCK block on? */
|
||||
if (!get_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn)) {
|
||||
/*set CCK block on*/
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn,
|
||||
bEnable);
|
||||
}
|
||||
/* Turn Off All Test Mode */
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx,
|
||||
bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier,
|
||||
bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone,
|
||||
bDisable);
|
||||
/*transmit mode*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, 0x2);
|
||||
/*turn off scramble setting*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKScramble,
|
||||
bDisable);
|
||||
/*Set CCK Tx Test Rate*/
|
||||
/*Set FTxRate to 1Mbps*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKTxRate, 0x0);
|
||||
}
|
||||
} else { /* Stop Carrier Suppression. */
|
||||
if (pAdapter->mppriv.curr_rateidx <= MPT_RATE_11M) {
|
||||
/*normal mode*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, 0x0);
|
||||
/*turn on scramble setting*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKScramble,
|
||||
bEnable);
|
||||
/*BB Reset*/
|
||||
set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
|
||||
set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void SetCCKContinuousTx(struct _adapter *pAdapter, u8 bStart)
|
||||
{
|
||||
u32 cckrate;
|
||||
|
||||
if (bStart) {
|
||||
/* 1. if CCK block on? */
|
||||
if (!get_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn)) {
|
||||
/*set CCK block on*/
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);
|
||||
}
|
||||
/* Turn Off All Test Mode */
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
|
||||
/*Set CCK Tx Test Rate*/
|
||||
cckrate = pAdapter->mppriv.curr_rateidx;
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKTxRate, cckrate);
|
||||
/*transmit mode*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, 0x2);
|
||||
/*turn on scramble setting*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
|
||||
} else {
|
||||
/*normal mode*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, 0x0);
|
||||
/*turn on scramble setting*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
|
||||
/*BB Reset*/
|
||||
set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
|
||||
set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
|
||||
}
|
||||
} /* mpt_StartCckContTx */
|
||||
|
||||
static void SetOFDMContinuousTx(struct _adapter *pAdapter, u8 bStart)
|
||||
{
|
||||
if (bStart) {
|
||||
/* 1. if OFDM block on? */
|
||||
if (!get_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) {
|
||||
/*set OFDM block on*/
|
||||
set_bb_reg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);
|
||||
}
|
||||
/* 2. set CCK test mode off, set to CCK normal mode*/
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKBBMode, bDisable);
|
||||
/* 3. turn on scramble setting */
|
||||
set_bb_reg(pAdapter, rCCK0_System, bCCKScramble, bEnable);
|
||||
/* 4. Turn On Continue Tx and turn off the other test modes.*/
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bEnable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
|
||||
} else {
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier,
|
||||
bDisable);
|
||||
set_bb_reg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable);
|
||||
msleep(20);
|
||||
/*BB Reset*/
|
||||
set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x0);
|
||||
set_bb_reg(pAdapter, rPMAC_Reset, bBBResetB, 0x1);
|
||||
}
|
||||
} /* mpt_StartOfdmContTx */
|
||||
|
||||
void r8712_SetContinuousTx(struct _adapter *pAdapter, u8 bStart)
|
||||
{
|
||||
/* ADC turn off [bit24-21] adc port0 ~ port1 */
|
||||
if (bStart) {
|
||||
r8712_bb_reg_write(pAdapter, rRx_Wait_CCCA,
|
||||
r8712_bb_reg_read(pAdapter,
|
||||
rRx_Wait_CCCA) & 0xFE1FFFFF);
|
||||
msleep(100);
|
||||
}
|
||||
if (pAdapter->mppriv.curr_rateidx <= MPT_RATE_11M)
|
||||
SetCCKContinuousTx(pAdapter, bStart);
|
||||
else if ((pAdapter->mppriv.curr_rateidx >= MPT_RATE_6M) &&
|
||||
(pAdapter->mppriv.curr_rateidx <= MPT_RATE_MCS15))
|
||||
SetOFDMContinuousTx(pAdapter, bStart);
|
||||
/* ADC turn on [bit24-21] adc port0 ~ port1 */
|
||||
if (!bStart)
|
||||
r8712_bb_reg_write(pAdapter, rRx_Wait_CCCA,
|
||||
r8712_bb_reg_read(pAdapter,
|
||||
rRx_Wait_CCCA) | 0x01E00000);
|
||||
}
|
||||
|
||||
void r8712_ResetPhyRxPktCount(struct _adapter *pAdapter)
|
||||
{
|
||||
u32 i, phyrx_set = 0;
|
||||
|
||||
for (i = OFDM_PPDU_BIT; i <= HT_MPDU_FAIL_BIT; i++) {
|
||||
phyrx_set = 0;
|
||||
phyrx_set |= (i << 28); /*select*/
|
||||
phyrx_set |= 0x08000000; /* set counter to zero*/
|
||||
r8712_write32(pAdapter, RXERR_RPT, phyrx_set);
|
||||
}
|
||||
}
|
||||
|
||||
static u32 GetPhyRxPktCounts(struct _adapter *pAdapter, u32 selbit)
|
||||
{
|
||||
/*selection*/
|
||||
u32 phyrx_set = 0, count = 0;
|
||||
u32 SelectBit;
|
||||
|
||||
SelectBit = selbit << 28;
|
||||
phyrx_set |= (SelectBit & 0xF0000000);
|
||||
r8712_write32(pAdapter, RXERR_RPT, phyrx_set);
|
||||
/*Read packet count*/
|
||||
count = r8712_read32(pAdapter, RXERR_RPT) & RPTMaxCount;
|
||||
return count;
|
||||
}
|
||||
|
||||
u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter)
|
||||
{
|
||||
u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
|
||||
|
||||
OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_OK_BIT);
|
||||
CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_OK_BIT);
|
||||
HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_OK_BIT);
|
||||
return OFDM_cnt + CCK_cnt + HT_cnt;
|
||||
}
|
||||
|
||||
u32 r8712_GetPhyRxPktCRC32Error(struct _adapter *pAdapter)
|
||||
{
|
||||
u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
|
||||
|
||||
OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_FAIL_BIT);
|
||||
CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_FAIL_BIT);
|
||||
HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_FAIL_BIT);
|
||||
return OFDM_cnt + CCK_cnt + HT_cnt;
|
||||
}
|
318
drivers/staging/rtl8712/rtl871x_mp.h
Normal file
318
drivers/staging/rtl8712/rtl871x_mp.h
Normal file
@ -0,0 +1,318 @@
|
||||
#ifndef __RTL871X_MP_H_
|
||||
#define __RTL871X_MP_H_
|
||||
|
||||
/* 00 - Success */
|
||||
/* 11 - Error */
|
||||
#define STATUS_SUCCESS (0x00000000L)
|
||||
#define STATUS_PENDING (0x00000103L)
|
||||
#define STATUS_UNSUCCESSFUL (0xC0000001L)
|
||||
#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL)
|
||||
#define STATUS_NOT_SUPPORTED (0xC00000BBL)
|
||||
#define NDIS_STATUS_SUCCESS ((uint)STATUS_SUCCESS)
|
||||
#define NDIS_STATUS_PENDING ((uint) STATUS_PENDING)
|
||||
#define NDIS_STATUS_NOT_RECOGNIZED ((uint)0x00010001L)
|
||||
#define NDIS_STATUS_NOT_COPIED ((uint)0x00010002L)
|
||||
#define NDIS_STATUS_NOT_ACCEPTED ((uint)0x00010003L)
|
||||
#define NDIS_STATUS_CALL_ACTIVE ((uint)0x00010007L)
|
||||
#define NDIS_STATUS_FAILURE ((uint) STATUS_UNSUCCESSFUL)
|
||||
#define NDIS_STATUS_RESOURCES ((uint)\
|
||||
STATUS_INSUFFICIENT_RESOURCES)
|
||||
#define NDIS_STATUS_CLOSING ((uint)0xC0010002L)
|
||||
#define NDIS_STATUS_BAD_VERSION ((uint)0xC0010004L)
|
||||
#define NDIS_STATUS_BAD_CHARACTERISTICS ((uint)0xC0010005L)
|
||||
#define NDIS_STATUS_ADAPTER_NOT_FOUND ((uint)0xC0010006L)
|
||||
#define NDIS_STATUS_OPEN_FAILED ((uint)0xC0010007L)
|
||||
#define NDIS_STATUS_DEVICE_FAILED ((uint)0xC0010008L)
|
||||
#define NDIS_STATUS_MULTICAST_FULL ((uint)0xC0010009L)
|
||||
#define NDIS_STATUS_MULTICAST_EXISTS ((uint)0xC001000AL)
|
||||
#define NDIS_STATUS_MULTICAST_NOT_FOUND ((uint)0xC001000BL)
|
||||
#define NDIS_STATUS_REQUEST_ABORTED ((uint)0xC001000CL)
|
||||
#define NDIS_STATUS_RESET_IN_PROGRESS ((uint)0xC001000DL)
|
||||
#define NDIS_STATUS_CLOSING_INDICATING ((uint)0xC001000EL)
|
||||
#define NDIS_STATUS_NOT_SUPPORTED ((uint)STATUS_NOT_SUPPORTED)
|
||||
#define NDIS_STATUS_INVALID_PACKET ((uint)0xC001000FL)
|
||||
#define NDIS_STATUS_OPEN_LIST_FULL ((uint)0xC0010010L)
|
||||
#define NDIS_STATUS_ADAPTER_NOT_READY ((uint)0xC0010011L)
|
||||
#define NDIS_STATUS_ADAPTER_NOT_OPEN ((uint)0xC0010012L)
|
||||
#define NDIS_STATUS_NOT_INDICATING ((uint)0xC0010013L)
|
||||
#define NDIS_STATUS_INVALID_LENGTH ((uint)0xC0010014L)
|
||||
#define NDIS_STATUS_INVALID_DATA ((uint)0xC0010015L)
|
||||
#define NDIS_STATUS_BUFFER_TOO_SHORT ((uint)0xC0010016L)
|
||||
#define NDIS_STATUS_INVALID_OID ((uint)0xC0010017L)
|
||||
#define NDIS_STATUS_ADAPTER_REMOVED ((uint)0xC0010018L)
|
||||
#define NDIS_STATUS_UNSUPPORTED_MEDIA ((uint)0xC0010019L)
|
||||
#define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((uint)0xC001001AL)
|
||||
#define NDIS_STATUS_FILE_NOT_FOUND ((uint)0xC001001BL)
|
||||
#define NDIS_STATUS_ERROR_READING_FILE ((uint)0xC001001CL)
|
||||
#define NDIS_STATUS_ALREADY_MAPPED ((uint)0xC001001DL)
|
||||
#define NDIS_STATUS_RESOURCE_CONFLICT ((uint)0xC001001EL)
|
||||
#define NDIS_STATUS_NO_CABLE ((uint)0xC001001FL)
|
||||
#define NDIS_STATUS_INVALID_SAP ((uint)0xC0010020L)
|
||||
#define NDIS_STATUS_SAP_IN_USE ((uint)0xC0010021L)
|
||||
#define NDIS_STATUS_INVALID_ADDRESS ((uint)0xC0010022L)
|
||||
#define NDIS_STATUS_VC_NOT_ACTIVATED ((uint)0xC0010023L)
|
||||
#define NDIS_STATUS_DEST_OUT_OF_ORDER ((uint)0xC0010024L) /* cause 27*/
|
||||
#define NDIS_STATUS_VC_NOT_AVAILABLE ((uint)0xC0010025L) /* 35,45*/
|
||||
#define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((uint)0xC0010026L) /* 37*/
|
||||
#define NDIS_STATUS_INCOMPATABLE_QOS ((uint)0xC0010027L) /* 49*/
|
||||
#define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((uint)0xC0010028L) /* 93*/
|
||||
#define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((uint)0xC0010029L) /* 3*/
|
||||
#define MPT_NOOP 0
|
||||
#define MPT_READ_MAC_1BYTE 1
|
||||
#define MPT_READ_MAC_2BYTE 2
|
||||
#define MPT_READ_MAC_4BYTE 3
|
||||
#define MPT_WRITE_MAC_1BYTE 4
|
||||
#define MPT_WRITE_MAC_2BYTE 5
|
||||
#define MPT_WRITE_MAC_4BYTE 6
|
||||
#define MPT_READ_BB_CCK 7
|
||||
#define MPT_WRITE_BB_CCK 8
|
||||
#define MPT_READ_BB_OFDM 9
|
||||
#define MPT_WRITE_BB_OFDM 10
|
||||
#define MPT_READ_RF 11
|
||||
#define MPT_WRITE_RF 12
|
||||
#define MPT_READ_EEPROM_1BYTE 13
|
||||
#define MPT_WRITE_EEPROM_1BYTE 14
|
||||
#define MPT_READ_EEPROM_2BYTE 15
|
||||
#define MPT_WRITE_EEPROM_2BYTE 16
|
||||
#define MPT_SET_CSTHRESHOLD 21
|
||||
#define MPT_SET_INITGAIN 22
|
||||
#define MPT_SWITCH_BAND 23
|
||||
#define MPT_SWITCH_CHANNEL 24
|
||||
#define MPT_SET_DATARATE 25
|
||||
#define MPT_SWITCH_ANTENNA 26
|
||||
#define MPT_SET_TX_POWER 27
|
||||
#define MPT_SET_CONT_TX 28
|
||||
#define MPT_SET_SINGLE_CARRIER 29
|
||||
#define MPT_SET_CARRIER_SUPPRESSION 30
|
||||
#define MPT_GET_RATE_TABLE 31
|
||||
#define MPT_READ_TSSI 32
|
||||
#define MPT_GET_THERMAL_METER 33
|
||||
#define MAX_MP_XMITBUF_SZ 2048
|
||||
#define NR_MP_XMITFRAME 8
|
||||
|
||||
struct mp_xmit_frame {
|
||||
struct list_head list;
|
||||
struct pkt_attrib attrib;
|
||||
_pkt *pkt;
|
||||
int frame_tag;
|
||||
struct _adapter *padapter;
|
||||
u8 *mem_addr;
|
||||
u16 sz[8];
|
||||
struct urb *pxmit_urb[8];
|
||||
u8 bpending[8];
|
||||
u8 last[8];
|
||||
uint mem[(MAX_MP_XMITBUF_SZ >> 2)];
|
||||
};
|
||||
|
||||
struct mp_wiparam {
|
||||
u32 bcompleted;
|
||||
u32 act_type;
|
||||
u32 io_offset;
|
||||
u32 io_value;
|
||||
};
|
||||
|
||||
struct mp_priv {
|
||||
struct _adapter *papdater;
|
||||
/*OID cmd handler*/
|
||||
struct mp_wiparam workparam;
|
||||
u8 act_in_progress;
|
||||
/*Tx Section*/
|
||||
u8 TID;
|
||||
u32 tx_pktcount;
|
||||
/*Rx Section*/
|
||||
u32 rx_pktcount;
|
||||
u32 rx_crcerrpktcount;
|
||||
u32 rx_pktloss;
|
||||
struct recv_stat rxstat;
|
||||
/*RF/BB relative*/
|
||||
u32 curr_ch;
|
||||
u32 curr_rateidx;
|
||||
u8 curr_bandwidth;
|
||||
u8 curr_modem;
|
||||
u8 curr_txpoweridx;
|
||||
u32 curr_crystalcap;
|
||||
u16 antenna_tx;
|
||||
u16 antenna_rx;
|
||||
u8 curr_rfpath;
|
||||
u8 check_mp_pkt;
|
||||
uint ForcedDataRate;
|
||||
struct wlan_network mp_network;
|
||||
unsigned char network_macaddr[6];
|
||||
/*Testing Flag*/
|
||||
u32 mode;/*0 for normal type packet,
|
||||
* 1 for loopback packet (16bytes TXCMD)*/
|
||||
sint prev_fw_state;
|
||||
u8 *pallocated_mp_xmitframe_buf;
|
||||
u8 *pmp_xmtframe_buf;
|
||||
struct __queue free_mp_xmitqueue;
|
||||
u32 free_mp_xmitframe_cnt;
|
||||
};
|
||||
|
||||
struct IOCMD_STRUCT {
|
||||
u8 cmdclass;
|
||||
u16 value;
|
||||
u8 index;
|
||||
};
|
||||
|
||||
struct rf_reg_param {
|
||||
u32 path;
|
||||
u32 offset;
|
||||
u32 value;
|
||||
};
|
||||
|
||||
struct bb_reg_param {
|
||||
u32 offset;
|
||||
u32 value;
|
||||
};
|
||||
/* ======================================================================= */
|
||||
|
||||
#define LOWER true
|
||||
#define RAISE false
|
||||
#define IOCMD_CTRL_REG 0x10250370
|
||||
#define IOCMD_DATA_REG 0x10250374
|
||||
#define IOCMD_GET_THERMAL_METER 0xFD000028
|
||||
#define IOCMD_CLASS_BB_RF 0xF0
|
||||
#define IOCMD_BB_READ_IDX 0x00
|
||||
#define IOCMD_BB_WRITE_IDX 0x01
|
||||
#define IOCMD_RF_READ_IDX 0x02
|
||||
#define IOCMD_RF_WRIT_IDX 0x03
|
||||
#define BB_REG_BASE_ADDR 0x800
|
||||
#define RF_PATH_A 0
|
||||
#define RF_PATH_B 1
|
||||
#define RF_PATH_C 2
|
||||
#define RF_PATH_D 3
|
||||
#define MAX_RF_PATH_NUMS 2
|
||||
#define _2MAC_MODE_ 0
|
||||
#define _LOOPBOOK_MODE_ 1
|
||||
|
||||
/* MP set force data rate base on the definition. */
|
||||
enum {
|
||||
/* CCK rate. */
|
||||
MPT_RATE_1M, /* 0 */
|
||||
MPT_RATE_2M,
|
||||
MPT_RATE_55M,
|
||||
MPT_RATE_11M, /* 3 */
|
||||
|
||||
/* OFDM rate. */
|
||||
MPT_RATE_6M, /* 4 */
|
||||
MPT_RATE_9M,
|
||||
MPT_RATE_12M,
|
||||
MPT_RATE_18M,
|
||||
MPT_RATE_24M,
|
||||
MPT_RATE_36M,
|
||||
MPT_RATE_48M,
|
||||
MPT_RATE_54M, /* 11 */
|
||||
|
||||
/* HT rate. */
|
||||
MPT_RATE_MCS0, /* 12 */
|
||||
MPT_RATE_MCS1,
|
||||
MPT_RATE_MCS2,
|
||||
MPT_RATE_MCS3,
|
||||
MPT_RATE_MCS4,
|
||||
MPT_RATE_MCS5,
|
||||
MPT_RATE_MCS6,
|
||||
MPT_RATE_MCS7, /* 19 */
|
||||
MPT_RATE_MCS8,
|
||||
MPT_RATE_MCS9,
|
||||
MPT_RATE_MCS10,
|
||||
MPT_RATE_MCS11,
|
||||
MPT_RATE_MCS12,
|
||||
MPT_RATE_MCS13,
|
||||
MPT_RATE_MCS14,
|
||||
MPT_RATE_MCS15, /* 27 */
|
||||
MPT_RATE_LAST
|
||||
};
|
||||
|
||||
/* Represent Channel Width in HT Capabilities */
|
||||
enum HT_CHANNEL_WIDTH {
|
||||
HT_CHANNEL_WIDTH_20 = 0,
|
||||
HT_CHANNEL_WIDTH_40 = 1,
|
||||
};
|
||||
|
||||
#define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */
|
||||
|
||||
enum POWER_MODE {
|
||||
POWER_LOW = 0,
|
||||
POWER_NORMAL
|
||||
};
|
||||
|
||||
#define RX_PKT_BROADCAST 1
|
||||
#define RX_PKT_DEST_ADDR 2
|
||||
#define RX_PKT_PHY_MATCH 3
|
||||
|
||||
#define RPTMaxCount 0x000FFFFF;
|
||||
|
||||
/* parameter 1 : BitMask
|
||||
* bit 0 : OFDM PPDU
|
||||
* bit 1 : OFDM False Alarm
|
||||
* bit 2 : OFDM MPDU OK
|
||||
* bit 3 : OFDM MPDU Fail
|
||||
* bit 4 : CCK PPDU
|
||||
* bit 5 : CCK False Alarm
|
||||
* bit 6 : CCK MPDU ok
|
||||
* bit 7 : CCK MPDU fail
|
||||
* bit 8 : HT PPDU counter
|
||||
* bit 9 : HT false alarm
|
||||
* bit 10 : HT MPDU total
|
||||
* bit 11 : HT MPDU OK
|
||||
* bit 12 : HT MPDU fail
|
||||
* bit 15 : RX full drop
|
||||
*/
|
||||
enum RXPHY_BITMASK {
|
||||
OFDM_PPDU_BIT = 0,
|
||||
OFDM_MPDU_OK_BIT,
|
||||
OFDM_MPDU_FAIL_BIT,
|
||||
CCK_PPDU_BIT,
|
||||
CCK_MPDU_OK_BIT,
|
||||
CCK_MPDU_FAIL_BIT,
|
||||
HT_PPDU_BIT,
|
||||
HT_MPDU_BIT,
|
||||
HT_MPDU_OK_BIT,
|
||||
HT_MPDU_FAIL_BIT,
|
||||
};
|
||||
|
||||
enum ENCRY_CTRL_STATE {
|
||||
HW_CONTROL, /*hw encryption& decryption*/
|
||||
SW_CONTROL, /*sw encryption& decryption*/
|
||||
HW_ENCRY_SW_DECRY, /*hw encryption & sw decryption*/
|
||||
SW_ENCRY_HW_DECRY /*sw encryption & hw decryption*/
|
||||
};
|
||||
|
||||
/* Bandwidth Offset */
|
||||
#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
|
||||
#define HAL_PRIME_CHNL_OFFSET_LOWER 1
|
||||
#define HAL_PRIME_CHNL_OFFSET_UPPER 2
|
||||
/*=======================================================================*/
|
||||
void mp871xinit(struct _adapter *padapter);
|
||||
void mp871xdeinit(struct _adapter *padapter);
|
||||
u32 r8712_bb_reg_read(struct _adapter *Adapter, u16 offset);
|
||||
u8 r8712_bb_reg_write(struct _adapter *Adapter, u16 offset, u32 value);
|
||||
u32 r8712_rf_reg_read(struct _adapter *Adapter, u8 path, u8 offset);
|
||||
u8 r8712_rf_reg_write(struct _adapter *Adapter, u8 path,
|
||||
u8 offset, u32 value);
|
||||
u32 r8712_get_bb_reg(struct _adapter *Adapter, u16 offset, u32 bitmask);
|
||||
u8 r8712_set_bb_reg(struct _adapter *Adapter, u16 offset,
|
||||
u32 bitmask, u32 value);
|
||||
u32 r8712_get_rf_reg(struct _adapter *Adapter, u8 path, u8 offset,
|
||||
u32 bitmask);
|
||||
u8 r8712_set_rf_reg(struct _adapter *Adapter, u8 path, u8 offset,
|
||||
u32 bitmask, u32 value);
|
||||
|
||||
void r8712_SetChannel(struct _adapter *pAdapter);
|
||||
void r8712_SetTxPower(struct _adapter *pAdapte);
|
||||
void r8712_SetTxAGCOffset(struct _adapter *pAdapter, u32 ulTxAGCOffset);
|
||||
void r8712_SetDataRate(struct _adapter *pAdapter);
|
||||
void r8712_SwitchBandwidth(struct _adapter *pAdapter);
|
||||
void r8712_SwitchAntenna(struct _adapter *pAdapter);
|
||||
void r8712_SetCrystalCap(struct _adapter *pAdapter);
|
||||
void r8712_GetThermalMeter(struct _adapter *pAdapter, u32 *value);
|
||||
void r8712_SetContinuousTx(struct _adapter *pAdapter, u8 bStart);
|
||||
void r8712_SetSingleCarrierTx(struct _adapter *pAdapter, u8 bStart);
|
||||
void r8712_SetSingleToneTx(struct _adapter *pAdapter, u8 bStart);
|
||||
void r8712_SetCarrierSuppressionTx(struct _adapter *pAdapter, u8 bStart);
|
||||
void r8712_ResetPhyRxPktCount(struct _adapter *pAdapter);
|
||||
u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter);
|
||||
u32 r8712_GetPhyRxPktCRC32Error(struct _adapter *pAdapter);
|
||||
|
||||
#endif /*__RTL871X_MP_H_*/
|
||||
|
1475
drivers/staging/rtl8712/rtl871x_mp_ioctl.c
Normal file
1475
drivers/staging/rtl8712/rtl871x_mp_ioctl.c
Normal file
File diff suppressed because it is too large
Load Diff
457
drivers/staging/rtl8712/rtl871x_mp_ioctl.h
Normal file
457
drivers/staging/rtl8712/rtl871x_mp_ioctl.h
Normal file
@ -0,0 +1,457 @@
|
||||
#ifndef _RTL871X_MP_IOCTL_H
|
||||
#define _RTL871X_MP_IOCTL_H
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "mp_custom_oid.h"
|
||||
#include "rtl871x_ioctl.h"
|
||||
#include "rtl871x_ioctl_rtl.h"
|
||||
#include "rtl8712_efuse.h"
|
||||
|
||||
#define TESTFWCMDNUMBER 1000000
|
||||
#define TEST_H2CINT_WAIT_TIME 500
|
||||
#define TEST_C2HINT_WAIT_TIME 500
|
||||
#define HCI_TEST_SYSCFG_HWMASK 1
|
||||
#define _BUSCLK_40M (4 << 2)
|
||||
|
||||
struct CFG_DBG_MSG_STRUCT {
|
||||
u32 DebugLevel;
|
||||
u32 DebugComponent_H32;
|
||||
u32 DebugComponent_L32;
|
||||
};
|
||||
|
||||
struct mp_rw_reg {
|
||||
uint offset;
|
||||
uint width;
|
||||
u32 value;
|
||||
};
|
||||
|
||||
/* for OID_RT_PRO_READ16_EEPROM & OID_RT_PRO_WRITE16_EEPROM */
|
||||
struct eeprom_rw_param {
|
||||
uint offset;
|
||||
u16 value;
|
||||
};
|
||||
|
||||
struct EFUSE_ACCESS_STRUCT {
|
||||
u16 start_addr;
|
||||
u16 cnts;
|
||||
u8 data[0];
|
||||
};
|
||||
|
||||
struct burst_rw_reg {
|
||||
uint offset;
|
||||
uint len;
|
||||
u8 Data[256];
|
||||
};
|
||||
|
||||
struct usb_vendor_req {
|
||||
u8 bRequest;
|
||||
u16 wValue;
|
||||
u16 wIndex;
|
||||
u16 wLength;
|
||||
u8 u8Dir;/*0:OUT, 1:IN */
|
||||
u8 u8InData;
|
||||
};
|
||||
|
||||
struct DR_VARIABLE_STRUCT {
|
||||
u8 offset;
|
||||
u32 variable;
|
||||
};
|
||||
|
||||
int mp_start_joinbss(struct _adapter *padapter, struct ndis_802_11_ssid *pssid);
|
||||
|
||||
/* oid_rtl_seg_87_11_00 */
|
||||
uint oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_burst_read_register_hdl(struct oid_par_priv*
|
||||
poid_par_priv);
|
||||
uint oid_rt_pro_burst_write_register_hdl(struct oid_par_priv*
|
||||
poid_par_priv);
|
||||
uint oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_wr_attrib_mem_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv);
|
||||
/* oid_rtl_seg_87_11_20 */
|
||||
uint oid_rt_pro_cfg_debug_message_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_data_rate_ex_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_basic_rate_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_power_tracking_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
/* oid_rtl_seg_87_11_50 */
|
||||
uint oid_rt_pro_qry_pwrstate_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_pwrstate_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
/* oid_rtl_seg_87_11_F0 */
|
||||
uint oid_rt_pro_h2c_set_rate_table_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_h2c_get_rate_table_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
/* oid_rtl_seg_81_80_00 */
|
||||
uint oid_rt_pro_set_data_rate_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_channel_direct_call_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_antenna_bb_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_tx_power_control_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
/* oid_rtl_seg_81_80_20 */
|
||||
uint oid_rt_pro_query_tx_packet_sent_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_query_rx_packet_received_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_query_rx_packet_crc32_error_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_reset_tx_packet_sent_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_reset_rx_packet_received_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_continuous_tx_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_single_carrier_tx_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_carrier_suppression_tx_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_single_tone_tx_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
/* oid_rtl_seg_81_87 */
|
||||
uint oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv);
|
||||
/* oid_rtl_seg_81_85 */
|
||||
uint oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv);
|
||||
/* oid_rtl_seg_87_12_00 */
|
||||
uint oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_query_dr_variable_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_efuse_current_size_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_tx_agc_offset_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_pro_set_pkt_test_mode_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_thermal_meter_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_reset_phy_rx_packet_count_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_phy_rx_packet_received_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_phy_rx_packet_crc32_error_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_set_power_down_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
uint oid_rt_get_power_mode_hdl(
|
||||
struct oid_par_priv *poid_par_priv);
|
||||
#ifdef _RTL871X_MP_IOCTL_C_ /* CAUTION!!! */
|
||||
/* This ifdef _MUST_ be left in!! */
|
||||
static const struct oid_obj_priv oid_rtl_seg_81_80_00[] = {
|
||||
{1, &oid_null_function}, /*0x00 OID_RT_PRO_RESET_DUT */
|
||||
{1, &oid_rt_pro_set_data_rate_hdl}, /*0x01*/
|
||||
{1, &oid_rt_pro_start_test_hdl},/*0x02*/
|
||||
{1, &oid_rt_pro_stop_test_hdl}, /*0x03*/
|
||||
{1, &oid_null_function}, /*0x04 OID_RT_PRO_SET_PREAMBLE*/
|
||||
{1, &oid_null_function}, /*0x05 OID_RT_PRO_SET_SCRAMBLER*/
|
||||
{1, &oid_null_function}, /*0x06 OID_RT_PRO_SET_FILTER_BB*/
|
||||
{1, &oid_null_function}, /*0x07
|
||||
* OID_RT_PRO_SET_MANUAL_DIVERS_BB*/
|
||||
{1, &oid_rt_pro_set_channel_direct_call_hdl}, /*0x08*/
|
||||
{1, &oid_null_function}, /*0x09
|
||||
* OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL*/
|
||||
{1, &oid_null_function}, /*0x0A
|
||||
* OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL*/
|
||||
{1, &oid_rt_pro_set_continuous_tx_hdl}, /*0x0B
|
||||
* OID_RT_PRO_SET_TX_CONTINUOUS_DIRECT_CALL*/
|
||||
{1, &oid_rt_pro_set_single_carrier_tx_hdl}, /*0x0C
|
||||
* OID_RT_PRO_SET_SINGLE_CARRIER_TX_CONTINUOUS*/
|
||||
{1, &oid_null_function}, /*0x0D
|
||||
* OID_RT_PRO_SET_TX_ANTENNA_BB*/
|
||||
{1, &oid_rt_pro_set_antenna_bb_hdl}, /*0x0E*/
|
||||
{1, &oid_null_function}, /*0x0F OID_RT_PRO_SET_CR_SCRAMBLER*/
|
||||
{1, &oid_null_function}, /*0x10 OID_RT_PRO_SET_CR_NEW_FILTER*/
|
||||
{1, &oid_rt_pro_set_tx_power_control_hdl}, /*0x11
|
||||
* OID_RT_PRO_SET_TX_POWER_CONTROL*/
|
||||
{1, &oid_null_function}, /*0x12 OID_RT_PRO_SET_CR_TX_CONFIG*/
|
||||
{1, &oid_null_function}, /*0x13
|
||||
* OID_RT_PRO_GET_TX_POWER_CONTROL*/
|
||||
{1, &oid_null_function}, /*0x14
|
||||
* OID_RT_PRO_GET_CR_SIGNAL_QUALITY*/
|
||||
{1, &oid_null_function}, /*0x15 OID_RT_PRO_SET_CR_SETPOINT*/
|
||||
{1, &oid_null_function}, /*0x16 OID_RT_PRO_SET_INTEGRATOR*/
|
||||
{1, &oid_null_function}, /*0x17 OID_RT_PRO_SET_SIGNAL_QUALITY*/
|
||||
{1, &oid_null_function}, /*0x18 OID_RT_PRO_GET_INTEGRATOR*/
|
||||
{1, &oid_null_function}, /*0x19 OID_RT_PRO_GET_SIGNAL_QUALITY*/
|
||||
{1, &oid_null_function}, /*0x1A OID_RT_PRO_QUERY_EEPROM_TYPE*/
|
||||
{1, &oid_null_function}, /*0x1B OID_RT_PRO_WRITE_MAC_ADDRESS*/
|
||||
{1, &oid_null_function}, /*0x1C OID_RT_PRO_READ_MAC_ADDRESS*/
|
||||
{1, &oid_null_function}, /*0x1D OID_RT_PRO_WRITE_CIS_DATA*/
|
||||
{1, &oid_null_function}, /*0x1E OID_RT_PRO_READ_CIS_DATA*/
|
||||
{1, &oid_null_function} /*0x1F OID_RT_PRO_WRITE_POWER_CONTROL*/
|
||||
};
|
||||
|
||||
static const struct oid_obj_priv oid_rtl_seg_81_80_20[] = {
|
||||
{1, &oid_null_function}, /*0x20 OID_RT_PRO_READ_POWER_CONTROL*/
|
||||
{1, &oid_null_function}, /*0x21 OID_RT_PRO_WRITE_EEPROM*/
|
||||
{1, &oid_null_function}, /*0x22 OID_RT_PRO_READ_EEPROM*/
|
||||
{1, &oid_rt_pro_reset_tx_packet_sent_hdl}, /*0x23*/
|
||||
{1, &oid_rt_pro_query_tx_packet_sent_hdl}, /*0x24*/
|
||||
{1, &oid_rt_pro_reset_rx_packet_received_hdl}, /*0x25*/
|
||||
{1, &oid_rt_pro_query_rx_packet_received_hdl}, /*0x26*/
|
||||
{1, &oid_rt_pro_query_rx_packet_crc32_error_hdl},/*0x27*/
|
||||
{1, &oid_null_function}, /*0x28
|
||||
*OID_RT_PRO_QUERY_CURRENT_ADDRESS*/
|
||||
{1, &oid_null_function}, /*0x29
|
||||
*OID_RT_PRO_QUERY_PERMANENT_ADDRESS*/
|
||||
{1, &oid_null_function}, /*0x2A
|
||||
*OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS*/
|
||||
{1, &oid_rt_pro_set_carrier_suppression_tx_hdl},/*0x2B
|
||||
*OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX*/
|
||||
{1, &oid_null_function}, /*0x2C OID_RT_PRO_RECEIVE_PACKET*/
|
||||
{1, &oid_null_function}, /*0x2D OID_RT_PRO_WRITE_EEPROM_BYTE*/
|
||||
{1, &oid_null_function}, /*0x2E OID_RT_PRO_READ_EEPROM_BYTE*/
|
||||
{1, &oid_rt_pro_set_modulation_hdl} /*0x2F*/
|
||||
};
|
||||
|
||||
static const struct oid_obj_priv oid_rtl_seg_81_80_40[] = {
|
||||
{1, &oid_null_function}, /*0x40*/
|
||||
{1, &oid_null_function}, /*0x41*/
|
||||
{1, &oid_null_function}, /*0x42*/
|
||||
{1, &oid_rt_pro_set_single_tone_tx_hdl}, /*0x43*/
|
||||
{1, &oid_null_function}, /*0x44*/
|
||||
{1, &oid_null_function} /*0x45*/
|
||||
};
|
||||
|
||||
static const struct oid_obj_priv oid_rtl_seg_81_80_80[] = {
|
||||
{1, &oid_null_function}, /*0x80 OID_RT_DRIVER_OPTION*/
|
||||
{1, &oid_null_function}, /*0x81 OID_RT_RF_OFF*/
|
||||
{1, &oid_null_function} /*0x82 OID_RT_AUTH_STATUS*/
|
||||
|
||||
};
|
||||
|
||||
static const struct oid_obj_priv oid_rtl_seg_81_85[] = {
|
||||
{1, &oid_rt_wireless_mode_hdl} /*0x00 OID_RT_WIRELESS_MODE*/
|
||||
};
|
||||
|
||||
#else /* _RTL871X_MP_IOCTL_C_ */
|
||||
extern struct oid_obj_priv oid_rtl_seg_81_80_00[32];
|
||||
extern struct oid_obj_priv oid_rtl_seg_81_80_20[16];
|
||||
extern struct oid_obj_priv oid_rtl_seg_81_80_40[6];
|
||||
extern struct oid_obj_priv oid_rtl_seg_81_80_80[3];
|
||||
extern struct oid_obj_priv oid_rtl_seg_81_85[1];
|
||||
extern struct oid_obj_priv oid_rtl_seg_81_87[5];
|
||||
extern struct oid_obj_priv oid_rtl_seg_87_11_00[32];
|
||||
extern struct oid_obj_priv oid_rtl_seg_87_11_20[5];
|
||||
extern struct oid_obj_priv oid_rtl_seg_87_11_50[2];
|
||||
extern struct oid_obj_priv oid_rtl_seg_87_11_80[1];
|
||||
extern struct oid_obj_priv oid_rtl_seg_87_11_B0[1];
|
||||
extern struct oid_obj_priv oid_rtl_seg_87_11_F0[16];
|
||||
extern struct oid_obj_priv oid_rtl_seg_87_12_00[32];
|
||||
|
||||
#endif /* _RTL871X_MP_IOCTL_C_ */
|
||||
|
||||
|
||||
enum MP_MODE {
|
||||
MP_START_MODE,
|
||||
MP_STOP_MODE,
|
||||
MP_ERR_MODE
|
||||
};
|
||||
|
||||
struct rwreg_param{
|
||||
unsigned int offset;
|
||||
unsigned int width;
|
||||
unsigned int value;
|
||||
};
|
||||
|
||||
struct bbreg_param{
|
||||
unsigned int offset;
|
||||
unsigned int phymask;
|
||||
unsigned int value;
|
||||
};
|
||||
|
||||
struct txpower_param{
|
||||
unsigned int pwr_index;
|
||||
};
|
||||
|
||||
struct datarate_param{
|
||||
unsigned int rate_index;
|
||||
};
|
||||
|
||||
struct rfintfs_parm {
|
||||
unsigned int rfintfs;
|
||||
};
|
||||
|
||||
struct mp_xmit_packet {
|
||||
unsigned int len;
|
||||
unsigned int mem[MAX_MP_XMITBUF_SZ >> 2];
|
||||
};
|
||||
|
||||
struct psmode_param {
|
||||
unsigned int ps_mode;
|
||||
unsigned int smart_ps;
|
||||
};
|
||||
|
||||
struct mp_ioctl_handler {
|
||||
unsigned int paramsize;
|
||||
unsigned int (*handler)(struct oid_par_priv *poid_par_priv);
|
||||
unsigned int oid;
|
||||
};
|
||||
|
||||
struct mp_ioctl_param{
|
||||
unsigned int subcode;
|
||||
unsigned int len;
|
||||
unsigned char data[0];
|
||||
};
|
||||
|
||||
#define GEN_MP_IOCTL_SUBCODE(code) _MP_IOCTL_ ## code ## _CMD_
|
||||
|
||||
enum RTL871X_MP_IOCTL_SUBCODE {
|
||||
GEN_MP_IOCTL_SUBCODE(MP_START), /*0*/
|
||||
GEN_MP_IOCTL_SUBCODE(MP_STOP), /*1*/
|
||||
GEN_MP_IOCTL_SUBCODE(READ_REG), /*2*/
|
||||
GEN_MP_IOCTL_SUBCODE(WRITE_REG),
|
||||
GEN_MP_IOCTL_SUBCODE(SET_CHANNEL), /*4*/
|
||||
GEN_MP_IOCTL_SUBCODE(SET_TXPOWER), /*5*/
|
||||
GEN_MP_IOCTL_SUBCODE(SET_DATARATE), /*6*/
|
||||
GEN_MP_IOCTL_SUBCODE(READ_BB_REG), /*7*/
|
||||
GEN_MP_IOCTL_SUBCODE(WRITE_BB_REG),
|
||||
GEN_MP_IOCTL_SUBCODE(READ_RF_REG), /*9*/
|
||||
GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG),
|
||||
GEN_MP_IOCTL_SUBCODE(SET_RF_INTFS),
|
||||
GEN_MP_IOCTL_SUBCODE(IOCTL_XMIT_PACKET), /*12*/
|
||||
GEN_MP_IOCTL_SUBCODE(PS_STATE), /*13*/
|
||||
GEN_MP_IOCTL_SUBCODE(READ16_EEPROM), /*14*/
|
||||
GEN_MP_IOCTL_SUBCODE(WRITE16_EEPROM), /*15*/
|
||||
GEN_MP_IOCTL_SUBCODE(SET_PTM), /*16*/
|
||||
GEN_MP_IOCTL_SUBCODE(READ_TSSI), /*17*/
|
||||
GEN_MP_IOCTL_SUBCODE(CNTU_TX), /*18*/
|
||||
GEN_MP_IOCTL_SUBCODE(SET_BANDWIDTH), /*19*/
|
||||
GEN_MP_IOCTL_SUBCODE(SET_RX_PKT_TYPE), /*20*/
|
||||
GEN_MP_IOCTL_SUBCODE(RESET_PHY_RX_PKT_CNT), /*21*/
|
||||
GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_RECV), /*22*/
|
||||
GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_ERROR), /*23*/
|
||||
GEN_MP_IOCTL_SUBCODE(SET_POWER_DOWN), /*24*/
|
||||
GEN_MP_IOCTL_SUBCODE(GET_THERMAL_METER), /*25*/
|
||||
GEN_MP_IOCTL_SUBCODE(GET_POWER_MODE), /*26*/
|
||||
GEN_MP_IOCTL_SUBCODE(EFUSE), /*27*/
|
||||
GEN_MP_IOCTL_SUBCODE(EFUSE_MAP), /*28*/
|
||||
GEN_MP_IOCTL_SUBCODE(GET_EFUSE_MAX_SIZE), /*29*/
|
||||
GEN_MP_IOCTL_SUBCODE(GET_EFUSE_CURRENT_SIZE), /*30*/
|
||||
GEN_MP_IOCTL_SUBCODE(SC_TX), /*31*/
|
||||
GEN_MP_IOCTL_SUBCODE(CS_TX), /*32*/
|
||||
GEN_MP_IOCTL_SUBCODE(ST_TX), /*33*/
|
||||
GEN_MP_IOCTL_SUBCODE(SET_ANTENNA), /*34*/
|
||||
MAX_MP_IOCTL_SUBCODE,
|
||||
};
|
||||
|
||||
unsigned int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv);
|
||||
|
||||
#ifdef _RTL871X_MP_IOCTL_C_ /* CAUTION!!! */
|
||||
/* This ifdef _MUST_ be left in!! */
|
||||
|
||||
struct mp_ioctl_handler mp_ioctl_hdl[] = {
|
||||
{sizeof(u32), oid_rt_pro_start_test_hdl,
|
||||
OID_RT_PRO_START_TEST},/*0*/
|
||||
{sizeof(u32), oid_rt_pro_stop_test_hdl,
|
||||
OID_RT_PRO_STOP_TEST},/*1*/
|
||||
{sizeof(struct rwreg_param),
|
||||
oid_rt_pro_read_register_hdl,
|
||||
OID_RT_PRO_READ_REGISTER},/*2*/
|
||||
{sizeof(struct rwreg_param),
|
||||
oid_rt_pro_write_register_hdl,
|
||||
OID_RT_PRO_WRITE_REGISTER},
|
||||
{sizeof(u32),
|
||||
oid_rt_pro_set_channel_direct_call_hdl,
|
||||
OID_RT_PRO_SET_CHANNEL_DIRECT_CALL},
|
||||
{sizeof(struct txpower_param),
|
||||
oid_rt_pro_set_tx_power_control_hdl,
|
||||
OID_RT_PRO_SET_TX_POWER_CONTROL},
|
||||
{sizeof(u32),
|
||||
oid_rt_pro_set_data_rate_hdl,
|
||||
OID_RT_PRO_SET_DATA_RATE},
|
||||
{sizeof(struct bb_reg_param),
|
||||
oid_rt_pro_read_bb_reg_hdl,
|
||||
OID_RT_PRO_READ_BB_REG},/*7*/
|
||||
{sizeof(struct bb_reg_param),
|
||||
oid_rt_pro_write_bb_reg_hdl,
|
||||
OID_RT_PRO_WRITE_BB_REG},
|
||||
{sizeof(struct rwreg_param),
|
||||
oid_rt_pro_read_rf_reg_hdl,
|
||||
OID_RT_PRO_RF_READ_REGISTRY},/*9*/
|
||||
{sizeof(struct rwreg_param),
|
||||
oid_rt_pro_write_rf_reg_hdl,
|
||||
OID_RT_PRO_RF_WRITE_REGISTRY},
|
||||
{sizeof(struct rfintfs_parm), NULL, 0},
|
||||
{0, &mp_ioctl_xmit_packet_hdl, 0},/*12*/
|
||||
{sizeof(struct psmode_param), NULL, 0},/*13*/
|
||||
{sizeof(struct eeprom_rw_param), NULL, 0},/*14*/
|
||||
{sizeof(struct eeprom_rw_param), NULL, 0},/*15*/
|
||||
{sizeof(u8), oid_rt_pro_set_power_tracking_hdl,
|
||||
OID_RT_PRO_SET_POWER_TRACKING},/*16*/
|
||||
{sizeof(u32), NULL, 0},/*17*/
|
||||
{sizeof(u32), oid_rt_pro_set_continuous_tx_hdl,
|
||||
OID_RT_PRO_SET_CONTINUOUS_TX},/*18*/
|
||||
{sizeof(u32), oid_rt_set_bandwidth_hdl,
|
||||
OID_RT_SET_BANDWIDTH},/*19*/
|
||||
{sizeof(u32), oid_rt_set_rx_packet_type_hdl,
|
||||
OID_RT_SET_RX_PACKET_TYPE},/*20*/
|
||||
{0, oid_rt_reset_phy_rx_packet_count_hdl,
|
||||
OID_RT_RESET_PHY_RX_PACKET_COUNT},/*21*/
|
||||
{sizeof(u32), oid_rt_get_phy_rx_packet_received_hdl,
|
||||
OID_RT_GET_PHY_RX_PACKET_RECEIVED},/*22*/
|
||||
{sizeof(u32), oid_rt_get_phy_rx_packet_crc32_error_hdl,
|
||||
OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR},/*23*/
|
||||
{sizeof(unsigned char), oid_rt_set_power_down_hdl,
|
||||
OID_RT_SET_POWER_DOWN},/*24*/
|
||||
{sizeof(u32), oid_rt_get_thermal_meter_hdl,
|
||||
OID_RT_PRO_GET_THERMAL_METER},/*25*/
|
||||
{sizeof(u32), oid_rt_get_power_mode_hdl,
|
||||
OID_RT_GET_POWER_MODE},/*26*/
|
||||
{sizeof(struct EFUSE_ACCESS_STRUCT),
|
||||
oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE},/*27*/
|
||||
{EFUSE_MAP_MAX_SIZE, oid_rt_pro_efuse_map_hdl,
|
||||
OID_RT_PRO_EFUSE_MAP},/*28*/
|
||||
{sizeof(u32), oid_rt_get_efuse_max_size_hdl,
|
||||
OID_RT_GET_EFUSE_MAX_SIZE},/*29*/
|
||||
{sizeof(u32), oid_rt_get_efuse_current_size_hdl,
|
||||
OID_RT_GET_EFUSE_CURRENT_SIZE},/*30*/
|
||||
{sizeof(u32), oid_rt_pro_set_single_carrier_tx_hdl,
|
||||
OID_RT_PRO_SET_SINGLE_CARRIER_TX},/*31*/
|
||||
{sizeof(u32), oid_rt_pro_set_carrier_suppression_tx_hdl,
|
||||
OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX},/*32*/
|
||||
{sizeof(u32), oid_rt_pro_set_single_tone_tx_hdl,
|
||||
OID_RT_PRO_SET_SINGLE_TONE_TX},/*33*/
|
||||
{sizeof(u32), oid_rt_pro_set_antenna_bb_hdl,
|
||||
OID_RT_PRO_SET_ANTENNA_BB},/*34*/
|
||||
};
|
||||
|
||||
#else /* _RTL871X_MP_IOCTL_C_ */
|
||||
extern struct mp_ioctl_handler mp_ioctl_hdl[];
|
||||
#endif /* _RTL871X_MP_IOCTL_C_ */
|
||||
|
||||
#endif
|
||||
|
1025
drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
Normal file
1025
drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
Normal file
File diff suppressed because it is too large
Load Diff
250
drivers/staging/rtl8712/rtl871x_pwrctrl.c
Normal file
250
drivers/staging/rtl8712/rtl871x_pwrctrl.c
Normal file
@ -0,0 +1,250 @@
|
||||
/******************************************************************************
|
||||
* rtl871x_pwrctrl.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 _RTL871X_PWRCTRL_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "osdep_intf.h"
|
||||
|
||||
#define RTL8712_SDIO_LOCAL_BASE 0X10100000
|
||||
#define SDIO_HCPWM (RTL8712_SDIO_LOCAL_BASE + 0x0081)
|
||||
|
||||
void r8712_set_rpwm(struct _adapter *padapter, u8 val8)
|
||||
{
|
||||
u8 rpwm;
|
||||
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
||||
|
||||
if (pwrpriv->rpwm == val8) {
|
||||
if (pwrpriv->rpwm_retry == 0)
|
||||
return;
|
||||
}
|
||||
if ((padapter->bDriverStopped == true) ||
|
||||
(padapter->bSurpriseRemoved == true))
|
||||
return;
|
||||
rpwm = val8 | pwrpriv->tog;
|
||||
switch (val8) {
|
||||
case PS_STATE_S1:
|
||||
pwrpriv->cpwm = val8;
|
||||
break;
|
||||
case PS_STATE_S2:/* only for USB normal powersave mode use,
|
||||
* temp mark some code. */
|
||||
case PS_STATE_S3:
|
||||
case PS_STATE_S4:
|
||||
pwrpriv->cpwm = val8;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
pwrpriv->rpwm_retry = 0;
|
||||
pwrpriv->rpwm = val8;
|
||||
r8712_write8(padapter, 0x1025FE58, rpwm);
|
||||
pwrpriv->tog += 0x80;
|
||||
}
|
||||
|
||||
void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode, uint smart_ps)
|
||||
{
|
||||
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
||||
|
||||
if (ps_mode > PM_Card_Disable)
|
||||
return;
|
||||
/* if driver is in active state, we dont need set smart_ps.*/
|
||||
if (ps_mode == PS_MODE_ACTIVE)
|
||||
smart_ps = 0;
|
||||
if ((pwrpriv->pwr_mode != ps_mode) || (pwrpriv->smart_ps != smart_ps)) {
|
||||
if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
|
||||
pwrpriv->bSleep = true;
|
||||
else
|
||||
pwrpriv->bSleep = false;
|
||||
pwrpriv->pwr_mode = ps_mode;
|
||||
pwrpriv->smart_ps = smart_ps;
|
||||
_set_workitem(&(pwrpriv->SetPSModeWorkItem));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Caller:ISR handler...
|
||||
*
|
||||
* This will be called when CPWM interrupt is up.
|
||||
*
|
||||
* using to update cpwn of drv; and drv willl make a decision to up or
|
||||
* down pwr level
|
||||
*/
|
||||
void r8712_cpwm_int_hdl(struct _adapter *padapter,
|
||||
struct reportpwrstate_parm *preportpwrstate)
|
||||
{
|
||||
struct pwrctrl_priv *pwrpriv = &(padapter->pwrctrlpriv);
|
||||
struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
|
||||
struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
|
||||
|
||||
if (pwrpriv->cpwm_tog == ((preportpwrstate->state) & 0x80))
|
||||
return;
|
||||
_cancel_timer_ex(&padapter->pwrctrlpriv. rpwm_check_timer);
|
||||
_enter_pwrlock(&pwrpriv->lock);
|
||||
pwrpriv->cpwm = (preportpwrstate->state) & 0xf;
|
||||
if (pwrpriv->cpwm >= PS_STATE_S2) {
|
||||
if (pwrpriv->alives & CMD_ALIVE)
|
||||
up(&(pcmdpriv->cmd_queue_sema));
|
||||
if (pwrpriv->alives & XMIT_ALIVE)
|
||||
up(&(pxmitpriv->xmit_sema));
|
||||
}
|
||||
pwrpriv->cpwm_tog = (preportpwrstate->state) & 0x80;
|
||||
up(&pwrpriv->lock);
|
||||
}
|
||||
|
||||
static inline void register_task_alive(struct pwrctrl_priv *pwrctrl, uint tag)
|
||||
{
|
||||
pwrctrl->alives |= tag;
|
||||
}
|
||||
|
||||
static inline void unregister_task_alive(struct pwrctrl_priv *pwrctrl, uint tag)
|
||||
{
|
||||
if (pwrctrl->alives & tag)
|
||||
pwrctrl->alives ^= tag;
|
||||
}
|
||||
|
||||
static void _rpwm_check_handler (struct _adapter *padapter)
|
||||
{
|
||||
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
||||
|
||||
if (padapter->bDriverStopped == true ||
|
||||
padapter->bSurpriseRemoved == true)
|
||||
return;
|
||||
if (pwrpriv->cpwm != pwrpriv->rpwm)
|
||||
_set_workitem(&(pwrpriv->rpwm_workitem));
|
||||
}
|
||||
|
||||
static void SetPSModeWorkItemCallback(struct work_struct *work)
|
||||
{
|
||||
struct pwrctrl_priv *pwrpriv = container_of(work,
|
||||
struct pwrctrl_priv, SetPSModeWorkItem);
|
||||
struct _adapter *padapter = container_of(pwrpriv,
|
||||
struct _adapter, pwrctrlpriv);
|
||||
_enter_pwrlock(&pwrpriv->lock);
|
||||
if (!pwrpriv->bSleep) {
|
||||
if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
|
||||
r8712_set_rpwm(padapter, PS_STATE_S4);
|
||||
}
|
||||
up(&pwrpriv->lock);
|
||||
}
|
||||
|
||||
static void rpwm_workitem_callback(struct work_struct *work)
|
||||
{
|
||||
struct pwrctrl_priv *pwrpriv = container_of(work,
|
||||
struct pwrctrl_priv, rpwm_workitem);
|
||||
struct _adapter *padapter = container_of(pwrpriv,
|
||||
struct _adapter, pwrctrlpriv);
|
||||
u8 cpwm = pwrpriv->cpwm;
|
||||
_enter_pwrlock(&pwrpriv->lock);
|
||||
if (pwrpriv->cpwm != pwrpriv->rpwm) {
|
||||
cpwm = r8712_read8(padapter, SDIO_HCPWM);
|
||||
pwrpriv->rpwm_retry = 1;
|
||||
r8712_set_rpwm(padapter, pwrpriv->rpwm);
|
||||
}
|
||||
up(&pwrpriv->lock);
|
||||
}
|
||||
|
||||
static void rpwm_check_handler (void *FunctionContext)
|
||||
{
|
||||
struct _adapter *adapter = (struct _adapter *)FunctionContext;
|
||||
_rpwm_check_handler(adapter);
|
||||
}
|
||||
|
||||
void r8712_init_pwrctrl_priv(struct _adapter *padapter)
|
||||
{
|
||||
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
|
||||
|
||||
memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct pwrctrl_priv));
|
||||
sema_init(&pwrctrlpriv->lock, 1);
|
||||
pwrctrlpriv->cpwm = PS_STATE_S4;
|
||||
pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE;
|
||||
pwrctrlpriv->smart_ps = 0;
|
||||
pwrctrlpriv->tog = 0x80;
|
||||
/* clear RPWM to ensure driver and fw back to initial state. */
|
||||
r8712_write8(padapter, 0x1025FE58, 0);
|
||||
_init_workitem(&(pwrctrlpriv->SetPSModeWorkItem),
|
||||
SetPSModeWorkItemCallback, padapter);
|
||||
_init_workitem(&(pwrctrlpriv->rpwm_workitem),
|
||||
rpwm_workitem_callback, padapter);
|
||||
_init_timer(&(pwrctrlpriv->rpwm_check_timer),
|
||||
padapter->pnetdev, rpwm_check_handler, (u8 *)padapter);
|
||||
}
|
||||
|
||||
/*
|
||||
Caller: r8712_cmd_thread
|
||||
|
||||
Check if the fw_pwrstate is okay for issuing cmd.
|
||||
If not (cpwm should be is less than P2 state), then the sub-routine
|
||||
will raise the cpwm to be greater than or equal to P2.
|
||||
|
||||
Calling Context: Passive
|
||||
|
||||
Return Value:
|
||||
|
||||
_SUCCESS: r8712_cmd_thread can issue cmds to firmware afterwards.
|
||||
_FAIL: r8712_cmd_thread can not do anything.
|
||||
*/
|
||||
sint r8712_register_cmd_alive(struct _adapter *padapter)
|
||||
{
|
||||
uint res = _SUCCESS;
|
||||
struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv;
|
||||
|
||||
_enter_pwrlock(&pwrctrl->lock);
|
||||
register_task_alive(pwrctrl, CMD_ALIVE);
|
||||
if (pwrctrl->cpwm < PS_STATE_S2) {
|
||||
r8712_set_rpwm(padapter, PS_STATE_S3);
|
||||
res = _FAIL;
|
||||
}
|
||||
up(&pwrctrl->lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
Caller: ISR
|
||||
|
||||
If ISR's txdone,
|
||||
No more pkts for TX,
|
||||
Then driver shall call this fun. to power down firmware again.
|
||||
*/
|
||||
|
||||
void r8712_unregister_cmd_alive(struct _adapter *padapter)
|
||||
{
|
||||
struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv;
|
||||
|
||||
_enter_pwrlock(&pwrctrl->lock);
|
||||
unregister_task_alive(pwrctrl, CMD_ALIVE);
|
||||
if ((pwrctrl->cpwm > PS_STATE_S2) &&
|
||||
(pwrctrl->pwr_mode > PS_MODE_ACTIVE)) {
|
||||
if ((pwrctrl->alives == 0) &&
|
||||
(check_fwstate(&padapter->mlmepriv,
|
||||
_FW_UNDER_LINKING) != true)) {
|
||||
r8712_set_rpwm(padapter, PS_STATE_S0);
|
||||
}
|
||||
}
|
||||
up(&pwrctrl->lock);
|
||||
}
|
127
drivers/staging/rtl8712/rtl871x_pwrctrl.h
Normal file
127
drivers/staging/rtl8712/rtl871x_pwrctrl.h
Normal file
@ -0,0 +1,127 @@
|
||||
#ifndef __RTL871X_PWRCTRL_H_
|
||||
#define __RTL871X_PWRCTRL_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
|
||||
|
||||
#define FW_PWR0 0
|
||||
#define FW_PWR1 1
|
||||
#define FW_PWR2 2
|
||||
#define FW_PWR3 3
|
||||
|
||||
|
||||
#define HW_PWR0 7
|
||||
#define HW_PWR1 6
|
||||
#define HW_PWR2 2
|
||||
#define HW_PWR3 0
|
||||
#define HW_PWR4 8
|
||||
|
||||
#define FW_PWRMSK 0x7
|
||||
|
||||
|
||||
#define XMIT_ALIVE BIT(0)
|
||||
#define RECV_ALIVE BIT(1)
|
||||
#define CMD_ALIVE BIT(2)
|
||||
#define EVT_ALIVE BIT(3)
|
||||
|
||||
|
||||
enum Power_Mgnt {
|
||||
PS_MODE_ACTIVE = 0 ,
|
||||
PS_MODE_MIN ,
|
||||
PS_MODE_MAX ,
|
||||
PS_MODE_DTIM ,
|
||||
PS_MODE_VOIP ,
|
||||
PS_MODE_UAPSD_WMM ,
|
||||
PS_MODE_UAPSD ,
|
||||
PS_MODE_IBSS ,
|
||||
PS_MODE_WWLAN ,
|
||||
PM_Radio_Off ,
|
||||
PM_Card_Disable ,
|
||||
PS_MODE_NUM
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
BIT[2:0] = HW state
|
||||
BIT[3] = Protocol PS state, 0: register active state,
|
||||
1: register sleep state
|
||||
BIT[4] = sub-state
|
||||
*/
|
||||
|
||||
#define PS_DPS BIT(0)
|
||||
#define PS_LCLK (PS_DPS)
|
||||
#define PS_RF_OFF BIT(1)
|
||||
#define PS_ALL_ON BIT(2)
|
||||
#define PS_ST_ACTIVE BIT(3)
|
||||
#define PS_LP BIT(4) /* low performance */
|
||||
|
||||
#define PS_STATE_MASK (0x0F)
|
||||
#define PS_STATE_HW_MASK (0x07)
|
||||
#define PS_SEQ_MASK (0xc0)
|
||||
|
||||
#define PS_STATE(x) (PS_STATE_MASK & (x))
|
||||
#define PS_STATE_HW(x) (PS_STATE_HW_MASK & (x))
|
||||
#define PS_SEQ(x) (PS_SEQ_MASK & (x))
|
||||
|
||||
#define PS_STATE_S0 (PS_DPS)
|
||||
#define PS_STATE_S1 (PS_LCLK)
|
||||
#define PS_STATE_S2 (PS_RF_OFF)
|
||||
#define PS_STATE_S3 (PS_ALL_ON)
|
||||
#define PS_STATE_S4 ((PS_ST_ACTIVE) | (PS_ALL_ON))
|
||||
|
||||
|
||||
#define PS_IS_RF_ON(x) ((x) & (PS_ALL_ON))
|
||||
#define PS_IS_ACTIVE(x) ((x) & (PS_ST_ACTIVE))
|
||||
#define CLR_PS_STATE(x) ((x) = ((x) & (0xF0)))
|
||||
|
||||
|
||||
struct reportpwrstate_parm {
|
||||
unsigned char mode;
|
||||
unsigned char state; /* the CPWM value */
|
||||
unsigned short rsvd;
|
||||
};
|
||||
|
||||
static inline void _enter_pwrlock(struct semaphore *plock)
|
||||
{
|
||||
_down_sema(plock);
|
||||
}
|
||||
|
||||
struct pwrctrl_priv {
|
||||
struct semaphore lock;
|
||||
/*volatile*/ u8 rpwm; /* requested power state for fw */
|
||||
/* fw current power state. updated when 1. read from HCPWM or
|
||||
* 2. driver lowers power level */
|
||||
/*volatile*/ u8 cpwm;
|
||||
/*volatile*/ u8 tog; /* toggling */
|
||||
/*volatile*/ u8 cpwm_tog; /* toggling */
|
||||
/*volatile*/ u8 tgt_rpwm; /* wanted power state */
|
||||
uint pwr_mode;
|
||||
uint smart_ps;
|
||||
uint alives;
|
||||
uint ImrContent; /* used to store original imr. */
|
||||
uint bSleep; /* sleep -> active is different from active -> sleep. */
|
||||
|
||||
_workitem SetPSModeWorkItem;
|
||||
_workitem rpwm_workitem;
|
||||
struct timer_list rpwm_check_timer;
|
||||
u8 rpwm_retry;
|
||||
uint bSetPSModeWorkItemInProgress;
|
||||
|
||||
struct semaphore pnp_pwr_mgnt_sema;
|
||||
spinlock_t pnp_pwr_mgnt_lock;
|
||||
s32 pnp_current_pwr_state;
|
||||
u8 pnp_bstop_trx;
|
||||
u8 pnp_wwirp_pending;
|
||||
};
|
||||
|
||||
void r8712_init_pwrctrl_priv(struct _adapter *adapter);
|
||||
sint r8712_register_cmd_alive(struct _adapter *padapter);
|
||||
void r8712_unregister_cmd_alive(struct _adapter *padapter);
|
||||
void r8712_cpwm_int_hdl(struct _adapter *padapter,
|
||||
struct reportpwrstate_parm *preportpwrstate);
|
||||
void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode,
|
||||
uint smart_ps);
|
||||
void r8712_set_rpwm(struct _adapter *padapter, u8 val8);
|
||||
|
||||
#endif /* __RTL871X_PWRCTRL_H_ */
|
715
drivers/staging/rtl8712/rtl871x_recv.c
Normal file
715
drivers/staging/rtl8712/rtl871x_recv.c
Normal file
@ -0,0 +1,715 @@
|
||||
/******************************************************************************
|
||||
* rtl871x_recv.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 _RTL871X_RECV_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "recv_osdep.h"
|
||||
#include "mlme_osdep.h"
|
||||
#include "ip.h"
|
||||
#include "if_ether.h"
|
||||
#include "ethernet.h"
|
||||
#include "usb_ops.h"
|
||||
#include "wifi.h"
|
||||
|
||||
static const u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37};
|
||||
|
||||
/* Datagram Delivery Protocol */
|
||||
static const u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3};
|
||||
|
||||
/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
|
||||
static const u8 bridge_tunnel_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8};
|
||||
|
||||
/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
|
||||
static const u8 rfc1042_header[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
|
||||
|
||||
void _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv)
|
||||
{
|
||||
memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv));
|
||||
spin_lock_init(&psta_recvpriv->lock);
|
||||
_init_queue(&psta_recvpriv->defrag_q);
|
||||
}
|
||||
|
||||
sint _r8712_init_recv_priv(struct recv_priv *precvpriv,
|
||||
struct _adapter *padapter)
|
||||
{
|
||||
sint i;
|
||||
union recv_frame *precvframe;
|
||||
|
||||
memset((unsigned char *)precvpriv, 0, sizeof(struct recv_priv));
|
||||
spin_lock_init(&precvpriv->lock);
|
||||
_init_queue(&precvpriv->free_recv_queue);
|
||||
_init_queue(&precvpriv->recv_pending_queue);
|
||||
precvpriv->adapter = padapter;
|
||||
precvpriv->free_recvframe_cnt = NR_RECVFRAME;
|
||||
precvpriv->pallocated_frame_buf = _malloc(NR_RECVFRAME *
|
||||
sizeof(union recv_frame) +
|
||||
RXFRAME_ALIGN_SZ);
|
||||
if (precvpriv->pallocated_frame_buf == NULL)
|
||||
return _FAIL;
|
||||
memset(precvpriv->pallocated_frame_buf, 0, NR_RECVFRAME *
|
||||
sizeof(union recv_frame) + RXFRAME_ALIGN_SZ);
|
||||
precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf +
|
||||
RXFRAME_ALIGN_SZ -
|
||||
((addr_t)(precvpriv->pallocated_frame_buf) &
|
||||
(RXFRAME_ALIGN_SZ-1));
|
||||
precvframe = (union recv_frame *)precvpriv->precv_frame_buf;
|
||||
for (i = 0; i < NR_RECVFRAME; i++) {
|
||||
_init_listhead(&(precvframe->u.list));
|
||||
list_insert_tail(&(precvframe->u.list),
|
||||
&(precvpriv->free_recv_queue.queue));
|
||||
r8712_os_recv_resource_alloc(padapter, precvframe);
|
||||
precvframe->u.hdr.adapter = padapter;
|
||||
precvframe++;
|
||||
}
|
||||
precvpriv->rx_pending_cnt = 1;
|
||||
sema_init(&precvpriv->allrxreturnevt, 0);
|
||||
return r8712_init_recv_priv(precvpriv, padapter);
|
||||
}
|
||||
|
||||
void _r8712_free_recv_priv(struct recv_priv *precvpriv)
|
||||
{
|
||||
kfree(precvpriv->pallocated_frame_buf);
|
||||
r8712_free_recv_priv(precvpriv);
|
||||
}
|
||||
|
||||
union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue)
|
||||
{
|
||||
unsigned long irqL;
|
||||
union recv_frame *precvframe;
|
||||
struct list_head *plist, *phead;
|
||||
struct _adapter *padapter;
|
||||
struct recv_priv *precvpriv;
|
||||
|
||||
spin_lock_irqsave(&pfree_recv_queue->lock, irqL);
|
||||
if (_queue_empty(pfree_recv_queue) == true)
|
||||
precvframe = NULL;
|
||||
else {
|
||||
phead = get_list_head(pfree_recv_queue);
|
||||
plist = get_next(phead);
|
||||
precvframe = LIST_CONTAINOR(plist, union recv_frame, u);
|
||||
list_delete(&precvframe->u.hdr.list);
|
||||
padapter = precvframe->u.hdr.adapter;
|
||||
if (padapter != NULL) {
|
||||
precvpriv = &padapter->recvpriv;
|
||||
if (pfree_recv_queue == &precvpriv->free_recv_queue)
|
||||
precvpriv->free_recvframe_cnt--;
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&pfree_recv_queue->lock, irqL);
|
||||
return precvframe;
|
||||
}
|
||||
|
||||
union recv_frame *dequeue_recvframe(struct __queue *queue)
|
||||
{
|
||||
return r8712_alloc_recvframe(queue);
|
||||
}
|
||||
|
||||
sint enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct _adapter *padapter = precvframe->u.hdr.adapter;
|
||||
struct recv_priv *precvpriv = &padapter->recvpriv;
|
||||
|
||||
spin_lock_irqsave(&queue->lock, irqL);
|
||||
list_delete(&(precvframe->u.hdr.list));
|
||||
list_insert_tail(&(precvframe->u.hdr.list), get_list_head(queue));
|
||||
if (padapter != NULL) {
|
||||
if (queue == &precvpriv->free_recv_queue)
|
||||
precvpriv->free_recvframe_cnt++;
|
||||
}
|
||||
spin_unlock_irqrestore(&queue->lock, irqL);
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
caller : defrag; recvframe_chk_defrag in recv_thread (passive)
|
||||
pframequeue: defrag_queue : will be accessed in recv_thread (passive)
|
||||
|
||||
using spin_lock to protect
|
||||
|
||||
*/
|
||||
|
||||
void r8712_free_recvframe_queue(struct __queue *pframequeue,
|
||||
struct __queue *pfree_recv_queue)
|
||||
{
|
||||
union recv_frame *precvframe;
|
||||
struct list_head *plist, *phead;
|
||||
|
||||
spin_lock(&pframequeue->lock);
|
||||
phead = get_list_head(pframequeue);
|
||||
plist = get_next(phead);
|
||||
while (end_of_queue_search(phead, plist) == false) {
|
||||
precvframe = LIST_CONTAINOR(plist, union recv_frame, u);
|
||||
plist = get_next(plist);
|
||||
r8712_free_recvframe(precvframe, pfree_recv_queue);
|
||||
}
|
||||
spin_unlock(&pframequeue->lock);
|
||||
}
|
||||
|
||||
sint r8712_recvframe_chkmic(struct _adapter *adapter,
|
||||
union recv_frame *precvframe)
|
||||
{
|
||||
sint i, res = _SUCCESS;
|
||||
u32 datalen;
|
||||
u8 miccode[8];
|
||||
u8 bmic_err = false;
|
||||
u8 *pframe, *payload, *pframemic;
|
||||
u8 *mickey, idx, *iv;
|
||||
struct sta_info *stainfo;
|
||||
struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib;
|
||||
struct security_priv *psecuritypriv = &adapter->securitypriv;
|
||||
|
||||
stainfo = r8712_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]);
|
||||
if (prxattrib->encrypt == _TKIP_) {
|
||||
/* calculate mic code */
|
||||
if (stainfo != NULL) {
|
||||
if (IS_MCAST(prxattrib->ra)) {
|
||||
iv = precvframe->u.hdr.rx_data +
|
||||
prxattrib->hdrlen;
|
||||
idx = iv[3];
|
||||
mickey = &psecuritypriv->XGrprxmickey[(((idx >>
|
||||
6) & 0x3)) - 1].skey[0];
|
||||
if (psecuritypriv->binstallGrpkey == false)
|
||||
return _FAIL;
|
||||
} else
|
||||
mickey = &stainfo->tkiprxmickey.skey[0];
|
||||
/*icv_len included the mic code*/
|
||||
datalen = precvframe->u.hdr.len - prxattrib->hdrlen -
|
||||
prxattrib->iv_len - prxattrib->icv_len - 8;
|
||||
pframe = precvframe->u.hdr.rx_data;
|
||||
payload = pframe + prxattrib->hdrlen +
|
||||
prxattrib->iv_len;
|
||||
seccalctkipmic(mickey, pframe, payload, datalen,
|
||||
&miccode[0],
|
||||
(unsigned char)prxattrib->priority);
|
||||
pframemic = payload + datalen;
|
||||
bmic_err = false;
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (miccode[i] != *(pframemic + i))
|
||||
bmic_err = true;
|
||||
}
|
||||
if (bmic_err == true) {
|
||||
if (prxattrib->bdecrypted == true)
|
||||
r8712_handle_tkip_mic_err(adapter,
|
||||
(u8)IS_MCAST(prxattrib->ra));
|
||||
res = _FAIL;
|
||||
} else {
|
||||
/* mic checked ok */
|
||||
if ((psecuritypriv->bcheck_grpkey ==
|
||||
false) && (IS_MCAST(prxattrib->ra) ==
|
||||
true))
|
||||
psecuritypriv->bcheck_grpkey = true;
|
||||
}
|
||||
recvframe_pull_tail(precvframe, 8);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* decrypt and set the ivlen,icvlen of the recv_frame */
|
||||
union recv_frame *r8712_decryptor(struct _adapter *padapter,
|
||||
union recv_frame *precv_frame)
|
||||
{
|
||||
struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib;
|
||||
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
||||
union recv_frame *return_packet = precv_frame;
|
||||
|
||||
if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) ||
|
||||
(psecuritypriv->sw_decrypt == true))) {
|
||||
psecuritypriv->hw_decrypted = false;
|
||||
switch (prxattrib->encrypt) {
|
||||
case _WEP40_:
|
||||
case _WEP104_:
|
||||
r8712_wep_decrypt(padapter, (u8 *)precv_frame);
|
||||
break;
|
||||
case _TKIP_:
|
||||
r8712_tkip_decrypt(padapter, (u8 *)precv_frame);
|
||||
break;
|
||||
case _AES_:
|
||||
r8712_aes_decrypt(padapter, (u8 *)precv_frame);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (prxattrib->bdecrypted == 1)
|
||||
psecuritypriv->hw_decrypted = true;
|
||||
return return_packet;
|
||||
}
|
||||
/*###set the security information in the recv_frame */
|
||||
union recv_frame *r8712_portctrl(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame)
|
||||
{
|
||||
u8 *psta_addr, *ptr;
|
||||
uint auth_alg;
|
||||
struct recv_frame_hdr *pfhdr;
|
||||
struct sta_info *psta;
|
||||
struct sta_priv *pstapriv;
|
||||
union recv_frame *prtnframe;
|
||||
u16 ether_type = 0;
|
||||
|
||||
pstapriv = &adapter->stapriv;
|
||||
ptr = get_recvframe_data(precv_frame);
|
||||
pfhdr = &precv_frame->u.hdr;
|
||||
psta_addr = pfhdr->attrib.ta;
|
||||
psta = r8712_get_stainfo(pstapriv, psta_addr);
|
||||
auth_alg = adapter->securitypriv.AuthAlgrthm;
|
||||
if (auth_alg == 2) {
|
||||
if ((psta != NULL) && (psta->ieee8021x_blocked)) {
|
||||
/* blocked
|
||||
* only accept EAPOL frame */
|
||||
prtnframe = precv_frame;
|
||||
/*get ether_type */
|
||||
ptr = ptr + pfhdr->attrib.hdrlen +
|
||||
pfhdr->attrib.iv_len + LLC_HEADER_SIZE;
|
||||
memcpy(ðer_type, ptr, 2);
|
||||
ether_type = ntohs((unsigned short)ether_type);
|
||||
if (ether_type == 0x888e)
|
||||
prtnframe = precv_frame;
|
||||
else {
|
||||
/*free this frame*/
|
||||
r8712_free_recvframe(precv_frame,
|
||||
&adapter->recvpriv.free_recv_queue);
|
||||
prtnframe = NULL;
|
||||
}
|
||||
} else {
|
||||
/* allowed
|
||||
* check decryption status, and decrypt the
|
||||
* frame if needed */
|
||||
prtnframe = precv_frame;
|
||||
/* check is the EAPOL frame or not (Rekey) */
|
||||
if (ether_type == 0x888e) {
|
||||
/* check Rekey */
|
||||
prtnframe = precv_frame;
|
||||
}
|
||||
}
|
||||
} else
|
||||
prtnframe = precv_frame;
|
||||
return prtnframe;
|
||||
}
|
||||
|
||||
sint recv_decache(union recv_frame *precv_frame, u8 bretry,
|
||||
struct stainfo_rxcache *prxcache)
|
||||
{
|
||||
sint tid = precv_frame->u.hdr.attrib.priority;
|
||||
u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) |
|
||||
(precv_frame->u.hdr.attrib.frag_num & 0xf);
|
||||
|
||||
if (tid > 15)
|
||||
return _FAIL;
|
||||
if (seq_ctrl == prxcache->tid_rxseq[tid])
|
||||
return _FAIL;
|
||||
prxcache->tid_rxseq[tid] = seq_ctrl;
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
sint sta2sta_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
|
||||
struct sta_info **psta
|
||||
)
|
||||
{
|
||||
u8 *ptr = precv_frame->u.hdr.rx_data;
|
||||
sint ret = _SUCCESS;
|
||||
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
|
||||
struct sta_priv *pstapriv = &adapter->stapriv;
|
||||
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
||||
u8 *mybssid = get_bssid(pmlmepriv);
|
||||
u8 *myhwaddr = myid(&adapter->eeprompriv);
|
||||
u8 *sta_addr = NULL;
|
||||
sint bmcast = IS_MCAST(pattrib->dst);
|
||||
|
||||
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) ||
|
||||
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
|
||||
/* filter packets that SA is myself or multicast or broadcast */
|
||||
if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN))
|
||||
return _FAIL;
|
||||
if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast))
|
||||
return _FAIL;
|
||||
if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
|
||||
!memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
|
||||
(memcmp(pattrib->bssid, mybssid, ETH_ALEN)))
|
||||
return _FAIL;
|
||||
sta_addr = pattrib->src;
|
||||
} else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) {
|
||||
/* For Station mode, sa and bssid should always be BSSID,
|
||||
* and DA is my mac-address */
|
||||
if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN))
|
||||
return _FAIL;
|
||||
sta_addr = pattrib->bssid;
|
||||
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
|
||||
if (bmcast) {
|
||||
/* For AP mode, if DA == MCAST, then BSSID should
|
||||
* be also MCAST */
|
||||
if (!IS_MCAST(pattrib->bssid))
|
||||
return _FAIL;
|
||||
} else { /* not mc-frame */
|
||||
/* For AP mode, if DA is non-MCAST, then it must be
|
||||
* BSSID, and bssid == BSSID */
|
||||
if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN))
|
||||
return _FAIL;
|
||||
sta_addr = pattrib->src;
|
||||
}
|
||||
} else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) {
|
||||
memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN);
|
||||
memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
|
||||
memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN);
|
||||
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
|
||||
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
|
||||
sta_addr = mybssid;
|
||||
} else
|
||||
ret = _FAIL;
|
||||
if (bmcast)
|
||||
*psta = r8712_get_bcmc_stainfo(adapter);
|
||||
else
|
||||
*psta = r8712_get_stainfo(pstapriv, sta_addr); /* get ap_info */
|
||||
if (*psta == NULL) {
|
||||
if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)
|
||||
adapter->mppriv.rx_pktloss++;
|
||||
return _FAIL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
sint ap2sta_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
|
||||
struct sta_info **psta)
|
||||
{
|
||||
u8 *ptr = precv_frame->u.hdr.rx_data;
|
||||
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
|
||||
struct sta_priv *pstapriv = &adapter->stapriv;
|
||||
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
||||
u8 *mybssid = get_bssid(pmlmepriv);
|
||||
u8 *myhwaddr = myid(&adapter->eeprompriv);
|
||||
sint bmcast = IS_MCAST(pattrib->dst);
|
||||
|
||||
if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
|
||||
&& (check_fwstate(pmlmepriv, _FW_LINKED) == true)) {
|
||||
/* if NULL-frame, drop packet */
|
||||
if ((GetFrameSubType(ptr)) == WIFI_DATA_NULL)
|
||||
return _FAIL;
|
||||
/* drop QoS-SubType Data, including QoS NULL,
|
||||
* excluding QoS-Data */
|
||||
if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) ==
|
||||
WIFI_QOS_DATA_TYPE) {
|
||||
if (GetFrameSubType(ptr) & (BIT(4) | BIT(5) | BIT(6)))
|
||||
return _FAIL;
|
||||
}
|
||||
|
||||
/* filter packets that SA is myself or multicast or broadcast */
|
||||
if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN))
|
||||
return _FAIL;
|
||||
|
||||
/* da should be for me */
|
||||
if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast))
|
||||
return _FAIL;
|
||||
/* check BSSID */
|
||||
if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
|
||||
!memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) ||
|
||||
(memcmp(pattrib->bssid, mybssid, ETH_ALEN)))
|
||||
return _FAIL;
|
||||
if (bmcast)
|
||||
*psta = r8712_get_bcmc_stainfo(adapter);
|
||||
else
|
||||
*psta = r8712_get_stainfo(pstapriv, pattrib->bssid);
|
||||
if (*psta == NULL)
|
||||
return _FAIL;
|
||||
} else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) &&
|
||||
(check_fwstate(pmlmepriv, _FW_LINKED) == true)) {
|
||||
memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN);
|
||||
memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
|
||||
memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN);
|
||||
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
|
||||
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
|
||||
memcpy(pattrib->bssid, mybssid, ETH_ALEN);
|
||||
*psta = r8712_get_stainfo(pstapriv, pattrib->bssid);
|
||||
if (*psta == NULL)
|
||||
return _FAIL;
|
||||
} else
|
||||
return _FAIL;
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
sint sta2ap_data_frame(struct _adapter *adapter, union recv_frame *precv_frame,
|
||||
struct sta_info **psta)
|
||||
{
|
||||
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
|
||||
struct sta_priv *pstapriv = &adapter->stapriv;
|
||||
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
||||
unsigned char *mybssid = get_bssid(pmlmepriv);
|
||||
|
||||
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
|
||||
/* For AP mode, if DA is non-MCAST, then it must be BSSID,
|
||||
* and bssid == BSSID
|
||||
* For AP mode, RA=BSSID, TX=STA(SRC_ADDR), A3=DST_ADDR */
|
||||
if (memcmp(pattrib->bssid, mybssid, ETH_ALEN))
|
||||
return _FAIL;
|
||||
*psta = r8712_get_stainfo(pstapriv, pattrib->src);
|
||||
if (*psta == NULL)
|
||||
return _FAIL;
|
||||
}
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
sint validate_recv_ctrl_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame)
|
||||
{
|
||||
return _FAIL;
|
||||
}
|
||||
|
||||
sint validate_recv_mgnt_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame)
|
||||
{
|
||||
return _FAIL;
|
||||
}
|
||||
|
||||
|
||||
sint validate_recv_data_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame)
|
||||
{
|
||||
int res;
|
||||
u8 bretry;
|
||||
u8 *psa, *pda, *pbssid;
|
||||
struct sta_info *psta = NULL;
|
||||
u8 *ptr = precv_frame->u.hdr.rx_data;
|
||||
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
|
||||
struct security_priv *psecuritypriv = &adapter->securitypriv;
|
||||
|
||||
bretry = GetRetry(ptr);
|
||||
pda = get_da(ptr);
|
||||
psa = get_sa(ptr);
|
||||
pbssid = get_hdr_bssid(ptr);
|
||||
if (pbssid == NULL)
|
||||
return _FAIL;
|
||||
memcpy(pattrib->dst, pda, ETH_ALEN);
|
||||
memcpy(pattrib->src, psa, ETH_ALEN);
|
||||
memcpy(pattrib->bssid, pbssid, ETH_ALEN);
|
||||
switch (pattrib->to_fr_ds) {
|
||||
case 0:
|
||||
memcpy(pattrib->ra, pda, ETH_ALEN);
|
||||
memcpy(pattrib->ta, psa, ETH_ALEN);
|
||||
res = sta2sta_data_frame(adapter, precv_frame, &psta);
|
||||
break;
|
||||
case 1:
|
||||
memcpy(pattrib->ra, pda, ETH_ALEN);
|
||||
memcpy(pattrib->ta, pbssid, ETH_ALEN);
|
||||
res = ap2sta_data_frame(adapter, precv_frame, &psta);
|
||||
break;
|
||||
case 2:
|
||||
memcpy(pattrib->ra, pbssid, ETH_ALEN);
|
||||
memcpy(pattrib->ta, psa, ETH_ALEN);
|
||||
res = sta2ap_data_frame(adapter, precv_frame, &psta);
|
||||
break;
|
||||
case 3:
|
||||
memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN);
|
||||
memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN);
|
||||
return _FAIL;
|
||||
default:
|
||||
return _FAIL;
|
||||
}
|
||||
if (res == _FAIL)
|
||||
return _FAIL;
|
||||
if (psta == NULL)
|
||||
return _FAIL;
|
||||
else
|
||||
precv_frame->u.hdr.psta = psta;
|
||||
pattrib->amsdu = 0;
|
||||
/* parsing QC field */
|
||||
if (pattrib->qos == 1) {
|
||||
pattrib->priority = GetPriority((ptr + 24));
|
||||
pattrib->ack_policy = GetAckpolicy((ptr + 24));
|
||||
pattrib->amsdu = GetAMsdu((ptr + 24));
|
||||
pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 32 : 26;
|
||||
} else {
|
||||
pattrib->priority = 0;
|
||||
pattrib->hdrlen = (pattrib->to_fr_ds == 3) ? 30 : 24;
|
||||
}
|
||||
|
||||
if (pattrib->order)/*HT-CTRL 11n*/
|
||||
pattrib->hdrlen += 4;
|
||||
precv_frame->u.hdr.preorder_ctrl =
|
||||
&psta->recvreorder_ctrl[pattrib->priority];
|
||||
|
||||
/* decache, drop duplicate recv packets */
|
||||
if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) ==
|
||||
_FAIL)
|
||||
return _FAIL;
|
||||
|
||||
if (pattrib->privacy) {
|
||||
GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt,
|
||||
IS_MCAST(pattrib->ra));
|
||||
SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len,
|
||||
pattrib->encrypt);
|
||||
} else {
|
||||
pattrib->encrypt = 0;
|
||||
pattrib->iv_len = pattrib->icv_len = 0;
|
||||
}
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
sint r8712_validate_recv_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame)
|
||||
{
|
||||
/*shall check frame subtype, to / from ds, da, bssid */
|
||||
/*then call check if rx seq/frag. duplicated.*/
|
||||
|
||||
u8 type;
|
||||
u8 subtype;
|
||||
sint retval = _SUCCESS;
|
||||
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
|
||||
|
||||
u8 *ptr = precv_frame->u.hdr.rx_data;
|
||||
u8 ver = (unsigned char)(*ptr) & 0x3;
|
||||
|
||||
/*add version chk*/
|
||||
if (ver != 0)
|
||||
return _FAIL;
|
||||
type = GetFrameType(ptr);
|
||||
subtype = GetFrameSubType(ptr); /*bit(7)~bit(2)*/
|
||||
pattrib->to_fr_ds = get_tofr_ds(ptr);
|
||||
pattrib->frag_num = GetFragNum(ptr);
|
||||
pattrib->seq_num = GetSequence(ptr);
|
||||
pattrib->pw_save = GetPwrMgt(ptr);
|
||||
pattrib->mfrag = GetMFrag(ptr);
|
||||
pattrib->mdata = GetMData(ptr);
|
||||
pattrib->privacy = GetPrivacy(ptr);
|
||||
pattrib->order = GetOrder(ptr);
|
||||
switch (type) {
|
||||
case WIFI_MGT_TYPE: /*mgnt*/
|
||||
retval = validate_recv_mgnt_frame(adapter, precv_frame);
|
||||
break;
|
||||
case WIFI_CTRL_TYPE:/*ctrl*/
|
||||
retval = validate_recv_ctrl_frame(adapter, precv_frame);
|
||||
break;
|
||||
case WIFI_DATA_TYPE: /*data*/
|
||||
pattrib->qos = (subtype & BIT(7)) ? 1 : 0;
|
||||
retval = validate_recv_data_frame(adapter, precv_frame);
|
||||
break;
|
||||
default:
|
||||
return _FAIL;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
sint r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe)
|
||||
{
|
||||
/*remove the wlanhdr and add the eth_hdr*/
|
||||
sint rmv_len;
|
||||
u16 eth_type, len;
|
||||
u8 bsnaphdr;
|
||||
u8 *psnap_type;
|
||||
struct ieee80211_snap_hdr *psnap;
|
||||
|
||||
sint ret = _SUCCESS;
|
||||
struct _adapter *adapter = precvframe->u.hdr.adapter;
|
||||
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
|
||||
|
||||
u8 *ptr = get_recvframe_data(precvframe); /*point to frame_ctrl field*/
|
||||
struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib;
|
||||
|
||||
if (pattrib->encrypt)
|
||||
recvframe_pull_tail(precvframe, pattrib->icv_len);
|
||||
psnap = (struct ieee80211_snap_hdr *)(ptr + pattrib->hdrlen +
|
||||
pattrib->iv_len);
|
||||
psnap_type = ptr + pattrib->hdrlen + pattrib->iv_len + SNAP_SIZE;
|
||||
/* convert hdr + possible LLC headers into Ethernet header */
|
||||
if ((!memcmp(psnap, (void *)rfc1042_header, SNAP_SIZE) &&
|
||||
(memcmp(psnap_type, (void *)SNAP_ETH_TYPE_IPX, 2)) &&
|
||||
(memcmp(psnap_type, (void *)SNAP_ETH_TYPE_APPLETALK_AARP, 2))) ||
|
||||
!memcmp(psnap, (void *)bridge_tunnel_header, SNAP_SIZE)) {
|
||||
/* remove RFC1042 or Bridge-Tunnel encapsulation and
|
||||
* replace EtherType */
|
||||
bsnaphdr = true;
|
||||
} else {
|
||||
/* Leave Ethernet header part of hdr and full payload */
|
||||
bsnaphdr = false;
|
||||
}
|
||||
rmv_len = pattrib->hdrlen + pattrib->iv_len +
|
||||
(bsnaphdr ? SNAP_SIZE : 0);
|
||||
len = precvframe->u.hdr.len - rmv_len;
|
||||
if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) {
|
||||
ptr += rmv_len;
|
||||
*ptr = 0x87;
|
||||
*(ptr+1) = 0x12;
|
||||
eth_type = 0x8712;
|
||||
/* append rx status for mp test packets */
|
||||
ptr = recvframe_pull(precvframe, (rmv_len -
|
||||
sizeof(struct ethhdr) + 2) - 24);
|
||||
memcpy(ptr, get_rxmem(precvframe), 24);
|
||||
ptr += 24;
|
||||
} else
|
||||
ptr = recvframe_pull(precvframe, (rmv_len -
|
||||
sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0)));
|
||||
|
||||
memcpy(ptr, pattrib->dst, ETH_ALEN);
|
||||
memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN);
|
||||
if (!bsnaphdr) {
|
||||
len = htons(len);
|
||||
memcpy(ptr + 12, &len, 2);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 r8712_recv_entry(union recv_frame *precvframe)
|
||||
{
|
||||
struct _adapter *padapter;
|
||||
struct recv_priv *precvpriv;
|
||||
struct mlme_priv *pmlmepriv;
|
||||
struct recv_stat *prxstat;
|
||||
struct dvobj_priv *pdev;
|
||||
u8 *phead, *pdata, *ptail, *pend;
|
||||
|
||||
struct __queue *pfree_recv_queue, *ppending_recv_queue;
|
||||
s32 ret = _SUCCESS;
|
||||
struct intf_hdl *pintfhdl;
|
||||
|
||||
padapter = precvframe->u.hdr.adapter;
|
||||
pintfhdl = &padapter->pio_queue->intf;
|
||||
pmlmepriv = &padapter->mlmepriv;
|
||||
precvpriv = &(padapter->recvpriv);
|
||||
pdev = &padapter->dvobjpriv;
|
||||
pfree_recv_queue = &(precvpriv->free_recv_queue);
|
||||
ppending_recv_queue = &(precvpriv->recv_pending_queue);
|
||||
phead = precvframe->u.hdr.rx_head;
|
||||
pdata = precvframe->u.hdr.rx_data;
|
||||
ptail = precvframe->u.hdr.rx_tail;
|
||||
pend = precvframe->u.hdr.rx_end;
|
||||
prxstat = (struct recv_stat *)phead;
|
||||
|
||||
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_RX);
|
||||
|
||||
ret = recv_func(padapter, precvframe);
|
||||
if (ret == _FAIL)
|
||||
goto _recv_entry_drop;
|
||||
precvpriv->rx_pkts++;
|
||||
precvpriv->rx_bytes += (uint)(precvframe->u.hdr.rx_tail -
|
||||
precvframe->u.hdr.rx_data);
|
||||
return ret;
|
||||
_recv_entry_drop:
|
||||
precvpriv->rx_drop++;
|
||||
padapter->mppriv.rx_pktloss = precvpriv->rx_drop;
|
||||
return ret;
|
||||
}
|
330
drivers/staging/rtl8712/rtl871x_recv.h
Normal file
330
drivers/staging/rtl8712/rtl871x_recv.h
Normal file
@ -0,0 +1,330 @@
|
||||
#ifndef _RTL871X_RECV_H_
|
||||
#define _RTL871X_RECV_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
|
||||
#define NR_RECVFRAME 256
|
||||
|
||||
#define RXFRAME_ALIGN 8
|
||||
#define RXFRAME_ALIGN_SZ (1 << RXFRAME_ALIGN)
|
||||
|
||||
#define MAX_RXFRAME_CNT 512
|
||||
#define MAX_RX_NUMBLKS (32)
|
||||
#define RECVFRAME_HDR_ALIGN 128
|
||||
#define MAX_SUBFRAME_COUNT 64
|
||||
|
||||
#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
|
||||
|
||||
/* for Rx reordering buffer control */
|
||||
struct recv_reorder_ctrl {
|
||||
struct _adapter *padapter;
|
||||
u16 indicate_seq;/* =wstart_b, init_value=0xffff */
|
||||
u16 wend_b;
|
||||
u8 wsize_b;
|
||||
struct __queue pending_recvframe_queue;
|
||||
struct timer_list reordering_ctrl_timer;
|
||||
};
|
||||
|
||||
struct stainfo_rxcache {
|
||||
u16 tid_rxseq[16];
|
||||
};
|
||||
|
||||
#define PHY_RSSI_SLID_WIN_MAX 100
|
||||
#define PHY_LINKQUALITY_SLID_WIN_MAX 20
|
||||
|
||||
|
||||
struct smooth_rssi_data {
|
||||
u32 elements[100]; /* array to store values */
|
||||
u32 index; /* index to current array to store */
|
||||
u32 total_num; /* num of valid elements */
|
||||
u32 total_val; /* sum of valid elements */
|
||||
};
|
||||
|
||||
struct rx_pkt_attrib {
|
||||
|
||||
u8 amsdu;
|
||||
u8 order;
|
||||
u8 qos;
|
||||
u8 to_fr_ds;
|
||||
u8 frag_num;
|
||||
u16 seq_num;
|
||||
u8 pw_save;
|
||||
u8 mfrag;
|
||||
u8 mdata;
|
||||
u8 privacy; /* in frame_ctrl field */
|
||||
u8 bdecrypted;
|
||||
int hdrlen; /* the WLAN Header Len */
|
||||
int encrypt; /* 0 no encrypt. != 0 encrypt algorith */
|
||||
int iv_len;
|
||||
int icv_len;
|
||||
int priority;
|
||||
int ack_policy;
|
||||
u8 crc_err;
|
||||
u8 dst[ETH_ALEN];
|
||||
u8 src[ETH_ALEN];
|
||||
u8 ta[ETH_ALEN];
|
||||
u8 ra[ETH_ALEN];
|
||||
u8 bssid[ETH_ALEN];
|
||||
u8 tcpchk_valid; /* 0: invalid, 1: valid */
|
||||
u8 ip_chkrpt; /* 0: incorrect, 1: correct */
|
||||
u8 tcp_chkrpt; /* 0: incorrect, 1: correct */
|
||||
u8 signal_qual;
|
||||
s8 rx_mimo_signal_qual[2];
|
||||
u8 mcs_rate;
|
||||
u8 htc;
|
||||
u8 signal_strength;
|
||||
};
|
||||
|
||||
/*
|
||||
accesser of recv_priv: recv_entry(dispatch / passive level);
|
||||
recv_thread(passive) ; returnpkt(dispatch)
|
||||
; halt(passive) ;
|
||||
|
||||
using enter_critical section to protect
|
||||
*/
|
||||
struct recv_priv {
|
||||
spinlock_t lock;
|
||||
struct semaphore recv_sema;
|
||||
struct semaphore terminate_recvthread_sema;
|
||||
struct __queue free_recv_queue;
|
||||
struct __queue recv_pending_queue;
|
||||
u8 *pallocated_frame_buf;
|
||||
u8 *precv_frame_buf;
|
||||
uint free_recvframe_cnt;
|
||||
struct _adapter *adapter;
|
||||
uint rx_bytes;
|
||||
uint rx_pkts;
|
||||
uint rx_drop;
|
||||
uint rx_icv_err;
|
||||
uint rx_largepacket_crcerr;
|
||||
uint rx_smallpacket_crcerr;
|
||||
uint rx_middlepacket_crcerr;
|
||||
struct semaphore allrxreturnevt;
|
||||
u8 rx_pending_cnt;
|
||||
uint ff_hwaddr;
|
||||
struct tasklet_struct recv_tasklet;
|
||||
struct sk_buff_head free_recv_skb_queue;
|
||||
struct sk_buff_head rx_skb_queue;
|
||||
u8 *pallocated_recv_buf;
|
||||
u8 *precv_buf; /* 4 alignment */
|
||||
struct __queue free_recv_buf_queue;
|
||||
u32 free_recv_buf_queue_cnt;
|
||||
/* For the phy informatiom */
|
||||
s8 rssi;
|
||||
u8 signal;
|
||||
u8 noise;
|
||||
u8 fw_rssi;
|
||||
struct smooth_rssi_data signal_qual_data;
|
||||
struct smooth_rssi_data signal_strength_data;
|
||||
};
|
||||
|
||||
struct sta_recv_priv {
|
||||
spinlock_t lock;
|
||||
sint option;
|
||||
struct __queue defrag_q; /* keeping the fragment frame until defrag */
|
||||
struct stainfo_rxcache rxcache;
|
||||
uint sta_rx_bytes;
|
||||
uint sta_rx_pkts;
|
||||
uint sta_rx_fail;
|
||||
};
|
||||
|
||||
#include "rtl8712_recv.h"
|
||||
|
||||
/* get a free recv_frame from pfree_recv_queue */
|
||||
union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue);
|
||||
union recv_frame *r8712_dequeue_recvframe(struct __queue *queue);
|
||||
int r8712_enqueue_recvframe(union recv_frame *precvframe,
|
||||
struct __queue *queue);
|
||||
int r8712_free_recvframe(union recv_frame *precvframe,
|
||||
struct __queue *pfree_recv_queue);
|
||||
void r8712_free_recvframe_queue(struct __queue *pframequeue,
|
||||
struct __queue *pfree_recv_queue);
|
||||
void r8712_init_recvframe(union recv_frame *precvframe,
|
||||
struct recv_priv *precvpriv);
|
||||
int r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe);
|
||||
int recv_func(struct _adapter *padapter, void *pcontext);
|
||||
|
||||
static inline u8 *get_rxmem(union recv_frame *precvframe)
|
||||
{
|
||||
/* always return rx_head... */
|
||||
if (precvframe == NULL)
|
||||
return NULL;
|
||||
return precvframe->u.hdr.rx_head;
|
||||
}
|
||||
|
||||
static inline u8 *get_rx_status(union recv_frame *precvframe)
|
||||
{
|
||||
return get_rxmem(precvframe);
|
||||
}
|
||||
|
||||
static inline u8 *get_recvframe_data(union recv_frame *precvframe)
|
||||
{
|
||||
/* always return rx_data */
|
||||
if (precvframe == NULL)
|
||||
return NULL;
|
||||
return precvframe->u.hdr.rx_data;
|
||||
}
|
||||
|
||||
static inline u8 *recvframe_push(union recv_frame *precvframe, sint sz)
|
||||
{
|
||||
/* append data before rx_data */
|
||||
|
||||
/* add data to the start of recv_frame
|
||||
*
|
||||
* This function extends the used data area of the recv_frame at the
|
||||
* buffer start. rx_data must be still larger than rx_head, after
|
||||
* pushing.
|
||||
*/
|
||||
|
||||
if (precvframe == NULL)
|
||||
return NULL;
|
||||
precvframe->u.hdr.rx_data -= sz ;
|
||||
if (precvframe->u.hdr.rx_data < precvframe->u.hdr.rx_head) {
|
||||
precvframe->u.hdr.rx_data += sz ;
|
||||
return NULL;
|
||||
}
|
||||
precvframe->u.hdr.len += sz;
|
||||
return precvframe->u.hdr.rx_data;
|
||||
}
|
||||
|
||||
static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
|
||||
{
|
||||
/* used for extract sz bytes from rx_data, update rx_data and return
|
||||
* the updated rx_data to the caller */
|
||||
if (precvframe == NULL)
|
||||
return NULL;
|
||||
precvframe->u.hdr.rx_data += sz;
|
||||
if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) {
|
||||
precvframe->u.hdr.rx_data -= sz;
|
||||
return NULL;
|
||||
}
|
||||
precvframe->u.hdr.len -= sz;
|
||||
return precvframe->u.hdr.rx_data;
|
||||
}
|
||||
|
||||
static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
|
||||
{
|
||||
/* used for append sz bytes from ptr to rx_tail, update rx_tail and
|
||||
* return the updated rx_tail to the caller
|
||||
* after putting, rx_tail must be still larger than rx_end. */
|
||||
unsigned char *prev_rx_tail;
|
||||
|
||||
if (precvframe == NULL)
|
||||
return NULL;
|
||||
prev_rx_tail = precvframe->u.hdr.rx_tail;
|
||||
precvframe->u.hdr.rx_tail += sz;
|
||||
if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) {
|
||||
precvframe->u.hdr.rx_tail -= sz;
|
||||
return NULL;
|
||||
}
|
||||
precvframe->u.hdr.len += sz;
|
||||
return precvframe->u.hdr.rx_tail;
|
||||
}
|
||||
|
||||
static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
|
||||
{
|
||||
/* rmv data from rx_tail (by yitsen)
|
||||
* used for extract sz bytes from rx_end, update rx_end and return the
|
||||
* updated rx_end to the caller
|
||||
* after pulling, rx_end must be still larger than rx_data. */
|
||||
if (precvframe == NULL)
|
||||
return NULL;
|
||||
precvframe->u.hdr.rx_tail -= sz;
|
||||
if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) {
|
||||
precvframe->u.hdr.rx_tail += sz;
|
||||
return NULL;
|
||||
}
|
||||
precvframe->u.hdr.len -= sz;
|
||||
return precvframe->u.hdr.rx_tail;
|
||||
}
|
||||
|
||||
static inline _buffer *get_rxbuf_desc(union recv_frame *precvframe)
|
||||
{
|
||||
_buffer *buf_desc;
|
||||
if (precvframe == NULL)
|
||||
return NULL;
|
||||
return buf_desc;
|
||||
}
|
||||
|
||||
static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem)
|
||||
{
|
||||
/* due to the design of 2048 bytes alignment of recv_frame, we can
|
||||
* reference the union recv_frame from any given member of recv_frame.
|
||||
* rxmem indicates the any member/address in recv_frame */
|
||||
return (union recv_frame *)(((addr_t)rxmem >> RXFRAME_ALIGN) <<
|
||||
RXFRAME_ALIGN);
|
||||
}
|
||||
|
||||
static inline union recv_frame *pkt_to_recvframe(_pkt *pkt)
|
||||
{
|
||||
u8 *buf_star;
|
||||
union recv_frame *precv_frame;
|
||||
|
||||
precv_frame = rxmem_to_recvframe((unsigned char *)buf_star);
|
||||
return precv_frame;
|
||||
}
|
||||
|
||||
static inline u8 *pkt_to_recvmem(_pkt *pkt)
|
||||
{
|
||||
/* return the rx_head */
|
||||
union recv_frame *precv_frame = pkt_to_recvframe(pkt);
|
||||
|
||||
return precv_frame->u.hdr.rx_head;
|
||||
}
|
||||
|
||||
static inline u8 *pkt_to_recvdata(_pkt *pkt)
|
||||
{
|
||||
/* return the rx_data */
|
||||
union recv_frame *precv_frame = pkt_to_recvframe(pkt);
|
||||
|
||||
return precv_frame->u.hdr.rx_data;
|
||||
}
|
||||
|
||||
static inline sint get_recvframe_len(union recv_frame *precvframe)
|
||||
{
|
||||
return precvframe->u.hdr.len;
|
||||
}
|
||||
|
||||
struct sta_info;
|
||||
|
||||
void _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
|
||||
sint r8712_recvframe_chkmic(struct _adapter *adapter,
|
||||
union recv_frame *precvframe);
|
||||
union recv_frame *r8712_decryptor(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame);
|
||||
union recv_frame *r8712_recvframe_chk_defrag(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame);
|
||||
union recv_frame *r8712_recvframe_defrag(struct _adapter *adapter,
|
||||
struct __queue *defrag_q);
|
||||
union recv_frame *r8712_recvframe_chk_defrag_new(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame);
|
||||
union recv_frame *r8712_recvframe_defrag_new(struct _adapter *adapter,
|
||||
struct __queue *defrag_q,
|
||||
union recv_frame *precv_frame);
|
||||
int r8712_recv_decache(union recv_frame *precv_frame, u8 bretry,
|
||||
struct stainfo_rxcache *prxcache);
|
||||
int r8712_sta2sta_data_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame,
|
||||
struct sta_info **psta);
|
||||
int r8712_ap2sta_data_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame,
|
||||
struct sta_info **psta);
|
||||
int r8712_sta2ap_data_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame,
|
||||
struct sta_info **psta);
|
||||
int r8712_validate_recv_ctrl_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame);
|
||||
int r8712_validate_recv_mgnt_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame);
|
||||
int r8712_validate_recv_data_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame);
|
||||
int r8712_validate_recv_frame(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame);
|
||||
union recv_frame *r8712_portctrl(struct _adapter *adapter,
|
||||
union recv_frame *precv_frame);
|
||||
void r8712_mgt_dispatcher(struct _adapter *padapter, u8 *pframe, uint len);
|
||||
int r8712_amsdu_to_msdu(struct _adapter *padapter, union recv_frame *prframe);
|
||||
|
||||
#endif
|
||||
|
43
drivers/staging/rtl8712/rtl871x_rf.h
Normal file
43
drivers/staging/rtl8712/rtl871x_rf.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef __RTL871X_RF_H_
|
||||
#define __RTL871X_RF_H_
|
||||
|
||||
#include "rtl871x_cmd.h"
|
||||
#include "rtl871x_mp_phy_regdef.h"
|
||||
|
||||
#define OFDM_PHY 1
|
||||
#define MIXED_PHY 2
|
||||
#define CCK_PHY 3
|
||||
#define NumRates (13)
|
||||
#define RTL8711_RF_MAX_SENS 6
|
||||
#define RTL8711_RF_DEF_SENS 4
|
||||
#define NUM_CHANNELS 15
|
||||
|
||||
struct regulatory_class {
|
||||
u32 starting_freq; /*MHz, */
|
||||
u8 channel_set[NUM_CHANNELS];
|
||||
u8 channel_cck_power[NUM_CHANNELS]; /*dbm*/
|
||||
u8 channel_ofdm_power[NUM_CHANNELS];/*dbm*/
|
||||
u8 txpower_limit; /*dbm*/
|
||||
u8 channel_spacing; /*MHz*/
|
||||
u8 modem;
|
||||
};
|
||||
|
||||
enum _REG_PREAMBLE_MODE{
|
||||
PREAMBLE_LONG = 1,
|
||||
PREAMBLE_AUTO = 2,
|
||||
PREAMBLE_SHORT = 3,
|
||||
};
|
||||
|
||||
enum {
|
||||
RTL8712_RFC_1T = 0x10,
|
||||
RTL8712_RFC_2T = 0x20,
|
||||
RTL8712_RFC_1R = 0x01,
|
||||
RTL8712_RFC_2R = 0x02,
|
||||
RTL8712_RFC_1T1R = 0x11,
|
||||
RTL8712_RFC_1T2R = 0x12,
|
||||
RTL8712_RFC_TURBO = 0x92,
|
||||
RTL8712_RFC_2T2R = 0x22
|
||||
};
|
||||
|
||||
#endif /*_RTL8711_RF_H_*/
|
||||
|
1389
drivers/staging/rtl8712/rtl871x_security.c
Normal file
1389
drivers/staging/rtl8712/rtl871x_security.c
Normal file
File diff suppressed because it is too large
Load Diff
196
drivers/staging/rtl8712/rtl871x_security.h
Normal file
196
drivers/staging/rtl8712/rtl871x_security.h
Normal file
@ -0,0 +1,196 @@
|
||||
#ifndef __RTL871X_SECURITY_H_
|
||||
#define __RTL871X_SECURITY_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
|
||||
#define _NO_PRIVACY_ 0x0
|
||||
#define _WEP40_ 0x1
|
||||
#define _TKIP_ 0x2
|
||||
#define _TKIP_WTMIC_ 0x3
|
||||
#define _AES_ 0x4
|
||||
#define _WEP104_ 0x5
|
||||
|
||||
#define _WPA_IE_ID_ 0xdd
|
||||
#define _WPA2_IE_ID_ 0x30
|
||||
|
||||
#ifndef Ndis802_11AuthModeWPA2
|
||||
#define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1)
|
||||
#endif
|
||||
|
||||
#ifndef Ndis802_11AuthModeWPA2PSK
|
||||
#define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2)
|
||||
#endif
|
||||
union pn48 {
|
||||
u64 val;
|
||||
#if defined(__BIG_ENDIAN)
|
||||
struct {
|
||||
u8 TSC7;
|
||||
u8 TSC6;
|
||||
u8 TSC5;
|
||||
u8 TSC4;
|
||||
u8 TSC3;
|
||||
u8 TSC2;
|
||||
u8 TSC1;
|
||||
u8 TSC0;
|
||||
} _byte_;
|
||||
#else
|
||||
struct {
|
||||
u8 TSC0;
|
||||
u8 TSC1;
|
||||
u8 TSC2;
|
||||
u8 TSC3;
|
||||
u8 TSC4;
|
||||
u8 TSC5;
|
||||
u8 TSC6;
|
||||
u8 TSC7;
|
||||
} _byte_;
|
||||
#endif
|
||||
};
|
||||
|
||||
union Keytype {
|
||||
u8 skey[16];
|
||||
u32 lkey[4];
|
||||
};
|
||||
|
||||
struct RT_PMKID_LIST {
|
||||
u8 bUsed;
|
||||
u8 Bssid[6];
|
||||
u8 PMKID[16];
|
||||
u8 SsidBuf[33];
|
||||
u8 *ssid_octet;
|
||||
u16 ssid_length;
|
||||
};
|
||||
|
||||
struct security_priv {
|
||||
u32 AuthAlgrthm; /* 802.11 auth, could be open, shared,
|
||||
* 8021x and authswitch */
|
||||
u32 PrivacyAlgrthm; /* This specify the privacy for shared
|
||||
* auth. algorithm. */
|
||||
u32 PrivacyKeyIndex; /* this is only valid for legendary
|
||||
* wep, 0~3 for key id. */
|
||||
union Keytype DefKey[4]; /* this is only valid for def. key */
|
||||
u32 DefKeylen[4];
|
||||
u32 XGrpPrivacy; /* This specify the privacy algthm.
|
||||
* used for Grp key */
|
||||
u32 XGrpKeyid; /* key id used for Grp Key */
|
||||
union Keytype XGrpKey[2]; /* 802.1x Group Key, for
|
||||
* inx0 and inx1 */
|
||||
union Keytype XGrptxmickey[2];
|
||||
union Keytype XGrprxmickey[2];
|
||||
union pn48 Grptxpn; /* PN48 used for Grp Key xmit. */
|
||||
union pn48 Grprxpn; /* PN48 used for Grp Key recv. */
|
||||
u8 wps_hw_pbc_pressed;/*for hw pbc pressed*/
|
||||
u8 wps_phase;/*for wps*/
|
||||
u8 wps_ie[MAX_WPA_IE_LEN<<2];
|
||||
int wps_ie_len;
|
||||
u8 binstallGrpkey;
|
||||
u8 busetkipkey;
|
||||
struct timer_list tkip_timer;
|
||||
u8 bcheck_grpkey;
|
||||
u8 bgrpkey_handshake;
|
||||
s32 sw_encrypt; /* from registry_priv */
|
||||
s32 sw_decrypt; /* from registry_priv */
|
||||
s32 hw_decrypted; /* if the rx packets is hw_decrypted==false,
|
||||
* it means the hw has not been ready. */
|
||||
u32 ndisauthtype; /* keeps the auth_type & enc_status from upper
|
||||
* layer ioctl(wpa_supplicant or wzc) */
|
||||
u32 ndisencryptstatus;
|
||||
struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */
|
||||
struct NDIS_802_11_WEP ndiswep;
|
||||
u8 assoc_info[600];
|
||||
u8 szofcapability[256]; /* for wpa2 usage */
|
||||
u8 oidassociation[512]; /* for wpa/wpa2 usage */
|
||||
u8 authenticator_ie[256]; /* store ap security information element */
|
||||
u8 supplicant_ie[256]; /* store sta security information element */
|
||||
/* for tkip countermeasure */
|
||||
u32 last_mic_err_time;
|
||||
u8 btkip_countermeasure;
|
||||
u8 btkip_wait_report;
|
||||
u32 btkip_countermeasure_time;
|
||||
/*-------------------------------------------------------------------
|
||||
* For WPA2 Pre-Authentication.
|
||||
*------------------------------------------------------------------ */
|
||||
struct RT_PMKID_LIST PMKIDList[NUM_PMKID_CACHE];
|
||||
u8 PMKIDIndex;
|
||||
};
|
||||
|
||||
#define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst) \
|
||||
do { \
|
||||
switch (psecuritypriv->AuthAlgrthm) { \
|
||||
case 0: \
|
||||
case 1: \
|
||||
case 3: \
|
||||
encry_algo = (u8)psecuritypriv->PrivacyAlgrthm; \
|
||||
break; \
|
||||
case 2: \
|
||||
if (bmcst) \
|
||||
encry_algo = (u8)psecuritypriv->XGrpPrivacy; \
|
||||
else \
|
||||
encry_algo = (u8)psta->XPrivacy; \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
#define SET_ICE_IV_LEN(iv_len, icv_len, encrypt)\
|
||||
do {\
|
||||
switch (encrypt) { \
|
||||
case _WEP40_: \
|
||||
case _WEP104_: \
|
||||
iv_len = 4; \
|
||||
icv_len = 4; \
|
||||
break; \
|
||||
case _TKIP_: \
|
||||
iv_len = 8; \
|
||||
icv_len = 4; \
|
||||
break; \
|
||||
case _AES_: \
|
||||
iv_len = 8; \
|
||||
icv_len = 8; \
|
||||
break; \
|
||||
default: \
|
||||
iv_len = 0; \
|
||||
icv_len = 0; \
|
||||
break; \
|
||||
} \
|
||||
} while (0)
|
||||
#define GET_TKIP_PN(iv, txpn) \
|
||||
do {\
|
||||
txpn._byte_.TSC0 = iv[2];\
|
||||
txpn._byte_.TSC1 = iv[0];\
|
||||
txpn._byte_.TSC2 = iv[4];\
|
||||
txpn._byte_.TSC3 = iv[5];\
|
||||
txpn._byte_.TSC4 = iv[6];\
|
||||
txpn._byte_.TSC5 = iv[7];\
|
||||
} while (0)
|
||||
|
||||
#define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1)))
|
||||
#define ROR32(A, n) ROL32((A), 32 - (n))
|
||||
|
||||
struct mic_data {
|
||||
u32 K0, K1; /* Key */
|
||||
u32 L, R; /* Current state */
|
||||
u32 M; /* Message accumulator (single word) */
|
||||
u32 nBytesInM; /* # bytes in M */
|
||||
};
|
||||
|
||||
void seccalctkipmic(
|
||||
u8 *key,
|
||||
u8 *header,
|
||||
u8 *data,
|
||||
u32 data_len,
|
||||
u8 *Miccode,
|
||||
u8 priority);
|
||||
|
||||
void r8712_secmicsetkey(struct mic_data *pmicdata, u8 * key);
|
||||
void r8712_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nBytes);
|
||||
void r8712_secgetmic(struct mic_data *pmicdata, u8 * dst);
|
||||
u32 r8712_aes_encrypt(struct _adapter *padapter, u8 *pxmitframe);
|
||||
u32 r8712_tkip_encrypt(struct _adapter *padapter, u8 *pxmitframe);
|
||||
void r8712_wep_encrypt(struct _adapter *padapter, u8 *pxmitframe);
|
||||
u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe);
|
||||
u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe);
|
||||
void r8712_wep_decrypt(struct _adapter *padapter, u8 *precvframe);
|
||||
void r8712_use_tkipkey_handler(void *FunctionContext);
|
||||
|
||||
#endif /*__RTL871X_SECURITY_H_ */
|
||||
|
299
drivers/staging/rtl8712/rtl871x_sta_mgt.c
Normal file
299
drivers/staging/rtl8712/rtl871x_sta_mgt.c
Normal file
@ -0,0 +1,299 @@
|
||||
/******************************************************************************
|
||||
* rtl871x_sta_mgt.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 _RTL871X_STA_MGT_C_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "recv_osdep.h"
|
||||
#include "xmit_osdep.h"
|
||||
#include "sta_info.h"
|
||||
|
||||
static void _init_stainfo(struct sta_info *psta)
|
||||
{
|
||||
memset((u8 *)psta, 0, sizeof(struct sta_info));
|
||||
spin_lock_init(&psta->lock);
|
||||
_init_listhead(&psta->list);
|
||||
_init_listhead(&psta->hash_list);
|
||||
_r8712_init_sta_xmit_priv(&psta->sta_xmitpriv);
|
||||
_r8712_init_sta_recv_priv(&psta->sta_recvpriv);
|
||||
#ifdef CONFIG_R8712_AP
|
||||
_init_listhead(&psta->auth_list);
|
||||
#endif
|
||||
}
|
||||
|
||||
u32 _r8712_init_sta_priv(struct sta_priv *pstapriv)
|
||||
{
|
||||
struct sta_info *psta;
|
||||
s32 i;
|
||||
|
||||
pstapriv->pallocated_stainfo_buf = _malloc(sizeof(struct sta_info) *
|
||||
NUM_STA + 4);
|
||||
if (pstapriv->pallocated_stainfo_buf == NULL)
|
||||
return _FAIL;
|
||||
pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
|
||||
((addr_t)(pstapriv->pallocated_stainfo_buf) & 3);
|
||||
_init_queue(&pstapriv->free_sta_queue);
|
||||
spin_lock_init(&pstapriv->sta_hash_lock);
|
||||
pstapriv->asoc_sta_count = 0;
|
||||
_init_queue(&pstapriv->sleep_q);
|
||||
_init_queue(&pstapriv->wakeup_q);
|
||||
psta = (struct sta_info *)(pstapriv->pstainfo_buf);
|
||||
for (i = 0; i < NUM_STA; i++) {
|
||||
_init_stainfo(psta);
|
||||
_init_listhead(&(pstapriv->sta_hash[i]));
|
||||
list_insert_tail(&psta->list,
|
||||
get_list_head(&pstapriv->free_sta_queue));
|
||||
psta++;
|
||||
}
|
||||
#ifdef CONFIG_R8712_AP
|
||||
_init_listhead(&pstapriv->asoc_list);
|
||||
_init_listhead(&pstapriv->auth_list);
|
||||
#endif
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
/* this function is used to free the memory of lock || sema for all stainfos */
|
||||
static void mfree_all_stainfo(struct sta_priv *pstapriv)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct list_head *plist, *phead;
|
||||
struct sta_info *psta = NULL;
|
||||
|
||||
spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL);
|
||||
phead = get_list_head(&pstapriv->free_sta_queue);
|
||||
plist = get_next(phead);
|
||||
while ((end_of_queue_search(phead, plist)) == false) {
|
||||
psta = LIST_CONTAINOR(plist, struct sta_info, list);
|
||||
plist = get_next(plist);
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL);
|
||||
}
|
||||
|
||||
|
||||
static void mfree_sta_priv_lock(struct sta_priv *pstapriv)
|
||||
{
|
||||
mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */
|
||||
}
|
||||
|
||||
u32 _r8712_free_sta_priv(struct sta_priv *pstapriv)
|
||||
{
|
||||
if (pstapriv) {
|
||||
mfree_sta_priv_lock(pstapriv);
|
||||
kfree(pstapriv->pallocated_stainfo_buf);
|
||||
}
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
|
||||
{
|
||||
uint tmp_aid;
|
||||
s32 index;
|
||||
struct list_head *phash_list;
|
||||
struct sta_info *psta;
|
||||
struct __queue *pfree_sta_queue;
|
||||
struct recv_reorder_ctrl *preorder_ctrl;
|
||||
int i = 0;
|
||||
u16 wRxSeqInitialValue = 0xffff;
|
||||
unsigned long flags;
|
||||
|
||||
pfree_sta_queue = &pstapriv->free_sta_queue;
|
||||
spin_lock_irqsave(&(pfree_sta_queue->lock), flags);
|
||||
if (_queue_empty(pfree_sta_queue) == true)
|
||||
psta = NULL;
|
||||
else {
|
||||
psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue),
|
||||
struct sta_info, list);
|
||||
list_delete(&(psta->list));
|
||||
tmp_aid = psta->aid;
|
||||
_init_stainfo(psta);
|
||||
memcpy(psta->hwaddr, hwaddr, ETH_ALEN);
|
||||
index = wifi_mac_hash(hwaddr);
|
||||
if (index >= NUM_STA) {
|
||||
psta = NULL;
|
||||
goto exit;
|
||||
}
|
||||
phash_list = &(pstapriv->sta_hash[index]);
|
||||
list_insert_tail(&psta->hash_list, phash_list);
|
||||
pstapriv->asoc_sta_count++ ;
|
||||
|
||||
/* For the SMC router, the sequence number of first packet of WPS handshake
|
||||
* will be 0. In this case, this packet will be dropped by recv_decache function
|
||||
* if we use the 0x00 as the default value for tid_rxseq variable. So, we
|
||||
* initialize the tid_rxseq variable as the 0xffff.
|
||||
*/
|
||||
for (i = 0; i < 16; i++)
|
||||
memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i],
|
||||
&wRxSeqInitialValue, 2);
|
||||
/* for A-MPDU Rx reordering buffer control */
|
||||
for (i = 0; i < 16 ; i++) {
|
||||
preorder_ctrl = &psta->recvreorder_ctrl[i];
|
||||
preorder_ctrl->padapter = pstapriv->padapter;
|
||||
preorder_ctrl->indicate_seq = 0xffff;
|
||||
preorder_ctrl->wend_b = 0xffff;
|
||||
preorder_ctrl->wsize_b = 64;
|
||||
_init_queue(&preorder_ctrl->pending_recvframe_queue);
|
||||
r8712_init_recv_timer(preorder_ctrl);
|
||||
}
|
||||
}
|
||||
exit:
|
||||
spin_unlock_irqrestore(&(pfree_sta_queue->lock), flags);
|
||||
return psta;
|
||||
}
|
||||
|
||||
/* using pstapriv->sta_hash_lock to protect */
|
||||
void r8712_free_stainfo(struct _adapter *padapter, struct sta_info *psta)
|
||||
{
|
||||
int i;
|
||||
unsigned long irqL0;
|
||||
struct __queue *pfree_sta_queue;
|
||||
struct recv_reorder_ctrl *preorder_ctrl;
|
||||
struct sta_xmit_priv *pstaxmitpriv;
|
||||
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||
struct sta_priv *pstapriv = &padapter->stapriv;
|
||||
|
||||
if (psta == NULL)
|
||||
return;
|
||||
pfree_sta_queue = &pstapriv->free_sta_queue;
|
||||
pstaxmitpriv = &psta->sta_xmitpriv;
|
||||
spin_lock_irqsave(&(pxmitpriv->vo_pending.lock), irqL0);
|
||||
r8712_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending);
|
||||
list_delete(&(pstaxmitpriv->vo_q.tx_pending));
|
||||
spin_unlock_irqrestore(&(pxmitpriv->vo_pending.lock), irqL0);
|
||||
spin_lock_irqsave(&(pxmitpriv->vi_pending.lock), irqL0);
|
||||
r8712_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending);
|
||||
list_delete(&(pstaxmitpriv->vi_q.tx_pending));
|
||||
spin_unlock_irqrestore(&(pxmitpriv->vi_pending.lock), irqL0);
|
||||
spin_lock_irqsave(&(pxmitpriv->bk_pending.lock), irqL0);
|
||||
r8712_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending);
|
||||
list_delete(&(pstaxmitpriv->bk_q.tx_pending));
|
||||
spin_unlock_irqrestore(&(pxmitpriv->bk_pending.lock), irqL0);
|
||||
spin_lock_irqsave(&(pxmitpriv->be_pending.lock), irqL0);
|
||||
r8712_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending);
|
||||
list_delete(&(pstaxmitpriv->be_q.tx_pending));
|
||||
spin_unlock_irqrestore(&(pxmitpriv->be_pending.lock), irqL0);
|
||||
list_delete(&psta->hash_list);
|
||||
pstapriv->asoc_sta_count--;
|
||||
/* re-init sta_info; 20061114 */
|
||||
_r8712_init_sta_xmit_priv(&psta->sta_xmitpriv);
|
||||
_r8712_init_sta_recv_priv(&psta->sta_recvpriv);
|
||||
/* for A-MPDU Rx reordering buffer control,
|
||||
* cancel reordering_ctrl_timer */
|
||||
for (i = 0; i < 16; i++) {
|
||||
preorder_ctrl = &psta->recvreorder_ctrl[i];
|
||||
_cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer);
|
||||
}
|
||||
spin_lock(&(pfree_sta_queue->lock));
|
||||
/* insert into free_sta_queue; 20061114 */
|
||||
list_insert_tail(&psta->list, get_list_head(pfree_sta_queue));
|
||||
spin_unlock(&(pfree_sta_queue->lock));
|
||||
}
|
||||
|
||||
/* free all stainfo which in sta_hash[all] */
|
||||
void r8712_free_all_stainfo(struct _adapter *padapter)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct list_head *plist, *phead;
|
||||
s32 index;
|
||||
struct sta_info *psta = NULL;
|
||||
struct sta_priv *pstapriv = &padapter->stapriv;
|
||||
struct sta_info *pbcmc_stainfo = r8712_get_bcmc_stainfo(padapter);
|
||||
|
||||
if (pstapriv->asoc_sta_count == 1)
|
||||
return;
|
||||
spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL);
|
||||
for (index = 0; index < NUM_STA; index++) {
|
||||
phead = &(pstapriv->sta_hash[index]);
|
||||
plist = get_next(phead);
|
||||
while ((end_of_queue_search(phead, plist)) == false) {
|
||||
psta = LIST_CONTAINOR(plist,
|
||||
struct sta_info, hash_list);
|
||||
plist = get_next(plist);
|
||||
if (pbcmc_stainfo != psta)
|
||||
r8712_free_stainfo(padapter , psta);
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL);
|
||||
}
|
||||
|
||||
/* any station allocated can be searched by hash list */
|
||||
struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
|
||||
{
|
||||
unsigned long irqL;
|
||||
struct list_head *plist, *phead;
|
||||
struct sta_info *psta = NULL;
|
||||
u32 index;
|
||||
|
||||
if (hwaddr == NULL)
|
||||
return NULL;
|
||||
index = wifi_mac_hash(hwaddr);
|
||||
spin_lock_irqsave(&pstapriv->sta_hash_lock, irqL);
|
||||
phead = &(pstapriv->sta_hash[index]);
|
||||
plist = get_next(phead);
|
||||
while ((end_of_queue_search(phead, plist)) == false) {
|
||||
psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
|
||||
if ((!memcmp(psta->hwaddr, hwaddr, ETH_ALEN))) {
|
||||
/* if found the matched address */
|
||||
break;
|
||||
}
|
||||
psta = NULL;
|
||||
plist = get_next(plist);
|
||||
}
|
||||
spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL);
|
||||
return psta;
|
||||
}
|
||||
|
||||
void r8712_init_bcmc_stainfo(struct _adapter *padapter)
|
||||
{
|
||||
struct sta_info *psta;
|
||||
struct tx_servq *ptxservq;
|
||||
unsigned char bcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
struct sta_priv *pstapriv = &padapter->stapriv;
|
||||
|
||||
psta = r8712_alloc_stainfo(pstapriv, bcast_addr);
|
||||
if (psta == NULL)
|
||||
return;
|
||||
ptxservq = &(psta->sta_xmitpriv.be_q);
|
||||
}
|
||||
|
||||
struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter)
|
||||
{
|
||||
struct sta_info *psta;
|
||||
struct sta_priv *pstapriv = &padapter->stapriv;
|
||||
u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
|
||||
psta = r8712_get_stainfo(pstapriv, bc_addr);
|
||||
return psta;
|
||||
}
|
||||
|
||||
|
||||
u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 *mac_addr)
|
||||
{
|
||||
return true;
|
||||
}
|
22
drivers/staging/rtl8712/rtl871x_wlan_sme.h
Normal file
22
drivers/staging/rtl8712/rtl871x_wlan_sme.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef _RTL871X_WLAN_SME_H_
|
||||
#define _RTL871X_WLAN_SME_H_
|
||||
|
||||
#define MSR_APMODE 0x0C
|
||||
#define MSR_STAMODE 0x08
|
||||
#define MSR_ADHOCMODE 0x04
|
||||
#define MSR_NOLINKMODE 0x00
|
||||
#define _1M_RATE_ 0
|
||||
#define _2M_RATE_ 1
|
||||
#define _5M_RATE_ 2
|
||||
#define _11M_RATE_ 3
|
||||
#define _6M_RATE_ 4
|
||||
#define _9M_RATE_ 5
|
||||
#define _12M_RATE_ 6
|
||||
#define _18M_RATE_ 7
|
||||
#define _24M_RATE_ 8
|
||||
#define _36M_RATE_ 9
|
||||
#define _48M_RATE_ 10
|
||||
#define _54M_RATE_ 11
|
||||
|
||||
#endif
|
||||
|
1052
drivers/staging/rtl8712/rtl871x_xmit.c
Normal file
1052
drivers/staging/rtl8712/rtl871x_xmit.c
Normal file
File diff suppressed because it is too large
Load Diff
260
drivers/staging/rtl8712/rtl871x_xmit.h
Normal file
260
drivers/staging/rtl8712/rtl871x_xmit.h
Normal file
@ -0,0 +1,260 @@
|
||||
#ifndef _RTL871X_XMIT_H_
|
||||
#define _RTL871X_XMIT_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "xmit_osdep.h"
|
||||
|
||||
#define MAX_XMITBUF_SZ (2048)
|
||||
#define NR_XMITBUFF (4)
|
||||
#define XMITBUF_ALIGN_SZ 512
|
||||
#define TX_GUARD_BAND 5
|
||||
#define MAX_NUMBLKS (1)
|
||||
|
||||
/* Fixed the Big Endian bug when using the software driver encryption.*/
|
||||
#define WEP_IV(pattrib_iv, txpn, keyidx)\
|
||||
do { \
|
||||
pattrib_iv[0] = txpn._byte_.TSC0;\
|
||||
pattrib_iv[1] = txpn._byte_.TSC1;\
|
||||
pattrib_iv[2] = txpn._byte_.TSC2;\
|
||||
pattrib_iv[3] = ((keyidx & 0x3)<<6);\
|
||||
txpn.val = (txpn.val == 0xffffff) ? 0 : (txpn.val+1);\
|
||||
} while (0)
|
||||
|
||||
/* Fixed the Big Endian bug when doing the Tx.
|
||||
* The Linksys WRH54G will check this.*/
|
||||
#define TKIP_IV(pattrib_iv, txpn, keyidx)\
|
||||
do { \
|
||||
pattrib_iv[0] = txpn._byte_.TSC1;\
|
||||
pattrib_iv[1] = (txpn._byte_.TSC1 | 0x20) & 0x7f;\
|
||||
pattrib_iv[2] = txpn._byte_.TSC0;\
|
||||
pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
|
||||
pattrib_iv[4] = txpn._byte_.TSC2;\
|
||||
pattrib_iv[5] = txpn._byte_.TSC3;\
|
||||
pattrib_iv[6] = txpn._byte_.TSC4;\
|
||||
pattrib_iv[7] = txpn._byte_.TSC5;\
|
||||
txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
|
||||
(txpn.val+1);\
|
||||
} while (0)
|
||||
|
||||
#define AES_IV(pattrib_iv, txpn, keyidx)\
|
||||
do { \
|
||||
pattrib_iv[0] = txpn._byte_.TSC0;\
|
||||
pattrib_iv[1] = txpn._byte_.TSC1;\
|
||||
pattrib_iv[2] = 0;\
|
||||
pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\
|
||||
pattrib_iv[4] = txpn._byte_.TSC2;\
|
||||
pattrib_iv[5] = txpn._byte_.TSC3;\
|
||||
pattrib_iv[6] = txpn._byte_.TSC4;\
|
||||
pattrib_iv[7] = txpn._byte_.TSC5;\
|
||||
txpn.val = txpn.val == 0xffffffffffffULL ? 0 : \
|
||||
(txpn.val+1);\
|
||||
} while (0)
|
||||
|
||||
struct hw_xmit {
|
||||
spinlock_t xmit_lock;
|
||||
struct list_head pending;
|
||||
struct __queue *sta_queue;
|
||||
struct hw_txqueue *phwtxqueue;
|
||||
sint txcmdcnt;
|
||||
int accnt;
|
||||
};
|
||||
|
||||
struct pkt_attrib {
|
||||
u8 type;
|
||||
u8 subtype;
|
||||
u8 bswenc;
|
||||
u8 dhcp_pkt;
|
||||
|
||||
u16 seqnum;
|
||||
u16 ether_type;
|
||||
u32 pktlen; /* the original 802.3 pkt raw_data len
|
||||
* (not include ether_hdr data) */
|
||||
u32 last_txcmdsz;
|
||||
|
||||
u8 pkt_hdrlen; /*the original 802.3 pkt header len*/
|
||||
u8 hdrlen; /*the WLAN Header Len*/
|
||||
u8 nr_frags;
|
||||
u8 ack_policy;
|
||||
u8 mac_id;
|
||||
u8 vcs_mode; /*virtual carrier sense method*/
|
||||
u8 pctrl;/*per packet txdesc control enable*/
|
||||
u8 qsel;
|
||||
|
||||
u8 priority;
|
||||
u8 encrypt; /* when 0 indicate no encrypt. when non-zero,
|
||||
* indicate the encrypt algorith*/
|
||||
u8 iv_len;
|
||||
u8 icv_len;
|
||||
unsigned char iv[8];
|
||||
unsigned char icv[8];
|
||||
u8 dst[ETH_ALEN];
|
||||
u8 src[ETH_ALEN];
|
||||
u8 ta[ETH_ALEN];
|
||||
u8 ra[ETH_ALEN];
|
||||
struct sta_info *psta;
|
||||
};
|
||||
|
||||
#define WLANHDR_OFFSET 64
|
||||
#define DATA_FRAMETAG 0x01
|
||||
#define L2_FRAMETAG 0x02
|
||||
#define MGNT_FRAMETAG 0x03
|
||||
#define AMSDU_FRAMETAG 0x04
|
||||
#define EII_FRAMETAG 0x05
|
||||
#define IEEE8023_FRAMETAG 0x06
|
||||
#define MP_FRAMETAG 0x07
|
||||
#define TXAGG_FRAMETAG 0x08
|
||||
|
||||
struct xmit_buf {
|
||||
struct list_head list;
|
||||
|
||||
u8 *pallocated_buf;
|
||||
u8 *pbuf;
|
||||
struct urb *pxmit_urb[8];
|
||||
};
|
||||
|
||||
struct xmit_frame {
|
||||
struct list_head list;
|
||||
struct pkt_attrib attrib;
|
||||
_pkt *pkt;
|
||||
int frame_tag;
|
||||
struct _adapter *padapter;
|
||||
u8 *buf_addr;
|
||||
struct xmit_buf *pxmitbuf;
|
||||
u8 *mem_addr;
|
||||
u16 sz[8];
|
||||
struct urb *pxmit_urb[8];
|
||||
u8 bpending[8];
|
||||
u8 last[8];
|
||||
};
|
||||
|
||||
struct tx_servq {
|
||||
struct list_head tx_pending;
|
||||
struct __queue sta_pending;
|
||||
int qcnt;
|
||||
};
|
||||
|
||||
struct sta_xmit_priv {
|
||||
spinlock_t lock;
|
||||
sint option;
|
||||
sint apsd_setting; /* When bit mask is on, the associated edca
|
||||
* queue supports APSD.*/
|
||||
struct tx_servq be_q; /* priority == 0,3 */
|
||||
struct tx_servq bk_q; /* priority == 1,2*/
|
||||
struct tx_servq vi_q; /*priority == 4,5*/
|
||||
struct tx_servq vo_q; /*priority == 6,7*/
|
||||
struct list_head legacy_dz;
|
||||
struct list_head apsd;
|
||||
u16 txseq_tid[16];
|
||||
uint sta_tx_bytes;
|
||||
u64 sta_tx_pkts;
|
||||
uint sta_tx_fail;
|
||||
};
|
||||
|
||||
struct hw_txqueue {
|
||||
/*volatile*/ sint head;
|
||||
/*volatile*/ sint tail;
|
||||
/*volatile*/ sint free_sz; /*in units of 64 bytes*/
|
||||
/*volatile*/ sint free_cmdsz;
|
||||
/*volatile*/ sint txsz[8];
|
||||
uint ff_hwaddr;
|
||||
uint cmd_hwaddr;
|
||||
sint ac_tag;
|
||||
};
|
||||
|
||||
struct xmit_priv {
|
||||
spinlock_t lock;
|
||||
struct semaphore xmit_sema;
|
||||
struct semaphore terminate_xmitthread_sema;
|
||||
struct __queue be_pending;
|
||||
struct __queue bk_pending;
|
||||
struct __queue vi_pending;
|
||||
struct __queue vo_pending;
|
||||
struct __queue bm_pending;
|
||||
struct __queue legacy_dz_queue;
|
||||
struct __queue apsd_queue;
|
||||
u8 *pallocated_frame_buf;
|
||||
u8 *pxmit_frame_buf;
|
||||
uint free_xmitframe_cnt;
|
||||
uint mapping_addr;
|
||||
uint pkt_sz;
|
||||
struct __queue free_xmit_queue;
|
||||
struct hw_txqueue be_txqueue;
|
||||
struct hw_txqueue bk_txqueue;
|
||||
struct hw_txqueue vi_txqueue;
|
||||
struct hw_txqueue vo_txqueue;
|
||||
struct hw_txqueue bmc_txqueue;
|
||||
uint frag_len;
|
||||
struct _adapter *adapter;
|
||||
u8 vcs_setting;
|
||||
u8 vcs;
|
||||
u8 vcs_type;
|
||||
u16 rts_thresh;
|
||||
uint tx_bytes;
|
||||
u64 tx_pkts;
|
||||
uint tx_drop;
|
||||
struct hw_xmit *hwxmits;
|
||||
u8 hwxmit_entry;
|
||||
struct semaphore tx_retevt;/*all tx return event;*/
|
||||
u8 txirp_cnt;
|
||||
struct tasklet_struct xmit_tasklet;
|
||||
/*per AC pending irp*/
|
||||
int beq_cnt;
|
||||
int bkq_cnt;
|
||||
int viq_cnt;
|
||||
int voq_cnt;
|
||||
struct __queue free_amsdu_xmit_queue;
|
||||
u8 *pallocated_amsdu_frame_buf;
|
||||
u8 *pxmit_amsdu_frame_buf;
|
||||
uint free_amsdu_xmitframe_cnt;
|
||||
struct __queue free_txagg_xmit_queue;
|
||||
u8 *pallocated_txagg_frame_buf;
|
||||
u8 *pxmit_txagg_frame_buf;
|
||||
uint free_txagg_xmitframe_cnt;
|
||||
int cmdseq;
|
||||
struct __queue free_xmitbuf_queue;
|
||||
struct __queue pending_xmitbuf_queue;
|
||||
u8 *pallocated_xmitbuf;
|
||||
u8 *pxmitbuf;
|
||||
uint free_xmitbuf_cnt;
|
||||
};
|
||||
|
||||
static inline struct __queue *get_free_xmit_queue(
|
||||
struct xmit_priv *pxmitpriv)
|
||||
{
|
||||
return &(pxmitpriv->free_xmit_queue);
|
||||
}
|
||||
|
||||
int r8712_free_xmitbuf(struct xmit_priv *pxmitpriv,
|
||||
struct xmit_buf *pxmitbuf);
|
||||
struct xmit_buf *r8712_alloc_xmitbuf(struct xmit_priv *pxmitpriv);
|
||||
void r8712_update_protection(struct _adapter *padapter, u8 *ie, uint ie_len);
|
||||
struct xmit_frame *r8712_alloc_xmitframe(struct xmit_priv *pxmitpriv);
|
||||
void r8712_free_xmitframe(struct xmit_priv *pxmitpriv,
|
||||
struct xmit_frame *pxmitframe);
|
||||
void r8712_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
|
||||
struct __queue *pframequeue);
|
||||
sint r8712_xmit_classifier(struct _adapter *padapter,
|
||||
struct xmit_frame *pxmitframe);
|
||||
sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt,
|
||||
struct xmit_frame *pxmitframe);
|
||||
sint _r8712_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag);
|
||||
void _r8712_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv);
|
||||
sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt,
|
||||
struct pkt_attrib *pattrib);
|
||||
int r8712_txframes_sta_ac_pending(struct _adapter *padapter,
|
||||
struct pkt_attrib *pattrib);
|
||||
sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, struct _adapter *padapter);
|
||||
void _free_xmit_priv(struct xmit_priv *pxmitpriv);
|
||||
void r8712_free_xmitframe_ex(struct xmit_priv *pxmitpriv,
|
||||
struct xmit_frame *pxmitframe);
|
||||
int r8712_pre_xmit(struct _adapter *padapter, struct xmit_frame *pxmitframe);
|
||||
int r8712_xmit_enqueue(struct _adapter *padapter,
|
||||
struct xmit_frame *pxmitframe);
|
||||
int r8712_xmit_direct(struct _adapter *padapter, struct xmit_frame *pxmitframe);
|
||||
void r8712_xmit_bh(void *priv);
|
||||
|
||||
#include "rtl8712_xmit.h"
|
||||
|
||||
#endif /*_RTL871X_XMIT_H_*/
|
||||
|
125
drivers/staging/rtl8712/sta_info.h
Normal file
125
drivers/staging/rtl8712/sta_info.h
Normal file
@ -0,0 +1,125 @@
|
||||
#ifndef __STA_INFO_H_
|
||||
#define __STA_INFO_H_
|
||||
|
||||
#include "osdep_service.h"
|
||||
#include "drv_types.h"
|
||||
#include "wifi.h"
|
||||
|
||||
#define NUM_STA 32
|
||||
#define NUM_ACL 64
|
||||
|
||||
|
||||
/* if mode ==0, then the sta is allowed once the addr is hit.
|
||||
* if mode ==1, then the sta is rejected once the addr is non-hit.
|
||||
*/
|
||||
struct wlan_acl_node {
|
||||
struct list_head list;
|
||||
u8 addr[ETH_ALEN];
|
||||
u8 mode;
|
||||
};
|
||||
|
||||
struct wlan_acl_pool {
|
||||
struct wlan_acl_node aclnode[NUM_ACL];
|
||||
};
|
||||
|
||||
struct stainfo_stats {
|
||||
|
||||
uint rx_pkts;
|
||||
uint rx_bytes;
|
||||
u64 tx_pkts;
|
||||
uint tx_bytes;
|
||||
};
|
||||
|
||||
struct sta_info {
|
||||
spinlock_t lock;
|
||||
struct list_head list; /*free_sta_queue*/
|
||||
struct list_head hash_list; /*sta_hash*/
|
||||
struct sta_xmit_priv sta_xmitpriv;
|
||||
struct sta_recv_priv sta_recvpriv;
|
||||
uint state;
|
||||
uint aid;
|
||||
u8 mac_id;
|
||||
u8 qos_option;
|
||||
u8 hwaddr[ETH_ALEN];
|
||||
uint ieee8021x_blocked; /*0: allowed, 1:blocked */
|
||||
uint XPrivacy; /*aes, tkip...*/
|
||||
union Keytype tkiptxmickey;
|
||||
union Keytype tkiprxmickey;
|
||||
union Keytype x_UncstKey;
|
||||
union pn48 txpn; /* PN48 used for Unicast xmit.*/
|
||||
union pn48 rxpn; /* PN48 used for Unicast recv.*/
|
||||
u8 bssrateset[16];
|
||||
uint bssratelen;
|
||||
s32 rssi;
|
||||
s32 signal_quality;
|
||||
struct stainfo_stats sta_stats;
|
||||
/*for A-MPDU Rx reordering buffer control */
|
||||
struct recv_reorder_ctrl recvreorder_ctrl[16];
|
||||
struct ht_priv htpriv;
|
||||
/* Notes:
|
||||
* STA_Mode:
|
||||
* curr_network(mlme_priv/security_priv/qos/ht)
|
||||
* + sta_info: (STA & AP) CAP/INFO
|
||||
* scan_q: AP CAP/INFO
|
||||
* AP_Mode:
|
||||
* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO
|
||||
* sta_info: (AP & STA) CAP/INFO
|
||||
*/
|
||||
#ifdef CONFIG_R8712_AP
|
||||
struct list_head asoc_list;
|
||||
struct list_head auth_list;
|
||||
unsigned int expire_to;
|
||||
unsigned int auth_seq;
|
||||
unsigned int authalg;
|
||||
unsigned char chg_txt[128];
|
||||
unsigned int tx_ra_bitmap;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct sta_priv {
|
||||
u8 *pallocated_stainfo_buf;
|
||||
u8 *pstainfo_buf;
|
||||
struct __queue free_sta_queue;
|
||||
spinlock_t sta_hash_lock;
|
||||
struct list_head sta_hash[NUM_STA];
|
||||
int asoc_sta_count;
|
||||
struct __queue sleep_q;
|
||||
struct __queue wakeup_q;
|
||||
struct _adapter *padapter;
|
||||
#ifdef CONFIG_R8712_AP
|
||||
struct list_head asoc_list;
|
||||
struct list_head auth_list;
|
||||
unsigned int auth_to; /* sec, time to expire in authenticating. */
|
||||
unsigned int assoc_to; /* sec, time to expire before associating. */
|
||||
unsigned int expire_to; /* sec , time to expire after associated. */
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline u32 wifi_mac_hash(u8 *mac)
|
||||
{
|
||||
u32 x;
|
||||
|
||||
x = mac[0];
|
||||
x = (x << 2) ^ mac[1];
|
||||
x = (x << 2) ^ mac[2];
|
||||
x = (x << 2) ^ mac[3];
|
||||
x = (x << 2) ^ mac[4];
|
||||
x = (x << 2) ^ mac[5];
|
||||
x ^= x >> 8;
|
||||
x = x & (NUM_STA - 1);
|
||||
return x;
|
||||
}
|
||||
|
||||
u32 _r8712_init_sta_priv(struct sta_priv *pstapriv);
|
||||
u32 _r8712_free_sta_priv(struct sta_priv *pstapriv);
|
||||
struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv,
|
||||
u8 *hwaddr);
|
||||
void r8712_free_stainfo(struct _adapter *padapter , struct sta_info *psta);
|
||||
void r8712_free_all_stainfo(struct _adapter *padapter);
|
||||
struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
|
||||
void r8712_init_bcmc_stainfo(struct _adapter *padapter);
|
||||
struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter);
|
||||
u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 * mac_addr);
|
||||
|
||||
#endif /* _STA_INFO_H_ */
|
||||
|
106
drivers/staging/rtl8712/swab.h
Normal file
106
drivers/staging/rtl8712/swab.h
Normal file
@ -0,0 +1,106 @@
|
||||
#ifndef _LINUX_BYTEORDER_SWAB_H
|
||||
#define _LINUX_BYTEORDER_SWAB_H
|
||||
|
||||
#ifndef __u16
|
||||
#define __u16 unsigned short
|
||||
#endif
|
||||
|
||||
#ifndef __u32
|
||||
#define __u32 unsigned int
|
||||
#endif
|
||||
|
||||
#ifndef __u8
|
||||
#define __u8 unsigned char
|
||||
#endif
|
||||
|
||||
#ifndef __u64
|
||||
#define __u64 unsigned long long
|
||||
#endif
|
||||
|
||||
|
||||
static inline __u16 ___swab16(__u16 x)
|
||||
{
|
||||
__u16 __x = x;
|
||||
return (__u16)(
|
||||
(((__u16)(__x) & (__u16)0x00ffU) << 8) |
|
||||
(((__u16)(__x) & (__u16)0xff00U) >> 8));
|
||||
|
||||
}
|
||||
|
||||
static inline __u32 ___swab32(__u32 x)
|
||||
{
|
||||
__u32 __x = (x);
|
||||
return (__u32)(
|
||||
(((__u32)(__x) & (__u32)0x000000ffUL) << 24) |
|
||||
(((__u32)(__x) & (__u32)0x0000ff00UL) << 8) |
|
||||
(((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) |
|
||||
(((__u32)(__x) & (__u32)0xff000000UL) >> 24));
|
||||
}
|
||||
|
||||
static inline __u64 ___swab64(__u64 x)
|
||||
{
|
||||
__u64 __x = (x);
|
||||
|
||||
return (__u64)( \
|
||||
(__u64)(((__u64)(__x) & (__u64)0x00000000000000ffULL) << 56) | \
|
||||
(__u64)(((__u64)(__x) & (__u64)0x000000000000ff00ULL) << 40) | \
|
||||
(__u64)(((__u64)(__x) & (__u64)0x0000000000ff0000ULL) << 24) | \
|
||||
(__u64)(((__u64)(__x) & (__u64)0x00000000ff000000ULL) << 8) | \
|
||||
(__u64)(((__u64)(__x) & (__u64)0x000000ff00000000ULL) >> 8) | \
|
||||
(__u64)(((__u64)(__x) & (__u64)0x0000ff0000000000ULL) >> 24) | \
|
||||
(__u64)(((__u64)(__x) & (__u64)0x00ff000000000000ULL) >> 40) | \
|
||||
(__u64)(((__u64)(__x) & (__u64)0xff00000000000000ULL) >> 56));
|
||||
}
|
||||
|
||||
#ifndef __arch__swab16
|
||||
static inline __u16 __arch__swab16(__u16 x)
|
||||
{
|
||||
return ___swab16(x);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __arch__swab32
|
||||
static inline __u32 __arch__swab32(__u32 x)
|
||||
{
|
||||
__u32 __tmp = (x) ;
|
||||
return ___swab32(__tmp);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __arch__swab64
|
||||
|
||||
static inline __u64 __arch__swab64(__u64 x)
|
||||
{
|
||||
__u64 __tmp = (x) ;
|
||||
return ___swab64(__tmp);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#define __swab16(x) __fswab16(x)
|
||||
#define __swab32(x) __fswab32(x)
|
||||
#define __swab64(x) __fswab64(x)
|
||||
|
||||
static inline const __u16 __fswab16(__u16 x)
|
||||
{
|
||||
return __arch__swab16(x);
|
||||
}
|
||||
static inline const __u32 __fswab32(__u32 x)
|
||||
{
|
||||
return __arch__swab32(x);
|
||||
}
|
||||
|
||||
#define swab16 __swab16
|
||||
#define swab32 __swab32
|
||||
#define swab64 __swab64
|
||||
#define swab16p __swab16p
|
||||
#define swab32p __swab32p
|
||||
#define swab64p __swab64p
|
||||
#define swab16s __swab16s
|
||||
#define swab32s __swab32s
|
||||
#define swab64s __swab64s
|
||||
|
||||
#endif /* _LINUX_BYTEORDER_SWAB_H */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user