blob: c6e70dbc5de824a9ab63286c82d76ed6480a40ff [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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
57static 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
113static 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
187static 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
253static 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
322static 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
403static char arlan_drive_info[ARLAN_STR_SIZE] = "A655\n\0";
404
405static int arlan_sysctl_info(ctl_table * ctl, int write, struct file *filp,
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
Yoann Padioleau6dbc9c82007-08-03 19:37:16 +0200438 priva = netdev_priv(arlan_device[devnum]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
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);
628final:
629 *lenp = pos;
630
631 if (!write)
632 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
633 else
634 {
635 *lenp = 0;
636 return -1;
637 }
638 return retv;
639}
640
641
642static int arlan_sysctl_info161719(ctl_table * ctl, int write, struct file *filp,
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
Yoann Padioleau6dbc9c82007-08-03 19:37:16 +0200657 priva = netdev_priv(arlan_device[devnum]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 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
670final:
671 *lenp = pos;
672 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
673 return retv;
674}
675
676static int arlan_sysctl_infotxRing(ctl_table * ctl, int write, struct file *filp,
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
Yoann Padioleau6dbc9c82007-08-03 19:37:16 +0200691 priva = netdev_priv(arlan_device[devnum]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 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);
699final:
700 *lenp = pos;
701 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
702 return retv;
703}
704
705static int arlan_sysctl_inforxRing(ctl_table * ctl, int write, struct file *filp,
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
Yoann Padioleau6dbc9c82007-08-03 19:37:16 +0200719 priva = netdev_priv(arlan_device[devnum]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 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);
727final:
728 *lenp = pos;
729 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
730 return retv;
731}
732
733static int arlan_sysctl_info18(ctl_table * ctl, int write, struct file *filp,
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
Yoann Padioleau6dbc9c82007-08-03 19:37:16 +0200748 priva = netdev_priv(arlan_device[devnum]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 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
757final:
758 *lenp = pos;
759 retv = proc_dostring(ctl, write, filp, buffer, lenp, ppos);
760 return retv;
761}
762
763
764#endif /* #ifdef ARLAN_PROC_SHM_DUMP */
765
766
767static char conf_reset_result[200];
768
769static int arlan_configure(ctl_table * ctl, int write, struct file *filp,
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 {
Yoann Padioleau6dbc9c82007-08-03 19:37:16 +0200783 priv = netdev_priv(arlan_device[devnum]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784
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, filp, buffer, lenp, ppos);
792}
793
794static int arlan_sysctl_reset(ctl_table * ctl, int write, struct file *filp,
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 {
Yoann Padioleau6dbc9c82007-08-03 19:37:16 +0200808 priv = netdev_priv(arlan_device[devnum]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 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, filp, buffer, lenp, ppos);
815}
816
817
818/* Place files in /proc/sys/dev/arlan */
819#define CTBLN(num,card,nam) \
820 { .ctl_name = num,\
821 .procname = #nam,\
822 .data = &(arlan_conf[card].nam),\
823 .maxlen = sizeof(int), .mode = 0600, .proc_handler = &proc_dointvec}
824#ifdef ARLAN_DEBUGGING
825
826#define ARLAN_PROC_DEBUG_ENTRIES \
827 { .ctl_name = 48, .procname = "entry_exit_debug",\
828 .data = &arlan_entry_and_exit_debug,\
829 .maxlen = sizeof(int), .mode = 0600, .proc_handler = &proc_dointvec},\
830 { .ctl_name = 49, .procname = "debug", .data = &arlan_debug,\
831 .maxlen = sizeof(int), .mode = 0600, .proc_handler = &proc_dointvec},
832#else
833#define ARLAN_PROC_DEBUG_ENTRIES
834#endif
835
836#define ARLAN_SYSCTL_TABLE_TOTAL(cardNo)\
837 CTBLN(1,cardNo,spreadingCode),\
838 CTBLN(2,cardNo, channelNumber),\
839 CTBLN(3,cardNo, scramblingDisable),\
840 CTBLN(4,cardNo, txAttenuation),\
841 CTBLN(5,cardNo, systemId), \
842 CTBLN(6,cardNo, maxDatagramSize),\
843 CTBLN(7,cardNo, maxFrameSize),\
844 CTBLN(8,cardNo, maxRetries),\
845 CTBLN(9,cardNo, receiveMode),\
846 CTBLN(10,cardNo, priority),\
847 CTBLN(11,cardNo, rootOrRepeater),\
848 CTBLN(12,cardNo, SID),\
849 CTBLN(13,cardNo, registrationMode),\
850 CTBLN(14,cardNo, registrationFill),\
851 CTBLN(15,cardNo, localTalkAddress),\
852 CTBLN(16,cardNo, codeFormat),\
853 CTBLN(17,cardNo, numChannels),\
854 CTBLN(18,cardNo, channel1),\
855 CTBLN(19,cardNo, channel2),\
856 CTBLN(20,cardNo, channel3),\
857 CTBLN(21,cardNo, channel4),\
858 CTBLN(22,cardNo, txClear),\
859 CTBLN(23,cardNo, txRetries),\
860 CTBLN(24,cardNo, txRouting),\
861 CTBLN(25,cardNo, txScrambled),\
862 CTBLN(26,cardNo, rxParameter),\
863 CTBLN(27,cardNo, txTimeoutMs),\
864 CTBLN(28,cardNo, waitCardTimeout),\
865 CTBLN(29,cardNo, channelSet), \
866 {.ctl_name = 30, .procname = "name",\
867 .data = arlan_conf[cardNo].siteName,\
868 .maxlen = 16, .mode = 0600, .proc_handler = &proc_dostring},\
869 CTBLN(31,cardNo,waitTime),\
870 CTBLN(32,cardNo,lParameter),\
871 CTBLN(33,cardNo,_15),\
872 CTBLN(34,cardNo,headerSize),\
873 CTBLN(36,cardNo,tx_delay_ms),\
874 CTBLN(37,cardNo,retries),\
875 CTBLN(38,cardNo,ReTransmitPacketMaxSize),\
876 CTBLN(39,cardNo,waitReTransmitPacketMaxSize),\
877 CTBLN(40,cardNo,fastReTransCount),\
878 CTBLN(41,cardNo,driverRetransmissions),\
879 CTBLN(42,cardNo,txAckTimeoutMs),\
880 CTBLN(43,cardNo,registrationInterrupts),\
881 CTBLN(44,cardNo,hardwareType),\
882 CTBLN(45,cardNo,radioType),\
883 CTBLN(46,cardNo,writeEEPROM),\
884 CTBLN(47,cardNo,writeRadioType),\
885 ARLAN_PROC_DEBUG_ENTRIES\
886 CTBLN(50,cardNo,in_speed),\
887 CTBLN(51,cardNo,out_speed),\
888 CTBLN(52,cardNo,in_speed10),\
889 CTBLN(53,cardNo,out_speed10),\
890 CTBLN(54,cardNo,in_speed_max),\
891 CTBLN(55,cardNo,out_speed_max),\
892 CTBLN(56,cardNo,measure_rate),\
893 CTBLN(57,cardNo,pre_Command_Wait),\
894 CTBLN(58,cardNo,rx_tweak1),\
895 CTBLN(59,cardNo,rx_tweak2),\
896 CTBLN(60,cardNo,tx_queue_len),\
897
898
899
900static ctl_table arlan_conf_table0[] =
901{
902 ARLAN_SYSCTL_TABLE_TOTAL(0)
903
904#ifdef ARLAN_PROC_SHM_DUMP
905 {
906 .ctl_name = 150,
907 .procname = "arlan0-txRing",
908 .data = &arlan_drive_info,
909 .maxlen = ARLAN_STR_SIZE,
910 .mode = 0400,
911 .proc_handler = &arlan_sysctl_infotxRing,
912 },
913 {
914 .ctl_name = 151,
915 .procname = "arlan0-rxRing",
916 .data = &arlan_drive_info,
917 .maxlen = ARLAN_STR_SIZE,
918 .mode = 0400,
919 .proc_handler = &arlan_sysctl_inforxRing,
920 },
921 {
922 .ctl_name = 152,
923 .procname = "arlan0-18",
924 .data = &arlan_drive_info,
925 .maxlen = ARLAN_STR_SIZE,
926 .mode = 0400,
927 .proc_handler = &arlan_sysctl_info18,
928 },
929 {
930 .ctl_name = 153,
931 .procname = "arlan0-ring",
932 .data = &arlan_drive_info,
933 .maxlen = ARLAN_STR_SIZE,
934 .mode = 0400,
935 .proc_handler = &arlan_sysctl_info161719,
936 },
937 {
938 .ctl_name = 154,
939 .procname = "arlan0-shm-cpy",
940 .data = &arlan_drive_info,
941 .maxlen = ARLAN_STR_SIZE,
942 .mode = 0400,
943 .proc_handler = &arlan_sysctl_info,
944 },
945#endif
946 {
947 .ctl_name = 155,
948 .procname = "config0",
949 .data = &conf_reset_result,
950 .maxlen = 100,
951 .mode = 0400,
952 .proc_handler = &arlan_configure
953 },
954 {
955 .ctl_name = 156,
956 .procname = "reset0",
957 .data = &conf_reset_result,
958 .maxlen = 100,
959 .mode = 0400,
960 .proc_handler = &arlan_sysctl_reset,
961 },
962 { .ctl_name = 0 }
963};
964
965static ctl_table arlan_conf_table1[] =
966{
967
968 ARLAN_SYSCTL_TABLE_TOTAL(1)
969
970#ifdef ARLAN_PROC_SHM_DUMP
971 {
972 .ctl_name = 150,
973 .procname = "arlan1-txRing",
974 .data = &arlan_drive_info,
975 .maxlen = ARLAN_STR_SIZE,
976 .mode = 0400,
977 .proc_handler = &arlan_sysctl_infotxRing,
978 },
979 {
980 .ctl_name = 151,
981 .procname = "arlan1-rxRing",
982 .data = &arlan_drive_info,
983 .maxlen = ARLAN_STR_SIZE,
984 .mode = 0400,
985 .proc_handler = &arlan_sysctl_inforxRing,
986 },
987 {
988 .ctl_name = 152,
989 .procname = "arlan1-18",
990 .data = &arlan_drive_info,
991 .maxlen = ARLAN_STR_SIZE,
992 .mode = 0400,
993 .proc_handler = &arlan_sysctl_info18,
994 },
995 {
996 .ctl_name = 153,
997 .procname = "arlan1-ring",
998 .data = &arlan_drive_info,
999 .maxlen = ARLAN_STR_SIZE,
1000 .mode = 0400,
1001 .proc_handler = &arlan_sysctl_info161719,
1002 },
1003 {
1004 .ctl_name = 154,
1005 .procname = "arlan1-shm-cpy",
1006 .data = &arlan_drive_info,
1007 .maxlen = ARLAN_STR_SIZE,
1008 .mode = 0400,
1009 .proc_handler = &arlan_sysctl_info,
1010 },
1011#endif
1012 {
1013 .ctl_name = 155,
1014 .procname = "config1",
1015 .data = &conf_reset_result,
1016 .maxlen = 100,
1017 .mode = 0400,
1018 .proc_handler = &arlan_configure,
1019 },
1020 {
1021 .ctl_name = 156,
1022 .procname = "reset1",
1023 .data = &conf_reset_result,
1024 .maxlen = 100,
1025 .mode = 0400,
1026 .proc_handler = &arlan_sysctl_reset,
1027 },
1028 { .ctl_name = 0 }
1029};
1030
1031static ctl_table arlan_conf_table2[] =
1032{
1033
1034 ARLAN_SYSCTL_TABLE_TOTAL(2)
1035
1036#ifdef ARLAN_PROC_SHM_DUMP
1037 {
1038 .ctl_name = 150,
1039 .procname = "arlan2-txRing",
1040 .data = &arlan_drive_info,
1041 .maxlen = ARLAN_STR_SIZE,
1042 .mode = 0400,
1043 .proc_handler = &arlan_sysctl_infotxRing,
1044 },
1045 {
1046 .ctl_name = 151,
1047 .procname = "arlan2-rxRing",
1048 .data = &arlan_drive_info,
1049 .maxlen = ARLAN_STR_SIZE,
1050 .mode = 0400,
1051 .proc_handler = &arlan_sysctl_inforxRing,
1052 },
1053 {
1054 .ctl_name = 152,
1055 .procname = "arlan2-18",
1056 .data = &arlan_drive_info,
1057 .maxlen = ARLAN_STR_SIZE,
1058 .mode = 0400,
1059 .proc_handler = &arlan_sysctl_info18,
1060 },
1061 {
1062 .ctl_name = 153,
1063 .procname = "arlan2-ring",
1064 .data = &arlan_drive_info,
1065 .maxlen = ARLAN_STR_SIZE,
1066 .mode = 0400,
1067 .proc_handler = &arlan_sysctl_info161719,
1068 },
1069 {
1070 .ctl_name = 154,
1071 .procname = "arlan2-shm-cpy",
1072 .data = &arlan_drive_info,
1073 .maxlen = ARLAN_STR_SIZE,
1074 .mode = 0400,
1075 .proc_handler = &arlan_sysctl_info,
1076 },
1077#endif
1078 {
1079 .ctl_name = 155,
1080 .procname = "config2",
1081 .data = &conf_reset_result,
1082 .maxlen = 100,
1083 .mode = 0400,
1084 .proc_handler = &arlan_configure,
1085 },
1086 {
1087 .ctl_name = 156,
1088 .procname = "reset2",
1089 .data = &conf_reset_result,
1090 .maxlen = 100,
1091 .mode = 0400,
1092 .proc_handler = &arlan_sysctl_reset,
1093 },
1094 { .ctl_name = 0 }
1095};
1096
1097static ctl_table arlan_conf_table3[] =
1098{
1099
1100 ARLAN_SYSCTL_TABLE_TOTAL(3)
1101
1102#ifdef ARLAN_PROC_SHM_DUMP
1103 {
1104 .ctl_name = 150,
1105 .procname = "arlan3-txRing",
1106 .data = &arlan_drive_info,
1107 .maxlen = ARLAN_STR_SIZE,
1108 .mode = 0400,
1109 .proc_handler = &arlan_sysctl_infotxRing,
1110 },
1111 {
1112 .ctl_name = 151,
1113 .procname = "arlan3-rxRing",
1114 .data = &arlan_drive_info,
1115 .maxlen = ARLAN_STR_SIZE,
1116 .mode = 0400,
1117 .proc_handler = &arlan_sysctl_inforxRing,
1118 },
1119 {
1120 .ctl_name = 152,
1121 .procname = "arlan3-18",
1122 .data = &arlan_drive_info,
1123 .maxlen = ARLAN_STR_SIZE,
1124 .mode = 0400,
1125 .proc_handler = &arlan_sysctl_info18,
1126 },
1127 {
1128 .ctl_name = 153,
1129 .procname = "arlan3-ring",
1130 .data = &arlan_drive_info,
1131 .maxlen = ARLAN_STR_SIZE,
1132 .mode = 0400,
1133 .proc_handler = &arlan_sysctl_info161719,
1134 },
1135 {
1136 .ctl_name = 154,
1137 .procname = "arlan3-shm-cpy",
1138 .data = &arlan_drive_info,
1139 .maxlen = ARLAN_STR_SIZE,
1140 .mode = 0400,
1141 .proc_handler = &arlan_sysctl_info,
1142 },
1143#endif
1144 {
1145 .ctl_name = 155,
1146 .procname = "config3",
1147 .data = &conf_reset_result,
1148 .maxlen = 100,
1149 .mode = 0400,
1150 .proc_handler = &arlan_configure,
1151 },
1152 {
1153 .ctl_name = 156,
1154 .procname = "reset3",
1155 .data = &conf_reset_result,
1156 .maxlen = 100,
1157 .mode = 0400,
1158 .proc_handler = &arlan_sysctl_reset,
1159 },
1160 { .ctl_name = 0 }
1161};
1162
1163
1164
1165static ctl_table arlan_table[] =
1166{
1167 {
1168 .ctl_name = 0,
1169 .procname = "arlan0",
1170 .maxlen = 0,
1171 .mode = 0600,
1172 .child = arlan_conf_table0,
1173 },
1174 {
1175 .ctl_name = 0,
1176 .procname = "arlan1",
1177 .maxlen = 0,
1178 .mode = 0600,
1179 .child = arlan_conf_table1,
1180 },
1181 {
1182 .ctl_name = 0,
1183 .procname = "arlan2",
1184 .maxlen = 0,
1185 .mode = 0600,
1186 .child = arlan_conf_table2,
1187 },
1188 {
1189 .ctl_name = 0,
1190 .procname = "arlan3",
1191 .maxlen = 0,
1192 .mode = 0600,
1193 .child = arlan_conf_table3,
1194 },
1195 { .ctl_name = 0 }
1196};
1197
1198#else
1199
1200static ctl_table arlan_table[MAX_ARLANS + 1] =
1201{
1202 { .ctl_name = 0 }
1203};
1204#endif
1205#else
1206
1207static ctl_table arlan_table[MAX_ARLANS + 1] =
1208{
1209 { .ctl_name = 0 }
1210};
1211#endif
1212
1213
1214// static int mmtu = 1234;
1215
1216static ctl_table arlan_root_table[] =
1217{
1218 {
Eric W. Biederman59fc5312007-02-14 00:33:53 -08001219 .ctl_name = CTL_ARLAN,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 .procname = "arlan",
1221 .maxlen = 0,
1222 .mode = 0555,
1223 .child = arlan_table,
1224 },
1225 { .ctl_name = 0 }
1226};
1227
1228/* Make sure that /proc/sys/dev is there */
1229//static ctl_table arlan_device_root_table[] =
1230//{
1231// {CTL_DEV, "dev", NULL, 0, 0555, arlan_root_table},
1232// {0}
1233//};
1234
1235
1236#ifdef CONFIG_PROC_FS
1237static struct ctl_table_header *arlan_device_sysctl_header;
1238
1239int __init init_arlan_proc(void)
1240{
1241
1242 int i = 0;
1243 if (arlan_device_sysctl_header)
1244 return 0;
1245 for (i = 0; i < MAX_ARLANS && arlan_device[i]; i++)
1246 arlan_table[i].ctl_name = i + 1;
Eric W. Biederman0b4d4142007-02-14 00:34:09 -08001247 arlan_device_sysctl_header = register_sysctl_table(arlan_root_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 if (!arlan_device_sysctl_header)
1249 return -1;
1250
1251 return 0;
1252
1253}
1254
1255void __exit cleanup_arlan_proc(void)
1256{
1257 unregister_sysctl_table(arlan_device_sysctl_header);
1258 arlan_device_sysctl_header = NULL;
1259
1260}
1261#endif