mlxbf_gige: fix receive packet race condition
Subsystems (2)
PATCH 1/1 mlxbf_gige: fix receive packet race condition
Under heavy traffic, the BF2 Gigabit interface can become unresponsive for periods of time (several minutes) before eventually recovering. 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, disable receive DMA during the processing of received packets.
--- drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c +8 -0
@@ -299,6 +299,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget)mlxbf_gige_handle_tx_complete (priv); + data =readq (priv->base +MLXBF_GIGE_RX_DMA ); + data &= ~MLXBF_GIGE_RX_DMA_EN ; +writeq (data, priv->base +MLXBF_GIGE_RX_DMA ); +do { remaining_pkts =mlxbf_gige_rx_packet (priv, &work_done); }while (remaining_pkts && work_done < budget);
@@ -314,6 +318,10 @@ int mlxbf_gige_poll(struct napi_struct *napi, int budget) data =readq (priv->base +MLXBF_GIGE_INT_MASK ); data &= ~MLXBF_GIGE_INT_MASK_RX_RECEIVE_PACKET ;writeq (data, priv->base +MLXBF_GIGE_INT_MASK ); + + data =readq (priv->base +MLXBF_GIGE_RX_DMA ); + data |=MLXBF_GIGE_RX_DMA_EN ; +writeq (data, priv->base +MLXBF_GIGE_RX_DMA ); }return work_done;
Signature · 1 line
2.30.1
Jakub Kicinski
maintainerQuoted 8 lines · On Thu, 8 Sep 2022 16:28:53 -0400 David Thompson wrote:
Under heavy traffic, the BF2 Gigabit interface can become unresponsive for periods of time (several minutes) before eventually recovering. This is due to a possible race condition in the
mlxbf_gige_rx_packetfunction, 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, disable receive DMA during the processing of received packets.
Pausing Rx DMA seems a little drastic, is the capacity of the NIC buffer large enough to sink the traffic while the stack drains the ring?
Could you provide a little more detail on what the HW issue is? There is no less intrusive way we can fix it?
Quoted 18 lines
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Monday, September 19, 2022 5:18 PM
To: David Thompson <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Liming Sun <[email protected]>; Asmaa Mnebhi <[email protected]>
Subject: Re: [PATCH net v1]mlxbf_gige: fix receive packet race conditionQuoted 7 lines · On Thu, 8 Sep 2022 16:28:53 -0400 David Thompson wrote:
Under heavy traffic, the BF2 Gigabit interface can become unresponsive for periods of time (several minutes) before eventually recovering. This is due to a possible race condition in the
mlxbf_gige_rx_packetfunction, 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, disable receive DMA during the processing of received packets.
Quoted 5 lines
Pausing Rx DMA seems a little drastic, is the capacity of the NIC buffer large enough to sink the traffic while the stack drains the ring?
Could you provide a little more detail on what the HW issue is? There is no less intrusive way we can fix it?
Thank you for your insight Jakub. I will review this patch and see if it can be solved without pausing of the DMA process.
FYI, a little background on the DMA operation in hardware:
The pausing of RX DMA prevents writing new packets to memory.
New packets will be written to a 20KB buffer (but won't get forwarded to memory and no consumer index update). Once this buffer is full, packets will get dropped.
Thanks, Dave