Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1ffc0cd authored by David S. Miller's avatar David S. Miller
Browse files

Merge tag 'arcnet-cleanup-v4.3-rc2' of git://git.pengutronix.de/git/mgr/linux



Michael Grzeschik says:

====================
ARCNET: refactoring and cleanup

This series cleans up the code in drivers/net/arcnet
and include/uapi/linux/if_arcnet.h . It doesn't change
the runtime behaviour of the code. Its only purpose
is to improve the code maintenance and readability.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 927ab1d7 834c952a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -7292,7 +7292,6 @@ S: Odd Fixes
F:	drivers/net/
F:	include/linux/if_*
F:	include/linux/netdevice.h
F:	include/linux/arcdevice.h
F:	include/linux/etherdevice.h
F:	include/linux/fcdevice.h
F:	include/linux/fddidevice.h
+64 −78
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
 * **********************
 */

#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt

#include <linux/module.h>
#include <linux/gfp.h>
#include <linux/init.h>
@@ -31,58 +33,7 @@
#include <net/arp.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/arcdevice.h>

#define VERSION "arcnet: raw mode (`r') 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 struct ArcProto rawmode_proto =
{
	.suffix		= 'r',
	.mtu		= XMTU,
	.rx		= rx,
	.build_header	= build_header,
	.prepare_tx	= prepare_tx,
	.continue_tx    = NULL,
	.ack_tx         = NULL
};


static int __init arcnet_raw_init(void)
{
	int count;

	printk(VERSION);

	for (count = 0; count < 256; count++)
		if (arc_proto_map[count] == arc_proto_default)
			arc_proto_map[count] = &rawmode_proto;

	/* for raw mode, we only set the bcast proto if there's no better one */
	if (arc_bcast_proto == arc_proto_default)
		arc_bcast_proto = &rawmode_proto;

	arc_proto_default = &rawmode_proto;
	return 0;
}

static void __exit arcnet_raw_exit(void)
{
	arcnet_unregister_proto(&rawmode_proto);
}

module_init(arcnet_raw_init);
module_exit(arcnet_raw_exit);

MODULE_LICENSE("GPL");

#include "arcdevice.h"

/* packet receiver */
static void rx(struct net_device *dev, int bufnum,
@@ -93,7 +44,7 @@ static void rx(struct net_device *dev, int bufnum,
	struct archdr *pkt = pkthdr;
	int ofs;

	BUGMSG(D_DURING, "it's a raw packet (length=%d)\n", length);
	arc_printk(D_DURING, dev, "it's a raw packet (length=%d)\n", length);

	if (length > MTU)
		ofs = 512 - length;
@@ -101,8 +52,7 @@ static void rx(struct net_device *dev, int bufnum,
		ofs = 256 - length;

	skb = alloc_skb(length + ARC_HDR_SIZE, GFP_ATOMIC);
	if (skb == NULL) {
		BUGMSG(D_NORMAL, "Memory squeeze, dropping packet.\n");
	if (!skb) {
		dev->stats.rx_dropped++;
		return;
	}
@@ -121,15 +71,14 @@ static void rx(struct net_device *dev, int bufnum,
				      pkt->soft.raw + sizeof(pkt->soft),
				      length - sizeof(pkt->soft));

	BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx");
	if (BUGLVL(D_SKB))
		arcnet_dump_skb(dev, skb, "rx");

	skb->protocol = cpu_to_be16(ETH_P_ARCNET);
	netif_rx(skb);
}


/*
 * Create the ARCnet hard/soft headers for raw mode.
/* Create the ARCnet hard/soft headers for raw mode.
 * There aren't any soft headers in raw mode - not even the protocol id.
 */
static int build_header(struct sk_buff *skb, struct net_device *dev,
@@ -138,21 +87,19 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
	int hdr_size = ARC_HDR_SIZE;
	struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);

	/*
	 * Set the source hardware address.
	/* 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)
	 * 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.
		/* 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;
@@ -163,7 +110,6 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
	return hdr_size;	/* success */
}


static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
		      int bufnum)
{
@@ -171,14 +117,15 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
	struct arc_hardware *hard = &pkt->hard;
	int ofs;

	BUGMSG(D_DURING, "prepare_tx: txbufs=%d/%d/%d\n",
	arc_printk(D_DURING, dev, "prepare_tx: txbufs=%d/%d/%d\n",
		   lp->next_tx, lp->cur_tx, bufnum);

	length -= ARC_HDR_SIZE;	/* hard header is not included in packet length */
	/* hard header is not included in packet length */
	length -= ARC_HDR_SIZE;

	if (length > XMTU) {
		/* should never happen! other people already check for this. */
		BUGMSG(D_NORMAL, "Bug!  prepare_tx with size %d (> %d)\n",
		arc_printk(D_NORMAL, dev, "Bug!  prepare_tx with size %d (> %d)\n",
			   length, XMTU);
		length = XMTU;
	}
@@ -188,10 +135,11 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
	} else if (length > MTU) {
		hard->offset[0] = 0;
		hard->offset[1] = ofs = 512 - length - 3;
	} else
	} else {
		hard->offset[0] = ofs = 256 - length;
	}

	BUGMSG(D_DURING, "prepare_tx: length=%d ofs=%d\n",
	arc_printk(D_DURING, dev, "prepare_tx: length=%d ofs=%d\n",
		   length, ofs);

	lp->hw.copy_to_card(dev, bufnum, 0, hard, ARC_HDR_SIZE);
@@ -201,3 +149,41 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,

	return 1;		/* done */
}

static struct ArcProto rawmode_proto = {
	.suffix		= 'r',
	.mtu		= XMTU,
	.rx		= rx,
	.build_header	= build_header,
	.prepare_tx	= prepare_tx,
	.continue_tx    = NULL,
	.ack_tx         = NULL
};

static int __init arcnet_raw_init(void)
{
	int count;

	pr_info("raw mode (`r') encapsulation support loaded\n");

	for (count = 0; count < 256; count++)
		if (arc_proto_map[count] == arc_proto_default)
			arc_proto_map[count] = &rawmode_proto;

	/* for raw mode, we only set the bcast proto if there's no better one */
	if (arc_bcast_proto == arc_proto_default)
		arc_bcast_proto = &rawmode_proto;

	arc_proto_default = &rawmode_proto;
	return 0;
}

static void __exit arcnet_raw_exit(void)
{
	arcnet_unregister_proto(&rawmode_proto);
}

module_init(arcnet_raw_init);
module_exit(arcnet_raw_exit);

MODULE_LICENSE("GPL");
+64 −81
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@
 *
 * **********************
 */

#define pr_fmt(fmt) "arcnet:" KBUILD_MODNAME ": " fmt

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
@@ -33,12 +36,10 @@
#include <linux/bootmem.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include <linux/arcdevice.h>


#define VERSION "arcnet: RIM I (entirely mem-mapped) support\n"
#include <linux/io.h>

#include "arcdevice.h"
#include "com9026.h"

/* Internal function declarations */

@@ -50,8 +51,8 @@ static void arcrimi_setmask(struct net_device *dev, int mask);
static int arcrimi_reset(struct net_device *dev, int really_reset);
static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
				 void *buf, int count);
static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offset,
				   void *buf, int count);
static void arcrimi_copy_from_card(struct net_device *dev, int bufnum,
				   int offset, void *buf, int count);

/* Handy defines for ARCnet specific stuff */

@@ -59,57 +60,37 @@ static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offse
#define BUFFER_SIZE	(512)
#define MIRROR_SIZE	(BUFFER_SIZE * 4)

/* COM 9026 controller chip --> ARCnet register addresses */
#define _INTMASK (ioaddr+0)	/* writable */
#define _STATUS  (ioaddr+0)	/* readable */
#define _COMMAND (ioaddr+1)	/* writable, returns random vals on read (?) */
#define _RESET  (ioaddr+8)	/* software reset (on read) */
#define _MEMDATA  (ioaddr+12)	/* Data port for IO-mapped memory */
#define _ADDR_HI  (ioaddr+15)	/* Control registers for said */
#define _ADDR_LO  (ioaddr+14)
#define _CONFIG  (ioaddr+2)	/* Configuration register */

#undef ASTATUS
#undef ACOMMAND
#undef AINTMASK

#define ASTATUS()	readb(_STATUS)
#define ACOMMAND(cmd)	writeb((cmd),_COMMAND)
#define AINTMASK(msk)	writeb((msk),_INTMASK)
#define SETCONF()	writeb(lp->config,_CONFIG)


/*
 * We cannot probe for a RIM I card; one reason is I don't know how to reset
/* We cannot probe for a RIM I card; one reason is I don't know how to reset
 * them.  In fact, we can't even get their node ID automatically.  So, we
 * need to be passed a specific shmem address, IRQ, and node ID.
 */
static int __init arcrimi_probe(struct net_device *dev)
{
	BUGLVL(D_NORMAL) printk(VERSION);
	BUGLVL(D_NORMAL) printk("E-mail me if you actually test the RIM I driver, please!\n");

	BUGLVL(D_NORMAL) printk("Given: node %02Xh, shmem %lXh, irq %d\n",
	if (BUGLVL(D_NORMAL)) {
		pr_info("%s\n", "RIM I (entirely mem-mapped) support");
		pr_info("E-mail me if you actually test the RIM I driver, please!\n");
		pr_info("Given: node %02Xh, shmem %lXh, irq %d\n",
			dev->dev_addr[0], dev->mem_start, dev->irq);
	}

	if (dev->mem_start <= 0 || dev->irq <= 0) {
		BUGLVL(D_NORMAL) printk("No autoprobe for RIM I; you "
		       "must specify the shmem and irq!\n");
		if (BUGLVL(D_NORMAL))
			pr_err("No autoprobe for RIM I; you must specify the shmem and irq!\n");
		return -ENODEV;
	}
	if (dev->dev_addr[0] == 0) {
		BUGLVL(D_NORMAL) printk("You need to specify your card's station "
		       "ID!\n");
		if (BUGLVL(D_NORMAL))
			pr_err("You need to specify your card's station ID!\n");
		return -ENODEV;
	}
	/*
	 * Grab the memory region at mem_start for MIRROR_SIZE bytes.
	/* Grab the memory region at mem_start for MIRROR_SIZE bytes.
	 * Later in arcrimi_found() the real size will be determined
	 * and this reserve will be released and the correct size
	 * will be taken.
	 */
	if (!request_mem_region(dev->mem_start, MIRROR_SIZE, "arcnet (90xx)")) {
		BUGLVL(D_NORMAL) printk("Card memory already allocated\n");
		if (BUGLVL(D_NORMAL))
			pr_notice("Card memory already allocated\n");
		return -ENODEV;
	}
	return arcrimi_found(dev);
@@ -125,7 +106,7 @@ static int check_mirror(unsigned long addr, size_t size)

	p = ioremap(addr, size);
	if (p) {
		if (readb(p) == TESTvalue)
		if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
			res = 1;
		else
			res = 0;
@@ -136,9 +117,8 @@ static int check_mirror(unsigned long addr, size_t size)
	return res;
}

/*
 * Set up the struct net_device associated with this card.  Called after
 * probing succeeds.
/* Set up the struct net_device associated with this card.
 * Called after probing succeeds.
 */
static int __init arcrimi_found(struct net_device *dev)
{
@@ -151,7 +131,7 @@ static int __init arcrimi_found(struct net_device *dev)
	p = ioremap(dev->mem_start, MIRROR_SIZE);
	if (!p) {
		release_mem_region(dev->mem_start, MIRROR_SIZE);
		BUGMSG(D_NORMAL, "Can't ioremap\n");
		arc_printk(D_NORMAL, dev, "Can't ioremap\n");
		return -ENODEV;
	}

@@ -159,13 +139,14 @@ static int __init arcrimi_found(struct net_device *dev)
	if (request_irq(dev->irq, arcnet_interrupt, 0, "arcnet (RIM I)", dev)) {
		iounmap(p);
		release_mem_region(dev->mem_start, MIRROR_SIZE);
		BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
		arc_printk(D_NORMAL, dev, "Can't get IRQ %d!\n", dev->irq);
		return -ENODEV;
	}

	shmem = dev->mem_start;
	writeb(TESTvalue, p);
	writeb(dev->dev_addr[0], p + 1);	/* actually the node ID */
	arcnet_writeb(TESTvalue, p, COM9026_REG_W_INTMASK);
	arcnet_writeb(TESTvalue, p, COM9026_REG_W_COMMAND);
					/* actually the station/node ID */

	/* find the real shared memory start/end points, including mirrors */

@@ -174,7 +155,7 @@ static int __init arcrimi_found(struct net_device *dev)
	 * 2k (or there are no mirrors at all) but on some, it's 4k.
	 */
	mirror_size = MIRROR_SIZE;
	if (readb(p) == TESTvalue &&
	if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue &&
	    check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
	    check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
		mirror_size = 2 * MIRROR_SIZE;
@@ -204,8 +185,7 @@ static int __init arcrimi_found(struct net_device *dev)
	lp->hw.copy_to_card = arcrimi_copy_to_card;
	lp->hw.copy_from_card = arcrimi_copy_from_card;

	/*
	 * re-reserve the memory region - arcrimi_probe() alloced this reqion
	/* re-reserve the memory region - arcrimi_probe() alloced this reqion
	 * but didn't know the real size.  Free that region and then re-get
	 * with the correct size.  There is a VERY slim chance this could
	 * fail.
@@ -215,24 +195,25 @@ static int __init arcrimi_found(struct net_device *dev)
	if (!request_mem_region(dev->mem_start,
				dev->mem_end - dev->mem_start + 1,
				"arcnet (90xx)")) {
		BUGMSG(D_NORMAL, "Card memory already allocated\n");
		arc_printk(D_NORMAL, dev, "Card memory already allocated\n");
		goto err_free_irq;
	}

	lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1);
	lp->mem_start = ioremap(dev->mem_start,
				dev->mem_end - dev->mem_start + 1);
	if (!lp->mem_start) {
		BUGMSG(D_NORMAL, "Can't remap device memory!\n");
		arc_printk(D_NORMAL, dev, "Can't remap device memory!\n");
		goto err_release_mem;
	}

	/* get and check the station ID from offset 1 in shmem */
	dev->dev_addr[0] = readb(lp->mem_start + 1);
	dev->dev_addr[0] = arcnet_readb(lp->mem_start, COM9026_REG_R_STATION);

	BUGMSG(D_NORMAL, "ARCnet RIM I: station %02Xh found at IRQ %d, "
	       "ShMem %lXh (%ld*%d bytes).\n",
	arc_printk(D_NORMAL, dev, "ARCnet RIM I: station %02Xh found at IRQ %d, ShMem %lXh (%ld*%d bytes)\n",
		   dev->dev_addr[0],
		   dev->irq, dev->mem_start,
	 (dev->mem_end - dev->mem_start + 1) / mirror_size, mirror_size);
		   (dev->mem_end - dev->mem_start + 1) / mirror_size,
		   mirror_size);

	err = register_netdev(dev);
	if (err)
@@ -249,9 +230,7 @@ static int __init arcrimi_found(struct net_device *dev)
	return -EIO;
}


/*
 * Do a hardware reset on the card, and set up necessary registers.
/* Do a hardware reset on the card, and set up necessary registers.
 *
 * This should be called as little as possible, because it disrupts the
 * token on the network (causes a RECON) and requires a significant delay.
@@ -263,17 +242,19 @@ static int arcrimi_reset(struct net_device *dev, int really_reset)
	struct arcnet_local *lp = netdev_priv(dev);
	void __iomem *ioaddr = lp->mem_start + 0x800;

	BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, ASTATUS());
	arc_printk(D_INIT, dev, "Resetting %s (status=%02Xh)\n",
		   dev->name, arcnet_readb(ioaddr, COM9026_REG_R_STATUS));

	if (really_reset) {
		writeb(TESTvalue, ioaddr - 0x800);	/* fake reset */
		arcnet_writeb(TESTvalue, ioaddr, -0x800);	/* fake reset */
		return 0;
	}
	ACOMMAND(CFLAGScmd | RESETclear);	/* clear flags & end reset */
	ACOMMAND(CFLAGScmd | CONFIGclear);
	/* clear flags & end reset */
	arcnet_writeb(CFLAGScmd | RESETclear, ioaddr, COM9026_REG_W_COMMAND);
	arcnet_writeb(CFLAGScmd | CONFIGclear, ioaddr, COM9026_REG_W_COMMAND);

	/* enable extended (512-byte) packets */
	ACOMMAND(CONFIGcmd | EXTconf);
	arcnet_writeb(CONFIGcmd | EXTconf, ioaddr, COM9026_REG_W_COMMAND);

	/* done!  return success. */
	return 0;
@@ -284,7 +265,7 @@ static void arcrimi_setmask(struct net_device *dev, int mask)
	struct arcnet_local *lp = netdev_priv(dev);
	void __iomem *ioaddr = lp->mem_start + 0x800;

	AINTMASK(mask);
	arcnet_writeb(mask, ioaddr, COM9026_REG_W_INTMASK);
}

static int arcrimi_status(struct net_device *dev)
@@ -292,7 +273,7 @@ static int arcrimi_status(struct net_device *dev)
	struct arcnet_local *lp = netdev_priv(dev);
	void __iomem *ioaddr = lp->mem_start + 0x800;

	return ASTATUS();
	return arcnet_readb(ioaddr, COM9026_REG_R_STATUS);
}

static void arcrimi_command(struct net_device *dev, int cmd)
@@ -300,7 +281,7 @@ static void arcrimi_command(struct net_device *dev, int cmd)
	struct arcnet_local *lp = netdev_priv(dev);
	void __iomem *ioaddr = lp->mem_start + 0x800;

	ACOMMAND(cmd);
	arcnet_writeb(cmd, ioaddr, COM9026_REG_W_COMMAND);
}

static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
@@ -308,16 +289,17 @@ static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
{
	struct arcnet_local *lp = netdev_priv(dev);
	void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
	TIME("memcpy_toio", count, memcpy_toio(memaddr, buf, count));
}

	TIME(dev, "memcpy_toio", count, memcpy_toio(memaddr, buf, count));
}

static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offset,
				   void *buf, int count)
static void arcrimi_copy_from_card(struct net_device *dev, int bufnum,
				   int offset, void *buf, int count)
{
	struct arcnet_local *lp = netdev_priv(dev);
	void __iomem *memaddr = lp->mem_start + 0x800 + bufnum * 512 + offset;
	TIME("memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));

	TIME(dev, "memcpy_fromio", count, memcpy_fromio(buf, memaddr, count));
}

static int node;
@@ -374,12 +356,13 @@ static void __exit arc_rimi_exit(void)
static int __init arcrimi_setup(char *s)
{
	int ints[8];

	s = get_options(s, 8, ints);
	if (!ints[0])
		return 1;
	switch (ints[0]) {
	default:		/* ERROR */
		printk("arcrimi: Too many arguments.\n");
		pr_err("Too many arguments\n");
	case 3:		/* Node ID */
		node = ints[3];
	case 2:		/* IRQ */
+89 −63
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@
 */
#define RECON_THRESHOLD 30


/*
 * Define this to the minimum "timeout" value.  If a transmit takes longer
 * than TX_TIMEOUT jiffies, Linux will abort the TX and retry.  On a large
@@ -44,11 +43,9 @@
 */
#define TX_TIMEOUT (HZ * 200 / 1000)


/* Display warnings about the driver being an ALPHA version. */
#undef ALPHA_WARNING


/*
 * Debugging bitflags: each option can be enabled individually.
 *
@@ -81,31 +78,43 @@
#endif
extern int arcnet_debug;

#define BUGLVL(x)	((x) & ARCNET_DEBUG_MAX & arcnet_debug)

/* macros to simplify debug checking */
#define BUGLVL(x) if ((ARCNET_DEBUG_MAX)&arcnet_debug&(x))
#define BUGMSG2(x,msg,args...) do { BUGLVL(x) printk(msg, ## args); } while (0)
#define BUGMSG(x,msg,args...) \
	BUGMSG2(x, "%s%6s: " msg, \
            x==D_NORMAL	? KERN_WARNING \
            		: x < D_DURING ? KERN_INFO : KERN_DEBUG, \
	    dev->name , ## args)
#define arc_printk(x, dev, fmt, ...)					\
do {									\
	if (BUGLVL(x)) {						\
		if ((x) == D_NORMAL)					\
			netdev_warn(dev, fmt, ##__VA_ARGS__);		\
		else if ((x) < D_DURING)				\
			netdev_info(dev, fmt, ##__VA_ARGS__);		\
		else							\
			netdev_dbg(dev, fmt, ##__VA_ARGS__);		\
	}								\
} while (0)

#define arc_cont(x, fmt, ...)						\
do {									\
	if (BUGLVL(x))							\
		pr_cont(fmt, ##__VA_ARGS__);				\
} while (0)

/* see how long a function call takes to run, expressed in CPU cycles */
#define TIME(name, bytes, call) BUGLVL(D_TIMING) { \
#define TIME(dev, name, bytes, call)					\
do {									\
	if (BUGLVL(D_TIMING)) {						\
		unsigned long _x, _y;					\
		_x = get_cycles();					\
		call;							\
		_y = get_cycles();					\
	    BUGMSG(D_TIMING, \
	       "%s: %d bytes in %lu cycles == " \
	       "%lu Kbytes/100Mcycle\n",\
		arc_printk(D_TIMING, dev,				\
			   "%s: %d bytes in %lu cycles == %lu Kbytes/100Mcycle\n", \
			   name, bytes, _y - _x,			\
			   100000000 / 1024 * bytes / (_y - _x + 1));	\
	} \
	else { \
	} else {							\
		call;							\
	}

	}								\
} while (0)

/*
 * Time needed to reset the card - in ms (milliseconds).  This works on my
@@ -155,6 +164,7 @@ extern int arcnet_debug;
#define CONFIGcmd       0x05	/* define configuration */
#define CFLAGScmd       0x06	/* clear flags */
#define TESTcmd         0x07	/* load test flags */
#define STARTIOcmd      0x18	/* start internal operation */

/* flags for "clear flags" command */
#define RESETclear      0x08	/* power-on-reset */
@@ -182,7 +192,6 @@ extern int arcnet_debug;
#define ARC_CAN_10MBIT  2   /* card uses COM20022, supporting 10MBit,
				 but default is 2.5MBit. */


/* information needed to define an encapsulation driver */
struct ArcProto {
	char suffix;		/* a for RFC1201, e for ether-encap, etc. */
@@ -195,8 +204,8 @@ struct ArcProto {
			    unsigned short ethproto, uint8_t daddr);

	/* these functions return '1' if the skb can now be freed */
	int (*prepare_tx) (struct net_device * dev, struct archdr * pkt, int length,
			   int bufnum);
	int (*prepare_tx)(struct net_device *dev, struct archdr *pkt,
			  int length, int bufnum);
	int (*continue_tx)(struct net_device *dev, int bufnum);
	int (*ack_tx)(struct net_device *dev, int acked);
};
@@ -204,7 +213,6 @@ struct ArcProto {
extern struct ArcProto *arc_proto_map[256], *arc_proto_default,
	*arc_bcast_proto, *arc_raw_proto;


/*
 * "Incoming" is information needed for each address that could be sending
 * to us.  Mostly for partially-received split packets.
@@ -216,7 +224,6 @@ struct Incoming {
		numpackets;	/* number of packets in split     */
};


/* only needed for RFC1201 */
struct Outgoing {
	struct ArcProto *proto;	/* protocol driver that owns this:
@@ -230,7 +237,6 @@ struct Outgoing {
		numsegs;	/* number of segments */
};


struct arcnet_local {
	uint8_t config,		/* current value of CONFIG register */
		timeout,	/* Extended timeout for COM20020 */
@@ -251,7 +257,6 @@ struct arcnet_local {
	char *card_name;	/* card ident string */
	int card_flags;		/* special card features */


	/* On preemtive and SMB a lock is needed */
	spinlock_t lock;

@@ -305,27 +310,22 @@ struct arcnet_local {
		void (*open)(struct net_device *dev);
		void (*close)(struct net_device *dev);

		void (*copy_to_card) (struct net_device * dev, int bufnum, int offset,
				      void *buf, int count);
		void (*copy_from_card) (struct net_device * dev, int bufnum, int offset,
					void *buf, int count);
		void (*copy_to_card)(struct net_device *dev, int bufnum,
				     int offset, void *buf, int count);
		void (*copy_from_card)(struct net_device *dev, int bufnum,
				       int offset, void *buf, int count);
	} hw;

	void __iomem *mem_start;	/* pointer to ioremap'ed MMIO */
};


#define ARCRESET(x)  (lp->hw.reset(dev, (x)))
#define ACOMMAND(x)  (lp->hw.command(dev, (x)))
#define ASTATUS()    (lp->hw.status(dev))
#define AINTMASK(x)  (lp->hw.intmask(dev, (x)))



#if ARCNET_DEBUG_MAX & D_SKB
void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
#else
#define arcnet_dump_skb(dev,skb,desc) ;
static inline
void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc)
{
}
#endif

void arcnet_unregister_proto(struct ArcProto *proto);
@@ -338,5 +338,31 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
			       struct net_device *dev);
void arcnet_timeout(struct net_device *dev);

/* I/O equivalents */

#ifdef CONFIG_SA1100_CT6001
#define BUS_ALIGN  2  /* 8 bit device on a 16 bit bus - needs padding */
#else
#define BUS_ALIGN  1
#endif

/* addr and offset allow register like names to define the actual IO  address.
 * A configuration option multiplies the offset for alignment.
 */
#define arcnet_inb(addr, offset)					\
	inb((addr) + BUS_ALIGN * (offset))
#define arcnet_outb(value, addr, offset)				\
	outb(value, (addr) + BUS_ALIGN * (offset))

#define arcnet_insb(addr, offset, buffer, count)			\
	insb((addr) + BUS_ALIGN * (offset), buffer, count)
#define arcnet_outsb(addr, offset, buffer, count)			\
	outsb((addr) + BUS_ALIGN * (offset), buffer, count)

#define arcnet_readb(addr, offset)					\
	readb((addr) + (offset))
#define arcnet_writeb(value, addr, offset)				\
	writeb(value, (addr) + (offset))

#endif				/* __KERNEL__ */
#endif				/* _LINUX_ARCDEVICE_H */
+284 −317

File changed.

Preview size limit exceeded, changes collapsed.

Loading