patch-2.4.7 linux/drivers/net/sk98lin/skcsum.c

Next file: linux/drivers/net/sk98lin/skge.c
Previous file: linux/drivers/net/sk98lin/skaddr.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.6/linux/drivers/net/sk98lin/skcsum.c linux/drivers/net/sk98lin/skcsum.c
@@ -2,16 +2,15 @@
  *
  * Name:	skcsum.c
  * Project:	GEnesis, PCI Gigabit Ethernet Adapter
- * Version:	$Revision: 1.7 $
- * Date:	$Date: 2000/06/29 13:17:05 $
+ * Version:	$Revision: 1.8 $
+ * Date:	$Date: 2001/02/06 11:15:36 $
  * Purpose:	Store/verify Internet checksum in send/receive packets.
  *
  ******************************************************************************/
 
 /******************************************************************************
  *
- *	(C)Copyright 1998-2000 SysKonnect,
- *	a business unit of Schneider & Koch & Co. Datensysteme GmbH.
+ *	(C)Copyright 1998-2001 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
@@ -27,6 +26,9 @@
  * History:
  *
  *	$Log: skcsum.c,v $
+ *	Revision 1.8  2001/02/06 11:15:36  rassmann
+ *	Supporting two nets on dual-port adapters.
+ *	
  *	Revision 1.7  2000/06/29 13:17:05  rassmann
  *	Corrected reception of a packet with UDP checksum == 0 (which means there
  *	is no UDP checksum).
@@ -63,7 +65,7 @@
 
 #ifndef lint
 static const char SysKonnectFileId[] = "@(#)"
-	"$Id: skcsum.c,v 1.7 2000/06/29 13:17:05 rassmann Exp $"
+	"$Id: skcsum.c,v 1.8 2001/02/06 11:15:36 rassmann Exp $"
 	" (C) SysKonnect.";
 #endif	/* !lint */
 
@@ -249,7 +251,8 @@
 void SkCsGetSendInfo(
 SK_AC				*pAc,			/* Adapter context struct. */
 void				*pIpHeader,		/* IP header. */
-SKCS_PACKET_INFO	*pPacketInfo)	/* Packet information struct. */
+SKCS_PACKET_INFO	*pPacketInfo,	/* Packet information struct. */
+int					NetNumber)		/* Net number */
 {
 	/* Internet Header Version found in IP header. */
 	unsigned InternetHeaderVersion;
@@ -291,7 +294,7 @@
 			("Tx: Unknown Internet Header Version %u.\n",
 			InternetHeaderVersion));
 		pPacketInfo->ProtocolFlags = 0;
-		pAc->Csum.ProtoStats[SKCS_PROTO_STATS_IP].TxUnableCts++;
+		pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
 		return;
 	}
 
@@ -312,13 +315,13 @@
 		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[SKCS_PROTO_STATS_IP].TxUnableCts++;
+		pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
 		return;
 	}
 
 	/* This is an IPv4 frame with a header of valid length. */
 
-	pAc->Csum.ProtoStats[SKCS_PROTO_STATS_IP].TxOkCts++;
+	pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxOkCts++;
 
 	/* Check if we should calculate the IP header checksum. */
 
@@ -347,14 +350,14 @@
 		/* TCP/IP frame. */
 		ProtocolFlags &= SKCS_PROTO_TCP | SKCS_PROTO_IP;
 		NextLevelProtoStats =
-			&pAc->Csum.ProtoStats[SKCS_PROTO_STATS_TCP];
+			&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[SKCS_PROTO_STATS_UDP];
+			&pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
 	}
 	else {
 		/*
@@ -475,7 +478,8 @@
 SK_AC		*pAc,		/* Adapter context struct. */
 void		*pIpHeader,	/* IP header. */
 unsigned	Checksum1,	/* Hardware checksum 1. */
-unsigned	Checksum2)	/* Hardware checksum 2. */
+unsigned	Checksum2,	/* Hardware checksum 2. */
+int			NetNumber)	/* Net number */
 {
 	/* Internet Header Version found in IP header. */
 	unsigned InternetHeaderVersion;
@@ -522,7 +526,7 @@
 		SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_RX,
 			("Rx: Unknown Internet Header Version %u.\n",
 			InternetHeaderVersion));
-		pAc->Csum.ProtoStats[SKCS_PROTO_STATS_IP].RxUnableCts++;
+		pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxUnableCts++;
 		return (SKCS_STATUS_UNKNOWN_IP_VERSION);
 	}
 
@@ -541,7 +545,7 @@
 	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[SKCS_PROTO_STATS_IP].RxErrCts++;
+		pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxErrCts++;
 		return (SKCS_STATUS_IP_CSUM_ERROR);
 	}
 
@@ -590,7 +594,7 @@
 		SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL);
 
 	if (IpHeaderChecksum != 0xFFFF) {
-		pAc->Csum.ProtoStats[SKCS_PROTO_STATS_IP].RxErrCts++;
+		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);
@@ -609,15 +613,17 @@
 	 * frame.
 	 */
 
-	if ((pAc->Csum.ReceiveFlags & SKCS_PROTO_TCP) != 0 &&
+	if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_TCP) != 0 &&
 		NextLevelProtocol == SKCS_PROTO_ID_TCP) {
 		/* TCP/IP frame. */
-		NextLevelProtoStats = &pAc->Csum.ProtoStats[SKCS_PROTO_STATS_TCP];
+		NextLevelProtoStats =
+			&pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_TCP];
 	}
-	else if ((pAc->Csum.ReceiveFlags & SKCS_PROTO_UDP) != 0 &&
+	else if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_UDP) != 0 &&
 		NextLevelProtocol == SKCS_PROTO_ID_UDP) {
 		/* UDP/IP frame. */
-		NextLevelProtoStats = &pAc->Csum.ProtoStats[SKCS_PROTO_STATS_UDP];
+		NextLevelProtoStats =
+			&pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
 	}
 	else {
 		/*
@@ -755,11 +761,12 @@
 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. */
+unsigned	*pChecksum2Offset,	/* Offset for hardware checksum 2. */
+int			NetNumber)
 {
 	/* Save the receive flags. */
 
-	pAc->Csum.ReceiveFlags = ReceiveFlags;
+	pAc->Csum.ReceiveFlags[NetNumber] = ReceiveFlags;
 
 	/* First checksum start offset is the IP header. */
 	*pChecksum1Offset = SKCS_MAC_HEADER_SIZE;
@@ -871,23 +878,26 @@
 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[0];
+		ProtoIndex = (int)Param.Para32[0];
+		NetNumber = (int)Param.Para32[1];
 		if (ProtoIndex < 0) {	/* Clear for all protocols. */
-			memset(&pAc->Csum.ProtoStats[0], 0,
-				sizeof(pAc->Csum.ProtoStats));
+			memset(&pAc->Csum.ProtoStats[NetNumber][0], 0,
+				sizeof(pAc->Csum.ProtoStats[NetNumber]));
 		}
 		else {					/* Clear for individual protocol. */
-			memset(&pAc->Csum.ProtoStats[ProtoIndex], 0,
-				sizeof(pAc->Csum.ProtoStats[ProtoIndex]));
+			memset(&pAc->Csum.ProtoStats[NetNumber][ProtoIndex], 0,
+				sizeof(pAc->Csum.ProtoStats[NetNumber][ProtoIndex]));
 		}
 		break;
 	default:

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