freebsd-dev/sys/net
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
..
altq Use a void * argument to callout handlers instead of timeout_t casts. 2019-12-05 18:47:29 +00:00
route Revert uma zone alignemnt cache unadvertenly committed in r364950. 2020-08-29 12:04:13 +00:00
bpf_buffer.c Add an external mbuf buffer type that holds multiple unmapped pages. 2019-06-29 00:48:33 +00:00
bpf_buffer.h
bpf_filter.c
bpf_jitter.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
bpf_jitter.h
bpf_zerocopy.c Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
bpf_zerocopy.h
bpf.c To avoid a startup script race change net.bpf.optimize_writers from 2020-06-23 13:57:53 +00:00
bpf.h Extract eventfilter declarations to sys/_eventfilter.h 2019-05-20 00:38:23 +00:00
bpfdesc.h Rework locking in BPF code to remove rwlock from fast path. 2019-05-13 13:45:28 +00:00
bridgestp.c bridge: Fix panic if the STP root is removed 2019-03-15 11:21:20 +00:00
bridgestp.h
debugnet_inet.c Implement NetGDB(4) 2019-10-17 21:33:01 +00:00
debugnet_int.h Implement NetGDB(4) 2019-10-17 21:33:01 +00:00
debugnet.c Convert debugnet to the new routing KPI. 2020-04-26 18:42:38 +00:00
debugnet.h Implement NetGDB(4) 2019-10-17 21:33:01 +00:00
dlt.h MFV r353141 (by phillip): 2019-12-21 21:01:03 +00:00
ethernet.h typo: stray spaces. 2020-02-07 15:16:04 +00:00
firewire.h
ieee8023ad_lacp.c make lacp's use_numa hashing aware of send tags 2020-03-09 13:44:51 +00:00
ieee8023ad_lacp.h make lacp's use_numa hashing aware of send tags 2020-03-09 13:44:51 +00:00
ieee_oui.h Fix a typo in r349969 2019-07-14 03:49:48 +00:00
if_arp.h Improve ARP logging. 2019-03-09 01:12:59 +00:00
if_bridge.c bridge: Don't sleep during epoch 2020-07-18 12:43:11 +00:00
if_bridgevar.h libifconfig: Add function to get bridge status 2020-07-01 02:32:41 +00:00
if_clone.c epair: Do not abuse params to register the second interface 2020-01-28 22:44:24 +00:00
if_clone.h epair: Do not abuse params to register the second interface 2020-01-28 22:44:24 +00:00
if_dead.c This adds the third step in getting BBR into the tree. BBR and 2019-08-01 14:17:31 +00:00
if_debug.c
if_disc.c
if_dl.h
if_edsc.c if_edsc: generate an arbitrary MAC address 2020-03-02 02:45:57 +00:00
if_enc.c Consistently include opt_ipsec.h for consumers of <netipsec/ipsec.h>. 2020-05-29 19:22:40 +00:00
if_enc.h
if_epair.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
if_ethersubr.c Use devctl.h instead of bus.h to reduce newbus pollution. 2020-08-21 00:03:24 +00:00
if_fwsubr.c
if_gif.c Add if_reassing method to all tunneling interfaces. 2020-06-03 13:02:31 +00:00
if_gif.h gif_transmit() must always be called in the network epoch. 2020-01-15 06:18:32 +00:00
if_gre.c Add if_reassing method to all tunneling interfaces. 2020-06-03 13:02:31 +00:00
if_gre.h Add GRE-in-UDP encapsulation support as defined in RFC8086. 2019-04-24 09:05:45 +00:00
if_ipsec.c Add if_reassing method to all tunneling interfaces. 2020-06-03 13:02:31 +00:00
if_ipsec.h
if_lagg.c lagg: Avoid adding a port to a lagg device being destroyed. 2020-08-13 22:06:27 +00:00
if_lagg.h Decode the "LACP Fast Timeout" LAGG option flag 2020-06-11 22:46:08 +00:00
if_llatbl.c * Add rib_<add|del|change>_route() functions to manipulate the routing table. 2020-06-01 20:49:42 +00:00
if_llatbl.h Implement optional table entry limits for if_llatbl. 2020-03-04 17:17:02 +00:00
if_llc.h
if_loop.c
if_me.c Add if_reassing method to all tunneling interfaces. 2020-06-03 13:02:31 +00:00
if_media.c if_media.c: staticize and constify ifmedia description structures used under IFMEDIA_DEBUG. 2020-02-11 17:45:01 +00:00
if_media.h For consistency and to avoid any problems getting past the 31bit 2020-08-17 13:51:25 +00:00
if_mib.c net.link.generic.ifdata.<ifindex>.linkspecific: rework handler 2020-06-21 18:40:17 +00:00
if_mib.h
if_pflog.h
if_pfsync.h
if_sppp.h
if_spppfr.c
if_spppsubr.c Don't use if_maddr_rlock() in sppp(4), use epoch(9) directly instead. 2019-10-10 23:54:37 +00:00
if_stf.c Complete conversions from fib<4|6>_lookup_nh_<basic|ext> to fib<4|6>_lookup(). 2020-07-02 21:04:08 +00:00
if_tap.h tap: add support for virtio-net offloads 2019-10-18 21:53:27 +00:00
if_tun.h if_tuntap(4): Add TUNGIFNAME 2019-07-25 22:23:34 +00:00
if_tuntap.c tuntap: drop redundant if_mtu assignment in tuncreate 2020-07-16 15:02:11 +00:00
if_types.h
if_var.h Switch inet6 default route subscription to the new rib subscription api. 2020-07-12 11:24:23 +00:00
if_vlan_var.h Extract eventfilter declarations to sys/_eventfilter.h 2019-05-20 00:38:23 +00:00
if_vlan.c vlan: Fix panic when vnet jail with a vlan interface is destroyed 2020-01-31 22:54:44 +00:00
if_vxlan.c Correct the mask byte order when checking for reserved bits. 2020-08-15 16:48:58 +00:00
if_vxlan.h
if.c Remove free_domain() and uma_zfree_domain(). 2020-08-04 13:58:36 +00:00
if.h Although most of the NIC drivers are epoch ready, due to peer pressure 2020-02-24 21:07:30 +00:00
ifdi_if.m iflib: Stop interface before (un)registering VLAN 2020-04-27 22:02:44 +00:00
iflib_clone.c - Remove the unused ifc_link_irq and ifc_mtx_name members of struct iflib_ctx. 2019-05-06 20:56:41 +00:00
iflib_private.h - Replace unused and only ever written to members of public iflib(9) 2019-06-15 11:07:41 +00:00
iflib.c iflib: leave only 1 receive descriptor unused 2020-09-01 20:41:47 +00:00
iflib.h iflib: netmap: improve rxsync to support IFLIB_HAS_RXCQ 2020-08-12 14:45:31 +00:00
ifq.h
mp_ring.c - Merge r338254 from cxgbe(4): 2019-05-09 11:34:46 +00:00
mp_ring.h mp_ring: avoid items offset difference between iflib and mp_ring 2019-01-03 23:06:05 +00:00
mppc.h
mppcc.c kernel: provide panicky version of __unreachable 2020-05-13 18:07:37 +00:00
mppcd.c
netisr_internal.h
netisr.c sysctl: fix setting net.isr.dispatch during early boot 2020-05-16 17:05:44 +00:00
netisr.h
netmap_legacy.h add valectl to the system commands 2019-10-31 21:01:34 +00:00
netmap_user.h netmap: check if we already ran mmap before we attempt it 2019-11-19 21:29:49 +00:00
netmap_virt.h netmap: disable passthrough with no hypervisor support 2020-01-13 21:47:23 +00:00
netmap.h netmap: import changes from upstream (SHA 137f537eae513) 2019-09-01 14:47:41 +00:00
paravirt.h
pfil.c Since now drivers that support pfil run their interrupts in the network 2020-01-23 01:49:22 +00:00
pfil.h Most Ethernet drivers that potentially can run a pfil(9) hook with 2019-03-10 17:20:09 +00:00
pfkeyv2.h Refer to AES-CBC as "aes-cbc" rather than "rijndael-cbc" for IPsec. 2020-06-04 22:58:37 +00:00
pfvar.h pf: Add a new zone for per-table entry counters. 2020-05-16 00:28:12 +00:00
ppp_defs.h
radix_mpath.c Move net/route/shared.h definitions to net/route/route_var.h. 2020-08-28 22:50:20 +00:00
radix_mpath.h Convert rtalloc_mpath_fib() users to the new KPI. 2020-04-28 08:06:56 +00:00
radix.c
radix.h
raw_cb.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
raw_cb.h
raw_usrreq.c
rndis.h
route.c Move net/route/shared.h definitions to net/route/route_var.h. 2020-08-28 22:50:20 +00:00
route.h Make net.fibs growable. 2020-08-21 21:34:52 +00:00
rss_config.c Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00
rss_config.h
rtsock.c Move net/route/shared.h definitions to net/route/route_var.h. 2020-08-28 22:50:20 +00:00
sff8436.h
sff8472.h net: Update SFF-8024 definitions and strings with values from rev 4.6 2019-08-17 00:10:56 +00:00
slcompress.c
slcompress.h
toeplitz.c
toeplitz.h
vnet.c Partially revert VNET change and expand VNET structure. 2020-02-17 11:08:50 +00:00
vnet.h Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many) 2020-02-26 14:26:36 +00:00