Commit 84dcd8fd authored by Jeff Garzik's avatar Jeff Garzik

[netdrvr] Remove superceded wireless driver aironet4500

From the maintainer, Elmer Joandi(sp?):
	aironet4500 is superseded by cisco340 drivers (airo.c) by Ben Reed
and the  only strenght of my driver is that it allows to access absolutely
all registers on card. Which is useful for developers only. Besides there
is no normal interface to configure crypto in my driver, as the general
interface is not userfriendly at all. So in fact, I use Bens driver for my
ISP bussiness in general cases and my driver for troubleshooting.
parent 9f3eb491
......@@ -2443,104 +2443,6 @@ config ARLAN
On some computers the card ends up in non-valid state after some
time. Use a ping-reset script to clear it.
config AIRONET4500
tristate "Aironet 4500/4800 series adapters"
depends on NET_RADIO && (PCI || ISA || PCMCIA)
---help---
www.aironet.com (recently bought by Cisco) makes these 802.11 DS
adapters. Driver by Elmer Joandi (elmer@ylenurme.ee).
Say Y here if you have such an adapter, and then say Y below to
the option that applies to your particular type of card (PCI, ISA,
or PCMCIA).
This driver is also available as a module ( = code which can be
inserted in and removed from the running kernel whenever you want).
The module will be called aironet4500_core. If you want to
compile it as a module, say M here and read
<file:Documentation/modules.txt> as well as
<file:Documentation/networking/net-modules.txt>.
quick config parameters:
SSID=tsunami - "The Password"
adhoc=1 there are no Access Points around
master=1 Adhoc master (the one who creates network
sync)
slave=1 Adhoc slave (btw, it is still forming own net
sometimes, and has problems with firmware...
change IbssJoinNetTimeout from /proc...)
channel=1..? meaningful in adhoc mode
If you have problems with screwing up card, both_bap_lock=1 is a
conservative value (performance hit 15%).
All other parameters can be set via the proc interface.
config AIRONET4500_NONCS
tristate "Aironet 4500/4800 ISA/PCI/PNP/365 support "
depends on AIRONET4500
help
If you have an ISA, PCI or PCMCIA Aironet 4500/4800 wireless LAN
card, say Y here, and then also to the options below that apply
to you.
This driver is also available as a module ( = code which can be
inserted in and removed from the running kernel whenever you want).
The module will be called aironet4500_card. If you want to
compile it as a module, say M here and read
<file:Documentation/modules.txt>.
config AIRONET4500_PNP
bool "Aironet 4500/4800 PNP support "
depends on AIRONET4500_NONCS
help
If you have an ISA Aironet 4500/4800 card which you want to use in
PnP (Plug and Play) mode, say Y here. This is the recommended mode
for ISA cards. Remember however to enable the PnP jumper on the
board if you say Y here.
config AIRONET4500_PCI
bool "Aironet 4500/4800 PCI support "
depends on AIRONET4500_NONCS && PCI
help
If you have an PCI Aironet 4500/4800 card, say Y here.
config AIRONET4500_ISA
bool "Aironet 4500/4800 ISA broken support (EXPERIMENTAL)"
depends on AIRONET4500_NONCS && EXPERIMENTAL
help
If you have an ISA Aironet 4500/4800 card which you want to run in
non-PnP mode, say Y here. This is not recommended and does not work
correctly at this point. Say N.
config AIRONET4500_I365
bool "Aironet 4500/4800 I365 broken support (EXPERIMENTAL)"
depends on AIRONET4500_NONCS && EXPERIMENTAL
help
If you have a PCMCIA Aironet 4500/4800 card which you want to use
without the standard PCMCIA cardservices provided by the pcmcia-cs
package, say Y here. This is not recommended, so say N.
config AIRONET4500_PROC
tristate "Aironet 4500/4800 PROC interface "
depends on AIRONET4500 && m
---help---
If you say Y here (and to the "/proc file system" below), you will
be able to configure your Aironet card via the
/proc/sys/aironet4500 interface.
Additional info: look in <file:drivers/net/aironet4500_rid.c>.
This driver is also available as a module ( = code which can be
inserted in and removed from the running kernel whenever you want).
The module will be called aironet4500_proc. If you want to
compile it as a module, say M here and read
<file:Documentation/modules.txt>.
NOTE: the proc interface uses a lot of memory, so it is recommended
to compile it as a module and remove the module after
configuration.
# New directory for Wireless LAN devices - cards above will move there
source "drivers/net/wireless/Kconfig"
......
......@@ -59,11 +59,6 @@ obj-$(CONFIG_ADAPTEC_STARFIRE) += starfire.o mii.o
#
obj-$(CONFIG_MII) += mii.o
obj-$(CONFIG_AIRONET4500) += aironet4500_core.o
obj-$(CONFIG_AIRONET4500_CS) += aironet4500_core.o
obj-$(CONFIG_AIRONET4500_NONCS) += aironet4500_card.o
obj-$(CONFIG_AIRONET4500_PROC) += aironet4500_proc.o
obj-$(CONFIG_AIRONET4500_CS) += aironet4500_proc.o
obj-$(CONFIG_WINBOND_840) += mii.o
obj-$(CONFIG_SUNDANCE) += sundance.o mii.o
......
/*
* Aironet 4500 Pcmcia driver
*
* Elmer Joandi, Januar 1999
* Copyright: GPL
*
*
* Revision 0.1 ,started 30.12.1998
*
*
*/
#ifndef AIRONET4500_H
#define AIRONET4500_H
// redefined to avoid PCMCIA includes
#include <linux/version.h>
/*#include <linux/module.h>
#include <linux/kernel.h>
*/
/*
#include <linux/types.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/delay.h>
#include <linux/time.h>
*/
#include <linux/802_11.h>
#include <linux/workqueue.h>
//damn idiot PCMCIA stuff
#ifndef DEV_NAME_LEN
#define DEV_NAME_LEN 32
#endif
struct pcmcia_junkdev_node_t {
char dev_name[DEV_NAME_LEN];
u_short major, minor;
struct dev_node_t *next;
};
#ifndef CS_RELEASE
typedef struct pcmcia_junkdev_node_t dev_node_t;
#endif
#include <linux/spinlock.h>
#define AWC_ERROR -1
#define AWC_SUCCESS 0
struct awc_cis {
unsigned char cis[0x301];
unsigned char unknown302[0xdf];
unsigned short configuration_register;
unsigned short pin_replacement_register;
unsigned short socket_and_copy_register;
};
/* timeout for transmit watchdog timer, AP default is 8 sec */
#define AWC_TX_TIMEOUT (HZ * 8)
/*************************** REGISTER OFFSETS *********************/
#define awc_Command_register 0x00
#define awc_Param0_register 0x02
#define awc_Param1_register 0x04
#define awc_Param2_register 0x06
#define awc_Status_register 0x08
#define awc_Resp0_register 0x0A
#define awc_Resp1_register 0x0C
#define awc_Resp2_register 0x0E
#define awc_EvStat_register 0x30
#define awc_EvIntEn_register 0x32
#define awc_EvAck_register 0x34
#define awc_SWSupport0_register 0x28
#define awc_SWSupport1_register 0x2A
#define awc_SWSupport2_register 0x2C
#define awc_SWSupport3_register 0x2E
#define awc_LinkStatus_register 0x10
// Memory access RID FID
#define awc_Select0_register 0x18
#define awc_Offset0_register 0x1C
#define awc_Data0_register 0x36
#define awc_Select1_register 0x1A
#define awc_Offset1_register 0x1E
#define awc_Data1_register 0x38
//
#define awc_RxFID_register 0x20
#define awc_TxAllocFID_register 0x22
#define awc_TxComplFID_register 0x24
#define awc_AuxPage_register 0x3A
#define awc_AuxOffset_register 0x3C
#define awc_AuxData_register 0x3E
struct awc_bap {
u16 select;
u16 offset;
u16 data;
volatile int lock;
volatile int status;
struct semaphore sem;
spinlock_t spinlock;
unsigned long flags;
};
#define AWC_COMMAND_STATE_WAIT_CMD_BUSY 1
#define AWC_COMMAND_STATE_WAIT_CMD_ACK 2
#define AWC_COMMAND_STATE_WAIT_BAP_BUSY 3
#define AWC_COMMAND_STATE_BAP_NOT_SET 4
#define AWC_COMMAND_STATE_BAP_SET 5
struct awc_command {
volatile int state;
volatile int lock_state;
struct net_device * dev;
struct awc_private * priv;
u16 port;
struct awc_bap * bap;
u16 command;
u16 par0;
u16 par1;
u16 par2;
u16 status;
u16 resp0;
u16 resp1;
u16 resp2;
u16 rid;
u16 offset;
u16 len;
void * buff;
};
#define DOWN(a) down_interruptible( a ) ;
// if (in_interrupt()) { down_interruptible( a ) ; } else printk("semaphore DOWN in interrupt tried \n");
#define UP(a) up( a ) ;
// if (in_interrupt()) {up( a ) ; } else printk("semaphore UP in interrupt tried \n");
/* if (!in_interrupt())\
printk("bap lock under cli but not in int\n");\
*/
#define AWC_LOCK_COMMAND_ISSUING(a) spin_lock_irqsave(&a->command_issuing_spinlock,a->command_issuing_spinlock_flags);
#define AWC_UNLOCK_COMMAND_ISSUING(a) spin_unlock_irqrestore(&a->command_issuing_spinlock,a->command_issuing_spinlock_flags);
#define AWC_BAP_LOCK_UNDER_CLI_REAL(cmd) \
if (!cmd.priv) {\
printk(KERN_CRIT "awc4500: no priv present in command !");\
}\
cmd.bap = &(cmd.priv->bap1);\
if (both_bap_lock)\
spin_lock_irqsave(&cmd.priv->both_bap_spinlock,cmd.priv->both_bap_spinlock_flags);\
if (cmd.bap){\
spin_lock_irqsave(&(cmd.bap->spinlock),cmd.bap->flags);\
cmd.bap->lock++;\
if (cmd.bap->lock > 1)\
printk("Bap 1 lock high\n");\
cmd.lock_state |= AWC_BAP_LOCKED;\
}
#define AWC_BAP_LOCK_NOT_CLI_REAL(cmd) {\
if (in_interrupt())\
printk("bap lock not cli in int\n");\
if (!cmd.priv) {\
printk(KERN_CRIT "awc4500: no priv present in command,lockup follows !");\
}\
cmd.bap = &(cmd.priv->bap0);\
if (both_bap_lock)\
spin_lock_irqsave(&cmd.priv->both_bap_spinlock,cmd.priv->both_bap_spinlock_flags);\
spin_lock_irqsave(&(cmd.bap->spinlock),cmd.bap->flags);\
DOWN(&(cmd.priv->bap0.sem));\
cmd.bap->lock++;\
if (cmd.bap->lock > 1)\
printk("Bap 0 lock high\n");\
cmd.lock_state |= AWC_BAP_SEMALOCKED;\
}
#define AWC_BAP_LOCK_NOT_CLI_CLI_REAL(cmd) {\
cmd.bap = &(cmd.priv->bap0);\
if (both_bap_lock)\
spin_lock_irqsave(&cmd.priv->both_bap_spinlock,cmd.priv->both_bap_spinlock_flags);\
spin_lock_irqsave(&(cmd.bap->spinlock),cmd.bap->flags);\
cmd.bap->lock++;\
if (cmd.bap->lock > 1)\
printk("Bap 0 lock high\n");\
cmd.lock_state |= AWC_BAP_LOCKED;\
}
#define BAP_LOCK_ANY(cmd)\
if (in_interrupt()) AWC_BAP_LOCK_NOT_CLI_CLI_REAL(cmd)\
else AWC_BAP_LOCK_NOT_CLI_REAL(cmd)
#define AWC_BAP_LOCK_NOT_CLI(cmd) BAP_LOCK_ANY(cmd)
#define AWC_BAP_LOCK_UNDER_CLI(cmd) AWC_BAP_LOCK_UNDER_CLI_REAL(cmd)
/*
if (!cmd.priv->bap1.lock ) {BAP_LOCK_ANY(cmd);}\
else AWC_BAP_LOCK_NOT_CLI_CLI_REAL(cmd);
*/
#define AWC_BAP_LOCKED 0x01
#define AWC_BAP_SEMALOCKED 0x02
#define AWC_BAP_BUSY 0x8000
#define AWC_BAP_ERR 0x4000
#define AWC_BAP_DONE 0x2000
#define AWC_CLI 1
#define AWC_NOT_CLI 2
/*#define WAIT61x3 inb(0x61);\
inb(0x61);\
inb(0x61);
*/
#define WAIT61x3 udelay(bap_sleep)
#define AWC_INIT_COMMAND(context, a_com, a_dev,a_cmmand,a_pr0, a_rid, a_offset, a_len, a_buff) {\
memset(&a_com,0,sizeof(a_com) );\
a_com.dev = a_dev;\
a_com.priv = a_dev->priv;\
a_com.port = a_dev->base_addr;\
a_com.bap = NULL;\
a_com.command = a_cmmand;\
a_com.par0 = a_pr0;\
a_com.rid = a_rid;\
a_com.offset = a_offset;\
a_com.len = a_len;\
a_com.buff = a_buff;\
a_com.lock_state = 0;\
};
/* vga veider asi jrgnevast
makrost vlja jetud if (cmd.bap) AWC_IN((cmd.bap)->data);\
*/
#define AWC_BAP_UNLOCK(com) { \
if (com.bap){ \
if ( (com.lock_state & AWC_BAP_SEMALOCKED) &&\
(com.lock_state & AWC_BAP_LOCKED) ){\
printk("Both Sema and simple lock \n");\
}\
if ( com.lock_state & AWC_BAP_SEMALOCKED ){\
com.bap->lock--; \
com.lock_state &= ~AWC_BAP_SEMALOCKED;\
UP(&(com.bap->sem)); \
spin_unlock_irqrestore(&(cmd.bap->spinlock),cmd.bap->flags);\
} else if (com.lock_state & AWC_BAP_LOCKED){\
com.bap->lock--; \
com.lock_state &= ~AWC_BAP_LOCKED;\
spin_unlock_irqrestore(&(cmd.bap->spinlock),cmd.bap->flags);\
}\
}\
if (both_bap_lock)\
spin_unlock_irqrestore(&cmd.priv->both_bap_spinlock,cmd.priv->both_bap_spinlock_flags);\
}
#define AWC_RELEASE_COMMAND(com) {\
AWC_BAP_UNLOCK(cmd);\
}
#define awc_manufacturer_code 0x015F
#define awc_product_code 0x0005
#define awc_write(base,register,u16value) outw(u16value, (base)+(register))
#define awc_read(base,register) inw((base)+(register))
#define AWC_OUT(base,val) outw(val, base)
#define AWC_IN(base) inw(base)
#define awc_read_response(cmd) { \
cmd->status=awc_read(cmd->port,awc_Status_register);\
cmd->resp0=awc_read(cmd->port,awc_Resp0_register);\
cmd->resp1=awc_read(cmd->port,awc_Resp1_register);\
cmd->resp2=awc_read(cmd->port,awc_Resp2_register);\
};
#define awc_command_busy(base) (awc_read(base,awc_Command_register) & 0x8000)
#define awc_command_read(base) awc_read(base,awc_Command_register)
#define awc_command_write(base,cmd) awc_write(base,awc_Command_register,cmd)
#define awc_event_status_Awake(base) (awc_read(base,awc_EvStat_register) & 0x0100)
#define awc_event_status_Link(base) (awc_read(base,awc_EvStat_register) & 0x0080)
#define awc_event_status_Cmd(base) (awc_read(base,awc_EvStat_register) & 0x0010)
#define awc_event_status_Alloc(base) (awc_read(base,awc_EvStat_register) & 0x0008)
#define awc_event_status_TxExc(base) (awc_read(base,awc_EvStat_register) & 0x0004)
#define awc_event_status_Tx(base) (awc_read(base,awc_EvStat_register) & 0x0002)
#define awc_event_status_TxResp(base) (awc_read(base,awc_EvStat_register) & 0x0006)
#define awc_event_status_Rx(base) (awc_read(base,awc_EvStat_register) & 0x0001)
#define awc_event_status(base) (awc_read(base,awc_EvStat_register))
#define awc_Link_Status(base) awc_read(base,awc_LinkStatus_register)
#define awc_Rx_Fid(base) awc_read(base,awc_RxFID_register)
#define awc_Tx_Allocated_Fid(base) awc_read(base,awc_TxAllocFID_register)
#define awc_Tx_Compl_Fid(base) awc_read(base,awc_TxComplFID_register)
#define awc_event_ack_ClrStckCmdBsy(base) awc_write(base,awc_EvAck_register, 0x4000)
#define awc_event_ack_WakeUp(base) awc_write(base,awc_EvAck_register, 0x2000)
#define awc_event_ack_Awaken(base) awc_write(base,awc_EvAck_register, 0x0100)
#define awc_event_ack_Link(base) awc_write(base,awc_EvAck_register, 0x0080)
#define awc_event_ack_Cmd(base) awc_write(base,awc_EvAck_register, 0x0010)
#define awc_event_ack_Alloc(base) awc_write(base,awc_EvAck_register, 0x0008)
#define awc_event_ack_TxExc(base) awc_write(base,awc_EvAck_register, 0x0004)
#define awc_event_ack_Tx(base) awc_write(base,awc_EvAck_register, 0x0002)
#define awc_event_ack_Rx(base) awc_write(base,awc_EvAck_register, 0x0001)
#define awc_event_ack(base,ints) awc_write(base,awc_EvAck_register,ints)
#define awc_ints_enabled(base) (awc_read(base,awc_EvIntEn_register))
#define awc_ints_enable(base,ints) awc_write(base,awc_EvIntEn_register,ints)
/************************ RX TX BUFF ************************/
struct aironet4500_radio_rx_header {
u32 RxTime;
u16 Status;
u16 PayloadLength;
u8 Reserved0;
u8 RSSI;
u8 Rate;
u8 Frequency;
u8 Rx_association_count;
u8 Reserved1[3];
u8 PLCP_header[4];
};
struct aironet4500_radio_tx_header {
u32 SWSupport;
u16 Status;
#define aironet4500_tx_status_max_retries 0x0002
#define aironet4500_tx_status_lifetime_exceeded 0x0004
#define aironet4500_tx_status_AID_failure 0x0008
#define aironet4500_tx_status_MAC_disabled 0x0010
#define aironet4500_tx_status_association_lost 0x0020
u16 PayloadLength;
u16 TX_Control;
#define aironet4500_tx_control_tx_ok_event_enable 0x0002
#define aironet4500_tx_control_tx_fail_event_enable 0x0004
#define aironet4500_tx_control_header_type_802_11 0x0008
#define aironet4500_tx_control_payload_type_llc 0x0010
#define aironet4500_tx_control_no_release 0x0020
#define aironet4500_tx_control_reuse_fid \
(aironet4500_tx_control_tx_ok_event_enable |\
aironet4500_tx_control_tx_fail_event_enable |\
aironet4500_tx_control_no_release)
#define aironet4500_tx_control_no_retries 0x0040
#define aironet4500_tx_control_clear_AID 0x0080
#define aironet4500_tx_control_strict_order 0x0100
#define aironet4500_tx_control_use_rts 0x0200
u16 AID;
u8 Tx_Long_Retry;
u8 Tx_Short_Retry;
u8 tx_association_count;
u8 tx_bit_rate;
#define aironet4500_tx_bit_rate_automatic 0
#define aironet4500_tx_bit_rate_500kbps 1
#define aironet4500_tx_bit_rate_1Mbps 2
#define aironet4500_tx_bit_rate_2Mbps 4
u8 Max_Long_Retry;
u8 Max_Short_Retry;
u8 Reserved0[2];
};
struct aironet4500_rx_fid {
u16 rid;
struct aironet4500_radio_rx_header radio_rx;
struct ieee_802_11_header ieee_802_11;
u16 gap_length;
struct ieee_802_3_header ieee_802_3;
u8 * payload;
};
struct aironet4500_tx_fid {
u16 fid;
u16 fid_size;
struct aironet4500_radio_tx_header radio_tx;
struct ieee_802_11_header ieee_802_11;
u16 gap_length;
#define aironet4500_gap_len_without_802_3 6
#define aironet4500_gap_len_with_802_3 0
struct ieee_802_3_header ieee_802_3;
u8 * payload;
};
struct awc_fid {
u32 type;
#define p80211_llc_snap 0x0100
#define p80211_8021H 0x0200
#define p80211_8022 0x0400
#define p80211_8023 0x0800
#define p80211_snap_8021H 0x1000
#define p80211copy_path_skb 0x2000
u8 priority;
u8 busy;
#define awc_tx_fid_complete_read 0x01
u16 state;
union {
struct aironet4500_tx_fid tx;
struct aironet4500_rx_fid rx;
} u;
struct ieee_802_11_snap_header snap;
struct ieee_802_11_802_1H_header bridge;
u16 bridge_size;
struct ieee_802_11_802_2_header p8022;
u16 pkt_len;
u8 * mac;
struct sk_buff * skb;
long long transmit_start_time;
struct awc_fid * next;
struct awc_fid * prev;
};
struct awc_fid_queue {
struct awc_fid * head;
struct awc_fid * tail;
int size;
spinlock_t spinlock;
};
static __inline__ void
awc_fid_queue_init(struct awc_fid_queue * queue){
unsigned long flags;
memset(queue,0, sizeof(struct awc_fid_queue));
spin_lock_init(&queue->spinlock);
spin_lock_irqsave(&queue->spinlock,flags);
queue->head = NULL;
queue->tail = NULL;
queue->size = 0;
spin_unlock_irqrestore(&queue->spinlock,flags);
};
static inline void
awc_fid_queue_push_tail( struct awc_fid_queue * queue,
struct awc_fid * fid){
unsigned long flags;
spin_lock_irqsave(&queue->spinlock,flags);
fid->prev = queue->tail;
fid->next = NULL;
if (queue->tail){
queue->tail->next = fid;
}
queue->tail = fid;
if (!queue->head)
queue->head = fid;
queue->size++;
spin_unlock_irqrestore(&queue->spinlock,flags);
};
static inline void
awc_fid_queue_push_head( struct awc_fid_queue * queue,
struct awc_fid * fid){
unsigned long flags;
spin_lock_irqsave(&queue->spinlock,flags);
fid->prev = NULL;
fid->next = queue->head;
if (queue->head){
queue->head->prev = fid;
}
queue->head = fid;
if (!queue->tail)
queue->tail = fid;
queue->size++;
spin_unlock_irqrestore(&queue->spinlock,flags);
};
static inline void
awc_fid_queue_rm( struct awc_fid_queue * queue,
struct awc_fid * fid){
if (fid->prev) {
fid->prev->next = fid->next;
};
if (fid->next) {
fid->next->prev = fid->prev;
};
if (fid == queue->tail) {
queue->tail = fid->prev;
};
if (fid == queue->head) {
queue->head = fid->next;
};
fid->next = NULL;
fid->prev = NULL;
queue->size--;
if (queue->size ==0 ){
queue->tail = NULL;
queue->head = NULL;
}
};
static inline void
awc_fid_queue_remove( struct awc_fid_queue * queue,
struct awc_fid * fid){
unsigned long flags;
spin_lock_irqsave(&queue->spinlock,flags);
awc_fid_queue_rm(queue,fid);
spin_unlock_irqrestore(&queue->spinlock,flags);
};
static inline struct awc_fid *
awc_fid_queue_pop_head( struct awc_fid_queue * queue){
unsigned long flags;
struct awc_fid * fid;
spin_lock_irqsave(&queue->spinlock,flags);
fid = queue->head;
if (fid)
awc_fid_queue_rm(queue,fid);
spin_unlock_irqrestore(&queue->spinlock,flags);
return fid;
};
static inline struct awc_fid *
awc_fid_queue_pop_tail( struct awc_fid_queue * queue){
unsigned long flags;
struct awc_fid * fid;
spin_lock_irqsave(&queue->spinlock,flags);
fid = queue->tail;
if (fid)
awc_fid_queue_rm(queue,fid);
spin_unlock_irqrestore(&queue->spinlock,flags);
return fid;
};
#define AWC_TX_HEAD_SIZE 0x44
#define AWC_TX_ALLOC_SMALL_SIZE 200
#define AWC_RX_BUFFS 50
/***************************** RID & CONFIG ***********************/
struct awc_config{
unsigned short Len; /* sizeof(PC4500_CONFIG) */
unsigned short OperatingMode; /* operating mode */
#define MODE_STA_IBSS 0
#define MODE_STA_ESS 1
#define MODE_AP 2
#define MODE_AP_RPTR 3
#define MODE_ETHERNET_HOST (0<<8) /* rx payloads converted */
#define MODE_LLC_HOST (1<<8) /* rx payloads left as is */
#define MODE_AIRONET_EXTEND (1<<9) /* enable Aironet extenstions */
#define MODE_AP_INTERFACE (1<<10) /* enable ap interface extensions */
unsigned short ReceiveMode; /* receive mode */
#define RXMODE_BC_MC_ADDR 0
#define RXMODE_BC_ADDR 1 /* ignore multicasts */
#define RXMODE_ADDR 2 /* ignore multicast and broadcast */
#define RXMODE_RFMON 3 /* wireless monitor mode */
#define RXMODE_RFMON_ANYBSS 4
#define RXMODE_LANMON 5 /* lan style monitor -- data packets only */
#define RXMODE_DISABLE_802_3_HEADER 0x100 /* disables 802.3 header on rx */
unsigned short FragmentThreshold;
unsigned short RtsThreshold;
unsigned char StationMacAddress[6];
unsigned char Rates[8];
unsigned short ShortRetryLimit;
unsigned short LongRetryLimit;
unsigned short TxLifetime; /* in kusec */
unsigned short RxLifetime; /* in kusec */
unsigned short Stationary;
unsigned short Ordering;
unsigned short DeviceType; /* for overriding device type */
unsigned short _reserved1[5]; /*---------- Scanning/Associating ----------*/
unsigned short ScanMode;
#define SCANMODE_ACTIVE 0
#define SCANMODE_PASSIVE 1
#define SCANMODE_AIROSCAN 2
unsigned short ProbeDelay; /* in kusec */
unsigned short ProbeEnergyTimeout; /* in kusec */
unsigned short ProbeResponseTimeout;
unsigned short BeaconListenTimeout;
unsigned short JoinNetTimeout;
unsigned short AuthenticationTimeout;
unsigned short AuthenticationType;
#define AUTH_OPEN 1
#define AUTH_SHAREDKEY 2
#define AUTH_EXCLUDENONWEP 4
unsigned short AssociationTimeout;
unsigned short SpecifiedApTimeout;
unsigned short OfflineScanInterval;
unsigned short OfflineScanDuration;
unsigned short LinkLossDelay;
unsigned short MaxBeaconLostTime;
unsigned short RefreshInterval;
#define DISABLE_REFRESH 0xFFFF
unsigned short _reserved1a[1]; /*---------- Power save operation ----------*/
unsigned short PowerSaveMode;
#define POWERSAVE_CAM 0
#define POWERSAVE_PSP 1
#define POWERSAVE_PSP_CAM 2
unsigned short SleepForDtims;
unsigned short ListenInterval;
unsigned short FastListenInterval;
unsigned short ListenDecay;
unsigned short FastListenDelay;
unsigned short _reserved2[2]; /*---------- Ap/Ibss config items ----------*/
unsigned short BeaconPeriod;
unsigned short AtimDuration;
unsigned short HopPeriod;
unsigned short ChannelSet;
unsigned short Channel;
unsigned short DtimPeriod;
unsigned short _reserved3[2]; /*---------- Radio configuration ----------*/
unsigned short RadioType;
#define RADIOTYPE_DEFAULT 0
#define RADIOTYPE_802_11 1
#define RADIOTYPE_LEGACY 2
unsigned char u8RxDiversity;
unsigned char u8TxDiversity;
unsigned short TxPower;
#define TXPOWER_DEFAULT 0
unsigned short RssiThreshold;
#define RSSI_DEFAULT 0
unsigned short RadioSpecific[4]; /*---------- Aironet Extensions ----------*/
unsigned char NodeName[16];
unsigned short ArlThreshold;
unsigned short ArlDecay;
unsigned short ArlDelay;
unsigned short _reserved4[1]; /*---------- Aironet Extensions ----------*/
unsigned short MagicAction;
#define MAGIC_ACTION_STSCHG 1
#define MACIC_ACTION_RESUME 2
#define MAGIC_IGNORE_MCAST (1<<8)
#define MAGIC_IGNORE_BCAST (1<<9)
#define MAGIC_SWITCH_TO_PSP (0<<10)
#define MAGIC_STAY_IN_CAM (1<<10)
};
struct awc_SSID {
u16 lenght;
u8 SSID[32];
};
struct awc_SSIDs {
u16 ridLen;
struct awc_SSID SSID[3];
};
struct awc_fixed_APs{
u16 ridLen;
u8 AP[4][6];
};
struct awc_driver_name{
u16 ridLen;
u8 name[16];
};
struct awc_encapsulation{
u16 etherType;
u16 Action;
};
struct awc_enc_trans{
u16 ridLen;
struct awc_encapsulation rules[8];
};
struct awc_wep_key {
u16 ridLen;
u16 KeyIndex;
u8 Address[6];
u16 KeyLen;
u8 Key[16];
};
struct awc_modulation {
u16 ridLen;
u16 Modulation;
};
struct awc_cap{
u16 ridLen;
u8 OUI[3];
u8 ProductNum[3];
u8 ManufacturerName[32];
u8 ProductName[16];
u8 ProductVersion[8];
u8 FactoryAddress[6];
u8 AironetAddress[6];
u16 RadioType;
u16 RegDomain;
u8 Callid[6];
u8 SupportedRates[8];
u8 RxDiversity;
u8 TxDiversity;
u16 TxPowerLevels[8];
u16 HardwareVersion;
u16 HardwareCapabilities;
u16 TemperatureRange;
u16 SoftwareVersion;
u16 SoftwareSubVersion;
u16 InterfaceVersion;
u16 SoftwareCapabilities;
u8 BootBlockVersionMajor;
u8 BootBlockVersionMinor;
};
struct awc_status{
u16 ridLen;
u8 MacAddress[6];
u16 OperationalMode;
u16 ErrorCode;
u16 CurrentSignalQuality;
u16 SSIDlength;
u8 SSID[32];
u8 ApName[16];
u8 CurrentBssid[32];
u8 PreviousBSSIDs[3][6];
u16 BeaconPeriod;
u16 DtimPeriod;
u16 AtimDuration;
u16 HopPeriod;
u16 ChannelSet;
u16 Channel;
u16 HopsToBackbone;
u16 ApTotalLoad;
u16 OurGeneratedLoad;
u16 AccumulatedArl;
};
struct awc_AP{
u16 ridLen;
u16 TIM_Addr;
u16 Airo_Addr;
};
struct awc_Statistics_32 {
u32 RidLen;
u32 RxOverrunErr;
u32 RxPlcpCrcErr;
u32 RxPlcpFormat;
u32 RxPlcpLength;
u32 RxMacCrcErr;
u32 RxMacCrcOk;
u32 RxWepErr;
u32 RxWepOk;
u32 RetryLong;
u32 RetryShort;
u32 MaxRetries;
u32 NoAck;
u32 NoCts;
u32 RxAck;
u32 RxCts;
u32 TxAck;
u32 TxRts;
u32 TxCts;
u32 TxMc;
u32 TxBc;
u32 TxUcFrags;
u32 TxUcPackets;
u32 TxBeacon;
u32 RxBeacon;
u32 TxSinColl;
u32 TxMulColl;
u32 DefersNo;
u32 DefersProt;
u32 DefersEngy;
u32 DupFram;
u32 RxFragDisc;
u32 TxAged;
u32 RxAged;
u32 LostSync_Max;
u32 LostSync_Mis;
u32 LostSync_Arl;
u32 LostSync_Dea;
u32 LostSync_Disa;
u32 LostSync_Tsf;
u32 HostTxMc;
u32 HostTxBc;
u32 HostTxUc;
u32 HostTxFail;
u32 HostRxMc;
u32 HostRxBc;
u32 HostRxUc;
u32 HostRxDiscar;
u32 HmacTxMc;
u32 HmacTxBc;
u32 HmacTxUc;
u32 HmacTxFail;
u32 HmacRxMc;
u32 HmacRxBc;
u32 HmacRxUc;
u32 HmacRxDisca;
u32 HmacRxAcce;
u32 SsidMismatch;
u32 ApMismatch;
u32 RatesMismatc;
u32 AuthReject;
u32 AuthTimeout;
u32 AssocReject;
u32 AssocTimeout;
u32 NewReason;
u32 AuthFail_1;
u32 AuthFail_2;
u32 AuthFail_3;
u32 AuthFail_4;
u32 AuthFail_5;
u32 AuthFail_6;
u32 AuthFail_7;
u32 AuthFail_8;
u32 AuthFail_9;
u32 AuthFail_10;
u32 AuthFail_11;
u32 AuthFail_12;
u32 AuthFail_13;
u32 AuthFail_14;
u32 AuthFail_15;
u32 AuthFail_16;
u32 AuthFail_17;
u32 AuthFail_18;
u32 AuthFail_19;
u32 RxMan;
u32 TxMan;
u32 RxRefresh;
u32 TxRefresh;
u32 RxPoll;
u32 TxPoll;
u32 HostRetries;
u32 LostSync_HostReq;
u32 HostTxBytes;
u32 HostRxBytes;
u32 ElapsedUsec;
u32 ElapsedSec;
u32 LostSyncBett;
};
struct awc_Statistics_16 {
u16 RidLen;
u16 RxOverrunErr;
u16 RxPlcpCrcErr;
u16 RxPlcpFormat;
u16 RxPlcpLength;
u16 RxMacCrcErr;
u16 RxMacCrcOk;
u16 RxWepErr;
u16 RxWepOk;
u16 RetryLong;
u16 RetryShort;
u16 MaxRetries;
u16 NoAck;
u16 NoCts;
u16 RxAck;
u16 RxCts;
u16 TxAck;
u16 TxRts;
u16 TxCts;
u16 TxMc;
u16 TxBc;
u16 TxUcFrags;
u16 TxUcPackets;
u16 TxBeacon;
u16 RxBeacon;
u16 TxSinColl;
u16 TxMulColl;
u16 DefersNo;
u16 DefersProt;
u16 DefersEngy;
u16 DupFram;
u16 RxFragDisc;
u16 TxAged;
u16 RxAged;
u16 LostSync_Max;
u16 LostSync_Mis;
u16 LostSync_Arl;
u16 LostSync_Dea;
u16 LostSync_Disa;
u16 LostSync_Tsf;
u16 HostTxMc;
u16 HostTxBc;
u16 HostTxUc;
u16 HostTxFail;
u16 HostRxMc;
u16 HostRxBc;
u16 HostRxUc;
u16 HostRxDiscar;
u16 HmacTxMc;
u16 HmacTxBc;
u16 HmacTxUc;
u16 HmacTxFail;
u16 HmacRxMc;
u16 HmacRxBc;
u16 HmacRxUc;
u16 HmacRxDisca;
u16 HmacRxAcce;
u16 SsidMismatch;
u16 ApMismatch;
u16 RatesMismatc;
u16 AuthReject;
u16 AuthTimeout;
u16 AssocReject;
u16 AssocTimeout;
u16 NewReason;
u16 AuthFail_1;
u16 AuthFail_2;
u16 AuthFail_3;
u16 AuthFail_4;
u16 AuthFail_5;
u16 AuthFail_6;
u16 AuthFail_7;
u16 AuthFail_8;
u16 AuthFail_9;
u16 AuthFail_10;
u16 AuthFail_11;
u16 AuthFail_12;
u16 AuthFail_13;
u16 AuthFail_14;
u16 AuthFail_15;
u16 AuthFail_16;
u16 AuthFail_17;
u16 AuthFail_18;
u16 AuthFail_19;
u16 RxMan;
u16 TxMan;
u16 RxRefresh;
u16 TxRefresh;
u16 RxPoll;
u16 TxPoll;
u16 HostRetries;
u16 LostSync_HostReq;
u16 HostTxBytes;
u16 HostRxBytes;
u16 ElapsedUsec;
u16 ElapsedSec;
u16 LostSyncBett;
};
#define AWC_TXCTL_TXOK (1<<1) /* report if tx is ok */
#define AWC_TXCTL_TXEX (1<<2) /* report if tx fails */
#define AWC_TXCTL_802_3 (0<<3) /* 802.3 packet */
#define AWC_TXCTL_802_11 (1<<3) /* 802.11 mac packet */
#define AWC_TXCTL_ETHERNET (0<<4) /* payload has ethertype */
#define AWC_TXCTL_LLC (1<<4) /* payload is llc */
#define AWC_TXCTL_RELEASE (0<<5) /* release after completion */
#define AWC_TXCTL_NORELEASE (1<<5) /* on completion returns to host */
/************************* LINK STATUS STUFF *******************/
#define awc_link_status_loss_of_sync_missed_beacons 0x8000
#define awc_link_status_loss_of_sync_max_retries 0x8001
#define awc_link_status_loss_of_sync_ARL_exceed 0x8002
#define awc_link_status_loss_of_sync_host_request 0x8003
#define awc_link_status_loss_of_sync_TSF_sync 0x8004
#define awc_link_status_deauthentication 0x8100
#define awc_link_status_disassociation 0x8200
#define awc_link_status_association_failed 0x8400
#define awc_link_status_authentication_failed 0x0300
#define awc_link_status_associated 0x0400
struct awc_strings {
int par;
unsigned int mask;
const char * string;
};
#define awc_link_status_strings {\
{awc_link_status_loss_of_sync_missed_beacons, 0xFFFF,"Loss of sync -- missed beacons"},\
{awc_link_status_loss_of_sync_max_retries, 0xFFFF,"Loss of sync -- max retries"},\
{awc_link_status_loss_of_sync_ARL_exceed, 0xFFFF,"Loss of sync -- average retry level (ARL) exceeded"},\
{awc_link_status_loss_of_sync_host_request, 0xFFFF,"Loss of sync -- host request"},\
{awc_link_status_loss_of_sync_TSF_sync, 0xFFFF,"Loss of sync -- TSF synchronization"},\
{awc_link_status_deauthentication, 0xFF00,"Deauthentication "},\
{awc_link_status_disassociation, 0xFF00,"Disassocation "},\
{awc_link_status_association_failed , 0xFF00,"Association failed "},\
{awc_link_status_authentication_failed, 0xFF00,"Authentication failure"},\
{awc_link_status_associated, 0xFFFF,"Associated "},\
{0,0,NULL}\
}
/****************************** COMMANDS and DEFAULTS and STATUSES ***********/
/****************************** COMMANDS */
// Command definitions
#define awc4500wout(base, com, p0,p1,p2) {\
awc_write(base,awc_Param0_register, p0);\
awc_write(base,awc_Param1_register, p1);\
awc_write(base,awc_Param2_register, p2);\
WAIT61x3;\
awc_write(base,awc_Command_register, com);\
WAIT61x3;\
}
#define awc_wout(cmd, com, p0,p1,p2) {\
awc_write(base,awc_Param0_register, p0);\
awc_write(base,awc_Param1_register, p1);\
awc_write(base,awc_Param2_register, p2);\
WAIT61x3;\
awc_write(base,awc_Command_register, com);\
WAIT61x3;\
}
#define awc_command_NOP(cmd) awc_wout( cmd,0x0000,0,0,0) // NOP
#define awc_command_Enable_All(cmd) awc_wout( cmd,0x0001,0,0,0) // Enable
#define awc_command_Enable_MAC(cmd) awc_wout( cmd,0x0101,0,0,0) // Enable Mac
#define awc_command_Enable_Rx(cmd) awc_wout( cmd,0x0201,0,0,0) // Enable Rx
#define awc_command_Disable_MAC(cmd) awc_wout( cmd,0x0002,0,0,0) // Disable
#define awc_command_Sync_Loss(cmd) awc_wout( cmd,0x0003,0,0,0) // Force a Loss of Sync
#define awc_command_Soft_Reset(cmd) awc_wout( cmd,0x0004,0,0,0) // Firmware Restart (soft reset)
#define awc_command_Host_Sleep(cmd) awc_wout( cmd,0x0005,0,0,0) // Host Sleep (must be issued as 0x0085)
#define awc_command_Magic_Packet(cmd) awc_wout( cmd,0x0006,0,0,0) // Magic Packet
#define awc_command_Read_Configuration(cmd) awc_wout( cmd,0x0008,0,0,0) // Read the Configuration from nonvolatile storage
#define awc_command_Allocate_TX_Buff(cmd,size) awc_wout( cmd,0x000A,size,0,0) // Allocate Transmit Buffer
#define awc_command_TX(cmd,FID) awc_wout( cmd,0x000B,FID ,0,0) // Transmit
#define awc_command_Deallocate(cmd,FID) awc_wout( cmd,0x000C,FID ,0,0) // Deallocate
#define awc_command_NOP2(cmd) awc_wout( cmd,0x0010,0,0,0) // NOP (same as 0x0000)
#define awc_command_Read_RID(cmd,RID) awc_wout( cmd,0x0021,RID ,0,0) // Read RID
#define awc_command_Write_RID(cmd,RID) awc_wout( cmd,0x0121,RID ,0,0) // Write RID
#define awc_command_Allocate_Buff(cmd,size) awc_wout( cmd,0x0028,size,0,0) // Allocate Buffer
#define awc_command_PSP_Nodes(cmd) awc_wout( cmd,0x0030,0,0,0) // PSP nodes (AP only)
#define awc_command_Set_Phy_register(cmd,phy_register,clear_bits, set_bits)\
awc_wout( cmd,0x003E,phy_register,clear_bits, set_bits) // Set PHY register
#define awc_command_TX_Test(cmd,command, frequency, pattern) awc_wout( cmd,0x003F,command, frequency, pattern) // Transmitter Test
#define awc_command_RX_Test(cmd) awc_wout( cmd,0x013F,0,0,0) // RX Test
#define awc_command_Sleep(cmd) awc_wout( cmd,0x0085,0,0,0) // Go to Sleep (No Ack bit is mandatory)
#define awc_command_Save_Configuration(cmd) awc_wout( cmd,0x0108,0,0,0) // Save the configuration to nonvolatile
#define AWC_COMMAND_NOOP_BULL 0x000
#define AWC_COMMAND_ENABLE 0x001
#define AWC_COMMAND_ENABLE_MAC 0x101
#define AWC_COMMAND_ENABLE_RX 0x201
#define AWC_COMMAND_DISABLE 0x002
#define AWC_COMMAND_LOSE_SYNC 0x003
#define AWC_COMMAND_SOFT_RESET 0x004
#define AWC_COMMAND_HOST_SLEEP 0x085
#define AWC_COMMAND_MAGIC_PACKET 0x006
#define AWC_COMMAND_READ_CONF 0x008
#define AWC_COMMAND_SAVE_CONF 0x108
#define AWC_COMMAND_TX_ALLOC 0x00A
#define AWC_COMMAND_TX 0x00B
#define AWC_COMMAND_DEALLOC 0x00C
#define AWC_COMMAND_NOOP 0x010
#define AWC_COMMAND_READ_RID 0x021
#define AWC_COMMAND_WRITE_RID 0x121
#define AWC_COMMAND_ALLOC 0x028
#define AWC_COMMAND_PSP_NODES 0x030
#define AWC_COMMAND_SET_PHY 0x03E
#define AWC_COMMAND_TX_TEST 0x03F
#define AWC_COMMAND_SLEEP 0x085
#define awc_command_name_strings {\
{0x0000, 0x00FF,"awc_command_NOP " },\
{0x0001, 0x00FF,"awc_command_Enable_All " },\
{0x0101, 0x01FF,"awc_command_Enable_MAC " },\
{0x0201, 0x01FF,"awc_command_Enable_Rx " },\
{0x0002, 0x00FF,"awc_command_Disable_MAC " },\
{0x0003, 0x00FF,"awc_command_Sync_Loss " },\
{0x0004, 0x00FF,"awc_command_Soft_Reset " },\
{0x0005, 0x00FF,"awc_command_Host_Sleep " },\
{0x0006, 0x00FF,"awc_command_Magic_Packet " },\
{0x0008, 0x00FF,"awc_command_Read_Configuration " },\
{0x000A, 0x00FF,"awc_command_Allocate_TX_Buff " },\
{0x000B, 0x00FF,"awc_command_TX " },\
{0x000C, 0x00FF,"awc_command_Deallocate " },\
{0x0010, 0x00FF,"awc_command_NOP2 " },\
{0x0021, 0x00FF,"awc_command_Read_RID " },\
{0x0121, 0x01FF,"awc_command_Write_RID " },\
{0x0028, 0x00FF,"awc_command_Allocate_Buff " },\
{0x0030, 0x00FF,"awc_command_PSP_Nodes " },\
{0x003E, 0x00FF,"awc_command_Set_Phy_register " },\
{0x003F, 0x00FF,"awc_command_TX_Test " },\
{0x013F, 0x01FF,"awc_command_RX_Test " },\
{0x0085, 0x00FF,"awc_command_Sleep " },\
{0x0108, 0x01FF,"awc_command_Save_Configuration " },\
{0x0000, 0x00FF, NULL}\
};
/***************************** STATUSES */
#define awc_reply_success 0x0000
#define awc_reply_error_strings {\
{ 0x0000, 0x00FF," Success"},\
{ 0x0001, 0x00FF," Illegal command."},\
{ 0x0002, 0x00FF," Illegal format."},\
{ 0x0003, 0x00FF," Invalid FID."},\
{ 0x0004, 0x00FF," Invalid RID."},\
{ 0x0005, 0x00FF," Too Large"},\
{ 0x0006, 0x00FF," MAC is not disabled."},\
{ 0x0007, 0x00FF," Alloc is still busy processing previous alloc"},\
{ 0x0008, 0x00FF," Invalid Mode Field"},\
{ 0x0009, 0x00FF," Tx is not allowed in monitor mode"},\
{ 0x000A, 0x00FF," Loop test or memory test error"},\
{ 0x000B, 0x00FF," Cannot read this RID."},\
{ 0x000C, 0x00FF," Cannot write to this RID."},\
{ 0x000D, 0x00FF," Tag not found."},\
{ 0x0080, 0x00FF," Config mode is invalid."},\
{ 0x0081, 0x00FF," Config hop interval is invalid."},\
{ 0x0082, 0x00FF," Config beacon interval is invalid."},\
{ 0x0083, 0x00FF," Config receive mode is invalid."},\
{ 0x0084, 0x00FF," Config MAC address is invalid."},\
{ 0x0085, 0x00FF," Config rates are invalid."},\
{ 0x0086, 0x00FF," Config ordering field is invalid."},\
{ 0x0087, 0x00FF," Config scan mode is invalid."},\
{ 0x0088, 0x00FF," Config authentication type is invalid."},\
{ 0x0089, 0x00FF," Config power save mode is invalid."},\
{ 0x008A, 0x00FF," Config radio type is invalid."},\
{ 0x008B, 0x00FF," Config diversity is invalid."},\
{ 0x008C, 0x00FF," Config SSID list is invalid."},\
{ 0x008D, 0x00FF," Config specified AP list is invalid."},\
{ 0x0000, 0x00FF, NULL}\
};
#define awc_reply_command_failed( status) ((status & 0x7F00) == 0x7F)
/************************* PHY and TEST commands ****************/
// this might be wrong and reading is not implemented(was not in spec properly)
#define awc_Set_PLCP_Word(PLCP_Word)\
awc_command_Set_Phy_register(base,0x8000,0 ,PLCP_Word)
#define awc_Set_TX_Test_Freq(Tx_Test_Freq)\
awc_command_Set_Phy_register(base,0x8002,0 ,Tx_Test_Freq)
#define awc_Set_Tx_Power(Tx_Power)\
awc_command_Set_Phy_register(base,0x8004,0 ,Tx_Power)
#define awc_Set_RSSI_Treshold(RSSI_Treshold)\
awc_command_Set_Phy_register(base,0x8006,0 ,RSSI_Treshold)
#define awc_Get_PLCP_Word(PLCP_Word)\
awc_command_Set_Phy_register(base,0x8000,0 ,0)
#define awc_Get_TX_Test_Freq(Tx_Test_Freq)\
awc_command_Set_Phy_register(base,0x8002,0 ,0)
#define awc_Get_Tx_Power(Tx_Power)\
awc_command_Set_Phy_register(base,0x8004,0 ,0)
#define awc_Get_RSSI_Treshold(RSSI_Treshold)\
awc_command_Set_Phy_register(base,0x8006,0 ,0)
#define awc_tx_test_code_end 0x0000 // Ends the transmitter test
#define awc_tx_test_code_loop 0x0001 // Loop back to the beginning of the commands
#define awc_tx_test_code_start 0x0002 // Start transmitting
#define awc_tx_test_code_stop 0x0003 // Stop transmitting
#define awc_tx_test_code_delayu 0x0004 // Delay for N usec where N is the next word
#define awc_tx_test_code_delayk 0x0005 // Delay for N Kusec where N is the next word
#define awc_tx_test_code_next 0x0006 // Go to the next frequency in the frequency RID
#define awc_tx_test_code_rx 0x0007 // Start receive mode
#define awc_tx_test_code_strings {\
{ awc_tx_test_code_end , 0x000f ," Ends the transmitter test"},\
{ awc_tx_test_code_loop , 0x000f ," Loop back to the beginning of the commands"},\
{ awc_tx_test_code_start , 0x000f ," Start transmitting"},\
{ awc_tx_test_code_stop , 0x000f ," Stop transmitting"},\
{ awc_tx_test_code_delayu , 0x000f ," Delay for N usec where N is the next word"},\
{ awc_tx_test_code_delayk , 0x000f ," Delay for N Kusec where N is the next word"},\
{ awc_tx_test_code_next , 0x000f ," Go to the next frequency in the frequency RID"},\
{ awc_tx_test_code_rx , 0x000f ," Start receive mode"},\
{ 0 , 0x000f ,NULL}\
};
#define AWC_COMMSTAT_HARD_RESET 0x0000001
#define AWC_COMMSTAT_WAKE 0x0000002
#define AWC_COMMSTAT_SOFT_RESET 0x0000004
#define AWC_COMMSTAT_CONFIGURE 0x0000008
#define AWC_COMMSTAT_READ_CONF 0x0000010
#define AWC_COMMSTAT_SAVE_CONF 0x0000020
#define AWC_COMMSTAT_DEALLOC 0x0000040
#define AWC_COMMSTAT_ALLOC_TX 0x0000080
#define AWC_COMMSTAT_ALLOC_TEST 0x0000100
#define AWC_COMMSTAT_ENABLE_MAC 0x0000200
#define AWC_COMMSTAT_ENABLE_RX 0x0000400
#define AWC_COMMSTAT_DISABLE_MAC 0x0000800
#define AWC_COMMSTAT_RX_ACK 0x0001000
#define AWC_COMMSTAT_TX_ACK 0x0002000
#define AWC_COMMSTAT_AWAKEN_ACK 0x0004000
#define AWC_COMMSTAT_TX_FAIL_ACK 0x0008000
#define AWC_COMMSTAT_LINK_ACK 0x0010000
#define AWC_COMMSTAT_CLR_CMD 0x0020000
#define AWC_COMMSTAT_ALLOC_ACK 0x0040000
#define AWC_COMMSTAT_HOST_SLEEP 0x0080000
#define AWC_COMMSTAT_RX 0x0100000
#define AWC_COMMSTAT_TX 0x0200000
#define AWC_COMMSTAT_SLEEP 0x0400000
#define AWC_COMMSTAT_PSP_NODES 0x0800000
#define AWC_COMMSTAT_SET_TX_POWER 0x1000000
/***************************** R I D ***************/
#define AWC_NOF_RIDS 18
extern int awc_rid_setup(struct net_device * dev);
struct aironet4500_rid_selector{
const u16 selector;
const unsigned MAC_Disable_at_write:1;
const unsigned read_only:1;
const unsigned may_change:1;
const char * name;
};
extern const struct aironet4500_rid_selector aironet4500_RID_Select_General_Config;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_SSID_list;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_AP_list ;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_Driver_name;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_Encapsulation;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_Active_Config;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_Capabilities;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_AP_Info ;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_Radio_Info;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_Status ;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_Modulation ;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_WEP_volatile ;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_WEP_nonvolatile ;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_16_stats;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_16_stats_delta;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_16_stats_clear;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_32_stats;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_32_stats_delta;
extern const struct aironet4500_rid_selector aironet4500_RID_Select_32_stats_clear;
#define awc_def_gen_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_General_Config,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_SSID_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_SSID_list,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_AP_List_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_AP_list,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_Dname_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_Driver_name,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_act_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_Active_Config,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_Cap_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_Capabilities,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_AP_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_AP_Info,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_Radio_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_Radio_Info,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_Stat_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_Status,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_Enc_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_Encapsulation,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_WEPv_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_WEP_volatile,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_WEPnv_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_WEP_nonvolatile,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_Modulation_RID(offset,name, bits,mask,value,value_name)\
{&aironet4500_RID_Select_Modulation,offset, bits,1,1,0,0, mask, value, name, value_name}
#define awc_def_Stats_RID(o16,offset,name, value_name)\
{&aironet4500_RID_Select_32_stats,offset, 32,1,1,0,0, 0xffffffff, 0, name, value_name}
#define awc_def_Stats_delta_RID(o16,offset,name, value_name)\
{&aironet4500_RID_Select_32_stats_delta,offset, 32,1,1,0,0, 0xffffffff, 0, name, value_name}
#define awc_def_Stats_clear_RID(o16,offset,name, value_name)\
{&aironet4500_RID_Select_32_stats_delta,offset,32,1,1,0,0, 0xffffffff, 0, name,value_name}
#define awc_def_Stats16_RID(offset,o32,name, value_name)\
{&aironet4500_RID_Select_16_stats,offset, 16,1,1,0,0, 0xffffffff, 0, name, value_name}
#define awc_def_Stats16_delta_RID(offset,o32,name, value_name)\
{&aironet4500_RID_Select_16_stats_delta,offset, 16,1,1,0,0, 0xffffffff, 0, name,value_name}
#define awc_def_Stats16_clear_RID(offset,o32,name, value_name)\
{&aironet4500_RID_Select_16_stats_delta,offset, 16,1,1,0,0, 0xffffffff, 0, name,value_name}
#define aironet4500_RID_Select_strings {\
{ 0xFF10, 0xffff, "General Configuration"},\
{ 0xFF11, 0xffff, "Valid SSID list" },\
{ 0xFF12, 0xffff, "Valid AP list"},\
{ 0xFF13, 0xffff, "Driver name"},\
{ 0xFF14, 0xffff, "Ethernet Protocol"},\
{ 0xFF15, 0xffff, "WEP volatile"},\
{ 0xFF16, 0xffff, "WEP nonvolatile"},\
{ 0xFF17, 0xffff, "Modulation"},\
{ 0xFF20, 0xffff, "Actual Configuration"},\
{ 0xFF00, 0xffff, "Capabilities"},\
{ 0xFF01, 0xffff, "AP Info"},\
{ 0xFF02, 0xffff, "Radio Info"},\
{ 0xFF50, 0xffff, "Status"},\
{ 0xFF60, 0xffff, "Cumulative 16-bit Statistics"},\
{ 0xFF61, 0xffff, "Delta 16-bit Statistics"},\
{ 0xFF62, 0xffff, "Delta 16-bit Statistics and Clear"},\
{ 0xFF68, 0xffff, "Cumulative 32-bit Statistics"},\
{ 0xFF69, 0xffff, "Delta 32-bit Statistics "},\
{ 0xFF6A, 0xffff, "Delta 32-bit Statistics and Clear"},\
{ 0x0000, 0xffff, NULL}\
}
struct aironet4500_RID {
const struct aironet4500_rid_selector * selector;
const u32 offset;
const u8 bits;
const u8 array;
const u32 units;
const unsigned read_only:1;
const unsigned null_terminated:1;
const u32 mask;
const u32 value;
const char * name;
const char * value_name;
};
struct aironet4500_RID_names{
struct aironet4500_RID rid;
char *name;
};
struct aironet4500_RID_names_values{
struct aironet4500_RID rid;
char *name;
u32 mask;
};
struct awc_rid_dir{
const struct aironet4500_rid_selector * selector;
const int size;
const struct aironet4500_RID * rids;
struct net_device * dev ;
void * buff;
int bufflen; // just checking
};
extern int awc_nof_rids;
extern struct awc_rid_dir awc_rids[];
struct awc_private {
dev_node_t node; // somewhere back in times PCMCIA needed that
int dummy_test; // left for cleanup
// card rid inmemory copy
struct awc_config config; // card RID mirrors
struct awc_config general_config; //
struct awc_SSIDs SSIDs;
struct awc_fixed_APs fixed_APs;
struct awc_driver_name driver_name;
struct awc_enc_trans enc_trans;
struct awc_cap capabilities;
struct awc_status status;
struct awc_AP AP;
struct awc_Statistics_32 statistics;
struct awc_Statistics_32 statistics_delta;
struct awc_Statistics_32 statistics_delta_clear;
struct awc_Statistics_16 statistics16;
struct awc_Statistics_16 statistics16_delta;
struct awc_Statistics_16 statistics16_delta_clear;
struct awc_wep_key wep_volatile;
struct awc_wep_key wep_nonvolatile;
struct awc_modulation modulation;
// here are just references to rids
struct awc_rid_dir rid_dir[AWC_NOF_RIDS];
int rids_read;
struct awc_bap bap0;
struct awc_bap bap1;
int sleeping_bap;
struct awc_fid_queue tx_small_ready;
struct awc_fid_queue tx_large_ready;
struct awc_fid_queue tx_post_process;
struct awc_fid_queue tx_in_transmit;
spinlock_t queues_lock;
struct awc_fid_queue rx_ready;
struct awc_fid_queue rx_post_process;
struct semaphore tx_buff_semaphore;
volatile int tx_buffs_in_use;
volatile int tx_small_buffs_in_use;
volatile int tx_buffs_total;
volatile int tx_small_buffs_total;
int large_buff_mem;
int small_buff_no;
volatile int mac_enabled;
u16 link_status;
u8 link_status_changed;
volatile int ejected;
volatile int work_running;
volatile int work_active;
volatile long tx_chain_active;
volatile u16 enabled_interrupts;
volatile u16 waiting_interrupts;
volatile int interrupt_count;
// Command serialize stuff
//changed to spinlock struct semaphore command_semaphore;
spinlock_t both_bap_spinlock; // on SMP, card should theorethically live without that
unsigned long both_bap_spinlock_flags;
spinlock_t bap_setup_spinlock; // on SMP, card should theoretically live without that
unsigned long bap_setup_spinlock_flags;
spinlock_t command_issuing_spinlock;
unsigned long command_issuing_spinlock_flags;
spinlock_t interrupt_spinlock;
volatile int unlock_command_postponed;
struct awc_command cmd;
long long async_command_start;
volatile int command_semaphore_on;
struct work_struct work;
volatile int process_tx_results;
u8 p2p[6];
u8 bssid[6];
int p2p_uc;
int p2p_found;
int p802_11_send;
int simple_bridge;
int force_rts_on_shorter;
int force_tx_rate;
int ip_tos_reliability_rts;
int ip_tos_troughput_no_retries;
int full_stats;
int debug;
struct net_device_stats stats;
struct ctl_table * proc_table;
void * bus;
int card_type;
};
extern int awc_init(struct net_device * dev);
extern void awc_reset(struct net_device *dev);
extern int awc_config(struct net_device *dev);
extern int awc_open(struct net_device *dev);
extern void awc_tx_timeout(struct net_device *dev);
extern int awc_start_xmit(struct sk_buff *, struct net_device *);
extern void awc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
extern struct net_device_stats * awc_get_stats(struct net_device *dev);
extern void awc_set_multicast_list(struct net_device *dev);
extern int awc_change_mtu(struct net_device *dev, int new_mtu);
extern int awc_close(struct net_device *dev);
extern int awc_private_init(struct net_device * dev);
extern int awc_register_proc(int (*awc_proc_set_device) (int),int (*awc_proc_unset_device)(int));
extern int awc_unregister_proc(void);
extern int (* awc_proc_set_fun) (int) ;
extern int (* awc_proc_unset_fun) (int) ;
extern int awc_interrupt_process(struct net_device * dev);
extern int awc_readrid(struct net_device * dev, struct aironet4500_RID * rid, void *pBuf );
extern int awc_writerid(struct net_device * dev, struct aironet4500_RID * rid, void *pBuf);
extern int awc_readrid_dir(struct net_device * dev, struct awc_rid_dir * rid );
extern int awc_writerid_dir(struct net_device * dev, struct awc_rid_dir * rid);
extern int awc_tx_alloc(struct net_device * dev) ;
extern int awc_tx_dealloc(struct net_device * dev);
extern struct awc_fid *awc_tx_fid_lookup(struct net_device * dev, u16 fid);
extern int awc_issue_soft_reset(struct net_device * dev);
extern int awc_issue_noop(struct net_device * dev);
extern int awc_dump_registers(struct net_device * dev);
extern unsigned short awc_issue_command_and_block(struct awc_command * cmd);
extern int awc_enable_MAC(struct net_device * dev);
extern int awc_disable_MAC(struct net_device * dev);
extern int awc_read_all_rids(struct net_device * dev);
extern int awc_write_all_rids(struct net_device * dev);
extern int awc_receive_packet(struct net_device * dev);
extern int awc_transmit_packet(struct net_device * dev, struct awc_fid * tx_buff) ;
extern int awc_tx_complete_check(struct net_device * dev);
extern int awc_interrupt_process(struct net_device * dev);
extern void awc_work(struct net_device *dev);
extern int awc_802_11_find_copy_path(struct net_device * dev, struct awc_fid * rx_buff);
extern void awc_802_11_router_rx(struct net_device * dev,struct awc_fid * rx_buff);
extern int awc_802_11_tx_find_path_and_post(struct net_device * dev, struct sk_buff * skb);
extern void awc_802_11_after_tx_packet_to_card_write(struct net_device * dev, struct awc_fid * tx_buff);
extern void awc_802_11_after_failed_tx_packet_to_card_write(struct net_device * dev,struct awc_fid * tx_buff);
extern void awc_802_11_after_tx_complete(struct net_device * dev, struct awc_fid * tx_buff);
extern void awc_802_11_failed_rx_copy(struct net_device * dev,struct awc_fid * rx_buff);
extern int awc_tx_alloc(struct net_device * dev) ;
extern int awc_tx_dealloc_fid(struct net_device * dev,struct awc_fid * fid);
extern int awc_tx_dealloc(struct net_device * dev);
extern struct awc_fid *
awc_tx_fid_lookup_and_remove(struct net_device * dev, u16 fid_handle);
extern int awc_queues_init(struct net_device * dev);
extern int awc_queues_destroy(struct net_device * dev);
extern int awc_rids_setup(struct net_device * dev);
extern int awc_debug;
extern int bap_sleep ;
extern int bap_sleep_after_setup ;
extern int sleep_before_command ;
extern int bap_sleep_before_write;
extern int sleep_in_command ;
extern int both_bap_lock;
extern int bap_setup_spinlock;
extern int tx_queue_len ;
extern int tx_rate;
extern int awc_full_stats;
#define MAX_AWCS 4
extern struct net_device * aironet4500_devices[MAX_AWCS];
#define AWC_DEBUG 1
#ifdef AWC_DEBUG
#define DEBUG(a,args...) if (awc_debug & a) printk( args)
#define AWC_ENTRY_EXIT_DEBUG(a) if (awc_debug & 8) printk( a)
#else
#define DEBUG(a, args...)
#define AWC_ENTRY_EXIT_DEBUG(a)
#endif
#endif /* AIRONET4500_H */
/*
* Aironet 4500 PCI-ISA-i365 driver
*
* Elmer Joandi, Januar 1999
* Copyright GPL
*
*
* Revision 0.1 ,started 30.12.1998
*
* Revision 0.2, Feb 27, 2000
* Jeff Garzik - softnet, cleanups
*
*/
#ifdef MODULE
static const char *awc_version =
"aironet4500_cards.c v0.2 Feb 27, 2000 Elmer Joandi, elmer@ylenurme.ee.\n";
#endif
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/config.h>
#include <linux/if_arp.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/interrupt.h>
#include <linux/in.h>
#include <linux/version.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/bitops.h>
#include "aironet4500.h"
#define PCI_VENDOR_ID_AIRONET 0x14b9
#define PCI_DEVICE_AIRONET_4800_1 0x1
#define PCI_DEVICE_AIRONET_4800 0x4500
#define PCI_DEVICE_AIRONET_4500 0x4800
#define AIRONET4X00_IO_SIZE 0x40
#define AIRONET4X00_CIS_SIZE 0x300
#define AIRONET4X00_MEM_SIZE 0x300
#define AIRONET4500_PCI 1
#define AIRONET4500_PNP 2
#define AIRONET4500_ISA 3
#define AIRONET4500_365 4
#ifdef CONFIG_AIRONET4500_PCI
#include <linux/pci.h>
static struct pci_device_id aironet4500_card_pci_tbl[] __devinitdata = {
{ PCI_VENDOR_ID_AIRONET, PCI_DEVICE_AIRONET_4800_1, PCI_ANY_ID, PCI_ANY_ID, },
{ PCI_VENDOR_ID_AIRONET, PCI_DEVICE_AIRONET_4800, PCI_ANY_ID, PCI_ANY_ID, },
{ PCI_VENDOR_ID_AIRONET, PCI_DEVICE_AIRONET_4500, PCI_ANY_ID, PCI_ANY_ID, },
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(pci, aironet4500_card_pci_tbl);
MODULE_LICENSE("GPL");
static int awc_pci_init(struct net_device * dev, struct pci_dev *pdev,
int ioaddr, int cis_addr, int mem_addr,u8 pci_irq_line) ;
int awc4500_pci_probe(struct net_device *dev)
{
int cards_found = 0;
u8 pci_irq_line = 0;
// int p;
struct pci_dev *pdev = NULL;
if (!pci_present())
return -1;
while ((pdev = pci_find_class (PCI_CLASS_NETWORK_OTHER << 8, pdev))) {
u16 pci_command, new_command;
u32 pci_memaddr;
u32 pci_ioaddr;
u32 pci_cisaddr;
if (pdev->vendor != PCI_VENDOR_ID_AIRONET)
continue;
if ((pdev->device != PCI_DEVICE_AIRONET_4800_1) &&
(pdev->device != PCI_DEVICE_AIRONET_4800) &&
(pdev->device != PCI_DEVICE_AIRONET_4500))
continue;
if (pci_enable_device(pdev))
continue;
pci_irq_line = pdev->irq;
pci_memaddr = pci_resource_start (pdev, 0);
pci_cisaddr = pci_resource_start (pdev, 1);
pci_ioaddr = pci_resource_start (pdev, 2);
// printk("\n pci capabilities %x and ptr %x \n",pci_caps,pci_caps_ptr);
/* Remove I/O space marker in bit 0. */
// if (check_region(pci_ioaddr, AIRONET4X00_IO_SIZE) ||
// check_region(pci_cisaddr, AIRONET4X00_CIS_SIZE) ||
// check_region(pci_memaddr, AIRONET4X00_MEM_SIZE)) {
// printk(KERN_ERR "aironet4X00 mem addrs not available for maping \n");
// continue;
// }
if (!request_region(pci_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr"))
continue;
// request_region(pci_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis");
// request_region(pci_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem");
mdelay(10);
pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
new_command = pci_command | PCI_COMMAND_SERR;
if (pci_command != new_command)
pci_write_config_word(pdev, PCI_COMMAND, new_command);
/* if (device == PCI_DEVICE_AIRONET_4800)
pci_write_config_dword(pdev, 0x40, 0x00000000);
udelay(1000);
*/
if (pdev->device == PCI_DEVICE_AIRONET_4800)
pci_write_config_dword(pdev, 0x40, 0x40000000);
if (awc_pci_init(dev, pdev, pci_ioaddr,pci_cisaddr,pci_memaddr,pci_irq_line)){
printk(KERN_ERR "awc4800 pci init failed \n");
break;
}
dev = 0;
cards_found++;
}
return cards_found ? 0 : -ENODEV;
}
static int awc_pci_init(struct net_device * dev, struct pci_dev *pdev,
int ioaddr, int cis_addr, int mem_addr, u8 pci_irq_line) {
int i, allocd_dev = 0;
if (!dev) {
dev = init_etherdev(NULL, 0);
if (!dev)
return -ENOMEM;
allocd_dev = 1;
}
dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL );
if (!dev->priv) {
if (allocd_dev) {
unregister_netdev(dev);
kfree(dev);
}
return -ENOMEM;
}
memset(dev->priv,0,sizeof(struct awc_private));
if (!dev->priv) {
printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n");
if (allocd_dev) {
unregister_netdev(dev);
kfree(dev);
}
return -ENOMEM;
};
// ether_setup(dev);
// dev->tx_queue_len = tx_queue_len;
dev->hard_start_xmit = &awc_start_xmit;
// dev->set_config = &awc_config_misiganes,aga mitte awc_config;
dev->get_stats = &awc_get_stats;
// dev->set_multicast_list = &awc_set_multicast_list;
dev->change_mtu = awc_change_mtu;
dev->init = &awc_init;
dev->open = &awc_open;
dev->stop = &awc_close;
dev->base_addr = ioaddr;
dev->irq = pci_irq_line;
dev->tx_timeout = &awc_tx_timeout;
dev->watchdog_timeo = AWC_TX_TIMEOUT;
i = request_irq(dev->irq,awc_interrupt, SA_SHIRQ | SA_INTERRUPT, dev->name, dev);
if (i) {
kfree(dev->priv);
dev->priv = NULL;
if (allocd_dev) {
unregister_netdev(dev);
kfree(dev);
}
return i;
}
awc_private_init( dev);
awc_init(dev);
i=0;
while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
if (!aironet4500_devices[i]){
aironet4500_devices[i]=dev;
((struct awc_private *)
aironet4500_devices[i]->priv)->card_type = AIRONET4500_PCI;
if (awc_proc_set_fun)
awc_proc_set_fun(i);
}
// if (register_netdev(dev) != 0) {
// printk(KERN_NOTICE "awc_cs: register_netdev() failed\n");
// goto failed;
// }
return 0;
// failed:
// return -1;
}
#ifdef MODULE
static void awc_pci_release(void) {
// long flags;
int i=0;
DEBUG(0, "awc_detach \n");
i=0;
while ( i < MAX_AWCS) {
if (!aironet4500_devices[i])
{i++; continue;};
if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_PCI)
{i++; continue;}
if (awc_proc_unset_fun)
awc_proc_unset_fun(i);
release_region(aironet4500_devices[i]->base_addr, AIRONET4X00_IO_SIZE);
// release_region(pci_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis");
// release_region(pci_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem");
unregister_netdev(aironet4500_devices[i]);
free_irq(aironet4500_devices[i]->irq,aironet4500_devices[i]);
kfree(aironet4500_devices[i]->priv);
kfree(aironet4500_devices[i]);
aironet4500_devices[i]=0;
i++;
}
}
#endif //MODULE
#endif /* CONFIG_AIRONET4500_PCI */
#ifdef CONFIG_AIRONET4500_PNP
#include <linux/isapnp.h>
#define AIRONET4X00_IO_SIZE 0x40
#define isapnp_logdev pnp_dev
#define isapnp_dev pnp_card
#define isapnp_find_device pnp_find_card
#define isapnp_find_logdev pnp_find_dev
#define PNP_BUS card
#define PNP_BUS_NUMBER number
#define PNP_DEV_NUMBER number
int awc4500_pnp_hw_reset(struct net_device *dev){
struct isapnp_logdev *logdev;
DEBUG(0, "awc_pnp_reset \n");
if (!dev->priv ) {
printk("awc4500 no dev->priv in hw_reset\n");
return -1;
};
logdev = ((struct isapnp_logdev *) ((struct awc_private *)dev->priv)->bus);
if (!logdev ) {
printk("awc4500 no pnp logdev in hw_reset\n");
return -1;
};
pnp_disable_dev(logdev);
udelay(100);
if (pnp_activate_dev(logdev, NULL) < 0) {
printk("%s cfg begin failed in hw_reset for csn %x devnum %x \n",
dev->name, logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER);
return -EAGAIN;
}
return 0;
}
int awc4500_pnp_probe(struct net_device *dev)
{
int isa_index = 0;
int isa_irq_line = 0;
int isa_ioaddr = 0;
int card = 0;
int i=0;
struct isapnp_dev * pnp_dev ;
struct isapnp_logdev *logdev;
while (1) {
pnp_dev = isapnp_find_device(
ISAPNP_VENDOR('A','W','L'),
ISAPNP_DEVICE(1),
0);
if (!pnp_dev) break;
isa_index++;
logdev = isapnp_find_logdev(pnp_dev, ISAPNP_VENDOR('A','W','L'),
ISAPNP_FUNCTION(1),
0);
if (!logdev){
printk("No logical device found on Aironet board \n");
return -ENODEV;
}
if (pnp_device_attach(logdev) < 0) {
printk("pnp_device_attach failed for csn %x devnum %x \n",
logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER);
return -EAGAIN;
}
if (pnp_activate_dev(logdev, NULL) < 0) {
printk("pnp_activate_dev failed for csn %x devnum %x \n",
logdev->PNP_BUS->PNP_BUS_NUMBER, logdev->PNP_DEV_NUMBER);
pnp_device_detach(logdev);
return -EIO;
}
isa_irq_line = pnp_irq(logdev, 0);
isa_ioaddr = pnp_port_start(logdev, 0);
request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr");
if (!dev) {
dev = init_etherdev(NULL, 0);
if (!dev) {
release_region(isa_ioaddr, AIRONET4X00_IO_SIZE);
pnp_device_detach(logdev);
return -ENOMEM;
}
}
dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL );
memset(dev->priv,0,sizeof(struct awc_private));
if (!dev->priv) {
printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n");
return -1;
};
((struct awc_private *)dev->priv)->bus = logdev;
// ether_setup(dev);
// dev->tx_queue_len = tx_queue_len;
dev->hard_start_xmit = &awc_start_xmit;
// dev->set_config = &awc_config_misiganes,aga mitte awc_config;
dev->get_stats = &awc_get_stats;
// dev->set_multicast_list = &awc_set_multicast_list;
dev->change_mtu = awc_change_mtu;
dev->init = &awc_init;
dev->open = &awc_open;
dev->stop = &awc_close;
dev->base_addr = isa_ioaddr;
dev->irq = isa_irq_line;
dev->tx_timeout = &awc_tx_timeout;
dev->watchdog_timeo = AWC_TX_TIMEOUT;
netif_start_queue (dev);
request_irq(dev->irq,awc_interrupt , SA_SHIRQ | SA_INTERRUPT ,"Aironet 4X00",dev);
awc_private_init( dev);
((struct awc_private *)dev->priv)->bus = logdev;
cli();
if ( awc_init(dev) ){
printk("card not found at irq %x io %lx\n",dev->irq, dev->base_addr);
if (card==0){
sti();
return -1;
}
sti();
break;
}
udelay(10);
sti();
i=0;
while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
if (!aironet4500_devices[i] && i < MAX_AWCS-1 ){
aironet4500_devices[i]=dev;
((struct awc_private *)
aironet4500_devices[i]->priv)->card_type = AIRONET4500_PNP;
if (awc_proc_set_fun)
awc_proc_set_fun(i);
} else {
printk(KERN_CRIT "Out of resources (MAX_AWCS) \n");
return -1;
}
card++;
}
if (card == 0) return -ENODEV;
return 0;
}
#ifdef MODULE
static void awc_pnp_release(void) {
// long flags;
int i=0;
struct isapnp_logdev *logdev;
DEBUG(0, "awc_detach \n");
i=0;
while ( i < MAX_AWCS) {
if (!aironet4500_devices[i])
{i++; continue;}
if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_PNP)
{i++; continue;}
logdev = ((struct isapnp_logdev *) ((struct awc_private *)aironet4500_devices[i]->priv)->bus);
if (!logdev )
printk("awc4500 no pnp logdev in pnp_release\n");
if (awc_proc_unset_fun)
awc_proc_unset_fun(i);
pnp_device_detach(logdev);
release_region(aironet4500_devices[i]->base_addr, AIRONET4X00_IO_SIZE);
// release_region(isa_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis");
// release_region(isa_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem");
unregister_netdev(aironet4500_devices[i]);
free_irq(aironet4500_devices[i]->irq,aironet4500_devices[i]);
kfree(aironet4500_devices[i]->priv);
kfree(aironet4500_devices[i]);
aironet4500_devices[i]=0;
i++;
}
}
static struct isapnp_device_id id_table[] = {
{ ISAPNP_ANY_ID, ISAPNP_ANY_ID,
ISAPNP_VENDOR('A','W','L'), ISAPNP_DEVICE(1), 0 },
{0}
};
MODULE_DEVICE_TABLE(isapnp, id_table);
#endif //MODULE
#endif /* CONFIG_AIRONET4500_PNP */
#ifdef CONFIG_AIRONET4500_ISA
static int irq[] = {0,0,0,0,0};
static int io[] = {0,0,0,0,0};
/*
EXPORT_SYMBOL(irq);
EXPORT_SYMBOL(io);
*/
MODULE_PARM(irq,"i");
MODULE_PARM_DESC(irq,"Aironet 4x00 ISA non-PNP irqs,required");
MODULE_PARM(io,"i");
MODULE_PARM_DESC(io,"Aironet 4x00 ISA non-PNP ioports,required");
int awc4500_isa_probe(struct net_device *dev)
{
// int cards_found = 0;
// static int isa_index; /* Static, for multiple probe calls. */
int isa_irq_line = 0;
int isa_ioaddr = 0;
// int p;
int card = 0;
int i=0;
if (! io[0] || ! irq[0]){
// printk(" Both irq and io params must be supplied for ISA mode !!!\n");
return -ENODEV;
}
printk(KERN_WARNING " Aironet ISA Card in non-PNP(ISA) mode sometimes feels bad on interrupt \n");
printk(KERN_WARNING " Use aironet4500_pnp if any problems(i.e. card malfunctioning). \n");
printk(KERN_WARNING " Note that this isa probe is not friendly... must give exact parameters \n");
while (irq[card] != 0){
isa_ioaddr = io[card];
isa_irq_line = irq[card];
request_region(isa_ioaddr, AIRONET4X00_IO_SIZE, "aironet4x00 ioaddr");
if (!dev) {
dev = init_etherdev(NULL, 0);
if (!dev) {
release_region(isa_ioaddr, AIRONET4X00_IO_SIZE);
return (card == 0) ? -ENOMEM : 0;
}
}
dev->priv = kmalloc(sizeof(struct awc_private),GFP_KERNEL );
memset(dev->priv,0,sizeof(struct awc_private));
if (!dev->priv) {
printk(KERN_CRIT "aironet4x00: could not allocate device private, some unstability may follow\n");
return -1;
};
// ether_setup(dev);
// dev->tx_queue_len = tx_queue_len;
dev->hard_start_xmit = &awc_start_xmit;
// dev->set_config = &awc_config_misiganes,aga mitte awc_config;
dev->get_stats = &awc_get_stats;
// dev->set_multicast_list = &awc_set_multicast_list;
dev->change_mtu = awc_change_mtu;
dev->init = &awc_init;
dev->open = &awc_open;
dev->stop = &awc_close;
dev->base_addr = isa_ioaddr;
dev->irq = isa_irq_line;
dev->tx_timeout = &awc_tx_timeout;
dev->watchdog_timeo = AWC_TX_TIMEOUT;
request_irq(dev->irq,awc_interrupt ,SA_INTERRUPT ,"Aironet 4X00",dev);
awc_private_init( dev);
if ( awc_init(dev) ){
printk("card not found at irq %x mem %x\n",irq[card],io[card]);
if (card==0)
return -1;
break;
}
i=0;
while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
if (!aironet4500_devices[i]){
aironet4500_devices[i]=dev;
((struct awc_private *)
aironet4500_devices[i]->priv)->card_type = AIRONET4500_ISA;
if (awc_proc_set_fun)
awc_proc_set_fun(i);
}
card++;
}
if (card == 0 ) {
return -ENODEV;
};
return 0;
}
#ifdef MODULE
static void awc_isa_release(void) {
// long flags;
int i=0;
DEBUG(0, "awc_detach \n");
i=0;
while ( i < MAX_AWCS) {
if (!aironet4500_devices[i])
{i++; continue;}
if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_ISA)
{i++; continue;}
if (awc_proc_unset_fun)
awc_proc_unset_fun(i);
release_region(aironet4500_devices[i]->base_addr, AIRONET4X00_IO_SIZE);
// release_region(isa_cisaddr, AIRONET4X00_CIS_SIZE, "aironet4x00 cis");
// release_region(isa_memaddr, AIRONET4X00_MEM_SIZE, "aironet4x00 mem");
unregister_netdev(aironet4500_devices[i]);
free_irq(aironet4500_devices[i]->irq,aironet4500_devices[i]);
kfree(aironet4500_devices[i]->priv);
kfree(aironet4500_devices[i]);
aironet4500_devices[i]=0;
i++;
}
}
#endif //MODULE
#endif /* CONFIG_AIRONET4500_ISA */
#ifdef CONFIG_AIRONET4500_I365
#define port_range 0x40
int awc_i365_offset_ports[] = {0x3e0,0x3e0,0x3e2,0x3e2};
int awc_i365_data_ports [] = {0x3e1,0x3e1,0x3e3,0x3e3};
int awc_i365_irq[] = {5,5,11,12};
int awc_i365_io[] = {0x140,0x100,0x400,0x440};
int awc_i365_sockets = 0;
struct i365_socket {
int offset_port ;
int data_port;
int socket;
int irq;
int io;
int manufacturer;
int product;
};
inline u8 i365_in (struct i365_socket * s, int offset) {
outb(offset + (s->socket % 2)* 0x40, s->offset_port);
return inb(s->data_port);
};
inline void i365_out (struct i365_socket * s, int offset,int data){
outb(offset + (s->socket % 2)* 0x40 ,s->offset_port);
outb((data & 0xff),s->data_port) ;
};
void awc_i365_card_release(struct i365_socket * s){
i365_out(s, 0x5, 0); // clearing ints
i365_out(s, 0x6, 0x20); // mem 16 bits
i365_out(s, 0x7, 0); // clear IO
i365_out(s, 0x3, 0); // gen ctrl reset + mem mode
i365_out(s, 0x2, 0); // reset power
i365_out(s, 0x2, i365_in(s, 0x2) & 0x7f ); // cardenable off
i365_out(s, 0x2, 0); // remove power
};
int awc_i365_probe_once(struct i365_socket * s ){
int caps=i365_in(s, 0);
int ret;
unsigned long jiff;
// short rev = 0x3000;
unsigned char cis [0x3e3];
unsigned char * mem = phys_to_virt(0xd000);
int i;
int port ;
DEBUG(1," i365 control ID %x \n", caps);
if (caps & 0xC){
return 1;
};
ret = i365_in(s, 0x1);
if ((ret & 0xC0) != 0xC0){
printk("card in socket %d port %x not in known state, %x \n",
s->socket, s->offset_port, ret );
return -1;
};
awc_i365_card_release(s);
mdelay(100);
i365_out(s, 0x2, 0x10 ); // power enable
mdelay(200);
i365_out(s, 0x2, 0x10 | 0x01 | 0x04 | 0x80); //power enable
mdelay(250);
if (!s->irq)
s->irq = 11;
i365_out(s, 0x3, 0x40 | 0x20 | s->irq);
jiff = jiffies;
while (jiffies-jiff < HZ )
if (i365_in(s,0x1) & 0x20)
break;
if (! (i365_in(s,0x1) & 0x20) ){
printk("irq enable timeout on socket %x \n", s->socket);
return -1;
};
i365_out(s,0x10,0xd0);
i365_out(s,0x11,0x0);
i365_out(s,0x12,0xd0);
i365_out(s,0x13,0x0);
i365_out(s,0x14,0x30 );
i365_out(s,0x15,0x3f | 0x40); // enab mem reg bit
i365_out(s,0x06,0x01); // enab mem
mdelay(10);
cis[0] = 0x45;
// memcpy_toio( 0xd3e0, &(cis[0]),0x1);
// mem[0x3e0] = 0x0;
// mem[0] = 0x45;
mem[0x3e0] = 0x45;
mdelay(10);
memcpy_fromio(cis,0xD000, 0x3e0);
for (i = 0; i <= 0x3e2; i++)
printk("%02x", mem[i]);
for (i = 0; i <= 0x3e2; i++)
printk("%c", mem[i]);
i=0;
while (i < 0x3e0){
if (cis[i] == 0xff)
break;
if (cis[i] != 0x20 ){
i = i + 2 + cis[i+1];
continue;
}else {
s->manufacturer = cis[i+2] | (cis[i+3]<<8);
s->product = cis[i+4] | (cis[i+5]<<8);
break;
};
i++;
};
DEBUG(1,"socket %x manufacturer %x product %x \n",
s->socket, s->manufacturer,s->product);
i365_out(s,0x07, 0x1 | 0x2); // enable io 16bit
mdelay(1);
port = s->io;
i365_out(s,0x08, port & 0xff);
i365_out(s,0x09, (port & 0xff00)/ 0x100);
i365_out(s,0x0A, (port+port_range) & 0xff);
i365_out(s,0x0B, ((port+port_range) & 0xff00) /0x100);
i365_out(s,0x06, 0x40); // enable io window
mdelay(1);
i365_out(s,0x3e0,0x45);
outw(0x10, s->io);
jiff = jiffies;
while (!(inw(s->io + 0x30) & 0x10)){
if (jiffies - jiff > HZ ){
printk("timed out waitin for command ack \n");
break;
}
};
outw(0x10, s->io + 0x34);
mdelay(10);
return 0;
};
static int awc_i365_init(struct i365_socket * s) {
struct net_device * dev;
int i;
dev = init_etherdev(0, sizeof(struct awc_private) );
// dev->tx_queue_len = tx_queue_len;
ether_setup(dev);
dev->hard_start_xmit = &awc_start_xmit;
// dev->set_config = &awc_config_misiganes,aga mitte awc_config;
dev->get_stats = &awc_get_stats;
dev->set_multicast_list = &awc_set_multicast_list;
dev->init = &awc_init;
dev->open = &awc_open;
dev->stop = &awc_close;
dev->irq = s->irq;
dev->base_addr = s->io;
dev->tx_timeout = &awc_tx_timeout;
dev->watchdog_timeo = AWC_TX_TIMEOUT;
awc_private_init( dev);
i=0;
while (aironet4500_devices[i] && i < MAX_AWCS-1) i++;
if (!aironet4500_devices[i]){
aironet4500_devices[i]=dev;
((struct awc_private *)
aironet4500_devices[i]->priv)->card_type = AIRONET4500_365;
if (awc_proc_set_fun)
awc_proc_set_fun(i);
}
if (register_netdev(dev) != 0) {
printk(KERN_NOTICE "awc_cs: register_netdev() failed\n");
goto failed;
}
return 0;
failed:
return -1;
}
static void awc_i365_release(void) {
// long flags;
int i=0;
DEBUG(0, "awc_detach \n");
i=0;
while ( i < MAX_AWCS) {
if (!aironet4500_devices[i])
{i++; continue;}
if (((struct awc_private *)aironet4500_devices[i]->priv)->card_type != AIRONET4500_365)
{i++; continue;}
if (awc_proc_unset_fun)
awc_proc_unset_fun(i);
unregister_netdev(aironet4500_devices[i]);
//kfree(aironet4500_devices[i]->priv);
kfree(aironet4500_devices[i]);
aironet4500_devices[i]=0;
i++;
}
}
int awc_i365_probe(void) {
int i = 1;
int k = 0;
int ret = 0;
int found=0;
struct i365_socket s;
/* Always emit the version, before any failure. */
if (!awc_i365_sockets) {
printk(" awc i82635 4x00: use bitfiel opts awc_i365_sockets=0x3 <- (1|2) to probe sockets 0 and 1\n");
return -1;
};
while (k < 4){
if (i & awc_i365_sockets){
s.offset_port = awc_i365_offset_ports[k];
s.data_port = awc_i365_data_ports[k];
s.socket = k;
s.manufacturer = 0;
s.product = 0;
s.irq = awc_i365_irq[k];
s.io = awc_i365_io[k];
ret = awc_i365_probe_once(&s);
if (!ret){
if (awc_i365_init(&s))
goto failed;
else found++;
} else if (ret == -1)
goto failed;
};
k++;
i *=2;
};
if (!found){
printk("no aironet 4x00 cards found\n");
return -1;
}
return 0;
failed:
awc_i365_release();
return -1;
}
#endif /* CONFIG_AIRONET4500_I365 */
#ifdef MODULE
int init_module(void)
{
int found = 0;
printk("%s\n ", awc_version);
#ifdef CONFIG_AIRONET4500_PCI
if (awc4500_pci_probe(NULL) == -ENODEV){
// printk("PCI 4X00 aironet cards not found\n");
} else {
found++;
// printk("PCI 4X00 found some cards \n");
}
#endif
#ifdef CONFIG_AIRONET4500_PNP
if (awc4500_pnp_probe(NULL) == -ENODEV){
// printk("PNP 4X00 aironet cards not found\n");
} else {
found++;
// printk("PNP 4X00 found some cards \n");
}
#endif
#ifdef CONFIG_AIRONET4500_365
if ( awc_i365_probe() == -1) {
// printk("PCMCIA 4X00 aironet cards not found for i365(without card services) initialization\n");
} else {
found++ ;
// printk("PCMCIA 4X00 found some cards, take care, this code is not supposed to work yet \n");
}
#endif
#ifdef CONFIG_AIRONET4500_ISA
if (awc4500_isa_probe(NULL) == -ENODEV){
// printk("ISA 4X00 aironet ISA-bus non-PNP-mode cards not found\n");
} else {
found++;
// printk("ISA 4X00 found some cards \n");
}
#endif
if (!found) {
printk(KERN_ERR "No Aironet 4X00 cards were found. Note that for ISA \n cards you should use either automatic PNP mode or \n ISA mode with both io and irq param \n Aironet is also afraid of: being second PNP controller(by slot), having anything(brandname bios weirdnesses) in range 0x100-0x180 and maybe around 0xd0000\n If you PNP type card does not get found, try non-PNP switch before complainig. \n");
return -1;
}
return 0;
}
void cleanup_module(void)
{
DEBUG(0, "awc_cs: unloading %c ",'\n');
#ifdef CONFIG_AIRONET4500_PCI
awc_pci_release();
#endif
#ifdef CONFIG_AIRONET4500_PNP
awc_pnp_release();
#endif
#ifdef CONFIG_AIRONET4500_365
awc_i365_release();
#endif
#ifdef CONFIG_AIRONET4500_ISA
awc_isa_release();
#endif
}
#endif
/*
* Aironet 4500/4800 driver core
*
* Elmer Joandi, Januar 1999
* Copyright: GPL
*
*
* Revision 0.1 ,started 30.12.1998
*
*
*/
/* CHANGELOG:
march 99, stable version 2.0
august 99, stable version 2.2
november 99, integration with 2.3
17.12.99: finally, got SMP near-correct.
timing issues remain- on SMP box its 15% slower on tcp
10.03.00 looks like softnet take us back to normal on SMP
*/
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/workqueue.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/if_arp.h>
#include <linux/ioport.h>
#include <linux/ip.h>
#include <linux/time.h>
#include <asm/io.h>
#include <asm/bitops.h>
#include <asm/system.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
#include "aironet4500.h"
int bap_sleep = 10 ;
int bap_sleep_after_setup = 1;
int sleep_before_command = 1;
int bap_sleep_before_write= 1;
int sleep_in_command = 1;
int both_bap_lock; /* activated at awc_init in this */
int bap_setup_spinlock; /* file if numcpu >1 */
EXPORT_SYMBOL(bap_sleep);
EXPORT_SYMBOL(bap_sleep_after_setup);
EXPORT_SYMBOL(sleep_before_command);
EXPORT_SYMBOL(bap_sleep_before_write);
EXPORT_SYMBOL(sleep_in_command);
EXPORT_SYMBOL(both_bap_lock);
EXPORT_SYMBOL(bap_setup_spinlock);
struct awc_strings awc_status_error_codes[]=awc_reply_error_strings;
struct awc_strings awc_command_names[]=awc_command_name_strings;
struct awc_strings awc_link_status_names[]=awc_link_status_strings;
struct awc_strings awc_rid_names[]=aironet4500_RID_Select_strings;
struct awc_strings awc_link_failure_reason_names[]=IEEE_802_11_LINK_STATUS_FAILURE_REASON_STRINGS;
const char * awc_print_string( struct awc_strings* strings, int code){
struct awc_strings * str = strings;
int i = 0;
while (str[i].string != NULL){
if (str[i].par == (code & str[i].mask )){
return str[i].string;
};
i++;
};
return "UNKNOWN";
};
int awc_dump_registers(struct net_device * dev){
#ifdef AWC_DEBUG
int i;
#endif
int status= inw(dev->base_addr +4*2);
int r1= inw(dev->base_addr +5*2);
int r2= inw(dev->base_addr +6*2);
int r3= inw(dev->base_addr +7*2);
printk(KERN_ERR "Command %s , result: %s, at memblk %x(RID %s) , offset %x \n",
awc_print_string(awc_command_names,status),
awc_print_string(awc_status_error_codes,r1),
r2, awc_print_string(awc_rid_names,r2),
r3);
#ifdef AWC_DEBUG
printk(KERN_ERR "%s aironet register dump ",dev->name );
for (i=0; i < 32; i++){
printk("%4x ", inw(dev->base_addr + i*2 ) );
if ( (i+1)%8 == 0){
printk("\n");
printk(KERN_ERR "%02x",(i+1)*2);
}
};
printk(KERN_ERR " \n");
#endif
return 0;
};
/****************************** COMMAND ******************/
inline
int awc_command_busy_clear_wait(struct net_device * dev){
// long long jiff = jiffies;
u16 active_interrupts;
int cnt= 0;
AWC_ENTRY_EXIT_DEBUG(" entry awc_command_busy_clear_wait ");
while (awc_command_busy(dev->base_addr)){
if (cnt > 1000 ){
printk(KERN_ERR "awc command busy too long, clearing\n");
awc_dump_registers(dev);
awc_event_ack_ClrStckCmdBsy(dev->base_addr);
break;
};
if (((struct awc_private*) dev->priv)->ejected)
return -1;
cnt++;
udelay(10);
}
cnt = 0;
while (awc_command_busy(dev->base_addr)){
//if (jiffies - jiff > (HZ/3)){
if (cnt > 30000 ){
printk(KERN_CRIT "awc command busy WAY too long, clearing\n");
awc_dump_registers(dev);
awc_event_ack_ClrStckCmdBsy(dev->base_addr);
active_interrupts = awc_event_status(dev->base_addr);
awc_event_ack(dev->base_addr, active_interrupts);
AWC_ENTRY_EXIT_DEBUG("BAD exit\n ");
return -1 ;
};
if (((struct awc_private*) dev->priv)->ejected)
return -1;
cnt++;
udelay(10);
}
AWC_ENTRY_EXIT_DEBUG(" exit\n ");
return 0;
};
inline unsigned short
awc_issue_command_and_block(struct awc_command * cmd){
int ticks;
long long jiff;
u16 enabled_interrupts;
int cnt = 0;
// unsigned long flags;
jiff = jiffies;
AWC_ENTRY_EXIT_DEBUG(" entry awc_issue_command_and_block ");
AWC_LOCK_COMMAND_ISSUING(cmd->priv);
if (awc_command_busy_clear_wait(cmd->dev)) goto final;
if (cmd->priv->sleeping_bap) udelay(sleep_before_command);
awc4500wout(cmd->port,cmd->command,cmd->par0,cmd->par1,cmd->par2);
// awc_dump_registers(cmd->dev);
if (cmd->priv->sleeping_bap) udelay(sleep_in_command);
enabled_interrupts = awc_ints_enabled(cmd->dev->base_addr);
awc_ints_enable(cmd->dev->base_addr, enabled_interrupts & ~0x10);
if(cmd->priv->enabled_interrupts & 0x10)
cmd->priv->enabled_interrupts &= ~0x10;
while ( awc_command_read(cmd->port) == cmd->command) {
udelay(1);
awc_command_write(cmd->port, cmd->command);
//if ((jiffies - jiff) > 2){
if (cnt > 2000 ){
printk(" long wait with commmand reg busy in blocking command \n");
awc_dump_registers(cmd->dev);
goto final;
};
if (cmd->priv->ejected)
goto final;
cnt++;
udelay(10);
};
AWC_ENTRY_EXIT_DEBUG(" issued " );
ticks = 0;
while ( awc_event_status_Cmd(cmd->port) == 0) {
ticks++;
if (ticks > 100000){
printk(" long wait with commmand reg busy \n");
awc_dump_registers(cmd->dev);
goto final;
};
if (ticks > 500){
DEBUG(1, " long wait after issue 10mks * %d ", ticks );
//printk(" long wait with command reg busy about ticks\n");
// sti();
}
if (cmd->priv->ejected)
goto final;
udelay(10);
}
if (cmd->priv->sleeping_bap) udelay(sleep_in_command);
awc_read_response(cmd);
AWC_ENTRY_EXIT_DEBUG(" resp read \n");
if (awc_command_busy(cmd->port))
awc_event_ack_ClrStckCmdBsy(cmd->port);
awc_event_ack_Cmd(cmd->port);
if (cmd->priv->sleeping_bap) udelay(sleep_in_command);
if (cmd->status & 0xff00){
printk(KERN_ERR " bad response to command %s, parameter %x \n",awc_print_string(awc_command_names, cmd->command),cmd->par0);
awc_dump_registers(cmd->dev);
goto final;
}
AWC_UNLOCK_COMMAND_ISSUING(cmd->priv);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
udelay(1);
return 0;
final:
AWC_UNLOCK_COMMAND_ISSUING(cmd->priv);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
};
inline
unsigned short
awc_issue_command(struct awc_command * cmd){
// long long jiff = jiffies;
// unsigned short enabled_ints;
int cnt = 0;
// int i=0;
AWC_ENTRY_EXIT_DEBUG(" entry awc_issue_command");
if (!cmd){
printk(KERN_CRIT "cmd == NULL in awc_issue_command\n");
return -1;
}
if (!cmd->dev){
printk(KERN_CRIT "cmd->dev == NULL in awc_issue_command\n");
return -1;
}
AWC_LOCK_COMMAND_ISSUING(cmd->priv);
if(awc_command_busy_clear_wait(cmd->dev)) goto final;
if(!cmd->priv->enabled_interrupts & 0x10){
cmd->priv->enabled_interrupts |= 0x10;
awc_ints_enable(cmd->port, cmd->priv->enabled_interrupts );
}
cmd->priv->async_command_start = jiffies;
cmd->priv->command_semaphore_on++;
awc4500wout(cmd->port,cmd->command,cmd->par0,cmd->par1,cmd->par2);
while ( awc_command_read(cmd->port) == cmd->command) {
awc_command_write(cmd->port, cmd->command);
//if ((jiffies - jiff) > 2){
if (cnt > 2000) {
printk(" long wait with commmand reg busy in async command \n");
awc_dump_registers(cmd->dev);
goto final;
};
if (cmd->priv->ejected)
goto final;
cnt++;
udelay(10);
};
cmd->priv->cmd = *cmd;
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
AWC_UNLOCK_COMMAND_ISSUING(cmd->priv);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
};
inline
unsigned short
awc_issue_command_no_ack(struct net_device * dev,
u16 com, u16 par1, u16 par2, u16 par3){
struct awc_private * priv = (struct awc_private *)dev->priv;
int cnt = 0;
long long jiff;
jiff = jiffies;
AWC_ENTRY_EXIT_DEBUG(" entry awc_issue_command_no_ack ");
AWC_LOCK_COMMAND_ISSUING(priv);
if (awc_command_busy_clear_wait(dev)) {
printk("aironet4x00 no_ack command (reset) with stuck card \n");
}
awc4500wout(dev->base_addr,com, par1, par2,par3);
udelay(10);
while ( awc_event_status_Cmd(dev->base_addr) == 0) {
if (awc_command_read(dev->base_addr) == com) {
awc_command_write(dev->base_addr, com);
}
//if ((jiffies - jiff) > 2){
if (cnt > 2000) {
printk(" long wait with commmand reg busy in noack command %d par %d %d %d\n",com,par1,par2,par3);
awc_dump_registers(dev);
goto final;
};
if (priv->ejected)
goto final;
udelay(10);
cnt++;
}
if (awc_command_busy(dev->base_addr))
awc_event_ack_ClrStckCmdBsy(dev->base_addr);
AWC_UNLOCK_COMMAND_ISSUING(priv);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
AWC_UNLOCK_COMMAND_ISSUING(priv);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
};
/******************************** BAP *************************/
// inline // too long for inline
int awc_bap_setup(struct awc_command * cmd) {
int status;
long long jiff;
unsigned long flags;
int cleared = 0;
int cycles = 0;
AWC_ENTRY_EXIT_DEBUG(" entry awc_bap_setup ");
if ( cmd->priv->sleeping_bap)
udelay(bap_sleep);
if (cmd->priv->ejected)
return -1;
if (!cmd->bap || !(cmd->lock_state & (AWC_BAP_SEMALOCKED |AWC_BAP_LOCKED)))
DEBUG(1,"no bap or bap not locked cmd %d !!", cmd->command);
if (bap_setup_spinlock)
spin_lock_irqsave(&cmd->priv->bap_setup_spinlock,cmd->priv->bap_setup_spinlock_flags);
status = AWC_IN(cmd->bap->offset);
if (status & ~0x2000 ){
WAIT61x3;
status = AWC_IN(cmd->bap->offset);
}
if (status & ~0x2000 ){
WAIT61x3;
AWC_IN(cmd->dev->base_addr + 0x26);
AWC_OUT(cmd->dev->base_addr + 0x26, 0);
WAIT61x3;
udelay(60);
#ifdef AWC_DEBUG
printk("b");
#endif
status = AWC_IN(cmd->bap->offset);
}
if (status & 0xC000){
printk(KERN_ERR "bap entered with err or busy bit set %x \n",status);
if (cmd->bap->lock != 1)
printk(KERN_ERR "bap lock bad same time %x\n",cmd->bap->lock);
awc_dump_registers(cmd->dev);
// AWC_OUT(cmd->bap->offset, 0x800);
}
save_flags(flags);
cli();
AWC_OUT(cmd->bap->select, cmd->rid);
WAIT61x3;
AWC_OUT(cmd->bap->offset, cmd->offset);
restore_flags(flags);
WAIT61x3;
jiff = jiffies;
while (1) {
cycles++;
status = AWC_IN(cmd->bap->offset);
if ( cmd->priv->sleeping_bap)
udelay(bap_sleep);
if (cmd->priv->ejected)
goto ejected_unlock;
udelay(1);
if (cycles > 10000) {
printk(KERN_CRIT "deadlock in bap\n");
goto return_AWC_ERROR;
};
status = AWC_IN(cmd->bap->offset);
if (status & AWC_BAP_BUSY) {
if (cycles % 100 == 99 ) {
save_flags(flags);
cli();
if (!cleared){
AWC_IN(cmd->dev->base_addr + 0x26);
AWC_OUT(cmd->dev->base_addr + 0x26, 0);
WAIT61x3;
cleared = 1;
}
AWC_OUT(cmd->bap->select, cmd->rid);
WAIT61x3;
AWC_OUT(cmd->bap->offset, cmd->offset);
restore_flags(flags);
#ifdef AWC_DEBUG
printk("B");
#endif
if ( cmd->priv->sleeping_bap)
udelay(bap_sleep);
else udelay(30);
//restart_timeout();
}
if (jiffies - jiff > 1 ) {
AWC_ENTRY_EXIT_DEBUG(" BAD BUSY exit \n");
awc_dump_registers(cmd->dev);
goto return_AWC_ERROR;
}
continue;
}
if (status & AWC_BAP_DONE) {
WAIT61x3; WAIT61x3; WAIT61x3;
// if ((status & 0xfff) != cmd->offset)
// printk(KERN_ERR "awcPBD %x ",status);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
if (cmd->priv->sleeping_bap)
udelay(bap_sleep_after_setup);
// success
goto return_AWC_SUCCESS;
}
if (status & AWC_BAP_ERR) {
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
// invalid rid or offset
printk(KERN_ERR "bap setup error bit set for rid %x offset %x \n",cmd->rid,cmd->offset);
awc_dump_registers(cmd->dev);
goto return_AWC_ERROR;
}
if ( cmd->priv->sleeping_bap)
udelay(bap_sleep);
else udelay(1);
// -- awc missed it, try again
save_flags(flags);
cli();
AWC_OUT(cmd->bap->select, cmd->rid);
WAIT61x3;
AWC_OUT(cmd->bap->offset, cmd->offset);
WAIT61x3;
restore_flags(flags);
if (jiffies - jiff > HZ)
if (! (status &(AWC_BAP_ERR |AWC_BAP_DONE |AWC_BAP_BUSY))){
printk("aironet4500: bap setup lock without any status bits set");
awc_dump_registers(cmd->dev);
goto return_AWC_ERROR;
};
}
AWC_ENTRY_EXIT_DEBUG(" WE MUST NOT BE HERE exit \n");
ejected_unlock:
if (bap_setup_spinlock)
spin_unlock_irqrestore(&cmd->priv->bap_setup_spinlock,cmd->priv->bap_setup_spinlock_flags);
AWC_ENTRY_EXIT_DEBUG(" ejected_unlock_exit \n");
return -1;
return_AWC_ERROR:
if (bap_setup_spinlock)
spin_unlock_irqrestore(&cmd->priv->bap_setup_spinlock,cmd->priv->bap_setup_spinlock_flags);
AWC_ENTRY_EXIT_DEBUG(" AWC_ERROR_exit \n");
return AWC_ERROR;
return_AWC_SUCCESS:
if (bap_setup_spinlock)
spin_unlock_irqrestore(&cmd->priv->bap_setup_spinlock,cmd->priv->bap_setup_spinlock_flags);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return AWC_SUCCESS;
}
// requires call to awc_bap_setup() first
inline
int
awc_bap_read(struct awc_command * cmd) {
register u16 len;
register u16 * buff = (u16 *) cmd->buff;
register u16 port= cmd->bap->data;
AWC_ENTRY_EXIT_DEBUG(" entry awc_bap_read ");
if (!cmd->bap && !(cmd->lock_state & (AWC_BAP_SEMALOCKED |AWC_BAP_LOCKED)))
DEBUG(0,"no bap or bap not locked %d !!", cmd->command);
cmd->len = (cmd->len + 1) & (~1); // round up to even value
len = cmd->len / 2;
if (cmd->priv->ejected)
return -1;
if (cmd->priv->sleeping_bap)
udelay(bap_sleep_before_write);
if (!cmd->priv->sleeping_bap)
while ( len-- > 0)
*buff++ = AWC_IN(port);
else
while ( len-- > 0){
*buff++ = AWC_IN(port);
}
AWC_ENTRY_EXIT_DEBUG(" exit \n");
if (cmd->priv->ejected)
return -1;
return AWC_SUCCESS;
}
// requires call to awc_bap_setup() first
inline
int
awc_bap_write(struct awc_command * cmd){
register u16 len;
register u16 * buff = (u16 *) cmd->buff;
register u16 port= cmd->bap->data;
AWC_ENTRY_EXIT_DEBUG(" entry awc_bap_write ");
if (!cmd->bap && !(cmd->lock_state & (AWC_BAP_SEMALOCKED |AWC_BAP_LOCKED)))
DEBUG(0,"no bap or bap not locked %d !!", cmd->command);
cmd->len = (cmd->len + 1) & (~1); // round up to even value
len = cmd->len / 2;
if (cmd->priv->ejected)
return -1;
if (cmd->priv->sleeping_bap)
udelay(bap_sleep_before_write);
if (!cmd->priv->sleeping_bap)
while (len-- > 0)
AWC_OUT(port, *buff++);
else
while ( len-- > 0){
AWC_OUT(port, *buff++);
}
if (cmd->priv->ejected)
return -1;
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return AWC_SUCCESS;
}
/***************************** RID READ/WRITE ********************/
const struct aironet4500_rid_selector aironet4500_RID_Select_General_Config =(const struct aironet4500_rid_selector){ 0xFF10, 1,0,0, "General Configuration" }; // See notes General Configuration Many configuration items.
const struct aironet4500_rid_selector aironet4500_RID_Select_SSID_list =(const struct aironet4500_rid_selector){ 0xFF11, 1,0,0, "Valid SSID list" }; // See notes Valid SSID list List of SSIDs which the station may associate to.
const struct aironet4500_rid_selector aironet4500_RID_Select_AP_list =(const struct aironet4500_rid_selector){ 0xFF12, 1,0,0, "Valid AP list" }; // See notes Valid AP list List of APs which the station may associate to.
const struct aironet4500_rid_selector aironet4500_RID_Select_Driver_name =(const struct aironet4500_rid_selector){ 0xFF13, 1,0,0, "Driver name" }; // See notes Driver name The name and version of the driver (for debugging)
const struct aironet4500_rid_selector aironet4500_RID_Select_Encapsulation =(const struct aironet4500_rid_selector){ 0xFF14, 1,0,0, "Ethernet Protocol" }; // See notes Ethernet Protocol Rules for encapsulating ethernet payloads onto 802.11.
const struct aironet4500_rid_selector aironet4500_RID_Select_WEP_volatile =(const struct aironet4500_rid_selector){ 0xFF15, 1,0,0, "WEP key volatile" }; //
const struct aironet4500_rid_selector aironet4500_RID_Select_WEP_nonvolatile =(const struct aironet4500_rid_selector){ 0xFF16, 1,0,0, "WEP key non-volatile" }; //
const struct aironet4500_rid_selector aironet4500_RID_Select_Modulation =(const struct aironet4500_rid_selector){ 0xFF17, 1,0,0, "Modulation" }; //
const struct aironet4500_rid_selector aironet4500_RID_Select_Active_Config =(const struct aironet4500_rid_selector){ 0xFF20, 0,1,1, "Actual Configuration" }; // Read only Actual Configuration This has the same format as the General Configuration.
const struct aironet4500_rid_selector aironet4500_RID_Select_Capabilities =(const struct aironet4500_rid_selector){ 0xFF00, 0,1,0, "Capabilities" }; // Read Only Capabilities PC4500 Information
const struct aironet4500_rid_selector aironet4500_RID_Select_AP_Info =(const struct aironet4500_rid_selector){ 0xFF01, 0,1,1, "AP Info" }; // Read Only AP Info Access Point Information
const struct aironet4500_rid_selector aironet4500_RID_Select_Radio_Info =(const struct aironet4500_rid_selector){ 0xFF02, 0,1,1, "Radio Info" }; // Read Only Radio Info Radio Information -- note radio specific
const struct aironet4500_rid_selector aironet4500_RID_Select_Status =(const struct aironet4500_rid_selector){ 0xFF50, 0,1,1, "Status" }; // Read Only Status PC4500 Current Status Information
const struct aironet4500_rid_selector aironet4500_RID_Select_16_stats =(const struct aironet4500_rid_selector){ 0xFF60, 0,1,1, "Cumulative 16-bit Statistics" }; // Read Only 16-bit Statistics Cumulative 16-bit Statistics
const struct aironet4500_rid_selector aironet4500_RID_Select_16_stats_delta =(const struct aironet4500_rid_selector){ 0xFF61, 0,1,1, "Delta 16-bit Statistics" }; // Read Only 16-bit Statistics Delta 16-bit Statistics (since last clear)
const struct aironet4500_rid_selector aironet4500_RID_Select_16_stats_clear =(const struct aironet4500_rid_selector){ 0xFF62, 0,1,1, "Delta 16-bit Statistics and Clear" }; // Read Only / 16-bit Statistics Delta 16-bit Statistics and Clear
const struct aironet4500_rid_selector aironet4500_RID_Select_32_stats =(const struct aironet4500_rid_selector){ 0xFF68, 0,1,1, "Cumulative 32-bit Statistics" }; // Read Only 32-bit Statistics Cumulative 32-bit Statistics
const struct aironet4500_rid_selector aironet4500_RID_Select_32_stats_delta =(const struct aironet4500_rid_selector){ 0xFF69, 0,1,1, "Delta 32-bit Statistics" }; // Read Only 32-bit Statistics Delta 32-bit Statistics (since last clear)
const struct aironet4500_rid_selector aironet4500_RID_Select_32_stats_clear =(const struct aironet4500_rid_selector){ 0xFF6A, 0,1,1, "Delta 32-bit Statistics and Clear" }; // Read Only / 32-bit Statistics Delta 32-bit Statistics and Clear
EXPORT_SYMBOL(aironet4500_RID_Select_General_Config);
EXPORT_SYMBOL(aironet4500_RID_Select_SSID_list);
EXPORT_SYMBOL(aironet4500_RID_Select_AP_list);
EXPORT_SYMBOL(aironet4500_RID_Select_Driver_name);
EXPORT_SYMBOL(aironet4500_RID_Select_Encapsulation);
EXPORT_SYMBOL(aironet4500_RID_Select_WEP_volatile);
EXPORT_SYMBOL(aironet4500_RID_Select_WEP_nonvolatile);
EXPORT_SYMBOL(aironet4500_RID_Select_Modulation);
EXPORT_SYMBOL(aironet4500_RID_Select_Active_Config);
EXPORT_SYMBOL(aironet4500_RID_Select_Capabilities);
EXPORT_SYMBOL(aironet4500_RID_Select_AP_Info);
EXPORT_SYMBOL(aironet4500_RID_Select_Radio_Info);
EXPORT_SYMBOL(aironet4500_RID_Select_Status);
EXPORT_SYMBOL(aironet4500_RID_Select_16_stats);
EXPORT_SYMBOL(aironet4500_RID_Select_16_stats_delta);
EXPORT_SYMBOL(aironet4500_RID_Select_16_stats_clear);
EXPORT_SYMBOL(aironet4500_RID_Select_32_stats);
EXPORT_SYMBOL(aironet4500_RID_Select_32_stats_delta);
EXPORT_SYMBOL(aironet4500_RID_Select_32_stats_clear);
struct awc_rid_dir awc_rids_temp[]={
// following MUST be consistent with awc_rids_setup !!!
{&aironet4500_RID_Select_General_Config, 0x100 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_SSID_list, 0x68 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_AP_list, 0x20 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_Driver_name, 0x12 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_Encapsulation, 0x22 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_Active_Config, 0x100 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_Capabilities, 0x80 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_Status, 0x6c , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_AP_Info, 0x06 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_32_stats, 0x184 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_32_stats_delta, 0x184 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_32_stats_clear, 0x184 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_WEP_volatile, 0x1c , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_WEP_nonvolatile, 0x1c , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_Modulation, 0x04 , NULL, NULL, NULL,0 },
#ifdef AWC_USE_16BIT_STATS
{&aironet4500_RID_Select_16_stats, 0xC2 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_16_stats_delta, 0xC2 , NULL, NULL, NULL,0 },
{&aironet4500_RID_Select_16_stats_clear, 0xC2 , NULL, NULL, NULL,0 },
#else
{NULL},{NULL},{NULL},
#endif
{0}
};
int
awc_readrid(struct net_device * dev, struct aironet4500_RID * rid, void *pBuf ){
struct awc_command cmd;
int sleep_state ;
AWC_ENTRY_EXIT_DEBUG(" entry awc_readrid ");
if (!rid) return -1;
if (!rid->selector) return -1;
AWC_INIT_COMMAND(AWC_NOT_CLI,cmd,dev,0x21, rid->selector->selector,
rid->selector->selector, rid->offset, (rid->bits / 8),pBuf);
sleep_state = cmd.priv->sleeping_bap ;
cmd.priv->sleeping_bap = 1;
udelay(500);
AWC_BAP_LOCK_NOT_CLI(cmd);
if (awc_issue_command_and_block(&cmd)) goto final;
udelay(1);
if (awc_bap_setup(&cmd)) goto final;
udelay(1);
if (awc_bap_read(&cmd)) goto final;
cmd.priv->sleeping_bap = sleep_state;
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
cmd.priv->sleeping_bap = sleep_state;
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
}
int
awc_writerid(struct net_device * dev, struct aironet4500_RID * rid, void *pBuf){
struct awc_command cmd;
int sleep_state ;
AWC_ENTRY_EXIT_DEBUG(" entry awc_writerid ");
AWC_INIT_COMMAND(AWC_NOT_CLI,cmd,dev,0x21, rid->selector->selector,
rid->selector->selector,rid->offset, rid->bits/8,pBuf);
sleep_state = cmd.priv->sleeping_bap ;
cmd.priv->sleeping_bap = 1;
udelay(500);
AWC_BAP_LOCK_NOT_CLI(cmd);
if (awc_issue_command_and_block(&cmd)) goto final;
udelay(10);
if (awc_bap_setup(&cmd)) goto final;
udelay(10);
if (awc_bap_write(&cmd)) goto final;
udelay(10);
cmd.command=0x121;
if (awc_issue_command_and_block(&cmd)) goto final;
cmd.priv->sleeping_bap = sleep_state;
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
cmd.priv->sleeping_bap = sleep_state;
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
}
int
awc_readrid_dir(struct net_device * dev, struct awc_rid_dir * rid ){
struct awc_command cmd;
int sleep_state;
AWC_ENTRY_EXIT_DEBUG(" entry awcreadrid_dir ");
AWC_INIT_COMMAND(AWC_NOT_CLI,cmd,dev,0x21, rid->selector->selector,
rid->selector->selector,0, rid->bufflen,rid->buff);
sleep_state = cmd.priv->sleeping_bap ;
cmd.priv->sleeping_bap = 1;
udelay(500);
AWC_BAP_LOCK_NOT_CLI(cmd);
if (awc_issue_command_and_block(&cmd)) goto final;
if (awc_bap_setup(&cmd)) goto final;
if (awc_bap_read(&cmd)) goto final;
cmd.priv->sleeping_bap = sleep_state;
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
cmd.priv->sleeping_bap = sleep_state;
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
}
int
awc_writerid_dir(struct net_device * dev, struct awc_rid_dir * rid){
struct awc_command cmd;
int sleep_state ;
AWC_ENTRY_EXIT_DEBUG(" entry awc_writerid_dir ");
AWC_INIT_COMMAND(AWC_NOT_CLI,cmd,dev,0x21, rid->selector->selector,
rid->selector->selector,0, rid->bufflen,((char *)rid->buff));
sleep_state = cmd.priv->sleeping_bap ;
cmd.priv->sleeping_bap = 1;
udelay(500);
AWC_BAP_LOCK_NOT_CLI(cmd);
if (awc_issue_command_and_block(&cmd)) goto final;
if (awc_bap_setup(&cmd)) goto final;
if (awc_bap_write(&cmd)) goto final;
cmd.priv->sleeping_bap = sleep_state;
cmd.command=0x121;
udelay(500);
if (awc_issue_command_and_block(&cmd)) goto final;
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
cmd.priv->sleeping_bap = sleep_state;
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
}
EXPORT_SYMBOL(awc_readrid);
EXPORT_SYMBOL(awc_writerid);
EXPORT_SYMBOL(awc_readrid_dir);
EXPORT_SYMBOL(awc_writerid_dir);
/***************************** STARTUP *******************/
inline
int
awc_issue_blocking_command(struct net_device * dev,u16 comm){
struct awc_command cmd;
// struct awc_private * priv = (struct awc_private *)dev->priv;
AWC_ENTRY_EXIT_DEBUG(" entry awc_issue_blocking_command ");
AWC_INIT_COMMAND(AWC_NOT_CLI,cmd,dev,comm,0, 0, 0, 0 ,0 );
AWC_BAP_LOCK_NOT_CLI(cmd);
if (awc_issue_command_and_block(&cmd))
goto final;
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
};
int
awc_issue_soft_reset(struct net_device * dev){
u16 status ;
// int i= 0;
/* outw(inw(dev->base_addr + 0x30), dev->base_addr + 0x32);
udelay(10);
outw(inw(dev->base_addr + 0x30), dev->base_addr + 0x34);
for (i=0; i< 32; i++)
outw(0,dev->base_addr + i*2);
udelay(100);
outw(0x6,dev->base_addr + 0x34);
udelay(100);
outw(0x6,dev->base_addr + 0x34);
outw(0x6,dev->base_addr + 0x34);
WAIT61x3;
AWC_IN(dev->base_addr + 0x26);
AWC_OUT(dev->base_addr + 0x26, 0);
WAIT61x3;
udelay(60);
outw(0x4, dev->base_addr);
udelay(1000);
WAIT61x3;
AWC_IN(dev->base_addr + 0x26);
AWC_OUT(dev->base_addr + 0x26, 0);
WAIT61x3;
udelay(60);
*/
status = awc_issue_command_no_ack(dev, AWC_COMMAND_SOFT_RESET,0,0,0);
// awc_command_busy_clear_wait(dev);
return status;
};
int
awc_issue_noop(struct net_device * dev){
int retval;
AWC_OUT(dev->base_addr + 0x28, 0);
AWC_OUT(dev->base_addr + 0x2A, 0);
udelay(1000);
retval= awc_issue_blocking_command(dev, AWC_COMMAND_NOOP);
udelay(1000);
return retval;
};
EXPORT_SYMBOL(awc_enable_MAC);
int
awc_enable_MAC(struct net_device * dev){
struct awc_private * priv = (struct awc_private *)dev->priv;
AWC_ENTRY_EXIT_DEBUG(" entry awc_enable_MAC ");
if (priv->mac_enabled){
AWC_ENTRY_EXIT_DEBUG(" mac already enabled exit \n");
return 0;
}
udelay(500);
if (awc_issue_blocking_command(dev, AWC_COMMAND_ENABLE)){
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
}
udelay(500);
priv->mac_enabled = 1;
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
};
EXPORT_SYMBOL(awc_disable_MAC);
int
awc_disable_MAC(struct net_device * dev){
struct awc_private * priv = (struct awc_private *)dev->priv;
AWC_ENTRY_EXIT_DEBUG(" entry awc_disable_MAC ");
if (!priv->mac_enabled){
AWC_ENTRY_EXIT_DEBUG(" mac allready disabled exit \n");
return 0;
}
udelay(1000);
if (awc_issue_blocking_command(dev, AWC_COMMAND_DISABLE)){
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
}
udelay(1000);
priv->mac_enabled = 0;
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
};
int
awc_read_all_rids(struct net_device * dev){
struct awc_private * priv = (struct awc_private *)dev->priv;
int status,i;
AWC_ENTRY_EXIT_DEBUG(" entry awc_read_all_rids ");
for (i=0; i< AWC_NOF_RIDS && priv->rid_dir[i].selector ; i++){
status = awc_readrid_dir(dev,&priv->rid_dir[i]);
udelay(50);
if (status) return status;
}
priv->rids_read = 1;
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
}
int
awc_write_all_rids(struct net_device * dev){
struct awc_private * priv = (struct awc_private *)dev->priv;
int i,status ;
AWC_ENTRY_EXIT_DEBUG(" entry awc_write_all_rids ");
for (i=0;i < 5 && i< AWC_NOF_RIDS && priv->rid_dir[i].selector ; i++){
status = awc_writerid_dir(dev,&priv->rid_dir[i]);
udelay(10);
if(status) return status;
}
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
}
/************************** FID QUEUES ****************************/
/**************************** TX ALLOC / DEALLOC ***************/
int awc_tx_alloc(struct net_device * dev) {
struct awc_command cmd;
int k=0;
int tot=0;
struct awc_fid * fid = NULL;
AWC_ENTRY_EXIT_DEBUG(" entry awc_tx_alloc ");
AWC_INIT_COMMAND(AWC_NOT_CLI,cmd,dev,0x0A,0, 0,0,0,NULL);
cmd.par0 = dev->mtu + AWC_TX_HEAD_SIZE + 8 ;
DEBUG(32,"about to allocate %x bytes ",cmd.priv->large_buff_mem);
DEBUG(32,"in %x large buffers ",cmd.priv->large_buff_mem / (dev->mtu + AWC_TX_HEAD_SIZE + 8) );
k=0;tot=0;
AWC_BAP_LOCK_NOT_CLI(cmd);
while (k < cmd.priv->large_buff_mem / (dev->mtu + AWC_TX_HEAD_SIZE + 8) ) {
fid = kmalloc(sizeof(struct awc_fid),GFP_KERNEL );
if (!fid) goto final;
memset(fid, 0, sizeof(struct awc_fid));
if (awc_issue_command_and_block(&cmd)) goto final;
while ( awc_event_status_Alloc(cmd.port) == 0) ;
fid->u.tx.fid = awc_Tx_Allocated_Fid(cmd.port);
fid->u.tx.fid_size = dev->mtu + AWC_TX_HEAD_SIZE ;
DEBUG(32,"allocated large tx fid %x ",fid->u.tx.fid);
if(fid->u.tx.fid == 0
|| cmd.status != 0xA){
printk(KERN_ERR "%s bad tx_alloc\n",dev->name);
fid->busy =1;
goto final;
} else {
fid->busy =0;
tot++;
}
awc_event_ack_Alloc(cmd.port);
// shoudlnt goto final after that
awc_fid_queue_push_tail(&cmd.priv->tx_large_ready,fid);
k++;
}
cmd.priv->tx_buffs_total = tot;
DEBUG(32,"allocated %d large tx buffs\n",tot);
cmd.par0 = AWC_TX_ALLOC_SMALL_SIZE ;
k =0; tot = 0;
while (k < cmd.priv->small_buff_no) {
fid = kmalloc(sizeof(struct awc_fid),GFP_KERNEL );
if (!fid) goto final;
memset(fid, 0, sizeof(struct awc_fid));
cmd.par0 = AWC_TX_ALLOC_SMALL_SIZE ;
if (awc_issue_command_and_block(&cmd)) goto final;
while ( awc_event_status_Alloc(cmd.port) == 0) ;
fid->u.tx.fid = awc_Tx_Allocated_Fid(cmd.port);
fid->u.tx.fid_size = AWC_TX_ALLOC_SMALL_SIZE;
DEBUG(32,"allocated large tx fid %x ",fid->u.tx.fid);
if(fid->u.tx.fid == 0
|| cmd.status != 0xA){
printk(KERN_ERR "%s bad tx_alloc\n",dev->name);
fid->busy =1;
goto final;
} else {
fid->busy =0;
tot++;
}
awc_event_ack_Alloc(cmd.port);
// shoudlnt goto final after that
awc_fid_queue_push_tail(&cmd.priv->tx_small_ready,fid);
k++;
}
cmd.priv->tx_small_buffs_total = tot;
DEBUG(32,"allocated %d small tx buffs\n",tot);
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
if (fid )
kfree(fid);
printk(KERN_CRIT "%s awc tx prealloc failed \n",dev->name);
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
};
int
awc_tx_dealloc_fid(struct net_device * dev,struct awc_fid * fid){
struct awc_command cmd;
int fid_handle = 0;
AWC_INIT_COMMAND(AWC_NOT_CLI,cmd,dev,0x0C,0, 0,0,0,NULL);
AWC_BAP_LOCK_NOT_CLI(cmd);
if (fid->u.tx.fid){
fid_handle = cmd.par0 = fid->u.tx.fid;
fid->u.tx.fid = 0;
fid->busy =0;
kfree(fid);
if (!cmd.priv->ejected)
if (awc_issue_command_and_block(&cmd)) goto final;
//awc_event_ack_Alloc(cmd.port);
}
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
printk(KERN_ERR "awc_tx_dealloc failed for fid %x \n",fid_handle);
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
};
int
awc_tx_dealloc(struct net_device * dev){
struct awc_private * priv = (struct awc_private *)dev->priv;
// int k=0;
struct awc_fid * fid;
AWC_ENTRY_EXIT_DEBUG(" entry awc_tx_dealloc ");
while (NULL != (fid = awc_fid_queue_pop_head(&priv->tx_large_ready)))
awc_tx_dealloc_fid(dev,fid);
while (NULL != (fid = awc_fid_queue_pop_head(&priv->tx_small_ready)))
awc_tx_dealloc_fid(dev,fid);
while (NULL != (fid = awc_fid_queue_pop_head(&priv->tx_post_process)))
awc_tx_dealloc_fid(dev,fid);
while (NULL != (fid = awc_fid_queue_pop_head(&priv->tx_in_transmit)))
awc_tx_dealloc_fid(dev,fid);
return 0;
};
inline struct awc_fid *
awc_tx_fid_lookup_and_remove(struct net_device * dev, u16 fid_handle){
struct awc_private * priv = (struct awc_private *)dev->priv;
// int k = 0;
unsigned long flags;
struct awc_fid * fid = NULL;
int cnt=0;
AWC_ENTRY_EXIT_DEBUG(" entry awc_tx_fid_lookup ");
spin_lock_irqsave(&(priv->queues_lock),flags);
fid = priv->tx_in_transmit.head;
cnt = 0;
while (fid){
if (fid->u.tx.fid == fid_handle){
awc_fid_queue_remove(&priv->tx_in_transmit, fid);
spin_unlock_irqrestore(&(priv->queues_lock),flags);
return fid;
}
fid = fid->next;
// printk("iT\n");
if (cnt++ > 200) {
// printk("bbb in awc_fid_queue\n");
spin_unlock_irqrestore(&(priv->queues_lock),flags);
return 0;
};
};
cnt=0;
fid = priv->tx_post_process.head;
while (fid){
if (fid->u.tx.fid == fid_handle){
awc_fid_queue_remove(&priv->tx_post_process, fid);
spin_unlock_irqrestore(&(priv->queues_lock),flags);
return fid;
}
fid = fid->next;
// printk("pp\n");
if (cnt++ > 200) {
// printk("bbb in awc_fid_queue\n");
spin_unlock_irqrestore(&(priv->queues_lock),flags);
return 0;
};
};
cnt=0;
fid = priv->tx_large_ready.head;
while (fid){
if (fid->u.tx.fid == fid_handle){
awc_fid_queue_remove(&priv->tx_large_ready, fid);
spin_unlock_irqrestore(&(priv->queues_lock),flags);
return fid;
}
fid = fid->next;
// printk("lr\n");
if (cnt++ > 200) {
// printk("bbb in awc_fid_queue\n");
spin_unlock_irqrestore(&(priv->queues_lock),flags);
return 0;
};
};
cnt=0;
fid = priv->tx_small_ready.head;
while (fid){
if (fid->u.tx.fid == fid_handle){
awc_fid_queue_remove(&priv->tx_small_ready, fid);
spin_unlock_irqrestore(&(priv->queues_lock),flags);
return fid;
}
fid = fid->next;
// printk("sr\n");
if (cnt++ > 200) {
// printk("bbb in awc_fid_queue\n");
spin_unlock_irqrestore(&(priv->queues_lock),flags);
return 0;
};
};
spin_unlock_irqrestore(&(priv->queues_lock),flags);
printk(KERN_ERR "%s tx fid %x not found \n",dev->name, fid_handle);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return NULL;
}
int
awc_queues_init(struct net_device * dev){
struct awc_private * priv = (struct awc_private *)dev->priv;
struct awc_fid * fid = NULL;
int retv =0;
int k = 0;
awc_fid_queue_init(&priv->tx_in_transmit);
awc_fid_queue_init(&priv->tx_post_process);
awc_fid_queue_init(&priv->tx_large_ready);
awc_fid_queue_init(&priv->tx_small_ready);
awc_fid_queue_init(&priv->rx_ready);
awc_fid_queue_init(&priv->rx_post_process);
retv = awc_tx_alloc(dev);
k = 0;
while (k < AWC_RX_BUFFS){
fid = kmalloc(sizeof(struct awc_fid),GFP_KERNEL);
if (!fid) return -1;
awc_fid_queue_push_tail(&priv->rx_ready,fid);
k++;
};
if (retv) return retv;
return 0;
};
int
awc_queues_destroy(struct net_device * dev){
struct awc_private * priv = (struct awc_private *)dev->priv;
struct awc_fid * fid = NULL;
int retv =0;
while (NULL != (fid = awc_fid_queue_pop_head(&priv->rx_ready))){
kfree(fid);
}
while (NULL != (fid = awc_fid_queue_pop_head(&priv->rx_post_process))){
kfree(fid);
}
retv = awc_tx_dealloc(dev);
return retv;
};
/****************************** 802.11router ******************/
inline int
awc_802_11_copy_path_skb(struct net_device * dev, struct awc_fid * rx_buff){
struct awc_private * priv = (struct awc_private * )dev->priv;
AWC_ENTRY_EXIT_DEBUG("awc_802_11_copy_path_skb");
if (rx_buff->pkt_len < 22 ) rx_buff->pkt_len = 22;
// if (!rx_buff->skb)
rx_buff->skb = dev_alloc_skb(rx_buff->pkt_len + 12 +2);
if (rx_buff->skb == NULL) {
printk(KERN_CRIT "couldnt alloc rx_buff->skb in rx event \n");
priv->stats.rx_dropped++;
return -1;
}
rx_buff->type |= p80211copy_path_skb;
rx_buff->skb->dev = dev;
// skb_reserve(rx_buff->skb, rx_buff->pkt_len + 12 );
rx_buff->u.rx.payload = skb_put(rx_buff->skb, rx_buff->pkt_len + 12 ) ;
rx_buff->u.rx.payload = ((char *)rx_buff->u.rx.payload ) +12;
AWC_ENTRY_EXIT_DEBUG("exit\n");
return 0;
};
int
awc_802_11_find_copy_path(struct net_device * dev, struct awc_fid * rx_buff){
// struct awc_private * priv = (struct awc_private * )dev->priv;
// u8 is_802_3 = 0;
// int i = 0;
rx_buff->type =0;
return awc_802_11_copy_path_skb(dev,rx_buff);
};
/* called from INTERRUPT context,
must deliver the packet to where it was meant by
awc_802_11_find_copy_path
SHOULD be efficient and
queue the packet if operations take longer
*/
int parse_not_8023;
void
awc_802_11_router_rx(struct net_device * dev,struct awc_fid * rx_buff){
struct awc_private * priv = (struct awc_private * )dev->priv;
struct sk_buff * skb = rx_buff->skb;
u8 * payload = rx_buff->u.rx.payload;
// u8 * p802_3_macs_place = payload -12;
u16 pkt_len = rx_buff->pkt_len;
struct ieee_802_11_802_1H_header * bridge = NULL;
struct ieee_802_11_snap_header * snap = NULL;
struct ieee_802_11_802_1H_header * bridge_tmp;
struct ieee_802_11_snap_header * snap_tmp;
u16 ptr = 0;
u16 len;
AWC_ENTRY_EXIT_DEBUG("awc_802_11_router_rx");
// if (rx_buff->type & p80211_8023)
rx_buff->mac = rx_buff->u.rx.ieee_802_3.dst_mac;
// else
// rx_buff->mac = rx_buff->u.rx.ieee_802_11.mac1;
if ( rx_buff->u.rx.ieee_802_11.frame_control == 0x8 )
memcpy(priv->bssid,rx_buff->u.rx.ieee_802_11.mac3,6);
while ((ptr < pkt_len - 1 ) && payload && parse_not_8023){
bridge_tmp = (struct ieee_802_11_802_1H_header*) &payload[ptr];
snap_tmp = (struct ieee_802_11_snap_header*) &payload[ptr];
len = ntohs( *((u16*)&payload[ptr]) );
if ( len < 0x5DC) { // not a protocol
if ( len != pkt_len-2 - ptr){
printk(KERN_ERR "%s bad encapsulation lenght %x at pkt offset %x \n",dev->name,len,ptr);
goto bad_packet;
}
DEBUG(1,"parisng packet of size %x\n",len);
ptr +=2;
continue;
}
DEBUG(1,"parisng packet of proto %x\n",len);
if (snap_tmp->dsap == 0xaa && snap_tmp->ssap == 0xaa &&
pkt_len - ptr > sizeof(struct ieee_802_11_snap_header) ){
DEBUG(0x200,"%s SNAP ",dev->name);
if (snap_tmp->ctrl != 0x03){
printk(KERN_ERR "%s unknown snap ctrl %x \n",dev->name,snap_tmp->ctrl);
goto bad_packet;
};
if (snap_tmp->oui[0] == 0 && // LLC RFC1042
snap_tmp->oui[1] == 0 &&
snap_tmp->oui[2] == 0 ){
snap = snap_tmp;
ptr += sizeof(struct ieee_802_11_snap_header);
DEBUG(0x200,"%s LLC RFC1042 \n",dev->name);
continue;
}
if (snap_tmp->oui[0] == 0 && // LLC 802.1H
snap_tmp->oui[1] == 0 &&
snap_tmp->oui[2] == 0x78){
snap = snap_tmp;
DEBUG(0x200,"%s LLC 802.1H \n",dev->name);
ptr += sizeof(struct ieee_802_11_snap_header);
continue;
};
if (snap_tmp->oui[0] == 0x00 && // 802.1H itself
snap_tmp->oui[1] == 0x40 &&
snap_tmp->oui[2] == 0x96){
ptr += sizeof(struct ieee_802_11_802_1H_header);
if (ptr >= pkt_len){
goto bad_packet;
DEBUG(1,"%s invalid packet len in 802.1H SNAP OUI check \n",dev->name);
}
DEBUG(0x200,"%s OUI 004096 \n",dev->name);
DEBUG(0x200," 802.1H uknown1 %x ",ntohs(bridge_tmp->unknown1));
DEBUG(0x200," 802.1H uknw type %x \n",0xf000 & ntohs(bridge_tmp->unknown2));
DEBUG(0x200," 802.1H payloadsize %x \n",0x0fff & ntohs(bridge_tmp->unknown2));
//goto bad_packet; // TODO
bridge = bridge_tmp;
if (bridge_tmp->unknown1 == 0x0000 &&
((ntohs(bridge_tmp->unknown2) & 0xf000) == 0x1000 ) ){
rx_buff->type |= p80211_8021H;
rx_buff->mac = &payload[ptr];
DEBUG(0x200," 802.1H DATA packet of size %x\n",0xf000 & ntohs(bridge_tmp->unknown2) );
memcpy(priv->p2p,rx_buff->u.rx.ieee_802_11.mac2, 6);
ptr +=12;
continue;
};
DEBUG(0x200,"%s droping unknown 004096 packet \n ",dev->name);
goto bad_packet;
}
goto bad_packet;
}
if ( len > 0x5DC){
// packet without linklevel header for us
if ( len == 0x8000 || len == 0x8006){
DEBUG(0x200,"Non IP packet %x \n",ntohs(len));
};
goto good_packet;
};
goto good_packet;
}
good_packet:
if (ptr > pkt_len) goto bad_packet;
if ( rx_buff->mac != (payload + ptr -12) )
memcpy( payload +ptr -12, rx_buff->mac , 12);
if (!payload || !skb || !rx_buff->skb || !rx_buff->u.rx.payload)
return ;
//skb->ip_summed = CHECKSUM_NONE;
skb->data = payload + ptr -12;
skb->len += ptr ;
rx_buff->skb->protocol = eth_type_trans(rx_buff->skb,dev);
DEBUG(0x200,"eth_type_trans decided: %x\n",rx_buff->skb->protocol);
rx_buff->skb = NULL;
rx_buff->u.rx.payload = NULL;
priv->stats.rx_packets++;
priv->stats.rx_bytes += skb->len;
netif_rx(skb);
dev->last_rx = jiffies;
AWC_ENTRY_EXIT_DEBUG("exit\n");
return ;
bad_packet:
DEBUG(0x200,"%s packet dropped in packet hdr parse \n ",dev->name);
if (rx_buff->skb && (rx_buff->type & p80211copy_path_skb)){
dev_kfree_skb_irq(rx_buff->skb);
rx_buff->skb = NULL;
rx_buff->u.rx.payload = NULL;
};
AWC_ENTRY_EXIT_DEBUG("exit\n");
};
void
awc_802_11_failed_rx_copy(struct net_device * dev,struct awc_fid * rx_buff){
struct awc_private * priv = (struct awc_private * )dev->priv;
AWC_ENTRY_EXIT_DEBUG("awc_802_11_failed_rx_copy");
if (rx_buff->skb)
dev_kfree_skb_irq(rx_buff->skb);
rx_buff->skb = NULL;
rx_buff->u.rx.payload = NULL;
priv->stats.rx_errors++;
AWC_ENTRY_EXIT_DEBUG("exit\n");
};
/*
called from kernel->driver tx routine
must decide where and how to post the packet
must post the packet to wherever it decides
either copy to card or enqueue to destination queue
*/
int
awc_802_11_tx_find_path_and_post(struct net_device * dev,
struct sk_buff * skb){
struct awc_private * priv = (struct awc_private * )dev->priv;
int i;
int len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; /* check min length*/
struct awc_fid * fid = NULL;
// u16 saved_fid ;
u16 p2p_direct =priv->p2p_found;
struct iphdr * ip_hdr;
//buffer = skb->data;
AWC_ENTRY_EXIT_DEBUG("awc_802_11_tx_find_path_and_post");
// netif_stop_queue(dev);
DOWN(&priv->tx_buff_semaphore);
if (len > dev->mtu + 16 ) {
printk(KERN_ERR "%s packet size too large %d \n",dev->name, len);
goto final;
}
if (len + AWC_TX_HEAD_SIZE < AWC_TX_ALLOC_SMALL_SIZE )
fid = awc_fid_queue_pop_head(&priv->tx_small_ready);
if (!fid)
fid = awc_fid_queue_pop_head(&priv->tx_large_ready);
if (!fid) {
DEBUG(32,"%s buffs in use \n",dev->name);
goto no_space;
}
/*
if (fid->u.tx.fid_size < len + AWC_TX_HEAD_SIZE){
awc_fid_queue_push_tail(&priv->tx_small_ready, fid);
fid = awc_fid_queue_pop_head(&priv->tx_large_ready);
}
*/
if (!fid) {
DEBUG(32,"%s buffs in use \n",dev->name);
goto no_space;
}
if (fid->u.tx.fid_size < len + AWC_TX_HEAD_SIZE - 14){
printk(KERN_ERR "found too small tx fid size %d, pktlen %d \n",fid->u.tx.fid_size, len);
}
memset(&fid->u.tx.radio_tx, 0,sizeof(struct aironet4500_radio_tx_header));
memset(&fid->u.tx.ieee_802_11, 0,sizeof(struct ieee_802_11_header));
memset(&fid->u.tx.ieee_802_3, 0,sizeof(struct ieee_802_3_header));
fid->u.tx.payload =NULL;
fid->u.tx.gap_length =0;
fid->busy = 1;
priv->tx_buffs_in_use++;
DEBUG(32,"found large buff %x \n",fid->u.tx.fid);
/*
fid->type |= p80211_llc_snap;
fid->snap.dsap = 0xaa;
fid->snap.ssap = 0xaa;
fid->snap.ctrl = 0x03;
fid->snap.oui[0] = 0x0;
fid->snap.oui[1] = 0x0;
fid->snap.oui[2] = 0x0;
*/
fid->skb = skb;
if (priv->p2p_uc && !priv->p2p_found){ // we go without encapsulation to neighbour;
for (i=0; i < 6; i++)
if (priv->p2p[i] != skb->data[i]){
p2p_direct = 1;
break;
}
};
if (priv->force_tx_rate == 2 || priv->force_tx_rate == 4 ||
priv->force_tx_rate== 11 || priv->force_tx_rate == 22){
fid->u.tx.radio_tx.tx_bit_rate = priv->force_tx_rate;
} else if (priv->force_tx_rate != 0 ) {
printk(KERN_ERR "wrong force_tx_rate=%d changed to default \n", priv->force_tx_rate);
priv->force_tx_rate = 0;
};
fid->u.tx.radio_tx.TX_Control =
aironet4500_tx_control_tx_ok_event_enable |
aironet4500_tx_control_tx_fail_event_enable |
aironet4500_tx_control_no_release;
if (len < priv->force_rts_on_shorter){
fid->u.tx.radio_tx.TX_Control |=
aironet4500_tx_control_use_rts;
};
ip_hdr = (struct iphdr * ) ((( char * ) skb->data) + 14);
if (ip_hdr && skb->data[12] == 0x80 ){
if (ip_hdr->tos & IPTOS_RELIABILITY && priv->ip_tos_reliability_rts)
fid->u.tx.radio_tx.TX_Control |=
aironet4500_tx_control_use_rts;
if (ip_hdr->tos & IPTOS_THROUGHPUT && priv->ip_tos_troughput_no_retries)
fid->u.tx.radio_tx.TX_Control |=
aironet4500_tx_control_no_retries;
};
if (priv->p802_11_send || memcmp(dev->dev_addr, skb->data +6, 6) ){
fid->u.tx.radio_tx.TX_Control |=
aironet4500_tx_control_header_type_802_11;
DEBUG(0x200,"%s bridging, forcing 802_11 send \n ",dev->name);
}
if (!priv->p2p_uc || p2p_direct) {
if ((fid->u.tx.radio_tx.TX_Control &
aironet4500_tx_control_header_type_802_11 )){
// including 802.3 header into 802.11 packet
fid->u.tx.radio_tx.PayloadLength = len -12;
fid->u.tx.ieee_802_3.payload_length = len -12 ;
fid->pkt_len = len -12;
fid->u.tx.payload = skb->data +12;
if (priv->simple_bridge){
memcpy(fid->u.tx.ieee_802_11.mac1,skb->data,6);
memcpy(fid->u.tx.ieee_802_11.mac2,skb->data +6,6);
memcpy(fid->u.tx.ieee_802_11.mac3,priv->status.CurrentBssid ,6);
memset(fid->u.tx.ieee_802_11.mac4,0,6);
fid->u.tx.ieee_802_11.frame_control = 0x8;
fid->u.tx.ieee_802_11.gapLen=6;
} else {
memcpy(fid->u.tx.ieee_802_11.mac1,skb->data,6);
memcpy(fid->u.tx.ieee_802_11.mac2,dev->dev_addr,6);
memcpy(fid->u.tx.ieee_802_11.mac3,skb->data +6 ,6);
memset(fid->u.tx.ieee_802_11.mac4,0 ,6);
fid->u.tx.ieee_802_11.frame_control = 0x108;
fid->u.tx.ieee_802_11.gapLen=6;
}
} else { // plain old 802.3, with hdr copied
fid->u.tx.radio_tx.PayloadLength = len -12;
fid->u.tx.ieee_802_3.payload_length = len -12;
fid->pkt_len = len - 12;
fid->u.tx.payload = skb->data +12;
};
memcpy(fid->u.tx.ieee_802_3.dst_mac,skb->data, 12);
DEBUG(0x200,"%s tx simply 802.3 type \n ",dev->name);
} else {// 802.1H bridgeing
fid->type |= p80211_8021H;
fid->bridge_size = len + sizeof(fid->bridge) ;
fid->bridge.dsap = 0xaa;
fid->bridge.ssap = 0xaa;
fid->bridge.ctrl = 0x03;
fid->bridge.oui[0] = 0x0;
fid->bridge.oui[1] = 0x40;
fid->bridge.oui[2] = 0x96;
fid->bridge.unknown1= 0x0000;
fid->bridge.unknown2= htons((len) & 0x1000);
fid->u.tx.radio_tx.PayloadLength = fid->bridge_size + 2;
fid->u.tx.ieee_802_3.payload_length = fid->u.tx.radio_tx.PayloadLength ;
fid->u.tx.payload = skb->data +12;
if ((fid->u.tx.radio_tx.TX_Control &
aironet4500_tx_control_header_type_802_11 )){
memcpy(fid->u.tx.ieee_802_11.mac1,priv->p2p,6);
memcpy(fid->u.tx.ieee_802_11.mac2,skb->data +6,6);
memcpy(fid->u.tx.ieee_802_11.mac3,priv->bssid ,6);
memset(fid->u.tx.ieee_802_11.mac4,0,6);
fid->u.tx.ieee_802_11.gapLen=6;
fid->u.tx.ieee_802_11.frame_control = 0x8;
}
memcpy(fid->u.tx.ieee_802_3.dst_mac,priv->p2p, 6);
memcpy(fid->u.tx.ieee_802_3.src_mac,dev->dev_addr, 6);
fid->u.tx.payload = skb->data + 2 + sizeof(fid->bridge);
fid->pkt_len = len ;
DEBUG(0x200,"%s tx simply 802.1H type \n ",dev->name);
};
priv->stats.tx_bytes += fid->u.tx.ieee_802_3.payload_length;
priv->stats.tx_packets++;
awc_fid_queue_push_tail(&priv->tx_in_transmit,fid);
udelay(1);
awc_transmit_packet(dev,fid);
if (priv->tx_large_ready.size <= 2 || priv->tx_small_ready.size <= 2 ){
if (netif_running(dev))
netif_stop_queue(dev);
} else {
if (netif_running(dev))
netif_wake_queue(dev);
}
UP(&priv->tx_buff_semaphore);
AWC_ENTRY_EXIT_DEBUG("exit\n");
return 0;
no_space:
DEBUG(32,"%s tx buffs not found \n ",dev->name);
#ifdef AWC_DEBUG
// printk("s");
#endif
netif_stop_queue (dev); //weell, here it must be set anyway and before
//priv->stats.tx_fifo_errors++;
UP(&priv->tx_buff_semaphore);
AWC_ENTRY_EXIT_DEBUG("NoSpaceExit\n");
return 1 ;
final:
priv->stats.tx_errors++;
UP(&priv->tx_buff_semaphore);
if (!netif_running(dev))
netif_start_queue(dev);
dev_kfree_skb(skb);
AWC_ENTRY_EXIT_DEBUG("BADExit\n");
return -1;
};
/*
called from low level driver->card tx copy routine
probably wants to free skbuf if failed transmits won't be
resubmitted to another device (if more than one path)
or tried again (if tx buffer in card needs to be filled again)
*/
void
awc_802_11_after_tx_packet_to_card_write(struct net_device * dev,
struct awc_fid * tx_buff){
AWC_ENTRY_EXIT_DEBUG("awc_802_11_after_tx_packet_to_card_write");
if (!tx_buff){
DEBUG(1,"%s no damn tx_buff in awc_802_11_after_tx_packet_to_card_write \n",dev->name);
};
if(tx_buff->skb){
dev_kfree_skb(tx_buff->skb);
tx_buff->skb = NULL;
}
AWC_ENTRY_EXIT_DEBUG("exit\n");
};
/*
called from low level driver->card tx copy routine
probably wants to free skbuf if failed writes won't be
resubmitted to another device (if more than one path)
or tried again (if tx buffer in card needs to be filled again)
*/
void
awc_802_11_after_failed_tx_packet_to_card_write(struct net_device * dev,
struct awc_fid * tx_buff){
struct awc_private * priv = (struct awc_private *)dev->priv;
AWC_ENTRY_EXIT_DEBUG("awc_802_11_after_failed_tx_packet_to_card_write");
if (!tx_buff){
DEBUG(1,"%s no damn tx_buff in awc_802_11_after_failed_tx_packet_to_card_write \n",dev->name);
};
if(tx_buff->skb){
dev_kfree_skb(tx_buff->skb);
tx_buff->skb = NULL;
tx_buff->busy =0;
printk(KERN_ERR "%s packet to card write failed \n",dev->name);
}
awc_fid_queue_remove(&priv->tx_in_transmit,tx_buff);
if (tx_buff->u.tx.fid_size <= AWC_TX_ALLOC_SMALL_SIZE)
awc_fid_queue_push_tail(&priv->tx_small_ready,tx_buff);
else
awc_fid_queue_push_tail(&priv->tx_large_ready,tx_buff);
AWC_ENTRY_EXIT_DEBUG("exit\n");
};
inline void
awc_802_11_after_tx_complete(struct net_device * dev, struct awc_fid * tx_buff){
struct awc_private * priv = (struct awc_private *)dev->priv;
AWC_ENTRY_EXIT_DEBUG("awc_802_11_after_tx_complete");
DEBUG(32,"tx complete status %x \n ",tx_buff->u.tx.radio_tx.Status);
#ifdef AWC_DEBUG
if (tx_buff->u.tx.radio_tx.Status)
printk("tf%x ",tx_buff->u.tx.radio_tx.Status);
#endif
if (tx_buff->u.tx.fid_size <= AWC_TX_ALLOC_SMALL_SIZE){
awc_fid_queue_push_tail(&priv->tx_small_ready,tx_buff);
priv->tx_small_buffs_in_use--;
} else {
awc_fid_queue_push_tail(&priv->tx_large_ready,tx_buff);
priv->tx_buffs_in_use--;
}
tx_buff->busy = 0;
// netif_wake_queue (dev);
AWC_ENTRY_EXIT_DEBUG("exit\n");
};
/******************************** R X ***********************/
inline int
awc_receive_packet(struct net_device * dev){
struct awc_command cmd;
u16 Fid;
// struct sk_buff *skb = NULL;
struct awc_fid * rx_buff;
struct awc_private * priv ;
int i;
priv= (struct awc_private *)dev->priv;
rx_buff = priv->rx_ready.head ;
AWC_ENTRY_EXIT_DEBUG(" entry awc_receive_packet ");
Fid = awc_Rx_Fid(dev->base_addr);
DEBUG(128," RX FID %x \n",Fid);
if (!Fid){
printk(KERN_CRIT "No RxFid when rx event \n");
return -1;
}
if (!rx_buff){
printk(KERN_CRIT "No rx_buff in rx event \n");
return -1;
}
rx_buff->type = 0;
AWC_INIT_COMMAND(AWC_CLI,cmd,dev,0,0,
Fid, 0, 0x14 , &(rx_buff->u.rx.radio_rx));
// header reading , order is important
AWC_BAP_LOCK_UNDER_CLI(cmd);
if (awc_bap_setup(&cmd)) goto final;
if (awc_bap_read(&cmd)) goto final;
DEBUG(128, "rx receive radio header, length %x \n",rx_buff->u.rx.radio_rx.PayloadLength);
cmd.buff = &(rx_buff->u.rx.ieee_802_11);
cmd.len = 0x20;
if (awc_bap_read(&cmd)) goto final;
DEBUG(128, "rx receive 802_11 header, framecontrol %x \n",rx_buff->u.rx.ieee_802_11.frame_control);
if (rx_buff->u.rx.ieee_802_11.gapLen > 8) {
printk(KERN_ERR "%s: 802.11 gap lenght huge %d \n",dev->name,rx_buff->u.rx.ieee_802_11.gapLen);
goto final;
}
DEBUG(128,"SeqCtl %x, 802_11 macs: ",rx_buff->u.rx.ieee_802_11.SeqCtl);
if (awc_debug & 0x7000){
DEBUG(0x7000, " %s mac1 ",dev->name); for (i = 0; i < 6; i++) DEBUG(0x7000, "%02x:",((unsigned char)rx_buff->u.rx.ieee_802_11.mac1[i] )) ;
DEBUG(0x7000, " %s mac2 ",dev->name); for (i = 0; i < 6; i++) DEBUG(0x7000, "%02x:",((unsigned char)rx_buff->u.rx.ieee_802_11.mac2[i] )) ;
DEBUG(0x7000, " %s mac3 ",dev->name); for (i = 0; i < 6; i++) DEBUG(0x7000, "%02x:",((unsigned char)rx_buff->u.rx.ieee_802_11.mac3[i] )) ;
DEBUG(0x7000, " %s mac4 ",dev->name); for (i = 0; i < 6; i++) DEBUG(0x7000, "%02x:",((unsigned char)rx_buff->u.rx.ieee_802_11.mac4[i] )) ;
}
DEBUG(128,"\n GapLen %d ",rx_buff->u.rx.ieee_802_11.gapLen );
if (rx_buff->u.rx.ieee_802_11.gapLen > 0) {
cmd.buff = rx_buff->u.rx.ieee_802_11.gap;
cmd.len = rx_buff->u.rx.ieee_802_11.gapLen;
if (awc_bap_read(&cmd)) goto final;
DEBUG(128, "rx receive gap header , gap length %x \n",rx_buff->u.rx.gap_length);
}
for (i = 0; i < rx_buff->u.rx.ieee_802_11.gapLen ; i++) DEBUG(128,"%x",((unsigned char)rx_buff->u.rx.ieee_802_11.gap[i] )) ;
if ( !(priv->config.ReceiveMode & RXMODE_DISABLE_802_3_HEADER )
){
cmd.buff = &(rx_buff->u.rx.ieee_802_3);
cmd.len = 0x10;
rx_buff->type |= p80211_8023;
if (awc_bap_read(&cmd)) goto final;
DEBUG(128, "rx receive 802_3 header, payload length %x \n",rx_buff->u.rx.ieee_802_3.payload_length);
DEBUG(128,"\n 802_3 status %x ",rx_buff->u.rx.ieee_802_3.status );
DEBUG(128," RX payloadLen %x, dst,src: ",rx_buff->u.rx.ieee_802_3.payload_length);
if (awc_debug & 0x7000){
for (i = 0; i < 6; i++) printk("%02x:",((unsigned char)rx_buff->u.rx.ieee_802_3.dst_mac[i] )) ;
for (i = 0; i < 6; i++) printk("%02x:",((unsigned char)rx_buff->u.rx.ieee_802_3.src_mac[i] )) ;
}
};
rx_buff->pkt_len = rx_buff->u.rx.radio_rx.PayloadLength;
if (priv->config.OperatingMode & MODE_LLC_HOST)
rx_buff->type |= p80211_llc_snap;
if (awc_802_11_find_copy_path(dev,rx_buff)) goto final;
if (rx_buff->u.rx.payload ){
cmd.buff = rx_buff->u.rx.payload;
cmd.len = rx_buff->pkt_len;
if (awc_bap_read(&cmd)) goto final;
DEBUG(128, "rx payload read %x \n",rx_buff->u.rx.ieee_802_3.payload_length);
};
AWC_RELEASE_COMMAND(cmd);
DEBUG(128,"\n payload hdr %x ",rx_buff->u.rx.ieee_802_3.status );
if (awc_debug && rx_buff->u.rx.payload)
for (i = 0; i < 20; i++) DEBUG(128,"%x",((unsigned char)rx_buff->u.rx.payload[i] )) ;
DEBUG(128,"%c",'\n');
awc_802_11_router_rx(dev,rx_buff);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
awc_802_11_failed_rx_copy(dev,rx_buff);
// if (skb) dev_kfree_skb(skb, FREE_WRITE);
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
};
int
awc_transmit_packet(struct net_device * dev, struct awc_fid * tx_buff) {
struct awc_command cmd;
u16 size ;
// unsigned long flags;
int i;
struct awc_private * priv= (struct awc_private *)dev->priv;
AWC_ENTRY_EXIT_DEBUG(" entry awc_transmit_packet ");
if (priv->link_status_changed ){
priv->link_status_changed =0;
awc_readrid_dir(dev,&priv->rid_dir[7]);
}
AWC_INIT_COMMAND(AWC_NOT_CLI,cmd,dev,0xB, tx_buff->u.tx.fid,
tx_buff->u.tx.fid, 0, 0x14 , &(tx_buff->u.tx.radio_tx));
AWC_BAP_LOCK_NOT_CLI(cmd);
#ifdef AWC_BY_BOOK
#warning By books is bad, AWC_BY_BOOK
#error cli sti bad here
if ( !(tx_buff->type &(p80211_llc_snap|p80211_8021H) )
&& !(tx_buff->u.tx.radio_tx.TX_Control &
aironet4500_tx_control_header_type_802_11 )){
cmd.buff=&(tx_buff->u.tx.radio_tx.TX_Control);
cmd.len = 0x2 ;
cmd.offset = 0x8;
save_flags(flags);
cli();
if (awc_bap_setup(&cmd)) goto final;
if (awc_bap_write(&cmd)) goto final;
cmd.buff=&(tx_buff->u.tx.ieee_802_3.payload_length);
cmd.len = 14;
cmd.offset = 0x36;
if (awc_bap_setup(&cmd)) goto final;
if (awc_bap_write(&cmd)) goto final;
restore_flags(flags);
} else {
#endif
if (awc_bap_setup(&cmd)) goto final;
if (awc_bap_write(&cmd)) goto final;
DEBUG(64," wrote radio tx header for fid %x \n",tx_buff->u.tx.fid);
// 802.11
cmd.buff=&(tx_buff->u.tx.ieee_802_11);
cmd.len = 0x20;
if (awc_bap_write(&cmd)) goto final;
// Gap
if (tx_buff->u.tx.ieee_802_11.gapLen) {
cmd.buff=&(tx_buff->u.tx.ieee_802_11.gap);
cmd.len = tx_buff->u.tx.ieee_802_11.gapLen;
if (awc_bap_write(&cmd)) goto final;
}
// 802.3
if ( ! (tx_buff->u.tx.radio_tx.TX_Control &
aironet4500_tx_control_header_type_802_11 )){
cmd.buff=&(tx_buff->u.tx.ieee_802_3);
if (awc_debug & 0x7000){
printk("%s TX dst ",dev->name);
for (i=0; i < 6; i++) printk ("%02x:",(unsigned char) tx_buff->u.tx.ieee_802_3.dst_mac[i]);
printk(" src ");
for (i=0; i < 6; i++) printk ("%02x:",(unsigned char) tx_buff->u.tx.ieee_802_3.src_mac[i]);
printk(" \n ");
}
cmd.len = 0x10;
if (awc_bap_write(&cmd)) goto final;
};
if (tx_buff->type & p80211_llc_snap) {
cmd.buff= & tx_buff->snap;
cmd.len = sizeof(tx_buff->snap);
if (awc_bap_write(&cmd)) goto final;
};
if (tx_buff->type & p80211_8021H) {
size = htons(tx_buff->bridge_size);
// size = tx_buff->bridge_size;// to seasure raw speed of f** UC
cmd.buff= & size;
cmd.len = 2 ;
if (awc_bap_write(&cmd)) goto final;
cmd.buff= & tx_buff->bridge;
cmd.len = sizeof(tx_buff->bridge);
if (awc_bap_write(&cmd)) goto final;
};
#ifdef AWC_BY_BOOK
}
#endif
cmd.buff= tx_buff->u.tx.payload;
cmd.len = tx_buff->pkt_len;
if (awc_bap_write(&cmd)) goto final;
AWC_RELEASE_COMMAND(cmd);
// locking probs, these two lines below and above, swithc order
if (awc_issue_command_and_block(&cmd)) goto final_unlocked;
tx_buff->transmit_start_time = jiffies;
awc_802_11_after_tx_packet_to_card_write(dev,tx_buff);
// issue the transmit command
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
awc_802_11_after_failed_tx_packet_to_card_write(dev,tx_buff);
printk(KERN_CRIT "%s awc tx command failed \n",dev->name);
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
final_unlocked:
awc_802_11_after_failed_tx_packet_to_card_write(dev,tx_buff);
printk(KERN_CRIT "%s awc tx command failed \n",dev->name);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
}
inline int
awc_tx_complete_check(struct net_device * dev){
struct awc_fid * fid;
struct awc_command cmd;
AWC_ENTRY_EXIT_DEBUG(" entry awc_tx_complete_check ");
fid = awc_fid_queue_pop_head(&((struct awc_private *)dev->priv)->tx_post_process);
if (!fid) {
printk("awc_tx_complete_check with empty queue \n ");
return -1;
}
DEBUG(64," tx_complete fid %x \n",fid->u.tx.fid);
AWC_INIT_COMMAND(AWC_NOT_CLI,cmd,dev,0,0, fid->u.tx.fid,
0, 0x14 , &(fid->u.tx.radio_tx));
fid->state |= awc_tx_fid_complete_read;
AWC_BAP_LOCK_NOT_CLI(cmd);
if (awc_bap_setup(&cmd)) goto final;
if (awc_bap_read(&cmd)) goto final;
AWC_RELEASE_COMMAND(cmd);
awc_802_11_after_tx_complete(dev,fid);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
return 0;
final:
awc_802_11_after_tx_complete(dev,fid);
printk(KERN_ERR "%s awc_tx_complete_check failed \n",dev->name);
AWC_RELEASE_COMMAND(cmd);
AWC_ENTRY_EXIT_DEBUG(" BAD exit \n");
return -1; ;
}
#define AWC_QUEUE_BH {\
if (!priv->work_active && !priv->work_running){\
priv->work_active = 1;\
schedule_work(&priv->work); \
}\
}
void
awc_bh(struct net_device *dev){
struct awc_private * priv = (struct awc_private *)dev->priv;
int active_interrupts;
int enabled_interrupts;
// u16 tx_status;
int multi_ints = 0;
// u16 tx_fid = 0;
// unsigned long flags;
DEBUG(8, "awc_bh awoken on jiffie %ld \n",jiffies);
priv->work_running = 1;
active_interrupts = awc_event_status(dev->base_addr);
enabled_interrupts = awc_ints_enabled(dev->base_addr);
DEBUG(8, "awc_bh active ints %x \n",active_interrupts);
if (test_and_set_bit( 0, (void *) &priv->tx_chain_active) ) {
// printk(KERN_ERR "tx chain active in bh \n");
// schedule_work(&priv->work);
goto bad_end;
}
start:
if (active_interrupts == 0xffff){
printk(KERN_CRIT "%s device ejected in interrupt, disabling\n",dev->name);
netif_device_detach (dev);
if (priv->command_semaphore_on){
priv->command_semaphore_on--;
AWC_UNLOCK_COMMAND_ISSUING(priv);
}
priv->tx_chain_active =0;
goto bad_end;
}
if (priv->unlock_command_postponed ){
priv->unlock_command_postponed-- ;
if( priv->command_semaphore_on ){
awc_read_response((&priv->cmd));
priv->async_command_start = 0;
if (priv->command_semaphore_on){
priv->command_semaphore_on--;
AWC_UNLOCK_COMMAND_ISSUING(priv);
}
}
};
/* if ( active_interrupts & 0x1 ){
awc_receive_packet(dev) ;
awc_event_ack_Rx(dev->base_addr);
priv->waiting_interrupts &= ~0x1;
}
*/
while (priv->tx_post_process.size)
if (awc_tx_complete_check(dev)) break;
active_interrupts = awc_event_status(dev->base_addr);
if (priv->command_semaphore_on || priv->tx_post_process.size){
if (multi_ints++ < 10000){
goto start;
}
};
priv->work_active = 0;
priv->work_running = 0;
priv->tx_chain_active = 0;
bad_end:
// if (!priv->tx_chain_active)
// wake_up(&priv->tx_chain_wait_queue);
priv->work_running = 0;
priv->work_active = 0;
return ;
};
inline int
awc_interrupt_process(struct net_device * dev){
struct awc_private * priv ;
int active_interrupts;
int enabled_interrupts;
u16 tx_status;
int multi_ints = 0;
u16 tx_fid = 0;
// u16 ints_to_ack =0;
struct awc_fid * fid = NULL;
// int interrupt_reenter = 0;
// unsigned long flags;
// save_flags(flags);
// cli();
// here we need it, because on 2.3 SMP there are truly parallel irqs
disable_irq(dev->irq);
DEBUG(2," entering interrupt handler %s ",dev->name);
if (!dev) {
printk(KERN_ERR "No dev in interrupt \n");
goto bad_end;
};
priv = (struct awc_private *)dev->priv;
if (!priv) {
printk(KERN_ERR "No PRIV in interrupt \n");
goto bad_end;
};
enabled_interrupts = awc_ints_enabled(dev->base_addr);
active_interrupts = awc_event_status(dev->base_addr);
DEBUG(2,"entry: processing interrupts waiting %x \n",priv->waiting_interrupts);
DEBUG(2,"entry: processing interrupts active %x \n",active_interrupts);
DEBUG(2,"entry: processing interrupts enabled %x \n",enabled_interrupts);
// printk("ikka interruptis\n");
priv->interrupt_count++;
if (priv->interrupt_count > 1 )
printk(" interrupt count on\n ");
if (priv->waiting_interrupts & active_interrupts)
printk(KERN_ERR "double interrupt waiting %x active %x \n",
priv->waiting_interrupts, active_interrupts);
// priv->waiting_interrupts |= active_interrupts;
start:
DEBUG(2,"Start processing int, times %d\n",multi_ints);
if (active_interrupts == 0xffff){
printk(KERN_CRIT "%s device ejected, got interrupt, disabling\n",dev->name);
//priv->
netif_device_detach (dev);
priv->ejected = 1;
if (priv->work_active || priv->work_running){
priv->interrupt_count--;
goto bad_end;
} else if (priv->command_semaphore_on){
printk(KERN_ERR "ejected, last BH fired \n");
AWC_QUEUE_BH;
}
priv->interrupt_count--;
goto bad_end;
}
if (active_interrupts & 0x100 ){
awc_event_ack_Awaken(dev->base_addr);
udelay(10);
DEBUG(1,"%s device awoke \n",dev->name);
priv->waiting_interrupts &= ~0x100;
};
if (active_interrupts & 0x80 ){
priv->link_status = awc_Link_Status(dev->base_addr);
DEBUG(1,"link status changed %x \n",priv->link_status);
awc_event_ack_Link(dev->base_addr);
priv->waiting_interrupts &= ~0x80;
if(priv->link_status == 0x400)
printk(KERN_INFO "%s Associated\n",dev->name );
else {
printk(KERN_INFO "%s Link status change : %s \n",dev->name, awc_print_string(awc_link_status_names, priv->link_status) );
if ( priv->link_status & 0x8100 ||
priv->link_status & 0x0100 ||
priv->link_status & 0x8200 ||
priv->link_status & 0x8400 ||
priv->link_status & 0x0300 )
printk(KERN_INFO "%s Link status change reason : %s \n",dev->name, awc_print_string(awc_link_failure_reason_names, priv->link_status & 0xff) );
}
};
if (active_interrupts & 0x10 & enabled_interrupts ){
// printk(KERN_ERR "cmd int shouldnt be active in interrupt routine\n");
awc_event_ack_Cmd(priv->cmd.port);
if ( priv->enabled_interrupts & 0x10)
priv->enabled_interrupts &= ~0x10;
enabled_interrupts = awc_ints_enabled(dev->base_addr);
if (enabled_interrupts & 0x10){
awc_ints_enable(dev->base_addr, enabled_interrupts & ~0x10);
}
if (priv->command_semaphore_on){
priv->unlock_command_postponed++;
AWC_QUEUE_BH;
}
}
if ((active_interrupts & 0x10) && !(0x10 & enabled_interrupts) ){
// printk(KERN_ERR "%s: aironet4500: cmd int shouldnt be active in interrupt routine\n",dev->name);
//awc_event_ack_Cmd(priv->cmd.port);
}
// active_interrupts = awc_event_status(dev->base_addr);
tx_status = active_interrupts & 0x6 ;
if (tx_status) {
tx_fid = awc_Tx_Compl_Fid(dev->base_addr);
if (!tx_fid){
udelay(10);
tx_fid = awc_Tx_Compl_Fid(dev->base_addr);
}
if (!tx_fid)
printk(KERN_ERR "No tx fid when tx int active\n");
fid = awc_tx_fid_lookup_and_remove(dev, tx_fid);
if (fid) {
if (priv->process_tx_results) {
awc_fid_queue_push_tail(&priv->tx_post_process,fid);
AWC_QUEUE_BH;
}else {
if (fid->u.tx.fid_size <= AWC_TX_ALLOC_SMALL_SIZE)
awc_fid_queue_push_tail(&priv->tx_small_ready,fid);
else
awc_fid_queue_push_tail(&priv->tx_large_ready,fid);
netif_wake_queue (dev);
}
} else
printk(KERN_ERR "awc fid %x not found\n",tx_fid);
if (tx_status & 2){
awc_event_ack_Tx(dev->base_addr);
priv->stats.tx_packets++;
priv->waiting_interrupts &= ~0x2;
}
if (tx_status & 4){
priv->stats.tx_errors++;
awc_event_ack_TxExc(dev->base_addr);
priv->waiting_interrupts &= ~0x4;
}
if ((tx_status&6) == 6)
printk(KERN_NOTICE "%s: both tx and txExc up\n",dev->name);
}
// active_interrupts = awc_event_status(dev->base_addr);
if ( active_interrupts & 0x1 ){
awc_receive_packet(dev);
awc_event_ack_Rx(dev->base_addr);
priv->waiting_interrupts &= ~0x1;
}
active_interrupts = awc_event_status(dev->base_addr);
if ((active_interrupts & 0x7) &&
!priv->work_active &&
!priv->work_running ){
if (multi_ints++ < 5)
goto start;
}
if (multi_ints >=5 )
printk(KERN_ERR "%s multi_ints > 5 interrupts still active %x\n",dev->name,active_interrupts);
priv->interrupt_count--;
awc_ints_enable(dev->base_addr, 0x0000);
DEBUG(0x8, " enabling ints in interrupt_process %x \n",
priv->enabled_interrupts & ~priv->waiting_interrupts);
AWC_ENTRY_EXIT_DEBUG(" exit \n");
awc_ints_enable(dev->base_addr,
priv->enabled_interrupts);
//end_here:
enable_irq(dev->irq);
// restore_flags(flags);
return 0;
bad_end:
AWC_ENTRY_EXIT_DEBUG(" bad_end exit \n");
enable_irq(dev->irq);
// restore_flags(flags);
return -1;
};
static const char *aironet4500_core_version =
"aironet4500.c v0.1 1/1/99 Elmer Joandi, elmer@ylenurme.ee.\n";
struct net_device * aironet4500_devices[MAX_AWCS];
int awc_debug; // 0xffffff;
static int p802_11_send; // 1
static int awc_process_tx_results;
int tx_queue_len = 10;
int tx_rate;
int channel = 5;
//static int tx_full_rate;
int max_mtu = 2312;
int adhoc;
int large_buff_mem = 1700 * 10;
int small_buff_no = 20;
int awc_full_stats;
char SSID[33];
int master;
int slave;
int awc_simple_bridge;
// int debug =0;
#if LINUX_VERSION_CODE >= 0x20100
MODULE_PARM(awc_debug,"i");
MODULE_PARM(tx_rate,"i");
MODULE_PARM(channel,"i");
//MODULE_PARM(tx_full_rate,"i");
MODULE_PARM(adhoc,"i");
MODULE_PARM(master,"i");
MODULE_PARM(slave,"i");
MODULE_PARM(awc_simple_bridge,"i");
MODULE_PARM(max_mtu,"i");
MODULE_PARM(large_buff_mem,"i");
MODULE_PARM(small_buff_no,"i");
MODULE_PARM(SSID,"c33");
MODULE_PARM_DESC(awc_debug,"Aironet debug mask");
MODULE_PARM_DESC(channel,"Aironet ");
MODULE_PARM_DESC(adhoc,"Aironet Access Points not available (0-1)");
MODULE_PARM_DESC(master,"Aironet is Adhoc master (creates network sync) (0-1)");
MODULE_PARM_DESC(slave,"Aironet is Adhoc slave (0-1)");
MODULE_PARM_DESC(max_mtu,"Aironet MTU limit (256-2312)");
#endif
MODULE_LICENSE("GPL");
/*EXPORT_SYMBOL(tx_queue_len);
EXPORT_SYMBOL(awc_debug);
*/
EXPORT_SYMBOL(awc_init);
EXPORT_SYMBOL(awc_open);
EXPORT_SYMBOL(awc_close);
EXPORT_SYMBOL(awc_reset);
EXPORT_SYMBOL(awc_config);
EXPORT_SYMBOL(aironet4500_devices);
EXPORT_SYMBOL(awc_debug);
//EXPORT_SYMBOL();
EXPORT_SYMBOL(awc_private_init);
EXPORT_SYMBOL(awc_tx_timeout);
EXPORT_SYMBOL(awc_start_xmit);
EXPORT_SYMBOL(awc_interrupt);
EXPORT_SYMBOL(awc_get_stats);
EXPORT_SYMBOL(awc_change_mtu);
EXPORT_SYMBOL(awc_set_multicast_list);
EXPORT_SYMBOL(awc_proc_set_fun);
EXPORT_SYMBOL(awc_proc_unset_fun);
EXPORT_SYMBOL(awc_register_proc);
EXPORT_SYMBOL(awc_unregister_proc);
/*************************** RESET INIT CONFIG ***********************/
void awc_reset(struct net_device *dev)
{
long long jiff;
DEBUG(2, " awc_reset dev %p \n", dev);
DEBUG(2, "%s: awc_reset \n", dev->name);
awc_issue_soft_reset(dev);
jiff = jiffies;
udelay(1000);
while (awc_command_read(dev->base_addr)){
udelay(1000);
if (jiffies - jiff > 5*HZ){
printk(KERN_CRIT "%s bad reset\n",dev->name);
break;
}
};
}
int awc_config(struct net_device *dev)
{
// struct awc_private *priv = (struct awc_private *)dev->priv;
DEBUG(2, "%s: awc_config \n", dev->name);
if( awc_disable_MAC(dev)) goto final;
udelay(100);
if( awc_write_all_rids(dev) ) goto final;
udelay(100);
if( awc_enable_MAC(dev)) goto final;
return 0;
final:
return -1;
}
char name[] = "ElmerLinux";
int awc_init(struct net_device *dev){
struct awc_private *priv = (struct awc_private *)dev->priv;
int i;
const char * radioType;
DEBUG(2, "%s: awc_init \n", dev->name);
/* both_bap_lock decreases performance about 15%
* but without it card gets screwed up
*/
#ifdef CONFIG_SMP
both_bap_lock = 1;
bap_setup_spinlock = 1;
#endif
//awc_dump_registers(dev);
if (adhoc & !max_mtu)
max_mtu= 2250;
else if (!max_mtu)
max_mtu= 1500;
priv->sleeping_bap = 1;
priv->enabled_interrupts = awc_ints_enabled(dev->base_addr);
if( awc_issue_noop(dev) ) goto final;
awc_ints_enable(dev->base_addr,0);
if( awc_disable_MAC(dev) ) goto final;
// awc_rids_setup(dev);
i=0;
while ( i < AWC_NOF_RIDS){
if (awc_rids_temp[i].selector)
memcpy(&priv->rid_dir[i],&awc_rids_temp[i],sizeof(priv->rid_dir[0]) );
else priv->rid_dir[i].selector = NULL;
i++;
}
// following MUST be consistent with awc_rids in count and ordrering !!!
priv->rid_dir[0].buff = &priv->config; // card RID mirrors
priv->rid_dir[1].buff = &priv->SSIDs;
priv->rid_dir[2].buff = &priv->fixed_APs;
priv->rid_dir[3].buff = &priv->driver_name;
priv->rid_dir[4].buff = &priv->enc_trans;
priv->rid_dir[5].buff = &priv->general_config; //
priv->rid_dir[6].buff = &priv->capabilities;
priv->rid_dir[7].buff = &priv->status;
priv->rid_dir[8].buff = &priv->AP;
priv->rid_dir[9].buff = &priv->statistics;
priv->rid_dir[10].buff = &priv->statistics_delta;
priv->rid_dir[11].buff = &priv->statistics_delta_clear;
priv->rid_dir[12].buff = &priv->wep_volatile;
priv->rid_dir[13].buff = &priv->wep_nonvolatile;
priv->rid_dir[14].buff = &priv->modulation;
priv->rid_dir[15].buff = &priv->statistics16;
priv->rid_dir[16].buff = &priv->statistics16_delta;
priv->rid_dir[17].buff = &priv->statistics16_delta_clear;
priv->rid_dir[0].bufflen = sizeof(priv->config); // card RID mirrors
priv->rid_dir[1].bufflen = sizeof(priv->SSIDs);
priv->rid_dir[2].bufflen = sizeof(priv->fixed_APs);
priv->rid_dir[3].bufflen = sizeof(priv->driver_name);
priv->rid_dir[4].bufflen = sizeof(priv->enc_trans);
priv->rid_dir[5].bufflen = sizeof(priv->general_config); //
priv->rid_dir[6].bufflen = sizeof(priv->capabilities);
priv->rid_dir[7].bufflen = sizeof(priv->status);
priv->rid_dir[8].bufflen = sizeof(priv->AP);
priv->rid_dir[9].bufflen = sizeof(priv->statistics);
priv->rid_dir[10].bufflen = sizeof(priv->statistics_delta);
priv->rid_dir[11].bufflen = sizeof(priv->statistics_delta_clear);
priv->rid_dir[12].bufflen = sizeof(priv->wep_volatile);
priv->rid_dir[13].bufflen = sizeof(priv->wep_nonvolatile);
priv->rid_dir[14].bufflen = sizeof(priv->modulation);
priv->rid_dir[15].bufflen = sizeof(priv->statistics16);
priv->rid_dir[16].bufflen = sizeof(priv->statistics16_delta);
priv->rid_dir[17].bufflen = sizeof(priv->statistics16_delta_clear);
if( awc_read_all_rids(dev) ) goto final;
priv->config.OperatingMode = 0;// MODE_LLC_HOST;
DEBUG(1,"ReceiveMode %x \n",priv->config.ReceiveMode);
// priv->config.ReceiveMode = RXMODE_DISABLE_802_3_HEADER;
if (!adhoc)
priv->config.OperatingMode = MODE_STA_ESS;
// priv->config.OperatingMode = MODE_AP;
// Setting rates does not work with new hardware, use force_tx_rate via proc
// priv->config.Rates[0] =0x82;
// priv->config.Rates[1] =0x4;
// priv->config.Rates[2] =tx_full_rate;
// priv->config.Rates[3] =0;
// priv->config.Rates[4] =0;
// priv->config.Rates[5] =0;
// priv->config.Rates[6] =0;
// priv->config.Rates[7] =0;
priv->config.Channel = channel;
if (adhoc && master){
priv->config.JoinNetTimeout = 0x1;//0 is facotry default
} else if (adhoc && slave){
// by spec 0xffff, but, this causes immediate bad behaviour
// firmware behvaiour changed somehere around ver 2??
priv->config.JoinNetTimeout = 0x7fff;
};
// priv->config.AuthenticationType = 1;
priv->config.Stationary =1;
// priv->config.ScanMode = 1;
// priv->config.LinkLossDelay = 100;
priv->config.FragmentThreshold = 1700;
priv->config.RtsThreshold = 1700;
memcpy(priv->config.NodeName, name, 10);
DEBUG(1,"%s supported Rates \n",dev->name);
for (i=0; i< 8; i++)
DEBUG(1,"%x ",priv->capabilities.SupportedRates[i]);
DEBUG(1,"%c",'\n');
DEBUG(1,"%s default Rates \n",dev->name);
for (i=0; i< 8; i++)
DEBUG(1,"%x ",priv->config.Rates[i]);
DEBUG(1,"%c",'\n');
// here we go, bad aironet
memset(&priv->SSIDs,0,sizeof(priv->SSIDs));
spin_lock_init(&priv->queues_lock);
priv->SSIDs.ridLen =0;
if (!SSID) {
priv->SSIDs.SSID[0].SSID[0] ='a';
priv->SSIDs.SSID[0].SSID[1] ='b';
priv->SSIDs.SSID[0].SSID[2] ='c';
priv->SSIDs.SSID[0].lenght =3;
} else {
int sidlen = strlen(SSID);
memcpy(priv->SSIDs.SSID[0].SSID,SSID,sidlen);
priv->SSIDs.SSID[0].lenght = sidlen;
};
priv->SSIDs.SSID[1].lenght =0;
priv->SSIDs.SSID[1].SSID[0] =0;
priv->SSIDs.SSID[1].SSID[1] =0;
priv->SSIDs.SSID[2].lenght =0;
priv->SSIDs.SSID[2].SSID[0] =0;
priv->SSIDs.SSID[2].SSID[1] =0;
// priv->enc_trans.rules[0].etherType= 0x0008;
// priv->enc_trans.rules[0].Action = 1;
memcpy( priv->config.StationMacAddress,
priv->capabilities.FactoryAddress, 6 );
memcpy(dev->dev_addr, priv->config.StationMacAddress, 6);
DEBUG(2, "%s: awc_init success \n", dev->name);
if (priv->capabilities.RadioType == 1) radioType = "802.11 Frequency Hoping";
else if (priv->capabilities.RadioType == 2) radioType = "802.11 Direct Sequence";
else if (priv->capabilities.RadioType == 4) radioType = "LM2000";
else radioType = "Multiple Radio Types";
printk("%s: %s %s found @ 0x%lx irq %d firmwareVersion %d \n",dev->name,
priv->capabilities.ProductName,radioType,
dev->base_addr,dev->irq,
priv->capabilities.SoftwareVersion);
return 0;
final:
printk(KERN_ERR "aironet init failed \n");
return -ENODEV;
};
int awc_private_init(struct net_device * dev){
struct awc_private * priv = (struct awc_private *) dev->priv;
int i = 0;
DEBUG(2, "%s: awc_private_init \n", dev->name);
memset(priv, 0, sizeof(struct awc_private));
spin_lock_init(&priv->queues_lock);
priv->bap0.select = dev->base_addr + awc_Select0_register;
priv->bap0.offset = dev->base_addr + awc_Offset0_register;
priv->bap0.data = dev->base_addr + awc_Data0_register;
priv->bap0.lock = 0;
priv->bap0.status = 0;
spin_lock_init(&priv->bap0.spinlock);
init_MUTEX(&priv->bap0.sem);
priv->bap1.select = dev->base_addr + awc_Select1_register;
priv->bap1.offset = dev->base_addr + awc_Offset1_register;
priv->bap1.data = dev->base_addr + awc_Data1_register;
priv->bap1.lock = 0;
priv->bap1.status = 0;
spin_lock_init(&priv->bap1.spinlock);
init_MUTEX(&priv->bap1.sem);
priv->sleeping_bap = 1;
//spinlock now init_MUTEX(&priv->command_semaphore);
spin_lock_init(&priv->command_issuing_spinlock);
spin_lock_init(&priv->both_bap_spinlock);
spin_lock_init(&priv->bap_setup_spinlock);
spin_lock_init(&priv->interrupt_spinlock);
priv->command_semaphore_on = 0;
priv->unlock_command_postponed = 0;
INIT_WORK(&priv->work, (void *)(void *)awc_work, dev);
priv->work_running = 0;
priv->work_active = 0;
priv->tx_chain_active = 0;
priv->enabled_interrupts= 0x00;
priv->waiting_interrupts= 0x00;
init_MUTEX(&priv->tx_buff_semaphore);
priv->tx_buffs_in_use = 0;
priv->tx_small_buffs_in_use = 0;
priv->mac_enabled =0;
priv->link_status =0;
priv->large_buff_mem = large_buff_mem;
if (priv->large_buff_mem < max_mtu + AWC_TX_HEAD_SIZE + 10 )
priv->large_buff_mem = max_mtu + AWC_TX_HEAD_SIZE + 10;
priv->small_buff_no = small_buff_no;
if (priv->small_buff_no < 1 )
priv->small_buff_no = 1 ;
priv->process_tx_results = awc_process_tx_results;
//init_waitqueue(&priv->tx_chain_wait_queue);
for (i=0; i< 6 ; i++ ) {
priv->p2p[i] = 0xff;
priv->bssid[i] =0;
}
// priv->p2p_uc =1;
priv->p2p_found =0;
priv->p802_11_send =p802_11_send;
priv->full_stats = awc_full_stats;
priv->simple_bridge = awc_simple_bridge;
priv->force_rts_on_shorter = 0;
priv->force_tx_rate = tx_rate;
priv->ip_tos_reliability_rts = 0;
priv->ip_tos_troughput_no_retries = 0 ;
priv->ejected =0;
priv->interrupt_count =0;
return 0;
};
/**************************** OPEN CLOSE **********************/
int awc_open(struct net_device *dev)
{
struct awc_private *priv = (struct awc_private *)dev->priv;
DEBUG(2, "%s: awc_open \n", dev->name);
if( awc_queues_init(dev) ) goto final;
if( awc_config(dev) ) goto final;
memcpy(dev->dev_addr, priv->config.StationMacAddress, 6);
priv->enabled_interrupts = 0x87;
awc_ints_enable(dev->base_addr,priv->enabled_interrupts);
// priv->p8022_client = register_8022_client;
// priv->snap_client = register_snap_client;
DEBUG(2, "%s: opened \n", dev->name);
priv->sleeping_bap = 0;
MOD_INC_USE_COUNT;
// kernel_thread(awc_thread,dev,0);
netif_start_queue (dev);
return 0; /* Always succeed */
final:
netif_device_detach (dev);
printk(KERN_ERR "aironet open failed \n");
return -1;
}
int awc_close(struct net_device *dev)
{
struct awc_private * priv = (struct awc_private *) dev->priv;
DEBUG(2, "%s: closing device.\n", dev->name);
netif_stop_queue (dev);
awc_disable_MAC(dev);
awc_queues_destroy(dev);
awc_reset(dev);
mdelay(10);
AWC_LOCK_COMMAND_ISSUING(priv);
MOD_DEC_USE_COUNT;
AWC_UNLOCK_COMMAND_ISSUING(priv);
return 0;
}
/****************************** TX RX STUFF ******************/
void awc_tx_timeout (struct net_device *dev)
{
struct awc_private *priv = (struct awc_private *) dev->priv;
struct awc_fid * fid;
int cnt;
unsigned long flags;
DEBUG (2, "%s: awc_tx_timeout \n", dev->name);
printk (KERN_NOTICE "%s: Transmit timed out , buffs %d %d, queues tx %d pp %d lrg %d sm %d \n ",
dev->name, priv->tx_small_buffs_total, priv->tx_buffs_total,
priv->tx_in_transmit.size, priv->tx_post_process.size,
priv->tx_large_ready.size, priv->tx_small_ready.size);
priv->stats.tx_errors++;
save_flags(flags);
cli();
fid = priv->tx_in_transmit.head;
cnt = 0;
while (fid) { // removing all fids older that that
if (jiffies - fid->transmit_start_time > (HZ)) {
// printk(KERN_ERR "%s staled tx_buff found, age %uld jiffies\n",dev->name,
// jiffies - fid->transmit_start_time );
awc_fid_queue_remove (&priv->tx_in_transmit, fid);
if (fid->u.tx.fid_size <= AWC_TX_ALLOC_SMALL_SIZE)
awc_fid_queue_push_tail (&priv->tx_small_ready, fid);
else
awc_fid_queue_push_tail (&priv->tx_large_ready, fid);
}
fid = fid->next;
if (cnt++ > 200) {
printk ("bbb in awc_fid_queue\n");
restore_flags(flags);
return;
};
}
restore_flags(flags);
dev->trans_start = jiffies;
netif_wake_queue (dev);
}
long long last_tx_q_hack;
int direction = 1;
int awc_start_xmit(struct sk_buff *skb, struct net_device *dev) {
struct awc_private *priv = (struct awc_private *)dev->priv;
int retval = 0;
// unsigned long flags;
DEBUG(2, "%s: awc_start_xmit \n", dev->name);
if (!dev) {
DEBUG(1, " xmit dev=NULL, jiffie %ld \n",jiffies);
return -1;
};
if (!skb) {
DEBUG(1, " xmit skb=NULL, jiffie %ld \n",jiffies);
return -1;
};
// if (test_and_set_bit( 0, (void *) &priv->tx_chain_active) ) {
// netif_start_queue (dev);
// return 1;
// }
dev->trans_start = jiffies;
retval = awc_802_11_tx_find_path_and_post(dev,skb);
priv->tx_chain_active = 0;
// wake_up_interruptible(&priv->tx_chain_wait_queue);
// if (!dev->tbusy) dev_tint(dev);
return retval;
}
void awc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
struct net_device *dev = dev_id;
struct awc_private *priv;
unsigned long flags;
// if ((dev == NULL)) return;
priv = (struct awc_private *)dev->priv;
DEBUG(2, "%s: awc_interrupt \n", dev->name);
spin_lock_irqsave(&priv->interrupt_spinlock, flags);
awc_interrupt_process(dev);
spin_unlock_irqrestore(&priv->interrupt_spinlock, flags);
}
/************************ STATS, MULTICAST & STUFF ****************/
struct net_device_stats *awc_get_stats(struct net_device *dev)
{
struct awc_private *priv = (struct awc_private *)dev->priv;
// unsigned long flags;
// int cnt = 0;
// int unlocked_stats_in_interrupt=0;
DEBUG(2, "%s: awc_get_stats \n", dev->name);
if (!netif_running(dev)) {
return 0;
}
// save_flags(flags);
// cli();
if (awc_full_stats)
awc_readrid_dir(dev, &priv->rid_dir[9]);
// restore_flags(flags);
// the very following is the very wrong very probably
if (awc_full_stats){
priv->stats.rx_bytes = priv->statistics.HostRxBytes;
priv->stats.tx_bytes = priv->statistics.HostTxBytes;
priv->stats.rx_fifo_errors = priv->statistics.RxOverrunErr ;
priv->stats.rx_crc_errors = priv->statistics.RxPlcpCrcErr + priv->statistics.RxMacCrcErr ;
priv->stats.rx_frame_errors = priv->statistics.RxPlcpFormat ;
priv->stats.rx_length_errors = priv->statistics.RxPlcpLength ;
priv->stats.rx_missed_errors = priv->statistics.RxAged ;
priv->stats.rx_over_errors = priv->statistics.RxOverrunErr ;
priv->stats.collisions = priv->statistics.TxSinColl;
priv->stats.tx_aborted_errors = priv->statistics.TxAged ;
priv->stats.tx_fifo_errors = priv->statistics.HostTxFail ;
priv->stats.tx_window_errors = priv->statistics.TxMulColl ;
priv->stats.tx_heartbeat_errors = priv->statistics.DefersProt +priv->statistics.DefersEngy ;
priv->stats.tx_carrier_errors = priv->statistics.RetryLong +priv->statistics.RetryShort ;
priv->stats.multicast = priv->statistics.HostRxMc;
}
// printk("rx_packets %d\n",priv->stats.rx_packets);
return &(priv->stats);
}
int awc_change_mtu(struct net_device *dev, int new_mtu){
// struct awc_private *priv = (struct awc_private *)dev->priv;
unsigned long flags;
if ((new_mtu < 256 ) || (new_mtu > 2312) || (max_mtu && new_mtu > max_mtu) )
return -EINVAL;
if (netif_running(dev)) {
printk("PLEASE, ifconfig %s down for mtu change\n",dev->name);
};
if (dev->mtu != new_mtu) {
save_flags(flags);
cli();
netif_stop_queue(dev);
awc_disable_MAC(dev);
restore_flags(flags);
awc_tx_dealloc(dev);
dev->mtu = new_mtu;
awc_tx_alloc(dev);
awc_enable_MAC(dev);
netif_start_queue(dev);
printk("%s mtu has been changed to %d \n ",dev->name,dev->mtu);
}
return 0;
};
void
awc_set_multicast_list(struct net_device *dev) {
// int ioaddr = dev->base_addr;
/* if (dev->flags & IFF_PROMISC)
promisc
else if (dev->mc_count || (dev->flags & IFF_ALLMULTI))
allmulti
else
normal
*/
}
int (* awc_proc_set_fun) (int);
int (* awc_proc_unset_fun) (int);
int awc_register_proc(int (*awc_proc_set_device)(int),int (*awc_proc_unset_device)(int)){
AWC_ENTRY_EXIT_DEBUG("awc_register_proc");
awc_proc_set_fun = awc_proc_set_device;
awc_proc_unset_fun = awc_proc_unset_device;
AWC_ENTRY_EXIT_DEBUG("exit");
return 0;
};
int awc_unregister_proc(void){
AWC_ENTRY_EXIT_DEBUG("awc_unregister_proc");
awc_proc_set_fun = NULL;
awc_proc_unset_fun = NULL;
AWC_ENTRY_EXIT_DEBUG("exit");
return 0;
};
static int aironet_core_init(void)
{
// unsigned long flags;
printk(KERN_INFO"%s", aironet4500_core_version);
return 0;
}
static void aironet_core_exit(void)
{
printk(KERN_INFO "aironet4500 unloading core module \n");
}
module_init(aironet_core_init);
module_exit(aironet_core_exit);
/*
* Aironet 4500 /proc interface
*
* Elmer Joandi, Januar 1999
* Copyright GPL
*
*
* Revision 0.1 ,started 30.12.1998
*
*
*/
#include <linux/config.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/module.h>
#include <linux/if_arp.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/interrupt.h>
#include <linux/in.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/bitops.h>
#ifdef CONFIG_PROC_FS
#include <linux/sysctl.h>
#include <linux/fs.h>
#include "aironet4500.h"
#include "aironet4500_rid.c"
#define AWC_STR_SIZE 0x2ff0
#define DEV_AWC_INFO 1
#define DEV_AWC 1
static spinlock_t driver_lock = SPIN_LOCK_UNLOCKED;
struct awc_proc_private{
struct ctl_table_header * sysctl_header;
struct ctl_table * proc_table;
struct ctl_table proc_table_device_root[2];
struct ctl_table proc_table_sys_root[2];
char proc_name[10];
};
static char awc_drive_info[AWC_STR_SIZE]="Zcom \n\0";
static char awc_proc_buff[AWC_STR_SIZE];
static int awc_int_buff;
static struct awc_proc_private awc_proc_priv[MAX_AWCS];
extern int awc_proc_unset_device(int device_number);
int awc_proc_format_array(int write,char * buff, size_t * len, struct awc_rid_dir * rid_dir, struct aironet4500_RID * rid){
u8 * data = rid_dir->buff + rid->offset;
int pos = 0;
int null_past = 0;
int hex = ((rid->mask == 0xff) && (rid->value == 0x0 ));
int string = ((rid->mask == 0) && (rid->value == 0 ));
u32 val =0;
int bytes = (rid->bits / 8);
int ch =0;
int i,k;
int array_len = rid->array;
int nullX = 0;
AWC_ENTRY_EXIT_DEBUG("awc_proc_format_array");
if (rid->bits %8 ) bytes +=1;
if (bytes > 4 && rid->array == 1){
array_len = bytes;
bytes = 1;
hex = 1;
};
if (bytes < 1 || bytes > 4){
printk(KERN_ERR " weird number of bytes %d in aironet rid \n",bytes);
return -1;
};
DEBUG(0x20000,"awc proc array bytes %d",bytes);
DEBUG(0x20000," hex %d",hex);
DEBUG(0x20000," string %d",string);
DEBUG(0x20000," array_len %d \n",array_len);
DEBUG(0x20000," offset %d \n",rid->offset);
if (!write){
for (i=0; i < array_len ; i++){
if (bytes <= 1 ) val = data[i*bytes];
else if (bytes <= 2 ) val = *((u16 *)&data[i*bytes]);
else if (bytes <= 4 ) val = *((u32 *)&data[i*bytes]);
if (rid->null_terminated && !val)
null_past =1;
if (hex && !string)
for (k=0; k <bytes; k++)
pos += sprintf(buff+pos, "%02x",(unsigned char ) data[i*bytes +k]);
else if (string)
pos += sprintf(buff+pos, "%c",val);
else pos += sprintf(buff+pos, "%c",val);
DEBUG(0x20000, "awcproc %x %x \n",data[i], val);
};
} else {
for (i=0; i < array_len ; i++){
DEBUG(0x20000, "awcproc %x %x \n",data[i], buff[i]);
if (hex && ! string){
val = 0;
for (k=0; k < bytes; k++){
val <<= 8;
ch = *(buff + 2*i*bytes +k + nullX);
if (ch >= '0' && ch <='9')
ch -= '0';
if (ch >= 'A' && ch <='F')
ch -= 'A'+ 0xA;
if (ch >= 'a' && ch <='f')
ch -= 'a'+ 0xA;
val += ch <<4;
k++;
ch = *(buff + 2*i*bytes +k + nullX);
if (val == 0 && (ch == 'X' || ch == 'x')){
nullX=2;
val = 0;
k = -1;
continue;
};
if (ch >= '0' && ch <='9')
ch -= '0';
if (ch >= 'A' && ch <='F')
ch -= 'A'+ 0xA;
if (ch >= 'a' && ch <='f')
ch -= 'a'+ 0xA;
val += ch;
if (i*bytes > *len )
val = 0;
}
if (rid->bits <=8 ) data[i*bytes] = val;
else if (rid->bits <=16 ) *((u16 *)&data[i*bytes]) = val;
else if (rid->bits <=32 ) *((u32 *)&data[i*bytes]) = val;
if (!val) null_past=1;
} else {
for (k=0; k < bytes; k++){
data[i*bytes +k] = *(buff + i*bytes +k);
if (i*bytes +k > *len || !data[i*bytes +k])
null_past = 1;;
}
}
if (null_past){
if (rid->bits <=8 ) data[i*bytes] = 0;
else if (rid->bits <=16 ) *((u16 *)&data[i*bytes]) = 0;
else if (rid->bits <=32 ) *((u32 *)&data[i*bytes]) = 0;
}
}
};
// *len = pos;
AWC_ENTRY_EXIT_DEBUG("awc_proc_format_array");
return 0;
};
int awc_proc_format_bits(int write,u32 * buff, size_t* lenp, struct awc_rid_dir * rid_dir, struct aironet4500_RID * rid){
u8 * data = rid_dir->buff + rid->offset;
u32 val = 0;
int not_bool = 0;
AWC_ENTRY_EXIT_DEBUG("awc_proc_format_bits");
if ((rid->bits == 8 && rid->mask == 0xff) ||
(rid->bits == 16 && rid->mask == 0xffff) ||
(rid->bits == 32 && rid->mask == 0xffffffff) )
not_bool = 1;
if (rid->bits <=8 ) val = *data;
else if (rid->bits <=16 ) val = *((u16 *)data);
else if (rid->bits <=32 ) val = *((u32 *)data);
DEBUG(0x20000,"awc proc int enter data %x \n",val);
DEBUG(0x20000,"awc proc int enter buff %x \n",*buff);
DEBUG(0x20000,"awc proc int enter intbuff %x \n",awc_int_buff);
DEBUG(0x20000,"awc proc int enter lenp %x \n",*lenp);
if (!write){
if (rid->mask)
val &= rid->mask;
if (!not_bool && rid->mask &&
((val & rid->mask) == (rid->value & rid->mask)))
*buff = 1;
else if (!not_bool) *buff = 0;
else *buff = val;
} else {
if (not_bool){
val &= ~rid->mask;
val |= (*buff & rid->mask);
} else {
if (*buff){
val &= ~rid->mask;
if (rid->value)
val |= rid->mask & rid->value;
else val |= rid->mask & ~rid->value;
} else val &= ~rid->mask;
};
if (rid->bits == 8) *data = val & 0xff;
if (rid->bits == 16) *((u16*)data) = val &0xffff;
if (rid->bits == 32) *((u32*)data) = val &0xffffffff;
}
DEBUG(0x20000,"awc proc int buff %x \n",awc_int_buff);
if (rid->bits <=8 ) val = *data;
else if (rid->bits <=16 ) val = *((u16 *)data);
else if (rid->bits <=32 ) val = *((u32 *)data);
DEBUG(0x20000,"awc proc int data %x \n",val);
// both of them are crazy
// *lenp = sizeof(int);
// *lenp += 1;
AWC_ENTRY_EXIT_DEBUG("exit");
return 0;
};
int awc_proc_fun(ctl_table *ctl, int write, struct file * filp,
void *buffer, size_t *lenp)
{
int retv =-1;
struct awc_private *priv = NULL;
unsigned long flags;
// int device_number = (int ) ctl->extra1;
struct awc_rid_dir * rid_dir;
struct net_device * dev= NULL;
struct aironet4500_RID * rid = (struct aironet4500_RID * ) ctl->extra2;
AWC_ENTRY_EXIT_DEBUG("awc_proc_fun");
if (!write && filp)
if (filp->f_pos){
// printk(KERN_CRIT "Oversize read\n");
*lenp = 0;// hack against reading til eof
return 0;
}
MOD_INC_USE_COUNT;
rid_dir = ((struct awc_rid_dir *)ctl->extra1);
dev = rid_dir->dev;
if (!dev){
printk(KERN_ERR " NO device here \n");
goto final;
}
if(ctl->procname == NULL || awc_drive_info == NULL ){
printk(KERN_WARNING " procname is NULL in sysctl_table or awc_mib_info is NULL \n at awc module\n ");
MOD_DEC_USE_COUNT;
return -1;
}
priv = (struct awc_private * ) dev->priv;
if ((rid->selector->read_only || rid->read_only) && write){
printk(KERN_ERR "This value is read-only \n");
goto final;
};
if (!write && rid->selector->may_change) {
spin_lock_irqsave(&driver_lock, flags);
awc_readrid(dev,rid,rid_dir->buff + rid->offset);
spin_unlock_irqrestore(&driver_lock, flags);
};
if (rid->array > 1 || rid->bits > 32){
if (write){
retv = proc_dostring(ctl, write, filp, buffer, lenp);
if (retv) goto final;
retv = awc_proc_format_array(write, awc_proc_buff, lenp, rid_dir, rid);
if (retv) goto final;
} else {
retv = awc_proc_format_array(write, awc_proc_buff, lenp, rid_dir, rid);
if (retv) goto final;
retv = proc_dostring(ctl, write, filp, buffer, lenp);
if (retv) goto final;
}
} else {
if (write){
retv = proc_dointvec(ctl, write, filp, buffer, lenp);
if (retv) goto final;
retv = awc_proc_format_bits(write, &awc_int_buff, lenp, rid_dir, rid);
if (retv) goto final;
} else {
retv = awc_proc_format_bits(write, &awc_int_buff, lenp,rid_dir, rid);
if (retv) goto final;
retv = proc_dointvec(ctl, write, filp, buffer, lenp);
if (retv) goto final;
}
}
if (write) {
spin_lock_irqsave(&driver_lock, flags);
if (rid->selector->MAC_Disable_at_write){
awc_disable_MAC(dev);
};
awc_writerid(dev,rid,rid_dir->buff + rid->offset);
if (rid->selector->MAC_Disable_at_write){
awc_enable_MAC(dev);
};
spin_lock_irqsave(&driver_lock, flags);
};
DEBUG(0x20000,"awc proc ret %x \n",retv);
DEBUG(0x20000,"awc proc lenp %x \n",*lenp);
MOD_DEC_USE_COUNT;
return retv;
final:
AWC_ENTRY_EXIT_DEBUG("exit");
MOD_DEC_USE_COUNT;
return -1 ;
}
char conf_reset_result[200];
ctl_table awc_exdev_table[] = {
{
.ctl_name = 0,
.maxlen = 0,
.mode = 0400,
},
{ .ctl_name = 0 }
};
ctl_table awc_exroot_table[] = {
{
.ctl_name = 254,
.procname = "aironet4500",
.maxlen = 0,
.mode = 0555,
},
{ .ctl_name = 0 }
};
ctl_table awc_driver_proc_table[] = {
{
.ctl_name = 1,
.procname = "debug",
.data = &awc_debug,
.maxlen = sizeof(awc_debug),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 2,
.procname = "bap_sleep",
.data = &bap_sleep,
.maxlen = sizeof(bap_sleep),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 3,
.procname = "bap_sleep_after_setup",
.data = &bap_sleep_after_setup,
.maxlen = sizeof(bap_sleep_after_setup),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 4,
.procname = "sleep_before_command",
.data = &sleep_before_command,
.maxlen = sizeof(sleep_before_command),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 5,
.procname = "bap_sleep_before_write",
.data = &bap_sleep_before_write,
.maxlen = sizeof(bap_sleep_before_write),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 6,
.procname = "sleep_in_command",
.data = &sleep_in_command,
.maxlen = sizeof(sleep_in_command),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 7,
.procname = "both_bap_lock",
.data = &both_bap_lock,
.maxlen = sizeof(both_bap_lock),
.mode = 0600,
.proc_handler = proc_dointvec
},
{
.ctl_name = 8,
.procname = "bap_setup_spinlock",
.data = &bap_setup_spinlock,
.maxlen = sizeof(bap_setup_spinlock),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{ .ctl_name = 0 }
};
ctl_table awc_driver_level_ctable[] = {
{
.ctl_name = 1,
.procname = "force_rts_on_shorter",
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 2,
.procname = "force_tx_rate",
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 3,
.procname = "ip_tos_reliability_rts",
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 4,
.procname = "ip_tos_troughput_no_retries",
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 5,
.procname = "debug",
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 6,
.procname = "simple_bridge",
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 7,
.procname = "p802_11_send",
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{
.ctl_name = 8,
.procname = "full_stats",
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = proc_dointvec,
},
{ .ctl_name = 0 }
};
ctl_table awc_root_table[] = {
{
.ctl_name = 254,
.procname = "aironet4500",
.maxlen = 0,
.mode = 0555,
.child = awc_driver_proc_table,
},
{ .ctl_name = 0 }
};
struct ctl_table_header * awc_driver_sysctl_header;
const char awc_procname[]= "awc5";
int awc_proc_set_device(int device_number){
int group =0;
int rid = 0;
struct awc_private * priv;
ctl_table * tmp_table_ptr;
AWC_ENTRY_EXIT_DEBUG("awc_proc_set_device");
if (!aironet4500_devices[device_number] || (awc_nof_rids <=0 )) return -1 ;
priv = (struct awc_private * )aironet4500_devices[device_number]->priv;
awc_rids_setup(aironet4500_devices[device_number]);
memcpy(&(awc_proc_priv[device_number].proc_table_sys_root[0]), awc_exroot_table,sizeof(struct ctl_table)*2);
awc_proc_priv[device_number].proc_table_sys_root[0].ctl_name = 254 - device_number;
memcpy(awc_proc_priv[device_number].proc_table_device_root, awc_exdev_table,sizeof(awc_exdev_table) );
awc_proc_priv[device_number].proc_table_device_root[0].ctl_name = device_number+1;
awc_proc_priv[device_number].proc_table_sys_root->child = awc_proc_priv[device_number].proc_table_device_root;
memcpy(awc_proc_priv[device_number].proc_name,(struct NET_DEVICE * )aironet4500_devices[device_number]->name,5);
awc_proc_priv[device_number].proc_name[4]=0;
// awc_proc_priv[device_number].proc_name[3]=48+device_number;
awc_proc_priv[device_number].proc_table_device_root[0].procname = &(awc_proc_priv[device_number].proc_name[0]);
awc_proc_priv[device_number].proc_table = kmalloc(sizeof(struct ctl_table) * (awc_nof_rids+2),GFP_KERNEL);
if (!awc_proc_priv[device_number].proc_table){
printk(KERN_CRIT "Out of memory on aironet4500_proc huge table alloc \n");
return -1;
}
awc_proc_priv[device_number].proc_table_device_root[0].child=awc_proc_priv[device_number].proc_table;
if (awc_debug) printk("device %d of %d proc interface setup ",device_number, awc_nof_rids);
while (awc_rids[group].selector && group < awc_nof_rids){
if (awc_debug & 0x20000)
printk(KERN_CRIT "ridgroup %s size %d \n", awc_rids[group].selector->name,awc_rids[group].size);
awc_proc_priv[device_number].proc_table[group].ctl_name = group +1;
awc_proc_priv[device_number].proc_table[group+1].ctl_name = 0;
awc_proc_priv[device_number].proc_table[group].procname = awc_rids[group].selector->name;
awc_proc_priv[device_number].proc_table[group].data = awc_proc_buff;
awc_proc_priv[device_number].proc_table[group].maxlen = sizeof(awc_proc_buff) -1;
awc_proc_priv[device_number].proc_table[group].mode = 0600;
awc_proc_priv[device_number].proc_table[group].child = kmalloc(sizeof(struct ctl_table) * (awc_rids[group].size +2), GFP_KERNEL);
awc_proc_priv[device_number].proc_table[group].proc_handler = NULL;
awc_proc_priv[device_number].proc_table[group].strategy = NULL;
awc_proc_priv[device_number].proc_table[group].de = NULL;
awc_proc_priv[device_number].proc_table[group].extra1 = NULL;
awc_proc_priv[device_number].proc_table[group].extra2 = NULL;
if (!awc_proc_priv[device_number].proc_table[group].child) {
awc_proc_priv[device_number].proc_table[group].ctl_name = 0;
printk(KERN_CRIT "Out of memory on aironet4500_proc huge table alloc \n");
return 0;
}
rid=0;
while (awc_rids[group].rids[rid].selector && (rid < awc_rids[group].size -1)){
// DEBUG(0x20000,"rid %s \n", awc_rids[group].rids[rid].name);
awc_proc_priv[device_number].proc_table[group].child[rid].ctl_name = rid +1;
awc_proc_priv[device_number].proc_table[group].child[rid+1].ctl_name = 0;
awc_proc_priv[device_number].proc_table[group].child[rid].procname = awc_rids[group].rids[rid].name;
if (awc_rids[group].rids[rid].array > 1 ||
awc_rids[group].rids[rid].bits > 32 ){
awc_proc_priv[device_number].proc_table[group].child[rid].data = awc_proc_buff;
awc_proc_priv[device_number].proc_table[group].child[rid].maxlen = sizeof(awc_proc_buff) -1;
} else {
awc_proc_priv[device_number].proc_table[group].child[rid].data = &awc_int_buff;
awc_proc_priv[device_number].proc_table[group].child[rid].maxlen = sizeof(awc_int_buff);
}
if ( awc_rids[group].rids[rid].read_only ||
awc_rids[group].rids[rid].selector->read_only )
awc_proc_priv[device_number].proc_table[group].child[rid].mode = 0400;
else
awc_proc_priv[device_number].proc_table[group].child[rid].mode = 0600;
awc_proc_priv[device_number].proc_table[group].child[rid].child = NULL;
awc_proc_priv[device_number].proc_table[group].child[rid].proc_handler = awc_proc_fun;
awc_proc_priv[device_number].proc_table[group].child[rid].strategy = NULL;
awc_proc_priv[device_number].proc_table[group].child[rid].de = NULL;
awc_proc_priv[device_number].proc_table[group].child[rid].extra1 = (void *) &(((struct awc_private* )aironet4500_devices[device_number]->priv)->rid_dir[group]);
awc_proc_priv[device_number].proc_table[group].child[rid].extra2 = (void *) &(awc_rids[group].rids[rid]);
rid++;
}
group++;
};
// here are driver-level params dir
awc_proc_priv[device_number].proc_table[group].ctl_name = group +1;
awc_proc_priv[device_number].proc_table[group+1].ctl_name = 0;
awc_proc_priv[device_number].proc_table[group].procname = "driver-level";
awc_proc_priv[device_number].proc_table[group].data = awc_proc_buff;
awc_proc_priv[device_number].proc_table[group].maxlen = sizeof(awc_proc_buff) -1;
awc_proc_priv[device_number].proc_table[group].mode = 0600;
awc_proc_priv[device_number].proc_table[group].child = kmalloc(sizeof(awc_driver_level_ctable) , GFP_KERNEL);
awc_proc_priv[device_number].proc_table[group].proc_handler = NULL;
awc_proc_priv[device_number].proc_table[group].strategy = NULL;
awc_proc_priv[device_number].proc_table[group].de = NULL;
awc_proc_priv[device_number].proc_table[group].extra1 = NULL;
awc_proc_priv[device_number].proc_table[group].extra2 = NULL;
if (!awc_proc_priv[device_number].proc_table[group].child) {
awc_proc_priv[device_number].proc_table[group].ctl_name = 0;
printk(KERN_CRIT "Out of memory on aironet4500_proc huge table alloc \n");
return 0;
}
tmp_table_ptr = awc_proc_priv[device_number].proc_table[group].child;
memcpy(tmp_table_ptr,awc_driver_level_ctable,sizeof(awc_driver_level_ctable));
tmp_table_ptr[0].data =
&(priv->force_rts_on_shorter);
tmp_table_ptr[1].data = &priv->force_tx_rate;
tmp_table_ptr[2].data = (void *) &priv->ip_tos_reliability_rts;
tmp_table_ptr[3].data = (void *) &priv->ip_tos_troughput_no_retries;
tmp_table_ptr[4].data = (void *) &priv->debug;
tmp_table_ptr[5].data = (void *) &priv->simple_bridge;
tmp_table_ptr[6].data = (void *) &priv->p802_11_send;
tmp_table_ptr[7].data = (void *) &priv->full_stats;
awc_proc_priv[device_number].sysctl_header =
register_sysctl_table(awc_proc_priv[device_number].proc_table_sys_root,0);
AWC_ENTRY_EXIT_DEBUG("exit");
if (awc_proc_priv[device_number].sysctl_header)
return 0;
return 1;
};
int awc_proc_unset_device(int device_number){
int k;
AWC_ENTRY_EXIT_DEBUG("awc_proc_unset_device");
if (awc_proc_priv[device_number].sysctl_header){
unregister_sysctl_table(awc_proc_priv[device_number].sysctl_header);
awc_proc_priv[device_number].sysctl_header = NULL;
}
if (awc_proc_priv[device_number].proc_table){
for (k=0; awc_proc_priv[device_number].proc_table[k].ctl_name ; k++ ){
if (awc_proc_priv[device_number].proc_table[k].child)
kfree(awc_proc_priv[device_number].proc_table[k].child);
}
kfree(awc_proc_priv[device_number].proc_table);
awc_proc_priv[device_number].proc_table = NULL;
}
if (awc_proc_priv[device_number].proc_table_device_root[0].ctl_name)
awc_proc_priv[device_number].proc_table_device_root[0].ctl_name = 0;
if (awc_proc_priv[device_number].proc_table_sys_root[0].ctl_name)
awc_proc_priv[device_number].proc_table_sys_root[0].ctl_name = 0;
AWC_ENTRY_EXIT_DEBUG("exit");
return 0;
};
static int aironet_proc_init(void) {
int i=0;
AWC_ENTRY_EXIT_DEBUG("init_module");
for (i=0; i < MAX_AWCS; i++){
awc_proc_set_device(i);
}
awc_register_proc(awc_proc_set_device, awc_proc_unset_device);
awc_driver_sysctl_header = register_sysctl_table(awc_root_table,0);
AWC_ENTRY_EXIT_DEBUG("exit");
return 0;
};
static void aironet_proc_exit(void){
int i=0;
AWC_ENTRY_EXIT_DEBUG("cleanup_module");
awc_unregister_proc();
for (i=0; i < MAX_AWCS; i++){
awc_proc_unset_device(i);
}
if (awc_driver_sysctl_header)
unregister_sysctl_table(awc_driver_sysctl_header);
AWC_ENTRY_EXIT_DEBUG("exit");
};
module_init(aironet_proc_init);
module_exit(aironet_proc_exit);
#else
#error awc driver needs CONFIG_PROC_FS
#endif // whole proc system styff
MODULE_LICENSE("GPL");
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -14,10 +14,6 @@ extern int x25_asy_init_ctrl_dev(void);
extern int dmascc_init(void);
extern int awc4500_pci_probe(void);
extern int awc4500_isa_probe(void);
extern int awc4500_pnp_probe(void);
extern int awc4500_365_probe(void);
extern int arcnet_init(void);
extern int scc_enet_init(void);
extern int fec_enet_init(void);
......@@ -79,23 +75,6 @@ static struct net_probe pci_probes[] __initdata = {
{lmc_setup, 0},
#endif
/*
*
* Wireless non-HAM
*
*/
#ifdef CONFIG_AIRONET4500_NONCS
#ifdef CONFIG_AIRONET4500_PCI
{awc4500_pci_probe,0},
#endif
#ifdef CONFIG_AIRONET4500_PNP
{awc4500_pnp_probe,0},
#endif
#endif
/*
* Token Ring Drivers
*/
......
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