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