diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2014-07-08 05:35:20 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2014-07-08 05:35:20 +0000 |
commit | 4930c61b730e44cdce66c7f71fa9f703fcae2b38 (patch) | |
tree | 69bcdb82287306b3e015c5b2778bccc9790f2f81 /sys/dev/pci/if_oce.c | |
parent | f201a4bbc9d2fe8c3664f8b02ebf1ac13ae5b94e (diff) |
cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.
cut the reporting systat did over to the rxr ioctl.
tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@
Diffstat (limited to 'sys/dev/pci/if_oce.c')
-rw-r--r-- | sys/dev/pci/if_oce.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/sys/dev/pci/if_oce.c b/sys/dev/pci/if_oce.c index 37234120da5..4e08eb2b947 100644 --- a/sys/dev/pci/if_oce.c +++ b/sys/dev/pci/if_oce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_oce.c,v 1.74 2014/01/20 17:21:22 chris Exp $ */ +/* $OpenBSD: if_oce.c,v 1.75 2014/07/08 05:35:18 dlg Exp $ */ /* * Copyright (c) 2012 Mike Belopuhov @@ -279,11 +279,10 @@ struct oce_rq { struct oce_cq * cq; + struct if_rxring rxring; struct oce_pkt_list pkt_list; struct oce_pkt_list pkt_free; - uint32_t pending; - uint32_t rss_cpuid; #ifdef OCE_LRO @@ -831,9 +830,6 @@ oce_attach_ifp(struct oce_softc *sc) IFQ_SET_MAXLEN(&ifp->if_snd, sc->sc_tx_ring_size - 1); IFQ_SET_READY(&ifp->if_snd); - /* oce splits jumbos into 2k chunks... */ - m_clsetwms(ifp, MCLBYTES, 8, sc->sc_rx_ring_size); - ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4; @@ -1063,9 +1059,11 @@ oce_init(void *arg) sc->sc_dev.dv_xname); goto error; } - rq->pending = 0; rq->ring->index = 0; + /* oce splits jumbos into 2k chunks... */ + if_rxr_init(&rq->rxring, 8, rq->nitems); + if (!oce_alloc_rx_bufs(rq)) { printf("%s: failed to allocate rx buffers\n", sc->sc_dev.dv_xname); @@ -1523,7 +1521,7 @@ oce_intr_rq(void *arg) if (ncqe) { oce_arm_cq(cq, ncqe, FALSE); - if (rq->nitems - rq->pending > 1 && !oce_alloc_rx_bufs(rq)) + if (!oce_alloc_rx_bufs(rq)) timeout_add(&sc->sc_rxrefill, 1); } } @@ -1556,7 +1554,7 @@ oce_rxeof(struct oce_rq *rq, struct oce_nic_rx_cqe *cqe) bus_dmamap_sync(sc->sc_dmat, pkt->map, 0, pkt->map->dm_mapsize, BUS_DMASYNC_POSTREAD); bus_dmamap_unload(sc->sc_dmat, pkt->map); - rq->pending--; + if_rxr_put(&rq->rxring, 1); frag_len = (len > rq->fragsize) ? rq->fragsize : len; pkt->mbuf->m_len = frag_len; @@ -1593,9 +1591,6 @@ oce_rxeof(struct oce_rq *rq, struct oce_nic_rx_cqe *cqe) goto exit; } - /* Account for jumbo chains */ - m_cluncount(m, 1); - m->m_pkthdr.rcvif = ifp; #if NVLAN > 0 @@ -1670,7 +1665,7 @@ oce_rxeoc(struct oce_rq *rq, struct oce_nic_rx_cqe *cqe) bus_dmamap_sync(sc->sc_dmat, pkt->map, 0, pkt->map->dm_mapsize, BUS_DMASYNC_POSTREAD); bus_dmamap_unload(sc->sc_dmat, pkt->map); - rq->pending--; + if_rxr_put(&rq->rxring, 1); m_freem(pkt->mbuf); oce_pkt_put(&rq->pkt_free, pkt); } @@ -1758,14 +1753,13 @@ int oce_get_buf(struct oce_rq *rq) { struct oce_softc *sc = rq->sc; - struct ifnet *ifp = &sc->sc_ac.ac_if; struct oce_pkt *pkt; struct oce_nic_rqe *rqe; if ((pkt = oce_pkt_get(&rq->pkt_free)) == NULL) return (0); - pkt->mbuf = MCLGETI(NULL, M_DONTWAIT, ifp, MCLBYTES); + pkt->mbuf = MCLGETI(NULL, M_DONTWAIT, NULL, MCLBYTES); if (pkt->mbuf == NULL) { oce_pkt_put(&rq->pkt_free, pkt); return (0); @@ -1791,7 +1785,6 @@ oce_get_buf(struct oce_rq *rq) rqe = oce_ring_get(rq->ring); rqe->u0.s.frag_pa_hi = ADDR_HI(pkt->map->dm_segs[0].ds_addr); rqe->u0.s.frag_pa_lo = ADDR_LO(pkt->map->dm_segs[0].ds_addr); - rq->pending++; oce_dma_sync(&rq->ring->dma, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); @@ -1806,9 +1799,16 @@ oce_alloc_rx_bufs(struct oce_rq *rq) { struct oce_softc *sc = rq->sc; int i, nbufs = 0; + u_int slots; + + for (slots = if_rxr_get(&rq->rxring, rq->nitems); slots > 0; slots--) { + if (oce_get_buf(rq) == 0) + break; - while (oce_get_buf(rq)) nbufs++; + } + if_rxr_put(&rq->rxring, slots); + if (!nbufs) return (0); for (i = nbufs / OCE_MAX_RQ_POSTS; i > 0; i--) { @@ -2424,7 +2424,7 @@ oce_free_posted_rxbuf(struct oce_rq *rq) pkt->mbuf = NULL; } oce_pkt_put(&rq->pkt_free, pkt); - rq->pending--; + if_rxr_put(&rq->rxring, 1); } } |