hamachi-0.07 diffs

Pete Wyckoff pw@dancer.ca.sandia.gov
Thu Mar 25 17:28:23 1999


Here's some changes to the standard 0.07 hamachi driver that have nothing
to do with checksumming :).  Some of these already made it into Eric's
hamachi-0.14, but others haven't.

Let me know if you'd like an explanation on any that aren't obvious.

		-- Pete


--- stock-0.07-hamachi.c	Fri Feb 19 13:56:16 1999
+++ fixed-0.07.c	Thu Mar 25 14:23:41 1999
@@ -76,7 +76,6 @@
 #include <linux/malloc.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
-#include <linux/bios32.h>
 #include <asm/processor.h>	/* Processor type for cache alignment. */
 #include <asm/bitops.h>
 #include <asm/io.h>
@@ -249,7 +248,7 @@
 /* Bits in the interrupt status/mask registers. */
 enum intr_status_bits {
 	IntrRxDone=0x01, IntrRxPCIFault=0x02, IntrRxPCIErr=0x04,
-	IntrTxDone=0x10, IntrTxPCIFault=0x20, IntrTxPCIErr=0x40,
+	IntrTxDone=0x100, IntrTxPCIFault=0x200, IntrTxPCIErr=0x400,
 	LinkChange=0x10000, NegotiationChange=0x20000, StatsMax=0x40000, };
 
 /* The Hamachi Rx and Tx buffer descriptors. */
@@ -495,11 +494,8 @@
 	dev->base_addr = ioaddr;
 	dev->irq = irq;
 
-	/* Make certain the descriptor lists are aligned. */
-	hmp = (void *)(((long)kmalloc(sizeof(*hmp), GFP_KERNEL) + 15) & ~15);
-	memset(hmp, 0, sizeof(*hmp));
-	dev->priv = hmp;
-
+	/* Private space is already zeroed and aligned.  --pw */
+	hmp = (struct hamachi_private *) dev->priv;
 	hmp->next_module = root_hamachi_dev;
 	root_hamachi_dev = dev;
 
@@ -666,7 +662,12 @@
 
 	/* Configure interrupt mitigation.  This has a great effect on
 	   performance, so systems tuning should start here!. */
-	writel(0x00080000, ioaddr + TxIntrCtrl);
+	/*
+	 * add in ff on TxMaxLat so the last packet of
+	 * a communication evenutally causes an interrupt and there's no
+	 * "Socket destroy delayed" hang.  --pw
+	 */
+	writel(0x000800ff, ioaddr + TxIntrCtrl);
 	writel(0x00000020, ioaddr + RxIntrCtrl);
 
 	set_rx_mode(dev);
@@ -722,9 +723,11 @@
 		       readw(ioaddr + 0x0e8),
 		       readw(ioaddr + 0x0eA));
 	}
-	/* We could do something here... nah. */
-	hmp->timer.expires = RUN_AT(next_tick);
-	add_timer(&hmp->timer);
+	if (hamachi_debug > 4) {
+		/* We could do something here... nah. */
+		hmp->timer.expires = RUN_AT(next_tick);
+		add_timer(&hmp->timer);
+	}
 }
 
 static void hamachi_tx_timeout(struct device *dev)
@@ -887,7 +890,7 @@
 
 		for (; hmp->cur_tx - hmp->dirty_tx > 0; hmp->dirty_tx++) {
 			int entry = hmp->dirty_tx % TX_RING_SIZE;
-			if (hmp->tx_ring[entry].status == 0)
+			if (hmp->tx_ring[entry].status & DescOwn)
 				break;
 			/* Free the original skb. */
 			DEV_FREE_SKB(hmp->tx_skbuff[entry]);
@@ -916,8 +919,13 @@
 	} while (1);
 
 	if (hamachi_debug > 3)
+#if (BITS_PER_LONG == 64)
 		printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
+			   dev->name, (u32) readl(ioaddr + IntrStatus));
+#else
+		printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4lx.\n",
 			   dev->name, readl(ioaddr + IntrStatus));
+#endif
 
 #ifndef final_version
 	/* Code that should never be run!  Perhaps remove after testing.. */
@@ -942,6 +950,7 @@
 {
 	struct hamachi_private *hmp = (struct hamachi_private *)dev->priv;
 	int entry = hmp->cur_rx % RX_RING_SIZE;
+	int first_entry = entry;
 	int boguscnt = 20;
 
 	if (hamachi_debug > 4) {
@@ -1035,6 +1044,8 @@
 		}
 		entry = (++hmp->cur_rx) % RX_RING_SIZE;
 		hmp->rx_head_desc = &hmp->rx_ring[entry];
+		if (entry == first_entry)  /* wrap around */
+			break;
 	}
 
 	/* Refill the Rx ring buffers. */
@@ -1072,11 +1083,19 @@
 
 	if (intr_status & (LinkChange|NegotiationChange)) {
 		if (hamachi_debug > 1)
+#if BITS_PER_LONG == 64
 			printk(KERN_INFO "%s: Link changed: AutoNegotiation Ctrl"
 				   " %4.4x, Status %4.4x %4.4x Intr status %4.4x.\n",
+				   dev->name, (u16) readw(ioaddr + 0x0E0), (u16) readw(ioaddr + 0x0E2),
+				   (u16) readw(ioaddr + ANLinkPartnerAbility),
+				   (u32) readl(ioaddr + IntrStatus));
+#else
+			printk(KERN_INFO "%s: Link changed: AutoNegotiation Ctrl"
+				   " %4.4x, Status %4.4x %4.4x Intr status %4.4lx.\n",
 				   dev->name, readw(ioaddr + 0x0E0), readw(ioaddr + 0x0E2),
 				   readw(ioaddr + ANLinkPartnerAbility),
 				   readl(ioaddr + IntrStatus));
+#endif
 		if (readw(ioaddr + ANStatus) & 0x20)
 			writeb(0x01, ioaddr + LEDCtrl);
 		else
@@ -1188,7 +1207,8 @@
 	/* We should lock this segment of code for SMP eventually, although
 	   the vulnerability window is very small and statistics are
 	   non-critical. */
-	hmp->stats.tx_packets	= readl(ioaddr + 0x000);
+	hmp->stats.tx_packets	= readl(ioaddr + 0x380);
+	hmp->stats.rx_packets	= readl(ioaddr + 0x300);
 #if LINUX_VERSION_CODE >= 0x20119
 	hmp->stats.rx_bytes = readl(ioaddr + 0x330); /* Total Uni+Brd+Multi */
 	hmp->stats.tx_bytes = readl(ioaddr + 0x3B0); /* Total Uni+Brd+Multi */
---------------------------------------------
Pete Wyckoff          | wyckoff@ca.sandia.gov
Sandia National Labs  | 925 294 3503 (voice)
MS 9011, P.O. Box 969 | 925 294 1225 (fax)
Livermore, CA  94551  |
 | To unsubscribe, send mail to Majordomo@cesdis.gsfc.nasa.gov, and within the
 |  body of the mail, include only the text:
 |   unsubscribe this-list-name youraddress@wherever.org
 | You will be unsubscribed as speedily as possible.