arlan-proc.c 28 KB

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