HomeFreeBSD

Further correct and optimize the bus_dma(9) usage of iflib(4):

Description

Further correct and optimize the bus_dma(9) usage of iflib(4):
o Correct the obvious bugs in the netmap(4) parts:

  • No longer check for the existence of DMA maps as bus_dma(9) is used unconditionally in iflib(4) since r341095.
  • Supply the correct DMA tag and map pairs to bus_dma(9) functions (see also the commit message of r343753).
  • In iflib_netmap_timer_adjust(), add synchronization of the TX descriptors before calling the ift_txd_credits_update method as the latter evaluates the TX descriptors possibly updated by the MAC.
  • In _task_fn_tx(), wrap the netmap(4)-specific bits in #ifdef DEV_NETMAP just as done in _task_fn_admin() and _task_fn_rx() respectively.

o In iflib_fast_intr_rxtx(), synchronize the TX rather than

the RX descriptors before calling the ift_txd_credits_update
method (see also above).

o There's no need to synchronize an RX buffer that is going to

be recycled in iflib_rxd_pkt_get(), yet; it's sufficient to
do that as late as passing RX buffers to the MAC via the
ift_rxd_refill method. Hence, combine that synchronization
with the synchronization of new buffers into a common spot
in _iflib_fl_refill().

o There's no need to synchronize the RX descriptors of a free

list in preparation of the MAC updating their statuses with
every invocation of rxd_frag_to_sd(); it's enough to do this
once before handing control over to the MAC, i. e. before
calling ift_rxd_flush method in _iflib_fl_refill(), which
already performs the necessary synchronization.

o Given that the ift_rxd_available method evaluates the RX

descriptors which possibly have been altered by the MAC,
synchronize as appropriate beforehand. Most notably this
is now done in iflib_rxd_avail(), which in turn means that
we don't need to issue the same synchronization yet again
before calling the ift_rxd_pkt_get method in iflib_rxeof().

o In iflib_txd_db_check(), synchronize the TX descriptors

before handing them over to the MAC for transmission via
the ift_txd_flush method.

o In iflib_encap(), move the TX buffer synchronization after

the invocation of the ift_txd_encap() method. If the MAC
driver fails to encapsulate the packet and we retry with
a defragmented mbuf chain or finally fail, the cycles for
TX buffer synchronization have been wasted. Synchronizing
afterwards matches what non-iflib(4) drivers typically do
and is sufficient as the MAC will not actually start with
the transmission before - in this case - the ift_txd_flush
method is called.
Moreover, for the latter reason the synchronization of the
TX descriptors in iflib_encap() can go as it's enough to
synchronize them before passing control over to the MAC by
issuing the ift_txd_flush() method (see above).

o In iflib_txq_can_drain(), only synchronize TX descriptors

if the ift_txd_credits_update method accessing these is
actually called.

Differential Revision: https://reviews.freebsd.org/D19081

Details