File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / usr / src / etc / nstat / acestat.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:24:30 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

/*								*/
/*	if_ace: ACC VERSAbus Ethernet controler (v/eiu)		*/
/*								*/



#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/errno.h>

#include <net/if.h>
#include <net/netisr.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/ip_var.h>
#include <netinet/if_ether.h>

#include <machine/mtpr.h>
#include <tahoeif/if_acereg.h>
#include <sys/buf.h>
#include <vba/vbavar.h>
#include <nlist.h>
#include "nstat.h"

struct	nlist	acenl[] = {
#			define	N_ACEINFO	0
	{ "_aceinfo" },
#			define	N_ACESTAT	1
	{ "_ace_softc"},
#			define	N_NUMACE	2
	{ "_numace" },
	{ "" },
};

#define NACE		6
#define	NUMACESOFTC	10
struct	ace_softc	acesoftc[NUMACESOFTC];

extern	int	kmem;
extern	char	*system;

#define	STARTACE(X) sin = (struct sockaddr_in *)&(f->if_addr);\
		    if (sin->sin_addr.s_addr == 0) { \
			    printf("acestat: ace%d is not configured.\n", kk); \
			    continue; \
		    } \
		    printf("%-25s",X);
#define ENDACE 	    putchar('\n');

acestat(unit)
int	unit;
{
	int	i, j , kk;

	struct	ace_softc	*p;
	struct	ifnet		*f;
	struct	ace_stats	*s;
	struct	vba_device	*aceinfo;
	struct	sockaddr_in	*sin;

	off_t	numdev_memaddr;
	off_t	stat_memaddr;
	off_t	aceinfo_memaddr;
	int	num;

	struct vba_device ui;
	struct acedevice acdev; 
	short txidx, rcidx;

	static	int	getvm = 0;

	if (!getvm) {
		nlist(system, acenl);
		getvm = 1;
	}

	numdev_memaddr = acenl[N_NUMACE].n_value;
	stat_memaddr = acenl[N_ACESTAT].n_value;
	aceinfo_memaddr = acenl[N_ACEINFO].n_value;

	if (numdev_memaddr==0 || stat_memaddr == 0 || aceinfo_memaddr==0) {
		printf("acestat: symbol not in namelist\n");
		return;
	}

	klseek(kmem, numdev_memaddr, 0);
	read(kmem, &num, sizeof (num));

	if ((num < 0) || (num > NACE)) {
		printf("acestat: invalid number of devices (num = %d)\n", num);
		return;
	}

	if (num == 0) {
		printf("acestat: no ace (driver) installed.\n");
		return;
	}

	if (unit > num)
		if (unit == WILDCARD)
			unit = 0;	/* print all	*/
		else {
			printf("acestat: invalid device no.(unit=%d)\n", unit);
			return;
		}
	else
		num = unit + 1;		/* print one	*/

	klseek(kmem, stat_memaddr, 0);
	read(kmem, acesoftc, sizeof (struct ace_softc)*num);

	klseek(kmem, aceinfo_memaddr, 0);
	read(kmem, (char *)aceinfo, sizeof (aceinfo));
	
	for (kk = unit; kk < num; kk++) {
		p = &acesoftc[kk];
		f = &p->is_if;
		s = &p->is_stats;

		printf("--------------------------------\n");
		STARTACE("Device Name:");
			printf("%s%-12d", "ace", f->if_unit);
		ENDACE

		STARTACE("Ethernet Station Address:");
			for (j=0; j<6; j++)
				printf("%x.",p->is_addr[j] & 0xff);
			printf("   ");
		ENDACE

		STARTACE("Recv Overruns:");
			printf("%-15d", s->rx_overruns);
		ENDACE

		STARTACE("Recv Underruns:");
			printf("%-15d", s->rx_underruns);
		ENDACE

		STARTACE("Recv Alignment Errors:");
			printf("%-15d", s->rx_align_errors);
		ENDACE

		STARTACE("Recv CRC Errors:");
			printf("%-15d", s->rx_crc_errors);
		ENDACE
	
		STARTACE("Xmit Ethernet Retries:");
			printf("%-15d", s->tx_retries);
		ENDACE

		STARTACE("Xmit Discarded:");
			printf("%-15d", s->tx_discarded);
		ENDACE

		STARTACE("Xmit Busy Segments:");
			printf("%-15d", s->tx_busy);
		ENDACE
	}
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.