Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Second part of PR/46998. The following is taken f...



details:   https://anonhg.NetBSD.org/src/rev/031137edc629
branches:  trunk
changeset: 781976:031137edc629
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Oct 10 22:40:33 2012 +0000

description:
Second part of PR/46998. The following is taken from the PR with a slight
edit from me.

The TX buffer size is not a function of the SEEQ chip, it is an arbitrary
driver threshold, so I've renamed the define accordingly and added a new
one to specify how many buffers are used (in my port I allow multiple
packets to be in flight at once, so have used #ifndef, such that the
makefile can override).

Comment corrected, and make use of the above defines.

Missing delay(1) added, otherwise the 20,000 timeout loop is dependent
on the speed of your processor. Matches ea_stoptx logic now.

The FIFO empty check does nothing if the previous mode was 'read', but is
required before changing the BUFCODE (per 80C04 datasheet page 19,
note [2]). Then the mode is set to write, so a second FIFO empty check is
needed incase the previous mode was read.

Treat m0 as a pointer not an integer.

Remove double write of the NULL packet header. Either do
memset/ea_writebuf or two writes to SEEQ_BUFWIN, but not both.

The calculation of nextpacket (for hdr[]) assumes bufstart = 0, and puts
the packet header pointing in the wrong place when it isn't.

The setting of CFG2_OUTPUT is done in ea_init(), so doing it in ea_rxinit
is duplicated code.

diffstat:

 sys/dev/ic/seeq8005.c |  33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diffs (108 lines):

diff -r 8f47902a23c0 -r 031137edc629 sys/dev/ic/seeq8005.c
--- a/sys/dev/ic/seeq8005.c     Wed Oct 10 22:17:44 2012 +0000
+++ b/sys/dev/ic/seeq8005.c     Wed Oct 10 22:40:33 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: seeq8005.c,v 1.50 2012/10/10 22:17:44 skrll Exp $ */
+/* $NetBSD: seeq8005.c,v 1.51 2012/10/10 22:40:33 skrll Exp $ */
 
 /*
  * Copyright (c) 2000, 2001 Ben Harris
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: seeq8005.c,v 1.50 2012/10/10 22:17:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: seeq8005.c,v 1.51 2012/10/10 22:40:33 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -106,7 +106,12 @@
 #define DPRINTF(f, x)
 #endif
 
-#define        SEEQ_TX_BUFFER_SIZE             0x800           /* (> ETHER_MAX_LEN) */
+#ifndef EA_TX_BUFFER_SIZE
+#define EA_TX_BUFFER_SIZE              0x800           /* (> ETHER_MAX_LEN) */
+#endif
+#ifndef EA_TX_BUFFER_COUNT
+#define EA_TX_BUFFER_COUNT             1               /* (> 0) */
+#endif
 
 #define SEEQ_READ16(sc, iot, ioh, reg)                                 \
        ((sc)->sc_flags & SF_8BIT ?                                     \
@@ -225,12 +230,11 @@
        /*
         * Set up tx and rx buffers.
         *
-        * We use approximately a quarter of the packet memory for TX
+        * We set aside EA_TX_BUFFER_SIZE * EA_TX_BUFFER_COUNT for TX
         * buffers and the rest for RX buffers
         */
-       /* sc->sc_tx_bufs = sc->sc_buffersize / SEEQ_TX_BUFFER_SIZE / 4; */
-       sc->sc_tx_bufs = 1;
-       sc->sc_tx_bufsize = sc->sc_tx_bufs * SEEQ_TX_BUFFER_SIZE;
+       sc->sc_tx_bufs = EA_TX_BUFFER_COUNT;
+       sc->sc_tx_bufsize = sc->sc_tx_bufs * EA_TX_BUFFER_SIZE;
        sc->sc_rx_bufsize = sc->sc_buffersize - sc->sc_tx_bufsize;
        sc->sc_enabled = 0;
 
@@ -443,6 +447,7 @@
        timeout = 20000;
        do {
                status = SEEQ_READ16(sc, iot, ioh, SEEQ_STATUS);
+               delay(1);
        } while ((status & SEEQ_STATUS_RX_ON) && --timeout > 0);
        if (timeout == 0)
                log(LOG_ERR, "%s: timeout waiting for rx termination\n",
@@ -604,6 +609,9 @@
                ea_select_buffer(sc, SEEQ_BUFCODE_LOCAL_MEM);
                SEEQ_WRITE16(sc, iot, ioh, SEEQ_COMMAND,
                    sc->sc_command | SEEQ_CMD_FIFO_WRITE);
+
+               ea_await_fifo_empty(sc);
+
                SEEQ_WRITE16(sc, iot, ioh, SEEQ_DMA_ADDR, addr);
        }
 
@@ -901,7 +909,7 @@
        IFQ_DEQUEUE(&ifp->if_snd, m0);
 
        /* If there's nothing to send, return. */
-       if (!m0) {
+       if (m0 == NULL) {
                ifp->if_flags &= ~IFF_OACTIVE;
                sc->sc_config2 |= SEEQ_CFG2_OUTPUT;
                SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG2, sc->sc_config2);
@@ -968,20 +976,18 @@
        /* Follow it with a NULL packet header */
        memset(hdr, 0, 4);
        ea_writebuf(sc, hdr, bufstart + 4 + len, 4);
-       SEEQ_WRITE16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_BUFWIN, 0x0000);
-       SEEQ_WRITE16(sc, sc->sc_iot, sc->sc_ioh, SEEQ_BUFWIN, 0x0000);
 
        /* Ok we now have a packet len bytes long in our packet buffer */
        DPRINTF(SEEQ_DEBUG_TX, ("ea_writembuf: length=%d\n", len));
 
        /* Write the packet header */
-       nextpacket = len + 4;
+       nextpacket = bufstart + len + 4;
        hdr[0] = (nextpacket >> 8) & 0xff;
        hdr[1] = nextpacket & 0xff;
        hdr[2] = SEEQ_PKTCMD_TX | SEEQ_PKTCMD_DATA_FOLLOWS |
                SEEQ_TXCMD_XMIT_SUCCESS_INT | SEEQ_TXCMD_COLLISION_INT;
        hdr[3] = 0; /* Status byte -- will be updated by hardware. */
-       ea_writebuf(sc, hdr, 0x0000, 4);
+       ea_writebuf(sc, hdr, bufstart, 4);
 
        return len;
 }
@@ -1195,9 +1201,6 @@
                        log(LOG_ERR,
                            "%s: rx packet size error at %04x (len=%d)\n",
                            device_xname(sc->sc_dev), addr, len);
-                       sc->sc_config2 |= SEEQ_CFG2_OUTPUT;
-                       SEEQ_WRITE16(sc, iot, ioh, SEEQ_CONFIG2,
-                                         sc->sc_config2);
                        ea_init(ifp);
                        return;
                }



Home | Main Index | Thread Index | Old Index