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