📄 device.h
字号:
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This software is copyrighted by and is the sole property of
* VIA Networking Technologies, Inc. This software may only be used
* in accordance with the corresponding license agreement. Any unauthorized
* use, duplication, transmission, distribution, or disclosure of this
* software is expressly forbidden.
*
* This software is provided by VIA Networking Technologies, Inc. "as is"
* and any express or implied warranties, including, but not limited to, the
* implied warranties of merchantability and fitness for a particular purpose
* are disclaimed. In no event shall VIA Networking Technologies, Inc.
* be liable for any direct, indirect, incidental, special, exemplary, or
* consequential damages.
*
* File: device.h
*
* Purpose: MAC Data structure
*
* Author: Tevin Chen
*
* Date: Mar 17, 1997
*
*/
#ifndef __DEVICE_H__
#define __DEVICE_H__
#ifdef MODULE
#ifdef MODVERSIONS
#include <linux/modversions.h>
#endif /* MODVERSIONS */
#include <linux/module.h>
#endif /* MODULE */
#include <linux/types.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/pci.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/delay.h>
#include <linux/timer.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/version.h>
#include <linux/string.h>
#include <linux/wait.h>
#include <linux/if_arp.h>
#include <linux/sched.h>
#include <asm/io.h>
#include <linux/if.h>
#include <linux/config.h>
#include <asm/uaccess.h>
#include <linux/proc_fs.h>
#include <linux/inetdevice.h>
#include <linux/reboot.h>
#ifdef SIOCETHTOOL
#define DEVICE_ETHTOOL_IOCTL_SUPPORT
#include <linux/ethtool.h>
#else
#undef DEVICE_ETHTOOL_IOCTL_SUPPORT
#endif
/* Include Wireless Extension definition and check version - Jean II */
#include <linux/wireless.h>
#if WIRELESS_EXT > 12
#include <net/iw_handler.h> // New driver API
#endif /* WIRELESS_EXT > 12 */
//
// device specific
//
#if !defined(_KCOMPAT_H)
#include "kcompat.h"
#endif
#if !defined(__DEVICE_CONFIG_H)
#include "device_cfg.h"
#endif
#if !defined(__TTYPE_H__)
#include "ttype.h"
#endif
#if !defined(__80211HDR_H__)
#include "80211hdr.h"
#endif
#if !defined(__TETHER_H__)
#include "tether.h"
#endif
#if !defined(__WMGR_H__)
#include "wmgr.h"
#endif
#if !defined(__WCMD_H__)
#include "wcmd.h"
#endif
#if !defined(__MIB_H__)
#include "mib.h"
#endif
#if !defined(__SROM_H__)
#include "srom.h"
#endif
#if !defined(__RC4_H__)
#include "rc4.h"
#endif
#if !defined(__TPCI_H__)
#include "tpci.h"
#endif
#if !defined(__DESC_H__)
#include "desc.h"
#endif
#if !defined(__KEY_H__)
#include "key.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
// #ifdef PRIVATE_OBJ
//#if !defined(__DEVICE_MODULE_H)
//#include "device_module.h"
//#endif
/*--------------------- Export Definitions -------------------------*/
#define MAC_MAX_CONTEXT_REG (256+128)
#define MAX_MULTICAST_ADDRESS_NUM 32
#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * U_ETHER_ADDR_LEN)
//#define OP_MODE_INFRASTRUCTURE 0
//#define OP_MODE_ADHOC 1
//#define OP_MODE_AP 2
#define DUPLICATE_RX_CACHE_LENGTH 5
#define NUM_KEY_ENTRY 11
#define TX_WEP_NONE 0
#define TX_WEP_OTF 1
#define TX_WEP_SW 2
#define TX_WEP_SWOTP 3
#define TX_WEP_OTPSW 4
#define TX_WEP_SW232 5
#define KEYSEL_WEP40 0
#define KEYSEL_WEP104 1
#define KEYSEL_TKIP 2
#define KEYSEL_CCMP 3
#define AUTO_FB_NONE 0
#define AUTO_FB_0 1
#define AUTO_FB_1 2
#define FB_RATE0 0
#define FB_RATE1 1
// Antenna Mode
#define ANT_A 0
#define ANT_B 1
#define ANT_DIVERSITY 2
#define ANT_RXD_TXA 3
#define ANT_RXD_TXB 4
#define ANT_UNKNOWN 0xFF
#define MAXCHECKHANGCNT 4
#define BB_VGA_LEVEL 4
#define BB_VGA_CHANGE_THRESHOLD 16
#ifndef RUN_AT
#define RUN_AT(x) (jiffies+(x))
#endif
// DMA related
#define RESERV_AC0DMA 4
// BUILD OBJ mode
#ifdef PRIVATE_OBJ
#undef dev_kfree_skb
#undef dev_kfree_skb_irq
#undef dev_alloc_skb
#undef kfree
#undef del_timer
#undef init_timer
#undef add_timer
#undef kmalloc
#undef netif_stop_queue
#undef netif_start_queue
#undef netif_wake_queue
#undef netif_queue_stopped
#undef netif_rx
#undef netif_running
#undef udelay
#undef mdelay
#undef eth_type_trans
#undef skb_put
#undef HZ
#undef RUN_AT
#undef pci_alloc_consistent
#undef pci_free_consistent
#undef register_netdevice
#undef register_netdev
#undef unregister_netdevice
#undef unregister_netdev
#undef skb_queue_head_init
#undef skb_queue_tail
#undef skb_queue_empty
#undef free_irq
#undef copy_from_user
#undef copy_to_user
#undef spin_lock_init
#undef pci_map_single
#undef pci_unmap_single
// redefine kernel dependent fucntion
#define dev_kfree_skb ref_dev_kfree_skb
#define dev_kfree_skb_irq ref_dev_kfree_skb_irq
#define dev_alloc_skb ref_dev_alloc_skb
#define kfree ref_kfree
#define del_timer ref_del_timer
#define init_timer ref_init_timer
#define add_timer ref_add_timer
#define kmalloc ref_kmalloc
#define netif_stop_queue ref_netif_stop_queue
#define netif_start_queue ref_netif_start_queue
#define netif_wake_queue ref_netif_wake_queue
#define netif_queue_stopped ref_netif_queue_stopped
#define netif_rx ref_netif_rx
#define netif_running ref_netif_running
#define udelay ref_udelay
#define mdelay ref_mdelay
#define get_jiffies() ref_get_jiffies()
#define RUN_AT(x) (get_jiffies()+(x))
#define HZ ref_HZ_tick()
#define eth_type_trans ref_eth_type_trans
#define skb_put ref_skb_put
#define skb_queue_head_init ref_skb_queue_head_init
#define skb_queue_tail ref_skb_queue_tail
#define skb_queue_empty ref_skb_queue_empty
#define pci_alloc_consistent ref_pci_alloc_consistent
#define pci_free_consistent ref_pci_free_consistent
#define register_netdevice ref_register_netdevice
#define register_netdev ref_register_netdev
#define unregister_netdevice ref_unregister_netdevice
#define unregister_netdev ref_unregister_netdev
#define free_irq ref_free_irq
#define copy_from_user ref_copy_from_user
#define copy_to_user ref_copy_to_user
#define spin_lock_init ref_spin_lock_init
#define pci_map_single ref_pci_map_single
#define pci_unmap_single ref_pci_unmap_single
#endif
#ifdef PRIVATE_OBJ
#undef printk
#define DEVICE_PRT(l, p, args...) {if (l<=msglevel) do {} while (0);}
//#define DEVICE_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);}
#else
#define DEVICE_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);}
#endif
#define AVAIL_TD(p,q) ((p)->sOpts.nTxDescs[(q)]-((p)->iTDUsed[(q)]))
/*--------------------- Export Types ------------------------------*/
//0:11A 1:11B 2:11G
typedef enum _VIA_BB_TYPE
{
BB_TYPE_11A=0,
BB_TYPE_11B,
BB_TYPE_11G
} VIA_BB_TYPE, *PVIA_BB_TYPE;
//0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate)
typedef enum _VIA_PKT_TYPE
{
PK_TYPE_11A=0,
PK_TYPE_11B,
PK_TYPE_11GB,
PK_TYPE_11GA
} VIA_PKT_TYPE, *PVIA_PKT_TYPE;
typedef enum __device_msg_level {
MSG_LEVEL_ERR=0, //Errors that will cause abnormal operation.
MSG_LEVEL_NOTICE=1, //Some errors need users to be notified.
MSG_LEVEL_INFO=2, //Normal message.
MSG_LEVEL_VERBOSE=3, //Will report all trival errors.
MSG_LEVEL_DEBUG=4 //Only for debug purpose.
} DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL;
typedef enum __device_init_type {
DEVICE_INIT_COLD=0, // cold init
DEVICE_INIT_RESET, // reset init or Dx to D0 power remain init
DEVICE_INIT_DXPL // Dx to D0 power lost init
} DEVICE_INIT_TYPE, *PDEVICE_INIT_TYPE;
//++ NDIS related
#define MAX_BSSIDINFO_4_PMKID 16
#define MAX_PMKIDLIST 5
//Flags for PMKID Candidate list structure
#define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01
// PMKID Structures
typedef UCHAR NDIS_802_11_PMKID_VALUE[16];
typedef enum _NDIS_802_11_WEP_STATUS
{
Ndis802_11WEPEnabled,
Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled,
Ndis802_11WEPDisabled,
Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled,
Ndis802_11WEPKeyAbsent,
Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent,
Ndis802_11WEPNotSupported,
Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported,
Ndis802_11Encryption2Enabled,
Ndis802_11Encryption2KeyAbsent,
Ndis802_11Encryption3Enabled,
Ndis802_11Encryption3KeyAbsent
} NDIS_802_11_WEP_STATUS, *PNDIS_802_11_WEP_STATUS,
NDIS_802_11_ENCRYPTION_STATUS, *PNDIS_802_11_ENCRYPTION_STATUS;
typedef enum _NDIS_802_11_STATUS_TYPE
{
Ndis802_11StatusType_Authentication,
Ndis802_11StatusType_MediaStreamMode,
Ndis802_11StatusType_PMKID_CandidateList,
Ndis802_11StatusTypeMax // not a real type, defined as an upper bound
} NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
//Added new types for PMKID Candidate lists.
typedef struct _PMKID_CANDIDATE {
NDIS_802_11_MAC_ADDRESS BSSID;
ULONG Flags;
} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
typedef struct _BSSID_INFO
{
NDIS_802_11_MAC_ADDRESS BSSID;
NDIS_802_11_PMKID_VALUE PMKID;
} BSSID_INFO, *PBSSID_INFO;
typedef struct tagSPMKID {
ULONG Length;
ULONG BSSIDInfoCount;
BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID];
} SPMKID, *PSPMKID;
typedef struct tagSPMKIDCandidateEvent {
NDIS_802_11_STATUS_TYPE StatusType;
ULONG Version; // Version of the structure
ULONG NumCandidates; // No. of pmkid candidates
PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST];
} SPMKIDCandidateEvent, DEF* PSPMKIDCandidateEvent;
//--
//++ 802.11h related
#define MAX_QUIET_COUNT 8
typedef struct tagSQuietControl {
BOOL bEnable;
DWORD dwStartTime;
BYTE byPeriod;
WORD wDuration;
} SQuietControl, DEF* PSQuietControl;
//--
typedef struct __chip_info_tbl{
CHIP_TYPE chip_id;
char* name;
int io_size;
int nTxQueue;
U32 flags;
} CHIP_INFO, *PCHIP_INFO;
typedef enum {
OWNED_BY_HOST=0,
OWNED_BY_NIC=1
} DEVICE_OWNER_TYPE, *PDEVICE_OWNER_TYPE;
// The receive duplicate detection cache entry
typedef struct tagSCacheEntry{
WORD wFmSequence;
BYTE abyAddr2[U_ETHER_ADDR_LEN];
} SCacheEntry, *PSCacheEntry;
typedef struct tagSCache{
/* The receive cache is updated circularly. The next entry to be written is
* indexed by the "InPtr".
*/
UINT uInPtr; // Place to use next
SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH];
} SCache, *PSCache;
#define CB_MAX_RX_FRAG 64
// DeFragment Control Block, used for collecting fragments prior to reassembly
typedef struct tagSDeFragControlBlock
{
WORD wSequence;
WORD wFragNum;
BYTE abyAddr2[U_ETHER_ADDR_LEN];
UINT uLifetime;
struct sk_buff* skb;
#ifdef PRIVATE_OBJ
ref_sk_buff ref_skb;
#endif
PBYTE pbyRxBuffer;
UINT cbFrameLength;
BOOL bInUse;
} SDeFragControlBlock, DEF* PSDeFragControlBlock;
//flags for options
#define DEVICE_FLAGS_IP_ALIGN 0x00000001UL
#define DEVICE_FLAGS_PREAMBLE_TYPE 0x00000002UL
#define DEVICE_FLAGS_OP_MODE 0x00000004UL
#define DEVICE_FLAGS_PS_MODE 0x00000008UL
#define DEVICE_FLAGS_80211h_MODE 0x00000010UL
#define DEVICE_FLAGS_DiversityANT 0x00000020UL
//flags for driver status
#define DEVICE_FLAGS_OPENED 0x00010000UL
#define DEVICE_FLAGS_WOL_ENABLED 0x00080000UL
//flags for capbilities
#define DEVICE_FLAGS_TX_ALIGN 0x01000000UL
#define DEVICE_FLAGS_HAVE_CAM 0x02000000UL
#define DEVICE_FLAGS_FLOW_CTRL 0x04000000UL
//flags for MII status
#define DEVICE_LINK_FAIL 0x00000001UL
#define DEVICE_SPEED_10 0x00000002UL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -