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