changeset 10727:64d9f366e98f

6888680 GLDv3 PPA nits 6888202 vnic not available in early boot 6888700 potential fencepost errors involving MAX_PPA and MAX_MINOR
author Garrett D'Amore <gdamore@opensolaris.org>
date Wed, 07 Oct 2009 07:12:17 -0700
parents dd40023f03e8
children dc710e38fcc4
files usr/src/uts/common/io/dld/dld_str.c usr/src/uts/common/io/dls/dls_mgmt.c usr/src/uts/common/io/mac/mac_provider.c usr/src/uts/common/io/softmac/softmac_main.c
diffstat 4 files changed, 20 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/io/dld/dld_str.c	Tue Oct 06 16:59:04 2009 -0400
+++ b/usr/src/uts/common/io/dld/dld_str.c	Wed Oct 07 07:12:17 2009 -0700
@@ -155,7 +155,7 @@
 		 */
 		if (mh != NULL) {
 			statep->ds_dip = mac_devinfo_get(mh);
-			statep->ds_instance = mac_minor(mh) - 1;
+			statep->ds_instance = DLS_MINOR2INST(mac_minor(mh));
 		}
 		return (MH_WALK_TERMINATE);
 	}
@@ -202,8 +202,8 @@
 		return (-1);
 
 	/*
-	 * Check for style 2 unassociated node, this is quick and
-	 * easy.  Note that this doesn't *necessarily* work for legacy
+	 * Check for unopened style 1 node.
+	 * Note that this doesn't *necessarily* work for legacy
 	 * devices, but this code is only called within the
 	 * getinfo(9e) implementation for true GLDv3 devices, so it
 	 * doesn't matter.
@@ -228,7 +228,7 @@
  * instances are attached.  Hence, if a particular provider needs a
  * special mapping (the mac instance != ddi_get_instance()), then it
  * may need to provide its own implmentation using the
- * MAC_MINOR_TO_INSTANCE() function, and translating the returned mac
+ * mac_devt_to_instance() function, and translating the returned mac
  * instance to a devinfo instance.  For dev_t's where the minor number
  * is too large (i.e. > MAC_MAX_MINOR), the provider can call this
  * function indirectly via the mac_getinfo() function.
--- a/usr/src/uts/common/io/dls/dls_mgmt.c	Tue Oct 06 16:59:04 2009 -0400
+++ b/usr/src/uts/common/io/dls/dls_mgmt.c	Wed Oct 07 07:12:17 2009 -0700
@@ -1068,7 +1068,7 @@
 	 * Hold this link to prevent it being detached in case of a
 	 * GLDv3 physical link.
 	 */
-	if (DLS_MINOR2INST(getminor(dev)) < DLS_MAX_MINOR)
+	if (DLS_MINOR2INST(getminor(dev)) <= DLS_MAX_PPA)
 		(void) softmac_hold_device(dev, &ddh);
 
 	rw_enter(&i_dls_devnet_lock, RW_WRITER);
--- a/usr/src/uts/common/io/mac/mac_provider.c	Tue Oct 06 16:59:04 2009 -0400
+++ b/usr/src/uts/common/io/mac/mac_provider.c	Wed Oct 07 07:12:17 2009 -0700
@@ -403,7 +403,7 @@
 	dnp->dn_flags |= (DN_GLDV3_DRIVER | DN_NETWORK_DRIVER);
 	UNLOCK_DEV_OPS(&dnp->dn_lock);
 
-	if (mip->mi_minor < MAC_MAX_MINOR + 1) {
+	if (mip->mi_minor <= MAC_MAX_MINOR) {
 		/* Create a style-2 DLPI device */
 		if (ddi_create_minor_node(mip->mi_dip, driver, S_IFCHR, 0,
 		    DDI_NT_NET, CLONE_DEV) != DDI_SUCCESS)
--- a/usr/src/uts/common/io/softmac/softmac_main.c	Tue Oct 06 16:59:04 2009 -0400
+++ b/usr/src/uts/common/io/softmac/softmac_main.c	Wed Oct 07 07:12:17 2009 -0700
@@ -1509,21 +1509,13 @@
 	drvname = ddi_major_to_name(getmajor(dev));
 
 	/*
-	 * Exclude non-physical network device instances, for example, aggr0.
-	 */
-	if (!NETWORK_DRV(getmajor(dev)) || (strcmp(drvname, "aggr") == 0) ||
-	    (strcmp(drvname, "vnic") == 0)) {
-		return (ENOENT);
-	}
-
-	/*
 	 * We have to lookup the device instance using getinfo(9e).
 	 */
 	inst = dev_to_instance(dev);
 	if (inst < 0)
 		return (ENOENT);
 
-	if ((ppa = getminor(dev) - 1) > 1000)
+	if ((ppa = getminor(dev) - 1) > DLS_MAX_PPA)
 		return (ENOENT);
 
 	/*
@@ -1534,6 +1526,19 @@
 		return (ENOENT);
 
 	/*
+	 * Exclude non-physical network device instances, for example, aggr0.
+	 * Note: this check *must* occur after the dip is held, or else
+	 * NETWORK_DRV might return false incorrectly.  (Essentially, the
+	 * driver needs to be loaded to populate the dev_ops structure
+	 * that NETWORK_DRV checks.)
+	 */
+	if (!NETWORK_DRV(getmajor(dev)) || (strcmp(drvname, "aggr") == 0) ||
+	    (strcmp(drvname, "vnic") == 0)) {
+		ddi_release_devi(dip);
+		return (ENOENT);
+	}
+
+	/*
 	 * This is a network device; wait for its softmac to be registered.
 	 */
 	(void) snprintf(devname, MAXNAMELEN, "%s%d", drvname, ppa);