commented early_printk patch because of rejects.
[linux-flexiantxendom0-3.2.10.git] / net / irda / irsysctl.c
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
26 #include <linux/config.h>
27 #include <linux/mm.h>
28 #include <linux/ctype.h>
29 #include <linux/sysctl.h>
30 #include <linux/init.h>
31
32 #include <net/irda/irda.h>
33 #include <net/irda/irias_object.h>
34
35 #define NET_IRDA 412 /* Random number */
36 enum { DISCOVERY=1, DEVNAME, DEBUG, FAST_POLL, DISCOVERY_SLOTS,
37        DISCOVERY_TIMEOUT, SLOT_TIMEOUT, MAX_BAUD_RATE, MIN_TX_TURN_TIME,
38        MAX_TX_DATA_SIZE, MAX_TX_WINDOW, MAX_NOREPLY_TIME, WARN_NOREPLY_TIME,
39        LAP_KEEPALIVE_TIME };
40
41 extern int  sysctl_discovery;
42 extern int  sysctl_discovery_slots;
43 extern int  sysctl_discovery_timeout;
44 extern int  sysctl_slot_timeout;
45 extern int  sysctl_fast_poll_increase;
46 int         sysctl_compression = 0;
47 extern char sysctl_devname[];
48 extern int  sysctl_max_baud_rate;
49 extern int  sysctl_min_tx_turn_time;
50 extern int  sysctl_max_tx_data_size;
51 extern int  sysctl_max_tx_window;
52 extern int  sysctl_max_noreply_time;
53 extern int  sysctl_warn_noreply_time;
54 extern int  sysctl_lap_keepalive_time;
55
56 #ifdef CONFIG_IRDA_DEBUG
57 extern unsigned int irda_debug;
58 #endif
59
60 /* this is needed for the proc_dointvec_minmax - Jean II */
61 static int max_discovery_slots = 16;            /* ??? */
62 static int min_discovery_slots = 1;
63 /* IrLAP 6.13.2 says 25ms to 10+70ms - allow higher since some devices
64  * seems to require it. (from Dag's comment) */
65 static int max_slot_timeout = 160;
66 static int min_slot_timeout = 20;
67 static int max_max_baud_rate = 16000000;        /* See qos.c - IrLAP spec */
68 static int min_max_baud_rate = 2400;
69 static int max_min_tx_turn_time = 10000;        /* See qos.c - IrLAP spec */
70 static int min_min_tx_turn_time;
71 static int max_max_tx_data_size = 2048;         /* See qos.c - IrLAP spec */
72 static int min_max_tx_data_size = 64;
73 static int max_max_tx_window = 7;               /* See qos.c - IrLAP spec */
74 static int min_max_tx_window = 1;
75 static int max_max_noreply_time = 40;           /* See qos.c - IrLAP spec */
76 static int min_max_noreply_time = 3;
77 static int max_warn_noreply_time = 3;           /* 3s == standard */
78 static int min_warn_noreply_time = 1;           /* 1s == min WD_TIMER */
79 static int max_lap_keepalive_time = 10000;      /* 10s */
80 static int min_lap_keepalive_time = 100;        /* 100us */
81 /* For other sysctl, I've no idea of the range. Maybe Dag could help
82  * us on that - Jean II */
83
84 static int do_devname(ctl_table *table, int write, struct file *filp,
85                       void *buffer, size_t *lenp)
86 {
87         int ret;
88
89         ret = proc_dostring(table, write, filp, buffer, lenp);
90         if (ret == 0 && write) {
91                 struct ias_value *val;
92
93                 val = irias_new_string_value(sysctl_devname);
94                 if (val)
95                         irias_object_change_attribute("Device", "DeviceName", val);
96         }
97         return ret;
98 }
99
100 /* One file */
101 static ctl_table irda_table[] = {
102         {
103                 .ctl_name       = DISCOVERY,
104                 .procname       = "discovery",
105                 .data           = &sysctl_discovery,
106                 .maxlen         = sizeof(int),
107                 .mode           = 0644,
108                 .proc_handler   = &proc_dointvec
109         },
110         {
111                 .ctl_name       = DEVNAME,
112                 .procname       = "devname",
113                 .data           = sysctl_devname,
114                 .maxlen         = 65,
115                 .mode           = 0644,
116                 .proc_handler   = &do_devname,
117                 .strategy       = &sysctl_string
118         },
119 #ifdef CONFIG_IRDA_DEBUG
120         {
121                 .ctl_name       = DEBUG,
122                 .procname       = "debug",
123                 .data           = &irda_debug,
124                 .maxlen         = sizeof(int),
125                 .mode           = 0644,
126                 .proc_handler   = &proc_dointvec
127         },
128 #endif
129 #ifdef CONFIG_IRDA_FAST_RR
130         {
131                 .ctl_name       = FAST_POLL,
132                 .procname       = "fast_poll_increase",
133                 .data           = &sysctl_fast_poll_increase,
134                 .maxlen         = sizeof(int),
135                 .mode           = 0644,
136                 .proc_handler   = &proc_dointvec
137         },
138 #endif
139         {
140                 .ctl_name       = DISCOVERY_SLOTS,
141                 .procname       = "discovery_slots",
142                 .data           = &sysctl_discovery_slots,
143                 .maxlen         = sizeof(int),
144                 .mode           = 0644,
145                 .proc_handler   = &proc_dointvec_minmax,
146                 .strategy       = &sysctl_intvec,
147                 .extra1         = &min_discovery_slots,
148                 .extra2         = &max_discovery_slots
149         },
150         {
151                 .ctl_name       = DISCOVERY_TIMEOUT,
152                 .procname       = "discovery_timeout",
153                 .data           = &sysctl_discovery_timeout,
154                 .maxlen         = sizeof(int),
155                 .mode           = 0644,
156                 .proc_handler   = &proc_dointvec
157         },
158         {
159                 .ctl_name       = SLOT_TIMEOUT,
160                 .procname       = "slot_timeout",
161                 .data           = &sysctl_slot_timeout,
162                 .maxlen         = sizeof(int),
163                 .mode           = 0644,
164                 .proc_handler   = &proc_dointvec_minmax,
165                 .strategy       = &sysctl_intvec,
166                 .extra1         = &min_slot_timeout,
167                 .extra2         = &max_slot_timeout
168         },
169         {
170                 .ctl_name       = MAX_BAUD_RATE,
171                 .procname       = "max_baud_rate",
172                 .data           = &sysctl_max_baud_rate,
173                 .maxlen         = sizeof(int),
174                 .mode           = 0644,
175                 .proc_handler   = &proc_dointvec_minmax,
176                 .strategy       = &sysctl_intvec,
177                 .extra1         = &min_max_baud_rate,
178                 .extra2         = &max_max_baud_rate
179         },
180         {
181                 .ctl_name       = MIN_TX_TURN_TIME,
182                 .procname       = "min_tx_turn_time",
183                 .data           = &sysctl_min_tx_turn_time,
184                 .maxlen         = sizeof(int),
185                 .mode           = 0644,
186                 .proc_handler   = &proc_dointvec_minmax,
187                 .strategy       = &sysctl_intvec,
188                 .extra1         = &min_min_tx_turn_time,
189                 .extra2         = &max_min_tx_turn_time
190         },
191         {
192                 .ctl_name       = MAX_TX_DATA_SIZE,
193                 .procname       = "max_tx_data_size",
194                 .data           = &sysctl_max_tx_data_size,
195                 .maxlen         = sizeof(int),
196                 .mode           = 0644,
197                 .proc_handler   = &proc_dointvec_minmax,
198                 .strategy       = &sysctl_intvec,
199                 .extra1         = &min_max_tx_data_size,
200                 .extra2         = &max_max_tx_data_size
201         },
202         {
203                 .ctl_name       = MAX_TX_WINDOW,
204                 .procname       = "max_tx_window",
205                 .data           = &sysctl_max_tx_window,
206                 .maxlen         = sizeof(int),
207                 .mode           = 0644,
208                 .proc_handler   = &proc_dointvec_minmax,
209                 .strategy       = &sysctl_intvec,
210                 .extra1         = &min_max_tx_window,
211                 .extra2         = &max_max_tx_window
212         },
213         {
214                 .ctl_name       = MAX_NOREPLY_TIME,
215                 .procname       = "max_noreply_time",
216                 .data           = &sysctl_max_noreply_time,
217                 .maxlen         = sizeof(int),
218                 .mode           = 0644,
219                 .proc_handler   = &proc_dointvec_minmax,
220                 .strategy       = &sysctl_intvec,
221                 .extra1         = &min_max_noreply_time,
222                 .extra2         = &max_max_noreply_time
223         },
224         {
225                 .ctl_name       = WARN_NOREPLY_TIME,
226                 .procname       = "warn_noreply_time",
227                 .data           = &sysctl_warn_noreply_time,
228                 .maxlen         = sizeof(int),
229                 .mode           = 0644,
230                 .proc_handler   = &proc_dointvec_minmax,
231                 .strategy       = &sysctl_intvec,
232                 .extra1         = &min_warn_noreply_time,
233                 .extra2         = &max_warn_noreply_time
234         },
235         {
236                 .ctl_name       = LAP_KEEPALIVE_TIME,
237                 .procname       = "lap_keepalive_time",
238                 .data           = &sysctl_lap_keepalive_time,
239                 .maxlen         = sizeof(int),
240                 .mode           = 0644,
241                 .proc_handler   = &proc_dointvec_minmax,
242                 .strategy       = &sysctl_intvec,
243                 .extra1         = &min_lap_keepalive_time,
244                 .extra2         = &max_lap_keepalive_time
245         },
246         { .ctl_name = 0 }
247 };
248
249 /* One directory */
250 static ctl_table irda_net_table[] = {
251         {
252                 .ctl_name       = NET_IRDA,
253                 .procname       = "irda",
254                 .maxlen         = 0,
255                 .mode           = 0555,
256                 .child          = irda_table
257         },
258         { .ctl_name = 0 }
259 };
260
261 /* The parent directory */
262 static ctl_table irda_root_table[] = {
263         {
264                 .ctl_name       = CTL_NET,
265                 .procname       = "net",
266                 .maxlen         = 0,
267                 .mode           = 0555,
268                 .child          = irda_net_table
269         },
270         { .ctl_name = 0 }
271 };
272
273 static struct ctl_table_header *irda_table_header;
274
275 /*
276  * Function irda_sysctl_register (void)
277  *
278  *    Register our sysctl interface
279  *
280  */
281 int __init irda_sysctl_register(void)
282 {
283         irda_table_header = register_sysctl_table(irda_root_table, 0);
284         if (!irda_table_header)
285                 return -ENOMEM;
286
287         return 0;
288 }
289
290 /*
291  * Function irda_sysctl_unregister (void)
292  *
293  *    Unregister our sysctl interface
294  *
295  */
296 void __exit irda_sysctl_unregister(void) 
297 {
298         unregister_sysctl_table(irda_table_header);
299 }
300
301
302