NetBSD-Bugs archive

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

Re: kern/47788



The following reply was made to PR kern/47788; it has been noted by GNATS.

From: Robert Sprowson <webpages%sprow.co.uk@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/47788
Date: Thu, 30 May 2013 08:49:50 +0100

 Minor update to patch following testing by Chuck on a big endian 68000, two
 places in the send packet function were reversing the data bytes.
 
 --- smc91cxx_new.c     Thu Apr 25 06:49:32 2013
 +++ smc91cxx_len.c     Thu May 30 08:45:20 2013
 @@ -652,13 +652,12 @@
         */
        for (len = 0; m != NULL; m = m->m_next)
                len += m->m_len;
 -      pad = (len & 1);
  
        /*
         * We drop packets that are too large.  Perhaps we should
         * truncate them instead?
         */
 -      if ((len + pad) > (ETHER_MAX_LEN - ETHER_CRC_LEN)) {
 +      if (len > (ETHER_MAX_LEN - ETHER_CRC_LEN)) {
                printf("%s: large packet discarded\n", 
device_xname(sc->sc_dev));
                ifp->if_oerrors++;
                IFQ_DEQUEUE(&ifp->if_snd, m);
 @@ -666,6 +665,7 @@
                goto readcheck;
        }
  
 +      pad = 0;
  #ifdef SMC91CXX_SW_PAD
        /*
         * Not using hardware padding; pad to ETHER_MIN_LEN.
 @@ -745,24 +745,17 @@
        IFQ_DEQUEUE(&ifp->if_snd, m);
  
        /*
 -       * Push the packet out to the card.
 +       * Push the packet out to the card.  The copying function only does 
whole
 +       * words and returns the straggling byte (if any).
         */
        oddbyte = smc91cxx_copy_tx_frame(sc, m);
  
  #ifdef SMC91CXX_SW_PAD
 -#ifdef SMC91CXX_NO_BYTE_WRITE
 -#if BYTE_ORDER == LITTLE_ENDIAN
        if (pad > 1 && (pad & 1)) {
                bus_space_write_2(bst, bsh, DATA_REG_W, oddbyte << 0);
                oddbyte = 0;
 +              pad -= 1;
        }
 -#else
 -      if (pad > 1 && (pad & 1)) {
 -              bus_space_write_2(bst, bsh, DATA_REG_W, oddbyte << 8);
 -              oddbyte = 0;
 -      }
 -#endif
 -#endif
  
        /*
         * Push out padding.
 @@ -773,23 +766,13 @@
        }
  #endif
  
 -#ifdef SMC91CXX_NO_BYTE_WRITE
        /*
         * Push out control byte and unused packet byte.  The control byte
 -       * is 0, meaning the packet is even lengthed and no special
 +       * denotes whether this is an odd or even length packet, and that no
 special
         * CRC handling is necessary.
         */
 -#if BYTE_ORDER == LITTLE_ENDIAN
        bus_space_write_2(bst, bsh, DATA_REG_W,
 -          oddbyte | (pad ? (CTLB_ODD << 8) : 0));
 -#else
 -      bus_space_write_2(bst, bsh, DATA_REG_W,
 -          (oddbyte << 8) | (pad ? CTLB_ODD : 0));
 -#endif
 -#else
 -      if (pad)
 -              bus_space_write_1(bst, bsh, DATA_REG_B, 0);
 -#endif
 +          oddbyte | ((length & 1) ? (CTLB_ODD << 8) : 0));
  
        /*
         * Enable transmit interrupts and let the chip go.  Set a watchdog
 @@ -892,10 +875,7 @@
                        panic("smc91cxx_copy_tx_frame: p != lim");
  #endif
        }
 -#ifndef SMC91CXX_NO_BYTE_WRITE
 -      if (leftover)
 -              bus_space_write_1(bst, bsh, DATA_REG_B, dbuf);
 -#endif
 +
        return dbuf;
  }
 



Home | Main Index | Thread Index | Old Index