| 1916 | } |
| 1917 | |
| 1918 | static int |
| 1919 | arge_dma_alloc(struct arge_softc *sc) |
| 1920 | { |
| 1921 | struct arge_dmamap_arg ctx; |
| 1922 | struct arge_txdesc *txd; |
| 1923 | struct arge_rxdesc *rxd; |
| 1924 | int error, i; |
| 1925 | int arge_tx_align, arge_rx_align; |
| 1926 | |
| 1927 | /* Assume 4 byte alignment by default */ |
| 1928 | arge_tx_align = 4; |
| 1929 | arge_rx_align = 4; |
| 1930 | |
| 1931 | if (sc->arge_hw_flags & ARGE_HW_FLG_TX_DESC_ALIGN_1BYTE) |
| 1932 | arge_tx_align = 1; |
| 1933 | if (sc->arge_hw_flags & ARGE_HW_FLG_RX_DESC_ALIGN_1BYTE) |
| 1934 | arge_rx_align = 1; |
| 1935 | |
| 1936 | /* Create parent DMA tag. */ |
| 1937 | error = bus_dma_tag_create( |
| 1938 | bus_get_dma_tag(sc->arge_dev), /* parent */ |
| 1939 | 1, 0, /* alignment, boundary */ |
| 1940 | BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ |
| 1941 | BUS_SPACE_MAXADDR, /* highaddr */ |
| 1942 | NULL, NULL, /* filter, filterarg */ |
| 1943 | BUS_SPACE_MAXSIZE_32BIT, /* maxsize */ |
| 1944 | 0, /* nsegments */ |
| 1945 | BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ |
| 1946 | 0, /* flags */ |
| 1947 | NULL, NULL, /* lockfunc, lockarg */ |
| 1948 | &sc->arge_cdata.arge_parent_tag); |
| 1949 | if (error != 0) { |
| 1950 | device_printf(sc->arge_dev, |
| 1951 | "failed to create parent DMA tag\n"); |
| 1952 | goto fail; |
| 1953 | } |
| 1954 | /* Create tag for Tx ring. */ |
| 1955 | error = bus_dma_tag_create( |
| 1956 | sc->arge_cdata.arge_parent_tag, /* parent */ |
| 1957 | ARGE_RING_ALIGN, 0, /* alignment, boundary */ |
| 1958 | BUS_SPACE_MAXADDR, /* lowaddr */ |
| 1959 | BUS_SPACE_MAXADDR, /* highaddr */ |
| 1960 | NULL, NULL, /* filter, filterarg */ |
| 1961 | ARGE_TX_DMA_SIZE, /* maxsize */ |
| 1962 | 1, /* nsegments */ |
| 1963 | ARGE_TX_DMA_SIZE, /* maxsegsize */ |
| 1964 | 0, /* flags */ |
| 1965 | NULL, NULL, /* lockfunc, lockarg */ |
| 1966 | &sc->arge_cdata.arge_tx_ring_tag); |
| 1967 | if (error != 0) { |
| 1968 | device_printf(sc->arge_dev, |
| 1969 | "failed to create Tx ring DMA tag\n"); |
| 1970 | goto fail; |
| 1971 | } |
| 1972 | |
| 1973 | /* Create tag for Rx ring. */ |
| 1974 | error = bus_dma_tag_create( |
| 1975 | sc->arge_cdata.arge_parent_tag, /* parent */ |
no test coverage detected