blob: a2cca521f4449b29825ca076ca184bf3515cef41 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/config.h>
2#include "arlan.h"
3
4#include <linux/sysctl.h>
5
6#ifdef CONFIG_PROC_FS
7
8/* void enableReceive(struct net_device* dev);
9*/
10
11
12
13#define ARLAN_STR_SIZE 0x2ff0
14#define DEV_ARLAN_INFO 1
15#define DEV_ARLAN 1
16#define SARLG(type,var) {\
17 pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n", #var, READSHMB(priva->card->var)); \
18 }
19
20#define SARLBN(type,var,nn) {\
21 pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x",#var);\
22 for (i=0; i < nn; i++ ) pos += sprintf(arlan_drive_info+pos, "%02x",READSHMB(priva->card->var[i]));\
23 pos += sprintf(arlan_drive_info+pos, "\n"); \
24 }
25
26#define SARLBNpln(type,var,nn) {\
27 for (i=0; i < nn; i++ ) pos += sprintf(arlan_drive_info+pos, "%02x",READSHMB(priva->card->var[i]));\
28 }
29
30#define SARLSTR(var,nn) {\
31 char tmpStr[400];\
32 int tmpLn = nn;\
33 if (nn > 399 ) tmpLn = 399; \
34 memcpy(tmpStr,(char *) priva->conf->var,tmpLn);\
35 tmpStr[tmpLn] = 0; \
36 pos += sprintf(arlan_drive_info+pos, "%s\t=\t%s \n",#var,priva->conf->var);\
37 }
38
39#define SARLUC(var) SARLG(u_char, var)
40#define SARLUCN(var,nn) SARLBN(u_char,var, nn)
41#define SARLUS(var) SARLG(u_short, var)
42#define SARLUSN(var,nn) SARLBN(u_short,var, nn)
43#define SARLUI(var) SARLG(u_int, var)
44
45#define SARLUSA(var) {\
46 u_short tmpVar;\
47 memcpy(&tmpVar, (short *) priva->conf->var,2); \
48 pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n",#var, tmpVar);\
49}
50
51#define SARLUIA(var) {\
52 u_int tmpVar;\
53 memcpy(&tmpVar, (int* )priva->conf->var,4); \
54 pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n",#var, tmpVar);\
55}
56
57
58static const char *arlan_diagnostic_info_string(struct net_device *dev)
59{
60
61 struct arlan_private *priv = netdev_priv(dev);
62 volatile struct arlan_shmem __iomem *arlan = priv->card;
63 u_char diagnosticInfo;
64
65 READSHM(diagnosticInfo, arlan->diagnosticInfo, u_char);
66
67 switch (diagnosticInfo)
68 {
69 case 0xFF:
70 return "Diagnostic info is OK";
71 case 0xFE:
72 return "ERROR EPROM Checksum error ";
73 case 0xFD:
74 return "ERROR Local Ram Test Failed ";
75 case 0xFC:
76 return "ERROR SCC failure ";
77 case 0xFB:
78 return "ERROR BackBone failure ";
79 case 0xFA:
80 return "ERROR transceiver not found ";
81 case 0xF9:
82 return "ERROR no more address space ";
83 case 0xF8:
84 return "ERROR Checksum error ";
85 case 0xF7:
86 return "ERROR Missing SS Code";
87 case 0xF6:
88 return "ERROR Invalid config format";
89 case 0xF5:
90 return "ERROR Reserved errorcode F5";
91 case 0xF4:
92 return "ERROR Invalid spreading code/channel number";
93 case 0xF3:
94 return "ERROR Load Code Error";
95 case 0xF2:
96 return "ERROR Reserver errorcode F2 ";
97 case 0xF1:
98 return "ERROR Invalid command receivec by LAN card ";
99 case 0xF0:
100 return "ERROR Invalid parameter found in command ";
101 case 0xEF:
102 return "ERROR On-chip timer failure ";
103 case 0xEE:
104 return "ERROR T410 timer failure ";
105 case 0xED:
106 return "ERROR Too Many TxEnable commands ";
107 case 0xEC:
108 return "ERROR EEPROM error on radio module ";
109 default:
110 return "ERROR unknown Diagnostic info reply code ";
111 }
112}
113
114static const char *arlan_hardware_type_string(struct net_device *dev)
115{
116 u_char hardwareType;
117 struct arlan_private *priv = netdev_priv(dev);
118 volatile struct arlan_shmem __iomem *arlan = priv->card;
119
120 READSHM(hardwareType, arlan->hardwareType, u_char);
121 switch (hardwareType)
122 {
123 case 0x00:
124 return "type A450";
125 case 0x01:
126 return "type A650 ";
127 case 0x04:
128 return "type TMA coproc";
129 case 0x0D:
130 return "type A650E ";
131 case 0x18:
132 return "type TMA coproc Australian";
133 case 0x19:
134 return "type A650A ";
135 case 0x26:
136 return "type TMA coproc European";
137 case 0x2E:
138 return "type A655 ";
139 case 0x2F:
140 return "type A655A ";
141 case 0x30:
142 return "type A655E ";
143 case 0x0B:
144 return "type A670 ";
145 case 0x0C:
146 return "type A670E ";
147 case 0x2D:
148 return "type A670A ";
149 case 0x0F:
150 return "type A411T";
151 case 0x16:
152 return "type A411TA";
153 case 0x1B:
154 return "type A440T";
155 case 0x1C:
156 return "type A412T";
157 case 0x1E:
158 return "type A412TA";
159 case 0x22:
160 return "type A411TE";
161 case 0x24:
162 return "type A412TE";
163 case 0x27:
164 return "type A671T ";
165 case 0x29:
166 return "type A671TA ";
167 case 0x2B:
168 return "type A671TE ";
169 case 0x31:
170 return "type A415T ";
171 case 0x33:
172 return "type A415TA ";
173 case 0x35:
174 return "type A415TE ";
175 case 0x37:
176 return "type A672";
177 case 0x39:
178 return "type A672A ";
179 case 0x3B:
180 return "type A672T";
181 case 0x6B:
182 return "type IC2200";
183 default:
184 return "type A672T";
185 }
186}
187#ifdef ARLAN_DEBUGGING
188static void arlan_print_diagnostic_info(struct net_device *dev)
189{
190 int i;
191 u_char diagnosticInfo;
192 u_short diagnosticOffset;
193 u_char hardwareType;
194 struct arlan_private *priv = netdev_priv(dev);
195 volatile struct arlan_shmem __iomem *arlan = priv->card;
196
197 // ARLAN_DEBUG_ENTRY("arlan_print_diagnostic_info");
198
199 if (READSHMB(arlan->configuredStatusFlag) == 0)
200 printk("Arlan: Card NOT configured\n");
201 else
202 printk("Arlan: Card is configured\n");
203
204 READSHM(diagnosticInfo, arlan->diagnosticInfo, u_char);
205 READSHM(diagnosticOffset, arlan->diagnosticOffset, u_short);
206
207 printk(KERN_INFO "%s\n", arlan_diagnostic_info_string(dev));
208
209 if (diagnosticInfo != 0xff)
210 printk("%s arlan: Diagnostic Offset %d \n", dev->name, diagnosticOffset);
211
212 printk("arlan: LAN CODE ID = ");
213 for (i = 0; i < 6; i++)
214 DEBUGSHM(1, "%03d:", arlan->lanCardNodeId[i], u_char);
215 printk("\n");
216
217 printk("arlan: Arlan BroadCast address = ");
218 for (i = 0; i < 6; i++)
219 DEBUGSHM(1, "%03d:", arlan->broadcastAddress[i], u_char);
220 printk("\n");
221
222 READSHM(hardwareType, arlan->hardwareType, u_char);
223 printk(KERN_INFO "%s\n", arlan_hardware_type_string(dev));
224
225
226 DEBUGSHM(1, "arlan: channelNumber=%d\n", arlan->channelNumber, u_char);
227 DEBUGSHM(1, "arlan: channelSet=%d\n", arlan->channelSet, u_char);
228 DEBUGSHM(1, "arlan: spreadingCode=%d\n", arlan->spreadingCode, u_char);
229 DEBUGSHM(1, "arlan: radioNodeId=%d\n", arlan->radioNodeId, u_short);
230 DEBUGSHM(1, "arlan: SID =%d\n", arlan->SID, u_short);
231 DEBUGSHM(1, "arlan: rxOffset=%d\n", arlan->rxOffset, u_short);
232
233 DEBUGSHM(1, "arlan: registration mode is %d\n", arlan->registrationMode, u_char);
234
235 printk("arlan: name= ");
236 IFDEBUG(1)
237
238 for (i = 0; i < 16; i++)
239 {
240 char c;
241 READSHM(c, arlan->name[i], char);
242 if (c)
243 printk("%c", c);
244 }
245 printk("\n");
246
247// ARLAN_DEBUG_EXIT("arlan_print_diagnostic_info");
248
249}
250
251
252/****************************** TEST MEMORY **************/
253
254static int arlan_hw_test_memory(struct net_device *dev)
255{
256 u_char *ptr;
257 int i;
258 int memlen = sizeof(struct arlan_shmem) - 0xF; /* avoid control register */
259 volatile char *arlan_mem = (char *) (dev->mem_start);
260 struct arlan_private *priv = netdev_priv(dev);
261 volatile struct arlan_shmem __iomem *arlan = priv->card;
262 char pattern;
263
264 ptr = NULL;
265
266 /* hold card in reset state */
267 setHardwareReset(dev);
268
269 /* test memory */
270 pattern = 0;
271 for (i = 0; i < memlen; i++)
272 WRITESHM(arlan_mem[i], ((u_char) pattern++), u_char);
273
274 pattern = 0;
275 for (i = 0; i < memlen; i++)
276 {
277 char res;
278 READSHM(res, arlan_mem[i], char);
279 if (res != pattern++)
280 {
281 printk(KERN_ERR "Arlan driver memory test 1 failed \n");
282 return -1;
283 }
284 }
285
286 pattern = 0;
287 for (i = 0; i < memlen; i++)
288 WRITESHM(arlan_mem[i], ~(pattern++), char);
289
290 pattern = 0;
291 for (i = 0; i < memlen; i++)
292 {
293 char res;
294 READSHM(res, arlan_mem[i], char);
295 if (res != ~(pattern++))
296 {
297 printk(KERN_ERR "Arlan driver memory test 2 failed \n");
298 return -1;
299 }
300 }
301
302 /* zero memory */
303 for (i = 0; i < memlen; i++)
304 WRITESHM(arlan_mem[i], 0x00, char);
305
306 IFDEBUG(1) printk(KERN_INFO "Arlan: memory tests ok\n");
307
308 /* set reset flag and then release reset */
309 WRITESHM(arlan->resetFlag, 0xff, u_char);
310
311 clearChannelAttention(dev);
312 clearHardwareReset(dev);
313
314 /* wait for reset flag to become zero, we'll wait for two seconds */
315 if (arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW))
316 {
317 printk(KERN_ERR "%s arlan: failed to come back from memory test\n", dev->name);
318 return -1;
319 }
320 return 0;
321}
322
323static int arlan_setup_card_by_book(struct net_device *dev)
324{
325 u_char irqLevel, configuredStatusFlag;
326 struct arlan_private *priv = netdev_priv(dev);
327 volatile struct arlan_shmem __iomem *arlan = priv->card;
328
329// ARLAN_DEBUG_ENTRY("arlan_setup_card");
330
331 READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char);
332
333 IFDEBUG(10)
334 if (configuredStatusFlag != 0)
335 IFDEBUG(10) printk("arlan: CARD IS CONFIGURED\n");
336 else
337 IFDEBUG(10) printk("arlan: card is NOT configured\n");
338
339 if (testMemory || (READSHMB(arlan->diagnosticInfo) != 0xff))
340 if (arlan_hw_test_memory(dev))
341 return -1;
342
343 DEBUGSHM(4, "arlan configuredStatus = %d \n", arlan->configuredStatusFlag, u_char);
344 DEBUGSHM(4, "arlan driver diagnostic: 0x%2x\n", arlan->diagnosticInfo, u_char);
345
346 /* issue nop command - no interrupt */
347 arlan_command(dev, ARLAN_COMMAND_NOOP);
348 if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0)
349 return -1;
350
351 IFDEBUG(50) printk("1st Noop successfully executed !!\n");
352
353 /* try to turn on the arlan interrupts */
354 clearClearInterrupt(dev);
355 setClearInterrupt(dev);
356 setInterruptEnable(dev);
357
358 /* issue nop command - with interrupt */
359
360 arlan_command(dev, ARLAN_COMMAND_NOOPINT);
361 if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0)
362 return -1;
363
364
365 IFDEBUG(50) printk("2nd Noop successfully executed !!\n");
366
367 READSHM(irqLevel, arlan->irqLevel, u_char)
368
369 if (irqLevel != dev->irq)
370 {
371 IFDEBUG(1) printk(KERN_WARNING "arlan dip switches set irq to %d\n", irqLevel);
372 printk(KERN_WARNING "device driver irq set to %d - does not match\n", dev->irq);
373 dev->irq = irqLevel;
374 }
375 else
376 IFDEBUG(2) printk("irq level is OK\n");
377
378
379 IFDEBUG(3) arlan_print_diagnostic_info(dev);
380
381 arlan_command(dev, ARLAN_COMMAND_CONF);
382
383 READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char);
384 if (configuredStatusFlag == 0)
385 {
386 printk(KERN_WARNING "arlan configure failed\n");
387 return -1;
388 }
389 arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW);
390 arlan_command(dev, ARLAN_COMMAND_RX);
391 arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW);
392 printk(KERN_NOTICE "%s: arlan driver version %s loaded\n",
393 dev->name, arlan_version);
394
395// ARLAN_DEBUG_EXIT("arlan_setup_card");
396
397 return 0; /* no errors */
398}
399#endif
400
401#ifdef ARLAN_PROC_INTERFACE
402#ifdef ARLAN_PROC_SHM_DUMP
403
404static char arlan_drive_info[ARLAN_STR_SIZE] = "A655\n\0";
405
406static int arlan_sysctl_info(ctl_table * ctl, int write, struct file *filp,
407 void __user *buffer, size_t * lenp, loff_t *ppos)
408{
409 int i;
410 int retv, pos, devnum;
411 struct arlan_private *priva = NULL;
412 struct net_device *dev;
413 pos = 0;
414 if (write)
415 {
416 printk("wrirte: ");
417 for (i = 0; i < 100; i++)
418 printk("adi %x \n", arlan_drive_info[i]);
419 }
420 if (ctl->procname == NULL || arlan_drive_info == NULL)
421 {
422 printk(KERN_WARNING " procname is NULL in sysctl_table or arlan_drive_info is NULL \n at arlan module\n ");
423 return -1;
424 }
425 devnum = ctl->procname[5] - '0';
426 if (devnum < 0 || devnum > MAX_ARLANS - 1)
427 {
428 printk(KERN_WARNING "too strange devnum in procfs parse\n ");
429 return -1;
430 }
431 else if (arlan_device[devnum] == NULL)
432 {
433 if (ctl->procname)
434 pos += sprintf(arlan_drive_info + pos, "\t%s\n\n", ctl->procname);
435 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
436 goto final;
437 }
438 else
439 priva = arlan_device[devnum]->priv;
440
441 if (priva == NULL)
442 {
443 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
444 return -1;
445 }
446 dev = arlan_device[devnum];
447
448 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
449
450 pos = sprintf(arlan_drive_info, "Arlan info \n");
451 /* Header Signature */
452 SARLSTR(textRegion, 48);
453 SARLUC(resetFlag);
454 pos += sprintf(arlan_drive_info + pos, "diagnosticInfo\t=\t%s \n", arlan_diagnostic_info_string(dev));
455 SARLUC(diagnosticInfo);
456 SARLUS(diagnosticOffset);
457 SARLUCN(_1, 12);
458 SARLUCN(lanCardNodeId, 6);
459 SARLUCN(broadcastAddress, 6);
460 pos += sprintf(arlan_drive_info + pos, "hardwareType =\t %s \n", arlan_hardware_type_string(dev));
461 SARLUC(hardwareType);
462 SARLUC(majorHardwareVersion);
463 SARLUC(minorHardwareVersion);
464 SARLUC(radioModule);
465 SARLUC(defaultChannelSet);
466 SARLUCN(_2, 47);
467
468 /* Control/Status Block - 0x0080 */
469 SARLUC(interruptInProgress);
470 SARLUC(cntrlRegImage);
471
472 SARLUCN(_3, 14);
473 SARLUC(commandByte);
474 SARLUCN(commandParameter, 15);
475
476 /* Receive Status - 0x00a0 */
477 SARLUC(rxStatus);
478 SARLUC(rxFrmType);
479 SARLUS(rxOffset);
480 SARLUS(rxLength);
481 SARLUCN(rxSrc, 6);
482 SARLUC(rxBroadcastFlag);
483 SARLUC(rxQuality);
484 SARLUC(scrambled);
485 SARLUCN(_4, 1);
486
487 /* Transmit Status - 0x00b0 */
488 SARLUC(txStatus);
489 SARLUC(txAckQuality);
490 SARLUC(numRetries);
491 SARLUCN(_5, 14);
492 SARLUCN(registeredRouter, 6);
493 SARLUCN(backboneRouter, 6);
494 SARLUC(registrationStatus);
495 SARLUC(configuredStatusFlag);
496 SARLUCN(_6, 1);
497 SARLUCN(ultimateDestAddress, 6);
498 SARLUCN(immedDestAddress, 6);
499 SARLUCN(immedSrcAddress, 6);
500 SARLUS(rxSequenceNumber);
501 SARLUC(assignedLocaltalkAddress);
502 SARLUCN(_7, 27);
503
504 /* System Parameter Block */
505
506 /* - Driver Parameters (Novell Specific) */
507
508 SARLUS(txTimeout);
509 SARLUS(transportTime);
510 SARLUCN(_8, 4);
511
512 /* - Configuration Parameters */
513 SARLUC(irqLevel);
514 SARLUC(spreadingCode);
515 SARLUC(channelSet);
516 SARLUC(channelNumber);
517 SARLUS(radioNodeId);
518 SARLUCN(_9, 2);
519 SARLUC(scramblingDisable);
520 SARLUC(radioType);
521 SARLUS(routerId);
522 SARLUCN(_10, 9);
523 SARLUC(txAttenuation);
524 SARLUIA(systemId);
525 SARLUS(globalChecksum);
526 SARLUCN(_11, 4);
527 SARLUS(maxDatagramSize);
528 SARLUS(maxFrameSize);
529 SARLUC(maxRetries);
530 SARLUC(receiveMode);
531 SARLUC(priority);
532 SARLUC(rootOrRepeater);
533 SARLUCN(specifiedRouter, 6);
534 SARLUS(fastPollPeriod);
535 SARLUC(pollDecay);
536 SARLUSA(fastPollDelay);
537 SARLUC(arlThreshold);
538 SARLUC(arlDecay);
539 SARLUCN(_12, 1);
540 SARLUS(specRouterTimeout);
541 SARLUCN(_13, 5);
542
543 /* Scrambled Area */
544 SARLUIA(SID);
545 SARLUCN(encryptionKey, 12);
546 SARLUIA(_14);
547 SARLUSA(waitTime);
548 SARLUSA(lParameter);
549 SARLUCN(_15, 3);
550 SARLUS(headerSize);
551 SARLUS(sectionChecksum);
552
553 SARLUC(registrationMode);
554 SARLUC(registrationFill);
555 SARLUS(pollPeriod);
556 SARLUS(refreshPeriod);
557 SARLSTR(name, 16);
558 SARLUCN(NID, 6);
559 SARLUC(localTalkAddress);
560 SARLUC(codeFormat);
561 SARLUC(numChannels);
562 SARLUC(channel1);
563 SARLUC(channel2);
564 SARLUC(channel3);
565 SARLUC(channel4);
566 SARLUCN(SSCode, 59);
567
568/* SARLUCN( _16, 0x140);
569 */
570 /* Statistics Block - 0x0300 */
571 SARLUC(hostcpuLock);
572 SARLUC(lancpuLock);
573 SARLUCN(resetTime, 18);
574 SARLUIA(numDatagramsTransmitted);
575 SARLUIA(numReTransmissions);
576 SARLUIA(numFramesDiscarded);
577 SARLUIA(numDatagramsReceived);
578 SARLUIA(numDuplicateReceivedFrames);
579 SARLUIA(numDatagramsDiscarded);
580 SARLUS(maxNumReTransmitDatagram);
581 SARLUS(maxNumReTransmitFrames);
582 SARLUS(maxNumConsecutiveDuplicateFrames);
583 /* misaligned here so we have to go to characters */
584 SARLUIA(numBytesTransmitted);
585 SARLUIA(numBytesReceived);
586 SARLUIA(numCRCErrors);
587 SARLUIA(numLengthErrors);
588 SARLUIA(numAbortErrors);
589 SARLUIA(numTXUnderruns);
590 SARLUIA(numRXOverruns);
591 SARLUIA(numHoldOffs);
592 SARLUIA(numFramesTransmitted);
593 SARLUIA(numFramesReceived);
594 SARLUIA(numReceiveFramesLost);
595 SARLUIA(numRXBufferOverflows);
596 SARLUIA(numFramesDiscardedAddrMismatch);
597 SARLUIA(numFramesDiscardedSIDMismatch);
598 SARLUIA(numPollsTransmistted);
599 SARLUIA(numPollAcknowledges);
600 SARLUIA(numStatusTimeouts);
601 SARLUIA(numNACKReceived);
602 SARLUS(auxCmd);
603 SARLUCN(dumpPtr, 4);
604 SARLUC(dumpVal);
605 SARLUC(wireTest);
606
607 /* next 4 seems too long for procfs, over single page ?
608 SARLUCN( _17, 0x86);
609 SARLUCN( txBuffer, 0x800);
610 SARLUCN( rxBuffer, 0x800);
611 SARLUCN( _18, 0x0bff);
612 */
613
614 pos += sprintf(arlan_drive_info + pos, "rxRing\t=\t0x");
615 for (i = 0; i < 0x50; i++)
616 pos += sprintf(arlan_drive_info + pos, "%02x", ((char *) priva->conf)[priva->conf->rxOffset + i]);
617 pos += sprintf(arlan_drive_info + pos, "\n");
618
619 SARLUC(configStatus);
620 SARLUC(_22);
621 SARLUC(progIOCtrl);
622 SARLUC(shareMBase);
623 SARLUC(controlRegister);
624
625 pos += sprintf(arlan_drive_info + pos, " total %d chars\n", pos);
626 if (ctl)
627 if (ctl->procname)
628 pos += sprintf(arlan_drive_info + pos, " driver name : %s\n", ctl->procname);
629final:
630 *lenp = pos;
631
632 if (!write)
633 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
634 else
635 {
636 *lenp = 0;
637 return -1;
638 }
639 return retv;
640}
641
642
643static int arlan_sysctl_info161719(ctl_table * ctl, int write, struct file *filp,
644 void __user *buffer, size_t * lenp, loff_t *ppos)
645{
646 int i;
647 int retv, pos, devnum;
648 struct arlan_private *priva = NULL;
649
650 pos = 0;
651 devnum = ctl->procname[5] - '0';
652 if (arlan_device[devnum] == NULL)
653 {
654 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
655 goto final;
656 }
657 else
658 priva = arlan_device[devnum]->priv;
659 if (priva == NULL)
660 {
661 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
662 return -1;
663 }
664 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
665 SARLUCN(_16, 0xC0);
666 SARLUCN(_17, 0x6A);
667 SARLUCN(_18, 14);
668 SARLUCN(_19, 0x86);
669 SARLUCN(_21, 0x3fd);
670
671final:
672 *lenp = pos;
673 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
674 return retv;
675}
676
677static int arlan_sysctl_infotxRing(ctl_table * ctl, int write, struct file *filp,
678 void __user *buffer, size_t * lenp, loff_t *ppos)
679{
680 int i;
681 int retv, pos, devnum;
682 struct arlan_private *priva = NULL;
683
684 pos = 0;
685 devnum = ctl->procname[5] - '0';
686 if (arlan_device[devnum] == NULL)
687 {
688 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
689 goto final;
690 }
691 else
692 priva = arlan_device[devnum]->priv;
693 if (priva == NULL)
694 {
695 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
696 return -1;
697 }
698 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
699 SARLBNpln(u_char, txBuffer, 0x800);
700final:
701 *lenp = pos;
702 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
703 return retv;
704}
705
706static int arlan_sysctl_inforxRing(ctl_table * ctl, int write, struct file *filp,
707 void __user *buffer, size_t * lenp, loff_t *ppos)
708{
709 int i;
710 int retv, pos, devnum;
711 struct arlan_private *priva = NULL;
712
713 pos = 0;
714 devnum = ctl->procname[5] - '0';
715 if (arlan_device[devnum] == NULL)
716 {
717 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
718 goto final;
719 } else
720 priva = arlan_device[devnum]->priv;
721 if (priva == NULL)
722 {
723 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
724 return -1;
725 }
726 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
727 SARLBNpln(u_char, rxBuffer, 0x800);
728final:
729 *lenp = pos;
730 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
731 return retv;
732}
733
734static int arlan_sysctl_info18(ctl_table * ctl, int write, struct file *filp,
735 void __user *buffer, size_t * lenp, loff_t *ppos)
736{
737 int i;
738 int retv, pos, devnum;
739 struct arlan_private *priva = NULL;
740
741 pos = 0;
742 devnum = ctl->procname[5] - '0';
743 if (arlan_device[devnum] == NULL)
744 {
745 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
746 goto final;
747 }
748 else
749 priva = arlan_device[devnum]->priv;
750 if (priva == NULL)
751 {
752 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
753 return -1;
754 }
755 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
756 SARLBNpln(u_char, _18, 0x800);
757
758final:
759 *lenp = pos;
760 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
761 return retv;
762}
763
764
765#endif /* #ifdef ARLAN_PROC_SHM_DUMP */
766
767
768static char conf_reset_result[200];
769
770static int arlan_configure(ctl_table * ctl, int write, struct file *filp,
771 void __user *buffer, size_t * lenp, loff_t *ppos)
772{
773 int pos = 0;
774 int devnum = ctl->procname[6] - '0';
775 struct arlan_private *priv;
776
777 if (devnum < 0 || devnum > MAX_ARLANS - 1)
778 {
779 printk(KERN_WARNING "too strange devnum in procfs parse\n ");
780 return -1;
781 }
782 else if (arlan_device[devnum] != NULL)
783 {
784 priv = arlan_device[devnum]->priv;
785
786 arlan_command(arlan_device[devnum], ARLAN_COMMAND_CLEAN_AND_CONF);
787 }
788 else
789 return -1;
790
791 *lenp = pos;
792 return proc_dostring(ctl, write, filp, buffer, lenp, ppos);
793}
794
795static int arlan_sysctl_reset(ctl_table * ctl, int write, struct file *filp,
796 void __user *buffer, size_t * lenp, loff_t *ppos)
797{
798 int pos = 0;
799 int devnum = ctl->procname[5] - '0';
800 struct arlan_private *priv;
801
802 if (devnum < 0 || devnum > MAX_ARLANS - 1)
803 {
804 printk(KERN_WARNING "too strange devnum in procfs parse\n ");
805 return -1;
806 }
807 else if (arlan_device[devnum] != NULL)
808 {
809 priv = arlan_device[devnum]->priv;
810 arlan_command(arlan_device[devnum], ARLAN_COMMAND_CLEAN_AND_RESET);
811
812 } else
813 return -1;
814 *lenp = pos + 3;
815 return proc_dostring(ctl, write, filp, buffer, lenp, ppos);
816}
817
818
819/* Place files in /proc/sys/dev/arlan */
820#define CTBLN(num,card,nam) \
821 { .ctl_name = num,\
822 .procname = #nam,\
823 .data = &(arlan_conf[card].nam),\
824 .maxlen = sizeof(int), .mode = 0600, .proc_handler = &proc_dointvec}
825#ifdef ARLAN_DEBUGGING
826
827#define ARLAN_PROC_DEBUG_ENTRIES \
828 { .ctl_name = 48, .procname = "entry_exit_debug",\
829 .data = &arlan_entry_and_exit_debug,\
830 .maxlen = sizeof(int), .mode = 0600, .proc_handler = &proc_dointvec},\
831 { .ctl_name = 49, .procname = "debug", .data = &arlan_debug,\
832 .maxlen = sizeof(int), .mode = 0600, .proc_handler = &proc_dointvec},
833#else
834#define ARLAN_PROC_DEBUG_ENTRIES
835#endif
836
837#define ARLAN_SYSCTL_TABLE_TOTAL(cardNo)\
838 CTBLN(1,cardNo,spreadingCode),\
839 CTBLN(2,cardNo, channelNumber),\
840 CTBLN(3,cardNo, scramblingDisable),\
841 CTBLN(4,cardNo, txAttenuation),\
842 CTBLN(5,cardNo, systemId), \
843 CTBLN(6,cardNo, maxDatagramSize),\
844 CTBLN(7,cardNo, maxFrameSize),\
845 CTBLN(8,cardNo, maxRetries),\
846 CTBLN(9,cardNo, receiveMode),\
847 CTBLN(10,cardNo, priority),\
848 CTBLN(11,cardNo, rootOrRepeater),\
849 CTBLN(12,cardNo, SID),\
850 CTBLN(13,cardNo, registrationMode),\
851 CTBLN(14,cardNo, registrationFill),\
852 CTBLN(15,cardNo, localTalkAddress),\
853 CTBLN(16,cardNo, codeFormat),\
854 CTBLN(17,cardNo, numChannels),\
855 CTBLN(18,cardNo, channel1),\
856 CTBLN(19,cardNo, channel2),\
857 CTBLN(20,cardNo, channel3),\
858 CTBLN(21,cardNo, channel4),\
859 CTBLN(22,cardNo, txClear),\
860 CTBLN(23,cardNo, txRetries),\
861 CTBLN(24,cardNo, txRouting),\
862 CTBLN(25,cardNo, txScrambled),\
863 CTBLN(26,cardNo, rxParameter),\
864 CTBLN(27,cardNo, txTimeoutMs),\
865 CTBLN(28,cardNo, waitCardTimeout),\
866 CTBLN(29,cardNo, channelSet), \
867 {.ctl_name = 30, .procname = "name",\
868 .data = arlan_conf[cardNo].siteName,\
869 .maxlen = 16, .mode = 0600, .proc_handler = &proc_dostring},\
870 CTBLN(31,cardNo,waitTime),\
871 CTBLN(32,cardNo,lParameter),\
872 CTBLN(33,cardNo,_15),\
873 CTBLN(34,cardNo,headerSize),\
874 CTBLN(36,cardNo,tx_delay_ms),\
875 CTBLN(37,cardNo,retries),\
876 CTBLN(38,cardNo,ReTransmitPacketMaxSize),\
877 CTBLN(39,cardNo,waitReTransmitPacketMaxSize),\
878 CTBLN(40,cardNo,fastReTransCount),\
879 CTBLN(41,cardNo,driverRetransmissions),\
880 CTBLN(42,cardNo,txAckTimeoutMs),\
881 CTBLN(43,cardNo,registrationInterrupts),\
882 CTBLN(44,cardNo,hardwareType),\
883 CTBLN(45,cardNo,radioType),\
884 CTBLN(46,cardNo,writeEEPROM),\
885 CTBLN(47,cardNo,writeRadioType),\
886 ARLAN_PROC_DEBUG_ENTRIES\
887 CTBLN(50,cardNo,in_speed),\
888 CTBLN(51,cardNo,out_speed),\
889 CTBLN(52,cardNo,in_speed10),\
890 CTBLN(53,cardNo,out_speed10),\
891 CTBLN(54,cardNo,in_speed_max),\
892 CTBLN(55,cardNo,out_speed_max),\
893 CTBLN(56,cardNo,measure_rate),\
894 CTBLN(57,cardNo,pre_Command_Wait),\
895 CTBLN(58,cardNo,rx_tweak1),\
896 CTBLN(59,cardNo,rx_tweak2),\
897 CTBLN(60,cardNo,tx_queue_len),\
898
899
900
901static ctl_table arlan_conf_table0[] =
902{
903 ARLAN_SYSCTL_TABLE_TOTAL(0)
904
905#ifdef ARLAN_PROC_SHM_DUMP
906 {
907 .ctl_name = 150,
908 .procname = "arlan0-txRing",
909 .data = &arlan_drive_info,
910 .maxlen = ARLAN_STR_SIZE,
911 .mode = 0400,
912 .proc_handler = &arlan_sysctl_infotxRing,
913 },
914 {
915 .ctl_name = 151,
916 .procname = "arlan0-rxRing",
917 .data = &arlan_drive_info,
918 .maxlen = ARLAN_STR_SIZE,
919 .mode = 0400,
920 .proc_handler = &arlan_sysctl_inforxRing,
921 },
922 {
923 .ctl_name = 152,
924 .procname = "arlan0-18",
925 .data = &arlan_drive_info,
926 .maxlen = ARLAN_STR_SIZE,
927 .mode = 0400,
928 .proc_handler = &arlan_sysctl_info18,
929 },
930 {
931 .ctl_name = 153,
932 .procname = "arlan0-ring",
933 .data = &arlan_drive_info,
934 .maxlen = ARLAN_STR_SIZE,
935 .mode = 0400,
936 .proc_handler = &arlan_sysctl_info161719,
937 },
938 {
939 .ctl_name = 154,
940 .procname = "arlan0-shm-cpy",
941 .data = &arlan_drive_info,
942 .maxlen = ARLAN_STR_SIZE,
943 .mode = 0400,
944 .proc_handler = &arlan_sysctl_info,
945 },
946#endif
947 {
948 .ctl_name = 155,
949 .procname = "config0",
950 .data = &conf_reset_result,
951 .maxlen = 100,
952 .mode = 0400,
953 .proc_handler = &arlan_configure
954 },
955 {
956 .ctl_name = 156,
957 .procname = "reset0",
958 .data = &conf_reset_result,
959 .maxlen = 100,
960 .mode = 0400,
961 .proc_handler = &arlan_sysctl_reset,
962 },
963 { .ctl_name = 0 }
964};
965
966static ctl_table arlan_conf_table1[] =
967{
968
969 ARLAN_SYSCTL_TABLE_TOTAL(1)
970
971#ifdef ARLAN_PROC_SHM_DUMP
972 {
973 .ctl_name = 150,
974 .procname = "arlan1-txRing",
975 .data = &arlan_drive_info,
976 .maxlen = ARLAN_STR_SIZE,
977 .mode = 0400,
978 .proc_handler = &arlan_sysctl_infotxRing,
979 },
980 {
981 .ctl_name = 151,
982 .procname = "arlan1-rxRing",
983 .data = &arlan_drive_info,
984 .maxlen = ARLAN_STR_SIZE,
985 .mode = 0400,
986 .proc_handler = &arlan_sysctl_inforxRing,
987 },
988 {
989 .ctl_name = 152,
990 .procname = "arlan1-18",
991 .data = &arlan_drive_info,
992 .maxlen = ARLAN_STR_SIZE,
993 .mode = 0400,
994 .proc_handler = &arlan_sysctl_info18,
995 },
996 {
997 .ctl_name = 153,
998 .procname = "arlan1-ring",
999 .data = &arlan_drive_info,
1000 .maxlen = ARLAN_STR_SIZE,
1001 .mode = 0400,
1002 .proc_handler = &arlan_sysctl_info161719,
1003 },
1004 {
1005 .ctl_name = 154,
1006 .procname = "arlan1-shm-cpy",
1007 .data = &arlan_drive_info,
1008 .maxlen = ARLAN_STR_SIZE,
1009 .mode = 0400,
1010 .proc_handler = &arlan_sysctl_info,
1011 },
1012#endif
1013 {
1014 .ctl_name = 155,
1015 .procname = "config1",
1016 .data = &conf_reset_result,
1017 .maxlen = 100,
1018 .mode = 0400,
1019 .proc_handler = &arlan_configure,
1020 },
1021 {
1022 .ctl_name = 156,
1023 .procname = "reset1",
1024 .data = &conf_reset_result,
1025 .maxlen = 100,
1026 .mode = 0400,
1027 .proc_handler = &arlan_sysctl_reset,
1028 },
1029 { .ctl_name = 0 }
1030};
1031
1032static ctl_table arlan_conf_table2[] =
1033{
1034
1035 ARLAN_SYSCTL_TABLE_TOTAL(2)
1036
1037#ifdef ARLAN_PROC_SHM_DUMP
1038 {
1039 .ctl_name = 150,
1040 .procname = "arlan2-txRing",
1041 .data = &arlan_drive_info,
1042 .maxlen = ARLAN_STR_SIZE,
1043 .mode = 0400,
1044 .proc_handler = &arlan_sysctl_infotxRing,
1045 },
1046 {
1047 .ctl_name = 151,
1048 .procname = "arlan2-rxRing",
1049 .data = &arlan_drive_info,
1050 .maxlen = ARLAN_STR_SIZE,
1051 .mode = 0400,
1052 .proc_handler = &arlan_sysctl_inforxRing,
1053 },
1054 {
1055 .ctl_name = 152,
1056 .procname = "arlan2-18",
1057 .data = &arlan_drive_info,
1058 .maxlen = ARLAN_STR_SIZE,
1059 .mode = 0400,
1060 .proc_handler = &arlan_sysctl_info18,
1061 },
1062 {
1063 .ctl_name = 153,
1064 .procname = "arlan2-ring",
1065 .data = &arlan_drive_info,
1066 .maxlen = ARLAN_STR_SIZE,
1067 .mode = 0400,
1068 .proc_handler = &arlan_sysctl_info161719,
1069 },
1070 {
1071 .ctl_name = 154,
1072 .procname = "arlan2-shm-cpy",
1073 .data = &arlan_drive_info,
1074 .maxlen = ARLAN_STR_SIZE,
1075 .mode = 0400,
1076 .proc_handler = &arlan_sysctl_info,
1077 },
1078#endif
1079 {
1080 .ctl_name = 155,
1081 .procname = "config2",
1082 .data = &conf_reset_result,
1083 .maxlen = 100,
1084 .mode = 0400,
1085 .proc_handler = &arlan_configure,
1086 },
1087 {
1088 .ctl_name = 156,
1089 .procname = "reset2",
1090 .data = &conf_reset_result,
1091 .maxlen = 100,
1092 .mode = 0400,
1093 .proc_handler = &arlan_sysctl_reset,
1094 },
1095 { .ctl_name = 0 }
1096};
1097
1098static ctl_table arlan_conf_table3[] =
1099{
1100
1101 ARLAN_SYSCTL_TABLE_TOTAL(3)
1102
1103#ifdef ARLAN_PROC_SHM_DUMP
1104 {
1105 .ctl_name = 150,
1106 .procname = "arlan3-txRing",
1107 .data = &arlan_drive_info,
1108 .maxlen = ARLAN_STR_SIZE,
1109 .mode = 0400,
1110 .proc_handler = &arlan_sysctl_infotxRing,
1111 },
1112 {
1113 .ctl_name = 151,
1114 .procname = "arlan3-rxRing",
1115 .data = &arlan_drive_info,
1116 .maxlen = ARLAN_STR_SIZE,
1117 .mode = 0400,
1118 .proc_handler = &arlan_sysctl_inforxRing,
1119 },
1120 {
1121 .ctl_name = 152,
1122 .procname = "arlan3-18",
1123 .data = &arlan_drive_info,
1124 .maxlen = ARLAN_STR_SIZE,
1125 .mode = 0400,
1126 .proc_handler = &arlan_sysctl_info18,
1127 },
1128 {
1129 .ctl_name = 153,
1130 .procname = "arlan3-ring",
1131 .data = &arlan_drive_info,
1132 .maxlen = ARLAN_STR_SIZE,
1133 .mode = 0400,
1134 .proc_handler = &arlan_sysctl_info161719,
1135 },
1136 {
1137 .ctl_name = 154,
1138 .procname = "arlan3-shm-cpy",
1139 .data = &arlan_drive_info,
1140 .maxlen = ARLAN_STR_SIZE,
1141 .mode = 0400,
1142 .proc_handler = &arlan_sysctl_info,
1143 },
1144#endif
1145 {
1146 .ctl_name = 155,
1147 .procname = "config3",
1148 .data = &conf_reset_result,
1149 .maxlen = 100,
1150 .mode = 0400,
1151 .proc_handler = &arlan_configure,
1152 },
1153 {
1154 .ctl_name = 156,
1155 .procname = "reset3",
1156 .data = &conf_reset_result,
1157 .maxlen = 100,
1158 .mode = 0400,
1159 .proc_handler = &arlan_sysctl_reset,
1160 },
1161 { .ctl_name = 0 }
1162};
1163
1164
1165
1166static ctl_table arlan_table[] =
1167{
1168 {
1169 .ctl_name = 0,
1170 .procname = "arlan0",
1171 .maxlen = 0,
1172 .mode = 0600,
1173 .child = arlan_conf_table0,
1174 },
1175 {
1176 .ctl_name = 0,
1177 .procname = "arlan1",
1178 .maxlen = 0,
1179 .mode = 0600,
1180 .child = arlan_conf_table1,
1181 },
1182 {
1183 .ctl_name = 0,
1184 .procname = "arlan2",
1185 .maxlen = 0,
1186 .mode = 0600,
1187 .child = arlan_conf_table2,
1188 },
1189 {
1190 .ctl_name = 0,
1191 .procname = "arlan3",
1192 .maxlen = 0,
1193 .mode = 0600,
1194 .child = arlan_conf_table3,
1195 },
1196 { .ctl_name = 0 }
1197};
1198
1199#else
1200
1201static ctl_table arlan_table[MAX_ARLANS + 1] =
1202{
1203 { .ctl_name = 0 }
1204};
1205#endif
1206#else
1207
1208static ctl_table arlan_table[MAX_ARLANS + 1] =
1209{
1210 { .ctl_name = 0 }
1211};
1212#endif
1213
1214
1215// static int mmtu = 1234;
1216
1217static ctl_table arlan_root_table[] =
1218{
1219 {
1220 .ctl_name = 254,
1221 .procname = "arlan",
1222 .maxlen = 0,
1223 .mode = 0555,
1224 .child = arlan_table,
1225 },
1226 { .ctl_name = 0 }
1227};
1228
1229/* Make sure that /proc/sys/dev is there */
1230//static ctl_table arlan_device_root_table[] =
1231//{
1232// {CTL_DEV, "dev", NULL, 0, 0555, arlan_root_table},
1233// {0}
1234//};
1235
1236
1237#ifdef CONFIG_PROC_FS
1238static struct ctl_table_header *arlan_device_sysctl_header;
1239
1240int __init init_arlan_proc(void)
1241{
1242
1243 int i = 0;
1244 if (arlan_device_sysctl_header)
1245 return 0;
1246 for (i = 0; i < MAX_ARLANS && arlan_device[i]; i++)
1247 arlan_table[i].ctl_name = i + 1;
1248 arlan_device_sysctl_header = register_sysctl_table(arlan_root_table, 0);
1249 if (!arlan_device_sysctl_header)
1250 return -1;
1251
1252 return 0;
1253
1254}
1255
1256void __exit cleanup_arlan_proc(void)
1257{
1258 unregister_sysctl_table(arlan_device_sysctl_header);
1259 arlan_device_sysctl_header = NULL;
1260
1261}
1262#endif