2 * Copyright (c) 2000 Hans Petter Selasky. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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
25 *---------------------------------------------------------------------------
27 * i4b_ihfc.h - ihfc common header file
28 * ------------------------------------
30 * last edit-date: [Wed Jul 19 09:40:45 2000]
32 * $Id: i4b_ihfc.h,v 1.9 2000/09/19 13:50:36 hm Exp $
34 * $FreeBSD: src/sys/i4b/layer1/ihfc/i4b_ihfc.h,v 1.1.2.1 2001/08/10 14:08:37 obrien Exp $
35 * $DragonFly: src/sys/net/i4b/layer1/ihfc/i4b_ihfc.h,v 1.3 2003/08/07 21:17:26 dillon Exp $
37 *---------------------------------------------------------------------------*/
42 #include "../../include/i4b_l3l4.h"
44 /*---------------------------------------------------------------------------*
45 * global stuff (HFC-1/S/SP)
46 *---------------------------------------------------------------------------*/
47 #define DCH_MAX_LEN 264 /* max length of a D frame */
49 #define IHFC_ACTIVATION_TIMEOUT 3*hz /* S0-bus must activate before this time */
51 #define IHFC_IO_BASES 1
53 #define IHFC_DISBUSYTO 500 /* do at least 500 inb's before giving up */
54 #define IHFC_NONBUSYTO 8000 /* do at least 8000 inb's before giving up */
56 #define IHFC_NTMODE 0 /* use TE-mode as default */
57 #define IHFC_DLP 0 /* use (8/9) priority as default */
59 #define IHFC_MAXUNIT 4
61 /* #define IHFC_DEBUG internal debugging enabled *
62 * #undef IHFC_DEBUG internal debugging disabled */
72 #define HFC_1 0x01 /* HFC 2B */
73 #define HFC_S 0x02 /* HFC - S 2BDS0 */
74 #define HFC_SP 0x04 /* HFC - SP 2BDS0 */
75 #define HFC_SPCI 0x08 /* HFC - SPCI 2BDS0 X */
76 #define HFC_S2M 0x10 /* HFC - S2M 2BDS0 X */
77 #define HFC_USB 0x20 /* HFC - USB 2BDS0 X */
79 /*---------------------------------------------------------------------------*
80 * "Help Fix Corruption" macros (HFC-1/S/SP)
82 * NOTE: If the code does not run at splhigh, we will sporadically
83 * lose bytes. On fast PC's (200 Mhz), this is very little noticable.
84 *---------------------------------------------------------------------------*/
85 #define HFC_VAR int _s_ /* declare variable */
86 #define HFC_BEG _s_ = splhigh() /* save spl */
87 #define HFC_END splx(_s_) /* restore spl */
89 /*---------------------------------------------------------------------------*
90 * macros related to i4b linking (HFC-1/S/SP)
91 *---------------------------------------------------------------------------*/
92 #define S_BLINK sc->sc_blinktab[(chan > 3) ? 1 : 0]
93 #define S_BDRVLINK sc->sc_bdrvlinktab[(chan > 3) ? 1 : 0]
95 /*---------------------------------------------------------------------------*
96 * macros related to ihfc_sc (HFC-1/S/SP)
97 *---------------------------------------------------------------------------*/
101 #define S_IOM2 (sc->sc_config.i_adf2 & 0x80)
102 /* 0x80: IOM2 mode selected */
104 #define S_DLP (sc->sc_config.dlp)
105 #define S_NTMODE (sc->sc_config.ntmode)
106 #define S_STDEL (sc->sc_config.stdel)
108 #define S_PHSTATE sc->sc_statemachine.state
109 #define S_STM_T3 sc->sc_statemachine.T3
110 #define S_STM_T3CALLOUT sc->sc_statemachine.T3callout
114 #define S_UNIT sc->sc_unit
115 #define S_FLAG sc->sc_flag
116 #define S_I4BUNIT sc->sc_i4bunit
117 #define S_I4BFLAG sc->sc_i4bflag
121 #define S_IOBASE sc->sc_resources.io_base
122 #define S_IORID sc->sc_resources.io_rid
123 #define S_IRQ sc->sc_resources.irq
124 #define S_IRQRID sc->sc_resources.irq_rid
128 #define S_HFC sc->sc_config.chiptype
129 #define S_IIO sc->sc_config.iio
130 #define S_IIRQ sc->sc_config.iirq
132 /* registers of the HFC-S/SP (write only) */
134 #define S_HFC_CONFIG sc->sc_config.cirm
136 #define S_CIRM sc->sc_config.cirm
137 #define S_CTMT sc->sc_config.ctmt
138 #define S_TEST sc->sc_config.test
139 #define S_SCTRL sc->sc_config.sctrl
140 #define S_CLKDEL sc->sc_config.clkdel
141 #define S_INT_M1 sc->sc_config.int_m1
142 #define S_INT_M2 sc->sc_config.int_m2
143 #define S_CONNECT sc->sc_config.connect
144 #define S_SCTRL_R sc->sc_config.sctrl_r
145 #define S_MST_MODE sc->sc_config.mst_mode
147 /* registers of the HFC-S/SP (read only) */
149 #define S_INT_S1 sc->sc_config.int_s1
151 /* registers of the ISAC (write only) */
153 #define S_ISAC_CONFIG sc->sc_config.i_adf2
155 #define S_ADF1 sc->sc_config.i_adf1
156 #define S_ADF2 sc->sc_config.i_adf2
157 #define S_MASK sc->sc_config.i_mask
158 #define S_MODE sc->sc_config.i_mode
159 #define S_SPCR sc->sc_config.i_spcr
160 #define S_SQXR sc->sc_config.i_sqxr
161 #define S_STCR sc->sc_config.i_stcr
162 #define S_STAR2 sc->sc_config.i_star2
164 /* registers of the ISAC (read only) */
166 #define S_ISTA sc->sc_config.i_ista
168 /* state of the softc */
170 #define S_ENABLED sc->sc_enabled
171 #define S_INTR_ACTIVE sc->sc_intr_active
175 #define S_HDLC_IB sc->sc_fifo.chan[chan].hdlc.ib /* u_short */
176 #define S_HDLC_CRC sc->sc_fifo.chan[chan].hdlc.crc /* u_short */
177 #define S_HDLC_TMP sc->sc_fifo.chan[chan].hdlc.tmp /* u_int */
178 #define S_HDLC_FLAG sc->sc_fifo.chan[chan].hdlc.flag /* u_char */
179 #define S_HDLC_BLEVEL sc->sc_fifo.chan[chan].hdlc.blevel /* u_short */
183 #define S_BYTES sc->sc_fifo.chan[chan].bytes
187 #define S_HDLC_DZ_TAB sc->sc_fifo.dztable
191 #define S_PROT sc->sc_fifo.chan[chan].prot
192 #define S_FILTER sc->sc_fifo.chan[chan].filter
193 #define S_ACTIVITY sc->sc_fifo.chan[chan].activity
194 #define S_LAST_CHAN sc->sc_fifo.last_chan
198 #define RESET_SOFT_CHAN(sc, chan) bzero(&sc->sc_fifo.chan[chan], sizeof(sc->sc_fifo.chan[0]))
202 #define S_TRACE sc->sc_trace
203 #define S_DTRACECOUNT sc->sc_Dtracecount
204 #define S_BTRACECOUNT sc->sc_Btracecount
208 #define S_MBUF sc->sc_fifo.chan[chan].buffer.mbuf
209 #define S_MBUFDUMMY sc->sc_fifo.chan[chan].buffer.mbufdummy
210 #define S_MBUFLEN sc->sc_fifo.chan[chan].buffer.mbuf->m_len
211 #define S_MBUFPKTHDR sc->sc_fifo.chan[chan].buffer.mbuf->m_pkthdr
212 #define S_MBUFDATA sc->sc_fifo.chan[chan].buffer.mbuf->m_data
213 #define S_MBUFDAT sc->sc_fifo.chan[chan].buffer.mbuf->m_dat
215 #define S_IFQUEUE sc->sc_fifo.chan[chan].buffer.ifqueue
219 #define HFC_INIT ihfc_init
220 #define HFC_INTR ((S_HFC & HFC_1) ? ihfc_intr1 : ihfc_intr2)
221 #define HFC_FSM ihfc_fsm
222 #define HFC_CONTROL ihfc_control
228 struct sc_resources {
229 struct resource * io_base[IHFC_IO_BASES];
230 int io_rid [IHFC_IO_BASES];
231 struct resource * irq;
244 struct ifqueue ifqueue; /* data queue */
245 struct mbuf *mbuf; /* current mbuf */
246 struct mbuf *mbufdummy; /* temporary */
253 struct buffer buffer;
254 void (*filter)(struct ihfc_sc *sc, u_char chan);
266 u_short chiptype; /* chiptype (eg. HFC_1) */
267 u_char dlp; /* D-priority */
268 u_short iio; /* internal IO */
269 u_char iirq; /* internal IRQ */
270 u_char ntmode; /* mode */
271 u_char stdel; /* S/T delay */
285 /* isac write only - hfc-1: */
298 /* isac read only - hfc-1: */
302 struct sc_statemachine {
303 u_char state; /* see i4b_ihfc_drv.h */
305 u_char T3; /* T3 running */
306 struct callout_handle T3callout;
309 /*---------------------------------------------------------------------------*
311 *---------------------------------------------------------------------------*/
312 typedef struct ihfc_sc
316 int sc_i4bunit; /* L0IHFCUNIT(sc_unit) */
317 int sc_i4bflag; /* FLAG_TEL_S0_16_3C .. */
319 u_char sc_enabled; /* daemon running if set */
320 u_char sc_intr_active; /* interrupt is active */
323 u_int sc_Btracecount;
324 u_int sc_Dtracecount;
326 struct sc_config sc_config;
327 struct sc_resources sc_resources;
328 struct sc_statemachine sc_statemachine;
330 isdn_link_t sc_blinktab[2];
331 drvr_link_t *sc_bdrvlinktab[2];
333 struct sc_fifo sc_fifo;
336 extern ihfc_sc_t ihfc_softc[];
338 #endif /* _I4B_IHFC_H_ */