| @@ -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 | |
508 | void | | 508 | void |
509 | qttint(struct qt_softc *sc) | | 509 | qttint(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 | |
547 | void | | 545 | void |
548 | qtrint(struct qt_softc *sc) | | 546 | qtrint(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); |
585 | rnext: | | 581 | rnext: |
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 | |