1 /*	$NetBSD: i4b_capi.h,v 1.2 2003/10/03 16:38:44 pooka Exp $	*/
2 
3 /*
4  * Copyright (c) 2001-2003 Cubical Solutions Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  * capi/capi.h		The CAPI device interface.
28  *
29  * $FreeBSD: src/sys/i4b/capi/capi.h,v 1.1 2001/05/25 08:39:31 hm Exp $
30  */
31 
32 #ifndef _I4B_CAPI_H_
33 #define _I4B_CAPI_H_
34 
35 /*
36 //  CAPI driver context: B channels and controller softcs.
37 */
38 
39 #define INVALID -1
40 
41 enum capi_b_state {
42     B_FREE,                  /* 0:  channel free, ncci invalid */
43     B_CONNECT_CONF,          /* 1:  wait for CONNECT_CONF */
44     B_CONNECT_IND,           /* 2:  IND got, wait for appl RESP */
45     B_CONNECT_ACTIVE_IND,    /* 3:  wait for CONNECT_ACTIVE_IND */
46     B_CONNECT_B3_CONF,       /* 4:  wait for CONNECT_B3_CONF */
47     B_CONNECT_B3_IND,        /* 5:  wait for CONNECT_B3_IND */
48     B_CONNECT_B3_ACTIVE_IND, /* 6:  wait for CONNECT_B3_ACTIVE_IND */
49     B_CONNECTED,             /* 7:  channel connected & in use */
50     B_DISCONNECT_CONF,       /* 8:  wait for DISCONNECT_CONF */
51     B_DISCONNECT_B3_CONF,    /* 9:  wait for DISCONNECT_B3_CONF */
52     B_DISCONNECT_IND,        /* 10: wait for DISCONNECT_IND */
53 };
54 
55 typedef struct capi_bchan
56 {
57     /* Channel state */
58 
59     int ncci;
60 #define CAPI_CTRL_MASK 0x000000ff
61 #define CAPI_PLCI_MASK 0x0000ffff
62 #define CAPI_NCCI_MASK 0xffff0000
63     u_int16_t msgid;
64     int busy;
65     enum capi_b_state state;
66 
67     struct ifqueue tx_queue;
68     struct ifqueue rx_queue;
69     int rxcount;
70     int txcount;
71 
72     /* The rest is needed for i4b integration */
73     int bprot;
74     int cdid;
75 
76     struct mbuf *in_mbuf;
77     isdn_link_t	capi_isdn_linktab;
78 
79     const struct isdn_l4_driver_functions *l4_driver;
80     void *l4_driver_softc;
81 } capi_bchan_t;
82 
83 enum capi_c_state {
84     C_DOWN,             /* controller uninitialized */
85     C_READY,            /* controller initialized but not listening */
86     C_UP,               /* controller listening */
87 };
88 
89 typedef struct capi_softc {
90     int sc_unit;        /* index in capi_sc[]                      */
91     int card_type;      /* CARD_TYPEC_xxx, filled by ll driver     */
92     int sc_nbch;        /* number of b channels on this controller */
93     int sc_enabled;     /* is daemon connected TRUE/FALSE          */
94     int sc_msgid;       /* next CAPI message id                    */
95     int capi_isdnif;    /* isdnif identifier                       */
96     char sc_profile[64];/* CAPI profile data                       */
97     enum capi_c_state sc_state;
98 
99     capi_bchan_t sc_bchan[MAX_BCHAN];
100 
101     /* Link layer driver context holder and methods */
102     void *ctx;
103 
104     int (*load)(struct capi_softc *, int, u_int8_t *);
105     int (*reg_appl)(struct capi_softc *, int, int);
106     int (*rel_appl)(struct capi_softc *, int);
107     int (*send)(struct capi_softc *, struct mbuf *);
108 } capi_softc_t;
109 
110 extern int ncapi;
111 
112 #define CARD_TYPEC_CAPI_UNK	0
113 #define CARD_TYPEC_AVM_T1_PCI	1
114 #define CARD_TYPEC_AVM_B1_PCI	2
115 #define CARD_TYPEC_AVM_B1_ISA	3
116 
117 /*
118 //  CAPI upcalls for the link layer.
119 */
120 
121 #define I4BCAPI_APPLID 1
122 
123 extern int capi_ll_attach(capi_softc_t *, const char *, const char *);
124 extern int capi_ll_control(capi_softc_t *, int op, int arg);
125 extern int capi_ll_detach(capi_softc_t *);
126 
127 #define CAPI_CTRL_READY     0 /* ctrl ready, value=TRUE/FALSE */
128 #define CAPI_CTRL_PROFILE   1 /* set CAPI profile             */
129 #define CAPI_CTRL_NEW_NCCI  2 /* new ncci value, assign bchan */
130 #define CAPI_CTRL_FREE_NCCI 3 /* free ncci value, clear bchan */
131 
132 extern int capi_ll_receive(capi_softc_t *, struct mbuf *);
133 
134 extern int capi_start_tx(void *, int bchan);
135 
136 #endif /* _I4B_CAPI_H_ */
137