* * Allocate DMA resources for TX buffers as well as memory for the TX * mbuf map. TX DMA maps (non-TSO/TSO) and TX mbuf map are kept in a * iflib_sw_tx_desc_array structure, storing all the information that * is needed to transmit a packet on the wire. This is called only * once at attach, setup is done every reset. * *****************************************************************
| 1641 | * |
| 1642 | **********************************************************************/ |
| 1643 | static int |
| 1644 | iflib_txsd_alloc(iflib_txq_t txq) |
| 1645 | { |
| 1646 | if_ctx_t ctx = txq->ift_ctx; |
| 1647 | if_shared_ctx_t sctx = ctx->ifc_sctx; |
| 1648 | if_softc_ctx_t scctx = &ctx->ifc_softc_ctx; |
| 1649 | device_t dev = ctx->ifc_dev; |
| 1650 | bus_size_t tsomaxsize; |
| 1651 | int err, nsegments, ntsosegments; |
| 1652 | bool tso; |
| 1653 | |
| 1654 | nsegments = scctx->isc_tx_nsegments; |
| 1655 | ntsosegments = scctx->isc_tx_tso_segments_max; |
| 1656 | tsomaxsize = scctx->isc_tx_tso_size_max; |
| 1657 | if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_VLAN_MTU) |
| 1658 | tsomaxsize += sizeof(struct ether_vlan_header); |
| 1659 | MPASS(scctx->isc_ntxd[0] > 0); |
| 1660 | MPASS(scctx->isc_ntxd[txq->ift_br_offset] > 0); |
| 1661 | MPASS(nsegments > 0); |
| 1662 | if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_TSO) { |
| 1663 | MPASS(ntsosegments > 0); |
| 1664 | MPASS(sctx->isc_tso_maxsize >= tsomaxsize); |
| 1665 | } |
| 1666 | |
| 1667 | /* |
| 1668 | * Set up DMA tags for TX buffers. |
| 1669 | */ |
| 1670 | if ((err = bus_dma_tag_create(bus_get_dma_tag(dev), |
| 1671 | 1, 0, /* alignment, bounds */ |
| 1672 | BUS_SPACE_MAXADDR, /* lowaddr */ |
| 1673 | BUS_SPACE_MAXADDR, /* highaddr */ |
| 1674 | NULL, NULL, /* filter, filterarg */ |
| 1675 | sctx->isc_tx_maxsize, /* maxsize */ |
| 1676 | nsegments, /* nsegments */ |
| 1677 | sctx->isc_tx_maxsegsize, /* maxsegsize */ |
| 1678 | 0, /* flags */ |
| 1679 | NULL, /* lockfunc */ |
| 1680 | NULL, /* lockfuncarg */ |
| 1681 | &txq->ift_buf_tag))) { |
| 1682 | device_printf(dev,"Unable to allocate TX DMA tag: %d\n", err); |
| 1683 | device_printf(dev,"maxsize: %ju nsegments: %d maxsegsize: %ju\n", |
| 1684 | (uintmax_t)sctx->isc_tx_maxsize, nsegments, (uintmax_t)sctx->isc_tx_maxsegsize); |
| 1685 | goto fail; |
| 1686 | } |
| 1687 | tso = (if_getcapabilities(ctx->ifc_ifp) & IFCAP_TSO) != 0; |
| 1688 | if (tso && (err = bus_dma_tag_create(bus_get_dma_tag(dev), |
| 1689 | 1, 0, /* alignment, bounds */ |
| 1690 | BUS_SPACE_MAXADDR, /* lowaddr */ |
| 1691 | BUS_SPACE_MAXADDR, /* highaddr */ |
| 1692 | NULL, NULL, /* filter, filterarg */ |
| 1693 | tsomaxsize, /* maxsize */ |
| 1694 | ntsosegments, /* nsegments */ |
| 1695 | sctx->isc_tso_maxsegsize,/* maxsegsize */ |
| 1696 | 0, /* flags */ |
| 1697 | NULL, /* lockfunc */ |
| 1698 | NULL, /* lockfuncarg */ |
| 1699 | &txq->ift_tso_buf_tag))) { |
| 1700 | device_printf(dev, "Unable to allocate TSO TX DMA tag: %d\n", |
no test coverage detected