blob: d8aba869ff11d8bb21e45cf1cea6f397afc8fd91 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*********************************************************************
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +09002 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * 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>
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090011 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 * Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090014 *
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 * the License, or (at your option) any later version.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090019 *
Jan Engelhardt96de0e22007-10-19 23:21:04 +020020 * Neither Dag Brattli nor University of Tromsø admit liability nor
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090021 * provide warranty for any of this software. This material is
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 * provided "AS-IS" and at no charge.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090023 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 ********************************************************************/
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#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 */
32#include <net/irda/irias_object.h>
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034extern int sysctl_discovery;
35extern int sysctl_discovery_slots;
36extern int sysctl_discovery_timeout;
37extern int sysctl_slot_timeout;
38extern int sysctl_fast_poll_increase;
39extern char sysctl_devname[];
40extern int sysctl_max_baud_rate;
41extern int sysctl_min_tx_turn_time;
42extern int sysctl_max_tx_data_size;
43extern int sysctl_max_tx_window;
44extern int sysctl_max_noreply_time;
45extern int sysctl_warn_noreply_time;
46extern int sysctl_lap_keepalive_time;
47
48/* this is needed for the proc_dointvec_minmax - Jean II */
49static int max_discovery_slots = 16; /* ??? */
50static int min_discovery_slots = 1;
51/* IrLAP 6.13.2 says 25ms to 10+70ms - allow higher since some devices
52 * seems to require it. (from Dag's comment) */
53static int max_slot_timeout = 160;
54static int min_slot_timeout = 20;
55static int max_max_baud_rate = 16000000; /* See qos.c - IrLAP spec */
56static int min_max_baud_rate = 2400;
57static int max_min_tx_turn_time = 10000; /* See qos.c - IrLAP spec */
58static int min_min_tx_turn_time;
59static int max_max_tx_data_size = 2048; /* See qos.c - IrLAP spec */
60static int min_max_tx_data_size = 64;
61static int max_max_tx_window = 7; /* See qos.c - IrLAP spec */
62static int min_max_tx_window = 1;
63static int max_max_noreply_time = 40; /* See qos.c - IrLAP spec */
64static int min_max_noreply_time = 3;
65static int max_warn_noreply_time = 3; /* 3s == standard */
66static int min_warn_noreply_time = 1; /* 1s == min WD_TIMER */
67static int max_lap_keepalive_time = 10000; /* 10s */
68static int min_lap_keepalive_time = 100; /* 100us */
69/* For other sysctl, I've no idea of the range. Maybe Dag could help
70 * us on that - Jean II */
71
72static int do_devname(ctl_table *table, int write, struct file *filp,
73 void __user *buffer, size_t *lenp, loff_t *ppos)
74{
75 int ret;
76
77 ret = proc_dostring(table, write, filp, buffer, lenp, ppos);
78 if (ret == 0 && write) {
79 struct ias_value *val;
80
81 val = irias_new_string_value(sysctl_devname);
82 if (val)
83 irias_object_change_attribute("Device", "DeviceName", val);
84 }
85 return ret;
86}
87
88/* One file */
89static ctl_table irda_table[] = {
90 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -070091 .ctl_name = NET_IRDA_DISCOVERY,
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 .procname = "discovery",
93 .data = &sysctl_discovery,
94 .maxlen = sizeof(int),
95 .mode = 0644,
96 .proc_handler = &proc_dointvec
97 },
98 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -070099 .ctl_name = NET_IRDA_DEVNAME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 .procname = "devname",
101 .data = sysctl_devname,
102 .maxlen = 65,
103 .mode = 0644,
104 .proc_handler = &do_devname,
105 .strategy = &sysctl_string
106 },
107#ifdef CONFIG_IRDA_DEBUG
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900108 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700109 .ctl_name = NET_IRDA_DEBUG,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 .procname = "debug",
111 .data = &irda_debug,
112 .maxlen = sizeof(int),
113 .mode = 0644,
114 .proc_handler = &proc_dointvec
115 },
116#endif
117#ifdef CONFIG_IRDA_FAST_RR
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900118 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700119 .ctl_name = NET_IRDA_FAST_POLL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 .procname = "fast_poll_increase",
121 .data = &sysctl_fast_poll_increase,
122 .maxlen = sizeof(int),
123 .mode = 0644,
124 .proc_handler = &proc_dointvec
125 },
126#endif
127 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700128 .ctl_name = NET_IRDA_DISCOVERY_SLOTS,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 .procname = "discovery_slots",
130 .data = &sysctl_discovery_slots,
131 .maxlen = sizeof(int),
132 .mode = 0644,
133 .proc_handler = &proc_dointvec_minmax,
134 .strategy = &sysctl_intvec,
135 .extra1 = &min_discovery_slots,
136 .extra2 = &max_discovery_slots
137 },
138 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700139 .ctl_name = NET_IRDA_DISCOVERY_TIMEOUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 .procname = "discovery_timeout",
141 .data = &sysctl_discovery_timeout,
142 .maxlen = sizeof(int),
143 .mode = 0644,
144 .proc_handler = &proc_dointvec
145 },
146 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700147 .ctl_name = NET_IRDA_SLOT_TIMEOUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 .procname = "slot_timeout",
149 .data = &sysctl_slot_timeout,
150 .maxlen = sizeof(int),
151 .mode = 0644,
152 .proc_handler = &proc_dointvec_minmax,
153 .strategy = &sysctl_intvec,
154 .extra1 = &min_slot_timeout,
155 .extra2 = &max_slot_timeout
156 },
157 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700158 .ctl_name = NET_IRDA_MAX_BAUD_RATE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 .procname = "max_baud_rate",
160 .data = &sysctl_max_baud_rate,
161 .maxlen = sizeof(int),
162 .mode = 0644,
163 .proc_handler = &proc_dointvec_minmax,
164 .strategy = &sysctl_intvec,
165 .extra1 = &min_max_baud_rate,
166 .extra2 = &max_max_baud_rate
167 },
168 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700169 .ctl_name = NET_IRDA_MIN_TX_TURN_TIME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 .procname = "min_tx_turn_time",
171 .data = &sysctl_min_tx_turn_time,
172 .maxlen = sizeof(int),
173 .mode = 0644,
174 .proc_handler = &proc_dointvec_minmax,
175 .strategy = &sysctl_intvec,
176 .extra1 = &min_min_tx_turn_time,
177 .extra2 = &max_min_tx_turn_time
178 },
179 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700180 .ctl_name = NET_IRDA_MAX_TX_DATA_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 .procname = "max_tx_data_size",
182 .data = &sysctl_max_tx_data_size,
183 .maxlen = sizeof(int),
184 .mode = 0644,
185 .proc_handler = &proc_dointvec_minmax,
186 .strategy = &sysctl_intvec,
187 .extra1 = &min_max_tx_data_size,
188 .extra2 = &max_max_tx_data_size
189 },
190 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700191 .ctl_name = NET_IRDA_MAX_TX_WINDOW,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 .procname = "max_tx_window",
193 .data = &sysctl_max_tx_window,
194 .maxlen = sizeof(int),
195 .mode = 0644,
196 .proc_handler = &proc_dointvec_minmax,
197 .strategy = &sysctl_intvec,
198 .extra1 = &min_max_tx_window,
199 .extra2 = &max_max_tx_window
200 },
201 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700202 .ctl_name = NET_IRDA_MAX_NOREPLY_TIME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 .procname = "max_noreply_time",
204 .data = &sysctl_max_noreply_time,
205 .maxlen = sizeof(int),
206 .mode = 0644,
207 .proc_handler = &proc_dointvec_minmax,
208 .strategy = &sysctl_intvec,
209 .extra1 = &min_max_noreply_time,
210 .extra2 = &max_max_noreply_time
211 },
212 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700213 .ctl_name = NET_IRDA_WARN_NOREPLY_TIME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 .procname = "warn_noreply_time",
215 .data = &sysctl_warn_noreply_time,
216 .maxlen = sizeof(int),
217 .mode = 0644,
218 .proc_handler = &proc_dointvec_minmax,
219 .strategy = &sysctl_intvec,
220 .extra1 = &min_warn_noreply_time,
221 .extra2 = &max_warn_noreply_time
222 },
223 {
Eric W. Biedermanf429cd32007-10-18 03:05:33 -0700224 .ctl_name = NET_IRDA_LAP_KEEPALIVE_TIME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 .procname = "lap_keepalive_time",
226 .data = &sysctl_lap_keepalive_time,
227 .maxlen = sizeof(int),
228 .mode = 0644,
229 .proc_handler = &proc_dointvec_minmax,
230 .strategy = &sysctl_intvec,
231 .extra1 = &min_lap_keepalive_time,
232 .extra2 = &max_lap_keepalive_time
233 },
234 { .ctl_name = 0 }
235};
236
Pavel Emelyanovb5ccd792008-01-09 00:30:05 -0800237static struct ctl_path irda_path[] = {
238 { .procname = "net", .ctl_name = CTL_NET, },
239 { .procname = "irda", .ctl_name = NET_IRDA, },
240 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241};
242
243static struct ctl_table_header *irda_table_header;
244
245/*
246 * Function irda_sysctl_register (void)
247 *
248 * Register our sysctl interface
249 *
250 */
251int __init irda_sysctl_register(void)
252{
Pavel Emelyanovb5ccd792008-01-09 00:30:05 -0800253 irda_table_header = register_sysctl_paths(irda_path, irda_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 if (!irda_table_header)
255 return -ENOMEM;
256
257 return 0;
258}
259
260/*
261 * Function irda_sysctl_unregister (void)
262 *
263 * Unregister our sysctl interface
264 *
265 */
Samuel Ortiz75a69ac2007-07-18 02:16:30 -0700266void irda_sysctl_unregister(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267{
268 unregister_sysctl_table(irda_table_header);
269}
270
271
272