Date: Wed, 30 Jul 2003 23:15:26 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 35256 for review Message-ID: <200307310615.h6V6FQr7020860@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=35256 Change 35256 by marcel@marcel_nfs on 2003/07/30 23:15:21 IFC @35254 Affected files ... .. //depot/projects/uart/alpha/alpha/machdep.c#6 integrate .. //depot/projects/uart/alpha/alpha/mp_machdep.c#5 integrate .. //depot/projects/uart/alpha/alpha/pmap.c#6 integrate .. //depot/projects/uart/alpha/alpha/vm_machdep.c#3 integrate .. //depot/projects/uart/alpha/include/param.h#2 integrate .. //depot/projects/uart/amd64/amd64/amd64_mem.c#1 branch .. //depot/projects/uart/amd64/amd64/machdep.c#4 integrate .. //depot/projects/uart/amd64/amd64/pmap.c#8 integrate .. //depot/projects/uart/amd64/include/param.h#2 integrate .. //depot/projects/uart/conf/kern.pre.mk#5 integrate .. //depot/projects/uart/ddb/db_ps.c#2 integrate .. //depot/projects/uart/dev/acpica/acpi_ec.c#7 integrate .. //depot/projects/uart/dev/ahb/ahb.c#3 integrate .. //depot/projects/uart/dev/fatm/if_fatm.c#5 integrate .. //depot/projects/uart/dev/fatm/if_fatmvar.h#2 integrate .. //depot/projects/uart/dev/hatm/if_hatm_ioctl.c#4 integrate .. //depot/projects/uart/dev/hatm/if_hatmvar.h#3 integrate .. //depot/projects/uart/dev/utopia/utopia.c#3 integrate .. //depot/projects/uart/i386/acpica/acpi_wakeup.c#4 integrate .. //depot/projects/uart/i386/i386/busdma_machdep.c#5 integrate .. //depot/projects/uart/i386/i386/identcpu.c#2 integrate .. //depot/projects/uart/i386/i386/machdep.c#3 integrate .. //depot/projects/uart/i386/i386/pmap.c#7 integrate .. //depot/projects/uart/i386/i386/sys_machdep.c#3 integrate .. //depot/projects/uart/i386/include/pcpu.h#2 integrate .. //depot/projects/uart/ia64/ia64/machdep.c#4 integrate .. //depot/projects/uart/ia64/ia64/mp_machdep.c#2 integrate .. //depot/projects/uart/ia64/ia64/pmap.c#6 integrate .. //depot/projects/uart/ia64/ia64/vm_machdep.c#2 integrate .. //depot/projects/uart/ia64/include/param.h#2 integrate .. //depot/projects/uart/kern/kern_mutex.c#3 integrate .. //depot/projects/uart/kern/kern_sig.c#8 integrate .. //depot/projects/uart/kern/subr_trap.c#2 integrate .. //depot/projects/uart/kern/sys_pipe.c#4 integrate .. //depot/projects/uart/pc98/i386/machdep.c#3 integrate .. //depot/projects/uart/powerpc/include/param.h#2 integrate .. //depot/projects/uart/powerpc/powerpc/machdep.c#3 integrate .. //depot/projects/uart/powerpc/powerpc/pmap.c#5 integrate .. //depot/projects/uart/powerpc/powerpc/vm_machdep.c#2 integrate .. //depot/projects/uart/sparc64/include/param.h#2 integrate .. //depot/projects/uart/sparc64/sparc64/genassym.c#3 integrate .. //depot/projects/uart/sparc64/sparc64/machdep.c#3 integrate .. //depot/projects/uart/sparc64/sparc64/pmap.c#5 integrate .. //depot/projects/uart/sparc64/sparc64/vm_machdep.c#2 integrate .. //depot/projects/uart/sys/param.h#4 integrate .. //depot/projects/uart/vm/uma_core.c#5 integrate .. //depot/projects/uart/vm/uma_int.h#2 integrate .. //depot/projects/uart/vm/vm_glue.c#2 integrate Differences ... ==== //depot/projects/uart/alpha/alpha/machdep.c#6 (text+ko) ==== @@ -88,10 +88,11 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/alpha/alpha/machdep.c,v 1.208 2003/07/27 23:45:47 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/alpha/machdep.c,v 1.211 2003/07/31 05:27:00 marcel Exp $"); #include "opt_compat.h" #include "opt_ddb.h" +#include "opt_kstack_pages.h" #include "opt_msgbuf.h" #include "opt_maxmem.h" @@ -2030,6 +2031,7 @@ if (clear_ret != 0) { mcp->mc_regs[FRAME_V0] = 0; mcp->mc_regs[FRAME_A4] = 0; + mcp->mc_regs[FRAME_A3] = 0; } /* @@ -2081,6 +2083,9 @@ if (td == curthread) { alpha_pal_wrusp(mcp->mc_regs[FRAME_SP]); alpha_pal_wrunique(mcp->mc_thrptr); + } else { + td->td_pcb->pcb_hw.apcb_usp = mcp->mc_regs[FRAME_SP]; + td->td_pcb->pcb_hw.apcb_unique = mcp->mc_thrptr; } /* ==== //depot/projects/uart/alpha/alpha/mp_machdep.c#5 (text+ko) ==== @@ -25,7 +25,9 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/alpha/alpha/mp_machdep.c,v 1.45 2003/07/27 23:45:48 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/alpha/mp_machdep.c,v 1.46 2003/07/31 01:31:31 peter Exp $"); + +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> ==== //depot/projects/uart/alpha/alpha/pmap.c#6 (text+ko) ==== @@ -148,7 +148,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/alpha/alpha/pmap.c,v 1.131 2003/07/25 18:58:39 alc Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/alpha/pmap.c,v 1.132 2003/07/31 03:39:50 bmilekic Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -642,7 +642,7 @@ if (initial_pvs < MINPV) initial_pvs = MINPV; pvzone = uma_zcreate("PV ENTRY", sizeof (struct pv_entry), NULL, NULL, - NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM); + NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM | UMA_ZONE_NOFREE); uma_prealloc(pvzone, initial_pvs); /* ==== //depot/projects/uart/alpha/alpha/vm_machdep.c#3 (text+ko) ==== @@ -67,7 +67,9 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/alpha/alpha/vm_machdep.c,v 1.89 2003/07/27 23:45:48 marcel Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/alpha/vm_machdep.c,v 1.91 2003/07/31 01:31:31 peter Exp $"); + +#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> @@ -260,7 +262,8 @@ { td->td_pcb = - (struct pcb *)(td->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + (struct pcb *)(td->td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1; + td->td_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)td->td_pcb); td->td_frame = (struct trapframe *)((caddr_t)td->td_pcb) - 1; } ==== //depot/projects/uart/alpha/include/param.h#2 (text+ko) ==== @@ -1,4 +1,4 @@ -/* $FreeBSD: src/sys/alpha/include/param.h,v 1.31 2003/06/14 23:23:52 alc Exp $ */ +/* $FreeBSD: src/sys/alpha/include/param.h,v 1.32 2003/07/31 01:31:31 peter Exp $ */ /* From: NetBSD: param.h,v 1.20 1997/09/19 13:52:53 leo Exp */ /* @@ -117,7 +117,9 @@ #define SSIZE 1 /* initial stack size/NBPG */ #define SINCR 1 /* increment of stack/NBPG */ +#ifndef KSTACK_PAGES #define KSTACK_PAGES 2 /* pages of kstack (with pcb) */ +#endif #define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ #define UAREA_PAGES 1 /* pages of u-area */ ==== //depot/projects/uart/amd64/amd64/machdep.c#4 (text+ko) ==== @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.587 2003/07/25 21:15:44 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/machdep.c,v 1.588 2003/07/31 01:26:39 peter Exp $"); #include "opt_atalk.h" #include "opt_compat.h" @@ -47,10 +47,10 @@ #include "opt_inet.h" #include "opt_ipx.h" #include "opt_isa.h" +#include "opt_kstack_pages.h" #include "opt_maxmem.h" #include "opt_msgbuf.h" #include "opt_perfmon.h" -#include "opt_kstack_pages.h" #include <sys/param.h> #include <sys/systm.h> ==== //depot/projects/uart/amd64/amd64/pmap.c#8 (text+ko) ==== @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.426 2003/07/25 21:15:44 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/amd64/pmap.c,v 1.427 2003/07/31 03:39:50 bmilekic Exp $"); /* * Manages physical address maps. @@ -610,7 +610,7 @@ if (initial_pvs < MINPV) initial_pvs = MINPV; pvzone = uma_zcreate("PV ENTRY", sizeof (struct pv_entry), NULL, NULL, - NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM); + NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_VM | UMA_ZONE_NOFREE); uma_zone_set_allocf(pvzone, pmap_pv_allocf); uma_prealloc(pvzone, initial_pvs); ==== //depot/projects/uart/amd64/include/param.h#2 (text+ko) ==== @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)param.h 8.1 (Berkeley) 6/10/93 - * $FreeBSD: src/sys/amd64/include/param.h,v 1.7 2003/06/14 23:23:53 alc Exp $ + * $FreeBSD: src/sys/amd64/include/param.h,v 1.8 2003/07/31 01:27:18 peter Exp $ */ /* @@ -117,7 +117,9 @@ #define IOPAGES 2 /* pages of i/o permission bitmap */ +#ifndef KSTACK_PAGES #define KSTACK_PAGES 4 /* pages of kstack (with pcb) */ +#endif #define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ #define UAREA_PAGES 1 /* holds struct user WITHOUT PCB (see def.) */ ==== //depot/projects/uart/conf/kern.pre.mk#5 (text+ko) ==== @@ -3,7 +3,7 @@ # Unified Makefile for building kernels. This includes all the definitions # that need to be included before %BEFORE_DEPEND # -# $FreeBSD: src/sys/conf/kern.pre.mk,v 1.32 2003/07/26 03:46:39 peter Exp $ +# $FreeBSD: src/sys/conf/kern.pre.mk,v 1.33 2003/07/30 22:11:36 scottl Exp $ # # Can be overridden by makeoptions or /etc/make.conf @@ -54,7 +54,7 @@ DEFINED_PROF= ${PROF} WERROR?= -Werror INLINE_LIMIT?= 15000 -CFLAGS+= -finline-limit=${INLINE_LIMIT} +CFLAGS+= -finline-limit=${INLINE_LIMIT} -fno-strict-aliasing # Put configuration-specific C flags last (except for ${PROF}) so that they ==== //depot/projects/uart/ddb/db_ps.c#2 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/ddb/db_ps.c,v 1.46 2003/06/15 00:31:22 davidxu Exp $"); +__FBSDID("$FreeBSD: src/sys/ddb/db_ps.c,v 1.47 2003/07/30 20:59:36 jhb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -145,6 +145,7 @@ static void dumpthread(volatile struct proc *p, volatile struct thread *td) { + if (p->p_flag & P_SA) db_printf( " thread %p ksegrp %p ", td, td->td_ksegrp); if (TD_ON_SLEEPQ(td)) { ==== //depot/projects/uart/dev/acpica/acpi_ec.c#7 (text+ko) ==== @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.37 2003/07/25 16:49:46 njl Exp $ + * $FreeBSD: src/sys/dev/acpica/acpi_ec.c,v 1.38 2003/07/30 16:22:52 njl Exp $ */ /****************************************************************************** * @@ -288,6 +288,9 @@ ((event) == EC_EVENT_INPUT_BUFFER_EMPTY && \ ((status) & EC_FLAG_INPUT_BUFFER) == 0)) +static int ec_poll_timeout = EC_POLL_TIMEOUT; +TUNABLE_INT("hw.acpi.ec.poll_timeout", &ec_poll_timeout); + static __inline ACPI_STATUS EcLock(struct acpi_ec_softc *sc) { @@ -792,12 +795,12 @@ sc->ec_polldelay = 100; /* - * If we still don't have a response, wait up to EC_POLL_TIMEOUT ms + * If we still don't have a response, wait up to ec_poll_timeout ms * for completion, sleeping for chunks of 10 ms. */ if (Status != AE_OK) { retval = -1; - for (i = 0; i < EC_POLL_TIMEOUT / 10; i++) { + for (i = 0; i < ec_poll_timeout / 10; i++) { if (retval != 0) EcStatus = EC_GET_CSR(sc); else ==== //depot/projects/uart/dev/ahb/ahb.c#3 (text+ko) ==== @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/ahb/ahb.c,v 1.30 2003/07/01 15:51:52 scottl Exp $ + * $FreeBSD: src/sys/dev/ahb/ahb.c,v 1.31 2003/07/30 20:09:22 gallatin Exp $ */ #include <sys/param.h> @@ -140,7 +140,8 @@ ahbecbptov(struct ahb_softc *ahb, u_int32_t ecb_addr) { return (ahb->ecb_array - + ((struct ecb*)ecb_addr - (struct ecb*)ahb->ecb_physbase)); + + ((struct ecb*)(uintptr_t)ecb_addr + - (struct ecb*)(uintptr_t)ahb->ecb_physbase)); } static __inline u_int32_t ==== //depot/projects/uart/dev/fatm/if_fatm.c#5 (text+ko) ==== @@ -29,7 +29,7 @@ * Fore PCA200E driver for NATM */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/fatm/if_fatm.c,v 1.4 2003/07/29 14:00:59 harti Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/fatm/if_fatm.c,v 1.5 2003/07/30 14:20:00 harti Exp $"); #include "opt_inet.h" #include "opt_natm.h" @@ -48,6 +48,7 @@ #include <sys/endian.h> #include <sys/sysctl.h> #include <sys/condvar.h> +#include <vm/uma.h> #include <sys/sockio.h> #include <sys/mbuf.h> @@ -520,9 +521,13 @@ sc->small_cnt = sc->large_cnt = 0; /* Reset vcc info */ - if (sc->vccs != NULL) - for (i = 0; i <= FORE_MAX_VCC; i++) - sc->vccs[i].flags = 0; + if (sc->vccs != NULL) { + for (i = 0; i < FORE_MAX_VCC + 1; i++) + if (sc->vccs[i] != NULL) { + uma_zfree(sc->vcc_zone, sc->vccs[i]); + sc->vccs[i] = NULL; + } + } sc->open_vccs = 0; } @@ -1446,7 +1451,7 @@ fatm_intr_drain_rx(struct fatm_softc *sc) { struct rxqueue *q; - int stat, mlen, drop; + int stat, mlen; u_int i; uint32_t h; struct mbuf *last, *m0; @@ -1455,6 +1460,7 @@ u_int vci, vpi, pt; struct atm_pseudohdr aph; struct ifnet *ifp; + struct card_vcc *vc; for (;;) { q = GET_QUEUE(sc->rxqueue, struct rxqueue, sc->rxqueue.tail); @@ -1469,7 +1475,6 @@ H_SYNCQ_POSTREAD(&sc->rxq_mem, rpd, RPD_SIZE); rpd->nseg = le32toh(rpd->nseg); - drop = 0; mlen = 0; m0 = last = 0; for (i = 0; i < rpd->nseg; i++) { @@ -1509,26 +1514,30 @@ * Locate the VCC this packet belongs to */ if (!VC_OK(sc, vpi, vci)) - drop = 1; - else if ((sc->vccs[vci].flags & FATM_VCC_OPEN) == 0) { + vc = NULL; + else if ((vc = sc->vccs[vci]) == NULL || + !(sc->vccs[vci]->vflags & FATM_VCC_OPEN)) { sc->istats.rx_closed++; - drop = 1; + vc = NULL; } DBG(sc, RCV, ("RCV: vc=%u.%u pt=%u mlen=%d %s", vpi, vci, - pt, mlen, drop ? "dropped" : "")); + pt, mlen, vc == NULL ? "dropped" : "")); - if (drop) { + if (vc == NULL) { m_freem(m0); } else { - ATM_PH_FLAGS(&aph) = sc->vccs[vci].flags & 0xff; + ATM_PH_FLAGS(&aph) = vc->param.flags; ATM_PH_VPI(&aph) = vpi; ATM_PH_SETVCI(&aph, vci); ifp = &sc->ifatm.ifnet; ifp->if_ipackets++; - atm_input(ifp, &aph, m0, sc->vccs[vci].rxhand); + vc->ipackets++; + vc->ibytes += m0->m_pkthdr.len; + + atm_input(ifp, &aph, m0, vc->rxhand); } H_SETSTAT(q->q.statp, FATM_STAT_FREE); @@ -1895,7 +1904,7 @@ * Note, that we update the internal statistics without the lock here. */ static int -fatm_tx(struct fatm_softc *sc, struct mbuf *m, u_int vpi, u_int vci, u_int mlen) +fatm_tx(struct fatm_softc *sc, struct mbuf *m, struct card_vcc *vc, u_int mlen) { struct txqueue *q; u_int nblks; @@ -1948,7 +1957,7 @@ /* * OK. Now go and do it. */ - aal = (sc->vccs[vci].aal == ATMIO_AAL_5) ? 5 : 0; + aal = (vc->param.aal == ATMIO_AAL_5) ? 5 : 0; H_SETSTAT(q->q.statp, FATM_STAT_PENDING); H_SYNCSTAT_PREWRITE(sc, q->q.statp); @@ -1961,15 +1970,16 @@ */ H_SETDESC(tpd->spec, TDX_MKSPEC((sc->txcnt >= (4 * FATM_TX_QLEN) / 5), aal, nsegs, mlen)); - H_SETDESC(tpd->atm_header, TDX_MKHDR(vpi, vci, 0, 0)); + H_SETDESC(tpd->atm_header, TDX_MKHDR(vc->param.vpi, + vc->param.vci, 0, 0)); - if (sc->vccs[vci].traffic == ATMIO_TRAFFIC_UBR) + if (vc->param.traffic == ATMIO_TRAFFIC_UBR) H_SETDESC(tpd->stream, 0); else { u_int i; for (i = 0; i < RATE_TABLE_SIZE; i++) - if (rate_table[i].cell_rate < sc->vccs[vci].pcr) + if (rate_table[i].cell_rate < vc->param.tparam.pcr) break; if (i > 0) i--; @@ -1987,6 +1997,8 @@ sc->txcnt++; sc->ifatm.ifnet.if_opackets++; + vc->obytes += m->m_pkthdr.len; + vc->opackets++; NEXT_QUEUE_ENTRY(sc->txqueue.head, FATM_TX_QLEN); @@ -2000,6 +2012,7 @@ struct fatm_softc *sc; struct mbuf *m; u_int mlen, vpi, vci; + struct card_vcc *vc; sc = (struct fatm_softc *)ifp->if_softc; @@ -2048,13 +2061,13 @@ m_freem(m); break; } - if (!VC_OK(sc, vpi, vci) || - !(sc->vccs[vci].flags & FATM_VCC_OPEN)) { + if (!VC_OK(sc, vpi, vci) || (vc = sc->vccs[vci]) == NULL || + !(vc->vflags & FATM_VCC_OPEN)) { FATM_UNLOCK(sc); m_freem(m); continue; } - if (fatm_tx(sc, m, vpi, vci, mlen)) { + if (fatm_tx(sc, m, vc, mlen)) { FATM_UNLOCK(sc); break; } @@ -2063,52 +2076,6 @@ } /* - * Return a table of all currently open VCCs. - */ -static struct atmio_vcctable * -get_vccs(struct fatm_softc *sc, int flags) -{ - struct atmio_vcctable *vccs; - struct atmio_vcc *v; - u_int i, alloc; - - alloc = 10; - vccs = NULL; - for (;;) { - vccs = reallocf(vccs, - sizeof(*vccs) + alloc * sizeof(vccs->vccs[0]), - M_DEVBUF, flags); - if (vccs == NULL) - return (NULL); - - vccs->count = 0; - FATM_LOCK(sc); - v = vccs->vccs; - for (i = 0; i < (1U << sc->ifatm.mib.vci_bits); i++) { - if (sc->vccs[i].flags & FATM_VCC_OPEN) { - if (vccs->count++ == alloc) { - alloc *= 2; - break; - } - v->vpi = 0; - v->vci = i; - v->flags = sc->vccs[i].flags; - v->aal = sc->vccs[i].aal; - v->traffic = sc->vccs[i].traffic; - bzero(&v->tparam, sizeof(v->tparam)); - v->tparam.pcr = sc->vccs[i].pcr; - v++; - } - } - if (i == (1U << sc->ifatm.mib.vci_bits)) - break; - FATM_UNLOCK(sc); - } - FATM_UNLOCK(sc); - return (vccs); -} - -/* * VCC managment * * This may seem complicated. The reason for this is, that we need an @@ -2153,79 +2120,57 @@ } /* - * Start to open a VCC. This just initiates the operation. + * The VC has been opened/closed and somebody has been waiting for this. + * Wake him up. */ -static int -fatm_start_open_vcc(struct fatm_softc *sc, u_int vpi, u_int vci, u_int aal, - u_int traffic, u_int pcr, u_int flags, void *rxhand, - void (*func)(struct fatm_softc *, struct cmdqueue *), struct cmdqueue **qp) +static void +fatm_cmd_complete(struct fatm_softc *sc, struct cmdqueue *q) { - int error; - uint32_t cmd; - struct cmdqueue *q; - error = 0; + H_SYNCSTAT_POSTREAD(sc, q->q.statp); + if (H_GETSTAT(q->q.statp) & FATM_STAT_ERROR) { + sc->istats.get_stat_errors++; + q->error = EIO; + } + wakeup(q); +} - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) - return (EIO); - if (!VC_OK(sc, vpi, vci) || - (aal != ATMIO_AAL_0 && aal != ATMIO_AAL_5) || - (traffic != ATMIO_TRAFFIC_UBR && traffic != ATMIO_TRAFFIC_CBR)) - return (EINVAL); - if (sc->vccs[vci].flags & FATM_VCC_BUSY) - return (EBUSY); +/* + * Open complete + */ +static void +fatm_open_finish(struct fatm_softc *sc, struct card_vcc *vc) +{ + vc->vflags &= ~FATM_VCC_TRY_OPEN; + vc->vflags |= FATM_VCC_OPEN; - /* Command and buffer strategy */ - cmd = FATM_OP_ACTIVATE_VCIN | FATM_OP_INTERRUPT_SEL | (0 << 16); - if (aal == ATMIO_AAL_0) - cmd |= (0 << 8); - else - cmd |= (5 << 8); - - if ((q = fatm_start_vcc(sc, vpi, vci, cmd, 1, func)) == NULL) - return (EIO); - if (qp != NULL) - *qp = q; - - sc->vccs[vci].aal = aal; - sc->vccs[vci].flags = flags | FATM_VCC_TRY_OPEN; - sc->vccs[vci].rxhand = rxhand; - sc->vccs[vci].pcr = pcr; - sc->vccs[vci].traffic = traffic; - - return (0); + /* inform management if this is not an NG + * VCC or it's an NG PVC. */ + if (!(vc->param.flags & ATMIO_FLAG_NG) || + (vc->param.flags & ATMIO_FLAG_PVC)) + ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vc->param.vci, 1); } /* - * Initiate closing a VCC + * The VC that we have tried to open asynchronuosly has been opened. */ -static int -fatm_start_close_vcc(struct fatm_softc *sc, u_int vpi, u_int vci, - void (*func)(struct fatm_softc *, struct cmdqueue *), struct cmdqueue **qp) +static void +fatm_open_complete(struct fatm_softc *sc, struct cmdqueue *q) { - int error; - struct cmdqueue *q; + u_int vci; + struct card_vcc *vc; - error = 0; - - if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) - return (EIO); - if (!VC_OK(sc, vpi, vci)) - return (EINVAL); - if (!(sc->vccs[vci].flags & (FATM_VCC_OPEN | FATM_VCC_TRY_OPEN))) - return (ENOENT); - - if ((q = fatm_start_vcc(sc, vpi, vci, - FATM_OP_DEACTIVATE_VCIN | FATM_OP_INTERRUPT_SEL, 1, func)) == NULL) - return (EIO); - - if (qp != NULL) - *qp = q; - - sc->vccs[vci].flags &= ~(FATM_VCC_OPEN | FATM_VCC_TRY_OPEN); - sc->vccs[vci].flags |= FATM_VCC_TRY_CLOSE; - - return (0); + vci = GETVCI(READ4(sc, q->q.card + FATMOC_ACTIN_VPVC)); + vc = sc->vccs[vci]; + H_SYNCSTAT_POSTREAD(sc, q->q.statp); + if (H_GETSTAT(q->q.statp) & FATM_STAT_ERROR) { + sc->istats.get_stat_errors++; + sc->vccs[vci] = NULL; + uma_zfree(sc->vcc_zone, vc); + if_printf(&sc->ifatm.ifnet, "opening VCI %u failed\n", vci); + return; + } + fatm_open_finish(sc, vc); } /* @@ -2247,119 +2192,121 @@ } /* - * The VC has been opened/closed and somebody has been waiting for this. - * Wake him up. - */ -static void -fatm_cmd_complete(struct fatm_softc *sc, struct cmdqueue *q) -{ - - H_SYNCSTAT_POSTREAD(sc, q->q.statp); - if (H_GETSTAT(q->q.statp) & FATM_STAT_ERROR) { - sc->istats.get_stat_errors++; - q->error = EIO; - } - wakeup(q); -} - -/* - * Open a vcc and wait for completion + * Start to open a VCC. This just initiates the operation. */ static int -fatm_open_vcc(struct fatm_softc *sc, u_int vpi, u_int vci, u_int flags, - u_int aal, u_int traffic, u_int pcr, void *rxhand) +fatm_open_vcc(struct fatm_softc *sc, struct atmio_openvcc *op, int wait) { + uint32_t cmd; int error; struct cmdqueue *q; + struct card_vcc *vc; + + /* + * Check parameters + */ + if ((op->param.flags & ATMIO_FLAG_NOTX) && + (op->param.flags & ATMIO_FLAG_NORX)) + return (EINVAL); + if (!VC_OK(sc, op->param.vpi, op->param.vci)) + return (EINVAL); + if (op->param.aal != ATMIO_AAL_0 && op->param.aal != ATMIO_AAL_5) + return (EINVAL); + + vc = uma_zalloc(sc->vcc_zone, M_NOWAIT | M_ZERO); + if (vc == NULL) + return (ENOMEM); + error = 0; FATM_LOCK(sc); - error = fatm_start_open_vcc(sc, vpi, vci, aal, traffic, pcr, - flags, rxhand, fatm_cmd_complete, &q); - if (error != 0) { - FATM_UNLOCK(sc); - return (error); + if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { + error = EIO; + goto done; + } + if (sc->vccs[op->param.vci] != NULL) { + error = EBUSY; + goto done; } - error = fatm_waitvcc(sc, q); + vc->param = op->param; + vc->rxhand = op->rxhand; - if (error == 0) { - sc->vccs[vci].flags &= ~FATM_VCC_TRY_OPEN; - sc->vccs[vci].flags |= FATM_VCC_OPEN; - sc->open_vccs++; + switch (op->param.traffic) { - /* inform management if this is not an NG - * VCC or it's an NG PVC. */ - if (!(sc->vccs[vci].flags & ATMIO_FLAG_NG) || - (sc->vccs[vci].flags & ATMIO_FLAG_PVC)) - ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vci, 1); - } else - bzero(&sc->vccs[vci], sizeof(sc->vccs[vci])); + case ATMIO_TRAFFIC_UBR: + break; - FATM_UNLOCK(sc); - return (error); -} + case ATMIO_TRAFFIC_CBR: + if (op->param.tparam.pcr == 0 || + op->param.tparam.pcr > sc->ifatm.mib.pcr) { + error = EINVAL; + goto done; + } + break; -/* - * Close a VCC synchronuosly - */ -static int -fatm_close_vcc(struct fatm_softc *sc, u_int vpi, u_int vci) -{ - int error; - struct cmdqueue *q; + default: + error = EINVAL; + goto done; + return (EINVAL); + } + vc->ibytes = vc->obytes = 0; + vc->ipackets = vc->opackets = 0; - error = 0; + /* Command and buffer strategy */ + cmd = FATM_OP_ACTIVATE_VCIN | FATM_OP_INTERRUPT_SEL | (0 << 16); + if (op->param.aal == ATMIO_AAL_0) + cmd |= (0 << 8); + else + cmd |= (5 << 8); - FATM_LOCK(sc); - error = fatm_start_close_vcc(sc, vpi, vci, fatm_cmd_complete, &q); - if (error != 0) { - FATM_UNLOCK(sc); - return (error); + q = fatm_start_vcc(sc, op->param.vpi, op->param.vci, cmd, 1, + wait ? fatm_cmd_complete : fatm_open_complete); + if (q == NULL) { + error = EIO; + goto done; } - error = fatm_waitvcc(sc, q); - if (error == 0) { - /* inform management of this is not an NG - * VCC or it's an NG PVC. */ - if (!(sc->vccs[vci].flags & ATMIO_FLAG_NG) || - (sc->vccs[vci].flags & ATMIO_FLAG_PVC)) - ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vci, 0); + vc->vflags = FATM_VCC_TRY_OPEN; + sc->vccs[op->param.vci] = vc; + sc->open_vccs++; - bzero(&sc->vccs[vci], sizeof(sc->vccs[vci])); - sc->open_vccs--; + if (wait) { + error = fatm_waitvcc(sc, q); + if (error != 0) { + sc->vccs[op->param.vci] = NULL; + sc->open_vccs--; + goto done; + } + fatm_open_finish(sc, vc); } + /* don't free below */ + vc = NULL; + + done: FATM_UNLOCK(sc); + if (vc != NULL) + uma_zfree(sc->vcc_zone, vc); return (error); } /* - * The VC has been opened. + * Finish close */ static void -fatm_open_complete(struct fatm_softc *sc, struct cmdqueue *q) +fatm_close_finish(struct fatm_softc *sc, struct card_vcc *vc) { - u_int vci; + /* inform management of this is not an NG + * VCC or it's an NG PVC. */ + if (!(vc->param.flags & ATMIO_FLAG_NG) || + (vc->param.flags & ATMIO_FLAG_PVC)) + ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vc->param.vci, 0); - vci = GETVCI(READ4(sc, q->q.card + FATMOC_ACTIN_VPVC)); - H_SYNCSTAT_POSTREAD(sc, q->q.statp); - if (H_GETSTAT(q->q.statp) & FATM_STAT_ERROR) { - sc->istats.get_stat_errors++; - bzero(&sc->vccs[vci], sizeof(sc->vccs[vci])); - if_printf(&sc->ifatm.ifnet, "opening VCI %u failed\n", vci); - return; - } + sc->vccs[vc->param.vci] = NULL; + sc->open_vccs--; - sc->vccs[vci].flags &= ~FATM_VCC_TRY_OPEN; - sc->vccs[vci].flags |= FATM_VCC_OPEN; - sc->open_vccs++; - - /* inform management if this is not an NG - * VCC or it's an NG PVC. */ - if (!(sc->vccs[vci].flags & ATMIO_FLAG_NG) || - (sc->vccs[vci].flags & ATMIO_FLAG_PVC)) - ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vci, 1); + uma_zfree(sc->vcc_zone, vc); } /* @@ -2369,8 +2316,10 @@ fatm_close_complete(struct fatm_softc *sc, struct cmdqueue *q) { u_int vci; + struct card_vcc *vc; vci = GETVCI(READ4(sc, q->q.card + FATMOC_ACTIN_VPVC)); + vc = sc->vccs[vci]; H_SYNCSTAT_POSTREAD(sc, q->q.statp); if (H_GETSTAT(q->q.statp) & FATM_STAT_ERROR) { sc->istats.get_stat_errors++; @@ -2379,42 +2328,55 @@ return; } - /* inform management of this is not an NG - * VCC or it's an NG PVC. */ - if (!(sc->vccs[vci].flags & ATMIO_FLAG_NG) || - (sc->vccs[vci].flags & ATMIO_FLAG_PVC)) - ATMEV_SEND_VCC_CHANGED(&sc->ifatm, 0, vci, 0); - - bzero(&sc->vccs[vci], sizeof(sc->vccs[vci])); - sc->open_vccs--; + fatm_close_finish(sc, vc); } /* - * Open a vcc but don't wait. + * Initiate closing a VCC */ static int -fatm_open_vcc_nowait(struct fatm_softc *sc, u_int vpi, u_int vci, u_int flags, - u_int aal, void *rxhand) +fatm_close_vcc(struct fatm_softc *sc, struct atmio_closevcc *cl, int wait) { int error; + struct cmdqueue *q; + struct card_vcc *vc; + + if (!VC_OK(sc, cl->vpi, cl->vci)) + return (EINVAL); + error = 0; + FATM_LOCK(sc); - error = fatm_start_open_vcc(sc, vpi, vci, aal, ATMIO_TRAFFIC_UBR, 0, - flags, rxhand, fatm_open_complete, NULL); - FATM_UNLOCK(sc); - return (error); -} + if (!(sc->ifatm.ifnet.if_flags & IFF_RUNNING)) { + error = EIO; + goto done; + } + vc = sc->vccs[cl->vci]; + if (vc == NULL || !(vc->vflags & (FATM_VCC_OPEN | FATM_VCC_TRY_OPEN))) { + error = ENOENT; + goto done; + } + + q = fatm_start_vcc(sc, cl->vpi, cl->vci, + FATM_OP_DEACTIVATE_VCIN | FATM_OP_INTERRUPT_SEL, 1, + wait ? fatm_cmd_complete : fatm_close_complete); + if (q == NULL) { + error = EIO; + goto done; + } + + vc->vflags &= ~(FATM_VCC_OPEN | FATM_VCC_TRY_OPEN); + vc->vflags |= FATM_VCC_TRY_CLOSE; + + if (wait) { + error = fatm_waitvcc(sc, q); + if (error != 0) + goto done; -/* - * Close a VCC but don't wait - */ -static int -fatm_close_vcc_nowait(struct fatm_softc *sc, u_int vpi, u_int vci) -{ - int error; + fatm_close_finish(sc, vc); + } - FATM_LOCK(sc); - error = fatm_start_close_vcc(sc, vpi, vci, fatm_close_complete, NULL); + done: FATM_UNLOCK(sc); return (error); } @@ -2433,30 +2395,38 @@ struct atmio_openvcc *op = (struct atmio_openvcc *)arg; struct atm_pseudoioctl *pa = (struct atm_pseudoioctl *)arg; struct atmio_vcctable *vtab; + struct atmio_openvcc ena; + struct atmio_closevcc dis; error = 0; switch (cmd) { case SIOCATMENA: /* internal NATM use */ - error = fatm_open_vcc_nowait(sc, ATM_PH_VPI(&pa->aph), - ATM_PH_VCI(&pa->aph), ATM_PH_FLAGS(&pa->aph), - (ATM_PH_FLAGS(&pa->aph) & ATM_PH_AAL5) ? ATMIO_AAL_5 : - ATMIO_AAL_0, pa->rxhand); + bzero(&ena, sizeof(ena)); + ena.param.flags = ATM_PH_FLAGS(&pa->aph) & + (ATM_PH_AAL5 | ATM_PH_LLCSNAP); + ena.param.vpi = ATM_PH_VPI(&pa->aph); + ena.param.vci = ATM_PH_VCI(&pa->aph); + ena.param.aal = (ATM_PH_FLAGS(&pa->aph) & ATM_PH_AAL5) ? + ATMIO_AAL_5 : ATMIO_AAL_0; + ena.param.traffic = ATMIO_TRAFFIC_UBR; + ena.rxhand = pa->rxhand; >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307310615.h6V6FQr7020860>