MCPcopy Create free account
hub / github.com/F-Stack/f-stack / arge_rx_ring_init

Function arge_rx_ring_init

freebsd/mips/atheros/if_arge.c:2246–2283  ·  view source on GitHub ↗

* Initialize the RX descriptors and allocate mbufs for them. Note that * we arrange the descriptors in a closed ring, so that the last descriptor * points back to the first. */

Source from the content-addressed store, hash-verified

2244 * points back to the first.
2245 */
2246static int
2247arge_rx_ring_init(struct arge_softc *sc)
2248{
2249 struct arge_ring_data *rd;
2250 struct arge_rxdesc *rxd;
2251 bus_addr_t addr;
2252 int i;
2253
2254 sc->arge_cdata.arge_rx_cons = 0;
2255
2256 rd = &sc->arge_rdata;
2257 bzero(rd->arge_rx_ring, sizeof(*rd->arge_rx_ring));
2258 for (i = 0; i < ARGE_RX_RING_COUNT; i++) {
2259 rxd = &sc->arge_cdata.arge_rxdesc[i];
2260 if (rxd->rx_m != NULL) {
2261 device_printf(sc->arge_dev,
2262 "%s: ring[%d] rx_m wasn't free?\n",
2263 __func__,
2264 i);
2265 }
2266 rxd->rx_m = NULL;
2267 rxd->desc = &rd->arge_rx_ring[i];
2268 if (i == ARGE_RX_RING_COUNT - 1)
2269 addr = ARGE_RX_RING_ADDR(sc, 0);
2270 else
2271 addr = ARGE_RX_RING_ADDR(sc, i + 1);
2272 rd->arge_rx_ring[i].next_desc = addr;
2273 if (arge_newbuf(sc, i) != 0) {
2274 return (ENOBUFS);
2275 }
2276 }
2277
2278 bus_dmamap_sync(sc->arge_cdata.arge_rx_ring_tag,
2279 sc->arge_cdata.arge_rx_ring_map,
2280 BUS_DMASYNC_PREWRITE);
2281
2282 return (0);
2283}
2284
2285/*
2286 * Free all the buffers in the RX ring.

Callers 1

arge_init_lockedFunction · 0.85

Calls 4

bzeroFunction · 0.85
device_printfFunction · 0.85
arge_newbufFunction · 0.85
bus_dmamap_syncFunction · 0.50

Tested by

no test coverage detected