3 * ===================================
4 * HARP | Host ATM Research Platform
5 * ===================================
8 * This Host ATM Research Platform ("HARP") file (the "Software") is
9 * made available by Network Computing Services, Inc. ("NetworkCS")
10 * "AS IS". NetworkCS does not provide maintenance, improvements or
11 * support of any kind.
13 * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14 * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15 * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16 * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17 * In no event shall NetworkCS be responsible for any damages, including
18 * but not limited to consequential damages, arising from or relating to
19 * any use of the Software or related support.
21 * Copyright 1994-1998 Network Computing Services, Inc.
23 * Copies of this Software may be made, however, the above copyright
24 * notice must be reproduced on all copies.
26 * @(#) $FreeBSD: src/sys/dev/hfa/fore_vcm.c,v 1.4 1999/08/28 00:41:53 peter Exp $
27 * @(#) $DragonFly: src/sys/dev/atm/hfa/fore_vcm.c,v 1.3 2003/08/07 21:16:49 dillon Exp $
31 * FORE Systems 200-Series Adapter Support
32 * ---------------------------------------
34 * Virtual Channel Management
38 #include "fore_include.h"
41 * VCC Stack Instantiation
43 * This function is called via the common driver code during a device VCC
44 * stack instantiation. The common code has already validated some of
45 * the request so we just need to check a few more Fore-specific details.
50 * cup pointer to device common unit
51 * cvp pointer to common VCC entry
54 * 0 instantiation successful
55 * err instantiation failed - reason indicated
59 fore_instvcc(cup, cvp)
63 Fore_vcc *fvp = (Fore_vcc *)cvp;
64 Atm_attributes *ap = &fvp->fv_connvc->cvc_attr;
67 * Validate requested AAL
69 switch (ap->aal.type) {
72 fvp->fv_aal = FORE_AAL_0;
76 fvp->fv_aal = FORE_AAL_4;
77 if ((ap->aal.v.aal4.forward_max_SDU_size > FORE_IFF_MTU) ||
78 (ap->aal.v.aal4.backward_max_SDU_size > FORE_IFF_MTU))
83 fvp->fv_aal = FORE_AAL_5;
84 if ((ap->aal.v.aal5.forward_max_SDU_size > FORE_IFF_MTU) ||
85 (ap->aal.v.aal5.backward_max_SDU_size > FORE_IFF_MTU))
100 * This function is called via the common driver code after receiving a
101 * stack *_INIT command. The common code has already validated most of
102 * the request so we just need to check a few more Fore-specific details.
103 * Then we just issue the command to the CP. Note that we can't wait around
104 * for the CP to process the command, so we return success for now and abort
105 * the connection if the command later fails.
110 * cup pointer to device common unit
111 * cvp pointer to common VCC entry
119 fore_openvcc(cup, cvp)
123 Fore_unit *fup = (Fore_unit *)cup;
124 Fore_vcc *fvp = (Fore_vcc *)cvp;
129 vcp = fvp->fv_connvc->cvc_vcc;
131 ATM_DEBUG4("fore_openvcc: fup=%p, fvp=%p, vcc=(%d,%d)\n",
132 fup, fvp, vcp->vc_vpi, vcp->vc_vci);
135 * Validate the VPI and VCI values
137 if ((vcp->vc_vpi > fup->fu_pif.pif_maxvpi) ||
138 (vcp->vc_vci > fup->fu_pif.pif_maxvci)) {
143 * Only need to tell the CP about incoming VCCs
145 if ((vcp->vc_type & VCC_IN) == 0) {
146 DEVICE_LOCK((Cmn_unit *)fup);
148 fvp->fv_state = CVS_ACTIVE;
149 DEVICE_UNLOCK((Cmn_unit *)fup);
154 * Queue command at end of command queue
156 hcp = fup->fu_cmd_tail;
157 if ((*hcp->hcq_status) & QSTAT_FREE) {
160 * Queue entry available, so set our view of things up
162 hcp->hcq_code = CMD_ACT_VCCIN;
164 fup->fu_cmd_tail = hcp->hcq_next;
165 fvp->fv_flags |= FVF_ACTCMD;
168 * Now set the CP-resident queue entry - the CP will grab
169 * the command when the op-code is set.
171 cqp = hcp->hcq_cpelem;
172 (*hcp->hcq_status) = QSTAT_PENDING;
173 cqp->cmdq_act.act_vccid = CP_WRITE(vcp->vc_vci);
174 if (fvp->fv_aal == FORE_AAL_0)
175 cqp->cmdq_act.act_batch = CP_WRITE(1);
176 cqp->cmdq_act.act_spec = CP_WRITE(
177 ACT_SET_SPEC(BUF_STRAT_1, fvp->fv_aal,
178 CMD_ACT_VCCIN | CMD_INTR_REQ));
183 fup->fu_stats->st_drv.drv_cm_full++;
194 * This function is called via the common driver code after receiving a
195 * stack *_TERM command. The common code has already validated most of
196 * the request so we just need to check a few more Fore-specific details.
197 * Then we just issue the command to the CP. Note that we can't wait around
198 * for the CP to process the command, so we return success for now and whine
199 * if the command later fails.
204 * cup pointer to device common unit
205 * cvp pointer to common VCC entry
213 fore_closevcc(cup, cvp)
217 Fore_unit *fup = (Fore_unit *)cup;
218 Fore_vcc *fvp = (Fore_vcc *)cvp;
225 vcp = fvp->fv_connvc->cvc_vcc;
227 ATM_DEBUG4("fore_closevcc: fup=%p, fvp=%p, vcc=(%d,%d)\n",
228 fup, fvp, vcp->vc_vpi, vcp->vc_vci);
230 DEVICE_LOCK((Cmn_unit *)fup);
233 * Clear any references to this VCC in our transmit queue
235 for (hxp = fup->fu_xmit_head, i = 0;
236 (*hxp->hxq_status != QSTAT_FREE) && (i < XMIT_QUELEN);
237 hxp = hxp->hxq_next, i++) {
238 if (hxp->hxq_vcc == fvp) {
244 * Clear any references to this VCC in our command queue
246 for (hcp = fup->fu_cmd_head, i = 0;
247 (*hcp->hcq_status != QSTAT_FREE) && (i < CMD_QUELEN);
248 hcp = hcp->hcq_next, i++) {
249 switch (hcp->hcq_code) {
253 if (hcp->hcq_arg == fvp) {
261 * If this VCC has been previously activated, then we need to tell
262 * the CP to deactivate it.
264 if (fvp->fv_flags & FVF_ACTCMD) {
267 * Queue command at end of command queue
269 hcp = fup->fu_cmd_tail;
270 if ((*hcp->hcq_status) & QSTAT_FREE) {
273 * Queue entry available, so set our view of things up
275 hcp->hcq_code = CMD_DACT_VCCIN;
277 fup->fu_cmd_tail = hcp->hcq_next;
280 * Now set the CP-resident queue entry - the CP will
281 * grab the command when the op-code is set.
283 cqp = hcp->hcq_cpelem;
284 (*hcp->hcq_status) = QSTAT_PENDING;
285 cqp->cmdq_dact.dact_vccid = CP_WRITE(vcp->vc_vci);
286 cqp->cmdq_dact.dact_cmd =
287 CP_WRITE(CMD_DACT_VCCIN|CMD_INTR_REQ);
292 * If we get here, we'll be getting out-of-sync with
293 * the CP because we can't (for now at least) do
294 * anything about close errors in the common code.
295 * This won't be too bad, since we'll just toss any
296 * PDUs received from the VCC and the sigmgr's will
297 * always get open failures when trying to use this
298 * (vpi,vci)...oh, well...always gotta have that one
299 * last bug to fix! XXX
301 fup->fu_stats->st_drv.drv_cm_full++;
309 if (fvp->fv_state == CVS_ACTIVE)
312 DEVICE_UNLOCK((Cmn_unit *)fup);