[Midnightbsd-cvs] src [10091] trunk/sys/dev: update nve

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun May 27 19:30:53 EDT 2018


Revision: 10091
          http://svnweb.midnightbsd.org/src/?rev=10091
Author:   laffer1
Date:     2018-05-27 19:30:53 -0400 (Sun, 27 May 2018)
Log Message:
-----------
update nve

Modified Paths:
--------------
    trunk/sys/dev/msk/if_msk.c
    trunk/sys/dev/msk/if_mskreg.h
    trunk/sys/dev/mvs/mvs.c
    trunk/sys/dev/mvs/mvs.h
    trunk/sys/dev/mvs/mvs_if.m
    trunk/sys/dev/mvs/mvs_pci.c
    trunk/sys/dev/mvs/mvs_soc.c
    trunk/sys/dev/mwl/if_mwl.c
    trunk/sys/dev/mwl/if_mwl_pci.c
    trunk/sys/dev/mwl/if_mwlioctl.h
    trunk/sys/dev/mwl/if_mwlvar.h
    trunk/sys/dev/mwl/mwldiag.h
    trunk/sys/dev/mwl/mwlhal.c
    trunk/sys/dev/mwl/mwlhal.h
    trunk/sys/dev/mwl/mwlreg.h
    trunk/sys/dev/ncv/ncr53c500.c
    trunk/sys/dev/ncv/ncr53c500_pccard.c
    trunk/sys/dev/ncv/ncr53c500hw.h
    trunk/sys/dev/ncv/ncr53c500hwtab.h
    trunk/sys/dev/ncv/ncr53c500reg.h
    trunk/sys/dev/ncv/ncr53c500var.h
    trunk/sys/dev/nfe/if_nfe.c
    trunk/sys/dev/nfe/if_nfereg.h
    trunk/sys/dev/nfe/if_nfevar.h
    trunk/sys/dev/nge/if_nge.c
    trunk/sys/dev/nge/if_ngereg.h
    trunk/sys/dev/nmdm/nmdm.c
    trunk/sys/dev/nsp/nsp.c
    trunk/sys/dev/nsp/nsp_pccard.c
    trunk/sys/dev/nsp/nspreg.h
    trunk/sys/dev/nsp/nspvar.h
    trunk/sys/dev/nve/if_nve.c
    trunk/sys/dev/nve/if_nvereg.h
    trunk/sys/dev/nvram/nvram.c

Property Changed:
----------------
    trunk/sys/dev/mvs/mvs_if.m

Modified: trunk/sys/dev/msk/if_msk.c
===================================================================
--- trunk/sys/dev/msk/if_msk.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/msk/if_msk.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /******************************************************************************
  *
  * Name   : sky2.c
@@ -99,7 +100,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/msk/if_msk.c 312362 2017-01-18 02:16:17Z yongari $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1626,7 +1627,7 @@
 	callout_init_mtx(&sc_if->msk_tick_ch, &sc_if->msk_softc->msk_mtx, 0);
 	msk_sysctl_node(sc_if);
 
-	if ((error = msk_txrx_dma_alloc(sc_if) != 0))
+	if ((error = msk_txrx_dma_alloc(sc_if)) != 0)
 		goto fail;
 	msk_rx_dma_jalloc(sc_if);
 
@@ -1638,7 +1639,6 @@
 	}
 	ifp->if_softc = sc_if;
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-	ifp->if_mtu = ETHERMTU;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_capabilities = IFCAP_TXCSUM | IFCAP_TSO4;
 	/*
@@ -3536,7 +3536,7 @@
 		 * On PCI Express bus bridges are called root complexes (RC).
 		 * PCI Express errors are recognized by the root complex too,
 		 * which requests the system to handle the problem. After
-		 * error occurence it may be that no access to the adapter
+		 * error occurrence it may be that no access to the adapter
 		 * may be performed any longer.
 		 */
 
@@ -4068,12 +4068,12 @@
 	CSR_WRITE_4(sc, B0_IMSK, sc->msk_intrmask);
 	CSR_READ_4(sc, B0_IMSK);
 
+	ifp->if_drv_flags |= IFF_DRV_RUNNING;
+	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+
 	sc_if->msk_flags &= ~MSK_FLAG_LINK;
 	mii_mediachg(mii);
 
-	ifp->if_drv_flags |= IFF_DRV_RUNNING;
-	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-
 	callout_reset(&sc_if->msk_tick_ch, hz, msk_tick, sc_if);
 }
 

Modified: trunk/sys/dev/msk/if_mskreg.h
===================================================================
--- trunk/sys/dev/msk/if_mskreg.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/msk/if_mskreg.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,9 +1,10 @@
+/* $MidnightBSD$ */
 /******************************************************************************
  *
  * Name:	skgehw.h
  * Project:	Gigabit Ethernet Adapters, Common Modules
- * Version:	$Revision: 1.7 $
- * Date:	$Date: 2013-01-08 03:53:24 $
+ * Version:	$Revision: 2.49 $
+ * Date:	$Date: 2005/01/20 13:01:35 $
  * Purpose:	Defines and Macros for the Gigabit Ethernet Adapter Product Family
  *
  ******************************************************************************/
@@ -93,7 +94,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/*$MidnightBSD$*/
+/*$FreeBSD: stable/10/sys/dev/msk/if_mskreg.h 287839 2015-09-16 00:25:40Z yongari $*/
 
 /*
  * SysKonnect PCI vendor ID
@@ -156,7 +157,7 @@
 #define DEVICEID_DLINK_DGE560SX	0x4002
 #define DEVICEID_DLINK_DGE560T	0x4b00
 
-#define BIT_31		(1 << 31)
+#define BIT_31		(1U << 31)
 #define BIT_30		(1 << 30)
 #define BIT_29		(1 << 29)
 #define BIT_28		(1 << 28)
@@ -2175,13 +2176,8 @@
 #define MSK_ADDR_LO(x)	((uint64_t) (x) & 0xffffffffUL)
 #define MSK_ADDR_HI(x)	((uint64_t) (x) >> 32)
 
-/*
- * At first I guessed 8 bytes, the size of a single descriptor, would be
- * required alignment constraints. But, it seems that Yukon II have 4096
- * bytes boundary alignment constraints.
- */
-#define MSK_RING_ALIGN	4096
-#define	MSK_STAT_ALIGN	4096
+#define	MSK_RING_ALIGN	32768
+#define	MSK_STAT_ALIGN	32768
 
 /* Rx descriptor data structure */
 struct msk_rx_desc {
@@ -2338,7 +2334,7 @@
 #endif
 #define	MSK_RX_BUF_ALIGN	8
 #define MSK_JUMBO_RX_RING_CNT	MSK_RX_RING_CNT
-#define MSK_MAXTXSEGS		32
+#define MSK_MAXTXSEGS		35
 #define	MSK_TSO_MAXSGSIZE	4096
 #define	MSK_TSO_MAXSIZE		(65535 + sizeof(struct ether_vlan_header))
 

Modified: trunk/sys/dev/mvs/mvs.c
===================================================================
--- trunk/sys/dev/mvs/mvs.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mvs/mvs.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/mvs/mvs.c 315813 2017-03-23 06:41:13Z mav $");
 
 #include <sys/param.h>
 #include <sys/module.h>
@@ -107,7 +108,7 @@
 {
 
 	device_set_desc_copy(dev, "Marvell SATA channel");
-	return (0);
+	return (BUS_PROBE_DEFAULT);
 }
 
 static int
@@ -654,9 +655,7 @@
 	struct mvs_channel *ch = device_get_softc(dev);
 
 	mtx_lock(&ch->mtx);
-	xpt_batch_start(ch->sim);
 	mvs_ch_intr(data);
-	xpt_batch_done(ch->sim);
 	mtx_unlock(&ch->mtx);
 }
 
@@ -894,7 +893,7 @@
 		    if (ccb->ataio.dxfer_len > ch->donecount) {
 			/* Set this transfer size according to HW capabilities */
 			ch->transfersize = min(ccb->ataio.dxfer_len - ch->donecount,
-			    ch->curr[ccb->ccb_h.target_id].bytecount);
+			    ch->transfersize);
 			/* If data write command - put them */
 			if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) {
 				if (mvs_wait(dev, ATA_S_DRQ, ATA_S_BUSY, 1000) < 0) {
@@ -1260,19 +1259,9 @@
 		mvs_set_edma_mode(dev, MVS_EDMA_OFF);
 	}
 	if (ch->numpslots == 0 || ch->basic_dma) {
-		void *buf;
-		bus_size_t size;
-
 		slot->state = MVS_SLOT_LOADING;
-		if (ccb->ccb_h.func_code == XPT_ATA_IO) {
-			buf = ccb->ataio.data_ptr;
-			size = ccb->ataio.dxfer_len;
-		} else {
-			buf = ccb->csio.data_ptr;
-			size = ccb->csio.dxfer_len;
-		}
-		bus_dmamap_load(ch->dma.data_tag, slot->dma.data_map,
-		    buf, size, mvs_dmasetprd, slot, 0);
+		bus_dmamap_load_ccb(ch->dma.data_tag, slot->dma.data_map,
+		    ccb, mvs_dmasetprd, slot, 0);
 	} else
 		mvs_legacy_execute_transaction(slot);
 }
@@ -1344,8 +1333,14 @@
 			return;
 		}
 		ch->donecount = 0;
-		ch->transfersize = min(ccb->ataio.dxfer_len,
-		    ch->curr[port].bytecount);
+		if (ccb->ataio.cmd.command == ATA_READ_MUL ||
+		    ccb->ataio.cmd.command == ATA_READ_MUL48 ||
+		    ccb->ataio.cmd.command == ATA_WRITE_MUL ||
+		    ccb->ataio.cmd.command == ATA_WRITE_MUL48) {
+			ch->transfersize = min(ccb->ataio.dxfer_len,
+			    ch->curr[port].bytecount);
+		} else
+			ch->transfersize = min(ccb->ataio.dxfer_len, 512);
 		if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE)
 			ch->fake_busy = 1;
 		/* If data write command - output the data */
@@ -1422,8 +1417,8 @@
 		}
 	}
 	/* Start command execution timeout */
-	callout_reset(&slot->timeout, (int)ccb->ccb_h.timeout * hz / 1000,
-	    (timeout_t*)mvs_timeout, slot);
+	callout_reset_sbt(&slot->timeout, SBT_1MS * ccb->ccb_h.timeout, 0,
+	    (timeout_t*)mvs_timeout, slot, 0);
 }
 
 /* Must be called with channel locked. */
@@ -1536,8 +1531,8 @@
 	ATA_OUTL(ch->r_mem, EDMA_REQQIP,
 	    ch->dma.workrq_bus + MVS_CRQB_OFFSET + (MVS_CRQB_SIZE * ch->out_idx));
 	/* Start command execution timeout */
-	callout_reset(&slot->timeout, (int)ccb->ccb_h.timeout * hz / 1000,
-	    (timeout_t*)mvs_timeout, slot);
+	callout_reset_sbt(&slot->timeout, SBT_1MS * ccb->ccb_h.timeout, 0,
+	    (timeout_t*)mvs_timeout, slot, 0);
 	return;
 }
 
@@ -1574,9 +1569,9 @@
 			continue;
 		if ((ch->toslots & (1 << i)) == 0)
 			continue;
-		callout_reset(&slot->timeout,
-		    (int)slot->ccb->ccb_h.timeout * hz / 2000,
-		    (timeout_t*)mvs_timeout, slot);
+		callout_reset_sbt(&slot->timeout,
+		    SBT_1MS * slot->ccb->ccb_h.timeout / 2, 0,
+		    (timeout_t*)mvs_timeout, slot, 0);
 	}
 }
 
@@ -2418,9 +2413,9 @@
 		cpi->initiator_id = 0;
 		cpi->bus_id = cam_sim_bus(sim);
 		cpi->base_transfer_speed = 150000;
-		strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
-		strncpy(cpi->hba_vid, "Marvell", HBA_IDLEN);
-		strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
+		strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
+		strlcpy(cpi->hba_vid, "Marvell", HBA_IDLEN);
+		strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
 		cpi->unit_number = cam_sim_unit(sim);
 		cpi->transport = XPORT_SATA;
 		cpi->transport_version = XPORT_VERSION_UNSPECIFIED;

Modified: trunk/sys/dev/mvs/mvs.h
===================================================================
--- trunk/sys/dev/mvs/mvs.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mvs/mvs.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/mvs/mvs.h 280276 2015-03-20 08:28:11Z mav $
  */
 
 #include "mvs_if.h"
@@ -141,7 +142,7 @@
 #define EDMA_IE_LINKDATARXERR(x)	((x) << 17)	/* Link Data Recv Err */
 #define EDMA_IE_LINKCTLTXERR(x)		((x) << 21)	/* Link Ctrl Tx Error */
 #define EDMA_IE_LINKDATATXERR(x)	((x) << 26)	/* Link Data Tx Error */
-#define EDMA_IE_TRANSPROTERR		(1 << 31)	/* Transport Proto E */
+#define EDMA_IE_TRANSPROTERR		(1U << 31)	/* Transport Proto E */
 #define EDMA_IE_TRANSIENT		(EDMA_IE_LINKCTLRXERR(0x0b) | \
 					 EDMA_IE_LINKCTLTXERR(0x1f))
 							/* Non-fatal Errors */

Modified: trunk/sys/dev/mvs/mvs_if.m
===================================================================
--- trunk/sys/dev/mvs/mvs_if.m	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mvs/mvs_if.m	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 # Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
 # All rights reserved.
 #
@@ -22,7 +23,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/dev/mvs/mvs_if.m 207536 2010-05-02 19:28:30Z mav $
 
 INTERFACE mvs;
 


Property changes on: trunk/sys/dev/mvs/mvs_if.m
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/dev/mvs/mvs_pci.c
===================================================================
--- trunk/sys/dev/mvs/mvs_pci.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mvs/mvs_pci.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/mvs/mvs_pci.c 281140 2015-04-06 08:23:06Z mav $");
 
 #include <sys/param.h>
 #include <sys/module.h>
@@ -88,7 +89,7 @@
 			snprintf(buf, sizeof(buf), "%s SATA controller",
 			    mvs_ids[i].name);
 			device_set_desc_copy(dev, buf);
-			return (BUS_PROBE_VENDOR);
+			return (BUS_PROBE_DEFAULT);
 		}
 	}
 	return (ENXIO);
@@ -488,6 +489,13 @@
 	return (0);
 }
 
+static bus_dma_tag_t
+mvs_get_dma_tag(device_t bus, device_t child)
+{
+
+	return (bus_get_dma_tag(bus));
+}
+
 static device_method_t mvs_methods[] = {
 	DEVMETHOD(device_probe,     mvs_probe),
 	DEVMETHOD(device_attach,    mvs_attach),
@@ -500,6 +508,7 @@
 	DEVMETHOD(bus_setup_intr,   mvs_setup_intr),
 	DEVMETHOD(bus_teardown_intr,mvs_teardown_intr),
 	DEVMETHOD(bus_child_location_str, mvs_child_location_str),
+	DEVMETHOD(bus_get_dma_tag,  mvs_get_dma_tag),
 	DEVMETHOD(mvs_edma,         mvs_edma),
 	{ 0, 0 }
 };

Modified: trunk/sys/dev/mvs/mvs_soc.c
===================================================================
--- trunk/sys/dev/mvs/mvs_soc.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mvs/mvs_soc.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Alexander Motin <mav at FreeBSD.org>
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/mvs/mvs_soc.c 281140 2015-04-06 08:23:06Z mav $");
 
 #include <sys/param.h>
 #include <sys/module.h>
@@ -63,8 +64,11 @@
 } mvs_ids[] = {
 	{MV_DEV_88F5182, 0x00,   "Marvell 88F5182",	2, MVS_Q_GENIIE|MVS_Q_SOC},
 	{MV_DEV_88F6281, 0x00,   "Marvell 88F6281",	2, MVS_Q_GENIIE|MVS_Q_SOC},
+	{MV_DEV_88F6282, 0x00,   "Marvell 88F6282",	2, MVS_Q_GENIIE|MVS_Q_SOC},
 	{MV_DEV_MV78100, 0x00,   "Marvell MV78100",	2, MVS_Q_GENIIE|MVS_Q_SOC},
 	{MV_DEV_MV78100_Z0, 0x00,"Marvell MV78100",	2, MVS_Q_GENIIE|MVS_Q_SOC},
+	{MV_DEV_MV78260, 0x00,   "Marvell MV78260",	2, MVS_Q_GENIIE|MVS_Q_SOC},
+	{MV_DEV_MV78460, 0x00,   "Marvell MV78460",	2, MVS_Q_GENIIE|MVS_Q_SOC},
 	{0,              0x00,   NULL,			0, 0}
 };
 
@@ -75,6 +79,9 @@
 	int i;
 	uint32_t devid, revid;
 
+	if (!ofw_bus_status_okay(dev))
+		return (ENXIO);
+
 	if (!ofw_bus_is_compatible(dev, "mrvl,sata"))
 		return (ENXIO);
 
@@ -85,7 +92,7 @@
 			snprintf(buf, sizeof(buf), "%s SATA controller",
 			    mvs_ids[i].name);
 			device_set_desc_copy(dev, buf);
-			return (BUS_PROBE_VENDOR);
+			return (BUS_PROBE_DEFAULT);
 		}
 	}
 	return (ENXIO);
@@ -429,6 +436,13 @@
 	return (0);
 }
 
+static bus_dma_tag_t
+mvs_get_dma_tag(device_t bus, device_t child)
+{
+
+	return (bus_get_dma_tag(bus));
+}
+
 static device_method_t mvs_methods[] = {
 	DEVMETHOD(device_probe,     mvs_probe),
 	DEVMETHOD(device_attach,    mvs_attach),
@@ -440,8 +454,9 @@
 	DEVMETHOD(bus_release_resource,     mvs_release_resource),
 	DEVMETHOD(bus_setup_intr,   mvs_setup_intr),
 	DEVMETHOD(bus_teardown_intr,mvs_teardown_intr),
+	DEVMETHOD(bus_child_location_str, mvs_child_location_str),
+	DEVMETHOD(bus_get_dma_tag,  mvs_get_dma_tag),
 	DEVMETHOD(mvs_edma,         mvs_edma),
-	DEVMETHOD(bus_child_location_str, mvs_child_location_str),
 	{ 0, 0 }
 };
 static driver_t mvs_driver = {

Modified: trunk/sys/dev/mwl/if_mwl.c
===================================================================
--- trunk/sys/dev/mwl/if_mwl.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mwl/if_mwl.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
  * Copyright (c) 2007-2008 Marvell Semiconductor, Inc.
@@ -29,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/mwl/if_mwl.c 314667 2017-03-04 13:03:31Z avg $");
 
 /*
  * Driver for the Marvell 88W8363 Wireless LAN controller.
@@ -37,6 +38,7 @@
 
 #include "opt_inet.h"
 #include "opt_mwl.h"
+#include "opt_wlan.h"
 
 #include <sys/param.h>
 #include <sys/systm.h> 
@@ -280,11 +282,13 @@
  * that all BAR 1 operations are done in the "hal" and
  * there should be no reference to them here.
  */
+#ifdef MWL_DEBUG
 static __inline uint32_t
 RD4(struct mwl_softc *sc, bus_size_t off)
 {
 	return bus_space_read_4(sc->sc_io0t, sc->sc_io0h, off);
 }
+#endif
 
 static __inline void
 WR4(struct mwl_softc *sc, bus_size_t off, uint32_t val)
@@ -309,6 +313,12 @@
 	}
 	ic = ifp->if_l2com;
 
+	/*
+	 * Setup the RX free list lock early, so it can be consistently
+	 * removed.
+	 */
+	MWL_RXFREE_INIT(sc);
+
 	/* set these up early for if_printf use */
 	if_initname(ifp, device_get_name(sc->sc_dev),
 		device_get_unit(sc->sc_dev));
@@ -359,7 +369,7 @@
 	if (error != 0)			/* NB: mwl_setupdma prints msg */
 		goto bad1;
 
-	callout_init(&sc->sc_timer, CALLOUT_MPSAFE);
+	callout_init(&sc->sc_timer, 1);
 	callout_init_mtx(&sc->sc_watchdog, &sc->sc_mtx, 0);
 
 	sc->sc_tq = taskqueue_create("mwl_taskq", M_NOWAIT,
@@ -530,6 +540,7 @@
 bad1:
 	mwl_hal_detach(mh);
 bad:
+	MWL_RXFREE_DESTROY(sc);
 	if_free(ifp);
 	sc->sc_invalid = 1;
 	return error;
@@ -560,6 +571,7 @@
 	ieee80211_ifdetach(ic);
 	callout_drain(&sc->sc_watchdog);
 	mwl_dma_cleanup(sc);
+	MWL_RXFREE_DESTROY(sc);
 	mwl_tx_cleanup(sc);
 	mwl_hal_detach(sc->sc_mh);
 	if_free(ifp);
@@ -2057,9 +2069,10 @@
 
 	ds = dd->dd_desc;
 	memset(ds, 0, dd->dd_desc_len);
-	DPRINTF(sc, MWL_DEBUG_RESET, "%s: %s DMA map: %p (%lu) -> %p (%lu)\n",
+	DPRINTF(sc, MWL_DEBUG_RESET,
+	    "%s: %s DMA map: %p (%lu) -> 0x%jx (%lu)\n",
 	    __func__, dd->dd_name, ds, (u_long) dd->dd_desc_len,
-	    (caddr_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len);
+	    (uintmax_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len);
 
 	return 0;
 fail2:
@@ -2273,7 +2286,6 @@
 		SLIST_INSERT_HEAD(&sc->sc_rxfree, rbuf, next);
 		sc->sc_nrxfree++;
 	}
-	MWL_RXFREE_INIT(sc);
 	return 0;
 }
 #undef DS2PHYS
@@ -2297,7 +2309,6 @@
 	}
 	if (sc->sc_rxdma.dd_desc_len != 0)
 		mwl_desc_cleanup(sc, &sc->sc_rxdma);
-	MWL_RXFREE_DESTROY(sc);
 }
 
 static int
@@ -2614,8 +2625,8 @@
 	return 0;
 }
 
-static void
-mwl_ext_free(void *data, void *arg)
+static int
+mwl_ext_free(struct mbuf *m, void *data, void *arg)
 {
 	struct mwl_softc *sc = arg;
 
@@ -2630,6 +2641,7 @@
 		sc->sc_rxblocked = 0;
 		mwl_hal_intrset(sc->sc_mh, sc->sc_imask);
 	}
+	return (EXT_FREE_OK);
 }
 
 struct mwl_frame_bar {
@@ -2875,12 +2887,13 @@
 		 * upper layer to put a station in power save
 		 * (except when configured with MWL_HOST_PS_SUPPORT).
 		 */
-		if (wh->i_fc[1] & IEEE80211_FC1_WEP)
+		if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED)
 			m->m_flags |= M_WEP;
 #ifdef MWL_HOST_PS_SUPPORT
-		wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
+		wh->i_fc[1] &= ~IEEE80211_FC1_PROTECTED;
 #else
-		wh->i_fc[1] &= ~(IEEE80211_FC1_WEP | IEEE80211_FC1_PWR_MGT);
+		wh->i_fc[1] &= ~(IEEE80211_FC1_PROTECTED |
+		    IEEE80211_FC1_PWR_MGT);
 #endif
 
 		if (ieee80211_radiotap_active(ic)) {
@@ -3194,7 +3207,7 @@
 #endif
 
 	wh = mtod(m0, struct ieee80211_frame *);
-	iswep = wh->i_fc[1] & IEEE80211_FC1_WEP;
+	iswep = wh->i_fc[1] & IEEE80211_FC1_PROTECTED;
 	ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
 	hdrlen = ieee80211_anyhdrsize(wh);
 	copyhdrlen = hdrlen;
@@ -3739,7 +3752,7 @@
 		/* NB: no held reference to ni */
 		sp = mwl_hal_bastream_alloc(MWL_VAP(vap)->mv_hvap,
 		    (baparamset & IEEE80211_BAPS_POLICY_IMMEDIATE) != 0,
-		    ni->ni_macaddr, WME_AC_TO_TID(tap->txa_ac), ni->ni_htparam,
+		    ni->ni_macaddr, tap->txa_tid, ni->ni_htparam,
 		    ni, tap);
 		if (sp == NULL) {
 			/*
@@ -3776,8 +3789,8 @@
 	if (bas == NULL) {
 		/* XXX should not happen */
 		DPRINTF(sc, MWL_DEBUG_AMPDU,
-		    "%s: no BA stream allocated, AC %d\n",
-		    __func__, tap->txa_ac);
+		    "%s: no BA stream allocated, TID %d\n",
+		    __func__, tap->txa_tid);
 		sc->sc_stats.mst_addba_nostream++;
 		return 0;
 	}
@@ -3805,18 +3818,18 @@
 			tap->txa_private = NULL;
 
 			DPRINTF(sc, MWL_DEBUG_AMPDU,
-			    "%s: create failed, error %d, bufsiz %d AC %d "
+			    "%s: create failed, error %d, bufsiz %d TID %d "
 			    "htparam 0x%x\n", __func__, error, bufsiz,
-			    tap->txa_ac, ni->ni_htparam);
+			    tap->txa_tid, ni->ni_htparam);
 			sc->sc_stats.mst_bacreate_failed++;
 			return 0;
 		}
 		/* NB: cache txq to avoid ptr indirect */
-		mwl_bastream_setup(bas, tap->txa_ac, bas->bastream->txq);
+		mwl_bastream_setup(bas, tap->txa_tid, bas->bastream->txq);
 		DPRINTF(sc, MWL_DEBUG_AMPDU,
-		    "%s: bastream %p assigned to txq %d AC %d bufsiz %d "
+		    "%s: bastream %p assigned to txq %d TID %d bufsiz %d "
 		    "htparam 0x%x\n", __func__, bas->bastream,
-		    bas->txq, tap->txa_ac, bufsiz, ni->ni_htparam);
+		    bas->txq, tap->txa_tid, bufsiz, ni->ni_htparam);
 	} else {
 		/*
 		 * Other side NAK'd us; return the resources.
@@ -4696,11 +4709,10 @@
 	const struct mwl_rxdesc *ds = bf->bf_desc;
 	uint32_t status = le32toh(ds->Status);
 
-	printf("R[%2u] (DS.V:%p DS.P:%p) NEXT:%08x DATA:%08x RC:%02x%s\n"
+	printf("R[%2u] (DS.V:%p DS.P:0x%jx) NEXT:%08x DATA:%08x RC:%02x%s\n"
 	       "      STAT:%02x LEN:%04x RSSI:%02x CHAN:%02x RATE:%02x QOS:%04x HT:%04x\n",
-	    ix, ds, (const struct mwl_desc *)bf->bf_daddr,
-	    le32toh(ds->pPhysNext), le32toh(ds->pPhysBuffData),
-	    ds->RxControl, 
+	    ix, ds, (uintmax_t)bf->bf_daddr, le32toh(ds->pPhysNext),
+	    le32toh(ds->pPhysBuffData), ds->RxControl, 
 	    ds->RxControl != EAGLE_RXD_CTRL_DRIVER_OWN ?
 	        "" : (status & EAGLE_RXD_STATUS_OK) ? " *" : " !",
 	    ds->Status, le16toh(ds->PktLen), ds->RSSI, ds->Channel,
@@ -4714,8 +4726,7 @@
 	uint32_t status = le32toh(ds->Status);
 
 	printf("Q%u[%3u]", qnum, ix);
-	printf(" (DS.V:%p DS.P:%p)\n",
-	    ds, (const struct mwl_txdesc *)bf->bf_daddr);
+	printf(" (DS.V:%p DS.P:0x%jx)\n", ds, (uintmax_t)bf->bf_daddr);
 	printf("    NEXT:%08x DATA:%08x LEN:%04x STAT:%08x%s\n",
 	    le32toh(ds->pPhysNext),
 	    le32toh(ds->PktPtr), le16toh(ds->PktLen), status,

Modified: trunk/sys/dev/mwl/if_mwl_pci.c
===================================================================
--- trunk/sys/dev/mwl/if_mwl_pci.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mwl/if_mwl_pci.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
  * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
@@ -30,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __FreeBSD__
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/mwl/if_mwl_pci.c 278415 2015-02-08 22:27:17Z marius $");
 #endif
 
 /*
@@ -120,29 +121,6 @@
 	return ENXIO;
 }
 
-static u_int32_t
-mwl_pci_setup(device_t dev)
-{
-	u_int32_t cmd;
-
-	/*
-	 * Enable memory mapping and bus mastering.
-	 */
-	cmd = pci_read_config(dev, PCIR_COMMAND, 4);
-	cmd |= PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN;
-	pci_write_config(dev, PCIR_COMMAND, cmd, 4);
-	cmd = pci_read_config(dev, PCIR_COMMAND, 4);
-	if ((cmd & PCIM_CMD_MEMEN) == 0) {
-		device_printf(dev, "failed to enable memory mapping\n");
-		return 0;
-	}
-	if ((cmd & PCIM_CMD_BUSMASTEREN) == 0) {
-		device_printf(dev, "failed to enable bus mastering\n");
-		return 0;
-	}
-	return 1;
-}
-
 static int
 mwl_pci_attach(device_t dev)
 {
@@ -152,11 +130,8 @@
 
 	sc->sc_dev = dev;
 
-	/*
-	 * Enable memory mapping and bus mastering.
-	 */
-	if (!mwl_pci_setup(dev))
-		return 0;
+	pci_enable_busmaster(dev);
+
 	/* 
 	 * Setup memory-mapping of PCI registers.
 	 */
@@ -201,9 +176,9 @@
 			       BUS_SPACE_MAXADDR_32BIT,	/* lowaddr */
 			       BUS_SPACE_MAXADDR,	/* highaddr */
 			       NULL, NULL,		/* filter, filterarg */
-			       BUS_SPACE_MAXADDR,	/* maxsize */
+			       BUS_SPACE_MAXSIZE,	/* maxsize */
 			       MWL_TXDESC,		/* nsegments */
-			       BUS_SPACE_MAXADDR,	/* maxsegsize */
+			       BUS_SPACE_MAXSIZE,	/* maxsegsize */
 			       0,			/* flags */
 			       NULL,			/* lockfunc */
 			       NULL,			/* lockarg */
@@ -285,8 +260,7 @@
 {
 	struct mwl_pci_softc *psc = device_get_softc(dev);
 
-	if (!mwl_pci_setup(dev))
-		return ENXIO;
+	pci_enable_busmaster(dev);
 
 	mwl_resume(&psc->sc_sc);
 

Modified: trunk/sys/dev/mwl/if_mwlioctl.h
===================================================================
--- trunk/sys/dev/mwl/if_mwlioctl.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mwl/if_mwlioctl.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
  * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
@@ -27,7 +28,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/mwl/if_mwlioctl.h 193240 2009-06-01 18:07:01Z sam $
  */
 
 /*

Modified: trunk/sys/dev/mwl/if_mwlvar.h
===================================================================
--- trunk/sys/dev/mwl/if_mwlvar.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mwl/if_mwlvar.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
  * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
@@ -27,7 +28,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/mwl/if_mwlvar.h 234324 2012-04-15 20:29:39Z adrian $
  */
 
 /*
@@ -187,10 +188,10 @@
 };
 
 static __inline__ void
-mwl_bastream_setup(struct mwl_bastate *bas, int ac, int txq)
+mwl_bastream_setup(struct mwl_bastate *bas, int tid, int txq)
 {
 	bas->txq = txq;
-	bas->qos = htole16(WME_AC_TO_TID(ac) | IEEE80211_QOS_ACKPOLICY_BA);
+	bas->qos = htole16(tid | IEEE80211_QOS_ACKPOLICY_BA);
 }
 
 static __inline__ void

Modified: trunk/sys/dev/mwl/mwldiag.h
===================================================================
--- trunk/sys/dev/mwl/mwldiag.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mwl/mwldiag.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
  * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
@@ -27,7 +28,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/mwl/mwldiag.h 193240 2009-06-01 18:07:01Z sam $
  */
 
 #ifndef _MWL_DIAG_H_

Modified: trunk/sys/dev/mwl/mwlhal.c
===================================================================
--- trunk/sys/dev/mwl/mwlhal.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mwl/mwlhal.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
  * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
@@ -27,7 +28,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/mwl/mwlhal.c 227309 2011-11-07 15:43:11Z ed $
  */
 
 #include <sys/param.h>

Modified: trunk/sys/dev/mwl/mwlhal.h
===================================================================
--- trunk/sys/dev/mwl/mwlhal.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mwl/mwlhal.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
  * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
@@ -27,7 +28,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/mwl/mwlhal.h 218909 2011-02-21 09:01:34Z brucec $
  */
 
 #ifndef _MWL_HAL_H_

Modified: trunk/sys/dev/mwl/mwlreg.h
===================================================================
--- trunk/sys/dev/mwl/mwlreg.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/mwl/mwlreg.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
  * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
@@ -27,7 +28,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGES.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/mwl/mwlreg.h 195171 2009-06-29 18:42:54Z sam $
  */
 
 /*

Modified: trunk/sys/dev/ncv/ncr53c500.c
===================================================================
--- trunk/sys/dev/ncv/ncr53c500.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/ncv/ncr53c500.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$NecBSD: ncr53c500.c,v 1.30.12.3 2001/06/26 07:31:41 honda Exp $	*/
 /*	$NetBSD$	*/
 
@@ -37,47 +38,21 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ncv/ncr53c500.c 240325 2012-09-10 18:49:49Z jhb $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500001
 #include <sys/bio.h>
-#endif	/* __FreeBSD__ */
 #include <sys/buf.h>
 #include <sys/queue.h>
 #include <sys/malloc.h>
 #include <sys/errno.h>
 
-#ifdef __NetBSD__
-#include <sys/device.h>
-#include <machine/bus.h>
-#include <machine/intr.h>
-
-#include <dev/scsipi/scsi_all.h>
-#include <dev/scsipi/scsipi_all.h>
-#include <dev/scsipi/scsiconf.h>
-#include <dev/scsipi/scsi_disk.h>
-
-#include <machine/dvcfg.h>
-#include <machine/physio_proc.h>
-
-#include <i386/Cbus/dev/scsi_low.h>
-
-#include <i386/Cbus/dev/ncr53c500reg.h>
-#include <i386/Cbus/dev/ncr53c500hw.h>
-#include <i386/Cbus/dev/ncr53c500var.h>
-
-#include <i386/Cbus/dev/ncr53c500hwtab.h>
-#endif /* __NetBSD__ */
-
-#ifdef __FreeBSD__
 #include <machine/cpu.h>
 #include <machine/bus.h>
 
 #include <compat/netbsd/dvcfg.h>
-#include <compat/netbsd/physio_proc.h>
 
 #include <cam/scsi/scsi_low.h>
 
@@ -86,7 +61,6 @@
 #include <dev/ncv/ncr53c500var.h>
 
 #include <dev/ncv/ncr53c500hwtab.h>
-#endif /* __FreeBSD__ */
 
 #define	NCV_MAX_DATA_SIZE	(64 * 1024)
 #define	NCV_DELAY_MAX		(2 * 1000 * 1000)
@@ -274,12 +248,12 @@
 	bus_space_write_1(iot, ioh, cr0_cmd, CMD_FLUSH);
 	bus_space_write_1(iot, ioh, cr0_cmd, CMD_RSTSCSI);
 	bus_space_write_1(iot, ioh, cr0_cmd, CMD_NOP | CMD_DMA);
-	SCSI_LOW_DELAY(100 * 1000);
+	DELAY(100 * 1000);
 
 	/* check response */
 	bus_space_read_1(iot, ioh, cr0_stat);
 	stat = bus_space_read_1(iot, ioh, cr0_istat);
-	SCSI_LOW_DELAY(1000);
+	DELAY(1000);
 
 	if (((stat & INTR_SBR) == 0) ||
 	    (bus_space_read_1(iot, ioh, cr0_istat) & INTR_SBR))
@@ -352,7 +326,7 @@
 
 	if (flags == SCSI_LOW_POWDOWN)
 	{
-		printf("%s power down\n", slp->sl_xname);
+		device_printf(slp->sl_dev, "power down\n");
 		ncvhw_select_register_1(iot, ioh, &sc->sc_hw);
 		bus_space_write_1(iot, ioh, cr1_atacmd, ATACMD_POWDOWN);
 	}
@@ -361,13 +335,13 @@
 		switch (sc->sc_rstep)
 		{
 		case 0:
-			printf("%s resume step O\n", slp->sl_xname);
+			device_printf(slp->sl_dev, "resume step O\n");
 			ncvhw_select_register_1(iot, ioh, &sc->sc_hw);
 			bus_space_write_1(iot, ioh, cr1_atacmd, ATACMD_ENGAGE);
 			break;
 
 		case 1:
-			printf("%s resume step I\n", slp->sl_xname);
+			device_printf(slp->sl_dev, "resume step I\n");
 			ncvhw_reset(iot, ioh, &sc->sc_hw);
 			ncvhw_init(iot, ioh, &sc->sc_hw);
 			break;
@@ -387,7 +361,7 @@
 {
 
 	bus_space_write_1(sc->sc_iot, sc->sc_ioh, cr0_cmd, CMD_SETATN);
-	SCSI_LOW_DELAY(10);
+	DELAY(10);
 }
 
 static void
@@ -493,13 +467,12 @@
 	ncvhw_select_register_0(iot, ioh, &sc->sc_hw);
 	bus_space_read_1(sc->sc_iot, sc->sc_ioh, cr0_stat);
 	stat = bus_space_read_1(sc->sc_iot, sc->sc_ioh, cr0_istat);
-	SCSI_LOW_DELAY(1000);
+	DELAY(1000);
 
 	if (((stat & INTR_SBR) == 0) ||
 	    (bus_space_read_1(sc->sc_iot, sc->sc_ioh, cr0_istat) & INTR_SBR))
 		return ENODEV;
 
-	SOFT_INTR_REQUIRED(slp);
 	return 0;
 }
 
@@ -633,17 +606,6 @@
 	return 1;
 }
 
-int
-ncvprint(aux, name)
-	void *aux;
-	const char *name;
-{
-
-	if (name != NULL)
-		printf("%s: scsibus ", name);
-	return UNCONF;
-}
-
 void
 ncvattachsubr(sc)
 	struct ncv_softc *sc;
@@ -722,9 +684,9 @@
 bad:
 			if ((slp->sl_error & PDMAERR) == 0)
 			{
-				printf("%s: stragne cnt hw 0x%x soft 0x%x\n",
-					slp->sl_xname, len,
-					slp->sl_scp.scp_datalen);
+				device_printf(slp->sl_dev,
+				    "strange cnt hw 0x%x soft 0x%x\n", len,
+				    slp->sl_scp.scp_datalen);
 			}
 			slp->sl_error |= PDMAERR;
 		}
@@ -732,7 +694,7 @@
 	}
 	else
 	{
-		printf("%s: data phase miss\n", slp->sl_xname);
+		device_printf(slp->sl_dev, "data phase miss\n");
 		slp->sl_error |= PDMAERR;
 	}
 
@@ -782,7 +744,7 @@
 			if (fstat & FIFO_BRK)
 				break;
 
-			SCSI_LOW_DELAY(1);
+			DELAY(1);
 		}
 	}
 
@@ -799,7 +761,7 @@
 			 if (fstat & FIFO_BRK)
 				break;
 
-			SCSI_LOW_DELAY(1);
+			DELAY(1);
 		}
 	}
 
@@ -845,7 +807,7 @@
 		}
 		else
 		{
-			SCSI_LOW_DELAY(1);
+			DELAY(1);
 		}
 	}
 
@@ -862,7 +824,7 @@
 		}
 		else
 		{
-			SCSI_LOW_DELAY(1);
+			DELAY(1);
 		}
 	}
 
@@ -885,7 +847,7 @@
 
 	if ((bus_space_read_1(iot, ioh, cr0_sffl) & CR0_SFFLR_BMASK) != 2)
 	{
-		printf("%s illegal fifo bytes\n", slp->sl_xname);
+		device_printf(slp->sl_dev, "illegal fifo bytes\n");
 		scsi_low_restart(slp, SCSI_LOW_RESTART_HARD, "chip confused");
 		return EJUSTRETURN;
 	}
@@ -977,7 +939,7 @@
 		if ((status & STAT_INT) != 0)
 			return 0;
 
-		SCSI_LOW_DELAY(NCV_DELAY_INTERVAL);
+		DELAY(NCV_DELAY_INTERVAL);
 	}
 	return EJUSTRETURN;
 }
@@ -991,7 +953,6 @@
 	bus_space_tag_t iot = sc->sc_iot;
 	bus_space_handle_t ioh = sc->sc_ioh;
 	struct targ_info *ti;
-	struct physio_proc *pp;
 	struct buf *bp;
 	u_int derror, flags;
 	int len;
@@ -1031,11 +992,11 @@
 	if (ncv_debug)
 	{
 		scsi_low_print(slp, NULL);
-		printf("%s st %x ist %x\n\n", slp->sl_xname,
+		device_printf(slp->sl_dev, "st %x ist %x\n\n",
 			status, ireason);
 #ifdef	KDB
 		if (ncv_debug > 1)
-			SCSI_LOW_DEBUGGER("ncv");
+			kdb_enter(KDB_WHY_CAM, "ncv");
 #endif	/* KDB */
 	}
 #endif	/* NCV_DEBUG */
@@ -1113,8 +1074,8 @@
 		ncv_target_nexus_establish(sc);
 		if ((status & PHASE_MASK) != MESSAGE_IN_PHASE)
 		{
-			printf("%s: unexpected phase after reselect\n",
-				slp->sl_xname);
+			device_printf(slp->sl_dev,
+			    "unexpected phase after reselect\n");
 			slp->sl_error |= FATALIO;
 			scsi_low_assert_msg(slp, ti, SCSI_LOW_MSG_ABORT, 1);
 			return 1;
@@ -1141,7 +1102,6 @@
 			scsi_low_attention(slp);
 		}
 
-		pp = physio_proc_enter(bp);
 		if (slp->sl_scp.scp_datalen <= 0)
 		{
 			if ((ireason & INTR_BS) == 0)
@@ -1148,7 +1108,7 @@
 				break;
 
 			if ((slp->sl_error & PDMAERR) == 0)
-				printf("%s: data underrun\n", slp->sl_xname);
+				device_printf(slp->sl_dev, "data underrun\n");
 			slp->sl_error |= PDMAERR;
 
 			if ((slp->sl_flags & HW_WRITE_PADDING) != 0)
@@ -1155,13 +1115,13 @@
 			{
 				u_int8_t padding[NCV_PADDING_SIZE];
 
-				SCSI_LOW_BZERO(padding, sizeof(padding));
+				bzero(padding, sizeof(padding));
 				ncv_pio_write(sc, padding, sizeof(padding));
 			}
 			else
 			{
-				printf("%s: write padding required\n",
-					slp->sl_xname);
+				device_printf(slp->sl_dev,
+				    "write padding required\n");
 			}
 		}
 		else
@@ -1174,7 +1134,6 @@
 			}
 			ncv_pio_write(sc, slp->sl_scp.scp_data, len);
 		}
-		physio_proc_leave(pp);
 		break;
 
 	case DATA_IN_PHASE: /* data in */
@@ -1184,7 +1143,6 @@
 			scsi_low_attention(slp);
 		}
 
-		pp = physio_proc_enter(bp);
 		if (slp->sl_scp.scp_datalen <= 0)
 		{
 			if ((ireason & INTR_BS) == 0)
@@ -1191,7 +1149,7 @@
 				break;
 
 			if ((slp->sl_error & PDMAERR) == 0)
-				printf("%s: data overrun\n", slp->sl_xname);
+				device_printf(slp->sl_dev, "data overrun\n");
 			slp->sl_error |= PDMAERR;
 
 			if ((slp->sl_flags & HW_READ_PADDING) != 0)
@@ -1202,8 +1160,8 @@
 			}
 			else
 			{
-				printf("%s: read padding required\n",
-					slp->sl_xname);
+				device_printf(slp->sl_dev,
+				    "read padding required\n");
 				break;
 			}
 		}
@@ -1217,7 +1175,6 @@
 			}
 			ncv_pio_read(sc, slp->sl_scp.scp_data, len);
 		}
-		physio_proc_leave(pp);
 		break;
 
 	case COMMAND_PHASE: /* cmd out */

Modified: trunk/sys/dev/ncv/ncr53c500_pccard.c
===================================================================
--- trunk/sys/dev/ncv/ncr53c500_pccard.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/ncv/ncr53c500_pccard.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$NecBSD: ncr53c500_pisa.c,v 1.28 1998/11/26 01:59:11 honda Exp $	*/
 /*	$NetBSD$	*/
 
@@ -37,12 +38,13 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/ncv/ncr53c500_pccard.c 240325 2012-09-10 18:49:49Z jhb $");
 
 #include <sys/param.h>
 #include <sys/errno.h>
 #include <sys/kernel.h>
 #include <sys/malloc.h>
+#include <sys/module.h>
 #include <sys/systm.h>
 
 #include <machine/bus.h>
@@ -50,12 +52,11 @@
 #include <sys/rman.h>
 #include <compat/netbsd/dvcfg.h>
 
-#include <sys/device_port.h>
+#include <sys/bus.h>
 
 #include <dev/pccard/pccardvar.h>
 
 #include <cam/scsi/scsi_low.h>
-#include <cam/scsi/scsi_low_pisa.h>
 
 #include <dev/ncv/ncr53c500reg.h>
 #include <dev/ncv/ncr53c500hw.h>
@@ -67,10 +68,10 @@
 
 #include "pccarddevs.h"
 
-static int ncvprobe(DEVPORT_PDEVICE devi);
-static int ncvattach(DEVPORT_PDEVICE devi);
+static int ncvprobe(device_t devi);
+static int ncvattach(device_t devi);
 
-static void	ncv_card_unload(DEVPORT_PDEVICE);
+static void	ncv_card_unload(device_t);
 
 static const struct ncv_product {
 	struct pccard_product	prod;
@@ -102,7 +103,7 @@
 }
 
 static void
-ncv_release_resource(DEVPORT_PDEVICE dev)
+ncv_release_resource(device_t dev)
 {
 	struct ncv_softc	*sc = device_get_softc(dev);
 
@@ -132,10 +133,10 @@
 }
 
 static int
-ncv_alloc_resource(DEVPORT_PDEVICE dev)
+ncv_alloc_resource(device_t dev)
 {
 	struct ncv_softc	*sc = device_get_softc(dev);
-	u_int32_t		flags = DEVPORT_PDEVFLAGS(dev);
+	u_int32_t		flags = device_get_flags(dev);
 	u_long			ioaddr, iosize, maddr, msize;
 	int			error;
 	bus_addr_t		offset = 0;
@@ -290,9 +291,9 @@
 DRIVER_MODULE(ncv, pccard, ncv_pccard_driver, ncv_devclass, 0, 0);
 
 static void
-ncv_card_unload(DEVPORT_PDEVICE devi)
+ncv_card_unload(device_t devi)
 {
-	struct ncv_softc *sc = DEVPORT_PDEVGET_SOFTC(devi);
+	struct ncv_softc *sc = device_get_softc(devi);
 	intrmask_t s;
 
 	s = splcam();
@@ -302,11 +303,11 @@
 }
 
 static int
-ncvprobe(DEVPORT_PDEVICE devi)
+ncvprobe(device_t devi)
 {
 	int rv;
 	struct ncv_softc *sc = device_get_softc(devi);
-	u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
+	u_int32_t flags = device_get_flags(devi);
 
 	rv = ncvprobesubr(rman_get_bustag(sc->port_res),
 			  rman_get_bushandle(sc->port_res),
@@ -316,17 +317,17 @@
 }
 
 static int
-ncvattach(DEVPORT_PDEVICE devi)
+ncvattach(device_t devi)
 {
 	struct ncv_softc *sc;
 	struct scsi_low_softc *slp;
-	u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
+	u_int32_t flags = device_get_flags(devi);
 	intrmask_t s;
 	char dvname[16]; /* SCSI_LOW_DVNAME_LEN */
 
 	strcpy(dvname, "ncv");
 
-	sc = DEVPORT_PDEVALLOC_SOFTC(devi);
+	sc = device_get_softc(devi);
 	if (sc == NULL) {
 		return(0);
 	}

Modified: trunk/sys/dev/ncv/ncr53c500hw.h
===================================================================
--- trunk/sys/dev/ncv/ncr53c500hw.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/ncv/ncr53c500hw.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/ncv/ncr53c500hw.h 240325 2012-09-10 18:49:49Z jhb $	*/
 /*	$NecBSD: ncr53c500hw.h,v 1.6.18.1 2001/06/08 06:27:44 honda Exp $	*/
 /*	$NetBSD$	*/
 
@@ -36,8 +37,6 @@
 #ifndef	__NCR53C500HW_H_
 #define	__NCR53C500HW_H_
 
-#include <compat/netbsd/dvcfg.h>
-
 #define	NCV_HOSTID	7
 #define	NCV_NTARGETS	8
 #define	NCV_NLUNS	8

Modified: trunk/sys/dev/ncv/ncr53c500hwtab.h
===================================================================
--- trunk/sys/dev/ncv/ncr53c500hwtab.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/ncv/ncr53c500hwtab.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/ncv/ncr53c500hwtab.h 139749 2005-01-06 01:43:34Z imp $	*/
 /*	$NecBSD: ncr53c500hwtab.h,v 1.2.18.1 2001/06/08 06:27:44 honda Exp $	*/
 /*	$NetBSD$	*/
 

Modified: trunk/sys/dev/ncv/ncr53c500reg.h
===================================================================
--- trunk/sys/dev/ncv/ncr53c500reg.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/ncv/ncr53c500reg.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/ncv/ncr53c500reg.h 139749 2005-01-06 01:43:34Z imp $	*/
 /*	$NecBSD: ncr53c500reg.h,v 1.5.14.1 2001/06/08 06:27:44 honda Exp $	*/
 /*	$NetBSD$	*/
 

Modified: trunk/sys/dev/ncv/ncr53c500var.h
===================================================================
--- trunk/sys/dev/ncv/ncr53c500var.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/ncv/ncr53c500var.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/ncv/ncr53c500var.h 240325 2012-09-10 18:49:49Z jhb $	*/
 /*	$NecBSD: ncr53c500var.h,v 1.11.18.1 2001/06/08 06:27:45 honda Exp $	*/
 /*	$NetBSD$	*/
 
@@ -42,19 +43,10 @@
 struct ncv_softc {
 	struct scsi_low_softc sc_sclow;		/* generic data */
 
-#ifdef	__NetBSD__
 	bus_space_tag_t sc_iot;
 	bus_space_tag_t sc_memt;
 	bus_space_handle_t sc_ioh;
 
-	void *sc_ih;
-#endif	/* __NetBSD__ */
-
-#ifdef	__FreeBSD__
-	bus_space_tag_t sc_iot;
-	bus_space_tag_t sc_memt;
-	bus_space_handle_t sc_ioh;
-
 	int port_rid;
 	int port_rid_dmy;
 	int irq_rid;
@@ -65,7 +57,6 @@
 	struct resource *mem_res;
 
 	void *ncv_intrhand;
-#endif	/* __FreeBSD__ */
 
 	int sc_tmaxcnt;
 	int sc_selstop;			/* sel atn stop asserted */
@@ -92,12 +83,6 @@
  *****************************************************************/
 int ncvprobesubr(bus_space_tag_t, bus_space_handle_t ioh, u_int, int);
 void ncvattachsubr(struct ncv_softc *);
-int ncvprint(void *, const char *);
 int ncvintr(void *);
 
-#if	defined(__i386__) && 0
-#define	SOFT_INTR_REQUIRED(slp)	(softintr((slp)->sl_irq))
-#else	/* !__i386__ */
-#define	SOFT_INTR_REQUIRED(slp)
-#endif	/* !__i386__ */
 #endif	/* !_NCR53C500VAR_H_ */

Modified: trunk/sys/dev/nfe/if_nfe.c
===================================================================
--- trunk/sys/dev/nfe/if_nfe.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nfe/if_nfe.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$OpenBSD: if_nfe.c,v 1.54 2006/04/07 12:38:12 jsg Exp $	*/
 
 /*-
@@ -21,6 +22,7 @@
 /* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */
 
 #include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/dev/nfe/if_nfe.c 266921 2014-05-31 11:08:22Z brueffer $");
 
 #ifdef HAVE_KERNEL_OPTION_HEADERS
 #include "opt_device_polling.h"
@@ -77,6 +79,7 @@
 static int  nfe_resume(device_t);
 static int nfe_shutdown(device_t);
 static int  nfe_can_use_msix(struct nfe_softc *);
+static int  nfe_detect_msik9(struct nfe_softc *);
 static void nfe_power(struct nfe_softc *);
 static int  nfe_miibus_readreg(device_t, int, int);
 static int  nfe_miibus_writereg(device_t, int, int, int);
@@ -332,13 +335,38 @@
 	}
 }
 
+
 static int
+nfe_detect_msik9(struct nfe_softc *sc)
+{
+	static const char *maker = "MSI";
+	static const char *product = "K9N6PGM2-V2 (MS-7309)";
+	char *m, *p;
+	int found;
+
+	found = 0;
+	m = getenv("smbios.planar.maker");
+	p = getenv("smbios.planar.product");
+	if (m != NULL && p != NULL) {
+		if (strcmp(m, maker) == 0 && strcmp(p, product) == 0)
+			found = 1;
+	}
+	if (m != NULL)
+		freeenv(m);
+	if (p != NULL)
+		freeenv(p);
+
+	return (found);
+}
+
+
+static int
 nfe_attach(device_t dev)
 {
 	struct nfe_softc *sc;
 	struct ifnet *ifp;
 	bus_addr_t dma_addr_max;
-	int error = 0, i, msic, reg, rid;
+	int error = 0, i, msic, phyloc, reg, rid;
 
 	sc = device_get_softc(dev);
 	sc->nfe_dev = dev;
@@ -564,7 +592,6 @@
 
 	ifp->if_softc = sc;
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-	ifp->if_mtu = ETHERMTU;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = nfe_ioctl;
 	ifp->if_start = nfe_start;
@@ -607,8 +634,16 @@
 #endif
 
 	/* Do MII setup */
+	phyloc = MII_PHY_ANY;
+	if (sc->nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN1 ||
+	    sc->nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN2 ||
+	    sc->nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN3 ||
+	    sc->nfe_devid == PCI_PRODUCT_NVIDIA_MCP61_LAN4) {
+		if (nfe_detect_msik9(sc) != 0)
+			phyloc = 0;
+	}
 	error = mii_attach(dev, &sc->nfe_miibus, ifp, nfe_ifmedia_upd,
-	    nfe_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY,
+	    nfe_ifmedia_sts, BMSR_DEFCAPMASK, phyloc, MII_OFFSET_ANY,
 	    MIIF_DOPAUSE);
 	if (error != 0) {
 		device_printf(dev, "attaching PHYs failed\n");
@@ -1341,15 +1376,12 @@
 {
 	struct nfe_rx_data *data;
 	void *desc;
-	int i, descsize;
+	int i;
 
-	if (sc->nfe_flags & NFE_40BIT_ADDR) {
+	if (sc->nfe_flags & NFE_40BIT_ADDR)
 		desc = ring->desc64;
-		descsize = sizeof (struct nfe_desc64);
-	} else {
+	else
 		desc = ring->desc32;
-		descsize = sizeof (struct nfe_desc32);
-	}
 
 	for (i = 0; i < NFE_RX_RING_COUNT; i++) {
 		data = &ring->data[i];
@@ -2390,7 +2422,7 @@
 	bus_dmamap_t map;
 	bus_dma_segment_t segs[NFE_MAX_SCATTER];
 	int error, i, nsegs, prod, si;
-	uint32_t tso_segsz;
+	uint32_t tsosegsz;
 	uint16_t cflags, flags;
 	struct mbuf *m;
 
@@ -2429,9 +2461,9 @@
 
 	m = *m_head;
 	cflags = flags = 0;
-	tso_segsz = 0;
+	tsosegsz = 0;
 	if ((m->m_pkthdr.csum_flags & CSUM_TSO) != 0) {
-		tso_segsz = (uint32_t)m->m_pkthdr.tso_segsz <<
+		tsosegsz = (uint32_t)m->m_pkthdr.tso_segsz <<
 		    NFE_TX_TSO_SHIFT;
 		cflags &= ~(NFE_TX_IP_CSUM | NFE_TX_TCP_UDP_CSUM);
 		cflags |= NFE_TX_TSO;
@@ -2482,14 +2514,14 @@
 		if ((m->m_flags & M_VLANTAG) != 0)
 			desc64->vtag = htole32(NFE_TX_VTAG |
 			    m->m_pkthdr.ether_vtag);
-		if (tso_segsz != 0) {
+		if (tsosegsz != 0) {
 			/*
 			 * XXX
 			 * The following indicates the descriptor element
 			 * is a 32bit quantity.
 			 */
-			desc64->length |= htole16((uint16_t)tso_segsz);
-			desc64->flags |= htole16(tso_segsz >> 16);
+			desc64->length |= htole16((uint16_t)tsosegsz);
+			desc64->flags |= htole16(tsosegsz >> 16);
 		}
 		/*
 		 * finally, set the valid/checksum/TSO bit in the first
@@ -2502,14 +2534,14 @@
 		else
 			desc32->flags |= htole16(NFE_TX_LASTFRAG_V1);
 		desc32 = &sc->txq.desc32[si];
-		if (tso_segsz != 0) {
+		if (tsosegsz != 0) {
 			/*
 			 * XXX
 			 * The following indicates the descriptor element
 			 * is a 32bit quantity.
 			 */
-			desc32->length |= htole16((uint16_t)tso_segsz);
-			desc32->flags |= htole16(tso_segsz >> 16);
+			desc32->length |= htole16((uint16_t)tsosegsz);
+			desc32->flags |= htole16(tsosegsz >> 16);
 		}
 		/*
 		 * finally, set the valid/checksum/TSO bit in the first
@@ -3205,8 +3237,8 @@
 	else
 		return;
 
-	for (i = 0; i < mib_cnt; i += sizeof(uint32_t))
-		NFE_READ(sc, NFE_TX_OCTET + i);
+	for (i = 0; i < mib_cnt; i++)
+		NFE_READ(sc, NFE_TX_OCTET + i * sizeof(uint32_t));
 
 	if ((sc->nfe_flags & NFE_MIB_V3) != 0) {
 		NFE_READ(sc, NFE_TX_UNICAST);
@@ -3260,7 +3292,7 @@
 	if ((sc->nfe_flags & NFE_MIB_V3) != 0) {
 		stats->tx_unicast += NFE_READ(sc, NFE_TX_UNICAST);
 		stats->tx_multicast += NFE_READ(sc, NFE_TX_MULTICAST);
-		stats->rx_broadcast += NFE_READ(sc, NFE_TX_BROADCAST);
+		stats->tx_broadcast += NFE_READ(sc, NFE_TX_BROADCAST);
 	}
 }
 

Modified: trunk/sys/dev/nfe/if_nfereg.h
===================================================================
--- trunk/sys/dev/nfe/if_nfereg.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nfe/if_nfereg.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$OpenBSD: if_nfereg.h,v 1.16 2006/02/22 19:23:44 damien Exp $	*/
 
 /*-
@@ -15,6 +16,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
+ * $FreeBSD: stable/10/sys/dev/nfe/if_nfereg.h 264442 2014-04-14 04:51:59Z yongari $
  */
 
 #define	NFE_RX_RING_COUNT	256
@@ -39,7 +41,7 @@
 	(NFE_JUMBO_FRAMELEN - NFE_RX_HEADERS)
 #define	NFE_MIN_FRAMELEN	(ETHER_MIN_LEN - ETHER_CRC_LEN)
 
-#define	NFE_MAX_SCATTER		32
+#define	NFE_MAX_SCATTER		35
 #define	NFE_TSO_MAXSGSIZE	4096
 #define	NFE_TSO_MAXSIZE		(65535 + sizeof(struct ether_vlan_header))
 

Modified: trunk/sys/dev/nfe/if_nfevar.h
===================================================================
--- trunk/sys/dev/nfe/if_nfevar.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nfe/if_nfevar.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$OpenBSD: if_nfevar.h,v 1.11 2006/02/19 13:57:02 damien Exp $	*/
 
 /*-
@@ -15,6 +16,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
+ * $FreeBSD: stable/10/sys/dev/nfe/if_nfevar.h 216925 2011-01-03 18:28:30Z jhb $
  */
 
 struct nfe_tx_data {

Modified: trunk/sys/dev/nge/if_nge.c
===================================================================
--- trunk/sys/dev/nge/if_nge.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nge/if_nge.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2000, 2001
@@ -32,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/nge/if_nge.c 280659 2015-03-26 05:07:18Z yongari $");
 
 /*
  * National Semiconductor DP83820/DP83821 gigabit ethernet driver
@@ -2102,27 +2103,6 @@
 	 */
 	nge_list_tx_init(sc);
 
-	/*
-	 * For the NatSemi chip, we have to explicitly enable the
-	 * reception of ARP frames, as well as turn on the 'perfect
-	 * match' filter where we store the station address, otherwise
-	 * we won't receive unicasts meant for this host.
-	 */
-	NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_ARP);
-	NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_PERFECT);
-
-	/*
-	 * Set the capture broadcast bit to capture broadcast frames.
-	 */
-	if (ifp->if_flags & IFF_BROADCAST) {
-		NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_BROAD);
-	} else {
-		NGE_CLRBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_BROAD);
-	}
-
-	/* Turn the receive filter on. */
-	NGE_SETBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_ENABLE);
-
 	/* Set Rx filter. */
 	nge_rxfilter(sc);
 
@@ -2335,9 +2315,9 @@
 	case SIOCADDMULTI:
 	case SIOCDELMULTI:
 		NGE_LOCK(sc);
-		nge_rxfilter(sc);
+		if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
+			nge_rxfilter(sc);
 		NGE_UNLOCK(sc);
-		error = 0;
 		break;
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:

Modified: trunk/sys/dev/nge/if_ngereg.h
===================================================================
--- trunk/sys/dev/nge/if_ngereg.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nge/if_ngereg.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2000, 2001
@@ -30,7 +31,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/nge/if_ngereg.h 226995 2011-11-01 16:13:59Z marius $
  */
 
 #define NGE_CSR			0x00

Modified: trunk/sys/dev/nmdm/nmdm.c
===================================================================
--- trunk/sys/dev/nmdm/nmdm.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nmdm/nmdm.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -29,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/nmdm/nmdm.c 271800 2014-09-18 19:20:08Z grehan $");
 
 /*
  * Pseudo-nulmodem driver
@@ -58,6 +59,8 @@
 static tsw_outwakeup_t	nmdm_inwakeup;
 static tsw_param_t	nmdm_param;
 static tsw_modem_t	nmdm_modem;
+static tsw_close_t	nmdm_close;
+static tsw_free_t	nmdm_free;
 
 static struct ttydevsw nmdm_class = {
 	.tsw_flags	= TF_NOPREFIX,
@@ -65,6 +68,8 @@
 	.tsw_outwakeup	= nmdm_outwakeup,
 	.tsw_param	= nmdm_param,
 	.tsw_modem	= nmdm_modem,
+	.tsw_close	= nmdm_close,
+	.tsw_free	= nmdm_free,
 };
 
 static void nmdm_task_tty(void *, int);
@@ -94,15 +99,83 @@
 
 static int nmdm_count = 0;
 
-static struct nmdmsoftc *
-nmdm_alloc(unsigned long unit)
+static void
+nmdm_close(struct tty *tp)
 {
+	struct nmdmpart *np;
+	struct nmdmpart *onp;
+	struct tty *otp;
+
+	np = tty_softc(tp);
+	onp = np->np_other;
+	otp = onp->np_tty;
+
+	/* If second part is opened, do not destroy ourselves. */
+	if (tty_opened(otp))
+		return;
+
+	/* Shut down self. */
+	tty_rel_gone(tp);
+
+	/* Shut down second part. */
+	tty_lock(tp);
+	onp = np->np_other;
+	if (onp == NULL)
+		return;
+	otp = onp->np_tty;
+	tty_rel_gone(otp);
+	tty_lock(tp);
+}
+
+static void
+nmdm_free(void *softc)
+{
+	struct nmdmpart *np = (struct nmdmpart *)softc;
+	struct nmdmsoftc *ns = np->np_pair;
+
+	callout_drain(&np->np_callout);
+	taskqueue_drain(taskqueue_swi, &np->np_task);
+
+	/*
+	 * The function is called on both parts simultaneously.  We serialize
+	 * with help of ns_mtx.  The first invocation should return and
+	 * delegate freeing of resources to the second.
+	 */
+	mtx_lock(&ns->ns_mtx);
+	if (np->np_other != NULL) {
+		np->np_other->np_other = NULL;
+		mtx_unlock(&ns->ns_mtx);
+		return;
+	}
+	mtx_destroy(&ns->ns_mtx);
+	free(ns, M_NMDM);
+	atomic_subtract_int(&nmdm_count, 1);
+}
+
+static void
+nmdm_clone(void *arg, struct ucred *cred, char *name, int nameen,
+    struct cdev **dev)
+{
 	struct nmdmsoftc *ns;
 	struct tty *tp;
+	char *end;
+	int error;
+	char endc;
 
-	atomic_add_int(&nmdm_count, 1);
+	if (*dev != NULL)
+		return;
+	if (strncmp(name, "nmdm", 4) != 0)
+		return;
+	if (strlen(name) <= strlen("nmdmX"))
+		return;
 
-	ns = malloc(sizeof(*ns), M_NMDM, M_WAITOK|M_ZERO);
+	/* Device name must be "nmdm%s%c", where %c is 'A' or 'B'. */
+	end = name + strlen(name) - 1;
+	endc = *end;
+	if (endc != 'A' && endc != 'B')
+		return;
+
+	ns = malloc(sizeof(*ns), M_NMDM, M_WAITOK | M_ZERO);
 	mtx_init(&ns->ns_mtx, "nmdm", NULL, MTX_DEF);
 
 	/* Hook the pairs together. */
@@ -119,43 +192,38 @@
 	/* Create device nodes. */
 	tp = ns->ns_part1.np_tty = tty_alloc_mutex(&nmdm_class, &ns->ns_part1,
 	    &ns->ns_mtx);
-	tty_makedev(tp, NULL, "nmdm%luA", unit);
+	*end = 'A';
+	error = tty_makedevf(tp, NULL, endc == 'A' ? TTYMK_CLONING : 0,
+	    "%s", name);
+	if (error) {
+		*end = endc;
+		mtx_destroy(&ns->ns_mtx);
+		free(ns, M_NMDM);
+		return;
+	}
 
 	tp = ns->ns_part2.np_tty = tty_alloc_mutex(&nmdm_class, &ns->ns_part2,
 	    &ns->ns_mtx);
-	tty_makedev(tp, NULL, "nmdm%luB", unit);
-
-	return (ns);
-}
-
-static void
-nmdm_clone(void *arg, struct ucred *cred, char *name, int nameen,
-    struct cdev **dev)
-{
-	unsigned long unit;
-	char *end;
-	struct nmdmsoftc *ns;
-
-	if (*dev != NULL)
+	*end = 'B';
+	error = tty_makedevf(tp, NULL, endc == 'B' ? TTYMK_CLONING : 0,
+	    "%s", name);
+	if (error) {
+		*end = endc;
+		mtx_lock(&ns->ns_mtx);
+		/* see nmdm_free() */
+		ns->ns_part1.np_other = NULL;
+		atomic_add_int(&nmdm_count, 1);
+		tty_rel_gone(ns->ns_part1.np_tty);
 		return;
-	if (strncmp(name, "nmdm", 4) != 0)
-		return;
+	}
 
-	/* Device name must be "nmdm%lu%c", where %c is 'A' or 'B'. */
-	name += 4;
-	unit = strtoul(name, &end, 10);
-	if (unit == ULONG_MAX || name == end)
-		return;
-	if ((end[0] != 'A' && end[0] != 'B') || end[1] != '\0')
-		return;
-
-	/* XXX: pass privileges? */
-	ns = nmdm_alloc(unit);
-
-	if (end[0] == 'A')
+	if (endc == 'A')
 		*dev = ns->ns_part1.np_tty->t_dev;
 	else
 		*dev = ns->ns_part2.np_tty->t_dev;
+
+	*end = endc;
+	atomic_add_int(&nmdm_count, 1);
 }
 
 static void
@@ -187,6 +255,10 @@
 
 	tp = np->np_tty;
 	tty_lock(tp);
+	if (tty_gone(tp)) {
+		tty_unlock(tp);
+		return;
+	}
 
 	otp = np->np_other->np_tty;
 	KASSERT(otp != NULL, ("NULL otp in nmdmstart"));
@@ -203,6 +275,12 @@
 		}
 	}
 
+	/* This may happen when we are in detach process. */
+	if (tty_gone(otp)) {
+		tty_unlock(otp);
+		return;
+	}
+
 	while (ttydisc_rint_poll(otp) > 0) {
 		if (np->np_rate && !np->np_quota)
 			break;

Modified: trunk/sys/dev/nsp/nsp.c
===================================================================
--- trunk/sys/dev/nsp/nsp.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nsp/nsp.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$NecBSD: nsp.c,v 1.21.12.6 2001/06/29 06:27:52 honda Exp $	*/
 /*	$NetBSD$	*/
 
@@ -40,48 +41,23 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/nsp/nsp.c 250460 2013-05-10 16:41:26Z eadler $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#if defined(__FreeBSD__) && __FreeBSD_version > 500001
 #include <sys/bio.h>
-#endif	/* __ FreeBSD__ */
 #include <sys/buf.h>
 #include <sys/queue.h>
 #include <sys/malloc.h>
 #include <sys/errno.h>
 
-#ifdef __NetBSD__
-#include <sys/device.h>
-#include <machine/bus.h>
-#include <machine/intr.h>
-
-#include <dev/scsipi/scsi_all.h>
-#include <dev/scsipi/scsipi_all.h>
-#include <dev/scsipi/scsiconf.h>
-#include <dev/scsipi/scsi_disk.h>
-
-#include <machine/dvcfg.h>
-#include <machine/physio_proc.h>
-
-#include <i386/Cbus/dev/scsi_low.h>
-#include <i386/Cbus/dev/nspreg.h>
-#include <i386/Cbus/dev/nspvar.h>
-#endif /* __NetBSD__ */
-
-#ifdef __FreeBSD__
 #include <machine/cpu.h>
 #include <machine/bus.h>
 
-#include <compat/netbsd/dvcfg.h>
-#include <compat/netbsd/physio_proc.h>
-
 #include <cam/scsi/scsi_low.h>
 #include <dev/nsp/nspreg.h>
 #include <dev/nsp/nspvar.h>
-#endif /* __FreeBSD__ */
 
 /***************************************************
  * USER SETTINGS
@@ -88,7 +64,7 @@
  ***************************************************/
 /* DEVICE CONFIGURATION FLAGS (MINOR)
  *
- * 0x01   DISCONECT OFF
+ * 0x01   DISCONNECT OFF
  * 0x02   PARITY LINE OFF
  * 0x04   IDENTIFY MSG OFF ( = single lun)
  * 0x08   SYNC TRANSFER OFF
@@ -248,10 +224,10 @@
 		if ((ph & mask) != 0 && (ph & SCBUSMON_PHMASK) == curphase)
 			return 1;
 
-		SCSI_LOW_DELAY(NSP_DELAY_INTERVAL);
+		DELAY(NSP_DELAY_INTERVAL);
 	}
 
-	printf("%s: nsp_expect_signal timeout\n", slp->sl_xname);
+	device_printf(slp->sl_dev, "nsp_expect_signal timeout\n");
 	return -1;
 }
 
@@ -312,7 +288,7 @@
 
 	cr = nsp_cr_read_1(bst, bsh, NSPR_SCBUSCR)/*  & ~SCBUSCR_ACK */;
 	nsp_cr_write_1(bst, bsh, NSPR_SCBUSCR, cr | SCBUSCR_ATN);
-	SCSI_LOW_DELAY(10);
+	DELAY(10);
 }
 
 static void
@@ -326,7 +302,7 @@
 	bus_space_write_1(bst, bsh, nsp_irqcr, IRQCR_ALLMASK);
 
 	nsp_cr_write_1(bst, bsh, NSPR_SCBUSCR, SCBUSCR_RST);
-	SCSI_LOW_DELAY(100 * 1000);	/* 100ms */
+	DELAY(100 * 1000);	/* 100ms */
 	nsp_cr_write_1(bst, bsh, NSPR_SCBUSCR, 0);
 	for (i = 0; i < 5; i ++)
 		(void) nsp_cr_read_1(bst, bsh, NSPR_IRQPHS);
@@ -350,7 +326,7 @@
 	/* deassert sel and assert atten */
 	sc->sc_seltout = 0;
 	nsp_cr_write_1(bst, bsh, NSPR_SCBUSCR, sc->sc_busc);
-	SCSI_LOW_DELAY(1);
+	DELAY(1);
 	nsp_cr_write_1(bst, bsh, NSPR_SCBUSCR, 
 			sc->sc_busc | SCBUSCR_ADIR | SCBUSCR_ACKEN);
 	SCSI_LOW_ASSERT_ATN(slp);
@@ -392,7 +368,7 @@
 	{
 		/* XXX: what a stupid chip! */
 		arbs = nsp_cr_read_1(bst, bsh, NSPR_ARBITS);
-		SCSI_LOW_DELAY(1);
+		DELAY(1);
 	} 
 	while ((arbs & (ARBITS_WIN | ARBITS_FAIL)) == 0 && wc -- > 0);
 
@@ -410,19 +386,19 @@
 	scsi_low_arbit_win(slp);
 
 	s = splhigh();
-	SCSI_LOW_DELAY(3);
+	DELAY(3);
 	nsp_cr_write_1(bst, bsh, NSPR_DATA,
 		       sc->sc_idbit | (1 << ti->ti_id));
 	nsp_cr_write_1(bst, bsh, NSPR_SCBUSCR,
 			SCBUSCR_SEL | SCBUSCR_BSY | sc->sc_busc);
-	SCSI_LOW_DELAY(3);
+	DELAY(3);
 	nsp_cr_write_1(bst, bsh, NSPR_SCBUSCR, SCBUSCR_SEL |
 			SCBUSCR_BSY | SCBUSCR_DOUT | sc->sc_busc);
 	nsp_cr_write_1(bst, bsh, NSPR_ARBITS, ARBITS_CLR);
-	SCSI_LOW_DELAY(3);
+	DELAY(3);
 	nsp_cr_write_1(bst, bsh, NSPR_SCBUSCR,
 		       SCBUSCR_SEL | SCBUSCR_DOUT | sc->sc_busc);
-	SCSI_LOW_DELAY(1);
+	DELAY(1);
 
 	if ((nsp_io_control & NSP_WAIT_FOR_SELECT) != 0)
 	{
@@ -436,11 +412,11 @@
 			ph = nsp_cr_read_1(bst, bsh, NSPR_SCBUSMON);
 			if ((ph & SCBUSMON_BSY) == 0)
 			{
-				SCSI_LOW_DELAY(NSP_SEL_CHECK_INTERVAL);
+				DELAY(NSP_SEL_CHECK_INTERVAL);
 				continue;
 			}
 
-			SCSI_LOW_DELAY(1);
+			DELAY(1);
 			ph = nsp_cr_read_1(bst, bsh, NSPR_SCBUSMON);
 			if ((ph & SCBUSMON_BSY) != 0)
 			{
@@ -485,7 +461,6 @@
 	nsphw_init(sc);
 	scsi_low_bus_reset(slp);
 
-	SOFT_INTR_REQUIRED(slp);
 	return 0;
 }
 
@@ -623,17 +598,6 @@
 	return 1;
 }
 
-int
-nspprint(aux, name)
-	void *aux;
-	const char *name;
-{
-
-	if (name != NULL)
-		printf("%s: scsibus ", name);
-	return UNCONF;
-}
-
 void
 nspattachsubr(sc)
 	struct nsp_softc *sc;
@@ -783,8 +747,8 @@
 			else
 			{
 				slp->sl_error |= PDMAERR;
-				printf("%s len %x >= datalen %x\n",
-					slp->sl_xname,
+				device_printf(slp->sl_dev,
+					"len %x >= datalen %x\n",
 					len, slp->sl_scp.scp_datalen);
 			}
 		}
@@ -794,8 +758,9 @@
 			    sc->sc_cnt > cb->ccb_scp.scp_datalen)
 			{
 				slp->sl_error |= PDMAERR;
-				printf("%s: data read count error %x != %x (%x)\n",
-					slp->sl_xname, sc->sc_cnt, cnt,
+				device_printf(slp->sl_dev,
+					"data read count error %x != %x (%x)\n",
+					sc->sc_cnt, cnt,
 					cb->ccb_scp.scp_datalen);
 			}
 		}
@@ -805,7 +770,7 @@
 	else
 	{
 
-		printf("%s data phase miss\n", slp->sl_xname);
+		device_printf(slp->sl_dev, "data phase miss\n");
 		slp->sl_error |= PDMAERR;
 	}
 }
@@ -856,8 +821,8 @@
 #ifdef	NSP_DEBUG
 	if (res < sc->sc_cnt || res == (u_int) -1)
 	{
-		printf("%s: strange fifo ack count 0x%x < 0x%x\n", 
-			slp->sl_xname, res, sc->sc_cnt);
+		device_printf(slp->sl_dev,
+		    "strange fifo ack count 0x%x < 0x%x\n", res, sc->sc_cnt);
 		return 0;
 	}
 #endif	/* NSP_DEBUG */
@@ -867,8 +832,8 @@
 	{
 		if ((slp->sl_error & PDMAERR) == 0)
 		{
-			printf("%s: data overrun 0x%x > 0x%x\n",
-				slp->sl_xname, res, slp->sl_scp.scp_datalen);
+			device_printf(slp->sl_dev, "data overrun 0x%x > 0x%x\n",
+			    res, slp->sl_scp.scp_datalen);
 		}
 
 		slp->sl_error |= PDMAERR;
@@ -876,7 +841,7 @@
 
 		if ((slp->sl_flags & HW_READ_PADDING) == 0)
 		{
-			printf("%s: read padding required\n", slp->sl_xname);
+			device_printf(slp->sl_dev, "read padding required\n");
 			return 0;
 		}
 
@@ -946,8 +911,9 @@
 #ifdef	NSP_DEBUG
 		if ((slp->sl_scp.scp_datalen % WFIFO_CRIT) != 0)
 		{
-			printf("%s: strange write length 0x%x\n",
-				slp->sl_xname, slp->sl_scp.scp_datalen);
+			device_printf(slp->sl_dev,
+			    "strange write length 0x%x\n",
+			    slp->sl_scp.scp_datalen);
 		}
 #endif	/* NSP_DEBUG */
 		res = slp->sl_scp.scp_datalen % suspendio;
@@ -1023,7 +989,7 @@
 			}
 			return 1;
 		}
-		SCSI_LOW_DELAY(1);
+		DELAY(1);
 	}
 	return 0;
 }
@@ -1088,12 +1054,12 @@
 			if ((sc->sc_icr & SCIENR_FIFO) != 0)
 				break;
 
-			SCSI_LOW_DELAY(1);
+			DELAY(1);
 		}
 
 		if ((-- tout) <= 0)
 		{
-			printf("%s: nsp_pio_read: timeout\n", slp->sl_xname);
+			device_printf(slp->sl_dev, "nsp_pio_read: timeout\n");
 			return;
 		}
 	}
@@ -1200,12 +1166,12 @@
 			if ((sc->sc_icr & SCIENR_FIFO) != 0)
 				break;
 
-			SCSI_LOW_DELAY(1);
+			DELAY(1);
 		}
 
 		if ((-- tout) <= 0)
 		{
-			printf("%s: nsp_pio_write: timeout\n", slp->sl_xname);
+			device_printf(slp->sl_dev, "nsp_pio_write: timeout\n");
 			return;
 		}
 	}
@@ -1234,10 +1200,10 @@
 			return -1;
 		if ((regv & mask) == 0)
 			return 1;
-		SCSI_LOW_DELAY(NSP_DELAY_INTERVAL);
+		DELAY(NSP_DELAY_INTERVAL);
 	}
 
-	printf("%s: %s nsp_negate_signal timeout\n", slp->sl_xname, s);
+	device_printf(slp->sl_dev, "%s nsp_negate_signal timeout\n", s);
 	return -1;
 }
 
@@ -1351,9 +1317,9 @@
 {
 	struct scsi_low_softc *slp = &sc->sc_sclow;
 
-	printf("%s: %s\n", slp->sl_xname, s);
-	printf("%s: isrc 0x%x scmon 0x%x irqphs 0x%x\n",
-	       slp->sl_xname, (u_int) isrc, (u_int) ph, (u_int) irqphs);
+	device_printf(slp->sl_dev, "%s\n", s);
+	device_printf(slp->sl_dev, "isrc 0x%x scmon 0x%x irqphs 0x%x\n",
+	    (u_int) isrc, (u_int) ph, (u_int) irqphs);
 }
 
 static int
@@ -1426,8 +1392,8 @@
 
 	if ((stat & SCBUSMON_PHMASK) != phase)
 	{
-		printf("%s: phase mismatch 0x%x != 0x%x\n",
-			slp->sl_xname, (u_int) phase, (u_int) stat);
+		device_printf(slp->sl_dev, "phase mismatch 0x%x != 0x%x\n",
+		    (u_int) phase, (u_int) stat);
 		return EINVAL;
 	}
 
@@ -1446,7 +1412,6 @@
 	bus_space_tag_t bst = sc->sc_iot;
 	bus_space_handle_t bsh = sc->sc_ioh;
 	struct targ_info *ti;
-	struct physio_proc *pp;
 	struct buf *bp;
 	u_int derror, flags;
 	int len, rv;
@@ -1519,7 +1484,7 @@
 		scsi_low_print(slp, NULL);
 #ifdef	KDB
 		if (nsp_debug > 1)
-			SCSI_LOW_DEBUGGER("nsp");
+			kdb_enter(KDB_WHY_CAM, "nsp");
 #endif	/* KDB */
 	}
 #endif	/* NSP_DEBUG */
@@ -1594,8 +1559,8 @@
 		nsp_target_nexus_establish(sc);
 		if ((ph & SCBUSMON_PHMASK) != PHASE_MSGIN)
 		{
-			printf("%s: unexpected phase after reselect\n",
-			       slp->sl_xname);
+			device_printf(slp->sl_dev,
+			    "unexpected phase after reselect\n");
 			slp->sl_error |= FATALIO;
 			scsi_low_assert_msg(slp, ti, SCSI_LOW_MSG_ABORT, 1);
 			return 1;
@@ -1675,9 +1640,7 @@
 			scsi_low_attention(slp);
 		}
 	
-		pp = physio_proc_enter(bp);
 		nsp_pio_write(sc, sc->sc_suspendio);
-		physio_proc_leave(pp);
 		break;
 
 	case IRQPHS_DATAIN:
@@ -1687,9 +1650,7 @@
 			scsi_low_attention(slp);
 		}
 
-		pp = physio_proc_enter(bp);
 		nsp_pio_read(sc, sc->sc_suspendio);
-		physio_proc_leave(pp);
 		break;
 
 	case IRQPHS_STATUS:
@@ -1886,7 +1847,7 @@
 	        slp->sl_error |= PDMAERR;
 		if ((slp->sl_flags & HW_WRITE_PADDING) == 0)
 		{
-			printf("%s: write padding required\n", slp->sl_xname);
+			device_printf(slp->sl_dev, "write padding required\n");
 			break;
 		}
 
@@ -1899,7 +1860,7 @@
 			regv = bus_space_read_1(iot, ioh, nsp_fifosr);
 			if ((regv & FIFOSR_FULLEMP) == 0)
 			{
-				SCSI_LOW_DELAY(1);
+				DELAY(1);
 				continue;
 			}
 

Modified: trunk/sys/dev/nsp/nsp_pccard.c
===================================================================
--- trunk/sys/dev/nsp/nsp_pccard.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nsp/nsp_pccard.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$NecBSD: nsp_pisa.c,v 1.4 1999/04/15 01:35:54 kmatsuda Exp $	*/
 /*	$NetBSD$	*/
 
@@ -35,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/nsp/nsp_pccard.c 240325 2012-09-10 18:49:49Z jhb $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -42,19 +43,18 @@
 #include <sys/errno.h>
 #include <sys/kernel.h>
 #include <sys/malloc.h>
+#include <sys/module.h>
 #include <sys/systm.h>
 
 #include <machine/bus.h>
 #include <machine/resource.h>
 #include <sys/rman.h>
-#include <compat/netbsd/dvcfg.h>
 
-#include <sys/device_port.h>
+#include <sys/bus.h>
 
 #include <dev/pccard/pccardvar.h>
 
 #include <cam/scsi/scsi_low.h>
-#include <cam/scsi/scsi_low_pisa.h>
 
 #include <dev/nsp/nspreg.h>
 #include <dev/nsp/nspvar.h>
@@ -65,10 +65,10 @@
 
 #define	PIO_MODE 0x100		/* pd_flags */
 
-static int nspprobe(DEVPORT_PDEVICE devi);
-static int nspattach(DEVPORT_PDEVICE devi);
+static int nspprobe(device_t devi);
+static int nspattach(device_t devi);
 
-static	void	nsp_card_unload	(DEVPORT_PDEVICE);
+static	void	nsp_card_unload	(device_t);
 
 const struct pccard_product nsp_products[] = {
   	PCMCIA_CARD(IODATA3, CBSC16),
@@ -139,7 +139,7 @@
 
 	/* No need to allocate memory if not configured and it's in PIO mode */
 	if (maddr == 0 || msize == 0) {
-		if ((DEVPORT_PDEVFLAGS(dev) & PIO_MODE) == 0) {
+		if ((device_get_flags(dev) & PIO_MODE) == 0) {
 			printf("Memory window was not configured. Configure or use in PIO mode.");
 			nsp_release_resource(dev);
 			return(ENOMEM);
@@ -229,9 +229,9 @@
 DRIVER_MODULE(nsp, pccard, nsp_pccard_driver, nsp_devclass, 0, 0);
 
 static void
-nsp_card_unload(DEVPORT_PDEVICE devi)
+nsp_card_unload(device_t devi)
 {
-	struct nsp_softc *sc = DEVPORT_PDEVGET_SOFTC(devi);
+	struct nsp_softc *sc = device_get_softc(devi);
 	intrmask_t s;
 
 	s = splcam();
@@ -241,7 +241,7 @@
 }
 
 static	int
-nspprobe(DEVPORT_PDEVICE devi)
+nspprobe(device_t devi)
 {
 	int rv;
 	struct nsp_softc *sc = device_get_softc(devi);
@@ -248,18 +248,18 @@
 
 	rv = nspprobesubr(rman_get_bustag(sc->port_res),
 			  rman_get_bushandle(sc->port_res),
-			  DEVPORT_PDEVFLAGS(devi));
+			  device_get_flags(devi));
 
 	return rv;
 }
 
 static	int
-nspattach(DEVPORT_PDEVICE devi)
+nspattach(device_t devi)
 {
 	struct nsp_softc *sc;
 	struct scsi_low_softc *slp;
-	u_int32_t flags = DEVPORT_PDEVFLAGS(devi);
-	u_int	iobase = DEVPORT_PDEVIOBASE(devi);
+	u_int32_t flags = device_get_flags(devi);
+	u_int	iobase = bus_get_resource_start(devi, SYS_RES_IOPORT, 0);
 	intrmask_t s;
 	char	dvname[16];
 
@@ -270,7 +270,7 @@
 		return (0);
 	}
 
-	sc = DEVPORT_PDEVALLOC_SOFTC(devi);
+	sc = device_get_softc(devi);
 	if (sc == NULL)
 		return (0);
 

Modified: trunk/sys/dev/nsp/nspreg.h
===================================================================
--- trunk/sys/dev/nsp/nspreg.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nsp/nspreg.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/nsp/nspreg.h 139749 2005-01-06 01:43:34Z imp $	*/
 /*	$NecBSD: nspreg.h,v 1.4.14.3 2001/06/29 06:27:53 honda Exp $	*/
 /*	$NetBSD$	*/
 

Modified: trunk/sys/dev/nsp/nspvar.h
===================================================================
--- trunk/sys/dev/nsp/nspvar.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nsp/nspvar.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,4 +1,5 @@
-/*	$MidnightBSD$	*/
+/* $MidnightBSD$ */
+/*	$FreeBSD: stable/10/sys/dev/nsp/nspvar.h 240325 2012-09-10 18:49:49Z jhb $	*/
 /*	$NecBSD: nspvar.h,v 1.7.14.5 2001/06/29 06:27:54 honda Exp $	*/
 /*	$NetBSD$	*/
 
@@ -43,21 +44,11 @@
 struct nsp_softc {
 	struct scsi_low_softc sc_sclow;		/* generic data */
 
-#ifdef	__NetBSD__
 	bus_space_tag_t sc_iot;
 	bus_space_handle_t sc_ioh;
 	bus_space_tag_t sc_memt;
 	bus_space_handle_t sc_memh;
 
-	void *sc_ih;
-#endif	/* __NetBSD__ */
-
-#ifdef __FreeBSD__
-	bus_space_tag_t sc_iot;
-	bus_space_handle_t sc_ioh;
-	bus_space_tag_t sc_memt;
-	bus_space_handle_t sc_memh;
-
 	int port_rid;
 	int irq_rid;
 	int mem_rid;
@@ -66,7 +57,6 @@
 	struct resource *mem_res;
 
 	void *nsp_intrhand;
-#endif	/* __FreeBSD__ */
 
 	int sc_tmaxcnt;				/* timeout count */
 	int sc_seltout;				/* selection timeout counter */
@@ -102,12 +92,6 @@
  *****************************************************************/
 int nspprobesubr(bus_space_tag_t, bus_space_handle_t, u_int);
 void nspattachsubr(struct nsp_softc *);
-int nspprint(void *, const char *);
 int nspintr(void *);
 
-#if	defined(__i386__) && 0
-#define	SOFT_INTR_REQUIRED(slp)	(softintr((slp)->sl_irq))
-#else	/* !__i386__ */
-#define	SOFT_INTR_REQUIRED(slp)
-#endif	/* !__i386__ */
 #endif	/* !_NSPVAR_H_ */

Modified: trunk/sys/dev/nve/if_nve.c
===================================================================
--- trunk/sys/dev/nve/if_nve.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nve/if_nve.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2005 by David E. O'Brien <obrien at FreeBSD.org>.
  * Copyright (c) 2003,2004 by Quinton Dolan <q at onthenet.com.au>. 
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $Id: if_nve.c,v 1.6 2013-01-08 00:45:19 laffer1 Exp $
+ * $Id: if_nv.c,v 1.19 2004/08/12 14:00:05 q Exp $
  */
 /*
  * NVIDIA nForce MCP Networking Adapter driver
@@ -72,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/dev/nve/if_nve.c 243857 2012-12-04 09:32:43Z glebius $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -532,7 +533,6 @@
 	ifp->if_ioctl = nve_ioctl;
 	ifp->if_start = nve_ifstart;
 	ifp->if_init = nve_init;
-	ifp->if_mtu = ETHERMTU;
 	ifp->if_baudrate = IF_Mbps(100);
 	IFQ_SET_MAXLEN(&ifp->if_snd, TX_RING_SIZE - 1);
 	ifp->if_snd.ifq_drv_maxlen = TX_RING_SIZE - 1;

Modified: trunk/sys/dev/nve/if_nvereg.h
===================================================================
--- trunk/sys/dev/nve/if_nvereg.h	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nve/if_nvereg.h	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2005 by David E. O'Brien <obrien at FreeBSD.org>.
  * Copyright (c) 2003 by Quinton Dolan <q at onthenet.com.au>.
@@ -24,8 +25,8 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
  * SUCH DAMAGE.
  *
- * $Id: if_nvereg.h,v 1.4 2013-01-08 00:45:19 laffer1 Exp $
- * $MidnightBSD$
+ * $Id: if_nvreg.h,v 1.6 2004/08/12 14:00:05 q Exp $
+ * $FreeBSD: stable/10/sys/dev/nve/if_nvereg.h 241652 2012-10-17 21:30:16Z glebius $
  */
  
 #ifndef _IF_NVEREG_H_
@@ -186,10 +187,6 @@
 #define NVE_UNLOCK(_sc)		mtx_unlock(&(_sc)->mtx)
 #define NVE_LOCK_ASSERT(_sc)	mtx_assert(&(_sc)->mtx, MA_OWNED)
 
-#define IF_Kbps(x) ((x) * 1000)			/* kilobits/sec. */
-#define IF_Mbps(x) (IF_Kbps((x) * 1000))	/* megabits/sec. */
-#define ETHER_ALIGN 2
-
 extern int ADAPTER_ReadPhy (PVOID pContext, ULONG ulPhyAddr, ULONG ulReg, ULONG *pulVal);
 extern int ADAPTER_WritePhy (PVOID pContext, ULONG ulPhyAddr, ULONG ulReg, ULONG ulVal);
 extern int ADAPTER_Init (PVOID pContext, USHORT usForcedSpeed, UCHAR ucForceDpx, UCHAR ucForceMode, UINT *puiLinkState);

Modified: trunk/sys/dev/nvram/nvram.c
===================================================================
--- trunk/sys/dev/nvram/nvram.c	2018-05-27 23:30:17 UTC (rev 10090)
+++ trunk/sys/dev/nvram/nvram.c	2018-05-27 23:30:53 UTC (rev 10091)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007 Peter Wemm
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/dev/nvram/nvram.c 181132 2008-08-01 20:39:18Z jhb $
  */
 
 #include <sys/param.h>



More information about the Midnightbsd-cvs mailing list