Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Use ETHER_*_LEN constants from <net/if_ether.h> i...



details:   https://anonhg.NetBSD.org/src/rev/ba5476e56a02
branches:  trunk
changeset: 467562:ba5476e56a02
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Mar 25 23:19:16 1999 +0000

description:
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.  Subtract ETHER_CRC_LEN as necessary to get the same values
for these constants as were previously defined locally.

diffstat:

 sys/dev/ic/mb86960.c    |  29 +++++++++++++++++------------
 sys/dev/ic/mb86960var.h |   7 +------
 2 files changed, 18 insertions(+), 18 deletions(-)

diffs (115 lines):

diff -r 2e74a88e3858 -r ba5476e56a02 sys/dev/ic/mb86960.c
--- a/sys/dev/ic/mb86960.c      Thu Mar 25 23:16:37 1999 +0000
+++ b/sys/dev/ic/mb86960.c      Thu Mar 25 23:19:16 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mb86960.c,v 1.31 1999/02/28 17:10:53 explorer Exp $    */
+/*     $NetBSD: mb86960.c,v 1.32 1999/03/25 23:19:16 thorpej Exp $     */
 
 /*
  * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@@ -747,7 +747,8 @@
                 * (i.e., minimum packet sized) packets rapidly.  An 8KB
                 * buffer can hold 130 blocks of 62 bytes long...
                 */
-               if (sc->txb_free < ETHER_MAX_LEN + FE_DATA_LEN_LEN) {
+               if (sc->txb_free <
+                   (ETHER_MAX_LEN - ETHER_CRC_LEN) + FE_DATA_LEN_LEN) {
                        /* No room. */
                        goto indicate_active;
                }
@@ -1034,12 +1035,13 @@
                 *
                 * Is this statement true?  FIXME.
                 */
-               if (len > ETHER_MAX_LEN || len < ETHER_HDR_SIZE) {
+               if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN) ||
+                   len < ETHER_HDR_LEN) {
 #if FE_DEBUG >= 2
                        log(LOG_WARNING,
                            "%s: received a %s packet? (%u bytes)\n",
                            sc->sc_dev.dv_xname,
-                           len < ETHER_HDR_SIZE ? "partial" : "big", len);
+                           len < ETHER_HDR_LEN ? "partial" : "big", len);
 #endif
                        ifp->if_ierrors++;
                        mb86960_droppacket(sc);
@@ -1053,7 +1055,7 @@
                 * if it carries data for upper layer.
                 */
 #if FE_DEBUG >= 2
-               if (len < ETHER_MIN_LEN) {
+               if (len < (ETHER_MIN_LEN - ETHER_CRC_LEN)) {
                        log(LOG_WARNING,
                            "%s: received a short packet? (%u bytes)\n",
                            sc->sc_dev.dv_xname, len);
@@ -1461,10 +1463,11 @@
         * it should be a bug of upper layer.  We just ignore it.
         * ... Partial (too short) packets, neither.
         */
-       if (totlen > ETHER_MAX_LEN || totlen < ETHER_HDR_SIZE) {
+       if (totlen > (ETHER_MAX_LEN - ETHER_CRC_LEN) ||
+           totlen < ETHER_HDR_LEN) {
                log(LOG_ERR, "%s: got a %s packet (%u bytes) to send\n",
                    sc->sc_dev.dv_xname,
-                   totlen < ETHER_HDR_SIZE ? "partial" : "big", totlen);
+                   totlen < ETHER_HDR_LEN ? "partial" : "big", totlen);
                sc->sc_ec.ec_if.if_oerrors++;
                return;
        }
@@ -1478,20 +1481,22 @@
         * packet in the transmission buffer, we can skip the
         * padding process.  It may gain performance slightly.  FIXME.
         */
-       bus_space_write_2(bst, bsh, FE_BMPR8, max(totlen, ETHER_MIN_LEN));
+       bus_space_write_2(bst, bsh, FE_BMPR8,
+           max(totlen, (ETHER_MIN_LEN - ETHER_CRC_LEN)));
 
        /*
         * Update buffer status now.
         * Truncate the length up to an even number, since we use outw().
         */
        totlen = (totlen + 1) & ~1;
-       sc->txb_free -= FE_DATA_LEN_LEN + max(totlen, ETHER_MIN_LEN);
+       sc->txb_free -= FE_DATA_LEN_LEN +
+           max(totlen, (ETHER_MIN_LEN - ETHER_CRC_LEN));
        sc->txb_count++;
 
 #if FE_DELAYED_PADDING
        /* Postpone the packet padding if necessary. */
-       if (totlen < ETHER_MIN_LEN)
-               sc->txb_padding = ETHER_MIN_LEN - totlen;
+       if (totlen < (ETHER_MIN_LEN - ETHER_CRC_LEN))
+               sc->txb_padding = (ETHER_MIN_LEN - ETHER_CRC_LEN) - totlen;
 #endif
 
        /*
@@ -1540,7 +1545,7 @@
        /*
         * Pad the packet to the minimum length if necessary.
         */
-       len = (ETHER_MIN_LEN >> 1) - (totlen >> 1);
+       len = ((ETHER_MIN_LEN - ETHER_CRC_LEN) >> 1) - (totlen >> 1);
        while (--len >= 0)
                bus_space_write_2(bst, bsh, FE_BMPR8, 0);
 #endif
diff -r 2e74a88e3858 -r ba5476e56a02 sys/dev/ic/mb86960var.h
--- a/sys/dev/ic/mb86960var.h   Thu Mar 25 23:16:37 1999 +0000
+++ b/sys/dev/ic/mb86960var.h   Thu Mar 25 23:19:16 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mb86960var.h,v 1.23 1998/11/18 18:34:52 thorpej Exp $  */
+/*     $NetBSD: mb86960var.h,v 1.24 1999/03/25 23:19:16 thorpej Exp $  */
 
 /*
  * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@@ -178,11 +178,6 @@
                    struct ifmediareq *));
 };
 
-/* Ethernet constants.  To be defined in if_ehter.h?  FIXME. */
-#define ETHER_MIN_LEN  60      /* with header, without CRC. */
-#define ETHER_MAX_LEN  1514    /* with header, without CRC. */
-#define ETHER_HDR_SIZE 14      /* src addr, dst addr, and data type. */
-
 /*
  * Fe driver specific constants which relate to 86960/86965.
  */



Home | Main Index | Thread Index | Old Index