sysctl: Drop & in front of every proc_handler.
[linux-2.6.git] / drivers / net / wireless / arlan-proc.c
1 #include "arlan.h"
2
3 #include <linux/sysctl.h>
4
5 #ifdef CONFIG_PROC_FS
6
7 /* void enableReceive(struct net_device* dev);
8 */
9
10
11
12 #define ARLAN_STR_SIZE  0x2ff0
13 #define DEV_ARLAN_INFO  1
14 #define DEV_ARLAN       1
15 #define SARLG(type,var) {\
16         pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n", #var, READSHMB(priva->card->var));        \
17         }
18
19 #define SARLBN(type,var,nn) {\
20         pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x",#var);\
21         for (i=0; i < nn; i++ ) pos += sprintf(arlan_drive_info+pos, "%02x",READSHMB(priva->card->var[i]));\
22         pos += sprintf(arlan_drive_info+pos, "\n");     \
23         }
24
25 #define SARLBNpln(type,var,nn) {\
26         for (i=0; i < nn; i++ ) pos += sprintf(arlan_drive_info+pos, "%02x",READSHMB(priva->card->var[i]));\
27         }
28
29 #define SARLSTR(var,nn) {\
30         char tmpStr[400];\
31         int  tmpLn = nn;\
32         if (nn > 399 ) tmpLn = 399; \
33         memcpy(tmpStr,(char *) priva->conf->var,tmpLn);\
34         tmpStr[tmpLn] = 0; \
35         pos += sprintf(arlan_drive_info+pos, "%s\t=\t%s \n",#var,priva->conf->var);\
36         }
37
38 #define SARLUC(var)     SARLG(u_char, var)
39 #define SARLUCN(var,nn) SARLBN(u_char,var, nn)
40 #define SARLUS(var)     SARLG(u_short, var)
41 #define SARLUSN(var,nn) SARLBN(u_short,var, nn)
42 #define SARLUI(var)     SARLG(u_int, var)
43
44 #define SARLUSA(var) {\
45         u_short tmpVar;\
46         memcpy(&tmpVar, (short *) priva->conf->var,2); \
47         pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n",#var, tmpVar);\
48 }
49
50 #define SARLUIA(var) {\
51         u_int tmpVar;\
52         memcpy(&tmpVar, (int* )priva->conf->var,4); \
53         pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n",#var, tmpVar);\
54 }
55
56
57 static const char *arlan_diagnostic_info_string(struct net_device *dev)
58 {
59
60         struct arlan_private *priv = netdev_priv(dev);
61         volatile struct arlan_shmem __iomem *arlan = priv->card;
62         u_char diagnosticInfo;
63
64         READSHM(diagnosticInfo, arlan->diagnosticInfo, u_char);
65
66         switch (diagnosticInfo)
67         {
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 ";
110           }
111 }
112
113 static const char *arlan_hardware_type_string(struct net_device *dev)
114 {
115         u_char hardwareType;
116         struct arlan_private *priv = netdev_priv(dev);
117         volatile struct arlan_shmem __iomem *arlan = priv->card;
118
119         READSHM(hardwareType, arlan->hardwareType, u_char);
120         switch (hardwareType)
121         {
122                 case 0x00:
123                         return "type A450";
124                 case 0x01:
125                         return "type A650 ";
126                 case 0x04:
127                         return "type TMA coproc";
128                 case 0x0D:
129                         return "type A650E ";
130                 case 0x18:
131                         return "type TMA coproc Australian";
132                 case 0x19:
133                         return "type A650A ";
134                 case 0x26:
135                         return "type TMA coproc European";
136                 case 0x2E:
137                         return "type A655 ";
138                 case 0x2F:
139                         return "type A655A ";
140                 case 0x30:
141                         return "type A655E ";
142                 case 0x0B:
143                         return "type A670 ";
144                 case 0x0C:
145                         return "type A670E ";
146                 case 0x2D:
147                         return "type A670A ";
148                 case 0x0F:
149                         return "type A411T";
150                 case 0x16:
151                         return "type A411TA";
152                 case 0x1B:
153                         return "type A440T";
154                 case 0x1C:
155                         return "type A412T";
156                 case 0x1E:
157                         return "type A412TA";
158                 case 0x22:
159                         return "type A411TE";
160                 case 0x24:
161                         return "type A412TE";
162                 case 0x27:
163                         return "type A671T ";
164                 case 0x29:
165                         return "type A671TA ";
166                 case 0x2B:
167                         return "type A671TE ";
168                 case 0x31:
169                         return "type A415T ";
170                 case 0x33:
171                         return "type A415TA ";
172                 case 0x35:
173                         return "type A415TE ";
174                 case 0x37:
175                         return "type A672";
176                 case 0x39:
177                         return "type A672A ";
178                 case 0x3B:
179                         return "type A672T";
180                 case 0x6B:
181                         return "type IC2200";
182                 default:
183                         return "type A672T";
184         }
185 }
186 #ifdef ARLAN_DEBUGGING
187 static void arlan_print_diagnostic_info(struct net_device *dev)
188 {
189         int i;
190         u_char diagnosticInfo;
191         u_short diagnosticOffset;
192         u_char hardwareType;
193         struct arlan_private *priv = netdev_priv(dev);
194         volatile struct arlan_shmem __iomem *arlan = priv->card;
195
196         //  ARLAN_DEBUG_ENTRY("arlan_print_diagnostic_info");
197
198         if (READSHMB(arlan->configuredStatusFlag) == 0)
199                 printk("Arlan: Card NOT configured\n");
200         else
201                 printk("Arlan: Card is configured\n");
202
203         READSHM(diagnosticInfo, arlan->diagnosticInfo, u_char);
204         READSHM(diagnosticOffset, arlan->diagnosticOffset, u_short);
205
206         printk(KERN_INFO "%s\n", arlan_diagnostic_info_string(dev));
207
208         if (diagnosticInfo != 0xff)
209                 printk("%s arlan: Diagnostic Offset %d \n", dev->name, diagnosticOffset);
210
211         printk("arlan: LAN CODE ID = ");
212         for (i = 0; i < 6; i++)
213                 DEBUGSHM(1, "%03d:", arlan->lanCardNodeId[i], u_char);
214         printk("\n");
215
216         printk("arlan: Arlan BroadCast address  = ");
217         for (i = 0; i < 6; i++)
218                 DEBUGSHM(1, "%03d:", arlan->broadcastAddress[i], u_char);
219         printk("\n");
220
221         READSHM(hardwareType, arlan->hardwareType, u_char);
222         printk(KERN_INFO "%s\n", arlan_hardware_type_string(dev));
223
224
225         DEBUGSHM(1, "arlan: channelNumber=%d\n", arlan->channelNumber, u_char);
226         DEBUGSHM(1, "arlan: channelSet=%d\n", arlan->channelSet, u_char);
227         DEBUGSHM(1, "arlan: spreadingCode=%d\n", arlan->spreadingCode, u_char);
228         DEBUGSHM(1, "arlan: radioNodeId=%d\n", arlan->radioNodeId, u_short);
229         DEBUGSHM(1, "arlan: SID =%d\n", arlan->SID, u_short);
230         DEBUGSHM(1, "arlan: rxOffset=%d\n", arlan->rxOffset, u_short);
231
232         DEBUGSHM(1, "arlan: registration mode is %d\n", arlan->registrationMode, u_char);
233
234         printk("arlan: name= ");
235         IFDEBUG(1)
236         
237         for (i = 0; i < 16; i++)
238         {
239                 char c;
240                 READSHM(c, arlan->name[i], char);
241                 if (c)
242                         printk("%c", c);
243         }
244         printk("\n");
245
246 //   ARLAN_DEBUG_EXIT("arlan_print_diagnostic_info");
247
248 }
249
250
251 /******************************         TEST    MEMORY  **************/
252
253 static int arlan_hw_test_memory(struct net_device *dev)
254 {
255         u_char *ptr;
256         int i;
257         int memlen = sizeof(struct arlan_shmem) - 0xF;  /* avoid control register */
258         volatile char *arlan_mem = (char *) (dev->mem_start);
259         struct arlan_private *priv = netdev_priv(dev);
260         volatile struct arlan_shmem __iomem *arlan = priv->card;
261         char pattern;
262
263         ptr = NULL;
264
265         /* hold card in reset state */
266         setHardwareReset(dev);
267
268         /* test memory */
269         pattern = 0;
270         for (i = 0; i < memlen; i++)
271                 WRITESHM(arlan_mem[i], ((u_char) pattern++), u_char);
272
273         pattern = 0;
274         for (i = 0; i < memlen; i++)
275         {
276                 char res;
277                 READSHM(res, arlan_mem[i], char);
278                 if (res != pattern++)
279                 {
280                         printk(KERN_ERR "Arlan driver memory test 1 failed \n");
281                         return -1;
282                 }
283         }
284
285         pattern = 0;
286         for (i = 0; i < memlen; i++)
287                 WRITESHM(arlan_mem[i], ~(pattern++), char);
288
289         pattern = 0;
290         for (i = 0; i < memlen; i++)
291         {
292                 char res;
293                 READSHM(res, arlan_mem[i], char);
294                 if (res != ~(pattern++))
295                 {
296                         printk(KERN_ERR "Arlan driver memory test 2 failed \n");
297                         return -1;
298                 }
299         }
300
301         /* zero memory */
302         for (i = 0; i < memlen; i++)
303                 WRITESHM(arlan_mem[i], 0x00, char);
304
305         IFDEBUG(1) printk(KERN_INFO "Arlan: memory tests ok\n");
306
307         /* set reset flag and then release reset */
308         WRITESHM(arlan->resetFlag, 0xff, u_char);
309
310         clearChannelAttention(dev);
311         clearHardwareReset(dev);
312
313         /* wait for reset flag to become zero, we'll wait for two seconds */
314         if (arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW))
315         {
316                 printk(KERN_ERR "%s arlan: failed to come back from memory test\n", dev->name);
317                 return -1;
318         }
319         return 0;
320 }
321
322 static int arlan_setup_card_by_book(struct net_device *dev)
323 {
324         u_char irqLevel, configuredStatusFlag;
325         struct arlan_private *priv = netdev_priv(dev);
326         volatile struct arlan_shmem __iomem *arlan = priv->card;
327
328 //      ARLAN_DEBUG_ENTRY("arlan_setup_card");
329
330         READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char);
331
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");
337
338         if (testMemory || (READSHMB(arlan->diagnosticInfo) != 0xff))
339                 if (arlan_hw_test_memory(dev))
340                         return -1;
341
342         DEBUGSHM(4, "arlan configuredStatus = %d \n", arlan->configuredStatusFlag, u_char);
343         DEBUGSHM(4, "arlan driver diagnostic: 0x%2x\n", arlan->diagnosticInfo, u_char);
344
345         /* issue nop command - no interrupt */
346         arlan_command(dev, ARLAN_COMMAND_NOOP);
347         if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0)
348                 return -1;
349
350         IFDEBUG(50) printk("1st Noop successfully executed !!\n");
351
352         /* try to turn on the arlan interrupts */
353         clearClearInterrupt(dev);
354         setClearInterrupt(dev);
355         setInterruptEnable(dev);
356
357         /* issue nop command - with interrupt */
358
359         arlan_command(dev, ARLAN_COMMAND_NOOPINT);
360         if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0)
361                 return -1;
362
363
364         IFDEBUG(50) printk("2nd Noop successfully executed !!\n");
365
366         READSHM(irqLevel, arlan->irqLevel, u_char)
367         
368         if (irqLevel != dev->irq)
369         {
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;
373         }
374         else
375                 IFDEBUG(2) printk("irq level is OK\n");
376
377
378         IFDEBUG(3) arlan_print_diagnostic_info(dev);
379
380         arlan_command(dev, ARLAN_COMMAND_CONF);
381
382         READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char);
383         if (configuredStatusFlag == 0)
384         {
385                 printk(KERN_WARNING "arlan configure failed\n");
386                 return -1;
387         }
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);
393
394 //      ARLAN_DEBUG_EXIT("arlan_setup_card");
395
396         return 0;               /* no errors */
397 }
398 #endif
399
400 #ifdef ARLAN_PROC_INTERFACE
401 #ifdef ARLAN_PROC_SHM_DUMP
402
403 static char arlan_drive_info[ARLAN_STR_SIZE] = "A655\n\0";
404
405 static int arlan_sysctl_info(ctl_table * ctl, int write,
406                       void __user *buffer, size_t * lenp, loff_t *ppos)
407 {
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)
414         {
415                 printk("wrirte: ");
416                 for (i = 0; i < 100; i++)
417                         printk("adi %x \n", arlan_drive_info[i]);
418         }
419         if (ctl->procname == NULL || arlan_drive_info == NULL)
420         {
421                 printk(KERN_WARNING " procname is NULL in sysctl_table or arlan_drive_info is NULL \n at arlan module\n ");
422                 return -1;
423         }
424         devnum = ctl->procname[5] - '0';
425         if (devnum < 0 || devnum > MAX_ARLANS - 1)
426         {
427                 printk(KERN_WARNING "too strange devnum in procfs parse\n ");
428                 return -1;
429         }
430         else if (arlan_device[devnum] == NULL)
431         {
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;
436         }
437         else
438                 priva = netdev_priv(arlan_device[devnum]);
439
440         if (priva == NULL)
441         {
442                 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
443                 return -1;
444         }
445         dev = arlan_device[devnum];
446
447         memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
448
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);
466
467         /* Control/Status Block - 0x0080 */
468         SARLUC(interruptInProgress);
469         SARLUC(cntrlRegImage);
470
471         SARLUCN(_3, 14);
472         SARLUC(commandByte);
473         SARLUCN(commandParameter, 15);
474
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);
485
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);
502
503         /* System Parameter Block */
504
505         /* - Driver Parameters (Novell Specific) */
506
507         SARLUS(txTimeout);
508         SARLUS(transportTime);
509         SARLUCN(_8, 4);
510
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);
541
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);
551
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);
566
567 /*      SARLUCN( _16, 0x140);
568  */
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);
605         
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);
611          */
612
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");
617
618         SARLUC(configStatus);
619         SARLUC(_22);
620         SARLUC(progIOCtrl);
621         SARLUC(shareMBase);
622         SARLUC(controlRegister);
623
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;
630
631         if (!write)
632                 retv = proc_dostring(ctl, write, buffer, lenp, ppos);
633         else
634         {
635                 *lenp = 0;
636                 return -1;
637         }
638         return retv;
639 }
640
641
642 static int arlan_sysctl_info161719(ctl_table * ctl, int write,
643                             void __user *buffer, size_t * lenp, loff_t *ppos)
644 {
645         int i;
646         int retv, pos, devnum;
647         struct arlan_private *priva = NULL;
648
649         pos = 0;
650         devnum = ctl->procname[5] - '0';
651         if (arlan_device[devnum] == NULL)
652         {
653                 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
654                 goto final;
655         }
656         else
657                 priva = netdev_priv(arlan_device[devnum]);
658         if (priva == NULL)
659         {
660                 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
661                 return -1;
662         }
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);
669
670 final:
671         *lenp = pos;
672         retv = proc_dostring(ctl, write, buffer, lenp, ppos);
673         return retv;
674 }
675
676 static int arlan_sysctl_infotxRing(ctl_table * ctl, int write,
677                             void __user *buffer, size_t * lenp, loff_t *ppos)
678 {
679         int i;
680         int retv, pos, devnum;
681         struct arlan_private *priva = NULL;
682
683         pos = 0;
684         devnum = ctl->procname[5] - '0';
685         if (arlan_device[devnum] == NULL)
686         {
687                   pos += sprintf(arlan_drive_info + pos, "No device found here \n");
688                   goto final;
689         }
690         else
691                 priva = netdev_priv(arlan_device[devnum]);
692         if (priva == NULL)
693         {
694                 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
695                 return -1;
696         }
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, buffer, lenp, ppos);
702         return retv;
703 }
704
705 static int arlan_sysctl_inforxRing(ctl_table * ctl, int write,
706                             void __user *buffer, size_t * lenp, loff_t *ppos)
707 {
708         int i;
709         int retv, pos, devnum;
710         struct arlan_private *priva = NULL;
711
712         pos = 0;
713         devnum = ctl->procname[5] - '0';
714         if (arlan_device[devnum] == NULL)
715         {
716                   pos += sprintf(arlan_drive_info + pos, "No device found here \n");
717                   goto final;
718         } else
719                 priva = netdev_priv(arlan_device[devnum]);
720         if (priva == NULL)
721         {
722                 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
723                 return -1;
724         }
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, buffer, lenp, ppos);
730         return retv;
731 }
732
733 static int arlan_sysctl_info18(ctl_table * ctl, int write,
734                         void __user *buffer, size_t * lenp, loff_t *ppos)
735 {
736         int i;
737         int retv, pos, devnum;
738         struct arlan_private *priva = NULL;
739
740         pos = 0;
741         devnum = ctl->procname[5] - '0';
742         if (arlan_device[devnum] == NULL)
743         {
744                 pos += sprintf(arlan_drive_info + pos, "No device found here \n");
745                 goto final;
746         }
747         else
748                 priva = netdev_priv(arlan_device[devnum]);
749         if (priva == NULL)
750         {
751                 printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n ");
752                 return -1;
753         }
754         memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem));
755         SARLBNpln(u_char, _18, 0x800);
756
757 final:
758         *lenp = pos;
759         retv = proc_dostring(ctl, write, buffer, lenp, ppos);
760         return retv;
761 }
762
763
764 #endif                          /* #ifdef ARLAN_PROC_SHM_DUMP */
765
766
767 static char conf_reset_result[200];
768
769 static int arlan_configure(ctl_table * ctl, int write,
770                     void __user *buffer, size_t * lenp, loff_t *ppos)
771 {
772         int pos = 0;
773         int devnum = ctl->procname[6] - '0';
774         struct arlan_private *priv;
775
776         if (devnum < 0 || devnum > MAX_ARLANS - 1)
777         {
778                   printk(KERN_WARNING "too strange devnum in procfs parse\n ");
779                   return -1;
780         }
781         else if (arlan_device[devnum] != NULL)
782         {
783                   priv = netdev_priv(arlan_device[devnum]);
784
785                   arlan_command(arlan_device[devnum], ARLAN_COMMAND_CLEAN_AND_CONF);
786         }
787         else
788                 return -1;
789
790         *lenp = pos;
791         return proc_dostring(ctl, write, buffer, lenp, ppos);
792 }
793
794 static int arlan_sysctl_reset(ctl_table * ctl, int write,
795                        void __user *buffer, size_t * lenp, loff_t *ppos)
796 {
797         int pos = 0;
798         int devnum = ctl->procname[5] - '0';
799         struct arlan_private *priv;
800
801         if (devnum < 0 || devnum > MAX_ARLANS - 1)
802         {
803                   printk(KERN_WARNING "too strange devnum in procfs parse\n ");
804                   return -1;
805         }
806         else if (arlan_device[devnum] != NULL)
807         {
808                 priv = netdev_priv(arlan_device[devnum]);
809                 arlan_command(arlan_device[devnum], ARLAN_COMMAND_CLEAN_AND_RESET);
810
811         } else
812                 return -1;
813         *lenp = pos + 3;
814         return proc_dostring(ctl, write, buffer, lenp, ppos);
815 }
816
817
818 /* Place files in /proc/sys/dev/arlan */
819 #define CTBLN(card,nam) \
820         { .procname = #nam,\
821           .data = &(arlan_conf[card].nam),\
822           .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec}
823 #ifdef ARLAN_DEBUGGING
824
825 #define ARLAN_PROC_DEBUG_ENTRIES \
826         { .procname = "entry_exit_debug",\
827           .data = &arlan_entry_and_exit_debug,\
828           .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec},\
829         { .procname = "debug", .data = &arlan_debug,\
830           .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec},
831 #else 
832 #define ARLAN_PROC_DEBUG_ENTRIES
833 #endif
834
835 #define ARLAN_SYSCTL_TABLE_TOTAL(cardNo)\
836         CTBLN(cardNo,spreadingCode),\
837         CTBLN(cardNo, channelNumber),\
838         CTBLN(cardNo, scramblingDisable),\
839         CTBLN(cardNo, txAttenuation),\
840         CTBLN(cardNo, systemId), \
841         CTBLN(cardNo, maxDatagramSize),\
842         CTBLN(cardNo, maxFrameSize),\
843         CTBLN(cardNo, maxRetries),\
844         CTBLN(cardNo, receiveMode),\
845         CTBLN(cardNo, priority),\
846         CTBLN(cardNo, rootOrRepeater),\
847         CTBLN(cardNo, SID),\
848         CTBLN(cardNo, registrationMode),\
849         CTBLN(cardNo, registrationFill),\
850         CTBLN(cardNo, localTalkAddress),\
851         CTBLN(cardNo, codeFormat),\
852         CTBLN(cardNo, numChannels),\
853         CTBLN(cardNo, channel1),\
854         CTBLN(cardNo, channel2),\
855         CTBLN(cardNo, channel3),\
856         CTBLN(cardNo, channel4),\
857         CTBLN(cardNo, txClear),\
858         CTBLN(cardNo, txRetries),\
859         CTBLN(cardNo, txRouting),\
860         CTBLN(cardNo, txScrambled),\
861         CTBLN(cardNo, rxParameter),\
862         CTBLN(cardNo, txTimeoutMs),\
863         CTBLN(cardNo, waitCardTimeout),\
864         CTBLN(cardNo, channelSet), \
865         { .procname = "name",\
866          .data = arlan_conf[cardNo].siteName,\
867          .maxlen = 16, .mode = 0600, .proc_handler = proc_dostring},\
868         CTBLN(cardNo,waitTime),\
869         CTBLN(cardNo,lParameter),\
870         CTBLN(cardNo,_15),\
871         CTBLN(cardNo,headerSize),\
872         CTBLN(cardNo,tx_delay_ms),\
873         CTBLN(cardNo,retries),\
874         CTBLN(cardNo,ReTransmitPacketMaxSize),\
875         CTBLN(cardNo,waitReTransmitPacketMaxSize),\
876         CTBLN(cardNo,fastReTransCount),\
877         CTBLN(cardNo,driverRetransmissions),\
878         CTBLN(cardNo,txAckTimeoutMs),\
879         CTBLN(cardNo,registrationInterrupts),\
880         CTBLN(cardNo,hardwareType),\
881         CTBLN(cardNo,radioType),\
882         CTBLN(cardNo,writeEEPROM),\
883         CTBLN(cardNo,writeRadioType),\
884         ARLAN_PROC_DEBUG_ENTRIES\
885         CTBLN(cardNo,in_speed),\
886         CTBLN(cardNo,out_speed),\
887         CTBLN(cardNo,in_speed10),\
888         CTBLN(cardNo,out_speed10),\
889         CTBLN(cardNo,in_speed_max),\
890         CTBLN(cardNo,out_speed_max),\
891         CTBLN(cardNo,measure_rate),\
892         CTBLN(cardNo,pre_Command_Wait),\
893         CTBLN(cardNo,rx_tweak1),\
894         CTBLN(cardNo,rx_tweak2),\
895         CTBLN(cardNo,tx_queue_len),\
896
897
898
899 static ctl_table arlan_conf_table0[] =
900 {
901         ARLAN_SYSCTL_TABLE_TOTAL(0)
902
903 #ifdef ARLAN_PROC_SHM_DUMP
904         {
905                 .procname       = "arlan0-txRing",
906                 .data           = &arlan_drive_info,
907                 .maxlen         = ARLAN_STR_SIZE,
908                 .mode           = 0400,
909                 .proc_handler   = arlan_sysctl_infotxRing,
910         },
911         {
912                 .procname       = "arlan0-rxRing",
913                 .data           = &arlan_drive_info,
914                 .maxlen         = ARLAN_STR_SIZE,
915                 .mode           = 0400,
916                 .proc_handler   = arlan_sysctl_inforxRing,
917         },
918         {
919                 .procname       = "arlan0-18",
920                 .data           = &arlan_drive_info,
921                 .maxlen         = ARLAN_STR_SIZE,
922                 .mode           = 0400,
923                 .proc_handler   = arlan_sysctl_info18,
924         },
925         {
926                 .procname       = "arlan0-ring",
927                 .data           = &arlan_drive_info,
928                 .maxlen         = ARLAN_STR_SIZE,
929                 .mode           = 0400,
930                 .proc_handler   = arlan_sysctl_info161719,
931         },
932         {
933                 .procname       = "arlan0-shm-cpy",
934                 .data           = &arlan_drive_info,
935                 .maxlen         = ARLAN_STR_SIZE,
936                 .mode           = 0400,
937                 .proc_handler   = arlan_sysctl_info,
938         },
939 #endif
940         {
941                 .procname       = "config0",
942                 .data           = &conf_reset_result,
943                 .maxlen         = 100,
944                 .mode           = 0400,
945                 .proc_handler   = arlan_configure
946         },
947         {
948                 .procname       = "reset0",
949                 .data           = &conf_reset_result,
950                 .maxlen         = 100,
951                 .mode           = 0400,
952                 .proc_handler   = arlan_sysctl_reset,
953         },
954         {  }
955 };
956
957 static ctl_table arlan_conf_table1[] =
958 {
959
960         ARLAN_SYSCTL_TABLE_TOTAL(1)
961
962 #ifdef ARLAN_PROC_SHM_DUMP
963         {
964                 .procname       = "arlan1-txRing",
965                 .data           = &arlan_drive_info,
966                 .maxlen         = ARLAN_STR_SIZE,
967                 .mode           = 0400,
968                 .proc_handler   = arlan_sysctl_infotxRing,
969         },
970         {
971                 .procname       = "arlan1-rxRing",
972                 .data           = &arlan_drive_info,
973                 .maxlen         = ARLAN_STR_SIZE,
974                 .mode           = 0400,
975                 .proc_handler   = arlan_sysctl_inforxRing,
976         },
977         {
978                 .procname       = "arlan1-18",
979                 .data           = &arlan_drive_info,
980                 .maxlen         = ARLAN_STR_SIZE,
981                 .mode           = 0400,
982                 .proc_handler   = arlan_sysctl_info18,
983         },
984         {
985                 .procname       = "arlan1-ring",
986                 .data           = &arlan_drive_info,
987                 .maxlen         = ARLAN_STR_SIZE,
988                 .mode           = 0400,
989                 .proc_handler   = arlan_sysctl_info161719,
990         },
991         {
992                 .procname       = "arlan1-shm-cpy",
993                 .data           = &arlan_drive_info,
994                 .maxlen         = ARLAN_STR_SIZE,
995                 .mode           = 0400,
996                 .proc_handler   = arlan_sysctl_info,
997         },
998 #endif
999         {
1000                 .procname       = "config1",
1001                 .data           = &conf_reset_result,
1002                 .maxlen         = 100,
1003                 .mode           = 0400,
1004                 .proc_handler   = arlan_configure,
1005         },
1006         {
1007                 .procname       = "reset1",
1008                 .data           = &conf_reset_result,
1009                 .maxlen         = 100,
1010                 .mode           = 0400,
1011                 .proc_handler   = arlan_sysctl_reset,
1012         },
1013         { }
1014 };
1015
1016 static ctl_table arlan_conf_table2[] =
1017 {
1018
1019         ARLAN_SYSCTL_TABLE_TOTAL(2)
1020
1021 #ifdef ARLAN_PROC_SHM_DUMP
1022         {
1023                 .procname       = "arlan2-txRing",
1024                 .data           = &arlan_drive_info,
1025                 .maxlen         = ARLAN_STR_SIZE,
1026                 .mode           = 0400,
1027                 .proc_handler   = arlan_sysctl_infotxRing,
1028         },
1029         {
1030                 .procname       = "arlan2-rxRing",
1031                 .data           = &arlan_drive_info,
1032                 .maxlen         = ARLAN_STR_SIZE,
1033                 .mode           = 0400,
1034                 .proc_handler   = arlan_sysctl_inforxRing,
1035         },
1036         {
1037                 .procname       = "arlan2-18",
1038                 .data           = &arlan_drive_info,
1039                 .maxlen         = ARLAN_STR_SIZE,
1040                 .mode           = 0400,
1041                 .proc_handler   = arlan_sysctl_info18,
1042         },
1043         {
1044                 .procname       = "arlan2-ring",
1045                 .data           = &arlan_drive_info,
1046                 .maxlen         = ARLAN_STR_SIZE,
1047                 .mode           = 0400,
1048                 .proc_handler   = arlan_sysctl_info161719,
1049         },
1050         {
1051                 .procname       = "arlan2-shm-cpy",
1052                 .data           = &arlan_drive_info,
1053                 .maxlen         = ARLAN_STR_SIZE,
1054                 .mode           = 0400,
1055                 .proc_handler   = arlan_sysctl_info,
1056         },
1057 #endif
1058         {
1059                 .procname       = "config2",
1060                 .data           = &conf_reset_result,
1061                 .maxlen         = 100,
1062                 .mode           = 0400,
1063                 .proc_handler   = arlan_configure,
1064         },
1065         {
1066                 .procname       = "reset2",
1067                 .data           = &conf_reset_result,
1068                 .maxlen         = 100,
1069                 .mode           = 0400,
1070                 .proc_handler   = arlan_sysctl_reset,
1071         },
1072         { }
1073 };
1074
1075 static ctl_table arlan_conf_table3[] =
1076 {
1077
1078         ARLAN_SYSCTL_TABLE_TOTAL(3)
1079
1080 #ifdef ARLAN_PROC_SHM_DUMP
1081         {
1082                 .procname       = "arlan3-txRing",
1083                 .data           = &arlan_drive_info,
1084                 .maxlen         = ARLAN_STR_SIZE,
1085                 .mode           = 0400,
1086                 .proc_handler   = arlan_sysctl_infotxRing,
1087         },
1088         {
1089                 .procname       = "arlan3-rxRing",
1090                 .data           = &arlan_drive_info,
1091                 .maxlen         = ARLAN_STR_SIZE,
1092                 .mode           = 0400,
1093                 .proc_handler   = arlan_sysctl_inforxRing,
1094         },
1095         {
1096                 .procname       = "arlan3-18",
1097                 .data           = &arlan_drive_info,
1098                 .maxlen         = ARLAN_STR_SIZE,
1099                 .mode           = 0400,
1100                 .proc_handler   = arlan_sysctl_info18,
1101         },
1102         {
1103                 .procname       = "arlan3-ring",
1104                 .data           = &arlan_drive_info,
1105                 .maxlen         = ARLAN_STR_SIZE,
1106                 .mode           = 0400,
1107                 .proc_handler   = arlan_sysctl_info161719,
1108         },
1109         {
1110                 .procname       = "arlan3-shm-cpy",
1111                 .data           = &arlan_drive_info,
1112                 .maxlen         = ARLAN_STR_SIZE,
1113                 .mode           = 0400,
1114                 .proc_handler   = arlan_sysctl_info,
1115         },
1116 #endif
1117         {
1118                 .procname       = "config3",
1119                 .data           = &conf_reset_result,
1120                 .maxlen         = 100,
1121                 .mode           = 0400,
1122                 .proc_handler   = arlan_configure,
1123         },
1124         {
1125                 .procname       = "reset3",
1126                 .data           = &conf_reset_result,
1127                 .maxlen         = 100,
1128                 .mode           = 0400,
1129                 .proc_handler   = arlan_sysctl_reset,
1130         },
1131         { }
1132 };
1133
1134
1135
1136 static ctl_table arlan_table[] =
1137 {
1138         {
1139                 .procname       = "arlan0",
1140                 .maxlen         = 0,
1141                 .mode           = 0600,
1142                 .child          = arlan_conf_table0,
1143         },
1144         {
1145                 .procname       = "arlan1",
1146                 .maxlen         = 0,
1147                 .mode           = 0600,
1148                 .child          = arlan_conf_table1,
1149         },
1150         {
1151                 .procname       = "arlan2",
1152                 .maxlen         = 0,
1153                 .mode           = 0600,
1154                 .child          = arlan_conf_table2,
1155         },
1156         {
1157                 .procname       = "arlan3",
1158                 .maxlen         = 0,
1159                 .mode           = 0600,
1160                 .child          = arlan_conf_table3,
1161         },
1162         { }
1163 };
1164
1165 #else
1166
1167 static ctl_table arlan_table[] =
1168 {
1169         { }
1170 };
1171 #endif
1172
1173
1174 // static int mmtu = 1234;
1175
1176 static ctl_table arlan_root_table[] =
1177 {
1178         {
1179                 .procname       = "arlan",
1180                 .maxlen         = 0,
1181                 .mode           = 0555,
1182                 .child          = arlan_table,
1183         },
1184         {  }
1185 };
1186
1187
1188 static struct ctl_table_header *arlan_device_sysctl_header;
1189
1190 int __init init_arlan_proc(void)
1191 {
1192
1193         int i = 0;
1194         if (arlan_device_sysctl_header)
1195                 return 0;
1196         arlan_device_sysctl_header = register_sysctl_table(arlan_root_table);
1197         if (!arlan_device_sysctl_header)
1198                 return -1;
1199
1200         return 0;
1201
1202 }
1203
1204 void __exit cleanup_arlan_proc(void)
1205 {
1206         unregister_sysctl_table(arlan_device_sysctl_header);
1207         arlan_device_sysctl_header = NULL;
1208
1209 }
1210 #endif