Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / net / i4b / layer1 / iwic / i4b_iwic_l1if.c
1 /*
2  * Copyright (c) 1999, 2000 Dave Boyce. 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  *---------------------------------------------------------------------------
26  *
27  *      i4b_iwic - isdn4bsd Winbond W6692 driver
28  *      ----------------------------------------
29  *
30  * $FreeBSD: src/sys/i4b/layer1/iwic/i4b_iwic_l1if.c,v 1.5.2.1 2001/08/10 14:08:40 obrien Exp $
31  * $DragonFly: src/sys/net/i4b/layer1/iwic/i4b_iwic_l1if.c,v 1.2 2003/06/17 04:28:40 dillon Exp $
32  *
33  *      last edit-date: [Sun Jan 21 11:09:33 2001]
34  *
35  *---------------------------------------------------------------------------*/
36
37 #include "iwic.h"
38 #include "opt_i4b.h"
39 #include "pci.h"
40
41 #if (NIWIC > 0) && (NPCI > 0)
42
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/socket.h>
46 #include <net/if.h>
47
48
49
50
51 #include <machine/i4b_debug.h>
52 #include <machine/i4b_ioctl.h>
53 #include <machine/i4b_trace.h>
54
55 #include <i4b/include/i4b_global.h>
56 #include <i4b/include/i4b_l3l4.h>
57
58 #include <i4b/layer1/i4b_l1.h>
59
60 #include <i4b/layer1/iwic/i4b_iwic.h>
61 #include <i4b/layer1/iwic/i4b_iwic_ext.h>
62
63 /* jump table for multiplex routines */
64
65 struct i4b_l1mux_func iwic_l1mux_func = {
66         iwic_ret_linktab,
67         iwic_set_linktab,
68         iwic_mph_command_req,
69         iwic_ph_data_req,
70         iwic_ph_activate_req,
71 };
72
73 /*---------------------------------------------------------------------------*
74  *
75  *---------------------------------------------------------------------------*/
76 int
77 iwic_ph_data_req(int unit, struct mbuf *m, int freeflag)
78 {
79         struct iwic_softc *sc = iwic_find_sc(unit);
80
81         return iwic_dchan_data_req(sc, m, freeflag);
82 }
83
84 /*---------------------------------------------------------------------------*
85  *
86  *---------------------------------------------------------------------------*/
87 int
88 iwic_ph_activate_req(int unit)
89 {
90         struct iwic_softc *sc = iwic_find_sc(unit);
91
92         iwic_next_state(sc, EV_PHAR);
93
94         return 0;
95 }
96
97 /*---------------------------------------------------------------------------*
98  *
99  *---------------------------------------------------------------------------*/
100 int
101 iwic_mph_command_req(int unit, int command, void *parm)
102 {
103         struct iwic_softc *sc = iwic_find_sc(unit);
104
105         switch (command)
106         {
107                 case CMR_DOPEN: /* Daemon running */
108                         NDBGL1(L1_PRIM, "CMR_DOPEN");
109                         sc->enabled = TRUE;
110                         break;
111
112                 case CMR_DCLOSE:        /* Daemon not running */
113                         NDBGL1(L1_PRIM, "CMR_DCLOSE");
114                         sc->enabled = FALSE;
115                         break;
116
117                 case CMR_SETTRACE:
118                         NDBGL1(L1_PRIM, "CMR_SETTRACE, parm = %d", (unsigned int)parm);
119                         sc->sc_trace = (unsigned int)parm;
120                         break;
121
122                 default:
123                         NDBGL1(L1_PRIM, "unknown command = %d", command);
124                         break;
125         }
126
127         return 0;
128 }
129
130 /*---------------------------------------------------------------------------*
131  *
132  *---------------------------------------------------------------------------*/
133 isdn_link_t *
134 iwic_ret_linktab(int unit, int channel)
135 {
136         struct iwic_softc *sc = iwic_find_sc(unit);
137         struct iwic_bchan *bchan = &sc->sc_bchan[channel];
138
139         return &bchan->iwic_isdn_linktab;
140 }
141
142 /*---------------------------------------------------------------------------*
143  *
144  *---------------------------------------------------------------------------*/
145 void
146 iwic_set_linktab (int unit, int channel, drvr_link_t *dlt)
147 {
148         struct iwic_softc *sc = iwic_find_sc(unit);
149         struct iwic_bchan *bchan = &sc->sc_bchan[channel];
150
151         bchan->iwic_drvr_linktab = dlt;
152 }
153
154 #endif