Commit 4db3af5c authored by Esben Nielsen's avatar Esben Nielsen Committed by David S. Miller

[ARCNET]: Fixes.

As previously reported the ArcNet driver didn't work with Preempt and SMB
on.  They do now.  I have changed the locking system from being a global
arcnet lock to being a lock per device.  I used the lock in
dev->hard_start_xmit = arcnet_send_packet.  

Furthermore I added the 'CAP mode' encapsulation.  As far as I see it it is
the only encapsulation which actually makes ArcNet usefull over ethernet. 
Previously, the driver just ignored the hardware transmit status, now you
can get hardware acknowledge and excessive nacks back to userspace via a
raw socket.  The capmode.c is nearly just a copy of arc-rawmode.c.  The
difference is that it inserts a ack_tx() handle into the general driver
framework.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 40786dac
...@@ -59,6 +59,25 @@ config ARCNET_RAW ...@@ -59,6 +59,25 @@ config ARCNET_RAW
to work unless talking to a copy of the same Linux arcnet driver, to work unless talking to a copy of the same Linux arcnet driver,
but perhaps marginally faster in that case. but perhaps marginally faster in that case.
config ARCNET_CAP
tristate "Enable CAP mode packet interface"
depends on ARCNET
help
ARCnet "cap mode" packet encapsulation. Used to get the hardware
acknowledge back to userspace. After the initial protocol byte every
packet is stuffed with an extra 4 byte "cookie" which doesn't
actually appear on the network. After transmit the driver will send
back a packet with protocol byte 0 containing the status of the
transmition:
0=no hardware acknowledge
1=excessive nak
2=transmition accepted by the reciever hardware
Received packets are also stuffed with the extra 4 bytes but it will
be random data.
Cap only listens to protocol 1-8.
config ARCNET_COM90xx config ARCNET_COM90xx
tristate "ARCnet COM90xx (normal) chipset driver" tristate "ARCnet COM90xx (normal) chipset driver"
depends on ARCNET depends on ARCNET
......
...@@ -5,6 +5,7 @@ obj-$(CONFIG_ARCNET) += arcnet.o ...@@ -5,6 +5,7 @@ obj-$(CONFIG_ARCNET) += arcnet.o
obj-$(CONFIG_ARCNET_1201) += rfc1201.o obj-$(CONFIG_ARCNET_1201) += rfc1201.o
obj-$(CONFIG_ARCNET_1051) += rfc1051.o obj-$(CONFIG_ARCNET_1051) += rfc1051.o
obj-$(CONFIG_ARCNET_RAW) += arc-rawmode.o obj-$(CONFIG_ARCNET_RAW) += arc-rawmode.o
obj-$(CONFIG_ARCNET_CAP) += capmode.o
obj-$(CONFIG_ARCNET_COM90xx) += com90xx.o obj-$(CONFIG_ARCNET_COM90xx) += com90xx.o
obj-$(CONFIG_ARCNET_COM90xxIO) += com90io.o obj-$(CONFIG_ARCNET_COM90xxIO) += com90io.o
obj-$(CONFIG_ARCNET_RIM_I) += arc-rimi.o obj-$(CONFIG_ARCNET_RIM_I) += arc-rimi.o
......
...@@ -42,7 +42,6 @@ static int build_header(struct sk_buff *skb, struct net_device *dev, ...@@ -42,7 +42,6 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length, static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
int bufnum); int bufnum);
struct ArcProto rawmode_proto = struct ArcProto rawmode_proto =
{ {
.suffix = 'r', .suffix = 'r',
...@@ -50,6 +49,8 @@ struct ArcProto rawmode_proto = ...@@ -50,6 +49,8 @@ struct ArcProto rawmode_proto =
.rx = rx, .rx = rx,
.build_header = build_header, .build_header = build_header,
.prepare_tx = prepare_tx, .prepare_tx = prepare_tx,
.continue_tx = NULL,
.ack_tx = NULL
}; };
...@@ -121,7 +122,8 @@ static void rx(struct net_device *dev, int bufnum, ...@@ -121,7 +122,8 @@ static void rx(struct net_device *dev, int bufnum,
BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx"); BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");
skb->protocol = 0; skb->protocol = __constant_htons(ETH_P_ARCNET);
;
netif_rx(skb); netif_rx(skb);
dev->last_rx = jiffies; dev->last_rx = jiffies;
} }
...@@ -190,6 +192,9 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length, ...@@ -190,6 +192,9 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
} else } else
hard->offset[0] = ofs = 256 - length; hard->offset[0] = ofs = 256 - length;
BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
length,ofs);
lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE); lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
lp->hw.copy_to_card(dev, bufnum, ofs, &pkt->soft, length); lp->hw.copy_to_card(dev, bufnum, ofs, &pkt->soft, length);
......
This diff is collapsed.
/*
* Linux ARCnet driver - "cap mode" packet encapsulation.
* It adds sequence numbers to packets for communicating between a user space
* application and the driver. After a transmit it sends a packet with protocol
* byte 0 back up to the userspace containing the sequence number of the packet
* plus the transmit-status on the ArcNet.
*
* Written 2002-4 by Esben Nielsen, Vestas Wind Systems A/S
* Derived from arc-rawmode.c by Avery Pennarun.
* arc-rawmode was in turned based on skeleton.c, see below.
*
* **********************
*
* The original copyright of skeleton.c was as follows:
*
* skeleton.c Written 1993 by Donald Becker.
* Copyright 1993 United States Government as represented by the
* Director, National Security Agency. This software may only be used
* and distributed according to the terms of the GNU General Public License as
* modified by SRC, incorporated herein by reference.
*
* **********************
*
* For more details, see drivers/net/arcnet.c
*
* **********************
*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/if_arp.h>
#include <net/arp.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/arcdevice.h>
#define VERSION "arcnet: cap mode (`c') encapsulation support loaded.\n"
static void rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length);
static int build_header(struct sk_buff *skb,
struct net_device *dev,
unsigned short type,
uint8_t daddr);
static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
int bufnum);
static int ack_tx(struct net_device *dev, int acked);
struct ArcProto capmode_proto =
{
'r',
XMTU,
0,
rx,
build_header,
prepare_tx,
NULL,
ack_tx
};
void arcnet_cap_init(void)
{
int count;
for (count = 1; count <= 8; count++)
if (arc_proto_map[count] == arc_proto_default)
arc_proto_map[count] = &capmode_proto;
/* for cap mode, we only set the bcast proto if there's no better one */
if (arc_bcast_proto == arc_proto_default)
arc_bcast_proto = &capmode_proto;
arc_proto_default = &capmode_proto;
arc_raw_proto = &capmode_proto;
}
#ifdef MODULE
int __init init_module(void)
{
printk(VERSION);
arcnet_cap_init();
return 0;
}
void cleanup_module(void)
{
arcnet_unregister_proto(&capmode_proto);
}
MODULE_LICENSE("GPL");
#endif /* MODULE */
/* packet receiver */
static void rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length)
{
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct sk_buff *skb;
struct archdr *pkt = pkthdr;
char *pktbuf, *pkthdrbuf;
int ofs;
BUGMSG(D_DURING, "it's a raw(cap) packet (length=%d)\n", length);
if (length >= MinTU)
ofs = 512 - length;
else
ofs = 256 - length;
skb = alloc_skb(length + ARC_HDR_SIZE + sizeof(int), GFP_ATOMIC);
if (skb == NULL) {
BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
lp->stats.rx_dropped++;
return;
}
skb_put(skb, length + ARC_HDR_SIZE + sizeof(int));
skb->dev = dev;
pkt = (struct archdr *) skb->data;
skb->mac.raw = skb->data;
skb_pull(skb, ARC_HDR_SIZE);
/* up to sizeof(pkt->soft) has already been copied from the card */
/* squeeze in an int for the cap encapsulation */
/* use these variables to be sure we count in bytes, not in
sizeof(struct archdr) */
pktbuf=(char*)pkt;
pkthdrbuf=(char*)pkthdr;
memcpy(pktbuf, pkthdrbuf, ARC_HDR_SIZE+sizeof(pkt->soft.cap.proto));
memcpy(pktbuf+ARC_HDR_SIZE+sizeof(pkt->soft.cap.proto)+sizeof(int),
pkthdrbuf+ARC_HDR_SIZE+sizeof(pkt->soft.cap.proto),
sizeof(struct archdr)-ARC_HDR_SIZE-sizeof(pkt->soft.cap.proto));
if (length > sizeof(pkt->soft))
lp->hw.copy_from_card(dev, bufnum, ofs + sizeof(pkt->soft),
pkt->soft.raw + sizeof(pkt->soft)
+ sizeof(int),
length - sizeof(pkt->soft));
BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");
skb->protocol = __constant_htons(ETH_P_ARCNET);
;
netif_rx(skb);
dev->last_rx = jiffies;
}
/*
* Create the ARCnet hard/soft headers for cap mode.
* There aren't any soft headers in cap mode - not even the protocol id.
*/
static int build_header(struct sk_buff *skb,
struct net_device *dev,
unsigned short type,
uint8_t daddr)
{
int hdr_size = ARC_HDR_SIZE;
struct archdr *pkt = (struct archdr *) skb_push(skb, hdr_size);
BUGMSG(D_PROTO, "Preparing header for cap packet %x.\n",
*((int*)&pkt->soft.cap.cookie[0]));
/*
* Set the source hardware address.
*
* This is pretty pointless for most purposes, but it can help in
* debugging. ARCnet does not allow us to change the source address in
* the actual packet sent)
*/
pkt->hard.source = *dev->dev_addr;
/* see linux/net/ethernet/eth.c to see where I got the following */
if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
/*
* FIXME: fill in the last byte of the dest ipaddr here to better
* comply with RFC1051 in "noarp" mode.
*/
pkt->hard.dest = 0;
return hdr_size;
}
/* otherwise, just fill it in and go! */
pkt->hard.dest = daddr;
return hdr_size; /* success */
}
static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
int bufnum)
{
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct arc_hardware *hard = &pkt->hard;
int ofs;
/* hard header is not included in packet length */
length -= ARC_HDR_SIZE;
/* And neither is the cookie field */
length -= sizeof(int);
BUGMSG(D_DURING, "prepare_tx: txbufs=%d/%d/%d\n",
lp->next_tx, lp->cur_tx, bufnum);
BUGMSG(D_PROTO, "Sending for cap packet %x.\n",
*((int*)&pkt->soft.cap.cookie[0]));
if (length > XMTU) {
/* should never happen! other people already check for this. */
BUGMSG(D_NORMAL, "Bug! prepare_tx with size %d (> %d)\n",
length, XMTU);
length = XMTU;
}
if (length > MinTU) {
hard->offset[0] = 0;
hard->offset[1] = ofs = 512 - length;
} else if (length > MTU) {
hard->offset[0] = 0;
hard->offset[1] = ofs = 512 - length - 3;
} else
hard->offset[0] = ofs = 256 - length;
BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
length,ofs);
// Copy the arcnet-header + the protocol byte down:
lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
lp->hw.copy_to_card(dev, bufnum, ofs, &pkt->soft.cap.proto,
sizeof(pkt->soft.cap.proto));
// Skip the extra integer we have written into it as a cookie
// but write the rest of the message:
lp->hw.copy_to_card(dev, bufnum, ofs+1,
((unsigned char*)&pkt->soft.cap.mes),length-1);
lp->lastload_dest = hard->dest;
return 1; /* done */
}
static int ack_tx(struct net_device *dev, int acked)
{
struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
struct sk_buff *ackskb;
struct archdr *ackpkt;
int length=sizeof(struct arc_cap);
BUGMSG(D_DURING, "capmode: ack_tx: protocol: %x: result: %d\n",
lp->outgoing.skb->protocol, acked);
BUGLVL(D_SKB) arcnet_dump_skb(dev, lp->outgoing.skb, "ack_tx");
/* Now alloc a skb to send back up through the layers: */
ackskb = alloc_skb(length + ARC_HDR_SIZE , GFP_ATOMIC);
if (ackskb == NULL) {
BUGMSG(D_NORMAL, "Memory squeeze, can't acknowledge.\n");
goto free_outskb;
}
skb_put(ackskb, length + ARC_HDR_SIZE );
ackskb->dev = dev;
ackpkt = (struct archdr *) ackskb->data;
ackskb->mac.raw = ackskb->data;
/* skb_pull(ackskb, ARC_HDR_SIZE); */
memcpy(ackpkt, lp->outgoing.skb->data, ARC_HDR_SIZE+sizeof(struct arc_cap));
ackpkt->soft.cap.proto=0; /* using protocol 0 for acknowledge */
ackpkt->soft.cap.mes.ack=acked;
BUGMSG(D_PROTO, "Ackknowledge for cap packet %x.\n",
*((int*)&ackpkt->soft.cap.cookie[0]));
ackskb->protocol = __constant_htons(ETH_P_ARCNET);
BUGLVL(D_SKB) arcnet_dump_skb(dev, ackskb, "ack_tx_recv");
netif_rx(ackskb);
free_outskb:
dev_kfree_skb_irq(lp->outgoing.skb);
lp->outgoing.proto = NULL; /* We are always finished when in this protocol */
return 0;
}
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include <asm/io.h> #include <asm/io.h>
#define VERSION "arcnet: COM20020 ISA support (by David Woodhouse et al.)\n" #define VERSION "arcnet: COM20020 ISA support (by David Woodhouse et al.)\n"
......
...@@ -117,7 +117,7 @@ int com20020_check(struct net_device *dev) ...@@ -117,7 +117,7 @@ int com20020_check(struct net_device *dev)
lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2); lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2);
/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */ /* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
SETCONF; SETCONF;
outb(0x42, ioaddr + 7); outb(0x42, ioaddr + BUS_ALIGN*7);
status = ASTATUS(); status = ASTATUS();
...@@ -129,7 +129,7 @@ int com20020_check(struct net_device *dev) ...@@ -129,7 +129,7 @@ int com20020_check(struct net_device *dev)
/* Enable TX */ /* Enable TX */
outb(0x39, _CONFIG); outb(0x39, _CONFIG);
outb(inb(ioaddr + 8), ioaddr + 7); outb(inb(ioaddr + BUS_ALIGN*8), ioaddr + BUS_ALIGN*7);
ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
...@@ -173,7 +173,7 @@ int com20020_found(struct net_device *dev, int shared) ...@@ -173,7 +173,7 @@ int com20020_found(struct net_device *dev, int shared)
dev->set_multicast_list = com20020_set_mc_list; dev->set_multicast_list = com20020_set_mc_list;
if (!dev->dev_addr[0]) if (!dev->dev_addr[0])
dev->dev_addr[0] = inb(ioaddr + 8); /* FIXME: do this some other way! */ dev->dev_addr[0] = inb(ioaddr + BUS_ALIGN*8); /* FIXME: do this some other way! */
SET_SUBADR(SUB_SETUP1); SET_SUBADR(SUB_SETUP1);
outb(lp->setup, _XREG); outb(lp->setup, _XREG);
...@@ -188,7 +188,6 @@ int com20020_found(struct net_device *dev, int shared) ...@@ -188,7 +188,6 @@ int com20020_found(struct net_device *dev, int shared)
outb(0x18, _COMMAND); outb(0x18, _COMMAND);
} }
lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1; lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1;
/* Default 0x38 + register: Node ID */ /* Default 0x38 + register: Node ID */
SETCONF; SETCONF;
...@@ -235,15 +234,19 @@ int com20020_found(struct net_device *dev, int shared) ...@@ -235,15 +234,19 @@ int com20020_found(struct net_device *dev, int shared)
static int com20020_reset(struct net_device *dev, int really_reset) static int com20020_reset(struct net_device *dev, int really_reset)
{ {
struct arcnet_local *lp = (struct arcnet_local *) dev->priv; struct arcnet_local *lp = (struct arcnet_local *) dev->priv;
short ioaddr = dev->base_addr; u_int ioaddr = dev->base_addr;
u_char inbyte; u_char inbyte;
BUGMSG(D_DEBUG, "%s: %d: %s: dev: %p, lp: %p, dev->name: %s\n",
__FILE__,__LINE__,__FUNCTION__,dev,lp,dev->name);
BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n",
dev->name, ASTATUS()); dev->name, ASTATUS());
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);
lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2); lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
/* power-up defaults */ /* power-up defaults */
SETCONF; SETCONF;
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);
if (really_reset) { if (really_reset) {
/* reset the card */ /* reset the card */
...@@ -251,17 +254,22 @@ static int com20020_reset(struct net_device *dev, int really_reset) ...@@ -251,17 +254,22 @@ static int com20020_reset(struct net_device *dev, int really_reset)
mdelay(RESETtime * 2); /* COM20020 seems to be slower sometimes */ mdelay(RESETtime * 2); /* COM20020 seems to be slower sometimes */
} }
/* clear flags & end reset */ /* clear flags & end reset */
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);
ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear); ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
/* verify that the ARCnet signature byte is present */ /* verify that the ARCnet signature byte is present */
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);
com20020_copy_from_card(dev, 0, 0, &inbyte, 1); com20020_copy_from_card(dev, 0, 0, &inbyte, 1);
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);
if (inbyte != TESTvalue) { if (inbyte != TESTvalue) {
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);
BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n"); BUGMSG(D_NORMAL, "reset failed: TESTvalue not present.\n");
return 1; return 1;
} }
/* enable extended (512-byte) packets */ /* enable extended (512-byte) packets */
ACOMMAND(CONFIGcmd | EXTconf); ACOMMAND(CONFIGcmd | EXTconf);
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__FUNCTION__);
/* done! return success. */ /* done! return success. */
return 0; return 0;
...@@ -270,22 +278,24 @@ static int com20020_reset(struct net_device *dev, int really_reset) ...@@ -270,22 +278,24 @@ static int com20020_reset(struct net_device *dev, int really_reset)
static void com20020_setmask(struct net_device *dev, int mask) static void com20020_setmask(struct net_device *dev, int mask)
{ {
short ioaddr = dev->base_addr; u_int ioaddr = dev->base_addr;
BUGMSG(D_DURING, "Setting mask to %x at %x\n",mask,ioaddr);
AINTMASK(mask); AINTMASK(mask);
} }
static void com20020_command(struct net_device *dev, int cmd) static void com20020_command(struct net_device *dev, int cmd)
{ {
short ioaddr = dev->base_addr; u_int ioaddr = dev->base_addr;
ACOMMAND(cmd); ACOMMAND(cmd);
} }
static int com20020_status(struct net_device *dev) static int com20020_status(struct net_device *dev)
{ {
short ioaddr = dev->base_addr; u_int ioaddr = dev->base_addr;
return ASTATUS();
return ASTATUS() + (ADIAGSTATUS()<<8);
} }
static void com20020_close(struct net_device *dev) static void com20020_close(struct net_device *dev)
......
...@@ -47,9 +47,12 @@ struct ArcProto rfc1051_proto = ...@@ -47,9 +47,12 @@ struct ArcProto rfc1051_proto =
{ {
.suffix = 's', .suffix = 's',
.mtu = XMTU - RFC1051_HDR_SIZE, .mtu = XMTU - RFC1051_HDR_SIZE,
.is_ip = 1,
.rx = rx, .rx = rx,
.build_header = build_header, .build_header = build_header,
.prepare_tx = prepare_tx, .prepare_tx = prepare_tx,
.continue_tx = NULL,
.ack_tx = NULL
}; };
......
...@@ -47,10 +47,12 @@ struct ArcProto rfc1201_proto = ...@@ -47,10 +47,12 @@ struct ArcProto rfc1201_proto =
{ {
.suffix = 'a', .suffix = 'a',
.mtu = 1500, /* could be more, but some receivers can't handle it... */ .mtu = 1500, /* could be more, but some receivers can't handle it... */
.is_ip = 1, /* This is for sending IP and ARP packages */
.rx = rx, .rx = rx,
.build_header = build_header, .build_header = build_header,
.prepare_tx = prepare_tx, .prepare_tx = prepare_tx,
.continue_tx = continue_tx, .continue_tx = continue_tx,
.ack_tx = NULL
}; };
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#define bool int #define bool int
#endif #endif
/* /*
* RECON_THRESHOLD is the maximum number of RECON messages to receive * RECON_THRESHOLD is the maximum number of RECON messages to receive
* within one minute before printing a "cabling problem" warning. The * within one minute before printing a "cabling problem" warning. The
...@@ -74,6 +73,7 @@ ...@@ -74,6 +73,7 @@
#define D_SKB 1024 /* show skb's */ #define D_SKB 1024 /* show skb's */
#define D_SKB_SIZE 2048 /* show skb sizes */ #define D_SKB_SIZE 2048 /* show skb sizes */
#define D_TIMING 4096 /* show time needed to copy buffers to card */ #define D_TIMING 4096 /* show time needed to copy buffers to card */
#define D_DEBUG 8192 /* Very detailed debug line for line */
#ifndef ARCNET_DEBUG_MAX #ifndef ARCNET_DEBUG_MAX
#define ARCNET_DEBUG_MAX (127) /* change to ~0 if you want detailed debugging */ #define ARCNET_DEBUG_MAX (127) /* change to ~0 if you want detailed debugging */
...@@ -135,6 +135,7 @@ extern int arcnet_debug; ...@@ -135,6 +135,7 @@ extern int arcnet_debug;
#define TXACKflag 0x02 /* transmitted msg. ackd */ #define TXACKflag 0x02 /* transmitted msg. ackd */
#define RECONflag 0x04 /* network reconfigured */ #define RECONflag 0x04 /* network reconfigured */
#define TESTflag 0x08 /* test flag */ #define TESTflag 0x08 /* test flag */
#define EXCNAKflag 0x08 /* excesive nak flag */
#define RESETflag 0x10 /* power-on-reset */ #define RESETflag 0x10 /* power-on-reset */
#define RES1flag 0x20 /* reserved - usually set by jumper */ #define RES1flag 0x20 /* reserved - usually set by jumper */
#define RES2flag 0x40 /* reserved - usually set by jumper */ #define RES2flag 0x40 /* reserved - usually set by jumper */
...@@ -162,6 +163,8 @@ extern int arcnet_debug; ...@@ -162,6 +163,8 @@ extern int arcnet_debug;
#define RESETclear 0x08 /* power-on-reset */ #define RESETclear 0x08 /* power-on-reset */
#define CONFIGclear 0x10 /* system reconfigured */ #define CONFIGclear 0x10 /* system reconfigured */
#define EXCNAKclear 0x0E /* Clear and acknowledge the excive nak bit */
/* flags for "load test flags" command */ /* flags for "load test flags" command */
#define TESTload 0x08 /* test flag (diagnostic) */ #define TESTload 0x08 /* test flag (diagnostic) */
...@@ -187,6 +190,7 @@ extern int arcnet_debug; ...@@ -187,6 +190,7 @@ extern int arcnet_debug;
struct ArcProto { struct ArcProto {
char suffix; /* a for RFC1201, e for ether-encap, etc. */ char suffix; /* a for RFC1201, e for ether-encap, etc. */
int mtu; /* largest possible packet */ int mtu; /* largest possible packet */
int is_ip; /* This is a ip plugin - not a raw thing */
void (*rx) (struct net_device * dev, int bufnum, void (*rx) (struct net_device * dev, int bufnum,
struct archdr * pkthdr, int length); struct archdr * pkthdr, int length);
...@@ -197,9 +201,11 @@ struct ArcProto { ...@@ -197,9 +201,11 @@ struct ArcProto {
int (*prepare_tx) (struct net_device * dev, struct archdr * pkt, int length, int (*prepare_tx) (struct net_device * dev, struct archdr * pkt, int length,
int bufnum); int bufnum);
int (*continue_tx) (struct net_device * dev, int bufnum); int (*continue_tx) (struct net_device * dev, int bufnum);
int (*ack_tx) (struct net_device * dev, int acked);
}; };
extern struct ArcProto *arc_proto_map[256], *arc_proto_default, *arc_bcast_proto; extern struct ArcProto *arc_proto_map[256], *arc_proto_default,
*arc_bcast_proto, *arc_raw_proto;
extern struct ArcProto arc_proto_null; extern struct ArcProto arc_proto_null;
...@@ -251,6 +257,10 @@ struct arcnet_local { ...@@ -251,6 +257,10 @@ struct arcnet_local {
char *card_name; /* card ident string */ char *card_name; /* card ident string */
int card_flags; /* special card features */ int card_flags; /* special card features */
/* On preemtive and SMB a lock is needed */
spinlock_t lock;
/* /*
* Buffer management: an ARCnet card has 4 x 512-byte buffers, each of * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
* which can be used for either sending or receiving. The new dynamic * which can be used for either sending or receiving. The new dynamic
...@@ -279,6 +289,8 @@ struct arcnet_local { ...@@ -279,6 +289,8 @@ struct arcnet_local {
int num_recons; /* number of RECONs between first and last. */ int num_recons; /* number of RECONs between first and last. */
bool network_down; /* do we think the network is down? */ bool network_down; /* do we think the network is down? */
bool excnak_pending; /* We just got an excesive nak interrupt */
struct { struct {
uint16_t sequence; /* sequence number (incs with each packet) */ uint16_t sequence; /* sequence number (incs with each packet) */
uint16_t aborted_seq; uint16_t aborted_seq;
...@@ -323,9 +335,10 @@ void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc); ...@@ -323,9 +335,10 @@ void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
#endif #endif
#if (ARCNET_DEBUG_MAX & D_RX) || (ARCNET_DEBUG_MAX & D_TX) #if (ARCNET_DEBUG_MAX & D_RX) || (ARCNET_DEBUG_MAX & D_TX)
void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc); void arcnet_dump_packet(struct net_device *dev, int bufnum, char *desc,
int take_arcnet_lock);
#else #else
#define arcnet_dump_packet(dev, bufnum, desc) ; #define arcnet_dump_packet(dev, bufnum, desc,take_arcnet_lock) ;
#endif #endif
void arcnet_unregister_proto(struct ArcProto *proto); void arcnet_unregister_proto(struct ArcProto *proto);
......
...@@ -34,17 +34,24 @@ int com20020_found(struct net_device *dev, int shared); ...@@ -34,17 +34,24 @@ int com20020_found(struct net_device *dev, int shared);
#define ARCNET_TOTAL_SIZE 8 #define ARCNET_TOTAL_SIZE 8
/* various register addresses */ /* various register addresses */
#define _INTMASK (ioaddr+0) /* writable */ #ifdef CONFIG_SA1100_CT6001
#define _STATUS (ioaddr+0) /* readable */ #define BUS_ALIGN 2 /* 8 bit device on a 16 bit bus - needs padding */
#define _COMMAND (ioaddr+1) /* standard arcnet commands */ #else
#define _DIAGSTAT (ioaddr+1) /* diagnostic status register */ #define BUS_ALIGN 1
#define _ADDR_HI (ioaddr+2) /* control registers for IO-mapped memory */ #endif
#define _ADDR_LO (ioaddr+3)
#define _MEMDATA (ioaddr+4) /* data port for IO-mapped memory */
#define _SUBADR (ioaddr+5) /* the extended port _XREG refers to */ #define _INTMASK (ioaddr+BUS_ALIGN*0) /* writable */
#define _CONFIG (ioaddr+6) /* configuration register */ #define _STATUS (ioaddr+BUS_ALIGN*0) /* readable */
#define _XREG (ioaddr+7) /* extra registers (indexed by _CONFIG #define _COMMAND (ioaddr+BUS_ALIGN*1) /* standard arcnet commands */
or _SUBADR) */ #define _DIAGSTAT (ioaddr+BUS_ALIGN*1) /* diagnostic status register */
#define _ADDR_HI (ioaddr+BUS_ALIGN*2) /* control registers for IO-mapped memory */
#define _ADDR_LO (ioaddr+BUS_ALIGN*3)
#define _MEMDATA (ioaddr+BUS_ALIGN*4) /* data port for IO-mapped memory */
#define _SUBADR (ioaddr+BUS_ALIGN*5) /* the extended port _XREG refers to */
#define _CONFIG (ioaddr+BUS_ALIGN*6) /* configuration register */
#define _XREG (ioaddr+BUS_ALIGN*7) /* extra registers (indexed by _CONFIG
or _SUBADR) */
/* in the ADDR_HI register */ /* in the ADDR_HI register */
#define RDDATAflag 0x80 /* next access is a read (not a write) */ #define RDDATAflag 0x80 /* next access is a read (not a write) */
...@@ -99,6 +106,7 @@ int com20020_found(struct net_device *dev, int shared); ...@@ -99,6 +106,7 @@ int com20020_found(struct net_device *dev, int shared);
} }
#define ASTATUS() inb(_STATUS) #define ASTATUS() inb(_STATUS)
#define ADIAGSTATUS() inb(_DIAGSTAT)
#define ACOMMAND(cmd) outb((cmd),_COMMAND) #define ACOMMAND(cmd) outb((cmd),_COMMAND)
#define AINTMASK(msk) outb((msk),_INTMASK) #define AINTMASK(msk) outb((msk),_INTMASK)
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
* These are the defined ARCnet Protocol ID's. * These are the defined ARCnet Protocol ID's.
*/ */
/* CAP mode */
/* No macro but uses 1-8 */
/* RFC1201 Protocol ID's */ /* RFC1201 Protocol ID's */
#define ARC_P_IP 212 /* 0xD4 */ #define ARC_P_IP 212 /* 0xD4 */
#define ARC_P_IPV6 196 /* 0xC4: RFC2497 */ #define ARC_P_IPV6 196 /* 0xC4: RFC2497 */
...@@ -86,6 +89,16 @@ struct arc_eth_encap ...@@ -86,6 +89,16 @@ struct arc_eth_encap
#define ETH_ENCAP_HDR_SIZE 14 #define ETH_ENCAP_HDR_SIZE 14
struct arc_cap
{
uint8_t proto;
uint8_t cookie[sizeof(int)]; /* Actually NOT sent over the network */
union {
uint8_t ack;
uint8_t raw[0]; /* 507 bytes */
} mes;
};
/* /*
* The data needed by the actual arcnet hardware. * The data needed by the actual arcnet hardware.
* *
...@@ -116,6 +129,7 @@ struct archdr ...@@ -116,6 +129,7 @@ struct archdr
struct arc_rfc1201 rfc1201; struct arc_rfc1201 rfc1201;
struct arc_rfc1051 rfc1051; struct arc_rfc1051 rfc1051;
struct arc_eth_encap eth_encap; struct arc_eth_encap eth_encap;
struct arc_cap cap;
uint8_t raw[0]; /* 508 bytes */ uint8_t raw[0]; /* 508 bytes */
} soft; } soft;
}; };
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ #define ETH_P_IRDA 0x0017 /* Linux-IrDA */
#define ETH_P_ECONET 0x0018 /* Acorn Econet */ #define ETH_P_ECONET 0x0018 /* Acorn Econet */
#define ETH_P_HDLC 0x0019 /* HDLC frames */ #define ETH_P_HDLC 0x0019 /* HDLC frames */
#define ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */
/* /*
* This is an Ethernet frame header. * This is an Ethernet frame header.
......
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