diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-08 05:37:58 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-08 05:37:58 -0400 |
commit | 5a2cec83a9bb1b4295aa8ab728fcb8ca1811a33c (patch) | |
tree | 2f83dc6949763e77cf6422e696dc6146684dcf4e /drivers/net | |
parent | f2c853bca542f5ac0b036377637192a74f2091c2 (diff) | |
parent | caf39e87cc1182f7dae84eefc43ca14d54c78ef9 (diff) |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'drivers/net')
32 files changed, 5495 insertions, 2492 deletions
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index 07746b95fd8..455ba915ede 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c @@ -973,6 +973,11 @@ static int vortex_suspend (struct pci_dev *pdev, pm_message_t state) netif_device_detach(dev); vortex_down(dev, 1); } + pci_save_state(pdev); + pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); + free_irq(dev->irq, dev); + pci_disable_device(pdev); + pci_set_power_state(pdev, pci_choose_state(pdev, state)); } return 0; } @@ -980,8 +985,19 @@ static int vortex_suspend (struct pci_dev *pdev, pm_message_t state) static int vortex_resume (struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); + struct vortex_private *vp = netdev_priv(dev); - if (dev && dev->priv) { + if (dev && vp) { + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + pci_enable_device(pdev); + pci_set_master(pdev); + if (request_irq(dev->irq, vp->full_bus_master_rx ? + &boomerang_interrupt : &vortex_interrupt, SA_SHIRQ, dev->name, dev)) { + printk(KERN_WARNING "%s: Could not reserve IRQ %d\n", dev->name, dev->irq); + pci_disable_device(pdev); + return -EBUSY; + } if (netif_running(dev)) { vortex_up(dev); netif_device_attach(dev); @@ -1873,6 +1889,7 @@ vortex_timer(unsigned long data) { spin_lock_bh(&vp->lock); mii_status = mdio_read(dev, vp->phys[0], 1); + mii_status = mdio_read(dev, vp->phys[0], 1); ok = 1; if (vortex_debug > 2) printk(KERN_DEBUG "%s: MII transceiver has status %4.4x.\n", diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index ae9e7a579b9..6bb9232514b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -2058,6 +2058,13 @@ config BNX2 To compile this driver as a module, choose M here: the module will be called bnx2. This is recommended. +config SPIDER_NET + tristate "Spider Gigabit Ethernet driver" + depends on PCI && PPC_BPA + help + This driver supports the Gigabit Ethernet chips present on the + Cell Processor-Based Blades from IBM. + config GIANFAR tristate "Gianfar Ethernet" depends on 85xx || 83xx diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 5baafcd5561..8645c843cf4 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -54,6 +54,8 @@ obj-$(CONFIG_STNIC) += stnic.o 8390.o obj-$(CONFIG_FEALNX) += fealnx.o obj-$(CONFIG_TIGON3) += tg3.o obj-$(CONFIG_BNX2) += bnx2.o +spidernet-y += spider_net.o spider_net_ethtool.o sungem_phy.o +obj-$(CONFIG_SPIDER_NET) += spidernet.o obj-$(CONFIG_TC35815) += tc35815.o obj-$(CONFIG_SKGE) += skge.o obj-$(CONFIG_SK98LIN) += sk98lin/ diff --git a/drivers/net/ac3200.c b/drivers/net/ac3200.c index 91791ba3776..8a0af5453e2 100644 --- a/drivers/net/ac3200.c +++ b/drivers/net/ac3200.c @@ -275,7 +275,7 @@ static int __init ac_probe1(int ioaddr, struct net_device *dev) return 0; out2: if (ei_status.reg0) - iounmap((void *)dev->mem_start); + iounmap(ei_status.mem); out1: free_irq(dev->irq, dev); out: diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c index 4f9f69e22c1..12ef52c193a 100644 --- a/drivers/net/arcnet/arcnet.c +++ b/drivers/net/arcnet/arcnet.c @@ -597,7 +597,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev) struct ArcProto *proto; int txbuf; unsigned long flags; - int freeskb = 0; + int freeskb, retval; BUGMSG(D_DURING, "transmit requested (status=%Xh, txbufs=%d/%d, len=%d, protocol %x)\n", @@ -615,7 +615,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev) if (skb->len - ARC_HDR_SIZE > XMTU && !proto->continue_tx) { BUGMSG(D_NORMAL, "fixme: packet too large: compensating badly!\n"); dev_kfree_skb(skb); - return 0; /* don't try again */ + return NETDEV_TX_OK; /* don't try again */ } /* We're busy transmitting a packet... */ @@ -623,8 +623,11 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev) spin_lock_irqsave(&lp->lock, flags); AINTMASK(0); - - txbuf = get_arcbuf(dev); + if(lp->next_tx == -1) + txbuf = get_arcbuf(dev); + else { + txbuf = -1; + } if (txbuf != -1) { if (proto->prepare_tx(dev, pkt, skb->len, txbuf) && !proto->ack_tx) { @@ -638,6 +641,8 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev) lp->outgoing.skb = skb; lp->outgoing.pkt = pkt; + freeskb = 0; + if (proto->continue_tx && proto->continue_tx(dev, txbuf)) { BUGMSG(D_NORMAL, @@ -645,10 +650,12 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev) "(proto='%c')\n", proto->suffix); } } - + retval = NETDEV_TX_OK; + dev->trans_start = jiffies; lp->next_tx = txbuf; } else { - freeskb = 1; + retval = NETDEV_TX_BUSY; + freeskb = 0; } BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__FUNCTION__,ASTATUS()); @@ -664,7 +671,7 @@ static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev) if (freeskb) { dev_kfree_skb(skb); } - return 0; /* no need to try again */ + return retval; /* no need to try again */ } @@ -690,7 +697,6 @@ static int go_tx(struct net_device *dev) /* start sending */ ACOMMAND(TXcmd | (lp->cur_tx << 3)); - dev->trans_start = jiffies; lp->stats.tx_packets++; lp->lasttrans_dest = lp->lastload_dest; lp->lastload_dest = 0; @@ -917,6 +923,9 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id, struct pt_regs *regs) BUGMSG(D_RECON, "Network reconfiguration detected (status=%Xh)\n", status); + /* MYRECON bit is at bit 7 of diagstatus */ + if(diagstatus & 0x80) + BUGMSG(D_RECON,"Put out that recon myself\n"); /* is the RECON info empty or old? */ if (!lp->first_recon || !lp->last_recon || diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c index ad011214c7f..e01b6a78ec6 100644 --- a/drivers/net/atarilance.c +++ b/drivers/net/atarilance.c @@ -235,7 +235,7 @@ struct lance_private { #define MEM lp->mem #define DREG IO->data #define AREG IO->addr -#define REGA(a) ( AREG = (a), DREG ) +#define REGA(a) (*( AREG = (a), &DREG )) /* Definitions for packet buffer access: */ #define PKT_BUF_SZ 1544 diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index 6440a892bb8..e54fc10f684 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c @@ -1140,7 +1140,7 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value) } static int -dm9000_drv_suspend(struct device *dev, u32 state, u32 level) +dm9000_drv_suspend(struct device *dev, pm_message_t state, u32 level) { struct net_device *ndev = dev_get_drvdata(dev); diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 7d93948aec8..d6eefdb71c1 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c @@ -1372,7 +1372,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu) /* synchronized against open : rtnl_lock() held by caller */ if (netif_running(dev)) { - u8 *base = get_hwbase(dev); + u8 __iomem *base = get_hwbase(dev); /* * It seems that the nic preloads valid ring entries into an * internal buffer. The procedure for flushing everything is @@ -1423,7 +1423,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu) static void nv_copy_mac_to_hw(struct net_device *dev) { - u8 *base = get_hwbase(dev); + u8 __iomem *base = get_hwbase(dev); u32 mac[2]; mac[0] = (dev->dev_addr[0] << 0) + (dev->dev_addr[1] << 8) + diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c index d9df1d9a573..bc9a3bf8d56 100644 --- a/drivers/net/hamachi.c +++ b/drivers/net/hamachi.c @@ -204,6 +204,10 @@ KERN_INFO " Further modifications by Keith Underwood <keithu@parl.clemson.edu> #define RUN_AT(x) (jiffies + (x)) +#ifndef ADDRLEN +#define ADDRLEN 32 +#endif + /* Condensed bus+endian portability operations. */ #if ADDRLEN == 64 #define cpu_to_leXX(addr) cpu_to_le64(addr) diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c index 10125a1dba2..dd89bda1f13 100644 --- a/drivers/net/irda/smsc-ircc2.c +++ b/drivers/net/irda/smsc-ircc2.c @@ -4,10 +4,10 @@ * Description: Driver for the SMC Infrared Communications Controller * Status: Experimental. * Author: Daniele Peri (peri@csai.unipa.it) - * Created at: - * Modified at: - * Modified by: - * + * Created at: + * Modified at: + * Modified by: + * * Copyright (c) 2002 Daniele Peri * All Rights Reserved. * Copyright (c) 2002 Jean Tourrilhes @@ -17,26 +17,26 @@ * * Copyright (c) 2001 Stefani Seibold * Copyright (c) 1999-2001 Dag Brattli - * Copyright (c) 1998-1999 Thomas Davis, + * Copyright (c) 1998-1999 Thomas Davis, * * and irport.c: * * Copyright (c) 1997, 1998, 1999-2000 Dag Brattli, All Rights Reserved. * - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ @@ -68,24 +68,42 @@ #include "smsc-ircc2.h" #include "smsc-sio.h" + +MODULE_AUTHOR("Daniele Peri <peri@csai.unipa.it>"); +MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver"); +MODULE_LICENSE("GPL"); + +static int ircc_dma = 255; +module_param(ircc_dma, int, 0); +MODULE_PARM_DESC(ircc_dma, "DMA channel"); + +static int ircc_irq = 255; +module_param(ircc_irq, int, 0); +MODULE_PARM_DESC(ircc_irq, "IRQ line"); + +static int ircc_fir; +module_param(ircc_fir, int, 0); +MODULE_PARM_DESC(ircc_fir, "FIR Base Address"); + +static int ircc_sir; +module_param(ircc_sir, int, 0); +MODULE_PARM_DESC(ircc_sir, "SIR Base Address"); + +static int ircc_cfg; +module_param(ircc_cfg, int, 0); +MODULE_PARM_DESC(ircc_cfg, "Configuration register base address"); + +static int ircc_transceiver; +module_param(ircc_transceiver, int, 0); +MODULE_PARM_DESC(ircc_transceiver, "Transceiver type"); + /* Types */ struct smsc_transceiver { char *name; - void (*set_for_speed)(int fir_base, u32 speed); + void (*set_for_speed)(int fir_base, u32 speed); int (*probe)(int fir_base); }; -typedef struct smsc_transceiver smsc_transceiver_t; - -#if 0 -struct smc_chip { - char *name; - u16 flags; - u8 devid; - u8 rev; -}; -typedef struct smc_chip smc_chip_t; -#endif struct smsc_chip { char *name; @@ -96,20 +114,18 @@ struct smsc_chip { u8 devid; u8 rev; }; -typedef struct smsc_chip smsc_chip_t; struct smsc_chip_address { unsigned int cfg_base; unsigned int type; }; -typedef struct smsc_chip_address smsc_chip_address_t; /* Private data for each instance */ struct smsc_ircc_cb { struct net_device *netdev; /* Yes! we are some kind of netdevice */ struct net_device_stats stats; struct irlap_cb *irlap; /* The link layer we are binded to */ - + chipio_t io; /* IrDA controller information */ iobuff_t tx_buff; /* Transmit buffer */ iobuff_t rx_buff; /* Receive buffer */ @@ -119,7 +135,7 @@ struct smsc_ircc_cb { struct qos_info qos; /* QoS capabilities for this device */ spinlock_t lock; /* For serializing operations */ - + __u32 new_speed; __u32 flags; /* Interface flags */ @@ -127,18 +143,20 @@ struct smsc_ircc_cb { int tx_len; /* Number of frames in tx_buff */ int transceiver; - struct pm_dev *pmdev; + struct platform_device *pldev; }; /* Constants */ -static const char *driver_name = "smsc-ircc2"; -#define DIM(x) (sizeof(x)/(sizeof(*(x)))) +#define SMSC_IRCC2_DRIVER_NAME "smsc-ircc2" + #define SMSC_IRCC2_C_IRDA_FALLBACK_SPEED 9600 #define SMSC_IRCC2_C_DEFAULT_TRANSCEIVER 1 -#define SMSC_IRCC2_C_NET_TIMEOUT 0 +#define SMSC_IRCC2_C_NET_TIMEOUT 0 #define SMSC_IRCC2_C_SIR_STOP 0 +static const char *driver_name = SMSC_IRCC2_DRIVER_NAME; + /* Prototypes */ static int smsc_ircc_open(unsigned int firbase, unsigned int sirbase, u8 dma, u8 irq); @@ -147,15 +165,15 @@ static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, unsigned int fir_base, static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self); static void smsc_ircc_init_chip(struct smsc_ircc_cb *self); static int __exit smsc_ircc_close(struct smsc_ircc_cb *self); -static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self, int iobase); -static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self, int iobase); +static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self); +static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self); static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self); static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev); static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev); -static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int iobase, int bofs); -static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self, int iobase); -static void smsc_ircc_change_speed(void *priv, u32 speed); -static void smsc_ircc_set_sir_speed(void *priv, u32 speed); +static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs); +static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self); +static void smsc_ircc_change_speed(struct smsc_ircc_cb *self, u32 speed); +static void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, u32 speed); static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *regs); static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev); static void smsc_ircc_sir_start(struct smsc_ircc_cb *self); @@ -171,7 +189,6 @@ static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cm static void smsc_ircc_timeout(struct net_device *dev); #endif static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev); -static int smsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data); static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self); static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self); static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed); @@ -179,9 +196,9 @@ static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self); /* Probing */ static int __init smsc_ircc_look_for_chips(void); -static const smsc_chip_t * __init smsc_ircc_probe(unsigned short cfg_base,u8 reg,const smsc_chip_t *chip,char *type); -static int __init smsc_superio_flat(const smsc_chip_t *chips, unsigned short cfg_base, char *type); -static int __init smsc_superio_paged(const smsc_chip_t *chips, unsigned short cfg_base, char *type); +static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type); +static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type); +static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type); static int __init smsc_superio_fdc(unsigned short cfg_base); static int __init smsc_superio_lpc(unsigned short cfg_base); @@ -196,21 +213,26 @@ static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base); /* Power Management */ -static void smsc_ircc_suspend(struct smsc_ircc_cb *self); -static void smsc_ircc_wakeup(struct smsc_ircc_cb *self); -static int smsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data); +static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level); +static int smsc_ircc_resume(struct device *dev, u32 level); +static struct device_driver smsc_ircc_driver = { + .name = SMSC_IRCC2_DRIVER_NAME, + .bus = &platform_bus_type, + .suspend = smsc_ircc_suspend, + .resume = smsc_ircc_resume, +}; /* Transceivers for SMSC-ircc */ -static smsc_transceiver_t smsc_transceivers[]= +static struct smsc_transceiver smsc_transceivers[] = { - { "Toshiba Satellite 1800 (GP data pin select)", smsc_ircc_set_transceiver_toshiba_sat1800, smsc_ircc_probe_transceiver_toshiba_sat1800}, - { "Fast pin select", smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select, smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select}, - { "ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc}, - { NULL, NULL} + { "Toshiba Satellite 1800 (GP data pin select)", smsc_ircc_set_transceiver_toshiba_sat1800, smsc_ircc_probe_transceiver_toshiba_sat1800 }, + { "Fast pin select", smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select, smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select }, + { "ATC IRMode", smsc_ircc_set_transceiver_smsc_ircc_atc, smsc_ircc_probe_transceiver_smsc_ircc_atc }, + { NULL, NULL } }; -#define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (DIM(smsc_transceivers)-1) +#define SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS (ARRAY_SIZE(smsc_transceivers) - 1) /* SMC SuperIO chipsets definitions */ @@ -221,7 +243,7 @@ static smsc_transceiver_t smsc_transceivers[]= #define FIR 4 /* SuperIO Chip has fast IRDA */ #define SERx4 8 /* SuperIO Chip supports 115,2 KBaud * 4=460,8 KBaud */ -static smsc_chip_t __initdata fdc_chips_flat[]= +static struct smsc_chip __initdata fdc_chips_flat[] = { /* Base address 0x3f0 or 0x370 */ { "37C44", KEY55_1|NoIRDA, 0x00, 0x00 }, /* This chip cannot be detected */ @@ -235,7 +257,7 @@ static smsc_chip_t __initdata fdc_chips_flat[]= { NULL } }; -static smsc_chip_t __initdata fdc_chips_paged[]= +static struct smsc_chip __initdata fdc_chips_paged[] = { /* Base address 0x3f0 or 0x370 */ { "37B72X", KEY55_1|SIR|SERx4, 0x4c, 0x00 }, @@ -254,7 +276,7 @@ static smsc_chip_t __initdata fdc_chips_paged[]= { NULL } }; -static smsc_chip_t __initdata lpc_chips_flat[]= +static struct smsc_chip __initdata lpc_chips_flat[] = { /* Base address 0x2E or 0x4E */ { "47N227", KEY55_1|FIR|SERx4, 0x5a, 0x00 }, @@ -262,7 +284,7 @@ static smsc_chip_t __initdata lpc_chips_flat[]= { NULL } }; -static smsc_chip_t __initdata lpc_chips_paged[]= +static struct smsc_chip __initdata lpc_chips_paged[] = { /* Base address 0x2E or 0x4E */ { "47B27X", KEY55_1|SIR|SERx4, 0x51, 0x00 }, @@ -281,33 +303,25 @@ static smsc_chip_t __initdata lpc_chips_paged[]= #define SMSCSIO_TYPE_FLAT 4 #define SMSCSIO_TYPE_PAGED 8 -static smsc_chip_address_t __initdata possible_addresses[]= +static struct smsc_chip_address __initdata possible_addresses[] = { - {0x3f0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED}, - {0x370, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED}, - {0xe0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED}, - {0x2e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED}, - {0x4e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED}, - {0,0} + { 0x3f0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED }, + { 0x370, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED }, + { 0xe0, SMSCSIO_TYPE_FDC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED }, + { 0x2e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED }, + { 0x4e, SMSCSIO_TYPE_LPC|SMSCSIO_TYPE_FLAT|SMSCSIO_TYPE_PAGED }, + { 0, 0 } }; /* Globals */ -static struct smsc_ircc_cb *dev_self[] = { NULL, NULL}; - -static int ircc_irq=255; -static int ircc_dma=255; -static int ircc_fir=0; -static int ircc_sir=0; -static int ircc_cfg=0; -static int ircc_transceiver=0; - -static unsigned short dev_count=0; +static struct smsc_ircc_cb *dev_self[] = { NULL, NULL }; +static unsigned short dev_count; static inline void register_bank(int iobase, int bank) { - outb(((inb(iobase+IRCC_MASTER) & 0xf0) | (bank & 0x07)), - iobase+IRCC_MASTER); + outb(((inb(iobase + IRCC_MASTER) & 0xf0) | (bank & 0x07)), + iobase + IRCC_MASTER); } @@ -327,34 +341,44 @@ static inline void register_bank(int iobase, int bank) */ static int __init smsc_ircc_init(void) { - int ret=-ENODEV; + int ret; IRDA_DEBUG(1, "%s\n", __FUNCTION__); - dev_count=0; - - if ((ircc_fir>0)&&(ircc_sir>0)) { + ret = driver_register(&smsc_ircc_driver); + if (ret) { + IRDA_ERROR("%s, Can't register driver!\n", driver_name); + return ret; + } + + dev_count = 0; + + if (ircc_fir > 0 && ircc_sir > 0) { IRDA_MESSAGE(" Overriding FIR address 0x%04x\n", ircc_fir); IRDA_MESSAGE(" Overriding SIR address 0x%04x\n", ircc_sir); - if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq) == 0) - return 0; - - return -ENODEV; - } + if (smsc_ircc_open(ircc_fir, ircc_sir, ircc_dma, ircc_irq)) + ret = -ENODEV; + } else { + ret = -ENODEV; + + /* try user provided configuration register base address */ + if (ircc_cfg > 0) { + IRDA_MESSAGE(" Overriding configuration address " + "0x%04x\n", ircc_cfg); + if (!smsc_superio_fdc(ircc_cfg)) + ret = 0; + if (!smsc_superio_lpc(ircc_cfg)) + ret = 0; + } - /* try user provided configuration register base address */ - if (ircc_cfg>0) { - IRDA_MESSAGE(" Overriding configuration address 0x%04x\n", - ircc_cfg); - if (!smsc_superio_fdc(ircc_cfg)) - ret = 0; - if (!smsc_superio_lpc(ircc_cfg)) + if (smsc_ircc_look_for_chips() > 0) ret = 0; } - - if(smsc_ircc_look_for_chips()>0) ret = 0; - + + if (ret) + driver_unregister(&smsc_ircc_driver); + return ret; } @@ -369,15 +393,15 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u struct smsc_ircc_cb *self; struct net_device *dev; int err; - + IRDA_DEBUG(1, "%s\n", __FUNCTION__); err = smsc_ircc_present(fir_base, sir_base); - if(err) + if (err) goto err_out; - + err = -ENOMEM; - if (dev_count > DIM(dev_self)) { + if (dev_count >= ARRAY_SIZE(dev_self)) { IRDA_WARNING("%s(), too many devices!\n", __FUNCTION__); goto err_out1; } @@ -396,14 +420,14 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u dev->hard_start_xmit = smsc_ircc_hard_xmit_sir; #if SMSC_IRCC2_C_NET_TIMEOUT dev->tx_timeout = smsc_ircc_timeout; - dev->watchdog_timeo = HZ*2; /* Allow enough time for speed change */ + dev->watchdog_timeo = HZ * 2; /* Allow enough time for speed change */ #endif dev->open = smsc_ircc_net_open; dev->stop = smsc_ircc_net_close; dev->do_ioctl = smsc_ircc_net_ioctl; dev->get_stats = smsc_ircc_net_get_stats; - - self = dev->priv; + + self = netdev_priv(dev); self->netdev = dev; /* Make ifconfig display some details */ @@ -411,10 +435,10 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u dev->irq = self->io.irq = irq; /* Need to store self somewhere */ - dev_self[dev_count++] = self; + dev_self[dev_count] = self; spin_lock_init(&self->lock); - self->rx_buff.truesize = SMSC_IRCC2_RX_BUFF_TRUESIZE; + self->rx_buff.truesize = SMSC_IRCC2_RX_BUFF_TRUESIZE; self->tx_buff.truesize = SMSC_IRCC2_TX_BUFF_TRUESIZE; self->rx_buff.head = @@ -442,33 +466,40 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u self->rx_buff.state = OUTSIDE_FRAME; self->tx_buff.data = self->tx_buff.head; self->rx_buff.data = self->rx_buff.head; - - smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq); + smsc_ircc_setup_io(self, fir_base, sir_base, dma, irq); smsc_ircc_setup_qos(self); - smsc_ircc_init_chip(self); - - if(ircc_transceiver > 0 && - ircc_transceiver < SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS) + + if (ircc_transceiver > 0 && + ircc_transceiver < SMSC_IRCC2_C_NUMBER_OF_TRANSCEIVERS) self->transceiver = ircc_transceiver; else smsc_ircc_probe_transceiver(self); err = register_netdev(self->netdev); - if(err) { + if (err) { IRDA_ERROR("%s, Network device registration failed!\n", driver_name); goto err_out4; } - self->pmdev = pm_register(PM_SYS_DEV, PM_SYS_IRDA, smsc_ircc_pmproc); - if (self->pmdev) - self->pmdev->data = self; + self->pldev = platform_device_register_simple(SMSC_IRCC2_DRIVER_NAME, + dev_count, NULL, 0); + if (IS_ERR(self->pldev)) { + err = PTR_ERR(self->pldev); + goto err_out5; + } + dev_set_drvdata(&self->pldev->dev, self); IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name); + dev_count++; return 0; + + err_out5: + unregister_netdev(self->netdev); + err_out4: dma_free_coherent(NULL, self->tx_buff.truesize, self->tx_buff.head, self->tx_buff_dma); @@ -477,7 +508,7 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u self->rx_buff.head, self->rx_buff_dma); err_out2: free_netdev(self->netdev); - dev_self[--dev_count] = NULL; + dev_self[dev_count] = NULL; err_out1: release_region(fir_base, SMSC_IRCC2_FIR_CHIP_IO_EXTENT); release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT); @@ -511,16 +542,16 @@ static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base) register_bank(fir_base, 3); - high = inb(fir_base+IRCC_ID_HIGH); - low = inb(fir_base+IRCC_ID_LOW); - chip = inb(fir_base+IRCC_CHIP_ID); - version = inb(fir_base+IRCC_VERSION); - config = inb(fir_base+IRCC_INTERFACE); + high = inb(fir_base + IRCC_ID_HIGH); + low = inb(fir_base + IRCC_ID_LOW); + chip = inb(fir_base + IRCC_CHIP_ID); + version = inb(fir_base + IRCC_VERSION); + config = inb(fir_base + IRCC_INTERFACE); dma = config & IRCC_INTERFACE_DMA_MASK; irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4; - if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) { - IRDA_WARNING("%s(), addr 0x%04x - no device found!\n", + if (high != 0x10 || low != 0xb8 || (chip != 0xf1 && chip != 0xf2)) { + IRDA_WARNING("%s(), addr 0x%04x - no device found!\n", __FUNCTION__, fir_base); goto out3; } @@ -529,6 +560,7 @@ static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base) chip & 0x0f, version, fir_base, sir_base, dma, irq); return 0; + out3: release_region(sir_base, SMSC_IRCC2_SIR_CHIP_IO_EXTENT); out2: @@ -543,16 +575,16 @@ static int smsc_ircc_present(unsigned int fir_base, unsigned int sir_base) * Setup I/O * */ -static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, - unsigned int fir_base, unsigned int sir_base, +static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, + unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq) { unsigned char config, chip_dma, chip_irq; register_bank(fir_base, 3); - config = inb(fir_base+IRCC_INTERFACE); - chip_dma = config & IRCC_INTERFACE_DMA_MASK; - chip_irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4; + config = inb(fir_base + IRCC_INTERFACE); + chip_dma = config & IRCC_INTERFACE_DMA_MASK; + chip_irq = (config & IRCC_INTERFACE_IRQ_MASK) >> 4; self->io.fir_base = fir_base; self->io.sir_base = sir_base; @@ -566,17 +598,15 @@ static void smsc_ircc_setup_io(struct smsc_ircc_cb *self, IRDA_MESSAGE("%s, Overriding IRQ - chip says %d, using %d\n", driver_name, chip_irq, irq); self->io.irq = irq; - } - else + } else self->io.irq = chip_irq; - + if (dma < 255) { if (dma != chip_dma) IRDA_MESSAGE("%s, Overriding DMA - chip says %d, using %d\n", driver_name, chip_dma, dma); self->io.dma = dma; - } - else + } else self->io.dma = chip_dma; } @@ -591,7 +621,7 @@ static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self) { /* Initialize QoS for this device */ irda_init_max_qos_capabilies(&self->qos); - + self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600| IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8); @@ -608,43 +638,43 @@ static void smsc_ircc_setup_qos(struct smsc_ircc_cb *self) */ static void smsc_ircc_init_chip(struct smsc_ircc_cb *self) { - int iobase, ir_mode, ctrl, fast; - - IRDA_ASSERT( self != NULL, return; ); - iobase = self->io.fir_base; + int iobase, ir_mode, ctrl, fast; + + IRDA_ASSERT(self != NULL, return;); + iobase = self->io.fir_base; ir_mode = IRCC_CFGA_IRDA_SIR_A; ctrl = 0; fast = 0; register_bank(iobase, 0); - outb(IRCC_MASTER_RESET, iobase+IRCC_MASTER); - outb(0x00, iobase+IRCC_MASTER); + outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER); + outb(0x00, iobase + IRCC_MASTER); register_bank(iobase, 1); - outb(((inb(iobase+IRCC_SCE_CFGA) & 0x87) | ir_mode), - iobase+IRCC_SCE_CFGA); + outb(((inb(iobase + IRCC_SCE_CFGA) & 0x87) | ir_mode), + iobase + IRCC_SCE_CFGA); #ifdef smsc_669 /* Uses pin 88/89 for Rx/Tx */ - outb(((inb(iobase+IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM), - iobase+IRCC_SCE_CFGB); -#else - outb(((inb(iobase+IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR), - iobase+IRCC_SCE_CFGB); -#endif - (void) inb(iobase+IRCC_FIFO_THRESHOLD); - outb(SMSC_IRCC2_FIFO_THRESHOLD, iobase+IRCC_FIFO_THRESHOLD); - + outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM), + iobase + IRCC_SCE_CFGB); +#else + outb(((inb(iobase + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR), + iobase + IRCC_SCE_CFGB); +#endif + (void) inb(iobase + IRCC_FIFO_THRESHOLD); + outb(SMSC_IRCC2_FIFO_THRESHOLD, iobase + IRCC_FIFO_THRESHOLD); + register_bank(iobase, 4); - outb((inb(iobase+IRCC_CONTROL) & 0x30) | ctrl, iobase+IRCC_CONTROL); - + outb((inb(iobase + IRCC_CONTROL) & 0x30) | ctrl, iobase + IRCC_CONTROL); + register_bank(iobase, 0); - outb(fast, iobase+IRCC_LCR_A); + outb(fast, iobase + IRCC_LCR_A); smsc_ircc_set_sir_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED); - + /* Power on device */ - outb(0x00, iobase+IRCC_MASTER); + outb(0x00, iobase + IRCC_MASTER); } /* @@ -662,12 +692,12 @@ static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd IRDA_ASSERT(dev != NULL, return -1;); - self = dev->priv; + self = netdev_priv(dev); IRDA_ASSERT(self != NULL, return -1;); IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__, dev->name, cmd); - + switch (cmd) { case SIOCSBANDWIDTH: /* Set bandwidth */ if (!capable(CAP_NET_ADMIN)) @@ -703,14 +733,14 @@ static int smsc_ircc_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd default: ret = -EOPNOTSUPP; } - + return ret; } static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev) { - struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) dev->priv; - + struct smsc_ircc_cb *self = netdev_priv(dev); + return &self->stats; } @@ -724,11 +754,9 @@ static struct net_device_stats *smsc_ircc_net_get_stats(struct net_device *dev) static void smsc_ircc_timeout(struct net_device *dev) { - struct smsc_ircc_cb *self; + struct smsc_ircc_cb *self = netdev_priv(dev); unsigned long flags; - self = (struct smsc_ircc_cb *) dev->priv; - IRDA_WARNING("%s: transmit timed out, changing speed to: %d\n", dev->name, self->io.speed); spin_lock_irqsave(&self->lock, flags); @@ -751,26 +779,23 @@ int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev) { struct smsc_ircc_cb *self; unsigned long flags; - int iobase; s32 speed; IRDA_DEBUG(1, "%s\n", __FUNCTION__); IRDA_ASSERT(dev != NULL, return 0;); - - self = (struct smsc_ircc_cb *) dev->priv; - IRDA_ASSERT(self != NULL, return 0;); - iobase = self->io.sir_base; + self = netdev_priv(dev); + IRDA_ASSERT(self != NULL, return 0;); netif_stop_queue(dev); - + /* Make sure test of self->io.speed & speed change are atomic */ spin_lock_irqsave(&self->lock, flags); /* Check if we need to change the speed */ speed = irda_get_next_speed(skb); - if ((speed != self->io.speed) && (speed != -1)) { + if (speed != self->io.speed && speed != -1) { /* Check for empty frame */ if (!skb->len) { /* @@ -787,27 +812,26 @@ int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev) spin_unlock_irqrestore(&self->lock, flags); dev_kfree_skb(skb); return 0; - } else { - self->new_speed = speed; } + self->new_speed = speed; } /* Init tx buffer */ self->tx_buff.data = self->tx_buff.head; /* Copy skb to tx_buff while wrapping, stuffing and making CRC */ - self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data, + self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data, self->tx_buff.truesize); - + self->stats.tx_bytes += self->tx_buff.len; /* Turn on transmit finished interrupt. Will fire immediately! */ - outb(UART_IER_THRI, iobase+UART_IER); + outb(UART_IER_THRI, self->io.sir_base + UART_IER); spin_unlock_irqrestore(&self->lock, flags); dev_kfree_skb(skb); - + return 0; } @@ -826,9 +850,9 @@ static void smsc_ircc_set_fir_speed(struct smsc_ircc_cb *self, u32 speed) self->io.speed = speed; - switch(speed) { + switch (speed) { default: - case 576000: + case 576000: ir_mode = IRCC_CFGA_IRDA_HDLC; ctrl = IRCC_CRC; fast = 0; @@ -853,14 +877,14 @@ static void smsc_ircc_set_fir_speed(struct smsc_ircc_cb *self, u32 speed) Now in tranceiver! /* This causes an interrupt */ register_bank(fir_base, 0); - outb((inb(fir_base+IRCC_LCR_A) & 0xbf) | fast, fir_base+IRCC_LCR_A); + outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast, fir_base + IRCC_LCR_A); #endif - + register_bank(fir_base, 1); - outb(((inb(fir_base+IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | ir_mode), fir_base+IRCC_SCE_CFGA); - + outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | ir_mode), fir_base + IRCC_SCE_CFGA); + register_bank(fir_base, 4); - outb((inb(fir_base+IRCC_CONTROL) & 0x30) | ctrl, fir_base+IRCC_CONTROL); + outb((inb(fir_base + IRCC_CONTROL) & 0x30) | ctrl, fir_base + IRCC_CONTROL); } /* @@ -885,31 +909,31 @@ static void smsc_ircc_fir_start(struct smsc_ircc_cb *self) /* Reset everything */ /* Install FIR transmit handler */ - dev->hard_start_xmit = smsc_ircc_hard_xmit_fir; + dev->hard_start_xmit = smsc_ircc_hard_xmit_fir; /* Clear FIFO */ - outb(inb(fir_base+IRCC_LCR_A)|IRCC_LCR_A_FIFO_RESET, fir_base+IRCC_LCR_A); + outb(inb(fir_base + IRCC_LCR_A) | IRCC_LCR_A_FIFO_RESET, fir_base + IRCC_LCR_A); /* Enable interrupt */ - /*outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, fir_base+IRCC_IER);*/ + /*outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, fir_base + IRCC_IER);*/ register_bank(fir_base, 1); - /* Select the TX/RX interface */ + /* Select the TX/RX interface */ #ifdef SMSC_669 /* Uses pin 88/89 for Rx/Tx */ - outb(((inb(fir_base+IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM), - fir_base+IRCC_SCE_CFGB); -#else - outb(((inb(fir_base+IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR), - fir_base+IRCC_SCE_CFGB); -#endif - (void) inb(fir_base+IRCC_FIFO_THRESHOLD); + outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_COM), + fir_base + IRCC_SCE_CFGB); +#else + outb(((inb(fir_base + IRCC_SCE_CFGB) & 0x3f) | IRCC_CFGB_MUX_IR), + fir_base + IRCC_SCE_CFGB); +#endif + (void) inb(fir_base + IRCC_FIFO_THRESHOLD); /* Enable SCE interrupts */ - outb(0, fir_base+IRCC_MASTER); + outb(0, fir_base + IRCC_MASTER); register_bank(fir_base, 0); - outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, fir_base+IRCC_IER); - outb(IRCC_MASTER_INT_EN, fir_base+IRCC_MASTER); + outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, fir_base + IRCC_IER); + outb(IRCC_MASTER_INT_EN, fir_base + IRCC_MASTER); } /* @@ -923,13 +947,13 @@ static void smsc_ircc_fir_stop(struct smsc_ircc_cb *self) int fir_base; IRDA_DEBUG(1, "%s\n", __FUNCTION__); - + IRDA_ASSERT(self != NULL, return;); fir_base = self->io.fir_base; register_bank(fir_base, 0); - /*outb(IRCC_MASTER_RESET, fir_base+IRCC_MASTER);*/ - outb(inb(fir_base+IRCC_LCR_B) & IRCC_LCR_B_SIP_ENABLE, fir_base+IRCC_LCR_B); + /*outb(IRCC_MASTER_RESET, fir_base + IRCC_MASTER);*/ + outb(inb(fir_base + IRCC_LCR_B) & IRCC_LCR_B_SIP_ENABLE, fir_base + IRCC_LCR_B); } @@ -941,18 +965,15 @@ static void smsc_ircc_fir_stop(struct smsc_ircc_cb *self) * This function *must* be called with spinlock held, because it may * be called from the irq handler. - Jean II */ -static void smsc_ircc_change_speed(void *priv, u32 speed) +static void smsc_ircc_change_speed(struct smsc_ircc_cb *self, u32 speed) { - struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) priv; struct net_device *dev; - int iobase; int last_speed_was_sir; - + IRDA_DEBUG(0, "%s() changing speed to: %d\n", __FUNCTION__, speed); IRDA_ASSERT(self != NULL, return;); dev = self->netdev; - iobase = self->io.fir_base; last_speed_was_sir = self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED; @@ -961,30 +982,30 @@ static void smsc_ircc_change_speed(void *priv, u32 speed) speed= 1152000; self->io.speed = speed; last_speed_was_sir = 0; - smsc_ircc_fir_start(self); + smsc_ircc_fir_start(self); #endif - - if(self->io.speed == 0) + + if (self->io.speed == 0) smsc_ircc_sir_start(self); #if 0 - if(!last_speed_was_sir) speed = self->io.speed; + if (!last_speed_was_sir) speed = self->io.speed; #endif - if(self->io.speed != speed) smsc_ircc_set_transceiver_for_speed(self, speed); + if (self->io.speed != speed) + smsc_ircc_set_transceiver_for_speed(self, speed); self->io.speed = speed; - - if(speed <= SMSC_IRCC2_MAX_SIR_SPEED) { - if(!last_speed_was_sir) { + + if (speed <= SMSC_IRCC2_MAX_SIR_SPEED) { + if (!last_speed_was_sir) { smsc_ircc_fir_stop(self); smsc_ircc_sir_start(self); } - smsc_ircc_set_sir_speed(self, speed); - } - else { - if(last_speed_was_sir) { - #if SMSC_IRCC2_C_SIR_STOP + smsc_ircc_set_sir_speed(self, speed); + } else { + if (last_speed_was_sir) { + #if SMSC_IRCC2_C_SIR_STOP smsc_ircc_sir_stop(self); #endif smsc_ircc_fir_start(self); @@ -994,13 +1015,13 @@ static void smsc_ircc_change_speed(void *priv, u32 speed) #if 0 self->tx_buff.len = 10; self->tx_buff.data = self->tx_buff.head; - - smsc_ircc_dma_xmit(self, iobase, 4000); + + smsc_ircc_dma_xmit(self, 4000); #endif /* Be ready for incoming frames */ - smsc_ircc_dma_receive(self, iobase); + smsc_ircc_dma_receive(self); } - + netif_wake_queue(dev); } @@ -1010,10 +1031,9 @@ static void smsc_ircc_change_speed(void *priv, u32 speed) * Set speed of IrDA port to specified baudrate * */ -void smsc_ircc_set_sir_speed(void *priv, __u32 speed) +void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, __u32 speed) { - struct smsc_ircc_cb *self = (struct smsc_ircc_cb *) priv; - int iobase; + int iobase; int fcr; /* FIFO control reg */ int lcr; /* Line control reg */ int divisor; @@ -1022,38 +1042,36 @@ void smsc_ircc_set_sir_speed(void *priv, __u32 speed) IRDA_ASSERT(self != NULL, return;); iobase = self->io.sir_base; - + /* Update accounting for new speed */ self->io.speed = speed; /* Turn off interrupts */ - outb(0, iobase+UART_IER); + outb(0, iobase + UART_IER); + + divisor = SMSC_IRCC2_MAX_SIR_SPEED / speed; - divisor = SMSC_IRCC2_MAX_SIR_SPEED/speed; - fcr = UART_FCR_ENABLE_FIFO; - /* + /* * Use trigger level 1 to avoid 3 ms. timeout delay at 9600 bps, and * almost 1,7 ms at 19200 bps. At speeds above that we can just forget - * about this timeout since it will always be fast enough. + * about this timeout since it will always be fast enough. */ - if (self->io.speed < 38400) - fcr |= UART_FCR_TRIGGER_1; - else - fcr |= UART_FCR_TRIGGER_14; - + fcr |= self->io.speed < 38400 ? + UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14; + /* IrDA ports use 8N1 */ lcr = UART_LCR_WLEN8; - - outb(UART_LCR_DLAB | lcr, iobase+UART_LCR); /* Set DLAB */ - outb(divisor & 0xff, iobase+UART_DLL); /* Set speed */ - outb(divisor >> 8, iobase+UART_DLM); - outb(lcr, iobase+UART_LCR); /* Set 8N1 */ - outb(fcr, iobase+UART_FCR); /* Enable FIFO's */ + + outb(UART_LCR_DLAB | lcr, iobase + UART_LCR); /* Set DLAB */ + outb(divisor & 0xff, iobase + UART_DLL); /* Set speed */ + outb(divisor >> 8, iobase + UART_DLM); + outb(lcr, iobase + UART_LCR); /* Set 8N1 */ + outb(fcr, iobase + UART_FCR); /* Enable FIFO's */ /* Turn on interrups */ - outb(UART_IER_RLSI|UART_IER_RDI|UART_IER_THRI, iobase+UART_IER); + outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER); IRDA_DEBUG(2, "%s() speed changed to: %d\n", __FUNCTION__, speed); } @@ -1070,15 +1088,12 @@ static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) struct smsc_ircc_cb *self; unsigned long flags; s32 speed; - int iobase; int mtt; IRDA_ASSERT(dev != NULL, return 0;); - self = (struct smsc_ircc_cb *) dev->priv; + self = netdev_priv(dev); IRDA_ASSERT(self != NULL, return 0;); - iobase = self->io.fir_base; - netif_stop_queue(dev); /* Make sure test of self->io.speed & speed change are atomic */ @@ -1086,30 +1101,31 @@ static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) /* Check if we need to change the speed after this frame */ speed = irda_get_next_speed(skb); - if ((speed != self->io.speed) && (speed != -1)) { + if (speed != self->io.speed && speed != -1) { /* Check for empty frame */ if (!skb->len) { /* Note : you should make sure that speed changes * are not going to corrupt any outgoing frame. * Look at nsc-ircc for the gory details - Jean II */ - smsc_ircc_change_speed(self, speed); + smsc_ircc_change_speed(self, speed); spin_unlock_irqrestore(&self->lock, flags); dev_kfree_skb(skb); return 0; - } else - self->new_speed = speed; + } + + self->new_speed = speed; } - + memcpy(self->tx_buff.head, skb->data, skb->len); self->tx_buff.len = skb->len; self->tx_buff.data = self->tx_buff.head; - - mtt = irda_get_mtt(skb); + + mtt = irda_get_mtt(skb); if (mtt) { int bofs; - /* + /* * Compute how many BOFs (STA or PA's) we need to waste the * min turn time given the speed of the link. */ @@ -1117,11 +1133,12 @@ static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) if (bofs > 4095) bofs = 4095; - smsc_ircc_dma_xmit(self, iobase, bofs); + smsc_ircc_dma_xmit(self, bofs); } else { /* Transmit frame */ - smsc_ircc_dma_xmit(self, iobase, 0); + smsc_ircc_dma_xmit(self, 0); } + spin_unlock_irqrestore(&self->lock, flags); dev_kfree_skb(skb); @@ -1129,43 +1146,44 @@ static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) } /* - * Function smsc_ircc_dma_xmit (self, iobase) + * Function smsc_ircc_dma_xmit (self, bofs) * * Transmit data using DMA * */ -static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int iobase, int bofs) +static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int bofs) { + int iobase = self->io.fir_base; u8 ctrl; IRDA_DEBUG(3, "%s\n", __FUNCTION__); #if 1 /* Disable Rx */ register_bank(iobase, 0); - outb(0x00, iobase+IRCC_LCR_B); + outb(0x00, iobase + IRCC_LCR_B); #endif register_bank(iobase, 1); - outb(inb(iobase+IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE, - iobase+IRCC_SCE_CFGB); + outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE, + iobase + IRCC_SCE_CFGB); self->io.direction = IO_XMIT; /* Set BOF additional count for generating the min turn time */ register_bank(iobase, 4); - outb(bofs & 0xff, iobase+IRCC_BOF_COUNT_LO); - ctrl = inb(iobase+IRCC_CONTROL) & 0xf0; - outb(ctrl | ((bofs >> 8) & 0x0f), iobase+IRCC_BOF_COUNT_HI); + outb(bofs & 0xff, iobase + IRCC_BOF_COUNT_LO); + ctrl = inb(iobase + IRCC_CONTROL) & 0xf0; + outb(ctrl | ((bofs >> 8) & 0x0f), iobase + IRCC_BOF_COUNT_HI); /* Set max Tx frame size */ - outb(self->tx_buff.len >> 8, iobase+IRCC_TX_SIZE_HI); - outb(self->tx_buff.len & 0xff, iobase+IRCC_TX_SIZE_LO); + outb(self->tx_buff.len >> 8, iobase + IRCC_TX_SIZE_HI); + outb(self->tx_buff.len & 0xff, iobase + IRCC_TX_SIZE_LO); /*outb(UART_MCR_OUT2, self->io.sir_base + UART_MCR);*/ - + /* Enable burst mode chip Tx DMA */ register_bank(iobase, 1); - outb(inb(iobase+IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE | - IRCC_CFGB_DMA_BURST, iobase+IRCC_SCE_CFGB); + outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE | + IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB); /* Setup DMA controller (must be done after enabling chip DMA) */ irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len, @@ -1174,50 +1192,52 @@ static void smsc_ircc_dma_xmit(struct smsc_ircc_cb *self, int iobase, int bofs) /* Enable interrupt */ register_bank(iobase, 0); - outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase+IRCC_IER); - outb(IRCC_MASTER_INT_EN, iobase+IRCC_MASTER); - + outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER); + outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER); + /* Enable transmit */ - outb(IRCC_LCR_B_SCE_TRANSMIT | IRCC_LCR_B_SIP_ENABLE, iobase+IRCC_LCR_B); + outb(IRCC_LCR_B_SCE_TRANSMIT | IRCC_LCR_B_SIP_ENABLE, iobase + IRCC_LCR_B); } /* * Function smsc_ircc_dma_xmit_complete (self) * - * The transfer of a frame in finished. This function will only be called + * The transfer of a frame in finished. This function will only be called * by the interrupt handler * */ -static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self, int iobase) +static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self) { + int iobase = self->io.fir_base; + IRDA_DEBUG(3, "%s\n", __FUNCTION__); #if 0 /* Disable Tx */ register_bank(iobase, 0); - outb(0x00, iobase+IRCC_LCR_B); + outb(0x00, iobase + IRCC_LCR_B); #endif - register_bank(self->io.fir_base, 1); - outb(inb(self->io.fir_base+IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE, - self->io.fir_base+IRCC_SCE_CFGB); + register_bank(iobase, 1); + outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE, + iobase + IRCC_SCE_CFGB); /* Check for underrun! */ register_bank(iobase, 0); - if (inb(iobase+IRCC_LSR) & IRCC_LSR_UNDERRUN) { + if (inb(iobase + IRCC_LSR) & IRCC_LSR_UNDERRUN) { self->stats.tx_errors++; self->stats.tx_fifo_errors++; /* Reset error condition */ register_bank(iobase, 0); - outb(IRCC_MASTER_ERROR_RESET, iobase+IRCC_MASTER); - outb(0x00, iobase+IRCC_MASTER); + outb(IRCC_MASTER_ERROR_RESET, iobase + IRCC_MASTER); + outb(0x00, iobase + IRCC_MASTER); } else { self->stats.tx_packets++; - self->stats.tx_bytes += self->tx_buff.len; + self->stats.tx_bytes += self->tx_buff.len; } /* Check if it's time to change the speed */ if (self->new_speed) { - smsc_ircc_change_speed(self, self->new_speed); + smsc_ircc_change_speed(self, self->new_speed); self->new_speed = 0; } @@ -1231,31 +1251,32 @@ static void smsc_ircc_dma_xmit_complete(struct smsc_ircc_cb *self, int iobase) * if it starts to receive a frame. * */ -static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self, int iobase) +static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self) { + int iobase = self->io.fir_base; #if 0 /* Turn off chip DMA */ register_bank(iobase, 1); - outb(inb(iobase+IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE, - iobase+IRCC_SCE_CFGB); + outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE, + iobase + IRCC_SCE_CFGB); #endif - + /* Disable Tx */ register_bank(iobase, 0); - outb(0x00, iobase+IRCC_LCR_B); + outb(0x00, iobase + IRCC_LCR_B); /* Turn off chip DMA */ register_bank(iobase, 1); - outb(inb(iobase+IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE, - iobase+IRCC_SCE_CFGB); + outb(inb(iobase + IRCC_SCE_CFGB) & ~IRCC_CFGB_DMA_ENABLE, + iobase + IRCC_SCE_CFGB); self->io.direction = IO_RECV; self->rx_buff.data = self->rx_buff.head; /* Set max Rx frame size */ register_bank(iobase, 4); - outb((2050 >> 8) & 0x0f, iobase+IRCC_RX_SIZE_HI); - outb(2050 & 0xff, iobase+IRCC_RX_SIZE_LO); + outb((2050 >> 8) & 0x0f, iobase + IRCC_RX_SIZE_HI); + outb(2050 & 0xff, iobase + IRCC_RX_SIZE_LO); /* Setup DMA controller */ irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize, @@ -1263,83 +1284,83 @@ static int smsc_ircc_dma_receive(struct smsc_ircc_cb *self, int iobase) /* Enable burst mode chip Rx DMA */ register_bank(iobase, 1); - outb(inb(iobase+IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE | - IRCC_CFGB_DMA_BURST, iobase+IRCC_SCE_CFGB); + outb(inb(iobase + IRCC_SCE_CFGB) | IRCC_CFGB_DMA_ENABLE | + IRCC_CFGB_DMA_BURST, iobase + IRCC_SCE_CFGB); /* Enable interrupt */ register_bank(iobase, 0); - outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase+IRCC_IER); - outb(IRCC_MASTER_INT_EN, iobase+IRCC_MASTER); - + outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER); + outb(IRCC_MASTER_INT_EN, iobase + IRCC_MASTER); /* Enable receiver */ register_bank(iobase, 0); - outb(IRCC_LCR_B_SCE_RECEIVE | IRCC_LCR_B_SIP_ENABLE, - iobase+IRCC_LCR_B); - + outb(IRCC_LCR_B_SCE_RECEIVE | IRCC_LCR_B_SIP_ENABLE, + iobase + IRCC_LCR_B); + return 0; } /* - * Function smsc_ircc_dma_receive_complete(self, iobase) + * Function smsc_ircc_dma_receive_complete(self) * * Finished with receiving frames * */ -static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self, int iobase) +static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self) { struct sk_buff *skb; int len, msgcnt, lsr; - + int iobase = self->io.fir_base; + register_bank(iobase, 0); - + IRDA_DEBUG(3, "%s\n", __FUNCTION__); #if 0 /* Disable Rx */ register_bank(iobase, 0); - outb(0x00, iobase+IRCC_LCR_B); + outb(0x00, iobase + IRCC_LCR_B); #endif register_bank(iobase, 0); - outb(inb(iobase+IRCC_LSAR) & ~IRCC_LSAR_ADDRESS_MASK, iobase+IRCC_LSAR); - lsr= inb(iobase+IRCC_LSR); - msgcnt = inb(iobase+IRCC_LCR_B) & 0x08; + outb(inb(iobase + IRCC_LSAR) & ~IRCC_LSAR_ADDRESS_MASK, iobase + IRCC_LSAR); + lsr= inb(iobase + IRCC_LSR); + msgcnt = inb(iobase + IRCC_LCR_B) & 0x08; IRDA_DEBUG(2, "%s: dma count = %d\n", __FUNCTION__, get_dma_residue(self->io.dma)); len = self->rx_buff.truesize - get_dma_residue(self->io.dma); - /* Look for errors - */ - - if(lsr & (IRCC_LSR_FRAME_ERROR | IRCC_LSR_CRC_ERROR | IRCC_LSR_SIZE_ERROR)) { + /* Look for errors */ + if (lsr & (IRCC_LSR_FRAME_ERROR | IRCC_LSR_CRC_ERROR | IRCC_LSR_SIZE_ERROR)) { self->stats.rx_errors++; - if(lsr & IRCC_LSR_FRAME_ERROR) self->stats.rx_frame_errors++; - if(lsr & IRCC_LSR_CRC_ERROR) self->stats.rx_crc_errors++; - if(lsr & IRCC_LSR_SIZE_ERROR) self->stats.rx_length_errors++; - if(lsr & (IRCC_LSR_UNDERRUN | IRCC_LSR_OVERRUN)) self->stats.rx_length_errors++; + if (lsr & IRCC_LSR_FRAME_ERROR) + self->stats.rx_frame_errors++; + if (lsr & IRCC_LSR_CRC_ERROR) + self->stats.rx_crc_errors++; + if (lsr & IRCC_LSR_SIZE_ERROR) + self->stats.rx_length_errors++; + if (lsr & (IRCC_LSR_UNDERRUN | IRCC_LSR_OVERRUN)) + self->stats.rx_length_errors++; return; } + /* Remove CRC */ - if (self->io.speed < 4000000) - len -= 2; - else - len -= 4; + len -= self->io.speed < 4000000 ? 2 : 4; - if ((len < 2) || (len > 2050)) { + if (len < 2 || len > 2050) { IRDA_WARNING("%s(), bogus len=%d\n", __FUNCTION__, len); return; } IRDA_DEBUG(2, "%s: msgcnt = %d, len=%d\n", __FUNCTION__, msgcnt, len); - skb = dev_alloc_skb(len+1); - if (!skb) { + skb = dev_alloc_skb(len + 1); + if (!skb) { IRDA_WARNING("%s(), memory squeeze, dropping frame.\n", __FUNCTION__); return; - } + } /* Make sure IP header gets aligned */ - skb_reserve(skb, 1); + skb_reserve(skb, 1); memcpy(skb_put(skb, len), self->rx_buff.data, len); self->stats.rx_packets++; @@ -1357,7 +1378,7 @@ static void smsc_ircc_dma_receive_complete(struct smsc_ircc_cb *self, int iobase * Receive one frame from the infrared port * */ -static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self) +static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self) { int boguscount = 0; int iobase; @@ -1366,20 +1387,20 @@ static void smsc_ircc_sir_receive(struct smsc_ircc_cb *self) iobase = self->io.sir_base; - /* - * Receive all characters in Rx FIFO, unwrap and unstuff them. - * async_unwrap_char will deliver all found frames + /* + * Receive all characters in Rx FIFO, unwrap and unstuff them. + * async_unwrap_char will deliver all found frames */ do { - async_unwrap_char(self->netdev, &self->stats, &self->rx_buff, - inb(iobase+UART_RX)); + async_unwrap_char(self->netdev, &self->stats, &self->rx_buff, + inb(iobase + UART_RX)); /* Make sure we don't stay here to long */ if (boguscount++ > 32) { IRDA_DEBUG(2, "%s(), breaking!\n", __FUNCTION__); break; } - } while (inb(iobase+UART_LSR) & UART_LSR_DR); + } while (inb(iobase + UART_LSR) & UART_LSR_DR); } @@ -1397,18 +1418,19 @@ static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *re irqreturn_t ret = IRQ_NONE; if (dev == NULL) { - printk(KERN_WARNING "%s: irq %d for unknown device.\n", + printk(KERN_WARNING "%s: irq %d for unknown device.\n", driver_name, irq); goto irq_ret; } - self = (struct smsc_ircc_cb *) dev->priv; + + self = netdev_priv(dev); IRDA_ASSERT(self != NULL, return IRQ_NONE;); /* Serialise the interrupt handler in various CPUs, stop Tx path */ - spin_lock(&self->lock); + spin_lock(&self->lock); /* Check if we should use the SIR interrupt handler */ - if (self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED) { + if (self->io.speed <= SMSC_IRCC2_MAX_SIR_SPEED) { ret = smsc_ircc_interrupt_sir(dev); goto irq_ret_unlock; } @@ -1416,25 +1438,25 @@ static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *re iobase = self->io.fir_base; register_bank(iobase, 0); - iir = inb(iobase+IRCC_IIR); - if (iir == 0) + iir = inb(iobase + IRCC_IIR); + if (iir == 0) goto irq_ret_unlock; ret = IRQ_HANDLED; /* Disable interrupts */ - outb(0, iobase+IRCC_IER); - lcra = inb(iobase+IRCC_LCR_A); - lsr = inb(iobase+IRCC_LSR); - + outb(0, iobase + IRCC_IER); + lcra = inb(iobase + IRCC_LCR_A); + lsr = inb(iobase + IRCC_LSR); + IRDA_DEBUG(2, "%s(), iir = 0x%02x\n", __FUNCTION__, iir); if (iir & IRCC_IIR_EOM) { if (self->io.direction == IO_RECV) - smsc_ircc_dma_receive_complete(self, iobase); + smsc_ircc_dma_receive_complete(self); else - smsc_ircc_dma_xmit_complete(self, iobase); - - smsc_ircc_dma_receive(self, iobase); + smsc_ircc_dma_xmit_complete(self); + + smsc_ircc_dma_receive(self); } if (iir & IRCC_IIR_ACTIVE_FRAME) { @@ -1444,7 +1466,7 @@ static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *re /* Enable interrupts again */ register_bank(iobase, 0); - outb(IRCC_IER_ACTIVE_FRAME|IRCC_IER_EOM, iobase+IRCC_IER); + outb(IRCC_IER_ACTIVE_FRAME | IRCC_IER_EOM, iobase + IRCC_IER); irq_ret_unlock: spin_unlock(&self->lock); @@ -1459,7 +1481,7 @@ static irqreturn_t smsc_ircc_interrupt(int irq, void *dev_id, struct pt_regs *re */ static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev) { - struct smsc_ircc_cb *self = dev->priv; + struct smsc_ircc_cb *self = netdev_priv(dev); int boguscount = 0; int iobase; int iir, lsr; @@ -1469,14 +1491,14 @@ static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev) iobase = self->io.sir_base; - iir = inb(iobase+UART_IIR) & UART_IIR_ID; + iir = inb(iobase + UART_IIR) & UART_IIR_ID; if (iir == 0) return IRQ_NONE; while (iir) { /* Clear interrupt */ - lsr = inb(iobase+UART_LSR); + lsr = inb(iobase + UART_LSR); - IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n", + IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n", __FUNCTION__, iir, lsr, iobase); switch (iir) { @@ -1496,13 +1518,13 @@ static irqreturn_t smsc_ircc_interrupt_sir(struct net_device *dev) IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n", __FUNCTION__, iir); break; - } - + } + /* Make sure we don't stay here to long */ if (boguscount++ > 100) break; - iir = inb(iobase + UART_IIR) & UART_IIR_ID; + iir = inb(iobase + UART_IIR) & UART_IIR_ID; } /*spin_unlock(&self->lock);*/ return IRQ_HANDLED; @@ -1529,7 +1551,7 @@ static int ircc_is_receiving(struct smsc_ircc_cb *self) get_dma_residue(self->io.dma)); status = (self->rx_buff.state != OUTSIDE_FRAME); - + return status; } #endif /* unused */ @@ -1544,19 +1566,16 @@ static int ircc_is_receiving(struct smsc_ircc_cb *self) static int smsc_ircc_net_open(struct net_device *dev) { struct smsc_ircc_cb *self; - int iobase; char hwname[16]; unsigned long flags; IRDA_DEBUG(1, "%s\n", __FUNCTION__); - + IRDA_ASSERT(dev != NULL, return -1;); - self = (struct smsc_ircc_cb *) dev->priv; + self = netdev_priv(dev); IRDA_ASSERT(self != NULL, return 0;); - - iobase = self->io.fir_base; - if (request_irq(self->io.irq, smsc_ircc_interrupt, 0, dev->name, + if (request_irq(self->io.irq, smsc_ircc_interrupt, 0, dev->name, (void *) dev)) { IRDA_DEBUG(0, "%s(), unable to allocate irq=%d\n", __FUNCTION__, self->io.irq); @@ -1568,14 +1587,14 @@ static int smsc_ircc_net_open(struct net_device *dev) self->io.speed = 0; smsc_ircc_change_speed(self, SMSC_IRCC2_C_IRDA_FALLBACK_SPEED); spin_unlock_irqrestore(&self->lock, flags); - + /* Give self a hardware name */ /* It would be cool to offer the chip revision here - Jean II */ sprintf(hwname, "SMSC @ 0x%03x", self->io.fir_base); - /* + /* * Open new IrLAP layer instance, now that everything should be - * initialized properly + * initialized properly */ self->irlap = irlap_open(dev, &self->qos, hwname); @@ -1590,7 +1609,7 @@ static int smsc_ircc_net_open(struct net_device *dev) __FUNCTION__, self->io.dma); return -EAGAIN; } - + netif_start_queue(dev); return 0; @@ -1605,73 +1624,53 @@ static int smsc_ircc_net_open(struct net_device *dev) static int smsc_ircc_net_close(struct net_device *dev) { struct smsc_ircc_cb *self; - int iobase; IRDA_DEBUG(1, "%s\n", __FUNCTION__); - + IRDA_ASSERT(dev != NULL, return -1;); - self = (struct smsc_ircc_cb *) dev->priv; + self = netdev_priv(dev); IRDA_ASSERT(self != NULL, return 0;); - - iobase = self->io.fir_base; /* Stop device */ netif_stop_queue(dev); - + /* Stop and remove instance of IrLAP */ if (self->irlap) irlap_close(self->irlap); self->irlap = NULL; free_irq(self->io.irq, dev); - disable_dma(self->io.dma); - free_dma(self->io.dma); return 0; } - -static void smsc_ircc_suspend(struct smsc_ircc_cb *self) +static int smsc_ircc_suspend(struct device *dev, pm_message_t state, u32 level) { - IRDA_MESSAGE("%s, Suspending\n", driver_name); + struct smsc_ircc_cb *self = dev_get_drvdata(dev); - if (self->io.suspended) - return; + IRDA_MESSAGE("%s, Suspending\n", driver_name); - smsc_ircc_net_close(self->netdev); + if (level == SUSPEND_DISABLE && !self->io.suspended) { + smsc_ircc_net_close(self->netdev); + self->io.suspended = 1; + } - self->io.suspended = 1; + return 0; } -static void smsc_ircc_wakeup(struct smsc_ircc_cb *self) +static int smsc_ircc_resume(struct device *dev, u32 level) { - if (!self->io.suspended) - return; + struct smsc_ircc_cb *self = dev_get_drvdata(dev); - /* The code was doing a "cli()" here, but this can't be right. - * If you need protection, do it in net_open with a spinlock - * or give a good reason. - Jean II */ + if (level == RESUME_ENABLE && self->io.suspended) { - smsc_ircc_net_open(self->netdev); - - IRDA_MESSAGE("%s, Waking up\n", driver_name); -} + smsc_ircc_net_open(self->netdev); + self->io.suspended = 0; -static int smsc_ircc_pmproc(struct pm_dev *dev, pm_request_t rqst, void *data) -{ - struct smsc_ircc_cb *self = (struct smsc_ircc_cb*) dev->data; - if (self) { - switch (rqst) { - case PM_SUSPEND: - smsc_ircc_suspend(self); - break; - case PM_RESUME: - smsc_ircc_wakeup(self); - break; - } - } + IRDA_MESSAGE("%s, Waking up\n", driver_name); + } return 0; } @@ -1690,10 +1689,7 @@ static int __exit smsc_ircc_close(struct smsc_ircc_cb *self) IRDA_ASSERT(self != NULL, return -1;); - iobase = self->io.fir_base; - - if (self->pmdev) - pm_unregister(self->pmdev); + platform_device_unregister(self->pldev); /* Remove netdevice */ unregister_netdev(self->netdev); @@ -1702,15 +1698,16 @@ static int __exit smsc_ircc_close(struct smsc_ircc_cb *self) spin_lock_irqsave(&self->lock, flags); /* Stop interrupts */ + iobase = self->io.fir_base; register_bank(iobase, 0); - outb(0, iobase+IRCC_IER); - outb(IRCC_MASTER_RESET, iobase+IRCC_MASTER); - outb(0x00, iobase+IRCC_MASTER); + outb(0, iobase + IRCC_IER); + outb(IRCC_MASTER_RESET, iobase + IRCC_MASTER); + outb(0x00, iobase + IRCC_MASTER); #if 0 /* Reset to SIR mode */ register_bank(iobase, 1); - outb(IRCC_CFGA_IRDA_SIR_A|IRCC_CFGA_TX_POLARITY, iobase+IRCC_SCE_CFGA); - outb(IRCC_CFGB_IR, iobase+IRCC_SCE_CFGB); + outb(IRCC_CFGA_IRDA_SIR_A|IRCC_CFGA_TX_POLARITY, iobase + IRCC_SCE_CFGA); + outb(IRCC_CFGB_IR, iobase + IRCC_SCE_CFGB); #endif spin_unlock_irqrestore(&self->lock, flags); @@ -1720,7 +1717,7 @@ static int __exit smsc_ircc_close(struct smsc_ircc_cb *self) release_region(self->io.fir_base, self->io.fir_ext); - IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__, + IRDA_DEBUG(0, "%s(), releasing 0x%03x\n", __FUNCTION__, self->io.sir_base); release_region(self->io.sir_base, self->io.sir_ext); @@ -1728,7 +1725,7 @@ static int __exit smsc_ircc_close(struct smsc_ircc_cb *self) if (self->tx_buff.head) dma_free_coherent(NULL, self->tx_buff.truesize, self->tx_buff.head, self->tx_buff_dma); - + if (self->rx_buff.head) dma_free_coherent(NULL, self->rx_buff.truesize, self->rx_buff.head, self->rx_buff_dma); @@ -1744,10 +1741,12 @@ static void __exit smsc_ircc_cleanup(void) IRDA_DEBUG(1, "%s\n", __FUNCTION__); - for (i=0; i < 2; i++) { + for (i = 0; i < 2; i++) { if (dev_self[i]) smsc_ircc_close(dev_self[i]); } + + driver_unregister(&smsc_ircc_driver); } /* @@ -1763,34 +1762,34 @@ void smsc_ircc_sir_start(struct smsc_ircc_cb *self) IRDA_DEBUG(3, "%s\n", __FUNCTION__); - IRDA_ASSERT(self != NULL, return;); - dev= self->netdev; - IRDA_ASSERT(dev != NULL, return;); + IRDA_ASSERT(self != NULL, return;); + dev = self->netdev; + IRDA_ASSERT(dev != NULL, return;); dev->hard_start_xmit = &smsc_ircc_hard_xmit_sir; fir_base = self->io.fir_base; sir_base = self->io.sir_base; /* Reset everything */ - outb(IRCC_MASTER_RESET, fir_base+IRCC_MASTER); + outb(IRCC_MASTER_RESET, fir_base + IRCC_MASTER); #if SMSC_IRCC2_C_SIR_STOP /*smsc_ircc_sir_stop(self);*/ #endif register_bank(fir_base, 1); - outb(((inb(fir_base+IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | IRCC_CFGA_IRDA_SIR_A), fir_base+IRCC_SCE_CFGA); + outb(((inb(fir_base + IRCC_SCE_CFGA) & IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK) | IRCC_CFGA_IRDA_SIR_A), fir_base + IRCC_SCE_CFGA); /* Initialize UART */ - outb(UART_LCR_WLEN8, sir_base+UART_LCR); /* Reset DLAB */ - outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), sir_base+UART_MCR); - + outb(UART_LCR_WLEN8, sir_base + UART_LCR); /* Reset DLAB */ + outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), sir_base + UART_MCR); + /* Turn on interrups */ - outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, sir_base+UART_IER); + outb(UART_IER_RLSI | UART_IER_RDI |UART_IER_THRI, sir_base + UART_IER); IRDA_DEBUG(3, "%s() - exit\n", __FUNCTION__); - outb(0x00, fir_base+IRCC_MASTER); + outb(0x00, fir_base + IRCC_MASTER); } #if SMSC_IRCC2_C_SIR_STOP @@ -1802,10 +1801,10 @@ void smsc_ircc_sir_stop(struct smsc_ircc_cb *self) iobase = self->io.sir_base; /* Reset UART */ - outb(0, iobase+UART_MCR); - + outb(0, iobase + UART_MCR); + /* Turn off interrupts */ - outb(0, iobase+UART_IER); + outb(0, iobase + UART_IER); } #endif @@ -1831,16 +1830,16 @@ static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self) /* Finished with frame? */ if (self->tx_buff.len > 0) { /* Write data left in transmit buffer */ - actual = smsc_ircc_sir_write(iobase, self->io.fifo_size, + actual = smsc_ircc_sir_write(iobase, self->io.fifo_size, self->tx_buff.data, self->tx_buff.len); self->tx_buff.data += actual; self->tx_buff.len -= actual; } else { - + /*if (self->tx_buff.len ==0) {*/ - - /* - * Now serial buffer is almost free & we can start + + /* + * Now serial buffer is almost free & we can start * transmission of another packet. But first we must check * if we need to change the speed of the hardware */ @@ -1856,21 +1855,19 @@ static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self) } self->stats.tx_packets++; - if(self->io.speed <= 115200) { - /* - * Reset Rx FIFO to make sure that all reflected transmit data - * is discarded. This is needed for half duplex operation - */ - fcr = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR; - if (self->io.speed < 38400) - fcr |= UART_FCR_TRIGGER_1; - else - fcr |= UART_FCR_TRIGGER_14; + if (self->io.speed <= 115200) { + /* + * Reset Rx FIFO to make sure that all reflected transmit data + * is discarded. This is needed for half duplex operation + */ + fcr = UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR; + fcr |= self->io.speed < 38400 ? + UART_FCR_TRIGGER_1 : UART_FCR_TRIGGER_14; - outb(fcr, iobase+UART_FCR); + outb(fcr, iobase + UART_FCR); - /* Turn on receive interrupts */ - outb(UART_IER_RDI, iobase+UART_IER); + /* Turn on receive interrupts */ + outb(UART_IER_RDI, iobase + UART_IER); } } } @@ -1884,17 +1881,17 @@ static void smsc_ircc_sir_write_wakeup(struct smsc_ircc_cb *self) static int smsc_ircc_sir_write(int iobase, int fifo_size, __u8 *buf, int len) { int actual = 0; - + /* Tx FIFO should be empty! */ - if (!(inb(iobase+UART_LSR) & UART_LSR_THRE)) { + if (!(inb(iobase + UART_LSR) & UART_LSR_THRE)) { IRDA_WARNING("%s(), failed, fifo not empty!\n", __FUNCTION__); return 0; } - + /* Fill FIFO with current frame */ - while ((fifo_size-- > 0) && (actual < len)) { + while (fifo_size-- > 0 && actual < len) { /* Transmit next byte */ - outb(buf[actual], iobase+UART_TX); + outb(buf[actual], iobase + UART_TX); actual++; } return actual; @@ -1921,20 +1918,21 @@ static int smsc_ircc_is_receiving(struct smsc_ircc_cb *self) static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self) { unsigned int i; - + IRDA_ASSERT(self != NULL, return;); - - for(i=0; smsc_transceivers[i].name!=NULL; i++) - if((*smsc_transceivers[i].probe)(self->io.fir_base)) { + + for (i = 0; smsc_transceivers[i].name != NULL; i++) + if (smsc_transceivers[i].probe(self->io.fir_base)) { IRDA_MESSAGE(" %s transceiver found\n", smsc_transceivers[i].name); - self->transceiver= i+1; + self->transceiver= i + 1; return; } + IRDA_MESSAGE("No transceiver found. Defaulting to %s\n", smsc_transceivers[SMSC_IRCC2_C_DEFAULT_TRANSCEIVER].name); - - self->transceiver= SMSC_IRCC2_C_DEFAULT_TRANSCEIVER; + + self->transceiver = SMSC_IRCC2_C_DEFAULT_TRANSCEIVER; } @@ -1947,9 +1945,10 @@ static void smsc_ircc_probe_transceiver(struct smsc_ircc_cb *self) static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 speed) { unsigned int trx; - + trx = self->transceiver; - if(trx>0) (*smsc_transceivers[trx-1].set_for_speed)(self->io.fir_base, speed); + if (trx > 0) + smsc_transceivers[trx - 1].set_for_speed(self->io.fir_base, speed); } /* @@ -1977,16 +1976,14 @@ static void smsc_ircc_set_transceiver_for_speed(struct smsc_ircc_cb *self, u32 s static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self) { - int iobase; + int iobase = self->io.sir_base; int count = SMSC_IRCC2_HW_TRANSMITTER_TIMEOUT_US; - - iobase = self->io.sir_base; - + /* Calibrated busy loop */ - while((count-- > 0) && !(inb(iobase+UART_LSR) & UART_LSR_TEMT)) + while (count-- > 0 && !(inb(iobase + UART_LSR) & UART_LSR_TEMT)) udelay(1); - if(count == 0) + if (count == 0) IRDA_DEBUG(0, "%s(): stuck transmitter\n", __FUNCTION__); } @@ -1998,40 +1995,42 @@ static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self) static int __init smsc_ircc_look_for_chips(void) { - smsc_chip_address_t *address; - char *type; + struct smsc_chip_address *address; + char *type; unsigned int cfg_base, found; - + found = 0; address = possible_addresses; - - while(address->cfg_base){ + + while (address->cfg_base) { cfg_base = address->cfg_base; - + /*printk(KERN_WARNING "%s(): probing: 0x%02x for: 0x%02x\n", __FUNCTION__, cfg_base, address->type);*/ - - if( address->type & SMSCSIO_TYPE_FDC){ + + if (address->type & SMSCSIO_TYPE_FDC) { type = "FDC"; - if((address->type) & SMSCSIO_TYPE_FLAT) { - if(!smsc_superio_flat(fdc_chips_flat,cfg_base, type)) found++; - } - if((address->type) & SMSCSIO_TYPE_PAGED) { - if(!smsc_superio_paged(fdc_chips_paged,cfg_base, type)) found++; - } + if (address->type & SMSCSIO_TYPE_FLAT) + if (!smsc_superio_flat(fdc_chips_flat, cfg_base, type)) + found++; + + if (address->type & SMSCSIO_TYPE_PAGED) + if (!smsc_superio_paged(fdc_chips_paged, cfg_base, type)) + found++; } - if( address->type & SMSCSIO_TYPE_LPC){ + if (address->type & SMSCSIO_TYPE_LPC) { type = "LPC"; - if((address->type) & SMSCSIO_TYPE_FLAT) { - if(!smsc_superio_flat(lpc_chips_flat,cfg_base,type)) found++; - } - if((address->type) & SMSCSIO_TYPE_PAGED) { - if(!smsc_superio_paged(lpc_chips_paged,cfg_base,"LPC")) found++; - } + if (address->type & SMSCSIO_TYPE_FLAT) + if (!smsc_superio_flat(lpc_chips_flat, cfg_base, type)) + found++; + + if (address->type & SMSCSIO_TYPE_PAGED) + if (!smsc_superio_paged(lpc_chips_paged, cfg_base, type)) + found++; } address++; } return found; -} +} /* * Function smsc_superio_flat (chip, base, type) @@ -2039,7 +2038,7 @@ static int __init smsc_ircc_look_for_chips(void) * Try to get configuration of a smc SuperIO chip with flat register model * */ -static int __init smsc_superio_flat(const smsc_chip_t *chips, unsigned short cfgbase, char *type) +static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfgbase, char *type) { unsigned short firbase, sirbase; u8 mode, dma, irq; @@ -2047,39 +2046,37 @@ static int __init smsc_superio_flat(const smsc_chip_t *chips, unsigned short cfg IRDA_DEBUG(1, "%s\n", __FUNCTION__); - if (smsc_ircc_probe(cfgbase, SMSCSIOFLAT_DEVICEID_REG, chips, type)==NULL) + if (smsc_ircc_probe(cfgbase, SMSCSIOFLAT_DEVICEID_REG, chips, type) == NULL) return ret; outb(SMSCSIOFLAT_UARTMODE0C_REG, cfgbase); - mode = inb(cfgbase+1); - + mode = inb(cfgbase + 1); + /*printk(KERN_WARNING "%s(): mode: 0x%02x\n", __FUNCTION__, mode);*/ - - if(!(mode & SMSCSIOFLAT_UART2MODE_VAL_IRDA)) + + if (!(mode & SMSCSIOFLAT_UART2MODE_VAL_IRDA)) IRDA_WARNING("%s(): IrDA not enabled\n", __FUNCTION__); outb(SMSCSIOFLAT_UART2BASEADDR_REG, cfgbase); - sirbase = inb(cfgbase+1) << 2; + sirbase = inb(cfgbase + 1) << 2; - /* FIR iobase */ + /* FIR iobase */ outb(SMSCSIOFLAT_FIRBASEADDR_REG, cfgbase); - firbase = inb(cfgbase+1) << 3; + firbase = inb(cfgbase + 1) << 3; /* DMA */ outb(SMSCSIOFLAT_FIRDMASELECT_REG, cfgbase); - dma = inb(cfgbase+1) & SMSCSIOFLAT_FIRDMASELECT_MASK; - + dma = inb(cfgbase + 1) & SMSCSIOFLAT_FIRDMASELECT_MASK; + /* IRQ */ outb(SMSCSIOFLAT_UARTIRQSELECT_REG, cfgbase); - irq = inb(cfgbase+1) & SMSCSIOFLAT_UART2IRQSELECT_MASK; + irq = inb(cfgbase + 1) & SMSCSIOFLAT_UART2IRQSELECT_MASK; IRDA_MESSAGE("%s(): fir: 0x%02x, sir: 0x%02x, dma: %02d, irq: %d, mode: 0x%02x\n", __FUNCTION__, firbase, sirbase, dma, irq, mode); - if (firbase) { - if (smsc_ircc_open(firbase, sirbase, dma, irq) == 0) - ret=0; - } - + if (firbase && smsc_ircc_open(firbase, sirbase, dma, irq) == 0) + ret = 0; + /* Exit configuration */ outb(SMSCSIO_CFGEXITKEY, cfgbase); @@ -2092,26 +2089,26 @@ static int __init smsc_superio_flat(const smsc_chip_t *chips, unsigned short cfg * Try to get configuration of a smc SuperIO chip with paged register model * */ -static int __init smsc_superio_paged(const smsc_chip_t *chips, unsigned short cfg_base, char *type) +static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type) { unsigned short fir_io, sir_io; int ret = -ENODEV; - + IRDA_DEBUG(1, "%s\n", __FUNCTION__); - if (smsc_ircc_probe(cfg_base,0x20,chips,type)==NULL) + if (smsc_ircc_probe(cfg_base, 0x20, chips, type) == NULL) return ret; - + /* Select logical device (UART2) */ outb(0x07, cfg_base); outb(0x05, cfg_base + 1); - + /* SIR iobase */ outb(0x60, cfg_base); - sir_io = inb(cfg_base + 1) << 8; + sir_io = inb(cfg_base + 1) << 8; outb(0x61, cfg_base); sir_io |= inb(cfg_base + 1); - + /* Read FIR base */ outb(0x62, cfg_base); fir_io = inb(cfg_base + 1) << 8; @@ -2119,11 +2116,9 @@ static int __init smsc_superio_paged(const smsc_chip_t *chips, unsigned short cf fir_io |= inb(cfg_base + 1); outb(0x2b, cfg_base); /* ??? */ - if (fir_io) { - if (smsc_ircc_open(fir_io, sir_io, ircc_dma, ircc_irq) == 0) - ret=0; - } - + if (fir_io && smsc_ircc_open(fir_io, sir_io, ircc_dma, ircc_irq) == 0) + ret = 0; + /* Exit configuration */ outb(SMSCSIO_CFGEXITKEY, cfg_base); @@ -2131,21 +2126,17 @@ static int __init smsc_superio_paged(const smsc_chip_t *chips, unsigned short cf } -static int __init smsc_access(unsigned short cfg_base,unsigned char reg) +static int __init smsc_access(unsigned short cfg_base, unsigned char reg) { IRDA_DEBUG(1, "%s\n", __FUNCTION__); outb(reg, cfg_base); - - if (inb(cfg_base)!=reg) - return -1; - - return 0; + return inb(cfg_base) != reg ? -1 : 0; } -static const smsc_chip_t * __init smsc_ircc_probe(unsigned short cfg_base,u8 reg,const smsc_chip_t *chip,char *type) +static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type) { - u8 devid,xdevid,rev; + u8 devid, xdevid, rev; IRDA_DEBUG(1, "%s\n", __FUNCTION__); @@ -2158,7 +2149,7 @@ static const smsc_chip_t * __init smsc_ircc_probe(unsigned short cfg_base,u8 reg outb(reg, cfg_base); - xdevid=inb(cfg_base+1); + xdevid = inb(cfg_base + 1); /* Enter configuration */ @@ -2168,51 +2159,49 @@ static const smsc_chip_t * __init smsc_ircc_probe(unsigned short cfg_base,u8 reg if (smsc_access(cfg_base,0x55)) /* send second key and check */ return NULL; #endif - + /* probe device ID */ - if (smsc_access(cfg_base,reg)) + if (smsc_access(cfg_base, reg)) return NULL; - devid=inb(cfg_base+1); - - if (devid==0) /* typical value for unused port */ - return NULL; + devid = inb(cfg_base + 1); - if (devid==0xff) /* typical value for unused port */ + if (devid == 0 || devid == 0xff) /* typical values for unused port */ return NULL; /* probe revision ID */ - if (smsc_access(cfg_base,reg+1)) + if (smsc_access(cfg_base, reg + 1)) return NULL; - rev=inb(cfg_base+1); + rev = inb(cfg_base + 1); - if (rev>=128) /* i think this will make no sense */ + if (rev >= 128) /* i think this will make no sense */ return NULL; - if (devid==xdevid) /* protection against false positives */ + if (devid == xdevid) /* protection against false positives */ return NULL; /* Check for expected device ID; are there others? */ - while(chip->devid!=devid) { + while (chip->devid != devid) { chip++; - if (chip->name==NULL) + if (chip->name == NULL) return NULL; } - IRDA_MESSAGE("found SMC SuperIO Chip (devid=0x%02x rev=%02X base=0x%04x): %s%s\n",devid,rev,cfg_base,type,chip->name); + IRDA_MESSAGE("found SMC SuperIO Chip (devid=0x%02x rev=%02X base=0x%04x): %s%s\n", + devid, rev, cfg_base, type, chip->name); - if (chip->rev>rev){ - IRDA_MESSAGE("Revision higher than expected\n"); + if (chip->rev > rev) { + IRDA_MESSAGE("Revision higher than expected\n"); return NULL; } - - if (chip->flags&NoIRDA) + + if (chip->flags & NoIRDA) IRDA_MESSAGE("chipset does not support IRDA\n"); return chip; @@ -2226,8 +2215,8 @@ static int __init smsc_superio_fdc(unsigned short cfg_base) IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n", __FUNCTION__, cfg_base); } else { - if (!smsc_superio_flat(fdc_chips_flat,cfg_base,"FDC") - ||!smsc_superio_paged(fdc_chips_paged,cfg_base,"FDC")) + if (!smsc_superio_flat(fdc_chips_flat, cfg_base, "FDC") || + !smsc_superio_paged(fdc_chips_paged, cfg_base, "FDC")) ret = 0; release_region(cfg_base, 2); @@ -2244,9 +2233,10 @@ static int __init smsc_superio_lpc(unsigned short cfg_base) IRDA_WARNING("%s: can't get cfg_base of 0x%03x\n", __FUNCTION__, cfg_base); } else { - if (!smsc_superio_flat(lpc_chips_flat,cfg_base,"LPC") - ||!smsc_superio_paged(lpc_chips_paged,cfg_base,"LPC")) + if (!smsc_superio_flat(lpc_chips_flat, cfg_base, "LPC") || + !smsc_superio_paged(lpc_chips_paged, cfg_base, "LPC")) ret = 0; + release_region(cfg_base, 2); } return ret; @@ -2269,18 +2259,23 @@ static int __init smsc_superio_lpc(unsigned short cfg_base) static void smsc_ircc_set_transceiver_smsc_ircc_atc(int fir_base, u32 speed) { unsigned long jiffies_now, jiffies_timeout; - u8 val; - - jiffies_now= jiffies; - jiffies_timeout= jiffies+SMSC_IRCC2_ATC_PROGRAMMING_TIMEOUT_JIFFIES; - + u8 val; + + jiffies_now = jiffies; + jiffies_timeout = jiffies + SMSC_IRCC2_ATC_PROGRAMMING_TIMEOUT_JIFFIES; + /* ATC */ register_bank(fir_base, 4); - outb((inb(fir_base+IRCC_ATC) & IRCC_ATC_MASK) |IRCC_ATC_nPROGREADY|IRCC_ATC_ENABLE, fir_base+IRCC_ATC); - while((val=(inb(fir_base+IRCC_ATC) & IRCC_ATC_nPROGREADY)) && !time_after(jiffies, jiffies_timeout)); - if(val) + outb((inb(fir_base + IRCC_ATC) & IRCC_ATC_MASK) | IRCC_ATC_nPROGREADY|IRCC_ATC_ENABLE, + fir_base + IRCC_ATC); + + while ((val = (inb(fir_base + IRCC_ATC) & IRCC_ATC_nPROGREADY)) && + !time_after(jiffies, jiffies_timeout)) + /* empty */; + + if (val) IRDA_WARNING("%s(): ATC: 0x%02x\n", __FUNCTION__, - inb(fir_base+IRCC_ATC)); + inb(fir_base + IRCC_ATC)); } /* @@ -2298,34 +2293,32 @@ static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base) /* * Function smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(self, speed) * - * Set transceiver + * Set transceiver * */ static void smsc_ircc_set_transceiver_smsc_ircc_fast_pin_select(int fir_base, u32 speed) { - u8 fast_mode; - - switch(speed) - { - default: - case 576000 : - fast_mode = 0; + u8 fast_mode; + + switch (speed) { + default: + case 576000 : + fast_mode = 0; break; - case 1152000 : - case 4000000 : + case 1152000 : + case 4000000 : fast_mode = IRCC_LCR_A_FAST; break; - } register_bank(fir_base, 0); - outb((inb(fir_base+IRCC_LCR_A) & 0xbf) | fast_mode, fir_base+IRCC_LCR_A); + outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A); } /* * Function smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(fir_base) * - * Probe transceiver + * Probe transceiver * */ @@ -2337,35 +2330,34 @@ static int smsc_ircc_probe_transceiver_smsc_ircc_fast_pin_select(int fir_base) /* * Function smsc_ircc_set_transceiver_toshiba_sat1800(fir_base, speed) * - * Set transceiver + * Set transceiver * */ static void smsc_ircc_set_transceiver_toshiba_sat1800(int fir_base, u32 speed) { - u8 fast_mode; - - switch(speed) - { - default: - case 576000 : - fast_mode = 0; + u8 fast_mode; + + switch (speed) { + default: + case 576000 : + fast_mode = 0; break; - case 1152000 : - case 4000000 : + case 1152000 : + case 4000000 : fast_mode = /*IRCC_LCR_A_FAST |*/ IRCC_LCR_A_GP_DATA; break; - + } /* This causes an interrupt */ register_bank(fir_base, 0); - outb((inb(fir_base+IRCC_LCR_A) & 0xbf) | fast_mode, fir_base+IRCC_LCR_A); + outb((inb(fir_base + IRCC_LCR_A) & 0xbf) | fast_mode, fir_base + IRCC_LCR_A); } /* * Function smsc_ircc_probe_transceiver_toshiba_sat1800(fir_base) * - * Probe transceiver + * Probe transceiver * */ @@ -2377,20 +2369,3 @@ static int smsc_ircc_probe_transceiver_toshiba_sat1800(int fir_base) module_init(smsc_ircc_init); module_exit(smsc_ircc_cleanup); - -MODULE_AUTHOR("Daniele Peri <peri@csai.unipa.it>"); -MODULE_DESCRIPTION("SMC IrCC SIR/FIR controller driver"); -MODULE_LICENSE("GPL"); - -module_param(ircc_dma, int, 0); -MODULE_PARM_DESC(ircc_dma, "DMA channel"); -module_param(ircc_irq, int, 0); -MODULE_PARM_DESC(ircc_irq, "IRQ line"); -module_param(ircc_fir, int, 0); -MODULE_PARM_DESC(ircc_fir, "FIR Base Address"); -module_param(ircc_sir, int, 0); -MODULE_PARM_DESC(ircc_sir, "SIR Base Address"); -module_param(ircc_cfg, int, 0); -MODULE_PARM_DESC(ircc_cfg, "Configuration register base address"); -module_param(ircc_transceiver, int, 0); -MODULE_PARM_DESC(ircc_transceiver, "Transceiver type"); diff --git a/drivers/net/irda/smsc-ircc2.h b/drivers/net/irda/smsc-ircc2.h index 458611cc0d4..0c36286d87f 100644 --- a/drivers/net/irda/smsc-ircc2.h +++ b/drivers/net/irda/smsc-ircc2.h @@ -1,5 +1,5 @@ /********************************************************************* - * $Id: smsc-ircc2.h,v 1.12.2.1 2002/10/27 10:52:37 dip Exp $ + * $Id: smsc-ircc2.h,v 1.12.2.1 2002/10/27 10:52:37 dip Exp $ * * Description: Definitions for the SMC IrCC chipset * Status: Experimental. @@ -9,25 +9,25 @@ * All Rights Reserved. * * Based on smc-ircc.h: - * + * * Copyright (c) 1999-2000, Dag Brattli <dagb@cs.uit.no> * Copyright (c) 1998-1999, Thomas Davis (tadavis@jps.net> * All Rights Reserved * - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ********************************************************************/ @@ -112,10 +112,10 @@ #define IRCC_CFGA_COM 0x00 #define IRCC_SCE_CFGA_BLOCK_CTRL_BITS_MASK 0x87 -#define IRCC_CFGA_IRDA_SIR_A 0x08 -#define IRCC_CFGA_ASK_SIR 0x10 -#define IRCC_CFGA_IRDA_SIR_B 0x18 -#define IRCC_CFGA_IRDA_HDLC 0x20 +#define IRCC_CFGA_IRDA_SIR_A 0x08 +#define IRCC_CFGA_ASK_SIR 0x10 +#define IRCC_CFGA_IRDA_SIR_B 0x18 +#define IRCC_CFGA_IRDA_HDLC 0x20 #define IRCC_CFGA_IRDA_4PPM 0x28 #define IRCC_CFGA_CONSUMER 0x30 #define IRCC_CFGA_RAW_IR 0x38 @@ -130,7 +130,7 @@ #define IRCC_CFGB_LPBCK_TX_CRC 0x10 #define IRCC_CFGB_NOWAIT 0x08 #define IRCC_CFGB_STRING_MOVE 0x04 -#define IRCC_CFGB_DMA_BURST 0x02 +#define IRCC_CFGB_DMA_BURST 0x02 #define IRCC_CFGB_DMA_ENABLE 0x01 #define IRCC_CFGB_MUX_COM 0x00 @@ -141,11 +141,11 @@ /* Register block 3 - Identification Registers! */ #define IRCC_ID_HIGH 0x00 /* 0x10 */ #define IRCC_ID_LOW 0x01 /* 0xB8 */ -#define IRCC_CHIP_ID 0x02 /* 0xF1 */ +#define IRCC_CHIP_ID 0x02 /* 0xF1 */ #define IRCC_VERSION 0x03 /* 0x01 */ #define IRCC_INTERFACE 0x04 /* low 4 = DMA, high 4 = IRQ */ -#define IRCC_INTERFACE_DMA_MASK 0x0F /* low 4 = DMA, high 4 = IRQ */ -#define IRCC_INTERFACE_IRQ_MASK 0xF0 /* low 4 = DMA, high 4 = IRQ */ +#define IRCC_INTERFACE_DMA_MASK 0x0F /* low 4 = DMA, high 4 = IRQ */ +#define IRCC_INTERFACE_IRQ_MASK 0xF0 /* low 4 = DMA, high 4 = IRQ */ /* Register block 4 - IrDA */ #define IRCC_CONTROL 0x00 @@ -163,10 +163,10 @@ /* Register block 5 - IrDA */ #define IRCC_ATC 0x00 -#define IRCC_ATC_nPROGREADY 0x80 -#define IRCC_ATC_SPEED 0x40 -#define IRCC_ATC_ENABLE 0x20 -#define IRCC_ATC_MASK 0xE0 +#define IRCC_ATC_nPROGREADY 0x80 +#define IRCC_ATC_SPEED 0x40 +#define IRCC_ATC_ENABLE 0x20 +#define IRCC_ATC_MASK 0xE0 #define IRCC_IRHALFDUPLEX_TIMEOUT 0x01 @@ -178,8 +178,8 @@ */ #define SMSC_IRCC2_MAX_SIR_SPEED 115200 -#define SMSC_IRCC2_FIR_CHIP_IO_EXTENT 8 -#define SMSC_IRCC2_SIR_CHIP_IO_EXTENT 8 +#define SMSC_IRCC2_FIR_CHIP_IO_EXTENT 8 +#define SMSC_IRCC2_SIR_CHIP_IO_EXTENT 8 #define SMSC_IRCC2_FIFO_SIZE 16 #define SMSC_IRCC2_FIFO_THRESHOLD 64 /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */ diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c index dc5d089bf18..3d56cf5a4e2 100644 --- a/drivers/net/iseries_veth.c +++ b/drivers/net/iseries_veth.c @@ -4,6 +4,7 @@ * Copyright (C) 2001 Kyle A. Lucke (klucke@us.ibm.com), IBM Corp. * Substantially cleaned up by: * Copyright (C) 2003 David Gibson <dwg@au1.ibm.com>, IBM Corporation. + * Copyright (C) 2004-2005 Michael Ellerman, IBM Corporation. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/drivers/net/s2io-regs.h b/drivers/net/s2io-regs.h index 2234a8f05eb..7cefe5507b9 100644 --- a/drivers/net/s2io-regs.h +++ b/drivers/net/s2io-regs.h @@ -1,5 +1,5 @@ /************************************************************************ - * regs.h: A Linux PCI-X Ethernet driver for S2IO 10GbE Server NIC + * regs.h: A Linux PCI-X Ethernet driver for Neterion 10GbE Server NIC * Copyright(c) 2002-2005 Neterion Inc. * This software may be used and distributed according to the terms of @@ -713,13 +713,16 @@ typedef struct _XENA_dev_config { u64 mc_err_reg; #define MC_ERR_REG_ECC_DB_ERR_L BIT(14) #define MC_ERR_REG_ECC_DB_ERR_U BIT(15) +#define MC_ERR_REG_MIRI_ECC_DB_ERR_0 BIT(18) +#define MC_ERR_REG_MIRI_ECC_DB_ERR_1 BIT(20) #define MC_ERR_REG_MIRI_CRI_ERR_0 BIT(22) #define MC_ERR_REG_MIRI_CRI_ERR_1 BIT(23) #define MC_ERR_REG_SM_ERR BIT(31) -#define MC_ERR_REG_ECC_ALL_SNG (BIT(6) | \ - BIT(7) | BIT(17) | BIT(19)) -#define MC_ERR_REG_ECC_ALL_DBL (BIT(14) | \ - BIT(15) | BIT(18) | BIT(20)) +#define MC_ERR_REG_ECC_ALL_SNG (BIT(2) | BIT(3) | BIT(4) | BIT(5) |\ + BIT(6) | BIT(7) | BIT(17) | BIT(19)) +#define MC_ERR_REG_ECC_ALL_DBL (BIT(10) | BIT(11) | BIT(12) |\ + BIT(13) | BIT(14) | BIT(15) |\ + BIT(18) | BIT(20)) u64 mc_err_mask; u64 mc_err_alarm; diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 5dda043bd9d..c829e6a2e8a 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c @@ -1,5 +1,5 @@ /************************************************************************ - * s2io.c: A Linux PCI-X Ethernet driver for S2IO 10GbE Server NIC + * s2io.c: A Linux PCI-X Ethernet driver for Neterion 10GbE Server NIC * Copyright(c) 2002-2005 Neterion Inc. * This software may be used and distributed according to the terms of @@ -28,7 +28,7 @@ * explaination of all the variables. * rx_ring_num : This can be used to program the number of receive rings used * in the driver. - * rx_ring_len: This defines the number of descriptors each ring can have. This + * rx_ring_sz: This defines the number of descriptors each ring can have. This * is also an array of size 8. * tx_fifo_num: This defines the number of Tx FIFOs thats used int the driver. * tx_fifo_len: This too is an array of 8. Each element defines the number of @@ -67,7 +67,7 @@ /* S2io Driver name & version. */ static char s2io_driver_name[] = "Neterion"; -static char s2io_driver_version[] = "Version 2.0.3.1"; +static char s2io_driver_version[] = "Version 2.0.8.1"; static inline int RXD_IS_UP2DT(RxD_t *rxdp) { @@ -354,7 +354,7 @@ static int init_shared_mem(struct s2io_nic *nic) int lst_size, lst_per_page; struct net_device *dev = nic->dev; #ifdef CONFIG_2BUFF_MODE - u64 tmp; + unsigned long tmp; buffAdd_t *ba; #endif @@ -404,7 +404,7 @@ static int init_shared_mem(struct s2io_nic *nic) config->tx_cfg[i].fifo_len - 1; mac_control->fifos[i].fifo_no = i; mac_control->fifos[i].nic = nic; - mac_control->fifos[i].max_txds = MAX_SKB_FRAGS; + mac_control->fifos[i].max_txds = MAX_SKB_FRAGS + 1; for (j = 0; j < page_num; j++) { int k = 0; @@ -418,6 +418,26 @@ static int init_shared_mem(struct s2io_nic *nic) DBG_PRINT(ERR_DBG, "failed for TxDL\n"); return -ENOMEM; } + /* If we got a zero DMA address(can happen on + * certain platforms like PPC), reallocate. + * Store virtual address of page we don't want, + * to be freed later. + */ + if (!tmp_p) { + mac_control->zerodma_virt_addr = tmp_v; + DBG_PRINT(INIT_DBG, + "%s: Zero DMA address for TxDL. ", dev->name); + DBG_PRINT(INIT_DBG, + "Virtual address %llx\n", (u64)tmp_v); + tmp_v = pci_alloc_consistent(nic->pdev, + PAGE_SIZE, &tmp_p); + if (!tmp_v) { + DBG_PRINT(ERR_DBG, + "pci_alloc_consistent "); + DBG_PRINT(ERR_DBG, "failed for TxDL\n"); + return -ENOMEM; + } + } while (k < lst_per_page) { int l = (j * lst_per_page) + k; if (l == config->tx_cfg[i].fifo_len) @@ -542,18 +562,18 @@ static int init_shared_mem(struct s2io_nic *nic) (BUF0_LEN + ALIGN_SIZE, GFP_KERNEL); if (!ba->ba_0_org) return -ENOMEM; - tmp = (u64) ba->ba_0_org; + tmp = (unsigned long) ba->ba_0_org; tmp += ALIGN_SIZE; - tmp &= ~((u64) ALIGN_SIZE); + tmp &= ~((unsigned long) ALIGN_SIZE); ba->ba_0 = (void *) tmp; ba->ba_1_org = (void *) kmalloc (BUF1_LEN + ALIGN_SIZE, GFP_KERNEL); if (!ba->ba_1_org) return -ENOMEM; - tmp = (u64) ba->ba_1_org; + tmp = (unsigned long) ba->ba_1_org; tmp += ALIGN_SIZE; - tmp &= ~((u64) ALIGN_SIZE); + tmp &= ~((unsigned long) ALIGN_SIZE); ba->ba_1 = (void *) tmp; k++; } @@ -600,7 +620,7 @@ static void free_shared_mem(struct s2io_nic *nic) mac_info_t *mac_control; struct config_param *config; int lst_size, lst_per_page; - + struct net_device *dev = nic->dev; if (!nic) return; @@ -616,9 +636,10 @@ static void free_shared_mem(struct s2io_nic *nic) lst_per_page); for (j = 0; j < page_num; j++) { int mem_blks = (j * lst_per_page); - if ((!mac_control->fifos[i].list_info) || - (!mac_control->fifos[i].list_info[mem_blks]. - list_virt_addr)) + if (!mac_control->fifos[i].list_info) + return; + if (!mac_control->fifos[i].list_info[mem_blks]. + list_virt_addr) break; pci_free_consistent(nic->pdev, PAGE_SIZE, mac_control->fifos[i]. @@ -628,6 +649,18 @@ static void free_shared_mem(struct s2io_nic *nic) list_info[mem_blks]. list_phy_addr); } + /* If we got a zero DMA address during allocation, + * free the page now + */ + if (mac_control->zerodma_virt_addr) { + pci_free_consistent(nic->pdev, PAGE_SIZE, + mac_control->zerodma_virt_addr, + (dma_addr_t)0); + DBG_PRINT(INIT_DBG, + "%s: Freeing TxDL with zero DMA addr. ", dev->name); + DBG_PRINT(INIT_DBG, "Virtual address %llx\n", + (u64)(mac_control->zerodma_virt_addr)); + } kfree(mac_control->fifos[i].list_info); } @@ -2479,9 +2512,10 @@ static void rx_intr_handler(ring_info_t *ring_data) #endif spin_lock(&nic->rx_lock); if (atomic_read(&nic->card_state) == CARD_DOWN) { - DBG_PRINT(ERR_DBG, "%s: %s going down for reset\n", + DBG_PRINT(INTR_DBG, "%s: %s going down for reset\n", __FUNCTION__, dev->name); spin_unlock(&nic->rx_lock); + return; } get_info = ring_data->rx_curr_get_info; @@ -2596,8 +2630,14 @@ static void tx_intr_handler(fifo_info_t *fifo_data) if (txdlp->Control_1 & TXD_T_CODE) { unsigned long long err; err = txdlp->Control_1 & TXD_T_CODE; - DBG_PRINT(ERR_DBG, "***TxD error %llx\n", - err); + if ((err >> 48) == 0xA) { + DBG_PRINT(TX_DBG, "TxD returned due \ + to loss of link\n"); + } + else { + DBG_PRINT(ERR_DBG, "***TxD error \ + %llx\n", err); + } } skb = (struct sk_buff *) ((unsigned long) @@ -2689,12 +2729,16 @@ static void alarm_intr_handler(struct s2io_nic *nic) if (val64 & MC_ERR_REG_ECC_ALL_DBL) { nic->mac_control.stats_info->sw_stat. double_ecc_errs++; - DBG_PRINT(ERR_DBG, "%s: Device indicates ", + DBG_PRINT(INIT_DBG, "%s: Device indicates ", dev->name); - DBG_PRINT(ERR_DBG, "double ECC error!!\n"); + DBG_PRINT(INIT_DBG, "double ECC error!!\n"); if (nic->device_type != XFRAME_II_DEVICE) { - netif_stop_queue(dev); - schedule_work(&nic->rst_timer_task); + /* Reset XframeI only if critical error */ + if (val64 & (MC_ERR_REG_MIRI_ECC_DB_ERR_0 | + MC_ERR_REG_MIRI_ECC_DB_ERR_1)) { + netif_stop_queue(dev); + schedule_work(&nic->rst_timer_task); + } } } else { nic->mac_control.stats_info->sw_stat. @@ -2706,7 +2750,8 @@ static void alarm_intr_handler(struct s2io_nic *nic) val64 = readq(&bar0->serr_source); if (val64 & SERR_SOURCE_ANY) { DBG_PRINT(ERR_DBG, "%s: Device indicates ", dev->name); - DBG_PRINT(ERR_DBG, "serious error!!\n"); + DBG_PRINT(ERR_DBG, "serious error %llx!!\n", + (unsigned long long)val64); netif_stop_queue(dev); schedule_work(&nic->rst_timer_task); } @@ -3130,7 +3175,7 @@ int s2io_xmit(struct sk_buff *skb, struct net_device *dev) queue_len = mac_control->fifos[queue].tx_curr_put_info.fifo_len + 1; /* Avoid "put" pointer going beyond "get" pointer */ if (txdp->Host_Control || (((put_off + 1) % queue_len) == get_off)) { - DBG_PRINT(ERR_DBG, "Error in xmit, No free TXDs.\n"); + DBG_PRINT(TX_DBG, "Error in xmit, No free TXDs.\n"); netif_stop_queue(dev); dev_kfree_skb(skb); spin_unlock_irqrestore(&sp->tx_lock, flags); @@ -3528,7 +3573,7 @@ static void s2io_set_multicast(struct net_device *dev) val64 = readq(&bar0->mac_cfg); sp->promisc_flg = 1; - DBG_PRINT(ERR_DBG, "%s: entered promiscuous mode\n", + DBG_PRINT(INFO_DBG, "%s: entered promiscuous mode\n", dev->name); } else if (!(dev->flags & IFF_PROMISC) && (sp->promisc_flg)) { /* Remove the NIC from promiscuous mode */ @@ -3543,7 +3588,7 @@ static void s2io_set_multicast(struct net_device *dev) val64 = readq(&bar0->mac_cfg); sp->promisc_flg = 0; - DBG_PRINT(ERR_DBG, "%s: left promiscuous mode\n", + DBG_PRINT(INFO_DBG, "%s: left promiscuous mode\n", dev->name); } @@ -5325,7 +5370,7 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) break; } } - config->max_txds = MAX_SKB_FRAGS; + config->max_txds = MAX_SKB_FRAGS + 1; /* Rx side parameters. */ if (rx_ring_sz[0] == 0) @@ -5525,9 +5570,14 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) if (sp->device_type & XFRAME_II_DEVICE) { DBG_PRINT(ERR_DBG, "%s: Neterion Xframe II 10GbE adapter ", dev->name); - DBG_PRINT(ERR_DBG, "(rev %d), Driver %s\n", + DBG_PRINT(ERR_DBG, "(rev %d), %s", get_xena_rev_id(sp->pdev), s2io_driver_version); +#ifdef CONFIG_2BUFF_MODE + DBG_PRINT(ERR_DBG, ", Buffer mode %d",2); +#endif + + DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n"); DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n", sp->def_mac_addr[0].mac_addr[0], sp->def_mac_addr[0].mac_addr[1], @@ -5544,9 +5594,13 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre) } else { DBG_PRINT(ERR_DBG, "%s: Neterion Xframe I 10GbE adapter ", dev->name); - DBG_PRINT(ERR_DBG, "(rev %d), Driver %s\n", + DBG_PRINT(ERR_DBG, "(rev %d), %s", get_xena_rev_id(sp->pdev), s2io_driver_version); +#ifdef CONFIG_2BUFF_MODE + DBG_PRINT(ERR_DBG, ", Buffer mode %d",2); +#endif + DBG_PRINT(ERR_DBG, "\nCopyright(c) 2002-2005 Neterion Inc.\n"); DBG_PRINT(ERR_DBG, "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x\n", sp->def_mac_addr[0].mac_addr[0], sp->def_mac_addr[0].mac_addr[1], diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h index bc64d967f08..89151cb5218 100644 --- a/drivers/net/s2io.h +++ b/drivers/net/s2io.h @@ -1,5 +1,5 @@ /************************************************************************ - * s2io.h: A Linux PCI-X Ethernet driver for S2IO 10GbE Server NIC + * s2io.h: A Linux PCI-X Ethernet driver for Neterion 10GbE Server NIC * Copyright(c) 2002-2005 Neterion Inc. * This software may be used and distributed according to the terms of @@ -622,6 +622,9 @@ typedef struct mac_info { /* Fifo specific structure */ fifo_info_t fifos[MAX_TX_FIFOS]; + /* Save virtual address of TxD page with zero DMA addr(if any) */ + void *zerodma_virt_addr; + /* rx side stuff */ /* Ring specific structure */ ring_info_t rings[MAX_RX_RINGS]; diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h index a9b06b8d8e3..ac9ce6509ee 100644 --- a/drivers/net/smc91x.h +++ b/drivers/net/smc91x.h @@ -986,7 +986,7 @@ static const char * chip_ids[ 16 ] = { }) #endif -#if SMC_CAN_USE_DATACS +#ifdef SMC_CAN_USE_DATACS #define SMC_PUSH_DATA(p, l) \ if ( lp->datacs ) { \ unsigned char *__ptr = (p); \ diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c new file mode 100644 index 00000000000..4e19220473d --- /dev/null +++ b/drivers/net/spider_net.c @@ -0,0 +1,2334 @@ +/* + * Network device driver for Cell Processor-Based Blade + * + * (C) Copyright IBM Corp. 2005 + * + * Authors : Utz Bacher <utz.bacher@de.ibm.com> + * Jens Osterkamp <Jens.Osterkamp@de.ibm.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <linux/config.h> + +#include <linux/compiler.h> +#include <linux/crc32.h> +#include <linux/delay.h> +#include <linux/etherdevice.h> +#include <linux/ethtool.h> +#include <linux/firmware.h> +#include <linux/if_vlan.h> +#include <linux/init.h> +#include <linux/ioport.h> +#include <linux/ip.h> +#include <linux/kernel.h> +#include <linux/mii.h> +#include <linux/module.h> +#include <linux/netdevice.h> +#include <linux/device.h> +#include <linux/pci.h> +#include <linux/skbuff.h> +#include <linux/slab.h> +#include <linux/tcp.h> +#include <linux/types.h> +#include <linux/wait.h> +#include <linux/workqueue.h> +#include <asm/bitops.h> +#include <asm/pci-bridge.h> +#include <net/checksum.h> + +#include "spider_net.h" + +MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com> and Jens Osterkamp " \ + "<Jens.Osterkamp@de.ibm.com>"); +MODULE_DESCRIPTION("Spider Southbridge Gigabit Ethernet driver"); +MODULE_LICENSE("GPL"); + +static int rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_DEFAULT; +static int tx_descriptors = SPIDER_NET_TX_DESCRIPTORS_DEFAULT; + +module_param(rx_descriptors, int, 0644); +module_param(tx_descriptors, int, 0644); + +MODULE_PARM_DESC(rx_descriptors, "number of descriptors used " \ + "in rx chains"); +MODULE_PARM_DESC(tx_descriptors, "number of descriptors used " \ + "in tx chain"); + +char spider_net_driver_name[] = "spidernet"; + +static struct pci_device_id spider_net_pci_tbl[] = { + { PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_SPIDER_NET, + PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, + { 0, } +}; + +MODULE_DEVICE_TABLE(pci, spider_net_pci_tbl); + +/** + * spider_net_read_reg - reads an SMMIO register of a card + * @card: device structure + * @reg: register to read from + * + * returns the content of the specified SMMIO register. + */ +static u32 +spider_net_read_reg(struct spider_net_card *card, u32 reg) +{ + u32 value; + + value = readl(card->regs + reg); + value = le32_to_cpu(value); + + return value; +} + +/** + * spider_net_write_reg - writes to an SMMIO register of a card + * @card: device structure + * @reg: register to write to + * @value: value to write into the specified SMMIO register + */ +static void +spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) +{ + value = cpu_to_le32(value); + writel(value, card->regs + reg); +} + +/** + * spider_net_write_reg_sync - writes to an SMMIO register of a card + * @card: device structure + * @reg: register to write to + * @value: value to write into the specified SMMIO register + * + * Unlike spider_net_write_reg, this will also make sure the + * data arrives on the card by reading the reg again. + */ +static void +spider_net_write_reg_sync(struct spider_net_card *card, u32 reg, u32 value) +{ + value = cpu_to_le32(value); + writel(value, card->regs + reg); + (void)readl(card->regs + reg); +} + +/** + * spider_net_rx_irq_off - switch off rx irq on this spider card + * @card: device structure + * + * switches off rx irq by masking them out in the GHIINTnMSK register + */ +static void +spider_net_rx_irq_off(struct spider_net_card *card) +{ + u32 regvalue; + unsigned long flags; + + spin_lock_irqsave(&card->intmask_lock, flags); + regvalue = spider_net_read_reg(card, SPIDER_NET_GHIINT0MSK); + regvalue &= ~SPIDER_NET_RXINT; + spider_net_write_reg_sync(card, SPIDER_NET_GHIINT0MSK, regvalue); + spin_unlock_irqrestore(&card->intmask_lock, flags); +} + +/** spider_net_write_phy - write to phy register + * @netdev: adapter to be written to + * @mii_id: id of MII + * @reg: PHY register + * @val: value to be written to phy register + * + * spider_net_write_phy_register writes to an arbitrary PHY + * register via the spider GPCWOPCMD register. We assume the queue does + * not run full (not more than 15 commands outstanding). + **/ +static void +spider_net_write_phy(struct net_device *netdev, int mii_id, + int reg, int val) +{ + struct spider_net_card *card = netdev_priv(netdev); + u32 writevalue; + + writevalue = ((u32)mii_id << 21) | + ((u32)reg << 16) | ((u32)val); + + spider_net_write_reg(card, SPIDER_NET_GPCWOPCMD, writevalue); +} + +/** spider_net_read_phy - read from phy register + * @netdev: network device to be read from + * @mii_id: id of MII + * @reg: PHY register + * + * Returns value read from PHY register + * + * spider_net_write_phy reads from an arbitrary PHY + * register via the spider GPCROPCMD register + **/ +static int +spider_net_read_phy(struct net_device *netdev, int mii_id, int reg) +{ + struct spider_net_card *card = netdev_priv(netdev); + u32 readvalue; + + readvalue = ((u32)mii_id << 21) | ((u32)reg << 16); + spider_net_write_reg(card, SPIDER_NET_GPCROPCMD, readvalue); + + /* we don't use semaphores to wait for an SPIDER_NET_GPROPCMPINT + * interrupt, as we poll for the completion of the read operation + * in spider_net_read_phy. Should take about 50 us */ + do { + readvalue = spider_net_read_reg(card, SPIDER_NET_GPCROPCMD); + } while (readvalue & SPIDER_NET_GPREXEC); + + readvalue &= SPIDER_NET_GPRDAT_MASK; + + return readvalue; +} + +/** + * spider_net_rx_irq_on - switch on rx irq on this spider card + * @card: device structure + * + * switches on rx irq by enabling them in the GHIINTnMSK register + */ +static void +spider_net_rx_irq_on(struct spider_net_card *card) +{ + u32 regvalue; + unsigned long flags; + + spin_lock_irqsave(&card->intmask_lock, flags); + regvalue = spider_net_read_reg(card, SPIDER_NET_GHIINT0MSK); + regvalue |= SPIDER_NET_RXINT; + spider_net_write_reg_sync(card, SPIDER_NET_GHIINT0MSK, regvalue); + spin_unlock_irqrestore(&card->intmask_lock, flags); +} + +/** + * spider_net_tx_irq_off - switch off tx irq on this spider card + * @card: device structure + * + * switches off tx irq by masking them out in the GHIINTnMSK register + */ +static void +spider_net_tx_irq_off(struct spider_net_card *card) +{ + u32 regvalue; + unsigned long flags; + + spin_lock_irqsave(&card->intmask_lock, flags); + regvalue = spider_net_read_reg(card, SPIDER_NET_GHIINT0MSK); + regvalue &= ~SPIDER_NET_TXINT; + spider_net_write_reg_sync(card, SPIDER_NET_GHIINT0MSK, regvalue); + spin_unlock_irqrestore(&card->intmask_lock, flags); +} + +/** + * spider_net_tx_irq_on - switch on tx irq on this spider card + * @card: device structure + * + * switches on tx irq by enabling them in the GHIINTnMSK register + */ +static void +spider_net_tx_irq_on(struct spider_net_card *card) +{ + u32 regvalue; + unsigned long flags; + + spin_lock_irqsave(&card->intmask_lock, flags); + regvalue = spider_net_read_reg(card, SPIDER_NET_GHIINT0MSK); + regvalue |= SPIDER_NET_TXINT; + spider_net_write_reg_sync(card, SPIDER_NET_GHIINT0MSK, regvalue); + spin_unlock_irqrestore(&card->intmask_lock, flags); +} + +/** + * spider_net_set_promisc - sets the unicast address or the promiscuous mode + * @card: card structure + * + * spider_net_set_promisc sets the unicast destination address filter and + * thus either allows for non-promisc mode or promisc mode + */ +static void +spider_net_set_promisc(struct spider_net_card *card) +{ + u32 macu, macl; + struct net_device *netdev = card->netdev; + + if (netdev->flags & IFF_PROMISC) { + /* clear destination entry 0 */ + spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, 0); + spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, 0); + spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, + SPIDER_NET_PROMISC_VALUE); + } else { + macu = netdev->dev_addr[0]; + macu <<= 8; + macu |= netdev->dev_addr[1]; + memcpy(&macl, &netdev->dev_addr[2], sizeof(macl)); + + macu |= SPIDER_NET_UA_DESCR_VALUE; + spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, macu); + spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, macl); + spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, + SPIDER_NET_NONPROMISC_VALUE); + } +} + +/** + * spider_net_get_mac_address - read mac address from spider card + * @card: device structure + * + * reads MAC address from GMACUNIMACU and GMACUNIMACL registers + */ +static int +spider_net_get_mac_address(struct net_device *netdev) +{ + struct spider_net_card *card = netdev_priv(netdev); + u32 macl, macu; + + macl = spider_net_read_reg(card, SPIDER_NET_GMACUNIMACL); + macu = spider_net_read_reg(card, SPIDER_NET_GMACUNIMACU); + + netdev->dev_addr[0] = (macu >> 24) & 0xff; + netdev->dev_addr[1] = (macu >> 16) & 0xff; + netdev->dev_addr[2] = (macu >> 8) & 0xff; + netdev->dev_addr[3] = macu & 0xff; + netdev->dev_addr[4] = (macl >> 8) & 0xff; + netdev->dev_addr[5] = macl & 0xff; + + if (!is_valid_ether_addr(&netdev->dev_addr[0])) + return -EINVAL; + + return 0; +} + +/** + * spider_net_get_descr_status -- returns the status of a descriptor + * @descr: descriptor to look at + * + * returns the status as in the dmac_cmd_status field of the descriptor + */ +static enum spider_net_descr_status +spider_net_get_descr_status(struct spider_net_descr *descr) +{ + u32 cmd_status; + rmb(); + cmd_status = descr->dmac_cmd_status; + rmb(); + cmd_status >>= SPIDER_NET_DESCR_IND_PROC_SHIFT; + /* no need to mask out any bits, as cmd_status is 32 bits wide only + * (and unsigned) */ + return cmd_status; +} + +/** + * spider_net_set_descr_status -- sets the status of a descriptor + * @descr: descriptor to change + * @status: status to set in the descriptor + * + * changes the status to the specified value. Doesn't change other bits + * in the status + */ +static void +spider_net_set_descr_status(struct spider_net_descr *descr, + enum spider_net_descr_status status) +{ + u32 cmd_status; + /* read the status */ + mb(); + cmd_status = descr->dmac_cmd_status; + /* clean the upper 4 bits */ + cmd_status &= SPIDER_NET_DESCR_IND_PROC_MASKO; + /* add the status to it */ + cmd_status |= ((u32)status)<<SPIDER_NET_DESCR_IND_PROC_SHIFT; + /* and write it back */ + descr->dmac_cmd_status = cmd_status; + wmb(); +} + +/** + * spider_net_free_chain - free descriptor chain + * @card: card structure + * @chain: address of chain + * + */ +static void +spider_net_free_chain(struct spider_net_card *card, + struct spider_net_descr_chain *chain) +{ + struct spider_net_descr *descr; + + for (descr = chain->tail; !descr->bus_addr; descr = descr->next) { + pci_unmap_single(card->pdev, descr->bus_addr, + SPIDER_NET_DESCR_SIZE, PCI_DMA_BIDIRECTIONAL); + descr->bus_addr = 0; + } +} + +/** + * spider_net_init_chain - links descriptor chain + * @card: card structure + * @chain: address of chain + * @start_descr: address of descriptor array + * @no: number of descriptors + * + * we manage a circular list that mirrors the hardware structure, + * except that the hardware uses bus addresses. + * + * returns 0 on success, <0 on failure + */ +static int +spider_net_init_chain(struct spider_net_card *card, + struct spider_net_descr_chain *chain, + struct spider_net_descr *start_descr, int no) +{ + int i; + struct spider_net_descr *descr; + + spin_lock_init(&card->chain_lock); + + descr = start_descr; + memset(descr, 0, sizeof(*descr) * no); + + /* set up the hardware pointers in each descriptor */ + for (i=0; i<no; i++, descr++) { + spider_net_set_descr_status(descr, SPIDER_NET_DESCR_NOT_IN_USE); + + descr->bus_addr = + pci_map_single(card->pdev, descr, + SPIDER_NET_DESCR_SIZE, + PCI_DMA_BIDIRECTIONAL); + + if (descr->bus_addr == DMA_ERROR_CODE) + goto iommu_error; + + descr->next = descr + 1; + descr->prev = descr - 1; + + } + /* do actual circular list */ + (descr-1)->next = start_descr; + start_descr->prev = descr-1; + + descr = start_descr; + for (i=0; i < no; i++, descr++) { + descr->next_descr_addr = descr->next->bus_addr; + } + + chain->head = start_descr; + chain->tail = start_descr; + + return 0; + +iommu_error: + descr = start_descr; + for (i=0; i < no; i++, descr++) + if (descr->bus_addr) + pci_unmap_single(card->pdev, descr->bus_addr, + SPIDER_NET_DESCR_SIZE, PCI_DMA_BIDIRECTIONAL); + return -ENOMEM; +} + +/** + * spider_net_free_rx_chain_contents - frees descr contents in rx chain + * @card: card structure + * + * returns 0 on success, <0 on failure + */ +static void +spider_net_free_rx_chain_contents(struct spider_net_card *card) +{ + struct spider_net_descr *descr; + + descr = card->rx_chain.head; + while (descr->next != card->rx_chain.head) { + if (descr->skb) { + dev_kfree_skb(descr->skb); + pci_unmap_single(card->pdev, descr->buf_addr, + SPIDER_NET_MAX_MTU, + PCI_DMA_BIDIRECTIONAL); + } + descr = descr->next; + } +} + +/** + * spider_net_prepare_rx_descr - reinitializes a rx descriptor + * @card: card structure + * @descr: descriptor to re-init + * + * return 0 on succes, <0 on failure + * + * allocates a new rx skb, iommu-maps it and attaches it to the descriptor. + * Activate the descriptor state-wise + */ +static int +spider_net_prepare_rx_descr(struct spider_net_card *card, + struct spider_net_descr *descr) +{ + int error = 0; + int offset; + int bufsize; + + /* we need to round up the buffer size to a multiple of 128 */ + bufsize = (SPIDER_NET_MAX_MTU + SPIDER_NET_RXBUF_ALIGN - 1) & + (~(SPIDER_NET_RXBUF_ALIGN - 1)); + + /* and we need to have it 128 byte aligned, therefore we allocate a + * bit more */ + /* allocate an skb */ + descr->skb = dev_alloc_skb(bufsize + SPIDER_NET_RXBUF_ALIGN - 1); + if (!descr->skb) { + if (net_ratelimit()) + if (netif_msg_rx_err(card)) + pr_err("Not enough memory to allocate " + "rx buffer\n"); + return -ENOMEM; + } + descr->buf_size = bufsize; + descr->result_size = 0; + descr->valid_size = 0; + descr->data_status = 0; + descr->data_error = 0; + + offset = ((unsigned long)descr->skb->data) & + (SPIDER_NET_RXBUF_ALIGN - 1); + if (offset) + skb_reserve(descr->skb, SPIDER_NET_RXBUF_ALIGN - offset); + /* io-mmu-map the skb */ + descr->buf_addr = pci_map_single(card->pdev, descr->skb->data, + SPIDER_NET_MAX_MTU, + PCI_DMA_BIDIRECTIONAL); + if (descr->buf_addr == DMA_ERROR_CODE) { + dev_kfree_skb_any(descr->skb); + if (netif_msg_rx_err(card)) + pr_err("Could not iommu-map rx buffer\n"); + spider_net_set_descr_status(descr, SPIDER_NET_DESCR_NOT_IN_USE); + } else { + descr->dmac_cmd_status = SPIDER_NET_DMAC_RX_CARDOWNED; + } + + return error; +} + +/** + * spider_net_enable_rxctails - sets RX dmac chain tail addresses + * @card: card structure + * + * spider_net_enable_rxctails sets the RX DMAC chain tail adresses in the + * chip by writing to the appropriate register. DMA is enabled in + * spider_net_enable_rxdmac. + */ +static void +spider_net_enable_rxchtails(struct spider_net_card *card) +{ + /* assume chain is aligned correctly */ + spider_net_write_reg(card, SPIDER_NET_GDADCHA , + card->rx_chain.tail->bus_addr); +} + +/** + * spider_net_enable_rxdmac - enables a receive DMA controller + * @card: card structure + * + * spider_net_enable_rxdmac enables the DMA controller by setting RX_DMA_EN + * in the GDADMACCNTR register + */ +static void +spider_net_enable_rxdmac(struct spider_net_card *card) +{ + spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, + SPIDER_NET_DMA_RX_VALUE); +} + +/** + * spider_net_refill_rx_chain - refills descriptors/skbs in the rx chains + * @card: card structure + * + * refills descriptors in all chains (last used chain first): allocates skbs + * and iommu-maps them. + */ +static void +spider_net_refill_rx_chain(struct spider_net_card *card) +{ + struct spider_net_descr_chain *chain; + int count = 0; + unsigned long flags; + + chain = &card->rx_chain; + + spin_lock_irqsave(&card->chain_lock, flags); + while (spider_net_get_descr_status(chain->head) == + SPIDER_NET_DESCR_NOT_IN_USE) { + if (spider_net_prepare_rx_descr(card, chain->head)) + break; + count++; + chain->head = chain->head->next; + } + spin_unlock_irqrestore(&card->chain_lock, flags); + + /* could be optimized, only do that, if we know the DMA processing + * has terminated */ + if (count) + spider_net_enable_rxdmac(card); +} + +/** + * spider_net_alloc_rx_skbs - allocates rx skbs in rx descriptor chains + * @card: card structure + * + * returns 0 on success, <0 on failure + */ +static int +spider_net_alloc_rx_skbs(struct spider_net_card *card) +{ + int result; + struct spider_net_descr_chain *chain; + + result = -ENOMEM; + + chain = &card->rx_chain; + /* put at least one buffer into the chain. if this fails, + * we've got a problem. if not, spider_net_refill_rx_chain + * will do the rest at the end of this function */ + if (spider_net_prepare_rx_descr(card, chain->head)) + goto error; + else + chain->head = chain->head->next; + + /* this will allocate the rest of the rx buffers; if not, it's + * business as usual later on */ + spider_net_refill_rx_chain(card); + return 0; + +error: + spider_net_free_rx_chain_contents(card); + return result; +} + +/** + * spider_net_release_tx_descr - processes a used tx descriptor + * @card: card structure + * @descr: descriptor to release + * + * releases a used tx descriptor (unmapping, freeing of skb) + */ +static void +spider_net_release_tx_descr(struct spider_net_card *card, + struct spider_net_descr *descr) +{ + struct sk_buff *skb; + + /* unmap the skb */ + skb = descr->skb; + pci_unmap_single(card->pdev, descr->buf_addr, skb->len, + PCI_DMA_BIDIRECTIONAL); + + dev_kfree_skb_any(skb); + + /* set status to not used */ + spider_net_set_descr_status(descr, SPIDER_NET_DESCR_NOT_IN_USE); +} + +/** + * spider_net_release_tx_chain - processes sent tx descriptors + * @card: adapter structure + * @brutal: if set, don't care about whether descriptor seems to be in use + * + * releases the tx descriptors that spider has finished with (if non-brutal) + * or simply release tx descriptors (if brutal) + */ +static void +spider_net_release_tx_chain(struct spider_net_card *card, int brutal) +{ + struct spider_net_descr_chain *tx_chain = &card->tx_chain; + enum spider_net_descr_status status; + + spider_net_tx_irq_off(card); + + /* no lock for chain needed, if this is only executed once at a time */ +again: + for (;;) { + status = spider_net_get_descr_status(tx_chain->tail); + switch (status) { + case SPIDER_NET_DESCR_CARDOWNED: + if (!brutal) goto out; + /* fallthrough, if we release the descriptors + * brutally (then we don't care about + * SPIDER_NET_DESCR_CARDOWNED) */ + case SPIDER_NET_DESCR_RESPONSE_ERROR: + case SPIDER_NET_DESCR_PROTECTION_ERROR: + case SPIDER_NET_DESCR_FORCE_END: + if (netif_msg_tx_err(card)) + pr_err("%s: forcing end of tx descriptor " + "with status x%02x\n", + card->netdev->name, status); + card->netdev_stats.tx_dropped++; + break; + + case SPIDER_NET_DESCR_COMPLETE: + card->netdev_stats.tx_packets++; + card->netdev_stats.tx_bytes += + tx_chain->tail->skb->len; + break; + + default: /* any other value (== SPIDER_NET_DESCR_NOT_IN_USE) */ + goto out; + } + spider_net_release_tx_descr(card, tx_chain->tail); + tx_chain->tail = tx_chain->tail->next; + } +out: + netif_wake_queue(card->netdev); + + if (!brutal) { + /* switch on tx irqs (while we are still in the interrupt + * handler, so we don't get an interrupt), check again + * for done descriptors. This results in fewer interrupts */ + spider_net_tx_irq_on(card); + status = spider_net_get_descr_status(tx_chain->tail); + switch (status) { + case SPIDER_NET_DESCR_RESPONSE_ERROR: + case SPIDER_NET_DESCR_PROTECTION_ERROR: + case SPIDER_NET_DESCR_FORCE_END: + case SPIDER_NET_DESCR_COMPLETE: + goto again; + default: + break; + } + } + +} + +/** + * spider_net_get_multicast_hash - generates hash for multicast filter table + * @addr: multicast address + * + * returns the hash value. + * + * spider_net_get_multicast_hash calculates a hash value for a given multicast + * address, that is used to set the multicast filter tables + */ +static u8 +spider_net_get_multicast_hash(struct net_device *netdev, __u8 *addr) +{ + /* FIXME: an addr of 01:00:5e:00:00:01 must result in 0xa9, + * ff:ff:ff:ff:ff:ff must result in 0xfd */ + u32 crc; + u8 hash; + + crc = crc32_be(~0, addr, netdev->addr_len); + + hash = (crc >> 27); + hash <<= 3; + hash |= crc & 7; + + return hash; +} + +/** + * spider_net_set_multi - sets multicast addresses and promisc flags + * @netdev: interface device structure + * + * spider_net_set_multi configures multicast addresses as needed for the + * netdev interface. It also sets up multicast, allmulti and promisc + * flags appropriately + */ +static void +spider_net_set_multi(struct net_device *netdev) +{ + struct dev_mc_list *mc; + u8 hash; + int i; + u32 reg; + struct spider_net_card *card = netdev_priv(netdev); + unsigned long bitmask[SPIDER_NET_MULTICAST_HASHES / BITS_PER_LONG] = + {0, }; + + spider_net_set_promisc(card); + + if (netdev->flags & IFF_ALLMULTI) { + for (i = 0; i < SPIDER_NET_MULTICAST_HASHES; i++) { + set_bit(i, bitmask); + } + goto write_hash; + } + + /* well, we know, what the broadcast hash value is: it's xfd + hash = spider_net_get_multicast_hash(netdev, netdev->broadcast); */ + set_bit(0xfd, bitmask); + + for (mc = netdev->mc_list; mc; mc = mc->next) { + hash = spider_net_get_multicast_hash(netdev, mc->dmi_addr); + set_bit(hash, bitmask); + } + +write_hash: + for (i = 0; i < SPIDER_NET_MULTICAST_HASHES / 4; i++) { + reg = 0; + if (test_bit(i * 4, bitmask)) + reg += 0x08; + reg <<= 8; + if (test_bit(i * 4 + 1, bitmask)) + reg += 0x08; + reg <<= 8; + if (test_bit(i * 4 + 2, bitmask)) + reg += 0x08; + reg <<= 8; + if (test_bit(i * 4 + 3, bitmask)) + reg += 0x08; + + spider_net_write_reg(card, SPIDER_NET_GMRMHFILnR + i * 4, reg); + } +} + +/** + * spider_net_disable_rxdmac - disables the receive DMA controller + * @card: card structure + * + * spider_net_disable_rxdmac terminates processing on the DMA controller by + * turing off DMA and issueing a force end + */ +static void +spider_net_disable_rxdmac(struct spider_net_card *card) +{ + spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, + SPIDER_NET_DMA_RX_FEND_VALUE); +} + +/** + * spider_net_stop - called upon ifconfig down + * @netdev: interface device structure + * + * always returns 0 + */ +int +spider_net_stop(struct net_device *netdev) +{ + struct spider_net_card *card = netdev_priv(netdev); + + netif_poll_disable(netdev); + netif_carrier_off(netdev); + netif_stop_queue(netdev); + + /* disable/mask all interrupts */ + spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0); + spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0); + spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0); + + /* free_irq(netdev->irq, netdev);*/ + free_irq(to_pci_dev(netdev->class_dev.dev)->irq, netdev); + + spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, + SPIDER_NET_DMA_TX_FEND_VALUE); + + /* turn off DMA, force end */ + spider_net_disable_rxdmac(card); + + /* release chains */ + spider_net_release_tx_chain(card, 1); + + spider_net_free_chain(card, &card->tx_chain); + spider_net_free_chain(card, &card->rx_chain); + + return 0; +} + +/** + * spider_net_get_next_tx_descr - returns the next available tx descriptor + * @card: device structure to get descriptor from + * + * returns the address of the next descriptor, or NULL if not available. + */ +static struct spider_net_descr * +spider_net_get_next_tx_descr(struct spider_net_card *card) +{ + /* check, if head points to not-in-use descr */ + if ( spider_net_get_descr_status(card->tx_chain.head) == + SPIDER_NET_DESCR_NOT_IN_USE ) { + return card->tx_chain.head; + } else { + return NULL; + } +} + +/** + * spider_net_set_txdescr_cmdstat - sets the tx descriptor command field + * @descr: descriptor structure to fill out + * @skb: packet to consider + * + * fills out the command and status field of the descriptor structure, + * depending on hardware checksum settings. This function assumes a wmb() + * has executed before. + */ +static void +spider_net_set_txdescr_cmdstat(struct spider_net_descr *descr, + struct sk_buff *skb) +{ + if (skb->ip_summed != CHECKSUM_HW) { + descr->dmac_cmd_status = SPIDER_NET_DMAC_CMDSTAT_NOCS; + return; + } + + /* is packet ip? + * if yes: tcp? udp? */ + if (skb->protocol == htons(ETH_P_IP)) { + if (skb->nh.iph->protocol == IPPROTO_TCP) { + descr->dmac_cmd_status = SPIDER_NET_DMAC_CMDSTAT_TCPCS; + } else if (skb->nh.iph->protocol == IPPROTO_UDP) { + descr->dmac_cmd_status = SPIDER_NET_DMAC_CMDSTAT_UDPCS; + } else { /* the stack should checksum non-tcp and non-udp + packets on his own: NETIF_F_IP_CSUM */ + descr->dmac_cmd_status = SPIDER_NET_DMAC_CMDSTAT_NOCS; + } + } +} + +/** + * spider_net_prepare_tx_descr - fill tx descriptor with skb data + * @card: card structure + * @descr: descriptor structure to fill out + * @skb: packet to use + * + * returns 0 on success, <0 on failure. + * + * fills out the descriptor structure with skb data and len. Copies data, + * if needed (32bit DMA!) + */ +static int +spider_net_prepare_tx_descr(struct spider_net_card *card, + struct spider_net_descr *descr, + struct sk_buff *skb) +{ + descr->buf_addr = pci_map_single(card->pdev, skb->data, + skb->len, PCI_DMA_BIDIRECTIONAL); + if (descr->buf_addr == DMA_ERROR_CODE) { + if (netif_msg_tx_err(card)) + pr_err("could not iommu-map packet (%p, %i). " + "Dropping packet\n", skb->data, skb->len); + return -ENOMEM; + } + + descr->buf_size = skb->len; + descr->skb = skb; + descr->data_status = 0; + + /* make sure the above values are in memory before we change the + * status */ + wmb(); + + spider_net_set_txdescr_cmdstat(descr,skb); + + return 0; +} + +/** + * spider_net_kick_tx_dma - enables TX DMA processing + * @card: card structure + * @descr: descriptor address to enable TX processing at + * + * spider_net_kick_tx_dma writes the current tx chain head as start address + * of the tx descriptor chain and enables the transmission DMA engine + */ +static void +spider_net_kick_tx_dma(struct spider_net_card *card, + struct spider_net_descr *descr) +{ + /* this is the only descriptor in the output chain. + * Enable TX DMA */ + + spider_net_write_reg(card, SPIDER_NET_GDTDCHA, + descr->bus_addr); + + spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, + SPIDER_NET_DMA_TX_VALUE); +} + +/** + * spider_net_xmit - transmits a frame over the device + * @skb: packet to send out + * @netdev: interface device structure + * + * returns 0 on success, <0 on failure + */ +static int +spider_net_xmit(struct sk_buff *skb, struct net_device *netdev) +{ + struct spider_net_card *card = netdev_priv(netdev); + struct spider_net_descr *descr; + int result; + + descr = spider_net_get_next_tx_descr(card); + + if (!descr) { + netif_stop_queue(netdev); + + descr = spider_net_get_next_tx_descr(card); + if (!descr) + goto error; + else + netif_start_queue(netdev); + } + + result = spider_net_prepare_tx_descr(card, descr, skb); + if (result) + goto error; + + card->tx_chain.head = card->tx_chain.head->next; + + /* make sure the status from spider_net_prepare_tx_descr is in + * memory before we check out the previous descriptor */ + wmb(); + + if (spider_net_get_descr_status(descr->prev) != + SPIDER_NET_DESCR_CARDOWNED) + spider_net_kick_tx_dma(card, descr); + + return NETDEV_TX_OK; + +error: + card->netdev_stats.tx_dropped++; + return NETDEV_TX_LOCKED; +} + +/** + * spider_net_do_ioctl - called for device ioctls + * @netdev: interface device structure + * @ifr: request parameter structure for ioctl + * @cmd: command code for ioctl + * + * returns 0 on success, <0 on failure. Currently, we have no special ioctls. + * -EOPNOTSUPP is returned, if an unknown ioctl was requested + */ +static int +spider_net_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) +{ + switch (cmd) { + default: + return -EOPNOTSUPP; + } +} + +/** + * spider_net_pass_skb_up - takes an skb from a descriptor and passes it on + * @descr: descriptor to process + * @card: card structure + * + * returns 1 on success, 0 if no packet was passed to the stack + * + * iommu-unmaps the skb, fills out skb structure and passes the data to the + * stack. The descriptor state is not changed. + */ +static int +spider_net_pass_skb_up(struct spider_net_descr *descr, + struct spider_net_card *card) +{ + struct sk_buff *skb; + struct net_device *netdev; + u32 data_status, data_error; + + data_status = descr->data_status; + data_error = descr->data_error; + + netdev = card->netdev; + + /* check for errors in the data_error flag */ + if ((data_error & SPIDER_NET_DATA_ERROR_MASK) && + netif_msg_rx_err(card)) + pr_err("error in received descriptor found, " + "data_status=x%08x, data_error=x%08x\n", + data_status, data_error); + + /* prepare skb, unmap descriptor */ + skb = descr->skb; + pci_unmap_single(card->pdev, descr->buf_addr, SPIDER_NET_MAX_MTU, + PCI_DMA_BIDIRECTIONAL); + + /* the cases we'll throw away the packet immediately */ + if (data_error & SPIDER_NET_DESTROY_RX_FLAGS) + return 0; + + skb->dev = netdev; + skb_put(skb, descr->valid_size); + + /* the card seems to add 2 bytes of junk in front + * of the ethernet frame */ +#define SPIDER_MISALIGN 2 + skb_pull(skb, SPIDER_MISALIGN); + skb->protocol = eth_type_trans(skb, netdev); + + /* checksum offload */ + if (card->options.rx_csum) { + if ( (data_status & SPIDER_NET_DATA_STATUS_CHK_MASK) && + (!(data_error & SPIDER_NET_DATA_ERROR_CHK_MASK)) ) + skb->ip_summed = CHECKSUM_UNNECESSARY; + else + skb->ip_summed = CHECKSUM_NONE; + } else { + skb->ip_summed = CHECKSUM_NONE; + } + + if (data_status & SPIDER_NET_VLAN_PACKET) { + /* further enhancements: HW-accel VLAN + * vlan_hwaccel_receive_skb + */ + } + + /* pass skb up to stack */ + netif_receive_skb(skb); + + /* update netdevice statistics */ + card->netdev_stats.rx_packets++; + card->netdev_stats.rx_bytes += skb->len; + + return 1; +} + +/** + * spider_net_decode_descr - processes an rx descriptor + * @card: card structure + * + * returns 1 if a packet has been sent to the stack, otherwise 0 + * + * processes an rx descriptor by iommu-unmapping the data buffer and passing + * the packet up to the stack + */ +static int +spider_net_decode_one_descr(struct spider_net_card *card) +{ + enum spider_net_descr_status status; + struct spider_net_descr *descr; + struct spider_net_descr_chain *chain; + int result; + + chain = &card->rx_chain; + descr = chain->tail; + + status = spider_net_get_descr_status(descr); + + if (status == SPIDER_NET_DESCR_CARDOWNED) { + /* nothing in the descriptor yet */ + return 0; + } + + if (status == SPIDER_NET_DESCR_NOT_IN_USE) { + /* not initialized yet, I bet chain->tail == chain->head + * and the ring is empty */ + spider_net_refill_rx_chain(card); + return 0; + } + + /* descriptor definitively used -- move on head */ + chain->tail = descr->next; + + result = 0; + if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) || + (status == SPIDER_NET_DESCR_PROTECTION_ERROR) || + (status == SPIDER_NET_DESCR_FORCE_END) ) { + if (netif_msg_rx_err(card)) + pr_err("%s: dropping RX descriptor with state %d\n", + card->netdev->name, status); + card->netdev_stats.rx_dropped++; + goto refill; + } + + if ( (status != SPIDER_NET_DESCR_COMPLETE) && + (status != SPIDER_NET_DESCR_FRAME_END) ) { + if (netif_msg_rx_err(card)) + pr_err("%s: RX descriptor with state %d\n", + card->netdev->name, status); + goto refill; + } + + /* ok, we've got a packet in descr */ + result = spider_net_pass_skb_up(descr, card); +refill: + spider_net_set_descr_status(descr, SPIDER_NET_DESCR_NOT_IN_USE); + /* change the descriptor state: */ + spider_net_refill_rx_chain(card); + + return result; +} + +/** + * spider_net_poll - NAPI poll function called by the stack to return packets + * @netdev: interface device structure + * @budget: number of packets we can pass to the stack at most + * + * returns 0 if no more packets available to the driver/stack. Returns 1, + * if the quota is exceeded, but the driver has still packets. + * + * spider_net_poll returns all packets from the rx descriptors to the stack + * (using netif_receive_skb). If all/enough packets are up, the driver + * reenables interrupts and returns 0. If not, 1 is returned. + */ +static int +spider_net_poll(struct net_device *netdev, int *budget) +{ + struct spider_net_card *card = netdev_priv(netdev); + int packets_to_do, packets_done = 0; + int no_more_packets = 0; + + packets_to_do = min(*budget, netdev->quota); + + while (packets_to_do) { + if (spider_net_decode_one_descr(card)) { + packets_done++; + packets_to_do--; + } else { + /* no more packets for the stack */ + no_more_packets = 1; + break; + } + } + + netdev->quota -= packets_done; + *budget -= packets_done; + + /* if all packets are in the stack, enable interrupts and return 0 */ + /* if not, return 1 */ + if (no_more_packets) { + netif_rx_complete(netdev); + spider_net_rx_irq_on(card); + return 0; + } + + return 1; +} + +/** + * spider_net_vlan_rx_reg - initializes VLAN structures in the driver and card + * @netdev: interface device structure + * @grp: vlan_group structure that is registered (NULL on destroying interface) + */ +static void +spider_net_vlan_rx_reg(struct net_device *netdev, struct vlan_group *grp) +{ + /* further enhancement... yet to do */ + return; +} + +/** + * spider_net_vlan_rx_add - adds VLAN id to the card filter + * @netdev: interface device structure + * @vid: VLAN id to add + */ +static void +spider_net_vlan_rx_add(struct net_device *netdev, uint16_t vid) +{ + /* further enhancement... yet to do */ + /* add vid to card's VLAN filter table */ + return; +} + +/** + * spider_net_vlan_rx_kill - removes VLAN id to the card filter + * @netdev: interface device structure + * @vid: VLAN id to remove + */ +static void +spider_net_vlan_rx_kill(struct net_device *netdev, uint16_t vid) +{ + /* further enhancement... yet to do */ + /* remove vid from card's VLAN filter table */ +} + +/** + * spider_net_get_stats - get interface statistics + * @netdev: interface device structure + * + * returns the interface statistics residing in the spider_net_card struct + */ +static struct net_device_stats * +spider_net_get_stats(struct net_device *netdev) +{ + struct spider_net_card *card = netdev_priv(netdev); + struct net_device_stats *stats = &card->netdev_stats; + return stats; +} + +/** + * spider_net_change_mtu - changes the MTU of an interface + * @netdev: interface device structure + * @new_mtu: new MTU value + * + * returns 0 on success, <0 on failure + */ +static int +spider_net_change_mtu(struct net_device *netdev, int new_mtu) +{ + /* no need to re-alloc skbs or so -- the max mtu is about 2.3k + * and mtu is outbound only anyway */ + if ( (new_mtu < SPIDER_NET_MIN_MTU ) || + (new_mtu > SPIDER_NET_MAX_MTU) ) + return -EINVAL; + netdev->mtu = new_mtu; + return 0; +} + +/** + * spider_net_set_mac - sets the MAC of an interface + * @netdev: interface device structure + * @ptr: pointer to new MAC address + * + * Returns 0 on success, <0 on failure. Currently, we don't support this + * and will always return EOPNOTSUPP. + */ +static int +spider_net_set_mac(struct net_device *netdev, void *p) +{ + struct spider_net_card *card = netdev_priv(netdev); + u32 macl, macu, regvalue; + struct sockaddr *addr = p; + + if (!is_valid_ether_addr(addr->sa_data)) + return -EADDRNOTAVAIL; + + /* switch off GMACTPE and GMACRPE */ + regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); + regvalue &= ~((1 << 5) | (1 << 6)); + spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); + + /* write mac */ + macu = (addr->sa_data[0]<<24) + (addr->sa_data[1]<<16) + + (addr->sa_data[2]<<8) + (addr->sa_data[3]); + macl = (addr->sa_data[4]<<8) + (addr->sa_data[5]); + spider_net_write_reg(card, SPIDER_NET_GMACUNIMACU, macu); + spider_net_write_reg(card, SPIDER_NET_GMACUNIMACL, macl); + + /* switch GMACTPE and GMACRPE back on */ + regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); + regvalue |= ((1 << 5) | (1 << 6)); + spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); + + spider_net_set_promisc(card); + + /* look up, whether we have been successful */ + if (spider_net_get_mac_address(netdev)) + return -EADDRNOTAVAIL; + if (memcmp(netdev->dev_addr,addr->sa_data,netdev->addr_len)) + return -EADDRNOTAVAIL; + + return 0; +} + +/** + * spider_net_enable_txdmac - enables a TX DMA controller + * @card: card structure + * + * spider_net_enable_txdmac enables the TX DMA controller by setting the + * descriptor chain tail address + */ +static void +spider_net_enable_txdmac(struct spider_net_card *card) +{ + /* assume chain is aligned correctly */ + spider_net_write_reg(card, SPIDER_NET_GDTDCHA, + card->tx_chain.tail->bus_addr); +} + +/** + * spider_net_handle_error_irq - handles errors raised by an interrupt + * @card: card structure + * @status_reg: interrupt status register 0 (GHIINT0STS) + * + * spider_net_handle_error_irq treats or ignores all error conditions + * found when an interrupt is presented + */ +static void +spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg) +{ + u32 error_reg1, error_reg2; + u32 i; + int show_error = 1; + + error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS); + error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS); + + /* check GHIINT0STS ************************************/ + if (status_reg) + for (i = 0; i < 32; i++) + if (status_reg & (1<<i)) + switch (i) + { + /* let error_reg1 and error_reg2 evaluation decide, what to do + case SPIDER_NET_PHYINT: + case SPIDER_NET_GMAC2INT: + case SPIDER_NET_GMAC1INT: + case SPIDER_NET_GIPSINT: + case SPIDER_NET_GFIFOINT: + case SPIDER_NET_DMACINT: + case SPIDER_NET_GSYSINT: + break; */ + + case SPIDER_NET_GPWOPCMPINT: + /* PHY write operation completed */ + show_error = 0; + break; + case SPIDER_NET_GPROPCMPINT: + /* PHY read operation completed */ + /* we don't use semaphores, as we poll for the completion + * of the read operation in spider_net_read_phy. Should take + * about 50 us */ + show_error = 0; + break; + case SPIDER_NET_GPWFFINT: + /* PHY command queue full */ + if (netif_msg_intr(card)) + pr_err("PHY write queue full\n"); + show_error = 0; + break; + + /* case SPIDER_NET_GRMDADRINT: not used. print a message */ + /* case SPIDER_NET_GRMARPINT: not used. print a message */ + /* case SPIDER_NET_GRMMPINT: not used. print a message */ + + case SPIDER_NET_GDTDEN0INT: + /* someone has set TX_DMA_EN to 0 */ + show_error = 0; + break; + + case SPIDER_NET_GDDDEN0INT: /* fallthrough */ + case SPIDER_NET_GDCDEN0INT: /* fallthrough */ + case SPIDER_NET_GDBDEN0INT: /* fallthrough */ + case SPIDER_NET_GDADEN0INT: + /* someone has set RX_DMA_EN to 0 */ + show_error = 0; + break; + + /* RX interrupts */ + case SPIDER_NET_GDDFDCINT: + case SPIDER_NET_GDCFDCINT: + case SPIDER_NET_GDBFDCINT: + case SPIDER_NET_GDAFDCINT: + /* case SPIDER_NET_GDNMINT: not used. print a message */ + /* case SPIDER_NET_GCNMINT: not used. print a message */ + /* case SPIDER_NET_GBNMINT: not used. print a message */ + /* case SPIDER_NET_GANMINT: not used. print a message */ + /* case SPIDER_NET_GRFNMINT: not used. print a message */ + show_error = 0; + break; + + /* TX interrupts */ + case SPIDER_NET_GDTFDCINT: + show_error = 0; + break; + case SPIDER_NET_GTTEDINT: + show_error = 0; + break; + case SPIDER_NET_GDTDCEINT: + /* chain end. If a descriptor should be sent, kick off + * tx dma + if (card->tx_chain.tail == card->tx_chain.head) + spider_net_kick_tx_dma(card); + show_error = 0; */ + break; + + /* case SPIDER_NET_G1TMCNTINT: not used. print a message */ + /* case SPIDER_NET_GFREECNTINT: not used. print a message */ + } + + /* check GHIINT1STS ************************************/ + if (error_reg1) + for (i = 0; i < 32; i++) + if (error_reg1 & (1<<i)) + switch (i) + { + case SPIDER_NET_GTMFLLINT: + if (netif_msg_intr(card)) + pr_err("Spider TX RAM full\n"); + show_error = 0; + break; + case SPIDER_NET_GRMFLLINT: + if (netif_msg_intr(card)) + pr_err("Spider RX RAM full, incoming packets " + "might be discarded !\n"); + netif_rx_schedule(card->netdev); + spider_net_enable_rxchtails(card); + spider_net_enable_rxdmac(card); + break; + + /* case SPIDER_NET_GTMSHTINT: problem, print a message */ + case SPIDER_NET_GDTINVDINT: + /* allrighty. tx from previous descr ok */ + show_error = 0; + break; + /* case SPIDER_NET_GRFDFLLINT: print a message down there */ + /* case SPIDER_NET_GRFCFLLINT: print a message down there */ + /* case SPIDER_NET_GRFBFLLINT: print a message down there */ + /* case SPIDER_NET_GRFAFLLINT: print a message down there */ + + /* chain end */ + case SPIDER_NET_GDDDCEINT: /* fallthrough */ + case SPIDER_NET_GDCDCEINT: /* fallthrough */ + case SPIDER_NET_GDBDCEINT: /* fallthrough */ + case SPIDER_NET_GDADCEINT: + if (netif_msg_intr(card)) + pr_err("got descriptor chain end interrupt, " + "restarting DMAC %c.\n", + 'D'+i-SPIDER_NET_GDDDCEINT); + spider_net_refill_rx_chain(card); + show_error = 0; + break; + + /* invalid descriptor */ + case SPIDER_NET_GDDINVDINT: /* fallthrough */ + case SPIDER_NET_GDCINVDINT: /* fallthrough */ + case SPIDER_NET_GDBINVDINT: /* fallthrough */ + case SPIDER_NET_GDAINVDINT: + /* could happen when rx chain is full */ + spider_net_refill_rx_chain(card); + show_error = 0; + break; + + /* case SPIDER_NET_GDTRSERINT: problem, print a message */ + /* case SPIDER_NET_GDDRSERINT: problem, print a message */ + /* case SPIDER_NET_GDCRSERINT: problem, print a message */ + /* case SPIDER_NET_GDBRSERINT: problem, print a message */ + /* case SPIDER_NET_GDARSERINT: problem, print a message */ + /* case SPIDER_NET_GDSERINT: problem, print a message */ + /* case SPIDER_NET_GDTPTERINT: problem, print a message */ + /* case SPIDER_NET_GDDPTERINT: problem, print a message */ + /* case SPIDER_NET_GDCPTERINT: problem, print a message */ + /* case SPIDER_NET_GDBPTERINT: problem, print a message */ + /* case SPIDER_NET_GDAPTERINT: problem, print a message */ + default: + show_error = 1; + break; + } + + /* check GHIINT2STS ************************************/ + if (error_reg2) + for (i = 0; i < 32; i++) + if (error_reg2 & (1<<i)) + switch (i) + { + /* there is nothing we can (want to) do at this time. Log a + * message, we can switch on and off the specific values later on + case SPIDER_NET_GPROPERINT: + case SPIDER_NET_GMCTCRSNGINT: + case SPIDER_NET_GMCTLCOLINT: + case SPIDER_NET_GMCTTMOTINT: + case SPIDER_NET_GMCRCAERINT: + case SPIDER_NET_GMCRCALERINT: + case SPIDER_NET_GMCRALNERINT: + case SPIDER_NET_GMCROVRINT: + case SPIDER_NET_GMCRRNTINT: + case SPIDER_NET_GMCRRXERINT: + case SPIDER_NET_GTITCSERINT: + case SPIDER_NET_GTIFMTERINT: + case SPIDER_NET_GTIPKTRVKINT: + case SPIDER_NET_GTISPINGINT: + case SPIDER_NET_GTISADNGINT: + case SPIDER_NET_GTISPDNGINT: + case SPIDER_NET_GRIFMTERINT: + case SPIDER_NET_GRIPKTRVKINT: + case SPIDER_NET_GRISPINGINT: + case SPIDER_NET_GRISADNGINT: + case SPIDER_NET_GRISPDNGINT: + break; + */ + default: + break; + } + + if ((show_error) && (netif_msg_intr(card))) + pr_err("Got error interrupt, GHIINT0STS = 0x%08x, " + "GHIINT1STS = 0x%08x, GHIINT2STS = 0x%08x\n", + status_reg, error_reg1, error_reg2); + + /* clear interrupt sources */ + spider_net_write_reg(card, SPIDER_NET_GHIINT1STS, error_reg1); + spider_net_write_reg(card, SPIDER_NET_GHIINT2STS, error_reg2); +} + +/** + * spider_net_interrupt - interrupt handler for spider_net + * @irq: interupt number + * @ptr: pointer to net_device + * @regs: PU registers + * + * returns IRQ_HANDLED, if interrupt was for driver, or IRQ_NONE, if no + * interrupt found raised by card. + * + * This is the interrupt handler, that turns off + * interrupts for this device and makes the stack poll the driver + */ +static irqreturn_t +spider_net_interrupt(int irq, void *ptr, struct pt_regs *regs) +{ + struct net_device *netdev = ptr; + struct spider_net_card *card = netdev_priv(netdev); + u32 status_reg; + + status_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0STS); + + if (!status_reg) + return IRQ_NONE; + + if (status_reg & SPIDER_NET_TXINT) + spider_net_release_tx_chain(card, 0); + + if (status_reg & SPIDER_NET_RXINT ) { + spider_net_rx_irq_off(card); + netif_rx_schedule(netdev); + } + + /* we do this after rx and tx processing, as we want the tx chain + * processed to see, whether we should restart tx dma processing */ + spider_net_handle_error_irq(card, status_reg); + + /* clear interrupt sources */ + spider_net_write_reg(card, SPIDER_NET_GHIINT0STS, status_reg); + + return IRQ_HANDLED; +} + +#ifdef CONFIG_NET_POLL_CONTROLLER +/** + * spider_net_poll_controller - artificial interrupt for netconsole etc. + * @netdev: interface device structure + * + * see Documentation/networking/netconsole.txt + */ +static void +spider_net_poll_controller(struct net_device *netdev) +{ + disable_irq(netdev->irq); + spider_net_interrupt(netdev->irq, netdev, NULL); + enable_irq(netdev->irq); +} +#endif /* CONFIG_NET_POLL_CONTROLLER */ + +/** + * spider_net_init_card - initializes the card + * @card: card structure + * + * spider_net_init_card initializes the card so that other registers can + * be used + */ +static void +spider_net_init_card(struct spider_net_card *card) +{ + spider_net_write_reg(card, SPIDER_NET_CKRCTRL, + SPIDER_NET_CKRCTRL_STOP_VALUE); + + spider_net_write_reg(card, SPIDER_NET_CKRCTRL, + SPIDER_NET_CKRCTRL_RUN_VALUE); +} + +/** + * spider_net_enable_card - enables the card by setting all kinds of regs + * @card: card structure + * + * spider_net_enable_card sets a lot of SMMIO registers to enable the device + */ +static void +spider_net_enable_card(struct spider_net_card *card) +{ + int i; + /* the following array consists of (register),(value) pairs + * that are set in this function. A register of 0 ends the list */ + u32 regs[][2] = { + { SPIDER_NET_GRESUMINTNUM, 0 }, + { SPIDER_NET_GREINTNUM, 0 }, + + /* set interrupt frame number registers */ + /* clear the single DMA engine registers first */ + { SPIDER_NET_GFAFRMNUM, SPIDER_NET_GFXFRAMES_VALUE }, + { SPIDER_NET_GFBFRMNUM, SPIDER_NET_GFXFRAMES_VALUE }, + { SPIDER_NET_GFCFRMNUM, SPIDER_NET_GFXFRAMES_VALUE }, + { SPIDER_NET_GFDFRMNUM, SPIDER_NET_GFXFRAMES_VALUE }, + /* then set, what we really need */ + { SPIDER_NET_GFFRMNUM, SPIDER_NET_FRAMENUM_VALUE }, + + /* timer counter registers and stuff */ + { SPIDER_NET_GFREECNNUM, 0 }, + { SPIDER_NET_GONETIMENUM, 0 }, + { SPIDER_NET_GTOUTFRMNUM, 0 }, + + /* RX mode setting */ + { SPIDER_NET_GRXMDSET, SPIDER_NET_RXMODE_VALUE }, + /* TX mode setting */ + { SPIDER_NET_GTXMDSET, SPIDER_NET_TXMODE_VALUE }, + /* IPSEC mode setting */ + { SPIDER_NET_GIPSECINIT, SPIDER_NET_IPSECINIT_VALUE }, + + { SPIDER_NET_GFTRESTRT, SPIDER_NET_RESTART_VALUE }, + + { SPIDER_NET_GMRWOLCTRL, 0 }, + { SPIDER_NET_GTESTMD, 0 }, + + { SPIDER_NET_GMACINTEN, 0 }, + + /* flow control stuff */ + { SPIDER_NET_GMACAPAUSE, SPIDER_NET_MACAPAUSE_VALUE }, + { SPIDER_NET_GMACTXPAUSE, SPIDER_NET_TXPAUSE_VALUE }, + + { SPIDER_NET_GMACBSTLMT, SPIDER_NET_BURSTLMT_VALUE }, + { 0, 0} + }; + + i = 0; + while (regs[i][0]) { + spider_net_write_reg(card, regs[i][0], regs[i][1]); + i++; + } + + /* clear unicast filter table entries 1 to 14 */ + for (i = 1; i <= 14; i++) { + spider_net_write_reg(card, + SPIDER_NET_GMRUAFILnR + i * 8, + 0x00080000); + spider_net_write_reg(card, + SPIDER_NET_GMRUAFILnR + i * 8 + 4, + 0x00000000); + } + + spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, 0x08080000); + + spider_net_write_reg(card, SPIDER_NET_ECMODE, SPIDER_NET_ECMODE_VALUE); + + /* set chain tail adress for RX chains and + * enable DMA */ + spider_net_enable_rxchtails(card); + spider_net_enable_rxdmac(card); + + spider_net_write_reg(card, SPIDER_NET_GRXDMAEN, SPIDER_NET_WOL_VALUE); + + /* set chain tail adress for TX chain */ + spider_net_enable_txdmac(card); + + spider_net_write_reg(card, SPIDER_NET_GMACLENLMT, + SPIDER_NET_LENLMT_VALUE); + spider_net_write_reg(card, SPIDER_NET_GMACMODE, + SPIDER_NET_MACMODE_VALUE); + spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, + SPIDER_NET_OPMODE_VALUE); + + /* set interrupt mask registers */ + spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, + SPIDER_NET_INT0_MASK_VALUE); + spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, + SPIDER_NET_INT1_MASK_VALUE); + spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, + SPIDER_NET_INT2_MASK_VALUE); +} + +/** + * spider_net_open - called upon ifonfig up + * @netdev: interface device structure + * + * returns 0 on success, <0 on failure + * + * spider_net_open allocates all the descriptors and memory needed for + * operation, sets up multicast list and enables interrupts + */ +int +spider_net_open(struct net_device *netdev) +{ + struct spider_net_card *card = netdev_priv(netdev); + int result; + + result = -ENOMEM; + if (spider_net_init_chain(card, &card->tx_chain, + card->descr, tx_descriptors)) + goto alloc_tx_failed; + if (spider_net_init_chain(card, &card->rx_chain, + card->descr + tx_descriptors, rx_descriptors)) + goto alloc_rx_failed; + + /* allocate rx skbs */ + if (spider_net_alloc_rx_skbs(card)) + goto alloc_skbs_failed; + + spider_net_set_multi(netdev); + + /* further enhancement: setup hw vlan, if needed */ + + result = -EBUSY; + if (request_irq(netdev->irq, spider_net_interrupt, + SA_SHIRQ, netdev->name, netdev)) + goto register_int_failed; + + spider_net_enable_card(card); + + netif_start_queue(netdev); + netif_carrier_on(netdev); + netif_poll_enable(netdev); + + return 0; + +register_int_failed: + spider_net_free_rx_chain_contents(card); +alloc_skbs_failed: + spider_net_free_chain(card, &card->rx_chain); +alloc_rx_failed: + spider_net_free_chain(card, &card->tx_chain); +alloc_tx_failed: + return result; +} + +/** + * spider_net_setup_phy - setup PHY + * @card: card structure + * + * returns 0 on success, <0 on failure + * + * spider_net_setup_phy is used as part of spider_net_probe. Sets + * the PHY to 1000 Mbps + **/ +static int +spider_net_setup_phy(struct spider_net_card *card) +{ + struct mii_phy *phy = &card->phy; + + spider_net_write_reg(card, SPIDER_NET_GDTDMASEL, + SPIDER_NET_DMASEL_VALUE); + spider_net_write_reg(card, SPIDER_NET_GPCCTRL, + SPIDER_NET_PHY_CTRL_VALUE); + phy->mii_id = 1; + phy->dev = card->netdev; + phy->mdio_read = spider_net_read_phy; + phy->mdio_write = spider_net_write_phy; + + mii_phy_probe(phy, phy->mii_id); + + if (phy->def->ops->setup_forced) + phy->def->ops->setup_forced(phy, SPEED_1000, DUPLEX_FULL); + + /* the following two writes could be moved to sungem_phy.c */ + /* enable fiber mode */ + spider_net_write_phy(card->netdev, 1, MII_NCONFIG, 0x9020); + /* LEDs active in both modes, autosense prio = fiber */ + spider_net_write_phy(card->netdev, 1, MII_NCONFIG, 0x945f); + + phy->def->ops->read_link(phy); + pr_info("Found %s with %i Mbps, %s-duplex.\n", phy->def->name, + phy->speed, phy->duplex==1 ? "Full" : "Half"); + + return 0; +} + +/** + * spider_net_download_firmware - loads firmware into the adapter + * @card: card structure + * @firmware: firmware pointer + * + * spider_net_download_firmware loads the firmware opened by + * spider_net_init_firmware into the adapter. + */ +static void +spider_net_download_firmware(struct spider_net_card *card, + const struct firmware *firmware) +{ + int sequencer, i; + u32 *fw_ptr = (u32 *)firmware->data; + + /* stop sequencers */ + spider_net_write_reg(card, SPIDER_NET_GSINIT, + SPIDER_NET_STOP_SEQ_VALUE); + + for (sequencer = 0; sequencer < 6; sequencer++) { + spider_net_write_reg(card, + SPIDER_NET_GSnPRGADR + sequencer * 8, 0); + for (i = 0; i < SPIDER_NET_FIRMWARE_LEN; i++) { + spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + + sequencer * 8, *fw_ptr); + fw_ptr++; + } + } + + spider_net_write_reg(card, SPIDER_NET_GSINIT, + SPIDER_NET_RUN_SEQ_VALUE); +} + +/** + * spider_net_init_firmware - reads in firmware parts + * @card: card structure + * + * Returns 0 on success, <0 on failure + * + * spider_net_init_firmware opens the sequencer firmware and does some basic + * checks. This function opens and releases the firmware structure. A call + * to download the firmware is performed before the release. + * + * Firmware format + * =============== + * spider_fw.bin is expected to be a file containing 6*1024*4 bytes, 4k being + * the program for each sequencer. Use the command + * tail -q -n +2 Seq_code1_0x088.txt Seq_code2_0x090.txt \ + * Seq_code3_0x098.txt Seq_code4_0x0A0.txt Seq_code5_0x0A8.txt \ + * Seq_code6_0x0B0.txt | xxd -r -p -c4 > spider_fw.bin + * + * to generate spider_fw.bin, if you have sequencer programs with something + * like the following contents for each sequencer: + * <ONE LINE COMMENT> + * <FIRST 4-BYTES-WORD FOR SEQUENCER> + * <SECOND 4-BYTES-WORD FOR SEQUENCER> + * ... + * <1024th 4-BYTES-WORD FOR SEQUENCER> + */ +static int +spider_net_init_firmware(struct spider_net_card *card) +{ + const struct firmware *firmware; + int err = -EIO; + + if (request_firmware(&firmware, + SPIDER_NET_FIRMWARE_NAME, &card->pdev->dev) < 0) { + if (netif_msg_probe(card)) + pr_err("Couldn't read in sequencer data file %s.\n", + SPIDER_NET_FIRMWARE_NAME); + firmware = NULL; + goto out; + } + + if (firmware->size != 6 * SPIDER_NET_FIRMWARE_LEN * sizeof(u32)) { + if (netif_msg_probe(card)) + pr_err("Invalid size of sequencer data file %s.\n", + SPIDER_NET_FIRMWARE_NAME); + goto out; + } + + spider_net_download_firmware(card, firmware); + + err = 0; +out: + release_firmware(firmware); + + return err; +} + +/** + * spider_net_workaround_rxramfull - work around firmware bug + * @card: card structure + * + * no return value + **/ +static void +spider_net_workaround_rxramfull(struct spider_net_card *card) +{ + int i, sequencer = 0; + + /* cancel reset */ + spider_net_write_reg(card, SPIDER_NET_CKRCTRL, + SPIDER_NET_CKRCTRL_RUN_VALUE); + + /* empty sequencer data */ + for (sequencer = 0; sequencer < 6; sequencer++) { + spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + + sequencer * 8, 0x0); + for (i = 0; i < SPIDER_NET_FIRMWARE_LEN; i++) { + spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + + sequencer * 8, 0x0); + } + } + + /* set sequencer operation */ + spider_net_write_reg(card, SPIDER_NET_GSINIT, 0x000000fe); + + /* reset */ + spider_net_write_reg(card, SPIDER_NET_CKRCTRL, + SPIDER_NET_CKRCTRL_STOP_VALUE); +} + +/** + * spider_net_tx_timeout_task - task scheduled by the watchdog timeout + * function (to be called not under interrupt status) + * @data: data, is interface device structure + * + * called as task when tx hangs, resets interface (if interface is up) + */ +static void +spider_net_tx_timeout_task(void *data) +{ + struct net_device *netdev = data; + struct spider_net_card *card = netdev_priv(netdev); + + if (!(netdev->flags & IFF_UP)) + goto out; + + netif_device_detach(netdev); + spider_net_stop(netdev); + + spider_net_workaround_rxramfull(card); + spider_net_init_card(card); + + if (spider_net_setup_phy(card)) + goto out; + if (spider_net_init_firmware(card)) + goto out; + + spider_net_open(netdev); + spider_net_kick_tx_dma(card, card->tx_chain.head); + netif_device_attach(netdev); + +out: + atomic_dec(&card->tx_timeout_task_counter); +} + +/** + * spider_net_tx_timeout - called when the tx timeout watchdog kicks in. + * @netdev: interface device structure + * + * called, if tx hangs. Schedules a task that resets the interface + */ +static void +spider_net_tx_timeout(struct net_device *netdev) +{ + struct spider_net_card *card; + + card = netdev_priv(netdev); + atomic_inc(&card->tx_timeout_task_counter); + if (netdev->flags & IFF_UP) + schedule_work(&card->tx_timeout_task); + else + atomic_dec(&card->tx_timeout_task_counter); +} + +/** + * spider_net_setup_netdev_ops - initialization of net_device operations + * @netdev: net_device structure + * + * fills out function pointers in the net_device structure + */ +static void +spider_net_setup_netdev_ops(struct net_device *netdev) +{ + netdev->open = &spider_net_open; + netdev->stop = &spider_net_stop; + netdev->hard_start_xmit = &spider_net_xmit; + netdev->get_stats = &spider_net_get_stats; + netdev->set_multicast_list = &spider_net_set_multi; + netdev->set_mac_address = &spider_net_set_mac; + netdev->change_mtu = &spider_net_change_mtu; + netdev->do_ioctl = &spider_net_do_ioctl; + /* tx watchdog */ + netdev->tx_timeout = &spider_net_tx_timeout; + netdev->watchdog_timeo = SPIDER_NET_WATCHDOG_TIMEOUT; + /* NAPI */ + netdev->poll = &spider_net_poll; + netdev->weight = SPIDER_NET_NAPI_WEIGHT; + /* HW VLAN */ + netdev->vlan_rx_register = &spider_net_vlan_rx_reg; + netdev->vlan_rx_add_vid = &spider_net_vlan_rx_add; + netdev->vlan_rx_kill_vid = &spider_net_vlan_rx_kill; +#ifdef CONFIG_NET_POLL_CONTROLLER + /* poll controller */ + netdev->poll_controller = &spider_net_poll_controller; +#endif /* CONFIG_NET_POLL_CONTROLLER */ + /* ethtool ops */ + netdev->ethtool_ops = &spider_net_ethtool_ops; +} + +/** + * spider_net_setup_netdev - initialization of net_device + * @card: card structure + * + * Returns 0 on success or <0 on failure + * + * spider_net_setup_netdev initializes the net_device structure + **/ +static int +spider_net_setup_netdev(struct spider_net_card *card) +{ + int result; + struct net_device *netdev = card->netdev; + struct device_node *dn; + struct sockaddr addr; + u8 *mac; + + SET_MODULE_OWNER(netdev); + SET_NETDEV_DEV(netdev, &card->pdev->dev); + + pci_set_drvdata(card->pdev, netdev); + spin_lock_init(&card->intmask_lock); + netdev->irq = card->pdev->irq; + + card->options.rx_csum = SPIDER_NET_RX_CSUM_DEFAULT; + + spider_net_setup_netdev_ops(netdev); + + netdev->features = 0; + /* some time: NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | + * NETIF_F_HW_VLAN_FILTER */ + + netdev->irq = card->pdev->irq; + + dn = pci_device_to_OF_node(card->pdev); + if (!dn) + return -EIO; + + mac = (u8 *)get_property(dn, "local-mac-address", NULL); + if (!mac) + return -EIO; + memcpy(addr.sa_data, mac, ETH_ALEN); + + result = spider_net_set_mac(netdev, &addr); + if ((result) && (netif_msg_probe(card))) + pr_err("Failed to set MAC address: %i\n", result); + + result = register_netdev(netdev); + if (result) { + if (netif_msg_probe(card)) + pr_err("Couldn't register net_device: %i\n", + result); + return result; + } + + if (netif_msg_probe(card)) + pr_info("Initialized device %s.\n", netdev->name); + + return 0; +} + +/** + * spider_net_alloc_card - allocates net_device and card structure + * + * returns the card structure or NULL in case of errors + * + * the card and net_device structures are linked to each other + */ +static struct spider_net_card * +spider_net_alloc_card(void) +{ + struct net_device *netdev; + struct spider_net_card *card; + size_t alloc_size; + + alloc_size = sizeof (*card) + + sizeof (struct spider_net_descr) * rx_descriptors + + sizeof (struct spider_net_descr) * tx_descriptors; + netdev = alloc_etherdev(alloc_size); + if (!netdev) + return NULL; + + card = netdev_priv(netdev); + card->netdev = netdev; + card->msg_enable = SPIDER_NET_DEFAULT_MSG; + INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task, netdev); + init_waitqueue_head(&card->waitq); + atomic_set(&card->tx_timeout_task_counter, 0); + + return card; +} + +/** + * spider_net_undo_pci_setup - releases PCI ressources + * @card: card structure + * + * spider_net_undo_pci_setup releases the mapped regions + */ +static void +spider_net_undo_pci_setup(struct spider_net_card *card) +{ + iounmap(card->regs); + pci_release_regions(card->pdev); +} + +/** + * spider_net_setup_pci_dev - sets up the device in terms of PCI operations + * @card: card structure + * @pdev: PCI device + * + * Returns the card structure or NULL if any errors occur + * + * spider_net_setup_pci_dev initializes pdev and together with the + * functions called in spider_net_open configures the device so that + * data can be transferred over it + * The net_device structure is attached to the card structure, if the + * function returns without error. + **/ +static struct spider_net_card * +spider_net_setup_pci_dev(struct pci_dev *pdev) +{ + struct spider_net_card *card; + unsigned long mmio_start, mmio_len; + + if (pci_enable_device(pdev)) { + pr_err("Couldn't enable PCI device\n"); + return NULL; + } + + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { + pr_err("Couldn't find proper PCI device base address.\n"); + goto out_disable_dev; + } + + if (pci_request_regions(pdev, spider_net_driver_name)) { + pr_err("Couldn't obtain PCI resources, aborting.\n"); + goto out_disable_dev; + } + + pci_set_master(pdev); + + card = spider_net_alloc_card(); + if (!card) { + pr_err("Couldn't allocate net_device structure, " + "aborting.\n"); + goto out_release_regions; + } + card->pdev = pdev; + + /* fetch base address and length of first resource */ + mmio_start = pci_resource_start(pdev, 0); + mmio_len = pci_resource_len(pdev, 0); + + card->netdev->mem_start = mmio_start; + card->netdev->mem_end = mmio_start + mmio_len; + card->regs = ioremap(mmio_start, mmio_len); + + if (!card->regs) { + pr_err("Couldn't obtain PCI resources, aborting.\n"); + goto out_release_regions; + } + + return card; + +out_release_regions: + pci_release_regions(pdev); +out_disable_dev: + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); + return NULL; +} + +/** + * spider_net_probe - initialization of a device + * @pdev: PCI device + * @ent: entry in the device id list + * + * Returns 0 on success, <0 on failure + * + * spider_net_probe initializes pdev and registers a net_device + * structure for it. After that, the device can be ifconfig'ed up + **/ +static int __devinit +spider_net_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + int err = -EIO; + struct spider_net_card *card; + + card = spider_net_setup_pci_dev(pdev); + if (!card) + goto out; + + spider_net_workaround_rxramfull(card); + spider_net_init_card(card); + + err = spider_net_setup_phy(card); + if (err) + goto out_undo_pci; + + err = spider_net_init_firmware(card); + if (err) + goto out_undo_pci; + + err = spider_net_setup_netdev(card); + if (err) + goto out_undo_pci; + + return 0; + +out_undo_pci: + spider_net_undo_pci_setup(card); + free_netdev(card->netdev); +out: + return err; +} + +/** + * spider_net_remove - removal of a device + * @pdev: PCI device + * + * Returns 0 on success, <0 on failure + * + * spider_net_remove is called to remove the device and unregisters the + * net_device + **/ +static void __devexit +spider_net_remove(struct pci_dev *pdev) +{ + struct net_device *netdev; + struct spider_net_card *card; + + netdev = pci_get_drvdata(pdev); + card = netdev_priv(netdev); + + wait_event(card->waitq, + atomic_read(&card->tx_timeout_task_counter) == 0); + + unregister_netdev(netdev); + + /* switch off card */ + spider_net_write_reg(card, SPIDER_NET_CKRCTRL, + SPIDER_NET_CKRCTRL_STOP_VALUE); + spider_net_write_reg(card, SPIDER_NET_CKRCTRL, + SPIDER_NET_CKRCTRL_RUN_VALUE); + + spider_net_undo_pci_setup(card); + free_netdev(netdev); +} + +static struct pci_driver spider_net_driver = { + .owner = THIS_MODULE, + .name = spider_net_driver_name, + .id_table = spider_net_pci_tbl, + .probe = spider_net_probe, + .remove = __devexit_p(spider_net_remove) +}; + +/** + * spider_net_init - init function when the driver is loaded + * + * spider_net_init registers the device driver + */ +static int __init spider_net_init(void) +{ + if (rx_descriptors < SPIDER_NET_RX_DESCRIPTORS_MIN) { + rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_MIN; + pr_info("adjusting rx descriptors to %i.\n", rx_descriptors); + } + if (rx_descriptors > SPIDER_NET_RX_DESCRIPTORS_MAX) { + rx_descriptors = SPIDER_NET_RX_DESCRIPTORS_MAX; + pr_info("adjusting rx descriptors to %i.\n", rx_descriptors); + } + if (tx_descriptors < SPIDER_NET_TX_DESCRIPTORS_MIN) { + tx_descriptors = SPIDER_NET_TX_DESCRIPTORS_MIN; + pr_info("adjusting tx descriptors to %i.\n", tx_descriptors); + } + if (tx_descriptors > SPIDER_NET_TX_DESCRIPTORS_MAX) { + tx_descriptors = SPIDER_NET_TX_DESCRIPTORS_MAX; + pr_info("adjusting tx descriptors to %i.\n", tx_descriptors); + } + + return pci_register_driver(&spider_net_driver); +} + +/** + * spider_net_cleanup - exit function when driver is unloaded + * + * spider_net_cleanup unregisters the device driver + */ +static void __exit spider_net_cleanup(void) +{ + pci_unregister_driver(&spider_net_driver); +} + +module_init(spider_net_init); +module_exit(spider_net_cleanup); diff --git a/drivers/net/spider_net.h b/drivers/net/spider_net.h new file mode 100644 index 00000000000..22b2f234735 --- /dev/null +++ b/drivers/net/spider_net.h @@ -0,0 +1,469 @@ +/* + * Network device driver for Cell Processor-Based Blade + * + * (C) Copyright IBM Corp. 2005 + * + * Authors : Utz Bacher <utz.bacher@de.ibm.com> + * Jens Osterkamp <Jens.Osterkamp@de.ibm.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef _SPIDER_NET_H +#define _SPIDER_NET_H + +#include "sungem_phy.h" + +extern int spider_net_stop(struct net_device *netdev); +extern int spider_net_open(struct net_device *netdev); + +extern struct ethtool_ops spider_net_ethtool_ops; + +extern char spider_net_driver_name[]; + +#define SPIDER_NET_MAX_MTU 2308 +#define SPIDER_NET_MIN_MTU 64 + +#define SPIDER_NET_RXBUF_ALIGN 128 + +#define SPIDER_NET_RX_DESCRIPTORS_DEFAULT 64 +#define SPIDER_NET_RX_DESCRIPTORS_MIN 16 +#define SPIDER_NET_RX_DESCRIPTORS_MAX 256 + +#define SPIDER_NET_TX_DESCRIPTORS_DEFAULT 64 +#define SPIDER_NET_TX_DESCRIPTORS_MIN 16 +#define SPIDER_NET_TX_DESCRIPTORS_MAX 256 + +#define SPIDER_NET_RX_CSUM_DEFAULT 1 + +#define SPIDER_NET_WATCHDOG_TIMEOUT 5*HZ +#define SPIDER_NET_NAPI_WEIGHT 64 + +#define SPIDER_NET_FIRMWARE_LEN 1024 +#define SPIDER_NET_FIRMWARE_NAME "spider_fw.bin" + +/** spider_net SMMIO registers */ +#define SPIDER_NET_GHIINT0STS 0x00000000 +#define SPIDER_NET_GHIINT1STS 0x00000004 +#define SPIDER_NET_GHIINT2STS 0x00000008 +#define SPIDER_NET_GHIINT0MSK 0x00000010 +#define SPIDER_NET_GHIINT1MSK 0x00000014 +#define SPIDER_NET_GHIINT2MSK 0x00000018 + +#define SPIDER_NET_GRESUMINTNUM 0x00000020 +#define SPIDER_NET_GREINTNUM 0x00000024 + +#define SPIDER_NET_GFFRMNUM 0x00000028 +#define SPIDER_NET_GFAFRMNUM 0x0000002c +#define SPIDER_NET_GFBFRMNUM 0x00000030 +#define SPIDER_NET_GFCFRMNUM 0x00000034 +#define SPIDER_NET_GFDFRMNUM 0x00000038 + +/* clear them (don't use it) */ +#define SPIDER_NET_GFREECNNUM 0x0000003c +#define SPIDER_NET_GONETIMENUM 0x00000040 + +#define SPIDER_NET_GTOUTFRMNUM 0x00000044 + +#define SPIDER_NET_GTXMDSET 0x00000050 +#define SPIDER_NET_GPCCTRL 0x00000054 +#define SPIDER_NET_GRXMDSET 0x00000058 +#define SPIDER_NET_GIPSECINIT 0x0000005c +#define SPIDER_NET_GFTRESTRT 0x00000060 +#define SPIDER_NET_GRXDMAEN 0x00000064 +#define SPIDER_NET_GMRWOLCTRL 0x00000068 +#define SPIDER_NET_GPCWOPCMD 0x0000006c +#define SPIDER_NET_GPCROPCMD 0x00000070 +#define SPIDER_NET_GTTFRMCNT 0x00000078 +#define SPIDER_NET_GTESTMD 0x0000007c + +#define SPIDER_NET_GSINIT 0x00000080 +#define SPIDER_NET_GSnPRGADR 0x00000084 +#define SPIDER_NET_GSnPRGDAT 0x00000088 + +#define SPIDER_NET_GMACOPEMD 0x00000100 +#define SPIDER_NET_GMACLENLMT 0x00000108 +#define SPIDER_NET_GMACINTEN 0x00000118 +#define SPIDER_NET_GMACPHYCTRL 0x00000120 + +#define SPIDER_NET_GMACAPAUSE 0x00000154 +#define SPIDER_NET_GMACTXPAUSE 0x00000164 + +#define SPIDER_NET_GMACMODE 0x000001b0 +#define SPIDER_NET_GMACBSTLMT 0x000001b4 + +#define SPIDER_NET_GMACUNIMACU 0x000001c0 +#define SPIDER_NET_GMACUNIMACL 0x000001c8 + +#define SPIDER_NET_GMRMHFILnR 0x00000400 +#define SPIDER_NET_MULTICAST_HASHES 256 + +#define SPIDER_NET_GMRUAFILnR 0x00000500 +#define SPIDER_NET_GMRUA0FIL15R 0x00000578 + +/* RX DMA controller registers, all 0x00000a.. are for DMA controller A, + * 0x00000b.. for DMA controller B, etc. */ +#define SPIDER_NET_GDADCHA 0x00000a00 +#define SPIDER_NET_GDADMACCNTR 0x00000a04 +#define SPIDER_NET_GDACTDPA 0x00000a08 +#define SPIDER_NET_GDACTDCNT 0x00000a0c +#define SPIDER_NET_GDACDBADDR 0x00000a20 +#define SPIDER_NET_GDACDBSIZE 0x00000a24 +#define SPIDER_NET_GDACNEXTDA 0x00000a28 +#define SPIDER_NET_GDACCOMST 0x00000a2c +#define SPIDER_NET_GDAWBCOMST 0x00000a30 +#define SPIDER_NET_GDAWBRSIZE 0x00000a34 +#define SPIDER_NET_GDAWBVSIZE 0x00000a38 +#define SPIDER_NET_GDAWBTRST 0x00000a3c +#define SPIDER_NET_GDAWBTRERR 0x00000a40 + +/* TX DMA controller registers */ +#define SPIDER_NET_GDTDCHA 0x00000e00 +#define SPIDER_NET_GDTDMACCNTR 0x00000e04 +#define SPIDER_NET_GDTCDPA 0x00000e08 +#define SPIDER_NET_GDTDMASEL 0x00000e14 + +#define SPIDER_NET_ECMODE 0x00000f00 +/* clock and reset control register */ +#define SPIDER_NET_CKRCTRL 0x00000ff0 + +/** SCONFIG registers */ +#define SPIDER_NET_SCONFIG_IOACTE 0x00002810 + +/** hardcoded register values */ +#define SPIDER_NET_INT0_MASK_VALUE 0x3f7fe3ff +#define SPIDER_NET_INT1_MASK_VALUE 0xffffffff +/* no MAC aborts -> auto retransmission */ +#define SPIDER_NET_INT2_MASK_VALUE 0xfffffff1 + +/* clear counter when interrupt sources are cleared +#define SPIDER_NET_FRAMENUM_VALUE 0x0001f001 */ +/* we rely on flagged descriptor interrupts */ +#define SPIDER_NET_FRAMENUM_VALUE 0x00000000 +/* set this first, then the FRAMENUM_VALUE */ +#define SPIDER_NET_GFXFRAMES_VALUE 0x00000000 + +#define SPIDER_NET_STOP_SEQ_VALUE 0x00000000 +#define SPIDER_NET_RUN_SEQ_VALUE 0x0000007e + +#define SPIDER_NET_PHY_CTRL_VALUE 0x00040040 +/* #define SPIDER_NET_PHY_CTRL_VALUE 0x01070080*/ +#define SPIDER_NET_RXMODE_VALUE 0x00000011 +/* auto retransmission in case of MAC aborts */ +#define SPIDER_NET_TXMODE_VALUE 0x00010000 +#define SPIDER_NET_RESTART_VALUE 0x00000000 +#define SPIDER_NET_WOL_VALUE 0x00001111 +#if 0 +#define SPIDER_NET_WOL_VALUE 0x00000000 +#endif +#define SPIDER_NET_IPSECINIT_VALUE 0x00f000f8 + +/* pause frames: automatic, no upper retransmission count */ +/* outside loopback mode: ETOMOD signal dont matter, not connected */ +#define SPIDER_NET_OPMODE_VALUE 0x00000063 +/*#define SPIDER_NET_OPMODE_VALUE 0x001b0062*/ +#define SPIDER_NET_LENLMT_VALUE 0x00000908 + +#define SPIDER_NET_MACAPAUSE_VALUE 0x00000800 /* about 1 ms */ +#define SPIDER_NET_TXPAUSE_VALUE 0x00000000 + +#define SPIDER_NET_MACMODE_VALUE 0x00000001 +#define SPIDER_NET_BURSTLMT_VALUE 0x00000200 /* about 16 us */ + +/* 1(0) enable r/tx dma + * 0000000 fixed to 0 + * + * 000000 fixed to 0 + * 0(1) en/disable descr writeback on force end + * 0(1) force end + * + * 000000 fixed to 0 + * 00 burst alignment: 128 bytes + * + * 00000 fixed to 0 + * 0 descr writeback size 32 bytes + * 0(1) descr chain end interrupt enable + * 0(1) descr status writeback enable */ + +/* to set RX_DMA_EN */ +#define SPIDER_NET_DMA_RX_VALUE 0x80000000 +#define SPIDER_NET_DMA_RX_FEND_VALUE 0x00030003 +/* to set TX_DMA_EN */ +#define SPIDER_NET_DMA_TX_VALUE 0x80000000 +#define SPIDER_NET_DMA_TX_FEND_VALUE 0x00030003 + +/* SPIDER_NET_UA_DESCR_VALUE is OR'ed with the unicast address */ +#define SPIDER_NET_UA_DESCR_VALUE 0x00080000 +#define SPIDER_NET_PROMISC_VALUE 0x00080000 +#define SPIDER_NET_NONPROMISC_VALUE 0x00000000 + +#define SPIDER_NET_DMASEL_VALUE 0x00000001 + +#define SPIDER_NET_ECMODE_VALUE 0x00000000 + +#define SPIDER_NET_CKRCTRL_RUN_VALUE 0x1fff010f +#define SPIDER_NET_CKRCTRL_STOP_VALUE 0x0000010f + +#define SPIDER_NET_SBIMSTATE_VALUE 0x00000000 +#define SPIDER_NET_SBTMSTATE_VALUE 0x00000000 + +/* SPIDER_NET_GHIINT0STS bits, in reverse order so that they can be used + * with 1 << SPIDER_NET_... */ +enum spider_net_int0_status { + SPIDER_NET_GPHYINT = 0, + SPIDER_NET_GMAC2INT, + SPIDER_NET_GMAC1INT, + SPIDER_NET_GIPSINT, + SPIDER_NET_GFIFOINT, + SPIDER_NET_GDMACINT, + SPIDER_NET_GSYSINT, + SPIDER_NET_GPWOPCMPINT, + SPIDER_NET_GPROPCMPINT, + SPIDER_NET_GPWFFINT, + SPIDER_NET_GRMDADRINT, + SPIDER_NET_GRMARPINT, + SPIDER_NET_GRMMPINT, + SPIDER_NET_GDTDEN0INT, + SPIDER_NET_GDDDEN0INT, + SPIDER_NET_GDCDEN0INT, + SPIDER_NET_GDBDEN0INT, + SPIDER_NET_GDADEN0INT, + SPIDER_NET_GDTFDCINT, + SPIDER_NET_GDDFDCINT, + SPIDER_NET_GDCFDCINT, + SPIDER_NET_GDBFDCINT, + SPIDER_NET_GDAFDCINT, + SPIDER_NET_GTTEDINT, + SPIDER_NET_GDTDCEINT, + SPIDER_NET_GRFDNMINT, + SPIDER_NET_GRFCNMINT, + SPIDER_NET_GRFBNMINT, + SPIDER_NET_GRFANMINT, + SPIDER_NET_GRFNMINT, + SPIDER_NET_G1TMCNTINT, + SPIDER_NET_GFREECNTINT +}; +/* GHIINT1STS bits */ +enum spider_net_int1_status { + SPIDER_NET_GTMFLLINT = 0, + SPIDER_NET_GRMFLLINT, + SPIDER_NET_GTMSHTINT, + SPIDER_NET_GDTINVDINT, + SPIDER_NET_GRFDFLLINT, + SPIDER_NET_GDDDCEINT, + SPIDER_NET_GDDINVDINT, + SPIDER_NET_GRFCFLLINT, + SPIDER_NET_GDCDCEINT, + SPIDER_NET_GDCINVDINT, + SPIDER_NET_GRFBFLLINT, + SPIDER_NET_GDBDCEINT, + SPIDER_NET_GDBINVDINT, + SPIDER_NET_GRFAFLLINT, + SPIDER_NET_GDADCEINT, + SPIDER_NET_GDAINVDINT, + SPIDER_NET_GDTRSERINT, + SPIDER_NET_GDDRSERINT, + SPIDER_NET_GDCRSERINT, + SPIDER_NET_GDBRSERINT, + SPIDER_NET_GDARSERINT, + SPIDER_NET_GDSERINT, + SPIDER_NET_GDTPTERINT, + SPIDER_NET_GDDPTERINT, + SPIDER_NET_GDCPTERINT, + SPIDER_NET_GDBPTERINT, + SPIDER_NET_GDAPTERINT +}; +/* GHIINT2STS bits */ +enum spider_net_int2_status { + SPIDER_NET_GPROPERINT = 0, + SPIDER_NET_GMCTCRSNGINT, + SPIDER_NET_GMCTLCOLINT, + SPIDER_NET_GMCTTMOTINT, + SPIDER_NET_GMCRCAERINT, + SPIDER_NET_GMCRCALERINT, + SPIDER_NET_GMCRALNERINT, + SPIDER_NET_GMCROVRINT, + SPIDER_NET_GMCRRNTINT, + SPIDER_NET_GMCRRXERINT, + SPIDER_NET_GTITCSERINT, + SPIDER_NET_GTIFMTERINT, + SPIDER_NET_GTIPKTRVKINT, + SPIDER_NET_GTISPINGINT, + SPIDER_NET_GTISADNGINT, + SPIDER_NET_GTISPDNGINT, + SPIDER_NET_GRIFMTERINT, + SPIDER_NET_GRIPKTRVKINT, + SPIDER_NET_GRISPINGINT, + SPIDER_NET_GRISADNGINT, + SPIDER_NET_GRISPDNGINT +}; + +#define SPIDER_NET_TXINT ( (1 << SPIDER_NET_GTTEDINT) | \ + (1 << SPIDER_NET_GDTDCEINT) | \ + (1 << SPIDER_NET_GDTFDCINT) ) + +/* we rely on flagged descriptor interrupts*/ +#define SPIDER_NET_RXINT ( (1 << SPIDER_NET_GDAFDCINT) | \ + (1 << SPIDER_NET_GRMFLLINT) ) + +#define SPIDER_NET_GPREXEC 0x80000000 +#define SPIDER_NET_GPRDAT_MASK 0x0000ffff + +/* descriptor bits + * + * 1010 descriptor ready + * 0 descr in middle of chain + * 000 fixed to 0 + * + * 0 no interrupt on completion + * 000 fixed to 0 + * 1 no ipsec processing + * 1 last descriptor for this frame + * 00 no checksum + * 10 tcp checksum + * 11 udp checksum + * + * 00 fixed to 0 + * 0 fixed to 0 + * 0 no interrupt on response errors + * 0 no interrupt on invalid descr + * 0 no interrupt on dma process termination + * 0 no interrupt on descr chain end + * 0 no interrupt on descr complete + * + * 000 fixed to 0 + * 0 response error interrupt status + * 0 invalid descr status + * 0 dma termination status + * 0 descr chain end status + * 0 descr complete status */ +#define SPIDER_NET_DMAC_CMDSTAT_NOCS 0xa00c0000 +#define SPIDER_NET_DMAC_CMDSTAT_TCPCS 0xa00e0000 +#define SPIDER_NET_DMAC_CMDSTAT_UDPCS 0xa00f0000 +#define SPIDER_NET_DESCR_IND_PROC_SHIFT 28 +#define SPIDER_NET_DESCR_IND_PROC_MASKO 0x0fffffff + +/* descr ready, descr is in middle of chain, get interrupt on completion */ +#define SPIDER_NET_DMAC_RX_CARDOWNED 0xa0800000 + +/* multicast is no problem */ +#define SPIDER_NET_DATA_ERROR_MASK 0xffffbfff + +enum spider_net_descr_status { + SPIDER_NET_DESCR_COMPLETE = 0x00, /* used in rx and tx */ + SPIDER_NET_DESCR_RESPONSE_ERROR = 0x01, /* used in rx and tx */ + SPIDER_NET_DESCR_PROTECTION_ERROR = 0x02, /* used in rx and tx */ + SPIDER_NET_DESCR_FRAME_END = 0x04, /* used in rx */ + SPIDER_NET_DESCR_FORCE_END = 0x05, /* used in rx and tx */ + SPIDER_NET_DESCR_CARDOWNED = 0x0a, /* used in rx and tx */ + SPIDER_NET_DESCR_NOT_IN_USE /* any other value */ +}; + +struct spider_net_descr { + /* as defined by the hardware */ + dma_addr_t buf_addr; + u32 buf_size; + dma_addr_t next_descr_addr; + u32 dmac_cmd_status; + u32 result_size; + u32 valid_size; /* all zeroes for tx */ + u32 data_status; + u32 data_error; /* all zeroes for tx */ + + /* used in the driver */ + struct sk_buff *skb; + dma_addr_t bus_addr; + struct spider_net_descr *next; + struct spider_net_descr *prev; +} __attribute__((aligned(32))); + +struct spider_net_descr_chain { + /* we walk from tail to head */ + struct spider_net_descr *head; + struct spider_net_descr *tail; +}; + +/* descriptor data_status bits */ +#define SPIDER_NET_RXIPCHK 29 +#define SPIDER_NET_TCPUDPIPCHK 28 +#define SPIDER_NET_DATA_STATUS_CHK_MASK (1 << SPIDER_NET_RXIPCHK | \ + 1 << SPIDER_NET_TCPUDPIPCHK) + +#define SPIDER_NET_VLAN_PACKET 21 + +/* descriptor data_error bits */ +#define SPIDER_NET_RXIPCHKERR 27 +#define SPIDER_NET_RXTCPCHKERR 26 +#define SPIDER_NET_DATA_ERROR_CHK_MASK (1 << SPIDER_NET_RXIPCHKERR | \ + 1 << SPIDER_NET_RXTCPCHKERR) + +/* the cases we don't pass the packet to the stack */ +#define SPIDER_NET_DESTROY_RX_FLAGS 0x70138000 + +#define SPIDER_NET_DESCR_SIZE 32 + +/* this will be bigger some time */ +struct spider_net_options { + int rx_csum; /* for rx: if 0 ip_summed=NONE, + if 1 and hw has verified, ip_summed=UNNECESSARY */ +}; + +#define SPIDER_NET_DEFAULT_MSG ( NETIF_MSG_DRV | \ + NETIF_MSG_PROBE | \ + NETIF_MSG_LINK | \ + NETIF_MSG_TIMER | \ + NETIF_MSG_IFDOWN | \ + NETIF_MSG_IFUP | \ + NETIF_MSG_RX_ERR | \ + NETIF_MSG_TX_ERR | \ + NETIF_MSG_TX_QUEUED | \ + NETIF_MSG_INTR | \ + NETIF_MSG_TX_DONE | \ + NETIF_MSG_RX_STATUS | \ + NETIF_MSG_PKTDATA | \ + NETIF_MSG_HW | \ + NETIF_MSG_WOL ) + +struct spider_net_card { + struct net_device *netdev; + struct pci_dev *pdev; + struct mii_phy phy; + + void __iomem *regs; + + struct spider_net_descr_chain tx_chain; + struct spider_net_descr_chain rx_chain; + spinlock_t chain_lock; + + struct net_device_stats netdev_stats; + + struct spider_net_options options; + + spinlock_t intmask_lock; + + struct work_struct tx_timeout_task; + atomic_t tx_timeout_task_counter; + wait_queue_head_t waitq; + + /* for ethtool */ + int msg_enable; + + struct spider_net_descr descr[0]; +}; + +#define pr_err(fmt,arg...) \ + printk(KERN_ERR fmt ,##arg) + +#endif diff --git a/drivers/net/spider_net_ethtool.c b/drivers/net/spider_net_ethtool.c new file mode 100644 index 00000000000..d42e60ba74c --- /dev/null +++ b/drivers/net/spider_net_ethtool.c @@ -0,0 +1,126 @@ +/* + * Network device driver for Cell Processor-Based Blade + * + * (C) Copyright IBM Corp. 2005 + * + * Authors : Utz Bacher <utz.bacher@de.ibm.com> + * Jens Osterkamp <Jens.Osterkamp@de.ibm.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <linux/netdevice.h> +#include <linux/ethtool.h> +#include <linux/pci.h> + +#include "spider_net.h" + +static int +spider_net_ethtool_get_settings(struct net_device *netdev, + struct ethtool_cmd *cmd) +{ + struct spider_net_card *card; + card = netdev_priv(netdev); + + cmd->supported = (SUPPORTED_1000baseT_Full | + SUPPORTED_FIBRE); + cmd->advertising = (ADVERTISED_1000baseT_Full | + ADVERTISED_FIBRE); + cmd->port = PORT_FIBRE; + cmd->speed = card->phy.speed; + cmd->duplex = DUPLEX_FULL; + + return 0; +} + +static void +spider_net_ethtool_get_drvinfo(struct net_device *netdev, + struct ethtool_drvinfo *drvinfo) +{ + struct spider_net_card *card; + card = netdev_priv(netdev); + + /* clear and fill out info */ + memset(drvinfo, 0, sizeof(struct ethtool_drvinfo)); + strncpy(drvinfo->driver, spider_net_driver_name, 32); + strncpy(drvinfo->version, "0.1", 32); + strcpy(drvinfo->fw_version, "no information"); + strncpy(drvinfo->bus_info, pci_name(card->pdev), 32); +} + +static void +spider_net_ethtool_get_wol(struct net_device *netdev, + struct ethtool_wolinfo *wolinfo) +{ + /* no support for wol */ + wolinfo->supported = 0; + wolinfo->wolopts = 0; +} + +static u32 +spider_net_ethtool_get_msglevel(struct net_device *netdev) +{ + struct spider_net_card *card; + card = netdev_priv(netdev); + return card->msg_enable; +} + +static void +spider_net_ethtool_set_msglevel(struct net_device *netdev, + u32 level) +{ + struct spider_net_card *card; + card = netdev_priv(netdev); + card->msg_enable = level; +} + +static int +spider_net_ethtool_nway_reset(struct net_device *netdev) +{ + if (netif_running(netdev)) { + spider_net_stop(netdev); + spider_net_open(netdev); + } + return 0; +} + +static u32 +spider_net_ethtool_get_rx_csum(struct net_device *netdev) +{ + struct spider_net_card *card = netdev->priv; + + return card->options.rx_csum; +} + +static int +spider_net_ethtool_set_rx_csum(struct net_device *netdev, u32 n) +{ + struct spider_net_card *card = netdev->priv; + + card->options.rx_csum = n; + return 0; +} + +struct ethtool_ops spider_net_ethtool_ops = { + .get_settings = spider_net_ethtool_get_settings, + .get_drvinfo = spider_net_ethtool_get_drvinfo, + .get_wol = spider_net_ethtool_get_wol, + .get_msglevel = spider_net_ethtool_get_msglevel, + .set_msglevel = spider_net_ethtool_set_msglevel, + .nway_reset = spider_net_ethtool_nway_reset, + .get_rx_csum = spider_net_ethtool_get_rx_csum, + .set_rx_csum = spider_net_ethtool_set_rx_csum, +}; + diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c index 1f43bbfbc1c..5c8fcd40ef4 100644 --- a/drivers/net/sun3lance.c +++ b/drivers/net/sun3lance.c @@ -162,7 +162,7 @@ struct lance_private { #define MEM lp->mem #define DREG lp->iobase[0] #define AREG lp->iobase[1] -#define REGA(a) ( AREG = (a), DREG ) +#define REGA(a) (*( AREG = (a), &DREG )) /* Definitions for the Lance */ diff --git a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c index f58c794a963..b56a7b516d2 100644 --- a/drivers/net/wan/syncppp.c +++ b/drivers/net/wan/syncppp.c @@ -1440,6 +1440,7 @@ static void sppp_print_bytes (u_char *p, u16 len) * @skb: The buffer to process * @dev: The device it arrived on * @p: Unused + * @orig_dev: Unused * * Protocol glue. This drives the deferred processing mode the poorer * cards use. This can be called directly by cards that do not have diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index dbcb5a8a219..2be65d308fb 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c @@ -3258,7 +3258,7 @@ badrx: wstats.noise = apriv->wstats.qual.noise; wstats.updated = IW_QUAL_LEVEL_UPDATED | IW_QUAL_QUAL_UPDATED - | IW_QUAL_NOISE_UPDATED; + | IW_QUAL_DBM; /* Update spy records */ wireless_spy_update(dev, sa, &wstats); } @@ -3604,7 +3604,7 @@ void mpi_receive_802_11 (struct airo_info *ai) wstats.noise = ai->wstats.qual.noise; wstats.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED - | IW_QUAL_NOISE_UPDATED; + | IW_QUAL_DBM; /* Update spy records */ wireless_spy_update(ai->dev, sa, &wstats); } @@ -6489,22 +6489,20 @@ static int airo_get_range(struct net_device *dev, range->max_qual.qual = 100; /* % */ else range->max_qual.qual = airo_get_max_quality(&cap_rid); - range->max_qual.level = 0; /* 0 means we use dBm */ - range->max_qual.noise = 0; - range->max_qual.updated = 0; + range->max_qual.level = 0x100 - 120; /* -120 dBm */ + range->max_qual.noise = 0x100 - 120; /* -120 dBm */ /* Experimental measurements - boundary 11/5.5 Mb/s */ /* Note : with or without the (local->rssi), results * are somewhat different. - Jean II */ if (local->rssi) { - range->avg_qual.qual = 50; /* % */ - range->avg_qual.level = 186; /* -70 dBm */ + range->avg_qual.qual = 50; /* % */ + range->avg_qual.level = 0x100 - 70; /* -70 dBm */ } else { range->avg_qual.qual = airo_get_avg_quality(&cap_rid); - range->avg_qual.level = 176; /* -80 dBm */ + range->avg_qual.level = 0x100 - 80; /* -80 dBm */ } - range->avg_qual.noise = 0; - range->avg_qual.updated = 0; + range->avg_qual.noise = 0x100 - 85; /* -85 dBm */ for(i = 0 ; i < 8 ; i++) { range->bitrate[i] = cap_rid.supportedRates[i] * 500000; @@ -6727,15 +6725,17 @@ static int airo_get_aplist(struct net_device *dev, if (local->rssi) { qual[i].level = 0x100 - BSSList.dBm; qual[i].qual = airo_dbm_to_pct( local->rssi, BSSList.dBm ); - qual[i].updated = IW_QUAL_QUAL_UPDATED; + qual[i].updated = IW_QUAL_QUAL_UPDATED + | IW_QUAL_LEVEL_UPDATED + | IW_QUAL_DBM; } else { qual[i].level = (BSSList.dBm + 321) / 2; qual[i].qual = 0; - qual[i].updated = IW_QUAL_QUAL_INVALID; + qual[i].updated = IW_QUAL_QUAL_INVALID + | IW_QUAL_LEVEL_UPDATED + | IW_QUAL_DBM; } qual[i].noise = local->wstats.qual.noise; - qual[i].updated = IW_QUAL_LEVEL_UPDATED - | IW_QUAL_NOISE_UPDATED; if (BSSList.index == 0xffff) break; } @@ -6861,15 +6861,17 @@ static inline char *airo_translate_scan(struct net_device *dev, if (ai->rssi) { iwe.u.qual.level = 0x100 - bss->dBm; iwe.u.qual.qual = airo_dbm_to_pct( ai->rssi, bss->dBm ); - iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED; + iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED + | IW_QUAL_LEVEL_UPDATED + | IW_QUAL_DBM; } else { iwe.u.qual.level = (bss->dBm + 321) / 2; iwe.u.qual.qual = 0; - iwe.u.qual.updated = IW_QUAL_QUAL_INVALID; + iwe.u.qual.updated = IW_QUAL_QUAL_INVALID + | IW_QUAL_LEVEL_UPDATED + | IW_QUAL_DBM; } iwe.u.qual.noise = ai->wstats.qual.noise; - iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED - | IW_QUAL_NOISE_UPDATED; current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); /* Add encryption capability */ @@ -7222,13 +7224,12 @@ static void airo_read_wireless_stats(struct airo_info *local) local->wstats.qual.level = (status_rid.normalizedSignalStrength + 321) / 2; local->wstats.qual.qual = airo_get_quality(&status_rid, &cap_rid); } - local->wstats.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED; if (status_rid.len >= 124) { local->wstats.qual.noise = 0x100 - status_rid.noisedBm; - local->wstats.qual.updated |= IW_QUAL_NOISE_UPDATED; + local->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; } else { local->wstats.qual.noise = 0; - local->wstats.qual.updated |= IW_QUAL_NOISE_INVALID; + local->wstats.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID | IW_QUAL_DBM; } /* Packets discarded in the wireless adapter due to wireless diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index f48a6e72922..587869d86ee 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c @@ -1593,7 +1593,6 @@ struct net_device *init_atmel_card( unsigned short irq, int port, const AtmelFWT dev->set_mac_address = atmel_set_mac_address; dev->hard_start_xmit = start_tx; dev->get_stats = atmel_get_stats; - dev->get_wireless_stats = atmel_get_wireless_stats; dev->wireless_handlers = (struct iw_handler_def *)&atmel_handler_def; dev->do_ioctl = atmel_ioctl; dev->irq = irq; @@ -2411,7 +2410,8 @@ static const struct iw_handler_def atmel_handler_def = .num_private_args = sizeof(atmel_private_args)/sizeof(struct iw_priv_args), .standard = (iw_handler *) atmel_handler, .private = (iw_handler *) atmel_private_handler, - .private_args = (struct iw_priv_args *) atmel_private_args + .private_args = (struct iw_priv_args *) atmel_private_args, + .get_wireless_stats = atmel_get_wireless_stats }; static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) @@ -2424,19 +2424,6 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) char domain[REGDOMAINSZ+1]; switch (cmd) { - case SIOCGIWPRIV: - if(wrq->u.data.pointer) { - /* Set the number of ioctl available */ - wrq->u.data.length = sizeof(atmel_private_args) / sizeof(atmel_private_args[0]); - - /* Copy structure to the user buffer */ - if (copy_to_user(wrq->u.data.pointer, - (u_char *) atmel_private_args, - sizeof(atmel_private_args))) - rc = -EFAULT; - } - break; - case ATMELIDIFC: wrq->u.param.value = ATMELMAGIC; break; diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index 2a3bd607a5c..b7f275c00de 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c @@ -72,7 +72,8 @@ static void ipw_rx_queue_replenish(void *); static int ipw_up(struct ipw_priv *); static void ipw_down(struct ipw_priv *); static int ipw_config(struct ipw_priv *); -static int init_supported_rates(struct ipw_priv *priv, struct ipw_supported_rates *prates); +static int init_supported_rates(struct ipw_priv *priv, + struct ipw_supported_rates *prates); static u8 band_b_active_channel[MAX_B_CHANNELS] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0 @@ -102,7 +103,7 @@ static int is_valid_channel(int mode_mask, int channel) } static char *snprint_line(char *buf, size_t count, - const u8 *data, u32 len, u32 ofs) + const u8 * data, u32 len, u32 ofs) { int out, i, j, l; char c; @@ -136,7 +137,7 @@ static char *snprint_line(char *buf, size_t count, return buf; } -static void printk_buf(int level, const u8 *data, u32 len) +static void printk_buf(int level, const u8 * data, u32 len) { char line[81]; u32 ofs = 0; @@ -161,21 +162,24 @@ static u8 _ipw_read_reg8(struct ipw_priv *ipw, u32 reg); static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value); static inline void ipw_write_reg8(struct ipw_priv *a, u32 b, u8 c) { - IPW_DEBUG_IO("%s %d: write_indirect8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c)); + IPW_DEBUG_IO("%s %d: write_indirect8(0x%08X, 0x%08X)\n", __FILE__, + __LINE__, (u32) (b), (u32) (c)); _ipw_write_reg8(a, b, c); } static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value); static inline void ipw_write_reg16(struct ipw_priv *a, u32 b, u16 c) { - IPW_DEBUG_IO("%s %d: write_indirect16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c)); + IPW_DEBUG_IO("%s %d: write_indirect16(0x%08X, 0x%08X)\n", __FILE__, + __LINE__, (u32) (b), (u32) (c)); _ipw_write_reg16(a, b, c); } static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value); static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c) { - IPW_DEBUG_IO("%s %d: write_indirect32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(b), (u32)(c)); + IPW_DEBUG_IO("%s %d: write_indirect32(0x%08X, 0x%08X)\n", __FILE__, + __LINE__, (u32) (b), (u32) (c)); _ipw_write_reg32(a, b, c); } @@ -195,24 +199,30 @@ static inline void ipw_write_reg32(struct ipw_priv *a, u32 b, u32 c) _ipw_write32(ipw, ofs, val) #define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs)) -static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) { - IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32)(ofs)); +static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) +{ + IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32) (ofs)); return _ipw_read8(ipw, ofs); } + #define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs) #define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs)) -static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) { - IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32)(ofs)); +static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) +{ + IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32) (ofs)); return _ipw_read16(ipw, ofs); } + #define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs) #define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs)) -static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) { - IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32)(ofs)); +static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) +{ + IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32) (ofs)); return _ipw_read32(ipw, ofs); } + #define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs) static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int); @@ -220,34 +230,30 @@ static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int); IPW_DEBUG_IO("%s %d: read_inddirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \ _ipw_read_indirect(a, b, c, d) -static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *data, int num); +static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * data, + int num); #define ipw_write_indirect(a, b, c, d) \ IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \ _ipw_write_indirect(a, b, c, d) /* indirect write s */ -static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, - u32 value) +static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value) { - IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n", - priv, reg, value); + IPW_DEBUG_IO(" %p : reg = 0x%8X : value = 0x%8X\n", priv, reg, value); _ipw_write32(priv, CX2_INDIRECT_ADDR, reg); _ipw_write32(priv, CX2_INDIRECT_DATA, value); } - static void _ipw_write_reg8(struct ipw_priv *priv, u32 reg, u8 value) { IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value); _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK); _ipw_write8(priv, CX2_INDIRECT_DATA, value); IPW_DEBUG_IO(" reg = 0x%8lX : value = 0x%8X\n", - (unsigned long)(priv->hw_base + CX2_INDIRECT_DATA), - value); + (unsigned long)(priv->hw_base + CX2_INDIRECT_DATA), value); } -static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, - u16 value) +static void _ipw_write_reg16(struct ipw_priv *priv, u32 reg, u16 value) { IPW_DEBUG_IO(" reg = 0x%8X : value = 0x%8X\n", reg, value); _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK); @@ -262,7 +268,7 @@ static u8 _ipw_read_reg8(struct ipw_priv *priv, u32 reg) _ipw_write32(priv, CX2_INDIRECT_ADDR, reg & CX2_INDIRECT_ADDR_MASK); IPW_DEBUG_IO(" reg = 0x%8X : \n", reg); word = _ipw_read32(priv, CX2_INDIRECT_DATA); - return (word >> ((reg & 0x3)*8)) & 0xff; + return (word >> ((reg & 0x3) * 8)) & 0xff; } static u32 _ipw_read_reg32(struct ipw_priv *priv, u32 reg) @@ -302,7 +308,7 @@ static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf, _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr); aligned_len = num & CX2_INDIRECT_ADDR_MASK; for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) - *(u32*)buf = ipw_read32(priv, CX2_AUTOINC_DATA); + *(u32 *) buf = ipw_read32(priv, CX2_AUTOINC_DATA); /* Copy the last nibble */ dif_len = num - aligned_len; @@ -311,7 +317,7 @@ static void _ipw_read_indirect(struct ipw_priv *priv, u32 addr, u8 * buf, *buf = ipw_read8(priv, CX2_INDIRECT_DATA + i); } -static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *buf, +static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * buf, int num) { u32 aligned_addr = addr & CX2_INDIRECT_ADDR_MASK; @@ -335,7 +341,7 @@ static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 *buf, _ipw_write32(priv, CX2_AUTOINC_ADDR, aligned_addr); aligned_len = num & CX2_INDIRECT_ADDR_MASK; for (i = 0; i < aligned_len; i += 4, buf += 4, aligned_addr += 4) - _ipw_write32(priv, CX2_AUTOINC_DATA, *(u32*)buf); + _ipw_write32(priv, CX2_AUTOINC_DATA, *(u32 *) buf); /* Copy the last nibble */ dif_len = num - aligned_len; @@ -428,20 +434,18 @@ static void ipw_dump_nic_error_log(struct ipw_priv *priv) } for (i = ERROR_START_OFFSET; - i <= count * ERROR_ELEM_SIZE; - i += ERROR_ELEM_SIZE) { - desc = ipw_read_reg32(priv, base + i); - time = ipw_read_reg32(priv, base + i + 1*sizeof(u32)); - blink1 = ipw_read_reg32(priv, base + i + 2*sizeof(u32)); - blink2 = ipw_read_reg32(priv, base + i + 3*sizeof(u32)); - ilink1 = ipw_read_reg32(priv, base + i + 4*sizeof(u32)); - ilink2 = ipw_read_reg32(priv, base + i + 5*sizeof(u32)); - idata = ipw_read_reg32(priv, base + i + 6*sizeof(u32)); + i <= count * ERROR_ELEM_SIZE; i += ERROR_ELEM_SIZE) { + desc = ipw_read_reg32(priv, base + i); + time = ipw_read_reg32(priv, base + i + 1 * sizeof(u32)); + blink1 = ipw_read_reg32(priv, base + i + 2 * sizeof(u32)); + blink2 = ipw_read_reg32(priv, base + i + 3 * sizeof(u32)); + ilink1 = ipw_read_reg32(priv, base + i + 4 * sizeof(u32)); + ilink2 = ipw_read_reg32(priv, base + i + 5 * sizeof(u32)); + idata = ipw_read_reg32(priv, base + i + 6 * sizeof(u32)); - IPW_ERROR( - "%s %i 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", - ipw_error_desc(desc), time, blink1, blink2, - ilink1, ilink2, idata); + IPW_ERROR("%s %i 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", + ipw_error_desc(desc), time, blink1, blink2, + ilink1, ilink2, idata); } } @@ -456,11 +460,10 @@ static void ipw_dump_nic_event_log(struct ipw_priv *priv) IPW_ERROR("Start IPW Event Log Dump:\n"); for (i = EVENT_START_OFFSET; - i <= count * EVENT_ELEM_SIZE; - i += EVENT_ELEM_SIZE) { + i <= count * EVENT_ELEM_SIZE; i += EVENT_ELEM_SIZE) { ev = ipw_read_reg32(priv, base + i); - time = ipw_read_reg32(priv, base + i + 1*sizeof(u32)); - data = ipw_read_reg32(priv, base + i + 2*sizeof(u32)); + time = ipw_read_reg32(priv, base + i + 1 * sizeof(u32)); + data = ipw_read_reg32(priv, base + i + 2 * sizeof(u32)); #ifdef CONFIG_IPW_DEBUG IPW_ERROR("%i\t0x%08x\t%i\n", time, data, ev); @@ -468,8 +471,7 @@ static void ipw_dump_nic_event_log(struct ipw_priv *priv) } } -static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, - u32 *len) +static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, u32 * len) { u32 addr, field_info, field_len, field_count, total_len; @@ -513,11 +515,11 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, } IPW_DEBUG_ORD("Reading TABLE0[%i] from offset 0x%08x\n", - ord, priv->table0_addr + (ord << 2)); + ord, priv->table0_addr + (ord << 2)); *len = sizeof(u32); ord <<= 2; - *((u32 *)val) = ipw_read32(priv, priv->table0_addr + ord); + *((u32 *) val) = ipw_read32(priv, priv->table0_addr + ord); break; case IPW_ORD_TABLE_1_MASK: @@ -545,7 +547,8 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, return -EINVAL; } - *((u32 *)val) = ipw_read_reg32(priv, (priv->table1_addr + (ord << 2))); + *((u32 *) val) = + ipw_read_reg32(priv, (priv->table1_addr + (ord << 2))); *len = sizeof(u32); break; @@ -573,13 +576,16 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, /* get the second DW of statistics ; * two 16-bit words - first is length, second is count */ - field_info = ipw_read_reg32(priv, priv->table2_addr + (ord << 3) + sizeof(u32)); + field_info = + ipw_read_reg32(priv, + priv->table2_addr + (ord << 3) + + sizeof(u32)); /* get each entry length */ - field_len = *((u16 *)&field_info); + field_len = *((u16 *) & field_info); /* get number of entries */ - field_count = *(((u16 *)&field_info) + 1); + field_count = *(((u16 *) & field_info) + 1); /* abort if not enought memory */ total_len = field_len * field_count; @@ -604,7 +610,6 @@ static int ipw_get_ordinal(struct ipw_priv *priv, u32 ord, void *val, } - return 0; } @@ -624,7 +629,7 @@ static void ipw_init_ordinals(struct ipw_priv *priv) priv->table2_addr = ipw_read32(priv, IPW_ORDINALS_TABLE_2); priv->table2_len = ipw_read_reg32(priv, priv->table2_addr); - priv->table2_len &= 0x0000ffff; /* use first two bytes */ + priv->table2_len &= 0x0000ffff; /* use first two bytes */ IPW_DEBUG_ORD("table 2 offset at 0x%08x, len = %i\n", priv->table2_addr, priv->table2_len); @@ -643,7 +648,7 @@ static ssize_t show_debug_level(struct device_driver *d, char *buf) return sprintf(buf, "0x%08X\n", ipw_debug_level); } static ssize_t store_debug_level(struct device_driver *d, - const char *buf, size_t count) + const char *buf, size_t count) { char *p = (char *)buf; u32 val; @@ -668,11 +673,12 @@ static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level, store_debug_level); static ssize_t show_status(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ipw_priv *p = d->driver_data; return sprintf(buf, "0x%08x\n", (int)p->status); } + static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); static ssize_t show_cfg(struct device *d, struct device_attribute *attr, @@ -681,10 +687,11 @@ static ssize_t show_cfg(struct device *d, struct device_attribute *attr, struct ipw_priv *p = d->driver_data; return sprintf(buf, "0x%08x\n", (int)p->config); } + static DEVICE_ATTR(cfg, S_IRUGO, show_cfg, NULL); static ssize_t show_nic_type(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct ipw_priv *p = d->driver_data; u8 type = p->eeprom[EEPROM_NIC_TYPE]; @@ -704,44 +711,50 @@ static ssize_t show_nic_type(struct device *d, return sprintf(buf, "UNKNOWN\n"); } + static DEVICE_ATTR(nic_type, S_IRUGO, show_nic_type, NULL); static ssize_t dump_error_log(struct device *d, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, const char *buf, + size_t count) { char *p = (char *)buf; if (p[0] == '1') - ipw_dump_nic_error_log((struct ipw_priv*)d->driver_data); + ipw_dump_nic_error_log((struct ipw_priv *)d->driver_data); return strnlen(buf, count); } + static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, dump_error_log); static ssize_t dump_event_log(struct device *d, - struct device_attribute *attr, const char *buf, size_t count) + struct device_attribute *attr, const char *buf, + size_t count) { char *p = (char *)buf; if (p[0] == '1') - ipw_dump_nic_event_log((struct ipw_priv*)d->driver_data); + ipw_dump_nic_event_log((struct ipw_priv *)d->driver_data); return strnlen(buf, count); } + static DEVICE_ATTR(dump_events, S_IWUSR, NULL, dump_event_log); static ssize_t show_ucode_version(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 len = sizeof(u32), tmp = 0; struct ipw_priv *p = d->driver_data; - if(ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len)) + if (ipw_get_ordinal(p, IPW_ORD_STAT_UCODE_VERSION, &tmp, &len)) return 0; return sprintf(buf, "0x%08x\n", tmp); } -static DEVICE_ATTR(ucode_version, S_IWUSR|S_IRUGO, show_ucode_version, NULL); + +static DEVICE_ATTR(ucode_version, S_IWUSR | S_IRUGO, show_ucode_version, NULL); static ssize_t show_rtc(struct device *d, struct device_attribute *attr, char *buf) @@ -749,36 +762,38 @@ static ssize_t show_rtc(struct device *d, struct device_attribute *attr, u32 len = sizeof(u32), tmp = 0; struct ipw_priv *p = d->driver_data; - if(ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len)) + if (ipw_get_ordinal(p, IPW_ORD_STAT_RTC, &tmp, &len)) return 0; return sprintf(buf, "0x%08x\n", tmp); } -static DEVICE_ATTR(rtc, S_IWUSR|S_IRUGO, show_rtc, NULL); + +static DEVICE_ATTR(rtc, S_IWUSR | S_IRUGO, show_rtc, NULL); /* * Add a device attribute to view/control the delay between eeprom * operations. */ static ssize_t show_eeprom_delay(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { - int n = ((struct ipw_priv*)d->driver_data)->eeprom_delay; + int n = ((struct ipw_priv *)d->driver_data)->eeprom_delay; return sprintf(buf, "%i\n", n); } static ssize_t store_eeprom_delay(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *p = d->driver_data; sscanf(buf, "%i", &p->eeprom_delay); return strnlen(buf, count); } -static DEVICE_ATTR(eeprom_delay, S_IWUSR|S_IRUGO, - show_eeprom_delay,store_eeprom_delay); + +static DEVICE_ATTR(eeprom_delay, S_IWUSR | S_IRUGO, + show_eeprom_delay, store_eeprom_delay); static ssize_t show_command_event_reg(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 reg = 0; struct ipw_priv *p = d->driver_data; @@ -787,8 +802,8 @@ static ssize_t show_command_event_reg(struct device *d, return sprintf(buf, "0x%08x\n", reg); } static ssize_t store_command_event_reg(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { u32 reg; struct ipw_priv *p = d->driver_data; @@ -797,11 +812,12 @@ static ssize_t store_command_event_reg(struct device *d, ipw_write_reg32(p, CX2_INTERNAL_CMD_EVENT, reg); return strnlen(buf, count); } -static DEVICE_ATTR(command_event_reg, S_IWUSR|S_IRUGO, - show_command_event_reg,store_command_event_reg); + +static DEVICE_ATTR(command_event_reg, S_IWUSR | S_IRUGO, + show_command_event_reg, store_command_event_reg); static ssize_t show_mem_gpio_reg(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 reg = 0; struct ipw_priv *p = d->driver_data; @@ -810,8 +826,8 @@ static ssize_t show_mem_gpio_reg(struct device *d, return sprintf(buf, "0x%08x\n", reg); } static ssize_t store_mem_gpio_reg(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { u32 reg; struct ipw_priv *p = d->driver_data; @@ -820,11 +836,12 @@ static ssize_t store_mem_gpio_reg(struct device *d, ipw_write_reg32(p, 0x301100, reg); return strnlen(buf, count); } -static DEVICE_ATTR(mem_gpio_reg, S_IWUSR|S_IRUGO, - show_mem_gpio_reg,store_mem_gpio_reg); + +static DEVICE_ATTR(mem_gpio_reg, S_IWUSR | S_IRUGO, + show_mem_gpio_reg, store_mem_gpio_reg); static ssize_t show_indirect_dword(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 reg = 0; struct ipw_priv *priv = d->driver_data; @@ -836,8 +853,8 @@ static ssize_t show_indirect_dword(struct device *d, return sprintf(buf, "0x%08x\n", reg); } static ssize_t store_indirect_dword(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *priv = d->driver_data; @@ -845,11 +862,12 @@ static ssize_t store_indirect_dword(struct device *d, priv->status |= STATUS_INDIRECT_DWORD; return strnlen(buf, count); } -static DEVICE_ATTR(indirect_dword, S_IWUSR|S_IRUGO, - show_indirect_dword,store_indirect_dword); + +static DEVICE_ATTR(indirect_dword, S_IWUSR | S_IRUGO, + show_indirect_dword, store_indirect_dword); static ssize_t show_indirect_byte(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u8 reg = 0; struct ipw_priv *priv = d->driver_data; @@ -861,8 +879,8 @@ static ssize_t show_indirect_byte(struct device *d, return sprintf(buf, "0x%02x\n", reg); } static ssize_t store_indirect_byte(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *priv = d->driver_data; @@ -870,11 +888,12 @@ static ssize_t store_indirect_byte(struct device *d, priv->status |= STATUS_INDIRECT_BYTE; return strnlen(buf, count); } -static DEVICE_ATTR(indirect_byte, S_IWUSR|S_IRUGO, + +static DEVICE_ATTR(indirect_byte, S_IWUSR | S_IRUGO, show_indirect_byte, store_indirect_byte); static ssize_t show_direct_dword(struct device *d, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { u32 reg = 0; struct ipw_priv *priv = d->driver_data; @@ -887,8 +906,8 @@ static ssize_t show_direct_dword(struct device *d, return sprintf(buf, "0x%08x\n", reg); } static ssize_t store_direct_dword(struct device *d, - struct device_attribute *attr, const char *buf, - size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *priv = d->driver_data; @@ -896,9 +915,9 @@ static ssize_t store_direct_dword(struct device *d, priv->status |= STATUS_DIRECT_DWORD; return strnlen(buf, count); } -static DEVICE_ATTR(direct_dword, S_IWUSR|S_IRUGO, - show_direct_dword,store_direct_dword); +static DEVICE_ATTR(direct_dword, S_IWUSR | S_IRUGO, + show_direct_dword, store_direct_dword); static inline int rf_kill_active(struct ipw_priv *priv) { @@ -911,7 +930,7 @@ static inline int rf_kill_active(struct ipw_priv *priv) } static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr, - char *buf) + char *buf) { /* 0 - RF kill not enabled 1 - SW based RF kill active (sysfs) @@ -919,7 +938,7 @@ static ssize_t show_rf_kill(struct device *d, struct device_attribute *attr, 3 - Both HW and SW baed RF kill active */ struct ipw_priv *priv = d->driver_data; int val = ((priv->status & STATUS_RF_KILL_SW) ? 0x1 : 0x0) | - (rf_kill_active(priv) ? 0x2 : 0x0); + (rf_kill_active(priv) ? 0x2 : 0x0); return sprintf(buf, "%i\n", val); } @@ -927,7 +946,7 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio) { if ((disable_radio ? 1 : 0) == (priv->status & STATUS_RF_KILL_SW ? 1 : 0)) - return 0 ; + return 0; IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n", disable_radio ? "OFF" : "ON"); @@ -956,8 +975,8 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio) return 1; } -static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct ipw_priv *priv = d->driver_data; @@ -965,7 +984,8 @@ static ssize_t store_rf_kill(struct device *d, struct device_attribute *attr, return count; } -static DEVICE_ATTR(rf_kill, S_IWUSR|S_IRUGO, show_rf_kill, store_rf_kill); + +static DEVICE_ATTR(rf_kill, S_IWUSR | S_IRUGO, show_rf_kill, store_rf_kill); static void ipw_irq_tasklet(struct ipw_priv *priv) { @@ -990,7 +1010,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) if (inta & CX2_INTA_BIT_TX_CMD_QUEUE) { IPW_DEBUG_HC("Command completed.\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq_cmd, -1); + rc = ipw_queue_tx_reclaim(priv, &priv->txq_cmd, -1); priv->status &= ~STATUS_HCMD_ACTIVE; wake_up_interruptible(&priv->wait_command_queue); handled |= CX2_INTA_BIT_TX_CMD_QUEUE; @@ -998,25 +1018,25 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) if (inta & CX2_INTA_BIT_TX_QUEUE_1) { IPW_DEBUG_TX("TX_QUEUE_1\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq[0], 0); + rc = ipw_queue_tx_reclaim(priv, &priv->txq[0], 0); handled |= CX2_INTA_BIT_TX_QUEUE_1; } if (inta & CX2_INTA_BIT_TX_QUEUE_2) { IPW_DEBUG_TX("TX_QUEUE_2\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq[1], 1); + rc = ipw_queue_tx_reclaim(priv, &priv->txq[1], 1); handled |= CX2_INTA_BIT_TX_QUEUE_2; } if (inta & CX2_INTA_BIT_TX_QUEUE_3) { IPW_DEBUG_TX("TX_QUEUE_3\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq[2], 2); + rc = ipw_queue_tx_reclaim(priv, &priv->txq[2], 2); handled |= CX2_INTA_BIT_TX_QUEUE_3; } if (inta & CX2_INTA_BIT_TX_QUEUE_4) { IPW_DEBUG_TX("TX_QUEUE_4\n"); - rc = ipw_queue_tx_reclaim( priv, &priv->txq[3], 3); + rc = ipw_queue_tx_reclaim(priv, &priv->txq[3], 3); handled |= CX2_INTA_BIT_TX_QUEUE_4; } @@ -1074,8 +1094,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv) } if (handled != inta) { - IPW_ERROR("Unhandled INTA bits 0x%08x\n", - inta & ~handled); + IPW_ERROR("Unhandled INTA bits 0x%08x\n", inta & ~handled); } /* enable all interrupts */ @@ -1143,7 +1162,7 @@ static char *get_cmd_string(u8 cmd) return "UNKNOWN"; } } -#endif /* CONFIG_IPW_DEBUG */ +#endif /* CONFIG_IPW_DEBUG */ #define HOST_COMPLETE_TIMEOUT HZ static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd) @@ -1159,15 +1178,16 @@ static int ipw_send_cmd(struct ipw_priv *priv, struct host_cmd *cmd) IPW_DEBUG_HC("Sending %s command (#%d), %d bytes\n", get_cmd_string(cmd->cmd), cmd->cmd, cmd->len); - printk_buf(IPW_DL_HOST_COMMAND, (u8*)cmd->param, cmd->len); + printk_buf(IPW_DL_HOST_COMMAND, (u8 *) cmd->param, cmd->len); rc = ipw_queue_tx_hcmd(priv, cmd->cmd, &cmd->param, cmd->len, 0); if (rc) return rc; - rc = wait_event_interruptible_timeout( - priv->wait_command_queue, !(priv->status & STATUS_HCMD_ACTIVE), - HOST_COMPLETE_TIMEOUT); + rc = wait_event_interruptible_timeout(priv->wait_command_queue, + !(priv-> + status & STATUS_HCMD_ACTIVE), + HOST_COMPLETE_TIMEOUT); if (rc == 0) { IPW_DEBUG_INFO("Command completion failed out after %dms.\n", jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); @@ -1215,7 +1235,7 @@ static int ipw_send_system_config(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,config,sizeof(*config)); + memcpy(&cmd.param, config, sizeof(*config)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send SYSTEM_CONFIG command\n"); return -1; @@ -1224,7 +1244,7 @@ static int ipw_send_system_config(struct ipw_priv *priv, return 0; } -static int ipw_send_ssid(struct ipw_priv *priv, u8 *ssid, int len) +static int ipw_send_ssid(struct ipw_priv *priv, u8 * ssid, int len) { struct host_cmd cmd = { .cmd = IPW_CMD_SSID, @@ -1245,7 +1265,7 @@ static int ipw_send_ssid(struct ipw_priv *priv, u8 *ssid, int len) return 0; } -static int ipw_send_adapter_address(struct ipw_priv *priv, u8 *mac) +static int ipw_send_adapter_address(struct ipw_priv *priv, u8 * mac) { struct host_cmd cmd = { .cmd = IPW_CMD_ADAPTER_ADDRESS, @@ -1284,9 +1304,6 @@ static void ipw_adapter_restart(void *adapter) } } - - - #define IPW_SCAN_CHECK_WATCHDOG (5 * HZ) static void ipw_scan_check(void *data) @@ -1313,7 +1330,7 @@ static int ipw_send_scan_request_ext(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,request,sizeof(*request)); + memcpy(&cmd.param, request, sizeof(*request)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send SCAN_REQUEST_EXT command\n"); return -1; @@ -1351,7 +1368,7 @@ static int ipw_set_sensitivity(struct ipw_priv *priv, u16 sens) .len = sizeof(struct ipw_sensitivity_calib) }; struct ipw_sensitivity_calib *calib = (struct ipw_sensitivity_calib *) - &cmd.param; + &cmd.param; calib->beacon_rssi_raw = sens; if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send SENSITIVITY CALIB command\n"); @@ -1374,7 +1391,7 @@ static int ipw_send_associate(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,associate,sizeof(*associate)); + memcpy(&cmd.param, associate, sizeof(*associate)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send ASSOCIATE command\n"); return -1; @@ -1396,7 +1413,7 @@ static int ipw_send_supported_rates(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,rates,sizeof(*rates)); + memcpy(&cmd.param, rates, sizeof(*rates)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send SUPPORTED_RATES command\n"); return -1; @@ -1440,7 +1457,7 @@ static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off) return -1; } - *((u32*)&cmd.param) = phy_off; + *((u32 *) & cmd.param) = phy_off; if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send CARD_DISABLE command\n"); @@ -1451,8 +1468,7 @@ static int ipw_send_card_disable(struct ipw_priv *priv, u32 phy_off) } #endif -static int ipw_send_tx_power(struct ipw_priv *priv, - struct ipw_tx_power *power) +static int ipw_send_tx_power(struct ipw_priv *priv, struct ipw_tx_power *power) { struct host_cmd cmd = { .cmd = IPW_CMD_TX_POWER, @@ -1464,7 +1480,7 @@ static int ipw_send_tx_power(struct ipw_priv *priv, return -1; } - memcpy(&cmd.param,power,sizeof(*power)); + memcpy(&cmd.param, power, sizeof(*power)); if (ipw_send_cmd(priv, &cmd)) { IPW_ERROR("failed to send TX_POWER command\n"); return -1; @@ -1527,7 +1543,7 @@ static int ipw_send_power_mode(struct ipw_priv *priv, u32 mode) .cmd = IPW_CMD_POWER_MODE, .len = sizeof(u32) }; - u32 *param = (u32*)(&cmd.param); + u32 *param = (u32 *) (&cmd.param); if (!priv) { IPW_ERROR("Invalid args\n"); @@ -1585,67 +1601,67 @@ static inline void eeprom_write_reg(struct ipw_priv *p, u32 data) } /* perform a chip select operation */ -static inline void eeprom_cs(struct ipw_priv* priv) +static inline void eeprom_cs(struct ipw_priv *priv) { - eeprom_write_reg(priv,0); - eeprom_write_reg(priv,EEPROM_BIT_CS); - eeprom_write_reg(priv,EEPROM_BIT_CS|EEPROM_BIT_SK); - eeprom_write_reg(priv,EEPROM_BIT_CS); + eeprom_write_reg(priv, 0); + eeprom_write_reg(priv, EEPROM_BIT_CS); + eeprom_write_reg(priv, EEPROM_BIT_CS | EEPROM_BIT_SK); + eeprom_write_reg(priv, EEPROM_BIT_CS); } /* perform a chip select operation */ -static inline void eeprom_disable_cs(struct ipw_priv* priv) +static inline void eeprom_disable_cs(struct ipw_priv *priv) { - eeprom_write_reg(priv,EEPROM_BIT_CS); - eeprom_write_reg(priv,0); - eeprom_write_reg(priv,EEPROM_BIT_SK); + eeprom_write_reg(priv, EEPROM_BIT_CS); + eeprom_write_reg(priv, 0); + eeprom_write_reg(priv, EEPROM_BIT_SK); } /* push a single bit down to the eeprom */ -static inline void eeprom_write_bit(struct ipw_priv *p,u8 bit) +static inline void eeprom_write_bit(struct ipw_priv *p, u8 bit) { - int d = ( bit ? EEPROM_BIT_DI : 0); - eeprom_write_reg(p,EEPROM_BIT_CS|d); - eeprom_write_reg(p,EEPROM_BIT_CS|d|EEPROM_BIT_SK); + int d = (bit ? EEPROM_BIT_DI : 0); + eeprom_write_reg(p, EEPROM_BIT_CS | d); + eeprom_write_reg(p, EEPROM_BIT_CS | d | EEPROM_BIT_SK); } /* push an opcode followed by an address down to the eeprom */ -static void eeprom_op(struct ipw_priv* priv, u8 op, u8 addr) +static void eeprom_op(struct ipw_priv *priv, u8 op, u8 addr) { int i; eeprom_cs(priv); - eeprom_write_bit(priv,1); - eeprom_write_bit(priv,op&2); - eeprom_write_bit(priv,op&1); - for ( i=7; i>=0; i-- ) { - eeprom_write_bit(priv,addr&(1<<i)); + eeprom_write_bit(priv, 1); + eeprom_write_bit(priv, op & 2); + eeprom_write_bit(priv, op & 1); + for (i = 7; i >= 0; i--) { + eeprom_write_bit(priv, addr & (1 << i)); } } /* pull 16 bits off the eeprom, one bit at a time */ -static u16 eeprom_read_u16(struct ipw_priv* priv, u8 addr) +static u16 eeprom_read_u16(struct ipw_priv *priv, u8 addr) { int i; - u16 r=0; + u16 r = 0; /* Send READ Opcode */ - eeprom_op(priv,EEPROM_CMD_READ,addr); + eeprom_op(priv, EEPROM_CMD_READ, addr); /* Send dummy bit */ - eeprom_write_reg(priv,EEPROM_BIT_CS); + eeprom_write_reg(priv, EEPROM_BIT_CS); /* Read the byte off the eeprom one bit at a time */ - for ( i=0; i<16; i++ ) { + for (i = 0; i < 16; i++) { u32 data = 0; - eeprom_write_reg(priv,EEPROM_BIT_CS|EEPROM_BIT_SK); - eeprom_write_reg(priv,EEPROM_BIT_CS); - data = ipw_read_reg32(priv,FW_MEM_REG_EEPROM_ACCESS); - r = (r<<1) | ((data & EEPROM_BIT_DO)?1:0); + eeprom_write_reg(priv, EEPROM_BIT_CS | EEPROM_BIT_SK); + eeprom_write_reg(priv, EEPROM_BIT_CS); + data = ipw_read_reg32(priv, FW_MEM_REG_EEPROM_ACCESS); + r = (r << 1) | ((data & EEPROM_BIT_DO) ? 1 : 0); } /* Send another dummy bit */ - eeprom_write_reg(priv,0); + eeprom_write_reg(priv, 0); eeprom_disable_cs(priv); return r; @@ -1653,9 +1669,9 @@ static u16 eeprom_read_u16(struct ipw_priv* priv, u8 addr) /* helper function for pulling the mac address out of the private */ /* data's copy of the eeprom data */ -static void eeprom_parse_mac(struct ipw_priv* priv, u8* mac) +static void eeprom_parse_mac(struct ipw_priv *priv, u8 * mac) { - u8* ee = (u8*)priv->eeprom; + u8 *ee = (u8 *) priv->eeprom; memcpy(mac, &ee[EEPROM_MAC_ADDRESS], 6); } @@ -1670,26 +1686,25 @@ static void eeprom_parse_mac(struct ipw_priv* priv, u8* mac) static void ipw_eeprom_init_sram(struct ipw_priv *priv) { int i; - u16 *eeprom = (u16 *)priv->eeprom; + u16 *eeprom = (u16 *) priv->eeprom; IPW_DEBUG_TRACE(">>\n"); /* read entire contents of eeprom into private buffer */ - for ( i=0; i<128; i++ ) - eeprom[i] = eeprom_read_u16(priv,(u8)i); + for (i = 0; i < 128; i++) + eeprom[i] = eeprom_read_u16(priv, (u8) i); /* If the data looks correct, then copy it to our private copy. Otherwise let the firmware know to perform the operation on it's own - */ + */ if ((priv->eeprom + EEPROM_VERSION) != 0) { IPW_DEBUG_INFO("Writing EEPROM data into SRAM\n"); /* write the eeprom data to sram */ - for( i=0; i<CX2_EEPROM_IMAGE_SIZE; i++ ) - ipw_write8(priv, IPW_EEPROM_DATA + i, - priv->eeprom[i]); + for (i = 0; i < CX2_EEPROM_IMAGE_SIZE; i++) + ipw_write8(priv, IPW_EEPROM_DATA + i, priv->eeprom[i]); /* Do not load eeprom data on fatal error or suspend */ ipw_write32(priv, IPW_EEPROM_LOAD_DISABLE, 0); @@ -1703,11 +1718,11 @@ static void ipw_eeprom_init_sram(struct ipw_priv *priv) IPW_DEBUG_TRACE("<<\n"); } - static inline void ipw_zero_memory(struct ipw_priv *priv, u32 start, u32 count) { count >>= 2; - if (!count) return; + if (!count) + return; _ipw_write32(priv, CX2_AUTOINC_ADDR, start); while (count--) _ipw_write32(priv, CX2_AUTOINC_DATA, 0); @@ -1721,7 +1736,7 @@ static inline void ipw_fw_dma_reset_command_blocks(struct ipw_priv *priv) } static int ipw_fw_dma_enable(struct ipw_priv *priv) -{ /* start dma engine but no transfers yet*/ +{ /* start dma engine but no transfers yet */ IPW_DEBUG_FW(">> : \n"); @@ -1749,12 +1764,16 @@ static void ipw_fw_dma_abort(struct ipw_priv *priv) IPW_DEBUG_FW("<< \n"); } -static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index, struct command_block *cb) +static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index, + struct command_block *cb) { - u32 address = CX2_SHARED_SRAM_DMA_CONTROL + (sizeof(struct command_block) * index); + u32 address = + CX2_SHARED_SRAM_DMA_CONTROL + + (sizeof(struct command_block) * index); IPW_DEBUG_FW(">> :\n"); - ipw_write_indirect(priv, address, (u8*)cb, (int)sizeof(struct command_block)); + ipw_write_indirect(priv, address, (u8 *) cb, + (int)sizeof(struct command_block)); IPW_DEBUG_FW("<< :\n"); return 0; @@ -1764,17 +1783,20 @@ static int ipw_fw_dma_write_command_block(struct ipw_priv *priv, int index, stru static int ipw_fw_dma_kick(struct ipw_priv *priv) { u32 control = 0; - u32 index=0; + u32 index = 0; IPW_DEBUG_FW(">> :\n"); for (index = 0; index < priv->sram_desc.last_cb_index; index++) - ipw_fw_dma_write_command_block(priv, index, &priv->sram_desc.cb_list[index]); + ipw_fw_dma_write_command_block(priv, index, + &priv->sram_desc.cb_list[index]); /* Enable the DMA in the CSR register */ - ipw_clear_bit(priv, CX2_RESET_REG,CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER); + ipw_clear_bit(priv, CX2_RESET_REG, + CX2_RESET_REG_MASTER_DISABLED | + CX2_RESET_REG_STOP_MASTER); - /* Set the Start bit. */ + /* Set the Start bit. */ control = DMA_CONTROL_SMALL_CB_CONST_VALUE | DMA_CB_START; ipw_write_reg32(priv, CX2_DMA_I_DMA_CONTROL, control); @@ -1785,25 +1807,25 @@ static int ipw_fw_dma_kick(struct ipw_priv *priv) static void ipw_fw_dma_dump_command_block(struct ipw_priv *priv) { u32 address; - u32 register_value=0; - u32 cb_fields_address=0; + u32 register_value = 0; + u32 cb_fields_address = 0; IPW_DEBUG_FW(">> :\n"); - address = ipw_read_reg32(priv,CX2_DMA_I_CURRENT_CB); - IPW_DEBUG_FW_INFO("Current CB is 0x%x \n",address); + address = ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB); + IPW_DEBUG_FW_INFO("Current CB is 0x%x \n", address); /* Read the DMA Controlor register */ register_value = ipw_read_reg32(priv, CX2_DMA_I_DMA_CONTROL); - IPW_DEBUG_FW_INFO("CX2_DMA_I_DMA_CONTROL is 0x%x \n",register_value); + IPW_DEBUG_FW_INFO("CX2_DMA_I_DMA_CONTROL is 0x%x \n", register_value); - /* Print the CB values*/ + /* Print the CB values */ cb_fields_address = address; register_value = ipw_read_reg32(priv, cb_fields_address); - IPW_DEBUG_FW_INFO("Current CB ControlField is 0x%x \n",register_value); + IPW_DEBUG_FW_INFO("Current CB ControlField is 0x%x \n", register_value); cb_fields_address += sizeof(u32); register_value = ipw_read_reg32(priv, cb_fields_address); - IPW_DEBUG_FW_INFO("Current CB Source Field is 0x%x \n",register_value); + IPW_DEBUG_FW_INFO("Current CB Source Field is 0x%x \n", register_value); cb_fields_address += sizeof(u32); register_value = ipw_read_reg32(priv, cb_fields_address); @@ -1812,7 +1834,7 @@ static void ipw_fw_dma_dump_command_block(struct ipw_priv *priv) cb_fields_address += sizeof(u32); register_value = ipw_read_reg32(priv, cb_fields_address); - IPW_DEBUG_FW_INFO("Current CB Status Field is 0x%x \n",register_value); + IPW_DEBUG_FW_INFO("Current CB Status Field is 0x%x \n", register_value); IPW_DEBUG_FW(">> :\n"); } @@ -1823,13 +1845,13 @@ static int ipw_fw_dma_command_block_index(struct ipw_priv *priv) u32 current_cb_index = 0; IPW_DEBUG_FW("<< :\n"); - current_cb_address= ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB); + current_cb_address = ipw_read_reg32(priv, CX2_DMA_I_CURRENT_CB); - current_cb_index = (current_cb_address - CX2_SHARED_SRAM_DMA_CONTROL )/ - sizeof (struct command_block); + current_cb_index = (current_cb_address - CX2_SHARED_SRAM_DMA_CONTROL) / + sizeof(struct command_block); IPW_DEBUG_FW_INFO("Current CB index 0x%x address = 0x%X \n", - current_cb_index, current_cb_address ); + current_cb_index, current_cb_address); IPW_DEBUG_FW(">> :\n"); return current_cb_index; @@ -1840,15 +1862,14 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv, u32 src_address, u32 dest_address, u32 length, - int interrupt_enabled, - int is_last) + int interrupt_enabled, int is_last) { u32 control = CB_VALID | CB_SRC_LE | CB_DEST_LE | CB_SRC_AUTOINC | - CB_SRC_IO_GATED | CB_DEST_AUTOINC | CB_SRC_SIZE_LONG | - CB_DEST_SIZE_LONG; + CB_SRC_IO_GATED | CB_DEST_AUTOINC | CB_SRC_SIZE_LONG | + CB_DEST_SIZE_LONG; struct command_block *cb; - u32 last_cb_element=0; + u32 last_cb_element = 0; IPW_DEBUG_FW_INFO("src_address=0x%x dest_address=0x%x length=0x%x\n", src_address, dest_address, length); @@ -1861,7 +1882,7 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv, priv->sram_desc.last_cb_index++; /* Calculate the new CB control word */ - if (interrupt_enabled ) + if (interrupt_enabled) control |= CB_INT_ENABLED; if (is_last) @@ -1870,7 +1891,7 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv, control |= length; /* Calculate the CB Element's checksum value */ - cb->status = control ^src_address ^dest_address; + cb->status = control ^ src_address ^ dest_address; /* Copy the Source and Destination addresses */ cb->dest_addr = dest_address; @@ -1883,22 +1904,21 @@ static int ipw_fw_dma_add_command_block(struct ipw_priv *priv, } static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, - u32 src_phys, - u32 dest_address, - u32 length) + u32 src_phys, u32 dest_address, u32 length) { u32 bytes_left = length; - u32 src_offset=0; - u32 dest_offset=0; + u32 src_offset = 0; + u32 dest_offset = 0; int status = 0; IPW_DEBUG_FW(">> \n"); IPW_DEBUG_FW_INFO("src_phys=0x%x dest_address=0x%x length=0x%x\n", src_phys, dest_address, length); while (bytes_left > CB_MAX_LENGTH) { - status = ipw_fw_dma_add_command_block( priv, - src_phys + src_offset, - dest_address + dest_offset, - CB_MAX_LENGTH, 0, 0); + status = ipw_fw_dma_add_command_block(priv, + src_phys + src_offset, + dest_address + + dest_offset, + CB_MAX_LENGTH, 0, 0); if (status) { IPW_DEBUG_FW_INFO(": Failed\n"); return -1; @@ -1912,18 +1932,18 @@ static int ipw_fw_dma_add_buffer(struct ipw_priv *priv, /* add the buffer tail */ if (bytes_left > 0) { - status = ipw_fw_dma_add_command_block( - priv, src_phys + src_offset, - dest_address + dest_offset, - bytes_left, 0, 0); + status = + ipw_fw_dma_add_command_block(priv, src_phys + src_offset, + dest_address + dest_offset, + bytes_left, 0, 0); if (status) { IPW_DEBUG_FW_INFO(": Failed on the buffer tail\n"); return -1; } else - IPW_DEBUG_FW_INFO(": Adding new cb - the buffer tail\n"); + IPW_DEBUG_FW_INFO + (": Adding new cb - the buffer tail\n"); } - IPW_DEBUG_FW("<< \n"); return 0; } @@ -1937,7 +1957,7 @@ static int ipw_fw_dma_wait(struct ipw_priv *priv) current_index = ipw_fw_dma_command_block_index(priv); IPW_DEBUG_FW_INFO("sram_desc.last_cb_index:0x%8X\n", - (int) priv->sram_desc.last_cb_index); + (int)priv->sram_desc.last_cb_index); while (current_index < priv->sram_desc.last_cb_index) { udelay(50); @@ -1955,8 +1975,8 @@ static int ipw_fw_dma_wait(struct ipw_priv *priv) ipw_fw_dma_abort(priv); - /*Disable the DMA in the CSR register*/ - ipw_set_bit(priv, CX2_RESET_REG, + /*Disable the DMA in the CSR register */ + ipw_set_bit(priv, CX2_RESET_REG, CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER); IPW_DEBUG_FW("<< dmaWaitSync \n"); @@ -2011,8 +2031,7 @@ static inline int ipw_poll_bit(struct ipw_priv *priv, u32 addr, u32 mask, * image and the caller is handling the memory allocation and clean up. */ - -static int ipw_stop_master(struct ipw_priv * priv) +static int ipw_stop_master(struct ipw_priv *priv) { int rc; @@ -2071,14 +2090,13 @@ struct fw_chunk { #define IPW_FW_NAME(x) "ipw2200_" x ".fw" #endif -static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, - size_t len) +static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len) { int rc = 0, i, addr; u8 cr = 0; u16 *image; - image = (u16 *)data; + image = (u16 *) data; IPW_DEBUG_TRACE(">> \n"); @@ -2087,7 +2105,7 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, if (rc < 0) return rc; -// spin_lock_irqsave(&priv->lock, flags); +// spin_lock_irqsave(&priv->lock, flags); for (addr = CX2_SHARED_LOWER_BOUND; addr < CX2_REGISTER_DOMAIN1_END; addr += 4) { @@ -2099,7 +2117,7 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, /* destroy DMA queues */ /* reset sequence */ - ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET ,CX2_BIT_HALT_RESET_ON); + ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET, CX2_BIT_HALT_RESET_ON); ipw_arc_release(priv); ipw_write_reg32(priv, CX2_MEM_HALT_AND_RESET, CX2_BIT_HALT_RESET_OFF); mdelay(1); @@ -2128,13 +2146,11 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, for (i = 0; i < len / 2; i++) ipw_write_reg16(priv, CX2_BASEBAND_CONTROL_STORE, image[i]); - /* enable DINO */ ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0); - ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, - DINO_ENABLE_SYSTEM ); + ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, DINO_ENABLE_SYSTEM); - /* this is where the igx / win driver deveates from the VAP driver.*/ + /* this is where the igx / win driver deveates from the VAP driver. */ /* wait for alive response */ for (i = 0; i < 100; i++) { @@ -2151,25 +2167,24 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, for (i = 0; i < ARRAY_SIZE(response_buffer); i++) response_buffer[i] = - ipw_read_reg32(priv, - CX2_BASEBAND_RX_FIFO_READ); + ipw_read_reg32(priv, CX2_BASEBAND_RX_FIFO_READ); memcpy(&priv->dino_alive, response_buffer, sizeof(priv->dino_alive)); if (priv->dino_alive.alive_command == 1 && priv->dino_alive.ucode_valid == 1) { rc = 0; - IPW_DEBUG_INFO( - "Microcode OK, rev. %d (0x%x) dev. %d (0x%x) " - "of %02d/%02d/%02d %02d:%02d\n", - priv->dino_alive.software_revision, - priv->dino_alive.software_revision, - priv->dino_alive.device_identifier, - priv->dino_alive.device_identifier, - priv->dino_alive.time_stamp[0], - priv->dino_alive.time_stamp[1], - priv->dino_alive.time_stamp[2], - priv->dino_alive.time_stamp[3], - priv->dino_alive.time_stamp[4]); + IPW_DEBUG_INFO + ("Microcode OK, rev. %d (0x%x) dev. %d (0x%x) " + "of %02d/%02d/%02d %02d:%02d\n", + priv->dino_alive.software_revision, + priv->dino_alive.software_revision, + priv->dino_alive.device_identifier, + priv->dino_alive.device_identifier, + priv->dino_alive.time_stamp[0], + priv->dino_alive.time_stamp[1], + priv->dino_alive.time_stamp[2], + priv->dino_alive.time_stamp[3], + priv->dino_alive.time_stamp[4]); } else { IPW_DEBUG_INFO("Microcode is not alive\n"); rc = -EINVAL; @@ -2183,13 +2198,12 @@ static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, firmware have problem getting alive resp. */ ipw_write_reg8(priv, CX2_BASEBAND_CONTROL_STATUS, 0); -// spin_unlock_irqrestore(&priv->lock, flags); +// spin_unlock_irqrestore(&priv->lock, flags); return rc; } -static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, - size_t len) +static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len) { int rc = -1; int offset = 0; @@ -2231,7 +2245,7 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, offset += chunk->length; } while (offset < len); - /* Run the DMA and wait for the answer*/ + /* Run the DMA and wait for the answer */ rc = ipw_fw_dma_kick(priv); if (rc) { IPW_ERROR("dmaKick Failed\n"); @@ -2243,8 +2257,8 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, IPW_ERROR("dmaWaitSync Failed\n"); goto out; } - out: - pci_free_consistent( priv->pci_dev, len, shared_virt, shared_phys); + out: + pci_free_consistent(priv->pci_dev, len, shared_virt, shared_phys); return rc; } @@ -2253,7 +2267,7 @@ static int ipw_stop_nic(struct ipw_priv *priv) { int rc = 0; - /* stop*/ + /* stop */ ipw_write32(priv, CX2_RESET_REG, CX2_RESET_REG_STOP_MASTER); rc = ipw_poll_bit(priv, CX2_RESET_REG, @@ -2272,14 +2286,15 @@ static void ipw_start_nic(struct ipw_priv *priv) { IPW_DEBUG_TRACE(">>\n"); - /* prvHwStartNic release ARC*/ + /* prvHwStartNic release ARC */ ipw_clear_bit(priv, CX2_RESET_REG, CX2_RESET_REG_MASTER_DISABLED | CX2_RESET_REG_STOP_MASTER | CBD_RESET_REG_PRINCETON_RESET); /* enable power management */ - ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY); + ipw_set_bit(priv, CX2_GP_CNTRL_RW, + CX2_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY); IPW_DEBUG_TRACE("<<\n"); } @@ -2295,12 +2310,13 @@ static int ipw_init_nic(struct ipw_priv *priv) ipw_set_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_INIT_DONE); /* low-level PLL activation */ - ipw_write32(priv, CX2_READ_INT_REGISTER, CX2_BIT_INT_HOST_SRAM_READ_INT_REGISTER); + ipw_write32(priv, CX2_READ_INT_REGISTER, + CX2_BIT_INT_HOST_SRAM_READ_INT_REGISTER); /* wait for clock stabilization */ rc = ipw_poll_bit(priv, CX2_GP_CNTRL_RW, CX2_GP_CNTRL_BIT_CLOCK_READY, 250); - if (rc < 0 ) + if (rc < 0) IPW_DEBUG_INFO("FAILED wait for clock stablization\n"); /* assert SW reset */ @@ -2315,7 +2331,6 @@ static int ipw_init_nic(struct ipw_priv *priv) return 0; } - /* Call this function from process context, it will sleep in request_firmware. * Probe is an ok place to call this from. */ @@ -2383,8 +2398,7 @@ static inline void ipw_rx_queue_reset(struct ipw_priv *priv, * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].skb != NULL) { pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr, - CX2_RX_BUF_SIZE, - PCI_DMA_FROMDEVICE); + CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); dev_kfree_skb(rxq->pool[i].skb); } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -2438,12 +2452,12 @@ static int ipw_load(struct ipw_priv *priv) if (rc) goto error; - rc = ipw_get_fw(priv, &firmware, IPW_FW_NAME("sniffer")); + rc = ipw_get_fw(priv, &firmware, + IPW_FW_NAME("sniffer")); break; #endif case IW_MODE_INFRA: - rc = ipw_get_fw(priv, &ucode, - IPW_FW_NAME("bss_ucode")); + rc = ipw_get_fw(priv, &ucode, IPW_FW_NAME("bss_ucode")); if (rc) goto error; @@ -2471,7 +2485,7 @@ static int ipw_load(struct ipw_priv *priv) goto error; } - retry: + retry: /* Ensure interrupts are disabled */ ipw_write32(priv, CX2_INTA_MASK_R, ~CX2_INTA_MASK_ALL); priv->status &= ~STATUS_INT_ENABLED; @@ -2528,7 +2542,7 @@ static int ipw_load(struct ipw_priv *priv) rc = ipw_load_firmware(priv, firmware->data + sizeof(struct fw_header), firmware->size - sizeof(struct fw_header)); - if (rc < 0 ) { + if (rc < 0) { IPW_ERROR("Unable to load firmware\n"); goto error; } @@ -2593,7 +2607,7 @@ static int ipw_load(struct ipw_priv *priv) #endif return 0; - error: + error: if (priv->rxq) { ipw_rx_queue_free(priv, priv->rxq); priv->rxq = NULL; @@ -2671,8 +2685,7 @@ static inline int ipw_queue_inc_wrap(int index, int n_bd) * (not offset within BAR, full address) */ static void ipw_queue_init(struct ipw_priv *priv, struct clx2_queue *q, - int count, u32 read, u32 write, - u32 base, u32 size) + int count, u32 read, u32 write, u32 base, u32 size) { q->n_bd = count; @@ -2698,8 +2711,7 @@ static void ipw_queue_init(struct ipw_priv *priv, struct clx2_queue *q, static int ipw_queue_tx_init(struct ipw_priv *priv, struct clx2_tx_queue *q, - int count, u32 read, u32 write, - u32 base, u32 size) + int count, u32 read, u32 write, u32 base, u32 size) { struct pci_dev *dev = priv->pci_dev; @@ -2709,10 +2721,11 @@ static int ipw_queue_tx_init(struct ipw_priv *priv, return -ENOMEM; } - q->bd = pci_alloc_consistent(dev,sizeof(q->bd[0])*count, &q->q.dma_addr); + q->bd = + pci_alloc_consistent(dev, sizeof(q->bd[0]) * count, &q->q.dma_addr); if (!q->bd) { IPW_ERROR("pci_alloc_consistent(%zd) failed\n", - sizeof(q->bd[0]) * count); + sizeof(q->bd[0]) * count); kfree(q->txb); q->txb = NULL; return -ENOMEM; @@ -2768,8 +2781,7 @@ static void ipw_queue_tx_free_tfd(struct ipw_priv *priv, * @param dev * @param q */ -static void ipw_queue_tx_free(struct ipw_priv *priv, - struct clx2_tx_queue *txq) +static void ipw_queue_tx_free(struct ipw_priv *priv, struct clx2_tx_queue *txq) { struct clx2_queue *q = &txq->q; struct pci_dev *dev = priv->pci_dev; @@ -2784,7 +2796,7 @@ static void ipw_queue_tx_free(struct ipw_priv *priv, } /* free buffers belonging to queue itself */ - pci_free_consistent(dev, sizeof(txq->bd[0])*q->n_bd, txq->bd, + pci_free_consistent(dev, sizeof(txq->bd[0]) * q->n_bd, txq->bd, q->dma_addr); kfree(txq->txb); @@ -2792,7 +2804,6 @@ static void ipw_queue_tx_free(struct ipw_priv *priv, memset(txq, 0, sizeof(*txq)); } - /** * Destroy all DMA queues and structures * @@ -2825,7 +2836,7 @@ static void inline __maybe_wake_tx(struct ipw_priv *priv) } -static inline void ipw_create_bssid(struct ipw_priv *priv, u8 *bssid) +static inline void ipw_create_bssid(struct ipw_priv *priv, u8 * bssid) { /* First 3 bytes are manufacturer */ bssid[0] = priv->mac_addr[0]; @@ -2833,13 +2844,13 @@ static inline void ipw_create_bssid(struct ipw_priv *priv, u8 *bssid) bssid[2] = priv->mac_addr[2]; /* Last bytes are random */ - get_random_bytes(&bssid[3], ETH_ALEN-3); + get_random_bytes(&bssid[3], ETH_ALEN - 3); - bssid[0] &= 0xfe; /* clear multicast bit */ - bssid[0] |= 0x02; /* set local assignment bit (IEEE802) */ + bssid[0] &= 0xfe; /* clear multicast bit */ + bssid[0] |= 0x02; /* set local assignment bit (IEEE802) */ } -static inline u8 ipw_add_station(struct ipw_priv *priv, u8 *bssid) +static inline u8 ipw_add_station(struct ipw_priv *priv, u8 * bssid) { struct ipw_station_entry entry; int i; @@ -2866,14 +2877,13 @@ static inline u8 ipw_add_station(struct ipw_priv *priv, u8 *bssid) memcpy(entry.mac_addr, bssid, ETH_ALEN); memcpy(priv->stations[i], bssid, ETH_ALEN); ipw_write_direct(priv, IPW_STATION_TABLE_LOWER + i * sizeof(entry), - &entry, - sizeof(entry)); + &entry, sizeof(entry)); priv->num_stations++; return i; } -static inline u8 ipw_find_station(struct ipw_priv *priv, u8 *bssid) +static inline u8 ipw_find_station(struct ipw_priv *priv, u8 * bssid) { int i; @@ -2944,26 +2954,34 @@ static const struct ipw_status_code ipw_status_codes[] = { "association exists"}, {0x0C, "Association denied due to reason outside the scope of this " "standard"}, - {0x0D, "Responding station does not support the specified authentication " + {0x0D, + "Responding station does not support the specified authentication " "algorithm"}, - {0x0E, "Received an Authentication frame with authentication sequence " + {0x0E, + "Received an Authentication frame with authentication sequence " "transaction sequence number out of expected sequence"}, {0x0F, "Authentication rejected because of challenge failure"}, {0x10, "Authentication rejected due to timeout waiting for next " "frame in sequence"}, {0x11, "Association denied because AP is unable to handle additional " "associated stations"}, - {0x12, "Association denied due to requesting station not supporting all " + {0x12, + "Association denied due to requesting station not supporting all " "of the datarates in the BSSBasicServiceSet Parameter"}, - {0x13, "Association denied due to requesting station not supporting " + {0x13, + "Association denied due to requesting station not supporting " "short preamble operation"}, - {0x14, "Association denied due to requesting station not supporting " + {0x14, + "Association denied due to requesting station not supporting " "PBCC encoding"}, - {0x15, "Association denied due to requesting station not supporting " + {0x15, + "Association denied due to requesting station not supporting " "channel agility"}, - {0x19, "Association denied due to requesting station not supporting " + {0x19, + "Association denied due to requesting station not supporting " "short slot operation"}, - {0x1A, "Association denied due to requesting station not supporting " + {0x1A, + "Association denied due to requesting station not supporting " "DSSS-OFDM operation"}, {0x28, "Invalid Information Element"}, {0x29, "Group Cipher is not valid"}, @@ -3043,7 +3061,6 @@ static void ipw_reset_stats(struct ipw_priv *priv) } - static inline u32 ipw_get_max_rate(struct ipw_priv *priv) { u32 i = 0x80000000; @@ -3056,20 +3073,21 @@ static inline u32 ipw_get_max_rate(struct ipw_priv *priv) /* TODO: Verify that the rate is supported by the current rates * list. */ - while (i && !(mask & i)) i >>= 1; + while (i && !(mask & i)) + i >>= 1; switch (i) { - case IEEE80211_CCK_RATE_1MB_MASK: return 1000000; - case IEEE80211_CCK_RATE_2MB_MASK: return 2000000; - case IEEE80211_CCK_RATE_5MB_MASK: return 5500000; - case IEEE80211_OFDM_RATE_6MB_MASK: return 6000000; - case IEEE80211_OFDM_RATE_9MB_MASK: return 9000000; - case IEEE80211_CCK_RATE_11MB_MASK: return 11000000; - case IEEE80211_OFDM_RATE_12MB_MASK: return 12000000; - case IEEE80211_OFDM_RATE_18MB_MASK: return 18000000; - case IEEE80211_OFDM_RATE_24MB_MASK: return 24000000; - case IEEE80211_OFDM_RATE_36MB_MASK: return 36000000; - case IEEE80211_OFDM_RATE_48MB_MASK: return 48000000; - case IEEE80211_OFDM_RATE_54MB_MASK: return 54000000; + case IEEE80211_CCK_RATE_1MB_MASK: return 1000000; + case IEEE80211_CCK_RATE_2MB_MASK: return 2000000; + case IEEE80211_CCK_RATE_5MB_MASK: return 5500000; + case IEEE80211_OFDM_RATE_6MB_MASK: return 6000000; + case IEEE80211_OFDM_RATE_9MB_MASK: return 9000000; + case IEEE80211_CCK_RATE_11MB_MASK: return 11000000; + case IEEE80211_OFDM_RATE_12MB_MASK: return 12000000; + case IEEE80211_OFDM_RATE_18MB_MASK: return 18000000; + case IEEE80211_OFDM_RATE_24MB_MASK: return 24000000; + case IEEE80211_OFDM_RATE_36MB_MASK: return 36000000; + case IEEE80211_OFDM_RATE_48MB_MASK: return 48000000; + case IEEE80211_OFDM_RATE_54MB_MASK: return 54000000; } if (priv->ieee->mode == IEEE_B) @@ -3097,18 +3115,18 @@ static u32 ipw_get_current_rate(struct ipw_priv *priv) return ipw_get_max_rate(priv); switch (rate) { - case IPW_TX_RATE_1MB: return 1000000; - case IPW_TX_RATE_2MB: return 2000000; - case IPW_TX_RATE_5MB: return 5500000; - case IPW_TX_RATE_6MB: return 6000000; - case IPW_TX_RATE_9MB: return 9000000; - case IPW_TX_RATE_11MB: return 11000000; - case IPW_TX_RATE_12MB: return 12000000; - case IPW_TX_RATE_18MB: return 18000000; - case IPW_TX_RATE_24MB: return 24000000; - case IPW_TX_RATE_36MB: return 36000000; - case IPW_TX_RATE_48MB: return 48000000; - case IPW_TX_RATE_54MB: return 54000000; + case IPW_TX_RATE_1MB: return 1000000; + case IPW_TX_RATE_2MB: return 2000000; + case IPW_TX_RATE_5MB: return 5500000; + case IPW_TX_RATE_6MB: return 6000000; + case IPW_TX_RATE_9MB: return 9000000; + case IPW_TX_RATE_11MB: return 11000000; + case IPW_TX_RATE_12MB: return 12000000; + case IPW_TX_RATE_18MB: return 18000000; + case IPW_TX_RATE_24MB: return 24000000; + case IPW_TX_RATE_36MB: return 36000000; + case IPW_TX_RATE_48MB: return 48000000; + case IPW_TX_RATE_54MB: return 54000000; } return 0; @@ -3126,7 +3144,7 @@ static void ipw_gather_stats(struct ipw_priv *priv) u32 len = sizeof(u32); s16 rssi; u32 beacon_quality, signal_quality, tx_quality, rx_quality, - rate_quality; + rate_quality; if (!(priv->status & STATUS_ASSOCIATED)) { priv->quality = 0; @@ -3136,13 +3154,12 @@ static void ipw_gather_stats(struct ipw_priv *priv) /* Update the statistics */ ipw_get_ordinal(priv, IPW_ORD_STAT_MISSED_BEACONS, &priv->missed_beacons, &len); - missed_beacons_delta = priv->missed_beacons - - priv->last_missed_beacons; + missed_beacons_delta = priv->missed_beacons - priv->last_missed_beacons; priv->last_missed_beacons = priv->missed_beacons; if (priv->assoc_request.beacon_interval) { missed_beacons_percent = missed_beacons_delta * - (HZ * priv->assoc_request.beacon_interval) / - (IPW_STATS_INTERVAL * 10); + (HZ * priv->assoc_request.beacon_interval) / + (IPW_STATS_INTERVAL * 10); } else { missed_beacons_percent = 0; } @@ -3179,28 +3196,26 @@ static void ipw_gather_stats(struct ipw_priv *priv) beacon_quality = 0; else beacon_quality = (beacon_quality - BEACON_THRESHOLD) * 100 / - (100 - BEACON_THRESHOLD); + (100 - BEACON_THRESHOLD); IPW_DEBUG_STATS("Missed beacon: %3d%% (%d%%)\n", beacon_quality, missed_beacons_percent); priv->last_rate = ipw_get_current_rate(priv); - rate_quality = priv->last_rate * 40 / priv->last_rate + 60; + rate_quality = priv->last_rate * 40 / priv->last_rate + 60; IPW_DEBUG_STATS("Rate quality : %3d%% (%dMbs)\n", rate_quality, priv->last_rate / 1000000); - if (rx_packets_delta > 100 && - rx_packets_delta + rx_err_delta) + if (rx_packets_delta > 100 && rx_packets_delta + rx_err_delta) rx_quality = 100 - (rx_err_delta * 100) / - (rx_packets_delta + rx_err_delta); + (rx_packets_delta + rx_err_delta); else rx_quality = 100; IPW_DEBUG_STATS("Rx quality : %3d%% (%u errors, %u packets)\n", rx_quality, rx_err_delta, rx_packets_delta); - if (tx_packets_delta > 100 && - tx_packets_delta + tx_failures_delta) + if (tx_packets_delta > 100 && tx_packets_delta + tx_failures_delta) tx_quality = 100 - (tx_failures_delta * 100) / - (tx_packets_delta + tx_failures_delta); + (tx_packets_delta + tx_failures_delta); else tx_quality = 100; IPW_DEBUG_STATS("Tx quality : %3d%% (%u errors, %u packets)\n", @@ -3213,7 +3228,7 @@ static void ipw_gather_stats(struct ipw_priv *priv) signal_quality = 0; else signal_quality = (rssi - WORST_RSSI) * 100 / - (PERFECT_RSSI - WORST_RSSI); + (PERFECT_RSSI - WORST_RSSI); IPW_DEBUG_STATS("Signal level : %3d%% (%d dBm)\n", signal_quality, rssi); @@ -3221,25 +3236,20 @@ static void ipw_gather_stats(struct ipw_priv *priv) min(rate_quality, min(tx_quality, min(rx_quality, signal_quality)))); if (quality == beacon_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to missed beacons.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to missed beacons.\n", + quality); if (quality == rate_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to rate quality.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to rate quality.\n", + quality); if (quality == tx_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to Tx quality.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to Tx quality.\n", + quality); if (quality == rx_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to Rx quality.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to Rx quality.\n", + quality); if (quality == signal_quality) - IPW_DEBUG_STATS( - "Quality (%d%%): Clamped to signal quality.\n", - quality); + IPW_DEBUG_STATS("Quality (%d%%): Clamped to signal quality.\n", + quality); priv->quality = quality; @@ -3251,402 +3261,454 @@ static void ipw_gather_stats(struct ipw_priv *priv) * Handle host notification packet. * Called from interrupt routine */ -static inline void ipw_rx_notification(struct ipw_priv* priv, +static inline void ipw_rx_notification(struct ipw_priv *priv, struct ipw_rx_notification *notif) { - IPW_DEBUG_NOTIF("type = %i (%d bytes)\n", - notif->subtype, notif->size); + IPW_DEBUG_NOTIF("type = %i (%d bytes)\n", notif->subtype, notif->size); switch (notif->subtype) { - case HOST_NOTIFICATION_STATUS_ASSOCIATED: { - struct notif_association *assoc = ¬if->u.assoc; - - switch (assoc->state) { - case CMAS_ASSOCIATED: { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "associated: '%s' " MAC_FMT " \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); - - switch (priv->ieee->iw_mode) { - case IW_MODE_INFRA: - memcpy(priv->ieee->bssid, priv->bssid, - ETH_ALEN); - break; - - case IW_MODE_ADHOC: - memcpy(priv->ieee->bssid, priv->bssid, - ETH_ALEN); - - /* clear out the station table */ - priv->num_stations = 0; - - IPW_DEBUG_ASSOC("queueing adhoc check\n"); - queue_delayed_work(priv->workqueue, - &priv->adhoc_check, - priv->assoc_request.beacon_interval); - break; - } - - priv->status &= ~STATUS_ASSOCIATING; - priv->status |= STATUS_ASSOCIATED; - - netif_carrier_on(priv->net_dev); - if (netif_queue_stopped(priv->net_dev)) { - IPW_DEBUG_NOTIF("waking queue\n"); - netif_wake_queue(priv->net_dev); - } else { - IPW_DEBUG_NOTIF("starting queue\n"); - netif_start_queue(priv->net_dev); - } - - ipw_reset_stats(priv); - /* Ensure the rate is updated immediately */ - priv->last_rate = ipw_get_current_rate(priv); - schedule_work(&priv->gather_stats); - notify_wx_assoc_event(priv); + case HOST_NOTIFICATION_STATUS_ASSOCIATED:{ + struct notif_association *assoc = ¬if->u.assoc; + + switch (assoc->state) { + case CMAS_ASSOCIATED:{ + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "associated: '%s' " MAC_FMT + " \n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + + switch (priv->ieee->iw_mode) { + case IW_MODE_INFRA: + memcpy(priv->ieee->bssid, + priv->bssid, ETH_ALEN); + break; + + case IW_MODE_ADHOC: + memcpy(priv->ieee->bssid, + priv->bssid, ETH_ALEN); + + /* clear out the station table */ + priv->num_stations = 0; + + IPW_DEBUG_ASSOC + ("queueing adhoc check\n"); + queue_delayed_work(priv-> + workqueue, + &priv-> + adhoc_check, + priv-> + assoc_request. + beacon_interval); + break; + } + + priv->status &= ~STATUS_ASSOCIATING; + priv->status |= STATUS_ASSOCIATED; + + netif_carrier_on(priv->net_dev); + if (netif_queue_stopped(priv->net_dev)) { + IPW_DEBUG_NOTIF + ("waking queue\n"); + netif_wake_queue(priv->net_dev); + } else { + IPW_DEBUG_NOTIF + ("starting queue\n"); + netif_start_queue(priv-> + net_dev); + } + + ipw_reset_stats(priv); + /* Ensure the rate is updated immediately */ + priv->last_rate = + ipw_get_current_rate(priv); + schedule_work(&priv->gather_stats); + notify_wx_assoc_event(priv); /* queue_delayed_work(priv->workqueue, &priv->request_scan, SCAN_ASSOCIATED_INTERVAL); */ - break; - } + break; + } - case CMAS_AUTHENTICATED: { - if (priv->status & (STATUS_ASSOCIATED | STATUS_AUTH)) { + case CMAS_AUTHENTICATED:{ + if (priv-> + status & (STATUS_ASSOCIATED | + STATUS_AUTH)) { #ifdef CONFIG_IPW_DEBUG - struct notif_authenticate *auth = ¬if->u.auth; - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "deauthenticated: '%s' " MAC_FMT ": (0x%04X) - %s \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid), - ntohs(auth->status), - ipw_get_status_code(ntohs(auth->status))); + struct notif_authenticate *auth + = ¬if->u.auth; + IPW_DEBUG(IPW_DL_NOTIF | + IPW_DL_STATE | + IPW_DL_ASSOC, + "deauthenticated: '%s' " + MAC_FMT + ": (0x%04X) - %s \n", + escape_essid(priv-> + essid, + priv-> + essid_len), + MAC_ARG(priv->bssid), + ntohs(auth->status), + ipw_get_status_code + (ntohs + (auth->status))); #endif - priv->status &= ~(STATUS_ASSOCIATING | - STATUS_AUTH | - STATUS_ASSOCIATED); + priv->status &= + ~(STATUS_ASSOCIATING | + STATUS_AUTH | + STATUS_ASSOCIATED); + + netif_carrier_off(priv-> + net_dev); + netif_stop_queue(priv->net_dev); + queue_work(priv->workqueue, + &priv->request_scan); + notify_wx_assoc_event(priv); + break; + } + + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "authenticated: '%s' " MAC_FMT + "\n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + break; + } + + case CMAS_INIT:{ + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "disassociated: '%s' " MAC_FMT + " \n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + + priv->status &= + ~(STATUS_DISASSOCIATING | + STATUS_ASSOCIATING | + STATUS_ASSOCIATED | STATUS_AUTH); + + netif_stop_queue(priv->net_dev); + if (!(priv->status & STATUS_ROAMING)) { + netif_carrier_off(priv-> + net_dev); + notify_wx_assoc_event(priv); + + /* Cancel any queued work ... */ + cancel_delayed_work(&priv-> + request_scan); + cancel_delayed_work(&priv-> + adhoc_check); + + /* Queue up another scan... */ + queue_work(priv->workqueue, + &priv->request_scan); + + cancel_delayed_work(&priv-> + gather_stats); + } else { + priv->status |= STATUS_ROAMING; + queue_work(priv->workqueue, + &priv->request_scan); + } + + ipw_reset_stats(priv); + break; + } - netif_carrier_off(priv->net_dev); - netif_stop_queue(priv->net_dev); - queue_work(priv->workqueue, &priv->request_scan); - notify_wx_assoc_event(priv); + default: + IPW_ERROR("assoc: unknown (%d)\n", + assoc->state); break; } - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "authenticated: '%s' " MAC_FMT "\n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); break; } - case CMAS_INIT: { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "disassociated: '%s' " MAC_FMT " \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); + case HOST_NOTIFICATION_STATUS_AUTHENTICATE:{ + struct notif_authenticate *auth = ¬if->u.auth; + switch (auth->state) { + case CMAS_AUTHENTICATED: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, + "authenticated: '%s' " MAC_FMT " \n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + priv->status |= STATUS_AUTH; + break; - priv->status &= ~( - STATUS_DISASSOCIATING | - STATUS_ASSOCIATING | - STATUS_ASSOCIATED | - STATUS_AUTH); + case CMAS_INIT: + if (priv->status & STATUS_AUTH) { + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "authentication failed (0x%04X): %s\n", + ntohs(auth->status), + ipw_get_status_code(ntohs + (auth-> + status))); + } + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, + "deauthenticated: '%s' " MAC_FMT "\n", + escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); - netif_stop_queue(priv->net_dev); - if (!(priv->status & STATUS_ROAMING)) { - netif_carrier_off(priv->net_dev); - notify_wx_assoc_event(priv); - - /* Cancel any queued work ... */ - cancel_delayed_work(&priv->request_scan); - cancel_delayed_work(&priv->adhoc_check); + priv->status &= ~(STATUS_ASSOCIATING | + STATUS_AUTH | + STATUS_ASSOCIATED); - /* Queue up another scan... */ + netif_carrier_off(priv->net_dev); + netif_stop_queue(priv->net_dev); queue_work(priv->workqueue, &priv->request_scan); + notify_wx_assoc_event(priv); + break; - cancel_delayed_work(&priv->gather_stats); - } else { - priv->status |= STATUS_ROAMING; - queue_work(priv->workqueue, - &priv->request_scan); + case CMAS_TX_AUTH_SEQ_1: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_1\n"); + break; + case CMAS_RX_AUTH_SEQ_2: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_2\n"); + break; + case CMAS_AUTH_SEQ_1_PASS: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_1_PASS\n"); + break; + case CMAS_AUTH_SEQ_1_FAIL: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_1_FAIL\n"); + break; + case CMAS_TX_AUTH_SEQ_3: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_3\n"); + break; + case CMAS_RX_AUTH_SEQ_4: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "RX_AUTH_SEQ_4\n"); + break; + case CMAS_AUTH_SEQ_2_PASS: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUTH_SEQ_2_PASS\n"); + break; + case CMAS_AUTH_SEQ_2_FAIL: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "AUT_SEQ_2_FAIL\n"); + break; + case CMAS_TX_ASSOC: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "TX_ASSOC\n"); + break; + case CMAS_RX_ASSOC_RESP: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "RX_ASSOC_RESP\n"); + break; + case CMAS_ASSOCIATED: + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | + IPW_DL_ASSOC, "ASSOCIATED\n"); + break; + default: + IPW_DEBUG_NOTIF("auth: failure - %d\n", + auth->state); + break; } - - ipw_reset_stats(priv); - break; - } - - default: - IPW_ERROR("assoc: unknown (%d)\n", - assoc->state); break; } - break; - } + case HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT:{ + struct notif_channel_result *x = + ¬if->u.channel_result; - case HOST_NOTIFICATION_STATUS_AUTHENTICATE: { - struct notif_authenticate *auth = ¬if->u.auth; - switch (auth->state) { - case CMAS_AUTHENTICATED: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, - "authenticated: '%s' " MAC_FMT " \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); - priv->status |= STATUS_AUTH; - break; - - case CMAS_INIT: - if (priv->status & STATUS_AUTH) { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "authentication failed (0x%04X): %s\n", - ntohs(auth->status), - ipw_get_status_code(ntohs(auth->status))); + if (notif->size == sizeof(*x)) { + IPW_DEBUG_SCAN("Scan result for channel %d\n", + x->channel_num); + } else { + IPW_DEBUG_SCAN("Scan result of wrong size %d " + "(should be %zd)\n", + notif->size, sizeof(*x)); } - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "deauthenticated: '%s' " MAC_FMT "\n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); - - priv->status &= ~(STATUS_ASSOCIATING | - STATUS_AUTH | - STATUS_ASSOCIATED); - - netif_carrier_off(priv->net_dev); - netif_stop_queue(priv->net_dev); - queue_work(priv->workqueue, &priv->request_scan); - notify_wx_assoc_event(priv); - break; - - case CMAS_TX_AUTH_SEQ_1: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_1\n"); - break; - case CMAS_RX_AUTH_SEQ_2: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_2\n"); - break; - case CMAS_AUTH_SEQ_1_PASS: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_1_PASS\n"); - break; - case CMAS_AUTH_SEQ_1_FAIL: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_1_FAIL\n"); - break; - case CMAS_TX_AUTH_SEQ_3: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_3\n"); - break; - case CMAS_RX_AUTH_SEQ_4: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "RX_AUTH_SEQ_4\n"); - break; - case CMAS_AUTH_SEQ_2_PASS: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUTH_SEQ_2_PASS\n"); - break; - case CMAS_AUTH_SEQ_2_FAIL: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "AUT_SEQ_2_FAIL\n"); - break; - case CMAS_TX_ASSOC: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "TX_ASSOC\n"); - break; - case CMAS_RX_ASSOC_RESP: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "RX_ASSOC_RESP\n"); - break; - case CMAS_ASSOCIATED: - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE | IPW_DL_ASSOC, - "ASSOCIATED\n"); - break; - default: - IPW_DEBUG_NOTIF("auth: failure - %d\n", auth->state); break; } - break; - } - - case HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT: { - struct notif_channel_result *x = ¬if->u.channel_result; - - if (notif->size == sizeof(*x)) { - IPW_DEBUG_SCAN("Scan result for channel %d\n", - x->channel_num); - } else { - IPW_DEBUG_SCAN("Scan result of wrong size %d " - "(should be %zd)\n", - notif->size, sizeof(*x)); - } - break; - } - case HOST_NOTIFICATION_STATUS_SCAN_COMPLETED: { - struct notif_scan_complete* x = ¬if->u.scan_complete; - if (notif->size == sizeof(*x)) { - IPW_DEBUG_SCAN("Scan completed: type %d, %d channels, " - "%d status\n", - x->scan_type, - x->num_channels, - x->status); - } else { - IPW_ERROR("Scan completed of wrong size %d " - "(should be %zd)\n", - notif->size, sizeof(*x)); - } - - priv->status &= ~(STATUS_SCANNING | STATUS_SCAN_ABORTING); - - cancel_delayed_work(&priv->scan_check); - - if (!(priv->status & (STATUS_ASSOCIATED | - STATUS_ASSOCIATING | - STATUS_ROAMING | - STATUS_DISASSOCIATING))) - queue_work(priv->workqueue, &priv->associate); - else if (priv->status & STATUS_ROAMING) { - /* If a scan completed and we are in roam mode, then - * the scan that completed was the one requested as a - * result of entering roam... so, schedule the - * roam work */ - queue_work(priv->workqueue, &priv->roam); - } else if (priv->status & STATUS_SCAN_PENDING) - queue_work(priv->workqueue, &priv->request_scan); - - priv->ieee->scans++; - break; - } + case HOST_NOTIFICATION_STATUS_SCAN_COMPLETED:{ + struct notif_scan_complete *x = ¬if->u.scan_complete; + if (notif->size == sizeof(*x)) { + IPW_DEBUG_SCAN + ("Scan completed: type %d, %d channels, " + "%d status\n", x->scan_type, + x->num_channels, x->status); + } else { + IPW_ERROR("Scan completed of wrong size %d " + "(should be %zd)\n", + notif->size, sizeof(*x)); + } - case HOST_NOTIFICATION_STATUS_FRAG_LENGTH: { - struct notif_frag_length *x = ¬if->u.frag_len; + priv->status &= + ~(STATUS_SCANNING | STATUS_SCAN_ABORTING); + + cancel_delayed_work(&priv->scan_check); + + if (!(priv->status & (STATUS_ASSOCIATED | + STATUS_ASSOCIATING | + STATUS_ROAMING | + STATUS_DISASSOCIATING))) + queue_work(priv->workqueue, &priv->associate); + else if (priv->status & STATUS_ROAMING) { + /* If a scan completed and we are in roam mode, then + * the scan that completed was the one requested as a + * result of entering roam... so, schedule the + * roam work */ + queue_work(priv->workqueue, &priv->roam); + } else if (priv->status & STATUS_SCAN_PENDING) + queue_work(priv->workqueue, + &priv->request_scan); - if (notif->size == sizeof(*x)) { - IPW_ERROR("Frag length: %d\n", x->frag_length); - } else { - IPW_ERROR("Frag length of wrong size %d " - "(should be %zd)\n", - notif->size, sizeof(*x)); + priv->ieee->scans++; + break; } - break; - } - case HOST_NOTIFICATION_STATUS_LINK_DETERIORATION: { - struct notif_link_deterioration *x = - ¬if->u.link_deterioration; - if (notif->size==sizeof(*x)) { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, - "link deterioration: '%s' " MAC_FMT " \n", - escape_essid(priv->essid, priv->essid_len), - MAC_ARG(priv->bssid)); - memcpy(&priv->last_link_deterioration, x, sizeof(*x)); - } else { - IPW_ERROR("Link Deterioration of wrong size %d " - "(should be %zd)\n", - notif->size, sizeof(*x)); - } - break; - } + case HOST_NOTIFICATION_STATUS_FRAG_LENGTH:{ + struct notif_frag_length *x = ¬if->u.frag_len; - case HOST_NOTIFICATION_DINO_CONFIG_RESPONSE: { - IPW_ERROR("Dino config\n"); - if (priv->hcmd && priv->hcmd->cmd == HOST_CMD_DINO_CONFIG) { - /* TODO: Do anything special? */ - } else { - IPW_ERROR("Unexpected DINO_CONFIG_RESPONSE\n"); + if (notif->size == sizeof(*x)) { + IPW_ERROR("Frag length: %d\n", x->frag_length); + } else { + IPW_ERROR("Frag length of wrong size %d " + "(should be %zd)\n", + notif->size, sizeof(*x)); + } + break; } - break; - } - case HOST_NOTIFICATION_STATUS_BEACON_STATE: { - struct notif_beacon_state *x = ¬if->u.beacon_state; - if (notif->size != sizeof(*x)) { - IPW_ERROR("Beacon state of wrong size %d (should " - "be %zd)\n", notif->size, sizeof(*x)); + case HOST_NOTIFICATION_STATUS_LINK_DETERIORATION:{ + struct notif_link_deterioration *x = + ¬if->u.link_deterioration; + if (notif->size == sizeof(*x)) { + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, + "link deterioration: '%s' " MAC_FMT + " \n", escape_essid(priv->essid, + priv->essid_len), + MAC_ARG(priv->bssid)); + memcpy(&priv->last_link_deterioration, x, + sizeof(*x)); + } else { + IPW_ERROR("Link Deterioration of wrong size %d " + "(should be %zd)\n", + notif->size, sizeof(*x)); + } break; } - if (x->state == HOST_NOTIFICATION_STATUS_BEACON_MISSING) { - if (priv->status & STATUS_SCANNING) { - /* Stop scan to keep fw from getting - * stuck... */ - queue_work(priv->workqueue, - &priv->abort_scan); + case HOST_NOTIFICATION_DINO_CONFIG_RESPONSE:{ + IPW_ERROR("Dino config\n"); + if (priv->hcmd + && priv->hcmd->cmd == HOST_CMD_DINO_CONFIG) { + /* TODO: Do anything special? */ + } else { + IPW_ERROR("Unexpected DINO_CONFIG_RESPONSE\n"); } + break; + } - if (x->number > priv->missed_beacon_threshold && - priv->status & STATUS_ASSOCIATED) { - IPW_DEBUG(IPW_DL_INFO | IPW_DL_NOTIF | - IPW_DL_STATE, - "Missed beacon: %d - disassociate\n", - x->number); - queue_work(priv->workqueue, - &priv->disassociate); - } else if (x->number > priv->roaming_threshold) { - IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, - "Missed beacon: %d - initiate " - "roaming\n", - x->number); - queue_work(priv->workqueue, - &priv->roam); - } else { - IPW_DEBUG_NOTIF("Missed beacon: %d\n", - x->number); + case HOST_NOTIFICATION_STATUS_BEACON_STATE:{ + struct notif_beacon_state *x = ¬if->u.beacon_state; + if (notif->size != sizeof(*x)) { + IPW_ERROR + ("Beacon state of wrong size %d (should " + "be %zd)\n", notif->size, sizeof(*x)); + break; } - priv->notif_missed_beacons = x->number; + if (x->state == HOST_NOTIFICATION_STATUS_BEACON_MISSING) { + if (priv->status & STATUS_SCANNING) { + /* Stop scan to keep fw from getting + * stuck... */ + queue_work(priv->workqueue, + &priv->abort_scan); + } + + if (x->number > priv->missed_beacon_threshold && + priv->status & STATUS_ASSOCIATED) { + IPW_DEBUG(IPW_DL_INFO | IPW_DL_NOTIF | + IPW_DL_STATE, + "Missed beacon: %d - disassociate\n", + x->number); + queue_work(priv->workqueue, + &priv->disassociate); + } else if (x->number > priv->roaming_threshold) { + IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE, + "Missed beacon: %d - initiate " + "roaming\n", x->number); + queue_work(priv->workqueue, + &priv->roam); + } else { + IPW_DEBUG_NOTIF("Missed beacon: %d\n", + x->number); + } + + priv->notif_missed_beacons = x->number; - } + } + break; + } - break; - } + case HOST_NOTIFICATION_STATUS_TGI_TX_KEY:{ + struct notif_tgi_tx_key *x = ¬if->u.tgi_tx_key; + if (notif->size == sizeof(*x)) { + IPW_ERROR("TGi Tx Key: state 0x%02x sec type " + "0x%02x station %d\n", + x->key_state, x->security_type, + x->station_index); + break; + } - case HOST_NOTIFICATION_STATUS_TGI_TX_KEY: { - struct notif_tgi_tx_key *x = ¬if->u.tgi_tx_key; - if (notif->size==sizeof(*x)) { - IPW_ERROR("TGi Tx Key: state 0x%02x sec type " - "0x%02x station %d\n", - x->key_state,x->security_type, - x->station_index); + IPW_ERROR + ("TGi Tx Key of wrong size %d (should be %zd)\n", + notif->size, sizeof(*x)); break; } - IPW_ERROR("TGi Tx Key of wrong size %d (should be %zd)\n", - notif->size, sizeof(*x)); - break; - } + case HOST_NOTIFICATION_CALIB_KEEP_RESULTS:{ + struct notif_calibration *x = ¬if->u.calibration; - case HOST_NOTIFICATION_CALIB_KEEP_RESULTS: { - struct notif_calibration *x = ¬if->u.calibration; + if (notif->size == sizeof(*x)) { + memcpy(&priv->calib, x, sizeof(*x)); + IPW_DEBUG_INFO("TODO: Calibration\n"); + break; + } - if (notif->size == sizeof(*x)) { - memcpy(&priv->calib, x, sizeof(*x)); - IPW_DEBUG_INFO("TODO: Calibration\n"); + IPW_ERROR + ("Calibration of wrong size %d (should be %zd)\n", + notif->size, sizeof(*x)); break; } - IPW_ERROR("Calibration of wrong size %d (should be %zd)\n", - notif->size, sizeof(*x)); - break; - } + case HOST_NOTIFICATION_NOISE_STATS:{ + if (notif->size == sizeof(u32)) { + priv->last_noise = + (u8) (notif->u.noise.value & 0xff); + average_add(&priv->average_noise, + priv->last_noise); + break; + } - case HOST_NOTIFICATION_NOISE_STATS: { - if (notif->size == sizeof(u32)) { - priv->last_noise = (u8)(notif->u.noise.value & 0xff); - average_add(&priv->average_noise, priv->last_noise); + IPW_ERROR + ("Noise stat is wrong size %d (should be %zd)\n", + notif->size, sizeof(u32)); break; } - IPW_ERROR("Noise stat is wrong size %d (should be %zd)\n", - notif->size, sizeof(u32)); - break; - } - default: IPW_ERROR("Unknown notification: " "subtype=%d,flags=0x%2x,size=%d\n", @@ -3680,8 +3742,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) rc = ipw_queue_tx_init(priv, &priv->txq[0], nTx, CX2_TX_QUEUE_0_READ_INDEX, CX2_TX_QUEUE_0_WRITE_INDEX, - CX2_TX_QUEUE_0_BD_BASE, - CX2_TX_QUEUE_0_BD_SIZE); + CX2_TX_QUEUE_0_BD_BASE, CX2_TX_QUEUE_0_BD_SIZE); if (rc) { IPW_ERROR("Tx 0 queue init failed\n"); goto error; @@ -3689,8 +3750,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) rc = ipw_queue_tx_init(priv, &priv->txq[1], nTx, CX2_TX_QUEUE_1_READ_INDEX, CX2_TX_QUEUE_1_WRITE_INDEX, - CX2_TX_QUEUE_1_BD_BASE, - CX2_TX_QUEUE_1_BD_SIZE); + CX2_TX_QUEUE_1_BD_BASE, CX2_TX_QUEUE_1_BD_SIZE); if (rc) { IPW_ERROR("Tx 1 queue init failed\n"); goto error; @@ -3698,8 +3758,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) rc = ipw_queue_tx_init(priv, &priv->txq[2], nTx, CX2_TX_QUEUE_2_READ_INDEX, CX2_TX_QUEUE_2_WRITE_INDEX, - CX2_TX_QUEUE_2_BD_BASE, - CX2_TX_QUEUE_2_BD_SIZE); + CX2_TX_QUEUE_2_BD_BASE, CX2_TX_QUEUE_2_BD_SIZE); if (rc) { IPW_ERROR("Tx 2 queue init failed\n"); goto error; @@ -3707,8 +3766,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) rc = ipw_queue_tx_init(priv, &priv->txq[3], nTx, CX2_TX_QUEUE_3_READ_INDEX, CX2_TX_QUEUE_3_WRITE_INDEX, - CX2_TX_QUEUE_3_BD_BASE, - CX2_TX_QUEUE_3_BD_SIZE); + CX2_TX_QUEUE_3_BD_BASE, CX2_TX_QUEUE_3_BD_SIZE); if (rc) { IPW_ERROR("Tx 3 queue init failed\n"); goto error; @@ -3718,7 +3776,7 @@ static int ipw_queue_reset(struct ipw_priv *priv) priv->rx_pend_max = 0; return rc; - error: + error: ipw_tx_queue_free(priv); return rc; } @@ -3746,8 +3804,8 @@ static int ipw_queue_tx_reclaim(struct ipw_priv *priv, hw_tail = ipw_read32(priv, q->reg_r); if (hw_tail >= q->n_bd) { IPW_ERROR - ("Read index for DMA queue (%d) is out of range [0-%d)\n", - hw_tail, q->n_bd); + ("Read index for DMA queue (%d) is out of range [0-%d)\n", + hw_tail, q->n_bd); goto done; } for (; q->last_used != hw_tail; @@ -3755,7 +3813,7 @@ static int ipw_queue_tx_reclaim(struct ipw_priv *priv, ipw_queue_tx_free_tfd(priv, txq); priv->tx_packets++; } - done: + done: if (ipw_queue_space(q) > q->low_mark && qindex >= 0) { __maybe_wake_tx(priv); } @@ -3795,8 +3853,6 @@ static int ipw_queue_tx_hcmd(struct ipw_priv *priv, int hcmd, void *buf, return 0; } - - /* * Rx theory of operation * @@ -3933,9 +3989,9 @@ static void ipw_rx_queue_replenish(void *data) list_del(element); rxb->rxb = (struct ipw_rx_buffer *)rxb->skb->data; - rxb->dma_addr = pci_map_single( - priv->pci_dev, rxb->skb->data, CX2_RX_BUF_SIZE, - PCI_DMA_FROMDEVICE); + rxb->dma_addr = + pci_map_single(priv->pci_dev, rxb->skb->data, + CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; @@ -3950,8 +4006,7 @@ static void ipw_rx_queue_replenish(void *data) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -static void ipw_rx_queue_free(struct ipw_priv *priv, - struct ipw_rx_queue *rxq) +static void ipw_rx_queue_free(struct ipw_priv *priv, struct ipw_rx_queue *rxq) { int i; @@ -3961,8 +4016,7 @@ static void ipw_rx_queue_free(struct ipw_priv *priv, for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].skb != NULL) { pci_unmap_single(priv->pci_dev, rxq->pool[i].dma_addr, - CX2_RX_BUF_SIZE, - PCI_DMA_FROMDEVICE); + CX2_RX_BUF_SIZE, PCI_DMA_FROMDEVICE); dev_kfree_skb(rxq->pool[i].skb); } } @@ -4001,28 +4055,28 @@ static int ipw_is_rate_in_mask(struct ipw_priv *priv, int ieee_mode, u8 rate) switch (rate) { case IEEE80211_OFDM_RATE_6MB: return priv->rates_mask & IEEE80211_OFDM_RATE_6MB_MASK ? - 1 : 0; + 1 : 0; case IEEE80211_OFDM_RATE_9MB: return priv->rates_mask & IEEE80211_OFDM_RATE_9MB_MASK ? - 1 : 0; + 1 : 0; case IEEE80211_OFDM_RATE_12MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_12MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_18MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_18MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_24MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_24MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_36MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_36MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_48MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_48MB_MASK ? 1 : 0; case IEEE80211_OFDM_RATE_54MB: - return priv->rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ? - 1 : 0; + return priv-> + rates_mask & IEEE80211_OFDM_RATE_54MB_MASK ? 1 : 0; default: return 0; } @@ -4074,10 +4128,11 @@ static int ipw_compatible_rates(struct ipw_priv *priv, int num_rates, i; memset(rates, 0, sizeof(*rates)); - num_rates = min(network->rates_len, (u8)IPW_MAX_RATES); + num_rates = min(network->rates_len, (u8) IPW_MAX_RATES); rates->num_rates = 0; for (i = 0; i < num_rates; i++) { - if (!ipw_is_rate_in_mask(priv, network->mode, network->rates[i])) { + if (!ipw_is_rate_in_mask + (priv, network->mode, network->rates[i])) { IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n", network->rates[i], priv->rates_mask); continue; @@ -4086,15 +4141,18 @@ static int ipw_compatible_rates(struct ipw_priv *priv, rates->supported_rates[rates->num_rates++] = network->rates[i]; } - num_rates = min(network->rates_ex_len, (u8)(IPW_MAX_RATES - num_rates)); + num_rates = + min(network->rates_ex_len, (u8) (IPW_MAX_RATES - num_rates)); for (i = 0; i < num_rates; i++) { - if (!ipw_is_rate_in_mask(priv, network->mode, network->rates_ex[i])) { + if (!ipw_is_rate_in_mask + (priv, network->mode, network->rates_ex[i])) { IPW_DEBUG_SCAN("Rate %02X masked : 0x%08X\n", network->rates_ex[i], priv->rates_mask); continue; } - rates->supported_rates[rates->num_rates++] = network->rates_ex[i]; + rates->supported_rates[rates->num_rates++] = + network->rates_ex[i]; } return rates->num_rates; @@ -4113,65 +4171,65 @@ static inline void ipw_copy_rates(struct ipw_supported_rates *dest, * mask should ever be used -- right now all callers to add the scan rates are * set with the modulation = CCK, so BASIC_RATE_MASK is never set... */ static void ipw_add_cck_scan_rates(struct ipw_supported_rates *rates, - u8 modulation, u32 rate_mask) + u8 modulation, u32 rate_mask) { u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ? - IEEE80211_BASIC_RATE_MASK : 0; + IEEE80211_BASIC_RATE_MASK : 0; if (rate_mask & IEEE80211_CCK_RATE_1MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; + IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; if (rate_mask & IEEE80211_CCK_RATE_2MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; + IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB; if (rate_mask & IEEE80211_CCK_RATE_5MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_CCK_RATE_5MB; + IEEE80211_CCK_RATE_5MB; if (rate_mask & IEEE80211_CCK_RATE_11MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_CCK_RATE_11MB; + IEEE80211_CCK_RATE_11MB; } static void ipw_add_ofdm_scan_rates(struct ipw_supported_rates *rates, - u8 modulation, u32 rate_mask) + u8 modulation, u32 rate_mask) { u8 basic_mask = (IEEE80211_OFDM_MODULATION == modulation) ? - IEEE80211_BASIC_RATE_MASK : 0; + IEEE80211_BASIC_RATE_MASK : 0; if (rate_mask & IEEE80211_OFDM_RATE_6MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_OFDM_RATE_6MB; + IEEE80211_OFDM_RATE_6MB; if (rate_mask & IEEE80211_OFDM_RATE_9MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_9MB; + IEEE80211_OFDM_RATE_9MB; if (rate_mask & IEEE80211_OFDM_RATE_12MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_OFDM_RATE_12MB; + IEEE80211_OFDM_RATE_12MB; if (rate_mask & IEEE80211_OFDM_RATE_18MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_18MB; + IEEE80211_OFDM_RATE_18MB; if (rate_mask & IEEE80211_OFDM_RATE_24MB_MASK) rates->supported_rates[rates->num_rates++] = basic_mask | - IEEE80211_OFDM_RATE_24MB; + IEEE80211_OFDM_RATE_24MB; if (rate_mask & IEEE80211_OFDM_RATE_36MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_36MB; + IEEE80211_OFDM_RATE_36MB; if (rate_mask & IEEE80211_OFDM_RATE_48MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_48MB; + IEEE80211_OFDM_RATE_48MB; if (rate_mask & IEEE80211_OFDM_RATE_54MB_MASK) rates->supported_rates[rates->num_rates++] = - IEEE80211_OFDM_RATE_54MB; + IEEE80211_OFDM_RATE_54MB; } struct ipw_network_match { @@ -4179,11 +4237,9 @@ struct ipw_network_match { struct ipw_supported_rates rates; }; -static int ipw_best_network( - struct ipw_priv *priv, - struct ipw_network_match *match, - struct ieee80211_network *network, - int roaming) +static int ipw_best_network(struct ipw_priv *priv, + struct ipw_network_match *match, + struct ieee80211_network *network, int roaming) { struct ipw_supported_rates rates; @@ -4231,21 +4287,21 @@ static int ipw_best_network( memcmp(network->ssid, priv->essid, min(network->ssid_len, priv->essid_len)))) { char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; - strncpy(escaped, escape_essid( - network->ssid, network->ssid_len), + strncpy(escaped, + escape_essid(network->ssid, network->ssid_len), sizeof(escaped)); IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded " "because of ESSID mismatch: '%s'.\n", escaped, MAC_ARG(network->bssid), - escape_essid(priv->essid, priv->essid_len)); + escape_essid(priv->essid, + priv->essid_len)); return 0; } } /* If the old network rate is better than this one, don't bother * testing everything else. */ - if (match->network && match->network->stats.rssi > - network->stats.rssi) { + if (match->network && match->network->stats.rssi > network->stats.rssi) { char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; strncpy(escaped, escape_essid(network->ssid, network->ssid_len), @@ -4303,7 +4359,7 @@ static int ipw_best_network( priv->capability & CAP_PRIVACY_ON ? "on" : "off", network->capability & - WLAN_CAPABILITY_PRIVACY ?"on" : "off"); + WLAN_CAPABILITY_PRIVACY ? "on" : "off"); return 0; } @@ -4312,8 +4368,7 @@ static int ipw_best_network( IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded " "because of BSSID mismatch: " MAC_FMT ".\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid), - MAC_ARG(priv->bssid)); + MAC_ARG(network->bssid), MAC_ARG(priv->bssid)); return 0; } @@ -4351,9 +4406,8 @@ static int ipw_best_network( return 1; } - static void ipw_adhoc_create(struct ipw_priv *priv, - struct ieee80211_network *network) + struct ieee80211_network *network) { /* * For the purposes of scanning, we can set our wireless mode @@ -4393,8 +4447,7 @@ static void ipw_adhoc_create(struct ipw_priv *priv, if (priv->capability & CAP_PRIVACY_ON) network->capability |= WLAN_CAPABILITY_PRIVACY; network->rates_len = min(priv->rates.num_rates, MAX_RATES_LENGTH); - memcpy(network->rates, priv->rates.supported_rates, - network->rates_len); + memcpy(network->rates, priv->rates.supported_rates, network->rates_len); network->rates_ex_len = priv->rates.num_rates - network->rates_len; memcpy(network->rates_ex, &priv->rates.supported_rates[network->rates_len], @@ -4404,13 +4457,13 @@ static void ipw_adhoc_create(struct ipw_priv *priv, network->last_associate = 0; network->time_stamp[0] = 0; network->time_stamp[1] = 0; - network->beacon_interval = 100; /* Default */ - network->listen_interval = 10; /* Default */ - network->atim_window = 0; /* Default */ + network->beacon_interval = 100; /* Default */ + network->listen_interval = 10; /* Default */ + network->atim_window = 0; /* Default */ #ifdef CONFIG_IEEE80211_WPA network->wpa_ie_len = 0; network->rsn_ie_len = 0; -#endif /* CONFIG_IEEE80211_WPA */ +#endif /* CONFIG_IEEE80211_WPA */ } static void ipw_send_wep_keys(struct ipw_priv *priv) @@ -4464,14 +4517,12 @@ static void ipw_debug_config(struct ipw_priv *priv) IPW_DEBUG_INFO("Scan completed, no valid APs matched " "[CFG 0x%08X]\n", priv->config); if (priv->config & CFG_STATIC_CHANNEL) - IPW_DEBUG_INFO("Channel locked to %d\n", - priv->channel); + IPW_DEBUG_INFO("Channel locked to %d\n", priv->channel); else IPW_DEBUG_INFO("Channel unlocked.\n"); if (priv->config & CFG_STATIC_ESSID) IPW_DEBUG_INFO("ESSID locked to '%s'\n", - escape_essid(priv->essid, - priv->essid_len)); + escape_essid(priv->essid, priv->essid_len)); else IPW_DEBUG_INFO("ESSID unlocked.\n"); if (priv->config & CFG_STATIC_BSSID) @@ -4502,7 +4553,7 @@ static inline void ipw_set_fixed_rate(struct ipw_priv *priv, * Tx rates */ switch (priv->ieee->freq_band) { - case IEEE80211_52GHZ_BAND: /* A only */ + case IEEE80211_52GHZ_BAND: /* A only */ /* IEEE_A */ if (priv->rates_mask & ~IEEE80211_OFDM_RATES_MASK) { /* Invalid fixed rate mask */ @@ -4513,7 +4564,7 @@ static inline void ipw_set_fixed_rate(struct ipw_priv *priv, fr.tx_rates >>= IEEE80211_OFDM_SHIFT_MASK_A; break; - default: /* 2.4Ghz or Mixed */ + default: /* 2.4Ghz or Mixed */ /* IEEE_B */ if (network->mode == IEEE_B) { if (fr.tx_rates & ~IEEE80211_CCK_RATES_MASK) { @@ -4551,13 +4602,12 @@ static inline void ipw_set_fixed_rate(struct ipw_priv *priv, } reg = ipw_read32(priv, IPW_MEM_FIXED_OVERRIDE); - ipw_write_reg32(priv, reg, *(u32*)&fr); + ipw_write_reg32(priv, reg, *(u32 *) & fr); } static int ipw_associate_network(struct ipw_priv *priv, struct ieee80211_network *network, - struct ipw_supported_rates *rates, - int roaming) + struct ipw_supported_rates *rates, int roaming) { int err; @@ -4566,7 +4616,7 @@ static int ipw_associate_network(struct ipw_priv *priv, if (!(priv->config & CFG_STATIC_ESSID)) { priv->essid_len = min(network->ssid_len, - (u8)IW_ESSID_MAX_SIZE); + (u8) IW_ESSID_MAX_SIZE); memcpy(priv->essid, network->ssid, priv->essid_len); } @@ -4612,13 +4662,11 @@ static int ipw_associate_network(struct ipw_priv *priv, priv->capability & CAP_PRIVACY_ON ? " key=" : "", priv->capability & CAP_PRIVACY_ON ? '1' + priv->sec.active_key : '.', - priv->capability & CAP_PRIVACY_ON ? - '.' : ' '); + priv->capability & CAP_PRIVACY_ON ? '.' : ' '); priv->assoc_request.beacon_interval = network->beacon_interval; if ((priv->ieee->iw_mode == IW_MODE_ADHOC) && - (network->time_stamp[0] == 0) && - (network->time_stamp[1] == 0)) { + (network->time_stamp[0] == 0) && (network->time_stamp[1] == 0)) { priv->assoc_request.assoc_type = HC_IBSS_START; priv->assoc_request.assoc_tsf_msw = 0; priv->assoc_request.assoc_tsf_lsw = 0; @@ -4637,8 +4685,7 @@ static int ipw_associate_network(struct ipw_priv *priv, memset(&priv->assoc_request.dest, 0xFF, ETH_ALEN); priv->assoc_request.atim_window = network->atim_window; } else { - memcpy(&priv->assoc_request.dest, network->bssid, - ETH_ALEN); + memcpy(&priv->assoc_request.dest, network->bssid, ETH_ALEN); priv->assoc_request.atim_window = 0; } @@ -4772,14 +4819,13 @@ static void ipw_associate(void *data) if (!(priv->config & CFG_ASSOCIATE) && !(priv->config & (CFG_STATIC_ESSID | - CFG_STATIC_CHANNEL | - CFG_STATIC_BSSID))) { + CFG_STATIC_CHANNEL | CFG_STATIC_BSSID))) { IPW_DEBUG_ASSOC("Not attempting association (associate=0)\n"); return; } list_for_each_entry(network, &priv->ieee->network_list, list) - ipw_best_network(priv, &match, network, 0); + ipw_best_network(priv, &match, network, 0); network = match.network; rates = &match.rates; @@ -4790,8 +4836,7 @@ static void ipw_associate(void *data) priv->config & CFG_STATIC_ESSID && !list_empty(&priv->ieee->network_free_list)) { element = priv->ieee->network_free_list.next; - network = list_entry(element, struct ieee80211_network, - list); + network = list_entry(element, struct ieee80211_network, list); ipw_adhoc_create(priv, network); rates = &priv->rates; list_del(element); @@ -4813,8 +4858,8 @@ static void ipw_associate(void *data) } static inline void ipw_handle_data_packet(struct ipw_priv *priv, - struct ipw_rx_mem_buffer *rxb, - struct ieee80211_rx_stats *stats) + struct ipw_rx_mem_buffer *rxb, + struct ieee80211_rx_stats *stats) { struct ipw_rx_packet *pkt = (struct ipw_rx_packet *)rxb->skb->data; @@ -4846,11 +4891,10 @@ static inline void ipw_handle_data_packet(struct ipw_priv *priv, if (!ieee80211_rx(priv->ieee, rxb->skb, stats)) priv->ieee->stats.rx_errors++; - else /* ieee80211_rx succeeded, so it now owns the SKB */ + else /* ieee80211_rx succeeded, so it now owns the SKB */ rxb->skb = NULL; } - /* * Main entry function for recieving a packet with 80211 headers. This * should be called when ever the FW has notified us that there is a new @@ -4885,125 +4929,152 @@ static void ipw_rx(struct ipw_priv *priv) pkt = (struct ipw_rx_packet *)rxb->skb->data; IPW_DEBUG_RX("Packet: type=%02X seq=%02X bits=%02X\n", pkt->header.message_type, - pkt->header.rx_seq_num, - pkt->header.control_bits); + pkt->header.rx_seq_num, pkt->header.control_bits); switch (pkt->header.message_type) { - case RX_FRAME_TYPE: /* 802.11 frame */ { - struct ieee80211_rx_stats stats = { - .rssi = pkt->u.frame.rssi_dbm - - IPW_RSSI_TO_DBM, - .signal = pkt->u.frame.signal, - .rate = pkt->u.frame.rate, - .mac_time = jiffies, - .received_channel = - pkt->u.frame.received_channel, - .freq = (pkt->u.frame.control & (1<<0)) ? - IEEE80211_24GHZ_BAND : IEEE80211_52GHZ_BAND, - .len = pkt->u.frame.length, - }; - - if (stats.rssi != 0) - stats.mask |= IEEE80211_STATMASK_RSSI; - if (stats.signal != 0) - stats.mask |= IEEE80211_STATMASK_SIGNAL; - if (stats.rate != 0) - stats.mask |= IEEE80211_STATMASK_RATE; - - priv->rx_packets++; + case RX_FRAME_TYPE: /* 802.11 frame */ { + struct ieee80211_rx_stats stats = { + .rssi = pkt->u.frame.rssi_dbm - + IPW_RSSI_TO_DBM, + .signal = pkt->u.frame.signal, + .rate = pkt->u.frame.rate, + .mac_time = jiffies, + .received_channel = + pkt->u.frame.received_channel, + .freq = + (pkt->u.frame. + control & (1 << 0)) ? + IEEE80211_24GHZ_BAND : + IEEE80211_52GHZ_BAND, + .len = pkt->u.frame.length, + }; + + if (stats.rssi != 0) + stats.mask |= IEEE80211_STATMASK_RSSI; + if (stats.signal != 0) + stats.mask |= IEEE80211_STATMASK_SIGNAL; + if (stats.rate != 0) + stats.mask |= IEEE80211_STATMASK_RATE; + + priv->rx_packets++; #ifdef CONFIG_IPW_PROMISC - if (priv->ieee->iw_mode == IW_MODE_MONITOR) { - ipw_handle_data_packet(priv, rxb, &stats); - break; - } + if (priv->ieee->iw_mode == IW_MODE_MONITOR) { + ipw_handle_data_packet(priv, rxb, + &stats); + break; + } #endif - header = (struct ieee80211_hdr *)(rxb->skb->data + - IPW_RX_FRAME_SIZE); + header = + (struct ieee80211_hdr *)(rxb->skb->data + + IPW_RX_FRAME_SIZE); /* TODO: Check Ad-Hoc dest/source and make sure * that we are actually parsing these packets * correctly -- we should probably use the * frame control of the packet and disregard * the current iw_mode */ - switch (priv->ieee->iw_mode) { - case IW_MODE_ADHOC: - network_packet = - !memcmp(header->addr1, - priv->net_dev->dev_addr, - ETH_ALEN) || - !memcmp(header->addr3, - priv->bssid, ETH_ALEN) || - is_broadcast_ether_addr(header->addr1) || - is_multicast_ether_addr(header->addr1); - break; - - case IW_MODE_INFRA: - default: - network_packet = - !memcmp(header->addr3, - priv->bssid, ETH_ALEN) || - !memcmp(header->addr1, - priv->net_dev->dev_addr, - ETH_ALEN) || - is_broadcast_ether_addr(header->addr1) || - is_multicast_ether_addr(header->addr1); + switch (priv->ieee->iw_mode) { + case IW_MODE_ADHOC: + network_packet = + !memcmp(header->addr1, + priv->net_dev->dev_addr, + ETH_ALEN) || + !memcmp(header->addr3, + priv->bssid, ETH_ALEN) || + is_broadcast_ether_addr(header-> + addr1) + || is_multicast_ether_addr(header-> + addr1); + break; + + case IW_MODE_INFRA: + default: + network_packet = + !memcmp(header->addr3, + priv->bssid, ETH_ALEN) || + !memcmp(header->addr1, + priv->net_dev->dev_addr, + ETH_ALEN) || + is_broadcast_ether_addr(header-> + addr1) + || is_multicast_ether_addr(header-> + addr1); + break; + } + + if (network_packet && priv->assoc_network) { + priv->assoc_network->stats.rssi = + stats.rssi; + average_add(&priv->average_rssi, + stats.rssi); + priv->last_rx_rssi = stats.rssi; + } + + IPW_DEBUG_RX("Frame: len=%u\n", + pkt->u.frame.length); + + if (pkt->u.frame.length < frame_hdr_len(header)) { + IPW_DEBUG_DROP + ("Received packet is too small. " + "Dropping.\n"); + priv->ieee->stats.rx_errors++; + priv->wstats.discard.misc++; + break; + } + + switch (WLAN_FC_GET_TYPE(header->frame_ctl)) { + case IEEE80211_FTYPE_MGMT: + ieee80211_rx_mgt(priv->ieee, header, + &stats); + if (priv->ieee->iw_mode == IW_MODE_ADHOC + && + ((WLAN_FC_GET_STYPE + (header->frame_ctl) == + IEEE80211_STYPE_PROBE_RESP) + || + (WLAN_FC_GET_STYPE + (header->frame_ctl) == + IEEE80211_STYPE_BEACON)) + && !memcmp(header->addr3, + priv->bssid, ETH_ALEN)) + ipw_add_station(priv, + header->addr2); + break; + + case IEEE80211_FTYPE_CTL: + break; + + case IEEE80211_FTYPE_DATA: + if (network_packet) + ipw_handle_data_packet(priv, + rxb, + &stats); + else + IPW_DEBUG_DROP("Dropping: " + MAC_FMT ", " + MAC_FMT ", " + MAC_FMT "\n", + MAC_ARG(header-> + addr1), + MAC_ARG(header-> + addr2), + MAC_ARG(header-> + addr3)); + break; + } break; } - if (network_packet && priv->assoc_network) { - priv->assoc_network->stats.rssi = stats.rssi; - average_add(&priv->average_rssi, - stats.rssi); - priv->last_rx_rssi = stats.rssi; - } - - IPW_DEBUG_RX("Frame: len=%u\n", pkt->u.frame.length); - - if (pkt->u.frame.length < frame_hdr_len(header)) { - IPW_DEBUG_DROP("Received packet is too small. " - "Dropping.\n"); - priv->ieee->stats.rx_errors++; - priv->wstats.discard.misc++; - break; - } - - switch (WLAN_FC_GET_TYPE(header->frame_ctl)) { - case IEEE80211_FTYPE_MGMT: - ieee80211_rx_mgt(priv->ieee, header, &stats); - if (priv->ieee->iw_mode == IW_MODE_ADHOC && - ((WLAN_FC_GET_STYPE(header->frame_ctl) == - IEEE80211_STYPE_PROBE_RESP) || - (WLAN_FC_GET_STYPE(header->frame_ctl) == - IEEE80211_STYPE_BEACON)) && - !memcmp(header->addr3, priv->bssid, ETH_ALEN)) - ipw_add_station(priv, header->addr2); - break; - - case IEEE80211_FTYPE_CTL: - break; - - case IEEE80211_FTYPE_DATA: - if (network_packet) - ipw_handle_data_packet(priv, rxb, &stats); - else - IPW_DEBUG_DROP("Dropping: " MAC_FMT - ", " MAC_FMT ", " MAC_FMT "\n", - MAC_ARG(header->addr1), MAC_ARG(header->addr2), - MAC_ARG(header->addr3)); - break; - } - break; - } - - case RX_HOST_NOTIFICATION_TYPE: { - IPW_DEBUG_RX("Notification: subtype=%02X flags=%02X size=%d\n", + case RX_HOST_NOTIFICATION_TYPE:{ + IPW_DEBUG_RX + ("Notification: subtype=%02X flags=%02X size=%d\n", pkt->u.notification.subtype, pkt->u.notification.flags, pkt->u.notification.size); - ipw_rx_notification(priv, &pkt->u.notification); - break; - } + ipw_rx_notification(priv, &pkt->u.notification); + break; + } default: IPW_DEBUG_RX("Bad Rx packet of type %d\n", @@ -5088,10 +5159,10 @@ static int ipw_request_scan(struct ipw_priv *priv) /* If we are roaming, then make this a directed scan for the current * network. Otherwise, ensure that every other scan is a fast * channel hop scan */ - if ((priv->status & STATUS_ROAMING) || ( - !(priv->status & STATUS_ASSOCIATED) && - (priv->config & CFG_STATIC_ESSID) && - (scan.full_scan_index % 2))) { + if ((priv->status & STATUS_ROAMING) + || (!(priv->status & STATUS_ASSOCIATED) + && (priv->config & CFG_STATIC_ESSID) + && (scan.full_scan_index % 2))) { err = ipw_send_ssid(priv, priv->essid, priv->essid_len); if (err) { IPW_DEBUG_HC("Attempt to send SSID command failed.\n"); @@ -5103,7 +5174,7 @@ static int ipw_request_scan(struct ipw_priv *priv) scan_type = IPW_SCAN_ACTIVE_BROADCAST_SCAN; } - if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) { + if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) { int start = channel_index; for (i = 0; i < MAX_A_CHANNELS; i++) { if (band_a_active_channel[i] == 0) @@ -5113,18 +5184,18 @@ static int ipw_request_scan(struct ipw_priv *priv) continue; channel_index++; scan.channels_list[channel_index] = - band_a_active_channel[i]; + band_a_active_channel[i]; ipw_set_scan_type(&scan, channel_index, scan_type); } if (start != channel_index) { - scan.channels_list[start] = (u8)(IPW_A_MODE << 6) | - (channel_index - start); + scan.channels_list[start] = (u8) (IPW_A_MODE << 6) | + (channel_index - start); channel_index++; } } - if (priv->ieee->freq_band & IEEE80211_24GHZ_BAND) { + if (priv->ieee->freq_band & IEEE80211_24GHZ_BAND) { int start = channel_index; for (i = 0; i < MAX_B_CHANNELS; i++) { if (band_b_active_channel[i] == 0) @@ -5134,20 +5205,19 @@ static int ipw_request_scan(struct ipw_priv *priv) continue; channel_index++; scan.channels_list[channel_index] = - band_b_active_channel[i]; + band_b_active_channel[i]; ipw_set_scan_type(&scan, channel_index, scan_type); } if (start != channel_index) { - scan.channels_list[start] = (u8)(IPW_B_MODE << 6) | - (channel_index - start); + scan.channels_list[start] = (u8) (IPW_B_MODE << 6) | + (channel_index - start); } } err = ipw_send_scan_request_ext(priv, &scan); if (err) { - IPW_DEBUG_HC("Sending scan command failed: %08X\n", - err); + IPW_DEBUG_HC("Sending scan command failed: %08X\n", err); return -EIO; } @@ -5199,9 +5269,8 @@ static int ipw_set_channel(struct ipw_priv *priv, u8 channel) priv->config |= CFG_STATIC_CHANNEL; if (priv->channel == channel) { - IPW_DEBUG_INFO( - "Request to set channel to current value (%d)\n", - channel); + IPW_DEBUG_INFO("Request to set channel to current value (%d)\n", + channel); return 0; } @@ -5229,8 +5298,7 @@ static int ipw_wx_set_freq(struct net_device *dev, /* if setting by freq convert to channel */ if (fwrq->e == 1) { - if ((fwrq->m >= (int) 2.412e8 && - fwrq->m <= (int) 2.487e8)) { + if ((fwrq->m >= (int)2.412e8 && fwrq->m <= (int)2.487e8)) { int f = fwrq->m / 100000; int c = 0; @@ -5248,12 +5316,11 @@ static int ipw_wx_set_freq(struct net_device *dev, return -EOPNOTSUPP; IPW_DEBUG_WX("SET Freq/Channel -> %d \n", fwrq->m); - return ipw_set_channel(priv, (u8)fwrq->m); + return ipw_set_channel(priv, (u8) fwrq->m); return 0; } - static int ipw_wx_get_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5306,7 +5373,7 @@ static int ipw_wx_set_mode(struct net_device *dev, if (wrqu->mode == IW_MODE_MONITOR) priv->net_dev->type = ARPHRD_IEEE80211; -#endif /* CONFIG_IPW_PROMISC */ +#endif /* CONFIG_IPW_PROMISC */ #ifdef CONFIG_PM /* Free the existing firmware and reset the fw_loaded @@ -5324,12 +5391,12 @@ static int ipw_wx_set_mode(struct net_device *dev, priv->ieee->iw_mode = wrqu->mode; ipw_adapter_restart(priv); - return err; + return err; } static int ipw_wx_get_mode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct ipw_priv *priv = ieee80211_priv(dev); @@ -5339,7 +5406,6 @@ static int ipw_wx_get_mode(struct net_device *dev, return 0; } - #define DEFAULT_RTS_THRESHOLD 2304U #define MIN_RTS_THRESHOLD 1U #define MAX_RTS_THRESHOLD 2304U @@ -5383,19 +5449,19 @@ static int ipw_wx_get_range(struct net_device *dev, /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; range->max_qual.noise = 0; - range->max_qual.updated = 7; /* Updated all three */ + range->max_qual.updated = 7; /* Updated all three */ range->avg_qual.qual = 70; /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ - range->avg_qual.level = 0; /* FIXME to real average level */ + range->avg_qual.level = 0; /* FIXME to real average level */ range->avg_qual.noise = 0; - range->avg_qual.updated = 7; /* Updated all three */ + range->avg_qual.updated = 7; /* Updated all three */ - range->num_bitrates = min(priv->rates.num_rates, (u8)IW_MAX_BITRATES); + range->num_bitrates = min(priv->rates.num_rates, (u8) IW_MAX_BITRATES); for (i = 0; i < range->num_bitrates; i++) range->bitrate[i] = (priv->rates.supported_rates[i] & 0x7F) * - 500000; + 500000; range->max_rts = DEFAULT_RTS_THRESHOLD; range->min_frag = MIN_FRAG_THRESHOLD; @@ -5410,7 +5476,7 @@ static int ipw_wx_get_range(struct net_device *dev, range->we_version_compiled = WIRELESS_EXT; range->we_version_source = 16; - range->num_channels = FREQ_COUNT; + range->num_channels = FREQ_COUNT; val = 0; for (i = 0; i < FREQ_COUNT; i++) { @@ -5506,7 +5572,7 @@ static int ipw_wx_set_essid(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct ipw_priv *priv = ieee80211_priv(dev); - char *essid = ""; /* ANY */ + char *essid = ""; /* ANY */ int length = 0; if (wrqu->essid.flags && wrqu->essid.length) { @@ -5567,11 +5633,11 @@ static int ipw_wx_get_essid(struct net_device *dev, escape_essid(priv->essid, priv->essid_len)); memcpy(extra, priv->essid, priv->essid_len); wrqu->essid.length = priv->essid_len; - wrqu->essid.flags = 1; /* active */ + wrqu->essid.flags = 1; /* active */ } else { IPW_DEBUG_WX("Getting essid: ANY\n"); wrqu->essid.length = 0; - wrqu->essid.flags = 0; /* active */ + wrqu->essid.flags = 0; /* active */ } return 0; @@ -5587,15 +5653,14 @@ static int ipw_wx_set_nick(struct net_device *dev, if (wrqu->data.length > IW_ESSID_MAX_SIZE) return -E2BIG; - wrqu->data.length = min((size_t)wrqu->data.length, sizeof(priv->nick)); + wrqu->data.length = min((size_t) wrqu->data.length, sizeof(priv->nick)); memset(priv->nick, 0, sizeof(priv->nick)); - memcpy(priv->nick, extra, wrqu->data.length); + memcpy(priv->nick, extra, wrqu->data.length); IPW_DEBUG_TRACE("<<\n"); return 0; } - static int ipw_wx_get_nick(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5604,11 +5669,10 @@ static int ipw_wx_get_nick(struct net_device *dev, IPW_DEBUG_WX("Getting nick\n"); wrqu->data.length = strlen(priv->nick) + 1; memcpy(extra, priv->nick, wrqu->data.length); - wrqu->data.flags = 1; /* active */ + wrqu->data.flags = 1; /* active */ return 0; } - static int ipw_wx_set_rate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5621,14 +5685,13 @@ static int ipw_wx_get_rate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct ipw_priv * priv = ieee80211_priv(dev); + struct ipw_priv *priv = ieee80211_priv(dev); wrqu->bitrate.value = priv->last_rate; IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value); return 0; } - static int ipw_wx_set_rts(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5657,14 +5720,12 @@ static int ipw_wx_get_rts(struct net_device *dev, struct ipw_priv *priv = ieee80211_priv(dev); wrqu->rts.value = priv->rts_threshold; wrqu->rts.fixed = 0; /* no auto select */ - wrqu->rts.disabled = - (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); + wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); IPW_DEBUG_WX("GET RTS Threshold -> %d \n", wrqu->rts.value); return 0; } - static int ipw_wx_set_txpow(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5679,8 +5740,7 @@ static int ipw_wx_set_txpow(struct net_device *dev, if (wrqu->power.flags != IW_TXPOW_DBM) return -EINVAL; - if ((wrqu->power.value > 20) || - (wrqu->power.value < -12)) + if ((wrqu->power.value > 20) || (wrqu->power.value < -12)) return -EINVAL; priv->tx_power = wrqu->power.value; @@ -5704,11 +5764,10 @@ static int ipw_wx_set_txpow(struct net_device *dev, return 0; - error: + error: return -EIO; } - static int ipw_wx_get_txpow(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5721,15 +5780,14 @@ static int ipw_wx_get_txpow(struct net_device *dev, wrqu->power.disabled = (priv->status & STATUS_RF_KILL_MASK) ? 1 : 0; IPW_DEBUG_WX("GET TX Power -> %s %d \n", - wrqu->power.disabled ? "ON" : "OFF", - wrqu->power.value); + wrqu->power.disabled ? "ON" : "OFF", wrqu->power.value); return 0; } static int ipw_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct ipw_priv *priv = ieee80211_priv(dev); @@ -5749,14 +5807,13 @@ static int ipw_wx_set_frag(struct net_device *dev, } static int ipw_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct ipw_priv *priv = ieee80211_priv(dev); wrqu->frag.value = priv->ieee->fts; wrqu->frag.fixed = 0; /* no auto select */ - wrqu->frag.disabled = - (wrqu->frag.value == DEFAULT_FTS); + wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FTS); IPW_DEBUG_WX("GET Frag Threshold -> %d \n", wrqu->frag.value); @@ -5771,7 +5828,6 @@ static int ipw_wx_set_retry(struct net_device *dev, return -EOPNOTSUPP; } - static int ipw_wx_get_retry(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5780,7 +5836,6 @@ static int ipw_wx_get_retry(struct net_device *dev, return -EOPNOTSUPP; } - static int ipw_wx_set_scan(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -5801,24 +5856,24 @@ static int ipw_wx_get_scan(struct net_device *dev, } static int ipw_wx_set_encode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key) + struct iw_request_info *info, + union iwreq_data *wrqu, char *key) { struct ipw_priv *priv = ieee80211_priv(dev); return ieee80211_wx_set_encode(priv->ieee, info, wrqu, key); } static int ipw_wx_get_encode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key) + struct iw_request_info *info, + union iwreq_data *wrqu, char *key) { struct ipw_priv *priv = ieee80211_priv(dev); return ieee80211_wx_get_encode(priv->ieee, info, wrqu, key); } static int ipw_wx_set_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct ipw_priv *priv = ieee80211_priv(dev); int err; @@ -5837,11 +5892,11 @@ static int ipw_wx_set_power(struct net_device *dev, } switch (wrqu->power.flags & IW_POWER_MODE) { - case IW_POWER_ON: /* If not specified */ - case IW_POWER_MODE: /* If set all mask */ - case IW_POWER_ALL_R: /* If explicitely state all */ + case IW_POWER_ON: /* If not specified */ + case IW_POWER_MODE: /* If set all mask */ + case IW_POWER_ALL_R: /* If explicitely state all */ break; - default: /* Otherwise we don't support it */ + default: /* Otherwise we don't support it */ IPW_DEBUG_WX("SET PM Mode: %X not supported.\n", wrqu->power.flags); return -EOPNOTSUPP; @@ -5849,7 +5904,7 @@ static int ipw_wx_set_power(struct net_device *dev, /* If the user hasn't specified a power management mode yet, default * to BATTERY */ - if (IPW_POWER_LEVEL(priv->power_mode) == IPW_POWER_AC) + if (IPW_POWER_LEVEL(priv->power_mode) == IPW_POWER_AC) priv->power_mode = IPW_POWER_ENABLED | IPW_POWER_BATTERY; else priv->power_mode = IPW_POWER_ENABLED | priv->power_mode; @@ -5859,15 +5914,14 @@ static int ipw_wx_set_power(struct net_device *dev, return err; } - IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", - priv->power_mode); + IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode); return 0; } static int ipw_wx_get_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct ipw_priv *priv = ieee80211_priv(dev); @@ -5883,8 +5937,8 @@ static int ipw_wx_get_power(struct net_device *dev, } static int ipw_wx_set_powermode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct ipw_priv *priv = ieee80211_priv(dev); int mode = *(int *)extra; @@ -5911,8 +5965,8 @@ static int ipw_wx_set_powermode(struct net_device *dev, #define MAX_WX_STRING 80 static int ipw_wx_get_powermode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct ipw_priv *priv = ieee80211_priv(dev); int level = IPW_POWER_LEVEL(priv->power_mode); @@ -5935,7 +5989,7 @@ static int ipw_wx_get_powermode(struct net_device *dev, } if (!(priv->power_mode & IPW_POWER_ENABLED)) - p += snprintf(p, MAX_WX_STRING - (p - extra)," OFF"); + p += snprintf(p, MAX_WX_STRING - (p - extra), " OFF"); wrqu->data.length = p - extra + 1; @@ -5943,16 +5997,15 @@ static int ipw_wx_get_powermode(struct net_device *dev, } static int ipw_wx_set_wireless_mode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct ipw_priv *priv = ieee80211_priv(dev); + struct ipw_priv *priv = ieee80211_priv(dev); int mode = *(int *)extra; u8 band = 0, modulation = 0; if (mode == 0 || mode & ~IEEE_MODE_MASK) { - IPW_WARNING("Attempt to set invalid wireless mode: %d\n", - mode); + IPW_WARNING("Attempt to set invalid wireless mode: %d\n", mode); return -EINVAL; } @@ -5988,31 +6041,30 @@ static int ipw_wx_set_wireless_mode(struct net_device *dev, priv->ieee->mode = mode; priv->ieee->freq_band = band; priv->ieee->modulation = modulation; - init_supported_rates(priv, &priv->rates); + init_supported_rates(priv, &priv->rates); /* If we are currently associated, or trying to associate - * then see if this is a new configuration (causing us to + * then see if this is a new configuration (causing us to * disassociate) */ - if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { + if (priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING)) { /* The resulting association will trigger * the new rates to be sent to the device */ - IPW_DEBUG_ASSOC("Disassociating due to mode change.\n"); - ipw_disassociate(priv); + IPW_DEBUG_ASSOC("Disassociating due to mode change.\n"); + ipw_disassociate(priv); } else ipw_send_supported_rates(priv, &priv->rates); IPW_DEBUG_WX("PRIV SET MODE: %c%c%c\n", mode & IEEE_A ? 'a' : '.', - mode & IEEE_B ? 'b' : '.', - mode & IEEE_G ? 'g' : '.'); + mode & IEEE_B ? 'b' : '.', mode & IEEE_G ? 'g' : '.'); return 0; } static int ipw_wx_get_wireless_mode(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct ipw_priv *priv = ieee80211_priv(dev); + struct ipw_priv *priv = ieee80211_priv(dev); switch (priv->ieee->freq_band) { case IEEE80211_24GHZ_BAND: @@ -6033,7 +6085,7 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev, strncpy(extra, "802.11a (1)", MAX_WX_STRING); break; - default: /* Mixed Band */ + default: /* Mixed Band */ switch (priv->ieee->modulation) { case IEEE80211_CCK_MODULATION: strncpy(extra, "802.11ab (3)", MAX_WX_STRING); @@ -6050,9 +6102,9 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev, IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra); - wrqu->data.length = strlen(extra) + 1; + wrqu->data.length = strlen(extra) + 1; - return 0; + return 0; } #ifdef CONFIG_IPW_PROMISC @@ -6081,7 +6133,6 @@ static int ipw_wx_set_promisc(struct net_device *dev, return 0; } - static int ipw_wx_reset(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -6091,40 +6142,39 @@ static int ipw_wx_reset(struct net_device *dev, ipw_adapter_restart(priv); return 0; } -#endif // CONFIG_IPW_PROMISC +#endif // CONFIG_IPW_PROMISC /* Rebase the WE IOCTLs to zero for the handler array */ #define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] -static iw_handler ipw_wx_handlers[] = -{ - IW_IOCTL(SIOCGIWNAME) = ipw_wx_get_name, - IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq, - IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq, - IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode, - IW_IOCTL(SIOCGIWMODE) = ipw_wx_get_mode, - IW_IOCTL(SIOCGIWRANGE) = ipw_wx_get_range, - IW_IOCTL(SIOCSIWAP) = ipw_wx_set_wap, - IW_IOCTL(SIOCGIWAP) = ipw_wx_get_wap, - IW_IOCTL(SIOCSIWSCAN) = ipw_wx_set_scan, - IW_IOCTL(SIOCGIWSCAN) = ipw_wx_get_scan, - IW_IOCTL(SIOCSIWESSID) = ipw_wx_set_essid, - IW_IOCTL(SIOCGIWESSID) = ipw_wx_get_essid, - IW_IOCTL(SIOCSIWNICKN) = ipw_wx_set_nick, - IW_IOCTL(SIOCGIWNICKN) = ipw_wx_get_nick, - IW_IOCTL(SIOCSIWRATE) = ipw_wx_set_rate, - IW_IOCTL(SIOCGIWRATE) = ipw_wx_get_rate, - IW_IOCTL(SIOCSIWRTS) = ipw_wx_set_rts, - IW_IOCTL(SIOCGIWRTS) = ipw_wx_get_rts, - IW_IOCTL(SIOCSIWFRAG) = ipw_wx_set_frag, - IW_IOCTL(SIOCGIWFRAG) = ipw_wx_get_frag, - IW_IOCTL(SIOCSIWTXPOW) = ipw_wx_set_txpow, - IW_IOCTL(SIOCGIWTXPOW) = ipw_wx_get_txpow, - IW_IOCTL(SIOCSIWRETRY) = ipw_wx_set_retry, - IW_IOCTL(SIOCGIWRETRY) = ipw_wx_get_retry, - IW_IOCTL(SIOCSIWENCODE) = ipw_wx_set_encode, - IW_IOCTL(SIOCGIWENCODE) = ipw_wx_get_encode, - IW_IOCTL(SIOCSIWPOWER) = ipw_wx_set_power, - IW_IOCTL(SIOCGIWPOWER) = ipw_wx_get_power, +static iw_handler ipw_wx_handlers[] = { + IW_IOCTL(SIOCGIWNAME) = ipw_wx_get_name, + IW_IOCTL(SIOCSIWFREQ) = ipw_wx_set_freq, + IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq, + IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode, + IW_IOCTL(SIOCGIWMODE) = ipw_wx_get_mode, + IW_IOCTL(SIOCGIWRANGE) = ipw_wx_get_range, + IW_IOCTL(SIOCSIWAP) = ipw_wx_set_wap, + IW_IOCTL(SIOCGIWAP) = ipw_wx_get_wap, + IW_IOCTL(SIOCSIWSCAN) = ipw_wx_set_scan, + IW_IOCTL(SIOCGIWSCAN) = ipw_wx_get_scan, + IW_IOCTL(SIOCSIWESSID) = ipw_wx_set_essid, + IW_IOCTL(SIOCGIWESSID) = ipw_wx_get_essid, + IW_IOCTL(SIOCSIWNICKN) = ipw_wx_set_nick, + IW_IOCTL(SIOCGIWNICKN) = ipw_wx_get_nick, + IW_IOCTL(SIOCSIWRATE) = ipw_wx_set_rate, + IW_IOCTL(SIOCGIWRATE) = ipw_wx_get_rate, + IW_IOCTL(SIOCSIWRTS) = ipw_wx_set_rts, + IW_IOCTL(SIOCGIWRTS) = ipw_wx_get_rts, + IW_IOCTL(SIOCSIWFRAG) = ipw_wx_set_frag, + IW_IOCTL(SIOCGIWFRAG) = ipw_wx_get_frag, + IW_IOCTL(SIOCSIWTXPOW) = ipw_wx_set_txpow, + IW_IOCTL(SIOCGIWTXPOW) = ipw_wx_get_txpow, + IW_IOCTL(SIOCSIWRETRY) = ipw_wx_set_retry, + IW_IOCTL(SIOCGIWRETRY) = ipw_wx_get_retry, + IW_IOCTL(SIOCSIWENCODE) = ipw_wx_set_encode, + IW_IOCTL(SIOCGIWENCODE) = ipw_wx_get_encode, + IW_IOCTL(SIOCSIWPOWER) = ipw_wx_set_power, + IW_IOCTL(SIOCGIWPOWER) = ipw_wx_get_power, }; #define IPW_PRIV_SET_POWER SIOCIWFIRSTPRIV @@ -6134,38 +6184,31 @@ static iw_handler ipw_wx_handlers[] = #define IPW_PRIV_SET_PROMISC SIOCIWFIRSTPRIV+4 #define IPW_PRIV_RESET SIOCIWFIRSTPRIV+5 - static struct iw_priv_args ipw_priv_args[] = { { - .cmd = IPW_PRIV_SET_POWER, - .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, - .name = "set_power" - }, + .cmd = IPW_PRIV_SET_POWER, + .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + .name = "set_power"}, { - .cmd = IPW_PRIV_GET_POWER, - .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, - .name = "get_power" - }, + .cmd = IPW_PRIV_GET_POWER, + .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, + .name = "get_power"}, { - .cmd = IPW_PRIV_SET_MODE, - .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, - .name = "set_mode" - }, + .cmd = IPW_PRIV_SET_MODE, + .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, + .name = "set_mode"}, { - .cmd = IPW_PRIV_GET_MODE, - .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, - .name = "get_mode" - }, + .cmd = IPW_PRIV_GET_MODE, + .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, + .name = "get_mode"}, #ifdef CONFIG_IPW_PROMISC { - IPW_PRIV_SET_PROMISC, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor" - }, + IPW_PRIV_SET_PROMISC, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "monitor"}, { - IPW_PRIV_RESET, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset" - }, -#endif /* CONFIG_IPW_PROMISC */ + IPW_PRIV_RESET, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 0, 0, "reset"}, +#endif /* CONFIG_IPW_PROMISC */ }; static iw_handler ipw_priv_handler[] = { @@ -6179,25 +6222,21 @@ static iw_handler ipw_priv_handler[] = { #endif }; -static struct iw_handler_def ipw_wx_handler_def = -{ - .standard = ipw_wx_handlers, - .num_standard = ARRAY_SIZE(ipw_wx_handlers), - .num_private = ARRAY_SIZE(ipw_priv_handler), - .num_private_args = ARRAY_SIZE(ipw_priv_args), - .private = ipw_priv_handler, - .private_args = ipw_priv_args, +static struct iw_handler_def ipw_wx_handler_def = { + .standard = ipw_wx_handlers, + .num_standard = ARRAY_SIZE(ipw_wx_handlers), + .num_private = ARRAY_SIZE(ipw_priv_handler), + .num_private_args = ARRAY_SIZE(ipw_priv_args), + .private = ipw_priv_handler, + .private_args = ipw_priv_args, }; - - - /* * Get wireless statistics. * Called by /proc/net/wireless * Also called by SIOCGIWSTATS */ -static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev) +static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev) { struct ipw_priv *priv = ieee80211_priv(dev); struct iw_statistics *wstats; @@ -6217,7 +6256,7 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev) wstats->qual.noise = 0; wstats->qual.updated = 7; wstats->qual.updated |= IW_QUAL_NOISE_INVALID | - IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; + IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID; return wstats; } @@ -6225,7 +6264,7 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev) wstats->qual.level = average_value(&priv->average_rssi); wstats->qual.noise = average_value(&priv->average_noise); wstats->qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | - IW_QUAL_NOISE_UPDATED; + IW_QUAL_NOISE_UPDATED; wstats->miss.beacon = average_value(&priv->average_missed_beacons); wstats->discard.retries = priv->last_tx_failures; @@ -6238,13 +6277,12 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device * dev) return wstats; } - /* net device stuff */ static inline void init_sys_config(struct ipw_sys_config *sys_config) { - memset(sys_config, 0, sizeof(struct ipw_sys_config)); - sys_config->bt_coexistence = 1; /* We may need to look into prvStaBtConfig */ + memset(sys_config, 0, sizeof(struct ipw_sys_config)); + sys_config->bt_coexistence = 1; /* We may need to look into prvStaBtConfig */ sys_config->answer_broadcast_ssid_probe = 0; sys_config->accept_all_data_frames = 0; sys_config->accept_non_directed_frames = 1; @@ -6253,7 +6291,7 @@ static inline void init_sys_config(struct ipw_sys_config *sys_config) sys_config->exclude_multicast_unencrypted = 0; sys_config->disable_multicast_decryption = 1; sys_config->antenna_diversity = CFG_SYS_ANTENNA_BOTH; - sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */ + sys_config->pass_crc_to_host = 0; /* TODO: See if 1 gives us FCS */ sys_config->dot11g_auto_detection = 0; sys_config->enable_cts_to_self = 0; sys_config->bt_coexist_collision_thr = 0; @@ -6288,7 +6326,7 @@ we need to heavily modify the ieee80211_skb_to_txb. static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) - txb->fragments[0]->data; + txb->fragments[0]->data; int i = 0; struct tfd_frame *tfd; struct clx2_tx_queue *txq = &priv->txq[0]; @@ -6300,7 +6338,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) case IW_MODE_ADHOC: hdr_len = IEEE80211_3ADDR_LEN; unicast = !is_broadcast_ether_addr(hdr->addr1) && - !is_multicast_ether_addr(hdr->addr1); + !is_multicast_ether_addr(hdr->addr1); id = ipw_find_station(priv, hdr->addr1); if (id == IPW_INVALID_STATION) { id = ipw_add_station(priv, hdr->addr1); @@ -6316,7 +6354,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) case IW_MODE_INFRA: default: unicast = !is_broadcast_ether_addr(hdr->addr3) && - !is_multicast_ether_addr(hdr->addr3); + !is_multicast_ether_addr(hdr->addr3); hdr_len = IEEE80211_3ADDR_LEN; id = 0; break; @@ -6349,7 +6387,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) memcpy(&tfd->u.data.tfd.tfd_24.mchdr, hdr, hdr_len); /* payload */ - tfd->u.data.num_chunks = min((u8)(NUM_TFD_CHUNKS - 2), txb->nr_frags); + tfd->u.data.num_chunks = min((u8) (NUM_TFD_CHUNKS - 2), txb->nr_frags); for (i = 0; i < tfd->u.data.num_chunks; i++) { IPW_DEBUG_TX("Dumping TX packet frag %i of %i (%d bytes):\n", i, tfd->u.data.num_chunks, @@ -6357,9 +6395,11 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) printk_buf(IPW_DL_TX, txb->fragments[i]->data + hdr_len, txb->fragments[i]->len - hdr_len); - tfd->u.data.chunk_ptr[i] = pci_map_single( - priv->pci_dev, txb->fragments[i]->data + hdr_len, - txb->fragments[i]->len - hdr_len, PCI_DMA_TODEVICE); + tfd->u.data.chunk_ptr[i] = + pci_map_single(priv->pci_dev, + txb->fragments[i]->data + hdr_len, + txb->fragments[i]->len - hdr_len, + PCI_DMA_TODEVICE); tfd->u.data.chunk_len[i] = txb->fragments[i]->len - hdr_len; } @@ -6379,16 +6419,16 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) for (j = i; j < txb->nr_frags; j++) { int size = txb->fragments[j]->len - hdr_len; printk(KERN_INFO "Adding frag %d %d...\n", - j, size); + j, size); memcpy(skb_put(skb, size), - txb->fragments[j]->data + hdr_len, - size); + txb->fragments[j]->data + hdr_len, size); } dev_kfree_skb_any(txb->fragments[i]); txb->fragments[i] = skb; - tfd->u.data.chunk_ptr[i] = pci_map_single( - priv->pci_dev, skb->data, - tfd->u.data.chunk_len[i], PCI_DMA_TODEVICE); + tfd->u.data.chunk_ptr[i] = + pci_map_single(priv->pci_dev, skb->data, + tfd->u.data.chunk_len[i], + PCI_DMA_TODEVICE); tfd->u.data.num_chunks++; } } @@ -6402,7 +6442,7 @@ static inline void ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb) return; - drop: + drop: IPW_DEBUG_DROP("Silently dropping Tx packet.\n"); ieee80211_txb_free(txb); } @@ -6429,7 +6469,7 @@ static int ipw_net_hard_start_xmit(struct ieee80211_txb *txb, spin_unlock_irqrestore(&priv->lock, flags); return 0; - fail_unlock: + fail_unlock: spin_unlock_irqrestore(&priv->lock, flags); return 1; } @@ -6478,7 +6518,7 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev, len = sizeof(date); ipw_get_ordinal(p, IPW_ORD_STAT_FW_DATE, date, &len); - snprintf(info->fw_version, sizeof(info->fw_version),"%s (%s)", + snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)", vers, date); strcpy(info->bus_info, pci_name(p->pci_dev)); info->eedump_len = CX2_EEPROM_IMAGE_SIZE; @@ -6496,19 +6536,19 @@ static int ipw_ethtool_get_eeprom_len(struct net_device *dev) } static int ipw_ethtool_get_eeprom(struct net_device *dev, - struct ethtool_eeprom *eeprom, u8 *bytes) + struct ethtool_eeprom *eeprom, u8 * bytes) { struct ipw_priv *p = ieee80211_priv(dev); if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE) return -EINVAL; - memcpy(bytes, &((u8 *)p->eeprom)[eeprom->offset], eeprom->len); + memcpy(bytes, &((u8 *) p->eeprom)[eeprom->offset], eeprom->len); return 0; } static int ipw_ethtool_set_eeprom(struct net_device *dev, - struct ethtool_eeprom *eeprom, u8 *bytes) + struct ethtool_eeprom *eeprom, u8 * bytes) { struct ipw_priv *p = ieee80211_priv(dev); int i; @@ -6516,21 +6556,20 @@ static int ipw_ethtool_set_eeprom(struct net_device *dev, if (eeprom->offset + eeprom->len > CX2_EEPROM_IMAGE_SIZE) return -EINVAL; - memcpy(&((u8 *)p->eeprom)[eeprom->offset], bytes, eeprom->len); + memcpy(&((u8 *) p->eeprom)[eeprom->offset], bytes, eeprom->len); for (i = IPW_EEPROM_DATA; - i < IPW_EEPROM_DATA + CX2_EEPROM_IMAGE_SIZE; - i++) + i < IPW_EEPROM_DATA + CX2_EEPROM_IMAGE_SIZE; i++) ipw_write8(p, i, p->eeprom[i]); return 0; } static struct ethtool_ops ipw_ethtool_ops = { - .get_link = ipw_ethtool_get_link, - .get_drvinfo = ipw_ethtool_get_drvinfo, - .get_eeprom_len = ipw_ethtool_get_eeprom_len, - .get_eeprom = ipw_ethtool_get_eeprom, - .set_eeprom = ipw_ethtool_set_eeprom, + .get_link = ipw_ethtool_get_link, + .get_drvinfo = ipw_ethtool_get_drvinfo, + .get_eeprom_len = ipw_ethtool_get_eeprom_len, + .get_eeprom = ipw_ethtool_get_eeprom, + .set_eeprom = ipw_ethtool_set_eeprom, }; static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs) @@ -6574,10 +6613,10 @@ static irqreturn_t ipw_isr(int irq, void *data, struct pt_regs *regs) tasklet_schedule(&priv->irq_tasklet); - spin_unlock(&priv->lock); + spin_unlock(&priv->lock); return IRQ_HANDLED; - none: + none: spin_unlock(&priv->lock); return IRQ_NONE; } @@ -6609,7 +6648,7 @@ static void ipw_rf_kill(void *adapter) IPW_DEBUG_RF_KILL("HW RF Kill deactivated. SW RF Kill still " "enabled\n"); - exit_unlock: + exit_unlock: spin_unlock_irqrestore(&priv->lock, flags); } @@ -6642,7 +6681,6 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv) return ret; } - static void shim__set_security(struct net_device *dev, struct ieee80211_security *sec) { @@ -6683,8 +6721,7 @@ static void shim__set_security(struct net_device *dev, priv->status |= STATUS_SECURITY_UPDATED; } - if (sec->flags & SEC_ENABLED && - priv->sec.enabled != sec->enabled) { + if (sec->flags & SEC_ENABLED && priv->sec.enabled != sec->enabled) { priv->sec.flags |= SEC_ENABLED; priv->sec.enabled = sec->enabled; priv->status |= STATUS_SECURITY_UPDATED; @@ -6694,8 +6731,7 @@ static void shim__set_security(struct net_device *dev, priv->capability &= ~CAP_PRIVACY_ON; } - if (sec->flags & SEC_LEVEL && - priv->sec.level != sec->level) { + if (sec->flags & SEC_LEVEL && priv->sec.level != sec->level) { priv->sec.level = sec->level; priv->sec.flags |= SEC_LEVEL; priv->status |= STATUS_SECURITY_UPDATED; @@ -6709,7 +6745,7 @@ static void shim__set_security(struct net_device *dev, (((priv->assoc_request.capability & WLAN_CAPABILITY_PRIVACY) && !sec->enabled) || (!(priv->assoc_request.capability & - WLAN_CAPABILITY_PRIVACY) && sec->enabled))) { + WLAN_CAPABILITY_PRIVACY) && sec->enabled))) { IPW_DEBUG_ASSOC("Disassociating due to capability " "change.\n"); ipw_disassociate(priv); @@ -6723,7 +6759,7 @@ static int init_supported_rates(struct ipw_priv *priv, /* TODO: Mask out rates based on priv->rates_mask */ memset(rates, 0, sizeof(*rates)); - /* configure supported rates */ + /* configure supported rates */ switch (priv->ieee->freq_band) { case IEEE80211_52GHZ_BAND: rates->ieee_mode = IPW_A_MODE; @@ -6732,7 +6768,7 @@ static int init_supported_rates(struct ipw_priv *priv, IEEE80211_OFDM_DEFAULT_RATES_MASK); break; - default: /* Mixed or 2.4Ghz */ + default: /* Mixed or 2.4Ghz */ rates->ieee_mode = IPW_G_MODE; rates->purpose = IPW_RATE_CAPABILITIES; ipw_add_cck_scan_rates(rates, IEEE80211_CCK_MODULATION, @@ -6783,8 +6819,8 @@ static int ipw_config(struct ipw_priv *priv) if (ipw_send_system_config(priv, &priv->sys_config)) goto error; - init_supported_rates(priv, &priv->rates); - if (ipw_send_supported_rates(priv, &priv->rates)) + init_supported_rates(priv, &priv->rates); + if (ipw_send_supported_rates(priv, &priv->rates)) goto error; /* Set request-to-send threshold */ @@ -6806,7 +6842,7 @@ static int ipw_config(struct ipw_priv *priv) return 0; - error: + error: return -EIO; } @@ -6818,13 +6854,12 @@ static int ipw_up(struct ipw_priv *priv) if (priv->status & STATUS_EXIT_PENDING) return -EIO; - for (i = 0; i < MAX_HW_RESTARTS; i++ ) { + for (i = 0; i < MAX_HW_RESTARTS; i++) { /* Load the microcode, firmware, and eeprom. * Also start the clocks. */ rc = ipw_load(priv); if (rc) { - IPW_ERROR("Unable to load firmware: 0x%08X\n", - rc); + IPW_ERROR("Unable to load firmware: 0x%08X\n", rc); return rc; } @@ -6857,8 +6892,7 @@ static int ipw_up(struct ipw_priv *priv) /* tried to restart and config the device for as long as our * patience could withstand */ - IPW_ERROR("Unable to initialize device after %d attempts.\n", - i); + IPW_ERROR("Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -6923,10 +6957,10 @@ static struct pci_device_id card_ids[] = { {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2761, 0, 0, 0}, {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2762, 0, 0, 0}, {PCI_VENDOR_ID_INTEL, 0x104f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - {PCI_VENDOR_ID_INTEL, 0x4220, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* BG */ - {PCI_VENDOR_ID_INTEL, 0x4221, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 2225BG */ - {PCI_VENDOR_ID_INTEL, 0x4223, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ - {PCI_VENDOR_ID_INTEL, 0x4224, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ + {PCI_VENDOR_ID_INTEL, 0x4220, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* BG */ + {PCI_VENDOR_ID_INTEL, 0x4221, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 2225BG */ + {PCI_VENDOR_ID_INTEL, 0x4223, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ + {PCI_VENDOR_ID_INTEL, 0x4224, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ /* required last entry */ {0,} @@ -6954,11 +6988,10 @@ static struct attribute *ipw_sysfs_entries[] = { static struct attribute_group ipw_attribute_group = { .name = NULL, /* put in device directory */ - .attrs = ipw_sysfs_entries, + .attrs = ipw_sysfs_entries, }; -static int ipw_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *ent) +static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0; struct net_device *net_dev; @@ -7051,7 +7084,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, priv->config |= CFG_STATIC_CHANNEL; priv->channel = channel; IPW_DEBUG_INFO("Bind to static channel %d\n", channel); - IPW_DEBUG_INFO("Bind to static channel %d\n", channel); + IPW_DEBUG_INFO("Bind to static channel %d\n", channel); /* TODO: Validate that provided channel is in range */ } @@ -7078,9 +7111,9 @@ static int ipw_pci_probe(struct pci_dev *pdev, priv->ieee->abg_ture = 1; band = IEEE80211_52GHZ_BAND | IEEE80211_24GHZ_BAND; modulation = IEEE80211_OFDM_MODULATION | - IEEE80211_CCK_MODULATION; + IEEE80211_CCK_MODULATION; priv->adapter = IPW_2915ABG; - priv->ieee->mode = IEEE_A|IEEE_G|IEEE_B; + priv->ieee->mode = IEEE_A | IEEE_G | IEEE_B; } else { if (priv->pci_dev->device == 0x4221) printk(KERN_INFO DRV_NAME @@ -7094,9 +7127,9 @@ static int ipw_pci_probe(struct pci_dev *pdev, priv->ieee->abg_ture = 0; band = IEEE80211_24GHZ_BAND; modulation = IEEE80211_OFDM_MODULATION | - IEEE80211_CCK_MODULATION; + IEEE80211_CCK_MODULATION; priv->adapter = IPW_2200BG; - priv->ieee->mode = IEEE_G|IEEE_B; + priv->ieee->mode = IEEE_G | IEEE_B; } priv->ieee->freq_band = band; @@ -7110,11 +7143,10 @@ static int ipw_pci_probe(struct pci_dev *pdev, priv->rts_threshold = DEFAULT_RTS_THRESHOLD; /* If power management is turned on, default to AC mode */ - priv->power_mode = IPW_POWER_AC; + priv->power_mode = IPW_POWER_AC; priv->tx_power = IPW_DEFAULT_TX_POWER; - err = request_irq(pdev->irq, ipw_isr, SA_SHIRQ, DRV_NAME, - priv); + err = request_irq(pdev->irq, ipw_isr, SA_SHIRQ, DRV_NAME, priv); if (err) { IPW_ERROR("Error allocating IRQ %d\n", pdev->irq); goto out_destroy_workqueue; @@ -7136,7 +7168,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, net_dev->wireless_handlers = &ipw_wx_handler_def; net_dev->ethtool_ops = &ipw_ethtool_ops; net_dev->irq = pdev->irq; - net_dev->base_addr = (unsigned long )priv->hw_base; + net_dev->base_addr = (unsigned long)priv->hw_base; net_dev->mem_start = pci_resource_start(pdev, 0); net_dev->mem_end = net_dev->mem_start + pci_resource_len(pdev, 0) - 1; @@ -7154,23 +7186,23 @@ static int ipw_pci_probe(struct pci_dev *pdev, return 0; - out_remove_group: + out_remove_group: sysfs_remove_group(&pdev->dev.kobj, &ipw_attribute_group); - out_release_irq: + out_release_irq: free_irq(pdev->irq, priv); - out_destroy_workqueue: + out_destroy_workqueue: destroy_workqueue(priv->workqueue); priv->workqueue = NULL; - out_iounmap: + out_iounmap: iounmap(priv->hw_base); - out_pci_release_regions: + out_pci_release_regions: pci_release_regions(pdev); - out_pci_disable_device: + out_pci_disable_device: pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - out_free_ieee80211: + out_free_ieee80211: free_ieee80211(priv->net_dev); - out: + out: return err; } @@ -7223,7 +7255,6 @@ static void ipw_pci_remove(struct pci_dev *pdev) #endif } - #ifdef CONFIG_PM static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state) { @@ -7232,7 +7263,7 @@ static int ipw_pci_suspend(struct pci_dev *pdev, pm_message_t state) printk(KERN_INFO "%s: Going into suspend...\n", dev->name); - /* Take down the device; powers it off, etc. */ + /* Take down the device; powers it off, etc. */ ipw_down(priv); /* Remove the PRESENT state of the device */ @@ -7306,8 +7337,7 @@ static int __init ipw_init(void) return ret; } - ret = driver_create_file(&ipw_driver.driver, - &driver_attr_debug_level); + ret = driver_create_file(&ipw_driver.driver, &driver_attr_debug_level); if (ret) { IPW_ERROR("Unable to create driver sysfs file\n"); pci_unregister_driver(&ipw_driver); diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h index 66bb5903537..5b00882133f 100644 --- a/drivers/net/wireless/ipw2200.h +++ b/drivers/net/wireless/ipw2200.h @@ -56,8 +56,7 @@ #include <linux/workqueue.h> /* Authentication and Association States */ -enum connection_manager_assoc_states -{ +enum connection_manager_assoc_states { CMAS_INIT = 0, CMAS_TX_AUTH_SEQ_1, CMAS_RX_AUTH_SEQ_2, @@ -74,7 +73,6 @@ enum connection_manager_assoc_states CMAS_LAST }; - #define IPW_WAIT (1<<0) #define IPW_QUIET (1<<1) #define IPW_ROAMING (1<<2) @@ -190,7 +188,6 @@ enum connection_manager_assoc_states #define DCT_FLAG_EXT_MODE_CCK 0x01 #define DCT_FLAG_EXT_MODE_OFDM 0x00 - #define TX_RX_TYPE_MASK 0xFF #define TX_FRAME_TYPE 0x00 #define TX_HOST_COMMAND_TYPE 0x01 @@ -242,107 +239,97 @@ enum connection_manager_assoc_states * Contains common data for Rx and Tx queues */ struct clx2_queue { - int n_bd; /**< number of BDs in this queue */ - int first_empty; /**< 1-st empty entry (index) */ - int last_used; /**< last used entry (index) */ - u32 reg_w; /**< 'write' reg (queue head), addr in domain 1 */ - u32 reg_r; /**< 'read' reg (queue tail), addr in domain 1 */ - dma_addr_t dma_addr; /**< physical addr for BD's */ - int low_mark; /**< low watermark, resume queue if free space more than this */ - int high_mark; /**< high watermark, stop queue if free space less than this */ + int n_bd; /**< number of BDs in this queue */ + int first_empty; /**< 1-st empty entry (index) */ + int last_used; /**< last used entry (index) */ + u32 reg_w; /**< 'write' reg (queue head), addr in domain 1 */ + u32 reg_r; /**< 'read' reg (queue tail), addr in domain 1 */ + dma_addr_t dma_addr; /**< physical addr for BD's */ + int low_mark; /**< low watermark, resume queue if free space more than this */ + int high_mark; /**< high watermark, stop queue if free space less than this */ } __attribute__ ((packed)); -struct machdr32 -{ +struct machdr32 { u16 frame_ctl; - u16 duration; // watch out for endians! - u8 addr1[ MACADRR_BYTE_LEN ]; - u8 addr2[ MACADRR_BYTE_LEN ]; - u8 addr3[ MACADRR_BYTE_LEN ]; - u16 seq_ctrl; // more endians! - u8 addr4[ MACADRR_BYTE_LEN ]; + u16 duration; // watch out for endians! + u8 addr1[MACADRR_BYTE_LEN]; + u8 addr2[MACADRR_BYTE_LEN]; + u8 addr3[MACADRR_BYTE_LEN]; + u16 seq_ctrl; // more endians! + u8 addr4[MACADRR_BYTE_LEN]; u16 qos_ctrl; -} __attribute__ ((packed)) ; +} __attribute__ ((packed)); -struct machdr30 -{ +struct machdr30 { u16 frame_ctl; - u16 duration; // watch out for endians! - u8 addr1[ MACADRR_BYTE_LEN ]; - u8 addr2[ MACADRR_BYTE_LEN ]; - u8 addr3[ MACADRR_BYTE_LEN ]; - u16 seq_ctrl; // more endians! - u8 addr4[ MACADRR_BYTE_LEN ]; -} __attribute__ ((packed)) ; - -struct machdr26 -{ + u16 duration; // watch out for endians! + u8 addr1[MACADRR_BYTE_LEN]; + u8 addr2[MACADRR_BYTE_LEN]; + u8 addr3[MACADRR_BYTE_LEN]; + u16 seq_ctrl; // more endians! + u8 addr4[MACADRR_BYTE_LEN]; +} __attribute__ ((packed)); + +struct machdr26 { u16 frame_ctl; - u16 duration; // watch out for endians! - u8 addr1[ MACADRR_BYTE_LEN ]; - u8 addr2[ MACADRR_BYTE_LEN ]; - u8 addr3[ MACADRR_BYTE_LEN ]; - u16 seq_ctrl; // more endians! + u16 duration; // watch out for endians! + u8 addr1[MACADRR_BYTE_LEN]; + u8 addr2[MACADRR_BYTE_LEN]; + u8 addr3[MACADRR_BYTE_LEN]; + u16 seq_ctrl; // more endians! u16 qos_ctrl; -} __attribute__ ((packed)) ; +} __attribute__ ((packed)); -struct machdr24 -{ +struct machdr24 { u16 frame_ctl; - u16 duration; // watch out for endians! - u8 addr1[ MACADRR_BYTE_LEN ]; - u8 addr2[ MACADRR_BYTE_LEN ]; - u8 addr3[ MACADRR_BYTE_LEN ]; - u16 seq_ctrl; // more endians! -} __attribute__ ((packed)) ; + u16 duration; // watch out for endians! + u8 addr1[MACADRR_BYTE_LEN]; + u8 addr2[MACADRR_BYTE_LEN]; + u8 addr3[MACADRR_BYTE_LEN]; + u16 seq_ctrl; // more endians! +} __attribute__ ((packed)); // TX TFD with 32 byte MAC Header -struct tx_tfd_32 -{ - struct machdr32 mchdr; // 32 - u32 uivplaceholder[2]; // 8 -} __attribute__ ((packed)) ; +struct tx_tfd_32 { + struct machdr32 mchdr; // 32 + u32 uivplaceholder[2]; // 8 +} __attribute__ ((packed)); // TX TFD with 30 byte MAC Header -struct tx_tfd_30 -{ - struct machdr30 mchdr; // 30 - u8 reserved[2]; // 2 - u32 uivplaceholder[2]; // 8 -} __attribute__ ((packed)) ; +struct tx_tfd_30 { + struct machdr30 mchdr; // 30 + u8 reserved[2]; // 2 + u32 uivplaceholder[2]; // 8 +} __attribute__ ((packed)); // tx tfd with 26 byte mac header -struct tx_tfd_26 -{ - struct machdr26 mchdr; // 26 - u8 reserved1[2]; // 2 - u32 uivplaceholder[2]; // 8 - u8 reserved2[4]; // 4 -} __attribute__ ((packed)) ; +struct tx_tfd_26 { + struct machdr26 mchdr; // 26 + u8 reserved1[2]; // 2 + u32 uivplaceholder[2]; // 8 + u8 reserved2[4]; // 4 +} __attribute__ ((packed)); // tx tfd with 24 byte mac header -struct tx_tfd_24 -{ - struct machdr24 mchdr; // 24 - u32 uivplaceholder[2]; // 8 - u8 reserved[8]; // 8 -} __attribute__ ((packed)) ; - +struct tx_tfd_24 { + struct machdr24 mchdr; // 24 + u32 uivplaceholder[2]; // 8 + u8 reserved[8]; // 8 +} __attribute__ ((packed)); #define DCT_WEP_KEY_FIELD_LENGTH 16 -struct tfd_command -{ +struct tfd_command { u8 index; u8 length; u16 reserved; u8 payload[0]; -} __attribute__ ((packed)) ; +} __attribute__ ((packed)); struct tfd_data { /* Header */ u32 work_area_ptr; - u8 station_number; /* 0 for BSS */ + u8 station_number; /* 0 for BSS */ u8 reserved1; u16 reserved2; @@ -359,14 +346,13 @@ struct tfd_data { u8 antenna; u16 next_packet_duration; u16 next_frag_len; - u16 back_off_counter; //////txop; + u16 back_off_counter; //////txop; u8 retrylimit; u16 cwcurrent; u8 reserved3; /* 802.11 MAC Header */ - union - { + union { struct tx_tfd_24 tfd_24; struct tx_tfd_26 tfd_26; struct tx_tfd_30 tfd_30; @@ -379,8 +365,7 @@ struct tfd_data { u16 chunk_len[NUM_TFD_CHUNKS]; } __attribute__ ((packed)); -struct txrx_control_flags -{ +struct txrx_control_flags { u8 message_type; u8 rx_seq_num; u8 control_bits; @@ -390,17 +375,16 @@ struct txrx_control_flags #define TFD_SIZE 128 #define TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH (TFD_SIZE - sizeof(struct txrx_control_flags)) -struct tfd_frame -{ +struct tfd_frame { struct txrx_control_flags control_flags; union { struct tfd_data data; struct tfd_command cmd; u8 raw[TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH]; } u; -} __attribute__ ((packed)) ; +} __attribute__ ((packed)); -typedef void destructor_func(const void*); +typedef void destructor_func(const void *); /** * Tx Queue for DMA. Queue consists of circular buffer of @@ -408,7 +392,7 @@ typedef void destructor_func(const void*); */ struct clx2_tx_queue { struct clx2_queue q; - struct tfd_frame* bd; + struct tfd_frame *bd; struct ieee80211_txb **txb; }; @@ -423,8 +407,7 @@ struct clx2_tx_queue { #define SUP_RATE_11G_MAX_NUM_CHANNELS (12) // Used for passing to driver number of successes and failures per rate -struct rate_histogram -{ +struct rate_histogram { union { u32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; u32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; @@ -475,12 +458,12 @@ struct notif_scan_complete { u8 num_channels; u8 status; u8 reserved; -} __attribute__ ((packed)); +} __attribute__ ((packed)); struct notif_frag_length { u16 frag_length; u16 reserved; -} __attribute__ ((packed)); +} __attribute__ ((packed)); struct notif_beacon_state { u32 state; @@ -543,11 +526,11 @@ struct ipw_rx_notification { struct ipw_rx_frame { u32 reserved1; - u8 parent_tsf[4]; // fw_use[0] is boolean for OUR_TSF_IS_GREATER - u8 received_channel; // The channel that this frame was received on. - // Note that for .11b this does not have to be - // the same as the channel that it was sent. - // Filled by LMAC + u8 parent_tsf[4]; // fw_use[0] is boolean for OUR_TSF_IS_GREATER + u8 received_channel; // The channel that this frame was received on. + // Note that for .11b this does not have to be + // the same as the channel that it was sent. + // Filled by LMAC u8 frameStatus; u8 rate; u8 rssi; @@ -556,10 +539,10 @@ struct ipw_rx_frame { u16 signal; u16 noise; u8 antennaAndPhy; - u8 control; // control bit should be on in bg - u8 rtscts_rate; // rate of rts or cts (in rts cts sequence rate - // is identical) - u8 rtscts_seen; // 0x1 RTS seen ; 0x2 CTS seen + u8 control; // control bit should be on in bg + u8 rtscts_rate; // rate of rts or cts (in rts cts sequence rate + // is identical) + u8 rtscts_seen; // 0x1 RTS seen ; 0x2 CTS seen u16 length; u8 data[0]; } __attribute__ ((packed)); @@ -571,8 +554,7 @@ struct ipw_rx_header { u8 reserved; } __attribute__ ((packed)); -struct ipw_rx_packet -{ +struct ipw_rx_packet { struct ipw_rx_header header; union { struct ipw_rx_frame frame; @@ -589,21 +571,20 @@ struct ipw_rx_mem_buffer { struct ipw_rx_buffer *rxb; struct sk_buff *skb; struct list_head list; -}; /* Not transferred over network, so not __attribute__ ((packed)) */ +}; /* Not transferred over network, so not __attribute__ ((packed)) */ struct ipw_rx_queue { struct ipw_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; struct ipw_rx_mem_buffer *queue[RX_QUEUE_SIZE]; - u32 processed; /* Internal index to last handled Rx packet */ - u32 read; /* Shared index to newest available Rx buffer */ - u32 write; /* Shared index to oldest written Rx packet */ - u32 free_count;/* Number of pre-allocated buffers in rx_free */ + u32 processed; /* Internal index to last handled Rx packet */ + u32 read; /* Shared index to newest available Rx buffer */ + u32 write; /* Shared index to oldest written Rx packet */ + u32 free_count; /* Number of pre-allocated buffers in rx_free */ /* Each of these lists is used as a FIFO for ipw_rx_mem_buffers */ - struct list_head rx_free; /* Own an SKBs */ - struct list_head rx_used; /* No SKB allocated */ + struct list_head rx_free; /* Own an SKBs */ + struct list_head rx_used; /* No SKB allocated */ spinlock_t lock; -}; /* Not transferred over network, so not __attribute__ ((packed)) */ - +}; /* Not transferred over network, so not __attribute__ ((packed)) */ struct alive_command_responce { u8 alive_command; @@ -627,8 +608,7 @@ struct ipw_rates { u8 rates[IPW_MAX_RATES]; } __attribute__ ((packed)); -struct command_block -{ +struct command_block { unsigned int control; u32 source_addr; u32 dest_addr; @@ -636,18 +616,16 @@ struct command_block } __attribute__ ((packed)); #define CB_NUMBER_OF_ELEMENTS_SMALL 64 -struct fw_image_desc -{ +struct fw_image_desc { unsigned long last_cb_index; unsigned long current_cb_index; struct command_block cb_list[CB_NUMBER_OF_ELEMENTS_SMALL]; - void * v_addr; + void *v_addr; unsigned long p_addr; unsigned long len; }; -struct ipw_sys_config -{ +struct ipw_sys_config { u8 bt_coexistence; u8 reserved1; u8 answer_broadcast_ssid_probe; @@ -670,8 +648,7 @@ struct ipw_sys_config u8 reserved3; } __attribute__ ((packed)); -struct ipw_multicast_addr -{ +struct ipw_multicast_addr { u8 num_of_multicast_addresses; u8 reserved[3]; u8 mac1[6]; @@ -680,8 +657,7 @@ struct ipw_multicast_addr u8 mac4[6]; } __attribute__ ((packed)); -struct ipw_wep_key -{ +struct ipw_wep_key { u8 cmd_id; u8 seq_num; u8 key_index; @@ -689,8 +665,7 @@ struct ipw_wep_key u8 key[16]; } __attribute__ ((packed)); -struct ipw_tgi_tx_key -{ +struct ipw_tgi_tx_key { u8 key_id; u8 security_type; u8 station_index; @@ -701,8 +676,7 @@ struct ipw_tgi_tx_key #define IPW_SCAN_CHANNELS 54 -struct ipw_scan_request -{ +struct ipw_scan_request { u8 scan_type; u16 dwell_time; u8 channels_list[IPW_SCAN_CHANNELS]; @@ -718,8 +692,7 @@ enum { IPW_SCAN_TYPES }; -struct ipw_scan_request_ext -{ +struct ipw_scan_request_ext { u32 full_scan_index; u8 channels_list[IPW_SCAN_CHANNELS]; u8 scan_type[IPW_SCAN_CHANNELS / 2]; @@ -740,19 +713,16 @@ extern inline void ipw_set_scan_type(struct ipw_scan_request_ext *scan, { if (index % 2) scan->scan_type[index / 2] = - (scan->scan_type[index / 2] & 0xF0) | - (scan_type & 0x0F); + (scan->scan_type[index / 2] & 0xF0) | (scan_type & 0x0F); else scan->scan_type[index / 2] = - (scan->scan_type[index / 2] & 0x0F) | - ((scan_type & 0x0F) << 4); + (scan->scan_type[index / 2] & 0x0F) | + ((scan_type & 0x0F) << 4); } -struct ipw_associate -{ +struct ipw_associate { u8 channel; - u8 auth_type:4, - auth_key:4; + u8 auth_type:4, auth_key:4; u8 assoc_type; u8 reserved; u16 policy_support; @@ -771,8 +741,7 @@ struct ipw_associate u16 reserved2; } __attribute__ ((packed)); -struct ipw_supported_rates -{ +struct ipw_supported_rates { u8 ieee_mode; u8 num_rates; u8 purpose; @@ -780,42 +749,36 @@ struct ipw_supported_rates u8 supported_rates[IPW_MAX_RATES]; } __attribute__ ((packed)); -struct ipw_rts_threshold -{ +struct ipw_rts_threshold { u16 rts_threshold; u16 reserved; } __attribute__ ((packed)); -struct ipw_frag_threshold -{ +struct ipw_frag_threshold { u16 frag_threshold; u16 reserved; } __attribute__ ((packed)); -struct ipw_retry_limit -{ +struct ipw_retry_limit { u8 short_retry_limit; u8 long_retry_limit; u16 reserved; } __attribute__ ((packed)); -struct ipw_dino_config -{ +struct ipw_dino_config { u32 dino_config_addr; u16 dino_config_size; u8 dino_response; u8 reserved; } __attribute__ ((packed)); -struct ipw_aironet_info -{ +struct ipw_aironet_info { u8 id; u8 length; u16 reserved; } __attribute__ ((packed)); -struct ipw_rx_key -{ +struct ipw_rx_key { u8 station_index; u8 key_type; u8 key_id; @@ -826,23 +789,20 @@ struct ipw_rx_key u8 reserved; } __attribute__ ((packed)); -struct ipw_country_channel_info -{ +struct ipw_country_channel_info { u8 first_channel; u8 no_channels; s8 max_tx_power; } __attribute__ ((packed)); -struct ipw_country_info -{ +struct ipw_country_info { u8 id; u8 length; u8 country_str[3]; struct ipw_country_channel_info groups[7]; } __attribute__ ((packed)); -struct ipw_channel_tx_power -{ +struct ipw_channel_tx_power { u8 channel_number; s8 tx_power; } __attribute__ ((packed)); @@ -852,15 +812,13 @@ struct ipw_channel_tx_power #define MAX_A_CHANNELS 37 #define MAX_B_CHANNELS 14 -struct ipw_tx_power -{ +struct ipw_tx_power { u8 num_channels; u8 ieee_mode; struct ipw_channel_tx_power channels_tx_power[MAX_A_CHANNELS]; } __attribute__ ((packed)); -struct ipw_qos_parameters -{ +struct ipw_qos_parameters { u16 cw_min[4]; u16 cw_max[4]; u8 aifs[4]; @@ -868,15 +826,13 @@ struct ipw_qos_parameters u16 tx_op_limit[4]; } __attribute__ ((packed)); -struct ipw_rsn_capabilities -{ +struct ipw_rsn_capabilities { u8 id; u8 length; u16 version; } __attribute__ ((packed)); -struct ipw_sensitivity_calib -{ +struct ipw_sensitivity_calib { u16 beacon_rssi_raw; u16 reserved; } __attribute__ ((packed)); @@ -895,10 +851,11 @@ struct ipw_sensitivity_calib * - \a param filled with status parameters. */ struct ipw_cmd { - u32 cmd; /**< Host command */ - u32 status; /**< Status */ - u32 status_len; /**< How many 32 bit parameters in the status */ - u32 len; /**< incoming parameters length, bytes */ + u32 cmd; /**< Host command */ + u32 status;/**< Status */ + u32 status_len; + /**< How many 32 bit parameters in the status */ + u32 len; /**< incoming parameters length, bytes */ /** * command parameters. * There should be enough space for incoming and @@ -906,10 +863,10 @@ struct ipw_cmd { * Incoming parameters listed 1-st, followed by outcoming params. * nParams=(len+3)/4+status_len */ - u32 param[0]; + u32 param[0]; } __attribute__ ((packed)); -#define STATUS_HCMD_ACTIVE (1<<0) /**< host command in progress */ +#define STATUS_HCMD_ACTIVE (1<<0) /**< host command in progress */ #define STATUS_INT_ENABLED (1<<1) #define STATUS_RF_KILL_HW (1<<2) @@ -932,15 +889,15 @@ struct ipw_cmd { #define STATUS_SCANNING (1<<21) #define STATUS_SCAN_ABORTING (1<<22) -#define STATUS_INDIRECT_BYTE (1<<28) /* sysfs entry configured for access */ -#define STATUS_INDIRECT_DWORD (1<<29) /* sysfs entry configured for access */ -#define STATUS_DIRECT_DWORD (1<<30) /* sysfs entry configured for access */ +#define STATUS_INDIRECT_BYTE (1<<28) /* sysfs entry configured for access */ +#define STATUS_INDIRECT_DWORD (1<<29) /* sysfs entry configured for access */ +#define STATUS_DIRECT_DWORD (1<<30) /* sysfs entry configured for access */ -#define STATUS_SECURITY_UPDATED (1<<31) /* Security sync needed */ +#define STATUS_SECURITY_UPDATED (1<<31) /* Security sync needed */ -#define CFG_STATIC_CHANNEL (1<<0) /* Restrict assoc. to single channel */ -#define CFG_STATIC_ESSID (1<<1) /* Restrict assoc. to single SSID */ -#define CFG_STATIC_BSSID (1<<2) /* Restrict assoc. to single BSSID */ +#define CFG_STATIC_CHANNEL (1<<0) /* Restrict assoc. to single channel */ +#define CFG_STATIC_ESSID (1<<1) /* Restrict assoc. to single SSID */ +#define CFG_STATIC_BSSID (1<<2) /* Restrict assoc. to single BSSID */ #define CFG_CUSTOM_MAC (1<<3) #define CFG_PREAMBLE (1<<4) #define CFG_ADHOC_PERSIST (1<<5) @@ -948,8 +905,8 @@ struct ipw_cmd { #define CFG_FIXED_RATE (1<<7) #define CFG_ADHOC_CREATE (1<<8) -#define CAP_SHARED_KEY (1<<0) /* Off = OPEN */ -#define CAP_PRIVACY_ON (1<<1) /* Off = No privacy */ +#define CAP_SHARED_KEY (1<<0) /* Off = OPEN */ +#define CAP_PRIVACY_ON (1<<1) /* Off = No privacy */ #define MAX_STATIONS 32 #define IPW_INVALID_STATION (0xff) @@ -989,8 +946,8 @@ struct ipw_priv { /* result of ucode download */ struct alive_command_responce dino_alive; - wait_queue_head_t wait_command_queue; - wait_queue_head_t wait_state; + wait_queue_head_t wait_command_queue; + wait_queue_head_t wait_state; /* Rx and Tx DMA processing queues */ struct ipw_rx_queue *rxq; @@ -1006,9 +963,9 @@ struct ipw_priv { struct average average_rssi; struct average average_noise; u32 port_type; - int rx_bufs_min; /**< minimum number of bufs in Rx queue */ - int rx_pend_max; /**< maximum pending buffers for one IRQ */ - u32 hcmd_seq; /**< sequence number for hcmd */ + int rx_bufs_min; /**< minimum number of bufs in Rx queue */ + int rx_pend_max; /**< maximum pending buffers for one IRQ */ + u32 hcmd_seq; /**< sequence number for hcmd */ u32 missed_beacon_threshold; u32 roaming_threshold; @@ -1017,17 +974,17 @@ struct ipw_priv { unsigned long ts_scan_abort; struct ipw_supported_rates rates; - struct ipw_rates phy[3]; /**< PHY restrictions, per band */ - struct ipw_rates supp; /**< software defined */ - struct ipw_rates extended; /**< use for corresp. IE, AP only */ + struct ipw_rates phy[3]; /**< PHY restrictions, per band */ + struct ipw_rates supp; /**< software defined */ + struct ipw_rates extended; /**< use for corresp. IE, AP only */ struct notif_link_deterioration last_link_deterioration; /** for statistics */ - struct ipw_cmd* hcmd; /**< host command currently executed */ + struct ipw_cmd *hcmd; /**< host command currently executed */ wait_queue_head_t hcmd_wq; /**< host command waits for execution */ - u32 tsf_bcn[2]; /**< TSF from latest beacon */ + u32 tsf_bcn[2]; /**< TSF from latest beacon */ - struct notif_calibration calib; /**< last calibration */ + struct notif_calibration calib; /**< last calibration */ /* ordinal interface with firmware */ u32 table0_addr; @@ -1067,8 +1024,8 @@ struct ipw_priv { u32 tx_packets; u32 quality; - /* eeprom */ - u8 eeprom[0x100]; /* 256 bytes of eeprom */ + /* eeprom */ + u8 eeprom[0x100]; /* 256 bytes of eeprom */ int eeprom_delay; struct iw_statistics wstats; @@ -1091,7 +1048,6 @@ struct ipw_priv { struct tasklet_struct irq_tasklet; - #define IPW_2200BG 1 #define IPW_2915ABG 2 u8 adapter; @@ -1114,7 +1070,6 @@ struct ipw_priv { u32 indirect_byte; }; /*ipw_priv */ - /* debug macros */ #ifdef CONFIG_IPW_DEBUG @@ -1170,7 +1125,6 @@ do { if (ipw_debug_level & (level)) \ #define IPW_DL_RF_KILL (1<<17) #define IPW_DL_FW_ERRORS (1<<18) - #define IPW_DL_ORD (1<<20) #define IPW_DL_FRAG (1<<21) @@ -1184,7 +1138,6 @@ do { if (ipw_debug_level & (level)) \ #define IPW_DL_STATS (1<<29) - #define IPW_ERROR(f, a...) printk(KERN_ERR DRV_NAME ": " f, ## a) #define IPW_WARNING(f, a...) printk(KERN_WARNING DRV_NAME ": " f, ## a) #define IPW_DEBUG_INFO(f, a...) IPW_DEBUG(IPW_DL_INFO, f, ## a) @@ -1253,12 +1206,12 @@ do { if (ipw_debug_level & (level)) \ /* * RESET Register Bit Indexes */ -#define CBD_RESET_REG_PRINCETON_RESET 0x00000001 /* Bit 0 (LSB) */ -#define CX2_RESET_REG_SW_RESET 0x00000080 /* Bit 7 */ -#define CX2_RESET_REG_MASTER_DISABLED 0x00000100 /* Bit 8 */ -#define CX2_RESET_REG_STOP_MASTER 0x00000200 /* Bit 9 */ -#define CX2_ARC_KESHET_CONFIG 0x08000000 /* Bit 27 */ -#define CX2_START_STANDBY 0x00000004 /* Bit 2 */ +#define CBD_RESET_REG_PRINCETON_RESET 0x00000001 /* Bit 0 (LSB) */ +#define CX2_RESET_REG_SW_RESET 0x00000080 /* Bit 7 */ +#define CX2_RESET_REG_MASTER_DISABLED 0x00000100 /* Bit 8 */ +#define CX2_RESET_REG_STOP_MASTER 0x00000200 /* Bit 9 */ +#define CX2_ARC_KESHET_CONFIG 0x08000000 /* Bit 27 */ +#define CX2_START_STANDBY 0x00000004 /* Bit 2 */ #define CX2_CSR_CIS_UPPER_BOUND 0x00000200 #define CX2_DOMAIN_0_END 0x1000 @@ -1289,14 +1242,12 @@ do { if (ipw_debug_level & (level)) \ #define CB_SRC_SIZE_LONG 0x00200000 #define CB_DEST_SIZE_LONG 0x00020000 - /* DMA DEFINES */ #define DMA_CONTROL_SMALL_CB_CONST_VALUE 0x00540000 #define DMA_CB_STOP_AND_ABORT 0x00000C00 #define DMA_CB_START 0x00000100 - #define CX2_SHARED_SRAM_SIZE 0x00030000 #define CX2_SHARED_SRAM_DMA_CONTROL 0x00027000 #define CB_MAX_LENGTH 0x1FFF @@ -1304,7 +1255,6 @@ do { if (ipw_debug_level & (level)) \ #define CX2_HOST_EEPROM_DATA_SRAM_SIZE 0xA18 #define CX2_EEPROM_IMAGE_SIZE 0x100 - /* DMA defs */ #define CX2_DMA_I_CURRENT_CB 0x003000D0 #define CX2_DMA_O_CURRENT_CB 0x003000D4 @@ -1356,7 +1306,6 @@ do { if (ipw_debug_level & (level)) \ #define IPW_WHO_IS_AWAKE (CX2_SHARED_LOWER_BOUND + 0xB14) #define IPW_DURING_ATIM_WINDOW (CX2_SHARED_LOWER_BOUND + 0xB18) - #define MSB 1 #define LSB 0 #define WORD_TO_BYTE(_word) ((_word) * sizeof(u16)) @@ -1365,16 +1314,16 @@ do { if (ipw_debug_level & (level)) \ ( WORD_TO_BYTE(_wordoffset) + (_byteoffset) ) /* EEPROM access by BYTE */ -#define EEPROM_PME_CAPABILITY (GET_EEPROM_ADDR(0x09,MSB)) /* 1 byte */ -#define EEPROM_MAC_ADDRESS (GET_EEPROM_ADDR(0x21,LSB)) /* 6 byte */ -#define EEPROM_VERSION (GET_EEPROM_ADDR(0x24,MSB)) /* 1 byte */ -#define EEPROM_NIC_TYPE (GET_EEPROM_ADDR(0x25,LSB)) /* 1 byte */ -#define EEPROM_SKU_CAPABILITY (GET_EEPROM_ADDR(0x25,MSB)) /* 1 byte */ -#define EEPROM_COUNTRY_CODE (GET_EEPROM_ADDR(0x26,LSB)) /* 3 bytes */ -#define EEPROM_IBSS_CHANNELS_BG (GET_EEPROM_ADDR(0x28,LSB)) /* 2 bytes */ -#define EEPROM_IBSS_CHANNELS_A (GET_EEPROM_ADDR(0x29,MSB)) /* 5 bytes */ -#define EEPROM_BSS_CHANNELS_BG (GET_EEPROM_ADDR(0x2c,LSB)) /* 2 bytes */ -#define EEPROM_HW_VERSION (GET_EEPROM_ADDR(0x72,LSB)) /* 2 bytes */ +#define EEPROM_PME_CAPABILITY (GET_EEPROM_ADDR(0x09,MSB)) /* 1 byte */ +#define EEPROM_MAC_ADDRESS (GET_EEPROM_ADDR(0x21,LSB)) /* 6 byte */ +#define EEPROM_VERSION (GET_EEPROM_ADDR(0x24,MSB)) /* 1 byte */ +#define EEPROM_NIC_TYPE (GET_EEPROM_ADDR(0x25,LSB)) /* 1 byte */ +#define EEPROM_SKU_CAPABILITY (GET_EEPROM_ADDR(0x25,MSB)) /* 1 byte */ +#define EEPROM_COUNTRY_CODE (GET_EEPROM_ADDR(0x26,LSB)) /* 3 bytes */ +#define EEPROM_IBSS_CHANNELS_BG (GET_EEPROM_ADDR(0x28,LSB)) /* 2 bytes */ +#define EEPROM_IBSS_CHANNELS_A (GET_EEPROM_ADDR(0x29,MSB)) /* 5 bytes */ +#define EEPROM_BSS_CHANNELS_BG (GET_EEPROM_ADDR(0x2c,LSB)) /* 2 bytes */ +#define EEPROM_HW_VERSION (GET_EEPROM_ADDR(0x72,LSB)) /* 2 bytes */ /* NIC type as found in the one byte EEPROM_NIC_TYPE offset*/ #define EEPROM_NIC_TYPE_STANDARD 0 @@ -1479,7 +1428,6 @@ enum { #define IPW_RATE_CAPABILITIES 1 #define IPW_RATE_CONNECT 0 - /* * Rate values and masks */ @@ -1524,12 +1472,6 @@ enum { IPW_ORD_STAT_TX_DIR_DATA_B_11, /* Hole */ - - - - - - IPW_ORD_STAT_TX_DIR_DATA_G_1 = IPW_ORD_TABLE_0_MASK + 19, IPW_ORD_STAT_TX_DIR_DATA_G_2, IPW_ORD_STAT_TX_DIR_DATA_G_5_5, @@ -1549,12 +1491,6 @@ enum { IPW_ORD_STAT_TX_NON_DIR_DATA_B_11, /* Hole */ - - - - - - IPW_ORD_STAT_TX_NON_DIR_DATA_G_1 = IPW_ORD_TABLE_0_MASK + 44, IPW_ORD_STAT_TX_NON_DIR_DATA_G_2, IPW_ORD_STAT_TX_NON_DIR_DATA_G_5_5, @@ -1685,7 +1621,7 @@ struct host_cmd { #define CFG_BT_COEXISTENCE_WME_OVER_BT 0x08 #define CFG_BT_COEXISTENCE_OOB 0x10 #define CFG_BT_COEXISTENCE_MAX 0xFF -#define CFG_BT_COEXISTENCE_DEF 0x80 /* read Bt from EEPROM*/ +#define CFG_BT_COEXISTENCE_DEF 0x80 /* read Bt from EEPROM */ #define CFG_CTS_TO_ITSELF_ENABLED_MIN 0x0 #define CFG_CTS_TO_ITSELF_ENABLED_MAX 0x1 @@ -1727,11 +1663,11 @@ static inline u32 frame_hdr_len(struct ieee80211_hdr *hdr) fc = le16_to_cpu(hdr->frame_ctl); /* - * Function ToDS FromDS - * IBSS 0 0 - * To AP 1 0 - * From AP 0 1 - * WDS (bridge) 1 1 + * Function ToDS FromDS + * IBSS 0 0 + * To AP 1 0 + * From AP 0 1 + * WDS (bridge) 1 1 * * Only WDS frames use Address4 among them. --YZ */ @@ -1741,4 +1677,4 @@ static inline u32 frame_hdr_len(struct ieee80211_hdr *hdr) return retval; } -#endif /* __ipw2200_h__ */ +#endif /* __ipw2200_h__ */ diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index 5f507c49907..ca6c03c8992 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c @@ -471,12 +471,12 @@ static dev_link_t *netwave_attach(void) dev->get_stats = &netwave_get_stats; dev->set_multicast_list = &set_multicast_list; /* wireless extensions */ -#ifdef WIRELESS_EXT +#if WIRELESS_EXT <= 16 dev->get_wireless_stats = &netwave_get_wireless_stats; +#endif /* WIRELESS_EXT <= 16 */ #if WIRELESS_EXT > 12 dev->wireless_handlers = (struct iw_handler_def *)&netwave_handler_def; #endif /* WIRELESS_EXT > 12 */ -#endif /* WIRELESS_EXT */ dev->do_ioctl = &netwave_ioctl; dev->tx_timeout = &netwave_watchdog; @@ -839,6 +839,9 @@ static const struct iw_handler_def netwave_handler_def = .standard = (iw_handler *) netwave_handler, .private = (iw_handler *) netwave_private_handler, .private_args = (struct iw_priv_args *) netwave_private_args, +#if WIRELESS_EXT > 16 + .get_wireless_stats = netwave_get_wireless_stats, +#endif /* WIRELESS_EXT > 16 */ }; #endif /* WIRELESS_EXT > 12 */ diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index 0f29a9c7bc2..9a8790e3580 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c @@ -2727,6 +2727,9 @@ const struct iw_handler_def prism54_handler_def = { .standard = (iw_handler *) prism54_handler, .private = (iw_handler *) prism54_private_handler, .private_args = (struct iw_priv_args *) prism54_private_args, +#if WIRELESS_EXT > 16 + .get_wireless_stats = prism54_get_wireless_stats, +#endif /* WIRELESS_EXT > 16 */ #if WIRELESS_EXT == 16 .spy_offset = offsetof(islpci_private, spy_data), #endif /* WIRELESS_EXT == 16 */ diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c index efab07e9e24..6f13d4a8e2d 100644 --- a/drivers/net/wireless/prism54/islpci_dev.c +++ b/drivers/net/wireless/prism54/islpci_dev.c @@ -815,7 +815,6 @@ islpci_setup(struct pci_dev *pdev) ndev->open = &islpci_open; ndev->stop = &islpci_close; ndev->get_stats = &islpci_statistics; - ndev->get_wireless_stats = &prism54_get_wireless_stats; ndev->do_ioctl = &prism54_ioctl; ndev->wireless_handlers = (struct iw_handler_def *) &prism54_handler_def; @@ -844,6 +843,8 @@ islpci_setup(struct pci_dev *pdev) /* Add pointers to enable iwspy support. */ priv->wireless_data.spy_data = &priv->spy_data; ndev->wireless_data = &priv->wireless_data; +#else /* WIRELESS_EXT > 16 */ + ndev->get_wireless_stats = &prism54_get_wireless_stats; #endif /* WIRELESS_EXT > 16 */ /* save the start and end address of the PCI memory area */ diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 0e0ba614259..e9c5ea0f553 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -53,6 +53,7 @@ #include <pcmcia/ds.h> #include <pcmcia/mem_op.h> +#include <net/ieee80211.h> #include <linux/wireless.h> #include <asm/io.h> @@ -64,7 +65,6 @@ #define WIRELESS_SPY /* Enable spying addresses */ /* Definitions we need for spy */ typedef struct iw_statistics iw_stats; -typedef struct iw_quality iw_qual; typedef u_char mac_addr[ETH_ALEN]; /* Hardware address */ #include "rayctl.h" @@ -101,7 +101,6 @@ static int ray_dev_close(struct net_device *dev); static int ray_dev_config(struct net_device *dev, struct ifmap *map); static struct net_device_stats *ray_get_stats(struct net_device *dev); static int ray_dev_init(struct net_device *dev); -static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); static struct ethtool_ops netdev_ethtool_ops; @@ -114,9 +113,8 @@ static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx, static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx, UCHAR msg_type, unsigned char *data); static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len); -#if WIRELESS_EXT > 7 /* If wireless extension exist in the kernel */ static iw_stats * ray_get_wireless_stats(struct net_device * dev); -#endif /* WIRELESS_EXT > 7 */ +static const struct iw_handler_def ray_handler_def; /***** Prototypes for raylink functions **************************************/ static int asc_to_int(char a); @@ -373,11 +371,12 @@ static dev_link_t *ray_attach(void) dev->hard_start_xmit = &ray_dev_start_xmit; dev->set_config = &ray_dev_config; dev->get_stats = &ray_get_stats; - dev->do_ioctl = &ray_dev_ioctl; SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); -#if WIRELESS_EXT > 7 /* If wireless extension exist in the kernel */ - dev->get_wireless_stats = ray_get_wireless_stats; -#endif + dev->wireless_handlers = &ray_handler_def; +#ifdef WIRELESS_SPY + local->wireless_data.spy_data = &local->spy_data; + dev->wireless_data = &local->wireless_data; +#endif /* WIRELESS_SPY */ dev->set_multicast_list = &set_multicast_list; @@ -1201,436 +1200,420 @@ static struct ethtool_ops netdev_ethtool_ops = { /*====================================================================*/ -static int ray_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : get protocol name + */ +static int ray_get_name(struct net_device *dev, + struct iw_request_info *info, + char *cwrq, + char *extra) { - ray_dev_t *local = (ray_dev_t *)dev->priv; - dev_link_t *link = local->finder; - int err = 0; -#if WIRELESS_EXT > 7 - struct iwreq *wrq = (struct iwreq *) ifr; -#endif /* WIRELESS_EXT > 7 */ -#ifdef WIRELESS_SPY - struct sockaddr address[IW_MAX_SPY]; -#endif /* WIRELESS_SPY */ + strcpy(cwrq, "IEEE 802.11-FH"); + return 0; +} - if (!(link->state & DEV_PRESENT)) { - DEBUG(2,"ray_dev_ioctl - device not present\n"); - return -1; - } - DEBUG(2,"ray_cs IOCTL dev=%p, ifr=%p, cmd = 0x%x\n",dev,ifr,cmd); - /* Validate the command */ - switch (cmd) - { -#if WIRELESS_EXT > 7 - /* --------------- WIRELESS EXTENSIONS --------------- */ - /* Get name */ - case SIOCGIWNAME: - strcpy(wrq->u.name, "IEEE 802.11-FH"); - break; - - /* Get frequency/channel */ - case SIOCGIWFREQ: - wrq->u.freq.m = local->sparm.b5.a_hop_pattern; - wrq->u.freq.e = 0; - break; - - /* Set frequency/channel */ - case SIOCSIWFREQ: - /* Reject if card is already initialised */ - if(local->card_status != CARD_AWAITING_PARAM) - { - err = -EBUSY; - break; - } +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : set frequency + */ +static int ray_set_freq(struct net_device *dev, + struct iw_request_info *info, + struct iw_freq *fwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + int err = -EINPROGRESS; /* Call commit handler */ - /* Setting by channel number */ - if ((wrq->u.freq.m > USA_HOP_MOD) || (wrq->u.freq.e > 0)) - err = -EOPNOTSUPP; - else - local->sparm.b5.a_hop_pattern = wrq->u.freq.m; - break; + /* Reject if card is already initialised */ + if(local->card_status != CARD_AWAITING_PARAM) + return -EBUSY; - /* Get current network name (ESSID) */ - case SIOCGIWESSID: - if (wrq->u.data.pointer) - { - char essid[IW_ESSID_MAX_SIZE + 1]; - /* Get the essid that was set */ - memcpy(essid, local->sparm.b5.a_current_ess_id, - IW_ESSID_MAX_SIZE); - essid[IW_ESSID_MAX_SIZE] = '\0'; - - /* Push it out ! */ - wrq->u.data.length = strlen(essid) + 1; - wrq->u.data.flags = 1; /* active */ - if (copy_to_user(wrq->u.data.pointer, essid, sizeof(essid))) - err = -EFAULT; - } - break; + /* Setting by channel number */ + if ((fwrq->m > USA_HOP_MOD) || (fwrq->e > 0)) + err = -EOPNOTSUPP; + else + local->sparm.b5.a_hop_pattern = fwrq->m; - /* Set desired network name (ESSID) */ - case SIOCSIWESSID: - /* Reject if card is already initialised */ - if(local->card_status != CARD_AWAITING_PARAM) - { - err = -EBUSY; - break; - } + return err; +} + +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : get frequency + */ +static int ray_get_freq(struct net_device *dev, + struct iw_request_info *info, + struct iw_freq *fwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; - if (wrq->u.data.pointer) - { - char card_essid[IW_ESSID_MAX_SIZE + 1]; - - /* Check if we asked for `any' */ - if(wrq->u.data.flags == 0) - { + fwrq->m = local->sparm.b5.a_hop_pattern; + fwrq->e = 0; + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : set ESSID + */ +static int ray_set_essid(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + + /* Reject if card is already initialised */ + if(local->card_status != CARD_AWAITING_PARAM) + return -EBUSY; + + /* Check if we asked for `any' */ + if(dwrq->flags == 0) { /* Corey : can you do that ? */ - err = -EOPNOTSUPP; - } - else - { + return -EOPNOTSUPP; + } else { /* Check the size of the string */ - if(wrq->u.data.length > - IW_ESSID_MAX_SIZE + 1) - { - err = -E2BIG; - break; - } - if (copy_from_user(card_essid, - wrq->u.data.pointer, - wrq->u.data.length)) { - err = -EFAULT; - break; + if(dwrq->length > IW_ESSID_MAX_SIZE + 1) { + return -E2BIG; } - card_essid[IW_ESSID_MAX_SIZE] = '\0'; /* Set the ESSID in the card */ - memcpy(local->sparm.b5.a_current_ess_id, card_essid, - IW_ESSID_MAX_SIZE); - } + memset(local->sparm.b5.a_current_ess_id, 0, IW_ESSID_MAX_SIZE); + memcpy(local->sparm.b5.a_current_ess_id, extra, dwrq->length); } - break; - - /* Get current Access Point (BSSID in our case) */ - case SIOCGIWAP: - memcpy(wrq->u.ap_addr.sa_data, local->bss_id, ETH_ALEN); - wrq->u.ap_addr.sa_family = ARPHRD_ETHER; - break; - - /* Get the current bit-rate */ - case SIOCGIWRATE: - if(local->net_default_tx_rate == 3) - wrq->u.bitrate.value = 2000000; /* Hum... */ - else - wrq->u.bitrate.value = local->net_default_tx_rate * 500000; - wrq->u.bitrate.fixed = 0; /* We are in auto mode */ - break; - - /* Set the desired bit-rate */ - case SIOCSIWRATE: - /* Check if rate is in range */ - if((wrq->u.bitrate.value != 1000000) && - (wrq->u.bitrate.value != 2000000)) - { - err = -EINVAL; - break; - } - /* Hack for 1.5 Mb/s instead of 2 Mb/s */ - if((local->fw_ver == 0x55) && /* Please check */ - (wrq->u.bitrate.value == 2000000)) - local->net_default_tx_rate = 3; - else - local->net_default_tx_rate = wrq->u.bitrate.value/500000; - break; - - /* Get the current RTS threshold */ - case SIOCGIWRTS: - wrq->u.rts.value = (local->sparm.b5.a_rts_threshold[0] << 8) - + local->sparm.b5.a_rts_threshold[1]; -#if WIRELESS_EXT > 8 - wrq->u.rts.disabled = (wrq->u.rts.value == 32767); -#endif /* WIRELESS_EXT > 8 */ - wrq->u.rts.fixed = 1; - break; - - /* Set the desired RTS threshold */ - case SIOCSIWRTS: - { - int rthr = wrq->u.rts.value; - /* Reject if card is already initialised */ - if(local->card_status != CARD_AWAITING_PARAM) - { - err = -EBUSY; - break; - } + return -EINPROGRESS; /* Call commit handler */ +} - /* if(wrq->u.rts.fixed == 0) we should complain */ -#if WIRELESS_EXT > 8 - if(wrq->u.rts.disabled) - rthr = 32767; +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : get ESSID + */ +static int ray_get_essid(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + + /* Get the essid that was set */ + memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE); + extra[IW_ESSID_MAX_SIZE] = '\0'; + + /* Push it out ! */ + dwrq->length = strlen(extra) + 1; + dwrq->flags = 1; /* active */ + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : get AP address + */ +static int ray_get_wap(struct net_device *dev, + struct iw_request_info *info, + struct sockaddr *awrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + + memcpy(awrq->sa_data, local->bss_id, ETH_ALEN); + awrq->sa_family = ARPHRD_ETHER; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : set Bit-Rate + */ +static int ray_set_rate(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + + /* Reject if card is already initialised */ + if(local->card_status != CARD_AWAITING_PARAM) + return -EBUSY; + + /* Check if rate is in range */ + if((vwrq->value != 1000000) && (vwrq->value != 2000000)) + return -EINVAL; + + /* Hack for 1.5 Mb/s instead of 2 Mb/s */ + if((local->fw_ver == 0x55) && /* Please check */ + (vwrq->value == 2000000)) + local->net_default_tx_rate = 3; else -#endif /* WIRELESS_EXT > 8 */ - if((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */ - { - err = -EINVAL; - break; - } + local->net_default_tx_rate = vwrq->value/500000; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : get Bit-Rate + */ +static int ray_get_rate(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + + if(local->net_default_tx_rate == 3) + vwrq->value = 2000000; /* Hum... */ + else + vwrq->value = local->net_default_tx_rate * 500000; + vwrq->fixed = 0; /* We are in auto mode */ + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : set RTS threshold + */ +static int ray_set_rts(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + int rthr = vwrq->value; + + /* Reject if card is already initialised */ + if(local->card_status != CARD_AWAITING_PARAM) + return -EBUSY; + + /* if(wrq->u.rts.fixed == 0) we should complain */ + if(vwrq->disabled) + rthr = 32767; + else { + if((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */ + return -EINVAL; + } local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF; local->sparm.b5.a_rts_threshold[1] = rthr & 0xFF; - } - break; - /* Get the current fragmentation threshold */ - case SIOCGIWFRAG: - wrq->u.frag.value = (local->sparm.b5.a_frag_threshold[0] << 8) - + local->sparm.b5.a_frag_threshold[1]; -#if WIRELESS_EXT > 8 - wrq->u.frag.disabled = (wrq->u.frag.value == 32767); -#endif /* WIRELESS_EXT > 8 */ - wrq->u.frag.fixed = 1; - break; + return -EINPROGRESS; /* Call commit handler */ +} - /* Set the desired fragmentation threshold */ - case SIOCSIWFRAG: - { - int fthr = wrq->u.frag.value; - /* Reject if card is already initialised */ - if(local->card_status != CARD_AWAITING_PARAM) - { - err = -EBUSY; - break; - } +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : get RTS threshold + */ +static int ray_get_rts(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + + vwrq->value = (local->sparm.b5.a_rts_threshold[0] << 8) + + local->sparm.b5.a_rts_threshold[1]; + vwrq->disabled = (vwrq->value == 32767); + vwrq->fixed = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : set Fragmentation threshold + */ +static int ray_set_frag(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + int fthr = vwrq->value; + + /* Reject if card is already initialised */ + if(local->card_status != CARD_AWAITING_PARAM) + return -EBUSY; /* if(wrq->u.frag.fixed == 0) should complain */ -#if WIRELESS_EXT > 8 - if(wrq->u.frag.disabled) - fthr = 32767; - else -#endif /* WIRELESS_EXT > 8 */ - if((fthr < 256) || (fthr > 2347)) /* To check out ! */ - { - err = -EINVAL; - break; - } + if(vwrq->disabled) + fthr = 32767; + else { + if((fthr < 256) || (fthr > 2347)) /* To check out ! */ + return -EINVAL; + } local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF; local->sparm.b5.a_frag_threshold[1] = fthr & 0xFF; - } - break; -#endif /* WIRELESS_EXT > 7 */ -#if WIRELESS_EXT > 8 + return -EINPROGRESS; /* Call commit handler */ +} - /* Get the current mode of operation */ - case SIOCGIWMODE: - if(local->sparm.b5.a_network_type) - wrq->u.mode = IW_MODE_INFRA; - else - wrq->u.mode = IW_MODE_ADHOC; - break; +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : get Fragmentation threshold + */ +static int ray_get_frag(struct net_device *dev, + struct iw_request_info *info, + struct iw_param *vwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; - /* Set the current mode of operation */ - case SIOCSIWMODE: - { + vwrq->value = (local->sparm.b5.a_frag_threshold[0] << 8) + + local->sparm.b5.a_frag_threshold[1]; + vwrq->disabled = (vwrq->value == 32767); + vwrq->fixed = 1; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : set Mode of Operation + */ +static int ray_set_mode(struct net_device *dev, + struct iw_request_info *info, + __u32 *uwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; + int err = -EINPROGRESS; /* Call commit handler */ char card_mode = 1; - - /* Reject if card is already initialised */ - if(local->card_status != CARD_AWAITING_PARAM) - { - err = -EBUSY; - break; - } - switch (wrq->u.mode) + /* Reject if card is already initialised */ + if(local->card_status != CARD_AWAITING_PARAM) + return -EBUSY; + + switch (*uwrq) { case IW_MODE_ADHOC: - card_mode = 0; - // Fall through + card_mode = 0; + // Fall through case IW_MODE_INFRA: - local->sparm.b5.a_network_type = card_mode; - break; + local->sparm.b5.a_network_type = card_mode; + break; default: - err = -EINVAL; + err = -EINVAL; } - } - break; -#endif /* WIRELESS_EXT > 8 */ -#if WIRELESS_EXT > 7 - /* ------------------ IWSPY SUPPORT ------------------ */ - /* Define the range (variations) of above parameters */ - case SIOCGIWRANGE: - /* Basic checking... */ - if(wrq->u.data.pointer != (caddr_t) 0) - { - struct iw_range range; - memset((char *) &range, 0, sizeof(struct iw_range)); - - /* Set the length (very important for backward compatibility) */ - wrq->u.data.length = sizeof(struct iw_range); - -#if WIRELESS_EXT > 10 - /* Set the Wireless Extension versions */ - range.we_version_compiled = WIRELESS_EXT; - range.we_version_source = 9; -#endif /* WIRELESS_EXT > 10 */ - - /* Set information in the range struct */ - range.throughput = 1.1 * 1000 * 1000; /* Put the right number here */ - range.num_channels = hop_pattern_length[(int)country]; - range.num_frequency = 0; - range.max_qual.qual = 0; - range.max_qual.level = 255; /* What's the correct value ? */ - range.max_qual.noise = 255; /* Idem */ - range.num_bitrates = 2; - range.bitrate[0] = 1000000; /* 1 Mb/s */ - range.bitrate[1] = 2000000; /* 2 Mb/s */ - - /* Copy structure to the user buffer */ - if(copy_to_user(wrq->u.data.pointer, &range, - sizeof(struct iw_range))) - err = -EFAULT; - } - break; + return err; +} -#ifdef WIRELESS_SPY - /* Set addresses to spy */ - case SIOCSIWSPY: - /* Check the number of addresses */ - if(wrq->u.data.length > IW_MAX_SPY) - { - err = -E2BIG; - break; - } - local->spy_number = wrq->u.data.length; +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : get Mode of Operation + */ +static int ray_get_mode(struct net_device *dev, + struct iw_request_info *info, + __u32 *uwrq, + char *extra) +{ + ray_dev_t *local = (ray_dev_t *)dev->priv; - /* If there is some addresses to copy */ - if(local->spy_number > 0) - { - int i; - - /* Copy addresses to the driver */ - if(copy_from_user(address, wrq->u.data.pointer, - sizeof(struct sockaddr) * local->spy_number)) - { - err = -EFAULT; - break; - } - - /* Copy addresses to the lp structure */ - for(i = 0; i < local->spy_number; i++) - memcpy(local->spy_address[i], address[i].sa_data, ETH_ALEN); - - /* Reset structure... */ - memset(local->spy_stat, 0x00, sizeof(iw_qual) * IW_MAX_SPY); - -#ifdef DEBUG_IOCTL_INFO - printk(KERN_DEBUG "SetSpy - Set of new addresses is :\n"); - for(i = 0; i < local->spy_number; i++) - printk(KERN_DEBUG "%02X:%02X:%02X:%02X:%02X:%02X\n", - local->spy_address[i][0], - local->spy_address[i][1], - local->spy_address[i][2], - local->spy_address[i][3], - local->spy_address[i][4], - local->spy_address[i][5]); -#endif /* DEBUG_IOCTL_INFO */ - } - break; + if(local->sparm.b5.a_network_type) + *uwrq = IW_MODE_INFRA; + else + *uwrq = IW_MODE_ADHOC; - /* Get the spy list and spy stats */ - case SIOCGIWSPY: - /* Set the number of addresses */ - wrq->u.data.length = local->spy_number; + return 0; +} - /* If the user want to have the addresses back... */ - if((local->spy_number > 0) && (wrq->u.data.pointer != (caddr_t) 0)) - { - int i; - - /* Copy addresses from the lp structure */ - for(i = 0; i < local->spy_number; i++) - { - memcpy(address[i].sa_data, local->spy_address[i], ETH_ALEN); - address[i].sa_family = ARPHRD_ETHER; - } - - /* Copy addresses to the user buffer */ - if(copy_to_user(wrq->u.data.pointer, address, - sizeof(struct sockaddr) * local->spy_number)) - { - err = -EFAULT; - break; - } - - /* Copy stats to the user buffer (just after) */ - if(copy_to_user(wrq->u.data.pointer + - (sizeof(struct sockaddr) * local->spy_number), - local->spy_stat, sizeof(iw_qual) * local->spy_number)) - { - err = -EFAULT; - break; - } - - /* Reset updated flags */ - for(i = 0; i < local->spy_number; i++) - local->spy_stat[i].updated = 0x0; - } /* if(pointer != NULL) */ - - break; -#endif /* WIRELESS_SPY */ +/*------------------------------------------------------------------*/ +/* + * Wireless Handler : get range info + */ +static int ray_get_range(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *dwrq, + char *extra) +{ + struct iw_range *range = (struct iw_range *) extra; + + memset((char *) range, 0, sizeof(struct iw_range)); + + /* Set the length (very important for backward compatibility) */ + dwrq->length = sizeof(struct iw_range); + + /* Set the Wireless Extension versions */ + range->we_version_compiled = WIRELESS_EXT; + range->we_version_source = 9; + + /* Set information in the range struct */ + range->throughput = 1.1 * 1000 * 1000; /* Put the right number here */ + range->num_channels = hop_pattern_length[(int)country]; + range->num_frequency = 0; + range->max_qual.qual = 0; + range->max_qual.level = 255; /* What's the correct value ? */ + range->max_qual.noise = 255; /* Idem */ + range->num_bitrates = 2; + range->bitrate[0] = 1000000; /* 1 Mb/s */ + range->bitrate[1] = 2000000; /* 2 Mb/s */ + return 0; +} - /* ------------------ PRIVATE IOCTL ------------------ */ -#ifndef SIOCIWFIRSTPRIV -#define SIOCIWFIRSTPRIV SIOCDEVPRIVATE -#endif /* SIOCIWFIRSTPRIV */ -#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */ -#define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1 /* Get framing mode */ -#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */ - case SIOCSIPFRAMING: - if(!capable(CAP_NET_ADMIN)) /* For private IOCTLs, we need to check permissions */ - { - err = -EPERM; - break; - } - translate = *(wrq->u.name); /* Set framing mode */ - break; - case SIOCGIPFRAMING: - *(wrq->u.name) = translate; - break; - case SIOCGIPCOUNTRY: - *(wrq->u.name) = country; - break; - case SIOCGIWPRIV: - /* Export our "private" intercace */ - if(wrq->u.data.pointer != (caddr_t) 0) - { - struct iw_priv_args priv[] = - { /* cmd, set_args, get_args, name */ - { SIOCSIPFRAMING, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "set_framing" }, - { SIOCGIPFRAMING, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_framing" }, - { SIOCGIPCOUNTRY, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_country" }, - }; - /* Set the number of ioctl available */ - wrq->u.data.length = 3; - /* Copy structure to the user buffer */ - if(copy_to_user(wrq->u.data.pointer, (u_char *) priv, - sizeof(priv))) - err = -EFAULT; - } - break; -#endif /* WIRELESS_EXT > 7 */ +/*------------------------------------------------------------------*/ +/* + * Wireless Private Handler : set framing mode + */ +static int ray_set_framing(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, + char *extra) +{ + translate = *(extra); /* Set framing mode */ + return 0; +} - default: - DEBUG(0,"ray_dev_ioctl cmd = 0x%x\n", cmd); - err = -EOPNOTSUPP; - } - return err; -} /* end ray_dev_ioctl */ -/*===========================================================================*/ -#if WIRELESS_EXT > 7 /* If wireless extension exist in the kernel */ +/*------------------------------------------------------------------*/ +/* + * Wireless Private Handler : get framing mode + */ +static int ray_get_framing(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, + char *extra) +{ + *(extra) = translate; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Wireless Private Handler : get country + */ +static int ray_get_country(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, + char *extra) +{ + *(extra) = country; + + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Commit handler : called after a bunch of SET operations + */ +static int ray_commit(struct net_device *dev, + struct iw_request_info *info, /* NULL */ + void *zwrq, /* NULL */ + char *extra) /* NULL */ +{ + return 0; +} + +/*------------------------------------------------------------------*/ +/* + * Stats handler : return Wireless Stats + */ static iw_stats * ray_get_wireless_stats(struct net_device * dev) { ray_dev_t * local = (ray_dev_t *) dev->priv; @@ -1642,13 +1625,13 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev) local->wstats.status = local->card_status; #ifdef WIRELESS_SPY - if((local->spy_number > 0) && (local->sparm.b5.a_network_type == 0)) + if((local->spy_data.spy_number > 0) && (local->sparm.b5.a_network_type == 0)) { /* Get it from the first node in spy list */ - local->wstats.qual.qual = local->spy_stat[0].qual; - local->wstats.qual.level = local->spy_stat[0].level; - local->wstats.qual.noise = local->spy_stat[0].noise; - local->wstats.qual.updated = local->spy_stat[0].updated; + local->wstats.qual.qual = local->spy_data.spy_stat[0].qual; + local->wstats.qual.level = local->spy_data.spy_stat[0].level; + local->wstats.qual.noise = local->spy_data.spy_stat[0].noise; + local->wstats.qual.updated = local->spy_data.spy_stat[0].updated; } #endif /* WIRELESS_SPY */ @@ -1659,7 +1642,65 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev) return &local->wstats; } /* end ray_get_wireless_stats */ -#endif /* WIRELESS_EXT > 7 */ + +/*------------------------------------------------------------------*/ +/* + * Structures to export the Wireless Handlers + */ + +static const iw_handler ray_handler[] = { + [SIOCSIWCOMMIT-SIOCIWFIRST] (iw_handler) ray_commit, + [SIOCGIWNAME -SIOCIWFIRST] (iw_handler) ray_get_name, + [SIOCSIWFREQ -SIOCIWFIRST] (iw_handler) ray_set_freq, + [SIOCGIWFREQ -SIOCIWFIRST] (iw_handler) ray_get_freq, + [SIOCSIWMODE -SIOCIWFIRST] (iw_handler) ray_set_mode, + [SIOCGIWMODE -SIOCIWFIRST] (iw_handler) ray_get_mode, + [SIOCGIWRANGE -SIOCIWFIRST] (iw_handler) ray_get_range, +#ifdef WIRELESS_SPY + [SIOCSIWSPY -SIOCIWFIRST] (iw_handler) iw_handler_set_spy, + [SIOCGIWSPY -SIOCIWFIRST] (iw_handler) iw_handler_get_spy, + [SIOCSIWTHRSPY-SIOCIWFIRST] (iw_handler) iw_handler_set_thrspy, + [SIOCGIWTHRSPY-SIOCIWFIRST] (iw_handler) iw_handler_get_thrspy, +#endif /* WIRELESS_SPY */ + [SIOCGIWAP -SIOCIWFIRST] (iw_handler) ray_get_wap, + [SIOCSIWESSID -SIOCIWFIRST] (iw_handler) ray_set_essid, + [SIOCGIWESSID -SIOCIWFIRST] (iw_handler) ray_get_essid, + [SIOCSIWRATE -SIOCIWFIRST] (iw_handler) ray_set_rate, + [SIOCGIWRATE -SIOCIWFIRST] (iw_handler) ray_get_rate, + [SIOCSIWRTS -SIOCIWFIRST] (iw_handler) ray_set_rts, + [SIOCGIWRTS -SIOCIWFIRST] (iw_handler) ray_get_rts, + [SIOCSIWFRAG -SIOCIWFIRST] (iw_handler) ray_set_frag, + [SIOCGIWFRAG -SIOCIWFIRST] (iw_handler) ray_get_frag, +}; + +#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */ +#define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1 /* Get framing mode */ +#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */ + +static const iw_handler ray_private_handler[] = { + [0] (iw_handler) ray_set_framing, + [1] (iw_handler) ray_get_framing, + [3] (iw_handler) ray_get_country, +}; + +static const struct iw_priv_args ray_private_args[] = { +/* cmd, set_args, get_args, name */ +{ SIOCSIPFRAMING, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "set_framing" }, +{ SIOCGIPFRAMING, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_framing" }, +{ SIOCGIPCOUNTRY, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_country" }, +}; + +static const struct iw_handler_def ray_handler_def = +{ + .num_standard = sizeof(ray_handler)/sizeof(iw_handler), + .num_private = sizeof(ray_private_handler)/sizeof(iw_handler), + .num_private_args = sizeof(ray_private_args)/sizeof(struct iw_priv_args), + .standard = ray_handler, + .private = ray_private_handler, + .private_args = ray_private_args, + .get_wireless_stats = ray_get_wireless_stats, +}; + /*===========================================================================*/ static int ray_open(struct net_device *dev) { @@ -2392,20 +2433,15 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned i /*local->wstats.qual.noise = none ? */ local->wstats.qual.updated = 0x2; } - /* Now, for the addresses in the spy list */ + /* Now, update the spy stuff */ { - int i; - /* Look all addresses */ - for(i = 0; i < local->spy_number; i++) - /* If match */ - if(!memcmp(linksrcaddr, local->spy_address[i], ETH_ALEN)) - { - /* Update statistics */ - /*local->spy_stat[i].qual = none ? */ - local->spy_stat[i].level = siglev; - /*local->spy_stat[i].noise = none ? */ - local->spy_stat[i].updated = 0x2; - } + struct iw_quality wstats; + wstats.level = siglev; + /* wstats.noise = none ? */ + /* wstats.qual = none ? */ + wstats.updated = 0x2; + /* Update spy records */ + wireless_spy_update(dev, linksrcaddr, &wstats); } #endif /* WIRELESS_SPY */ } /* end rx_data */ diff --git a/drivers/net/wireless/ray_cs.h b/drivers/net/wireless/ray_cs.h index c77afa14fa8..42660fe64bf 100644 --- a/drivers/net/wireless/ray_cs.h +++ b/drivers/net/wireless/ray_cs.h @@ -63,13 +63,10 @@ typedef struct ray_dev_t { UCHAR last_rsl; int beacon_rxed; struct beacon_rx last_bcn; -#ifdef WIRELESS_EXT iw_stats wstats; /* Wireless specific stats */ -#endif #ifdef WIRELESS_SPY - int spy_number; /* Number of addresses to spy */ - mac_addr spy_address[IW_MAX_SPY + 1]; /* The addresses to spy */ - iw_qual spy_stat[IW_MAX_SPY + 1]; /* Statistics gathered */ + struct iw_spy_data spy_data; + struct iw_public_data wireless_data; #endif /* WIRELESS_SPY */ } ray_dev_t; diff --git a/drivers/net/wireless/wl3501.h b/drivers/net/wireless/wl3501.h index b5719437e98..7fcbe589c3f 100644 --- a/drivers/net/wireless/wl3501.h +++ b/drivers/net/wireless/wl3501.h @@ -609,6 +609,7 @@ struct wl3501_card { struct net_device_stats stats; struct iw_statistics wstats; struct iw_spy_data spy_data; + struct iw_public_data wireless_data; struct dev_node_t node; }; #endif diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 7cc5edbf6ed..3f8c27f0871 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -1944,7 +1944,7 @@ static const iw_handler wl3501_handler[] = { static const struct iw_handler_def wl3501_handler_def = { .num_standard = sizeof(wl3501_handler) / sizeof(iw_handler), .standard = (iw_handler *)wl3501_handler, - .spy_offset = offsetof(struct wl3501_card, spy_data), + .get_wireless_stats = wl3501_get_wireless_stats, }; /** @@ -1961,6 +1961,7 @@ static dev_link_t *wl3501_attach(void) client_reg_t client_reg; dev_link_t *link; struct net_device *dev; + struct wl3501_card *this; int ret; /* Initialize the dev_link_t structure */ @@ -1995,7 +1996,9 @@ static dev_link_t *wl3501_attach(void) dev->tx_timeout = wl3501_tx_timeout; dev->watchdog_timeo = 5 * HZ; dev->get_stats = wl3501_get_stats; - dev->get_wireless_stats = wl3501_get_wireless_stats; + this = dev->priv; + this->wireless_data.spy_data = &this->spy_data; + dev->wireless_data = &this->wireless_data; dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def; SET_ETHTOOL_OPS(dev, &ops); netif_stop_queue(dev); |