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