|
|
1.1 ! root 1: ! 2: /* if_enp: ACC VERSAbus Ethernet controler (v/eiu) */ ! 3: /* */ ! 4: ! 5: #include <stdio.h> ! 6: #include <sys/types.h> ! 7: #include <sys/socket.h> ! 8: #include <sys/errno.h> ! 9: ! 10: #include <net/if.h> ! 11: #include <net/netisr.h> ! 12: #include <net/route.h> ! 13: #include <netinet/in.h> ! 14: #include <netinet/ip_var.h> ! 15: #include <netinet/if_ether.h> ! 16: ! 17: #include <machine/mtpr.h> ! 18: #include <tahoeif/if_enp.h> ! 19: #include <sys/buf.h> ! 20: #include <vba/vbavar.h> ! 21: #include <nlist.h> ! 22: #include "nstat.h" ! 23: ! 24: struct nlist enpnl[] = { ! 25: # define N_ENPSOFTC 0 ! 26: { "_enp_softc"}, ! 27: # define N_STATADDR 1 ! 28: { "_stat_addr"}, ! 29: # define N_NUMENP 2 ! 30: { "_numenp" }, ! 31: { "" }, ! 32: }; ! 33: ! 34: #define NENP 6 ! 35: struct enp_softc enpsoftc[NENP]; ! 36: ! 37: extern int kmem; ! 38: extern int vmem; ! 39: extern char *system; ! 40: char *vmemf = "/dev/vmem"; ! 41: int vmem; ! 42: ENPSTAT enp_stats; ! 43: ! 44: #define STARTENP() sin = (struct sockaddr_in *)&(f->if_addr);\ ! 45: if (sin->sin_addr.s_addr == 0) { \ ! 46: printf("enpstat: enp%d is not configured.\n", kk);\ ! 47: continue; \ ! 48: } ! 49: #define ENDENP putchar('\n'); ! 50: ! 51: enpstat(unit, from) ! 52: int unit, from; ! 53: { ! 54: int i, j, num; ! 55: ! 56: ENPSTAT *s; ! 57: long stat_addr[NENP]; /* addrs of stat areas */ ! 58: struct enp_softc *p; ! 59: struct ifnet *f; ! 60: struct sockaddr_in *sin; ! 61: ! 62: off_t numdev_memaddr; ! 63: off_t stat_memaddr; ! 64: off_t enpsoftc_memaddr; ! 65: ! 66: int kk; ! 67: static int getvm = 0; ! 68: ! 69: if (!getvm) { ! 70: nlist(system, enpnl); ! 71: getvm = 1; ! 72: } ! 73: ! 74: numdev_memaddr = enpnl[N_NUMENP].n_value; ! 75: stat_memaddr = enpnl[N_STATADDR].n_value; /* versa bus address */ ! 76: enpsoftc_memaddr = enpnl[N_ENPSOFTC].n_value; ! 77: ! 78: if (numdev_memaddr==0 || stat_memaddr == 0 || enpsoftc_memaddr == 0) { ! 79: printf("enpstat: symbol not in namelist\n"); ! 80: return(1); ! 81: } ! 82: ! 83: klseek(kmem, numdev_memaddr, 0); ! 84: read(kmem, (char *)&num, sizeof (num)); ! 85: ! 86: if ((num < 0) || (num > NENP)) { ! 87: printf("enpstat: invalid number of devices (num = %d)\n", num); ! 88: return(1); ! 89: } ! 90: if (num == 0) { ! 91: printf("enpstat: no enp (driver) installed.\n"); ! 92: return(1); ! 93: } ! 94: ! 95: if (unit > num) ! 96: if (unit == WILDCARD) ! 97: unit = 0; /* print all */ ! 98: else { ! 99: printf("enpstat: invalid device no.(unit=%d)\n", unit); ! 100: return; ! 101: } ! 102: else ! 103: num = unit + 1; /* print only once for dev-> unit */ ! 104: ! 105: if (!from) { ! 106: klseek(kmem, enpsoftc_memaddr, 0); ! 107: read(kmem, enpsoftc, sizeof(struct enp_softc)*num); ! 108: } ! 109: ! 110: klseek(kmem, stat_memaddr, 0); ! 111: read(kmem, (char *)stat_addr, sizeof(long)*num); ! 112: ! 113: vmem = open(vmemf, 0); ! 114: if (vmem < 0) { ! 115: printf("enpstat: cannot open "); ! 116: perror(vmemf); ! 117: return(1); ! 118: } ! 119: ! 120: if (from) ! 121: return(0); /* don't output */ ! 122: ! 123: for (kk = unit; kk < num; kk++) { ! 124: lseek(vmem, (off_t)stat_addr[kk], 0); ! 125: read(vmem, (char *)&enp_stats, sizeof(ENPSTAT)); ! 126: p = &enpsoftc[kk]; ! 127: f = &p->es_if; ! 128: s = (ENPSTAT *)&enp_stats; ! 129: ! 130: printf("--------------------------------\n"); ! 131: STARTENP(); ! 132: printf("Device Name: %s%d", "enp", f->if_unit); ! 133: printf("\t\tEthernet Station Address: "); ! 134: for (j=0; j<6; j++) ! 135: printf("%x.",p->es_enaddr[j] & 0xff); ! 136: printf(" "); ! 137: ENDENP ! 138: ! 139: lseek(vmem, (off_t)stat_addr[kk], 0); ! 140: read(vmem, (char *)&enp_stats, sizeof(ENPSTAT)); ! 141: ! 142: STARTENP(); ! 143: printf("Transmit:%20d", s->e_xmit_successful); ! 144: printf("\tReceive:%25d", s->e_rcv_successful); ! 145: ENDENP ! 146: ! 147: STARTENP(); ! 148: printf("Multiple Retries:%12d", s->e_mult_retry); ! 149: printf("\tMissed Packets(out of buf):%6d", ! 150: s->e_rcv_missed); ! 151: ENDENP ! 152: ! 153: STARTENP(); ! 154: printf("Single Retries:%14d", s->e_one_retry); ! 155: printf("\tCRC Errors:%22d", s->e_crc_err); ! 156: ENDENP ! 157: ! 158: STARTENP(); ! 159: printf("Retry Failures:%14d", s->e_fail_retry); ! 160: printf("\tFraming Errors:%18d", s->e_frame_err); ! 161: ENDENP ! 162: ! 163: STARTENP(); ! 164: printf("Late Collision:%14d", s->e_late_coll); ! 165: ENDENP ! 166: ! 167: STARTENP(); ! 168: printf("No. of Collisions:%11d", ! 169: s->e_mult_retry+s->e_one_retry+s->e_late_coll); ! 170: ENDENP ! 171: ! 172: STARTENP(); ! 173: printf("Deferals on Xmit:%12d", s->e_deferrals); ! 174: ENDENP ! 175: ! 176: STARTENP(); ! 177: printf("Transmit BUF Errors*:%8d", s->e_xmit_buff_err); ! 178: printf("\tReceive BUF Errors*:%13d", s->e_rcv_buff_err); ! 179: ENDENP ! 180: ! 181: STARTENP(); ! 182: printf("Underrun Errors:%13d", s->e_silo_underrun); ! 183: printf("\tOverrun Errors:%18d", s->e_silo_overrun); ! 184: ENDENP ! 185: ! 186: STARTENP(); ! 187: printf("Carriers Losses*:%12d", s->e_lost_carrier); ! 188: ENDENP ! 189: ! 190: STARTENP(); ! 191: printf("Babbling Xmitter Errors:%5d", s->e_babble); ! 192: ENDENP ! 193: ! 194: STARTENP(); ! 195: printf("Memory Errors* (Xmit):%7d", s->e_xmit_mem_err); ! 196: printf("\tMemory Errors* (Recv):%11d", ! 197: s->e_rcv_mem_err); ! 198: ENDENP ! 199: printf("--------------------------------\n"); ! 200: printf("* Fatal Errors. Controller has to be reloaded.\n"); ! 201: } ! 202: close(vmem); ! 203: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.