File: /usr/src/linux/drivers/isdn/tpam/tpam.h

1     /* $Id: tpam.h,v 1.1.2.1 2001/06/05 19:45:37 kai Exp $
2      *
3      * Turbo PAM ISDN driver for Linux. (Kernel Driver)
4      *
5      * Copyright 2001 Stelian Pop <stelian.pop@fr.alcove.com>, Alcôve
6      *
7      * For all support questions please contact: <support@auvertech.fr>
8      *
9      * This program is free software; you can redistribute it and/or modify
10      * it under the terms of the GNU General Public License as published by
11      * the Free Software Foundation; either version 2, or (at your option)
12      * any later version.
13      *
14      * This program is distributed in the hope that it will be useful,
15      * but WITHOUT ANY WARRANTY; without even the implied warranty of
16      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17      * GNU General Public License for more details.
18      *
19      * You should have received a copy of the GNU General Public License
20      * along with this program; if not, write to the Free Software
21      * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22      *
23      */
24     
25     #ifndef _TPAM_PRIV_H_
26     #define _TPAM_PRIV_H_
27     
28     #include <linux/module.h>
29     #include <linux/isdnif.h>
30     #include <linux/init.h>
31     
32     /* Maximum number of channels for this board */
33     #define TPAM_NBCHANNEL		30
34     /* Maximum size of data */
35     #define TPAM_MAXBUFSIZE		2032
36     /* Size of a page of board memory */
37     #define TPAM_PAGE_SIZE		0x003ffffc	/* 4 MB */
38     /* Magic number present if the board was successfully started */
39     #define TPAM_MAGICNUMBER	0x2a343242
40     
41     /* Registers in the PCI BAR0 */
42     #define TPAM_PAGE_REGISTER	0x00400000	/* Select page */
43     #define TPAM_DSPINT_REGISTER	0x00400004	/* Interrupt board */
44     #define TPAM_RESETPAM_REGISTER	0x00400008	/* Reset board */
45     #define TPAM_HINTACK_REGISTER	0x0040000c	/* Ack interrupt */
46     #define TPAM_HPIC_REGISTER	0x00400014	/* Board ready */
47     
48     /* Registers in the board memory */
49     #define TPAM_MAGICNUMBER_REGISTER	0x80008000 /* Magic number */
50     #define TPAM_EXID_REGISTER		0x80008004 /* EXID - not used */
51     #define TPAM_UPLOADPTR_REGISTER		0x80008008 /* Upload data ptr */
52     #define TPAM_DOWNLOADPTR_REGISTER	0x8000800c /* Download data ptr */
53     #define TPAM_ACKUPLOAD_REGISTER		0x80008010 /* Ack upload */
54     #define TPAM_ACKDOWNLOAD_REGISTER	0x80008014 /* Ack download */
55     #define TPAM_INTERRUPTACK_REGISTER	0x80008018 /* Ack interrupt */
56     
57     /* Reserved areas in the board memory */
58     #define	TPAM_RESERVEDAREA1_START	0x00000000
59     #define TPAM_RESERVEDAREA1_END		0x003FFFFF
60     #define TPAM_RESERVEDAREA2_START	0x01C00000
61     #define TPAM_RESERVEDAREA2_END		0x01FFFFFF
62     #define TPAM_RESERVEDAREA3_START	0x04000000
63     #define TPAM_RESERVEDAREA3_END		0x7FFFFFFF
64     #define TPAM_RESERVEDAREA4_START	0x80010000
65     #define TPAM_RESERVEDAREA4_END		0xFFFFFFFF
66     
67     /* NCO ID invalid */
68     #define TPAM_NCOID_INVALID	0xffff
69     /* channel number invalid */
70     #define TPAM_CHANNEL_INVALID	0xffff
71     
72     /* Channel structure */
73     typedef struct tpam_channel {
74     	int num;			/* channel number */
75     	struct tpam_card *card;		/* channel's card */
76     	u32 ncoid;			/* ncoid */
77     	u8  hdlc;			/* hdlc mode (set by user level) */
78     	u8  realhdlc;			/* hdlc mode (negociated with peer) */
79     	u32 hdlcshift;			/* hdlc shift */
80     	u8  readytoreceive;		/* channel ready to receive data */
81     	struct sk_buff_head sendq;	/* Send queue */
82     } tpam_channel;
83     
84     /* Card structure */
85     typedef struct tpam_card {
86     	struct tpam_card *next;		/* next card in list */
87     	unsigned int irq;		/* IRQ used by this board */
88     	unsigned long bar0;		/* ioremapped bar0 */
89     	int id;				/* id of the board */
90     	isdn_if interface;		/* isdn link-level pointer */
91     	int channels_used;		/* number of channels actually used */
92     	int channels_tested;		/* number of channels being tested */
93     	u8 loopmode;			/* board in looptest mode */
94     	tpam_channel channels[TPAM_NBCHANNEL];/* channels tab */
95     	int running;			/* card is running */
96     	int busy;			/* waiting for ack from card */
97     	int roundrobin;			/* round robin between channels */
98     	struct sk_buff_head sendq;	/* send queue */
99     	struct sk_buff_head recvq;	/* receive queue */
100     	struct tq_struct send_tq;	/* send task queue */
101     	struct tq_struct recv_tq;	/* receive task queue */
102     	spinlock_t lock;		/* lock for the card */
103     } tpam_card;
104     
105     /* Timeout waiting for signature to become available */
106     #define SIGNATURE_TIMEOUT	(5*HZ)
107     /* Timeout waiting for receiving all the ACreateNCOCnf */
108     #define NCOCREATE_TIMEOUT	(30*HZ)
109     
110     /* Maximum size of the TLV block */
111     #define MPB_MAXIMUMBLOCKTLVSIZE	 128
112     /* Maximum size of the data block */
113     #define MPB_MAXIMUMDATASIZE	4904
114     /* Maximum size of a phone number */
115     #define PHONE_MAXIMUMSIZE	  32
116     
117     /* Header for a sk_buff structure */
118     typedef struct skb_header {
119     	u16 size;		/* size of pci_mpb block + size of tlv block */
120     	u16 data_size;		/* size of the data block */
121     	u16 ack;		/* packet needs to send ack upon send */
122     	u16 ack_size;		/* size of data to be acknowledged upon send */
123     } skb_header;
124     
125     /* PCI message header structure */
126     typedef struct pci_mpb {
127     	u16 exID;			/* exID - not used */
128     	u16 flags;			/* flags - not used */
129     	u32 errorCode;			/* errorCode - not used */
130     	u16 messageID;			/* message ID - one of ID_XXX */
131     	u16 maximumBlockTLVSize;	/* MPB_MAXIMUMBLOCKTLVSIZE */
132     	u16 actualBlockTLVSize;		/* size of the tlv block */
133     	u16 maximumDataSize;		/* MPB_MAXIMUMDATASIZE */
134     	u16 actualDataSize;		/* size of the data block */
135     	u16 dummy;			/* padding */
136     } pci_mpb;
137     
138     /* Types of PCI messages */
139     #define ID_ACreateNCOReq	101
140     #define ID_ACreateNCOCnf	102
141     #define ID_ADestroyNCOReq	103
142     #define ID_ADestroyNCOCnf	104
143     #define ID_CConnectReq		203
144     #define ID_CConnectInd		204
145     #define ID_CConnectRsp		205
146     #define ID_CConnectCnf		206
147     #define ID_CDisconnectReq	207
148     #define ID_CDisconnectInd	208
149     #define ID_CDisconnectRsp	209
150     #define ID_CDisconnectCnf	210
151     #define ID_U3DataReq		307
152     #define ID_U3DataInd		308
153     #define ID_U3ReadyToReceiveInd	318
154     
155     /* Parameters for the PCI message TLV block */
156     #define PAR_BearerCap		3
157     #define PAR_CalledNumber	7
158     #define PAR_CallingNumber	11
159     #define PAR_CauseToPUF		15
160     #define PAR_Cdirection		16
161     #define PAR_CompletionStatus	19
162     #define PAR_Facility		30
163     #define PAR_HLC			34
164     #define PAR_NCOID		49
165     #define PAR_NCOType		50
166     #define PAR_ReadyFlag		55
167     #define PAR_U3Protocol		62
168     #define PAR_Udirection		64
169     
170     /* Delayed statcallb structure */
171     typedef struct tpam_statcallb_data {
172     	tpam_card *card;		/* card issuing the statcallb */
173     	struct timer_list *timer;	/* timer launching the statcallb */
174     	isdn_ctrl ctrl;			/* isdn command */
175     } tpam_statcallb_data;
176     
177     /* Function prototypes from tpam_main.c */
178     extern tpam_card *tpam_findcard(int);
179     extern u32 tpam_findchannel(tpam_card *, u32);
180     
181     /* Function prototypes from tpam_memory.c */
182     extern void copy_to_pam_dword(tpam_card *, const void *, u32);
183     extern void copy_to_pam(tpam_card *, void *, const void *, u32);
184     extern u32 copy_from_pam_dword(tpam_card *, const void *);
185     extern void copy_from_pam(tpam_card *, void *, const void *, u32);
186     extern int copy_from_pam_to_user(tpam_card *, void *, const void *, u32);
187     extern int copy_from_user_to_pam(tpam_card *, void *, const void *, u32);
188     extern int tpam_verify_area(u32, u32);
189     
190     /* Function prototypes from tpam_nco.c */
191     extern struct sk_buff *build_ACreateNCOReq(const u8 *);
192     extern struct sk_buff *build_ADestroyNCOReq(u32);
193     extern struct sk_buff *build_CConnectReq(u32, const u8 *, u8);
194     extern struct sk_buff *build_CConnectRsp(u32);
195     extern struct sk_buff *build_CDisconnectReq(u32);
196     extern struct sk_buff *build_CDisconnectRsp(u32);
197     extern struct sk_buff *build_U3DataReq(u32, void *, u16, u16, u16);
198     extern int parse_ACreateNCOCnf(struct sk_buff *, u8 *, u32 *);
199     extern int parse_ADestroyNCOCnf(struct sk_buff *, u8 *, u32 *);
200     extern int parse_CConnectCnf(struct sk_buff *, u32 *);
201     extern int parse_CConnectInd(struct sk_buff *, u32 *, u8 *, u8 *, 
202     			     u8 *, u8 *, u8 *);
203     extern int parse_CDisconnectCnf(struct sk_buff *, u32 *, u32 *);
204     extern int parse_CDisconnectInd(struct sk_buff *, u32 *, u32 *);
205     extern int parse_U3ReadyToReceiveInd(struct sk_buff *, u32 *, u8 *);
206     extern int parse_U3DataInd(struct sk_buff *, u32 *, u8 **, u16 *);
207     
208     /* Function prototypes from tpam_queues.c */
209     extern void tpam_enqueue(tpam_card *, struct sk_buff *);
210     extern void tpam_enqueue_data(tpam_channel *, struct sk_buff *);
211     extern void tpam_irq(int, void *, struct pt_regs *);
212     extern void tpam_recv_tq(tpam_card *);
213     extern void tpam_send_tq(tpam_card *);
214     
215     /* Function prototypes from tpam_commands.c */
216     extern int tpam_command(isdn_ctrl *);
217     extern int tpam_writebuf_skb(int, int, int, struct sk_buff *);
218     extern void tpam_recv_ACreateNCOCnf(tpam_card *, struct sk_buff *);
219     extern void tpam_recv_ADestroyNCOCnf(tpam_card *, struct sk_buff *);
220     extern void tpam_recv_CConnectCnf(tpam_card *, struct sk_buff *);
221     extern void tpam_recv_CConnectInd(tpam_card *, struct sk_buff *);
222     extern void tpam_recv_CDisconnectInd(tpam_card *, struct sk_buff *);
223     extern void tpam_recv_CDisconnectCnf(tpam_card *, struct sk_buff *);
224     extern void tpam_recv_U3DataInd(tpam_card *, struct sk_buff *);
225     extern void tpam_recv_U3ReadyToReceiveInd(tpam_card *, struct sk_buff *);
226     
227     /* Function prototypes from tpam_hdlc.c */
228     extern u32 hdlc_encode(u8 *, u8 *, u32 *, u32);
229     extern u32 hdlc_decode(u8 *, u8 *, u32);
230     
231     /* Function prototypes from tpam_crcpc.c */
232     extern void init_CRC(void);
233     extern void hdlc_encode_modem(u8 *, u32, u8 *, u32 *);
234     extern void hdlc_no_accm_encode(u8 *, u32, u8 *, u32 *);
235     extern u32 hdlc_no_accm_decode(u8 *, u32);
236     
237     /* Define this to enable debug tracing prints */
238     #undef DEBUG
239     
240     #ifdef DEBUG
241     #define dprintk printk
242     #else
243     #define dprintk while(0) printk
244     #endif
245     
246     #endif /* _TPAM_H_ */
247