Commit 2865d42c authored by Larry Finger's avatar Larry Finger

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

This code is for a completely new version of the Realtek 8192 USB devices
such as the D-Link DWA-130. The Realtek code, which was originally for
Linux, Windows XP and Windows CE, has been stripped of all code not needed
for Linux. In addition, only one additional configuration variable, which
enables AP mode, remains.
Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarFlorian Schilhabel <florian.c.schilhabel@googlemail.com>
Tested-by: default avatarFrederic Leroy <fredo@starox.org>
parent 763008c4
......@@ -79,6 +79,8 @@ source "drivers/staging/rtl8192u/Kconfig"
source "drivers/staging/rtl8192e/Kconfig"
source "drivers/staging/rtl8712/Kconfig"
source "drivers/staging/frontier/Kconfig"
source "drivers/staging/dream/Kconfig"
......
......@@ -23,6 +23,7 @@ obj-$(CONFIG_R8187SE) += rtl8187se/
obj-$(CONFIG_RTL8192SU) += rtl8192su/
obj-$(CONFIG_RTL8192U) += rtl8192u/
obj-$(CONFIG_RTL8192E) += rtl8192e/
obj-$(CONFIG_R8712U) += rtl8712/
obj-$(CONFIG_SPECTRA) += spectra/
obj-$(CONFIG_TRANZPORT) += frontier/
obj-$(CONFIG_DREAM) += dream/
......
config R8712U
tristate "RealTek RTL8712U (RTL8192SU) Wireless LAN NIC driver"
depends on WLAN && USB
select WIRELESS_EXT
select WEXT_PRIV
default N
---help---
This option adds the Realtek RTL8712 USB device such as the D-Link DWA-130.
If built as a module, it will be called r8712u.
config R8712_AP
bool "Realtek RTL8712U AP code"
depends on R8712U
default N
---help---
This option allows the Realtek RTL8712 USB device to be an Access Point.
r8712u-objs := \
rtl871x_cmd.o \
rtl8712_cmd.o \
rtl871x_security.o \
rtl871x_eeprom.o \
rtl8712_efuse.o \
hal_init.o \
usb_halinit.o \
usb_ops.o \
usb_ops_linux.o \
rtl871x_io.o \
rtl8712_io.o \
rtl871x_ioctl_linux.o \
rtl871x_ioctl_rtl.o \
rtl871x_ioctl_set.o \
rtl8712_led.o \
rtl871x_mlme.o \
ieee80211.o \
rtl871x_mp_ioctl.o \
rtl871x_mp.o \
mlme_linux.o \
recv_linux.o \
xmit_linux.o \
usb_intf.o \
os_intfs.o \
rtl871x_pwrctrl.o \
rtl8712_recv.o \
rtl871x_recv.o \
rtl871x_sta_mgt.o \
rtl871x_xmit.o \
rtl8712_xmit.o
obj-$(CONFIG_R8712U) := r8712u.o
#ifndef __BASIC_TYPES_H__
#define __BASIC_TYPES_H__
#define SUCCESS 0
#define FAIL (-1)
#include <linux/types.h>
#define SIZE_T __kernel_size_t
#define sint signed int
#define FIELD_OFFSET(s, field) ((addr_t)&((s *)(0))->field)
/* Should we extend this to be host_addr_t and target_addr_t for case:
* host : x86_64
* target : mips64
*/
#define addr_t unsigned long
#define MEM_ALIGNMENT_OFFSET (sizeof(SIZE_T))
#define MEM_ALIGNMENT_PADDING (sizeof(SIZE_T) - 1)
#endif /*__BASIC_TYPES_H__*/
#ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H
#define _LINUX_BYTEORDER_BIG_ENDIAN_H
#ifndef __BIG_ENDIAN
#define __BIG_ENDIAN 4321
#endif
#ifndef __BIG_ENDIAN_BITFIELD
#define __BIG_ENDIAN_BITFIELD
#endif
#include "swab.h"
#define __constant_htonl(x) ((__u32)(x))
#define __constant_ntohl(x) ((__u32)(x))
#define __constant_htons(x) ((__u16)(x))
#define __constant_ntohs(x) ((__u16)(x))
#define __constant_cpu_to_le64(x) ___constant_swab64((x))
#define __constant_le64_to_cpu(x) ___constant_swab64((x))
#define __constant_cpu_to_le32(x) ___constant_swab32((x))
#define __constant_le32_to_cpu(x) ___constant_swab32((x))
#define __constant_cpu_to_le16(x) ___constant_swab16((x))
#define __constant_le16_to_cpu(x) ___constant_swab16((x))
#define __constant_cpu_to_be64(x) ((__u64)(x))
#define __constant_be64_to_cpu(x) ((__u64)(x))
#define __constant_cpu_to_be32(x) ((__u32)(x))
#define __constant_be32_to_cpu(x) ((__u32)(x))
#define __constant_cpu_to_be16(x) ((__u16)(x))
#define __constant_be16_to_cpu(x) ((__u16)(x))
#define __cpu_to_le64(x) __swab64((x))
#define __le64_to_cpu(x) __swab64((x))
#define __cpu_to_le32(x) __swab32((x))
#define __le32_to_cpu(x) __swab32((x))
#define __cpu_to_le16(x) __swab16((x))
#define __le16_to_cpu(x) __swab16((x))
#define __cpu_to_be64(x) ((__u64)(x))
#define __be64_to_cpu(x) ((__u64)(x))
#define __cpu_to_be32(x) ((__u32)(x))
#define __be32_to_cpu(x) ((__u32)(x))
#define __cpu_to_be16(x) ((__u16)(x))
#define __be16_to_cpu(x) ((__u16)(x))
#define __cpu_to_le64p(x) __swab64p((x))
#define __le64_to_cpup(x) __swab64p((x))
#define __cpu_to_le32p(x) __swab32p((x))
#define __le32_to_cpup(x) __swab32p((x))
#define __cpu_to_le16p(x) __swab16p((x))
#define __le16_to_cpup(x) __swab16p((x))
#define __cpu_to_be64p(x) (*(__u64 *)(x))
#define __be64_to_cpup(x) (*(__u64 *)(x))
#define __cpu_to_be32p(x) (*(__u32 *)(x))
#define __be32_to_cpup(x) (*(__u32 *)(x))
#define __cpu_to_be16p(x) (*(__u16 *)(x))
#define __be16_to_cpup(x) (*(__u16 *)(x))
#define __cpu_to_le64s(x) __swab64s((x))
#define __le64_to_cpus(x) __swab64s((x))
#define __cpu_to_le32s(x) __swab32s((x))
#define __le32_to_cpus(x) __swab32s((x))
#define __cpu_to_le16s(x) __swab16s((x))
#define __le16_to_cpus(x) __swab16s((x))
#define __cpu_to_be64s(x) do {} while (0)
#define __be64_to_cpus(x) do {} while (0)
#define __cpu_to_be32s(x) do {} while (0)
#define __be32_to_cpus(x) do {} while (0)
#define __cpu_to_be16s(x) do {} while (0)
#define __be16_to_cpus(x) do {} while (0)
#include "generic.h"
#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
/*---------------------------------------------------------------------
For type defines and data structure defines
-----------------------------------------------------------------------*/
#ifndef __DRV_TYPES_H__
#define __DRV_TYPES_H__
struct _adapter;
#include "osdep_service.h"
#include "wlan_bssdef.h"
#include "rtl8712_spec.h"
#include "rtl8712_hal.h"
enum _NIC_VERSION {
RTL8711_NIC,
RTL8712_NIC,
RTL8713_NIC,
RTL8716_NIC
};
struct _adapter;
struct qos_priv {
/* bit mask option: u-apsd, s-apsd, ts, block ack... */
unsigned int qos_option;
};
#include "rtl871x_ht.h"
#include "rtl871x_cmd.h"
#include "wlan_bssdef.h"
#include "rtl871x_xmit.h"
#include "rtl871x_recv.h"
#include "rtl871x_security.h"
#include "rtl871x_pwrctrl.h"
#include "rtl871x_io.h"
#include "rtl871x_eeprom.h"
#include "sta_info.h"
#include "rtl871x_mlme.h"
#include "rtl871x_mp.h"
#include "rtl871x_debug.h"
#include "rtl871x_rf.h"
#include "rtl871x_event.h"
#include "rtl871x_led.h"
#define SPEC_DEV_ID_NONE BIT(0)
#define SPEC_DEV_ID_DISABLE_HT BIT(1)
#define SPEC_DEV_ID_ENABLE_PS BIT(2)
struct specific_device_id {
u32 flags;
u16 idVendor;
u16 idProduct;
};
struct registry_priv {
u8 chip_version;
u8 rfintfs;
u8 lbkmode;
u8 hci;
u8 network_mode; /*infra, ad-hoc, auto*/
struct ndis_802_11_ssid ssid;
u8 channel;/* ad-hoc support requirement */
u8 wireless_mode;/* A, B, G, auto */
u8 vrtl_carrier_sense; /*Enable, Disable, Auto*/
u8 vcs_type;/*RTS/CTS, CTS-to-self*/
u16 rts_thresh;
u16 frag_thresh;
u8 preamble;/*long, short, auto*/
u8 scan_mode;/*active, passive*/
u8 adhoc_tx_pwr;
u8 soft_ap;
u8 smart_ps;
u8 power_mgnt;
u8 radio_enable;
u8 long_retry_lmt;
u8 short_retry_lmt;
u16 busy_thresh;
u8 ack_policy;
u8 mp_mode;
u8 software_encrypt;
u8 software_decrypt;
/* UAPSD */
u8 wmm_enable;
u8 uapsd_enable;
u8 uapsd_max_sp;
u8 uapsd_acbk_en;
u8 uapsd_acbe_en;
u8 uapsd_acvi_en;
u8 uapsd_acvo_en;
struct wlan_bssid_ex dev_network;
u8 ht_enable;
u8 cbw40_enable;
u8 ampdu_enable;/*for tx*/
u8 rf_config ;
u8 low_power ;
};
/* For registry parameters */
#define RGTRY_OFT(field) ((addr_t)FIELD_OFFSET(struct registry_priv, field))
#define RGTRY_SZ(field) sizeof(((struct registry_priv *)0)->field)
#define BSSID_OFT(field) ((addr_t)FIELD_OFFSET(struct ndis_wlan_bssid_ex, \
field))
#define BSSID_SZ(field) sizeof(((struct ndis_wlan_bssid_ex *)0)->field)
struct dvobj_priv {
struct _adapter *padapter;
u32 nr_endpoint;
u8 ishighspeed;
uint(*inirp_init)(struct _adapter *adapter);
uint(*inirp_deinit)(struct _adapter *adapter);
struct semaphore usb_suspend_sema;
struct usb_device *pusbdev;
};
struct _adapter {
struct dvobj_priv dvobjpriv;
struct mlme_priv mlmepriv;
struct cmd_priv cmdpriv;
struct evt_priv evtpriv;
struct io_queue *pio_queue;
struct xmit_priv xmitpriv;
struct recv_priv recvpriv;
struct sta_priv stapriv;
struct security_priv securitypriv;
struct registry_priv registrypriv;
struct wlan_acl_pool acl_list;
struct pwrctrl_priv pwrctrlpriv;
struct eeprom_priv eeprompriv;
struct hal_priv halpriv;
struct led_priv ledpriv;
struct mp_priv mppriv;
s32 bDriverStopped;
s32 bSurpriseRemoved;
u32 IsrContent;
u32 ImrContent;
u8 EepromAddressSize;
u8 hw_init_completed;
struct task_struct *cmdThread;
pid_t evtThread;
struct task_struct *xmitThread;
pid_t recvThread;
uint(*dvobj_init)(struct _adapter *adapter);
void (*dvobj_deinit)(struct _adapter *adapter);
struct net_device *pnetdev;
int bup;
struct net_device_stats stats;
struct iw_statistics iwstats;
int pid; /*process id from UI*/
};
static inline u8 *myid(struct eeprom_priv *peepriv)
{
return peepriv->mac_addr;
}
u8 r8712_usb_hal_bus_init(struct _adapter *adapter);
#endif /*__DRV_TYPES_H__*/
#ifndef __INC_ETHERNET_H
#define __INC_ETHERNET_H
#define ETHERNET_ADDRESS_LENGTH 6 /*!< Ethernet Address Length*/
#define ETHERNET_HEADER_SIZE 14 /*!< Ethernet Header Length*/
#define LLC_HEADER_SIZE 6 /*!< LLC Header Length*/
#define TYPE_LENGTH_FIELD_SIZE 2 /*!< Type/Length Size*/
#define MINIMUM_ETHERNET_PACKET_SIZE 60 /*!< Min Ethernet Packet Size*/
#define MAXIMUM_ETHERNET_PACKET_SIZE 1514 /*!< Max Ethernet Packet Size*/
/*!< Is Multicast Address? */
#define RT_ETH_IS_MULTICAST(_pAddr) ((((u8 *)(_pAddr))[0]&0x01) != 0)
/*!< Is Broadcast Address? */
#define RT_ETH_IS_BROADCAST(_pAddr) ( \
((u8 *)(_pAddr))[0] == 0xff && \
((u8 *)(_pAddr))[1] == 0xff && \
((u8 *)(_pAddr))[2] == 0xff && \
((u8 *)(_pAddr))[3] == 0xff && \
((u8 *)(_pAddr))[4] == 0xff && \
((u8 *)(_pAddr))[5] == 0xff)
#endif /* #ifndef __INC_ETHERNET_H */
This diff is collapsed.
#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 */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Global definitions for the Ethernet IEEE 802.3 interface.
*
* Version: @(#)if_ether.h 1.0.1a 02/08/94
*
* Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Donald Becker, <becker@super.org>
* Alan Cox, <alan@redhat.com>
* Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#ifndef _LINUX_IF_ETHER_H
#define _LINUX_IF_ETHER_H
/*
* IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble
* and FCS/CRC (frame check sequence).
*/
#define ETH_ALEN 6 /* Octets in one ethernet addr */
#define ETH_HLEN 14 /* Total octets in header. */
#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */
#define ETH_DATA_LEN 1500 /* Max. octets in payload */
#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */
/*
* These are the defined Ethernet Protocol ID's.
*/
#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */
#define ETH_P_PUP 0x0200 /* Xerox PUP packet */
#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_P_X25 0x0805 /* CCITT X.25 */
#define ETH_P_ARP 0x0806 /* Address Resolution packet */
#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet
* [ NOT AN OFFICIAL ID ] */
#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr
* Trans packet */
#define ETH_P_DEC 0x6000 /* DEC Assigned proto */
#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */
#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */
#define ETH_P_LAT 0x6004 /* DEC LAT */
#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */
#define ETH_P_CUST 0x6006 /* DEC Customer use */
#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */
#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
#define ETH_P_ATALK 0x809B /* Appletalk DDP */
#define ETH_P_AARP 0x80F3 /* Appletalk AARP */
#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
#define ETH_P_IPX 0x8137 /* IPX over DIX */
#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */
#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */
#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */
#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */
#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport
* over Ethernet
*/
/*
* Non DIX types. Won't clash for 1500 types.
*/
#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
#define ETH_P_802_2 0x0004 /* 802.2 frames */
#define ETH_P_SNAP 0x0005 /* Internal only */
#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
#define ETH_P_TR_802_2 0x0011i /* 802.2 frames */
#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
#define ETH_P_CONTROL 0x0016 /* Card specific control frames */
#define ETH_P_IRDA 0x0017 /* Linux-IrDA */
#define ETH_P_ECONET 0x0018 /* Acorn Econet */
/*
* This is an Ethernet frame header.
*/
struct ethhdr {
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
unsigned char h_source[ETH_ALEN]; /* source ether addr */
unsigned short h_proto; /* packet type ID field */
};
struct _vlan {
unsigned short h_vlan_TCI; /* Encapsulates priority and VLAN ID*/
unsigned short h_vlan_encapsulated_proto;
};
#define get_vlan_id(pvlan) ((ntohs((unsigned short)pvlan->h_vlan_TCI)) & 0xfff)
#define get_vlan_priority(pvlan) ((ntohs((unsigned short)\
pvlan->h_vlan_TCI)) >> 13)
#define get_vlan_encap_proto(pvlan) (ntohs((unsigned short)\
pvlan->h_vlan_encapsulated_proto))
#endif /* _LINUX_IF_ETHER_H */
/*
* INET An implementation of the TCP/IP protocol suite for the LINUX
* operating system. INET is implemented using the BSD Socket
* interface as the means of communication with the user level.
*
* Definitions for the IP protocol.
*
* Version: @(#)ip.h 1.0.2 04/28/93
*
* Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#ifndef _LINUX_IP_H
#define _LINUX_IP_H
#include "rtl871x_byteorder.h"
/* SOL_IP socket options */
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK)
#define IPTOS_LOWDELAY 0x10
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_RELIABILITY 0x04
#define IPTOS_MINCOST 0x02
#define IPTOS_PREC_MASK 0xE0
#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK)
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
#define IPTOS_PREC_CRITIC_ECP 0xa0
#define IPTOS_PREC_FLASHOVERRIDE 0x80
#define IPTOS_PREC_FLASH 0x60
#define IPTOS_PREC_IMMEDIATE 0x40
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
/* IP options */
#define IPOPT_COPY 0x80
#define IPOPT_CLASS_MASK 0x60
#define IPOPT_NUMBER_MASK 0x1f
#define IPOPT_COPIED(o) ((o)&IPOPT_COPY)
#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK)
#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK)
#define IPOPT_CONTROL 0x00
#define IPOPT_RESERVED1 0x20
#define IPOPT_MEASUREMENT 0x40
#define IPOPT_RESERVED2 0x60
#define IPOPT_END (0 | IPOPT_CONTROL)
#define IPOPT_NOOP (1 | IPOPT_CONTROL)
#define IPOPT_SEC (2 | IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_LSRR (3 | IPOPT_CONTROL|IPOPT_COPY)
#define IPOPT_TIMESTAMP (4 | IPOPT_MEASUREMENT)
#define IPOPT_RR (7 | IPOPT_CONTROL)
#define IPOPT_SID (8 | IPOPT_CONTROL | IPOPT_COPY)
#define IPOPT_SSRR (9 | IPOPT_CONTROL | IPOPT_COPY)
#define IPOPT_RA (20 | IPOPT_CONTROL | IPOPT_COPY)
#define IPVERSION 4
#define MAXTTL 255
#define IPDEFTTL 64
/* struct timestamp, struct route and MAX_ROUTES are removed.
*
* REASONS: it is clear that nobody used them because:
* - MAX_ROUTES value was wrong.
* - "struct route" was wrong.
* - "struct timestamp" had fatally misaligned bitfields and was completely
* unusable.
*/
#define IPOPT_OPTVAL 0
#define IPOPT_OLEN 1
#define IPOPT_OFFSET 2
#define IPOPT_MINOFF 4
#define MAX_IPOPTLEN 40
#define IPOPT_NOP IPOPT_NOOP
#define IPOPT_EOL IPOPT_END
#define IPOPT_TS IPOPT_TIMESTAMP
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
struct ip_options {
__u32 faddr; /* Saved first hop address */
unsigned char optlen;
unsigned char srr;
unsigned char rr;
unsigned char ts;
unsigned char is_setbyuser:1, /* Set by setsockopt? */
is_data:1, /* Options in __data, rather than skb */
is_strictroute:1, /* Strict source route */
srr_is_hit:1, /* Packet destination addr was our one */
is_changed:1, /* IP checksum more not valid */
rr_needaddr:1, /* Need to record addr of outgoing dev */
ts_needtime:1, /* Need to record timestamp */
ts_needaddr:1; /* Need to record addr of outgoing dev */
unsigned char router_alert;
unsigned char __pad1;
unsigned char __pad2;
unsigned char __data[0];
};
#define optlength(opt) (sizeof(struct ip_options) + opt->optlen)
struct iphdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 ihl:4,
version:4;
#elif defined(__BIG_ENDIAN_BITFIELD)
__u8 version:4,
ihl:4;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__u8 tos;
__u16 tot_len;
__u16 id;
__u16 frag_off;
__u8 ttl;
__u8 protocol;
__u16 check;
__u32 saddr;
__u32 daddr;
/*The options start here. */
};
#endif /* _LINUX_IP_H */
#ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H
#define _LINUX_BYTEORDER_LITTLE_ENDIAN_H
#ifndef __LITTLE_ENDIAN
#define __LITTLE_ENDIAN 1234
#endif
#ifndef __LITTLE_ENDIAN_BITFIELD
#define __LITTLE_ENDIAN_BITFIELD
#endif
#include "swab.h"
#define __constant_htonl(x) ___constant_swab32((x))
#define __constant_ntohl(x) ___constant_swab32((x))
#define __constant_htons(x) ___constant_swab16((x))
#define __constant_ntohs(x) ___constant_swab16((x))
#define __constant_cpu_to_le64(x) ((__u64)(x))
#define __constant_le64_to_cpu(x) ((__u64)(x))
#define __constant_cpu_to_le32(x) ((__u32)(x))
#define __constant_le32_to_cpu(x) ((__u32)(x))
#define __constant_cpu_to_le16(x) ((__u16)(x))
#define __constant_le16_to_cpu(x) ((__u16)(x))
#define __constant_cpu_to_be64(x) ___constant_swab64((x))
#define __constant_be64_to_cpu(x) ___constant_swab64((x))
#define __constant_cpu_to_be32(x) ___constant_swab32((x))
#define __constant_be32_to_cpu(x) ___constant_swab32((x))
#define __constant_cpu_to_be16(x) ___constant_swab16((x))
#define __constant_be16_to_cpu(x) ___constant_swab16((x))
#define __cpu_to_le64(x) ((__u64)(x))
#define __le64_to_cpu(x) ((__u64)(x))
#define __cpu_to_le32(x) ((__u32)(x))
#define __le32_to_cpu(x) ((__u32)(x))
#define __cpu_to_le16(x) ((__u16)(x))
#define __le16_to_cpu(x) ((__u16)(x))
#define __cpu_to_be64(x) __swab64((x))
#define __be64_to_cpu(x) __swab64((x))
#define __cpu_to_be32(x) __swab32((x))
#define __be32_to_cpu(x) __swab32((x))
#define __cpu_to_be16(x) __swab16((x))
#define __be16_to_cpu(x) __swab16((x))
#define __cpu_to_le64p(x) (*(__u64 *)(x))
#define __le64_to_cpup(x) (*(__u64 *)(x))
#define __cpu_to_le32p(x) (*(__u32 *)(x))
#define __le32_to_cpup(x) (*(__u32 *)(x))
#define __cpu_to_le16p(x) (*(__u16 *)(x))
#define __le16_to_cpup(x) (*(__u16 *)(x))
#define __cpu_to_be64p(x) __swab64p((x))
#define __be64_to_cpup(x) __swab64p((x))
#define __cpu_to_be32p(x) __swab32p((x))
#define __be32_to_cpup(x) __swab32p((x))
#define __cpu_to_be16p(x) __swab16p((x))
#define __be16_to_cpup(x) __swab16p((x))
#define __cpu_to_le64s(x) do {} while (0)
#define __le64_to_cpus(x) do {} while (0)
#define __cpu_to_le32s(x) do {} while (0)
#define __le32_to_cpus(x) do {} while (0)
#define __cpu_to_le16s(x) do {} while (0)
#define __le16_to_cpus(x) do {} while (0)
#define __cpu_to_be64s(x) __swab64s((x))
#define __be64_to_cpus(x) __swab64s((x))
#define __cpu_to_be32s(x) __swab32s((x))
#define __be32_to_cpus(x) __swab32s((x))
#define __cpu_to_be16s(x) __swab16s((x))
#define __be16_to_cpus(x) __swab16s((x))
#include "generic.h"
#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
/******************************************************************************
* mlme_linux.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>.
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _MLME_OSDEP_C_
#include "osdep_service.h"
#include "drv_types.h"
#include "mlme_osdep.h"
static void sitesurvey_ctrl_handler(void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
_r8712_sitesurvey_ctrl_handler(adapter);
_set_timer(&adapter->mlmepriv.sitesurveyctrl.sitesurvey_ctrl_timer,
3000);
}
static void join_timeout_handler (void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
_r8712_join_timeout_handler(adapter);
}
static void _scan_timeout_handler (void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
r8712_scan_timeout_handler(adapter);
}
static void dhcp_timeout_handler (void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
_r8712_dhcp_timeout_handler(adapter);
}
static void wdg_timeout_handler (void *FunctionContext)
{
struct _adapter *adapter = (struct _adapter *)FunctionContext;
_r8712_wdg_timeout_handler(adapter);
_set_timer(&adapter->mlmepriv.wdg_timer, 2000);
}
void r8712_init_mlme_timer(struct _adapter *padapter)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
_init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev,
join_timeout_handler, (pmlmepriv->nic_hdl));
_init_timer(&(pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer),
padapter->pnetdev, sitesurvey_ctrl_handler,
(u8 *)(pmlmepriv->nic_hdl));
_init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev,
_scan_timeout_handler, (pmlmepriv->nic_hdl));
_init_timer(&(pmlmepriv->dhcp_timer), padapter->pnetdev,
dhcp_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
_init_timer(&(pmlmepriv->wdg_timer), padapter->pnetdev,
wdg_timeout_handler, (u8 *)(pmlmepriv->nic_hdl));
}
void r8712_os_indicate_connect(struct _adapter *adapter)
{
r8712_indicate_wx_assoc_event(adapter);
netif_carrier_on(adapter->pnetdev);
}
static struct RT_PMKID_LIST backupPMKIDList[NUM_PMKID_CACHE];
void r8712_os_indicate_disconnect(struct _adapter *adapter)
{
u8 backupPMKIDIndex = 0;
u8 backupTKIPCountermeasure = 0x00;
r8712_indicate_wx_disassoc_event(adapter);
netif_carrier_off(adapter->pnetdev);
if (adapter->securitypriv.AuthAlgrthm == 2) { /*/802.1x*/
/* We have to backup the PMK information for WiFi PMK Caching
* test item. Backup the btkip_countermeasure information.
* When the countermeasure is trigger, the driver have to
* disconnect with AP for 60 seconds.
*/
memset(&backupPMKIDList[0], 0x00, sizeof(
struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
memcpy(&backupPMKIDList[0], &adapter->securitypriv.
PMKIDList[0], sizeof(struct RT_PMKID_LIST) *
NUM_PMKID_CACHE);
backupPMKIDIndex = adapter->securitypriv.PMKIDIndex;
backupTKIPCountermeasure = adapter->securitypriv.
btkip_countermeasure;
memset((unsigned char *)&adapter->securitypriv, 0,
sizeof(struct security_priv));
_init_timer(&(adapter->securitypriv.tkip_timer),
adapter->pnetdev, r8712_use_tkipkey_handler,
adapter);
/* Restore the PMK information to securitypriv structure
* for the following connection. */
memcpy(&adapter->securitypriv.PMKIDList[0],
&backupPMKIDList[0],
sizeof(struct RT_PMKID_LIST) * NUM_PMKID_CACHE);
adapter->securitypriv.PMKIDIndex = backupPMKIDIndex;
adapter->securitypriv.btkip_countermeasure =
backupTKIPCountermeasure;
} else { /*reset values in securitypriv*/
struct security_priv *psec_priv = &adapter->securitypriv;
psec_priv->AuthAlgrthm = 0; /*open system*/
psec_priv->PrivacyAlgrthm = _NO_PRIVACY_;
psec_priv->PrivacyKeyIndex = 0;
psec_priv->XGrpPrivacy = _NO_PRIVACY_;
psec_priv->XGrpKeyid = 1;
psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
psec_priv->wps_phase = false;
}
}
void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie)
{
uint len;
u8 *buff, *p, i;
union iwreq_data wrqu;
buff = NULL;
if (authmode == _WPA_IE_ID_) {
buff = _malloc(IW_CUSTOM_MAX);
if (buff == NULL)
return;
memset(buff, 0, IW_CUSTOM_MAX);
p = buff;
p += sprintf(p, "ASSOCINFO(ReqIEs=");
len = sec_ie[1] + 2;
len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
for (i = 0; i < len; i++)
p += sprintf(p, "%02x", sec_ie[i]);
p += sprintf(p, ")");
memset(&wrqu, 0, sizeof(wrqu));
wrqu.data.length = p-buff;
wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
wrqu.data.length : IW_CUSTOM_MAX;
wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
kfree(buff);
}
}
#ifndef __MLME_OSDEP_H_
#define __MLME_OSDEP_H_
#include "osdep_service.h"
#include "drv_types.h"
void r8712_init_mlme_timer(struct _adapter *padapter);
void r8712_os_indicate_disconnect(struct _adapter *adapter);
void r8712_os_indicate_connect(struct _adapter *adapter);
void r8712_report_sec_ie(struct _adapter *adapter, u8 authmode, u8 *sec_ie);
int r8712_recv_indicatepkts_in_order(struct _adapter *adapter,
struct recv_reorder_ctrl *precvreorder_ctrl,
int bforced);
void r8712_indicate_wx_assoc_event(struct _adapter *padapter);
void r8712_indicate_wx_disassoc_event(struct _adapter *padapter);
#endif /*_MLME_OSDEP_H_*/
This diff is collapsed.
This diff is collapsed.
#ifndef __OSDEP_INTF_H_
#define __OSDEP_INTF_H_
#include "osdep_service.h"
#include "drv_types.h"
#define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0 : 1)) << 2)
struct intf_priv {
u8 *intf_dev;
/* when in USB, IO is through interrupt in/out endpoints */
struct usb_device *udev;
struct urb *piorw_urb;
struct semaphore io_retevt;
};
int r871x_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
#endif /*_OSDEP_INTF_H_*/
#ifndef __OSDEP_SERVICE_H_
#define __OSDEP_SERVICE_H_
#define _SUCCESS 1
#define _FAIL 0
#include "basic_types.h"
#include <linux/version.h>
#include <linux/spinlock.h>
#include <linux/semaphore.h>
#include <linux/sem.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <net/iw_handler.h>
#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/kref.h>
#include <linux/smp_lock.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/usb.h>
#include <linux/usb/ch9.h>
#include <linux/io.h>
#include <linux/circ_buf.h>
#include <linux/uaccess.h>
#include <asm/byteorder.h>
#include <asm/atomic.h>
#include <linux/wireless.h>
#include <linux/rtnetlink.h>
#include "ethernet.h"
#include <linux/if_arp.h>
#include <linux/firmware.h>
#define _usb_alloc_urb(x, y) usb_alloc_urb(x, y)
#define _usb_submit_urb(x, y) usb_submit_urb(x, y)
struct __queue {
struct list_head queue;
spinlock_t lock;
};
#define _pkt struct sk_buff
#define _buffer unsigned char
#define thread_exit() complete_and_exit(NULL, 0)
#define _workitem struct work_struct
#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000)
#define _init_queue(pqueue) \
do { \
_init_listhead(&((pqueue)->queue)); \
spin_lock_init(&((pqueue)->lock)); \
} while (0)
static inline void *_netdev_priv(struct net_device *dev)
{
return netdev_priv(dev);
}
static inline void os_free_netdev(struct net_device *dev)
{
free_netdev(dev);
}
static inline struct list_head *get_next(struct list_head *list)
{
return list->next;
}
static inline struct list_head *get_list_head(struct __queue *queue)
{
return &(queue->queue);
}
#define LIST_CONTAINOR(ptr, type, member) \
((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
static inline void _enter_hwio_critical(struct semaphore *prwlock,
unsigned long *pirqL)
{
down(prwlock);
}
static inline void _exit_hwio_critical(struct semaphore *prwlock,
unsigned long *pirqL)
{
up(prwlock);
}
static inline void list_delete(struct list_head *plist)
{
list_del_init(plist);
}
static inline void _init_timer(struct timer_list *ptimer,
struct net_device *padapter,
void *pfunc, void *cntx)
{
ptimer->function = pfunc;
ptimer->data = (addr_t)cntx;
init_timer(ptimer);
}
static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
{
mod_timer(ptimer, (jiffies+(delay_time*HZ/1000)));
}
static inline void _cancel_timer(struct timer_list *ptimer, u8 *bcancelled)
{
del_timer(ptimer);
*bcancelled = true; /*true ==1; false==0*/
}
static inline void _init_workitem(_workitem *pwork, void *pfunc, void *cntx)
{
INIT_WORK(pwork, pfunc);
}
static inline void _set_workitem(_workitem *pwork)
{
schedule_work(pwork);
}
#include "rtl871x_byteorder.h"
#ifndef BIT
#define BIT(x) (1 << (x))
#endif
/*
For the following list_xxx operations,
caller must guarantee the atomic context.
Otherwise, there will be racing condition.
*/
static inline u32 is_list_empty(struct list_head *phead)
{
if (list_empty(phead))
return true;
else
return false;
}
static inline void list_insert_tail(struct list_head *plist, struct list_head *phead)
{
list_add_tail(plist, phead);
}
static inline u32 _down_sema(struct semaphore *sema)
{
if (down_interruptible(sema))
return _FAIL;
else
return _SUCCESS;
}
static inline void _rtl_rwlock_init(struct semaphore *prwlock)
{
init_MUTEX(prwlock);
}
static inline void _init_listhead(struct list_head *list)
{
INIT_LIST_HEAD(list);
}
static inline u32 _queue_empty(struct __queue *pqueue)
{
return is_list_empty(&(pqueue->queue));
}
static inline u32 end_of_queue_search(struct list_head *head, struct list_head *plist)
{
if (head == plist)
return true;
else
return false;
}
static inline void sleep_schedulable(int ms)
{
u32 delta;
delta = (ms * HZ) / 1000;/*(ms)*/
if (delta == 0)
delta = 1;/* 1 ms */
set_current_state(TASK_INTERRUPTIBLE);
if (schedule_timeout(delta) != 0)
return ;
}
static inline u8 *_malloc(u32 sz)
{
u8 *pbuf;
pbuf = kmalloc(sz, GFP_ATOMIC);
return pbuf;
}
static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer)
{
return del_timer(ptimer);
}
static inline void thread_enter(void *context)
{
daemonize("%s", "RTKTHREAD");
allow_signal(SIGTERM);
}
static inline void flush_signals_thread(void)
{
if (signal_pending(current))
flush_signals(current);
}
static inline u32 _RND8(u32 sz)
{
u32 val;
val = ((sz >> 3) + ((sz & 7) ? 1 : 0)) << 3;
return val;
}
static inline u32 _RND128(u32 sz)
{
u32 val;
val = ((sz >> 7) + ((sz & 127) ? 1 : 0)) << 7;
return val;
}
static inline u32 _RND256(u32 sz)
{
u32 val;
val = ((sz >> 8) + ((sz & 255) ? 1 : 0)) << 8;
return val;
}
static inline u32 _RND512(u32 sz)
{
u32 val;
val = ((sz >> 9) + ((sz & 511) ? 1 : 0)) << 9;
return val;
}
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
#define STRUCT_PACKED __attribute__ ((packed))
#endif
/******************************************************************************
* recv_linux.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>.
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _RECV_OSDEP_C_
#include "osdep_service.h"
#include "drv_types.h"
#include "wifi.h"
#include "recv_osdep.h"
#include "osdep_intf.h"
#include "usb_ops.h"
/*init os related resource in struct recv_priv*/
/*alloc os related resource in union recv_frame*/
int r8712_os_recv_resource_alloc(struct _adapter *padapter,
union recv_frame *precvframe)
{
precvframe->u.hdr.pkt_newalloc = precvframe->u.hdr.pkt = NULL;
return _SUCCESS;
}
/*alloc os related resource in struct recv_buf*/
int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
struct recv_buf *precvbuf)
{
int res = _SUCCESS;
precvbuf->irp_pending = false;
precvbuf->purb = _usb_alloc_urb(0, GFP_KERNEL);
if (precvbuf->purb == NULL)
res = _FAIL;
precvbuf->pskb = NULL;
precvbuf->reuse = false;
precvbuf->pallocated_buf = NULL;
precvbuf->pbuf = NULL;
precvbuf->pdata = NULL;
precvbuf->phead = NULL;
precvbuf->ptail = NULL;
precvbuf->pend = NULL;
precvbuf->transfer_len = 0;
precvbuf->len = 0;
return res;
}
/*free os related resource in struct recv_buf*/
int r8712_os_recvbuf_resource_free(struct _adapter *padapter,
struct recv_buf *precvbuf)
{
if (precvbuf->pskb)
dev_kfree_skb_any(precvbuf->pskb);
if (precvbuf->purb) {
usb_kill_urb(precvbuf->purb);
usb_free_urb(precvbuf->purb);
}
return _SUCCESS;
}
void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup)
{
union iwreq_data wrqu;
struct iw_michaelmicfailure ev;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
memset(&ev, 0x00, sizeof(ev));
if (bgroup)
ev.flags |= IW_MICFAILURE_GROUP;
else
ev.flags |= IW_MICFAILURE_PAIRWISE;
ev.src_addr.sa_family = ARPHRD_ETHER;
memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN);
memset(&wrqu, 0x00, sizeof(wrqu));
wrqu.data.length = sizeof(ev);
wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu,
(char *)&ev);
}
void r8712_recv_indicatepkt(struct _adapter *padapter,
union recv_frame *precv_frame)
{
struct recv_priv *precvpriv;
struct __queue *pfree_recv_queue;
_pkt *skb;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
precvpriv = &(padapter->recvpriv);
pfree_recv_queue = &(precvpriv->free_recv_queue);
skb = precv_frame->u.hdr.pkt;
if (skb == NULL)
goto _recv_indicatepkt_drop;
skb->data = precv_frame->u.hdr.rx_data;
#ifdef NET_SKBUFF_DATA_USES_OFFSET
skb->tail = (sk_buff_data_t)(precv_frame->u.hdr.rx_tail -
precv_frame->u.hdr.rx_head);
#else
skb->tail = (sk_buff_data_t)precv_frame->u.hdr.rx_tail;
#endif
skb->len = precv_frame->u.hdr.len;
if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
skb->ip_summed = CHECKSUM_UNNECESSARY;
else
skb->ip_summed = CHECKSUM_NONE;
skb->dev = padapter->pnetdev;
skb->protocol = eth_type_trans(skb, padapter->pnetdev);
netif_rx(skb);
precv_frame->u.hdr.pkt = NULL; /* pointers to NULL before
* r8712_free_recvframe() */
r8712_free_recvframe(precv_frame, pfree_recv_queue);
return;
_recv_indicatepkt_drop:
/*enqueue back to free_recv_queue*/
if (precv_frame)
r8712_free_recvframe(precv_frame, pfree_recv_queue);
precvpriv->rx_drop++;
}
void r8712_os_read_port(struct _adapter *padapter, struct recv_buf *precvbuf)
{
struct recv_priv *precvpriv = &padapter->recvpriv;
precvbuf->ref_cnt--;
/*free skb in recv_buf*/
dev_kfree_skb_any(precvbuf->pskb);
precvbuf->pskb = NULL;
precvbuf->reuse = false;
if (precvbuf->irp_pending == false)
r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
(unsigned char *)precvbuf);
}
static void _r8712_reordering_ctrl_timeout_handler (void *FunctionContext)
{
struct recv_reorder_ctrl *preorder_ctrl =
(struct recv_reorder_ctrl *)FunctionContext;
r8712_reordering_ctrl_timeout_handler(preorder_ctrl);
}
void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
{
struct _adapter *padapter = preorder_ctrl->padapter;
_init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev,
_r8712_reordering_ctrl_timeout_handler, preorder_ctrl);
}
#ifndef __RECV_OSDEP_H_
#define __RECV_OSDEP_H_
#include "osdep_service.h"
#include "drv_types.h"
#include <linux/skbuff.h>
sint _r8712_init_recv_priv(struct recv_priv *precvpriv,
struct _adapter *padapter);
void _r8712_free_recv_priv(struct recv_priv *precvpriv);
s32 r8712_recv_entry(union recv_frame *precv_frame);
void r8712_recv_indicatepkt(struct _adapter *adapter,
union recv_frame *precv_frame);
void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup);
int r8712_init_recv_priv(struct recv_priv *precvpriv, struct _adapter *padapter);
void r8712_free_recv_priv(struct recv_priv *precvpriv);
int r8712_os_recv_resource_alloc(struct _adapter *padapter,
union recv_frame *precvframe);
int r8712_os_recvbuf_resource_alloc(struct _adapter *padapter,
struct recv_buf *precvbuf);
int r8712_os_recvbuf_resource_free(struct _adapter *padapter,
struct recv_buf *precvbuf);
void r8712_os_read_port(struct _adapter *padapter, struct recv_buf *precvbuf);
void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl);
#endif
#ifndef __RTL8712_BITDEF_H__
#define __RTL8712_BITDEF_H__
#include "rtl8712_cmdctrl_bitdef.h"
#include "rtl8712_syscfg_bitdef.h"
#include "rtl8712_macsetting_bitdef.h"
#include "rtl8712_timectrl_bitdef.h"
#include "rtl8712_fifoctrl_bitdef.h"
#include "rtl8712_ratectrl_bitdef.h"
#include "rtl8712_edcasetting_bitdef.h"
#include "rtl8712_wmac_bitdef.h"
#include "rtl8712_security_bitdef.h"
#include "rtl8712_powersave_bitdef.h"
#include "rtl8712_gp_bitdef.h"
#include "rtl8712_interrupt_bitdef.h"
#include "rtl8712_debugctrl_bitdef.h"
#endif /* __RTL8712_BITDEF_H__ */
This diff is collapsed.
#ifndef __RTL8712_CMD_H_
#define __RTL8712_CMD_H_
u8 r8712_fw_cmd(struct _adapter *pAdapter, u32 cmd);
void r8712_fw_cmd_data(struct _adapter *pAdapter, u32 *value, u8 flag);
enum rtl8712_h2c_cmd {
GEN_CMD_CODE(_Read_MACREG), /*0*/
GEN_CMD_CODE(_Write_MACREG),
GEN_CMD_CODE(_Read_BBREG),
GEN_CMD_CODE(_Write_BBREG),
GEN_CMD_CODE(_Read_RFREG),
GEN_CMD_CODE(_Write_RFREG), /*5*/
GEN_CMD_CODE(_Read_EEPROM),
GEN_CMD_CODE(_Write_EEPROM),
GEN_CMD_CODE(_Read_EFUSE),
GEN_CMD_CODE(_Write_EFUSE),
GEN_CMD_CODE(_Read_CAM), /*10*/
GEN_CMD_CODE(_Write_CAM),
GEN_CMD_CODE(_setBCNITV),
GEN_CMD_CODE(_setMBIDCFG),
GEN_CMD_CODE(_JoinBss), /*14*/
GEN_CMD_CODE(_DisConnect), /*15*/
GEN_CMD_CODE(_CreateBss),
GEN_CMD_CODE(_SetOpMode),
GEN_CMD_CODE(_SiteSurvey), /*18*/
GEN_CMD_CODE(_SetAuth),
GEN_CMD_CODE(_SetKey), /*20*/
GEN_CMD_CODE(_SetStaKey),
GEN_CMD_CODE(_SetAssocSta),
GEN_CMD_CODE(_DelAssocSta),
GEN_CMD_CODE(_SetStaPwrState),
GEN_CMD_CODE(_SetBasicRate), /*25*/
GEN_CMD_CODE(_GetBasicRate),
GEN_CMD_CODE(_SetDataRate),
GEN_CMD_CODE(_GetDataRate),
GEN_CMD_CODE(_SetPhyInfo),
GEN_CMD_CODE(_GetPhyInfo), /*30*/
GEN_CMD_CODE(_SetPhy),
GEN_CMD_CODE(_GetPhy),
GEN_CMD_CODE(_readRssi),
GEN_CMD_CODE(_readGain),
GEN_CMD_CODE(_SetAtim), /*35*/
GEN_CMD_CODE(_SetPwrMode),
GEN_CMD_CODE(_JoinbssRpt),
GEN_CMD_CODE(_SetRaTable),
GEN_CMD_CODE(_GetRaTable),
GEN_CMD_CODE(_GetCCXReport), /*40*/
GEN_CMD_CODE(_GetDTMReport),
GEN_CMD_CODE(_GetTXRateStatistics),
GEN_CMD_CODE(_SetUsbSuspend),
GEN_CMD_CODE(_SetH2cLbk),
GEN_CMD_CODE(_AddBAReq), /*45*/
GEN_CMD_CODE(_SetChannel), /*46*/
/* MP_OFFLOAD Start (47~54)*/
GEN_CMD_CODE(_SetTxPower),
GEN_CMD_CODE(_SwitchAntenna),
GEN_CMD_CODE(_SetCrystalCap),
GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/
GEN_CMD_CODE(_SetSingleToneTx),
GEN_CMD_CODE(_SetCarrierSuppressionTx),
GEN_CMD_CODE(_SetContinuousTx),
GEN_CMD_CODE(_SwitchBandwidth), /*54*/
/* MP_OFFLOAD End*/
GEN_CMD_CODE(_TX_Beacon), /*55*/
GEN_CMD_CODE(_SetPowerTracking),
GEN_CMD_CODE(_AMSDU_TO_AMPDU), /*57*/
GEN_CMD_CODE(_SetMacAddress), /*58*/
MAX_H2CCMD
};
#define _GetBBReg_CMD_ _Read_BBREG_CMD_
#define _SetBBReg_CMD_ _Write_BBREG_CMD_
#define _GetRFReg_CMD_ _Read_RFREG_CMD_
#define _SetRFReg_CMD_ _Write_RFREG_CMD_
#define _DRV_INT_CMD_ (MAX_H2CCMD+1)
#define _SetRFIntFs_CMD_ (MAX_H2CCMD+2)
#ifdef _RTL8712_CMD_C_
static struct _cmd_callback cmd_callback[] = {
{GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/
{GEN_CMD_CODE(_Write_MACREG), NULL},
{GEN_CMD_CODE(_Read_BBREG), &r8712_getbbrfreg_cmdrsp_callback},
{GEN_CMD_CODE(_Write_BBREG), NULL},
{GEN_CMD_CODE(_Read_RFREG), &r8712_getbbrfreg_cmdrsp_callback},
{GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/
{GEN_CMD_CODE(_Read_EEPROM), NULL},
{GEN_CMD_CODE(_Write_EEPROM), NULL},
{GEN_CMD_CODE(_Read_EFUSE), NULL},
{GEN_CMD_CODE(_Write_EFUSE), NULL},
{GEN_CMD_CODE(_Read_CAM), NULL}, /*10*/
{GEN_CMD_CODE(_Write_CAM), NULL},
{GEN_CMD_CODE(_setBCNITV), NULL},
{GEN_CMD_CODE(_setMBIDCFG), NULL},
{GEN_CMD_CODE(_JoinBss), &r8712_joinbss_cmd_callback}, /*14*/
{GEN_CMD_CODE(_DisConnect), &r8712_disassoc_cmd_callback}, /*15*/
{GEN_CMD_CODE(_CreateBss), &r8712_createbss_cmd_callback},
{GEN_CMD_CODE(_SetOpMode), NULL},
{GEN_CMD_CODE(_SiteSurvey), &r8712_survey_cmd_callback}, /*18*/
{GEN_CMD_CODE(_SetAuth), NULL},
{GEN_CMD_CODE(_SetKey), NULL}, /*20*/
{GEN_CMD_CODE(_SetStaKey), &r8712_setstaKey_cmdrsp_callback},
{GEN_CMD_CODE(_SetAssocSta), &r8712_setassocsta_cmdrsp_callback},
{GEN_CMD_CODE(_DelAssocSta), NULL},
{GEN_CMD_CODE(_SetStaPwrState), NULL},
{GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/
{GEN_CMD_CODE(_GetBasicRate), NULL},
{GEN_CMD_CODE(_SetDataRate), NULL},
{GEN_CMD_CODE(_GetDataRate), NULL},
{GEN_CMD_CODE(_SetPhyInfo), NULL},
{GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/
{GEN_CMD_CODE(_SetPhy), NULL},
{GEN_CMD_CODE(_GetPhy), NULL},
{GEN_CMD_CODE(_readRssi), NULL},
{GEN_CMD_CODE(_readGain), NULL},
{GEN_CMD_CODE(_SetAtim), NULL}, /*35*/
{GEN_CMD_CODE(_SetPwrMode), NULL},
{GEN_CMD_CODE(_JoinbssRpt), NULL},
{GEN_CMD_CODE(_SetRaTable), NULL},
{GEN_CMD_CODE(_GetRaTable), NULL},
{GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/
{GEN_CMD_CODE(_GetDTMReport), NULL},
{GEN_CMD_CODE(_GetTXRateStatistics), NULL},
{GEN_CMD_CODE(_SetUsbSuspend), NULL},
{GEN_CMD_CODE(_SetH2cLbk), NULL},
{GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/
{GEN_CMD_CODE(_SetChannel), NULL}, /*46*/
/* MP_OFFLOAD Start (47~54)*/
{GEN_CMD_CODE(_SetTxPower), NULL},
{GEN_CMD_CODE(_SwitchAntenna), NULL},
{GEN_CMD_CODE(_SetCrystalCap), NULL},
{GEN_CMD_CODE(_SetSingleCarrierTx), NULL}, /*50*/
{GEN_CMD_CODE(_SetSingleToneTx), NULL},
{GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL},
{GEN_CMD_CODE(_SetContinuousTx), NULL},
{GEN_CMD_CODE(_SwitchBandwidth), NULL}, /*54*/
/* MP_OFFLOAD End*/
{GEN_CMD_CODE(_TX_Beacon), NULL}, /*55*/
{GEN_CMD_CODE(_SetPowerTracking), NULL},
{GEN_CMD_CODE(_AMSDU_TO_AMPDU), NULL}, /*57*/
{GEN_CMD_CODE(_SetMacAddress), NULL}, /*58*/
};
#endif
#endif
#ifndef __RTL8712_CMDCTRL_BITDEF_H__
#define __RTL8712_CMDCTRL_BITDEF_H__
/*
* 2. Command Control Registers (Offset: 0x0040 - 0x004F)*/
/*--------------------------------------------------------------------------*/
/* 8192S (CMD) command register bits (Offset 0x40, 16 bits)*/
/*--------------------------------------------------------------------------*/
#define _APSDOFF_STATUS BIT(15)
#define _APSDOFF BIT(14)
#define _BBRSTn BIT(13) /*Enable OFDM/CCK*/
#define _BB_GLB_RSTn BIT(12) /*Enable BB*/
#define _SCHEDULE_EN BIT(10) /*Enable MAC scheduler*/
#define _MACRXEN BIT(9)
#define _MACTXEN BIT(8)
#define _DDMA_EN BIT(7) /*FW off load function enable*/
#define _FW2HW_EN BIT(6) /*MAC every module reset */
#define _RXDMA_EN BIT(5)
#define _TXDMA_EN BIT(4)
#define _HCI_RXDMA_EN BIT(3)
#define _HCI_TXDMA_EN BIT(2)
/*TXPAUSE*/
#define _STOPHCCA BIT(6)
#define _STOPHIGH BIT(5)
#define _STOPMGT BIT(4)
#define _STOPVO BIT(3)
#define _STOPVI BIT(2)
#define _STOPBE BIT(1)
#define _STOPBK BIT(0)
/*TCR*/
#define _DISCW BIT(20)
#define _ICV BIT(19)
#define _CFEND_FMT BIT(17)
#define _CRC BIT(16)
#define _FWRDY BIT(7)
#define _BASECHG BIT(6)
#define _IMEM_RDY BIT(5)
#define _DMEM_CODE_DONE BIT(4)
#define _EMEM_CHK_RPT BIT(3)
#define _EMEM_CODE_DONE BIT(2)
#define _IMEM_CHK_RPT BIT(1)
#define _IMEM_CODE_DONE BIT(0)
#define _TXDMA_INIT_VALUE (_IMEM_CHK_RPT|_EMEM_CHK_RPT)
/*RCR*/
#define _ENMBID BIT(27)
#define _APP_PHYST_RXFF BIT(25)
#define _APP_PHYST_STAFF BIT(24)
#define _CBSSID BIT(23)
#define _APWRMGT BIT(22)
#define _ADD3 BIT(21)
#define _AMF BIT(20)
#define _ACF BIT(19)
#define _ADF BIT(18)
#define _APP_MIC BIT(17)
#define _APP_ICV BIT(16)
#define _RXFTH_MSK 0x0000E000
#define _RXFTH_SHT 13
#define _AICV BIT(12)
#define _RXPKTLMT_MSK 0x00000FC0
#define _RXPKTLMT_SHT 6
#define _ACRC32 BIT(5)
#define _AB BIT(3)
#define _AM BIT(2)
#define _APM BIT(1)
#define _AAP BIT(0)
/*MSR*/
#define _NETTYPE_MSK 0x03
#define _NETTYPE_SHT 0
/*BT*/
#define _BTMODE_MSK 0x06
#define _BTMODE_SHT 1
#define _ENBT BIT(0)
/*MBIDCTRL*/
#define _ENMBID_MODE BIT(15)
#define _BCNNO_MSK 0x7000
#define _BCNNO_SHT 12
#define _BCNSPACE_MSK 0x0FFF
#define _BCNSPACE_SHT 0
#endif /* __RTL8712_CMDCTRL_BITDEF_H__*/
#ifndef __RTL8712_CMDCTRL_REGDEF_H__
#define __RTL8712_CMDCTRL_REGDEF_H__
#define CR (RTL8712_CMDCTRL_ + 0x0000)
#define TXPAUSE (RTL8712_CMDCTRL_ + 0x0002)
#define TCR (RTL8712_CMDCTRL_ + 0x0004)
#define RCR (RTL8712_CMDCTRL_ + 0x0008)
#define MSR (RTL8712_CMDCTRL_ + 0x000C)
#define SYSF_CFG (RTL8712_CMDCTRL_ + 0x000D)
#define MBIDCTRL (RTL8712_CMDCTRL_ + 0x000E)
#endif /* __RTL8712_CMDCTRL_REGDEF_H__ */
#ifndef __RTL8712_DEBUGCTRL_BITDEF_H__
#define __RTL8712_DEBUGCTRL_BITDEF_H__
/*BIST*/
#define _BIST_RST BIT(0)
/*LMS*/
#define _LMS_MSK 0x03
/*WDG_CTRL*/
#define _OVSEL_MSK 0x0600
#define _OVSEL_SHT 9
#define _WDGCLR BIT(8)
#define _WDGEN_MSK 0x00FF
#define _WDGEN_SHT 0
/*INTM*/
#define _TXTIMER_MSK 0xF000
#define _TXTIMER_SHT 12
#define _TXNUM_MSK 0x0F00
#define _TXNUM_SHT 8
#define _RXTIMER_MSK 0x00F0
#define _RXTIMER_SHT 4
#define _RXNUM_MSK 0x000F
#define _RXNUM_SHT 0
/*FDLOCKTURN0*/
/*FDLOCKTURN1*/
#define _TURN1 BIT(0)
/*FDLOCKFLAG0*/
/*FDLOCKFLAG1*/
#define _LOCKFLAG1_MSK 0x03
#endif /* __RTL8712_DEBUGCTRL_BITDEF_H__ */
#ifndef __RTL8712_DEBUGCTRL_REGDEF_H__
#define __RTL8712_DEBUGCTRL_REGDEF_H__
#define BIST (RTL8712_DEBUGCTRL_ + 0x00)
#define DBS (RTL8712_DEBUGCTRL_ + 0x04)
#define LMS (RTL8712_DEBUGCTRL_ + 0x05)
#define CPUINST (RTL8712_DEBUGCTRL_ + 0x08)
#define CPUCAUSE (RTL8712_DEBUGCTRL_ + 0x0C)
#define LBUS_ERR_ADDR (RTL8712_DEBUGCTRL_ + 0x10)
#define LBUS_ERR_CMD (RTL8712_DEBUGCTRL_ + 0x14)
#define LBUS_ERR_DATA_L (RTL8712_DEBUGCTRL_ + 0x18)
#define LBUS_ERR_DATA_H (RTL8712_DEBUGCTRL_ + 0x1C)
#define LBUS_EXCEPTION_ADDR (RTL8712_DEBUGCTRL_ + 0x20)
#define WDG_CTRL (RTL8712_DEBUGCTRL_ + 0x24)
#define INTMTU (RTL8712_DEBUGCTRL_ + 0x28)
#define INTM (RTL8712_DEBUGCTRL_ + 0x2A)
#define FDLOCKTURN0 (RTL8712_DEBUGCTRL_ + 0x2C)
#define FDLOCKTURN1 (RTL8712_DEBUGCTRL_ + 0x2D)
#define FDLOCKFLAG0 (RTL8712_DEBUGCTRL_ + 0x2E)
#define FDLOCKFLAG1 (RTL8712_DEBUGCTRL_ + 0x2F)
#define TRXPKTBUF_DBG_DATA (RTL8712_DEBUGCTRL_ + 0x30)
#define TRXPKTBUF_DBG_CTRL (RTL8712_DEBUGCTRL_ + 0x38)
#define DPLL_MON (RTL8712_DEBUGCTRL_ + 0x3A)
#endif /* __RTL8712_DEBUGCTRL_REGDEF_H__ */
#ifndef __RTL8712_EDCASETTING_BITDEF_H__
#define __RTL8712_EDCASETTING_BITDEF_H__
/*EDCAPARAM*/
#define _TXOPLIMIT_MSK 0xFFFF0000
#define _TXOPLIMIT_SHT 16
#define _ECWIN_MSK 0x0000FF00
#define _ECWIN_SHT 8
#define _AIFS_MSK 0x000000FF
#define _AIFS_SHT 0
/*BCNTCFG*/
#define _BCNECW_MSK 0xFF00
#define _BCNECW_SHT 8
#define _BCNIFS_MSK 0x00FF
#define _BCNIFS_SHT 0
/*CWRR*/
#define _CWRR_MSK 0x03FF
/*ACMAVG*/
#define _AVG_TIME_UP BIT(3)
#define _AVGPERIOD_MSK 0x03
/*ACMHWCTRL*/
#define _VOQ_ACM_STATUS BIT(6)
#define _VIQ_ACM_STATUS BIT(5)
#define _BEQ_ACM_STATUS BIT(4)
#define _VOQ_ACM_EN BIT(3)
#define _VIQ_ACM_EN BIT(2)
#define _BEQ_ACM_EN BIT(1)
#define _ACMHWEN BIT(0)
/*VO_ADMTIME*/
#define _VO_ACM_RUT BIT(18)
#define _VO_ADMTIME_MSK 0x0003FFF
/*VI_ADMTIME*/
#define _VI_ACM_RUT BIT(18)
#define _VI_ADMTIME_MSK 0x0003FFF
/*BE_ADMTIME*/
#define _BE_ACM_RUT BIT(18)
#define _BE_ADMTIME_MSK 0x0003FFF
/*Retry limit reg*/
#define _SRL_MSK 0xFF00
#define _SRL_SHT 8
#define _LRL_MSK 0x00FF
#define _LRL_SHT 0
#endif /* __RTL8712_EDCASETTING_BITDEF_H__*/
#ifndef __RTL8712_EDCASETTING_REGDEF_H__
#define __RTL8712_EDCASETTING_REGDEF_H__
#define EDCA_VO_PARAM (RTL8712_EDCASETTING_ + 0x00)
#define EDCA_VI_PARAM (RTL8712_EDCASETTING_ + 0x04)
#define EDCA_BE_PARAM (RTL8712_EDCASETTING_ + 0x08)
#define EDCA_BK_PARAM (RTL8712_EDCASETTING_ + 0x0C)
#define BCNTCFG (RTL8712_EDCASETTING_ + 0x10)
#define CWRR (RTL8712_EDCASETTING_ + 0x12)
#define ACMAVG (RTL8712_EDCASETTING_ + 0x16)
#define ACMHWCTRL (RTL8712_EDCASETTING_ + 0x17)
#define VO_ADMTIME (RTL8712_EDCASETTING_ + 0x18)
#define VI_ADMTIME (RTL8712_EDCASETTING_ + 0x1C)
#define BE_ADMTIME (RTL8712_EDCASETTING_ + 0x20)
#define RL (RTL8712_EDCASETTING_ + 0x24)
#endif /* __RTL8712_EDCASETTING_REGDEF_H__ */
This diff is collapsed.
#ifndef __RTL8712_EFUSE_H__
#define __RTL8712_EFUSE_H__
#include "osdep_service.h"
#define _REPEAT_THRESHOLD_ 3
#define EFUSE_MAX_SIZE 512
#define EFUSE_MAP_MAX_SIZE 128
#define PGPKG_MAX_WORDS 4
#define PGPKT_DATA_SIZE 8 /* PGPKG_MAX_WORDS*2; BYTES sizeof(u8)*8*/
#define MAX_PGPKT_SIZE 9 /* 1 + PGPKT_DATA_SIZE; header + 2 * 4 words (BYTES)*/
#define GET_EFUSE_OFFSET(header) ((header & 0xF0) >> 4)
#define GET_EFUSE_WORD_EN(header) (header & 0x0F)
#define MAKE_EFUSE_HEADER(offset, word_en) (((offset & 0x0F) << 4) | \
(word_en & 0x0F))
/*--------------------------------------------------------------------------*/
struct PGPKT_STRUCT {
u8 offset;
u8 word_en;
u8 data[PGPKT_DATA_SIZE];
};
/*--------------------------------------------------------------------------*/
u8 r8712_efuse_reg_init(struct _adapter *padapter);
void r8712_efuse_reg_uninit(struct _adapter *padapter);
u16 r8712_efuse_get_current_size(struct _adapter *padapter);
int r8712_efuse_get_max_size(struct _adapter *padapter);
void r8712_efuse_change_max_size(struct _adapter *padapter);
u8 r8712_efuse_pg_packet_read(struct _adapter *padapter,
u8 offset, u8 *data);
u8 r8712_efuse_pg_packet_write(struct _adapter *padapter,
const u8 offset, const u8 word_en,
const u8 *data);
u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead,
u16 start_addr, u16 cnts, u8 *data);
u8 r8712_efuse_map_read(struct _adapter *padapter, u16 addr,
u16 cnts, u8 *data);
u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr,
u16 cnts, u8 *data);
#endif
#ifndef _RTL8712_EVENT_H_
#define _RTL8712_EVENT_H_
void r8712_event_handle(struct _adapter *padapter, uint *peventbuf);
void r8712_got_addbareq_event_callback(struct _adapter *adapter , u8 *pbuf);
enum rtl8712_c2h_event {
GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/
GEN_EVT_CODE(_Read_BBREG),
GEN_EVT_CODE(_Read_RFREG),
GEN_EVT_CODE(_Read_EEPROM),
GEN_EVT_CODE(_Read_EFUSE),
GEN_EVT_CODE(_Read_CAM), /*5*/
GEN_EVT_CODE(_Get_BasicRate),
GEN_EVT_CODE(_Get_DataRate),
GEN_EVT_CODE(_Survey), /*8*/
GEN_EVT_CODE(_SurveyDone), /*9*/
GEN_EVT_CODE(_JoinBss) , /*10*/
GEN_EVT_CODE(_AddSTA),
GEN_EVT_CODE(_DelSTA),
GEN_EVT_CODE(_AtimDone) ,
GEN_EVT_CODE(_TX_Report),
GEN_EVT_CODE(_CCX_Report), /*15*/
GEN_EVT_CODE(_DTM_Report),
GEN_EVT_CODE(_TX_Rate_Statistics),
GEN_EVT_CODE(_C2HLBK),
GEN_EVT_CODE(_FWDBG),
GEN_EVT_CODE(_C2HFEEDBACK), /*20*/
GEN_EVT_CODE(_ADDBA),
GEN_EVT_CODE(_C2HBCN),
GEN_EVT_CODE(_ReportPwrState), /*filen: only for PCIE, USB*/
GEN_EVT_CODE(_WPS_PBC), /*24*/
GEN_EVT_CODE(_ADDBAReq_Report), /*25*/
MAX_C2HEVT
};
#ifdef _RTL8712_CMD_C_
static struct fwevent wlanevents[] = {
{0, NULL}, /*0*/
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, &r8712_survey_event_callback}, /*8*/
{sizeof(struct surveydone_event), &r8712_surveydone_event_callback},/*9*/
{0, &r8712_joinbss_event_callback}, /*10*/
{sizeof(struct stassoc_event), &r8712_stassoc_event_callback},
{sizeof(struct stadel_event), &r8712_stadel_event_callback},
{0, &r8712_atimdone_event_callback},
{0, NULL},
{0, NULL}, /*15*/
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL}, /*fwdbg_event_callback},*/
{0, NULL}, /*20*/
{0, NULL},
{0, NULL},
{0, &r8712_cpwm_event_callback},
{0, &r8712_wpspbc_event_callback},
{0, &r8712_got_addbareq_event_callback},
};
#endif/*_RTL8712_CMD_C_*/
#endif
#ifndef __RTL8712_FIFOCTRL_BITDEF_H__
#define __RTL8712_FIFOCTRL_BITDEF_H__
/*PBP*/
#define _PSTX_MSK 0xF0
#define _PSTX_SHT 4
#define _PSRX_MSK 0x0F
#define _PSRX_SHT 0
/*TXFF_STATUS*/
#define _TXSTATUS_OVF BIT(15)
/*RXFF_STATUS*/
#define _STATUSFF1_OVF BIT(7)
#define _STATUSFF1_EMPTY BIT(6)
#define _STATUSFF0_OVF BIT(5)
#define _STATUSFF0_EMPTY BIT(4)
#define _RXFF1_OVF BIT(3)
#define _RXFF1_EMPTY BIT(2)
#define _RXFF0_OVF BIT(1)
#define _RXFF0_EMPTY BIT(0)
/*TXFF_EMPTY_TH*/
#define _BKQ_EMPTY_TH_MSK 0x0F0000
#define _BKQ_EMPTY_TH_SHT 16
#define _BEQ_EMPTY_TH_MSK 0x00F000
#define _BEQ_EMPTY_TH_SHT 12
#define _VIQ_EMPTY_TH_MSK 0x000F00
#define _VIQ_EMPTY_TH_SHT 8
#define _VOQ_EMPTY_TH_MSK 0x0000F0
#define _VOQ_EMPTY_TH_SHT 4
#define _BMCQ_EMPTY_TH_MSK 0x00000F
#define _BMCQ_EMPTY_TH_SHT 0
/*SDIO_RX_BLKSZ*/
#define _SDIO_RX_BLKSZ_MSK 0x07
/*RXDMA_CTRL*/
#define _C2HFF_POLL BIT(4)
#define _RXPKT_POLL BIT(0)
/*RXPKT_NUM*/
#define _RXCMD_NUM_MSK 0xFF00
#define _RXCMD_NUM_SHT 8
#define _RXFF0_NUM_MSK 0x00FF
#define _RXFF0_NUM_SHT 0
/*FIFOPAGE2*/
#define _PUB_AVAL_PG_MSK 0xFFFF0000
#define _PUB_AVAL_PG_SHT 16
#define _BCN_AVAL_PG_MSK 0x0000FFFF
#define _BCN_AVAL_PG_SHT 0
/*RX0PKTNUM*/
#define _RXFF0_DEC_POLL BIT(15)
#define _RXFF0_PKT_DEC_NUM_MSK 0x3F00
#define _RXFF0_PKT_DEC_NUM_SHT 8
#define _RXFF0_PKTNUM_RPT_MSK 0x00FF
#define _RXFF0_PKTNUM_RPT_SHT 0
/*RX1PKTNUM*/
#define _RXFF1_DEC_POLL BIT(15)
#define _RXFF1_PKT_DEC_NUM_MSK 0x3F00
#define _RXFF1_PKT_DEC_NUM_SHT 8
#define _RXFF1_PKTNUM_RPT_MSK 0x00FF
#define _RXFF1_PKTNUM_RPT_SHT 0
/*RXFLTMAP0*/
#define _MGTFLT13EN BIT(13)
#define _MGTFLT12EN BIT(12)
#define _MGTFLT11EN BIT(11)
#define _MGTFLT10EN BIT(10)
#define _MGTFLT9EN BIT(9)
#define _MGTFLT8EN BIT(8)
#define _MGTFLT5EN BIT(5)
#define _MGTFLT4EN BIT(4)
#define _MGTFLT3EN BIT(3)
#define _MGTFLT2EN BIT(2)
#define _MGTFLT1EN BIT(1)
#define _MGTFLT0EN BIT(0)
/*RXFLTMAP1*/
#define _CTRLFLT15EN BIT(15)
#define _CTRLFLT14EN BIT(14)
#define _CTRLFLT13EN BIT(13)
#define _CTRLFLT12EN BIT(12)
#define _CTRLFLT11EN BIT(11)
#define _CTRLFLT10EN BIT(10)
#define _CTRLFLT9EN BIT(9)
#define _CTRLFLT8EN BIT(8)
#define _CTRLFLT7EN BIT(7)
#define _CTRLFLT6EN BIT(6)
/*RXFLTMAP2*/
#define _DATAFLT15EN BIT(15)
#define _DATAFLT14EN BIT(14)
#define _DATAFLT13EN BIT(13)
#define _DATAFLT12EN BIT(12)
#define _DATAFLT11EN BIT(11)
#define _DATAFLT10EN BIT(10)
#define _DATAFLT9EN BIT(9)
#define _DATAFLT8EN BIT(8)
#define _DATAFLT7EN BIT(7)
#define _DATAFLT6EN BIT(6)
#define _DATAFLT5EN BIT(5)
#define _DATAFLT4EN BIT(4)
#define _DATAFLT3EN BIT(3)
#define _DATAFLT2EN BIT(2)
#define _DATAFLT1EN BIT(1)
#define _DATAFLT0EN BIT(0)
/*RXFLTMAP3*/
#define _MESHAFLT1EN BIT(1)
#define _MESHAFLT0EN BIT(0)
/*TXPKT_NUM_CTRL*/
#define _TXPKTNUM_DEC BIT(8)
#define _TXPKTNUM_MSK 0x00FF
#define _TXPKTNUM_SHT 0
/*TXFF_PG_NUM*/
#define _TXFF_PG_NUM_MSK 0x0FFF
#endif /* __RTL8712_FIFOCTRL_BITDEF_H__ */
#ifndef __RTL8712_FIFOCTRL_REGDEF_H__
#define __RTL8712_FIFOCTRL_REGDEF_H__
#define RQPN (RTL8712_FIFOCTRL_ + 0x00)
#define RXFF_BNDY (RTL8712_FIFOCTRL_ + 0x0C)
#define RXRPT_BNDY (RTL8712_FIFOCTRL_ + 0x10)
#define TXPKTBUF_PGBNDY (RTL8712_FIFOCTRL_ + 0x14)
#define PBP (RTL8712_FIFOCTRL_ + 0x15)
#define RX_DRVINFO_SZ (RTL8712_FIFOCTRL_ + 0x16)
#define TXFF_STATUS (RTL8712_FIFOCTRL_ + 0x17)
#define RXFF_STATUS (RTL8712_FIFOCTRL_ + 0x18)
#define TXFF_EMPTY_TH (RTL8712_FIFOCTRL_ + 0x19)
#define SDIO_RX_BLKSZ (RTL8712_FIFOCTRL_ + 0x1C)
#define RXDMA_RXCTRL (RTL8712_FIFOCTRL_ + 0x1D)
#define RXPKT_NUM (RTL8712_FIFOCTRL_ + 0x1E)
#define RXPKT_NUM_C2H (RTL8712_FIFOCTRL_ + 0x1F)
#define C2HCMD_UDT_SIZE (RTL8712_FIFOCTRL_ + 0x20)
#define C2HCMD_UDT_ADDR (RTL8712_FIFOCTRL_ + 0x22)
#define FIFOPAGE2 (RTL8712_FIFOCTRL_ + 0x24)
#define FIFOPAGE1 (RTL8712_FIFOCTRL_ + 0x28)
#define FW_RSVD_PG_CTRL (RTL8712_FIFOCTRL_ + 0x30)
#define TXRPTFF_RDPTR (RTL8712_FIFOCTRL_ + 0x40)
#define TXRPTFF_WTPTR (RTL8712_FIFOCTRL_ + 0x44)
#define C2HFF_RDPTR (RTL8712_FIFOCTRL_ + 0x48)
#define C2HFF_WTPTR (RTL8712_FIFOCTRL_ + 0x4C)
#define RXFF0_RDPTR (RTL8712_FIFOCTRL_ + 0x50)
#define RXFF0_WTPTR (RTL8712_FIFOCTRL_ + 0x54)
#define RXFF1_RDPTR (RTL8712_FIFOCTRL_ + 0x58)
#define RXFF1_WTPTR (RTL8712_FIFOCTRL_ + 0x5C)
#define RXRPT0FF_RDPTR (RTL8712_FIFOCTRL_ + 0x60)
#define RXRPT0FF_WTPTR (RTL8712_FIFOCTRL_ + 0x64)
#define RXRPT1FF_RDPTR (RTL8712_FIFOCTRL_ + 0x68)
#define RXRPT1FF_WTPTR (RTL8712_FIFOCTRL_ + 0x6C)
#define RX0PKTNUM (RTL8712_FIFOCTRL_ + 0x72)
#define RX1PKTNUM (RTL8712_FIFOCTRL_ + 0x74)
#define RXFLTMAP0 (RTL8712_FIFOCTRL_ + 0x76)
#define RXFLTMAP1 (RTL8712_FIFOCTRL_ + 0x78)
#define RXFLTMAP2 (RTL8712_FIFOCTRL_ + 0x7A)
#define RXFLTMAP3 (RTL8712_FIFOCTRL_ + 0x7c)
#define TBDA (RTL8712_FIFOCTRL_ + 0x84)
#define THPDA (RTL8712_FIFOCTRL_ + 0x88)
#define TCDA (RTL8712_FIFOCTRL_ + 0x8C)
#define TMDA (RTL8712_FIFOCTRL_ + 0x90)
#define HDA (RTL8712_FIFOCTRL_ + 0x94)
#define TVODA (RTL8712_FIFOCTRL_ + 0x98)
#define TVIDA (RTL8712_FIFOCTRL_ + 0x9C)
#define TBEDA (RTL8712_FIFOCTRL_ + 0xA0)
#define TBKDA (RTL8712_FIFOCTRL_ + 0xA4)
#define RCDA (RTL8712_FIFOCTRL_ + 0xA8)
#define RDSA (RTL8712_FIFOCTRL_ + 0xAC)
#define TXPKT_NUM_CTRL (RTL8712_FIFOCTRL_ + 0xB0)
#define TXQ_PGADD (RTL8712_FIFOCTRL_ + 0xB3)
#define TXFF_PG_NUM (RTL8712_FIFOCTRL_ + 0xB4)
#endif /* __RTL8712_FIFOCTRL_REGDEF_H__ */
This diff is collapsed.
#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__ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment