From owner-p4-projects@FreeBSD.ORG Tue Feb 3 21:41:14 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6B4571065679; Tue, 3 Feb 2009 21:41:14 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 11AD5106566C for ; Tue, 3 Feb 2009 21:41:14 +0000 (UTC) (envelope-from marius@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id F329C8FC1C for ; Tue, 3 Feb 2009 21:41:13 +0000 (UTC) (envelope-from marius@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n13LfD7l088592 for ; Tue, 3 Feb 2009 21:41:13 GMT (envelope-from marius@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n13LfD1w088590 for perforce@freebsd.org; Tue, 3 Feb 2009 21:41:13 GMT (envelope-from marius@freebsd.org) Date: Tue, 3 Feb 2009 21:41:13 GMT Message-Id: <200902032141.n13LfD1w088590@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marius@freebsd.org using -f From: Marius Strobl To: Perforce Change Reviews Cc: Subject: PERFORCE change 157114 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Feb 2009 21:41:16 -0000 http://perforce.freebsd.org/chv.cgi?CH=157114 Change 157114 by marius@flak on 2009/02/03 21:40:36 Add glue for FreeBSD < 800016. Affected files ... .. //depot/projects/usiii/dev/cas/if_cas.c#2 edit .. //depot/projects/usiii/dev/cas/if_casvar.h#2 edit Differences ... ==== //depot/projects/usiii/dev/cas/if_cas.c#2 (text+ko) ==== @@ -812,8 +812,8 @@ sc->sc_rxcptr = 0; /* - * Initialize the receive descriptor rings. We leave the - * the second ring zeroed as we don't actually use it. + * Initialize the first receive descriptor ring. We leave + * the second one zeroed as we don't actually use it. */ for (i = 0; i < CAS_NRXDESC; i++) CAS_INIT_RXDESC(sc, i, i); @@ -1620,8 +1620,13 @@ refcount_acquire(&rxds->rxds_refcount); MEXTADD(m, (caddr_t)rxds->rxds_buf + CAS_GET(word2, CAS_RC2_HDR_OFF) * 256 + - ETHER_ALIGN, len, cas_free, sc, - (void *)(uintptr_t)idx, 0, EXT_NET_DRV); + ETHER_ALIGN, len, cas_free, +#if __FreeBSD_version < 800016 + rxds, +#else + sc, (void *)(uintptr_t)idx, +#endif + 0, EXT_NET_DRV); if ((m->m_flags & M_EXT) == 0) { m_freem(m); m = NULL; @@ -1663,8 +1668,13 @@ refcount_acquire(&rxds->rxds_refcount); MEXTADD(m, (caddr_t)rxds->rxds_buf + CAS_GET(word1, CAS_RC1_DATA_OFF) + - ETHER_ALIGN, len, cas_free, sc, - (void *)(uintptr_t)idx, 0, EXT_NET_DRV); + ETHER_ALIGN, len, cas_free, +#if __FreeBSD_version < 800016 + rxds, +#else + sc, (void *)(uintptr_t)idx, +#endif + 0, EXT_NET_DRV); if ((m->m_flags & M_EXT) == 0) { m_freem(m); m = NULL; @@ -1719,10 +1729,18 @@ cas_free(void *arg1, void *arg2) { struct cas_rxdsoft *rxds; - struct cas_softc *sc = arg1; - u_int idx = (uintptr_t)arg2; + struct cas_softc *sc; + u_int idx; +#if __FreeBSD_version < 800016 + rxds = arg2; + sc = rxds->rxds_sc; + idx = rxds->rxds_idx; +#else + sc = arg1; + idx = (uintptr_t)arg2; rxds = &sc->sc_rxdsoft[idx]; +#endif if (refcount_release(&rxds->rxds_refcount) == 0) return; @@ -1735,7 +1753,7 @@ cas_add_rxdesc(struct cas_softc *sc, u_int idx) { - CAS_INIT_RXDESC(sc, sc->sc_rxdptr, idx); + CAS_UPDATE_RXDESC(sc, sc->sc_rxdptr, idx); /* * Update the RX kick register. This register has to point to the ==== //depot/projects/usiii/dev/cas/if_casvar.h#2 (text+ko) ==== @@ -33,10 +33,6 @@ #ifndef _IF_CASVAR_H #define _IF_CASVAR_H -#include -#include -#include - /* * The page size is configurable, but needs to be at least 8k (the * default) in order to also support jumbo buffers. @@ -129,6 +125,10 @@ void *rxds_buf; /* receive buffer */ bus_dmamap_t rxds_dmamap; /* our DMA map */ bus_addr_t rxds_paddr; /* physical address of the segment */ +#if __FreeBSD_version < 800016 + struct cas_softc *rxds_sc; /* softc pointer */ + u_int rxds_idx; /* our index */ +#endif u_int rxds_refcount; /* hardware + mbuf references */ }; @@ -195,8 +195,8 @@ u_int sc_txnext; /* next ready TX descriptor */ u_int sc_txwin; /* TX desc. since last TX intr. */ - struct cas_txsq sc_txfreeq; /* free TX descsofts */ - struct cas_txsq sc_txdirtyq; /* dirty TX descsofts */ + struct cas_txsq sc_txfreeq; /* free software TX descriptors */ + struct cas_txsq sc_txdirtyq; /* dirty software TX descriptors */ u_int sc_rxcptr; /* next ready RX completion */ u_int sc_rxdptr; /* next ready RX descriptor */ @@ -228,18 +228,33 @@ #define CAS_CDSYNC(sc, ops) \ bus_dmamap_sync((sc)->sc_cdmatag, (sc)->sc_cddmamap, (ops)); +#define __CAS_UPDATE_RXDESC(rxd, rxds, s) \ +do { \ + \ + refcount_init(&(rxds)->rxds_refcount, 1); \ + (rxd)->cd_buf_ptr = htole64((rxds)->rxds_paddr); \ + KASSERT((s) < CAS_RD_BUF_INDEX_MASK >> CAS_RD_BUF_INDEX_SHFT, \ + ("%s: RX buffer index too large!", __func__)); \ + (rxd)->cd_flags = \ + htole64((uint64_t)((s) << CAS_RD_BUF_INDEX_SHFT)); \ +} while (0) + +#define CAS_UPDATE_RXDESC(sc, d, s) \ + __CAS_UPDATE_RXDESC(&(sc)->sc_rxdescs[(d)], \ + &(sc)->sc_rxdsoft[(s)], (s)) + +#if __FreeBSD_version < 800016 #define CAS_INIT_RXDESC(sc, d, s) \ do { \ - struct cas_rxdsoft *__rxds = &sc->sc_rxdsoft[(s)]; \ - struct cas_desc *__rxd = &sc->sc_rxdescs[(d)]; \ + struct cas_rxdsoft *__rxds = &(sc)->sc_rxdsoft[(s)]; \ \ - refcount_init(&__rxds->rxds_refcount, 1); \ - __rxd->cd_buf_ptr = htole64(__rxds->rxds_paddr); \ - KASSERT(s < CAS_RD_BUF_INDEX_MASK >> CAS_RD_BUF_INDEX_SHFT, \ - ("%s: RX buffer index too large!", __func__)); \ - __rxd->cd_flags = \ - htole64((uint64_t)(s << CAS_RD_BUF_INDEX_SHFT)); \ + __rxds->rxds_sc = (sc); \ + __rxds->rxds_idx = (s); \ + __CAS_UPDATE_RXDESC(&(sc)->sc_rxdescs[(d)], __rxds, (s)); \ } while (0) +#else +#define CAS_INIT_RXDESC(sc, d, s) CAS_UPDATE_RXDESC(sc, d, s) +#endif #define CAS_LOCK_INIT(_sc, _name) \ mtx_init(&(_sc)->sc_mtx, _name, MTX_NETWORK_LOCK, MTX_DEF)