diff mbox series

[net,2/2] tsnep: Fix XDP_RING_NEED_WAKEUP for empty fill ring

Message ID 20240123200918.61219-3-gerhard@engleder-embedded.com (mailing list archive)
State Accepted
Commit 9a91c05f4bd6f6bdd6b8f90445e0da92e3ac956c
Delegated to: Netdev Maintainers
Headers show
Series tsnep: XDP fixes | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1078 this patch: 1078
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1095 this patch: 1095
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1096 this patch: 1096
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest pending net-next-2024-01-25--09-00

Commit Message

Gerhard Engleder Jan. 23, 2024, 8:09 p.m. UTC
The fill ring of the XDP socket may contain not enough buffers to
completey fill the RX queue during socket creation. In this case the
flag XDP_RING_NEED_WAKEUP is not set as this flag is only set if the RX
queue is not completely filled during polling.

Set XDP_RING_NEED_WAKEUP flag also if RX queue is not completely filled
during XDP socket creation.

Fixes: 3fc2333933fd ("tsnep: Add XDP socket zero-copy RX support")
Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
---
 drivers/net/ethernet/engleder/tsnep_main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Paolo Abeni Jan. 25, 2024, 11:06 a.m. UTC | #1
On Tue, 2024-01-23 at 21:09 +0100, Gerhard Engleder wrote:
> The fill ring of the XDP socket may contain not enough buffers to
> completey fill the RX queue during socket creation. In this case the
> flag XDP_RING_NEED_WAKEUP is not set as this flag is only set if the RX
> queue is not completely filled during polling.
> 
> Set XDP_RING_NEED_WAKEUP flag also if RX queue is not completely filled
> during XDP socket creation.
> 
> Fixes: 3fc2333933fd ("tsnep: Add XDP socket zero-copy RX support")
> Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com>
> ---
>  drivers/net/ethernet/engleder/tsnep_main.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c
> index d380a407e175..ae0b8b37b9bf 100644
> --- a/drivers/net/ethernet/engleder/tsnep_main.c
> +++ b/drivers/net/ethernet/engleder/tsnep_main.c
> @@ -1764,6 +1764,19 @@ static void tsnep_rx_reopen_xsk(struct tsnep_rx *rx)
>  			allocated--;
>  		}
>  	}
> +
> +	/* set need wakeup flag immediately if ring is not filled completely,
> +	 * first polling would be too late as need wakeup signalisation would
> +	 * be delayed for an indefinite time
> +	 */
> +	if (xsk_uses_need_wakeup(rx->xsk_pool)) {
> +		int desc_available = tsnep_rx_desc_available(rx);
> +
> +		if (desc_available)
> +			xsk_set_rx_need_wakeup(rx->xsk_pool);
> +		else
> +			xsk_clear_rx_need_wakeup(rx->xsk_pool);
> +	}
>  }
>  
>  static bool tsnep_pending(struct tsnep_queue *queue)

The patch LGTM, but there is a very similar chunk of code in
tsnep_rx_poll_zc(). You should consider a net-next follow-up
consolidating the code in a common helper.

Cheers,

Paolo
Gerhard Engleder Jan. 25, 2024, 9:50 p.m. UTC | #2
On 25.01.24 12:06, Paolo Abeni wrote:
> On Tue, 2024-01-23 at 21:09 +0100, Gerhard Engleder wrote:
>> +	if (xsk_uses_need_wakeup(rx->xsk_pool)) {
>> +		int desc_available = tsnep_rx_desc_available(rx);
>> +
>> +		if (desc_available)
>> +			xsk_set_rx_need_wakeup(rx->xsk_pool);
>> +		else
>> +			xsk_clear_rx_need_wakeup(rx->xsk_pool);
>> +	}
>>   }
>>   
>>   static bool tsnep_pending(struct tsnep_queue *queue)
> 
> The patch LGTM, but there is a very similar chunk of code in
> tsnep_rx_poll_zc(). You should consider a net-next follow-up
> consolidating the code in a common helper.

I will do. Thanks!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/engleder/tsnep_main.c b/drivers/net/ethernet/engleder/tsnep_main.c
index d380a407e175..ae0b8b37b9bf 100644
--- a/drivers/net/ethernet/engleder/tsnep_main.c
+++ b/drivers/net/ethernet/engleder/tsnep_main.c
@@ -1764,6 +1764,19 @@  static void tsnep_rx_reopen_xsk(struct tsnep_rx *rx)
 			allocated--;
 		}
 	}
+
+	/* set need wakeup flag immediately if ring is not filled completely,
+	 * first polling would be too late as need wakeup signalisation would
+	 * be delayed for an indefinite time
+	 */
+	if (xsk_uses_need_wakeup(rx->xsk_pool)) {
+		int desc_available = tsnep_rx_desc_available(rx);
+
+		if (desc_available)
+			xsk_set_rx_need_wakeup(rx->xsk_pool);
+		else
+			xsk_clear_rx_need_wakeup(rx->xsk_pool);
+	}
 }
 
 static bool tsnep_pending(struct tsnep_queue *queue)