1 /*********************************************************************
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>
12 * Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
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.
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.
24 ********************************************************************/
27 #include <linux/ctype.h>
28 #include <linux/sysctl.h>
29 #include <linux/init.h>
31 #include <net/irda/irda.h> /* irda_debug */
32 #include <net/irda/irlmp.h>
33 #include <net/irda/timer.h>
34 #include <net/irda/irias_object.h>
36 extern int sysctl_discovery
;
37 extern int sysctl_discovery_slots
;
38 extern int sysctl_discovery_timeout
;
39 extern int sysctl_slot_timeout
;
40 extern int sysctl_fast_poll_increase
;
41 extern char sysctl_devname
[];
42 extern int sysctl_max_baud_rate
;
43 extern int sysctl_min_tx_turn_time
;
44 extern int sysctl_max_tx_data_size
;
45 extern int sysctl_max_tx_window
;
46 extern int sysctl_max_noreply_time
;
47 extern int sysctl_warn_noreply_time
;
48 extern int sysctl_lap_keepalive_time
;
50 extern struct irlmp_cb
*irlmp
;
52 /* this is needed for the proc_dointvec_minmax - Jean II */
53 static int max_discovery_slots
= 16; /* ??? */
54 static int min_discovery_slots
= 1;
55 /* IrLAP 6.13.2 says 25ms to 10+70ms - allow higher since some devices
56 * seems to require it. (from Dag's comment) */
57 static int max_slot_timeout
= 160;
58 static int min_slot_timeout
= 20;
59 static int max_max_baud_rate
= 16000000; /* See qos.c - IrLAP spec */
60 static int min_max_baud_rate
= 2400;
61 static int max_min_tx_turn_time
= 10000; /* See qos.c - IrLAP spec */
62 static int min_min_tx_turn_time
;
63 static int max_max_tx_data_size
= 2048; /* See qos.c - IrLAP spec */
64 static int min_max_tx_data_size
= 64;
65 static int max_max_tx_window
= 7; /* See qos.c - IrLAP spec */
66 static int min_max_tx_window
= 1;
67 static int max_max_noreply_time
= 40; /* See qos.c - IrLAP spec */
68 static int min_max_noreply_time
= 3;
69 static int max_warn_noreply_time
= 3; /* 3s == standard */
70 static int min_warn_noreply_time
= 1; /* 1s == min WD_TIMER */
71 static int max_lap_keepalive_time
= 10000; /* 10s */
72 static int min_lap_keepalive_time
= 100; /* 100us */
73 /* For other sysctl, I've no idea of the range. Maybe Dag could help
74 * us on that - Jean II */
76 static int do_devname(ctl_table
*table
, int write
, struct file
*filp
,
77 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
81 ret
= proc_dostring(table
, write
, filp
, buffer
, lenp
, ppos
);
82 if (ret
== 0 && write
) {
83 struct ias_value
*val
;
85 val
= irias_new_string_value(sysctl_devname
);
87 irias_object_change_attribute("Device", "DeviceName", val
);
93 static int do_discovery(ctl_table
*table
, int write
, struct file
*filp
,
94 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
98 ret
= proc_dointvec(table
, write
, filp
, buffer
, lenp
, ppos
);
105 if (sysctl_discovery
)
106 irlmp_start_discovery_timer(irlmp
, sysctl_discovery_timeout
*HZ
);
108 del_timer_sync(&irlmp
->discovery_timer
);
114 static ctl_table irda_table
[] = {
116 .ctl_name
= NET_IRDA_DISCOVERY
,
117 .procname
= "discovery",
118 .data
= &sysctl_discovery
,
119 .maxlen
= sizeof(int),
121 .proc_handler
= do_discovery
,
122 .strategy
= sysctl_intvec
125 .ctl_name
= NET_IRDA_DEVNAME
,
126 .procname
= "devname",
127 .data
= sysctl_devname
,
130 .proc_handler
= do_devname
,
131 .strategy
= sysctl_string
133 #ifdef CONFIG_IRDA_DEBUG
135 .ctl_name
= NET_IRDA_DEBUG
,
138 .maxlen
= sizeof(int),
140 .proc_handler
= proc_dointvec
143 #ifdef CONFIG_IRDA_FAST_RR
145 .ctl_name
= NET_IRDA_FAST_POLL
,
146 .procname
= "fast_poll_increase",
147 .data
= &sysctl_fast_poll_increase
,
148 .maxlen
= sizeof(int),
150 .proc_handler
= proc_dointvec
154 .ctl_name
= NET_IRDA_DISCOVERY_SLOTS
,
155 .procname
= "discovery_slots",
156 .data
= &sysctl_discovery_slots
,
157 .maxlen
= sizeof(int),
159 .proc_handler
= proc_dointvec_minmax
,
160 .strategy
= sysctl_intvec
,
161 .extra1
= &min_discovery_slots
,
162 .extra2
= &max_discovery_slots
165 .ctl_name
= NET_IRDA_DISCOVERY_TIMEOUT
,
166 .procname
= "discovery_timeout",
167 .data
= &sysctl_discovery_timeout
,
168 .maxlen
= sizeof(int),
170 .proc_handler
= proc_dointvec
173 .ctl_name
= NET_IRDA_SLOT_TIMEOUT
,
174 .procname
= "slot_timeout",
175 .data
= &sysctl_slot_timeout
,
176 .maxlen
= sizeof(int),
178 .proc_handler
= proc_dointvec_minmax
,
179 .strategy
= sysctl_intvec
,
180 .extra1
= &min_slot_timeout
,
181 .extra2
= &max_slot_timeout
184 .ctl_name
= NET_IRDA_MAX_BAUD_RATE
,
185 .procname
= "max_baud_rate",
186 .data
= &sysctl_max_baud_rate
,
187 .maxlen
= sizeof(int),
189 .proc_handler
= proc_dointvec_minmax
,
190 .strategy
= sysctl_intvec
,
191 .extra1
= &min_max_baud_rate
,
192 .extra2
= &max_max_baud_rate
195 .ctl_name
= NET_IRDA_MIN_TX_TURN_TIME
,
196 .procname
= "min_tx_turn_time",
197 .data
= &sysctl_min_tx_turn_time
,
198 .maxlen
= sizeof(int),
200 .proc_handler
= proc_dointvec_minmax
,
201 .strategy
= sysctl_intvec
,
202 .extra1
= &min_min_tx_turn_time
,
203 .extra2
= &max_min_tx_turn_time
206 .ctl_name
= NET_IRDA_MAX_TX_DATA_SIZE
,
207 .procname
= "max_tx_data_size",
208 .data
= &sysctl_max_tx_data_size
,
209 .maxlen
= sizeof(int),
211 .proc_handler
= proc_dointvec_minmax
,
212 .strategy
= sysctl_intvec
,
213 .extra1
= &min_max_tx_data_size
,
214 .extra2
= &max_max_tx_data_size
217 .ctl_name
= NET_IRDA_MAX_TX_WINDOW
,
218 .procname
= "max_tx_window",
219 .data
= &sysctl_max_tx_window
,
220 .maxlen
= sizeof(int),
222 .proc_handler
= proc_dointvec_minmax
,
223 .strategy
= sysctl_intvec
,
224 .extra1
= &min_max_tx_window
,
225 .extra2
= &max_max_tx_window
228 .ctl_name
= NET_IRDA_MAX_NOREPLY_TIME
,
229 .procname
= "max_noreply_time",
230 .data
= &sysctl_max_noreply_time
,
231 .maxlen
= sizeof(int),
233 .proc_handler
= proc_dointvec_minmax
,
234 .strategy
= sysctl_intvec
,
235 .extra1
= &min_max_noreply_time
,
236 .extra2
= &max_max_noreply_time
239 .ctl_name
= NET_IRDA_WARN_NOREPLY_TIME
,
240 .procname
= "warn_noreply_time",
241 .data
= &sysctl_warn_noreply_time
,
242 .maxlen
= sizeof(int),
244 .proc_handler
= proc_dointvec_minmax
,
245 .strategy
= sysctl_intvec
,
246 .extra1
= &min_warn_noreply_time
,
247 .extra2
= &max_warn_noreply_time
250 .ctl_name
= NET_IRDA_LAP_KEEPALIVE_TIME
,
251 .procname
= "lap_keepalive_time",
252 .data
= &sysctl_lap_keepalive_time
,
253 .maxlen
= sizeof(int),
255 .proc_handler
= proc_dointvec_minmax
,
256 .strategy
= sysctl_intvec
,
257 .extra1
= &min_lap_keepalive_time
,
258 .extra2
= &max_lap_keepalive_time
263 static struct ctl_path irda_path
[] = {
264 { .procname
= "net", .ctl_name
= CTL_NET
, },
265 { .procname
= "irda", .ctl_name
= NET_IRDA
, },
269 static struct ctl_table_header
*irda_table_header
;
272 * Function irda_sysctl_register (void)
274 * Register our sysctl interface
277 int __init
irda_sysctl_register(void)
279 irda_table_header
= register_sysctl_paths(irda_path
, irda_table
);
280 if (!irda_table_header
)
287 * Function irda_sysctl_unregister (void)
289 * Unregister our sysctl interface
292 void irda_sysctl_unregister(void)
294 unregister_sysctl_table(irda_table_header
);