Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: hysdn_defs.h,v 1.5.6.3 2001/09/23 22:24:54 kai Exp $ |
| 2 | * |
| 3 | * Linux driver for HYSDN cards |
| 4 | * global definitions and exported vars and functions. |
| 5 | * |
| 6 | * Author Werner Cornelius (werner@titro.de) for Hypercope GmbH |
| 7 | * Copyright 1999 by Werner Cornelius (werner@titro.de) |
| 8 | * |
| 9 | * This software may be used and distributed according to the terms |
| 10 | * of the GNU General Public License, incorporated herein by reference. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #ifndef HYSDN_DEFS_H |
| 15 | #define HYSDN_DEFS_H |
| 16 | |
| 17 | #include <linux/config.h> |
| 18 | #include <linux/hysdn_if.h> |
| 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/workqueue.h> |
| 21 | #include <linux/skbuff.h> |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include "ince1pc.h" |
| 24 | |
| 25 | #ifdef CONFIG_HYSDN_CAPI |
| 26 | #include <linux/capi.h> |
| 27 | #include <linux/isdn/capicmd.h> |
| 28 | #include <linux/isdn/capiutil.h> |
| 29 | #include <linux/isdn/capilli.h> |
| 30 | |
| 31 | /***************************/ |
| 32 | /* CAPI-Profile values. */ |
| 33 | /***************************/ |
| 34 | |
| 35 | #define GLOBAL_OPTION_INTERNAL_CONTROLLER 0x0001 |
| 36 | #define GLOBAL_OPTION_EXTERNAL_CONTROLLER 0x0002 |
| 37 | #define GLOBAL_OPTION_HANDSET 0x0004 |
| 38 | #define GLOBAL_OPTION_DTMF 0x0008 |
| 39 | #define GLOBAL_OPTION_SUPPL_SERVICES 0x0010 |
| 40 | #define GLOBAL_OPTION_CHANNEL_ALLOCATION 0x0020 |
| 41 | #define GLOBAL_OPTION_B_CHANNEL_OPERATION 0x0040 |
| 42 | |
| 43 | #define B1_PROT_64KBIT_HDLC 0x0001 |
| 44 | #define B1_PROT_64KBIT_TRANSPARENT 0x0002 |
| 45 | #define B1_PROT_V110_ASYNCH 0x0004 |
| 46 | #define B1_PROT_V110_SYNCH 0x0008 |
| 47 | #define B1_PROT_T30 0x0010 |
| 48 | #define B1_PROT_64KBIT_INV_HDLC 0x0020 |
| 49 | #define B1_PROT_56KBIT_TRANSPARENT 0x0040 |
| 50 | |
| 51 | #define B2_PROT_ISO7776 0x0001 |
| 52 | #define B2_PROT_TRANSPARENT 0x0002 |
| 53 | #define B2_PROT_SDLC 0x0004 |
| 54 | #define B2_PROT_LAPD 0x0008 |
| 55 | #define B2_PROT_T30 0x0010 |
| 56 | #define B2_PROT_PPP 0x0020 |
| 57 | #define B2_PROT_TRANSPARENT_IGNORE_B1_FRAMING_ERRORS 0x0040 |
| 58 | |
| 59 | #define B3_PROT_TRANSPARENT 0x0001 |
| 60 | #define B3_PROT_T90NL 0x0002 |
| 61 | #define B3_PROT_ISO8208 0x0004 |
| 62 | #define B3_PROT_X25_DCE 0x0008 |
| 63 | #define B3_PROT_T30 0x0010 |
| 64 | #define B3_PROT_T30EXT 0x0020 |
| 65 | |
| 66 | #define HYSDN_MAXVERSION 8 |
| 67 | |
| 68 | /* Number of sendbuffers in CAPI-queue */ |
| 69 | #define HYSDN_MAX_CAPI_SKB 20 |
| 70 | |
| 71 | #endif /* CONFIG_HYSDN_CAPI*/ |
| 72 | |
| 73 | /************************************************/ |
| 74 | /* constants and bits for debugging/log outputs */ |
| 75 | /************************************************/ |
| 76 | #define LOG_MAX_LINELEN 120 |
| 77 | #define DEB_OUT_SYSLOG 0x80000000 /* output to syslog instead of proc fs */ |
| 78 | #define LOG_MEM_ERR 0x00000001 /* log memory errors like kmalloc failure */ |
| 79 | #define LOG_POF_OPEN 0x00000010 /* log pof open and close activities */ |
| 80 | #define LOG_POF_RECORD 0x00000020 /* log pof record parser */ |
| 81 | #define LOG_POF_WRITE 0x00000040 /* log detailed pof write operation */ |
| 82 | #define LOG_POF_CARD 0x00000080 /* log pof related card functions */ |
| 83 | #define LOG_CNF_LINE 0x00000100 /* all conf lines are put to procfs */ |
| 84 | #define LOG_CNF_DATA 0x00000200 /* non comment conf lines are shown with channel */ |
| 85 | #define LOG_CNF_MISC 0x00000400 /* additional conf line debug outputs */ |
| 86 | #define LOG_SCHED_ASYN 0x00001000 /* debug schedulers async tx routines */ |
| 87 | #define LOG_PROC_OPEN 0x00100000 /* open and close from procfs are logged */ |
| 88 | #define LOG_PROC_ALL 0x00200000 /* all actions from procfs are logged */ |
| 89 | #define LOG_NET_INIT 0x00010000 /* network init and deinit logging */ |
| 90 | |
| 91 | #define DEF_DEB_FLAGS 0x7fff000f /* everything is logged to procfs */ |
| 92 | |
| 93 | /**********************************/ |
| 94 | /* proc filesystem name constants */ |
| 95 | /**********************************/ |
| 96 | #define PROC_SUBDIR_NAME "hysdn" |
| 97 | #define PROC_CONF_BASENAME "cardconf" |
| 98 | #define PROC_LOG_BASENAME "cardlog" |
| 99 | |
| 100 | /***********************************/ |
| 101 | /* PCI 32 bit parms for IO and MEM */ |
| 102 | /***********************************/ |
| 103 | #define PCI_REG_PLX_MEM_BASE 0 |
| 104 | #define PCI_REG_PLX_IO_BASE 1 |
| 105 | #define PCI_REG_MEMORY_BASE 3 |
| 106 | |
| 107 | /**************/ |
| 108 | /* card types */ |
| 109 | /**************/ |
| 110 | #define BD_NONE 0U |
| 111 | #define BD_PERFORMANCE 1U |
| 112 | #define BD_VALUE 2U |
| 113 | #define BD_PCCARD 3U |
| 114 | #define BD_ERGO 4U |
| 115 | #define BD_METRO 5U |
| 116 | #define BD_CHAMP2 6U |
| 117 | #define BD_PLEXUS 7U |
| 118 | |
| 119 | /******************************************************/ |
| 120 | /* defined states for cards shown by reading cardconf */ |
| 121 | /******************************************************/ |
| 122 | #define CARD_STATE_UNUSED 0 /* never been used or booted */ |
| 123 | #define CARD_STATE_BOOTING 1 /* booting is in progress */ |
| 124 | #define CARD_STATE_BOOTERR 2 /* a previous boot was aborted */ |
| 125 | #define CARD_STATE_RUN 3 /* card is active */ |
| 126 | |
| 127 | /*******************************/ |
| 128 | /* defines for error_log_state */ |
| 129 | /*******************************/ |
| 130 | #define ERRLOG_STATE_OFF 0 /* error log is switched off, nothing to do */ |
| 131 | #define ERRLOG_STATE_ON 1 /* error log is switched on, wait for data */ |
| 132 | #define ERRLOG_STATE_START 2 /* start error logging */ |
| 133 | #define ERRLOG_STATE_STOP 3 /* stop error logging */ |
| 134 | |
| 135 | /*******************************/ |
| 136 | /* data structure for one card */ |
| 137 | /*******************************/ |
| 138 | typedef struct HYSDN_CARD { |
| 139 | |
| 140 | /* general variables for the cards */ |
| 141 | int myid; /* own driver card id */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 142 | unsigned char bus; /* pci bus the card is connected to */ |
| 143 | unsigned char devfn; /* slot+function bit encoded */ |
| 144 | unsigned short subsysid;/* PCI subsystem id */ |
| 145 | unsigned char brdtype; /* type of card */ |
| 146 | unsigned int bchans; /* number of available B-channels */ |
| 147 | unsigned int faxchans; /* number of available fax-channels */ |
| 148 | unsigned char mac_addr[6];/* MAC Address read from card */ |
| 149 | unsigned int irq; /* interrupt number */ |
| 150 | unsigned int iobase; /* IO-port base address */ |
| 151 | unsigned long plxbase; /* PLX memory base */ |
| 152 | unsigned long membase; /* DPRAM memory base */ |
| 153 | unsigned long memend; /* DPRAM memory end */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | void *dpram; /* mapped dpram */ |
| 155 | int state; /* actual state of card -> CARD_STATE_** */ |
| 156 | struct HYSDN_CARD *next; /* pointer to next card */ |
| 157 | |
| 158 | /* data areas for the /proc file system */ |
| 159 | void *proclog; /* pointer to proclog filesystem specific data */ |
| 160 | void *procconf; /* pointer to procconf filesystem specific data */ |
| 161 | |
| 162 | /* debugging and logging */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 163 | unsigned char err_log_state;/* actual error log state of the card */ |
| 164 | unsigned long debug_flags;/* tells what should be debugged and where */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | void (*set_errlog_state) (struct HYSDN_CARD *, int); |
| 166 | |
| 167 | /* interrupt handler + interrupt synchronisation */ |
| 168 | struct work_struct irq_queue; /* interrupt task queue */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 169 | unsigned char volatile irq_enabled;/* interrupt enabled if != 0 */ |
| 170 | unsigned char volatile hw_lock;/* hardware is currently locked -> no access */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | /* boot process */ |
| 173 | void *boot; /* pointer to boot private data */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 174 | int (*writebootimg) (struct HYSDN_CARD *, unsigned char *, unsigned long); |
| 175 | int (*writebootseq) (struct HYSDN_CARD *, unsigned char *, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | int (*waitpofready) (struct HYSDN_CARD *); |
| 177 | int (*testram) (struct HYSDN_CARD *); |
| 178 | |
| 179 | /* scheduler for data transfer (only async parts) */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 180 | unsigned char async_data[256];/* async data to be sent (normally for config) */ |
| 181 | unsigned short volatile async_len;/* length of data to sent */ |
| 182 | unsigned short volatile async_channel;/* channel number for async transfer */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | int volatile async_busy; /* flag != 0 sending in progress */ |
| 184 | int volatile net_tx_busy; /* a network packet tx is in progress */ |
| 185 | |
| 186 | /* network interface */ |
| 187 | void *netif; /* pointer to network structure */ |
| 188 | |
| 189 | /* init and deinit stopcard for booting, too */ |
| 190 | void (*stopcard) (struct HYSDN_CARD *); |
| 191 | void (*releasehardware) (struct HYSDN_CARD *); |
| 192 | #ifdef CONFIG_HYSDN_CAPI |
| 193 | struct hycapictrl_info { |
| 194 | char cardname[32]; |
| 195 | spinlock_t lock; |
| 196 | int versionlen; |
| 197 | char versionbuf[1024]; |
| 198 | char *version[HYSDN_MAXVERSION]; |
| 199 | |
| 200 | char infobuf[128]; /* for function procinfo */ |
| 201 | |
| 202 | struct HYSDN_CARD *card; |
| 203 | struct capi_ctr capi_ctrl; |
| 204 | struct sk_buff *skbs[HYSDN_MAX_CAPI_SKB]; |
| 205 | int in_idx, out_idx; /* indexes to buffer ring */ |
| 206 | int sk_count; /* number of buffers currently in ring */ |
| 207 | struct sk_buff *tx_skb; /* buffer for tx operation */ |
| 208 | |
| 209 | struct list_head ncci_head; |
| 210 | } *hyctrlinfo; |
| 211 | #endif /* CONFIG_HYSDN_CAPI */ |
| 212 | } hysdn_card; |
| 213 | |
| 214 | #ifdef CONFIG_HYSDN_CAPI |
| 215 | typedef struct hycapictrl_info hycapictrl_info; |
| 216 | #endif /* CONFIG_HYSDN_CAPI */ |
| 217 | |
| 218 | |
| 219 | /*****************/ |
| 220 | /* exported vars */ |
| 221 | /*****************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | extern hysdn_card *card_root; /* pointer to first card */ |
| 223 | |
| 224 | |
| 225 | |
| 226 | /*************************/ |
| 227 | /* im/exported functions */ |
| 228 | /*************************/ |
| 229 | extern char *hysdn_getrev(const char *); |
| 230 | |
| 231 | /* hysdn_procconf.c */ |
| 232 | extern int hysdn_procconf_init(void); /* init proc config filesys */ |
| 233 | extern void hysdn_procconf_release(void); /* deinit proc config filesys */ |
| 234 | |
| 235 | /* hysdn_proclog.c */ |
| 236 | extern int hysdn_proclog_init(hysdn_card *); /* init proc log entry */ |
| 237 | extern void hysdn_proclog_release(hysdn_card *); /* deinit proc log entry */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | extern void hysdn_addlog(hysdn_card *, char *,...); /* output data to log */ |
| 239 | extern void hysdn_card_errlog(hysdn_card *, tErrLogEntry *, int); /* output card log */ |
| 240 | |
| 241 | /* boardergo.c */ |
| 242 | extern int ergo_inithardware(hysdn_card * card); /* get hardware -> module init */ |
| 243 | |
| 244 | /* hysdn_boot.c */ |
| 245 | extern int pof_write_close(hysdn_card *); /* close proc file after writing pof */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 246 | extern int pof_write_open(hysdn_card *, unsigned char **); /* open proc file for writing pof */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | extern int pof_write_buffer(hysdn_card *, int); /* write boot data to card */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 248 | extern int EvalSysrTokData(hysdn_card *, unsigned char *, int); /* Check Sysready Token Data */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | |
| 250 | /* hysdn_sched.c */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 251 | extern int hysdn_sched_tx(hysdn_card *, unsigned char *, |
| 252 | unsigned short volatile *, unsigned short volatile *, |
| 253 | unsigned short); |
| 254 | extern int hysdn_sched_rx(hysdn_card *, unsigned char *, unsigned short, |
| 255 | unsigned short); |
| 256 | extern int hysdn_tx_cfgline(hysdn_card *, unsigned char *, |
| 257 | unsigned short); /* send one cfg line */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | |
| 259 | /* hysdn_net.c */ |
| 260 | extern unsigned int hynet_enable; |
| 261 | extern char *hysdn_net_revision; |
| 262 | extern int hysdn_net_create(hysdn_card *); /* create a new net device */ |
| 263 | extern int hysdn_net_release(hysdn_card *); /* delete the device */ |
| 264 | extern char *hysdn_net_getname(hysdn_card *); /* get name of net interface */ |
| 265 | extern void hysdn_tx_netack(hysdn_card *); /* acknowledge a packet tx */ |
| 266 | extern struct sk_buff *hysdn_tx_netget(hysdn_card *); /* get next network packet */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 267 | extern void hysdn_rx_netpkt(hysdn_card *, unsigned char *, |
| 268 | unsigned short); /* rxed packet from network */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | |
| 270 | #ifdef CONFIG_HYSDN_CAPI |
| 271 | extern unsigned int hycapi_enable; |
| 272 | extern int hycapi_capi_create(hysdn_card *); /* create a new capi device */ |
| 273 | extern int hycapi_capi_release(hysdn_card *); /* delete the device */ |
| 274 | extern int hycapi_capi_stop(hysdn_card *card); /* suspend */ |
Andrew Morton | c721bcc | 2006-03-25 03:07:04 -0800 | [diff] [blame^] | 275 | extern void hycapi_rx_capipkt(hysdn_card * card, unsigned char * buf, |
| 276 | unsigned short len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | extern void hycapi_tx_capiack(hysdn_card * card); |
| 278 | extern struct sk_buff *hycapi_tx_capiget(hysdn_card *card); |
| 279 | extern int hycapi_init(void); |
| 280 | extern void hycapi_cleanup(void); |
| 281 | #endif /* CONFIG_HYSDN_CAPI */ |
| 282 | |
| 283 | #endif /* HYSDN_DEFS_H */ |