Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /********************************************************************* |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 2 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 11 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved. |
| 13 | * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com> |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | * the License, or (at your option) any later version. |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 19 | * |
Jan Engelhardt | 96de0e2 | 2007-10-19 23:21:04 +0200 | [diff] [blame] | 20 | * Neither Dag Brattli nor University of Tromsø admit liability nor |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 21 | * provide warranty for any of this software. This material is |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | * provided "AS-IS" and at no charge. |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 23 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | ********************************************************************/ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 */ |
| 32 | #include <net/irda/irias_object.h> |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | extern int sysctl_discovery; |
| 35 | extern int sysctl_discovery_slots; |
| 36 | extern int sysctl_discovery_timeout; |
| 37 | extern int sysctl_slot_timeout; |
| 38 | extern int sysctl_fast_poll_increase; |
| 39 | extern char sysctl_devname[]; |
| 40 | extern int sysctl_max_baud_rate; |
| 41 | extern int sysctl_min_tx_turn_time; |
| 42 | extern int sysctl_max_tx_data_size; |
| 43 | extern int sysctl_max_tx_window; |
| 44 | extern int sysctl_max_noreply_time; |
| 45 | extern int sysctl_warn_noreply_time; |
| 46 | extern int sysctl_lap_keepalive_time; |
| 47 | |
| 48 | /* this is needed for the proc_dointvec_minmax - Jean II */ |
| 49 | static int max_discovery_slots = 16; /* ??? */ |
| 50 | static 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) */ |
| 53 | static int max_slot_timeout = 160; |
| 54 | static int min_slot_timeout = 20; |
| 55 | static int max_max_baud_rate = 16000000; /* See qos.c - IrLAP spec */ |
| 56 | static int min_max_baud_rate = 2400; |
| 57 | static int max_min_tx_turn_time = 10000; /* See qos.c - IrLAP spec */ |
| 58 | static int min_min_tx_turn_time; |
| 59 | static int max_max_tx_data_size = 2048; /* See qos.c - IrLAP spec */ |
| 60 | static int min_max_tx_data_size = 64; |
| 61 | static int max_max_tx_window = 7; /* See qos.c - IrLAP spec */ |
| 62 | static int min_max_tx_window = 1; |
| 63 | static int max_max_noreply_time = 40; /* See qos.c - IrLAP spec */ |
| 64 | static int min_max_noreply_time = 3; |
| 65 | static int max_warn_noreply_time = 3; /* 3s == standard */ |
| 66 | static int min_warn_noreply_time = 1; /* 1s == min WD_TIMER */ |
| 67 | static int max_lap_keepalive_time = 10000; /* 10s */ |
| 68 | static 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 | |
| 72 | static 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 */ |
| 89 | static ctl_table irda_table[] = { |
| 90 | { |
Eric W. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 91 | .ctl_name = NET_IRDA_DISCOVERY, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | .procname = "discovery", |
| 93 | .data = &sysctl_discovery, |
| 94 | .maxlen = sizeof(int), |
| 95 | .mode = 0644, |
| 96 | .proc_handler = &proc_dointvec |
| 97 | }, |
| 98 | { |
Eric W. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 99 | .ctl_name = NET_IRDA_DEVNAME, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | .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 Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 108 | { |
Eric W. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 109 | .ctl_name = NET_IRDA_DEBUG, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | .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 Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 118 | { |
Eric W. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 119 | .ctl_name = NET_IRDA_FAST_POLL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | .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. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 128 | .ctl_name = NET_IRDA_DISCOVERY_SLOTS, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | .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. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 139 | .ctl_name = NET_IRDA_DISCOVERY_TIMEOUT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | .procname = "discovery_timeout", |
| 141 | .data = &sysctl_discovery_timeout, |
| 142 | .maxlen = sizeof(int), |
| 143 | .mode = 0644, |
| 144 | .proc_handler = &proc_dointvec |
| 145 | }, |
| 146 | { |
Eric W. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 147 | .ctl_name = NET_IRDA_SLOT_TIMEOUT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | .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. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 158 | .ctl_name = NET_IRDA_MAX_BAUD_RATE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | .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. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 169 | .ctl_name = NET_IRDA_MIN_TX_TURN_TIME, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | .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. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 180 | .ctl_name = NET_IRDA_MAX_TX_DATA_SIZE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | .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. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 191 | .ctl_name = NET_IRDA_MAX_TX_WINDOW, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | .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. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 202 | .ctl_name = NET_IRDA_MAX_NOREPLY_TIME, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | .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. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 213 | .ctl_name = NET_IRDA_WARN_NOREPLY_TIME, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | .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. Biederman | f429cd3 | 2007-10-18 03:05:33 -0700 | [diff] [blame] | 224 | .ctl_name = NET_IRDA_LAP_KEEPALIVE_TIME, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | .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 Emelyanov | b5ccd79 | 2008-01-09 00:30:05 -0800 | [diff] [blame^] | 237 | static struct ctl_path irda_path[] = { |
| 238 | { .procname = "net", .ctl_name = CTL_NET, }, |
| 239 | { .procname = "irda", .ctl_name = NET_IRDA, }, |
| 240 | { } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | }; |
| 242 | |
| 243 | static struct ctl_table_header *irda_table_header; |
| 244 | |
| 245 | /* |
| 246 | * Function irda_sysctl_register (void) |
| 247 | * |
| 248 | * Register our sysctl interface |
| 249 | * |
| 250 | */ |
| 251 | int __init irda_sysctl_register(void) |
| 252 | { |
Pavel Emelyanov | b5ccd79 | 2008-01-09 00:30:05 -0800 | [diff] [blame^] | 253 | irda_table_header = register_sysctl_paths(irda_path, irda_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | 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 Ortiz | 75a69ac | 2007-07-18 02:16:30 -0700 | [diff] [blame] | 266 | void irda_sysctl_unregister(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | { |
| 268 | unregister_sysctl_table(irda_table_header); |
| 269 | } |
| 270 | |
| 271 | |
| 272 | |