2005-04-16 18:20:36 -04:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Filename: netwave_cs.c
|
|
|
|
* Version: 0.4.1
|
|
|
|
* Description: Netwave AirSurfer Wireless LAN PC Card driver
|
|
|
|
* Status: Experimental.
|
2007-10-19 17:21:04 -04:00
|
|
|
* Authors: John Markus Bjørndalen <johnm@cs.uit.no>
|
2005-04-16 18:20:36 -04:00
|
|
|
* Dag Brattli <dagb@cs.uit.no>
|
|
|
|
* David Hinds <dahinds@users.sourceforge.net>
|
|
|
|
* Created at: A long time ago!
|
|
|
|
* Modified at: Mon Nov 10 11:54:37 1997
|
|
|
|
* Modified by: Dag Brattli <dagb@cs.uit.no>
|
|
|
|
*
|
2007-10-19 17:21:04 -04:00
|
|
|
* Copyright (c) 1997 University of Tromsø, Norway
|
2005-04-16 18:20:36 -04:00
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
*
|
2007-10-19 17:21:04 -04:00
|
|
|
* 08-Nov-97 15:14:47 John Markus Bjørndalen <johnm@cs.uit.no>
|
2005-04-16 18:20:36 -04:00
|
|
|
* - Fixed some bugs in netwave_rx and cleaned it up a bit.
|
|
|
|
* (One of the bugs would have destroyed packets when receiving
|
|
|
|
* multiple packets per interrupt).
|
|
|
|
* - Cleaned up parts of newave_hw_xmit.
|
|
|
|
* - A few general cleanups.
|
|
|
|
* 24-Oct-97 13:17:36 Dag Brattli <dagb@cs.uit.no>
|
|
|
|
* - Fixed netwave_rx receive function (got updated docs)
|
|
|
|
* Others:
|
|
|
|
* - Changed name from xircnw to netwave, take a look at
|
|
|
|
* http://www.netwave-wireless.com
|
|
|
|
* - Some reorganizing of the code
|
|
|
|
* - Removed possible race condition between interrupt handler and transmit
|
|
|
|
* function
|
|
|
|
* - Started to add wireless extensions, but still needs some coding
|
|
|
|
* - Added watchdog for better handling of transmission timeouts
|
|
|
|
* (hopefully this works better)
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
/* To have statistics (just packets sent) define this */
|
|
|
|
#undef NETWAVE_STATS
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/wireless.h>
|
|
|
|
#include <net/iw_handler.h>
|
|
|
|
|
|
|
|
#include <pcmcia/cs_types.h>
|
|
|
|
#include <pcmcia/cs.h>
|
|
|
|
#include <pcmcia/cistpl.h>
|
|
|
|
#include <pcmcia/cisreg.h>
|
|
|
|
#include <pcmcia/ds.h>
|
|
|
|
#include <pcmcia/mem_op.h>
|
|
|
|
|
|
|
|
#include <asm/system.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/dma.h>
|
|
|
|
|
|
|
|
#define NETWAVE_REGOFF 0x8000
|
|
|
|
/* The Netwave IO registers, offsets to iobase */
|
|
|
|
#define NETWAVE_REG_COR 0x0
|
|
|
|
#define NETWAVE_REG_CCSR 0x2
|
|
|
|
#define NETWAVE_REG_ASR 0x4
|
|
|
|
#define NETWAVE_REG_IMR 0xa
|
|
|
|
#define NETWAVE_REG_PMR 0xc
|
|
|
|
#define NETWAVE_REG_IOLOW 0x6
|
|
|
|
#define NETWAVE_REG_IOHI 0x7
|
|
|
|
#define NETWAVE_REG_IOCONTROL 0x8
|
|
|
|
#define NETWAVE_REG_DATA 0xf
|
|
|
|
/* The Netwave Extended IO registers, offsets to RamBase */
|
|
|
|
#define NETWAVE_EREG_ASCC 0x114
|
|
|
|
#define NETWAVE_EREG_RSER 0x120
|
|
|
|
#define NETWAVE_EREG_RSERW 0x124
|
|
|
|
#define NETWAVE_EREG_TSER 0x130
|
|
|
|
#define NETWAVE_EREG_TSERW 0x134
|
|
|
|
#define NETWAVE_EREG_CB 0x100
|
|
|
|
#define NETWAVE_EREG_SPCQ 0x154
|
|
|
|
#define NETWAVE_EREG_SPU 0x155
|
|
|
|
#define NETWAVE_EREG_LIF 0x14e
|
|
|
|
#define NETWAVE_EREG_ISPLQ 0x156
|
|
|
|
#define NETWAVE_EREG_HHC 0x158
|
|
|
|
#define NETWAVE_EREG_NI 0x16e
|
|
|
|
#define NETWAVE_EREG_MHS 0x16b
|
|
|
|
#define NETWAVE_EREG_TDP 0x140
|
|
|
|
#define NETWAVE_EREG_RDP 0x150
|
|
|
|
#define NETWAVE_EREG_PA 0x160
|
|
|
|
#define NETWAVE_EREG_EC 0x180
|
|
|
|
#define NETWAVE_EREG_CRBP 0x17a
|
|
|
|
#define NETWAVE_EREG_ARW 0x166
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Commands used in the extended command buffer
|
|
|
|
* NETWAVE_EREG_CB (0x100-0x10F)
|
|
|
|
*/
|
|
|
|
#define NETWAVE_CMD_NOP 0x00
|
|
|
|
#define NETWAVE_CMD_SRC 0x01
|
|
|
|
#define NETWAVE_CMD_STC 0x02
|
|
|
|
#define NETWAVE_CMD_AMA 0x03
|
|
|
|
#define NETWAVE_CMD_DMA 0x04
|
|
|
|
#define NETWAVE_CMD_SAMA 0x05
|
|
|
|
#define NETWAVE_CMD_ER 0x06
|
|
|
|
#define NETWAVE_CMD_DR 0x07
|
|
|
|
#define NETWAVE_CMD_TL 0x08
|
|
|
|
#define NETWAVE_CMD_SRP 0x09
|
|
|
|
#define NETWAVE_CMD_SSK 0x0a
|
|
|
|
#define NETWAVE_CMD_SMD 0x0b
|
|
|
|
#define NETWAVE_CMD_SAPD 0x0c
|
|
|
|
#define NETWAVE_CMD_SSS 0x11
|
|
|
|
/* End of Command marker */
|
|
|
|
#define NETWAVE_CMD_EOC 0x00
|
|
|
|
|
|
|
|
/* ASR register bits */
|
|
|
|
#define NETWAVE_ASR_RXRDY 0x80
|
|
|
|
#define NETWAVE_ASR_TXBA 0x01
|
|
|
|
|
|
|
|
#define TX_TIMEOUT ((32*HZ)/100)
|
|
|
|
|
|
|
|
static const unsigned int imrConfRFU1 = 0x10; /* RFU interrupt mask, keep high */
|
|
|
|
static const unsigned int imrConfIENA = 0x02; /* Interrupt enable */
|
|
|
|
|
|
|
|
static const unsigned int corConfIENA = 0x01; /* Interrupt enable */
|
|
|
|
static const unsigned int corConfLVLREQ = 0x40; /* Keep high */
|
|
|
|
|
|
|
|
static const unsigned int rxConfRxEna = 0x80; /* Receive Enable */
|
|
|
|
static const unsigned int rxConfMAC = 0x20; /* MAC host receive mode*/
|
|
|
|
static const unsigned int rxConfPro = 0x10; /* Promiscuous */
|
|
|
|
static const unsigned int rxConfAMP = 0x08; /* Accept Multicast Packets */
|
|
|
|
static const unsigned int rxConfBcast = 0x04; /* Accept Broadcast Packets */
|
|
|
|
|
|
|
|
static const unsigned int txConfTxEna = 0x80; /* Transmit Enable */
|
|
|
|
static const unsigned int txConfMAC = 0x20; /* Host sends MAC mode */
|
|
|
|
static const unsigned int txConfEUD = 0x10; /* Enable Uni-Data packets */
|
|
|
|
static const unsigned int txConfKey = 0x02; /* Scramble data packets */
|
|
|
|
static const unsigned int txConfLoop = 0x01; /* Loopback mode */
|
|
|
|
|
|
|
|
/*
|
|
|
|
All the PCMCIA modules use PCMCIA_DEBUG to control debugging. If
|
|
|
|
you do not define PCMCIA_DEBUG at all, all the debug code will be
|
|
|
|
left out. If you compile with PCMCIA_DEBUG=0, the debug code will
|
|
|
|
be present but disabled -- but it can then be enabled for specific
|
|
|
|
modules at load time with a 'pc_debug=#' option to insmod.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef PCMCIA_DEBUG
|
|
|
|
static int pc_debug = PCMCIA_DEBUG;
|
|
|
|
module_param(pc_debug, int, 0);
|
|
|
|
#define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args)
|
|
|
|
static char *version =
|
2007-10-19 17:21:04 -04:00
|
|
|
"netwave_cs.c 0.3.0 Thu Jul 17 14:36:02 1997 (John Markus Bjørndalen)\n";
|
2005-04-16 18:20:36 -04:00
|
|
|
#else
|
|
|
|
#define DEBUG(n, args...)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
/* Parameters that can be set with 'insmod' */
|
|
|
|
|
|
|
|
/* Choose the domain, default is 0x100 */
|
|
|
|
static u_int domain = 0x100;
|
|
|
|
|
|
|
|
/* Scramble key, range from 0x0 to 0xffff.
|
|
|
|
* 0x0 is no scrambling.
|
|
|
|
*/
|
|
|
|
static u_int scramble_key = 0x0;
|
|
|
|
|
|
|
|
/* Shared memory speed, in ns. The documentation states that
|
|
|
|
* the card should not be read faster than every 400ns.
|
|
|
|
* This timing should be provided by the HBA. If it becomes a
|
|
|
|
* problem, try setting mem_speed to 400.
|
|
|
|
*/
|
|
|
|
static int mem_speed;
|
|
|
|
|
|
|
|
module_param(domain, int, 0);
|
|
|
|
module_param(scramble_key, int, 0);
|
|
|
|
module_param(mem_speed, int, 0);
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
|
|
|
/* PCMCIA (Card Services) related functions */
|
2006-03-31 10:21:06 -05:00
|
|
|
static void netwave_release(struct pcmcia_device *link); /* Card removal */
|
2006-03-31 10:26:06 -05:00
|
|
|
static int netwave_pcmcia_config(struct pcmcia_device *arg); /* Runs after card
|
2005-04-16 18:20:36 -04:00
|
|
|
insertion */
|
2005-11-14 15:23:14 -05:00
|
|
|
static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* Hardware configuration */
|
|
|
|
static void netwave_doreset(kio_addr_t iobase, u_char __iomem *ramBase);
|
|
|
|
static void netwave_reset(struct net_device *dev);
|
|
|
|
|
|
|
|
/* Misc device stuff */
|
|
|
|
static int netwave_open(struct net_device *dev); /* Open the device */
|
|
|
|
static int netwave_close(struct net_device *dev); /* Close the device */
|
|
|
|
|
|
|
|
/* Packet transmission and Packet reception */
|
|
|
|
static int netwave_start_xmit( struct sk_buff *skb, struct net_device *dev);
|
|
|
|
static int netwave_rx( struct net_device *dev);
|
|
|
|
|
|
|
|
/* Interrupt routines */
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 09:55:46 -04:00
|
|
|
static irqreturn_t netwave_interrupt(int irq, void *dev_id);
|
2005-04-16 18:20:36 -04:00
|
|
|
static void netwave_watchdog(struct net_device *);
|
|
|
|
|
|
|
|
/* Statistics */
|
|
|
|
static void update_stats(struct net_device *dev);
|
|
|
|
static struct net_device_stats *netwave_get_stats(struct net_device *dev);
|
|
|
|
|
|
|
|
/* Wireless extensions */
|
|
|
|
static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev);
|
|
|
|
|
|
|
|
static void set_multicast_list(struct net_device *dev);
|
|
|
|
|
|
|
|
/*
|
2006-03-31 10:21:06 -05:00
|
|
|
A struct pcmcia_device structure has fields for most things that are needed
|
2005-04-16 18:20:36 -04:00
|
|
|
to keep track of a socket, but there will usually be some device
|
|
|
|
specific information that also needs to be kept track of. The
|
2006-03-31 10:21:06 -05:00
|
|
|
'priv' pointer in a struct pcmcia_device structure can be used to point to
|
2005-04-16 18:20:36 -04:00
|
|
|
a device-specific private data structure, like this.
|
|
|
|
|
|
|
|
A driver needs to provide a dev_node_t structure for each device
|
|
|
|
on a card. In some cases, there is only one device per card (for
|
|
|
|
example, ethernet cards, modems). In other cases, there may be
|
|
|
|
many actual or logical devices (SCSI adapters, memory cards with
|
|
|
|
multiple partitions). The dev_node_t structures need to be kept
|
2006-03-31 10:21:06 -05:00
|
|
|
in a linked list starting at the 'dev' field of a struct pcmcia_device
|
2005-04-16 18:20:36 -04:00
|
|
|
structure. We allocate them in the card's private data structure,
|
|
|
|
because they generally can't be allocated dynamically.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const struct iw_handler_def netwave_handler_def;
|
|
|
|
|
|
|
|
#define SIOCGIPSNAP SIOCIWFIRSTPRIV + 1 /* Site Survey Snapshot */
|
|
|
|
|
|
|
|
#define MAX_ESA 10
|
|
|
|
|
|
|
|
typedef struct net_addr {
|
|
|
|
u_char addr48[6];
|
|
|
|
} net_addr;
|
|
|
|
|
|
|
|
struct site_survey {
|
|
|
|
u_short length;
|
|
|
|
u_char struct_revision;
|
|
|
|
u_char roaming_state;
|
|
|
|
|
|
|
|
u_char sp_existsFlag;
|
|
|
|
u_char sp_link_quality;
|
|
|
|
u_char sp_max_link_quality;
|
|
|
|
u_char linkQualityGoodFairBoundary;
|
|
|
|
u_char linkQualityFairPoorBoundary;
|
|
|
|
u_char sp_utilization;
|
|
|
|
u_char sp_goodness;
|
|
|
|
u_char sp_hotheadcount;
|
|
|
|
u_char roaming_condition;
|
|
|
|
|
|
|
|
net_addr sp;
|
|
|
|
u_char numAPs;
|
|
|
|
net_addr nearByAccessPoints[MAX_ESA];
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct netwave_private {
|
2006-03-05 04:45:09 -05:00
|
|
|
struct pcmcia_device *p_dev;
|
2005-04-16 18:20:36 -04:00
|
|
|
spinlock_t spinlock; /* Serialize access to the hardware (SMP) */
|
|
|
|
dev_node_t node;
|
|
|
|
u_char __iomem *ramBase;
|
|
|
|
int timeoutCounter;
|
|
|
|
int lastExec;
|
|
|
|
struct timer_list watchdog; /* To avoid blocking state */
|
|
|
|
struct site_survey nss;
|
|
|
|
struct net_device_stats stats;
|
|
|
|
struct iw_statistics iw_stats; /* Wireless stats */
|
|
|
|
} netwave_private;
|
|
|
|
|
|
|
|
#ifdef NETWAVE_STATS
|
|
|
|
static struct net_device_stats *netwave_get_stats(struct net_device *dev);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The Netwave card is little-endian, so won't work for big endian
|
|
|
|
* systems.
|
|
|
|
*/
|
|
|
|
static inline unsigned short get_uint16(u_char __iomem *staddr)
|
|
|
|
{
|
|
|
|
return readw(staddr); /* Return only 16 bits */
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline short get_int16(u_char __iomem * staddr)
|
|
|
|
{
|
|
|
|
return readw(staddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait until the WOC (Write Operation Complete) bit in the
|
|
|
|
* ASR (Adapter Status Register) is asserted.
|
|
|
|
* This should have aborted if it takes too long time.
|
|
|
|
*/
|
|
|
|
static inline void wait_WOC(unsigned int iobase)
|
|
|
|
{
|
|
|
|
/* Spin lock */
|
|
|
|
while ((inb(iobase + NETWAVE_REG_ASR) & 0x8) != 0x8) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void netwave_snapshot(netwave_private *priv, u_char __iomem *ramBase,
|
|
|
|
kio_addr_t iobase) {
|
|
|
|
u_short resultBuffer;
|
|
|
|
|
|
|
|
/* if time since last snapshot is > 1 sec. (100 jiffies?) then take
|
|
|
|
* new snapshot, else return cached data. This is the recommended rate.
|
|
|
|
*/
|
|
|
|
if ( jiffies - priv->lastExec > 100) {
|
|
|
|
/* Take site survey snapshot */
|
|
|
|
/*printk( KERN_DEBUG "Taking new snapshot. %ld\n", jiffies -
|
|
|
|
priv->lastExec); */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_SSS, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
wait_WOC(iobase);
|
|
|
|
|
|
|
|
/* Get result and copy to cach */
|
|
|
|
resultBuffer = readw(ramBase + NETWAVE_EREG_CRBP);
|
|
|
|
copy_from_pc( &priv->nss, ramBase+resultBuffer,
|
|
|
|
sizeof(struct site_survey));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function netwave_get_wireless_stats (dev)
|
|
|
|
*
|
|
|
|
* Wireless extensions statistics
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
kio_addr_t iobase = dev->base_addr;
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
u_char __iomem *ramBase = priv->ramBase;
|
|
|
|
struct iw_statistics* wstats;
|
|
|
|
|
|
|
|
wstats = &priv->iw_stats;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
netwave_snapshot( priv, ramBase, iobase);
|
|
|
|
|
|
|
|
wstats->status = priv->nss.roaming_state;
|
|
|
|
wstats->qual.qual = readb( ramBase + NETWAVE_EREG_SPCQ);
|
|
|
|
wstats->qual.level = readb( ramBase + NETWAVE_EREG_ISPLQ);
|
|
|
|
wstats->qual.noise = readb( ramBase + NETWAVE_EREG_SPU) & 0x3f;
|
|
|
|
wstats->discard.nwid = 0L;
|
|
|
|
wstats->discard.code = 0L;
|
|
|
|
wstats->discard.misc = 0L;
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
return &priv->iw_stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function netwave_attach (void)
|
|
|
|
*
|
|
|
|
* Creates an "instance" of the driver, allocating local data
|
|
|
|
* structures for one device. The device is registered with Card
|
|
|
|
* Services.
|
|
|
|
*
|
|
|
|
* The dev_link structure is initialized, but we don't actually
|
|
|
|
* configure the card at this point -- we wait until we receive a
|
|
|
|
* card insertion event.
|
|
|
|
*/
|
2006-03-31 10:26:06 -05:00
|
|
|
static int netwave_probe(struct pcmcia_device *link)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
|
|
|
struct net_device *dev;
|
|
|
|
netwave_private *priv;
|
2005-11-14 15:25:51 -05:00
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
DEBUG(0, "netwave_attach()\n");
|
2005-11-14 15:25:51 -05:00
|
|
|
|
2006-03-31 10:21:06 -05:00
|
|
|
/* Initialize the struct pcmcia_device structure */
|
2005-04-16 18:20:36 -04:00
|
|
|
dev = alloc_etherdev(sizeof(netwave_private));
|
|
|
|
if (!dev)
|
2005-11-14 15:25:51 -05:00
|
|
|
return -ENOMEM;
|
2005-04-16 18:20:36 -04:00
|
|
|
priv = netdev_priv(dev);
|
2006-03-31 10:21:06 -05:00
|
|
|
priv->p_dev = link;
|
2005-04-16 18:20:36 -04:00
|
|
|
link->priv = dev;
|
|
|
|
|
|
|
|
/* The io structure describes IO port mapping */
|
|
|
|
link->io.NumPorts1 = 16;
|
|
|
|
link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
|
|
|
|
/* link->io.NumPorts2 = 16;
|
|
|
|
link->io.Attributes2 = IO_DATA_PATH_WIDTH_16; */
|
|
|
|
link->io.IOAddrLines = 5;
|
|
|
|
|
|
|
|
/* Interrupt setup */
|
|
|
|
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
|
|
|
|
link->irq.IRQInfo1 = IRQ_LEVEL_ID;
|
|
|
|
link->irq.Handler = &netwave_interrupt;
|
|
|
|
|
|
|
|
/* General socket configuration */
|
|
|
|
link->conf.Attributes = CONF_ENABLE_IRQ;
|
|
|
|
link->conf.IntType = INT_MEMORY_AND_IO;
|
|
|
|
link->conf.ConfigIndex = 1;
|
|
|
|
|
|
|
|
/* Netwave private struct init. link/dev/node already taken care of,
|
|
|
|
* other stuff zero'd - Jean II */
|
|
|
|
spin_lock_init(&priv->spinlock);
|
|
|
|
|
|
|
|
/* Netwave specific entries in the device structure */
|
|
|
|
dev->hard_start_xmit = &netwave_start_xmit;
|
|
|
|
dev->get_stats = &netwave_get_stats;
|
|
|
|
dev->set_multicast_list = &set_multicast_list;
|
|
|
|
/* wireless extensions */
|
|
|
|
dev->wireless_handlers = (struct iw_handler_def *)&netwave_handler_def;
|
|
|
|
|
|
|
|
dev->tx_timeout = &netwave_watchdog;
|
|
|
|
dev->watchdog_timeo = TX_TIMEOUT;
|
|
|
|
|
|
|
|
dev->open = &netwave_open;
|
|
|
|
dev->stop = &netwave_close;
|
|
|
|
link->irq.Instance = dev;
|
|
|
|
|
2006-03-31 10:26:06 -05:00
|
|
|
return netwave_pcmcia_config( link);
|
2005-04-16 18:20:36 -04:00
|
|
|
} /* netwave_attach */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function netwave_detach (link)
|
|
|
|
*
|
|
|
|
* This deletes a driver "instance". The device is de-registered
|
|
|
|
* with Card Services. If it has been released, all local data
|
|
|
|
* structures are freed. Otherwise, the structures will be freed
|
|
|
|
* when the device is released.
|
|
|
|
*/
|
2006-03-31 10:21:06 -05:00
|
|
|
static void netwave_detach(struct pcmcia_device *link)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2005-11-14 15:25:35 -05:00
|
|
|
struct net_device *dev = link->priv;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2005-11-14 15:25:35 -05:00
|
|
|
DEBUG(0, "netwave_detach(0x%p)\n", link);
|
|
|
|
|
2006-03-01 18:09:29 -05:00
|
|
|
netwave_release(link);
|
2005-11-14 15:25:35 -05:00
|
|
|
|
2006-03-05 04:45:09 -05:00
|
|
|
if (link->dev_node)
|
2005-11-14 15:25:35 -05:00
|
|
|
unregister_netdev(dev);
|
|
|
|
|
|
|
|
free_netdev(dev);
|
2005-04-16 18:20:36 -04:00
|
|
|
} /* netwave_detach */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get protocol name
|
|
|
|
*/
|
|
|
|
static int netwave_get_name(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu,
|
|
|
|
char *extra)
|
|
|
|
{
|
|
|
|
strcpy(wrqu->name, "Netwave");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wireless Handler : set Network ID
|
|
|
|
*/
|
|
|
|
static int netwave_set_nwid(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu,
|
|
|
|
char *extra)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
kio_addr_t iobase = dev->base_addr;
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
u_char __iomem *ramBase = priv->ramBase;
|
|
|
|
|
|
|
|
/* Disable interrupts & save flags */
|
|
|
|
spin_lock_irqsave(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
if(!wrqu->nwid.disabled) {
|
|
|
|
domain = wrqu->nwid.value;
|
|
|
|
printk( KERN_DEBUG "Setting domain to 0x%x%02x\n",
|
|
|
|
(domain >> 8) & 0x01, domain & 0xff);
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_SMD, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb( domain & 0xff, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
writeb((domain >>8 ) & 0x01,ramBase + NETWAVE_EREG_CB+2);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ReEnable interrupts & restore flags */
|
|
|
|
spin_unlock_irqrestore(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get Network ID
|
|
|
|
*/
|
|
|
|
static int netwave_get_nwid(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu,
|
|
|
|
char *extra)
|
|
|
|
{
|
|
|
|
wrqu->nwid.value = domain;
|
|
|
|
wrqu->nwid.disabled = 0;
|
|
|
|
wrqu->nwid.fixed = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wireless Handler : set scramble key
|
|
|
|
*/
|
|
|
|
static int netwave_set_scramble(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu,
|
|
|
|
char *key)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
kio_addr_t iobase = dev->base_addr;
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
u_char __iomem *ramBase = priv->ramBase;
|
|
|
|
|
|
|
|
/* Disable interrupts & save flags */
|
|
|
|
spin_lock_irqsave(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
scramble_key = (key[0] << 8) | key[1];
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_SSK, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(scramble_key & 0xff, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
writeb((scramble_key>>8) & 0xff, ramBase + NETWAVE_EREG_CB + 2);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 3);
|
|
|
|
|
|
|
|
/* ReEnable interrupts & restore flags */
|
|
|
|
spin_unlock_irqrestore(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get scramble key
|
|
|
|
*/
|
|
|
|
static int netwave_get_scramble(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu,
|
|
|
|
char *key)
|
|
|
|
{
|
|
|
|
key[1] = scramble_key & 0xff;
|
|
|
|
key[0] = (scramble_key>>8) & 0xff;
|
|
|
|
wrqu->encoding.flags = IW_ENCODE_ENABLED;
|
|
|
|
wrqu->encoding.length = 2;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get mode
|
|
|
|
*/
|
|
|
|
static int netwave_get_mode(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu,
|
|
|
|
char *extra)
|
|
|
|
{
|
|
|
|
if(domain & 0x100)
|
|
|
|
wrqu->mode = IW_MODE_INFRA;
|
|
|
|
else
|
|
|
|
wrqu->mode = IW_MODE_ADHOC;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get range info
|
|
|
|
*/
|
|
|
|
static int netwave_get_range(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu,
|
|
|
|
char *extra)
|
|
|
|
{
|
|
|
|
struct iw_range *range = (struct iw_range *) extra;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* Set the length (very important for backward compatibility) */
|
|
|
|
wrqu->data.length = sizeof(struct iw_range);
|
|
|
|
|
|
|
|
/* Set all the info we don't care or don't know about to zero */
|
|
|
|
memset(range, 0, sizeof(struct iw_range));
|
|
|
|
|
|
|
|
/* Set the Wireless Extension versions */
|
|
|
|
range->we_version_compiled = WIRELESS_EXT;
|
|
|
|
range->we_version_source = 9; /* Nothing for us in v10 and v11 */
|
|
|
|
|
|
|
|
/* Set information in the range struct */
|
|
|
|
range->throughput = 450 * 1000; /* don't argue on this ! */
|
|
|
|
range->min_nwid = 0x0000;
|
|
|
|
range->max_nwid = 0x01FF;
|
|
|
|
|
|
|
|
range->num_channels = range->num_frequency = 0;
|
|
|
|
|
|
|
|
range->sensitivity = 0x3F;
|
|
|
|
range->max_qual.qual = 255;
|
|
|
|
range->max_qual.level = 255;
|
|
|
|
range->max_qual.noise = 0;
|
|
|
|
|
|
|
|
range->num_bitrates = 1;
|
|
|
|
range->bitrate[0] = 1000000; /* 1 Mb/s */
|
|
|
|
|
|
|
|
range->encoding_size[0] = 2; /* 16 bits scrambling */
|
|
|
|
range->num_encoding_sizes = 1;
|
|
|
|
range->max_encoding_tokens = 1; /* Only one key possible */
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wireless Private Handler : get snapshot
|
|
|
|
*/
|
|
|
|
static int netwave_get_snap(struct net_device *dev,
|
|
|
|
struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu,
|
|
|
|
char *extra)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
kio_addr_t iobase = dev->base_addr;
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
u_char __iomem *ramBase = priv->ramBase;
|
|
|
|
|
|
|
|
/* Disable interrupts & save flags */
|
|
|
|
spin_lock_irqsave(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
/* Take snapshot of environment */
|
|
|
|
netwave_snapshot( priv, ramBase, iobase);
|
|
|
|
wrqu->data.length = priv->nss.length;
|
|
|
|
memcpy(extra, (u_char *) &priv->nss, sizeof( struct site_survey));
|
|
|
|
|
|
|
|
priv->lastExec = jiffies;
|
|
|
|
|
|
|
|
/* ReEnable interrupts & restore flags */
|
|
|
|
spin_unlock_irqrestore(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Structures to export the Wireless Handlers
|
|
|
|
* This is the stuff that are treated the wireless extensions (iwconfig)
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const struct iw_priv_args netwave_private_args[] = {
|
|
|
|
/*{ cmd, set_args, get_args, name } */
|
|
|
|
{ SIOCGIPSNAP, 0,
|
|
|
|
IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | sizeof(struct site_survey),
|
|
|
|
"getsitesurvey" },
|
|
|
|
};
|
|
|
|
|
|
|
|
static const iw_handler netwave_handler[] =
|
|
|
|
{
|
|
|
|
NULL, /* SIOCSIWNAME */
|
|
|
|
netwave_get_name, /* SIOCGIWNAME */
|
|
|
|
netwave_set_nwid, /* SIOCSIWNWID */
|
|
|
|
netwave_get_nwid, /* SIOCGIWNWID */
|
|
|
|
NULL, /* SIOCSIWFREQ */
|
|
|
|
NULL, /* SIOCGIWFREQ */
|
|
|
|
NULL, /* SIOCSIWMODE */
|
|
|
|
netwave_get_mode, /* SIOCGIWMODE */
|
|
|
|
NULL, /* SIOCSIWSENS */
|
|
|
|
NULL, /* SIOCGIWSENS */
|
|
|
|
NULL, /* SIOCSIWRANGE */
|
|
|
|
netwave_get_range, /* SIOCGIWRANGE */
|
|
|
|
NULL, /* SIOCSIWPRIV */
|
|
|
|
NULL, /* SIOCGIWPRIV */
|
|
|
|
NULL, /* SIOCSIWSTATS */
|
|
|
|
NULL, /* SIOCGIWSTATS */
|
|
|
|
NULL, /* SIOCSIWSPY */
|
|
|
|
NULL, /* SIOCGIWSPY */
|
|
|
|
NULL, /* -- hole -- */
|
|
|
|
NULL, /* -- hole -- */
|
|
|
|
NULL, /* SIOCSIWAP */
|
|
|
|
NULL, /* SIOCGIWAP */
|
|
|
|
NULL, /* -- hole -- */
|
|
|
|
NULL, /* SIOCGIWAPLIST */
|
|
|
|
NULL, /* -- hole -- */
|
|
|
|
NULL, /* -- hole -- */
|
|
|
|
NULL, /* SIOCSIWESSID */
|
|
|
|
NULL, /* SIOCGIWESSID */
|
|
|
|
NULL, /* SIOCSIWNICKN */
|
|
|
|
NULL, /* SIOCGIWNICKN */
|
|
|
|
NULL, /* -- hole -- */
|
|
|
|
NULL, /* -- hole -- */
|
|
|
|
NULL, /* SIOCSIWRATE */
|
|
|
|
NULL, /* SIOCGIWRATE */
|
|
|
|
NULL, /* SIOCSIWRTS */
|
|
|
|
NULL, /* SIOCGIWRTS */
|
|
|
|
NULL, /* SIOCSIWFRAG */
|
|
|
|
NULL, /* SIOCGIWFRAG */
|
|
|
|
NULL, /* SIOCSIWTXPOW */
|
|
|
|
NULL, /* SIOCGIWTXPOW */
|
|
|
|
NULL, /* SIOCSIWRETRY */
|
|
|
|
NULL, /* SIOCGIWRETRY */
|
|
|
|
netwave_set_scramble, /* SIOCSIWENCODE */
|
|
|
|
netwave_get_scramble, /* SIOCGIWENCODE */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const iw_handler netwave_private_handler[] =
|
|
|
|
{
|
|
|
|
NULL, /* SIOCIWFIRSTPRIV */
|
|
|
|
netwave_get_snap, /* SIOCIWFIRSTPRIV + 1 */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct iw_handler_def netwave_handler_def =
|
|
|
|
{
|
2007-09-02 06:30:18 -04:00
|
|
|
.num_standard = ARRAY_SIZE(netwave_handler),
|
|
|
|
.num_private = ARRAY_SIZE(netwave_private_handler),
|
|
|
|
.num_private_args = ARRAY_SIZE(netwave_private_args),
|
2005-04-16 18:20:36 -04:00
|
|
|
.standard = (iw_handler *) netwave_handler,
|
|
|
|
.private = (iw_handler *) netwave_private_handler,
|
|
|
|
.private_args = (struct iw_priv_args *) netwave_private_args,
|
2005-09-02 14:39:02 -04:00
|
|
|
.get_wireless_stats = netwave_get_wireless_stats,
|
2005-04-16 18:20:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function netwave_pcmcia_config (link)
|
|
|
|
*
|
|
|
|
* netwave_pcmcia_config() is scheduled to run after a CARD_INSERTION
|
|
|
|
* event is received, to configure the PCMCIA socket, and to make the
|
|
|
|
* device available to the system.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define CS_CHECK(fn, ret) \
|
|
|
|
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
|
|
|
|
|
2006-03-31 10:26:06 -05:00
|
|
|
static int netwave_pcmcia_config(struct pcmcia_device *link) {
|
2005-04-16 18:20:36 -04:00
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
int i, j, last_ret, last_fn;
|
|
|
|
win_req_t req;
|
|
|
|
memreq_t mem;
|
|
|
|
u_char __iomem *ramBase = NULL;
|
2007-10-03 20:59:30 -04:00
|
|
|
DECLARE_MAC_BUF(mac);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
DEBUG(0, "netwave_pcmcia_config(0x%p)\n", link);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try allocating IO ports. This tries a few fixed addresses.
|
|
|
|
* If you want, you can also read the card's config table to
|
|
|
|
* pick addresses -- see the serial driver for an example.
|
|
|
|
*/
|
|
|
|
for (i = j = 0x0; j < 0x400; j += 0x20) {
|
|
|
|
link->io.BasePort1 = j ^ 0x300;
|
2006-03-31 10:21:06 -05:00
|
|
|
i = pcmcia_request_io(link, &link->io);
|
2005-04-16 18:20:36 -04:00
|
|
|
if (i == CS_SUCCESS) break;
|
|
|
|
}
|
|
|
|
if (i != CS_SUCCESS) {
|
2006-03-31 10:21:06 -05:00
|
|
|
cs_error(link, RequestIO, i);
|
2005-04-16 18:20:36 -04:00
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now allocate an interrupt line. Note that this does not
|
|
|
|
* actually assign a handler to the interrupt.
|
|
|
|
*/
|
2006-03-31 10:21:06 -05:00
|
|
|
CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This actually configures the PCMCIA socket -- setting up
|
|
|
|
* the I/O windows and the interrupt mapping.
|
|
|
|
*/
|
2006-03-31 10:21:06 -05:00
|
|
|
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/*
|
2006-03-31 10:21:06 -05:00
|
|
|
* Allocate a 32K memory window. Note that the struct pcmcia_device
|
2005-04-16 18:20:36 -04:00
|
|
|
* structure provides space for one window handle -- if your
|
|
|
|
* device needs several windows, you'll need to keep track of
|
|
|
|
* the handles in your private data structure, dev->priv.
|
|
|
|
*/
|
|
|
|
DEBUG(1, "Setting mem speed of %d\n", mem_speed);
|
|
|
|
|
|
|
|
req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE;
|
|
|
|
req.Base = 0; req.Size = 0x8000;
|
|
|
|
req.AccessSpeed = mem_speed;
|
2006-03-31 10:21:06 -05:00
|
|
|
CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win));
|
2005-04-16 18:20:36 -04:00
|
|
|
mem.CardOffset = 0x20000; mem.Page = 0;
|
|
|
|
CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
|
|
|
|
|
|
|
|
/* Store base address of the common window frame */
|
|
|
|
ramBase = ioremap(req.Base, 0x8000);
|
|
|
|
priv->ramBase = ramBase;
|
|
|
|
|
|
|
|
dev->irq = link->irq.AssignedIRQ;
|
|
|
|
dev->base_addr = link->io.BasePort1;
|
2006-03-31 10:21:06 -05:00
|
|
|
SET_NETDEV_DEV(dev, &handle_to_dev(link));
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
if (register_netdev(dev) != 0) {
|
|
|
|
printk(KERN_DEBUG "netwave_cs: register_netdev() failed\n");
|
|
|
|
goto failed;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(priv->node.dev_name, dev->name);
|
2006-03-05 04:45:09 -05:00
|
|
|
link->dev_node = &priv->node;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* Reset card before reading physical address */
|
|
|
|
netwave_doreset(dev->base_addr, ramBase);
|
|
|
|
|
|
|
|
/* Read the ethernet address and fill in the Netwave registers. */
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
dev->dev_addr[i] = readb(ramBase + NETWAVE_EREG_PA + i);
|
|
|
|
|
2007-11-19 20:48:27 -05:00
|
|
|
printk(KERN_INFO "%s: Netwave: port %#3lx, irq %d, mem %lx, "
|
2007-10-03 20:59:30 -04:00
|
|
|
"id %c%c, hw_addr %s\n",
|
|
|
|
dev->name, dev->base_addr, dev->irq,
|
|
|
|
(u_long) ramBase,
|
|
|
|
(int) readb(ramBase+NETWAVE_EREG_NI),
|
|
|
|
(int) readb(ramBase+NETWAVE_EREG_NI+1),
|
|
|
|
print_mac(mac, dev->dev_addr));
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/* get revision words */
|
|
|
|
printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n",
|
|
|
|
get_uint16(ramBase + NETWAVE_EREG_ARW),
|
|
|
|
get_uint16(ramBase + NETWAVE_EREG_ARW+2));
|
2006-03-31 10:26:06 -05:00
|
|
|
return 0;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
cs_failed:
|
2006-03-31 10:21:06 -05:00
|
|
|
cs_error(link, last_fn, last_ret);
|
2005-04-16 18:20:36 -04:00
|
|
|
failed:
|
|
|
|
netwave_release(link);
|
2006-03-31 10:26:06 -05:00
|
|
|
return -ENODEV;
|
2005-04-16 18:20:36 -04:00
|
|
|
} /* netwave_pcmcia_config */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function netwave_release (arg)
|
|
|
|
*
|
|
|
|
* After a card is removed, netwave_release() will unregister the net
|
|
|
|
* device, and release the PCMCIA configuration. If the device is
|
|
|
|
* still open, this will be postponed until it is closed.
|
|
|
|
*/
|
2006-03-31 10:21:06 -05:00
|
|
|
static void netwave_release(struct pcmcia_device *link)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
2006-01-15 03:32:39 -05:00
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2006-01-15 03:32:39 -05:00
|
|
|
DEBUG(0, "netwave_release(0x%p)\n", link);
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2006-03-31 10:21:06 -05:00
|
|
|
pcmcia_disable_device(link);
|
2006-01-15 03:32:39 -05:00
|
|
|
if (link->win)
|
|
|
|
iounmap(priv->ramBase);
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
2006-03-31 10:21:06 -05:00
|
|
|
static int netwave_suspend(struct pcmcia_device *link)
|
2005-11-14 15:21:18 -05:00
|
|
|
{
|
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
|
2006-03-01 18:09:29 -05:00
|
|
|
if (link->open)
|
2006-03-01 18:02:33 -05:00
|
|
|
netif_device_detach(dev);
|
2005-11-14 15:21:18 -05:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-31 10:21:06 -05:00
|
|
|
static int netwave_resume(struct pcmcia_device *link)
|
2005-11-14 15:21:18 -05:00
|
|
|
{
|
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
|
2006-03-01 18:09:29 -05:00
|
|
|
if (link->open) {
|
2006-03-01 18:02:33 -05:00
|
|
|
netwave_reset(dev);
|
|
|
|
netif_device_attach(dev);
|
2005-11-14 15:21:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* Function netwave_doreset (ioBase, ramBase)
|
|
|
|
*
|
|
|
|
* Proper hardware reset of the card.
|
|
|
|
*/
|
|
|
|
static void netwave_doreset(kio_addr_t ioBase, u_char __iomem *ramBase)
|
|
|
|
{
|
|
|
|
/* Reset card */
|
|
|
|
wait_WOC(ioBase);
|
|
|
|
outb(0x80, ioBase + NETWAVE_REG_PMR);
|
|
|
|
writeb(0x08, ramBase + NETWAVE_EREG_ASCC); /* Bit 3 is WOC */
|
|
|
|
outb(0x0, ioBase + NETWAVE_REG_PMR); /* release reset */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function netwave_reset (dev)
|
|
|
|
*
|
|
|
|
* Reset and restore all of the netwave registers
|
|
|
|
*/
|
|
|
|
static void netwave_reset(struct net_device *dev) {
|
|
|
|
/* u_char state; */
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
u_char __iomem *ramBase = priv->ramBase;
|
|
|
|
kio_addr_t iobase = dev->base_addr;
|
|
|
|
|
|
|
|
DEBUG(0, "netwave_reset: Done with hardware reset\n");
|
|
|
|
|
|
|
|
priv->timeoutCounter = 0;
|
|
|
|
|
|
|
|
/* Reset card */
|
|
|
|
netwave_doreset(iobase, ramBase);
|
|
|
|
printk(KERN_DEBUG "netwave_reset: Done with hardware reset\n");
|
|
|
|
|
|
|
|
/* Write a NOP to check the card */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_NOP, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
|
|
|
|
/* Set receive conf */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_SRC, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(rxConfRxEna + rxConfBcast, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 2);
|
|
|
|
|
|
|
|
/* Set transmit conf */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_STC, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(txConfTxEna, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 2);
|
|
|
|
|
|
|
|
/* Now set the MU Domain */
|
|
|
|
printk(KERN_DEBUG "Setting domain to 0x%x%02x\n", (domain >> 8) & 0x01, domain & 0xff);
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_SMD, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(domain & 0xff, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
writeb((domain>>8) & 0x01, ramBase + NETWAVE_EREG_CB + 2);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 3);
|
|
|
|
|
|
|
|
/* Set scramble key */
|
|
|
|
printk(KERN_DEBUG "Setting scramble key to 0x%x\n", scramble_key);
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_SSK, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(scramble_key & 0xff, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
writeb((scramble_key>>8) & 0xff, ramBase + NETWAVE_EREG_CB + 2);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 3);
|
|
|
|
|
|
|
|
/* Enable interrupts, bit 4 high to keep unused
|
|
|
|
* source from interrupting us, bit 2 high to
|
|
|
|
* set interrupt enable, 567 to enable TxDN,
|
|
|
|
* RxErr and RxRdy
|
|
|
|
*/
|
|
|
|
wait_WOC(iobase);
|
|
|
|
outb(imrConfIENA+imrConfRFU1, iobase + NETWAVE_REG_IMR);
|
|
|
|
|
|
|
|
/* Hent 4 bytes fra 0x170. Skal vaere 0a,29,88,36
|
|
|
|
* waitWOC
|
|
|
|
* skriv 80 til d000:3688
|
|
|
|
* sjekk om det ble 80
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Enable Receiver */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_ER, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
|
|
|
|
/* Set the IENA bit in COR */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
outb(corConfIENA + corConfLVLREQ, iobase + NETWAVE_REG_COR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function netwave_hw_xmit (data, len, dev)
|
|
|
|
*/
|
|
|
|
static int netwave_hw_xmit(unsigned char* data, int len,
|
|
|
|
struct net_device* dev) {
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int TxFreeList,
|
|
|
|
curBuff,
|
|
|
|
MaxData,
|
|
|
|
DataOffset;
|
|
|
|
int tmpcount;
|
|
|
|
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
u_char __iomem * ramBase = priv->ramBase;
|
|
|
|
kio_addr_t iobase = dev->base_addr;
|
|
|
|
|
|
|
|
/* Disable interrupts & save flags */
|
|
|
|
spin_lock_irqsave(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
/* Check if there are transmit buffers available */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
if ((inb(iobase+NETWAVE_REG_ASR) & NETWAVE_ASR_TXBA) == 0) {
|
|
|
|
/* No buffers available */
|
|
|
|
printk(KERN_DEBUG "netwave_hw_xmit: %s - no xmit buffers available.\n",
|
|
|
|
dev->name);
|
|
|
|
spin_unlock_irqrestore(&priv->spinlock, flags);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->stats.tx_bytes += len;
|
|
|
|
|
|
|
|
DEBUG(3, "Transmitting with SPCQ %x SPU %x LIF %x ISPLQ %x\n",
|
|
|
|
readb(ramBase + NETWAVE_EREG_SPCQ),
|
|
|
|
readb(ramBase + NETWAVE_EREG_SPU),
|
|
|
|
readb(ramBase + NETWAVE_EREG_LIF),
|
|
|
|
readb(ramBase + NETWAVE_EREG_ISPLQ));
|
|
|
|
|
|
|
|
/* Now try to insert it into the adapters free memory */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
TxFreeList = get_uint16(ramBase + NETWAVE_EREG_TDP);
|
|
|
|
MaxData = get_uint16(ramBase + NETWAVE_EREG_TDP+2);
|
|
|
|
DataOffset = get_uint16(ramBase + NETWAVE_EREG_TDP+4);
|
|
|
|
|
|
|
|
DEBUG(3, "TxFreeList %x, MaxData %x, DataOffset %x\n",
|
|
|
|
TxFreeList, MaxData, DataOffset);
|
|
|
|
|
|
|
|
/* Copy packet to the adapter fragment buffers */
|
|
|
|
curBuff = TxFreeList;
|
|
|
|
tmpcount = 0;
|
|
|
|
while (tmpcount < len) {
|
|
|
|
int tmplen = len - tmpcount;
|
|
|
|
copy_to_pc(ramBase + curBuff + DataOffset, data + tmpcount,
|
|
|
|
(tmplen < MaxData) ? tmplen : MaxData);
|
|
|
|
tmpcount += MaxData;
|
|
|
|
|
|
|
|
/* Advance to next buffer */
|
|
|
|
curBuff = get_uint16(ramBase + curBuff);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now issue transmit list */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_TL, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(len & 0xff, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
writeb((len>>8) & 0xff, ramBase + NETWAVE_EREG_CB + 2);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 3);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&priv->spinlock, flags);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netwave_start_xmit(struct sk_buff *skb, struct net_device *dev) {
|
|
|
|
/* This flag indicate that the hardware can't perform a transmission.
|
|
|
|
* Theoritically, NET3 check it before sending a packet to the driver,
|
|
|
|
* but in fact it never do that and pool continuously.
|
|
|
|
* As the watchdog will abort too long transmissions, we are quite safe...
|
|
|
|
*/
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
|
|
|
{
|
|
|
|
short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
|
|
|
|
unsigned char* buf = skb->data;
|
|
|
|
|
|
|
|
if (netwave_hw_xmit( buf, length, dev) == 1) {
|
|
|
|
/* Some error, let's make them call us another time? */
|
|
|
|
netif_start_queue(dev);
|
|
|
|
}
|
|
|
|
dev->trans_start = jiffies;
|
|
|
|
}
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
} /* netwave_start_xmit */
|
|
|
|
|
|
|
|
/*
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 09:55:46 -04:00
|
|
|
* Function netwave_interrupt (irq, dev_id)
|
2005-04-16 18:20:36 -04:00
|
|
|
*
|
|
|
|
* This function is the interrupt handler for the Netwave card. This
|
|
|
|
* routine will be called whenever:
|
|
|
|
* 1. A packet is received.
|
|
|
|
* 2. A packet has successfully been transferred and the unit is
|
|
|
|
* ready to transmit another packet.
|
|
|
|
* 3. A command has completed execution.
|
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 09:55:46 -04:00
|
|
|
static irqreturn_t netwave_interrupt(int irq, void* dev_id)
|
2005-04-16 18:20:36 -04:00
|
|
|
{
|
|
|
|
kio_addr_t iobase;
|
|
|
|
u_char __iomem *ramBase;
|
|
|
|
struct net_device *dev = (struct net_device *)dev_id;
|
|
|
|
struct netwave_private *priv = netdev_priv(dev);
|
2006-03-31 10:21:06 -05:00
|
|
|
struct pcmcia_device *link = priv->p_dev;
|
2005-04-16 18:20:36 -04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!netif_device_present(dev))
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
|
|
|
iobase = dev->base_addr;
|
|
|
|
ramBase = priv->ramBase;
|
|
|
|
|
|
|
|
/* Now find what caused the interrupt, check while interrupts ready */
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
u_char status;
|
|
|
|
|
|
|
|
wait_WOC(iobase);
|
|
|
|
if (!(inb(iobase+NETWAVE_REG_CCSR) & 0x02))
|
|
|
|
break; /* None of the interrupt sources asserted (normal exit) */
|
|
|
|
|
|
|
|
status = inb(iobase + NETWAVE_REG_ASR);
|
|
|
|
|
2006-03-05 05:04:33 -05:00
|
|
|
if (!pcmcia_dev_present(link)) {
|
2005-04-16 18:20:36 -04:00
|
|
|
DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x "
|
|
|
|
"from removed or suspended card!\n", status);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* RxRdy */
|
|
|
|
if (status & 0x80) {
|
|
|
|
netwave_rx(dev);
|
|
|
|
/* wait_WOC(iobase); */
|
|
|
|
/* RxRdy cannot be reset directly by the host */
|
|
|
|
}
|
|
|
|
/* RxErr */
|
|
|
|
if (status & 0x40) {
|
|
|
|
u_char rser;
|
|
|
|
|
|
|
|
rser = readb(ramBase + NETWAVE_EREG_RSER);
|
|
|
|
|
|
|
|
if (rser & 0x04) {
|
|
|
|
++priv->stats.rx_dropped;
|
|
|
|
++priv->stats.rx_crc_errors;
|
|
|
|
}
|
|
|
|
if (rser & 0x02)
|
|
|
|
++priv->stats.rx_frame_errors;
|
|
|
|
|
|
|
|
/* Clear the RxErr bit in RSER. RSER+4 is the
|
|
|
|
* write part. Also clear the RxCRC (0x04) and
|
|
|
|
* RxBig (0x02) bits if present */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(0x40 | (rser & 0x06), ramBase + NETWAVE_EREG_RSER + 4);
|
|
|
|
|
|
|
|
/* Write bit 6 high to ASCC to clear RxErr in ASR,
|
|
|
|
* WOC must be set first!
|
|
|
|
*/
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(0x40, ramBase + NETWAVE_EREG_ASCC);
|
|
|
|
|
|
|
|
/* Remember to count up priv->stats on error packets */
|
|
|
|
++priv->stats.rx_errors;
|
|
|
|
}
|
|
|
|
/* TxDN */
|
|
|
|
if (status & 0x20) {
|
|
|
|
int txStatus;
|
|
|
|
|
|
|
|
txStatus = readb(ramBase + NETWAVE_EREG_TSER);
|
|
|
|
DEBUG(3, "Transmit done. TSER = %x id %x\n",
|
|
|
|
txStatus, readb(ramBase + NETWAVE_EREG_TSER + 1));
|
|
|
|
|
|
|
|
if (txStatus & 0x20) {
|
|
|
|
/* Transmitting was okay, clear bits */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(0x2f, ramBase + NETWAVE_EREG_TSER + 4);
|
|
|
|
++priv->stats.tx_packets;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (txStatus & 0xd0) {
|
|
|
|
if (txStatus & 0x80) {
|
|
|
|
++priv->stats.collisions; /* Because of /proc/net/dev*/
|
|
|
|
/* ++priv->stats.tx_aborted_errors; */
|
|
|
|
/* printk("Collision. %ld\n", jiffies - dev->trans_start); */
|
|
|
|
}
|
|
|
|
if (txStatus & 0x40)
|
|
|
|
++priv->stats.tx_carrier_errors;
|
|
|
|
/* 0x80 TxGU Transmit giveup - nine times and no luck
|
|
|
|
* 0x40 TxNOAP No access point. Discarded packet.
|
|
|
|
* 0x10 TxErr Transmit error. Always set when
|
|
|
|
* TxGU and TxNOAP is set. (Those are the only ones
|
|
|
|
* to set TxErr).
|
|
|
|
*/
|
|
|
|
DEBUG(3, "netwave_interrupt: TxDN with error status %x\n",
|
|
|
|
txStatus);
|
|
|
|
|
|
|
|
/* Clear out TxGU, TxNOAP, TxErr and TxTrys */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(0xdf & txStatus, ramBase+NETWAVE_EREG_TSER+4);
|
|
|
|
++priv->stats.tx_errors;
|
|
|
|
}
|
|
|
|
DEBUG(3, "New status is TSER %x ASR %x\n",
|
|
|
|
readb(ramBase + NETWAVE_EREG_TSER),
|
|
|
|
inb(iobase + NETWAVE_REG_ASR));
|
|
|
|
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
|
|
|
/* TxBA, this would trigger on all error packets received */
|
|
|
|
/* if (status & 0x01) {
|
|
|
|
DEBUG(4, "Transmit buffers available, %x\n", status);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
/* Handled if we looped at least one time - Jean II */
|
|
|
|
return IRQ_RETVAL(i);
|
|
|
|
} /* netwave_interrupt */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function netwave_watchdog (a)
|
|
|
|
*
|
|
|
|
* Watchdog : when we start a transmission, we set a timer in the
|
|
|
|
* kernel. If the transmission complete, this timer is disabled. If
|
|
|
|
* it expire, we reset the card.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void netwave_watchdog(struct net_device *dev) {
|
|
|
|
|
|
|
|
DEBUG(1, "%s: netwave_watchdog: watchdog timer expired\n", dev->name);
|
|
|
|
netwave_reset(dev);
|
|
|
|
dev->trans_start = jiffies;
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
} /* netwave_watchdog */
|
|
|
|
|
|
|
|
static struct net_device_stats *netwave_get_stats(struct net_device *dev) {
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
|
|
|
|
update_stats(dev);
|
|
|
|
|
|
|
|
DEBUG(2, "netwave: SPCQ %x SPU %x LIF %x ISPLQ %x MHS %x rxtx %x"
|
|
|
|
" %x tx %x %x %x %x\n",
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_SPCQ),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_SPU),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_LIF),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_ISPLQ),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_MHS),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_EC + 0xe),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_EC + 0xf),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_EC + 0x18),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_EC + 0x19),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_EC + 0x1a),
|
|
|
|
readb(priv->ramBase + NETWAVE_EREG_EC + 0x1b));
|
|
|
|
|
|
|
|
return &priv->stats;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_stats(struct net_device *dev) {
|
|
|
|
//unsigned long flags;
|
|
|
|
/* netwave_private *priv = netdev_priv(dev); */
|
|
|
|
|
|
|
|
//spin_lock_irqsave(&priv->spinlock, flags);
|
|
|
|
|
|
|
|
/* priv->stats.rx_packets = readb(priv->ramBase + 0x18e);
|
|
|
|
priv->stats.tx_packets = readb(priv->ramBase + 0x18f); */
|
|
|
|
|
|
|
|
//spin_unlock_irqrestore(&priv->spinlock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netwave_rx(struct net_device *dev)
|
|
|
|
{
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
u_char __iomem *ramBase = priv->ramBase;
|
|
|
|
kio_addr_t iobase = dev->base_addr;
|
|
|
|
u_char rxStatus;
|
|
|
|
struct sk_buff *skb = NULL;
|
|
|
|
unsigned int curBuffer,
|
|
|
|
rcvList;
|
|
|
|
int rcvLen;
|
|
|
|
int tmpcount = 0;
|
|
|
|
int dataCount, dataOffset;
|
|
|
|
int i;
|
|
|
|
u_char *ptr;
|
|
|
|
|
|
|
|
DEBUG(3, "xinw_rx: Receiving ... \n");
|
|
|
|
|
|
|
|
/* Receive max 10 packets for now. */
|
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
/* Any packets? */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
rxStatus = readb(ramBase + NETWAVE_EREG_RSER);
|
|
|
|
if ( !( rxStatus & 0x80)) /* No more packets */
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Check if multicast/broadcast or other */
|
|
|
|
/* multicast = (rxStatus & 0x20); */
|
|
|
|
|
|
|
|
/* The receive list pointer and length of the packet */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
rcvLen = get_int16( ramBase + NETWAVE_EREG_RDP);
|
|
|
|
rcvList = get_uint16( ramBase + NETWAVE_EREG_RDP + 2);
|
|
|
|
|
|
|
|
if (rcvLen < 0) {
|
|
|
|
printk(KERN_DEBUG "netwave_rx: Receive packet with len %d\n",
|
|
|
|
rcvLen);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb = dev_alloc_skb(rcvLen+5);
|
|
|
|
if (skb == NULL) {
|
|
|
|
DEBUG(1, "netwave_rx: Could not allocate an sk_buff of "
|
|
|
|
"length %d\n", rcvLen);
|
|
|
|
++priv->stats.rx_dropped;
|
|
|
|
/* Tell the adapter to skip the packet */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_SRP, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb_reserve( skb, 2); /* Align IP on 16 byte */
|
|
|
|
skb_put( skb, rcvLen);
|
|
|
|
|
|
|
|
/* Copy packet fragments to the skb data area */
|
|
|
|
ptr = (u_char*) skb->data;
|
|
|
|
curBuffer = rcvList;
|
|
|
|
tmpcount = 0;
|
|
|
|
while ( tmpcount < rcvLen) {
|
|
|
|
/* Get length and offset of current buffer */
|
|
|
|
dataCount = get_uint16( ramBase+curBuffer+2);
|
|
|
|
dataOffset = get_uint16( ramBase+curBuffer+4);
|
|
|
|
|
|
|
|
copy_from_pc( ptr + tmpcount,
|
|
|
|
ramBase+curBuffer+dataOffset, dataCount);
|
|
|
|
|
|
|
|
tmpcount += dataCount;
|
|
|
|
|
|
|
|
/* Point to next buffer */
|
|
|
|
curBuffer = get_uint16(ramBase + curBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
skb->protocol = eth_type_trans(skb,dev);
|
|
|
|
/* Queue packet for network layer */
|
|
|
|
netif_rx(skb);
|
|
|
|
|
|
|
|
dev->last_rx = jiffies;
|
|
|
|
priv->stats.rx_packets++;
|
|
|
|
priv->stats.rx_bytes += rcvLen;
|
|
|
|
|
|
|
|
/* Got the packet, tell the adapter to skip it */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_SRP, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
DEBUG(3, "Packet reception ok\n");
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netwave_open(struct net_device *dev) {
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
2006-03-31 10:21:06 -05:00
|
|
|
struct pcmcia_device *link = priv->p_dev;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
DEBUG(1, "netwave_open: starting.\n");
|
|
|
|
|
2006-03-05 05:04:33 -05:00
|
|
|
if (!pcmcia_dev_present(link))
|
2005-04-16 18:20:36 -04:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
link->open++;
|
|
|
|
|
|
|
|
netif_start_queue(dev);
|
|
|
|
netwave_reset(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int netwave_close(struct net_device *dev) {
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
2006-03-31 10:21:06 -05:00
|
|
|
struct pcmcia_device *link = priv->p_dev;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
DEBUG(1, "netwave_close: finishing.\n");
|
|
|
|
|
|
|
|
link->open--;
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-27 19:28:23 -04:00
|
|
|
static struct pcmcia_device_id netwave_ids[] = {
|
|
|
|
PCMCIA_DEVICE_PROD_ID12("Xircom", "CreditCard Netwave", 0x2e3ee845, 0x54e28a28),
|
|
|
|
PCMCIA_DEVICE_NULL,
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pcmcia, netwave_ids);
|
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
static struct pcmcia_driver netwave_driver = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.drv = {
|
|
|
|
.name = "netwave_cs",
|
|
|
|
},
|
2006-03-31 10:26:06 -05:00
|
|
|
.probe = netwave_probe,
|
2005-11-14 15:23:14 -05:00
|
|
|
.remove = netwave_detach,
|
2005-06-27 19:28:23 -04:00
|
|
|
.id_table = netwave_ids,
|
2005-11-14 15:21:18 -05:00
|
|
|
.suspend = netwave_suspend,
|
|
|
|
.resume = netwave_resume,
|
2005-04-16 18:20:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init init_netwave_cs(void)
|
|
|
|
{
|
|
|
|
return pcmcia_register_driver(&netwave_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit exit_netwave_cs(void)
|
|
|
|
{
|
|
|
|
pcmcia_unregister_driver(&netwave_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(init_netwave_cs);
|
|
|
|
module_exit(exit_netwave_cs);
|
|
|
|
|
|
|
|
/* Set or clear the multicast filter for this adaptor.
|
|
|
|
num_addrs == -1 Promiscuous mode, receive all packets
|
|
|
|
num_addrs == 0 Normal mode, clear multicast list
|
|
|
|
num_addrs > 0 Multicast mode, receive normal and MC packets, and do
|
|
|
|
best-effort filtering.
|
|
|
|
*/
|
|
|
|
static void set_multicast_list(struct net_device *dev)
|
|
|
|
{
|
|
|
|
kio_addr_t iobase = dev->base_addr;
|
|
|
|
netwave_private *priv = netdev_priv(dev);
|
|
|
|
u_char __iomem * ramBase = priv->ramBase;
|
|
|
|
u_char rcvMode = 0;
|
|
|
|
|
|
|
|
#ifdef PCMCIA_DEBUG
|
|
|
|
if (pc_debug > 2) {
|
|
|
|
static int old;
|
|
|
|
if (old != dev->mc_count) {
|
|
|
|
old = dev->mc_count;
|
|
|
|
DEBUG(0, "%s: setting Rx mode to %d addresses.\n",
|
|
|
|
dev->name, dev->mc_count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (dev->mc_count || (dev->flags & IFF_ALLMULTI)) {
|
|
|
|
/* Multicast Mode */
|
|
|
|
rcvMode = rxConfRxEna + rxConfAMP + rxConfBcast;
|
|
|
|
} else if (dev->flags & IFF_PROMISC) {
|
|
|
|
/* Promiscous mode */
|
|
|
|
rcvMode = rxConfRxEna + rxConfPro + rxConfAMP + rxConfBcast;
|
|
|
|
} else {
|
|
|
|
/* Normal mode */
|
|
|
|
rcvMode = rxConfRxEna + rxConfBcast;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* printk("netwave set_multicast_list: rcvMode to %x\n", rcvMode);*/
|
|
|
|
/* Now set receive mode */
|
|
|
|
wait_WOC(iobase);
|
|
|
|
writeb(NETWAVE_CMD_SRC, ramBase + NETWAVE_EREG_CB + 0);
|
|
|
|
writeb(rcvMode, ramBase + NETWAVE_EREG_CB + 1);
|
|
|
|
writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 2);
|
|
|
|
}
|
|
|
|
MODULE_LICENSE("GPL");
|