Source-Changes-HG archive

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

[src/netbsd-1-6]: src/sys/dev/pci Pull up revision 1.34 (requested by tron in...



details:   https://anonhg.NetBSD.org/src/rev/240544db8ab9
branches:  netbsd-1-6
changeset: 530287:240544db8ab9
user:      grant <grant%NetBSD.org@localhost>
date:      Mon Jun 16 13:20:21 2003 +0000

description:
Pull up revision 1.34 (requested by tron in ticket #1249):

FreeBSD fix for problems reported (to FreeBSD) with 16-bit accesses
to 32-bit device registers. Add (untested) NetBSD fix for big-endian hosts.
>From FreeBSD versions:
        if_bge.c:       1.26 and 1.27
        if_bgereg.h: 1.12

FreeBSD (MFC) comment:

MFC:  Avoid 16-bit accesses to device memory.  Use volatile where
appropriate in referencing device memory.  Parenthesize BGE_HOSTADDR
define properly.

diffstat:

 sys/dev/pci/if_bge.c |  65 +++++++++++++++++++++++----------------------------
 1 files changed, 29 insertions(+), 36 deletions(-)

diffs (145 lines):

diff -r 91b87d07c0f9 -r 240544db8ab9 sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c      Mon Jun 16 13:18:36 2003 +0000
+++ b/sys/dev/pci/if_bge.c      Mon Jun 16 13:20:21 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bge.c,v 1.29.2.3 2003/06/16 13:04:42 grant Exp $    */
+/*     $NetBSD: if_bge.c,v 1.29.2.4 2003/06/16 13:20:21 grant Exp $    */
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -886,8 +886,7 @@
        struct bge_softc *sc;
 {
        int i;
-       struct bge_rcb *rcb;
-       struct bge_rcb_opaque *rcbo;
+       volatile struct bge_rcb *rcb;
 
        for (i = 0; i < BGE_JUMBO_RX_RING_CNT; i++) {
                if (bge_newbuf_jumbo(sc, i, NULL) == ENOBUFS)
@@ -897,9 +896,8 @@
        sc->bge_jumbo = i - 1;
 
        rcb = &sc->bge_rdata->bge_info.bge_jumbo_rx_rcb;
-       rcbo = (struct bge_rcb_opaque *)rcb;
-       rcb->bge_flags = 0;
-       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_MAXLEN_FLAGS, rcbo->bge_reg2);
+       rcb->bge_maxlen_flags = 0;
+       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_MAXLEN_FLAGS, rcb->bge_maxlen_flags);
 
        CSR_WRITE_4(sc, BGE_MBX_RX_JUMBO_PROD_LO, sc->bge_jumbo);
 
@@ -1258,8 +1256,7 @@
 bge_blockinit(sc)
        struct bge_softc *sc;
 {
-       struct bge_rcb          *rcb;
-       struct bge_rcb_opaque   *rcbo;
+       volatile struct bge_rcb         *rcb;
        bus_size_t              rcb_addr;
        int                     i;
        struct ifnet            *ifp = &sc->ethercom.ec_if;
@@ -1342,17 +1339,15 @@
        rcb = &sc->bge_rdata->bge_info.bge_std_rx_rcb;
        bge_set_hostaddr(&rcb->bge_hostaddr,
            BGE_RING_DMA_ADDR(sc, bge_rx_std_ring));
-       rcb->bge_max_len = BGE_MAX_FRAMELEN;
+       rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(BGE_MAX_FRAMELEN, 0);
        if (sc->bge_extram)
                rcb->bge_nicaddr = BGE_EXT_STD_RX_RINGS;
        else
                rcb->bge_nicaddr = BGE_STD_RX_RINGS;
-       rcb->bge_flags = 0;
-       rcbo = (struct bge_rcb_opaque *)rcb;
-       CSR_WRITE_4(sc, BGE_RX_STD_RCB_HADDR_HI, rcbo->bge_reg0);
-       CSR_WRITE_4(sc, BGE_RX_STD_RCB_HADDR_LO, rcbo->bge_reg1);
-       CSR_WRITE_4(sc, BGE_RX_STD_RCB_MAXLEN_FLAGS, rcbo->bge_reg2);
-       CSR_WRITE_4(sc, BGE_RX_STD_RCB_NICADDR, rcbo->bge_reg3);
+       CSR_WRITE_4(sc, BGE_RX_STD_RCB_HADDR_HI, rcb->bge_hostaddr.bge_addr_hi);
+       CSR_WRITE_4(sc, BGE_RX_STD_RCB_HADDR_LO, rcb->bge_hostaddr.bge_addr_lo);
+       CSR_WRITE_4(sc, BGE_RX_STD_RCB_MAXLEN_FLAGS, rcb->bge_maxlen_flags);
+       CSR_WRITE_4(sc, BGE_RX_STD_RCB_NICADDR, rcb->bge_nicaddr);
 
        /*
         * Initialize the jumbo RX ring control block
@@ -1364,24 +1359,23 @@
        rcb = &sc->bge_rdata->bge_info.bge_jumbo_rx_rcb;
        bge_set_hostaddr(&rcb->bge_hostaddr,
            BGE_RING_DMA_ADDR(sc, bge_rx_jumbo_ring));
-       rcb->bge_max_len = BGE_MAX_FRAMELEN;
+       rcb->bge_maxlen_flags = 
+          BGE_RCB_MAXLEN_FLAGS(BGE_MAX_FRAMELEN, BGE_RCB_FLAG_RING_DISABLED);
        if (sc->bge_extram)
                rcb->bge_nicaddr = BGE_EXT_JUMBO_RX_RINGS;
        else
                rcb->bge_nicaddr = BGE_JUMBO_RX_RINGS;
-       rcb->bge_flags = BGE_RCB_FLAG_RING_DISABLED;
-
-       rcbo = (struct bge_rcb_opaque *)rcb;
-       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_HADDR_HI, rcbo->bge_reg0);
-       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_HADDR_LO, rcbo->bge_reg1);
-       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_MAXLEN_FLAGS, rcbo->bge_reg2);
-       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_NICADDR, rcbo->bge_reg3);
+
+       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_HADDR_HI, rcb->bge_hostaddr.bge_addr_hi);
+       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_HADDR_LO, rcb->bge_hostaddr.bge_addr_lo);
+       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_MAXLEN_FLAGS, rcb->bge_maxlen_flags);
+       CSR_WRITE_4(sc, BGE_RX_JUMBO_RCB_NICADDR, rcb->bge_nicaddr);
 
        /* Set up dummy disabled mini ring RCB */
        rcb = &sc->bge_rdata->bge_info.bge_mini_rx_rcb;
-       rcb->bge_flags = BGE_RCB_FLAG_RING_DISABLED;
-       rcbo = (struct bge_rcb_opaque *)rcb;
-       CSR_WRITE_4(sc, BGE_RX_MINI_RCB_MAXLEN_FLAGS, rcbo->bge_reg2);
+       rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(0,
+           BGE_RCB_FLAG_RING_DISABLED);
+       CSR_WRITE_4(sc, BGE_RX_MINI_RCB_MAXLEN_FLAGS, rcb->bge_maxlen_flags);
 
        bus_dmamap_sync(sc->bge_dmatag, sc->bge_ring_map,
            offsetof(struct bge_ring_data, bge_info), sizeof (struct bge_gib),
@@ -1402,9 +1396,8 @@
         */
        rcb_addr = BGE_MEMWIN_START + BGE_SEND_RING_RCB;
        for (i = 0; i < BGE_TX_RINGS_EXTSSRAM_MAX; i++) {
-               RCB_WRITE_2(sc, rcb_addr, bge_flags,
-                           BGE_RCB_FLAG_RING_DISABLED);
-               RCB_WRITE_2(sc, rcb_addr, bge_max_len, 0);
+               RCB_WRITE_4(sc, rcb_addr, bge_maxlen_flags,
+                   BGE_RCB_MAXLEN_FLAGS(0,BGE_RCB_FLAG_RING_DISABLED));
                RCB_WRITE_4(sc, rcb_addr, bge_nicaddr, 0);
                rcb_addr += sizeof(struct bge_rcb);
        }
@@ -1416,17 +1409,17 @@
        RCB_WRITE_4(sc, rcb_addr, bge_hostaddr.bge_addr_lo, taddr.bge_addr_lo);
        RCB_WRITE_4(sc, rcb_addr, bge_nicaddr,
                    BGE_NIC_TXRING_ADDR(0, BGE_TX_RING_CNT));
-       RCB_WRITE_2(sc, rcb_addr, bge_max_len, BGE_TX_RING_CNT);
-       RCB_WRITE_2(sc, rcb_addr, bge_flags, 0);
+       RCB_WRITE_4(sc, rcb_addr, bge_maxlen_flags, 
+           BGE_RCB_MAXLEN_FLAGS(BGE_TX_RING_CNT, 0));
 
        /* Disable all unused RX return rings */
        rcb_addr = BGE_MEMWIN_START + BGE_RX_RETURN_RING_RCB;
        for (i = 0; i < BGE_RX_RINGS_MAX; i++) {
                RCB_WRITE_4(sc, rcb_addr, bge_hostaddr.bge_addr_hi, 0);
                RCB_WRITE_4(sc, rcb_addr, bge_hostaddr.bge_addr_lo, 0);
-               RCB_WRITE_2(sc, rcb_addr, bge_flags,
-                           BGE_RCB_FLAG_RING_DISABLED);
-               RCB_WRITE_2(sc, rcb_addr, bge_max_len, BGE_RETURN_RING_CNT);
+               RCB_WRITE_4(sc, rcb_addr, bge_maxlen_flags, 
+                           BGE_RCB_MAXLEN_FLAGS(BGE_RETURN_RING_CNT,
+                                     BGE_RCB_FLAG_RING_DISABLED));
                RCB_WRITE_4(sc, rcb_addr, bge_nicaddr, 0);
                CSR_WRITE_4(sc, BGE_MBX_RX_CONS0_LO +
                    (i * (sizeof(u_int64_t))), 0);
@@ -1449,8 +1442,8 @@
        RCB_WRITE_4(sc, rcb_addr, bge_hostaddr.bge_addr_hi, taddr.bge_addr_hi);
        RCB_WRITE_4(sc, rcb_addr, bge_hostaddr.bge_addr_lo, taddr.bge_addr_lo);
        RCB_WRITE_4(sc, rcb_addr, bge_nicaddr, 0x00000000);
-       RCB_WRITE_2(sc, rcb_addr, bge_max_len, BGE_RETURN_RING_CNT);
-       RCB_WRITE_2(sc, rcb_addr, bge_flags, 0);
+       RCB_WRITE_4(sc, rcb_addr, bge_maxlen_flags,
+           BGE_RCB_MAXLEN_FLAGS(BGE_RETURN_RING_CNT,0));
 
        /* Set random backoff seed for TX */
        CSR_WRITE_4(sc, BGE_TX_RANDOM_BACKOFF,



Home | Main Index | Thread Index | Old Index