From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 00:42:28 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BFEE106564A; Sun, 27 Mar 2011 00:42:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5AB1D8FC12; Sun, 27 Mar 2011 00:42:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R0gSDJ041661; Sun, 27 Mar 2011 00:42:28 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R0gSTi041655; Sun, 27 Mar 2011 00:42:28 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103270042.p2R0gSTi041655@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 27 Mar 2011 00:42:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220047 - in stable/8/sys: conf modules/ufs ufs/ffs ufs/ufs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 00:42:28 -0000 Author: kib Date: Sun Mar 27 00:42:28 2011 New Revision: 220047 URL: http://svn.freebsd.org/changeset/base/220047 Log: MFC r219804: Retire opt_ffs_broken_fixme.h. Modified: stable/8/sys/conf/options stable/8/sys/modules/ufs/Makefile stable/8/sys/ufs/ffs/ffs_vfsops.c stable/8/sys/ufs/ufs/ufs_lookup.c stable/8/sys/ufs/ufs/ufsmount.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/conf/options ============================================================================== --- stable/8/sys/conf/options Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/conf/options Sun Mar 27 00:42:28 2011 (r220047) @@ -198,6 +198,7 @@ CD9660 opt_dontuse.h CODA opt_dontuse.h EXT2FS opt_dontuse.h FDESCFS opt_dontuse.h +FFS opt_dontuse.h HPFS opt_dontuse.h MSDOSFS opt_dontuse.h NTFS opt_dontuse.h @@ -215,9 +216,6 @@ UNIONFS opt_dontuse.h # Pseudofs debugging PSEUDOFS_TRACE opt_pseudofs.h -# Broken - ffs_snapshot() dependency from ufs_lookup() :-( -FFS opt_ffs_broken_fixme.h - # In-kernel GSS-API KGSSAPI opt_kgssapi.h KGSSAPI_DEBUG opt_kgssapi.h Modified: stable/8/sys/modules/ufs/Makefile ============================================================================== --- stable/8/sys/modules/ufs/Makefile Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/modules/ufs/Makefile Sun Mar 27 00:42:28 2011 (r220047) @@ -3,8 +3,7 @@ .PATH: ${.CURDIR}/../../ufs/ufs ${.CURDIR}/../../ufs/ffs KMOD= ufs -SRCS= opt_ddb.h opt_directio.h opt_ffs.h opt_ffs_broken_fixme.h \ - opt_quota.h opt_suiddir.h opt_ufs.h \ +SRCS= opt_ddb.h opt_directio.h opt_ffs.h opt_quota.h opt_suiddir.h opt_ufs.h \ vnode_if.h ufs_acl.c ufs_bmap.c ufs_dirhash.c ufs_extattr.c \ ufs_gjournal.c ufs_inode.c ufs_lookup.c ufs_quota.c ufs_vfsops.c \ ufs_vnops.c ffs_alloc.c ffs_balloc.c ffs_inode.c ffs_snapshot.c \ Modified: stable/8/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- stable/8/sys/ufs/ffs/ffs_vfsops.c Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/ufs/ffs/ffs_vfsops.c Sun Mar 27 00:42:28 2011 (r220047) @@ -792,6 +792,7 @@ ffs_mountfs(devvp, mp, td) ump->um_vfree = ffs_vfree; ump->um_ifree = ffs_ifree; ump->um_rdonly = ffs_rdonly; + ump->um_snapgone = ffs_snapgone; mtx_init(UFS_MTX(ump), "FFS", "FFS Lock", MTX_DEF); bcopy(bp->b_data, ump->um_fs, (u_int)fs->fs_sbsize); if (fs->fs_sbsize < SBLOCKSIZE) Modified: stable/8/sys/ufs/ufs/ufs_lookup.c ============================================================================== --- stable/8/sys/ufs/ufs/ufs_lookup.c Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/ufs/ufs/ufs_lookup.c Sun Mar 27 00:42:28 2011 (r220047) @@ -37,7 +37,6 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_ffs_broken_fixme.h" #include "opt_ufs.h" #include "opt_quota.h" @@ -1239,7 +1238,7 @@ out: * when last open reference goes away. */ if (ip != 0 && (ip->i_flags & SF_SNAPSHOT) != 0 && ip->i_effnlink == 0) - ffs_snapgone(ip); + UFS_SNAPGONE(ip); return (error); } @@ -1289,7 +1288,7 @@ ufs_dirrewrite(dp, oip, newinum, newtype * when last open reference goes away. */ if ((oip->i_flags & SF_SNAPSHOT) != 0 && oip->i_effnlink == 0) - ffs_snapgone(oip); + UFS_SNAPGONE(oip); return (error); } Modified: stable/8/sys/ufs/ufs/ufsmount.h ============================================================================== --- stable/8/sys/ufs/ufs/ufsmount.h Sat Mar 26 22:39:23 2011 (r220046) +++ stable/8/sys/ufs/ufs/ufsmount.h Sun Mar 27 00:42:28 2011 (r220047) @@ -95,6 +95,7 @@ struct ufsmount { int (*um_vfree)(struct vnode *, ino_t, int); void (*um_ifree)(struct ufsmount *, struct inode *); int (*um_rdonly)(struct inode *); + void (*um_snapgone)(struct inode *); }; #define UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff) @@ -105,6 +106,7 @@ struct ufsmount { #define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc) #define UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb)) #define UFS_RDONLY(aa) ((aa)->i_ump->um_rdonly(aa)) +#define UFS_SNAPGONE(aa) ((aa)->i_ump->um_snapgone(aa)) #define UFS_LOCK(aa) mtx_lock(&(aa)->um_lock) #define UFS_UNLOCK(aa) mtx_unlock(&(aa)->um_lock) From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 05:09:21 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E67E4106566C; Sun, 27 Mar 2011 05:09:21 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D4D7F8FC12; Sun, 27 Mar 2011 05:09:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2R59Ldm047183; Sun, 27 Mar 2011 05:09:21 GMT (envelope-from np@svn.freebsd.org) Received: (from np@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2R59LTx047179; Sun, 27 Mar 2011 05:09:21 GMT (envelope-from np@svn.freebsd.org) Message-Id: <201103270509.p2R59LTx047179@svn.freebsd.org> From: Navdeep Parhar Date: Sun, 27 Mar 2011 05:09:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220050 - stable/8/sys/dev/cxgbe X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 05:09:22 -0000 Author: np Date: Sun Mar 27 05:09:21 2011 New Revision: 220050 URL: http://svn.freebsd.org/changeset/base/220050 Log: MFC r219944 Do not over-allocate MSI interrupts for the case where each ingress queue has its own interrupt. If the exact number that we need is not a power of 2 and we're using MSI, then switch to interrupt multiplexing. While here, replace the magic numbers with something more readable. Modified: stable/8/sys/dev/cxgbe/adapter.h stable/8/sys/dev/cxgbe/t4_main.c stable/8/sys/dev/cxgbe/t4_sge.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/cxgbe/adapter.h ============================================================================== --- stable/8/sys/dev/cxgbe/adapter.h Sun Mar 27 03:06:58 2011 (r220049) +++ stable/8/sys/dev/cxgbe/adapter.h Sun Mar 27 05:09:21 2011 (r220050) @@ -128,6 +128,13 @@ enum { }; enum { + /* adapter intr_type */ + INTR_INTX = (1 << 0), + INTR_MSI = (1 << 1), + INTR_MSIX = (1 << 2) +}; + +enum { /* adapter flags */ FULL_INIT_DONE = (1 << 0), FW_OK = (1 << 1), Modified: stable/8/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/8/sys/dev/cxgbe/t4_main.c Sun Mar 27 03:06:58 2011 (r220049) +++ stable/8/sys/dev/cxgbe/t4_main.c Sun Mar 27 05:09:21 2011 (r220050) @@ -205,7 +205,7 @@ SYSCTL_UINT(_hw_cxgbe, OID_AUTO, qsize_r /* * Interrupt types allowed. */ -static int intr_types = 7; +static int intr_types = INTR_MSIX | INTR_MSI | INTR_INTX; TUNABLE_INT("hw.cxgbe.interrupt_types", &intr_types); SYSCTL_UINT(_hw_cxgbe, OID_AUTO, interrupt_types, CTLFLAG_RDTUN, &intr_types, 0, "interrupt types allowed (bits 0, 1, 2 = INTx, MSI, MSI-X respectively)"); @@ -219,7 +219,7 @@ SYSCTL_UINT(_hw_cxgbe, OID_AUTO, interru &intr_fwd, 0, "always use forwarded interrupts"); struct intrs_and_queues { - int intr_type; /* 1, 2, or 4 for INTx, MSI, or MSI-X */ + int intr_type; /* INTx, MSI, or MSI-X */ int nirq; /* Number of vectors */ int intr_fwd; /* Interrupts forwarded */ int ntxq10g; /* # of NIC txq's for each 10G port */ @@ -639,7 +639,7 @@ t4_detach(device_t dev) if (sc->flags & FW_OK) t4_fw_bye(sc, sc->mbox); - if (sc->intr_type == 2 || sc->intr_type == 4) + if (sc->intr_type == INTR_MSI || sc->intr_type == INTR_MSIX) pci_release_msi(dev); if (sc->regs_res) @@ -1152,14 +1152,14 @@ cfg_itype_and_nqueues(struct adapter *sc bzero(iaq, sizeof(*iaq)); nc = mp_ncpus; /* our snapshot of the number of CPUs */ - for (itype = 4; itype; itype >>= 1) { + for (itype = INTR_MSIX; itype; itype >>= 1) { if ((itype & intr_types) == 0) continue; /* not allowed */ - if (itype == 4) + if (itype == INTR_MSIX) navail = pci_msix_count(sc->dev); - else if (itype == 2) + else if (itype == INTR_MSI) navail = pci_msi_count(sc->dev); else navail = 1; @@ -1179,44 +1179,50 @@ cfg_itype_and_nqueues(struct adapter *sc iaq->nirq = n10g * nrxq10g + n1g * nrxq1g + 2; if (iaq->nirq <= navail && intr_fwd == 0) { + if (itype == INTR_MSI && !powerof2(iaq->nirq)) + goto fwd; + /* One for err, one for fwq, and one for each rxq */ iaq->intr_fwd = 0; iaq->nrxq10g = nrxq10g; iaq->nrxq1g = nrxq1g; - if (itype == 2) { - /* # of vectors requested must be power of 2 */ - while (!powerof2(iaq->nirq)) - iaq->nirq++; - KASSERT(iaq->nirq <= navail, - ("%s: bad MSI calculation", __func__)); - } + } else { fwd: iaq->intr_fwd = 1; - iaq->nirq = navail; + + if (navail > nc) { + if (itype == INTR_MSIX) + navail = nc + 1; + + /* navail is and must remain a pow2 for MSI */ + if (itype == INTR_MSI) { + KASSERT(powerof2(navail), + ("%d not power of 2", navail)); + + while (navail / 2 > nc) + navail /= 2; + } + } + iaq->nirq = navail; /* total # of interrupts */ /* * If we have multiple vectors available reserve one * exclusively for errors. The rest will be shared by * the fwq and data. */ - if (navail > 1) { + if (navail > 1) navail--; - - if (navail > nc && itype == 4) - iaq->nirq = nc + 1; - } - iaq->nrxq10g = min(nrxq10g, navail); iaq->nrxq1g = min(nrxq1g, navail); } navail = iaq->nirq; rc = 0; - if (itype == 4) + if (itype == INTR_MSIX) rc = pci_alloc_msix(sc->dev, &navail); - else if (itype == 2) + else if (itype == INTR_MSI) rc = pci_alloc_msi(sc->dev, &navail); if (rc == 0) { @@ -1481,10 +1487,10 @@ t4_set_desc(struct adapter *sc) struct adapter_params *p = &sc->params; snprintf(buf, sizeof(buf), - "Chelsio %s (rev %d) %d port %sNIC PCIe-x%d %s, S/N:%s, E/C:%s", + "Chelsio %s (rev %d) %d port %sNIC PCIe-x%d %d %s, S/N:%s, E/C:%s", p->vpd.id, p->rev, p->nports, is_offload(sc) ? "R" : "", - p->pci.width, (sc->intr_type == 4 ) ? "MSI-X" : - (sc->intr_type == 2) ? "MSI" : "INTx", p->vpd.sn, p->vpd.ec); + p->pci.width, sc->intr_count, sc->intr_type == INTR_MSIX ? "MSI-X" : + (sc->intr_type == INTR_MSI ? "MSI" : "INTx"), p->vpd.sn, p->vpd.ec); device_set_desc_copy(sc->dev, buf); } Modified: stable/8/sys/dev/cxgbe/t4_sge.c ============================================================================== --- stable/8/sys/dev/cxgbe/t4_sge.c Sun Mar 27 03:06:58 2011 (r220049) +++ stable/8/sys/dev/cxgbe/t4_sge.c Sun Mar 27 05:09:21 2011 (r220050) @@ -468,7 +468,7 @@ t4_intr_err(void *arg) { struct adapter *sc = arg; - if (sc->intr_type == 1) + if (sc->intr_type == INTR_INTX) t4_write_reg(sc, MYPF_REG(A_PCIE_PF_CLI), 0); t4_slow_intr_handler(sc); From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 20:35:33 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 009A01065677; Sun, 27 Mar 2011 20:35:33 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E35F78FC08; Sun, 27 Mar 2011 20:35:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RKZWK6068379; Sun, 27 Mar 2011 20:35:32 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RKZWBt068377; Sun, 27 Mar 2011 20:35:32 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201103272035.p2RKZWBt068377@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Sun, 27 Mar 2011 20:35:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220063 - stable/8/sbin/geom/class/part X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 20:35:33 -0000 Author: ae Date: Sun Mar 27 20:35:32 2011 New Revision: 220063 URL: http://svn.freebsd.org/changeset/base/220063 Log: MFC r219573: Document GEOM_PART_EBR_COMPAT option. MFC r219581: Fix grammar. Pointed out: Ben Kaduk Modified: stable/8/sbin/geom/class/part/gpart.8 Directory Properties: stable/8/sbin/geom/class/part/ (props changed) Modified: stable/8/sbin/geom/class/part/gpart.8 ============================================================================== --- stable/8/sbin/geom/class/part/gpart.8 Sun Mar 27 19:56:55 2011 (r220062) +++ stable/8/sbin/geom/class/part/gpart.8 Sun Mar 27 20:35:32 2011 (r220063) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 9, 2011 +.Dd March 12, 2011 .Dt GPART 8 .Os .Sh NAME @@ -38,6 +38,7 @@ lines in your kernel configuration file: .Cd "options GEOM_PART_APM" .Cd "options GEOM_PART_BSD" .Cd "options GEOM_PART_EBR" +.Cd "options GEOM_PART_EBR_COMPAT" .Cd "options GEOM_PART_GPT" .Cd "options GEOM_PART_MBR" .Cd "options GEOM_PART_PC98" @@ -58,6 +59,11 @@ The option adds support for the Extended Boot Record (EBR), which is used to define a logical partition. The +.Dv GEOM_PART_EBR_COMPAT +option enables backward compatibility for partition names +in the EBR scheme. Also it makes impossible any types of actions +with such partitions. +The .Dv GEOM_PART_GPT option adds support for the GUID Partition Table (GPT) found on Intel Itanium computers and Intel-based Macintosh computers. From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:12:51 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A3301065672; Sun, 27 Mar 2011 22:12:51 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 67DF28FC12; Sun, 27 Mar 2011 22:12:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMCpwq070434; Sun, 27 Mar 2011 22:12:51 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMCpuR070431; Sun, 27 Mar 2011 22:12:51 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272212.p2RMCpuR070431@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:12:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220064 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:12:51 -0000 Author: yongari Date: Sun Mar 27 22:12:51 2011 New Revision: 220064 URL: http://svn.freebsd.org/changeset/base/220064 Log: MFC r218786: Always check memory allocation failure. If driver encounter memory allocation error, do not attach driver. Reviewed by: marius Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 20:35:32 2011 (r220063) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:12:51 2011 (r220064) @@ -287,11 +287,11 @@ static void dc_reset(struct dc_softc *); static int dc_list_rx_init(struct dc_softc *); static int dc_list_tx_init(struct dc_softc *); -static void dc_read_srom(struct dc_softc *, int); -static void dc_parse_21143_srom(struct dc_softc *); -static void dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *); -static void dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); -static void dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); +static int dc_read_srom(struct dc_softc *, int); +static int dc_parse_21143_srom(struct dc_softc *); +static int dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *); +static int dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); +static int dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); static void dc_apply_fixup(struct dc_softc *, int); #ifdef DC_USEIOSPACE @@ -1615,12 +1615,16 @@ dc_apply_fixup(struct dc_softc *sc, int } } -static void +static int dc_decode_leaf_sia(struct dc_softc *sc, struct dc_eblock_sia *l) { struct dc_mediainfo *m; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } switch (l->dc_sia_code & ~DC_SIA_CODE_EXT) { case DC_SIA_CODE_10BT: m->dc_media = IFM_10_T; @@ -1657,14 +1661,19 @@ dc_decode_leaf_sia(struct dc_softc *sc, sc->dc_mi = m; sc->dc_pmode = DC_PMODE_SIA; + return (0); } -static void +static int dc_decode_leaf_sym(struct dc_softc *sc, struct dc_eblock_sym *l) { struct dc_mediainfo *m; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } if (l->dc_sym_code == DC_SYM_CODE_100BT) m->dc_media = IFM_100_TX; @@ -1678,15 +1687,20 @@ dc_decode_leaf_sym(struct dc_softc *sc, sc->dc_mi = m; sc->dc_pmode = DC_PMODE_SYM; + return (0); } -static void +static int dc_decode_leaf_mii(struct dc_softc *sc, struct dc_eblock_mii *l) { struct dc_mediainfo *m; u_int8_t *p; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } /* We abuse IFM_AUTO to represent MII. */ m->dc_media = IFM_AUTO; m->dc_gp_len = l->dc_gpr_len; @@ -1701,24 +1715,30 @@ dc_decode_leaf_mii(struct dc_softc *sc, m->dc_next = sc->dc_mi; sc->dc_mi = m; + return (0); } -static void +static int dc_read_srom(struct dc_softc *sc, int bits) { int size; - size = 2 << bits; + size = DC_ROM_SIZE(bits); sc->dc_srom = malloc(size, M_DEVBUF, M_NOWAIT); + if (sc->dc_srom == NULL) { + device_printf(sc->dc_dev, "Could not allocate SROM buffer\n"); + return (ENOMEM); + } dc_read_eeprom(sc, (caddr_t)sc->dc_srom, 0, (size / 2), 0); + return (0); } -static void +static int dc_parse_21143_srom(struct dc_softc *sc) { struct dc_leaf_hdr *lhdr; struct dc_eblock_hdr *hdr; - int have_mii, i, loff; + int error, have_mii, i, loff; char *ptr; have_mii = 0; @@ -1745,20 +1765,21 @@ dc_parse_21143_srom(struct dc_softc *sc) */ ptr = (char *)lhdr; ptr += sizeof(struct dc_leaf_hdr) - 1; + error = 0; for (i = 0; i < lhdr->dc_mcnt; i++) { hdr = (struct dc_eblock_hdr *)ptr; switch (hdr->dc_type) { case DC_EBLOCK_MII: - dc_decode_leaf_mii(sc, (struct dc_eblock_mii *)hdr); + error = dc_decode_leaf_mii(sc, (struct dc_eblock_mii *)hdr); break; case DC_EBLOCK_SIA: if (! have_mii) - dc_decode_leaf_sia(sc, + error = dc_decode_leaf_sia(sc, (struct dc_eblock_sia *)hdr); break; case DC_EBLOCK_SYM: if (! have_mii) - dc_decode_leaf_sym(sc, + error = dc_decode_leaf_sym(sc, (struct dc_eblock_sym *)hdr); break; default: @@ -1768,6 +1789,7 @@ dc_parse_21143_srom(struct dc_softc *sc) ptr += (hdr->dc_len & 0x7F); ptr++; } + return (error); } static void @@ -1834,6 +1856,7 @@ dc_attach(device_t dev) sc->dc_info = dc_devtype(dev); revision = pci_get_revid(dev); + error = 0; /* Get the eeprom width, but PNIC and XIRCOM have diff eeprom */ if (sc->dc_info->dc_devid != DC_DEVID(DC_VENDORID_LO, DC_DEVICEID_82C168) && @@ -1847,7 +1870,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_POLL | DC_TX_USE_TX_INTR; sc->dc_flags |= DC_REDUCED_MII_POLL; /* Save EEPROM contents so we can parse them later. */ - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; case DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9009): case DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9100): @@ -1866,7 +1891,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_USE_TX_INTR; sc->dc_flags |= DC_TX_ADMTEK_WAR; sc->dc_pmode = DC_PMODE_MII; - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983): case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985): @@ -1933,6 +1960,12 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_STORENFWD | DC_TX_INTR_ALWAYS; sc->dc_flags |= DC_PNIC_RX_BUG_WAR; sc->dc_pnic_rx_buf = malloc(DC_RXLEN * 5, M_DEVBUF, M_NOWAIT); + if (sc->dc_pnic_rx_buf == NULL) { + device_printf(sc->dc_dev, + "Could not allocate PNIC RX buffer\n"); + error = ENOMEM; + goto fail; + } if (revision < DC_REVISION_82C169) sc->dc_pmode = DC_PMODE_SYM; break; @@ -1958,7 +1991,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_INTR_ALWAYS; sc->dc_flags |= DC_REDUCED_MII_POLL; sc->dc_pmode = DC_PMODE_MII; - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; default: device_printf(dev, "unknown device: %x\n", @@ -1989,9 +2024,11 @@ dc_attach(device_t dev) * The tricky ones are the Macronix/PNIC II and the * Intel 21143. */ - if (DC_IS_INTEL(sc)) - dc_parse_21143_srom(sc); - else if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) { + if (DC_IS_INTEL(sc)) { + error = dc_parse_21143_srom(sc); + if (error != 0) + goto fail; + } else if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) { if (sc->dc_type == DC_TYPE_98713) sc->dc_pmode = DC_PMODE_MII; else Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 20:35:32 2011 (r220063) +++ stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:12:51 2011 (r220064) @@ -1063,6 +1063,8 @@ struct dc_softc { * SROM nonsense. */ +#define DC_ROM_SIZE(bits) (2 << (bits)) + #define DC_IB_CTLRCNT 0x13 #define DC_IB_LEAF0_CNUM 0x1A #define DC_IB_LEAF0_OFFSET 0x1B From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:14:14 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87B241065674; Sun, 27 Mar 2011 22:14:14 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 757CF8FC0C; Sun, 27 Mar 2011 22:14:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMEE13070494; Sun, 27 Mar 2011 22:14:14 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMEEQJ070491; Sun, 27 Mar 2011 22:14:14 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272214.p2RMEEQJ070491@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:14:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220065 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:14:14 -0000 Author: yongari Date: Sun Mar 27 22:14:14 2011 New Revision: 220065 URL: http://svn.freebsd.org/changeset/base/220065 Log: MFC r218786: Always check memory allocation failure. If driver encounter memory allocation error, do not attach driver. Reviewed by: marius Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:12:51 2011 (r220064) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:14:14 2011 (r220065) @@ -287,11 +287,11 @@ static void dc_reset(struct dc_softc *); static int dc_list_rx_init(struct dc_softc *); static int dc_list_tx_init(struct dc_softc *); -static void dc_read_srom(struct dc_softc *, int); -static void dc_parse_21143_srom(struct dc_softc *); -static void dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *); -static void dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); -static void dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); +static int dc_read_srom(struct dc_softc *, int); +static int dc_parse_21143_srom(struct dc_softc *); +static int dc_decode_leaf_sia(struct dc_softc *, struct dc_eblock_sia *); +static int dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); +static int dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); static void dc_apply_fixup(struct dc_softc *, int); #ifdef DC_USEIOSPACE @@ -1616,12 +1616,16 @@ dc_apply_fixup(struct dc_softc *sc, int } } -static void +static int dc_decode_leaf_sia(struct dc_softc *sc, struct dc_eblock_sia *l) { struct dc_mediainfo *m; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } switch (l->dc_sia_code & ~DC_SIA_CODE_EXT) { case DC_SIA_CODE_10BT: m->dc_media = IFM_10_T; @@ -1658,14 +1662,19 @@ dc_decode_leaf_sia(struct dc_softc *sc, sc->dc_mi = m; sc->dc_pmode = DC_PMODE_SIA; + return (0); } -static void +static int dc_decode_leaf_sym(struct dc_softc *sc, struct dc_eblock_sym *l) { struct dc_mediainfo *m; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } if (l->dc_sym_code == DC_SYM_CODE_100BT) m->dc_media = IFM_100_TX; @@ -1679,15 +1688,20 @@ dc_decode_leaf_sym(struct dc_softc *sc, sc->dc_mi = m; sc->dc_pmode = DC_PMODE_SYM; + return (0); } -static void +static int dc_decode_leaf_mii(struct dc_softc *sc, struct dc_eblock_mii *l) { struct dc_mediainfo *m; u_int8_t *p; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); + if (m == NULL) { + device_printf(sc->dc_dev, "Could not allocate mediainfo\n"); + return (ENOMEM); + } /* We abuse IFM_AUTO to represent MII. */ m->dc_media = IFM_AUTO; m->dc_gp_len = l->dc_gpr_len; @@ -1702,24 +1716,30 @@ dc_decode_leaf_mii(struct dc_softc *sc, m->dc_next = sc->dc_mi; sc->dc_mi = m; + return (0); } -static void +static int dc_read_srom(struct dc_softc *sc, int bits) { int size; - size = 2 << bits; + size = DC_ROM_SIZE(bits); sc->dc_srom = malloc(size, M_DEVBUF, M_NOWAIT); + if (sc->dc_srom == NULL) { + device_printf(sc->dc_dev, "Could not allocate SROM buffer\n"); + return (ENOMEM); + } dc_read_eeprom(sc, (caddr_t)sc->dc_srom, 0, (size / 2), 0); + return (0); } -static void +static int dc_parse_21143_srom(struct dc_softc *sc) { struct dc_leaf_hdr *lhdr; struct dc_eblock_hdr *hdr; - int have_mii, i, loff; + int error, have_mii, i, loff; char *ptr; have_mii = 0; @@ -1746,20 +1766,21 @@ dc_parse_21143_srom(struct dc_softc *sc) */ ptr = (char *)lhdr; ptr += sizeof(struct dc_leaf_hdr) - 1; + error = 0; for (i = 0; i < lhdr->dc_mcnt; i++) { hdr = (struct dc_eblock_hdr *)ptr; switch (hdr->dc_type) { case DC_EBLOCK_MII: - dc_decode_leaf_mii(sc, (struct dc_eblock_mii *)hdr); + error = dc_decode_leaf_mii(sc, (struct dc_eblock_mii *)hdr); break; case DC_EBLOCK_SIA: if (! have_mii) - dc_decode_leaf_sia(sc, + error = dc_decode_leaf_sia(sc, (struct dc_eblock_sia *)hdr); break; case DC_EBLOCK_SYM: if (! have_mii) - dc_decode_leaf_sym(sc, + error = dc_decode_leaf_sym(sc, (struct dc_eblock_sym *)hdr); break; default: @@ -1769,6 +1790,7 @@ dc_parse_21143_srom(struct dc_softc *sc) ptr += (hdr->dc_len & 0x7F); ptr++; } + return (error); } static void @@ -1835,6 +1857,7 @@ dc_attach(device_t dev) sc->dc_info = dc_devtype(dev); revision = pci_get_revid(dev); + error = 0; /* Get the eeprom width, but PNIC and XIRCOM have diff eeprom */ if (sc->dc_info->dc_devid != DC_DEVID(DC_VENDORID_LO, DC_DEVICEID_82C168) && @@ -1848,7 +1871,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_POLL | DC_TX_USE_TX_INTR; sc->dc_flags |= DC_REDUCED_MII_POLL; /* Save EEPROM contents so we can parse them later. */ - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; case DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9009): case DC_DEVID(DC_VENDORID_DAVICOM, DC_DEVICEID_DM9100): @@ -1867,7 +1892,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_USE_TX_INTR; sc->dc_flags |= DC_TX_ADMTEK_WAR; sc->dc_pmode = DC_PMODE_MII; - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983): case DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985): @@ -1934,6 +1961,12 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_STORENFWD | DC_TX_INTR_ALWAYS; sc->dc_flags |= DC_PNIC_RX_BUG_WAR; sc->dc_pnic_rx_buf = malloc(DC_RXLEN * 5, M_DEVBUF, M_NOWAIT); + if (sc->dc_pnic_rx_buf == NULL) { + device_printf(sc->dc_dev, + "Could not allocate PNIC RX buffer\n"); + error = ENOMEM; + goto fail; + } if (revision < DC_REVISION_82C169) sc->dc_pmode = DC_PMODE_SYM; break; @@ -1959,7 +1992,9 @@ dc_attach(device_t dev) sc->dc_flags |= DC_TX_INTR_ALWAYS; sc->dc_flags |= DC_REDUCED_MII_POLL; sc->dc_pmode = DC_PMODE_MII; - dc_read_srom(sc, sc->dc_romwidth); + error = dc_read_srom(sc, sc->dc_romwidth); + if (error != 0) + goto fail; break; default: device_printf(dev, "unknown device: %x\n", @@ -1990,9 +2025,11 @@ dc_attach(device_t dev) * The tricky ones are the Macronix/PNIC II and the * Intel 21143. */ - if (DC_IS_INTEL(sc)) - dc_parse_21143_srom(sc); - else if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) { + if (DC_IS_INTEL(sc)) { + error = dc_parse_21143_srom(sc); + if (error != 0) + goto fail; + } else if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) { if (sc->dc_type == DC_TYPE_98713) sc->dc_pmode = DC_PMODE_MII; else Modified: stable/7/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:12:51 2011 (r220064) +++ stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:14:14 2011 (r220065) @@ -1063,6 +1063,8 @@ struct dc_softc { * SROM nonsense. */ +#define DC_ROM_SIZE(bits) (2 << (bits)) + #define DC_IB_CTLRCNT 0x13 #define DC_IB_LEAF0_CNUM 0x1A #define DC_IB_LEAF0_OFFSET 0x1B From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:20:45 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E8851065787; Sun, 27 Mar 2011 22:20:45 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0BE128FC1A; Sun, 27 Mar 2011 22:20:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMKi86070719; Sun, 27 Mar 2011 22:20:44 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMKiha070716; Sun, 27 Mar 2011 22:20:44 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272220.p2RMKiha070716@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:20:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220066 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:20:45 -0000 Author: yongari Date: Sun Mar 27 22:20:44 2011 New Revision: 220066 URL: http://svn.freebsd.org/changeset/base/220066 Log: MFC r213841,218787-218788: r213841: It seems some multi-port dc(4) controllers shares SROM of the first port such that reading station address from second port always returned 0xFF:0xFF:0xFF:0xFF:0xFF:0xFF Unfortunately it seems there is no easy way to know whether SROM is shared or not. Workaround the issue by traversing dc(4) device list and see whether we're using second port and use station address of controller 0 as base station address of second port. PR: kern/79262 r218787: When driver have to use base softc due to lack of SROM on second port, copy SROM information from base softc as well and run SROM parser again. This change is necessary for some dual port controllers to make dc(4) correctly detect PHY media based on first port configuration table. While I'm here add a check for validity of the base softc before duplicating SROM contents from base softc. If driver failed to attach to the first port it can access invalid area. PR: kern/79262 Reviewed by: marius r218788: Apply special PHY initialization code for 21143 controllers before any other media configuration. Otherwise some 21143 controller cannot establish a link. While I'm here remove the PHY initialization code in dc_setcfg(). Since dc_setcfg() is called whenever link state is changed, having the PHY initialization code in dc_setcfg() resulted in continuous link flips. After driver resets SIA, use default SIA transmit/receive configuration instead of disabling autosense/autonegotiation. Otherwise, controller fails to establish a link as well as losing auto-negotiation capability. For manual media configuration, always configure 21143 controller with specified media to ensure media change. This change makes ANA-6922 establish link with/without auto-negotiation. While I'm here be more strict on link UP/DOWN detection logic. Many thanks to marius who fixed several bugs in initial patch and even tested the patch on a couple of dc(4) controllers. PR: kern/79262 Reviewed by: marius Tested by: marius Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:14:14 2011 (r220065) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:20:44 2011 (r220066) @@ -293,6 +293,7 @@ static int dc_decode_leaf_sia(struct dc_ static int dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); static int dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); static void dc_apply_fixup(struct dc_softc *, int); +static int dc_check_multiport(struct dc_softc *); #ifdef DC_USEIOSPACE #define DC_RES SYS_RES_IOPORT @@ -943,23 +944,45 @@ static void dc_miibus_statchg(device_t dev) { struct dc_softc *sc; + struct ifnet *ifp; struct mii_data *mii; struct ifmedia *ifm; sc = device_get_softc(dev); - if (DC_IS_ADMTEK(sc)) - return; mii = device_get_softc(sc->dc_miibus); + ifp = sc->dc_ifp; + if (mii == NULL || ifp == NULL || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + return; + ifm = &mii->mii_media; if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) { dc_setcfg(sc, ifm->ifm_media); sc->dc_if_media = ifm->ifm_media; - } else { - dc_setcfg(sc, mii->mii_media_active); - sc->dc_if_media = mii->mii_media_active; + return; } + + sc->dc_link = 0; + if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == + (IFM_ACTIVE | IFM_AVALID)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc->dc_link = 1; + break; + default: + break; + } + } + if (sc->dc_link == 0) + return; + + sc->dc_if_media = mii->mii_media_active; + if (DC_IS_ADMTEK(sc)) + return; + dc_setcfg(sc, mii->mii_media_active); } /* @@ -1403,8 +1426,6 @@ dc_setcfg(struct dc_softc *sc, int media if (!DC_IS_DAVICOM(sc)) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, IFM_AUTO); } else { if (DC_IS_PNIC(sc)) { DC_PN_GPIO_SETBIT(sc, DC_PN_GPIO_SPEEDSEL); @@ -1414,10 +1435,6 @@ dc_setcfg(struct dc_softc *sc, int media DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PCS); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_SCRAMBLER); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, - (media & IFM_GMASK) == IFM_FDX ? - IFM_100_TX | IFM_FDX : IFM_100_TX); } } @@ -1441,8 +1458,6 @@ dc_setcfg(struct dc_softc *sc, int media if (!DC_IS_DAVICOM(sc)) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, IFM_AUTO); } else { if (DC_IS_PNIC(sc)) { DC_PN_GPIO_CLRBIT(sc, DC_PN_GPIO_SPEEDSEL); @@ -1462,9 +1477,6 @@ dc_setcfg(struct dc_softc *sc, int media DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); DC_CLRBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL); - dc_apply_fixup(sc, - (media & IFM_GMASK) == IFM_FDX ? - IFM_10_T | IFM_FDX : IFM_10_T); DELAY(20000); } } @@ -1536,7 +1548,7 @@ dc_reset(struct dc_softc *sc) */ if (DC_IS_INTEL(sc)) { DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); - CSR_WRITE_4(sc, DC_10BTCTRL, 0); + CSR_WRITE_4(sc, DC_10BTCTRL, 0xFFFFFFFF); CSR_WRITE_4(sc, DC_WATCHDOG, 0); } } @@ -1814,6 +1826,7 @@ dc_attach(device_t dev) u_int32_t command; struct dc_softc *sc; struct ifnet *ifp; + struct dc_mediainfo *m; u_int32_t reg, revision; int error, i, mac_offset, phy, rid, tmp; u_int8_t *mac; @@ -2097,6 +2110,36 @@ dc_attach(device_t dev) break; } + bcopy(eaddr, sc->dc_eaddr, sizeof(eaddr)); + /* + * If we still have invalid station address, see whether we can + * find station address for chip 0. Some multi-port controllers + * just store station address for chip 0 if they have a shared + * SROM. + */ + if ((sc->dc_eaddr[0] == 0 && (sc->dc_eaddr[1] & ~0xffff) == 0) || + (sc->dc_eaddr[0] == 0xffffffff && + (sc->dc_eaddr[1] & 0xffff) == 0xffff)) { + error = dc_check_multiport(sc); + if (error == 0) { + bcopy(sc->dc_eaddr, eaddr, sizeof(eaddr)); + /* Extract media information. */ + if (DC_IS_INTEL(sc) && sc->dc_srom != NULL) { + while (sc->dc_mi != NULL) { + m = sc->dc_mi->dc_next; + free(sc->dc_mi, M_DEVBUF); + sc->dc_mi = m; + } + error = dc_parse_21143_srom(sc); + if (error != 0) + goto fail; + } + } else if (error == ENOMEM) + goto fail; + else + error = 0; + } + /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, @@ -2931,11 +2974,8 @@ dc_tick(void *xsc) */ if ((DC_HAS_BROKEN_RXSTATE(sc) || (CSR_READ_4(sc, DC_ISR) & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT) && - sc->dc_cdata.dc_tx_cnt == 0) { + sc->dc_cdata.dc_tx_cnt == 0) mii_tick(mii); - if (!(mii->mii_media_status & IFM_ACTIVE)) - sc->dc_link = 0; - } } } else mii_tick(mii); @@ -2959,12 +2999,8 @@ dc_tick(void *xsc) * that time, packets will stay in the send queue, and once the * link comes up, they will be flushed out to the wire. */ - if (!sc->dc_link && mii->mii_media_status & IFM_ACTIVE && - IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { - sc->dc_link++; - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - dc_start_locked(ifp); - } + if (sc->dc_link != 0 && !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + dc_start_locked(ifp); if (sc->dc_flags & DC_21143_NWAY && !sc->dc_link) callout_reset(&sc->dc_stat_ch, hz/10, dc_tick, sc); @@ -3389,6 +3425,7 @@ dc_init_locked(struct dc_softc *sc) { struct ifnet *ifp = sc->dc_ifp; struct mii_data *mii; + struct ifmedia *ifm; DC_LOCK_ASSERT(sc); @@ -3399,6 +3436,10 @@ dc_init_locked(struct dc_softc *sc) */ dc_stop(sc); dc_reset(sc); + if (DC_IS_INTEL(sc)) { + ifm = &mii->mii_media; + dc_apply_fixup(sc, ifm->ifm_media); + } /* * Set cache alignment and burst length. @@ -3542,12 +3583,12 @@ dc_init_locked(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); CSR_WRITE_4(sc, DC_RXSTART, 0xFFFFFFFF); - mii_mediachg(mii); - dc_setcfg(sc, sc->dc_if_media); - ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + mii_mediachg(mii); + dc_setcfg(sc, sc->dc_if_media); + /* Don't start the ticker if this is a homePNA link. */ if (IFM_SUBTYPE(mii->mii_media.ifm_media) == IFM_HPNA_1) sc->dc_link = 1; @@ -3578,7 +3619,9 @@ dc_ifmedia_upd(struct ifnet *ifp) mii_mediachg(mii); ifm = &mii->mii_media; - if (DC_IS_DAVICOM(sc) && + if (DC_IS_INTEL(sc)) + dc_setcfg(sc, ifm->ifm_media); + else if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) dc_setcfg(sc, ifm->ifm_media); else @@ -3839,3 +3882,52 @@ dc_shutdown(device_t dev) return (0); } + +static int +dc_check_multiport(struct dc_softc *sc) +{ + struct dc_softc *dsc; + devclass_t dc; + device_t child; + uint8_t *eaddr; + int unit; + + dc = devclass_find("dc"); + for (unit = 0; unit < devclass_get_maxunit(dc); unit++) { + child = devclass_get_device(dc, unit); + if (child == NULL) + continue; + if (child == sc->dc_dev) + continue; + if (device_get_parent(child) != device_get_parent(sc->dc_dev)) + continue; + if (unit > device_get_unit(sc->dc_dev)) + continue; + if (device_is_attached(child) == 0) + continue; + dsc = device_get_softc(child); + device_printf(sc->dc_dev, + "Using station address of %s as base\n", + device_get_nameunit(child)); + bcopy(dsc->dc_eaddr, sc->dc_eaddr, ETHER_ADDR_LEN); + eaddr = (uint8_t *)sc->dc_eaddr; + eaddr[5]++; + /* Prepare SROM to parse again. */ + if (DC_IS_INTEL(sc) && dsc->dc_srom != NULL && + sc->dc_romwidth != 0) { + free(sc->dc_srom, M_DEVBUF); + sc->dc_romwidth = dsc->dc_romwidth; + sc->dc_srom = malloc(DC_ROM_SIZE(sc->dc_romwidth), + M_DEVBUF, M_NOWAIT); + if (sc->dc_srom == NULL) { + device_printf(sc->dc_dev, + "Could not allocate SROM buffer\n"); + return (ENOMEM); + } + bcopy(dsc->dc_srom, sc->dc_srom, + DC_ROM_SIZE(sc->dc_romwidth)); + } + return (0); + } + return (ENOENT); +} Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:14:14 2011 (r220065) +++ stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:20:44 2011 (r220066) @@ -745,6 +745,7 @@ struct dc_softc { int dc_if_media; u_int32_t dc_flags; u_int32_t dc_txthresh; + u_int32_t dc_eaddr[2]; u_int8_t *dc_srom; struct dc_mediainfo *dc_mi; struct dc_list_data *dc_ldata; From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:21:52 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D3B31065672; Sun, 27 Mar 2011 22:21:52 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6AA498FC21; Sun, 27 Mar 2011 22:21:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMLqHs070778; Sun, 27 Mar 2011 22:21:52 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMLqFQ070775; Sun, 27 Mar 2011 22:21:52 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272221.p2RMLqFQ070775@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:21:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220067 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:21:52 -0000 Author: yongari Date: Sun Mar 27 22:21:52 2011 New Revision: 220067 URL: http://svn.freebsd.org/changeset/base/220067 Log: MFC r213841,218787-218788: r213841: It seems some multi-port dc(4) controllers shares SROM of the first port such that reading station address from second port always returned 0xFF:0xFF:0xFF:0xFF:0xFF:0xFF Unfortunately it seems there is no easy way to know whether SROM is shared or not. Workaround the issue by traversing dc(4) device list and see whether we're using second port and use station address of controller 0 as base station address of second port. PR: kern/79262 r218787: When driver have to use base softc due to lack of SROM on second port, copy SROM information from base softc as well and run SROM parser again. This change is necessary for some dual port controllers to make dc(4) correctly detect PHY media based on first port configuration table. While I'm here add a check for validity of the base softc before duplicating SROM contents from base softc. If driver failed to attach to the first port it can access invalid area. PR: kern/79262 Reviewed by: marius r218788: Apply special PHY initialization code for 21143 controllers before any other media configuration. Otherwise some 21143 controller cannot establish a link. While I'm here remove the PHY initialization code in dc_setcfg(). Since dc_setcfg() is called whenever link state is changed, having the PHY initialization code in dc_setcfg() resulted in continuous link flips. After driver resets SIA, use default SIA transmit/receive configuration instead of disabling autosense/autonegotiation. Otherwise, controller fails to establish a link as well as losing auto-negotiation capability. For manual media configuration, always configure 21143 controller with specified media to ensure media change. This change makes ANA-6922 establish link with/without auto-negotiation. While I'm here be more strict on link UP/DOWN detection logic. Many thanks to marius who fixed several bugs in initial patch and even tested the patch on a couple of dc(4) controllers. PR: kern/79262 Reviewed by: marius Tested by: marius Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:20:44 2011 (r220066) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:21:52 2011 (r220067) @@ -293,6 +293,7 @@ static int dc_decode_leaf_sia(struct dc_ static int dc_decode_leaf_mii(struct dc_softc *, struct dc_eblock_mii *); static int dc_decode_leaf_sym(struct dc_softc *, struct dc_eblock_sym *); static void dc_apply_fixup(struct dc_softc *, int); +static int dc_check_multiport(struct dc_softc *); #ifdef DC_USEIOSPACE #define DC_RES SYS_RES_IOPORT @@ -944,23 +945,45 @@ static void dc_miibus_statchg(device_t dev) { struct dc_softc *sc; + struct ifnet *ifp; struct mii_data *mii; struct ifmedia *ifm; sc = device_get_softc(dev); - if (DC_IS_ADMTEK(sc)) - return; mii = device_get_softc(sc->dc_miibus); + ifp = sc->dc_ifp; + if (mii == NULL || ifp == NULL || + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + return; + ifm = &mii->mii_media; if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) { dc_setcfg(sc, ifm->ifm_media); sc->dc_if_media = ifm->ifm_media; - } else { - dc_setcfg(sc, mii->mii_media_active); - sc->dc_if_media = mii->mii_media_active; + return; } + + sc->dc_link = 0; + if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) == + (IFM_ACTIVE | IFM_AVALID)) { + switch (IFM_SUBTYPE(mii->mii_media_active)) { + case IFM_10_T: + case IFM_100_TX: + sc->dc_link = 1; + break; + default: + break; + } + } + if (sc->dc_link == 0) + return; + + sc->dc_if_media = mii->mii_media_active; + if (DC_IS_ADMTEK(sc)) + return; + dc_setcfg(sc, mii->mii_media_active); } /* @@ -1404,8 +1427,6 @@ dc_setcfg(struct dc_softc *sc, int media if (!DC_IS_DAVICOM(sc)) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, IFM_AUTO); } else { if (DC_IS_PNIC(sc)) { DC_PN_GPIO_SETBIT(sc, DC_PN_GPIO_SPEEDSEL); @@ -1415,10 +1436,6 @@ dc_setcfg(struct dc_softc *sc, int media DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PCS); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_SCRAMBLER); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, - (media & IFM_GMASK) == IFM_FDX ? - IFM_100_TX | IFM_FDX : IFM_100_TX); } } @@ -1442,8 +1459,6 @@ dc_setcfg(struct dc_softc *sc, int media if (!DC_IS_DAVICOM(sc)) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL); DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF); - if (DC_IS_INTEL(sc)) - dc_apply_fixup(sc, IFM_AUTO); } else { if (DC_IS_PNIC(sc)) { DC_PN_GPIO_CLRBIT(sc, DC_PN_GPIO_SPEEDSEL); @@ -1463,9 +1478,6 @@ dc_setcfg(struct dc_softc *sc, int media DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); DC_CLRBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL); - dc_apply_fixup(sc, - (media & IFM_GMASK) == IFM_FDX ? - IFM_10_T | IFM_FDX : IFM_10_T); DELAY(20000); } } @@ -1537,7 +1549,7 @@ dc_reset(struct dc_softc *sc) */ if (DC_IS_INTEL(sc)) { DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET); - CSR_WRITE_4(sc, DC_10BTCTRL, 0); + CSR_WRITE_4(sc, DC_10BTCTRL, 0xFFFFFFFF); CSR_WRITE_4(sc, DC_WATCHDOG, 0); } } @@ -1815,6 +1827,7 @@ dc_attach(device_t dev) u_int32_t command; struct dc_softc *sc; struct ifnet *ifp; + struct dc_mediainfo *m; u_int32_t reg, revision; int error, i, mac_offset, phy, rid, tmp; u_int8_t *mac; @@ -2098,6 +2111,36 @@ dc_attach(device_t dev) break; } + bcopy(eaddr, sc->dc_eaddr, sizeof(eaddr)); + /* + * If we still have invalid station address, see whether we can + * find station address for chip 0. Some multi-port controllers + * just store station address for chip 0 if they have a shared + * SROM. + */ + if ((sc->dc_eaddr[0] == 0 && (sc->dc_eaddr[1] & ~0xffff) == 0) || + (sc->dc_eaddr[0] == 0xffffffff && + (sc->dc_eaddr[1] & 0xffff) == 0xffff)) { + error = dc_check_multiport(sc); + if (error == 0) { + bcopy(sc->dc_eaddr, eaddr, sizeof(eaddr)); + /* Extract media information. */ + if (DC_IS_INTEL(sc) && sc->dc_srom != NULL) { + while (sc->dc_mi != NULL) { + m = sc->dc_mi->dc_next; + free(sc->dc_mi, M_DEVBUF); + sc->dc_mi = m; + } + error = dc_parse_21143_srom(sc); + if (error != 0) + goto fail; + } + } else if (error == ENOMEM) + goto fail; + else + error = 0; + } + /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, @@ -2928,11 +2971,8 @@ dc_tick(void *xsc) */ if ((DC_HAS_BROKEN_RXSTATE(sc) || (CSR_READ_4(sc, DC_ISR) & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT) && - sc->dc_cdata.dc_tx_cnt == 0) { + sc->dc_cdata.dc_tx_cnt == 0) mii_tick(mii); - if (!(mii->mii_media_status & IFM_ACTIVE)) - sc->dc_link = 0; - } } } else mii_tick(mii); @@ -2956,12 +2996,8 @@ dc_tick(void *xsc) * that time, packets will stay in the send queue, and once the * link comes up, they will be flushed out to the wire. */ - if (!sc->dc_link && mii->mii_media_status & IFM_ACTIVE && - IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) { - sc->dc_link++; - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - dc_start_locked(ifp); - } + if (sc->dc_link != 0 && !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + dc_start_locked(ifp); if (sc->dc_flags & DC_21143_NWAY && !sc->dc_link) callout_reset(&sc->dc_stat_ch, hz/10, dc_tick, sc); @@ -3384,6 +3420,7 @@ dc_init_locked(struct dc_softc *sc) { struct ifnet *ifp = sc->dc_ifp; struct mii_data *mii; + struct ifmedia *ifm; DC_LOCK_ASSERT(sc); @@ -3394,6 +3431,10 @@ dc_init_locked(struct dc_softc *sc) */ dc_stop(sc); dc_reset(sc); + if (DC_IS_INTEL(sc)) { + ifm = &mii->mii_media; + dc_apply_fixup(sc, ifm->ifm_media); + } /* * Set cache alignment and burst length. @@ -3537,12 +3578,12 @@ dc_init_locked(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); CSR_WRITE_4(sc, DC_RXSTART, 0xFFFFFFFF); - mii_mediachg(mii); - dc_setcfg(sc, sc->dc_if_media); - ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + mii_mediachg(mii); + dc_setcfg(sc, sc->dc_if_media); + /* Don't start the ticker if this is a homePNA link. */ if (IFM_SUBTYPE(mii->mii_media.ifm_media) == IFM_HPNA_1) sc->dc_link = 1; @@ -3573,7 +3614,9 @@ dc_ifmedia_upd(struct ifnet *ifp) mii_mediachg(mii); ifm = &mii->mii_media; - if (DC_IS_DAVICOM(sc) && + if (DC_IS_INTEL(sc)) + dc_setcfg(sc, ifm->ifm_media); + else if (DC_IS_DAVICOM(sc) && IFM_SUBTYPE(ifm->ifm_media) == IFM_HPNA_1) dc_setcfg(sc, ifm->ifm_media); else @@ -3834,3 +3877,52 @@ dc_shutdown(device_t dev) return (0); } + +static int +dc_check_multiport(struct dc_softc *sc) +{ + struct dc_softc *dsc; + devclass_t dc; + device_t child; + uint8_t *eaddr; + int unit; + + dc = devclass_find("dc"); + for (unit = 0; unit < devclass_get_maxunit(dc); unit++) { + child = devclass_get_device(dc, unit); + if (child == NULL) + continue; + if (child == sc->dc_dev) + continue; + if (device_get_parent(child) != device_get_parent(sc->dc_dev)) + continue; + if (unit > device_get_unit(sc->dc_dev)) + continue; + if (device_is_attached(child) == 0) + continue; + dsc = device_get_softc(child); + device_printf(sc->dc_dev, + "Using station address of %s as base\n", + device_get_nameunit(child)); + bcopy(dsc->dc_eaddr, sc->dc_eaddr, ETHER_ADDR_LEN); + eaddr = (uint8_t *)sc->dc_eaddr; + eaddr[5]++; + /* Prepare SROM to parse again. */ + if (DC_IS_INTEL(sc) && dsc->dc_srom != NULL && + sc->dc_romwidth != 0) { + free(sc->dc_srom, M_DEVBUF); + sc->dc_romwidth = dsc->dc_romwidth; + sc->dc_srom = malloc(DC_ROM_SIZE(sc->dc_romwidth), + M_DEVBUF, M_NOWAIT); + if (sc->dc_srom == NULL) { + device_printf(sc->dc_dev, + "Could not allocate SROM buffer\n"); + return (ENOMEM); + } + bcopy(dsc->dc_srom, sc->dc_srom, + DC_ROM_SIZE(sc->dc_romwidth)); + } + return (0); + } + return (ENOENT); +} Modified: stable/7/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:20:44 2011 (r220066) +++ stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:21:52 2011 (r220067) @@ -745,6 +745,7 @@ struct dc_softc { int dc_if_media; u_int32_t dc_flags; u_int32_t dc_txthresh; + u_int32_t dc_eaddr[2]; u_int8_t *dc_srom; struct dc_mediainfo *dc_mi; struct dc_list_data *dc_ldata; From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:31:17 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBF99106564A; Sun, 27 Mar 2011 22:31:17 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AED318FC14; Sun, 27 Mar 2011 22:31:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMVHJY071115; Sun, 27 Mar 2011 22:31:17 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMVHR6071112; Sun, 27 Mar 2011 22:31:17 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272231.p2RMVHR6071112@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:31:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220068 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:31:17 -0000 Author: yongari Date: Sun Mar 27 22:31:17 2011 New Revision: 220068 URL: http://svn.freebsd.org/changeset/base/220068 Log: MFC r218789,218820,218826-218828: r218789: Remove use case of DC_TX_ONE. It was used to limit queue just 1 TX frame in DM910x controllers. In r67595(more than 10 years ago) it was replaced to use "Store and Forward" mode and made controller generate TX completion interrupt for every frame. r218820: For controllers that have TX interrupt moderation capability, request TX completion interrupt for every 8-th frames. Previously dc(4) requested TX completion interrupt if number of queued TX descriptors is greater than 64. This caused a lot of TX completion interrupt under high TX load once driver queued more than 64 TX descriptors. It's quite normal to see more than 64 queued TX descriptors under high TX load. This change reduces the number of TX completion interrupts to be less than 17k under high TX load. Because this change does not generate TX completion interrupt for each frame, add reclaiming transmitted buffers in dc_tick not to generate false watchdog timeouts. While I'm here add check for queued descriptors in dc_txeof() since there is no more work to do when there is no pending descriptors. r218826: Make sure to clear status word of TX descriptor in dc_list_tx_init(). Do not update if_opackets if the transmission had failed. r218827: There is no need to execute filter configuration when driver is not running. Remove wrong driver state change in dc_setfilt_xircom(). While I'm here nuke unnecessary assignments. r218828: Fix a long standing bug where driver handed over RX descriptor ownership to controller before completion of access to the descriptor. Driver is faking up status word so it should not give ownership to controller until it completes RX processing. Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:21:52 2011 (r220067) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:31:17 2011 (r220068) @@ -1334,7 +1334,6 @@ dc_setfilt_xircom(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); - ifp->if_drv_flags |= IFF_DRV_RUNNING; sframe->dc_status = htole32(DC_TXSTAT_OWN); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); @@ -2466,13 +2465,15 @@ dc_list_tx_init(struct dc_softc *sc) nexti = 0; else nexti = i + 1; + ld->dc_tx_list[i].dc_status = 0; + ld->dc_tx_list[i].dc_ctl = 0; + ld->dc_tx_list[i].dc_data = 0; ld->dc_tx_list[i].dc_next = htole32(DC_TXDESC(sc, nexti)); cd->dc_tx_chain[i] = NULL; - ld->dc_tx_list[i].dc_data = 0; - ld->dc_tx_list[i].dc_ctl = 0; } cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; + cd->dc_tx_pkts = 0; bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); @@ -2670,7 +2671,6 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, * the status word to make it look like a successful * frame reception. */ - dc_newbuf(sc, i, 0); bcopy(ptr, mtod(m, char *), total_len); cur_rx->dc_status = htole32(rxstat | DC_RXSTAT_FIRSTFRAG); } @@ -2841,6 +2841,9 @@ dc_txeof(struct dc_softc *sc) int idx; u_int32_t ctl, txstat; + if (sc->dc_cdata.dc_tx_cnt == 0) + return; + ifp = sc->dc_ifp; /* @@ -2912,11 +2915,10 @@ dc_txeof(struct dc_softc *sc) dc_init_locked(sc); return; } - } - + } else + ifp->if_opackets++; ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3; - ifp->if_opackets++; if (sc->dc_cdata.dc_tx_chain[idx] != NULL) { bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], @@ -2952,6 +2954,13 @@ dc_tick(void *xsc) ifp = sc->dc_ifp; mii = device_get_softc(sc->dc_miibus); + /* + * Reclaim transmitted frames for controllers that do + * not generate TX completion interrupt for every frame. + */ + if (sc->dc_flags & DC_TX_USE_TX_INTR) + dc_txeof(sc); + if (sc->dc_flags & DC_REDUCED_MII_POLL) { if (sc->dc_flags & DC_21143_NWAY) { r = CSR_READ_4(sc, DC_10BTSTAT); @@ -3322,8 +3331,11 @@ dc_encap(struct dc_softc *sc, struct mbu htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_INTR_ALWAYS) sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); - if (sc->dc_flags & DC_TX_USE_TX_INTR && sc->dc_cdata.dc_tx_cnt > 64) + if (sc->dc_flags & DC_TX_USE_TX_INTR && + ++sc->dc_cdata.dc_tx_pkts >= 8) { + sc->dc_cdata.dc_tx_pkts = 0; sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + } sc->dc_ldata->dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], @@ -3391,11 +3403,6 @@ dc_start_locked(struct ifnet *ifp) * to him. */ BPF_MTAP(ifp, m_head); - - if (sc->dc_flags & DC_TX_ONE) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - break; - } } if (queued > 0) { @@ -3687,14 +3694,13 @@ dc_ioctl(struct ifnet *ifp, u_long comma } sc->dc_if_flags = ifp->if_flags; DC_UNLOCK(sc); - error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: DC_LOCK(sc); - dc_setfilt(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + dc_setfilt(sc); DC_UNLOCK(sc); - error = 0; break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:21:52 2011 (r220067) +++ stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 22:31:17 2011 (r220068) @@ -495,6 +495,7 @@ struct dc_chain_data { bus_dmamap_t dc_tx_map[DC_TX_LIST_CNT]; u_int32_t *dc_sbuf; u_int8_t dc_pad[DC_MIN_FRAMELEN]; + int dc_tx_pkts; int dc_tx_first; int dc_tx_prod; int dc_tx_cons; @@ -780,7 +781,6 @@ struct dc_softc { #define DC_128BIT_HASH 0x00001000 #define DC_64BIT_HASH 0x00002000 #define DC_TULIP_LEDS 0x00004000 -#define DC_TX_ONE 0x00008000 #define DC_TX_ALIGN 0x00010000 /* align mbuf on tx */ /* From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:32:14 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7621F106566C; Sun, 27 Mar 2011 22:32:14 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 63A478FC08; Sun, 27 Mar 2011 22:32:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMWEBX071171; Sun, 27 Mar 2011 22:32:14 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMWEhP071168; Sun, 27 Mar 2011 22:32:14 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272232.p2RMWEhP071168@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:32:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220069 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:32:14 -0000 Author: yongari Date: Sun Mar 27 22:32:14 2011 New Revision: 220069 URL: http://svn.freebsd.org/changeset/base/220069 Log: MFC r218789,218820,218826-218828: r218789: Remove use case of DC_TX_ONE. It was used to limit queue just 1 TX frame in DM910x controllers. In r67595(more than 10 years ago) it was replaced to use "Store and Forward" mode and made controller generate TX completion interrupt for every frame. r218820: For controllers that have TX interrupt moderation capability, request TX completion interrupt for every 8-th frames. Previously dc(4) requested TX completion interrupt if number of queued TX descriptors is greater than 64. This caused a lot of TX completion interrupt under high TX load once driver queued more than 64 TX descriptors. It's quite normal to see more than 64 queued TX descriptors under high TX load. This change reduces the number of TX completion interrupts to be less than 17k under high TX load. Because this change does not generate TX completion interrupt for each frame, add reclaiming transmitted buffers in dc_tick not to generate false watchdog timeouts. While I'm here add check for queued descriptors in dc_txeof() since there is no more work to do when there is no pending descriptors. r218826: Make sure to clear status word of TX descriptor in dc_list_tx_init(). Do not update if_opackets if the transmission had failed. r218827: There is no need to execute filter configuration when driver is not running. Remove wrong driver state change in dc_setfilt_xircom(). While I'm here nuke unnecessary assignments. r218828: Fix a long standing bug where driver handed over RX descriptor ownership to controller before completion of access to the descriptor. Driver is faking up status word so it should not give ownership to controller until it completes RX processing. Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:31:17 2011 (r220068) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:32:14 2011 (r220069) @@ -1335,7 +1335,6 @@ dc_setfilt_xircom(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); - ifp->if_drv_flags |= IFF_DRV_RUNNING; sframe->dc_status = htole32(DC_TXSTAT_OWN); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); @@ -2467,13 +2466,15 @@ dc_list_tx_init(struct dc_softc *sc) nexti = 0; else nexti = i + 1; + ld->dc_tx_list[i].dc_status = 0; + ld->dc_tx_list[i].dc_ctl = 0; + ld->dc_tx_list[i].dc_data = 0; ld->dc_tx_list[i].dc_next = htole32(DC_TXDESC(sc, nexti)); cd->dc_tx_chain[i] = NULL; - ld->dc_tx_list[i].dc_data = 0; - ld->dc_tx_list[i].dc_ctl = 0; } cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; + cd->dc_tx_pkts = 0; bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); @@ -2671,7 +2672,6 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, * the status word to make it look like a successful * frame reception. */ - dc_newbuf(sc, i, 0); bcopy(ptr, mtod(m, char *), total_len); cur_rx->dc_status = htole32(rxstat | DC_RXSTAT_FIRSTFRAG); } @@ -2838,6 +2838,9 @@ dc_txeof(struct dc_softc *sc) int idx; u_int32_t ctl, txstat; + if (sc->dc_cdata.dc_tx_cnt == 0) + return; + ifp = sc->dc_ifp; /* @@ -2909,11 +2912,10 @@ dc_txeof(struct dc_softc *sc) dc_init_locked(sc); return; } - } - + } else + ifp->if_opackets++; ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3; - ifp->if_opackets++; if (sc->dc_cdata.dc_tx_chain[idx] != NULL) { bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], @@ -2949,6 +2951,13 @@ dc_tick(void *xsc) ifp = sc->dc_ifp; mii = device_get_softc(sc->dc_miibus); + /* + * Reclaim transmitted frames for controllers that do + * not generate TX completion interrupt for every frame. + */ + if (sc->dc_flags & DC_TX_USE_TX_INTR) + dc_txeof(sc); + if (sc->dc_flags & DC_REDUCED_MII_POLL) { if (sc->dc_flags & DC_21143_NWAY) { r = CSR_READ_4(sc, DC_10BTSTAT); @@ -3317,8 +3326,11 @@ dc_encap(struct dc_softc *sc, struct mbu htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_INTR_ALWAYS) sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); - if (sc->dc_flags & DC_TX_USE_TX_INTR && sc->dc_cdata.dc_tx_cnt > 64) + if (sc->dc_flags & DC_TX_USE_TX_INTR && + ++sc->dc_cdata.dc_tx_pkts >= 8) { + sc->dc_cdata.dc_tx_pkts = 0; sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + } sc->dc_ldata->dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], @@ -3386,11 +3398,6 @@ dc_start_locked(struct ifnet *ifp) * to him. */ BPF_MTAP(ifp, m_head); - - if (sc->dc_flags & DC_TX_ONE) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - break; - } } if (queued > 0) { @@ -3682,14 +3689,13 @@ dc_ioctl(struct ifnet *ifp, u_long comma } sc->dc_if_flags = ifp->if_flags; DC_UNLOCK(sc); - error = 0; break; case SIOCADDMULTI: case SIOCDELMULTI: DC_LOCK(sc); - dc_setfilt(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + dc_setfilt(sc); DC_UNLOCK(sc); - error = 0; break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: Modified: stable/7/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:31:17 2011 (r220068) +++ stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 22:32:14 2011 (r220069) @@ -495,6 +495,7 @@ struct dc_chain_data { bus_dmamap_t dc_tx_map[DC_TX_LIST_CNT]; u_int32_t *dc_sbuf; u_int8_t dc_pad[DC_MIN_FRAMELEN]; + int dc_tx_pkts; int dc_tx_first; int dc_tx_prod; int dc_tx_cons; @@ -780,7 +781,6 @@ struct dc_softc { #define DC_128BIT_HASH 0x00001000 #define DC_64BIT_HASH 0x00002000 #define DC_TULIP_LEDS 0x00004000 -#define DC_TX_ONE 0x00008000 #define DC_TX_ALIGN 0x00010000 /* align mbuf on tx */ /* From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:36:16 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C64EC106566B; Sun, 27 Mar 2011 22:36:16 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B42298FC0C; Sun, 27 Mar 2011 22:36:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMaGFC071392; Sun, 27 Mar 2011 22:36:16 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMaGdO071390; Sun, 27 Mar 2011 22:36:16 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272236.p2RMaGdO071390@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:36:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220070 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:36:17 -0000 Author: yongari Date: Sun Mar 27 22:36:16 2011 New Revision: 220070 URL: http://svn.freebsd.org/changeset/base/220070 Log: MFC r218830-218831: r218830: Send frames only when there is a valid link and driver is running as well as controller has enough free TX descriptors. Remove check for number of queued frames before attempting to transmit. I guess it was added to allow draining queued frames even if there is no link. I'm under the impression this type of check should be done in upper layer. No other drivers in tree do that. r218831: Rearrange interrupt handler a bit and remove forever loop. Previously dc(4) always checked whether there is pending interrupts and this consumed a lot of CPU cycles in interrupt handler. Limit the number of processing for TX/RX frames to 16. Also allow sending frames in the loop not to starve TX under high RX load. Reading DC_ISR register should be protected with driver lock, otherwise interrupt handler could be run(e.g. link state change) before the completion of dc_init_locked(). While I'm here remove unneeded code. Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:32:14 2011 (r220069) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:36:16 2011 (r220070) @@ -3135,16 +3135,19 @@ dc_intr(void *arg) struct dc_softc *sc; struct ifnet *ifp; u_int32_t status; + int curpkts, n; sc = arg; if (sc->suspended) return; - if ((CSR_READ_4(sc, DC_ISR) & DC_INTRS) == 0) - return; - DC_LOCK(sc); + status = CSR_READ_4(sc, DC_ISR); + if (status == 0xFFFFFFFF || (status & DC_INTRS) == 0) { + DC_UNLOCK(sc); + return; + } ifp = sc->dc_ifp; #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { @@ -3152,26 +3155,16 @@ dc_intr(void *arg) return; } #endif - - /* Suppress unwanted interrupts */ - if (!(ifp->if_flags & IFF_UP)) { - if (CSR_READ_4(sc, DC_ISR) & DC_INTRS) - dc_stop(sc); - DC_UNLOCK(sc); - return; - } - /* Disable interrupts. */ CSR_WRITE_4(sc, DC_IMR, 0x00000000); - while (((status = CSR_READ_4(sc, DC_ISR)) & DC_INTRS) && - status != 0xFFFFFFFF && - (ifp->if_drv_flags & IFF_DRV_RUNNING)) { - + for (n = 16; n > 0; n--) { + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + break; + /* Ack interrupts. */ CSR_WRITE_4(sc, DC_ISR, status); if (status & DC_ISR_RX_OK) { - int curpkts; curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3196,7 +3189,6 @@ dc_intr(void *arg) if ((status & DC_ISR_RX_WATDOGTIMEO) || (status & DC_ISR_RX_NOBUF)) { - int curpkts; curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3205,17 +3197,23 @@ dc_intr(void *arg) } } + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + dc_start_locked(ifp); + if (status & DC_ISR_BUS_ERR) { dc_reset(sc); dc_init_locked(sc); + DC_UNLOCK(sc); + return; } + status = CSR_READ_4(sc, DC_ISR); + if (status == 0xFFFFFFFF || (status & DC_INTRS) == 0) + break; } /* Re-enable interrupts. */ - CSR_WRITE_4(sc, DC_IMR, DC_INTRS); - - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - dc_start_locked(ifp); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + CSR_WRITE_4(sc, DC_IMR, DC_INTRS); DC_UNLOCK(sc); } @@ -3375,10 +3373,8 @@ dc_start_locked(struct ifnet *ifp) DC_LOCK_ASSERT(sc); - if (!sc->dc_link && ifp->if_snd.ifq_len < 10) - return; - - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING || sc->dc_link == 0) return; idx = sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:37:29 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 075911065670; Sun, 27 Mar 2011 22:37:29 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E949F8FC12; Sun, 27 Mar 2011 22:37:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMbShT071450; Sun, 27 Mar 2011 22:37:28 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMbSWV071448; Sun, 27 Mar 2011 22:37:28 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272237.p2RMbSWV071448@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:37:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220071 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:37:29 -0000 Author: yongari Date: Sun Mar 27 22:37:28 2011 New Revision: 220071 URL: http://svn.freebsd.org/changeset/base/220071 Log: MFC r218830-218831: r218830: Send frames only when there is a valid link and driver is running as well as controller has enough free TX descriptors. Remove check for number of queued frames before attempting to transmit. I guess it was added to allow draining queued frames even if there is no link. I'm under the impression this type of check should be done in upper layer. No other drivers in tree do that. r218831: Rearrange interrupt handler a bit and remove forever loop. Previously dc(4) always checked whether there is pending interrupts and this consumed a lot of CPU cycles in interrupt handler. Limit the number of processing for TX/RX frames to 16. Also allow sending frames in the loop not to starve TX under high RX load. Reading DC_ISR register should be protected with driver lock, otherwise interrupt handler could be run(e.g. link state change) before the completion of dc_init_locked(). While I'm here remove unneeded code. Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:36:16 2011 (r220070) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:37:28 2011 (r220071) @@ -3130,16 +3130,19 @@ dc_intr(void *arg) struct dc_softc *sc; struct ifnet *ifp; u_int32_t status; + int curpkts, n; sc = arg; if (sc->suspended) return; - if ((CSR_READ_4(sc, DC_ISR) & DC_INTRS) == 0) - return; - DC_LOCK(sc); + status = CSR_READ_4(sc, DC_ISR); + if (status == 0xFFFFFFFF || (status & DC_INTRS) == 0) { + DC_UNLOCK(sc); + return; + } ifp = sc->dc_ifp; #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { @@ -3147,26 +3150,16 @@ dc_intr(void *arg) return; } #endif - - /* Suppress unwanted interrupts */ - if (!(ifp->if_flags & IFF_UP)) { - if (CSR_READ_4(sc, DC_ISR) & DC_INTRS) - dc_stop(sc); - DC_UNLOCK(sc); - return; - } - /* Disable interrupts. */ CSR_WRITE_4(sc, DC_IMR, 0x00000000); - while (((status = CSR_READ_4(sc, DC_ISR)) & DC_INTRS) && - status != 0xFFFFFFFF && - (ifp->if_drv_flags & IFF_DRV_RUNNING)) { - + for (n = 16; n > 0; n--) { + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) + break; + /* Ack interrupts. */ CSR_WRITE_4(sc, DC_ISR, status); if (status & DC_ISR_RX_OK) { - int curpkts; curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3191,7 +3184,6 @@ dc_intr(void *arg) if ((status & DC_ISR_RX_WATDOGTIMEO) || (status & DC_ISR_RX_NOBUF)) { - int curpkts; curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3200,17 +3192,23 @@ dc_intr(void *arg) } } + if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) + dc_start_locked(ifp); + if (status & DC_ISR_BUS_ERR) { dc_reset(sc); dc_init_locked(sc); + DC_UNLOCK(sc); + return; } + status = CSR_READ_4(sc, DC_ISR); + if (status == 0xFFFFFFFF || (status & DC_INTRS) == 0) + break; } /* Re-enable interrupts. */ - CSR_WRITE_4(sc, DC_IMR, DC_INTRS); - - if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - dc_start_locked(ifp); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) + CSR_WRITE_4(sc, DC_IMR, DC_INTRS); DC_UNLOCK(sc); } @@ -3370,10 +3368,8 @@ dc_start_locked(struct ifnet *ifp) DC_LOCK_ASSERT(sc); - if (!sc->dc_link && ifp->if_snd.ifq_len < 10) - return; - - if (ifp->if_drv_flags & IFF_DRV_OACTIVE) + if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != + IFF_DRV_RUNNING || sc->dc_link == 0) return; idx = sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:48:59 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38E64106566C; Sun, 27 Mar 2011 22:48:59 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 251058FC0A; Sun, 27 Mar 2011 22:48:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMmxp9071711; Sun, 27 Mar 2011 22:48:59 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMmxOQ071708; Sun, 27 Mar 2011 22:48:59 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272248.p2RMmxOQ071708@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:48:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220072 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:48:59 -0000 Author: yongari Date: Sun Mar 27 22:48:58 2011 New Revision: 220072 URL: http://svn.freebsd.org/changeset/base/220072 Log: MFC r218832: Split common TX/RX descriptor DMA tag to TX and RX DMA tags respectively and fix all bus_dma(9) issues seen when bounce buffers are used. o Setup frame handling had no bus_dmamap_sync(9) which prevented driver from configuring RX filter. Add missing bus_dmamap_sync(9) in both dc_setfilt_21143()/dc_setfilt_xircom() and dc_txeof(). o Use bus_addr_t for DMA segment instead of using u_int32_t. o Introduce dc_dma_alloc()/dc_dma_free() functions to allocate/free DMA'able memory. o Create two DMA descriptor list for each TX/RX lists. This change will minimize the size of bounce buffers that would be used in each TX/RX path. Previously driver had to copy both TX/RX lists when bounce buffer is active. o 21143 data sheet says descriptor list requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Setup frame requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Add missing DMA map unload for both setup frame and TX/RX descriptor list. o Overhaul RX handling logic such that make driver always allocate new RX buffer with dc_newbuf(). Previously driver allowed to copy received frame with m_devget(9) after passing the descriptor ownership to controller. This can lead to passing wrong frame to upper stack. o Introduce dc_discard_rxbuf() which will discard received frame and reuse loaded DMA map and RX mbuf. o Correct several wrong bus_dmamap_sync(9) usage in dc_rxeof and dc_txeof. The TX/RX descriptor lists are updated by both driver and HW so READ/WRITE semantics should be used. o If driver failed to allocate new RX buffer, update if_iqdrops counter instead of if_ierrors since driver received the frame without errors. o Make sure to unload loaded setup frame DMA map in dc_txeof and clear the mark of setup frame of the TX descriptor in dc_txeof(). o Add check for possible TX descriptor overruns in dc_encap() and move check for free buffer to caller, dc_start_locked(). o Swap the loaded DMA map and the last DMA map for multi-segmented frames. Since dc_txeof() assumes the last descriptor of the frame has the DMA map, driver should swap the first and the last DMA map in dc_encap(). Previously driver tried to unload not-yet-loaded DMA map such that the loaded DMA map was not unloaded at all for multi-segmented frames. o Rewrite DC_RXDESC/DC_TXDESC macro to simpler one. o Remove definition of ETHER_ALIGN, it's already defined in ethernet.h. With this changes, dc(4) works with bounce buffers and it shall also fix issues which might have shown in PAE environments. Tested by: marius Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:37:28 2011 (r220071) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:48:58 2011 (r220072) @@ -233,7 +233,8 @@ static int dc_detach(device_t); static int dc_suspend(device_t); static int dc_resume(device_t); static const struct dc_type *dc_devtype(device_t); -static int dc_newbuf(struct dc_softc *, int, int); +static void dc_discard_rxbuf(struct dc_softc *, int); +static int dc_newbuf(struct dc_softc *, int); static int dc_encap(struct dc_softc *, struct mbuf **); static void dc_pnic_rx_bug_war(struct dc_softc *, int); static int dc_rx_resync(struct dc_softc *); @@ -253,6 +254,10 @@ static int dc_shutdown(device_t); static int dc_ifmedia_upd(struct ifnet *); static void dc_ifmedia_sts(struct ifnet *, struct ifmediareq *); +static int dc_dma_alloc(struct dc_softc *); +static void dc_dma_free(struct dc_softc *); +static void dc_dma_map_addr(void *, bus_dma_segment_t *, int, int); + static void dc_delay(struct dc_softc *); static void dc_eeprom_idle(struct dc_softc *); static void dc_eeprom_putbyte(struct dc_softc *, int); @@ -1087,11 +1092,11 @@ dc_setfilt_21143(struct dc_softc *sc) i = sc->dc_cdata.dc_tx_prod; DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); sc->dc_cdata.dc_tx_cnt++; - sframe = &sc->dc_ldata->dc_tx_list[i]; + sframe = &sc->dc_ldata.dc_tx_list[i]; sp = sc->dc_cdata.dc_sbuf; bzero(sp, DC_SFRAME_LEN); - sframe->dc_data = htole32(sc->dc_saddr); + sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | DC_TXCTL_TLINK | DC_FILTER_HASHPERF | DC_TXCTL_FINT); @@ -1130,6 +1135,7 @@ dc_setfilt_21143(struct dc_softc *sc) sp[41] = DC_SP_MAC(eaddr[2]); sframe->dc_status = htole32(DC_TXSTAT_OWN); + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); /* @@ -1290,11 +1296,11 @@ dc_setfilt_xircom(struct dc_softc *sc) i = sc->dc_cdata.dc_tx_prod; DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); sc->dc_cdata.dc_tx_cnt++; - sframe = &sc->dc_ldata->dc_tx_list[i]; + sframe = &sc->dc_ldata.dc_tx_list[i]; sp = sc->dc_cdata.dc_sbuf; bzero(sp, DC_SFRAME_LEN); - sframe->dc_data = htole32(sc->dc_saddr); + sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | DC_TXCTL_TLINK | DC_FILTER_HASHPERF | DC_TXCTL_FINT); @@ -1335,6 +1341,7 @@ dc_setfilt_xircom(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); sframe->dc_status = htole32(DC_TXSTAT_OWN); + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); /* @@ -1806,7 +1813,7 @@ dc_parse_21143_srom(struct dc_softc *sc) static void dc_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error) { - u_int32_t *paddr; + bus_addr_t *paddr; KASSERT(nseg == 1, ("%s: wrong number of segments (%d)", __func__, nseg)); @@ -1814,6 +1821,208 @@ dc_dma_map_addr(void *arg, bus_dma_segme *paddr = segs->ds_addr; } +static int +dc_dma_alloc(struct dc_softc *sc) +{ + int error, i; + + error = bus_dma_tag_create(bus_get_dma_tag(sc->dc_dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, 0, + NULL, NULL, &sc->dc_ptag); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate parent DMA tag\n"); + goto fail; + } + + /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, DC_RX_LIST_SZ, 1, + DC_RX_LIST_SZ, 0, NULL, NULL, &sc->dc_rx_ltag); + if (error) { + device_printf(sc->dc_dev, "failed to create RX list DMA tag\n"); + goto fail; + } + + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, DC_TX_LIST_SZ, 1, + DC_TX_LIST_SZ, 0, NULL, NULL, &sc->dc_tx_ltag); + if (error) { + device_printf(sc->dc_dev, "failed to create TX list DMA tag\n"); + goto fail; + } + + /* RX descriptor list. */ + error = bus_dmamem_alloc(sc->dc_rx_ltag, + (void **)&sc->dc_ldata.dc_rx_list, BUS_DMA_NOWAIT | + BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_rx_lmap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for RX list\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_rx_ltag, sc->dc_rx_lmap, + sc->dc_ldata.dc_rx_list, DC_RX_LIST_SZ, dc_dma_map_addr, + &sc->dc_ldata.dc_rx_list_paddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "failed to load DMA'able memory for RX list\n"); + goto fail; + } + /* TX descriptor list. */ + error = bus_dmamem_alloc(sc->dc_tx_ltag, + (void **)&sc->dc_ldata.dc_tx_list, BUS_DMA_NOWAIT | + BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_tx_lmap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for TX list\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_tx_ltag, sc->dc_tx_lmap, + sc->dc_ldata.dc_tx_list, DC_TX_LIST_SZ, dc_dma_map_addr, + &sc->dc_ldata.dc_tx_list_paddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "cannot load DMA'able memory for TX list\n"); + goto fail; + } + + /* + * Allocate a busdma tag and DMA safe memory for the multicast + * setup frame. + */ + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + DC_SFRAME_LEN + DC_MIN_FRAMELEN, 1, DC_SFRAME_LEN + DC_MIN_FRAMELEN, + 0, NULL, NULL, &sc->dc_stag); + if (error) { + device_printf(sc->dc_dev, + "failed to create DMA tag for setup frame\n"); + goto fail; + } + error = bus_dmamem_alloc(sc->dc_stag, (void **)&sc->dc_cdata.dc_sbuf, + BUS_DMA_NOWAIT, &sc->dc_smap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for setup frame\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_stag, sc->dc_smap, sc->dc_cdata.dc_sbuf, + DC_SFRAME_LEN, dc_dma_map_addr, &sc->dc_saddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "cannot load DMA'able memory for setup frame\n"); + goto fail; + } + + /* Allocate a busdma tag for RX mbufs. */ + error = bus_dma_tag_create(sc->dc_ptag, DC_RXBUF_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &sc->dc_rx_mtag); + if (error) { + device_printf(sc->dc_dev, "failed to create RX mbuf tag\n"); + goto fail; + } + + /* Allocate a busdma tag for TX mbufs. */ + error = bus_dma_tag_create(sc->dc_ptag, 1, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES * DC_MAXFRAGS, DC_MAXFRAGS, MCLBYTES, + 0, NULL, NULL, &sc->dc_tx_mtag); + if (error) { + device_printf(sc->dc_dev, "failed to create TX mbuf tag\n"); + goto fail; + } + + /* Create the TX/RX busdma maps. */ + for (i = 0; i < DC_TX_LIST_CNT; i++) { + error = bus_dmamap_create(sc->dc_tx_mtag, 0, + &sc->dc_cdata.dc_tx_map[i]); + if (error) { + device_printf(sc->dc_dev, + "failed to create TX mbuf dmamap\n"); + goto fail; + } + } + for (i = 0; i < DC_RX_LIST_CNT; i++) { + error = bus_dmamap_create(sc->dc_rx_mtag, 0, + &sc->dc_cdata.dc_rx_map[i]); + if (error) { + device_printf(sc->dc_dev, + "failed to create RX mbuf dmamap\n"); + goto fail; + } + } + error = bus_dmamap_create(sc->dc_rx_mtag, 0, &sc->dc_sparemap); + if (error) { + device_printf(sc->dc_dev, + "failed to create spare RX mbuf dmamap\n"); + goto fail; + } + +fail: + return (error); +} + +static void +dc_dma_free(struct dc_softc *sc) +{ + int i; + + /* RX buffers. */ + if (sc->dc_rx_mtag != NULL) { + for (i = 0; i < DC_RX_LIST_CNT; i++) { + if (sc->dc_cdata.dc_rx_map[i] != NULL) + bus_dmamap_destroy(sc->dc_rx_mtag, + sc->dc_cdata.dc_rx_map[i]); + } + if (sc->dc_sparemap != NULL) + bus_dmamap_destroy(sc->dc_rx_mtag, sc->dc_sparemap); + bus_dma_tag_destroy(sc->dc_rx_mtag); + } + + /* TX buffers. */ + if (sc->dc_rx_mtag != NULL) { + for (i = 0; i < DC_TX_LIST_CNT; i++) { + if (sc->dc_cdata.dc_tx_map[i] != NULL) + bus_dmamap_destroy(sc->dc_tx_mtag, + sc->dc_cdata.dc_tx_map[i]); + } + bus_dma_tag_destroy(sc->dc_tx_mtag); + } + + /* RX descriptor list. */ + if (sc->dc_rx_ltag) { + if (sc->dc_rx_lmap != NULL) + bus_dmamap_unload(sc->dc_rx_ltag, sc->dc_rx_lmap); + if (sc->dc_rx_lmap != NULL && sc->dc_ldata.dc_rx_list != NULL) + bus_dmamem_free(sc->dc_rx_ltag, sc->dc_ldata.dc_rx_list, + sc->dc_rx_lmap); + bus_dma_tag_destroy(sc->dc_rx_ltag); + } + + /* TX descriptor list. */ + if (sc->dc_tx_ltag) { + if (sc->dc_tx_lmap != NULL) + bus_dmamap_unload(sc->dc_tx_ltag, sc->dc_tx_lmap); + if (sc->dc_tx_lmap != NULL && sc->dc_ldata.dc_tx_list != NULL) + bus_dmamem_free(sc->dc_tx_ltag, sc->dc_ldata.dc_tx_list, + sc->dc_tx_lmap); + bus_dma_tag_destroy(sc->dc_tx_ltag); + } + + /* multicast setup frame. */ + if (sc->dc_stag) { + if (sc->dc_smap != NULL) + bus_dmamap_unload(sc->dc_stag, sc->dc_smap); + if (sc->dc_smap != NULL && sc->dc_cdata.dc_sbuf != NULL) + bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, + sc->dc_smap); + bus_dma_tag_destroy(sc->dc_stag); + } +} + /* * Attach the interface. Allocate softc structures, do ifmedia * setup and ethernet/BPF attach. @@ -1827,7 +2036,7 @@ dc_attach(device_t dev) struct ifnet *ifp; struct dc_mediainfo *m; u_int32_t reg, revision; - int error, i, mac_offset, phy, rid, tmp; + int error, mac_offset, phy, rid, tmp; u_int8_t *mac; sc = device_get_softc(dev); @@ -2139,96 +2348,8 @@ dc_attach(device_t dev) error = 0; } - /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - sizeof(struct dc_list_data), 1, sizeof(struct dc_list_data), - 0, NULL, NULL, &sc->dc_ltag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamem_alloc(sc->dc_ltag, (void **)&sc->dc_ldata, - BUS_DMA_NOWAIT | BUS_DMA_ZERO, &sc->dc_lmap); - if (error) { - device_printf(dev, "failed to allocate DMA safe memory\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamap_load(sc->dc_ltag, sc->dc_lmap, sc->dc_ldata, - sizeof(struct dc_list_data), dc_dma_map_addr, &sc->dc_laddr, - BUS_DMA_NOWAIT); - if (error) { - device_printf(dev, "cannot get address of the descriptors\n"); - error = ENXIO; + if ((error = dc_dma_alloc(sc)) != 0) goto fail; - } - - /* - * Allocate a busdma tag and DMA safe memory for the multicast - * setup frame. - */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - DC_SFRAME_LEN + DC_MIN_FRAMELEN, 1, DC_SFRAME_LEN + DC_MIN_FRAMELEN, - 0, NULL, NULL, &sc->dc_stag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamem_alloc(sc->dc_stag, (void **)&sc->dc_cdata.dc_sbuf, - BUS_DMA_NOWAIT, &sc->dc_smap); - if (error) { - device_printf(dev, "failed to allocate DMA safe memory\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamap_load(sc->dc_stag, sc->dc_smap, sc->dc_cdata.dc_sbuf, - DC_SFRAME_LEN, dc_dma_map_addr, &sc->dc_saddr, BUS_DMA_NOWAIT); - if (error) { - device_printf(dev, "cannot get address of the descriptors\n"); - error = ENXIO; - goto fail; - } - - /* Allocate a busdma tag for mbufs. */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - MCLBYTES * DC_MAXFRAGS, DC_MAXFRAGS, MCLBYTES, - 0, NULL, NULL, &sc->dc_mtag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - - /* Create the TX/RX busdma maps. */ - for (i = 0; i < DC_TX_LIST_CNT; i++) { - error = bus_dmamap_create(sc->dc_mtag, 0, - &sc->dc_cdata.dc_tx_map[i]); - if (error) { - device_printf(dev, "failed to init TX ring\n"); - error = ENXIO; - goto fail; - } - } - for (i = 0; i < DC_RX_LIST_CNT; i++) { - error = bus_dmamap_create(sc->dc_mtag, 0, - &sc->dc_cdata.dc_rx_map[i]); - if (error) { - device_printf(dev, "failed to init RX ring\n"); - error = ENXIO; - goto fail; - } - } - error = bus_dmamap_create(sc->dc_mtag, 0, &sc->dc_sparemap); - if (error) { - device_printf(dev, "failed to init RX ring\n"); - error = ENXIO; - goto fail; - } ifp = sc->dc_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { @@ -2377,7 +2498,6 @@ dc_detach(device_t dev) struct dc_softc *sc; struct ifnet *ifp; struct dc_mediainfo *m; - int i; sc = device_get_softc(dev); KASSERT(mtx_initialized(&sc->dc_mtx), ("dc mutex not initialized")); @@ -2412,27 +2532,7 @@ dc_detach(device_t dev) if (ifp) if_free(ifp); - if (sc->dc_cdata.dc_sbuf != NULL) - bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, sc->dc_smap); - if (sc->dc_ldata != NULL) - bus_dmamem_free(sc->dc_ltag, sc->dc_ldata, sc->dc_lmap); - if (sc->dc_mtag) { - for (i = 0; i < DC_TX_LIST_CNT; i++) - if (sc->dc_cdata.dc_tx_map[i] != NULL) - bus_dmamap_destroy(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[i]); - for (i = 0; i < DC_RX_LIST_CNT; i++) - if (sc->dc_cdata.dc_rx_map[i] != NULL) - bus_dmamap_destroy(sc->dc_mtag, - sc->dc_cdata.dc_rx_map[i]); - bus_dmamap_destroy(sc->dc_mtag, sc->dc_sparemap); - } - if (sc->dc_stag) - bus_dma_tag_destroy(sc->dc_stag); - if (sc->dc_mtag) - bus_dma_tag_destroy(sc->dc_mtag); - if (sc->dc_ltag) - bus_dma_tag_destroy(sc->dc_ltag); + dc_dma_free(sc); free(sc->dc_pnic_rx_buf, M_DEVBUF); @@ -2459,7 +2559,7 @@ dc_list_tx_init(struct dc_softc *sc) int i, nexti; cd = &sc->dc_cdata; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; for (i = 0; i < DC_TX_LIST_CNT; i++) { if (i == DC_TX_LIST_CNT - 1) nexti = 0; @@ -2474,7 +2574,7 @@ dc_list_tx_init(struct dc_softc *sc) cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; cd->dc_tx_pkts = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2493,10 +2593,10 @@ dc_list_rx_init(struct dc_softc *sc) int i, nexti; cd = &sc->dc_cdata; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; for (i = 0; i < DC_RX_LIST_CNT; i++) { - if (dc_newbuf(sc, i, 1) != 0) + if (dc_newbuf(sc, i) != 0) return (ENOBUFS); if (i == DC_RX_LIST_CNT - 1) nexti = 0; @@ -2506,7 +2606,7 @@ dc_list_rx_init(struct dc_softc *sc) } cd->dc_rx_prod = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2515,23 +2615,18 @@ dc_list_rx_init(struct dc_softc *sc) * Initialize an RX descriptor and attach an MBUF cluster. */ static int -dc_newbuf(struct dc_softc *sc, int i, int alloc) +dc_newbuf(struct dc_softc *sc, int i) { - struct mbuf *m_new; - bus_dmamap_t tmp; + struct mbuf *m; + bus_dmamap_t map; bus_dma_segment_t segs[1]; int error, nseg; - if (alloc) { - m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (m_new == NULL) - return (ENOBUFS); - } else { - m_new = sc->dc_cdata.dc_rx_chain[i]; - m_new->m_data = m_new->m_ext.ext_buf; - } - m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; - m_adj(m_new, sizeof(u_int64_t)); + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m == NULL) + return (ENOBUFS); + m->m_len = m->m_pkthdr.len = MCLBYTES; + m_adj(m, sizeof(u_int64_t)); /* * If this is a PNIC chip, zero the buffer. This is part @@ -2539,31 +2634,31 @@ dc_newbuf(struct dc_softc *sc, int i, in * 82c169 chips. */ if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) - bzero(mtod(m_new, char *), m_new->m_len); + bzero(mtod(m, char *), m->m_len); - /* No need to remap the mbuf if we're reusing it. */ - if (alloc) { - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, sc->dc_sparemap, - m_new, segs, &nseg, 0); - if (error) { - m_freem(m_new); - return (error); - } - KASSERT(nseg == 1, - ("%s: wrong number of segments (%d)", __func__, nseg)); - sc->dc_ldata->dc_rx_list[i].dc_data = htole32(segs->ds_addr); - bus_dmamap_unload(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i]); - tmp = sc->dc_cdata.dc_rx_map[i]; - sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap; - sc->dc_sparemap = tmp; - sc->dc_cdata.dc_rx_chain[i] = m_new; + error = bus_dmamap_load_mbuf_sg(sc->dc_rx_mtag, sc->dc_sparemap, + m, segs, &nseg, 0); + if (error) { + m_freem(m); + return (error); } - - sc->dc_ldata->dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); - sc->dc_ldata->dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i], + KASSERT(nseg == 1, ("%s: wrong number of segments (%d)", __func__, + nseg)); + if (sc->dc_cdata.dc_rx_chain[i] != NULL) + bus_dmamap_unload(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i]); + + map = sc->dc_cdata.dc_rx_map[i]; + sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap; + sc->dc_sparemap = map; + sc->dc_cdata.dc_rx_chain[i] = m; + bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_PREREAD); - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + + sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); + sc->dc_ldata.dc_rx_list[i].dc_data = + htole32(DC_ADDR_LO(segs[0].ds_addr)); + sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2632,13 +2727,13 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, u_int32_t rxstat = 0; i = sc->dc_pnic_rx_bug_save; - cur_rx = &sc->dc_ldata->dc_rx_list[idx]; + cur_rx = &sc->dc_ldata.dc_rx_list[idx]; ptr = sc->dc_pnic_rx_buf; bzero(ptr, DC_RXLEN * 5); /* Copy all the bytes from the bogus buffers. */ while (1) { - c = &sc->dc_ldata->dc_rx_list[i]; + c = &sc->dc_ldata.dc_rx_list[i]; rxstat = le32toh(c->dc_status); m = sc->dc_cdata.dc_rx_chain[i]; bcopy(mtod(m, char *), ptr, DC_RXLEN); @@ -2646,7 +2741,7 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, /* If this is the last buffer, break out. */ if (i == idx || rxstat & DC_RXSTAT_LASTFRAG) break; - dc_newbuf(sc, i, 0); + dc_discard_rxbuf(sc, i); DC_INC(i, DC_RX_LIST_CNT); } @@ -2695,7 +2790,9 @@ dc_rx_resync(struct dc_softc *sc) pos = sc->dc_cdata.dc_rx_prod; for (i = 0; i < DC_RX_LIST_CNT; i++) { - cur_rx = &sc->dc_ldata->dc_rx_list[pos]; + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); + cur_rx = &sc->dc_ldata.dc_rx_list[pos]; if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) break; DC_INC(pos, DC_RX_LIST_CNT); @@ -2711,6 +2808,22 @@ dc_rx_resync(struct dc_softc *sc) return (EAGAIN); } +static void +dc_discard_rxbuf(struct dc_softc *sc, int i) +{ + struct mbuf *m; + + if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { + m = sc->dc_cdata.dc_rx_chain[i]; + bzero(mtod(m, char *), m->m_len); + } + + sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); + sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREREAD | + BUS_DMASYNC_PREWRITE); +} + /* * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. @@ -2718,7 +2831,7 @@ dc_rx_resync(struct dc_softc *sc) static int dc_rxeof(struct dc_softc *sc) { - struct mbuf *m, *m0; + struct mbuf *m; struct ifnet *ifp; struct dc_desc *cur_rx; int i, total_len, rx_npkts; @@ -2727,13 +2840,13 @@ dc_rxeof(struct dc_softc *sc) DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; - i = sc->dc_cdata.dc_rx_prod; - total_len = 0; rx_npkts = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD); - while (!(le32toh(sc->dc_ldata->dc_rx_list[i].dc_status) & - DC_RXSTAT_OWN)) { + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_POSTREAD | + BUS_DMASYNC_POSTWRITE); + for (i = sc->dc_cdata.dc_rx_prod; + (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; + DC_INC(i, DC_RX_LIST_CNT)) { #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { if (sc->rxcycles <= 0) @@ -2741,10 +2854,12 @@ dc_rxeof(struct dc_softc *sc) sc->rxcycles--; } #endif - cur_rx = &sc->dc_ldata->dc_rx_list[i]; + cur_rx = &sc->dc_ldata.dc_rx_list[i]; rxstat = le32toh(cur_rx->dc_status); + if ((rxstat & DC_RXSTAT_OWN) != 0) + break; m = sc->dc_cdata.dc_rx_chain[i]; - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i], + bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_POSTREAD); total_len = DC_RXBYTES(rxstat); @@ -2752,10 +2867,8 @@ dc_rxeof(struct dc_softc *sc) if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) { if (rxstat & DC_RXSTAT_FIRSTFRAG) sc->dc_pnic_rx_bug_save = i; - if ((rxstat & DC_RXSTAT_LASTFRAG) == 0) { - DC_INC(i, DC_RX_LIST_CNT); + if ((rxstat & DC_RXSTAT_LASTFRAG) == 0) continue; - } dc_pnic_rx_bug_war(sc, i); rxstat = le32toh(cur_rx->dc_status); total_len = DC_RXBYTES(rxstat); @@ -2777,11 +2890,10 @@ dc_rxeof(struct dc_softc *sc) ifp->if_ierrors++; if (rxstat & DC_RXSTAT_COLLSEEN) ifp->if_collisions++; - dc_newbuf(sc, i, 0); - if (rxstat & DC_RXSTAT_CRCERR) { - DC_INC(i, DC_RX_LIST_CNT); + dc_discard_rxbuf(sc, i); + if (rxstat & DC_RXSTAT_CRCERR) continue; - } else { + else { dc_init_locked(sc); return (rx_npkts); } @@ -2800,23 +2912,27 @@ dc_rxeof(struct dc_softc *sc) * if the allocation fails, then use m_devget and leave the * existing buffer in the receive ring. */ - if (dc_newbuf(sc, i, 1) == 0) { - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = m->m_len = total_len; - DC_INC(i, DC_RX_LIST_CNT); - } else -#endif + if (dc_newbuf(sc, i) != 0) { + dc_discard_rxbuf(sc, i); + ifp->if_iqdrops++; + continue; + } + m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.len = m->m_len = total_len; +#else { + struct mbuf *m0; + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, ifp, NULL); - dc_newbuf(sc, i, 0); - DC_INC(i, DC_RX_LIST_CNT); + dc_discard_rxbuf(sc, i); if (m0 == NULL) { - ifp->if_ierrors++; + ifp->if_iqdrops++; continue; } m = m0; } +#endif ifp->if_ipackets++; DC_UNLOCK(sc); @@ -2836,9 +2952,9 @@ dc_rxeof(struct dc_softc *sc) static void dc_txeof(struct dc_softc *sc) { - struct dc_desc *cur_tx = NULL; + struct dc_desc *cur_tx; struct ifnet *ifp; - int idx; + int idx, setup; u_int32_t ctl, txstat; if (sc->dc_cdata.dc_tx_cnt == 0) @@ -2850,36 +2966,40 @@ dc_txeof(struct dc_softc *sc) * Go through our tx list and free mbufs for those * frames that have been transmitted. */ - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD); - idx = sc->dc_cdata.dc_tx_cons; - while (idx != sc->dc_cdata.dc_tx_prod) { - - cur_tx = &sc->dc_ldata->dc_tx_list[idx]; + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_POSTREAD | + BUS_DMASYNC_POSTWRITE); + setup = 0; + for (idx = sc->dc_cdata.dc_tx_cons; idx != sc->dc_cdata.dc_tx_prod; + DC_INC(idx, DC_TX_LIST_CNT), sc->dc_cdata.dc_tx_cnt--) { + cur_tx = &sc->dc_ldata.dc_tx_list[idx]; txstat = le32toh(cur_tx->dc_status); ctl = le32toh(cur_tx->dc_ctl); if (txstat & DC_TXSTAT_OWN) break; - if (!(ctl & DC_TXCTL_LASTFRAG) || ctl & DC_TXCTL_SETUP) { - if (ctl & DC_TXCTL_SETUP) { - /* - * Yes, the PNIC is so brain damaged - * that it will sometimes generate a TX - * underrun error while DMAing the RX - * filter setup frame. If we detect this, - * we have to send the setup frame again, - * or else the filter won't be programmed - * correctly. - */ - if (DC_IS_PNIC(sc)) { - if (txstat & DC_TXSTAT_ERRSUM) - dc_setfilt(sc); - } - sc->dc_cdata.dc_tx_chain[idx] = NULL; + if (sc->dc_cdata.dc_tx_chain[idx] == NULL) + continue; + + if (ctl & DC_TXCTL_SETUP) { + cur_tx->dc_ctl = htole32(ctl & ~DC_TXCTL_SETUP); + setup++; + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, + BUS_DMASYNC_POSTWRITE); + /* + * Yes, the PNIC is so brain damaged + * that it will sometimes generate a TX + * underrun error while DMAing the RX + * filter setup frame. If we detect this, + * we have to send the setup frame again, + * or else the filter won't be programmed + * correctly. + */ + if (DC_IS_PNIC(sc)) { + if (txstat & DC_TXSTAT_ERRSUM) + dc_setfilt(sc); } - sc->dc_cdata.dc_tx_cnt--; - DC_INC(idx, DC_TX_LIST_CNT); + sc->dc_cdata.dc_tx_chain[idx] = NULL; continue; } @@ -2919,26 +3039,22 @@ dc_txeof(struct dc_softc *sc) ifp->if_opackets++; ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3; - if (sc->dc_cdata.dc_tx_chain[idx] != NULL) { - bus_dmamap_sync(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[idx], - BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[idx]); - m_freem(sc->dc_cdata.dc_tx_chain[idx]); - sc->dc_cdata.dc_tx_chain[idx] = NULL; - } - - sc->dc_cdata.dc_tx_cnt--; - DC_INC(idx, DC_TX_LIST_CNT); + bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], + BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); + m_freem(sc->dc_cdata.dc_tx_chain[idx]); + sc->dc_cdata.dc_tx_chain[idx] = NULL; } sc->dc_cdata.dc_tx_cons = idx; - if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_RSVD) + if (sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - - if (sc->dc_cdata.dc_tx_cnt == 0) - sc->dc_wdog_timer = 0; + if (sc->dc_cdata.dc_tx_cnt == 0) + sc->dc_wdog_timer = 0; + } + if (setup > 0) + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } static void @@ -3226,16 +3342,11 @@ static int dc_encap(struct dc_softc *sc, struct mbuf **m_head) { bus_dma_segment_t segs[DC_MAXFRAGS]; + bus_dmamap_t map; struct dc_desc *f; struct mbuf *m; int cur, defragged, error, first, frag, i, idx, nseg; - /* - * If there's no way we can send any packets, return now. - */ - if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_RSVD) - return (ENOBUFS); - m = NULL; defragged = 0; if (sc->dc_flags & DC_TX_COALESCE && @@ -3269,7 +3380,7 @@ dc_encap(struct dc_softc *sc, struct mbu } idx = sc->dc_cdata.dc_tx_prod; - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, + error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); if (error == EFBIG) { if (defragged != 0 || (m = m_collapse(*m_head, M_DONTWAIT, @@ -3279,7 +3390,7 @@ dc_encap(struct dc_softc *sc, struct mbu return (defragged != 0 ? error : ENOBUFS); } *m_head = m; - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, + error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); if (error != 0) { m_freem(*m_head); @@ -3296,26 +3407,34 @@ dc_encap(struct dc_softc *sc, struct mbu return (EIO); } + /* Check descriptor overruns. */ + if (sc->dc_cdata.dc_tx_cnt + nseg > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); + return (ENOBUFS); + } + bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], + BUS_DMASYNC_PREWRITE); + first = cur = frag = sc->dc_cdata.dc_tx_prod; for (i = 0; i < nseg; i++) { if ((sc->dc_flags & DC_TX_ADMTEK_WAR) && (frag == (DC_TX_LIST_CNT - 1)) && (first != sc->dc_cdata.dc_tx_first)) { - bus_dmamap_unload(sc->dc_mtag, + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[first]); m_freem(*m_head); *m_head = NULL; return (ENOBUFS); } - f = &sc->dc_ldata->dc_tx_list[frag]; + f = &sc->dc_ldata.dc_tx_list[frag]; f->dc_ctl = htole32(DC_TXCTL_TLINK | segs[i].ds_len); if (i == 0) { f->dc_status = 0; f->dc_ctl |= htole32(DC_TXCTL_FIRSTFRAG); } else f->dc_status = htole32(DC_TXSTAT_OWN); - f->dc_data = htole32(segs[i].ds_addr); + f->dc_data = htole32(DC_ADDR_LO(segs[i].ds_addr)); cur = frag; DC_INC(frag, DC_TX_LIST_CNT); } @@ -3323,23 +3442,30 @@ dc_encap(struct dc_softc *sc, struct mbu sc->dc_cdata.dc_tx_prod = frag; sc->dc_cdata.dc_tx_cnt += nseg; sc->dc_cdata.dc_tx_chain[cur] = *m_head; - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_LASTFRAG); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_LASTFRAG); if (sc->dc_flags & DC_TX_INTR_FIRSTFRAG) - sc->dc_ldata->dc_tx_list[first].dc_ctl |= + sc->dc_ldata.dc_tx_list[first].dc_ctl |= htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_INTR_ALWAYS) - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_USE_TX_INTR && ++sc->dc_cdata.dc_tx_pkts >= 8) { sc->dc_cdata.dc_tx_pkts = 0; - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); } - sc->dc_ldata->dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); + sc->dc_ldata.dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); + + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + + /* + * Swap the last and the first dmamaps to ensure the map for + * this transmission is placed at the last descriptor. + */ + map = sc->dc_cdata.dc_tx_map[cur]; + sc->dc_cdata.dc_tx_map[cur] = sc->dc_cdata.dc_tx_map[first]; + sc->dc_cdata.dc_tx_map[first] = map; - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], - BUS_DMASYNC_PREWRITE); - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -3365,9 +3491,8 @@ static void dc_start_locked(struct ifnet *ifp) { struct dc_softc *sc; - struct mbuf *m_head = NULL; - unsigned int queued = 0; - int idx; + struct mbuf *m_head; + int queued; sc = ifp->if_softc; @@ -3377,9 +3502,16 @@ dc_start_locked(struct ifnet *ifp) IFF_DRV_RUNNING || sc->dc_link == 0) return; - idx = sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; + sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; - while (sc->dc_cdata.dc_tx_chain[idx] == NULL) { + for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) { + /* + * If there's no way we can send any packets, return now. + */ + if (sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + break; + } IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -3391,7 +3523,6 @@ dc_start_locked(struct ifnet *ifp) ifp->if_drv_flags |= IFF_DRV_OACTIVE; break; } - idx = sc->dc_cdata.dc_tx_prod; queued++; /* @@ -3778,7 +3909,7 @@ dc_stop(struct dc_softc *sc) DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; cd = &sc->dc_cdata; callout_stop(&sc->dc_stat_ch); @@ -3798,11 +3929,17 @@ dc_stop(struct dc_softc *sc) */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 22:50:10 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 437801065674; Sun, 27 Mar 2011 22:50:10 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2FA528FC1B; Sun, 27 Mar 2011 22:50:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RMoASR071776; Sun, 27 Mar 2011 22:50:10 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RMoAgH071773; Sun, 27 Mar 2011 22:50:10 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272250.p2RMoAgH071773@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 22:50:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220073 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 22:50:10 -0000 Author: yongari Date: Sun Mar 27 22:50:09 2011 New Revision: 220073 URL: http://svn.freebsd.org/changeset/base/220073 Log: MFC r218832: Split common TX/RX descriptor DMA tag to TX and RX DMA tags respectively and fix all bus_dma(9) issues seen when bounce buffers are used. o Setup frame handling had no bus_dmamap_sync(9) which prevented driver from configuring RX filter. Add missing bus_dmamap_sync(9) in both dc_setfilt_21143()/dc_setfilt_xircom() and dc_txeof(). o Use bus_addr_t for DMA segment instead of using u_int32_t. o Introduce dc_dma_alloc()/dc_dma_free() functions to allocate/free DMA'able memory. o Create two DMA descriptor list for each TX/RX lists. This change will minimize the size of bounce buffers that would be used in each TX/RX path. Previously driver had to copy both TX/RX lists when bounce buffer is active. o 21143 data sheet says descriptor list requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Setup frame requires 4 bytes alignment. Remove PAGE_SIZE alignment restriction and use sizeof(struct dc_dec). o Add missing DMA map unload for both setup frame and TX/RX descriptor list. o Overhaul RX handling logic such that make driver always allocate new RX buffer with dc_newbuf(). Previously driver allowed to copy received frame with m_devget(9) after passing the descriptor ownership to controller. This can lead to passing wrong frame to upper stack. o Introduce dc_discard_rxbuf() which will discard received frame and reuse loaded DMA map and RX mbuf. o Correct several wrong bus_dmamap_sync(9) usage in dc_rxeof and dc_txeof. The TX/RX descriptor lists are updated by both driver and HW so READ/WRITE semantics should be used. o If driver failed to allocate new RX buffer, update if_iqdrops counter instead of if_ierrors since driver received the frame without errors. o Make sure to unload loaded setup frame DMA map in dc_txeof and clear the mark of setup frame of the TX descriptor in dc_txeof(). o Add check for possible TX descriptor overruns in dc_encap() and move check for free buffer to caller, dc_start_locked(). o Swap the loaded DMA map and the last DMA map for multi-segmented frames. Since dc_txeof() assumes the last descriptor of the frame has the DMA map, driver should swap the first and the last DMA map in dc_encap(). Previously driver tried to unload not-yet-loaded DMA map such that the loaded DMA map was not unloaded at all for multi-segmented frames. o Rewrite DC_RXDESC/DC_TXDESC macro to simpler one. o Remove definition of ETHER_ALIGN, it's already defined in ethernet.h. With this changes, dc(4) works with bounce buffers and it shall also fix issues which might have shown in PAE environments. Tested by: marius Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:48:58 2011 (r220072) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 22:50:09 2011 (r220073) @@ -233,7 +233,8 @@ static int dc_detach(device_t); static int dc_suspend(device_t); static int dc_resume(device_t); static const struct dc_type *dc_devtype(device_t); -static int dc_newbuf(struct dc_softc *, int, int); +static void dc_discard_rxbuf(struct dc_softc *, int); +static int dc_newbuf(struct dc_softc *, int); static int dc_encap(struct dc_softc *, struct mbuf **); static void dc_pnic_rx_bug_war(struct dc_softc *, int); static int dc_rx_resync(struct dc_softc *); @@ -253,6 +254,10 @@ static int dc_shutdown(device_t); static int dc_ifmedia_upd(struct ifnet *); static void dc_ifmedia_sts(struct ifnet *, struct ifmediareq *); +static int dc_dma_alloc(struct dc_softc *); +static void dc_dma_free(struct dc_softc *); +static void dc_dma_map_addr(void *, bus_dma_segment_t *, int, int); + static void dc_delay(struct dc_softc *); static void dc_eeprom_idle(struct dc_softc *); static void dc_eeprom_putbyte(struct dc_softc *, int); @@ -1088,11 +1093,11 @@ dc_setfilt_21143(struct dc_softc *sc) i = sc->dc_cdata.dc_tx_prod; DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); sc->dc_cdata.dc_tx_cnt++; - sframe = &sc->dc_ldata->dc_tx_list[i]; + sframe = &sc->dc_ldata.dc_tx_list[i]; sp = sc->dc_cdata.dc_sbuf; bzero(sp, DC_SFRAME_LEN); - sframe->dc_data = htole32(sc->dc_saddr); + sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | DC_TXCTL_TLINK | DC_FILTER_HASHPERF | DC_TXCTL_FINT); @@ -1131,6 +1136,7 @@ dc_setfilt_21143(struct dc_softc *sc) sp[41] = DC_SP_MAC(eaddr[2]); sframe->dc_status = htole32(DC_TXSTAT_OWN); + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); /* @@ -1291,11 +1297,11 @@ dc_setfilt_xircom(struct dc_softc *sc) i = sc->dc_cdata.dc_tx_prod; DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT); sc->dc_cdata.dc_tx_cnt++; - sframe = &sc->dc_ldata->dc_tx_list[i]; + sframe = &sc->dc_ldata.dc_tx_list[i]; sp = sc->dc_cdata.dc_sbuf; bzero(sp, DC_SFRAME_LEN); - sframe->dc_data = htole32(sc->dc_saddr); + sframe->dc_data = htole32(DC_ADDR_LO(sc->dc_saddr)); sframe->dc_ctl = htole32(DC_SFRAME_LEN | DC_TXCTL_SETUP | DC_TXCTL_TLINK | DC_FILTER_HASHPERF | DC_TXCTL_FINT); @@ -1336,6 +1342,7 @@ dc_setfilt_xircom(struct dc_softc *sc) DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON); sframe->dc_status = htole32(DC_TXSTAT_OWN); + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, BUS_DMASYNC_PREWRITE); CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF); /* @@ -1807,7 +1814,7 @@ dc_parse_21143_srom(struct dc_softc *sc) static void dc_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error) { - u_int32_t *paddr; + bus_addr_t *paddr; KASSERT(nseg == 1, ("%s: wrong number of segments (%d)", __func__, nseg)); @@ -1815,6 +1822,208 @@ dc_dma_map_addr(void *arg, bus_dma_segme *paddr = segs->ds_addr; } +static int +dc_dma_alloc(struct dc_softc *sc) +{ + int error, i; + + error = bus_dma_tag_create(bus_get_dma_tag(sc->dc_dev), 1, 0, + BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, + BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT, 0, + NULL, NULL, &sc->dc_ptag); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate parent DMA tag\n"); + goto fail; + } + + /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, DC_RX_LIST_SZ, 1, + DC_RX_LIST_SZ, 0, NULL, NULL, &sc->dc_rx_ltag); + if (error) { + device_printf(sc->dc_dev, "failed to create RX list DMA tag\n"); + goto fail; + } + + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, DC_TX_LIST_SZ, 1, + DC_TX_LIST_SZ, 0, NULL, NULL, &sc->dc_tx_ltag); + if (error) { + device_printf(sc->dc_dev, "failed to create TX list DMA tag\n"); + goto fail; + } + + /* RX descriptor list. */ + error = bus_dmamem_alloc(sc->dc_rx_ltag, + (void **)&sc->dc_ldata.dc_rx_list, BUS_DMA_NOWAIT | + BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_rx_lmap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for RX list\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_rx_ltag, sc->dc_rx_lmap, + sc->dc_ldata.dc_rx_list, DC_RX_LIST_SZ, dc_dma_map_addr, + &sc->dc_ldata.dc_rx_list_paddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "failed to load DMA'able memory for RX list\n"); + goto fail; + } + /* TX descriptor list. */ + error = bus_dmamem_alloc(sc->dc_tx_ltag, + (void **)&sc->dc_ldata.dc_tx_list, BUS_DMA_NOWAIT | + BUS_DMA_ZERO | BUS_DMA_COHERENT, &sc->dc_tx_lmap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for TX list\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_tx_ltag, sc->dc_tx_lmap, + sc->dc_ldata.dc_tx_list, DC_TX_LIST_SZ, dc_dma_map_addr, + &sc->dc_ldata.dc_tx_list_paddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "cannot load DMA'able memory for TX list\n"); + goto fail; + } + + /* + * Allocate a busdma tag and DMA safe memory for the multicast + * setup frame. + */ + error = bus_dma_tag_create(sc->dc_ptag, DC_LIST_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + DC_SFRAME_LEN + DC_MIN_FRAMELEN, 1, DC_SFRAME_LEN + DC_MIN_FRAMELEN, + 0, NULL, NULL, &sc->dc_stag); + if (error) { + device_printf(sc->dc_dev, + "failed to create DMA tag for setup frame\n"); + goto fail; + } + error = bus_dmamem_alloc(sc->dc_stag, (void **)&sc->dc_cdata.dc_sbuf, + BUS_DMA_NOWAIT, &sc->dc_smap); + if (error) { + device_printf(sc->dc_dev, + "failed to allocate DMA'able memory for setup frame\n"); + goto fail; + } + error = bus_dmamap_load(sc->dc_stag, sc->dc_smap, sc->dc_cdata.dc_sbuf, + DC_SFRAME_LEN, dc_dma_map_addr, &sc->dc_saddr, BUS_DMA_NOWAIT); + if (error) { + device_printf(sc->dc_dev, + "cannot load DMA'able memory for setup frame\n"); + goto fail; + } + + /* Allocate a busdma tag for RX mbufs. */ + error = bus_dma_tag_create(sc->dc_ptag, DC_RXBUF_ALIGN, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES, 1, MCLBYTES, 0, NULL, NULL, &sc->dc_rx_mtag); + if (error) { + device_printf(sc->dc_dev, "failed to create RX mbuf tag\n"); + goto fail; + } + + /* Allocate a busdma tag for TX mbufs. */ + error = bus_dma_tag_create(sc->dc_ptag, 1, 0, + BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, + MCLBYTES * DC_MAXFRAGS, DC_MAXFRAGS, MCLBYTES, + 0, NULL, NULL, &sc->dc_tx_mtag); + if (error) { + device_printf(sc->dc_dev, "failed to create TX mbuf tag\n"); + goto fail; + } + + /* Create the TX/RX busdma maps. */ + for (i = 0; i < DC_TX_LIST_CNT; i++) { + error = bus_dmamap_create(sc->dc_tx_mtag, 0, + &sc->dc_cdata.dc_tx_map[i]); + if (error) { + device_printf(sc->dc_dev, + "failed to create TX mbuf dmamap\n"); + goto fail; + } + } + for (i = 0; i < DC_RX_LIST_CNT; i++) { + error = bus_dmamap_create(sc->dc_rx_mtag, 0, + &sc->dc_cdata.dc_rx_map[i]); + if (error) { + device_printf(sc->dc_dev, + "failed to create RX mbuf dmamap\n"); + goto fail; + } + } + error = bus_dmamap_create(sc->dc_rx_mtag, 0, &sc->dc_sparemap); + if (error) { + device_printf(sc->dc_dev, + "failed to create spare RX mbuf dmamap\n"); + goto fail; + } + +fail: + return (error); +} + +static void +dc_dma_free(struct dc_softc *sc) +{ + int i; + + /* RX buffers. */ + if (sc->dc_rx_mtag != NULL) { + for (i = 0; i < DC_RX_LIST_CNT; i++) { + if (sc->dc_cdata.dc_rx_map[i] != NULL) + bus_dmamap_destroy(sc->dc_rx_mtag, + sc->dc_cdata.dc_rx_map[i]); + } + if (sc->dc_sparemap != NULL) + bus_dmamap_destroy(sc->dc_rx_mtag, sc->dc_sparemap); + bus_dma_tag_destroy(sc->dc_rx_mtag); + } + + /* TX buffers. */ + if (sc->dc_rx_mtag != NULL) { + for (i = 0; i < DC_TX_LIST_CNT; i++) { + if (sc->dc_cdata.dc_tx_map[i] != NULL) + bus_dmamap_destroy(sc->dc_tx_mtag, + sc->dc_cdata.dc_tx_map[i]); + } + bus_dma_tag_destroy(sc->dc_tx_mtag); + } + + /* RX descriptor list. */ + if (sc->dc_rx_ltag) { + if (sc->dc_rx_lmap != NULL) + bus_dmamap_unload(sc->dc_rx_ltag, sc->dc_rx_lmap); + if (sc->dc_rx_lmap != NULL && sc->dc_ldata.dc_rx_list != NULL) + bus_dmamem_free(sc->dc_rx_ltag, sc->dc_ldata.dc_rx_list, + sc->dc_rx_lmap); + bus_dma_tag_destroy(sc->dc_rx_ltag); + } + + /* TX descriptor list. */ + if (sc->dc_tx_ltag) { + if (sc->dc_tx_lmap != NULL) + bus_dmamap_unload(sc->dc_tx_ltag, sc->dc_tx_lmap); + if (sc->dc_tx_lmap != NULL && sc->dc_ldata.dc_tx_list != NULL) + bus_dmamem_free(sc->dc_tx_ltag, sc->dc_ldata.dc_tx_list, + sc->dc_tx_lmap); + bus_dma_tag_destroy(sc->dc_tx_ltag); + } + + /* multicast setup frame. */ + if (sc->dc_stag) { + if (sc->dc_smap != NULL) + bus_dmamap_unload(sc->dc_stag, sc->dc_smap); + if (sc->dc_smap != NULL && sc->dc_cdata.dc_sbuf != NULL) + bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, + sc->dc_smap); + bus_dma_tag_destroy(sc->dc_stag); + } +} + /* * Attach the interface. Allocate softc structures, do ifmedia * setup and ethernet/BPF attach. @@ -1828,7 +2037,7 @@ dc_attach(device_t dev) struct ifnet *ifp; struct dc_mediainfo *m; u_int32_t reg, revision; - int error, i, mac_offset, phy, rid, tmp; + int error, mac_offset, phy, rid, tmp; u_int8_t *mac; sc = device_get_softc(dev); @@ -2140,96 +2349,8 @@ dc_attach(device_t dev) error = 0; } - /* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - sizeof(struct dc_list_data), 1, sizeof(struct dc_list_data), - 0, NULL, NULL, &sc->dc_ltag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamem_alloc(sc->dc_ltag, (void **)&sc->dc_ldata, - BUS_DMA_NOWAIT | BUS_DMA_ZERO, &sc->dc_lmap); - if (error) { - device_printf(dev, "failed to allocate DMA safe memory\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamap_load(sc->dc_ltag, sc->dc_lmap, sc->dc_ldata, - sizeof(struct dc_list_data), dc_dma_map_addr, &sc->dc_laddr, - BUS_DMA_NOWAIT); - if (error) { - device_printf(dev, "cannot get address of the descriptors\n"); - error = ENXIO; - goto fail; - } - - /* - * Allocate a busdma tag and DMA safe memory for the multicast - * setup frame. - */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), PAGE_SIZE, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - DC_SFRAME_LEN + DC_MIN_FRAMELEN, 1, DC_SFRAME_LEN + DC_MIN_FRAMELEN, - 0, NULL, NULL, &sc->dc_stag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamem_alloc(sc->dc_stag, (void **)&sc->dc_cdata.dc_sbuf, - BUS_DMA_NOWAIT, &sc->dc_smap); - if (error) { - device_printf(dev, "failed to allocate DMA safe memory\n"); - error = ENXIO; - goto fail; - } - error = bus_dmamap_load(sc->dc_stag, sc->dc_smap, sc->dc_cdata.dc_sbuf, - DC_SFRAME_LEN, dc_dma_map_addr, &sc->dc_saddr, BUS_DMA_NOWAIT); - if (error) { - device_printf(dev, "cannot get address of the descriptors\n"); - error = ENXIO; - goto fail; - } - - /* Allocate a busdma tag for mbufs. */ - error = bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0, - BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, - MCLBYTES * DC_MAXFRAGS, DC_MAXFRAGS, MCLBYTES, - 0, NULL, NULL, &sc->dc_mtag); - if (error) { - device_printf(dev, "failed to allocate busdma tag\n"); - error = ENXIO; + if ((error = dc_dma_alloc(sc)) != 0) goto fail; - } - - /* Create the TX/RX busdma maps. */ - for (i = 0; i < DC_TX_LIST_CNT; i++) { - error = bus_dmamap_create(sc->dc_mtag, 0, - &sc->dc_cdata.dc_tx_map[i]); - if (error) { - device_printf(dev, "failed to init TX ring\n"); - error = ENXIO; - goto fail; - } - } - for (i = 0; i < DC_RX_LIST_CNT; i++) { - error = bus_dmamap_create(sc->dc_mtag, 0, - &sc->dc_cdata.dc_rx_map[i]); - if (error) { - device_printf(dev, "failed to init RX ring\n"); - error = ENXIO; - goto fail; - } - } - error = bus_dmamap_create(sc->dc_mtag, 0, &sc->dc_sparemap); - if (error) { - device_printf(dev, "failed to init RX ring\n"); - error = ENXIO; - goto fail; - } ifp = sc->dc_ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { @@ -2378,7 +2499,6 @@ dc_detach(device_t dev) struct dc_softc *sc; struct ifnet *ifp; struct dc_mediainfo *m; - int i; sc = device_get_softc(dev); KASSERT(mtx_initialized(&sc->dc_mtx), ("dc mutex not initialized")); @@ -2413,27 +2533,7 @@ dc_detach(device_t dev) if (ifp) if_free(ifp); - if (sc->dc_cdata.dc_sbuf != NULL) - bus_dmamem_free(sc->dc_stag, sc->dc_cdata.dc_sbuf, sc->dc_smap); - if (sc->dc_ldata != NULL) - bus_dmamem_free(sc->dc_ltag, sc->dc_ldata, sc->dc_lmap); - if (sc->dc_mtag) { - for (i = 0; i < DC_TX_LIST_CNT; i++) - if (sc->dc_cdata.dc_tx_map[i] != NULL) - bus_dmamap_destroy(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[i]); - for (i = 0; i < DC_RX_LIST_CNT; i++) - if (sc->dc_cdata.dc_rx_map[i] != NULL) - bus_dmamap_destroy(sc->dc_mtag, - sc->dc_cdata.dc_rx_map[i]); - bus_dmamap_destroy(sc->dc_mtag, sc->dc_sparemap); - } - if (sc->dc_stag) - bus_dma_tag_destroy(sc->dc_stag); - if (sc->dc_mtag) - bus_dma_tag_destroy(sc->dc_mtag); - if (sc->dc_ltag) - bus_dma_tag_destroy(sc->dc_ltag); + dc_dma_free(sc); free(sc->dc_pnic_rx_buf, M_DEVBUF); @@ -2460,7 +2560,7 @@ dc_list_tx_init(struct dc_softc *sc) int i, nexti; cd = &sc->dc_cdata; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; for (i = 0; i < DC_TX_LIST_CNT; i++) { if (i == DC_TX_LIST_CNT - 1) nexti = 0; @@ -2475,7 +2575,7 @@ dc_list_tx_init(struct dc_softc *sc) cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; cd->dc_tx_pkts = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2494,10 +2594,10 @@ dc_list_rx_init(struct dc_softc *sc) int i, nexti; cd = &sc->dc_cdata; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; for (i = 0; i < DC_RX_LIST_CNT; i++) { - if (dc_newbuf(sc, i, 1) != 0) + if (dc_newbuf(sc, i) != 0) return (ENOBUFS); if (i == DC_RX_LIST_CNT - 1) nexti = 0; @@ -2507,7 +2607,7 @@ dc_list_rx_init(struct dc_softc *sc) } cd->dc_rx_prod = 0; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2516,23 +2616,18 @@ dc_list_rx_init(struct dc_softc *sc) * Initialize an RX descriptor and attach an MBUF cluster. */ static int -dc_newbuf(struct dc_softc *sc, int i, int alloc) +dc_newbuf(struct dc_softc *sc, int i) { - struct mbuf *m_new; - bus_dmamap_t tmp; + struct mbuf *m; + bus_dmamap_t map; bus_dma_segment_t segs[1]; int error, nseg; - if (alloc) { - m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (m_new == NULL) - return (ENOBUFS); - } else { - m_new = sc->dc_cdata.dc_rx_chain[i]; - m_new->m_data = m_new->m_ext.ext_buf; - } - m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; - m_adj(m_new, sizeof(u_int64_t)); + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m == NULL) + return (ENOBUFS); + m->m_len = m->m_pkthdr.len = MCLBYTES; + m_adj(m, sizeof(u_int64_t)); /* * If this is a PNIC chip, zero the buffer. This is part @@ -2540,31 +2635,31 @@ dc_newbuf(struct dc_softc *sc, int i, in * 82c169 chips. */ if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) - bzero(mtod(m_new, char *), m_new->m_len); + bzero(mtod(m, char *), m->m_len); - /* No need to remap the mbuf if we're reusing it. */ - if (alloc) { - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, sc->dc_sparemap, - m_new, segs, &nseg, 0); - if (error) { - m_freem(m_new); - return (error); - } - KASSERT(nseg == 1, - ("%s: wrong number of segments (%d)", __func__, nseg)); - sc->dc_ldata->dc_rx_list[i].dc_data = htole32(segs->ds_addr); - bus_dmamap_unload(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i]); - tmp = sc->dc_cdata.dc_rx_map[i]; - sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap; - sc->dc_sparemap = tmp; - sc->dc_cdata.dc_rx_chain[i] = m_new; + error = bus_dmamap_load_mbuf_sg(sc->dc_rx_mtag, sc->dc_sparemap, + m, segs, &nseg, 0); + if (error) { + m_freem(m); + return (error); } - - sc->dc_ldata->dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); - sc->dc_ldata->dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i], + KASSERT(nseg == 1, ("%s: wrong number of segments (%d)", __func__, + nseg)); + if (sc->dc_cdata.dc_rx_chain[i] != NULL) + bus_dmamap_unload(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i]); + + map = sc->dc_cdata.dc_rx_map[i]; + sc->dc_cdata.dc_rx_map[i] = sc->dc_sparemap; + sc->dc_sparemap = map; + sc->dc_cdata.dc_rx_chain[i] = m; + bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_PREREAD); - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, + + sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); + sc->dc_ldata.dc_rx_list[i].dc_data = + htole32(DC_ADDR_LO(segs[0].ds_addr)); + sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -2633,13 +2728,13 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, u_int32_t rxstat = 0; i = sc->dc_pnic_rx_bug_save; - cur_rx = &sc->dc_ldata->dc_rx_list[idx]; + cur_rx = &sc->dc_ldata.dc_rx_list[idx]; ptr = sc->dc_pnic_rx_buf; bzero(ptr, DC_RXLEN * 5); /* Copy all the bytes from the bogus buffers. */ while (1) { - c = &sc->dc_ldata->dc_rx_list[i]; + c = &sc->dc_ldata.dc_rx_list[i]; rxstat = le32toh(c->dc_status); m = sc->dc_cdata.dc_rx_chain[i]; bcopy(mtod(m, char *), ptr, DC_RXLEN); @@ -2647,7 +2742,7 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, /* If this is the last buffer, break out. */ if (i == idx || rxstat & DC_RXSTAT_LASTFRAG) break; - dc_newbuf(sc, i, 0); + dc_discard_rxbuf(sc, i); DC_INC(i, DC_RX_LIST_CNT); } @@ -2696,7 +2791,9 @@ dc_rx_resync(struct dc_softc *sc) pos = sc->dc_cdata.dc_rx_prod; for (i = 0; i < DC_RX_LIST_CNT; i++) { - cur_rx = &sc->dc_ldata->dc_rx_list[pos]; + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, + BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); + cur_rx = &sc->dc_ldata.dc_rx_list[pos]; if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) break; DC_INC(pos, DC_RX_LIST_CNT); @@ -2712,6 +2809,22 @@ dc_rx_resync(struct dc_softc *sc) return (EAGAIN); } +static void +dc_discard_rxbuf(struct dc_softc *sc, int i) +{ + struct mbuf *m; + + if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { + m = sc->dc_cdata.dc_rx_chain[i]; + bzero(mtod(m, char *), m->m_len); + } + + sc->dc_ldata.dc_rx_list[i].dc_ctl = htole32(DC_RXCTL_RLINK | DC_RXLEN); + sc->dc_ldata.dc_rx_list[i].dc_status = htole32(DC_RXSTAT_OWN); + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_PREREAD | + BUS_DMASYNC_PREWRITE); +} + /* * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. @@ -2719,20 +2832,21 @@ dc_rx_resync(struct dc_softc *sc) static void dc_rxeof(struct dc_softc *sc) { - struct mbuf *m, *m0; + struct mbuf *m; struct ifnet *ifp; struct dc_desc *cur_rx; - int i, total_len = 0; + int i, total_len; u_int32_t rxstat; DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; - i = sc->dc_cdata.dc_rx_prod; - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD); - while (!(le32toh(sc->dc_ldata->dc_rx_list[i].dc_status) & - DC_RXSTAT_OWN)) { + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_POSTREAD | + BUS_DMASYNC_POSTWRITE); + for (i = sc->dc_cdata.dc_rx_prod; + (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0; + DC_INC(i, DC_RX_LIST_CNT)) { #ifdef DEVICE_POLLING if (ifp->if_capenable & IFCAP_POLLING) { if (sc->rxcycles <= 0) @@ -2740,10 +2854,12 @@ dc_rxeof(struct dc_softc *sc) sc->rxcycles--; } #endif - cur_rx = &sc->dc_ldata->dc_rx_list[i]; + cur_rx = &sc->dc_ldata.dc_rx_list[i]; rxstat = le32toh(cur_rx->dc_status); + if ((rxstat & DC_RXSTAT_OWN) != 0) + break; m = sc->dc_cdata.dc_rx_chain[i]; - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_rx_map[i], + bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_POSTREAD); total_len = DC_RXBYTES(rxstat); @@ -2751,10 +2867,8 @@ dc_rxeof(struct dc_softc *sc) if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) { if (rxstat & DC_RXSTAT_FIRSTFRAG) sc->dc_pnic_rx_bug_save = i; - if ((rxstat & DC_RXSTAT_LASTFRAG) == 0) { - DC_INC(i, DC_RX_LIST_CNT); + if ((rxstat & DC_RXSTAT_LASTFRAG) == 0) continue; - } dc_pnic_rx_bug_war(sc, i); rxstat = le32toh(cur_rx->dc_status); total_len = DC_RXBYTES(rxstat); @@ -2776,11 +2890,10 @@ dc_rxeof(struct dc_softc *sc) ifp->if_ierrors++; if (rxstat & DC_RXSTAT_COLLSEEN) ifp->if_collisions++; - dc_newbuf(sc, i, 0); - if (rxstat & DC_RXSTAT_CRCERR) { - DC_INC(i, DC_RX_LIST_CNT); + dc_discard_rxbuf(sc, i); + if (rxstat & DC_RXSTAT_CRCERR) continue; - } else { + else { dc_init_locked(sc); return; } @@ -2799,23 +2912,27 @@ dc_rxeof(struct dc_softc *sc) * if the allocation fails, then use m_devget and leave the * existing buffer in the receive ring. */ - if (dc_newbuf(sc, i, 1) == 0) { - m->m_pkthdr.rcvif = ifp; - m->m_pkthdr.len = m->m_len = total_len; - DC_INC(i, DC_RX_LIST_CNT); - } else -#endif + if (dc_newbuf(sc, i) != 0) { + dc_discard_rxbuf(sc, i); + ifp->if_iqdrops++; + continue; + } + m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.len = m->m_len = total_len; +#else { + struct mbuf *m0; + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, ifp, NULL); - dc_newbuf(sc, i, 0); - DC_INC(i, DC_RX_LIST_CNT); + dc_discard_rxbuf(sc, i); if (m0 == NULL) { - ifp->if_ierrors++; + ifp->if_iqdrops++; continue; } m = m0; } +#endif ifp->if_ipackets++; DC_UNLOCK(sc); @@ -2833,9 +2950,9 @@ dc_rxeof(struct dc_softc *sc) static void dc_txeof(struct dc_softc *sc) { - struct dc_desc *cur_tx = NULL; + struct dc_desc *cur_tx; struct ifnet *ifp; - int idx; + int idx, setup; u_int32_t ctl, txstat; if (sc->dc_cdata.dc_tx_cnt == 0) @@ -2847,36 +2964,40 @@ dc_txeof(struct dc_softc *sc) * Go through our tx list and free mbufs for those * frames that have been transmitted. */ - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, BUS_DMASYNC_POSTREAD); - idx = sc->dc_cdata.dc_tx_cons; - while (idx != sc->dc_cdata.dc_tx_prod) { - - cur_tx = &sc->dc_ldata->dc_tx_list[idx]; + bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_tx_lmap, BUS_DMASYNC_POSTREAD | + BUS_DMASYNC_POSTWRITE); + setup = 0; + for (idx = sc->dc_cdata.dc_tx_cons; idx != sc->dc_cdata.dc_tx_prod; + DC_INC(idx, DC_TX_LIST_CNT), sc->dc_cdata.dc_tx_cnt--) { + cur_tx = &sc->dc_ldata.dc_tx_list[idx]; txstat = le32toh(cur_tx->dc_status); ctl = le32toh(cur_tx->dc_ctl); if (txstat & DC_TXSTAT_OWN) break; - if (!(ctl & DC_TXCTL_LASTFRAG) || ctl & DC_TXCTL_SETUP) { - if (ctl & DC_TXCTL_SETUP) { - /* - * Yes, the PNIC is so brain damaged - * that it will sometimes generate a TX - * underrun error while DMAing the RX - * filter setup frame. If we detect this, - * we have to send the setup frame again, - * or else the filter won't be programmed - * correctly. - */ - if (DC_IS_PNIC(sc)) { - if (txstat & DC_TXSTAT_ERRSUM) - dc_setfilt(sc); - } - sc->dc_cdata.dc_tx_chain[idx] = NULL; + if (sc->dc_cdata.dc_tx_chain[idx] == NULL) + continue; + + if (ctl & DC_TXCTL_SETUP) { + cur_tx->dc_ctl = htole32(ctl & ~DC_TXCTL_SETUP); + setup++; + bus_dmamap_sync(sc->dc_stag, sc->dc_smap, + BUS_DMASYNC_POSTWRITE); + /* + * Yes, the PNIC is so brain damaged + * that it will sometimes generate a TX + * underrun error while DMAing the RX + * filter setup frame. If we detect this, + * we have to send the setup frame again, + * or else the filter won't be programmed + * correctly. + */ + if (DC_IS_PNIC(sc)) { + if (txstat & DC_TXSTAT_ERRSUM) + dc_setfilt(sc); } - sc->dc_cdata.dc_tx_cnt--; - DC_INC(idx, DC_TX_LIST_CNT); + sc->dc_cdata.dc_tx_chain[idx] = NULL; continue; } @@ -2916,26 +3037,22 @@ dc_txeof(struct dc_softc *sc) ifp->if_opackets++; ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3; - if (sc->dc_cdata.dc_tx_chain[idx] != NULL) { - bus_dmamap_sync(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[idx], - BUS_DMASYNC_POSTWRITE); - bus_dmamap_unload(sc->dc_mtag, - sc->dc_cdata.dc_tx_map[idx]); - m_freem(sc->dc_cdata.dc_tx_chain[idx]); - sc->dc_cdata.dc_tx_chain[idx] = NULL; - } - - sc->dc_cdata.dc_tx_cnt--; - DC_INC(idx, DC_TX_LIST_CNT); + bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], + BUS_DMASYNC_POSTWRITE); + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); + m_freem(sc->dc_cdata.dc_tx_chain[idx]); + sc->dc_cdata.dc_tx_chain[idx] = NULL; } sc->dc_cdata.dc_tx_cons = idx; - if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_RSVD) + if (sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - - if (sc->dc_cdata.dc_tx_cnt == 0) - sc->dc_wdog_timer = 0; + if (sc->dc_cdata.dc_tx_cnt == 0) + sc->dc_wdog_timer = 0; + } + if (setup > 0) + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); } static void @@ -3221,16 +3338,11 @@ static int dc_encap(struct dc_softc *sc, struct mbuf **m_head) { bus_dma_segment_t segs[DC_MAXFRAGS]; + bus_dmamap_t map; struct dc_desc *f; struct mbuf *m; int cur, defragged, error, first, frag, i, idx, nseg; - /* - * If there's no way we can send any packets, return now. - */ - if (DC_TX_LIST_CNT - sc->dc_cdata.dc_tx_cnt <= DC_TX_LIST_RSVD) - return (ENOBUFS); - m = NULL; defragged = 0; if (sc->dc_flags & DC_TX_COALESCE && @@ -3264,7 +3376,7 @@ dc_encap(struct dc_softc *sc, struct mbu } idx = sc->dc_cdata.dc_tx_prod; - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, + error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); if (error == EFBIG) { if (defragged != 0 || (m = m_collapse(*m_head, M_DONTWAIT, @@ -3274,7 +3386,7 @@ dc_encap(struct dc_softc *sc, struct mbu return (defragged != 0 ? error : ENOBUFS); } *m_head = m; - error = bus_dmamap_load_mbuf_sg(sc->dc_mtag, + error = bus_dmamap_load_mbuf_sg(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], *m_head, segs, &nseg, 0); if (error != 0) { m_freem(*m_head); @@ -3291,26 +3403,34 @@ dc_encap(struct dc_softc *sc, struct mbu return (EIO); } + /* Check descriptor overruns. */ + if (sc->dc_cdata.dc_tx_cnt + nseg > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx]); + return (ENOBUFS); + } + bus_dmamap_sync(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[idx], + BUS_DMASYNC_PREWRITE); + first = cur = frag = sc->dc_cdata.dc_tx_prod; for (i = 0; i < nseg; i++) { if ((sc->dc_flags & DC_TX_ADMTEK_WAR) && (frag == (DC_TX_LIST_CNT - 1)) && (first != sc->dc_cdata.dc_tx_first)) { - bus_dmamap_unload(sc->dc_mtag, + bus_dmamap_unload(sc->dc_tx_mtag, sc->dc_cdata.dc_tx_map[first]); m_freem(*m_head); *m_head = NULL; return (ENOBUFS); } - f = &sc->dc_ldata->dc_tx_list[frag]; + f = &sc->dc_ldata.dc_tx_list[frag]; f->dc_ctl = htole32(DC_TXCTL_TLINK | segs[i].ds_len); if (i == 0) { f->dc_status = 0; f->dc_ctl |= htole32(DC_TXCTL_FIRSTFRAG); } else f->dc_status = htole32(DC_TXSTAT_OWN); - f->dc_data = htole32(segs[i].ds_addr); + f->dc_data = htole32(DC_ADDR_LO(segs[i].ds_addr)); cur = frag; DC_INC(frag, DC_TX_LIST_CNT); } @@ -3318,23 +3438,30 @@ dc_encap(struct dc_softc *sc, struct mbu sc->dc_cdata.dc_tx_prod = frag; sc->dc_cdata.dc_tx_cnt += nseg; sc->dc_cdata.dc_tx_chain[cur] = *m_head; - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_LASTFRAG); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_LASTFRAG); if (sc->dc_flags & DC_TX_INTR_FIRSTFRAG) - sc->dc_ldata->dc_tx_list[first].dc_ctl |= + sc->dc_ldata.dc_tx_list[first].dc_ctl |= htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_INTR_ALWAYS) - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); if (sc->dc_flags & DC_TX_USE_TX_INTR && ++sc->dc_cdata.dc_tx_pkts >= 8) { sc->dc_cdata.dc_tx_pkts = 0; - sc->dc_ldata->dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); + sc->dc_ldata.dc_tx_list[cur].dc_ctl |= htole32(DC_TXCTL_FINT); } - sc->dc_ldata->dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); + sc->dc_ldata.dc_tx_list[first].dc_status = htole32(DC_TXSTAT_OWN); + + bus_dmamap_sync(sc->dc_tx_ltag, sc->dc_tx_lmap, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + + /* + * Swap the last and the first dmamaps to ensure the map for + * this transmission is placed at the last descriptor. + */ + map = sc->dc_cdata.dc_tx_map[cur]; + sc->dc_cdata.dc_tx_map[cur] = sc->dc_cdata.dc_tx_map[first]; + sc->dc_cdata.dc_tx_map[first] = map; - bus_dmamap_sync(sc->dc_mtag, sc->dc_cdata.dc_tx_map[idx], - BUS_DMASYNC_PREWRITE); - bus_dmamap_sync(sc->dc_ltag, sc->dc_lmap, - BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); return (0); } @@ -3360,9 +3487,8 @@ static void dc_start_locked(struct ifnet *ifp) { struct dc_softc *sc; - struct mbuf *m_head = NULL; - unsigned int queued = 0; - int idx; + struct mbuf *m_head; + int queued; sc = ifp->if_softc; @@ -3372,9 +3498,16 @@ dc_start_locked(struct ifnet *ifp) IFF_DRV_RUNNING || sc->dc_link == 0) return; - idx = sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; + sc->dc_cdata.dc_tx_first = sc->dc_cdata.dc_tx_prod; - while (sc->dc_cdata.dc_tx_chain[idx] == NULL) { + for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) { + /* + * If there's no way we can send any packets, return now. + */ + if (sc->dc_cdata.dc_tx_cnt > DC_TX_LIST_CNT - DC_TX_LIST_RSVD) { + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + break; + } IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); if (m_head == NULL) break; @@ -3386,7 +3519,6 @@ dc_start_locked(struct ifnet *ifp) ifp->if_drv_flags |= IFF_DRV_OACTIVE; break; } - idx = sc->dc_cdata.dc_tx_prod; queued++; /* @@ -3773,7 +3905,7 @@ dc_stop(struct dc_softc *sc) DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; - ld = sc->dc_ldata; + ld = &sc->dc_ldata; cd = &sc->dc_cdata; callout_stop(&sc->dc_stat_ch); @@ -3793,11 +3925,17 @@ dc_stop(struct dc_softc *sc) */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 23:02:13 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA19C106566C; Sun, 27 Mar 2011 23:02:12 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D77708FC12; Sun, 27 Mar 2011 23:02:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RN2Cug072104; Sun, 27 Mar 2011 23:02:12 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RN2C1i072102; Sun, 27 Mar 2011 23:02:12 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272302.p2RN2C1i072102@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:02:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220074 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:02:13 -0000 Author: yongari Date: Sun Mar 27 23:02:12 2011 New Revision: 220074 URL: http://svn.freebsd.org/changeset/base/220074 Log: MFC r218833,218964: r218833: Count how many frames driver lost in interrupt handler. This register is cleared on read so make sure to clear it in driver initialization phase. r218964: Remove unnecessary controller reinitialization which resulted in link flips during alias address insertion or dhclient operation. While I'm here remove dc_reset() in DC_ISR_BUS_ERR case. Device is fully reinitialized again in dc_init_locked(). Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 22:50:09 2011 (r220073) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:02:12 2011 (r220074) @@ -2894,6 +2894,7 @@ dc_rxeof(struct dc_softc *sc) if (rxstat & DC_RXSTAT_CRCERR) continue; else { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); return (rx_npkts); } @@ -3032,6 +3033,7 @@ dc_txeof(struct dc_softc *sc) if (txstat & DC_TXSTAT_LATECOLL) ifp->if_collisions++; if (!(txstat & DC_TXSTAT_UNDERRUN)) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); return; } @@ -3143,8 +3145,10 @@ dc_tx_underrun(struct dc_softc *sc) u_int32_t isr; int i; - if (DC_IS_DAVICOM(sc)) + if (DC_IS_DAVICOM(sc)) { + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); + } if (DC_IS_INTEL(sc)) { /* @@ -3164,6 +3168,7 @@ dc_tx_underrun(struct dc_softc *sc) device_printf(sc->dc_dev, "%s: failed to force tx to idle state\n", __func__); + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } @@ -3236,7 +3241,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd if (status & DC_ISR_BUS_ERR) { if_printf(ifp, "%s: bus error\n", __func__); - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } @@ -3250,7 +3255,7 @@ dc_intr(void *arg) { struct dc_softc *sc; struct ifnet *ifp; - u_int32_t status; + u_int32_t r, status; int curpkts, n; sc = arg; @@ -3305,6 +3310,8 @@ dc_intr(void *arg) if ((status & DC_ISR_RX_WATDOGTIMEO) || (status & DC_ISR_RX_NOBUF)) { + r = CSR_READ_4(sc, DC_FRAMESDISCARDED); + ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3317,7 +3324,7 @@ dc_intr(void *arg) dc_start_locked(ifp); if (status & DC_ISR_BUS_ERR) { - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); DC_UNLOCK(sc); return; @@ -3563,6 +3570,9 @@ dc_init_locked(struct dc_softc *sc) DC_LOCK_ASSERT(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; + mii = device_get_softc(sc->dc_miibus); /* @@ -3723,6 +3733,9 @@ dc_init_locked(struct dc_softc *sc) mii_mediachg(mii); dc_setcfg(sc, sc->dc_if_media); + /* Clear missed frames and overflow counter. */ + CSR_READ_4(sc, DC_FRAMESDISCARDED); + /* Don't start the ticker if this is a homePNA link. */ if (IFM_SUBTYPE(mii->mii_media.ifm_media) == IFM_HPNA_1) sc->dc_link = 1; @@ -3813,6 +3826,7 @@ dc_ioctl(struct ifnet *ifp, u_long comma dc_setfilt(sc); } else { sc->dc_txthresh = 0; + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } else { @@ -3885,8 +3899,7 @@ dc_watchdog(void *xsc) ifp->if_oerrors++; device_printf(sc->dc_dev, "watchdog timeout\n"); - dc_stop(sc); - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 23:03:15 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AF848106566C; Sun, 27 Mar 2011 23:03:15 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9CEFD8FC1C; Sun, 27 Mar 2011 23:03:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RN3FoK072173; Sun, 27 Mar 2011 23:03:15 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RN3FQt072171; Sun, 27 Mar 2011 23:03:15 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272303.p2RN3FQt072171@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:03:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220075 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:03:15 -0000 Author: yongari Date: Sun Mar 27 23:03:15 2011 New Revision: 220075 URL: http://svn.freebsd.org/changeset/base/220075 Log: MFC r218833,218964: r218833: Count how many frames driver lost in interrupt handler. This register is cleared on read so make sure to clear it in driver initialization phase. r218964: Remove unnecessary controller reinitialization which resulted in link flips during alias address insertion or dhclient operation. While I'm here remove dc_reset() in DC_ISR_BUS_ERR case. Device is fully reinitialized again in dc_init_locked(). Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:02:12 2011 (r220074) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:03:15 2011 (r220075) @@ -2894,6 +2894,7 @@ dc_rxeof(struct dc_softc *sc) if (rxstat & DC_RXSTAT_CRCERR) continue; else { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); return; } @@ -3030,6 +3031,7 @@ dc_txeof(struct dc_softc *sc) if (txstat & DC_TXSTAT_LATECOLL) ifp->if_collisions++; if (!(txstat & DC_TXSTAT_UNDERRUN)) { + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); return; } @@ -3141,8 +3143,10 @@ dc_tx_underrun(struct dc_softc *sc) u_int32_t isr; int i; - if (DC_IS_DAVICOM(sc)) + if (DC_IS_DAVICOM(sc)) { + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); + } if (DC_IS_INTEL(sc)) { /* @@ -3162,6 +3166,7 @@ dc_tx_underrun(struct dc_softc *sc) device_printf(sc->dc_dev, "%s: failed to force tx to idle state\n", __func__); + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } @@ -3233,7 +3238,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd if (status & DC_ISR_BUS_ERR) { if_printf(ifp, "%s: bus error\n", __func__); - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } @@ -3246,7 +3251,7 @@ dc_intr(void *arg) { struct dc_softc *sc; struct ifnet *ifp; - u_int32_t status; + u_int32_t r, status; int curpkts, n; sc = arg; @@ -3301,6 +3306,8 @@ dc_intr(void *arg) if ((status & DC_ISR_RX_WATDOGTIMEO) || (status & DC_ISR_RX_NOBUF)) { + r = CSR_READ_4(sc, DC_FRAMESDISCARDED); + ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); curpkts = ifp->if_ipackets; dc_rxeof(sc); if (curpkts == ifp->if_ipackets) { @@ -3313,7 +3320,7 @@ dc_intr(void *arg) dc_start_locked(ifp); if (status & DC_ISR_BUS_ERR) { - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); DC_UNLOCK(sc); return; @@ -3559,6 +3566,9 @@ dc_init_locked(struct dc_softc *sc) DC_LOCK_ASSERT(sc); + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) + return; + mii = device_get_softc(sc->dc_miibus); /* @@ -3719,6 +3729,9 @@ dc_init_locked(struct dc_softc *sc) mii_mediachg(mii); dc_setcfg(sc, sc->dc_if_media); + /* Clear missed frames and overflow counter. */ + CSR_READ_4(sc, DC_FRAMESDISCARDED); + /* Don't start the ticker if this is a homePNA link. */ if (IFM_SUBTYPE(mii->mii_media.ifm_media) == IFM_HPNA_1) sc->dc_link = 1; @@ -3809,6 +3822,7 @@ dc_ioctl(struct ifnet *ifp, u_long comma dc_setfilt(sc); } else { sc->dc_txthresh = 0; + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } } else { @@ -3881,8 +3895,7 @@ dc_watchdog(void *xsc) ifp->if_oerrors++; device_printf(sc->dc_dev, "watchdog timeout\n"); - dc_stop(sc); - dc_reset(sc); + ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 23:08:02 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 271FA1065676; Sun, 27 Mar 2011 23:08:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 131408FC15; Sun, 27 Mar 2011 23:08:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RN82ZC072352; Sun, 27 Mar 2011 23:08:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RN82CX072349; Sun, 27 Mar 2011 23:08:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272308.p2RN82CX072349@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:08:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220076 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:08:02 -0000 Author: yongari Date: Sun Mar 27 23:08:01 2011 New Revision: 220076 URL: http://svn.freebsd.org/changeset/base/220076 Log: MFC r218834-218835: r218834: Consistently use a tab character instead of space after #define. No functional changes. r218835: s/u_intXX_t/uintXX_t/g Modified: stable/8/sys/dev/dc/if_dc.c stable/8/sys/dev/dc/if_dcreg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:03:15 2011 (r220075) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:08:01 2011 (r220076) @@ -127,7 +127,7 @@ __FBSDID("$FreeBSD$"); #include #include -#define DC_USEIOSPACE +#define DC_USEIOSPACE #include @@ -261,16 +261,16 @@ static void dc_dma_map_addr(void *, bus_ static void dc_delay(struct dc_softc *); static void dc_eeprom_idle(struct dc_softc *); static void dc_eeprom_putbyte(struct dc_softc *, int); -static void dc_eeprom_getword(struct dc_softc *, int, u_int16_t *); -static void dc_eeprom_getword_pnic(struct dc_softc *, int, u_int16_t *); -static void dc_eeprom_getword_xircom(struct dc_softc *, int, u_int16_t *); +static void dc_eeprom_getword(struct dc_softc *, int, uint16_t *); +static void dc_eeprom_getword_pnic(struct dc_softc *, int, uint16_t *); +static void dc_eeprom_getword_xircom(struct dc_softc *, int, uint16_t *); static void dc_eeprom_width(struct dc_softc *); static void dc_read_eeprom(struct dc_softc *, caddr_t, int, int, int); static void dc_mii_writebit(struct dc_softc *, int); static int dc_mii_readbit(struct dc_softc *); static void dc_mii_sync(struct dc_softc *); -static void dc_mii_send(struct dc_softc *, u_int32_t, int); +static void dc_mii_send(struct dc_softc *, uint32_t, int); static int dc_mii_readreg(struct dc_softc *, struct dc_mii_frame *); static int dc_mii_writereg(struct dc_softc *, struct dc_mii_frame *); static int dc_miibus_readreg(device_t, int, int); @@ -301,11 +301,11 @@ static void dc_apply_fixup(struct dc_sof static int dc_check_multiport(struct dc_softc *); #ifdef DC_USEIOSPACE -#define DC_RES SYS_RES_IOPORT -#define DC_RID DC_PCI_CFBIO +#define DC_RES SYS_RES_IOPORT +#define DC_RID DC_PCI_CFBIO #else -#define DC_RES SYS_RES_MEMORY -#define DC_RID DC_PCI_CFBMA +#define DC_RES SYS_RES_MEMORY +#define DC_RID DC_PCI_CFBMA #endif static device_method_t dc_methods[] = { @@ -341,14 +341,14 @@ static devclass_t dc_devclass; DRIVER_MODULE(dc, pci, dc_driver, dc_devclass, 0, 0); DRIVER_MODULE(miibus, dc, miibus_driver, miibus_devclass, 0, 0); -#define DC_SETBIT(sc, reg, x) \ +#define DC_SETBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) | (x)) -#define DC_CLRBIT(sc, reg, x) \ +#define DC_CLRBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) & ~(x)) -#define SIO_SET(x) DC_SETBIT(sc, DC_SIO, (x)) -#define SIO_CLR(x) DC_CLRBIT(sc, DC_SIO, (x)) +#define SIO_SET(x) DC_SETBIT(sc, DC_SIO, (x)) +#define SIO_CLR(x) DC_CLRBIT(sc, DC_SIO, (x)) static void dc_delay(struct dc_softc *sc) @@ -495,10 +495,10 @@ dc_eeprom_putbyte(struct dc_softc *sc, i * the EEPROM. */ static void -dc_eeprom_getword_pnic(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword_pnic(struct dc_softc *sc, int addr, uint16_t *dest) { int i; - u_int32_t r; + uint32_t r; CSR_WRITE_4(sc, DC_PN_SIOCTL, DC_PN_EEOPCODE_READ | addr); @@ -506,7 +506,7 @@ dc_eeprom_getword_pnic(struct dc_softc * DELAY(1); r = CSR_READ_4(sc, DC_SIO); if (!(r & DC_PN_SIOCTL_BUSY)) { - *dest = (u_int16_t)(r & 0xFFFF); + *dest = (uint16_t)(r & 0xFFFF); return; } } @@ -518,17 +518,17 @@ dc_eeprom_getword_pnic(struct dc_softc * * the EEPROM, too. */ static void -dc_eeprom_getword_xircom(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword_xircom(struct dc_softc *sc, int addr, uint16_t *dest) { SIO_SET(DC_SIO_ROMSEL | DC_SIO_ROMCTL_READ); addr *= 2; CSR_WRITE_4(sc, DC_ROM, addr | 0x160); - *dest = (u_int16_t)CSR_READ_4(sc, DC_SIO) & 0xff; + *dest = (uint16_t)CSR_READ_4(sc, DC_SIO) & 0xff; addr += 1; CSR_WRITE_4(sc, DC_ROM, addr | 0x160); - *dest |= ((u_int16_t)CSR_READ_4(sc, DC_SIO) & 0xff) << 8; + *dest |= ((uint16_t)CSR_READ_4(sc, DC_SIO) & 0xff) << 8; SIO_CLR(DC_SIO_ROMSEL | DC_SIO_ROMCTL_READ); } @@ -537,10 +537,10 @@ dc_eeprom_getword_xircom(struct dc_softc * Read a word of data stored in the EEPROM at address 'addr.' */ static void -dc_eeprom_getword(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword(struct dc_softc *sc, int addr, uint16_t *dest) { int i; - u_int16_t word = 0; + uint16_t word = 0; /* Force EEPROM to idle state. */ dc_eeprom_idle(sc); @@ -586,7 +586,7 @@ static void dc_read_eeprom(struct dc_softc *sc, caddr_t dest, int off, int cnt, int be) { int i; - u_int16_t word = 0, *ptr; + uint16_t word = 0, *ptr; for (i = 0; i < cnt; i++) { if (DC_IS_PNIC(sc)) @@ -595,7 +595,7 @@ dc_read_eeprom(struct dc_softc *sc, cadd dc_eeprom_getword_xircom(sc, off + i, &word); else dc_eeprom_getword(sc, off + i, &word); - ptr = (u_int16_t *)(dest + (i * 2)); + ptr = (uint16_t *)(dest + (i * 2)); if (be) *ptr = be16toh(word); else @@ -680,7 +680,7 @@ dc_mii_sync(struct dc_softc *sc) * Clock a series of bits through the MII. */ static void -dc_mii_send(struct dc_softc *sc, u_int32_t bits, int cnt) +dc_mii_send(struct dc_softc *sc, uint32_t bits, int cnt) { int i; @@ -1016,9 +1016,9 @@ dc_miibus_mediainit(device_t dev) ifmedia_add(ifm, IFM_ETHER | IFM_HPNA_1, 0, NULL); } -#define DC_BITS_512 9 -#define DC_BITS_128 7 -#define DC_BITS_64 6 +#define DC_BITS_512 9 +#define DC_BITS_128 7 +#define DC_BITS_64 6 static uint32_t dc_mchash_le(struct dc_softc *sc, const uint8_t *addr) @@ -1082,7 +1082,7 @@ dc_setfilt_21143(struct dc_softc *sc) { uint16_t eaddr[(ETHER_ADDR_LEN+1)/2]; struct dc_desc *sframe; - u_int32_t h, *sp; + uint32_t h, *sp; struct ifmultiaddr *ifma; struct ifnet *ifp; int i; @@ -1156,7 +1156,7 @@ dc_setfilt_admtek(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; int h = 0; - u_int32_t hashes[2] = { 0, 0 }; + uint32_t hashes[2] = { 0, 0 }; ifp = sc->dc_ifp; @@ -1217,7 +1217,7 @@ dc_setfilt_asix(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; int h = 0; - u_int32_t hashes[2] = { 0, 0 }; + uint32_t hashes[2] = { 0, 0 }; ifp = sc->dc_ifp; @@ -1287,7 +1287,7 @@ dc_setfilt_xircom(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; struct dc_desc *sframe; - u_int32_t h, *sp; + uint32_t h, *sp; int i; ifp = sc->dc_ifp; @@ -1379,7 +1379,7 @@ static void dc_setcfg(struct dc_softc *sc, int media) { int i, restart = 0, watchdogreg; - u_int32_t isr; + uint32_t isr; if (IFM_SUBTYPE(media) == IFM_NONE) return; @@ -1563,8 +1563,8 @@ static const struct dc_type * dc_devtype(device_t dev) { const struct dc_type *t; - u_int32_t devid; - u_int8_t rev; + uint32_t devid; + uint8_t rev; t = dc_devs; devid = pci_get_devid(dev); @@ -1607,9 +1607,9 @@ static void dc_apply_fixup(struct dc_softc *sc, int media) { struct dc_mediainfo *m; - u_int8_t *p; + uint8_t *p; int i; - u_int32_t reg; + uint32_t reg; m = sc->dc_mi; @@ -1668,11 +1668,11 @@ dc_decode_leaf_sia(struct dc_softc *sc, if (l->dc_sia_code & DC_SIA_CODE_EXT) { m->dc_gp_len = 2; m->dc_gp_ptr = - (u_int8_t *)&l->dc_un.dc_sia_ext.dc_sia_gpio_ctl; + (uint8_t *)&l->dc_un.dc_sia_ext.dc_sia_gpio_ctl; } else { m->dc_gp_len = 2; m->dc_gp_ptr = - (u_int8_t *)&l->dc_un.dc_sia_noext.dc_sia_gpio_ctl; + (uint8_t *)&l->dc_un.dc_sia_noext.dc_sia_gpio_ctl; } m->dc_next = sc->dc_mi; @@ -1699,7 +1699,7 @@ dc_decode_leaf_sym(struct dc_softc *sc, m->dc_media = IFM_100_TX | IFM_FDX; m->dc_gp_len = 2; - m->dc_gp_ptr = (u_int8_t *)&l->dc_sym_gpio_ctl; + m->dc_gp_ptr = (uint8_t *)&l->dc_sym_gpio_ctl; m->dc_next = sc->dc_mi; sc->dc_mi = m; @@ -1712,7 +1712,7 @@ static int dc_decode_leaf_mii(struct dc_softc *sc, struct dc_eblock_mii *l) { struct dc_mediainfo *m; - u_int8_t *p; + uint8_t *p; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); if (m == NULL) { @@ -1723,7 +1723,7 @@ dc_decode_leaf_mii(struct dc_softc *sc, m->dc_media = IFM_AUTO; m->dc_gp_len = l->dc_gpr_len; - p = (u_int8_t *)l; + p = (uint8_t *)l; p += sizeof(struct dc_eblock_mii); m->dc_gp_ptr = p; p += 2 * l->dc_gpr_len; @@ -2031,13 +2031,13 @@ static int dc_attach(device_t dev) { uint32_t eaddr[(ETHER_ADDR_LEN+3)/4]; - u_int32_t command; + uint32_t command; struct dc_softc *sc; struct ifnet *ifp; struct dc_mediainfo *m; - u_int32_t reg, revision; + uint32_t reg, revision; int error, mac_offset, phy, rid, tmp; - u_int8_t *mac; + uint8_t *mac; sc = device_get_softc(dev); sc->dc_dev = dev; @@ -2715,7 +2715,7 @@ dc_newbuf(struct dc_softc *sc, int i) * the time. */ -#define DC_WHOLEFRAME (DC_RXSTAT_FIRSTFRAG | DC_RXSTAT_LASTFRAG) +#define DC_WHOLEFRAME (DC_RXSTAT_FIRSTFRAG | DC_RXSTAT_LASTFRAG) static void dc_pnic_rx_bug_war(struct dc_softc *sc, int idx) { @@ -2724,7 +2724,7 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, struct mbuf *m = NULL; unsigned char *ptr; int i, total_len; - u_int32_t rxstat = 0; + uint32_t rxstat = 0; i = sc->dc_pnic_rx_bug_save; cur_rx = &sc->dc_ldata.dc_rx_list[idx]; @@ -2835,7 +2835,7 @@ dc_rxeof(struct dc_softc *sc) struct ifnet *ifp; struct dc_desc *cur_rx; int i, total_len, rx_npkts; - u_int32_t rxstat; + uint32_t rxstat; DC_LOCK_ASSERT(sc); @@ -2956,7 +2956,7 @@ dc_txeof(struct dc_softc *sc) struct dc_desc *cur_tx; struct ifnet *ifp; int idx, setup; - u_int32_t ctl, txstat; + uint32_t ctl, txstat; if (sc->dc_cdata.dc_tx_cnt == 0) return; @@ -3065,7 +3065,7 @@ dc_tick(void *xsc) struct dc_softc *sc; struct mii_data *mii; struct ifnet *ifp; - u_int32_t r; + uint32_t r; sc = xsc; DC_LOCK_ASSERT(sc); @@ -3142,7 +3142,7 @@ dc_tick(void *xsc) static void dc_tx_underrun(struct dc_softc *sc) { - u_int32_t isr; + uint32_t isr; int i; if (DC_IS_DAVICOM(sc)) { @@ -3212,7 +3212,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd dc_start_locked(ifp); if (cmd == POLL_AND_CHECK_STATUS) { /* also check status register */ - u_int32_t status; + uint32_t status; status = CSR_READ_4(sc, DC_ISR); status &= (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF | @@ -3226,7 +3226,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd CSR_WRITE_4(sc, DC_ISR, status); if (status & (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF)) { - u_int32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED); + uint32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED); ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); if (dc_rx_resync(sc)) @@ -3255,7 +3255,7 @@ dc_intr(void *arg) { struct dc_softc *sc; struct ifnet *ifp; - u_int32_t r, status; + uint32_t r, status; int curpkts, n; sc = arg; @@ -3917,7 +3917,7 @@ dc_stop(struct dc_softc *sc) struct dc_list_data *ld; struct dc_chain_data *cd; int i; - u_int32_t ctl; + uint32_t ctl; DC_LOCK_ASSERT(sc); Modified: stable/8/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 23:03:15 2011 (r220075) +++ stable/8/sys/dev/dc/if_dcreg.h Sun Mar 27 23:08:01 2011 (r220076) @@ -36,23 +36,23 @@ * 21143 and clone common register definitions. */ -#define DC_BUSCTL 0x00 /* bus control */ -#define DC_TXSTART 0x08 /* tx start demand */ -#define DC_RXSTART 0x10 /* rx start demand */ -#define DC_RXADDR 0x18 /* rx descriptor list start addr */ -#define DC_TXADDR 0x20 /* tx descriptor list start addr */ -#define DC_ISR 0x28 /* interrupt status register */ -#define DC_NETCFG 0x30 /* network config register */ -#define DC_IMR 0x38 /* interrupt mask */ -#define DC_FRAMESDISCARDED 0x40 /* # of discarded frames */ -#define DC_SIO 0x48 /* MII and ROM/EEPROM access */ -#define DC_ROM 0x50 /* ROM programming address */ -#define DC_TIMER 0x58 /* general timer */ -#define DC_10BTSTAT 0x60 /* SIA status */ -#define DC_SIARESET 0x68 /* SIA connectivity */ -#define DC_10BTCTRL 0x70 /* SIA transmit and receive */ -#define DC_WATCHDOG 0x78 /* SIA and general purpose port */ -#define DC_SIAGP 0x78 /* SIA and general purpose port (X3201) */ +#define DC_BUSCTL 0x00 /* bus control */ +#define DC_TXSTART 0x08 /* tx start demand */ +#define DC_RXSTART 0x10 /* rx start demand */ +#define DC_RXADDR 0x18 /* rx descriptor list start addr */ +#define DC_TXADDR 0x20 /* tx descriptor list start addr */ +#define DC_ISR 0x28 /* interrupt status register */ +#define DC_NETCFG 0x30 /* network config register */ +#define DC_IMR 0x38 /* interrupt mask */ +#define DC_FRAMESDISCARDED 0x40 /* # of discarded frames */ +#define DC_SIO 0x48 /* MII and ROM/EEPROM access */ +#define DC_ROM 0x50 /* ROM programming address */ +#define DC_TIMER 0x58 /* general timer */ +#define DC_10BTSTAT 0x60 /* SIA status */ +#define DC_SIARESET 0x68 /* SIA connectivity */ +#define DC_10BTCTRL 0x70 /* SIA transmit and receive */ +#define DC_WATCHDOG 0x78 /* SIA and general purpose port */ +#define DC_SIAGP 0x78 /* SIA and general purpose port (X3201) */ /* * There are two general 'types' of MX chips that we need to be @@ -64,427 +64,427 @@ * 'magic' numbers we write to CSR16. The PNIC II falls into the * 98713A/98715/98715A/98725 category. */ -#define DC_TYPE_98713 0x1 -#define DC_TYPE_98713A 0x2 -#define DC_TYPE_987x5 0x3 +#define DC_TYPE_98713 0x1 +#define DC_TYPE_98713A 0x2 +#define DC_TYPE_987x5 0x3 /* Other type of supported chips. */ -#define DC_TYPE_21143 0x4 /* Intel 21143 */ -#define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */ -#define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */ -#define DC_TYPE_AN983 0x7 /* ADMtek AN983 Centaur */ -#define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */ -#define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */ -#define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */ +#define DC_TYPE_21143 0x4 /* Intel 21143 */ +#define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */ +#define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */ +#define DC_TYPE_AN983 0x7 /* ADMtek AN983 Centaur */ +#define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */ +#define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */ +#define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */ #define DC_TYPE_XIRCOM 0xB /* Xircom X3201 */ -#define DC_TYPE_CONEXANT 0xC /* Conexant LANfinity RS7112 */ +#define DC_TYPE_CONEXANT 0xC /* Conexant LANfinity RS7112 */ -#define DC_IS_MACRONIX(x) \ +#define DC_IS_MACRONIX(x) \ (x->dc_type == DC_TYPE_98713 || \ x->dc_type == DC_TYPE_98713A || \ x->dc_type == DC_TYPE_987x5) -#define DC_IS_ADMTEK(x) \ +#define DC_IS_ADMTEK(x) \ (x->dc_type == DC_TYPE_AL981 || \ x->dc_type == DC_TYPE_AN983) -#define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143) -#define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX) -#define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981) -#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN983) -#define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102) -#define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII) -#define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC) +#define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143) +#define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX) +#define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981) +#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN983) +#define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102) +#define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII) +#define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC) #define DC_IS_XIRCOM(x) (x->dc_type == DC_TYPE_XIRCOM) -#define DC_IS_CONEXANT(x) (x->dc_type == DC_TYPE_CONEXANT) +#define DC_IS_CONEXANT(x) (x->dc_type == DC_TYPE_CONEXANT) /* MII/symbol mode port types */ -#define DC_PMODE_MII 0x1 -#define DC_PMODE_SYM 0x2 -#define DC_PMODE_SIA 0x3 +#define DC_PMODE_MII 0x1 +#define DC_PMODE_SYM 0x2 +#define DC_PMODE_SIA 0x3 /* * Bus control bits. */ -#define DC_BUSCTL_RESET 0x00000001 -#define DC_BUSCTL_ARBITRATION 0x00000002 -#define DC_BUSCTL_SKIPLEN 0x0000007C -#define DC_BUSCTL_BUF_BIGENDIAN 0x00000080 -#define DC_BUSCTL_BURSTLEN 0x00003F00 -#define DC_BUSCTL_CACHEALIGN 0x0000C000 -#define DC_BUSCTL_TXPOLL 0x000E0000 -#define DC_BUSCTL_DBO 0x00100000 -#define DC_BUSCTL_MRME 0x00200000 -#define DC_BUSCTL_MRLE 0x00800000 -#define DC_BUSCTL_MWIE 0x01000000 -#define DC_BUSCTL_ONNOW_ENB 0x04000000 - -#define DC_SKIPLEN_1LONG 0x00000004 -#define DC_SKIPLEN_2LONG 0x00000008 -#define DC_SKIPLEN_3LONG 0x00000010 -#define DC_SKIPLEN_4LONG 0x00000020 -#define DC_SKIPLEN_5LONG 0x00000040 - -#define DC_CACHEALIGN_NONE 0x00000000 -#define DC_CACHEALIGN_8LONG 0x00004000 -#define DC_CACHEALIGN_16LONG 0x00008000 -#define DC_CACHEALIGN_32LONG 0x0000C000 - -#define DC_BURSTLEN_USECA 0x00000000 -#define DC_BURSTLEN_1LONG 0x00000100 -#define DC_BURSTLEN_2LONG 0x00000200 -#define DC_BURSTLEN_4LONG 0x00000400 -#define DC_BURSTLEN_8LONG 0x00000800 -#define DC_BURSTLEN_16LONG 0x00001000 -#define DC_BURSTLEN_32LONG 0x00002000 - -#define DC_TXPOLL_OFF 0x00000000 -#define DC_TXPOLL_1 0x00020000 -#define DC_TXPOLL_2 0x00040000 -#define DC_TXPOLL_3 0x00060000 -#define DC_TXPOLL_4 0x00080000 -#define DC_TXPOLL_5 0x000A0000 -#define DC_TXPOLL_6 0x000C0000 -#define DC_TXPOLL_7 0x000E0000 +#define DC_BUSCTL_RESET 0x00000001 +#define DC_BUSCTL_ARBITRATION 0x00000002 +#define DC_BUSCTL_SKIPLEN 0x0000007C +#define DC_BUSCTL_BUF_BIGENDIAN 0x00000080 +#define DC_BUSCTL_BURSTLEN 0x00003F00 +#define DC_BUSCTL_CACHEALIGN 0x0000C000 +#define DC_BUSCTL_TXPOLL 0x000E0000 +#define DC_BUSCTL_DBO 0x00100000 +#define DC_BUSCTL_MRME 0x00200000 +#define DC_BUSCTL_MRLE 0x00800000 +#define DC_BUSCTL_MWIE 0x01000000 +#define DC_BUSCTL_ONNOW_ENB 0x04000000 + +#define DC_SKIPLEN_1LONG 0x00000004 +#define DC_SKIPLEN_2LONG 0x00000008 +#define DC_SKIPLEN_3LONG 0x00000010 +#define DC_SKIPLEN_4LONG 0x00000020 +#define DC_SKIPLEN_5LONG 0x00000040 + +#define DC_CACHEALIGN_NONE 0x00000000 +#define DC_CACHEALIGN_8LONG 0x00004000 +#define DC_CACHEALIGN_16LONG 0x00008000 +#define DC_CACHEALIGN_32LONG 0x0000C000 + +#define DC_BURSTLEN_USECA 0x00000000 +#define DC_BURSTLEN_1LONG 0x00000100 +#define DC_BURSTLEN_2LONG 0x00000200 +#define DC_BURSTLEN_4LONG 0x00000400 +#define DC_BURSTLEN_8LONG 0x00000800 +#define DC_BURSTLEN_16LONG 0x00001000 +#define DC_BURSTLEN_32LONG 0x00002000 + +#define DC_TXPOLL_OFF 0x00000000 +#define DC_TXPOLL_1 0x00020000 +#define DC_TXPOLL_2 0x00040000 +#define DC_TXPOLL_3 0x00060000 +#define DC_TXPOLL_4 0x00080000 +#define DC_TXPOLL_5 0x000A0000 +#define DC_TXPOLL_6 0x000C0000 +#define DC_TXPOLL_7 0x000E0000 /* * Interrupt status bits. */ -#define DC_ISR_TX_OK 0x00000001 -#define DC_ISR_TX_IDLE 0x00000002 -#define DC_ISR_TX_NOBUF 0x00000004 -#define DC_ISR_TX_JABBERTIMEO 0x00000008 -#define DC_ISR_LINKGOOD 0x00000010 -#define DC_ISR_TX_UNDERRUN 0x00000020 -#define DC_ISR_RX_OK 0x00000040 -#define DC_ISR_RX_NOBUF 0x00000080 -#define DC_ISR_RX_READ 0x00000100 -#define DC_ISR_RX_WATDOGTIMEO 0x00000200 -#define DC_ISR_TX_EARLY 0x00000400 -#define DC_ISR_TIMER_EXPIRED 0x00000800 -#define DC_ISR_LINKFAIL 0x00001000 -#define DC_ISR_BUS_ERR 0x00002000 -#define DC_ISR_RX_EARLY 0x00004000 -#define DC_ISR_ABNORMAL 0x00008000 -#define DC_ISR_NORMAL 0x00010000 -#define DC_ISR_RX_STATE 0x000E0000 -#define DC_ISR_TX_STATE 0x00700000 -#define DC_ISR_BUSERRTYPE 0x03800000 -#define DC_ISR_100MBPSLINK 0x08000000 -#define DC_ISR_MAGICKPACK 0x10000000 - -#define DC_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */ -#define DC_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */ -#define DC_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */ -#define DC_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */ -#define DC_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */ -#define DC_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */ -#define DC_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */ -#define DC_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */ +#define DC_ISR_TX_OK 0x00000001 +#define DC_ISR_TX_IDLE 0x00000002 +#define DC_ISR_TX_NOBUF 0x00000004 +#define DC_ISR_TX_JABBERTIMEO 0x00000008 +#define DC_ISR_LINKGOOD 0x00000010 +#define DC_ISR_TX_UNDERRUN 0x00000020 +#define DC_ISR_RX_OK 0x00000040 +#define DC_ISR_RX_NOBUF 0x00000080 +#define DC_ISR_RX_READ 0x00000100 +#define DC_ISR_RX_WATDOGTIMEO 0x00000200 +#define DC_ISR_TX_EARLY 0x00000400 +#define DC_ISR_TIMER_EXPIRED 0x00000800 +#define DC_ISR_LINKFAIL 0x00001000 +#define DC_ISR_BUS_ERR 0x00002000 +#define DC_ISR_RX_EARLY 0x00004000 +#define DC_ISR_ABNORMAL 0x00008000 +#define DC_ISR_NORMAL 0x00010000 +#define DC_ISR_RX_STATE 0x000E0000 +#define DC_ISR_TX_STATE 0x00700000 +#define DC_ISR_BUSERRTYPE 0x03800000 +#define DC_ISR_100MBPSLINK 0x08000000 +#define DC_ISR_MAGICKPACK 0x10000000 + +#define DC_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */ +#define DC_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */ +#define DC_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */ +#define DC_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */ +#define DC_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */ +#define DC_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */ +#define DC_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */ +#define DC_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */ #define DC_HAS_BROKEN_RXSTATE(x) \ (DC_IS_CENTAUR(x) || DC_IS_CONEXANT(x) || (DC_IS_DAVICOM(x) && \ pci_get_revid((x)->dc_dev) >= DC_REVISION_DM9102A)) -#define DC_TXSTATE_RESET 0x00000000 /* 000 - reset */ -#define DC_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */ -#define DC_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */ -#define DC_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */ -#define DC_TXSTATE_RSVD 0x00400000 /* 100 - reserved */ -#define DC_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */ -#define DC_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */ -#define DC_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */ +#define DC_TXSTATE_RESET 0x00000000 /* 000 - reset */ +#define DC_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */ +#define DC_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */ +#define DC_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */ +#define DC_TXSTATE_RSVD 0x00400000 /* 100 - reserved */ +#define DC_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */ +#define DC_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */ +#define DC_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */ /* * Network config bits. */ -#define DC_NETCFG_RX_HASHPERF 0x00000001 -#define DC_NETCFG_RX_ON 0x00000002 -#define DC_NETCFG_RX_HASHONLY 0x00000004 -#define DC_NETCFG_RX_BADFRAMES 0x00000008 -#define DC_NETCFG_RX_INVFILT 0x00000010 -#define DC_NETCFG_BACKOFFCNT 0x00000020 -#define DC_NETCFG_RX_PROMISC 0x00000040 -#define DC_NETCFG_RX_ALLMULTI 0x00000080 -#define DC_NETCFG_FULLDUPLEX 0x00000200 -#define DC_NETCFG_LOOPBACK 0x00000C00 -#define DC_NETCFG_FORCECOLL 0x00001000 -#define DC_NETCFG_TX_ON 0x00002000 -#define DC_NETCFG_TX_THRESH 0x0000C000 -#define DC_NETCFG_TX_BACKOFF 0x00020000 -#define DC_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */ -#define DC_NETCFG_HEARTBEAT 0x00080000 -#define DC_NETCFG_STORENFWD 0x00200000 -#define DC_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */ -#define DC_NETCFG_PCS 0x00800000 -#define DC_NETCFG_SCRAMBLER 0x01000000 -#define DC_NETCFG_NO_RXCRC 0x02000000 -#define DC_NETCFG_RX_ALL 0x40000000 -#define DC_NETCFG_CAPEFFECT 0x80000000 - -#define DC_OPMODE_NORM 0x00000000 -#define DC_OPMODE_INTLOOP 0x00000400 -#define DC_OPMODE_EXTLOOP 0x00000800 +#define DC_NETCFG_RX_HASHPERF 0x00000001 +#define DC_NETCFG_RX_ON 0x00000002 +#define DC_NETCFG_RX_HASHONLY 0x00000004 +#define DC_NETCFG_RX_BADFRAMES 0x00000008 +#define DC_NETCFG_RX_INVFILT 0x00000010 +#define DC_NETCFG_BACKOFFCNT 0x00000020 +#define DC_NETCFG_RX_PROMISC 0x00000040 +#define DC_NETCFG_RX_ALLMULTI 0x00000080 +#define DC_NETCFG_FULLDUPLEX 0x00000200 +#define DC_NETCFG_LOOPBACK 0x00000C00 +#define DC_NETCFG_FORCECOLL 0x00001000 +#define DC_NETCFG_TX_ON 0x00002000 +#define DC_NETCFG_TX_THRESH 0x0000C000 +#define DC_NETCFG_TX_BACKOFF 0x00020000 +#define DC_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */ +#define DC_NETCFG_HEARTBEAT 0x00080000 +#define DC_NETCFG_STORENFWD 0x00200000 +#define DC_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */ +#define DC_NETCFG_PCS 0x00800000 +#define DC_NETCFG_SCRAMBLER 0x01000000 +#define DC_NETCFG_NO_RXCRC 0x02000000 +#define DC_NETCFG_RX_ALL 0x40000000 +#define DC_NETCFG_CAPEFFECT 0x80000000 + +#define DC_OPMODE_NORM 0x00000000 +#define DC_OPMODE_INTLOOP 0x00000400 +#define DC_OPMODE_EXTLOOP 0x00000800 #if 0 -#define DC_TXTHRESH_72BYTES 0x00000000 -#define DC_TXTHRESH_96BYTES 0x00004000 -#define DC_TXTHRESH_128BYTES 0x00008000 -#define DC_TXTHRESH_160BYTES 0x0000C000 +#define DC_TXTHRESH_72BYTES 0x00000000 +#define DC_TXTHRESH_96BYTES 0x00004000 +#define DC_TXTHRESH_128BYTES 0x00008000 +#define DC_TXTHRESH_160BYTES 0x0000C000 #endif -#define DC_TXTHRESH_MIN 0x00000000 -#define DC_TXTHRESH_INC 0x00004000 -#define DC_TXTHRESH_MAX 0x0000C000 +#define DC_TXTHRESH_MIN 0x00000000 +#define DC_TXTHRESH_INC 0x00004000 +#define DC_TXTHRESH_MAX 0x0000C000 /* * Interrupt mask bits. */ -#define DC_IMR_TX_OK 0x00000001 -#define DC_IMR_TX_IDLE 0x00000002 -#define DC_IMR_TX_NOBUF 0x00000004 -#define DC_IMR_TX_JABBERTIMEO 0x00000008 -#define DC_IMR_LINKGOOD 0x00000010 -#define DC_IMR_TX_UNDERRUN 0x00000020 -#define DC_IMR_RX_OK 0x00000040 -#define DC_IMR_RX_NOBUF 0x00000080 -#define DC_IMR_RX_READ 0x00000100 -#define DC_IMR_RX_WATDOGTIMEO 0x00000200 -#define DC_IMR_TX_EARLY 0x00000400 -#define DC_IMR_TIMER_EXPIRED 0x00000800 -#define DC_IMR_LINKFAIL 0x00001000 -#define DC_IMR_BUS_ERR 0x00002000 -#define DC_IMR_RX_EARLY 0x00004000 -#define DC_IMR_ABNORMAL 0x00008000 -#define DC_IMR_NORMAL 0x00010000 -#define DC_IMR_100MBPSLINK 0x08000000 -#define DC_IMR_MAGICKPACK 0x10000000 +#define DC_IMR_TX_OK 0x00000001 +#define DC_IMR_TX_IDLE 0x00000002 +#define DC_IMR_TX_NOBUF 0x00000004 +#define DC_IMR_TX_JABBERTIMEO 0x00000008 +#define DC_IMR_LINKGOOD 0x00000010 +#define DC_IMR_TX_UNDERRUN 0x00000020 +#define DC_IMR_RX_OK 0x00000040 +#define DC_IMR_RX_NOBUF 0x00000080 +#define DC_IMR_RX_READ 0x00000100 +#define DC_IMR_RX_WATDOGTIMEO 0x00000200 +#define DC_IMR_TX_EARLY 0x00000400 +#define DC_IMR_TIMER_EXPIRED 0x00000800 +#define DC_IMR_LINKFAIL 0x00001000 +#define DC_IMR_BUS_ERR 0x00002000 +#define DC_IMR_RX_EARLY 0x00004000 +#define DC_IMR_ABNORMAL 0x00008000 +#define DC_IMR_NORMAL 0x00010000 +#define DC_IMR_100MBPSLINK 0x08000000 +#define DC_IMR_MAGICKPACK 0x10000000 -#define DC_INTRS \ +#define DC_INTRS \ (DC_IMR_RX_OK|DC_IMR_TX_OK|DC_IMR_RX_NOBUF|DC_IMR_RX_WATDOGTIMEO|\ DC_IMR_TX_NOBUF|DC_IMR_TX_UNDERRUN|DC_IMR_BUS_ERR| \ DC_IMR_ABNORMAL|DC_IMR_NORMAL/*|DC_IMR_TX_EARLY*/) /* * Serial I/O (EEPROM/ROM) bits. */ -#define DC_SIO_EE_CS 0x00000001 /* EEPROM chip select */ -#define DC_SIO_EE_CLK 0x00000002 /* EEPROM clock */ -#define DC_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */ -#define DC_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */ -#define DC_SIO_ROMDATA4 0x00000010 -#define DC_SIO_ROMDATA5 0x00000020 -#define DC_SIO_ROMDATA6 0x00000040 -#define DC_SIO_ROMDATA7 0x00000080 -#define DC_SIO_EESEL 0x00000800 -#define DC_SIO_ROMSEL 0x00001000 -#define DC_SIO_ROMCTL_WRITE 0x00002000 -#define DC_SIO_ROMCTL_READ 0x00004000 -#define DC_SIO_MII_CLK 0x00010000 /* MDIO clock */ -#define DC_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */ -#define DC_SIO_MII_DIR 0x00040000 /* MDIO dir */ -#define DC_SIO_MII_DATAIN 0x00080000 /* MDIO data in */ - -#define DC_EECMD_WRITE 0x140 -#define DC_EECMD_READ 0x180 -#define DC_EECMD_ERASE 0x1c0 +#define DC_SIO_EE_CS 0x00000001 /* EEPROM chip select */ +#define DC_SIO_EE_CLK 0x00000002 /* EEPROM clock */ +#define DC_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */ +#define DC_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */ +#define DC_SIO_ROMDATA4 0x00000010 +#define DC_SIO_ROMDATA5 0x00000020 +#define DC_SIO_ROMDATA6 0x00000040 +#define DC_SIO_ROMDATA7 0x00000080 +#define DC_SIO_EESEL 0x00000800 +#define DC_SIO_ROMSEL 0x00001000 +#define DC_SIO_ROMCTL_WRITE 0x00002000 +#define DC_SIO_ROMCTL_READ 0x00004000 +#define DC_SIO_MII_CLK 0x00010000 /* MDIO clock */ +#define DC_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */ +#define DC_SIO_MII_DIR 0x00040000 /* MDIO dir */ +#define DC_SIO_MII_DATAIN 0x00080000 /* MDIO data in */ + +#define DC_EECMD_WRITE 0x140 +#define DC_EECMD_READ 0x180 +#define DC_EECMD_ERASE 0x1c0 -#define DC_EE_NODEADDR_OFFSET 0x70 -#define DC_EE_NODEADDR 10 +#define DC_EE_NODEADDR_OFFSET 0x70 +#define DC_EE_NODEADDR 10 /* * General purpose timer register */ -#define DC_TIMER_VALUE 0x0000FFFF -#define DC_TIMER_CONTINUOUS 0x00010000 +#define DC_TIMER_VALUE 0x0000FFFF +#define DC_TIMER_CONTINUOUS 0x00010000 /* * 10baseT status register */ -#define DC_TSTAT_MIIACT 0x00000001 /* MII port activity */ -#define DC_TSTAT_LS100 0x00000002 /* link status of 100baseTX */ -#define DC_TSTAT_LS10 0x00000004 /* link status of 10baseT */ -#define DC_TSTAT_AUTOPOLARITY 0x00000008 -#define DC_TSTAT_AUIACT 0x00000100 /* AUI activity */ -#define DC_TSTAT_10BTACT 0x00000200 /* 10baseT activity */ -#define DC_TSTAT_NSN 0x00000400 /* non-stable FLPs detected */ -#define DC_TSTAT_REMFAULT 0x00000800 -#define DC_TSTAT_ANEGSTAT 0x00007000 -#define DC_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */ -#define DC_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */ - -#define DC_ASTAT_DISABLE 0x00000000 -#define DC_ASTAT_TXDISABLE 0x00001000 -#define DC_ASTAT_ABDETECT 0x00002000 -#define DC_ASTAT_ACKDETECT 0x00003000 -#define DC_ASTAT_CMPACKDETECT 0x00004000 -#define DC_ASTAT_AUTONEGCMP 0x00005000 -#define DC_ASTAT_LINKCHECK 0x00006000 +#define DC_TSTAT_MIIACT 0x00000001 /* MII port activity */ +#define DC_TSTAT_LS100 0x00000002 /* link status of 100baseTX */ +#define DC_TSTAT_LS10 0x00000004 /* link status of 10baseT */ +#define DC_TSTAT_AUTOPOLARITY 0x00000008 +#define DC_TSTAT_AUIACT 0x00000100 /* AUI activity */ +#define DC_TSTAT_10BTACT 0x00000200 /* 10baseT activity */ +#define DC_TSTAT_NSN 0x00000400 /* non-stable FLPs detected */ +#define DC_TSTAT_REMFAULT 0x00000800 +#define DC_TSTAT_ANEGSTAT 0x00007000 +#define DC_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */ +#define DC_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */ + +#define DC_ASTAT_DISABLE 0x00000000 +#define DC_ASTAT_TXDISABLE 0x00001000 +#define DC_ASTAT_ABDETECT 0x00002000 +#define DC_ASTAT_ACKDETECT 0x00003000 +#define DC_ASTAT_CMPACKDETECT 0x00004000 +#define DC_ASTAT_AUTONEGCMP 0x00005000 +#define DC_ASTAT_LINKCHECK 0x00006000 /* * PHY reset register */ -#define DC_SIA_RESET 0x00000001 -#define DC_SIA_AUI 0x00000008 /* AUI or 10baseT */ +#define DC_SIA_RESET 0x00000001 +#define DC_SIA_AUI 0x00000008 /* AUI or 10baseT */ /* * 10baseT control register */ -#define DC_TCTL_ENCODER_ENB 0x00000001 -#define DC_TCTL_LOOPBACK 0x00000002 -#define DC_TCTL_DRIVER_ENB 0x00000004 -#define DC_TCTL_LNKPULSE_ENB 0x00000008 -#define DC_TCTL_HALFDUPLEX 0x00000040 -#define DC_TCTL_AUTONEGENBL 0x00000080 -#define DC_TCTL_RX_SQUELCH 0x00000100 -#define DC_TCTL_COLL_SQUELCH 0x00000200 -#define DC_TCTL_COLL_DETECT 0x00000400 -#define DC_TCTL_SQE_ENB 0x00000800 -#define DC_TCTL_LINKTEST 0x00001000 -#define DC_TCTL_AUTOPOLARITY 0x00002000 -#define DC_TCTL_SET_POL_PLUS 0x00004000 -#define DC_TCTL_AUTOSENSE 0x00008000 /* 10bt/AUI autosense */ -#define DC_TCTL_100BTXHALF 0x00010000 -#define DC_TCTL_100BTXFULL 0x00020000 -#define DC_TCTL_100BT4 0x00040000 +#define DC_TCTL_ENCODER_ENB 0x00000001 +#define DC_TCTL_LOOPBACK 0x00000002 +#define DC_TCTL_DRIVER_ENB 0x00000004 +#define DC_TCTL_LNKPULSE_ENB 0x00000008 +#define DC_TCTL_HALFDUPLEX 0x00000040 +#define DC_TCTL_AUTONEGENBL 0x00000080 +#define DC_TCTL_RX_SQUELCH 0x00000100 +#define DC_TCTL_COLL_SQUELCH 0x00000200 +#define DC_TCTL_COLL_DETECT 0x00000400 +#define DC_TCTL_SQE_ENB 0x00000800 +#define DC_TCTL_LINKTEST 0x00001000 +#define DC_TCTL_AUTOPOLARITY 0x00002000 +#define DC_TCTL_SET_POL_PLUS 0x00004000 +#define DC_TCTL_AUTOSENSE 0x00008000 /* 10bt/AUI autosense */ +#define DC_TCTL_100BTXHALF 0x00010000 +#define DC_TCTL_100BTXFULL 0x00020000 +#define DC_TCTL_100BT4 0x00040000 /* * Watchdog timer register */ -#define DC_WDOG_JABBERDIS 0x00000001 -#define DC_WDOG_HOSTUNJAB 0x00000002 -#define DC_WDOG_JABBERCLK 0x00000004 -#define DC_WDOG_RXWDOGDIS 0x00000010 -#define DC_WDOG_RXWDOGCLK 0x00000020 -#define DC_WDOG_MUSTBEZERO 0x00000100 -#define DC_WDOG_AUIBNC 0x00100000 -#define DC_WDOG_ACTIVITY 0x00200000 -#define DC_WDOG_RX_MATCH 0x00400000 -#define DC_WDOG_LINK 0x00800000 -#define DC_WDOG_CTLWREN 0x08000000 +#define DC_WDOG_JABBERDIS 0x00000001 +#define DC_WDOG_HOSTUNJAB 0x00000002 +#define DC_WDOG_JABBERCLK 0x00000004 +#define DC_WDOG_RXWDOGDIS 0x00000010 +#define DC_WDOG_RXWDOGCLK 0x00000020 +#define DC_WDOG_MUSTBEZERO 0x00000100 +#define DC_WDOG_AUIBNC 0x00100000 +#define DC_WDOG_ACTIVITY 0x00200000 +#define DC_WDOG_RX_MATCH 0x00400000 +#define DC_WDOG_LINK 0x00800000 +#define DC_WDOG_CTLWREN 0x08000000 /* * SIA and General Purpose Port register (X3201) */ -#define DC_SIAGP_RXMATCH 0x40000000 -#define DC_SIAGP_INT1 0x20000000 -#define DC_SIAGP_INT0 0x10000000 -#define DC_SIAGP_WRITE_EN 0x08000000 -#define DC_SIAGP_RXMATCH_EN 0x04000000 -#define DC_SIAGP_INT1_EN 0x02000000 -#define DC_SIAGP_INT0_EN 0x01000000 -#define DC_SIAGP_LED3 0x00800000 -#define DC_SIAGP_LED2 0x00400000 -#define DC_SIAGP_LED1 0x00200000 -#define DC_SIAGP_LED0 0x00100000 -#define DC_SIAGP_MD_GP3_OUTPUT 0x00080000 -#define DC_SIAGP_MD_GP2_OUTPUT 0x00040000 -#define DC_SIAGP_MD_GP1_OUTPUT 0x00020000 -#define DC_SIAGP_MD_GP0_OUTPUT 0x00010000 +#define DC_SIAGP_RXMATCH 0x40000000 +#define DC_SIAGP_INT1 0x20000000 +#define DC_SIAGP_INT0 0x10000000 +#define DC_SIAGP_WRITE_EN 0x08000000 +#define DC_SIAGP_RXMATCH_EN 0x04000000 +#define DC_SIAGP_INT1_EN 0x02000000 +#define DC_SIAGP_INT0_EN 0x01000000 +#define DC_SIAGP_LED3 0x00800000 +#define DC_SIAGP_LED2 0x00400000 +#define DC_SIAGP_LED1 0x00200000 +#define DC_SIAGP_LED0 0x00100000 +#define DC_SIAGP_MD_GP3_OUTPUT 0x00080000 +#define DC_SIAGP_MD_GP2_OUTPUT 0x00040000 +#define DC_SIAGP_MD_GP1_OUTPUT 0x00020000 +#define DC_SIAGP_MD_GP0_OUTPUT 0x00010000 /* * Size of a setup frame. */ -#define DC_SFRAME_LEN 192 +#define DC_SFRAME_LEN 192 /* * 21x4x TX/RX list structure. */ struct dc_desc { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 23:09:09 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB3321065673; Sun, 27 Mar 2011 23:09:09 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C75288FC15; Sun, 27 Mar 2011 23:09:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RN995N072410; Sun, 27 Mar 2011 23:09:09 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RN99bP072407; Sun, 27 Mar 2011 23:09:09 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272309.p2RN99bP072407@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:09:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220077 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:09:10 -0000 Author: yongari Date: Sun Mar 27 23:09:09 2011 New Revision: 220077 URL: http://svn.freebsd.org/changeset/base/220077 Log: MFC r218834-218835: r218834: Consistently use a tab character instead of space after #define. No functional changes. r218835: s/u_intXX_t/uintXX_t/g Modified: stable/7/sys/dev/dc/if_dc.c stable/7/sys/dev/dc/if_dcreg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:08:01 2011 (r220076) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:09:09 2011 (r220077) @@ -127,7 +127,7 @@ __FBSDID("$FreeBSD$"); #include #include -#define DC_USEIOSPACE +#define DC_USEIOSPACE #include @@ -261,16 +261,16 @@ static void dc_dma_map_addr(void *, bus_ static void dc_delay(struct dc_softc *); static void dc_eeprom_idle(struct dc_softc *); static void dc_eeprom_putbyte(struct dc_softc *, int); -static void dc_eeprom_getword(struct dc_softc *, int, u_int16_t *); -static void dc_eeprom_getword_pnic(struct dc_softc *, int, u_int16_t *); -static void dc_eeprom_getword_xircom(struct dc_softc *, int, u_int16_t *); +static void dc_eeprom_getword(struct dc_softc *, int, uint16_t *); +static void dc_eeprom_getword_pnic(struct dc_softc *, int, uint16_t *); +static void dc_eeprom_getword_xircom(struct dc_softc *, int, uint16_t *); static void dc_eeprom_width(struct dc_softc *); static void dc_read_eeprom(struct dc_softc *, caddr_t, int, int, int); static void dc_mii_writebit(struct dc_softc *, int); static int dc_mii_readbit(struct dc_softc *); static void dc_mii_sync(struct dc_softc *); -static void dc_mii_send(struct dc_softc *, u_int32_t, int); +static void dc_mii_send(struct dc_softc *, uint32_t, int); static int dc_mii_readreg(struct dc_softc *, struct dc_mii_frame *); static int dc_mii_writereg(struct dc_softc *, struct dc_mii_frame *); static int dc_miibus_readreg(device_t, int, int); @@ -301,11 +301,11 @@ static void dc_apply_fixup(struct dc_sof static int dc_check_multiport(struct dc_softc *); #ifdef DC_USEIOSPACE -#define DC_RES SYS_RES_IOPORT -#define DC_RID DC_PCI_CFBIO +#define DC_RES SYS_RES_IOPORT +#define DC_RID DC_PCI_CFBIO #else -#define DC_RES SYS_RES_MEMORY -#define DC_RID DC_PCI_CFBMA +#define DC_RES SYS_RES_MEMORY +#define DC_RID DC_PCI_CFBMA #endif static device_method_t dc_methods[] = { @@ -342,14 +342,14 @@ DRIVER_MODULE(dc, cardbus, dc_driver, dc DRIVER_MODULE(dc, pci, dc_driver, dc_devclass, 0, 0); DRIVER_MODULE(miibus, dc, miibus_driver, miibus_devclass, 0, 0); -#define DC_SETBIT(sc, reg, x) \ +#define DC_SETBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) | (x)) -#define DC_CLRBIT(sc, reg, x) \ +#define DC_CLRBIT(sc, reg, x) \ CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) & ~(x)) -#define SIO_SET(x) DC_SETBIT(sc, DC_SIO, (x)) -#define SIO_CLR(x) DC_CLRBIT(sc, DC_SIO, (x)) +#define SIO_SET(x) DC_SETBIT(sc, DC_SIO, (x)) +#define SIO_CLR(x) DC_CLRBIT(sc, DC_SIO, (x)) static void dc_delay(struct dc_softc *sc) @@ -496,10 +496,10 @@ dc_eeprom_putbyte(struct dc_softc *sc, i * the EEPROM. */ static void -dc_eeprom_getword_pnic(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword_pnic(struct dc_softc *sc, int addr, uint16_t *dest) { int i; - u_int32_t r; + uint32_t r; CSR_WRITE_4(sc, DC_PN_SIOCTL, DC_PN_EEOPCODE_READ | addr); @@ -507,7 +507,7 @@ dc_eeprom_getword_pnic(struct dc_softc * DELAY(1); r = CSR_READ_4(sc, DC_SIO); if (!(r & DC_PN_SIOCTL_BUSY)) { - *dest = (u_int16_t)(r & 0xFFFF); + *dest = (uint16_t)(r & 0xFFFF); return; } } @@ -519,17 +519,17 @@ dc_eeprom_getword_pnic(struct dc_softc * * the EEPROM, too. */ static void -dc_eeprom_getword_xircom(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword_xircom(struct dc_softc *sc, int addr, uint16_t *dest) { SIO_SET(DC_SIO_ROMSEL | DC_SIO_ROMCTL_READ); addr *= 2; CSR_WRITE_4(sc, DC_ROM, addr | 0x160); - *dest = (u_int16_t)CSR_READ_4(sc, DC_SIO) & 0xff; + *dest = (uint16_t)CSR_READ_4(sc, DC_SIO) & 0xff; addr += 1; CSR_WRITE_4(sc, DC_ROM, addr | 0x160); - *dest |= ((u_int16_t)CSR_READ_4(sc, DC_SIO) & 0xff) << 8; + *dest |= ((uint16_t)CSR_READ_4(sc, DC_SIO) & 0xff) << 8; SIO_CLR(DC_SIO_ROMSEL | DC_SIO_ROMCTL_READ); } @@ -538,10 +538,10 @@ dc_eeprom_getword_xircom(struct dc_softc * Read a word of data stored in the EEPROM at address 'addr.' */ static void -dc_eeprom_getword(struct dc_softc *sc, int addr, u_int16_t *dest) +dc_eeprom_getword(struct dc_softc *sc, int addr, uint16_t *dest) { int i; - u_int16_t word = 0; + uint16_t word = 0; /* Force EEPROM to idle state. */ dc_eeprom_idle(sc); @@ -587,7 +587,7 @@ static void dc_read_eeprom(struct dc_softc *sc, caddr_t dest, int off, int cnt, int be) { int i; - u_int16_t word = 0, *ptr; + uint16_t word = 0, *ptr; for (i = 0; i < cnt; i++) { if (DC_IS_PNIC(sc)) @@ -596,7 +596,7 @@ dc_read_eeprom(struct dc_softc *sc, cadd dc_eeprom_getword_xircom(sc, off + i, &word); else dc_eeprom_getword(sc, off + i, &word); - ptr = (u_int16_t *)(dest + (i * 2)); + ptr = (uint16_t *)(dest + (i * 2)); if (be) *ptr = be16toh(word); else @@ -681,7 +681,7 @@ dc_mii_sync(struct dc_softc *sc) * Clock a series of bits through the MII. */ static void -dc_mii_send(struct dc_softc *sc, u_int32_t bits, int cnt) +dc_mii_send(struct dc_softc *sc, uint32_t bits, int cnt) { int i; @@ -1017,9 +1017,9 @@ dc_miibus_mediainit(device_t dev) ifmedia_add(ifm, IFM_ETHER | IFM_HPNA_1, 0, NULL); } -#define DC_BITS_512 9 -#define DC_BITS_128 7 -#define DC_BITS_64 6 +#define DC_BITS_512 9 +#define DC_BITS_128 7 +#define DC_BITS_64 6 static uint32_t dc_mchash_le(struct dc_softc *sc, const uint8_t *addr) @@ -1083,7 +1083,7 @@ dc_setfilt_21143(struct dc_softc *sc) { uint16_t eaddr[(ETHER_ADDR_LEN+1)/2]; struct dc_desc *sframe; - u_int32_t h, *sp; + uint32_t h, *sp; struct ifmultiaddr *ifma; struct ifnet *ifp; int i; @@ -1157,7 +1157,7 @@ dc_setfilt_admtek(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; int h = 0; - u_int32_t hashes[2] = { 0, 0 }; + uint32_t hashes[2] = { 0, 0 }; ifp = sc->dc_ifp; @@ -1218,7 +1218,7 @@ dc_setfilt_asix(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; int h = 0; - u_int32_t hashes[2] = { 0, 0 }; + uint32_t hashes[2] = { 0, 0 }; ifp = sc->dc_ifp; @@ -1288,7 +1288,7 @@ dc_setfilt_xircom(struct dc_softc *sc) struct ifnet *ifp; struct ifmultiaddr *ifma; struct dc_desc *sframe; - u_int32_t h, *sp; + uint32_t h, *sp; int i; ifp = sc->dc_ifp; @@ -1380,7 +1380,7 @@ static void dc_setcfg(struct dc_softc *sc, int media) { int i, restart = 0, watchdogreg; - u_int32_t isr; + uint32_t isr; if (IFM_SUBTYPE(media) == IFM_NONE) return; @@ -1564,8 +1564,8 @@ static const struct dc_type * dc_devtype(device_t dev) { const struct dc_type *t; - u_int32_t devid; - u_int8_t rev; + uint32_t devid; + uint8_t rev; t = dc_devs; devid = pci_get_devid(dev); @@ -1608,9 +1608,9 @@ static void dc_apply_fixup(struct dc_softc *sc, int media) { struct dc_mediainfo *m; - u_int8_t *p; + uint8_t *p; int i; - u_int32_t reg; + uint32_t reg; m = sc->dc_mi; @@ -1669,11 +1669,11 @@ dc_decode_leaf_sia(struct dc_softc *sc, if (l->dc_sia_code & DC_SIA_CODE_EXT) { m->dc_gp_len = 2; m->dc_gp_ptr = - (u_int8_t *)&l->dc_un.dc_sia_ext.dc_sia_gpio_ctl; + (uint8_t *)&l->dc_un.dc_sia_ext.dc_sia_gpio_ctl; } else { m->dc_gp_len = 2; m->dc_gp_ptr = - (u_int8_t *)&l->dc_un.dc_sia_noext.dc_sia_gpio_ctl; + (uint8_t *)&l->dc_un.dc_sia_noext.dc_sia_gpio_ctl; } m->dc_next = sc->dc_mi; @@ -1700,7 +1700,7 @@ dc_decode_leaf_sym(struct dc_softc *sc, m->dc_media = IFM_100_TX | IFM_FDX; m->dc_gp_len = 2; - m->dc_gp_ptr = (u_int8_t *)&l->dc_sym_gpio_ctl; + m->dc_gp_ptr = (uint8_t *)&l->dc_sym_gpio_ctl; m->dc_next = sc->dc_mi; sc->dc_mi = m; @@ -1713,7 +1713,7 @@ static int dc_decode_leaf_mii(struct dc_softc *sc, struct dc_eblock_mii *l) { struct dc_mediainfo *m; - u_int8_t *p; + uint8_t *p; m = malloc(sizeof(struct dc_mediainfo), M_DEVBUF, M_NOWAIT | M_ZERO); if (m == NULL) { @@ -1724,7 +1724,7 @@ dc_decode_leaf_mii(struct dc_softc *sc, m->dc_media = IFM_AUTO; m->dc_gp_len = l->dc_gpr_len; - p = (u_int8_t *)l; + p = (uint8_t *)l; p += sizeof(struct dc_eblock_mii); m->dc_gp_ptr = p; p += 2 * l->dc_gpr_len; @@ -2032,13 +2032,13 @@ static int dc_attach(device_t dev) { uint32_t eaddr[(ETHER_ADDR_LEN+3)/4]; - u_int32_t command; + uint32_t command; struct dc_softc *sc; struct ifnet *ifp; struct dc_mediainfo *m; - u_int32_t reg, revision; + uint32_t reg, revision; int error, mac_offset, phy, rid, tmp; - u_int8_t *mac; + uint8_t *mac; sc = device_get_softc(dev); sc->dc_dev = dev; @@ -2716,7 +2716,7 @@ dc_newbuf(struct dc_softc *sc, int i) * the time. */ -#define DC_WHOLEFRAME (DC_RXSTAT_FIRSTFRAG | DC_RXSTAT_LASTFRAG) +#define DC_WHOLEFRAME (DC_RXSTAT_FIRSTFRAG | DC_RXSTAT_LASTFRAG) static void dc_pnic_rx_bug_war(struct dc_softc *sc, int idx) { @@ -2725,7 +2725,7 @@ dc_pnic_rx_bug_war(struct dc_softc *sc, struct mbuf *m = NULL; unsigned char *ptr; int i, total_len; - u_int32_t rxstat = 0; + uint32_t rxstat = 0; i = sc->dc_pnic_rx_bug_save; cur_rx = &sc->dc_ldata.dc_rx_list[idx]; @@ -2836,7 +2836,7 @@ dc_rxeof(struct dc_softc *sc) struct ifnet *ifp; struct dc_desc *cur_rx; int i, total_len; - u_int32_t rxstat; + uint32_t rxstat; DC_LOCK_ASSERT(sc); @@ -2954,7 +2954,7 @@ dc_txeof(struct dc_softc *sc) struct dc_desc *cur_tx; struct ifnet *ifp; int idx, setup; - u_int32_t ctl, txstat; + uint32_t ctl, txstat; if (sc->dc_cdata.dc_tx_cnt == 0) return; @@ -3063,7 +3063,7 @@ dc_tick(void *xsc) struct dc_softc *sc; struct mii_data *mii; struct ifnet *ifp; - u_int32_t r; + uint32_t r; sc = xsc; DC_LOCK_ASSERT(sc); @@ -3140,7 +3140,7 @@ dc_tick(void *xsc) static void dc_tx_underrun(struct dc_softc *sc) { - u_int32_t isr; + uint32_t isr; int i; if (DC_IS_DAVICOM(sc)) { @@ -3209,7 +3209,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd dc_start_locked(ifp); if (cmd == POLL_AND_CHECK_STATUS) { /* also check status register */ - u_int32_t status; + uint32_t status; status = CSR_READ_4(sc, DC_ISR); status &= (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF | @@ -3223,7 +3223,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd CSR_WRITE_4(sc, DC_ISR, status); if (status & (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF)) { - u_int32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED); + uint32_t r = CSR_READ_4(sc, DC_FRAMESDISCARDED); ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); if (dc_rx_resync(sc)) @@ -3251,7 +3251,7 @@ dc_intr(void *arg) { struct dc_softc *sc; struct ifnet *ifp; - u_int32_t r, status; + uint32_t r, status; int curpkts, n; sc = arg; @@ -3913,7 +3913,7 @@ dc_stop(struct dc_softc *sc) struct dc_list_data *ld; struct dc_chain_data *cd; int i; - u_int32_t ctl; + uint32_t ctl; DC_LOCK_ASSERT(sc); Modified: stable/7/sys/dev/dc/if_dcreg.h ============================================================================== --- stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 23:08:01 2011 (r220076) +++ stable/7/sys/dev/dc/if_dcreg.h Sun Mar 27 23:09:09 2011 (r220077) @@ -36,23 +36,23 @@ * 21143 and clone common register definitions. */ -#define DC_BUSCTL 0x00 /* bus control */ -#define DC_TXSTART 0x08 /* tx start demand */ -#define DC_RXSTART 0x10 /* rx start demand */ -#define DC_RXADDR 0x18 /* rx descriptor list start addr */ -#define DC_TXADDR 0x20 /* tx descriptor list start addr */ -#define DC_ISR 0x28 /* interrupt status register */ -#define DC_NETCFG 0x30 /* network config register */ -#define DC_IMR 0x38 /* interrupt mask */ -#define DC_FRAMESDISCARDED 0x40 /* # of discarded frames */ -#define DC_SIO 0x48 /* MII and ROM/EEPROM access */ -#define DC_ROM 0x50 /* ROM programming address */ -#define DC_TIMER 0x58 /* general timer */ -#define DC_10BTSTAT 0x60 /* SIA status */ -#define DC_SIARESET 0x68 /* SIA connectivity */ -#define DC_10BTCTRL 0x70 /* SIA transmit and receive */ -#define DC_WATCHDOG 0x78 /* SIA and general purpose port */ -#define DC_SIAGP 0x78 /* SIA and general purpose port (X3201) */ +#define DC_BUSCTL 0x00 /* bus control */ +#define DC_TXSTART 0x08 /* tx start demand */ +#define DC_RXSTART 0x10 /* rx start demand */ +#define DC_RXADDR 0x18 /* rx descriptor list start addr */ +#define DC_TXADDR 0x20 /* tx descriptor list start addr */ +#define DC_ISR 0x28 /* interrupt status register */ +#define DC_NETCFG 0x30 /* network config register */ +#define DC_IMR 0x38 /* interrupt mask */ +#define DC_FRAMESDISCARDED 0x40 /* # of discarded frames */ +#define DC_SIO 0x48 /* MII and ROM/EEPROM access */ +#define DC_ROM 0x50 /* ROM programming address */ +#define DC_TIMER 0x58 /* general timer */ +#define DC_10BTSTAT 0x60 /* SIA status */ +#define DC_SIARESET 0x68 /* SIA connectivity */ +#define DC_10BTCTRL 0x70 /* SIA transmit and receive */ +#define DC_WATCHDOG 0x78 /* SIA and general purpose port */ +#define DC_SIAGP 0x78 /* SIA and general purpose port (X3201) */ /* * There are two general 'types' of MX chips that we need to be @@ -64,427 +64,427 @@ * 'magic' numbers we write to CSR16. The PNIC II falls into the * 98713A/98715/98715A/98725 category. */ -#define DC_TYPE_98713 0x1 -#define DC_TYPE_98713A 0x2 -#define DC_TYPE_987x5 0x3 +#define DC_TYPE_98713 0x1 +#define DC_TYPE_98713A 0x2 +#define DC_TYPE_987x5 0x3 /* Other type of supported chips. */ -#define DC_TYPE_21143 0x4 /* Intel 21143 */ -#define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */ -#define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */ -#define DC_TYPE_AN983 0x7 /* ADMtek AN983 Centaur */ -#define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */ -#define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */ -#define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */ +#define DC_TYPE_21143 0x4 /* Intel 21143 */ +#define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */ +#define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */ +#define DC_TYPE_AN983 0x7 /* ADMtek AN983 Centaur */ +#define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */ +#define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */ +#define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */ #define DC_TYPE_XIRCOM 0xB /* Xircom X3201 */ -#define DC_TYPE_CONEXANT 0xC /* Conexant LANfinity RS7112 */ +#define DC_TYPE_CONEXANT 0xC /* Conexant LANfinity RS7112 */ -#define DC_IS_MACRONIX(x) \ +#define DC_IS_MACRONIX(x) \ (x->dc_type == DC_TYPE_98713 || \ x->dc_type == DC_TYPE_98713A || \ x->dc_type == DC_TYPE_987x5) -#define DC_IS_ADMTEK(x) \ +#define DC_IS_ADMTEK(x) \ (x->dc_type == DC_TYPE_AL981 || \ x->dc_type == DC_TYPE_AN983) -#define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143) -#define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX) -#define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981) -#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN983) -#define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102) -#define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII) -#define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC) +#define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143) +#define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX) +#define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981) +#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN983) +#define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102) +#define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII) +#define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC) #define DC_IS_XIRCOM(x) (x->dc_type == DC_TYPE_XIRCOM) -#define DC_IS_CONEXANT(x) (x->dc_type == DC_TYPE_CONEXANT) +#define DC_IS_CONEXANT(x) (x->dc_type == DC_TYPE_CONEXANT) /* MII/symbol mode port types */ -#define DC_PMODE_MII 0x1 -#define DC_PMODE_SYM 0x2 -#define DC_PMODE_SIA 0x3 +#define DC_PMODE_MII 0x1 +#define DC_PMODE_SYM 0x2 +#define DC_PMODE_SIA 0x3 /* * Bus control bits. */ -#define DC_BUSCTL_RESET 0x00000001 -#define DC_BUSCTL_ARBITRATION 0x00000002 -#define DC_BUSCTL_SKIPLEN 0x0000007C -#define DC_BUSCTL_BUF_BIGENDIAN 0x00000080 -#define DC_BUSCTL_BURSTLEN 0x00003F00 -#define DC_BUSCTL_CACHEALIGN 0x0000C000 -#define DC_BUSCTL_TXPOLL 0x000E0000 -#define DC_BUSCTL_DBO 0x00100000 -#define DC_BUSCTL_MRME 0x00200000 -#define DC_BUSCTL_MRLE 0x00800000 -#define DC_BUSCTL_MWIE 0x01000000 -#define DC_BUSCTL_ONNOW_ENB 0x04000000 - -#define DC_SKIPLEN_1LONG 0x00000004 -#define DC_SKIPLEN_2LONG 0x00000008 -#define DC_SKIPLEN_3LONG 0x00000010 -#define DC_SKIPLEN_4LONG 0x00000020 -#define DC_SKIPLEN_5LONG 0x00000040 - -#define DC_CACHEALIGN_NONE 0x00000000 -#define DC_CACHEALIGN_8LONG 0x00004000 -#define DC_CACHEALIGN_16LONG 0x00008000 -#define DC_CACHEALIGN_32LONG 0x0000C000 - -#define DC_BURSTLEN_USECA 0x00000000 -#define DC_BURSTLEN_1LONG 0x00000100 -#define DC_BURSTLEN_2LONG 0x00000200 -#define DC_BURSTLEN_4LONG 0x00000400 -#define DC_BURSTLEN_8LONG 0x00000800 -#define DC_BURSTLEN_16LONG 0x00001000 -#define DC_BURSTLEN_32LONG 0x00002000 - -#define DC_TXPOLL_OFF 0x00000000 -#define DC_TXPOLL_1 0x00020000 -#define DC_TXPOLL_2 0x00040000 -#define DC_TXPOLL_3 0x00060000 -#define DC_TXPOLL_4 0x00080000 -#define DC_TXPOLL_5 0x000A0000 -#define DC_TXPOLL_6 0x000C0000 -#define DC_TXPOLL_7 0x000E0000 +#define DC_BUSCTL_RESET 0x00000001 +#define DC_BUSCTL_ARBITRATION 0x00000002 +#define DC_BUSCTL_SKIPLEN 0x0000007C +#define DC_BUSCTL_BUF_BIGENDIAN 0x00000080 +#define DC_BUSCTL_BURSTLEN 0x00003F00 +#define DC_BUSCTL_CACHEALIGN 0x0000C000 +#define DC_BUSCTL_TXPOLL 0x000E0000 +#define DC_BUSCTL_DBO 0x00100000 +#define DC_BUSCTL_MRME 0x00200000 +#define DC_BUSCTL_MRLE 0x00800000 +#define DC_BUSCTL_MWIE 0x01000000 +#define DC_BUSCTL_ONNOW_ENB 0x04000000 + +#define DC_SKIPLEN_1LONG 0x00000004 +#define DC_SKIPLEN_2LONG 0x00000008 +#define DC_SKIPLEN_3LONG 0x00000010 +#define DC_SKIPLEN_4LONG 0x00000020 +#define DC_SKIPLEN_5LONG 0x00000040 + +#define DC_CACHEALIGN_NONE 0x00000000 +#define DC_CACHEALIGN_8LONG 0x00004000 +#define DC_CACHEALIGN_16LONG 0x00008000 +#define DC_CACHEALIGN_32LONG 0x0000C000 + +#define DC_BURSTLEN_USECA 0x00000000 +#define DC_BURSTLEN_1LONG 0x00000100 +#define DC_BURSTLEN_2LONG 0x00000200 +#define DC_BURSTLEN_4LONG 0x00000400 +#define DC_BURSTLEN_8LONG 0x00000800 +#define DC_BURSTLEN_16LONG 0x00001000 +#define DC_BURSTLEN_32LONG 0x00002000 + +#define DC_TXPOLL_OFF 0x00000000 +#define DC_TXPOLL_1 0x00020000 +#define DC_TXPOLL_2 0x00040000 +#define DC_TXPOLL_3 0x00060000 +#define DC_TXPOLL_4 0x00080000 +#define DC_TXPOLL_5 0x000A0000 +#define DC_TXPOLL_6 0x000C0000 +#define DC_TXPOLL_7 0x000E0000 /* * Interrupt status bits. */ -#define DC_ISR_TX_OK 0x00000001 -#define DC_ISR_TX_IDLE 0x00000002 -#define DC_ISR_TX_NOBUF 0x00000004 -#define DC_ISR_TX_JABBERTIMEO 0x00000008 -#define DC_ISR_LINKGOOD 0x00000010 -#define DC_ISR_TX_UNDERRUN 0x00000020 -#define DC_ISR_RX_OK 0x00000040 -#define DC_ISR_RX_NOBUF 0x00000080 -#define DC_ISR_RX_READ 0x00000100 -#define DC_ISR_RX_WATDOGTIMEO 0x00000200 -#define DC_ISR_TX_EARLY 0x00000400 -#define DC_ISR_TIMER_EXPIRED 0x00000800 -#define DC_ISR_LINKFAIL 0x00001000 -#define DC_ISR_BUS_ERR 0x00002000 -#define DC_ISR_RX_EARLY 0x00004000 -#define DC_ISR_ABNORMAL 0x00008000 -#define DC_ISR_NORMAL 0x00010000 -#define DC_ISR_RX_STATE 0x000E0000 -#define DC_ISR_TX_STATE 0x00700000 -#define DC_ISR_BUSERRTYPE 0x03800000 -#define DC_ISR_100MBPSLINK 0x08000000 -#define DC_ISR_MAGICKPACK 0x10000000 - -#define DC_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */ -#define DC_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */ -#define DC_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */ -#define DC_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */ -#define DC_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */ -#define DC_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */ -#define DC_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */ -#define DC_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */ +#define DC_ISR_TX_OK 0x00000001 +#define DC_ISR_TX_IDLE 0x00000002 +#define DC_ISR_TX_NOBUF 0x00000004 +#define DC_ISR_TX_JABBERTIMEO 0x00000008 +#define DC_ISR_LINKGOOD 0x00000010 +#define DC_ISR_TX_UNDERRUN 0x00000020 +#define DC_ISR_RX_OK 0x00000040 +#define DC_ISR_RX_NOBUF 0x00000080 +#define DC_ISR_RX_READ 0x00000100 +#define DC_ISR_RX_WATDOGTIMEO 0x00000200 +#define DC_ISR_TX_EARLY 0x00000400 +#define DC_ISR_TIMER_EXPIRED 0x00000800 +#define DC_ISR_LINKFAIL 0x00001000 +#define DC_ISR_BUS_ERR 0x00002000 +#define DC_ISR_RX_EARLY 0x00004000 +#define DC_ISR_ABNORMAL 0x00008000 +#define DC_ISR_NORMAL 0x00010000 +#define DC_ISR_RX_STATE 0x000E0000 +#define DC_ISR_TX_STATE 0x00700000 +#define DC_ISR_BUSERRTYPE 0x03800000 +#define DC_ISR_100MBPSLINK 0x08000000 +#define DC_ISR_MAGICKPACK 0x10000000 + +#define DC_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */ +#define DC_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */ +#define DC_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */ +#define DC_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */ +#define DC_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */ +#define DC_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */ +#define DC_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */ +#define DC_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */ #define DC_HAS_BROKEN_RXSTATE(x) \ (DC_IS_CENTAUR(x) || DC_IS_CONEXANT(x) || (DC_IS_DAVICOM(x) && \ pci_get_revid((x)->dc_dev) >= DC_REVISION_DM9102A)) -#define DC_TXSTATE_RESET 0x00000000 /* 000 - reset */ -#define DC_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */ -#define DC_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */ -#define DC_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */ -#define DC_TXSTATE_RSVD 0x00400000 /* 100 - reserved */ -#define DC_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */ -#define DC_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */ -#define DC_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */ +#define DC_TXSTATE_RESET 0x00000000 /* 000 - reset */ +#define DC_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */ +#define DC_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */ +#define DC_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */ +#define DC_TXSTATE_RSVD 0x00400000 /* 100 - reserved */ +#define DC_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */ +#define DC_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */ +#define DC_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */ /* * Network config bits. */ -#define DC_NETCFG_RX_HASHPERF 0x00000001 -#define DC_NETCFG_RX_ON 0x00000002 -#define DC_NETCFG_RX_HASHONLY 0x00000004 -#define DC_NETCFG_RX_BADFRAMES 0x00000008 -#define DC_NETCFG_RX_INVFILT 0x00000010 -#define DC_NETCFG_BACKOFFCNT 0x00000020 -#define DC_NETCFG_RX_PROMISC 0x00000040 -#define DC_NETCFG_RX_ALLMULTI 0x00000080 -#define DC_NETCFG_FULLDUPLEX 0x00000200 -#define DC_NETCFG_LOOPBACK 0x00000C00 -#define DC_NETCFG_FORCECOLL 0x00001000 -#define DC_NETCFG_TX_ON 0x00002000 -#define DC_NETCFG_TX_THRESH 0x0000C000 -#define DC_NETCFG_TX_BACKOFF 0x00020000 -#define DC_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */ -#define DC_NETCFG_HEARTBEAT 0x00080000 -#define DC_NETCFG_STORENFWD 0x00200000 -#define DC_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */ -#define DC_NETCFG_PCS 0x00800000 -#define DC_NETCFG_SCRAMBLER 0x01000000 -#define DC_NETCFG_NO_RXCRC 0x02000000 -#define DC_NETCFG_RX_ALL 0x40000000 -#define DC_NETCFG_CAPEFFECT 0x80000000 - -#define DC_OPMODE_NORM 0x00000000 -#define DC_OPMODE_INTLOOP 0x00000400 -#define DC_OPMODE_EXTLOOP 0x00000800 +#define DC_NETCFG_RX_HASHPERF 0x00000001 +#define DC_NETCFG_RX_ON 0x00000002 +#define DC_NETCFG_RX_HASHONLY 0x00000004 +#define DC_NETCFG_RX_BADFRAMES 0x00000008 +#define DC_NETCFG_RX_INVFILT 0x00000010 +#define DC_NETCFG_BACKOFFCNT 0x00000020 +#define DC_NETCFG_RX_PROMISC 0x00000040 +#define DC_NETCFG_RX_ALLMULTI 0x00000080 +#define DC_NETCFG_FULLDUPLEX 0x00000200 +#define DC_NETCFG_LOOPBACK 0x00000C00 +#define DC_NETCFG_FORCECOLL 0x00001000 +#define DC_NETCFG_TX_ON 0x00002000 +#define DC_NETCFG_TX_THRESH 0x0000C000 +#define DC_NETCFG_TX_BACKOFF 0x00020000 +#define DC_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */ +#define DC_NETCFG_HEARTBEAT 0x00080000 +#define DC_NETCFG_STORENFWD 0x00200000 +#define DC_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */ +#define DC_NETCFG_PCS 0x00800000 +#define DC_NETCFG_SCRAMBLER 0x01000000 +#define DC_NETCFG_NO_RXCRC 0x02000000 +#define DC_NETCFG_RX_ALL 0x40000000 +#define DC_NETCFG_CAPEFFECT 0x80000000 + +#define DC_OPMODE_NORM 0x00000000 +#define DC_OPMODE_INTLOOP 0x00000400 +#define DC_OPMODE_EXTLOOP 0x00000800 #if 0 -#define DC_TXTHRESH_72BYTES 0x00000000 -#define DC_TXTHRESH_96BYTES 0x00004000 -#define DC_TXTHRESH_128BYTES 0x00008000 -#define DC_TXTHRESH_160BYTES 0x0000C000 +#define DC_TXTHRESH_72BYTES 0x00000000 +#define DC_TXTHRESH_96BYTES 0x00004000 +#define DC_TXTHRESH_128BYTES 0x00008000 +#define DC_TXTHRESH_160BYTES 0x0000C000 #endif -#define DC_TXTHRESH_MIN 0x00000000 -#define DC_TXTHRESH_INC 0x00004000 -#define DC_TXTHRESH_MAX 0x0000C000 +#define DC_TXTHRESH_MIN 0x00000000 +#define DC_TXTHRESH_INC 0x00004000 +#define DC_TXTHRESH_MAX 0x0000C000 /* * Interrupt mask bits. */ -#define DC_IMR_TX_OK 0x00000001 -#define DC_IMR_TX_IDLE 0x00000002 -#define DC_IMR_TX_NOBUF 0x00000004 -#define DC_IMR_TX_JABBERTIMEO 0x00000008 -#define DC_IMR_LINKGOOD 0x00000010 -#define DC_IMR_TX_UNDERRUN 0x00000020 -#define DC_IMR_RX_OK 0x00000040 -#define DC_IMR_RX_NOBUF 0x00000080 -#define DC_IMR_RX_READ 0x00000100 -#define DC_IMR_RX_WATDOGTIMEO 0x00000200 -#define DC_IMR_TX_EARLY 0x00000400 -#define DC_IMR_TIMER_EXPIRED 0x00000800 -#define DC_IMR_LINKFAIL 0x00001000 -#define DC_IMR_BUS_ERR 0x00002000 -#define DC_IMR_RX_EARLY 0x00004000 -#define DC_IMR_ABNORMAL 0x00008000 -#define DC_IMR_NORMAL 0x00010000 -#define DC_IMR_100MBPSLINK 0x08000000 -#define DC_IMR_MAGICKPACK 0x10000000 +#define DC_IMR_TX_OK 0x00000001 +#define DC_IMR_TX_IDLE 0x00000002 +#define DC_IMR_TX_NOBUF 0x00000004 +#define DC_IMR_TX_JABBERTIMEO 0x00000008 +#define DC_IMR_LINKGOOD 0x00000010 +#define DC_IMR_TX_UNDERRUN 0x00000020 +#define DC_IMR_RX_OK 0x00000040 +#define DC_IMR_RX_NOBUF 0x00000080 +#define DC_IMR_RX_READ 0x00000100 +#define DC_IMR_RX_WATDOGTIMEO 0x00000200 +#define DC_IMR_TX_EARLY 0x00000400 +#define DC_IMR_TIMER_EXPIRED 0x00000800 +#define DC_IMR_LINKFAIL 0x00001000 +#define DC_IMR_BUS_ERR 0x00002000 +#define DC_IMR_RX_EARLY 0x00004000 +#define DC_IMR_ABNORMAL 0x00008000 +#define DC_IMR_NORMAL 0x00010000 +#define DC_IMR_100MBPSLINK 0x08000000 +#define DC_IMR_MAGICKPACK 0x10000000 -#define DC_INTRS \ +#define DC_INTRS \ (DC_IMR_RX_OK|DC_IMR_TX_OK|DC_IMR_RX_NOBUF|DC_IMR_RX_WATDOGTIMEO|\ DC_IMR_TX_NOBUF|DC_IMR_TX_UNDERRUN|DC_IMR_BUS_ERR| \ DC_IMR_ABNORMAL|DC_IMR_NORMAL/*|DC_IMR_TX_EARLY*/) /* * Serial I/O (EEPROM/ROM) bits. */ -#define DC_SIO_EE_CS 0x00000001 /* EEPROM chip select */ -#define DC_SIO_EE_CLK 0x00000002 /* EEPROM clock */ -#define DC_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */ -#define DC_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */ -#define DC_SIO_ROMDATA4 0x00000010 -#define DC_SIO_ROMDATA5 0x00000020 -#define DC_SIO_ROMDATA6 0x00000040 -#define DC_SIO_ROMDATA7 0x00000080 -#define DC_SIO_EESEL 0x00000800 -#define DC_SIO_ROMSEL 0x00001000 -#define DC_SIO_ROMCTL_WRITE 0x00002000 -#define DC_SIO_ROMCTL_READ 0x00004000 -#define DC_SIO_MII_CLK 0x00010000 /* MDIO clock */ -#define DC_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */ -#define DC_SIO_MII_DIR 0x00040000 /* MDIO dir */ -#define DC_SIO_MII_DATAIN 0x00080000 /* MDIO data in */ - -#define DC_EECMD_WRITE 0x140 -#define DC_EECMD_READ 0x180 -#define DC_EECMD_ERASE 0x1c0 +#define DC_SIO_EE_CS 0x00000001 /* EEPROM chip select */ +#define DC_SIO_EE_CLK 0x00000002 /* EEPROM clock */ +#define DC_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */ +#define DC_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */ +#define DC_SIO_ROMDATA4 0x00000010 +#define DC_SIO_ROMDATA5 0x00000020 +#define DC_SIO_ROMDATA6 0x00000040 +#define DC_SIO_ROMDATA7 0x00000080 +#define DC_SIO_EESEL 0x00000800 +#define DC_SIO_ROMSEL 0x00001000 +#define DC_SIO_ROMCTL_WRITE 0x00002000 +#define DC_SIO_ROMCTL_READ 0x00004000 +#define DC_SIO_MII_CLK 0x00010000 /* MDIO clock */ +#define DC_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */ +#define DC_SIO_MII_DIR 0x00040000 /* MDIO dir */ +#define DC_SIO_MII_DATAIN 0x00080000 /* MDIO data in */ + +#define DC_EECMD_WRITE 0x140 +#define DC_EECMD_READ 0x180 +#define DC_EECMD_ERASE 0x1c0 -#define DC_EE_NODEADDR_OFFSET 0x70 -#define DC_EE_NODEADDR 10 +#define DC_EE_NODEADDR_OFFSET 0x70 +#define DC_EE_NODEADDR 10 /* * General purpose timer register */ -#define DC_TIMER_VALUE 0x0000FFFF -#define DC_TIMER_CONTINUOUS 0x00010000 +#define DC_TIMER_VALUE 0x0000FFFF +#define DC_TIMER_CONTINUOUS 0x00010000 /* * 10baseT status register */ -#define DC_TSTAT_MIIACT 0x00000001 /* MII port activity */ -#define DC_TSTAT_LS100 0x00000002 /* link status of 100baseTX */ -#define DC_TSTAT_LS10 0x00000004 /* link status of 10baseT */ -#define DC_TSTAT_AUTOPOLARITY 0x00000008 -#define DC_TSTAT_AUIACT 0x00000100 /* AUI activity */ -#define DC_TSTAT_10BTACT 0x00000200 /* 10baseT activity */ -#define DC_TSTAT_NSN 0x00000400 /* non-stable FLPs detected */ -#define DC_TSTAT_REMFAULT 0x00000800 -#define DC_TSTAT_ANEGSTAT 0x00007000 -#define DC_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */ -#define DC_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */ - -#define DC_ASTAT_DISABLE 0x00000000 -#define DC_ASTAT_TXDISABLE 0x00001000 -#define DC_ASTAT_ABDETECT 0x00002000 -#define DC_ASTAT_ACKDETECT 0x00003000 -#define DC_ASTAT_CMPACKDETECT 0x00004000 -#define DC_ASTAT_AUTONEGCMP 0x00005000 -#define DC_ASTAT_LINKCHECK 0x00006000 +#define DC_TSTAT_MIIACT 0x00000001 /* MII port activity */ +#define DC_TSTAT_LS100 0x00000002 /* link status of 100baseTX */ +#define DC_TSTAT_LS10 0x00000004 /* link status of 10baseT */ +#define DC_TSTAT_AUTOPOLARITY 0x00000008 +#define DC_TSTAT_AUIACT 0x00000100 /* AUI activity */ +#define DC_TSTAT_10BTACT 0x00000200 /* 10baseT activity */ +#define DC_TSTAT_NSN 0x00000400 /* non-stable FLPs detected */ +#define DC_TSTAT_REMFAULT 0x00000800 +#define DC_TSTAT_ANEGSTAT 0x00007000 +#define DC_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */ +#define DC_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */ + +#define DC_ASTAT_DISABLE 0x00000000 +#define DC_ASTAT_TXDISABLE 0x00001000 +#define DC_ASTAT_ABDETECT 0x00002000 +#define DC_ASTAT_ACKDETECT 0x00003000 +#define DC_ASTAT_CMPACKDETECT 0x00004000 +#define DC_ASTAT_AUTONEGCMP 0x00005000 +#define DC_ASTAT_LINKCHECK 0x00006000 /* * PHY reset register */ -#define DC_SIA_RESET 0x00000001 -#define DC_SIA_AUI 0x00000008 /* AUI or 10baseT */ +#define DC_SIA_RESET 0x00000001 +#define DC_SIA_AUI 0x00000008 /* AUI or 10baseT */ /* * 10baseT control register */ -#define DC_TCTL_ENCODER_ENB 0x00000001 -#define DC_TCTL_LOOPBACK 0x00000002 -#define DC_TCTL_DRIVER_ENB 0x00000004 -#define DC_TCTL_LNKPULSE_ENB 0x00000008 -#define DC_TCTL_HALFDUPLEX 0x00000040 -#define DC_TCTL_AUTONEGENBL 0x00000080 -#define DC_TCTL_RX_SQUELCH 0x00000100 -#define DC_TCTL_COLL_SQUELCH 0x00000200 -#define DC_TCTL_COLL_DETECT 0x00000400 -#define DC_TCTL_SQE_ENB 0x00000800 -#define DC_TCTL_LINKTEST 0x00001000 -#define DC_TCTL_AUTOPOLARITY 0x00002000 -#define DC_TCTL_SET_POL_PLUS 0x00004000 -#define DC_TCTL_AUTOSENSE 0x00008000 /* 10bt/AUI autosense */ -#define DC_TCTL_100BTXHALF 0x00010000 -#define DC_TCTL_100BTXFULL 0x00020000 -#define DC_TCTL_100BT4 0x00040000 +#define DC_TCTL_ENCODER_ENB 0x00000001 +#define DC_TCTL_LOOPBACK 0x00000002 +#define DC_TCTL_DRIVER_ENB 0x00000004 +#define DC_TCTL_LNKPULSE_ENB 0x00000008 +#define DC_TCTL_HALFDUPLEX 0x00000040 +#define DC_TCTL_AUTONEGENBL 0x00000080 +#define DC_TCTL_RX_SQUELCH 0x00000100 +#define DC_TCTL_COLL_SQUELCH 0x00000200 +#define DC_TCTL_COLL_DETECT 0x00000400 +#define DC_TCTL_SQE_ENB 0x00000800 +#define DC_TCTL_LINKTEST 0x00001000 +#define DC_TCTL_AUTOPOLARITY 0x00002000 +#define DC_TCTL_SET_POL_PLUS 0x00004000 +#define DC_TCTL_AUTOSENSE 0x00008000 /* 10bt/AUI autosense */ +#define DC_TCTL_100BTXHALF 0x00010000 +#define DC_TCTL_100BTXFULL 0x00020000 +#define DC_TCTL_100BT4 0x00040000 /* * Watchdog timer register */ -#define DC_WDOG_JABBERDIS 0x00000001 -#define DC_WDOG_HOSTUNJAB 0x00000002 -#define DC_WDOG_JABBERCLK 0x00000004 -#define DC_WDOG_RXWDOGDIS 0x00000010 -#define DC_WDOG_RXWDOGCLK 0x00000020 -#define DC_WDOG_MUSTBEZERO 0x00000100 -#define DC_WDOG_AUIBNC 0x00100000 -#define DC_WDOG_ACTIVITY 0x00200000 -#define DC_WDOG_RX_MATCH 0x00400000 -#define DC_WDOG_LINK 0x00800000 -#define DC_WDOG_CTLWREN 0x08000000 +#define DC_WDOG_JABBERDIS 0x00000001 +#define DC_WDOG_HOSTUNJAB 0x00000002 +#define DC_WDOG_JABBERCLK 0x00000004 +#define DC_WDOG_RXWDOGDIS 0x00000010 +#define DC_WDOG_RXWDOGCLK 0x00000020 +#define DC_WDOG_MUSTBEZERO 0x00000100 +#define DC_WDOG_AUIBNC 0x00100000 +#define DC_WDOG_ACTIVITY 0x00200000 +#define DC_WDOG_RX_MATCH 0x00400000 +#define DC_WDOG_LINK 0x00800000 +#define DC_WDOG_CTLWREN 0x08000000 /* * SIA and General Purpose Port register (X3201) */ -#define DC_SIAGP_RXMATCH 0x40000000 -#define DC_SIAGP_INT1 0x20000000 -#define DC_SIAGP_INT0 0x10000000 -#define DC_SIAGP_WRITE_EN 0x08000000 -#define DC_SIAGP_RXMATCH_EN 0x04000000 -#define DC_SIAGP_INT1_EN 0x02000000 -#define DC_SIAGP_INT0_EN 0x01000000 -#define DC_SIAGP_LED3 0x00800000 -#define DC_SIAGP_LED2 0x00400000 -#define DC_SIAGP_LED1 0x00200000 -#define DC_SIAGP_LED0 0x00100000 -#define DC_SIAGP_MD_GP3_OUTPUT 0x00080000 -#define DC_SIAGP_MD_GP2_OUTPUT 0x00040000 -#define DC_SIAGP_MD_GP1_OUTPUT 0x00020000 -#define DC_SIAGP_MD_GP0_OUTPUT 0x00010000 +#define DC_SIAGP_RXMATCH 0x40000000 +#define DC_SIAGP_INT1 0x20000000 +#define DC_SIAGP_INT0 0x10000000 +#define DC_SIAGP_WRITE_EN 0x08000000 +#define DC_SIAGP_RXMATCH_EN 0x04000000 +#define DC_SIAGP_INT1_EN 0x02000000 +#define DC_SIAGP_INT0_EN 0x01000000 +#define DC_SIAGP_LED3 0x00800000 +#define DC_SIAGP_LED2 0x00400000 +#define DC_SIAGP_LED1 0x00200000 +#define DC_SIAGP_LED0 0x00100000 +#define DC_SIAGP_MD_GP3_OUTPUT 0x00080000 +#define DC_SIAGP_MD_GP2_OUTPUT 0x00040000 +#define DC_SIAGP_MD_GP1_OUTPUT 0x00020000 +#define DC_SIAGP_MD_GP0_OUTPUT 0x00010000 /* * Size of a setup frame. */ -#define DC_SFRAME_LEN 192 +#define DC_SFRAME_LEN 192 /* * 21x4x TX/RX list structure. */ struct dc_desc { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 23:13:02 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 94BE2106566C; Sun, 27 Mar 2011 23:13:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 81AD98FC14; Sun, 27 Mar 2011 23:13:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RND2du072575; Sun, 27 Mar 2011 23:13:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RND2sg072573; Sun, 27 Mar 2011 23:13:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272313.p2RND2sg072573@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:13:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220078 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:13:02 -0000 Author: yongari Date: Sun Mar 27 23:13:02 2011 New Revision: 220078 URL: http://svn.freebsd.org/changeset/base/220078 Log: MFC r219407: Rearrange dc_tx_underrun() a bit to correctly set TX FIFO threshold value. Controllers that always require "store and forward" mode( Davicom and PNIC 82C168) have no way to recover from TX underrun except completely reinitializing hardware. Previously only Davicom was reinitialized and the TX FIFO threshold was changed not to use "store and forward" mode after reinitialization since the default FIFO threshold value was 0. This effectively disabled Davicom controller's "store and forward" mode once it encountered TX underruns. In theory, this can cause watchodg timeouts. Intel 21143 controller requires TX MAC should be idle before changing TX FIFO threshold. So driver tried to disable TX MAC and checked whether it saw the idle state of TX MAC. Driver should perform full hardware reinitialization on failing to enter to idle state and it should not touch TX MAC again once it performed full reinitialization. While I'm here remove resetting TX FIFO threshold to 0 when interface is put into down state. If driver ever encountered TX underrun, it's likely to trigger TX underrun again whenever interface is brought to up again. Keeping old/learned TX FIFO threshold value shall reduce the chance of seeing TX underrns in next run. Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:09:09 2011 (r220077) +++ stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:13:02 2011 (r220078) @@ -3142,50 +3142,57 @@ dc_tick(void *xsc) static void dc_tx_underrun(struct dc_softc *sc) { - uint32_t isr; - int i; + uint32_t netcfg, isr; + int i, reinit; - if (DC_IS_DAVICOM(sc)) { - sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - dc_init_locked(sc); - } - - if (DC_IS_INTEL(sc)) { - /* - * The real 21143 requires that the transmitter be idle - * in order to change the transmit threshold or store - * and forward state. - */ - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); - - for (i = 0; i < DC_TIMEOUT; i++) { - isr = CSR_READ_4(sc, DC_ISR); - if (isr & DC_ISR_TX_IDLE) - break; - DELAY(10); - } - if (i == DC_TIMEOUT) { - device_printf(sc->dc_dev, - "%s: failed to force tx to idle state\n", - __func__); - sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - dc_init_locked(sc); + reinit = 0; + netcfg = CSR_READ_4(sc, DC_NETCFG); + device_printf(sc->dc_dev, "TX underrun -- "); + if ((sc->dc_flags & DC_TX_STORENFWD) == 0) { + if (sc->dc_txthresh + DC_TXTHRESH_INC > DC_TXTHRESH_MAX) { + printf("using store and forward mode\n"); + netcfg |= DC_NETCFG_STORENFWD; + } else { + printf("increasing TX threshold\n"); + sc->dc_txthresh += DC_TXTHRESH_INC; + netcfg &= ~DC_NETCFG_TX_THRESH; + netcfg |= sc->dc_txthresh; + } + + if (DC_IS_INTEL(sc)) { + /* + * The real 21143 requires that the transmitter be idle + * in order to change the transmit threshold or store + * and forward state. + */ + CSR_WRITE_4(sc, DC_NETCFG, netcfg & ~DC_NETCFG_TX_ON); + + for (i = 0; i < DC_TIMEOUT; i++) { + isr = CSR_READ_4(sc, DC_ISR); + if (isr & DC_ISR_TX_IDLE) + break; + DELAY(10); + } + if (i == DC_TIMEOUT) { + device_printf(sc->dc_dev, + "%s: failed to force tx to idle state\n", + __func__); + reinit++; + } } + } else { + printf("resetting\n"); + reinit++; } - device_printf(sc->dc_dev, "TX underrun -- "); - sc->dc_txthresh += DC_TXTHRESH_INC; - if (sc->dc_txthresh > DC_TXTHRESH_MAX) { - printf("using store and forward mode\n"); - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_STORENFWD); + if (reinit == 0) { + CSR_WRITE_4(sc, DC_NETCFG, netcfg); + if (DC_IS_INTEL(sc)) + CSR_WRITE_4(sc, DC_NETCFG, netcfg | DC_NETCFG_TX_ON); } else { - printf("increasing TX threshold\n"); - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_THRESH); - DC_SETBIT(sc, DC_NETCFG, sc->dc_txthresh); + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + dc_init_locked(sc); } - - if (DC_IS_INTEL(sc)) - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); } #ifdef DEVICE_POLLING @@ -3825,7 +3832,6 @@ dc_ioctl(struct ifnet *ifp, u_long comma if (need_setfilt) dc_setfilt(sc); } else { - sc->dc_txthresh = 0; ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } From owner-svn-src-stable@FreeBSD.ORG Sun Mar 27 23:14:02 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4B281065676; Sun, 27 Mar 2011 23:14:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 91C348FC19; Sun, 27 Mar 2011 23:14:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2RNE2XF072628; Sun, 27 Mar 2011 23:14:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2RNE22p072626; Sun, 27 Mar 2011 23:14:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103272314.p2RNE22p072626@svn.freebsd.org> From: Pyun YongHyeon Date: Sun, 27 Mar 2011 23:14:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220079 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Mar 2011 23:14:02 -0000 Author: yongari Date: Sun Mar 27 23:14:02 2011 New Revision: 220079 URL: http://svn.freebsd.org/changeset/base/220079 Log: MFC r219407: Rearrange dc_tx_underrun() a bit to correctly set TX FIFO threshold value. Controllers that always require "store and forward" mode( Davicom and PNIC 82C168) have no way to recover from TX underrun except completely reinitializing hardware. Previously only Davicom was reinitialized and the TX FIFO threshold was changed not to use "store and forward" mode after reinitialization since the default FIFO threshold value was 0. This effectively disabled Davicom controller's "store and forward" mode once it encountered TX underruns. In theory, this can cause watchodg timeouts. Intel 21143 controller requires TX MAC should be idle before changing TX FIFO threshold. So driver tried to disable TX MAC and checked whether it saw the idle state of TX MAC. Driver should perform full hardware reinitialization on failing to enter to idle state and it should not touch TX MAC again once it performed full reinitialization. While I'm here remove resetting TX FIFO threshold to 0 when interface is put into down state. If driver ever encountered TX underrun, it's likely to trigger TX underrun again whenever interface is brought to up again. Keeping old/learned TX FIFO threshold value shall reduce the chance of seeing TX underrns in next run. Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:13:02 2011 (r220078) +++ stable/7/sys/dev/dc/if_dc.c Sun Mar 27 23:14:02 2011 (r220079) @@ -3140,50 +3140,57 @@ dc_tick(void *xsc) static void dc_tx_underrun(struct dc_softc *sc) { - uint32_t isr; - int i; + uint32_t netcfg, isr; + int i, reinit; - if (DC_IS_DAVICOM(sc)) { - sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - dc_init_locked(sc); - } - - if (DC_IS_INTEL(sc)) { - /* - * The real 21143 requires that the transmitter be idle - * in order to change the transmit threshold or store - * and forward state. - */ - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); - - for (i = 0; i < DC_TIMEOUT; i++) { - isr = CSR_READ_4(sc, DC_ISR); - if (isr & DC_ISR_TX_IDLE) - break; - DELAY(10); - } - if (i == DC_TIMEOUT) { - device_printf(sc->dc_dev, - "%s: failed to force tx to idle state\n", - __func__); - sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; - dc_init_locked(sc); + reinit = 0; + netcfg = CSR_READ_4(sc, DC_NETCFG); + device_printf(sc->dc_dev, "TX underrun -- "); + if ((sc->dc_flags & DC_TX_STORENFWD) == 0) { + if (sc->dc_txthresh + DC_TXTHRESH_INC > DC_TXTHRESH_MAX) { + printf("using store and forward mode\n"); + netcfg |= DC_NETCFG_STORENFWD; + } else { + printf("increasing TX threshold\n"); + sc->dc_txthresh += DC_TXTHRESH_INC; + netcfg &= ~DC_NETCFG_TX_THRESH; + netcfg |= sc->dc_txthresh; + } + + if (DC_IS_INTEL(sc)) { + /* + * The real 21143 requires that the transmitter be idle + * in order to change the transmit threshold or store + * and forward state. + */ + CSR_WRITE_4(sc, DC_NETCFG, netcfg & ~DC_NETCFG_TX_ON); + + for (i = 0; i < DC_TIMEOUT; i++) { + isr = CSR_READ_4(sc, DC_ISR); + if (isr & DC_ISR_TX_IDLE) + break; + DELAY(10); + } + if (i == DC_TIMEOUT) { + device_printf(sc->dc_dev, + "%s: failed to force tx to idle state\n", + __func__); + reinit++; + } } + } else { + printf("resetting\n"); + reinit++; } - device_printf(sc->dc_dev, "TX underrun -- "); - sc->dc_txthresh += DC_TXTHRESH_INC; - if (sc->dc_txthresh > DC_TXTHRESH_MAX) { - printf("using store and forward mode\n"); - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_STORENFWD); + if (reinit == 0) { + CSR_WRITE_4(sc, DC_NETCFG, netcfg); + if (DC_IS_INTEL(sc)) + CSR_WRITE_4(sc, DC_NETCFG, netcfg | DC_NETCFG_TX_ON); } else { - printf("increasing TX threshold\n"); - DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_THRESH); - DC_SETBIT(sc, DC_NETCFG, sc->dc_txthresh); + sc->dc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING; + dc_init_locked(sc); } - - if (DC_IS_INTEL(sc)) - DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON); } #ifdef DEVICE_POLLING @@ -3821,7 +3828,6 @@ dc_ioctl(struct ifnet *ifp, u_long comma if (need_setfilt) dc_setfilt(sc); } else { - sc->dc_txthresh = 0; ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); } From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 00:13:42 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 566361065674; Mon, 28 Mar 2011 00:13:42 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 37DC98FC0C; Mon, 28 Mar 2011 00:13:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S0Dg9v073954; Mon, 28 Mar 2011 00:13:42 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S0DgkO073952; Mon, 28 Mar 2011 00:13:42 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103280013.p2S0DgkO073952@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 00:13:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220083 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:13:42 -0000 Author: yongari Date: Mon Mar 28 00:13:41 2011 New Revision: 220083 URL: http://svn.freebsd.org/changeset/base/220083 Log: MFC r219701: Remove too expensive bus_dmamap_sync(9) call in dc_rx_resync(). With this change, driver may not notice updated descriptor status change when bounce buffers are active. However, rxeof() in next run will handle the synchronization. Change dc_rxeof() a bit to return the number of processed frames in RX descriptor ring. Previously it returned the number of frames that were successfully passed to upper stack which in turn means it ignored frames that were discarded due to errors. The number of processed frames in RX descriptor ring is used to detect whether driver is out of sync with controller's current descriptor pointer. Returning number of processed frames reduces unnecessary (probably wrong) re-synchronization. Reviewed by: marius Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Sun Mar 27 23:46:52 2011 (r220082) +++ stable/8/sys/dev/dc/if_dc.c Mon Mar 28 00:13:41 2011 (r220083) @@ -2790,8 +2790,6 @@ dc_rx_resync(struct dc_softc *sc) pos = sc->dc_cdata.dc_rx_prod; for (i = 0; i < DC_RX_LIST_CNT; i++) { - bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); cur_rx = &sc->dc_ldata.dc_rx_list[pos]; if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) break; @@ -2862,6 +2860,7 @@ dc_rxeof(struct dc_softc *sc) bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_POSTREAD); total_len = DC_RXBYTES(rxstat); + rx_npkts++; if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) { @@ -2939,7 +2938,6 @@ dc_rxeof(struct dc_softc *sc) DC_UNLOCK(sc); (*ifp->if_input)(ifp, m); DC_LOCK(sc); - rx_npkts++; } sc->dc_cdata.dc_rx_prod = i; @@ -3263,7 +3261,7 @@ dc_intr(void *arg) struct dc_softc *sc; struct ifnet *ifp; uint32_t r, status; - int curpkts, n; + int n; sc = arg; @@ -3293,9 +3291,7 @@ dc_intr(void *arg) CSR_WRITE_4(sc, DC_ISR, status); if (status & DC_ISR_RX_OK) { - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); } @@ -3319,9 +3315,7 @@ dc_intr(void *arg) || (status & DC_ISR_RX_NOBUF)) { r = CSR_READ_4(sc, DC_FRAMESDISCARDED); ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); } From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 00:14:56 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 988B61065672; Mon, 28 Mar 2011 00:14:56 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 84A708FC12; Mon, 28 Mar 2011 00:14:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S0Eu2u074010; Mon, 28 Mar 2011 00:14:56 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S0Eu5w074008; Mon, 28 Mar 2011 00:14:56 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103280014.p2S0Eu5w074008@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 00:14:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220084 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:14:56 -0000 Author: yongari Date: Mon Mar 28 00:14:56 2011 New Revision: 220084 URL: http://svn.freebsd.org/changeset/base/220084 Log: MFC r219701: Remove too expensive bus_dmamap_sync(9) call in dc_rx_resync(). With this change, driver may not notice updated descriptor status change when bounce buffers are active. However, rxeof() in next run will handle the synchronization. Change dc_rxeof() a bit to return the number of processed frames in RX descriptor ring. Previously it returned the number of frames that were successfully passed to upper stack which in turn means it ignored frames that were discarded due to errors. The number of processed frames in RX descriptor ring is used to detect whether driver is out of sync with controller's current descriptor pointer. Returning number of processed frames reduces unnecessary (probably wrong) re-synchronization. Reviewed by: marius Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:13:41 2011 (r220083) +++ stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:14:56 2011 (r220084) @@ -238,7 +238,7 @@ static int dc_newbuf(struct dc_softc *, static int dc_encap(struct dc_softc *, struct mbuf **); static void dc_pnic_rx_bug_war(struct dc_softc *, int); static int dc_rx_resync(struct dc_softc *); -static void dc_rxeof(struct dc_softc *); +static int dc_rxeof(struct dc_softc *); static void dc_txeof(struct dc_softc *); static void dc_tick(void *); static void dc_tx_underrun(struct dc_softc *); @@ -2791,8 +2791,6 @@ dc_rx_resync(struct dc_softc *sc) pos = sc->dc_cdata.dc_rx_prod; for (i = 0; i < DC_RX_LIST_CNT; i++) { - bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, - BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); cur_rx = &sc->dc_ldata.dc_rx_list[pos]; if (!(le32toh(cur_rx->dc_status) & DC_RXSTAT_OWN)) break; @@ -2829,18 +2827,19 @@ dc_discard_rxbuf(struct dc_softc *sc, in * A frame has been uploaded: pass the resulting mbuf chain up to * the higher level protocols. */ -static void +static int dc_rxeof(struct dc_softc *sc) { struct mbuf *m; struct ifnet *ifp; struct dc_desc *cur_rx; - int i, total_len; + int i, total_len, rx_npkts; uint32_t rxstat; DC_LOCK_ASSERT(sc); ifp = sc->dc_ifp; + rx_npkts = 0; bus_dmamap_sync(sc->dc_rx_ltag, sc->dc_rx_lmap, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); @@ -2862,6 +2861,7 @@ dc_rxeof(struct dc_softc *sc) bus_dmamap_sync(sc->dc_rx_mtag, sc->dc_cdata.dc_rx_map[i], BUS_DMASYNC_POSTREAD); total_len = DC_RXBYTES(rxstat); + rx_npkts++; if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) { if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) { @@ -2896,7 +2896,7 @@ dc_rxeof(struct dc_softc *sc) else { ifp->if_drv_flags &= ~IFF_DRV_RUNNING; dc_init_locked(sc); - return; + return (rx_npkts); } } } @@ -2942,6 +2942,7 @@ dc_rxeof(struct dc_softc *sc) } sc->dc_cdata.dc_rx_prod = i; + return (rx_npkts); } /* @@ -3259,7 +3260,7 @@ dc_intr(void *arg) struct dc_softc *sc; struct ifnet *ifp; uint32_t r, status; - int curpkts, n; + int n; sc = arg; @@ -3289,9 +3290,7 @@ dc_intr(void *arg) CSR_WRITE_4(sc, DC_ISR, status); if (status & DC_ISR_RX_OK) { - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); } @@ -3315,9 +3314,7 @@ dc_intr(void *arg) || (status & DC_ISR_RX_NOBUF)) { r = CSR_READ_4(sc, DC_FRAMESDISCARDED); ifp->if_ierrors += (r & 0xffff) + ((r >> 17) & 0x7ff); - curpkts = ifp->if_ipackets; - dc_rxeof(sc); - if (curpkts == ifp->if_ipackets) { + if (dc_rxeof(sc) == 0) { while (dc_rx_resync(sc)) dc_rxeof(sc); } From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 00:18:02 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F0763106564A; Mon, 28 Mar 2011 00:18:02 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DCC688FC0A; Mon, 28 Mar 2011 00:18:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S0I2cv074135; Mon, 28 Mar 2011 00:18:02 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S0I2J8074133; Mon, 28 Mar 2011 00:18:02 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103280018.p2S0I2J8074133@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 00:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220085 - stable/8/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:18:03 -0000 Author: yongari Date: Mon Mar 28 00:18:02 2011 New Revision: 220085 URL: http://svn.freebsd.org/changeset/base/220085 Log: MFC r201449: Fix CardBus spelling. Modified: stable/8/sys/dev/dc/if_dc.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/dc/if_dc.c ============================================================================== --- stable/8/sys/dev/dc/if_dc.c Mon Mar 28 00:14:56 2011 (r220084) +++ stable/8/sys/dev/dc/if_dc.c Mon Mar 28 00:18:02 2011 (r220085) @@ -44,8 +44,8 @@ __FBSDID("$FreeBSD$"); * ASIX Electronics AX88141 (www.asix.com.tw) * ADMtek AL981 (www.admtek.com.tw) * ADMtek AN983 (www.admtek.com.tw) - * ADMtek cardbus AN985 (www.admtek.com.tw) - * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek cardbus AN985 + * ADMtek CardBus AN985 (www.admtek.com.tw) + * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek CardBus AN985 * Davicom DM9100, DM9102, DM9102A (www.davicom8.com) * Accton EN1217 (www.accton.com) * Xircom X3201 (www.xircom.com) @@ -165,7 +165,7 @@ static const struct dc_type dc_devs[] = { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983), 0, "ADMtek AN983 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985), 0, - "ADMtek AN985 cardBus 10/100BaseTX or clone" }, + "ADMtek AN985 CardBus 10/100BaseTX or clone" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9511), 0, "ADMtek ADM9511 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9513), 0, From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 00:19:01 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 72187106566B; Mon, 28 Mar 2011 00:19:01 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E69A8FC19; Mon, 28 Mar 2011 00:19:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S0J1rE074185; Mon, 28 Mar 2011 00:19:01 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S0J1aR074183; Mon, 28 Mar 2011 00:19:01 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201103280019.p2S0J1aR074183@svn.freebsd.org> From: Pyun YongHyeon Date: Mon, 28 Mar 2011 00:19:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220086 - stable/7/sys/dev/dc X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 00:19:01 -0000 Author: yongari Date: Mon Mar 28 00:19:01 2011 New Revision: 220086 URL: http://svn.freebsd.org/changeset/base/220086 Log: MFC r201449: Fix CardBus spelling. Modified: stable/7/sys/dev/dc/if_dc.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/dc/if_dc.c ============================================================================== --- stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:18:02 2011 (r220085) +++ stable/7/sys/dev/dc/if_dc.c Mon Mar 28 00:19:01 2011 (r220086) @@ -44,8 +44,8 @@ __FBSDID("$FreeBSD$"); * ASIX Electronics AX88141 (www.asix.com.tw) * ADMtek AL981 (www.admtek.com.tw) * ADMtek AN983 (www.admtek.com.tw) - * ADMtek cardbus AN985 (www.admtek.com.tw) - * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek cardbus AN985 + * ADMtek CardBus AN985 (www.admtek.com.tw) + * Netgear FA511 (www.netgear.com) Appears to be rebadged ADMTek CardBus AN985 * Davicom DM9100, DM9102, DM9102A (www.davicom8.com) * Accton EN1217 (www.accton.com) * Xircom X3201 (www.xircom.com) @@ -165,7 +165,7 @@ static const struct dc_type dc_devs[] = { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN983), 0, "ADMtek AN983 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_AN985), 0, - "ADMtek AN985 cardBus 10/100BaseTX or clone" }, + "ADMtek AN985 CardBus 10/100BaseTX or clone" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9511), 0, "ADMtek ADM9511 10/100BaseTX" }, { DC_DEVID(DC_VENDORID_ADMTEK, DC_DEVICEID_ADM9513), 0, From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 01:24:21 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F8E41065672; Mon, 28 Mar 2011 01:24:21 +0000 (UTC) (envelope-from kevlo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 335B58FC0C; Mon, 28 Mar 2011 01:24:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S1OLnI075546; Mon, 28 Mar 2011 01:24:21 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S1OLnm075544; Mon, 28 Mar 2011 01:24:21 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201103280124.p2S1OLnm075544@svn.freebsd.org> From: Kevin Lo Date: Mon, 28 Mar 2011 01:24:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220087 - stable/8/sys/dev/usb/wlan X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 01:24:21 -0000 Author: kevlo Date: Mon Mar 28 01:24:20 2011 New Revision: 220087 URL: http://svn.freebsd.org/changeset/base/220087 Log: MFC r219982: Fix panic while associating access point. While here, add the SMC SMCWUSB-G Modified: stable/8/sys/dev/usb/wlan/if_zyd.c Modified: stable/8/sys/dev/usb/wlan/if_zyd.c ============================================================================== --- stable/8/sys/dev/usb/wlan/if_zyd.c Mon Mar 28 00:19:01 2011 (r220086) +++ stable/8/sys/dev/usb/wlan/if_zyd.c Mon Mar 28 01:24:20 2011 (r220087) @@ -229,6 +229,7 @@ static const struct usb_device_id zyd_de ZYD_ZD1211_DEV(ZYXEL, ZYAIRG220), ZYD_ZD1211_DEV(ZYXEL, G200V2), /* ZYD_ZD1211B */ + ZYD_ZD1211B_DEV(ACCTON, SMCWUSBG_NF), ZYD_ZD1211B_DEV(ACCTON, SMCWUSBG), ZYD_ZD1211B_DEV(ACCTON, ZD1211B), ZYD_ZD1211B_DEV(ASUS, A9T_WIFI), @@ -510,9 +511,6 @@ zyd_tx_free(struct zyd_tx_data *data, in m_freem(data->m); data->m = NULL; - if (txerr == 0) - ieee80211_ratectl_tx_complete(data->ni->ni_vap, - data->ni, IEEE80211_RATECTL_TX_SUCCESS, NULL, NULL); ieee80211_free_node(data->ni); data->ni = NULL; } From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 08:22:14 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1634C106566B; Mon, 28 Mar 2011 08:22:14 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DF5AA8FC1C; Mon, 28 Mar 2011 08:22:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S8MDwa086451; Mon, 28 Mar 2011 08:22:13 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S8MDKe086449; Mon, 28 Mar 2011 08:22:13 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103280822.p2S8MDKe086449@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 08:22:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220092 - stable/8/sys/compat/freebsd32 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 08:22:14 -0000 Author: kib Date: Mon Mar 28 08:22:13 2011 New Revision: 220092 URL: http://svn.freebsd.org/changeset/base/220092 Log: MFC r219986: Fix file leakage in the freebsd32_ioctl routines. Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Mon Mar 28 07:00:41 2011 (r220091) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Mon Mar 28 08:22:13 2011 (r220092) @@ -70,7 +70,6 @@ freebsd32_ioctl_md(struct thread *td, st panic("%s: where is my ioctl data??", __func__); if (uap->com & IOC_IN) { if ((error = copyin(uap->data, &md32, sizeof(md32)))) { - fdrop(fp, td); return (error); } CP(md32, mdv, md_version); @@ -121,7 +120,6 @@ freebsd32_ioctl_md(struct thread *td, st CP(mdv, md32, md_fwsectors); error = copyout(&md32, uap->data, sizeof(md32)); } - fdrop(fp, td); return error; } @@ -144,7 +142,6 @@ freebsd32_ioctl_ioc_toc_header(struct th CP(toch32, toch, ending_track); error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&toch, td->td_ucred, td); - fdrop(fp, td); return (error); } @@ -175,7 +172,6 @@ freebsd32_ioctl_ioc_read_toc(struct thre PTROUT_CP(toce, toce32, data); error = copyout(&toce32, uap->data, sizeof(toce32)); } - fdrop(fp, td); return error; } @@ -192,7 +188,6 @@ freebsd32_ioctl_fiodgname(struct thread CP(fgn32, fgn, len); PTRIN_CP(fgn32, fgn, buf); error = fo_ioctl(fp, FIODGNAME, (caddr_t)&fgn, td->td_ucred, td); - fdrop(fp, td); return (error); } @@ -219,16 +214,20 @@ freebsd32_ioctl(struct thread *td, struc case MDIOCDETACH_32: /* FALLTHROUGH */ case MDIOCQUERY_32: /* FALLTHROUGH */ case MDIOCLIST_32: - return freebsd32_ioctl_md(td, uap, fp); + error = freebsd32_ioctl_md(td, uap, fp); + break; case CDIOREADTOCENTRYS_32: - return freebsd32_ioctl_ioc_read_toc(td, uap, fp); + error = freebsd32_ioctl_ioc_read_toc(td, uap, fp); + break; case CDIOREADTOCHEADER_32: - return freebsd32_ioctl_ioc_toc_header(td, uap, fp); + error = freebsd32_ioctl_ioc_toc_header(td, uap, fp); + break; case FIODGNAME_32: - return freebsd32_ioctl_fiodgname(td, uap, fp); + error = freebsd32_ioctl_fiodgname(td, uap, fp); + break; default: fdrop(fp, td); @@ -237,4 +236,7 @@ freebsd32_ioctl(struct thread *td, struc PTRIN_CP(*uap, ap, data); return ioctl(td, &ap); } + + fdrop(fp, td); + return error; } From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 08:23:46 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55AB5106566C; Mon, 28 Mar 2011 08:23:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 452038FC13; Mon, 28 Mar 2011 08:23:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2S8NkAv086537; Mon, 28 Mar 2011 08:23:46 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2S8NkVD086535; Mon, 28 Mar 2011 08:23:46 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201103280823.p2S8NkVD086535@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 28 Mar 2011 08:23:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220093 - stable/8/sys/compat/freebsd32 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 08:23:46 -0000 Author: kib Date: Mon Mar 28 08:23:45 2011 New Revision: 220093 URL: http://svn.freebsd.org/changeset/base/220093 Log: MFC r219987: Remove unneccessary panics. Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Mon Mar 28 08:22:13 2011 (r220092) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Mon Mar 28 08:23:45 2011 (r220093) @@ -66,8 +66,6 @@ freebsd32_ioctl_md(struct thread *td, st u_long com = 0; int error; - if (uap->data == NULL) - panic("%s: where is my ioctl data??", __func__); if (uap->com & IOC_IN) { if ((error = copyin(uap->data, &md32, sizeof(md32)))) { return (error); @@ -132,9 +130,6 @@ freebsd32_ioctl_ioc_toc_header(struct th struct ioc_toc_header32 toch32; int error; - if (uap->data == NULL) - panic("%s: where is my ioctl data??", __func__); - if ((error = copyin(uap->data, &toch32, sizeof(toch32)))) return (error); CP(toch32, toch, len); @@ -154,9 +149,6 @@ freebsd32_ioctl_ioc_read_toc(struct thre struct ioc_read_toc_entry32 toce32; int error; - if (uap->data == NULL) - panic("%s: where is my ioctl data??", __func__); - if ((error = copyin(uap->data, &toce32, sizeof(toce32)))) return (error); CP(toce32, toce, address_format); From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 17:41:10 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7BC501065677; Mon, 28 Mar 2011 17:41:10 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 683098FC1A; Mon, 28 Mar 2011 17:41:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SHfAR3001563; Mon, 28 Mar 2011 17:41:10 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SHfAFu001547; Mon, 28 Mar 2011 17:41:10 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103281741.p2SHfAFu001547@svn.freebsd.org> From: Mikolaj Golub Date: Mon, 28 Mar 2011 17:41:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220104 - in stable/8: etc etc/mail etc/rc.d sbin/hastctl sbin/hastd X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 17:41:10 -0000 Author: trociny Date: Mon Mar 28 17:41:10 2011 New Revision: 220104 URL: http://svn.freebsd.org/changeset/base/220104 Log: MFC r217729, r217730, r217731, r217732, r217737, r217784, r217958, r217961, r217962, r217964, r217965, r217966, r217967, r217969, r218040, r218041, r218042, r218043, r218044, r218045, r218048, r218049, r218119, r218132, r218138, r218139, r218147, r218148, r218158, r218185, r218191, r218192, r218193, r218194, r218201, r218214, r218215, r218217, r218218, r218370, r218373, r218374, r218375, r218376, r218464, r218465, r218474, r219082: r217729 (pjd): - On primary worker reload, update hr_exec field. - Update comment. r217730 (pjd): Use int16 for error. r217731 (pjd): Use more consistent function name with the others (pjdlogv_prefix_set() instead of pjdlog_prefix_setv()). r217732 (pjd): Add nv_assert() which allows to assert that the given name exists. r217737 (pjd): Add missing logs. r217784 (pjd): Don't open configuration file from worker process. Handle SIGHUP in the master process only and pass changes to the worker processes over control socket. This removes access to global namespace in preparation for capsicum sandboxing. r217958 (pjd): Remove __dead2 from pjdlog_verify() prototype, it does return sometimes. r217961 (pjd): - Remove obvious NOTREACHED comment after abort() call. - Remove redundant newline at the end of the file. r217962 (pjd): Add LOG_NDELAY flag to openlog(3) - we want descriptor to be immediately open so there are no surprises once we start chrooting or using capsicum. r217964 (pjd): Use pjd copyright for 2011 work. r217965 (pjd): Add functions to initialize/finalize pjdlog. This allows to open/close log file at will. r217966 (pjd): Extend pjdlog_verify() to support the following additional macros: PJDLOG_RVERIFY() - always check expression and on false log the given message and exit. PJDLOG_RASSERT() - check expression when NDEBUG is not defined and on false log given message and exit. PJDLOG_ABORT() - log the given message and exit. r217967 (pjd): Close the control socket before exiting, so it will be unlinked. r217969 (pjd): Remember created control connection so on fork(2) we can close it in child. r218040 (pjd): Initialize all global variables on pjdlog_init(). r218041 (pjd): Add function to close all unneeded descriptors after fork(2). r218042 (pjd): Add comments to places where we treat errors as ciritical, but it is possible to handle them more gracefully. r218043 (pjd): Close all unneeded descriptors after fork(2). r218044 (pjd): Add function to assert that the only descriptors we have open are the ones we expect to be open. Also assert that they point at expected type. Because openlog(3) API is unable to tell us descriptor number it is using, we have to close syslog socket, remember assert message in local buffer and if we fail on assertion, reopen syslog socket and log the message. r218045 (pjd): Use newly added descriptors_assert() function to ensure only expected descriptors are open. r218046 (pjd), r218047 (pjd), r218119 (maxim): Add 'hast' user and 'hast' group that will be used by hastd (and maybe hastctl) to drop privileges. r218048 (pjd): Implement function that drops privileges by: - chrooting to /var/empty (user hast home directory), - setting groups to 'hast' (user hast primary group), - setting real group id, effective group id and saved group id to 'hast', - setting real user id, effective user id and saved user id to 'hast'. At the end verify that those operations where successfull. r218049 (pjd): Drop privileges in worker processes. Accepting connections and handshaking in secondary is still done before dropping privileges. It should be implemented by only accepting connections in privileged main process and passing connection descriptors to the worker, but is not implemented yet. r218132 (pjd): Rename pjdlog_verify() to pjdlog_abort() as it better describes what the the function does and mark it with __dead2. r218138 (pjd): - Use pjdlog for assertions and aborts as this will log assert/abort message to syslog if we run in background. - Asserts in proto.c that method we want to call is implemented and remove dummy methods from protocols implementation that are only there to abort the program with nice message. r218139 (pjd): Implement two new functions for sending descriptor and receving descriptor over UNIX domain sockets and socket pairs. This is in preparation for capsicum. r218147 (pjd), r218148 (pjd): Fix build on ia64. r218158 (pjd): Do not set socket send and receive buffer. It will be auto-tuned. Confirmed by: rwatson r218185 (pjd): Be prepared that hp_client or hp_server might be NULL now. r218191 (pjd): Move protocol allocation and deallocation to separate functions. r218192 (pjd), r218201 (bz): Allow to specify connection timeout by the caller. r218193 (pjd): Add proto_connect_wait() to wait for connection to finish. If timeout argument to proto_connect() is -1, then the caller needs to use this new function to wait for connection. This change is in preparation for capsicum, where sandboxed worker wants to ask main process to connect in worker's behalf and pass descriptor to the worker. Because we don't want the main process to wait for the connection, it will start async connection and pass descriptor to the worker who will be responsible for waiting for the connection to finish. r218194 (pjd): - Rename proto_descriptor_{send,recv}() functions to proto_connection_{send,recv} and change them to return proto_conn structure. We don't operate directly on descriptors, but on proto_conns. - Add wrap method to wrap descriptor with proto_conn. - Remove methods to send and receive descriptors and implement this functionality as additional argument to send and receive methods. r218214 (pjd): Let the caller log info about successful privilege drop. We don't want to log this in hastctl. r218215 (pjd): Drop privileges after connecting to hastd, but before sending or receiving anything. r218217 (pjd): Add missing locking after moving keepalive_send() to remote send thread in r214692. r218218 (pjd): Setup another socketpair between parent and child, so that primary sandboxed worker can ask the main privileged process to connect in worker's behalf and then we can migrate descriptor using this socketpair to worker. This is not really needed now, but will be needed once we start to use capsicum for sandboxing. r218370 (pjd): Close more descriptors that can be open if the worker process for the given resource is already running. Submitted by: Mikolaj Golub r218373 (pjd): Open syslog when logging sysconf(3) failure. Reported by: Mikolaj Golub r218374 (pjd): Treat fstat(2) failure (different than EBADF) as fatal error. Reported by: Mikolaj Golub r218375 (pjd): Add (void) cast before snprintf(3)s for which we are not interested in return values. r218376 (pjd): Now that we break the loop on fstat(2) failure we no longer need to satisfy gcc's imperfections. r218464 (pjd): Unlink UNIX domain socket file only if: 1. The descriptor is the one we are listening on (not the one when we connect as a client and not the one which is created on accept(2)). 2. Descriptor was created by us (PID matches with the PID stored on bind(2)). Reported by: Mikolaj Golub r218465 (pjd): Explicitly include as suggested by getpid(2) and don't rely on including what's needed. r218474 (pjd): When we decide to unlink socket file, sun_path must be set. If it is set, but there is problem unlinking the file, log a warning. r219082 (pjd): Recognize 'reload' command, as hastd can be reloaded with the SIGHUP signal. Approved by: pjd (mentor) Modified: stable/8/etc/ftpusers stable/8/etc/group stable/8/etc/mail/aliases stable/8/etc/master.passwd stable/8/etc/rc.d/hastd stable/8/sbin/hastctl/hastctl.c stable/8/sbin/hastd/control.c stable/8/sbin/hastd/control.h stable/8/sbin/hastd/hast.h stable/8/sbin/hastd/hastd.c stable/8/sbin/hastd/hastd.h stable/8/sbin/hastd/nv.c stable/8/sbin/hastd/nv.h stable/8/sbin/hastd/pjdlog.c stable/8/sbin/hastd/pjdlog.h stable/8/sbin/hastd/primary.c stable/8/sbin/hastd/proto.c stable/8/sbin/hastd/proto.h stable/8/sbin/hastd/proto_common.c stable/8/sbin/hastd/proto_impl.h stable/8/sbin/hastd/proto_socketpair.c stable/8/sbin/hastd/proto_tcp4.c stable/8/sbin/hastd/proto_uds.c stable/8/sbin/hastd/secondary.c stable/8/sbin/hastd/subr.c stable/8/sbin/hastd/subr.h Directory Properties: stable/8/etc/ (props changed) stable/8/sbin/hastctl/ (props changed) stable/8/sbin/hastd/ (props changed) Modified: stable/8/etc/ftpusers ============================================================================== --- stable/8/etc/ftpusers Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/ftpusers Mon Mar 28 17:41:10 2011 (r220104) @@ -20,6 +20,7 @@ _dhcp uucp pop www +hast nobody mailnull smmsp Modified: stable/8/etc/group ============================================================================== --- stable/8/etc/group Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/group Mon Mar 28 17:41:10 2011 (r220104) @@ -27,5 +27,6 @@ dialer:*:68: network:*:69: audit:*:77: www:*:80: +hast:*:845: nogroup:*:65533: nobody:*:65534: Modified: stable/8/etc/mail/aliases ============================================================================== --- stable/8/etc/mail/aliases Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/mail/aliases Mon Mar 28 17:41:10 2011 (r220104) @@ -30,6 +30,7 @@ bin: root bind: root daemon: root games: root +hast: root kmem: root mailnull: postmaster man: root Modified: stable/8/etc/master.passwd ============================================================================== --- stable/8/etc/master.passwd Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/master.passwd Mon Mar 28 17:41:10 2011 (r220104) @@ -20,4 +20,5 @@ _dhcp:*:65:65::0:0:dhcp programs:/var/em uucp:*:66:66::0:0:UUCP pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp/uucico pop:*:68:6::0:0:Post Office Owner:/nonexistent:/usr/sbin/nologin www:*:80:80::0:0:World Wide Web Owner:/nonexistent:/usr/sbin/nologin +hast:*:845:845::0:0:HAST unprivileged user:/var/empty:/usr/sbin/nologin nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin Modified: stable/8/etc/rc.d/hastd ============================================================================== --- stable/8/etc/rc.d/hastd Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/etc/rc.d/hastd Mon Mar 28 17:41:10 2011 (r220104) @@ -18,6 +18,7 @@ hastctl="/sbin/hastctl" required_files="/etc/hast.conf" stop_precmd="hastd_stop_precmd" required_modules="geom_gate:g_gate" +extra_commands="reload" hastd_stop_precmd() { Modified: stable/8/sbin/hastctl/hastctl.c ============================================================================== --- stable/8/sbin/hastctl/hastctl.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastctl/hastctl.c Mon Mar 28 17:41:10 2011 (r220104) @@ -430,6 +430,7 @@ main(int argc, char *argv[]) break; } + pjdlog_init(PJDLOG_MODE_STD); pjdlog_debug_set(debug); cfg = yy_config_parse(cfgpath, true); @@ -486,10 +487,15 @@ main(int argc, char *argv[]) cfg->hc_controladdr); } /* ...and connect to hastd. */ - if (proto_connect(controlconn) < 0) { + if (proto_connect(controlconn, HAST_TIMEOUT) < 0) { pjdlog_exit(EX_OSERR, "Unable to connect to hastd via %s", cfg->hc_controladdr); } + + if (drop_privs() != 0) + exit(EX_CONFIG); + pjdlog_debug(1, "Privileges successfully dropped."); + /* Send the command to the server... */ if (hast_proto_send(NULL, controlconn, nv, NULL, 0) < 0) { pjdlog_exit(EX_UNAVAILABLE, Modified: stable/8/sbin/hastd/control.c ============================================================================== --- stable/8/sbin/hastd/control.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/control.c Mon Mar 28 17:41:10 2011 (r220104) @@ -62,6 +62,10 @@ child_cleanup(struct hast_resource *res) proto_close(res->hr_event); res->hr_event = NULL; } + if (res->hr_conn != NULL) { + proto_close(res->hr_conn); + res->hr_conn = NULL; + } res->hr_workerpid = 0; } @@ -159,12 +163,13 @@ control_status_worker(struct hast_resour nv_add_uint8(cnvout, HASTCTL_STATUS, "cmd"); error = nv_error(cnvout); if (error != 0) { - /* LOG */ + pjdlog_common(LOG_ERR, 0, error, + "Unable to prepare control header"); goto end; } if (hast_proto_send(res, res->hr_ctrl, cnvout, NULL, 0) < 0) { error = errno; - /* LOG */ + pjdlog_errno(LOG_ERR, "Unable to send control header"); goto end; } @@ -173,17 +178,17 @@ control_status_worker(struct hast_resour */ if (hast_proto_recv_hdr(res->hr_ctrl, &cnvin) < 0) { error = errno; - /* LOG */ + pjdlog_errno(LOG_ERR, "Unable to receive control header"); goto end; } - error = nv_get_int64(cnvin, "error"); + error = nv_get_int16(cnvin, "error"); if (error != 0) goto end; if ((str = nv_get_string(cnvin, "status")) == NULL) { error = ENOENT; - /* LOG */ + pjdlog_errno(LOG_ERR, "Field 'status' is missing."); goto end; } nv_add_string(nvout, str, "status%u", no); @@ -277,6 +282,7 @@ control_handle(struct hastd_config *cfg) return; } + cfg->hc_controlin = conn; nvin = nvout = NULL; role = HAST_ROLE_UNDEF; @@ -383,6 +389,7 @@ close: if (nvout != NULL) nv_free(nvout); proto_close(conn); + cfg->hc_controlin = NULL; } /* @@ -410,7 +417,6 @@ ctrl_thread(void *arg) nv_free(nvin); continue; } - nv_free(nvin); nvout = nv_alloc(); switch (cmd) { case HASTCTL_STATUS: @@ -432,11 +438,23 @@ ctrl_thread(void *arg) nv_add_uint32(nvout, (uint32_t)0, "keepdirty"); nv_add_uint64(nvout, (uint64_t)0, "dirty"); } + nv_add_int16(nvout, 0, "error"); + break; + case HASTCTL_RELOAD: + /* + * When parent receives SIGHUP and discovers that + * something related to us has changes, it sends reload + * message to us. + */ + assert(res->hr_role == HAST_ROLE_PRIMARY); + primary_config_reload(res, nvin); + nv_add_int16(nvout, 0, "error"); break; default: nv_add_int16(nvout, EINVAL, "error"); break; } + nv_free(nvin); if (nv_error(nvout) != 0) { pjdlog_error("Unable to create answer on control message."); nv_free(nvout); Modified: stable/8/sbin/hastd/control.h ============================================================================== --- stable/8/sbin/hastd/control.h Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/control.h Mon Mar 28 17:41:10 2011 (r220104) @@ -34,6 +34,7 @@ #define HASTCTL_SET_ROLE 1 #define HASTCTL_STATUS 2 +#define HASTCTL_RELOAD 3 struct hastd_config; struct hast_resource; Modified: stable/8/sbin/hastd/hast.h ============================================================================== --- stable/8/sbin/hastd/hast.h Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/hast.h Mon Mar 28 17:41:10 2011 (r220104) @@ -81,6 +81,7 @@ #define HIO_FLUSH 4 #define HIO_KEEPALIVE 5 +#define HAST_USER "hast" #define HAST_TIMEOUT 5 #define HAST_CONFIG "/etc/hast.conf" #define HAST_CONTROL "/var/run/hastctl" @@ -101,6 +102,8 @@ struct hastd_config { char hc_controladdr[HAST_ADDRSIZE]; /* Protocol-specific data. */ struct proto_conn *hc_controlconn; + /* Incoming control connection. */ + struct proto_conn *hc_controlin; /* Address to listen on. */ char hc_listenaddr[HAST_ADDRSIZE]; /* Protocol-specific data. */ @@ -179,10 +182,12 @@ struct hast_resource { int hr_previous_role; /* PID of child worker process. 0 - no child. */ pid_t hr_workerpid; - /* Control connection between parent and child. */ + /* Control commands from parent to child. */ struct proto_conn *hr_ctrl; /* Events from child to parent. */ struct proto_conn *hr_event; + /* Connection requests from child to parent. */ + struct proto_conn *hr_conn; /* Activemap structure. */ struct activemap *hr_amp; Modified: stable/8/sbin/hastd/hastd.c ============================================================================== --- stable/8/sbin/hastd/hastd.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/hastd.c Mon Mar 28 17:41:10 2011 (r220104) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation - * Copyright (c) 2010 Pawel Jakub Dawidek + * Copyright (c) 2010-2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -34,9 +34,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include -#include #include #include #include @@ -93,6 +93,194 @@ g_gate_load(void) } } +void +descriptors_cleanup(struct hast_resource *res) +{ + struct hast_resource *tres; + + TAILQ_FOREACH(tres, &cfg->hc_resources, hr_next) { + if (tres == res) { + PJDLOG_VERIFY(res->hr_role == HAST_ROLE_SECONDARY || + (res->hr_remotein == NULL && + res->hr_remoteout == NULL)); + continue; + } + if (tres->hr_remotein != NULL) + proto_close(tres->hr_remotein); + if (tres->hr_remoteout != NULL) + proto_close(tres->hr_remoteout); + if (tres->hr_ctrl != NULL) + proto_close(tres->hr_ctrl); + if (tres->hr_event != NULL) + proto_close(tres->hr_event); + if (tres->hr_conn != NULL) + proto_close(tres->hr_conn); + } + if (cfg->hc_controlin != NULL) + proto_close(cfg->hc_controlin); + proto_close(cfg->hc_controlconn); + proto_close(cfg->hc_listenconn); + (void)pidfile_close(pfh); + hook_fini(); + pjdlog_fini(); +} + +static const char * +dtype2str(mode_t mode) +{ + + if (S_ISBLK(mode)) + return ("block device"); + else if (S_ISCHR(mode)) + return ("character device"); + else if (S_ISDIR(mode)) + return ("directory"); + else if (S_ISFIFO(mode)) + return ("pipe or FIFO"); + else if (S_ISLNK(mode)) + return ("symbolic link"); + else if (S_ISREG(mode)) + return ("regular file"); + else if (S_ISSOCK(mode)) + return ("socket"); + else if (S_ISWHT(mode)) + return ("whiteout"); + else + return ("unknown"); +} + +void +descriptors_assert(const struct hast_resource *res, int pjdlogmode) +{ + char msg[256]; + struct stat sb; + long maxfd; + bool isopen; + mode_t mode; + int fd; + + /* + * At this point descriptor to syslog socket is closed, so if we want + * to log assertion message, we have to first store it in 'msg' local + * buffer and then open syslog socket and log it. + */ + msg[0] = '\0'; + + maxfd = sysconf(_SC_OPEN_MAX); + if (maxfd < 0) { + pjdlog_init(pjdlogmode); + pjdlog_prefix_set("[%s] (%s) ", res->hr_name, + role2str(res->hr_role)); + pjdlog_errno(LOG_WARNING, "sysconf(_SC_OPEN_MAX) failed"); + pjdlog_fini(); + maxfd = 16384; + } + for (fd = 0; fd <= maxfd; fd++) { + if (fstat(fd, &sb) == 0) { + isopen = true; + mode = sb.st_mode; + } else if (errno == EBADF) { + isopen = false; + mode = 0; + } else { + (void)snprintf(msg, sizeof(msg), + "Unable to fstat descriptor %d: %s", fd, + strerror(errno)); + break; + } + if (fd == STDIN_FILENO || fd == STDOUT_FILENO || + fd == STDERR_FILENO) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (%s) is closed, but should be open.", + fd, (fd == STDIN_FILENO ? "stdin" : + (fd == STDOUT_FILENO ? "stdout" : "stderr"))); + break; + } + } else if (fd == proto_descriptor(res->hr_event)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (event) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (event) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else if (fd == proto_descriptor(res->hr_ctrl)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (ctrl) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (ctrl) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else if (fd == proto_descriptor(res->hr_conn)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (conn) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (conn) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else if (res->hr_role == HAST_ROLE_SECONDARY && + fd == proto_descriptor(res->hr_remotein)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (remote in) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (remote in) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else if (res->hr_role == HAST_ROLE_SECONDARY && + fd == proto_descriptor(res->hr_remoteout)) { + if (!isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (remote out) is closed, but should be open.", + fd); + break; + } + if (!S_ISSOCK(mode)) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (remote out) is %s, but should be %s.", + fd, dtype2str(mode), dtype2str(S_IFSOCK)); + break; + } + } else { + if (isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d is open (%s), but should be closed.", + fd, dtype2str(mode)); + break; + } + } + } + if (msg[0] != '\0') { + pjdlog_init(pjdlogmode); + pjdlog_prefix_set("[%s] (%s) ", res->hr_name, + role2str(res->hr_role)); + PJDLOG_ABORT("%s", msg); + } +} + static void child_exit_log(unsigned int pid, int status) { @@ -161,7 +349,7 @@ resource_needs_restart(const struct hast const struct hast_resource *res1) { - assert(strcmp(res0->hr_name, res1->hr_name) == 0); + PJDLOG_ASSERT(strcmp(res0->hr_name, res1->hr_name) == 0); if (strcmp(res0->hr_provname, res1->hr_provname) != 0) return (true); @@ -186,9 +374,9 @@ resource_needs_reload(const struct hast_ const struct hast_resource *res1) { - assert(strcmp(res0->hr_name, res1->hr_name) == 0); - assert(strcmp(res0->hr_provname, res1->hr_provname) == 0); - assert(strcmp(res0->hr_localpath, res1->hr_localpath) == 0); + PJDLOG_ASSERT(strcmp(res0->hr_name, res1->hr_name) == 0); + PJDLOG_ASSERT(strcmp(res0->hr_provname, res1->hr_provname) == 0); + PJDLOG_ASSERT(strcmp(res0->hr_localpath, res1->hr_localpath) == 0); if (res0->hr_role != HAST_ROLE_PRIMARY) return (false); @@ -205,6 +393,45 @@ resource_needs_reload(const struct hast_ } static void +resource_reload(const struct hast_resource *res) +{ + struct nv *nvin, *nvout; + int error; + + PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY); + + nvout = nv_alloc(); + nv_add_uint8(nvout, HASTCTL_RELOAD, "cmd"); + nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr"); + nv_add_int32(nvout, (int32_t)res->hr_replication, "replication"); + nv_add_int32(nvout, (int32_t)res->hr_timeout, "timeout"); + nv_add_string(nvout, res->hr_exec, "exec"); + if (nv_error(nvout) != 0) { + nv_free(nvout); + pjdlog_error("Unable to allocate header for reload message."); + return; + } + if (hast_proto_send(res, res->hr_ctrl, nvout, NULL, 0) < 0) { + pjdlog_errno(LOG_ERR, "Unable to send reload message"); + nv_free(nvout); + return; + } + nv_free(nvout); + + /* Receive response. */ + if (hast_proto_recv_hdr(res->hr_ctrl, &nvin) < 0) { + pjdlog_errno(LOG_ERR, "Unable to receive reload reply"); + return; + } + error = nv_get_int16(nvin, "error"); + nv_free(nvin); + if (error != 0) { + pjdlog_common(LOG_ERR, 0, error, "Reload failed"); + return; + } +} + +static void hastd_reload(void) { struct hastd_config *newcfg; @@ -306,8 +533,9 @@ hastd_reload(void) * recreating it. * * We do just reload (send SIGHUP to worker process) if we act as - * PRIMARY, but only remote address, replication mode and timeout - * has changed. For those, there is no need to restart worker process. + * PRIMARY, but only if remote address, replication mode, timeout or + * execution path has changed. For those, there is no need to restart + * worker process. * If PRIMARY receives SIGHUP, it will reconnect if remote address or * replication mode has changed or simply set new timeout if only * timeout has changed. @@ -317,7 +545,7 @@ hastd_reload(void) if (strcmp(cres->hr_name, nres->hr_name) == 0) break; } - assert(cres != NULL); + PJDLOG_ASSERT(cres != NULL); if (resource_needs_restart(cres, nres)) { pjdlog_info("Resource %s configuration was modified, restarting it.", cres->hr_name); @@ -335,13 +563,10 @@ hastd_reload(void) sizeof(cres->hr_remoteaddr)); cres->hr_replication = nres->hr_replication; cres->hr_timeout = nres->hr_timeout; - if (cres->hr_workerpid != 0) { - if (kill(cres->hr_workerpid, SIGHUP) < 0) { - pjdlog_errno(LOG_WARNING, - "Unable to send SIGHUP to worker process %u", - (unsigned int)cres->hr_workerpid); - } - } + strlcpy(cres->hr_exec, nres->hr_exec, + sizeof(cres->hr_exec)); + if (cres->hr_workerpid != 0) + resource_reload(cres); } } @@ -496,10 +721,10 @@ listen_accept(void) * we have to cancel those and accept the new connection. */ if (token == NULL) { - assert(res->hr_remoteout == NULL); + PJDLOG_ASSERT(res->hr_remoteout == NULL); pjdlog_debug(1, "Initial connection from %s.", raddr); if (res->hr_workerpid != 0) { - assert(res->hr_remotein == NULL); + PJDLOG_ASSERT(res->hr_remotein == NULL); pjdlog_debug(1, "Worker process exists (pid=%u), stopping it.", (unsigned int)res->hr_workerpid); @@ -599,6 +824,41 @@ close: } static void +connection_migrate(struct hast_resource *res) +{ + struct proto_conn *conn; + int16_t val = 0; + + if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) { + pjdlog_errno(LOG_WARNING, + "Unable to receive connection command"); + return; + } + if (proto_client(res->hr_remoteaddr, &conn) < 0) { + val = errno; + pjdlog_errno(LOG_WARNING, + "Unable to create outgoing connection to %s", + res->hr_remoteaddr); + goto out; + } + if (proto_connect(conn, -1) < 0) { + val = errno; + pjdlog_errno(LOG_WARNING, "Unable to connect to %s", + res->hr_remoteaddr); + proto_close(conn); + goto out; + } + val = 0; +out: + if (proto_send(res->hr_conn, &val, sizeof(val)) < 0) { + pjdlog_errno(LOG_WARNING, + "Unable to send reply to connection request"); + } + if (val == 0 && proto_connection_send(res->hr_conn, conn) < 0) + pjdlog_errno(LOG_WARNING, "Unable to send connection"); +} + +static void main_loop(void) { struct hast_resource *res; @@ -629,6 +889,7 @@ main_loop(void) case SIGTERM: sigexit_received = true; terminate_workers(); + proto_close(cfg->hc_controlconn); exit(EX_OK); break; case SIGCHLD: @@ -638,29 +899,37 @@ main_loop(void) hastd_reload(); break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("Unexpected signal (%d).", signo); } } /* Setup descriptors for select(2). */ FD_ZERO(&rfds); maxfd = fd = proto_descriptor(cfg->hc_controlconn); - assert(fd >= 0); + PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); fd = proto_descriptor(cfg->hc_listenconn); - assert(fd >= 0); + PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); maxfd = fd > maxfd ? fd : maxfd; TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; + PJDLOG_ASSERT(res->hr_conn != NULL); fd = proto_descriptor(res->hr_event); - assert(fd >= 0); + PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); maxfd = fd > maxfd ? fd : maxfd; + if (res->hr_role == HAST_ROLE_PRIMARY) { + /* Only primary workers asks for connections. */ + fd = proto_descriptor(res->hr_conn); + PJDLOG_ASSERT(fd >= 0); + FD_SET(fd, &rfds); + maxfd = fd > maxfd ? fd : maxfd; + } } - assert(maxfd + 1 <= (int)FD_SETSIZE); + PJDLOG_ASSERT(maxfd + 1 <= (int)FD_SETSIZE); ret = select(maxfd + 1, &rfds, NULL, NULL, &seltimeout); if (ret == 0) hook_check(); @@ -678,12 +947,20 @@ main_loop(void) TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; + PJDLOG_ASSERT(res->hr_conn != NULL); if (FD_ISSET(proto_descriptor(res->hr_event), &rfds)) { if (event_recv(res) == 0) continue; /* The worker process exited? */ proto_close(res->hr_event); res->hr_event = NULL; + proto_close(res->hr_conn); + res->hr_conn = NULL; + continue; + } + if (res->hr_role == HAST_ROLE_PRIMARY && + FD_ISSET(proto_descriptor(res->hr_conn), &rfds)) { + connection_migrate(res); } } } @@ -735,6 +1012,7 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + pjdlog_init(PJDLOG_MODE_STD); pjdlog_debug_set(debuglevel); g_gate_load(); @@ -751,7 +1029,7 @@ main(int argc, char *argv[]) } cfg = yy_config_parse(cfgpath, true); - assert(cfg != NULL); + PJDLOG_ASSERT(cfg != NULL); /* * Restore default actions for interesting signals in case parent Modified: stable/8/sbin/hastd/hastd.h ============================================================================== --- stable/8/sbin/hastd/hastd.h Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/hastd.h Mon Mar 28 17:41:10 2011 (r220104) @@ -43,7 +43,12 @@ extern const char *cfgpath; extern bool sigexit_received; extern struct pidfh *pfh; +void descriptors_cleanup(struct hast_resource *res); +void descriptors_assert(const struct hast_resource *res, int pjdlogmode); + void hastd_primary(struct hast_resource *res); void hastd_secondary(struct hast_resource *res, struct nv *nvin); +void primary_config_reload(struct hast_resource *res, struct nv *nv); + #endif /* !_HASTD_H_ */ Modified: stable/8/sbin/hastd/nv.c ============================================================================== --- stable/8/sbin/hastd/nv.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/nv.c Mon Mar 28 17:41:10 2011 (r220104) @@ -563,11 +563,10 @@ nv_get_string(struct nv *nv, const char return (str); } -bool -nv_exists(struct nv *nv, const char *namefmt, ...) +static bool +nv_vexists(struct nv *nv, const char *namefmt, va_list nameap) { struct nvhdr *nvh; - va_list nameap; int snverror, serrno; if (nv == NULL) @@ -576,9 +575,7 @@ nv_exists(struct nv *nv, const char *nam serrno = errno; snverror = nv->nv_error; - va_start(nameap, namefmt); nvh = nv_find(nv, NV_TYPE_NONE, namefmt, nameap); - va_end(nameap); errno = serrno; nv->nv_error = snverror; @@ -586,6 +583,29 @@ nv_exists(struct nv *nv, const char *nam return (nvh != NULL); } +bool +nv_exists(struct nv *nv, const char *namefmt, ...) +{ + va_list nameap; + bool ret; + + va_start(nameap, namefmt); + ret = nv_vexists(nv, namefmt, nameap); + va_end(nameap); + + return (ret); +} + +void +nv_assert(struct nv *nv, const char *namefmt, ...) +{ + va_list nameap; + + va_start(nameap, namefmt); + assert(nv_vexists(nv, namefmt, nameap)); + va_end(nameap); +} + /* * Dump content of the nv structure. */ Modified: stable/8/sbin/hastd/nv.h ============================================================================== --- stable/8/sbin/hastd/nv.h Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/nv.h Mon Mar 28 17:41:10 2011 (r220104) @@ -127,6 +127,7 @@ const char *nv_get_string(struct nv *nv, __printflike(2, 3); bool nv_exists(struct nv *nv, const char *namefmt, ...) __printflike(2, 3); +void nv_assert(struct nv *nv, const char *namefmt, ...) __printflike(2, 3); void nv_dump(struct nv *nv); #endif /* !_NV_H_ */ Modified: stable/8/sbin/hastd/pjdlog.c ============================================================================== --- stable/8/sbin/hastd/pjdlog.c Mon Mar 28 16:58:48 2011 (r220103) +++ stable/8/sbin/hastd/pjdlog.c Mon Mar 28 17:41:10 2011 (r220104) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -33,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -40,10 +42,38 @@ __FBSDID("$FreeBSD$"); #include "pjdlog.h" -static int pjdlog_mode = PJDLOG_MODE_STD; -static int pjdlog_debug_level = 0; +static bool pjdlog_initialized = false; +static int pjdlog_mode, pjdlog_debug_level; static char pjdlog_prefix[128]; +void +pjdlog_init(int mode) +{ + + assert(!pjdlog_initialized); + assert(mode == PJDLOG_MODE_STD || mode == PJDLOG_MODE_SYSLOG); + + if (mode == PJDLOG_MODE_SYSLOG) + openlog(NULL, LOG_PID | LOG_NDELAY, LOG_DAEMON); + pjdlog_mode = mode; + pjdlog_debug_level = 0; + bzero(pjdlog_prefix, sizeof(pjdlog_prefix)); + + pjdlog_initialized = true; +} + +void +pjdlog_fini(void) +{ + + assert(pjdlog_initialized); + + if (pjdlog_mode == PJDLOG_MODE_SYSLOG) + closelog(); + + pjdlog_initialized = false; +} + /* * Configure where the logs should go. * By default they are send to stdout/stderr, but after going into background @@ -54,12 +84,18 @@ void pjdlog_mode_set(int mode) { + assert(pjdlog_initialized); assert(mode == PJDLOG_MODE_STD || mode == PJDLOG_MODE_SYSLOG); - pjdlog_mode = mode; + if (pjdlog_mode == mode) + return; if (mode == PJDLOG_MODE_SYSLOG) - openlog(NULL, LOG_PID, LOG_DAEMON); + openlog(NULL, LOG_PID | LOG_NDELAY, LOG_DAEMON); + else /* if (mode == PJDLOG_MODE_STD) */ + closelog(); + + pjdlog_mode = mode; } /* @@ -69,6 +105,8 @@ int pjdlog_mode_get(void) { + assert(pjdlog_initialized); + return (pjdlog_mode); } @@ -80,6 +118,7 @@ void pjdlog_debug_set(int level) { + assert(pjdlog_initialized); assert(level >= 0); pjdlog_debug_level = level; @@ -92,6 +131,8 @@ int pjdlog_debug_get(void) { + assert(pjdlog_initialized); + return (pjdlog_debug_level); } @@ -104,8 +145,10 @@ pjdlog_prefix_set(const char *fmt, ...) { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); - pjdlog_prefix_setv(fmt, ap); + pjdlogv_prefix_set(fmt, ap); va_end(ap); } @@ -114,9 +157,10 @@ pjdlog_prefix_set(const char *fmt, ...) * Setting prefix to NULL will remove it. */ void -pjdlog_prefix_setv(const char *fmt, va_list ap) +pjdlogv_prefix_set(const char *fmt, va_list ap) { + assert(pjdlog_initialized); assert(fmt != NULL); vsnprintf(pjdlog_prefix, sizeof(pjdlog_prefix), fmt, ap); @@ -159,6 +203,8 @@ pjdlog_common(int loglevel, int debuglev { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_common(loglevel, debuglevel, error, fmt, ap); va_end(ap); @@ -173,6 +219,7 @@ pjdlogv_common(int loglevel, int debugle va_list ap) { + assert(pjdlog_initialized); assert(loglevel == LOG_EMERG || loglevel == LOG_ALERT || loglevel == LOG_CRIT || loglevel == LOG_ERR || loglevel == LOG_WARNING || loglevel == LOG_NOTICE || @@ -249,6 +296,8 @@ void pjdlogv(int loglevel, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + /* LOG_DEBUG is invalid here, pjdlogv?_debug() should be used. */ assert(loglevel == LOG_EMERG || loglevel == LOG_ALERT || loglevel == LOG_CRIT || loglevel == LOG_ERR || @@ -266,6 +315,8 @@ pjdlog(int loglevel, const char *fmt, .. { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv(loglevel, fmt, ap); va_end(ap); @@ -278,6 +329,8 @@ void pjdlogv_debug(int debuglevel, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + pjdlogv_common(LOG_DEBUG, debuglevel, -1, fmt, ap); } @@ -289,6 +342,8 @@ pjdlog_debug(int debuglevel, const char { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_debug(debuglevel, fmt, ap); va_end(ap); @@ -301,6 +356,8 @@ void pjdlogv_errno(int loglevel, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + pjdlogv_common(loglevel, 0, errno, fmt, ap); } @@ -312,6 +369,8 @@ pjdlog_errno(int loglevel, const char *f { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_errno(loglevel, fmt, ap); va_end(ap); @@ -324,6 +383,8 @@ void pjdlogv_exit(int exitcode, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + pjdlogv_errno(LOG_ERR, fmt, ap); exit(exitcode); /* NOTREACHED */ @@ -337,6 +398,8 @@ pjdlog_exit(int exitcode, const char *fm { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_exit(exitcode, fmt, ap); /* NOTREACHED */ @@ -350,6 +413,8 @@ void pjdlogv_exitx(int exitcode, const char *fmt, va_list ap) { + assert(pjdlog_initialized); + pjdlogv(LOG_ERR, fmt, ap); exit(exitcode); /* NOTREACHED */ @@ -363,6 +428,8 @@ pjdlog_exitx(int exitcode, const char *f { va_list ap; + assert(pjdlog_initialized); + va_start(ap, fmt); pjdlogv_exitx(exitcode, fmt, ap); /* NOTREACHED */ @@ -370,21 +437,42 @@ pjdlog_exitx(int exitcode, const char *f *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 19:22:56 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 16E14106564A; Mon, 28 Mar 2011 19:22:56 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 058F58FC0A; Mon, 28 Mar 2011 19:22:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJMt7t004131; Mon, 28 Mar 2011 19:22:55 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJMtva004130; Mon, 28 Mar 2011 19:22:55 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281922.p2SJMtva004130@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:22:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220107 - in stable/8/etc: periodic/daily periodic/security periodic/weekly rc.d X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:22:56 -0000 Author: dougb Date: Mon Mar 28 19:22:55 2011 New Revision: 220107 URL: http://svn.freebsd.org/changeset/base/220107 Log: MFC r219587, r220017, r220048 Adjust svn:executable properties Modified: Directory Properties: stable/8/etc/ (props changed) stable/8/etc/periodic/daily/404.status-zfs (props changed) stable/8/etc/periodic/daily/405.status-ata-raid (props changed) stable/8/etc/periodic/daily/406.status-gmirror (props changed) stable/8/etc/periodic/daily/407.status-graid3 (props changed) stable/8/etc/periodic/daily/408.status-gstripe (props changed) stable/8/etc/periodic/daily/409.status-gconcat (props changed) stable/8/etc/periodic/daily/480.status-ntpd (props changed) stable/8/etc/periodic/security/410.logincheck (props changed) stable/8/etc/periodic/security/460.chkportsum (props changed) stable/8/etc/periodic/security/510.ipfdenied (props changed) stable/8/etc/periodic/security/520.pfdenied (props changed) stable/8/etc/periodic/security/610.ipf6denied (props changed) stable/8/etc/periodic/weekly/340.noid (props changed) stable/8/etc/rc.d/Makefile (props changed) stable/8/etc/rc.d/hastd (props changed) From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 19:27:46 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F7EF1065676; Mon, 28 Mar 2011 19:27:46 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5E6BA8FC14; Mon, 28 Mar 2011 19:27:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJRkru004359; Mon, 28 Mar 2011 19:27:46 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJRka9004358; Mon, 28 Mar 2011 19:27:46 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281927.p2SJRka9004358@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:27:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220109 - in stable/7/etc: periodic/daily periodic/security periodic/weekly rc.d X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:27:46 -0000 Author: dougb Date: Mon Mar 28 19:27:46 2011 New Revision: 220109 URL: http://svn.freebsd.org/changeset/base/220109 Log: MFC r219587, r220017, r220048 Adjust svn:executable properties Modified: Directory Properties: stable/7/etc/ (props changed) stable/7/etc/periodic/daily/404.status-zfs (props changed) stable/7/etc/periodic/daily/405.status-ata-raid (props changed) stable/7/etc/periodic/daily/406.status-gmirror (props changed) stable/7/etc/periodic/daily/407.status-graid3 (props changed) stable/7/etc/periodic/daily/408.status-gstripe (props changed) stable/7/etc/periodic/daily/409.status-gconcat (props changed) stable/7/etc/periodic/daily/480.status-ntpd (props changed) stable/7/etc/periodic/security/410.logincheck (props changed) stable/7/etc/periodic/security/510.ipfdenied (props changed) stable/7/etc/periodic/security/520.pfdenied (props changed) stable/7/etc/periodic/security/610.ipf6denied (props changed) stable/7/etc/periodic/weekly/340.noid (props changed) stable/7/etc/rc.d/Makefile (props changed) From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 19:29:30 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC34D1065675; Mon, 28 Mar 2011 19:29:30 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9B4DF8FC1E; Mon, 28 Mar 2011 19:29:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJTUAp004432; Mon, 28 Mar 2011 19:29:30 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJTUN6004431; Mon, 28 Mar 2011 19:29:30 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281929.p2SJTUN6004431@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:29:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220110 - stable/7/etc/rc.d X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:29:30 -0000 Author: dougb Date: Mon Mar 28 19:29:30 2011 New Revision: 220110 URL: http://svn.freebsd.org/changeset/base/220110 Log: Direct commit to update svn:executable property on remaining scripts Modified: Directory Properties: stable/7/etc/rc.d/FILESYSTEMS (props changed) stable/7/etc/rc.d/NETWORKING (props changed) stable/7/etc/rc.d/abi (props changed) stable/7/etc/rc.d/addswap (props changed) stable/7/etc/rc.d/adjkerntz (props changed) stable/7/etc/rc.d/apm (props changed) stable/7/etc/rc.d/archdep (props changed) stable/7/etc/rc.d/atm1 (props changed) stable/7/etc/rc.d/atm2 (props changed) stable/7/etc/rc.d/atm3 (props changed) stable/7/etc/rc.d/auditd (props changed) stable/7/etc/rc.d/auto_linklocal (props changed) stable/7/etc/rc.d/bgfsck (props changed) stable/7/etc/rc.d/bluetooth (props changed) stable/7/etc/rc.d/bridge (props changed) stable/7/etc/rc.d/bsnmpd (props changed) stable/7/etc/rc.d/bthidd (props changed) stable/7/etc/rc.d/cleanvar (props changed) stable/7/etc/rc.d/ddb (props changed) stable/7/etc/rc.d/devd (props changed) stable/7/etc/rc.d/devfs (props changed) stable/7/etc/rc.d/dumpon (props changed) stable/7/etc/rc.d/early.sh (props changed) stable/7/etc/rc.d/encswap (props changed) stable/7/etc/rc.d/ftp-proxy (props changed) stable/7/etc/rc.d/ftpd (props changed) stable/7/etc/rc.d/gbde (props changed) stable/7/etc/rc.d/geli (props changed) stable/7/etc/rc.d/geli2 (props changed) stable/7/etc/rc.d/hcsecd (props changed) stable/7/etc/rc.d/hostapd (props changed) stable/7/etc/rc.d/hostid (props changed) stable/7/etc/rc.d/hostname (props changed) stable/7/etc/rc.d/idmapd (props changed) stable/7/etc/rc.d/initrandom (props changed) stable/7/etc/rc.d/ip6addrctl (props changed) stable/7/etc/rc.d/ip6fw (props changed) stable/7/etc/rc.d/ipfw (props changed) stable/7/etc/rc.d/ipxrouted (props changed) stable/7/etc/rc.d/isdnd (props changed) stable/7/etc/rc.d/jail (props changed) stable/7/etc/rc.d/kadmind (props changed) stable/7/etc/rc.d/kerberos (props changed) stable/7/etc/rc.d/keyserv (props changed) stable/7/etc/rc.d/kldxref (props changed) stable/7/etc/rc.d/kpasswdd (props changed) stable/7/etc/rc.d/localpkg (props changed) stable/7/etc/rc.d/lockd (props changed) stable/7/etc/rc.d/mdconfig (props changed) stable/7/etc/rc.d/mdconfig2 (props changed) stable/7/etc/rc.d/mixer (props changed) stable/7/etc/rc.d/mountlate (props changed) stable/7/etc/rc.d/moused (props changed) stable/7/etc/rc.d/mroute6d (props changed) stable/7/etc/rc.d/msgs (props changed) stable/7/etc/rc.d/natd (props changed) stable/7/etc/rc.d/netif (props changed) stable/7/etc/rc.d/netoptions (props changed) stable/7/etc/rc.d/network_ipv6 (props changed) stable/7/etc/rc.d/nfsclient (props changed) stable/7/etc/rc.d/nfsserver (props changed) stable/7/etc/rc.d/nisdomain (props changed) stable/7/etc/rc.d/nscd (props changed) stable/7/etc/rc.d/nsswitch (props changed) stable/7/etc/rc.d/othermta (props changed) stable/7/etc/rc.d/pf (props changed) stable/7/etc/rc.d/pflog (props changed) stable/7/etc/rc.d/pfsync (props changed) stable/7/etc/rc.d/power_profile (props changed) stable/7/etc/rc.d/powerd (props changed) stable/7/etc/rc.d/ppp (props changed) stable/7/etc/rc.d/pppoed (props changed) stable/7/etc/rc.d/random (props changed) stable/7/etc/rc.d/resolv (props changed) stable/7/etc/rc.d/rfcomm_pppd_server (props changed) stable/7/etc/rc.d/routing (props changed) stable/7/etc/rc.d/sdpd (props changed) stable/7/etc/rc.d/serial (props changed) stable/7/etc/rc.d/sppp (props changed) stable/7/etc/rc.d/statd (props changed) stable/7/etc/rc.d/static_arp (props changed) stable/7/etc/rc.d/syscons (props changed) stable/7/etc/rc.d/sysctl (props changed) stable/7/etc/rc.d/tmp (props changed) stable/7/etc/rc.d/ugidfw (props changed) stable/7/etc/rc.d/var (props changed) stable/7/etc/rc.d/watchdogd (props changed) stable/7/etc/rc.d/wpa_supplicant (props changed) stable/7/etc/rc.d/ypset (props changed) stable/7/etc/rc.d/ypupdated (props changed) stable/7/etc/rc.d/ypxfrd (props changed) stable/7/etc/rc.d/zfs (props changed) From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 19:32:16 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 577911065672; Mon, 28 Mar 2011 19:32:16 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 471508FC08; Mon, 28 Mar 2011 19:32:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJWGZs004574; Mon, 28 Mar 2011 19:32:16 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJWGL6004572; Mon, 28 Mar 2011 19:32:16 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281932.p2SJWGL6004572@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:32:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220111 - stable/8/usr.sbin/newsyslog X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:32:16 -0000 Author: dougb Date: Mon Mar 28 19:32:16 2011 New Revision: 220111 URL: http://svn.freebsd.org/changeset/base/220111 Log: MFC r220015: An EXAMPLE for Modified: stable/8/usr.sbin/newsyslog/newsyslog.conf.5 Directory Properties: stable/8/usr.sbin/newsyslog/ (props changed) Modified: stable/8/usr.sbin/newsyslog/newsyslog.conf.5 ============================================================================== --- stable/8/usr.sbin/newsyslog/newsyslog.conf.5 Mon Mar 28 19:29:30 2011 (r220110) +++ stable/8/usr.sbin/newsyslog/newsyslog.conf.5 Mon Mar 28 19:32:16 2011 (r220111) @@ -21,7 +21,7 @@ .\" the suitability of this software for any purpose. It is .\" provided "as is" without express or implied warranty. .\" -.Dd January 31, 2011 +.Dd February 25, 2011 .Dt NEWSYSLOG.CONF 5 .Os .Sh NAME @@ -349,6 +349,11 @@ If this field is not present, then a .Dv SIGHUP signal will be sent. .El +.Sh EXAMPLES +The following is an example of the +.Dq Aq Li include +entry: +.Dl " /etc/newsyslog-local.conf" .Sh SEE ALSO .Xr bzip2 1 , .Xr gzip 1 , From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 19:39:54 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 360121065676; Mon, 28 Mar 2011 19:39:54 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 24C628FC20; Mon, 28 Mar 2011 19:39:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJdsX2004854; Mon, 28 Mar 2011 19:39:54 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJdrEC004849; Mon, 28 Mar 2011 19:39:53 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281939.p2SJdrEC004849@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:39:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220112 - in stable/8/etc: defaults periodic/daily periodic/security X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:39:54 -0000 Author: dougb Date: Mon Mar 28 19:39:53 2011 New Revision: 220112 URL: http://svn.freebsd.org/changeset/base/220112 Log: MFC r220020: Add a daily period script to back up /var/db/pkg MFC r220049: Hook the 220.backup-pkgdb script I added to the build unconditionally Hook up 610.ipf6denied based on MK_IPFILTER as 510.ipfdenied is now Added: stable/8/etc/periodic/daily/220.backup-pkgdb - copied unchanged from r220020, head/etc/periodic/daily/220.backup-pkgdb Modified: stable/8/etc/defaults/periodic.conf stable/8/etc/periodic/daily/Makefile stable/8/etc/periodic/security/Makefile Directory Properties: stable/8/etc/ (props changed) Modified: stable/8/etc/defaults/periodic.conf ============================================================================== --- stable/8/etc/defaults/periodic.conf Mon Mar 28 19:32:16 2011 (r220111) +++ stable/8/etc/defaults/periodic.conf Mon Mar 28 19:39:53 2011 (r220112) @@ -74,6 +74,10 @@ daily_backup_passwd_enable="YES" # Bac # 210.backup-aliases daily_backup_aliases_enable="YES" # Backup mail aliases +# 220.backup-pkgdb +daily_backup_pkgdb_enable="YES" # Backup /var/db/pkg +daily_backup_pkgdb_dir="/var/backups" + # 300.calendar daily_calendar_enable="NO" # Run calendar -a Copied: stable/8/etc/periodic/daily/220.backup-pkgdb (from r220020, head/etc/periodic/daily/220.backup-pkgdb) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/etc/periodic/daily/220.backup-pkgdb Mon Mar 28 19:39:53 2011 (r220112, copy of r220020, head/etc/periodic/daily/220.backup-pkgdb) @@ -0,0 +1,50 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# If there is a global system configuration file, suck it in. +# +if [ -r /etc/defaults/periodic.conf ] +then + . /etc/defaults/periodic.conf + source_periodic_confs +fi + +rc=0 + +case "$daily_backup_pkgdb_enable" in + [Yy][Ee][Ss]) + bak="${daily_backup_pkgdb_dir:-/var/backups}" + bak_file="${bak}/pkgdb.bak.tbz" + + pkg_dbdir=`make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2>/dev/null` + + if [ ! -d "$bak" ] + then + install -d -o root -g wheel -m 750 $bak || { + echo '$daily_backup_pkgdb_enable is enabled but' \ + "$daily_backup_pkgdb_dbdir doesn't exist" ; + exit 2 ; } + fi + + echo '' + echo 'Backing up package db directory:' + + new_bak_file=`mktemp ${bak_file}-XXXXX` + + if tar -cjf "${new_bak_file}" "$pkg_dbdir"; then + chmod 644 "${new_bak_file}" + + if [ -e "${bak_file}.2" -a -e "${bak_file}" ]; then + unlink "${bak_file}.2" + mv "${bak_file}" "${bak_file}.2" + fi + [ -e "${bak_file}" ] && mv "${bak_file}" "${bak_file}.2" + mv "${new_bak_file}" "${bak_file}" + else + rc=3 + fi ;; +esac + +exit $rc Modified: stable/8/etc/periodic/daily/Makefile ============================================================================== --- stable/8/etc/periodic/daily/Makefile Mon Mar 28 19:32:16 2011 (r220111) +++ stable/8/etc/periodic/daily/Makefile Mon Mar 28 19:39:53 2011 (r220112) @@ -6,6 +6,7 @@ FILES= 100.clean-disks \ 110.clean-tmps \ 120.clean-preserve \ 200.backup-passwd \ + 220.backup-pkgdb \ 330.news \ 400.status-disks \ 405.status-ata-raid \ Modified: stable/8/etc/periodic/security/Makefile ============================================================================== --- stable/8/etc/periodic/security/Makefile Mon Mar 28 19:32:16 2011 (r220111) +++ stable/8/etc/periodic/security/Makefile Mon Mar 28 19:39:53 2011 (r220112) @@ -17,6 +17,7 @@ FILES= 100.chksetuid \ .if ${MK_IPFILTER} != "no" FILES+= 510.ipfdenied +FILES+= 610.ipf6denied .endif .if ${MK_IPFW} != "no" From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 19:42:21 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8CF60106566C; Mon, 28 Mar 2011 19:42:21 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7BBEB8FC14; Mon, 28 Mar 2011 19:42:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SJgLk1004981; Mon, 28 Mar 2011 19:42:21 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SJgLeK004976; Mon, 28 Mar 2011 19:42:21 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103281942.p2SJgLeK004976@svn.freebsd.org> From: Doug Barton Date: Mon, 28 Mar 2011 19:42:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220113 - in stable/7/etc: defaults periodic/daily periodic/security X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 19:42:21 -0000 Author: dougb Date: Mon Mar 28 19:42:21 2011 New Revision: 220113 URL: http://svn.freebsd.org/changeset/base/220113 Log: MFC r220020: Add a daily period script to back up /var/db/pkg MFC r220049: Hook the 220.backup-pkgdb script I added to the build unconditionally Hook up 610.ipf6denied based on MK_IPFILTER as 510.ipfdenied is now Added: stable/7/etc/periodic/daily/220.backup-pkgdb - copied unchanged from r220020, head/etc/periodic/daily/220.backup-pkgdb Modified: stable/7/etc/defaults/periodic.conf stable/7/etc/periodic/daily/Makefile stable/7/etc/periodic/security/Makefile Directory Properties: stable/7/etc/ (props changed) Modified: stable/7/etc/defaults/periodic.conf ============================================================================== --- stable/7/etc/defaults/periodic.conf Mon Mar 28 19:39:53 2011 (r220112) +++ stable/7/etc/defaults/periodic.conf Mon Mar 28 19:42:21 2011 (r220113) @@ -74,6 +74,10 @@ daily_backup_passwd_enable="YES" # Bac # 210.backup-aliases daily_backup_aliases_enable="YES" # Backup mail aliases +# 220.backup-pkgdb +daily_backup_pkgdb_enable="YES" # Backup /var/db/pkg +daily_backup_pkgdb_dir="/var/backups" + # 300.calendar daily_calendar_enable="NO" # Run calendar -a Copied: stable/7/etc/periodic/daily/220.backup-pkgdb (from r220020, head/etc/periodic/daily/220.backup-pkgdb) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/etc/periodic/daily/220.backup-pkgdb Mon Mar 28 19:42:21 2011 (r220113, copy of r220020, head/etc/periodic/daily/220.backup-pkgdb) @@ -0,0 +1,50 @@ +#!/bin/sh +# +# $FreeBSD$ +# + +# If there is a global system configuration file, suck it in. +# +if [ -r /etc/defaults/periodic.conf ] +then + . /etc/defaults/periodic.conf + source_periodic_confs +fi + +rc=0 + +case "$daily_backup_pkgdb_enable" in + [Yy][Ee][Ss]) + bak="${daily_backup_pkgdb_dir:-/var/backups}" + bak_file="${bak}/pkgdb.bak.tbz" + + pkg_dbdir=`make -f/usr/share/mk/bsd.port.mk -V PKG_DBDIR 2>/dev/null` + + if [ ! -d "$bak" ] + then + install -d -o root -g wheel -m 750 $bak || { + echo '$daily_backup_pkgdb_enable is enabled but' \ + "$daily_backup_pkgdb_dbdir doesn't exist" ; + exit 2 ; } + fi + + echo '' + echo 'Backing up package db directory:' + + new_bak_file=`mktemp ${bak_file}-XXXXX` + + if tar -cjf "${new_bak_file}" "$pkg_dbdir"; then + chmod 644 "${new_bak_file}" + + if [ -e "${bak_file}.2" -a -e "${bak_file}" ]; then + unlink "${bak_file}.2" + mv "${bak_file}" "${bak_file}.2" + fi + [ -e "${bak_file}" ] && mv "${bak_file}" "${bak_file}.2" + mv "${new_bak_file}" "${bak_file}" + else + rc=3 + fi ;; +esac + +exit $rc Modified: stable/7/etc/periodic/daily/Makefile ============================================================================== --- stable/7/etc/periodic/daily/Makefile Mon Mar 28 19:39:53 2011 (r220112) +++ stable/7/etc/periodic/daily/Makefile Mon Mar 28 19:42:21 2011 (r220113) @@ -6,6 +6,7 @@ FILES= 100.clean-disks \ 110.clean-tmps \ 120.clean-preserve \ 200.backup-passwd \ + 220.backup-pkgdb \ 330.news \ 400.status-disks \ 404.status-zfs \ Modified: stable/7/etc/periodic/security/Makefile ============================================================================== --- stable/7/etc/periodic/security/Makefile Mon Mar 28 19:39:53 2011 (r220112) +++ stable/7/etc/periodic/security/Makefile Mon Mar 28 19:42:21 2011 (r220113) @@ -16,6 +16,7 @@ FILES= 100.chksetuid \ .if ${MK_IPFILTER} != "no" FILES+= 510.ipfdenied +FILES+= 610.ipf6denied .endif .if ${MK_IPFW} != "no" From owner-svn-src-stable@FreeBSD.ORG Mon Mar 28 22:50:03 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F40CD106564A; Mon, 28 Mar 2011 22:50:02 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D94488FC0C; Mon, 28 Mar 2011 22:50:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2SMo2B9009071; Mon, 28 Mar 2011 22:50:02 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2SMo2HI009069; Mon, 28 Mar 2011 22:50:02 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201103282250.p2SMo2HI009069@svn.freebsd.org> From: Jilles Tjoelker Date: Mon, 28 Mar 2011 22:50:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220115 - stable/8/lib/libc/string X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Mar 2011 22:50:03 -0000 Author: jilles Date: Mon Mar 28 22:50:02 2011 New Revision: 220115 URL: http://svn.freebsd.org/changeset/base/220115 Log: MFC r219803: index(3): Mention that index/rindex are deprecated and not specified by POSIX.1-2008. Modified: stable/8/lib/libc/string/index.3 Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/string/index.3 ============================================================================== --- stable/8/lib/libc/string/index.3 Mon Mar 28 19:44:54 2011 (r220114) +++ stable/8/lib/libc/string/index.3 Mon Mar 28 22:50:02 2011 (r220115) @@ -30,7 +30,7 @@ .\" @(#)index.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd March 20, 2011 .Dt INDEX 3 .Os .Sh NAME @@ -45,6 +45,17 @@ .Ft "char *" .Fn rindex "const char *s" "int c" .Sh DESCRIPTION +.Bf -symbolic +The +.Fn index +and +.Fn rindex +functions have been deprecated in favor of +.Xr strchr 3 +and +.Xr strrchr 3 . +.Ef +.Pp The .Fn index function @@ -100,3 +111,5 @@ before they were moved to for .St -p1003.1-2001 compliance. +The functions are not specified by +.St -p1003.1-2008 . From owner-svn-src-stable@FreeBSD.ORG Tue Mar 29 11:54:22 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E252A106564A; Tue, 29 Mar 2011 11:54:22 +0000 (UTC) (envelope-from ru@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D05CF8FC0C; Tue, 29 Mar 2011 11:54:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TBsMCm027526; Tue, 29 Mar 2011 11:54:22 GMT (envelope-from ru@svn.freebsd.org) Received: (from ru@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TBsMiG027524; Tue, 29 Mar 2011 11:54:22 GMT (envelope-from ru@svn.freebsd.org) Message-Id: <201103291154.p2TBsMiG027524@svn.freebsd.org> From: Ruslan Ermilov Date: Tue, 29 Mar 2011 11:54:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220125 - stable/8/usr.bin/netstat X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 11:54:23 -0000 Author: ru Date: Tue Mar 29 11:54:22 2011 New Revision: 220125 URL: http://svn.freebsd.org/changeset/base/220125 Log: MFC r220041: Fixed sockets display somewhat (-L, -T, -x, -Lx, with and without -A). (I didn't try to fix negative TCP timers with -x.) Also, fixed a mismerge of -T option in r216964 -- it erroneously added headers for TCP timers to -x. Modified: stable/8/usr.bin/netstat/inet.c Directory Properties: stable/8/usr.bin/netstat/ (props changed) Modified: stable/8/usr.bin/netstat/inet.c ============================================================================== --- stable/8/usr.bin/netstat/inet.c Tue Mar 29 06:42:52 2011 (r220124) +++ stable/8/usr.bin/netstat/inet.c Tue Mar 29 11:54:22 2011 (r220125) @@ -404,43 +404,44 @@ protopr(u_long off, const char *name, in "Current listen queue sizes (qlen/incqlen/maxqlen)"); putchar('\n'); if (Aflag) - printf("%-8.8s ", "Tcpcb"); + printf("%-*s ", 2 * (int)sizeof(void *), "Tcpcb"); if (Lflag) - printf("%-5.5s %-14.14s %-22.22s\n", + printf((Aflag && !Wflag) ? + "%-5.5s %-14.14s %-18.18s" : + "%-5.5s %-14.14s %-22.22s", "Proto", "Listen", "Local Address"); - if (Tflag) + else if (Tflag) printf((Aflag && !Wflag) ? - "%-5.5s %-6.6s %-6.6s %-6.6s %-18.18s %s\n" : - "%-5.5s %-6.6s %-6.6s %-6.6s %-22.22s %s\n", + "%-5.5s %-6.6s %-6.6s %-6.6s %-18.18s %s" : + "%-5.5s %-6.6s %-6.6s %-6.6s %-22.22s %s", "Proto", "Rexmit", "OOORcv", "0-win", "Local Address", "Foreign Address"); + else { + printf((Aflag && !Wflag) ? + "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s" : + "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s", + "Proto", "Recv-Q", "Send-Q", + "Local Address", "Foreign Address"); + if (!xflag) + printf(" (state)"); + } if (xflag) { - printf("%-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s ", + printf(" %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s %-6.6s", "R-MBUF", "S-MBUF", "R-CLUS", "S-CLUS", "R-HIWA", "S-HIWA", "R-LOWA", "S-LOWA", "R-BCNT", "S-BCNT", "R-BMAX", "S-BMAX"); - printf("%7.7s %7.7s %7.7s %7.7s %7.7s %7.7s\n", - "rexmt", "persist", "keep", - "2msl", "delack", "rcvtime"); - } - if (!xflag && !Tflag) { - printf((Aflag && !Wflag) ? - "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s" : - "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s", - "Proto", "Recv-Q", "Send-Q", - "Local Address", "Foreign Address"); - printf("(state)\n"); } + putchar('\n'); first = 0; } if (Lflag && so->so_qlimit == 0) continue; if (Aflag) { if (istcp) - printf("%8lx ", (u_long)inp->inp_ppcb); + printf("%*lx ", 2 * (int)sizeof(void *), (u_long)inp->inp_ppcb); else - printf("%8lx ", (u_long)so->so_pcb); + printf("%*lx ", 2 * (int)sizeof(void *), (u_long)so->so_pcb); } #ifdef INET6 if ((inp->inp_vflag & INP_IPV6) != 0) @@ -521,23 +522,13 @@ protopr(u_long off, const char *name, in #endif /* INET6 */ } if (xflag) { - if (Lflag) - printf("%21s %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u ", - " ", - so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt, - so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt, - so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat, - so->so_rcv.sb_lowat, so->so_snd.sb_lowat, - so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt, - so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax); - else - printf("%6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u ", - so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt, - so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt, - so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat, - so->so_rcv.sb_lowat, so->so_snd.sb_lowat, - so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt, - so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax); + printf("%6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u %6u", + so->so_rcv.sb_mcnt, so->so_snd.sb_mcnt, + so->so_rcv.sb_ccnt, so->so_snd.sb_ccnt, + so->so_rcv.sb_hiwat, so->so_snd.sb_hiwat, + so->so_rcv.sb_lowat, so->so_snd.sb_lowat, + so->so_rcv.sb_mbcnt, so->so_snd.sb_mbcnt, + so->so_rcv.sb_mbmax, so->so_snd.sb_mbmax); } if (istcp && !Lflag && !xflag && !Tflag) { if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES) From owner-svn-src-stable@FreeBSD.ORG Tue Mar 29 17:52:45 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 964A6106566C; Tue, 29 Mar 2011 17:52:45 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 69C3B8FC21; Tue, 29 Mar 2011 17:52:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THqjXx036030; Tue, 29 Mar 2011 17:52:45 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THqjeF036028; Tue, 29 Mar 2011 17:52:45 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103291752.p2THqjeF036028@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 17:52:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220138 - stable/8/lib/libc/stdio X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 17:52:45 -0000 Author: trociny Date: Tue Mar 29 17:52:45 2011 New Revision: 220138 URL: http://svn.freebsd.org/changeset/base/220138 Log: MFC r219342, r219346: r219342 (pjd): Fix various issues in how %#T is handled: - If precision is 0, don't print period followed by no digits. - If precision is 0 stop printing units as soon as possible (eg. if we have three years and five days and precision is 0 print only 3y5d). - If precision is not 0, print all units (eg. 3y0d0h0m0s.00). r219346 (pjd): Because we call __printf_out() with a on-stack buffer, also call __printf_flush() so we are sure it won't be referenced after we return. Approved by: kib (co-mentor), pjd (mentor) Modified: stable/8/lib/libc/stdio/xprintf_time.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/stdio/xprintf_time.c ============================================================================== --- stable/8/lib/libc/stdio/xprintf_time.c Tue Mar 29 17:47:25 2011 (r220137) +++ stable/8/lib/libc/stdio/xprintf_time.c Tue Mar 29 17:52:45 2011 (r220138) @@ -62,7 +62,7 @@ __printf_render_time(struct __printf_io struct timespec *ts; time_t *tp; intmax_t t, tx; - int i, prec, nsec; + int i, prec, nsec, ret; prec = 0; if (pi->is_long) { @@ -79,6 +79,12 @@ __printf_render_time(struct __printf_io tp = *((time_t **)arg[0]); t = *tp; } + if (pi->is_long || pi->is_long_double) { + if (pi->prec >= 0) + prec = pi->prec; + if (prec == 0) + nsec = 0; + } p = buf; if (pi->alt) { @@ -87,29 +93,29 @@ __printf_render_time(struct __printf_io p += sprintf(p, "%jdy", t / YEAR); t %= YEAR; } - if (t >= DAY && t != 0) { + if (tx >= DAY && (t != 0 || prec != 0)) { p += sprintf(p, "%jdd", t / DAY); t %= DAY; } - if (t >= HOUR && t != 0) { + if (tx >= HOUR && (t != 0 || prec != 0)) { p += sprintf(p, "%jdh", t / HOUR); t %= HOUR; } - if (t >= MINUTE && t != 0) { + if (tx >= MINUTE && (t != 0 || prec != 0)) { p += sprintf(p, "%jdm", t / MINUTE); t %= MINUTE; } - if (t != 0 || tx == 0) + if (t != 0 || tx == 0 || prec != 0) p += sprintf(p, "%jds", t); } else { p += sprintf(p, "%jd", (intmax_t)t); } - if (pi->is_long || pi->is_long_double) { - if (pi->prec >= 0) - prec = pi->prec; + if (prec != 0) { for (i = prec; i < 9; i++) nsec /= 10; p += sprintf(p, ".%.*d", prec, nsec); } - return(__printf_out(io, pi, buf, p - buf)); + ret = __printf_out(io, pi, buf, p - buf); + __printf_flush(io); + return (ret); } From owner-svn-src-stable@FreeBSD.ORG Tue Mar 29 17:55:16 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F3071065672; Tue, 29 Mar 2011 17:55:16 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2CA508FC15; Tue, 29 Mar 2011 17:55:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THtGiC036130; Tue, 29 Mar 2011 17:55:16 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THtGcr036128; Tue, 29 Mar 2011 17:55:16 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103291755.p2THtGcr036128@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 17:55:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220139 - stable/8/lib/libutil X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 17:55:16 -0000 Author: trociny Date: Tue Mar 29 17:55:15 2011 New Revision: 220139 URL: http://svn.freebsd.org/changeset/base/220139 Log: MFC r200035, r219344: Bring in missing headers and primitive type declarations into to make it work when included by itself. r200035 (ed): Make work when included by itself. There are several reasons why it didn't work: - It was missing for __BEGIN_DECLS. - It uses various primitive types that were not declared. r219344 (pjd): expand_number() needs uint64_t, declare it here if not already declared. Approved by: kib (co-mentor), pjd (mentor) Modified: stable/8/lib/libutil/libutil.h Directory Properties: stable/8/lib/libutil/ (props changed) Modified: stable/8/lib/libutil/libutil.h ============================================================================== --- stable/8/lib/libutil/libutil.h Tue Mar 29 17:52:45 2011 (r220138) +++ stable/8/lib/libutil/libutil.h Tue Mar 29 17:55:15 2011 (r220139) @@ -39,6 +39,39 @@ #ifndef _LIBUTIL_H_ #define _LIBUTIL_H_ +#include +#include + +#ifndef _GID_T_DECLARED +typedef __gid_t gid_t; +#define _GID_T_DECLARED +#endif + +#ifndef _INT64_T_DECLARED +typedef __int64_t int64_t; +#define _INT64_T_DECLARED +#endif + +#ifndef _UINT64_T_DECLARED +typedef __uint64_t uint64_t; +#define _UINT64_T_DECLARED +#endif + +#ifndef _PID_T_DECLARED +typedef __pid_t pid_t; +#define _PID_T_DECLARED +#endif + +#ifndef _SIZE_T_DECLARED +typedef __size_t size_t; +#define _SIZE_T_DECLARED +#endif + +#ifndef _UID_T_DECLARED +typedef __uid_t uid_t; +#define _UID_T_DECLARED +#endif + #define PROPERTY_MAX_NAME 64 #define PROPERTY_MAX_VALUE 512 From owner-svn-src-stable@FreeBSD.ORG Tue Mar 29 17:57:40 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 83CDD1065674; Tue, 29 Mar 2011 17:57:40 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 718A98FC12; Tue, 29 Mar 2011 17:57:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THveUl036208; Tue, 29 Mar 2011 17:57:40 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THveVn036206; Tue, 29 Mar 2011 17:57:40 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103291757.p2THveVn036206@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 17:57:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220140 - stable/8/include X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 17:57:40 -0000 Author: trociny Date: Tue Mar 29 17:57:40 2011 New Revision: 220140 URL: http://svn.freebsd.org/changeset/base/220140 Log: MFC r219343: r219343 (pjd): Include stdio.h, so we can include printf.h in any order, as it needs FILE. Approved by: kib (co-mentor), pjd (mentor) Modified: stable/8/include/printf.h Directory Properties: stable/8/include/ (props changed) Modified: stable/8/include/printf.h ============================================================================== --- stable/8/include/printf.h Tue Mar 29 17:55:15 2011 (r220139) +++ stable/8/include/printf.h Tue Mar 29 17:57:40 2011 (r220140) @@ -29,6 +29,7 @@ #ifndef _PRINTF_H_ #define _PRINTF_H_ +#include #include /* From owner-svn-src-stable@FreeBSD.ORG Tue Mar 29 17:59:30 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98853106566B; Tue, 29 Mar 2011 17:59:30 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 865138FC13; Tue, 29 Mar 2011 17:59:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2THxUiV036276; Tue, 29 Mar 2011 17:59:30 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2THxU9g036274; Tue, 29 Mar 2011 17:59:30 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103291759.p2THxU9g036274@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 17:59:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220141 - stable/8/share/mk X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 17:59:30 -0000 Author: trociny Date: Tue Mar 29 17:59:30 2011 New Revision: 220141 URL: http://svn.freebsd.org/changeset/base/220141 Log: MFC r219368: r219368 (pjd): To be able to use printf extensions we need to turn off gcc format checking. Following the convention of NO_WERROR and NO_WCAST_ALIGN add NO_WFORMAT, which, when defined in Makefile, turns off compile-time format checking (by adding -Wno-format), but still allows to use high WARNS level. Approved by: kib (co-mentor), pjd (mentor) Modified: stable/8/share/mk/bsd.sys.mk Directory Properties: stable/8/share/mk/ (props changed) Modified: stable/8/share/mk/bsd.sys.mk ============================================================================== --- stable/8/share/mk/bsd.sys.mk Tue Mar 29 17:57:40 2011 (r220140) +++ stable/8/share/mk/bsd.sys.mk Tue Mar 29 17:59:30 2011 (r220141) @@ -69,6 +69,9 @@ CWARNFLAGS += -Werror . endif . endif . endif +. if defined(NO_WFORMAT) +CWARNFLAGS += -Wno-format +. endif .endif .if defined(IGNORE_PRAGMA) From owner-svn-src-stable@FreeBSD.ORG Tue Mar 29 20:58:25 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9D61C106568A; Tue, 29 Mar 2011 20:58:25 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 877E38FC2B; Tue, 29 Mar 2011 20:58:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2TKwPRX040811; Tue, 29 Mar 2011 20:58:25 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2TKwPL6040796; Tue, 29 Mar 2011 20:58:25 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201103292058.p2TKwPL6040796@svn.freebsd.org> From: Mikolaj Golub Date: Tue, 29 Mar 2011 20:58:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220151 - in stable/8/sbin: hastctl hastd X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Mar 2011 20:58:25 -0000 Author: trociny Date: Tue Mar 29 20:58:25 2011 New Revision: 220151 URL: http://svn.freebsd.org/changeset/base/220151 Log: MFC r219351, r219354, r219369, r219370, r219371, r219372, r219373, r219385, r219482, r219620, r219669, r219721, r219813, r219814, r219815, r219816, r219817, r219818, r219821, r219830, r219831, r219832, r219833, r219837, r219844, r219864, r219873, r219879, r219882, r219884, r219887, r219900: r219351 (pjd): Allow to checksum on-the-wire data using either CRC32 or SHA256. r219354 (pjd): Allow to compress on-the-wire data using two algorithms: - HOLE - it simply turns all-zero blocks into few bytes header; it is extremely fast, so it is turned on by default; it is mostly intended to speed up initial synchronization where we expect many zeros; - LZF - very fast algorithm by Marc Alexander Lehmann, which shows very decent compression ratio and has BSD license. r219369 (pjd): Provides three states for pjdlog_initialized, so we can also tell that this is fist initialization ever. r219370 (pjd), r219385 (pjd): - Turn on printf extentions. - Load support for %T for pritning time. - Add support for %N for printing number in human readable form. - Add support for %S for printing sockaddr structure (currently only AF_INET family is supported, as this is all we need in HAST). - Disable gcc compile-time format checking as this will no longer work. r219371 (pjd): Use %S to print IP address and port number. r219372 (pjd): - Log size of data to synchronize in human readable form (using %N). - Log synchronization time (using %T). - Log synchronization speed in human readable form (using %N). r219373 (pjd): Print some of the numbers in human readable form (using %N). r219482: Make workers inherit debug level from the main process. r219620 (pjd): In command line options allow size to be specified using k/M/G/T suffixes. r219669 (pjd): Remove #include needed for debugging. r219721: For secondary, set 2 * HAST_KEEPALIVE seconds timeout for incoming connection so the worker will exit if it does not receive packets from the primary during this interval. Reported by: Christian Vogt Tested by: Christian Vogt r219813 (pjd): If there is any traffic on one of out descriptors, we were not checking for long running hooks. Fix it by not using select(2) timeout to decide if we want to check hooks or not. r219814 (pjd): When creating connection on behalf of primary worker, set pjdlog prefix to resource name and role, so that any logs related to that can be identified properly. r219815 (pjd): Add snprlcat() and vsnprlcat() - the functions I'm always missing. They work as a combination of snprintf(3) and strlcat(3) - the caller can append a string build based on the given format. r219816 (pjd): Use snprlcat() instead of two strlcat(3)s. r219817 (pjd): Log when we start hooks checking and when we execute a hook. r219818 (pjd), r219821 (pjd): In hast.conf we define the other node's address in 'remote' variable. This way we know how to connect to secondary node when we are primary. The same variable is used by the secondary node - it only accepts connections from the address stored in 'remote' variable. In cluster configurations it is common that each node has its individual IP address and there is one addtional shared IP address which is assigned to primary node. It seems it is possible that if the shared IP address is from the same network as the individual IP address it might be choosen by the kernel as a source address for connection with the secondary node. Such connection will be rejected by secondary, as it doesn't come from primary node individual IP. Add 'source' variable that allows to specify source IP address we want to bind to before connecting to the secondary node. r219821 (pjd): Forgot to commit this as a part of r219818. r219830 (pjd): Detect situation where resource internal identifier differs. This means that both nodes have separately managed resources that don't have the same data. r219831 (pjd): Be pedantic and free nvout before exiting. r219832 (pjd): Increase debug level of "Checking hooks." message. r219833 (pjd): Remove stale comment. Yes, it is valid to set role back to init. r219837 (pjd): Before handling any events on descriptors check signals so we can update our info about worker processes if any of them was terminated in the meantime. This fixes the problem with 'hastctl status' running from a hook called on split-brain: 1. Secondary calls a hooks and terminates. 2. Hook asks for resource status via 'hastctl status'. 3. The main hastd handles the status request by sending it to the secondary worker who is already dead, but because signals weren't checked yet he doesn't know that and we get EPIPE. r219843 (pjd): Fix typo. r219844 (pjd): Initialize localcnt on first write. This fixes assertion when we create resource, set role to primary, do no writes, then sent it to secondary and accept connection from primary. r219864 (pjd): White space cleanups. r219873 (pjd), r219873 (pjd): The proto API is a general purpose API, so don't use 'hast' in structures or function names. It can now be used outside of HAST. r219879: For requests that are sent only to remote component use the error from remote. r219882: After synchronization is complete we should make primary counters be equal to secondary counters: primary_localcnt = secondary_remotecnt primary_remotecnt = secondary_localcnt Previously it was done wrong and split-brain was observed after primary had synchronized up-to-date data from secondary. r219887 (pjd): Add pjd copyright. r219900 (pjd): Don't create socketpair for connection forwarding between parent and secondary. Secondary doesn't need to connect anywhere. Approved by: pjd (mentor) Added: stable/8/sbin/hastd/crc32.c - copied unchanged from r219351, head/sbin/hastd/crc32.c stable/8/sbin/hastd/crc32.h - copied unchanged from r219351, head/sbin/hastd/crc32.h stable/8/sbin/hastd/hast_checksum.c - copied unchanged from r219351, head/sbin/hastd/hast_checksum.c stable/8/sbin/hastd/hast_checksum.h - copied unchanged from r219351, head/sbin/hastd/hast_checksum.h stable/8/sbin/hastd/hast_compression.c - copied unchanged from r219354, head/sbin/hastd/hast_compression.c stable/8/sbin/hastd/hast_compression.h - copied unchanged from r219354, head/sbin/hastd/hast_compression.h stable/8/sbin/hastd/lzf.c - copied unchanged from r219354, head/sbin/hastd/lzf.c stable/8/sbin/hastd/lzf.h - copied unchanged from r219354, head/sbin/hastd/lzf.h Modified: stable/8/sbin/hastctl/Makefile stable/8/sbin/hastctl/hastctl.8 stable/8/sbin/hastctl/hastctl.c stable/8/sbin/hastd/Makefile stable/8/sbin/hastd/activemap.c stable/8/sbin/hastd/control.c stable/8/sbin/hastd/hast.conf.5 stable/8/sbin/hastd/hast.h stable/8/sbin/hastd/hast_proto.c stable/8/sbin/hastd/hastd.8 stable/8/sbin/hastd/hastd.c stable/8/sbin/hastd/hooks.c stable/8/sbin/hastd/parse.y stable/8/sbin/hastd/pjdlog.c stable/8/sbin/hastd/primary.c stable/8/sbin/hastd/proto.c stable/8/sbin/hastd/proto.h stable/8/sbin/hastd/proto_common.c stable/8/sbin/hastd/proto_impl.h stable/8/sbin/hastd/proto_socketpair.c stable/8/sbin/hastd/proto_tcp4.c stable/8/sbin/hastd/proto_uds.c stable/8/sbin/hastd/secondary.c stable/8/sbin/hastd/subr.c stable/8/sbin/hastd/subr.h stable/8/sbin/hastd/token.l Directory Properties: stable/8/sbin/hastctl/ (props changed) stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastctl/Makefile ============================================================================== --- stable/8/sbin/hastctl/Makefile Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastctl/Makefile Tue Mar 29 20:58:25 2011 (r220151) @@ -6,18 +6,21 @@ PROG= hastctl SRCS= activemap.c +SRCS+= crc32.c SRCS+= ebuf.c -SRCS+= hast_proto.c hastctl.c +SRCS+= hast_checksum.c hast_compression.c hast_proto.c hastctl.c +SRCS+= lzf.c SRCS+= metadata.c SRCS+= nv.c SRCS+= parse.y pjdlog.c -SRCS+= proto.c proto_common.c proto_tcp4.c proto_uds.c +SRCS+= proto.c proto_common.c proto_uds.c SRCS+= token.l SRCS+= subr.c SRCS+= y.tab.h WARNS?= 6 MAN= hastctl.8 +NO_WFORMAT= CFLAGS+=-I${.CURDIR}/../hastd CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" @@ -26,8 +29,8 @@ CFLAGS+=-DINET6 # This is needed to have WARNS > 1. CFLAGS+=-DYY_NO_UNPUT -DPADD= ${LIBL} -LDADD= -ll +DPADD= ${LIBL} ${LIBUTIL} +LDADD= -ll -lutil .if ${MK_OPENSSL} != "no" DPADD+= ${LIBCRYPTO} LDADD+= -lcrypto Modified: stable/8/sbin/hastctl/hastctl.8 ============================================================================== --- stable/8/sbin/hastctl/hastctl.8 Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastctl/hastctl.8 Tue Mar 29 20:58:25 2011 (r220151) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 1, 2010 +.Dd March 13, 2011 .Dt HASTCTL 8 .Os .Sh NAME @@ -113,6 +113,9 @@ Size of the smaller provider used as bac This option can be omitted if node providers have the same size on both sides. .El +.Pp +If size is suffixed with a k, M, G or T, it is taken as a kilobyte, +megabyte, gigabyte or terabyte measurement respectively. .It Cm role Change role of the given resource. The role can be one of: Modified: stable/8/sbin/hastctl/hastctl.c ============================================================================== --- stable/8/sbin/hastctl/hastctl.c Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastctl/hastctl.c Tue Mar 29 20:58:25 2011 (r220151) @@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include @@ -213,8 +213,10 @@ dump_one(struct hast_resource *res) return (ret); printf("resource: %s\n", res->hr_name); - printf(" datasize: %ju\n", (uintmax_t)res->hr_datasize); - printf(" extentsize: %d\n", res->hr_extentsize); + printf(" datasize: %ju (%NB)\n", (uintmax_t)res->hr_datasize, + (intmax_t)res->hr_datasize); + printf(" extentsize: %d (%NB)\n", res->hr_extentsize, + (intmax_t)res->hr_extentsize); printf(" keepdirty: %d\n", res->hr_keepdirty); printf(" localoff: %ju\n", (uintmax_t)res->hr_localoff); printf(" resuid: %ju\n", (uintmax_t)res->hr_resuid); @@ -321,47 +323,33 @@ control_status(struct nv *nv) nv_get_string(nv, "provname%u", ii)); printf(" localpath: %s\n", nv_get_string(nv, "localpath%u", ii)); - printf(" extentsize: %u\n", - (unsigned int)nv_get_uint32(nv, "extentsize%u", ii)); + printf(" extentsize: %u (%NB)\n", + (unsigned int)nv_get_uint32(nv, "extentsize%u", ii), + (intmax_t)nv_get_uint32(nv, "extentsize%u", ii)); printf(" keepdirty: %u\n", (unsigned int)nv_get_uint32(nv, "keepdirty%u", ii)); printf(" remoteaddr: %s\n", nv_get_string(nv, "remoteaddr%u", ii)); + str = nv_get_string(nv, "sourceaddr%u", ii); + if (str != NULL) + printf(" sourceaddr: %s\n", str); printf(" replication: %s\n", nv_get_string(nv, "replication%u", ii)); str = nv_get_string(nv, "status%u", ii); if (str != NULL) printf(" status: %s\n", str); - printf(" dirty: %ju bytes\n", - (uintmax_t)nv_get_uint64(nv, "dirty%u", ii)); + printf(" dirty: %ju (%NB)\n", + (uintmax_t)nv_get_uint64(nv, "dirty%u", ii), + (intmax_t)nv_get_uint64(nv, "dirty%u", ii)); } return (ret); } -static int -numfromstr(const char *str, intmax_t *nump) -{ - intmax_t num; - char *suffix; - int rerrno; - - rerrno = errno; - errno = 0; - num = strtoimax(str, &suffix, 0); - if (errno == 0 && *suffix != '\0') - errno = EINVAL; - if (errno != 0) - return (-1); - *nump = num; - errno = rerrno; - return (0); -} - int main(int argc, char *argv[]) { struct nv *nv; - intmax_t mediasize, extentsize, keepdirty; + int64_t mediasize, extentsize, keepdirty; int cmd, debug, error, ii; const char *optstr; @@ -403,15 +391,15 @@ main(int argc, char *argv[]) debug++; break; case 'e': - if (numfromstr(optarg, &extentsize) < 0) + if (expand_number(optarg, &extentsize) < 0) err(1, "Invalid extentsize"); break; case 'k': - if (numfromstr(optarg, &keepdirty) < 0) + if (expand_number(optarg, &keepdirty) < 0) err(1, "Invalid keepdirty"); break; case 'm': - if (numfromstr(optarg, &mediasize) < 0) + if (expand_number(optarg, &mediasize) < 0) err(1, "Invalid mediasize"); break; case 'h': @@ -481,7 +469,7 @@ main(int argc, char *argv[]) } /* Setup control connection... */ - if (proto_client(cfg->hc_controladdr, &controlconn) < 0) { + if (proto_client(NULL, cfg->hc_controladdr, &controlconn) < 0) { pjdlog_exit(EX_OSERR, "Unable to setup control connection to %s", cfg->hc_controladdr); Modified: stable/8/sbin/hastd/Makefile ============================================================================== --- stable/8/sbin/hastd/Makefile Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/Makefile Tue Mar 29 20:58:25 2011 (r220151) @@ -4,9 +4,10 @@ PROG= hastd SRCS= activemap.c -SRCS+= control.c +SRCS+= control.c crc32.c SRCS+= ebuf.c event.c -SRCS+= hast_proto.c hastd.c hooks.c +SRCS+= hast_checksum.c hast_compression.c hast_proto.c hastd.c hooks.c +SRCS+= lzf.c SRCS+= metadata.c SRCS+= nv.c SRCS+= secondary.c @@ -19,6 +20,8 @@ SRCS+= y.tab.h WARNS?= 6 MAN= hastd.8 hast.conf.5 +NO_WFORMAT= +CFLAGS+=-DPROTO_TCP4_DEFAULT_PORT=8457 CFLAGS+=-I${.CURDIR} CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" Modified: stable/8/sbin/hastd/activemap.c ============================================================================== --- stable/8/sbin/hastd/activemap.c Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/activemap.c Tue Mar 29 20:58:25 2011 (r220151) @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); #define ACTIVEMAP_MAGIC 0xac71e4 struct activemap { int am_magic; /* Magic value. */ - off_t am_mediasize; /* Media size in bytes. */ + off_t am_mediasize; /* Media size in bytes. */ uint32_t am_extentsize; /* Extent size in bytes, must be power of 2. */ uint8_t am_extentshift;/* 2 ^ extentbits == extentsize */ Modified: stable/8/sbin/hastd/control.c ============================================================================== --- stable/8/sbin/hastd/control.c Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/control.c Tue Mar 29 20:58:25 2011 (r220151) @@ -43,6 +43,8 @@ __FBSDID("$FreeBSD$"); #include "hast.h" #include "hastd.h" +#include "hast_checksum.h" +#include "hast_compression.h" #include "hast_proto.h" #include "hooks.h" #include "nv.h" @@ -232,6 +234,8 @@ control_status(struct hastd_config *cfg, nv_add_string(nvout, res->hr_provname, "provname%u", no); nv_add_string(nvout, res->hr_localpath, "localpath%u", no); nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr%u", no); + if (res->hr_sourceaddr[0] != '\0') + nv_add_string(nvout, res->hr_sourceaddr, "sourceaddr%u", no); switch (res->hr_replication) { case HAST_REPLICATION_FULLSYNC: nv_add_string(nvout, "fullsync", "replication%u", no); @@ -246,6 +250,10 @@ control_status(struct hastd_config *cfg, nv_add_string(nvout, "unknown", "replication%u", no); break; } + nv_add_string(nvout, checksum_name(res->hr_checksum), + "checksum%u", no); + nv_add_string(nvout, compression_name(res->hr_compression), + "compression%u", no); nv_add_string(nvout, role2str(res->hr_role), "role%u", no); switch (res->hr_role) { @@ -319,7 +327,7 @@ control_handle(struct hastd_config *cfg) if (cmd == HASTCTL_SET_ROLE) { role = nv_get_uint8(nvin, "role"); switch (role) { - case HAST_ROLE_INIT: /* Is that valid to set, hmm? */ + case HAST_ROLE_INIT: case HAST_ROLE_PRIMARY: case HAST_ROLE_SECONDARY: break; Copied: stable/8/sbin/hastd/crc32.c (from r219351, head/sbin/hastd/crc32.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/crc32.c Tue Mar 29 20:58:25 2011 (r220151, copy of r219351, head/sbin/hastd/crc32.c) @@ -0,0 +1,115 @@ +/*- + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. + */ + +/* + * First, the polynomial itself and its table of feedback terms. The + * polynomial is + * X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 + * + * Note that we take it "backwards" and put the highest-order term in + * the lowest-order bit. The X^32 term is "implied"; the LSB is the + * X^31 term, etc. The X^0 term (usually shown as "+1") results in + * the MSB being 1 + * + * Note that the usual hardware shift register implementation, which + * is what we're using (we're merely optimizing it by doing eight-bit + * chunks at a time) shifts bits into the lowest-order term. In our + * implementation, that means shifting towards the right. Why do we + * do it this way? Because the calculated CRC must be transmitted in + * order from highest-order term to lowest-order term. UARTs transmit + * characters in order from LSB to MSB. By storing the CRC this way + * we hand it to the UART in the order low-byte to high-byte; the UART + * sends each low-bit to hight-bit; and the result is transmission bit + * by bit from highest- to lowest-order term without requiring any bit + * shuffling on our part. Reception works similarly + * + * The feedback terms table consists of 256, 32-bit entries. Notes + * + * The table can be generated at runtime if desired; code to do so + * is shown later. It might not be obvious, but the feedback + * terms simply represent the results of eight shift/xor opera + * tions for all combinations of data and CRC register values + * + * The values must be right-shifted by eight bits by the "updcrc + * logic; the shift must be unsigned (bring in zeroes). On some + * hardware you could probably optimize the shift in assembler by + * using byte-swap instructions + * polynomial $edb88320 + * + * + * CRC32 code derived from work by Gary S. Brown. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include + +uint32_t crc32_tab[] = { + 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, + 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, + 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, + 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, + 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, + 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, + 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, + 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, + 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, + 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, + 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, + 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, + 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, + 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, + 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, + 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, + 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, + 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, + 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, + 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, + 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, + 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, + 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, + 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, + 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, + 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, + 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, + 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, + 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, + 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, + 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, + 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, + 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, + 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, + 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, + 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, + 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, + 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, + 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, + 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, + 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, + 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, + 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d +}; + +/* + * A function that calculates the CRC-32 based on the table above is + * given below for documentation purposes. An equivalent implementation + * of this function that's actually used in the kernel can be found + * in sys/libkern.h, where it can be inlined. + * + * uint32_t + * crc32(const void *buf, size_t size) + * { + * const uint8_t *p = buf; + * uint32_t crc; + * + * crc = ~0U; + * while (size--) + * crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); + * return crc ^ ~0U; + * } + */ Copied: stable/8/sbin/hastd/crc32.h (from r219351, head/sbin/hastd/crc32.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/crc32.h Tue Mar 29 20:58:25 2011 (r220151, copy of r219351, head/sbin/hastd/crc32.h) @@ -0,0 +1,28 @@ +/*- + * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or + * code or tables extracted from it, as desired without restriction. + * + * $FreeBSD$ + */ + +#ifndef _CRC32_H_ +#define _CRC32_H_ + +#include /* uint32_t */ +#include /* size_t */ + +extern uint32_t crc32_tab[]; + +static __inline uint32_t +crc32(const void *buf, size_t size) +{ + const uint8_t *p = buf; + uint32_t crc; + + crc = ~0U; + while (size--) + crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); + return (crc ^ ~0U); +} + +#endif /* !_CRC32_H_ */ Modified: stable/8/sbin/hastd/hast.conf.5 ============================================================================== --- stable/8/sbin/hastd/hast.conf.5 Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/hast.conf.5 Tue Mar 29 20:58:25 2011 (r220151) @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 The FreeBSD Foundation -.\" Copyright (c) 2010 Pawel Jakub Dawidek +.\" Copyright (c) 2010-2011 Pawel Jakub Dawidek .\" All rights reserved. .\" .\" This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 30, 2010 +.Dd March 20, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -59,6 +59,8 @@ file is following: control listen replication +checksum +compression timeout exec @@ -77,6 +79,8 @@ on { resource { # Resource section replication + checksum + compression name local timeout @@ -89,6 +93,7 @@ resource { local # Required remote + source } on { # Resource-node section @@ -97,6 +102,7 @@ resource { local # Required remote + source } } .Ed @@ -201,6 +207,36 @@ The .Ic async replication mode is currently not implemented. .El +.It Ic checksum Aq algorithm +.Pp +Checksum algorithm should be one of the following: +.Bl -tag -width ".Ic sha256" +.It Ic none +No checksum will be calculated for the data being send over the network. +This is the default setting. +.It Ic crc32 +CRC32 checksum will be calculated. +.It Ic sha256 +SHA256 checksum will be calculated. +.El +.It Ic compression Aq algorithm +.Pp +Compression algorithm should be one of the following: +.Bl -tag -width ".Ic none" +.It Ic none +Data send over the network will not be compressed. +.It Ic hole +Only blocks that contain all zeros will be compressed. +This is very useful for initial synchronization where potentially many blocks +are still all zeros. +There should be no measurable performance overhead when this algorithm is being +used. +This is the default setting. +.It Ic lzf +The LZF algorithm by Marc Alexander Lehmann will be used to compress the data +send over the network. +LZF is very fast, general purpose compression algorithm. +.El .It Ic timeout Aq seconds .Pp Connection timeout in seconds. @@ -303,6 +339,14 @@ A special value of .Va none can be used when the remote address is not yet known (eg. the other node is not set up yet). +.It Ic source Aq addr +.Pp +Local address to bind to before connecting to the remote +.Nm hastd +daemon. +Format is the same as for the +.Ic listen +statement. .El .Sh FILES .Bl -tag -width ".Pa /var/run/hastctl" -compact @@ -333,10 +377,12 @@ resource shared { resource tank { on hasta { local /dev/mirror/tanka + source tcp4://10.0.0.1 remote tcp4://10.0.0.2 } on hastb { local /dev/mirror/tankb + source tcp4://10.0.0.2 remote tcp4://10.0.0.1 } } Modified: stable/8/sbin/hastd/hast.h ============================================================================== --- stable/8/sbin/hastd/hast.h Tue Mar 29 20:53:51 2011 (r220150) +++ stable/8/sbin/hastd/hast.h Tue Mar 29 20:58:25 2011 (r220151) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -85,7 +86,6 @@ #define HAST_TIMEOUT 5 #define HAST_CONFIG "/etc/hast.conf" #define HAST_CONTROL "/var/run/hastctl" -#define HASTD_PORT 8457 #define HASTD_LISTEN "tcp4://0.0.0.0:8457" #define HASTD_PIDFILE "/var/run/hastd.pid" @@ -97,6 +97,9 @@ #define HAST_ADDRSIZE 1024 #define HAST_TOKEN_SIZE 16 +/* Number of seconds to sleep between reconnect retries or keepalive packets. */ +#define HAST_KEEPALIVE 10 + struct hastd_config { /* Address to communicate with hastctl(8). */ char hc_controladdr[HAST_ADDRSIZE]; @@ -116,6 +119,14 @@ struct hastd_config { #define HAST_REPLICATION_MEMSYNC 1 #define HAST_REPLICATION_ASYNC 2 +#define HAST_COMPRESSION_NONE 0 +#define HAST_COMPRESSION_HOLE 1 +#define HAST_COMPRESSION_LZF 2 + +#define HAST_CHECKSUM_NONE 0 +#define HAST_CHECKSUM_CRC32 1 +#define HAST_CHECKSUM_SHA256 2 + /* * Structure that describes single resource. */ @@ -132,6 +143,10 @@ struct hast_resource { int hr_keepdirty; /* Path to a program to execute on various events. */ char hr_exec[PATH_MAX]; + /* Compression algorithm. */ + int hr_compression; + /* Checksum algorithm. */ + int hr_checksum; /* Path to local component. */ char hr_localpath[PATH_MAX]; @@ -153,6 +168,8 @@ struct hast_resource { /* Address of the remote component. */ char hr_remoteaddr[HAST_ADDRSIZE]; + /* Local address to bind to for outgoing connections. */ + char hr_sourceaddr[HAST_ADDRSIZE]; /* Connection for incoming data. */ struct proto_conn *hr_remotein; /* Connection for outgoing data. */ Copied: stable/8/sbin/hastd/hast_checksum.c (from r219351, head/sbin/hastd/hast_checksum.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/hast_checksum.c Tue Mar 29 20:58:25 2011 (r220151, copy of r219351, head/sbin/hastd/hast_checksum.c) @@ -0,0 +1,169 @@ +/*- + * Copyright (c) 2011 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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 +#include +#include + +#ifdef HAVE_CRYPTO +#include +#endif + +#include +#include +#include +#include + +#include "hast_checksum.h" + +#ifdef HAVE_CRYPTO +#define MAX_HASH_SIZE SHA256_DIGEST_LENGTH +#else +#define MAX_HASH_SIZE 4 +#endif + +static int +hast_crc32_checksum(const unsigned char *data, size_t size, + unsigned char *hash, size_t *hsizep) +{ + uint32_t crc; + + crc = crc32(data, size); + /* XXXPJD: Do we have to use htole32() on crc first? */ + bcopy(&crc, hash, sizeof(crc)); + *hsizep = sizeof(crc); + + return (0); +} + +#ifdef HAVE_CRYPTO +static int +hast_sha256_checksum(const unsigned char *data, size_t size, + unsigned char *hash, size_t *hsizep) +{ + SHA256_CTX ctx; + + SHA256_Init(&ctx); + SHA256_Update(&ctx, data, size); + SHA256_Final(hash, &ctx); + *hsizep = SHA256_DIGEST_LENGTH; + + return (0); +} +#endif /* HAVE_CRYPTO */ + +const char * +checksum_name(int num) +{ + + switch (num) { + case HAST_CHECKSUM_NONE: + return ("none"); + case HAST_CHECKSUM_CRC32: + return ("crc32"); + case HAST_CHECKSUM_SHA256: + return ("sha256"); + } + return ("unknown"); +} + +int +checksum_send(const struct hast_resource *res, struct nv *nv, void **datap, + size_t *sizep, bool *freedatap __unused) +{ + unsigned char hash[MAX_HASH_SIZE]; + size_t hsize; + int ret; + + switch (res->hr_checksum) { + case HAST_CHECKSUM_NONE: + return (0); + case HAST_CHECKSUM_CRC32: + ret = hast_crc32_checksum(*datap, *sizep, hash, &hsize); + break; +#ifdef HAVE_CRYPTO + case HAST_CHECKSUM_SHA256: + ret = hast_sha256_checksum(*datap, *sizep, hash, &hsize); + break; +#endif + default: + PJDLOG_ABORT("Invalid checksum: %d.", res->hr_checksum); + } + + if (ret != 0) + return (ret); + nv_add_string(nv, checksum_name(res->hr_checksum), "checksum"); + nv_add_uint8_array(nv, hash, hsize, "hash"); + if (nv_error(nv) != 0) { + errno = nv_error(nv); + return (-1); + } + return (0); +} + +int +checksum_recv(const struct hast_resource *res __unused, struct nv *nv, + void **datap, size_t *sizep, bool *freedatap __unused) +{ + unsigned char chash[MAX_HASH_SIZE]; + const unsigned char *rhash; + size_t chsize, rhsize; + const char *algo; + int ret; + + algo = nv_get_string(nv, "checksum"); + if (algo == NULL) + return (0); /* No checksum. */ + rhash = nv_get_uint8_array(nv, &rhsize, "hash"); + if (rhash == NULL) { + pjdlog_error("Hash is missing."); + return (-1); /* Hash not found. */ + } + if (strcmp(algo, "crc32") == 0) + ret = hast_crc32_checksum(*datap, *sizep, chash, &chsize); +#ifdef HAVE_CRYPTO + else if (strcmp(algo, "sha256") == 0) + ret = hast_sha256_checksum(*datap, *sizep, chash, &chsize); +#endif + else { + pjdlog_error("Unknown checksum algorithm '%s'.", algo); + return (-1); /* Unknown checksum algorithm. */ + } + if (rhsize != chsize) { + pjdlog_error("Invalid hash size (%zu) for %s, should be %zu.", + rhsize, algo, chsize); + return (-1); /* Different hash size. */ + } + if (bcmp(rhash, chash, chsize) != 0) { + pjdlog_error("Hash mismatch."); + return (-1); /* Hash mismatch. */ + } + + return (0); +} Copied: stable/8/sbin/hastd/hast_checksum.h (from r219351, head/sbin/hastd/hast_checksum.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/hast_checksum.h Tue Mar 29 20:58:25 2011 (r220151, copy of r219351, head/sbin/hastd/hast_checksum.h) @@ -0,0 +1,44 @@ +/*- + * Copyright (c) 2011 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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$ + */ + +#ifndef _HAST_CHECKSUM_H_ +#define _HAST_CHECKSUM_H_ + +#include /* size_t */ + +#include +#include + +const char *checksum_name(int num); + +int checksum_send(const struct hast_resource *res, struct nv *nv, + void **datap, size_t *sizep, bool *freedatap); +int checksum_recv(const struct hast_resource *res, struct nv *nv, + void **datap, size_t *sizep, bool *freedatap); + +#endif /* !_HAST_CHECKSUM_H_ */ Copied: stable/8/sbin/hastd/hast_compression.c (from r219354, head/sbin/hastd/hast_compression.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/sbin/hastd/hast_compression.c Tue Mar 29 20:58:25 2011 (r220151, copy of r219354, head/sbin/hastd/hast_compression.c) @@ -0,0 +1,283 @@ +/*- + * Copyright (c) 2011 Pawel Jakub Dawidek + * 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 AUTHORS 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 AUTHORS 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 + +#include +#include +#include + +#include +#include +#include +#include + +#include "hast_compression.h" + +static bool +allzeros(const void *data, size_t size) +{ + const uint64_t *p = data; + unsigned int i; + uint64_t v; + + PJDLOG_ASSERT((size % sizeof(*p)) == 0); + + /* + * This is the fastest method I found for checking if the given + * buffer contain all zeros. + * Because inside the loop we don't check at every step, we would + * get an answer only after walking through entire buffer. + * To return early if the buffer doesn't contain all zeros, we probe + * 8 bytes at the begining, in the middle and at the end of the buffer + * first. + */ + + size >>= 3; /* divide by 8 */ + if ((p[0] | p[size >> 1] | p[size - 1]) != 0) + return (false); + v = 0; + for (i = 0; i < size; i++) + v |= *p++; + return (v == 0); +} + +static void * +hast_hole_compress(const unsigned char *data, size_t *sizep) +{ + uint32_t size; + void *newbuf; + + if (!allzeros(data, *sizep)) + return (NULL); + + newbuf = malloc(sizeof(size)); + if (newbuf == NULL) { + pjdlog_warning("Unable to compress (no memory: %zu).", + (size_t)*sizep); + return (NULL); + } + size = htole32((uint32_t)*sizep); + bcopy(&size, newbuf, sizeof(size)); + *sizep = sizeof(size); + + return (newbuf); +} + +static void * +hast_hole_decompress(const unsigned char *data, size_t *sizep) +{ + uint32_t size; + void *newbuf; + + if (*sizep != sizeof(size)) { + pjdlog_error("Unable to decompress (invalid size: %zu).", + *sizep); + return (NULL); + } + + bcopy(data, &size, sizeof(size)); + size = le32toh(size); + + newbuf = malloc(size); + if (newbuf == NULL) { + pjdlog_error("Unable to decompress (no memory: %zu).", + (size_t)size); + return (NULL); + } + bzero(newbuf, size); + *sizep = size; + + return (newbuf); +} + +/* Minimum block size to try to compress. */ +#define HAST_LZF_COMPRESS_MIN 1024 + +static void * +hast_lzf_compress(const unsigned char *data, size_t *sizep) +{ + unsigned char *newbuf; + uint32_t origsize; + size_t newsize; + + origsize = *sizep; + + if (origsize <= HAST_LZF_COMPRESS_MIN) + return (NULL); + + newsize = sizeof(origsize) + origsize - HAST_LZF_COMPRESS_MIN; + newbuf = malloc(newsize); + if (newbuf == NULL) { + pjdlog_warning("Unable to compress (no memory: %zu).", + newsize); + return (NULL); + } + newsize = lzf_compress(data, *sizep, newbuf + sizeof(origsize), + newsize - sizeof(origsize)); + if (newsize == 0) { + free(newbuf); + return (NULL); + } + origsize = htole32(origsize); + bcopy(&origsize, newbuf, sizeof(origsize)); + + *sizep = sizeof(origsize) + newsize; + return (newbuf); +} + +static void * +hast_lzf_decompress(const unsigned char *data, size_t *sizep) +{ + unsigned char *newbuf; + uint32_t origsize; + size_t newsize; + + PJDLOG_ASSERT(*sizep > sizeof(origsize)); + + bcopy(data, &origsize, sizeof(origsize)); + origsize = le32toh(origsize); + PJDLOG_ASSERT(origsize > HAST_LZF_COMPRESS_MIN); + + newbuf = malloc(origsize); + if (newbuf == NULL) { + pjdlog_error("Unable to decompress (no memory: %zu).", + (size_t)origsize); + return (NULL); + } + newsize = lzf_decompress(data + sizeof(origsize), + *sizep - sizeof(origsize), newbuf, origsize); + if (newsize == 0) { + free(newbuf); + pjdlog_error("Unable to decompress."); + return (NULL); + } + PJDLOG_ASSERT(newsize == origsize); + + *sizep = newsize; + return (newbuf); +} + +const char * +compression_name(int num) +{ + + switch (num) { + case HAST_COMPRESSION_NONE: + return ("none"); + case HAST_COMPRESSION_HOLE: + return ("hole"); + case HAST_COMPRESSION_LZF: + return ("lzf"); + } + return ("unknown"); +} + +int +compression_send(const struct hast_resource *res, struct nv *nv, void **datap, + size_t *sizep, bool *freedatap) +{ + unsigned char *newbuf; + int compression; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@FreeBSD.ORG Thu Mar 31 06:29:16 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 290B3106566C; Thu, 31 Mar 2011 06:29:16 +0000 (UTC) (envelope-from edwin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 15ADA8FC0C; Thu, 31 Mar 2011 06:29:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V6TG5T093914; Thu, 31 Mar 2011 06:29:16 GMT (envelope-from edwin@svn.freebsd.org) Received: (from edwin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V6TG6n093911; Thu, 31 Mar 2011 06:29:16 GMT (envelope-from edwin@svn.freebsd.org) Message-Id: <201103310629.p2V6TG6n093911@svn.freebsd.org> From: Edwin Groothuis Date: Thu, 31 Mar 2011 06:29:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220183 - stable/8/usr.sbin/tzsetup X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 06:29:16 -0000 Author: edwin Date: Thu Mar 31 06:29:15 2011 New Revision: 220183 URL: http://svn.freebsd.org/changeset/base/220183 Log: MFC of 198254, 198255, 198350, 198267, 209190, 208831, 208830, 210243 198254: When tzsetup is run as non-root and the "CMOS clock question on UTC" is answered as No, it would abort without properly ending the dialog session. 198255: Make the usage of the default zoneinfo file to install clearer. 198350: - Add support for chrooted installs. - Add examples to the man-page. 198267: Instead of having to know which timezone was picked last time, you now can run "tzsetup -r" which will reinstall the last choice. This data is recorded in /var/db/zoneinfo. 209190: Use literal format strings. Found by clang. 208831: Add comment that this value is unused. It is obvious that it isn't used, but both clang and Coverity talk about it. 208830: When there is a problem with writing, also bail out. Found with the clang checker. 210243: Fix support for chrooted installs. Modified: stable/8/usr.sbin/tzsetup/tzsetup.8 stable/8/usr.sbin/tzsetup/tzsetup.c Directory Properties: stable/8/usr.sbin/tzsetup/ (props changed) Modified: stable/8/usr.sbin/tzsetup/tzsetup.8 ============================================================================== --- stable/8/usr.sbin/tzsetup/tzsetup.8 Thu Mar 31 06:11:49 2011 (r220182) +++ stable/8/usr.sbin/tzsetup/tzsetup.8 Thu Mar 31 06:29:15 2011 (r220183) @@ -31,8 +31,9 @@ .Nd set local timezone .Sh SYNOPSIS .Nm -.Op Fl ns -.Op Ar default +.Op Fl nrs +.Op Fl C Ar chroot directory +.Op Ar zoneinfo file | zoneinfo name .Sh DESCRIPTION The .Nm @@ -49,17 +50,26 @@ the hardware clock does not keep .Pp The following option is available: .Bl -tag -offset indent -width Fl +.It Fl C Ar chroot directory +Open all files and directories relative to +.Ar chroot directory . .It Fl n Do not create or copy files. +.It Fl r +Reinstall the zoneinfo file installed last time. The name is obtained from +.Pa /var/db/zoneinfo . .It Fl s Skip the initial question about adjusting the clock if not set to .Tn UTC . .El .Pp -It is possible to short-circuit the menu system by specifying a -.Ar default -on the command line; this is intended mainly for pre-configured -installation scripts. +It is possible to short-circuit the menu system by specifying the +location of a +.Ar zoneinfo file +or the name of the +.Ar zoneinfo name +on the command line; this is intended mainly for pre-configured installation +scripts or people who know which zoneinfo they want to install. .Sh TIMEZONE DATABASE The contents of the timezone database are indexed by .Pa /usr/share/zoneinfo/zone.tab . @@ -93,19 +103,36 @@ historically minded. .Sh FILES .Bl -tag -width /usr/share/zoneinfo/zone.tab -compact .It Pa /etc/localtime -current time zone file +current time zone file. .It Pa /etc/wall_cmos_clock see .Xr adjkerntz 8 . .It Pa /usr/share/misc/iso3166 mapping of .Tn ISO -3166 territory codes to names +3166 territory codes to names. .It Pa /usr/share/zoneinfo -directory for zoneinfo files +directory for zoneinfo files. .It Pa /usr/share/zoneinfo/zone.tab -mapping of timezone file to country and location +mapping of timezone file to country and location. +.It Pa /var/db/zoneinfo +saved name of the timezone file installed last. .El +.Sh EXAMPLES +Normal usage, to select the right zoneinfo file via the dialog-based +user interface: +.Dl # tzsetup +Install the file +.Pa /usr/share/zoneinfo/Australia/Sydney : +.Dl # tzsetup /usr/share/zoneinfo/Australia/Sydney +Install the zoneinfo file for Australia/Sydney, assumed to be located +in +.Pa /usr/share/zoneinfo : +.Dl # tzsetup Australia/Sydney +After a reinstall of the zoneinfo files, you can reinstall the +latest installed zoneinfo file: (as specified in +.Pa /var/db/zoneinfo ) +.Dl # tzsetup -r .Sh SEE ALSO .Xr date 1 , .Xr adjtime 2 , Modified: stable/8/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- stable/8/usr.sbin/tzsetup/tzsetup.c Thu Mar 31 06:11:49 2011 (r220182) +++ stable/8/usr.sbin/tzsetup/tzsetup.c Thu Mar 31 06:29:15 2011 (r220183) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -52,9 +53,17 @@ __FBSDID("$FreeBSD$"); #define _PATH_ISO3166 "/usr/share/misc/iso3166" #define _PATH_ZONEINFO "/usr/share/zoneinfo" #define _PATH_LOCALTIME "/etc/localtime" +#define _PATH_DB "/var/db/zoneinfo" #define _PATH_WALL_CMOS_CLOCK "/etc/wall_cmos_clock" +static char path_zonetab[MAXPATHLEN], path_iso3166[MAXPATHLEN], + path_zoneinfo[MAXPATHLEN], path_localtime[MAXPATHLEN], + path_db[MAXPATHLEN], path_wall_cmos_clock[MAXPATHLEN]; + static int reallydoit = 1; +static int reinstall = 0; +static int usedialog = 1; +static char *chrootenv = NULL; static void usage(void); static int continent_country_menu(dialogMenuItem *); @@ -193,15 +202,15 @@ read_iso3166_table(void) char *s, *t, *name; int lineno; - fp = fopen(_PATH_ISO3166, "r"); + fp = fopen(path_iso3166, "r"); if (!fp) - err(1, _PATH_ISO3166); + err(1, "%s", path_iso3166); lineno = 0; while ((s = fgetln(fp, &len)) != 0) { lineno++; if (s[len - 1] != '\n') - errx(1, _PATH_ISO3166 ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_iso3166, lineno); s[len - 1] = '\0'; if (s[0] == '#' || strspn(s, " \t") == len - 1) continue; @@ -209,26 +218,25 @@ read_iso3166_table(void) /* Isolate the two-letter code. */ t = strsep(&s, "\t"); if (t == 0 || strlen(t) != 2) - errx(1, _PATH_ISO3166 ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_iso3166, lineno); if (t[0] < 'A' || t[0] > 'Z' || t[1] < 'A' || t[1] > 'Z') - errx(1, _PATH_ISO3166 ":%d: invalid code `%s'", + errx(1, "%s:%d: invalid code `%s'", path_iso3166, lineno, t); /* Now skip past the three-letter and numeric codes. */ name = strsep(&s, "\t"); /* 3-let */ if (name == 0 || strlen(name) != 3) - errx(1, _PATH_ISO3166 ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_iso3166, lineno); name = strsep(&s, "\t"); /* numeric */ if (name == 0 || strlen(name) != 3) - errx(1, _PATH_ISO3166 ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_iso3166, lineno); name = s; cp = &countries[CODE2INT(t)]; if (cp->name) - errx(1, _PATH_ISO3166 - ":%d: country code `%s' multiply defined: %s", - lineno, t, cp->name); + errx(1, "%s:%d: country code `%s' multiply defined: %s", + path_iso3166, lineno, t, cp->name); cp->name = strdup(name); if (cp->name == NULL) errx(1, "malloc failed"); @@ -248,18 +256,18 @@ add_zone_to_country(int lineno, const ch struct country *cp; if (tlc[0] < 'A' || tlc[0] > 'Z' || tlc[1] < 'A' || tlc[1] > 'Z') - errx(1, _PATH_ZONETAB ":%d: country code `%s' invalid", + errx(1, "%s:%d: country code `%s' invalid", path_zonetab, lineno, tlc); cp = &countries[CODE2INT(tlc)]; if (cp->name == 0) - errx(1, _PATH_ZONETAB ":%d: country code `%s' unknown", + errx(1, "%s:%d: country code `%s' unknown", path_zonetab, lineno, tlc); if (descr) { if (cp->nzones < 0) - errx(1, _PATH_ZONETAB - ":%d: conflicting zone definition", lineno); + errx(1, "%s:%d: conflicting zone definition", + path_zonetab, lineno); zp = malloc(sizeof(*zp)); if (zp == 0) @@ -279,11 +287,11 @@ add_zone_to_country(int lineno, const ch cp->nzones++; } else { if (cp->nzones > 0) - errx(1, _PATH_ZONETAB - ":%d: zone must have description", lineno); + errx(1, "%s:%d: zone must have description", + path_zonetab, lineno); if (cp->nzones < 0) - errx(1, _PATH_ZONETAB - ":%d: zone multiply defined", lineno); + errx(1, "%s:%d: zone multiply defined", + path_zonetab, lineno); cp->nzones = -1; cp->filename = strdup(file); if (cp->filename == NULL) @@ -333,34 +341,34 @@ read_zones(void) char *line, *tlc, *coord, *file, *descr, *p; int lineno; - fp = fopen(_PATH_ZONETAB, "r"); + fp = fopen(path_zonetab, "r"); if (!fp) - err(1, _PATH_ZONETAB); + err(1, "%s", path_zonetab); lineno = 0; while ((line = fgetln(fp, &len)) != 0) { lineno++; if (line[len - 1] != '\n') - errx(1, _PATH_ZONETAB ":%d: invalid format", lineno); + errx(1, "%s:%d: invalid format", path_zonetab, lineno); line[len - 1] = '\0'; if (line[0] == '#') continue; tlc = strsep(&line, "\t"); if (strlen(tlc) != 2) - errx(1, _PATH_ZONETAB ":%d: invalid country code `%s'", - lineno, tlc); - coord = strsep(&line, "\t"); + errx(1, "%s:%d: invalid country code `%s'", + path_zonetab, lineno, tlc); + coord = strsep(&line, "\t"); /* Unused */ file = strsep(&line, "\t"); p = strchr(file, '/'); if (p == 0) - errx(1, _PATH_ZONETAB ":%d: invalid zone name `%s'", + errx(1, "%s:%d: invalid zone name `%s'", path_zonetab, lineno, file); contbuf[0] = '\0'; strncat(contbuf, file, p - file); cont = find_continent(contbuf); if (!cont) - errx(1, _PATH_ZONETAB ":%d: invalid region `%s'", + errx(1, "%s:%d: invalid region `%s'", path_zonetab, lineno, contbuf); descr = (line != NULL && *line != '\0') ? line : NULL; @@ -495,7 +503,7 @@ set_zone_menu(dialogMenuItem *dmi) } static int -install_zone_file(const char *filename) +install_zoneinfo_file(const char *zoneinfo_file) { char buf[1024]; char title[64], prompt[64]; @@ -503,7 +511,7 @@ install_zone_file(const char *filename) ssize_t len; int fd1, fd2, copymode; - if (lstat(_PATH_LOCALTIME, &sb) < 0) { + if (lstat(path_localtime, &sb) < 0) { /* Nothing there yet... */ copymode = 1; } else if (S_ISLNK(sb.st_mode)) @@ -514,70 +522,89 @@ install_zone_file(const char *filename) #ifdef VERBOSE if (copymode) snprintf(prompt, sizeof(prompt), - "Copying %s to " _PATH_LOCALTIME, filename); + "Copying %s to %s", zoneinfo_file, path_localtime); else snprintf(prompt, sizeof(prompt), - "Creating symbolic link " _PATH_LOCALTIME " to %s", - filename); - dialog_notify(prompt); + "Creating symbolic link %s to %s", + path_localtime, zoneinfo_file); + if (usedialog) + dialog_notify(prompt); + else + fprintf(stderr, "%s\n", prompt); #endif if (reallydoit) { if (copymode) { - fd1 = open(filename, O_RDONLY, 0); + fd1 = open(zoneinfo_file, O_RDONLY, 0); if (fd1 < 0) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Could not open %s: %s", filename, + "Could not open %s: %s", zoneinfo_file, strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); return (DITEM_FAILURE | DITEM_RECREATE); } - unlink(_PATH_LOCALTIME); - fd2 = open(_PATH_LOCALTIME, O_CREAT | O_EXCL | O_WRONLY, + unlink(path_localtime); + fd2 = open(path_localtime, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IRGRP | S_IROTH); if (fd2 < 0) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Could not open " _PATH_LOCALTIME ": %s", - strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + "Could not open %s: %s", + path_localtime, strerror(errno)); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); return (DITEM_FAILURE | DITEM_RECREATE); } while ((len = read(fd1, buf, sizeof(buf))) > 0) - len = write(fd2, buf, len); + if ((len = write(fd2, buf, len)) < 0) + break; if (len == -1) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Error copying %s to " _PATH_LOCALTIME - ": %s", filename, strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + "Error copying %s to %s %s", zoneinfo_file, + path_localtime, strerror(errno)); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); /* Better to leave none than a corrupt one. */ - unlink(_PATH_LOCALTIME); + unlink(path_localtime); return (DITEM_FAILURE | DITEM_RECREATE); } close(fd1); close(fd2); } else { - if (access(filename, R_OK) != 0) { + if (access(zoneinfo_file, R_OK) != 0) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Cannot access %s: %s", filename, + "Cannot access %s: %s", zoneinfo_file, strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); return (DITEM_FAILURE | DITEM_RECREATE); } - unlink(_PATH_LOCALTIME); - if (symlink(filename, _PATH_LOCALTIME) < 0) { + unlink(path_localtime); + if (symlink(zoneinfo_file, path_localtime) < 0) { snprintf(title, sizeof(title), "Error"); snprintf(prompt, sizeof(prompt), - "Cannot create symbolic link " - _PATH_LOCALTIME " to %s: %s", filename, + "Cannot create symbolic link %s to %s: %s", + path_localtime, zoneinfo_file, strerror(errno)); - dialog_mesgbox(title, prompt, 8, 72); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); + else + fprintf(stderr, "%s\n", prompt); return (DITEM_FAILURE | DITEM_RECREATE); } } @@ -587,17 +614,41 @@ install_zone_file(const char *filename) snprintf(title, sizeof(title), "Done"); if (copymode) snprintf(prompt, sizeof(prompt), - "Copied timezone file from %s to " _PATH_LOCALTIME, - filename); + "Copied timezone file from %s to %s", zoneinfo_file, + path_localtime); + else + snprintf(prompt, sizeof(prompt), + "Created symbolic link from %s to %s", zoneinfo_file, + path_localtime); + if (usedialog) + dialog_mesgbox(title, prompt, 8, 72); else - snprintf(prompt, sizeof(prompt), "Created symbolic link from " - _PATH_LOCALTIME " to %s", filename); - dialog_mesgbox(title, prompt, 8, 72); + fprintf(stderr, "%s\n", prompt); #endif + return (DITEM_LEAVE_MENU); } static int +install_zoneinfo(const char *zoneinfo) +{ + int rv; + FILE *f; + char path_zoneinfo_file[MAXPATHLEN]; + + sprintf(path_zoneinfo_file, "%s/%s", path_zoneinfo, zoneinfo); + rv = install_zoneinfo_file(path_zoneinfo_file); + + /* Save knowledge for later */ + if ((f = fopen(path_db, "w")) != NULL) { + fprintf(f, "%s\n", zoneinfo); + fclose(f); + } + + return (rv); +} + +static int confirm_zone(const char *filename) { char title[64], prompt[64]; @@ -620,15 +671,12 @@ static int set_zone_multi(dialogMenuItem *dmi) { struct zone *zp = dmi->data; - char *fn; int rv; if (!confirm_zone(zp->filename)) return (DITEM_FAILURE | DITEM_RECREATE); - asprintf(&fn, "%s/%s", _PATH_ZONEINFO, zp->filename); - rv = install_zone_file(fn); - free(fn); + rv = install_zoneinfo(zp->filename); return (rv); } @@ -636,15 +684,12 @@ static int set_zone_whole_country(dialogMenuItem *dmi) { struct country *cp = dmi->data; - char *fn; int rv; if (!confirm_zone(cp->filename)) return (DITEM_FAILURE | DITEM_RECREATE); - asprintf(&fn, "%s/%s", _PATH_ZONEINFO, cp->filename); - rv = install_zone_file(fn); - free(fn); + rv = install_zoneinfo(cp->filename); return (rv); } @@ -652,7 +697,7 @@ static void usage(void) { - fprintf(stderr, "usage: tzsetup [-ns]\n"); + fprintf(stderr, "usage: tzsetup [-nrs] [zoneinfo file]\n"); exit(1); } @@ -666,14 +711,21 @@ int main(int argc, char **argv) { char title[64], prompt[128]; - int c, fd, skiputc; + int c, fd, rv, skiputc; skiputc = 0; - while ((c = getopt(argc, argv, "ns")) != -1) { + while ((c = getopt(argc, argv, "C:nrs")) != -1) { switch(c) { + case 'C': + chrootenv = optarg; + break; case 'n': reallydoit = 0; break; + case 'r': + reinstall = 1; + usedialog = 0; + break; case 's': skiputc = 1; break; @@ -685,6 +737,24 @@ main(int argc, char **argv) if (argc - optind > 1) usage(); + if (chrootenv == NULL) { + strcpy(path_zonetab, _PATH_ZONETAB); + strcpy(path_iso3166, _PATH_ISO3166); + strcpy(path_zoneinfo, _PATH_ZONEINFO); + strcpy(path_localtime, _PATH_LOCALTIME); + strcpy(path_db, _PATH_DB); + strcpy(path_wall_cmos_clock, _PATH_WALL_CMOS_CLOCK); + } else { + sprintf(path_zonetab, "%s/%s", chrootenv, _PATH_ZONETAB); + sprintf(path_iso3166, "%s/%s", chrootenv, _PATH_ISO3166); + sprintf(path_zoneinfo, "%s/%s", chrootenv, _PATH_ZONEINFO); + sprintf(path_localtime, "%s/%s", chrootenv, _PATH_LOCALTIME); + sprintf(path_db, "%s/%s", chrootenv, _PATH_DB); + sprintf(path_wall_cmos_clock, "%s/%s", chrootenv, + _PATH_WALL_CMOS_CLOCK); + } + + /* Override the user-supplied umask. */ (void)umask(S_IWGRP | S_IWOTH); @@ -693,6 +763,54 @@ main(int argc, char **argv) sort_countries(); make_menus(); + if (reinstall == 1) { + FILE *f; + char zonefile[MAXPATHLEN]; + char path_db[MAXPATHLEN]; + + zonefile[0] = '\0'; + path_db[0] = '\0'; + if (chrootenv != NULL) { + sprintf(zonefile, "%s/", chrootenv); + sprintf(path_db, "%s/", chrootenv); + } + strcat(zonefile, _PATH_ZONEINFO); + strcat(zonefile, "/"); + strcat(path_db, _PATH_DB); + + if ((f = fopen(path_db, "r")) != NULL) { + if (fgets(zonefile, sizeof(zonefile), f) != NULL) { + zonefile[sizeof(zonefile) - 1] = 0; + if (strlen(zonefile) > 0) { + zonefile[strlen(zonefile) - 1] = 0; + rv = install_zoneinfo(zonefile); + exit(rv & ~DITEM_LEAVE_MENU); + } + errx(1, "Error reading %s.\n", path_db); + } + fclose(f); + errx(1, + "Unable to determine earlier installed zoneinfo " + "file. Check %s", path_db); + } + errx(1, "Cannot open %s for reading. Does it exist?", path_db); + } + + /* + * If the arguments on the command-line do not specify a file, + * then interpret it as a zoneinfo name + */ + if (optind == argc - 1) { + struct stat sb; + + if (stat(argv[optind], &sb) != 0) { + usedialog = 0; + rv = install_zoneinfo(argv[optind]); + exit(rv & ~DITEM_LEAVE_MENU); + } + /* FALLTHROUGH */ + } + init_dialog(); if (skiputc == 0) { snprintf(title, sizeof(title), @@ -703,15 +821,17 @@ main(int argc, char **argv) "or you don't know, please choose NO here!"); if (!DIALOG_UTC(title, prompt, 7, 72)) { if (reallydoit) - unlink(_PATH_WALL_CMOS_CLOCK); + unlink(path_wall_cmos_clock); } else { if (reallydoit) { - fd = open(_PATH_WALL_CMOS_CLOCK, + fd = open(path_wall_cmos_clock, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH); - if (fd < 0) + if (fd < 0) { + end_dialog(); err(1, "create %s", - _PATH_WALL_CMOS_CLOCK); + path_wall_cmos_clock); + } close(fd); } } @@ -722,10 +842,10 @@ main(int argc, char **argv) snprintf(prompt, sizeof(prompt), "\nUse the default `%s' zone?", argv[optind]); if (!dialog_yesno(title, prompt, 7, 72)) { - install_zone_file(argv[optind]); + rv = install_zoneinfo_file(argv[optind]); dialog_clear(); end_dialog(); - return (0); + exit(rv & ~DITEM_LEAVE_MENU); } dialog_clear_norefresh(); } From owner-svn-src-stable@FreeBSD.ORG Thu Mar 31 08:55:01 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E583E106564A; Thu, 31 Mar 2011 08:55:00 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D27538FC14; Thu, 31 Mar 2011 08:55:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2V8t0GW097455; Thu, 31 Mar 2011 08:55:00 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2V8t0w8097453; Thu, 31 Mar 2011 08:55:00 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201103310855.p2V8t0w8097453@svn.freebsd.org> From: Sergey Kandaurov Date: Thu, 31 Mar 2011 08:55:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220189 - stable/8/lib/libutil X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 08:55:01 -0000 Author: pluknet Date: Thu Mar 31 08:55:00 2011 New Revision: 220189 URL: http://svn.freebsd.org/changeset/base/220189 Log: MFC r219963: Add missing resource limits: - RLIMIT_NPTS - RLIMIT_SWAP Modified: stable/8/lib/libutil/login_class.3 Directory Properties: stable/8/lib/libutil/ (props changed) Modified: stable/8/lib/libutil/login_class.3 ============================================================================== --- stable/8/lib/libutil/login_class.3 Thu Mar 31 08:48:05 2011 (r220188) +++ stable/8/lib/libutil/login_class.3 Thu Mar 31 08:55:00 2011 (r220189) @@ -19,7 +19,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 20, 2008 +.Dd March 24, 2011 .Dt LOGIN_CLASS 3 .Os .Sh NAME @@ -105,17 +105,19 @@ Class capability tags used, with and wit or -max (hard limit) suffixes and the corresponding resource setting: .Bd -literal -cputime RLIMIT_CPU -filesize RLIMIT_FSIZE -datasize RLIMIT_DATA -stacksize RLIMIT_STACK -coredumpsize RLIMIT_CORE -memoryuse RLIMIT_RSS -memorylocked RLIMIT_MEMLOCK -maxproc RLIMIT_NPROC -openfiles RLIMIT_NOFILE -sbsize RLIMIT_SBSIZE -vmemoryuse RLIMIT_VMEM +cputime RLIMIT_CPU +filesize RLIMIT_FSIZE +datasize RLIMIT_DATA +stacksize RLIMIT_STACK +coredumpsize RLIMIT_CORE +memoryuse RLIMIT_RSS +memorylocked RLIMIT_MEMLOCK +maxproc RLIMIT_NPROC +openfiles RLIMIT_NOFILE +sbsize RLIMIT_SBSIZE +vmemoryuse RLIMIT_VMEM +pseudoterminals RLIMIT_NPTS +swapuse RLIMIT_SWAP .Ed .It LOGIN_SETPRIORITY Set the scheduling priority for the current process based on the From owner-svn-src-stable@FreeBSD.ORG Fri Apr 1 12:50:30 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 434C51065670; Fri, 1 Apr 2011 12:50:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3265C8FC12; Fri, 1 Apr 2011 12:50:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31CoUkx045358; Fri, 1 Apr 2011 12:50:30 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31CoULd045353; Fri, 1 Apr 2011 12:50:30 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011250.p31CoULd045353@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 12:50:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220241 - in stable/8/sys: kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 12:50:30 -0000 Author: kib Date: Fri Apr 1 12:50:29 2011 New Revision: 220241 URL: http://svn.freebsd.org/changeset/base/220241 Log: MFC r219999: Add O_CLOEXEC flag to open(2) and fhopen(2). Modified: stable/8/sys/kern/kern_descrip.c stable/8/sys/kern/vfs_syscalls.c stable/8/sys/sys/fcntl.h stable/8/sys/sys/filedesc.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_descrip.c ============================================================================== --- stable/8/sys/kern/kern_descrip.c Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/kern/kern_descrip.c Fri Apr 1 12:50:29 2011 (r220241) @@ -1514,7 +1514,7 @@ fdavail(struct thread *td, int n) * release the FILEDESC lock. */ int -falloc(struct thread *td, struct file **resultfp, int *resultfd) +fallocf(struct thread *td, struct file **resultfp, int *resultfd, int flags) { struct proc *p = td->td_proc; struct file *fp; @@ -1557,6 +1557,8 @@ falloc(struct thread *td, struct file ** return (error); } p->p_fd->fd_ofiles[i] = fp; + if ((flags & O_CLOEXEC) != 0) + p->p_fd->fd_ofileflags[i] |= UF_EXCLOSE; FILEDESC_XUNLOCK(p->p_fd); if (resultfp) *resultfp = fp; @@ -1565,6 +1567,13 @@ falloc(struct thread *td, struct file ** return (0); } +int +falloc(struct thread *td, struct file **resultfp, int *resultfd) +{ + + return (fallocf(td, resultfp, resultfd, 0)); +} + /* * Build a new filedesc structure from another. * Copy the current, root, and jail root vnode references. Modified: stable/8/sys/kern/vfs_syscalls.c ============================================================================== --- stable/8/sys/kern/vfs_syscalls.c Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/kern/vfs_syscalls.c Fri Apr 1 12:50:29 2011 (r220241) @@ -1069,7 +1069,7 @@ kern_openat(struct thread *td, int fd, c else flags = FFLAGS(flags); - error = falloc(td, &nfp, &indx); + error = fallocf(td, &nfp, &indx, flags); if (error) return (error); /* An extra reference on `nfp' has been held for us by falloc(). */ @@ -4478,7 +4478,7 @@ fhopen(td, uap) * end of vn_open code */ - if ((error = falloc(td, &nfp, &indx)) != 0) { + if ((error = fallocf(td, &nfp, &indx, fmode)) != 0) { if (fmode & FWRITE) vp->v_writecount--; goto bad; Modified: stable/8/sys/sys/fcntl.h ============================================================================== --- stable/8/sys/sys/fcntl.h Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/sys/fcntl.h Fri Apr 1 12:50:29 2011 (r220241) @@ -123,9 +123,11 @@ typedef __pid_t pid_t; #define FEXEC O_EXEC #endif -/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */ #if __POSIX_VISIBLE >= 200809 +/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */ #define O_TTY_INIT 0x00080000 /* Restore default termios attributes */ + +#define O_CLOEXEC 0x00100000 #endif /* Modified: stable/8/sys/sys/filedesc.h ============================================================================== --- stable/8/sys/sys/filedesc.h Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/sys/filedesc.h Fri Apr 1 12:50:29 2011 (r220241) @@ -112,6 +112,8 @@ int closef(struct file *fp, struct threa int dupfdopen(struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode, int error); int falloc(struct thread *td, struct file **resultfp, int *resultfd); +int fallocf(struct thread *td, struct file **resultfp, int *resultfd, + int flags); int fdalloc(struct thread *td, int minfd, int *result); int fdavail(struct thread *td, int n); int fdcheckstd(struct thread *td); From owner-svn-src-stable@FreeBSD.ORG Fri Apr 1 12:52:55 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B18C3106566B; Fri, 1 Apr 2011 12:52:55 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A0EAE8FC0A; Fri, 1 Apr 2011 12:52:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31Cqte3045527; Fri, 1 Apr 2011 12:52:55 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31CqtoA045525; Fri, 1 Apr 2011 12:52:55 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011252.p31CqtoA045525@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 12:52:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220242 - stable/8/lib/libc/sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 12:52:55 -0000 Author: kib Date: Fri Apr 1 12:52:55 2011 New Revision: 220242 URL: http://svn.freebsd.org/changeset/base/220242 Log: MFC r220000: Document O_CLOEXEC. Modified: stable/8/lib/libc/sys/open.2 Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/sys/open.2 ============================================================================== --- stable/8/lib/libc/sys/open.2 Fri Apr 1 12:50:29 2011 (r220241) +++ stable/8/lib/libc/sys/open.2 Fri Apr 1 12:52:55 2011 (r220242) @@ -28,7 +28,7 @@ .\" @(#)open.2 8.2 (Berkeley) 11/16/93 .\" $FreeBSD$ .\" -.Dd February 28, 2009 +.Dd March 25, 2011 .Dt OPEN 2 .Os .Sh NAME @@ -117,6 +117,7 @@ O_SYNC synchronous writes O_NOFOLLOW do not follow symlinks O_NOCTTY don't assign controlling terminal O_TTY_INIT restore default terminal attributes +O_CLOEXEC set FD_CLOEXEC upon open .Ed .Pp Opening a file with @@ -222,6 +223,11 @@ The initial call to on a TTY will always restore default terminal attributes on .Fx . .Pp +.Dv O_CLOEXEC +may be used to set +.Dv FD_CLOEXEC +flag for the newly returned file descriptor. +.Pp If successful, .Fn open returns a non-negative integer, termed a file descriptor. @@ -232,12 +238,18 @@ file is set to the beginning of the file When a new file is created it is given the group of the directory which contains it. .Pp -The new descriptor is set to remain open across +Unless +.Dv +O_CLOEXEC +flag was specified, +the new descriptor is set to remain open across .Xr execve 2 system calls; see -.Xr close 2 +.Xr close 2 , +.Xr fcntl 2 and -.Xr fcntl 2 . +.Dv O_CLOEXEC +description. .Pp The system imposes a limit on the number of file descriptors open simultaneously by one process. From owner-svn-src-stable@FreeBSD.ORG Fri Apr 1 13:20:39 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69E1C106564A; Fri, 1 Apr 2011 13:20:39 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 58E718FC17; Fri, 1 Apr 2011 13:20:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31DKda3046513; Fri, 1 Apr 2011 13:20:39 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31DKdEJ046511; Fri, 1 Apr 2011 13:20:39 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011320.p31DKdEJ046511@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 13:20:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220243 - stable/8/sys/compat/freebsd32 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 13:20:39 -0000 Author: kib Date: Fri Apr 1 13:20:39 2011 New Revision: 220243 URL: http://svn.freebsd.org/changeset/base/220243 Log: MFC r219988: Fully emulate MDIOCLIST for compat32. Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 1 12:52:55 2011 (r220242) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 1 13:20:39 2011 (r220243) @@ -64,7 +64,7 @@ freebsd32_ioctl_md(struct thread *td, st struct md_ioctl mdv; struct md_ioctl32 md32; u_long com = 0; - int error; + int i, error; if (uap->com & IOC_IN) { if ((error = copyin(uap->data, &md32, sizeof(md32)))) { @@ -116,6 +116,14 @@ freebsd32_ioctl_md(struct thread *td, st CP(mdv, md32, md_base); CP(mdv, md32, md_fwheads); CP(mdv, md32, md_fwsectors); + if (com == MDIOCLIST) { + /* + * Use MDNPAD, and not MDNPAD32. Padding is + * allocated and used by compat32 ABI. + */ + for (i = 0; i < MDNPAD; i++) + CP(mdv, md32, md_pad[i]); + } error = copyout(&md32, uap->data, sizeof(md32)); } return error; From owner-svn-src-stable@FreeBSD.ORG Fri Apr 1 13:23:54 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1B2D106564A; Fri, 1 Apr 2011 13:23:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D062A8FC14; Fri, 1 Apr 2011 13:23:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31DNrUq046655; Fri, 1 Apr 2011 13:23:53 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31DNru3046652; Fri, 1 Apr 2011 13:23:53 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011323.p31DNru3046652@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 13:23:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220244 - stable/8/sys/compat/freebsd32 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 13:23:54 -0000 Author: kib Date: Fri Apr 1 13:23:53 2011 New Revision: 220244 URL: http://svn.freebsd.org/changeset/base/220244 Log: MFC r219989: Implement compat32 MEMRANGE_GET and MEMRANGE_SET. Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c stable/8/sys/compat/freebsd32/freebsd32_ioctl.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.c ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 1 13:20:39 2011 (r220243) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.c Fri Apr 1 13:23:53 2011 (r220244) @@ -38,7 +38,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include +#include #include #include #include @@ -55,6 +57,7 @@ __FBSDID("$FreeBSD$"); CTASSERT((sizeof(struct md_ioctl32)+4) == 436); CTASSERT(sizeof(struct ioc_read_toc_entry32) == 8); CTASSERT(sizeof(struct ioc_toc_header32) == 4); +CTASSERT(sizeof(struct mem_range_op32) == 12); static int @@ -191,6 +194,49 @@ freebsd32_ioctl_fiodgname(struct thread return (error); } +static int +freebsd32_ioctl_memrange(struct thread *td, + struct freebsd32_ioctl_args *uap, struct file *fp) +{ + struct mem_range_op mro; + struct mem_range_op32 mro32; + int error; + u_long com; + + if ((error = copyin(uap->data, &mro32, sizeof(mro32))) != 0) + return (error); + + PTRIN_CP(mro32, mro, mo_desc); + CP(mro32, mro, mo_arg[0]); + CP(mro32, mro, mo_arg[1]); + + com = 0; + switch (uap->com) { + case MEMRANGE_GET32: + com = MEMRANGE_GET; + break; + + case MEMRANGE_SET32: + com = MEMRANGE_SET; + break; + + default: + panic("%s: unknown MEMRANGE %#x", __func__, uap->com); + } + + if ((error = fo_ioctl(fp, com, (caddr_t)&mro, td->td_ucred, td)) != 0) + return (error); + + if ( (com & IOC_OUT) ) { + CP(mro, mro32, mo_arg[0]); + CP(mro, mro32, mo_arg[1]); + + error = copyout(&mro32, uap->data, sizeof(mro32)); + } + + return (error); +} + int freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap) { @@ -229,6 +275,11 @@ freebsd32_ioctl(struct thread *td, struc error = freebsd32_ioctl_fiodgname(td, uap, fp); break; + case MEMRANGE_GET32: /* FALLTHROUGH */ + case MEMRANGE_SET32: + error = freebsd32_ioctl_memrange(td, uap, fp); + break; + default: fdrop(fp, td); ap.fd = uap->fd; Modified: stable/8/sys/compat/freebsd32/freebsd32_ioctl.h ============================================================================== --- stable/8/sys/compat/freebsd32/freebsd32_ioctl.h Fri Apr 1 13:20:39 2011 (r220243) +++ stable/8/sys/compat/freebsd32/freebsd32_ioctl.h Fri Apr 1 13:23:53 2011 (r220244) @@ -67,6 +67,12 @@ struct fiodgname_arg32 { caddr_t32 buf; }; +struct mem_range_op32 +{ + caddr_t32 mo_desc; + int mo_arg[2]; +}; + #define CDIOREADTOCENTRYS_32 _IOWR('c', 5, struct ioc_read_toc_entry32) #define CDIOREADTOCHEADER_32 _IOR('c', 4, struct ioc_toc_header32) #define MDIOCATTACH_32 _IOC(IOC_INOUT, 'm', 0, sizeof(struct md_ioctl32) + 4) @@ -74,5 +80,7 @@ struct fiodgname_arg32 { #define MDIOCQUERY_32 _IOC(IOC_INOUT, 'm', 2, sizeof(struct md_ioctl32) + 4) #define MDIOCLIST_32 _IOC(IOC_INOUT, 'm', 3, sizeof(struct md_ioctl32) + 4) #define FIODGNAME_32 _IOW('f', 120, struct fiodgname_arg32) +#define MEMRANGE_GET32 _IOWR('m', 50, struct mem_range_op32) +#define MEMRANGE_SET32 _IOW('m', 51, struct mem_range_op32) #endif /* _COMPAT_FREEBSD32_IOCTL_H_ */ From owner-svn-src-stable@FreeBSD.ORG Fri Apr 1 14:04:36 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A65CB10656B3; Fri, 1 Apr 2011 14:04:36 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 954228FC24; Fri, 1 Apr 2011 14:04:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31E4aTE047754; Fri, 1 Apr 2011 14:04:36 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31E4a2w047752; Fri, 1 Apr 2011 14:04:36 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011404.p31E4a2w047752@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 14:04:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220246 - stable/8/sys/fs/msdosfs X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 14:04:36 -0000 Author: kib Date: Fri Apr 1 14:04:36 2011 New Revision: 220246 URL: http://svn.freebsd.org/changeset/base/220246 Log: MFC r220014: Report EBUSY instead of EROFS for attempt of deleting or renaming the root directory of msdosfs mount. Modified: stable/8/sys/fs/msdosfs/msdosfs_lookup.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/fs/msdosfs/msdosfs_lookup.c ============================================================================== --- stable/8/sys/fs/msdosfs/msdosfs_lookup.c Fri Apr 1 13:28:34 2011 (r220245) +++ stable/8/sys/fs/msdosfs/msdosfs_lookup.c Fri Apr 1 14:04:36 2011 (r220246) @@ -458,7 +458,7 @@ foundroot: * Don't allow deleting the root. */ if (blkoff == MSDOSFSROOT_OFS) - return EROFS; /* really? XXX */ + return (EBUSY); /* * Write access to directory required to delete files. @@ -491,7 +491,7 @@ foundroot: */ if (nameiop == RENAME && (flags & ISLASTCN)) { if (blkoff == MSDOSFSROOT_OFS) - return EROFS; /* really? XXX */ + return (EBUSY); error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_thread); if (error) From owner-svn-src-stable@FreeBSD.ORG Fri Apr 1 18:23:44 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E91FB106564A; Fri, 1 Apr 2011 18:23:44 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D60E38FC08; Fri, 1 Apr 2011 18:23:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31INixW055198; Fri, 1 Apr 2011 18:23:44 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31INiHv055195; Fri, 1 Apr 2011 18:23:44 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201104011823.p31INiHv055195@svn.freebsd.org> From: Xin LI Date: Fri, 1 Apr 2011 18:23:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220250 - in stable/8: bin/test tools/regression/bin/test X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 18:23:45 -0000 Author: delphij Date: Fri Apr 1 18:23:44 2011 New Revision: 220250 URL: http://svn.freebsd.org/changeset/base/220250 Log: MFC r219084: Accept == as an alias of = which is a popular GNU extension. This is intentionally undocumented for now since it's not part of any standard. Modified: stable/8/bin/test/test.c stable/8/tools/regression/bin/test/regress.sh Directory Properties: stable/8/bin/test/ (props changed) stable/8/tools/regression/bin/test/ (props changed) Modified: stable/8/bin/test/test.c ============================================================================== --- stable/8/bin/test/test.c Fri Apr 1 16:45:26 2011 (r220249) +++ stable/8/bin/test/test.c Fri Apr 1 18:23:44 2011 (r220250) @@ -144,6 +144,7 @@ struct t_op { {"-L", FILSYM, UNOP}, {"-S", FILSOCK,UNOP}, {"=", STREQ, BINOP}, + {"==", STREQ, BINOP}, {"!=", STRNE, BINOP}, {"<", STRLT, BINOP}, {">", STRGT, BINOP}, Modified: stable/8/tools/regression/bin/test/regress.sh ============================================================================== --- stable/8/tools/regression/bin/test/regress.sh Fri Apr 1 16:45:26 2011 (r220249) +++ stable/8/tools/regression/bin/test/regress.sh Fri Apr 1 18:23:44 2011 (r220250) @@ -52,12 +52,15 @@ t () } count=0 -echo "1..94" +echo "1..97" t 0 'b = b' +t 0 'b == b' t 1 'b != b' t 0 '\( b = b \)' +t 0 '\( b == b \)' t 1 '! \( b = b \)' +t 1 '! \( b == b \)' t 1 '! -f /etc/passwd' t 0 '-h = -h' From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 01:55:52 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1033) id B5FC91065674; Sat, 2 Apr 2011 01:55:52 +0000 (UTC) Date: Sat, 2 Apr 2011 01:55:52 +0000 From: Alexey Dokuchaev To: Xin LI Message-ID: <20110402015552.GA32901@FreeBSD.org> References: <201104011823.p31INiHv055195@svn.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <201104011823.p31INiHv055195@svn.freebsd.org> User-Agent: Mutt/1.4.2.1i Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-8@freebsd.org Subject: Re: svn commit: r220250 - in stable/8: bin/test tools/regression/bin/test X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 01:55:52 -0000 On Fri, Apr 01, 2011 at 06:23:44PM +0000, Xin LI wrote: > Accept == as an alias of = which is a popular GNU extension. > > This is intentionally undocumented for now since it's not part > of any standard. I thought general consensus that this change should never be part of FreeBSD, not just being undocumented (which, as we all know, is bad practice pe se). ./danfe From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 06:13:31 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B994B106564A; Sat, 2 Apr 2011 06:13:31 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A98A18FC08; Sat, 2 Apr 2011 06:13:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p326DVlP072504; Sat, 2 Apr 2011 06:13:31 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p326DVpE072499; Sat, 2 Apr 2011 06:13:31 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020613.p326DVpE072499@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 06:13:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220262 - in stable/8/sys: kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 06:13:31 -0000 Author: dchagin Date: Sat Apr 2 06:13:31 2011 New Revision: 220262 URL: http://svn.freebsd.org/changeset/base/220262 Log: MFC r219041: ktrace_resize_pool() locking slightly reworked: 1) do not take a lock around the single atomic operation. 2) do not lose the invariant of lock by dropping/acquiring ktrace_mtx around free() or malloc(). MFC r219042: Introduce preliminary support of the show description of the ABI of traced process by adding two new events which records value of process sv_flags to the trace file at process creation/execing/exiting time. MFC r219311: Partially rework r219042. The reason for this is a bug at ktrops() where process dereferenced without having a lock. This might cause a panic if ktrace was runned with -p flag and the specified process exited between the dropping a lock and writing sv_flags. Since it is impossible to acquire sx lock while holding mtx switch to use asynchronous enqueuerequest() instead of writerequest(). Rename ktr_getrequest_ne() to more understandable name. MFC r219312: Fix indentation in comment, double ';' in variable declaration. Modified: stable/8/sys/kern/kern_exec.c stable/8/sys/kern/kern_fork.c stable/8/sys/kern/kern_ktrace.c stable/8/sys/sys/ktrace.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_exec.c ============================================================================== --- stable/8/sys/kern/kern_exec.c Sat Apr 2 05:01:09 2011 (r220261) +++ stable/8/sys/kern/kern_exec.c Sat Apr 2 06:13:31 2011 (r220262) @@ -896,6 +896,12 @@ done2: exit1(td, W_EXITCODE(0, SIGABRT)); /* NOT REACHED */ } + +#ifdef KTRACE + if (error == 0) + ktrprocctor(p); +#endif + return (error); } Modified: stable/8/sys/kern/kern_fork.c ============================================================================== --- stable/8/sys/kern/kern_fork.c Sat Apr 2 05:01:09 2011 (r220261) +++ stable/8/sys/kern/kern_fork.c Sat Apr 2 06:13:31 2011 (r220262) @@ -649,10 +649,6 @@ again: callout_init(&p2->p_itcallout, CALLOUT_MPSAFE); -#ifdef KTRACE - ktrprocfork(p1, p2); -#endif - /* * If PF_FORK is set, the child process inherits the * procfs ioctl flags from its parent. @@ -688,6 +684,10 @@ again: p2->p_acflag = AFORK; PROC_UNLOCK(p2); +#ifdef KTRACE + ktrprocfork(p1, p2); +#endif + /* * Finish creating the child process. It will return via a different * execution path later. (ie: directly into user mode) Modified: stable/8/sys/kern/kern_ktrace.c ============================================================================== --- stable/8/sys/kern/kern_ktrace.c Sat Apr 2 05:01:09 2011 (r220261) +++ stable/8/sys/kern/kern_ktrace.c Sat Apr 2 06:13:31 2011 (r220262) @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -91,6 +92,7 @@ struct ktr_request { struct ktr_header ktr_header; void *ktr_buffer; union { + struct ktr_proc_ctor ktr_proc_ctor; struct ktr_syscall ktr_syscall; struct ktr_sysret ktr_sysret; struct ktr_genio ktr_genio; @@ -111,6 +113,8 @@ static int data_lengths[] = { 0, /* KTR_USER */ 0, /* KTR_STRUCT */ 0, /* KTR_SYSCTL */ + sizeof(struct ktr_proc_ctor), /* KTR_PROCCTOR */ + 0, /* KTR_PROCDTOR */ }; static STAILQ_HEAD(, ktr_request) ktr_free; @@ -131,7 +135,8 @@ static struct sx ktrace_sx; static void ktrace_init(void *dummy); static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS); -static u_int ktrace_resize_pool(u_int newsize); +static u_int ktrace_resize_pool(u_int oldsize, u_int newsize); +static struct ktr_request *ktr_getrequest_entered(struct thread *td, int type); static struct ktr_request *ktr_getrequest(int type); static void ktr_submitrequest(struct thread *td, struct ktr_request *req); static void ktr_freeproc(struct proc *p, struct ucred **uc, @@ -142,6 +147,7 @@ static void ktr_writerequest(struct thre static int ktrcanset(struct thread *,struct proc *); static int ktrsetchildren(struct thread *,struct proc *,int,int,struct vnode *); static int ktrops(struct thread *,struct proc *,int,int,struct vnode *); +static void ktrprocctor_entered(struct thread *, struct proc *); /* * ktrace itself generates events, such as context switches, which we do not @@ -197,9 +203,7 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H /* Handle easy read-only case first to avoid warnings from GCC. */ if (!req->newptr) { - mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - mtx_unlock(&ktrace_mtx); return (SYSCTL_OUT(req, &oldsize, sizeof(u_int))); } @@ -208,10 +212,8 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H return (error); td = curthread; ktrace_enter(td); - mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - newsize = ktrace_resize_pool(wantsize); - mtx_unlock(&ktrace_mtx); + newsize = ktrace_resize_pool(oldsize, wantsize); ktrace_exit(td); error = SYSCTL_OUT(req, &oldsize, sizeof(u_int)); if (error) @@ -224,38 +226,40 @@ SYSCTL_PROC(_kern_ktrace, OID_AUTO, requ &ktr_requestpool, 0, sysctl_kern_ktrace_request_pool, "IU", ""); static u_int -ktrace_resize_pool(u_int newsize) +ktrace_resize_pool(u_int oldsize, u_int newsize) { + STAILQ_HEAD(, ktr_request) ktr_new; struct ktr_request *req; int bound; - mtx_assert(&ktrace_mtx, MA_OWNED); print_message = 1; - bound = newsize - ktr_requestpool; + bound = newsize - oldsize; if (bound == 0) return (ktr_requestpool); - if (bound < 0) + if (bound < 0) { + mtx_lock(&ktrace_mtx); /* Shrink pool down to newsize if possible. */ while (bound++ < 0) { req = STAILQ_FIRST(&ktr_free); if (req == NULL) - return (ktr_requestpool); + break; STAILQ_REMOVE_HEAD(&ktr_free, ktr_list); ktr_requestpool--; - mtx_unlock(&ktrace_mtx); free(req, M_KTRACE); - mtx_lock(&ktrace_mtx); } - else + } else { /* Grow pool up to newsize. */ + STAILQ_INIT(&ktr_new); while (bound-- > 0) { - mtx_unlock(&ktrace_mtx); req = malloc(sizeof(struct ktr_request), M_KTRACE, M_WAITOK); - mtx_lock(&ktrace_mtx); - STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); - ktr_requestpool++; + STAILQ_INSERT_HEAD(&ktr_new, req, ktr_list); } + mtx_lock(&ktrace_mtx); + STAILQ_CONCAT(&ktr_free, &ktr_new); + ktr_requestpool += (newsize - oldsize); + } + mtx_unlock(&ktrace_mtx); return (ktr_requestpool); } @@ -264,18 +268,15 @@ CTASSERT(sizeof(((struct ktr_header *)NU (sizeof((struct thread *)NULL)->td_name)); static struct ktr_request * -ktr_getrequest(int type) +ktr_getrequest_entered(struct thread *td, int type) { struct ktr_request *req; - struct thread *td = curthread; struct proc *p = td->td_proc; int pm; - ktrace_enter(td); /* XXX: In caller instead? */ mtx_lock(&ktrace_mtx); if (!KTRCHECK(td, type)) { mtx_unlock(&ktrace_mtx); - ktrace_exit(td); return (NULL); } req = STAILQ_FIRST(&ktr_free); @@ -301,11 +302,24 @@ ktr_getrequest(int type) mtx_unlock(&ktrace_mtx); if (pm) printf("Out of ktrace request objects.\n"); - ktrace_exit(td); } return (req); } +static struct ktr_request * +ktr_getrequest(int type) +{ + struct thread *td = curthread; + struct ktr_request *req; + + ktrace_enter(td); + req = ktr_getrequest_entered(td, type); + if (req == NULL) + ktrace_exit(td); + + return (req); +} + /* * Some trace generation environments don't permit direct access to VFS, * such as during a context switch where sleeping is not allowed. Under these @@ -319,7 +333,6 @@ ktr_enqueuerequest(struct thread *td, st mtx_lock(&ktrace_mtx); STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list); mtx_unlock(&ktrace_mtx); - ktrace_exit(td); } /* @@ -369,7 +382,6 @@ ktr_submitrequest(struct thread *td, str ktr_writerequest(td, req); ktr_freerequest(req); sx_xunlock(&ktrace_sx); - ktrace_exit(td); } @@ -487,6 +499,7 @@ ktrprocexec(struct proc *p, struct ucred void ktrprocexit(struct thread *td) { + struct ktr_request *req; struct proc *p; struct ucred *cred; struct vnode *vp; @@ -497,6 +510,9 @@ ktrprocexit(struct thread *td) return; ktrace_enter(td); + req = ktr_getrequest_entered(td, KTR_PROCDTOR); + if (req != NULL) + ktr_enqueuerequest(td, req); sx_xlock(&ktrace_sx); ktr_drain(td); sx_xunlock(&ktrace_sx); @@ -515,6 +531,36 @@ ktrprocexit(struct thread *td) ktrace_exit(td); } +static void +ktrprocctor_entered(struct thread *td, struct proc *p) +{ + struct ktr_proc_ctor *ktp; + struct ktr_request *req; + struct thread *td2; + + ktrace_assert(td); + td2 = FIRST_THREAD_IN_PROC(p); + req = ktr_getrequest_entered(td2, KTR_PROCCTOR); + if (req == NULL) + return; + ktp = &req->ktr_data.ktr_proc_ctor; + ktp->sv_flags = p->p_sysent->sv_flags; + ktr_enqueuerequest(td2, req); +} + +void +ktrprocctor(struct proc *p) +{ + struct thread *td = curthread; + + if ((p->p_traceflag & KTRFAC_MASK) == 0) + return; + + ktrace_enter(td); + ktrprocctor_entered(td, p); + ktrace_exit(td); +} + /* * When a process forks, enable tracing in the new process if needed. */ @@ -522,8 +568,7 @@ void ktrprocfork(struct proc *p1, struct proc *p2) { - PROC_LOCK_ASSERT(p1, MA_OWNED); - PROC_LOCK_ASSERT(p2, MA_OWNED); + PROC_LOCK(p1); mtx_lock(&ktrace_mtx); KASSERT(p2->p_tracevp == NULL, ("new process has a ktrace vnode")); if (p1->p_traceflag & KTRFAC_INHERIT) { @@ -536,6 +581,9 @@ ktrprocfork(struct proc *p1, struct proc } } mtx_unlock(&ktrace_mtx); + PROC_UNLOCK(p1); + + ktrprocctor(p2); } /* @@ -659,6 +707,7 @@ ktrpsig(sig, action, mask, code) sigset_t *mask; int code; { + struct thread *td = curthread; struct ktr_request *req; struct ktr_psig *kp; @@ -670,13 +719,15 @@ ktrpsig(sig, action, mask, code) kp->action = action; kp->mask = *mask; kp->code = code; - ktr_enqueuerequest(curthread, req); + ktr_enqueuerequest(td, req); + ktrace_exit(td); } void ktrcsw(out, user) int out, user; { + struct thread *td = curthread; struct ktr_request *req; struct ktr_csw *kc; @@ -686,7 +737,8 @@ ktrcsw(out, user) kc = &req->ktr_data.ktr_csw; kc->out = out; kc->user = user; - ktr_enqueuerequest(curthread, req); + ktr_enqueuerequest(td, req); + ktrace_exit(td); } void @@ -962,6 +1014,8 @@ ktrops(td, p, ops, facs, vp) ktr_freeproc(p, &tracecred, &tracevp); } mtx_unlock(&ktrace_mtx); + if ((p->p_traceflag & KTRFAC_MASK) != 0) + ktrprocctor_entered(td, p); PROC_UNLOCK(p); if (tracevp != NULL) { int vfslocked; Modified: stable/8/sys/sys/ktrace.h ============================================================================== --- stable/8/sys/sys/ktrace.h Sat Apr 2 05:01:09 2011 (r220261) +++ stable/8/sys/sys/ktrace.h Sat Apr 2 06:13:31 2011 (r220262) @@ -156,6 +156,7 @@ struct ktr_csw { #define KTR_STRUCT 8 struct sockaddr; struct stat; +struct sysentvec; /* * KTR_SYSCTL - name of a sysctl MIB @@ -164,6 +165,19 @@ struct stat; /* record contains null-terminated MIB name */ /* + * KTR_PROCCTOR - trace process creation (multiple ABI support) + */ +#define KTR_PROCCTOR 10 +struct ktr_proc_ctor { + u_int sv_flags; /* struct sysentvec sv_flags copy */ +}; + +/* + * KTR_PROCDTOR - trace process destruction (multiple ABI support) + */ +#define KTR_PROCDTOR 11 + +/* * KTR_DROP - If this bit is set in ktr_type, then at least one event * between the previous record and this record was dropped. */ @@ -182,6 +196,8 @@ struct stat; #define KTRFAC_USER (1< Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D4EF106564A; Sat, 2 Apr 2011 06:25:13 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6D6B48FC08; Sat, 2 Apr 2011 06:25:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p326PDIV072787; Sat, 2 Apr 2011 06:25:13 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p326PDlf072782; Sat, 2 Apr 2011 06:25:13 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020625.p326PDlf072782@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 06:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220263 - in stable/7/sys: kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 06:25:13 -0000 Author: dchagin Date: Sat Apr 2 06:25:13 2011 New Revision: 220263 URL: http://svn.freebsd.org/changeset/base/220263 Log: MFC r219041: ktrace_resize_pool() locking slightly reworked: 1) do not take a lock around the single atomic operation. 2) do not lose the invariant of lock by dropping/acquiring ktrace_mtx around free() or malloc(). MFC r219042: Introduce preliminary support of the show description of the ABI of traced process by adding two new events which records value of process sv_flags to the trace file at process creation/execing/exiting time. MFC r219311: Partially rework r219042. The reason for this is a bug at ktrops() where process dereferenced without having a lock. This might cause a panic if ktrace was runned with -p flag and the specified process exited between the dropping a lock and writing sv_flags. Since it is impossible to acquire sx lock while holding mtx switch to use asynchronous enqueuerequest() instead of writerequest(). Rename ktr_getrequest_ne() to more understandable name. MFC r219312: Fix indentation in comment, double ';' in variable declaration. PR: ports/155083 Modified: stable/7/sys/kern/kern_exec.c stable/7/sys/kern/kern_fork.c stable/7/sys/kern/kern_ktrace.c stable/7/sys/sys/ktrace.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/kern_exec.c ============================================================================== --- stable/7/sys/kern/kern_exec.c Sat Apr 2 06:13:31 2011 (r220262) +++ stable/7/sys/kern/kern_exec.c Sat Apr 2 06:25:13 2011 (r220263) @@ -845,6 +845,12 @@ done2: exit1(td, W_EXITCODE(0, SIGABRT)); /* NOT REACHED */ } + +#ifdef KTRACE + if (error == 0) + ktrprocctor(p); +#endif + return (error); } Modified: stable/7/sys/kern/kern_fork.c ============================================================================== --- stable/7/sys/kern/kern_fork.c Sat Apr 2 06:13:31 2011 (r220262) +++ stable/7/sys/kern/kern_fork.c Sat Apr 2 06:25:13 2011 (r220263) @@ -613,10 +613,6 @@ again: callout_init(&p2->p_itcallout, CALLOUT_MPSAFE); -#ifdef KTRACE - ktrprocfork(p1, p2); -#endif - /* * If PF_FORK is set, the child process inherits the * procfs ioctl flags from its parent. @@ -661,6 +657,10 @@ again: p2->p_acflag = AFORK; PROC_UNLOCK(p2); +#ifdef KTRACE + ktrprocfork(p1, p2); +#endif + /* * Finish creating the child process. It will return via a different * execution path later. (ie: directly into user mode) Modified: stable/7/sys/kern/kern_ktrace.c ============================================================================== --- stable/7/sys/kern/kern_ktrace.c Sat Apr 2 06:13:31 2011 (r220262) +++ stable/7/sys/kern/kern_ktrace.c Sat Apr 2 06:25:13 2011 (r220263) @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -92,6 +93,7 @@ struct ktr_request { struct ktr_header ktr_header; void *ktr_buffer; union { + struct ktr_proc_ctor ktr_proc_ctor; struct ktr_syscall ktr_syscall; struct ktr_sysret ktr_sysret; struct ktr_genio ktr_genio; @@ -112,6 +114,8 @@ static int data_lengths[] = { 0, /* KTR_USER */ 0, /* KTR_STRUCT */ 0, /* KTR_SYSCTL */ + sizeof(struct ktr_proc_ctor), /* KTR_PROCCTOR */ + 0, /* KTR_PROCDTOR */ }; static STAILQ_HEAD(, ktr_request) ktr_free; @@ -132,7 +136,8 @@ static struct sx ktrace_sx; static void ktrace_init(void *dummy); static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS); -static u_int ktrace_resize_pool(u_int newsize); +static u_int ktrace_resize_pool(u_int oldsize, u_int newsize); +static struct ktr_request *ktr_getrequest_entered(struct thread *td, int type); static struct ktr_request *ktr_getrequest(int type); static void ktr_submitrequest(struct thread *td, struct ktr_request *req); static void ktr_freeproc(struct proc *p, struct ucred **uc, @@ -143,6 +148,7 @@ static void ktr_writerequest(struct thre static int ktrcanset(struct thread *,struct proc *); static int ktrsetchildren(struct thread *,struct proc *,int,int,struct vnode *); static int ktrops(struct thread *,struct proc *,int,int,struct vnode *); +static void ktrprocctor_entered(struct thread *, struct proc *); /* * ktrace itself generates events, such as context switches, which we do not @@ -198,9 +204,7 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H /* Handle easy read-only case first to avoid warnings from GCC. */ if (!req->newptr) { - mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - mtx_unlock(&ktrace_mtx); return (SYSCTL_OUT(req, &oldsize, sizeof(u_int))); } @@ -209,10 +213,8 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H return (error); td = curthread; ktrace_enter(td); - mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - newsize = ktrace_resize_pool(wantsize); - mtx_unlock(&ktrace_mtx); + newsize = ktrace_resize_pool(oldsize, wantsize); ktrace_exit(td); error = SYSCTL_OUT(req, &oldsize, sizeof(u_int)); if (error) @@ -225,38 +227,40 @@ SYSCTL_PROC(_kern_ktrace, OID_AUTO, requ &ktr_requestpool, 0, sysctl_kern_ktrace_request_pool, "IU", ""); static u_int -ktrace_resize_pool(u_int newsize) +ktrace_resize_pool(u_int oldsize, u_int newsize) { + STAILQ_HEAD(, ktr_request) ktr_new; struct ktr_request *req; int bound; - mtx_assert(&ktrace_mtx, MA_OWNED); print_message = 1; - bound = newsize - ktr_requestpool; + bound = newsize - oldsize; if (bound == 0) return (ktr_requestpool); - if (bound < 0) + if (bound < 0) { + mtx_lock(&ktrace_mtx); /* Shrink pool down to newsize if possible. */ while (bound++ < 0) { req = STAILQ_FIRST(&ktr_free); if (req == NULL) - return (ktr_requestpool); + break; STAILQ_REMOVE_HEAD(&ktr_free, ktr_list); ktr_requestpool--; - mtx_unlock(&ktrace_mtx); free(req, M_KTRACE); - mtx_lock(&ktrace_mtx); } - else + } else { /* Grow pool up to newsize. */ + STAILQ_INIT(&ktr_new); while (bound-- > 0) { - mtx_unlock(&ktrace_mtx); req = malloc(sizeof(struct ktr_request), M_KTRACE, M_WAITOK); - mtx_lock(&ktrace_mtx); - STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); - ktr_requestpool++; + STAILQ_INSERT_HEAD(&ktr_new, req, ktr_list); } + mtx_lock(&ktrace_mtx); + STAILQ_CONCAT(&ktr_free, &ktr_new); + ktr_requestpool += (newsize - oldsize); + } + mtx_unlock(&ktrace_mtx); return (ktr_requestpool); } @@ -265,18 +269,15 @@ CTASSERT(sizeof(((struct ktr_header *)NU (sizeof((struct proc *)NULL)->p_comm)); static struct ktr_request * -ktr_getrequest(int type) +ktr_getrequest_entered(struct thread *td, int type) { struct ktr_request *req; - struct thread *td = curthread; struct proc *p = td->td_proc; int pm; - ktrace_enter(td); /* XXX: In caller instead? */ mtx_lock(&ktrace_mtx); if (!KTRCHECK(td, type)) { mtx_unlock(&ktrace_mtx); - ktrace_exit(td); return (NULL); } req = STAILQ_FIRST(&ktr_free); @@ -302,11 +303,24 @@ ktr_getrequest(int type) mtx_unlock(&ktrace_mtx); if (pm) printf("Out of ktrace request objects.\n"); - ktrace_exit(td); } return (req); } +static struct ktr_request * +ktr_getrequest(int type) +{ + struct thread *td = curthread; + struct ktr_request *req; + + ktrace_enter(td); + req = ktr_getrequest_entered(td, type); + if (req == NULL) + ktrace_exit(td); + + return (req); +} + /* * Some trace generation environments don't permit direct access to VFS, * such as during a context switch where sleeping is not allowed. Under these @@ -320,7 +334,6 @@ ktr_enqueuerequest(struct thread *td, st mtx_lock(&ktrace_mtx); STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list); mtx_unlock(&ktrace_mtx); - ktrace_exit(td); } /* @@ -370,7 +383,6 @@ ktr_submitrequest(struct thread *td, str ktr_writerequest(td, req); ktr_freerequest(req); sx_xunlock(&ktrace_sx); - ktrace_exit(td); } @@ -488,6 +500,7 @@ ktrprocexec(struct proc *p, struct ucred void ktrprocexit(struct thread *td) { + struct ktr_request *req; struct proc *p; struct ucred *cred; struct vnode *vp; @@ -498,6 +511,9 @@ ktrprocexit(struct thread *td) return; ktrace_enter(td); + req = ktr_getrequest_entered(td, KTR_PROCDTOR); + if (req != NULL) + ktr_enqueuerequest(td, req); sx_xlock(&ktrace_sx); ktr_drain(td); sx_xunlock(&ktrace_sx); @@ -516,6 +532,36 @@ ktrprocexit(struct thread *td) ktrace_exit(td); } +static void +ktrprocctor_entered(struct thread *td, struct proc *p) +{ + struct ktr_proc_ctor *ktp; + struct ktr_request *req; + struct thread *td2; + + ktrace_assert(td); + td2 = FIRST_THREAD_IN_PROC(p); + req = ktr_getrequest_entered(td2, KTR_PROCCTOR); + if (req == NULL) + return; + ktp = &req->ktr_data.ktr_proc_ctor; + ktp->sv_flags = p->p_sysent->sv_flags; + ktr_enqueuerequest(td2, req); +} + +void +ktrprocctor(struct proc *p) +{ + struct thread *td = curthread; + + if ((p->p_traceflag & KTRFAC_MASK) == 0) + return; + + ktrace_enter(td); + ktrprocctor_entered(td, p); + ktrace_exit(td); +} + /* * When a process forks, enable tracing in the new process if needed. */ @@ -523,8 +569,7 @@ void ktrprocfork(struct proc *p1, struct proc *p2) { - PROC_LOCK_ASSERT(p1, MA_OWNED); - PROC_LOCK_ASSERT(p2, MA_OWNED); + PROC_LOCK(p1); mtx_lock(&ktrace_mtx); KASSERT(p2->p_tracevp == NULL, ("new process has a ktrace vnode")); if (p1->p_traceflag & KTRFAC_INHERIT) { @@ -537,6 +582,9 @@ ktrprocfork(struct proc *p1, struct proc } } mtx_unlock(&ktrace_mtx); + PROC_UNLOCK(p1); + + ktrprocctor(p2); } /* @@ -660,6 +708,7 @@ ktrpsig(sig, action, mask, code) sigset_t *mask; int code; { + struct thread *td = curthread; struct ktr_request *req; struct ktr_psig *kp; @@ -671,13 +720,15 @@ ktrpsig(sig, action, mask, code) kp->action = action; kp->mask = *mask; kp->code = code; - ktr_enqueuerequest(curthread, req); + ktr_enqueuerequest(td, req); + ktrace_exit(td); } void ktrcsw(out, user) int out, user; { + struct thread *td = curthread; struct ktr_request *req; struct ktr_csw *kc; @@ -687,7 +738,8 @@ ktrcsw(out, user) kc = &req->ktr_data.ktr_csw; kc->out = out; kc->user = user; - ktr_enqueuerequest(curthread, req); + ktr_enqueuerequest(td, req); + ktrace_exit(td); } void @@ -963,6 +1015,8 @@ ktrops(td, p, ops, facs, vp) ktr_freeproc(p, &tracecred, &tracevp); } mtx_unlock(&ktrace_mtx); + if ((p->p_traceflag & KTRFAC_MASK) != 0) + ktrprocctor_entered(td, p); PROC_UNLOCK(p); if (tracevp != NULL) { int vfslocked; Modified: stable/7/sys/sys/ktrace.h ============================================================================== --- stable/7/sys/sys/ktrace.h Sat Apr 2 06:13:31 2011 (r220262) +++ stable/7/sys/sys/ktrace.h Sat Apr 2 06:25:13 2011 (r220263) @@ -156,6 +156,7 @@ struct ktr_csw { #define KTR_STRUCT 8 struct sockaddr; struct stat; +struct sysentvec; /* * KTR_SYSCTL - name of a sysctl MIB @@ -164,6 +165,19 @@ struct stat; /* record contains null-terminated MIB name */ /* + * KTR_PROCCTOR - trace process creation (multiple ABI support) + */ +#define KTR_PROCCTOR 10 +struct ktr_proc_ctor { + u_int sv_flags; /* struct sysentvec sv_flags copy */ +}; + +/* + * KTR_PROCDTOR - trace process destruction (multiple ABI support) + */ +#define KTR_PROCDTOR 11 + +/* * KTR_DROP - If this bit is set in ktr_type, then at least one event * between the previous record and this record was dropped. */ @@ -182,6 +196,8 @@ struct stat; #define KTRFAC_USER (1< Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 844FF1065670; Sat, 2 Apr 2011 07:56:15 +0000 (UTC) (envelope-from delphij@gmail.com) Received: from mail-pw0-f54.google.com (mail-pw0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 3FED28FC19; Sat, 2 Apr 2011 07:56:15 +0000 (UTC) Received: by pwj8 with SMTP id 8so1079448pwj.13 for ; Sat, 02 Apr 2011 00:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=OU67HbBCOAGoIlSwKvNg+yG3Ktxw4HD/Teqb4FU+QkI=; b=n2F2cDXWsHI5t5Z3TuwqbXbqF+z9Av7k5GCy4aTgtBKcr94eIVqKaZQxcIUDOdriS8 ZcmICObnz9QpE8YZfytwcNx+GfqiG6VoAxKvJvLgWOx3rKjl6SWAldZ6u5IXNnxFo6za tVFzQfZym0sf8z2YY0/FNflaWsabYscyx5vis= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=RsBpw7otGYCHTVzvRbaX+1fCl9VfsnZXuRBmpYxV2rZJ4+cOqUs9964sbXXqMCRGTV NCAr4DURsWFeDCZmr6TFUd0M5Yunz3ZBDl4x5/aqRDdXq7ZzKy7xYCScjYHfLAPVIFds IBnWkxbSPZUEQUpxtsHMdNhakcxaYmN099w0Q= MIME-Version: 1.0 Received: by 10.143.27.39 with SMTP id e39mr3963246wfj.155.1301729624013; Sat, 02 Apr 2011 00:33:44 -0700 (PDT) Received: by 10.68.62.164 with HTTP; Sat, 2 Apr 2011 00:33:43 -0700 (PDT) In-Reply-To: <20110402015552.GA32901@FreeBSD.org> References: <201104011823.p31INiHv055195@svn.freebsd.org> <20110402015552.GA32901@FreeBSD.org> Date: Sat, 2 Apr 2011 00:33:43 -0700 Message-ID: From: Xin LI To: Alexey Dokuchaev Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Xin LI , svn-src-stable-8@freebsd.org Subject: Re: svn commit: r220250 - in stable/8: bin/test tools/regression/bin/test X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 07:56:15 -0000 2011/4/1 Alexey Dokuchaev : > On Fri, Apr 01, 2011 at 06:23:44PM +0000, Xin LI wrote: >> =C2=A0 Accept =3D=3D as an alias of =3D which is a popular GNU extension= . >> >> =C2=A0 This is intentionally undocumented for now since it's not part >> =C2=A0 of any standard. > > I thought general consensus that this change should never be part of > FreeBSD, not just being undocumented (which, as we all know, is bad > practice pe se). This have been discussed in -standards@ and have been settled for more than 1 month, there were two developers asked me after the commit but nobody asked for a revert (so far), so I don't think it's general consensus that this change should not be part of FreeBSD. Being undocumented means we do not encourage its use. I think there is good reason to add this extension for compatibility reasons, plus it does not break anything. So did I missed some discussion about why it's a bad move? Cheers, --=20 Xin LI http://www.delphij.net From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 08:29:02 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EAA461065674; Sat, 2 Apr 2011 08:29:02 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DD5388FC14; Sat, 2 Apr 2011 08:29:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p328T2cW075584; Sat, 2 Apr 2011 08:29:02 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p328T2aP075577; Sat, 2 Apr 2011 08:29:02 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020829.p328T2aP075577@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 08:29:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220267 - in stable/8/usr.bin: kdump ktrace X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 08:29:03 -0000 Author: dchagin Date: Sat Apr 2 08:29:02 2011 New Revision: 220267 URL: http://svn.freebsd.org/changeset/base/220267 Log: MFC r219043: Teach kdump to understand sv_flags records in the trace files. MFC r219044: Update manual page to reflect latest changes of ABI description support. MFC r219138: Teach kdump to understand linux syscalls names too. Fix bug introduced in r219043: the kernel always dump native signal numbers, so no need to check the ABI in ktrpsig(). Added: stable/8/usr.bin/kdump/linux_syscalls.conf - copied unchanged from r219138, head/usr.bin/kdump/linux_syscalls.conf Modified: stable/8/usr.bin/kdump/Makefile stable/8/usr.bin/kdump/kdump.1 stable/8/usr.bin/kdump/kdump.c stable/8/usr.bin/ktrace/ktrace.c stable/8/usr.bin/ktrace/ktrace.h Directory Properties: stable/8/usr.bin/kdump/ (props changed) stable/8/usr.bin/ktrace/ (props changed) Modified: stable/8/usr.bin/kdump/Makefile ============================================================================== --- stable/8/usr.bin/kdump/Makefile Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/kdump/Makefile Sat Apr 2 08:29:02 2011 (r220267) @@ -1,13 +1,21 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.if (${MACHINE_ARCH} == "amd64") +SFX= 32 +.endif + .PATH: ${.CURDIR}/../ktrace PROG= kdump SRCS= kdump.c ioctl.c kdump_subr.c subr.c CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -CLEANFILES= ioctl.c kdump_subr.c +.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" +SRCS+= linux_syscalls.c +.endif + +CLEANFILES= ioctl.c kdump_subr.c linux_syscalls.c ioctl.c: mkioctls sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET} @@ -15,4 +23,10 @@ ioctl.c: mkioctls kdump_subr.c: mksubr sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET} +linux_syscalls.c: + /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \ + ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux${SFX}/syscalls.master ${.CURDIR}/linux_syscalls.conf + echo "int nlinux_syscalls = sizeof(linux_syscallnames) / sizeof(linux_syscallnames[0]);" \ + >> linux_syscalls.c + .include Modified: stable/8/usr.bin/kdump/kdump.1 ============================================================================== --- stable/8/usr.bin/kdump/kdump.1 Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/kdump/kdump.1 Sat Apr 2 08:29:02 2011 (r220267) @@ -40,7 +40,7 @@ .Nd display kernel trace data .Sh SYNOPSIS .Nm -.Op Fl dEnlHRsT +.Op Fl dEnlHRsTA .Op Fl f Ar trfile .Op Fl m Ar maxdata .Op Fl p Ar pid @@ -103,6 +103,8 @@ GIDs, dates etc. symbolically instead of Suppress display of I/O data. .It Fl T Display absolute timestamps for each entry (seconds since epoch). +.It Fl A +Display description of the ABI of traced process. .It Fl t Ar trstr See the .Fl t Modified: stable/8/usr.bin/kdump/kdump.c ============================================================================== --- stable/8/usr.bin/kdump/kdump.c Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/kdump/kdump.c Sat Apr 2 08:29:02 2011 (r220267) @@ -59,7 +59,9 @@ extern int errno; #include #include #include +#include #include +#include #ifdef IPX #include #include @@ -85,10 +87,12 @@ extern int errno; #include "ktrace.h" #include "kdump_subr.h" +u_int abidump(struct ktr_header *); +int fetchprocinfo(struct ktr_header *, u_int *); int fread_tail(void *, int, int); void dumpheader(struct ktr_header *); -void ktrsyscall(struct ktr_syscall *); -void ktrsysret(struct ktr_sysret *); +void ktrsyscall(struct ktr_syscall *, u_int); +void ktrsysret(struct ktr_sysret *, u_int); void ktrnamei(char *, int); void hexdump(char *, int, int); void visdump(char *, int, int); @@ -104,13 +108,57 @@ void sockfamilyname(int); const char *ioctlname(u_long); int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, - resolv = 0; + resolv = 0, abiflag = 0; const char *tracefile = DEF_TRACEFILE; struct ktr_header ktr_header; #define TIME_FORMAT "%b %e %T %Y" #define eqs(s1, s2) (strcmp((s1), (s2)) == 0) +#define print_number(i,n,c) do { \ + if (decimal) \ + printf("%c%ld", c, (long)*i); \ + else \ + printf("%c%#lx", c, (long)*i); \ + i++; \ + n--; \ + c = ','; \ + } while (0); + +#if defined(__amd64__) || defined(__i386__) + +void linux_ktrsyscall(struct ktr_syscall *); +void linux_ktrsysret(struct ktr_sysret *); +extern char *linux_syscallnames[]; +extern int nlinux_syscalls; + +/* + * from linux.h + * Linux syscalls return negative errno's, we do positive and map them + */ +static int bsd_to_linux_errno[ELAST + 1] = { + -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, + -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, + -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, + -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, + -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, + -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, + -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, + -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, + -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -72, -67, -71 +}; +#endif + +struct proc_info +{ + TAILQ_ENTRY(proc_info) info; + u_int sv_flags; + pid_t pid; +}; + +TAILQ_HEAD(trace_procs, proc_info) trace_procs; + int main(int argc, char *argv[]) { @@ -119,11 +167,15 @@ main(int argc, char *argv[]) int trpoints = ALL_POINTS; int drop_logged; pid_t pid = 0; + u_int sv_flags; (void) setlocale(LC_CTYPE, ""); - while ((ch = getopt(argc,argv,"f:dElm:np:HRrsTt:")) != -1) + while ((ch = getopt(argc,argv,"f:dElm:np:AHRrsTt:")) != -1) switch((char)ch) { + case 'A': + abiflag = 1; + break; case 'f': tracefile = optarg; break; @@ -177,6 +229,7 @@ main(int argc, char *argv[]) errx(1, "%s", strerror(ENOMEM)); if (!freopen(tracefile, "r", stdin)) err(1, "%s", tracefile); + TAILQ_INIT(&trace_procs); drop_logged = 0; while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) { if (ktr_header.ktr_type & KTR_DROP) { @@ -209,6 +262,9 @@ main(int argc, char *argv[]) } if (ktrlen && fread_tail(m, ktrlen, 1) == 0) errx(1, "data too short"); + if (fetchprocinfo(&ktr_header, (u_int *)m) != 0) + continue; + sv_flags = abidump(&ktr_header); if (pid && ktr_header.ktr_pid != pid) continue; if ((trpoints & (1<ktr_type) { + case KTR_PROCCTOR: + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + TAILQ_REMOVE(&trace_procs, pi, info); + break; + } + } + pi = malloc(sizeof(struct proc_info)); + if (pi == NULL) + errx(1, "%s", strerror(ENOMEM)); + pi->sv_flags = *flags; + pi->pid = kth->ktr_pid; + TAILQ_INSERT_TAIL(&trace_procs, pi, info); + return (1); + + case KTR_PROCDTOR: + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + TAILQ_REMOVE(&trace_procs, pi, info); + free(pi); + break; + } + } + return (1); + } + + return (0); +} + +u_int +abidump(struct ktr_header *kth) +{ + struct proc_info *pi; + const char *abi; + const char *arch; + u_int flags = 0; + + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + flags = pi->sv_flags; + break; + } + } + + if (abiflag == 0) + return (flags); + + switch (flags & SV_ABI_MASK) { + case SV_ABI_LINUX: + abi = "L"; + break; + case SV_ABI_FREEBSD: + abi = "F"; + break; + default: + abi = "U"; + break; + } + + if (flags != 0) { + if (flags & SV_LP64) + arch = "64"; + else + arch = "32"; + } else + arch = "00"; + + printf("%s%s ", abi, arch); + + return (flags); +} + void dumpheader(struct ktr_header *kth) { @@ -297,6 +441,10 @@ dumpheader(struct ktr_header *kth) case KTR_SYSCTL: type = "SCTL"; break; + case KTR_PROCCTOR: + /* FALLTHROUGH */ + case KTR_PROCDTOR: + return; default: (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type); type = unknown; @@ -341,30 +489,21 @@ dumpheader(struct ktr_header *kth) int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]); void -ktrsyscall(struct ktr_syscall *ktr) +ktrsyscall(struct ktr_syscall *ktr, u_int flags) { int narg = ktr->ktr_narg; register_t *ip; - if (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0) + if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || + (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)) (void)printf("[%d]", ktr->ktr_code); else (void)printf("%s", syscallnames[ktr->ktr_code]); ip = &ktr->ktr_args[0]; if (narg) { char c = '('; - if (fancy) { - -#define print_number(i,n,c) do { \ - if (decimal) \ - (void)printf("%c%ld", c, (long)*i); \ - else \ - (void)printf("%c%#lx", c, (long)*i); \ - i++; \ - n--; \ - c = ','; \ - } while (0); - + if (fancy && + (flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) { if (ktr->ktr_code == SYS_ioctl) { const char *cp; print_number(ip,narg,c); @@ -811,13 +950,14 @@ ktrsyscall(struct ktr_syscall *ktr) } void -ktrsysret(struct ktr_sysret *ktr) +ktrsysret(struct ktr_sysret *ktr, u_int flags) { register_t ret = ktr->ktr_retval; int error = ktr->ktr_error; int code = ktr->ktr_code; - if (code >= nsyscalls || code < 0) + if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || + (code >= nsyscalls || code < 0)) (void)printf("[%d] ", code); else (void)printf("%s ", syscallnames[code]); @@ -1365,10 +1505,71 @@ invalid: printf("invalid record\n"); } +#if defined(__amd64__) || defined(__i386__) +void +linux_ktrsyscall(struct ktr_syscall *ktr) +{ + int narg = ktr->ktr_narg; + register_t *ip; + + if (ktr->ktr_code >= nlinux_syscalls || ktr->ktr_code < 0) + printf("[%d]", ktr->ktr_code); + else + printf("%s", linux_syscallnames[ktr->ktr_code]); + ip = &ktr->ktr_args[0]; + if (narg) { + char c = '('; + while (narg > 0) + print_number(ip, narg, c); + putchar(')'); + } + putchar('\n'); +} + +void +linux_ktrsysret(struct ktr_sysret *ktr) +{ + register_t ret = ktr->ktr_retval; + int error = ktr->ktr_error; + int code = ktr->ktr_code; + + if (code >= nlinux_syscalls || code < 0) + printf("[%d] ", code); + else + printf("%s ", linux_syscallnames[code]); + + if (error == 0) { + if (fancy) { + printf("%ld", (long)ret); + if (ret < 0 || ret > 9) + printf("/%#lx", (long)ret); + } else { + if (decimal) + printf("%ld", (long)ret); + else + printf("%#lx", (long)ret); + } + } else if (error == ERESTART) + printf("RESTART"); + else if (error == EJUSTRETURN) + printf("JUSTRETURN"); + else { + if (ktr->ktr_error <= ELAST + 1) + error = abs(bsd_to_linux_errno[ktr->ktr_error]); + else + error = 999; + printf("-1 errno %d", error); + if (fancy) + printf(" %s", strerror(ktr->ktr_error)); + } + putchar('\n'); +} +#endif + void usage(void) { - fprintf(stderr, "usage: kdump [-dEnlHRrsT] [-f trfile] " + fprintf(stderr, "usage: kdump [-dEnlHRrsTA] [-f trfile] " "[-m maxdata] [-p pid] [-t trstr]\n"); exit(1); } Copied: stable/8/usr.bin/kdump/linux_syscalls.conf (from r219138, head/usr.bin/kdump/linux_syscalls.conf) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/usr.bin/kdump/linux_syscalls.conf Sat Apr 2 08:29:02 2011 (r220267, copy of r219138, head/usr.bin/kdump/linux_syscalls.conf) @@ -0,0 +1,11 @@ +# $FreeBSD$ +sysnames="linux_syscalls.c" +sysproto="/dev/null" +sysproto_h=_LINUX_SYSPROTO_H_ +syshdr="/dev/null" +syssw="/dev/null" +sysmk="/dev/null" +syscallprefix="LINUX_SYS_" +switchname="/dev/null" +namesname="linux_syscallnames" +systrace="/dev/null" Modified: stable/8/usr.bin/ktrace/ktrace.c ============================================================================== --- stable/8/usr.bin/ktrace/ktrace.c Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/ktrace/ktrace.c Sat Apr 2 08:29:02 2011 (r220267) @@ -163,6 +163,8 @@ main(int argc, char *argv[]) (void)umask(omask); (void)close(fd); + trpoints |= PROC_ABI_POINTS; + if (*argv) { if (ktrace(tracefile, ops, trpoints, getpid()) < 0) err(1, "%s", tracefile); Modified: stable/8/usr.bin/ktrace/ktrace.h ============================================================================== --- stable/8/usr.bin/ktrace/ktrace.h Sat Apr 2 07:01:09 2011 (r220266) +++ stable/8/usr.bin/ktrace/ktrace.h Sat Apr 2 08:29:02 2011 (r220267) @@ -38,7 +38,9 @@ KTRFAC_GENIO | KTRFAC_PSIG | KTRFAC_USER | \ KTRFAC_STRUCT | KTRFAC_SYSCTL) -#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW) +#define PROC_ABI_POINTS (KTRFAC_PROCCTOR | KTRFAC_PROCDTOR) + +#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW | PROC_ABI_POINTS) #define DEF_TRACEFILE "ktrace.out" From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 08:34:24 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D8A42106564A; Sat, 2 Apr 2011 08:34:24 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CBBBE8FC15; Sat, 2 Apr 2011 08:34:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p328YOHj075768; Sat, 2 Apr 2011 08:34:24 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p328YOhG075761; Sat, 2 Apr 2011 08:34:24 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020834.p328YOhG075761@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 08:34:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220268 - in stable/7/usr.bin: kdump ktrace X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 08:34:25 -0000 Author: dchagin Date: Sat Apr 2 08:34:24 2011 New Revision: 220268 URL: http://svn.freebsd.org/changeset/base/220268 Log: MFC r219043: Teach kdump to understand sv_flags records in the trace files. MFC r219044: Update manual page to reflect latest changes of ABI description support. MFC r219138: Teach kdump to understand linux syscalls names too. Fix bug introduced in r219043: the kernel always dump native signal numbers, so no need to check the ABI in ktrpsig(). Added: stable/7/usr.bin/kdump/linux_syscalls.conf - copied unchanged from r219138, head/usr.bin/kdump/linux_syscalls.conf Modified: stable/7/usr.bin/kdump/Makefile stable/7/usr.bin/kdump/kdump.1 stable/7/usr.bin/kdump/kdump.c stable/7/usr.bin/ktrace/ktrace.c stable/7/usr.bin/ktrace/ktrace.h Directory Properties: stable/7/usr.bin/kdump/ (props changed) stable/7/usr.bin/ktrace/ (props changed) Modified: stable/7/usr.bin/kdump/Makefile ============================================================================== --- stable/7/usr.bin/kdump/Makefile Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/kdump/Makefile Sat Apr 2 08:34:24 2011 (r220268) @@ -1,13 +1,21 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ +.if (${MACHINE_ARCH} == "amd64") +SFX= 32 +.endif + .PATH: ${.CURDIR}/../ktrace PROG= kdump SRCS= kdump.c ioctl.c kdump_subr.c subr.c CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -CLEANFILES= ioctl.c kdump_subr.c +.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" +SRCS+= linux_syscalls.c +.endif + +CLEANFILES= ioctl.c kdump_subr.c linux_syscalls.c ioctl.c: mkioctls sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET} @@ -15,4 +23,10 @@ ioctl.c: mkioctls kdump_subr.c: mksubr sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET} +linux_syscalls.c: + /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \ + ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux${SFX}/syscalls.master ${.CURDIR}/linux_syscalls.conf + echo "int nlinux_syscalls = sizeof(linux_syscallnames) / sizeof(linux_syscallnames[0]);" \ + >> linux_syscalls.c + .include Modified: stable/7/usr.bin/kdump/kdump.1 ============================================================================== --- stable/7/usr.bin/kdump/kdump.1 Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/kdump/kdump.1 Sat Apr 2 08:34:24 2011 (r220268) @@ -40,7 +40,7 @@ .Nd display kernel trace data .Sh SYNOPSIS .Nm -.Op Fl dEnlHRsT +.Op Fl dEnlHRsTA .Op Fl f Ar trfile .Op Fl m Ar maxdata .Op Fl p Ar pid @@ -103,6 +103,8 @@ GIDs, dates etc. symbolically instead of Suppress display of I/O data. .It Fl T Display absolute timestamps for each entry (seconds since epoch). +.It Fl A +Display description of the ABI of traced process. .It Fl t Ar trstr See the .Fl t Modified: stable/7/usr.bin/kdump/kdump.c ============================================================================== --- stable/7/usr.bin/kdump/kdump.c Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/kdump/kdump.c Sat Apr 2 08:34:24 2011 (r220268) @@ -59,7 +59,9 @@ extern int errno; #include #include #include +#include #include +#include #ifdef IPX #include #include @@ -83,10 +85,12 @@ extern int errno; #include "ktrace.h" #include "kdump_subr.h" +u_int abidump(struct ktr_header *); +int fetchprocinfo(struct ktr_header *, u_int *); int fread_tail(void *, int, int); void dumpheader(struct ktr_header *); -void ktrsyscall(struct ktr_syscall *); -void ktrsysret(struct ktr_sysret *); +void ktrsyscall(struct ktr_syscall *, u_int); +void ktrsysret(struct ktr_sysret *, u_int); void ktrnamei(char *, int); void hexdump(char *, int, int); void visdump(char *, int, int); @@ -101,13 +105,57 @@ void usage(void); const char *ioctlname(u_long); int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, - resolv = 0; + resolv = 0, abiflag = 0; const char *tracefile = DEF_TRACEFILE; struct ktr_header ktr_header; #define TIME_FORMAT "%b %e %T %Y" #define eqs(s1, s2) (strcmp((s1), (s2)) == 0) +#define print_number(i,n,c) do { \ + if (decimal) \ + printf("%c%ld", c, (long)*i); \ + else \ + printf("%c%#lx", c, (long)*i); \ + i++; \ + n--; \ + c = ','; \ + } while (0); + +#if defined(__amd64__) || defined(__i386__) + +void linux_ktrsyscall(struct ktr_syscall *); +void linux_ktrsysret(struct ktr_sysret *); +extern char *linux_syscallnames[]; +extern int nlinux_syscalls; + +/* + * from linux.h + * Linux syscalls return negative errno's, we do positive and map them + */ +static int bsd_to_linux_errno[ELAST + 1] = { + -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, + -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, + -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, + -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, + -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, + -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, + -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, + -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, + -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, + -72, -67, -71 +}; +#endif + +struct proc_info +{ + TAILQ_ENTRY(proc_info) info; + u_int sv_flags; + pid_t pid; +}; + +TAILQ_HEAD(trace_procs, proc_info) trace_procs; + int main(int argc, char *argv[]) { @@ -116,11 +164,15 @@ main(int argc, char *argv[]) int trpoints = ALL_POINTS; int drop_logged; pid_t pid = 0; + u_int sv_flags; (void) setlocale(LC_CTYPE, ""); - while ((ch = getopt(argc,argv,"f:dElm:np:HRrsTt:")) != -1) + while ((ch = getopt(argc,argv,"f:dElm:np:AHRrsTt:")) != -1) switch((char)ch) { + case 'A': + abiflag = 1; + break; case 'f': tracefile = optarg; break; @@ -174,6 +226,7 @@ main(int argc, char *argv[]) errx(1, "%s", strerror(ENOMEM)); if (!freopen(tracefile, "r", stdin)) err(1, "%s", tracefile); + TAILQ_INIT(&trace_procs); drop_logged = 0; while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) { if (ktr_header.ktr_type & KTR_DROP) { @@ -206,6 +259,9 @@ main(int argc, char *argv[]) } if (ktrlen && fread_tail(m, ktrlen, 1) == 0) errx(1, "data too short"); + if (fetchprocinfo(&ktr_header, (u_int *)m) != 0) + continue; + sv_flags = abidump(&ktr_header); if (pid && ktr_header.ktr_pid != pid) continue; if ((trpoints & (1<ktr_type) { + case KTR_PROCCTOR: + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + TAILQ_REMOVE(&trace_procs, pi, info); + break; + } + } + pi = malloc(sizeof(struct proc_info)); + if (pi == NULL) + errx(1, "%s", strerror(ENOMEM)); + pi->sv_flags = *flags; + pi->pid = kth->ktr_pid; + TAILQ_INSERT_TAIL(&trace_procs, pi, info); + return (1); + + case KTR_PROCDTOR: + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + TAILQ_REMOVE(&trace_procs, pi, info); + free(pi); + break; + } + } + return (1); + } + + return (0); +} + +u_int +abidump(struct ktr_header *kth) +{ + struct proc_info *pi; + const char *abi; + const char *arch; + u_int flags = 0; + + TAILQ_FOREACH(pi, &trace_procs, info) { + if (pi->pid == kth->ktr_pid) { + flags = pi->sv_flags; + break; + } + } + + if (abiflag == 0) + return (flags); + + switch (flags & SV_ABI_MASK) { + case SV_ABI_LINUX: + abi = "L"; + break; + case SV_ABI_FREEBSD: + abi = "F"; + break; + default: + abi = "U"; + break; + } + + if (flags != 0) { + if (flags & SV_LP64) + arch = "64"; + else + arch = "32"; + } else + arch = "00"; + + printf("%s%s ", abi, arch); + + return (flags); +} + void dumpheader(struct ktr_header *kth) { @@ -294,6 +438,10 @@ dumpheader(struct ktr_header *kth) case KTR_SYSCTL: type = "SCTL"; break; + case KTR_PROCCTOR: + /* FALLTHROUGH */ + case KTR_PROCDTOR: + return; default: (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type); type = unknown; @@ -338,30 +486,21 @@ dumpheader(struct ktr_header *kth) int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]); void -ktrsyscall(struct ktr_syscall *ktr) +ktrsyscall(struct ktr_syscall *ktr, u_int flags) { int narg = ktr->ktr_narg; register_t *ip; - if (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0) + if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || + (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)) (void)printf("[%d]", ktr->ktr_code); else (void)printf("%s", syscallnames[ktr->ktr_code]); ip = &ktr->ktr_args[0]; if (narg) { char c = '('; - if (fancy) { - -#define print_number(i,n,c) do { \ - if (decimal) \ - (void)printf("%c%ld", c, (long)*i); \ - else \ - (void)printf("%c%#lx", c, (long)*i); \ - i++; \ - n--; \ - c = ','; \ - } while (0); - + if (fancy && + (flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) { if (ktr->ktr_code == SYS_ioctl) { const char *cp; print_number(ip,narg,c); @@ -814,13 +953,14 @@ ktrsyscall(struct ktr_syscall *ktr) } void -ktrsysret(struct ktr_sysret *ktr) +ktrsysret(struct ktr_sysret *ktr, u_int flags) { register_t ret = ktr->ktr_retval; int error = ktr->ktr_error; int code = ktr->ktr_code; - if (code >= nsyscalls || code < 0) + if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || + (code >= nsyscalls || code < 0)) (void)printf("[%d] ", code); else (void)printf("%s ", syscallnames[code]); @@ -1368,10 +1508,71 @@ invalid: printf("invalid record\n"); } +#if defined(__amd64__) || defined(__i386__) +void +linux_ktrsyscall(struct ktr_syscall *ktr) +{ + int narg = ktr->ktr_narg; + register_t *ip; + + if (ktr->ktr_code >= nlinux_syscalls || ktr->ktr_code < 0) + printf("[%d]", ktr->ktr_code); + else + printf("%s", linux_syscallnames[ktr->ktr_code]); + ip = &ktr->ktr_args[0]; + if (narg) { + char c = '('; + while (narg > 0) + print_number(ip, narg, c); + putchar(')'); + } + putchar('\n'); +} + +void +linux_ktrsysret(struct ktr_sysret *ktr) +{ + register_t ret = ktr->ktr_retval; + int error = ktr->ktr_error; + int code = ktr->ktr_code; + + if (code >= nlinux_syscalls || code < 0) + printf("[%d] ", code); + else + printf("%s ", linux_syscallnames[code]); + + if (error == 0) { + if (fancy) { + printf("%ld", (long)ret); + if (ret < 0 || ret > 9) + printf("/%#lx", (long)ret); + } else { + if (decimal) + printf("%ld", (long)ret); + else + printf("%#lx", (long)ret); + } + } else if (error == ERESTART) + printf("RESTART"); + else if (error == EJUSTRETURN) + printf("JUSTRETURN"); + else { + if (ktr->ktr_error <= ELAST + 1) + error = abs(bsd_to_linux_errno[ktr->ktr_error]); + else + error = 999; + printf("-1 errno %d", error); + if (fancy) + printf(" %s", strerror(ktr->ktr_error)); + } + putchar('\n'); +} +#endif + void usage(void) { - fprintf(stderr, "usage: kdump [-dEnlHRrsT] [-f trfile] " + fprintf(stderr, "usage: kdump [-dEnlHRrsTA] [-f trfile] " "[-m maxdata] [-p pid] [-t trstr]\n"); exit(1); } Copied: stable/7/usr.bin/kdump/linux_syscalls.conf (from r219138, head/usr.bin/kdump/linux_syscalls.conf) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/usr.bin/kdump/linux_syscalls.conf Sat Apr 2 08:34:24 2011 (r220268, copy of r219138, head/usr.bin/kdump/linux_syscalls.conf) @@ -0,0 +1,11 @@ +# $FreeBSD$ +sysnames="linux_syscalls.c" +sysproto="/dev/null" +sysproto_h=_LINUX_SYSPROTO_H_ +syshdr="/dev/null" +syssw="/dev/null" +sysmk="/dev/null" +syscallprefix="LINUX_SYS_" +switchname="/dev/null" +namesname="linux_syscallnames" +systrace="/dev/null" Modified: stable/7/usr.bin/ktrace/ktrace.c ============================================================================== --- stable/7/usr.bin/ktrace/ktrace.c Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/ktrace/ktrace.c Sat Apr 2 08:34:24 2011 (r220268) @@ -163,6 +163,8 @@ main(int argc, char *argv[]) (void)umask(omask); (void)close(fd); + trpoints |= PROC_ABI_POINTS; + if (*argv) { if (ktrace(tracefile, ops, trpoints, getpid()) < 0) err(1, "%s", tracefile); Modified: stable/7/usr.bin/ktrace/ktrace.h ============================================================================== --- stable/7/usr.bin/ktrace/ktrace.h Sat Apr 2 08:29:02 2011 (r220267) +++ stable/7/usr.bin/ktrace/ktrace.h Sat Apr 2 08:34:24 2011 (r220268) @@ -38,7 +38,9 @@ KTRFAC_GENIO | KTRFAC_PSIG | KTRFAC_USER | \ KTRFAC_STRUCT | KTRFAC_SYSCTL) -#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW) +#define PROC_ABI_POINTS (KTRFAC_PROCCTOR | KTRFAC_PROCDTOR) + +#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW | PROC_ABI_POINTS) #define DEF_TRACEFILE "ktrace.out" From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 08:45:13 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EF2EB1065673; Sat, 2 Apr 2011 08:45:13 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E3FBD8FC08; Sat, 2 Apr 2011 08:45:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p328jD9f076057; Sat, 2 Apr 2011 08:45:13 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p328jDxD076055; Sat, 2 Apr 2011 08:45:13 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104020845.p328jDxD076055@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 08:45:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220269 - stable/8/sys/amd64/linux32 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 08:45:14 -0000 Author: dchagin Date: Sat Apr 2 08:45:13 2011 New Revision: 220269 URL: http://svn.freebsd.org/changeset/base/220269 Log: MFC r219364: Remove dead (since r190620) code. Modified: stable/8/sys/amd64/linux32/linux32_genassym.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/linux32/linux32_genassym.c ============================================================================== --- stable/8/sys/amd64/linux32/linux32_genassym.c Sat Apr 2 08:34:24 2011 (r220268) +++ stable/8/sys/amd64/linux32/linux32_genassym.c Sat Apr 2 08:45:13 2011 (r220269) @@ -9,8 +9,6 @@ __FBSDID("$FreeBSD$"); ASSYM(LINUX_SIGF_HANDLER, offsetof(struct l_sigframe, sf_handler)); ASSYM(LINUX_SIGF_SC, offsetof(struct l_sigframe, sf_sc)); -ASSYM(LINUX_SC_ES, offsetof(struct l_sigcontext, sc_es)); -ASSYM(LINUX_SC_DS, offsetof(struct l_sigcontext, sc_ds)); ASSYM(LINUX_RT_SIGF_HANDLER, offsetof(struct l_rt_sigframe, sf_handler)); ASSYM(LINUX_RT_SIGF_UC, offsetof(struct l_rt_sigframe, sf_sc)); ASSYM(LINUX_RT_SIGF_SC, offsetof(struct l_ucontext, uc_mcontext)); From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 10:06:26 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA3A01065672; Sat, 2 Apr 2011 10:06:26 +0000 (UTC) (envelope-from freebsd@nagilum.org) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.171]) by mx1.freebsd.org (Postfix) with ESMTP id 7D0148FC0A; Sat, 2 Apr 2011 10:06:26 +0000 (UTC) Received: from cakebox.homeunix.net (krlh-4d0376d5.pool.mediaWays.net [77.3.118.213]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0LwSnT-1PtL7M1S6Z-018NPX; Sat, 02 Apr 2011 11:53:47 +0200 Received: from cakebox.homeunix.net (localhost [127.0.0.1]) by cakebox.homeunix.net (Postfix) with ESMTP id 79E956794E; Sat, 2 Apr 2011 11:53:38 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on cakebox.tis X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.1 Received: by cakebox.homeunix.net (Postfix, from userid 80) id 292EF6781A; Sat, 2 Apr 2011 11:53:37 +0200 (CEST) Received: from krlh-4d0376d5.pool.mediaWays.net (krlh-4d0376d5.pool.mediaWays.net [77.3.118.213]) by cakebox.homeunix.net (Horde Framework) with HTTP; Sat, 02 Apr 2011 11:53:36 +0200 Message-ID: <20110402115336.37394ztrsha7r58o@cakebox.homeunix.net> Date: Sat, 02 Apr 2011 11:53:36 +0200 From: Alexander To: Xin LI References: <201104011823.p31INiHv055195@svn.freebsd.org> <20110402015552.GA32901@FreeBSD.org> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Dynamic Internet Messaging Program (DIMP) H3 (1.1.6) X-Provags-ID: V02:K0:6MkYu8xJUuHw4/usA+0z1nDQR1k5imtu7Qd9I3sdLOt ev6EbW5Jwc/wyrktxGhy64zQnpy2mPVxPdmuGE0pquQxLgYD6N zuJzP1g4J9eGp0wACttnewxdEnz2V8JrtgQf5r667bvkrDPAod Jud9lC1Yjjqogq9j74IMxj6s6KOQZXqKBtcm9m+R8eW9dC2QCi hQJTH5cpiBd3hZ2jrwTKXrqX6JbLypqFrZsOkBkBbw= Cc: svn-src-stable@freebsd.org, Alexey Dokuchaev Subject: Re: svn commit: r220250 - in stable/8: bin/test tools/regression/bin/test X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 10:06:27 -0000 The downside is that one may end up writing scripts on FreeBSD which =20 will unexpectedly break on other Unixes. Alex. ----- Message from delphij@gmail.com --------- Date: Sat, 2 Apr 2011 00:33:43 -0700 From: Xin LI Subject: Re: svn commit: r220250 - in stable/8: bin/test =20 tools/regression/bin/test To: Alexey Dokuchaev Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, =20 src-committers@freebsd.org, Xin LI , =20 svn-src-stable-8@freebsd.org > 2011/4/1 Alexey Dokuchaev : >> On Fri, Apr 01, 2011 at 06:23:44PM +0000, Xin LI wrote: >>> =A0 Accept =3D=3D as an alias of =3D which is a popular GNU extension. >>> >>> =A0 This is intentionally undocumented for now since it's not part >>> =A0 of any standard. >> >> I thought general consensus that this change should never be part of >> FreeBSD, not just being undocumented (which, as we all know, is bad >> practice pe se). > > This have been discussed in -standards@ and have been settled for more > than 1 month, there were two developers asked me after the commit but > nobody asked for a revert (so far), so I don't think it's general > consensus that this change should not be part of FreeBSD. Being > undocumented means we do not encourage its use. > > I think there is good reason to add this extension for compatibility > reasons, plus it does not break anything. > > So did I missed some discussion about why it's a bad move? > > Cheers, > -- > Xin LI http://www.delphij.net > _______________________________________________ > svn-src-stable-8@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-stable-8 > To unsubscribe, send any mail to "svn-src-stable-8-unsubscribe@freebsd.or= g" > ----- End message from delphij@gmail.com ----- =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D # _ __ _ __ http://www.nagilum.org/ \n icq://69646724 # # / |/ /__ ____ _(_) /_ ____ _ nagilum@nagilum.org \n +491776461165 # # / / _ `/ _ `/ / / // / ' \ Amiga (68k/PPC): AOS/NetBSD/Linux # # /_/|_/\_,_/\_, /_/_/\_,_/_/_/_/ Mac (PPC): MacOS-X / Linux / MacOS-X # # /___/ x86: FreeBSD/Linux/Solaris/Win2k ARM9: EPOC EV6 # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---------------------------------------------------------------- cakebox.homeunix.net - all the machine one needs.. From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 10:13:42 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 504281065672; Sat, 2 Apr 2011 10:13:42 +0000 (UTC) (envelope-from delphij@gmail.com) Received: from mail-pv0-f182.google.com (mail-pv0-f182.google.com [74.125.83.182]) by mx1.freebsd.org (Postfix) with ESMTP id 228F68FC14; Sat, 2 Apr 2011 10:13:41 +0000 (UTC) Received: by pvg11 with SMTP id 11so1090126pvg.13 for ; Sat, 02 Apr 2011 03:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=x/TV9A2V0IPeqJPLQ9yfT/nFk7LE9bTogkK30BuiLuo=; b=ACTtVOm9GniTfn0/7IRPljJux9kD6+S+c66Rn30CfPblITlrNhvVyTzMisg1cUcQRF RO8ApFoscVsxjZSwOE/eE2IIJx+T1zSd84RZngleBsn0Sx3Eqkct918hyX6TXuDJ3fGj TKlPxo4AwaHRyFmN0zempGi+ZjZSkEtnYwbSE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=MfvZci7x8g0nkmlz+rWgp9y2iCgy/7TStBSyJ3ufL6zG2wZ1lyzgoab7VffPAh1LQf IzBnqUR8z6Q0sXA4shxkxiwUSTDEAnxrh7JIXk1Zl9qolxD6IbtPIxMphtHZdk5uuac+ jswjB0yqfYgp2x0xeYklPJkSdzZuayOQUwdCs= MIME-Version: 1.0 Received: by 10.142.173.20 with SMTP id v20mr3801431wfe.212.1301739221538; Sat, 02 Apr 2011 03:13:41 -0700 (PDT) Received: by 10.68.62.164 with HTTP; Sat, 2 Apr 2011 03:13:41 -0700 (PDT) In-Reply-To: <20110402115336.37394ztrsha7r58o@cakebox.homeunix.net> References: <201104011823.p31INiHv055195@svn.freebsd.org> <20110402015552.GA32901@FreeBSD.org> <20110402115336.37394ztrsha7r58o@cakebox.homeunix.net> Date: Sat, 2 Apr 2011 03:13:41 -0700 Message-ID: From: Xin LI To: Alexander Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: svn-src-stable@freebsd.org, Alexey Dokuchaev Subject: Re: svn commit: r220250 - in stable/8: bin/test tools/regression/bin/test X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 10:13:42 -0000 2011/4/2 Alexander : > The downside is that one may end up writing scripts on FreeBSD which will > unexpectedly break on other Unixes. Do we consider having someone else's script 'unexpectedly' break on FreeBSD as a better thing then? I think if we want FreeBSD to serve as a standard validator, it's better to hide such behavior under things like a POSIXLY_CORRECT umbrella. > ----- Message from delphij@gmail.com --------- > =C2=A0 =C2=A0Date: Sat, 2 Apr 2011 00:33:43 -0700 > =C2=A0 =C2=A0From: Xin LI > =C2=A0Subject: Re: svn commit: r220250 - in stable/8: bin/test > tools/regression/bin/test > =C2=A0 =C2=A0 =C2=A0To: Alexey Dokuchaev > =C2=A0 =C2=A0 =C2=A0Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.o= rg, > src-committers@freebsd.org, Xin LI , > svn-src-stable-8@freebsd.org > > >> 2011/4/1 Alexey Dokuchaev : >>> >>> On Fri, Apr 01, 2011 at 06:23:44PM +0000, Xin LI wrote: >>>> >>>> =C2=A0 Accept =3D=3D as an alias of =3D which is a popular GNU extensi= on. >>>> >>>> =C2=A0 This is intentionally undocumented for now since it's not part >>>> =C2=A0 of any standard. >>> >>> I thought general consensus that this change should never be part of >>> FreeBSD, not just being undocumented (which, as we all know, is bad >>> practice pe se). >> >> This have been discussed in -standards@ and have been settled for more >> than 1 month, there were two developers asked me after the commit but >> nobody asked for a revert (so far), so I don't think it's general >> consensus that this change should not be part of FreeBSD. =C2=A0Being >> undocumented means we do not encourage its use. >> >> I think there is good reason to add this extension for compatibility >> reasons, plus it does not break anything. >> >> So did I missed some discussion about why it's a bad move? >> >> Cheers, >> -- >> Xin LI http://www.delphij.net >> _______________________________________________ >> svn-src-stable-8@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/svn-src-stable-8 >> To unsubscribe, send any mail to >> "svn-src-stable-8-unsubscribe@freebsd.org" >> > > > ----- End message from delphij@gmail.com ----- > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > # =C2=A0 =C2=A0_ =C2=A0__ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_ __ =C2=A0 = =C2=A0 http://www.nagilum.org/ \n icq://69646724 # > # =C2=A0 / |/ /__ ____ _(_) /_ ____ _ =C2=A0nagilum@nagilum.org \n +49177= 6461165 # > # =C2=A0/ =C2=A0 =C2=A0/ _ `/ _ `/ / / // / =C2=A0' \ =C2=A0Amiga (68k/PP= C): AOS/NetBSD/Linux =C2=A0 # > # /_/|_/\_,_/\_, /_/_/\_,_/_/_/_/ Mac (PPC): MacOS-X / Linux / MacOS-X # > # =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /___/ =C2=A0 =C2=A0 x86: FreeBSD/Lin= ux/Solaris/Win2k =C2=A0ARM9: EPOC EV6 # > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > ---------------------------------------------------------------- > cakebox.homeunix.net - all the machine one needs.. > --=20 Xin LI http://www.delphij.net From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 10:19:43 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 1033) id 21D1D1065677; Sat, 2 Apr 2011 10:19:43 +0000 (UTC) Date: Sat, 2 Apr 2011 10:19:43 +0000 From: Alexey Dokuchaev To: Alexander Message-ID: <20110402101943.GA81206@FreeBSD.org> References: <201104011823.p31INiHv055195@svn.freebsd.org> <20110402015552.GA32901@FreeBSD.org> <20110402115336.37394ztrsha7r58o@cakebox.homeunix.net> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20110402115336.37394ztrsha7r58o@cakebox.homeunix.net> User-Agent: Mutt/1.4.2.1i Cc: svn-src-stable@freebsd.org, Xin LI Subject: Re: svn commit: r220250 - in stable/8: bin/test tools/regression/bin/test X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 10:19:43 -0000 On Sat, Apr 02, 2011 at 11:53:36AM +0200, Alexander wrote: > The downside is that one may end up writing scripts on FreeBSD which > will unexpectedly break on other Unixes. Exactly. I also fail to understand why would we want to strive for compatibility which broken shells (bash) by introducing controversial features that are not part of any standard and deliberately undocumented. This is what usually happens when deprecating stuff, no? Introducing new functionality in "stealth" mode like this makes little sense, and I believe does more harm than good. I recall that it was discussed here on svn-* lists after in was committed to HEAD, and opinions were mostly negative IMSMR. I am a bit surprised it was not backed out (not that it is my call). ./danfe From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 10:28:09 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31CBF106566C; Sat, 2 Apr 2011 10:28:09 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 200E38FC13; Sat, 2 Apr 2011 10:28:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32AS9Ae078629; Sat, 2 Apr 2011 10:28:09 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32AS8c2078623; Sat, 2 Apr 2011 10:28:08 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104021028.p32AS8c2078623@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 10:28:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220276 - in stable/7/usr.bin: kdump ktrace X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 10:28:09 -0000 Author: dchagin Date: Sat Apr 2 10:28:08 2011 New Revision: 220276 URL: http://svn.freebsd.org/changeset/base/220276 Log: Revert r220268, SV_ABI patches was never merged to 7. Deleted: stable/7/usr.bin/kdump/linux_syscalls.conf Modified: stable/7/usr.bin/kdump/Makefile stable/7/usr.bin/kdump/kdump.1 stable/7/usr.bin/kdump/kdump.c stable/7/usr.bin/ktrace/ktrace.c stable/7/usr.bin/ktrace/ktrace.h Modified: stable/7/usr.bin/kdump/Makefile ============================================================================== --- stable/7/usr.bin/kdump/Makefile Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/kdump/Makefile Sat Apr 2 10:28:08 2011 (r220276) @@ -1,21 +1,13 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.if (${MACHINE_ARCH} == "amd64") -SFX= 32 -.endif - .PATH: ${.CURDIR}/../ktrace PROG= kdump SRCS= kdump.c ioctl.c kdump_subr.c subr.c CFLAGS+= -I${.CURDIR}/../ktrace -I${.CURDIR} -I${.CURDIR}/../.. -.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" -SRCS+= linux_syscalls.c -.endif - -CLEANFILES= ioctl.c kdump_subr.c linux_syscalls.c +CLEANFILES= ioctl.c kdump_subr.c ioctl.c: mkioctls sh ${.CURDIR}/mkioctls ${DESTDIR}/usr/include > ${.TARGET} @@ -23,10 +15,4 @@ ioctl.c: mkioctls kdump_subr.c: mksubr sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include > ${.TARGET} -linux_syscalls.c: - /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \ - ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux${SFX}/syscalls.master ${.CURDIR}/linux_syscalls.conf - echo "int nlinux_syscalls = sizeof(linux_syscallnames) / sizeof(linux_syscallnames[0]);" \ - >> linux_syscalls.c - .include Modified: stable/7/usr.bin/kdump/kdump.1 ============================================================================== --- stable/7/usr.bin/kdump/kdump.1 Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/kdump/kdump.1 Sat Apr 2 10:28:08 2011 (r220276) @@ -40,7 +40,7 @@ .Nd display kernel trace data .Sh SYNOPSIS .Nm -.Op Fl dEnlHRsTA +.Op Fl dEnlHRsT .Op Fl f Ar trfile .Op Fl m Ar maxdata .Op Fl p Ar pid @@ -103,8 +103,6 @@ GIDs, dates etc. symbolically instead of Suppress display of I/O data. .It Fl T Display absolute timestamps for each entry (seconds since epoch). -.It Fl A -Display description of the ABI of traced process. .It Fl t Ar trstr See the .Fl t Modified: stable/7/usr.bin/kdump/kdump.c ============================================================================== --- stable/7/usr.bin/kdump/kdump.c Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/kdump/kdump.c Sat Apr 2 10:28:08 2011 (r220276) @@ -59,9 +59,7 @@ extern int errno; #include #include #include -#include #include -#include #ifdef IPX #include #include @@ -85,12 +83,10 @@ extern int errno; #include "ktrace.h" #include "kdump_subr.h" -u_int abidump(struct ktr_header *); -int fetchprocinfo(struct ktr_header *, u_int *); int fread_tail(void *, int, int); void dumpheader(struct ktr_header *); -void ktrsyscall(struct ktr_syscall *, u_int); -void ktrsysret(struct ktr_sysret *, u_int); +void ktrsyscall(struct ktr_syscall *); +void ktrsysret(struct ktr_sysret *); void ktrnamei(char *, int); void hexdump(char *, int, int); void visdump(char *, int, int); @@ -105,57 +101,13 @@ void usage(void); const char *ioctlname(u_long); int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, - resolv = 0, abiflag = 0; + resolv = 0; const char *tracefile = DEF_TRACEFILE; struct ktr_header ktr_header; #define TIME_FORMAT "%b %e %T %Y" #define eqs(s1, s2) (strcmp((s1), (s2)) == 0) -#define print_number(i,n,c) do { \ - if (decimal) \ - printf("%c%ld", c, (long)*i); \ - else \ - printf("%c%#lx", c, (long)*i); \ - i++; \ - n--; \ - c = ','; \ - } while (0); - -#if defined(__amd64__) || defined(__i386__) - -void linux_ktrsyscall(struct ktr_syscall *); -void linux_ktrsysret(struct ktr_sysret *); -extern char *linux_syscallnames[]; -extern int nlinux_syscalls; - -/* - * from linux.h - * Linux syscalls return negative errno's, we do positive and map them - */ -static int bsd_to_linux_errno[ELAST + 1] = { - -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, - -10, -35, -12, -13, -14, -15, -16, -17, -18, -19, - -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, - -30, -31, -32, -33, -34, -11,-115,-114, -88, -89, - -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, - -100,-101,-102,-103,-104,-105,-106,-107,-108,-109, - -110,-111, -40, -36,-112,-113, -39, -11, -87,-122, - -116, -66, -6, -6, -6, -6, -6, -37, -38, -9, - -6, -6, -43, -42, -75,-125, -84, -95, -16, -74, - -72, -67, -71 -}; -#endif - -struct proc_info -{ - TAILQ_ENTRY(proc_info) info; - u_int sv_flags; - pid_t pid; -}; - -TAILQ_HEAD(trace_procs, proc_info) trace_procs; - int main(int argc, char *argv[]) { @@ -164,15 +116,11 @@ main(int argc, char *argv[]) int trpoints = ALL_POINTS; int drop_logged; pid_t pid = 0; - u_int sv_flags; (void) setlocale(LC_CTYPE, ""); - while ((ch = getopt(argc,argv,"f:dElm:np:AHRrsTt:")) != -1) + while ((ch = getopt(argc,argv,"f:dElm:np:HRrsTt:")) != -1) switch((char)ch) { - case 'A': - abiflag = 1; - break; case 'f': tracefile = optarg; break; @@ -226,7 +174,6 @@ main(int argc, char *argv[]) errx(1, "%s", strerror(ENOMEM)); if (!freopen(tracefile, "r", stdin)) err(1, "%s", tracefile); - TAILQ_INIT(&trace_procs); drop_logged = 0; while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) { if (ktr_header.ktr_type & KTR_DROP) { @@ -259,9 +206,6 @@ main(int argc, char *argv[]) } if (ktrlen && fread_tail(m, ktrlen, 1) == 0) errx(1, "data too short"); - if (fetchprocinfo(&ktr_header, (u_int *)m) != 0) - continue; - sv_flags = abidump(&ktr_header); if (pid && ktr_header.ktr_pid != pid) continue; if ((trpoints & (1<ktr_type) { - case KTR_PROCCTOR: - TAILQ_FOREACH(pi, &trace_procs, info) { - if (pi->pid == kth->ktr_pid) { - TAILQ_REMOVE(&trace_procs, pi, info); - break; - } - } - pi = malloc(sizeof(struct proc_info)); - if (pi == NULL) - errx(1, "%s", strerror(ENOMEM)); - pi->sv_flags = *flags; - pi->pid = kth->ktr_pid; - TAILQ_INSERT_TAIL(&trace_procs, pi, info); - return (1); - - case KTR_PROCDTOR: - TAILQ_FOREACH(pi, &trace_procs, info) { - if (pi->pid == kth->ktr_pid) { - TAILQ_REMOVE(&trace_procs, pi, info); - free(pi); - break; - } - } - return (1); - } - - return (0); -} - -u_int -abidump(struct ktr_header *kth) -{ - struct proc_info *pi; - const char *abi; - const char *arch; - u_int flags = 0; - - TAILQ_FOREACH(pi, &trace_procs, info) { - if (pi->pid == kth->ktr_pid) { - flags = pi->sv_flags; - break; - } - } - - if (abiflag == 0) - return (flags); - - switch (flags & SV_ABI_MASK) { - case SV_ABI_LINUX: - abi = "L"; - break; - case SV_ABI_FREEBSD: - abi = "F"; - break; - default: - abi = "U"; - break; - } - - if (flags != 0) { - if (flags & SV_LP64) - arch = "64"; - else - arch = "32"; - } else - arch = "00"; - - printf("%s%s ", abi, arch); - - return (flags); -} - void dumpheader(struct ktr_header *kth) { @@ -438,10 +294,6 @@ dumpheader(struct ktr_header *kth) case KTR_SYSCTL: type = "SCTL"; break; - case KTR_PROCCTOR: - /* FALLTHROUGH */ - case KTR_PROCDTOR: - return; default: (void)sprintf(unknown, "UNKNOWN(%d)", kth->ktr_type); type = unknown; @@ -486,21 +338,30 @@ dumpheader(struct ktr_header *kth) int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]); void -ktrsyscall(struct ktr_syscall *ktr, u_int flags) +ktrsyscall(struct ktr_syscall *ktr) { int narg = ktr->ktr_narg; register_t *ip; - if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || - (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)) + if (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0) (void)printf("[%d]", ktr->ktr_code); else (void)printf("%s", syscallnames[ktr->ktr_code]); ip = &ktr->ktr_args[0]; if (narg) { char c = '('; - if (fancy && - (flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) { + if (fancy) { + +#define print_number(i,n,c) do { \ + if (decimal) \ + (void)printf("%c%ld", c, (long)*i); \ + else \ + (void)printf("%c%#lx", c, (long)*i); \ + i++; \ + n--; \ + c = ','; \ + } while (0); + if (ktr->ktr_code == SYS_ioctl) { const char *cp; print_number(ip,narg,c); @@ -953,14 +814,13 @@ ktrsyscall(struct ktr_syscall *ktr, u_in } void -ktrsysret(struct ktr_sysret *ktr, u_int flags) +ktrsysret(struct ktr_sysret *ktr) { register_t ret = ktr->ktr_retval; int error = ktr->ktr_error; int code = ktr->ktr_code; - if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || - (code >= nsyscalls || code < 0)) + if (code >= nsyscalls || code < 0) (void)printf("[%d] ", code); else (void)printf("%s ", syscallnames[code]); @@ -1508,71 +1368,10 @@ invalid: printf("invalid record\n"); } -#if defined(__amd64__) || defined(__i386__) -void -linux_ktrsyscall(struct ktr_syscall *ktr) -{ - int narg = ktr->ktr_narg; - register_t *ip; - - if (ktr->ktr_code >= nlinux_syscalls || ktr->ktr_code < 0) - printf("[%d]", ktr->ktr_code); - else - printf("%s", linux_syscallnames[ktr->ktr_code]); - ip = &ktr->ktr_args[0]; - if (narg) { - char c = '('; - while (narg > 0) - print_number(ip, narg, c); - putchar(')'); - } - putchar('\n'); -} - -void -linux_ktrsysret(struct ktr_sysret *ktr) -{ - register_t ret = ktr->ktr_retval; - int error = ktr->ktr_error; - int code = ktr->ktr_code; - - if (code >= nlinux_syscalls || code < 0) - printf("[%d] ", code); - else - printf("%s ", linux_syscallnames[code]); - - if (error == 0) { - if (fancy) { - printf("%ld", (long)ret); - if (ret < 0 || ret > 9) - printf("/%#lx", (long)ret); - } else { - if (decimal) - printf("%ld", (long)ret); - else - printf("%#lx", (long)ret); - } - } else if (error == ERESTART) - printf("RESTART"); - else if (error == EJUSTRETURN) - printf("JUSTRETURN"); - else { - if (ktr->ktr_error <= ELAST + 1) - error = abs(bsd_to_linux_errno[ktr->ktr_error]); - else - error = 999; - printf("-1 errno %d", error); - if (fancy) - printf(" %s", strerror(ktr->ktr_error)); - } - putchar('\n'); -} -#endif - void usage(void) { - fprintf(stderr, "usage: kdump [-dEnlHRrsTA] [-f trfile] " + fprintf(stderr, "usage: kdump [-dEnlHRrsT] [-f trfile] " "[-m maxdata] [-p pid] [-t trstr]\n"); exit(1); } Modified: stable/7/usr.bin/ktrace/ktrace.c ============================================================================== --- stable/7/usr.bin/ktrace/ktrace.c Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/ktrace/ktrace.c Sat Apr 2 10:28:08 2011 (r220276) @@ -163,8 +163,6 @@ main(int argc, char *argv[]) (void)umask(omask); (void)close(fd); - trpoints |= PROC_ABI_POINTS; - if (*argv) { if (ktrace(tracefile, ops, trpoints, getpid()) < 0) err(1, "%s", tracefile); Modified: stable/7/usr.bin/ktrace/ktrace.h ============================================================================== --- stable/7/usr.bin/ktrace/ktrace.h Sat Apr 2 09:46:09 2011 (r220275) +++ stable/7/usr.bin/ktrace/ktrace.h Sat Apr 2 10:28:08 2011 (r220276) @@ -38,9 +38,7 @@ KTRFAC_GENIO | KTRFAC_PSIG | KTRFAC_USER | \ KTRFAC_STRUCT | KTRFAC_SYSCTL) -#define PROC_ABI_POINTS (KTRFAC_PROCCTOR | KTRFAC_PROCDTOR) - -#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW | PROC_ABI_POINTS) +#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW) #define DEF_TRACEFILE "ktrace.out" From owner-svn-src-stable@FreeBSD.ORG Sat Apr 2 10:31:41 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8969D106566C; Sat, 2 Apr 2011 10:31:41 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7C07A8FC0A; Sat, 2 Apr 2011 10:31:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32AVffM078777; Sat, 2 Apr 2011 10:31:41 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32AVfbu078772; Sat, 2 Apr 2011 10:31:41 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <201104021031.p32AVfbu078772@svn.freebsd.org> From: Dmitry Chagin Date: Sat, 2 Apr 2011 10:31:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220277 - in stable/7/sys: kern sys X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 10:31:41 -0000 Author: dchagin Date: Sat Apr 2 10:31:41 2011 New Revision: 220277 URL: http://svn.freebsd.org/changeset/base/220277 Log: Revert r220263, SV_ABI patches was never merged to 7. Modified: stable/7/sys/kern/kern_exec.c stable/7/sys/kern/kern_fork.c stable/7/sys/kern/kern_ktrace.c stable/7/sys/sys/ktrace.h Modified: stable/7/sys/kern/kern_exec.c ============================================================================== --- stable/7/sys/kern/kern_exec.c Sat Apr 2 10:28:08 2011 (r220276) +++ stable/7/sys/kern/kern_exec.c Sat Apr 2 10:31:41 2011 (r220277) @@ -845,12 +845,6 @@ done2: exit1(td, W_EXITCODE(0, SIGABRT)); /* NOT REACHED */ } - -#ifdef KTRACE - if (error == 0) - ktrprocctor(p); -#endif - return (error); } Modified: stable/7/sys/kern/kern_fork.c ============================================================================== --- stable/7/sys/kern/kern_fork.c Sat Apr 2 10:28:08 2011 (r220276) +++ stable/7/sys/kern/kern_fork.c Sat Apr 2 10:31:41 2011 (r220277) @@ -613,6 +613,10 @@ again: callout_init(&p2->p_itcallout, CALLOUT_MPSAFE); +#ifdef KTRACE + ktrprocfork(p1, p2); +#endif + /* * If PF_FORK is set, the child process inherits the * procfs ioctl flags from its parent. @@ -657,10 +661,6 @@ again: p2->p_acflag = AFORK; PROC_UNLOCK(p2); -#ifdef KTRACE - ktrprocfork(p1, p2); -#endif - /* * Finish creating the child process. It will return via a different * execution path later. (ie: directly into user mode) Modified: stable/7/sys/kern/kern_ktrace.c ============================================================================== --- stable/7/sys/kern/kern_ktrace.c Sat Apr 2 10:28:08 2011 (r220276) +++ stable/7/sys/kern/kern_ktrace.c Sat Apr 2 10:31:41 2011 (r220277) @@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include @@ -93,7 +92,6 @@ struct ktr_request { struct ktr_header ktr_header; void *ktr_buffer; union { - struct ktr_proc_ctor ktr_proc_ctor; struct ktr_syscall ktr_syscall; struct ktr_sysret ktr_sysret; struct ktr_genio ktr_genio; @@ -114,8 +112,6 @@ static int data_lengths[] = { 0, /* KTR_USER */ 0, /* KTR_STRUCT */ 0, /* KTR_SYSCTL */ - sizeof(struct ktr_proc_ctor), /* KTR_PROCCTOR */ - 0, /* KTR_PROCDTOR */ }; static STAILQ_HEAD(, ktr_request) ktr_free; @@ -136,8 +132,7 @@ static struct sx ktrace_sx; static void ktrace_init(void *dummy); static int sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS); -static u_int ktrace_resize_pool(u_int oldsize, u_int newsize); -static struct ktr_request *ktr_getrequest_entered(struct thread *td, int type); +static u_int ktrace_resize_pool(u_int newsize); static struct ktr_request *ktr_getrequest(int type); static void ktr_submitrequest(struct thread *td, struct ktr_request *req); static void ktr_freeproc(struct proc *p, struct ucred **uc, @@ -148,7 +143,6 @@ static void ktr_writerequest(struct thre static int ktrcanset(struct thread *,struct proc *); static int ktrsetchildren(struct thread *,struct proc *,int,int,struct vnode *); static int ktrops(struct thread *,struct proc *,int,int,struct vnode *); -static void ktrprocctor_entered(struct thread *, struct proc *); /* * ktrace itself generates events, such as context switches, which we do not @@ -204,7 +198,9 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H /* Handle easy read-only case first to avoid warnings from GCC. */ if (!req->newptr) { + mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; + mtx_unlock(&ktrace_mtx); return (SYSCTL_OUT(req, &oldsize, sizeof(u_int))); } @@ -213,8 +209,10 @@ sysctl_kern_ktrace_request_pool(SYSCTL_H return (error); td = curthread; ktrace_enter(td); + mtx_lock(&ktrace_mtx); oldsize = ktr_requestpool; - newsize = ktrace_resize_pool(oldsize, wantsize); + newsize = ktrace_resize_pool(wantsize); + mtx_unlock(&ktrace_mtx); ktrace_exit(td); error = SYSCTL_OUT(req, &oldsize, sizeof(u_int)); if (error) @@ -227,40 +225,38 @@ SYSCTL_PROC(_kern_ktrace, OID_AUTO, requ &ktr_requestpool, 0, sysctl_kern_ktrace_request_pool, "IU", ""); static u_int -ktrace_resize_pool(u_int oldsize, u_int newsize) +ktrace_resize_pool(u_int newsize) { - STAILQ_HEAD(, ktr_request) ktr_new; struct ktr_request *req; int bound; + mtx_assert(&ktrace_mtx, MA_OWNED); print_message = 1; - bound = newsize - oldsize; + bound = newsize - ktr_requestpool; if (bound == 0) return (ktr_requestpool); - if (bound < 0) { - mtx_lock(&ktrace_mtx); + if (bound < 0) /* Shrink pool down to newsize if possible. */ while (bound++ < 0) { req = STAILQ_FIRST(&ktr_free); if (req == NULL) - break; + return (ktr_requestpool); STAILQ_REMOVE_HEAD(&ktr_free, ktr_list); ktr_requestpool--; + mtx_unlock(&ktrace_mtx); free(req, M_KTRACE); + mtx_lock(&ktrace_mtx); } - } else { + else /* Grow pool up to newsize. */ - STAILQ_INIT(&ktr_new); while (bound-- > 0) { + mtx_unlock(&ktrace_mtx); req = malloc(sizeof(struct ktr_request), M_KTRACE, M_WAITOK); - STAILQ_INSERT_HEAD(&ktr_new, req, ktr_list); + mtx_lock(&ktrace_mtx); + STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); + ktr_requestpool++; } - mtx_lock(&ktrace_mtx); - STAILQ_CONCAT(&ktr_free, &ktr_new); - ktr_requestpool += (newsize - oldsize); - } - mtx_unlock(&ktrace_mtx); return (ktr_requestpool); } @@ -269,15 +265,18 @@ CTASSERT(sizeof(((struct ktr_header *)NU (sizeof((struct proc *)NULL)->p_comm)); static struct ktr_request * -ktr_getrequest_entered(struct thread *td, int type) +ktr_getrequest(int type) { struct ktr_request *req; + struct thread *td = curthread; struct proc *p = td->td_proc; int pm; + ktrace_enter(td); /* XXX: In caller instead? */ mtx_lock(&ktrace_mtx); if (!KTRCHECK(td, type)) { mtx_unlock(&ktrace_mtx); + ktrace_exit(td); return (NULL); } req = STAILQ_FIRST(&ktr_free); @@ -303,21 +302,8 @@ ktr_getrequest_entered(struct thread *td mtx_unlock(&ktrace_mtx); if (pm) printf("Out of ktrace request objects.\n"); - } - return (req); -} - -static struct ktr_request * -ktr_getrequest(int type) -{ - struct thread *td = curthread; - struct ktr_request *req; - - ktrace_enter(td); - req = ktr_getrequest_entered(td, type); - if (req == NULL) ktrace_exit(td); - + } return (req); } @@ -334,6 +320,7 @@ ktr_enqueuerequest(struct thread *td, st mtx_lock(&ktrace_mtx); STAILQ_INSERT_TAIL(&td->td_proc->p_ktr, req, ktr_list); mtx_unlock(&ktrace_mtx); + ktrace_exit(td); } /* @@ -383,6 +370,7 @@ ktr_submitrequest(struct thread *td, str ktr_writerequest(td, req); ktr_freerequest(req); sx_xunlock(&ktrace_sx); + ktrace_exit(td); } @@ -500,7 +488,6 @@ ktrprocexec(struct proc *p, struct ucred void ktrprocexit(struct thread *td) { - struct ktr_request *req; struct proc *p; struct ucred *cred; struct vnode *vp; @@ -511,9 +498,6 @@ ktrprocexit(struct thread *td) return; ktrace_enter(td); - req = ktr_getrequest_entered(td, KTR_PROCDTOR); - if (req != NULL) - ktr_enqueuerequest(td, req); sx_xlock(&ktrace_sx); ktr_drain(td); sx_xunlock(&ktrace_sx); @@ -532,36 +516,6 @@ ktrprocexit(struct thread *td) ktrace_exit(td); } -static void -ktrprocctor_entered(struct thread *td, struct proc *p) -{ - struct ktr_proc_ctor *ktp; - struct ktr_request *req; - struct thread *td2; - - ktrace_assert(td); - td2 = FIRST_THREAD_IN_PROC(p); - req = ktr_getrequest_entered(td2, KTR_PROCCTOR); - if (req == NULL) - return; - ktp = &req->ktr_data.ktr_proc_ctor; - ktp->sv_flags = p->p_sysent->sv_flags; - ktr_enqueuerequest(td2, req); -} - -void -ktrprocctor(struct proc *p) -{ - struct thread *td = curthread; - - if ((p->p_traceflag & KTRFAC_MASK) == 0) - return; - - ktrace_enter(td); - ktrprocctor_entered(td, p); - ktrace_exit(td); -} - /* * When a process forks, enable tracing in the new process if needed. */ @@ -569,7 +523,8 @@ void ktrprocfork(struct proc *p1, struct proc *p2) { - PROC_LOCK(p1); + PROC_LOCK_ASSERT(p1, MA_OWNED); + PROC_LOCK_ASSERT(p2, MA_OWNED); mtx_lock(&ktrace_mtx); KASSERT(p2->p_tracevp == NULL, ("new process has a ktrace vnode")); if (p1->p_traceflag & KTRFAC_INHERIT) { @@ -582,9 +537,6 @@ ktrprocfork(struct proc *p1, struct proc } } mtx_unlock(&ktrace_mtx); - PROC_UNLOCK(p1); - - ktrprocctor(p2); } /* @@ -708,7 +660,6 @@ ktrpsig(sig, action, mask, code) sigset_t *mask; int code; { - struct thread *td = curthread; struct ktr_request *req; struct ktr_psig *kp; @@ -720,15 +671,13 @@ ktrpsig(sig, action, mask, code) kp->action = action; kp->mask = *mask; kp->code = code; - ktr_enqueuerequest(td, req); - ktrace_exit(td); + ktr_enqueuerequest(curthread, req); } void ktrcsw(out, user) int out, user; { - struct thread *td = curthread; struct ktr_request *req; struct ktr_csw *kc; @@ -738,8 +687,7 @@ ktrcsw(out, user) kc = &req->ktr_data.ktr_csw; kc->out = out; kc->user = user; - ktr_enqueuerequest(td, req); - ktrace_exit(td); + ktr_enqueuerequest(curthread, req); } void @@ -1015,8 +963,6 @@ ktrops(td, p, ops, facs, vp) ktr_freeproc(p, &tracecred, &tracevp); } mtx_unlock(&ktrace_mtx); - if ((p->p_traceflag & KTRFAC_MASK) != 0) - ktrprocctor_entered(td, p); PROC_UNLOCK(p); if (tracevp != NULL) { int vfslocked; Modified: stable/7/sys/sys/ktrace.h ============================================================================== --- stable/7/sys/sys/ktrace.h Sat Apr 2 10:28:08 2011 (r220276) +++ stable/7/sys/sys/ktrace.h Sat Apr 2 10:31:41 2011 (r220277) @@ -156,7 +156,6 @@ struct ktr_csw { #define KTR_STRUCT 8 struct sockaddr; struct stat; -struct sysentvec; /* * KTR_SYSCTL - name of a sysctl MIB @@ -165,19 +164,6 @@ struct sysentvec; /* record contains null-terminated MIB name */ /* - * KTR_PROCCTOR - trace process creation (multiple ABI support) - */ -#define KTR_PROCCTOR 10 -struct ktr_proc_ctor { - u_int sv_flags; /* struct sysentvec sv_flags copy */ -}; - -/* - * KTR_PROCDTOR - trace process destruction (multiple ABI support) - */ -#define KTR_PROCDTOR 11 - -/* * KTR_DROP - If this bit is set in ktr_type, then at least one event * between the previous record and this record was dropped. */ @@ -196,8 +182,6 @@ struct ktr_proc_ctor { #define KTRFAC_USER (1< Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 493F9106564A; Sat, 2 Apr 2011 11:10:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3C2AB8FC08; Sat, 2 Apr 2011 11:10:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32BAbrP080882; Sat, 2 Apr 2011 11:10:37 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32BAbPn080880; Sat, 2 Apr 2011 11:10:37 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104021110.p32BAbPn080880@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 2 Apr 2011 11:10:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220278 - stable/8/gnu/usr.bin/gdb/libgdb X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 11:10:37 -0000 Author: kib Date: Sat Apr 2 11:10:36 2011 New Revision: 220278 URL: http://svn.freebsd.org/changeset/base/220278 Log: MFC r220043: Print the raw value of si_code, that is esp. useful for undecoded values. Sponsored by: The FreeBSD Foundation Modified: stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c Directory Properties: stable/8/gnu/usr.bin/gdb/ (props changed) stable/8/gnu/usr.bin/gdb/kgdb/ (props changed) Modified: stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c ============================================================================== --- stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c Sat Apr 2 10:31:41 2011 (r220277) +++ stable/8/gnu/usr.bin/gdb/libgdb/fbsd-threads.c Sat Apr 2 11:10:36 2011 (r220278) @@ -1389,9 +1389,10 @@ fbsd_thread_signal_cmd (char *exp, int f code = "UNKNOWN"; break; } - printf_filtered("si_code %s si_pid %d si_uid %d si_status %x si_addr %p\n", - code, ti.ti_siginfo.si_pid, ti.ti_siginfo.si_uid, ti.ti_siginfo.si_status, - ti.ti_siginfo.si_addr); + printf_filtered("si_code %s (%d) si_pid %d si_uid %d si_status %x " + "si_addr %p\n", + code, ti.ti_siginfo.si_code, ti.ti_siginfo.si_pid, ti.ti_siginfo.si_uid, + ti.ti_siginfo.si_status, ti.ti_siginfo.si_addr); } }