]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mlxbf_gige: fix receive packet race condition
authorDavid Thompson <davthompson@nvidia.com>
Wed, 20 Dec 2023 23:47:39 +0000 (18:47 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Jan 2024 17:51:12 +0000 (18:51 +0100)
commitc0b56aa9d1a6eaf5569a0c0315ba3297bf2194dd
tree2d8a41394cab7ebd677452c051e944ced3c53959
parent271567afd4c2ea5e9ee3a52ec87f2da2e02e2eb3
mlxbf_gige: fix receive packet race condition

[ Upstream commit dcea1bd45e6d111cc8fc1aaefa7e31694089bda3 ]

Under heavy traffic, the BlueField Gigabit interface can
become unresponsive. This is due to a possible race condition
in the mlxbf_gige_rx_packet function, where the function exits
with producer and consumer indices equal but there are remaining
packet(s) to be processed. In order to prevent this situation,
read receive consumer index *before* the HW replenish so that
the mlxbf_gige_rx_packet function returns an accurate return
value even if a packet is received into just-replenished buffer
prior to exiting this routine. If the just-replenished buffer
is received and occupies the last RX ring entry, the interface
would not recover and instead would encounter RX packet drops
related to internal buffer shortages since the driver RX logic
is not being triggered to drain the RX ring. This patch will
address and prevent this "ring full" condition.

Fixes: f92e1869d74e ("Add Mellanox BlueField Gigabit Ethernet driver")
Reviewed-by: Asmaa Mnebhi <asmaa@nvidia.com>
Signed-off-by: David Thompson <davthompson@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c