changeset 4938:2f612e2f1503

6589668 naked constant in hme is incorrect, bcopies stack garbage somewhere it shouldn't go 6593956 After cpr resume, ultra-10 ultra-60 and ultra-80 systems lose communications cannot ping/be pinged 6594442 hme_m_start should return error when hardware init fails 6594448 hme minor cleanups
author gd78059
date Thu, 23 Aug 2007 20:40:28 -0700
parents 6bbd6595e537
children d8c715038e31
files usr/src/uts/sun/io/hme.c usr/src/uts/sun/sys/hme.h
diffstat 2 files changed, 18 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/sun/io/hme.c	Thu Aug 23 19:00:58 2007 -0700
+++ b/usr/src/uts/sun/io/hme.c	Thu Aug 23 20:40:28 2007 -0700
@@ -963,9 +963,7 @@
 static void
 hme_start_timer(struct hme *hmep, fptrv_t func, int msec)
 {
-	if (!(hmep->hme_flags & HMENOTIMEOUTS))
-		hmep->hme_timerid = timeout(func, (caddr_t)hmep,
-		    drv_usectohz(1000 * msec));
+	hmep->hme_timerid = timeout(func, hmep, drv_usectohz(1000 * msec));
 
 	mutex_exit(&hmep->hme_linklock);
 }
@@ -2740,8 +2738,6 @@
 		uint8_t j1;
 		uint16_t j2;
 	} *cfg_ptr;
-	boolean_t doinit;
-
 
 	switch (cmd) {
 	case DDI_ATTACH:
@@ -2754,10 +2750,7 @@
 		hmep->hme_flags &= ~HMESUSPENDED;
 		hmep->hme_linkcheck = 0;
 
-		mutex_enter(&hmep->hme_intrlock);
-		doinit = ((hmep->hme_flags & HMESTARTED) != 0);
-		mutex_exit(&hmep->hme_intrlock);
-		if (doinit)
+		if (hmep->hme_started)
 			(void) hmeinit(hmep);
 		return (DDI_SUCCESS);
 
@@ -3160,8 +3153,6 @@
 	 */
 	(void) hmestop(hmep);
 
-	ddi_remove_minor_node(dip, NULL);
-
 	/*
 	 * Remove instance of the intr
 	 */
@@ -3779,12 +3770,13 @@
 {
 	struct hme *hmep = arg;
 
-
-	mutex_enter(&hmep->hme_intrlock);
-	hmep->hme_flags |= HMESTARTED;
-	mutex_exit(&hmep->hme_intrlock);
-	(void) hmeinit(hmep);
-	return (0);
+	if (hmeinit(hmep) != 0) {
+		/* initialization failed -- really want DL_INITFAILED */
+		return (EIO);
+	} else {
+		hmep->hme_started = B_TRUE;
+		return (0);
+	}
 }
 
 static void
@@ -3792,9 +3784,7 @@
 {
 	struct hme *hmep = arg;
 
-	mutex_enter(&hmep->hme_intrlock);
-	hmep->hme_flags &= ~HMESTARTED;
-	mutex_exit(&hmep->hme_intrlock);
+	hmep->hme_started = B_FALSE;
 	hmeuninit(hmep);
 }
 
@@ -4126,7 +4116,7 @@
 			uint16_t sum;
 			sum = hme_cksum(mp->b_rptr + start_offset,
 			    len1 - start_offset);
-			bcopy(&sum, mp->b_rptr + stuff_offset, 20);
+			bcopy(&sum, mp->b_rptr + stuff_offset, sizeof (sum));
 			csflags = 0;
 		}
 
@@ -4413,7 +4403,8 @@
 				uint16_t sum;
 				sum = hme_cksum(bp->b_rptr + start_offset,
 				    len1 - start_offset);
-				bcopy(&sum, bp->b_rptr + stuff_offset, 2);
+				bcopy(&sum, bp->b_rptr + stuff_offset,
+				    sizeof (sum));
 				csflags = 0;
 			}
 
@@ -4650,12 +4641,6 @@
 	hmep->hme_tnextp = hmep->hme_tmdp;
 
 	/*
-	 * Determine if promiscuous mode.
-	 */
-	if (hmep->hme_promisc)
-		hmep->hme_flags |= HMEPROMISC;
-
-	/*
 	 * This is the right place to initialize MIF !!!
 	 */
 
@@ -4875,11 +4860,11 @@
 
 	if (hme_reject_own) {
 		PUT_MACREG(rxcfg,
-		    ((hmep->hme_flags & HMEPROMISC ? BMAC_RXCFG_PROMIS : 0) |
+		    ((hmep->hme_promisc ? BMAC_RXCFG_PROMIS : 0) |
 		    BMAC_RXCFG_MYOWN | BMAC_RXCFG_HASH));
 	} else {
 		PUT_MACREG(rxcfg,
-		    ((hmep->hme_flags & HMEPROMISC ? BMAC_RXCFG_PROMIS : 0) |
+		    ((hmep->hme_promisc ? BMAC_RXCFG_PROMIS : 0) |
 		    BMAC_RXCFG_HASH));
 	}
 
@@ -6082,7 +6067,7 @@
 #endif
 	if (hme_debug_level >= type) {
 		va_start(ap, fmt);
-		vsprintf(msg_buffer, fmt, ap);
+		vsnprintf(msg_buffer, sizeof (msg_buffer), fmt, ap);
 
 		cmn_err(CE_CONT, "D: %s (%d): %s\n",
 		    msg_string[type], line, msg_buffer);
@@ -6101,7 +6086,7 @@
 	va_list	ap;
 
 	va_start(ap, fmt);
-	(void) vsprintf(msg_buffer, fmt, ap);
+	(void) vsnprintf(msg_buffer, sizeof (msg_buffer), fmt, ap);
 
 	if (hmep == NULL) {
 		cmn_err(CE_NOTE, "hme : %s", msg_buffer);
--- a/usr/src/uts/sun/sys/hme.h	Thu Aug 23 19:00:58 2007 -0700
+++ b/usr/src/uts/sun/sys/hme.h	Thu Aug 23 20:40:28 2007 -0700
@@ -301,6 +301,7 @@
 	uint32_t		hme_addrflags;	/* address flags */
 	uint32_t		hme_flags;	/* misc. flags */
 	boolean_t		hme_wantw;	/* xmit: out of resources */
+	boolean_t		hme_started;	/* mac layer started */
 
 	uint16_t		hme_ladrf[4];	/* 64 bit multicast filter */
 	uint32_t		hme_ladrf_refcnt[64];
@@ -451,11 +452,8 @@
 
 /* flags */
 #define	HMERUNNING	0x01	/* chip is initialized */
-#define	HMEPROMISC	0x02	/* promiscuous mode enabled */
 #define	HMESUSPENDED	0x08	/* suspended interface */
 #define	HMEINITIALIZED	0x10	/* interface initialized */
-#define	HMENOTIMEOUTS	0x20	/* disallow timeout rescheduling */
-#define	HMESTARTED	0x40	/* upper layer initialized */
 
 /* Mac address flags */