Import 2.3.18pre1
[davej-history.git] / drivers / net / arlan-proc.c
blob3cd214c64e05162674c582e7b957efabbc477b5d
1 #include <linux/config.h>
2 #include "arlan.h"
4 #ifdef CONFIG_PROC_FS
7 #include <linux/sysctl.h>
8 #include <linux/version.h>
10 /* void enableReceive(struct net_device* dev);
13 static int arlan_command(struct net_device * dev, int command);
16 #define ARLAN_STR_SIZE 0x2ff0
17 #define DEV_ARLAN_INFO 1
18 #define DEV_ARLAN 1
19 #define SARLG(type,var) {\
20 pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n", #var, READSHMB(priva->card->var)); \
23 #define SARLBN(type,var,nn) {\
24 pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x",#var);\
25 for (i=0; i < nn; i++ ) pos += sprintf(arlan_drive_info+pos, "%02x",READSHMB(priva->card->var[i]));\
26 pos += sprintf(arlan_drive_info+pos, "\n"); \
29 #define SARLBNpln(type,var,nn) {\
30 for (i=0; i < nn; i++ ) pos += sprintf(arlan_drive_info+pos, "%02x",READSHMB(priva->card->var[i]));\
33 #define SARLSTR(var,nn) {\
34 char tmpStr[400];\
35 int tmpLn = nn;\
36 if (nn > 399 ) tmpLn = 399; \
37 memcpy(tmpStr,(char *) priva->conf->var,tmpLn);\
38 tmpStr[tmpLn] = 0; \
39 pos += sprintf(arlan_drive_info+pos, "%s\t=\t%s \n",#var,priva->conf->var);\
42 #define SARLUC(var) SARLG(u_char, var)
43 #define SARLUCN(var,nn) SARLBN(u_char,var, nn)
44 #define SARLUS(var) SARLG(u_short, var)
45 #define SARLUSN(var,nn) SARLBN(u_short,var, nn)
46 #define SARLUI(var) SARLG(u_int, var)
48 #define SARLUSA(var) {\
49 u_short tmpVar;\
50 memcpy(&tmpVar, (short *) priva->conf->var,2); \
51 pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n",#var, tmpVar);\
54 #define SARLUIA(var) {\
55 u_int tmpVar;\
56 memcpy(&tmpVar, (int* )priva->conf->var,4); \
57 pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n",#var, tmpVar);\
61 const char *arlan_diagnostic_info_string(struct net_device *dev)
64 volatile struct arlan_shmem *arlan = ((struct arlan_private *) dev->priv)->card;
65 u_char diagnosticInfo;
67 READSHM(diagnosticInfo, arlan->diagnosticInfo, u_char);
69 switch (diagnosticInfo)
71 case 0xFF:
72 return "Diagnostic info is OK";
73 case 0xFE:
74 return "ERROR EPROM Checksum error ";
75 case 0xFD:
76 return "ERROR Local Ram Test Failed ";
77 case 0xFC:
78 return "ERROR SCC failure ";
79 case 0xFB:
80 return "ERROR BackBone failure ";
81 case 0xFA:
82 return "ERROR tranceiver not found ";
83 case 0xF9:
84 return "ERROR no more address space ";
85 case 0xF8:
86 return "ERROR Checksum error ";
87 case 0xF7:
88 return "ERROR Missing SS Code";
89 case 0xF6:
90 return "ERROR Invalid config format";
91 case 0xF5:
92 return "ERROR Reserved errorcode F5";
93 case 0xF4:
94 return "ERROR Invalid spreading code/channel number";
95 case 0xF3:
96 return "ERROR Load Code Error";
97 case 0xF2:
98 return "ERROR Reserver errorcode F2 ";
99 case 0xF1:
100 return "ERROR Invalid command receivec by LAN card ";
101 case 0xF0:
102 return "ERROR Invalid parameter found in command ";
103 case 0xEF:
104 return "ERROR On-chip timer failure ";
105 case 0xEE:
106 return "ERROR T410 timer failure ";
107 case 0xED:
108 return "ERROR Too Many TxEnable commands ";
109 case 0xEC:
110 return "ERROR EEPROM error on radio module ";
111 default:
112 return "ERROR unknown Diagnostic info reply code ";
116 static const char *arlan_hardware_type_string(struct net_device *dev)
118 u_char hardwareType;
119 volatile struct arlan_shmem *arlan = ((struct arlan_private *) dev->priv)->card;
121 READSHM(hardwareType, arlan->hardwareType, u_char);
122 switch (hardwareType)
124 case 0x00:
125 return "type A450";
126 case 0x01:
127 return "type A650 ";
128 case 0x04:
129 return "type TMA coproc";
130 case 0x0D:
131 return "type A650E ";
132 case 0x18:
133 return "type TMA coproc Australian";
134 case 0x19:
135 return "type A650A ";
136 case 0x26:
137 return "type TMA coproc European";
138 case 0x2E:
139 return "type A655 ";
140 case 0x2F:
141 return "type A655A ";
142 case 0x30:
143 return "type A655E ";
144 case 0x0B:
145 return "type A670 ";
146 case 0x0C:
147 return "type A670E ";
148 case 0x2D:
149 return "type A670A ";
150 case 0x0F:
151 return "type A411T";
152 case 0x16:
153 return "type A411TA";
154 case 0x1B:
155 return "type A440T";
156 case 0x1C:
157 return "type A412T";
158 case 0x1E:
159 return "type A412TA";
160 case 0x22:
161 return "type A411TE";
162 case 0x24:
163 return "type A412TE";
164 case 0x27:
165 return "type A671T ";
166 case 0x29:
167 return "type A671TA ";
168 case 0x2B:
169 return "type A671TE ";
170 case 0x31:
171 return "type A415T ";
172 case 0x33:
173 return "type A415TA ";
174 case 0x35:
175 return "type A415TE ";
176 case 0x37:
177 return "type A672";
178 case 0x39:
179 return "type A672A ";
180 case 0x3B:
181 return "type A672T";
182 case 0x6B:
183 return "type IC2200";
184 default:
185 return "type A672T";
189 static void arlan_print_diagnostic_info(struct net_device *dev)
191 int i;
192 u_char diagnosticInfo;
193 u_short diagnosticOffset;
194 u_char hardwareType;
195 volatile struct arlan_shmem *arlan = ((struct arlan_private *) dev->priv)->card;
197 // ARLAN_DEBUG_ENTRY("arlan_print_diagnostic_info");
199 if (READSHMB(arlan->configuredStatusFlag) == 0)
200 printk("Arlan: Card NOT configured\n");
201 else
202 printk("Arlan: Card is configured\n");
204 READSHM(diagnosticInfo, arlan->diagnosticInfo, u_char);
205 READSHM(diagnosticOffset, arlan->diagnosticOffset, u_short);
207 printk(KERN_INFO "%s\n", arlan_diagnostic_info_string(dev));
209 if (diagnosticInfo != 0xff)
210 printk("%s arlan: Diagnostic Offset %d \n", dev->name, diagnosticOffset);
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");
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");
222 READSHM(hardwareType, arlan->hardwareType, u_char);
223 printk(KERN_INFO "%s\n", arlan_hardware_type_string(dev));
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);
233 DEBUGSHM(1, "arlan: registration mode is %d\n", arlan->registrationMode, u_char);
235 printk("arlan: name= ");
236 IFDEBUG(1)
238 for (i = 0; i < 16; i++)
240 char c;
241 READSHM(c, arlan->name[i], char);
242 if (c)
243 printk("%c", c);
245 printk("\n");
247 // ARLAN_DEBUG_EXIT("arlan_print_diagnostic_info");
252 /****************************** TEST MEMORY **************/
254 static int arlan_hw_test_memory(struct net_device *dev)
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 volatile struct arlan_shmem *arlan = ((struct arlan_private *) dev->priv)->card;
261 char pattern;
263 ptr = NULL;
265 /* hold card in reset state */
266 setHardwareReset(dev);
268 /* test memory */
269 pattern = 0;
270 for (i = 0; i < memlen; i++)
271 WRITESHM(arlan_mem[i], ((u_char) pattern++), u_char);
273 pattern = 0;
274 for (i = 0; i < memlen; i++)
276 char res;
277 READSHM(res, arlan_mem[i], char);
278 if (res != pattern++)
280 printk(KERN_ERR "Arlan driver memory test 1 failed \n");
281 return -1;
285 pattern = 0;
286 for (i = 0; i < memlen; i++)
287 WRITESHM(arlan_mem[i], ~(pattern++), char);
289 pattern = 0;
290 for (i = 0; i < memlen; i++)
292 char res;
293 READSHM(res, arlan_mem[i], char);
294 if (res != ~(pattern++))
296 printk(KERN_ERR "Arlan driver memory test 2 failed \n");
297 return -1;
301 /* zero memory */
302 for (i = 0; i < memlen; i++)
303 WRITESHM(arlan_mem[i], 0x00, char);
305 IFDEBUG(1) printk(KERN_INFO "Arlan: memory tests ok\n");
307 /* set reset flag and then release reset */
308 WRITESHM(arlan->resetFlag, 0xff, u_char);
310 clearChannelAttention(dev);
311 clearHardwareReset(dev);
313 /* wait for reset flag to become zero, we'll wait for two seconds */
314 if (arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW))
316 printk(KERN_ERR "%s arlan: failed to come back from memory test\n", dev->name);
317 return -1;
319 return 0;
323 static int arlan_setup_card_by_book(struct net_device *dev)
325 u_char irqLevel, configuredStatusFlag;
326 volatile struct arlan_shmem *arlan = ((struct arlan_private *) dev->priv)->card;
328 // ARLAN_DEBUG_ENTRY("arlan_setup_card");
330 READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char);
332 IFDEBUG(10)
333 if (configuredStatusFlag != 0)
334 IFDEBUG(10) printk("arlan: CARD IS CONFIGURED\n");
335 else
336 IFDEBUG(10) printk("arlan: card is NOT configured\n");
338 if (testMemory || (READSHMB(arlan->diagnosticInfo) != 0xff))
339 if (arlan_hw_test_memory(dev))
340 return -1;
342 DEBUGSHM(4, "arlan configuredStatus = %d \n", arlan->configuredStatusFlag, u_char);
343 DEBUGSHM(4, "arlan driver diagnostic: 0x%2x\n", arlan->diagnosticInfo, u_char);
345 /* issue nop command - no interupt */
346 arlan_command(dev, ARLAN_COMMAND_NOOP);
347 if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0)
348 return -1;
350 IFDEBUG(50) printk("1st Noop successfully executed !!\n");
352 /* try to turn on the arlan interrupts */
353 clearClearInterrupt(dev);
354 setClearInterrupt(dev);
355 setInterruptEnable(dev);
357 /* issue nop command - with interrupt */
359 arlan_command(dev, ARLAN_COMMAND_NOOPINT);
360 if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0)
361 return -1;
364 IFDEBUG(50) printk("2nd Noop successfully executed !!\n");
366 READSHM(irqLevel, arlan->irqLevel, u_char)
368 if (irqLevel != dev->irq)
370 IFDEBUG(1) printk(KERN_WARNING "arlan dip switches set irq to %d\n", irqLevel);
371 printk(KERN_WARNING "device driver irq set to %d - does not match\n", dev->irq);
372 dev->irq = irqLevel;
374 else
375 IFDEBUG(2) printk("irq level is OK\n");
378 IFDEBUG(3) arlan_print_diagnostic_info(dev);
380 arlan_command(dev, ARLAN_COMMAND_CONF);
382 READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char);
383 if (configuredStatusFlag == 0)
385 printk(KERN_WARNING "arlan configure failed\n");
386 return -1;
388 arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW);
389 arlan_command(dev, ARLAN_COMMAND_RX);
390 arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW);
391 printk(KERN_NOTICE "%s: arlan driver version %s loaded\n",
392 dev->name, arlan_version);
394 // ARLAN_DEBUG_EXIT("arlan_setup_card");
396 return 0; /* no errors */
400 #ifdef ARLAN_PROC_INTERFACE
401 #ifdef ARLAN_PROC_SHM_DUMP
403 static char arlan_drive_info[ARLAN_STR_SIZE] = "A655\n\0";
405 static int arlan_sysctl_info(ctl_table * ctl, int write, struct file *filp,
406 void *buffer, size_t * lenp)
408 int i;
409 int retv, pos, devnum;
410 struct arlan_private *priva = NULL;
411 struct net_device *dev;
412 pos = 0;
413 if (write)
415 printk("wrirte: ");
416 for (i = 0; i < 100; i++)
417 printk("adi %x \n", arlan_drive_info[i]);
419 if (ctl->procname == NULL || arlan_drive_info == NULL)
421 printk(KERN_WARNING " procname is NULL in sysctl_table or arlan_drive_info is NULL \n at arlan module\n ");
422 return -1;
424 devnum = ctl->procname[5] - '0';
425 if (devnum < 0 || devnum > MAX_ARLANS - 1)
427 printk(KERN_WARNING "too strange devnum in procfs parse\n ");
428 return -1;
430 else if (arlan_device[devnum] == NULL)
432 if (ctl->procname)
433 pos += sprintf(arlan_drive_info + pos, "\t%s\n\n", ctl->procname);
434 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
435 goto final;
437 else
438 priva = arlan_device[devnum]->priv;
440 if (priva == NULL)
442 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
443 return -1;
445 dev = arlan_device[devnum];
447 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
449 pos = sprintf(arlan_drive_info, "Arlan info \n");
450 /* Header Signature */
451 SARLSTR(textRegion, 48);
452 SARLUC(resetFlag);
453 pos += sprintf(arlan_drive_info + pos, "diagnosticInfo\t=\t%s \n", arlan_diagnostic_info_string(dev));
454 SARLUC(diagnosticInfo);
455 SARLUS(diagnosticOffset);
456 SARLUCN(_1, 12);
457 SARLUCN(lanCardNodeId, 6);
458 SARLUCN(broadcastAddress, 6);
459 pos += sprintf(arlan_drive_info + pos, "hardwareType =\t %s \n", arlan_hardware_type_string(dev));
460 SARLUC(hardwareType);
461 SARLUC(majorHardwareVersion);
462 SARLUC(minorHardwareVersion);
463 SARLUC(radioModule);
464 SARLUC(defaultChannelSet);
465 SARLUCN(_2, 47);
467 /* Control/Status Block - 0x0080 */
468 SARLUC(interruptInProgress);
469 SARLUC(cntrlRegImage);
471 SARLUCN(_3, 14);
472 SARLUC(commandByte);
473 SARLUCN(commandParameter, 15);
475 /* Receive Status - 0x00a0 */
476 SARLUC(rxStatus);
477 SARLUC(rxFrmType);
478 SARLUS(rxOffset);
479 SARLUS(rxLength);
480 SARLUCN(rxSrc, 6);
481 SARLUC(rxBroadcastFlag);
482 SARLUC(rxQuality);
483 SARLUC(scrambled);
484 SARLUCN(_4, 1);
486 /* Transmit Status - 0x00b0 */
487 SARLUC(txStatus);
488 SARLUC(txAckQuality);
489 SARLUC(numRetries);
490 SARLUCN(_5, 14);
491 SARLUCN(registeredRouter, 6);
492 SARLUCN(backboneRouter, 6);
493 SARLUC(registrationStatus);
494 SARLUC(configuredStatusFlag);
495 SARLUCN(_6, 1);
496 SARLUCN(ultimateDestAddress, 6);
497 SARLUCN(immedDestAddress, 6);
498 SARLUCN(immedSrcAddress, 6);
499 SARLUS(rxSequenceNumber);
500 SARLUC(assignedLocaltalkAddress);
501 SARLUCN(_7, 27);
503 /* System Parameter Block */
505 /* - Driver Parameters (Novell Specific) */
507 SARLUS(txTimeout);
508 SARLUS(transportTime);
509 SARLUCN(_8, 4);
511 /* - Configuration Parameters */
512 SARLUC(irqLevel);
513 SARLUC(spreadingCode);
514 SARLUC(channelSet);
515 SARLUC(channelNumber);
516 SARLUS(radioNodeId);
517 SARLUCN(_9, 2);
518 SARLUC(scramblingDisable);
519 SARLUC(radioType);
520 SARLUS(routerId);
521 SARLUCN(_10, 9);
522 SARLUC(txAttenuation);
523 SARLUIA(systemId);
524 SARLUS(globalChecksum);
525 SARLUCN(_11, 4);
526 SARLUS(maxDatagramSize);
527 SARLUS(maxFrameSize);
528 SARLUC(maxRetries);
529 SARLUC(receiveMode);
530 SARLUC(priority);
531 SARLUC(rootOrRepeater);
532 SARLUCN(specifiedRouter, 6);
533 SARLUS(fastPollPeriod);
534 SARLUC(pollDecay);
535 SARLUSA(fastPollDelay);
536 SARLUC(arlThreshold);
537 SARLUC(arlDecay);
538 SARLUCN(_12, 1);
539 SARLUS(specRouterTimeout);
540 SARLUCN(_13, 5);
542 /* Scrambled Area */
543 SARLUIA(SID);
544 SARLUCN(encryptionKey, 12);
545 SARLUIA(_14);
546 SARLUSA(waitTime);
547 SARLUSA(lParameter);
548 SARLUCN(_15, 3);
549 SARLUS(headerSize);
550 SARLUS(sectionChecksum);
552 SARLUC(registrationMode);
553 SARLUC(registrationFill);
554 SARLUS(pollPeriod);
555 SARLUS(refreshPeriod);
556 SARLSTR(name, 16);
557 SARLUCN(NID, 6);
558 SARLUC(localTalkAddress);
559 SARLUC(codeFormat);
560 SARLUC(numChannels);
561 SARLUC(channel1);
562 SARLUC(channel2);
563 SARLUC(channel3);
564 SARLUC(channel4);
565 SARLUCN(SSCode, 59);
567 /* SARLUCN( _16, 0x140);
569 /* Statistics Block - 0x0300 */
570 SARLUC(hostcpuLock);
571 SARLUC(lancpuLock);
572 SARLUCN(resetTime, 18);
573 SARLUIA(numDatagramsTransmitted);
574 SARLUIA(numReTransmissions);
575 SARLUIA(numFramesDiscarded);
576 SARLUIA(numDatagramsReceived);
577 SARLUIA(numDuplicateReceivedFrames);
578 SARLUIA(numDatagramsDiscarded);
579 SARLUS(maxNumReTransmitDatagram);
580 SARLUS(maxNumReTransmitFrames);
581 SARLUS(maxNumConsecutiveDuplicateFrames);
582 /* misaligned here so we have to go to characters */
583 SARLUIA(numBytesTransmitted);
584 SARLUIA(numBytesReceived);
585 SARLUIA(numCRCErrors);
586 SARLUIA(numLengthErrors);
587 SARLUIA(numAbortErrors);
588 SARLUIA(numTXUnderruns);
589 SARLUIA(numRXOverruns);
590 SARLUIA(numHoldOffs);
591 SARLUIA(numFramesTransmitted);
592 SARLUIA(numFramesReceived);
593 SARLUIA(numReceiveFramesLost);
594 SARLUIA(numRXBufferOverflows);
595 SARLUIA(numFramesDiscardedAddrMismatch);
596 SARLUIA(numFramesDiscardedSIDMismatch);
597 SARLUIA(numPollsTransmistted);
598 SARLUIA(numPollAcknowledges);
599 SARLUIA(numStatusTimeouts);
600 SARLUIA(numNACKReceived);
601 SARLUS(auxCmd);
602 SARLUCN(dumpPtr, 4);
603 SARLUC(dumpVal);
604 SARLUC(wireTest);
606 /* next 4 seems too long for procfs, over single page ?
607 SARLUCN( _17, 0x86);
608 SARLUCN( txBuffer, 0x800);
609 SARLUCN( rxBuffer, 0x800);
610 SARLUCN( _18, 0x0bff);
613 pos += sprintf(arlan_drive_info + pos, "rxRing\t=\t0x");
614 for (i = 0; i < 0x50; i++)
615 pos += sprintf(arlan_drive_info + pos, "%02x", ((char *) priva->conf)[priva->conf->rxOffset + i]);
616 pos += sprintf(arlan_drive_info + pos, "\n");
618 SARLUC(configStatus);
619 SARLUC(_22);
620 SARLUC(progIOCtrl);
621 SARLUC(shareMBase);
622 SARLUC(controlRegister);
624 pos += sprintf(arlan_drive_info + pos, " total %d chars\n", pos);
625 if (ctl)
626 if (ctl->procname)
627 pos += sprintf(arlan_drive_info + pos, " driver name : %s\n", ctl->procname);
628 final:
629 *lenp = pos;
631 if (!write)
632 retv = proc_dostring(ctl, write, filp, buffer, lenp);
633 else
635 *lenp = 0;
636 return -1;
638 return retv;
642 static int arlan_sysctl_info161719(ctl_table * ctl, int write, struct file *filp,
643 void *buffer, size_t * lenp)
645 int i;
646 int retv, pos, devnum;
647 struct arlan_private *priva = NULL;
649 pos = 0;
650 devnum = ctl->procname[5] - '0';
651 if (arlan_device[devnum] == NULL)
653 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
654 goto final;
656 else
657 priva = arlan_device[devnum]->priv;
658 if (priva == NULL)
660 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
661 return -1;
663 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
664 SARLUCN(_16, 0xC0);
665 SARLUCN(_17, 0x6A);
666 SARLUCN(_18, 14);
667 SARLUCN(_19, 0x86);
668 SARLUCN(_21, 0x3fd);
670 final:
671 *lenp = pos;
672 retv = proc_dostring(ctl, write, filp, buffer, lenp);
673 return retv;
676 static int arlan_sysctl_infotxRing(ctl_table * ctl, int write, struct file *filp,
677 void *buffer, size_t * lenp)
679 int i;
680 int retv, pos, devnum;
681 struct arlan_private *priva = NULL;
683 pos = 0;
684 devnum = ctl->procname[5] - '0';
685 if (arlan_device[devnum] == NULL)
687 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
688 goto final;
690 else
691 priva = arlan_device[devnum]->priv;
692 if (priva == NULL)
694 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
695 return -1;
697 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
698 SARLBNpln(u_char, txBuffer, 0x800);
699 final:
700 *lenp = pos;
701 retv = proc_dostring(ctl, write, filp, buffer, lenp);
702 return retv;
705 static int arlan_sysctl_inforxRing(ctl_table * ctl, int write, struct file *filp,
706 void *buffer, size_t * lenp)
708 int i;
709 int retv, pos, devnum;
710 struct arlan_private *priva = NULL;
712 pos = 0;
713 devnum = ctl->procname[5] - '0';
714 if (arlan_device[devnum] == NULL)
716 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
717 goto final;
718 } else
719 priva = arlan_device[devnum]->priv;
720 if (priva == NULL)
722 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
723 return -1;
725 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
726 SARLBNpln(u_char, rxBuffer, 0x800);
727 final:
728 *lenp = pos;
729 retv = proc_dostring(ctl, write, filp, buffer, lenp);
730 return retv;
733 static int arlan_sysctl_info18(ctl_table * ctl, int write, struct file *filp,
734 void *buffer, size_t * lenp)
736 int i;
737 int retv, pos, devnum;
738 struct arlan_private *priva = NULL;
740 pos = 0;
741 devnum = ctl->procname[5] - '0';
742 if (arlan_device[devnum] == NULL)
744 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
745 goto final;
747 else
748 priva = arlan_device[devnum]->priv;
749 if (priva == NULL)
751 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
752 return -1;
754 memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
755 SARLBNpln(u_char, _18, 0x800);
757 final:
758 *lenp = pos;
759 retv = proc_dostring(ctl, write, filp, buffer, lenp);
760 return retv;
764 #endif /* #ifdef ARLAN_PROC_SHM_DUMP */
767 static char conf_reset_result[200];
769 static int arlan_configure(ctl_table * ctl, int write, struct file *filp,
770 void *buffer, size_t * lenp)
772 int pos = 0;
773 int devnum = ctl->procname[6] - '0';
774 struct arlan_private *priv;
776 if (devnum < 0 || devnum > MAX_ARLANS - 1)
778 printk(KERN_WARNING "too strange devnum in procfs parse\n ");
779 return -1;
781 else if (arlan_device[devnum] != NULL)
783 priv = arlan_device[devnum]->priv;
785 arlan_command(arlan_device[devnum], ARLAN_COMMAND_CLEAN_AND_CONF);
787 else
788 return -1;
790 *lenp = pos;
791 return proc_dostring(ctl, write, filp, buffer, lenp);
794 int arlan_sysctl_reset(ctl_table * ctl, int write, struct file *filp,
795 void *buffer, size_t * lenp)
797 int pos = 0;
798 int devnum = ctl->procname[5] - '0';
799 struct arlan_private *priv;
801 if (devnum < 0 || devnum > MAX_ARLANS - 1)
803 printk(KERN_WARNING "too strange devnum in procfs parse\n ");
804 return -1;
806 else if (arlan_device[devnum] != NULL)
808 priv = arlan_device[devnum]->priv;
809 arlan_command(arlan_device[devnum], ARLAN_COMMAND_CLEAN_AND_RESET);
811 } else
812 return -1;
813 *lenp = pos + 3;
814 return proc_dostring(ctl, write, filp, buffer, lenp);
818 /* Place files in /proc/sys/dev/arlan */
819 #define CTBLN(num,card,nam) \
820 {num , #nam, &(arlan_conf[card].nam), \
821 sizeof(int), 0600, NULL, &proc_dointvec}
824 #define ARLAN_SYSCTL_TABLE_TOTAL(cardNo)\
825 CTBLN(1,cardNo,spreadingCode),\
826 CTBLN(2,cardNo, channelNumber),\
827 CTBLN(3,cardNo, scramblingDisable),\
828 CTBLN(4,cardNo, txAttenuation),\
829 CTBLN(5,cardNo, systemId), \
830 CTBLN(6,cardNo, maxDatagramSize),\
831 CTBLN(7,cardNo, maxFrameSize),\
832 CTBLN(8,cardNo, maxRetries),\
833 CTBLN(9,cardNo, receiveMode),\
834 CTBLN(10,cardNo, priority),\
835 CTBLN(11,cardNo, rootOrRepeater),\
836 CTBLN(12,cardNo, SID),\
837 CTBLN(13,cardNo, registrationMode),\
838 CTBLN(14,cardNo, registrationFill),\
839 CTBLN(15,cardNo, localTalkAddress),\
840 CTBLN(16,cardNo, codeFormat),\
841 CTBLN(17,cardNo, numChannels),\
842 CTBLN(18,cardNo, channel1),\
843 CTBLN(19,cardNo, channel2),\
844 CTBLN(20,cardNo, channel3),\
845 CTBLN(21,cardNo, channel4),\
846 CTBLN(22,cardNo, txClear),\
847 CTBLN(23,cardNo, txRetries),\
848 CTBLN(24,cardNo, txRouting),\
849 CTBLN(25,cardNo, txScrambled),\
850 CTBLN(26,cardNo, rxParameter),\
851 CTBLN(27,cardNo, txTimeoutMs),\
852 CTBLN(28,cardNo, waitCardTimeout),\
853 CTBLN(29,cardNo, channelSet), \
854 {30, "name", arlan_conf[cardNo].siteName, \
855 16, 0600, NULL, &proc_dostring},\
856 CTBLN(31,cardNo,waitTime),\
857 CTBLN(32,cardNo,lParameter),\
858 CTBLN(33,cardNo,_15),\
859 CTBLN(34,cardNo,headerSize),\
860 CTBLN(35,cardNo,async),\
861 CTBLN(36,cardNo,tx_delay_ms),\
862 CTBLN(37,cardNo,retries),\
863 CTBLN(38,cardNo,ReTransmitPacketMaxSize),\
864 CTBLN(39,cardNo,waitReTransmitPacketMaxSize),\
865 CTBLN(40,cardNo,fastReTransCount),\
866 CTBLN(41,cardNo,driverRetransmissions),\
867 CTBLN(42,cardNo,txAckTimeoutMs),\
868 CTBLN(43,cardNo,registrationInterrupts),\
869 CTBLN(44,cardNo,hardwareType),\
870 CTBLN(45,cardNo,radioType),\
871 CTBLN(46,cardNo,writeEEPROM),\
872 CTBLN(47,cardNo,writeRadioType),\
873 {48, "entry_exit_debug", &arlan_entry_and_exit_debug, \
874 sizeof(int), 0600, NULL, &proc_dointvec},\
875 {49, "debug", &arlan_debug, \
876 sizeof(int), 0600, NULL, &proc_dointvec},\
877 CTBLN(50,cardNo,in_speed),\
878 CTBLN(51,cardNo,out_speed),\
879 CTBLN(52,cardNo,in_speed10),\
880 CTBLN(53,cardNo,out_speed10),\
881 CTBLN(54,cardNo,in_speed_max),\
882 CTBLN(55,cardNo,out_speed_max),\
883 CTBLN(56,cardNo,measure_rate),\
884 CTBLN(57,cardNo,pre_Command_Wait),\
885 CTBLN(58,cardNo,rx_tweak1),\
886 CTBLN(59,cardNo,rx_tweak2),\
887 CTBLN(60,cardNo,tx_queue_len),\
891 static ctl_table arlan_conf_table0[] =
893 ARLAN_SYSCTL_TABLE_TOTAL(0)
895 #ifdef ARLAN_PROC_SHM_DUMP
896 {150, "arlan0-txRing", &arlan_drive_info,
897 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_infotxRing},
898 {151, "arlan0-rxRing", &arlan_drive_info,
899 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_inforxRing},
900 {152, "arlan0-18", &arlan_drive_info,
901 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info18},
902 {153, "arlan0-ring", &arlan_drive_info,
903 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info161719},
904 {154, "arlan0-shm-cpy", &arlan_drive_info,
905 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info},
906 #endif
907 {155, "config0", &conf_reset_result, \
908 100, 0400, NULL, &arlan_configure}, \
909 {156, "reset0", &conf_reset_result, \
910 100, 0400, NULL, &arlan_sysctl_reset}, \
914 static ctl_table arlan_conf_table1[] =
917 ARLAN_SYSCTL_TABLE_TOTAL(1)
919 #ifdef ARLAN_PROC_SHM_DUMP
920 {150, "arlan1-txRing", &arlan_drive_info,
921 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_infotxRing},
922 {151, "arlan1-rxRing", &arlan_drive_info,
923 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_inforxRing},
924 {152, "arlan1-18", &arlan_drive_info,
925 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info18},
926 {153, "arlan1-ring", &arlan_drive_info,
927 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info161719},
928 {154, "arlan1-shm-cpy", &arlan_drive_info,
929 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info},
930 #endif
931 {155, "config1", &conf_reset_result,
932 100, 0400, NULL, &arlan_configure},
933 {156, "reset1", &conf_reset_result,
934 100, 0400, NULL, &arlan_sysctl_reset},
938 static ctl_table arlan_conf_table2[] =
941 ARLAN_SYSCTL_TABLE_TOTAL(2)
943 #ifdef ARLAN_PROC_SHM_DUMP
944 {150, "arlan2-txRing", &arlan_drive_info,
945 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_infotxRing},
946 {151, "arlan2-rxRing", &arlan_drive_info,
947 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_inforxRing},
948 {152, "arlan2-18", &arlan_drive_info,
949 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info18},
950 {153, "arlan2-ring", &arlan_drive_info,
951 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info161719},
952 {154, "arlan2-shm-cpy", &arlan_drive_info,
953 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info},
954 #endif
955 {155, "config2", &conf_reset_result,
956 100, 0400, NULL, &arlan_configure},
957 {156, "reset2", &conf_reset_result,
958 100, 0400, NULL, &arlan_sysctl_reset},
962 static ctl_table arlan_conf_table3[] =
965 ARLAN_SYSCTL_TABLE_TOTAL(3)
967 #ifdef ARLAN_PROC_SHM_DUMP
968 {150, "arlan3-txRing", &arlan_drive_info,
969 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_infotxRing},
970 {151, "arlan3-rxRing", &arlan_drive_info,
971 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_inforxRing},
972 {152, "arlan3-18", &arlan_drive_info,
973 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info18},
974 {153, "arlan3-ring", &arlan_drive_info,
975 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info161719},
976 {154, "arlan3-shm-cpy", &arlan_drive_info,
977 ARLAN_STR_SIZE, 0400, NULL, &arlan_sysctl_info},
978 #endif
979 {155, "config3", &conf_reset_result,
980 100, 0400, NULL, &arlan_configure},
981 {156, "reset3", &conf_reset_result,
982 100, 0400, NULL, &arlan_sysctl_reset},
988 static ctl_table arlan_table[] =
990 {0, "arlan0", NULL, 0, 0600, arlan_conf_table0},
991 {0, "arlan1", NULL, 0, 0600, arlan_conf_table1},
992 {0, "arlan2", NULL, 0, 0600, arlan_conf_table2},
993 {0, "arlan3", NULL, 0, 0600, arlan_conf_table3},
997 #else
999 static ctl_table arlan_table[MAX_ARLANS + 1] =
1003 #endif
1004 #endif
1006 static int mmtu = 1234;
1008 static ctl_table arlan_root_table[] =
1010 {254, "arlan", NULL, 0, 0555, arlan_table},
1014 /* Make sure that /proc/sys/dev is there */
1015 static ctl_table arlan_device_root_table[] =
1017 {CTL_DEV, "dev", NULL, 0, 0555, arlan_root_table},
1023 static struct ctl_table_header *arlan_device_sysctl_header = NULL;
1025 int init_arlan_proc(void)
1028 int i = 0;
1029 if (arlan_device_sysctl_header)
1030 return 0;
1031 for (i = 0; i < MAX_ARLANS && arlan_device[i]; i++)
1032 arlan_table[i].ctl_name = i + 1;
1033 arlan_device_sysctl_header = register_sysctl_table(arlan_root_table, 0);
1034 if (!arlan_device_sysctl_header)
1035 return -1;
1037 return 0;
1043 #ifdef MODULE
1045 int init_module(void)
1048 return init_arlan_proc();
1051 void cleanup_module(void)
1053 unregister_sysctl_table(arlan_device_sysctl_header);
1054 arlan_device_sysctl_header = NULL;
1056 return;
1059 #endif // MODULE