freebsd-skq/sys/dev/bnxt
Vincenzo Maffione 35d8a463e8 iflib: leave only 1 receive descriptor unused
The pidx argument of isc_rxd_flush() indicates which is the last valid
receive descriptor to be used by the NIC. However, current code has
multiple issues:
  - Intel drivers write pidx to their RDT register, which means that
    NICs will only use the descriptors up to pidx-1 (modulo ring size N),
    and won't actually use the one pointed by pidx. This does not break
    reception, but it is anyway confusing and suboptimal (the NIC will
    actually see only N-2 descriptors as available, rather than N-1).
    Other drivers (if_vmx, if_bnxt, if_mgb) adhere to this semantic).
  - The semantic used by Intel (RDT is one descriptor past the last
     valid one) is used by most (if not all) NICs, and it is also used
     on the TX side (also in iflib). Since iflib is not currently
     using this semantic for RX, it must decrement fl->ifl_pidx
     (modulo N) before calling isc_rxd_flush(), and then the
     per-driver callback implementation must increment the index
     again (to match the real semantic). This is confusing and suboptimal.
  -  The iflib refill function is also called at initialization.
     However, in case the ring size is smaller than 128 (e.g. if_mgb),
     the refill function will actually prepare all the receive
     descriptors (N), without leaving one unused, as most of NICs assume
     (e.g. to avoid RDT to overrun RDH). I can speculate that the code
     looks like this right now because this issue showed up during
     testing (e.g. with if_mgb), and it was easy to workaround by
     decrementing pidx before isc_rxd_flush().

The goal of this change is to simplify the code (removing a bunch
of instructions from the RX fast path), and to make the semantic of
isc_rxd_flush() consistent across drivers. To achieve this, we:
  - change the semantics of the pidx argument to the usual one (that
    is the index one past the last valid one), so that both iflib and
    drivers avoid the decrement/increment dance.
  - fix the initialization code to prepare at most N-1 descriptors.

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D26191
2020-09-01 20:41:47 +00:00
..
bnxt_hwrm.c remove extraneous double ;s in sys/ 2020-03-30 16:04:25 +00:00
bnxt_hwrm.h Support short HWRM commands 2017-12-19 21:07:30 +00:00
bnxt_ioctl.h
bnxt_sysctl.c remove extraneous double ;s in sys/ 2020-03-30 16:04:25 +00:00
bnxt_sysctl.h bnxt: add support for Flow control setting using sysctl 2017-10-24 21:18:50 +00:00
bnxt_txrx.c iflib: leave only 1 receive descriptor unused 2020-09-01 20:41:47 +00:00
bnxt.h bnxt: isc_nrxd_max and isc_ntxd_max must be powers of two 2020-05-20 16:07:37 +00:00
convert_hsi.pl
hsi_struct_def.h bnxt: Update firmware header file with the latest one 2017-09-06 20:19:30 +00:00
if_bnxt.c bnxt: isc_nrxd_max and isc_ntxd_max must be powers of two 2020-05-20 16:07:37 +00:00