patch-2.4.25 linux-2.4.25/drivers/net/sk98lin/skproc.c

Next file: linux-2.4.25/drivers/net/sk98lin/skqueue.c
Previous file: linux-2.4.25/drivers/net/sk98lin/sklm80.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.24/drivers/net/sk98lin/skproc.c linux-2.4.25/drivers/net/sk98lin/skproc.c
@@ -1,16 +1,17 @@
 /******************************************************************************
  *
- * Name:    skproc.c
+ * Name:	skproc.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.2 $
- * Date:    $Date: 2003/08/12 16:45:29 $
+ * Version:	$Revision: 1.11 $
+ * Date:	$Date: 2003/12/11 16:03:57 $
  * Purpose:	Funktions to display statictic data
  *
  ******************************************************************************/
  
 /******************************************************************************
  *
- *	(C)Copyright 1998-2003 SysKonnect GmbH.
+ *	(C)Copyright 1998-2002 SysKonnect GmbH.
+ *	(C)Copyright 2002-2003 Marvell.
  *
  *	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
@@ -28,6 +29,33 @@
  * History:
  *
  *	$Log: skproc.c,v $
+ *	Revision 1.11  2003/12/11 16:03:57  mlindner
+ *	Fix: Create backup from pnmi data structure
+ *	
+ *	Revision 1.10  2003/11/19 16:25:36  mlindner
+ *	Fix: Print output as 64-bit digit
+ *	
+ *	Revision 1.9  2003/11/17 13:29:05  mlindner
+ *	Fix: Editorial changes
+ *	
+ *	Revision 1.8  2003/11/13 14:18:48  rroesler
+ *	Fix: added latest changes regarding the use of the proc system
+ *	
+ *	Revision 1.7  2003/11/10 09:35:07  rroesler
+ *	Fix: diag backup restore of PNMI structure
+ *	
+ *	Revision 1.6  2003/11/07 17:31:39  rroesler
+ *	Add: security counter for the proc file system
+ *	
+ *	Revision 1.5  2003/10/07 08:17:08  mlindner
+ *	Fix: Copyright changes
+ *	
+ *	Revision 1.4  2003/09/01 15:29:24  mlindner
+ *	Fix: Editorial changes
+ *	
+ *	Revision 1.3  2003/08/29 12:30:58  mlindner
+ *	Add: Version entry in the proc file system
+ *	
  *	Revision 1.2  2003/08/12 16:45:29  mlindner
  *	Add: Removed SkNumber and SkDoDiv
  *	Add: Counter output as (unsigned long long)
@@ -93,54 +121,83 @@
 
 #include "h/skdrv1st.h"
 #include "h/skdrv2nd.h"
+#include "h/skversion.h"
 
-	extern struct net_device	*SkGeRootDev;
+extern struct SK_NET_DEVICE *SkGeRootDev;
+static int sk_proc_print(void *writePtr, char *format, ...);
+static void sk_gen_browse(void *buffer);
+int len;
 
+struct proc_dir_entry *file = NULL;
 
-int sk_proc_read(char *buffer,
-				char **buffer_location,
-				off_t offset,
-				int buffer_length,
-				int *eof,
-				void *data);
+/*****************************************************************************
+ *
+ *      sk_proc_read - 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
+ *      
+ */
+int sk_proc_read(char   *buffer,
+		char  **buffer_location,
+		off_t   offset,
+		int     buffer_length,
+		int    *eof,
+		void   *data)
+{
+	void *castedBuffer = (void *) buffer;
+	file               = (struct proc_dir_entry*) data;
+	len                = 0; /* initial value */
+	sk_gen_browse(castedBuffer);
 
+	if (offset >= len) {
+		*eof = 1;
+		return 0;
+	}
 
+	*buffer_location = buffer + offset;
+	if (buffer_length >= len - offset) {
+		*eof = 1;
+	}
+	return (min_t(int, buffer_length, len - offset));
+}
 
 /*****************************************************************************
  *
- * 	sk_proc_read - print "summaries" entry 
+ * 	sk_gen_browse -generic  print "summaries" entry 
  *
  * Description:
  *  This function fills the proc entry with statistic data about 
  *  the ethernet device.
  *  
- *
- * Returns: buffer with statistic data
+ * Returns: -
  *	
  */
-int sk_proc_read(char *buffer,
-char **buffer_location,
-off_t offset,
-int buffer_length,
-int *eof,
-void *data)
+static void sk_gen_browse(void *buffer)
 {
-	int len = 0;
-	int t;
-	int i;
-	DEV_NET					*pNet;
-	SK_AC					*pAC;
-	char					sens_msg[50];
-	unsigned long			Flags;	
-	unsigned int			Size;
-	struct SK_NET_DEVICE 		*next;
-	struct SK_NET_DEVICE 		*SkgeProcDev = SkGeRootDev;
-
+	struct SK_NET_DEVICE	*SkgeProcDev = SkGeRootDev;
+	struct SK_NET_DEVICE	*next;
 	SK_PNMI_STRUCT_DATA 	*pPnmiStruct;
 	SK_PNMI_STAT		*pPnmiStat;
-	struct proc_dir_entry *file = (struct proc_dir_entry*) data;
+	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;
@@ -153,38 +210,52 @@
 
 			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);
+			}
+#else
 			SkPnmiGetStruct(pAC, pAC->IoBase, 
 				pPnmiStruct, &Size, t-1);
+#endif
 			spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 	
 			if (strcmp(pAC->dev[t-1]->name, file->name) == 0) {
 				pPnmiStat = &pPnmiStruct->Stat[0];
-				len = sprintf(buffer, 
+				len = sk_proc_print(buffer, 
 					"\nDetailed statistic for device %s\n",
 					pAC->dev[t-1]->name);
-				len += sprintf(buffer + len,
+				len += sk_proc_print(buffer,
 					"=======================================\n");
 	
 				/* Board statistics */
-				len += sprintf(buffer + len, 
+				len += sk_proc_print(buffer, 
 					"\nBoard statistics\n\n");
-				len += sprintf(buffer + len,
+				len += sk_proc_print(buffer,
 					"Active Port                    %c\n",
 					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
 					Net[t-1].PrefPort]->PortNumber);
-				len += sprintf(buffer + len,
+				len += sk_proc_print(buffer,
 					"Preferred Port                 %c\n",
 					'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
 					Net[t-1].PrefPort]->PortNumber);
 
-				len += sprintf(buffer + len,
+				len += sk_proc_print(buffer,
 					"Bus speed (MHz)                %d\n",
 					pPnmiStruct->BusSpeed);
 
-				len += sprintf(buffer + len,
+				len += sk_proc_print(buffer,
 					"Bus width (Bit)                %d\n",
 					pPnmiStruct->BusWidth);
-				len += sprintf(buffer + len,
+				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);
@@ -196,7 +267,7 @@
 					case 1:
 						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
 						strcat(sens_msg, " (C)");
-						len += sprintf(buffer + len,
+						len += sk_proc_print(buffer,
 							"%-25s      %d.%02d\n",
 							sens_msg,
 							pAC->I2c.SenTable[i].SenValue / 10,
@@ -204,7 +275,7 @@
 
 						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
 						strcat(sens_msg, " (F)");
-						len += sprintf(buffer + len,
+						len += sk_proc_print(buffer,
 							"%-25s      %d.%02d\n",
 							sens_msg,
 							((((pAC->I2c.SenTable[i].SenValue)
@@ -215,7 +286,7 @@
 					case 2:
 						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
 						strcat(sens_msg, " (V)");
-						len += sprintf(buffer + len,
+						len += sk_proc_print(buffer,
 							"%-25s      %d.%03d\n",
 							sens_msg,
 							pAC->I2c.SenTable[i].SenValue / 1000,
@@ -224,7 +295,7 @@
 					case 3:
 						strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
 						strcat(sens_msg, " (rpm)");
-						len += sprintf(buffer + len,
+						len += sk_proc_print(buffer,
 							"%-25s      %d\n",
 							sens_msg,
 							pAC->I2c.SenTable[i].SenValue);
@@ -235,14 +306,14 @@
 				}
 				
 				/*Receive statistics */
-				len += sprintf(buffer + len, 
+				len += sk_proc_print(buffer, 
 				"\nReceive statistics\n\n");
 
-				len += sprintf(buffer + len,
-					"Received bytes                 %Ld\n",
+				len += sk_proc_print(buffer,
+					"Received bytes                 %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxOctetsOkCts);
-				len += sprintf(buffer + len,
-					"Received packets               %Ld\n",
+				len += sk_proc_print(buffer,
+					"Received packets               %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxOkCts);
 #if 0
 				if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && 
@@ -256,110 +327,138 @@
 					pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
 						pPnmiStat->StatRxTooLongCts;
 
-				len += sprintf(buffer + len,
-					"Receive errors                 %Ld\n",
+				len += sk_proc_print(buffer,
+					"Receive errors                 %Lu\n",
 					(unsigned long long) pPnmiStruct->InErrorsCts);
-				len += sprintf(buffer + len,
-					"Receive dropped                %Ld\n",
+				len += sk_proc_print(buffer,
+					"Receive dropped                %Lu\n",
 					(unsigned long long) pPnmiStruct->RxNoBufCts);
-				len += sprintf(buffer + len,
-					"Received multicast             %Ld\n",
+				len += sk_proc_print(buffer,
+					"Received multicast             %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxMulticastOkCts);
-				len += sprintf(buffer + len,
+				len += sk_proc_print(buffer,
 					"Receive error types\n");
-				len += sprintf(buffer + len,
-					"   length                      %Ld\n",
+				len += sk_proc_print(buffer,
+					"   length                      %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxRuntCts);
-				len += sprintf(buffer + len,
-					"   buffer overflow             %Ld\n",
+				len += sk_proc_print(buffer,
+					"   buffer overflow             %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
-				len += sprintf(buffer + len,
-					"   bad crc                     %Ld\n",
+				len += sk_proc_print(buffer,
+					"   bad crc                     %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxFcsCts);
-				len += sprintf(buffer + len,
-					"   framing                     %Ld\n",
+				len += sk_proc_print(buffer,
+					"   framing                     %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxFramingCts);
-				len += sprintf(buffer + len,
-					"   missed frames               %Ld\n",
+				len += sk_proc_print(buffer,
+					"   missed frames               %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxMissedCts);
 
 				if (pNet->Mtu > 1500)
 					pPnmiStat->StatRxTooLongCts = 0;
 
-				len += sprintf(buffer + len,
-					"   too long                    %Ld\n",
+				len += sk_proc_print(buffer,
+					"   too long                    %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxTooLongCts);					
-				len += sprintf(buffer + len,
-					"   carrier extension           %Ld\n",
+				len += sk_proc_print(buffer,
+					"   carrier extension           %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxCextCts);				
-				len += sprintf(buffer + len,
-					"   too short                   %Ld\n",
+				len += sk_proc_print(buffer,
+					"   too short                   %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxShortsCts);				
-				len += sprintf(buffer + len,
-					"   symbol                      %Ld\n",
+				len += sk_proc_print(buffer,
+					"   symbol                      %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxSymbolCts);				
-				len += sprintf(buffer + len,
-					"   LLC MAC size                %Ld\n",
+				len += sk_proc_print(buffer,
+					"   LLC MAC size                %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxIRLengthCts);				
-				len += sprintf(buffer + len,
-					"   carrier event               %Ld\n",
+				len += sk_proc_print(buffer,
+					"   carrier event               %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxCarrierCts);				
-				len += sprintf(buffer + len,
-					"   jabber                      %Ld\n",
+				len += sk_proc_print(buffer,
+					"   jabber                      %Lu\n",
 					(unsigned long long) pPnmiStat->StatRxJabberCts);				
 
 
 				/*Transmit statistics */
-				len += sprintf(buffer + len, 
+				len += sk_proc_print(buffer, 
 				"\nTransmit statistics\n\n");
 				
-				len += sprintf(buffer + len,
-					"Transmited bytes               %Ld\n",
+				len += sk_proc_print(buffer,
+					"Transmited bytes               %Lu\n",
 					(unsigned long long) pPnmiStat->StatTxOctetsOkCts);
-				len += sprintf(buffer + len,
-					"Transmited packets             %Ld\n",
+				len += sk_proc_print(buffer,
+					"Transmited packets             %Lu\n",
 					(unsigned long long) pPnmiStat->StatTxOkCts);
-				len += sprintf(buffer + len,
-					"Transmit errors                %Ld\n",
+				len += sk_proc_print(buffer,
+					"Transmit errors                %Lu\n",
 					(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
-				len += sprintf(buffer + len,
-					"Transmit dropped               %Ld\n",
+				len += sk_proc_print(buffer,
+					"Transmit dropped               %Lu\n",
 					(unsigned long long) pPnmiStruct->TxNoBufCts);
-				len += sprintf(buffer + len,
-					"Transmit collisions            %Ld\n",
+				len += sk_proc_print(buffer,
+					"Transmit collisions            %Lu\n",
 					(unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
-				len += sprintf(buffer + len,
+				len += sk_proc_print(buffer,
 					"Transmit error types\n");
-				len += sprintf(buffer + len,
+				len += sk_proc_print(buffer,
 					"   excessive collision         %ld\n",
 					pAC->stats.tx_aborted_errors);
-				len += sprintf(buffer + len,
-					"   carrier                     %Ld\n",
+				len += sk_proc_print(buffer,
+					"   carrier                     %Lu\n",
 					(unsigned long long) pPnmiStat->StatTxCarrierCts);
-				len += sprintf(buffer + len,
-					"   fifo underrun               %Ld\n",
+				len += sk_proc_print(buffer,
+					"   fifo underrun               %Lu\n",
 					(unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
-				len += sprintf(buffer + len,
-					"   heartbeat                   %Ld\n",
+				len += sk_proc_print(buffer,
+					"   heartbeat                   %Lu\n",
 					(unsigned long long) pPnmiStat->StatTxCarrierCts);
-				len += sprintf(buffer + len,
+				len += sk_proc_print(buffer,
 					"   window                      %ld\n",
 					pAC->stats.tx_window_errors);
 				
-			}
+			} /* if (strcmp(pACname, currDeviceName) == 0) */
 		}
 		SkgeProcDev = next;
 	}
-	if (offset >= len) {
-		*eof = 1;
-		return 0;
-	}
+}
 
-	*buffer_location = buffer + offset;
-	if (buffer_length >= len - offset) {
-		*eof = 1;
-	}
-	return (min_t(int, buffer_length, len - offset));
+/*****************************************************************************
+ *
+ *      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;
+
+	char    *buffer = (char *) writePtr;
+	buffer = buffer + len; /* plus global variable len for current location */
+
+	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);
+
+	sprintf(buffer, str);
+	return lenght;
 }
 
 
+/*******************************************************************************
+ *
+ * End of file
+ *
+ ******************************************************************************/

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)