linux/drivers/isdn/gigaset/gigaset.h
<<
>>
Prefs
   1/*
   2 * Siemens Gigaset 307x driver
   3 * Common header file for all connection variants
   4 *
   5 * Written by Stefan Eilers
   6 *        and Hansjoerg Lipp <hjlipp@web.de>
   7 *
   8 * =====================================================================
   9 *      This program is free software; you can redistribute it and/or
  10 *      modify it under the terms of the GNU General Public License as
  11 *      published by the Free Software Foundation; either version 2 of
  12 *      the License, or (at your option) any later version.
  13 * =====================================================================
  14 */
  15
  16#ifndef GIGASET_H
  17#define GIGASET_H
  18
  19#include <linux/kernel.h>
  20#include <linux/compiler.h>
  21#include <linux/types.h>
  22#include <linux/spinlock.h>
  23#include <linux/isdnif.h>
  24#include <linux/usb.h>
  25#include <linux/skbuff.h>
  26#include <linux/netdevice.h>
  27#include <linux/ppp_defs.h>
  28#include <linux/timer.h>
  29#include <linux/interrupt.h>
  30#include <linux/tty.h>
  31#include <linux/tty_driver.h>
  32#include <linux/list.h>
  33#include <asm/atomic.h>
  34
  35#define GIG_VERSION {0,5,0,0}
  36#define GIG_COMPAT  {0,4,0,0}
  37
  38#define MAX_REC_PARAMS 10       /* Max. number of params in response string */
  39#define MAX_RESP_SIZE 512       /* Max. size of a response string */
  40#define HW_HDR_LEN 2            /* Header size used to store ack info */
  41
  42#define MAX_EVENTS 64           /* size of event queue */
  43
  44#define RBUFSIZE 8192
  45#define SBUFSIZE 4096           /* sk_buff payload size */
  46
  47#define TRANSBUFSIZE 768        /* bytes per skb for transparent receive */
  48#define MAX_BUF_SIZE (SBUFSIZE - 2)     /* Max. size of a data packet from LL */
  49
  50/* compile time options */
  51#define GIG_MAJOR 0
  52
  53#define GIG_MAYINITONDIAL
  54#define GIG_RETRYCID
  55#define GIG_X75
  56
  57#define GIG_TICK 100            /* in milliseconds */
  58
  59/* timeout values (unit: 1 sec) */
  60#define INIT_TIMEOUT 1
  61
  62/* timeout values (unit: 0.1 sec) */
  63#define RING_TIMEOUT 3          /* for additional parameters to RING */
  64#define BAS_TIMEOUT 20          /* for response to Base USB ops */
  65#define ATRDY_TIMEOUT 3         /* for HD_READY_SEND_ATDATA */
  66
  67#define BAS_RETRY 3             /* max. retries for base USB ops */
  68
  69#define MAXACT 3
  70
  71extern int gigaset_debuglevel;  /* "needs" cast to (enum debuglevel) */
  72
  73/* debug flags, combine by adding/bitwise OR */
  74enum debuglevel {
  75        DEBUG_INTR        = 0x00008, /* interrupt processing */
  76        DEBUG_CMD         = 0x00020, /* sent/received LL commands */
  77        DEBUG_STREAM      = 0x00040, /* application data stream I/O events */
  78        DEBUG_STREAM_DUMP = 0x00080, /* application data stream content */
  79        DEBUG_LLDATA      = 0x00100, /* sent/received LL data */
  80        DEBUG_DRIVER      = 0x00400, /* driver structure */
  81        DEBUG_HDLC        = 0x00800, /* M10x HDLC processing */
  82        DEBUG_WRITE       = 0x01000, /* M105 data write */
  83        DEBUG_TRANSCMD    = 0x02000, /* AT-COMMANDS+RESPONSES */
  84        DEBUG_MCMD        = 0x04000, /* COMMANDS THAT ARE SENT VERY OFTEN */
  85        DEBUG_INIT        = 0x08000, /* (de)allocation+initialization of data
  86                                        structures */
  87        DEBUG_SUSPEND     = 0x10000, /* suspend/resume processing */
  88        DEBUG_OUTPUT      = 0x20000, /* output to device */
  89        DEBUG_ISO         = 0x40000, /* isochronous transfers */
  90        DEBUG_IF          = 0x80000, /* character device operations */
  91        DEBUG_USBREQ      = 0x100000, /* USB communication (except payload
  92                                         data) */
  93        DEBUG_LOCKCMD     = 0x200000, /* AT commands and responses when
  94                                         MS_LOCKED */
  95
  96        DEBUG_ANY         = 0x3fffff, /* print message if any of the others is
  97                                         activated */
  98};
  99
 100/* Kernel message macros for situations where dev_printk and friends cannot be
 101 * used for lack of reliable access to a device structure.
 102 * linux/usb.h already contains these but in an obsolete form which clutters
 103 * the log needlessly, and according to the USB maintainer those should be
 104 * removed rather than fixed anyway.
 105 */
 106#undef err
 107#undef info
 108#undef warn
 109
 110#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \
 111        format "\n" , ## arg)
 112#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \
 113        format "\n" , ## arg)
 114#define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \
 115        format "\n" , ## arg)
 116
 117#ifdef CONFIG_GIGASET_DEBUG
 118
 119#define gig_dbg(level, format, arg...) \
 120        do { \
 121                if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \
 122                        printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \
 123                               ## arg); \
 124        } while (0)
 125#define DEBUG_DEFAULT (DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ)
 126
 127#else
 128
 129#define gig_dbg(level, format, arg...) do {} while (0)
 130#define DEBUG_DEFAULT 0
 131
 132#endif
 133
 134void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
 135                        size_t len, const unsigned char *buf);
 136
 137/* connection state */
 138#define ZSAU_NONE                       0
 139#define ZSAU_DISCONNECT_IND             4
 140#define ZSAU_OUTGOING_CALL_PROCEEDING   1
 141#define ZSAU_PROCEEDING                 1
 142#define ZSAU_CALL_DELIVERED             2
 143#define ZSAU_ACTIVE                     3
 144#define ZSAU_NULL                       5
 145#define ZSAU_DISCONNECT_REQ             6
 146#define ZSAU_UNKNOWN                    -1
 147
 148/* USB control transfer requests */
 149#define OUT_VENDOR_REQ  (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT)
 150#define IN_VENDOR_REQ   (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT)
 151
 152/* int-in-events 3070 */
 153#define HD_B1_FLOW_CONTROL              0x80
 154#define HD_B2_FLOW_CONTROL              0x81
 155#define HD_RECEIVEATDATA_ACK            (0x35)          // 3070
 156                                                // att: HD_RECEIVE>>AT<<DATA_ACK
 157#define HD_READY_SEND_ATDATA            (0x36)          // 3070
 158#define HD_OPEN_ATCHANNEL_ACK           (0x37)          // 3070
 159#define HD_CLOSE_ATCHANNEL_ACK          (0x38)          // 3070
 160#define HD_DEVICE_INIT_OK               (0x11)          // ISurf USB + 3070
 161#define HD_OPEN_B1CHANNEL_ACK           (0x51)          // ISurf USB + 3070
 162#define HD_OPEN_B2CHANNEL_ACK           (0x52)          // ISurf USB + 3070
 163#define HD_CLOSE_B1CHANNEL_ACK          (0x53)          // ISurf USB + 3070
 164#define HD_CLOSE_B2CHANNEL_ACK          (0x54)          // ISurf USB + 3070
 165//       Powermangment
 166#define HD_SUSPEND_END                  (0x61)          // ISurf USB
 167//   Configuration
 168#define HD_RESET_INTERRUPT_PIPE_ACK     (0xFF)          // ISurf USB + 3070
 169
 170/* control requests 3070 */
 171#define HD_OPEN_B1CHANNEL               (0x23)          // ISurf USB + 3070
 172#define HD_CLOSE_B1CHANNEL              (0x24)          // ISurf USB + 3070
 173#define HD_OPEN_B2CHANNEL               (0x25)          // ISurf USB + 3070
 174#define HD_CLOSE_B2CHANNEL              (0x26)          // ISurf USB + 3070
 175#define HD_RESET_INTERRUPT_PIPE         (0x27)          // ISurf USB + 3070
 176#define HD_DEVICE_INIT_ACK              (0x34)          // ISurf USB + 3070
 177#define HD_WRITE_ATMESSAGE              (0x12)          // 3070
 178#define HD_READ_ATMESSAGE               (0x13)          // 3070
 179#define HD_OPEN_ATCHANNEL               (0x28)          // 3070
 180#define HD_CLOSE_ATCHANNEL              (0x29)          // 3070
 181
 182/* number of B channels supported by base driver */
 183#define BAS_CHANNELS    2
 184
 185/* USB frames for isochronous transfer */
 186#define BAS_FRAMETIME   1       /* number of milliseconds between frames */
 187#define BAS_NUMFRAMES   8       /* number of frames per URB */
 188#define BAS_MAXFRAME    16      /* allocated bytes per frame */
 189#define BAS_NORMFRAME   8       /* send size without flow control */
 190#define BAS_HIGHFRAME   10      /* "    "    with positive flow control */
 191#define BAS_LOWFRAME    5       /* "    "    with negative flow control */
 192#define BAS_CORRFRAMES  4       /* flow control multiplicator */
 193
 194#define BAS_INBUFSIZE   (BAS_MAXFRAME * BAS_NUMFRAMES)
 195                                        /* size of isoc in buf per URB */
 196#define BAS_OUTBUFSIZE  4096            /* size of common isoc out buffer */
 197#define BAS_OUTBUFPAD   BAS_MAXFRAME    /* size of pad area for isoc out buf */
 198
 199#define BAS_INURBS      3
 200#define BAS_OUTURBS     3
 201
 202/* variable commands in struct bc_state */
 203#define AT_ISO          0
 204#define AT_DIAL         1
 205#define AT_MSN          2
 206#define AT_BC           3
 207#define AT_PROTO        4
 208#define AT_TYPE         5
 209#define AT_HLC          6
 210#define AT_NUM          7
 211
 212/* variables in struct at_state_t */
 213#define VAR_ZSAU        0
 214#define VAR_ZDLE        1
 215#define VAR_ZVLS        2
 216#define VAR_ZCTP        3
 217#define VAR_NUM         4
 218
 219#define STR_NMBR        0
 220#define STR_ZCPN        1
 221#define STR_ZCON        2
 222#define STR_ZBC         3
 223#define STR_ZHLC        4
 224#define STR_NUM         5
 225
 226#define EV_TIMEOUT      -105
 227#define EV_IF_VER       -106
 228#define EV_PROC_CIDMODE -107
 229#define EV_SHUTDOWN     -108
 230#define EV_START        -110
 231#define EV_STOP         -111
 232#define EV_IF_LOCK      -112
 233#define EV_PROTO_L2     -113
 234#define EV_ACCEPT       -114
 235#define EV_DIAL         -115
 236#define EV_HUP          -116
 237#define EV_BC_OPEN      -117
 238#define EV_BC_CLOSED    -118
 239
 240/* input state */
 241#define INS_command     0x0001
 242#define INS_DLE_char    0x0002
 243#define INS_byte_stuff  0x0004
 244#define INS_have_data   0x0008
 245#define INS_skip_frame  0x0010
 246#define INS_DLE_command 0x0020
 247#define INS_flag_hunt   0x0040
 248
 249/* channel state */
 250#define CHS_D_UP        0x01
 251#define CHS_B_UP        0x02
 252#define CHS_NOTIFY_LL   0x04
 253
 254#define ICALL_REJECT    0
 255#define ICALL_ACCEPT    1
 256#define ICALL_IGNORE    2
 257
 258/* device state */
 259#define MS_UNINITIALIZED        0
 260#define MS_INIT                 1
 261#define MS_LOCKED               2
 262#define MS_SHUTDOWN             3
 263#define MS_RECOVER              4
 264#define MS_READY                5
 265
 266/* mode */
 267#define M_UNKNOWN       0
 268#define M_CONFIG        1
 269#define M_UNIMODEM      2
 270#define M_CID           3
 271
 272/* start mode */
 273#define SM_LOCKED       0
 274#define SM_ISDN         1 /* default */
 275
 276struct gigaset_ops;
 277struct gigaset_driver;
 278
 279struct usb_cardstate;
 280struct ser_cardstate;
 281struct bas_cardstate;
 282
 283struct bc_state;
 284struct usb_bc_state;
 285struct ser_bc_state;
 286struct bas_bc_state;
 287
 288struct reply_t {
 289        int     resp_code;      /* RSP_XXXX */
 290        int     min_ConState;   /* <0 => ignore */
 291        int     max_ConState;   /* <0 => ignore */
 292        int     parameter;      /* e.g. ZSAU_XXXX <0: ignore*/
 293        int     new_ConState;   /* <0 => ignore */
 294        int     timeout;        /* >0 => *HZ; <=0 => TOUT_XXXX*/
 295        int     action[MAXACT]; /* ACT_XXXX */
 296        char    *command;       /* NULL==none */
 297};
 298
 299extern struct reply_t gigaset_tab_cid_m10x[];
 300extern struct reply_t gigaset_tab_nocid_m10x[];
 301
 302struct inbuf_t {
 303        unsigned char           *rcvbuf;        /* usb-gigaset receive buffer */
 304        struct bc_state         *bcs;
 305        struct cardstate        *cs;
 306        int                     inputstate;
 307        int                     head, tail;
 308        unsigned char           data[RBUFSIZE];
 309};
 310
 311/* isochronous write buffer structure
 312 * circular buffer with pad area for extraction of complete USB frames
 313 * - data[read..nextread-1] is valid data already submitted to the USB subsystem
 314 * - data[nextread..write-1] is valid data yet to be sent
 315 * - data[write] is the next byte to write to
 316 *   - in byte-oriented L2 procotols, it is completely free
 317 *   - in bit-oriented L2 procotols, it may contain a partial byte of valid data
 318 * - data[write+1..read-1] is free
 319 * - wbits is the number of valid data bits in data[write], starting at the LSB
 320 * - writesem is the semaphore for writing to the buffer:
 321 *   if writesem <= 0, data[write..read-1] is currently being written to
 322 * - idle contains the byte value to repeat when the end of valid data is
 323 *   reached; if nextread==write (buffer contains no data to send), either the
 324 *   BAS_OUTBUFPAD bytes immediately before data[write] (if
 325 *   write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD)
 326 *   are also filled with that value
 327 */
 328struct isowbuf_t {
 329        int             read;
 330        int             nextread;
 331        int             write;
 332        atomic_t        writesem;
 333        int             wbits;
 334        unsigned char   data[BAS_OUTBUFSIZE + BAS_OUTBUFPAD];
 335        unsigned char   idle;
 336};
 337
 338/* isochronous write URB context structure
 339 * data to be stored along with the URB and retrieved when it is returned
 340 * as completed by the USB subsystem
 341 * - urb: pointer to the URB itself
 342 * - bcs: pointer to the B Channel control structure
 343 * - limit: end of write buffer area covered by this URB
 344 * - status: URB completion status
 345 */
 346struct isow_urbctx_t {
 347        struct urb *urb;
 348        struct bc_state *bcs;
 349        int limit;
 350        int status;
 351};
 352
 353/* AT state structure
 354 * data associated with the state of an ISDN connection, whether or not
 355 * it is currently assigned a B channel
 356 */
 357struct at_state_t {
 358        struct list_head        list;
 359        int                     waiting;
 360        int                     getstring;
 361        unsigned                timer_index;
 362        unsigned long           timer_expires;
 363        int                     timer_active;
 364        unsigned int            ConState;       /* State of connection */
 365        struct reply_t          *replystruct;
 366        int                     cid;
 367        int                     int_var[VAR_NUM];       /* see VAR_XXXX */
 368        char                    *str_var[STR_NUM];      /* see STR_XXXX */
 369        unsigned                pending_commands;       /* see PC_XXXX */
 370        unsigned                seq_index;
 371
 372        struct cardstate        *cs;
 373        struct bc_state         *bcs;
 374};
 375
 376struct resp_type_t {
 377        unsigned char   *response;
 378        int             resp_code;      /* RSP_XXXX */
 379        int             type;           /* RT_XXXX */
 380};
 381
 382struct event_t {
 383        int type;
 384        void *ptr, *arg;
 385        int parameter;
 386        int cid;
 387        struct at_state_t *at_state;
 388};
 389
 390/* This buffer holds all information about the used B-Channel */
 391struct bc_state {
 392        struct sk_buff *tx_skb;         /* Current transfer buffer to modem */
 393        struct sk_buff_head squeue;     /* B-Channel send Queue */
 394
 395        /* Variables for debugging .. */
 396        int corrupted;                  /* Counter for corrupted packages */
 397        int trans_down;                 /* Counter of packages (downstream) */
 398        int trans_up;                   /* Counter of packages (upstream) */
 399
 400        struct at_state_t at_state;
 401        unsigned long rcvbytes;
 402
 403        __u16 fcs;
 404        struct sk_buff *skb;
 405        int inputstate;                 /* see INS_XXXX */
 406
 407        int channel;
 408
 409        struct cardstate *cs;
 410
 411        unsigned chstate;               /* bitmap (CHS_*) */
 412        int ignore;
 413        unsigned proto2;                /* Layer 2 protocol (ISDN_PROTO_L2_*) */
 414        char *commands[AT_NUM];         /* see AT_XXXX */
 415
 416#ifdef CONFIG_GIGASET_DEBUG
 417        int emptycount;
 418#endif
 419        int busy;
 420        int use_count;
 421
 422        /* private data of hardware drivers */
 423        union {
 424                struct ser_bc_state *ser;       /* serial hardware driver */
 425                struct usb_bc_state *usb;       /* usb hardware driver (m105) */
 426                struct bas_bc_state *bas;       /* usb hardware driver (base) */
 427        } hw;
 428};
 429
 430struct cardstate {
 431        struct gigaset_driver *driver;
 432        unsigned minor_index;
 433        struct device *dev;
 434        struct device *tty_dev;
 435        unsigned flags;
 436
 437        const struct gigaset_ops *ops;
 438
 439        /* Stuff to handle communication */
 440        wait_queue_head_t waitqueue;
 441        int waiting;
 442        int mode;                       /* see M_XXXX */
 443        int mstate;                     /* Modem state: see MS_XXXX */
 444                                        /* only changed by the event layer */
 445        int cmd_result;
 446
 447        int channels;
 448        struct bc_state *bcs;           /* Array of struct bc_state */
 449
 450        int onechannel;                 /* data and commands transmitted in one
 451                                           stream (M10x) */
 452
 453        spinlock_t lock;
 454        struct at_state_t at_state;     /* at_state_t for cid == 0 */
 455        struct list_head temp_at_states;/* list of temporary "struct
 456                                           at_state_t"s without B channel */
 457
 458        struct inbuf_t *inbuf;
 459
 460        struct cmdbuf_t *cmdbuf, *lastcmdbuf;
 461        spinlock_t cmdlock;
 462        unsigned curlen, cmdbytes;
 463
 464        unsigned open_count;
 465        struct tty_struct *tty;
 466        struct tasklet_struct if_wake_tasklet;
 467        unsigned control_state;
 468
 469        unsigned fwver[4];
 470        int gotfwver;
 471
 472        unsigned running;               /* !=0 if events are handled */
 473        unsigned connected;             /* !=0 if hardware is connected */
 474        unsigned isdn_up;               /* !=0 after ISDN_STAT_RUN */
 475
 476        unsigned cidmode;
 477
 478        int myid;                       /* id for communication with LL */
 479        isdn_if iif;
 480
 481        struct reply_t *tabnocid;
 482        struct reply_t *tabcid;
 483        int cs_init;
 484        int ignoreframes;               /* frames to ignore after setting up the
 485                                           B channel */
 486        struct mutex mutex;             /* locks this structure:
 487                                         *   connected is not changed,
 488                                         *   hardware_up is not changed,
 489                                         *   MState is not changed to or from
 490                                         *   MS_LOCKED */
 491
 492        struct timer_list timer;
 493        int retry_count;
 494        int dle;                        /* !=0 if modem commands/responses are
 495                                           dle encoded */
 496        int cur_at_seq;                 /* sequence of AT commands being
 497                                           processed */
 498        int curchannel;                 /* channel those commands are meant
 499                                           for */
 500        int commands_pending;           /* flag(s) in xxx.commands_pending have
 501                                           been set */
 502        struct tasklet_struct event_tasklet;
 503                                        /* tasklet for serializing AT commands.
 504                                         * Scheduled
 505                                         *   -> for modem reponses (and
 506                                         *      incoming data for M10x)
 507                                         *   -> on timeout
 508                                         *   -> after setting bits in
 509                                         *      xxx.at_state.pending_command
 510                                         *      (e.g. command from LL) */
 511        struct tasklet_struct write_tasklet;
 512                                        /* tasklet for serial output
 513                                         * (not used in base driver) */
 514
 515        /* event queue */
 516        struct event_t events[MAX_EVENTS];
 517        unsigned ev_tail, ev_head;
 518        spinlock_t ev_lock;
 519
 520        /* current modem response */
 521        unsigned char respdata[MAX_RESP_SIZE];
 522        unsigned cbytes;
 523
 524        /* private data of hardware drivers */
 525        union {
 526                struct usb_cardstate *usb; /* USB hardware driver (m105) */
 527                struct ser_cardstate *ser; /* serial hardware driver */
 528                struct bas_cardstate *bas; /* USB hardware driver (base) */
 529        } hw;
 530};
 531
 532struct gigaset_driver {
 533        struct list_head list;
 534        spinlock_t lock;                /* locks minor tables and blocked */
 535        struct tty_driver *tty;
 536        unsigned have_tty;
 537        unsigned minor;
 538        unsigned minors;
 539        struct cardstate *cs;
 540        int blocked;
 541
 542        const struct gigaset_ops *ops;
 543        struct module *owner;
 544};
 545
 546struct cmdbuf_t {
 547        struct cmdbuf_t *next, *prev;
 548        int len, offset;
 549        struct tasklet_struct *wake_tasklet;
 550        unsigned char buf[0];
 551};
 552
 553struct bas_bc_state {
 554        /* isochronous output state */
 555        int             running;
 556        atomic_t        corrbytes;
 557        spinlock_t      isooutlock;
 558        struct isow_urbctx_t    isoouturbs[BAS_OUTURBS];
 559        struct isow_urbctx_t    *isooutdone, *isooutfree, *isooutovfl;
 560        struct isowbuf_t        *isooutbuf;
 561        unsigned numsub;                /* submitted URB counter
 562                                           (for diagnostic messages only) */
 563        struct tasklet_struct   sent_tasklet;
 564
 565        /* isochronous input state */
 566        spinlock_t isoinlock;
 567        struct urb *isoinurbs[BAS_INURBS];
 568        unsigned char isoinbuf[BAS_INBUFSIZE * BAS_INURBS];
 569        struct urb *isoindone;          /* completed isoc read URB */
 570        int isoinstatus;                /* status of completed URB */
 571        int loststatus;                 /* status of dropped URB */
 572        unsigned isoinlost;             /* number of bytes lost */
 573        /* state of bit unstuffing algorithm
 574           (in addition to BC_state.inputstate) */
 575        unsigned seqlen;                /* number of '1' bits not yet
 576                                           unstuffed */
 577        unsigned inbyte, inbits;        /* collected bits for next byte */
 578        /* statistics */
 579        unsigned goodbytes;             /* bytes correctly received */
 580        unsigned alignerrs;             /* frames with incomplete byte at end */
 581        unsigned fcserrs;               /* FCS errors */
 582        unsigned frameerrs;             /* framing errors */
 583        unsigned giants;                /* long frames */
 584        unsigned runts;                 /* short frames */
 585        unsigned aborts;                /* HDLC aborts */
 586        unsigned shared0s;              /* '0' bits shared between flags */
 587        unsigned stolen0s;              /* '0' stuff bits also serving as
 588                                           leading flag bits */
 589        struct tasklet_struct rcvd_tasklet;
 590};
 591
 592struct gigaset_ops {
 593        /* Called from ev-layer.c/interface.c for sending AT commands to the
 594           device */
 595        int (*write_cmd)(struct cardstate *cs,
 596                         const unsigned char *buf, int len,
 597                         struct tasklet_struct *wake_tasklet);
 598
 599        /* Called from interface.c for additional device control */
 600        int (*write_room)(struct cardstate *cs);
 601        int (*chars_in_buffer)(struct cardstate *cs);
 602        int (*brkchars)(struct cardstate *cs, const unsigned char buf[6]);
 603
 604        /* Called from ev-layer.c after setting up connection
 605         * Should call gigaset_bchannel_up(), when finished. */
 606        int (*init_bchannel)(struct bc_state *bcs);
 607
 608        /* Called from ev-layer.c after hanging up
 609         * Should call gigaset_bchannel_down(), when finished. */
 610        int (*close_bchannel)(struct bc_state *bcs);
 611
 612        /* Called by gigaset_initcs() for setting up bcs->hw.xxx */
 613        int (*initbcshw)(struct bc_state *bcs);
 614
 615        /* Called by gigaset_freecs() for freeing bcs->hw.xxx */
 616        int (*freebcshw)(struct bc_state *bcs);
 617
 618        /* Called by gigaset_bchannel_down() for resetting bcs->hw.xxx */
 619        void (*reinitbcshw)(struct bc_state *bcs);
 620
 621        /* Called by gigaset_initcs() for setting up cs->hw.xxx */
 622        int (*initcshw)(struct cardstate *cs);
 623
 624        /* Called by gigaset_freecs() for freeing cs->hw.xxx */
 625        void (*freecshw)(struct cardstate *cs);
 626
 627        /* Called from common.c/interface.c for additional serial port
 628           control */
 629        int (*set_modem_ctrl)(struct cardstate *cs, unsigned old_state,
 630                              unsigned new_state);
 631        int (*baud_rate)(struct cardstate *cs, unsigned cflag);
 632        int (*set_line_ctrl)(struct cardstate *cs, unsigned cflag);
 633
 634        /* Called from i4l.c to put an skb into the send-queue. */
 635        int (*send_skb)(struct bc_state *bcs, struct sk_buff *skb);
 636
 637        /* Called from ev-layer.c to process a block of data
 638         * received through the common/control channel. */
 639        void (*handle_input)(struct inbuf_t *inbuf);
 640
 641};
 642
 643/* = Common structures and definitions ======================================= */
 644
 645/* Parser states for DLE-Event:
 646 * <DLE-EVENT>: <DLE_FLAG> "X" <EVENT> <DLE_FLAG> "."
 647 * <DLE_FLAG>:  0x10
 648 * <EVENT>:     ((a-z)* | (A-Z)* | (0-10)*)+
 649 */
 650#define DLE_FLAG        0x10
 651
 652/* ===========================================================================
 653 *  Functions implemented in asyncdata.c
 654 */
 655
 656/* Called from i4l.c to put an skb into the send-queue.
 657 * After sending gigaset_skb_sent() should be called. */
 658int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb);
 659
 660/* Called from ev-layer.c to process a block of data
 661 * received through the common/control channel. */
 662void gigaset_m10x_input(struct inbuf_t *inbuf);
 663
 664/* ===========================================================================
 665 *  Functions implemented in isocdata.c
 666 */
 667
 668/* Called from i4l.c to put an skb into the send-queue.
 669 * After sending gigaset_skb_sent() should be called. */
 670int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb);
 671
 672/* Called from ev-layer.c to process a block of data
 673 * received through the common/control channel. */
 674void gigaset_isoc_input(struct inbuf_t *inbuf);
 675
 676/* Called from bas-gigaset.c to process a block of data
 677 * received through the isochronous channel */
 678void gigaset_isoc_receive(unsigned char *src, unsigned count,
 679                          struct bc_state *bcs);
 680
 681/* Called from bas-gigaset.c to put a block of data
 682 * into the isochronous output buffer */
 683int gigaset_isoc_buildframe(struct bc_state *bcs, unsigned char *in, int len);
 684
 685/* Called from bas-gigaset.c to initialize the isochronous output buffer */
 686void gigaset_isowbuf_init(struct isowbuf_t *iwb, unsigned char idle);
 687
 688/* Called from bas-gigaset.c to retrieve a block of bytes for sending */
 689int gigaset_isowbuf_getbytes(struct isowbuf_t *iwb, int size);
 690
 691/* ===========================================================================
 692 *  Functions implemented in i4l.c/gigaset.h
 693 */
 694
 695/* Called by gigaset_initcs() for setting up with the isdn4linux subsystem */
 696int gigaset_register_to_LL(struct cardstate *cs, const char *isdnid);
 697
 698/* Called from xxx-gigaset.c to indicate completion of sending an skb */
 699void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb);
 700
 701/* Called from common.c/ev-layer.c to indicate events relevant to the LL */
 702int gigaset_isdn_icall(struct at_state_t *at_state);
 703int gigaset_isdn_setup_accept(struct at_state_t *at_state);
 704int gigaset_isdn_setup_dial(struct at_state_t *at_state, void *data);
 705
 706void gigaset_i4l_cmd(struct cardstate *cs, int cmd);
 707void gigaset_i4l_channel_cmd(struct bc_state *bcs, int cmd);
 708
 709
 710static inline void gigaset_isdn_rcv_err(struct bc_state *bcs)
 711{
 712        isdn_ctrl response;
 713
 714        /* error -> LL */
 715        gig_dbg(DEBUG_CMD, "sending L1ERR");
 716        response.driver = bcs->cs->myid;
 717        response.command = ISDN_STAT_L1ERR;
 718        response.arg = bcs->channel;
 719        response.parm.errcode = ISDN_STAT_L1ERR_RECV;
 720        bcs->cs->iif.statcallb(&response);
 721}
 722
 723/* ===========================================================================
 724 *  Functions implemented in ev-layer.c
 725 */
 726
 727/* tasklet called from common.c to process queued events */
 728void gigaset_handle_event(unsigned long data);
 729
 730/* called from isocdata.c / asyncdata.c
 731 * when a complete modem response line has been received */
 732void gigaset_handle_modem_response(struct cardstate *cs);
 733
 734/* ===========================================================================
 735 *  Functions implemented in proc.c
 736 */
 737
 738/* initialize sysfs for device */
 739void gigaset_init_dev_sysfs(struct cardstate *cs);
 740void gigaset_free_dev_sysfs(struct cardstate *cs);
 741
 742/* ===========================================================================
 743 *  Functions implemented in common.c/gigaset.h
 744 */
 745
 746void gigaset_bcs_reinit(struct bc_state *bcs);
 747void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs,
 748                     struct cardstate *cs, int cid);
 749int gigaset_get_channel(struct bc_state *bcs);
 750void gigaset_free_channel(struct bc_state *bcs);
 751int gigaset_get_channels(struct cardstate *cs);
 752void gigaset_free_channels(struct cardstate *cs);
 753void gigaset_block_channels(struct cardstate *cs);
 754
 755/* Allocate and initialize driver structure. */
 756struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
 757                                          const char *procname,
 758                                          const char *devname,
 759                                          const struct gigaset_ops *ops,
 760                                          struct module *owner);
 761
 762/* Deallocate driver structure. */
 763void gigaset_freedriver(struct gigaset_driver *drv);
 764void gigaset_debugdrivers(void);
 765struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty);
 766struct cardstate *gigaset_get_cs_by_id(int id);
 767void gigaset_blockdriver(struct gigaset_driver *drv);
 768
 769/* Allocate and initialize card state. Calls hardware dependent
 770   gigaset_init[b]cs(). */
 771struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
 772                                 int onechannel, int ignoreframes,
 773                                 int cidmode, const char *modulename);
 774
 775/* Free card state. Calls hardware dependent gigaset_free[b]cs(). */
 776void gigaset_freecs(struct cardstate *cs);
 777
 778/* Tell common.c that hardware and driver are ready. */
 779int gigaset_start(struct cardstate *cs);
 780
 781/* Tell common.c that the device is not present any more. */
 782void gigaset_stop(struct cardstate *cs);
 783
 784/* Tell common.c that the driver is being unloaded. */
 785int gigaset_shutdown(struct cardstate *cs);
 786
 787/* Tell common.c that an skb has been sent. */
 788void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb);
 789
 790/* Append event to the queue.
 791 * Returns NULL on failure or a pointer to the event on success.
 792 * ptr must be kmalloc()ed (and not be freed by the caller).
 793 */
 794struct event_t *gigaset_add_event(struct cardstate *cs,
 795                                  struct at_state_t *at_state, int type,
 796                                  void *ptr, int parameter, void *arg);
 797
 798/* Called on CONFIG1 command from frontend. */
 799int gigaset_enterconfigmode(struct cardstate *cs); //0: success <0: errorcode
 800
 801/* cs->lock must not be locked */
 802static inline void gigaset_schedule_event(struct cardstate *cs)
 803{
 804        unsigned long flags;
 805        spin_lock_irqsave(&cs->lock, flags);
 806        if (cs->running)
 807                tasklet_schedule(&cs->event_tasklet);
 808        spin_unlock_irqrestore(&cs->lock, flags);
 809}
 810
 811/* Tell common.c that B channel has been closed. */
 812/* cs->lock must not be locked */
 813static inline void gigaset_bchannel_down(struct bc_state *bcs)
 814{
 815        gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL);
 816
 817        gig_dbg(DEBUG_CMD, "scheduling BC_CLOSED");
 818        gigaset_schedule_event(bcs->cs);
 819}
 820
 821/* Tell common.c that B channel has been opened. */
 822/* cs->lock must not be locked */
 823static inline void gigaset_bchannel_up(struct bc_state *bcs)
 824{
 825        gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL);
 826
 827        gig_dbg(DEBUG_CMD, "scheduling BC_OPEN");
 828        gigaset_schedule_event(bcs->cs);
 829}
 830
 831/* handling routines for sk_buff */
 832/* ============================= */
 833
 834/* pass received skb to LL
 835 * Warning: skb must not be accessed anymore!
 836 */
 837static inline void gigaset_rcv_skb(struct sk_buff *skb,
 838                                   struct cardstate *cs,
 839                                   struct bc_state *bcs)
 840{
 841        cs->iif.rcvcallb_skb(cs->myid, bcs->channel, skb);
 842        bcs->trans_down++;
 843}
 844
 845/* handle reception of corrupted skb
 846 * Warning: skb must not be accessed anymore!
 847 */
 848static inline void gigaset_rcv_error(struct sk_buff *procskb,
 849                                     struct cardstate *cs,
 850                                     struct bc_state *bcs)
 851{
 852        if (procskb)
 853                dev_kfree_skb(procskb);
 854
 855        if (bcs->ignore)
 856                --bcs->ignore;
 857        else {
 858                ++bcs->corrupted;
 859                gigaset_isdn_rcv_err(bcs);
 860        }
 861}
 862
 863/* append received bytes to inbuf */
 864int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src,
 865                       unsigned numbytes);
 866
 867/* ===========================================================================
 868 *  Functions implemented in interface.c
 869 */
 870
 871/* initialize interface */
 872void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname,
 873                           const char *devname);
 874/* release interface */
 875void gigaset_if_freedriver(struct gigaset_driver *drv);
 876/* add minor */
 877void gigaset_if_init(struct cardstate *cs);
 878/* remove minor */
 879void gigaset_if_free(struct cardstate *cs);
 880/* device received data */
 881void gigaset_if_receive(struct cardstate *cs,
 882                        unsigned char *buffer, size_t len);
 883
 884#endif
 885
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.