Commit ae490785 authored by Mirko Lindner's avatar Mirko Lindner Committed by Stephen Hemminger

[netdrvr sk98lin] small fixes

Patch 3/5 (Update to version 6.17)
* Add: Removed SkNumber and SkDoDiv
* Add: Counter output as (unsigned long long)
parent 7e031571
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
* *
* Name: skproc.c * Name: skproc.c
* Project: GEnesis, PCI Gigabit Ethernet Adapter * Project: GEnesis, PCI Gigabit Ethernet Adapter
* Version: $Revision: 1.8 $ * Version: $Revision: 1.2 $
* Date: $Date: 2003/06/27 14:41:42 $ * Date: $Date: 2003/08/12 16:45:29 $
* Purpose: Funktions to display statictic data * Purpose: Funktions to display statictic data
* *
******************************************************************************/ ******************************************************************************/
...@@ -28,6 +28,13 @@ ...@@ -28,6 +28,13 @@
* History: * History:
* *
* $Log: skproc.c,v $ * $Log: skproc.c,v $
* Revision 1.2 2003/08/12 16:45:29 mlindner
* Add: Removed SkNumber and SkDoDiv
* Add: Counter output as (unsigned long long)
*
* Revision 1.1 2003/07/18 13:39:57 rroesler
* Fix: Re-enter after CVS crash
*
* Revision 1.8 2003/06/27 14:41:42 rroesler * Revision 1.8 2003/06/27 14:41:42 rroesler
* Corrected compiler-warning kernel 2.2 * Corrected compiler-warning kernel 2.2
* *
...@@ -86,23 +93,9 @@ ...@@ -86,23 +93,9 @@
#include "h/skdrv1st.h" #include "h/skdrv1st.h"
#include "h/skdrv2nd.h" #include "h/skdrv2nd.h"
#define ZEROPAD 1 /* pad with zero */
#define SIGN 2 /* unsigned/signed long */
#define PLUS 4 /* show plus */
#define SPACE 8 /* space if plus */
#define LEFT 16 /* left justified */
#define SPECIALX 32 /* 0x */
#define LARGE 64
extern struct net_device *SkGeRootDev; extern struct net_device *SkGeRootDev;
extern char * SkNumber(
char * str,
long long num,
int base,
int size,
int precision,
int type);
int sk_proc_read(char *buffer, int sk_proc_read(char *buffer,
char **buffer_location, char **buffer_location,
...@@ -137,7 +130,6 @@ void *data) ...@@ -137,7 +130,6 @@ void *data)
int i; int i;
DEV_NET *pNet; DEV_NET *pNet;
SK_AC *pAC; SK_AC *pAC;
char test_buf[100];
char sens_msg[50]; char sens_msg[50];
unsigned long Flags; unsigned long Flags;
unsigned int Size; unsigned int Size;
...@@ -247,13 +239,11 @@ void *data) ...@@ -247,13 +239,11 @@ void *data)
"\nReceive statistics\n\n"); "\nReceive statistics\n\n");
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Received bytes %s\n", "Received bytes %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxOctetsOkCts, (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
10,0,-1,0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Received packets %s\n", "Received packets %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxOkCts, (unsigned long long) pPnmiStat->StatRxOkCts);
10,0,-1,0));
#if 0 #if 0
if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC &&
pAC->HWRevision < 12) { pAC->HWRevision < 12) {
...@@ -267,71 +257,56 @@ void *data) ...@@ -267,71 +257,56 @@ void *data)
pPnmiStat->StatRxTooLongCts; pPnmiStat->StatRxTooLongCts;
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Receive errors %s\n", "Receive errors %Ld\n",
SkNumber(test_buf, pPnmiStruct->InErrorsCts, (unsigned long long) pPnmiStruct->InErrorsCts);
10,0,-1,0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Receive dropped %s\n", "Receive dropped %Ld\n",
SkNumber(test_buf, pPnmiStruct->RxNoBufCts, (unsigned long long) pPnmiStruct->RxNoBufCts);
10,0,-1,0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Received multicast %s\n", "Received multicast %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxMulticastOkCts, (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
10,0,-1,0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Receive error types\n"); "Receive error types\n");
len += sprintf(buffer + len, len += sprintf(buffer + len,
" length %s\n", " length %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxRuntCts, (unsigned long long) pPnmiStat->StatRxRuntCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" buffer overflow %s\n", " buffer overflow %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxFifoOverflowCts, (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" bad crc %s\n", " bad crc %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxFcsCts, (unsigned long long) pPnmiStat->StatRxFcsCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" framing %s\n", " framing %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxFramingCts, (unsigned long long) pPnmiStat->StatRxFramingCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" missed frames %s\n", " missed frames %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxMissedCts, (unsigned long long) pPnmiStat->StatRxMissedCts);
10, 0, -1, 0));
if (pNet->Mtu > 1500) if (pNet->Mtu > 1500)
pPnmiStat->StatRxTooLongCts = 0; pPnmiStat->StatRxTooLongCts = 0;
len += sprintf(buffer + len, len += sprintf(buffer + len,
" too long %s\n", " too long %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxTooLongCts, (unsigned long long) pPnmiStat->StatRxTooLongCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" carrier extension %s\n", " carrier extension %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxCextCts, (unsigned long long) pPnmiStat->StatRxCextCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" too short %s\n", " too short %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxShortsCts, (unsigned long long) pPnmiStat->StatRxShortsCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" symbol %s\n", " symbol %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxSymbolCts, (unsigned long long) pPnmiStat->StatRxSymbolCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" LLC MAC size %s\n", " LLC MAC size %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxIRLengthCts, (unsigned long long) pPnmiStat->StatRxIRLengthCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" carrier event %s\n", " carrier event %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxCarrierCts, (unsigned long long) pPnmiStat->StatRxCarrierCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" jabber %s\n", " jabber %Ld\n",
SkNumber(test_buf, pPnmiStat->StatRxJabberCts, (unsigned long long) pPnmiStat->StatRxJabberCts);
10, 0, -1, 0));
/*Transmit statistics */ /*Transmit statistics */
...@@ -339,42 +314,34 @@ void *data) ...@@ -339,42 +314,34 @@ void *data)
"\nTransmit statistics\n\n"); "\nTransmit statistics\n\n");
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Transmited bytes %s\n", "Transmited bytes %Ld\n",
SkNumber(test_buf, pPnmiStat->StatTxOctetsOkCts, (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
10,0,-1,0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Transmited packets %s\n", "Transmited packets %Ld\n",
SkNumber(test_buf, pPnmiStat->StatTxOkCts, (unsigned long long) pPnmiStat->StatTxOkCts);
10,0,-1,0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Transmit errors %s\n", "Transmit errors %Ld\n",
SkNumber(test_buf, pPnmiStat->StatTxSingleCollisionCts, (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
10,0,-1,0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Transmit dropped %s\n", "Transmit dropped %Ld\n",
SkNumber(test_buf, pPnmiStruct->TxNoBufCts, (unsigned long long) pPnmiStruct->TxNoBufCts);
10,0,-1,0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Transmit collisions %s\n", "Transmit collisions %Ld\n",
SkNumber(test_buf, pPnmiStat->StatTxSingleCollisionCts, (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
10,0,-1,0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
"Transmit error types\n"); "Transmit error types\n");
len += sprintf(buffer + len, len += sprintf(buffer + len,
" excessive collision %ld\n", " excessive collision %ld\n",
pAC->stats.tx_aborted_errors); pAC->stats.tx_aborted_errors);
len += sprintf(buffer + len, len += sprintf(buffer + len,
" carrier %s\n", " carrier %Ld\n",
SkNumber(test_buf, pPnmiStat->StatTxCarrierCts, (unsigned long long) pPnmiStat->StatTxCarrierCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" fifo underrun %s\n", " fifo underrun %Ld\n",
SkNumber(test_buf, pPnmiStat->StatTxFifoUnderrunCts, (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" heartbeat %s\n", " heartbeat %Ld\n",
SkNumber(test_buf, pPnmiStat->StatTxCarrierCts, (unsigned long long) pPnmiStat->StatTxCarrierCts);
10, 0, -1, 0));
len += sprintf(buffer + len, len += sprintf(buffer + len,
" window %ld\n", " window %ld\n",
pAC->stats.tx_window_errors); pAC->stats.tx_window_errors);
...@@ -396,139 +363,3 @@ void *data) ...@@ -396,139 +363,3 @@ void *data)
} }
/*****************************************************************************
*
* SkDoDiv - convert 64bit number
*
* Description:
* This function "converts" a long long number.
*
* Returns:
* remainder of division
*/
static long SkDoDiv (long long Dividend, int Divisor, long long *pErg)
{
long Rest;
long long Ergebnis;
long Akku;
Akku = Dividend >> 32;
Ergebnis = ((long long) (Akku / Divisor)) << 32;
Rest = Akku % Divisor ;
Akku = Rest << 16;
Akku |= ((Dividend & 0xFFFF0000) >> 16);
Ergebnis += ((long long) (Akku / Divisor)) << 16;
Rest = Akku % Divisor ;
Akku = Rest << 16;
Akku |= (Dividend & 0xFFFF);
Ergebnis += (Akku / Divisor);
Rest = Akku % Divisor ;
*pErg = Ergebnis;
return (Rest);
}
#if 0
#define do_div(n,base) ({ \
long long __res; \
__res = ((unsigned long long) n) % (unsigned) base; \
n = ((unsigned long long) n) / (unsigned) base; \
__res; })
#endif
/*****************************************************************************
*
* SkNumber - Print results
*
* Description:
* This function converts a long long number into a string.
*
* Returns:
* number as string
*/
char * SkNumber(char * str, long long num, int base, int size, int precision
,int type)
{
char c,sign,tmp[66], *strorg = str;
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return 0;
c = (type & ZEROPAD) ? '0' : ' ';
sign = 0;
if (type & SIGN) {
if (num < 0) {
sign = '-';
num = -num;
size--;
} else if (type & PLUS) {
sign = '+';
size--;
} else if (type & SPACE) {
sign = ' ';
size--;
}
}
if (type & SPECIALX) {
if (base == 16)
size -= 2;
else if (base == 8)
size--;
}
i = 0;
if (num == 0)
tmp[i++]='0';
else while (num != 0)
tmp[i++] = digits[SkDoDiv(num,base, &num)];
if (i > precision)
precision = i;
size -= precision;
if (!(type&(ZEROPAD+LEFT)))
while(size-->0)
*str++ = ' ';
if (sign)
*str++ = sign;
if (type & SPECIALX) {
if (base==8)
*str++ = '0';
else if (base==16) {
*str++ = '0';
*str++ = digits[33];
}
}
if (!(type & LEFT))
while (size-- > 0)
*str++ = c;
while (i < precision--)
*str++ = '0';
while (i-- > 0)
*str++ = tmp[i];
while (size-- > 0)
*str++ = ' ';
str[0] = '\0';
return strorg;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment