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/irias_object.h>
34 #define NET_IRDA 412 /* Random number */
35 enum { DISCOVERY
=1, DEVNAME
, DEBUG
, FAST_POLL
, DISCOVERY_SLOTS
,
36 DISCOVERY_TIMEOUT
, SLOT_TIMEOUT
, MAX_BAUD_RATE
, MIN_TX_TURN_TIME
,
37 MAX_TX_DATA_SIZE
, MAX_TX_WINDOW
, MAX_NOREPLY_TIME
, WARN_NOREPLY_TIME
,
40 extern int sysctl_discovery
;
41 extern int sysctl_discovery_slots
;
42 extern int sysctl_discovery_timeout
;
43 extern int sysctl_slot_timeout
;
44 extern int sysctl_fast_poll_increase
;
45 extern char sysctl_devname
[];
46 extern int sysctl_max_baud_rate
;
47 extern int sysctl_min_tx_turn_time
;
48 extern int sysctl_max_tx_data_size
;
49 extern int sysctl_max_tx_window
;
50 extern int sysctl_max_noreply_time
;
51 extern int sysctl_warn_noreply_time
;
52 extern int sysctl_lap_keepalive_time
;
54 /* this is needed for the proc_dointvec_minmax - Jean II */
55 static int max_discovery_slots
= 16; /* ??? */
56 static int min_discovery_slots
= 1;
57 /* IrLAP 6.13.2 says 25ms to 10+70ms - allow higher since some devices
58 * seems to require it. (from Dag's comment) */
59 static int max_slot_timeout
= 160;
60 static int min_slot_timeout
= 20;
61 static int max_max_baud_rate
= 16000000; /* See qos.c - IrLAP spec */
62 static int min_max_baud_rate
= 2400;
63 static int max_min_tx_turn_time
= 10000; /* See qos.c - IrLAP spec */
64 static int min_min_tx_turn_time
;
65 static int max_max_tx_data_size
= 2048; /* See qos.c - IrLAP spec */
66 static int min_max_tx_data_size
= 64;
67 static int max_max_tx_window
= 7; /* See qos.c - IrLAP spec */
68 static int min_max_tx_window
= 1;
69 static int max_max_noreply_time
= 40; /* See qos.c - IrLAP spec */
70 static int min_max_noreply_time
= 3;
71 static int max_warn_noreply_time
= 3; /* 3s == standard */
72 static int min_warn_noreply_time
= 1; /* 1s == min WD_TIMER */
73 static int max_lap_keepalive_time
= 10000; /* 10s */
74 static int min_lap_keepalive_time
= 100; /* 100us */
75 /* For other sysctl, I've no idea of the range. Maybe Dag could help
76 * us on that - Jean II */
78 static int do_devname(ctl_table
*table
, int write
, struct file
*filp
,
79 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
83 ret
= proc_dostring(table
, write
, filp
, buffer
, lenp
, ppos
);
84 if (ret
== 0 && write
) {
85 struct ias_value
*val
;
87 val
= irias_new_string_value(sysctl_devname
);
89 irias_object_change_attribute("Device", "DeviceName", val
);
95 static ctl_table irda_table
[] = {
97 .ctl_name
= DISCOVERY
,
98 .procname
= "discovery",
99 .data
= &sysctl_discovery
,
100 .maxlen
= sizeof(int),
102 .proc_handler
= &proc_dointvec
106 .procname
= "devname",
107 .data
= sysctl_devname
,
110 .proc_handler
= &do_devname
,
111 .strategy
= &sysctl_string
113 #ifdef CONFIG_IRDA_DEBUG
118 .maxlen
= sizeof(int),
120 .proc_handler
= &proc_dointvec
123 #ifdef CONFIG_IRDA_FAST_RR
125 .ctl_name
= FAST_POLL
,
126 .procname
= "fast_poll_increase",
127 .data
= &sysctl_fast_poll_increase
,
128 .maxlen
= sizeof(int),
130 .proc_handler
= &proc_dointvec
134 .ctl_name
= DISCOVERY_SLOTS
,
135 .procname
= "discovery_slots",
136 .data
= &sysctl_discovery_slots
,
137 .maxlen
= sizeof(int),
139 .proc_handler
= &proc_dointvec_minmax
,
140 .strategy
= &sysctl_intvec
,
141 .extra1
= &min_discovery_slots
,
142 .extra2
= &max_discovery_slots
145 .ctl_name
= DISCOVERY_TIMEOUT
,
146 .procname
= "discovery_timeout",
147 .data
= &sysctl_discovery_timeout
,
148 .maxlen
= sizeof(int),
150 .proc_handler
= &proc_dointvec
153 .ctl_name
= SLOT_TIMEOUT
,
154 .procname
= "slot_timeout",
155 .data
= &sysctl_slot_timeout
,
156 .maxlen
= sizeof(int),
158 .proc_handler
= &proc_dointvec_minmax
,
159 .strategy
= &sysctl_intvec
,
160 .extra1
= &min_slot_timeout
,
161 .extra2
= &max_slot_timeout
164 .ctl_name
= MAX_BAUD_RATE
,
165 .procname
= "max_baud_rate",
166 .data
= &sysctl_max_baud_rate
,
167 .maxlen
= sizeof(int),
169 .proc_handler
= &proc_dointvec_minmax
,
170 .strategy
= &sysctl_intvec
,
171 .extra1
= &min_max_baud_rate
,
172 .extra2
= &max_max_baud_rate
175 .ctl_name
= MIN_TX_TURN_TIME
,
176 .procname
= "min_tx_turn_time",
177 .data
= &sysctl_min_tx_turn_time
,
178 .maxlen
= sizeof(int),
180 .proc_handler
= &proc_dointvec_minmax
,
181 .strategy
= &sysctl_intvec
,
182 .extra1
= &min_min_tx_turn_time
,
183 .extra2
= &max_min_tx_turn_time
186 .ctl_name
= MAX_TX_DATA_SIZE
,
187 .procname
= "max_tx_data_size",
188 .data
= &sysctl_max_tx_data_size
,
189 .maxlen
= sizeof(int),
191 .proc_handler
= &proc_dointvec_minmax
,
192 .strategy
= &sysctl_intvec
,
193 .extra1
= &min_max_tx_data_size
,
194 .extra2
= &max_max_tx_data_size
197 .ctl_name
= MAX_TX_WINDOW
,
198 .procname
= "max_tx_window",
199 .data
= &sysctl_max_tx_window
,
200 .maxlen
= sizeof(int),
202 .proc_handler
= &proc_dointvec_minmax
,
203 .strategy
= &sysctl_intvec
,
204 .extra1
= &min_max_tx_window
,
205 .extra2
= &max_max_tx_window
208 .ctl_name
= MAX_NOREPLY_TIME
,
209 .procname
= "max_noreply_time",
210 .data
= &sysctl_max_noreply_time
,
211 .maxlen
= sizeof(int),
213 .proc_handler
= &proc_dointvec_minmax
,
214 .strategy
= &sysctl_intvec
,
215 .extra1
= &min_max_noreply_time
,
216 .extra2
= &max_max_noreply_time
219 .ctl_name
= WARN_NOREPLY_TIME
,
220 .procname
= "warn_noreply_time",
221 .data
= &sysctl_warn_noreply_time
,
222 .maxlen
= sizeof(int),
224 .proc_handler
= &proc_dointvec_minmax
,
225 .strategy
= &sysctl_intvec
,
226 .extra1
= &min_warn_noreply_time
,
227 .extra2
= &max_warn_noreply_time
230 .ctl_name
= LAP_KEEPALIVE_TIME
,
231 .procname
= "lap_keepalive_time",
232 .data
= &sysctl_lap_keepalive_time
,
233 .maxlen
= sizeof(int),
235 .proc_handler
= &proc_dointvec_minmax
,
236 .strategy
= &sysctl_intvec
,
237 .extra1
= &min_lap_keepalive_time
,
238 .extra2
= &max_lap_keepalive_time
244 static ctl_table irda_net_table
[] = {
246 .ctl_name
= NET_IRDA
,
255 /* The parent directory */
256 static ctl_table irda_root_table
[] = {
262 .child
= irda_net_table
267 static struct ctl_table_header
*irda_table_header
;
270 * Function irda_sysctl_register (void)
272 * Register our sysctl interface
275 int __init
irda_sysctl_register(void)
277 irda_table_header
= register_sysctl_table(irda_root_table
, 0);
278 if (!irda_table_header
)
285 * Function irda_sysctl_unregister (void)
287 * Unregister our sysctl interface
290 void __exit
irda_sysctl_unregister(void)
292 unregister_sysctl_table(irda_table_header
);