qeth_proc.c 8.5 KB

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