Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Jan 2017 18:35:41 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r311805 - in projects/bsnmp-ipv6-mib: contrib/bsnmp/gensnmpdef contrib/bsnmp/snmp_mibII contrib/bsnmp/snmpd lib/libprocstat share/mk sys/arm/ti sys/cam/ctl sys/conf sys/dev/hyperv/inclu...
Message-ID:  <201701091835.v09IZfwL023365@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Mon Jan  9 18:35:41 2017
New Revision: 311805
URL: https://svnweb.freebsd.org/changeset/base/311805

Log:
  MFhead@r311262

Added:
  projects/bsnmp-ipv6-mib/sys/dev/sdhci/sdhci_fdt_gpio.c
     - copied unchanged from r311804, head/sys/dev/sdhci/sdhci_fdt_gpio.c
  projects/bsnmp-ipv6-mib/sys/dev/sdhci/sdhci_fdt_gpio.h
     - copied unchanged from r311804, head/sys/dev/sdhci/sdhci_fdt_gpio.h
Deleted:
  projects/bsnmp-ipv6-mib/lib/libprocstat/Versions.def
Modified:
  projects/bsnmp-ipv6-mib/contrib/bsnmp/gensnmpdef/gensnmpdef.c
  projects/bsnmp-ipv6-mib/contrib/bsnmp/snmp_mibII/BEGEMOT-IP-MIB.txt
  projects/bsnmp-ipv6-mib/contrib/bsnmp/snmp_mibII/mibII.c
  projects/bsnmp-ipv6-mib/contrib/bsnmp/snmpd/BEGEMOT-MIB.txt
  projects/bsnmp-ipv6-mib/contrib/bsnmp/snmpd/FOKUS-MIB.txt
  projects/bsnmp-ipv6-mib/lib/libprocstat/Makefile
  projects/bsnmp-ipv6-mib/share/mk/bsd.README
  projects/bsnmp-ipv6-mib/sys/arm/ti/ti_sdhci.c
  projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl.c
  projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_backend.h
  projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_frontend.c
  projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_frontend.h
  projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_ioctl.h
  projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_private.h
  projects/bsnmp-ipv6-mib/sys/conf/files
  projects/bsnmp-ipv6-mib/sys/dev/hyperv/include/hyperv.h
  projects/bsnmp-ipv6-mib/sys/dev/hyperv/utilities/vmbus_timesync.c
  projects/bsnmp-ipv6-mib/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
  projects/bsnmp-ipv6-mib/sys/dev/hyperv/vmbus/hyperv.c
  projects/bsnmp-ipv6-mib/sys/dev/hyperv/vmbus/vmbus_et.c
  projects/bsnmp-ipv6-mib/sys/dev/mmc/mmcsd.c
  projects/bsnmp-ipv6-mib/sys/dev/sdhci/fsl_sdhci.c
  projects/bsnmp-ipv6-mib/sys/dev/sdhci/sdhci.c
  projects/bsnmp-ipv6-mib/sys/dev/sdhci/sdhci.h
  projects/bsnmp-ipv6-mib/sys/dev/sdhci/sdhci_pci.c
  projects/bsnmp-ipv6-mib/tools/tools/gensnmpdef/Makefile
  projects/bsnmp-ipv6-mib/usr.bin/ctlstat/ctlstat.8
  projects/bsnmp-ipv6-mib/usr.bin/ctlstat/ctlstat.c
  projects/bsnmp-ipv6-mib/usr.bin/netstat/main.c
  projects/bsnmp-ipv6-mib/usr.bin/netstat/route.c
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_atm/BEGEMOT-ATM-FREEBSD-MIB.txt
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_atm/Makefile
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_hast/Makefile
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_hostres/BEGEMOT-HOSTRES-MIB.txt
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_mibII/Makefile
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_netgraph/BEGEMOT-NETGRAPH.txt
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_target/Makefile
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_usm/Makefile
  projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_vacm/Makefile
Directory Properties:
  projects/bsnmp-ipv6-mib/   (props changed)

Modified: projects/bsnmp-ipv6-mib/contrib/bsnmp/gensnmpdef/gensnmpdef.c
==============================================================================
--- projects/bsnmp-ipv6-mib/contrib/bsnmp/gensnmpdef/gensnmpdef.c	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/contrib/bsnmp/gensnmpdef/gensnmpdef.c	Mon Jan  9 18:35:41 2017	(r311805)
@@ -126,9 +126,11 @@ open_node(const SmiNode *n, u_int level,
 
 	while (level < n->oidlen - 1) {
 		if (level >= cut) {
+			n1 = smiGetNodeByOID(level + 1, n->oid);
+			if (n1 == NULL)
+				continue;
 			pindent(level);
 			printf("(%u", n->oid[level]);
-			n1 = smiGetNodeByOID(level + 1, n->oid);
 			printf(" ");
 			print_name(n1);
 			printf("\n");
@@ -397,12 +399,11 @@ static void
 save_typdef(char *name)
 {
 	struct tdef *t;
-	t = malloc(sizeof(struct tdef));
 
+	t = calloc(1, sizeof(struct tdef));
 	if (t == NULL)
 		err(1, NULL);
 
-	memset(t, 0 , sizeof(struct tdef));
 	t->name = name;
 	SLIST_INSERT_HEAD(&tdefs, t, link);
 }
@@ -559,7 +560,11 @@ main(int argc, char *argv[])
 	level = 0;
 	last = NULL;
 	for (opt = 0; opt < argc; opt++) {
+		if (mods[opt] == NULL) /* smiGetModule failed above */
+			continue;
 		n = smiGetFirstNode(mods[opt], SMI_NODEKIND_ANY);
+		if (n == NULL)
+			continue;
 		for (;;) {
 			if (do_typedef == 0) {
 				level = open_node(n, level, &last);

Modified: projects/bsnmp-ipv6-mib/contrib/bsnmp/snmp_mibII/BEGEMOT-IP-MIB.txt
==============================================================================
--- projects/bsnmp-ipv6-mib/contrib/bsnmp/snmp_mibII/BEGEMOT-IP-MIB.txt	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/contrib/bsnmp/snmp_mibII/BEGEMOT-IP-MIB.txt	Mon Jan  9 18:35:41 2017	(r311805)
@@ -54,6 +54,9 @@ begemotIp MODULE-IDENTITY
 	     E-mail:	harti@freebsd.org"
     DESCRIPTION
 	    "The MIB for IP stuff that is not in the official IP MIBs."
+    REVISION	"200602130000Z"
+    DESCRIPTION
+		"Initial revision."
     ::= { begemot 3 }
 
 begemotIpObjects	OBJECT IDENTIFIER ::= { begemotIp 1 }

Modified: projects/bsnmp-ipv6-mib/contrib/bsnmp/snmp_mibII/mibII.c
==============================================================================
--- projects/bsnmp-ipv6-mib/contrib/bsnmp/snmp_mibII/mibII.c	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/contrib/bsnmp/snmp_mibII/mibII.c	Mon Jan  9 18:35:41 2017	(r311805)
@@ -319,7 +319,7 @@ fetch_generic_mib(struct mibif *ifp, con
 	name[5] = IFDATA_GENERAL;
 
 	len = sizeof(ifp->mib);
-	if (sysctl(name, 6, &ifp->mib, &len, NULL, 0) == -1) {
+	if (sysctl(name, nitems(name), &ifp->mib, &len, NULL, 0) == -1) {
 		if (errno != ENOENT)
 			syslog(LOG_WARNING, "sysctl(ifmib, %s) failed %m",
 			    ifp->name);
@@ -480,7 +480,7 @@ mib_fetch_ifmib(struct mibif *ifp)
 	name[3] = IFMIB_IFDATA;
 	name[4] = ifp->sysindex;
 	name[5] = IFDATA_LINKSPECIFIC;
-	if (sysctl(name, 6, NULL, &len, NULL, 0) == -1) {
+	if (sysctl(name, nitems(name), NULL, &len, NULL, 0) == -1) {
 		syslog(LOG_WARNING, "sysctl linkmib estimate (%s): %m",
 		    ifp->name);
 		if (ifp->specmib != NULL) {
@@ -506,7 +506,7 @@ mib_fetch_ifmib(struct mibif *ifp)
 		ifp->specmib = newmib;
 		ifp->specmiblen = len;
 	}
-	if (sysctl(name, 6, ifp->specmib, &len, NULL, 0) == -1) {
+	if (sysctl(name, nitems(name), ifp->specmib, &len, NULL, 0) == -1) {
 		syslog(LOG_WARNING, "sysctl linkmib (%s): %m", ifp->name);
 		if (ifp->specmib != NULL) {
 			ifp->specmib = NULL;
@@ -902,7 +902,7 @@ mib_refresh_iflist(void)
 	for (idx = 1; idx <= count; idx++) {
 		name[4] = idx;
 		len = sizeof(mib);
-		if (sysctl(name, 6, &mib, &len, NULL, 0) == -1) {
+		if (sysctl(name, nitems(name), &mib, &len, NULL, 0) == -1) {
 			if (errno == ENOENT)
 				continue;
 			syslog(LOG_ERR, "ifmib(%u): %m", idx);
@@ -1213,7 +1213,7 @@ mib_fetch_rtab(int af, int info, int arg
 	*lenp = 0;
 
 	/* initial estimate */
-	if (sysctl(name, 6, NULL, lenp, NULL, 0) == -1) {
+	if (sysctl(name, nitems(name), NULL, lenp, NULL, 0) == -1) {
 		syslog(LOG_ERR, "sysctl estimate (%d,%d,%d,%d,%d,%d): %m",
 		    name[0], name[1], name[2], name[3], name[4], name[5]);
 		return (NULL);
@@ -1230,7 +1230,7 @@ mib_fetch_rtab(int af, int info, int arg
 		}
 		buf = newbuf;
 
-		if (sysctl(name, 6, buf, lenp, NULL, 0) == 0)
+		if (sysctl(name, nitems(name), buf, lenp, NULL, 0) == 0)
 			break;
 
 		if (errno != ENOMEM) {

Modified: projects/bsnmp-ipv6-mib/contrib/bsnmp/snmpd/BEGEMOT-MIB.txt
==============================================================================
--- projects/bsnmp-ipv6-mib/contrib/bsnmp/snmpd/BEGEMOT-MIB.txt	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/contrib/bsnmp/snmpd/BEGEMOT-MIB.txt	Mon Jan  9 18:35:41 2017	(r311805)
@@ -54,6 +54,9 @@ begemot MODULE-IDENTITY
 	     E-mail:	harti@freebsd.org"
     DESCRIPTION
 	    "The root of the Begemot subtree of the fokus tree."
+    REVISION "200201300000Z"
+    DESCRIPTION
+	    "Initial revision."
     ::= { fokus 1 }
 
 END

Modified: projects/bsnmp-ipv6-mib/contrib/bsnmp/snmpd/FOKUS-MIB.txt
==============================================================================
--- projects/bsnmp-ipv6-mib/contrib/bsnmp/snmpd/FOKUS-MIB.txt	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/contrib/bsnmp/snmpd/FOKUS-MIB.txt	Mon Jan  9 18:35:41 2017	(r311805)
@@ -52,6 +52,9 @@ fokus MODULE-IDENTITY
 	     E-mail:	harti@freebsd.org"
     DESCRIPTION
 	    "The root of the Fokus enterprises tree."
+    REVISION "200202050000Z"
+    DESCRIPTION
+	    "Initial revision."
     ::= { enterprises 12325 }
 
 END

Modified: projects/bsnmp-ipv6-mib/lib/libprocstat/Makefile
==============================================================================
--- projects/bsnmp-ipv6-mib/lib/libprocstat/Makefile	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/lib/libprocstat/Makefile	Mon Jan  9 18:35:41 2017	(r311805)
@@ -9,11 +9,11 @@ SRCS=	cd9660.c	\
 	common_kvm.c	\
 	core.c		\
 	libprocstat.c	\
-        msdosfs.c	\
+	msdosfs.c	\
 	smbfs.c		\
 	udf.c
 
-VERSION_DEF=	${.CURDIR}/Versions.def
+VERSION_DEF=	${LIBCSRCDIR}/Versions.def
 SYMBOL_MAPS=	${.CURDIR}/Symbol.map
 
 INCS=		libprocstat.h

Modified: projects/bsnmp-ipv6-mib/share/mk/bsd.README
==============================================================================
--- projects/bsnmp-ipv6-mib/share/mk/bsd.README	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/share/mk/bsd.README	Mon Jan  9 18:35:41 2017	(r311805)
@@ -410,6 +410,63 @@ If foo has multiple source files, add th
 
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
+The include file, <bsd.snmpmod.mk>, handles building MIB modules for bsnmpd
+from one or more source files, along with their manual pages.  It has a
+limited number of suffixes, consistent with the current needs of the BSD
+tree.
+
+bsd.snmpmod.mk leverages bsd.lib.mk for building MIB modules and
+bsd.files.mk for installing MIB description and definition files.
+
+It has no additional targets.
+
+It sets/uses the following variables:
+
+BMIBS		The MIB definitions to install.
+
+BMIBSDIR	The directory where the MIB definitions are installed.
+		This defaults to `${SHAREDIR}/snmp/mibs`.
+
+DEFS		The MIB description files to install.
+
+DEFSDIR		The directory where MIB description files are installed.
+		This defaults to `${SHAREDIR}/snmp/defs`.
+
+EXTRAMIBDEFS	Extra MIB description files to use as input when
+		generating ${MOD}_oid.h and ${MOD}_tree.[ch].
+
+EXTRAMIBSYMS	Extra MIB definition files used only for extracting
+		symbols.
+
+		EXTRAMIBSYMS are useful when resolving inter-module
+		dependencies and are useful with files containing only
+		enum-definitions.
+
+		See ${MOD}_oid.h for more details.
+
+MOD		The bsnmpd module name.
+
+XSYM		MIB names to extract symbols for. See ${MOD}_oid.h for
+		more details.
+
+It generates the following files:
+
+${MOD}_tree.c	A source file and header which programmatically describes
+${MOD}_tree.h	the MIB (type, OID name, ACCESS attributes, etc).
+
+		The files are generated via "gensnmptree -p".
+
+		See gensnmptree(1) for more details.
+
+${MOD}_oid.h	A header which programmatically describes the MIB root and
+		MIB tables.
+
+		The files are generated via "gensnmptree -e".
+
+		See gensnmptree(1) for more details.
+
+=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
 The include file <bsd.subdir.mk> contains the default targets for building
 subdirectories.  It has the same seven targets as <bsd.prog.mk>: all, clean,
 cleandir, depend, install, lint, and tags.  For all of the directories

Modified: projects/bsnmp-ipv6-mib/sys/arm/ti/ti_sdhci.c
==============================================================================
--- projects/bsnmp-ipv6-mib/sys/arm/ti/ti_sdhci.c	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/sys/arm/ti/ti_sdhci.c	Mon Jan  9 18:35:41 2017	(r311805)
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/mmc/mmcbrvar.h>
 
 #include <dev/sdhci/sdhci.h>
+#include <dev/sdhci/sdhci_fdt_gpio.h>
 #include "sdhci_if.h"
 
 #include <arm/ti/ti_cpuid.h>
@@ -61,7 +62,7 @@ __FBSDID("$FreeBSD$");
 
 struct ti_sdhci_softc {
 	device_t		dev;
-	device_t		gpio_dev;
+	struct sdhci_fdt_gpio * gpio;
 	struct resource *	mem_res;
 	struct resource *	irq_res;
 	void *			intr_cookie;
@@ -362,20 +363,24 @@ static int
 ti_sdhci_get_ro(device_t brdev, device_t reqdev)
 {
 	struct ti_sdhci_softc *sc = device_get_softc(brdev);
-	unsigned int readonly = 0;
 
-	/* If a gpio pin is configured, read it. */
-	if (sc->gpio_dev != NULL) {
-		GPIO_PIN_GET(sc->gpio_dev, sc->wp_gpio_pin, &readonly);
-	}
+	return (sdhci_fdt_gpio_get_readonly(sc->gpio));
+}
 
-	return (readonly);
+static bool
+ti_sdhci_get_card_present(device_t dev, struct sdhci_slot *slot)
+{
+	struct ti_sdhci_softc *sc = device_get_softc(dev);
+
+	return (sdhci_fdt_gpio_get_present(sc->gpio));
 }
 
 static int
 ti_sdhci_detach(device_t dev)
 {
 
+	/* sdhci_fdt_gpio_teardown(sc->gpio); */
+
 	return (EBUSY);
 }
 
@@ -502,25 +507,6 @@ ti_sdhci_attach(device_t dev)
 	}
 
 	/*
-	 * See if we've got a GPIO-based write detect pin.  This is not the
-	 * standard documented property for this, we added it in freebsd.
-	 */
-	if ((OF_getencprop(node, "mmchs-wp-gpio-pin", &prop, sizeof(prop))) <= 0)
-		sc->wp_gpio_pin = 0xffffffff;
-	else
-		sc->wp_gpio_pin = prop;
-
-	if (sc->wp_gpio_pin != 0xffffffff) {
-		sc->gpio_dev = devclass_get_device(devclass_find("gpio"), 0);
-		if (sc->gpio_dev == NULL) 
-			device_printf(dev, "Error: No GPIO device, "
-			    "Write Protect pin will not function\n");
-		else
-			GPIO_PIN_SETFLAGS(sc->gpio_dev, sc->wp_gpio_pin,
-			                  GPIO_PIN_INPUT);
-	}
-
-	/*
 	 * Set the offset from the device's memory start to the MMCHS registers.
 	 * Also for OMAP4 disable high speed mode due to erratum ID i626.
 	 */
@@ -572,6 +558,8 @@ ti_sdhci_attach(device_t dev)
 		goto fail;
 	}
 
+	sc->gpio = sdhci_fdt_gpio_setup(sc->dev, &sc->slot);
+
 	/* Initialise the MMCHS hardware. */
 	ti_sdhci_hw_init(dev);
 
@@ -706,6 +694,7 @@ static device_method_t ti_sdhci_methods[
 	DEVMETHOD(sdhci_write_2,	ti_sdhci_write_2),
 	DEVMETHOD(sdhci_write_4,	ti_sdhci_write_4),
 	DEVMETHOD(sdhci_write_multi_4,	ti_sdhci_write_multi_4),
+	DEVMETHOD(sdhci_get_card_present, ti_sdhci_get_card_present),
 
 	DEVMETHOD_END
 };

Modified: projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl.c
==============================================================================
--- projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl.c	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl.c	Mon Jan  9 18:35:41 2017	(r311805)
@@ -1,7 +1,7 @@
 /*-
  * Copyright (c) 2003-2009 Silicon Graphics International Corp.
  * Copyright (c) 2012 The FreeBSD Foundation
- * Copyright (c) 2015 Alexander Motin <mav@FreeBSD.org>
+ * Copyright (c) 2014-2017 Alexander Motin <mav@FreeBSD.org>
  * All rights reserved.
  *
  * Portions of this software were developed by Edward Tomasz Napierala
@@ -2567,6 +2567,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 	  struct thread *td)
 {
 	struct ctl_softc *softc = dev->si_drv1;
+	struct ctl_port *port;
 	struct ctl_lun *lun;
 	int retval;
 
@@ -2778,6 +2779,7 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 #endif /* CTL_IO_DELAY */
 		break;
 	}
+#ifdef CTL_LEGACY_STATS
 	case CTL_GETSTATS: {
 		struct ctl_stats *stats = (struct ctl_stats *)addr;
 		int i;
@@ -2790,26 +2792,26 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 		stats->status = CTL_SS_OK;
 		stats->fill_len = 0;
 		STAILQ_FOREACH(lun, &softc->lun_list, links) {
-			if (stats->fill_len + sizeof(lun->stats) >
+			if (stats->fill_len + sizeof(lun->legacy_stats) >
 			    stats->alloc_len) {
 				stats->status = CTL_SS_NEED_MORE_SPACE;
 				break;
 			}
-			retval = copyout(&lun->stats, &stats->lun_stats[i++],
-					 sizeof(lun->stats));
+			retval = copyout(&lun->legacy_stats, &stats->lun_stats[i++],
+					 sizeof(lun->legacy_stats));
 			if (retval != 0)
 				break;
-			stats->fill_len += sizeof(lun->stats);
+			stats->fill_len += sizeof(lun->legacy_stats);
 		}
 		stats->num_luns = softc->num_luns;
-#ifdef CTL_TIME_IO
-		stats->flags = CTL_STATS_FLAG_TIME_VALID;
-#else
 		stats->flags = CTL_STATS_FLAG_NONE;
+#ifdef CTL_TIME_IO
+		stats->flags |= CTL_STATS_FLAG_TIME_VALID;
 #endif
 		getnanouptime(&stats->timestamp);
 		break;
 	}
+#endif /* CTL_LEGACY_STATS */
 	case CTL_ERROR_INJECT: {
 		struct ctl_error_desc *err_desc, *new_err_desc;
 
@@ -3397,6 +3399,72 @@ ctl_ioctl(struct cdev *dev, u_long cmd, 
 			ctl_isc_announce_port(port);
 		break;
 	}
+	case CTL_GET_LUN_STATS: {
+		struct ctl_get_io_stats *stats = (struct ctl_get_io_stats *)addr;
+		int i;
+
+		/*
+		 * XXX KDM no locking here.  If the LUN list changes,
+		 * things can blow up.
+		 */
+		i = 0;
+		stats->status = CTL_SS_OK;
+		stats->fill_len = 0;
+		STAILQ_FOREACH(lun, &softc->lun_list, links) {
+			if (lun->lun < stats->first_item)
+				continue;
+			if (stats->fill_len + sizeof(lun->stats) >
+			    stats->alloc_len) {
+				stats->status = CTL_SS_NEED_MORE_SPACE;
+				break;
+			}
+			retval = copyout(&lun->stats, &stats->stats[i++],
+					 sizeof(lun->stats));
+			if (retval != 0)
+				break;
+			stats->fill_len += sizeof(lun->stats);
+		}
+		stats->num_items = softc->num_luns;
+		stats->flags = CTL_STATS_FLAG_NONE;
+#ifdef CTL_TIME_IO
+		stats->flags |= CTL_STATS_FLAG_TIME_VALID;
+#endif
+		getnanouptime(&stats->timestamp);
+		break;
+	}
+	case CTL_GET_PORT_STATS: {
+		struct ctl_get_io_stats *stats = (struct ctl_get_io_stats *)addr;
+		int i;
+
+		/*
+		 * XXX KDM no locking here.  If the LUN list changes,
+		 * things can blow up.
+		 */
+		i = 0;
+		stats->status = CTL_SS_OK;
+		stats->fill_len = 0;
+		STAILQ_FOREACH(port, &softc->port_list, links) {
+			if (port->targ_port < stats->first_item)
+				continue;
+			if (stats->fill_len + sizeof(port->stats) >
+			    stats->alloc_len) {
+				stats->status = CTL_SS_NEED_MORE_SPACE;
+				break;
+			}
+			retval = copyout(&port->stats, &stats->stats[i++],
+					 sizeof(port->stats));
+			if (retval != 0)
+				break;
+			stats->fill_len += sizeof(port->stats);
+		}
+		stats->num_items = softc->num_ports;
+		stats->flags = CTL_STATS_FLAG_NONE;
+#ifdef CTL_TIME_IO
+		stats->flags |= CTL_STATS_FLAG_TIME_VALID;
+#endif
+		getnanouptime(&stats->timestamp);
+		break;
+	}
 	default: {
 		/* XXX KDM should we fix this? */
 #if 0
@@ -4391,7 +4459,7 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft
 	struct scsi_vpd_id_descriptor *desc;
 	struct scsi_vpd_id_t10 *t10id;
 	const char *eui, *naa, *scsiname, *uuid, *vendor, *value;
-	int lun_number, i, lun_malloced;
+	int lun_number, lun_malloced;
 	int devidlen, idlen1, idlen2 = 0, len;
 
 	if (be_lun == NULL)
@@ -4585,6 +4653,10 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft
 	lun->ie_reported = 1;
 	callout_init_mtx(&lun->ie_callout, &lun->lun_lock, 0);
 	ctl_tpc_lun_init(lun);
+	if (lun->flags & CTL_LUN_REMOVABLE) {
+		lun->prevent = malloc((CTL_MAX_INITIATORS + 31) / 32 * 4,
+		    M_CTL, M_WAITOK);
+	}
 
 	/*
 	 * Initialize the mode and log page index.
@@ -4609,13 +4681,16 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft
 	ctl_softc->num_luns++;
 
 	/* Setup statistics gathering */
-	lun->stats.device_type = be_lun->lun_type;
-	lun->stats.lun_number = lun_number;
-	lun->stats.blocksize = be_lun->blocksize;
+#ifdef CTL_LEGACY_STATS
+	lun->legacy_stats.device_type = be_lun->lun_type;
+	lun->legacy_stats.lun_number = lun_number;
+	lun->legacy_stats.blocksize = be_lun->blocksize;
 	if (be_lun->blocksize == 0)
-		lun->stats.flags = CTL_LUN_STATS_NO_BLOCKSIZE;
-	for (i = 0;i < CTL_MAX_PORTS;i++)
-		lun->stats.ports[i].targ_port = i;
+		lun->legacy_stats.flags = CTL_LUN_STATS_NO_BLOCKSIZE;
+	for (len = 0; len < CTL_MAX_PORTS; len++)
+		lun->legacy_stats.ports[len].targ_port = len;
+#endif /* CTL_LEGACY_STATS */
+	lun->stats.item = lun_number;
 
 	mtx_unlock(&ctl_softc->ctl_lock);
 
@@ -4666,6 +4741,7 @@ ctl_free_lun(struct ctl_lun *lun)
 	for (i = 0; i < CTL_MAX_PORTS; i++)
 		free(lun->pr_keys[i], M_CTL);
 	free(lun->write_buffer, M_CTL);
+	free(lun->prevent, M_CTL);
 	if (lun->flags & CTL_LUN_MALLOCED)
 		free(lun, M_CTL);
 
@@ -5276,7 +5352,7 @@ ctl_prevent_allow(struct ctl_scsiio *cts
 
 	cdb = (struct scsi_prevent *)ctsio->cdb;
 
-	if ((lun->flags & CTL_LUN_REMOVABLE) == 0) {
+	if ((lun->flags & CTL_LUN_REMOVABLE) == 0 || lun->prevent == NULL) {
 		ctl_set_invalid_opcode(ctsio);
 		ctl_done((union ctl_io *)ctsio);
 		return (CTL_RETVAL_COMPLETE);
@@ -6680,9 +6756,7 @@ ctl_sap_log_sense_handler(struct ctl_scs
 {
 	struct ctl_lun *lun = CTL_LUN(ctsio);
 	struct stat_page *data;
-	uint64_t rn, wn, rb, wb;
-	struct bintime rt, wt;
-	int i;
+	struct bintime *t;
 
 	data = (struct stat_page *)page_index->page_data;
 
@@ -6690,28 +6764,21 @@ ctl_sap_log_sense_handler(struct ctl_scs
 	data->sap.hdr.param_control = SLP_LBIN;
 	data->sap.hdr.param_len = sizeof(struct scsi_log_stat_and_perf) -
 	    sizeof(struct scsi_log_param_header);
-	rn = wn = rb = wb = 0;
-	bintime_clear(&rt);
-	bintime_clear(&wt);
-	for (i = 0; i < CTL_MAX_PORTS; i++) {
-		rn += lun->stats.ports[i].operations[CTL_STATS_READ];
-		wn += lun->stats.ports[i].operations[CTL_STATS_WRITE];
-		rb += lun->stats.ports[i].bytes[CTL_STATS_READ];
-		wb += lun->stats.ports[i].bytes[CTL_STATS_WRITE];
-		bintime_add(&rt, &lun->stats.ports[i].time[CTL_STATS_READ]);
-		bintime_add(&wt, &lun->stats.ports[i].time[CTL_STATS_WRITE]);
-	}
-	scsi_u64to8b(rn, data->sap.read_num);
-	scsi_u64to8b(wn, data->sap.write_num);
-	if (lun->stats.blocksize > 0) {
-		scsi_u64to8b(wb / lun->stats.blocksize,
-		    data->sap.recvieved_lba);
-		scsi_u64to8b(rb / lun->stats.blocksize,
-		    data->sap.transmitted_lba);
+	scsi_u64to8b(lun->stats.operations[CTL_STATS_READ],
+	    data->sap.read_num);
+	scsi_u64to8b(lun->stats.operations[CTL_STATS_WRITE],
+	    data->sap.write_num);
+	if (lun->be_lun->blocksize > 0) {
+		scsi_u64to8b(lun->stats.bytes[CTL_STATS_WRITE] /
+		    lun->be_lun->blocksize, data->sap.recvieved_lba);
+		scsi_u64to8b(lun->stats.bytes[CTL_STATS_READ] /
+		    lun->be_lun->blocksize, data->sap.transmitted_lba);
 	}
-	scsi_u64to8b((uint64_t)rt.sec * 1000 + rt.frac / (UINT64_MAX / 1000),
+	t = &lun->stats.time[CTL_STATS_READ];
+	scsi_u64to8b((uint64_t)t->sec * 1000 + t->frac / (UINT64_MAX / 1000),
 	    data->sap.read_int);
-	scsi_u64to8b((uint64_t)wt.sec * 1000 + wt.frac / (UINT64_MAX / 1000),
+	t = &lun->stats.time[CTL_STATS_WRITE];
+	scsi_u64to8b((uint64_t)t->sec * 1000 + t->frac / (UINT64_MAX / 1000),
 	    data->sap.write_int);
 	scsi_u64to8b(0, data->sap.weighted_num);
 	scsi_u64to8b(0, data->sap.weighted_int);
@@ -11872,8 +11939,10 @@ ctl_do_lun_reset(struct ctl_lun *lun, un
 		ctl_clear_mask(lun->have_ca, i);
 #endif
 	lun->prevent_count = 0;
-	for (i = 0; i < CTL_MAX_INITIATORS; i++)
-		ctl_clear_mask(lun->prevent, i);
+	if (lun->prevent) {
+		for (i = 0; i < CTL_MAX_INITIATORS; i++)
+			ctl_clear_mask(lun->prevent, i);
+	}
 	mtx_unlock(&lun->lun_lock);
 
 	return (0);
@@ -12019,7 +12088,7 @@ ctl_i_t_nexus_reset(union ctl_io *io)
 #endif
 		if ((lun->flags & CTL_LUN_RESERVED) && (lun->res_idx == initidx))
 			lun->flags &= ~CTL_LUN_RESERVED;
-		if (ctl_is_set(lun->prevent, initidx)) {
+		if (lun->prevent && ctl_is_set(lun->prevent, initidx)) {
 			ctl_clear_mask(lun->prevent, initidx);
 			lun->prevent_count--;
 		}
@@ -13046,13 +13115,13 @@ static void
 ctl_process_done(union ctl_io *io)
 {
 	struct ctl_softc *softc = CTL_SOFTC(io);
+	struct ctl_port *port = CTL_PORT(io);
 	struct ctl_lun *lun = CTL_LUN(io);
 	void (*fe_done)(union ctl_io *io);
 	union ctl_ha_msg msg;
-	uint32_t targ_port = io->io_hdr.nexus.targ_port;
 
 	CTL_DEBUG_PRINT(("ctl_process_done\n"));
-	fe_done = softc->ctl_ports[targ_port]->fe_done;
+	fe_done = port->fe_done;
 
 #ifdef CTL_TIME_IO
 	if ((time_uptime - io->io_hdr.start_time) > ctl_time_io_secs) {
@@ -13155,11 +13224,13 @@ ctl_process_done(union ctl_io *io)
 	 */
 	if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS &&
 	    io->io_hdr.io_type == CTL_IO_SCSI) {
-#ifdef CTL_TIME_IO
-		struct bintime cur_bt;
-#endif
 		int type;
+#ifdef CTL_TIME_IO
+		struct bintime bt;
 
+		getbinuptime(&bt);
+		bintime_sub(&bt, &io->io_hdr.start_bt);
+#endif
 		if ((io->io_hdr.flags & CTL_FLAG_DATA_MASK) ==
 		    CTL_FLAG_DATA_IN)
 			type = CTL_STATS_READ;
@@ -13169,18 +13240,38 @@ ctl_process_done(union ctl_io *io)
 		else
 			type = CTL_STATS_NO_IO;
 
-		lun->stats.ports[targ_port].bytes[type] +=
+#ifdef CTL_LEGACY_STATS
+		uint32_t targ_port = port->targ_port;
+		lun->legacy_stats.ports[targ_port].bytes[type] +=
 		    io->scsiio.kern_total_len;
-		lun->stats.ports[targ_port].operations[type]++;
+		lun->legacy_stats.ports[targ_port].operations[type] ++;
+		lun->legacy_stats.ports[targ_port].num_dmas[type] +=
+		    io->io_hdr.num_dmas;
 #ifdef CTL_TIME_IO
-		bintime_add(&lun->stats.ports[targ_port].dma_time[type],
+		bintime_add(&lun->legacy_stats.ports[targ_port].dma_time[type],
 		   &io->io_hdr.dma_bt);
-		getbinuptime(&cur_bt);
-		bintime_sub(&cur_bt, &io->io_hdr.start_bt);
-		bintime_add(&lun->stats.ports[targ_port].time[type], &cur_bt);
+		bintime_add(&lun->legacy_stats.ports[targ_port].time[type],
+		    &bt);
 #endif
-		lun->stats.ports[targ_port].num_dmas[type] +=
-		    io->io_hdr.num_dmas;
+#endif /* CTL_LEGACY_STATS */
+
+		lun->stats.bytes[type] += io->scsiio.kern_total_len;
+		lun->stats.operations[type] ++;
+		lun->stats.dmas[type] += io->io_hdr.num_dmas;
+#ifdef CTL_TIME_IO
+		bintime_add(&lun->stats.dma_time[type], &io->io_hdr.dma_bt);
+		bintime_add(&lun->stats.time[type], &bt);
+#endif
+
+		mtx_lock(&port->port_lock);
+		port->stats.bytes[type] += io->scsiio.kern_total_len;
+		port->stats.operations[type] ++;
+		port->stats.dmas[type] += io->io_hdr.num_dmas;
+#ifdef CTL_TIME_IO
+		bintime_add(&port->stats.dma_time[type], &io->io_hdr.dma_bt);
+		bintime_add(&port->stats.time[type], &bt);
+#endif
+		mtx_unlock(&port->port_lock);
 	}
 
 	/*

Modified: projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_backend.h
==============================================================================
--- projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_backend.h	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_backend.h	Mon Jan  9 18:35:41 2017	(r311805)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2003 Silicon Graphics International Corp.
- * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org>
+ * Copyright (c) 2014-2017 Alexander Motin <mav@FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -40,54 +40,7 @@
 #ifndef	_CTL_BACKEND_H_
 #define	_CTL_BACKEND_H_
 
-/*
- * XXX KDM move this to another header file?
- */
-#define	CTL_BE_NAME_LEN		32
-
-/*
- * The ID_REQ flag is used to say that the caller has requested a
- * particular LUN ID in the req_lun_id field.  If we cannot allocate that
- * LUN ID, the ctl_add_lun() call will fail.
- *
- * The STOPPED flag tells us that the LUN should default to the powered
- * off state.  It will return 0x04,0x02 until it is powered up.  ("Logical
- * unit not ready, initializing command required.")
- *
- * The NO_MEDIA flag tells us that the LUN has no media inserted.
- *
- * The PRIMARY flag tells us that this LUN is registered as a Primary LUN
- * which is accessible via the Master shelf controller in an HA. This flag
- * being set indicates a Primary LUN. This flag being reset represents a
- * Secondary LUN controlled by the Secondary controller in an HA
- * configuration. Flag is applicable at this time to T_DIRECT types. 
- *
- * The SERIAL_NUM flag tells us that the serial_num field is filled in and
- * valid for use in SCSI INQUIRY VPD page 0x80.
- *
- * The DEVID flag tells us that the device_id field is filled in and
- * valid for use in SCSI INQUIRY VPD page 0x83.
- *
- * The DEV_TYPE flag tells us that the device_type field is filled in.
- *
- * The EJECTED flag tells us that the removable LUN has tray open.
- *
- * The UNMAP flag tells us that this LUN supports UNMAP.
- *
- * The OFFLINE flag tells us that this LUN can not access backing store.
- */
-typedef enum {
-	CTL_LUN_FLAG_ID_REQ		= 0x01,
-	CTL_LUN_FLAG_STOPPED		= 0x02,
-	CTL_LUN_FLAG_NO_MEDIA		= 0x04,
-	CTL_LUN_FLAG_PRIMARY		= 0x08,
-	CTL_LUN_FLAG_SERIAL_NUM		= 0x10,
-	CTL_LUN_FLAG_DEVID		= 0x20,
-	CTL_LUN_FLAG_DEV_TYPE		= 0x40,
-	CTL_LUN_FLAG_UNMAP		= 0x80,
-	CTL_LUN_FLAG_EJECTED		= 0x100,
-	CTL_LUN_FLAG_READONLY		= 0x200
-} ctl_backend_lun_flags;
+#include <cam/ctl/ctl_ioctl.h>
 
 typedef enum {
 	CTL_LUN_SERSEQ_OFF,

Modified: projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_frontend.c
==============================================================================
--- projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_frontend.c	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_frontend.c	Mon Jan  9 18:35:41 2017	(r311805)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003 Silicon Graphics International Corp.
+ * Copyright (c) 2014-2017 Alexander Motin <mav@FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -192,13 +193,14 @@ error:
 		mtx_unlock(&softc->ctl_lock);
 		return (retval);
 	}
+	port->targ_port = port_num;
 	port->ctl_pool_ref = pool;
-
 	if (port->options.stqh_first == NULL)
 		STAILQ_INIT(&port->options);
+	port->stats.item = port_num;
+	mtx_init(&port->port_lock, "CTL port", NULL, MTX_DEF);
 
 	mtx_lock(&softc->ctl_lock);
-	port->targ_port = port_num;
 	STAILQ_INSERT_TAIL(&port->frontend->port_list, port, fe_links);
 	for (tport = NULL, nport = STAILQ_FIRST(&softc->port_list);
 	    nport != NULL && nport->targ_port < port_num;
@@ -218,17 +220,11 @@ int
 ctl_port_deregister(struct ctl_port *port)
 {
 	struct ctl_softc *softc = port->ctl_softc;
-	struct ctl_io_pool *pool;
-	int retval, i;
-
-	retval = 0;
-
-	pool = (struct ctl_io_pool *)port->ctl_pool_ref;
+	struct ctl_io_pool *pool = (struct ctl_io_pool *)port->ctl_pool_ref;
+	int i;
 
-	if (port->targ_port == -1) {
-		retval = 1;
-		goto bailout;
-	}
+	if (port->targ_port == -1)
+		return (1);
 
 	mtx_lock(&softc->ctl_lock);
 	STAILQ_REMOVE(&softc->port_list, port, ctl_port, links);
@@ -251,9 +247,9 @@ ctl_port_deregister(struct ctl_port *por
 	for (i = 0; i < port->max_initiators; i++)
 		free(port->wwpn_iid[i].name, M_CTL);
 	free(port->wwpn_iid, M_CTL);
+	mtx_destroy(&port->port_lock);
 
-bailout:
-	return (retval);
+	return (0);
 }
 
 void

Modified: projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_frontend.h
==============================================================================
--- projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_frontend.h	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_frontend.h	Mon Jan  9 18:35:41 2017	(r311805)
@@ -1,5 +1,6 @@
 /*-
  * Copyright (c) 2003 Silicon Graphics International Corp.
+ * Copyright (c) 2014-2017 Alexander Motin <mav@FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -39,6 +40,8 @@
 #ifndef	_CTL_FRONTEND_H_
 #define	_CTL_FRONTEND_H_
 
+#include <cam/ctl/ctl_ioctl.h>
+
 typedef enum {
 	CTL_PORT_STATUS_NONE		= 0x00,
 	CTL_PORT_STATUS_ONLINE		= 0x01,
@@ -243,6 +246,8 @@ struct ctl_port {
 	struct ctl_devid *port_devid;		/* passed to CTL */
 	struct ctl_devid *target_devid;		/* passed to CTL */
 	struct ctl_devid *init_devid;		/* passed to CTL */
+	struct ctl_io_stats stats;		/* used by CTL */
+	struct mtx	port_lock;		/* used by CTL */
 	STAILQ_ENTRY(ctl_port) fe_links;	/* used by CTL */
 	STAILQ_ENTRY(ctl_port) links;		/* used by CTL */
 };

Modified: projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_ioctl.h
==============================================================================
--- projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_ioctl.h	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_ioctl.h	Mon Jan  9 18:35:41 2017	(r311805)
@@ -1,6 +1,7 @@
 /*-
  * Copyright (c) 2003 Silicon Graphics International Corp.
  * Copyright (c) 2011 Spectra Logic Corporation
+ * Copyright (c) 2014-2017 Alexander Motin <mav@FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -80,6 +81,9 @@
 /* Hopefully this won't conflict with new misc devices that pop up */
 #define	CTL_MINOR	225
 
+/* Legacy statistics accumulated for every port for every LU. */
+//#define CTL_LEGACY_STATS	1
+
 typedef enum {
 	CTL_DELAY_TYPE_NONE,
 	CTL_DELAY_TYPE_CONT,
@@ -117,6 +121,18 @@ typedef enum {
 #define	CTL_STATS_NUM_TYPES	3
 
 typedef enum {
+	CTL_SS_OK,
+	CTL_SS_NEED_MORE_SPACE,
+	CTL_SS_ERROR
+} ctl_stats_status;
+
+typedef enum {
+	CTL_STATS_FLAG_NONE		= 0x00,
+	CTL_STATS_FLAG_TIME_VALID	= 0x01
+} ctl_stats_flags;
+
+#ifdef CTL_LEGACY_STATS
+typedef enum {
 	CTL_LUN_STATS_NO_BLOCKSIZE	= 0x01
 } ctl_lun_stats_flags;
 
@@ -137,17 +153,6 @@ struct ctl_lun_io_stats {
 	struct ctl_lun_io_port_stats	ports[CTL_MAX_PORTS];
 };
 
-typedef enum {
-	CTL_SS_OK,
-	CTL_SS_NEED_MORE_SPACE,
-	CTL_SS_ERROR
-} ctl_stats_status;
-
-typedef enum {
-	CTL_STATS_FLAG_NONE		= 0x00,
-	CTL_STATS_FLAG_TIME_VALID	= 0x01
-} ctl_stats_flags;
-
 struct ctl_stats {
 	int			alloc_len;	/* passed to kernel */
 	struct ctl_lun_io_stats	*lun_stats;	/* passed to/from kernel */
@@ -157,6 +162,27 @@ struct ctl_stats {
 	ctl_stats_flags		flags;		/* passed to userland */
 	struct timespec		timestamp;	/* passed to userland */
 };
+#endif /* CTL_LEGACY_STATS */
+
+struct ctl_io_stats {
+	uint32_t			item;
+	uint64_t			bytes[CTL_STATS_NUM_TYPES];
+	uint64_t			operations[CTL_STATS_NUM_TYPES];
+	uint64_t			dmas[CTL_STATS_NUM_TYPES];
+	struct bintime			time[CTL_STATS_NUM_TYPES];
+	struct bintime			dma_time[CTL_STATS_NUM_TYPES];
+};
+
+struct ctl_get_io_stats {
+	struct ctl_io_stats	*stats;		/* passed to/from kernel */
+	size_t			alloc_len;	/* passed to kernel */
+	size_t			fill_len;	/* passed to userland */
+	int			first_item;	/* passed to kernel */
+	int			num_items;	/* passed to userland */
+	ctl_stats_status	status;		/* passed to userland */
+	ctl_stats_flags		flags;		/* passed to userland */
+	struct timespec		timestamp;	/* passed to userland */
+};
 
 /*
  * The types of errors that can be injected:
@@ -342,12 +368,54 @@ typedef enum {
 	CTL_LUNREQ_MODIFY,
 } ctl_lunreq_type;
 
+/*
+ * The ID_REQ flag is used to say that the caller has requested a
+ * particular LUN ID in the req_lun_id field.  If we cannot allocate that
+ * LUN ID, the ctl_add_lun() call will fail.
+ *
+ * The STOPPED flag tells us that the LUN should default to the powered
+ * off state.  It will return 0x04,0x02 until it is powered up.  ("Logical
+ * unit not ready, initializing command required.")
+ *
+ * The NO_MEDIA flag tells us that the LUN has no media inserted.
+ *
+ * The PRIMARY flag tells us that this LUN is registered as a Primary LUN
+ * which is accessible via the Master shelf controller in an HA. This flag
+ * being set indicates a Primary LUN. This flag being reset represents a
+ * Secondary LUN controlled by the Secondary controller in an HA
+ * configuration. Flag is applicable at this time to T_DIRECT types. 
+ *
+ * The SERIAL_NUM flag tells us that the serial_num field is filled in and
+ * valid for use in SCSI INQUIRY VPD page 0x80.
+ *
+ * The DEVID flag tells us that the device_id field is filled in and
+ * valid for use in SCSI INQUIRY VPD page 0x83.
+ *
+ * The DEV_TYPE flag tells us that the device_type field is filled in.
+ *
+ * The EJECTED flag tells us that the removable LUN has tray open.
+ *
+ * The UNMAP flag tells us that this LUN supports UNMAP.
+ *
+ * The OFFLINE flag tells us that this LUN can not access backing store.
+ */
+typedef enum {
+	CTL_LUN_FLAG_ID_REQ		= 0x01,
+	CTL_LUN_FLAG_STOPPED		= 0x02,
+	CTL_LUN_FLAG_NO_MEDIA		= 0x04,
+	CTL_LUN_FLAG_PRIMARY		= 0x08,
+	CTL_LUN_FLAG_SERIAL_NUM		= 0x10,
+	CTL_LUN_FLAG_DEVID		= 0x20,
+	CTL_LUN_FLAG_DEV_TYPE		= 0x40,
+	CTL_LUN_FLAG_UNMAP		= 0x80,
+	CTL_LUN_FLAG_EJECTED		= 0x100,
+	CTL_LUN_FLAG_READONLY		= 0x200
+} ctl_backend_lun_flags;
 
 /*
  * LUN creation parameters:
  *
- * flags:		Various LUN flags, see ctl_backend.h for a
- *			description of the flag values and meanings.
+ * flags:		Various LUN flags, see above.
  *
  * device_type:		The SCSI device type.  e.g. 0 for Direct Access,
  *			3 for Processor, etc.  Only certain backends may
@@ -465,6 +533,7 @@ union ctl_lunreq_data {
  * kern_be_args:	For kernel use only.
  */
 struct ctl_lun_req {
+#define	CTL_BE_NAME_LEN		32
 	char			backend[CTL_BE_NAME_LEN];
 	ctl_lunreq_type		reqtype;
 	union ctl_lunreq_data	reqdata;
@@ -777,6 +846,8 @@ struct ctl_lun_map {
 #define	CTL_PORT_REQ		_IOWR(CTL_MINOR, 0x26, struct ctl_req)
 #define	CTL_PORT_LIST		_IOWR(CTL_MINOR, 0x27, struct ctl_lun_list)
 #define	CTL_LUN_MAP		_IOW(CTL_MINOR, 0x28, struct ctl_lun_map)
+#define	CTL_GET_LUN_STATS	_IOWR(CTL_MINOR, 0x29, struct ctl_get_io_stats)
+#define	CTL_GET_PORT_STATS	_IOWR(CTL_MINOR, 0x2a, struct ctl_get_io_stats)
 
 #endif /* _CTL_IOCTL_H_ */
 

Modified: projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_private.h
==============================================================================
--- projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_private.h	Mon Jan  9 18:18:15 2017	(r311804)
+++ projects/bsnmp-ipv6-mib/sys/cam/ctl/ctl_private.h	Mon Jan  9 18:35:41 2017	(r311805)
@@ -1,6 +1,6 @@
 /*-
  * Copyright (c) 2003, 2004, 2005, 2008 Silicon Graphics International Corp.
- * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org>
+ * Copyright (c) 2014-2017 Alexander Motin <mav@FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -404,7 +404,10 @@ struct ctl_lun {
 	struct callout			ie_callout;	/* INTERVAL TIMER */
 	struct ctl_mode_pages		mode_pages;
 	struct ctl_log_pages		log_pages;
-	struct ctl_lun_io_stats		stats;
+#ifdef CTL_LEGACY_STATS
+	struct ctl_lun_io_stats		legacy_stats;
+#endif /* CTL_LEGACY_STATS */
+	struct ctl_io_stats		stats;
 	uint32_t			res_idx;
 	uint32_t			pr_generation;
 	uint64_t			*pr_keys[CTL_MAX_PORTS];
@@ -412,7 +415,7 @@ struct ctl_lun {
 	uint32_t			pr_res_idx;
 	uint8_t				pr_res_type;
 	int				prevent_count;
-	uint32_t			prevent[(CTL_MAX_INITIATORS+31)/32];
+	uint32_t			*prevent;
 	uint8_t				*write_buffer;
 	struct ctl_devid		*lun_devid;
 	TAILQ_HEAD(tpc_lists, tpc_list) tpc_lists;

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701091835.v09IZfwL023365>