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