Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs...
[linux-block.git] / net / irda / irsysctl.c
CommitLineData
1da177e4 1/*********************************************************************
6819bc2e 2 *
1da177e4
LT
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>
6819bc2e 11 *
1da177e4
LT
12 * Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
6819bc2e
YH
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
1da177e4 18 * the License, or (at your option) any later version.
6819bc2e 19 *
96de0e25 20 * Neither Dag Brattli nor University of Tromsø admit liability nor
6819bc2e 21 * provide warranty for any of this software. This material is
1da177e4 22 * provided "AS-IS" and at no charge.
6819bc2e 23 *
1da177e4
LT
24 ********************************************************************/
25
1da177e4
LT
26#include <linux/mm.h>
27#include <linux/ctype.h>
28#include <linux/sysctl.h>
29#include <linux/init.h>
30
31#include <net/irda/irda.h> /* irda_debug */
91cde6f7
RB
32#include <net/irda/irlmp.h>
33#include <net/irda/timer.h>
1da177e4
LT
34#include <net/irda/irias_object.h>
35
1da177e4
LT
36extern int sysctl_discovery;
37extern int sysctl_discovery_slots;
38extern int sysctl_discovery_timeout;
39extern int sysctl_slot_timeout;
40extern int sysctl_fast_poll_increase;
41extern char sysctl_devname[];
42extern int sysctl_max_baud_rate;
43extern int sysctl_min_tx_turn_time;
44extern int sysctl_max_tx_data_size;
45extern int sysctl_max_tx_window;
46extern int sysctl_max_noreply_time;
47extern int sysctl_warn_noreply_time;
48extern int sysctl_lap_keepalive_time;
49
91cde6f7
RB
50extern struct irlmp_cb *irlmp;
51
1da177e4
LT
52/* this is needed for the proc_dointvec_minmax - Jean II */
53static int max_discovery_slots = 16; /* ??? */
54static 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) */
57static int max_slot_timeout = 160;
58static int min_slot_timeout = 20;
59static int max_max_baud_rate = 16000000; /* See qos.c - IrLAP spec */
60static int min_max_baud_rate = 2400;
61static int max_min_tx_turn_time = 10000; /* See qos.c - IrLAP spec */
62static int min_min_tx_turn_time;
63static int max_max_tx_data_size = 2048; /* See qos.c - IrLAP spec */
64static int min_max_tx_data_size = 64;
65static int max_max_tx_window = 7; /* See qos.c - IrLAP spec */
66static int min_max_tx_window = 1;
67static int max_max_noreply_time = 40; /* See qos.c - IrLAP spec */
68static int min_max_noreply_time = 3;
69static int max_warn_noreply_time = 3; /* 3s == standard */
70static int min_warn_noreply_time = 1; /* 1s == min WD_TIMER */
71static int max_lap_keepalive_time = 10000; /* 10s */
72static 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 */
75
76static int do_devname(ctl_table *table, int write, struct file *filp,
77 void __user *buffer, size_t *lenp, loff_t *ppos)
78{
79 int ret;
80
81 ret = proc_dostring(table, write, filp, buffer, lenp, ppos);
82 if (ret == 0 && write) {
83 struct ias_value *val;
84
85 val = irias_new_string_value(sysctl_devname);
86 if (val)
87 irias_object_change_attribute("Device", "DeviceName", val);
88 }
89 return ret;
90}
91
91cde6f7
RB
92
93static int do_discovery(ctl_table *table, int write, struct file *filp,
94 void __user *buffer, size_t *lenp, loff_t *ppos)
95{
96 int ret;
97
98 ret = proc_dointvec(table, write, filp, buffer, lenp, ppos);
99 if (ret)
100 return ret;
101
102 if (irlmp == NULL)
103 return -ENODEV;
104
105 if (sysctl_discovery)
106 irlmp_start_discovery_timer(irlmp, sysctl_discovery_timeout*HZ);
107 else
108 del_timer_sync(&irlmp->discovery_timer);
109
110 return ret;
111}
112
1da177e4
LT
113/* One file */
114static ctl_table irda_table[] = {
115 {
f429cd37 116 .ctl_name = NET_IRDA_DISCOVERY,
1da177e4
LT
117 .procname = "discovery",
118 .data = &sysctl_discovery,
119 .maxlen = sizeof(int),
120 .mode = 0644,
6d9f239a
AD
121 .proc_handler = do_discovery,
122 .strategy = sysctl_intvec
1da177e4
LT
123 },
124 {
f429cd37 125 .ctl_name = NET_IRDA_DEVNAME,
1da177e4
LT
126 .procname = "devname",
127 .data = sysctl_devname,
128 .maxlen = 65,
129 .mode = 0644,
6d9f239a
AD
130 .proc_handler = do_devname,
131 .strategy = sysctl_string
1da177e4
LT
132 },
133#ifdef CONFIG_IRDA_DEBUG
6819bc2e 134 {
f429cd37 135 .ctl_name = NET_IRDA_DEBUG,
1da177e4
LT
136 .procname = "debug",
137 .data = &irda_debug,
138 .maxlen = sizeof(int),
139 .mode = 0644,
6d9f239a 140 .proc_handler = proc_dointvec
1da177e4
LT
141 },
142#endif
143#ifdef CONFIG_IRDA_FAST_RR
6819bc2e 144 {
f429cd37 145 .ctl_name = NET_IRDA_FAST_POLL,
1da177e4
LT
146 .procname = "fast_poll_increase",
147 .data = &sysctl_fast_poll_increase,
148 .maxlen = sizeof(int),
149 .mode = 0644,
6d9f239a 150 .proc_handler = proc_dointvec
1da177e4
LT
151 },
152#endif
153 {
f429cd37 154 .ctl_name = NET_IRDA_DISCOVERY_SLOTS,
1da177e4
LT
155 .procname = "discovery_slots",
156 .data = &sysctl_discovery_slots,
157 .maxlen = sizeof(int),
158 .mode = 0644,
6d9f239a
AD
159 .proc_handler = proc_dointvec_minmax,
160 .strategy = sysctl_intvec,
1da177e4
LT
161 .extra1 = &min_discovery_slots,
162 .extra2 = &max_discovery_slots
163 },
164 {
f429cd37 165 .ctl_name = NET_IRDA_DISCOVERY_TIMEOUT,
1da177e4
LT
166 .procname = "discovery_timeout",
167 .data = &sysctl_discovery_timeout,
168 .maxlen = sizeof(int),
169 .mode = 0644,
6d9f239a 170 .proc_handler = proc_dointvec
1da177e4
LT
171 },
172 {
f429cd37 173 .ctl_name = NET_IRDA_SLOT_TIMEOUT,
1da177e4
LT
174 .procname = "slot_timeout",
175 .data = &sysctl_slot_timeout,
176 .maxlen = sizeof(int),
177 .mode = 0644,
6d9f239a
AD
178 .proc_handler = proc_dointvec_minmax,
179 .strategy = sysctl_intvec,
1da177e4
LT
180 .extra1 = &min_slot_timeout,
181 .extra2 = &max_slot_timeout
182 },
183 {
f429cd37 184 .ctl_name = NET_IRDA_MAX_BAUD_RATE,
1da177e4
LT
185 .procname = "max_baud_rate",
186 .data = &sysctl_max_baud_rate,
187 .maxlen = sizeof(int),
188 .mode = 0644,
6d9f239a
AD
189 .proc_handler = proc_dointvec_minmax,
190 .strategy = sysctl_intvec,
1da177e4
LT
191 .extra1 = &min_max_baud_rate,
192 .extra2 = &max_max_baud_rate
193 },
194 {
f429cd37 195 .ctl_name = NET_IRDA_MIN_TX_TURN_TIME,
1da177e4
LT
196 .procname = "min_tx_turn_time",
197 .data = &sysctl_min_tx_turn_time,
198 .maxlen = sizeof(int),
199 .mode = 0644,
6d9f239a
AD
200 .proc_handler = proc_dointvec_minmax,
201 .strategy = sysctl_intvec,
1da177e4
LT
202 .extra1 = &min_min_tx_turn_time,
203 .extra2 = &max_min_tx_turn_time
204 },
205 {
f429cd37 206 .ctl_name = NET_IRDA_MAX_TX_DATA_SIZE,
1da177e4
LT
207 .procname = "max_tx_data_size",
208 .data = &sysctl_max_tx_data_size,
209 .maxlen = sizeof(int),
210 .mode = 0644,
6d9f239a
AD
211 .proc_handler = proc_dointvec_minmax,
212 .strategy = sysctl_intvec,
1da177e4
LT
213 .extra1 = &min_max_tx_data_size,
214 .extra2 = &max_max_tx_data_size
215 },
216 {
f429cd37 217 .ctl_name = NET_IRDA_MAX_TX_WINDOW,
1da177e4
LT
218 .procname = "max_tx_window",
219 .data = &sysctl_max_tx_window,
220 .maxlen = sizeof(int),
221 .mode = 0644,
6d9f239a
AD
222 .proc_handler = proc_dointvec_minmax,
223 .strategy = sysctl_intvec,
1da177e4
LT
224 .extra1 = &min_max_tx_window,
225 .extra2 = &max_max_tx_window
226 },
227 {
f429cd37 228 .ctl_name = NET_IRDA_MAX_NOREPLY_TIME,
1da177e4
LT
229 .procname = "max_noreply_time",
230 .data = &sysctl_max_noreply_time,
231 .maxlen = sizeof(int),
232 .mode = 0644,
6d9f239a
AD
233 .proc_handler = proc_dointvec_minmax,
234 .strategy = sysctl_intvec,
1da177e4
LT
235 .extra1 = &min_max_noreply_time,
236 .extra2 = &max_max_noreply_time
237 },
238 {
f429cd37 239 .ctl_name = NET_IRDA_WARN_NOREPLY_TIME,
1da177e4
LT
240 .procname = "warn_noreply_time",
241 .data = &sysctl_warn_noreply_time,
242 .maxlen = sizeof(int),
243 .mode = 0644,
6d9f239a
AD
244 .proc_handler = proc_dointvec_minmax,
245 .strategy = sysctl_intvec,
1da177e4
LT
246 .extra1 = &min_warn_noreply_time,
247 .extra2 = &max_warn_noreply_time
248 },
249 {
f429cd37 250 .ctl_name = NET_IRDA_LAP_KEEPALIVE_TIME,
1da177e4
LT
251 .procname = "lap_keepalive_time",
252 .data = &sysctl_lap_keepalive_time,
253 .maxlen = sizeof(int),
254 .mode = 0644,
6d9f239a
AD
255 .proc_handler = proc_dointvec_minmax,
256 .strategy = sysctl_intvec,
1da177e4
LT
257 .extra1 = &min_lap_keepalive_time,
258 .extra2 = &max_lap_keepalive_time
259 },
260 { .ctl_name = 0 }
261};
262
b5ccd792
PE
263static struct ctl_path irda_path[] = {
264 { .procname = "net", .ctl_name = CTL_NET, },
265 { .procname = "irda", .ctl_name = NET_IRDA, },
266 { }
1da177e4
LT
267};
268
269static struct ctl_table_header *irda_table_header;
270
271/*
272 * Function irda_sysctl_register (void)
273 *
274 * Register our sysctl interface
275 *
276 */
277int __init irda_sysctl_register(void)
278{
b5ccd792 279 irda_table_header = register_sysctl_paths(irda_path, irda_table);
1da177e4
LT
280 if (!irda_table_header)
281 return -ENOMEM;
282
283 return 0;
284}
285
286/*
287 * Function irda_sysctl_unregister (void)
288 *
289 * Unregister our sysctl interface
290 *
291 */
75a69ac6 292void irda_sysctl_unregister(void)
1da177e4
LT
293{
294 unregister_sysctl_table(irda_table_header);
295}
296
297
298