12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
226c6d281SJoe Perches /*
326c6d281SJoe Perches * INET An implementation of the TCP/IP protocol suite for the LINUX
426c6d281SJoe Perches * operating system. NET is implemented using the BSD Socket
526c6d281SJoe Perches * interface as the means of communication with the user level.
626c6d281SJoe Perches *
726c6d281SJoe Perches * Definitions used by the ARCnet driver.
826c6d281SJoe Perches *
926c6d281SJoe Perches * Authors: Avery Pennarun and David Woodhouse
1026c6d281SJoe Perches */
1126c6d281SJoe Perches #ifndef _LINUX_ARCDEVICE_H
1226c6d281SJoe Perches #define _LINUX_ARCDEVICE_H
1326c6d281SJoe Perches
1426c6d281SJoe Perches #include <asm/timex.h>
1526c6d281SJoe Perches #include <linux/if_arcnet.h>
1626c6d281SJoe Perches
1726c6d281SJoe Perches #ifdef __KERNEL__
180ab10314SFlorian Westphal #include <linux/interrupt.h>
1926c6d281SJoe Perches
2026c6d281SJoe Perches /*
2126c6d281SJoe Perches * RECON_THRESHOLD is the maximum number of RECON messages to receive
2226c6d281SJoe Perches * within one minute before printing a "cabling problem" warning. The
2326c6d281SJoe Perches * default value should be fine.
2426c6d281SJoe Perches *
2526c6d281SJoe Perches * After that, a "cabling restored" message will be printed on the next IRQ
2626c6d281SJoe Perches * if no RECON messages have been received for 10 seconds.
2726c6d281SJoe Perches *
2826c6d281SJoe Perches * Do not define RECON_THRESHOLD at all if you want to disable this feature.
2926c6d281SJoe Perches */
3026c6d281SJoe Perches #define RECON_THRESHOLD 30
3126c6d281SJoe Perches
3226c6d281SJoe Perches /*
3326c6d281SJoe Perches * Define this to the minimum "timeout" value. If a transmit takes longer
3426c6d281SJoe Perches * than TX_TIMEOUT jiffies, Linux will abort the TX and retry. On a large
3526c6d281SJoe Perches * network, or one with heavy network traffic, this timeout may need to be
3626c6d281SJoe Perches * increased. The larger it is, though, the longer it will be between
3726c6d281SJoe Perches * necessary transmits - don't set this too high.
3826c6d281SJoe Perches */
3926c6d281SJoe Perches #define TX_TIMEOUT (HZ * 200 / 1000)
4026c6d281SJoe Perches
4126c6d281SJoe Perches /* Display warnings about the driver being an ALPHA version. */
4226c6d281SJoe Perches #undef ALPHA_WARNING
4326c6d281SJoe Perches
4426c6d281SJoe Perches /*
4526c6d281SJoe Perches * Debugging bitflags: each option can be enabled individually.
4626c6d281SJoe Perches *
4726c6d281SJoe Perches * Note: only debug flags included in the ARCNET_DEBUG_MAX define will
4826c6d281SJoe Perches * actually be available. GCC will (at least, GCC 2.7.0 will) notice
4926c6d281SJoe Perches * lines using a BUGLVL not in ARCNET_DEBUG_MAX and automatically optimize
5026c6d281SJoe Perches * them out.
5126c6d281SJoe Perches */
5226c6d281SJoe Perches #define D_NORMAL 1 /* important operational info */
5326c6d281SJoe Perches #define D_EXTRA 2 /* useful, but non-vital information */
5426c6d281SJoe Perches #define D_INIT 4 /* show init/probe messages */
5526c6d281SJoe Perches #define D_INIT_REASONS 8 /* show reasons for discarding probes */
5626c6d281SJoe Perches #define D_RECON 32 /* print a message whenever token is lost */
5726c6d281SJoe Perches #define D_PROTO 64 /* debug auto-protocol support */
5826c6d281SJoe Perches /* debug levels below give LOTS of output during normal operation! */
5926c6d281SJoe Perches #define D_DURING 128 /* trace operations (including irq's) */
6026c6d281SJoe Perches #define D_TX 256 /* show tx packets */
6126c6d281SJoe Perches #define D_RX 512 /* show rx packets */
6226c6d281SJoe Perches #define D_SKB 1024 /* show skb's */
6326c6d281SJoe Perches #define D_SKB_SIZE 2048 /* show skb sizes */
6426c6d281SJoe Perches #define D_TIMING 4096 /* show time needed to copy buffers to card */
6526c6d281SJoe Perches #define D_DEBUG 8192 /* Very detailed debug line for line */
6626c6d281SJoe Perches
6726c6d281SJoe Perches #ifndef ARCNET_DEBUG_MAX
6826c6d281SJoe Perches #define ARCNET_DEBUG_MAX (127) /* change to ~0 if you want detailed debugging */
6926c6d281SJoe Perches #endif
7026c6d281SJoe Perches
7126c6d281SJoe Perches #ifndef ARCNET_DEBUG
7226c6d281SJoe Perches #define ARCNET_DEBUG (D_NORMAL | D_EXTRA)
7326c6d281SJoe Perches #endif
7426c6d281SJoe Perches extern int arcnet_debug;
7526c6d281SJoe Perches
7626c6d281SJoe Perches #define BUGLVL(x) ((x) & ARCNET_DEBUG_MAX & arcnet_debug)
7726c6d281SJoe Perches
7826c6d281SJoe Perches /* macros to simplify debug checking */
7926c6d281SJoe Perches #define arc_printk(x, dev, fmt, ...) \
8026c6d281SJoe Perches do { \
8126c6d281SJoe Perches if (BUGLVL(x)) { \
8226c6d281SJoe Perches if ((x) == D_NORMAL) \
8326c6d281SJoe Perches netdev_warn(dev, fmt, ##__VA_ARGS__); \
8426c6d281SJoe Perches else if ((x) < D_DURING) \
8526c6d281SJoe Perches netdev_info(dev, fmt, ##__VA_ARGS__); \
8626c6d281SJoe Perches else \
8726c6d281SJoe Perches netdev_dbg(dev, fmt, ##__VA_ARGS__); \
8826c6d281SJoe Perches } \
8926c6d281SJoe Perches } while (0)
9026c6d281SJoe Perches
9126c6d281SJoe Perches #define arc_cont(x, fmt, ...) \
9226c6d281SJoe Perches do { \
9326c6d281SJoe Perches if (BUGLVL(x)) \
9426c6d281SJoe Perches pr_cont(fmt, ##__VA_ARGS__); \
9526c6d281SJoe Perches } while (0)
9626c6d281SJoe Perches
9726c6d281SJoe Perches /* see how long a function call takes to run, expressed in CPU cycles */
9826c6d281SJoe Perches #define TIME(dev, name, bytes, call) \
9926c6d281SJoe Perches do { \
10026c6d281SJoe Perches if (BUGLVL(D_TIMING)) { \
10126c6d281SJoe Perches unsigned long _x, _y; \
10226c6d281SJoe Perches _x = get_cycles(); \
10326c6d281SJoe Perches call; \
10426c6d281SJoe Perches _y = get_cycles(); \
10526c6d281SJoe Perches arc_printk(D_TIMING, dev, \
10626c6d281SJoe Perches "%s: %d bytes in %lu cycles == %lu Kbytes/100Mcycle\n", \
10726c6d281SJoe Perches name, bytes, _y - _x, \
10826c6d281SJoe Perches 100000000 / 1024 * bytes / (_y - _x + 1)); \
10926c6d281SJoe Perches } else { \
11026c6d281SJoe Perches call; \
11126c6d281SJoe Perches } \
11226c6d281SJoe Perches } while (0)
11326c6d281SJoe Perches
11426c6d281SJoe Perches /*
11526c6d281SJoe Perches * Time needed to reset the card - in ms (milliseconds). This works on my
11626c6d281SJoe Perches * SMC PC100. I can't find a reference that tells me just how long I
11726c6d281SJoe Perches * should wait.
11826c6d281SJoe Perches */
11926c6d281SJoe Perches #define RESETtime (300)
12026c6d281SJoe Perches
12126c6d281SJoe Perches /*
12226c6d281SJoe Perches * These are the max/min lengths of packet payload, not including the
12326c6d281SJoe Perches * arc_hardware header, but definitely including the soft header.
12426c6d281SJoe Perches *
12526c6d281SJoe Perches * Note: packet sizes 254, 255, 256 are impossible because of the way
12626c6d281SJoe Perches * ARCnet registers work That's why RFC1201 defines "exception" packets.
12726c6d281SJoe Perches * In non-RFC1201 protocols, we have to just tack some extra bytes on the
12826c6d281SJoe Perches * end.
12926c6d281SJoe Perches */
13026c6d281SJoe Perches #define MTU 253 /* normal packet max size */
13126c6d281SJoe Perches #define MinTU 257 /* extended packet min size */
13226c6d281SJoe Perches #define XMTU 508 /* extended packet max size */
13326c6d281SJoe Perches
13426c6d281SJoe Perches /* status/interrupt mask bit fields */
13526c6d281SJoe Perches #define TXFREEflag 0x01 /* transmitter available */
13626c6d281SJoe Perches #define TXACKflag 0x02 /* transmitted msg. ackd */
13726c6d281SJoe Perches #define RECONflag 0x04 /* network reconfigured */
13826c6d281SJoe Perches #define TESTflag 0x08 /* test flag */
13926c6d281SJoe Perches #define EXCNAKflag 0x08 /* excesive nak flag */
14026c6d281SJoe Perches #define RESETflag 0x10 /* power-on-reset */
14126c6d281SJoe Perches #define RES1flag 0x20 /* reserved - usually set by jumper */
14226c6d281SJoe Perches #define RES2flag 0x40 /* reserved - usually set by jumper */
14326c6d281SJoe Perches #define NORXflag 0x80 /* receiver inhibited */
14426c6d281SJoe Perches
14526c6d281SJoe Perches /* Flags used for IO-mapped memory operations */
14626c6d281SJoe Perches #define AUTOINCflag 0x40 /* Increase location with each access */
14726c6d281SJoe Perches #define IOMAPflag 0x02 /* (for 90xx) Use IO mapped memory, not mmap */
14826c6d281SJoe Perches #define ENABLE16flag 0x80 /* (for 90xx) Enable 16-bit mode */
14926c6d281SJoe Perches
15026c6d281SJoe Perches /* in the command register, the following bits have these meanings:
15126c6d281SJoe Perches * 0-2 command
15226c6d281SJoe Perches * 3-4 page number (for enable rcv/xmt command)
15326c6d281SJoe Perches * 7 receive broadcasts
15426c6d281SJoe Perches */
15526c6d281SJoe Perches #define NOTXcmd 0x01 /* disable transmitter */
15626c6d281SJoe Perches #define NORXcmd 0x02 /* disable receiver */
15726c6d281SJoe Perches #define TXcmd 0x03 /* enable transmitter */
15826c6d281SJoe Perches #define RXcmd 0x04 /* enable receiver */
15926c6d281SJoe Perches #define CONFIGcmd 0x05 /* define configuration */
16026c6d281SJoe Perches #define CFLAGScmd 0x06 /* clear flags */
16126c6d281SJoe Perches #define TESTcmd 0x07 /* load test flags */
16284286f19SMichael Grzeschik #define STARTIOcmd 0x18 /* start internal operation */
16326c6d281SJoe Perches
16426c6d281SJoe Perches /* flags for "clear flags" command */
16526c6d281SJoe Perches #define RESETclear 0x08 /* power-on-reset */
16626c6d281SJoe Perches #define CONFIGclear 0x10 /* system reconfigured */
16726c6d281SJoe Perches
16826c6d281SJoe Perches #define EXCNAKclear 0x0E /* Clear and acknowledge the excive nak bit */
16926c6d281SJoe Perches
17026c6d281SJoe Perches /* flags for "load test flags" command */
17126c6d281SJoe Perches #define TESTload 0x08 /* test flag (diagnostic) */
17226c6d281SJoe Perches
17326c6d281SJoe Perches /* byte deposited into first address of buffers on reset */
17426c6d281SJoe Perches #define TESTvalue 0321 /* that's octal for 0xD1 :) */
17526c6d281SJoe Perches
17626c6d281SJoe Perches /* for "enable receiver" command */
17726c6d281SJoe Perches #define RXbcasts 0x80 /* receive broadcasts */
17826c6d281SJoe Perches
17926c6d281SJoe Perches /* flags for "define configuration" command */
18026c6d281SJoe Perches #define NORMALconf 0x00 /* 1-249 byte packets */
18126c6d281SJoe Perches #define EXTconf 0x08 /* 250-504 byte packets */
18226c6d281SJoe Perches
18326c6d281SJoe Perches /* card feature flags, set during auto-detection.
18426c6d281SJoe Perches * (currently only used by com20020pci)
18526c6d281SJoe Perches */
18626c6d281SJoe Perches #define ARC_IS_5MBIT 1 /* card default speed is 5MBit */
18726c6d281SJoe Perches #define ARC_CAN_10MBIT 2 /* card uses COM20022, supporting 10MBit,
18826c6d281SJoe Perches but default is 2.5MBit. */
189*5106d7adSThomas Reichinger #define ARC_HAS_LED 4 /* card has software controlled LEDs */
190*5106d7adSThomas Reichinger #define ARC_HAS_ROTARY 8 /* card has rotary encoder */
19126c6d281SJoe Perches
19226c6d281SJoe Perches /* information needed to define an encapsulation driver */
19326c6d281SJoe Perches struct ArcProto {
19426c6d281SJoe Perches char suffix; /* a for RFC1201, e for ether-encap, etc. */
19526c6d281SJoe Perches int mtu; /* largest possible packet */
19626c6d281SJoe Perches int is_ip; /* This is a ip plugin - not a raw thing */
19726c6d281SJoe Perches
19826c6d281SJoe Perches void (*rx)(struct net_device *dev, int bufnum,
19926c6d281SJoe Perches struct archdr *pkthdr, int length);
20026c6d281SJoe Perches int (*build_header)(struct sk_buff *skb, struct net_device *dev,
20126c6d281SJoe Perches unsigned short ethproto, uint8_t daddr);
20226c6d281SJoe Perches
20326c6d281SJoe Perches /* these functions return '1' if the skb can now be freed */
20426c6d281SJoe Perches int (*prepare_tx)(struct net_device *dev, struct archdr *pkt,
20526c6d281SJoe Perches int length, int bufnum);
20626c6d281SJoe Perches int (*continue_tx)(struct net_device *dev, int bufnum);
20726c6d281SJoe Perches int (*ack_tx)(struct net_device *dev, int acked);
20826c6d281SJoe Perches };
20926c6d281SJoe Perches
21026c6d281SJoe Perches extern struct ArcProto *arc_proto_map[256], *arc_proto_default,
21126c6d281SJoe Perches *arc_bcast_proto, *arc_raw_proto;
21226c6d281SJoe Perches
21326c6d281SJoe Perches /*
21426c6d281SJoe Perches * "Incoming" is information needed for each address that could be sending
21526c6d281SJoe Perches * to us. Mostly for partially-received split packets.
21626c6d281SJoe Perches */
21726c6d281SJoe Perches struct Incoming {
21826c6d281SJoe Perches struct sk_buff *skb; /* packet data buffer */
21926c6d281SJoe Perches __be16 sequence; /* sequence number of assembly */
22026c6d281SJoe Perches uint8_t lastpacket, /* number of last packet (from 1) */
22126c6d281SJoe Perches numpackets; /* number of packets in split */
22226c6d281SJoe Perches };
22326c6d281SJoe Perches
22426c6d281SJoe Perches /* only needed for RFC1201 */
22526c6d281SJoe Perches struct Outgoing {
22626c6d281SJoe Perches struct ArcProto *proto; /* protocol driver that owns this:
22726c6d281SJoe Perches * if NULL, no packet is pending.
22826c6d281SJoe Perches */
22926c6d281SJoe Perches struct sk_buff *skb; /* buffer from upper levels */
23026c6d281SJoe Perches struct archdr *pkt; /* a pointer into the skb */
23126c6d281SJoe Perches uint16_t length, /* bytes total */
23226c6d281SJoe Perches dataleft, /* bytes left */
23326c6d281SJoe Perches segnum, /* segment being sent */
23426c6d281SJoe Perches numsegs; /* number of segments */
23526c6d281SJoe Perches };
23626c6d281SJoe Perches
2378890624aSMichael Grzeschik #define ARCNET_LED_NAME_SZ (IFNAMSIZ + 6)
2388890624aSMichael Grzeschik
23926c6d281SJoe Perches struct arcnet_local {
24026c6d281SJoe Perches uint8_t config, /* current value of CONFIG register */
24126c6d281SJoe Perches timeout, /* Extended timeout for COM20020 */
24226c6d281SJoe Perches backplane, /* Backplane flag for COM20020 */
24326c6d281SJoe Perches clockp, /* COM20020 clock divider */
24426c6d281SJoe Perches clockm, /* COM20020 clock multiplier flag */
24526c6d281SJoe Perches setup, /* Contents of setup1 register */
24626c6d281SJoe Perches setup2, /* Contents of setup2 register */
24726c6d281SJoe Perches intmask; /* current value of INTMASK register */
24826c6d281SJoe Perches uint8_t default_proto[256]; /* default encap to use for each host */
24926c6d281SJoe Perches int cur_tx, /* buffer used by current transmit, or -1 */
25026c6d281SJoe Perches next_tx, /* buffer where a packet is ready to send */
25126c6d281SJoe Perches cur_rx; /* current receive buffer */
25226c6d281SJoe Perches int lastload_dest, /* can last loaded packet be acked? */
25326c6d281SJoe Perches lasttrans_dest; /* can last TX'd packet be acked? */
25426c6d281SJoe Perches int timed_out; /* need to process TX timeout and drop packet */
25526c6d281SJoe Perches unsigned long last_timeout; /* time of last reported timeout */
25626c6d281SJoe Perches char *card_name; /* card ident string */
25726c6d281SJoe Perches int card_flags; /* special card features */
25826c6d281SJoe Perches
25926c6d281SJoe Perches /* On preemtive and SMB a lock is needed */
26026c6d281SJoe Perches spinlock_t lock;
26126c6d281SJoe Perches
2628890624aSMichael Grzeschik struct led_trigger *tx_led_trig;
2638890624aSMichael Grzeschik char tx_led_trig_name[ARCNET_LED_NAME_SZ];
2648890624aSMichael Grzeschik struct led_trigger *recon_led_trig;
2658890624aSMichael Grzeschik char recon_led_trig_name[ARCNET_LED_NAME_SZ];
2668890624aSMichael Grzeschik
26759fbcbc6SMichael Grzeschik struct timer_list timer;
26859fbcbc6SMichael Grzeschik
26905fcd31cSMichael Grzeschik struct net_device *dev;
27005fcd31cSMichael Grzeschik int reply_status;
27105fcd31cSMichael Grzeschik struct tasklet_struct reply_tasklet;
27205fcd31cSMichael Grzeschik
27326c6d281SJoe Perches /*
27426c6d281SJoe Perches * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
27526c6d281SJoe Perches * which can be used for either sending or receiving. The new dynamic
27626c6d281SJoe Perches * buffer management routines use a simple circular queue of available
27726c6d281SJoe Perches * buffers, and take them as they're needed. This way, we simplify
27826c6d281SJoe Perches * situations in which we (for example) want to pre-load a transmit
27926c6d281SJoe Perches * buffer, or start receiving while we copy a received packet to
28026c6d281SJoe Perches * memory.
28126c6d281SJoe Perches *
28226c6d281SJoe Perches * The rules: only the interrupt handler is allowed to _add_ buffers to
28326c6d281SJoe Perches * the queue; thus, this doesn't require a lock. Both the interrupt
28426c6d281SJoe Perches * handler and the transmit function will want to _remove_ buffers, so
28526c6d281SJoe Perches * we need to handle the situation where they try to do it at the same
28626c6d281SJoe Perches * time.
28726c6d281SJoe Perches *
28826c6d281SJoe Perches * If next_buf == first_free_buf, the queue is empty. Since there are
28926c6d281SJoe Perches * only four possible buffers, the queue should never be full.
29026c6d281SJoe Perches */
29126c6d281SJoe Perches atomic_t buf_lock;
29226c6d281SJoe Perches int buf_queue[5];
29326c6d281SJoe Perches int next_buf, first_free_buf;
29426c6d281SJoe Perches
29526c6d281SJoe Perches /* network "reconfiguration" handling */
29626c6d281SJoe Perches unsigned long first_recon; /* time of "first" RECON message to count */
29726c6d281SJoe Perches unsigned long last_recon; /* time of most recent RECON */
29826c6d281SJoe Perches int num_recons; /* number of RECONs between first and last. */
29926c6d281SJoe Perches int network_down; /* do we think the network is down? */
30026c6d281SJoe Perches
30126c6d281SJoe Perches int excnak_pending; /* We just got an excesive nak interrupt */
30226c6d281SJoe Perches
30301365633SAhmed S. Darwish /* RESET flag handling */
30401365633SAhmed S. Darwish int reset_in_progress;
30501365633SAhmed S. Darwish struct work_struct reset_work;
30601365633SAhmed S. Darwish
30726c6d281SJoe Perches struct {
30826c6d281SJoe Perches uint16_t sequence; /* sequence number (incs with each packet) */
30926c6d281SJoe Perches __be16 aborted_seq;
31026c6d281SJoe Perches
31126c6d281SJoe Perches struct Incoming incoming[256]; /* one from each address */
31226c6d281SJoe Perches } rfc1201;
31326c6d281SJoe Perches
31426c6d281SJoe Perches /* really only used by rfc1201, but we'll pretend it's not */
31526c6d281SJoe Perches struct Outgoing outgoing; /* packet currently being sent */
31626c6d281SJoe Perches
31726c6d281SJoe Perches /* hardware-specific functions */
31826c6d281SJoe Perches struct {
31926c6d281SJoe Perches struct module *owner;
32026c6d281SJoe Perches void (*command)(struct net_device *dev, int cmd);
32126c6d281SJoe Perches int (*status)(struct net_device *dev);
32226c6d281SJoe Perches void (*intmask)(struct net_device *dev, int mask);
32326c6d281SJoe Perches int (*reset)(struct net_device *dev, int really_reset);
32426c6d281SJoe Perches void (*open)(struct net_device *dev);
32526c6d281SJoe Perches void (*close)(struct net_device *dev);
3268890624aSMichael Grzeschik void (*datatrigger) (struct net_device * dev, int enable);
3278890624aSMichael Grzeschik void (*recontrigger) (struct net_device * dev, int enable);
32826c6d281SJoe Perches
32926c6d281SJoe Perches void (*copy_to_card)(struct net_device *dev, int bufnum,
33026c6d281SJoe Perches int offset, void *buf, int count);
33126c6d281SJoe Perches void (*copy_from_card)(struct net_device *dev, int bufnum,
33226c6d281SJoe Perches int offset, void *buf, int count);
33326c6d281SJoe Perches } hw;
33426c6d281SJoe Perches
33526c6d281SJoe Perches void __iomem *mem_start; /* pointer to ioremap'ed MMIO */
33626c6d281SJoe Perches };
33726c6d281SJoe Perches
3388890624aSMichael Grzeschik enum arcnet_led_event {
3398890624aSMichael Grzeschik ARCNET_LED_EVENT_RECON,
3408890624aSMichael Grzeschik ARCNET_LED_EVENT_OPEN,
3418890624aSMichael Grzeschik ARCNET_LED_EVENT_STOP,
3428890624aSMichael Grzeschik ARCNET_LED_EVENT_TX,
3438890624aSMichael Grzeschik };
3448890624aSMichael Grzeschik
3458890624aSMichael Grzeschik void arcnet_led_event(struct net_device *netdev, enum arcnet_led_event event);
3468890624aSMichael Grzeschik void devm_arcnet_led_init(struct net_device *netdev, int index, int subid);
3478890624aSMichael Grzeschik
34826c6d281SJoe Perches #if ARCNET_DEBUG_MAX & D_SKB
34926c6d281SJoe Perches void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
35026c6d281SJoe Perches #else
35126c6d281SJoe Perches static inline
arcnet_dump_skb(struct net_device * dev,struct sk_buff * skb,char * desc)35226c6d281SJoe Perches void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc)
35326c6d281SJoe Perches {
35426c6d281SJoe Perches }
35526c6d281SJoe Perches #endif
35626c6d281SJoe Perches
35726c6d281SJoe Perches void arcnet_unregister_proto(struct ArcProto *proto);
35826c6d281SJoe Perches irqreturn_t arcnet_interrupt(int irq, void *dev_id);
35901365633SAhmed S. Darwish
36026c6d281SJoe Perches struct net_device *alloc_arcdev(const char *name);
36101365633SAhmed S. Darwish void free_arcdev(struct net_device *dev);
36226c6d281SJoe Perches
36326c6d281SJoe Perches int arcnet_open(struct net_device *dev);
36426c6d281SJoe Perches int arcnet_close(struct net_device *dev);
36526c6d281SJoe Perches netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
36626c6d281SJoe Perches struct net_device *dev);
3670290bd29SMichael S. Tsirkin void arcnet_timeout(struct net_device *dev, unsigned int txqueue);
36826c6d281SJoe Perches
arcnet_set_addr(struct net_device * dev,u8 addr)36913b5ffa0SJakub Kicinski static inline void arcnet_set_addr(struct net_device *dev, u8 addr)
37013b5ffa0SJakub Kicinski {
37113b5ffa0SJakub Kicinski dev_addr_set(dev, &addr);
37213b5ffa0SJakub Kicinski }
37313b5ffa0SJakub Kicinski
374e5fcfc1fSJoe Perches /* I/O equivalents */
375e5fcfc1fSJoe Perches
3760fec6513SJoe Perches #ifdef CONFIG_SA1100_CT6001
3770fec6513SJoe Perches #define BUS_ALIGN 2 /* 8 bit device on a 16 bit bus - needs padding */
3780fec6513SJoe Perches #else
3790fec6513SJoe Perches #define BUS_ALIGN 1
3800fec6513SJoe Perches #endif
3810fec6513SJoe Perches
382e5fcfc1fSJoe Perches /* addr and offset allow register like names to define the actual IO address.
383e5fcfc1fSJoe Perches * A configuration option multiplies the offset for alignment.
384e5fcfc1fSJoe Perches */
385e5fcfc1fSJoe Perches #define arcnet_inb(addr, offset) \
3860fec6513SJoe Perches inb((addr) + BUS_ALIGN * (offset))
387e5fcfc1fSJoe Perches #define arcnet_outb(value, addr, offset) \
3880fec6513SJoe Perches outb(value, (addr) + BUS_ALIGN * (offset))
389e5fcfc1fSJoe Perches
390e5fcfc1fSJoe Perches #define arcnet_insb(addr, offset, buffer, count) \
3910fec6513SJoe Perches insb((addr) + BUS_ALIGN * (offset), buffer, count)
392e5fcfc1fSJoe Perches #define arcnet_outsb(addr, offset, buffer, count) \
3930fec6513SJoe Perches outsb((addr) + BUS_ALIGN * (offset), buffer, count)
394e5fcfc1fSJoe Perches
3959c76aa55SJoe Perches #define arcnet_readb(addr, offset) \
3969c76aa55SJoe Perches readb((addr) + (offset))
3979c76aa55SJoe Perches #define arcnet_writeb(value, addr, offset) \
3989c76aa55SJoe Perches writeb(value, (addr) + (offset))
3999c76aa55SJoe Perches
40026c6d281SJoe Perches #endif /* __KERNEL__ */
40126c6d281SJoe Perches #endif /* _LINUX_ARCDEVICE_H */
402