Wed Jan 29 05:57:21 2020 UTC ()
Adopt <net/if_stats.h>.


(thorpej)
diff -r1.34 -r1.35 src/sys/dev/qbus/if_de.c
diff -r1.24 -r1.25 src/sys/dev/qbus/if_qt.c

cvs diff -r1.34 -r1.35 src/sys/dev/qbus/if_de.c (expand / switch to unified diff)

--- src/sys/dev/qbus/if_de.c 2018/06/26 06:48:02 1.34
+++ src/sys/dev/qbus/if_de.c 2020/01/29 05:57:21 1.35
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_de.c,v 1.34 2018/06/26 06:48:02 msaitoh Exp $ */ 1/* $NetBSD: if_de.c,v 1.35 2020/01/29 05:57:21 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1989 Regents of the University of California. 4 * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -62,27 +62,27 @@ @@ -62,27 +62,27 @@
62/* 62/*
63 * DEC DEUNA interface 63 * DEC DEUNA interface
64 * 64 *
65 * Lou Salkind 65 * Lou Salkind
66 * New York University 66 * New York University
67 * 67 *
68 * Rewritten by Ragge 30 April 2000 to match new world. 68 * Rewritten by Ragge 30 April 2000 to match new world.
69 * 69 *
70 * TODO: 70 * TODO:
71 * timeout routine (get statistics) 71 * timeout routine (get statistics)
72 */ 72 */
73 73
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.34 2018/06/26 06:48:02 msaitoh Exp $"); 75__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.35 2020/01/29 05:57:21 thorpej Exp $");
76 76
77#include "opt_inet.h" 77#include "opt_inet.h"
78 78
79#include <sys/param.h> 79#include <sys/param.h>
80#include <sys/systm.h> 80#include <sys/systm.h>
81#include <sys/mbuf.h> 81#include <sys/mbuf.h>
82#include <sys/buf.h> 82#include <sys/buf.h>
83#include <sys/protosw.h> 83#include <sys/protosw.h>
84#include <sys/socket.h> 84#include <sys/socket.h>
85#include <sys/ioctl.h> 85#include <sys/ioctl.h>
86#include <sys/errno.h> 86#include <sys/errno.h>
87#include <sys/syslog.h> 87#include <sys/syslog.h>
88#include <sys/device.h> 88#include <sys/device.h>
@@ -470,39 +470,39 @@ deintr(void *arg) @@ -470,39 +470,39 @@ deintr(void *arg)
470 470
471 /* 471 /*
472 * Poll transmit ring and check status. 472 * Poll transmit ring and check status.
473 * Be careful about loopback requests. 473 * Be careful about loopback requests.
474 * Then free buffer space and check for 474 * Then free buffer space and check for
475 * more transmit requests. 475 * more transmit requests.
476 */ 476 */
477 dc = sc->sc_dedata; 477 dc = sc->sc_dedata;
478 for ( ; sc->sc_nxmit > 0; sc->sc_nxmit--) { 478 for ( ; sc->sc_nxmit > 0; sc->sc_nxmit--) {
479 rp = &dc->dc_xrent[sc->sc_xindex]; 479 rp = &dc->dc_xrent[sc->sc_xindex];
480 if (rp->r_flags & XFLG_OWN) 480 if (rp->r_flags & XFLG_OWN)
481 break; 481 break;
482 482
483 sc->sc_if.if_opackets++; 483 if_statinc(&sc->sc_if, if_opackets);
484 ifxp = &sc->sc_ifw[sc->sc_xindex]; 484 ifxp = &sc->sc_ifw[sc->sc_xindex];
485 /* check for unusual conditions */ 485 /* check for unusual conditions */
486 if (rp->r_flags & (XFLG_ERRS|XFLG_MTCH|XFLG_ONE|XFLG_MORE)) { 486 if (rp->r_flags & (XFLG_ERRS|XFLG_MTCH|XFLG_ONE|XFLG_MORE)) {
487 if (rp->r_flags & XFLG_ERRS) { 487 if (rp->r_flags & XFLG_ERRS) {
488 /* output error */ 488 /* output error */
489 sc->sc_if.if_oerrors++; 489 if_statinc(&sc->sc_if, if_oerrors);
490 } else if (rp->r_flags & XFLG_ONE) { 490 } else if (rp->r_flags & XFLG_ONE) {
491 /* one collision */ 491 /* one collision */
492 sc->sc_if.if_collisions++; 492 if_statinc(&sc->sc_if, if_collisions);
493 } else if (rp->r_flags & XFLG_MORE) { 493 } else if (rp->r_flags & XFLG_MORE) {
494 /* more than one collision */ 494 /* more than one collision (guess...) */
495 sc->sc_if.if_collisions += 2; /* guess */ 495 if_statadd(&sc->sc_if, if_collisions, 2);
496 } 496 }
497 } 497 }
498 if_ubaend(&sc->sc_ifuba, ifxp); 498 if_ubaend(&sc->sc_ifuba, ifxp);
499 /* check if next transmit buffer also finished */ 499 /* check if next transmit buffer also finished */
500 sc->sc_xindex++; 500 sc->sc_xindex++;
501 if (sc->sc_xindex == NXMT) 501 if (sc->sc_xindex == NXMT)
502 sc->sc_xindex = 0; 502 sc->sc_xindex = 0;
503 } 503 }
504 sc->sc_if.if_flags &= ~IFF_OACTIVE; 504 sc->sc_if.if_flags &= ~IFF_OACTIVE;
505 destart(&sc->sc_if); 505 destart(&sc->sc_if);
506 506
507 if (csr0 & PCSR0_RCBI) { 507 if (csr0 & PCSR0_RCBI) {
508 DE_WLOW(PCSR0_INTE|CMD_PDMD); 508 DE_WLOW(PCSR0_INTE|CMD_PDMD);
@@ -524,33 +524,33 @@ derecv(struct de_softc *sc) @@ -524,33 +524,33 @@ derecv(struct de_softc *sc)
524 struct ifnet *ifp = &sc->sc_if; 524 struct ifnet *ifp = &sc->sc_if;
525 struct de_ring *rp; 525 struct de_ring *rp;
526 struct de_cdata *dc; 526 struct de_cdata *dc;
527 struct mbuf *m; 527 struct mbuf *m;
528 int len; 528 int len;
529 529
530 dc = sc->sc_dedata; 530 dc = sc->sc_dedata;
531 rp = &dc->dc_rrent[sc->sc_rindex]; 531 rp = &dc->dc_rrent[sc->sc_rindex];
532 while ((rp->r_flags & RFLG_OWN) == 0) { 532 while ((rp->r_flags & RFLG_OWN) == 0) {
533 len = (rp->r_lenerr&RERR_MLEN) - ETHER_CRC_LEN; 533 len = (rp->r_lenerr&RERR_MLEN) - ETHER_CRC_LEN;
534 /* check for errors */ 534 /* check for errors */
535 if ((rp->r_flags & (RFLG_ERRS|RFLG_FRAM|RFLG_OFLO|RFLG_CRC)) || 535 if ((rp->r_flags & (RFLG_ERRS|RFLG_FRAM|RFLG_OFLO|RFLG_CRC)) ||
536 (rp->r_lenerr & (RERR_BUFL|RERR_UBTO))) { 536 (rp->r_lenerr & (RERR_BUFL|RERR_UBTO))) {
537 sc->sc_if.if_ierrors++; 537 if_statinc(&sc->sc_if, if_ierrors);
538 goto next; 538 goto next;
539 } 539 }
540 m = if_ubaget(&sc->sc_ifuba, &sc->sc_ifr[sc->sc_rindex], 540 m = if_ubaget(&sc->sc_ifuba, &sc->sc_ifr[sc->sc_rindex],
541 ifp, len); 541 ifp, len);
542 if (m == 0) { 542 if (m == 0) {
543 sc->sc_if.if_ierrors++; 543 if_statinc(&sc->sc_if, if_ierrors);
544 goto next; 544 goto next;
545 } 545 }
546 546
547 if_percpuq_enqueue(ifp->if_percpuq, m); 547 if_percpuq_enqueue(ifp->if_percpuq, m);
548 548
549 /* hang the receive buffer again */ 549 /* hang the receive buffer again */
550next: rp->r_lenerr = 0; 550next: rp->r_lenerr = 0;
551 rp->r_flags = RFLG_OWN; 551 rp->r_flags = RFLG_OWN;
552 552
553 /* check next receive buffer */ 553 /* check next receive buffer */
554 sc->sc_rindex++; 554 sc->sc_rindex++;
555 if (sc->sc_rindex == NRCV) 555 if (sc->sc_rindex == NRCV)
556 sc->sc_rindex = 0; 556 sc->sc_rindex = 0;

cvs diff -r1.24 -r1.25 src/sys/dev/qbus/if_qt.c (expand / switch to unified diff)

--- src/sys/dev/qbus/if_qt.c 2019/10/21 08:22:06 1.24
+++ src/sys/dev/qbus/if_qt.c 2020/01/29 05:57:21 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_qt.c,v 1.24 2019/10/21 08:22:06 msaitoh Exp $ */ 1/* $NetBSD: if_qt.c,v 1.25 2020/01/29 05:57:21 thorpej Exp $ */
2/* 2/*
3 * Copyright (c) 1992 Steven M. Schultz 3 * Copyright (c) 1992 Steven M. Schultz
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products 14 * 3. The name of the author may not be used to endorse or promote products
@@ -70,27 +70,27 @@ @@ -70,27 +70,27 @@
70 * Darned alignment restrictions! 70 * Darned alignment restrictions!
71 * 71 *
72 * A couple of typos were corrected (missing parentheses, reversed 72 * A couple of typos were corrected (missing parentheses, reversed
73 * arguments to printf calls, etc). 73 * arguments to printf calls, etc).
74 * 74 *
75 * 13-Oct-92 -- sms@wlv.iipo.gtegsc.com 75 * 13-Oct-92 -- sms@wlv.iipo.gtegsc.com
76 * Created based on the DELQA-PLUS addendum to DELQA User's Guide. 76 * Created based on the DELQA-PLUS addendum to DELQA User's Guide.
77 * This driver ('qt') is selected at system configuration time. If the 77 * This driver ('qt') is selected at system configuration time. If the
78 * board * is not a DELQA-YM an error message will be printed and the 78 * board * is not a DELQA-YM an error message will be printed and the
79 * interface will not be attached. 79 * interface will not be attached.
80 */ 80 */
81 81
82#include <sys/cdefs.h> 82#include <sys/cdefs.h>
83__KERNEL_RCSID(0, "$NetBSD: if_qt.c,v 1.24 2019/10/21 08:22:06 msaitoh Exp $"); 83__KERNEL_RCSID(0, "$NetBSD: if_qt.c,v 1.25 2020/01/29 05:57:21 thorpej Exp $");
84 84
85#include "opt_inet.h" 85#include "opt_inet.h"
86 86
87#include <sys/param.h> 87#include <sys/param.h>
88#include <sys/systm.h> 88#include <sys/systm.h>
89#include <sys/mbuf.h> 89#include <sys/mbuf.h>
90#include <sys/protosw.h> 90#include <sys/protosw.h>
91#include <sys/socket.h> 91#include <sys/socket.h>
92#include <sys/ioctl.h> 92#include <sys/ioctl.h>
93#include <sys/device.h> 93#include <sys/device.h>
94#include <sys/errno.h> 94#include <sys/errno.h>
95#include <sys/syslog.h> 95#include <sys/syslog.h>
96#include <sys/time.h> 96#include <sys/time.h>
@@ -497,98 +497,94 @@ qtintr(void *arg) @@ -497,98 +497,94 @@ qtintr(void *arg)
497 qtstart(&sc->is_ec.ec_if); 497 qtstart(&sc->is_ec.ec_if);
498 } 498 }
499 499
500/* 500/*
501 * Transmit interrupt service. Only called if there are outstanding transmit 501 * Transmit interrupt service. Only called if there are outstanding transmit
502 * requests which could have completed. The DELQA-YM doesn't provide the 502 * requests which could have completed. The DELQA-YM doesn't provide the
503 * status bits telling the kind (receive, transmit) of interrupt. 503 * status bits telling the kind (receive, transmit) of interrupt.
504*/ 504*/
505 505
506#define BBLMIS (TMD2_BBL|TMD2_MIS) 506#define BBLMIS (TMD2_BBL|TMD2_MIS)
507 507
508void 508void
509qttint(struct qt_softc *sc) 509qttint(struct qt_softc *sc)
510 { 510{
511 struct qt_tring *rp; 511 struct qt_tring *rp;
512 512
513 while (sc->nxmit > 0) 513 while (sc->nxmit > 0) {
514 { 
515 rp = &sc->sc_ib->qc_t[sc->xlast]; 514 rp = &sc->sc_ib->qc_t[sc->xlast];
516 if ((rp->tmd3 & TMD3_OWN) == 0) 515 if ((rp->tmd3 & TMD3_OWN) == 0)
517 break; 516 break;
518 sc->is_if.if_opackets++; 517 if_statinc(&sc->is_if, if_opackets);
519/* 518/*
520 * Collisions don't count as output errors, but babbling and missing packets 519 * Collisions don't count as output errors, but babbling and missing packets
521 * do count as output errors. 520 * do count as output errors.
522*/ 521*/
523 if (rp->tmd2 & TMD2_CER) 522 if (rp->tmd2 & TMD2_CER)
524 sc->is_if.if_collisions++; 523 if_statinc(&sc->is_if, if_collisions);
525 if ((rp->tmd0 & TMD0_ERR1) || 524 if ((rp->tmd0 & TMD0_ERR1) ||
526 ((rp->tmd2 & TMD2_ERR2) && (rp->tmd2 & BBLMIS))) 525 ((rp->tmd2 & TMD2_ERR2) && (rp->tmd2 & BBLMIS))) {
527 { 
528#ifdef QTDEBUG 526#ifdef QTDEBUG
529 char buf[100]; 527 char buf[100];
530 snprintb(buf, sizeof(buf), TMD2_BITS, rp->tmd2); 528 snprintb(buf, sizeof(buf), TMD2_BITS, rp->tmd2);
531 printf("%s: tmd2 %s\n", device_xname(sc->sc_dev), buf); 529 printf("%s: tmd2 %s\n", device_xname(sc->sc_dev), buf);
532#endif 530#endif
533 sc->is_if.if_oerrors++; 531 if_statinc(&sc->is_if, if_oerrors);
534 } 532 }
535 if_ubaend(&sc->sc_ifuba, &sc->sc_ifw[sc->xlast]); 533 if_ubaend(&sc->sc_ifuba, &sc->sc_ifw[sc->xlast]);
536 if (++sc->xlast >= NXMT) 534 if (++sc->xlast >= NXMT)
537 sc->xlast = 0; 535 sc->xlast = 0;
538 sc->nxmit--; 536 sc->nxmit--;
539 } 
540 } 537 }
 538}
541 539
542/* 540/*
543 * Receive interrupt service. Pull packet off the interface and put into 541 * Receive interrupt service. Pull packet off the interface and put into
544 * a mbuf chain for processing later. 542 * a mbuf chain for processing later.
545*/ 543*/
546 544
547void 545void
548qtrint(struct qt_softc *sc) 546qtrint(struct qt_softc *sc)
549{ 547{
550 struct qt_rring *rp; 548 struct qt_rring *rp;
551 struct ifnet *ifp = &sc->is_ec.ec_if; 549 struct ifnet *ifp = &sc->is_ec.ec_if;
552 struct mbuf *m; 550 struct mbuf *m;
553 int len; 551 int len;
554 552
555 while (sc->sc_ib->qc_r[(int)sc->rindex].rmd3 & RMD3_OWN) 553 while (sc->sc_ib->qc_r[(int)sc->rindex].rmd3 & RMD3_OWN)
556 { 554 {
557 rp = &sc->sc_ib->qc_r[(int)sc->rindex]; 555 rp = &sc->sc_ib->qc_r[(int)sc->rindex];
558 if ((rp->rmd0 & (RMD0_STP|RMD0_ENP)) != (RMD0_STP|RMD0_ENP)) 556 if ((rp->rmd0 & (RMD0_STP|RMD0_ENP)) != (RMD0_STP|RMD0_ENP)) {
559 { 
560 printf("%s: chained packet\n", device_xname(sc->sc_dev)); 557 printf("%s: chained packet\n", device_xname(sc->sc_dev));
561 sc->is_if.if_ierrors++; 558 if_statinc(&sc->is_if, if_ierrors);
562 goto rnext; 559 goto rnext;
563 } 560 }
564 len = (rp->rmd1 & RMD1_MCNT) - 4; /* -4 for CRC */ 561 len = (rp->rmd1 & RMD1_MCNT) - 4; /* -4 for CRC */
565 562
566 if ((rp->rmd0 & RMD0_ERR3) || (rp->rmd2 & RMD2_ERR4)) 563 if ((rp->rmd0 & RMD0_ERR3) || (rp->rmd2 & RMD2_ERR4)) {
567 { 
568#ifdef QTDEBUG 564#ifdef QTDEBUG
569 char buf[100]; 565 char buf[100];
570 snprintb(buf, sizeof(buf), RMD0_BITS, rp->rmd0); 566 snprintb(buf, sizeof(buf), RMD0_BITS, rp->rmd0);
571 printf("%s: rmd0 %s\n", device_xname(sc->sc_dev), buf); 567 printf("%s: rmd0 %s\n", device_xname(sc->sc_dev), buf);
572 snprintb(buf, sizeof(buf), RMD2_BITS, rp->rmd2); 568 snprintb(buf, sizeof(buf), RMD2_BITS, rp->rmd2);
573 printf("%s: rmd2 %s\n", device_xname(sc->sc_dev), buf); 569 printf("%s: rmd2 %s\n", device_xname(sc->sc_dev), buf);
574#endif 570#endif
575 sc->is_if.if_ierrors++; 571 if_statinc(&sc->is_if, if_ierrors);
576 goto rnext; 572 goto rnext;
577 } 573 }
578 m = if_ubaget(&sc->sc_ifuba, &sc->sc_ifr[(int)sc->rindex], 574 m = if_ubaget(&sc->sc_ifuba, &sc->sc_ifr[(int)sc->rindex],
579 ifp, len); 575 ifp, len);
580 if (m == 0) { 576 if (m == 0) {
581 sc->is_if.if_ierrors++; 577 if_statinc(&sc->is_if, if_ierrors);
582 goto rnext; 578 goto rnext;
583 } 579 }
584 if_percpuq_enqueue(ifp->if_percpuq, m); 580 if_percpuq_enqueue(ifp->if_percpuq, m);
585rnext: 581rnext:
586 --sc->nrcv; 582 --sc->nrcv;
587 rp->rmd3 = 0; 583 rp->rmd3 = 0;
588 rp->rmd1 = MCLBYTES; 584 rp->rmd1 = MCLBYTES;
589 if (++sc->rindex >= NRCV) 585 if (++sc->rindex >= NRCV)
590 sc->rindex = 0; 586 sc->rindex = 0;
591 } 587 }
592 QT_WCSR(CSR_ARQR, ARQR_RRQ); /* tell device it has buffer */ 588 QT_WCSR(CSR_ARQR, ARQR_RRQ); /* tell device it has buffer */
593 } 589 }
594 590