gigaset.h
来自「LINUX 2.6.17.4的源码」· C头文件 代码 · 共 906 行 · 第 1/2 页
H
906 行
/* * Siemens Gigaset 307x driver * Common header file for all connection variants * * Written by Stefan Eilers * and Hansjoerg Lipp <hjlipp@web.de> * * ===================================================================== * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * ===================================================================== */#ifndef GIGASET_H#define GIGASET_H#include <linux/config.h>#include <linux/kernel.h>#include <linux/compiler.h>#include <linux/types.h>#include <linux/spinlock.h>#include <linux/isdnif.h>#include <linux/usb.h>#include <linux/skbuff.h>#include <linux/netdevice.h>#include <linux/ppp_defs.h>#include <linux/timer.h>#include <linux/interrupt.h>#include <linux/tty.h>#include <linux/tty_driver.h>#include <linux/list.h>#include <asm/atomic.h>#define GIG_VERSION {0,5,0,0}#define GIG_COMPAT {0,4,0,0}#define MAX_REC_PARAMS 10 /* Max. number of params in response string */#define MAX_RESP_SIZE 512 /* Max. size of a response string */#define HW_HDR_LEN 2 /* Header size used to store ack info */#define MAX_EVENTS 64 /* size of event queue */#define RBUFSIZE 8192#define SBUFSIZE 4096 /* sk_buff payload size */#define TRANSBUFSIZE 768 /* bytes per skb for transparent receive */#define MAX_BUF_SIZE (SBUFSIZE - 2) /* Max. size of a data packet from LL *//* compile time options */#define GIG_MAJOR 0#define GIG_MAYINITONDIAL#define GIG_RETRYCID#define GIG_X75#define GIG_TICK 100 /* in milliseconds *//* timeout values (unit: 1 sec) */#define INIT_TIMEOUT 1/* timeout values (unit: 0.1 sec) */#define RING_TIMEOUT 3 /* for additional parameters to RING */#define BAS_TIMEOUT 20 /* for response to Base USB ops */#define ATRDY_TIMEOUT 3 /* for HD_READY_SEND_ATDATA */#define BAS_RETRY 3 /* max. retries for base USB ops */#define MAXACT 3extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) *//* any combination of these can be given with the 'debug=' parameter to insmod, * e.g. 'insmod usb_gigaset.o debug=0x2c' will set DEBUG_OPEN, DEBUG_CMD and * DEBUG_INTR. */enum debuglevel { DEBUG_REG = 0x0002, /* serial port I/O register operations */ DEBUG_OPEN = 0x0004, /* open/close serial port */ DEBUG_INTR = 0x0008, /* interrupt processing */ DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on interrupt requests, not available as run-time option */ DEBUG_CMD = 0x00020, /* sent/received LL commands */ DEBUG_STREAM = 0x00040, /* application data stream I/O events */ DEBUG_STREAM_DUMP = 0x00080, /* application data stream content */ DEBUG_LLDATA = 0x00100, /* sent/received LL data */ DEBUG_INTR_0 = 0x00200, /* serial port interrupt processing */ DEBUG_DRIVER = 0x00400, /* driver structure */ DEBUG_HDLC = 0x00800, /* M10x HDLC processing */ DEBUG_WRITE = 0x01000, /* M105 data write */ DEBUG_TRANSCMD = 0x02000, /* AT-COMMANDS+RESPONSES */ DEBUG_MCMD = 0x04000, /* COMMANDS THAT ARE SENT VERY OFTEN */ DEBUG_INIT = 0x08000, /* (de)allocation+initialization of data structures */ DEBUG_LOCK = 0x10000, /* semaphore operations */ DEBUG_OUTPUT = 0x20000, /* output to device */ DEBUG_ISO = 0x40000, /* isochronous transfers */ DEBUG_IF = 0x80000, /* character device operations */ DEBUG_USBREQ = 0x100000, /* USB communication (except payload data) */ DEBUG_LOCKCMD = 0x200000, /* AT commands and responses when MS_LOCKED */ DEBUG_ANY = 0x3fffff, /* print message if any of the others is activated */};/* missing from linux/device.h ... */#ifndef dev_notice#define dev_notice(dev, format, arg...) \ dev_printk(KERN_NOTICE , dev , format , ## arg)#endif/* Kernel message macros for situations where dev_printk and friends cannot be * used for lack of reliable access to a device structure. * linux/usb.h already contains these but in an obsolete form which clutters * the log needlessly, and according to the USB maintainer those should be * removed rather than fixed anyway. */#undef err#undef info#undef warn#undef notice#define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ format "\n" , ## arg)#define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \ format "\n" , ## arg)#define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \ format "\n" , ## arg)#define notice(format, arg...) printk(KERN_NOTICE KBUILD_MODNAME ": " \ format "\n" , ## arg)#ifdef CONFIG_GIGASET_DEBUG#define gig_dbg(level, format, arg...) \ do { \ if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \ printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \ ## arg); \ } while (0)#define DEBUG_DEFAULT (DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ)#else#define gig_dbg(level, format, arg...) do {} while (0)#define DEBUG_DEFAULT 0#endifvoid gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, size_t len, const unsigned char *buf);/* connection state */#define ZSAU_NONE 0#define ZSAU_DISCONNECT_IND 4#define ZSAU_OUTGOING_CALL_PROCEEDING 1#define ZSAU_PROCEEDING 1#define ZSAU_CALL_DELIVERED 2#define ZSAU_ACTIVE 3#define ZSAU_NULL 5#define ZSAU_DISCONNECT_REQ 6#define ZSAU_UNKNOWN -1/* USB control transfer requests */#define OUT_VENDOR_REQ (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT)#define IN_VENDOR_REQ (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT)/* int-in-events 3070 */#define HD_B1_FLOW_CONTROL 0x80#define HD_B2_FLOW_CONTROL 0x81#define HD_RECEIVEATDATA_ACK (0x35) // 3070 // att: HD_RECEIVE>>AT<<DATA_ACK#define HD_READY_SEND_ATDATA (0x36) // 3070#define HD_OPEN_ATCHANNEL_ACK (0x37) // 3070#define HD_CLOSE_ATCHANNEL_ACK (0x38) // 3070#define HD_DEVICE_INIT_OK (0x11) // ISurf USB + 3070#define HD_OPEN_B1CHANNEL_ACK (0x51) // ISurf USB + 3070#define HD_OPEN_B2CHANNEL_ACK (0x52) // ISurf USB + 3070#define HD_CLOSE_B1CHANNEL_ACK (0x53) // ISurf USB + 3070#define HD_CLOSE_B2CHANNEL_ACK (0x54) // ISurf USB + 3070// Powermangment#define HD_SUSPEND_END (0x61) // ISurf USB// Configuration#define HD_RESET_INTERRUPT_PIPE_ACK (0xFF) // ISurf USB + 3070/* control requests 3070 */#define HD_OPEN_B1CHANNEL (0x23) // ISurf USB + 3070#define HD_CLOSE_B1CHANNEL (0x24) // ISurf USB + 3070#define HD_OPEN_B2CHANNEL (0x25) // ISurf USB + 3070#define HD_CLOSE_B2CHANNEL (0x26) // ISurf USB + 3070#define HD_RESET_INTERRUPT_PIPE (0x27) // ISurf USB + 3070#define HD_DEVICE_INIT_ACK (0x34) // ISurf USB + 3070#define HD_WRITE_ATMESSAGE (0x12) // 3070#define HD_READ_ATMESSAGE (0x13) // 3070#define HD_OPEN_ATCHANNEL (0x28) // 3070#define HD_CLOSE_ATCHANNEL (0x29) // 3070/* USB frames for isochronous transfer */#define BAS_FRAMETIME 1 /* number of milliseconds between frames */#define BAS_NUMFRAMES 8 /* number of frames per URB */#define BAS_MAXFRAME 16 /* allocated bytes per frame */#define BAS_NORMFRAME 8 /* send size without flow control */#define BAS_HIGHFRAME 10 /* " " with positive flow control */#define BAS_LOWFRAME 5 /* " " with negative flow control */#define BAS_CORRFRAMES 4 /* flow control multiplicator */#define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES) /* size of isoc in buf per URB */#define BAS_OUTBUFSIZE 4096 /* size of common isoc out buffer */#define BAS_OUTBUFPAD BAS_MAXFRAME /* size of pad area for isoc out buf */#define BAS_INURBS 3#define BAS_OUTURBS 3/* variable commands in struct bc_state */#define AT_ISO 0#define AT_DIAL 1#define AT_MSN 2#define AT_BC 3#define AT_PROTO 4#define AT_TYPE 5#define AT_HLC 6#define AT_NUM 7/* variables in struct at_state_t */#define VAR_ZSAU 0#define VAR_ZDLE 1#define VAR_ZVLS 2#define VAR_ZCTP 3#define VAR_NUM 4#define STR_NMBR 0#define STR_ZCPN 1#define STR_ZCON 2#define STR_ZBC 3#define STR_ZHLC 4#define STR_NUM 5#define EV_TIMEOUT -105#define EV_IF_VER -106#define EV_PROC_CIDMODE -107#define EV_SHUTDOWN -108#define EV_START -110#define EV_STOP -111#define EV_IF_LOCK -112#define EV_PROTO_L2 -113#define EV_ACCEPT -114#define EV_DIAL -115#define EV_HUP -116#define EV_BC_OPEN -117#define EV_BC_CLOSED -118/* input state */#define INS_command 0x0001#define INS_DLE_char 0x0002#define INS_byte_stuff 0x0004#define INS_have_data 0x0008#define INS_skip_frame 0x0010#define INS_DLE_command 0x0020#define INS_flag_hunt 0x0040/* channel state */#define CHS_D_UP 0x01#define CHS_B_UP 0x02#define CHS_NOTIFY_LL 0x04#define ICALL_REJECT 0#define ICALL_ACCEPT 1#define ICALL_IGNORE 2/* device state */#define MS_UNINITIALIZED 0#define MS_INIT 1#define MS_LOCKED 2#define MS_SHUTDOWN 3#define MS_RECOVER 4#define MS_READY 5/* mode */#define M_UNKNOWN 0#define M_CONFIG 1#define M_UNIMODEM 2#define M_CID 3/* start mode */#define SM_LOCKED 0#define SM_ISDN 1 /* default */struct gigaset_ops;struct gigaset_driver;struct usb_cardstate;struct ser_cardstate;struct bas_cardstate;struct bc_state;struct usb_bc_state;struct ser_bc_state;struct bas_bc_state;struct reply_t { int resp_code; /* RSP_XXXX */ int min_ConState; /* <0 => ignore */ int max_ConState; /* <0 => ignore */ int parameter; /* e.g. ZSAU_XXXX <0: ignore*/ int new_ConState; /* <0 => ignore */ int timeout; /* >0 => *HZ; <=0 => TOUT_XXXX*/ int action[MAXACT]; /* ACT_XXXX */ char *command; /* NULL==none */};extern struct reply_t gigaset_tab_cid_m10x[];extern struct reply_t gigaset_tab_nocid_m10x[];struct inbuf_t { unsigned char *rcvbuf; /* usb-gigaset receive buffer */ struct bc_state *bcs; struct cardstate *cs; int inputstate; atomic_t head, tail; unsigned char data[RBUFSIZE];};/* isochronous write buffer structure * circular buffer with pad area for extraction of complete USB frames * - data[read..nextread-1] is valid data already submitted to the USB subsystem * - data[nextread..write-1] is valid data yet to be sent * - data[write] is the next byte to write to * - in byte-oriented L2 procotols, it is completely free * - in bit-oriented L2 procotols, it may contain a partial byte of valid data * - data[write+1..read-1] is free * - wbits is the number of valid data bits in data[write], starting at the LSB * - writesem is the semaphore for writing to the buffer: * if writesem <= 0, data[write..read-1] is currently being written to * - idle contains the byte value to repeat when the end of valid data is * reached; if nextread==write (buffer contains no data to send), either the * BAS_OUTBUFPAD bytes immediately before data[write] (if * write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD) * are also filled with that value */struct isowbuf_t { atomic_t read; atomic_t nextread; atomic_t write; atomic_t writesem; int wbits; unsigned char data[BAS_OUTBUFSIZE + BAS_OUTBUFPAD]; unsigned char idle;};/* isochronous write URB context structure * data to be stored along with the URB and retrieved when it is returned * as completed by the USB subsystem * - urb: pointer to the URB itself * - bcs: pointer to the B Channel control structure * - limit: end of write buffer area covered by this URB */struct isow_urbctx_t { struct urb *urb; struct bc_state *bcs; int limit;};/* AT state structure * data associated with the state of an ISDN connection, whether or not * it is currently assigned a B channel */struct at_state_t { struct list_head list; int waiting; int getstring; unsigned timer_index; unsigned long timer_expires; int timer_active; unsigned int ConState; /* State of connection */ struct reply_t *replystruct; int cid; int int_var[VAR_NUM]; /* see VAR_XXXX */ char *str_var[STR_NUM]; /* see STR_XXXX */ unsigned pending_commands; /* see PC_XXXX */ unsigned seq_index; struct cardstate *cs; struct bc_state *bcs;};struct resp_type_t { unsigned char *response; int resp_code; /* RSP_XXXX */ int type; /* RT_XXXX */};struct event_t { int type; void *ptr, *arg; int parameter; int cid; struct at_state_t *at_state;};/* This buffer holds all information about the used B-Channel */struct bc_state { struct sk_buff *tx_skb; /* Current transfer buffer to modem */ struct sk_buff_head squeue; /* B-Channel send Queue */ /* Variables for debugging .. */ int corrupted; /* Counter for corrupted packages */ int trans_down; /* Counter of packages (downstream) */ int trans_up; /* Counter of packages (upstream) */ struct at_state_t at_state; unsigned long rcvbytes; __u16 fcs; struct sk_buff *skb; int inputstate; /* see INS_XXXX */ int channel; struct cardstate *cs; unsigned chstate; /* bitmap (CHS_*) */ int ignore; unsigned proto2; /* Layer 2 protocol (ISDN_PROTO_L2_*) */ char *commands[AT_NUM]; /* see AT_XXXX */#ifdef CONFIG_GIGASET_DEBUG int emptycount;#endif int busy; int use_count; /* private data of hardware drivers */ union { struct ser_bc_state *ser; /* serial hardware driver */ struct usb_bc_state *usb; /* usb hardware driver (m105) */ struct bas_bc_state *bas; /* usb hardware driver (base) */ } hw;};struct cardstate { struct gigaset_driver *driver; unsigned minor_index; struct device *dev; const struct gigaset_ops *ops; /* Stuff to handle communication */ wait_queue_head_t waitqueue; int waiting;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?