1 /*
2 * Copyright (C) 1997 Cullen Jennings
3 * Copyright (C) 1998 Elmer.Joandi@ut.ee, +37-255-13500
4 * Gnu Public License applies
5 */
6 #include <linux/version.h>
7
8 #include <linux/module.h>
9 #include <linux/config.h>
10 #include <linux/kernel.h>
11 #include <linux/types.h>
12 #include <linux/skbuff.h>
13 #include <linux/if_ether.h> /* For the statistics structure. */
14 #include <linux/if_arp.h> /* For ARPHRD_ETHER */
15 #include <linux/ptrace.h>
16 #include <linux/ioport.h>
17 #include <linux/in.h>
18 #include <linux/malloc.h>
19 #include <linux/string.h>
20 #include <linux/timer.h>
21
22 #include <linux/init.h>
23 #include <asm/system.h>
24 #include <asm/bitops.h>
25 #include <asm/io.h>
26 #include <linux/errno.h>
27 #include <linux/delay.h>
28 #include <linux/netdevice.h>
29 #include <linux/etherdevice.h>
30
31
32 //#define ARLAN_DEBUGING 1
33
34 #define ARLAN_PROC_INTERFACE
35 #define MAX_ARLANS 4 /* not more than 4 ! */
36 #define ARLAN_PROC_SHM_DUMP /* shows all card registers, makes driver way larger */
37
38 #define ARLAN_MAX_MULTICAST_ADDRS 16
39 #define ARLAN_RCV_CLEAN 0
40 #define ARLAN_RCV_PROMISC 1
41 #define ARLAN_RCV_CONTROL 2
42
43
44 #ifdef CONFIG_PROC_FS
45 extern int init_arlan_proc(void);
46 #endif
47
48 extern struct net_device *arlan_device[MAX_ARLANS];
49 extern int arlan_debug;
50 extern char * siteName;
51 extern int arlan_entry_debug;
52 extern int arlan_exit_debug;
53 extern int arlan_entry_and_exit_debug;
54 extern int testMemory;
55 extern const char* arlan_version;
56 extern int arlan_command(struct net_device * dev, int command);
57
58 #define SIDUNKNOWN -1
59 #define radioNodeIdUNKNOWN -1
60 #define encryptionKeyUNKNOWN '\0';
61 #define irqUNKNOWN 0
62 #define memUNKNOWN 0
63 #define debugUNKNOWN 0
64 #define probeUNKNOWN 1
65 #define numDevicesUNKNOWN 1
66 #define testMemoryUNKNOWN 1
67 #define spreadingCodeUNKNOWN 0
68 #define channelNumberUNKNOWN 0
69 #define channelSetUNKNOWN 0
70 #define systemIdUNKNOWN -1
71 #define registrationModeUNKNOWN -1
72 #define siteNameUNKNOWN "LinuxSite"
73
74
75
76 #define IFDEBUG( L ) if ( (L) & arlan_debug )
77 #define ARLAN_FAKE_HDR_LEN 12
78
79 #ifdef ARLAN_DEBUGING
80 #define DEBUG 1
81 #define ARLAN_ENTRY_EXIT_DEBUGING 1
82 #define ARLAN_DEBUG(a,b) printk(KERN_DEBUG a, b)
83 #else
84 #define ARLAN_DEBUG(a,b)
85 #endif
86
87 struct arlan_shmem
88 {
89 /* Header Signature */
90 volatile char textRegion[48];
91 volatile u_char resetFlag;
92 volatile u_char diagnosticInfo;
93 volatile u_short diagnosticOffset;
94 volatile u_char _1[12];
95 volatile u_char lanCardNodeId[6];
96 volatile u_char broadcastAddress[6];
97 volatile u_char hardwareType;
98 volatile u_char majorHardwareVersion;
99 volatile u_char minorHardwareVersion;
100 volatile u_char radioModule;// shows EEPROM, can be overridden at 0x111
101 volatile u_char defaultChannelSet; // shows EEProm, can be overriiden at 0x10A
102 volatile u_char _2[47];
103
104 /* Control/Status Block - 0x0080 */
105 volatile u_char interruptInProgress; /* not used by lancpu */
106 volatile u_char cntrlRegImage; /* not used by lancpu */
107 volatile u_char _3[13];
108 volatile u_char dumpByte;
109 volatile u_char commandByte; /* non-zero = active */
110 volatile u_char commandParameter[15];
111
112 /* Receive Status - 0x00a0 */
113 volatile u_char rxStatus; /* 1- data, 2-control, 0xff - registr change */
114 volatile u_char rxFrmType;
115 volatile u_short rxOffset;
116 volatile u_short rxLength;
117 volatile u_char rxSrc[6];
118 volatile u_char rxBroadcastFlag;
119 volatile u_char rxQuality;
120 volatile u_char scrambled;
121 volatile u_char _4[1];
122
123 /* Transmit Status - 0x00b0 */
124 volatile u_char txStatus;
125 volatile u_char txAckQuality;
126 volatile u_char numRetries;
127 volatile u_char _5[14];
128 volatile u_char registeredRouter[6];
129 volatile u_char backboneRouter[6];
130 volatile u_char registrationStatus;
131 volatile u_char configuredStatusFlag;
132 volatile u_char _6[1];
133 volatile u_char ultimateDestAddress[6];
134 volatile u_char immedDestAddress[6];
135 volatile u_char immedSrcAddress[6];
136 volatile u_short rxSequenceNumber;
137 volatile u_char assignedLocaltalkAddress;
138 volatile u_char _7[27];
139
140 /* System Parameter Block */
141
142 /* - Driver Parameters (Novell Specific) */
143
144 volatile u_short txTimeout;
145 volatile u_short transportTime;
146 volatile u_char _8[4];
147
148 /* - Configuration Parameters */
149 volatile u_char irqLevel;
150 volatile u_char spreadingCode;
151 volatile u_char channelSet;
152 volatile u_char channelNumber;
153 volatile u_short radioNodeId;
154 volatile u_char _9[2];
155 volatile u_char scramblingDisable;
156 volatile u_char radioType;
157 volatile u_short routerId;
158 volatile u_char _10[9];
159 volatile u_char txAttenuation;
160 volatile u_char systemId[4];
161 volatile u_short globalChecksum;
162 volatile u_char _11[4];
163 volatile u_short maxDatagramSize;
164 volatile u_short maxFrameSize;
165 volatile u_char maxRetries;
166 volatile u_char receiveMode;
167 volatile u_char priority;
168 volatile u_char rootOrRepeater;
169 volatile u_char specifiedRouter[6];
170 volatile u_short fastPollPeriod;
171 volatile u_char pollDecay;
172 volatile u_char fastPollDelay[2];
173 volatile u_char arlThreshold;
174 volatile u_char arlDecay;
175 volatile u_char _12[1];
176 volatile u_short specRouterTimeout;
177 volatile u_char _13[5];
178
179 /* Scrambled Area */
180 volatile u_char SID[4];
181 volatile u_char encryptionKey[12];
182 volatile u_char _14[2];
183 volatile u_char waitTime[2];
184 volatile u_char lParameter[2];
185 volatile u_char _15[3];
186 volatile u_short headerSize;
187 volatile u_short sectionChecksum;
188
189 volatile u_char registrationMode;
190 volatile u_char registrationFill;
191 volatile u_short pollPeriod;
192 volatile u_short refreshPeriod;
193 volatile u_char name[16];
194 volatile u_char NID[6];
195 volatile u_char localTalkAddress;
196 volatile u_char codeFormat;
197 volatile u_char numChannels;
198 volatile u_char channel1;
199 volatile u_char channel2;
200 volatile u_char channel3;
201 volatile u_char channel4;
202 volatile u_char SSCode[59];
203
204 volatile u_char _16[0xC0];
205 volatile u_short auxCmd;
206 volatile u_char dumpPtr[4];
207 volatile u_char dumpVal;
208 volatile u_char _17[0x6A];
209 volatile u_char wireTest;
210 volatile u_char _18[14];
211
212 /* Statistics Block - 0x0300 */
213 volatile u_char hostcpuLock;
214 volatile u_char lancpuLock;
215 volatile u_char resetTime[18];
216
217 volatile u_char numDatagramsTransmitted[4];
218 volatile u_char numReTransmissions[4];
219 volatile u_char numFramesDiscarded[4];
220 volatile u_char numDatagramsReceived[4];
221 volatile u_char numDuplicateReceivedFrames[4];
222 volatile u_char numDatagramsDiscarded[4];
223
224 volatile u_short maxNumReTransmitDatagram;
225 volatile u_short maxNumReTransmitFrames;
226 volatile u_short maxNumConsecutiveDuplicateFrames;
227 /* misaligned here so we have to go to characters */
228
229 volatile u_char numBytesTransmitted[4];
230 volatile u_char numBytesReceived[4];
231 volatile u_char numCRCErrors[4];
232 volatile u_char numLengthErrors[4];
233 volatile u_char numAbortErrors[4];
234 volatile u_char numTXUnderruns[4];
235 volatile u_char numRXOverruns[4];
236 volatile u_char numHoldOffs[4];
237 volatile u_char numFramesTransmitted[4];
238 volatile u_char numFramesReceived[4];
239 volatile u_char numReceiveFramesLost[4];
240 volatile u_char numRXBufferOverflows[4];
241 volatile u_char numFramesDiscardedAddrMismatch[4];
242 volatile u_char numFramesDiscardedSIDMismatch[4];
243 volatile u_char numPollsTransmistted[4];
244 volatile u_char numPollAcknowledges[4];
245 volatile u_char numStatusTimeouts[4];
246 volatile u_char numNACKReceived[4];
247
248 volatile u_char _19[0x86];
249
250 volatile u_char txBuffer[0x800];
251 volatile u_char rxBuffer[0x800];
252
253 volatile u_char _20[0x800];
254 volatile u_char _21[0x3fb];
255 volatile u_char configStatus;
256 volatile u_char _22;
257 volatile u_char progIOCtrl;
258 volatile u_char shareMBase;
259 volatile u_char controlRegister;
260 };
261
262 struct arlan_conf_stru {
263 int spreadingCode;
264 int channelSet;
265 int channelNumber;
266 int scramblingDisable;
267 int txAttenuation;
268 int systemId;
269 int maxDatagramSize;
270 int maxFrameSize;
271 int maxRetries;
272 int receiveMode;
273 int priority;
274 int rootOrRepeater;
275 int SID;
276 int radioNodeId;
277 int registrationMode;
278 int registrationFill;
279 int localTalkAddress;
280 int codeFormat;
281 int numChannels;
282 int channel1;
283 int channel2;
284 int channel3;
285 int channel4;
286 int txClear;
287 int txRetries;
288 int txRouting;
289 int txScrambled;
290 int rxParameter;
291 int txTimeoutMs;
292 int txAckTimeoutMs;
293 int waitCardTimeout;
294 int waitTime;
295 int lParameter;
296 int _15;
297 int headerSize;
298 int async;
299 int retries;
300 int tx_delay_ms;
301 int waitReTransmitPacketMaxSize;
302 int ReTransmitPacketMaxSize;
303 int fastReTransCount;
304 int driverRetransmissions;
305 int registrationInterrupts;
306 int hardwareType;
307 int radioType;
308 int writeRadioType;
309 int writeEEPROM;
310 char siteName[17];
311 int measure_rate;
312 int in_speed;
313 int out_speed;
314 int in_speed10;
315 int out_speed10;
316 int in_speed_max;
317 int out_speed_max;
318 int pre_Command_Wait;
319 int rx_tweak1;
320 int rx_tweak2;
321 int tx_queue_len;
322 };
323
324 struct arlan_conf_stru arlan_conf[MAX_ARLANS];
325
326 struct TxParam
327 {
328 volatile short offset;
329 volatile short length;
330 volatile u_char dest[6];
331 volatile unsigned char clear;
332 volatile unsigned char retries;
333 volatile unsigned char routing;
334 volatile unsigned char scrambled;
335 };
336
337 struct TxRingPoint {
338 struct TxParam txParam;
339
340
341 };
342
343 #define TX_RING_SIZE 2
344 /* Information that need to be kept for each board. */
345 struct arlan_private {
346 struct net_device_stats stats;
347 long open_time; /* Useless example local info. */
348 struct arlan_shmem * card;
349 struct arlan_shmem * conf;
350 struct TxParam txParam;
351 int multicastLength;
352 char multicastList[ARLAN_MAX_MULTICAST_ADDRS][6];
353 int promiscModeEnabled;
354 struct arlan_conf_stru * Conf;
355 int bad;
356 int reset;
357 long long lastReset;
358 struct timer_list timer;
359 struct timer_list tx_delay_timer;
360 struct timer_list tx_retry_timer;
361 struct timer_list rx_check_timer;
362 struct semaphore card_lock;
363 atomic_t card_users;
364 atomic_t delay_on;
365 atomic_t retr_on;
366 int registrationLostCount;
367 int reRegisterExp;
368 int nof_tx;
369 int nof_tx_ack;
370 int last_nof_tx;
371 int last_nof_tx_ack;
372 int irq_test_done;
373 int last_command_was_rx;
374 struct TxParam txRing[TX_RING_SIZE];
375 char reTransmitBuff[0x800];
376 volatile int txLast;
377 volatile int txNew;
378 volatile int txOffset;
379 volatile char ReTransmitRequested;
380 volatile long long tx_done_delayed;
381 volatile long long registrationLastSeen;
382 volatile char under_command;
383 volatile char under_toggle;
384 volatile long long tx_last_sent;
385 volatile long long tx_last_cleared;
386 volatile u_char under_tx;
387 volatile int retransmissions;
388 volatile int tx_chain_active;
389 volatile int timer_chain_active;
390 volatile int interrupt_ack_requested;
391 volatile long command_lock;
392 volatile int rx_command_needed;
393 volatile int tx_command_needed;
394 volatile int waiting_command_mask;
395 volatile int card_polling_interval;
396 volatile int last_command_buff_free_time;
397 volatile int numResets;
398 volatile int under_reset;
399 volatile int under_config;
400 volatile int rx_command_given;
401 volatile long tx_command_given;
402 volatile long interrupt_processing_active;
403 volatile long long last_tx_time;
404 volatile long long last_rx_time;
405 volatile long long last_rx_int_ack_time;
406 int in_bytes;
407 int out_bytes;
408 int in_time;
409 int out_time;
410 int in_time10;
411 int out_time10;
412 int in_bytes10;
413 int out_bytes10;
414 };
415
416
417
418 #define ARLAN_CLEAR 0x00
419 #define ARLAN_RESET 0x01
420 #define ARLAN_CHANNEL_ATTENTION 0x02
421 #define ARLAN_INTERRUPT_ENABLE 0x04
422 #define ARLAN_CLEAR_INTERRUPT 0x08
423 #define ARLAN_POWER 0x40
424 #define ARLAN_ACCESS 0x80
425
426 #define ARLAN_COM_CONF 0x01
427 #define ARLAN_COM_RX_ENABLE 0x03
428 #define ARLAN_COM_RX_ABORT 0x04
429 #define ARLAN_COM_TX_ENABLE 0x05
430 #define ARLAN_COM_TX_ABORT 0x06
431 #define ARLAN_COM_NOP 0x07
432 #define ARLAN_COM_STANDBY 0x08
433 #define ARLAN_COM_ACTIVATE 0x09
434 #define ARLAN_COM_GOTO_SLOW_POLL 0x0a
435 #define ARLAN_COM_INT 0x80
436
437
438 #define TXLAST(dev) (((struct arlan_private *)dev->priv)->txRing[((struct arlan_private *)dev->priv)->txLast])
439 #define TXHEAD(dev) (((struct arlan_private *)dev->priv)->txRing[0])
440 #define TXTAIL(dev) (((struct arlan_private *)dev->priv)->txRing[1])
441
442 #define TXBuffStart(dev) \
443 ((int)(((struct arlan_private *)dev->priv)->card)->txBuffer) - ((int)(((struct arlan_private *)dev->priv)->card) )
444 #define TXBuffEnd(dev) \
445 ((int)(((struct arlan_private *)dev->priv)->card)->rxBuffer) - ((int)(((struct arlan_private *)dev->priv)->card)
446
447 #define READSHM(to,from,atype) {\
448 atype tmp;\
449 memcpy_fromio(&(tmp),&(from),sizeof(atype));\
450 to = tmp;\
451 }
452
453 #define READSHMEM(from,atype)\
454 atype from; \
455 READSHM(from, arlan->from, atype);
456
457 #define WRITESHM(to,from,atype) \
458 { atype tmpSHM = from;\
459 memcpy_toio(&(to),&tmpSHM,sizeof(atype));\
460 }
461
462 #define DEBUGSHM(levelSHM,stringSHM,stuff,atype) \
463 { atype tmpSHM; \
464 memcpy_fromio(&tmpSHM,&(stuff),sizeof(atype));\
465 IFDEBUG(levelSHM) printk(stringSHM,tmpSHM);\
466 }
467
468 #define WRITESHMB(to, val) \
469 writeb(val,&(to))
470 #define READSHMB(to) \
471 readb(&(to))
472 #define WRITESHMS(to, val) \
473 writew(val,&(to))
474 #define READSHMS(to) \
475 readw(&(to))
476 #define WRITESHMI(to, val) \
477 writel(val,&(to))
478 #define READSHMI(to) \
479 readl(&(to))
480
481
482
483
484
485 #define registrationBad(dev)\
486 ( ( READSHMB(((struct arlan_private *)dev->priv)->card->registrationMode) > 0) && \
487 ( READSHMB(((struct arlan_private *)dev->priv)->card->registrationStatus) == 0) )
488
489
490 #define readControlRegister(dev)\
491 READSHMB(((struct arlan_private *)dev->priv)->card->cntrlRegImage)
492
493 #define writeControlRegister(dev, v){\
494 WRITESHMB(((struct arlan_private *)dev->priv)->card->cntrlRegImage ,((v) &0xF) );\
495 WRITESHMB(((struct arlan_private *)dev->priv)->card->controlRegister ,(v) );}
496
497
498 #define arlan_interrupt_lancpu(dev) {\
499 int cr; \
500 \
501 priv->under_toggle++; \
502 cr = readControlRegister(dev);\
503 if (cr & ARLAN_CHANNEL_ATTENTION){ \
504 writeControlRegister(dev, (cr & ~ARLAN_CHANNEL_ATTENTION));\
505 }else \
506 writeControlRegister(dev, (cr | ARLAN_CHANNEL_ATTENTION));\
507 priv->under_toggle=0; \
508 }
509
510 #define clearChannelAttention(dev){ \
511 writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_CHANNEL_ATTENTION);}
512 #define setHardwareReset(dev) {\
513 writeControlRegister(dev,readControlRegister(dev) | ARLAN_RESET);}
514 #define clearHardwareReset(dev) {\
515 writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_RESET);}
516 #define setInterruptEnable(dev){\
517 writeControlRegister(dev,readControlRegister(dev) | ARLAN_INTERRUPT_ENABLE) ;}
518 #define clearInterruptEnable(dev){\
519 writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_INTERRUPT_ENABLE) ;}
520 #define setClearInterrupt(dev){\
521 writeControlRegister(dev,readControlRegister(dev) | ARLAN_CLEAR_INTERRUPT) ;}
522 #define clearClearInterrupt(dev){\
523 writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_CLEAR_INTERRUPT);}
524 #define setPowerOff(dev){\
525 writeControlRegister(dev,readControlRegister(dev) | (ARLAN_POWER && ARLAN_ACCESS));\
526 writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_ACCESS);}
527 #define setPowerOn(dev){\
528 writeControlRegister(dev,readControlRegister(dev) & ~(ARLAN_POWER)); }
529 #define arlan_lock_card_access(dev){\
530 writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_ACCESS);}
531 #define arlan_unlock_card_access(dev){\
532 writeControlRegister(dev,readControlRegister(dev) | ARLAN_ACCESS ); }
533
534
535
536
537 #define ARLAN_COMMAND_RX 0x000001
538 #define ARLAN_COMMAND_NOOP 0x000002
539 #define ARLAN_COMMAND_NOOPINT 0x000004
540 #define ARLAN_COMMAND_TX 0x000008
541 #define ARLAN_COMMAND_CONF 0x000010
542 #define ARLAN_COMMAND_RESET 0x000020
543 #define ARLAN_COMMAND_TX_ABORT 0x000040
544 #define ARLAN_COMMAND_RX_ABORT 0x000080
545 #define ARLAN_COMMAND_POWERDOWN 0x000100
546 #define ARLAN_COMMAND_POWERUP 0x000200
547 #define ARLAN_COMMAND_SLOW_POLL 0x000400
548 #define ARLAN_COMMAND_ACTIVATE 0x000800
549 #define ARLAN_COMMAND_INT_ACK 0x001000
550 #define ARLAN_COMMAND_INT_ENABLE 0x002000
551 #define ARLAN_COMMAND_WAIT_NOW 0x004000
552 #define ARLAN_COMMAND_LONG_WAIT_NOW 0x008000
553 #define ARLAN_COMMAND_STANDBY 0x010000
554 #define ARLAN_COMMAND_INT_RACK 0x020000
555 #define ARLAN_COMMAND_INT_RENABLE 0x040000
556 #define ARLAN_COMMAND_CONF_WAIT 0x080000
557 #define ARLAN_COMMAND_TBUSY_CLEAR 0x100000
558 #define ARLAN_COMMAND_CLEAN_AND_CONF (ARLAN_COMMAND_TX_ABORT\
559 | ARLAN_COMMAND_RX_ABORT\
560 | ARLAN_COMMAND_CONF)
561 #define ARLAN_COMMAND_CLEAN_AND_RESET (ARLAN_COMMAND_TX_ABORT\
562 | ARLAN_COMMAND_RX_ABORT\
563 | ARLAN_COMMAND_RESET)
564
565
566
567 #define ARLAN_DEBUG_CHAIN_LOCKS 0x00001
568 #define ARLAN_DEBUG_RESET 0x00002
569 #define ARLAN_DEBUG_TIMING 0x00004
570 #define ARLAN_DEBUG_CARD_STATE 0x00008
571 #define ARLAN_DEBUG_TX_CHAIN 0x00010
572 #define ARLAN_DEBUG_MULTICAST 0x00020
573 #define ARLAN_DEBUG_HEADER_DUMP 0x00040
574 #define ARLAN_DEBUG_INTERRUPT 0x00080
575 #define ARLAN_DEBUG_STARTUP 0x00100
576 #define ARLAN_DEBUG_SHUTDOWN 0x00200
577
578
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.