^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * INET An implementation of the TCP/IP protocol suite for the LINUX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * operating system. NET is implemented using the BSD Socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * interface as the means of communication with the user level.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Definitions used by the ARCnet driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Authors: Avery Pennarun and David Woodhouse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #ifndef _LINUX_ARCDEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define _LINUX_ARCDEVICE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/timex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/if_arcnet.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * RECON_THRESHOLD is the maximum number of RECON messages to receive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * within one minute before printing a "cabling problem" warning. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * default value should be fine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * After that, a "cabling restored" message will be printed on the next IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * if no RECON messages have been received for 10 seconds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * Do not define RECON_THRESHOLD at all if you want to disable this feature.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define RECON_THRESHOLD 30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * Define this to the minimum "timeout" value. If a transmit takes longer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * than TX_TIMEOUT jiffies, Linux will abort the TX and retry. On a large
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * network, or one with heavy network traffic, this timeout may need to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * increased. The larger it is, though, the longer it will be between
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * necessary transmits - don't set this too high.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define TX_TIMEOUT (HZ * 200 / 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* Display warnings about the driver being an ALPHA version. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #undef ALPHA_WARNING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * Debugging bitflags: each option can be enabled individually.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * Note: only debug flags included in the ARCNET_DEBUG_MAX define will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * actually be available. GCC will (at least, GCC 2.7.0 will) notice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * lines using a BUGLVL not in ARCNET_DEBUG_MAX and automatically optimize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * them out.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define D_NORMAL 1 /* important operational info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define D_EXTRA 2 /* useful, but non-vital information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define D_INIT 4 /* show init/probe messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define D_INIT_REASONS 8 /* show reasons for discarding probes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define D_RECON 32 /* print a message whenever token is lost */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define D_PROTO 64 /* debug auto-protocol support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /* debug levels below give LOTS of output during normal operation! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define D_DURING 128 /* trace operations (including irq's) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define D_TX 256 /* show tx packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define D_RX 512 /* show rx packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define D_SKB 1024 /* show skb's */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define D_SKB_SIZE 2048 /* show skb sizes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define D_TIMING 4096 /* show time needed to copy buffers to card */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define D_DEBUG 8192 /* Very detailed debug line for line */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #ifndef ARCNET_DEBUG_MAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define ARCNET_DEBUG_MAX (127) /* change to ~0 if you want detailed debugging */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #ifndef ARCNET_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define ARCNET_DEBUG (D_NORMAL | D_EXTRA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) extern int arcnet_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define BUGLVL(x) ((x) & ARCNET_DEBUG_MAX & arcnet_debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* macros to simplify debug checking */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define arc_printk(x, dev, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) if (BUGLVL(x)) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) if ((x) == D_NORMAL) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) netdev_warn(dev, fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) else if ((x) < D_DURING) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) netdev_info(dev, fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) netdev_dbg(dev, fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define arc_cont(x, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) if (BUGLVL(x)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) pr_cont(fmt, ##__VA_ARGS__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* see how long a function call takes to run, expressed in CPU cycles */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define TIME(dev, name, bytes, call) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) if (BUGLVL(D_TIMING)) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) unsigned long _x, _y; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) _x = get_cycles(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) call; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) _y = get_cycles(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) arc_printk(D_TIMING, dev, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) "%s: %d bytes in %lu cycles == %lu Kbytes/100Mcycle\n", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) name, bytes, _y - _x, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 100000000 / 1024 * bytes / (_y - _x + 1)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) } else { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) call; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * Time needed to reset the card - in ms (milliseconds). This works on my
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * SMC PC100. I can't find a reference that tells me just how long I
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * should wait.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define RESETtime (300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * These are the max/min lengths of packet payload, not including the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * arc_hardware header, but definitely including the soft header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * Note: packet sizes 254, 255, 256 are impossible because of the way
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * ARCnet registers work That's why RFC1201 defines "exception" packets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * In non-RFC1201 protocols, we have to just tack some extra bytes on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * end.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define MTU 253 /* normal packet max size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define MinTU 257 /* extended packet min size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define XMTU 508 /* extended packet max size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* status/interrupt mask bit fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define TXFREEflag 0x01 /* transmitter available */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define TXACKflag 0x02 /* transmitted msg. ackd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define RECONflag 0x04 /* network reconfigured */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) #define TESTflag 0x08 /* test flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define EXCNAKflag 0x08 /* excesive nak flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #define RESETflag 0x10 /* power-on-reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #define RES1flag 0x20 /* reserved - usually set by jumper */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #define RES2flag 0x40 /* reserved - usually set by jumper */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #define NORXflag 0x80 /* receiver inhibited */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* Flags used for IO-mapped memory operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define AUTOINCflag 0x40 /* Increase location with each access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #define IOMAPflag 0x02 /* (for 90xx) Use IO mapped memory, not mmap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #define ENABLE16flag 0x80 /* (for 90xx) Enable 16-bit mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* in the command register, the following bits have these meanings:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * 0-2 command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * 3-4 page number (for enable rcv/xmt command)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * 7 receive broadcasts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define NOTXcmd 0x01 /* disable transmitter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #define NORXcmd 0x02 /* disable receiver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #define TXcmd 0x03 /* enable transmitter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #define RXcmd 0x04 /* enable receiver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #define CONFIGcmd 0x05 /* define configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #define CFLAGScmd 0x06 /* clear flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define TESTcmd 0x07 /* load test flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #define STARTIOcmd 0x18 /* start internal operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /* flags for "clear flags" command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #define RESETclear 0x08 /* power-on-reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #define CONFIGclear 0x10 /* system reconfigured */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #define EXCNAKclear 0x0E /* Clear and acknowledge the excive nak bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /* flags for "load test flags" command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #define TESTload 0x08 /* test flag (diagnostic) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* byte deposited into first address of buffers on reset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) #define TESTvalue 0321 /* that's octal for 0xD1 :) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /* for "enable receiver" command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #define RXbcasts 0x80 /* receive broadcasts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* flags for "define configuration" command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) #define NORMALconf 0x00 /* 1-249 byte packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) #define EXTconf 0x08 /* 250-504 byte packets */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) /* card feature flags, set during auto-detection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * (currently only used by com20020pci)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #define ARC_IS_5MBIT 1 /* card default speed is 5MBit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) #define ARC_CAN_10MBIT 2 /* card uses COM20022, supporting 10MBit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) but default is 2.5MBit. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) /* information needed to define an encapsulation driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) struct ArcProto {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) char suffix; /* a for RFC1201, e for ether-encap, etc. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) int mtu; /* largest possible packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) int is_ip; /* This is a ip plugin - not a raw thing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) void (*rx)(struct net_device *dev, int bufnum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct archdr *pkthdr, int length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) int (*build_header)(struct sk_buff *skb, struct net_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) unsigned short ethproto, uint8_t daddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) /* these functions return '1' if the skb can now be freed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) int (*prepare_tx)(struct net_device *dev, struct archdr *pkt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) int length, int bufnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) int (*continue_tx)(struct net_device *dev, int bufnum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) int (*ack_tx)(struct net_device *dev, int acked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) extern struct ArcProto *arc_proto_map[256], *arc_proto_default,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) *arc_bcast_proto, *arc_raw_proto;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * "Incoming" is information needed for each address that could be sending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * to us. Mostly for partially-received split packets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) struct Incoming {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct sk_buff *skb; /* packet data buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) __be16 sequence; /* sequence number of assembly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) uint8_t lastpacket, /* number of last packet (from 1) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) numpackets; /* number of packets in split */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /* only needed for RFC1201 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct Outgoing {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct ArcProto *proto; /* protocol driver that owns this:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * if NULL, no packet is pending.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) struct sk_buff *skb; /* buffer from upper levels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct archdr *pkt; /* a pointer into the skb */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) uint16_t length, /* bytes total */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) dataleft, /* bytes left */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) segnum, /* segment being sent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) numsegs; /* number of segments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) #define ARCNET_LED_NAME_SZ (IFNAMSIZ + 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) struct arcnet_local {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) uint8_t config, /* current value of CONFIG register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) timeout, /* Extended timeout for COM20020 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) backplane, /* Backplane flag for COM20020 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) clockp, /* COM20020 clock divider */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) clockm, /* COM20020 clock multiplier flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) setup, /* Contents of setup1 register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) setup2, /* Contents of setup2 register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) intmask; /* current value of INTMASK register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) uint8_t default_proto[256]; /* default encap to use for each host */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) int cur_tx, /* buffer used by current transmit, or -1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) next_tx, /* buffer where a packet is ready to send */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) cur_rx; /* current receive buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) int lastload_dest, /* can last loaded packet be acked? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) lasttrans_dest; /* can last TX'd packet be acked? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) int timed_out; /* need to process TX timeout and drop packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) unsigned long last_timeout; /* time of last reported timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) char *card_name; /* card ident string */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) int card_flags; /* special card features */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) /* On preemtive and SMB a lock is needed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct led_trigger *tx_led_trig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) char tx_led_trig_name[ARCNET_LED_NAME_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct led_trigger *recon_led_trig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) char recon_led_trig_name[ARCNET_LED_NAME_SZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct timer_list timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) struct net_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) int reply_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) struct tasklet_struct reply_tasklet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) * Buffer management: an ARCnet card has 4 x 512-byte buffers, each of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) * which can be used for either sending or receiving. The new dynamic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * buffer management routines use a simple circular queue of available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * buffers, and take them as they're needed. This way, we simplify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * situations in which we (for example) want to pre-load a transmit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * buffer, or start receiving while we copy a received packet to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) * memory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) * The rules: only the interrupt handler is allowed to _add_ buffers to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * the queue; thus, this doesn't require a lock. Both the interrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) * handler and the transmit function will want to _remove_ buffers, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * we need to handle the situation where they try to do it at the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * If next_buf == first_free_buf, the queue is empty. Since there are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) * only four possible buffers, the queue should never be full.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) atomic_t buf_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) int buf_queue[5];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) int next_buf, first_free_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) /* network "reconfiguration" handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) unsigned long first_recon; /* time of "first" RECON message to count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) unsigned long last_recon; /* time of most recent RECON */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) int num_recons; /* number of RECONs between first and last. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) int network_down; /* do we think the network is down? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) int excnak_pending; /* We just got an excesive nak interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) uint16_t sequence; /* sequence number (incs with each packet) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) __be16 aborted_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) struct Incoming incoming[256]; /* one from each address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) } rfc1201;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) /* really only used by rfc1201, but we'll pretend it's not */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) struct Outgoing outgoing; /* packet currently being sent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) /* hardware-specific functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) struct module *owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) void (*command)(struct net_device *dev, int cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) int (*status)(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) void (*intmask)(struct net_device *dev, int mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) int (*reset)(struct net_device *dev, int really_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) void (*open)(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) void (*close)(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) void (*datatrigger) (struct net_device * dev, int enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) void (*recontrigger) (struct net_device * dev, int enable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) void (*copy_to_card)(struct net_device *dev, int bufnum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) int offset, void *buf, int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) void (*copy_from_card)(struct net_device *dev, int bufnum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) int offset, void *buf, int count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) } hw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) void __iomem *mem_start; /* pointer to ioremap'ed MMIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) enum arcnet_led_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) ARCNET_LED_EVENT_RECON,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) ARCNET_LED_EVENT_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) ARCNET_LED_EVENT_STOP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) ARCNET_LED_EVENT_TX,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) void arcnet_led_event(struct net_device *netdev, enum arcnet_led_event event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) void devm_arcnet_led_init(struct net_device *netdev, int index, int subid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) #if ARCNET_DEBUG_MAX & D_SKB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) void arcnet_unregister_proto(struct ArcProto *proto);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) irqreturn_t arcnet_interrupt(int irq, void *dev_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) struct net_device *alloc_arcdev(const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) int arcnet_open(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) int arcnet_close(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) void arcnet_timeout(struct net_device *dev, unsigned int txqueue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) /* I/O equivalents */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) #ifdef CONFIG_SA1100_CT6001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #define BUS_ALIGN 2 /* 8 bit device on a 16 bit bus - needs padding */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) #define BUS_ALIGN 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /* addr and offset allow register like names to define the actual IO address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * A configuration option multiplies the offset for alignment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) #define arcnet_inb(addr, offset) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) inb((addr) + BUS_ALIGN * (offset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) #define arcnet_outb(value, addr, offset) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) outb(value, (addr) + BUS_ALIGN * (offset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) #define arcnet_insb(addr, offset, buffer, count) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) insb((addr) + BUS_ALIGN * (offset), buffer, count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) #define arcnet_outsb(addr, offset, buffer, count) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) outsb((addr) + BUS_ALIGN * (offset), buffer, count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) #define arcnet_readb(addr, offset) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) readb((addr) + (offset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) #define arcnet_writeb(value, addr, offset) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) writeb(value, (addr) + (offset))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) #endif /* __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) #endif /* _LINUX_ARCDEVICE_H */