From delphij at FreeBSD.org Sun Nov 2 14:43:38 2008 From: delphij at FreeBSD.org (Xin LI) Date: Sun Nov 2 14:43:53 2008 Subject: svn commit: r184569 - in stable/7/sys: . dev/aac Message-ID: <200811022243.mA2MhcRf049860@svn.freebsd.org> Author: delphij Date: Sun Nov 2 22:43:37 2008 New Revision: 184569 URL: http://svn.freebsd.org/changeset/base/184569 Log: MFC revisions 180072 and 182967 by emaste: Add explicit PCI IDs for the following Adaptec RAID Series 2 adapters: Adaptec RAID 2045 Adaptec RAID 2405 Adaptec RAID 2445 Adaptec RAID 2805 Without this change these devices are supported by the driver's family support, but they then appear as "Adaptec RAID Controller" in boot messages and the dev.aac.0.%desc sysctl. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/dev/aac/aac_pci.c Modified: stable/7/sys/dev/aac/aac_pci.c ============================================================================== --- stable/7/sys/dev/aac/aac_pci.c Sun Nov 2 20:22:24 2008 (r184568) +++ stable/7/sys/dev/aac/aac_pci.c Sun Nov 2 22:43:37 2008 (r184569) @@ -245,7 +245,15 @@ struct aac_ident {0x9005, 0x0285, 0x9005, 0x02d0, AAC_HWIF_I960RX, 0, "Adaptec RAID 52445"}, {0x9005, 0x0285, 0x9005, 0x02d1, AAC_HWIF_I960RX, 0, - "Adaptec RAID 5405"}, + "Adaptec RAID 5405"}, + {0x9005, 0x0285, 0x9005, 0x02d4, AAC_HWIF_I960RX, 0, + "Adaptec RAID 2045"}, + {0x9005, 0x0285, 0x9005, 0x02d5, AAC_HWIF_I960RX, 0, + "Adaptec RAID 2405"}, + {0x9005, 0x0285, 0x9005, 0x02d6, AAC_HWIF_I960RX, 0, + "Adaptec RAID 2445"}, + {0x9005, 0x0285, 0x9005, 0x02d7, AAC_HWIF_I960RX, 0, + "Adaptec RAID 2805"}, {0x9005, 0x0286, 0x1014, 0x9580, AAC_HWIF_RKT, 0, "IBM ServeRAID-8k"}, {0x9005, 0x0285, 0x1014, 0x034d, AAC_HWIF_I960RX, 0, From kib at FreeBSD.org Mon Nov 3 06:08:09 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Nov 3 06:08:21 2008 Subject: svn commit: r184590 - in stable/7/sys: . kern ufs/ffs Message-ID: <200811031408.mA3E89Bx068087@svn.freebsd.org> Author: kib Date: Mon Nov 3 14:08:08 2008 New Revision: 184590 URL: http://svn.freebsd.org/changeset/base/184590 Log: MFC r184074: Assert that v_holdcnt is non-zero before entering lockmgr in vn_lock and ffs_lock. This cannot catch situations where holdcnt is incremented not by curthread, but I think it is useful. Approved by: re (kensmith) Modified: stable/7/sys/ (props changed) stable/7/sys/kern/vfs_vnops.c stable/7/sys/ufs/ffs/ffs_vnops.c Modified: stable/7/sys/kern/vfs_vnops.c ============================================================================== --- stable/7/sys/kern/vfs_vnops.c Mon Nov 3 10:39:35 2008 (r184589) +++ stable/7/sys/kern/vfs_vnops.c Mon Nov 3 14:08:08 2008 (r184590) @@ -800,6 +800,10 @@ _vn_lock(struct vnode *vp, int flags, st do { if ((flags & LK_INTERLOCK) == 0) VI_LOCK(vp); +#ifdef DEBUG_VFS_LOCKS + KASSERT(vp->v_holdcnt != 0, + ("vn_lock %p: zero hold count", vp)); +#endif if ((flags & LK_NOWAIT || (flags & LK_TYPE_MASK) == 0) && vp->v_iflag & VI_DOOMED) { VI_UNLOCK(vp); Modified: stable/7/sys/ufs/ffs/ffs_vnops.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_vnops.c Mon Nov 3 10:39:35 2008 (r184589) +++ stable/7/sys/ufs/ffs/ffs_vnops.c Mon Nov 3 14:08:08 2008 (r184590) @@ -369,6 +369,10 @@ ffs_lock(ap) VI_LOCK(vp); flags |= LK_INTERLOCK; } +#ifdef DEBUG_VFS_LOCKS + KASSERT(vp->v_holdcnt != 0, + ("ffs_lock %p: zero hold count", vp)); +#endif lkp = vp->v_vnlock; result = _lockmgr(lkp, flags, VI_MTX(vp), ap->a_td, ap->a_file, ap->a_line); if (lkp == vp->v_vnlock || result != 0) From kib at FreeBSD.org Mon Nov 3 06:11:06 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Nov 3 06:11:12 2008 Subject: svn commit: r184591 - in stable/7/sys: . kern Message-ID: <200811031411.mA3EB6t4068217@svn.freebsd.org> Author: kib Date: Mon Nov 3 14:11:06 2008 New Revision: 184591 URL: http://svn.freebsd.org/changeset/base/184591 Log: In vfs_busy(), lockmgr() cannot legitimately sleep, because code checked MNTK_UNMOUNT before, and mnt_mtx is used as interlock. vfs_busy() always tries to obtain a shared lock on mnt_lock, the other user is unmount who tries to drain it, setting MNTK_UNMOUNT before. Approved by: re (kensmith) Modified: stable/7/sys/ (props changed) stable/7/sys/kern/vfs_subr.c Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Mon Nov 3 14:08:08 2008 (r184590) +++ stable/7/sys/kern/vfs_subr.c Mon Nov 3 14:11:06 2008 (r184591) @@ -361,7 +361,7 @@ vfs_busy(struct mount *mp, int flags, st } if (interlkp) mtx_unlock(interlkp); - lkflags = LK_SHARED | LK_INTERLOCK; + lkflags = LK_SHARED | LK_INTERLOCK | LK_NOWAIT; if (lockmgr(&mp->mnt_lock, lkflags, MNT_MTX(mp), td)) panic("vfs_busy: unexpected lock failure"); return (0); From kib at FreeBSD.org Mon Nov 3 06:35:43 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Nov 3 06:35:59 2008 Subject: svn commit: r184593 - in stable/7/sys: . ufs/ufs Message-ID: <200811031435.mA3EZhUC068702@svn.freebsd.org> Author: kib Date: Mon Nov 3 14:35:43 2008 New Revision: 184593 URL: http://svn.freebsd.org/changeset/base/184593 Log: MFC r184408: Provide an explanation for getinoquota() call in the ufs_access vop. Approved by: re (kensmith) Modified: stable/7/sys/ (props changed) stable/7/sys/ufs/ufs/ufs_vnops.c Modified: stable/7/sys/ufs/ufs/ufs_vnops.c ============================================================================== --- stable/7/sys/ufs/ufs/ufs_vnops.c Mon Nov 3 14:23:15 2008 (r184592) +++ stable/7/sys/ufs/ufs/ufs_vnops.c Mon Nov 3 14:35:43 2008 (r184593) @@ -330,7 +330,18 @@ ufs_access(ap) if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); #ifdef QUOTA + /* + * Inode is accounted in the quotas only if struct + * dquot is attached to it. VOP_ACCESS() is called + * from vn_open_cred() and provides a convenient + * point to call getinoquota(). + */ if (VOP_ISLOCKED(vp, ap->a_td) != LK_EXCLUSIVE) { + + /* + * Upgrade vnode lock, since getinoquota() + * requires exclusive lock to modify inode. + */ relocked = 1; vhold(vp); vn_lock(vp, LK_UPGRADE | LK_RETRY, ap->a_td); From marius at FreeBSD.org Mon Nov 3 13:41:35 2008 From: marius at FreeBSD.org (Marius Strobl) Date: Mon Nov 3 13:41:53 2008 Subject: svn commit: r184603 - in stable/7/sys: . sparc64/sparc64 sun4v/sun4v Message-ID: <200811032141.mA3LfZsk076797@svn.freebsd.org> Author: marius Date: Mon Nov 3 21:41:35 2008 New Revision: 184603 URL: http://svn.freebsd.org/changeset/base/184603 Log: MFC: r184376 - In GCC 4.2 __builtin_frame_address() was fixed to include the V9 stack bias so we no longer need to add it in db_backtrace() and stack_capture() respectively. This also reverts r182168, which kludged around the resulting unaligned access. - Sync the sun4v versions of db_trace.c and stack_machdep.c with the sparc64 ones and fix some style bugs. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/sparc64/sparc64/db_trace.c stable/7/sys/sparc64/sparc64/stack_machdep.c stable/7/sys/sun4v/sun4v/db_trace.c stable/7/sys/sun4v/sun4v/stack_machdep.c Modified: stable/7/sys/sparc64/sparc64/db_trace.c ============================================================================== --- stable/7/sys/sparc64/sparc64/db_trace.c Mon Nov 3 21:17:18 2008 (r184602) +++ stable/7/sys/sparc64/sparc64/db_trace.c Mon Nov 3 21:41:35 2008 (r184603) @@ -276,10 +276,9 @@ db_backtrace(struct thread *td, struct f void db_trace_self(void) { - db_expr_t addr; - addr = (db_expr_t)__builtin_frame_address(1); - db_backtrace(curthread, (struct frame *)(addr + SPOFF), -1); + db_backtrace(curthread, + (struct frame *)__builtin_frame_address(1), -1); } int @@ -288,5 +287,6 @@ db_trace_thread(struct thread *td, int c struct pcb *ctx; ctx = kdb_thr_ctx(td); - return (db_backtrace(td, (struct frame*)(ctx->pcb_sp + SPOFF), count)); + return (db_backtrace(td, + (struct frame *)(ctx->pcb_sp + SPOFF), count)); } Modified: stable/7/sys/sparc64/sparc64/stack_machdep.c ============================================================================== --- stable/7/sys/sparc64/sparc64/stack_machdep.c Mon Nov 3 21:17:18 2008 (r184602) +++ stable/7/sys/sparc64/sparc64/stack_machdep.c Mon Nov 3 21:41:35 2008 (r184603) @@ -28,31 +28,24 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include #include -#include -#include -#include - -#include #include #include -#include #include +static void stack_capture(struct stack *st, struct frame *fp); + static void -stack_capture(struct stack *st, uint64_t addr) +stack_capture(struct stack *st, struct frame *fp) { vm_offset_t callpc; stack_zero(st); while (1) { - addr += SPOFF; - callpc = - be64dec((void *)(addr + offsetof(struct frame, fr_pc))); + callpc = fp->fr_pc; if (!INKERNEL(callpc)) break; /* Don't bother traversing trap frames. */ @@ -63,30 +56,25 @@ stack_capture(struct stack *st, uint64_t break; if (stack_put(st, callpc) == -1) break; - addr = - be64dec((void *)(addr + offsetof(struct frame, fr_fp))); + fp = v9next_frame(fp); } } void stack_save_td(struct stack *st, struct thread *td) { - uint64_t addr; if (TD_IS_SWAPPED(td)) panic("stack_save_td: swapped"); if (TD_IS_RUNNING(td)) panic("stack_save_td: running"); - addr = td->td_pcb->pcb_sp; - stack_capture(st, addr); + stack_capture(st, (struct frame *)(td->td_pcb->pcb_sp + SPOFF)); } void stack_save(struct stack *st) { - uint64_t addr; - addr = (uint64_t)__builtin_frame_address(1); - stack_capture(st, addr); + stack_capture(st, (struct frame *)__builtin_frame_address(1)); } Modified: stable/7/sys/sun4v/sun4v/db_trace.c ============================================================================== --- stable/7/sys/sun4v/sun4v/db_trace.c Mon Nov 3 21:17:18 2008 (r184602) +++ stable/7/sys/sun4v/sun4v/db_trace.c Mon Nov 3 21:41:35 2008 (r184603) @@ -22,10 +22,11 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -241,7 +242,6 @@ db_backtrace(struct thread *td, struct f db_addr_t pc; int trap; int user; - int quit; if (count == -1) count = 1024; @@ -249,7 +249,6 @@ db_backtrace(struct thread *td, struct f trap = 0; user = 0; npc = 0; - quit = 0; while (count-- && !user && !db_pager_quit) { pc = (db_addr_t)db_get_value((db_addr_t)&fp->fr_pc, sizeof(fp->fr_pc), FALSE); @@ -288,10 +287,9 @@ db_backtrace(struct thread *td, struct f void db_trace_self(void) { - db_expr_t addr; - addr = (db_expr_t)__builtin_frame_address(1); - db_backtrace(curthread, (struct frame *)(addr + SPOFF), -1); + db_backtrace(curthread, + (struct frame *)__builtin_frame_address(1), -1); } int @@ -300,5 +298,6 @@ db_trace_thread(struct thread *td, int c struct pcb *ctx; ctx = kdb_thr_ctx(td); - return (db_backtrace(td, (struct frame*)(ctx->pcb_sp + SPOFF), count)); + return (db_backtrace(td, + (struct frame *)(ctx->pcb_sp + SPOFF), count)); } Modified: stable/7/sys/sun4v/sun4v/stack_machdep.c ============================================================================== --- stable/7/sys/sun4v/sun4v/stack_machdep.c Mon Nov 3 21:17:18 2008 (r184602) +++ stable/7/sys/sun4v/sun4v/stack_machdep.c Mon Nov 3 21:41:35 2008 (r184603) @@ -32,54 +32,43 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include - -#include #include #include -#include #include +static void stack_capture(struct stack *st, struct frame *fp); + static void -stack_capture(struct stack *st, uint64_t addr) +stack_capture(struct stack *st, struct frame *fp) { - struct frame *fp; vm_offset_t callpc; stack_zero(st); - fp = (struct frame *)(addr + SPOFF); while (1) { callpc = fp->fr_pc; if (!INKERNEL(callpc)) break; if (stack_put(st, callpc) == -1) break; - fp = (struct frame *)(fp->fr_fp + SPOFF); + fp = v9next_frame(fp); } - } void stack_save_td(struct stack *st, struct thread *td) { - uint64_t addr; if (TD_IS_SWAPPED(td)) panic("stack_save_td: swapped"); if (TD_IS_RUNNING(td)) panic("stack_save_td: running"); - addr = td->td_pcb->pcb_sp; - stack_capture(st, addr); + stack_capture(st, (struct frame *)(td->td_pcb->pcb_sp + SPOFF)); } void stack_save(struct stack *st) { - uint64_t addr; - addr = (uint64_t)__builtin_frame_address(1); - stack_capture(st, addr); + stack_capture(st, (struct frame *)__builtin_frame_address(1)); } From kib at FreeBSD.org Tue Nov 4 07:56:45 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Tue Nov 4 07:56:55 2008 Subject: svn commit: r184641 - in stable/7/sys: . kern Message-ID: <200811041556.mA4FuijN001109@svn.freebsd.org> Author: kib Date: Tue Nov 4 15:56:44 2008 New Revision: 184641 URL: http://svn.freebsd.org/changeset/base/184641 Log: MFC r184409: Protect check for v_pollinfo == NULL and assignment of the newly allocated vpollinfo with vnode interlock. Fully initialize vpollinfo before putting pointer to it into vp->v_pollinfo. Approved by: re (kensmith) Modified: stable/7/sys/ (props changed) stable/7/sys/kern/vfs_subr.c Modified: stable/7/sys/kern/vfs_subr.c ============================================================================== --- stable/7/sys/kern/vfs_subr.c Tue Nov 4 15:47:06 2008 (r184640) +++ stable/7/sys/kern/vfs_subr.c Tue Nov 4 15:56:44 2008 (r184641) @@ -109,7 +109,7 @@ static void vgonel(struct vnode *); static void vfs_knllock(void *arg); static void vfs_knlunlock(void *arg); static int vfs_knllocked(void *arg); - +static void destroy_vpollinfo(struct vpollinfo *vi); /* * Enable Giant pushdown based on whether or not the vm is mpsafe in this @@ -815,11 +815,8 @@ vdestroy(struct vnode *vp) #ifdef MAC mac_destroy_vnode(vp); #endif - if (vp->v_pollinfo != NULL) { - knlist_destroy(&vp->v_pollinfo->vpi_selinfo.si_note); - mtx_destroy(&vp->v_pollinfo->vpi_lock); - uma_zfree(vnodepoll_zone, vp->v_pollinfo); - } + if (vp->v_pollinfo != NULL) + destroy_vpollinfo(vp->v_pollinfo); #ifdef INVARIANTS /* XXX Elsewhere we can detect an already freed vnode via NULL v_op. */ vp->v_op = NULL; @@ -3050,6 +3047,14 @@ vbusy(struct vnode *vp) mtx_unlock(&vnode_free_list_mtx); } +static void +destroy_vpollinfo(struct vpollinfo *vi) +{ + knlist_destroy(&vi->vpi_selinfo.si_note); + mtx_destroy(&vi->vpi_lock); + uma_zfree(vnodepoll_zone, vi); +} + /* * Initalize per-vnode helper structure to hold poll-related state. */ @@ -3058,15 +3063,20 @@ v_addpollinfo(struct vnode *vp) { struct vpollinfo *vi; + if (vp->v_pollinfo != NULL) + return; vi = uma_zalloc(vnodepoll_zone, M_WAITOK); + mtx_init(&vi->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); + knlist_init(&vi->vpi_selinfo.si_note, vp, vfs_knllock, + vfs_knlunlock, vfs_knllocked); + VI_LOCK(vp); if (vp->v_pollinfo != NULL) { - uma_zfree(vnodepoll_zone, vi); + VI_UNLOCK(vp); + destroy_vpollinfo(vi); return; } vp->v_pollinfo = vi; - mtx_init(&vp->v_pollinfo->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); - knlist_init(&vp->v_pollinfo->vpi_selinfo.si_note, vp, vfs_knllock, - vfs_knlunlock, vfs_knllocked); + VI_UNLOCK(vp); } /* @@ -3081,8 +3091,7 @@ int vn_pollrecord(struct vnode *vp, struct thread *td, int events) { - if (vp->v_pollinfo == NULL) - v_addpollinfo(vp); + v_addpollinfo(vp); mtx_lock(&vp->v_pollinfo->vpi_lock); if (vp->v_pollinfo->vpi_revents & events) { /* @@ -3917,8 +3926,7 @@ vfs_kqfilter(struct vop_kqfilter_args *a kn->kn_hook = (caddr_t)vp; - if (vp->v_pollinfo == NULL) - v_addpollinfo(vp); + v_addpollinfo(vp); if (vp->v_pollinfo == NULL) return (ENOMEM); knl = &vp->v_pollinfo->vpi_selinfo.si_note; From scottl at samsco.org Tue Nov 4 08:44:00 2008 From: scottl at samsco.org (Scott Long) Date: Tue Nov 4 08:44:12 2008 Subject: svn commit: r184641 - in stable/7/sys: . kern In-Reply-To: <200811041556.mA4FuijN001109@svn.freebsd.org> References: <200811041556.mA4FuijN001109@svn.freebsd.org> Message-ID: <49107254.9070307@samsco.org> In stable branches, and especially during release cycles, would it be possible to annotate whether changes like this fix known panics or user-visible bugs? Scott Konstantin Belousov wrote: > Author: kib > Date: Tue Nov 4 15:56:44 2008 > New Revision: 184641 > URL: http://svn.freebsd.org/changeset/base/184641 > > Log: > MFC r184409: > Protect check for v_pollinfo == NULL and assignment of the newly allocated > vpollinfo with vnode interlock. Fully initialize vpollinfo before putting > pointer to it into vp->v_pollinfo. > > Approved by: re (kensmith) > > Modified: > stable/7/sys/ (props changed) > stable/7/sys/kern/vfs_subr.c > > Modified: stable/7/sys/kern/vfs_subr.c > ============================================================================== > --- stable/7/sys/kern/vfs_subr.c Tue Nov 4 15:47:06 2008 (r184640) > +++ stable/7/sys/kern/vfs_subr.c Tue Nov 4 15:56:44 2008 (r184641) > @@ -109,7 +109,7 @@ static void vgonel(struct vnode *); > static void vfs_knllock(void *arg); > static void vfs_knlunlock(void *arg); > static int vfs_knllocked(void *arg); > - > +static void destroy_vpollinfo(struct vpollinfo *vi); > > /* > * Enable Giant pushdown based on whether or not the vm is mpsafe in this > @@ -815,11 +815,8 @@ vdestroy(struct vnode *vp) > #ifdef MAC > mac_destroy_vnode(vp); > #endif > - if (vp->v_pollinfo != NULL) { > - knlist_destroy(&vp->v_pollinfo->vpi_selinfo.si_note); > - mtx_destroy(&vp->v_pollinfo->vpi_lock); > - uma_zfree(vnodepoll_zone, vp->v_pollinfo); > - } > + if (vp->v_pollinfo != NULL) > + destroy_vpollinfo(vp->v_pollinfo); > #ifdef INVARIANTS > /* XXX Elsewhere we can detect an already freed vnode via NULL v_op. */ > vp->v_op = NULL; > @@ -3050,6 +3047,14 @@ vbusy(struct vnode *vp) > mtx_unlock(&vnode_free_list_mtx); > } > > +static void > +destroy_vpollinfo(struct vpollinfo *vi) > +{ > + knlist_destroy(&vi->vpi_selinfo.si_note); > + mtx_destroy(&vi->vpi_lock); > + uma_zfree(vnodepoll_zone, vi); > +} > + > /* > * Initalize per-vnode helper structure to hold poll-related state. > */ > @@ -3058,15 +3063,20 @@ v_addpollinfo(struct vnode *vp) > { > struct vpollinfo *vi; > > + if (vp->v_pollinfo != NULL) > + return; > vi = uma_zalloc(vnodepoll_zone, M_WAITOK); > + mtx_init(&vi->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); > + knlist_init(&vi->vpi_selinfo.si_note, vp, vfs_knllock, > + vfs_knlunlock, vfs_knllocked); > + VI_LOCK(vp); > if (vp->v_pollinfo != NULL) { > - uma_zfree(vnodepoll_zone, vi); > + VI_UNLOCK(vp); > + destroy_vpollinfo(vi); > return; > } > vp->v_pollinfo = vi; > - mtx_init(&vp->v_pollinfo->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); > - knlist_init(&vp->v_pollinfo->vpi_selinfo.si_note, vp, vfs_knllock, > - vfs_knlunlock, vfs_knllocked); > + VI_UNLOCK(vp); > } > > /* > @@ -3081,8 +3091,7 @@ int > vn_pollrecord(struct vnode *vp, struct thread *td, int events) > { > > - if (vp->v_pollinfo == NULL) > - v_addpollinfo(vp); > + v_addpollinfo(vp); > mtx_lock(&vp->v_pollinfo->vpi_lock); > if (vp->v_pollinfo->vpi_revents & events) { > /* > @@ -3917,8 +3926,7 @@ vfs_kqfilter(struct vop_kqfilter_args *a > > kn->kn_hook = (caddr_t)vp; > > - if (vp->v_pollinfo == NULL) > - v_addpollinfo(vp); > + v_addpollinfo(vp); > if (vp->v_pollinfo == NULL) > return (ENOMEM); > knl = &vp->v_pollinfo->vpi_selinfo.si_note; From kostikbel at gmail.com Tue Nov 4 08:59:59 2008 From: kostikbel at gmail.com (Kostik Belousov) Date: Tue Nov 4 09:00:18 2008 Subject: svn commit: r184641 - in stable/7/sys: . kern In-Reply-To: <49107254.9070307@samsco.org> References: <200811041556.mA4FuijN001109@svn.freebsd.org> <49107254.9070307@samsco.org> Message-ID: <20081104165951.GQ18100@deviant.kiev.zoral.com.ua> On Tue, Nov 04, 2008 at 09:03:32AM -0700, Scott Long wrote: > In stable branches, and especially during release cycles, would it be > possible to annotate whether changes like this fix known panics or > user-visible bugs? I thought that description of the change made it obvious. Access to the partially initialized structure is sure reason for a bad behaviour, panic in this particular case. It is slightly more involved in this case, because other thread was able to overwrite pointer to fully initialized structure put by current thread. This is what prevented by vnode interlock region. > > Scott > > > Konstantin Belousov wrote: > >Author: kib > >Date: Tue Nov 4 15:56:44 2008 > >New Revision: 184641 > >URL: http://svn.freebsd.org/changeset/base/184641 > > > >Log: > > MFC r184409: > > Protect check for v_pollinfo == NULL and assignment of the newly > > allocated > > vpollinfo with vnode interlock. Fully initialize vpollinfo before putting > > pointer to it into vp->v_pollinfo. > > > > Approved by: re (kensmith) > > > >Modified: > > stable/7/sys/ (props changed) > > stable/7/sys/kern/vfs_subr.c > > > >Modified: stable/7/sys/kern/vfs_subr.c > >============================================================================== > >--- stable/7/sys/kern/vfs_subr.c Tue Nov 4 15:47:06 2008 (r184640) > >+++ stable/7/sys/kern/vfs_subr.c Tue Nov 4 15:56:44 2008 (r184641) > >@@ -109,7 +109,7 @@ static void vgonel(struct vnode *); > > static void vfs_knllock(void *arg); > > static void vfs_knlunlock(void *arg); > > static int vfs_knllocked(void *arg); > >- > >+static void destroy_vpollinfo(struct vpollinfo *vi); > > > > /* > > * Enable Giant pushdown based on whether or not the vm is mpsafe in this > >@@ -815,11 +815,8 @@ vdestroy(struct vnode *vp) > > #ifdef MAC > > mac_destroy_vnode(vp); > > #endif > >- if (vp->v_pollinfo != NULL) { > >- knlist_destroy(&vp->v_pollinfo->vpi_selinfo.si_note); > >- mtx_destroy(&vp->v_pollinfo->vpi_lock); > >- uma_zfree(vnodepoll_zone, vp->v_pollinfo); > >- } > >+ if (vp->v_pollinfo != NULL) > >+ destroy_vpollinfo(vp->v_pollinfo); > > #ifdef INVARIANTS > > /* XXX Elsewhere we can detect an already freed vnode via NULL v_op. > > */ > > vp->v_op = NULL; > >@@ -3050,6 +3047,14 @@ vbusy(struct vnode *vp) > > mtx_unlock(&vnode_free_list_mtx); > > } > > > >+static void > >+destroy_vpollinfo(struct vpollinfo *vi) > >+{ > >+ knlist_destroy(&vi->vpi_selinfo.si_note); > >+ mtx_destroy(&vi->vpi_lock); > >+ uma_zfree(vnodepoll_zone, vi); > >+} > >+ > > /* > > * Initalize per-vnode helper structure to hold poll-related state. > > */ > >@@ -3058,15 +3063,20 @@ v_addpollinfo(struct vnode *vp) > > { > > struct vpollinfo *vi; > > > >+ if (vp->v_pollinfo != NULL) > >+ return; > > vi = uma_zalloc(vnodepoll_zone, M_WAITOK); > >+ mtx_init(&vi->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); > >+ knlist_init(&vi->vpi_selinfo.si_note, vp, vfs_knllock, > >+ vfs_knlunlock, vfs_knllocked); > >+ VI_LOCK(vp); > > if (vp->v_pollinfo != NULL) { > >- uma_zfree(vnodepoll_zone, vi); > >+ VI_UNLOCK(vp); > >+ destroy_vpollinfo(vi); > > return; > > } > > vp->v_pollinfo = vi; > >- mtx_init(&vp->v_pollinfo->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); > >- knlist_init(&vp->v_pollinfo->vpi_selinfo.si_note, vp, vfs_knllock, > >- vfs_knlunlock, vfs_knllocked); > >+ VI_UNLOCK(vp); > > } > > > > /* > >@@ -3081,8 +3091,7 @@ int > > vn_pollrecord(struct vnode *vp, struct thread *td, int events) > > { > > > >- if (vp->v_pollinfo == NULL) > >- v_addpollinfo(vp); > >+ v_addpollinfo(vp); > > mtx_lock(&vp->v_pollinfo->vpi_lock); > > if (vp->v_pollinfo->vpi_revents & events) { > > /* > >@@ -3917,8 +3926,7 @@ vfs_kqfilter(struct vop_kqfilter_args *a > > > > kn->kn_hook = (caddr_t)vp; > > > >- if (vp->v_pollinfo == NULL) > >- v_addpollinfo(vp); > >+ v_addpollinfo(vp); > > if (vp->v_pollinfo == NULL) > > return (ENOMEM); > > knl = &vp->v_pollinfo->vpi_selinfo.si_note; -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-stable-7/attachments/20081104/df2c71ab/attachment.pgp From marius at FreeBSD.org Tue Nov 4 14:51:57 2008 From: marius at FreeBSD.org (Marius Strobl) Date: Tue Nov 4 14:52:09 2008 Subject: svn commit: r184662 - stable/7/lib/libcam Message-ID: <200811042251.mA4MpuDS009857@svn.freebsd.org> Author: marius Date: Tue Nov 4 22:51:56 2008 New Revision: 184662 URL: http://svn.freebsd.org/changeset/base/184662 Log: MFC: r184379 Supply a valid Connect ID when issuing XPT_DEV_MATCH, which according to my reading of the CAM draft is mandatory for all CCB function calls and enforced by xptioctl() since at least r168752. Previously we happened to use 0 as the Path ID, causing the XPT_DEV_MATCH call to fail if there's no SCSI bus 0. Basically the same bug was also fixed the same way for camcontrol(8) as part of r126514. PR: 127605 Approved by: re (kib) Modified: stable/7/lib/libcam/ (props changed) stable/7/lib/libcam/camlib.c Modified: stable/7/lib/libcam/camlib.c ============================================================================== --- stable/7/lib/libcam/camlib.c Tue Nov 4 22:31:04 2008 (r184661) +++ stable/7/lib/libcam/camlib.c Tue Nov 4 22:51:56 2008 (r184662) @@ -346,6 +346,9 @@ cam_open_btl(path_id_t path_id, target_i bzero(&ccb, sizeof(union ccb)); ccb.ccb_h.func_code = XPT_DEV_MATCH; + ccb.ccb_h.path_id = CAM_XPT_PATH_ID; + ccb.ccb_h.target_id = CAM_TARGET_WILDCARD; + ccb.ccb_h.target_lun = CAM_LUN_WILDCARD; /* Setup the result buffer */ bufsize = sizeof(struct dev_match_result); From kib at FreeBSD.org Wed Nov 5 04:28:45 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Wed Nov 5 04:29:02 2008 Subject: svn commit: r184684 - stable/7/libexec/rtld-elf Message-ID: <200811051228.mA5CSjSf026889@svn.freebsd.org> Author: kib Date: Wed Nov 5 12:28:44 2008 New Revision: 184684 URL: http://svn.freebsd.org/changeset/base/184684 Log: MFC r183737 (by kan): Allow strong symbols to override weak ones for lookups done through dlsym with RTLD_NEXT/RTLD_SELF handles. Allow symbols from ld-elf.so to be located this way too. Approved by: re (kensmith), kan Modified: stable/7/libexec/rtld-elf/ (props changed) stable/7/libexec/rtld-elf/rtld.c Modified: stable/7/libexec/rtld-elf/rtld.c ============================================================================== --- stable/7/libexec/rtld-elf/rtld.c Wed Nov 5 12:13:10 2008 (r184683) +++ stable/7/libexec/rtld-elf/rtld.c Wed Nov 5 12:28:44 2008 (r184684) @@ -1891,7 +1891,7 @@ do_dlsym(void *handle, const char *name, { DoneList donelist; const Obj_Entry *obj, *defobj; - const Elf_Sym *def; + const Elf_Sym *def, *symp; unsigned long hash; int lockstate; @@ -1917,9 +1917,26 @@ do_dlsym(void *handle, const char *name, if (handle == RTLD_NEXT) obj = obj->next; for (; obj != NULL; obj = obj->next) { - if ((def = symlook_obj(name, hash, obj, ve, flags)) != NULL) { - defobj = obj; - break; + if ((symp = symlook_obj(name, hash, obj, ve, flags)) != NULL) { + if (def == NULL || ELF_ST_BIND(symp->st_info) != STB_WEAK) { + def = symp; + defobj = obj; + if (ELF_ST_BIND(def->st_info) != STB_WEAK) + break; + } + } + } + /* + * Search the dynamic linker itself, and possibly resolve the + * symbol from there. This is how the application links to + * dynamic linker services such as dlopen. Only the values listed + * in the "exports" array can be resolved from the dynamic linker. + */ + if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) { + symp = symlook_obj(name, hash, &obj_rtld, ve, flags); + if (symp != NULL && is_exported(symp)) { + def = symp; + defobj = &obj_rtld; } } } else { From kib at FreeBSD.org Wed Nov 5 04:32:43 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Wed Nov 5 04:32:59 2008 Subject: svn commit: r184685 - stable/7/libexec/rtld-elf Message-ID: <200811051232.mA5CWgbB027010@svn.freebsd.org> Author: kib Date: Wed Nov 5 12:32:42 2008 New Revision: 184685 URL: http://svn.freebsd.org/changeset/base/184685 Log: MFC r182698 (by kan): Make sure internal rtld malloc routines are not called from unlocked contexts as rtld's malloc is not thread safe and is only supposed to be called with exclusive bind lock already held. Approved by: re (kensmith), kan Modified: stable/7/libexec/rtld-elf/ (props changed) stable/7/libexec/rtld-elf/rtld.c Modified: stable/7/libexec/rtld-elf/rtld.c ============================================================================== --- stable/7/libexec/rtld-elf/rtld.c Wed Nov 5 12:28:44 2008 (r184684) +++ stable/7/libexec/rtld-elf/rtld.c Wed Nov 5 12:32:42 2008 (r184685) @@ -106,8 +106,8 @@ static int load_needed_objects(Obj_Entry static int load_preload_objects(void); static Obj_Entry *load_object(const char *, const Obj_Entry *); static Obj_Entry *obj_from_addr(const void *); -static void objlist_call_fini(Objlist *); -static void objlist_call_init(Objlist *); +static void objlist_call_fini(Objlist *, int *lockstate); +static void objlist_call_init(Objlist *, int *lockstate); static void objlist_clear(Objlist *); static Objlist_Entry *objlist_find(Objlist *, const Obj_Entry *); static void objlist_init(Objlist *); @@ -512,8 +512,8 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_ r_debug_state(NULL, &obj_main->linkmap); /* say hello to gdb! */ - objlist_call_init(&initlist); lockstate = wlock_acquire(rtld_bind_lock); + objlist_call_init(&initlist, &lockstate); objlist_clear(&initlist); wlock_release(rtld_bind_lock, lockstate); @@ -1433,7 +1433,7 @@ obj_from_addr(const void *addr) * non-NULL fini functions. */ static void -objlist_call_fini(Objlist *list) +objlist_call_fini(Objlist *list, int *lockstate) { Objlist_Entry *elm; char *saved_msg; @@ -1443,6 +1443,7 @@ objlist_call_fini(Objlist *list) * call into the dynamic linker and overwrite it. */ saved_msg = errmsg_save(); + wlock_release(rtld_bind_lock, *lockstate); STAILQ_FOREACH(elm, list, link) { if (elm->obj->refcount == 0) { dbg("calling fini function for %s at %p", elm->obj->path, @@ -1452,6 +1453,7 @@ objlist_call_fini(Objlist *list) call_initfini_pointer(elm->obj, elm->obj->fini); } } + *lockstate = wlock_acquire(rtld_bind_lock); errmsg_restore(saved_msg); } @@ -1461,7 +1463,7 @@ objlist_call_fini(Objlist *list) * functions. */ static void -objlist_call_init(Objlist *list) +objlist_call_init(Objlist *list, int *lockstate) { Objlist_Entry *elm; char *saved_msg; @@ -1471,6 +1473,7 @@ objlist_call_init(Objlist *list) * call into the dynamic linker and overwrite it. */ saved_msg = errmsg_save(); + wlock_release(rtld_bind_lock, *lockstate); STAILQ_FOREACH(elm, list, link) { dbg("calling init function for %s at %p", elm->obj->path, (void *)elm->obj->init); @@ -1478,6 +1481,7 @@ objlist_call_init(Objlist *list) elm->obj->path); call_initfini_pointer(elm->obj, elm->obj->init); } + *lockstate = wlock_acquire(rtld_bind_lock); errmsg_restore(saved_msg); } @@ -1638,15 +1642,18 @@ static void rtld_exit(void) { Obj_Entry *obj; + int lockstate; + lockstate = wlock_acquire(rtld_bind_lock); dbg("rtld_exit()"); /* Clear all the reference counts so the fini functions will be called. */ for (obj = obj_list; obj != NULL; obj = obj->next) obj->refcount = 0; - objlist_call_fini(&list_fini); + objlist_call_fini(&list_fini, &lockstate); /* No need to remove the items from the list, since we are exiting. */ if (!libmap_disable) lm_fini(); + wlock_release(rtld_bind_lock, lockstate); } static void * @@ -1760,11 +1767,9 @@ dlclose(void *handle) if (root->refcount == 0) { /* * The object is no longer referenced, so we must unload it. - * First, call the fini functions with no locks held. + * First, call the fini functions. */ - wlock_release(rtld_bind_lock, lockstate); - objlist_call_fini(&list_fini); - lockstate = wlock_acquire(rtld_bind_lock); + objlist_call_fini(&list_fini, &lockstate); objlist_remove_unref(&list_fini); /* Finish cleaning up the newly-unreferenced objects. */ @@ -1872,10 +1877,8 @@ dlopen(const char *name, int mode) name); GDB_STATE(RT_CONSISTENT,obj ? &obj->linkmap : NULL); - /* Call the init functions with no locks held. */ - wlock_release(rtld_bind_lock, lockstate); - objlist_call_init(&initlist); - lockstate = wlock_acquire(rtld_bind_lock); + /* Call the init functions. */ + objlist_call_init(&initlist, &lockstate); objlist_clear(&initlist); wlock_release(rtld_bind_lock, lockstate); return obj; From danger at FreeBSD.org Wed Nov 5 06:14:32 2008 From: danger at FreeBSD.org (Daniel Gerzo) Date: Wed Nov 5 06:14:49 2008 Subject: svn commit: r184686 - in stable/7/usr.sbin/portsnap: . portsnap Message-ID: <200811051414.mA5EEVVv028839@svn.freebsd.org> Author: danger (doc committer) Date: Wed Nov 5 14:14:31 2008 New Revision: 184686 URL: http://svn.freebsd.org/changeset/base/184686 Log: MFC rev. 183041: - remove superfluous word PR: docs/127401 Submitted by: Mick Charles Beaver Approved by: re@ (blackend) Modified: stable/7/usr.sbin/portsnap/ (props changed) stable/7/usr.sbin/portsnap/portsnap/portsnap.8 Modified: stable/7/usr.sbin/portsnap/portsnap/portsnap.8 ============================================================================== --- stable/7/usr.sbin/portsnap/portsnap/portsnap.8 Wed Nov 5 12:32:42 2008 (r184685) +++ stable/7/usr.sbin/portsnap/portsnap/portsnap.8 Wed Nov 5 14:14:31 2008 (r184686) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 13, 2005 +.Dd September 15, 2008 .Dt PORTSNAP 8 .Os FreeBSD .Sh NAME @@ -60,7 +60,7 @@ Store working files (e.g.\& downloaded u .Pa /var/db/portsnap , or as given in the configuration file.) .It Fl f Ar conffile -Read the configuration from from +Read the configuration from .Ar conffile . (default: .Pa /etc/portsnap.conf ) From kensmith at FreeBSD.org Thu Nov 6 05:28:50 2008 From: kensmith at FreeBSD.org (Ken Smith) Date: Thu Nov 6 05:29:08 2008 Subject: svn commit: r184723 - stable/7/release Message-ID: <200811061328.mA6DSonm056705@svn.freebsd.org> Author: kensmith Date: Thu Nov 6 13:28:50 2008 New Revision: 184723 URL: http://svn.freebsd.org/changeset/base/184723 Log: Oops. Correct a mis-merge. This piece of r183860 didn't make it through while doing the merge. PR: misc/128610 Submitted by: veron x503 hotmail com Approved by: re (blackend, kib) Modified: stable/7/release/Makefile Modified: stable/7/release/Makefile ============================================================================== --- stable/7/release/Makefile Thu Nov 6 13:25:59 2008 (r184722) +++ stable/7/release/Makefile Thu Nov 6 13:28:50 2008 (r184723) @@ -1091,7 +1091,7 @@ CD_DISC2_PKGS= ${CD_PACKAGE_TREE}/disc2 CD_DISC3_PKGS= ${CD_PACKAGE_TREE}/disc3 .endif .if exists(${CD_PACKAGE_TREE}/dvd1) -CD_DVD_PKGS= ${CD_PACKAGE_TREE}/dvd1 +CD_DVD1_PKGS= ${CD_PACKAGE_TREE}/dvd1 .endif .endif .endif From julian at FreeBSD.org Thu Nov 6 14:11:58 2008 From: julian at FreeBSD.org (Julian Elischer) Date: Thu Nov 6 14:12:16 2008 Subject: svn commit: r184739 - in stable/7/sys: . modules/cxgb net netinet Message-ID: <200811062211.mA6MBvdU066984@svn.freebsd.org> Author: julian Date: Thu Nov 6 22:11:57 2008 New Revision: 184739 URL: http://svn.freebsd.org/changeset/base/184739 Log: MFC a rewrite of rt_check(). also revert the addition of rt_check_fib() which we discovered is not needed. fixes some hangs people have seen Approved by: re (ken) Modified: stable/7/sys/ (props changed) stable/7/sys/modules/cxgb/ (props changed) stable/7/sys/net/if_atmsubr.c stable/7/sys/net/if_fwsubr.c stable/7/sys/net/if_iso88025subr.c stable/7/sys/net/route.c stable/7/sys/net/route.h stable/7/sys/netinet/if_ether.c stable/7/sys/netinet/in_rmx.c stable/7/sys/netinet/in_var.h Modified: stable/7/sys/net/if_atmsubr.c ============================================================================== --- stable/7/sys/net/if_atmsubr.c Thu Nov 6 21:47:02 2008 (r184738) +++ stable/7/sys/net/if_atmsubr.c Thu Nov 6 22:11:57 2008 (r184739) @@ -158,8 +158,7 @@ atm_output(struct ifnet *ifp, struct mbu * check route */ if (rt0 != NULL) { - error = rt_check_fib(&rt, &rt0, - dst, rt0->rt_fibnum); + error = rt_check(&rt, &rt0, dst); if (error) goto bad; RT_UNLOCK(rt); Modified: stable/7/sys/net/if_fwsubr.c ============================================================================== --- stable/7/sys/net/if_fwsubr.c Thu Nov 6 21:47:02 2008 (r184738) +++ stable/7/sys/net/if_fwsubr.c Thu Nov 6 22:11:57 2008 (r184739) @@ -103,7 +103,7 @@ firewire_output(struct ifnet *ifp, struc } if (rt0 != NULL) { - error = rt_check_fib(&rt, &rt0, dst, rt0->rt_fibnum); + error = rt_check(&rt, &rt0, dst); if (error) goto bad; RT_UNLOCK(rt); Modified: stable/7/sys/net/if_iso88025subr.c ============================================================================== --- stable/7/sys/net/if_iso88025subr.c Thu Nov 6 21:47:02 2008 (r184738) +++ stable/7/sys/net/if_iso88025subr.c Thu Nov 6 22:11:57 2008 (r184739) @@ -259,8 +259,7 @@ iso88025_output(ifp, m, dst, rt0) /* Calculate routing info length based on arp table entry */ /* XXX any better way to do this ? */ if (rt0 != NULL) { -/* XXX MRT *//* Guess only */ - error = rt_check_fib(&rt, &rt0, dst, rt0->rt_fibnum); + error = rt_check(&rt, &rt0, dst); if (error) goto bad; RT_UNLOCK(rt); Modified: stable/7/sys/net/route.c ============================================================================== --- stable/7/sys/net/route.c Thu Nov 6 21:47:02 2008 (r184738) +++ stable/7/sys/net/route.c Thu Nov 6 22:11:57 2008 (r184739) @@ -1549,84 +1549,120 @@ rtinit(struct ifaddr *ifa, int cmd, int * final destination if directly reachable); * *lrt0 points to the cached route to the final destination; * *lrt is not meaningful; - * fibnum is the index to the correct network fib for this packet + * (*lrt0 has no ref held on it by us so REMREF is not needed. + * Refs only account for major structural references and not usages, + * which is actually a bit of a problem.) * * === Operation === * If the route is marked down try to find a new route. If the route * to the gateway is gone, try to setup a new route. Otherwise, * if the route is marked for packets to be rejected, enforce that. + * Note that rtalloc returns an rtentry with an extra REF that we may + * need to lose. * * === On return === * *dst is unchanged; * *lrt0 points to the (possibly new) route to the final destination - * *lrt points to the route to the next hop + * *lrt points to the route to the next hop [LOCKED] * * Their values are meaningful ONLY if no error is returned. + * + * To follow this you have to remember that: + * RT_REMREF reduces the reference count by 1 but doesn't check it for 0 (!) + * RTFREE_LOCKED includes an RT_REMREF (or an rtfree if refs == 1) + * and an RT_UNLOCK + * RTFREE does an RT_LOCK and an RTFREE_LOCKED + * The gwroute pointer counts as a reference on the rtentry to which it points. + * so when we add it we use the ref that rtalloc gives us and when we lose it + * we need to remove the reference. + * RT_TEMP_UNLOCK does an RT_ADDREF before freeing the lock, and + * RT_RELOCK locks it (it can't have gone away due to the ref) and + * drops the ref, possibly freeing it and zeroing the pointer if + * the ref goes to 0 (unlocking in the process). */ int rt_check(struct rtentry **lrt, struct rtentry **lrt0, struct sockaddr *dst) { - return (rt_check_fib(lrt, lrt0, dst, 0)); -} - -int -rt_check_fib(struct rtentry **lrt, struct rtentry **lrt0, struct sockaddr *dst, - u_int fibnum) -{ struct rtentry *rt; struct rtentry *rt0; - int error; + u_int fibnum; KASSERT(*lrt0 != NULL, ("rt_check")); - rt = rt0 = *lrt0; + rt0 = *lrt0; + rt = NULL; + fibnum = rt0->rt_fibnum; /* NB: the locking here is tortuous... */ - RT_LOCK(rt); - if ((rt->rt_flags & RTF_UP) == 0) { - RT_UNLOCK(rt); - rt = rtalloc1_fib(dst, 1, 0UL, fibnum); - if (rt != NULL) { - RT_REMREF(rt); - /* XXX what about if change? */ - } else + RT_LOCK(rt0); +retry: + if (rt0 && (rt0->rt_flags & RTF_UP) == 0) { + /* Current rt0 is useless, try get a replacement. */ + RT_UNLOCK(rt0); + rt0 = NULL; + } + if (rt0 == NULL) { + rt0 = rtalloc1_fib(dst, 1, 0UL, fibnum); + if (rt0 == NULL) { return (EHOSTUNREACH); - rt0 = rt; + } + RT_REMREF(rt0); /* don't need the reference. */ } - /* XXX BSD/OS checks dst->sa_family != AF_NS */ - if (rt->rt_flags & RTF_GATEWAY) { - if (rt->rt_gwroute == NULL) - goto lookup; - rt = rt->rt_gwroute; - RT_LOCK(rt); /* NB: gwroute */ - if ((rt->rt_flags & RTF_UP) == 0) { - RTFREE_LOCKED(rt); /* unlock gwroute */ - rt = rt0; - rt0->rt_gwroute = NULL; - lookup: - RT_UNLOCK(rt0); -/* XXX MRT link level looked up in table 0 */ - rt = rtalloc1_fib(rt->rt_gateway, 1, 0UL, 0); - if (rt == rt0) { - RT_REMREF(rt0); - RT_UNLOCK(rt0); + + if (rt0->rt_flags & RTF_GATEWAY) { + if ((rt = rt0->rt_gwroute) != NULL) { + RT_LOCK(rt); /* NB: gwroute */ + if ((rt->rt_flags & RTF_UP) == 0) { + /* gw route is dud. ignore/lose it */ + RTFREE_LOCKED(rt); /* unref (&unlock) gwroute */ + rt = rt0->rt_gwroute = NULL; + } + } + + if (rt == NULL) { /* NOT AN ELSE CLAUSE */ + RT_TEMP_UNLOCK(rt0); /* MUST return to undo this */ + rt = rtalloc1_fib(rt0->rt_gateway, 1, 0UL, fibnum); + if ((rt == rt0) || (rt == NULL)) { + /* the best we can do is not good enough */ + if (rt) { + RT_REMREF(rt); /* assumes ref > 0 */ + RT_UNLOCK(rt); + } + RTFREE(rt0); /* lock, unref, (unlock) */ return (ENETUNREACH); } - RT_LOCK(rt0); - if (rt0->rt_gwroute != NULL) - RTFREE(rt0->rt_gwroute); - rt0->rt_gwroute = rt; - if (rt == NULL) { - RT_UNLOCK(rt0); - return (EHOSTUNREACH); + /* + * Relock it and lose the added reference. + * All sorts of things could have happenned while we + * had no lock on it, so check for them. + */ + RT_RELOCK(rt0); + if (rt0 == NULL || ((rt0->rt_flags & RTF_UP) == 0)) + /* Ru-roh.. what we had is no longer any good */ + goto retry; + /* + * While we were away, someone replaced the gateway. + * Since a reference count is involved we can't just + * overwrite it. + */ + if (rt0->rt_gwroute) { + if (rt0->rt_gwroute != rt) { + RTFREE_LOCKED(rt); + goto retry; + } + } else { + rt0->rt_gwroute = rt; } } + RT_LOCK_ASSERT(rt); RT_UNLOCK(rt0); + } else { + /* think of rt as having the lock from now on.. */ + rt = rt0; } /* XXX why are we inspecting rmx_expire? */ - error = (rt->rt_flags & RTF_REJECT) && - (rt->rt_rmx.rmx_expire == 0 || - time_uptime < rt->rt_rmx.rmx_expire); - if (error) { + if ((rt->rt_flags & RTF_REJECT) && + (rt->rt_rmx.rmx_expire == 0 || + time_uptime < rt->rt_rmx.rmx_expire)) { RT_UNLOCK(rt); return (rt == rt0 ? EHOSTDOWN : EHOSTUNREACH); } Modified: stable/7/sys/net/route.h ============================================================================== --- stable/7/sys/net/route.h Thu Nov 6 21:47:02 2008 (r184738) +++ stable/7/sys/net/route.h Thu Nov 6 22:11:57 2008 (r184739) @@ -312,19 +312,35 @@ struct rt_addrinfo { } while (0) #define RTFREE_LOCKED(_rt) do { \ - if ((_rt)->rt_refcnt <= 1) \ - rtfree(_rt); \ - else { \ - RT_REMREF(_rt); \ - RT_UNLOCK(_rt); \ - } \ - /* guard against invalid refs */ \ - _rt = 0; \ - } while (0) + if ((_rt)->rt_refcnt <= 1) \ + rtfree(_rt); \ + else { \ + RT_REMREF(_rt); \ + RT_UNLOCK(_rt); \ + } \ + /* guard against invalid refs */ \ + _rt = 0; \ +} while (0) #define RTFREE(_rt) do { \ - RT_LOCK(_rt); \ - RTFREE_LOCKED(_rt); \ - } while (0) + RT_LOCK(_rt); \ + RTFREE_LOCKED(_rt); \ +} while (0) + +#define RT_TEMP_UNLOCK(_rt) do { \ + RT_ADDREF(_rt); \ + RT_UNLOCK(_rt); \ +} while (0) + +#define RT_RELOCK(_rt) do { \ + RT_LOCK(_rt); \ + if ((_rt)->rt_refcnt <= 1) { \ + rtfree(_rt); \ + _rt = 0; /* signal that it went away */ \ + } else { \ + RT_REMREF(_rt); \ + /* note that _rt is still valid */ \ + } \ +} while (0) extern struct radix_node_head *rt_tables[][AF_MAX+1]; @@ -352,6 +368,7 @@ int rt_setgate(struct rtentry *, struct int rtexpunge(struct rtentry *); void rtfree(struct rtentry *); +int rt_check(struct rtentry **, struct rtentry **, struct sockaddr *); /* XXX MRT COMPAT VERSIONS THAT SET UNIVERSE to 0 */ /* Thes are used by old code not yet converted to use multiple FIBS */ @@ -366,7 +383,6 @@ void rtredirect(struct sockaddr *, stru int rtrequest(int, struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct rtentry **); int rtrequest1(int, struct rt_addrinfo *, struct rtentry **); -int rt_check(struct rtentry **, struct rtentry **, struct sockaddr *); /* defaults to "all" FIBs */ int rtinit_fib(struct ifaddr *, int, int); @@ -385,7 +401,6 @@ void rtredirect_fib(struct sockaddr *, int rtrequest_fib(int, struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct rtentry **, u_int); int rtrequest1_fib(int, struct rt_addrinfo *, struct rtentry **, u_int); -int rt_check_fib(struct rtentry **, struct rtentry **, struct sockaddr *, u_int); #include typedef void (*rtevent_arp_update_fn)(void *, struct rtentry *, uint8_t *, struct sockaddr *); Modified: stable/7/sys/netinet/if_ether.c ============================================================================== --- stable/7/sys/netinet/if_ether.c Thu Nov 6 21:47:02 2008 (r184738) +++ stable/7/sys/netinet/if_ether.c Thu Nov 6 22:11:57 2008 (r184739) @@ -362,7 +362,7 @@ arpresolve(struct ifnet *ifp, struct rte struct rtentry *rt = NULL; struct sockaddr_dl *sdl; int error; - int fibnum = 0; + int fibnum = -1; if (m) { @@ -379,7 +379,7 @@ arpresolve(struct ifnet *ifp, struct rte if (rt0 != NULL) { /* Look for a cached arp (ll) entry. */ - error = in_rt_check(&rt, &rt0, dst, fibnum); + error = rt_check(&rt, &rt0, dst); if (error) { m_freem(m); return error; @@ -388,14 +388,23 @@ arpresolve(struct ifnet *ifp, struct rte if (la == NULL) RT_UNLOCK(rt); } + + /* + * If we had no mbuf and no route, then hope the caller + * has a fib in mind because we are running out of ideas. + * I think this should not happen in current code. + * (kmacy would know). + */ + if (fibnum == -1) + fibnum = curthread->td_proc->p_fibnum; /* last gasp */ + if (la == NULL) { /* * We enter this block if rt0 was NULL, - * or if rt found by in_rt_check() didn't have llinfo. - * we should get a cloned route, which since it should - * come from the local interface should have a ll entry. - * if may be incoplete but that's ok. - * XXXMRT if we haven't found a fibnum is that OK? + * or if rt found by rt_check() didn't have llinfo. + * We should get a cloned route from the local interface, + * so it should have an ll entry. + * It may be incomplete but that's ok. */ rt = arplookup(SIN(dst)->sin_addr.s_addr, 1, 0, fibnum); if (rt == NULL) { Modified: stable/7/sys/netinet/in_rmx.c ============================================================================== --- stable/7/sys/netinet/in_rmx.c Thu Nov 6 21:47:02 2008 (r184738) +++ stable/7/sys/netinet/in_rmx.c Thu Nov 6 22:11:57 2008 (r184739) @@ -465,13 +465,6 @@ in_rtalloc1(struct sockaddr *dst, int re return (rtalloc1_fib(dst, report, ignflags, fibnum)); } -int -in_rt_check(struct rtentry **lrt, struct rtentry **lrt0, - struct sockaddr *dst, u_int fibnum) -{ - return (rt_check_fib(lrt, lrt0, dst, fibnum)); -} - void in_rtredirect(struct sockaddr *dst, struct sockaddr *gateway, Modified: stable/7/sys/netinet/in_var.h ============================================================================== --- stable/7/sys/netinet/in_var.h Thu Nov 6 21:47:02 2008 (r184738) +++ stable/7/sys/netinet/in_var.h Thu Nov 6 22:11:57 2008 (r184739) @@ -314,7 +314,6 @@ void in_rtredirect(struct sockaddr *, s struct sockaddr *, int, struct sockaddr *, u_int); int in_rtrequest(int, struct sockaddr *, struct sockaddr *, struct sockaddr *, int, struct rtentry **, u_int); -int in_rt_check(struct rtentry **, struct rtentry **, struct sockaddr *, u_int); #if 0 int in_rt_getifa(struct rt_addrinfo *, u_int fibnum); From peter at FreeBSD.org Thu Nov 6 14:32:20 2008 From: peter at FreeBSD.org (Peter Wemm) Date: Thu Nov 6 14:32:36 2008 Subject: svn commit: r184741 - in stable/7/sys: . kern modules/cxgb sys Message-ID: <200811062232.mA6MWKD4067493@svn.freebsd.org> Author: peter Date: Thu Nov 6 22:32:19 2008 New Revision: 184741 URL: http://svn.freebsd.org/changeset/base/184741 Log: MFC: r184492 - add offset / fileid / fsid to KERN_PROC_VMMAP sysctl for the benefit of valgrind. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/kern/kern_proc.c stable/7/sys/modules/cxgb/ (props changed) stable/7/sys/sys/user.h Modified: stable/7/sys/kern/kern_proc.c ============================================================================== --- stable/7/sys/kern/kern_proc.c Thu Nov 6 22:28:04 2008 (r184740) +++ stable/7/sys/kern/kern_proc.c Thu Nov 6 22:32:19 2008 (r184741) @@ -1346,6 +1346,8 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR unsigned int last_timestamp; char *fullpath, *freepath; struct kinfo_vmentry *kve; + struct vattr va; + struct ucred *cred; int error, *name; struct vnode *vp; struct proc *p; @@ -1405,6 +1407,8 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR lobj = tobj; } + kve->kve_fileid = 0; + kve->kve_fsid = 0; freepath = NULL; fullpath = ""; if (lobj) { @@ -1446,6 +1450,11 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR curthread); vn_fullpath(curthread, vp, &fullpath, &freepath); + cred = curthread->td_ucred; + if (VOP_GETATTR(vp, &va, cred) == 0) { + kve->kve_fileid = va.va_fileid; + kve->kve_fsid = va.va_fsid; + } vput(vp); VFS_UNLOCK_GIANT(vfslocked); } @@ -1457,6 +1466,7 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR kve->kve_start = (void*)entry->start; kve->kve_end = (void*)entry->end; + kve->kve_offset = (off_t)entry->offset; if (entry->protection & VM_PROT_READ) kve->kve_protection |= KVME_PROT_READ; Modified: stable/7/sys/sys/user.h ============================================================================== --- stable/7/sys/sys/user.h Thu Nov 6 22:28:04 2008 (r184740) +++ stable/7/sys/sys/user.h Thu Nov 6 22:32:19 2008 (r184741) @@ -320,7 +320,10 @@ struct kinfo_vmentry { int kve_shadow_count; /* VM obj shadow count. */ char kve_path[PATH_MAX]; /* Path to VM obj, if any. */ void *_kve_pspare[8]; /* Space for more stuff. */ - int _kve_ispare[8]; /* Space for more stuff. */ + off_t kve_offset; /* Mapping offset in object */ + uint64_t kve_fileid; /* inode number of vnode */ + dev_t kve_fsid; /* dev_t of vnode location */ + int _kve_ispare[3]; /* Space for more stuff. */ }; /* From kib at FreeBSD.org Fri Nov 7 03:07:58 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Fri Nov 7 03:08:09 2008 Subject: svn commit: r184746 - stable/7/sys/kern Message-ID: <200811071107.mA7B7vZF082104@svn.freebsd.org> Author: kib Date: Fri Nov 7 11:07:57 2008 New Revision: 184746 URL: http://svn.freebsd.org/changeset/base/184746 Log: This is direct commit to stable/7 to accomodate KPI difference between HEAD and the branch. Provide struct thread * argument to VOP_GETATTR. Approved by: re (rwatson) Modified: stable/7/sys/kern/kern_proc.c Modified: stable/7/sys/kern/kern_proc.c ============================================================================== --- stable/7/sys/kern/kern_proc.c Fri Nov 7 10:46:15 2008 (r184745) +++ stable/7/sys/kern/kern_proc.c Fri Nov 7 11:07:57 2008 (r184746) @@ -1451,7 +1451,7 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_AR vn_fullpath(curthread, vp, &fullpath, &freepath); cred = curthread->td_ucred; - if (VOP_GETATTR(vp, &va, cred) == 0) { + if (VOP_GETATTR(vp, &va, cred, curthread) == 0) { kve->kve_fileid = va.va_fileid; kve->kve_fsid = va.va_fsid; } From bz at FreeBSD.org Fri Nov 7 03:42:02 2008 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Fri Nov 7 03:42:09 2008 Subject: svn commit: r184747 - in stable/7/sys: . modules/cxgb netinet Message-ID: <200811071142.mA7Bg2Bx082737@svn.freebsd.org> Author: bz Date: Fri Nov 7 11:42:02 2008 New Revision: 184747 URL: http://svn.freebsd.org/changeset/base/184747 Log: MFC: r183014 (which was missed with r184739: r183013,r183017,r183032,r183034) Original commit message from HEAD: Julian: "oops commit the version that compiles" Unbreak RELENG_7 including the missing sys/proc.h header file. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/modules/cxgb/ (props changed) stable/7/sys/netinet/if_ether.c Modified: stable/7/sys/netinet/if_ether.c ============================================================================== --- stable/7/sys/netinet/if_ether.c Fri Nov 7 11:07:57 2008 (r184746) +++ stable/7/sys/netinet/if_ether.c Fri Nov 7 11:42:02 2008 (r184747) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include From blackend at FreeBSD.org Fri Nov 7 14:06:06 2008 From: blackend at FreeBSD.org (Marc Fonvieille) Date: Fri Nov 7 14:06:17 2008 Subject: svn commit: r184754 - stable/7/usr.sbin/sysinstall Message-ID: <200811072206.mA7M64P5094011@svn.freebsd.org> Author: blackend (doc committer) Date: Fri Nov 7 22:06:04 2008 New Revision: 184754 URL: http://svn.freebsd.org/changeset/base/184754 Log: MFC: r184753 Update ports number and size of Ports Collection. Approved by: re (kib) Modified: stable/7/usr.sbin/sysinstall/dist.c Modified: stable/7/usr.sbin/sysinstall/dist.c ============================================================================== --- stable/7/usr.sbin/sysinstall/dist.c Fri Nov 7 22:01:31 2008 (r184753) +++ stable/7/usr.sbin/sysinstall/dist.c Fri Nov 7 22:06:04 2008 (r184754) @@ -304,8 +304,8 @@ distMaybeSetPorts(dialogMenuItem *self) { dialog_clear_norefresh(); if (!msgYesNo("Would you like to install the FreeBSD ports collection?\n\n" - "This will give you ready access to over 17,000 ported software packages,\n" - "at a cost of around 400MB of disk space when \"clean\" and possibly\n" + "This will give you ready access to over 19,000 ported software packages,\n" + "at a cost of around 445MB of disk space when \"clean\" and possibly\n" "much more than that when a lot of the distribution tarballs are loaded\n" "(unless you have the extra discs available from a FreeBSD CD/DVD distribution\n" "and can mount them on /cdrom, in which case this is far less of a problem).\n\n" From davidxu at FreeBSD.org Sun Nov 9 17:42:47 2008 From: davidxu at FreeBSD.org (David Xu) Date: Sun Nov 9 17:42:53 2008 Subject: svn commit: r184806 - in stable/7: include sys/kern sys/sys Message-ID: <200811100142.mAA1glCJ055598@svn.freebsd.org> Author: davidxu Date: Mon Nov 10 01:42:46 2008 New Revision: 184806 URL: http://svn.freebsd.org/changeset/base/184806 Log: MFC: Add POSIX clock id CLOCK_THREAD_CPUTIME_ID support. Approved by: re (kib) Modified: stable/7/include/time.h stable/7/include/unistd.h stable/7/sys/kern/kern_time.c stable/7/sys/sys/time.h Modified: stable/7/include/time.h ============================================================================== --- stable/7/include/time.h Mon Nov 10 01:24:19 2008 (r184805) +++ stable/7/include/time.h Mon Nov 10 01:42:46 2008 (r184806) @@ -108,6 +108,7 @@ typedef __timer_t timer_t; #define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */ #define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */ #define CLOCK_SECOND 13 /* FreeBSD-specific. */ +#define CLOCK_THREAD_CPUTIME_ID 14 #endif /* !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 */ #if !defined(TIMER_ABSTIME) && __POSIX_VISIBLE >= 200112 Modified: stable/7/include/unistd.h ============================================================================== --- stable/7/include/unistd.h Mon Nov 10 01:24:19 2008 (r184805) +++ stable/7/include/unistd.h Mon Nov 10 01:42:46 2008 (r184806) @@ -111,7 +111,7 @@ typedef __useconds_t useconds_t; #define _POSIX_SPIN_LOCKS 200112L #define _POSIX_THREAD_ATTR_STACKADDR 200112L #define _POSIX_THREAD_ATTR_STACKSIZE 200112L -#define _POSIX_THREAD_CPUTIME -1 +#define _POSIX_THREAD_CPUTIME 200112L #define _POSIX_THREAD_PRIO_INHERIT 200112L #define _POSIX_THREAD_PRIO_PROTECT 200112L #define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L Modified: stable/7/sys/kern/kern_time.c ============================================================================== --- stable/7/sys/kern/kern_time.c Mon Nov 10 01:24:19 2008 (r184805) +++ stable/7/sys/kern/kern_time.c Mon Nov 10 01:42:46 2008 (r184806) @@ -201,6 +201,7 @@ kern_clock_gettime(struct thread *td, cl { struct timeval sys, user; struct proc *p; + uint64_t runtime, curtime, switchtime; p = td->td_proc; switch (clock_id) { @@ -242,6 +243,16 @@ kern_clock_gettime(struct thread *td, cl ats->tv_sec = time_second; ats->tv_nsec = 0; break; + case CLOCK_THREAD_CPUTIME_ID: + critical_enter(); + switchtime = PCPU_GET(switchtime); + curtime = cpu_ticks(); + runtime = td->td_runtime; + critical_exit(); + runtime = cputick2usec(runtime + curtime - switchtime); + ats->tv_sec = runtime / 1000000; + ats->tv_nsec = runtime % 1000000 * 1000; + break; default: return (EINVAL); } Modified: stable/7/sys/sys/time.h ============================================================================== --- stable/7/sys/sys/time.h Mon Nov 10 01:24:19 2008 (r184805) +++ stable/7/sys/sys/time.h Mon Nov 10 01:42:46 2008 (r184806) @@ -246,6 +246,7 @@ struct clockinfo { #define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */ #define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */ #define CLOCK_SECOND 13 /* FreeBSD-specific. */ +#define CLOCK_THREAD_CPUTIME_ID 14 #endif #ifndef TIMER_ABSTIME From ndenev at gmail.com Mon Nov 10 04:39:59 2008 From: ndenev at gmail.com (Nikolay Denev) Date: Mon Nov 10 04:40:05 2008 Subject: svn commit: r184806 - in stable/7: include sys/kern sys/sys In-Reply-To: <200811100142.mAA1glCJ055598@svn.freebsd.org> References: <200811100142.mAA1glCJ055598@svn.freebsd.org> Message-ID: <217D0CE9-905B-4AAC-81E7-AE7AA8A00866@gmail.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 10 Nov, 2008, at 03:42 , David Xu wrote: > Author: davidxu > Date: Mon Nov 10 01:42:46 2008 > New Revision: 184806 > URL: http://svn.freebsd.org/changeset/base/184806 > > Log: > MFC: > Add POSIX clock id CLOCK_THREAD_CPUTIME_ID support. > > Approved by: re (kib) Thanks! - -- Regards, Nikolay Denev -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (Darwin) iEYEARECAAYFAkkYJBEACgkQHNAJ/fLbfrkh+gCgvT3i9t4Ulle7cJx4Us8NxfZS mqAAn0V+t6DFTDEuOCN4Mnrj4TR8d48K =GQgC -----END PGP SIGNATURE----- From jasone at FreeBSD.org Mon Nov 10 09:30:49 2008 From: jasone at FreeBSD.org (Jason Evans) Date: Mon Nov 10 09:31:06 2008 Subject: svn commit: r184819 - in stable/7/lib/libc: . stdlib Message-ID: <200811101730.mAAHUnIt076010@svn.freebsd.org> Author: jasone Date: Mon Nov 10 17:30:49 2008 New Revision: 184819 URL: http://svn.freebsd.org/changeset/base/184819 Log: MFC: Revert to preferring mmap(2) over sbrk(2) when mapping memory, due to potential extreme contention in the kernel for multi-threaded applications on SMP systems. Approved by: re (kib) Modified: stable/7/lib/libc/ (props changed) stable/7/lib/libc/stdlib/malloc.3 stable/7/lib/libc/stdlib/malloc.c Modified: stable/7/lib/libc/stdlib/malloc.3 ============================================================================== --- stable/7/lib/libc/stdlib/malloc.3 Mon Nov 10 16:44:25 2008 (r184818) +++ stable/7/lib/libc/stdlib/malloc.3 Mon Nov 10 17:30:49 2008 (r184819) @@ -250,7 +250,7 @@ If both the .Dq D and .Dq M -options are enabled, the allocator prefers the DSS over anonymous mappings, +options are enabled, the allocator prefers anonymous mappings over the DSS, but allocation only fails if memory cannot be acquired via either method. If neither option is enabled, then the .Dq M Modified: stable/7/lib/libc/stdlib/malloc.c ============================================================================== --- stable/7/lib/libc/stdlib/malloc.c Mon Nov 10 16:44:25 2008 (r184818) +++ stable/7/lib/libc/stdlib/malloc.c Mon Nov 10 17:30:49 2008 (r184819) @@ -1275,11 +1275,6 @@ base_pages_alloc(size_t minsize) { #ifdef MALLOC_DSS - if (opt_dss) { - if (base_pages_alloc_dss(minsize) == false) - return (false); - } - if (opt_mmap && minsize != 0) #endif { @@ -1287,6 +1282,14 @@ base_pages_alloc(size_t minsize) return (false); } +#ifdef MALLOC_DSS + if (opt_dss) { + if (base_pages_alloc_dss(minsize) == false) + return (false); + } + +#endif + return (true); } @@ -1709,6 +1712,15 @@ chunk_alloc(size_t size, bool zero) assert((size & chunksize_mask) == 0); #ifdef MALLOC_DSS + if (opt_mmap) +#endif + { + ret = chunk_alloc_mmap(size); + if (ret != NULL) + goto RETURN; + } + +#ifdef MALLOC_DSS if (opt_dss) { ret = chunk_recycle_dss(size, zero); if (ret != NULL) { @@ -1719,14 +1731,7 @@ chunk_alloc(size_t size, bool zero) if (ret != NULL) goto RETURN; } - - if (opt_mmap) #endif - { - ret = chunk_alloc_mmap(size); - if (ret != NULL) - goto RETURN; - } /* All strategies for allocation failed. */ ret = NULL; From rwatson at FreeBSD.org Mon Nov 10 10:24:12 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Nov 10 10:24:28 2008 Subject: svn commit: r184823 - in stable/7/sys: . modules/cxgb netinet Message-ID: <200811101824.mAAIOBdY077218@svn.freebsd.org> Author: rwatson Date: Mon Nov 10 18:24:11 2008 New Revision: 184823 URL: http://svn.freebsd.org/changeset/base/184823 Log: Merge r184298 from head to stable/7: Remove endearing but syntactically unnecessary "return;" statements directly before the final closeing brackets of some TCP functions. Approved by: re (gnn) Modified: stable/7/sys/ (props changed) stable/7/sys/modules/cxgb/ (props changed) stable/7/sys/netinet/tcp_input.c stable/7/sys/netinet/tcp_sack.c stable/7/sys/netinet/tcp_syncache.c Modified: stable/7/sys/netinet/tcp_input.c ============================================================================== --- stable/7/sys/netinet/tcp_input.c Mon Nov 10 18:09:52 2008 (r184822) +++ stable/7/sys/netinet/tcp_input.c Mon Nov 10 18:24:11 2008 (r184823) @@ -878,7 +878,6 @@ drop: free(s, M_TCPLOG); if (m != NULL) m_freem(m); - return; } static void @@ -2445,7 +2444,6 @@ drop: if (headlocked) INP_INFO_WUNLOCK(&tcbinfo); m_freem(m); - return; } /* @@ -2504,7 +2502,6 @@ tcp_dropwithreset(struct mbuf *m, struct return; drop: m_freem(m); - return; } /* Modified: stable/7/sys/netinet/tcp_sack.c ============================================================================== --- stable/7/sys/netinet/tcp_sack.c Mon Nov 10 18:09:52 2008 (r184822) +++ stable/7/sys/netinet/tcp_sack.c Mon Nov 10 18:24:11 2008 (r184823) @@ -677,5 +677,4 @@ tcp_sack_adjust(struct tcpcb *tp) if (SEQ_LT(tp->snd_nxt, cur->end)) return; tp->snd_nxt = tp->snd_fack; - return; } Modified: stable/7/sys/netinet/tcp_syncache.c ============================================================================== --- stable/7/sys/netinet/tcp_syncache.c Mon Nov 10 18:09:52 2008 (r184822) +++ stable/7/sys/netinet/tcp_syncache.c Mon Nov 10 18:24:11 2008 (r184823) @@ -1297,7 +1297,6 @@ done: #endif *lsop = NULL; m_freem(m); - return; } static int @@ -1624,7 +1623,6 @@ syncookie_generate(struct syncache_head } tcpstat.tcps_sc_sendcookie++; - return; } static struct syncache * From delphij at FreeBSD.org Mon Nov 10 14:40:17 2008 From: delphij at FreeBSD.org (Xin LI) Date: Mon Nov 10 14:40:30 2008 Subject: svn commit: r184826 - in stable/7/sys: . dev/bce Message-ID: <200811102240.mAAMeGfs084286@svn.freebsd.org> Author: delphij Date: Mon Nov 10 22:40:16 2008 New Revision: 184826 URL: http://svn.freebsd.org/changeset/base/184826 Log: Merge the following bce(4) changes: r176448,178132,178853,179436,179695,179771,182293 r176448 (davidch) - Added loose RX MTU functionality to allow frames larger than 1500 bytes to be accepted even though the interface MTU is set to 1500. - Implemented new TCP header splitting/jumbo frame support which uses two chains for receive traffic rather than the original single receive chain. - Added additional debug support code. r178132 (davidch) - Fixed a problem with the send chain consumer index which would cause TX traffic to sit in the send chain until a received packet kick started the interrupt handler. This would cause extremely slow performance when used with NFS over UDP. - Removed untested polling code. - Updated copyright year in the file header. - Removed inadvertent ^M's created by DOS text editor. r178853 (scottl) The BCE chips appear to have an undocumented requirement that RX frames be aligned on an 8 byte boundary. Prior to rev 1.36 (now r176448) this wasn't a problem because mbuf clusters tend be naturally aligned. The switch to using split buffers with the first buffer being the embedded data area of the mbuf has broken this assumption, at least on i386, causing a complete failure of RX functionality. Fix this for now by using a full cluster for the first RX buffer. A more sophisticated approach could be done with the old buffer scheme to realign the m_data pointer with m_adj(), but I'm also not clear on performance benefits of this old scheme or the performance implications of adding an m_adj() call to every allocation. r179436 (jhb) Trim an extra semi-colon. r179695 (davidch) - Fixed kern/123696 by increasing firmware timeout value from 100 to 1000. - Fixed a problem on i386 architecture when using split header/jumbo frame firmware caused by hardware alignment requirements. - Added #define BCE_USE_SPLIT_HEADER to allow the feature to be enabled/disabled. Enabled by default. PR: kern/123696 r179771 (davidch) - Added support for BCM5709 and BCM5716 controllers. r182293 (davidch) - Updated support for 5716. - Added some additional code for debug builds. - Fixed a problem printing physical memory on 64bit system during debugging. - Modified some of the context memory and mailbox register names to more clearly distinguish their use. - Added memory barriers for Intel CPUs when accessing host memory data structures which are written by hardware. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/dev/bce/if_bce.c stable/7/sys/dev/bce/if_bcefw.h stable/7/sys/dev/bce/if_bcereg.h Modified: stable/7/sys/dev/bce/if_bce.c ============================================================================== --- stable/7/sys/dev/bce/if_bce.c Mon Nov 10 22:06:24 2008 (r184825) +++ stable/7/sys/dev/bce/if_bce.c Mon Nov 10 22:40:16 2008 (r184826) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2006-2007 Broadcom Corporation + * Copyright (c) 2006-2008 Broadcom Corporation * David Christensen . All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,13 +34,19 @@ __FBSDID("$FreeBSD$"); /* * The following controllers are supported by this driver: * BCM5706C A2, A3 + * BCM5706S A2, A3 * BCM5708C B1, B2 + * BCM5708S B1, B2 + * BCM5709C A1, C0 + * BCM5716 C0 * * The following controllers are not supported by this driver: - * BCM5706C A0, A1 - * BCM5706S A0, A1, A2, A3 - * BCM5708C A0, B0 - * BCM5708S A0, B0, B1, B2 + * BCM5706C A0, A1 (pre-production) + * BCM5706S A0, A1 (pre-production) + * BCM5708C A0, B0 (pre-production) + * BCM5708S A0, B0 (pre-production) + * BCM5709C A0 B0, B1, B2 (pre-production) + * BCM5709S A0, A1, B0, B1, B2, C0 (pre-production) */ #include "opt_bce.h" @@ -80,6 +86,12 @@ __FBSDID("$FreeBSD$"); int bce_debug_bootcode_running_failure = 0; #endif +/****************************************************************************/ +/* BCE Build Time Options */ +/****************************************************************************/ +#define BCE_USE_SPLIT_HEADER 1 +/* #define BCE_NVRAM_WRITE_SUPPORT 1 */ + /****************************************************************************/ /* PCI Device ID Table */ @@ -110,6 +122,19 @@ static struct bce_type bce_devs[] = { /* BCM5708S controllers and OEM boards. */ { BRCM_VENDORID, BRCM_DEVICEID_BCM5708S, PCI_ANY_ID, PCI_ANY_ID, "Broadcom NetXtreme II BCM5708 1000Base-SX" }, + + /* BCM5709C controllers and OEM boards. */ + { BRCM_VENDORID, BRCM_DEVICEID_BCM5709, PCI_ANY_ID, PCI_ANY_ID, + "Broadcom NetXtreme II BCM5709 1000Base-T" }, + + /* BCM5709S controllers and OEM boards. */ + { BRCM_VENDORID, BRCM_DEVICEID_BCM5709S, PCI_ANY_ID, PCI_ANY_ID, + "Broadcom NetXtreme II BCM5709 1000Base-SX" }, + + /* BCM5716 controllers and OEM boards. */ + { BRCM_VENDORID, BRCM_DEVICEID_BCM5716, PCI_ANY_ID, PCI_ANY_ID, + "Broadcom NetXtreme II BCM5716 1000Base-T" }, + { 0, 0, 0, 0, NULL } }; @@ -119,91 +144,110 @@ static struct bce_type bce_devs[] = { /****************************************************************************/ static struct flash_spec flash_table[] = { +#define BUFFERED_FLAGS (BCE_NV_BUFFERED | BCE_NV_TRANSLATE) +#define NONBUFFERED_FLAGS (BCE_NV_WREN) + /* Slow EEPROM */ {0x00000000, 0x40830380, 0x009f0081, 0xa184a053, 0xaf000400, - 1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE, + BUFFERED_FLAGS, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE, SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE, "EEPROM - slow"}, /* Expansion entry 0001 */ {0x08000002, 0x4b808201, 0x00050081, 0x03840253, 0xaf020406, - 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, SAIFUN_FLASH_BYTE_ADDR_MASK, 0, "Entry 0001"}, /* Saifun SA25F010 (non-buffered flash) */ /* strap, cfg1, & write1 need updates */ {0x04000001, 0x47808201, 0x00050081, 0x03840253, 0xaf020406, - 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*2, "Non-buffered flash (128kB)"}, /* Saifun SA25F020 (non-buffered flash) */ /* strap, cfg1, & write1 need updates */ {0x0c000003, 0x4f808201, 0x00050081, 0x03840253, 0xaf020406, - 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE*4, "Non-buffered flash (256kB)"}, /* Expansion entry 0100 */ {0x11000000, 0x53808201, 0x00050081, 0x03840253, 0xaf020406, - 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, SAIFUN_FLASH_BYTE_ADDR_MASK, 0, "Entry 0100"}, /* Entry 0101: ST M45PE10 (non-buffered flash, TetonII B0) */ {0x19000002, 0x5b808201, 0x000500db, 0x03840253, 0xaf020406, - 0, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE, ST_MICRO_FLASH_BYTE_ADDR_MASK, ST_MICRO_FLASH_BASE_TOTAL_SIZE*2, "Entry 0101: ST M45PE10 (128kB non-bufferred)"}, /* Entry 0110: ST M45PE20 (non-buffered flash)*/ {0x15000001, 0x57808201, 0x000500db, 0x03840253, 0xaf020406, - 0, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE, ST_MICRO_FLASH_BYTE_ADDR_MASK, ST_MICRO_FLASH_BASE_TOTAL_SIZE*4, "Entry 0110: ST M45PE20 (256kB non-bufferred)"}, /* Saifun SA25F005 (non-buffered flash) */ /* strap, cfg1, & write1 need updates */ {0x1d000003, 0x5f808201, 0x00050081, 0x03840253, 0xaf020406, - 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, SAIFUN_FLASH_BYTE_ADDR_MASK, SAIFUN_FLASH_BASE_TOTAL_SIZE, "Non-buffered flash (64kB)"}, /* Fast EEPROM */ {0x22000000, 0x62808380, 0x009f0081, 0xa184a053, 0xaf000400, - 1, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE, + BUFFERED_FLAGS, SEEPROM_PAGE_BITS, SEEPROM_PAGE_SIZE, SEEPROM_BYTE_ADDR_MASK, SEEPROM_TOTAL_SIZE, "EEPROM - fast"}, /* Expansion entry 1001 */ {0x2a000002, 0x6b808201, 0x00050081, 0x03840253, 0xaf020406, - 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, SAIFUN_FLASH_BYTE_ADDR_MASK, 0, "Entry 1001"}, /* Expansion entry 1010 */ {0x26000001, 0x67808201, 0x00050081, 0x03840253, 0xaf020406, - 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, SAIFUN_FLASH_BYTE_ADDR_MASK, 0, "Entry 1010"}, /* ATMEL AT45DB011B (buffered flash) */ {0x2e000003, 0x6e808273, 0x00570081, 0x68848353, 0xaf000400, - 1, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE, + BUFFERED_FLAGS, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE, BUFFERED_FLASH_BYTE_ADDR_MASK, BUFFERED_FLASH_TOTAL_SIZE, "Buffered flash (128kB)"}, /* Expansion entry 1100 */ {0x33000000, 0x73808201, 0x00050081, 0x03840253, 0xaf020406, - 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, SAIFUN_FLASH_BYTE_ADDR_MASK, 0, "Entry 1100"}, /* Expansion entry 1101 */ {0x3b000002, 0x7b808201, 0x00050081, 0x03840253, 0xaf020406, - 0, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, + NONBUFFERED_FLAGS, SAIFUN_FLASH_PAGE_BITS, SAIFUN_FLASH_PAGE_SIZE, SAIFUN_FLASH_BYTE_ADDR_MASK, 0, "Entry 1101"}, /* Ateml Expansion entry 1110 */ {0x37000001, 0x76808273, 0x00570081, 0x68848353, 0xaf000400, - 1, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE, + BUFFERED_FLAGS, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE, BUFFERED_FLASH_BYTE_ADDR_MASK, 0, "Entry 1110 (Atmel)"}, /* ATMEL AT45DB021B (buffered flash) */ {0x3f000003, 0x7e808273, 0x00570081, 0x68848353, 0xaf000400, - 1, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE, + BUFFERED_FLAGS, BUFFERED_FLASH_PAGE_BITS, BUFFERED_FLASH_PAGE_SIZE, BUFFERED_FLASH_BYTE_ADDR_MASK, BUFFERED_FLASH_TOTAL_SIZE*2, "Buffered flash (256kB)"}, }; +/* + * The BCM5709 controllers transparently handle the + * differences between Atmel 264 byte pages and all + * flash devices which use 256 byte pages, so no + * logical-to-physical mapping is required in the + * driver. + */ +static struct flash_spec flash_5709 = { + .flags = BCE_NV_BUFFERED, + .page_bits = BCM5709_FLASH_PAGE_BITS, + .page_size = BCM5709_FLASH_PAGE_SIZE, + .addr_mask = BCM5709_FLASH_BYTE_ADDR_MASK, + .total_size = BUFFERED_FLASH_TOTAL_SIZE * 2, + .name = "5709/5716 buffered flash (256kB)", +}; + /****************************************************************************/ /* FreeBSD device entry points. */ @@ -218,19 +262,41 @@ static int bce_shutdown (device_t); /* BCE Debug Data Structure Dump Routines */ /****************************************************************************/ #ifdef BCE_DEBUG +static u32 bce_reg_rd (struct bce_softc *, u32); +static void bce_reg_wr (struct bce_softc *, u32, u32); +static void bce_reg_wr16 (struct bce_softc *, u32, u16); +static u32 bce_ctx_rd (struct bce_softc *, u32, u32); +static void bce_dump_enet (struct bce_softc *, struct mbuf *); static void bce_dump_mbuf (struct bce_softc *, struct mbuf *); -static void bce_dump_tx_mbuf_chain (struct bce_softc *, int, int); -static void bce_dump_rx_mbuf_chain (struct bce_softc *, int, int); +static void bce_dump_tx_mbuf_chain (struct bce_softc *, u16, int); +static void bce_dump_rx_mbuf_chain (struct bce_softc *, u16, int); +#ifdef BCE_USE_SPLIT_HEADER +static void bce_dump_pg_mbuf_chain (struct bce_softc *, u16, int); +#endif static void bce_dump_txbd (struct bce_softc *, int, struct tx_bd *); static void bce_dump_rxbd (struct bce_softc *, int, struct rx_bd *); +#ifdef BCE_USE_SPLIT_HEADER +static void bce_dump_pgbd (struct bce_softc *, int, struct rx_bd *); +#endif static void bce_dump_l2fhdr (struct bce_softc *, int, struct l2_fhdr *); -static void bce_dump_tx_chain (struct bce_softc *, int, int); -static void bce_dump_rx_chain (struct bce_softc *, int, int); +static void bce_dump_ctx (struct bce_softc *, u16); +static void bce_dump_ftqs (struct bce_softc *); +static void bce_dump_tx_chain (struct bce_softc *, u16, int); +static void bce_dump_rx_chain (struct bce_softc *, u16, int); +#ifdef BCE_USE_SPLIT_HEADER +static void bce_dump_pg_chain (struct bce_softc *, u16, int); +#endif static void bce_dump_status_block (struct bce_softc *); static void bce_dump_stats_block (struct bce_softc *); static void bce_dump_driver_state (struct bce_softc *); static void bce_dump_hw_state (struct bce_softc *); +static void bce_dump_mq_regs (struct bce_softc *); static void bce_dump_bc_state (struct bce_softc *); +static void bce_dump_txp_state (struct bce_softc *, int); +static void bce_dump_rxp_state (struct bce_softc *, int); +static void bce_dump_tpat_state (struct bce_softc *, int); +static void bce_dump_cp_state (struct bce_softc *, int); +static void bce_dump_com_state (struct bce_softc *, int); static void bce_breakpoint (struct bce_softc *); #endif @@ -268,6 +334,7 @@ static int bce_nvram_write (struct bc /****************************************************************************/ /* */ /****************************************************************************/ +static void bce_get_media (struct bce_softc *); static void bce_dma_map_addr (void *, bus_dma_segment_t *, int, int); static int bce_dma_alloc (device_t); static void bce_dma_free (struct bce_softc *); @@ -279,19 +346,34 @@ static void bce_release_resources (struc static int bce_fw_sync (struct bce_softc *, u32); static void bce_load_rv2p_fw (struct bce_softc *, u32 *, u32, u32); static void bce_load_cpu_fw (struct bce_softc *, struct cpu_reg *, struct fw_info *); +static void bce_init_rxp_cpu (struct bce_softc *); +static void bce_init_txp_cpu (struct bce_softc *); +static void bce_init_tpat_cpu (struct bce_softc *); +static void bce_init_cp_cpu (struct bce_softc *); +static void bce_init_com_cpu (struct bce_softc *); static void bce_init_cpus (struct bce_softc *); +static void bce_print_adapter_info (struct bce_softc *); +static void bce_probe_pci_caps (device_t, struct bce_softc *); static void bce_stop (struct bce_softc *); static int bce_reset (struct bce_softc *, u32); static int bce_chipinit (struct bce_softc *); static int bce_blockinit (struct bce_softc *); -static int bce_get_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *, u32 *); static int bce_init_tx_chain (struct bce_softc *); -static void bce_fill_rx_chain (struct bce_softc *); +static void bce_free_tx_chain (struct bce_softc *); + +static int bce_get_rx_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *, u32 *); static int bce_init_rx_chain (struct bce_softc *); +static void bce_fill_rx_chain (struct bce_softc *); static void bce_free_rx_chain (struct bce_softc *); -static void bce_free_tx_chain (struct bce_softc *); + +#ifdef BCE_USE_SPLIT_HEADER +static int bce_get_pg_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *); +static int bce_init_pg_chain (struct bce_softc *); +static void bce_fill_pg_chain (struct bce_softc *); +static void bce_free_pg_chain (struct bce_softc *); +#endif static int bce_tx_encap (struct bce_softc *, struct mbuf **); static void bce_start_locked (struct ifnet *); @@ -305,19 +387,16 @@ static void bce_init_locked (struct bc static void bce_init (void *); static void bce_mgmt_init_locked (struct bce_softc *sc); -static void bce_init_context (struct bce_softc *); +static void bce_init_ctx (struct bce_softc *); static void bce_get_mac_addr (struct bce_softc *); static void bce_set_mac_addr (struct bce_softc *); static void bce_phy_intr (struct bce_softc *); +static inline u16 bce_get_hw_rx_cons(struct bce_softc *); static void bce_rx_intr (struct bce_softc *); static void bce_tx_intr (struct bce_softc *); static void bce_disable_intr (struct bce_softc *); -static void bce_enable_intr (struct bce_softc *); +static void bce_enable_intr (struct bce_softc *, int); -#ifdef DEVICE_POLLING -static void bce_poll_locked (struct ifnet *, enum poll_cmd, int); -static void bce_poll (struct ifnet *, enum poll_cmd, int); -#endif static void bce_intr (void *); static void bce_set_rx_mode (struct bce_softc *); static void bce_stats_update (struct bce_softc *); @@ -330,20 +409,28 @@ static void bce_add_sysctls (struct bc /* FreeBSD device dispatch table. */ /****************************************************************************/ static device_method_t bce_methods[] = { - /* Device interface */ + /* Device interface (device_if.h) */ DEVMETHOD(device_probe, bce_probe), DEVMETHOD(device_attach, bce_attach), DEVMETHOD(device_detach, bce_detach), DEVMETHOD(device_shutdown, bce_shutdown), +/* Supported by device interface but not used here. */ +/* DEVMETHOD(device_identify, bce_identify), */ +/* DEVMETHOD(device_suspend, bce_suspend), */ +/* DEVMETHOD(device_resume, bce_resume), */ +/* DEVMETHOD(device_quiesce, bce_quiesce), */ - /* bus interface */ + /* Bus interface (bus_if.h) */ DEVMETHOD(bus_print_child, bus_generic_print_child), DEVMETHOD(bus_driver_added, bus_generic_driver_added), - /* MII interface */ + /* MII interface (miibus_if.h) */ DEVMETHOD(miibus_readreg, bce_miibus_read_reg), DEVMETHOD(miibus_writereg, bce_miibus_write_reg), DEVMETHOD(miibus_statchg, bce_miibus_statchg), +/* Supported by MII interface but not used here. */ +/* DEVMETHOD(miibus_linkchg, bce_miibus_linkchg), */ +/* DEVMETHOD(miibus_mediainit, bce_miibus_mediainit), */ { 0, 0 } }; @@ -367,19 +454,26 @@ DRIVER_MODULE(miibus, bce, miibus_driver /****************************************************************************/ /* Tunable device values */ /****************************************************************************/ -static int bce_tso_enable = TRUE; -static int bce_msi_enable = 1; +SYSCTL_NODE(_hw, OID_AUTO, bce, CTLFLAG_RD, 0, "bce driver parameters"); /* Allowable values are TRUE or FALSE */ +static int bce_tso_enable = TRUE; TUNABLE_INT("hw.bce.tso_enable", &bce_tso_enable); -/* Allowable values are 0 (IRQ only) and 1 (IRQ or MSI) */ -TUNABLE_INT("hw.bce.msi_enable", &bce_msi_enable); - -SYSCTL_NODE(_hw, OID_AUTO, bce, CTLFLAG_RD, 0, "bce driver parameters"); SYSCTL_UINT(_hw_bce, OID_AUTO, tso_enable, CTLFLAG_RDTUN, &bce_tso_enable, 0, "TSO Enable/Disable"); + +/* Allowable values are 0 (IRQ), 1 (MSI/IRQ), and 2 (MSI-X/MSI/IRQ) */ +/* ToDo: Add MSI-X support. */ +static int bce_msi_enable = 1; +TUNABLE_INT("hw.bce.msi_enable", &bce_msi_enable); SYSCTL_UINT(_hw_bce, OID_AUTO, msi_enable, CTLFLAG_RDTUN, &bce_msi_enable, 0, -"MSI | INTx selector"); +"MSI-X|MSI|INTx selector"); + +/* ToDo: Add tunable to enable/disable strict MTU handling. */ +/* Currently allows "loose" RX MTU checking (i.e. sets the */ +/* H/W RX MTU to the size of the largest receive buffer, or */ +/* 2048 bytes). */ + /****************************************************************************/ /* Device probe function. */ @@ -411,14 +505,14 @@ bce_probe(device_t dev) svid = pci_get_subvendor(dev); sdid = pci_get_subdevice(dev); - DBPRINT(sc, BCE_VERBOSE_LOAD, + DBPRINT(sc, BCE_EXTREME_LOAD, "%s(); VID = 0x%04X, DID = 0x%04X, SVID = 0x%04X, " "SDID = 0x%04X\n", __FUNCTION__, vid, did, svid, sdid); /* Look through the list of known devices for a match. */ while(t->bce_name != NULL) { - if ((vid == t->bce_vid) && (did == t->bce_did) && + if ((vid == t->bce_vid) && (did == t->bce_did) && ((svid == t->bce_svid) || (t->bce_svid == PCI_ANY_ID)) && ((sdid == t->bce_sdid) || (t->bce_sdid == PCI_ANY_ID))) { @@ -428,7 +522,7 @@ bce_probe(device_t dev) return(ENOMEM); /* Print out the device identity. */ - snprintf(descbuf, BCE_DEVDESC_MAX, "%s (%c%d)", + snprintf(descbuf, BCE_DEVDESC_MAX, "%s (%c%d)", t->bce_name, (((pci_read_config(dev, PCIR_REVID, 4) & 0xf0) >> 4) + 'A'), (pci_read_config(dev, PCIR_REVID, 4) & 0xf)); @@ -445,6 +539,109 @@ bce_probe(device_t dev) /****************************************************************************/ +/* PCI Capabilities Probe Function. */ +/* */ +/* Walks the PCI capabiites list for the device to find what features are */ +/* supported. */ +/* */ +/* Returns: */ +/* None. */ +/****************************************************************************/ +static void +bce_print_adapter_info(struct bce_softc *sc) +{ + DBENTER(BCE_VERBOSE_LOAD); + + BCE_PRINTF("ASIC (0x%08X); ", sc->bce_chipid); + printf("Rev (%c%d); ", ((BCE_CHIP_ID(sc) & 0xf000) >> 12) + 'A', + ((BCE_CHIP_ID(sc) & 0x0ff0) >> 4)); + + /* Bus info. */ + if (sc->bce_flags & BCE_PCIE_FLAG) { + printf("Bus (PCIe x%d, ", sc->link_width); + switch (sc->link_speed) { + case 1: printf("2.5Gbps); "); break; + case 2: printf("5Gbps); "); break; + default: printf("Unknown link speed); "); + } + } else { + printf("Bus (PCI%s, %s, %dMHz); ", + ((sc->bce_flags & BCE_PCIX_FLAG) ? "-X" : ""), + ((sc->bce_flags & BCE_PCI_32BIT_FLAG) ? "32-bit" : "64-bit"), + sc->bus_speed_mhz); + } + + /* Firmware version and device features. */ + printf("F/W (0x%08X); Flags( ", sc->bce_fw_ver); +#ifdef BCE_USE_SPLIT_HEADER + printf("SPLT "); +#endif + if (sc->bce_flags & BCE_MFW_ENABLE_FLAG) + printf("MFW "); + if (sc->bce_flags & BCE_USING_MSI_FLAG) + printf("MSI "); + if (sc->bce_flags & BCE_USING_MSIX_FLAG) + printf("MSI-X "); + if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) + printf("2.5G "); + printf(")\n"); + + DBEXIT(BCE_VERBOSE_LOAD); +} + + +/****************************************************************************/ +/* PCI Capabilities Probe Function. */ +/* */ +/* Walks the PCI capabiites list for the device to find what features are */ +/* supported. */ +/* */ +/* Returns: */ +/* None. */ +/****************************************************************************/ +static void +bce_probe_pci_caps(device_t dev, struct bce_softc *sc) +{ + u32 reg; + + DBENTER(BCE_VERBOSE_LOAD); + + /* Check if PCI-X capability is enabled. */ + if (pci_find_extcap(dev, PCIY_PCIX, ®) == 0) { + if (reg != 0) + sc->bce_cap_flags |= BCE_PCIX_CAPABLE_FLAG; + } + + /* Check if PCIe capability is enabled. */ + if (pci_find_extcap(dev, PCIY_EXPRESS, ®) == 0) { + if (reg != 0) { + u16 link_status = pci_read_config(dev, reg + 0x12, 2); + DBPRINT(sc, BCE_INFO_LOAD, "PCIe link_status = 0x%08X\n", + link_status); + sc->link_speed = link_status & 0xf; + sc->link_width = (link_status >> 4) & 0x3f; + sc->bce_cap_flags |= BCE_PCIE_CAPABLE_FLAG; + sc->bce_flags |= BCE_PCIE_FLAG; + } + } + + /* Check if MSI capability is enabled. */ + if (pci_find_extcap(dev, PCIY_MSI, ®) == 0) { + if (reg != 0) + sc->bce_cap_flags |= BCE_MSI_CAPABLE_FLAG; + } + + /* Check if MSI-X capability is enabled. */ + if (pci_find_extcap(dev, PCIY_MSIX, ®) == 0) { + if (reg != 0) + sc->bce_cap_flags |= BCE_MSIX_CAPABLE_FLAG; + } + + DBEXIT(BCE_VERBOSE_LOAD); +} + + +/****************************************************************************/ /* Device attach function. */ /* */ /* Allocates device resources, performs secondary chip identification, */ @@ -460,21 +657,19 @@ bce_attach(device_t dev) struct bce_softc *sc; struct ifnet *ifp; u32 val; - int count, mbuf, rid, rc = 0; + int error, rid, rc = 0; sc = device_get_softc(dev); sc->bce_dev = dev; - DBPRINT(sc, BCE_VERBOSE_RESET, "Entering %s()\n", __FUNCTION__); + DBENTER(BCE_VERBOSE_LOAD | BCE_VERBOSE_RESET); - mbuf = device_get_unit(dev); + sc->bce_unit = device_get_unit(dev); /* Set initial device and PHY flags */ sc->bce_flags = 0; sc->bce_phy_flags = 0; - sc->bce_unit = mbuf; - pci_enable_busmaster(dev); /* Allocate PCI memory resources. */ @@ -483,7 +678,7 @@ bce_attach(device_t dev) &rid, RF_ACTIVE | PCI_RF_DENSE); if (sc->bce_res_mem == NULL) { - BCE_PRINTF("%s(%d): PCI memory allocation failed\n", + BCE_PRINTF("%s(%d): PCI memory allocation failed\n", __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; @@ -494,25 +689,74 @@ bce_attach(device_t dev) sc->bce_bhandle = rman_get_bushandle(sc->bce_res_mem); sc->bce_vhandle = (vm_offset_t) rman_get_virtual(sc->bce_res_mem); - /* If MSI is enabled in the driver, get the vector count. */ - count = bce_msi_enable ? pci_msi_count(dev) : 0; + bce_probe_pci_caps(dev, sc); - /* Allocate PCI IRQ resources. */ - if (count == 1 && pci_alloc_msi(dev, &count) == 0 && count == 1) { - rid = 1; - sc->bce_flags |= BCE_USING_MSI_FLAG; - DBPRINT(sc, BCE_VERBOSE_LOAD, - "Allocating %d MSI interrupt(s)\n", count); - } else { + rid = 1; +#if 0 + /* Try allocating MSI-X interrupts. */ + if ((sc->bce_cap_flags & BCE_MSIX_CAPABLE_FLAG) && + (bce_msi_enable >= 2) && + ((sc->bce_res_irq = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &rid, RF_ACTIVE)) != NULL)) { + + msi_needed = sc->bce_msi_count = 1; + + if (((error = pci_alloc_msix(dev, &sc->bce_msi_count)) != 0) || + (sc->bce_msi_count != msi_needed)) { + BCE_PRINTF("%s(%d): MSI-X allocation failed! Requested = %d," + "Received = %d, error = %d\n", __FILE__, __LINE__, + msi_needed, sc->bce_msi_count, error); + sc->bce_msi_count = 0; + pci_release_msi(dev); + bus_release_resource(dev, SYS_RES_MEMORY, rid, + sc->bce_res_irq); + sc->bce_res_irq = NULL; + } else { + DBPRINT(sc, BCE_INFO_LOAD, "%s(): Using MSI-X interrupt.\n", + __FUNCTION__); + sc->bce_flags |= BCE_USING_MSIX_FLAG; + sc->bce_intr = bce_intr; + } + } +#endif + + /* Try allocating a MSI interrupt. */ + if ((sc->bce_cap_flags & BCE_MSI_CAPABLE_FLAG) && + (bce_msi_enable >= 1) && (sc->bce_msi_count == 0)) { + sc->bce_msi_count = 1; + if ((error = pci_alloc_msi(dev, &sc->bce_msi_count)) != 0) { + BCE_PRINTF("%s(%d): MSI allocation failed! error = %d\n", + __FILE__, __LINE__, error); + sc->bce_msi_count = 0; + pci_release_msi(dev); + } else { + DBPRINT(sc, BCE_INFO_LOAD, "%s(): Using MSI interrupt.\n", + __FUNCTION__); + sc->bce_flags |= BCE_USING_MSI_FLAG; + if ((BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5709) || + (BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5716)) + sc->bce_flags |= BCE_ONE_SHOT_MSI_FLAG; + sc->bce_irq_rid = 1; + sc->bce_intr = bce_intr; + } + } + + /* Try allocating a legacy interrupt. */ + if (sc->bce_msi_count == 0) { + DBPRINT(sc, BCE_INFO_LOAD, "%s(): Using INTx interrupt.\n", + __FUNCTION__); rid = 0; - DBPRINT(sc, BCE_VERBOSE_LOAD, "Allocating IRQ interrupt\n"); + sc->bce_intr = bce_intr; } - sc->bce_res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + sc->bce_res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, + &rid, RF_SHAREABLE | RF_ACTIVE); + + sc->bce_irq_rid = rid; + /* Report any IRQ allocation errors. */ if (sc->bce_res_irq == NULL) { - BCE_PRINTF("%s(%d): PCI map interrupt failed!\n", + BCE_PRINTF("%s(%d): PCI map interrupt failed!\n", __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; @@ -540,18 +784,22 @@ bce_attach(device_t dev) case BCE_CHIP_ID_5706_A1: case BCE_CHIP_ID_5708_A0: case BCE_CHIP_ID_5708_B0: + case BCE_CHIP_ID_5709_A0: + case BCE_CHIP_ID_5709_B0: + case BCE_CHIP_ID_5709_B1: + case BCE_CHIP_ID_5709_B2: BCE_PRINTF("%s(%d): Unsupported controller revision (%c%d)!\n", - __FILE__, __LINE__, + __FILE__, __LINE__, (((pci_read_config(dev, PCIR_REVID, 4) & 0xf0) >> 4) + 'A'), (pci_read_config(dev, PCIR_REVID, 4) & 0xf)); rc = ENODEV; goto bce_attach_fail; } - /* - * The embedded PCIe to PCI-X bridge (EPB) - * in the 5708 cannot address memory above - * 40 bits (E7_5708CB1_23043 & E6_5708SB1_23043). + /* + * The embedded PCIe to PCI-X bridge (EPB) + * in the 5708 cannot address memory above + * 40 bits (E7_5708CB1_23043 & E6_5708SB1_23043). */ if (BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5708) sc->max_bus_addr = BCE_BUS_SPACE_MAXADDR; @@ -565,25 +813,23 @@ bce_attach(device_t dev) */ val = REG_RD_IND(sc, BCE_SHM_HDR_SIGNATURE); if ((val & BCE_SHM_HDR_SIGNATURE_SIG_MASK) == BCE_SHM_HDR_SIGNATURE_SIG) - sc->bce_shmem_base = REG_RD_IND(sc, BCE_SHM_HDR_ADDR_0); + /* Multi-port devices use different offsets in shared memory. */ + sc->bce_shmem_base = REG_RD_IND(sc, BCE_SHM_HDR_ADDR_0 + + (pci_get_function(sc->bce_dev) << 2)); else sc->bce_shmem_base = HOST_VIEW_SHMEM_BASE; - DBPRINT(sc, BCE_VERBOSE_FIRMWARE, "%s(): bce_shmem_base = 0x%08X\n", + DBPRINT(sc, BCE_VERBOSE_FIRMWARE, "%s(): bce_shmem_base = 0x%08X\n", __FUNCTION__, sc->bce_shmem_base); - sc->bce_fw_ver = REG_RD_IND(sc, sc->bce_shmem_base + + /* Fetch the bootcode revision. */ + sc->bce_fw_ver = REG_RD_IND(sc, sc->bce_shmem_base + BCE_DEV_INFO_BC_REV); - DBPRINT(sc, BCE_INFO_FIRMWARE, "%s(): bce_fw_ver = 0x%08X\n", - __FUNCTION__, sc->bce_fw_ver); /* Check if any management firmware is running. */ val = REG_RD_IND(sc, sc->bce_shmem_base + BCE_PORT_FEATURE); - if (val & (BCE_PORT_FEATURE_ASF_ENABLED | BCE_PORT_FEATURE_IMD_ENABLED)) { + if (val & (BCE_PORT_FEATURE_ASF_ENABLED | BCE_PORT_FEATURE_IMD_ENABLED)) sc->bce_flags |= BCE_MFW_ENABLE_FLAG; - DBPRINT(sc, BCE_INFO_LOAD, "%s(): BCE_MFW_ENABLE_FLAG\n", - __FUNCTION__); - } /* Get PCI bus information (speed and type). */ val = REG_RD(sc, BCE_PCICFG_MISC_STATUS); @@ -632,7 +878,7 @@ bce_attach(device_t dev) /* Reset the controller and announce to bootcode that driver is present. */ if (bce_reset(sc, BCE_DRV_MSG_CODE_RESET)) { - BCE_PRINTF("%s(%d): Controller reset failed!\n", + BCE_PRINTF("%s(%d): Controller reset failed!\n", __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; @@ -662,7 +908,7 @@ bce_attach(device_t dev) * should be ready before generating an * interrupt while ticks control how long * a BD can sit in the chain before - * generating an interrupt. Set the default + * generating an interrupt. Set the default * values for the RX and TX chains. */ @@ -693,33 +939,14 @@ bce_attach(device_t dev) /* Update statistics once every second. */ sc->bce_stats_ticks = 1000000 & 0xffff00; - /* - * The SerDes based NetXtreme II controllers - * that support 2.5Gb operation (currently - * 5708S) use a PHY at address 2, otherwise - * the PHY is present at address 1. - */ - sc->bce_phy_addr = 1; - - if (BCE_CHIP_BOND_ID(sc) & BCE_CHIP_BOND_ID_SERDES_BIT) { - sc->bce_phy_flags |= BCE_PHY_SERDES_FLAG; - sc->bce_flags |= BCE_NO_WOL_FLAG; - if (BCE_CHIP_NUM(sc) != BCE_CHIP_NUM_5706) { - sc->bce_phy_addr = 2; - val = REG_RD_IND(sc, sc->bce_shmem_base + - BCE_SHARED_HW_CFG_CONFIG); - if (val & BCE_SHARED_HW_CFG_PHY_2_5G) { - sc->bce_phy_flags |= BCE_PHY_2_5G_CAPABLE_FLAG; - DBPRINT(sc, BCE_INFO_LOAD, "Found 2.5Gb capable adapter\n"); - } - } - } + /* Find the media type for the adapter. */ + bce_get_media(sc); /* Store data needed by PHY driver for backplane applications */ sc->bce_shared_hw_cfg = REG_RD_IND(sc, sc->bce_shmem_base + BCE_SHARED_HW_CFG_CONFIG); sc->bce_port_hw_cfg = REG_RD_IND(sc, sc->bce_shmem_base + - BCE_SHARED_HW_CFG_CONFIG); + BCE_PORT_HW_CFG_CONFIG); /* Allocate DMA memory resources. */ if (bce_dma_alloc(dev)) { @@ -732,7 +959,7 @@ bce_attach(device_t dev) /* Allocate an ifnet structure. */ ifp = sc->bce_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { - BCE_PRINTF("%s(%d): Interface allocation failed!\n", + BCE_PRINTF("%s(%d): Interface allocation failed!\n", __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; @@ -757,10 +984,24 @@ bce_attach(device_t dev) ifp->if_capenable = ifp->if_capabilities; - /* Assume a standard 1500 byte MTU size for mbuf allocations. */ - sc->mbuf_alloc_size = MCLBYTES; -#ifdef DEVICE_POLLING - ifp->if_capabilities |= IFCAP_POLLING; + /* + * Assume standard mbuf sizes for buffer allocation. + * This may change later if the MTU size is set to + * something other than 1500. + */ +#ifdef BCE_USE_SPLIT_HEADER + sc->rx_bd_mbuf_alloc_size = MHLEN; + /* Make sure offset is 16 byte aligned for hardware. */ + sc->rx_bd_mbuf_align_pad = roundup2((MSIZE - MHLEN), 16) - + (MSIZE - MHLEN); + sc->rx_bd_mbuf_data_len = sc->rx_bd_mbuf_alloc_size - + sc->rx_bd_mbuf_align_pad; + sc->pg_bd_mbuf_alloc_size = MCLBYTES; +#else + sc->rx_bd_mbuf_alloc_size = MCLBYTES; + sc->rx_bd_mbuf_align_pad = roundup2(MCLBYTES, 16) - MCLBYTES; + sc->rx_bd_mbuf_data_len = sc->rx_bd_mbuf_alloc_size - + sc->rx_bd_mbuf_align_pad; #endif ifp->if_snd.ifq_drv_maxlen = USABLE_TX_BD; @@ -775,7 +1016,7 @@ bce_attach(device_t dev) /* Check for an MII child bus by probing the PHY. */ if (mii_phy_probe(dev, &sc->bce_miibus, bce_ifmedia_upd, bce_ifmedia_sts)) { - BCE_PRINTF("%s(%d): No PHY found on child MII bus!\n", + BCE_PRINTF("%s(%d): No PHY found on child MII bus!\n", __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; @@ -793,30 +1034,31 @@ bce_attach(device_t dev) #endif /* Hookup IRQ last. */ - rc = bus_setup_intr(dev, sc->bce_res_irq, INTR_TYPE_NET | INTR_MPSAFE, NULL, - bce_intr, sc, &sc->bce_intrhand); + rc = bus_setup_intr(dev, sc->bce_res_irq, INTR_TYPE_NET | INTR_MPSAFE, + NULL, bce_intr, sc, &sc->bce_intrhand); if (rc) { - BCE_PRINTF("%s(%d): Failed to setup IRQ!\n", + BCE_PRINTF("%s(%d): Failed to setup IRQ!\n", __FILE__, __LINE__); bce_detach(dev); goto bce_attach_exit; } - /* - * At this point we've acquired all the resources + /* + * At this point we've acquired all the resources * we need to run so there's no turning back, we're * cleared for launch. */ /* Print some important debugging info. */ - DBRUN(BCE_INFO, bce_dump_driver_state(sc)); + DBRUNMSG(BCE_INFO, bce_dump_driver_state(sc)); /* Add the supported sysctls to the kernel. */ bce_add_sysctls(sc); BCE_LOCK(sc); - /* + + /* * The chip reset earlier notified the bootcode that * a driver is present. We now need to start our pulse * routine so that the bootcode is reminded that we're @@ -828,21 +1070,9 @@ bce_attach(device_t dev) BCE_UNLOCK(sc); /* Finally, print some useful adapter info */ - BCE_PRINTF("ASIC (0x%08X); ", sc->bce_chipid); - printf("Rev (%c%d); ", ((BCE_CHIP_ID(sc) & 0xf000) >> 12) + 'A', - ((BCE_CHIP_ID(sc) & 0x0ff0) >> 4)); - printf("Bus (PCI%s, %s, %dMHz); ", - ((sc->bce_flags & BCE_PCIX_FLAG) ? "-X" : ""), - ((sc->bce_flags & BCE_PCI_32BIT_FLAG) ? "32-bit" : "64-bit"), - sc->bus_speed_mhz); - printf("F/W (0x%08X); Flags( ", sc->bce_fw_ver); - if (sc->bce_flags & BCE_MFW_ENABLE_FLAG) - printf("MFW "); - if (sc->bce_flags & BCE_USING_MSI_FLAG) - printf("MSI "); - if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) - printf("2.5G "); - printf(")\n"); + bce_print_adapter_info(sc); + DBPRINT(sc, BCE_FATAL, "%s(): sc = %p\n", + __FUNCTION__, sc); goto bce_attach_exit; @@ -851,7 +1081,7 @@ bce_attach_fail: bce_attach_exit: - DBPRINT(sc, BCE_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); + DBEXIT(BCE_VERBOSE_LOAD | BCE_VERBOSE_RESET); return(rc); } @@ -872,26 +1102,23 @@ bce_detach(device_t dev) struct ifnet *ifp; u32 msg; - DBPRINT(sc, BCE_VERBOSE_RESET, "Entering %s()\n", __FUNCTION__); + DBENTER(BCE_VERBOSE_UNLOAD | BCE_VERBOSE_RESET); ifp = sc->bce_ifp; -#ifdef DEVICE_POLLING - if (ifp->if_capenable & IFCAP_POLLING) - ether_poll_deregister(ifp); -#endif + /* Stop and reset the controller. */ + BCE_LOCK(sc); /* Stop the pulse so the bootcode can go to driver absent state. */ callout_stop(&sc->bce_pulse_callout); - /* Stop and reset the controller. */ - BCE_LOCK(sc); bce_stop(sc); if (sc->bce_flags & BCE_NO_WOL_FLAG) msg = BCE_DRV_MSG_CODE_UNLOAD_LNK_DN; else msg = BCE_DRV_MSG_CODE_UNLOAD; bce_reset(sc, msg); + BCE_UNLOCK(sc); ether_ifdetach(ifp); @@ -903,7 +1130,7 @@ bce_detach(device_t dev) /* Release all remaining resources. */ bce_release_resources(sc); - DBPRINT(sc, BCE_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); + DBEXIT(BCE_VERBOSE_UNLOAD | BCE_VERBOSE_RESET); return(0); } @@ -923,7 +1150,7 @@ bce_shutdown(device_t dev) struct bce_softc *sc = device_get_softc(dev); u32 msg; - DBPRINT(sc, BCE_VERBOSE_SPECIAL, "Entering %s()\n", __FUNCTION__); + DBENTER(BCE_VERBOSE); BCE_LOCK(sc); bce_stop(sc); @@ -933,13 +1160,60 @@ bce_shutdown(device_t dev) msg = BCE_DRV_MSG_CODE_UNLOAD; bce_reset(sc, msg); BCE_UNLOCK(sc); - - DBPRINT(sc, BCE_VERBOSE_SPECIAL, "Exiting %s()\n", __FUNCTION__); + + DBEXIT(BCE_VERBOSE); return (0); } +#ifdef BCE_DEBUG +/****************************************************************************/ +/* Register read. */ +/* */ +/* Returns: */ +/* The value of the register. */ +/****************************************************************************/ +static u32 +bce_reg_rd(struct bce_softc *sc, u32 offset) +{ + u32 val = bus_space_read_4(sc->bce_btag, sc->bce_bhandle, offset); + DBPRINT(sc, BCE_INSANE_REG, "%s(); offset = 0x%08X, val = 0x%08X\n", + __FUNCTION__, offset, val); + return val; +} + + +/****************************************************************************/ +/* Register write (16 bit). */ +/* */ +/* Returns: */ +/* Nothing. */ +/****************************************************************************/ +static void +bce_reg_wr16(struct bce_softc *sc, u32 offset, u16 val) +{ + DBPRINT(sc, BCE_INSANE_REG, "%s(); offset = 0x%08X, val = 0x%04X\n", + __FUNCTION__, offset, val); + bus_space_write_2(sc->bce_btag, sc->bce_bhandle, offset, val); +} + + +/****************************************************************************/ +/* Register write. */ +/* */ +/* Returns: */ +/* Nothing. */ +/****************************************************************************/ +static void +bce_reg_wr(struct bce_softc *sc, u32 offset, u32 val) +{ + DBPRINT(sc, BCE_INSANE_REG, "%s(); offset = 0x%08X, val = 0x%08X\n", + __FUNCTION__, offset, val); + bus_space_write_4(sc->bce_btag, sc->bce_bhandle, offset, val); +} +#endif + /****************************************************************************/ /* Indirect register read. */ /* */ @@ -961,7 +1235,7 @@ bce_reg_rd_ind(struct bce_softc *sc, u32 { u32 val; val = pci_read_config(dev, BCE_PCICFG_REG_WINDOW, 4); - DBPRINT(sc, BCE_EXCESSIVE, "%s(); offset = 0x%08X, val = 0x%08X\n", + DBPRINT(sc, BCE_INSANE_REG, "%s(); offset = 0x%08X, val = 0x%08X\n", __FUNCTION__, offset, val); return val; } @@ -987,7 +1261,7 @@ bce_reg_wr_ind(struct bce_softc *sc, u32 device_t dev; dev = sc->bce_dev; - DBPRINT(sc, BCE_EXCESSIVE, "%s(); offset = 0x%08X, val = 0x%08X\n", + DBPRINT(sc, BCE_INSANE_REG, "%s(); offset = 0x%08X, val = 0x%08X\n", __FUNCTION__, offset, val); pci_write_config(dev, BCE_PCICFG_REG_WINDOW_ADDRESS, offset, 4); @@ -995,6 +1269,58 @@ bce_reg_wr_ind(struct bce_softc *sc, u32 } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From rwatson at FreeBSD.org Tue Nov 11 09:12:27 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Tue Nov 11 09:12:43 2008 Subject: svn commit: r184853 - in stable/7/sys: . modules/cxgb netinet Message-ID: <200811111712.mABHCQZK007373@svn.freebsd.org> Author: rwatson Date: Tue Nov 11 17:12:26 2008 New Revision: 184853 URL: http://svn.freebsd.org/changeset/base/184853 Log: Merge r184304 from head to stable/7: In both dropwithreset paths in tcp_input.c, drop the tcbinfo lock sooner to decomplicate locking and eliminate the need for a rather chatty comment about why we have to handle the global lock in a special way for the benefit of ipfw and pf cred rules. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/modules/cxgb/ (props changed) stable/7/sys/netinet/tcp_input.c Modified: stable/7/sys/netinet/tcp_input.c ============================================================================== --- stable/7/sys/netinet/tcp_input.c Tue Nov 11 17:10:24 2008 (r184852) +++ stable/7/sys/netinet/tcp_input.c Tue Nov 11 17:12:26 2008 (r184853) @@ -849,19 +849,12 @@ findpcb: dropwithreset: INP_INFO_WLOCK_ASSERT(&tcbinfo); + INP_INFO_WUNLOCK(&tcbinfo); - /* - * If inp is non-NULL, we call tcp_dropwithreset() holding both inpcb - * and global locks. However, if NULL, we must hold neither as - * firewalls may acquire the global lock in order to look for a - * matching inpcb. - */ if (inp != NULL) { tcp_dropwithreset(m, th, tp, tlen, rstreason); INP_WUNLOCK(inp); - } - INP_INFO_WUNLOCK(&tcbinfo); - if (inp == NULL) + } else tcp_dropwithreset(m, th, NULL, tlen, rstreason); m = NULL; /* mbuf chain got consumed. */ goto drop; @@ -2414,19 +2407,12 @@ dropafterack: dropwithreset: KASSERT(headlocked, ("%s: dropwithreset: head not locked", __func__)); + INP_INFO_WUNLOCK(&tcbinfo); - /* - * If tp is non-NULL, we call tcp_dropwithreset() holding both inpcb - * and global locks. However, if NULL, we must hold neither as - * firewalls may acquire the global lock in order to look for a - * matching inpcb. - */ if (tp != NULL) { tcp_dropwithreset(m, th, tp, tlen, rstreason); INP_WUNLOCK(tp->t_inpcb); - } - INP_INFO_WUNLOCK(&tcbinfo); - if (tp == NULL) + } else tcp_dropwithreset(m, th, NULL, tlen, rstreason); return; From delphij at FreeBSD.org Tue Nov 11 23:07:28 2008 From: delphij at FreeBSD.org (Xin LI) Date: Tue Nov 11 23:07:40 2008 Subject: svn commit: r184862 - in stable/7/sys: . dev/et Message-ID: <200811120707.mAC77RUI022682@svn.freebsd.org> Author: delphij Date: Wed Nov 12 07:07:27 2008 New Revision: 184862 URL: http://svn.freebsd.org/changeset/base/184862 Log: MFC revision 1801453: Don't leak DMA map if not freed. Submitted by: kevlo Approved by: re (kensmith) Modified: stable/7/sys/ (props changed) stable/7/sys/dev/et/if_et.c Modified: stable/7/sys/dev/et/if_et.c ============================================================================== --- stable/7/sys/dev/et/if_et.c Wed Nov 12 04:45:09 2008 (r184861) +++ stable/7/sys/dev/et/if_et.c Wed Nov 12 07:07:27 2008 (r184862) @@ -1326,6 +1326,8 @@ et_free_rx_ring(struct et_softc *sc) struct et_rxbuf *rb = &rbd->rbd_buf[i]; if (rb->rb_mbuf != NULL) { + bus_dmamap_unload(sc->sc_mbuf_dtag, + rb->rb_dmap); m_freem(rb->rb_mbuf); rb->rb_mbuf = NULL; } From joerg at FreeBSD.org Wed Nov 12 01:35:58 2008 From: joerg at FreeBSD.org (Joerg Wunsch) Date: Wed Nov 12 01:36:06 2008 Subject: svn commit: r184867 - stable/7/bin/chio Message-ID: <200811120935.mAC9Zvoc025503@svn.freebsd.org> Author: joerg Date: Wed Nov 12 09:35:57 2008 New Revision: 184867 URL: http://svn.freebsd.org/changeset/base/184867 Log: (MFC r184484) When running a "chio return" operation using a physical source unit rather than a voltag name, do not set the CESR_VOLTAGS flags in the CHIOGSTATUS command requesting the current status. As voltags are an optional feature that must be handled as "reserved" by media changers not implementing the feature, always setting CESR_VOLTAGS resulted in the command being aborted with an `Invalid field in CDB', and consequently the "chio return" failed, for media changers that do not support voltags. Approved by: re (kib) Modified: stable/7/bin/chio/ (props changed) stable/7/bin/chio/chio.c Modified: stable/7/bin/chio/chio.c ============================================================================== --- stable/7/bin/chio/chio.c Wed Nov 12 09:04:44 2008 (r184866) +++ stable/7/bin/chio/chio.c Wed Nov 12 09:35:57 2008 (r184867) @@ -69,7 +69,7 @@ static const char *bits_to_string(ces_st static void find_element(char *, uint16_t *, uint16_t *); static struct changer_element_status *get_element_status - (unsigned int, unsigned int); + (unsigned int, unsigned int, int); static int do_move(const char *, int, char **); static int do_exchange(const char *, int, char **); @@ -969,7 +969,8 @@ do_return(const char *cname, int argc, c ++argv; --argc; /* Get the status */ - ces = get_element_status((unsigned int)type, (unsigned int)element); + ces = get_element_status((unsigned int)type, (unsigned int)element, + CHET_VT == type); if (NULL == ces) errx(1, "%s: null element status pointer", cname); @@ -1004,7 +1005,7 @@ usage: * should free() it when done. */ static struct changer_element_status * -get_element_status(unsigned int type, unsigned int element) +get_element_status(unsigned int type, unsigned int element, int use_voltags) { struct changer_element_status_request cesr; struct changer_element_status *ces; @@ -1020,7 +1021,8 @@ get_element_status(unsigned int type, un cesr.cesr_element_type = (uint16_t)type; cesr.cesr_element_base = (uint16_t)element; cesr.cesr_element_count = 1; /* Only this one element */ - cesr.cesr_flags |= CESR_VOLTAGS; /* Grab voltags as well */ + if (use_voltags) + cesr.cesr_flags |= CESR_VOLTAGS; /* Grab voltags as well */ cesr.cesr_element_status = ces; if (ioctl(changer_fd, CHIOGSTATUS, (char *)&cesr) == -1) { From peter at FreeBSD.org Wed Nov 12 18:35:30 2008 From: peter at FreeBSD.org (Peter Wemm) Date: Wed Nov 12 18:35:36 2008 Subject: svn commit: r184907 - in stable/7/sys: . compat/freebsd32 modules/cxgb Message-ID: <200811130235.mAD2ZTUi046903@svn.freebsd.org> Author: peter Date: Thu Nov 13 02:35:29 2008 New Revision: 184907 URL: http://svn.freebsd.org/changeset/base/184907 Log: MFC 184828,184829: Fix si_addr in 32 bit signals. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/compat/freebsd32/freebsd32_misc.c stable/7/sys/modules/cxgb/ (props changed) Modified: stable/7/sys/compat/freebsd32/freebsd32_misc.c ============================================================================== --- stable/7/sys/compat/freebsd32/freebsd32_misc.c Thu Nov 13 02:22:29 2008 (r184906) +++ stable/7/sys/compat/freebsd32/freebsd32_misc.c Thu Nov 13 02:35:29 2008 (r184907) @@ -2389,7 +2389,7 @@ siginfo_to_siginfo32(siginfo_t *src, str dst->si_pid = src->si_pid; dst->si_uid = src->si_uid; dst->si_status = src->si_status; - dst->si_addr = dst->si_addr; + dst->si_addr = (uintptr_t)src->si_addr; dst->si_value.sigval_int = src->si_value.sival_int; dst->si_timerid = src->si_timerid; dst->si_overrun = src->si_overrun; From yongari at FreeBSD.org Thu Nov 13 03:00:15 2008 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Thu Nov 13 03:00:34 2008 Subject: svn commit: r184918 - in stable/7/sys: . dev/mii modules/cxgb Message-ID: <200811131100.mADB0FHg057297@svn.freebsd.org> Author: yongari Date: Thu Nov 13 11:00:15 2008 New Revision: 184918 URL: http://svn.freebsd.org/changeset/base/184918 Log: MFC r184253: Use auto-negotiation for manual media type selection. This fixes establishment of 10/100Mbps link on Atheros AR8121(L1E). Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/dev/mii/atphy.c stable/7/sys/modules/cxgb/ (props changed) Modified: stable/7/sys/dev/mii/atphy.c ============================================================================== --- stable/7/sys/dev/mii/atphy.c Thu Nov 13 10:40:13 2008 (r184917) +++ stable/7/sys/dev/mii/atphy.c Thu Nov 13 11:00:15 2008 (r184918) @@ -217,7 +217,8 @@ atphy_service(struct mii_softc *sc, stru /* * Reset the PHY so all changes take effect. */ - PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_RESET); + PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_RESET | BMCR_AUTOEN | + BMCR_STARTNEG); done: break; From kib at FreeBSD.org Thu Nov 13 07:00:41 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Thu Nov 13 07:00:58 2008 Subject: svn commit: r184924 - in stable/7/sys: . compat/linux modules/cxgb Message-ID: <200811131500.mADF0esO061783@svn.freebsd.org> Author: kib Date: Thu Nov 13 15:00:40 2008 New Revision: 184924 URL: http://svn.freebsd.org/changeset/base/184924 Log: MFC r184501: The code in linux_proc_exit() contains a race when multiple linux based processes exits at the same time. The linux_emuldata structure is freed but p->p_emuldata is left as a dangling pointer to the just freed memory. The check for W_EXIT in the loop scanning the child processes isn't safe since the state of the child process can change right afterwards. Lock the process and check the W_EXIT before delivering signal. Approved by: re (kensmith) Modified: stable/7/sys/ (props changed) stable/7/sys/compat/linux/linux_emul.c stable/7/sys/modules/cxgb/ (props changed) Modified: stable/7/sys/compat/linux/linux_emul.c ============================================================================== --- stable/7/sys/compat/linux/linux_emul.c Thu Nov 13 15:00:34 2008 (r184923) +++ stable/7/sys/compat/linux/linux_emul.c Thu Nov 13 15:00:40 2008 (r184924) @@ -232,11 +232,11 @@ linux_proc_exit(void *arg __unused, stru continue; em = em_find(q, EMUL_DOLOCK); KASSERT(em != NULL, ("linux_reparent: emuldata not found: %i\n", q->p_pid)); - if (em->pdeath_signal != 0) { - PROC_LOCK(q); + PROC_LOCK(q); + if ((q->p_flag & P_WEXIT) == 0 && em->pdeath_signal != 0) { psignal(q, em->pdeath_signal); - PROC_UNLOCK(q); } + PROC_UNLOCK(q); EMUL_UNLOCK(&emul_lock); } sx_xunlock(&proctree_lock); From rpaulo at FreeBSD.org Thu Nov 13 07:27:48 2008 From: rpaulo at FreeBSD.org (Rui Paulo) Date: Thu Nov 13 07:28:07 2008 Subject: svn commit: r184928 - in stable/7: contrib/traceroute usr.sbin/traceroute Message-ID: <200811131527.mADFRmMs062402@svn.freebsd.org> Author: rpaulo Date: Thu Nov 13 15:27:48 2008 New Revision: 184928 URL: http://svn.freebsd.org/changeset/base/184928 Log: MFC r176428: Add AS lookup functionality. On each hop we query a whois server to find the corresponding AS for that IP (-a switch). We can also choose a different whois server with the -A switch. The default is whois.radb.net. Obtained from: NetBSD Approved by: re Added: stable/7/contrib/traceroute/as.c (contents, props changed) stable/7/contrib/traceroute/as.h (contents, props changed) Modified: stable/7/contrib/traceroute/traceroute.8 stable/7/contrib/traceroute/traceroute.c stable/7/usr.sbin/traceroute/Makefile Added: stable/7/contrib/traceroute/as.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/contrib/traceroute/as.c Thu Nov 13 15:27:48 2008 (r184928) @@ -0,0 +1,242 @@ +/* $FreeBSD$ */ +/* $NetBSD: as.c,v 1.1 2001/11/04 23:14:36 atatat Exp $ */ + +/* + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Brown. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "as.h" + +#define DEFAULT_AS_SERVER "whois.radb.net" +#undef AS_DEBUG_FILE + +struct aslookup { + FILE *as_f; +#ifdef AS_DEBUG_FILE + FILE *as_debug; +#endif /* AS_DEBUG_FILE */ +}; + +void * +as_setup(server) + char *server; +{ + struct aslookup *asn; + struct hostent *he = NULL; + struct servent *se; + struct sockaddr_in in; + FILE *f; + int s; + + if (server == NULL) + server = DEFAULT_AS_SERVER; + + (void)memset(&in, 0, sizeof(in)); + in.sin_family = AF_INET; + in.sin_len = sizeof(in); + if ((se = getservbyname("whois", "tcp")) == NULL) { + warnx("warning: whois/tcp service not found"); + in.sin_port = ntohs(43); + } else + in.sin_port = se->s_port; + + if (inet_aton(server, &in.sin_addr) == 0 && + ((he = gethostbyname(server)) == NULL || + he->h_addr == NULL)) { + warnx("%s: %s", server, hstrerror(h_errno)); + return (NULL); + } + + if ((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) { + warn("socket"); + return (NULL); + } + + do { + if (he != NULL) { + memcpy(&in.sin_addr, he->h_addr, he->h_length); + he->h_addr_list++; + } + if (connect(s, (struct sockaddr *)&in, sizeof(in)) == 0) + break; + if (he == NULL || he->h_addr == NULL) { + close(s); + s = -1; + break; + } + } while (1); + + if (s == -1) { + warn("connect"); + return (NULL); + } + + f = fdopen(s, "r+"); + (void)fprintf(f, "!!\n"); + (void)fflush(f); + + asn = malloc(sizeof(struct aslookup)); + if (asn == NULL) + (void)fclose(f); + else + asn->as_f = f; + +#ifdef AS_DEBUG_FILE + asn->as_debug = fopen(AS_DEBUG_FILE, "w"); + if (asn->as_debug) { + (void)fprintf(asn->as_debug, ">> !!\n"); + (void)fflush(asn->as_debug); + } +#endif /* AS_DEBUG_FILE */ + + return (asn); +} + +int +as_lookup(_asn, addr) + void *_asn; + struct in_addr *addr; +{ + struct aslookup *asn = _asn; + char buf[1024]; + int as, rc, dlen; + + as = rc = dlen = 0; + (void)fprintf(asn->as_f, "!r%s/32,l\n", inet_ntoa(*addr)); + (void)fflush(asn->as_f); + +#ifdef AS_DEBUG_FILE + if (asn->as_debug) { + (void)fprintf(asn->as_debug, ">> !r%s/32,l\n", + inet_ntoa(*addr)); + (void)fflush(asn->as_debug); + } +#endif /* AS_DEBUG_FILE */ + + while (fgets(buf, sizeof(buf), asn->as_f) != NULL) { + buf[sizeof(buf) - 1] = '\0'; + +#ifdef AS_DEBUG_FILE + if (asn->as_debug) { + (void)fprintf(asn->as_debug, "<< %s", buf); + (void)fflush(asn->as_debug); + } +#endif /* AS_DEBUG_FILE */ + + if (rc == 0) { + rc = buf[0]; + switch (rc) { + case 'A': + /* A - followed by # bytes of answer */ + sscanf(buf, "A%d\n", &dlen); +#ifdef AS_DEBUG_FILE + if (asn->as_debug) { + (void)fprintf(asn->as_debug, + "dlen: %d\n", dlen); + (void)fflush(asn->as_debug); + } +#endif /* AS_DEBUG_FILE */ + break; + case 'C': + case 'D': + case 'E': + case 'F': + /* C - no data returned */ + /* D - key not found */ + /* E - multiple copies of key */ + /* F - some other error */ + break; + } + if (rc == 'A') + /* skip to next input line */ + continue; + } + + if (dlen == 0) + /* out of data, next char read is end code */ + rc = buf[0]; + if (rc != 'A') + /* either an error off the bat, or a done code */ + break; + + /* data received, thank you */ + dlen -= strlen(buf); + + /* origin line is the interesting bit */ + if (as == 0 && strncasecmp(buf, "origin:", 7) == 0) { + sscanf(buf + 7, " AS%d", &as); +#ifdef AS_DEBUG_FILE + if (asn->as_debug) { + (void)fprintf(asn->as_debug, "as: %d\n", as); + (void)fflush(asn->as_debug); + } +#endif /* AS_DEBUG_FILE */ + } + } + + return (as); +} + +void +as_shutdown(_asn) + void *_asn; +{ + struct aslookup *asn = _asn; + + (void)fprintf(asn->as_f, "!q\n"); + (void)fclose(asn->as_f); + +#ifdef AS_DEBUG_FILE + if (asn->as_debug) { + (void)fprintf(asn->as_debug, ">> !q\n"); + (void)fclose(asn->as_debug); + } +#endif /* AS_DEBUG_FILE */ + + free(asn); +} Added: stable/7/contrib/traceroute/as.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/contrib/traceroute/as.h Thu Nov 13 15:27:48 2008 (r184928) @@ -0,0 +1,42 @@ +/* $FreeBSD$ */ +/* $NetBSD: as.h,v 1.1 2001/11/04 23:14:36 atatat Exp $ */ + +/* + * Copyright (c) 2001 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Brown. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +void *as_setup __P((char *)); +int as_lookup __P((void *, struct in_addr *)); +void as_shutdown __P((void *)); Modified: stable/7/contrib/traceroute/traceroute.8 ============================================================================== --- stable/7/contrib/traceroute/traceroute.8 Thu Nov 13 15:15:19 2008 (r184927) +++ stable/7/contrib/traceroute/traceroute.8 Thu Nov 13 15:27:48 2008 (r184928) @@ -16,7 +16,7 @@ .\" $Id: traceroute.8,v 1.19 2000/09/21 08:44:19 leres Exp $ .\" $FreeBSD$ .\" -.TH TRACEROUTE 8 "21 September 2000" +.TH TRACEROUTE 8 "19 February 2008" .UC 6 .SH NAME traceroute \- print the route packets take to network host @@ -24,7 +24,7 @@ traceroute \- print the route packets ta .na .B traceroute [ -.B \-dDeFISnrvx +.B \-adDeFISnrvx ] [ .B \-f .I first_ttl @@ -71,6 +71,9 @@ traceroute \- print the route packets ta .B \-w .I waittime ] [ +.B \-A +.I as_server +] [ .B \-z .I pausemsecs ] @@ -98,6 +101,13 @@ name. .PP Other options are: .TP +.B \-a +Turn on AS# lookups for each hop encountered. +.TP +.B -A +Turn on AS# lookups and use the given server instead of the +default. +.TP .B \-e Firewall evasion mode. Use fixed destination ports for UDP and TCP probes. @@ -443,3 +453,7 @@ should listen for a RST from the destina router that's filtering packets), but this is not implemented yet. .PP Please send bug reports to traceroute@ee.lbl.gov. +.PP +The AS number capability reports information that may sometimes be +inaccurate due to discrepancies between the contents of the +routing database server and the current state of the Internet. Modified: stable/7/contrib/traceroute/traceroute.c ============================================================================== --- stable/7/contrib/traceroute/traceroute.c Thu Nov 13 15:15:19 2008 (r184927) +++ stable/7/contrib/traceroute/traceroute.c Thu Nov 13 15:27:48 2008 (r184928) @@ -263,6 +263,7 @@ static const char rcsid[] = #include "findsaddr.h" #include "ifaddrlist.h" +#include "as.h" #include "traceroute.h" /* Maximum number of gateways (include room for one noop) */ @@ -350,6 +351,9 @@ int options; /* socket options */ int verbose; int waittime = 5; /* time to wait for response (in seconds) */ int nflag; /* print addresses numerically */ +int as_path; /* print as numbers for each hop */ +char *as_server = NULL; +void *asn; #ifdef CANT_HACK_IPCKSUM int doipcksum = 0; /* don't calculate ip checksums by default */ #else @@ -535,9 +539,17 @@ main(int argc, char **argv) prog = argv[0]; opterr = 0; - while ((op = getopt(argc, argv, "edDFInrSvxf:g:i:M:m:P:p:q:s:t:w:z:")) != EOF) + while ((op = getopt(argc, argv, "aA:edDFInrSvxf:g:i:M:m:P:p:q:s:t:w:z:")) != EOF) switch (op) { - + case 'a': + as_path = 1; + break; + + case 'A': + as_path = 1; + as_server = optarg; + break; + case 'd': options |= SO_DEBUG; break; @@ -913,6 +925,16 @@ main(int argc, char **argv) exit (1); } + if (as_path) { + asn = as_setup(as_server); + if (asn == NULL) { + Fprintf(stderr, "%s: as_setup failed, AS# lookups" + " disabled\n", prog); + (void)fflush(stderr); + as_path = 0; + } + } + #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) if (setpolicy(sndsock, "in bypass") < 0) errx(1, "%s", ipsec_strerror()); @@ -1118,6 +1140,8 @@ main(int argc, char **argv) (unreachable > 0 && unreachable >= nprobes - 1)) break; } + if (as_path) + as_shutdown(asn); exit(0); } @@ -1458,6 +1482,9 @@ print(register u_char *buf, register int hlen = ip->ip_hl << 2; cc -= hlen; + if (as_path) + Printf(" [AS%d]", as_lookup(asn, &from->sin_addr)); + if (nflag) Printf(" %s", inet_ntoa(from->sin_addr)); else @@ -1764,8 +1791,8 @@ usage(void) Fprintf(stderr, "Version %s\n", version); Fprintf(stderr, - "Usage: %s [-dDeFInrSvx] [-f first_ttl] [-g gateway] [-i iface]\n" + "Usage: %s [-adDeFInrSvx] [-f first_ttl] [-g gateway] [-i iface]\n" "\t[-m max_ttl] [-p port] [-P proto] [-q nqueries] [-s src_addr]\n" - "\t[-t tos] [-w waittime] [-z pausemsecs] host [packetlen]\n", prog); + "\t[-t tos] [-w waittime] [-A as_server] [-z pausemsecs] host [packetlen]\n", prog); exit(1); } Modified: stable/7/usr.sbin/traceroute/Makefile ============================================================================== --- stable/7/usr.sbin/traceroute/Makefile Thu Nov 13 15:15:19 2008 (r184927) +++ stable/7/usr.sbin/traceroute/Makefile Thu Nov 13 15:27:48 2008 (r184928) @@ -5,7 +5,7 @@ TRACEROUTE_DISTDIR?= ${.CURDIR}/../../co PROG= traceroute MAN= traceroute.8 -SRCS= version.c traceroute.c ifaddrlist.c findsaddr-socket.c +SRCS= as.c version.c traceroute.c ifaddrlist.c findsaddr-socket.c BINOWN= root BINMODE=4555 CLEANFILES= version.c From rpaulo at FreeBSD.org Thu Nov 13 08:02:12 2008 From: rpaulo at FreeBSD.org (Rui Paulo) Date: Thu Nov 13 08:02:23 2008 Subject: svn commit: r184929 - stable/7/contrib Message-ID: <200811131602.mADG2CuA063104@svn.freebsd.org> Author: rpaulo Date: Thu Nov 13 16:02:12 2008 New Revision: 184929 URL: http://svn.freebsd.org/changeset/base/184929 Log: Record MFC r176428. Approved by: re (implicit) Modified: stable/7/contrib/ (props changed) From rpaulo at FreeBSD.org Thu Nov 13 08:03:44 2008 From: rpaulo at FreeBSD.org (Rui Paulo) Date: Thu Nov 13 08:03:54 2008 Subject: svn commit: r184930 - stable/7/usr.sbin Message-ID: <200811131603.mADG3h8e063173@svn.freebsd.org> Author: rpaulo Date: Thu Nov 13 16:03:43 2008 New Revision: 184930 URL: http://svn.freebsd.org/changeset/base/184930 Log: Record MFC r176428. Approved by: re (implicit) Modified: stable/7/usr.sbin/ (props changed) From rpaulo at FreeBSD.org Thu Nov 13 08:17:51 2008 From: rpaulo at FreeBSD.org (Rui Paulo) Date: Thu Nov 13 08:18:07 2008 Subject: svn commit: r184931 - in stable/7/usr.sbin: . traceroute Message-ID: <200811131617.mADGHpi1063544@svn.freebsd.org> Author: rpaulo Date: Thu Nov 13 16:17:50 2008 New Revision: 184931 URL: http://svn.freebsd.org/changeset/base/184931 Log: Reverse botched mergeinfo for r176428. Approved by: re (implicit) Modified: stable/7/usr.sbin/ (props changed) stable/7/usr.sbin/traceroute/ (props changed) From peter at FreeBSD.org Thu Nov 13 12:46:10 2008 From: peter at FreeBSD.org (Peter Wemm) Date: Thu Nov 13 12:46:17 2008 Subject: svn commit: r184939 - in stable/7/lib/libc: . amd64 amd64/gen amd64/stdlib amd64/string amd64/sys i386 i386/gen i386/stdlib i386/string i386/sys Message-ID: <200811132046.mADKk7nd068519@svn.freebsd.org> Author: peter Date: Thu Nov 13 20:46:07 2008 New Revision: 184939 URL: http://svn.freebsd.org/changeset/base/184939 Log: MFC: 184547,184548: add END() macros for Assembler code in libc. This causes the symbol table to include the size of the function. Approved by: re (kib) Modified: stable/7/lib/libc/ (props changed) stable/7/lib/libc/amd64/SYS.h stable/7/lib/libc/amd64/gen/_setjmp.S stable/7/lib/libc/amd64/gen/fabs.S stable/7/lib/libc/amd64/gen/modf.S stable/7/lib/libc/amd64/gen/rfork_thread.S stable/7/lib/libc/amd64/gen/setjmp.S stable/7/lib/libc/amd64/gen/sigsetjmp.S stable/7/lib/libc/amd64/stdlib/div.S stable/7/lib/libc/amd64/stdlib/ldiv.S stable/7/lib/libc/amd64/stdlib/lldiv.S stable/7/lib/libc/amd64/string/bcmp.S stable/7/lib/libc/amd64/string/bcopy.S stable/7/lib/libc/amd64/string/bzero.S stable/7/lib/libc/amd64/string/memcmp.S stable/7/lib/libc/amd64/string/memset.S stable/7/lib/libc/amd64/string/strcat.S stable/7/lib/libc/amd64/string/strcmp.S stable/7/lib/libc/amd64/string/strcpy.S stable/7/lib/libc/amd64/sys/brk.S stable/7/lib/libc/amd64/sys/exect.S stable/7/lib/libc/amd64/sys/getcontext.S stable/7/lib/libc/amd64/sys/pipe.S stable/7/lib/libc/amd64/sys/ptrace.S stable/7/lib/libc/amd64/sys/reboot.S stable/7/lib/libc/amd64/sys/sbrk.S stable/7/lib/libc/amd64/sys/setlogin.S stable/7/lib/libc/amd64/sys/vfork.S stable/7/lib/libc/i386/SYS.h stable/7/lib/libc/i386/gen/_ctx_start.S stable/7/lib/libc/i386/gen/_setjmp.S stable/7/lib/libc/i386/gen/fabs.S stable/7/lib/libc/i386/gen/modf.S stable/7/lib/libc/i386/gen/rfork_thread.S stable/7/lib/libc/i386/gen/setjmp.S stable/7/lib/libc/i386/gen/sigsetjmp.S stable/7/lib/libc/i386/stdlib/abs.S stable/7/lib/libc/i386/stdlib/div.S stable/7/lib/libc/i386/stdlib/labs.S stable/7/lib/libc/i386/stdlib/ldiv.S stable/7/lib/libc/i386/string/bcmp.S stable/7/lib/libc/i386/string/bcopy.S stable/7/lib/libc/i386/string/bzero.S stable/7/lib/libc/i386/string/ffs.S stable/7/lib/libc/i386/string/index.S stable/7/lib/libc/i386/string/memchr.S stable/7/lib/libc/i386/string/memcmp.S stable/7/lib/libc/i386/string/memset.S stable/7/lib/libc/i386/string/rindex.S stable/7/lib/libc/i386/string/strcat.S stable/7/lib/libc/i386/string/strchr.S stable/7/lib/libc/i386/string/strcmp.S stable/7/lib/libc/i386/string/strcpy.S stable/7/lib/libc/i386/string/strlen.S stable/7/lib/libc/i386/string/strncmp.S stable/7/lib/libc/i386/string/strrchr.S stable/7/lib/libc/i386/string/swab.S stable/7/lib/libc/i386/string/wcschr.S stable/7/lib/libc/i386/string/wcscmp.S stable/7/lib/libc/i386/string/wcslen.S stable/7/lib/libc/i386/string/wmemchr.S stable/7/lib/libc/i386/sys/Ovfork.S stable/7/lib/libc/i386/sys/brk.S stable/7/lib/libc/i386/sys/exect.S stable/7/lib/libc/i386/sys/getcontext.S stable/7/lib/libc/i386/sys/pipe.S stable/7/lib/libc/i386/sys/ptrace.S stable/7/lib/libc/i386/sys/reboot.S stable/7/lib/libc/i386/sys/sbrk.S stable/7/lib/libc/i386/sys/setlogin.S stable/7/lib/libc/i386/sys/syscall.S Modified: stable/7/lib/libc/amd64/SYS.h ============================================================================== --- stable/7/lib/libc/amd64/SYS.h Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/SYS.h Thu Nov 13 20:46:07 2008 (r184939) @@ -43,13 +43,15 @@ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret; \ - 2: movq PIC_GOT(HIDENAME(cerror)),%rcx; jmp *%rcx + 2: movq PIC_GOT(HIDENAME(cerror)),%rcx; jmp *%rcx; \ + END(__CONCAT(__sys_,x)) #define PSEUDO(x) ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret ; \ - 2: movq PIC_GOT(HIDENAME(cerror)),%rcx; jmp *%rcx + 2: movq PIC_GOT(HIDENAME(cerror)),%rcx; jmp *%rcx; \ + END(__CONCAT(__sys_,x)) #else #define RSYSCALL(x) ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(x); \ @@ -57,13 +59,15 @@ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret; \ - 2: jmp HIDENAME(cerror) + 2: jmp HIDENAME(cerror); \ + END(__CONCAT(__sys_,x)) #define PSEUDO(x) ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ mov __CONCAT($SYS_,x),%rax; KERNCALL; jb 2f; ret; \ - 2: jmp HIDENAME(cerror) + 2: jmp HIDENAME(cerror); \ + END(__CONCAT(__sys_,x)) #endif #define KERNCALL movq %rcx, %r10; syscall Modified: stable/7/lib/libc/amd64/gen/_setjmp.S ============================================================================== --- stable/7/lib/libc/amd64/gen/_setjmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/gen/_setjmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -60,6 +60,7 @@ ENTRY(_setjmp) fnstcw 64(%rax) /* 8; fpu cw */ xorq %rax,%rax ret +END(_setjmp) .weak CNAME(_longjmp) .set CNAME(_longjmp),CNAME(___longjmp) @@ -81,3 +82,4 @@ ENTRY(___longjmp) incq %rax 1: movq %rcx,0(%rsp) ret +END(___longjmp) Modified: stable/7/lib/libc/amd64/gen/fabs.S ============================================================================== --- stable/7/lib/libc/amd64/gen/fabs.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/gen/fabs.S Thu Nov 13 20:46:07 2008 (r184939) @@ -37,6 +37,7 @@ ENTRY(fabs) movsd signbit(%rip), %xmm0 andnpd %xmm1, %xmm0 ret +END(fabs) .data signbit: Modified: stable/7/lib/libc/amd64/gen/modf.S ============================================================================== --- stable/7/lib/libc/amd64/gen/modf.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/gen/modf.S Thu Nov 13 20:46:07 2008 (r184939) @@ -86,3 +86,4 @@ ENTRY(modf) movsd -8(%rsp),%xmm0 ret +END(modf) Modified: stable/7/lib/libc/amd64/gen/rfork_thread.S ============================================================================== --- stable/7/lib/libc/amd64/gen/rfork_thread.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/gen/rfork_thread.S Thu Nov 13 20:46:07 2008 (r184939) @@ -99,3 +99,4 @@ ENTRY(rfork_thread) #else jmp HIDENAME(cerror) #endif +END(rfork_thread) Modified: stable/7/lib/libc/amd64/gen/setjmp.S ============================================================================== --- stable/7/lib/libc/amd64/gen/setjmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/gen/setjmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -69,6 +69,7 @@ ENTRY(setjmp) fnstcw 64(%rcx) /* 8; fpu cw */ xorq %rax,%rax ret +END(setjmp) .weak CNAME(longjmp) .set CNAME(longjmp),CNAME(__longjmp) @@ -99,3 +100,4 @@ ENTRY(__longjmp) incq %rax 1: movq %rcx,0(%rsp) ret +END(__longjmp) Modified: stable/7/lib/libc/amd64/gen/sigsetjmp.S ============================================================================== --- stable/7/lib/libc/amd64/gen/sigsetjmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/gen/sigsetjmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -77,6 +77,7 @@ ENTRY(sigsetjmp) fnstcw 64(%rcx) /* 8; fpu cw */ xorq %rax,%rax ret +END(sigsetjmp) .weak CNAME(siglongjmp) .set CNAME(siglongjmp),CNAME(__siglongjmp) @@ -109,3 +110,4 @@ ENTRY(__siglongjmp) incq %rax 1: movq %rcx,0(%rsp) ret +END(__siglongjmp) Modified: stable/7/lib/libc/amd64/stdlib/div.S ============================================================================== --- stable/7/lib/libc/amd64/stdlib/div.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/stdlib/div.S Thu Nov 13 20:46:07 2008 (r184939) @@ -15,3 +15,4 @@ ENTRY(div) salq $32,%rdx orq %rdx,%rax ret +END(div) Modified: stable/7/lib/libc/amd64/stdlib/ldiv.S ============================================================================== --- stable/7/lib/libc/amd64/stdlib/ldiv.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/stdlib/ldiv.S Thu Nov 13 20:46:07 2008 (r184939) @@ -13,3 +13,4 @@ ENTRY(ldiv) cqto idivq %rsi ret +END(ldiv) Modified: stable/7/lib/libc/amd64/stdlib/lldiv.S ============================================================================== --- stable/7/lib/libc/amd64/stdlib/lldiv.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/stdlib/lldiv.S Thu Nov 13 20:46:07 2008 (r184939) @@ -13,3 +13,4 @@ ENTRY(lldiv) cqto idivq %rsi ret +END(lldiv) Modified: stable/7/lib/libc/amd64/string/bcmp.S ============================================================================== --- stable/7/lib/libc/amd64/string/bcmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/string/bcmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -22,3 +22,4 @@ L1: setne %al movsbl %al,%eax ret +END(bcmp) Modified: stable/7/lib/libc/amd64/string/bcopy.S ============================================================================== --- stable/7/lib/libc/amd64/string/bcopy.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/string/bcopy.S Thu Nov 13 20:46:07 2008 (r184939) @@ -86,3 +86,12 @@ ENTRY(bcopy) movsq cld ret +#ifdef MEMCOPY +END(memcpy) +#else +#ifdef MEMMOVE +END(memmove) +#else +END(bcopy) +#endif +#endif Modified: stable/7/lib/libc/amd64/string/bzero.S ============================================================================== --- stable/7/lib/libc/amd64/string/bzero.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/string/bzero.S Thu Nov 13 20:46:07 2008 (r184939) @@ -41,3 +41,4 @@ L1: movq %rsi,%rcx /* zero remainder by stosb ret +END(bzero) Modified: stable/7/lib/libc/amd64/string/memcmp.S ============================================================================== --- stable/7/lib/libc/amd64/string/memcmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/string/memcmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -39,3 +39,4 @@ L6: xorl %eax,%eax /* Perform unsigned movb -1(%rsi),%dl subl %edx,%eax ret +END(memcmp) Modified: stable/7/lib/libc/amd64/string/memset.S ============================================================================== --- stable/7/lib/libc/amd64/string/memset.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/string/memset.S Thu Nov 13 20:46:07 2008 (r184939) @@ -58,3 +58,4 @@ L1: rep movq %r11,%rax ret +END(memset) Modified: stable/7/lib/libc/amd64/string/strcat.S ============================================================================== --- stable/7/lib/libc/amd64/string/strcat.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/string/strcat.S Thu Nov 13 20:46:07 2008 (r184939) @@ -163,3 +163,4 @@ ENTRY(strcat) .Ldone: ret +END(strcat) Modified: stable/7/lib/libc/amd64/string/strcmp.S ============================================================================== --- stable/7/lib/libc/amd64/string/strcmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/string/strcmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -71,3 +71,4 @@ ENTRY(strcmp) movzbq %dl,%rdx subq %rdx,%rax ret +END(strcmp) Modified: stable/7/lib/libc/amd64/string/strcpy.S ============================================================================== --- stable/7/lib/libc/amd64/string/strcpy.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/string/strcpy.S Thu Nov 13 20:46:07 2008 (r184939) @@ -109,3 +109,4 @@ ENTRY(strcpy) .Ldone: ret +END(strcpy) Modified: stable/7/lib/libc/amd64/sys/brk.S ============================================================================== --- stable/7/lib/libc/amd64/sys/brk.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/sys/brk.S Thu Nov 13 20:46:07 2008 (r184939) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); ENTRY(_brk) pushq %rdi jmp ok +END(_brk) ENTRY(brk) pushq %rdi @@ -81,3 +82,4 @@ err: #else jmp HIDENAME(cerror) #endif +END(brk) Modified: stable/7/lib/libc/amd64/sys/exect.S ============================================================================== --- stable/7/lib/libc/amd64/sys/exect.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/sys/exect.S Thu Nov 13 20:46:07 2008 (r184939) @@ -53,3 +53,4 @@ ENTRY(exect) #else jmp HIDENAME(cerror) #endif +END(exect) Modified: stable/7/lib/libc/amd64/sys/getcontext.S ============================================================================== --- stable/7/lib/libc/amd64/sys/getcontext.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/sys/getcontext.S Thu Nov 13 20:46:07 2008 (r184939) @@ -52,3 +52,4 @@ ENTRY(__sys_getcontext) #else jmp HIDENAME(cerror) #endif +END(__sys_getcontext) Modified: stable/7/lib/libc/amd64/sys/pipe.S ============================================================================== --- stable/7/lib/libc/amd64/sys/pipe.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/sys/pipe.S Thu Nov 13 20:46:07 2008 (r184939) @@ -57,3 +57,4 @@ ENTRY(__sys_pipe) #else jmp HIDENAME(cerror) #endif +END(__sys_pipe) Modified: stable/7/lib/libc/amd64/sys/ptrace.S ============================================================================== --- stable/7/lib/libc/amd64/sys/ptrace.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/sys/ptrace.S Thu Nov 13 20:46:07 2008 (r184939) @@ -57,3 +57,4 @@ err: #else jmp HIDENAME(cerror) #endif +END(ptrace) Modified: stable/7/lib/libc/amd64/sys/reboot.S ============================================================================== --- stable/7/lib/libc/amd64/sys/reboot.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/sys/reboot.S Thu Nov 13 20:46:07 2008 (r184939) @@ -54,3 +54,4 @@ ENTRY(__sys_reboot) #else jmp HIDENAME(cerror) #endif +END(__sys_reboot) Modified: stable/7/lib/libc/amd64/sys/sbrk.S ============================================================================== --- stable/7/lib/libc/amd64/sys/sbrk.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/sys/sbrk.S Thu Nov 13 20:46:07 2008 (r184939) @@ -85,3 +85,4 @@ err: #else jmp HIDENAME(cerror) #endif +END(sbrk) Modified: stable/7/lib/libc/amd64/sys/setlogin.S ============================================================================== --- stable/7/lib/libc/amd64/sys/setlogin.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/sys/setlogin.S Thu Nov 13 20:46:07 2008 (r184939) @@ -62,3 +62,4 @@ ENTRY(__sys_setlogin) #else jmp HIDENAME(cerror) #endif +END(__sys_setlogin) Modified: stable/7/lib/libc/amd64/sys/vfork.S ============================================================================== --- stable/7/lib/libc/amd64/sys/vfork.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/amd64/sys/vfork.S Thu Nov 13 20:46:07 2008 (r184939) @@ -56,3 +56,4 @@ ENTRY(__sys_vfork) #else jmp HIDENAME(cerror) #endif +END(__sys_vfork) Modified: stable/7/lib/libc/i386/SYS.h ============================================================================== --- stable/7/lib/libc/i386/SYS.h Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/SYS.h Thu Nov 13 20:46:07 2008 (r184939) @@ -44,13 +44,14 @@ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ mov __CONCAT($SYS_,x),%eax; KERNCALL; jb 2b -#define RSYSCALL(x) SYSCALL(x); ret +#define RSYSCALL(x) SYSCALL(x); ret; END(__CONCAT(__sys_,x)) #define PSEUDO(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \ ENTRY(__CONCAT(__sys_,x)); \ .weak CNAME(__CONCAT(_,x)); \ .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \ - mov __CONCAT($SYS_,x),%eax; KERNCALL; jb 2b; ret + mov __CONCAT($SYS_,x),%eax; KERNCALL; jb 2b; ret; \ + END(__CONCAT(__sys_,x)) /* gas messes up offset -- although we don't currently need it, do for BCS */ #define LCALL(x,y) .byte 0x9a ; .long y; .word x Modified: stable/7/lib/libc/i386/gen/_ctx_start.S ============================================================================== --- stable/7/lib/libc/i386/gen/_ctx_start.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/gen/_ctx_start.S Thu Nov 13 20:46:07 2008 (r184939) @@ -49,3 +49,4 @@ ENTRY(_ctx_start) call PIC_PLT(_ctx_done) /* should never return */ call PIC_PLT(abort) /* fubar */ ret +END(_ctx_start) Modified: stable/7/lib/libc/i386/gen/_setjmp.S ============================================================================== --- stable/7/lib/libc/i386/gen/_setjmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/gen/_setjmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -58,6 +58,7 @@ ENTRY(_setjmp) fnstcw 24(%eax) xorl %eax,%eax ret +END(_setjmp) .weak CNAME(_longjmp) .set CNAME(_longjmp),CNAME(___longjmp) @@ -77,3 +78,4 @@ ENTRY(___longjmp) incl %eax 1: movl %ecx,0(%esp) ret +END(___longjmp) Modified: stable/7/lib/libc/i386/gen/fabs.S ============================================================================== --- stable/7/lib/libc/i386/gen/fabs.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/gen/fabs.S Thu Nov 13 20:46:07 2008 (r184939) @@ -40,3 +40,4 @@ ENTRY(fabs) fldl 4(%esp) fabs ret +END(fabs) Modified: stable/7/lib/libc/i386/gen/modf.S ============================================================================== --- stable/7/lib/libc/i386/gen/modf.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/gen/modf.S Thu Nov 13 20:46:07 2008 (r184939) @@ -82,3 +82,4 @@ ENTRY(modf) fdivp /* return +/- 0 for +/- Inf, NaN for NaN */ leave ret +END(modf) Modified: stable/7/lib/libc/i386/gen/rfork_thread.S ============================================================================== --- stable/7/lib/libc/i386/gen/rfork_thread.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/gen/rfork_thread.S Thu Nov 13 20:46:07 2008 (r184939) @@ -115,3 +115,4 @@ ENTRY(rfork_thread) popl %ebp PIC_PROLOGUE jmp PIC_PLT(HIDENAME(cerror)) +END(rfork_thread) Modified: stable/7/lib/libc/i386/gen/setjmp.S ============================================================================== --- stable/7/lib/libc/i386/gen/setjmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/gen/setjmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -69,6 +69,7 @@ ENTRY(setjmp) fnstcw 24(%ecx) xorl %eax,%eax ret +END(setjmp) .weak CNAME(longjmp) .set CNAME(longjmp),CNAME(__longjmp) @@ -97,3 +98,4 @@ ENTRY(__longjmp) incl %eax 1: movl %ecx,0(%esp) ret +END(__longjmp) Modified: stable/7/lib/libc/i386/gen/sigsetjmp.S ============================================================================== --- stable/7/lib/libc/i386/gen/sigsetjmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/gen/sigsetjmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -78,10 +78,11 @@ ENTRY(sigsetjmp) fnstcw 24(%ecx) xorl %eax,%eax ret +END(sigsetjmp) .weak CNAME(siglongjmp); - .set CNAME(siglongjmp),CNAME(__siglongjmp); -ENTRY(__siglongjmp); + .set CNAME(siglongjmp),CNAME(__siglongjmp) +ENTRY(__siglongjmp) movl 4(%esp),%edx cmpl $0,44(%edx) jz 2f @@ -108,3 +109,4 @@ ENTRY(__siglongjmp); incl %eax 1: movl %ecx,0(%esp) ret +END(__siglongjmp) Modified: stable/7/lib/libc/i386/stdlib/abs.S ============================================================================== --- stable/7/lib/libc/i386/stdlib/abs.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/stdlib/abs.S Thu Nov 13 20:46:07 2008 (r184939) @@ -44,3 +44,4 @@ ENTRY(abs) jns 1f negl %eax 1: ret +END(abs) Modified: stable/7/lib/libc/i386/stdlib/div.S ============================================================================== --- stable/7/lib/libc/i386/stdlib/div.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/stdlib/div.S Thu Nov 13 20:46:07 2008 (r184939) @@ -36,3 +36,4 @@ ENTRY(div) movl %eax,4(%esp) movl %edx,8(%esp) ret +END(div) Modified: stable/7/lib/libc/i386/stdlib/labs.S ============================================================================== --- stable/7/lib/libc/i386/stdlib/labs.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/stdlib/labs.S Thu Nov 13 20:46:07 2008 (r184939) @@ -44,3 +44,4 @@ ENTRY(labs) jns 1f negl %eax 1: ret +END(labs) Modified: stable/7/lib/libc/i386/stdlib/ldiv.S ============================================================================== --- stable/7/lib/libc/i386/stdlib/ldiv.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/stdlib/ldiv.S Thu Nov 13 20:46:07 2008 (r184939) @@ -39,3 +39,4 @@ ENTRY(ldiv) movl %eax,4(%esp) movl %edx,8(%esp) ret +END(ldiv) Modified: stable/7/lib/libc/i386/string/bcmp.S ============================================================================== --- stable/7/lib/libc/i386/string/bcmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/bcmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -61,3 +61,4 @@ L1: popl %esi popl %edi ret +END(bcmp) Modified: stable/7/lib/libc/i386/string/bcopy.S ============================================================================== --- stable/7/lib/libc/i386/string/bcopy.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/bcopy.S Thu Nov 13 20:46:07 2008 (r184939) @@ -97,3 +97,12 @@ ENTRY(bcopy) popl %esi cld ret +#ifdef MEMCOPY +END(memcpy) +#else +#ifdef MEMMOVE +END(memmove) +#else +END(bcopy) +#endif +#endif Modified: stable/7/lib/libc/i386/string/bzero.S ============================================================================== --- stable/7/lib/libc/i386/string/bzero.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/bzero.S Thu Nov 13 20:46:07 2008 (r184939) @@ -79,3 +79,4 @@ L1: rep popl %ebx popl %edi ret +END(bzero) Modified: stable/7/lib/libc/i386/string/ffs.S ============================================================================== --- stable/7/lib/libc/i386/string/ffs.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/ffs.S Thu Nov 13 20:46:07 2008 (r184939) @@ -51,3 +51,4 @@ ENTRY(ffs) .align 2 L1: xorl %eax,%eax /* clear result */ ret +END(ffs) Modified: stable/7/lib/libc/i386/string/index.S ============================================================================== --- stable/7/lib/libc/i386/string/index.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/index.S Thu Nov 13 20:46:07 2008 (r184939) @@ -61,3 +61,4 @@ L1: L2: popl %ebx ret +END(index) Modified: stable/7/lib/libc/i386/string/memchr.S ============================================================================== --- stable/7/lib/libc/i386/string/memchr.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/memchr.S Thu Nov 13 20:46:07 2008 (r184939) @@ -56,3 +56,4 @@ ENTRY(memchr) L1: xorl %eax,%eax popl %edi ret +END(memchr) Modified: stable/7/lib/libc/i386/string/memcmp.S ============================================================================== --- stable/7/lib/libc/i386/string/memcmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/memcmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -73,3 +73,4 @@ L6: movzbl -1(%edi),%eax /* Perform un popl %esi popl %edi ret +END(memcmp) Modified: stable/7/lib/libc/i386/string/memset.S ============================================================================== --- stable/7/lib/libc/i386/string/memset.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/memset.S Thu Nov 13 20:46:07 2008 (r184939) @@ -87,3 +87,4 @@ L1: rep popl %ebx popl %edi ret +END(memset) Modified: stable/7/lib/libc/i386/string/rindex.S ============================================================================== --- stable/7/lib/libc/i386/string/rindex.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/rindex.S Thu Nov 13 20:46:07 2008 (r184939) @@ -62,3 +62,4 @@ L2: jne L1 popl %ebx ret +END(rindex) Modified: stable/7/lib/libc/i386/string/strcat.S ============================================================================== --- stable/7/lib/libc/i386/string/strcat.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/strcat.S Thu Nov 13 20:46:07 2008 (r184939) @@ -98,3 +98,4 @@ L1: movb (%edx),%al /* unroll loop, but L2: popl %eax /* pop destination address */ popl %edi /* restore edi */ ret +END(strcat) Modified: stable/7/lib/libc/i386/string/strchr.S ============================================================================== --- stable/7/lib/libc/i386/string/strchr.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/strchr.S Thu Nov 13 20:46:07 2008 (r184939) @@ -61,3 +61,4 @@ L1: L2: popl %ebx ret +END(strchr) Modified: stable/7/lib/libc/i386/string/strcmp.S ============================================================================== --- stable/7/lib/libc/i386/string/strcmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/strcmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -117,3 +117,4 @@ L3: movzbl (%eax),%eax movzbl (%edx),%edx subl %edx,%eax ret +END(strcmp) Modified: stable/7/lib/libc/i386/string/strcpy.S ============================================================================== --- stable/7/lib/libc/i386/string/strcpy.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/strcpy.S Thu Nov 13 20:46:07 2008 (r184939) @@ -87,3 +87,4 @@ L1: movb (%edx),%al /* unroll loop, but jne L1 L2: popl %eax /* pop dst address */ ret +END(strcpy) Modified: stable/7/lib/libc/i386/string/strlen.S ============================================================================== --- stable/7/lib/libc/i386/string/strlen.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/strlen.S Thu Nov 13 20:46:07 2008 (r184939) @@ -51,3 +51,4 @@ ENTRY(strlen) leal -1(%ecx),%eax /* and subtracting one */ popl %edi ret +END(strlen) Modified: stable/7/lib/libc/i386/string/strncmp.S ============================================================================== --- stable/7/lib/libc/i386/string/strncmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/strncmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -164,3 +164,4 @@ L3: movzbl (%eax),%eax /* unsigned comp L4: xorl %eax,%eax popl %ebx ret +END(strncmp) Modified: stable/7/lib/libc/i386/string/strrchr.S ============================================================================== --- stable/7/lib/libc/i386/string/strrchr.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/strrchr.S Thu Nov 13 20:46:07 2008 (r184939) @@ -62,3 +62,4 @@ L2: jne L1 popl %ebx ret +END(strrchr) Modified: stable/7/lib/libc/i386/string/swab.S ============================================================================== --- stable/7/lib/libc/i386/string/swab.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/swab.S Thu Nov 13 20:46:07 2008 (r184939) @@ -97,3 +97,4 @@ L3: lodsw L4: popl %edi popl %esi ret +END(swab) Modified: stable/7/lib/libc/i386/string/wcschr.S ============================================================================== --- stable/7/lib/libc/i386/string/wcschr.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/wcschr.S Thu Nov 13 20:46:07 2008 (r184939) @@ -74,3 +74,4 @@ found0: popl %ebx no: popl %ebx xorl %eax,%eax ret +END(wcschr) Modified: stable/7/lib/libc/i386/string/wcscmp.S ============================================================================== --- stable/7/lib/libc/i386/string/wcscmp.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/wcscmp.S Thu Nov 13 20:46:07 2008 (r184939) @@ -77,3 +77,4 @@ no0: subl (%esi),%eax popl %esi popl %edi ret +END(wcscmp) Modified: stable/7/lib/libc/i386/string/wcslen.S ============================================================================== --- stable/7/lib/libc/i386/string/wcslen.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/wcslen.S Thu Nov 13 20:46:07 2008 (r184939) @@ -66,3 +66,4 @@ found2: incl %eax found1: incl %eax found0: popl %ebx ret +END(wcslen) Modified: stable/7/lib/libc/i386/string/wmemchr.S ============================================================================== --- stable/7/lib/libc/i386/string/wmemchr.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/string/wmemchr.S Thu Nov 13 20:46:07 2008 (r184939) @@ -103,3 +103,4 @@ no: xorl %eax,%eax popl %ebx popl %edi ret +END(wmemchr) Modified: stable/7/lib/libc/i386/sys/Ovfork.S ============================================================================== --- stable/7/lib/libc/i386/sys/Ovfork.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/Ovfork.S Thu Nov 13 20:46:07 2008 (r184939) @@ -52,3 +52,4 @@ ENTRY(__sys_vfork) pushl %ecx PIC_PROLOGUE jmp PIC_PLT(HIDENAME(cerror)) +END(__sys_vfork) Modified: stable/7/lib/libc/i386/sys/brk.S ============================================================================== --- stable/7/lib/libc/i386/sys/brk.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/brk.S Thu Nov 13 20:46:07 2008 (r184939) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); .globl HIDENAME(minbrk) ENTRY(_brk) jmp ok +END(_brk) ENTRY(brk) #ifdef PIC @@ -84,3 +85,4 @@ ok: err: jmp HIDENAME(cerror) #endif +END(brk) Modified: stable/7/lib/libc/i386/sys/exect.S ============================================================================== --- stable/7/lib/libc/i386/sys/exect.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/exect.S Thu Nov 13 20:46:07 2008 (r184939) @@ -49,3 +49,4 @@ ENTRY(exect) KERNCALL PIC_PROLOGUE jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */ +END(exect) Modified: stable/7/lib/libc/i386/sys/getcontext.S ============================================================================== --- stable/7/lib/libc/i386/sys/getcontext.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/getcontext.S Thu Nov 13 20:46:07 2008 (r184939) @@ -48,3 +48,4 @@ ENTRY(__sys_getcontext) 1: PIC_PROLOGUE jmp PIC_PLT(HIDENAME(cerror)) +END(__sys_getcontext) Modified: stable/7/lib/libc/i386/sys/pipe.S ============================================================================== --- stable/7/lib/libc/i386/sys/pipe.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/pipe.S Thu Nov 13 20:46:07 2008 (r184939) @@ -44,3 +44,4 @@ SYSCALL(pipe) movl %edx,4(%ecx) movl $0,%eax ret +END(pipe) Modified: stable/7/lib/libc/i386/sys/ptrace.S ============================================================================== --- stable/7/lib/libc/i386/sys/ptrace.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/ptrace.S Thu Nov 13 20:46:07 2008 (r184939) @@ -55,3 +55,4 @@ ENTRY(ptrace) err: PIC_PROLOGUE jmp PIC_PLT(HIDENAME(cerror)) +END(ptrace) Modified: stable/7/lib/libc/i386/sys/reboot.S ============================================================================== --- stable/7/lib/libc/i386/sys/reboot.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/reboot.S Thu Nov 13 20:46:07 2008 (r184939) @@ -40,3 +40,4 @@ __FBSDID("$FreeBSD$"); SYSCALL(reboot) iret +END(reboot) Modified: stable/7/lib/libc/i386/sys/sbrk.S ============================================================================== --- stable/7/lib/libc/i386/sys/sbrk.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/sbrk.S Thu Nov 13 20:46:07 2008 (r184939) @@ -88,3 +88,4 @@ back: err: jmp HIDENAME(cerror) #endif /* PIC */ +END(sbrk) Modified: stable/7/lib/libc/i386/sys/setlogin.S ============================================================================== --- stable/7/lib/libc/i386/sys/setlogin.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/setlogin.S Thu Nov 13 20:46:07 2008 (r184939) @@ -52,3 +52,4 @@ SYSCALL(setlogin) movl $0,CNAME(_logname_valid) #endif ret /* setlogin(name) */ +END(setlogin) Modified: stable/7/lib/libc/i386/sys/syscall.S ============================================================================== --- stable/7/lib/libc/i386/sys/syscall.S Thu Nov 13 20:40:38 2008 (r184938) +++ stable/7/lib/libc/i386/sys/syscall.S Thu Nov 13 20:46:07 2008 (r184939) @@ -50,3 +50,4 @@ ENTRY(syscall) 1: PIC_PROLOGUE jmp PIC_PLT(HIDENAME(cerror)) +END(syscall) From rpaulo at FreeBSD.org Thu Nov 13 13:11:35 2008 From: rpaulo at FreeBSD.org (Rui Paulo) Date: Thu Nov 13 13:11:41 2008 Subject: svn commit: r184940 - in stable/7/contrib: . traceroute Message-ID: <200811132111.mADLBYqu069094@svn.freebsd.org> Author: rpaulo Date: Thu Nov 13 21:11:34 2008 New Revision: 184940 URL: http://svn.freebsd.org/changeset/base/184940 Log: Reverse botched mergeinfo for r176428. Approved by: re (implicit) Modified: stable/7/contrib/ (props changed) stable/7/contrib/traceroute/ (props changed) From jhb at FreeBSD.org Thu Nov 13 14:34:33 2008 From: jhb at FreeBSD.org (John Baldwin) Date: Thu Nov 13 14:34:51 2008 Subject: svn commit: r184944 - in stable/7/sys: . kern modules/cxgb Message-ID: <200811132234.mADMYXL9071580@svn.freebsd.org> Author: jhb Date: Thu Nov 13 22:34:33 2008 New Revision: 184944 URL: http://svn.freebsd.org/changeset/base/184944 Log: MFC: Adjust the license statement to more closely match a standard 3-clause BSD license. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/kern/subr_smp.c stable/7/sys/modules/cxgb/ (props changed) Modified: stable/7/sys/kern/subr_smp.c ============================================================================== --- stable/7/sys/kern/subr_smp.c Thu Nov 13 21:49:07 2008 (r184943) +++ stable/7/sys/kern/subr_smp.c Thu Nov 13 22:34:33 2008 (r184944) @@ -1,6 +1,6 @@ /*- - * Copyright (c) 2001 - * John Baldwin . All rights reserved. + * Copyright (c) 2001, John Baldwin . + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,21 +10,21 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the author nor the names of any co-contributors + * 3. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY JOHN BALDWIN AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL JOHN BALDWIN OR THE VOICES IN HIS HEAD - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* From dougb at FreeBSD.org Fri Nov 14 03:00:36 2008 From: dougb at FreeBSD.org (Doug Barton) Date: Fri Nov 14 03:00:56 2008 Subject: svn commit: r184967 - in stable/7: contrib/bind9 contrib/bind9/bin/dig contrib/bind9/bin/named contrib/bind9/bin/rndc contrib/bind9/doc/arm contrib/bind9/lib/bind contrib/bind9/lib/bind9 contrib/bi... Message-ID: <200811141100.mAEB0Zh8089899@svn.freebsd.org> Author: dougb Date: Fri Nov 14 11:00:34 2008 New Revision: 184967 URL: http://svn.freebsd.org/changeset/base/184967 Log: MFC the BIND 9.4.2-P2 update Approved by: re (kib) Modified: stable/7/contrib/bind9/ (props changed) stable/7/contrib/bind9/CHANGES stable/7/contrib/bind9/COPYRIGHT stable/7/contrib/bind9/bin/dig/dighost.c stable/7/contrib/bind9/bin/named/client.c stable/7/contrib/bind9/bin/named/config.c stable/7/contrib/bind9/bin/named/controlconf.c stable/7/contrib/bind9/bin/named/interfacemgr.c stable/7/contrib/bind9/bin/named/lwresd.c stable/7/contrib/bind9/bin/named/named.conf.docbook stable/7/contrib/bind9/bin/named/server.c stable/7/contrib/bind9/bin/rndc/rndc.c stable/7/contrib/bind9/configure.in stable/7/contrib/bind9/doc/arm/Bv9ARM-book.xml stable/7/contrib/bind9/lib/bind/configure.in stable/7/contrib/bind9/lib/bind9/check.c stable/7/contrib/bind9/lib/dns/api stable/7/contrib/bind9/lib/dns/dispatch.c stable/7/contrib/bind9/lib/dns/include/dns/dispatch.h stable/7/contrib/bind9/lib/dns/request.c stable/7/contrib/bind9/lib/dns/resolver.c stable/7/contrib/bind9/lib/dns/xfrin.c stable/7/contrib/bind9/lib/isc/api stable/7/contrib/bind9/lib/isc/include/isc/resource.h stable/7/contrib/bind9/lib/isc/include/isc/socket.h stable/7/contrib/bind9/lib/isc/include/isc/timer.h stable/7/contrib/bind9/lib/isc/timer.c stable/7/contrib/bind9/lib/isc/unix/app.c stable/7/contrib/bind9/lib/isc/unix/resource.c stable/7/contrib/bind9/lib/isc/unix/socket.c stable/7/contrib/bind9/lib/isc/unix/socket_p.h stable/7/contrib/bind9/lib/isccfg/api stable/7/contrib/bind9/lib/isccfg/namedconf.c stable/7/contrib/bind9/version stable/7/lib/bind/ (props changed) stable/7/lib/bind/config.h Modified: stable/7/contrib/bind9/CHANGES ============================================================================== --- stable/7/contrib/bind9/CHANGES Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/CHANGES Fri Nov 14 11:00:34 2008 (r184967) @@ -1,3 +1,47 @@ + --- 9.4.2-P2 released --- + +2406. [bug] Some operating systems have FD_SETSIZE set to a + low value by default, which can cause resource + exhaustion when many simultaneous connections are + open. Linux in particular makes it difficult to + increase this value. To use more sockets with + select(), set ISC_SOCKET_FDSETSIZE. Example: + STD_CDEFINES="-DISC_SOCKET_FDSETSIZE=4096" ./configure + (This should not be necessary in most cases, and + never for an authoritative-only server.) [RT #18328] + +2404. [port] hpux: files unlimited support. + +2403. [bug] TSIG context leak. [RT #18341] + +2402. [port] Support Solaris 2.11 and over. [RT #18362] + +2401. [bug] Expect to get E[MN]FILE errno internal_accept() + (from accept() or fcntl() system calls). [RT #18358] + +2399. [bug] Abort timeout queries to reduce the number of open + UDP sockets. [RT #18367] + +2398. [bug] Improve file descriptor management. New, + temporary, named.conf option reserved-sockets, + default 512. [RT #18344] + +2396. [bug] Don't set SO_REUSEADDR for randomized ports. + [RT #18336] + +2395. [port] Avoid warning and no effect from "files unlimited" + on Linux when running as root. [RT #18335] + +2394. [bug] Default configuration options set the limit for + open files to 'unlimited' as described in the + documentation. [RT #18331] + +2392. [bug] remove 'grep -q' from acl test script, some platforms + don't support it. [RT #18253] + +2322. [port] MacOS: work around the limitation of setrlimit() + for RLIMIT_NOFILE. [RT #17526] + --- 9.4.2-P1 released --- 2375. [security] Fully randomize UDP query ports to improve @@ -33,7 +77,7 @@ [RT #17113] 2249. [bug] Only set Authentic Data bit if client requested - DNSSEC, per RFC 3655 [RT #17175] + DNSSEC, per RFC 3655 [RT #17175] 2248. [cleanup] Fix several errors reported by Coverity. [RT #17160] Modified: stable/7/contrib/bind9/COPYRIGHT ============================================================================== --- stable/7/contrib/bind9/COPYRIGHT Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/COPYRIGHT Fri Nov 14 11:00:34 2008 (r184967) @@ -1,4 +1,4 @@ -Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") +Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") Copyright (C) 1996-2003 Internet Software Consortium. Permission to use, copy, modify, and/or distribute this software for any @@ -13,7 +13,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -$Id: COPYRIGHT,v 1.9.18.4 2007/08/28 07:19:54 tbox Exp $ +$Id: COPYRIGHT,v 1.9.18.4.10.1 2008/07/23 07:28:54 tbox Exp $ Portions Copyright (C) 1996-2001 Nominum, Inc. Modified: stable/7/contrib/bind9/bin/dig/dighost.c ============================================================================== --- stable/7/contrib/bind9/bin/dig/dighost.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/bin/dig/dighost.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dighost.c,v 1.259.18.43 2007/08/28 07:19:55 tbox Exp $ */ +/* $Id: dighost.c,v 1.259.18.43.10.3 2008/07/23 23:16:43 marka Exp $ */ /*! \file * \note @@ -2217,14 +2217,15 @@ send_tcp_connect(dig_query_t *query) { sockcount++; debug("sockcount=%d", sockcount); if (specified_source) - result = isc_socket_bind(query->sock, &bind_address); + result = isc_socket_bind(query->sock, &bind_address, + ISC_SOCKET_REUSEADDRESS); else { if ((isc_sockaddr_pf(&query->sockaddr) == AF_INET) && have_ipv4) isc_sockaddr_any(&bind_any); else isc_sockaddr_any6(&bind_any); - result = isc_socket_bind(query->sock, &bind_any); + result = isc_socket_bind(query->sock, &bind_any, 0); } check_result(result, "isc_socket_bind"); bringup_timer(query, TCP_TIMEOUT); @@ -2271,11 +2272,12 @@ send_udp(dig_query_t *query) { sockcount++; debug("sockcount=%d", sockcount); if (specified_source) { - result = isc_socket_bind(query->sock, &bind_address); + result = isc_socket_bind(query->sock, &bind_address, + ISC_SOCKET_REUSEADDRESS); } else { isc_sockaddr_anyofpf(&bind_any, isc_sockaddr_pf(&query->sockaddr)); - result = isc_socket_bind(query->sock, &bind_any); + result = isc_socket_bind(query->sock, &bind_any, 0); } check_result(result, "isc_socket_bind"); Modified: stable/7/contrib/bind9/bin/named/client.c ============================================================================== --- stable/7/contrib/bind9/bin/named/client.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/bin/named/client.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: client.c,v 1.219.18.28.10.1 2008/05/22 21:28:04 each Exp $ */ +/* $Id: client.c,v 1.219.18.28.10.2 2008/07/23 07:28:54 tbox Exp $ */ #include Modified: stable/7/contrib/bind9/bin/named/config.c ============================================================================== --- stable/7/contrib/bind9/bin/named/config.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/bin/named/config.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2001-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.c,v 1.47.18.32 2007/09/13 05:04:01 each Exp $ */ +/* $Id: config.c,v 1.47.18.32.10.3 2008/07/23 23:48:17 tbox Exp $ */ /*! \file */ @@ -52,7 +52,7 @@ options {\n\ #ifndef WIN32 " coresize default;\n\ datasize default;\n\ - files default;\n\ + files unlimited;\n\ stacksize default;\n" #endif " deallocate-on-exit true;\n\ @@ -99,6 +99,7 @@ options {\n\ use-ixfr true;\n\ edns-udp-size 4096;\n\ max-udp-size 4096;\n\ + reserved-sockets 512;\n\ \n\ /* view */\n\ allow-notify {none;};\n\ Modified: stable/7/contrib/bind9/bin/named/controlconf.c ============================================================================== --- stable/7/contrib/bind9/bin/named/controlconf.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/bin/named/controlconf.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2001-2003 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: controlconf.c,v 1.40.18.10 2006/12/07 04:53:02 marka Exp $ */ +/* $Id: controlconf.c,v 1.40.18.10.40.3 2008/07/23 23:16:43 marka Exp $ */ /*! \file */ @@ -1151,8 +1151,8 @@ add_listener(ns_controls_t *cp, controll type, &listener->sock); if (result == ISC_R_SUCCESS) - result = isc_socket_bind(listener->sock, - &listener->address); + result = isc_socket_bind(listener->sock, &listener->address, + ISC_SOCKET_REUSEADDRESS); if (result == ISC_R_SUCCESS && type == isc_sockettype_unix) { listener->perm = cfg_obj_asuint32(cfg_tuple_get(control, Modified: stable/7/contrib/bind9/bin/named/interfacemgr.c ============================================================================== --- stable/7/contrib/bind9/bin/named/interfacemgr.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/bin/named/interfacemgr.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2002 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: interfacemgr.c,v 1.76.18.8 2006/07/20 01:10:30 marka Exp $ */ +/* $Id: interfacemgr.c,v 1.76.18.8.44.3 2008/07/23 23:16:43 marka Exp $ */ /*! \file */ @@ -307,7 +307,8 @@ ns_interface_accepttcp(ns_interface_t *i #ifndef ISC_ALLOW_MAPPED isc_socket_ipv6only(ifp->tcpsocket, ISC_TRUE); #endif - result = isc_socket_bind(ifp->tcpsocket, &ifp->addr); + result = isc_socket_bind(ifp->tcpsocket, &ifp->addr, + ISC_SOCKET_REUSEADDRESS); if (result != ISC_R_SUCCESS) { isc_log_write(IFMGR_COMMON_LOGARGS, ISC_LOG_ERROR, "binding TCP socket: %s", Modified: stable/7/contrib/bind9/bin/named/lwresd.c ============================================================================== --- stable/7/contrib/bind9/bin/named/lwresd.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/bin/named/lwresd.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: lwresd.c,v 1.46.18.7 2006/03/02 00:37:21 marka Exp $ */ +/* $Id: lwresd.c,v 1.46.18.7.52.3 2008/07/23 23:16:43 marka Exp $ */ /*! \file * \brief @@ -576,7 +576,8 @@ listener_bind(ns_lwreslistener_t *listen return (result); } - result = isc_socket_bind(sock, &listener->address); + result = isc_socket_bind(sock, &listener->address, + ISC_SOCKET_REUSEADDRESS); if (result != ISC_R_SUCCESS) { char socktext[ISC_SOCKADDR_FORMATSIZE]; isc_sockaddr_format(&listener->address, socktext, Modified: stable/7/contrib/bind9/bin/named/named.conf.docbook ============================================================================== --- stable/7/contrib/bind9/bin/named/named.conf.docbook Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/bin/named/named.conf.docbook Fri Nov 14 11:00:34 2008 (r184967) @@ -2,7 +2,7 @@ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" []> - + Aug 13, 2004 @@ -40,6 +40,7 @@ 2005 2006 2007 + 2008 Internet Systems Consortium, Inc. ("ISC") @@ -201,6 +202,7 @@ options { port integer; querylog boolean; recursing-file quoted_string; + reserved-sockets integer; random-device quoted_string; recursive-clients integer; serial-query-rate integer; Modified: stable/7/contrib/bind9/bin/named/server.c ============================================================================== --- stable/7/contrib/bind9/bin/named/server.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/bin/named/server.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.419.18.57.10.1 2008/05/22 21:28:04 each Exp $ */ +/* $Id: server.c,v 1.419.18.57.10.3 2008/07/23 12:04:32 marka Exp $ */ /*! \file */ @@ -2696,27 +2696,29 @@ static isc_result_t load_configuration(const char *filename, ns_server_t *server, isc_boolean_t first_time) { - isc_result_t result; - isc_interval_t interval; - cfg_parser_t *parser = NULL; + cfg_aclconfctx_t aclconfctx; cfg_obj_t *config; - const cfg_obj_t *options; - const cfg_obj_t *views; + cfg_parser_t *parser = NULL; + const cfg_listelt_t *element; + const cfg_obj_t *builtin_views; + const cfg_obj_t *maps[3]; const cfg_obj_t *obj; + const cfg_obj_t *options; const cfg_obj_t *v4ports, *v6ports; - const cfg_obj_t *maps[3]; - const cfg_obj_t *builtin_views; - const cfg_listelt_t *element; + const cfg_obj_t *views; dns_view_t *view = NULL; dns_view_t *view_next; - dns_viewlist_t viewlist; dns_viewlist_t tmpviewlist; - cfg_aclconfctx_t aclconfctx; - isc_uint32_t interface_interval; - isc_uint32_t heartbeat_interval; - isc_uint32_t udpsize; + dns_viewlist_t viewlist; in_port_t listen_port; int i; + isc_interval_t interval; + isc_resourcevalue_t files; + isc_result_t result; + isc_uint32_t heartbeat_interval; + isc_uint32_t interface_interval; + isc_uint32_t reserved; + isc_uint32_t udpsize; cfg_aclconfctx_init(&aclconfctx); ISC_LIST_INIT(viewlist); @@ -2797,6 +2799,43 @@ load_configuration(const char *filename, set_limits(maps); /* + * Sanity check on "files" limit. + */ + result = isc_resource_curlimit(isc_resource_openfiles, &files); + if (result == ISC_R_SUCCESS && files < FD_SETSIZE) { + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, + NS_LOGMODULE_SERVER, ISC_LOG_WARNING, + "the 'files' limit (%" ISC_PRINT_QUADFORMAT "u) " + "is less than FD_SETSIZE (%d), increase " + "'files' in named.conf or recompile with a " + "smaller FD_SETSIZE.", files, FD_SETSIZE); + if (files > FD_SETSIZE) + files = FD_SETSIZE; + } else + files = FD_SETSIZE; + + /* + * Set the number of socket reserved for TCP, stdio etc. + */ + obj = NULL; + result = ns_config_get(maps, "reserved-sockets", &obj); + INSIST(result == ISC_R_SUCCESS); + reserved = cfg_obj_asuint32(obj); + if (files < 128U) /* Prevent underflow. */ + reserved = 0; + else if (reserved > files - 128U) /* Mimimum UDP space. */ + reserved = files - 128; + if (reserved < 128U) /* Mimimum TCP/stdio space. */ + reserved = 128; + if (reserved + 128U > files) { + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, + NS_LOGMODULE_SERVER, ISC_LOG_WARNING, + "less than 128 UDP sockets available after " + "applying 'reserved-sockets' and 'files'"); + } + isc__socketmgr_setreserved(ns_g_socketmgr, reserved); + + /* * Configure various server options. */ configure_server_quota(maps, "transfers-out", &server->xfroutquota); Modified: stable/7/contrib/bind9/bin/rndc/rndc.c ============================================================================== --- stable/7/contrib/bind9/bin/rndc/rndc.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/bin/rndc/rndc.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2003 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rndc.c,v 1.96.18.17 2006/08/04 03:03:41 marka Exp $ */ +/* $Id: rndc.c,v 1.96.18.17.42.3 2008/07/23 23:16:43 marka Exp $ */ /*! \file */ @@ -400,10 +400,10 @@ rndc_startconnect(isc_sockaddr_t *addr, DO("create socket", isc_socket_create(socketmgr, pf, type, &sock)); switch (isc_sockaddr_pf(addr)) { case AF_INET: - DO("bind socket", isc_socket_bind(sock, &local4)); + DO("bind socket", isc_socket_bind(sock, &local4, 0)); break; case AF_INET6: - DO("bind socket", isc_socket_bind(sock, &local6)); + DO("bind socket", isc_socket_bind(sock, &local6, 0)); break; default: break; Modified: stable/7/contrib/bind9/configure.in ============================================================================== --- stable/7/contrib/bind9/configure.in Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/configure.in Fri Nov 14 11:00:34 2008 (r184967) @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") # Copyright (C) 1998-2003 Internet Software Consortium. # # Permission to use, copy, modify, and/or distribute this software for any @@ -18,7 +18,7 @@ AC_DIVERT_PUSH(1)dnl esyscmd([sed "s/^/# /" COPYRIGHT])dnl AC_DIVERT_POP()dnl -AC_REVISION($Revision: 1.355.18.71 $) +AC_REVISION($Revision: 1.355.18.71.8.2 $) AC_INIT(lib/dns/name.c) AC_PREREQ(2.59) @@ -1839,7 +1839,7 @@ case "$host" in [*-solaris2.[89]]) hack_shutup_pthreadonceinit=yes ;; - *-solaris2.10) + *-solaris2.1[0-9]) hack_shutup_pthreadonceinit=yes ;; esac Modified: stable/7/contrib/bind9/doc/arm/Bv9ARM-book.xml ============================================================================== --- stable/7/contrib/bind9/doc/arm/Bv9ARM-book.xml Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/doc/arm/Bv9ARM-book.xml Fri Nov 14 11:00:34 2008 (r184967) @@ -2,7 +2,7 @@ "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" []> - + BIND 9 Administrator Reference Manual @@ -28,6 +28,7 @@ 2005 2006 2007 + 2008 Internet Systems Consortium, Inc. ("ISC") @@ -4441,6 +4442,7 @@ category notify { null; }; max-transfer-idle-in number; max-transfer-idle-out number; tcp-clients number; + reserved-sockets number; recursive-clients number; serial-query-rate number; serial-queries number; @@ -6606,6 +6608,23 @@ query-source-v6 address * port *; + reserved-sockets + + + The number of file descriptors reserved for TCP, stdio, + etc. This needs to be big enough to cover the number of + interfaces named listens on, tcp-clients as well as + to provide room for outgoing TCP queries and incoming zone + transfers. The default is 512. + The minimum value is 128 and the + maximum value is 128 less than + 'files' or FD_SETSIZE (whichever is smaller). This + option may be removed in the future. + + + + + max-cache-size Modified: stable/7/contrib/bind9/lib/bind/configure.in ============================================================================== --- stable/7/contrib/bind9/lib/bind/configure.in Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/bind/configure.in Fri Nov 14 11:00:34 2008 (r184967) @@ -1,4 +1,4 @@ -# Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") # Copyright (C) 2001, 2003 Internet Software Consortium. # # Permission to use, copy, modify, and/or distribute this software for any @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -AC_REVISION($Revision: 1.90.18.34 $) +AC_REVISION($Revision: 1.90.18.34.10.2 $) AC_INIT(resolv/herror.c) AC_PREREQ(2.13) @@ -2590,7 +2590,7 @@ case "$host" in *-solaris2.9) hack_shutup_in6addr_init_macros=yes ;; - *-solaris2.10) + *-solaris2.1[0-9]) hack_shutup_in6addr_init_macros=yes ;; esac Modified: stable/7/contrib/bind9/lib/bind9/check.c ============================================================================== --- stable/7/contrib/bind9/lib/bind9/check.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/bind9/check.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1015,10 +1015,10 @@ check_zoneconf(const cfg_obj_t *zconfig, isc_buffer_add(&b, strlen(zname)); tresult = dns_name_fromtext(dns_fixedname_name(&fixedname), &b, dns_rootname, ISC_TRUE, NULL); - if (tresult != ISC_R_SUCCESS) { + if (result != ISC_R_SUCCESS) { cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR, "zone '%s': is not a valid name", zname); - result = ISC_R_FAILURE; + tresult = ISC_R_FAILURE; } else { char namebuf[DNS_NAME_FORMATSIZE]; Modified: stable/7/contrib/bind9/lib/dns/api ============================================================================== --- stable/7/contrib/bind9/lib/dns/api Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/dns/api Fri Nov 14 11:00:34 2008 (r184967) @@ -1,3 +1,3 @@ LIBINTERFACE = 35 -LIBREVISION = 0 +LIBREVISION = 1 LIBAGE = 0 Modified: stable/7/contrib/bind9/lib/dns/dispatch.c ============================================================================== --- stable/7/contrib/bind9/lib/dns/dispatch.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/dns/dispatch.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dispatch.c,v 1.116.18.19.12.1 2008/05/22 21:28:06 each Exp $ */ +/* $Id: dispatch.c,v 1.116.18.19.12.5 2008/07/23 23:16:43 marka Exp $ */ /*! \file */ @@ -276,7 +276,26 @@ request_log(dns_dispatch_t *disp, dns_di } /* - * ARC4 random number generator obtained from OpenBSD + * ARC4 random number generator derived from OpenBSD. + * Only dispatch_arc4random() and dispatch_arc4uniformrandom() are expected + * to be called from general dispatch routines; the rest of them are subroutines + * for these two. + * + * The original copyright follows: + * Copyright (c) 1996, David Mazieres + * Copyright (c) 2008, Damien Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ static void dispatch_arc4init(arc4ctx_t *actx) { @@ -1172,7 +1191,7 @@ destroy_mgr(dns_dispatchmgr_t **mgrp) { static isc_result_t create_socket(isc_socketmgr_t *mgr, isc_sockaddr_t *local, - isc_socket_t **sockp) + unsigned int options, isc_socket_t **sockp) { isc_socket_t *sock; isc_result_t result; @@ -1186,7 +1205,7 @@ create_socket(isc_socketmgr_t *mgr, isc_ #ifndef ISC_ALLOW_MAPPED isc_socket_ipv6only(sock, ISC_TRUE); #endif - result = isc_socket_bind(sock, local); + result = isc_socket_bind(sock, local, options); if (result != ISC_R_SUCCESS) { isc_socket_detach(&sock); return (result); @@ -1917,7 +1936,7 @@ dispatch_createudp(dns_dispatchmgr_t *mg attributes &= ~DNS_DISPATCHATTR_RANDOMPORT; goto getsocket; } - result = create_socket(sockmgr, &localaddr_bound, &sock); + result = create_socket(sockmgr, &localaddr_bound, 0, &sock); if (result == ISC_R_ADDRINUSE) { if (++k == 1024) attributes &= ~DNS_DISPATCHATTR_RANDOMPORT; @@ -1925,7 +1944,8 @@ dispatch_createudp(dns_dispatchmgr_t *mg } localport = prt; } else - result = create_socket(sockmgr, localaddr, &sock); + result = create_socket(sockmgr, localaddr, + ISC_SOCKET_REUSEADDRESS, &sock); if (result != ISC_R_SUCCESS) goto deallocate_dispatch; if ((attributes & DNS_DISPATCHATTR_RANDOMPORT) == 0 && Modified: stable/7/contrib/bind9/lib/dns/include/dns/dispatch.h ============================================================================== --- stable/7/contrib/bind9/lib/dns/include/dns/dispatch.h Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/dns/include/dns/dispatch.h Fri Nov 14 11:00:34 2008 (r184967) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dispatch.h,v 1.48.18.5.12.1 2008/05/22 21:28:06 each Exp $ */ +/* $Id: dispatch.h,v 1.48.18.5.12.2 2008/07/23 07:28:56 tbox Exp $ */ #ifndef DNS_DISPATCH_H #define DNS_DISPATCH_H 1 Modified: stable/7/contrib/bind9/lib/dns/request.c ============================================================================== --- stable/7/contrib/bind9/lib/dns/request.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/dns/request.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000-2002 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: request.c,v 1.72.18.5 2006/08/21 00:40:53 marka Exp $ */ +/* $Id: request.c,v 1.72.18.5.42.2 2008/07/23 07:28:56 tbox Exp $ */ /*! \file */ @@ -518,11 +518,11 @@ create_tcp_dispatch(dns_requestmgr_t *re if (srcaddr == NULL) { isc_sockaddr_anyofpf(&bind_any, isc_sockaddr_pf(destaddr)); - result = isc_socket_bind(socket, &bind_any); + result = isc_socket_bind(socket, &bind_any, 0); } else { src = *srcaddr; isc_sockaddr_setport(&src, 0); - result = isc_socket_bind(socket, &src); + result = isc_socket_bind(socket, &src, 0); } if (result != ISC_R_SUCCESS) goto cleanup; Modified: stable/7/contrib/bind9/lib/dns/resolver.c ============================================================================== --- stable/7/contrib/bind9/lib/dns/resolver.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/dns/resolver.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.284.18.66.8.1 2008/05/22 21:28:06 each Exp $ */ +/* $Id: resolver.c,v 1.284.18.66.8.4 2008/07/24 05:00:48 jinmei Exp $ */ /*! \file */ @@ -1123,7 +1123,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddr goto cleanup_query; #ifndef BROKEN_TCP_BIND_BEFORE_CONNECT - result = isc_socket_bind(query->tcpsocket, &addr); + result = isc_socket_bind(query->tcpsocket, &addr, 0); if (result != ISC_R_SUCCESS) goto cleanup_socket; #endif @@ -2689,6 +2689,8 @@ fctx_destroy(fetchctx_t *fctx) { static void fctx_timeout(isc_task_t *task, isc_event_t *event) { fetchctx_t *fctx = event->ev_arg; + isc_timerevent_t *tevent = (isc_timerevent_t *)event; + resquery_t *query; REQUIRE(VALID_FCTX(fctx)); @@ -2704,8 +2706,18 @@ fctx_timeout(isc_task_t *task, isc_event fctx->timeouts++; /* * We could cancel the running queries here, or we could let - * them keep going. Right now we choose the latter... - */ + * them keep going. Since we normally use separate sockets for + * different queries, we adopt the former approach to reduce + * the number of open sockets: cancel the oldest query if it + * expired after the query had started (this is usually the + * case but is not always so, depending on the task schedule + * timing). + */ + query = ISC_LIST_HEAD(fctx->queries); + if (query != NULL && + isc_time_compare(&tevent->due, &query->start) >= 0) { + fctx_cancelquery(&query, NULL, NULL, ISC_TRUE); + } fctx->attributes &= ~FCTX_ATTR_ADDRWAIT; /* * Our timer has triggered. Reestablish the fctx lifetime Modified: stable/7/contrib/bind9/lib/dns/xfrin.c ============================================================================== --- stable/7/contrib/bind9/lib/dns/xfrin.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/dns/xfrin.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: xfrin.c,v 1.135.18.16 2007/10/31 01:59:47 marka Exp $ */ +/* $Id: xfrin.c,v 1.135.18.16.10.3 2008/07/23 23:16:43 marka Exp $ */ /*! \file */ @@ -862,7 +862,8 @@ xfrin_start(dns_xfrin_ctx_t *xfr) { isc_sockettype_tcp, &xfr->socket)); #ifndef BROKEN_TCP_BIND_BEFORE_CONNECT - CHECK(isc_socket_bind(xfr->socket, &xfr->sourceaddr)); + CHECK(isc_socket_bind(xfr->socket, &xfr->sourceaddr, + ISC_SOCKET_REUSEADDRESS)); #endif CHECK(isc_socket_connect(xfr->socket, &xfr->masteraddr, xfr->task, xfrin_connect_done, xfr)); Modified: stable/7/contrib/bind9/lib/isc/api ============================================================================== --- stable/7/contrib/bind9/lib/isc/api Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/isc/api Fri Nov 14 11:00:34 2008 (r184967) @@ -1,3 +1,3 @@ -LIBINTERFACE = 32 -LIBREVISION = 5 +LIBINTERFACE = 35 +LIBREVISION = 0 LIBAGE = 0 Modified: stable/7/contrib/bind9/lib/isc/include/isc/resource.h ============================================================================== --- stable/7/contrib/bind9/lib/isc/include/isc/resource.h Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/isc/include/isc/resource.h Fri Nov 14 11:00:34 2008 (r184967) @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resource.h,v 1.5.18.2 2005/04/29 00:17:02 marka Exp $ */ +/* $Id: resource.h,v 1.5.18.2.52.2 2008/07/23 23:48:17 tbox Exp $ */ #ifndef ISC_RESOURCE_H #define ISC_RESOURCE_H 1 @@ -81,6 +81,19 @@ isc_resource_getlimit(isc_resource_t res *\li #ISC_R_NOTIMPLEMENTED 'resource' is not a type known by the OS. */ +isc_result_t +isc_resource_curlimit(isc_resource_t resource, isc_resourcevalue_t *value); +/* + * Get the current limit on a resource. + * + * Requires: + * 'resource' is a valid member of the isc_resource_t enumeration. + * + * Returns: + * ISC_R_SUCCESS Success. + * ISC_R_NOTIMPLEMENTED 'resource' is not a type known by the OS. + */ + ISC_LANG_ENDDECLS #endif /* ISC_RESOURCE_H */ Modified: stable/7/contrib/bind9/lib/isc/include/isc/socket.h ============================================================================== --- stable/7/contrib/bind9/lib/isc/include/isc/socket.h Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/isc/include/isc/socket.h Fri Nov 14 11:00:34 2008 (r184967) @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: socket.h,v 1.57.18.6 2006/06/07 00:29:45 marka Exp $ */ +/* $Id: socket.h,v 1.57.18.6.46.4 2008/07/23 23:16:43 marka Exp $ */ #ifndef ISC_SOCKET_H #define ISC_SOCKET_H 1 @@ -77,6 +77,12 @@ ISC_LANG_BEGINDECLS */ #define ISC_SOCKET_MAXSCATTERGATHER 8 +/*% + * In isc_socket_bind() set socket option SO_REUSEADDR prior to calling + * bind() if a non zero port is specified (AF_INET and AF_INET6). + */ +#define ISC_SOCKET_REUSEADDRESS 0x01U + /*** *** Types ***/ @@ -312,7 +318,8 @@ isc_socket_detach(isc_socket_t **socketp */ isc_result_t -isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *addressp); +isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *addressp, + unsigned int options); /*%< * Bind 'socket' to '*addressp'. * @@ -747,6 +754,12 @@ isc_socket_permunix(isc_sockaddr_t *sock * \li #ISC_R_FAILURE */ +void +isc__socketmgr_setreserved(isc_socketmgr_t *mgr, isc_uint32_t); +/*%< + * Temporary. For use by named only. + */ + ISC_LANG_ENDDECLS #endif /* ISC_SOCKET_H */ Modified: stable/7/contrib/bind9/lib/isc/include/isc/timer.h ============================================================================== --- stable/7/contrib/bind9/lib/isc/include/isc/timer.h Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/isc/include/isc/timer.h Fri Nov 14 11:00:34 2008 (r184967) @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.h,v 1.31.18.3 2005/10/26 06:50:50 marka Exp $ */ +/* $Id: timer.h,v 1.31.18.3.52.2 2008/07/24 23:48:09 tbox Exp $ */ #ifndef ISC_TIMER_H #define ISC_TIMER_H 1 @@ -76,6 +76,7 @@ #include #include #include +#include ISC_LANG_BEGINDECLS @@ -93,6 +94,7 @@ typedef enum { typedef struct isc_timerevent { struct isc_event common; + isc_time_t due; } isc_timerevent_t; #define ISC_TIMEREVENT_FIRSTEVENT (ISC_EVENTCLASS_TIMER + 0) Modified: stable/7/contrib/bind9/lib/isc/timer.c ============================================================================== --- stable/7/contrib/bind9/lib/isc/timer.c Fri Nov 14 10:59:36 2008 (r184966) +++ stable/7/contrib/bind9/lib/isc/timer.c Fri Nov 14 11:00:34 2008 (r184967) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2002 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: timer.c,v 1.73.18.7 2007/10/24 23:46:26 tbox Exp $ */ +/* $Id: timer.c,v 1.73.18.7.10.3 2008/07/29 18:35:53 jinmei Exp $ */ /*! \file */ @@ -577,7 +577,7 @@ isc_timer_detach(isc_timer_t **timerp) { static void dispatch(isc_timermgr_t *manager, isc_time_t *now) { isc_boolean_t done = ISC_FALSE, post_event, need_schedule; - isc_event_t *event; + isc_timerevent_t *event; isc_eventtype_t type = 0; isc_timer_t *timer; isc_result_t result; @@ -650,16 +650,18 @@ dispatch(isc_timermgr_t *manager, isc_ti /* * XXX We could preallocate this event. */ - event = isc_event_allocate(manager->mctx, + event = (isc_timerevent_t *)isc_event_allocate(manager->mctx, timer, type, timer->action, timer->arg, sizeof(*event)); - if (event != NULL) - isc_task_send(timer->task, &event); - else + if (event != NULL) { + event->due = timer->due; + isc_task_send(timer->task, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From imp at FreeBSD.org Fri Nov 14 10:09:20 2008 From: imp at FreeBSD.org (Warner Losh) Date: Fri Nov 14 10:09:31 2008 Subject: svn commit: r184973 - in stable/7/sys: . dev/pccbb modules/cxgb Message-ID: <200811141809.mAEI9KJ8098552@svn.freebsd.org> Author: imp Date: Fri Nov 14 18:09:19 2008 New Revision: 184973 URL: http://svn.freebsd.org/changeset/base/184973 Log: Merge r183539 and r183558: Do match on class to avoid false positives, return BUS_GENERIC_PROBE for a generic match. Approved by: re@ Modified: stable/7/sys/ (props changed) stable/7/sys/dev/pccbb/pccbb_pci.c stable/7/sys/modules/cxgb/ (props changed) Modified: stable/7/sys/dev/pccbb/pccbb_pci.c ============================================================================== --- stable/7/sys/dev/pccbb/pccbb_pci.c Fri Nov 14 12:31:05 2008 (r184972) +++ stable/7/sys/dev/pccbb/pccbb_pci.c Fri Nov 14 18:09:19 2008 (r184973) @@ -229,6 +229,7 @@ cbb_pci_probe(device_t brdev) { const char *name; uint32_t progif; + uint32_t baseclass; uint32_t subclass; /* @@ -245,11 +246,13 @@ cbb_pci_probe(device_t brdev) * to date have progif 0 (the Yenta spec, and successors mandate * this). */ + baseclass = pci_get_class(brdev); subclass = pci_get_subclass(brdev); progif = pci_get_progif(brdev); - if (subclass == PCIS_BRIDGE_CARDBUS && progif == 0) { + if (baseclass == PCIC_BRIDGE && + subclass == PCIS_BRIDGE_CARDBUS && progif == 0) { device_set_desc(brdev, "PCI-CardBus Bridge"); - return (BUS_PROBE_DEFAULT); + return (BUS_PROBE_GENERIC); } return (ENXIO); } From marius at FreeBSD.org Sun Nov 16 05:19:47 2008 From: marius at FreeBSD.org (Marius Strobl) Date: Sun Nov 16 05:20:06 2008 Subject: svn commit: r184999 - in stable/7/sys: . dev/esp Message-ID: <200811161319.mAGDJlQd053573@svn.freebsd.org> Author: marius Date: Sun Nov 16 13:19:47 2008 New Revision: 184999 URL: http://svn.freebsd.org/changeset/base/184999 Log: MFC: r180692 o Fix style(9) bugs and similar nits. o Merge ncr53c9x.c from NetBSD: 1.115: fix variable shadowing 1.118: __inline -> inline 1.121: fix empty if Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/dev/esp/esp_sbus.c stable/7/sys/dev/esp/ncr53c9x.c stable/7/sys/dev/esp/ncr53c9xvar.h Modified: stable/7/sys/dev/esp/esp_sbus.c ============================================================================== --- stable/7/sys/dev/esp/esp_sbus.c Sun Nov 16 04:26:38 2008 (r184998) +++ stable/7/sys/dev/esp/esp_sbus.c Sun Nov 16 13:19:47 2008 (r184999) @@ -158,19 +158,19 @@ MODULE_DEPEND(esp, sbus, 1, 1, 1); MODULE_DEPEND(esp, cam, 1, 1, 1); /* - * Functions and the switch for the MI code. + * Functions and the switch for the MI code */ -static u_char esp_read_reg(struct ncr53c9x_softc *, int); -static void esp_write_reg(struct ncr53c9x_softc *, int, u_char); -static int esp_dma_isintr(struct ncr53c9x_softc *); -static void esp_dma_reset(struct ncr53c9x_softc *); -static int esp_dma_intr(struct ncr53c9x_softc *); -static int esp_dma_setup(struct ncr53c9x_softc *, caddr_t *, size_t *, - int, size_t *); -static void esp_dma_go(struct ncr53c9x_softc *); -static void esp_dma_stop(struct ncr53c9x_softc *); -static int esp_dma_isactive(struct ncr53c9x_softc *); -static int espattach(struct esp_softc *, struct ncr53c9x_glue *); +static u_char esp_read_reg(struct ncr53c9x_softc *sc, int reg); +static void esp_write_reg(struct ncr53c9x_softc *sc, int reg, u_char v); +static int esp_dma_isintr(struct ncr53c9x_softc *sc); +static void esp_dma_reset(struct ncr53c9x_softc *sc); +static int esp_dma_intr(struct ncr53c9x_softc *sc); +static int esp_dma_setup(struct ncr53c9x_softc *sc, caddr_t *addr, + size_t *len, int datain, size_t *dmasize); +static void esp_dma_go(struct ncr53c9x_softc *sc); +static void esp_dma_stop(struct ncr53c9x_softc *sc); +static int esp_dma_isactive(struct ncr53c9x_softc *sc); +static int espattach(struct esp_softc *esc, struct ncr53c9x_glue *gluep); static struct ncr53c9x_glue esp_sbus_glue = { esp_read_reg, @@ -311,7 +311,7 @@ esp_sbus_attach(device_t dev) esc->sc_regh = rman_get_bushandle(esc->sc_res); } else { /* - * Search accompanying DMA engine. It should have been + * Search accompanying DMA engine. It should have been * already attached otherwise there isn't much we can do. */ if (device_get_children(device_get_parent(dev), &children, @@ -498,9 +498,6 @@ esp_resume(device_t dev) return (ENXIO); } -/* - * Attach this instance, and then all the sub-devices - */ static int espattach(struct esp_softc *esc, struct ncr53c9x_glue *gluep) { @@ -530,7 +527,7 @@ espattach(struct esp_softc *esc, struct */ /* - * Read the part-unique ID code of the SCSI chip. The contained + * Read the part-unique ID code of the SCSI chip. The contained * value is only valid if all of the following conditions are met: * - After power-up or chip reset. * - Before any value is written to this register. @@ -570,7 +567,7 @@ espattach(struct esp_softc *esc, struct (NCRCFG3_CDB | NCRCFG3_FCLK)) { sc->sc_rev = NCR_VARIANT_ESP100A; } else { - /* NCRCFG2_FE enables > 64K transfers */ + /* NCRCFG2_FE enables > 64K transfers. */ sc->sc_cfg2 |= NCRCFG2_FE; sc->sc_cfg3 = 0; NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3); @@ -581,15 +578,18 @@ espattach(struct esp_softc *esc, struct case 0x00: sc->sc_rev = NCR_VARIANT_FAS100A; break; + case 0x02: if ((uid & 0x07) == 0x02) sc->sc_rev = NCR_VARIANT_FAS216; else sc->sc_rev = NCR_VARIANT_FAS236; break; + case 0x0a: sc->sc_rev = NCR_VARIANT_FAS366; break; + default: /* * We could just treat unknown chips @@ -660,10 +660,10 @@ espattach(struct esp_softc *esc, struct /* * The onboard SCSI chips in Sun Ultra 1 are actually * documented to be NCR53C9X which use NCRCFG3_FCLK and - * NCRCFG3_FSCSI. BSD/OS however probes these chips as + * NCRCFG3_FSCSI. BSD/OS however probes these chips as * FAS100A and uses NCRF9XCFG3_FCLK and NCRF9XCFG3_FSCSI * instead which seems to be correct as otherwise sync - * negotiation just doesn't work. Using NCRF9XCFG3_FCLK + * negotiation just doesn't work. Using NCRF9XCFG3_FCLK * and NCRF9XCFG3_FSCSI with these chips in fact also * yields Fast-SCSI speed. */ @@ -683,7 +683,7 @@ espattach(struct esp_softc *esc, struct /* Limit minsync due to unsolved performance issues. */ sc->sc_maxsync = sc->sc_minsync; - /* Establish interrupt channel */ + /* Establish interrupt channel. */ esc->sc_irqrid = 0; if ((esc->sc_irqres = bus_alloc_resource_any(esc->sc_dev, SYS_RES_IRQ, &esc->sc_irqrid, RF_SHAREABLE|RF_ACTIVE)) == NULL) { @@ -697,7 +697,7 @@ espattach(struct esp_softc *esc, struct goto fail_ires; } - /* Turn on target selection using the `DMA' method */ + /* Turn on target selection using the `DMA' method. */ if (sc->sc_rev != NCR_VARIANT_FAS366) sc->sc_features |= NCR_F_DMASELECT; @@ -720,7 +720,7 @@ espattach(struct esp_softc *esc, struct } /* - * Glue functions. + * Glue functions */ #ifdef ESP_SBUS_DEBUG @@ -844,11 +844,8 @@ static void esp_dma_stop(struct ncr53c9x_softc *sc) { struct esp_softc *esc = (struct esp_softc *)sc; - uint32_t csr; - csr = L64854_GCSR(esc->sc_dma); - csr &= ~D_EN_DMA; - L64854_SCSR(esc->sc_dma, csr); + L64854_SCSR(esc->sc_dma, L64854_GCSR(esc->sc_dma) & ~D_EN_DMA); } static int Modified: stable/7/sys/dev/esp/ncr53c9x.c ============================================================================== --- stable/7/sys/dev/esp/ncr53c9x.c Sun Nov 16 04:26:38 2008 (r184998) +++ stable/7/sys/dev/esp/ncr53c9x.c Sun Nov 16 13:19:47 2008 (r184999) @@ -129,46 +129,54 @@ __FBSDID("$FreeBSD$"); #include #include -int ncr53c9x_debug = NCR_SHOWMISC /*|NCR_SHOWPHASE|NCR_SHOWTRAC|NCR_SHOWCMDS*/; +int ncr53c9x_debug = + NCR_SHOWMISC /* | NCR_SHOWPHASE | NCR_SHOWTRAC | NCR_SHOWCMDS */; #ifdef DEBUG int ncr53c9x_notag = 0; #endif -static void ncr53c9x_select(struct ncr53c9x_softc *, struct ncr53c9x_ecb *); -static int ncr53c9x_reselect(struct ncr53c9x_softc *, int, int, int); -static void ncr53c9x_scsi_reset(struct ncr53c9x_softc *); -static void ncr53c9x_poll(struct cam_sim *); -static void ncr53c9x_sched(struct ncr53c9x_softc *); -static void ncr53c9x_done(struct ncr53c9x_softc *, struct ncr53c9x_ecb *); -static void ncr53c9x_msgin(struct ncr53c9x_softc *); -static void ncr53c9x_msgout(struct ncr53c9x_softc *); +static void ncr53c9x_abort(struct ncr53c9x_softc *sc, + struct ncr53c9x_ecb *ecb); +static void ncr53c9x_dequeue(struct ncr53c9x_softc *sc, + struct ncr53c9x_ecb *ecb); +static void ncr53c9x_done(struct ncr53c9x_softc *sc, + struct ncr53c9x_ecb *ecb); +static void ncr53c9x_free_ecb(struct ncr53c9x_softc *sc, + struct ncr53c9x_ecb *ecb); +static void ncr53c9x_msgin(struct ncr53c9x_softc *sc); +static void ncr53c9x_msgout(struct ncr53c9x_softc *sc); +static void ncr53c9x_poll(struct cam_sim *sim); +static int ncr53c9x_rdfifo(struct ncr53c9x_softc *sc, int how); +static int ncr53c9x_reselect(struct ncr53c9x_softc *sc, int message, + int tagtype, int tagid); +static void ncr53c9x_sense(struct ncr53c9x_softc *sc, + struct ncr53c9x_ecb *ecb); +static void ncr53c9x_scsi_reset(struct ncr53c9x_softc *sc); +static void ncr53c9x_sched(struct ncr53c9x_softc *sc); +static void ncr53c9x_select(struct ncr53c9x_softc *sc, + struct ncr53c9x_ecb *ecb); static void ncr53c9x_timeout(void *arg); static void ncr53c9x_watch(void *arg); -static void ncr53c9x_abort(struct ncr53c9x_softc *, struct ncr53c9x_ecb *); -static void ncr53c9x_dequeue(struct ncr53c9x_softc *, - struct ncr53c9x_ecb *); -static void ncr53c9x_sense(struct ncr53c9x_softc *, struct ncr53c9x_ecb *); -static void ncr53c9x_free_ecb(struct ncr53c9x_softc *, - struct ncr53c9x_ecb *); -static void ncr53c9x_wrfifo(struct ncr53c9x_softc *, u_char *, int); -static int ncr53c9x_rdfifo(struct ncr53c9x_softc *, int); - -static struct ncr53c9x_ecb *ncr53c9x_get_ecb(struct ncr53c9x_softc *); -static struct ncr53c9x_linfo *ncr53c9x_lunsearch(struct ncr53c9x_tinfo *, - int64_t lun); - -static __inline void ncr53c9x_readregs(struct ncr53c9x_softc *); -static __inline int ncr53c9x_stp2cpb(struct ncr53c9x_softc *, int); -static __inline void ncr53c9x_setsync(struct ncr53c9x_softc *, - struct ncr53c9x_tinfo *); +static void ncr53c9x_wrfifo(struct ncr53c9x_softc *sc, u_char *p, + int len); -#define NCR_RDFIFO_START 0 -#define NCR_RDFIFO_CONTINUE 1 +static struct ncr53c9x_ecb *ncr53c9x_get_ecb(struct ncr53c9x_softc *sc); +static struct ncr53c9x_linfo *ncr53c9x_lunsearch(struct ncr53c9x_tinfo *sc, + int64_t lun); + +static inline void ncr53c9x_readregs(struct ncr53c9x_softc *sc); +static inline void ncr53c9x_setsync(struct ncr53c9x_softc *sc, + struct ncr53c9x_tinfo *ti); +static inline int ncr53c9x_stp2cpb(struct ncr53c9x_softc *sc, + int period); -#define NCR_SET_COUNT(sc, size) do { \ - NCR_WRITE_REG((sc), NCR_TCL, (size)); \ +#define NCR_RDFIFO_START 0 +#define NCR_RDFIFO_CONTINUE 1 + +#define NCR_SET_COUNT(sc, size) do { \ + NCR_WRITE_REG((sc), NCR_TCL, (size)); \ NCR_WRITE_REG((sc), NCR_TCM, (size) >> 8); \ - if ((sc->sc_cfg2 & NCRCFG2_FE) || \ + if ((sc->sc_cfg2 & NCRCFG2_FE) || \ (sc->sc_rev == NCR_VARIANT_FAS366)) { \ NCR_WRITE_REG((sc), NCR_TCH, (size) >> 16); \ } \ @@ -178,8 +186,8 @@ static __inline void ncr53c9x_setsync(st } while (0) #ifndef mstohz -#define mstohz(ms) \ - (((ms) < 0x20000) ? \ +#define mstohz(ms) \ + (((ms) < 0x20000) ? \ ((ms +0u) / 1000u) * hz : \ ((ms +0u) * hz) /1000u) #endif @@ -211,6 +219,7 @@ static struct ncr53c9x_linfo * ncr53c9x_lunsearch(struct ncr53c9x_tinfo *ti, int64_t lun) { struct ncr53c9x_linfo *li; + LIST_FOREACH(li, &ti->luns, link) if (li->lun == lun) return (li); @@ -248,7 +257,7 @@ ncr53c9x_attach(struct ncr53c9x_softc *s /* * Allocate SCSI message buffers. * Front-ends can override allocation to avoid alignment - * handling in the DMA engines. Note that that ncr53c9x_msgout() + * handling in the DMA engines. Note that ncr53c9x_msgout() * can request a 1 byte DMA transfer. */ if (sc->sc_omess == NULL) { @@ -294,12 +303,12 @@ ncr53c9x_attach(struct ncr53c9x_softc *s sc->sc_ccf = FREQTOCCF(sc->sc_freq); - /* The value *must not* be == 1. Make it 2 */ + /* The value *must not* be == 1. Make it 2. */ if (sc->sc_ccf == 1) sc->sc_ccf = 2; /* - * The recommended timeout is 250ms. This register is loaded + * The recommended timeout is 250ms. This register is loaded * with a value calculated as follows, from the docs: * * (timout period) x (CLK frequency) @@ -311,11 +320,11 @@ ncr53c9x_attach(struct ncr53c9x_softc *s */ sc->sc_timeout = ((250 * 1000) * sc->sc_freq) / (8192 * sc->sc_ccf); - /* CCF register only has 3 bits; 0 is actually 8 */ + /* The CCF register only has 3 bits; 0 is actually 8. */ sc->sc_ccf &= 7; /* - * Register with CAM + * Register with CAM. */ devq = cam_simq_alloc(sc->sc_ntarg); if (devq == NULL) { @@ -325,8 +334,7 @@ ncr53c9x_attach(struct ncr53c9x_softc *s } sim = cam_sim_alloc(ncr53c9x_action, ncr53c9x_poll, "esp", sc, - device_get_unit(sc->sc_dev), &Giant, 1, - NCR_TAG_DEPTH, devq); + device_get_unit(sc->sc_dev), &Giant, 1, NCR_TAG_DEPTH, devq); if (sim == NULL) { device_printf(sc->sc_dev, "cannot allocate SIM entry\n"); error = ENOMEM; @@ -339,8 +347,7 @@ ncr53c9x_attach(struct ncr53c9x_softc *s } if (xpt_create_path(&path, NULL, cam_sim_path(sim), - CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) - != CAM_REQ_CMP) { + CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) { device_printf(sc->sc_dev, "cannot create path\n"); error = EIO; goto fail_bus; @@ -349,16 +356,19 @@ ncr53c9x_attach(struct ncr53c9x_softc *s sc->sc_sim = sim; sc->sc_path = path; - /* Reset state & bus */ + /* Reset state and bus. */ #if 0 sc->sc_cfflags = sc->sc_dev.dv_cfdata->cf_flags; +#else + sc->sc_cfflags = 0; #endif sc->sc_state = 0; ncr53c9x_init(sc, 1); TAILQ_INIT(&sc->free_list); - if ((sc->ecb_array = malloc(sizeof(struct ncr53c9x_ecb) * NCR_TAG_DEPTH, - M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) { + if ((sc->ecb_array = + malloc(sizeof(struct ncr53c9x_ecb) * NCR_TAG_DEPTH, M_DEVBUF, + M_NOWAIT | M_ZERO)) == NULL) { device_printf(sc->sc_dev, "cannot allocate ECB array\n"); error = ENOMEM; goto fail_path; @@ -416,8 +426,8 @@ ncr53c9x_detach(struct ncr53c9x_softc *s } /* - * This is the generic ncr53c9x reset function. It does not reset the SCSI bus, - * only this controller, but kills any on-going commands, and also stops + * This is the generic ncr53c9x reset function. It does not reset the SCSI + * bus, only this controller, but kills any on-going commands, and also stops * and resets the DMA. * * After reset, registers are loaded with the defaults from the attach @@ -427,20 +437,21 @@ void ncr53c9x_reset(struct ncr53c9x_softc *sc) { - /* reset DMA first */ + /* Reset DMA first. */ NCRDMA_RESET(sc); - /* reset SCSI chip */ + /* Reset SCSI chip. */ NCRCMD(sc, NCRCMD_RSTCHIP); NCRCMD(sc, NCRCMD_NOP); DELAY(500); - /* do these backwards, and fall through */ + /* Do these backwards, and fall through. */ switch (sc->sc_rev) { case NCR_VARIANT_ESP406: case NCR_VARIANT_FAS408: NCR_WRITE_REG(sc, NCR_CFG5, sc->sc_cfg5 | NCRCFG5_SINT); NCR_WRITE_REG(sc, NCR_CFG4, sc->sc_cfg4); + /* FALLTHROUGH */ case NCR_VARIANT_AM53C974: case NCR_VARIANT_FAS100A: case NCR_VARIANT_FAS216: @@ -450,9 +461,11 @@ ncr53c9x_reset(struct ncr53c9x_softc *sc case NCR_VARIANT_ESP200: sc->sc_features |= NCR_F_HASCFG3; NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3); + /* FALLTHROUGH */ case NCR_VARIANT_ESP100A: sc->sc_features |= NCR_F_SELATN3; NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); + /* FALLTHROUGH */ case NCR_VARIANT_ESP100: NCR_WRITE_REG(sc, NCR_CFG1, sc->sc_cfg1); NCR_WRITE_REG(sc, NCR_CCF, sc->sc_ccf); @@ -466,7 +479,7 @@ ncr53c9x_reset(struct ncr53c9x_softc *sc sc->sc_cfg3 = NCRFASCFG3_FASTCLK | NCRFASCFG3_OBAUTO; sc->sc_cfg3_fscsi = NCRFASCFG3_FASTSCSI; NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3); - sc->sc_cfg2 = 0; /* NCRCFG2_HMEFE| NCRCFG2_HME32 */ + sc->sc_cfg2 = 0; /* NCRCFG2_HMEFE | NCRCFG2_HME32 */ NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); NCR_WRITE_REG(sc, NCR_CFG1, sc->sc_cfg1); NCR_WRITE_REG(sc, NCR_CCF, sc->sc_ccf); @@ -475,8 +488,8 @@ ncr53c9x_reset(struct ncr53c9x_softc *sc break; default: - device_printf(sc->sc_dev, "unknown revision code, " - "assuming ESP100\n"); + device_printf(sc->sc_dev, + "unknown revision code, assuming ESP100\n"); NCR_WRITE_REG(sc, NCR_CFG1, sc->sc_cfg1); NCR_WRITE_REG(sc, NCR_CCF, sc->sc_ccf); NCR_WRITE_REG(sc, NCR_SYNCOFF, 0); @@ -488,7 +501,7 @@ ncr53c9x_reset(struct ncr53c9x_softc *sc #if 0 device_printf(sc->sc_dev, "ncr53c9x_reset: revision %d\n", - sc->sc_rev); + sc->sc_rev); device_printf(sc->sc_dev, "ncr53c9x_reset: cfg1 0x%x, cfg2 0x%x, " "cfg3 0x%x, ccf 0x%x, timeout 0x%x\n", sc->sc_cfg1, sc->sc_cfg2, sc->sc_cfg3, sc->sc_ccf, sc->sc_timeout); @@ -496,7 +509,7 @@ ncr53c9x_reset(struct ncr53c9x_softc *sc } /* - * Reset the SCSI bus, but not the chip + * Reset the SCSI bus, but not the chip. */ static void ncr53c9x_scsi_reset(struct ncr53c9x_softc *sc) @@ -510,13 +523,14 @@ ncr53c9x_scsi_reset(struct ncr53c9x_soft } /* - * Initialize ncr53c9x state machine + * Initialize ncr53c9x state machine. */ void ncr53c9x_init(struct ncr53c9x_softc *sc, int doreset) { struct ncr53c9x_ecb *ecb; struct ncr53c9x_linfo *li; + struct ncr53c9x_tinfo *ti; int i, r; NCR_MISC(("[NCR_INIT(%d) %d] ", doreset, sc->sc_state)); @@ -538,13 +552,13 @@ ncr53c9x_init(struct ncr53c9x_softc *sc, ecb->ccb->ccb_h.status = CAM_CMD_TIMEOUT; ncr53c9x_done(sc, ecb); } - /* Cancel outstanding disconnected commands on each LUN */ + /* Cancel outstanding disconnected commands on each LUN. */ for (r = 0; r < sc->sc_ntarg; r++) { LIST_FOREACH(li, &sc->sc_tinfo[r].luns, link) { if ((ecb = li->untagged) != NULL) { li->untagged = NULL; /* - * XXXXXXX + * XXX * * Should we terminate a command * that never reached the disk? @@ -567,7 +581,7 @@ ncr53c9x_init(struct ncr53c9x_softc *sc, } /* - * reset the chip to a known state + * Reset the chip to a known state. */ ncr53c9x_reset(sc); @@ -576,12 +590,14 @@ ncr53c9x_init(struct ncr53c9x_softc *sc, sc->sc_phase = sc->sc_prevphase = INVALID_PHASE; for (r = 0; r < sc->sc_ntarg; r++) { - struct ncr53c9x_tinfo *ti = &sc->sc_tinfo[r]; + ti = &sc->sc_tinfo[r]; /* XXX - config flags per target: low bits: no reselect; high bits: no synch */ + ti->flags = ((sc->sc_minsync != 0 && + (sc->sc_cfflags & (1 << ((r & 7) + 8))) == 0) ? + 0 : T_SYNCHOFF) | + ((sc->sc_cfflags & (1 << (r & 7))) == 0 ? + 0 : T_RSELECTOFF); - ti->flags = ((sc->sc_minsync && !(sc->sc_cfflags & (1<<((r&7)+8)))) - ? 0 : T_SYNCHOFF) | - ((sc->sc_cfflags & (1<<(r&7))) ? T_RSELECTOFF : 0); #ifdef DEBUG if (ncr53c9x_notag) ti->flags &= ~T_TAG; @@ -606,15 +622,15 @@ ncr53c9x_init(struct ncr53c9x_softc *sc, * NCR_INTR - so make sure it is the last read. * * I think that (from reading the docs) most bits in these registers - * only make sense when he DMA CSR has an interrupt showing. Call only + * only make sense when the DMA CSR has an interrupt showing. Call only * if an interrupt is pending. */ -static __inline void +static inline void ncr53c9x_readregs(struct ncr53c9x_softc *sc) { sc->sc_espstat = NCR_READ_REG(sc, NCR_STAT); - /* Only the stepo bits are of interest */ + /* Only the step bits are of interest. */ sc->sc_espstep = NCR_READ_REG(sc, NCR_STEP) & NCRSTEP_MASK; if (sc->sc_rev == NCR_VARIANT_FAS366) @@ -629,9 +645,8 @@ ncr53c9x_readregs(struct ncr53c9x_softc * Determine the SCSI bus phase, return either a real SCSI bus phase * or some pseudo phase we use to detect certain exceptions. */ - sc->sc_phase = (sc->sc_espintr & NCRINTR_DIS) ? - /* Disconnected */ BUSFREE_PHASE : sc->sc_espstat & NCRSTAT_PHASE; + BUSFREE_PHASE : sc->sc_espstat & NCRSTAT_PHASE; NCR_INTS(("regs[intr=%02x,stat=%02x,step=%02x,stat2=%02x] ", sc->sc_espintr, sc->sc_espstat, sc->sc_espstep, sc->sc_espstat2)); @@ -640,18 +655,18 @@ ncr53c9x_readregs(struct ncr53c9x_softc /* * Convert Synchronous Transfer Period to chip register Clock Per Byte value. */ -static __inline int +static inline int ncr53c9x_stp2cpb(struct ncr53c9x_softc *sc, int period) { int v; v = (sc->sc_freq * period) / 250; if (ncr53c9x_cpb2stp(sc, v) < period) - /* Correct round-down error */ + /* Correct round-down error. */ v++; return (v); } -static __inline void +static inline void ncr53c9x_setsync(struct ncr53c9x_softc *sc, struct ncr53c9x_tinfo *ti) { u_char syncoff, synctp; @@ -705,20 +720,17 @@ ncr53c9x_setsync(struct ncr53c9x_softc * static void ncr53c9x_select(struct ncr53c9x_softc *sc, struct ncr53c9x_ecb *ecb) { - int target = ecb->ccb->ccb_h.target_id; - int lun = ecb->ccb->ccb_h.target_lun; struct ncr53c9x_tinfo *ti; - int tiflags; u_char *cmd; - int clen; - int selatn3, selatns; size_t dmasize; + int clen, selatn3, selatns; + int lun = ecb->ccb->ccb_h.target_lun; + int target = ecb->ccb->ccb_h.target_id; NCR_TRACE(("[ncr53c9x_select(t%d,l%d,cmd:%x,tag:%x,%x)] ", target, lun, ecb->cmd.cmd.opcode, ecb->tag[0], ecb->tag[1])); ti = &sc->sc_tinfo[target]; - tiflags = ti->flags; sc->sc_state = NCR_SELECTING; /* * Schedule the timeout now, the first time we will go away @@ -730,7 +742,7 @@ ncr53c9x_select(struct ncr53c9x_softc *s /* * The docs say the target register is never reset, and I - * can't think of a better place to set it + * can't think of a better place to set it. */ if (sc->sc_rev == NCR_VARIANT_FAS366) { NCRCMD(sc, NCRCMD_FLUSH); @@ -756,9 +768,9 @@ ncr53c9x_select(struct ncr53c9x_softc *s NCR_SET_COUNT(sc, dmasize); if (sc->sc_rev != NCR_VARIANT_FAS366) - NCRCMD(sc, NCRCMD_NOP|NCRCMD_DMA); + NCRCMD(sc, NCRCMD_NOP | NCRCMD_DMA); - /* And get the targets attention */ + /* And get the target's attention */ NCRCMD(sc, NCRCMD_SELNATN | NCRCMD_DMA); NCRDMA_SETUP(sc, &sc->sc_cmdp, &sc->sc_cmdlen, 0, &dmasize); @@ -773,15 +785,15 @@ ncr53c9x_select(struct ncr53c9x_softc *s selatn3 = selatns = 0; if (ecb->tag[0] != 0) { if (sc->sc_features & NCR_F_SELATN3) - /* use SELATN3 to send tag messages */ + /* Use SELATN3 to send tag messages. */ selatn3 = 1; else - /* We don't have SELATN3; use SELATNS to send tags */ + /* We don't have SELATN3; use SELATNS to send tags. */ selatns = 1; } if (ti->flags & T_NEGOTIATE) { - /* We have to use SELATNS to send sync/wide messages */ + /* We have to use SELATNS to send sync/wide messages. */ selatn3 = 0; selatns = 1; } @@ -789,34 +801,33 @@ ncr53c9x_select(struct ncr53c9x_softc *s cmd = (u_char *)&ecb->cmd.cmd; if (selatn3) { - /* We'll use tags with SELATN3 */ + /* We'll use tags with SELATN3. */ clen = ecb->clen + 3; cmd -= 3; cmd[0] = MSG_IDENTIFY(lun, 1); /* msg[0] */ cmd[1] = ecb->tag[0]; /* msg[1] */ cmd[2] = ecb->tag[1]; /* msg[2] */ } else { - /* We don't have tags, or will send messages with SELATNS */ + /* We don't have tags, or will send messages with SELATNS. */ clen = ecb->clen + 1; cmd -= 1; - cmd[0] = MSG_IDENTIFY(lun, (tiflags & T_RSELECTOFF) == 0); + cmd[0] = MSG_IDENTIFY(lun, (ti->flags & T_RSELECTOFF) == 0); } if ((sc->sc_features & NCR_F_DMASELECT) && !selatns) { - - /* setup DMA transfer for command */ + /* Setup DMA transfer for command. */ dmasize = clen; sc->sc_cmdlen = clen; sc->sc_cmdp = cmd; - /* Program the SCSI counter */ + /* Program the SCSI counter. */ NCR_SET_COUNT(sc, dmasize); - /* load the count in */ + /* Load the count in. */ /* if (sc->sc_rev != NCR_VARIANT_FAS366) */ - NCRCMD(sc, NCRCMD_NOP|NCRCMD_DMA); + NCRCMD(sc, NCRCMD_NOP | NCRCMD_DMA); - /* And get the targets attention */ + /* And get the target's attention. */ if (selatn3) { sc->sc_msgout = SEND_TAG; sc->sc_flags |= NCR_ATN; @@ -833,13 +844,13 @@ ncr53c9x_select(struct ncr53c9x_softc *s * happy for it to disconnect etc. */ - /* Now get the command into the FIFO */ + /* Now get the command into the FIFO. */ ncr53c9x_wrfifo(sc, cmd, clen); - /* And get the targets attention */ + /* And get the target's attention. */ if (selatns) { NCR_MSGS(("SELATNS \n")); - /* Arbitrate, select and stop after IDENTIFY message */ + /* Arbitrate, select and stop after IDENTIFY message. */ NCRCMD(sc, NCRCMD_SELATNS); } else if (selatn3) { sc->sc_msgout = SEND_TAG; @@ -855,7 +866,6 @@ ncr53c9x_free_ecb(struct ncr53c9x_softc ecb->flags = 0; TAILQ_INSERT_TAIL(&sc->free_list, ecb, free_links); - return; } static struct ncr53c9x_ecb * @@ -870,7 +880,7 @@ ncr53c9x_get_ecb(struct ncr53c9x_softc * TAILQ_REMOVE(&sc->free_list, ecb, free_links); ecb->flags = ECB_ALLOC; bzero(&ecb->ccb, sizeof(struct ncr53c9x_ecb) - - offsetof(struct ncr53c9x_ecb, ccb)); + offsetof(struct ncr53c9x_ecb, ccb)); } return (ecb); } @@ -880,7 +890,7 @@ ncr53c9x_get_ecb(struct ncr53c9x_softc * */ /* - * Start a SCSI-command + * Start a SCSI-command. * This function is called by the higher level SCSI-driver to queue/run * SCSI-commands. */ @@ -888,8 +898,15 @@ ncr53c9x_get_ecb(struct ncr53c9x_softc * void ncr53c9x_action(struct cam_sim *sim, union ccb *ccb) { - struct ncr53c9x_softc *sc; + struct ccb_pathinq *cpi; + struct ccb_scsiio *csio; + struct ccb_trans_settings *cts; + struct ccb_trans_settings_scsi *scsi; + struct ccb_trans_settings_spi *spi; struct ncr53c9x_ecb *ecb; + struct ncr53c9x_softc *sc; + struct ncr53c9x_tinfo *ti; + int target; NCR_TRACE(("[ncr53c9x_action %d]", ccb->ccb_h.func_code)); @@ -903,17 +920,17 @@ ncr53c9x_action(struct cam_sim *sim, uni mtx_unlock(&sc->sc_lock); xpt_done(ccb); return; + case XPT_CALC_GEOMETRY: mtx_unlock(&sc->sc_lock); cam_calc_geometry(&ccb->ccg, sc->sc_extended_geom); xpt_done(ccb); return; - case XPT_PATH_INQ: - { - struct ccb_pathinq *cpi = &ccb->cpi; + case XPT_PATH_INQ: + cpi = &ccb->cpi; cpi->version_num = 1; - cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE; + cpi->hba_inquiry = PI_SDTR_ABLE | PI_TAG_ABLE; cpi->hba_inquiry |= (sc->sc_rev == NCR_VARIANT_FAS366) ? PI_WIDE_16 : 0; cpi->target_sprt = 0; @@ -936,15 +953,12 @@ ncr53c9x_action(struct cam_sim *sim, uni mtx_unlock(&sc->sc_lock); xpt_done(ccb); return; - } + case XPT_GET_TRAN_SETTINGS: - { - struct ccb_trans_settings *cts = &ccb->cts; - struct ncr53c9x_tinfo *ti = &sc->sc_tinfo[ccb->ccb_h.target_id]; - struct ccb_trans_settings_scsi *scsi = - &cts->proto_specific.scsi; - struct ccb_trans_settings_spi *spi = - &cts->xport_specific.spi; + cts = &ccb->cts; + ti = &sc->sc_tinfo[ccb->ccb_h.target_id]; + scsi = &cts->proto_specific.scsi; + spi = &cts->xport_specific.spi; cts->protocol = PROTO_SCSI; cts->protocol_version = SCSI_REV_2; @@ -979,25 +993,24 @@ ncr53c9x_action(struct cam_sim *sim, uni mtx_unlock(&sc->sc_lock); xpt_done(ccb); return; - } + case XPT_ABORT: printf("XPT_ABORT called\n"); ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; mtx_unlock(&sc->sc_lock); xpt_done(ccb); return; + case XPT_TERM_IO: printf("XPT_TERM_IO called\n"); ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; mtx_unlock(&sc->sc_lock); xpt_done(ccb); return; + case XPT_RESET_DEV: printf("XPT_RESET_DEV called\n"); case XPT_SCSI_IO: - { - struct ccb_scsiio *csio; - if (ccb->ccb_h.target_id < 0 || ccb->ccb_h.target_id >= sc->sc_ntarg) { ccb->ccb_h.status = CAM_PATH_INVALID; @@ -1020,7 +1033,7 @@ ncr53c9x_action(struct cam_sim *sim, uni return; } - /* Initialize ecb */ + /* Initialize ecb. */ ecb->ccb = ccb; ecb->timeout = ccb->ccb_h.timeout; @@ -1032,10 +1045,10 @@ ncr53c9x_action(struct cam_sim *sim, uni csio = &ccb->csio; if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0) bcopy(csio->cdb_io.cdb_ptr, &ecb->cmd.cmd, - csio->cdb_len); + csio->cdb_len); else bcopy(csio->cdb_io.cdb_bytes, &ecb->cmd.cmd, - csio->cdb_len); + csio->cdb_len); ecb->clen = csio->cdb_len; ecb->daddr = csio->data_ptr; ecb->dleft = csio->dxfer_len; @@ -1046,19 +1059,14 @@ ncr53c9x_action(struct cam_sim *sim, uni ecb->flags |= ECB_READY; if (sc->sc_state == NCR_IDLE) ncr53c9x_sched(sc); - break; - } case XPT_SET_TRAN_SETTINGS: - { - struct ccb_trans_settings *cts = &ccb->cts; - int target = ccb->ccb_h.target_id; - struct ncr53c9x_tinfo *ti = &sc->sc_tinfo[target]; - struct ccb_trans_settings_scsi *scsi = - &cts->proto_specific.scsi; - struct ccb_trans_settings_spi *spi = - &cts->xport_specific.spi; + cts = &ccb->cts; + target = ccb->ccb_h.target_id; + ti = &sc->sc_tinfo[target]; + scsi = &cts->proto_specific.scsi; + spi = &cts->xport_specific.spi; if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) { if ((sc->sc_cfflags & (1<<((target & 7) + 16))) == 0 && @@ -1103,11 +1111,10 @@ ncr53c9x_action(struct cam_sim *sim, uni ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); return; - } default: device_printf(sc->sc_dev, "Unhandled function code %d\n", - ccb->ccb_h.func_code); + ccb->ccb_h.func_code); ccb->ccb_h.status = CAM_PROVIDE_FAIL; mtx_unlock(&sc->sc_lock); xpt_done(ccb); @@ -1137,7 +1144,7 @@ ncr53c9x_poll(struct cam_sim *sim) */ /* - * Schedule a scsi operation. This has now been pulled out of the interrupt + * Schedule a SCSI operation. This has now been pulled out of the interrupt * handler so that we may call it from ncr53c9x_scsipi_request and * ncr53c9x_done. This may save us an unnecessary interrupt just to get * things going. Should only be called when state == NCR_IDLE and at bio pl. @@ -1146,12 +1153,12 @@ static void ncr53c9x_sched(struct ncr53c9x_softc *sc) { struct ncr53c9x_ecb *ecb; - struct ncr53c9x_tinfo *ti; struct ncr53c9x_linfo *li; - int lun; - int tag; + struct ncr53c9x_tinfo *ti; + int lun, tag; NCR_TRACE(("[ncr53c9x_sched] ")); + if (sc->sc_state != NCR_IDLE) panic("ncr53c9x_sched: not IDLE (state=%d)", sc->sc_state); @@ -1182,7 +1189,7 @@ ncr53c9x_sched(struct ncr53c9x_softc *sc if (li == NULL) { /* Initialize LUN info and add to list. */ if ((li = malloc(sizeof(*li), - M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) { + M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) { continue; } li->lun = lun; @@ -1193,17 +1200,20 @@ ncr53c9x_sched(struct ncr53c9x_softc *sc } li->last_used = time_second; if (tag == 0) { - /* Try to issue this as an un-tagged command */ + /* Try to issue this as an untagged command. */ if (li->untagged == NULL) li->untagged = ecb; } if (li->untagged != NULL) { tag = 0; if ((li->busy != 1) && li->used == 0) { - /* We need to issue this untagged command now */ + /* + * We need to issue this untagged command + * now. + */ ecb = li->untagged; } else { - /* Not ready yet */ + /* not ready, yet */ continue; } } @@ -1227,10 +1237,11 @@ ncr53c9x_sched(struct ncr53c9x_softc *sc sc->sc_nexus = ecb; ncr53c9x_select(sc, ecb); break; - } else + } else { NCR_TRACE(("%d:%d busy\n", ecb->ccb->ccb_h.target_id, ecb->ccb->ccb_h.target_lun)); + } } } @@ -1238,9 +1249,9 @@ static void ncr53c9x_sense(struct ncr53c9x_softc *sc, struct ncr53c9x_ecb *ecb) { union ccb *ccb = ecb->ccb; + struct ncr53c9x_linfo *li; struct ncr53c9x_tinfo *ti; struct scsi_request_sense *ss = (void *)&ecb->cmd.cmd; - struct ncr53c9x_linfo *li; int lun; NCR_TRACE(("requesting sense ")); @@ -1248,7 +1259,7 @@ ncr53c9x_sense(struct ncr53c9x_softc *sc lun = ccb->ccb_h.target_lun; ti = &sc->sc_tinfo[ccb->ccb_h.target_id]; - /* Next, setup a request sense command block */ + /* Next, setup a REQUEST SENSE command block. */ memset(ss, 0, sizeof(*ss)); ss->opcode = REQUEST_SENSE; ss->byte2 = ccb->ccb_h.target_lun << SCSI_CMD_LUN_SHIFT; @@ -1263,7 +1274,7 @@ ncr53c9x_sense(struct ncr53c9x_softc *sc if (li->busy) li->busy = 0; ncr53c9x_dequeue(sc, ecb); - li->untagged = ecb; /* must be executed first to fix C/A */ + li->untagged = ecb; /* Must be executed first to fix C/A. */ li->busy = 2; if (ecb == sc->sc_nexus) { ncr53c9x_select(sc, ecb); @@ -1282,15 +1293,15 @@ static void ncr53c9x_done(struct ncr53c9x_softc *sc, struct ncr53c9x_ecb *ecb) { union ccb *ccb = ecb->ccb; - struct ncr53c9x_tinfo *ti; struct ncr53c9x_linfo *li; + struct ncr53c9x_tinfo *ti; int lun; NCR_TRACE(("[ncr53c9x_done(status:%x)] ", ccb->ccb_h.status)); ti = &sc->sc_tinfo[ccb->ccb_h.target_id]; lun = ccb->ccb_h.target_lun; - li = TINFO_LUN(ti, lun); + li = TINFO_LUN(ti, lun); untimeout(ncr53c9x_timeout, ecb, ccb->ccb_h.timeout_ch); @@ -1312,7 +1323,7 @@ ncr53c9x_done(struct ncr53c9x_softc *sc, if ((ecb->flags & ECB_SENSE) != 0) ccb->ccb_h.status = CAM_AUTOSENSE_FAIL; else { - /* First, save the return values */ + /* First, save the return values. */ ccb->csio.resid = ecb->dleft; ncr53c9x_sense(sc, ecb); return; @@ -1353,7 +1364,7 @@ ncr53c9x_done(struct ncr53c9x_softc *sc, } if (ccb->ccb_h.status == CAM_SEL_TIMEOUT) { - /* Selection timeout -- discard this LUN if empty */ + /* Selection timeout -- discard this LUN if empty. */ if (li->untagged == NULL && li->used == 0) { if (lun < NCR_NLUN) ti->lun[lun] = NULL; @@ -1370,8 +1381,8 @@ ncr53c9x_done(struct ncr53c9x_softc *sc, static void ncr53c9x_dequeue(struct ncr53c9x_softc *sc, struct ncr53c9x_ecb *ecb) { - struct ncr53c9x_tinfo *ti; struct ncr53c9x_linfo *li; + struct ncr53c9x_tinfo *ti; int64_t lun; ti = &sc->sc_tinfo[ecb->ccb->ccb_h.target_id]; @@ -1380,7 +1391,7 @@ ncr53c9x_dequeue(struct ncr53c9x_softc * #ifdef DIAGNOSTIC if (li == NULL || li->lun != lun) panic("ncr53c9x_dequeue: lun %qx for ecb %p does not exist", - (long long) lun, ecb); + (long long)lun, ecb); #endif if (li->untagged == ecb) { li->busy = 0; @@ -1392,8 +1403,7 @@ ncr53c9x_dequeue(struct ncr53c9x_softc * (li->queued[ecb->tag[1]] != ecb)) panic("ncr53c9x_dequeue: slot %d for lun %qx has %p " "instead of ecb %p\n", ecb->tag[1], - (long long) lun, - li->queued[ecb->tag[1]], ecb); + (long long)lun, li->queued[ecb->tag[1]], ecb); #endif li->queued[ecb->tag[1]] = NULL; li->used--; @@ -1411,16 +1421,15 @@ ncr53c9x_dequeue(struct ncr53c9x_softc * /* * Schedule an outgoing message by prioritizing it, and asserting - * attention on the bus. We can only do this when we are the initiator + * attention on the bus. We can only do this when we are the initiator * else there will be an illegal command interrupt. *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From marius at FreeBSD.org Sun Nov 16 06:55:59 2008 From: marius at FreeBSD.org (Marius Strobl) Date: Sun Nov 16 06:56:06 2008 Subject: svn commit: r185001 - in stable/7/sys: . dev/esp dev/le modules/cxgb sparc64/sbus Message-ID: <200811161455.mAGEtxSt056640@svn.freebsd.org> Author: marius Date: Sun Nov 16 14:55:58 2008 New Revision: 185001 URL: http://svn.freebsd.org/changeset/base/185001 Log: MFC: r182876 Adapt the locking of esp(4) to MPSAFE cam(4) (so that ncr53c9x_intr() actually is INTR_MPSAFE now) and fix a couple of bugs which lead to panics, amongst other improvements. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/dev/esp/esp_sbus.c stable/7/sys/dev/esp/ncr53c9x.c stable/7/sys/dev/esp/ncr53c9xreg.h stable/7/sys/dev/esp/ncr53c9xvar.h stable/7/sys/dev/le/if_le_ledma.c stable/7/sys/modules/cxgb/ (props changed) stable/7/sys/sparc64/sbus/dma_sbus.c stable/7/sys/sparc64/sbus/lsi64854.c stable/7/sys/sparc64/sbus/lsi64854var.h Modified: stable/7/sys/dev/esp/esp_sbus.c ============================================================================== --- stable/7/sys/dev/esp/esp_sbus.c Sun Nov 16 14:43:33 2008 (r185000) +++ stable/7/sys/dev/esp/esp_sbus.c Sun Nov 16 14:55:58 2008 (r185001) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2004 Scott Long + * Copyright (c) 2005 Marius Strobl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,8 +72,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include -#include +#include #include #include @@ -83,6 +85,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -97,12 +100,8 @@ struct esp_softc { struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */ struct device *sc_dev; - int sc_rid; struct resource *sc_res; - bus_space_handle_t sc_regh; - bus_space_tag_t sc_regt; - int sc_irqrid; struct resource *sc_irqres; void *sc_irq; @@ -155,8 +154,6 @@ static driver_t esp_sbus_driver = { DRIVER_MODULE(esp, sbus, esp_sbus_driver, esp_devclass, 0, 0); MODULE_DEPEND(esp, sbus, 1, 1, 1); -MODULE_DEPEND(esp, cam, 1, 1, 1); - /* * Functions and the switch for the MI code */ @@ -170,9 +167,11 @@ static int esp_dma_setup(struct ncr53c9x static void esp_dma_go(struct ncr53c9x_softc *sc); static void esp_dma_stop(struct ncr53c9x_softc *sc); static int esp_dma_isactive(struct ncr53c9x_softc *sc); -static int espattach(struct esp_softc *esc, struct ncr53c9x_glue *gluep); +static int espattach(struct esp_softc *esc, + const struct ncr53c9x_glue *gluep); +static int espdetach(struct esp_softc *esc); -static struct ncr53c9x_glue esp_sbus_glue = { +static const struct ncr53c9x_glue esp_sbus_glue = { esp_read_reg, esp_write_reg, esp_dma_isintr, @@ -209,29 +208,16 @@ esp_sbus_attach(device_t dev) struct ncr53c9x_softc *sc; struct lsi64854_softc *lsc; device_t *children; - const char *name; - phandle_t node; - int burst, error, i, nchildren, slot; + int error, i, nchildren; esc = device_get_softc(dev); - bzero(esc, sizeof(struct esp_softc)); sc = &esc->sc_ncr53c9x; lsc = NULL; esc->sc_dev = dev; - name = ofw_bus_get_name(dev); - node = ofw_bus_get_node(dev); - if (OF_getprop(node, "initiator-id", &sc->sc_id, - sizeof(sc->sc_id)) == -1) - sc->sc_id = 7; sc->sc_freq = sbus_get_clockfreq(dev); -#ifdef ESP_SBUS_DEBUG - device_printf(dev, "%s: sc_id %d, freq %d\n", __func__, sc->sc_id, - sc->sc_freq); -#endif - - if (strcmp(name, "SUNW,fas") == 0) { + if (strcmp(ofw_bus_get_name(dev), "SUNW,fas") == 0) { /* * Allocate space for DMA, in SUNW,fas there are no * separate DMA devices. @@ -250,20 +236,18 @@ esp_sbus_attach(device_t dev) */ /* Allocate DMA registers. */ - lsc->sc_rid = 0; + i = 0; if ((lsc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &lsc->sc_rid, RF_ACTIVE)) == NULL) { + &i, RF_ACTIVE)) == NULL) { device_printf(dev, "cannot allocate DMA registers\n"); error = ENXIO; goto fail_sbus_lsc; } - lsc->sc_regt = rman_get_bustag(lsc->sc_res); - lsc->sc_regh = rman_get_bushandle(lsc->sc_res); /* Create a parent DMA tag based on this bus. */ error = bus_dma_tag_create( bus_get_dma_tag(dev), /* parent */ - PAGE_SIZE, 0, /* alignment, boundary */ + 1, 0, /* alignment, boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ @@ -277,38 +261,31 @@ esp_sbus_attach(device_t dev) device_printf(dev, "cannot allocate parent DMA tag\n"); goto fail_sbus_lres; } - burst = sbus_get_burstsz(dev); + + i = sbus_get_burstsz(dev); #ifdef ESP_SBUS_DEBUG - printf("%s: burst 0x%x\n", __func__, burst); + printf("%s: burst 0x%x\n", __func__, i); #endif - lsc->sc_burst = (burst & SBUS_BURST_32) ? 32 : - (burst & SBUS_BURST_16) ? 16 : 0; + lsc->sc_burst = (i & SBUS_BURST_32) ? 32 : + (i & SBUS_BURST_16) ? 16 : 0; lsc->sc_channel = L64854_CHANNEL_SCSI; lsc->sc_client = sc; lsc->sc_dev = dev; - error = lsi64854_attach(lsc); - if (error != 0) { - device_printf(dev, "lsi64854_attach failed\n"); - goto fail_sbus_lpdma; - } - /* * Allocate SCSI core registers. */ - esc->sc_rid = 1; + i = 1; if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &esc->sc_rid, RF_ACTIVE)) == NULL) { + &i, RF_ACTIVE)) == NULL) { device_printf(dev, "cannot allocate SCSI core registers\n"); error = ENXIO; - goto fail_sbus_lsi; + goto fail_sbus_lpdma; } - esc->sc_regt = rman_get_bustag(esc->sc_res); - esc->sc_regh = rman_get_bushandle(esc->sc_res); } else { /* * Search accompanying DMA engine. It should have been @@ -319,10 +296,9 @@ esp_sbus_attach(device_t dev) device_printf(dev, "cannot determine siblings\n"); return (ENXIO); } - slot = sbus_get_slot(dev); for (i = 0; i < nchildren; i++) { if (device_is_attached(children[i]) && - sbus_get_slot(children[i]) == slot && + sbus_get_slot(children[i]) == sbus_get_slot(dev) && strcmp(ofw_bus_get_name(children[i]), "dma") == 0) { /* XXX hackery */ esc->sc_dma = (struct lsi64854_softc *) @@ -340,15 +316,13 @@ esp_sbus_attach(device_t dev) /* * Allocate SCSI core registers. */ - esc->sc_rid = 0; + i = 0; if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &esc->sc_rid, RF_ACTIVE)) == NULL) { + &i, RF_ACTIVE)) == NULL) { device_printf(dev, "cannot allocate SCSI core registers\n"); return (ENXIO); } - esc->sc_regt = rman_get_bustag(esc->sc_res); - esc->sc_regh = rman_get_bushandle(esc->sc_res); } error = espattach(esc, &esp_sbus_glue); @@ -360,15 +334,15 @@ esp_sbus_attach(device_t dev) return (0); fail_sbus_eres: - bus_release_resource(dev, SYS_RES_MEMORY, esc->sc_rid, esc->sc_res); - if (strcmp(name, "SUNW,fas") != 0) + bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res), + esc->sc_res); + if (strcmp(ofw_bus_get_name(dev), "SUNW,fas") != 0) return (error); - fail_sbus_lsi: - lsi64854_detach(lsc); fail_sbus_lpdma: bus_dma_tag_destroy(lsc->sc_parent_dmat); fail_sbus_lres: - bus_release_resource(dev, SYS_RES_MEMORY, lsc->sc_rid, lsc->sc_res); + bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lsc->sc_res), + lsc->sc_res); fail_sbus_lsc: free(lsc, M_DEVBUF); return (error); @@ -378,28 +352,22 @@ static int esp_sbus_detach(device_t dev) { struct esp_softc *esc; - struct ncr53c9x_softc *sc; struct lsi64854_softc *lsc; int error; esc = device_get_softc(dev); - sc = &esc->sc_ncr53c9x; lsc = esc->sc_dma; - bus_teardown_intr(esc->sc_dev, esc->sc_irqres, esc->sc_irq); - error = ncr53c9x_detach(sc); + error = espdetach(esc); if (error != 0) return (error); - bus_release_resource(esc->sc_dev, SYS_RES_IRQ, esc->sc_irqrid, - esc->sc_irqres); - bus_release_resource(dev, SYS_RES_MEMORY, esc->sc_rid, esc->sc_res); + bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res), + esc->sc_res); if (strcmp(ofw_bus_get_name(dev), "SUNW,fas") != 0) return (0); - error = lsi64854_detach(lsc); - if (error != 0) - return (error); bus_dma_tag_destroy(lsc->sc_parent_dmat); - bus_release_resource(dev, SYS_RES_MEMORY, lsc->sc_rid, lsc->sc_res); + bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lsc->sc_res), + lsc->sc_res); free(lsc, M_DEVBUF); return (0); @@ -410,29 +378,18 @@ esp_dma_attach(device_t dev) { struct esp_softc *esc; struct ncr53c9x_softc *sc; - phandle_t node; - int error; + int error, i; esc = device_get_softc(dev); - bzero(esc, sizeof(struct esp_softc)); sc = &esc->sc_ncr53c9x; esc->sc_dev = dev; - node = ofw_bus_get_node(dev); - if (OF_getprop(node, "initiator-id", &sc->sc_id, - sizeof(sc->sc_id)) == -1) - sc->sc_id = 7; - if (OF_getprop(node, "clock-frequency", &sc->sc_freq, - sizeof(sc->sc_freq)) == -1) { + if (OF_getprop(ofw_bus_get_node(dev), "clock-frequency", + &sc->sc_freq, sizeof(sc->sc_freq)) == -1) { printf("failed to query OFW for clock-frequency\n"); return (ENXIO); } -#ifdef ESP_SBUS_DEBUG - device_printf(dev, "%s: sc_id %d, freq %d\n", __func__, sc->sc_id, - sc->sc_freq); -#endif - /* XXX hackery */ esc->sc_dma = (struct lsi64854_softc *) device_get_softc(device_get_parent(dev)); @@ -441,14 +398,12 @@ esp_dma_attach(device_t dev) /* * Allocate SCSI core registers. */ - esc->sc_rid = 0; + i = 0; if ((esc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &esc->sc_rid, RF_ACTIVE)) == NULL) { + &i, RF_ACTIVE)) == NULL) { device_printf(dev, "cannot allocate SCSI core registers\n"); return (ENXIO); } - esc->sc_regt = rman_get_bustag(esc->sc_res); - esc->sc_regh = rman_get_bushandle(esc->sc_res); error = espattach(esc, &esp_sbus_glue); if (error != 0) { @@ -459,7 +414,8 @@ esp_dma_attach(device_t dev) return (0); fail_dma_eres: - bus_release_resource(dev, SYS_RES_MEMORY, esc->sc_rid, esc->sc_res); + bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res), + esc->sc_res); return (error); } @@ -467,19 +423,15 @@ static int esp_dma_detach(device_t dev) { struct esp_softc *esc; - struct ncr53c9x_softc *sc; int error; esc = device_get_softc(dev); - sc = &esc->sc_ncr53c9x; - bus_teardown_intr(esc->sc_dev, esc->sc_irqres, esc->sc_irq); - error = ncr53c9x_detach(sc); + error = espdetach(esc); if (error != 0) return (error); - bus_release_resource(esc->sc_dev, SYS_RES_IRQ, esc->sc_irqrid, - esc->sc_irqres); - bus_release_resource(dev, SYS_RES_MEMORY, esc->sc_rid, esc->sc_res); + bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(esc->sc_res), + esc->sc_res); return (0); } @@ -499,11 +451,29 @@ esp_resume(device_t dev) } static int -espattach(struct esp_softc *esc, struct ncr53c9x_glue *gluep) +espattach(struct esp_softc *esc, const struct ncr53c9x_glue *gluep) { struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x; unsigned int uid = 0; - int error; + int error, i; + + NCR_LOCK_INIT(sc); + + /* Attach the DMA engine. */ + error = lsi64854_attach(esc->sc_dma); + if (error != 0) { + device_printf(esc->sc_dev, "lsi64854_attach failed\n"); + goto fail_lock; + } + + if (OF_getprop(ofw_bus_get_node(esc->sc_dev), "scsi-initiator-id", + &sc->sc_id, sizeof(sc->sc_id)) == -1) + sc->sc_id = 7; + +#ifdef ESP_SBUS_DEBUG + device_printf(esc->sc_dev, "%s: sc_id %d, freq %d\n", + __func__, sc->sc_id, sc->sc_freq); +#endif /* * The `ESC' DMA chip must be reset before we can access @@ -598,7 +568,7 @@ espattach(struct esp_softc *esc, struct */ device_printf(esc->sc_dev, "Unknown chip\n"); - return (ENXIO); + goto fail_lsi; } } } @@ -635,20 +605,20 @@ espattach(struct esp_softc *esc, struct */ switch (sc->sc_rev) { case NCR_VARIANT_ESP100: - sc->sc_maxwidth = 0; + sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; sc->sc_maxxfer = 64 * 1024; sc->sc_minsync = 0; /* No synch on old chip? */ break; case NCR_VARIANT_ESP100A: - sc->sc_maxwidth = 0; + sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; sc->sc_maxxfer = 64 * 1024; /* Min clocks/byte is 5 */ sc->sc_minsync = ncr53c9x_cpb2stp(sc, 5); break; case NCR_VARIANT_ESP200: - sc->sc_maxwidth = 0; + sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; sc->sc_maxxfer = 16 * 1024 * 1024; /* Min clocks/byte is 5 */ sc->sc_minsync = ncr53c9x_cpb2stp(sc, 5); @@ -670,28 +640,26 @@ espattach(struct esp_softc *esc, struct sc->sc_features = NCR_F_FASTSCSI; sc->sc_cfg3 = NCRF9XCFG3_FCLK; sc->sc_cfg3_fscsi = NCRF9XCFG3_FSCSI; - sc->sc_maxwidth = 0; + sc->sc_maxwidth = MSG_EXT_WDTR_BUS_8_BIT; sc->sc_maxxfer = 16 * 1024 * 1024; break; case NCR_VARIANT_FAS366: - sc->sc_maxwidth = 1; + sc->sc_maxwidth = MSG_EXT_WDTR_BUS_16_BIT; sc->sc_maxxfer = 16 * 1024 * 1024; break; } - /* Limit minsync due to unsolved performance issues. */ - sc->sc_maxsync = sc->sc_minsync; - /* Establish interrupt channel. */ - esc->sc_irqrid = 0; + i = 0; if ((esc->sc_irqres = bus_alloc_resource_any(esc->sc_dev, SYS_RES_IRQ, - &esc->sc_irqrid, RF_SHAREABLE|RF_ACTIVE)) == NULL) { + &i, RF_SHAREABLE|RF_ACTIVE)) == NULL) { device_printf(esc->sc_dev, "cannot allocate interrupt\n"); - return (ENXIO); + goto fail_lsi; } if (bus_setup_intr(esc->sc_dev, esc->sc_irqres, - INTR_TYPE_BIO|INTR_MPSAFE, NULL, ncr53c9x_intr, sc, &esc->sc_irq)) { + INTR_MPSAFE | INTR_TYPE_CAM, NULL, ncr53c9x_intr, sc, + &esc->sc_irq)) { device_printf(esc->sc_dev, "cannot set up interrupt\n"); error = ENXIO; goto fail_ires; @@ -714,19 +682,43 @@ espattach(struct esp_softc *esc, struct fail_intr: bus_teardown_intr(esc->sc_dev, esc->sc_irqres, esc->sc_irq); fail_ires: - bus_release_resource(esc->sc_dev, SYS_RES_IRQ, esc->sc_irqrid, - esc->sc_irqres); + bus_release_resource(esc->sc_dev, SYS_RES_IRQ, + rman_get_rid(esc->sc_irqres), esc->sc_irqres); + fail_lsi: + lsi64854_detach(esc->sc_dma); + fail_lock: + NCR_LOCK_DESTROY(sc); return (error); } +static int +espdetach(struct esp_softc *esc) +{ + struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x; + int error; + + bus_teardown_intr(esc->sc_dev, esc->sc_irqres, esc->sc_irq); + error = ncr53c9x_detach(sc); + if (error != 0) + return (error); + error = lsi64854_detach(esc->sc_dma); + if (error != 0) + return (error); + NCR_LOCK_DESTROY(sc); + bus_release_resource(esc->sc_dev, SYS_RES_IRQ, + rman_get_rid(esc->sc_irqres), esc->sc_irqres); + + return (0); +} + /* * Glue functions */ #ifdef ESP_SBUS_DEBUG -int esp_sbus_debug = 0; +static int esp_sbus_debug = 0; -static struct { +static const struct { char *r_name; int r_flag; } esp__read_regnames [] = { @@ -748,7 +740,7 @@ static struct { { "TCX", 1}, /* f/3c */ }; -static struct { +static const struct { char *r_name; int r_flag; } esp__write_regnames[] = { @@ -777,13 +769,15 @@ esp_read_reg(struct ncr53c9x_softc *sc, struct esp_softc *esc = (struct esp_softc *)sc; u_char v; - v = bus_space_read_1(esc->sc_regt, esc->sc_regh, reg * 4); + v = bus_read_1(esc->sc_res, reg * 4); + #ifdef ESP_SBUS_DEBUG if (esp_sbus_debug && (reg < 0x10) && esp__read_regnames[reg].r_flag) - printf("RD:%x <%s> %x\n", reg * 4, - ((unsigned)reg < 0x10) ? esp__read_regnames[reg].r_name : "<***>", v); + printf("RD:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ? + esp__read_regnames[reg].r_name : "<***>", v); #endif - return v; + + return (v); } static void @@ -793,10 +787,11 @@ esp_write_reg(struct ncr53c9x_softc *sc, #ifdef ESP_SBUS_DEBUG if (esp_sbus_debug && (reg < 0x10) && esp__write_regnames[reg].r_flag) - printf("WR:%x <%s> %x\n", reg * 4, - ((unsigned)reg < 0x10) ? esp__write_regnames[reg].r_name : "<***>", v); + printf("WR:%x <%s> %x\n", reg * 4, ((unsigned)reg < 0x10) ? + esp__write_regnames[reg].r_name : "<***>", v); #endif - bus_space_write_1(esc->sc_regt, esc->sc_regh, reg * 4, v); + + bus_write_1(esc->sc_res, reg * 4, v); } static int Modified: stable/7/sys/dev/esp/ncr53c9x.c ============================================================================== --- stable/7/sys/dev/esp/ncr53c9x.c Sun Nov 16 14:43:33 2008 (r185000) +++ stable/7/sys/dev/esp/ncr53c9x.c Sun Nov 16 14:55:58 2008 (r185001) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2004 Scott Long + * Copyright (c) 2005, 2008 Marius Strobl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,7 +26,7 @@ * */ -/* $NetBSD: ncr53c9x.c,v 1.114 2005/02/27 00:27:02 perry Exp $ */ +/* $NetBSD: ncr53c9x.c,v 1.125 2007/01/09 12:53:12 itohy Exp $ */ /*- * Copyright (c) 1998, 2002 The NetBSD Foundation, Inc. @@ -111,8 +112,8 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include #include #include #include @@ -129,14 +130,22 @@ __FBSDID("$FreeBSD$"); #include #include -int ncr53c9x_debug = +MODULE_DEPEND(esp, cam, 1, 1, 1); + +#ifdef NCR53C9X_DEBUG +static int ncr53c9x_debug = NCR_SHOWMISC /* | NCR_SHOWPHASE | NCR_SHOWTRAC | NCR_SHOWCMDS */; -#ifdef DEBUG -int ncr53c9x_notag = 0; #endif static void ncr53c9x_abort(struct ncr53c9x_softc *sc, struct ncr53c9x_ecb *ecb); +static void ncr53c9x_action(struct cam_sim *sim, union ccb *ccb); +static void ncr53c9x_async(void *cbarg, uint32_t code, + struct cam_path *path, void *arg); +static void ncr53c9x_callout(void *arg); +static void ncr53c9x_clear(struct ncr53c9x_softc *sc, cam_status result); +static void ncr53c9x_clear_target(struct ncr53c9x_softc *sc, int target, + cam_status result); static void ncr53c9x_dequeue(struct ncr53c9x_softc *sc, struct ncr53c9x_ecb *ecb); static void ncr53c9x_done(struct ncr53c9x_softc *sc, @@ -145,17 +154,18 @@ static void ncr53c9x_free_ecb(struct ncr struct ncr53c9x_ecb *ecb); static void ncr53c9x_msgin(struct ncr53c9x_softc *sc); static void ncr53c9x_msgout(struct ncr53c9x_softc *sc); +static void ncr53c9x_init(struct ncr53c9x_softc *sc, int doreset); +static void ncr53c9x_intr1(struct ncr53c9x_softc *sc); static void ncr53c9x_poll(struct cam_sim *sim); static int ncr53c9x_rdfifo(struct ncr53c9x_softc *sc, int how); static int ncr53c9x_reselect(struct ncr53c9x_softc *sc, int message, int tagtype, int tagid); +static void ncr53c9x_reset(struct ncr53c9x_softc *sc); static void ncr53c9x_sense(struct ncr53c9x_softc *sc, struct ncr53c9x_ecb *ecb); -static void ncr53c9x_scsi_reset(struct ncr53c9x_softc *sc); static void ncr53c9x_sched(struct ncr53c9x_softc *sc); static void ncr53c9x_select(struct ncr53c9x_softc *sc, struct ncr53c9x_ecb *ecb); -static void ncr53c9x_timeout(void *arg); static void ncr53c9x_watch(void *arg); static void ncr53c9x_wrfifo(struct ncr53c9x_softc *sc, u_char *p, int len); @@ -238,7 +248,12 @@ ncr53c9x_attach(struct ncr53c9x_softc *s struct ncr53c9x_ecb *ecb; int error, i; - mtx_init(&sc->sc_lock, "ncr", "ncr53c9x lock", MTX_DEF); + if (NCR_LOCK_INITIALIZED(sc) == 0) { + device_printf(sc->sc_dev, "mutex not initialized\n"); + return (ENXIO); + } + + callout_init_mtx(&sc->sc_watchdog, &sc->sc_lock, 0); /* * Note, the front-end has set us up to print the chip variation. @@ -292,8 +307,6 @@ ncr53c9x_attach(struct ncr53c9x_softc *s goto fail_imess; } - callout_init(&sc->sc_watchdog, 0); - /* * Treat NCR53C90 with the 86C01 DMA chip exactly as ESP100 * from now on. @@ -334,16 +347,19 @@ ncr53c9x_attach(struct ncr53c9x_softc *s } sim = cam_sim_alloc(ncr53c9x_action, ncr53c9x_poll, "esp", sc, - device_get_unit(sc->sc_dev), &Giant, 1, NCR_TAG_DEPTH, devq); + device_get_unit(sc->sc_dev), &sc->sc_lock, 1, NCR_TAG_DEPTH, devq); if (sim == NULL) { device_printf(sc->sc_dev, "cannot allocate SIM entry\n"); error = ENOMEM; goto fail_devq; } + + NCR_LOCK(sc); + if (xpt_bus_register(sim, sc->sc_dev, 0) != CAM_SUCCESS) { device_printf(sc->sc_dev, "cannot register bus\n"); error = EIO; - goto fail_sim; + goto fail_lock; } if (xpt_create_path(&path, NULL, cam_sim_path(sim), @@ -353,6 +369,13 @@ ncr53c9x_attach(struct ncr53c9x_softc *s goto fail_bus; } + if (xpt_register_async(AC_LOST_DEVICE, ncr53c9x_async, sim, path) != + CAM_REQ_CMP) { + device_printf(sc->sc_dev, "cannot register async handler\n"); + error = EIO; + goto fail_path; + } + sc->sc_sim = sim; sc->sc_path = path; @@ -371,7 +394,7 @@ ncr53c9x_attach(struct ncr53c9x_softc *s M_NOWAIT | M_ZERO)) == NULL) { device_printf(sc->sc_dev, "cannot allocate ECB array\n"); error = ENOMEM; - goto fail_path; + goto fail_async; } for (i = 0; i < NCR_TAG_DEPTH; i++) { ecb = &sc->ecb_array[i]; @@ -380,15 +403,20 @@ ncr53c9x_attach(struct ncr53c9x_softc *s TAILQ_INSERT_HEAD(&sc->free_list, ecb, free_links); } - callout_reset(&sc->sc_watchdog, 60*hz, ncr53c9x_watch, sc); + callout_reset(&sc->sc_watchdog, 60 * hz, ncr53c9x_watch, sc); + + NCR_UNLOCK(sc); return (0); +fail_async: + xpt_register_async(0, ncr53c9x_async, sim, path); fail_path: xpt_free_path(path); fail_bus: xpt_bus_deregister(cam_sim_path(sim)); -fail_sim: +fail_lock: + NCR_UNLOCK(sc); cam_sim_free(sim, TRUE); fail_devq: cam_simq_free(devq); @@ -406,13 +434,33 @@ fail_omess: int ncr53c9x_detach(struct ncr53c9x_softc *sc) { + struct ncr53c9x_linfo *li, *nextli; + int t; callout_drain(&sc->sc_watchdog); - mtx_lock(&sc->sc_lock); - ncr53c9x_init(sc, 1); - mtx_unlock(&sc->sc_lock); + + NCR_LOCK(sc); + + if (sc->sc_tinfo) { + /* Cancel all commands. */ + ncr53c9x_clear(sc, CAM_REQ_ABORTED); + + /* Free logical units. */ + for (t = 0; t < sc->sc_ntarg; t++) { + for (li = LIST_FIRST(&sc->sc_tinfo[t].luns); li; + li = nextli) { + nextli = LIST_NEXT(li, link); + free(li, M_DEVBUF); + } + } + } + + xpt_register_async(0, ncr53c9x_async, sc->sc_sim, sc->sc_path); xpt_free_path(sc->sc_path); xpt_bus_deregister(cam_sim_path(sc->sc_sim)); + + NCR_UNLOCK(sc); + cam_sim_free(sc->sc_sim, TRUE); free(sc->ecb_array, M_DEVBUF); free(sc->sc_tinfo, M_DEVBUF); @@ -420,7 +468,6 @@ ncr53c9x_detach(struct ncr53c9x_softc *s free(sc->sc_imess, M_DEVBUF); if (sc->sc_omess_self) free(sc->sc_omess, M_DEVBUF); - mtx_destroy(&sc->sc_lock); return (0); } @@ -433,10 +480,12 @@ ncr53c9x_detach(struct ncr53c9x_softc *s * After reset, registers are loaded with the defaults from the attach * routine above. */ -void +static void ncr53c9x_reset(struct ncr53c9x_softc *sc) { + NCR_LOCK_ASSERT(sc, MA_OWNED); + /* Reset DMA first. */ NCRDMA_RESET(sc); @@ -477,9 +526,11 @@ ncr53c9x_reset(struct ncr53c9x_softc *sc sc->sc_features |= NCR_F_HASCFG3 | NCR_F_FASTSCSI | NCR_F_SELATN3; sc->sc_cfg3 = NCRFASCFG3_FASTCLK | NCRFASCFG3_OBAUTO; + if (sc->sc_id > 7) + sc->sc_cfg3 |= NCRFASCFG3_IDBIT3; sc->sc_cfg3_fscsi = NCRFASCFG3_FASTSCSI; NCR_WRITE_REG(sc, NCR_CFG3, sc->sc_cfg3); - sc->sc_cfg2 = 0; /* NCRCFG2_HMEFE | NCRCFG2_HME32 */ + sc->sc_cfg2 = NCRCFG2_HMEFE | NCRCFG2_HME32; NCR_WRITE_REG(sc, NCR_CFG2, sc->sc_cfg2); NCR_WRITE_REG(sc, NCR_CFG1, sc->sc_cfg1); NCR_WRITE_REG(sc, NCR_CCF, sc->sc_ccf); @@ -509,29 +560,73 @@ ncr53c9x_reset(struct ncr53c9x_softc *sc } /* - * Reset the SCSI bus, but not the chip. + * Clear all commands. */ static void -ncr53c9x_scsi_reset(struct ncr53c9x_softc *sc) +ncr53c9x_clear(struct ncr53c9x_softc *sc, cam_status result) { + struct ncr53c9x_ecb *ecb; + int r; - (*sc->sc_glue->gl_dma_stop)(sc); + NCR_LOCK_ASSERT(sc, MA_OWNED); - NCR_MISC(("%s: resetting SCSI bus\n", device_get_nameunit(sc->sc_dev))); - NCRCMD(sc, NCRCMD_RSTSCSI); - DELAY(250000); /* Give the bus a fighting chance to settle */ + /* Cancel any active commands. */ + sc->sc_state = NCR_CLEANING; + sc->sc_msgify = 0; + if ((ecb = sc->sc_nexus) != NULL) { + ecb->ccb->ccb_h.status = result; + ncr53c9x_done(sc, ecb); + } + /* Cancel outstanding disconnected commands. */ + for (r = 0; r < sc->sc_ntarg; r++) + ncr53c9x_clear_target(sc, r, result); } /* - * Initialize ncr53c9x state machine. + * Clear all commands for a specific target. */ -void -ncr53c9x_init(struct ncr53c9x_softc *sc, int doreset) +static void +ncr53c9x_clear_target(struct ncr53c9x_softc *sc, int target, + cam_status result) { struct ncr53c9x_ecb *ecb; struct ncr53c9x_linfo *li; + int i; + + NCR_LOCK_ASSERT(sc, MA_OWNED); + + /* Cancel outstanding disconnected commands on each LUN. */ + LIST_FOREACH(li, &sc->sc_tinfo[target].luns, link) { + if ((ecb = li->untagged) != NULL) { + li->untagged = NULL; + /* + * XXX should we terminate a command + * that never reached the disk? + */ + li->busy = 0; + ecb->ccb->ccb_h.status = result; + ncr53c9x_done(sc, ecb); + } + for (i = 0; i < NCR_TAG_DEPTH; i++) + if ((ecb = li->queued[i])) { + li->queued[i] = NULL; + ecb->ccb->ccb_h.status = result; + ncr53c9x_done(sc, ecb); + } + li->used = 0; + } +} + +/* + * Initialize ncr53c9x state machine. + */ +static void +ncr53c9x_init(struct ncr53c9x_softc *sc, int doreset) +{ struct ncr53c9x_tinfo *ti; - int i, r; + int r; + + NCR_LOCK_ASSERT(sc, MA_OWNED); NCR_MISC(("[NCR_INIT(%d) %d] ", doreset, sc->sc_state)); @@ -544,41 +639,8 @@ ncr53c9x_init(struct ncr53c9x_softc *sc, for (r = 0; r < sc->sc_ntarg; r++) { LIST_INIT(&sc->sc_tinfo[r].luns); } - } else { - /* Cancel any active commands. */ - sc->sc_state = NCR_CLEANING; - sc->sc_msgify = 0; - if ((ecb = sc->sc_nexus) != NULL) { - ecb->ccb->ccb_h.status = CAM_CMD_TIMEOUT; - ncr53c9x_done(sc, ecb); - } - /* Cancel outstanding disconnected commands on each LUN. */ - for (r = 0; r < sc->sc_ntarg; r++) { - LIST_FOREACH(li, &sc->sc_tinfo[r].luns, link) { - if ((ecb = li->untagged) != NULL) { - li->untagged = NULL; - /* - * XXX - * - * Should we terminate a command - * that never reached the disk? - */ - li->busy = 0; - ecb->ccb->ccb_h.status = - CAM_CMD_TIMEOUT; - ncr53c9x_done(sc, ecb); - } - for (i = 0; i < 256; i++) - if ((ecb = li->queued[i])) { - li->queued[i] = NULL; - ecb->ccb->ccb_h.status = - CAM_CMD_TIMEOUT; - ncr53c9x_done(sc, ecb); - } - li->used = 0; - } - } - } + } else + ncr53c9x_clear(sc, CAM_CMD_TIMEOUT); /* * Reset the chip to a known state. @@ -589,27 +651,42 @@ ncr53c9x_init(struct ncr53c9x_softc *sc, sc->sc_msgpriq = sc->sc_msgout = sc->sc_msgoutq = 0; sc->sc_phase = sc->sc_prevphase = INVALID_PHASE; - for (r = 0; r < sc->sc_ntarg; r++) { - ti = &sc->sc_tinfo[r]; + /* + * If we're the first time through, set the default parameters + * for all targets. Otherwise we only clear their current transfer + * settings so we'll renegotiate their goal settings with the next + * command. + */ + if (sc->sc_state == 0) { + for (r = 0; r < sc->sc_ntarg; r++) { + ti = &sc->sc_tinfo[r]; /* XXX - config flags per target: low bits: no reselect; high bits: no synch */ - ti->flags = ((sc->sc_minsync != 0 && - (sc->sc_cfflags & (1 << ((r & 7) + 8))) == 0) ? - 0 : T_SYNCHOFF) | - ((sc->sc_cfflags & (1 << (r & 7))) == 0 ? - 0 : T_RSELECTOFF); -#ifdef DEBUG - if (ncr53c9x_notag) - ti->flags &= ~T_TAG; -#endif - ti->period = sc->sc_minsync; - ti->offset = 0; - ti->cfg3 = 0; + ti->flags = ((sc->sc_minsync != 0 && + (sc->sc_cfflags & (1 << ((r & 7) + 8))) == 0) ? + 0 : T_SYNCHOFF) | + ((sc->sc_cfflags & (1 << (r & 7))) == 0 ? + 0 : T_RSELECTOFF); + ti->curr.period = ti->goal.period = 0; + ti->curr.offset = ti->goal.offset = 0; + ti->curr.width = ti->goal.width = + MSG_EXT_WDTR_BUS_8_BIT; + } + } else { + for (r = 0; r < sc->sc_ntarg; r++) { + ti = &sc->sc_tinfo[r]; + ti->flags &= ~(T_SDTRSENT | T_WDTRSENT); + ti->curr.period = 0; + ti->curr.offset = 0; + ti->curr.width = MSG_EXT_WDTR_BUS_8_BIT; + } } if (doreset) { sc->sc_state = NCR_SBR; NCRCMD(sc, NCRCMD_RSTSCSI); + /* Give the bus a fighting chance to settle. */ + DELAY(250000); } else { sc->sc_state = NCR_IDLE; ncr53c9x_sched(sc); @@ -629,6 +706,8 @@ static inline void ncr53c9x_readregs(struct ncr53c9x_softc *sc) { + NCR_LOCK_ASSERT(sc, MA_OWNED); + sc->sc_espstat = NCR_READ_REG(sc, NCR_STAT); /* Only the step bits are of interest. */ sc->sc_espstep = NCR_READ_REG(sc, NCR_STEP) & NCRSTEP_MASK; @@ -659,6 +738,9 @@ static inline int ncr53c9x_stp2cpb(struct ncr53c9x_softc *sc, int period) { int v; + + NCR_LOCK_ASSERT(sc, MA_OWNED); + v = (sc->sc_freq * period) / 250; if (ncr53c9x_cpb2stp(sc, v) < period) /* Correct round-down error. */ @@ -669,18 +751,20 @@ ncr53c9x_stp2cpb(struct ncr53c9x_softc * static inline void ncr53c9x_setsync(struct ncr53c9x_softc *sc, struct ncr53c9x_tinfo *ti) { - u_char syncoff, synctp; - u_char cfg3 = sc->sc_cfg3 | ti->cfg3; + u_char cfg3, syncoff, synctp; - if (ti->flags & T_SYNCMODE) { - syncoff = ti->offset; - synctp = ncr53c9x_stp2cpb(sc, ti->period); + NCR_LOCK_ASSERT(sc, MA_OWNED); + + cfg3 = sc->sc_cfg3; + if (ti->curr.offset != 0) { + syncoff = ti->curr.offset; + synctp = ncr53c9x_stp2cpb(sc, ti->curr.period); if (sc->sc_features & NCR_F_FASTSCSI) { /* * If the period is 200ns or less (ti->period <= 50), * put the chip in Fast SCSI mode. */ - if (ti->period <= 50) + if (ti->curr.period <= 50) /* * There are (at least) 4 variations of the * configuration 3 register. The drive attach @@ -703,6 +787,11 @@ ncr53c9x_setsync(struct ncr53c9x_softc * synctp = 0; } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From kib at FreeBSD.org Mon Nov 17 10:45:08 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Nov 17 10:45:20 2008 Subject: svn commit: r185025 - in stable/7: include lib/libc lib/libc/string Message-ID: <200811171845.mAHIj7Wr089992@svn.freebsd.org> Author: kib Date: Mon Nov 17 18:45:07 2008 New Revision: 185025 URL: http://svn.freebsd.org/changeset/base/185025 Log: MFC r184587: Add the ffsll and flsll functions. These are ffs and fls operating on long long arguments. Approved by: re (kensmith) Added: stable/7/lib/libc/string/ffsll.c - copied unchanged from r184587, head/lib/libc/string/ffsll.c stable/7/lib/libc/string/flsll.c - copied unchanged from r184587, head/lib/libc/string/flsll.c Modified: stable/7/include/ (props changed) stable/7/include/strings.h stable/7/lib/libc/ (props changed) stable/7/lib/libc/string/Makefile.inc stable/7/lib/libc/string/Symbol.map stable/7/lib/libc/string/ffs.3 Modified: stable/7/include/strings.h ============================================================================== --- stable/7/include/strings.h Mon Nov 17 16:37:04 2008 (r185024) +++ stable/7/include/strings.h Mon Nov 17 18:45:07 2008 (r185025) @@ -44,8 +44,10 @@ void bzero(void *, size_t); /* LEGA int ffs(int) __pure2; #ifdef __BSD_VISIBLE int ffsl(long) __pure2; +int ffsll(long long) __pure2; int fls(int) __pure2; int flsl(long) __pure2; +int flsll(long long) __pure2; #endif char *index(const char *, int) __pure; /* LEGACY */ char *rindex(const char *, int) __pure; /* LEGACY */ Modified: stable/7/lib/libc/string/Makefile.inc ============================================================================== --- stable/7/lib/libc/string/Makefile.inc Mon Nov 17 16:37:04 2008 (r185024) +++ stable/7/lib/libc/string/Makefile.inc Mon Nov 17 18:45:07 2008 (r185025) @@ -6,8 +6,8 @@ CFLAGS+= -I${.CURDIR}/locale # machine-independent string sources -MISRCS+=bcmp.c bcopy.c bzero.c ffs.c ffsl.c fls.c flsl.c index.c memccpy.c \ - memchr.c memrchr.c memcmp.c \ +MISRCS+=bcmp.c bcopy.c bzero.c ffs.c ffsl.c ffsll.c fls.c flsl.c flsll.c \ + index.c memccpy.c memchr.c memrchr.c memcmp.c \ memcpy.c memmem.c memmove.c memset.c rindex.c stpcpy.c strcasecmp.c \ strcat.c strchr.c strcmp.c strcoll.c strcpy.c strcspn.c strdup.c \ strerror.c strlcat.c strlcpy.c strlen.c strmode.c strncat.c strncmp.c \ @@ -38,6 +38,8 @@ MAN+= bcmp.3 bcopy.3 bstring.3 bzero.3 f MLINKS+=ffs.3 ffsl.3 MLINKS+=ffs.3 fls.3 MLINKS+=ffs.3 flsl.3 +MLINKS+=ffs.3 ffsll.3 +MLINKS+=ffs.3 flsll.3 MLINKS+=index.3 rindex.3 MLINKS+=memchr.3 memrchr.3 MLINKS+=strcasecmp.3 strncasecmp.3 Modified: stable/7/lib/libc/string/Symbol.map ============================================================================== --- stable/7/lib/libc/string/Symbol.map Mon Nov 17 16:37:04 2008 (r185024) +++ stable/7/lib/libc/string/Symbol.map Mon Nov 17 18:45:07 2008 (r185025) @@ -78,6 +78,8 @@ FBSD_1.0 { }; FBSD_1.1 { + ffsll; + flsll; memrchr; }; Modified: stable/7/lib/libc/string/ffs.3 ============================================================================== --- stable/7/lib/libc/string/ffs.3 Mon Nov 17 16:37:04 2008 (r185024) +++ stable/7/lib/libc/string/ffs.3 Mon Nov 17 18:45:07 2008 (r185025) @@ -30,14 +30,16 @@ .\" @(#)ffs.3 8.2 (Berkeley) 4/19/94 .\" $FreeBSD$ .\" -.Dd October 12, 2006 +.Dd October 26, 2008 .Dt FFS 3 .Os .Sh NAME .Nm ffs , .Nm ffsl , +.Nm ffsll , .Nm fls , -.Nm flsl +.Nm flsl , +.Nm flsll .Nd find first or last bit set in a bit string .Sh LIBRARY .Lb libc @@ -48,14 +50,19 @@ .Ft int .Fn ffsl "long value" .Ft int +.Ft int +.Fn ffsll "long long value" .Fn fls "int value" .Ft int .Fn flsl "long value" +.Ft int +.Fn flsll "long long value" .Sh DESCRIPTION The -.Fn ffs -and +.Fn ffs , .Fn ffsl +and +.Fn ffsll functions find the first bit set (beginning with the least significant bit) in @@ -63,9 +70,10 @@ in and return the index of that bit. .Pp The -.Fn fls -and +.Fn fls , .Fn flsl +and +.Fn flsll functions find the last bit set in .Fa value and return the index of that bit. @@ -95,3 +103,9 @@ and .Fn flsl functions appeared in .Fx 5.3 . +The +.Fn ffsll +and +.Fn flsll +functions appeared in +.Fx 8.0 . Copied: stable/7/lib/libc/string/ffsll.c (from r184587, head/lib/libc/string/ffsll.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/lib/libc/string/ffsll.c Mon Nov 17 18:45:07 2008 (r185025, copy of r184587, head/lib/libc/string/ffsll.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +/* + * Find First Set bit + */ +int +ffsll(long long mask) +{ + int bit; + + if (mask == 0) + return (0); + for (bit = 1; !(mask & 1); bit++) + mask = (unsigned long long)mask >> 1; + return (bit); +} Copied: stable/7/lib/libc/string/flsll.c (from r184587, head/lib/libc/string/flsll.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/lib/libc/string/flsll.c Mon Nov 17 18:45:07 2008 (r185025, copy of r184587, head/lib/libc/string/flsll.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +/* + * Find Last Set bit + */ +int +flsll(long long mask) +{ + int bit; + + if (mask == 0) + return (0); + for (bit = 1; mask != 1; bit++) + mask = (unsigned long long)mask >> 1; + return (bit); +} From ambrisko at FreeBSD.org Mon Nov 17 15:07:20 2008 From: ambrisko at FreeBSD.org (Doug Ambrisko) Date: Mon Nov 17 15:07:32 2008 Subject: svn commit: r185034 - in stable/7/sys: . dev/mfi Message-ID: <200811172307.mAHN7J1p060623@svn.freebsd.org> Author: ambrisko Date: Mon Nov 17 23:07:18 2008 New Revision: 185034 URL: http://svn.freebsd.org/changeset/base/185034 Log: MFC 182085, 184897, 184933, 184974, 184975 This addresses: 1) New HW support from LSI (they want to get the HW support into a FreeBSD release before the HW comes out!). 2) Bug fix in the ioctl path with zero length command. 3) Adds functional support so that SCSI sense will work when requested from user-land. This is a little strange, since they store a user-land pointer in the "data" space of the ioctl packet. So copy the data out into another structure that is a union of the data and pointer (mfi_sense_ptr union). This way we can cleanly use the pointer, as pointer on both 64bit and 32bit machines (i386/amd64). Submitted by: LSI Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/dev/mfi/mfi.c stable/7/sys/dev/mfi/mfi_ioctl.h stable/7/sys/dev/mfi/mfi_pci.c stable/7/sys/dev/mfi/mfireg.h stable/7/sys/dev/mfi/mfivar.h Modified: stable/7/sys/dev/mfi/mfi.c ============================================================================== --- stable/7/sys/dev/mfi/mfi.c Mon Nov 17 22:46:29 2008 (r185033) +++ stable/7/sys/dev/mfi/mfi.c Mon Nov 17 23:07:18 2008 (r185034) @@ -163,7 +163,11 @@ static void mfi_enable_intr_ppc(struct mfi_softc *sc) { MFI_WRITE4(sc, MFI_ODCR0, 0xFFFFFFFF); - MFI_WRITE4(sc, MFI_OMSK, ~MFI_1078_EIM); + if (sc->mfi_flags & MFI_FLAGS_1078) { + MFI_WRITE4(sc, MFI_OMSK, ~MFI_1078_EIM); + } else if (sc->mfi_flags & MFI_FLAGS_GEN2) { + MFI_WRITE4(sc, MFI_OMSK, ~MFI_GEN2_EIM); + } } static int32_t @@ -171,14 +175,14 @@ mfi_read_fw_status_xscale(struct mfi_sof { return MFI_READ4(sc, MFI_OMSG0); } - + static int32_t mfi_read_fw_status_ppc(struct mfi_softc *sc) { return MFI_READ4(sc, MFI_OSP0); } -static int +static int mfi_check_clear_intr_xscale(struct mfi_softc *sc) { int32_t status; @@ -189,28 +193,35 @@ mfi_check_clear_intr_xscale(struct mfi_s MFI_WRITE4(sc, MFI_OSTS, status); return 0; - } +} -static int +static int mfi_check_clear_intr_ppc(struct mfi_softc *sc) { int32_t status; status = MFI_READ4(sc, MFI_OSTS); - if (!status) - return 1; + if (sc->mfi_flags & MFI_FLAGS_1078) { + if (!(status & MFI_1078_RM)) { + return 1; + } + } else if (sc->mfi_flags & MFI_FLAGS_GEN2) { + if (!(status & MFI_GEN2_RM)) { + return 1; + } + } MFI_WRITE4(sc, MFI_ODCR0, status); return 0; - } +} -static void +static void mfi_issue_cmd_xscale(struct mfi_softc *sc,uint32_t bus_add,uint32_t frame_cnt) { MFI_WRITE4(sc, MFI_IQP,(bus_add >>3)|frame_cnt); } - -static void + +static void mfi_issue_cmd_ppc(struct mfi_softc *sc,uint32_t bus_add,uint32_t frame_cnt) { MFI_WRITE4(sc, MFI_IQP, (bus_add |frame_cnt <<1)|1 ); @@ -1399,6 +1410,8 @@ mfi_bio_complete(struct mfi_command *cm) device_printf(sc->mfi_dev, "I/O error, status= %d " "scsi_status= %d\n", hdr->cmd_status, hdr->scsi_status); mfi_print_sense(cm->cm_sc, cm->cm_sense); + } else if (cm->cm_error != 0) { + bio->bio_flags |= BIO_ERROR; } mfi_release_command(cm); @@ -1815,6 +1828,9 @@ mfi_check_command_post(struct mfi_softc case MFI_DCMD_CFG_ADD: mfi_ldprobe(sc); break; + case MFI_DCMD_CFG_FOREIGN_IMPORT: + mfi_ldprobe(sc); + break; } } @@ -1904,7 +1920,7 @@ mfi_ioctl(struct cdev *dev, u_long cmd, struct mfi_ioc_aen *aen; struct mfi_command *cm = NULL; uint32_t context; - uint8_t *sense_ptr; + union mfi_sense_ptr sense_ptr; uint8_t *data = NULL, *temp; int i; struct mfi_ioc_passthru *iop = (struct mfi_ioc_passthru *)arg; @@ -1986,8 +2002,9 @@ mfi_ioctl(struct cdev *dev, u_long cmd, context = cm->cm_frame->header.context; bcopy(ioc->mfi_frame.raw, cm->cm_frame, - 2 * MFI_DCMD_FRAME_SIZE); /* this isn't quite right */ - cm->cm_total_frame_size = (sizeof(union mfi_sgl) * ioc->mfi_sge_count) + ioc->mfi_sgl_off; + 2 * MFI_DCMD_FRAME_SIZE); /* this isn't quite right */ + cm->cm_total_frame_size = (sizeof(union mfi_sgl) + * ioc->mfi_sge_count) + ioc->mfi_sgl_off; if (ioc->mfi_sge_count) { cm->cm_sg = (union mfi_sgl *)&cm->cm_frame->bytes[ioc->mfi_sgl_off]; @@ -2001,7 +2018,8 @@ mfi_ioctl(struct cdev *dev, u_long cmd, if (cm->cm_flags == 0) cm->cm_flags |= MFI_CMD_DATAIN | MFI_CMD_DATAOUT; cm->cm_len = cm->cm_frame->header.data_len; - if (cm->cm_flags & (MFI_CMD_DATAIN | MFI_CMD_DATAOUT)) { + if (cm->cm_len && + (cm->cm_flags & (MFI_CMD_DATAIN | MFI_CMD_DATAOUT))) { cm->cm_data = data = malloc(cm->cm_len, M_MFIBUF, M_WAITOK | M_ZERO); if (cm->cm_data == NULL) { @@ -2051,6 +2069,11 @@ mfi_ioctl(struct cdev *dev, u_long cmd, if (cm->cm_frame->header.cmd == MFI_CMD_DCMD) locked = mfi_config_lock(sc, cm->cm_frame->dcmd.opcode); + if (cm->cm_frame->header.cmd == MFI_CMD_PD_SCSI_IO) { + cm->cm_frame->pass.sense_addr_lo = cm->cm_sense_busaddr; + cm->cm_frame->pass.sense_addr_hi = 0; + } + mtx_lock(&sc->mfi_io_lock); error = mfi_check_command_pre(sc, cm); if (error) { @@ -2102,10 +2125,20 @@ mfi_ioctl(struct cdev *dev, u_long cmd, } if (ioc->mfi_sense_len) { - /* copy out sense */ - sense_ptr = &((struct mfi_ioc_packet*)arg) - ->mfi_frame.raw[0]; - error = copyout(cm->cm_sense, sense_ptr, + /* get user-space sense ptr then copy out sense */ + bcopy(&((struct mfi_ioc_packet*)arg) + ->mfi_frame.raw[ioc->mfi_sense_off], + &sense_ptr.sense_ptr_data[0], + sizeof(sense_ptr.sense_ptr_data)); +#ifdef __amd64__ + if (cmd != MFI_CMD) { + /* + * not 64bit native so zero out any address + * over 32bit */ + sense_ptr.addr.high = 0; + } +#endif + error = copyout(cm->cm_sense, sense_ptr.user_space, ioc->mfi_sense_len); if (error != 0) { device_printf(sc->mfi_dev, @@ -2207,7 +2240,7 @@ mfi_linux_ioctl_int(struct cdev *dev, u_ struct mfi_linux_ioc_aen l_aen; struct mfi_command *cm = NULL; struct mfi_aen *mfi_aen_entry; - uint8_t *sense_ptr; + union mfi_sense_ptr sense_ptr; uint32_t context; uint8_t *data = NULL, *temp; int i; @@ -2241,7 +2274,8 @@ mfi_linux_ioctl_int(struct cdev *dev, u_ bcopy(l_ioc.lioc_frame.raw, cm->cm_frame, 2 * MFI_DCMD_FRAME_SIZE); /* this isn't quite right */ - cm->cm_total_frame_size = (sizeof(union mfi_sgl) * l_ioc.lioc_sge_count) + l_ioc.lioc_sgl_off; + cm->cm_total_frame_size = (sizeof(union mfi_sgl) + * l_ioc.lioc_sge_count) + l_ioc.lioc_sgl_off; if (l_ioc.lioc_sge_count) cm->cm_sg = (union mfi_sgl *)&cm->cm_frame->bytes[l_ioc.lioc_sgl_off]; @@ -2251,7 +2285,8 @@ mfi_linux_ioctl_int(struct cdev *dev, u_ if (cm->cm_frame->header.flags & MFI_FRAME_DATAOUT) cm->cm_flags |= MFI_CMD_DATAOUT; cm->cm_len = cm->cm_frame->header.data_len; - if (cm->cm_flags & (MFI_CMD_DATAIN | MFI_CMD_DATAOUT)) { + if (cm->cm_len && + (cm->cm_flags & (MFI_CMD_DATAIN | MFI_CMD_DATAOUT))) { cm->cm_data = data = malloc(cm->cm_len, M_MFIBUF, M_WAITOK | M_ZERO); if (cm->cm_data == NULL) { @@ -2283,6 +2318,11 @@ mfi_linux_ioctl_int(struct cdev *dev, u_ if (cm->cm_frame->header.cmd == MFI_CMD_DCMD) locked = mfi_config_lock(sc, cm->cm_frame->dcmd.opcode); + if (cm->cm_frame->header.cmd == MFI_CMD_PD_SCSI_IO) { + cm->cm_frame->pass.sense_addr_lo = cm->cm_sense_busaddr; + cm->cm_frame->pass.sense_addr_hi = 0; + } + mtx_lock(&sc->mfi_io_lock); error = mfi_check_command_pre(sc, cm); if (error) { @@ -2316,10 +2356,19 @@ mfi_linux_ioctl_int(struct cdev *dev, u_ } if (l_ioc.lioc_sense_len) { - /* copy out sense */ - sense_ptr = &((struct mfi_linux_ioc_packet*)arg) - ->lioc_frame.raw[0]; - error = copyout(cm->cm_sense, sense_ptr, + /* get user-space sense ptr then copy out sense */ + bcopy(&((struct mfi_linux_ioc_packet*)arg) + ->lioc_frame.raw[l_ioc.lioc_sense_off], + &sense_ptr.sense_ptr_data[0], + sizeof(sense_ptr.sense_ptr_data)); +#ifdef __amd64__ + /* + * only 32bit Linux support so zero out any + * address over 32bit + */ + sense_ptr.addr.high = 0; +#endif + error = copyout(cm->cm_sense, sense_ptr.user_space, l_ioc.lioc_sense_len); if (error != 0) { device_printf(sc->mfi_dev, Modified: stable/7/sys/dev/mfi/mfi_ioctl.h ============================================================================== --- stable/7/sys/dev/mfi/mfi_ioctl.h Mon Nov 17 22:46:29 2008 (r185033) +++ stable/7/sys/dev/mfi/mfi_ioctl.h Mon Nov 17 23:07:18 2008 (r185034) @@ -50,6 +50,16 @@ union mfi_statrequest { struct mfi_qstat ms_qstat; }; +#define MAX_SPACE_FOR_SENSE_PTR 32 +union mfi_sense_ptr { + uint8_t sense_ptr_data[MAX_SPACE_FOR_SENSE_PTR]; + void *user_space; + struct { + uint32_t low; + uint32_t high; + } addr; +} __packed; + #define MAX_IOCTL_SGE 16 struct mfi_ioc_packet { Modified: stable/7/sys/dev/mfi/mfi_pci.c ============================================================================== --- stable/7/sys/dev/mfi/mfi_pci.c Mon Nov 17 22:46:29 2008 (r185033) +++ stable/7/sys/dev/mfi/mfi_pci.c Mon Nov 17 23:07:18 2008 (r185034) @@ -118,7 +118,14 @@ struct mfi_ident { {0x1000, 0x0413, 0xffff, 0xffff, MFI_FLAGS_1064R, "LSI MegaSAS 1064R"}, /* Verde ZCR */ {0x1028, 0x0015, 0xffff, 0xffff, MFI_FLAGS_1064R, "Dell PERC 5/i"}, {0x1000, 0x0060, 0x1028, 0xffff, MFI_FLAGS_1078, "Dell PERC 6"}, - {0x1000, 0x0060, 0xffff, 0xffff, MFI_FLAGS_1078, "LSI MegaSAS 1078"}, + {0x1000, 0x0060, 0xffff, 0xffff, MFI_FLAGS_1078, "LSI MegaSAS 1078"}, + {0x1000, 0x0079, 0x1028, 0x1f15, MFI_FLAGS_GEN2, "Dell PERC 607E Adapter"}, + {0x1000, 0x0079, 0x1028, 0x1f16, MFI_FLAGS_GEN2, "Dell PERC 607I Adapter"}, + {0x1000, 0x0079, 0x1028, 0x1f17, MFI_FLAGS_GEN2, "Dell PERC 607I Integrated"}, + {0x1000, 0x0079, 0x1028, 0x1f18, MFI_FLAGS_GEN2, "Dell PERC 607I Modular"}, + {0x1000, 0x0078, 0xffff, 0xffff, MFI_FLAGS_GEN2, "LSI MegaSAS Gen2"}, + {0x1000, 0x0079, 0xffff, 0xffff, MFI_FLAGS_GEN2, "LSI MegaSAS Gen2"}, + {0x1000, 0x007c, 0xffff, 0xffff, MFI_FLAGS_1078, "LSI MegaSAS 1078"}, {0, 0, 0, 0, 0, NULL} }; @@ -163,6 +170,8 @@ mfi_pci_attach(device_t dev) sc = device_get_softc(dev); bzero(sc, sizeof(*sc)); sc->mfi_dev = dev; + m = mfi_find_ident(dev); + sc->mfi_flags = m->flags; /* Verify that the adapter can be set up in PCI space */ command = pci_read_config(dev, PCIR_COMMAND, 2); @@ -179,7 +188,14 @@ mfi_pci_attach(device_t dev) } /* Allocate PCI registers */ - sc->mfi_regs_rid = PCIR_BAR(0); + if ((sc->mfi_flags & MFI_FLAGS_1064R) || + (sc->mfi_flags & MFI_FLAGS_1078)) { + /* 1068/1078: Memory mapped BAR is at offset 0x10 */ + sc->mfi_regs_rid = PCIR_BAR(0); + } else if (sc->mfi_flags & MFI_FLAGS_GEN2) { + /* GEN2: Memory mapped BAR is at offset 0x14 */ + sc->mfi_regs_rid = PCIR_BAR(1); + } if ((sc->mfi_regs_resource = bus_alloc_resource_any(sc->mfi_dev, SYS_RES_MEMORY, &sc->mfi_regs_rid, RF_ACTIVE)) == NULL) { device_printf(dev, "Cannot allocate PCI registers\n"); @@ -206,9 +222,6 @@ mfi_pci_attach(device_t dev) goto out; } - m = mfi_find_ident(dev); - sc->mfi_flags = m->flags; - error = mfi_attach(sc); out: if (error) { Modified: stable/7/sys/dev/mfi/mfireg.h ============================================================================== --- stable/7/sys/dev/mfi/mfireg.h Mon Nov 17 22:46:29 2008 (r185033) +++ stable/7/sys/dev/mfi/mfireg.h Mon Nov 17 23:07:18 2008 (r185034) @@ -89,10 +89,16 @@ __FBSDID("$FreeBSD$"); #define MFI_ODCR0 0xa0 /* outbound doorbell clear register0 */ #define MFI_OSP0 0xb0 /* outbound scratch pad0 */ #define MFI_1078_EIM 0x80000004 /* 1078 enable intrrupt mask */ -#define MFI_RMI 0x2 /* reply message interrupt */ +#define MFI_RMI 0x2 /* reply message interrupt */ #define MFI_1078_RM 0x80000000 /* reply 1078 message interrupt */ #define MFI_ODC 0x4 /* outbound doorbell change interrupt */ +/* + * GEN2 specific changes + */ +#define MFI_GEN2_EIM 0x00000005 /* GEN2 enable interrupt mask */ +#define MFI_GEN2_RM 0x00000001 /* reply GEN2 message interrupt */ + /* Bits for MFI_OSTS */ #define MFI_OSTS_INTR_VALID 0x00000002 @@ -153,6 +159,7 @@ typedef enum { MFI_DCMD_CFG_READ = 0x04010000, MFI_DCMD_CFG_ADD = 0x04020000, MFI_DCMD_CFG_CLEAR = 0x04030000, + MFI_DCMD_CFG_FOREIGN_IMPORT = 0x04060400, MFI_DCMD_CLUSTER = 0x08000000, MFI_DCMD_CLUSTER_RESET_ALL = 0x08010100, MFI_DCMD_CLUSTER_RESET_LD = 0x08010200 Modified: stable/7/sys/dev/mfi/mfivar.h ============================================================================== --- stable/7/sys/dev/mfi/mfivar.h Mon Nov 17 22:46:29 2008 (r185033) +++ stable/7/sys/dev/mfi/mfivar.h Mon Nov 17 23:07:18 2008 (r185034) @@ -133,6 +133,7 @@ struct mfi_softc { #define MFI_FLAGS_STOP (1<<3) #define MFI_FLAGS_1064R (1<<4) #define MFI_FLAGS_1078 (1<<5) +#define MFI_FLAGS_GEN2 (1<<6) struct mfi_hwcomms *mfi_comms; TAILQ_HEAD(,mfi_command) mfi_free; From ambrisko at FreeBSD.org Tue Nov 18 10:21:36 2008 From: ambrisko at FreeBSD.org (Doug Ambrisko) Date: Tue Nov 18 10:21:42 2008 Subject: svn commit: r185054 - in stable/7/sys: . ufs/ffs Message-ID: <200811181821.mAIILa1W084886@svn.freebsd.org> Author: ambrisko Date: Tue Nov 18 18:21:36 2008 New Revision: 185054 URL: http://svn.freebsd.org/changeset/base/185054 Log: MFC 184934: For now on every 10 cyclinder groups flush the buffer cache to free up space. If the buffer cache fills up then the disk systems can grind to a halt. PR: 128832 Approved by: re (kensmith) Modified: stable/7/sys/ (props changed) stable/7/sys/ufs/ffs/ffs_snapshot.c Modified: stable/7/sys/ufs/ffs/ffs_snapshot.c ============================================================================== --- stable/7/sys/ufs/ffs/ffs_snapshot.c Tue Nov 18 15:48:23 2008 (r185053) +++ stable/7/sys/ufs/ffs/ffs_snapshot.c Tue Nov 18 18:21:36 2008 (r185054) @@ -345,6 +345,8 @@ restart: if (error) goto out; bawrite(nbp); + if (cg % 10 == 0) + ffs_syncvnode(vp, MNT_WAIT); } /* * Copy all the cylinder group maps. Although the @@ -366,6 +368,8 @@ restart: goto out; error = cgaccount(cg, vp, nbp, 1); bawrite(nbp); + if (cg % 10 == 0) + ffs_syncvnode(vp, MNT_WAIT); if (error) goto out; } From delphij at FreeBSD.org Tue Nov 18 12:41:15 2008 From: delphij at FreeBSD.org (Xin LI) Date: Tue Nov 18 12:41:26 2008 Subject: svn commit: r185058 - in stable/7/sbin/geom: . class/part misc Message-ID: <200811182041.mAIKfE4W088369@svn.freebsd.org> Author: delphij Date: Tue Nov 18 20:41:14 2008 New Revision: 185058 URL: http://svn.freebsd.org/changeset/base/185058 Log: MFC r183718 and r185057: Add some examples to demostrate gpart(8). Approved by: re (kib) Modified: stable/7/sbin/geom/ (props changed) stable/7/sbin/geom/class/part/ (props changed) stable/7/sbin/geom/class/part/gpart.8 stable/7/sbin/geom/misc/ (props changed) Modified: stable/7/sbin/geom/class/part/gpart.8 ============================================================================== --- stable/7/sbin/geom/class/part/gpart.8 Tue Nov 18 20:38:07 2008 (r185057) +++ stable/7/sbin/geom/class/part/gpart.8 Tue Nov 18 20:41:14 2008 (r185058) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd Jun 17, 2008 +.Dd Nov 18, 2008 .Dt GPART 8 .Os .Sh NAME @@ -404,6 +404,41 @@ action or reverted with the action. .Sh EXIT STATUS Exit status is 0 on success, and 1 if the command fails. +.Sh EXAMPLES +Create GPT scheme on +.Pa ad0 . +.Bd -literal -offset indent +/sbin/gpart create -s GPT ad0 +.Ed +.Pp +Embed GPT bootstrap code into protective MBR. +.Bd -literal -offset indent +/sbin/gpart bootcode -b /boot/pmbr ad0 +.Ed +.Pp +Create a dedicated +.Pa freebsd-boot +partition that can boot FreeBSD from a +.Pa freebsd-ufs +partition, and install bootstrap code into it. +This partition must be larger than +.Pa /boot/gptboot , +or the GPT boot you are planning to write. +A size of 15 blocks (7680 bytes) would be sufficient for +booting from UFS but lets use 128 blocks (64 KB) here in +this example, in order to reserve some space for potential +future need (e.g. from a ZFS partition). +.Bd -literal -offset indent +/sbin/gpart add -b 34 -s 128 -t freebsd-boot ad0 +/sbin/gpart bootcode -p /boot/gptboot -i 1 ad0 +.Ed +.Pp +Create a 512MB-sized +.Pa freebsd-ufs +partition that would contain UFS where the system boot from. +.Bd -literal -offset indent +/sbin/gpart add -b 162 -s 1048576 -t freebsd-ufs ad0 +.Ed .Sh SEE ALSO .Xr geom 4 , .Xr geom 8 , From delphij at FreeBSD.org Tue Nov 18 22:58:52 2008 From: delphij at FreeBSD.org (Xin LI) Date: Tue Nov 18 22:58:59 2008 Subject: svn commit: r185086 - stable/7/share/man/man4 Message-ID: <200811190658.mAJ6wqAi008576@svn.freebsd.org> Author: delphij Date: Wed Nov 19 06:58:52 2008 New Revision: 185086 URL: http://svn.freebsd.org/changeset/base/185086 Log: MFC revisions 183653 183654 183714 (simon), all recent em(4) and add igb(4). Approved by: re (hrs) Added: stable/7/share/man/man4/igb.4 (props changed) - copied unchanged from r183654, head/share/man/man4/igb.4 Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/Makefile stable/7/share/man/man4/em.4 Modified: stable/7/share/man/man4/Makefile ============================================================================== --- stable/7/share/man/man4/Makefile Wed Nov 19 04:05:44 2008 (r185085) +++ stable/7/share/man/man4/Makefile Wed Nov 19 06:58:52 2008 (r185086) @@ -118,6 +118,7 @@ MAN= aac.4 \ ieee80211.4 \ if_bridge.4 \ ifmib.4 \ + igb.4 \ iic.4 \ iicbb.4 \ iicbus.4 \ Modified: stable/7/share/man/man4/em.4 ============================================================================== --- stable/7/share/man/man4/em.4 Wed Nov 19 04:05:44 2008 (r185085) +++ stable/7/share/man/man4/em.4 Wed Nov 19 06:58:52 2008 (r185086) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 15, 2006 +.Dd October 6, 2008 .Dt EM 4 .Os .Sh NAME @@ -56,7 +56,8 @@ The .Nm driver provides support for PCI Gigabit Ethernet adapters based on the Intel 82540, 82541ER, 82541PI, 82542, 82543, 82544, 82545, 82546, -82546EB, 82546GB, 82547, 82571, 81572 and 82573 Ethernet controller chips. +82546EB, 82546GB, 82547, 82571, 81572, 82573, and 82574 Ethernet +controller chips. The driver supports Transmit/Receive checksum offload and Jumbo Frames on all but 82542-based adapters. Furthermore it supports TCP segmentation offload (TSO) on all adapters but @@ -135,7 +136,7 @@ The .Nm driver supports Gigabit Ethernet adapters based on the Intel 82540, 82541ER, 82541PI, 82542, 82543, 82544, 82545, 82546, 82546EB, -82546GB, 82547, 82571, 82572 and 82573 controller chips: +82546GB, 82547, 82571, 82572, 82573, and 82574 controller chips: .Pp .Bl -bullet -compact .It @@ -163,6 +164,20 @@ Intel PRO/1000 MT Quad Port Server Adapt .It Intel PRO/1000 MT Server Adapter (82545) .It +Intel PRO/1000 PF Dual Port Server Adapter (82571) +.It +Intel PRO/1000 PF Quad Port Server Adapter (82571) +.It +Intel PRO/1000 PF Server Adapter (82572) +.It +Intel PRO/1000 PT Desktop Adapter (82572) +.It +Intel PRO/1000 PT Dual Port Server Adapter (82571) +.It +Intel PRO/1000 PT Quad Port Server Adapter (82571) +.It +Intel PRO/1000 PT Server Adapter (82572) +.It Intel PRO/1000 T Desktop Adapter (82544) .It Intel PRO/1000 T Server Adapter (82543) Copied: stable/7/share/man/man4/igb.4 (from r183654, head/share/man/man4/igb.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/share/man/man4/igb.4 Wed Nov 19 06:58:52 2008 (r185086, copy of r183654, head/share/man/man4/igb.4) @@ -0,0 +1,196 @@ +.\" Copyright (c) 2001-2003, Intel Corporation +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions are met: +.\" +.\" 1. Redistributions of source code must retain the above copyright notice, +.\" this list of conditions and the following disclaimer. +.\" +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" 3. Neither the name of the Intel Corporation nor the names of its +.\" contributors may be used to endorse or promote products derived from +.\" this software without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.\" * Other names and brands may be claimed as the property of others. +.\" +.\" $FreeBSD$ +.\" +.Dd October 6, 2008 +.Dt IGB 4 +.Os +.Sh NAME +.Nm igb +.Nd "Intel(R) PRO/1000 PCI Express Gigabit Ethernet adapter driver" +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following line in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device igb" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_igb_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for PCI Express Gigabit Ethernet adapters +based on the Intel 82575 and 82576 Ethernet controller chips. +The driver supports Transmit/Receive checksum offload and Jumbo +Frames. +Furthermore it supports TCP segmentation offload (TSO) on all +adapters. +.Pp +For questions related to hardware requirements, refer to the +documentation supplied with your Intel PRO/1000 adapter. +All hardware requirements listed apply to use with +.Fx . +.Pp +Support for Jumbo Frames is provided via the interface MTU setting. +Selecting an MTU larger than 1500 bytes with the +.Xr ifconfig 8 +utility configures the adapter to receive and transmit Jumbo Frames. +The maximum MTU size for Jumbo Frames is 9216. +.Pp +This driver supports hardware assisted VLANs. +The +.Nm +driver supports the following media types: +.Bl -tag -width ".Cm 10baseT/UTP" +.It Cm autoselect +Enables auto-negotiation for speed and duplex. +.It Cm 10baseT/UTP +Sets 10Mbps operation. +Use the +.Cm mediaopt +option to select +.Cm full-duplex +mode. +.It Cm 100baseTX +Sets 100Mbps operation. +Use the +.Cm mediaopt +option to select +.Cm full-duplex +mode. +.It Cm 1000baseSX +Sets 1000Mbps operation. +Only +.Cm full-duplex +mode is supported at this speed. +.It Cm 1000baseTX +Sets 1000Mbps operation. +Only +.Cm full-duplex +mode is supported at this speed. +.El +.Pp +The +.Nm +driver supports the following media options: +.Bl -tag -width ".Cm full-duplex" +.It Cm full-duplex +Forces full-duplex operation +.It Cm half-duplex +Forces half-duplex operation. +.El +.Pp +Only use +.Cm mediaopt +to set the driver to +.Cm full-duplex . +If +.Cm mediaopt +is not specified, the driver defaults to +.Cm half-duplex . +.Pp +For more information on configuring this device, see +.Xr ifconfig 8 . +.Sh HARDWARE +The +.Nm +driver supports Gigabit Ethernet adapters based on the Intel 82575 and +82576 controller chips: +.Pp +.Bl -bullet -compact +.It +Intel Gigabit ET Dual Port Server Adapter (82576) +.It +Intel Gigabit VT Quad Port Server Adapter (82575) +.El +.Sh LOADER TUNABLES +Tunables can be set at the +.Xr loader 8 +prompt before booting the kernel or stored in +.Xr loader.conf 5 . +.Bl -tag -width indent +.It Va hw.igb.rxd +Number of receive descriptors allocated by the driver. +The default value is 256. +The minimum is 80, and the maximum is 4096. +.It Va hw.igb.txd +Number of transmit descriptors allocated by the driver. +The default value is 256. +The minimum is 80, and the maximum is 4096. +.It Va hw.igb.enable_aim +If set to 1, enable Adaptive Interrupt Moderation. +The default is to enable Adaptive Interrupt Moderation. +.El +.Sh DIAGNOSTICS +.Bl -diag +.It "igb%d: Unable to allocate bus resource: memory" +A fatal initialization error has occurred. +.It "igb%d: Unable to allocate bus resource: interrupt" +A fatal initialization error has occurred. +.It "igb%d: watchdog timeout -- resetting" +The device has stopped responding to the network, or there is a problem with +the network connection (cable). +.El +.Sh SUPPORT +For general information and support, +go to the Intel support website at: +.Pa http://support.intel.com . +.Pp +If an issue is identified with the released source code on the supported kernel +with a supported adapter, email the specific information related to the +issue to +.Aq freebsdnic@mailbox.intel.com . +.Sh SEE ALSO +.Xr altq 4 , +.Xr arp 4 , +.Xr em 4 , +.Xr netintro 4 , +.Xr ng_ether 4 , +.Xr polling 4 , +.Xr vlan 4 , +.Xr ifconfig 8 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Fx 7.1 . +.Sh AUTHORS +The +.Nm +driver was written by +.An Intel Corporation Aq freebsdnic@mailbox.intel.com . From hrs at FreeBSD.org Wed Nov 19 10:06:30 2008 From: hrs at FreeBSD.org (Hiroki Sato) Date: Wed Nov 19 10:06:41 2008 Subject: svn commit: r185100 - stable/7/usr.bin/sed Message-ID: <200811191806.mAJI6TfN024284@svn.freebsd.org> Author: hrs Date: Wed Nov 19 18:06:29 2008 New Revision: 185100 URL: http://svn.freebsd.org/changeset/base/185100 Log: MFC: Add workaround for a back reference when no corresponding parenthesized subexpression is defined. For example, the following command line caused unexpected behavior like segmentation fault: % echo test | sed -e 's/test/\1/' Approved by: re (kib) PR: bin/126682 Modified: stable/7/usr.bin/sed/ (props changed) stable/7/usr.bin/sed/compile.c Modified: stable/7/usr.bin/sed/compile.c ============================================================================== --- stable/7/usr.bin/sed/compile.c Wed Nov 19 17:34:28 2008 (r185099) +++ stable/7/usr.bin/sed/compile.c Wed Nov 19 18:06:29 2008 (r185100) @@ -324,9 +324,17 @@ nonsel: /* Now parse the command */ if (p == NULL) errx(1, "%lu: %s: unterminated substitute pattern", linenum, fname); + + /* Compile RE with no case sensitivity temporarily */ + if (*re == '\0') + cmd->u.s->re = NULL; + else + cmd->u.s->re = compile_re(re, 0); --p; p = compile_subst(p, cmd->u.s); p = compile_flags(p, cmd->u.s); + + /* Recompile RE with case sensitivity from "I" flag if any */ if (*re == '\0') cmd->u.s->re = NULL; else From delphij at FreeBSD.org Wed Nov 19 16:43:41 2008 From: delphij at FreeBSD.org (Xin LI) Date: Wed Nov 19 16:43:58 2008 Subject: svn commit: r185110 - in stable/7/release/doc/en_US.ISO8859-1: hardware relnotes Message-ID: <200811200043.mAK0hfsh033233@svn.freebsd.org> Author: delphij Date: Thu Nov 20 00:43:41 2008 New Revision: 185110 URL: http://svn.freebsd.org/changeset/base/185110 Log: MFC: Document igb(4). Approved by: re (hrs) Modified: stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml stable/7/release/doc/en_US.ISO8859-1/relnotes/article.sgml Modified: stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml ============================================================================== --- stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml Wed Nov 19 22:12:32 2008 (r185109) +++ stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml Thu Nov 20 00:43:41 2008 (r185110) @@ -29,6 +29,7 @@ 2005 2006 2007 + 2008 The &os; Documentation Project @@ -657,6 +658,8 @@ &hwlist.ie; + &hwlist.igb; + &hwlist.ixgb; &hwlist.kue; Modified: stable/7/release/doc/en_US.ISO8859-1/relnotes/article.sgml ============================================================================== --- stable/7/release/doc/en_US.ISO8859-1/relnotes/article.sgml Wed Nov 19 22:12:32 2008 (r185109) +++ stable/7/release/doc/en_US.ISO8859-1/relnotes/article.sgml Thu Nov 20 00:43:41 2008 (r185110) @@ -198,6 +198,12 @@ Network Interface Support + The &man.em.4; driver has been split into two drivers + with some common parts. The &man.em.4; driver will continue + to support adapters up to the 82575, as well as new + client/desktop adapters. A new &man.igb.4; driver + will support new server adapters. + [&arch.amd64;, &arch.i386;] The &man.wpi.4; driver has been updated to include a number of stability fixes. From delphij at FreeBSD.org Thu Nov 20 16:48:58 2008 From: delphij at FreeBSD.org (Xin LI) Date: Thu Nov 20 16:49:10 2008 Subject: svn commit: r185135 - in stable/7/release/doc/zh_CN.GB2312: hardware relnotes Message-ID: <200811210048.mAL0mwa8068228@svn.freebsd.org> Author: delphij Date: Fri Nov 21 00:48:57 2008 New Revision: 185135 URL: http://svn.freebsd.org/changeset/base/185135 Log: MFen r185110: document igb(4) Approved by: re (kensmith) Modified: stable/7/release/doc/zh_CN.GB2312/hardware/article.sgml stable/7/release/doc/zh_CN.GB2312/relnotes/article.sgml Modified: stable/7/release/doc/zh_CN.GB2312/hardware/article.sgml ============================================================================== --- stable/7/release/doc/zh_CN.GB2312/hardware/article.sgml Thu Nov 20 19:51:06 2008 (r185134) +++ stable/7/release/doc/zh_CN.GB2312/hardware/article.sgml Fri Nov 21 00:48:57 2008 (r185135) @@ -392,7 +392,7 @@ - + @@ -183,6 +183,10 @@ ÍøÂç½Ó¿ÚÖ§³Ö + ½« &man.em.4; Çý¶¯³ÌÐò·Ö²ð³ÉÁËÁ½¸ö¹²Ïí²¿·Ö´úÂëµÄÇý¶¯³ÌÐò¡£ + &man.em.4; Çý¶¯³ÌÐò½«¼ÌÐøÖ§³Ö¸ßÖÁ 82575 µÄÍø¿¨ÒÔ¼°ÐµÄÕë¶Ô¿Í»§»ú/×ÀÃæµÄÍø¿¨¡£ + ÐÂÔöµÄ &man.igb.4; Çý¶¯³ÌÐòÔòÓÃÓÚÖ§³ÖеķþÎñÆ÷Íø¿¨¡£ + [&arch.amd64;¡¢ &arch.i386;] ¶Ô &man.wpi.4; Çý¶¯³ÌÐò½øÐÐÁ˸üУ¬ ÐÞÕýÁËһϵÁпɿ¿ÐÔÎÊÌâ¡£ From delphij at FreeBSD.org Fri Nov 21 17:48:21 2008 From: delphij at FreeBSD.org (Xin LI) Date: Fri Nov 21 17:48:27 2008 Subject: svn commit: r185161 - in stable/7/sys: . dev/bce modules/cxgb Message-ID: <200811220148.mAM1mKvg002423@svn.freebsd.org> Author: delphij Date: Sat Nov 22 01:48:20 2008 New Revision: 185161 URL: http://svn.freebsd.org/changeset/base/185161 Log: MFC r185082: Correct a logic error when testing BCE_PHY_SERDES_FLAG. PR: kern/128801 Pointed out by: Adam Morrison Ok'ed by: davidch Approved by: re (kensmith) Modified: stable/7/sys/ (props changed) stable/7/sys/dev/bce/if_bce.c stable/7/sys/modules/cxgb/ (props changed) Modified: stable/7/sys/dev/bce/if_bce.c ============================================================================== --- stable/7/sys/dev/bce/if_bce.c Sat Nov 22 01:35:59 2008 (r185160) +++ stable/7/sys/dev/bce/if_bce.c Sat Nov 22 01:48:20 2008 (r185161) @@ -2555,7 +2555,7 @@ bce_get_media(struct bce_softc *sc) } else if (BCE_CHIP_BOND_ID(sc) & BCE_CHIP_BOND_ID_SERDES_BIT) sc->bce_phy_flags |= BCE_PHY_SERDES_FLAG; - if (sc->bce_phy_flags && BCE_PHY_SERDES_FLAG) { + if (sc->bce_phy_flags & BCE_PHY_SERDES_FLAG) { sc->bce_flags |= BCE_NO_WOL_FLAG; if (BCE_CHIP_NUM(sc) != BCE_CHIP_NUM_5706) { sc->bce_phy_addr = 2; From marcel at FreeBSD.org Sat Nov 22 09:54:31 2008 From: marcel at FreeBSD.org (Marcel Moolenaar) Date: Sat Nov 22 09:54:42 2008 Subject: svn commit: r185184 - in stable/7/sys: . geom/part modules/cxgb Message-ID: <200811221754.mAMHsUiN025130@svn.freebsd.org> Author: marcel Date: Sat Nov 22 17:54:30 2008 New Revision: 185184 URL: http://svn.freebsd.org/changeset/base/185184 Log: MFC 184734: Fix a panic caused by a corrupted table when the header is still valid. PR: 119868 Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/geom/part/g_part_gpt.c stable/7/sys/modules/cxgb/ (props changed) Modified: stable/7/sys/geom/part/g_part_gpt.c ============================================================================== --- stable/7/sys/geom/part/g_part_gpt.c Sat Nov 22 16:55:55 2008 (r185183) +++ stable/7/sys/geom/part/g_part_gpt.c Sat Nov 22 17:54:30 2008 (r185184) @@ -619,13 +619,16 @@ g_part_gpt_read(struct g_part_table *bas if (table->state[GPT_ELT_PRIHDR] == GPT_STATE_OK && table->state[GPT_ELT_SECHDR] == GPT_STATE_OK && !gpt_matched_hdrs(&prihdr, &sechdr)) { - if (table->state[GPT_ELT_PRITBL] == GPT_STATE_OK) + if (table->state[GPT_ELT_PRITBL] == GPT_STATE_OK) { table->state[GPT_ELT_SECHDR] = GPT_STATE_INVALID; - else + table->state[GPT_ELT_SECTBL] = GPT_STATE_MISSING; + } else { table->state[GPT_ELT_PRIHDR] = GPT_STATE_INVALID; + table->state[GPT_ELT_PRITBL] = GPT_STATE_MISSING; + } } - if (table->state[GPT_ELT_PRIHDR] != GPT_STATE_OK) { + if (table->state[GPT_ELT_PRITBL] != GPT_STATE_OK) { printf("GEOM: %s: the primary GPT table is corrupt or " "invalid.\n", pp->name); printf("GEOM: %s: using the secondary instead -- recovery " @@ -635,7 +638,7 @@ g_part_gpt_read(struct g_part_table *bas if (pritbl != NULL) g_free(pritbl); } else { - if (table->state[GPT_ELT_SECHDR] != GPT_STATE_OK) { + if (table->state[GPT_ELT_SECTBL] != GPT_STATE_OK) { printf("GEOM: %s: the secondary GPT table is corrupt " "or invalid.\n", pp->name); printf("GEOM: %s: using the primary only -- recovery " From kib at FreeBSD.org Sat Nov 22 13:08:25 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sat Nov 22 13:08:42 2008 Subject: svn commit: r185185 - stable/7 Message-ID: <200811222108.mAML8P10029225@svn.freebsd.org> Author: kib Date: Sat Nov 22 21:08:25 2008 New Revision: 185185 URL: http://svn.freebsd.org/changeset/base/185185 Log: MFC r184860 (by obrien): Add the kerberos5 libs to the install32 target. Approved by: re (kensmith) Modified: stable/7/Makefile.inc1 (contents, props changed) Modified: stable/7/Makefile.inc1 ============================================================================== --- stable/7/Makefile.inc1 Sat Nov 22 17:54:30 2008 (r185184) +++ stable/7/Makefile.inc1 Sat Nov 22 21:08:25 2008 (r185185) @@ -487,6 +487,9 @@ distribute32 install32: .if ${MK_CRYPT} != "no" cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} .endif +.if ${MK_KERBEROS} != "no" + cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//} +.endif cd ${.CURDIR}/libexec/rtld-elf; \ PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//} cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} ${.TARGET:S/32$//} From sam at FreeBSD.org Sat Nov 22 15:48:34 2008 From: sam at FreeBSD.org (Sam Leffler) Date: Sat Nov 22 15:48:45 2008 Subject: svn commit: r185190 - stable/7/sys/net80211 Message-ID: <200811222348.mAMNmXf3032612@svn.freebsd.org> Author: sam Date: Sat Nov 22 23:48:33 2008 New Revision: 185190 URL: http://svn.freebsd.org/changeset/base/185190 Log: change private mbuf flags to use M_PROTO* so they don't conflict with public definitions; note this constitutes an ABI change so drivers that use M_TXCB or M_FF must be recompiled Approved by: re (kib) Modified: stable/7/sys/net80211/ieee80211_freebsd.h Modified: stable/7/sys/net80211/ieee80211_freebsd.h ============================================================================== --- stable/7/sys/net80211/ieee80211_freebsd.h Sat Nov 22 22:15:34 2008 (r185189) +++ stable/7/sys/net80211/ieee80211_freebsd.h Sat Nov 22 23:48:33 2008 (r185190) @@ -197,9 +197,10 @@ struct mbuf *ieee80211_getmgtframe(uint8 #define M_LINK0 M_PROTO1 /* WEP requested */ #define M_PWR_SAV M_PROTO4 /* bypass PS handling */ #define M_MORE_DATA M_PROTO5 /* more data frames to follow */ -#define M_FF 0x20000 /* fast frame */ -#define M_TXCB 0x40000 /* do tx complete callback */ -#define M_80211_TX (0x60000|M_PROTO1|M_WME_AC_MASK|M_PROTO4|M_PROTO5) +#define M_FF M_PROTO6 /* fast frame */ +#define M_TXCB M_PROTO7 /* do tx complete callback */ +#define M_80211_TX \ + (M_LINK0|M_WME_AC_MASK|M_PWR_SAV|M_MORE_DATA|M_FF|M_TXCB) /* rx path usage */ #define M_AMPDU M_PROTO1 /* A-MPDU processing done */ From delphij at FreeBSD.org Sat Nov 22 16:16:10 2008 From: delphij at FreeBSD.org (Xin LI) Date: Sat Nov 22 16:16:22 2008 Subject: svn commit: r185192 - in stable/7/sbin/geom: . class/part misc Message-ID: <200811230016.mAN0GA7x033233@svn.freebsd.org> Author: delphij Date: Sun Nov 23 00:16:10 2008 New Revision: 185192 URL: http://svn.freebsd.org/changeset/base/185192 Log: MFC r185038,185044,185046: Automatically pad gptboot, style for include files, use humanize_number() for consistency and reduce code duplication. Approved by: re (kib) Modified: stable/7/sbin/geom/ (props changed) stable/7/sbin/geom/class/part/ (props changed) stable/7/sbin/geom/class/part/Makefile stable/7/sbin/geom/class/part/geom_part.c stable/7/sbin/geom/misc/ (props changed) Modified: stable/7/sbin/geom/class/part/Makefile ============================================================================== --- stable/7/sbin/geom/class/part/Makefile Sun Nov 23 00:13:25 2008 (r185191) +++ stable/7/sbin/geom/class/part/Makefile Sun Nov 23 00:16:10 2008 (r185192) @@ -4,6 +4,8 @@ CLASS= part +LDADD= -lutil + WARNS?= 4 .include Modified: stable/7/sbin/geom/class/part/geom_part.c ============================================================================== --- stable/7/sbin/geom/class/part/geom_part.c Sun Nov 23 00:13:25 2008 (r185191) +++ stable/7/sbin/geom/class/part/geom_part.c Sun Nov 23 00:16:10 2008 (r185192) @@ -27,19 +27,21 @@ #include __FBSDID("$FreeBSD$"); -#include -#include -#include -#include +#include + +#include #include +#include #include -#include -#include #include +#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include "core/geom.h" #include "misc/subr.h" @@ -202,21 +204,12 @@ find_provider(struct ggeom *gp, unsigned } static const char * -fmtsize(long double rawsz) +fmtsize(int64_t rawsz) { - static char buf[32]; - static const char *sfx[] = { "B", "KB", "MB", "GB", "TB" }; - long double sz; - int sfxidx; - - sfxidx = 0; - sz = (long double)rawsz; - while (sfxidx < 4 && sz > 1099.0) { - sz /= 1000; - sfxidx++; - } + static char buf[5]; - sprintf(buf, "%.1Lf%s", sz, sfx[sfxidx]); + humanize_number(buf, sizeof(buf), rawsz, "", HN_AUTOSCALE, + HN_B | HN_NOSPACE | HN_DECIMAL); return (buf); } @@ -386,6 +379,8 @@ gpart_write_partcode(struct gctl_req *re struct ggeom *gp; struct gprovider *pp; const char *s; + char *buf; + off_t bsize; int error, fd; s = gctl_get_ascii(req, "class"); @@ -421,8 +416,21 @@ gpart_write_partcode(struct gctl_req *re errx(EXIT_FAILURE, "%s: not enough space", dsf); if (lseek(fd, 0, SEEK_SET) != 0) err(EXIT_FAILURE, "%s", dsf); - if (write(fd, code, size) != size) + + /* + * When writing to a disk device, the write must be + * sector aligned and not write to any partial sectors, + * so round up the buffer size to the next sector and zero it. + */ + bsize = (size + pp->lg_sectorsize - 1) / + pp->lg_sectorsize * pp->lg_sectorsize; + buf = calloc(1, bsize); + if (buf == NULL) + err(EXIT_FAILURE, "%s", dsf); + bcopy(code, buf, size); + if (write(fd, buf, bsize) != bsize) err(EXIT_FAILURE, "%s", dsf); + free(buf); close(fd); } else errx(EXIT_FAILURE, "invalid partition index"); From kib at FreeBSD.org Sun Nov 23 08:08:36 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Nov 23 08:08:53 2008 Subject: svn commit: r185210 - in stable/7/sys: . modules/cxgb vm Message-ID: <200811231608.mANG8aPg056631@svn.freebsd.org> Author: kib Date: Sun Nov 23 16:08:36 2008 New Revision: 185210 URL: http://svn.freebsd.org/changeset/base/185210 Log: MFC r185012: Instead of forcing vn_start_write() to reset mp back to NULL for the failed calls with non-NULL vp, explicitely clear mp after failure. Approved by: re (kensmith) PR: 123768 Modified: stable/7/sys/ (props changed) stable/7/sys/modules/cxgb/ (props changed) stable/7/sys/vm/vm_pageout.c Modified: stable/7/sys/vm/vm_pageout.c ============================================================================== --- stable/7/sys/vm/vm_pageout.c Sun Nov 23 16:06:41 2008 (r185209) +++ stable/7/sys/vm/vm_pageout.c Sun Nov 23 16:08:36 2008 (r185210) @@ -947,8 +947,7 @@ rescan0: vp = object->handle; if (vp->v_type == VREG && vn_start_write(vp, &mp, V_NOWAIT) != 0) { - KASSERT(mp == NULL, - ("vm_pageout_scan: mp != NULL")); + mp = NULL; ++pageout_lock_miss; if (object->flags & OBJ_MIGHTBEDIRTY) vnodes_skipped++; From marius at FreeBSD.org Sun Nov 23 09:10:05 2008 From: marius at FreeBSD.org (Marius Strobl) Date: Sun Nov 23 09:10:18 2008 Subject: svn commit: r185212 - stable/7/share/man/man9 Message-ID: <200811231710.mANHA5bx057968@svn.freebsd.org> Author: marius Date: Sun Nov 23 17:10:04 2008 New Revision: 185212 URL: http://svn.freebsd.org/changeset/base/185212 Log: MFC: r185004 - For maximum flexibility, sparc64 supports BUS_DMA_COHERENT also with bus_dmamap_create() and not only bus_dmamem_alloc() so move the description of this flag up accordingly in order to document this fact. While at it, refine this description with an application example. - Reword the description of BUS_DMA_NOCACHE as this flag is also implemented on sparc64. Approved by: re (kib) Modified: stable/7/share/man/man9/ (props changed) stable/7/share/man/man9/bus_dma.9 Modified: stable/7/share/man/man9/bus_dma.9 ============================================================================== --- stable/7/share/man/man9/bus_dma.9 Sun Nov 23 16:44:49 2008 (r185211) +++ stable/7/share/man/man9/bus_dma.9 Sun Nov 23 17:10:04 2008 (r185212) @@ -60,7 +60,7 @@ .\" $FreeBSD$ .\" $NetBSD: bus_dma.9,v 1.25 2002/10/14 13:43:16 wiz Exp $ .\" -.Dd March 6, 2007 +.Dd November 16, 2008 .Dt BUS_DMA 9 .Os .Sh NAME @@ -474,9 +474,23 @@ Arguments are as follows: .It Fa dmat DMA tag. .It Fa flags -The value of this argument is currently undefined and should be -specified as -.Ql 0 . +Are as follows: +.Bl -tag -width ".Dv BUS_DMA_COHERENT" +.It Dv BUS_DMA_COHERENT +Attempt to map the memory loaded with this map such that cache sync +operations are as cheap as possible. +This flag is typically set on maps when the memory loaded with these will +be accessed by both a CPU and a DMA engine, frequently such as control data +and as opposed to streamable data such as receive and transmit buffers. +Use of this flag does not remove the requirement of using +.Fn bus_dmamap_sync , +but it may reduce the cost of performing these operations. +For +.Fn bus_dmamap_create , +the +.Dv BUS_DMA_COHERENT +flag is currently implemented on sparc64. +.El .It Fa mapp Pointer to a .Vt bus_dmamap_t @@ -542,9 +556,11 @@ and instead should return immediately wi The allocated memory will not be cached in the processor caches. All memory accesses appear on the bus and are executed without reordering. -Currently the flag is implemented for i386 and amd64 architectures -only, where it results in the Strong Uncacheable -PAT to be set for the allocated virtual address range. +On the amd64 and i386 architectures this flag results in the +Strong Uncacheable PAT to be set for the allocated virtual address range. +The +.Dv BUS_DMA_NOCACHE +flag is currently implemented on amd64, i386 and sparc64. .El .El .Pp @@ -749,16 +765,15 @@ If resources are not available, .Dv ENOMEM is returned. .It Dv BUS_DMA_COHERENT -Attempt to map this memory such that cache sync operations are -as cheap as possible. -This flag is typically set on memory that will be accessed by both -a CPU and a DMA engine, frequently. -Use of this flag does not remove the requirement of using -bus_dmamap_sync, but it may reduce the cost of performing -these operations. -The +Attempt to map this memory in a coherent fashion. +See +.Fn bus_dmamap_create +above for a description of this flag. +For +.Fn bus_dmamem_alloc , +the .Dv BUS_DMA_COHERENT -flag is currently implemented on sparc64 and arm. +flag is currently implemented on arm and sparc64. .It Dv BUS_DMA_ZERO Causes the allocated memory to be set to all zeros. .El From xcllnt at mac.com Sun Nov 23 10:50:44 2008 From: xcllnt at mac.com (Marcel Moolenaar) Date: Sun Nov 23 10:50:50 2008 Subject: svn commit: r185192 - in stable/7/sbin/geom: . class/part misc In-Reply-To: <200811230016.mAN0GA7x033233@svn.freebsd.org> References: <200811230016.mAN0GA7x033233@svn.freebsd.org> Message-ID: <441DF4B4-CD86-4769-A6D3-27D1010E1DE0@mac.com> On Nov 22, 2008, at 4:16 PM, Xin LI wrote: > Author: delphij > Date: Sun Nov 23 00:16:10 2008 > New Revision: 185192 > URL: http://svn.freebsd.org/changeset/base/185192 > > Log: > MFC r185038,185044,185046: Thanks! -- Marcel Moolenaar xcllnt@mac.com From yongari at FreeBSD.org Sun Nov 23 16:52:26 2008 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Sun Nov 23 16:52:49 2008 Subject: svn commit: r185238 - in stable/7/sys: . amd64/conf boot/forth conf dev/ale i386/conf modules modules/ale modules/cxgb Message-ID: <200811240052.mAO0qQ3H069096@svn.freebsd.org> Author: yongari Date: Mon Nov 24 00:52:26 2008 New Revision: 185238 URL: http://svn.freebsd.org/changeset/base/185238 Log: MFC r184870: Add ale(4), a driver for Atheros AR8121/AR8113/AR8114 PCIe ethernet controller. The controller is also known as L1E(AR8121) and L2E(AR8113/AR8114). Unlike its predecessor Attansic L1, AR8121/AR8113/AR8114 uses completely different Rx logic such that it requires separate driver. Datasheet for AR81xx is not available to open source driver writers but it shares large part of Tx and PHY logic of L1. I still don't understand some part of register meaning and some MAC statistics counters but the driver seems to have no critical issues for performance and stability. The AR81xx requires copy operation to pass received frames to upper stack such that ale(4) consumes a lot of CPU cycles than that of other controller. A couple of silicon bugs also adds more CPU cycles to address the known hardware bug. However, if you have fast CPU you can still saturate the link. Currently ale(4) supports the following hardware features. - MSI. - TCP Segmentation offload. - Hardware VLAN tag insertion/stripping with checksum offload. - Tx TCP/UDP checksum offload and Rx IP/TCP/UDP checksum offload. - Tx/Rx interrupt moderation. - Hardware statistics counters. - Jumbo frame. - WOL. AR81xx PCIe ethernet controllers are mainly found on ASUS EeePC or P5Q series of ASUS motherboards. Special thanks to Jeremy Chadwick who sent the hardware to me. Without his donation writing a driver for AR81xx would never have been possible. Big thanks to all people who reported feedback or tested patches. HW donated by: koitsu Tested by: bsam, Joao Barros gmail DOT com > Jan Henrik Sylvester janh DOT de > Ivan Brawley < ivan <> brawley DOT id DOT au >, CURRENT ML Approved by: re (kib) Note, GENERIC kernel does NOT include ale(4) but users can still kldload it. It was requested by re. Added: stable/7/sys/dev/ale/ - copied from r184870, head/sys/dev/ale/ stable/7/sys/modules/ale/ - copied from r184870, head/sys/modules/ale/ Modified: stable/7/sys/ (props changed) stable/7/sys/amd64/conf/GENERIC stable/7/sys/boot/forth/loader.conf stable/7/sys/conf/NOTES stable/7/sys/conf/files stable/7/sys/i386/conf/GENERIC stable/7/sys/modules/Makefile stable/7/sys/modules/cxgb/ (props changed) Modified: stable/7/sys/amd64/conf/GENERIC ============================================================================== --- stable/7/sys/amd64/conf/GENERIC Sun Nov 23 23:26:12 2008 (r185237) +++ stable/7/sys/amd64/conf/GENERIC Mon Nov 24 00:52:26 2008 (r185238) @@ -194,6 +194,7 @@ device vx # 3Com 3c590, 3c595 (``Vorte # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! device miibus # MII bus support device age # Attansic/Atheros L1 Gigabit Ethernet +#device ale # Atheros AR8121/AR8113/AR8114 Ethernet device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet device bfe # Broadcom BCM440x 10/100 Ethernet device bge # Broadcom BCM570xx Gigabit Ethernet Modified: stable/7/sys/boot/forth/loader.conf ============================================================================== --- stable/7/sys/boot/forth/loader.conf Sun Nov 23 23:26:12 2008 (r185237) +++ stable/7/sys/boot/forth/loader.conf Mon Nov 24 00:52:26 2008 (r185238) @@ -208,6 +208,7 @@ pf_load="NO" # packet filter miibus_load="NO" # miibus support, needed for some drivers if_age_load="NO" # Attansic/Atheros L1 Gigabit Ethernet +if_ale_load="NO" # Atheros AR8121/AR8113/AR8114 Ethernet if_an_load="NO" # Aironet 4500/4800 802.11 wireless NICs if_ar_load="NO" # Digi SYNC/570i if_arl_load="NO" # Aironet Arlan 655 wireless network adapter Modified: stable/7/sys/conf/NOTES ============================================================================== --- stable/7/sys/conf/NOTES Sun Nov 23 23:26:12 2008 (r185237) +++ stable/7/sys/conf/NOTES Mon Nov 24 00:52:26 2008 (r185238) @@ -1724,6 +1724,7 @@ device miibus # Harris (Intersil) Chipset with PCnetMobile firmware by AMD. # age: Support for gigabit ethernet adapters based on the Attansic/Atheros # L1 PCI express gigabit ethernet controllers. +# ale: Support for Atheros AR8121/AR8113/AR8114 PCIe ethernet controllers. # bce: Broadcom NetXtreme II (BCM5706/BCM5708) PCI/PCIe Gigabit Ethernet # adapters. # bfe: Broadcom BCM4401 Ethernet adapter. @@ -1868,6 +1869,7 @@ device xe # PCI Ethernet NICs that use the common MII bus controller code. device ae # Attansic/Atheros L2 FastEthernet device age # Attansic/Atheros L1 Gigabit Ethernet +device ale # Atheros AR8121/AR8113/AR8114 Ethernet device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet device bfe # Broadcom BCM440x 10/100 Ethernet device bge # Broadcom BCM570xx Gigabit Ethernet Modified: stable/7/sys/conf/files ============================================================================== --- stable/7/sys/conf/files Sun Nov 23 23:26:12 2008 (r185237) +++ stable/7/sys/conf/files Mon Nov 24 00:52:26 2008 (r185238) @@ -446,6 +446,7 @@ dev/aic7xxx/aic7xxx.c optional ahc dev/aic7xxx/aic7xxx_93cx6.c optional ahc dev/aic7xxx/aic7xxx_osm.c optional ahc dev/aic7xxx/aic7xxx_pci.c optional ahc pci +dev/ale/if_ale.c optional ale pci dev/amd/amd.c optional amd dev/amr/amr.c optional amr dev/amr/amr_cam.c optional amr Modified: stable/7/sys/i386/conf/GENERIC ============================================================================== --- stable/7/sys/i386/conf/GENERIC Sun Nov 23 23:26:12 2008 (r185237) +++ stable/7/sys/i386/conf/GENERIC Mon Nov 24 00:52:26 2008 (r185238) @@ -204,6 +204,7 @@ device vx # 3Com 3c590, 3c595 (``Vorte # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! device miibus # MII bus support device age # Attansic/Atheros L1 Gigabit Ethernet +#device ale # Atheros AR8121/AR8113/AR8114 Ethernet device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet device bfe # Broadcom BCM440x 10/100 Ethernet device bge # Broadcom BCM570xx Gigabit Ethernet Modified: stable/7/sys/modules/Makefile ============================================================================== --- stable/7/sys/modules/Makefile Sun Nov 23 23:26:12 2008 (r185237) +++ stable/7/sys/modules/Makefile Mon Nov 24 00:52:26 2008 (r185238) @@ -17,6 +17,7 @@ SUBDIR= ${_3dfx} \ aic7xxx \ aio \ ${_amd} \ + ale \ amr \ ${_an} \ ${_aout} \ From yongari at FreeBSD.org Sun Nov 23 16:56:21 2008 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Sun Nov 23 16:56:31 2008 Subject: svn commit: r185239 - stable/7/usr.sbin/sysinstall Message-ID: <200811240056.mAO0uJDJ069238@svn.freebsd.org> Author: yongari Date: Mon Nov 24 00:56:19 2008 New Revision: 185239 URL: http://svn.freebsd.org/changeset/base/185239 Log: MFC r184871: Add ale(4) to the list of supported network interface. Approved by: re (kib) Modified: stable/7/usr.sbin/sysinstall/ (props changed) stable/7/usr.sbin/sysinstall/devices.c Modified: stable/7/usr.sbin/sysinstall/devices.c ============================================================================== --- stable/7/usr.sbin/sysinstall/devices.c Mon Nov 24 00:52:26 2008 (r185238) +++ stable/7/usr.sbin/sysinstall/devices.c Mon Nov 24 00:56:19 2008 (r185239) @@ -95,6 +95,7 @@ static struct _devname { SERIAL("cuad%d", "%s on device %s (COM%d)", 16), NETWORK("ae", "Attansic/Atheros L2 FastEthernet"), NETWORK("age", "Attansic/Atheros L1 Gigabit Ethernet"), + NETWORK("ale", "Atheros AR8121/AR8113/AR8114 PCIe Ethernet"), NETWORK("an", "Aironet 4500/4800 802.11 wireless adapter"), NETWORK("ath", "Atheros IEEE 802.11 wireless adapter"), NETWORK("aue", "ADMtek USB Ethernet adapter"), From yongari at FreeBSD.org Sun Nov 23 17:00:37 2008 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Sun Nov 23 17:01:07 2008 Subject: svn commit: r185240 - stable/7/share/man/man4 Message-ID: <200811240100.mAO10b9M069409@svn.freebsd.org> Author: yongari Date: Mon Nov 24 01:00:36 2008 New Revision: 185240 URL: http://svn.freebsd.org/changeset/base/185240 Log: MFC r184872-184873: Add ale(4) man page and hook up ale(4) to the build. Also add Xr to appropriate man pages. Approved by: re (kib) Added: stable/7/share/man/man4/ale.4 - copied unchanged from r184872, head/share/man/man4/ale.4 Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/Makefile stable/7/share/man/man4/altq.4 stable/7/share/man/man4/igb.4 (props changed) stable/7/share/man/man4/miibus.4 stable/7/share/man/man4/vlan.4 Modified: stable/7/share/man/man4/Makefile ============================================================================== --- stable/7/share/man/man4/Makefile Mon Nov 24 00:56:19 2008 (r185239) +++ stable/7/share/man/man4/Makefile Mon Nov 24 01:00:36 2008 (r185240) @@ -16,6 +16,7 @@ MAN= aac.4 \ ahc.4 \ ahd.4 \ aio.4 \ + ale.4 \ altq.4 \ amd.4 \ ${_amdsmb.4} \ Copied: stable/7/share/man/man4/ale.4 (from r184872, head/share/man/man4/ale.4) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/share/man/man4/ale.4 Mon Nov 24 01:00:36 2008 (r185240, copy of r184872, head/share/man/man4/ale.4) @@ -0,0 +1,162 @@ +.\" Copyright (c) 2008 Pyun YongHyeon +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 12, 2008 +.Dt ALE 4 +.Os +.Sh NAME +.Nm ale +.Nd Atheros AR8121/AR8113/AR8114 Gigabit/Fast Ethernet driver +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device miibus" +.Cd "device ale" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +if_ale_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +device driver provides support for Atheros AR8121 PCI Express +Gigabit Ethernet controller and Atheros AR8113/AR8114 PCI +Express Fast Ethernet controllers. +.Pp +All LOMs supported by the +.Nm +driver have TCP/UDP/IP checksum offload for both receive and transmit, +TCP segmentation offload (TSO), hardware VLAN tag stripping/insertion +features, Wake On Lan (WOL) and an interrupt coalescing/moderation +mechanism as well as a 64-bit multicast hash filter. +.Pp +The AR8121 also supports Jumbo Frames (up to 8132 bytes), which can +be configured via the interface MTU setting. +Selecting an MTU larger than 1500 bytes with the +.Xr ifconfig 8 +utility configures the adapter to receive and transmit Jumbo Frames. +.Pp +The +.Nm +driver supports the following media types: +.Bl -tag -width ".Cm 10baseT/UTP" +.It Cm autoselect +Enable autoselection of the media type and options. +The user can manually override +the autoselected mode by adding media options to +.Xr rc.conf 5 . +.It Cm 10baseT/UTP +Set 10Mbps operation. +.It Cm 100baseTX +Set 100Mbps (Fast Ethernet) operation. +.It Cm 1000baseTX +Set 1000baseTX operation over twisted pair. +.El +.Pp +The +.Nm +driver supports the following media options: +.Bl -tag -width ".Cm full-duplex" +.It Cm full-duplex +Force full duplex operation. +.It Cm half-duplex +Force half duplex operation. +.El +.Pp +For more information on configuring this device, see +.Xr ifconfig 8 . +.Sh HARDWARE +The +.Nm +device driver provides support for the following Ethernet controllers: +.Pp +.Bl -bullet -compact +.It +Atheros AR8113 PCI Express Fast Ethernet controller +.It +Atheros AR8114 PCI Express Fast Ethernet controller +.It +Atheros AR8121 PCI Express Gigabit Ethernet controller +.El +.Sh LOADER TUNABLES +Tunables can be set at the +.Xr loader 8 +prompt before booting the kernel or stored in +.Xr loader.conf 5 . +.Bl -tag -width "xxxxxx" +.It Va hw.ale.msi_disable +This tunable disables MSI support on the Ethernet hardware. +The default value is 0. +.It Va hw.ale.msix_disable +This tunable disables MSI-X support on the Ethernet hardware. +The default value is 0. +.El +.Sh SYSCTL VARIABLES +The following variables are available as both +.Xr sysctl 8 +variables and +.Xr loader 8 +tunables: +.Bl -tag -width "xxxxxx" +.It Va dev.ale.%d.int_rx_mod +Maximum amount of time to delay receive interrupt processing in +units of 1us. +The accepted range is 0 to 130000, the default is 30(30us). +Value 0 completely disables the interrupt moderation. +.It Va dev.ale.%d.int_tx_mod +Maximum amount of time to delay transmit interrupt processing in +units of 1us. +The accepted range is 0 to 130000, the default is 1000(1ms). +Value 0 completely disables the interrupt moderation. +.It Va dev.ale.%d.process_limit +Maximum amount of Rx frames to be processed in the event loop before +rescheduling a taskqueue. +The accepted range is 32 to 255, the default value is 128 events. +The interface does not need to be brought down and up again before +a change takes effect. +.El +.Sh SEE ALSO +.Xr altq 4 , +.Xr arp 4 , +.Xr miibus 4 , +.Xr netintro 4 , +.Xr ng_ether 4 , +.Xr vlan 4 , +.Xr ifconfig 8 +.Sh HISTORY +The +.Nm +driver was written by +.An Pyun YongHyeon +.Aq yongari@FreeBSD.org . +It first appeared in +.Fx 7.1 . Modified: stable/7/share/man/man4/altq.4 ============================================================================== --- stable/7/share/man/man4/altq.4 Mon Nov 24 00:56:19 2008 (r185239) +++ stable/7/share/man/man4/altq.4 Mon Nov 24 01:00:36 2008 (r185240) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 27, 2008 +.Dd November 12, 2008 .Dt ALTQ 4 .Os .Sh NAME @@ -116,6 +116,7 @@ are required to use a certain network ca .Nm . They have been applied to the following hardware drivers: .Xr age 4 , +.Xr ale 4 , .Xr an 4 , .Xr ath 4 , .Xr aue 4 , Modified: stable/7/share/man/man4/miibus.4 ============================================================================== --- stable/7/share/man/man4/miibus.4 Mon Nov 24 00:56:19 2008 (r185239) +++ stable/7/share/man/man4/miibus.4 Mon Nov 24 01:00:36 2008 (r185240) @@ -8,7 +8,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 20, 2008 +.Dd November 12, 2008 .Dt MIIBUS 4 .Os .Sh NAME @@ -47,6 +47,8 @@ interface: .Bl -tag -compact -width ".Xr fxp 4" .It Xr age 4 Attansic/Atheros L1 Gigabit Ethernet +.It Xr ale 4 +Atheros AR8121/AR8113/AR8114 PCIe Ethernet .It Xr aue 4 ADMtek USB Ethernet .It Xr axe 4 @@ -125,6 +127,7 @@ and but as a result are not well behaved newbus device drivers. .Sh SEE ALSO .Xr age 4 , +.Xr ale 4 , .Xr arp 4 , .Xr aue 4 , .Xr axe 4 , Modified: stable/7/share/man/man4/vlan.4 ============================================================================== --- stable/7/share/man/man4/vlan.4 Mon Nov 24 00:56:19 2008 (r185239) +++ stable/7/share/man/man4/vlan.4 Mon Nov 24 01:00:36 2008 (r185240) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 27, 2008 +.Dd November 12, 2008 .Dt VLAN 4 .Os .Sh NAME @@ -124,6 +124,7 @@ By now, the list of physical interfaces in the hardware is limited to the following devices: .Xr ae 4 , .Xr age 4 , +.Xr ale 4 , .Xr bce 4 , .Xr bge 4 , .Xr cxgb 4 , From yongari at FreeBSD.org Mon Nov 24 03:22:26 2008 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Mon Nov 24 03:22:33 2008 Subject: svn commit: r185249 - in stable/7/sys: . dev/vr modules/cxgb Message-ID: <200811241122.mAOBMQr1085870@svn.freebsd.org> Author: yongari Date: Mon Nov 24 11:22:25 2008 New Revision: 185249 URL: http://svn.freebsd.org/changeset/base/185249 Log: MFC r185014: Fix typo. It restuled in activating unwanted Rx filtering as well as resetting Rx threshold configuration. Submitted by: Joost Mulders < Joost.Mulders <> Sun DOT COM > Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/dev/vr/if_vr.c stable/7/sys/modules/cxgb/ (props changed) Modified: stable/7/sys/dev/vr/if_vr.c ============================================================================== --- stable/7/sys/dev/vr/if_vr.c Mon Nov 24 11:07:25 2008 (r185248) +++ stable/7/sys/dev/vr/if_vr.c Mon Nov 24 11:22:25 2008 (r185249) @@ -465,7 +465,8 @@ vr_set_filter(struct vr_softc *sc) ifp = sc->vr_ifp; rxfilt = CSR_READ_1(sc, VR_RXCFG); - rxfilt = ~(VR_RXCFG_RX_PROMISC | VR_RXCFG_RX_BROAD | VR_RXCFG_RX_MULTI); + rxfilt &= ~(VR_RXCFG_RX_PROMISC | VR_RXCFG_RX_BROAD | + VR_RXCFG_RX_MULTI); if (ifp->if_flags & IFF_BROADCAST) rxfilt |= VR_RXCFG_RX_BROAD; if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) { From cperciva at FreeBSD.org Mon Nov 24 09:39:40 2008 From: cperciva at FreeBSD.org (Colin Percival) Date: Mon Nov 24 09:39:57 2008 Subject: svn commit: r185254 - head/sys/dev/random releng/6.3 releng/6.3/sys/conf releng/6.3/sys/dev/random releng/6.4 releng/6.4/sys/dev/random releng/7.0 releng/7.0/sys/conf releng/7.0/sys/dev/random stab... Message-ID: <200811241739.mAOHdeiR093565@svn.freebsd.org> Author: cperciva Date: Mon Nov 24 17:39:39 2008 New Revision: 185254 URL: http://svn.freebsd.org/changeset/base/185254 Log: Make sure arc4random(9) is properly seeded when /etc/rc.d/initrandom returns. Approved by: so (cperciva) Approved by: re (kensmith) Security: FreeBSD-SA-08:11.arc4random Modified: stable/7/sys/dev/random/randomdev.c stable/7/sys/dev/random/randomdev_soft.c Changes in other areas also in this revision: Modified: head/sys/dev/random/randomdev.c head/sys/dev/random/randomdev_soft.c releng/6.3/UPDATING releng/6.3/sys/conf/newvers.sh releng/6.3/sys/dev/random/randomdev.c releng/6.3/sys/dev/random/randomdev_soft.c releng/6.4/UPDATING releng/6.4/sys/dev/random/randomdev.c releng/6.4/sys/dev/random/randomdev_soft.c releng/7.0/UPDATING releng/7.0/sys/conf/newvers.sh releng/7.0/sys/dev/random/randomdev.c releng/7.0/sys/dev/random/randomdev_soft.c stable/6/sys/dev/random/randomdev.c stable/6/sys/dev/random/randomdev_soft.c Modified: stable/7/sys/dev/random/randomdev.c ============================================================================== --- stable/7/sys/dev/random/randomdev.c Mon Nov 24 17:34:00 2008 (r185253) +++ stable/7/sys/dev/random/randomdev.c Mon Nov 24 17:39:39 2008 (r185254) @@ -90,6 +90,7 @@ random_close(struct cdev *dev __unused, && (securelevel_gt(td->td_ucred, 0) == 0)) { (*random_systat.reseed)(); random_systat.seeded = 1; + arc4rand(NULL, 0, 1); /* Reseed arc4random as well. */ } return (0); Modified: stable/7/sys/dev/random/randomdev_soft.c ============================================================================== --- stable/7/sys/dev/random/randomdev_soft.c Mon Nov 24 17:34:00 2008 (r185253) +++ stable/7/sys/dev/random/randomdev_soft.c Mon Nov 24 17:39:39 2008 (r185254) @@ -61,6 +61,7 @@ random_harvest_internal(u_int64_t, const u_int, u_int, enum esource); static int random_yarrow_poll(int event,struct thread *td); static int random_yarrow_block(int flag); +static void random_yarrow_flush_reseed(void); struct random_systat random_yarrow = { .ident = "Software, Yarrow", @@ -70,7 +71,7 @@ struct random_systat random_yarrow = { .read = random_yarrow_read, .write = random_yarrow_write, .poll = random_yarrow_poll, - .reseed = random_yarrow_reseed, + .reseed = random_yarrow_flush_reseed, .seeded = 1, }; @@ -96,7 +97,7 @@ static struct entropyfifo emptyfifo; /* Harvested entropy */ static struct entropyfifo harvestfifo[ENTROPYSOURCE]; -/* <0 to end the kthread, 0 to let it run */ +/* <0 to end the kthread, 0 to let it run, 1 to flush the harvest queues */ static int random_kthread_control = 0; static struct proc *random_kthread_proc; @@ -241,7 +242,7 @@ random_kthread(void *arg __unused) local_count = 0; /* Process until told to stop */ - for (; random_kthread_control == 0;) { + for (; random_kthread_control >= 0;) { active = 0; @@ -276,6 +277,13 @@ random_kthread(void *arg __unused) KASSERT(local_count == 0, ("random_kthread: local_count %d", local_count)); + /* + * If a queue flush was commanded, it has now happened, + * and we can mark this by resetting the command. + */ + if (random_kthread_control == 1) + random_kthread_control = 0; + /* Found nothing, so don't belabour the issue */ if (!active) pause("-", hz / 10); @@ -400,3 +408,15 @@ random_yarrow_block(int flag) return error; } + +/* Helper routine to perform explicit reseeds */ +static void +random_yarrow_flush_reseed(void) +{ + /* Command a entropy queue flush and wait for it to finish */ + random_kthread_control = 1; + while (random_kthread_control) + pause("-", hz / 10); + + random_yarrow_reseed(); +} From brueffer at FreeBSD.org Mon Nov 24 11:52:20 2008 From: brueffer at FreeBSD.org (Christian Brueffer) Date: Mon Nov 24 11:52:31 2008 Subject: svn commit: r185257 - stable/7/share/man/man4 Message-ID: <200811241952.mAOJqKX1096359@svn.freebsd.org> Author: brueffer Date: Mon Nov 24 19:52:19 2008 New Revision: 185257 URL: http://svn.freebsd.org/changeset/base/185257 Log: MFC r184523 - Add one more supported adapter - Fix a couple of typos Approved by: re (kensmith) Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/igb.4 (props changed) stable/7/share/man/man4/zyd.4 Modified: stable/7/share/man/man4/zyd.4 ============================================================================== --- stable/7/share/man/man4/zyd.4 Mon Nov 24 19:28:52 2008 (r185256) +++ stable/7/share/man/man4/zyd.4 Mon Nov 24 19:52:19 2008 (r185257) @@ -32,7 +32,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF .\" THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 6, 2007 +.Dd November 1, 2008 .Dt ZYD 4 .Os .Sh NAME @@ -103,7 +103,7 @@ driver: .It Airlink+ AWLL3025 .It Airlink 101 AWLL3026 .It AOpen 802.11g WL54 -.It Asus A9T integrated wirless +.It Asus A9T integrated wireless .It Asus WL-159g .It Belkin F5D7050 v.4000 .It Billion BiPAC 3011G @@ -117,6 +117,7 @@ driver: .It Linksys WUSBF54G .It Longshine LCS-8131G3 .It MSI US54SE +.It MyTek MWU-201 USB adapter .It Philips SNU5600 .It Planet WL-U356 .It Planex GW-US54GZ @@ -143,7 +144,7 @@ driver: .El .Sh EXAMPLES The following -examples configures zyd0 to join whatever network is available on boot, +example configures zyd0 to join whatever network is available on boot, using WEP key .Dq 0x1deadbeef1 , channel 11: From delphij at FreeBSD.org Mon Nov 24 12:05:15 2008 From: delphij at FreeBSD.org (Xin LI) Date: Mon Nov 24 12:05:34 2008 Subject: svn commit: r185258 - in stable/7/release/doc/en_US.ISO8859-1: hardware relnotes Message-ID: <200811242005.mAOK5EFj096674@svn.freebsd.org> Author: delphij Date: Mon Nov 24 20:05:14 2008 New Revision: 185258 URL: http://svn.freebsd.org/changeset/base/185258 Log: MFC: Document ale(4), mention that it is not present in GENERIC kernel for this release. Approved by: re (blackend) Modified: stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml stable/7/release/doc/en_US.ISO8859-1/relnotes/article.sgml Modified: stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml ============================================================================== --- stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml Mon Nov 24 19:52:19 2008 (r185257) +++ stable/7/release/doc/en_US.ISO8859-1/hardware/article.sgml Mon Nov 24 20:05:14 2008 (r185258) @@ -615,6 +615,8 @@ Ethernet Interfaces + &hwlist.ale; + &hwlist.aue; &hwlist.axe; Modified: stable/7/release/doc/en_US.ISO8859-1/relnotes/article.sgml ============================================================================== --- stable/7/release/doc/en_US.ISO8859-1/relnotes/article.sgml Mon Nov 24 19:52:19 2008 (r185257) +++ stable/7/release/doc/en_US.ISO8859-1/relnotes/article.sgml Mon Nov 24 20:05:14 2008 (r185258) @@ -198,6 +198,11 @@ Network Interface Support + The &man.ale.4; driver has been added to provide support + for Atheros AR8121/AR8113/AR8114 Gigabit/Fast Ethernet controllers. + This driver is not enabled in GENERIC + kernels for this release. + The &man.em.4; driver has been split into two drivers with some common parts. The &man.em.4; driver will continue to support adapters up to the 82575, as well as new From delphij at FreeBSD.org Mon Nov 24 13:09:06 2008 From: delphij at FreeBSD.org (Xin LI) Date: Mon Nov 24 13:09:17 2008 Subject: svn commit: r185261 - in stable/7/release/doc/zh_CN.GB2312: hardware relnotes Message-ID: <200811242109.mAOL95vh098288@svn.freebsd.org> Author: delphij Date: Mon Nov 24 21:09:05 2008 New Revision: 185261 URL: http://svn.freebsd.org/changeset/base/185261 Log: MFen rev 185258: Document ale(4). Approved by: re (blackend) Modified: stable/7/release/doc/zh_CN.GB2312/hardware/article.sgml stable/7/release/doc/zh_CN.GB2312/relnotes/article.sgml Modified: stable/7/release/doc/zh_CN.GB2312/hardware/article.sgml ============================================================================== --- stable/7/release/doc/zh_CN.GB2312/hardware/article.sgml Mon Nov 24 21:08:43 2008 (r185260) +++ stable/7/release/doc/zh_CN.GB2312/hardware/article.sgml Mon Nov 24 21:09:05 2008 (r185261) @@ -392,7 +392,7 @@ - + @@ -183,6 +183,11 @@ ÍøÂç½Ó¿ÚÖ§³Ö + ÐÂÔöÁËÓÃÓÚÖ§³Ö + Atheros AR8121/AR8113/AR8114 ǧÕ×/°ÙÕ×ÒÔÌ«Íø¿ØÖÆÆ÷µÄ &man.ale.4; Çý¶¯³ÌÐò¡£ + ÔÚÕâÒ»°æ±¾ÖÐµÄ GENERIC + ÄÚºËÖÐĬÈϲ¢²»°üº¬´ËÇý¶¯¡£ + ½« &man.em.4; Çý¶¯³ÌÐò·Ö²ð³ÉÁËÁ½¸ö¹²Ïí²¿·Ö´úÂëµÄÇý¶¯³ÌÐò¡£ &man.em.4; Çý¶¯³ÌÐò½«¼ÌÐøÖ§³Ö¸ßÖÁ 82575 µÄÍø¿¨ÒÔ¼°ÐµÄÕë¶Ô¿Í»§»ú/×ÀÃæµÄÍø¿¨¡£ ÐÂÔöµÄ &man.igb.4; Çý¶¯³ÌÐòÔòÓÃÓÚÖ§³ÖеķþÎñÆ÷Íø¿¨¡£ From kensmith at FreeBSD.org Tue Nov 25 09:27:12 2008 From: kensmith at FreeBSD.org (Ken Smith) Date: Tue Nov 25 09:27:17 2008 Subject: svn commit: r185301 - stable/7/release Message-ID: <200811251727.mAPHRBNt029758@svn.freebsd.org> Author: kensmith Date: Tue Nov 25 17:27:11 2008 New Revision: 185301 URL: http://svn.freebsd.org/changeset/base/185301 Log: With the branch for 7.1 done start bumping misc. version numbers from 7.0 to 7.1. Approved by: re (implicit) Modified: stable/7/release/Makefile Modified: stable/7/release/Makefile ============================================================================== --- stable/7/release/Makefile Tue Nov 25 16:38:10 2008 (r185300) +++ stable/7/release/Makefile Tue Nov 25 17:27:11 2008 (r185301) @@ -18,11 +18,11 @@ # Set these, release builder! # # Fixed version: -#BUILDNAME=7.0-STABLE +#BUILDNAME=7.1-STABLE # # Automatic SNAP versioning: DATE != date +%Y%m%d -BASE = 7.0 +BASE = 7.1 BUILDNAME?=${BASE}-${DATE}-SNAP # #CHROOTDIR=/junk/release From kensmith at FreeBSD.org Tue Nov 25 09:31:45 2008 From: kensmith at FreeBSD.org (Ken Smith) Date: Tue Nov 25 09:32:02 2008 Subject: svn commit: r185302 - stable/7/sys/sys Message-ID: <200811251731.mAPHVjLB029888@svn.freebsd.org> Author: kensmith Date: Tue Nov 25 17:31:45 2008 New Revision: 185302 URL: http://svn.freebsd.org/changeset/base/185302 Log: Bump __FreeBSD_version for 7.1. Approved by: re (implicit) Modified: stable/7/sys/sys/param.h Modified: stable/7/sys/sys/param.h ============================================================================== --- stable/7/sys/sys/param.h Tue Nov 25 17:27:11 2008 (r185301) +++ stable/7/sys/sys/param.h Tue Nov 25 17:31:45 2008 (r185302) @@ -57,7 +57,7 @@ * is created, otherwise 1. */ #undef __FreeBSD_version -#define __FreeBSD_version 700112 /* Master, propagated to newvers */ +#define __FreeBSD_version 701100 /* Master, propagated to newvers */ #ifndef LOCORE #include From kensmith at FreeBSD.org Tue Nov 25 09:34:36 2008 From: kensmith at FreeBSD.org (Ken Smith) Date: Tue Nov 25 09:34:53 2008 Subject: svn commit: r185303 - stable/7/usr.sbin/pkg_install/add Message-ID: <200811251734.mAPHYabD029998@svn.freebsd.org> Author: kensmith Date: Tue Nov 25 17:34:36 2008 New Revision: 185303 URL: http://svn.freebsd.org/changeset/base/185303 Log: Add FreeBSD_version and package directory for 7.1. Approved by: re (implicit) Modified: stable/7/usr.sbin/pkg_install/add/main.c Modified: stable/7/usr.sbin/pkg_install/add/main.c ============================================================================== --- stable/7/usr.sbin/pkg_install/add/main.c Tue Nov 25 17:31:45 2008 (r185302) +++ stable/7/usr.sbin/pkg_install/add/main.c Tue Nov 25 17:34:36 2008 (r185303) @@ -79,6 +79,7 @@ struct { { 602000, 602099, "/packages-6.2-release" }, { 603000, 603099, "/packages-6.3-release" }, { 700000, 700099, "/packages-7.0-release" }, + { 701000, 701099, "/packages-7.1-release" }, { 300000, 399000, "/packages-3-stable" }, { 400000, 499000, "/packages-4-stable" }, { 502100, 502128, "/packages-5-current" }, From julian at FreeBSD.org Tue Nov 25 11:26:37 2008 From: julian at FreeBSD.org (Julian Elischer) Date: Tue Nov 25 11:26:44 2008 Subject: svn commit: r185311 - in stable/7/sys: kern netinet Message-ID: <200811251926.mAPJQbqY032613@svn.freebsd.org> Author: julian Date: Tue Nov 25 19:26:36 2008 New Revision: 185311 URL: http://svn.freebsd.org/changeset/base/185311 Log: MFC @ 185101 Fix a scope problem in the multiple routing table code that stopped the SO_SETFIB socket option from working correctly. Approved by: re (kensmith, kostik) Obtained from: Ironport Modified: stable/7/sys/kern/uipc_socket.c stable/7/sys/netinet/ip_divert.c stable/7/sys/netinet/ip_output.c stable/7/sys/netinet/raw_ip.c Modified: stable/7/sys/kern/uipc_socket.c ============================================================================== --- stable/7/sys/kern/uipc_socket.c Tue Nov 25 19:25:54 2008 (r185310) +++ stable/7/sys/kern/uipc_socket.c Tue Nov 25 19:26:36 2008 (r185311) @@ -2218,6 +2218,9 @@ sosetopt(struct socket *so, struct socko if ((so->so_proto->pr_domain->dom_family == PF_INET) || (so->so_proto->pr_domain->dom_family == PF_ROUTE)) { so->so_fibnum = optval; + /* Note: ignore error */ + if (so->so_proto && so->so_proto->pr_ctloutput) + (*so->so_proto->pr_ctloutput)(so, sopt); } else { so->so_fibnum = 0; } Modified: stable/7/sys/netinet/ip_divert.c ============================================================================== --- stable/7/sys/netinet/ip_divert.c Tue Nov 25 19:25:54 2008 (r185310) +++ stable/7/sys/netinet/ip_divert.c Tue Nov 25 19:26:36 2008 (r185311) @@ -314,6 +314,7 @@ div_output(struct socket *so, struct mbu */ m->m_pkthdr.rcvif = NULL; m->m_nextpkt = NULL; + M_SETFIB(m, so->so_fibnum); if (control) m_freem(control); /* XXX */ Modified: stable/7/sys/netinet/ip_output.c ============================================================================== --- stable/7/sys/netinet/ip_output.c Tue Nov 25 19:25:54 2008 (r185310) +++ stable/7/sys/netinet/ip_output.c Tue Nov 25 19:26:36 2008 (r185311) @@ -125,8 +125,10 @@ ip_output(struct mbuf *m, struct mbuf *o bzero(ro, sizeof (*ro)); } - if (inp != NULL) + if (inp != NULL) { + M_SETFIB(m, inp->inp_inc.inc_fibnum); INP_LOCK_ASSERT(inp); + } if (opt) { len = 0; @@ -808,6 +810,11 @@ ip_ctloutput(struct socket *so, struct s error = optval = 0; if (sopt->sopt_level != IPPROTO_IP) { + if ((sopt->sopt_level == SOL_SOCKET) && + (sopt->sopt_name == SO_SETFIB)) { + inp->inp_inc.inc_fibnum = so->so_fibnum; + return (0); + } return (EINVAL); } Modified: stable/7/sys/netinet/raw_ip.c ============================================================================== --- stable/7/sys/netinet/raw_ip.c Tue Nov 25 19:25:54 2008 (r185310) +++ stable/7/sys/netinet/raw_ip.c Tue Nov 25 19:26:36 2008 (r185311) @@ -441,8 +441,14 @@ rip_ctloutput(struct socket *so, struct struct inpcb *inp = sotoinpcb(so); int error, optval; - if (sopt->sopt_level != IPPROTO_IP) + if (sopt->sopt_level != IPPROTO_IP) { + if ((sopt->sopt_level == SOL_SOCKET) && + (sopt->sopt_name == SO_SETFIB)) { + inp->inp_inc.inc_fibnum = so->so_fibnum; + return (0); + } return (EINVAL); + } error = 0; switch (sopt->sopt_dir) { From cmdlnkid at gmail.com Wed Nov 26 07:23:46 2008 From: cmdlnkid at gmail.com (CmdLnKid) Date: Wed Nov 26 07:23:52 2008 Subject: svn commit: r185238 - in stable/7/sys: . amd64/conf boot/forth conf dev/ale i386/conf modules modules/ale modules/cxgb Message-ID: <492D669B.7010008@gmail.com> I don't suppose any support for the WMP110 which reports as Atheros will be added before the release of 7.1. data sheet. http://www.linksys.com/servlet/Satellite?c=L_CASupport_C2&childpagename=US%2FLayout&cid=1$ ndis0@pci0:1:8:0: class=0x028000 card=0x00721737 chip=0x0023168c rev=0x01 hdr=0x00 vendor = 'Atheros Communications Inc.' device = 'AR5008 Wireless Network Adapter' class = network as you can tell it works great under NDIS but I would rather see a resolve with a native driver. Best regards, CmdLnKid - J. Hellenthal From cmdlnkid at gmail.com Wed Nov 26 07:43:49 2008 From: cmdlnkid at gmail.com (CmdLnKid) Date: Wed Nov 26 07:43:55 2008 Subject: svn commit: r185238 - in stable/7/sys: . amd64/conf boot/forth conf dev/ale i386/conf modules modules/ale modules/cxgb In-Reply-To: <492D669B.7010008@gmail.com> References: <492D669B.7010008@gmail.com> Message-ID: <492D677E.7020104@gmail.com> CmdLnKid wrote: > I don't suppose any support for the WMP110 which reports as Atheros will > be added before the release of 7.1. > > data sheet. > http://www.linksys.com/servlet/Satellite?c=L_CASupport_C2&childpagename=US%2FLayout&cid=1$ > > > ndis0@pci0:1:8:0: class=0x028000 card=0x00721737 chip=0x0023168c > rev=0x01 hdr=0x00 > vendor = 'Atheros Communications Inc.' > device = 'AR5008 Wireless Network Adapter' > class = network > > as you can tell it works great under NDIS but I would rather see a > resolve with a native driver. > > Best regards, > CmdLnKid - J. Hellenthal Sorry for the broken link. Here it is again. http://www.linksys.com/servlet/Satellite?c=L_CASupport_C2&childpagename=US%2FLayout&cid=1175244795392&pagename=Linksys%2FCommon%2FVisitorWrapper&lid=9539240888B11&displaypage=download#versiondetail From sam at freebsd.org Wed Nov 26 08:44:20 2008 From: sam at freebsd.org (Sam Leffler) Date: Wed Nov 26 08:44:26 2008 Subject: svn commit: r185238 - in stable/7/sys: . amd64/conf boot/forth conf dev/ale i386/conf modules modules/ale modules/cxgb In-Reply-To: <492D669B.7010008@gmail.com> References: <492D669B.7010008@gmail.com> Message-ID: <492D77B9.6090104@freebsd.org> CmdLnKid wrote: > I don't suppose any support for the WMP110 which reports as Atheros will > be added before the release of 7.1. > > data sheet. > http://www.linksys.com/servlet/Satellite?c=L_CASupport_C2&childpagename=US%2FLayout&cid=1$ > > > ndis0@pci0:1:8:0: class=0x028000 card=0x00721737 chip=0x0023168c > rev=0x01 hdr=0x00 > vendor = 'Atheros Communications Inc.' > device = 'AR5008 Wireless Network Adapter' > class = network > > as you can tell it works great under NDIS but I would rather see a > resolve with a native driver. > Definitely not before 7.1. Sam From peter at FreeBSD.org Wed Nov 26 11:22:09 2008 From: peter at FreeBSD.org (Peter Wemm) Date: Wed Nov 26 11:22:20 2008 Subject: svn commit: r185340 - stable/7/sys/modules/cxgb Message-ID: <200811261922.mAQJM8bQ063958@svn.freebsd.org> Author: peter Date: Wed Nov 26 19:22:08 2008 New Revision: 185340 URL: http://svn.freebsd.org/changeset/base/185340 Log: Remove zombie mergeinfo that Julian brought back to life in rev 184739. Submitted by: bz Approved by: re (implicit) Modified: stable/7/sys/modules/cxgb/ (props changed) From bz at FreeBSD.org Wed Nov 26 14:36:35 2008 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Nov 26 14:36:41 2008 Subject: svn commit: r185350 - in stable/7/sys: . netinet6 Message-ID: <200811262236.mAQMaZsm068357@svn.freebsd.org> Author: bz Date: Wed Nov 26 22:36:35 2008 New Revision: 185350 URL: http://svn.freebsd.org/changeset/base/185350 Log: MFC: r185332 Plug a credential leak in case the inpcb is freed by in6_pcbfree() instead of in_pcbfree(); missed in r183606. Approved by: re (gnn) Modified: stable/7/sys/ (props changed) stable/7/sys/netinet6/in6_pcb.c Modified: stable/7/sys/netinet6/in6_pcb.c ============================================================================== --- stable/7/sys/netinet6/in6_pcb.c Wed Nov 26 22:33:55 2008 (r185349) +++ stable/7/sys/netinet6/in6_pcb.c Wed Nov 26 22:36:35 2008 (r185350) @@ -437,6 +437,7 @@ in6_pcbfree(struct inpcb *inp) if (inp->inp_moptions != NULL) inp_freemoptions(inp->inp_moptions); inp->inp_vflag = 0; + crfree(inp->inp_cred); #ifdef MAC mac_destroy_inpcb(inp); #endif From kientzle at FreeBSD.org Fri Nov 28 12:08:48 2008 From: kientzle at FreeBSD.org (Tim Kientzle) Date: Fri Nov 28 12:09:07 2008 Subject: svn commit: r185408 - in stable/7/lib/libarchive: . test Message-ID: <200811282008.mASK8l6H028595@svn.freebsd.org> Author: kientzle Date: Fri Nov 28 20:08:47 2008 New Revision: 185408 URL: http://svn.freebsd.org/changeset/base/185408 Log: MFC 182590,182778,182779,184109: Support for certain archive_entry attributes to be explicitly "unset". This fixes a number of issues: * Zip archives with "length at end" can now be extracted correctly, since the Zip extractor can simply mark the size as "unknown." * Extract-to-disk can now accurately handle cases with partial time information (e.g., mtime is known but not atime) * We get more accurate handling of different hardlink extraction cases; sometimes a hardlink entry has definitive size information and sometimes not. Approved by: re Modified: stable/7/lib/libarchive/ (props changed) stable/7/lib/libarchive/archive_entry.c stable/7/lib/libarchive/archive_entry.h stable/7/lib/libarchive/archive_entry_private.h stable/7/lib/libarchive/archive_read_support_format_zip.c stable/7/lib/libarchive/archive_write_disk.c stable/7/lib/libarchive/test/test_entry.c stable/7/lib/libarchive/test/test_read_format_zip.c stable/7/lib/libarchive/test/test_read_format_zip.zip.uu stable/7/lib/libarchive/test/test_write_disk.c stable/7/lib/libarchive/test/test_write_disk_hardlink.c Modified: stable/7/lib/libarchive/archive_entry.c ============================================================================== --- stable/7/lib/libarchive/archive_entry.c Fri Nov 28 19:58:31 2008 (r185407) +++ stable/7/lib/libarchive/archive_entry.c Fri Nov 28 20:08:47 2008 (r185408) @@ -395,8 +395,7 @@ archive_entry_clone(struct archive_entry aes_copy(&entry2->ae_hardlink, &entry->ae_hardlink); aes_copy(&entry2->ae_pathname, &entry->ae_pathname); aes_copy(&entry2->ae_symlink, &entry->ae_symlink); - entry2->ae_hardlinkset = entry->ae_hardlinkset; - entry2->ae_symlinkset = entry->ae_symlinkset; + entry2->ae_set = entry->ae_set; aes_copy(&entry2->ae_uname, &entry->ae_uname); /* Copy ACL data over. */ @@ -455,12 +454,24 @@ archive_entry_atime_nsec(struct archive_ return (entry->ae_stat.aest_atime_nsec); } +int +archive_entry_atime_is_set(struct archive_entry *entry) +{ + return (entry->ae_set & AE_SET_ATIME); +} + time_t archive_entry_ctime(struct archive_entry *entry) { return (entry->ae_stat.aest_ctime); } +int +archive_entry_ctime_is_set(struct archive_entry *entry) +{ + return (entry->ae_set & AE_SET_CTIME); +} + long archive_entry_ctime_nsec(struct archive_entry *entry) { @@ -562,17 +573,17 @@ archive_entry_gname_w(struct archive_ent const char * archive_entry_hardlink(struct archive_entry *entry) { - if (!entry->ae_hardlinkset) - return (NULL); - return (aes_get_mbs(&entry->ae_hardlink)); + if (entry->ae_set & AE_SET_HARDLINK) + return (aes_get_mbs(&entry->ae_hardlink)); + return (NULL); } const wchar_t * archive_entry_hardlink_w(struct archive_entry *entry) { - if (!entry->ae_hardlinkset) - return (NULL); - return (aes_get_wcs(&entry->ae_hardlink)); + if (entry->ae_set & AE_SET_HARDLINK) + return (aes_get_wcs(&entry->ae_hardlink)); + return (NULL); } ino_t @@ -599,6 +610,12 @@ archive_entry_mtime_nsec(struct archive_ return (entry->ae_stat.aest_mtime_nsec); } +int +archive_entry_mtime_is_set(struct archive_entry *entry) +{ + return (entry->ae_set & AE_SET_MTIME); +} + unsigned int archive_entry_nlink(struct archive_entry *entry) { @@ -651,6 +668,12 @@ archive_entry_size(struct archive_entry return (entry->ae_stat.aest_size); } +int +archive_entry_size_is_set(struct archive_entry *entry) +{ + return (entry->ae_set & AE_SET_SIZE); +} + const char * archive_entry_sourcepath(struct archive_entry *entry) { @@ -660,17 +683,17 @@ archive_entry_sourcepath(struct archive_ const char * archive_entry_symlink(struct archive_entry *entry) { - if (!entry->ae_symlinkset) - return (NULL); - return (aes_get_mbs(&entry->ae_symlink)); + if (entry->ae_set & AE_SET_SYMLINK) + return (aes_get_mbs(&entry->ae_symlink)); + return (NULL); } const wchar_t * archive_entry_symlink_w(struct archive_entry *entry) { - if (!entry->ae_symlinkset) - return (NULL); - return (aes_get_wcs(&entry->ae_symlink)); + if (entry->ae_set & AE_SET_SYMLINK) + return (aes_get_wcs(&entry->ae_symlink)); + return (NULL); } uid_t @@ -773,7 +796,9 @@ archive_entry_set_hardlink(struct archiv { aes_set_mbs(&entry->ae_hardlink, target); if (target != NULL) - entry->ae_hardlinkset = 1; + entry->ae_set |= AE_SET_HARDLINK; + else + entry->ae_set &= ~AE_SET_HARDLINK; } void @@ -781,7 +806,9 @@ archive_entry_copy_hardlink(struct archi { aes_copy_mbs(&entry->ae_hardlink, target); if (target != NULL) - entry->ae_hardlinkset = 1; + entry->ae_set |= AE_SET_HARDLINK; + else + entry->ae_set &= ~AE_SET_HARDLINK; } void @@ -789,26 +816,44 @@ archive_entry_copy_hardlink_w(struct arc { aes_copy_wcs(&entry->ae_hardlink, target); if (target != NULL) - entry->ae_hardlinkset = 1; + entry->ae_set |= AE_SET_HARDLINK; + else + entry->ae_set &= ~AE_SET_HARDLINK; } void archive_entry_set_atime(struct archive_entry *entry, time_t t, long ns) { entry->stat_valid = 0; + entry->ae_set |= AE_SET_ATIME; entry->ae_stat.aest_atime = t; entry->ae_stat.aest_atime_nsec = ns; } void +archive_entry_unset_atime(struct archive_entry *entry) +{ + archive_entry_set_atime(entry, 0, 0); + entry->ae_set &= ~AE_SET_ATIME; +} + +void archive_entry_set_ctime(struct archive_entry *entry, time_t t, long ns) { entry->stat_valid = 0; + entry->ae_set |= AE_SET_CTIME; entry->ae_stat.aest_ctime = t; entry->ae_stat.aest_ctime_nsec = ns; } void +archive_entry_unset_ctime(struct archive_entry *entry) +{ + archive_entry_set_ctime(entry, 0, 0); + entry->ae_set &= ~AE_SET_CTIME; +} + +void archive_entry_set_dev(struct archive_entry *entry, dev_t d) { entry->stat_valid = 0; @@ -836,7 +881,7 @@ archive_entry_set_devminor(struct archiv void archive_entry_set_link(struct archive_entry *entry, const char *target) { - if (entry->ae_symlinkset) + if (entry->ae_set & AE_SET_SYMLINK) aes_set_mbs(&entry->ae_symlink, target); else aes_set_mbs(&entry->ae_hardlink, target); @@ -846,7 +891,7 @@ archive_entry_set_link(struct archive_en void archive_entry_copy_link(struct archive_entry *entry, const char *target) { - if (entry->ae_symlinkset) + if (entry->ae_set & AE_SET_SYMLINK) aes_copy_mbs(&entry->ae_symlink, target); else aes_copy_mbs(&entry->ae_hardlink, target); @@ -856,7 +901,7 @@ archive_entry_copy_link(struct archive_e void archive_entry_copy_link_w(struct archive_entry *entry, const wchar_t *target) { - if (entry->ae_symlinkset) + if (entry->ae_set & AE_SET_SYMLINK) aes_copy_wcs(&entry->ae_symlink, target); else aes_copy_wcs(&entry->ae_hardlink, target); @@ -865,7 +910,7 @@ archive_entry_copy_link_w(struct archive int archive_entry_update_link_utf8(struct archive_entry *entry, const char *target) { - if (entry->ae_symlinkset) + if (entry->ae_set & AE_SET_SYMLINK) return (aes_update_utf8(&entry->ae_symlink, target)); else return (aes_update_utf8(&entry->ae_hardlink, target)); @@ -882,11 +927,19 @@ void archive_entry_set_mtime(struct archive_entry *entry, time_t m, long ns) { entry->stat_valid = 0; + entry->ae_set |= AE_SET_MTIME; entry->ae_stat.aest_mtime = m; entry->ae_stat.aest_mtime_nsec = ns; } void +archive_entry_unset_mtime(struct archive_entry *entry) +{ + archive_entry_set_mtime(entry, 0, 0); + entry->ae_set &= ~AE_SET_MTIME; +} + +void archive_entry_set_nlink(struct archive_entry *entry, unsigned int nlink) { entry->stat_valid = 0; @@ -954,6 +1007,14 @@ archive_entry_set_size(struct archive_en { entry->stat_valid = 0; entry->ae_stat.aest_size = s; + entry->ae_set |= AE_SET_SIZE; +} + +void +archive_entry_unset_size(struct archive_entry *entry) +{ + archive_entry_set_size(entry, 0); + entry->ae_set &= ~AE_SET_SIZE; } void @@ -967,7 +1028,9 @@ archive_entry_set_symlink(struct archive { aes_set_mbs(&entry->ae_symlink, linkname); if (linkname != NULL) - entry->ae_symlinkset = 1; + entry->ae_set |= AE_SET_SYMLINK; + else + entry->ae_set &= ~AE_SET_SYMLINK; } void @@ -975,7 +1038,9 @@ archive_entry_copy_symlink(struct archiv { aes_copy_mbs(&entry->ae_symlink, linkname); if (linkname != NULL) - entry->ae_symlinkset = 1; + entry->ae_set |= AE_SET_SYMLINK; + else + entry->ae_set &= ~AE_SET_SYMLINK; } void @@ -983,7 +1048,9 @@ archive_entry_copy_symlink_w(struct arch { aes_copy_wcs(&entry->ae_symlink, linkname); if (linkname != NULL) - entry->ae_symlinkset = 1; + entry->ae_set |= AE_SET_SYMLINK; + else + entry->ae_set &= ~AE_SET_SYMLINK; } void Modified: stable/7/lib/libarchive/archive_entry.h ============================================================================== --- stable/7/lib/libarchive/archive_entry.h Fri Nov 28 19:58:31 2008 (r185407) +++ stable/7/lib/libarchive/archive_entry.h Fri Nov 28 20:08:47 2008 (r185408) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2003-2008 Tim Kientzle * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -152,12 +152,29 @@ __LA_DECL struct archive_entry *archive_ /* * Retrieve fields from an archive_entry. + * + * There are a number of implicit conversions among these fields. For + * example, if a regular string field is set and you read the _w wide + * character field, the entry will implicitly convert narrow-to-wide + * using the current locale. Similarly, dev values are automatically + * updated when you write devmajor or devminor and vice versa. + * + * In addition, fields can be "set" or "unset." Unset string fields + * return NULL, non-string fields have _is_set() functions to test + * whether they've been set. You can "unset" a string field by + * assigning NULL; non-string fields have _unset() functions to + * unset them. + * + * Note: There is one ambiguity in the above; string fields will + * also return NULL when implicit character set conversions fail. + * This is usually what you want. */ - __LA_DECL time_t archive_entry_atime(struct archive_entry *); __LA_DECL long archive_entry_atime_nsec(struct archive_entry *); +__LA_DECL int archive_entry_atime_is_set(struct archive_entry *); __LA_DECL time_t archive_entry_ctime(struct archive_entry *); __LA_DECL long archive_entry_ctime_nsec(struct archive_entry *); +__LA_DECL int archive_entry_ctime_is_set(struct archive_entry *); __LA_DECL dev_t archive_entry_dev(struct archive_entry *); __LA_DECL dev_t archive_entry_devmajor(struct archive_entry *); __LA_DECL dev_t archive_entry_devminor(struct archive_entry *); @@ -175,6 +192,7 @@ __LA_DECL __LA_INO_T archive_entry_ino( __LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *); __LA_DECL time_t archive_entry_mtime(struct archive_entry *); __LA_DECL long archive_entry_mtime_nsec(struct archive_entry *); +__LA_DECL int archive_entry_mtime_is_set(struct archive_entry *); __LA_DECL unsigned int archive_entry_nlink(struct archive_entry *); __LA_DECL const char *archive_entry_pathname(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *); @@ -183,6 +201,7 @@ __LA_DECL dev_t archive_entry_rdevmajo __LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *); __LA_DECL const char *archive_entry_sourcepath(struct archive_entry *); __LA_DECL int64_t archive_entry_size(struct archive_entry *); +__LA_DECL int archive_entry_size_is_set(struct archive_entry *); __LA_DECL const char *archive_entry_strmode(struct archive_entry *); __LA_DECL const char *archive_entry_symlink(struct archive_entry *); __LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *); @@ -195,10 +214,16 @@ __LA_DECL const wchar_t *archive_entry_u * * Note that string 'set' functions do not copy the string, only the pointer. * In contrast, 'copy' functions do copy the object pointed to. + * + * Note: As of libarchive 2.4, 'set' functions do copy the string and + * are therefore exact synonyms for the 'copy' versions. The 'copy' + * names will be retired in libarchive 3.0. */ __LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long); +__LA_DECL void archive_entry_unset_atime(struct archive_entry *); __LA_DECL void archive_entry_set_ctime(struct archive_entry *, time_t, long); +__LA_DECL void archive_entry_unset_ctime(struct archive_entry *); __LA_DECL void archive_entry_set_dev(struct archive_entry *, dev_t); __LA_DECL void archive_entry_set_devmajor(struct archive_entry *, dev_t); __LA_DECL void archive_entry_set_devminor(struct archive_entry *, dev_t); @@ -226,6 +251,7 @@ __LA_DECL void archive_entry_copy_link_w __LA_DECL int archive_entry_update_link_utf8(struct archive_entry *, const char *); __LA_DECL void archive_entry_set_mode(struct archive_entry *, __LA_MODE_T); __LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long); +__LA_DECL void archive_entry_unset_mtime(struct archive_entry *); __LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int); __LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_pathname(struct archive_entry *, const char *); @@ -236,6 +262,7 @@ __LA_DECL void archive_entry_set_rdev(st __LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t); __LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t); __LA_DECL void archive_entry_set_size(struct archive_entry *, int64_t); +__LA_DECL void archive_entry_unset_size(struct archive_entry *); __LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *); __LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *); __LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *); @@ -257,6 +284,7 @@ __LA_DECL int archive_entry_update_uname __LA_DECL const struct stat *archive_entry_stat(struct archive_entry *); __LA_DECL void archive_entry_copy_stat(struct archive_entry *, const struct stat *); + /* * ACL routines. This used to simply store and return text-format ACL * strings, but that proved insufficient for a number of reasons: Modified: stable/7/lib/libarchive/archive_entry_private.h ============================================================================== --- stable/7/lib/libarchive/archive_entry_private.h Fri Nov 28 19:58:31 2008 (r185407) +++ stable/7/lib/libarchive/archive_entry_private.h Fri Nov 28 20:08:47 2008 (r185408) @@ -136,6 +136,14 @@ struct archive_entry { dev_t aest_rdevminor; } ae_stat; + int ae_set; /* bitmap of fields that are currently set */ +#define AE_SET_HARDLINK 1 +#define AE_SET_SYMLINK 2 +#define AE_SET_ATIME 4 +#define AE_SET_CTIME 8 +#define AE_SET_MTIME 16 +#define AE_SET_SIZE 64 + /* * Use aes here so that we get transparent mbs<->wcs conversions. */ @@ -147,8 +155,6 @@ struct archive_entry { struct aes ae_pathname; /* Name of entry */ struct aes ae_symlink; /* symlink contents */ struct aes ae_uname; /* Name of owner */ - unsigned char ae_hardlinkset; - unsigned char ae_symlinkset; /* Not used within libarchive; useful for some clients. */ struct aes ae_sourcepath; /* Path this entry is sourced from. */ Modified: stable/7/lib/libarchive/archive_read_support_format_zip.c ============================================================================== --- stable/7/lib/libarchive/archive_read_support_format_zip.c Fri Nov 28 19:58:31 2008 (r185407) +++ stable/7/lib/libarchive/archive_read_support_format_zip.c Fri Nov 28 20:08:47 2008 (r185408) @@ -444,7 +444,9 @@ zip_read_file_header(struct archive_read archive_entry_set_mtime(entry, zip->mtime, 0); archive_entry_set_ctime(entry, zip->ctime, 0); archive_entry_set_atime(entry, zip->atime, 0); - archive_entry_set_size(entry, zip->uncompressed_size); + /* Set the size only if it's meaningful. */ + if (0 == (zip->flags & ZIP_LENGTH_AT_END)) + archive_entry_set_size(entry, zip->uncompressed_size); zip->entry_bytes_remaining = zip->compressed_size; zip->entry_offset = 0; @@ -573,12 +575,16 @@ archive_read_format_zip_read_data(struct } break; } + if (r != ARCHIVE_OK) + return (r); /* Update checksum */ - if (r == ARCHIVE_OK && *size) { + if (*size) zip->entry_crc32 = crc32(zip->entry_crc32, *buff, *size); - } - return (r); + /* Return EOF immediately if this is a non-regular file. */ + if (AE_IFREG != (zip->mode & AE_IFMT)) + return (ARCHIVE_EOF); + return (ARCHIVE_OK); } /* Modified: stable/7/lib/libarchive/archive_write_disk.c ============================================================================== --- stable/7/lib/libarchive/archive_write_disk.c Fri Nov 28 19:58:31 2008 (r185407) +++ stable/7/lib/libarchive/archive_write_disk.c Fri Nov 28 20:08:47 2008 (r185408) @@ -176,7 +176,7 @@ struct archive_write_disk { int fd; /* Current offset for writing data to the file. */ off_t offset; - /* Maximum size of file. */ + /* Maximum size of file, -1 if unknown. */ off_t filesize; /* Dir we were in before this restore; only for deep paths. */ int restore_pwd; @@ -231,7 +231,8 @@ static int set_time(struct archive_write static struct fixup_entry *sort_dir_list(struct fixup_entry *p); static gid_t trivial_lookup_gid(void *, const char *, gid_t); static uid_t trivial_lookup_uid(void *, const char *, uid_t); - +static ssize_t write_data_block(struct archive_write_disk *, + const char *, size_t, off_t); static struct archive_vtable *archive_write_disk_vtable(void); @@ -337,7 +338,10 @@ _archive_write_header(struct archive *_a a->offset = 0; a->uid = a->user_uid; a->mode = archive_entry_mode(a->entry); - a->filesize = archive_entry_size(a->entry); + if (archive_entry_size_is_set(a->entry)) + a->filesize = archive_entry_size(a->entry); + else + a->filesize = -1; archive_strcpy(&(a->_name_data), archive_entry_pathname(a->entry)); a->name = a->_name_data.s; archive_clear_error(&a->archive); @@ -439,15 +443,25 @@ _archive_write_header(struct archive *_a fe->mode = a->mode; } - if (a->deferred & TODO_TIMES) { + if ((a->deferred & TODO_TIMES) + && (archive_entry_mtime_is_set(entry) + || archive_entry_atime_is_set(entry))) { fe = current_fixup(a, archive_entry_pathname(entry)); fe->fixup |= TODO_TIMES; - fe->mtime = archive_entry_mtime(entry); - fe->mtime_nanos = archive_entry_mtime_nsec(entry); - fe->atime = archive_entry_atime(entry); - fe->atime_nanos = archive_entry_atime_nsec(entry); - if (fe->atime == 0 && fe->atime_nanos == 0) + if (archive_entry_mtime_is_set(entry)) { + fe->mtime = archive_entry_mtime(entry); + fe->mtime_nanos = archive_entry_mtime_nsec(entry); + } else { + fe->mtime = a->start_time; + fe->mtime_nanos = 0; + } + if (archive_entry_atime_is_set(entry)) { + fe->atime = archive_entry_atime(entry); + fe->atime_nanos = archive_entry_atime_nsec(entry); + } else { fe->atime = a->start_time; + fe->atime_nanos = 0; + } } if (a->deferred & TODO_FFLAGS) { @@ -486,89 +500,113 @@ archive_write_disk_set_skip_file(struct } static ssize_t -_archive_write_data_block(struct archive *_a, - const void *buff, size_t size, off_t offset) +write_data_block(struct archive_write_disk *a, + const char *buff, size_t size, off_t offset) { - struct archive_write_disk *a = (struct archive_write_disk *)_a; ssize_t bytes_written = 0; - ssize_t block_size, bytes_to_write; - int r = ARCHIVE_OK; + ssize_t block_size = 0, bytes_to_write; + int r; - __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, - ARCHIVE_STATE_DATA, "archive_write_disk_block"); - if (a->fd < 0) { - archive_set_error(&a->archive, 0, "File not open"); + if (a->filesize == 0 || a->fd < 0) { + archive_set_error(&a->archive, 0, + "Attempt to write to an empty file"); return (ARCHIVE_WARN); } - archive_clear_error(&a->archive); if (a->flags & ARCHIVE_EXTRACT_SPARSE) { if ((r = _archive_write_disk_lazy_stat(a)) != ARCHIVE_OK) return (r); block_size = a->pst->st_blksize; - } else - block_size = -1; - - if ((off_t)(offset + size) > a->filesize) { - size = (size_t)(a->filesize - a->offset); - archive_set_error(&a->archive, 0, - "Write request too large"); - r = ARCHIVE_WARN; } + if (a->filesize >= 0 && (off_t)(offset + size) > a->filesize) + size = (size_t)(a->filesize - offset); + /* Write the data. */ while (size > 0) { - if (block_size != -1) { - const char *buf; - - for (buf = buff; size; ++buf, --size, ++offset) { - if (*buf != '\0') + if (block_size == 0) { + bytes_to_write = size; + } else { + /* We're sparsifying the file. */ + const char *p, *end; + off_t block_end; + + /* Skip leading zero bytes. */ + for (p = buff, end = buff + size; p < end; ++p) { + if (*p != '\0') break; } + offset += p - buff; + size -= p - buff; + buff = p; if (size == 0) break; - bytes_to_write = block_size - offset % block_size; - buff = buf; - } else + + /* Calculate next block boundary after offset. */ + block_end + = (offset / block_size) * block_size + block_size; + + /* If the adjusted write would cross block boundary, + * truncate it to the block boundary. */ bytes_to_write = size; + if (offset + bytes_to_write > block_end) + bytes_to_write = block_end - offset; + } + /* Seek if necessary to the specified offset. */ if (offset != a->last_offset) { if (lseek(a->fd, offset, SEEK_SET) < 0) { - archive_set_error(&a->archive, errno, "Seek failed"); + archive_set_error(&a->archive, errno, + "Seek failed"); return (ARCHIVE_FATAL); } } - bytes_written = write(a->fd, buff, size); + bytes_written = write(a->fd, buff, bytes_to_write); if (bytes_written < 0) { archive_set_error(&a->archive, errno, "Write failed"); return (ARCHIVE_WARN); } - buff = (const char *)buff + bytes_written; + buff += bytes_written; size -= bytes_written; offset += bytes_written; a->archive.file_position += bytes_written; a->archive.raw_position += bytes_written; a->last_offset = a->offset = offset; } - a->offset = offset; - return (r); + return (bytes_written); +} + +static ssize_t +_archive_write_data_block(struct archive *_a, + const void *buff, size_t size, off_t offset) +{ + struct archive_write_disk *a = (struct archive_write_disk *)_a; + ssize_t r; + + __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, + ARCHIVE_STATE_DATA, "archive_write_disk_block"); + + r = write_data_block(a, buff, size, offset); + + if (r < 0) + return (r); + if ((size_t)r < size) { + archive_set_error(&a->archive, 0, + "Write request too large"); + return (ARCHIVE_WARN); + } + return (ARCHIVE_OK); } static ssize_t _archive_write_data(struct archive *_a, const void *buff, size_t size) { struct archive_write_disk *a = (struct archive_write_disk *)_a; - int r; __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, ARCHIVE_STATE_DATA, "archive_write_data"); - if (a->fd < 0) - return (ARCHIVE_OK); - r = _archive_write_data_block(_a, buff, size, a->offset); - if (r < ARCHIVE_OK) - return (r); - return size; + return (write_data_block(a, buff, size, a->offset)); } static int @@ -584,7 +622,15 @@ _archive_write_finish_entry(struct archi return (ARCHIVE_OK); archive_clear_error(&a->archive); - if (a->last_offset != a->filesize && a->fd >= 0) { + /* Pad or truncate file to the right size. */ + if (a->fd < 0) { + /* There's no file. */ + } else if (a->filesize < 0) { + /* File size is unknown, so we can't set the size. */ + } else if (a->last_offset == a->filesize) { + /* Last write ended at exactly the filesize; we're done. */ + /* Hopefully, this is the common case. */ + } else { if (ftruncate(a->fd, a->filesize) == -1 && a->filesize == 0) { archive_set_error(&a->archive, errno, @@ -601,7 +647,8 @@ _archive_write_finish_entry(struct archi if (a->st.st_size != a->filesize) { const char nul = '\0'; if (lseek(a->fd, a->st.st_size - 1, SEEK_SET) < 0) { - archive_set_error(&a->archive, errno, "Seek failed"); + archive_set_error(&a->archive, errno, + "Seek failed"); return (ARCHIVE_FATAL); } if (write(a->fd, &nul, 1) < 0) { @@ -609,6 +656,7 @@ _archive_write_finish_entry(struct archi "Write to restore size failed"); return (ARCHIVE_FATAL); } + a->pst = NULL; } } @@ -975,7 +1023,7 @@ create_filesystem_object(struct archive_ * If the hardlink does carry data, let the last * archive entry decide ownership. */ - if (r == 0 && a->filesize == 0) { + if (r == 0 && a->filesize <= 0) { a->todo = 0; a->deferred = 0; } if (r == 0 && a->filesize > 0) { @@ -1635,18 +1683,31 @@ set_time(struct archive_write_disk *a) { struct timeval times[2]; - times[1].tv_sec = archive_entry_mtime(a->entry); - times[1].tv_usec = archive_entry_mtime_nsec(a->entry) / 1000; + /* If no time was provided, we're done. */ + if (!archive_entry_atime_is_set(a->entry) + && !archive_entry_mtime_is_set(a->entry)) + return (ARCHIVE_OK); - times[0].tv_sec = archive_entry_atime(a->entry); - times[0].tv_usec = archive_entry_atime_nsec(a->entry) / 1000; + /* We know at least one is set, so... */ + if (archive_entry_mtime_is_set(a->entry)) { + times[1].tv_sec = archive_entry_mtime(a->entry); + times[1].tv_usec = archive_entry_mtime_nsec(a->entry) / 1000; + } else { + times[1].tv_sec = a->start_time; + times[1].tv_usec = 0; + } /* If no atime was specified, use start time instead. */ /* In theory, it would be marginally more correct to use * time(NULL) here, but that would cost us an extra syscall * for little gain. */ - if (times[0].tv_sec == 0 && times[0].tv_usec == 0) + if (archive_entry_atime_is_set(a->entry)) { + times[0].tv_sec = archive_entry_atime(a->entry); + times[0].tv_usec = archive_entry_atime_nsec(a->entry) / 1000; + } else { times[0].tv_sec = a->start_time; + times[0].tv_usec = 0; + } #ifdef HAVE_FUTIMES if (a->fd >= 0 && futimes(a->fd, times) == 0) { @@ -1684,10 +1745,24 @@ set_time(struct archive_write_disk *a) { struct utimbuf times; - times.modtime = archive_entry_mtime(a->entry); - times.actime = archive_entry_atime(a->entry); - if (times.actime == 0) + /* If no time was provided, we're done. */ + if (!archive_entry_atime_is_set(a->entry) + && !archive_entry_mtime_is_set(a->entry)) + return (ARCHIVE_OK); + + /* We know at least one is set, so... */ + /* Set mtime from mtime if set, else start time. */ + if (archive_entry_mtime_is_set(a->entry)) + times.modtime = archive_entry_mtime(a->entry); + else + times.modtime = a->start_time; + + /* Set atime from provided atime, else mtime. */ + if (archive_entry_atime_is_set(a->entry)) + times.actime = archive_entry_atime(a->entry); + else times.actime = a->start_time; + if (!S_ISLNK(a->mode) && utime(a->name, ×) != 0) { archive_set_error(&a->archive, errno, "Can't update time for %s", a->name); Modified: stable/7/lib/libarchive/test/test_entry.c ============================================================================== --- stable/7/lib/libarchive/test/test_entry.c Fri Nov 28 19:58:31 2008 (r185407) +++ stable/7/lib/libarchive/test/test_entry.c Fri Nov 28 20:08:47 2008 (r185408) @@ -69,14 +69,25 @@ DEFINE_TEST(test_entry) * The following tests are ordered alphabetically by the * name of the field. */ + /* atime */ archive_entry_set_atime(e, 13579, 24680); assertEqualInt(archive_entry_atime(e), 13579); assertEqualInt(archive_entry_atime_nsec(e), 24680); + archive_entry_unset_atime(e); + assertEqualInt(archive_entry_atime(e), 0); + assertEqualInt(archive_entry_atime_nsec(e), 0); + assert(!archive_entry_atime_is_set(e)); + /* ctime */ archive_entry_set_ctime(e, 13580, 24681); assertEqualInt(archive_entry_ctime(e), 13580); assertEqualInt(archive_entry_ctime_nsec(e), 24681); + archive_entry_unset_ctime(e); + assertEqualInt(archive_entry_ctime(e), 0); + assertEqualInt(archive_entry_ctime_nsec(e), 0); + assert(!archive_entry_ctime_is_set(e)); + #if ARCHIVE_VERSION_STAMP >= 1009000 /* dev */ archive_entry_set_dev(e, 235); @@ -85,6 +96,7 @@ DEFINE_TEST(test_entry) skipping("archive_entry_dev()"); #endif /* devmajor/devminor are tested specially below. */ + #if ARCHIVE_VERSION_STAMP >= 1009000 /* filetype */ archive_entry_set_filetype(e, AE_IFREG); @@ -92,10 +104,13 @@ DEFINE_TEST(test_entry) #else skipping("archive_entry_filetype()"); #endif + /* fflags are tested specially below */ + /* gid */ archive_entry_set_gid(e, 204); assertEqualInt(archive_entry_gid(e), 204); + /* gname */ archive_entry_set_gname(e, "group"); assertEqualString(archive_entry_gname(e), "group"); @@ -104,6 +119,7 @@ DEFINE_TEST(test_entry) assertEqualWString(archive_entry_gname_w(e), L"wgroup"); memset(wbuff, 0, sizeof(wbuff)); assertEqualWString(archive_entry_gname_w(e), L"wgroup"); + /* hardlink */ archive_entry_set_hardlink(e, "hardlinkname"); assertEqualString(archive_entry_hardlink(e), "hardlinkname"); @@ -158,10 +174,16 @@ DEFINE_TEST(test_entry) /* mode */ archive_entry_set_mode(e, 0123456); assertEqualInt(archive_entry_mode(e), 0123456); + /* mtime */ archive_entry_set_mtime(e, 13581, 24682); assertEqualInt(archive_entry_mtime(e), 13581); assertEqualInt(archive_entry_mtime_nsec(e), 24682); + archive_entry_unset_mtime(e); + assertEqualInt(archive_entry_mtime(e), 0); + assertEqualInt(archive_entry_mtime_nsec(e), 0); + assert(!archive_entry_mtime_is_set(e)); + #if ARCHIVE_VERSION_STAMP >= 1009000 /* nlink */ archive_entry_set_nlink(e, 736); @@ -169,6 +191,7 @@ DEFINE_TEST(test_entry) #else skipping("archive_entry_nlink()"); #endif + /* pathname */ archive_entry_set_pathname(e, "path"); assertEqualString(archive_entry_pathname(e), "path"); @@ -184,6 +207,7 @@ DEFINE_TEST(test_entry) assertEqualWString(archive_entry_pathname_w(e), L"wpath"); memset(wbuff, 0, sizeof(wbuff)); assertEqualWString(archive_entry_pathname_w(e), L"wpath"); + #if ARCHIVE_VERSION_STAMP >= 1009000 /* rdev */ archive_entry_set_rdev(e, 532); @@ -192,9 +216,14 @@ DEFINE_TEST(test_entry) skipping("archive_entry_rdev()"); #endif /* rdevmajor/rdevminor are tested specially below. */ + /* size */ archive_entry_set_size(e, 987654321); assertEqualInt(archive_entry_size(e), 987654321); + archive_entry_unset_size(e); + assertEqualInt(archive_entry_size(e), 0); + assert(!archive_entry_size_is_set(e)); + /* symlink */ archive_entry_set_symlink(e, "symlinkname"); assertEqualString(archive_entry_symlink(e), "symlinkname"); @@ -207,9 +236,11 @@ DEFINE_TEST(test_entry) #endif archive_entry_copy_symlink_w(e, L"wsymlink"); assertEqualWString(archive_entry_symlink_w(e), L"wsymlink"); + /* uid */ archive_entry_set_uid(e, 83); assertEqualInt(archive_entry_uid(e), 83); + /* uname */ archive_entry_set_uname(e, "user"); assertEqualString(archive_entry_uname(e), "user"); Modified: stable/7/lib/libarchive/test/test_read_format_zip.c ============================================================================== --- stable/7/lib/libarchive/test/test_read_format_zip.c Fri Nov 28 19:58:31 2008 (r185407) +++ stable/7/lib/libarchive/test/test_read_format_zip.c Fri Nov 28 20:08:47 2008 (r185408) @@ -25,6 +25,12 @@ #include "test.h" __FBSDID("$FreeBSD$"); +/* + * The reference file for this has been manually tweaked so that: + * * file2 has length-at-end but file1 does not + * * file2 has an invalid CRC + */ + DEFINE_TEST(test_read_format_zip) { const char *refname = "test_read_format_zip.zip"; @@ -57,7 +63,8 @@ DEFINE_TEST(test_read_format_zip) assertA(0 == archive_read_next_header(a, &ae)); assertEqualString("file2", archive_entry_pathname(ae)); assertEqualInt(1179605932, archive_entry_mtime(ae)); - assertEqualInt(18, archive_entry_size(ae)); + failure("file2 has length-at-end, so we shouldn't see a valid size"); + assertEqualInt(0, archive_entry_size_is_set(ae)); failure("file2 has a bad CRC, so reading to end should fail"); assertEqualInt(ARCHIVE_WARN, archive_read_data(a, buff, 19)); assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18)); Modified: stable/7/lib/libarchive/test/test_read_format_zip.zip.uu ============================================================================== --- stable/7/lib/libarchive/test/test_read_format_zip.zip.uu Fri Nov 28 19:58:31 2008 (r185407) +++ stable/7/lib/libarchive/test/test_read_format_zip.zip.uu Fri Nov 28 20:08:47 2008 (r185408) @@ -1,13 +1,14 @@ $FreeBSD$ begin 644 test_read_format_zip.zip -M4$L#!`H``````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1AE5 -M3T95>`0`Z`/H`U!+`P04````"`!O9K,V.C=F/0H````2````!0`5`&9I;&4Q -M550)``-!54]&K%M/1E5X!`#H`^@#RTC-R%8T$@H````2````!0`5`&9I;&4R550)``.L6T]&K%M/1E5X!`#H`^@#RTC- -MR%8T$@H````2````!0`-```````!````I(%Y```` -H9FEL93)55`4``ZQ;3T95>```4$L%!@`````#``,`OP```+L````````` +M4$L#!`H`"````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1M19 +M_4A5>`0`Z`/H`U!+!P@```````````````!02P,$%`````@`;V:S-CHW9CT* +M````$@````4`%0!F:6QE,554"0`#055/1L!9_4A5>`0`Z`/H`\M(S`0`Z`/H`\M(S```4$L!`A<#%``(``@`;V:S-CHW9CT*````$@````4`#0`` +M`````0```.V!1P```&9I;&4Q550%``-!54]&57@``%!+`0(7`Q0`"``(`%IJ +MLS8Z-V8]"@```!(````%``T```````$```#M@8D```!F:6QE,E54!0`#K%M/ +;1E5X``!02P4&``````,``P"_````VP`````` ` end Modified: stable/7/lib/libarchive/test/test_write_disk.c ============================================================================== --- stable/7/lib/libarchive/test/test_write_disk.c Fri Nov 28 19:58:31 2008 (r185407) +++ stable/7/lib/libarchive/test/test_write_disk.c Fri Nov 28 20:08:47 2008 (r185408) @@ -84,7 +84,7 @@ static void create_reg_file(struct archi * the entry being a maximum size. */ archive_entry_set_size(ae, sizeof(data)); - archive_entry_set_mtime(ae, 123456789, 0); + archive_entry_set_mtime(ae, 123456789, 0); assertEqualIntA(ad, 0, archive_write_header(ad, ae)); assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data))); assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); @@ -152,6 +152,61 @@ static void create_reg_file2(struct arch free(compare); free(data); } + +static void create_reg_file3(struct archive_entry *ae, const char *msg) +{ + static const char data[]="abcdefghijklmnopqrstuvwxyz"; + struct archive *ad; + struct stat st; + + /* Write the entry to disk. */ + assert((ad = archive_write_disk_new()) != NULL); + failure("%s", msg); + /* Set the size smaller than the data and verify the truncation. */ + archive_entry_set_size(ae, 5); + assertEqualIntA(ad, 0, archive_write_header(ad, ae)); + assertEqualInt(5, archive_write_data(ad, data, sizeof(data))); + assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); +#if ARCHIVE_VERSION_NUMBER < 2000000 + archive_write_finish(ad); +#else + assertEqualInt(0, archive_write_finish(ad)); +#endif + /* Test the entry on disk. */ + assert(0 == stat(archive_entry_pathname(ae), &st)); + failure("st.st_mode=%o archive_entry_mode(ae)=%o", + st.st_mode, archive_entry_mode(ae)); + assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK)); + assertEqualInt(st.st_size, 5); +} + + +static void create_reg_file4(struct archive_entry *ae, const char *msg) +{ + static const char data[]="abcdefghijklmnopqrstuvwxyz"; + struct archive *ad; + struct stat st; + + /* Write the entry to disk. */ + assert((ad = archive_write_disk_new()) != NULL); + /* Leave the size unset. The data should not be truncated. */ + assertEqualIntA(ad, 0, archive_write_header(ad, ae)); + assertEqualInt(ARCHIVE_OK, + archive_write_data_block(ad, data, sizeof(data), 0)); + assertEqualIntA(ad, 0, archive_write_finish_entry(ad)); +#if ARCHIVE_VERSION_NUMBER < 2000000 + archive_write_finish(ad); +#else + assertEqualInt(0, archive_write_finish(ad)); +#endif + /* Test the entry on disk. */ + assert(0 == stat(archive_entry_pathname(ae), &st)); + failure("st.st_mode=%o archive_entry_mode(ae)=%o", + st.st_mode, archive_entry_mode(ae)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From kientzle at FreeBSD.org Fri Nov 28 12:13:24 2008 From: kientzle at FreeBSD.org (Tim Kientzle) Date: Fri Nov 28 12:13:40 2008 Subject: svn commit: r185410 - stable/7/usr.bin/tar Message-ID: <200811282013.mASKDORv028810@svn.freebsd.org> Author: kientzle Date: Fri Nov 28 20:13:23 2008 New Revision: 185410 URL: http://svn.freebsd.org/changeset/base/185410 Log: MFC r185359: Return a non-zero exit code when directories disappear during the filesystem traversal. Tested by: David Wolfskill Approved by: re Modified: stable/7/usr.bin/tar/ (props changed) stable/7/usr.bin/tar/write.c Modified: stable/7/usr.bin/tar/write.c ============================================================================== --- stable/7/usr.bin/tar/write.c Fri Nov 28 20:09:48 2008 (r185409) +++ stable/7/usr.bin/tar/write.c Fri Nov 28 20:13:23 2008 (r185410) @@ -659,8 +659,10 @@ write_hierarchy(struct bsdtar *bsdtar, s const struct stat *st = NULL, *lst = NULL; int descend; - if (tree_ret == TREE_ERROR_DIR) + if (tree_ret == TREE_ERROR_DIR) { bsdtar_warnc(bsdtar, errno, "%s: Couldn't visit directory", name); + bsdtar->return_value = 1; + } if (tree_ret != TREE_REGULAR) continue; lst = tree_current_lstat(tree); From kientzle at FreeBSD.org Fri Nov 28 19:17:30 2008 From: kientzle at FreeBSD.org (Tim Kientzle) Date: Fri Nov 28 19:17:35 2008 Subject: svn commit: r185423 - stable/7/sys/fs/cd9660 Message-ID: <200811290317.mAT3HTDc037471@svn.freebsd.org> Author: kientzle Date: Sat Nov 29 03:17:29 2008 New Revision: 185423 URL: http://svn.freebsd.org/changeset/base/185423 Log: MFC r185361: timezone value is signed PR: kern/128934 Submitted by: J.R. Oldroyd Approved by: re Modified: stable/7/sys/fs/cd9660/cd9660_node.c Modified: stable/7/sys/fs/cd9660/cd9660_node.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_node.c Sat Nov 29 02:28:05 2008 (r185422) +++ stable/7/sys/fs/cd9660/cd9660_node.c Sat Nov 29 03:17:29 2008 (r185423) @@ -242,7 +242,7 @@ cd9660_tstamp_conv7(pi,pu,ftype) minute = pi[4]; second = pi[5]; if(ftype != ISO_FTYPE_HIGH_SIERRA) - tz = pi[6]; + tz = ((signed char *)pi)[6]; /* Timezone value is signed. */ else /* original high sierra misses timezone data */ tz = 0; From kientzle at FreeBSD.org Fri Nov 28 21:10:30 2008 From: kientzle at FreeBSD.org (Tim Kientzle) Date: Fri Nov 28 21:10:41 2008 Subject: svn commit: r185426 - stable/7/sys/fs/cd9660 Message-ID: <200811290510.mAT5AUkb039756@svn.freebsd.org> Author: kientzle Date: Sat Nov 29 05:10:30 2008 New Revision: 185426 URL: http://svn.freebsd.org/changeset/base/185426 Log: MFC r185334: Recognize Rockridge extensions even when the IEEE-standard extension name (as standardized in 1994) is used. PR: kern/128942 Submitted by: J.R. Oldroyd Approved by: re Modified: stable/7/sys/fs/cd9660/cd9660_rrip.c Modified: stable/7/sys/fs/cd9660/cd9660_rrip.c ============================================================================== --- stable/7/sys/fs/cd9660/cd9660_rrip.c Sat Nov 29 05:08:49 2008 (r185425) +++ stable/7/sys/fs/cd9660/cd9660_rrip.c Sat Nov 29 05:10:30 2008 (r185426) @@ -467,8 +467,12 @@ cd9660_rrip_extref(p,ana) ISO_RRIP_EXTREF *p; ISO_RRIP_ANALYZE *ana; { - if (isonum_711(p->len_id) != 10 - || bcmp((char *)p + 8,"RRIP_1991A",10) + if ( ! ((isonum_711(p->len_id) == 10 + && bcmp((char *)p + 8,"RRIP_1991A",10) == 0) + || (isonum_711(p->len_id) == 10 + && bcmp((char *)p + 8,"IEEE_P1282",10) == 0) + || (isonum_711(p->len_id) == 9 + && bcmp((char *)p + 8,"IEEE_1282", 9) == 0)) || isonum_711(p->version) != 1) return 0; ana->fields &= ~ISO_SUSP_EXTREF; From rwatson at FreeBSD.org Sat Nov 29 06:49:57 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Sat Nov 29 06:50:07 2008 Subject: svn commit: r185437 - in stable/7/contrib/smbfs: . lib/smb Message-ID: <200811291449.mATEnuIG054182@svn.freebsd.org> Author: rwatson Date: Sat Nov 29 14:49:56 2008 New Revision: 185437 URL: http://svn.freebsd.org/changeset/base/185437 Log: Merge r184567 from head to stable/7: When encoding an smb name, truncate one byte earlier in order than we did previously in order to ensure it fit properly in the bufer when encoded. This prevents a debugging printf from firing if a source or destination host name for an smb mount exceeds 15 characters. Obtained from: Apple, Inc. Approved by: re (kensmith) Modified: stable/7/contrib/smbfs/ (props changed) stable/7/contrib/smbfs/lib/smb/nb_name.c Modified: stable/7/contrib/smbfs/lib/smb/nb_name.c ============================================================================== --- stable/7/contrib/smbfs/lib/smb/nb_name.c Sat Nov 29 14:34:30 2008 (r185436) +++ stable/7/contrib/smbfs/lib/smb/nb_name.c Sat Nov 29 14:49:56 2008 (r185437) @@ -169,7 +169,7 @@ nb_name_encode(struct nb_name *np, u_cha memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' ')); cp += NB_ENCNAMELEN; } else { - for (i = 0; *name && i < NB_NAMELEN; i++, cp += 2, name++) + for (i = 0; *name && i < NB_NAMELEN - 1; i++, cp += 2, name++) *(u_short*)cp = NBENCODE(toupper(*name)); i = NB_NAMELEN - i - 1; if (i > 0) { From rwatson at FreeBSD.org Sat Nov 29 06:58:59 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Sat Nov 29 06:59:10 2008 Subject: svn commit: r185440 - stable/7/sys/security/mac_bsdextended Message-ID: <200811291458.mATEwx32054504@svn.freebsd.org> Author: rwatson Date: Sat Nov 29 14:58:58 2008 New Revision: 185440 URL: http://svn.freebsd.org/changeset/base/185440 Log: Merge r184367 from head to stable/7: When the mac_bsdextended policy is unloaded, free rule memory. Obtained from: TrustedBSD Project Approved by: re (kensmith) Modified: stable/7/sys/security/mac_bsdextended/mac_bsdextended.c Modified: stable/7/sys/security/mac_bsdextended/mac_bsdextended.c ============================================================================== --- stable/7/sys/security/mac_bsdextended/mac_bsdextended.c Sat Nov 29 14:57:58 2008 (r185439) +++ stable/7/sys/security/mac_bsdextended/mac_bsdextended.c Sat Nov 29 14:58:58 2008 (r185440) @@ -208,7 +208,12 @@ ugidfw_init(struct mac_policy_conf *mpc) static void ugidfw_destroy(struct mac_policy_conf *mpc) { + int i; + for (i = 0; i < MAC_BSDEXTENDED_MAXRULES; i++) { + if (rules[i] != NULL) + free(rules[i], M_MACBSDEXTENDED); + } mtx_destroy(&ugidfw_mtx); } From rnoland at FreeBSD.org Sat Nov 29 09:33:38 2008 From: rnoland at FreeBSD.org (Robert Noland) Date: Sat Nov 29 09:33:44 2008 Subject: svn commit: r185443 - in stable/7/sys: . pci Message-ID: <200811291733.mATHXcJt057774@svn.freebsd.org> Author: rnoland Date: Sat Nov 29 17:33:38 2008 New Revision: 185443 URL: http://svn.freebsd.org/changeset/base/185443 Log: MFC r183555: Correctly handle Intel g33 chips and add support for g45 chips. g33 based chips use a different method of identifying the gtt size. g45 based chips gtt is located in a different area of stolen memory. Approved by: re@ (kensmith) Modified: stable/7/sys/ (props changed) stable/7/sys/pci/agp_i810.c stable/7/sys/pci/agpreg.h Modified: stable/7/sys/pci/agp_i810.c ============================================================================== --- stable/7/sys/pci/agp_i810.c Sat Nov 29 17:14:06 2008 (r185442) +++ stable/7/sys/pci/agp_i810.c Sat Nov 29 17:33:38 2008 (r185443) @@ -70,6 +70,7 @@ enum { CHIP_I915, /* 915G/915GM */ CHIP_I965, /* G965 */ CHIP_G33, /* G33/Q33/Q35 */ + CHIP_G4X, /* G45/Q45 */ }; /* The i810 through i855 have the registers at BAR 1, and the GATT gets @@ -133,7 +134,7 @@ static const struct agp_i810_match { {0x25628086, CHIP_I830, 0x00020000, "Intel 82845M (845M GMCH) SVGA controller"}, {0x35828086, CHIP_I855, 0x00020000, - "Intel 82852/5"}, + "Intel 82852/855GM SVGA controller"}, {0x25728086, CHIP_I855, 0x00020000, "Intel 82865G (865G GMCH) SVGA controller"}, {0x25828086, CHIP_I915, 0x00020000, @@ -154,18 +155,26 @@ static const struct agp_i810_match { "Intel G965 SVGA controller"}, {0x29928086, CHIP_I965, 0x00020000, "Intel Q965 SVGA controller"}, - {0x29a28086, CHIP_I965, 0x00020000, + {0x29A28086, CHIP_I965, 0x00020000, "Intel G965 SVGA controller"}, - {0x29b28086, CHIP_G33, 0x00020000, + {0x29B28086, CHIP_G33, 0x00020000, "Intel Q35 SVGA controller"}, - {0x29c28086, CHIP_G33, 0x00020000, + {0x29C28086, CHIP_G33, 0x00020000, "Intel G33 SVGA controller"}, - {0x29d28086, CHIP_G33, 0x00020000, + {0x29D28086, CHIP_G33, 0x00020000, "Intel Q33 SVGA controller"}, - {0x2a028086, CHIP_I965, 0x00020000, + {0x2A028086, CHIP_I965, 0x00020000, "Intel GM965 SVGA controller"}, - {0x2a128086, CHIP_I965, 0x00020000, + {0x2A128086, CHIP_I965, 0x00020000, "Intel GME965 SVGA controller"}, + {0x2A428086, CHIP_I965, 0x00020000, + "Intel GM45 SVGA controller"}, + {0x2E028086, CHIP_G4X, 0x00020000, + "Intel 4 Series SVGA controller"}, + {0x2E128086, CHIP_G4X, 0x00020000, + "Intel Q45 SVGA controller"}, + {0x2E228086, CHIP_G4X, 0x00020000, + "Intel G45 SVGA controller"}, {0, 0, 0, NULL} }; @@ -377,6 +386,7 @@ agp_i810_attach(device_t dev) agp_set_aperture_resource(dev, AGP_I915_GMADR); break; case CHIP_I965: + case CHIP_G4X: sc->sc_res_spec = agp_i965_res_spec; agp_set_aperture_resource(dev, AGP_I915_GMADR); break; @@ -476,7 +486,8 @@ agp_i810_attach(device_t dev) gatt->ag_physical = pgtblctl & ~1; } else if (sc->chiptype == CHIP_I855 || sc->chiptype == CHIP_I915 || - sc->chiptype == CHIP_I965 || sc->chiptype == CHIP_G33) { + sc->chiptype == CHIP_I965 || sc->chiptype == CHIP_G33 || + sc->chiptype == CHIP_G4X) { unsigned int gcc1, pgtblctl, stolen, gtt_size; /* Stolen memory is set up at the beginning of the aperture by @@ -491,7 +502,6 @@ agp_i810_attach(device_t dev) gtt_size = 256; break; case CHIP_I965: - case CHIP_G33: switch (bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL) & AGP_I810_PGTBL_SIZE_MASK) { case AGP_I810_PGTBL_SIZE_128KB: @@ -503,6 +513,33 @@ agp_i810_attach(device_t dev) case AGP_I810_PGTBL_SIZE_512KB: gtt_size = 512; break; + case AGP_I965_PGTBL_SIZE_1MB: + gtt_size = 1024; + break; + case AGP_I965_PGTBL_SIZE_2MB: + gtt_size = 2048; + break; + case AGP_I965_PGTBL_SIZE_1_5MB: + gtt_size = 1024 + 512; + break; + default: + device_printf(dev, "Bad PGTBL size\n"); + bus_release_resources(dev, sc->sc_res_spec, + sc->sc_res); + free(gatt, M_AGP); + agp_generic_detach(dev); + return EINVAL; + } + break; + case CHIP_G33: + gcc1 = pci_read_config(sc->bdev, AGP_I855_GCC1, 2); + switch (gcc1 & AGP_G33_MGGC_GGMS_MASK) { + case AGP_G33_MGGC_GGMS_SIZE_1M: + gtt_size = 1024; + break; + case AGP_G33_MGGC_GGMS_SIZE_2M: + gtt_size = 2048; + break; default: device_printf(dev, "Bad PGTBL size\n"); bus_release_resources(dev, sc->sc_res_spec, @@ -512,6 +549,9 @@ agp_i810_attach(device_t dev) return EINVAL; } break; + case CHIP_G4X: + gtt_size = 0; + break; default: device_printf(dev, "Bad chiptype\n"); bus_release_resources(dev, sc->sc_res_spec, @@ -528,28 +568,86 @@ agp_i810_attach(device_t dev) stolen = 1024; break; case AGP_I855_GCC1_GMS_STOLEN_4M: - stolen = 4096; + stolen = 4 * 1024; break; case AGP_I855_GCC1_GMS_STOLEN_8M: - stolen = 8192; + stolen = 8 * 1024; break; case AGP_I855_GCC1_GMS_STOLEN_16M: - stolen = 16384; + stolen = 16 * 1024; break; case AGP_I855_GCC1_GMS_STOLEN_32M: - stolen = 32768; + stolen = 32 * 1024; break; case AGP_I915_GCC1_GMS_STOLEN_48M: - stolen = 49152; + if (sc->chiptype == CHIP_I915 || + sc->chiptype == CHIP_I965 || + sc->chiptype == CHIP_G33 || + sc->chiptype == CHIP_G4X) { + stolen = 48 * 1024; + } else { + stolen = 0; + } break; case AGP_I915_GCC1_GMS_STOLEN_64M: - stolen = 65536; + if (sc->chiptype == CHIP_I915 || + sc->chiptype == CHIP_I965 || + sc->chiptype == CHIP_G33 || + sc->chiptype == CHIP_G4X) { + stolen = 64 * 1024; + } else { + stolen = 0; + } break; case AGP_G33_GCC1_GMS_STOLEN_128M: - stolen = 128 * 1024; + if (sc->chiptype == CHIP_I965 || + sc->chiptype == CHIP_G33 || + sc->chiptype == CHIP_G4X) { + stolen = 128 * 1024; + } else { + stolen = 0; + } break; case AGP_G33_GCC1_GMS_STOLEN_256M: - stolen = 256 * 1024; + if (sc->chiptype == CHIP_I965 || + sc->chiptype == CHIP_G33 || + sc->chiptype == CHIP_G4X) { + stolen = 256 * 1024; + } else { + stolen = 0; + } + break; + case AGP_G4X_GCC1_GMS_STOLEN_96M: + if (sc->chiptype == CHIP_I965 || + sc->chiptype == CHIP_G4X) { + stolen = 96 * 1024; + } else { + stolen = 0; + } + break; + case AGP_G4X_GCC1_GMS_STOLEN_160M: + if (sc->chiptype == CHIP_I965 || + sc->chiptype == CHIP_G4X) { + stolen = 160 * 1024; + } else { + stolen = 0; + } + break; + case AGP_G4X_GCC1_GMS_STOLEN_224M: + if (sc->chiptype == CHIP_I965 || + sc->chiptype == CHIP_G4X) { + stolen = 224 * 1024; + } else { + stolen = 0; + } + break; + case AGP_G4X_GCC1_GMS_STOLEN_352M: + if (sc->chiptype == CHIP_I965 || + sc->chiptype == CHIP_G4X) { + stolen = 352 * 1024; + } else { + stolen = 0; + } break; default: device_printf(dev, "unknown memory configuration, " @@ -560,7 +658,11 @@ agp_i810_attach(device_t dev) agp_generic_detach(dev); return EINVAL; } - sc->stolen = (stolen - gtt_size - 4) * 1024 / 4096; + + if (sc->chiptype != CHIP_G4X) + gtt_size += 4; + + sc->stolen = (stolen - gtt_size) * 1024 / 4096; if (sc->stolen > 0) device_printf(dev, "detected %dk stolen memory\n", sc->stolen * 4); device_printf(dev, "aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); Modified: stable/7/sys/pci/agpreg.h ============================================================================== --- stable/7/sys/pci/agpreg.h Sat Nov 29 17:14:06 2008 (r185442) +++ stable/7/sys/pci/agpreg.h Sat Nov 29 17:33:38 2008 (r185443) @@ -215,7 +215,7 @@ #define AGP_I855_GCC1_DEV2 0x08 #define AGP_I855_GCC1_DEV2_ENABLED 0x00 #define AGP_I855_GCC1_DEV2_DISABLED 0x08 -#define AGP_I855_GCC1_GMS 0x70 +#define AGP_I855_GCC1_GMS 0xf0 /* Top bit reserved pre-G33 */ #define AGP_I855_GCC1_GMS_STOLEN_0M 0x00 #define AGP_I855_GCC1_GMS_STOLEN_1M 0x10 #define AGP_I855_GCC1_GMS_STOLEN_4M 0x20 @@ -259,14 +259,28 @@ #define AGP_I965_MSAC_GMASIZE_128 0x00 #define AGP_I965_MSAC_GMASIZE_256 0x02 #define AGP_I965_MSAC_GMASIZE_512 0x06 +#define AGP_I965_PGTBL_SIZE_1MB (3 << 1) +#define AGP_I965_PGTBL_SIZE_2MB (4 << 1) +#define AGP_I965_PGTBL_SIZE_1_5MB (5 << 1) /* * G33 registers */ +#define AGP_G33_MGGC_GGMS_MASK (3 << 8) +#define AGP_G33_MGGC_GGMS_SIZE_1M (1 << 8) +#define AGP_G33_MGGC_GGMS_SIZE_2M (2 << 8) #define AGP_G33_GCC1_GMS_STOLEN_128M 0x80 #define AGP_G33_GCC1_GMS_STOLEN_256M 0x90 /* + * G4X registers + */ +#define AGP_G4X_GCC1_GMS_STOLEN_96M 0xa0 +#define AGP_G4X_GCC1_GMS_STOLEN_160M 0xb0 +#define AGP_G4X_GCC1_GMS_STOLEN_224M 0xc0 +#define AGP_G4X_GCC1_GMS_STOLEN_352M 0xd0 + +/* * NVIDIA nForce/nForce2 registers */ #define AGP_NVIDIA_0_APBASE 0x10 From luigi at FreeBSD.org Sat Nov 29 16:00:03 2008 From: luigi at FreeBSD.org (Luigi Rizzo) Date: Sat Nov 29 16:00:09 2008 Subject: svn commit: r185458 - stable/7/sys/boot/i386/boot0 Message-ID: <200811300000.mAU002At065992@svn.freebsd.org> Author: luigi Date: Sun Nov 30 00:00:02 2008 New Revision: 185458 URL: http://svn.freebsd.org/changeset/base/185458 Log: MFC: pass the correct value in %si to the next stage boot Approved by: re@ Modified: stable/7/sys/boot/i386/boot0/boot0.S Modified: stable/7/sys/boot/i386/boot0/boot0.S ============================================================================== --- stable/7/sys/boot/i386/boot0/boot0.S Sat Nov 29 21:48:12 2008 (r185457) +++ stable/7/sys/boot/i386/boot0/boot0.S Sun Nov 30 00:00:02 2008 (r185458) @@ -319,8 +319,9 @@ main.15: movw $LOAD,%bx # Address for jc main.10 # If error cmpw $MAGIC,0x1fe(%bx) # Bootable? jne main.10 # No - movw $crlf,%si # Leave some - callw puts # space + pushw %si # Save ptr to selected part. + callw putn # Leave some space + popw %si # Restore, next stage uses it jmp *%bx # Invoke bootstrap /* From csjp at FreeBSD.org Sun Nov 30 13:00:23 2008 From: csjp at FreeBSD.org (Christian S.J. Peron) Date: Sun Nov 30 13:00:35 2008 Subject: svn commit: r185486 - in stable/7/sys: . security/audit Message-ID: <200811302100.mAUL0NLV001741@svn.freebsd.org> Author: csjp Date: Sun Nov 30 21:00:22 2008 New Revision: 185486 URL: http://svn.freebsd.org/changeset/base/185486 Log: MFC revision 185484 - fixup ABI issues with ip6/audit Approved by: re@ (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/security/audit/audit_syscalls.c Modified: stable/7/sys/security/audit/audit_syscalls.c ============================================================================== --- stable/7/sys/security/audit/audit_syscalls.c Sun Nov 30 20:48:57 2008 (r185485) +++ stable/7/sys/security/audit/audit_syscalls.c Sun Nov 30 21:00:22 2008 (r185486) @@ -508,7 +508,7 @@ getaudit(struct thread *td, struct getau if (error) return (error); if (td->td_ucred->cr_audit.ai_termid.at_type == AU_IPv6) - return (ERANGE); + return (E2BIG); bzero(&ai, sizeof(ai)); ai.ai_auid = td->td_ucred->cr_audit.ai_auid; ai.ai_mask = td->td_ucred->cr_audit.ai_mask; From kmacy at FreeBSD.org Sun Nov 30 16:23:13 2008 From: kmacy at FreeBSD.org (Kip Macy) Date: Sun Nov 30 16:23:25 2008 Subject: svn commit: r185498 - in stable/7/sys/dev/cxgb: . common ulp/tom Message-ID: <200812010023.mB10NCY8006640@svn.freebsd.org> Author: kmacy Date: Mon Dec 1 00:23:12 2008 New Revision: 185498 URL: http://svn.freebsd.org/changeset/base/185498 Log: MFC 183967, 184861, 185157 183967: Track number of packets transmitted and number of packets received PR: 125806 184861: Update firmware version check make ddp a tunable Obtained from: Chelsio Inc. 185157: Several small additions to the Chelsio 10G driver. 1) Fix a bug in dealing with the Alerus 1006 PHY which prevented the device from ever coming back up once it had been set to down. 2) Add a kernel tunable (hw.cxgb.snd_queue_len) which makes it possible to give the device more than IFQ_MAXLEN entries in its send queue. The default remains 50. 3) Add code to place the card'd identification and serial number into its description (%desc) so that users can tell which card they have installed. Approved by: re Modified: stable/7/sys/dev/cxgb/common/cxgb_ael1002.c stable/7/sys/dev/cxgb/common/cxgb_common.h stable/7/sys/dev/cxgb/common/cxgb_ctl_defs.h stable/7/sys/dev/cxgb/common/cxgb_t3_hw.c stable/7/sys/dev/cxgb/cxgb_main.c stable/7/sys/dev/cxgb/cxgb_sge.c stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c stable/7/sys/dev/cxgb/ulp/tom/cxgb_tom.c stable/7/sys/dev/cxgb/ulp/tom/cxgb_tom_sysctl.c Modified: stable/7/sys/dev/cxgb/common/cxgb_ael1002.c ============================================================================== --- stable/7/sys/dev/cxgb/common/cxgb_ael1002.c Mon Dec 1 00:07:17 2008 (r185497) +++ stable/7/sys/dev/cxgb/common/cxgb_ael1002.c Mon Dec 1 00:23:12 2008 (r185498) @@ -195,7 +195,21 @@ int t3_ael1002_phy_prep(struct cphy *phy static int ael1006_reset(struct cphy *phy, int wait) { - return t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); + u32 gpio_out; + t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); + /* Hack to reset the phy correctly */ + /* Read out the current value */ + gpio_out = t3_read_reg(phy->adapter, A_T3DBG_GPIO_EN); + /* Reset the phy */ + gpio_out &= ~F_GPIO6_OUT_VAL; + t3_write_reg(phy->adapter, A_T3DBG_GPIO_EN, gpio_out); + msleep(125); + /* Take the phy out of reset */ + gpio_out |= F_GPIO6_OUT_VAL; + t3_write_reg(phy->adapter, A_T3DBG_GPIO_EN, gpio_out); + msleep(125); + t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); + return 0; } static int ael1006_power_down(struct cphy *phy, int enable) Modified: stable/7/sys/dev/cxgb/common/cxgb_common.h ============================================================================== --- stable/7/sys/dev/cxgb/common/cxgb_common.h Mon Dec 1 00:07:17 2008 (r185497) +++ stable/7/sys/dev/cxgb/common/cxgb_common.h Mon Dec 1 00:23:12 2008 (r185498) @@ -41,6 +41,7 @@ enum { MAX_FRAME_SIZE = 10240, /* max MAC frame size, includes header + FCS */ EEPROMSIZE = 8192, /* Serial EEPROM size */ SERNUM_LEN = 16, /* Serial # length */ + ECNUM_LEN = 16, /* EC # length */ RSS_TABLE_SIZE = 64, /* size of RSS lookup and mapping tables */ TCB_SIZE = 128, /* TCB size */ NMTUS = 16, /* size of MTU table */ @@ -342,6 +343,7 @@ struct vpd_params { unsigned int mdc; unsigned int mem_timing; u8 sn[SERNUM_LEN + 1]; + u8 ec[ECNUM_LEN + 1]; u8 eth_base[6]; u8 port_type[MAX_NPORTS]; unsigned short xauicfg[2]; Modified: stable/7/sys/dev/cxgb/common/cxgb_ctl_defs.h ============================================================================== --- stable/7/sys/dev/cxgb/common/cxgb_ctl_defs.h Mon Dec 1 00:07:17 2008 (r185497) +++ stable/7/sys/dev/cxgb/common/cxgb_ctl_defs.h Mon Dec 1 00:23:12 2008 (r185498) @@ -85,7 +85,7 @@ struct ddp_params { struct adap_ports { unsigned int nports; /* number of ports on this adapter */ - struct net_device *lldevs[2]; + struct net_device *lldevs[MAX_NPORTS]; }; /* Modified: stable/7/sys/dev/cxgb/common/cxgb_t3_hw.c ============================================================================== --- stable/7/sys/dev/cxgb/common/cxgb_t3_hw.c Mon Dec 1 00:07:17 2008 (r185497) +++ stable/7/sys/dev/cxgb/common/cxgb_t3_hw.c Mon Dec 1 00:23:12 2008 (r185498) @@ -554,7 +554,7 @@ struct t3_vpd { u8 vpdr_tag; u8 vpdr_len[2]; VPD_ENTRY(pn, 16); /* part number */ - VPD_ENTRY(ec, 16); /* EC level */ + VPD_ENTRY(ec, ECNUM_LEN); /* EC level */ VPD_ENTRY(sn, SERNUM_LEN); /* serial number */ VPD_ENTRY(na, 12); /* MAC address base */ VPD_ENTRY(cclk, 6); /* core clock */ @@ -699,6 +699,7 @@ static int get_vpd_params(adapter_t *ada p->mdc = simple_strtoul(vpd.mdc_data, NULL, 10); p->mem_timing = simple_strtoul(vpd.mt_data, NULL, 10); memcpy(p->sn, vpd.sn_data, SERNUM_LEN); + memcpy(p->ec, vpd.ec_data, ECNUM_LEN); /* Old eeproms didn't have port information */ if (adapter->params.rev == 0 && !vpd.port0_data[0]) { @@ -743,7 +744,8 @@ enum { SF_ERASE_SECTOR = 0xd8, /* erase sector */ FW_FLASH_BOOT_ADDR = 0x70000, /* start address of FW in flash */ - FW_VERS_ADDR = 0x77ffc, /* flash address holding FW version */ + OLD_FW_VERS_ADDR = 0x77ffc, /* flash address holding FW version */ + FW_VERS_ADDR = 0x7fffc, /* flash address holding FW version */ FW_MIN_SIZE = 8, /* at least version and csum */ FW_MAX_SIZE = FW_VERS_ADDR - FW_FLASH_BOOT_ADDR, @@ -1030,7 +1032,12 @@ enum fw_version_type { */ int t3_get_fw_version(adapter_t *adapter, u32 *vers) { - return t3_read_flash(adapter, FW_VERS_ADDR, 1, vers, 0); + int ret = t3_read_flash(adapter, FW_VERS_ADDR, 1, vers, 0); + + if (!ret && *vers != 0xffffffff) + return 0; + else + return t3_read_flash(adapter, OLD_FW_VERS_ADDR, 1, vers, 0); } /** Modified: stable/7/sys/dev/cxgb/cxgb_main.c ============================================================================== --- stable/7/sys/dev/cxgb/cxgb_main.c Mon Dec 1 00:07:17 2008 (r185497) +++ stable/7/sys/dev/cxgb/cxgb_main.c Mon Dec 1 00:23:12 2008 (r185498) @@ -232,6 +232,15 @@ TUNABLE_INT("hw.cxgb.use_16k_clusters", SYSCTL_UINT(_hw_cxgb, OID_AUTO, use_16k_clusters, CTLFLAG_RDTUN, &cxgb_use_16k_clusters, 0, "use 16kB clusters for the jumbo queue "); +/* + * Tune the size of the output queue. + */ +int cxgb_snd_queue_len = IFQ_MAXLEN; +TUNABLE_INT("hw.cxgb.snd_queue_len", &cxgb_snd_queue_len); +SYSCTL_UINT(_hw_cxgb, OID_AUTO, snd_queue_len, CTLFLAG_RDTUN, + &cxgb_snd_queue_len, 0, "send queue size "); + + enum { MAX_TXQ_ENTRIES = 16384, MAX_CTRL_TXQ_ENTRIES = 1024, @@ -375,7 +384,8 @@ cxgb_controller_probe(device_t dev) const struct adapter_info *ai; char *ports, buf[80]; int nports; - + struct adapter *sc = device_get_softc(dev); + ai = cxgb_get_adapter_info(dev); if (ai == NULL) return (ENXIO); @@ -386,7 +396,9 @@ cxgb_controller_probe(device_t dev) else ports = "ports"; - snprintf(buf, sizeof(buf), "%s RNIC, %d %s", ai->desc, nports, ports); + snprintf(buf, sizeof(buf), "%s %sNIC, rev: %d nports: %d %s", + ai->desc, is_offload(sc) ? "R" : "", + sc->params.rev, nports, ports); device_set_desc_copy(dev, buf); return (BUS_PROBE_DEFAULT); } @@ -432,6 +444,8 @@ cxgb_controller_attach(device_t dev) int msi_needed, reg; #endif int must_load = 0; + char buf[80]; + sc = device_get_softc(dev); sc->dev = dev; sc->msi_count = 0; @@ -644,6 +658,11 @@ cxgb_controller_attach(device_t dev) G_FW_VERSION_MAJOR(vers), G_FW_VERSION_MINOR(vers), G_FW_VERSION_MICRO(vers)); + snprintf(buf, sizeof(buf), "%s\t E/C: %s S/N: %s", + ai->desc, + sc->params.vpd.ec, sc->params.vpd.sn); + device_set_desc_copy(dev, buf); + device_printf(sc->dev, "Firmware Version %s\n", &sc->fw_version[0]); callout_reset(&sc->cxgb_tick_ch, CXGB_TICKS(sc), cxgb_tick, sc); t3_add_attach_sysctls(sc); @@ -954,7 +973,7 @@ cxgb_port_attach(device_t dev) ifp->if_timer = 0; /* Disable ifnet watchdog */ ifp->if_watchdog = NULL; - ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN; + ifp->if_snd.ifq_drv_maxlen = cxgb_snd_queue_len; IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); IFQ_SET_READY(&ifp->if_snd); Modified: stable/7/sys/dev/cxgb/cxgb_sge.c ============================================================================== --- stable/7/sys/dev/cxgb/cxgb_sge.c Mon Dec 1 00:07:17 2008 (r185497) +++ stable/7/sys/dev/cxgb/cxgb_sge.c Mon Dec 1 00:23:12 2008 (r185498) @@ -1889,7 +1889,11 @@ t3_free_tx_desc(struct sge_txq *q, int r m_freem_iovec(&txsd->mi); buf_ring_scan(&q->txq_mr, txsd->mi.mi_base, __FILE__, __LINE__); txsd->mi.mi_base = NULL; - + /* + * XXX check for cache hit rate here + * + */ + q->port->ifp->if_opackets++; #if defined(DIAGNOSTIC) && 0 if (m_get_priority(txsd->m[0]) != cidx) printf("pri=%d cidx=%d\n", @@ -2511,6 +2515,7 @@ t3_rx_eth(struct adapter *adap, struct s m->m_pkthdr.rcvif = ifp; m->m_pkthdr.header = mtod(m, uint8_t *) + sizeof(*cpl) + ethpad; + ifp->if_ipackets++; #ifndef DISABLE_MBUF_IOVEC m_explode(m); #endif Modified: stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c ============================================================================== --- stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Mon Dec 1 00:07:17 2008 (r185497) +++ stable/7/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Mon Dec 1 00:23:12 2008 (r185498) @@ -3448,9 +3448,7 @@ process_pass_accept_req(struct socket *s V_TF_DDP_OFF(1) | TP_DDP_TIMER_WORKAROUND_VAL, 1); } else - printf("not offloading\n"); - - + DPRINTF("no DDP\n"); return; reject: Modified: stable/7/sys/dev/cxgb/ulp/tom/cxgb_tom.c ============================================================================== --- stable/7/sys/dev/cxgb/ulp/tom/cxgb_tom.c Mon Dec 1 00:07:17 2008 (r185497) +++ stable/7/sys/dev/cxgb/ulp/tom/cxgb_tom.c Mon Dec 1 00:23:12 2008 (r185498) @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -90,17 +89,6 @@ __FBSDID("$FreeBSD$"); #include #include - - - - -static int activated = 1; -TUNABLE_INT("hw.t3toe.activated", &activated); -SYSCTL_NODE(_hw, OID_AUTO, t3toe, CTLFLAG_RD, 0, "T3 toe driver parameters"); -SYSCTL_UINT(_hw_t3toe, OID_AUTO, activated, CTLFLAG_RDTUN, &activated, 0, - "enable TOE at init time"); - - TAILQ_HEAD(, adapter) adapter_list; static struct rwlock adapter_list_lock; @@ -913,7 +901,7 @@ do_act_establish(struct t3cdev *dev, str } else { log(LOG_ERR, "%s: received clientless CPL command 0x%x\n", - dev->name, CPL_PASS_ACCEPT_REQ); + dev->name, CPL_ACT_ESTABLISH); return CPL_RET_BUF_DONE | CPL_RET_BAD_MSG; } } @@ -1335,8 +1323,6 @@ t3_toe_attach(struct toedev *dev, const t3_init_tunables(t); mtx_init(&t->listen_lock, "tom data listeners", NULL, MTX_DEF); CTR2(KTR_TOM, "t3_toe_attach dev=%p entry=%p", dev, entry); - /* Adjust TOE activation for this module */ - t->conf.activated = activated; dev->tod_can_offload = can_offload; dev->tod_connect = t3_connect; Modified: stable/7/sys/dev/cxgb/ulp/tom/cxgb_tom_sysctl.c ============================================================================== --- stable/7/sys/dev/cxgb/ulp/tom/cxgb_tom_sysctl.c Mon Dec 1 00:07:17 2008 (r185497) +++ stable/7/sys/dev/cxgb/ulp/tom/cxgb_tom_sysctl.c Mon Dec 1 00:23:12 2008 (r185498) @@ -76,6 +76,10 @@ __FBSDID("$FreeBSD$"); #include #include +/* Avoid clutter in the hw.* space, keep all toe tunables within hw.cxgb */ +SYSCTL_DECL(_hw_cxgb); +SYSCTL_NODE(_hw_cxgb, OID_AUTO, toe, CTLFLAG_RD, 0, "TOE parameters"); + static struct tom_tunables default_tunable_vals = { .max_host_sndbuf = 32 * 1024, .tx_hold_thres = 0, @@ -100,11 +104,24 @@ static struct tom_tunables default_tunab .activated = 1, }; +static int activated = 1; +TUNABLE_INT("hw.cxgb.toe.activated", &activated); +SYSCTL_UINT(_hw_cxgb_toe, OID_AUTO, activated, CTLFLAG_RDTUN, &activated, 0, + "enable TOE at init time"); + +static int ddp = 1; +TUNABLE_INT("hw.cxgb.toe.ddp", &ddp); +SYSCTL_UINT(_hw_cxgb_toe, OID_AUTO, ddp, CTLFLAG_RDTUN, &ddp, 0, "enable DDP"); + void t3_init_tunables(struct tom_data *t) { t->conf = default_tunable_vals; + /* Adjust tunables */ + t->conf.activated = activated; + t->conf.ddp = ddp; + /* Now apply device specific fixups. */ t->conf.mss = T3C_DATA(t->cdev)->tx_max_chunk; t->conf.max_wrs = T3C_DATA(t->cdev)->max_wrs; From jfv at FreeBSD.org Sun Nov 30 20:03:18 2008 From: jfv at FreeBSD.org (Jack F Vogel) Date: Sun Nov 30 20:03:30 2008 Subject: svn commit: r185505 - stable/7/sys/dev/ixgbe Message-ID: <200812010403.mB143HoX011658@svn.freebsd.org> Author: jfv Date: Mon Dec 1 04:03:17 2008 New Revision: 185505 URL: http://svn.freebsd.org/changeset/base/185505 Log: MFC of version 1.6.2 of the ixgbe driver, contains header split, new adapter support, and general code improvement/cleanup. Approved by:re Modified: stable/7/sys/dev/ixgbe/ixgbe.c stable/7/sys/dev/ixgbe/ixgbe.h stable/7/sys/dev/ixgbe/ixgbe_82598.c stable/7/sys/dev/ixgbe/ixgbe_api.c stable/7/sys/dev/ixgbe/ixgbe_api.h stable/7/sys/dev/ixgbe/ixgbe_common.c stable/7/sys/dev/ixgbe/ixgbe_common.h stable/7/sys/dev/ixgbe/ixgbe_osdep.h stable/7/sys/dev/ixgbe/ixgbe_phy.c stable/7/sys/dev/ixgbe/ixgbe_phy.h stable/7/sys/dev/ixgbe/ixgbe_type.h Modified: stable/7/sys/dev/ixgbe/ixgbe.c ============================================================================== --- stable/7/sys/dev/ixgbe/ixgbe.c Mon Dec 1 03:00:26 2008 (r185504) +++ stable/7/sys/dev/ixgbe/ixgbe.c Mon Dec 1 04:03:17 2008 (r185505) @@ -46,7 +46,7 @@ int ixgbe_display_debug_stat /********************************************************************* * Driver version *********************************************************************/ -char ixgbe_driver_version[] = "1.4.7"; +char ixgbe_driver_version[] = "1.6.2"; /********************************************************************* * PCI Device ID Table @@ -62,11 +62,15 @@ static ixgbe_vendor_info_t ixgbe_vendor_ { {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT, 0, 0, 0}, - {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT_DUAL_PORT, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4, 0, 0, 0}, + {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT, 0, 0, 0}, + {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598, 0, 0, 0}, + {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR, 0, 0, 0}, {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT, 0, 0, 0}, + {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM, 0, 0, 0}, + {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM, 0, 0, 0}, /* required last entry */ {0, 0, 0, 0, 0} }; @@ -125,14 +129,14 @@ static void ixgbe_disable_intr(struc static void ixgbe_update_stats_counters(struct adapter *); static bool ixgbe_txeof(struct tx_ring *); static bool ixgbe_rxeof(struct rx_ring *, int); -static void ixgbe_rx_checksum(struct adapter *, u32, struct mbuf *); +static void ixgbe_rx_checksum(u32, struct mbuf *); static void ixgbe_set_promisc(struct adapter *); static void ixgbe_disable_promisc(struct adapter *); static void ixgbe_set_multi(struct adapter *); static void ixgbe_print_hw_stats(struct adapter *); static void ixgbe_print_debug_info(struct adapter *); static void ixgbe_update_link_status(struct adapter *); -static int ixgbe_get_buf(struct rx_ring *, int); +static int ixgbe_get_buf(struct rx_ring *, int, u8); static int ixgbe_xmit(struct tx_ring *, struct mbuf **); static int ixgbe_sysctl_stats(SYSCTL_HANDLER_ARGS); static int ixgbe_sysctl_debug(SYSCTL_HANDLER_ARGS); @@ -144,12 +148,19 @@ static void ixgbe_add_rx_process_limit(s const char *, int *, int); static boolean_t ixgbe_tx_ctx_setup(struct tx_ring *, struct mbuf *); static boolean_t ixgbe_tso_setup(struct tx_ring *, struct mbuf *, u32 *); -static void ixgbe_set_ivar(struct adapter *, u16, u8); +static void ixgbe_set_ivar(struct adapter *, u16, u8, s8); static void ixgbe_configure_ivars(struct adapter *); static u8 * ixgbe_mc_array_itr(struct ixgbe_hw *, u8 **, u32 *); +#ifdef IXGBE_HW_VLAN_SUPPORT static void ixgbe_register_vlan(void *, struct ifnet *, u16); static void ixgbe_unregister_vlan(void *, struct ifnet *, u16); +#endif + +static void ixgbe_update_aim(struct rx_ring *); + +/* Support for pluggable optic modules */ +static bool ixgbe_sfp_probe(struct adapter *); /* Legacy (single vector interrupt handler */ static void ixgbe_legacy_irq(void *); @@ -163,9 +174,6 @@ static void ixgbe_msix_link(void *); static void ixgbe_handle_tx(void *context, int pending); static void ixgbe_handle_rx(void *context, int pending); -#ifndef NO_82598_A0_SUPPORT -static void desc_flip(void *); -#endif /********************************************************************* * FreeBSD Device Interface Entry Points @@ -194,12 +202,28 @@ MODULE_DEPEND(ixgbe, ether, 1, 1, 1); ** TUNEABLE PARAMETERS: */ +/* +** These parameters are used in Adaptive +** Interrupt Moderation. The value is set +** into EITR and controls the interrupt +** frequency. They can be modified but +** be careful in tuning them. +*/ +static int ixgbe_enable_aim = TRUE; +TUNABLE_INT("hw.ixgbe.enable_aim", &ixgbe_enable_aim); +static int ixgbe_low_latency = IXGBE_LOW_LATENCY; +TUNABLE_INT("hw.ixgbe.low_latency", &ixgbe_low_latency); +static int ixgbe_ave_latency = IXGBE_LOW_LATENCY; +TUNABLE_INT("hw.ixgbe.ave_latency", &ixgbe_low_latency); +static int ixgbe_bulk_latency = IXGBE_BULK_LATENCY; +TUNABLE_INT("hw.ixgbe.bulk_latency", &ixgbe_bulk_latency); + /* How many packets rxeof tries to clean at a time */ static int ixgbe_rx_process_limit = 100; TUNABLE_INT("hw.ixgbe.rx_process_limit", &ixgbe_rx_process_limit); /* Flow control setting, default to full */ -static int ixgbe_flow_control = 3; +static int ixgbe_flow_control = ixgbe_fc_none; TUNABLE_INT("hw.ixgbe.flow_control", &ixgbe_flow_control); /* @@ -208,7 +232,7 @@ TUNABLE_INT("hw.ixgbe.flow_control", &ix * interface must be reset (down/up) for it * to take effect. */ -static int ixgbe_enable_lro = 0; +static int ixgbe_enable_lro = 1; TUNABLE_INT("hw.ixgbe.enable_lro", &ixgbe_enable_lro); /* @@ -219,12 +243,18 @@ static int ixgbe_enable_msix = 1; TUNABLE_INT("hw.ixgbe.enable_msix", &ixgbe_enable_msix); /* + * Enable RX Header Split + */ +static int ixgbe_rx_hdr_split = 1; +TUNABLE_INT("hw.ixgbe.rx_hdr_split", &ixgbe_rx_hdr_split); + +/* * Number of TX/RX Queues, with 0 setting * it autoconfigures to the number of cpus. */ static int ixgbe_tx_queues = 1; TUNABLE_INT("hw.ixgbe.tx_queues", &ixgbe_tx_queues); -static int ixgbe_rx_queues = 4; +static int ixgbe_rx_queues = 1; TUNABLE_INT("hw.ixgbe.rx_queues", &ixgbe_rx_queues); /* Number of TX descriptors per ring */ @@ -238,9 +268,6 @@ TUNABLE_INT("hw.ixgbe.rxd", &ixgbe_rxd); /* Total number of Interfaces - need for config sanity check */ static int ixgbe_total_ports; -/* Optics type of this interface */ -static int ixgbe_optics; - /********************************************************************* * Device identification routine * @@ -255,11 +282,11 @@ ixgbe_probe(device_t dev) { ixgbe_vendor_info_t *ent; - u_int16_t pci_vendor_id = 0; - u_int16_t pci_device_id = 0; - u_int16_t pci_subvendor_id = 0; - u_int16_t pci_subdevice_id = 0; - char adapter_name[128]; + u16 pci_vendor_id = 0; + u16 pci_device_id = 0; + u16 pci_subvendor_id = 0; + u16 pci_subdevice_id = 0; + char adapter_name[256]; INIT_DEBUGOUT("ixgbe_probe: begin"); @@ -284,41 +311,11 @@ ixgbe_probe(device_t dev) sprintf(adapter_name, "%s, Version - %s", ixgbe_strings[ent->index], ixgbe_driver_version); - switch (pci_device_id) { - case IXGBE_DEV_ID_82598AT_DUAL_PORT : - ixgbe_total_ports += 2; - break; - case IXGBE_DEV_ID_82598_CX4_DUAL_PORT : - ixgbe_optics = IFM_10G_CX4; - ixgbe_total_ports += 2; - break; - case IXGBE_DEV_ID_82598AF_DUAL_PORT : - ixgbe_optics = IFM_10G_SR; - ixgbe_total_ports += 2; - break; - case IXGBE_DEV_ID_82598AF_SINGLE_PORT : - ixgbe_optics = IFM_10G_SR; - ixgbe_total_ports += 1; - break; - case IXGBE_DEV_ID_82598EB_XF_LR : - ixgbe_optics = IFM_10G_LR; - ixgbe_total_ports += 1; - break; - case IXGBE_DEV_ID_82598EB_CX4 : - ixgbe_optics = IFM_10G_CX4; - ixgbe_total_ports += 1; - break; - case IXGBE_DEV_ID_82598AT : - ixgbe_total_ports += 1; - default: - break; - } device_set_desc_copy(dev, adapter_name); return (0); } ent++; } - return (ENXIO); } @@ -337,7 +334,8 @@ ixgbe_attach(device_t dev) { struct adapter *adapter; int error = 0; - u32 ctrl_ext; + u16 pci_device_id; + u32 ctrl_ext; INIT_DEBUGOUT("ixgbe_attach: begin"); @@ -348,6 +346,37 @@ ixgbe_attach(device_t dev) /* Core Lock Init*/ IXGBE_CORE_LOCK_INIT(adapter, device_get_nameunit(dev)); + /* Keep track of number of ports and optics */ + pci_device_id = pci_get_device(dev); + switch (pci_device_id) { + case IXGBE_DEV_ID_82598_CX4_DUAL_PORT : + adapter->optics = IFM_10G_CX4; + ixgbe_total_ports += 2; + break; + case IXGBE_DEV_ID_82598AF_DUAL_PORT : + adapter->optics = IFM_10G_SR; + ixgbe_total_ports += 2; + break; + case IXGBE_DEV_ID_82598AF_SINGLE_PORT : + adapter->optics = IFM_10G_SR; + ixgbe_total_ports += 1; + break; + case IXGBE_DEV_ID_82598EB_XF_LR : + adapter->optics = IFM_10G_LR; + ixgbe_total_ports += 1; + break; + case IXGBE_DEV_ID_82598EB_CX4 : + adapter->optics = IFM_10G_CX4; + ixgbe_total_ports += 1; + break; + case IXGBE_DEV_ID_82598AT : + ixgbe_total_ports += 1; + case IXGBE_DEV_ID_82598_DA_DUAL_PORT : + ixgbe_total_ports += 2; + default: + break; + } + /* SYSCTL APIs */ SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), @@ -369,15 +398,37 @@ ixgbe_attach(device_t dev) OID_AUTO, "enable_lro", CTLTYPE_INT|CTLFLAG_RW, &ixgbe_enable_lro, 1, "Large Receive Offload"); + SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "enable_aim", CTLTYPE_INT|CTLFLAG_RW, + &ixgbe_enable_aim, 1, "Interrupt Moderation"); + + SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "low_latency", CTLTYPE_INT|CTLFLAG_RW, + &ixgbe_low_latency, 1, "Low Latency"); + + SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "ave_latency", CTLTYPE_INT|CTLFLAG_RW, + &ixgbe_ave_latency, 1, "Average Latency"); + + SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "bulk_latency", CTLTYPE_INT|CTLFLAG_RW, + &ixgbe_bulk_latency, 1, "Bulk Latency"); + + SYSCTL_ADD_INT(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), + OID_AUTO, "hdr_split", CTLTYPE_INT|CTLFLAG_RW, + &ixgbe_rx_hdr_split, 1, "RX Header Split"); + /* Set up the timer callout */ callout_init_mtx(&adapter->timer, &adapter->core_mtx, 0); /* Determine hardware revision */ ixgbe_identify_hardware(adapter); - /* Indicate to RX setup to use Jumbo Clusters */ - adapter->bigbufs = TRUE; - /* Do base PCI setup - map BAR0 */ if (ixgbe_allocate_pci_resources(adapter)) { device_printf(dev, "Allocation of PCI resources failed\n"); @@ -423,7 +474,20 @@ ixgbe_attach(device_t dev) } /* Initialize the shared code */ - if (ixgbe_init_shared_code(&adapter->hw)) { + error = ixgbe_init_shared_code(&adapter->hw); + if (error == IXGBE_ERR_SFP_NOT_PRESENT) { + /* + ** No optics in this port, set up + ** so the timer routine will probe + ** for later insertion. + */ + adapter->sfp_probe = TRUE; + error = 0; + } else if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) { + device_printf(dev,"Unsupported SFP+ module detected!\n"); + error = EIO; + goto err_late; + } else if (error) { device_printf(dev,"Unable to initialize the shared code\n"); error = EIO; goto err_late; @@ -454,12 +518,14 @@ ixgbe_attach(device_t dev) /* Initialize statistics */ ixgbe_update_stats_counters(adapter); +#ifdef IXGBE_HW_VLAN_SUPPORT /* Register for VLAN events */ adapter->vlan_attach = EVENTHANDLER_REGISTER(vlan_config, ixgbe_register_vlan, 0, EVENTHANDLER_PRI_FIRST); adapter->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig, ixgbe_unregister_vlan, 0, EVENTHANDLER_PRI_FIRST); - +#endif + /* let hardware know driver is loaded */ ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT); ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD; @@ -514,7 +580,6 @@ ixgbe_detach(device_t dev) if (txr->tq) { taskqueue_drain(txr->tq, &txr->tx_task); taskqueue_free(txr->tq); - txr->tq = NULL; } } @@ -522,20 +587,21 @@ ixgbe_detach(device_t dev) if (rxr->tq) { taskqueue_drain(rxr->tq, &rxr->rx_task); taskqueue_free(rxr->tq); - rxr->tq = NULL; } } + /* let hardware know driver is unloading */ + ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT); + ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD; + IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, ctrl_ext); + +#ifdef IXGBE_HW_VLAN_SUPPORT /* Unregister VLAN events */ if (adapter->vlan_attach != NULL) EVENTHANDLER_DEREGISTER(vlan_config, adapter->vlan_attach); if (adapter->vlan_detach != NULL) EVENTHANDLER_DEREGISTER(vlan_unconfig, adapter->vlan_detach); - - /* let hardware know driver is unloading */ - ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT); - ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD; - IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, ctrl_ext); +#endif ether_ifdetach(adapter->ifp); callout_drain(&adapter->timer); @@ -839,10 +905,13 @@ ixgbe_watchdog(struct adapter *adapter) static void ixgbe_init_locked(struct adapter *adapter) { + struct rx_ring *rxr = adapter->rx_rings; + struct tx_ring *txr = adapter->tx_rings; struct ifnet *ifp = adapter->ifp; device_t dev = adapter->dev; struct ixgbe_hw *hw; - u32 txdctl, rxdctl, mhadd, gpie; + u32 k, txdctl, mhadd, gpie; + u32 rxdctl, rxctrl; INIT_DEBUGOUT("ixgbe_init: begin"); @@ -863,6 +932,16 @@ ixgbe_init_locked(struct adapter *adapte return; } +#ifndef IXGBE_HW_VLAN_SUPPORT + if (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) { + u32 ctrl; + + ctrl = IXGBE_READ_REG(&adapter->hw, IXGBE_VLNCTRL); + ctrl |= IXGBE_VLNCTRL_VME; + ctrl &= ~IXGBE_VLNCTRL_CFIEN; + IXGBE_WRITE_REG(&adapter->hw, IXGBE_VLNCTRL, ctrl); + } +#endif /* Prepare transmit descriptors and buffers */ if (ixgbe_setup_transmit_structures(adapter)) { device_printf(dev,"Could not setup transmit structures\n"); @@ -872,15 +951,24 @@ ixgbe_init_locked(struct adapter *adapte ixgbe_initialize_transmit_units(adapter); + /* TX irq moderation rate is fixed */ + for (int i = 0; i < adapter->num_tx_queues; i++, txr++) { + IXGBE_WRITE_REG(&adapter->hw, + IXGBE_EITR(txr->msix), ixgbe_ave_latency); + txr->watchdog_timer = FALSE; + } + /* Setup Multicast table */ ixgbe_set_multi(adapter); /* - ** If we are resetting MTU smaller than 2K - ** drop to small RX buffers + ** Determine the correct mbuf pool + ** for doing jumbo/headersplit */ - if (adapter->max_frame_size <= MCLBYTES) - adapter->bigbufs = FALSE; + if (ifp->if_mtu > ETHERMTU) + adapter->rx_mbuf_sz = MJUMPAGESIZE; + else + adapter->rx_mbuf_sz = MCLBYTES; /* Prepare receive descriptors and buffers */ if (ixgbe_setup_receive_structures(adapter)) { @@ -892,10 +980,22 @@ ixgbe_init_locked(struct adapter *adapte /* Configure RX settings */ ixgbe_initialize_receive_units(adapter); + /* RX moderation will be adapted over time, set default */ + for (int i = 0; i < adapter->num_rx_queues; i++, rxr++) { + IXGBE_WRITE_REG(&adapter->hw, + IXGBE_EITR(rxr->msix), ixgbe_low_latency); + } + + /* Set Link moderation */ + IXGBE_WRITE_REG(&adapter->hw, + IXGBE_EITR(adapter->linkvec), IXGBE_LINK_ITR); + gpie = IXGBE_READ_REG(&adapter->hw, IXGBE_GPIE); + /* Enable Fan Failure Interrupt */ if (adapter->hw.phy.media_type == ixgbe_media_type_copper) gpie |= IXGBE_SDP1_GPIEN; + if (adapter->msix) { /* Enable Enhanced MSIX mode */ gpie |= IXGBE_GPIE_MSIX_MODE; @@ -935,12 +1035,29 @@ ixgbe_init_locked(struct adapter *adapte rxdctl |= 0x0020; rxdctl |= IXGBE_RXDCTL_ENABLE; IXGBE_WRITE_REG(&adapter->hw, IXGBE_RXDCTL(i), rxdctl); + for (k = 0; k < 10; k++) { + if (IXGBE_READ_REG(hw, IXGBE_RXDCTL(i)) & + IXGBE_RXDCTL_ENABLE) + break; + else + msec_delay(1); + } + wmb(); + IXGBE_WRITE_REG(hw, IXGBE_RDT(i), adapter->num_rx_desc - 1); } + /* Enable Receive engine */ + rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL); + if (adapter->hw.mac.type == ixgbe_mac_82598EB) + rxctrl |= IXGBE_RXCTRL_DMBYPS; + rxctrl |= IXGBE_RXCTRL_RXEN; + IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl); + callout_reset(&adapter->timer, hz, ixgbe_local_timer, adapter); /* Set up MSI/X routing */ - ixgbe_configure_ivars(adapter); + if (ixgbe_enable_msix) + ixgbe_configure_ivars(adapter); ixgbe_enable_intr(adapter); @@ -964,7 +1081,7 @@ ixgbe_init(void *arg) /* -** Legacy Deferred Interrupt Handlers +** MSIX Interrupt Handlers */ static void @@ -972,11 +1089,14 @@ ixgbe_handle_rx(void *context, int pendi { struct rx_ring *rxr = context; struct adapter *adapter = rxr->adapter; - u32 loop = 0; + u32 loop = MAX_LOOP; + bool more; - while (loop++ < MAX_INTR) - if (ixgbe_rxeof(rxr, adapter->rx_process_limit) == 0) - break; + do { + more = ixgbe_rxeof(rxr, -1); + } while (loop-- && more); + /* Reenable this interrupt */ + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, rxr->eims); } static void @@ -985,15 +1105,21 @@ ixgbe_handle_tx(void *context, int pendi struct tx_ring *txr = context; struct adapter *adapter = txr->adapter; struct ifnet *ifp = adapter->ifp; - u32 loop = 0; + u32 loop = MAX_LOOP; + bool more; - IXGBE_TX_LOCK(txr); - while (loop++ < MAX_INTR) - if (ixgbe_txeof(txr) == 0) - break; - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - ixgbe_start_locked(txr, ifp); - IXGBE_TX_UNLOCK(txr); + IXGBE_TX_LOCK(txr); + do { + more = ixgbe_txeof(txr); + } while (loop-- && more); + + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + ixgbe_start_locked(txr, ifp); + + IXGBE_TX_UNLOCK(txr); + + /* Reenable this interrupt */ + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, txr->eims); } @@ -1006,34 +1132,38 @@ ixgbe_handle_tx(void *context, int pendi static void ixgbe_legacy_irq(void *arg) { - u32 reg_eicr; struct adapter *adapter = arg; + struct ixgbe_hw *hw = &adapter->hw; struct tx_ring *txr = adapter->tx_rings; struct rx_ring *rxr = adapter->rx_rings; - struct ixgbe_hw *hw; + u32 reg_eicr; - hw = &adapter->hw; - reg_eicr = IXGBE_READ_REG(&adapter->hw, IXGBE_EICR); - if (reg_eicr == 0) + + reg_eicr = IXGBE_READ_REG(hw, IXGBE_EICR); + + if (reg_eicr == 0) { + ixgbe_enable_intr(adapter); return; + } - if (ixgbe_rxeof(rxr, adapter->rx_process_limit) != 0) + if (ixgbe_rxeof(rxr, adapter->rx_process_limit)) taskqueue_enqueue(rxr->tq, &rxr->rx_task); - if (ixgbe_txeof(txr) != 0) - taskqueue_enqueue(txr->tq, &txr->tx_task); + if (ixgbe_txeof(txr)) + taskqueue_enqueue(txr->tq, &txr->tx_task); /* Check for fan failure */ if ((hw->phy.media_type == ixgbe_media_type_copper) && (reg_eicr & IXGBE_EICR_GPI_SDP1)) { device_printf(adapter->dev, "\nCRITICAL: FAN FAILURE!! " "REPLACE IMMEDIATELY!!\n"); - IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, - IXGBE_EICR_GPI_SDP1); + IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EICR_GPI_SDP1); } + /* Link status change */ if (reg_eicr & IXGBE_EICR_LSC) ixgbe_update_link_status(adapter); + ixgbe_enable_intr(adapter); return; } @@ -1047,25 +1177,25 @@ ixgbe_legacy_irq(void *arg) void ixgbe_msix_tx(void *arg) { - struct tx_ring *txr = arg; - struct adapter *adapter = txr->adapter; - u32 loop = 0; + struct tx_ring *txr = arg; + struct adapter *adapter = txr->adapter; + bool more; - ++txr->tx_irq; IXGBE_TX_LOCK(txr); - while (loop++ < MAX_INTR) - if (ixgbe_txeof(txr) == 0) - break; + ++txr->tx_irq; + more = ixgbe_txeof(txr); IXGBE_TX_UNLOCK(txr); - /* Reenable this interrupt */ - IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, txr->eims); - + if (more) + taskqueue_enqueue(txr->tq, &txr->tx_task); + else /* Reenable this interrupt */ + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, txr->eims); return; } + /********************************************************************* * - * MSI RX Interrupt Service routine + * MSIX RX Interrupt Service routine * **********************************************************************/ @@ -1073,18 +1203,71 @@ static void ixgbe_msix_rx(void *arg) { struct rx_ring *rxr = arg; - struct adapter *adapter = rxr->adapter; - u32 loop = 0; + struct adapter *adapter = rxr->adapter; + bool more; ++rxr->rx_irq; - while (loop++ < MAX_INTR) - if (ixgbe_rxeof(rxr, adapter->rx_process_limit) == 0) - break; - /* Reenable this interrupt */ - IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, rxr->eims); + more = ixgbe_rxeof(rxr, -1); + if (more) + taskqueue_enqueue(rxr->tq, &rxr->rx_task); + else + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, rxr->eims); + /* Update interrupt rate */ + if (ixgbe_enable_aim == TRUE) + ixgbe_update_aim(rxr); return; } +/* +** Routine to do adjust the RX EITR value based on traffic, +** its a simple three state model, but seems to help. +** +** Note that the three EITR values are tuneable using +** sysctl in real time. The feature can be effectively +** nullified by setting them equal. +*/ +#define BULK_THRESHOLD 10000 +#define AVE_THRESHOLD 1600 + +static void +ixgbe_update_aim(struct rx_ring *rxr) +{ + struct adapter *adapter = rxr->adapter; + u32 olditr, newitr; + + /* Update interrupt moderation based on traffic */ + olditr = rxr->eitr_setting; + newitr = olditr; + + /* Idle, don't change setting */ + if (rxr->bytes == 0) + return; + + if (olditr == ixgbe_low_latency) { + if (rxr->bytes > AVE_THRESHOLD) + newitr = ixgbe_ave_latency; + } else if (olditr == ixgbe_ave_latency) { + if (rxr->bytes < AVE_THRESHOLD) + newitr = ixgbe_low_latency; + else if (rxr->bytes > BULK_THRESHOLD) + newitr = ixgbe_bulk_latency; + } else if (olditr == ixgbe_bulk_latency) { + if (rxr->bytes < BULK_THRESHOLD) + newitr = ixgbe_ave_latency; + } + + if (olditr != newitr) { + /* Change interrupt rate */ + rxr->eitr_setting = newitr; + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITR(rxr->me), + newitr | (newitr << 16)); + } + + rxr->bytes = 0; + return; +} + + static void ixgbe_msix_link(void *arg) { @@ -1144,7 +1327,7 @@ ixgbe_media_status(struct ifnet * ifp, s ifmr->ifm_active |= IFM_1000_T | IFM_FDX; break; case IXGBE_LINK_SPEED_10GB_FULL: - ifmr->ifm_active |= ixgbe_optics | IFM_FDX; + ifmr->ifm_active |= adapter->optics | IFM_FDX; break; } @@ -1200,7 +1383,7 @@ ixgbe_xmit(struct tx_ring *txr, struct m { struct adapter *adapter = txr->adapter; u32 olinfo_status = 0, cmd_type_len = 0; - u32 paylen; + u32 paylen = 0; int i, j, error, nsegs; int first, last = 0; struct mbuf *m_head; @@ -1210,7 +1393,6 @@ ixgbe_xmit(struct tx_ring *txr, struct m union ixgbe_adv_tx_desc *txd = NULL; m_head = *m_headp; - paylen = 0; /* Basic descriptor defines */ cmd_type_len |= IXGBE_ADVTXD_DTYP_DATA; @@ -1254,7 +1436,7 @@ ixgbe_xmit(struct tx_ring *txr, struct m m = m_defrag(*m_headp, M_DONTWAIT); if (m == NULL) { - adapter->mbuf_alloc_failed++; + adapter->mbuf_defrag_failed++; m_freem(*m_headp); *m_headp = NULL; return (ENOBUFS); @@ -1306,6 +1488,11 @@ ixgbe_xmit(struct tx_ring *txr, struct m } else if (ixgbe_tx_ctx_setup(txr, m_head)) olinfo_status |= IXGBE_TXD_POPTS_TXSM << 8; + /* Record payload length */ + if (paylen == 0) + olinfo_status |= m_head->m_pkthdr.len << + IXGBE_ADVTXD_PAYLEN_SHIFT; + i = txr->next_avail_tx_desc; for (j = 0; j < nsegs; j++) { bus_size_t seglen; @@ -1326,19 +1513,10 @@ ixgbe_xmit(struct tx_ring *txr, struct m i = 0; txbuf->m_head = NULL; - /* - ** we have to do this inside the loop right now - ** because of the hardware workaround. - */ - if (j == (nsegs -1)) /* Last descriptor gets EOP and RS */ - txd->read.cmd_type_len |= - htole32(IXGBE_TXD_CMD_EOP | IXGBE_TXD_CMD_RS); -#ifndef NO_82598_A0_SUPPORT - if (adapter->hw.revision_id == 0) - desc_flip(txd); -#endif } + txd->read.cmd_type_len |= + htole32(IXGBE_TXD_CMD_EOP | IXGBE_TXD_CMD_RS); txr->tx_avail -= nsegs; txr->next_avail_tx_desc = i; @@ -1355,8 +1533,8 @@ ixgbe_xmit(struct tx_ring *txr, struct m * Advance the Transmit Descriptor Tail (Tdt), this tells the * hardware that this frame is available to transmit. */ + ++txr->total_packets; IXGBE_WRITE_REG(&adapter->hw, IXGBE_TDT(txr->me), i); - ++txr->tx_packets; return (0); xmit_fail: @@ -1484,17 +1662,26 @@ ixgbe_local_timer(void *arg) mtx_assert(&adapter->core_mtx, MA_OWNED); + /* Check for pluggable optics */ + if (adapter->sfp_probe) + if (!ixgbe_sfp_probe(adapter)) + goto out; /* Nothing to do */ + ixgbe_update_link_status(adapter); ixgbe_update_stats_counters(adapter); if (ixgbe_display_debug_stats && ifp->if_drv_flags & IFF_DRV_RUNNING) { ixgbe_print_hw_stats(adapter); } /* - * Each second we check the watchdog + * Each tick we check the watchdog * to protect against hardware hangs. */ ixgbe_watchdog(adapter); +out: + /* Trigger an RX interrupt on all queues */ + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS, adapter->rx_mask); + callout_reset(&adapter->timer, hz, ixgbe_local_timer, adapter); } @@ -1681,6 +1868,11 @@ ixgbe_allocate_msix(struct adapter *adap } txr->msix = vector; txr->eims = IXGBE_IVAR_TX_QUEUE(vector); + TASK_INIT(&txr->tx_task, 0, ixgbe_handle_tx, txr); + txr->tq = taskqueue_create_fast("ixgbe_txq", M_NOWAIT, + taskqueue_thread_enqueue, &txr->tq); + taskqueue_start_threads(&txr->tq, 1, PI_NET, "%s txq", + device_get_nameunit(adapter->dev)); } /* RX setup */ @@ -1705,6 +1897,13 @@ ixgbe_allocate_msix(struct adapter *adap } rxr->msix = vector; rxr->eims = IXGBE_IVAR_RX_QUEUE(vector); + /* used in local timer */ + adapter->rx_mask |= rxr->eims; + TASK_INIT(&rxr->rx_task, 0, ixgbe_handle_rx, rxr); + rxr->tq = taskqueue_create_fast("ixgbe_rxq", M_NOWAIT, + taskqueue_thread_enqueue, &rxr->tq); + taskqueue_start_threads(&rxr->tq, 1, PI_NET, "%s rxq", + device_get_nameunit(adapter->dev)); } /* Now for Link changes */ @@ -1739,11 +1938,20 @@ ixgbe_setup_msix(struct adapter *adapter device_t dev = adapter->dev; int rid, want, queues, msgs; + /* Override by tuneable */ + if (ixgbe_enable_msix == 0) + goto msi; + /* First try MSI/X */ - rid = PCIR_BAR(IXGBE_MSIX_BAR); + rid = PCIR_BAR(MSIX_82598_BAR); adapter->msix_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (!adapter->msix_mem) { + rid += 4; /* 82599 maps in higher BAR */ + adapter->msix_mem = bus_alloc_resource_any(dev, + SYS_RES_MEMORY, &rid, RF_ACTIVE); + } + if (!adapter->msix_mem) { /* May not be enabled */ device_printf(adapter->dev, "Unable to map MSIX table \n"); @@ -1753,7 +1961,7 @@ ixgbe_setup_msix(struct adapter *adapter msgs = pci_msix_count(dev); if (msgs == 0) { /* system has msix disabled */ bus_release_resource(dev, SYS_RES_MEMORY, - PCIR_BAR(IXGBE_MSIX_BAR), adapter->msix_mem); + rid, adapter->msix_mem); adapter->msix_mem = NULL; goto msi; } @@ -1833,7 +2041,8 @@ ixgbe_allocate_pci_resources(struct adap static void ixgbe_free_pci_resources(struct adapter * adapter) { - device_t dev = adapter->dev; + device_t dev = adapter->dev; + int rid; /* * Legacy has this set to 0, but we need @@ -1842,6 +2051,8 @@ ixgbe_free_pci_resources(struct adapter if (adapter->msix == 0) adapter->msix = 1; + rid = PCIR_BAR(MSIX_82598_BAR); + /* * First release all the interrupt resources: * notice that since these are just kept @@ -1865,7 +2076,7 @@ ixgbe_free_pci_resources(struct adapter if (adapter->msix_mem != NULL) bus_release_resource(dev, SYS_RES_MEMORY, - PCIR_BAR(IXGBE_MSIX_BAR), adapter->msix_mem); + rid, adapter->msix_mem); if (adapter->pci_mem != NULL) bus_release_resource(dev, SYS_RES_MEMORY, @@ -1900,7 +2111,7 @@ ixgbe_hardware_init(struct adapter *adap } /* Get Hardware Flow Control setting */ - adapter->hw.fc.type = ixgbe_fc_full; + adapter->hw.fc.requested_mode = ixgbe_fc_full; adapter->hw.fc.pause_time = IXGBE_FC_PAUSE; adapter->hw.fc.low_water = IXGBE_FC_LO; adapter->hw.fc.high_water = IXGBE_FC_HI; @@ -1957,8 +2168,7 @@ ixgbe_setup_interface(device_t dev, stru ifp->if_capenable = ifp->if_capabilities; - if ((hw->device_id == IXGBE_DEV_ID_82598AT) || - (hw->device_id == IXGBE_DEV_ID_82598AT_DUAL_PORT)) + if (hw->device_id == IXGBE_DEV_ID_82598AT) ixgbe_setup_link_speed(hw, (IXGBE_LINK_SPEED_10GB_FULL | IXGBE_LINK_SPEED_1GB_FULL), TRUE, TRUE); else @@ -1971,10 +2181,9 @@ ixgbe_setup_interface(device_t dev, stru */ ifmedia_init(&adapter->media, IFM_IMASK, ixgbe_media_change, ixgbe_media_status); - ifmedia_add(&adapter->media, IFM_ETHER | ixgbe_optics | + ifmedia_add(&adapter->media, IFM_ETHER | adapter->optics | IFM_FDX, 0, NULL); - if ((hw->device_id == IXGBE_DEV_ID_82598AT) || - (hw->device_id == IXGBE_DEV_ID_82598AT_DUAL_PORT)) { + if (hw->device_id == IXGBE_DEV_ID_82598AT) { ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL); ifmedia_add(&adapter->media, @@ -2075,7 +2284,6 @@ ixgbe_allocate_queues(struct adapter *ad struct tx_ring *txr; struct rx_ring *rxr; int rsize, tsize, error = IXGBE_SUCCESS; - char name_string[16]; int txconf = 0, rxconf = 0; /* First allocate the TX ring struct memory */ @@ -2114,9 +2322,9 @@ ixgbe_allocate_queues(struct adapter *ad txr->me = i; /* Initialize the TX side lock */ - snprintf(name_string, sizeof(name_string), "%s:tx(%d)", + snprintf(txr->mtx_name, sizeof(txr->mtx_name), "%s:tx(%d)", device_get_nameunit(dev), txr->me); - mtx_init(&txr->tx_mtx, name_string, NULL, MTX_DEF); + mtx_init(&txr->tx_mtx, txr->mtx_name, NULL, MTX_DEF); if (ixgbe_dma_malloc(adapter, tsize, &txr->txdma, BUS_DMA_NOWAIT)) { @@ -2149,10 +2357,10 @@ ixgbe_allocate_queues(struct adapter *ad rxr->adapter = adapter; rxr->me = i; - /* Initialize the TX side lock */ - snprintf(name_string, sizeof(name_string), "%s:rx(%d)", + /* Initialize the RX side lock */ + snprintf(rxr->mtx_name, sizeof(rxr->mtx_name), "%s:rx(%d)", device_get_nameunit(dev), rxr->me); - mtx_init(&rxr->rx_mtx, name_string, NULL, MTX_DEF); + mtx_init(&rxr->rx_mtx, rxr->mtx_name, NULL, MTX_DEF); if (ixgbe_dma_malloc(adapter, rsize, &rxr->rxdma, BUS_DMA_NOWAIT)) { @@ -2534,11 +2742,6 @@ ixgbe_tx_ctx_setup(struct tx_ring *txr, TXD->seqnum_seed = htole32(0); TXD->mss_l4len_idx = htole32(0); -#ifndef NO_82598_A0_SUPPORT - if (adapter->hw.revision_id == 0) - desc_flip(TXD); -#endif - tx_buffer->m_head = NULL; /* We've consumed the first desc, adjust counters */ @@ -2632,11 +2835,6 @@ ixgbe_tso_setup(struct tx_ring *txr, str TXD->seqnum_seed = htole32(0); tx_buffer->m_head = NULL; -#ifndef NO_82598_A0_SUPPORT - if (adapter->hw.revision_id == 0) - desc_flip(TXD); -#endif - if (++ctxd == adapter->num_tx_desc) ctxd = 0; @@ -2758,76 +2956,110 @@ ixgbe_txeof(struct tx_ring *txr) * **********************************************************************/ static int -ixgbe_get_buf(struct rx_ring *rxr, int i) +ixgbe_get_buf(struct rx_ring *rxr, int i, u8 clean) { - struct adapter *adapter = rxr->adapter; - struct mbuf *mp; - bus_dmamap_t map; - int nsegs, error, old, s = 0; - int size = MCLBYTES; - *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From jfv at FreeBSD.org Sun Nov 30 23:13:53 2008 From: jfv at FreeBSD.org (Jack F Vogel) Date: Sun Nov 30 23:14:06 2008 Subject: svn commit: r185510 - stable/7/sys/dev/e1000 Message-ID: <200812010713.mB17Dqu8015582@svn.freebsd.org> Author: jfv Date: Mon Dec 1 07:13:52 2008 New Revision: 185510 URL: http://svn.freebsd.org/changeset/base/185510 Log: MFC of a critical fix for the ESB2 adapters in the em driver, however the fix required a shared code change that involves both em and igb, requiring some compatibility changes throughout. Also, the igb driver now has header split. This is a hardware assist that is able to seperate the payload and header into seperate buffers. Using jumbo frames and 4K mbuf clusters, this should allow the use of ZERO COPY, but that has yet to be implemented. Approved by:re Modified: stable/7/sys/dev/e1000/e1000_80003es2lan.c stable/7/sys/dev/e1000/e1000_82540.c stable/7/sys/dev/e1000/e1000_82541.c stable/7/sys/dev/e1000/e1000_82542.c stable/7/sys/dev/e1000/e1000_82543.c stable/7/sys/dev/e1000/e1000_82571.c stable/7/sys/dev/e1000/e1000_82575.c stable/7/sys/dev/e1000/e1000_82575.h stable/7/sys/dev/e1000/e1000_api.c stable/7/sys/dev/e1000/e1000_api.h stable/7/sys/dev/e1000/e1000_defines.h stable/7/sys/dev/e1000/e1000_hw.h stable/7/sys/dev/e1000/e1000_ich8lan.c stable/7/sys/dev/e1000/e1000_ich8lan.h stable/7/sys/dev/e1000/e1000_mac.c stable/7/sys/dev/e1000/e1000_mac.h stable/7/sys/dev/e1000/e1000_manage.c stable/7/sys/dev/e1000/e1000_nvm.c stable/7/sys/dev/e1000/e1000_osdep.c stable/7/sys/dev/e1000/e1000_osdep.h stable/7/sys/dev/e1000/e1000_phy.c stable/7/sys/dev/e1000/e1000_phy.h stable/7/sys/dev/e1000/e1000_regs.h stable/7/sys/dev/e1000/if_em.c stable/7/sys/dev/e1000/if_em.h stable/7/sys/dev/e1000/if_igb.c stable/7/sys/dev/e1000/if_igb.h Modified: stable/7/sys/dev/e1000/e1000_80003es2lan.c ============================================================================== --- stable/7/sys/dev/e1000/e1000_80003es2lan.c Mon Dec 1 05:44:08 2008 (r185509) +++ stable/7/sys/dev/e1000/e1000_80003es2lan.c Mon Dec 1 07:13:52 2008 (r185510) @@ -32,7 +32,9 @@ ******************************************************************************/ /*$FreeBSD$*/ -/* e1000_80003es2lan +/* + * 80003ES2LAN Gigabit Ethernet Controller (Copper) + * 80003ES2LAN Gigabit Ethernet Controller (Serdes) */ #include "e1000_api.h" @@ -41,7 +43,9 @@ static s32 e1000_init_phy_params_80003e static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw); static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw); static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw); +static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw); static void e1000_release_phy_80003es2lan(struct e1000_hw *hw); +static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw); static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw); static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw); static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, @@ -64,6 +68,11 @@ static void e1000_clear_hw_cntrs_80003es static s32 e1000_acquire_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex); static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw); +static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw); +static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, + u16 *data); +static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, + u16 data); static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw); static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw); static void e1000_release_swfw_sync_80003es2lan(struct e1000_hw *hw, u16 mask); @@ -84,8 +93,6 @@ static const u16 e1000_gg82563_cable_len /** * e1000_init_phy_params_80003es2lan - Init ESB2 PHY func ptrs. * @hw: pointer to the HW structure - * - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_phy_params_80003es2lan(struct e1000_hw *hw) { @@ -122,6 +129,8 @@ static s32 e1000_init_phy_params_80003es phy->ops.read_reg = e1000_read_phy_reg_gg82563_80003es2lan; phy->ops.write_reg = e1000_write_phy_reg_gg82563_80003es2lan; + phy->ops.cfg_on_link_up = e1000_cfg_on_link_up_80003es2lan; + /* This can only be done after all function pointers are setup. */ ret_val = e1000_get_phy_id(hw); @@ -138,8 +147,6 @@ out: /** * e1000_init_nvm_params_80003es2lan - Init ESB2 NVM func ptrs. * @hw: pointer to the HW structure - * - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw) { @@ -197,8 +204,6 @@ static s32 e1000_init_nvm_params_80003es /** * e1000_init_mac_params_80003es2lan - Init ESB2 MAC func ptrs. * @hw: pointer to the HW structure - * - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw) { @@ -280,8 +285,6 @@ static s32 e1000_init_mac_params_80003es /* turn on/off LED */ mac->ops.led_on = e1000_led_on_generic; mac->ops.led_off = e1000_led_off_generic; - /* remove device */ - mac->ops.remove_device = e1000_remove_device_generic; /* clear hardware counters */ mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_80003es2lan; /* link info */ @@ -295,8 +298,7 @@ out: * e1000_init_function_pointers_80003es2lan - Init ESB2 func ptrs. * @hw: pointer to the HW structure * - * The only function explicitly called by the api module to initialize - * all function pointers and parameters. + * Called to initialize all function pointers and parameters. **/ void e1000_init_function_pointers_80003es2lan(struct e1000_hw *hw) { @@ -305,14 +307,14 @@ void e1000_init_function_pointers_80003e hw->mac.ops.init_params = e1000_init_mac_params_80003es2lan; hw->nvm.ops.init_params = e1000_init_nvm_params_80003es2lan; hw->phy.ops.init_params = e1000_init_phy_params_80003es2lan; + e1000_get_bus_info_pcie_generic(hw); } /** * e1000_acquire_phy_80003es2lan - Acquire rights to access PHY * @hw: pointer to the HW structure * - * A wrapper to acquire access rights to the correct PHY. This is a - * function pointer entry point called by the api module. + * A wrapper to acquire access rights to the correct PHY. **/ static s32 e1000_acquire_phy_80003es2lan(struct e1000_hw *hw) { @@ -321,8 +323,6 @@ static s32 e1000_acquire_phy_80003es2lan DEBUGFUNC("e1000_acquire_phy_80003es2lan"); mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM; - mask |= E1000_SWFW_CSR_SM; - return e1000_acquire_swfw_sync_80003es2lan(hw, mask); } @@ -330,8 +330,7 @@ static s32 e1000_acquire_phy_80003es2lan * e1000_release_phy_80003es2lan - Release rights to access PHY * @hw: pointer to the HW structure * - * A wrapper to release access rights to the correct PHY. This is a - * function pointer entry point called by the api module. + * A wrapper to release access rights to the correct PHY. **/ static void e1000_release_phy_80003es2lan(struct e1000_hw *hw) { @@ -340,7 +339,41 @@ static void e1000_release_phy_80003es2la DEBUGFUNC("e1000_release_phy_80003es2lan"); mask = hw->bus.func ? E1000_SWFW_PHY1_SM : E1000_SWFW_PHY0_SM; - mask |= E1000_SWFW_CSR_SM; + e1000_release_swfw_sync_80003es2lan(hw, mask); +} + + +/** + * e1000_acquire_mac_csr_80003es2lan - Acquire rights to access Kumeran register + * @hw: pointer to the HW structure + * + * Acquire the semaphore to access the Kumeran interface. + * + **/ +static s32 e1000_acquire_mac_csr_80003es2lan(struct e1000_hw *hw) +{ + u16 mask; + + DEBUGFUNC("e1000_acquire_mac_csr_80003es2lan"); + + mask = E1000_SWFW_CSR_SM; + + return e1000_acquire_swfw_sync_80003es2lan(hw, mask); +} + +/** + * e1000_release_mac_csr_80003es2lan - Release rights to access Kumeran Register + * @hw: pointer to the HW structure + * + * Release the semaphore used to access the Kumeran interface + **/ +static void e1000_release_mac_csr_80003es2lan(struct e1000_hw *hw) +{ + u16 mask; + + DEBUGFUNC("e1000_release_mac_csr_80003es2lan"); + + mask = E1000_SWFW_CSR_SM; e1000_release_swfw_sync_80003es2lan(hw, mask); } @@ -349,8 +382,7 @@ static void e1000_release_phy_80003es2la * e1000_acquire_nvm_80003es2lan - Acquire rights to access NVM * @hw: pointer to the HW structure * - * Acquire the semaphore to access the EEPROM. This is a function - * pointer entry point called by the api module. + * Acquire the semaphore to access the EEPROM. **/ static s32 e1000_acquire_nvm_80003es2lan(struct e1000_hw *hw) { @@ -375,8 +407,7 @@ out: * e1000_release_nvm_80003es2lan - Relinquish rights to access NVM * @hw: pointer to the HW structure * - * Release the semaphore used to access the EEPROM. This is a - * function pointer entry point called by the api module. + * Release the semaphore used to access the EEPROM. **/ static void e1000_release_nvm_80003es2lan(struct e1000_hw *hw) { @@ -400,7 +431,7 @@ static s32 e1000_acquire_swfw_sync_80003 u32 swmask = mask; u32 fwmask = mask << 16; s32 ret_val = E1000_SUCCESS; - s32 i = 0, timeout = 200; + s32 i = 0, timeout = 50; DEBUGFUNC("e1000_acquire_swfw_sync_80003es2lan"); @@ -452,8 +483,8 @@ static void e1000_release_swfw_sync_8000 DEBUGFUNC("e1000_release_swfw_sync_80003es2lan"); - while (e1000_get_hw_semaphore_generic(hw) != E1000_SUCCESS); - /* Empty */ + while (e1000_get_hw_semaphore_generic(hw) != E1000_SUCCESS) + ; /* Empty */ swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC); swfw_sync &= ~mask; @@ -468,8 +499,7 @@ static void e1000_release_swfw_sync_8000 * @offset: offset of the register to read * @data: pointer to the data returned from the operation * - * Read the GG82563 PHY register. This is a function pointer entry - * point called by the api module. + * Read the GG82563 PHY register. **/ static s32 e1000_read_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, u32 offset, u16 *data) @@ -520,9 +550,8 @@ static s32 e1000_read_phy_reg_gg82563_80 usec_delay(200); - ret_val = e1000_read_phy_reg_mdic(hw, - MAX_PHY_REG_ADDRESS & offset, - data); + ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, + data); usec_delay(200); e1000_release_phy_80003es2lan(hw); @@ -537,8 +566,7 @@ out: * @offset: offset of the register to read * @data: value to write to the register * - * Write to the GG82563 PHY register. This is a function pointer entry - * point called by the api module. + * Write to the GG82563 PHY register. **/ static s32 e1000_write_phy_reg_gg82563_80003es2lan(struct e1000_hw *hw, u32 offset, u16 data) @@ -590,8 +618,7 @@ static s32 e1000_write_phy_reg_gg82563_8 usec_delay(200); - ret_val = e1000_write_phy_reg_mdic(hw, - MAX_PHY_REG_ADDRESS & offset, + ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, data); usec_delay(200); @@ -608,8 +635,7 @@ out: * @words: number of words to write * @data: buffer of data to write to the NVM * - * Write "words" of data to the ESB2 NVM. This is a function - * pointer entry point called by the api module. + * Write "words" of data to the ESB2 NVM. **/ static s32 e1000_write_nvm_80003es2lan(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) @@ -775,10 +801,17 @@ static s32 e1000_get_cable_length_80003e goto out; index = phy_data & GG82563_DSPD_CABLE_LENGTH; - phy->min_cable_length = e1000_gg82563_cable_length_table[index]; - phy->max_cable_length = e1000_gg82563_cable_length_table[index+5]; - phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; + if (index < GG82563_CABLE_LENGTH_TABLE_SIZE + 5) { + phy->min_cable_length = e1000_gg82563_cable_length_table[index]; + phy->max_cable_length = + e1000_gg82563_cable_length_table[index+5]; + + phy->cable_length = (phy->min_cable_length + + phy->max_cable_length) / 2; + } else { + ret_val = E1000_ERR_PHY; + } out: return ret_val; @@ -791,7 +824,6 @@ out: * @duplex: pointer to duplex buffer * * Retrieve the current speed and duplex configuration. - * This is a function pointer entry point called by the api module. **/ static s32 e1000_get_link_up_info_80003es2lan(struct e1000_hw *hw, u16 *speed, u16 *duplex) @@ -804,20 +836,13 @@ static s32 e1000_get_link_up_info_80003e ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed, duplex); - if (ret_val) - goto out; - if (*speed == SPEED_1000) - ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw); - else - ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, - *duplex); + hw->phy.ops.cfg_on_link_up(hw); } else { ret_val = e1000_get_speed_and_duplex_fiber_serdes_generic(hw, speed, duplex); } -out: return ret_val; } @@ -826,7 +851,6 @@ out: * @hw: pointer to the HW structure * * Perform a global reset to the ESB2 controller. - * This is a function pointer entry point called by the api module. **/ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw) { @@ -840,9 +864,8 @@ static s32 e1000_reset_hw_80003es2lan(st * on the last TLP read/write transaction when MAC is reset. */ ret_val = e1000_disable_pcie_master_generic(hw); - if (ret_val) { + if (ret_val) DEBUGOUT("PCI-E Master disable polling has failed.\n"); - } DEBUGOUT("Masking off all interrupts\n"); E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff); @@ -855,8 +878,10 @@ static s32 e1000_reset_hw_80003es2lan(st ctrl = E1000_READ_REG(hw, E1000_CTRL); + ret_val = e1000_acquire_phy_80003es2lan(hw); DEBUGOUT("Issuing a global reset to MAC\n"); E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST); + e1000_release_phy_80003es2lan(hw); ret_val = e1000_get_auto_rd_done_generic(hw); if (ret_val) @@ -878,7 +903,6 @@ out: * @hw: pointer to the HW structure * * Initialize the hw bits, LED, VFTA, MTA, link and hw counters. - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw) { @@ -969,9 +993,6 @@ static void e1000_initialize_hw_bits_800 DEBUGFUNC("e1000_initialize_hw_bits_80003es2lan"); - if (hw->mac.disable_hw_init_bits) - goto out; - /* Transmit Descriptor Control 0 */ reg = E1000_READ_REG(hw, E1000_TXDCTL(0)); reg |= (1 << 22); @@ -997,7 +1018,6 @@ static void e1000_initialize_hw_bits_800 reg |= (1 << 28); E1000_WRITE_REG(hw, E1000_TARC(1), reg); -out: return; } @@ -1012,8 +1032,7 @@ static s32 e1000_copper_link_setup_gg825 struct e1000_phy_info *phy = &hw->phy; s32 ret_val; u32 ctrl_ext; - u32 i = 0; - u16 data, data2; + u16 data; DEBUGFUNC("e1000_copper_link_setup_gg82563_80003es2lan"); @@ -1084,20 +1103,20 @@ static s32 e1000_copper_link_setup_gg825 } /* Bypass Rx and Tx FIFO's */ - ret_val = e1000_write_kmrn_reg_generic(hw, + ret_val = e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL, E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS | E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS); if (ret_val) goto out; - ret_val = e1000_read_kmrn_reg_generic(hw, + ret_val = e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE, &data); if (ret_val) goto out; data |= E1000_KMRNCTRLSTA_OPMODE_E_IDLE; - ret_val = e1000_write_kmrn_reg_generic(hw, + ret_val = e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE, data); if (ret_val) @@ -1129,30 +1148,20 @@ static s32 e1000_copper_link_setup_gg825 /* Enable Electrical Idle on the PHY */ data |= GG82563_PMCR_ENABLE_ELECTRICAL_IDLE; ret_val = hw->phy.ops.write_reg(hw, - GG82563_PHY_PWR_MGMT_CTRL, - data); + GG82563_PHY_PWR_MGMT_CTRL, + data); if (ret_val) goto out; - - do { - ret_val = hw->phy.ops.read_reg(hw, - GG82563_PHY_KMRN_MODE_CTRL, - &data); - if (ret_val) - goto out; - - ret_val = hw->phy.ops.read_reg(hw, - GG82563_PHY_KMRN_MODE_CTRL, - &data2); + ret_val = hw->phy.ops.read_reg(hw, + GG82563_PHY_KMRN_MODE_CTRL, + &data); if (ret_val) goto out; - i++; - } while ((data != data2) && (i < GG82563_MAX_KMRN_RETRY)); data &= ~GG82563_KMCR_PASS_FALSE_CARRIER; ret_val = hw->phy.ops.write_reg(hw, - GG82563_PHY_KMRN_MODE_CTRL, - data); + GG82563_PHY_KMRN_MODE_CTRL, + data); if (ret_val) goto out; @@ -1185,7 +1194,7 @@ out: static s32 e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw) { u32 ctrl; - s32 ret_val; + s32 ret_val; u16 reg_data; DEBUGFUNC("e1000_setup_copper_link_80003es2lan"); @@ -1200,26 +1209,26 @@ static s32 e1000_setup_copper_link_80003 * iteration and increase the max iterations when * polling the phy; this fixes erroneous timeouts at 10Mbps. */ - ret_val = e1000_write_kmrn_reg_generic(hw, GG82563_REG(0x34, 4), - 0xFFFF); + ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4), + 0xFFFF); if (ret_val) goto out; - ret_val = e1000_read_kmrn_reg_generic(hw, GG82563_REG(0x34, 9), - ®_data); + ret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9), + ®_data); if (ret_val) goto out; reg_data |= 0x3F; - ret_val = e1000_write_kmrn_reg_generic(hw, GG82563_REG(0x34, 9), - reg_data); + ret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9), + reg_data); if (ret_val) goto out; - ret_val = e1000_read_kmrn_reg_generic(hw, + ret_val = e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, ®_data); if (ret_val) goto out; reg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING; - ret_val = e1000_write_kmrn_reg_generic(hw, + ret_val = e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET_INB_CTRL, reg_data); if (ret_val) @@ -1236,6 +1245,40 @@ out: } /** + * e1000_cfg_on_link_up_80003es2lan - es2 link configuration after link-up + * @hw: pointer to the HW structure + * @duplex: current duplex setting + * + * Configure the KMRN interface by applying last minute quirks for + * 10/100 operation. + **/ +static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw) +{ + s32 ret_val = E1000_SUCCESS; + u16 speed; + u16 duplex; + + DEBUGFUNC("e1000_configure_on_link_up"); + + if (hw->phy.media_type == e1000_media_type_copper) { + + ret_val = e1000_get_speed_and_duplex_copper_generic(hw, + &speed, + &duplex); + if (ret_val) + goto out; + + if (speed == SPEED_1000) + ret_val = e1000_cfg_kmrn_1000_80003es2lan(hw); + else + ret_val = e1000_cfg_kmrn_10_100_80003es2lan(hw, duplex); + } + +out: + return ret_val; +} + +/** * e1000_cfg_kmrn_10_100_80003es2lan - Apply "quirks" for 10/100 operation * @hw: pointer to the HW structure * @duplex: current duplex setting @@ -1253,7 +1296,7 @@ static s32 e1000_cfg_kmrn_10_100_80003es DEBUGFUNC("e1000_configure_kmrn_for_10_100"); reg_data = E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT; - ret_val = e1000_write_kmrn_reg_generic(hw, + ret_val = e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET_HD_CTRL, reg_data); if (ret_val) @@ -1268,12 +1311,12 @@ static s32 e1000_cfg_kmrn_10_100_80003es do { ret_val = hw->phy.ops.read_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, - ®_data); + ®_data); if (ret_val) goto out; ret_val = hw->phy.ops.read_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, - ®_data2); + ®_data2); if (ret_val) goto out; i++; @@ -1307,7 +1350,7 @@ static s32 e1000_cfg_kmrn_1000_80003es2l DEBUGFUNC("e1000_configure_kmrn_for_1000"); reg_data = E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT; - ret_val = e1000_write_kmrn_reg_generic(hw, + ret_val = e1000_write_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_OFFSET_HD_CTRL, reg_data); if (ret_val) @@ -1322,12 +1365,12 @@ static s32 e1000_cfg_kmrn_1000_80003es2l do { ret_val = hw->phy.ops.read_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, - ®_data); + ®_data); if (ret_val) goto out; ret_val = hw->phy.ops.read_reg(hw, GG82563_PHY_KMRN_MODE_CTRL, - ®_data2); + ®_data2); if (ret_val) goto out; i++; @@ -1341,6 +1384,75 @@ out: } /** + * e1000_read_kmrn_reg_80003es2lan - Read kumeran register + * @hw: pointer to the HW structure + * @offset: register offset to be read + * @data: pointer to the read data + * + * Acquire semaphore, then read the PHY register at offset + * using the kumeran interface. The information retrieved is stored in data. + * Release the semaphore before exiting. + **/ +s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, u16 *data) +{ + u32 kmrnctrlsta; + s32 ret_val = E1000_SUCCESS; + + DEBUGFUNC("e1000_read_kmrn_reg_80003es2lan"); + + ret_val = e1000_acquire_mac_csr_80003es2lan(hw); + if (ret_val) + goto out; + + kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & + E1000_KMRNCTRLSTA_OFFSET) | E1000_KMRNCTRLSTA_REN; + E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta); + + usec_delay(2); + + kmrnctrlsta = E1000_READ_REG(hw, E1000_KMRNCTRLSTA); + *data = (u16)kmrnctrlsta; + + e1000_release_mac_csr_80003es2lan(hw); + +out: + return ret_val; +} + +/** + * e1000_write_kmrn_reg_80003es2lan - Write kumeran register + * @hw: pointer to the HW structure + * @offset: register offset to write to + * @data: data to write at register offset + * + * Acquire semaphore, then write the data to PHY register + * at the offset using the kumeran interface. Release semaphore + * before exiting. + **/ +s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, u16 data) +{ + u32 kmrnctrlsta; + s32 ret_val = E1000_SUCCESS; + + DEBUGFUNC("e1000_write_kmrn_reg_80003es2lan"); + + ret_val = e1000_acquire_mac_csr_80003es2lan(hw); + if (ret_val) + goto out; + + kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & + E1000_KMRNCTRLSTA_OFFSET) | data; + E1000_WRITE_REG(hw, E1000_KMRNCTRLSTA, kmrnctrlsta); + + usec_delay(2); + + e1000_release_mac_csr_80003es2lan(hw); + +out: + return ret_val; +} + +/** * e1000_read_mac_addr_80003es2lan - Read device MAC address * @hw: pointer to the HW structure **/ @@ -1380,44 +1492,42 @@ static void e1000_power_down_phy_copper_ **/ static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw) { - volatile u32 temp; - DEBUGFUNC("e1000_clear_hw_cntrs_80003es2lan"); e1000_clear_hw_cntrs_base_generic(hw); - temp = E1000_READ_REG(hw, E1000_PRC64); - temp = E1000_READ_REG(hw, E1000_PRC127); - temp = E1000_READ_REG(hw, E1000_PRC255); - temp = E1000_READ_REG(hw, E1000_PRC511); - temp = E1000_READ_REG(hw, E1000_PRC1023); - temp = E1000_READ_REG(hw, E1000_PRC1522); - temp = E1000_READ_REG(hw, E1000_PTC64); - temp = E1000_READ_REG(hw, E1000_PTC127); - temp = E1000_READ_REG(hw, E1000_PTC255); - temp = E1000_READ_REG(hw, E1000_PTC511); - temp = E1000_READ_REG(hw, E1000_PTC1023); - temp = E1000_READ_REG(hw, E1000_PTC1522); - - temp = E1000_READ_REG(hw, E1000_ALGNERRC); - temp = E1000_READ_REG(hw, E1000_RXERRC); - temp = E1000_READ_REG(hw, E1000_TNCRS); - temp = E1000_READ_REG(hw, E1000_CEXTERR); - temp = E1000_READ_REG(hw, E1000_TSCTC); - temp = E1000_READ_REG(hw, E1000_TSCTFC); - - temp = E1000_READ_REG(hw, E1000_MGTPRC); - temp = E1000_READ_REG(hw, E1000_MGTPDC); - temp = E1000_READ_REG(hw, E1000_MGTPTC); - - temp = E1000_READ_REG(hw, E1000_IAC); - temp = E1000_READ_REG(hw, E1000_ICRXOC); - - temp = E1000_READ_REG(hw, E1000_ICRXPTC); - temp = E1000_READ_REG(hw, E1000_ICRXATC); - temp = E1000_READ_REG(hw, E1000_ICTXPTC); - temp = E1000_READ_REG(hw, E1000_ICTXATC); - temp = E1000_READ_REG(hw, E1000_ICTXQEC); - temp = E1000_READ_REG(hw, E1000_ICTXQMTC); - temp = E1000_READ_REG(hw, E1000_ICRXDMTC); + E1000_READ_REG(hw, E1000_PRC64); + E1000_READ_REG(hw, E1000_PRC127); + E1000_READ_REG(hw, E1000_PRC255); + E1000_READ_REG(hw, E1000_PRC511); + E1000_READ_REG(hw, E1000_PRC1023); + E1000_READ_REG(hw, E1000_PRC1522); + E1000_READ_REG(hw, E1000_PTC64); + E1000_READ_REG(hw, E1000_PTC127); + E1000_READ_REG(hw, E1000_PTC255); + E1000_READ_REG(hw, E1000_PTC511); + E1000_READ_REG(hw, E1000_PTC1023); + E1000_READ_REG(hw, E1000_PTC1522); + + E1000_READ_REG(hw, E1000_ALGNERRC); + E1000_READ_REG(hw, E1000_RXERRC); + E1000_READ_REG(hw, E1000_TNCRS); + E1000_READ_REG(hw, E1000_CEXTERR); + E1000_READ_REG(hw, E1000_TSCTC); + E1000_READ_REG(hw, E1000_TSCTFC); + + E1000_READ_REG(hw, E1000_MGTPRC); + E1000_READ_REG(hw, E1000_MGTPDC); + E1000_READ_REG(hw, E1000_MGTPTC); + + E1000_READ_REG(hw, E1000_IAC); + E1000_READ_REG(hw, E1000_ICRXOC); + + E1000_READ_REG(hw, E1000_ICRXPTC); + E1000_READ_REG(hw, E1000_ICRXATC); + E1000_READ_REG(hw, E1000_ICTXPTC); + E1000_READ_REG(hw, E1000_ICTXATC); + E1000_READ_REG(hw, E1000_ICTXQEC); + E1000_READ_REG(hw, E1000_ICTXQMTC); + E1000_READ_REG(hw, E1000_ICRXDMTC); } Modified: stable/7/sys/dev/e1000/e1000_82540.c ============================================================================== --- stable/7/sys/dev/e1000/e1000_82540.c Mon Dec 1 05:44:08 2008 (r185509) +++ stable/7/sys/dev/e1000/e1000_82540.c Mon Dec 1 07:13:52 2008 (r185510) @@ -32,11 +32,15 @@ ******************************************************************************/ /*$FreeBSD$*/ -/* e1000_82540 - * e1000_82545 - * e1000_82546 - * e1000_82545_rev_3 - * e1000_82546_rev_3 +/* + * 82540EM Gigabit Ethernet Controller + * 82540EP Gigabit Ethernet Controller + * 82545EM Gigabit Ethernet Controller (Copper) + * 82545EM Gigabit Ethernet Controller (Fiber) + * 82545GM Gigabit Ethernet Controller + * 82546EB Gigabit Ethernet Controller (Copper) + * 82546EB Gigabit Ethernet Controller (Fiber) + * 82546GB Gigabit Ethernet Controller */ #include "e1000_api.h" @@ -57,8 +61,6 @@ static void e1000_power_down_phy_copper_ /** * e1000_init_phy_params_82540 - Init PHY func ptrs. * @hw: pointer to the HW structure - * - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_phy_params_82540(struct e1000_hw *hw) { @@ -110,8 +112,6 @@ out: /** * e1000_init_nvm_params_82540 - Init NVM func ptrs. * @hw: pointer to the HW structure - * - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_nvm_params_82540(struct e1000_hw *hw) { @@ -153,8 +153,6 @@ static s32 e1000_init_nvm_params_82540(s /** * e1000_init_mac_params_82540 - Init MAC func ptrs. * @hw: pointer to the HW structure - * - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_mac_params_82540(struct e1000_hw *hw) { @@ -189,6 +187,8 @@ static s32 e1000_init_mac_params_82540(s /* bus type/speed/width */ mac->ops.get_bus_info = e1000_get_bus_info_pci_generic; + /* function id */ + mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pci; /* reset */ mac->ops.reset_hw = e1000_reset_hw_82540; /* hw initialization */ @@ -247,8 +247,7 @@ out: * e1000_init_function_pointers_82540 - Init func ptrs. * @hw: pointer to the HW structure * - * The only function explicitly called by the api module to initialize - * all function pointers and parameters. + * Called to initialize all function pointers and parameters. **/ void e1000_init_function_pointers_82540(struct e1000_hw *hw) { @@ -263,8 +262,7 @@ void e1000_init_function_pointers_82540( * e1000_reset_hw_82540 - Reset hardware * @hw: pointer to the HW structure * - * This resets the hardware into a known state. This is a - * function pointer entry point called by the api module. + * This resets the hardware into a known state. **/ static s32 e1000_reset_hw_82540(struct e1000_hw *hw) { @@ -322,8 +320,7 @@ static s32 e1000_reset_hw_82540(struct e * e1000_init_hw_82540 - Initialize hardware * @hw: pointer to the HW structure * - * This inits the hardware readying it for operation. This is a - * function pointer entry point called by the api module. + * This inits the hardware readying it for operation. **/ static s32 e1000_init_hw_82540(struct e1000_hw *hw) { @@ -406,8 +403,7 @@ static s32 e1000_init_hw_82540(struct e1 * Calls the appropriate function to configure the link for auto-neg or forced * speed and duplex. Then we check for link, once link is established calls * to configure collision distance and flow control are called. If link is - * not established, we return -E1000_ERR_PHY (-2). This is a function - * pointer entry point called by the api module. + * not established, we return -E1000_ERR_PHY (-2). **/ static s32 e1000_setup_copper_link_82540(struct e1000_hw *hw) { @@ -454,8 +450,7 @@ out: * Set the output amplitude to the value in the EEPROM and adjust the VCO * speed to improve Bit Error Rate (BER) performance. Configures collision * distance and flow control for fiber and serdes links. Upon successful - * setup, poll for link. This is a function pointer entry point called by - * the api module. + * setup, poll for link. **/ static s32 e1000_setup_fiber_serdes_link_82540(struct e1000_hw *hw) { @@ -650,34 +645,32 @@ static void e1000_power_down_phy_copper_ **/ static void e1000_clear_hw_cntrs_82540(struct e1000_hw *hw) { - volatile u32 temp; - DEBUGFUNC("e1000_clear_hw_cntrs_82540"); e1000_clear_hw_cntrs_base_generic(hw); - temp = E1000_READ_REG(hw, E1000_PRC64); - temp = E1000_READ_REG(hw, E1000_PRC127); - temp = E1000_READ_REG(hw, E1000_PRC255); - temp = E1000_READ_REG(hw, E1000_PRC511); - temp = E1000_READ_REG(hw, E1000_PRC1023); - temp = E1000_READ_REG(hw, E1000_PRC1522); - temp = E1000_READ_REG(hw, E1000_PTC64); - temp = E1000_READ_REG(hw, E1000_PTC127); - temp = E1000_READ_REG(hw, E1000_PTC255); - temp = E1000_READ_REG(hw, E1000_PTC511); - temp = E1000_READ_REG(hw, E1000_PTC1023); - temp = E1000_READ_REG(hw, E1000_PTC1522); - - temp = E1000_READ_REG(hw, E1000_ALGNERRC); - temp = E1000_READ_REG(hw, E1000_RXERRC); - temp = E1000_READ_REG(hw, E1000_TNCRS); - temp = E1000_READ_REG(hw, E1000_CEXTERR); - temp = E1000_READ_REG(hw, E1000_TSCTC); - temp = E1000_READ_REG(hw, E1000_TSCTFC); - - temp = E1000_READ_REG(hw, E1000_MGTPRC); - temp = E1000_READ_REG(hw, E1000_MGTPDC); - temp = E1000_READ_REG(hw, E1000_MGTPTC); + E1000_READ_REG(hw, E1000_PRC64); + E1000_READ_REG(hw, E1000_PRC127); + E1000_READ_REG(hw, E1000_PRC255); + E1000_READ_REG(hw, E1000_PRC511); + E1000_READ_REG(hw, E1000_PRC1023); + E1000_READ_REG(hw, E1000_PRC1522); + E1000_READ_REG(hw, E1000_PTC64); + E1000_READ_REG(hw, E1000_PTC127); + E1000_READ_REG(hw, E1000_PTC255); + E1000_READ_REG(hw, E1000_PTC511); + E1000_READ_REG(hw, E1000_PTC1023); + E1000_READ_REG(hw, E1000_PTC1522); + + E1000_READ_REG(hw, E1000_ALGNERRC); + E1000_READ_REG(hw, E1000_RXERRC); + E1000_READ_REG(hw, E1000_TNCRS); + E1000_READ_REG(hw, E1000_CEXTERR); + E1000_READ_REG(hw, E1000_TSCTC); + E1000_READ_REG(hw, E1000_TSCTFC); + + E1000_READ_REG(hw, E1000_MGTPRC); + E1000_READ_REG(hw, E1000_MGTPDC); + E1000_READ_REG(hw, E1000_MGTPTC); } Modified: stable/7/sys/dev/e1000/e1000_82541.c ============================================================================== --- stable/7/sys/dev/e1000/e1000_82541.c Mon Dec 1 05:44:08 2008 (r185509) +++ stable/7/sys/dev/e1000/e1000_82541.c Mon Dec 1 07:13:52 2008 (r185510) @@ -32,10 +32,13 @@ ******************************************************************************/ /*$FreeBSD$*/ -/* e1000_82541 - * e1000_82547 - * e1000_82541_rev_2 - * e1000_82547_rev_2 +/* + * 82541EI Gigabit Ethernet Controller + * 82541ER Gigabit Ethernet Controller + * 82541GI Gigabit Ethernet Controller + * 82541PI Gigabit Ethernet Controller + * 82547EI Gigabit Ethernet Controller + * 82547GI Gigabit Ethernet Controller */ #include "e1000_api.h" @@ -74,18 +77,9 @@ static const u16 e1000_igp_cable_length_ (sizeof(e1000_igp_cable_length_table) / \ sizeof(e1000_igp_cable_length_table[0])) -struct e1000_dev_spec_82541 { - enum e1000_dsp_config dsp_config; - enum e1000_ffe_config ffe_config; - u16 spd_default; - bool phy_init_script; -}; - /** * e1000_init_phy_params_82541 - Init PHY func ptrs. * @hw: pointer to the HW structure - * - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_phy_params_82541(struct e1000_hw *hw) { @@ -129,8 +123,6 @@ out: /** * e1000_init_nvm_params_82541 - Init NVM func ptrs. * @hw: pointer to the HW structure - * - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_nvm_params_82541(struct e1000_hw *hw) { @@ -227,13 +219,10 @@ out: /** * e1000_init_mac_params_82541 - Init MAC func ptrs. * @hw: pointer to the HW structure - * - * This is a function pointer entry point called by the api module. **/ static s32 e1000_init_mac_params_82541(struct e1000_hw *hw) { struct e1000_mac_info *mac = &hw->mac; - s32 ret_val; DEBUGFUNC("e1000_init_mac_params_82541"); @@ -250,6 +239,8 @@ static s32 e1000_init_mac_params_82541(s /* bus type/speed/width */ mac->ops.get_bus_info = e1000_get_bus_info_pci_generic; + /* function id */ + mac->ops.set_lan_id = e1000_set_lan_id_single_port; /* reset */ mac->ops.reset_hw = e1000_reset_hw_82541; /* hw initialization */ @@ -277,25 +268,17 @@ static s32 e1000_init_mac_params_82541(s /* turn on/off LED */ mac->ops.led_on = e1000_led_on_generic; mac->ops.led_off = e1000_led_off_generic; - /* remove device */ - mac->ops.remove_device = e1000_remove_device_generic; /* clear hardware counters */ mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82541; - hw->dev_spec_size = sizeof(struct e1000_dev_spec_82541); - - /* Device-specific structure allocation */ - ret_val = e1000_alloc_zeroed_dev_spec_struct(hw, hw->dev_spec_size); - - return ret_val; + return E1000_SUCCESS; } /** * e1000_init_function_pointers_82541 - Init func ptrs. * @hw: pointer to the HW structure * - * The only function explicitly called by the api module to initialize - * all function pointers and parameters. + * Called to initialize all function pointers and parameters. **/ void e1000_init_function_pointers_82541(struct e1000_hw *hw) { @@ -310,8 +293,7 @@ void e1000_init_function_pointers_82541( * e1000_reset_hw_82541 - Reset hardware * @hw: pointer to the HW structure * - * This resets the hardware into a known state. This is a - * function pointer entry point called by the api module. *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***