| 790 | } |
| 791 | |
| 792 | static int |
| 793 | awg_setup_dma(device_t dev) |
| 794 | { |
| 795 | struct awg_softc *sc; |
| 796 | int error, i; |
| 797 | |
| 798 | sc = device_get_softc(dev); |
| 799 | |
| 800 | /* Setup TX ring */ |
| 801 | error = bus_dma_tag_create( |
| 802 | bus_get_dma_tag(dev), /* Parent tag */ |
| 803 | DESC_ALIGN, 0, /* alignment, boundary */ |
| 804 | BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ |
| 805 | BUS_SPACE_MAXADDR, /* highaddr */ |
| 806 | NULL, NULL, /* filter, filterarg */ |
| 807 | TX_DESC_SIZE, 1, /* maxsize, nsegs */ |
| 808 | TX_DESC_SIZE, /* maxsegsize */ |
| 809 | 0, /* flags */ |
| 810 | NULL, NULL, /* lockfunc, lockarg */ |
| 811 | &sc->tx.desc_tag); |
| 812 | if (error != 0) { |
| 813 | device_printf(dev, "cannot create TX descriptor ring tag\n"); |
| 814 | return (error); |
| 815 | } |
| 816 | |
| 817 | error = bus_dmamem_alloc(sc->tx.desc_tag, (void **)&sc->tx.desc_ring, |
| 818 | BUS_DMA_COHERENT | BUS_DMA_WAITOK | BUS_DMA_ZERO, &sc->tx.desc_map); |
| 819 | if (error != 0) { |
| 820 | device_printf(dev, "cannot allocate TX descriptor ring\n"); |
| 821 | return (error); |
| 822 | } |
| 823 | |
| 824 | error = bus_dmamap_load(sc->tx.desc_tag, sc->tx.desc_map, |
| 825 | sc->tx.desc_ring, TX_DESC_SIZE, awg_dmamap_cb, |
| 826 | &sc->tx.desc_ring_paddr, 0); |
| 827 | if (error != 0) { |
| 828 | device_printf(dev, "cannot load TX descriptor ring\n"); |
| 829 | return (error); |
| 830 | } |
| 831 | |
| 832 | for (i = 0; i < TX_DESC_COUNT; i++) |
| 833 | sc->tx.desc_ring[i].next = |
| 834 | htole32(sc->tx.desc_ring_paddr + DESC_OFF(TX_NEXT(i))); |
| 835 | |
| 836 | error = bus_dma_tag_create( |
| 837 | bus_get_dma_tag(dev), /* Parent tag */ |
| 838 | 1, 0, /* alignment, boundary */ |
| 839 | BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ |
| 840 | BUS_SPACE_MAXADDR, /* highaddr */ |
| 841 | NULL, NULL, /* filter, filterarg */ |
| 842 | MCLBYTES, TX_MAX_SEGS, /* maxsize, nsegs */ |
| 843 | MCLBYTES, /* maxsegsize */ |
| 844 | 0, /* flags */ |
| 845 | NULL, NULL, /* lockfunc, lockarg */ |
| 846 | &sc->tx.buf_tag); |
| 847 | if (error != 0) { |
| 848 | device_printf(dev, "cannot create TX buffer tag\n"); |
| 849 | return (error); |
no test coverage detected