Commit 52e8a6a2 authored by Krzysztof Hałasa's avatar Krzysztof Hałasa

WAN: Convert Zilog-based drivers to generic HDLC

Signed-off-by: default avatarKrzysztof Hałasa <khc@pm.waw.pl>
parent aca25753
...@@ -25,7 +25,7 @@ if WAN ...@@ -25,7 +25,7 @@ if WAN
# There is no way to detect a comtrol sv11 - force it modular for now. # There is no way to detect a comtrol sv11 - force it modular for now.
config HOSTESS_SV11 config HOSTESS_SV11
tristate "Comtrol Hostess SV-11 support" tristate "Comtrol Hostess SV-11 support"
depends on ISA && m && ISA_DMA_API && INET depends on ISA && m && ISA_DMA_API && INET && HDLC
help help
Driver for Comtrol Hostess SV-11 network card which Driver for Comtrol Hostess SV-11 network card which
operates on low speed synchronous serial links at up to operates on low speed synchronous serial links at up to
...@@ -88,7 +88,7 @@ config LANMEDIA ...@@ -88,7 +88,7 @@ config LANMEDIA
# There is no way to detect a Sealevel board. Force it modular # There is no way to detect a Sealevel board. Force it modular
config SEALEVEL_4021 config SEALEVEL_4021
tristate "Sealevel Systems 4021 support" tristate "Sealevel Systems 4021 support"
depends on ISA && m && ISA_DMA_API && INET depends on ISA && m && ISA_DMA_API && INET && HDLC
help help
This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
......
...@@ -21,11 +21,11 @@ pc300-y := pc300_drv.o ...@@ -21,11 +21,11 @@ pc300-y := pc300_drv.o
pc300-$(CONFIG_PC300_MLPPP) += pc300_tty.o pc300-$(CONFIG_PC300_MLPPP) += pc300_tty.o
pc300-objs := $(pc300-y) pc300-objs := $(pc300-y)
obj-$(CONFIG_HOSTESS_SV11) += z85230.o syncppp.o hostess_sv11.o obj-$(CONFIG_HOSTESS_SV11) += z85230.o hostess_sv11.o
obj-$(CONFIG_SEALEVEL_4021) += z85230.o syncppp.o sealevel.o obj-$(CONFIG_SEALEVEL_4021) += z85230.o sealevel.o
obj-$(CONFIG_COSA) += cosa.o obj-$(CONFIG_COSA) += cosa.o
obj-$(CONFIG_FARSYNC) += farsync.o obj-$(CONFIG_FARSYNC) += farsync.o
obj-$(CONFIG_DSCC4) += dscc4.o obj-$(CONFIG_DSCC4) += dscc4.o
obj-$(CONFIG_LANMEDIA) += syncppp.o obj-$(CONFIG_LANMEDIA) += syncppp.o
obj-$(CONFIG_X25_ASY) += x25_asy.o obj-$(CONFIG_X25_ASY) += x25_asy.o
......
This diff is collapsed.
This diff is collapsed.
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/hdlc.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/init.h> #include <linux/init.h>
#include <asm/dma.h> #include <asm/dma.h>
...@@ -51,7 +52,6 @@ ...@@ -51,7 +52,6 @@
#define RT_UNLOCK #define RT_UNLOCK
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <net/syncppp.h>
#include "z85230.h" #include "z85230.h"
...@@ -440,51 +440,46 @@ static void z8530_tx(struct z8530_channel *c) ...@@ -440,51 +440,46 @@ static void z8530_tx(struct z8530_channel *c)
* A status event occurred in PIO synchronous mode. There are several * A status event occurred in PIO synchronous mode. There are several
* reasons the chip will bother us here. A transmit underrun means we * reasons the chip will bother us here. A transmit underrun means we
* failed to feed the chip fast enough and just broke a packet. A DCD * failed to feed the chip fast enough and just broke a packet. A DCD
* change is a line up or down. We communicate that back to the protocol * change is a line up or down.
* layer for synchronous PPP to renegotiate.
*/ */
static void z8530_status(struct z8530_channel *chan) static void z8530_status(struct z8530_channel *chan)
{ {
u8 status, altered; u8 status, altered;
status=read_zsreg(chan, R0); status = read_zsreg(chan, R0);
altered=chan->status^status; altered = chan->status ^ status;
chan->status=status; chan->status = status;
if(status&TxEOM) if (status & TxEOM) {
{
/* printk("%s: Tx underrun.\n", chan->dev->name); */ /* printk("%s: Tx underrun.\n", chan->dev->name); */
chan->stats.tx_fifo_errors++; chan->netdevice->stats.tx_fifo_errors++;
write_zsctrl(chan, ERR_RES); write_zsctrl(chan, ERR_RES);
z8530_tx_done(chan); z8530_tx_done(chan);
} }
if(altered&chan->dcdcheck) if (altered & chan->dcdcheck)
{ {
if(status&chan->dcdcheck) if (status & chan->dcdcheck) {
{
printk(KERN_INFO "%s: DCD raised\n", chan->dev->name); printk(KERN_INFO "%s: DCD raised\n", chan->dev->name);
write_zsreg(chan, R3, chan->regs[3]|RxENABLE); write_zsreg(chan, R3, chan->regs[3] | RxENABLE);
if(chan->netdevice && if (chan->netdevice)
((chan->netdevice->type == ARPHRD_HDLC) || netif_carrier_on(chan->netdevice);
(chan->netdevice->type == ARPHRD_PPP))) } else {
sppp_reopen(chan->netdevice);
}
else
{
printk(KERN_INFO "%s: DCD lost\n", chan->dev->name); printk(KERN_INFO "%s: DCD lost\n", chan->dev->name);
write_zsreg(chan, R3, chan->regs[3]&~RxENABLE); write_zsreg(chan, R3, chan->regs[3] & ~RxENABLE);
z8530_flush_fifo(chan); z8530_flush_fifo(chan);
if (chan->netdevice)
netif_carrier_off(chan->netdevice);
} }
} }
write_zsctrl(chan, RES_EXT_INT); write_zsctrl(chan, RES_EXT_INT);
write_zsctrl(chan, RES_H_IUS); write_zsctrl(chan, RES_H_IUS);
} }
struct z8530_irqhandler z8530_sync= struct z8530_irqhandler z8530_sync =
{ {
z8530_rx, z8530_rx,
z8530_tx, z8530_tx,
...@@ -556,8 +551,7 @@ static void z8530_dma_tx(struct z8530_channel *chan) ...@@ -556,8 +551,7 @@ static void z8530_dma_tx(struct z8530_channel *chan)
* *
* A status event occurred on the Z8530. We receive these for two reasons * A status event occurred on the Z8530. We receive these for two reasons
* when in DMA mode. Firstly if we finished a packet transfer we get one * when in DMA mode. Firstly if we finished a packet transfer we get one
* and kick the next packet out. Secondly we may see a DCD change and * and kick the next packet out. Secondly we may see a DCD change.
* have to poke the protocol layer.
* *
*/ */
...@@ -586,24 +580,21 @@ static void z8530_dma_status(struct z8530_channel *chan) ...@@ -586,24 +580,21 @@ static void z8530_dma_status(struct z8530_channel *chan)
} }
} }
if(altered&chan->dcdcheck) if (altered & chan->dcdcheck)
{ {
if(status&chan->dcdcheck) if (status & chan->dcdcheck) {
{
printk(KERN_INFO "%s: DCD raised\n", chan->dev->name); printk(KERN_INFO "%s: DCD raised\n", chan->dev->name);
write_zsreg(chan, R3, chan->regs[3]|RxENABLE); write_zsreg(chan, R3, chan->regs[3] | RxENABLE);
if(chan->netdevice && if (chan->netdevice)
((chan->netdevice->type == ARPHRD_HDLC) || netif_carrier_on(chan->netdevice);
(chan->netdevice->type == ARPHRD_PPP))) } else {
sppp_reopen(chan->netdevice);
}
else
{
printk(KERN_INFO "%s:DCD lost\n", chan->dev->name); printk(KERN_INFO "%s:DCD lost\n", chan->dev->name);
write_zsreg(chan, R3, chan->regs[3]&~RxENABLE); write_zsreg(chan, R3, chan->regs[3] & ~RxENABLE);
z8530_flush_fifo(chan); z8530_flush_fifo(chan);
if (chan->netdevice)
netif_carrier_off(chan->netdevice);
} }
} }
write_zsctrl(chan, RES_EXT_INT); write_zsctrl(chan, RES_EXT_INT);
write_zsctrl(chan, RES_H_IUS); write_zsctrl(chan, RES_H_IUS);
...@@ -1459,10 +1450,10 @@ static void z8530_tx_begin(struct z8530_channel *c) ...@@ -1459,10 +1450,10 @@ static void z8530_tx_begin(struct z8530_channel *c)
/* /*
* Check if we crapped out. * Check if we crapped out.
*/ */
if(get_dma_residue(c->txdma)) if (get_dma_residue(c->txdma))
{ {
c->stats.tx_dropped++; c->netdevice->stats.tx_dropped++;
c->stats.tx_fifo_errors++; c->netdevice->stats.tx_fifo_errors++;
} }
release_dma_lock(flags); release_dma_lock(flags);
} }
...@@ -1534,21 +1525,21 @@ static void z8530_tx_begin(struct z8530_channel *c) ...@@ -1534,21 +1525,21 @@ static void z8530_tx_begin(struct z8530_channel *c)
* packet. This code is fairly timing sensitive. * packet. This code is fairly timing sensitive.
* *
* Called with the register lock held. * Called with the register lock held.
*/ */
static void z8530_tx_done(struct z8530_channel *c) static void z8530_tx_done(struct z8530_channel *c)
{ {
struct sk_buff *skb; struct sk_buff *skb;
/* Actually this can happen.*/ /* Actually this can happen.*/
if(c->tx_skb==NULL) if (c->tx_skb == NULL)
return; return;
skb=c->tx_skb; skb = c->tx_skb;
c->tx_skb=NULL; c->tx_skb = NULL;
z8530_tx_begin(c); z8530_tx_begin(c);
c->stats.tx_packets++; c->netdevice->stats.tx_packets++;
c->stats.tx_bytes+=skb->len; c->netdevice->stats.tx_bytes += skb->len;
dev_kfree_skb_irq(skb); dev_kfree_skb_irq(skb);
} }
...@@ -1558,7 +1549,7 @@ static void z8530_tx_done(struct z8530_channel *c) ...@@ -1558,7 +1549,7 @@ static void z8530_tx_done(struct z8530_channel *c)
* @skb: The buffer * @skb: The buffer
* *
* We point the receive handler at this function when idle. Instead * We point the receive handler at this function when idle. Instead
* of syncppp processing the frames we get to throw them away. * of processing the frames we get to throw them away.
*/ */
void z8530_null_rx(struct z8530_channel *c, struct sk_buff *skb) void z8530_null_rx(struct z8530_channel *c, struct sk_buff *skb)
...@@ -1635,10 +1626,11 @@ static void z8530_rx_done(struct z8530_channel *c) ...@@ -1635,10 +1626,11 @@ static void z8530_rx_done(struct z8530_channel *c)
else else
/* Can't occur as we dont reenable the DMA irq until /* Can't occur as we dont reenable the DMA irq until
after the flip is done */ after the flip is done */
printk(KERN_WARNING "%s: DMA flip overrun!\n", c->netdevice->name); printk(KERN_WARNING "%s: DMA flip overrun!\n",
c->netdevice->name);
release_dma_lock(flags); release_dma_lock(flags);
/* /*
* Shove the old buffer into an sk_buff. We can't DMA * Shove the old buffer into an sk_buff. We can't DMA
* directly into one on a PC - it might be above the 16Mb * directly into one on a PC - it might be above the 16Mb
...@@ -1646,27 +1638,23 @@ static void z8530_rx_done(struct z8530_channel *c) ...@@ -1646,27 +1638,23 @@ static void z8530_rx_done(struct z8530_channel *c)
* can avoid the copy. Optimisation 2 - make the memcpy * can avoid the copy. Optimisation 2 - make the memcpy
* a copychecksum. * a copychecksum.
*/ */
skb=dev_alloc_skb(ct); skb = dev_alloc_skb(ct);
if(skb==NULL) if (skb == NULL) {
{ c->netdevice->stats.rx_dropped++;
c->stats.rx_dropped++; printk(KERN_WARNING "%s: Memory squeeze.\n",
printk(KERN_WARNING "%s: Memory squeeze.\n", c->netdevice->name); c->netdevice->name);
} } else {
else
{
skb_put(skb, ct); skb_put(skb, ct);
skb_copy_to_linear_data(skb, rxb, ct); skb_copy_to_linear_data(skb, rxb, ct);
c->stats.rx_packets++; c->netdevice->stats.rx_packets++;
c->stats.rx_bytes+=ct; c->netdevice->stats.rx_bytes += ct;
} }
c->dma_ready=1; c->dma_ready = 1;
} } else {
else RT_LOCK;
{ skb = c->skb;
RT_LOCK;
skb=c->skb;
/* /*
* The game we play for non DMA is similar. We want to * The game we play for non DMA is similar. We want to
* get the controller set up for the next packet as fast * get the controller set up for the next packet as fast
...@@ -1677,48 +1665,39 @@ static void z8530_rx_done(struct z8530_channel *c) ...@@ -1677,48 +1665,39 @@ static void z8530_rx_done(struct z8530_channel *c)
* if you build a system where the sync irq isnt blocked * if you build a system where the sync irq isnt blocked
* by the kernel IRQ disable then you need only block the * by the kernel IRQ disable then you need only block the
* sync IRQ for the RT_LOCK area. * sync IRQ for the RT_LOCK area.
* *
*/ */
ct=c->count; ct=c->count;
c->skb = c->skb2; c->skb = c->skb2;
c->count = 0; c->count = 0;
c->max = c->mtu; c->max = c->mtu;
if(c->skb) if (c->skb) {
{
c->dptr = c->skb->data; c->dptr = c->skb->data;
c->max = c->mtu; c->max = c->mtu;
} } else {
else c->count = 0;
{
c->count= 0;
c->max = 0; c->max = 0;
} }
RT_UNLOCK; RT_UNLOCK;
c->skb2 = dev_alloc_skb(c->mtu); c->skb2 = dev_alloc_skb(c->mtu);
if(c->skb2==NULL) if (c->skb2 == NULL)
printk(KERN_WARNING "%s: memory squeeze.\n", printk(KERN_WARNING "%s: memory squeeze.\n",
c->netdevice->name); c->netdevice->name);
else else
{ skb_put(c->skb2, c->mtu);
skb_put(c->skb2,c->mtu); c->netdevice->stats.rx_packets++;
} c->netdevice->stats.rx_bytes += ct;
c->stats.rx_packets++;
c->stats.rx_bytes+=ct;
} }
/* /*
* If we received a frame we must now process it. * If we received a frame we must now process it.
*/ */
if(skb) if (skb) {
{
skb_trim(skb, ct); skb_trim(skb, ct);
c->rx_function(c,skb); c->rx_function(c, skb);
} } else {
else c->netdevice->stats.rx_dropped++;
{
c->stats.rx_dropped++;
printk(KERN_ERR "%s: Lost a frame\n", c->netdevice->name); printk(KERN_ERR "%s: Lost a frame\n", c->netdevice->name);
} }
} }
...@@ -1730,7 +1709,7 @@ static void z8530_rx_done(struct z8530_channel *c) ...@@ -1730,7 +1709,7 @@ static void z8530_rx_done(struct z8530_channel *c)
* Returns true if the buffer cross a DMA boundary on a PC. The poor * Returns true if the buffer cross a DMA boundary on a PC. The poor
* thing can only DMA within a 64K block not across the edges of it. * thing can only DMA within a 64K block not across the edges of it.
*/ */
static inline int spans_boundary(struct sk_buff *skb) static inline int spans_boundary(struct sk_buff *skb)
{ {
unsigned long a=(unsigned long)skb->data; unsigned long a=(unsigned long)skb->data;
...@@ -1799,24 +1778,6 @@ int z8530_queue_xmit(struct z8530_channel *c, struct sk_buff *skb) ...@@ -1799,24 +1778,6 @@ int z8530_queue_xmit(struct z8530_channel *c, struct sk_buff *skb)
EXPORT_SYMBOL(z8530_queue_xmit); EXPORT_SYMBOL(z8530_queue_xmit);
/**
* z8530_get_stats - Get network statistics
* @c: The channel to use
*
* Get the statistics block. We keep the statistics in software as
* the chip doesn't do it for us.
*
* Locking is ignored here - we could lock for a copy but its
* not likely to be that big an issue
*/
struct net_device_stats *z8530_get_stats(struct z8530_channel *c)
{
return &c->stats;
}
EXPORT_SYMBOL(z8530_get_stats);
/* /*
* Module support * Module support
*/ */
......
...@@ -325,7 +325,6 @@ struct z8530_channel ...@@ -325,7 +325,6 @@ struct z8530_channel
void *private; /* For our owner */ void *private; /* For our owner */
struct net_device *netdevice; /* Network layer device */ struct net_device *netdevice; /* Network layer device */
struct net_device_stats stats; /* Network layer statistics */
/* /*
* Async features * Async features
...@@ -366,13 +365,13 @@ struct z8530_channel ...@@ -366,13 +365,13 @@ struct z8530_channel
unsigned char tx_active; /* character is being xmitted */ unsigned char tx_active; /* character is being xmitted */
unsigned char tx_stopped; /* output is suspended */ unsigned char tx_stopped; /* output is suspended */
spinlock_t *lock; /* Devicr lock */ spinlock_t *lock; /* Device lock */
}; };
/* /*
* Each Z853x0 device. * Each Z853x0 device.
*/ */
struct z8530_dev struct z8530_dev
{ {
char *name; /* Device instance name */ char *name; /* Device instance name */
...@@ -408,7 +407,6 @@ extern int z8530_sync_txdma_open(struct net_device *, struct z8530_channel *); ...@@ -408,7 +407,6 @@ extern int z8530_sync_txdma_open(struct net_device *, struct z8530_channel *);
extern int z8530_sync_txdma_close(struct net_device *, struct z8530_channel *); extern int z8530_sync_txdma_close(struct net_device *, struct z8530_channel *);
extern int z8530_channel_load(struct z8530_channel *, u8 *); extern int z8530_channel_load(struct z8530_channel *, u8 *);
extern int z8530_queue_xmit(struct z8530_channel *c, struct sk_buff *skb); extern int z8530_queue_xmit(struct z8530_channel *c, struct sk_buff *skb);
extern struct net_device_stats *z8530_get_stats(struct z8530_channel *c);
extern void z8530_null_rx(struct z8530_channel *c, struct sk_buff *skb); extern void z8530_null_rx(struct z8530_channel *c, struct sk_buff *skb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment