netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] (2/23) sk98: local variable can be constant
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
@ 2004-11-11 23:53   ` Stephen Hemminger
  2004-11-11 23:53   ` [PATCH] (3/23) sk98: /proc interface related changes Stephen Hemminger
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:53 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev


The table OnesHash is only used in this file, and should
be made a local constant.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skaddr.c b/drivers/net/sk98lin/skaddr.c
--- a/drivers/net/sk98lin/skaddr.c	2004-11-03 14:07:28 -08:00
+++ b/drivers/net/sk98lin/skaddr.c	2004-11-03 14:07:28 -08:00
@@ -79,7 +79,7 @@
 
 /* 64-bit hash values with all bits set. */
 
-SK_U16	OnesHash[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
+static const SK_U16	OnesHash[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
 
 /* local variables ************************************************************/
 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (3/23) sk98: /proc interface related changes
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
  2004-11-11 23:53   ` [PATCH] (2/23) sk98: local variable can be constant Stephen Hemminger
@ 2004-11-11 23:53   ` Stephen Hemminger
  2004-11-12 16:26     ` Christoph Hellwig
  2004-11-11 23:54   ` [PATCH] (4/23) sk98: use netdev_priv Stephen Hemminger
                     ` (19 subsequent siblings)
  21 siblings, 1 reply; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:53 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

The /proc intereface can be cleaned up a lot:
+ Pass the device to through the proc data/seq_private hook.
+ No longer needs to have a list of network devices 
+ use seq_printf directly rather than indirection into a buffer
+ failure to create proc directory or interface should not
  be fatal.
+ if PROC_FS not configured, let the stubs cause the necessary
  code elimination rather than using #ifdef

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>


diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-05 16:25:13 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-05 16:25:13 -08:00
@@ -266,7 +266,6 @@
 typedef struct s_DevNet DEV_NET;
 
 struct s_DevNet {
-	struct			proc_dir_entry *proc;
 	int             PortNr;
 	int             NetNr;
 	int             Mtu;
@@ -395,7 +394,7 @@
 	SK_U32		PciDevId;	/* pci device id */
 	struct SK_NET_DEVICE	*dev[2];	/* pointer to device struct */
 	char		Name[30];	/* driver name */
-	struct SK_NET_DEVICE	*Next;		/* link all devices (for clearing) */
+
 	int		RxBufSize;	/* length of receive buffers */
         struct net_device_stats stats;	/* linux 'netstat -i' statistics */
 	int		Index;		/* internal board index number */
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-05 16:25:13 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-05 16:25:13 -08:00
@@ -233,12 +233,27 @@
  * Extern Function Prototypes
  *
  ******************************************************************************/
-
-#ifdef CONFIG_PROC_FS
-static const char 	SK_Root_Dir_entry[] = "sk98lin";
+static const char 	SKRootName[] = "sk98lin";
 static struct		proc_dir_entry *pSkRootDir;
 extern struct	file_operations sk_proc_fops;
-#endif
+
+static inline void SkGeProcCreate(struct net_device *dev)
+{
+	struct proc_dir_entry *pe;
+
+	if (pSkRootDir && 
+	    (pe = create_proc_entry(dev->name, S_IRUGO, pSkRootDir))) {
+		pe->proc_fops = &sk_proc_fops;
+		pe->data = dev;
+		pe->owner = THIS_MODULE;
+	}
+}
+ 
+static inline void SkGeProcRemove(struct net_device *dev)
+{
+	if (pSkRootDir)
+		remove_proc_entry(dev->name, pSkRootDir);
+}
 
 extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);	
 extern void SkDimDisplayModerationSettings(SK_AC *pAC);
@@ -252,7 +267,6 @@
 #endif
 
 /* global variables *********************************************************/
-struct SK_NET_DEVICE *SkGeRootDev = NULL;
 static SK_BOOL DoPrintInterfaceChange = SK_TRUE;
 
 /* local variables **********************************************************/
@@ -601,12 +615,6 @@
 		return(-EAGAIN);
 	}
 
-	/*
-	 * Register the device here
-	 */
-	pAC->Next = SkGeRootDev;
-	SkGeRootDev = dev;
-
 	return (0);
 } /* SkGeBoardInit */
 
@@ -4876,9 +4884,6 @@
 	SK_AC			*pAC;
 	DEV_NET			*pNet = NULL;
 	struct net_device	*dev = NULL;
-#ifdef CONFIG_PROC_FS
-	struct proc_dir_entry	*pProcFile;
-#endif
 	static int boards_found = 0;
 	int error = -ENODEV;
 
@@ -4974,14 +4979,7 @@
 
 	memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
 
-#ifdef CONFIG_PROC_FS
-	pProcFile = create_proc_entry(dev->name, S_IRUGO, pSkRootDir);
-	if (pProcFile) {
-		pProcFile->proc_fops = &sk_proc_fops;
-		pProcFile->data = dev;
-		pProcFile->owner = THIS_MODULE;
-	}
-#endif
+	SkGeProcCreate(dev);
 
 	pNet->PortNr = 0;
 	pNet->NetNr  = 0;
@@ -5028,16 +5026,7 @@
 			free_netdev(dev);
 			pAC->dev[1] = pAC->dev[0];
 		} else {
-#ifdef CONFIG_PROC_FS
-			pProcFile = create_proc_entry(dev->name, S_IRUGO,
-					pSkRootDir);
-			if (pProcFile) {
-				pProcFile->proc_fops = &sk_proc_fops;
-				pProcFile->data = dev;
-				pProcFile->owner = THIS_MODULE;
-			}
-#endif
-
+			SkGeProcCreate(dev);
 			memcpy(&dev->dev_addr,
 					&pAC->Addr.Net[1].CurrentMacAddress, 6);
 	
@@ -5075,17 +5064,12 @@
 	struct net_device *dev = pci_get_drvdata(pdev);
 	DEV_NET *pNet = (DEV_NET *) dev->priv;
 	SK_AC *pAC = pNet->pAC;
-	int have_second_mac = 0;
-
-	if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2)
-		have_second_mac = 1;
+	struct net_device *otherdev = pAC->dev[1];
 
-	remove_proc_entry(dev->name, pSkRootDir);
+	SkGeProcRemove(dev);
 	unregister_netdev(dev);
-	if (have_second_mac) {
-		remove_proc_entry(pAC->dev[1]->name, pSkRootDir);
-		unregister_netdev(pAC->dev[1]);
-	}
+	if (otherdev != dev)
+		SkGeProcRemove(otherdev);
 
 	SkGeYellowLED(pAC, pAC->IoBase, 0);
 
@@ -5118,8 +5102,8 @@
 
 	FreeResources(dev);
 	free_netdev(dev);
-	if (have_second_mac)
-		free_netdev(pAC->dev[1]);
+	if (otherdev != dev)
+		free_netdev(otherdev);
 	kfree(pAC);
 }
 
@@ -5152,34 +5136,21 @@
 {
 	int error;
 
-#ifdef CONFIG_PROC_FS
-	memcpy(&SK_Root_Dir_entry, BOOT_STRING, sizeof(SK_Root_Dir_entry) - 1);
-
-	pSkRootDir = proc_mkdir(SK_Root_Dir_entry, proc_net);
-	if (!pSkRootDir) {
-		printk(KERN_WARNING "Unable to create /proc/net/%s",
-				SK_Root_Dir_entry);
-		return -ENOMEM;
-	}
-	pSkRootDir->owner = THIS_MODULE;
-#endif
-
-	error = pci_module_init(&skge_driver);
-	if (error) {
-#ifdef CONFIG_PROC_FS
-		remove_proc_entry(pSkRootDir->name, proc_net);
-#endif
-	}
-
+	pSkRootDir = proc_mkdir(SKRootName, proc_net);
+	if (pSkRootDir) 
+		pSkRootDir->owner = THIS_MODULE;
+	
+	error = pci_register_driver(&skge_driver);
+	if (error)
+		proc_net_remove(SKRootName);
 	return error;
 }
 
 static void __exit skge_exit(void)
 {
-	 pci_unregister_driver(&skge_driver);
-#ifdef CONFIG_PROC_FS
-	remove_proc_entry(pSkRootDir->name, proc_net);
-#endif
+	pci_unregister_driver(&skge_driver);
+	proc_net_remove(SKRootName);
+
 }
 
 module_init(skge_init);
diff -Nru a/drivers/net/sk98lin/skproc.c b/drivers/net/sk98lin/skproc.c
--- a/drivers/net/sk98lin/skproc.c	2004-11-05 16:25:13 -08:00
+++ b/drivers/net/sk98lin/skproc.c	2004-11-05 16:25:13 -08:00
@@ -31,13 +31,9 @@
 #include "h/skdrv2nd.h"
 #include "h/skversion.h"
 
-extern struct SK_NET_DEVICE *SkGeRootDev;
-static int sk_proc_print(void *writePtr, char *format, ...);
-static void sk_gen_browse(void *buffer);
-int len;
-
 static int sk_seq_show(struct seq_file *seq, void *v);
 static int sk_proc_open(struct inode *inode, struct file *file);
+
 struct file_operations sk_proc_fops = {
 	.owner		= THIS_MODULE,
 	.open		= sk_proc_open,
@@ -45,315 +41,206 @@
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
-struct net_device *currDev = NULL;
+
 
 /*****************************************************************************
  *
- * 	sk_gen_browse -generic  print "summaries" entry 
+ *      sk_seq_show - show proc information of a particular adapter
  *
  * Description:
  *  This function fills the proc entry with statistic data about 
- *  the ethernet device.
+ *  the ethernet device. It invokes the generic sk_gen_browse() to
+ *  print out all items one per one.
  *  
- * Returns: -
- *	
+ * Returns: 0
+ *      
  */
-static void sk_gen_browse(void *buffer)
+static int sk_seq_show(struct seq_file *seq, void *v)
 {
-	struct SK_NET_DEVICE	*SkgeProcDev = SkGeRootDev;
-	struct SK_NET_DEVICE	*next;
-	SK_PNMI_STRUCT_DATA 	*pPnmiStruct;
-	SK_PNMI_STAT		*pPnmiStat;
+	struct net_device *dev = seq->private;
+	DEV_NET			*pNet = netdev_priv(dev);
+	SK_AC			*pAC = pNet->pAC;
+	SK_PNMI_STRUCT_DATA 	*pPnmiStruct = &pAC->PnmiStruct;
 	unsigned long		Flags;	
 	unsigned int		Size;
-	DEV_NET			*pNet;
-	SK_AC			*pAC;
 	char			sens_msg[50];
-	int			MaxSecurityCount = 0;
 	int 			t;
 	int 			i;
 
-	while (SkgeProcDev) {
-		MaxSecurityCount++;
-		if (MaxSecurityCount > 100) {
-			printk("Max limit for sk_proc_read security counter!\n");
-			return;
-		}
-		pNet = (DEV_NET*) SkgeProcDev->priv;
-		pAC = pNet->pAC;
-		next = pAC->Next;
-		pPnmiStruct = &pAC->PnmiStruct;
-		/* NetIndex in GetStruct is now required, zero is only dummy */
-
-		for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
-			if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
-				t--;
+	/* NetIndex in GetStruct is now required, zero is only dummy */
+	for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
+		if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
+			t--;
 
-			spin_lock_irqsave(&pAC->SlowPathLock, Flags);
-			Size = SK_PNMI_STRUCT_SIZE;
+		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
+		Size = SK_PNMI_STRUCT_SIZE;
 #ifdef SK_DIAG_SUPPORT
-			if (pAC->BoardLevel == SK_INIT_DATA) {
-				SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
-				if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
-					pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
-				}
-			} else {
-				SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
+		if (pAC->BoardLevel == SK_INIT_DATA) {
+			SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
+			if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
+				pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
 			}
+		} else {
+			SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
+		}
 #else
-			SkPnmiGetStruct(pAC, pAC->IoBase, 
+		SkPnmiGetStruct(pAC, pAC->IoBase, 
 				pPnmiStruct, &Size, t-1);
 #endif
-			spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
+		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 	
-			if (strcmp(pAC->dev[t-1]->name, currDev->name) == 0) {
-				pPnmiStat = &pPnmiStruct->Stat[0];
-				len = sk_proc_print(buffer, 
-					"\nDetailed statistic for device %s\n",
-					pAC->dev[t-1]->name);
-				len += sk_proc_print(buffer,
-					"=======================================\n");
+		if (pAC->dev[t-1] == dev) {
+			SK_PNMI_STAT	*pPnmiStat = &pPnmiStruct->Stat[0];
+
+			seq_printf(seq, "\nDetailed statistic for device %s\n",
+				      pAC->dev[t-1]->name);
+			seq_printf(seq, "=======================================\n");
 	
-				/* Board statistics */
-				len += sk_proc_print(buffer, 
-					"\nBoard statistics\n\n");
-				len += sk_proc_print(buffer,
-					"Active Port                    %c\n",
-					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
-					Net[t-1].PrefPort]->PortNumber);
-				len += sk_proc_print(buffer,
-					"Preferred Port                 %c\n",
-					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
-					Net[t-1].PrefPort]->PortNumber);
-
-				len += sk_proc_print(buffer,
-					"Bus speed (MHz)                %d\n",
-					pPnmiStruct->BusSpeed);
-
-				len += sk_proc_print(buffer,
-					"Bus width (Bit)                %d\n",
-					pPnmiStruct->BusWidth);
-				len += sk_proc_print(buffer,
-					"Driver version                 %s\n",
-					VER_STRING);
-				len += sk_proc_print(buffer,
-					"Hardware revision              v%d.%d\n",
-					(pAC->GIni.GIPciHwRev >> 4) & 0x0F,
-					pAC->GIni.GIPciHwRev & 0x0F);
-
-				/* Print sensor informations */
-				for (i=0; i < pAC->I2c.MaxSens; i ++) {
-					/* Check type */
-					switch (pAC->I2c.SenTable[i].SenType) {
-					case 1:
-						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
-						strcat(sens_msg, " (C)");
-						len += sk_proc_print(buffer,
-							"%-25s      %d.%02d\n",
-							sens_msg,
-							pAC->I2c.SenTable[i].SenValue / 10,
-							pAC->I2c.SenTable[i].SenValue % 10);
-
-						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
-						strcat(sens_msg, " (F)");
-						len += sk_proc_print(buffer,
-							"%-25s      %d.%02d\n",
-							sens_msg,
-							((((pAC->I2c.SenTable[i].SenValue)
-							*10)*9)/5 + 3200)/100,
-							((((pAC->I2c.SenTable[i].SenValue)
-							*10)*9)/5 + 3200) % 10);
-						break;
-					case 2:
-						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
-						strcat(sens_msg, " (V)");
-						len += sk_proc_print(buffer,
-							"%-25s      %d.%03d\n",
-							sens_msg,
-							pAC->I2c.SenTable[i].SenValue / 1000,
-							pAC->I2c.SenTable[i].SenValue % 1000);
-						break;
-					case 3:
-						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
-						strcat(sens_msg, " (rpm)");
-						len += sk_proc_print(buffer,
-							"%-25s      %d\n",
-							sens_msg,
-							pAC->I2c.SenTable[i].SenValue);
-						break;
-					default:
-						break;
-					}
+			/* Board statistics */
+			seq_printf(seq, "\nBoard statistics\n\n");
+			seq_printf(seq, "Active Port                    %c\n",
+				      'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
+								    Net[t-1].PrefPort]->PortNumber);
+			seq_printf(seq, "Preferred Port                 %c\n",
+				      'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
+								    Net[t-1].PrefPort]->PortNumber);
+
+			seq_printf(seq, "Bus speed (MHz)                %d\n",
+				      pPnmiStruct->BusSpeed);
+
+			seq_printf(seq, "Bus width (Bit)                %d\n",
+				      pPnmiStruct->BusWidth);
+			seq_printf(seq, "Driver version                 %s\n",
+				      VER_STRING);
+			seq_printf(seq, "Hardware revision              v%d.%d\n",
+				      (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
+				      pAC->GIni.GIPciHwRev & 0x0F);
+
+			/* Print sensor informations */
+			for (i=0; i < pAC->I2c.MaxSens; i ++) {
+				/* Check type */
+				switch (pAC->I2c.SenTable[i].SenType) {
+				case 1:
+					strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+					strcat(sens_msg, " (C)");
+					seq_printf(seq, "%-25s      %d.%02d\n",
+						      sens_msg,
+						      pAC->I2c.SenTable[i].SenValue / 10,
+						      pAC->I2c.SenTable[i].SenValue % 10);
+
+					strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+					strcat(sens_msg, " (F)");
+					seq_printf(seq, "%-25s      %d.%02d\n",
+						      sens_msg,
+						      ((((pAC->I2c.SenTable[i].SenValue)
+							 *10)*9)/5 + 3200)/100,
+						      ((((pAC->I2c.SenTable[i].SenValue)
+							 *10)*9)/5 + 3200) % 10);
+					break;
+				case 2:
+					strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+					strcat(sens_msg, " (V)");
+					seq_printf(seq, "%-25s      %d.%03d\n",
+						      sens_msg,
+						      pAC->I2c.SenTable[i].SenValue / 1000,
+						      pAC->I2c.SenTable[i].SenValue % 1000);
+					break;
+				case 3:
+					strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
+					strcat(sens_msg, " (rpm)");
+					seq_printf(seq, "%-25s      %d\n",
+						      sens_msg,
+						      pAC->I2c.SenTable[i].SenValue);
+					break;
+				default:
+					break;
 				}
+			}
 				
-				/*Receive statistics */
-				len += sk_proc_print(buffer, 
-				"\nReceive statistics\n\n");
-
-				len += sk_proc_print(buffer,
-					"Received bytes                 %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxOctetsOkCts);
-				len += sk_proc_print(buffer,
-					"Received packets               %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxOkCts);
+			/*Receive statistics */
+			seq_printf(seq, "\nReceive statistics\n\n");
+
+			seq_printf(seq, "Received bytes                 %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
+			seq_printf(seq, "Received packets               %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxOkCts);
 #if 0
-				if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && 
-					pAC->HWRevision < 12) {
-					pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts - 
-						pPnmiStat->StatRxShortsCts;
-					pPnmiStat->StatRxShortsCts = 0;
-				}
+			if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && 
+			    pAC->HWRevision < 12) {
+				pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts - 
+					pPnmiStat->StatRxShortsCts;
+				pPnmiStat->StatRxShortsCts = 0;
+			}
 #endif
-				if (pNet->Mtu > 1500) 
-					pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
-						pPnmiStat->StatRxTooLongCts;
-
-				len += sk_proc_print(buffer,
-					"Receive errors                 %Lu\n",
-					(unsigned long long) pPnmiStruct->InErrorsCts);
-				len += sk_proc_print(buffer,
-					"Receive dropped                %Lu\n",
-					(unsigned long long) pPnmiStruct->RxNoBufCts);
-				len += sk_proc_print(buffer,
-					"Received multicast             %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxMulticastOkCts);
-				len += sk_proc_print(buffer,
-					"Receive error types\n");
-				len += sk_proc_print(buffer,
-					"   length                      %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxRuntCts);
-				len += sk_proc_print(buffer,
-					"   buffer overflow             %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
-				len += sk_proc_print(buffer,
-					"   bad crc                     %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxFcsCts);
-				len += sk_proc_print(buffer,
-					"   framing                     %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxFramingCts);
-				len += sk_proc_print(buffer,
-					"   missed frames               %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxMissedCts);
-
-				if (pNet->Mtu > 1500)
-					pPnmiStat->StatRxTooLongCts = 0;
-
-				len += sk_proc_print(buffer,
-					"   too long                    %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxTooLongCts);					
-				len += sk_proc_print(buffer,
-					"   carrier extension           %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxCextCts);				
-				len += sk_proc_print(buffer,
-					"   too short                   %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxShortsCts);				
-				len += sk_proc_print(buffer,
-					"   symbol                      %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxSymbolCts);				
-				len += sk_proc_print(buffer,
-					"   LLC MAC size                %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxIRLengthCts);				
-				len += sk_proc_print(buffer,
-					"   carrier event               %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxCarrierCts);				
-				len += sk_proc_print(buffer,
-					"   jabber                      %Lu\n",
-					(unsigned long long) pPnmiStat->StatRxJabberCts);				
-
-
-				/*Transmit statistics */
-				len += sk_proc_print(buffer, 
-				"\nTransmit statistics\n\n");
+			if (dev->mtu > 1500)
+				pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
+					pPnmiStat->StatRxTooLongCts;
+
+			seq_printf(seq, "Receive errors                 %Lu\n",
+				      (unsigned long long) pPnmiStruct->InErrorsCts);
+			seq_printf(seq, "Receive dropped                %Lu\n",
+				      (unsigned long long) pPnmiStruct->RxNoBufCts);
+			seq_printf(seq, "Received multicast             %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
+			seq_printf(seq, "Receive error types\n");
+			seq_printf(seq, "   length                      %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxRuntCts);
+			seq_printf(seq, "   buffer overflow             %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
+			seq_printf(seq, "   bad crc                     %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxFcsCts);
+			seq_printf(seq, "   framing                     %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxFramingCts);
+			seq_printf(seq, "   missed frames               %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxMissedCts);
+
+			if (dev->mtu > 1500)
+				pPnmiStat->StatRxTooLongCts = 0;
+
+			seq_printf(seq, "   too long                    %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxTooLongCts);					
+			seq_printf(seq, "   carrier extension           %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxCextCts);				
+			seq_printf(seq, "   too short                   %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxShortsCts);				
+			seq_printf(seq, "   symbol                      %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxSymbolCts);				
+			seq_printf(seq, "   LLC MAC size                %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxIRLengthCts);				
+			seq_printf(seq, "   carrier event               %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxCarrierCts);				
+			seq_printf(seq, "   jabber                      %Lu\n",
+				      (unsigned long long) pPnmiStat->StatRxJabberCts);				
+
+
+			/*Transmit statistics */
+			seq_printf(seq, "\nTransmit statistics\n\n");
 				
-				len += sk_proc_print(buffer,
-					"Transmited bytes               %Lu\n",
-					(unsigned long long) pPnmiStat->StatTxOctetsOkCts);
-				len += sk_proc_print(buffer,
-					"Transmited packets             %Lu\n",
-					(unsigned long long) pPnmiStat->StatTxOkCts);
-				len += sk_proc_print(buffer,
-					"Transmit errors                %Lu\n",
-					(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
-				len += sk_proc_print(buffer,
-					"Transmit dropped               %Lu\n",
-					(unsigned long long) pPnmiStruct->TxNoBufCts);
-				len += sk_proc_print(buffer,
-					"Transmit collisions            %Lu\n",
-					(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
-				len += sk_proc_print(buffer,
-					"Transmit error types\n");
-				len += sk_proc_print(buffer,
-					"   excessive collision         %ld\n",
-					pAC->stats.tx_aborted_errors);
-				len += sk_proc_print(buffer,
-					"   carrier                     %Lu\n",
-					(unsigned long long) pPnmiStat->StatTxCarrierCts);
-				len += sk_proc_print(buffer,
-					"   fifo underrun               %Lu\n",
-					(unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
-				len += sk_proc_print(buffer,
-					"   heartbeat                   %Lu\n",
-					(unsigned long long) pPnmiStat->StatTxCarrierCts);
-				len += sk_proc_print(buffer,
-					"   window                      %ld\n",
-					pAC->stats.tx_window_errors);
+			seq_printf(seq, "Transmited bytes               %Lu\n",
+				      (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
+			seq_printf(seq, "Transmited packets             %Lu\n",
+				      (unsigned long long) pPnmiStat->StatTxOkCts);
+			seq_printf(seq, "Transmit errors                %Lu\n",
+				      (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
+			seq_printf(seq, "Transmit dropped               %Lu\n",
+				      (unsigned long long) pPnmiStruct->TxNoBufCts);
+			seq_printf(seq, "Transmit collisions            %Lu\n",
+				      (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
+			seq_printf(seq, "Transmit error types\n");
+			seq_printf(seq, "   excessive collision         %ld\n",
+				      pAC->stats.tx_aborted_errors);
+			seq_printf(seq, "   carrier                     %Lu\n",
+				      (unsigned long long) pPnmiStat->StatTxCarrierCts);
+			seq_printf(seq, "   fifo underrun               %Lu\n",
+				      (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
+			seq_printf(seq, "   heartbeat                   %Lu\n",
+				      (unsigned long long) pPnmiStat->StatTxCarrierCts);
+			seq_printf(seq, "   window                      %ld\n",
+				      pAC->stats.tx_window_errors);
 				
-			} /* if (strcmp(pACname, currDeviceName) == 0) */
 		}
-		SkgeProcDev = next;
 	}
-}
-
-/*****************************************************************************
- *
- *      sk_proc_print -generic line print  
- *
- * Description:
- *  This function fills the proc entry with statistic data about 
- *  the ethernet device.
- *  
- * Returns: number of bytes written
- *      
- */ 
-static int sk_proc_print(void *writePtr, char *format, ...)
-{   
-#define MAX_LEN_SINGLE_LINE 256
-	char     str[MAX_LEN_SINGLE_LINE];
-	va_list  a_start;
-	int      lenght = 0;
-
-	struct seq_file *seq = (struct seq_file *) writePtr;
-
-	SK_MEMSET(str, 0, MAX_LEN_SINGLE_LINE);
-
-	va_start(a_start, format);
-	vsprintf(str, format, a_start);
-	va_end(a_start);
-
-	lenght = strlen(str);
-
-	seq_printf(seq, str);
-	return lenght;
-}
-
-/*****************************************************************************
- *
- *      sk_seq_show - show proc information of a particular adapter
- *
- * Description:
- *  This function fills the proc entry with statistic data about 
- *  the ethernet device. It invokes the generic sk_gen_browse() to
- *  print out all items one per one.
- *  
- * Returns: number of bytes written
- *      
- */
-static int sk_seq_show(struct seq_file *seq, void *v)
-{
-    void *castedBuffer = (void *) seq;
-    currDev = seq->private;
-    sk_gen_browse(castedBuffer);
-    return 0;
+	return 0;
 }
 
 /*****************************************************************************

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (4/23) sk98: use netdev_priv
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
  2004-11-11 23:53   ` [PATCH] (2/23) sk98: local variable can be constant Stephen Hemminger
  2004-11-11 23:53   ` [PATCH] (3/23) sk98: /proc interface related changes Stephen Hemminger
@ 2004-11-11 23:54   ` Stephen Hemminger
  2004-11-11 23:54   ` [PATCH] (5/23) sk98: use module_param Stephen Hemminger
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:54 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Use netdev_priv when dereferenceing net_device private

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 14:07:58 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 14:07:58 -08:00
@@ -337,22 +337,20 @@
 DEV_NET		*pNet;
 SK_AC		*pAC;
 
-	if (dev->priv) {
-		pNet = (DEV_NET*) dev->priv;
-		pAC = pNet->pAC;
-		AllocFlag = pAC->AllocFlag;
-		if (pAC->PciDev) {
-			pci_release_regions(pAC->PciDev);
-		}
-		if (AllocFlag & SK_ALLOC_IRQ) {
-			free_irq(dev->irq, dev);
-		}
-		if (pAC->IoBase) {
-			iounmap(pAC->IoBase);
-		}
-		if (pAC->pDescrMem) {
-			BoardFreeMem(pAC);
-		}
+	pNet = netdev_priv(dev);
+	pAC = pNet->pAC;
+	AllocFlag = pAC->AllocFlag;
+	if (pAC->PciDev) {
+		pci_release_regions(pAC->PciDev);
+	}
+	if (AllocFlag & SK_ALLOC_IRQ) {
+		free_irq(dev->irq, dev);
+	}
+	if (pAC->IoBase) {
+		iounmap(pAC->IoBase);
+	}
+	if (pAC->pDescrMem) {
+		BoardFreeMem(pAC);
 	}
 	
 } /* FreeResources */
@@ -887,7 +885,7 @@
 SK_AC		*pAC;
 SK_U32		IntSrc;		/* interrupts source register contents */	
 
-	pNet = (DEV_NET*) dev->priv;
+	pNet = netdev_priv(dev);
 	pAC = pNet->pAC;
 	
 	/*
@@ -1036,7 +1034,7 @@
 SK_AC		*pAC;
 SK_U32		IntSrc;		/* interrupts source register contents */	
 
-	pNet = (DEV_NET*) dev->priv;
+	pNet = netdev_priv(dev);
 	pAC = pNet->pAC;
 	
 	/*
@@ -1152,7 +1150,7 @@
 	int				i;
 	SK_EVPARA		EvPara;		/* an event parameter union */
 
-	pNet = (DEV_NET*) dev->priv;
+	pNet = netdev_priv(dev);
 	pAC = pNet->pAC;
 	
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
@@ -1273,7 +1271,7 @@
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeClose: pAC=0x%lX ", (unsigned long)pAC));
 
-	pNet = (DEV_NET*) dev->priv;
+	pNet = netdev_priv(dev);
 	pAC = pNet->pAC;
 
 #ifdef SK_DIAG_SUPPORT
@@ -1284,7 +1282,7 @@
 			** by operator interaction must not be started up 
 			** again when the DIAG has finished. 
 			*/
-			newPtrNet = (DEV_NET *) pAC->dev[0]->priv;
+			newPtrNet = netdev_priv(pAC->dev[0]);
 			if (newPtrNet == pNet) {
 				pAC->WasIfUp[0] = SK_FALSE;
 			} else {
@@ -1394,7 +1392,7 @@
 SK_AC		*pAC;
 int			Rc;	/* return code of XmitFrame */
 
-	pNet = (DEV_NET*) dev->priv;
+	pNet = netdev_priv(dev);
 	pAC = pNet->pAC;
 
 	if ((!skb_shinfo(skb)->nr_frags) ||
@@ -2490,7 +2488,7 @@
 static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p)
 {
 
-DEV_NET *pNet = (DEV_NET*) dev->priv;
+DEV_NET *pNet = netdev_priv(dev);
 SK_AC	*pAC = pNet->pAC;
 
 struct sockaddr	*addr = p;
@@ -2547,7 +2545,7 @@
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeSetRxMode starts now... "));
 
-	pNet = (DEV_NET*) dev->priv;
+	pNet = netdev_priv(dev);
 	pAC = pNet->pAC;
 	if (pAC->RlmtNets == 1)
 		PortIdx = pAC->ActivePort;
@@ -2619,7 +2617,7 @@
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeChangeMtu starts now...\n"));
 
-	pNet = (DEV_NET*) dev->priv;
+	pNet = netdev_priv(dev);
 	pAC  = pNet->pAC;
 
 	if ((NewMtu < 68) || (NewMtu > SK_JUMBO_MTU)) {
@@ -2641,7 +2639,7 @@
 #endif
 
 	pNet->Mtu = NewMtu;
-	pOtherNet = (DEV_NET*)pAC->dev[1 - pNet->NetNr]->priv;
+	pOtherNet = netdev_priv(pAC->dev[1 - pNet->NetNr]);
 	if ((pOtherNet->Mtu>1500) && (NewMtu<=1500) && (pOtherNet->Up==1)) {
 		return(0);
 	}
@@ -2847,7 +2845,7 @@
  */
 static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev)
 {
-DEV_NET *pNet = (DEV_NET*) dev->priv;
+DEV_NET *pNet = netdev_priv(dev);
 SK_AC	*pAC = pNet->pAC;
 SK_PNMI_STRUCT_DATA *pPnmiStruct;       /* structure for all Pnmi-Data */
 SK_PNMI_STAT    *pPnmiStat;             /* pointer to virtual XMAC stat. data */
@@ -2945,7 +2943,7 @@
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeIoctl starts now...\n"));
 
-	pNet = (DEV_NET*) dev->priv;
+	pNet = netdev_priv(dev);
 	pAC = pNet->pAC;
 	
 	if(copy_from_user(&Ioctl, rq->ifr_data, sizeof(SK_GE_IOCTL))) {
@@ -4531,11 +4529,8 @@
 int SkDrvEnterDiagMode(
 SK_AC   *pAc)   /* pointer to adapter context */
 {
-	SK_AC   *pAC  = NULL;
-	DEV_NET *pNet = NULL;
-
-	pNet = (DEV_NET *) pAc->dev[0]->priv;
-	pAC = pNet->pAC;
+	DEV_NET *pNet = netdev_priv(pAc->dev[0]);
+	SK_AC   *pAC  = pNet->pAC;
 
 	SK_MEMCPY(&(pAc->PnmiBackup), &(pAc->PnmiStruct), 
 			sizeof(SK_PNMI_STRUCT_DATA));
@@ -4550,8 +4545,8 @@
 		} else {
 			pAC->WasIfUp[0] = SK_FALSE;
 		}
-		if (pNet != (DEV_NET *) pAc->dev[1]->priv) {
-			pNet = (DEV_NET *) pAc->dev[1]->priv;
+		if (pNet != netdev_priv(pAC->dev[1])) {
+			pNet = netdev_priv(pAC->dev[1]);
 			if (pNet->Up) {
 				pAC->WasIfUp[1] = SK_TRUE;
 				pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
@@ -4897,7 +4892,7 @@
 		goto out_disable_device;
 	}
 
-	pNet = dev->priv;
+	pNet = netdev_priv(dev);
 	pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
 	if (!pNet->pAC) {
 		printk(KERN_ERR "Unable to allocate adapter "
@@ -4997,7 +4992,7 @@
 		}
 
 		pAC->dev[1]   = dev;
-		pNet          = dev->priv;
+		pNet          = netdev_priv(dev);
 		pNet->PortNr  = 1;
 		pNet->NetNr   = 1;
 		pNet->pAC     = pAC;
@@ -5073,7 +5068,7 @@
 static void __devexit skge_remove_one(struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
-	DEV_NET *pNet = (DEV_NET *) dev->priv;
+	DEV_NET *pNet = netdev_priv(dev);
 	SK_AC *pAC = pNet->pAC;
 	int have_second_mac = 0;
 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (5/23) sk98: use module_param
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (2 preceding siblings ...)
  2004-11-11 23:54   ` [PATCH] (4/23) sk98: use netdev_priv Stephen Hemminger
@ 2004-11-11 23:54   ` Stephen Hemminger
  2004-11-11 23:54   ` [PATCH] (6/23) sk98: add netpoll console support Stephen Hemminger
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:54 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Use new format module_param rather than now deprecated MODULE_PARM

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 14:08:18 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 14:08:18 -08:00
@@ -109,6 +109,7 @@
 #include	"h/skversion.h"
 
 #include	<linux/module.h>
+#include	<linux/moduleparam.h>
 #include	<linux/init.h>
 #include 	<linux/proc_fs.h>
 
@@ -358,26 +359,6 @@
 MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
 MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver");
 MODULE_LICENSE("GPL");
-MODULE_PARM(Speed_A,    "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(Speed_B,    "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(AutoNeg_A,  "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(AutoNeg_B,  "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(DupCap_A,   "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(DupCap_B,   "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(FlowCtrl_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(FlowCtrl_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(Role_A,	"1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(Role_B,	"1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(ConType,	"1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(PrefPort,   "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(RlmtMode,   "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-/* used for interrupt moderation */
-MODULE_PARM(IntsPerSec,     "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "i");
-MODULE_PARM(Moderation,     "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(Stats,          "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(ModerationMask, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-MODULE_PARM(AutoSizing,     "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
-
 
 #ifdef LINK_SPEED_A
 static char *Speed_A[SK_MAX_CARD_PARAM] = LINK_SPEED;
@@ -462,6 +443,26 @@
 static char *ModerationMask[SK_MAX_CARD_PARAM];
 static char *AutoSizing[SK_MAX_CARD_PARAM];
 static char *Stats[SK_MAX_CARD_PARAM];
+
+module_param_array(Speed_A, charp, NULL, 0);
+module_param_array(Speed_B, charp, NULL, 0);
+module_param_array(AutoNeg_A, charp, NULL, 0);
+module_param_array(AutoNeg_B, charp, NULL, 0);
+module_param_array(DupCap_A, charp, NULL, 0);
+module_param_array(DupCap_B, charp, NULL, 0);
+module_param_array(FlowCtrl_A, charp, NULL, 0);
+module_param_array(FlowCtrl_B, charp, NULL, 0);
+module_param_array(Role_A, charp, NULL, 0);
+module_param_array(Role_B, charp, NULL, 0);
+module_param_array(ConType, charp, NULL, 0);
+module_param_array(PrefPort, charp, NULL, 0);
+module_param_array(RlmtMode, charp, NULL, 0);
+/* used for interrupt moderation */
+module_param_array(IntsPerSec, int, NULL, 0);
+module_param_array(Moderation, charp, NULL, 0);
+module_param_array(Stats, charp, NULL, 0);
+module_param_array(ModerationMask, charp, NULL, 0);
+module_param_array(AutoSizing, charp, NULL, 0);
 
 /*****************************************************************************
  *

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (6/23) sk98: add netpoll console support
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (3 preceding siblings ...)
  2004-11-11 23:54   ` [PATCH] (5/23) sk98: use module_param Stephen Hemminger
@ 2004-11-11 23:54   ` Stephen Hemminger
  2004-11-11 23:55   ` [PATCH] (7/23) sk98: basic ethtool support Stephen Hemminger
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:54 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Add netpoll console support

From: Michal Schmidt <xschmi00@stud.feec.vutbr.cz>
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 14:08:32 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 14:08:32 -08:00
@@ -1125,6 +1125,24 @@
 		return SkIsrRetHandled;
 } /* SkGeIsrOnePort */
 
+#ifdef CONFIG_NET_POLL_CONTROLLER
+/****************************************************************************
+ *
+ * 	SkGePollController - polling receive, for netconsole
+ *
+ * Description:
+ *	Polling receive - used by netconsole and other diagnostic tools
+ *	to allow network i/o with interrupts disabled.
+ *
+ * Returns: N/A
+ */
+static void SkGePollController(struct net_device *dev)
+{
+	disable_irq(dev->irq);
+	SkGeIsr(dev->irq, dev, NULL);
+	enable_irq(dev->irq);
+}
+#endif
 
 /****************************************************************************
  *
@@ -4928,6 +4946,9 @@
 	dev->set_mac_address =	&SkGeSetMacAddr;
 	dev->do_ioctl =		&SkGeIoctl;
 	dev->change_mtu =	&SkGeChangeMtu;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	dev->poll_controller =	&SkGePollController;
+#endif
 	dev->flags &= 		~IFF_RUNNING;
 	SET_NETDEV_DEV(dev, &pdev->dev);
 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (7/23) sk98: basic ethtool support
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (4 preceding siblings ...)
  2004-11-11 23:54   ` [PATCH] (6/23) sk98: add netpoll console support Stephen Hemminger
@ 2004-11-11 23:55   ` Stephen Hemminger
  2004-11-12 16:29     ` Christoph Hellwig
  2004-11-11 23:55   ` [PATCH] (8/23) sk98: ethtool phy support Stephen Hemminger
                     ` (15 subsequent siblings)
  21 siblings, 1 reply; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:55 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

The basic stuff comes from the newer code from SysKonnect, but I redid
it using ethtool_ops and a cleaner way of doing the stats (from e100)

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile
--- a/drivers/net/sk98lin/Makefile	2004-11-03 14:28:47 -08:00
+++ b/drivers/net/sk98lin/Makefile	2004-11-03 14:28:47 -08:00
@@ -13,6 +13,7 @@
 obj-$(CONFIG_SK98LIN) += sk98lin.o
 sk98lin-objs    :=	\
 		skge.o		\
+		skethtool.o	\
 		skdim.o		\
 		skaddr.o	\
 		skgehwt.o	\
diff -Nru a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/drivers/net/sk98lin/skethtool.c	2004-11-03 14:28:47 -08:00
@@ -0,0 +1,330 @@
+/******************************************************************************
+ *
+ * Name:        skethtool.c
+ * Project:     GEnesis, PCI Gigabit Ethernet Adapter
+ * Version:     $Revision: 1.7 $
+ * Date:        $Date: 2004/09/29 13:32:07 $
+ * Purpose:     All functions regarding ethtool handling
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2004 Marvell.
+ *
+ *	Driver for Marvell Yukon/2 chipset and SysKonnect Gigabit Ethernet 
+ *      Server Adapters.
+ *
+ *	Author: Ralph Roesler (rroesler@syskonnect.de)
+ *	        Mirko Lindner (mlindner@syskonnect.de)
+ *
+ *	Address all question to: linux@syskonnect.de
+ *
+ *	The technical manual for the adapters is available from SysKonnect's
+ *	web pages: www.syskonnect.com
+ *	
+ *	This program is free software; you can redistribute it and/or modify
+ *	it under the terms of the GNU General Public License as published by
+ *	the Free Software Foundation; either version 2 of the License, or
+ *	(at your option) any later version.
+ *
+ *	The information in this file is provided "AS IS" without warranty.
+ *
+ *****************************************************************************/
+
+#include "h/skdrv1st.h"
+#include "h/skdrv2nd.h"
+#include "h/skversion.h"
+
+#include <linux/ethtool.h>
+#include <linux/timer.h>
+
+/******************************************************************************
+ *
+ * Defines
+ *
+ *****************************************************************************/
+
+#define SUPP_COPPER_ALL (SUPPORTED_10baseT_Half  | SUPPORTED_10baseT_Full  | \
+                         SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | \
+                         SUPPORTED_1000baseT_Half| SUPPORTED_1000baseT_Full| \
+                         SUPPORTED_TP)
+
+#define ADV_COPPER_ALL  (ADVERTISED_10baseT_Half  | ADVERTISED_10baseT_Full  | \
+                         ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full | \
+                         ADVERTISED_1000baseT_Half| ADVERTISED_1000baseT_Full| \
+                         ADVERTISED_TP)
+
+#define SUPP_FIBRE_ALL  (SUPPORTED_1000baseT_Full | \
+                         SUPPORTED_FIBRE          | \
+                         SUPPORTED_Autoneg)
+
+#define ADV_FIBRE_ALL   (ADVERTISED_1000baseT_Full | \
+                         ADVERTISED_FIBRE          | \
+                         ADVERTISED_Autoneg)
+
+
+/******************************************************************************
+ *
+ * Local Functions
+ *
+ *****************************************************************************/
+
+/*****************************************************************************
+ *
+ * 	getSettings - retrieves the current settings of the selected adapter
+ *
+ * Description:
+ *	The current configuration of the selected adapter is returned.
+ *	This configuration involves a)speed, b)duplex and c)autoneg plus
+ *	a number of other variables.
+ *
+ * Returns:    always 0
+ *
+ */
+static int getSettings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	const DEV_NET *pNet = netdev_priv(dev);
+	int port = pNet->PortNr;
+	const SK_AC *pAC = pNet->pAC;
+	const SK_GEPORT *pPort = &pAC->GIni.GP[port];
+
+	static int DuplexAutoNegConfMap[9][3]= {
+		{ -1                     , -1         , -1              },
+		{ 0                      , -1         , -1              },
+		{ SK_LMODE_HALF          , DUPLEX_HALF, AUTONEG_DISABLE },
+		{ SK_LMODE_FULL          , DUPLEX_FULL, AUTONEG_DISABLE },
+		{ SK_LMODE_AUTOHALF      , DUPLEX_HALF, AUTONEG_ENABLE  },
+		{ SK_LMODE_AUTOFULL      , DUPLEX_FULL, AUTONEG_ENABLE  },
+		{ SK_LMODE_AUTOBOTH      , DUPLEX_FULL, AUTONEG_ENABLE  },
+		{ SK_LMODE_AUTOSENSE     , -1         , -1              },
+		{ SK_LMODE_INDETERMINATED, -1         , -1              }
+	};
+	static int SpeedConfMap[6][2] = {
+		{ 0                       , -1         },
+		{ SK_LSPEED_AUTO          , -1         },
+		{ SK_LSPEED_10MBPS        , SPEED_10   },
+		{ SK_LSPEED_100MBPS       , SPEED_100  },
+		{ SK_LSPEED_1000MBPS      , SPEED_1000 },
+		{ SK_LSPEED_INDETERMINATED, -1         }
+	};
+	static int AdvSpeedMap[6][2] = {
+		{ 0                       , -1         },
+		{ SK_LSPEED_AUTO          , -1         },
+		{ SK_LSPEED_10MBPS        , ADVERTISED_10baseT_Half   | ADVERTISED_10baseT_Full },
+		{ SK_LSPEED_100MBPS       , ADVERTISED_100baseT_Half  | ADVERTISED_100baseT_Full },
+		{ SK_LSPEED_1000MBPS      , ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full},
+		{ SK_LSPEED_INDETERMINATED, -1         }
+	};
+
+	ecmd->phy_address = port;
+	ecmd->speed       = SpeedConfMap[pPort->PLinkSpeedUsed][1];
+	ecmd->duplex      = DuplexAutoNegConfMap[pPort->PLinkModeStatus][1];
+	ecmd->autoneg     = DuplexAutoNegConfMap[pPort->PLinkModeStatus][2];
+	ecmd->transceiver = XCVR_INTERNAL;
+
+	if (pAC->GIni.GICopperType) {
+		ecmd->port        = PORT_TP;
+		ecmd->supported   = (SUPP_COPPER_ALL|SUPPORTED_Autoneg);
+		if (pAC->GIni.GIGenesis) {
+			ecmd->supported &= ~(SUPPORTED_10baseT_Half);
+			ecmd->supported &= ~(SUPPORTED_10baseT_Full);
+			ecmd->supported &= ~(SUPPORTED_100baseT_Half);
+			ecmd->supported &= ~(SUPPORTED_100baseT_Full);
+		} else {
+			if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
+				ecmd->supported &= ~(SUPPORTED_1000baseT_Half);
+			} 
+#ifdef CHIP_ID_YUKON_FE
+			if (pAC->GIni.GIChipId == CHIP_ID_YUKON_FE) {
+				ecmd->supported &= ~(SUPPORTED_1000baseT_Half);
+				ecmd->supported &= ~(SUPPORTED_1000baseT_Full);
+			}
+#endif
+		}
+		if (pAC->GIni.GP[0].PLinkSpeed != SK_LSPEED_AUTO) {
+			ecmd->advertising = AdvSpeedMap[pPort->PLinkSpeed][1];
+			if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
+				ecmd->advertising &= ~(SUPPORTED_1000baseT_Half);
+			} 
+		} else {
+			ecmd->advertising = ecmd->supported;
+		}
+
+		if (ecmd->autoneg == AUTONEG_ENABLE) 
+			ecmd->advertising |= ADVERTISED_Autoneg;
+	} else {
+		ecmd->port        = PORT_FIBRE;
+		ecmd->supported   = SUPP_FIBRE_ALL;
+		ecmd->advertising = ADV_FIBRE_ALL;
+	}
+	return 0;
+}
+
+/*****************************************************************************
+ *
+ *	setSettings - configures the settings of a selected adapter
+ *
+ * Description:
+ *	Possible settings that may be altered are a)speed, b)duplex or 
+ *	c)autonegotiation.
+ *
+ * Returns:
+ *	0:	everything fine, no error
+ *	<0:	the return value is the error code of the failure 
+ */
+static int setSettings(struct net_device *dev, struct ethtool_cmd *ecmd)
+{
+	DEV_NET *pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+	u32 instance;
+	char buf[4];
+	int len = 1;
+
+	if (ecmd->speed != SPEED_10 && ecmd->speed != SPEED_100 
+	    && ecmd->speed != SPEED_1000)
+		return -EINVAL;
+
+	if (ecmd->duplex != DUPLEX_HALF && ecmd->duplex != DUPLEX_FULL)
+		return -EINVAL;
+
+	if (ecmd->autoneg != AUTONEG_DISABLE && ecmd->autoneg != AUTONEG_ENABLE)
+		return -EINVAL;
+
+	if (ecmd->autoneg == AUTONEG_DISABLE)
+		*buf = (ecmd->duplex == DUPLEX_FULL) 
+			? SK_LMODE_FULL : SK_LMODE_HALF;
+	else
+		*buf = (ecmd->duplex == DUPLEX_FULL) 
+			? SK_LMODE_AUTOFULL : SK_LMODE_AUTOHALF;
+	
+	instance = 1 + (pAC->RlmtNets == 2) + pNet->PortNr;
+	if (SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_LINK_MODE, 
+			   &buf, &len, instance, pNet->NetNr) != SK_PNMI_ERR_OK)
+		return -EINVAL;
+
+	switch(ecmd->speed) {
+	case SPEED_1000:
+		*buf = SK_LSPEED_1000MBPS;
+		break;
+	case SPEED_100:
+		*buf = SK_LSPEED_100MBPS;
+		break;
+	case SPEED_10:
+		*buf = SK_LSPEED_10MBPS;
+	}
+
+	if (SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_SPEED_MODE, 
+			 &buf, &len, instance, pNet->NetNr) != SK_PNMI_ERR_OK)
+		return -EINVAL;
+
+	return 0;
+}
+
+/*****************************************************************************
+ *
+ * 	getDriverInfo - returns generic driver and adapter information
+ *
+ * Description:
+ *	Generic driver information is returned via this function, such as
+ *	the name of the driver, its version and and firmware version.
+ *	In addition to this, the location of the selected adapter is 
+ *	returned as a bus info string (e.g. '01:05.0').
+ *	
+ * Returns:	N/A
+ *
+ */
+static void getDriverInfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	const DEV_NET	*pNet = netdev_priv(dev);
+	const SK_AC *pAC = pNet->pAC;
+	char vers[32];
+
+	snprintf(vers, sizeof(vers)-1, VER_STRING "(v%d.%d)",
+		(pAC->GIni.GIPciHwRev >> 4) & 0xf, pAC->GIni.GIPciHwRev & 0xf);
+
+	strlcpy(info->driver, DRIVER_FILE_NAME, sizeof(info->driver));
+	strcpy(info->version, vers);
+	strcpy(info->fw_version, "N/A");
+	strlcpy(info->bus_info, pAC->PciDev->slot_name, ETHTOOL_BUSINFO_LEN);
+}
+
+/*
+ * Ethtool statistics support.
+ */
+static const char StringsStats[][ETH_GSTRING_LEN] = {
+	"rx_packets",	"tx_packets",
+	"rx_bytes",	"tx_bytes",
+	"rx_errors",	"tx_errors",	
+	"rx_dropped",	"tx_dropped",
+	"multicasts",	"collisions",	
+	"rx_length_errors",		"rx_buffer_overflow_errors",
+	"rx_crc_errors",		"rx_frame_errors",
+	"rx_too_short_errors",		"rx_too_long_errors",
+	"rx_carrier_extension_errors",	"rx_symbol_errors",
+	"rx_llc_mac_size_errors",	"rx_carrier_errors",	
+	"rx_jabber_errors",		"rx_missed_errors",
+	"tx_abort_collision_errors",	"tx_carrier_errors",
+	"tx_buffer_underrun_errors",	"tx_heartbeat_errors",
+	"tx_window_errors",
+};
+
+static int getStatsCount(struct net_device *dev)
+{
+	return ARRAY_SIZE(StringsStats);
+}
+
+static void getStrings(struct net_device *dev, u32 stringset, u8 *data)
+{
+	switch(stringset) {
+	case ETH_SS_STATS:
+		memcpy(data, *StringsStats, sizeof(StringsStats));
+		break;
+	}
+}
+
+static void getEthtoolStats(struct net_device *dev,
+			    struct ethtool_stats *stats, u64 *data)
+{
+	const DEV_NET	*pNet = netdev_priv(dev);
+	const SK_AC *pAC = pNet->pAC;
+	const SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;
+
+	*data++ = pPnmiStruct->Stat[0].StatRxOkCts;
+	*data++ = pPnmiStruct->Stat[0].StatTxOkCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxOctetsOkCts;
+	*data++ = pPnmiStruct->Stat[0].StatTxOctetsOkCts;
+	*data++ = pPnmiStruct->InErrorsCts;
+	*data++ = pPnmiStruct->Stat[0].StatTxSingleCollisionCts;
+	*data++ = pPnmiStruct->RxNoBufCts;
+	*data++ = pPnmiStruct->TxNoBufCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxMulticastOkCts;
+	*data++ = pPnmiStruct->Stat[0].StatTxSingleCollisionCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxRuntCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxFifoOverflowCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxFcsCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxFramingCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxShortsCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxTooLongCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxCextCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxSymbolCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxIRLengthCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxCarrierCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxJabberCts;
+	*data++ = pPnmiStruct->Stat[0].StatRxMissedCts;
+	*data++ = pAC->stats.tx_aborted_errors;
+	*data++ = pPnmiStruct->Stat[0].StatTxCarrierCts;
+	*data++ = pPnmiStruct->Stat[0].StatTxFifoUnderrunCts;
+	*data++ = pPnmiStruct->Stat[0].StatTxCarrierCts;
+	*data++ = pAC->stats.tx_window_errors;
+}
+
+struct ethtool_ops SkGeEthtoolOps = {
+	.get_settings		= getSettings,
+	.set_settings		= setSettings,
+	.get_drvinfo		= getDriverInfo,
+	.get_strings		= getStrings,
+	.get_stats_count	= getStatsCount,
+	.get_ethtool_stats	= getEthtoolStats,
+};
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 14:28:47 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 14:28:47 -08:00
@@ -255,6 +255,7 @@
 /* global variables *********************************************************/
 struct SK_NET_DEVICE *SkGeRootDev = NULL;
 static SK_BOOL DoPrintInterfaceChange = SK_TRUE;
+extern  struct ethtool_ops SkGeEthtoolOps;
 
 /* local variables **********************************************************/
 static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
@@ -4951,6 +4952,7 @@
 #endif
 	dev->flags &= 		~IFF_RUNNING;
 	SET_NETDEV_DEV(dev, &pdev->dev);
+	SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
 
 #ifdef SK_ZEROCOPY
 #ifdef USE_SK_TX_CHECKSUM
@@ -5030,6 +5032,8 @@
 		dev->do_ioctl           = &SkGeIoctl;
 		dev->change_mtu         = &SkGeChangeMtu;
 		dev->flags             &= ~IFF_RUNNING;
+		SET_NETDEV_DEV(dev, &pdev->dev);
+		SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
 
 #ifdef SK_ZEROCOPY
 #ifdef USE_SK_TX_CHECKSUM

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (8/23) sk98: ethtool phy support
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (5 preceding siblings ...)
  2004-11-11 23:55   ` [PATCH] (7/23) sk98: basic ethtool support Stephen Hemminger
@ 2004-11-11 23:55   ` Stephen Hemminger
  2004-11-11 23:55   ` [PATCH] (9/23) sk98: ethtool pause param support Stephen Hemminger
                     ` (14 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:55 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

The basic stuff comes from the newer code from SysKonnect, but I redid
it using a per board timer rather than a global timer.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-03 14:31:05 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-03 14:31:05 -08:00
@@ -383,6 +383,8 @@
 	SK_CSUM		Csum;		/* for checksum module */
 	SK_RLMT		Rlmt;		/* for rlmt module */
 	spinlock_t	SlowPathLock;	/* Normal IRQ lock */
+	struct timer_list BlinkTimer;	/* for LED blinking */
+	int		LedsOn;
 	SK_PNMI_STRUCT_DATA PnmiStruct;	/* structure to get all Pnmi-Data */
 	int			RlmtMode;	/* link check mode to set */
 	int			RlmtNets;	/* Number of nets */
diff -Nru a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
--- a/drivers/net/sk98lin/skethtool.c	2004-11-03 14:31:05 -08:00
+++ b/drivers/net/sk98lin/skethtool.c	2004-11-03 14:31:05 -08:00
@@ -39,6 +39,7 @@
 
 #include <linux/ethtool.h>
 #include <linux/timer.h>
+#include <linux/delay.h>
 
 /******************************************************************************
  *
@@ -320,6 +321,122 @@
 	*data++ = pAC->stats.tx_window_errors;
 }
 
+
+/*****************************************************************************
+ *
+ * 	toggleLeds - Changes the LED state of an adapter
+ *
+ * Description:
+ *	This function changes the current state of all LEDs of an adapter so
+ *	that it can be located by a user. 
+ *
+ * Returns:	N/A
+ *
+ */
+static void toggleLeds(DEV_NET *pNet, int on)
+{
+	SK_AC *pAC = pNet->pAC;
+	int port = pNet->PortNr;
+	void __iomem *io = pAC->IoBase;
+
+	if (pAC->GIni.GIGenesis) {
+		SK_OUT8(io, MR_ADDR(port,LNK_LED_REG), 
+			on ? SK_LNK_ON : SK_LNK_OFF);
+		SkGeYellowLED(pAC, io, 
+			      on ? (LED_ON >> 1) : (LED_OFF >> 1));
+		SkGeXmitLED(pAC, io, MR_ADDR(port,RX_LED_INI),
+			    on ? SK_LED_TST : SK_LED_DIS);
+
+		if (pAC->GIni.GP[port].PhyType == SK_PHY_BCOM)
+			SkXmPhyWrite(pAC, io, port, PHY_BCOM_P_EXT_CTRL, 
+				     on ? PHY_B_PEC_LED_ON : PHY_B_PEC_LED_OFF);
+		else if (pAC->GIni.GP[port].PhyType == SK_PHY_LONE)
+			SkXmPhyWrite(pAC, io, port, PHY_LONE_LED_CFG,
+				     on ? 0x0800 : PHY_L_LC_LEDT);
+		else
+			SkGeXmitLED(pAC, io, MR_ADDR(port,TX_LED_INI),
+				    on ? SK_LED_TST : SK_LED_DIS);
+	} else {
+		const u16 YukLedOn = (PHY_M_LED_MO_DUP(MO_LED_ON)  |
+				      PHY_M_LED_MO_10(MO_LED_ON)   |
+				      PHY_M_LED_MO_100(MO_LED_ON)  |
+				      PHY_M_LED_MO_1000(MO_LED_ON) | 
+				      PHY_M_LED_MO_RX(MO_LED_ON));
+		const u16  YukLedOff = (PHY_M_LED_MO_DUP(MO_LED_OFF)  |
+					PHY_M_LED_MO_10(MO_LED_OFF)   |
+					PHY_M_LED_MO_100(MO_LED_OFF)  |
+					PHY_M_LED_MO_1000(MO_LED_OFF) | 
+					PHY_M_LED_MO_RX(MO_LED_OFF));
+	
+
+		SkGmPhyWrite(pAC,io,port,PHY_MARV_LED_CTRL,0);
+		SkGmPhyWrite(pAC,io,port,PHY_MARV_LED_OVER, 
+			     on ? YukLedOn : YukLedOff);
+	}
+}
+
+/*****************************************************************************
+ *
+ * 	skGeBlinkTimer - Changes the LED state of an adapter
+ *
+ * Description:
+ *	This function changes the current state of all LEDs of an adapter so
+ *	that it can be located by a user. If the requested time interval for
+ *	this test has elapsed, this function cleans up everything that was 
+ *	temporarily setup during the locate NIC test. This involves of course
+ *	also closing or opening any adapter so that the initial board state 
+ *	is recovered.
+ *
+ * Returns:	N/A
+ *
+ */
+void SkGeBlinkTimer(unsigned long data)
+{
+	struct net_device *dev = (struct net_device *) data;
+	DEV_NET *pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+
+	toggleLeds(pNet, pAC->LedsOn);
+
+	pAC->LedsOn = !pAC->LedsOn;
+	mod_timer(&pAC->BlinkTimer, jiffies + HZ/4);
+}
+
+/*****************************************************************************
+ *
+ * 	locateDevice - start the locate NIC feature of the elected adapter 
+ *
+ * Description:
+ *	This function is used if the user want to locate a particular NIC.
+ *	All LEDs are regularly switched on and off, so the NIC can easily
+ *	be identified.
+ *
+ * Returns:	
+ *	==0:	everything fine, no error, locateNIC test was started
+ *	!=0:	one locateNIC test runs already
+ *
+ */
+static int locateDevice(struct net_device *dev, u32 data)
+{
+	DEV_NET *pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+
+	if(!data || data > (u32)(MAX_SCHEDULE_TIMEOUT / HZ))
+		data = (u32)(MAX_SCHEDULE_TIMEOUT / HZ);
+
+	/* start blinking */
+	pAC->LedsOn = 0;
+	mod_timer(&pAC->BlinkTimer, jiffies);
+	msleep_interruptible(data * 1000);
+
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(data * HZ);
+	del_timer_sync(&pAC->BlinkTimer);
+	toggleLeds(pNet, 0);
+
+	return 0;
+}
+
 struct ethtool_ops SkGeEthtoolOps = {
 	.get_settings		= getSettings,
 	.set_settings		= setSettings,
@@ -327,4 +444,5 @@
 	.get_strings		= getStrings,
 	.get_stats_count	= getStatsCount,
 	.get_ethtool_stats	= getEthtoolStats,
+	.phys_id		= locateDevice,
 };
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 14:31:05 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 14:31:05 -08:00
@@ -245,6 +245,7 @@
 extern void SkDimDisplayModerationSettings(SK_AC *pAC);
 extern void SkDimStartModerationTimer(SK_AC *pAC);
 extern void SkDimModerate(SK_AC *pAC);
+extern void SkGeBlinkTimer(unsigned long data);
 
 #ifdef DEBUG
 static void	DumpMsg(struct sk_buff*, char*);
@@ -502,6 +503,11 @@
 		spin_lock_init(&pAC->RxPort[i].RxDesRingLock);
 	}
 	spin_lock_init(&pAC->SlowPathLock);
+
+	/* setup phy_id blink timer */
+	pAC->BlinkTimer.function = SkGeBlinkTimer;
+	pAC->BlinkTimer.data = (unsigned long) dev;
+	init_timer(&pAC->BlinkTimer);
 
 	/* level 0 init common modules here */
 	

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (9/23) sk98: ethtool pause param support
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (6 preceding siblings ...)
  2004-11-11 23:55   ` [PATCH] (8/23) sk98: ethtool phy support Stephen Hemminger
@ 2004-11-11 23:55   ` Stephen Hemminger
  2004-11-11 23:55   ` [PATCH] (10/23) sk98: cleanout unnecessary controller elements Stephen Hemminger
                     ` (13 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:55 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

The basic stuff comes from the newer code from SysKonnect, but there
code had ugly way to find the PNMI instance. This driver seems full
of places where they do unnecessary board/port bookeeping (*sigh*)

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
--- a/drivers/net/sk98lin/skethtool.c	2004-11-03 14:39:56 -08:00
+++ b/drivers/net/sk98lin/skethtool.c	2004-11-03 14:39:56 -08:00
@@ -163,6 +163,15 @@
 	return 0;
 }
 
+/*
+ * MIB infrastructure uses instance value starting at 1
+ * based on board and port.
+ */
+static inline u32 pnmiInstance(const DEV_NET *pNet)
+{
+	return 1 + (pNet->pAC->RlmtNets == 2) + pNet->PortNr;
+}
+
 /*****************************************************************************
  *
  *	setSettings - configures the settings of a selected adapter
@@ -200,7 +209,7 @@
 		*buf = (ecmd->duplex == DUPLEX_FULL) 
 			? SK_LMODE_AUTOFULL : SK_LMODE_AUTOHALF;
 	
-	instance = 1 + (pAC->RlmtNets == 2) + pNet->PortNr;
+	instance = pnmiInstance(pNet);
 	if (SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_LINK_MODE, 
 			   &buf, &len, instance, pNet->NetNr) != SK_PNMI_ERR_OK)
 		return -EINVAL;
@@ -437,6 +446,102 @@
 	return 0;
 }
 
+/*****************************************************************************
+ *
+ * 	getPauseParams - retrieves the pause parameters
+ *
+ * Description:
+ *	All current pause parameters of a selected adapter are placed 
+ *	in the passed ethtool_pauseparam structure and are returned.
+ *
+ * Returns:	N/A
+ *
+ */
+static void getPauseParams(struct net_device *dev, struct ethtool_pauseparam *epause) 
+{
+	DEV_NET	*pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+	SK_GEPORT *pPort = &pAC->GIni.GP[pNet->PortNr];
+
+	epause->rx_pause = (pPort->PFlowCtrlMode == SK_FLOW_MODE_SYMMETRIC) ||
+		  (pPort->PFlowCtrlMode == SK_FLOW_MODE_SYM_OR_REM);
+
+	epause->tx_pause = epause->rx_pause || (pPort->PFlowCtrlMode == SK_FLOW_MODE_LOC_SEND);
+	epause->autoneg = epause->rx_pause || epause->tx_pause;
+}
+
+/*****************************************************************************
+ *
+ *	setPauseParams - configures the pause parameters of an adapter
+ *
+ * Description:
+ *	This function sets the Rx or Tx pause parameters 
+ *
+ * Returns:
+ *	==0:	everything fine, no error
+ *	!=0:	the return value is the error code of the failure 
+ */
+static int setPauseParams(struct net_device *dev , struct ethtool_pauseparam *epause)
+{
+	DEV_NET	*pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+	SK_GEPORT *pPort = &pAC->GIni.GP[pNet->PortNr];
+	u32	instance = pnmiInstance(pNet);
+	struct ethtool_pauseparam old;
+	u8	oldspeed = pPort->PLinkSpeedUsed;
+	char	buf[4];
+	int	len = 1;
+	int ret;
+
+	/*
+	** we have to determine the current settings to see if 
+	** the operator requested any modification of the flow 
+	** control parameters...
+	*/
+	getPauseParams(dev, &old);
+
+	/*
+	** perform modifications regarding the changes 
+	** requested by the operator
+	*/
+	if (epause->autoneg != old.autoneg) 
+		*buf = epause->autoneg ? SK_FLOW_MODE_NONE : SK_FLOW_MODE_SYMMETRIC;
+	else {
+		if (epause->rx_pause && epause->tx_pause) 
+			*buf = SK_FLOW_MODE_SYMMETRIC;
+		else if (epause->rx_pause && !epause->tx_pause)
+			*buf =  SK_FLOW_MODE_SYM_OR_REM;
+		else if (!epause->rx_pause && epause->tx_pause)
+			*buf =  SK_FLOW_MODE_LOC_SEND;
+		else
+			*buf = SK_FLOW_MODE_NONE;
+	}
+
+	ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_FLOWCTRL_MODE,
+			 &buf, &len, instance, pNet->NetNr);
+
+	if (ret != SK_PNMI_ERR_OK) {
+		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_CTRL,
+			   ("ethtool (sk98lin): error changing rx/tx pause (%i)\n", ret));
+		goto err;
+	}
+
+	/*
+	** It may be that autoneg has been disabled! Therefore
+	** set the speed to the previously used value...
+	*/
+	if (!epause->autoneg) {
+		len = 1;
+		ret = SkPnmiSetVar(pAC, pAC->IoBase, OID_SKGE_SPEED_MODE, 
+				   &oldspeed, &len, instance, pNet->NetNr);
+		if (ret != SK_PNMI_ERR_OK) 
+			SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_CTRL,
+				   ("ethtool (sk98lin): error setting speed (%i)\n", ret));
+	}
+ err:
+        return ret ? -EIO : 0;
+}
+
 struct ethtool_ops SkGeEthtoolOps = {
 	.get_settings		= getSettings,
 	.set_settings		= setSettings,
@@ -445,4 +550,6 @@
 	.get_stats_count	= getStatsCount,
 	.get_ethtool_stats	= getEthtoolStats,
 	.phys_id		= locateDevice,
+	.get_pauseparam		= getPauseParams,
+	.set_pauseparam		= setPauseParams,
 };

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (10/23) sk98: cleanout unnecessary controller elements
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (7 preceding siblings ...)
  2004-11-11 23:55   ` [PATCH] (9/23) sk98: ethtool pause param support Stephen Hemminger
@ 2004-11-11 23:55   ` Stephen Hemminger
  2004-11-14  1:43     ` Jeff Garzik
  2004-11-11 23:57   ` [PATCH] (12/23) sk98: add module version Stephen Hemminger
                     ` (12 subsequent siblings)
  21 siblings, 1 reply; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:55 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Catchall cleanup patch:
	* get rid of obfuscating #define's
	* eliminate structure elements in the controller structure
	  that are never used or only used in one context or available
	  in net_device

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h
--- a/drivers/net/sk98lin/h/skdrv1st.h	2004-11-11 13:57:37 -08:00
+++ b/drivers/net/sk98lin/h/skdrv1st.h	2004-11-11 13:57:37 -08:00
@@ -96,9 +96,6 @@
 #define SK_BIG_ENDIAN
 #endif
 
-#define SK_NET_DEVICE	net_device
-
-
 /* we use gethrtime(), return unit: nanoseconds */
 #define SK_TICKS_PER_SEC	100
 
@@ -109,12 +106,11 @@
 #define SK_MAX_MACS		2
 #define SK_MAX_NETS		2
 
-#define SK_IOC			char __iomem *
-
+typedef char __iomem *SK_IOC;
 typedef struct s_DrvRlmtMbuf SK_MBUF;
 
-#define	SK_CONST64	INT64_C
-#define	SK_CONSTU64	UINT64_C
+#define	SK_CONST64(x)	(x##ll)
+#define	SK_CONSTU64(x)	(x##ull)
 
 #define SK_MEMCPY(dest,src,size)	memcpy(dest,src,size)
 #define SK_MEMCMP(s1,s2,size)		memcmp(s1,s2,size)
@@ -143,27 +139,21 @@
 #define t_uscalar_t	unsigned int
 #define uintptr_t	unsigned long
 
-#define __CONCAT__(A,B) A##B
+#ifdef DEBUG
 
-#define INT32_C(a)		__CONCAT__(a,L)
-#define INT64_C(a)		__CONCAT__(a,LL)
-#define UINT32_C(a)		__CONCAT__(a,UL)
-#define UINT64_C(a)		__CONCAT__(a,ULL)
+#define SK_DBG_PRINTF(fmt, arg...) printk(KERN_DEBUG fmt,##arg)
 
-#ifdef DEBUG
-#define SK_DBG_PRINTF		printk
 #ifndef SK_DEBUG_CHKMOD
 #define SK_DEBUG_CHKMOD		0
 #endif
 #ifndef SK_DEBUG_CHKCAT
 #define SK_DEBUG_CHKCAT		0
 #endif
+
 /* those come from the makefile */
 #define SK_DBG_CHKMOD(pAC)	(SK_DEBUG_CHKMOD)
 #define SK_DBG_CHKCAT(pAC)	(SK_DEBUG_CHKCAT)
 
-extern void SkDbgPrintf(const char *format,...);
-
 #define SK_DBGMOD_DRV			0x00010000
 
 /**** possible driver debug categories ********************************/
@@ -184,7 +174,7 @@
 
 #define SK_ERR_LOG		SkErrorLog
 
-extern void SkErrorLog(SK_AC*, int, int, char*);
+extern void SkErrorLog(const SK_AC*, int, int, const char*);
 
 #endif
 
diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-11 13:57:37 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-11 13:57:37 -08:00
@@ -266,11 +266,9 @@
 typedef struct s_DevNet DEV_NET;
 
 struct s_DevNet {
+	SK_AC   	*pAC;
 	int             PortNr;
 	int             NetNr;
-	int             Mtu;
-	int             Up;
-	SK_AC   *pAC;
 };  
 
 typedef struct s_TxPort		TX_PORT;
@@ -356,10 +354,6 @@
 	SK_TIMER        ModTimer; /* just some timer */
 };
 
-typedef struct s_PerStrm	PER_STRM;
-
-#define SK_ALLOC_IRQ	0x00000001
-
 #ifdef SK_DIAG_SUPPORT
 #define	DIAG_ACTIVE		1
 #define	DIAG_NOTACTIVE		0
@@ -390,31 +384,17 @@
 	
 	SK_IOC		IoBase;		/* register set of adapter */
 	int		BoardLevel;	/* level of active hw init (0-2) */
-	char		DeviceStr[80];	/* adapter string from vpd */
-	SK_U32		AllocFlag;	/* flag allocation of resources */
 	struct pci_dev	*PciDev;	/* for access to pci config space */
-	SK_U32		PciDevId;	/* pci device id */
-	struct SK_NET_DEVICE	*dev[2];	/* pointer to device struct */
-	char		Name[30];	/* driver name */
+	struct net_device *dev[2];	/* pointer to device struct */
 
 	int		RxBufSize;	/* length of receive buffers */
         struct net_device_stats stats;	/* linux 'netstat -i' statistics */
 	int		Index;		/* internal board index number */
 
 	/* adapter RAM sizes for queues of active port */
-	int		RxQueueSize;	/* memory used for receive queue */
-	int		TxSQueueSize;	/* memory used for sync. tx queue */
-	int		TxAQueueSize;	/* memory used for async. tx queue */
-
-	int		PromiscCount;	/* promiscuous mode counter  */
-	int		AllMultiCount;  /* allmulticast mode counter */
-	int		MulticCount;	/* number of different MC    */
-					/*  addresses for this board */
-					/*  (may be more than HW can)*/
-
 	int		HWRevision;	/* Hardware revision */
 	int		ActivePort;	/* the active XMAC port */
-	int		MaxPorts;		/* number of activated ports */
+	int		MaxPorts;	/* number of activated ports */
 	int		TxDescrPerRing;	/* # of descriptors per tx ring */
 	int		RxDescrPerRing;	/* # of descriptors per rx ring */
 
@@ -434,7 +414,6 @@
 	DIM_INFO        DynIrqModInfo;  /* all data related to DIM */
 
 	/* Only for tests */
-	int		PortUp;
 	int		PortDown;
 	int		ChipsetType;	/*  Chipset family type 
 					 *  0 == Genesis family support
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-11 13:57:37 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-11 13:57:37 -08:00
@@ -189,23 +189,23 @@
  *
  ******************************************************************************/
 
-static void	FreeResources(struct SK_NET_DEVICE *dev);
-static int	SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC);
+static void	FreeResources(struct net_device *dev);
+static int	SkGeBoardInit(struct net_device *dev, SK_AC *pAC);
 static SK_BOOL	BoardAllocMem(SK_AC *pAC);
 static void	BoardFreeMem(SK_AC *pAC);
 static void	BoardInitMem(SK_AC *pAC);
 static void	SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**, int*, SK_BOOL);
 static SkIsrRetVar	SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
 static SkIsrRetVar	SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
-static int	SkGeOpen(struct SK_NET_DEVICE *dev);
-static int	SkGeClose(struct SK_NET_DEVICE *dev);
-static int	SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev);
-static int	SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p);
-static void	SkGeSetRxMode(struct SK_NET_DEVICE *dev);
-static struct	net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev);
-static int	SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd);
+static int	SkGeOpen(struct net_device *dev);
+static int	SkGeClose(struct net_device *dev);
+static int	SkGeXmit(struct sk_buff *skb, struct net_device *dev);
+static int	SkGeSetMacAddr(struct net_device *dev, void *p);
+static void	SkGeSetRxMode(struct net_device *dev);
+static struct	net_device_stats *SkGeStats(struct net_device *dev);
+static int	SkGeIoctl(struct net_device *dev, struct ifreq *rq, int cmd);
 static void	GetConfiguration(SK_AC*);
-static void	ProductStr(SK_AC*);
+static void	PrintProductStr(const char *, SK_AC*);
 static int	XmitFrame(SK_AC*, TX_PORT*, struct sk_buff*);
 static void	FreeTxDescriptors(SK_AC*pAC, TX_PORT*);
 static void	FillRxRing(SK_AC*, RX_PORT*);
@@ -215,7 +215,7 @@
 static void	ClearTxIrq(SK_AC*, int, int);
 static void	ClearRxRing(SK_AC*, RX_PORT*);
 static void	ClearTxRing(SK_AC*, TX_PORT*);
-static int	SkGeChangeMtu(struct SK_NET_DEVICE *dev, int new_mtu);
+static int	SkGeChangeMtu(struct net_device *dev, int new_mtu);
 static void	PortReInitBmu(SK_AC*, int);
 static int	SkGeIocMib(DEV_NET*, unsigned int, int);
 static int	SkGeInitPCI(SK_AC *pAC);
@@ -288,7 +288,7 @@
  */
 int SkGeInitPCI(SK_AC *pAC)
 {
-	struct SK_NET_DEVICE *dev = pAC->dev[0];
+	struct net_device *dev = pAC->dev[0];
 	struct pci_dev *pdev = pAC->PciDev;
 	int retval;
 
@@ -299,7 +299,7 @@
 	dev->mem_start = pci_resource_start (pdev, 0);
 	pci_set_master(pdev);
 
-	if (pci_request_regions(pdev, pAC->Name) != 0) {
+	if (pci_request_regions(pdev, DRIVER_FILE_NAME) != 0) {
 		retval = 2;
 		goto out_disable;
 	}
@@ -348,27 +348,16 @@
  * Returns: N/A
  *	
  */
-static void FreeResources(struct SK_NET_DEVICE *dev)
+static void FreeResources(struct net_device *dev)
 {
-SK_U32 AllocFlag;
-DEV_NET		*pNet;
-SK_AC		*pAC;
+DEV_NET	*pNet = netdev_priv(dev);
+SK_AC	*pAC = pNet->pAC;
 
-	pNet = netdev_priv(dev);
-	pAC = pNet->pAC;
-	AllocFlag = pAC->AllocFlag;
-	if (pAC->PciDev) {
-		pci_release_regions(pAC->PciDev);
-	}
-	if (AllocFlag & SK_ALLOC_IRQ) {
-		free_irq(dev->irq, dev);
-	}
-	if (pAC->IoBase) {
-		iounmap(pAC->IoBase);
-	}
-	if (pAC->pDescrMem) {
-		BoardFreeMem(pAC);
-	}
+	free_irq(dev->irq, dev);
+	iounmap(pAC->IoBase);
+	pci_release_regions(pAC->PciDev);
+
+	BoardFreeMem(pAC);
 	
 } /* FreeResources */
 
@@ -493,14 +482,12 @@
  *	0, if everything is ok
  *	!=0, on error
  */
-static int __init SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC)
+static int SkGeBoardInit(struct net_device *dev, SK_AC *pAC)
 {
 short	i;
-unsigned long Flags;
 char	*DescrString = "sk98lin: Driver for Linux"; /* this is given to PNMI */
 char	*VerStr	= VER_STRING;
 int	Ret;			/* return code of request_irq */
-SK_BOOL	DualNet;
 
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("IoBase: %08lX\n", (unsigned long)pAC->IoBase));
@@ -524,12 +511,9 @@
 	init_timer(&pAC->BlinkTimer);
 
 	/* level 0 init common modules here */
-	
-	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
 	/* Does a RESET on board ...*/
 	if (SkGeInit(pAC, pAC->IoBase, SK_INIT_DATA) != 0) {
 		printk("HWInit (0) failed.\n");
-		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 		return(-EAGAIN);
 	}
 	SkI2cInit(  pAC, pAC->IoBase, SK_INIT_DATA);
@@ -545,13 +529,9 @@
 	SK_PNMI_SET_DRIVER_DESCR(pAC, DescrString);
 	SK_PNMI_SET_DRIVER_VER(pAC, VerStr);
 
-	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
-
 	/* level 1 init common modules here (HW init) */
-	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
 	if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
 		printk("sk98lin: HWInit (1) failed.\n");
-		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 		return(-EAGAIN);
 	}
 	SkI2cInit(  pAC, pAC->IoBase, SK_INIT_IO);
@@ -574,13 +554,12 @@
 	}
 
 	pAC->BoardLevel = SK_INIT_IO;
-	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
-
 	if (pAC->GIni.GIMacsFound == 2) {
-		 Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev);
+		Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, 
+				  DRIVER_FILE_NAME, dev);
 	} else if (pAC->GIni.GIMacsFound == 1) {
 		Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ,
-			pAC->Name, dev);
+				  DRIVER_FILE_NAME, dev);
 	} else {
 		printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n",
 		       pAC->GIni.GIMacsFound);
@@ -592,12 +571,11 @@
 		       dev->irq);
 		return -EAGAIN;
 	}
-	pAC->AllocFlag |= SK_ALLOC_IRQ;
 
 	/* Alloc memory for this board (Mem for RxD/TxD) : */
 	if(!BoardAllocMem(pAC)) {
 		printk("No memory for descriptor rings.\n");
-       		return(-EAGAIN);
+		goto out_free_irq;
 	}
 
 	SkCsSetReceiveFlags(pAC,
@@ -606,22 +584,21 @@
 	pAC->CsOfs = (pAC->CsOfs2 << 16) | pAC->CsOfs1;
 
 	BoardInitMem(pAC);
+
 	/* tschilling: New common function with minimum size check. */
-	DualNet = SK_FALSE;
-	if (pAC->RlmtNets == 2) {
-		DualNet = SK_TRUE;
-	}
-	
-	if (SkGeInitAssignRamToQueues(
-		pAC,
-		pAC->ActivePort,
-		DualNet)) {
-		BoardFreeMem(pAC);
+	if (SkGeInitAssignRamToQueues( pAC, pAC->ActivePort,
+				       (pAC->RlmtNets == 2))) {
 		printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
-		return(-EAGAIN);
+		goto out_free_mem;
 	}
 
 	return (0);
+
+ out_free_mem:
+	BoardFreeMem(pAC);
+ out_free_irq:
+	free_irq(dev->irq, dev);
+	return -EAGAIN;
 } /* SkGeBoardInit */
 
 
@@ -896,7 +873,7 @@
  */
 static SkIsrRetVar SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs)
 {
-struct SK_NET_DEVICE *dev = (struct SK_NET_DEVICE *)dev_id;
+struct net_device *dev = (struct net_device *)dev_id;
 DEV_NET		*pNet;
 SK_AC		*pAC;
 SK_U32		IntSrc;		/* interrupts source register contents */	
@@ -1045,7 +1022,7 @@
  */
 static SkIsrRetVar SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs)
 {
-struct SK_NET_DEVICE *dev = (struct SK_NET_DEVICE *)dev_id;
+struct net_device *dev = (struct net_device *)dev_id;
 DEV_NET		*pNet;
 SK_AC		*pAC;
 SK_U32		IntSrc;		/* interrupts source register contents */	
@@ -1176,7 +1153,7 @@
  *	!= 0 on error
  */
 static int SkGeOpen(
-struct SK_NET_DEVICE	*dev)
+struct net_device	*dev)
 {
 	DEV_NET			*pNet;
 	SK_AC			*pAC;
@@ -1269,8 +1246,6 @@
 	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 
 	pAC->MaxPorts++;
-	pNet->Up = 1;
-
 
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeOpen suceeded\n"));
@@ -1291,11 +1266,11 @@
  *	error code - on error
  */
 static int SkGeClose(
-struct SK_NET_DEVICE	*dev)
+struct net_device	*dev)
 {
-	DEV_NET		*pNet;
+	DEV_NET		*pNet = netdev_priv(dev);
 	DEV_NET		*newPtrNet;
-	SK_AC		*pAC;
+	SK_AC		*pAC = pNet->pAC;
 
 	unsigned long	Flags;		/* for spin lock */
 	int		i;
@@ -1305,9 +1280,6 @@
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeClose: pAC=0x%lX ", (unsigned long)pAC));
 
-	pNet = netdev_priv(dev);
-	pAC = pNet->pAC;
-
 #ifdef SK_DIAG_SUPPORT
 	if (pAC->DiagModeActive == DIAG_ACTIVE) {
 		if (pAC->DiagFlowCtrl == SK_FALSE) {
@@ -1399,7 +1371,6 @@
 			sizeof(SK_PNMI_STRUCT_DATA));
 
 	pAC->MaxPorts--;
-	pNet->Up = 0;
 
 	return (0);
 } /* SkGeClose */
@@ -1420,7 +1391,7 @@
  * WARNING: returning 1 in 'tbusy' case caused system crashes (double
  *	allocated skb's) !!!
  */
-static int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev)
+static int SkGeXmit(struct sk_buff *skb, struct net_device *dev)
 {
 DEV_NET		*pNet;
 SK_AC		*pAC;
@@ -2519,7 +2490,7 @@
  *	0, if everything is ok
  *	!=0, on error
  */
-static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p)
+static int SkGeSetMacAddr(struct net_device *dev, void *p)
 {
 
 DEV_NET *pNet = netdev_priv(dev);
@@ -2565,7 +2536,7 @@
  *	0, if everything is ok
  *	!=0, on error
  */
-static void SkGeSetRxMode(struct SK_NET_DEVICE *dev)
+static void SkGeSetRxMode(struct net_device *dev)
 {
 
 DEV_NET		*pNet;
@@ -2639,10 +2610,10 @@
  *	0, if everything is ok
  *	!=0, on error
  */
-static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu)
+static int SkGeChangeMtu(struct net_device *dev, int NewMtu)
 {
 DEV_NET		*pNet;
-DEV_NET		*pOtherNet;
+struct net_device *otherdev; 
 SK_AC		*pAC;
 unsigned long	Flags;
 int		i;
@@ -2672,11 +2643,10 @@
 	}
 #endif
 
-	pNet->Mtu = NewMtu;
-	pOtherNet = netdev_priv(pAC->dev[1 - pNet->NetNr]);
-	if ((pOtherNet->Mtu>1500) && (NewMtu<=1500) && (pOtherNet->Up==1)) {
-		return(0);
-	}
+	otherdev = pAC->dev[1 - pNet->NetNr];
+	if (NewMtu <= 1500 && otherdev != dev 
+  	    && netif_running(otherdev) && otherdev->mtu > 1500) 
+		return 0;
 
 	pAC->RxBufSize = NewMtu + 32;
 	dev->mtu = NewMtu;
@@ -2838,7 +2808,8 @@
 		EvPara.Para32[1] = -1;
 		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
 			
-		if (pOtherNet->Up) {
+		if (otherdev && netif_running(otherdev)) {
+			DEV_NET	*pOtherNet = netdev_priv(otherdev);
 			EvPara.Para32[0] = pOtherNet->PortNr;
 			SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
 		}
@@ -2848,21 +2819,8 @@
 
 	SkEventDispatcher(pAC, pAC->IoBase);
 	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
-	
-	/*
-	** While testing this driver with latest kernel 2.5 (2.5.70), it 
-	** seems as if upper layers have a problem to handle a successful
-	** return value of '0'. If such a zero is returned, the complete 
-	** system hangs for several minutes (!), which is in acceptable.
-	**
-	** Currently it is not clear, what the exact reason for this problem
-	** is. The implemented workaround for 2.5 is to return the desired 
-	** new MTU size if all needed changes for the new MTU size where 
-	** performed. In kernels 2.2 and 2.4, a zero value is returned,
-	** which indicates the successful change of the mtu-size.
-	*/
-	return NewMtu;
 
+	return 0;
 } /* SkGeChangeMtu */
 
 
@@ -2877,7 +2835,7 @@
  * Returns:
  *	pointer to the statistic structure.
  */
-static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev)
+static struct net_device_stats *SkGeStats(struct net_device *dev)
 {
 DEV_NET *pNet = netdev_priv(dev);
 SK_AC	*pAC = pNet->pAC;
@@ -2898,7 +2856,8 @@
         SK_MEMSET(pPnmiStruct, 0, sizeof(SK_PNMI_STRUCT_DATA));
         spin_lock_irqsave(&pAC->SlowPathLock, Flags);
         Size = SK_PNMI_STRUCT_SIZE;
-		SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
+	SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
+
         spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 #ifdef SK_DIAG_SUPPORT
 	}
@@ -2912,7 +2871,7 @@
 	pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts;
 	pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts;
 	
-        if (pNet->Mtu <= 1500) {
+        if (dev->mtu <= 1500) {
                 pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF;
         } else {
                 pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts -
@@ -2961,7 +2920,7 @@
  *	0, if everything is ok
  *	!=0, on error
  */
-static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd)
+static int SkGeIoctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
 DEV_NET		*pNet;
 SK_AC		*pAC;
@@ -3855,7 +3814,7 @@
 
 /*****************************************************************************
  *
- * 	ProductStr - return a adapter identification string from vpd
+ * 	PrintProductStr - show adapter identification string from vpd
  *
  * Description:
  *	This function reads the product name string from the vpd area
@@ -3863,25 +3822,22 @@
  *
  * Returns: N/A
  */
-static void ProductStr(
-SK_AC	*pAC		/* pointer to adapter context */
-)
+static void PrintProductStr(const char *name, SK_AC *pAC)
 {
-int	StrLen = 80;		/* length of the string, defined in SK_AC */
-char	Keyword[] = VPD_NAME;	/* vpd productname identifier */
+char	Buf[80];
+int	Len = sizeof(Buf);
 int	ReturnCode;		/* return code from vpd_read */
 unsigned long Flags;
 
 	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
-	ReturnCode = VpdRead(pAC, pAC->IoBase, Keyword, pAC->DeviceStr,
-		&StrLen);
+	ReturnCode = VpdRead(pAC, pAC->IoBase, VPD_NAME, Buf, &Len);
 	spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 	if (ReturnCode != 0) {
 		/* there was an error reading the vpd data */
-		SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ERROR,
-			("Error reading VPD data: %d\n", ReturnCode));
-		pAC->DeviceStr[0] = '\0';
+		sprintf(Buf, "Error reading VPD data: %d\n", ReturnCode);
 	}
+
+	printk(KERN_INFO "%s: %s\n", name, Buf);
 } /* ProductStr */
 
 /*****************************************************************************
@@ -4510,35 +4466,34 @@
  *	< 0  on error
  *	
  */
-void SkErrorLog(
-SK_AC	*pAC,
-int	ErrClass,
-int	ErrNum,
-char	*pErrorMsg)
+void SkErrorLog(const SK_AC *pAC,
+		int	ErrClass,
+		int	ErrNum,
+		const char	*pErrorMsg)
 {
-char	ClassStr[80];
+	const char *ClassStr = "";
 
 	switch (ErrClass) {
 	case SK_ERRCL_OTHER:
-		strcpy(ClassStr, "Other error");
+		ClassStr = "Other error";
 		break;
 	case SK_ERRCL_CONFIG:
-		strcpy(ClassStr, "Configuration error");
+		ClassStr = "Configuration error";
 		break;
 	case SK_ERRCL_INIT:
-		strcpy(ClassStr, "Initialization error");
+		ClassStr = "Initialization error";
 		break;
 	case SK_ERRCL_NORES:
-		strcpy(ClassStr, "Out of resources error");
+		ClassStr = "Out of resources error";
 		break;
 	case SK_ERRCL_SW:
-		strcpy(ClassStr, "internal Software error");
+		ClassStr = "internal Software error";
 		break;
 	case SK_ERRCL_HW:
-		strcpy(ClassStr, "Hardware failure");
+		ClassStr = "Hardware failure";
 		break;
 	case SK_ERRCL_COMM:
-		strcpy(ClassStr, "Communication error");
+		ClassStr = "Communication error";
 		break;
 	}
 	printk(KERN_INFO "%s: -- ERROR --\n        Class:  %s\n"
@@ -4571,7 +4526,7 @@
 
 	pAC->DiagModeActive = DIAG_ACTIVE;
 	if (pAC->BoardLevel > SK_INIT_DATA) {
-		if (pNet->Up) {
+		if (netif_running(pAC->dev[0])) {
 			pAC->WasIfUp[0] = SK_TRUE;
 			pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose      */
 			DoPrintInterfaceChange = SK_FALSE;
@@ -4580,8 +4535,7 @@
 			pAC->WasIfUp[0] = SK_FALSE;
 		}
 		if (pNet != netdev_priv(pAC->dev[1])) {
-			pNet = netdev_priv(pAC->dev[1]);
-			if (pNet->Up) {
+			if (netif_running(pAC->dev[1])) {
 				pAC->WasIfUp[1] = SK_TRUE;
 				pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
 				DoPrintInterfaceChange = SK_FALSE;
@@ -4698,7 +4652,7 @@
 SK_AC   *pAC,		/* pointer to adapter context   */
 int      devNbr)	/* what device is to be handled */
 {
-	struct SK_NET_DEVICE *dev;
+	struct net_device *dev;
 
 	dev = pAC->dev[devNbr];
 
@@ -4729,7 +4683,7 @@
 SK_AC   *pAC,		/* pointer to adapter context   */
 int      devNbr)	/* what device is to be handled */
 {
-	struct SK_NET_DEVICE *dev;
+	struct net_device *dev;
 
 	dev = pAC->dev[devNbr];
 
@@ -4934,14 +4888,10 @@
 	memset(pNet->pAC, 0, sizeof(SK_AC));
 	pAC = pNet->pAC;
 	pAC->PciDev = pdev;
-	pAC->PciDevId = pdev->device;
 	pAC->dev[0] = dev;
 	pAC->dev[1] = dev;
-	sprintf(pAC->Name, "SysKonnect SK-98xx");
 	pAC->CheckQueue = SK_FALSE;
 
-	pNet->Mtu = 1500;
-	pNet->Up = 0;
 	dev->irq = pdev->irq;
 	error = SkGeInitPCI(pAC);
 	if (error) {
@@ -4987,8 +4937,7 @@
 	}
 
 	/* Print adapter specific string from vpd */
-	ProductStr(pAC);
-	printk("%s: %s\n", dev->name, pAC->DeviceStr);
+	PrintProductStr(dev->name, pAC);
 
 	/* Print configuration settings */
 	printk("      PrefPort:%c  RlmtMode:%s\n",
@@ -5024,8 +4973,6 @@
 		pNet->PortNr  = 1;
 		pNet->NetNr   = 1;
 		pNet->pAC     = pAC;
-		pNet->Mtu     = 1500;
-		pNet->Up      = 0;
 
 		dev->open               = &SkGeOpen;
 		dev->stop               = &SkGeClose;
@@ -5057,7 +5004,7 @@
 			memcpy(&dev->dev_addr,
 					&pAC->Addr.Net[1].CurrentMacAddress, 6);
 	
-			printk("%s: %s\n", dev->name, pAC->DeviceStr);
+			PrintProductStr(dev->name, pAC);
 			printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
 		}
 	}

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (12/23) sk98: add module version
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (8 preceding siblings ...)
  2004-11-11 23:55   ` [PATCH] (10/23) sk98: cleanout unnecessary controller elements Stephen Hemminger
@ 2004-11-11 23:57   ` Stephen Hemminger
  2004-11-11 23:57   ` [PATCH] (11/23) sk98: board counter incremented twice Stephen Hemminger
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:57 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Add MODULE_VERSION to build process

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 15:35:02 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 15:35:02 -08:00
@@ -350,6 +350,7 @@
 MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
 MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver");
 MODULE_LICENSE("GPL");
+MODULE_VERSION(VER_STRING);
 
 #ifdef LINK_SPEED_A
 static char *Speed_A[SK_MAX_CARD_PARAM] = LINK_SPEED;

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (11/23) sk98: board counter incremented twice
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (9 preceding siblings ...)
  2004-11-11 23:57   ` [PATCH] (12/23) sk98: add module version Stephen Hemminger
@ 2004-11-11 23:57   ` Stephen Hemminger
  2004-11-12  0:00   ` [PATCH] (13/23) sk98: handle ring full correctly Stephen Hemminger
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-11 23:57 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Minor bug, bourd found incremented twice. Also don't need to
initialize fields already zerod.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 15:09:28 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 15:09:28 -08:00
@@ -4972,11 +4972,6 @@
 	}
 #endif
 
-	pNet->PortNr = 0;
-	pNet->NetNr  = 0;
-
-	boards_found++;
-
 	/* More then one port found */
 	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
 		if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) {

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (13/23) sk98: handle ring full correctly
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (10 preceding siblings ...)
  2004-11-11 23:57   ` [PATCH] (11/23) sk98: board counter incremented twice Stephen Hemminger
@ 2004-11-12  0:00   ` Stephen Hemminger
  2004-11-12 10:54     ` Tommy Christensen
  2004-11-12  0:01   ` [PATCH] (15/23) sk98: rearrange initialization Stephen Hemminger
                     ` (9 subsequent siblings)
  21 siblings, 1 reply; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:00 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

This driver needs to manage it's transmit queue properly.
The hard_start_xmit needs to return OK if send successfully
and BUSY (1) if queue is full. In either case must free skb,
existing code would leak if tx ring filled!

Also, check if queue is send fills queue and stop transmit queue 
as needed. In order to test for ring full w/o race, pull locking 
up from XmitFrame to SkGeXmit

Signed-off-by: Stephen Hemminger<shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 15:56:39 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 15:56:39 -08:00
@@ -1396,59 +1396,43 @@
  * Returns:
  *	0, if everything is ok
  *	!=0, on error
- * WARNING: returning 1 in 'tbusy' case caused system crashes (double
- *	allocated skb's) !!!
  */
 static int SkGeXmit(struct sk_buff *skb, struct net_device *dev)
 {
-DEV_NET		*pNet;
-SK_AC		*pAC;
-int			Rc;	/* return code of XmitFrame */
-
-	pNet = netdev_priv(dev);
-	pAC = pNet->pAC;
+	DEV_NET	*pNet = netdev_priv(dev);
+	SK_AC	*pAC = pNet->pAC;
+	TX_PORT		*pTxPort;
+	int	rc;
+	unsigned long flags;
+
+	if (pAC->RlmtNets == 2)
+		pTxPort = &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW];
+	else
+		pTxPort = &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW];
 
+	spin_lock_irqsave(&pTxPort->TxDesRingLock, flags);
 	if ((!skb_shinfo(skb)->nr_frags) ||
 		(pAC->GIni.GIChipId == CHIP_ID_GENESIS)) {
 		/* Don't activate scatter-gather and hardware checksum */
-
-		if (pAC->RlmtNets == 2)
-			Rc = XmitFrame(
-				pAC,
-				&pAC->TxPort[pNet->PortNr][TX_PRIO_LOW],
-				skb);
-		else
-			Rc = XmitFrame(
-				pAC,
-				&pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW],
-				skb);
+		rc = XmitFrame( pAC, pTxPort, skb);
 	} else {
-		/* scatter-gather and hardware TCP checksumming anabled*/
-		if (pAC->RlmtNets == 2)
-			Rc = XmitFrameSG(
-				pAC,
-				&pAC->TxPort[pNet->PortNr][TX_PRIO_LOW],
-				skb);
-		else
-			Rc = XmitFrameSG(
-				pAC,
-				&pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW],
-				skb);
+		rc = XmitFrameSG(pAC, pTxPort, skb);
 	}
 
-	/* Transmitter out of resources? */
-	if (Rc <= 0) {
+	/* No space left for next transmit */
+	if (rc <= 0) 
 		netif_stop_queue(dev);
-	}
 
-	/* If not taken, give buffer ownership back to the
-	 * queueing layer.
-	 */
-	if (Rc < 0)
-		return (1);
+	spin_unlock_irqrestore(&pTxPort->TxDesRingLock, flags);
 
-	dev->trans_start = jiffies;
-	return (0);
+	/* Transmit failed, out of resources */
+	if (rc < 0) {
+		dev_kfree_skb(skb);
+		return NETDEV_TX_BUSY;
+	} else {
+		dev->trans_start = jiffies;		
+		return NETDEV_TX_OK;
+	}
 } /* SkGeXmit */
 
 
@@ -1481,7 +1465,6 @@
 {
 	TXD		*pTxd;		/* the rxd to fill */
 	TXD		*pOldTxd;
-	unsigned long	 Flags;
 	SK_U64		 PhysAddr;
 	int	 	 Protocol;
 	int		 IpHeaderLength;
@@ -1489,7 +1472,6 @@
 
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X"));
 
-	spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
 #ifndef USE_TX_COMPLETE
 	FreeTxDescriptors(pAC, pTxPort);
 #endif
@@ -1500,7 +1482,6 @@
 		*/
 		FreeTxDescriptors(pAC, pTxPort);
 		if (pTxPort->TxdRingFree == 0) {
-			spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
 			SK_PNMI_CNT_NO_TX_BUF(pAC, pTxPort->PortIndex);
 			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
 				SK_DBGCAT_DRV_TX_PROGRESS,
@@ -1523,7 +1504,6 @@
 	*/
 	if (BytesSend < C_LEN_ETHERNET_MINSIZE) {
 		if ((pMessage = skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) == NULL) {
-			spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
 			return 0;
 		}
 		pMessage->len = C_LEN_ETHERNET_MINSIZE;
@@ -1598,16 +1578,7 @@
 		SK_OUT8(pTxPort->HwAddr, Q_CSR, CSR_START);
 	}	
 
-	/* 
-	** after releasing the lock, the skb may immediately be free'd 
-	*/
-	spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
-	if (pTxPort->TxdRingFree != 0) {
-		return (BytesSend);
-	} else {
-		return (0);
-	}
-
+	return (pTxPort->TxdRingFree != 0);
 } /* XmitFrame */
 
 /*****************************************************************************
@@ -1640,16 +1611,13 @@
 	int		 Protocol;
 	skb_frag_t	*sk_frag;
 	SK_U64		 PhysAddr;
-	unsigned long	 Flags;
 
-	spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
 #ifndef USE_TX_COMPLETE
 	FreeTxDescriptors(pAC, pTxPort);
 #endif
 	if ((skb_shinfo(pMessage)->nr_frags +1) > pTxPort->TxdRingFree) {
 		FreeTxDescriptors(pAC, pTxPort);
 		if ((skb_shinfo(pMessage)->nr_frags + 1) > pTxPort->TxdRingFree) {
-			spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
 			SK_PNMI_CNT_NO_TX_BUF(pAC, pTxPort->PortIndex);
 			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
 				SK_DBGCAT_DRV_TX_PROGRESS,
@@ -1781,13 +1749,7 @@
 	pTxPort->pTxdRingPrev = pTxdLst;
 	pTxPort->pTxdRingHead = pTxd;
 
-	spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
-
-	if (pTxPort->TxdRingFree > 0) {
-		return (BytesSend);
-	} else {
-		return (0);
-	}
+	return (pTxPort->TxdRingFree > 0);
 }
 
 /*****************************************************************************

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (15/23) sk98: rearrange initialization
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (11 preceding siblings ...)
  2004-11-12  0:00   ` [PATCH] (13/23) sk98: handle ring full correctly Stephen Hemminger
@ 2004-11-12  0:01   ` Stephen Hemminger
  2004-11-12 16:30     ` Christoph Hellwig
  2004-11-12  0:01   ` [PATCH] (14/23) sk98: don't obfuscate irqreturn_t Stephen Hemminger
                     ` (8 subsequent siblings)
  21 siblings, 1 reply; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:01 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

The code in the latest SysKonnect driver is arranged differently,
this aligns the two versions to allow for easier comparisons.
Also:
	Don't enable the pci device twice.
	Add common SkGeDevInit for common code used to setup both ports

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-05 16:54:01 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-05 16:54:01 -08:00
@@ -111,6 +111,7 @@
 #include	<linux/module.h>
 #include	<linux/moduleparam.h>
 #include	<linux/init.h>
+#include	<linux/ethtool.h>
 #include 	<linux/proc_fs.h>
 
 #include	"h/skdrv1st.h"
@@ -179,8 +180,11 @@
  *
  ******************************************************************************/
 
+static int 	sk98lin_init_device(struct pci_dev *pdev, const struct pci_device_id *ent);
+static void 	sk98lin_remove_device(struct pci_dev *pdev);
 static void	FreeResources(struct net_device *dev);
 static int	SkGeBoardInit(struct net_device *dev, SK_AC *pAC);
+static void	SkGeDevInit(struct net_device *dev, struct pci_dev *pdev);
 static SK_BOOL	BoardAllocMem(SK_AC *pAC);
 static void	BoardFreeMem(SK_AC *pAC);
 static void	BoardInitMem(SK_AC *pAC);
@@ -251,6 +255,7 @@
 extern void SkDimStartModerationTimer(SK_AC *pAC);
 extern void SkDimModerate(SK_AC *pAC);
 extern void SkGeBlinkTimer(unsigned long data);
+extern struct ethtool_ops SkGeEthtoolOps;
 
 #ifdef DEBUG
 static void	DumpMsg(struct sk_buff*, char*);
@@ -260,12 +265,237 @@
 
 /* global variables *********************************************************/
 static SK_BOOL DoPrintInterfaceChange = SK_TRUE;
-extern  struct ethtool_ops SkGeEthtoolOps;
+static const char *BootString = BOOT_STRING;
 
 /* local variables **********************************************************/
 static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
 static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
 
+
+static struct pci_device_id sk98lin_pci_tbl[] = {
+	{ PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_SYSKONNECT, 0x4300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_SYSKONNECT, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_DLINK, 0x4c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_MARVELL, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+#if 0	/* don't handle Yukon2 cards at the moment -- mlindner@syskonnect.de */
+	{ PCI_VENDOR_ID_MARVELL, 0x4360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_MARVELL, 0x4361, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+#endif
+	{ PCI_VENDOR_ID_MARVELL, 0x5005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_CNET, 0x434e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_LINKSYS, 0x1064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ 0, }
+};
+
+static struct pci_driver skge_driver = {
+	.name		= DRIVER_FILE_NAME,
+	.id_table	= sk98lin_pci_tbl,
+	.probe		= sk98lin_init_device,
+	.remove		= __devexit_p(sk98lin_remove_device),
+};
+
+/*****************************************************************************
+ *
+ * 	sk98lin_init_device - initialize the adapter
+ *
+ * Description:
+ *	This function initializes the adapter. Resources for
+ *	the adapter are allocated and the adapter is brought into Init 1
+ *	state.
+ *
+ * Returns:
+ *	0, if everything is ok
+ *	!=0, on error
+ */
+static int __devinit sk98lin_init_device(struct pci_dev *pdev,
+					 const struct pci_device_id *ent)
+{
+	SK_AC			*pAC;
+	DEV_NET			*pNet = NULL;
+	struct net_device	*dev = NULL;
+	static int boards_found = 0;
+	int error = -ENODEV;
+
+	error = pci_enable_device(pdev);
+	if (error) {
+		printk(KERN_ERR "sk98lin: cannot enable PCI device, aborting\n");
+		goto out;
+	}
+ 
+	/* Configure DMA attributes. */
+	if ((error = pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) ||
+	    (error = pci_set_dma_mask(pdev, (u64) 0xffffffff))) {
+		printk(KERN_ERR "sk98lin: cannot set PCI dma mask\n");
+		goto out_disable_device;
+	}
+
+	/* Allocate both structures for first port, 
+	   and only one for second port. */
+	dev = alloc_etherdev(sizeof(DEV_NET));
+	if (!dev) {
+		printk(KERN_ERR "sk98lin: unable to allocate etherdev structure!\n");
+		error = -ENOMEM;
+		goto out_disable_device;
+	}
+
+	pNet = netdev_priv(dev);
+	pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
+	if (pNet->pAC == NULL){
+		printk(KERN_ERR "sk98lin: unable to allocate adapter structure!\n");
+		error = -ENOMEM;
+		goto out_free_netdev;
+	}
+
+	if (BootString) {
+		printk("%s\n", BootString);
+		BootString = NULL;
+	}
+
+	memset(pNet->pAC, 0, sizeof(SK_AC));
+	pAC = pNet->pAC;
+	pAC->PciDev = pdev;
+	pAC->dev[0] = dev;
+	pAC->dev[1] = dev;
+	pAC->CheckQueue = SK_FALSE;
+
+	dev->irq = pdev->irq;
+
+	strcpy(dev->name, pci_name(pdev)); /* use PCI for early messages */
+	error = SkGeInitPCI(pAC);
+	if (error) {
+		printk("SKGE: PCI setup failed: %i\n", error);
+		goto out_free_adapter;
+	}
+
+	SkGeDevInit(dev, pdev);
+
+	pAC->Index = boards_found++;
+
+	if (SkGeBoardInit(dev, pAC))
+		goto out_free_adapter;
+
+#ifdef SK_ZEROCOPY
+#ifdef USE_SK_TX_CHECKSUM
+	if (pAC->ChipsetType)
+		/* Use only if yukon hardware */
+		/* SK and ZEROCOPY - fly baby... */
+		dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
+#endif
+#endif
+
+	/* Register net device */
+	strcpy(dev->name, "eth%d");
+	if (register_netdev(dev)) {
+		printk(KERN_ERR "SKGE: Could not register device.\n");
+		goto out_free_resources;
+	}
+
+	SkGeProcCreate(dev);
+
+	/* Print adapter specific string from vpd */
+	PrintProductStr(dev->name, pAC);
+
+	/* Print configuration settings */
+	printk("      PrefPort:%c  RlmtMode:%s\n",
+		'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber,
+		(pAC->RlmtMode==0)  ? "Check Link State" :
+		((pAC->RlmtMode==1) ? "Check Link State" :
+		((pAC->RlmtMode==3) ? "Check Local Port" :
+		((pAC->RlmtMode==7) ? "Check Segmentation" :
+		((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error")))));
+
+	SkGeYellowLED(pAC, pAC->IoBase, 1);
+
+	memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
+
+	/* More then one port found */
+	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
+		if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) {
+			printk(KERN_ERR "Unable to allocate etherdev "
+				"structure!\n");
+			goto out;
+		}
+
+		pAC->dev[1]   = dev;
+		pNet          = netdev_priv(dev);
+		pNet->PortNr  = 1;
+		pNet->NetNr   = 1;
+		pNet->pAC     = pAC;
+		
+		memcpy(&dev->dev_addr,
+		       &pAC->Addr.Net[1].CurrentMacAddress, 6);
+
+		SkGeDevInit(dev, pdev);
+
+#ifdef SK_ZEROCOPY
+#ifdef USE_SK_TX_CHECKSUM
+		if (pAC->ChipsetType)
+			/* Use only if yukon hardware */
+			/* SK and ZEROCOPY - fly baby... */
+			dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
+#endif
+#endif
+
+
+		if (register_netdev(dev)) {
+			printk(KERN_ERR "SKGE: Could not register device.\n");
+			free_netdev(dev);
+			pAC->dev[1] = pAC->dev[0];
+		} else {
+			SkGeProcCreate(dev);
+			PrintProductStr(dev->name, pAC);
+			printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
+		}
+	}
+
+	/* Save the hardware revision */
+	pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
+		(pAC->GIni.GIPciHwRev & 0x0F);
+
+	/* Set driver globals */
+	pAC->Pnmi.pDriverFileName    = DRIVER_FILE_NAME;
+	pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE;
+
+	memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA));
+	memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA));
+
+	pci_set_drvdata(pdev, dev);
+	return 0;
+
+ out_free_resources:
+	FreeResources(dev);
+ out_free_adapter:
+	kfree(pAC);
+ out_free_netdev:
+	free_netdev(dev);
+ out_disable_device:
+	pci_disable_device(pdev);
+ out:
+	return error;
+}
+
+static void SkGeDevInit(struct net_device *dev, struct pci_dev *pdev)
+{
+	SET_MODULE_OWNER(dev);
+	dev->open =		&SkGeOpen;
+	dev->stop =		&SkGeClose;
+	dev->hard_start_xmit =	&SkGeXmit;
+	dev->get_stats =	&SkGeStats;
+	dev->set_multicast_list = &SkGeSetRxMode;
+	dev->set_mac_address =	&SkGeSetMacAddr;
+	dev->do_ioctl =		&SkGeIoctl;
+	dev->change_mtu =	&SkGeChangeMtu;
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	dev->poll_controller =	&SkGePollController;
+#endif
+	SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
+	SET_NETDEV_DEV(dev, &pdev->dev);
+}
+
+
 /*****************************************************************************
  *
  * 	SkGeInitPCI - Init the PCI resources
@@ -276,16 +506,12 @@
  * Returns: N/A
  *	
  */
-int SkGeInitPCI(SK_AC *pAC)
+static int SkGeInitPCI(SK_AC *pAC)
 {
 	struct net_device *dev = pAC->dev[0];
 	struct pci_dev *pdev = pAC->PciDev;
 	int retval;
 
-	if (pci_enable_device(pdev) != 0) {
-		return 1;
-	}
-
 	dev->mem_start = pci_resource_start (pdev, 0);
 	pci_set_master(pdev);
 
@@ -326,7 +552,6 @@
 	return retval;
 }
 
-
 /*****************************************************************************
  *
  * 	FreeResources - release resources allocated for adapter
@@ -462,6 +687,69 @@
 
 /*****************************************************************************
  *
+ * 	sk98lin_remove_device - device deinit function
+ *
+ * Description:
+ *	Disable adapter if it is still running, free resources,
+ *	free device struct.
+ *
+ * Returns: N/A
+ */
+static void __devexit sk98lin_remove_device(struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata(pdev);
+	DEV_NET *pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+	struct net_device *dev1 = pAC->dev[1];
+
+	if (dev1 != dev) {
+		unregister_netdev(dev1);
+		SkGeProcRemove(dev1);
+	}
+
+	SkGeProcRemove(dev);
+	unregister_netdev(dev);
+
+	SkGeYellowLED(pAC, pAC->IoBase, 0);
+
+	if (pAC->BoardLevel == SK_INIT_RUN) {
+		SK_EVPARA EvPara;
+		unsigned long Flags;
+
+		/* board is still alive */
+		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
+		EvPara.Para32[0] = 0;
+		EvPara.Para32[1] = -1;
+		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
+		EvPara.Para32[0] = 1;
+		EvPara.Para32[1] = -1;
+		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
+		SkEventDispatcher(pAC, pAC->IoBase);
+		/* disable interrupts */
+		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
+		SkGeDeInit(pAC, pAC->IoBase);
+		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
+		pAC->BoardLevel = SK_INIT_DATA;
+		/* We do NOT check here, if IRQ was pending, of course*/
+	}
+
+	if (pAC->BoardLevel == SK_INIT_IO) {
+		/* board is still alive */
+		SkGeDeInit(pAC, pAC->IoBase);
+		pAC->BoardLevel = SK_INIT_DATA;
+	}
+
+	FreeResources(dev);
+
+	if (dev1 != dev)
+		free_netdev(dev1);
+	free_netdev(dev);
+	pci_disable_device(pdev);
+	pci_set_drvdata(pdev, NULL);
+}
+
+/*****************************************************************************
+ *
  * 	SkGeBoardInit - do level 0 and 1 initialization
  *
  * Description:
@@ -4821,253 +5109,6 @@
 
 #endif
 
-static int __devinit skge_probe_one(struct pci_dev *pdev,
-		const struct pci_device_id *ent)
-{
-	SK_AC			*pAC;
-	DEV_NET			*pNet = NULL;
-	struct net_device	*dev = NULL;
-	static int boards_found = 0;
-	int error = -ENODEV;
-
-	if (pci_enable_device(pdev))
-		goto out;
- 
-	/* Configure DMA attributes. */
-	if (pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL) &&
-	    pci_set_dma_mask(pdev, (u64) 0xffffffff))
-		goto out_disable_device;
-
-
-	if ((dev = alloc_etherdev(sizeof(DEV_NET))) == NULL) {
-		printk(KERN_ERR "Unable to allocate etherdev "
-		       "structure!\n");
-		goto out_disable_device;
-	}
-
-	pNet = netdev_priv(dev);
-	pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
-	if (!pNet->pAC) {
-		printk(KERN_ERR "Unable to allocate adapter "
-		       "structure!\n");
-		goto out_free_netdev;
-	}
-
-	memset(pNet->pAC, 0, sizeof(SK_AC));
-	pAC = pNet->pAC;
-	pAC->PciDev = pdev;
-	pAC->dev[0] = dev;
-	pAC->dev[1] = dev;
-	pAC->CheckQueue = SK_FALSE;
-
-	dev->irq = pdev->irq;
-	error = SkGeInitPCI(pAC);
-	if (error) {
-		printk("SKGE: PCI setup failed: %i\n", error);
-		goto out_free_netdev;
-	}
-
-	SET_MODULE_OWNER(dev);
-	dev->open =		&SkGeOpen;
-	dev->stop =		&SkGeClose;
-	dev->hard_start_xmit =	&SkGeXmit;
-	dev->get_stats =	&SkGeStats;
-	dev->set_multicast_list = &SkGeSetRxMode;
-	dev->set_mac_address =	&SkGeSetMacAddr;
-	dev->do_ioctl =		&SkGeIoctl;
-	dev->change_mtu =	&SkGeChangeMtu;
-#ifdef CONFIG_NET_POLL_CONTROLLER
-	dev->poll_controller =	&SkGePollController;
-#endif
-	dev->flags &= 		~IFF_RUNNING;
-	SET_NETDEV_DEV(dev, &pdev->dev);
-	SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
-
-#ifdef SK_ZEROCOPY
-#ifdef USE_SK_TX_CHECKSUM
-	if (pAC->ChipsetType) {
-		/* Use only if yukon hardware */
-		/* SK and ZEROCOPY - fly baby... */
-		dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
-	}
-#endif
-#endif
-
-	pAC->Index = boards_found++;
-
-	if (SkGeBoardInit(dev, pAC))
-		goto out_free_netdev;
-
-	/* Register net device */
-	if (register_netdev(dev)) {
-		printk(KERN_ERR "SKGE: Could not register device.\n");
-		goto out_free_resources;
-	}
-
-	/* Print adapter specific string from vpd */
-	PrintProductStr(dev->name, pAC);
-
-	/* Print configuration settings */
-	printk("      PrefPort:%c  RlmtMode:%s\n",
-		'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber,
-		(pAC->RlmtMode==0)  ? "Check Link State" :
-		((pAC->RlmtMode==1) ? "Check Link State" :
-		((pAC->RlmtMode==3) ? "Check Local Port" :
-		((pAC->RlmtMode==7) ? "Check Segmentation" :
-		((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error")))));
-
-	SkGeYellowLED(pAC, pAC->IoBase, 1);
-
-
-	memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
-
-	SkGeProcCreate(dev);
-
-	/* More then one port found */
-	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
-		if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) {
-			printk(KERN_ERR "Unable to allocate etherdev "
-				"structure!\n");
-			goto out;
-		}
-
-		pAC->dev[1]   = dev;
-		pNet          = netdev_priv(dev);
-		pNet->PortNr  = 1;
-		pNet->NetNr   = 1;
-		pNet->pAC     = pAC;
-
-		dev->open               = &SkGeOpen;
-		dev->stop               = &SkGeClose;
-		dev->hard_start_xmit    = &SkGeXmit;
-		dev->get_stats          = &SkGeStats;
-		dev->set_multicast_list = &SkGeSetRxMode;
-		dev->set_mac_address    = &SkGeSetMacAddr;
-		dev->do_ioctl           = &SkGeIoctl;
-		dev->change_mtu         = &SkGeChangeMtu;
-		dev->flags             &= ~IFF_RUNNING;
-		SET_NETDEV_DEV(dev, &pdev->dev);
-		SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
-
-#ifdef SK_ZEROCOPY
-#ifdef USE_SK_TX_CHECKSUM
-		if (pAC->ChipsetType) {
-			/* SG and ZEROCOPY - fly baby... */
-			dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
-		}
-#endif
-#endif
-
-		if (register_netdev(dev)) {
-			printk(KERN_ERR "SKGE: Could not register device.\n");
-			free_netdev(dev);
-			pAC->dev[1] = pAC->dev[0];
-		} else {
-			SkGeProcCreate(dev);
-			memcpy(&dev->dev_addr,
-					&pAC->Addr.Net[1].CurrentMacAddress, 6);
-	
-			PrintProductStr(dev->name, pAC);
-			printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
-		}
-	}
-
-	/* Save the hardware revision */
-	pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
-		(pAC->GIni.GIPciHwRev & 0x0F);
-
-	/* Set driver globals */
-	pAC->Pnmi.pDriverFileName    = DRIVER_FILE_NAME;
-	pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE;
-
-	memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA));
-	memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA));
-
-	pci_set_drvdata(pdev, dev);
-	return 0;
-
- out_free_resources:
-	FreeResources(dev);
- out_free_netdev:
-	free_netdev(dev);
- out_disable_device:
-	pci_disable_device(pdev);
- out:
-	return error;
-}
-
-static void __devexit skge_remove_one(struct pci_dev *pdev)
-{
-	struct net_device *dev = pci_get_drvdata(pdev);
-	DEV_NET *pNet = netdev_priv(dev);
-	SK_AC *pAC = pNet->pAC;
-	struct net_device *otherdev = pAC->dev[1];
-
-	SkGeProcRemove(dev);
-	unregister_netdev(dev);
-	if (otherdev != dev)
-		SkGeProcRemove(otherdev);
-
-	SkGeYellowLED(pAC, pAC->IoBase, 0);
-
-	if (pAC->BoardLevel == SK_INIT_RUN) {
-		SK_EVPARA EvPara;
-		unsigned long Flags;
-
-		/* board is still alive */
-		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
-		EvPara.Para32[0] = 0;
-		EvPara.Para32[1] = -1;
-		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
-		EvPara.Para32[0] = 1;
-		EvPara.Para32[1] = -1;
-		SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
-		SkEventDispatcher(pAC, pAC->IoBase);
-		/* disable interrupts */
-		SK_OUT32(pAC->IoBase, B0_IMSK, 0);
-		SkGeDeInit(pAC, pAC->IoBase);
-		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
-		pAC->BoardLevel = SK_INIT_DATA;
-		/* We do NOT check here, if IRQ was pending, of course*/
-	}
-
-	if (pAC->BoardLevel == SK_INIT_IO) {
-		/* board is still alive */
-		SkGeDeInit(pAC, pAC->IoBase);
-		pAC->BoardLevel = SK_INIT_DATA;
-	}
-
-	FreeResources(dev);
-	free_netdev(dev);
-	if (otherdev != dev)
-		free_netdev(otherdev);
-	kfree(pAC);
-}
-
-static struct pci_device_id skge_pci_tbl[] = {
-	{ PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_SYSKONNECT, 0x4300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_SYSKONNECT, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_DLINK, 0x4c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_MARVELL, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-#if 0	/* don't handle Yukon2 cards at the moment -- mlindner@syskonnect.de */
-	{ PCI_VENDOR_ID_MARVELL, 0x4360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_MARVELL, 0x4361, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-#endif
-	{ PCI_VENDOR_ID_MARVELL, 0x5005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_CNET, 0x434e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_LINKSYS, 0x1064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ 0, }
-};
-
-static struct pci_driver skge_driver = {
-	.name		= "skge",
-	.id_table	= skge_pci_tbl,
-	.probe		= skge_probe_one,
-	.remove		= __devexit_p(skge_remove_one),
-};
 
 static int __init skge_init(void)
 {

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (14/23) sk98: don't obfuscate irqreturn_t
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (12 preceding siblings ...)
  2004-11-12  0:01   ` [PATCH] (15/23) sk98: rearrange initialization Stephen Hemminger
@ 2004-11-12  0:01   ` Stephen Hemminger
  2004-11-12  0:02   ` [PATCH] (16/23) sk98: more efficient time OsGetTime Stephen Hemminger
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:01 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Dont redefine irqreturn_t and dev_kfree anymore.
It probably was done for compatiablity with 2.4 but we
are past that point now.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 16:26:15 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 16:26:15 -08:00
@@ -166,22 +166,12 @@
 // #define CON_TYPE 	{"Auto", }
 // #define RLMT_MODE	{"CheckLinkState", }
 
-#define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)
-#define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb)
-#define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb)
-
-
 /* Set blink mode*/
 #define OEM_CONFIG_VALUE (	SK_ACT_LED_BLINK | \
 				SK_DUP_LED_NORMAL | \
 				SK_LED_LINK100_ON)
 
 
-/* Isr return value */
-#define SkIsrRetVar	irqreturn_t
-#define SkIsrRetNone	IRQ_NONE
-#define SkIsrRetHandled	IRQ_HANDLED
-
 
 /*******************************************************************************
  *
@@ -195,8 +185,8 @@
 static void	BoardFreeMem(SK_AC *pAC);
 static void	BoardInitMem(SK_AC *pAC);
 static void	SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**, int*, SK_BOOL);
-static SkIsrRetVar	SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
-static SkIsrRetVar	SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
+static irqreturn_t	SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
+static irqreturn_t	SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
 static int	SkGeOpen(struct net_device *dev);
 static int	SkGeClose(struct net_device *dev);
 static int	SkGeXmit(struct sk_buff *skb, struct net_device *dev);
@@ -895,7 +885,7 @@
  * Returns: N/A
  *
  */
-static SkIsrRetVar SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs)
+static irqreturn_t SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs)
 {
 struct net_device *dev = (struct net_device *)dev_id;
 DEV_NET		*pNet;
@@ -909,8 +899,8 @@
 	 * Check and process if its our interrupt
 	 */
 	SK_IN32(pAC->IoBase, B0_SP_ISRC, &IntSrc);
-	if (IntSrc == 0) {
-		return SkIsrRetNone;
+	if (IntSrc == 0 || IntSrc == ~0) {
+		return IRQ_NONE;
 	}
 
 	while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
@@ -1027,7 +1017,7 @@
 	/* IRQ is processed - Enable IRQs again*/
 	SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
 
-		return SkIsrRetHandled;
+	return IRQ_HANDLED;
 } /* SkGeIsr */
 
 
@@ -1044,12 +1034,12 @@
  * Returns: N/A
  *
  */
-static SkIsrRetVar SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs)
+static irqreturn_t SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs)
 {
-struct net_device *dev = (struct net_device *)dev_id;
-DEV_NET		*pNet;
-SK_AC		*pAC;
-SK_U32		IntSrc;		/* interrupts source register contents */	
+struct net_device *dev = (struct net_device *)dev_id;
+DEV_NET		*pNet;
+SK_AC		*pAC;
+SK_U32		IntSrc;		/* interrupts source register contents */	
 
 	pNet = netdev_priv(dev);
 	pAC = pNet->pAC;
@@ -1058,30 +1048,30 @@
 	 * Check and process if its our interrupt
 	 */
 	SK_IN32(pAC->IoBase, B0_SP_ISRC, &IntSrc);
-	if (IntSrc == 0) {
-		return SkIsrRetNone;
+	if (IntSrc == 0 || IntSrc == ~0) {
+		return IRQ_NONE;
 	}
 	
 	while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
 #if 0 /* software irq currently not used */
 		if (IntSrc & IS_IRQ_SW) {
 			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
-				SK_DBGCAT_DRV_INT_SRC,
-				("Software IRQ\n"));
+				SK_DBGCAT_DRV_INT_SRC,
+				("Software IRQ\n"));
 		}
 #endif
 		if (IntSrc & IS_R1_F) {
 			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
-				SK_DBGCAT_DRV_INT_SRC,
-				("EOF RX1 IRQ\n"));
+				SK_DBGCAT_DRV_INT_SRC,
+				("EOF RX1 IRQ\n"));
 			ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
 			SK_PNMI_CNT_RX_INTR(pAC, 0);
 		}
 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
 		if (IntSrc & IS_XA1_F) {
 			SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
-				SK_DBGCAT_DRV_INT_SRC,
-				("EOF AS TX1 IRQ\n"));
+				SK_DBGCAT_DRV_INT_SRC,
+				("EOF AS TX1 IRQ\n"));
 			SK_PNMI_CNT_TX_INTR(pAC, 0);
 			spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
 			FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]);
@@ -1132,13 +1122,13 @@
 	 *           SkGeDrvEvent(), because it is timer
 	 *           guarded now
 	 *
-	ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
-	 */
+	ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
+	*/
 
 	/* IRQ is processed - Enable IRQs again*/
 	SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask);
 
-		return SkIsrRetHandled;
+	return IRQ_HANDLED;
 } /* SkGeIsrOnePort */
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1837,7 +1827,7 @@
 				 PCI_DMA_TODEVICE);
 
 		if (Control & BMU_EOF)
-			DEV_KFREE_SKB_ANY(pTxd->pMBuf);	/* free message */
+			dev_kfree_skb_any(pTxd->pMBuf);	/* free message */
 
 		pTxPort->TxdRingFree++;
 		pTxd->TBControl &= ~BMU_SW;
@@ -2267,7 +2257,7 @@
 				SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
 					SK_DBGCAT_DRV_RX_PROGRESS,
 					("D"));
-				DEV_KFREE_SKB(pMsg);
+				dev_kfree_skb(pMsg);
 			}
 			
 		} /* if not for rlmt */
@@ -2316,7 +2306,7 @@
 				pAC->dev[pRxPort->PortIndex]->last_rx = jiffies;
 			}
 			else {
-				DEV_KFREE_SKB(pMsg);
+				dev_kfree_skb(pMsg);
 			}
 
 		} /* if packet for rlmt */
@@ -2343,7 +2333,7 @@
 			 PhysAddr,
 			 pAC->RxBufSize - 2,
 			 PCI_DMA_FROMDEVICE);
-	DEV_KFREE_SKB_IRQ(pRxd->pMBuf);
+	dev_kfree_skb_irq(pRxd->pMBuf);
 	pRxd->pMBuf = NULL;
 	pRxPort->RxdRingFree++;
 	pRxPort->pRxdRingHead = pRxd->pNextRxd;
@@ -2426,7 +2416,7 @@
 					 PhysAddr,
 					 pAC->RxBufSize - 2,
 					 PCI_DMA_FROMDEVICE);
-			DEV_KFREE_SKB(pRxd->pMBuf);
+			dev_kfree_skb(pRxd->pMBuf);
 			pRxd->pMBuf = NULL;
 		}
 		pRxd->RBControl &= BMU_OWN;
@@ -3935,7 +3925,7 @@
 	pFreeMbuf = pMbuf;
 	do {
 		pNextMbuf = pFreeMbuf->pNext;
-		DEV_KFREE_SKB_ANY(pFreeMbuf->pOs);
+		dev_kfree_skb_any(pFreeMbuf->pOs);
 		pFreeMbuf = pNextMbuf;
 	} while ( pFreeMbuf != NULL );
 } /* SkDrvFreeRlmtMbuf */
@@ -4406,7 +4396,7 @@
 		if (XmitFrame(pAC, &pAC->TxPort[pRlmtMbuf->PortIdx][TX_PRIO_LOW],
 			pMsg) < 0)
 
-			DEV_KFREE_SKB_ANY(pMsg);
+			dev_kfree_skb_any(pMsg);
 		break;
 	case SK_DRV_TIMER:
 		if (Param.Para32[0] == SK_DRV_MODERATION_TIMER) {

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (16/23) sk98: more efficient time OsGetTime
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (13 preceding siblings ...)
  2004-11-12  0:01   ` [PATCH] (14/23) sk98: don't obfuscate irqreturn_t Stephen Hemminger
@ 2004-11-12  0:02   ` Stephen Hemminger
  2004-11-12  0:03   ` [PATCH] (17/23) sk98: use lockless transmit Stephen Hemminger
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:02 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Avoid doing a gettimeofday to only get low resolution time.
Can use jiffies_64 and internal 64 bit divide to get what is
needed.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/h/skdrv1st.h b/drivers/net/sk98lin/h/skdrv1st.h
--- a/drivers/net/sk98lin/h/skdrv1st.h	2004-11-03 17:06:12 -08:00
+++ b/drivers/net/sk98lin/h/skdrv1st.h	2004-11-03 17:06:12 -08:00
@@ -96,9 +96,6 @@
 #define SK_BIG_ENDIAN
 #endif
 
-/* we use gethrtime(), return unit: nanoseconds */
-#define SK_TICKS_PER_SEC	100
-
 #define	SK_MEM_MAPPED_IO
 
 // #define SK_RLMT_SLOW_LOOKAHEAD
diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-03 17:06:12 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-03 17:06:12 -08:00
@@ -56,7 +56,6 @@
 
 extern SK_MBUF		*SkDrvAllocRlmtMbuf(SK_AC*, SK_IOC, unsigned);
 extern void		SkDrvFreeRlmtMbuf(SK_AC*, SK_IOC, SK_MBUF*);
-extern SK_U64		SkOsGetTime(SK_AC*);
 extern int		SkPciReadCfgDWord(SK_AC*, int, SK_U32*);
 extern int		SkPciReadCfgWord(SK_AC*, int, SK_U16*);
 extern int		SkPciReadCfgByte(SK_AC*, int, SK_U8*);
@@ -83,25 +82,28 @@
 };
 
 
-/*
- * Time macros
- */
-#if SK_TICKS_PER_SEC == 100
-#define SK_PNMI_HUNDREDS_SEC(t)	(t)
+/* Units used for timing measurements. */
+#define SK_TICKS_PER_SEC	HZ
+
+/* OS time value in HZ (1000 or 100) */
+static inline SK_U64 SkOsGetTime(const SK_AC *pAC)
+{
+	return get_jiffies_64();
+}
+
+/* Convert OS time units to hundredth's of sec */
+static inline SK_U64 jiffies_64_to_hsecs(u64 t)
+{
+#if (HZ % 100) == 0
+	do_div(t, HZ / 100);
 #else
-#define SK_PNMI_HUNDREDS_SEC(t)	((((unsigned long)t) * 100) / \
-										(SK_TICKS_PER_SEC))
+	t *= 100;
+	do_div(x, HZ);
 #endif
-
-/*
- * New SkOsGetTime
- */
-#define SkOsGetTimeCurrent(pAC, pUsec) {\
-	struct timeval t;\
-	do_gettimeofday(&t);\
-	*pUsec = ((((t.tv_sec) * 1000000L)+t.tv_usec)/10000);\
+	return t;
 }
 
+#define SK_PNMI_HUNDREDS_SEC(t)	jiffies_64_to_hsecs(t)
 
 /*
  * ioctl definitions
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 17:06:12 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 17:06:12 -08:00
@@ -4221,26 +4221,6 @@
 
 /*****************************************************************************
  *
- *	SkOsGetTime - provide a time value
- *
- * Description:
- *	This routine provides a time value. The unit is 1/HZ (defined by Linux).
- *	It is not used for absolute time, but only for time differences.
- *
- *
- * Returns:
- *	Time value
- */
-SK_U64 SkOsGetTime(SK_AC *pAC)
-{
-	SK_U64	PrivateJiffies;
-	SkOsGetTimeCurrent(pAC, &PrivateJiffies);
-	return PrivateJiffies;
-} /* SkOsGetTime */
-
-
-/*****************************************************************************
- *
  *	SkPciReadCfgDWord - read a 32 bit value from pci config space
  *
  * Description:

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (17/23) sk98: use lockless transmit
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (14 preceding siblings ...)
  2004-11-12  0:02   ` [PATCH] (16/23) sk98: more efficient time OsGetTime Stephen Hemminger
@ 2004-11-12  0:03   ` Stephen Hemminger
  2004-11-12  0:07   ` [PATCH] (20/23) sk98: checksum ethtool and improvements Stephen Hemminger
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:03 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

This driver lends it self to the new lockless transmit hook in 2.6.
Also, flag that driver can do 64 bit DMA, if it is successful in
setting the bigger mask.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 18:57:15 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 18:57:15 -08:00
@@ -323,6 +323,7 @@
 	DEV_NET			*pNet = NULL;
 	struct net_device	*dev = NULL;
 	static int boards_found = 0;
+	int pci_using_dac  = 0;
 	int error = -ENODEV;
 
 	error = pci_enable_device(pdev);
@@ -332,8 +333,9 @@
 	}
  
 	/* Configure DMA attributes. */
-	if ((error = pci_set_dma_mask(pdev, (u64) 0xffffffffffffffffULL)) ||
-	    (error = pci_set_dma_mask(pdev, (u64) 0xffffffff))) {
+	if (!(error = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) 
+		pci_using_dac = 1;
+	else if ((error = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
 		printk(KERN_ERR "sk98lin: cannot set PCI dma mask\n");
 		goto out_disable_device;
 	}
@@ -375,6 +377,8 @@
 	}
 
 	SkGeDevInit(dev, pdev);
+	if (pci_using_dac)
+		dev->features |= NETIF_F_HIGHDMA;
 
 	pAC->Index = boards_found++;
 
@@ -438,6 +442,9 @@
 
 		SkGeDevInit(dev, pdev);
 
+		if (pci_using_dac)
+			dev->features |= NETIF_F_HIGHDMA;
+
 #ifdef SK_ZEROCOPY
 #ifdef USE_SK_TX_CHECKSUM
 		if (pAC->ChipsetType)
@@ -447,7 +454,6 @@
 #endif
 #endif
 
-
 		if (register_netdev(dev)) {
 			printk(KERN_ERR "SKGE: Could not register device.\n");
 			free_netdev(dev);
@@ -501,9 +507,10 @@
 #endif
 	SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
 	SET_NETDEV_DEV(dev, &pdev->dev);
-}
-
 
+	dev->flags &= ~IFF_RUNNING;
+	dev->features |= NETIF_F_LLTX;
+}
 /*****************************************************************************
  *
  * 	SkGeInitPCI - Init the PCI resources
@@ -1707,7 +1714,13 @@
 	else
 		pTxPort = &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW];
 
-	spin_lock_irqsave(&pTxPort->TxDesRingLock, flags);
+ 	local_irq_save(flags); 
+ 	if (!spin_trylock(&pTxPort->TxDesRingLock)) {
+ 		/* Collision - tell upper layer to requeue */ 
+ 		local_irq_restore(flags); 
+ 		return NETDEV_TX_LOCKED; 
+ 	} 
+
 	if ((!skb_shinfo(skb)->nr_frags) ||
 		(pAC->GIni.GIChipId == CHIP_ID_GENESIS)) {
 		/* Don't activate scatter-gather and hardware checksum */

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (20/23) sk98: checksum ethtool and improvements
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (15 preceding siblings ...)
  2004-11-12  0:03   ` [PATCH] (17/23) sk98: use lockless transmit Stephen Hemminger
@ 2004-11-12  0:07   ` Stephen Hemminger
  2004-11-12  0:07   ` [PATCH] (19/23) sk98: more cleanups Stephen Hemminger
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:07 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

The driver was going through a lot of work to use portable code
for receive checksum offload. On Linux it much simpler, and all that
code can be eliminated. 

Make transmit/receive checksum controllable by ethtool.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>


diff -Nru a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile
--- a/drivers/net/sk98lin/Makefile	2004-11-10 11:29:48 -08:00
+++ b/drivers/net/sk98lin/Makefile	2004-11-10 11:29:48 -08:00
@@ -26,9 +26,11 @@
 		skrlmt.o	\
 		sktimer.o	\
 		skvpd.o		\
-		skxmac2.o	\
-		skproc.o	\
-		skcsum.o
+		skxmac2.o
+
+ifdef CONFIG_PROC_FS
+sk98lin-objs	+= skproc.o
+endif
 
 # DBGDEF =  \
 # -DDEBUG
@@ -77,7 +79,8 @@
 # SK_DBGCAT_DRV_INT_SRC         0x04000000      interrupts sources
 # SK_DBGCAT_DRV_EVENT           0x08000000      driver events
 
-EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DSK_USE_CSUM -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM)
+EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT \
+	 -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM)
 
 clean:
 	rm -f core *.o *.a *.s
diff -Nru a/drivers/net/sk98lin/h/skcsum.h b/drivers/net/sk98lin/h/skcsum.h
--- a/drivers/net/sk98lin/h/skcsum.h	2004-11-10 11:29:48 -08:00
+++ b/drivers/net/sk98lin/h/skcsum.h	2004-11-10 11:29:48 -08:00
@@ -155,11 +155,11 @@
  * s_Csum - The CSUM module context structure.
  */
 typedef struct s_Csum {
+#ifdef SK_USE_CSUM
 	/* Enabled receive SK_PROTO_XXX bit flags. */
 	unsigned ReceiveFlags[SK_MAX_NETS];
-#ifdef TX_CSUM
 	unsigned TransmitFlags[SK_MAX_NETS];
-#endif /* TX_CSUM */
+#endif
 
 	/* The protocol statistics structure; one per supported protocol. */
 	SKCS_PROTO_STATS ProtoStats[SK_MAX_NETS][SKCS_NUM_PROTOCOLS];
diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-10 11:29:48 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-10 11:29:48 -08:00
@@ -200,6 +200,13 @@
 #define C_PROTO_ID_UDP                  17       /* refer to RFC 790 or Stevens'   */
 #define C_PROTO_ID_TCP                  6        /* TCP/IP illustrated for details */
 
+/*
+** Hardware supports receive checksumming starting at two offsets
+** Linux only uses the first one (skip ether header).
+*/
+#define SK_CHECKSUM_OFFSET_1	ETH_HLEN
+#define SK_CHECKSUM_OFFSET_2	(ETH_HLEN + 20)
+
 /* TX and RX descriptors *****************************************************/
 
 typedef struct s_RxD RXD; /* the receive descriptor */
@@ -302,6 +309,7 @@
 	int		RxFillLimit;	/* limit for buffers in ring */
 	SK_IOC		HwAddr;		/* bmu registers address */
 	int		PortIndex;	/* index number of port (0 or 1) */
+	SK_BOOL         UseRxCsum;      /* use Rx checksumming (yes/no)  */
 };
 
 /* Definitions needed for interrupt moderation *******************************/
@@ -410,10 +418,6 @@
 	/* the port structures with descriptor rings */
 	TX_PORT		TxPort[SK_MAX_MACS][2];
 	RX_PORT		RxPort[SK_MAX_MACS];
-
-	unsigned int	CsOfs1;		/* for checksum calculation */
-	unsigned int	CsOfs2;		/* for checksum calculation */
-	SK_U32		CsOfs;		/* for checksum calculation */
 
 	SK_BOOL		CheckQueue;	/* check event queue soon */
 	SK_TIMER        DrvCleanupTimer;/* to check for pending descriptors */
diff -Nru a/drivers/net/sk98lin/skcsum.c b/drivers/net/sk98lin/skcsum.c
--- a/drivers/net/sk98lin/skcsum.c	2004-11-10 11:29:48 -08:00
+++ /dev/null	Wed Dec 31 16:00:00 196900
@@ -1,871 +0,0 @@
-/******************************************************************************
- *
- * Name:	skcsum.c
- * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.12 $
- * Date:	$Date: 2003/08/20 13:55:53 $
- * Purpose:	Store/verify Internet checksum in send/receive packets.
- *
- ******************************************************************************/
-
-/******************************************************************************
- *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
- *
- *	This program is free software; you can redistribute it and/or modify
- *	it under the terms of the GNU General Public License as published by
- *	the Free Software Foundation; either version 2 of the License, or
- *	(at your option) any later version.
- *
- *	The information in this file is provided "AS IS" without warranty.
- *
- ******************************************************************************/
-
-#ifdef SK_USE_CSUM	/* Check if CSUM is to be used. */
-
-#ifndef lint
-static const char SysKonnectFileId[] =
-	"@(#) $Id: skcsum.c,v 1.12 2003/08/20 13:55:53 mschmid Exp $ (C) SysKonnect.";
-#endif	/* !lint */
-
-/******************************************************************************
- *
- * Description:
- *
- * This is the "GEnesis" common module "CSUM".
- *
- * This module contains the code necessary to calculate, store, and verify the
- * Internet Checksum of IP, TCP, and UDP frames.
- *
- * "GEnesis" is an abbreviation of "Gigabit Ethernet Network System in Silicon"
- * and is the code name of this SysKonnect project.
- *
- * Compilation Options:
- *
- *	SK_USE_CSUM - Define if CSUM is to be used. Otherwise, CSUM will be an
- *	empty module.
- *
- *	SKCS_OVERWRITE_PROTO - Define to overwrite the default protocol id
- *	definitions. In this case, all SKCS_PROTO_xxx definitions must be made
- *	external.
- *
- *	SKCS_OVERWRITE_STATUS - Define to overwrite the default return status
- *	definitions. In this case, all SKCS_STATUS_xxx definitions must be made
- *	external.
- *
- * Include File Hierarchy:
- *
- *	"h/skdrv1st.h"
- *	"h/skcsum.h"
- *	"h/sktypes.h"
- *	"h/skqueue.h"
- *	"h/skdrv2nd.h"
- *
- ******************************************************************************/
-
-#include "h/skdrv1st.h"
-#include "h/skcsum.h"
-#include "h/skdrv2nd.h"
-
-/* defines ********************************************************************/
-
-/* The size of an Ethernet MAC header. */
-#define SKCS_ETHERNET_MAC_HEADER_SIZE			(6+6+2)
-
-/* The size of the used topology's MAC header. */
-#define	SKCS_MAC_HEADER_SIZE	SKCS_ETHERNET_MAC_HEADER_SIZE
-
-/* The size of the IP header without any option fields. */
-#define SKCS_IP_HEADER_SIZE						20
-
-/*
- * Field offsets within the IP header.
- */
-
-/* "Internet Header Version" and "Length". */
-#define SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH	0
-
-/* "Total Length". */
-#define SKCS_OFS_IP_TOTAL_LENGTH				2
-
-/* "Flags" "Fragment Offset". */
-#define SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET	6
-
-/* "Next Level Protocol" identifier. */
-#define SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL			9
-
-/* Source IP address. */
-#define SKCS_OFS_IP_SOURCE_ADDRESS				12
-
-/* Destination IP address. */
-#define SKCS_OFS_IP_DESTINATION_ADDRESS			16
-
-
-/*
- * Field offsets within the UDP header.
- */
-
-/* UDP checksum. */
-#define SKCS_OFS_UDP_CHECKSUM					6
-
-/* IP "Next Level Protocol" identifiers (see RFC 790). */
-#define SKCS_PROTO_ID_TCP		6	/* Transport Control Protocol */
-#define SKCS_PROTO_ID_UDP		17	/* User Datagram Protocol */
-
-/* IP "Don't Fragment" bit. */
-#define SKCS_IP_DONT_FRAGMENT	SKCS_HTON16(0x4000)
-
-/* Add a byte offset to a pointer. */
-#define SKCS_IDX(pPtr, Ofs)	((void *) ((char *) (pPtr) + (Ofs)))
-
-/*
- * Macros that convert host to network representation and vice versa, i.e.
- * little/big endian conversion on little endian machines only.
- */
-#ifdef SK_LITTLE_ENDIAN
-#define SKCS_HTON16(Val16)	(((unsigned) (Val16) >> 8) | (((Val16) & 0xff) << 8))
-#endif	/* SK_LITTLE_ENDIAN */
-#ifdef SK_BIG_ENDIAN
-#define SKCS_HTON16(Val16)	(Val16)
-#endif	/* SK_BIG_ENDIAN */
-#define SKCS_NTOH16(Val16)	SKCS_HTON16(Val16)
-
-/* typedefs *******************************************************************/
-
-/* function prototypes ********************************************************/
-
-/******************************************************************************
- *
- *	SkCsGetSendInfo - get checksum information for a send packet
- *
- * Description:
- *	Get all checksum information necessary to send a TCP or UDP packet. The
- *	function checks the IP header passed to it. If the high-level protocol
- *	is either TCP or UDP the pseudo header checksum is calculated and
- *	returned.
- *
- *	The function returns the total length of the IP header (including any
- *	IP option fields), which is the same as the start offset of the IP data
- *	which in turn is the start offset of the TCP or UDP header.
- *
- *	The function also returns the TCP or UDP pseudo header checksum, which
- *	should be used as the start value for the hardware checksum calculation.
- *	(Note that any actual pseudo header checksum can never calculate to
- *	zero.)
- *
- * Note:
- *	There is a bug in the GENESIS ASIC which may lead to wrong checksums.
- *
- * Arguments:
- *	pAc - A pointer to the adapter context struct.
- *
- *	pIpHeader - Pointer to IP header. Must be at least the IP header *not*
- *	including any option fields, i.e. at least 20 bytes.
- *
- *	Note: This pointer will be used to address 8-, 16-, and 32-bit
- *	variables with the respective alignment offsets relative to the pointer.
- *	Thus, the pointer should point to a 32-bit aligned address. If the
- *	target system cannot address 32-bit variables on non 32-bit aligned
- *	addresses, then the pointer *must* point to a 32-bit aligned address.
- *
- *	pPacketInfo - A pointer to the packet information structure for this
- *	packet. Before calling this SkCsGetSendInfo(), the following field must
- *	be initialized:
- *
- *		ProtocolFlags - Initialize with any combination of
- *		SKCS_PROTO_XXX bit flags. SkCsGetSendInfo() will only work on
- *		the protocols specified here. Any protocol(s) not specified
- *		here will be ignored.
- *
- *		Note: Only one checksum can be calculated in hardware. Thus, if
- *		SKCS_PROTO_IP is specified in the 'ProtocolFlags',
- *		SkCsGetSendInfo() must calculate the IP header checksum in
- *		software. It might be a better idea to have the calling
- *		protocol stack calculate the IP header checksum.
- *
- * Returns: N/A
- *	On return, the following fields in 'pPacketInfo' may or may not have
- *	been filled with information, depending on the protocol(s) found in the
- *	packet:
- *
- *	ProtocolFlags - Returns the SKCS_PROTO_XXX bit flags of the protocol(s)
- *	that were both requested by the caller and actually found in the packet.
- *	Protocol(s) not specified by the caller and/or not found in the packet
- *	will have their respective SKCS_PROTO_XXX bit flags reset.
- *
- *	Note: For IP fragments, TCP and UDP packet information is ignored.
- *
- *	IpHeaderLength - The total length in bytes of the complete IP header
- *	including any option fields is returned here. This is the start offset
- *	of the IP data, i.e. the TCP or UDP header if present.
- *
- *	IpHeaderChecksum - If IP has been specified in the 'ProtocolFlags', the
- *	16-bit Internet Checksum of the IP header is returned here. This value
- *	is to be stored into the packet's 'IP Header Checksum' field.
- *
- *	PseudoHeaderChecksum - If this is a TCP or UDP packet and if TCP or UDP
- *	has been specified in the 'ProtocolFlags', the 16-bit Internet Checksum
- *	of the TCP or UDP pseudo header is returned here.
- */
-void SkCsGetSendInfo(
-SK_AC				*pAc,			/* Adapter context struct. */
-void				*pIpHeader,		/* IP header. */
-SKCS_PACKET_INFO	*pPacketInfo,	/* Packet information struct. */
-int					NetNumber)		/* Net number */
-{
-	/* Internet Header Version found in IP header. */
-	unsigned InternetHeaderVersion;
-
-	/* Length of the IP header as found in IP header. */
-	unsigned IpHeaderLength;
-
-	/* Bit field specifiying the desired/found protocols. */
-	unsigned ProtocolFlags;
-
-	/* Next level protocol identifier found in IP header. */
-	unsigned NextLevelProtocol;
-
-	/* Length of IP data portion. */
-	unsigned IpDataLength;
-
-	/* TCP/UDP pseudo header checksum. */
-	unsigned long PseudoHeaderChecksum;
-
-	/* Pointer to next level protocol statistics structure. */
-	SKCS_PROTO_STATS *NextLevelProtoStats;
-
-	/* Temporary variable. */
-	unsigned Tmp;
-
-	Tmp = *(SK_U8 *)
-		SKCS_IDX(pIpHeader, SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH);
-
-	/* Get the Internet Header Version (IHV). */
-	/* Note: The IHV is stored in the upper four bits. */
-
-	InternetHeaderVersion = Tmp >> 4;
-
-	/* Check the Internet Header Version. */
-	/* Note: We currently only support IP version 4. */
-
-	if (InternetHeaderVersion != 4) {	/* IPv4? */
-		SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_TX,
-			("Tx: Unknown Internet Header Version %u.\n",
-			InternetHeaderVersion));
-		pPacketInfo->ProtocolFlags = 0;
-		pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
-		return;
-	}
-
-	/* Get the IP header length (IHL). */
-	/*
-	 * Note: The IHL is stored in the lower four bits as the number of
-	 * 4-byte words.
-	 */
-
-	IpHeaderLength = (Tmp & 0xf) * 4;
-	pPacketInfo->IpHeaderLength = IpHeaderLength;
-
-	/* Check the IP header length. */
-
-	/* 04-Aug-1998 sw - Really check the IHL? Necessary? */
-
-	if (IpHeaderLength < 5*4) {
-		SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_TX,
-			("Tx: Invalid IP Header Length %u.\n", IpHeaderLength));
-		pPacketInfo->ProtocolFlags = 0;
-		pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
-		return;
-	}
-
-	/* This is an IPv4 frame with a header of valid length. */
-
-	pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxOkCts++;
-
-	/* Check if we should calculate the IP header checksum. */
-
-	ProtocolFlags = pPacketInfo->ProtocolFlags;
-
-	if (ProtocolFlags & SKCS_PROTO_IP) {
-		pPacketInfo->IpHeaderChecksum =
-			SkCsCalculateChecksum(pIpHeader, IpHeaderLength);
-	}
-
-	/* Get the next level protocol identifier. */
-
-	NextLevelProtocol =
-		*(SK_U8 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL);
-
-	/*
-	 * Check if this is a TCP or UDP frame and if we should calculate the
-	 * TCP/UDP pseudo header checksum.
-	 *
-	 * Also clear all protocol bit flags of protocols not present in the
-	 * frame.
-	 */
-
-	if ((ProtocolFlags & SKCS_PROTO_TCP) != 0 &&
-		NextLevelProtocol == SKCS_PROTO_ID_TCP) {
-		/* TCP/IP frame. */
-		ProtocolFlags &= SKCS_PROTO_TCP | SKCS_PROTO_IP;
-		NextLevelProtoStats =
-			&pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_TCP];
-	}
-	else if ((ProtocolFlags & SKCS_PROTO_UDP) != 0 &&
-		NextLevelProtocol == SKCS_PROTO_ID_UDP) {
-		/* UDP/IP frame. */
-		ProtocolFlags &= SKCS_PROTO_UDP | SKCS_PROTO_IP;
-		NextLevelProtoStats =
-			&pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
-	}
-	else {
-		/*
-		 * Either not a TCP or UDP frame and/or TCP/UDP processing not
-		 * specified.
-		 */
-		pPacketInfo->ProtocolFlags = ProtocolFlags & SKCS_PROTO_IP;
-		return;
-	}
-
-	/* Check if this is an IP fragment. */
-
-	/*
-	 * Note: An IP fragment has a non-zero "Fragment Offset" field and/or
-	 * the "More Fragments" bit set. Thus, if both the "Fragment Offset"
-	 * and the "More Fragments" are zero, it is *not* a fragment. We can
-	 * easily check both at the same time since they are in the same 16-bit
-	 * word.
-	 */
-
-	if ((*(SK_U16 *)
-		SKCS_IDX(pIpHeader, SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET) &
-		~SKCS_IP_DONT_FRAGMENT) != 0) {
-		/* IP fragment; ignore all other protocols. */
-		pPacketInfo->ProtocolFlags = ProtocolFlags & SKCS_PROTO_IP;
-		NextLevelProtoStats->TxUnableCts++;
-		return;
-	}
-
-	/*
-	 * Calculate the TCP/UDP pseudo header checksum.
-	 */
-
-	/* Get total length of IP header and data. */
-
-	IpDataLength =
-		*(SK_U16 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_TOTAL_LENGTH);
-
-	/* Get length of IP data portion. */
-
-	IpDataLength = SKCS_NTOH16(IpDataLength) - IpHeaderLength;
-
-	/* Calculate the sum of all pseudo header fields (16-bit). */
-
-	PseudoHeaderChecksum =
-		(unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
-			SKCS_OFS_IP_SOURCE_ADDRESS + 0) +
-		(unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
-			SKCS_OFS_IP_SOURCE_ADDRESS + 2) +
-		(unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
-			SKCS_OFS_IP_DESTINATION_ADDRESS + 0) +
-		(unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
-			SKCS_OFS_IP_DESTINATION_ADDRESS + 2) +
-		(unsigned long) SKCS_HTON16(NextLevelProtocol) +
-		(unsigned long) SKCS_HTON16(IpDataLength);
-	
-	/* Add-in any carries. */
-
-	SKCS_OC_ADD(PseudoHeaderChecksum, PseudoHeaderChecksum, 0);
-
-	/* Add-in any new carry. */
-
-	SKCS_OC_ADD(pPacketInfo->PseudoHeaderChecksum, PseudoHeaderChecksum, 0);
-
-	pPacketInfo->ProtocolFlags = ProtocolFlags;
-	NextLevelProtoStats->TxOkCts++;	/* Success. */
-}	/* SkCsGetSendInfo */
-
-
-/******************************************************************************
- *
- *	SkCsGetReceiveInfo - verify checksum information for a received packet
- *
- * Description:
- *	Verify a received frame's checksum. The function returns a status code
- *	reflecting the result of the verification.
- *
- * Note:
- *	Before calling this function you have to verify that the frame is
- *	not padded and Checksum1 and Checksum2 are bigger than 1.
- *
- * Arguments:
- *	pAc - Pointer to adapter context struct.
- *
- *	pIpHeader - Pointer to IP header. Must be at least the length in bytes
- *	of the received IP header including any option fields. For UDP packets,
- *	8 additional bytes are needed to access the UDP checksum.
- *
- *	Note: The actual length of the IP header is stored in the lower four
- *	bits of the first octet of the IP header as the number of 4-byte words,
- *	so it must be multiplied by four to get the length in bytes. Thus, the
- *	maximum IP header length is 15 * 4 = 60 bytes.
- *
- *	Checksum1 - The first 16-bit Internet Checksum calculated by the
- *	hardware starting at the offset returned by SkCsSetReceiveFlags().
- *
- *	Checksum2 - The second 16-bit Internet Checksum calculated by the
- *	hardware starting at the offset returned by SkCsSetReceiveFlags().
- *
- * Returns:
- *	SKCS_STATUS_UNKNOWN_IP_VERSION - Not an IP v4 frame.
- *	SKCS_STATUS_IP_CSUM_ERROR - IP checksum error.
- *	SKCS_STATUS_IP_CSUM_ERROR_TCP - IP checksum error in TCP frame.
- *	SKCS_STATUS_IP_CSUM_ERROR_UDP - IP checksum error in UDP frame
- *	SKCS_STATUS_IP_FRAGMENT - IP fragment (IP checksum ok).
- *	SKCS_STATUS_IP_CSUM_OK - IP checksum ok (not a TCP or UDP frame).
- *	SKCS_STATUS_TCP_CSUM_ERROR - TCP checksum error (IP checksum ok).
- *	SKCS_STATUS_UDP_CSUM_ERROR - UDP checksum error (IP checksum ok).
- *	SKCS_STATUS_TCP_CSUM_OK - IP and TCP checksum ok.
- *	SKCS_STATUS_UDP_CSUM_OK - IP and UDP checksum ok.
- *	SKCS_STATUS_IP_CSUM_OK_NO_UDP - IP checksum OK and no UDP checksum.
- *
- *	Note: If SKCS_OVERWRITE_STATUS is defined, the SKCS_STATUS_XXX values
- *	returned here can be defined in some header file by the module using CSUM.
- *	In this way, the calling module can assign return values for its own needs,
- *	e.g. by assigning bit flags to the individual protocols.
- */
-SKCS_STATUS SkCsGetReceiveInfo(
-SK_AC		*pAc,		/* Adapter context struct. */
-void		*pIpHeader,	/* IP header. */
-unsigned	Checksum1,	/* Hardware checksum 1. */
-unsigned	Checksum2,	/* Hardware checksum 2. */
-int			NetNumber)	/* Net number */
-{
-	/* Internet Header Version found in IP header. */
-	unsigned InternetHeaderVersion;
-
-	/* Length of the IP header as found in IP header. */
-	unsigned IpHeaderLength;
-
-	/* Length of IP data portion. */
-	unsigned IpDataLength;
-
-	/* IP header checksum. */
-	unsigned IpHeaderChecksum;
-
-	/* IP header options checksum, if any. */
-	unsigned IpOptionsChecksum;
-
-	/* IP data checksum, i.e. TCP/UDP checksum. */
-	unsigned IpDataChecksum;
-
-	/* Next level protocol identifier found in IP header. */
-	unsigned NextLevelProtocol;
-
-	/* The checksum of the "next level protocol", i.e. TCP or UDP. */
-	unsigned long NextLevelProtocolChecksum;
-
-	/* Pointer to next level protocol statistics structure. */
-	SKCS_PROTO_STATS *NextLevelProtoStats;
-
-	/* Temporary variable. */
-	unsigned Tmp;
-
-	Tmp = *(SK_U8 *)
-		SKCS_IDX(pIpHeader, SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH);
-
-	/* Get the Internet Header Version (IHV). */
-	/* Note: The IHV is stored in the upper four bits. */
-
-	InternetHeaderVersion = Tmp >> 4;
-
-	/* Check the Internet Header Version. */
-	/* Note: We currently only support IP version 4. */
-
-	if (InternetHeaderVersion != 4) {	/* IPv4? */
-		SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_RX,
-			("Rx: Unknown Internet Header Version %u.\n",
-			InternetHeaderVersion));
-		pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxUnableCts++;
-		return (SKCS_STATUS_UNKNOWN_IP_VERSION);
-	}
-
-	/* Get the IP header length (IHL). */
-	/*
-	 * Note: The IHL is stored in the lower four bits as the number of
-	 * 4-byte words.
-	 */
-
-	IpHeaderLength = (Tmp & 0xf) * 4;
-
-	/* Check the IP header length. */
-
-	/* 04-Aug-1998 sw - Really check the IHL? Necessary? */
-
-	if (IpHeaderLength < 5*4) {
-		SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_RX,
-			("Rx: Invalid IP Header Length %u.\n", IpHeaderLength));
-		pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxErrCts++;
-		return (SKCS_STATUS_IP_CSUM_ERROR);
-	}
-
-	/* This is an IPv4 frame with a header of valid length. */
-
-	/* Get the IP header and data checksum. */
-
-	IpDataChecksum = Checksum2;
-
-	/*
-	 * The IP header checksum is calculated as follows:
-	 *
-	 *	IpHeaderChecksum = Checksum1 - Checksum2
-	 */
-
-	SKCS_OC_SUB(IpHeaderChecksum, Checksum1, Checksum2);
-
-	/* Check if any IP header options. */
-
-	if (IpHeaderLength > SKCS_IP_HEADER_SIZE) {
-
-		/* Get the IP options checksum. */
-
-		IpOptionsChecksum = SkCsCalculateChecksum(
-			SKCS_IDX(pIpHeader, SKCS_IP_HEADER_SIZE),
-			IpHeaderLength - SKCS_IP_HEADER_SIZE);
-
-		/* Adjust the IP header and IP data checksums. */
-
-		SKCS_OC_ADD(IpHeaderChecksum, IpHeaderChecksum, IpOptionsChecksum);
-
-		SKCS_OC_SUB(IpDataChecksum, IpDataChecksum, IpOptionsChecksum);
-	}
-
-	/*
-	 * Check if the IP header checksum is ok.
-	 *
-	 * NOTE: We must check the IP header checksum even if the caller just wants
-	 * us to check upper-layer checksums, because we cannot do any further
-	 * processing of the packet without a valid IP checksum.
-	 */
-	
-	/* Get the next level protocol identifier. */
-	
-	NextLevelProtocol = *(SK_U8 *)
-		SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL);
-
-	if (IpHeaderChecksum != 0xffff) {
-		pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxErrCts++;
-		/* the NDIS tester wants to know the upper level protocol too */
-		if (NextLevelProtocol == SKCS_PROTO_ID_TCP) {
-			return(SKCS_STATUS_IP_CSUM_ERROR_TCP);
-		}
-		else if (NextLevelProtocol == SKCS_PROTO_ID_UDP) {
-			return(SKCS_STATUS_IP_CSUM_ERROR_UDP);
-		}
-		return (SKCS_STATUS_IP_CSUM_ERROR);
-	}
-
-	/*
-	 * Check if this is a TCP or UDP frame and if we should calculate the
-	 * TCP/UDP pseudo header checksum.
-	 *
-	 * Also clear all protocol bit flags of protocols not present in the
-	 * frame.
-	 */
-
-	if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_TCP) != 0 &&
-		NextLevelProtocol == SKCS_PROTO_ID_TCP) {
-		/* TCP/IP frame. */
-		NextLevelProtoStats =
-			&pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_TCP];
-	}
-	else if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_UDP) != 0 &&
-		NextLevelProtocol == SKCS_PROTO_ID_UDP) {
-		/* UDP/IP frame. */
-		NextLevelProtoStats =
-			&pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
-	}
-	else {
-		/*
-		 * Either not a TCP or UDP frame and/or TCP/UDP processing not
-		 * specified.
-		 */
-		return (SKCS_STATUS_IP_CSUM_OK);
-	}
-
-	/* Check if this is an IP fragment. */
-
-	/*
-	 * Note: An IP fragment has a non-zero "Fragment Offset" field and/or
-	 * the "More Fragments" bit set. Thus, if both the "Fragment Offset"
-	 * and the "More Fragments" are zero, it is *not* a fragment. We can
-	 * easily check both at the same time since they are in the same 16-bit
-	 * word.
-	 */
-
-	if ((*(SK_U16 *)
-		SKCS_IDX(pIpHeader, SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET) &
-		~SKCS_IP_DONT_FRAGMENT) != 0) {
-		/* IP fragment; ignore all other protocols. */
-		NextLevelProtoStats->RxUnableCts++;
-		return (SKCS_STATUS_IP_FRAGMENT);
-	}
-
-	/*
-	 * 08-May-2000 ra
-	 *
-	 * From RFC 768 (UDP)
-	 * If the computed checksum is zero, it is transmitted as all ones (the
-	 * equivalent in one's complement arithmetic).  An all zero transmitted
-	 * checksum value means that the transmitter generated no checksum (for
-	 * debugging or for higher level protocols that don't care).
-	 */
-
-	if (NextLevelProtocol == SKCS_PROTO_ID_UDP &&
-		*(SK_U16*)SKCS_IDX(pIpHeader, IpHeaderLength + 6) == 0x0000) {
-
-		NextLevelProtoStats->RxOkCts++;
-		
-		return (SKCS_STATUS_IP_CSUM_OK_NO_UDP);
-	}
-
-	/*
-	 * Calculate the TCP/UDP checksum.
-	 */
-
-	/* Get total length of IP header and data. */
-
-	IpDataLength =
-		*(SK_U16 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_TOTAL_LENGTH);
-
-	/* Get length of IP data portion. */
-
-	IpDataLength = SKCS_NTOH16(IpDataLength) - IpHeaderLength;
-
-	NextLevelProtocolChecksum =
-
-		/* Calculate the pseudo header checksum. */
-
-		(unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
-			SKCS_OFS_IP_SOURCE_ADDRESS + 0) +
-		(unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
-			SKCS_OFS_IP_SOURCE_ADDRESS + 2) +
-		(unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
-			SKCS_OFS_IP_DESTINATION_ADDRESS + 0) +
-		(unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
-			SKCS_OFS_IP_DESTINATION_ADDRESS + 2) +
-		(unsigned long) SKCS_HTON16(NextLevelProtocol) +
-		(unsigned long) SKCS_HTON16(IpDataLength) +
-
-		/* Add the TCP/UDP header checksum. */
-
-		(unsigned long) IpDataChecksum;
-
-	/* Add-in any carries. */
-
-	SKCS_OC_ADD(NextLevelProtocolChecksum, NextLevelProtocolChecksum, 0);
-
-	/* Add-in any new carry. */
-
-	SKCS_OC_ADD(NextLevelProtocolChecksum, NextLevelProtocolChecksum, 0);
-
-	/* Check if the TCP/UDP checksum is ok. */
-
-	if ((unsigned) NextLevelProtocolChecksum == 0xffff) {
-
-		/* TCP/UDP checksum ok. */
-
-		NextLevelProtoStats->RxOkCts++;
-
-		return (NextLevelProtocol == SKCS_PROTO_ID_TCP ?
-			SKCS_STATUS_TCP_CSUM_OK : SKCS_STATUS_UDP_CSUM_OK);
-	}
-	
-	/* TCP/UDP checksum error. */
-
-	NextLevelProtoStats->RxErrCts++;
-
-	return (NextLevelProtocol == SKCS_PROTO_ID_TCP ?
-		SKCS_STATUS_TCP_CSUM_ERROR : SKCS_STATUS_UDP_CSUM_ERROR);
-}	/* SkCsGetReceiveInfo */
-
-
-/******************************************************************************
- *
- *	SkCsSetReceiveFlags - set checksum receive flags
- *
- * Description:
- *	Use this function to set the various receive flags. According to the
- *	protocol flags set by the caller, the start offsets within received
- *	packets of the two hardware checksums are returned. These offsets must
- *	be stored in all receive descriptors.
- *
- * Arguments:
- *	pAc - Pointer to adapter context struct.
- *
- *	ReceiveFlags - Any combination of SK_PROTO_XXX flags of the protocols
- *	for which the caller wants checksum information on received frames.
- *
- *	pChecksum1Offset - The start offset of the first receive descriptor
- *	hardware checksum to be calculated for received frames is returned
- *	here.
- *
- *	pChecksum2Offset - The start offset of the second receive descriptor
- *	hardware checksum to be calculated for received frames is returned
- *	here.
- *
- * Returns: N/A
- *	Returns the two hardware checksum start offsets.
- */
-void SkCsSetReceiveFlags(
-SK_AC		*pAc,				/* Adapter context struct. */
-unsigned	ReceiveFlags,		/* New receive flags. */
-unsigned	*pChecksum1Offset,	/* Offset for hardware checksum 1. */
-unsigned	*pChecksum2Offset,	/* Offset for hardware checksum 2. */
-int			NetNumber)
-{
-	/* Save the receive flags. */
-
-	pAc->Csum.ReceiveFlags[NetNumber] = ReceiveFlags;
-
-	/* First checksum start offset is the IP header. */
-	*pChecksum1Offset = SKCS_MAC_HEADER_SIZE;
-
-	/*
-	 * Second checksum start offset is the IP data. Note that this may vary
-	 * if there are any IP header options in the actual packet.
-	 */
-	*pChecksum2Offset = SKCS_MAC_HEADER_SIZE + SKCS_IP_HEADER_SIZE;
-}	/* SkCsSetReceiveFlags */
-
-#ifndef SK_CS_CALCULATE_CHECKSUM
-
-/******************************************************************************
- *
- *	SkCsCalculateChecksum - calculate checksum for specified data
- *
- * Description:
- *	Calculate and return the 16-bit Internet Checksum for the specified
- *	data.
- *
- * Arguments:
- *	pData - Pointer to data for which the checksum shall be calculated.
- *	Note: The pointer should be aligned on a 16-bit boundary.
- *
- *	Length - Length in bytes of data to checksum.
- *
- * Returns:
- *	The 16-bit Internet Checksum for the specified data.
- *
- *	Note: The checksum is calculated in the machine's natural byte order,
- *	i.e. little vs. big endian. Thus, the resulting checksum is different
- *	for the same input data on little and big endian machines.
- *
- *	However, when written back to the network packet, the byte order is
- *	always in correct network order.
- */
-unsigned SkCsCalculateChecksum(
-void		*pData,		/* Data to checksum. */
-unsigned	Length)		/* Length of data. */
-{
-	SK_U16 *pU16;		/* Pointer to the data as 16-bit words. */
-	unsigned long Checksum;	/* Checksum; must be at least 32 bits. */
-
-	/* Sum up all 16-bit words. */
-
-	pU16 = (SK_U16 *) pData;
-	for (Checksum = 0; Length > 1; Length -= 2) {
-		Checksum += *pU16++;
-	}
-
-	/* If this is an odd number of bytes, add-in the last byte. */
-
-	if (Length > 0) {
-#ifdef SK_BIG_ENDIAN
-		/* Add the last byte as the high byte. */
-		Checksum += ((unsigned) *(SK_U8 *) pU16) << 8;
-#else	/* !SK_BIG_ENDIAN */
-		/* Add the last byte as the low byte. */
-		Checksum += *(SK_U8 *) pU16;
-#endif	/* !SK_BIG_ENDIAN */
-	}
-
-	/* Add-in any carries. */
-
-	SKCS_OC_ADD(Checksum, Checksum, 0);
-
-	/* Add-in any new carry. */
-
-	SKCS_OC_ADD(Checksum, Checksum, 0);
-
-	/* Note: All bits beyond the 16-bit limit are now zero. */
-
-	return ((unsigned) Checksum);
-}	/* SkCsCalculateChecksum */
-
-#endif /* SK_CS_CALCULATE_CHECKSUM */
-
-/******************************************************************************
- *
- *	SkCsEvent - the CSUM event dispatcher
- *
- * Description:
- *	This is the event handler for the CSUM module.
- *
- * Arguments:
- *	pAc - Pointer to adapter context.
- *
- *	Ioc - I/O context.
- *
- *	Event -	 Event id.
- *
- *	Param - Event dependent parameter.
- *
- * Returns:
- *	The 16-bit Internet Checksum for the specified data.
- *
- *	Note: The checksum is calculated in the machine's natural byte order,
- *	i.e. little vs. big endian. Thus, the resulting checksum is different
- *	for the same input data on little and big endian machines.
- *
- *	However, when written back to the network packet, the byte order is
- *	always in correct network order.
- */
-int SkCsEvent(
-SK_AC		*pAc,	/* Pointer to adapter context. */
-SK_IOC		Ioc,	/* I/O context. */
-SK_U32		Event,	/* Event id. */
-SK_EVPARA	Param)	/* Event dependent parameter. */
-{
-	int ProtoIndex;
-	int	NetNumber;
-
-	switch (Event) {
-	/*
-	 * Clear protocol statistics.
-	 *
-	 * Param - Protocol index, or -1 for all protocols.
-	 *		 - Net number.
-	 */
-	case SK_CSUM_EVENT_CLEAR_PROTO_STATS:
-
-		ProtoIndex = (int)Param.Para32[1];
-		NetNumber = (int)Param.Para32[0];
-		if (ProtoIndex < 0) {	/* Clear for all protocols. */
-			if (NetNumber >= 0) {
-				SK_MEMSET(&pAc->Csum.ProtoStats[NetNumber][0], 0,
-					sizeof(pAc->Csum.ProtoStats[NetNumber]));
-			}
-		}
-		else {					/* Clear for individual protocol. */
-			SK_MEMSET(&pAc->Csum.ProtoStats[NetNumber][ProtoIndex], 0,
-				sizeof(pAc->Csum.ProtoStats[NetNumber][ProtoIndex]));
-		}
-		break;
-	default:
-		break;
-	}
-	return (0);	/* Success. */
-}	/* SkCsEvent */
-
-#endif	/* SK_USE_CSUM */
diff -Nru a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
--- a/drivers/net/sk98lin/skethtool.c	2004-11-10 11:29:48 -08:00
+++ b/drivers/net/sk98lin/skethtool.c	2004-11-10 11:29:48 -08:00
@@ -542,9 +542,90 @@
         return ret ? -EIO : 0;
 }
 
+/*****************************************************************************
+ *
+ * 	setScatterGather
+ *
+ * Description:
+ *	Enable/disable scatter/gather DMA setting.
+ *
+ * Returns:    0 if successful
+ *
+ */
+static int setScatterGather(struct net_device *dev, u32 data)
+{
+	DEV_NET *pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+
+	if (!pAC->ChipsetType)
+		return -EOPNOTSUPP;
+	return ethtool_op_set_sg(dev, data);
+}
+
+/*****************************************************************************
+ *
+ * 	setTxChecksum
+ *
+ * Description:
+ *	Enable/disable transmit checksumming
+ *
+ * Returns:   0 if successful
+ *
+ */
+static int setTxChecksum(struct net_device *dev, u32 data)
+{
+	DEV_NET *pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+
+	if (!pAC->ChipsetType)
+		return -EOPNOTSUPP;
+	return ethtool_op_set_tx_csum(dev, data);
+}
+
+/*****************************************************************************
+ *
+ * 	getRxChecksum
+ *
+ * Description:
+ *	Report on state of receive checksumming
+ *
+ * Returns:   0 if disabled, 1 if enabled
+ *
+ */
+static u32 getRxChecksum(struct net_device *dev)
+{
+	DEV_NET *pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+
+	return pAC->RxPort[pNet->PortNr].UseRxCsum;
+}
+/*****************************************************************************
+ *
+ * 	setRxChecksum
+ *
+ * Description:
+ *	Enable/disable transmit checksumming
+ *
+ * Returns:   0 if successful
+ *
+ */
+static int setRxChecksum(struct net_device *dev, u32 data)
+{
+	DEV_NET *pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+
+	if (data &&
+	    !(pAC->GIni.GIChipId == CHIP_ID_GENESIS || pAC->ChipsetType))
+		return -EOPNOTSUPP;
+
+	pAC->RxPort[pNet->PortNr].UseRxCsum = data;
+	return 0;
+}
+
 struct ethtool_ops SkGeEthtoolOps = {
 	.get_settings		= getSettings,
 	.set_settings		= setSettings,
+	.get_link		= ethtool_op_get_link,
 	.get_drvinfo		= getDriverInfo,
 	.get_strings		= getStrings,
 	.get_stats_count	= getStatsCount,
@@ -552,4 +633,10 @@
 	.phys_id		= locateDevice,
 	.get_pauseparam		= getPauseParams,
 	.set_pauseparam		= setPauseParams,
+	.get_sg			= ethtool_op_get_sg,
+	.set_sg			= setScatterGather,
+	.get_rx_csum		= getRxChecksum,
+	.set_rx_csum		= setRxChecksum,
+	.get_tx_csum		= ethtool_op_get_tx_csum,
+	.set_tx_csum		= setTxChecksum,
 };
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-10 11:29:48 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-10 11:29:48 -08:00
@@ -463,6 +463,11 @@
 	memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA));
 	memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA));
 
+#ifdef USE_SK_RX_CHECKSUM
+	pAC->RxPort[0].UseRxCsum = SK_TRUE;
+	pAC->RxPort[1].UseRxCsum = SK_TRUE;
+#endif
+
 	pci_set_drvdata(pdev, dev);
 	return 0;
 
@@ -503,7 +508,9 @@
 		dev->features |= NETIF_F_HIGHDMA;
 
 	if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) {
+#ifdef SK_ZEROCOPY
 		dev->features |= NETIF_F_SG;
+#endif
 #ifdef USE_SK_TX_CHECKSUM
 		dev->features |= NETIF_F_IP_CSUM;
 #endif
@@ -871,11 +878,6 @@
 		goto out_free_irq;
 	}
 
-	SkCsSetReceiveFlags(pAC,
-		SKCS_PROTO_IP | SKCS_PROTO_TCP | SKCS_PROTO_UDP,
-		&pAC->CsOfs1, &pAC->CsOfs2, 0);
-	pAC->CsOfs = (pAC->CsOfs2 << 16) | pAC->CsOfs1;
-
 	BoardInitMem(pAC);
 
 	/* tschilling: New common function with minimum size check. */
@@ -1092,7 +1094,8 @@
 		/* set the pointers right */
 		pDescr->VNextRxd = VNextDescr & 0xffffffffULL;
 		pDescr->pNextRxd = pNextDescr;
-		pDescr->TcpSumStarts = pAC->CsOfs;
+		pDescr->TcpSumStarts = SK_CHECKSUM_OFFSET_1 
+			| (SK_CHECKSUM_OFFSET_2 << 16);
 
 		/* advance one step */
 		pPrevDescr = pDescr;
@@ -2179,7 +2182,8 @@
 		SK_PNMI_CNT_NO_RX_BUF(pAC, pRxPort->PortIndex);
 		return(SK_FALSE);
 	}
-	skb_reserve(pMsgBlock, 2); /* to align IP frames */
+
+	skb_reserve(pMsgBlock, NET_IP_ALIGN); /* to align IP frames */
 	/* skb allocated ok, so add buffer */
 	pRxd = pRxPort->pRxdRingTail;
 	pRxPort->pRxdRingTail = pRxd->pNextRxd;
@@ -2216,12 +2220,10 @@
  *
  * Returns: N/A
  */
-static void ReQueueRxBuffer(
+static inline void ReQueueRxBuffer(
 SK_AC		*pAC,		/* pointer to the adapter context struct */
 RX_PORT		*pRxPort,	/* ptr to port struct of ring to fill */
-struct sk_buff	*pMsg,		/* pointer to the buffer */
-SK_U32		PhysHigh,	/* phys address high dword */
-SK_U32		PhysLow)	/* phys address low dword */
+struct sk_buff	*pMsg)		/* pointer to the buffer */
 {
 RXD		*pRxd;		/* the rxd to fill */
 SK_U16		Length;		/* data fragment length */
@@ -2231,8 +2233,6 @@
 	pRxPort->RxdRingFree--;
 	Length = pAC->RxBufSize;
 
-	pRxd->VDataLow  = PhysLow;
-	pRxd->VDataHigh = PhysHigh;
 	pRxd->pMBuf     = pMsg;
 	pRxd->RBControl = BMU_OWN       | 
 			  BMU_STF       |
@@ -2263,7 +2263,6 @@
 struct sk_buff	*pMsg;			/* pointer to message holding frame */
 struct sk_buff	*pNewMsg;		/* pointer to a new message for copying frame */
 int				FrameLength;	/* total length of received frame */
-int				IpFrameLength;
 SK_MBUF			*pRlmtMbuf;		/* ptr to a buffer for giving a frame to rlmt */
 SK_EVPARA		EvPara;			/* an event parameter union */	
 unsigned long	Flags;			/* for spin lock */
@@ -2276,10 +2275,6 @@
 SK_BOOL  IsBadFrame; 			/* Bad frame */
 
 SK_U32			FrameStat;
-unsigned short	Csum1;
-unsigned short	Csum2;
-unsigned short	Type;
-int				Result;
 SK_U64			PhysAddr;
 
 rx_start:	
@@ -2384,8 +2379,7 @@
 				"Control: %x\nRxStat: %x\n",
 				Control, FrameStat));
 
-			ReQueueRxBuffer(pAC, pRxPort, pMsg,
-				pRxd->VDataHigh, pRxd->VDataLow);
+			ReQueueRxBuffer(pAC, pRxPort, pMsg);
 
 			continue;
 		}
@@ -2414,13 +2408,11 @@
 						       (dma_addr_t) PhysAddr,
 						       FrameLength,
 						       PCI_DMA_FROMDEVICE);
-			ReQueueRxBuffer(pAC, pRxPort, pMsg,
-				pRxd->VDataHigh, pRxd->VDataLow);
+			ReQueueRxBuffer(pAC, pRxPort, pMsg);
 
 			pMsg = pNewMsg;
 
-		}
-		else {
+		} else {
 			/*
 			 * if large frame, or SKB allocation failed, pass
 			 * the SKB directly to the networking
@@ -2437,67 +2429,13 @@
 
 			/* set length in message */
 			skb_put(pMsg, FrameLength);
-			/* hardware checksum */
-			Type = ntohs(*((short*)&pMsg->data[12]));
+			pMsg->ip_summed = CHECKSUM_NONE; /* initial default */
 
-#ifdef USE_SK_RX_CHECKSUM
-			if (Type == 0x800) {
-				Csum1=le16_to_cpu(pRxd->TcpSums & 0xffff);
-				Csum2=le16_to_cpu((pRxd->TcpSums >> 16) & 0xffff);
-				IpFrameLength = (int) ntohs((unsigned short)
-								((unsigned short *) pMsg->data)[8]);
-
-				/*
-				 * Test: If frame is padded, a check is not possible!
-				 * Frame not padded? Length difference must be 14 (0xe)!
-				 */
-				if ((FrameLength - IpFrameLength) != 0xe) {
-				/* Frame padded => TCP offload not possible! */
-					pMsg->ip_summed = CHECKSUM_NONE;
-				} else {
-				/* Frame not padded => TCP offload! */
-					if ((((Csum1 & 0xfffe) && (Csum2 & 0xfffe)) &&
-						(pAC->GIni.GIChipId == CHIP_ID_GENESIS)) ||
-						(pAC->ChipsetType)) {
-						Result = SkCsGetReceiveInfo(pAC,
-							&pMsg->data[14],
-							Csum1, Csum2, pRxPort->PortIndex);
-						if (Result ==
-							SKCS_STATUS_IP_FRAGMENT ||
-							Result ==
-							SKCS_STATUS_IP_CSUM_OK ||
-							Result ==
-							SKCS_STATUS_TCP_CSUM_OK ||
-							Result ==
-							SKCS_STATUS_UDP_CSUM_OK) {
-								pMsg->ip_summed =
-								CHECKSUM_UNNECESSARY;
-						}
-						else if (Result ==
-							SKCS_STATUS_TCP_CSUM_ERROR ||
-							Result ==
-							SKCS_STATUS_UDP_CSUM_ERROR ||
-							Result ==
-							SKCS_STATUS_IP_CSUM_ERROR_UDP ||
-							Result ==
-							SKCS_STATUS_IP_CSUM_ERROR_TCP ||
-							Result ==
-							SKCS_STATUS_IP_CSUM_ERROR ) {
-							/* HW Checksum error */
-							SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
-							SK_DBGCAT_DRV_RX_PROGRESS,
-							("skge: CRC error. Frame dropped!\n"));
-							goto rx_failed;
-						} else {
-								pMsg->ip_summed =
-								CHECKSUM_NONE;
-						}
-					}/* checksumControl calculation valid */
-				} /* Frame length check */
-			} /* IP frame */
-#else
-			pMsg->ip_summed = CHECKSUM_NONE;	
-#endif
+			/* Use hardware checksum of complete packet */
+			if (pRxPort->UseRxCsum) {
+			    pMsg->csum = le16_to_cpu(pRxd->TcpSums & 0xffff);
+			    pMsg->ip_summed = CHECKSUM_HW;
+			}
 		} /* frame > SK_COPY_TRESHOLD */
 		
 		SK_DBG_MSG(NULL, SK_DBGMOD_DRV,	1,("V"));
@@ -4518,26 +4456,23 @@
 		else if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_DYNAMIC)
 			printk("    irq moderation:  dynamic (%d ints/sec)\n",
 					pAC->DynIrqModInfo.MaxModIntsPerSec);
-		else
+		else 
 			printk("    irq moderation:  disabled\n");
 
-
-#ifdef SK_ZEROCOPY
-		if (pAC->ChipsetType)
-#ifdef USE_SK_TX_CHECKSUM
+		if (pAC->dev[FromPort]->features & NETIF_F_SG)
 			printk("    scatter-gather:  enabled\n");
-#else
-			printk("    tx-checksum:     disabled\n");
-#endif
 		else
 			printk("    scatter-gather:  disabled\n");
-#else
-			printk("    scatter-gather:  disabled\n");
-#endif
+		
+		if (pAC->dev[FromPort]->features & NETIF_F_IP_CSUM)
+			printk("    tx-checksum:     enabled\n");
+		else
+			printk("    tx-checksum:     disabled\n");
 
-#ifndef USE_SK_RX_CHECKSUM
+		if (pAC->RxPort[FromPort].UseRxCsum)
+			printk("    rx-checksum:     enabled\n");
+		else
 			printk("    rx-checksum:     disabled\n");
-#endif
 
 		} else {
                         DoPrintInterfaceChange = SK_TRUE;

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (19/23) sk98: more cleanups
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (16 preceding siblings ...)
  2004-11-12  0:07   ` [PATCH] (20/23) sk98: checksum ethtool and improvements Stephen Hemminger
@ 2004-11-12  0:07   ` Stephen Hemminger
  2004-11-12  0:07   ` [PATCH] (18/23) sk98: update pci_id table Stephen Hemminger
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:07 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Make sure and set flags on both ports correctly.
Set address before register_netdev so if any protocols want
to pickup mac address they see correct value.
Fix memory leak on remove (my bad from patch 15).

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-08 13:10:37 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-08 13:10:37 -08:00
@@ -184,7 +184,8 @@
 static void 	sk98lin_remove_device(struct pci_dev *pdev);
 static void	FreeResources(struct net_device *dev);
 static int	SkGeBoardInit(struct net_device *dev, SK_AC *pAC);
-static void	SkGeDevInit(struct net_device *dev, struct pci_dev *pdev);
+static void	SkGeDevInit(struct net_device *dev, struct pci_dev *pdev,
+			    const SK_AC *pAC);
 static SK_BOOL	BoardAllocMem(SK_AC *pAC);
 static void	BoardFreeMem(SK_AC *pAC);
 static void	BoardInitMem(SK_AC *pAC);
@@ -338,7 +339,6 @@
 	DEV_NET			*pNet = NULL;
 	struct net_device	*dev = NULL;
 	static int boards_found = 0;
-	int pci_using_dac  = 0;
 	int error = -ENODEV;
 
 	error = pci_enable_device(pdev);
@@ -348,9 +348,8 @@
 	}
  
 	/* Configure DMA attributes. */
-	if (!(error = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) 
-		pci_using_dac = 1;
-	else if ((error = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
+	if ((error = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
+	    (error = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
 		printk(KERN_ERR "sk98lin: cannot set PCI dma mask\n");
 		goto out_disable_device;
 	}
@@ -393,23 +392,12 @@
 		goto out_free_adapter;
 	}
 
-	SkGeDevInit(dev, pdev);
-	if (pci_using_dac)
-		dev->features |= NETIF_F_HIGHDMA;
-
 	pAC->Index = boards_found++;
 
 	if (SkGeBoardInit(dev, pAC))
-		goto out_free_adapter;
+		goto out_free_resources;
 
-#ifdef SK_ZEROCOPY
-#ifdef USE_SK_TX_CHECKSUM
-	if (pAC->ChipsetType)
-		/* Use only if yukon hardware */
-		/* SK and ZEROCOPY - fly baby... */
-		dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
-#endif
-#endif
+	SkGeDevInit(dev, pdev, pAC);
 
 	/* Register net device */
 	strcpy(dev->name, "eth%d");
@@ -419,6 +407,7 @@
 	}
 
 	SkGeProcCreate(dev);
+	memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
 
 	/* Print adapter specific string from vpd */
 	PrintProductStr(dev->name, pAC);
@@ -434,8 +423,6 @@
 
 	SkGeYellowLED(pAC, pAC->IoBase, 1);
 
-	memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
-
 	/* More then one port found */
 	if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
 		if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) {
@@ -450,22 +437,9 @@
 		pNet->NetNr   = 1;
 		pNet->pAC     = pAC;
 		
-		memcpy(&dev->dev_addr,
-		       &pAC->Addr.Net[1].CurrentMacAddress, 6);
-
-		SkGeDevInit(dev, pdev);
+		memcpy(&dev->dev_addr, &pAC->Addr.Net[1].CurrentMacAddress, 6);
 
-		if (pci_using_dac)
-			dev->features |= NETIF_F_HIGHDMA;
-
-#ifdef SK_ZEROCOPY
-#ifdef USE_SK_TX_CHECKSUM
-		if (pAC->ChipsetType)
-			/* Use only if yukon hardware */
-			/* SK and ZEROCOPY - fly baby... */
-			dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
-#endif
-#endif
+		SkGeDevInit(dev, pdev, pAC);
 
 		if (register_netdev(dev)) {
 			printk(KERN_ERR "SKGE: Could not register device.\n");
@@ -504,7 +478,8 @@
 	return error;
 }
 
-static void SkGeDevInit(struct net_device *dev, struct pci_dev *pdev)
+static void SkGeDevInit(struct net_device *dev, struct pci_dev *pdev, 
+			const SK_AC *pAC)
 {
 	SET_MODULE_OWNER(dev);
 	dev->open =		&SkGeOpen;
@@ -523,6 +498,16 @@
 
 	dev->flags &= ~IFF_RUNNING;
 	dev->features |= NETIF_F_LLTX;
+
+	if (pdev->dma_mask == DMA_64BIT_MASK)
+		dev->features |= NETIF_F_HIGHDMA;
+
+	if (pAC->GIni.GIChipId != CHIP_ID_GENESIS) {
+		dev->features |= NETIF_F_SG;
+#ifdef USE_SK_TX_CHECKSUM
+		dev->features |= NETIF_F_IP_CSUM;
+#endif
+	}
 }
 /*****************************************************************************
  *
@@ -768,6 +753,7 @@
 	}
 
 	FreeResources(dev);
+	kfree(pAC);
 
 	if (dev1 != dev)
 		free_netdev(dev1);

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (18/23) sk98: update pci_id table
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (17 preceding siblings ...)
  2004-11-12  0:07   ` [PATCH] (19/23) sk98: more cleanups Stephen Hemminger
@ 2004-11-12  0:07   ` Stephen Hemminger
  2004-11-12  0:09   ` [PATCH] (21/23) sk98: transmit ring barriers Stephen Hemminger
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:07 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Reformat and update pci id table.  Add values from lastest SysKonnect
driver, and use pci_id defines if available.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-04 10:30:02 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-04 10:30:02 -08:00
@@ -277,24 +277,45 @@
 static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
 static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
 
-
-static struct pci_device_id sk98lin_pci_tbl[] = {
-	{ PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_SYSKONNECT, 0x4300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_SYSKONNECT, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_DLINK, 0x4c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_MARVELL, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+static struct pci_device_id sk98lin_pci_tbl[] __devinitdata = {
+	{ PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940, 
+	  PCI_ANY_ID, PCI_ANY_ID }, 
+	{ PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C940B, 
+	  PCI_ANY_ID, PCI_ANY_ID }, 
+	{ PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE,
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_YU,
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_SYSKONNECT, 0x9E00, /* SK-9Exx 10/100/1000Base-T Adapter */
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_DLINK, PCI_DEVICE_ID_DLINK_DGE510T,
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_MARVELL, 0x4320, /* Gigabit Ethernet Controller */
+	  PCI_ANY_ID, PCI_ANY_ID },
 #if 0	/* don't handle Yukon2 cards at the moment -- mlindner@syskonnect.de */
-	{ PCI_VENDOR_ID_MARVELL, 0x4360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_MARVELL, 0x4361, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+	{ PCI_VENDOR_ID_MARVELL, 0x4350, /* Fast Ethernet Controller */
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_MARVELL, 0x4351, /* Fast Ethernet Controller */
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_MARVELL, 0x4360, /* Gigabit Ethernet Controller */
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_MARVELL, 0x4361, /* Gigabit Ethernet Controller */
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_MARVELL, 0x4362, /* Gigabit Ethernet Controller */
+	  PCI_ANY_ID, PCI_ANY_ID },
 #endif
-	{ PCI_VENDOR_ID_MARVELL, 0x5005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_CNET, 0x434e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ PCI_VENDOR_ID_LINKSYS, 0x1064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
-	{ 0, }
+	{ PCI_VENDOR_ID_MARVELL, 0x5005, /* Marvell (11ab), Belkin */
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_CNET, PCI_DEVICE_ID_CNET_GIGACARD,
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LINKSYS_EG1032,
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ PCI_VENDOR_ID_LINKSYS, PCI_DEVICE_ID_LINKSYS_EG1064,
+	  PCI_ANY_ID, PCI_ANY_ID },
+	{ 0 }
 };
+
+MODULE_DEVICE_TABLE(pci, sk98lin_pci_tbl);
 
 static struct pci_driver skge_driver = {
 	.name		= DRIVER_FILE_NAME,

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (21/23) sk98: transmit ring barriers
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (18 preceding siblings ...)
  2004-11-12  0:07   ` [PATCH] (18/23) sk98: update pci_id table Stephen Hemminger
@ 2004-11-12  0:09   ` Stephen Hemminger
  2004-11-12  0:09   ` [PATCH] (22/23) sk98: diag code changes Stephen Hemminger
  2004-11-12  0:11   ` [PATCH] (23/23) sk98: eliminate large controller scratch pad elements Stephen Hemminger
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:09 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Transmit descriptor control doesn't need to be volatile, it is
much better to use explicit memory barriers. This generates better
code and makes sure that ordering is maintained. When doing SG
figure out the bits once rather than for each frag.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-10 11:29:09 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-10 11:29:09 -08:00
@@ -227,7 +227,7 @@
 typedef struct s_TxD TXD; /* the transmit descriptor */
 
 struct s_TxD {
-	volatile SK_U32	TBControl;	/* Transmit Buffer Control */
+	SK_U32		TBControl;	/* Transmit Buffer Control */
 	SK_U32		VNextTxd;	/* Next transmit descriptor,low dword */
 	SK_U32		VDataLow;	/* Transmit Buffer Addr, low dword */
 	SK_U32		VDataHigh;	/* Transmit Buffer Addr, high dword */
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-10 11:29:09 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-10 11:29:09 -08:00
@@ -1760,9 +1760,6 @@
 	TXD		*pTxd;		/* the rxd to fill */
 	TXD		*pOldTxd;
 	SK_U64		 PhysAddr;
-	int	 	 Protocol;
-	int		 IpHeaderLength;
-	int		 BytesSend = pMessage->len;
 
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X"));
 
@@ -1796,7 +1793,7 @@
 	** the original packet end and the new packet end of 60 with 0x00.
 	** This is to resolve faulty padding by the HW with 0xaa bytes.
 	*/
-	if (BytesSend < C_LEN_ETHERNET_MINSIZE) {
+	if (pMessage->len < C_LEN_ETHERNET_MINSIZE) {
 		if ((pMessage = skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) == NULL) {
 			return 0;
 		}
@@ -1831,7 +1828,10 @@
 	pTxd->pMBuf     = pMessage;
 
 	if (pMessage->ip_summed == CHECKSUM_HW) {
-		Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff);
+		SK_U8 Protocol = pMessage->data[C_OFFSET_IPPROTO];
+		int IpHeaderLength
+			= (pMessage->data[C_OFFSET_IPHEADER]&0xf) * 4;
+
 		if ((Protocol == C_PROTO_ID_UDP) && 
 			(pAC->GIni.GIChipRev == 0) &&
 			(pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
@@ -1840,13 +1840,11 @@
 			pTxd->TBControl = BMU_UDP_CHECK;
 		}
 
-		IpHeaderLength  = (SK_U8)pMessage->data[C_OFFSET_IPHEADER];
-		IpHeaderLength  = (IpHeaderLength & 0xf) * 4;
 		pTxd->TcpSumOfs = 0; /* PH-Checksum already calculated */
-		pTxd->TcpSumSt  = C_LEN_ETHERMAC_HEADER + IpHeaderLength + 
-							(Protocol == C_PROTO_ID_UDP ?
-							C_OFFSET_UDPHEADER_UDPCS : 
-							C_OFFSET_TCPHEADER_TCPCS);
+		pTxd->TcpSumSt  = C_LEN_ETHERMAC_HEADER + IpHeaderLength
+			+ (Protocol == C_PROTO_ID_UDP ?
+			   C_OFFSET_UDPHEADER_UDPCS : 
+			   C_OFFSET_TCPHEADER_TCPCS);
 		pTxd->TcpSumWr  = C_LEN_ETHERMAC_HEADER + IpHeaderLength;
 
 		pTxd->TBControl |= BMU_OWN | BMU_STF | 
@@ -1863,6 +1861,7 @@
 #endif
 			pMessage->len;
 	}
+	wmb();
 
 	/* 
 	** If previous descriptor already done, give TX start cmd 
@@ -1901,9 +1900,8 @@
 	TXD		*pTxdLst;
 	int 	 	 CurrFrag;
 	int		 BytesSend;
-	int		 IpHeaderLength; 
-	int		 Protocol;
 	skb_frag_t	*sk_frag;
+	SK_U32		 CheckMsk;
 	SK_U64		 PhysAddr;
 
 #ifndef USE_TX_COMPLETE
@@ -1925,7 +1923,6 @@
 	pTxdFst   = pTxd;
 	pTxdLst   = pTxd;
 	BytesSend = 0;
-	Protocol  = 0;
 
 	/* 
 	** Map the first fragment (header) into the DMA-space
@@ -1943,32 +1940,32 @@
 	** Does the HW need to evaluate checksum for TCP or UDP packets? 
 	*/
 	if (pMessage->ip_summed == CHECKSUM_HW) {
-		pTxd->TBControl = BMU_STF | BMU_STFWD | skb_headlen(pMessage);
+		SK_U8 Protocol = pMessage->data[C_OFFSET_IPPROTO];
+		int IpHeaderLength
+			= (pMessage->data[C_OFFSET_IPHEADER]&0xf) * 4;
+
 		/* 
 		** We have to use the opcode for tcp here,  because the
 		** opcode for udp is not working in the hardware yet 
 		** (Revision 2.0)
 		*/
-		Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff);
 		if ((Protocol == C_PROTO_ID_UDP) && 
 			(pAC->GIni.GIChipRev == 0) &&
-			(pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
-			pTxd->TBControl |= BMU_TCP_CHECK;
-		} else {
-			pTxd->TBControl |= BMU_UDP_CHECK;
-		}
+			(pAC->GIni.GIChipId == CHIP_ID_YUKON))
+			CheckMsk = BMU_TCP_CHECK | BMU_STFWD;
+		else 
+			CheckMsk = BMU_UDP_CHECK;
 
-		IpHeaderLength  = ((SK_U8)pMessage->data[C_OFFSET_IPHEADER] & 0xf)*4;
 		pTxd->TcpSumOfs = 0; /* PH-Checksum already claculated */
-		pTxd->TcpSumSt  = C_LEN_ETHERMAC_HEADER + IpHeaderLength +
-						(Protocol == C_PROTO_ID_UDP ?
-						C_OFFSET_UDPHEADER_UDPCS :
-						C_OFFSET_TCPHEADER_TCPCS);
+		pTxd->TcpSumSt  = C_LEN_ETHERMAC_HEADER + IpHeaderLength
+			+ (Protocol == C_PROTO_ID_UDP ?
+			   C_OFFSET_UDPHEADER_UDPCS :
+			   C_OFFSET_TCPHEADER_TCPCS);
 		pTxd->TcpSumWr  = C_LEN_ETHERMAC_HEADER + IpHeaderLength;
-	} else {
-		pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_STF |
-					skb_headlen(pMessage);
-	}
+	} else 
+		CheckMsk = BMU_CHECK;
+
+	pTxd->TBControl = CheckMsk | BMU_STF | skb_headlen(pMessage);
 
 	pTxd = pTxd->pNextTxd;
 	pTxPort->TxdRingFree--;
@@ -1992,41 +1989,21 @@
 		pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
 		pTxd->pMBuf     = pMessage;
 		
-		/* 
-		** Does the HW need to evaluate checksum for TCP or UDP packets? 
-		*/
-		if (pMessage->ip_summed == CHECKSUM_HW) {
-			pTxd->TBControl = BMU_OWN | BMU_SW | BMU_STFWD;
-			/* 
-			** We have to use the opcode for tcp here because the 
-			** opcode for udp is not working in the hardware yet 
-			** (revision 2.0)
-			*/
-			if ((Protocol == C_PROTO_ID_UDP) && 
-				(pAC->GIni.GIChipRev == 0) &&
-				(pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
-				pTxd->TBControl |= BMU_TCP_CHECK;
-			} else {
-				pTxd->TBControl |= BMU_UDP_CHECK;
-			}
-		} else {
-			pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_OWN;
-		}
+		pTxd->TBControl = BMU_OWN | BMU_SW | CheckMsk | sk_frag->size;
 
 		/* 
 		** Do we have the last fragment? 
 		*/
 		if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags )  {
 #ifdef USE_TX_COMPLETE
-			pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF | sk_frag->size;
+			pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF;
 #else
-			pTxd->TBControl |= BMU_EOF | sk_frag->size;
+			pTxd->TBControl |= BMU_EOF;
 #endif
+			wmb();
 			pTxdFst->TBControl |= BMU_OWN | BMU_SW;
 
-		} else {
-			pTxd->TBControl |= sk_frag->size;
-		}
+		} 
 		pTxdLst = pTxd;
 		pTxd    = pTxd->pNextTxd;
 		pTxPort->TxdRingFree--;
@@ -2036,13 +2013,12 @@
 	/* 
 	** If previous descriptor already done, give TX start cmd 
 	*/
-	if ((pTxPort->pTxdRingPrev->TBControl & BMU_OWN) == 0) {
+	pTxPort->pTxdRingHead = pTxd;
+	pTxd = xchg(&pTxPort->pTxdRingPrev, pTxdLst);
+	if ((pTxd->TBControl & BMU_OWN) == 0) {
 		SK_OUT8(pTxPort->HwAddr, Q_CSR, CSR_START);
 	}
 
-	pTxPort->pTxdRingPrev = pTxdLst;
-	pTxPort->pTxdRingHead = pTxd;
-
 	return (pTxPort->TxdRingFree > 0);
 }
 
@@ -2080,6 +2056,7 @@
 	** or BMU_OWN bit set in any frame
 	*/
 	while (1) {
+		rmb();
 		Control = pTxd->TBControl;
 		if ((Control & BMU_SW) == 0) {
 			/*
@@ -2116,6 +2093,7 @@
 
 		pTxPort->TxdRingFree++;
 		pTxd->TBControl &= ~BMU_SW;
+		wmb();
 		pTxd = pTxd->pNextTxd; /* point behind fragment with EOF */
 	} /* while(forever) */
 } /* FreeTxDescriptors */
@@ -2674,6 +2652,7 @@
 		pTxd->TBControl &= ~BMU_OWN;
 		pTxd = pTxd->pNextTxd;
 	}
+	wmb();
 	FreeTxDescriptors(pAC, pTxPort);
 	spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
 } /* ClearTxRing */

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (22/23) sk98: diag code changes
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (19 preceding siblings ...)
  2004-11-12  0:09   ` [PATCH] (21/23) sk98: transmit ring barriers Stephen Hemminger
@ 2004-11-12  0:09   ` Stephen Hemminger
  2004-11-12  0:11   ` [PATCH] (23/23) sk98: eliminate large controller scratch pad elements Stephen Hemminger
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:09 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Cleanup DIAG support code.
  * Use type safe structure assignment rather than memcpy
  * PCI device number is available in pci_dev don't need to go
    string parsing to find it.
  * Compile correctly if SK_DIAG_SUPPORT not defined

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-11 14:17:16 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-11 14:17:16 -08:00
@@ -364,10 +364,8 @@
 	SK_TIMER        ModTimer; /* just some timer */
 };
 
-#ifdef SK_DIAG_SUPPORT
 #define	DIAG_ACTIVE		1
 #define	DIAG_NOTACTIVE		0
-#endif
 
 /****************************************************************************
  * Per board structure / Adapter Context structure:
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-11 14:17:16 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-11 14:17:16 -08:00
@@ -219,7 +219,6 @@
 static int	XmitFrameSG(SK_AC*, TX_PORT*, struct sk_buff*);
 
 #ifdef SK_DIAG_SUPPORT
-static SK_U32   ParseDeviceNbrFromSlotName(const char *SlotName);
 static int      SkDrvInitAdapter(SK_AC *pAC, int devNbr);
 static int      SkDrvDeInitAdapter(SK_AC *pAC, int devNbr);
 #endif
@@ -460,8 +459,9 @@
 	pAC->Pnmi.pDriverFileName    = DRIVER_FILE_NAME;
 	pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE;
 
-	memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA));
-	memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA));
+#ifdef SK_DIAG_SUPPORT
+	pAC->PnmiBackup = pAC->PnmiStruct;
+#endif
 
 #ifdef USE_SK_RX_CHECKSUM
 	pAC->RxPort[0].UseRxCsum = SK_TRUE;
@@ -1565,7 +1565,6 @@
 struct net_device	*dev)
 {
 	DEV_NET		*pNet = netdev_priv(dev);
-	DEV_NET		*newPtrNet;
 	SK_AC		*pAC = pNet->pAC;
 
 	unsigned long	Flags;		/* for spin lock */
@@ -1579,6 +1578,7 @@
 #ifdef SK_DIAG_SUPPORT
 	if (pAC->DiagModeActive == DIAG_ACTIVE) {
 		if (pAC->DiagFlowCtrl == SK_FALSE) {
+			DEV_NET		*newPtrNet;
 			/* 
 			** notify that the interface which has been closed
 			** by operator interaction must not be started up 
@@ -1662,10 +1662,9 @@
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeClose: done "));
 
-	SK_MEMSET(&(pAC->PnmiBackup), 0, sizeof(SK_PNMI_STRUCT_DATA));
-	SK_MEMCPY(&(pAC->PnmiBackup), &(pAC->PnmiStruct), 
-			sizeof(SK_PNMI_STRUCT_DATA));
-
+#ifdef SK_DIAG_SUPPORT
+	pAC->PnmiBackup = pAC->PnmiStruct;
+#endif
 	pAC->MaxPorts--;
 
 	return (0);
@@ -3103,7 +3102,6 @@
 DEV_NET		*pNet;
 SK_AC		*pAC;
 void		*pMemBuf;
-struct pci_dev  *pdev = NULL;
 SK_GE_IOCTL	Ioctl;
 unsigned int	Err = 0;
 int		Size = 0;
@@ -3185,7 +3183,6 @@
 			Err = -EFAULT;
 			goto fault_diag;
 		}
-		pdev = pAC->PciDev;
 		Length = 3 * sizeof(SK_U32);  /* Error, Bus and Device */
 		/* 
 		** While coding this new IOCTL interface, only a few lines of code
@@ -3194,8 +3191,8 @@
 		** should be used...
 		*/
 		* ((SK_U32 *)pMemBuf) = 0;
-		* ((SK_U32 *)pMemBuf + 1) = pdev->bus->number;
-		* ((SK_U32 *)pMemBuf + 2) = ParseDeviceNbrFromSlotName(pdev->slot_name);
+		* ((SK_U32 *)pMemBuf + 1) = pAC->PciDev->bus->number;
+		* ((SK_U32 *)pMemBuf + 2) = PCI_SLOT(pAC->PciDev->devfn);
 		if(copy_to_user(Ioctl.pData, pMemBuf, Length) ) {
 			Err = -EFAULT;
 			goto fault_diag;
@@ -4676,8 +4673,7 @@
 	DEV_NET *pNet = netdev_priv(pAc->dev[0]);
 	SK_AC   *pAC  = pNet->pAC;
 
-	SK_MEMCPY(&(pAc->PnmiBackup), &(pAc->PnmiStruct), 
-			sizeof(SK_PNMI_STRUCT_DATA));
+	pAc->PnmiBackup = pAC->PnmiStruct;
 
 	pAC->DiagModeActive = DIAG_ACTIVE;
 	if (pAC->BoardLevel > SK_INIT_DATA) {
@@ -4718,8 +4714,7 @@
 int SkDrvLeaveDiagMode(
 SK_AC   *pAc)   /* pointer to adapter control context */
 { 
-	SK_MEMCPY(&(pAc->PnmiStruct), &(pAc->PnmiBackup), 
-			sizeof(SK_PNMI_STRUCT_DATA));
+	pAc->PnmiStruct = pAc->PnmiBackup;
 	pAc->DiagModeActive    = DIAG_NOTACTIVE;
 	pAc->Pnmi.DiagAttached = SK_DIAG_IDLE;
         if (pAc->WasIfUp[0] == SK_TRUE) {
@@ -4735,61 +4730,6 @@
 	return(0);
 }
 
-/*****************************************************************************
- *
- *	ParseDeviceNbrFromSlotName - Evaluate PCI device number
- *
- * Description:
- * 	This function parses the PCI slot name information string and will
- *	retrieve the devcie number out of it. The slot_name maintianed by
- *	linux is in the form of '02:0a.0', whereas the first two characters 
- *	represent the bus number in hex (in the sample above this is 
- *	pci bus 0x02) and the next two characters the device number (0x0a).
- *
- * Returns:
- *	SK_U32: The device number from the PCI slot name
- */ 
-
-static SK_U32 ParseDeviceNbrFromSlotName(
-const char *SlotName)   /* pointer to pci slot name eg. '02:0a.0' */
-{
-	char	*CurrCharPos	= (char *) SlotName;
-	int	FirstNibble	= -1;
-	int	SecondNibble	= -1;
-	SK_U32	Result		=  0;
-
-	while (*CurrCharPos != '\0') {
-		if (*CurrCharPos == ':') { 
-			while (*CurrCharPos != '.') {
-				CurrCharPos++;  
-				if (	(*CurrCharPos >= '0') && 
-					(*CurrCharPos <= '9')) {
-					if (FirstNibble == -1) {
-						/* dec. value for '0' */
-						FirstNibble = *CurrCharPos - 48;
-					} else {
-						SecondNibble = *CurrCharPos - 48;
-					}  
-				} else if (	(*CurrCharPos >= 'a') && 
-						(*CurrCharPos <= 'f')  ) {
-					if (FirstNibble == -1) {
-						FirstNibble = *CurrCharPos - 87; 
-					} else {
-						SecondNibble = *CurrCharPos - 87; 
-					}
-				} else {
-					Result = 0;
-				}
-			}
-
-			Result = FirstNibble;
-			Result = Result << 4; /* first nibble is higher one */
-			Result = Result | SecondNibble;
-		}
-		CurrCharPos++;   /* next character */
-	}
-	return (Result);
-}
 
 /****************************************************************************
  *
diff -Nru a/drivers/net/sk98lin/skproc.c b/drivers/net/sk98lin/skproc.c
--- a/drivers/net/sk98lin/skproc.c	2004-11-11 14:17:16 -08:00
+++ b/drivers/net/sk98lin/skproc.c	2004-11-11 14:17:16 -08:00
@@ -76,7 +76,7 @@
 		Size = SK_PNMI_STRUCT_SIZE;
 #ifdef SK_DIAG_SUPPORT
 		if (pAC->BoardLevel == SK_INIT_DATA) {
-			SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
+			pAC->PnmiStruct = pAC->PnmiBackup;
 			if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
 				pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
 			}

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (0/23) sk98 driver fixes and enhancements
       [not found] <4192C60A.1050205@designassembly.de>
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
@ 2004-11-12  0:11 ` Stephen Hemminger
  2004-11-12  0:17   ` Michael Heyse
       [not found] ` <20041111154016.6381189d@zqx3.pdx.osdl.net>
  2 siblings, 1 reply; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:11 UTC (permalink / raw)
  To: Michael Heyse, Jeff Garzik, Mirko Lindner; +Cc: linux-kernel, netdev

This is the first set of patches to merge some of the new SysKonnect
code with existing 2.6 driver and fix several bugs. 

1: 	Remove explicit module refcounting (bug) 
2: 	Make OnesHash table local constant.
3: 	proc print interface cleanup
4: 	Use netdev_priv
5:  	Use module_param_array instead of deprecated MODULE_PARM
6: 	Add netpoll controller support
7:      Basic ethtool support
8:      Ethtool support for LED blinking
9: 	Ethtool pause param support
10:	Cleanup
11:	Fix boards_found count
12:	Add MODULE_VERSION
13:	Handle ring full condition properly (bug)
14:	Get rid of obfuscation irqreturn_t
15:	Rearrange functions to match SysKonnect code
16:	More efficient OsGetTime
17:	Enable high dma and lockless transmit
18:	reorganize pci_device table
19:	Do initialization better
20:	Ethtool tx & receive checksum efficiently
21:	Tx ring management improvements
22:	Cleanup the code under DIAG_SUPPORT
23:	Eliminate Pnmi scratchpad common

To spare people's mailbox the individual patches won't go to LKML just to netdev.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (1/23) sk98: no explicit module ref counting needed
       [not found] ` <20041111154016.6381189d@zqx3.pdx.osdl.net>
@ 2004-11-12  0:11   ` Stephen Hemminger
  2004-11-12  0:51     ` Mirko Lindner
  0 siblings, 1 reply; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:11 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Network driver's shouldn't be doing module reference counting
on 2.6.  This is a bad replication of 2.4 behaviour

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-03 14:07:09 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-03 14:07:09 -08:00
@@ -1166,10 +1166,6 @@
 	}
 #endif
 
-	if (!try_module_get(THIS_MODULE)) {
-		return (-1);	/* increase of usage count not possible */
-	}
-
 	/* Set blink mode */
 	if ((pAC->PciDev->vendor == 0x1186) || (pAC->PciDev->vendor == 0x11ab ))
 		pAC->GIni.GILedBlinkCtrl = OEM_CONFIG_VALUE;
@@ -1177,7 +1173,6 @@
 	if (pAC->BoardLevel == SK_INIT_DATA) {
 		/* level 1 init common modules here */
 		if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
-			module_put(THIS_MODULE); /* decrease usage count */
 			printk("%s: HWInit (1) failed.\n", pAC->dev[pNet->PortNr]->name);
 			return (-1);
 		}
@@ -1193,7 +1188,6 @@
 	if (pAC->BoardLevel != SK_INIT_RUN) {
 		/* tschilling: Level 2 init modules here, check return value. */
 		if (SkGeInit(pAC, pAC->IoBase, SK_INIT_RUN) != 0) {
-			module_put(THIS_MODULE); /* decrease usage count */
 			printk("%s: HWInit (2) failed.\n", pAC->dev[pNet->PortNr]->name);
 			return (-1);
 		}
@@ -1285,7 +1279,6 @@
 #ifdef SK_DIAG_SUPPORT
 	if (pAC->DiagModeActive == DIAG_ACTIVE) {
 		if (pAC->DiagFlowCtrl == SK_FALSE) {
-			module_put(THIS_MODULE);
 			/* 
 			** notify that the interface which has been closed
 			** by operator interaction must not be started up 
@@ -1376,7 +1369,6 @@
 	pAC->MaxPorts--;
 	pNet->Up = 0;
 
-	module_put(THIS_MODULE);
 	return (0);
 } /* SkGeClose */
 
@@ -4681,20 +4673,11 @@
 
 	dev = pAC->dev[devNbr];
 
-	/*
-	** Function SkGeClose() uses MOD_DEC_USE_COUNT (2.2/2.4)
-	** or module_put() (2.6) to decrease the number of users for
-	** a device, but if a device is to be put under control of 
-	** the DIAG, that count is OK already and does not need to 
-	** be adapted! Hence the opposite MOD_INC_USE_COUNT or 
-	** try_module_get() needs to be used again to correct that.
+	/* On Linux 2.6 the network driver does NOT mess with reference
+	** counts.  The driver MUST be able to be unloaded at any time
+	** due to the possibility of hotplug.
 	*/
-	if (!try_module_get(THIS_MODULE)) {
-		return (-1);
-	}
-
 	if (SkGeClose(dev) != 0) {
-		module_put(THIS_MODULE);
 		return (-1);
 	}
 	return (0);
@@ -4723,17 +4706,6 @@
 
 	if (SkGeOpen(dev) != 0) {
 		return (-1);
-	} else {
-		/*
-		** Function SkGeOpen() uses MOD_INC_USE_COUNT (2.2/2.4) 
-		** or try_module_get() (2.6) to increase the number of 
-		** users for a device, but if a device was just under 
-		** control of the DIAG, that count is OK already and 
-		** does not need to be adapted! Hence the opposite 
-		** MOD_DEC_USE_COUNT or module_put() needs to be used 
-		** again to correct that.
-		*/
-		module_put(THIS_MODULE);
 	}
 
 	/*

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH] (23/23) sk98: eliminate large controller scratch pad elements
       [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
                     ` (20 preceding siblings ...)
  2004-11-12  0:09   ` [PATCH] (22/23) sk98: diag code changes Stephen Hemminger
@ 2004-11-12  0:11   ` Stephen Hemminger
  21 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:11 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Michael Heyse, Mirko Lindner, netdev

Get rid of 44K of space in the driver structure which was just
being used as a scratch pad when making the calls to read stats.
PnmiStruct can just be kmalloc'd/kfree in those cases.

PNMI initialization can be done in one place using existing
macro's for consistency

Don't need to cast and mask when converting u64 to u32.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

diff -Nru a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
--- a/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-09 15:29:24 -08:00
+++ b/drivers/net/sk98lin/h/skdrv2nd.h	2004-11-09 15:29:24 -08:00
@@ -385,9 +385,9 @@
 	spinlock_t	SlowPathLock;	/* Normal IRQ lock */
 	struct timer_list BlinkTimer;	/* for LED blinking */
 	int		LedsOn;
-	SK_PNMI_STRUCT_DATA PnmiStruct;	/* structure to get all Pnmi-Data */
-	int			RlmtMode;	/* link check mode to set */
-	int			RlmtNets;	/* Number of nets */
+
+	int		RlmtMode;	/* link check mode to set */
+	int		RlmtNets;	/* Number of nets */
 	
 	SK_IOC		IoBase;		/* register set of adapter */
 	int		BoardLevel;	/* level of active hw init (0-2) */
@@ -425,7 +425,6 @@
 #ifdef SK_DIAG_SUPPORT
 	SK_U32		DiagModeActive;		/* is diag active?	*/
 	SK_BOOL		DiagFlowCtrl;		/* for control purposes	*/
-	SK_PNMI_STRUCT_DATA PnmiBackup;		/* backup structure for all Pnmi-Data */
 	SK_BOOL         WasIfUp[SK_MAX_MACS];   /* for OpenClose while 
 						 * DIAG is busy with NIC 
 						 */
diff -Nru a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
--- a/drivers/net/sk98lin/skethtool.c	2004-11-09 15:29:24 -08:00
+++ b/drivers/net/sk98lin/skethtool.c	2004-11-09 15:29:24 -08:00
@@ -297,9 +297,26 @@
 static void getEthtoolStats(struct net_device *dev,
 			    struct ethtool_stats *stats, u64 *data)
 {
-	const DEV_NET	*pNet = netdev_priv(dev);
-	const SK_AC *pAC = pNet->pAC;
-	const SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;
+	DEV_NET	*pNet = netdev_priv(dev);
+	SK_AC *pAC = pNet->pAC;
+	unsigned long flags;
+	unsigned int size;
+	int err;
+	SK_PNMI_STRUCT_DATA *pPnmiStruct;
+
+
+	pPnmiStruct = kmalloc(sizeof(*pPnmiStruct), GFP_KERNEL);
+	if (!pPnmiStruct)
+		return;
+
+	memset(pPnmiStruct, 0, sizeof(*pPnmiStruct));
+	size = sizeof(*pPnmiStruct);
+	spin_lock_irqsave(&pAC->SlowPathLock, flags);
+	err = SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &size, pNet->NetNr);
+	spin_unlock_irqrestore(&pAC->SlowPathLock, flags);
+
+	if (err)
+		return;
 
 	*data++ = pPnmiStruct->Stat[0].StatRxOkCts;
 	*data++ = pPnmiStruct->Stat[0].StatTxOkCts;
diff -Nru a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
--- a/drivers/net/sk98lin/skge.c	2004-11-09 15:29:23 -08:00
+++ b/drivers/net/sk98lin/skge.c	2004-11-09 15:29:24 -08:00
@@ -214,7 +214,7 @@
 static void	ClearTxRing(SK_AC*, TX_PORT*);
 static int	SkGeChangeMtu(struct net_device *dev, int new_mtu);
 static void	PortReInitBmu(SK_AC*, int);
-static int	SkGeIocMib(DEV_NET*, unsigned int, int);
+static unsigned int SkGeIocMib(DEV_NET*, SK_PNMI_STRUCT_DATA *,unsigned int, int);
 static int	SkGeInitPCI(SK_AC *pAC);
 static void	StartDrvCleanupTimer(SK_AC *pAC);
 static void	StopDrvCleanupTimer(SK_AC *pAC);
@@ -457,13 +457,6 @@
 	pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
 		(pAC->GIni.GIPciHwRev & 0x0F);
 
-	/* Set driver globals */
-	pAC->Pnmi.pDriverFileName    = DRIVER_FILE_NAME;
-	pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE;
-
-#ifdef SK_DIAG_SUPPORT
-	pAC->PnmiBackup = pAC->PnmiStruct;
-#endif
 
 	pci_set_drvdata(pdev, dev);
 	return 0;
@@ -780,8 +773,6 @@
 static int SkGeBoardInit(struct net_device *dev, SK_AC *pAC)
 {
 short	i;
-char	*DescrString = "sk98lin: Driver for Linux"; /* this is given to PNMI */
-char	*VerStr	= VER_STRING;
 int	Ret;			/* return code of request_irq */
 
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
@@ -821,8 +812,10 @@
 	pAC->BoardLevel = SK_INIT_DATA;
 	pAC->RxBufSize  = ETH_BUF_SIZE;
 
-	SK_PNMI_SET_DRIVER_DESCR(pAC, DescrString);
-	SK_PNMI_SET_DRIVER_VER(pAC, VerStr);
+	SK_PNMI_SET_DRIVER_DESCR(pAC, "sk98lin: Driver for Linux");
+	SK_PNMI_SET_DRIVER_VER(pAC, VER_STRING);
+	SK_PNMI_SET_DRIVER_FILENAME(pAC, DRIVER_FILE_NAME);
+	SK_PNMI_SET_DRIVER_RELDATE(pAC, DRIVER_REL_DATE);
 
 	/* level 1 init common modules here (HW init) */
 	if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
@@ -1657,9 +1650,6 @@
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeClose: done "));
 
-#ifdef SK_DIAG_SUPPORT
-	pAC->PnmiBackup = pAC->PnmiStruct;
-#endif
 	pAC->MaxPorts--;
 
 	return (0);
@@ -3034,69 +3024,60 @@
 SK_AC	*pAC = pNet->pAC;
 SK_PNMI_STRUCT_DATA *pPnmiStruct;       /* structure for all Pnmi-Data */
 SK_PNMI_STAT    *pPnmiStat;             /* pointer to virtual XMAC stat. data */
-SK_PNMI_CONF    *pPnmiConf;             /* pointer to virtual link config. */
 unsigned int    Size;                   /* size of pnmi struct */
 unsigned long	Flags;			/* for spin lock */
 
 	SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
 		("SkGeStats starts now...\n"));
-	pPnmiStruct = &pAC->PnmiStruct;
 
-#ifdef SK_DIAG_SUPPORT
-        if ((pAC->DiagModeActive == DIAG_NOTACTIVE) &&
-                (pAC->BoardLevel == SK_INIT_RUN)) {
-#endif
-        SK_MEMSET(pPnmiStruct, 0, sizeof(SK_PNMI_STRUCT_DATA));
+	pPnmiStruct = kmalloc(sizeof(*pPnmiStruct), GFP_ATOMIC);
+	if (!pPnmiStruct)
+		goto out;
+
+	memset(pPnmiStruct, 0, sizeof(*pPnmiStruct));
+        Size = sizeof(*pPnmiStruct);
+
         spin_lock_irqsave(&pAC->SlowPathLock, Flags);
-        Size = SK_PNMI_STRUCT_SIZE;
 	SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
-
         spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
-#ifdef SK_DIAG_SUPPORT
-	}
-#endif
 
         pPnmiStat = &pPnmiStruct->Stat[0];
-        pPnmiConf = &pPnmiStruct->Conf[0];
 
-	pAC->stats.rx_packets = (SK_U32) pPnmiStruct->RxDeliveredCts & 0xFFFFFFFF;
-	pAC->stats.tx_packets = (SK_U32) pPnmiStat->StatTxOkCts & 0xFFFFFFFF;
-	pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts;
-	pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts;
+	memset(&pAC->stats, 0, sizeof(struct net_device_stats));
+	pAC->stats.rx_packets = pPnmiStruct->RxDeliveredCts;
+	pAC->stats.tx_packets = pPnmiStat->StatTxOkCts;
+	pAC->stats.rx_bytes = pPnmiStruct->RxOctetsDeliveredCts;
+	pAC->stats.tx_bytes = pPnmiStat->StatTxOctetsOkCts;
 	
-        if (dev->mtu <= 1500) {
-                pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF;
-        } else {
-                pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts -
-                        pPnmiStat->StatRxTooLongCts) & 0xFFFFFFFF);
-	}
-
+	pAC->stats.rx_errors = pPnmiStruct->InErrorsCts;
+        if (dev->mtu > 1500)
+                pAC->stats.rx_errors -= pPnmiStat->StatRxTooLongCts;
 
 	if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && pAC->HWRevision < 12)
-		pAC->stats.rx_errors = pAC->stats.rx_errors - pPnmiStat->StatRxShortsCts;
+		pAC->stats.rx_errors -= pPnmiStat->StatRxShortsCts;
 
-	pAC->stats.tx_errors = (SK_U32) pPnmiStat->StatTxSingleCollisionCts & 0xFFFFFFFF;
-	pAC->stats.rx_dropped = (SK_U32) pPnmiStruct->RxNoBufCts & 0xFFFFFFFF;
-	pAC->stats.tx_dropped = (SK_U32) pPnmiStruct->TxNoBufCts & 0xFFFFFFFF;
-	pAC->stats.multicast = (SK_U32) pPnmiStat->StatRxMulticastOkCts & 0xFFFFFFFF;
-	pAC->stats.collisions = (SK_U32) pPnmiStat->StatTxSingleCollisionCts & 0xFFFFFFFF;
+	pAC->stats.tx_errors = pPnmiStat->StatTxSingleCollisionCts;
+	pAC->stats.rx_dropped = pPnmiStruct->RxNoBufCts;
+	pAC->stats.tx_dropped = pPnmiStruct->TxNoBufCts;
+	pAC->stats.multicast = pPnmiStat->StatRxMulticastOkCts;
+	pAC->stats.collisions = pPnmiStat->StatTxSingleCollisionCts;
 
 	/* detailed rx_errors: */
-	pAC->stats.rx_length_errors = (SK_U32) pPnmiStat->StatRxRuntCts & 0xFFFFFFFF;
-	pAC->stats.rx_over_errors = (SK_U32) pPnmiStat->StatRxFifoOverflowCts & 0xFFFFFFFF;
-	pAC->stats.rx_crc_errors = (SK_U32) pPnmiStat->StatRxFcsCts & 0xFFFFFFFF;
-	pAC->stats.rx_frame_errors = (SK_U32) pPnmiStat->StatRxFramingCts & 0xFFFFFFFF;
-	pAC->stats.rx_fifo_errors = (SK_U32) pPnmiStat->StatRxFifoOverflowCts & 0xFFFFFFFF;
-	pAC->stats.rx_missed_errors = (SK_U32) pPnmiStat->StatRxMissedCts & 0xFFFFFFFF;
+	pAC->stats.rx_length_errors = pPnmiStat->StatRxRuntCts;
+	pAC->stats.rx_over_errors = pPnmiStat->StatRxFifoOverflowCts;
+	pAC->stats.rx_crc_errors = pPnmiStat->StatRxFcsCts;
+	pAC->stats.rx_frame_errors = pPnmiStat->StatRxFramingCts;
+	pAC->stats.rx_fifo_errors = pPnmiStat->StatRxFifoOverflowCts;
+	pAC->stats.rx_missed_errors = pPnmiStat->StatRxMissedCts;
 
 	/* detailed tx_errors */
-	pAC->stats.tx_aborted_errors = (SK_U32) 0;
-	pAC->stats.tx_carrier_errors = (SK_U32) pPnmiStat->StatTxCarrierCts & 0xFFFFFFFF;
-	pAC->stats.tx_fifo_errors = (SK_U32) pPnmiStat->StatTxFifoUnderrunCts & 0xFFFFFFFF;
-	pAC->stats.tx_heartbeat_errors = (SK_U32) pPnmiStat->StatTxCarrierCts & 0xFFFFFFFF;
-	pAC->stats.tx_window_errors = (SK_U32) 0;
+	pAC->stats.tx_carrier_errors = pPnmiStat->StatTxCarrierCts;
+	pAC->stats.tx_fifo_errors = pPnmiStat->StatTxFifoUnderrunCts;
+	pAC->stats.tx_heartbeat_errors = pPnmiStat->StatTxCarrierCts;
 
-	return(&pAC->stats);
+	kfree(pPnmiStruct);
+ out:
+	return &pAC->stats;
 } /* SkGeStats */
 
 
@@ -3119,9 +3100,7 @@
 SK_AC		*pAC;
 void		*pMemBuf;
 SK_GE_IOCTL	Ioctl;
-unsigned int	Err = 0;
-int		Size = 0;
-int             Ret = 0;
+int		Err = 0;
 unsigned int	Length = 0;
 int		HeaderLength = sizeof(SK_U32) + sizeof(SK_U32);
 
@@ -3140,27 +3119,35 @@
 	case SK_IOCTL_PRESETMIB:
 		if (!capable(CAP_NET_ADMIN)) return -EPERM;
  	case SK_IOCTL_GETMIB:
-		if(copy_from_user(&pAC->PnmiStruct, Ioctl.pData,
-			Ioctl.Len<sizeof(pAC->PnmiStruct)?
-			Ioctl.Len : sizeof(pAC->PnmiStruct))) {
-			return -EFAULT;
-		}
-		Size = SkGeIocMib(pNet, Ioctl.Len, cmd);
-		if(copy_to_user(Ioctl.pData, &pAC->PnmiStruct,
-			Ioctl.Len<Size? Ioctl.Len : Size)) {
-			return -EFAULT;
-		}
-		Ioctl.Len = Size;
-		if(copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) {
+	{
+		SK_PNMI_STRUCT_DATA *pPnmiStruct;
+
+		pPnmiStruct = kmalloc(sizeof(*pPnmiStruct), GFP_KERNEL);
+		if (!pPnmiStruct)
+			return -ENOMEM;
+
+		memset(pPnmiStruct, 0, sizeof(*pPnmiStruct));
+
+		if (copy_from_user(pPnmiStruct, Ioctl.pData, 
+				   min(sizeof(*pPnmiStruct), Ioctl.Len)))
 			return -EFAULT;
+
+		Length = SkGeIocMib(pNet, pPnmiStruct, Ioctl.Len, cmd);
+		if (copy_to_user(Ioctl.pData, pPnmiStruct, 
+				 min(Length, Ioctl.Len)))
+			Err = -EFAULT;
+		else {
+			Ioctl.Len = Length;
+			if (copy_to_user(rq->ifr_data, &Ioctl, 
+					 sizeof(SK_GE_IOCTL))) 
+				Err = -EFAULT;
 		}
+		kfree(pPnmiStruct);
 		break;
+	}
 	case SK_IOCTL_GEN:
-		if (Ioctl.Len < (sizeof(pAC->PnmiStruct) + HeaderLength)) {
-			Length = Ioctl.Len;
-		} else {
-			Length = sizeof(pAC->PnmiStruct) + HeaderLength;
-		}
+		Length = min(Ioctl.Len, SK_PNMI_STRUCT_SIZE + HeaderLength);
+
 		if (NULL == (pMemBuf = kmalloc(Length, GFP_KERNEL))) {
 			return -ENOMEM;
 		}
@@ -3168,16 +3155,16 @@
 			Err = -EFAULT;
 			goto fault_gen;
 		}
-		if ((Ret = SkPnmiGenIoctl(pAC, pAC->IoBase, pMemBuf, &Length, 0)) < 0) {
+		if ((Err = SkPnmiGenIoctl(pAC, pAC->IoBase, pMemBuf, &Length, 0)) < 0) {
 			Err = -EFAULT;
 			goto fault_gen;
 		}
-		if(copy_to_user(Ioctl.pData, pMemBuf, Length) ) {
+		if (copy_to_user(Ioctl.pData, pMemBuf, Length) ) {
 			Err = -EFAULT;
 			goto fault_gen;
 		}
 		Ioctl.Len = Length;
-		if(copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) {
+		if (copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) {
 			Err = -EFAULT;
 			goto fault_gen;
 		}
@@ -3187,15 +3174,14 @@
 #ifdef SK_DIAG_SUPPORT
        case SK_IOCTL_DIAG:
 		if (!capable(CAP_NET_ADMIN)) return -EPERM;
-		if (Ioctl.Len < (sizeof(pAC->PnmiStruct) + HeaderLength)) {
-			Length = Ioctl.Len;
-		} else {
-			Length = sizeof(pAC->PnmiStruct) + HeaderLength;
-		}
+
+		Length = min(Ioctl.Len, SK_PNMI_STRUCT_SIZE + HeaderLength);
+
 		if (NULL == (pMemBuf = kmalloc(Length, GFP_KERNEL))) {
 			return -ENOMEM;
 		}
-		if(copy_from_user(pMemBuf, Ioctl.pData, Length)) {
+
+		if (copy_from_user(pMemBuf, Ioctl.pData, Length)) {
 			Err = -EFAULT;
 			goto fault_diag;
 		}
@@ -3230,7 +3216,6 @@
 
 } /* SkGeIoctl */
 
-
 /*****************************************************************************
  *
  * 	SkGeIocMib - handle a GetMib, SetMib- or PresetMib-ioctl message
@@ -3248,8 +3233,9 @@
  * Returns:
  *	returned size from PNMI call
  */
-static int SkGeIocMib(
+static unsigned int SkGeIocMib(
 DEV_NET		*pNet,	/* pointer to the adapter context */
+SK_PNMI_STRUCT_DATA *pPnmiStruct,       /* structure for all Pnmi-Data */
 unsigned int	Size,	/* length of ioctl data */
 int		mode)	/* flag for set/preset */
 {
@@ -3263,16 +3249,13 @@
 	spin_lock_irqsave(&pAC->SlowPathLock, Flags);
 	switch(mode) {
 	case SK_IOCTL_GETMIB:
-		SkPnmiGetStruct(pAC, pAC->IoBase, &pAC->PnmiStruct, &Size,
-			pNet->NetNr);
+		SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
 		break;
 	case SK_IOCTL_PRESETMIB:
-		SkPnmiPreSetStruct(pAC, pAC->IoBase, &pAC->PnmiStruct, &Size,
-			pNet->NetNr);
+		SkPnmiPreSetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
 		break;
 	case SK_IOCTL_SETMIB:
-		SkPnmiSetStruct(pAC, pAC->IoBase, &pAC->PnmiStruct, &Size,
-			pNet->NetNr);
+		SkPnmiSetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
 		break;
 	default:
 		break;
@@ -4689,8 +4672,6 @@
 	DEV_NET *pNet = netdev_priv(pAc->dev[0]);
 	SK_AC   *pAC  = pNet->pAC;
 
-	pAc->PnmiBackup = pAC->PnmiStruct;
-
 	pAC->DiagModeActive = DIAG_ACTIVE;
 	if (pAC->BoardLevel > SK_INIT_DATA) {
 		if (netif_running(pAC->dev[0])) {
@@ -4730,7 +4711,6 @@
 int SkDrvLeaveDiagMode(
 SK_AC   *pAc)   /* pointer to adapter control context */
 { 
-	pAc->PnmiStruct = pAc->PnmiBackup;
 	pAc->DiagModeActive    = DIAG_NOTACTIVE;
 	pAc->Pnmi.DiagAttached = SK_DIAG_IDLE;
         if (pAc->WasIfUp[0] == SK_TRUE) {
diff -Nru a/drivers/net/sk98lin/skproc.c b/drivers/net/sk98lin/skproc.c
--- a/drivers/net/sk98lin/skproc.c	2004-11-09 15:29:23 -08:00
+++ b/drivers/net/sk98lin/skproc.c	2004-11-09 15:29:23 -08:00
@@ -60,33 +60,26 @@
 	struct net_device *dev = seq->private;
 	DEV_NET			*pNet = netdev_priv(dev);
 	SK_AC			*pAC = pNet->pAC;
-	SK_PNMI_STRUCT_DATA 	*pPnmiStruct = &pAC->PnmiStruct;
+	SK_PNMI_STRUCT_DATA 	*pPnmiStruct;
 	unsigned long		Flags;	
 	unsigned int		Size;
 	char			sens_msg[50];
 	int 			t;
 	int 			i;
 
+	pPnmiStruct = kmalloc(sizeof(*pPnmiStruct), GFP_KERNEL);
+	if (!pPnmiStruct)
+		return -ENOMEM;
+
 	/* NetIndex in GetStruct is now required, zero is only dummy */
 	for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
 		if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
 			t--;
 
+		memset(pPnmiStruct, 0, sizeof(*pPnmiStruct));
 		spin_lock_irqsave(&pAC->SlowPathLock, Flags);
 		Size = SK_PNMI_STRUCT_SIZE;
-#ifdef SK_DIAG_SUPPORT
-		if (pAC->BoardLevel == SK_INIT_DATA) {
-			pAC->PnmiStruct = pAC->PnmiBackup;
-			if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
-				pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
-			}
-		} else {
-			SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
-		}
-#else
-		SkPnmiGetStruct(pAC, pAC->IoBase, 
-				pPnmiStruct, &Size, t-1);
-#endif
+		SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
 		spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 	
 		if (pAC->dev[t-1] == dev) {
@@ -240,6 +233,7 @@
 				
 		}
 	}
+	kfree(pPnmiStruct);
 	return 0;
 }
 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (0/23) sk98 driver fixes and enhancements
  2004-11-12  0:11 ` [PATCH] (0/23) sk98 driver fixes and enhancements Stephen Hemminger
@ 2004-11-12  0:17   ` Michael Heyse
  2004-11-12  0:27     ` Stephen Hemminger
  0 siblings, 1 reply; 35+ messages in thread
From: Michael Heyse @ 2004-11-12  0:17 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Jeff Garzik, netdev

Stephen Hemminger wrote:
> This is the first set of patches to merge some of the new SysKonnect
> code with existing 2.6 driver and fix several bugs. 

So I was wrong and it did *not* take very long ;-)
Thanks!

Michael

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (0/23) sk98 driver fixes and enhancements
  2004-11-12  0:17   ` Michael Heyse
@ 2004-11-12  0:27     ` Stephen Hemminger
  0 siblings, 0 replies; 35+ messages in thread
From: Stephen Hemminger @ 2004-11-12  0:27 UTC (permalink / raw)
  To: Michael Heyse; +Cc: Jeff Garzik, netdev

On Fri, 12 Nov 2004 01:17:10 +0100
Michael Heyse <mhk@designassembly.de> wrote:

> Stephen Hemminger wrote:
> > This is the first set of patches to merge some of the new SysKonnect
> > code with existing 2.6 driver and fix several bugs. 
> 
> So I was wrong and it did *not* take very long ;-)
> Thanks!
> 
> Michael

Still missing stuff from the SysKonnect version:
	* Yukon2 support because existing SysKonnect code is too ugly
	as it is. Next week I should have a de-mucked version.  
	* NAPI code in their version is broken under stress and needs work.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (1/23) sk98: no explicit module ref counting needed
  2004-11-12  0:11   ` [PATCH] (1/23) sk98: no explicit module ref counting needed Stephen Hemminger
@ 2004-11-12  0:51     ` Mirko Lindner
  0 siblings, 0 replies; 35+ messages in thread
From: Mirko Lindner @ 2004-11-12  0:51 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Jeff Garzik, Michael Heyse, Mirko Lindner, netdev

Thanks Stephen. We'll check the functionality and let you know as soon 
as possible.

Mirko

Stephen Hemminger wrote:
 > Network driver's shouldn't be doing module reference counting
 > on 2.6.  This is a bad replication of 2.4 behaviour

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (13/23) sk98: handle ring full correctly
  2004-11-12  0:00   ` [PATCH] (13/23) sk98: handle ring full correctly Stephen Hemminger
@ 2004-11-12 10:54     ` Tommy Christensen
  0 siblings, 0 replies; 35+ messages in thread
From: Tommy Christensen @ 2004-11-12 10:54 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Jeff Garzik, Michael Heyse, Mirko Lindner, netdev

On Fri, 2004-11-12 at 01:00, Stephen Hemminger wrote:
> This driver needs to manage it's transmit queue properly.
> The hard_start_xmit needs to return OK if send successfully
> and BUSY (1) if queue is full. In either case must free skb,
> existing code would leak if tx ring filled!

This isn't true. When returning NETDEV_TX_BUSY, the caller
will requeue or drop the skb. So

> +	/* Transmit failed, out of resources */
> +	if (rc < 0) {
> +		dev_kfree_skb(skb);
> +		return NETDEV_TX_BUSY;
> +	} else {
> +		dev->trans_start = jiffies;		
> +		return NETDEV_TX_OK;
> +	}

it shouldn't be freed here.

-Tommy

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (3/23) sk98: /proc interface related changes
  2004-11-11 23:53   ` [PATCH] (3/23) sk98: /proc interface related changes Stephen Hemminger
@ 2004-11-12 16:26     ` Christoph Hellwig
  2004-11-13  4:34       ` shemminger
  0 siblings, 1 reply; 35+ messages in thread
From: Christoph Hellwig @ 2004-11-12 16:26 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Jeff Garzik, Michael Heyse, Mirko Lindner, netdev

On Thu, Nov 11, 2004 at 03:53:49PM -0800, Stephen Hemminger wrote:
> The /proc intereface can be cleaned up a lot:
> + Pass the device to through the proc data/seq_private hook.
> + No longer needs to have a list of network devices 
> + use seq_printf directly rather than indirection into a buffer
> + failure to create proc directory or interface should not
>   be fatal.
> + if PROC_FS not configured, let the stubs cause the necessary
>   code elimination rather than using #ifdef

This is still totally broken because dev->name may change between
registration and removal.  If a netdriver wants to use procfs file
per-adapter it needs to use an enumeration scheme independant of the
netdevice naming.  Or even better stop using procfs at all.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (7/23) sk98: basic ethtool support
  2004-11-11 23:55   ` [PATCH] (7/23) sk98: basic ethtool support Stephen Hemminger
@ 2004-11-12 16:29     ` Christoph Hellwig
  2004-11-13  4:39       ` shemminger
  0 siblings, 1 reply; 35+ messages in thread
From: Christoph Hellwig @ 2004-11-12 16:29 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Jeff Garzik, Michael Heyse, Mirko Lindner, netdev

On Thu, Nov 11, 2004 at 03:55:03PM -0800, Stephen Hemminger wrote:
> The basic stuff comes from the newer code from SysKonnect, but I redid
> it using ethtool_ops and a cleaner way of doing the stats (from e100)


> +/*****************************************************************************
> + *
> + * 	getSettings - retrieves the current settings of the selected adapter
> + *
> + * Description:
> + *	The current configuration of the selected adapter is returned.
> + *	This configuration involves a)speed, b)duplex and c)autoneg plus
> + *	a number of other variables.
> + *
> + * Returns:    always 0
> + *
> + */

Please use normal kernel-doc function documentation.
 
> +static int getSettings(struct net_device *dev, struct ethtool_cmd *ecmd)

And avoid studlyCaps.  Also an sk98lin prefix even on private function
helps avoiding nameclashes for the generic names (and in the debugger
or oopses)

> +{
> +	const DEV_NET *pNet = netdev_priv(dev);

please always use struct net_device instead of strange typedefs for it.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (15/23) sk98: rearrange initialization
  2004-11-12  0:01   ` [PATCH] (15/23) sk98: rearrange initialization Stephen Hemminger
@ 2004-11-12 16:30     ` Christoph Hellwig
  2004-11-13  4:43       ` shemminger
  0 siblings, 1 reply; 35+ messages in thread
From: Christoph Hellwig @ 2004-11-12 16:30 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Jeff Garzik, Michael Heyse, Mirko Lindner, netdev

On Thu, Nov 11, 2004 at 04:01:13PM -0800, Stephen Hemminger wrote:
> The code in the latest SysKonnect driver is arranged differently,
> this aligns the two versions to allow for easier comparisons.
> Also:
> 	Don't enable the pci device twice.
> 	Add common SkGeDevInit for common code used to setup both ports

please don't reorder the functions.  I placed them in natural order when
converting to new pci probing for a good reason.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (3/23) sk98: /proc interface related changes
  2004-11-12 16:26     ` Christoph Hellwig
@ 2004-11-13  4:34       ` shemminger
  0 siblings, 0 replies; 35+ messages in thread
From: shemminger @ 2004-11-13  4:34 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Stephen Hemminger, Jeff Garzik, Michael Heyse, Mirko Lindner,
	netdev

> On Thu, Nov 11, 2004 at 03:53:49PM -0800, Stephen Hemminger wrote:
>> The /proc intereface can be cleaned up a lot:
>> + Pass the device to through the proc data/seq_private hook.
>> + No longer needs to have a list of network devices
>> + use seq_printf directly rather than indirection into a buffer
>> + failure to create proc directory or interface should not
>>   be fatal.
>> + if PROC_FS not configured, let the stubs cause the necessary
>>   code elimination rather than using #ifdef
>
> This is still totally broken because dev->name may change between
> registration and removal.  If a netdriver wants to use procfs file
> per-adapter it needs to use an enumeration scheme independant of the
> netdevice naming.  Or even better stop using procfs at all.

I would prefer to get rid of /proc interface altogether. I will
unless SysKonnect says they have some application depending on it.

There are a few statistics that don't show up in ethtool, but
it wouldn't be hard to add those (or put them in sysfs).

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (7/23) sk98: basic ethtool support
  2004-11-12 16:29     ` Christoph Hellwig
@ 2004-11-13  4:39       ` shemminger
  0 siblings, 0 replies; 35+ messages in thread
From: shemminger @ 2004-11-13  4:39 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Stephen Hemminger, Jeff Garzik, Michael Heyse, Mirko Lindner,
	netdev

> On Thu, Nov 11, 2004 at 03:55:03PM -0800, Stephen Hemminger wrote:
>> The basic stuff comes from the newer code from SysKonnect, but I redid
>> it using ethtool_ops and a cleaner way of doing the stats (from e100)
>
>
>> +/*****************************************************************************
>> + *
>> + * 	getSettings - retrieves the current settings of the selected
>> adapter
>> + *
>> + * Description:
>> + *	The current configuration of the selected adapter is returned.
>> + *	This configuration involves a)speed, b)duplex and c)autoneg plus
>> + *	a number of other variables.
>> + *
>> + * Returns:    always 0
>> + *
>> + */
>
> Please use normal kernel-doc function documentation.

That was SysKonnect's format, personally I would rather no
comment because this isn't an API for any external usage and
is obvious.

>
>> +static int getSettings(struct net_device *dev, struct ethtool_cmd
>> *ecmd)
>
> And avoid studlyCaps.  Also an sk98lin prefix even on private function
> helps avoiding nameclashes for the generic names (and in the debugger
> or oopses)

I'll just change them to normal kernel format (ie get_settings).
But no, putting prefix's on local obvious functions is a waste.

>> +{
>> +	const DEV_NET *pNet = netdev_priv(dev);
>
> please always use struct net_device instead of strange typedefs for it.

DEV_NET is one of their typedef's (for the driver private data). I prefer
to change them last after all the other patches. Don't want some files
using 'struct s_Devnet' and others using 'DEV_NET', that would be
more confusing.  Eventually DEV_NET will be replaced by something
more descriptive 'struct sk98_port' and AC will be 'struct sk8_board'

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (15/23) sk98: rearrange initialization
  2004-11-12 16:30     ` Christoph Hellwig
@ 2004-11-13  4:43       ` shemminger
  0 siblings, 0 replies; 35+ messages in thread
From: shemminger @ 2004-11-13  4:43 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Stephen Hemminger, Jeff Garzik, Michael Heyse, Mirko Lindner,
	netdev

> On Thu, Nov 11, 2004 at 04:01:13PM -0800, Stephen Hemminger wrote:
>> The code in the latest SysKonnect driver is arranged differently,
>> this aligns the two versions to allow for easier comparisons.
>> Also:
>> 	Don't enable the pci device twice.
>> 	Add common SkGeDevInit for common code used to setup both ports
>
> please don't reorder the functions.  I placed them in natural order when
> converting to new pci probing for a good reason.

I really don't care which way it goes, just trying to make SysKonnect's
life easeier.  When all the comments are in, I will redo the patches
without the reordering

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] (10/23) sk98: cleanout unnecessary controller elements
  2004-11-11 23:55   ` [PATCH] (10/23) sk98: cleanout unnecessary controller elements Stephen Hemminger
@ 2004-11-14  1:43     ` Jeff Garzik
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Garzik @ 2004-11-14  1:43 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Michael Heyse, Mirko Lindner, netdev

Stephen Hemminger wrote:
> Catchall cleanup patch:
> 	* get rid of obfuscating #define's
> 	* eliminate structure elements in the controller structure
> 	  that are never used or only used in one context or available
> 	  in net_device


I applied patches 1 - 9 to netdev-2.6 queue.

I would prefer that you split up this patch a bit more, and resend that 
(and the rest of this series) in a new patch series.

	Jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2004-11-14  1:43 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4192C60A.1050205@designassembly.de>
     [not found] ` <20041111154225.5cf85567@zqx3.pdx.osdl.net>
2004-11-11 23:53   ` [PATCH] (2/23) sk98: local variable can be constant Stephen Hemminger
2004-11-11 23:53   ` [PATCH] (3/23) sk98: /proc interface related changes Stephen Hemminger
2004-11-12 16:26     ` Christoph Hellwig
2004-11-13  4:34       ` shemminger
2004-11-11 23:54   ` [PATCH] (4/23) sk98: use netdev_priv Stephen Hemminger
2004-11-11 23:54   ` [PATCH] (5/23) sk98: use module_param Stephen Hemminger
2004-11-11 23:54   ` [PATCH] (6/23) sk98: add netpoll console support Stephen Hemminger
2004-11-11 23:55   ` [PATCH] (7/23) sk98: basic ethtool support Stephen Hemminger
2004-11-12 16:29     ` Christoph Hellwig
2004-11-13  4:39       ` shemminger
2004-11-11 23:55   ` [PATCH] (8/23) sk98: ethtool phy support Stephen Hemminger
2004-11-11 23:55   ` [PATCH] (9/23) sk98: ethtool pause param support Stephen Hemminger
2004-11-11 23:55   ` [PATCH] (10/23) sk98: cleanout unnecessary controller elements Stephen Hemminger
2004-11-14  1:43     ` Jeff Garzik
2004-11-11 23:57   ` [PATCH] (12/23) sk98: add module version Stephen Hemminger
2004-11-11 23:57   ` [PATCH] (11/23) sk98: board counter incremented twice Stephen Hemminger
2004-11-12  0:00   ` [PATCH] (13/23) sk98: handle ring full correctly Stephen Hemminger
2004-11-12 10:54     ` Tommy Christensen
2004-11-12  0:01   ` [PATCH] (15/23) sk98: rearrange initialization Stephen Hemminger
2004-11-12 16:30     ` Christoph Hellwig
2004-11-13  4:43       ` shemminger
2004-11-12  0:01   ` [PATCH] (14/23) sk98: don't obfuscate irqreturn_t Stephen Hemminger
2004-11-12  0:02   ` [PATCH] (16/23) sk98: more efficient time OsGetTime Stephen Hemminger
2004-11-12  0:03   ` [PATCH] (17/23) sk98: use lockless transmit Stephen Hemminger
2004-11-12  0:07   ` [PATCH] (20/23) sk98: checksum ethtool and improvements Stephen Hemminger
2004-11-12  0:07   ` [PATCH] (19/23) sk98: more cleanups Stephen Hemminger
2004-11-12  0:07   ` [PATCH] (18/23) sk98: update pci_id table Stephen Hemminger
2004-11-12  0:09   ` [PATCH] (21/23) sk98: transmit ring barriers Stephen Hemminger
2004-11-12  0:09   ` [PATCH] (22/23) sk98: diag code changes Stephen Hemminger
2004-11-12  0:11   ` [PATCH] (23/23) sk98: eliminate large controller scratch pad elements Stephen Hemminger
2004-11-12  0:11 ` [PATCH] (0/23) sk98 driver fixes and enhancements Stephen Hemminger
2004-11-12  0:17   ` Michael Heyse
2004-11-12  0:27     ` Stephen Hemminger
     [not found] ` <20041111154016.6381189d@zqx3.pdx.osdl.net>
2004-11-12  0:11   ` [PATCH] (1/23) sk98: no explicit module ref counting needed Stephen Hemminger
2004-11-12  0:51     ` Mirko Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).