qeth_proc.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /*
  2. *
  3. * linux/drivers/s390/net/qeth_fs.c
  4. *
  5. * Linux on zSeries OSA Express and HiperSockets support
  6. * This file contains code related to procfs.
  7. *
  8. * Copyright 2000,2003 IBM Corporation
  9. *
  10. * Author(s): Thomas Spatzier <tspat@de.ibm.com>
  11. *
  12. */
  13. #include <linux/module.h>
  14. #include <linux/init.h>
  15. #include <linux/proc_fs.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/list.h>
  18. #include <linux/rwsem.h>
  19. #include "qeth.h"
  20. #include "qeth_mpc.h"
  21. #include "qeth_fs.h"
  22. /***** /proc/qeth *****/
  23. #define QETH_PROCFILE_NAME "qeth"
  24. static struct proc_dir_entry *qeth_procfile;
  25. static int
  26. qeth_procfile_seq_match(struct device *dev, void *data)
  27. {
  28. return(dev ? 1 : 0);
  29. }
  30. static void *
  31. qeth_procfile_seq_start(struct seq_file *s, loff_t *offset)
  32. {
  33. struct device *dev = NULL;
  34. loff_t nr = 0;
  35. down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
  36. if (*offset == 0)
  37. return SEQ_START_TOKEN;
  38. while (1) {
  39. dev = driver_find_device(&qeth_ccwgroup_driver.driver, dev,
  40. NULL, qeth_procfile_seq_match);
  41. if (++nr == *offset)
  42. break;
  43. put_device(dev);
  44. }
  45. return dev;
  46. }
  47. static void
  48. qeth_procfile_seq_stop(struct seq_file *s, void* it)
  49. {
  50. up_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
  51. }
  52. static void *
  53. qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset)
  54. {
  55. struct device *prev, *next;
  56. if (it == SEQ_START_TOKEN)
  57. prev = NULL;
  58. else
  59. prev = (struct device *) it;
  60. next = driver_find_device(&qeth_ccwgroup_driver.driver,
  61. prev, NULL, qeth_procfile_seq_match);
  62. (*offset)++;
  63. return (void *) next;
  64. }
  65. static inline const char *
  66. qeth_get_router_str(struct qeth_card *card, int ipv)
  67. {
  68. enum qeth_routing_types routing_type = NO_ROUTER;
  69. if (ipv == 4) {
  70. routing_type = card->options.route4.type;
  71. } else {
  72. #ifdef CONFIG_QETH_IPV6
  73. routing_type = card->options.route6.type;
  74. #else
  75. return "n/a";
  76. #endif /* CONFIG_QETH_IPV6 */
  77. }
  78. switch (routing_type){
  79. case PRIMARY_ROUTER:
  80. return "pri";
  81. case SECONDARY_ROUTER:
  82. return "sec";
  83. case MULTICAST_ROUTER:
  84. if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
  85. return "mc+";
  86. return "mc";
  87. case PRIMARY_CONNECTOR:
  88. if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
  89. return "p+c";
  90. return "p.c";
  91. case SECONDARY_CONNECTOR:
  92. if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
  93. return "s+c";
  94. return "s.c";
  95. default: /* NO_ROUTER */
  96. return "no";
  97. }
  98. }
  99. static int
  100. qeth_procfile_seq_show(struct seq_file *s, void *it)
  101. {
  102. struct device *device;
  103. struct qeth_card *card;
  104. char tmp[12]; /* for qeth_get_prioq_str */
  105. if (it == SEQ_START_TOKEN){
  106. seq_printf(s, "devices CHPID interface "
  107. "cardtype port chksum prio-q'ing rtr4 "
  108. "rtr6 fsz cnt\n");
  109. seq_printf(s, "-------------------------- ----- ---------- "
  110. "-------------- ---- ------ ---------- ---- "
  111. "---- ----- -----\n");
  112. } else {
  113. device = (struct device *) it;
  114. card = device->driver_data;
  115. seq_printf(s, "%s/%s/%s x%02X %-10s %-14s %-4i ",
  116. CARD_RDEV_ID(card),
  117. CARD_WDEV_ID(card),
  118. CARD_DDEV_ID(card),
  119. card->info.chpid,
  120. QETH_CARD_IFNAME(card),
  121. qeth_get_cardname_short(card),
  122. card->info.portno);
  123. if (card->lan_online)
  124. seq_printf(s, "%-6s %-10s %-4s %-4s %-5s %-5i\n",
  125. qeth_get_checksum_str(card),
  126. qeth_get_prioq_str(card, tmp),
  127. qeth_get_router_str(card, 4),
  128. qeth_get_router_str(card, 6),
  129. qeth_get_bufsize_str(card),
  130. card->qdio.in_buf_pool.buf_count);
  131. else
  132. seq_printf(s, " +++ LAN OFFLINE +++\n");
  133. put_device(device);
  134. }
  135. return 0;
  136. }
  137. static struct seq_operations qeth_procfile_seq_ops = {
  138. .start = qeth_procfile_seq_start,
  139. .stop = qeth_procfile_seq_stop,
  140. .next = qeth_procfile_seq_next,
  141. .show = qeth_procfile_seq_show,
  142. };
  143. static int
  144. qeth_procfile_open(struct inode *inode, struct file *file)
  145. {
  146. return seq_open(file, &qeth_procfile_seq_ops);
  147. }
  148. static struct file_operations qeth_procfile_fops = {
  149. .owner = THIS_MODULE,
  150. .open = qeth_procfile_open,
  151. .read = seq_read,
  152. .llseek = seq_lseek,
  153. .release = seq_release,
  154. };
  155. /***** /proc/qeth_perf *****/
  156. #define QETH_PERF_PROCFILE_NAME "qeth_perf"
  157. static struct proc_dir_entry *qeth_perf_procfile;
  158. static int
  159. qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
  160. {
  161. struct device *device;
  162. struct qeth_card *card;
  163. if (it == SEQ_START_TOKEN)
  164. return 0;
  165. device = (struct device *) it;
  166. card = device->driver_data;
  167. seq_printf(s, "For card with devnos %s/%s/%s (%s):\n",
  168. CARD_RDEV_ID(card),
  169. CARD_WDEV_ID(card),
  170. CARD_DDEV_ID(card),
  171. QETH_CARD_IFNAME(card)
  172. );
  173. if (!card->options.performance_stats)
  174. seq_printf(s, "Performance statistics are deactivated.\n");
  175. seq_printf(s, " Skb's/buffers received : %lu/%u\n"
  176. " Skb's/buffers sent : %lu/%u\n\n",
  177. card->stats.rx_packets -
  178. card->perf_stats.initial_rx_packets,
  179. card->perf_stats.bufs_rec,
  180. card->stats.tx_packets -
  181. card->perf_stats.initial_tx_packets,
  182. card->perf_stats.bufs_sent
  183. );
  184. seq_printf(s, " Skb's/buffers sent without packing : %lu/%u\n"
  185. " Skb's/buffers sent with packing : %u/%u\n\n",
  186. card->stats.tx_packets - card->perf_stats.initial_tx_packets
  187. - card->perf_stats.skbs_sent_pack,
  188. card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack,
  189. card->perf_stats.skbs_sent_pack,
  190. card->perf_stats.bufs_sent_pack
  191. );
  192. seq_printf(s, " Skbs sent in SG mode : %u\n"
  193. " Skb fragments sent in SG mode : %u\n\n",
  194. card->perf_stats.sg_skbs_sent,
  195. card->perf_stats.sg_frags_sent);
  196. seq_printf(s, " large_send tx (in Kbytes) : %u\n"
  197. " large_send count : %u\n\n",
  198. card->perf_stats.large_send_bytes >> 10,
  199. card->perf_stats.large_send_cnt);
  200. seq_printf(s, " Packing state changes no pkg.->packing : %u/%u\n"
  201. " Watermarks L/H : %i/%i\n"
  202. " Current buffer usage (outbound q's) : "
  203. "%i/%i/%i/%i\n\n",
  204. card->perf_stats.sc_dp_p, card->perf_stats.sc_p_dp,
  205. QETH_LOW_WATERMARK_PACK, QETH_HIGH_WATERMARK_PACK,
  206. atomic_read(&card->qdio.out_qs[0]->used_buffers),
  207. (card->qdio.no_out_queues > 1)?
  208. atomic_read(&card->qdio.out_qs[1]->used_buffers)
  209. : 0,
  210. (card->qdio.no_out_queues > 2)?
  211. atomic_read(&card->qdio.out_qs[2]->used_buffers)
  212. : 0,
  213. (card->qdio.no_out_queues > 3)?
  214. atomic_read(&card->qdio.out_qs[3]->used_buffers)
  215. : 0
  216. );
  217. seq_printf(s, " Inbound handler time (in us) : %u\n"
  218. " Inbound handler count : %u\n"
  219. " Inbound do_QDIO time (in us) : %u\n"
  220. " Inbound do_QDIO count : %u\n\n"
  221. " Outbound handler time (in us) : %u\n"
  222. " Outbound handler count : %u\n\n"
  223. " Outbound time (in us, incl QDIO) : %u\n"
  224. " Outbound count : %u\n"
  225. " Outbound do_QDIO time (in us) : %u\n"
  226. " Outbound do_QDIO count : %u\n\n",
  227. card->perf_stats.inbound_time,
  228. card->perf_stats.inbound_cnt,
  229. card->perf_stats.inbound_do_qdio_time,
  230. card->perf_stats.inbound_do_qdio_cnt,
  231. card->perf_stats.outbound_handler_time,
  232. card->perf_stats.outbound_handler_cnt,
  233. card->perf_stats.outbound_time,
  234. card->perf_stats.outbound_cnt,
  235. card->perf_stats.outbound_do_qdio_time,
  236. card->perf_stats.outbound_do_qdio_cnt
  237. );
  238. put_device(device);
  239. return 0;
  240. }
  241. static struct seq_operations qeth_perf_procfile_seq_ops = {
  242. .start = qeth_procfile_seq_start,
  243. .stop = qeth_procfile_seq_stop,
  244. .next = qeth_procfile_seq_next,
  245. .show = qeth_perf_procfile_seq_show,
  246. };
  247. static int
  248. qeth_perf_procfile_open(struct inode *inode, struct file *file)
  249. {
  250. return seq_open(file, &qeth_perf_procfile_seq_ops);
  251. }
  252. static struct file_operations qeth_perf_procfile_fops = {
  253. .owner = THIS_MODULE,
  254. .open = qeth_perf_procfile_open,
  255. .read = seq_read,
  256. .llseek = seq_lseek,
  257. .release = seq_release,
  258. };
  259. int __init
  260. qeth_create_procfs_entries(void)
  261. {
  262. qeth_procfile = create_proc_entry(QETH_PROCFILE_NAME,
  263. S_IFREG | 0444, NULL);
  264. if (qeth_procfile)
  265. qeth_procfile->proc_fops = &qeth_procfile_fops;
  266. qeth_perf_procfile = create_proc_entry(QETH_PERF_PROCFILE_NAME,
  267. S_IFREG | 0444, NULL);
  268. if (qeth_perf_procfile)
  269. qeth_perf_procfile->proc_fops = &qeth_perf_procfile_fops;
  270. if (qeth_procfile &&
  271. qeth_perf_procfile)
  272. return 0;
  273. else
  274. return -ENOMEM;
  275. }
  276. void __exit
  277. qeth_remove_procfs_entries(void)
  278. {
  279. if (qeth_procfile)
  280. remove_proc_entry(QETH_PROCFILE_NAME, NULL);
  281. if (qeth_perf_procfile)
  282. remove_proc_entry(QETH_PERF_PROCFILE_NAME, NULL);
  283. }