Typical operation example:
**Network device driver call flow:**
```
/* Get xDMA controller */
sc->xdma_tx = xdma_ofw_get(sc->dev, "tx");
/* Allocate virtual channel */
sc->xchan_tx = xdma_channel_alloc(sc->xdma_tx, caps);
```
```
int
atse_xdma_tx_intr(void *arg, xdma_transfer_status_t *status)
{
for (;;) {
err = xdma_dequeue_mbuf(sc->xchan_tx, &m, &st);
if (err != 0) {
break;
}
}
}
/* Setup interrupt handler. */
xdma_setup_intr(sc->xchan_tx, atse_xdma_tx_intr, sc, &sc->ih_tx);
/* Prepare SG transfer */
xdma_prep_sg(sc->xchan_tx, TX_QUEUE_SIZE);
```
```
/* Enqueue (multiple) mbufs to receive */
m = m_getcl();
xdma_enqueue_mbuf(sc->xchan_rx, &m, 0, XDMA_DEV_TO_MEM);
m = m_getcl();
xdma_enqueue_mbuf(sc->xchan_rx, &m, 0, XDMA_DEV_TO_MEM);
...
xdma_queue_submit(sc->xchan_rx);
```
```
/* Enqueue mbuf to transmit */
xdma_enqueue_mbuf(sc->xchan_tx, &m, 0, XDMA_MEM_TO_DEV);
xdma_queue_submit(sc->xchan_tx);
```
**DMA engine driver functions:**
```
/* Prepare a channel for SG transfer */
softdma_channel_prep_sg(device_t dev, struct xdma_channel *xchan)
{
...
}
/* Submit sg list */
softdma_channel_submit_sg(device_t dev, struct xdma_channel *xchan,
struct xdma_sglist *sg, uint32_t sg_n)
{
...
}
/* Provide the amount of free entries for requests. */
softdma_channel_capacity(device_t dev, xdma_channel_t *xchan,
uint32_t *capacity)
{
...
}
```
Example usage:
[[ https://reviews.freebsd.org/D9618 | xDMA support for atse(4) D9618 ]]
[[ https://reviews.freebsd.org/D9619 | mSGDMA driver D9619 ]]
[[ https://reviews.freebsd.org/D9620 | SoftDMA® driver D9620 ]]
[[ https://reviews.freebsd.org/D10201 | ARM PrimeCell® PL330 driver D10201 ]]