irsysctl.c 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*********************************************************************
  2. *
  3. * Filename: irsysctl.c
  4. * Version: 1.0
  5. * Description: Sysctl interface for IrDA
  6. * Status: Experimental.
  7. * Author: Dag Brattli <dagb@cs.uit.no>
  8. * Created at: Sun May 24 22:12:06 1998
  9. * Modified at: Fri Jun 4 02:50:15 1999
  10. * Modified by: Dag Brattli <dagb@cs.uit.no>
  11. *
  12. * Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved.
  13. * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * Neither Dag Brattli nor University of Tromsø admit liability nor
  21. * provide warranty for any of this software. This material is
  22. * provided "AS-IS" and at no charge.
  23. *
  24. ********************************************************************/
  25. #include <linux/mm.h>
  26. #include <linux/ctype.h>
  27. #include <linux/sysctl.h>
  28. #include <linux/init.h>
  29. #include <net/irda/irda.h> /* irda_debug */
  30. #include <net/irda/irias_object.h>
  31. extern int sysctl_discovery;
  32. extern int sysctl_discovery_slots;
  33. extern int sysctl_discovery_timeout;
  34. extern int sysctl_slot_timeout;
  35. extern int sysctl_fast_poll_increase;
  36. extern char sysctl_devname[];
  37. extern int sysctl_max_baud_rate;
  38. extern int sysctl_min_tx_turn_time;
  39. extern int sysctl_max_tx_data_size;
  40. extern int sysctl_max_tx_window;
  41. extern int sysctl_max_noreply_time;
  42. extern int sysctl_warn_noreply_time;
  43. extern int sysctl_lap_keepalive_time;
  44. /* this is needed for the proc_dointvec_minmax - Jean II */
  45. static int max_discovery_slots = 16; /* ??? */
  46. static int min_discovery_slots = 1;
  47. /* IrLAP 6.13.2 says 25ms to 10+70ms - allow higher since some devices
  48. * seems to require it. (from Dag's comment) */
  49. static int max_slot_timeout = 160;
  50. static int min_slot_timeout = 20;
  51. static int max_max_baud_rate = 16000000; /* See qos.c - IrLAP spec */
  52. static int min_max_baud_rate = 2400;
  53. static int max_min_tx_turn_time = 10000; /* See qos.c - IrLAP spec */
  54. static int min_min_tx_turn_time;
  55. static int max_max_tx_data_size = 2048; /* See qos.c - IrLAP spec */
  56. static int min_max_tx_data_size = 64;
  57. static int max_max_tx_window = 7; /* See qos.c - IrLAP spec */
  58. static int min_max_tx_window = 1;
  59. static int max_max_noreply_time = 40; /* See qos.c - IrLAP spec */
  60. static int min_max_noreply_time = 3;
  61. static int max_warn_noreply_time = 3; /* 3s == standard */
  62. static int min_warn_noreply_time = 1; /* 1s == min WD_TIMER */
  63. static int max_lap_keepalive_time = 10000; /* 10s */
  64. static int min_lap_keepalive_time = 100; /* 100us */
  65. /* For other sysctl, I've no idea of the range. Maybe Dag could help
  66. * us on that - Jean II */
  67. static int do_devname(ctl_table *table, int write, struct file *filp,
  68. void __user *buffer, size_t *lenp, loff_t *ppos)
  69. {
  70. int ret;
  71. ret = proc_dostring(table, write, filp, buffer, lenp, ppos);
  72. if (ret == 0 && write) {
  73. struct ias_value *val;
  74. val = irias_new_string_value(sysctl_devname);
  75. if (val)
  76. irias_object_change_attribute("Device", "DeviceName", val);
  77. }
  78. return ret;
  79. }
  80. /* One file */
  81. static ctl_table irda_table[] = {
  82. {
  83. .ctl_name = NET_IRDA_DISCOVERY,
  84. .procname = "discovery",
  85. .data = &sysctl_discovery,
  86. .maxlen = sizeof(int),
  87. .mode = 0644,
  88. .proc_handler = &proc_dointvec
  89. },
  90. {
  91. .ctl_name = NET_IRDA_DEVNAME,
  92. .procname = "devname",
  93. .data = sysctl_devname,
  94. .maxlen = 65,
  95. .mode = 0644,
  96. .proc_handler = &do_devname,
  97. .strategy = &sysctl_string
  98. },
  99. #ifdef CONFIG_IRDA_DEBUG
  100. {
  101. .ctl_name = NET_IRDA_DEBUG,
  102. .procname = "debug",
  103. .data = &irda_debug,
  104. .maxlen = sizeof(int),
  105. .mode = 0644,
  106. .proc_handler = &proc_dointvec
  107. },
  108. #endif
  109. #ifdef CONFIG_IRDA_FAST_RR
  110. {
  111. .ctl_name = NET_IRDA_FAST_POLL,
  112. .procname = "fast_poll_increase",
  113. .data = &sysctl_fast_poll_increase,
  114. .maxlen = sizeof(int),
  115. .mode = 0644,
  116. .proc_handler = &proc_dointvec
  117. },
  118. #endif
  119. {
  120. .ctl_name = NET_IRDA_DISCOVERY_SLOTS,
  121. .procname = "discovery_slots",
  122. .data = &sysctl_discovery_slots,
  123. .maxlen = sizeof(int),
  124. .mode = 0644,
  125. .proc_handler = &proc_dointvec_minmax,
  126. .strategy = &sysctl_intvec,
  127. .extra1 = &min_discovery_slots,
  128. .extra2 = &max_discovery_slots
  129. },
  130. {
  131. .ctl_name = NET_IRDA_DISCOVERY_TIMEOUT,
  132. .procname = "discovery_timeout",
  133. .data = &sysctl_discovery_timeout,
  134. .maxlen = sizeof(int),
  135. .mode = 0644,
  136. .proc_handler = &proc_dointvec
  137. },
  138. {
  139. .ctl_name = NET_IRDA_SLOT_TIMEOUT,
  140. .procname = "slot_timeout",
  141. .data = &sysctl_slot_timeout,
  142. .maxlen = sizeof(int),
  143. .mode = 0644,
  144. .proc_handler = &proc_dointvec_minmax,
  145. .strategy = &sysctl_intvec,
  146. .extra1 = &min_slot_timeout,
  147. .extra2 = &max_slot_timeout
  148. },
  149. {
  150. .ctl_name = NET_IRDA_MAX_BAUD_RATE,
  151. .procname = "max_baud_rate",
  152. .data = &sysctl_max_baud_rate,
  153. .maxlen = sizeof(int),
  154. .mode = 0644,
  155. .proc_handler = &proc_dointvec_minmax,
  156. .strategy = &sysctl_intvec,
  157. .extra1 = &min_max_baud_rate,
  158. .extra2 = &max_max_baud_rate
  159. },
  160. {
  161. .ctl_name = NET_IRDA_MIN_TX_TURN_TIME,
  162. .procname = "min_tx_turn_time",
  163. .data = &sysctl_min_tx_turn_time,
  164. .maxlen = sizeof(int),
  165. .mode = 0644,
  166. .proc_handler = &proc_dointvec_minmax,
  167. .strategy = &sysctl_intvec,
  168. .extra1 = &min_min_tx_turn_time,
  169. .extra2 = &max_min_tx_turn_time
  170. },
  171. {
  172. .ctl_name = NET_IRDA_MAX_TX_DATA_SIZE,
  173. .procname = "max_tx_data_size",
  174. .data = &sysctl_max_tx_data_size,
  175. .maxlen = sizeof(int),
  176. .mode = 0644,
  177. .proc_handler = &proc_dointvec_minmax,
  178. .strategy = &sysctl_intvec,
  179. .extra1 = &min_max_tx_data_size,
  180. .extra2 = &max_max_tx_data_size
  181. },
  182. {
  183. .ctl_name = NET_IRDA_MAX_TX_WINDOW,
  184. .procname = "max_tx_window",
  185. .data = &sysctl_max_tx_window,
  186. .maxlen = sizeof(int),
  187. .mode = 0644,
  188. .proc_handler = &proc_dointvec_minmax,
  189. .strategy = &sysctl_intvec,
  190. .extra1 = &min_max_tx_window,
  191. .extra2 = &max_max_tx_window
  192. },
  193. {
  194. .ctl_name = NET_IRDA_MAX_NOREPLY_TIME,
  195. .procname = "max_noreply_time",
  196. .data = &sysctl_max_noreply_time,
  197. .maxlen = sizeof(int),
  198. .mode = 0644,
  199. .proc_handler = &proc_dointvec_minmax,
  200. .strategy = &sysctl_intvec,
  201. .extra1 = &min_max_noreply_time,
  202. .extra2 = &max_max_noreply_time
  203. },
  204. {
  205. .ctl_name = NET_IRDA_WARN_NOREPLY_TIME,
  206. .procname = "warn_noreply_time",
  207. .data = &sysctl_warn_noreply_time,
  208. .maxlen = sizeof(int),
  209. .mode = 0644,
  210. .proc_handler = &proc_dointvec_minmax,
  211. .strategy = &sysctl_intvec,
  212. .extra1 = &min_warn_noreply_time,
  213. .extra2 = &max_warn_noreply_time
  214. },
  215. {
  216. .ctl_name = NET_IRDA_LAP_KEEPALIVE_TIME,
  217. .procname = "lap_keepalive_time",
  218. .data = &sysctl_lap_keepalive_time,
  219. .maxlen = sizeof(int),
  220. .mode = 0644,
  221. .proc_handler = &proc_dointvec_minmax,
  222. .strategy = &sysctl_intvec,
  223. .extra1 = &min_lap_keepalive_time,
  224. .extra2 = &max_lap_keepalive_time
  225. },
  226. { .ctl_name = 0 }
  227. };
  228. /* One directory */
  229. static ctl_table irda_net_table[] = {
  230. {
  231. .ctl_name = NET_IRDA,
  232. .procname = "irda",
  233. .maxlen = 0,
  234. .mode = 0555,
  235. .child = irda_table
  236. },
  237. { .ctl_name = 0 }
  238. };
  239. /* The parent directory */
  240. static ctl_table irda_root_table[] = {
  241. {
  242. .ctl_name = CTL_NET,
  243. .procname = "net",
  244. .maxlen = 0,
  245. .mode = 0555,
  246. .child = irda_net_table
  247. },
  248. { .ctl_name = 0 }
  249. };
  250. static struct ctl_table_header *irda_table_header;
  251. /*
  252. * Function irda_sysctl_register (void)
  253. *
  254. * Register our sysctl interface
  255. *
  256. */
  257. int __init irda_sysctl_register(void)
  258. {
  259. irda_table_header = register_sysctl_table(irda_root_table);
  260. if (!irda_table_header)
  261. return -ENOMEM;
  262. return 0;
  263. }
  264. /*
  265. * Function irda_sysctl_unregister (void)
  266. *
  267. * Unregister our sysctl interface
  268. *
  269. */
  270. void irda_sysctl_unregister(void)
  271. {
  272. unregister_sysctl_table(irda_table_header);
  273. }