|
|
1.1 ! root 1: /* */ ! 2: /* if_ace: ACC VERSAbus Ethernet controler (v/eiu) */ ! 3: /* */ ! 4: ! 5: ! 6: ! 7: #include <stdio.h> ! 8: #include <sys/types.h> ! 9: #include <sys/socket.h> ! 10: #include <sys/errno.h> ! 11: ! 12: #include <net/if.h> ! 13: #include <net/netisr.h> ! 14: #include <net/route.h> ! 15: #include <netinet/in.h> ! 16: #include <netinet/ip_var.h> ! 17: #include <netinet/if_ether.h> ! 18: ! 19: #include <machine/mtpr.h> ! 20: #include <tahoeif/if_acereg.h> ! 21: #include <sys/buf.h> ! 22: #include <vba/vbavar.h> ! 23: #include <nlist.h> ! 24: #include "nstat.h" ! 25: ! 26: struct nlist acenl[] = { ! 27: # define N_ACEINFO 0 ! 28: { "_aceinfo" }, ! 29: # define N_ACESTAT 1 ! 30: { "_ace_softc"}, ! 31: # define N_NUMACE 2 ! 32: { "_numace" }, ! 33: { "" }, ! 34: }; ! 35: ! 36: #define NACE 6 ! 37: #define NUMACESOFTC 10 ! 38: struct ace_softc acesoftc[NUMACESOFTC]; ! 39: ! 40: extern int kmem; ! 41: extern char *system; ! 42: ! 43: #define STARTACE(X) sin = (struct sockaddr_in *)&(f->if_addr);\ ! 44: if (sin->sin_addr.s_addr == 0) { \ ! 45: printf("acestat: ace%d is not configured.\n", kk); \ ! 46: continue; \ ! 47: } \ ! 48: printf("%-25s",X); ! 49: #define ENDACE putchar('\n'); ! 50: ! 51: acestat(unit) ! 52: int unit; ! 53: { ! 54: int i, j , kk; ! 55: ! 56: struct ace_softc *p; ! 57: struct ifnet *f; ! 58: struct ace_stats *s; ! 59: struct vba_device *aceinfo; ! 60: struct sockaddr_in *sin; ! 61: ! 62: off_t numdev_memaddr; ! 63: off_t stat_memaddr; ! 64: off_t aceinfo_memaddr; ! 65: int num; ! 66: ! 67: struct vba_device ui; ! 68: struct acedevice acdev; ! 69: short txidx, rcidx; ! 70: ! 71: static int getvm = 0; ! 72: ! 73: if (!getvm) { ! 74: nlist(system, acenl); ! 75: getvm = 1; ! 76: } ! 77: ! 78: numdev_memaddr = acenl[N_NUMACE].n_value; ! 79: stat_memaddr = acenl[N_ACESTAT].n_value; ! 80: aceinfo_memaddr = acenl[N_ACEINFO].n_value; ! 81: ! 82: if (numdev_memaddr==0 || stat_memaddr == 0 || aceinfo_memaddr==0) { ! 83: printf("acestat: symbol not in namelist\n"); ! 84: return; ! 85: } ! 86: ! 87: klseek(kmem, numdev_memaddr, 0); ! 88: read(kmem, &num, sizeof (num)); ! 89: ! 90: if ((num < 0) || (num > NACE)) { ! 91: printf("acestat: invalid number of devices (num = %d)\n", num); ! 92: return; ! 93: } ! 94: ! 95: if (num == 0) { ! 96: printf("acestat: no ace (driver) installed.\n"); ! 97: return; ! 98: } ! 99: ! 100: if (unit > num) ! 101: if (unit == WILDCARD) ! 102: unit = 0; /* print all */ ! 103: else { ! 104: printf("acestat: invalid device no.(unit=%d)\n", unit); ! 105: return; ! 106: } ! 107: else ! 108: num = unit + 1; /* print one */ ! 109: ! 110: klseek(kmem, stat_memaddr, 0); ! 111: read(kmem, acesoftc, sizeof (struct ace_softc)*num); ! 112: ! 113: klseek(kmem, aceinfo_memaddr, 0); ! 114: read(kmem, (char *)aceinfo, sizeof (aceinfo)); ! 115: ! 116: for (kk = unit; kk < num; kk++) { ! 117: p = &acesoftc[kk]; ! 118: f = &p->is_if; ! 119: s = &p->is_stats; ! 120: ! 121: printf("--------------------------------\n"); ! 122: STARTACE("Device Name:"); ! 123: printf("%s%-12d", "ace", f->if_unit); ! 124: ENDACE ! 125: ! 126: STARTACE("Ethernet Station Address:"); ! 127: for (j=0; j<6; j++) ! 128: printf("%x.",p->is_addr[j] & 0xff); ! 129: printf(" "); ! 130: ENDACE ! 131: ! 132: STARTACE("Recv Overruns:"); ! 133: printf("%-15d", s->rx_overruns); ! 134: ENDACE ! 135: ! 136: STARTACE("Recv Underruns:"); ! 137: printf("%-15d", s->rx_underruns); ! 138: ENDACE ! 139: ! 140: STARTACE("Recv Alignment Errors:"); ! 141: printf("%-15d", s->rx_align_errors); ! 142: ENDACE ! 143: ! 144: STARTACE("Recv CRC Errors:"); ! 145: printf("%-15d", s->rx_crc_errors); ! 146: ENDACE ! 147: ! 148: STARTACE("Xmit Ethernet Retries:"); ! 149: printf("%-15d", s->tx_retries); ! 150: ENDACE ! 151: ! 152: STARTACE("Xmit Discarded:"); ! 153: printf("%-15d", s->tx_discarded); ! 154: ENDACE ! 155: ! 156: STARTACE("Xmit Busy Segments:"); ! 157: printf("%-15d", s->tx_busy); ! 158: ENDACE ! 159: } ! 160: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.