]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/i4b/layer1/iwic/i4b_iwic_l1if.c
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / 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  *
28  *      i4b_iwic - isdn4bsd Winbond W6692 driver
29  *      ----------------------------------------
30  *      last edit-date: [Sun Jan 21 11:09:33 2001]
31  *
32  *---------------------------------------------------------------------------*/
33
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD$");
36
37 #include "opt_i4b.h"
38
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/socket.h>
42 #include <net/if.h>
43
44 #include <i4b/include/i4b_debug.h>
45 #include <i4b/include/i4b_ioctl.h>
46 #include <i4b/include/i4b_trace.h>
47
48 #include <i4b/include/i4b_global.h>
49 #include <i4b/include/i4b_l3l4.h>
50
51 #include <i4b/layer1/i4b_l1.h>
52
53 #include <i4b/layer1/iwic/i4b_iwic.h>
54 #include <i4b/layer1/iwic/i4b_iwic_ext.h>
55
56 /* jump table for multiplex routines */
57
58 struct i4b_l1mux_func iwic_l1mux_func = {
59         iwic_ret_linktab,
60         iwic_set_linktab,
61         iwic_mph_command_req,
62         iwic_ph_data_req,
63         iwic_ph_activate_req,
64 };
65
66 /*---------------------------------------------------------------------------*
67  *
68  *---------------------------------------------------------------------------*/
69 int
70 iwic_ph_data_req(int unit, struct mbuf *m, int freeflag)
71 {
72         struct iwic_softc *sc = iwic_find_sc(unit);
73
74         return iwic_dchan_data_req(sc, m, freeflag);
75 }
76
77 /*---------------------------------------------------------------------------*
78  *
79  *---------------------------------------------------------------------------*/
80 int
81 iwic_ph_activate_req(int unit)
82 {
83         struct iwic_softc *sc = iwic_find_sc(unit);
84
85         iwic_next_state(sc, EV_PHAR);
86
87         return 0;
88 }
89
90 /*---------------------------------------------------------------------------*
91  *
92  *---------------------------------------------------------------------------*/
93 int
94 iwic_mph_command_req(int unit, int command, void *parm)
95 {
96         struct iwic_softc *sc = iwic_find_sc(unit);
97
98         switch (command)
99         {
100                 case CMR_DOPEN: /* Daemon running */
101                         NDBGL1(L1_PRIM, "CMR_DOPEN");
102                         sc->enabled = TRUE;
103                         break;
104
105                 case CMR_DCLOSE:        /* Daemon not running */
106                         NDBGL1(L1_PRIM, "CMR_DCLOSE");
107                         sc->enabled = FALSE;
108                         break;
109
110                 case CMR_SETTRACE:
111                         NDBGL1(L1_PRIM, "CMR_SETTRACE, parm = %d", (unsigned int)parm);
112                         sc->sc_trace = (unsigned int)parm;
113                         break;
114
115                 default:
116                         NDBGL1(L1_PRIM, "unknown command = %d", command);
117                         break;
118         }
119
120         return 0;
121 }
122
123 /*---------------------------------------------------------------------------*
124  *
125  *---------------------------------------------------------------------------*/
126 isdn_link_t *
127 iwic_ret_linktab(int unit, int channel)
128 {
129         struct iwic_softc *sc = iwic_find_sc(unit);
130         struct iwic_bchan *bchan = &sc->sc_bchan[channel];
131
132         return &bchan->iwic_isdn_linktab;
133 }
134
135 /*---------------------------------------------------------------------------*
136  *
137  *---------------------------------------------------------------------------*/
138 void
139 iwic_set_linktab (int unit, int channel, drvr_link_t *dlt)
140 {
141         struct iwic_softc *sc = iwic_find_sc(unit);
142         struct iwic_bchan *bchan = &sc->sc_bchan[channel];
143
144         bchan->iwic_drvr_linktab = dlt;
145 }