patch-2.3.45 linux/drivers/net/wan/sbni.c
Next file: linux/drivers/net/wan/sbni.h
Previous file: linux/drivers/net/wan/lapbether.c
Back to the patch index
Back to the overall index
- Lines: 230
- Date:
Sat Feb 12 15:45:05 2000
- Orig file:
v2.3.44/linux/drivers/net/wan/sbni.c
- Orig date:
Fri Oct 15 15:25:13 1999
diff -u --recursive --new-file v2.3.44/linux/drivers/net/wan/sbni.c linux/drivers/net/wan/sbni.c
@@ -59,11 +59,6 @@
#include <linux/version.h>
-#if LINUX_VERSION_CODE >=0x020200
-#define v22
-#endif
-
-
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
@@ -74,6 +69,7 @@
#include <linux/malloc.h>
#include <linux/string.h>
#include <linux/errno.h>
+#include <linux/spinlock.h>
#include <asm/io.h>
#include <asm/types.h>
@@ -88,12 +84,8 @@
#include <net/arp.h>
-
-
-#ifdef v22
#include <asm/uaccess.h>
#include <linux/init.h>
-#endif
#include "sbni.h"
@@ -523,6 +515,7 @@
dev->hard_header_cache = sbni_header_cache;
dev->header_cache_update = sbni_header_cache_update;
+ spin_lock_init(&lp->lock);
lp->m=dev;
lp->me=dev;
lp->next_lp=NULL;
@@ -538,15 +531,15 @@
{
struct net_local* lp = (struct net_local*)dev->priv;
struct timer_list* watchdog = &lp->watchdog;
-
+ unsigned long flags;
DP( printk("%s: sbni_open\n", dev->name); )
+ save_flags(flags);
cli();
lp->currframe = NULL;
card_start(dev);
- dev->start = 1;
/* set timer watchdog */
init_timer(watchdog);
watchdog->expires = jiffies + SBNI_TIMEOUT;
@@ -555,8 +548,9 @@
add_timer(watchdog);
DP( printk("%s: sbni timer watchdog initialized\n", dev->name); );
- sti();
-
+ restore_flags(flags);
+
+ netif_start_queue(dev);
MOD_INC_USE_COUNT;
return 0;
}
@@ -566,21 +560,18 @@
int ioaddr = dev->base_addr;
struct net_local* lp = (struct net_local*) dev->priv;
struct timer_list* watchdog = &lp->watchdog;
-
-
+ unsigned long flags;
+
DP( printk("%s: sbni_close\n", dev->name); )
+ netif_stop_queue(dev);
+
+ save_flags(flags);
cli();
-
sbni_drop_tx_queue(dev);
-
- dev->tbusy = 1;
- dev->start = 0;
-
del_timer(watchdog);
-
outb(0, ioaddr + CSR0);
- sti();
+ restore_flags(flags);
MOD_DEC_USE_COUNT;
return 0;
@@ -590,6 +581,7 @@
{
struct net_local *lp = (struct net_local*)dev->priv;
struct sbni_hard_header *hh=(struct sbni_hard_header *)skb->data;
+ unsigned long flags;
#ifdef KATYUSHA
struct net_local *nl;
@@ -602,13 +594,6 @@
if(lp->me != dev)
panic("sbni: lp->me != dev !!!\nMail to developer (xenon@granch.ru) if you noticed this error\n");
- if(dev->interrupt)
- {
- DP( printk("sbni_xmit_start: interrupt\n"); )
- /* May be unloading, don't stamp on */
- return 1; /* the packet buffer this time */
- }
-
hh->number = 1;
hh->reserv = 0;
@@ -623,6 +608,7 @@
skb->len - sizeof(struct sbni_hard_header),
hh->crc);
+ spin_lock_irqsave(&lp->lock, flags);
#ifdef KATYUSHA
/* looking for first idle device */
for (stop=0,nl=lp; nl && !stop; nl=nl->next_lp)
@@ -657,6 +643,7 @@
/* set request for transmit */
outb(inb(dev->base_addr + CSR0) | TR_REQ, dev->base_addr + CSR0);
#endif
+ spin_unlock_irqrestore(&lp->lock, flags);
return 0;
}
@@ -677,9 +664,6 @@
lp->waitack=0;
skb_queue_head_init(&lp->queue);
sbni_drop_tx_queue(dev);
- dev->tbusy = 0;
-
- dev->interrupt = 0;
/* Reset the card and set start parameters */
outb(PR_RES | *(char*)&lp->csr1, dev->base_addr + CSR1);
outb(EN_INT, dev->base_addr + CSR0);
@@ -776,8 +760,7 @@
/*
* reset output active flags
*/
- dev->tbusy = 0;
- mark_bh(NET_BH);
+ netif_wake_queue(dev);
/*} if */
}
case PACKET_RESEND:
@@ -920,17 +903,12 @@
return;
}
- if(dev->interrupt)
- {
- printk("%s: Reentering the interrupt driver!\n", dev->name);
- return;
- }
- dev->interrupt = 1;
-
csr0 = inb(dev->base_addr + CSR0);
DP( printk("%s: entering interrupt handler, CSR0 = %02x\n", dev->name, csr0); )
lp=dev->priv;
+
+ spin_lock(&lp->lock);
if(!lp->carrier)
lp->carrier=1;
@@ -971,7 +949,7 @@
*/
outb(csr0 | EN_INT, dev->base_addr + CSR0);
- dev->interrupt = 0;
+ spin_unlock(&lp->lock);
}
static struct enet_statistics *sbni_get_stats(struct net_device *dev)
@@ -1103,7 +1081,7 @@
}
sti();
outb(csr0 | RC_CHK, dev->base_addr + CSR0);
- if(dev->start)
+ if(test_bit(LINK_STATE_START, &dev->state))
{
struct timer_list* watchdog = &lp->watchdog;
init_timer(watchdog);
@@ -1167,9 +1145,8 @@
}
}
lp->waitack=0;
- dev->tbusy = 0;
-
- mark_bh(NET_BH);
+ netif_wake_queue(dev);
+
DP( printk("%s: queue dropping stoped\n",dev->name); );
}
@@ -1194,7 +1171,7 @@
/* struct net_local *lp = (struct net_local *)dev->priv; */
struct sockaddr *saddr = addr;
- if(dev->start)
+ if(test_bit(LINK_STATE_START, &dev->state))
{
/* Only possible while card isn't started */
return -EBUSY;
@@ -1400,13 +1377,11 @@
static int baud[SBNI_MAX_NUM_CARDS] = { 0 };
static long mac[SBNI_MAX_NUM_CARDS] = { 0 };
-#ifdef v22
MODULE_PARM(io, "1-" __MODULE_STRING(SBNI_MAX_NUM_CARDS) "i");
MODULE_PARM(irq, "1-" __MODULE_STRING(SBNI_MAX_NUM_CARDS) "i");
MODULE_PARM(rxl, "1-" __MODULE_STRING(SBNI_MAX_NUM_CARDS) "i");
MODULE_PARM(baud, "1-" __MODULE_STRING(SBNI_MAX_NUM_CARDS) "i");
MODULE_PARM(mac, "1-" __MODULE_STRING(SBNI_MAX_NUM_CARDS) "i");
-#endif
static int sbniautodetect = -1;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)