1 /* $NetBSD: iwicvar.h,v 1.4 2005/12/11 12:22:50 christos Exp $ */
4 * Copyright (c) 1999, 2000 Dave Boyce. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
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
31 #include <netisdn/i4b_debug.h>
32 #include <netisdn/i4b_ioctl.h>
33 #include <netisdn/i4b_trace.h>
35 #include <netisdn/i4b_l2.h>
36 #include <netisdn/i4b_l1l2.h>
37 #include <netisdn/i4b_l3l4.h>
39 /*---------------------------------------------------------------------------*
40 * state of a B channel
41 *---------------------------------------------------------------------------*/
43 int channel
; /* channel number */
44 int offset
; /* offset from iobase */
45 int bprot
; /* b channel protocol used */
46 int state
; /* transceiver state: */
47 #define ST_IDLE 0x00 /* channel idle */
48 #define ST_TX_ACTIVE 0x01 /* tx running */
50 unsigned int sc_trace_bcount
;
52 /* receive data from ISDN */
54 struct ifqueue rx_queue
;/* receiver queue */
55 int rxcount
; /* rx statistics counter */
56 struct mbuf
*in_mbuf
; /* rx input buffer */
57 u_char
*in_cbptr
; /* curr buffer pointer */
58 int in_len
; /* rx input buffer len */
60 /* transmit data to ISDN */
62 struct ifqueue tx_queue
;/* transmitter queue */
63 int txcount
; /* tx statistics counter */
64 struct mbuf
*out_mbuf_head
; /* first mbuf in possible chain */
65 struct mbuf
*out_mbuf_cur
; /* current mbuf in possbl chain */
66 unsigned char *out_mbuf_cur_ptr
; /* data pointer into mbuf */
67 int out_mbuf_cur_len
; /* remaining bytes in mbuf */
71 isdn_link_t iwic_isdn_linktab
;
72 const struct isdn_l4_driver_functions
*l4_driver
;
73 void *l4_driver_softc
;
75 /*---------------------------------------------------------------------------*
76 * state of a D channel
77 *---------------------------------------------------------------------------*/
82 u_char
*ibuf_ptr
; /* Input buffer pointer */
83 int ibuf_len
; /* Current length of input buffer */
84 int ibuf_max_len
; /* Max length in input buffer */
87 int tx_ready
; /* Can send next 64 bytes of data. */
98 /*---------------------------------------------------------------------------*
99 * state of one iwic unit
100 *---------------------------------------------------------------------------*/
102 struct device sc_dev
;
104 const char *sc_cardname
;
106 bus_addr_t sc_iobase
;
107 bus_size_t sc_iosize
;
108 bus_space_handle_t sc_io_bh
;
109 bus_space_tag_t sc_io_bt
;
111 struct iwic_dchan sc_dchan
;
112 struct iwic_bchan sc_bchan
[2];
114 void *sc_ih
; /* interrupt handler */
115 pci_chipset_tag_t sc_pc
;
117 void *sc_l3token
; /* pointer to registered L3 instance */
118 struct l2_softc sc_l2
; /* D-channel variables */
125 /*---------------------------------------------------------------------------*
126 * rd/wr register/fifo macros
127 *---------------------------------------------------------------------------*/
131 #define IWIC_READ(sc,reg) bus_space_read_1((sc)->sc_io_bt,(sc)->sc_io_bh,(reg))
132 #define IWIC_WRITE(sc,reg,val) bus_space_write_1((sc)->sc_io_bt,(sc)->sc_io_bh,(reg),(val))
133 #define IWIC_WRDFIFO(sc,p,l) bus_space_write_multi_1((sc)->sc_io_bt,(sc)->sc_io_bh,D_XFIFO,(p),(l))
134 #define IWIC_RDDFIFO(sc,p,l) bus_space_read_multi_1((sc)->sc_io_bt,(sc)->sc_io_bh,D_RFIFO,(p),(l))
135 #define IWIC_WRBFIFO(sc,b,p,l) bus_space_write_multi_1((sc)->sc_io_bt,(sc)->sc_io_bh,(b)->offset + B_XFIFO,(p),(l))
136 #define IWIC_RDBFIFO(sc,b,p,l) bus_space_read_multi_1((sc)->sc_io_bt,(sc)->sc_io_bh,(b)->offset + B_RFIFO,(p),(l))
138 /*---------------------------------------------------------------------------*
139 * possible I.430 states
140 *---------------------------------------------------------------------------*/
142 ST_F3N
, /* F3 Deactivated, no clock */
143 ST_F3
, /* F3 Deactivated */
144 ST_F4
, /* F4 Awaiting Signal */
145 ST_F5
, /* F5 Identifying Input */
146 ST_F6
, /* F6 Synchronized */
147 ST_F7
, /* F7 Activated */
148 ST_F8
, /* F8 Lost Framing */
149 ST_ILL
, /* Illegal State */
152 /*---------------------------------------------------------------------------*
153 * possible I.430 events
154 *---------------------------------------------------------------------------*/
156 EV_PHAR
, /* PH ACTIVATE REQUEST */
157 EV_CE
, /* Clock enabled */
158 EV_T3
, /* Timer 3 expired */
159 EV_INFO0
, /* receiving INFO0 */
160 EV_RSY
, /* receiving any signal */
161 EV_INFO2
, /* receiving INFO2 */
162 EV_INFO48
, /* receiving INFO4 pri 8/9 */
163 EV_INFO410
, /* receiving INFO4 pri 10/11 */
164 EV_DR
, /* Deactivate Request */
165 EV_PU
, /* Power UP */
166 EV_DIS
, /* Disconnected (only 2085) */
167 EV_EI
, /* Error Indication */
168 EV_ILL
, /* Illegal Event */
171 /*---------------------------------------------------------------------------*
173 *---------------------------------------------------------------------------*/
175 CMD_ECK
, /* Enable clock */
176 CMD_TIM
, /* Timing */
178 CMD_AR8
, /* Activation request pri 8 */
179 CMD_AR10
, /* Activation request pri 10 */
180 CMD_DIU
, /* Deactivate Indication Upstream */
181 CMD_ILL
/* Illegal command */
184 void iwic_init(struct iwic_softc
*);
185 void iwic_next_state(struct iwic_softc
*, int);
187 void iwic_dchan_init(struct iwic_softc
*);
188 void iwic_dchan_xirq(struct iwic_softc
*);
189 void iwic_dchan_xfer_irq(struct iwic_softc
*, int);
190 void iwic_dchan_disable(struct iwic_softc
*);
191 int iwic_dchan_data_req(struct iwic_softc
*, struct mbuf
*, int);
192 void iwic_dchan_transmit(struct iwic_softc
*);
194 const char *iwic_printstate(struct iwic_softc
*);
196 void iwic_init_linktab(struct iwic_softc
*);
197 void iwic_bchan_xirq(struct iwic_softc
*, int);
198 void iwic_bchannel_setup(isdn_layer1token
, int, int, int);
200 #endif /* _IWICVAR_H_ */