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