skproc.c 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /******************************************************************************
  2. *
  3. * Name: skproc.c
  4. * Project: GEnesis, PCI Gigabit Ethernet Adapter
  5. * Version: $Revision: 1.11 $
  6. * Date: $Date: 2003/12/11 16:03:57 $
  7. * Purpose: Funktions to display statictic data
  8. *
  9. ******************************************************************************/
  10. /******************************************************************************
  11. *
  12. * (C)Copyright 1998-2002 SysKonnect GmbH.
  13. * (C)Copyright 2002-2003 Marvell.
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * Created 22-Nov-2000
  21. * Author: Mirko Lindner (mlindner@syskonnect.de)
  22. *
  23. * The information in this file is provided "AS IS" without warranty.
  24. *
  25. ******************************************************************************/
  26. #include <linux/proc_fs.h>
  27. #include <linux/seq_file.h>
  28. #include "h/skdrv1st.h"
  29. #include "h/skdrv2nd.h"
  30. #include "h/skversion.h"
  31. static int sk_seq_show(struct seq_file *seq, void *v);
  32. static int sk_proc_open(struct inode *inode, struct file *file);
  33. struct file_operations sk_proc_fops = {
  34. .owner = THIS_MODULE,
  35. .open = sk_proc_open,
  36. .read = seq_read,
  37. .llseek = seq_lseek,
  38. .release = single_release,
  39. };
  40. /*****************************************************************************
  41. *
  42. * sk_seq_show - show proc information of a particular adapter
  43. *
  44. * Description:
  45. * This function fills the proc entry with statistic data about
  46. * the ethernet device. It invokes the generic sk_gen_browse() to
  47. * print out all items one per one.
  48. *
  49. * Returns: 0
  50. *
  51. */
  52. static int sk_seq_show(struct seq_file *seq, void *v)
  53. {
  54. struct net_device *dev = seq->private;
  55. DEV_NET *pNet = netdev_priv(dev);
  56. SK_AC *pAC = pNet->pAC;
  57. SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;
  58. unsigned long Flags;
  59. unsigned int Size;
  60. char sens_msg[50];
  61. int t;
  62. int i;
  63. /* NetIndex in GetStruct is now required, zero is only dummy */
  64. for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
  65. if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
  66. t--;
  67. spin_lock_irqsave(&pAC->SlowPathLock, Flags);
  68. Size = SK_PNMI_STRUCT_SIZE;
  69. #ifdef SK_DIAG_SUPPORT
  70. if (pAC->BoardLevel == SK_INIT_DATA) {
  71. SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
  72. if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
  73. pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
  74. }
  75. } else {
  76. SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
  77. }
  78. #else
  79. SkPnmiGetStruct(pAC, pAC->IoBase,
  80. pPnmiStruct, &Size, t-1);
  81. #endif
  82. spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
  83. if (pAC->dev[t-1] == dev) {
  84. SK_PNMI_STAT *pPnmiStat = &pPnmiStruct->Stat[0];
  85. seq_printf(seq, "\nDetailed statistic for device %s\n",
  86. pAC->dev[t-1]->name);
  87. seq_printf(seq, "=======================================\n");
  88. /* Board statistics */
  89. seq_printf(seq, "\nBoard statistics\n\n");
  90. seq_printf(seq, "Active Port %c\n",
  91. 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
  92. Net[t-1].PrefPort]->PortNumber);
  93. seq_printf(seq, "Preferred Port %c\n",
  94. 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
  95. Net[t-1].PrefPort]->PortNumber);
  96. seq_printf(seq, "Bus speed (MHz) %d\n",
  97. pPnmiStruct->BusSpeed);
  98. seq_printf(seq, "Bus width (Bit) %d\n",
  99. pPnmiStruct->BusWidth);
  100. seq_printf(seq, "Driver version %s\n",
  101. VER_STRING);
  102. seq_printf(seq, "Hardware revision v%d.%d\n",
  103. (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
  104. pAC->GIni.GIPciHwRev & 0x0F);
  105. /* Print sensor informations */
  106. for (i=0; i < pAC->I2c.MaxSens; i ++) {
  107. /* Check type */
  108. switch (pAC->I2c.SenTable[i].SenType) {
  109. case 1:
  110. strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
  111. strcat(sens_msg, " (C)");
  112. seq_printf(seq, "%-25s %d.%02d\n",
  113. sens_msg,
  114. pAC->I2c.SenTable[i].SenValue / 10,
  115. pAC->I2c.SenTable[i].SenValue % 10);
  116. strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
  117. strcat(sens_msg, " (F)");
  118. seq_printf(seq, "%-25s %d.%02d\n",
  119. sens_msg,
  120. ((((pAC->I2c.SenTable[i].SenValue)
  121. *10)*9)/5 + 3200)/100,
  122. ((((pAC->I2c.SenTable[i].SenValue)
  123. *10)*9)/5 + 3200) % 10);
  124. break;
  125. case 2:
  126. strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
  127. strcat(sens_msg, " (V)");
  128. seq_printf(seq, "%-25s %d.%03d\n",
  129. sens_msg,
  130. pAC->I2c.SenTable[i].SenValue / 1000,
  131. pAC->I2c.SenTable[i].SenValue % 1000);
  132. break;
  133. case 3:
  134. strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
  135. strcat(sens_msg, " (rpm)");
  136. seq_printf(seq, "%-25s %d\n",
  137. sens_msg,
  138. pAC->I2c.SenTable[i].SenValue);
  139. break;
  140. default:
  141. break;
  142. }
  143. }
  144. /*Receive statistics */
  145. seq_printf(seq, "\nReceive statistics\n\n");
  146. seq_printf(seq, "Received bytes %Lu\n",
  147. (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
  148. seq_printf(seq, "Received packets %Lu\n",
  149. (unsigned long long) pPnmiStat->StatRxOkCts);
  150. #if 0
  151. if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC &&
  152. pAC->HWRevision < 12) {
  153. pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
  154. pPnmiStat->StatRxShortsCts;
  155. pPnmiStat->StatRxShortsCts = 0;
  156. }
  157. #endif
  158. if (dev->mtu > 1500)
  159. pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
  160. pPnmiStat->StatRxTooLongCts;
  161. seq_printf(seq, "Receive errors %Lu\n",
  162. (unsigned long long) pPnmiStruct->InErrorsCts);
  163. seq_printf(seq, "Receive dropped %Lu\n",
  164. (unsigned long long) pPnmiStruct->RxNoBufCts);
  165. seq_printf(seq, "Received multicast %Lu\n",
  166. (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
  167. seq_printf(seq, "Receive error types\n");
  168. seq_printf(seq, " length %Lu\n",
  169. (unsigned long long) pPnmiStat->StatRxRuntCts);
  170. seq_printf(seq, " buffer overflow %Lu\n",
  171. (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
  172. seq_printf(seq, " bad crc %Lu\n",
  173. (unsigned long long) pPnmiStat->StatRxFcsCts);
  174. seq_printf(seq, " framing %Lu\n",
  175. (unsigned long long) pPnmiStat->StatRxFramingCts);
  176. seq_printf(seq, " missed frames %Lu\n",
  177. (unsigned long long) pPnmiStat->StatRxMissedCts);
  178. if (dev->mtu > 1500)
  179. pPnmiStat->StatRxTooLongCts = 0;
  180. seq_printf(seq, " too long %Lu\n",
  181. (unsigned long long) pPnmiStat->StatRxTooLongCts);
  182. seq_printf(seq, " carrier extension %Lu\n",
  183. (unsigned long long) pPnmiStat->StatRxCextCts);
  184. seq_printf(seq, " too short %Lu\n",
  185. (unsigned long long) pPnmiStat->StatRxShortsCts);
  186. seq_printf(seq, " symbol %Lu\n",
  187. (unsigned long long) pPnmiStat->StatRxSymbolCts);
  188. seq_printf(seq, " LLC MAC size %Lu\n",
  189. (unsigned long long) pPnmiStat->StatRxIRLengthCts);
  190. seq_printf(seq, " carrier event %Lu\n",
  191. (unsigned long long) pPnmiStat->StatRxCarrierCts);
  192. seq_printf(seq, " jabber %Lu\n",
  193. (unsigned long long) pPnmiStat->StatRxJabberCts);
  194. /*Transmit statistics */
  195. seq_printf(seq, "\nTransmit statistics\n\n");
  196. seq_printf(seq, "Transmited bytes %Lu\n",
  197. (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
  198. seq_printf(seq, "Transmited packets %Lu\n",
  199. (unsigned long long) pPnmiStat->StatTxOkCts);
  200. seq_printf(seq, "Transmit errors %Lu\n",
  201. (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
  202. seq_printf(seq, "Transmit dropped %Lu\n",
  203. (unsigned long long) pPnmiStruct->TxNoBufCts);
  204. seq_printf(seq, "Transmit collisions %Lu\n",
  205. (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
  206. seq_printf(seq, "Transmit error types\n");
  207. seq_printf(seq, " excessive collision %ld\n",
  208. pAC->stats.tx_aborted_errors);
  209. seq_printf(seq, " carrier %Lu\n",
  210. (unsigned long long) pPnmiStat->StatTxCarrierCts);
  211. seq_printf(seq, " fifo underrun %Lu\n",
  212. (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
  213. seq_printf(seq, " heartbeat %Lu\n",
  214. (unsigned long long) pPnmiStat->StatTxCarrierCts);
  215. seq_printf(seq, " window %ld\n",
  216. pAC->stats.tx_window_errors);
  217. }
  218. }
  219. return 0;
  220. }
  221. /*****************************************************************************
  222. *
  223. * sk_proc_open - register the show function when proc is open'ed
  224. *
  225. * Description:
  226. * This function is called whenever a sk98lin proc file is queried.
  227. *
  228. * Returns: the return value of single_open()
  229. *
  230. */
  231. static int sk_proc_open(struct inode *inode, struct file *file)
  232. {
  233. return single_open(file, sk_seq_show, PDE(inode)->data);
  234. }
  235. /*******************************************************************************
  236. *
  237. * End of file
  238. *
  239. ******************************************************************************/