port more changes to make PCI work
[linux-2.4.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 <asm/segment.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 = 0;
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         { DISCOVERY, "discovery", &sysctl_discovery,
103           sizeof(int), 0644, NULL, &proc_dointvec },
104         { DEVNAME, "devname", sysctl_devname,
105           65, 0644, NULL, &do_devname, &sysctl_string},
106 #ifdef CONFIG_IRDA_DEBUG
107         { DEBUG, "debug", &irda_debug,
108           sizeof(int), 0644, NULL, &proc_dointvec },
109 #endif
110 #ifdef CONFIG_IRDA_FAST_RR
111         { FAST_POLL, "fast_poll_increase", &sysctl_fast_poll_increase,
112           sizeof(int), 0644, NULL, &proc_dointvec },
113 #endif
114         { DISCOVERY_SLOTS, "discovery_slots", &sysctl_discovery_slots,
115           sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
116           NULL, &min_discovery_slots, &max_discovery_slots },
117         { DISCOVERY_TIMEOUT, "discovery_timeout", &sysctl_discovery_timeout,
118           sizeof(int), 0644, NULL, &proc_dointvec },
119         { SLOT_TIMEOUT, "slot_timeout", &sysctl_slot_timeout,
120           sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
121           NULL, &min_slot_timeout, &max_slot_timeout },
122         { MAX_BAUD_RATE, "max_baud_rate", &sysctl_max_baud_rate,
123           sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
124           NULL, &min_max_baud_rate, &max_max_baud_rate },
125         { MIN_TX_TURN_TIME, "min_tx_turn_time", &sysctl_min_tx_turn_time,
126           sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
127           NULL, &min_min_tx_turn_time, &max_min_tx_turn_time },
128         { MAX_TX_DATA_SIZE, "max_tx_data_size", &sysctl_max_tx_data_size,
129           sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
130           NULL, &min_max_tx_data_size, &max_max_tx_data_size },
131         { MAX_TX_WINDOW, "max_tx_window", &sysctl_max_tx_window,
132           sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
133           NULL, &min_max_tx_window, &max_max_tx_window },
134         { MAX_NOREPLY_TIME, "max_noreply_time", &sysctl_max_noreply_time,
135           sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
136           NULL, &min_max_noreply_time, &max_max_noreply_time },
137         { WARN_NOREPLY_TIME, "warn_noreply_time", &sysctl_warn_noreply_time,
138           sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
139           NULL, &min_warn_noreply_time, &max_warn_noreply_time },
140         { LAP_KEEPALIVE_TIME, "lap_keepalive_time", &sysctl_lap_keepalive_time,
141           sizeof(int), 0644, NULL, &proc_dointvec_minmax, &sysctl_intvec,
142           NULL, &min_lap_keepalive_time, &max_lap_keepalive_time },
143         { 0 }
144 };
145
146 /* One directory */
147 static ctl_table irda_net_table[] = {
148         { NET_IRDA, "irda", NULL, 0, 0555, irda_table },
149         { 0 }
150 };
151
152 /* The parent directory */
153 static ctl_table irda_root_table[] = {
154         { CTL_NET, "net", NULL, 0, 0555, irda_net_table },
155         { 0 }
156 };
157
158 static struct ctl_table_header *irda_table_header;
159
160 /*
161  * Function irda_sysctl_register (void)
162  *
163  *    Register our sysctl interface
164  *
165  */
166 int irda_sysctl_register(void)
167 {
168         irda_table_header = register_sysctl_table(irda_root_table, 0);
169         if (!irda_table_header)
170                 return -ENOMEM;
171
172         return 0;
173 }
174
175 /*
176  * Function irda_sysctl_unregister (void)
177  *
178  *    Unregister our sysctl interface
179  *
180  */
181 void irda_sysctl_unregister(void) 
182 {
183         unregister_sysctl_table(irda_table_header);
184 }
185
186
187