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.4 2008/03/01 22:03:13 swildner 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(Cmn_unit *cup, Cmn_vcc *cvp)
61 Fore_vcc *fvp = (Fore_vcc *)cvp;
62 Atm_attributes *ap = &fvp->fv_connvc->cvc_attr;
65 * Validate requested AAL
67 switch (ap->aal.type) {
70 fvp->fv_aal = FORE_AAL_0;
74 fvp->fv_aal = FORE_AAL_4;
75 if ((ap->aal.v.aal4.forward_max_SDU_size > FORE_IFF_MTU) ||
76 (ap->aal.v.aal4.backward_max_SDU_size > FORE_IFF_MTU))
81 fvp->fv_aal = FORE_AAL_5;
82 if ((ap->aal.v.aal5.forward_max_SDU_size > FORE_IFF_MTU) ||
83 (ap->aal.v.aal5.backward_max_SDU_size > FORE_IFF_MTU))
98 * This function is called via the common driver code after receiving a
99 * stack *_INIT command. The common code has already validated most of
100 * the request so we just need to check a few more Fore-specific details.
101 * Then we just issue the command to the CP. Note that we can't wait around
102 * for the CP to process the command, so we return success for now and abort
103 * the connection if the command later fails.
108 * cup pointer to device common unit
109 * cvp pointer to common VCC entry
117 fore_openvcc(Cmn_unit *cup, Cmn_vcc *cvp)
119 Fore_unit *fup = (Fore_unit *)cup;
120 Fore_vcc *fvp = (Fore_vcc *)cvp;
125 vcp = fvp->fv_connvc->cvc_vcc;
127 ATM_DEBUG4("fore_openvcc: fup=%p, fvp=%p, vcc=(%d,%d)\n",
128 fup, fvp, vcp->vc_vpi, vcp->vc_vci);
131 * Validate the VPI and VCI values
133 if ((vcp->vc_vpi > fup->fu_pif.pif_maxvpi) ||
134 (vcp->vc_vci > fup->fu_pif.pif_maxvci)) {
139 * Only need to tell the CP about incoming VCCs
141 if ((vcp->vc_type & VCC_IN) == 0) {
142 DEVICE_LOCK((Cmn_unit *)fup);
144 fvp->fv_state = CVS_ACTIVE;
145 DEVICE_UNLOCK((Cmn_unit *)fup);
150 * Queue command at end of command queue
152 hcp = fup->fu_cmd_tail;
153 if ((*hcp->hcq_status) & QSTAT_FREE) {
156 * Queue entry available, so set our view of things up
158 hcp->hcq_code = CMD_ACT_VCCIN;
160 fup->fu_cmd_tail = hcp->hcq_next;
161 fvp->fv_flags |= FVF_ACTCMD;
164 * Now set the CP-resident queue entry - the CP will grab
165 * the command when the op-code is set.
167 cqp = hcp->hcq_cpelem;
168 (*hcp->hcq_status) = QSTAT_PENDING;
169 cqp->cmdq_act.act_vccid = CP_WRITE(vcp->vc_vci);
170 if (fvp->fv_aal == FORE_AAL_0)
171 cqp->cmdq_act.act_batch = CP_WRITE(1);
172 cqp->cmdq_act.act_spec = CP_WRITE(
173 ACT_SET_SPEC(BUF_STRAT_1, fvp->fv_aal,
174 CMD_ACT_VCCIN | CMD_INTR_REQ));
179 fup->fu_stats->st_drv.drv_cm_full++;
190 * This function is called via the common driver code after receiving a
191 * stack *_TERM command. The common code has already validated most of
192 * the request so we just need to check a few more Fore-specific details.
193 * Then we just issue the command to the CP. Note that we can't wait around
194 * for the CP to process the command, so we return success for now and whine
195 * if the command later fails.
200 * cup pointer to device common unit
201 * cvp pointer to common VCC entry
209 fore_closevcc(Cmn_unit *cup, Cmn_vcc *cvp)
211 Fore_unit *fup = (Fore_unit *)cup;
212 Fore_vcc *fvp = (Fore_vcc *)cvp;
219 vcp = fvp->fv_connvc->cvc_vcc;
221 ATM_DEBUG4("fore_closevcc: fup=%p, fvp=%p, vcc=(%d,%d)\n",
222 fup, fvp, vcp->vc_vpi, vcp->vc_vci);
224 DEVICE_LOCK((Cmn_unit *)fup);
227 * Clear any references to this VCC in our transmit queue
229 for (hxp = fup->fu_xmit_head, i = 0;
230 (*hxp->hxq_status != QSTAT_FREE) && (i < XMIT_QUELEN);
231 hxp = hxp->hxq_next, i++) {
232 if (hxp->hxq_vcc == fvp) {
238 * Clear any references to this VCC in our command queue
240 for (hcp = fup->fu_cmd_head, i = 0;
241 (*hcp->hcq_status != QSTAT_FREE) && (i < CMD_QUELEN);
242 hcp = hcp->hcq_next, i++) {
243 switch (hcp->hcq_code) {
247 if (hcp->hcq_arg == fvp) {
255 * If this VCC has been previously activated, then we need to tell
256 * the CP to deactivate it.
258 if (fvp->fv_flags & FVF_ACTCMD) {
261 * Queue command at end of command queue
263 hcp = fup->fu_cmd_tail;
264 if ((*hcp->hcq_status) & QSTAT_FREE) {
267 * Queue entry available, so set our view of things up
269 hcp->hcq_code = CMD_DACT_VCCIN;
271 fup->fu_cmd_tail = hcp->hcq_next;
274 * Now set the CP-resident queue entry - the CP will
275 * grab the command when the op-code is set.
277 cqp = hcp->hcq_cpelem;
278 (*hcp->hcq_status) = QSTAT_PENDING;
279 cqp->cmdq_dact.dact_vccid = CP_WRITE(vcp->vc_vci);
280 cqp->cmdq_dact.dact_cmd =
281 CP_WRITE(CMD_DACT_VCCIN|CMD_INTR_REQ);
286 * If we get here, we'll be getting out-of-sync with
287 * the CP because we can't (for now at least) do
288 * anything about close errors in the common code.
289 * This won't be too bad, since we'll just toss any
290 * PDUs received from the VCC and the sigmgr's will
291 * always get open failures when trying to use this
292 * (vpi,vci)...oh, well...always gotta have that one
293 * last bug to fix! XXX
295 fup->fu_stats->st_drv.drv_cm_full++;
303 if (fvp->fv_state == CVS_ACTIVE)
306 DEVICE_UNLOCK((Cmn_unit *)fup);