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/hea/eni_vcm.c,v 1.3 1999/08/28 00:41:47 peter Exp $
30 * Efficient ENI Adapter Support
31 * -----------------------------
33 * Virtual Channel Managment
38 #include <netproto/atm/kern_include.h>
40 #include "eni_stats.h"
45 * VCC Stack Instantiation
47 * This function is called via the common driver code during a device VCC
48 * stack instantiation. The common code has already validated some of
49 * the request so we just need to check a few more ENI-specific details.
54 * cup pointer to device common unit
55 * cvp pointer to common VCC entry
58 * 0 instantiation successful
59 * err instantiation failed - reason indicated
63 eni_instvcc(Cmn_unit *cup, Cmn_vcc *cvp)
65 Eni_unit *eup = (Eni_unit *)cup;
66 Eni_vcc *evp = (Eni_vcc *)cvp;
67 Atm_attributes *ap = &evp->ev_connvc->cvc_attr;
70 * Validate requested AAL
72 switch (ap->aal.type) {
78 if ((ap->aal.v.aal5.forward_max_SDU_size > ENI_IFF_MTU) ||
79 (ap->aal.v.aal5.backward_max_SDU_size > ENI_IFF_MTU)) {
80 eup->eu_stats.eni_st_drv.drv_vc_maxpdu++;
96 * This function is called via the common driver code after receiving a
97 * stack *_INIT* command. The common code has already validated most of
98 * the request so we just need to check a few more ENI-specific details.
103 * cup pointer to device common unit
104 * cvp pointer to common VCC entry
112 eni_openvcc(Cmn_unit *cup, Cmn_vcc *cvp)
114 Eni_unit *eup = (Eni_unit *)cup;
115 Eni_vcc *evp = (Eni_vcc *)cvp;
116 struct vccb *vcp = evp->ev_connvc->cvc_vcc;
125 * Validate the VPI and VCI values
127 if ( (vcp->vc_vpi > eup->eu_pif.pif_maxvpi) ||
128 (vcp->vc_vci > eup->eu_pif.pif_maxvci) ) {
129 eup->eu_stats.eni_st_drv.drv_vc_badrng++;
134 * Check if this VCI is already active
136 vct = &eup->eu_vcitbl[ vcp->vc_vci ];
137 if ( vct->vci_control >> VCI_MODE_SHIFT != VCI_MODE_TRASH ) {
142 * Allocate some permanent adapter memory for the reassembly
143 * buffer. Special case the signalling channel(s) buffer size.
144 * Otherwise, the buffer size will be based on whether this is
145 * a server or client card.
147 if ( vcp->vc_vci == UNI_SIG_VCI ) /* HACK */
150 size = (eup->eu_ramsize > MAX_CLIENT_RAM * ENI_BUF_PGSZ) ?
151 RX_SERVER_BSIZE * ENI_BUF_PGSZ :
152 RX_CLIENT_BSIZE * ENI_BUF_PGSZ;
154 if ( ( evp->ev_rxbuf = eni_allocate_buffer ( eup, (u_long *)&size ) )
161 * We only need to open incoming VCI's so outbound VCI's
162 * just get set to CVS_ACTIVE state.
164 if ( ( vcp->vc_type & VCC_IN ) == 0 ) {
166 * Set the state and return - nothing else needs to be done.
168 evp->ev_state = CVS_ACTIVE;
173 * Set the VCI Table entry to start receiving
175 mode = ( evp->ev_connvc->cvc_attr.aal.type == ATM_AAL5
176 ? VCI_MODE_AAL5 : VCI_MODE_AAL0 );
177 size >>= ENI_LOC_PREDIV; /* Predivide by 256 WORDS */
178 for ( nsize = -1; size; nsize++ )
181 vct->vci_control = mode << VCI_MODE_SHIFT |
182 PTI_MODE_TRASH << VCI_PTI_SHIFT |
183 ( (u_int)(evp->ev_rxbuf) >> ENI_LOC_PREDIV ) << VCI_LOC_SHIFT |
184 nsize << VCI_SIZE_SHIFT;
185 vct->vci_descr = 0; /* Descr = Rdptr = 0 */
186 vct->vci_write = 0; /* WritePtr = CellCount = 0 */
191 evp->ev_state = CVS_ACTIVE;
199 * This function is called via the common driver code after receiving a
200 * stack *_TERM* command. The common code has already validated most of
201 * the request so we just need to check a few more ENI-specific details.
206 * cup pointer to device common unit
207 * cvp pointer to common VCC entry
215 eni_closevcc(Cmn_unit *cup, Cmn_vcc *cvp)
217 Eni_unit *eup = (Eni_unit *)cup;
218 Eni_vcc *evp = (Eni_vcc *)cvp;
219 struct vccb *vcp = evp->ev_connvc->cvc_vcc;
225 * Clear any references to this VCC in our transmit queue
228 * We'll simply allow any existing TX requests to be
229 * sent as that's easier then pulling them out of
230 * everywhere. Besides, they should be ignored at the
231 * receiver whenever the other end shuts down.
235 * Free the adapter receive buffer
237 (void) eni_free_buffer ( eup, (caddr_t)evp->ev_rxbuf );
240 * If this is an outbound only VCI, then we can close
243 if ( ( vcp->vc_type & VCC_IN ) == 0 ) {
245 * The state will be set to TERM when we return
246 * to the *_TERM caller.
252 * Find VCI entry in VCI Table
254 vct = &eup->eu_vcitbl[ vcp->vc_vci ];
257 * Reset the VCI state
259 vct->vci_control = ( vct->vci_control & VCI_MODE_MASK )
260 /* | VCI_MODE_TRASH */;
261 DELAY ( MIDWAY_DELAY ); /* Give the adapter time to */
262 /* make the transition */
267 KM_ZERO ( vct, sizeof(VCI_Table) );