| 744 | } |
| 745 | |
| 746 | static int |
| 747 | awg_newbuf_rx(struct awg_softc *sc, int index) |
| 748 | { |
| 749 | struct mbuf *m; |
| 750 | bus_dma_segment_t seg; |
| 751 | bus_dmamap_t map; |
| 752 | int nsegs; |
| 753 | |
| 754 | m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); |
| 755 | if (m == NULL) |
| 756 | return (ENOBUFS); |
| 757 | |
| 758 | m->m_pkthdr.len = m->m_len = m->m_ext.ext_size; |
| 759 | m_adj(m, ETHER_ALIGN); |
| 760 | |
| 761 | if (bus_dmamap_load_mbuf_sg(sc->rx.buf_tag, sc->rx.buf_spare_map, |
| 762 | m, &seg, &nsegs, BUS_DMA_NOWAIT) != 0) { |
| 763 | m_freem(m); |
| 764 | return (ENOBUFS); |
| 765 | } |
| 766 | |
| 767 | if (sc->rx.buf_map[index].mbuf != NULL) { |
| 768 | bus_dmamap_sync(sc->rx.buf_tag, sc->rx.buf_map[index].map, |
| 769 | BUS_DMASYNC_POSTREAD); |
| 770 | bus_dmamap_unload(sc->rx.buf_tag, sc->rx.buf_map[index].map); |
| 771 | } |
| 772 | map = sc->rx.buf_map[index].map; |
| 773 | sc->rx.buf_map[index].map = sc->rx.buf_spare_map; |
| 774 | sc->rx.buf_spare_map = map; |
| 775 | bus_dmamap_sync(sc->rx.buf_tag, sc->rx.buf_map[index].map, |
| 776 | BUS_DMASYNC_PREREAD); |
| 777 | |
| 778 | sc->rx.buf_map[index].mbuf = m; |
| 779 | awg_setup_rxdesc(sc, index, seg.ds_addr); |
| 780 | |
| 781 | return (0); |
| 782 | } |
| 783 | |
| 784 | static void |
| 785 | awg_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) |
no test coverage detected