netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] xsk: fix underflow issues in zerocopy xmit
@ 2025-07-22 13:50 Jason Xing
  2025-07-22 13:50 ` [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode Jason Xing
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jason Xing @ 2025-07-22 13:50 UTC (permalink / raw)
  To: anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev, davem,
	edumazet, kuba, pabeni, bjorn, magnus.karlsson,
	maciej.fijalkowski, jonathan.lemon, sdf, ast, daniel, hawk,
	john.fastabend, mcoquelin.stm32, alexandre.torgue
  Cc: linux-stm32, bpf, intel-wired-lan, netdev, Jason Xing

From: Jason Xing <kernelxing@tencent.com>

Fix two underflow issues around {stmmac_xdp|igb}_xmit_zc().

Jason Xing (2):
  stmmac: xsk: fix underflow of budget in zerocopy mode
  igb: xsk: solve underflow of nb_pkts in zerocopy mode

 drivers/net/ethernet/intel/igb/igb_xsk.c          | 3 +--
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

-- 
2.41.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
  2025-07-22 13:50 [PATCH net v2 0/2] xsk: fix underflow issues in zerocopy xmit Jason Xing
@ 2025-07-22 13:50 ` Jason Xing
  2025-07-22 15:03   ` [Intel-wired-lan] " Loktionov, Aleksandr
                     ` (2 more replies)
  2025-07-22 13:50 ` [PATCH net v2 2/2] igb: xsk: solve underflow of nb_pkts " Jason Xing
  2025-07-22 23:07 ` [PATCH net v2 0/2] xsk: fix underflow issues in zerocopy xmit Jason Xing
  2 siblings, 3 replies; 9+ messages in thread
From: Jason Xing @ 2025-07-22 13:50 UTC (permalink / raw)
  To: anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev, davem,
	edumazet, kuba, pabeni, bjorn, magnus.karlsson,
	maciej.fijalkowski, jonathan.lemon, sdf, ast, daniel, hawk,
	john.fastabend, mcoquelin.stm32, alexandre.torgue
  Cc: linux-stm32, bpf, intel-wired-lan, netdev, Jason Xing

From: Jason Xing <kernelxing@tencent.com>

An underflow can happen when the budget number of descs are consumed.
as long as the budget is decreased to zero, it will again go into
while (budget-- > 0) statement and get decreased by one, so the
underflow issue can happen. It will lead to returning true whereas the
expected value should be false.

In this case where all the budget is used up, it means zc function
should return false to let the poll run again because normally we
might have more data to process. Without this patch, zc function would
return true instead.

Fixes: 132c32ee5bc0 ("net: stmmac: Add TX via XDP zero-copy socket")
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
v2
Link: https://lore.kernel.org/all/20250721083343.16482-1-kerneljasonxing@gmail.com/
1. target net tree instead of net-next
2. revise commit message
3. use for loop to replace while loop
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index f350a6662880..c4cd4526ba05 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2596,7 +2596,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
 
 	budget = min(budget, stmmac_tx_avail(priv, queue));
 
-	while (budget-- > 0) {
+	for (; budget > 0; budget--)
 		struct stmmac_metadata_request meta_req;
 		struct xsk_tx_metadata *meta = NULL;
 		dma_addr_t dma_addr;
-- 
2.41.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH net v2 2/2] igb: xsk: solve underflow of nb_pkts in zerocopy mode
  2025-07-22 13:50 [PATCH net v2 0/2] xsk: fix underflow issues in zerocopy xmit Jason Xing
  2025-07-22 13:50 ` [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode Jason Xing
@ 2025-07-22 13:50 ` Jason Xing
  2025-07-22 15:03   ` [Intel-wired-lan] " Loktionov, Aleksandr
  2025-07-22 23:07 ` [PATCH net v2 0/2] xsk: fix underflow issues in zerocopy xmit Jason Xing
  2 siblings, 1 reply; 9+ messages in thread
From: Jason Xing @ 2025-07-22 13:50 UTC (permalink / raw)
  To: anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev, davem,
	edumazet, kuba, pabeni, bjorn, magnus.karlsson,
	maciej.fijalkowski, jonathan.lemon, sdf, ast, daniel, hawk,
	john.fastabend, mcoquelin.stm32, alexandre.torgue
  Cc: linux-stm32, bpf, intel-wired-lan, netdev, Jason Xing

From: Jason Xing <kernelxing@tencent.com>

There is no break time in the while() loop, so every time at the end of
igb_xmit_zc(), underflow of nb_pkts will occur, which renders the return
value always false. But theoretically, the result should be set after
calling xsk_tx_peek_release_desc_batch(). We can take i40e_xmit_zc() as
a good example.

Returning false means we're not done with transmission and we need one
more poll, which is exactly what igb_xmit_zc() always did before this
patch. After this patch, the return value depends on the nb_pkts value.
Two cases might happen then:
1. if (nb_pkts < budget), it means we process all the possible data, so
   return true and no more necessary poll will be triggered because of
   this.
2. if (nb_pkts == budget), it means we might have more data, so return
   false to let another poll run again.

Fixes: f8e284a02afc ("igb: Add AF_XDP zero-copy Tx support")
Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
v2
Link: https://lore.kernel.org/all/20250721083343.16482-1-kerneljasonxing@gmail.com/
1. target net tree instead of net-next
2. use for loop instead
---
 drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c b/drivers/net/ethernet/intel/igb/igb_xsk.c
index 5cf67ba29269..30ce5fbb5b77 100644
--- a/drivers/net/ethernet/intel/igb/igb_xsk.c
+++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
@@ -482,7 +482,7 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool)
 	if (!nb_pkts)
 		return true;
 
-	while (nb_pkts-- > 0) {
+	for (; i < nb_pkts; i++) {
 		dma = xsk_buff_raw_get_dma(xsk_pool, descs[i].addr);
 		xsk_buff_raw_dma_sync_for_device(xsk_pool, dma, descs[i].len);
 
@@ -512,7 +512,6 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool)
 
 		total_bytes += descs[i].len;
 
-		i++;
 		tx_ring->next_to_use++;
 		tx_buffer_info->next_to_watch = tx_desc;
 		if (tx_ring->next_to_use == tx_ring->count)
-- 
2.41.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* RE: [Intel-wired-lan] [PATCH net v2 2/2] igb: xsk: solve underflow of nb_pkts in zerocopy mode
  2025-07-22 13:50 ` [PATCH net v2 2/2] igb: xsk: solve underflow of nb_pkts " Jason Xing
@ 2025-07-22 15:03   ` Loktionov, Aleksandr
  0 siblings, 0 replies; 9+ messages in thread
From: Loktionov, Aleksandr @ 2025-07-22 15:03 UTC (permalink / raw)
  To: Jason Xing, Nguyen, Anthony L, Kitszel, Przemyslaw,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, bjorn@kernel.org,
	Karlsson, Magnus, Fijalkowski, Maciej, jonathan.lemon@gmail.com,
	sdf@fomichev.me, ast@kernel.org, daniel@iogearbox.net,
	hawk@kernel.org, john.fastabend@gmail.com,
	mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com
  Cc: linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	Jason Xing



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Jason Xing
> Sent: Tuesday, July 22, 2025 3:51 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@intel.com>; andrew+netdev@lunn.ch;
> davem@davemloft.net; edumazet@google.com; kuba@kernel.org;
> pabeni@redhat.com; bjorn@kernel.org; Karlsson, Magnus
> <magnus.karlsson@intel.com>; Fijalkowski, Maciej
> <maciej.fijalkowski@intel.com>; jonathan.lemon@gmail.com;
> sdf@fomichev.me; ast@kernel.org; daniel@iogearbox.net;
> hawk@kernel.org; john.fastabend@gmail.com; mcoquelin.stm32@gmail.com;
> alexandre.torgue@foss.st.com
> Cc: linux-stm32@st-md-mailman.stormreply.com; bpf@vger.kernel.org;
> intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; Jason Xing
> <kernelxing@tencent.com>
> Subject: [Intel-wired-lan] [PATCH net v2 2/2] igb: xsk: solve
> underflow of nb_pkts in zerocopy mode
> 
> From: Jason Xing <kernelxing@tencent.com>
> 
> There is no break time in the while() loop, so every time at the end
> of igb_xmit_zc(), underflow of nb_pkts will occur, which renders the
> return value always false. But theoretically, the result should be set
> after calling xsk_tx_peek_release_desc_batch(). We can take
> i40e_xmit_zc() as a good example.
> 
> Returning false means we're not done with transmission and we need one
> more poll, which is exactly what igb_xmit_zc() always did before this
> patch. After this patch, the return value depends on the nb_pkts
> value.
> Two cases might happen then:
> 1. if (nb_pkts < budget), it means we process all the possible data,
> so
>    return true and no more necessary poll will be triggered because of
>    this.
> 2. if (nb_pkts == budget), it means we might have more data, so return
>    false to let another poll run again.
> 
> Fixes: f8e284a02afc ("igb: Add AF_XDP zero-copy Tx support")
> Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> v2
> Link: https://lore.kernel.org/all/20250721083343.16482-1-
> kerneljasonxing@gmail.com/
> 1. target net tree instead of net-next
> 2. use for loop instead
> ---
>  drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_xsk.c
> b/drivers/net/ethernet/intel/igb/igb_xsk.c
> index 5cf67ba29269..30ce5fbb5b77 100644
> --- a/drivers/net/ethernet/intel/igb/igb_xsk.c
> +++ b/drivers/net/ethernet/intel/igb/igb_xsk.c
> @@ -482,7 +482,7 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct
> xsk_buff_pool *xsk_pool)
>  	if (!nb_pkts)
>  		return true;
> 
> -	while (nb_pkts-- > 0) {
> +	for (; i < nb_pkts; i++) {
>  		dma = xsk_buff_raw_get_dma(xsk_pool, descs[i].addr);
>  		xsk_buff_raw_dma_sync_for_device(xsk_pool, dma,
> descs[i].len);
> 
> @@ -512,7 +512,6 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct
> xsk_buff_pool *xsk_pool)
> 
>  		total_bytes += descs[i].len;
> 
> -		i++;
>  		tx_ring->next_to_use++;
>  		tx_buffer_info->next_to_watch = tx_desc;
>  		if (tx_ring->next_to_use == tx_ring->count)
> --
> 2.41.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
  2025-07-22 13:50 ` [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode Jason Xing
@ 2025-07-22 15:03   ` Loktionov, Aleksandr
  2025-07-23  4:09   ` kernel test robot
  2025-07-23  6:43   ` kernel test robot
  2 siblings, 0 replies; 9+ messages in thread
From: Loktionov, Aleksandr @ 2025-07-22 15:03 UTC (permalink / raw)
  To: Jason Xing, Nguyen, Anthony L, Kitszel, Przemyslaw,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, bjorn@kernel.org,
	Karlsson, Magnus, Fijalkowski, Maciej, jonathan.lemon@gmail.com,
	sdf@fomichev.me, ast@kernel.org, daniel@iogearbox.net,
	hawk@kernel.org, john.fastabend@gmail.com,
	mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com
  Cc: linux-stm32@st-md-mailman.stormreply.com, bpf@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org,
	Jason Xing



> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Jason Xing
> Sent: Tuesday, July 22, 2025 3:51 PM
> To: Nguyen, Anthony L <anthony.l.nguyen@intel.com>; Kitszel,
> Przemyslaw <przemyslaw.kitszel@intel.com>; andrew+netdev@lunn.ch;
> davem@davemloft.net; edumazet@google.com; kuba@kernel.org;
> pabeni@redhat.com; bjorn@kernel.org; Karlsson, Magnus
> <magnus.karlsson@intel.com>; Fijalkowski, Maciej
> <maciej.fijalkowski@intel.com>; jonathan.lemon@gmail.com;
> sdf@fomichev.me; ast@kernel.org; daniel@iogearbox.net;
> hawk@kernel.org; john.fastabend@gmail.com; mcoquelin.stm32@gmail.com;
> alexandre.torgue@foss.st.com
> Cc: linux-stm32@st-md-mailman.stormreply.com; bpf@vger.kernel.org;
> intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; Jason Xing
> <kernelxing@tencent.com>
> Subject: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix
> underflow of budget in zerocopy mode
> 
> From: Jason Xing <kernelxing@tencent.com>
> 
> An underflow can happen when the budget number of descs are consumed.
> as long as the budget is decreased to zero, it will again go into
> while (budget-- > 0) statement and get decreased by one, so the
> underflow issue can happen. It will lead to returning true whereas the
> expected value should be false.
> 
> In this case where all the budget is used up, it means zc function
> should return false to let the poll run again because normally we
> might have more data to process. Without this patch, zc function would
> return true instead.
> 
> Fixes: 132c32ee5bc0 ("net: stmmac: Add TX via XDP zero-copy socket")
> Signed-off-by: Jason Xing <kernelxing@tencent.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> v2
> Link: https://lore.kernel.org/all/20250721083343.16482-1-
> kerneljasonxing@gmail.com/
> 1. target net tree instead of net-next
> 2. revise commit message
> 3. use for loop to replace while loop
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f350a6662880..c4cd4526ba05 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2596,7 +2596,7 @@ static bool stmmac_xdp_xmit_zc(struct
> stmmac_priv *priv, u32 queue, u32 budget)
> 
>  	budget = min(budget, stmmac_tx_avail(priv, queue));
> 
> -	while (budget-- > 0) {
> +	for (; budget > 0; budget--)
>  		struct stmmac_metadata_request meta_req;
>  		struct xsk_tx_metadata *meta = NULL;
>  		dma_addr_t dma_addr;
> --
> 2.41.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH net v2 0/2] xsk: fix underflow issues in zerocopy xmit
  2025-07-22 13:50 [PATCH net v2 0/2] xsk: fix underflow issues in zerocopy xmit Jason Xing
  2025-07-22 13:50 ` [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode Jason Xing
  2025-07-22 13:50 ` [PATCH net v2 2/2] igb: xsk: solve underflow of nb_pkts " Jason Xing
@ 2025-07-22 23:07 ` Jason Xing
  2 siblings, 0 replies; 9+ messages in thread
From: Jason Xing @ 2025-07-22 23:07 UTC (permalink / raw)
  To: anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev, davem,
	edumazet, kuba, pabeni, bjorn, magnus.karlsson,
	maciej.fijalkowski, jonathan.lemon, sdf, ast, daniel, hawk,
	john.fastabend, mcoquelin.stm32, alexandre.torgue
  Cc: linux-stm32, bpf, intel-wired-lan, netdev, Jason Xing

On Tue, Jul 22, 2025 at 9:51 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> From: Jason Xing <kernelxing@tencent.com>
>
> Fix two underflow issues around {stmmac_xdp|igb}_xmit_zc().
>
> Jason Xing (2):
>   stmmac: xsk: fix underflow of budget in zerocopy mode
>   igb: xsk: solve underflow of nb_pkts in zerocopy mode

Willem has pointed out it's technically not underflow but the negative
overflow[1]. So I decided to send a V3 patch with this modified.

[1]: https://lore.kernel.org/all/687f9d4cf0b14_2aa7cc29443@willemb.c.googlers.com.notmuch/

Thanks,
Jason

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
  2025-07-22 13:50 ` [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode Jason Xing
  2025-07-22 15:03   ` [Intel-wired-lan] " Loktionov, Aleksandr
@ 2025-07-23  4:09   ` kernel test robot
  2025-07-23  4:16     ` Jason Xing
  2025-07-23  6:43   ` kernel test robot
  2 siblings, 1 reply; 9+ messages in thread
From: kernel test robot @ 2025-07-23  4:09 UTC (permalink / raw)
  To: Jason Xing, anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev,
	davem, edumazet, kuba, pabeni, bjorn, magnus.karlsson,
	maciej.fijalkowski, jonathan.lemon, sdf, ast, daniel, hawk,
	john.fastabend, mcoquelin.stm32, alexandre.torgue
  Cc: oe-kbuild-all, linux-stm32, bpf, intel-wired-lan, netdev,
	Jason Xing

Hi Jason,

kernel test robot noticed the following build errors:

[auto build test ERROR on net/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Jason-Xing/stmmac-xsk-fix-underflow-of-budget-in-zerocopy-mode/20250722-215348
base:   net/main
patch link:    https://lore.kernel.org/r/20250722135057.85386-2-kerneljasonxing%40gmail.com
patch subject: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20250723/202507231150.Gbhu52dL-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250723/202507231150.Gbhu52dL-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507231150.Gbhu52dL-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: In function 'stmmac_xdp_xmit_zc':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2600:17: error: expected expression before 'struct'
    2600 |                 struct stmmac_metadata_request meta_req;
         |                 ^~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2599:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    2599 |         for (; budget > 0; budget--)
         |         ^~~
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2601:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    2601 |                 struct xsk_tx_metadata *meta = NULL;
         |                 ^~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2611:25: error: break statement not within loop or switch
    2611 |                         break;
         |                         ^~~~~
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2615:25: error: break statement not within loop or switch
    2615 |                         break;
         |                         ^~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2621:25: error: continue statement not within a loop
    2621 |                         continue;
         |                         ^~~~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2660:17: error: 'meta_req' undeclared (first use in this function); did you mean 'net_eq'?
    2660 |                 meta_req.priv = priv;
         |                 ^~~~~~~~
         |                 net_eq
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2660:17: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2591:14: warning: variable 'work_done' set but not used [-Wunused-but-set-variable]
    2591 |         bool work_done = true;
         |              ^~~~~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2586:34: warning: unused variable 'txq_stats' [-Wunused-variable]
    2586 |         struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue];
         |                                  ^~~~~~~~~
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: At top level:
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:32: error: expected declaration specifiers or '...' before '&' token
    2685 |         u64_stats_update_begin(&txq_stats->napi_syncp);
         |                                ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:23: error: expected declaration specifiers or '...' before '&' token
    2686 |         u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
         |                       ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:55: error: unknown type name 'tx_set_ic_bit'
    2686 |         u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
         |                                                       ^~~~~~~~~~~~~
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2687:30: error: expected declaration specifiers or '...' before '&' token
    2687 |         u64_stats_update_end(&txq_stats->napi_syncp);
         |                              ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2689:9: error: expected identifier or '(' before 'if'
    2689 |         if (tx_desc) {
         |         ^~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2699:9: error: expected identifier or '(' before 'return'
    2699 |         return !!budget && work_done;
         |         ^~~~~~
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2700:1: error: expected identifier or '(' before '}' token
    2700 | }
         | ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: In function 'stmmac_xdp_xmit_zc':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2684:9: warning: control reaches end of non-void function [-Wreturn-type]
    2684 |         }
         |         ^


vim +/struct +2600 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

1347b419318d6a Song Yoong Siang  2023-11-27  2581  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2582  static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
132c32ee5bc09b Ong Boon Leong    2021-04-13  2583  {
132c32ee5bc09b Ong Boon Leong    2021-04-13  2584  	struct netdev_queue *nq = netdev_get_tx_queue(priv->dev, queue);
8531c80800c10e Christian Marangi 2022-07-23  2585  	struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
8070274b472e2e Jisheng Zhang     2023-09-18 @2586  	struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue];
132c32ee5bc09b Ong Boon Leong    2021-04-13  2587  	struct xsk_buff_pool *pool = tx_q->xsk_pool;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2588  	unsigned int entry = tx_q->cur_tx;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2589  	struct dma_desc *tx_desc = NULL;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2590  	struct xdp_desc xdp_desc;
132c32ee5bc09b Ong Boon Leong    2021-04-13 @2591  	bool work_done = true;
133466c3bbe171 Jisheng Zhang     2023-07-18  2592  	u32 tx_set_ic_bit = 0;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2593  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2594  	/* Avoids TX time-out as we are sharing with slow path */
e92af33e472cf3 Alexander Lobakin 2021-11-17  2595  	txq_trans_cond_update(nq);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2596  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2597  	budget = min(budget, stmmac_tx_avail(priv, queue));
132c32ee5bc09b Ong Boon Leong    2021-04-13  2598  
9074ec4e205d86 Jason Xing        2025-07-22 @2599  	for (; budget > 0; budget--)
1347b419318d6a Song Yoong Siang  2023-11-27 @2600  		struct stmmac_metadata_request meta_req;
1347b419318d6a Song Yoong Siang  2023-11-27  2601  		struct xsk_tx_metadata *meta = NULL;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2602  		dma_addr_t dma_addr;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2603  		bool set_ic;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2604  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2605  		/* We are sharing with slow path and stop XSK TX desc submission when
132c32ee5bc09b Ong Boon Leong    2021-04-13  2606  		 * available TX ring is less than threshold.
132c32ee5bc09b Ong Boon Leong    2021-04-13  2607  		 */
132c32ee5bc09b Ong Boon Leong    2021-04-13  2608  		if (unlikely(stmmac_tx_avail(priv, queue) < STMMAC_TX_XSK_AVAIL) ||
132c32ee5bc09b Ong Boon Leong    2021-04-13  2609  		    !netif_carrier_ok(priv->dev)) {
132c32ee5bc09b Ong Boon Leong    2021-04-13  2610  			work_done = false;
132c32ee5bc09b Ong Boon Leong    2021-04-13 @2611  			break;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2612  		}
132c32ee5bc09b Ong Boon Leong    2021-04-13  2613  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2614  		if (!xsk_tx_peek_desc(pool, &xdp_desc))
132c32ee5bc09b Ong Boon Leong    2021-04-13  2615  			break;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2616  
bd17382ac36ed9 Xiaolei Wang      2024-05-13  2617  		if (priv->est && priv->est->enable &&
bd17382ac36ed9 Xiaolei Wang      2024-05-13  2618  		    priv->est->max_sdu[queue] &&
bd17382ac36ed9 Xiaolei Wang      2024-05-13  2619  		    xdp_desc.len > priv->est->max_sdu[queue]) {
c5c3e1bfc9e0ee Rohan G Thomas    2024-01-27  2620  			priv->xstats.max_sdu_txq_drop[queue]++;
c5c3e1bfc9e0ee Rohan G Thomas    2024-01-27 @2621  			continue;
c5c3e1bfc9e0ee Rohan G Thomas    2024-01-27  2622  		}
c5c3e1bfc9e0ee Rohan G Thomas    2024-01-27  2623  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2624  		if (likely(priv->extend_desc))
132c32ee5bc09b Ong Boon Leong    2021-04-13  2625  			tx_desc = (struct dma_desc *)(tx_q->dma_etx + entry);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2626  		else if (tx_q->tbs & STMMAC_TBS_AVAIL)
132c32ee5bc09b Ong Boon Leong    2021-04-13  2627  			tx_desc = &tx_q->dma_entx[entry].basic;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2628  		else
132c32ee5bc09b Ong Boon Leong    2021-04-13  2629  			tx_desc = tx_q->dma_tx + entry;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2630  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2631  		dma_addr = xsk_buff_raw_get_dma(pool, xdp_desc.addr);
1347b419318d6a Song Yoong Siang  2023-11-27  2632  		meta = xsk_buff_get_metadata(pool, xdp_desc.addr);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2633  		xsk_buff_raw_dma_sync_for_device(pool, dma_addr, xdp_desc.len);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2634  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2635  		tx_q->tx_skbuff_dma[entry].buf_type = STMMAC_TXBUF_T_XSK_TX;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2636  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2637  		/* To return XDP buffer to XSK pool, we simple call
132c32ee5bc09b Ong Boon Leong    2021-04-13  2638  		 * xsk_tx_completed(), so we don't need to fill up
132c32ee5bc09b Ong Boon Leong    2021-04-13  2639  		 * 'buf' and 'xdpf'.
132c32ee5bc09b Ong Boon Leong    2021-04-13  2640  		 */
132c32ee5bc09b Ong Boon Leong    2021-04-13  2641  		tx_q->tx_skbuff_dma[entry].buf = 0;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2642  		tx_q->xdpf[entry] = NULL;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2643  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2644  		tx_q->tx_skbuff_dma[entry].map_as_page = false;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2645  		tx_q->tx_skbuff_dma[entry].len = xdp_desc.len;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2646  		tx_q->tx_skbuff_dma[entry].last_segment = true;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2647  		tx_q->tx_skbuff_dma[entry].is_jumbo = false;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2648  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2649  		stmmac_set_desc_addr(priv, tx_desc, dma_addr);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2650  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2651  		tx_q->tx_count_frames++;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2652  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2653  		if (!priv->tx_coal_frames[queue])
132c32ee5bc09b Ong Boon Leong    2021-04-13  2654  			set_ic = false;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2655  		else if (tx_q->tx_count_frames % priv->tx_coal_frames[queue] == 0)
132c32ee5bc09b Ong Boon Leong    2021-04-13  2656  			set_ic = true;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2657  		else
132c32ee5bc09b Ong Boon Leong    2021-04-13  2658  			set_ic = false;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2659  
1347b419318d6a Song Yoong Siang  2023-11-27 @2660  		meta_req.priv = priv;
1347b419318d6a Song Yoong Siang  2023-11-27  2661  		meta_req.tx_desc = tx_desc;
1347b419318d6a Song Yoong Siang  2023-11-27  2662  		meta_req.set_ic = &set_ic;
04f64dea13640f Song Yoong Siang  2025-02-16  2663  		meta_req.tbs = tx_q->tbs;
04f64dea13640f Song Yoong Siang  2025-02-16  2664  		meta_req.edesc = &tx_q->dma_entx[entry];
1347b419318d6a Song Yoong Siang  2023-11-27  2665  		xsk_tx_metadata_request(meta, &stmmac_xsk_tx_metadata_ops,
1347b419318d6a Song Yoong Siang  2023-11-27  2666  					&meta_req);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2667  		if (set_ic) {
132c32ee5bc09b Ong Boon Leong    2021-04-13  2668  			tx_q->tx_count_frames = 0;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2669  			stmmac_set_tx_ic(priv, tx_desc);
133466c3bbe171 Jisheng Zhang     2023-07-18  2670  			tx_set_ic_bit++;
132c32ee5bc09b Ong Boon Leong    2021-04-13  2671  		}
132c32ee5bc09b Ong Boon Leong    2021-04-13  2672  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2673  		stmmac_prepare_tx_desc(priv, tx_desc, 1, xdp_desc.len,
132c32ee5bc09b Ong Boon Leong    2021-04-13  2674  				       true, priv->mode, true, true,
132c32ee5bc09b Ong Boon Leong    2021-04-13  2675  				       xdp_desc.len);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2676  
ad72f783de0682 Yanteng Si        2024-08-07  2677  		stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2678  
1347b419318d6a Song Yoong Siang  2023-11-27  2679  		xsk_tx_metadata_to_compl(meta,
1347b419318d6a Song Yoong Siang  2023-11-27  2680  					 &tx_q->tx_skbuff_dma[entry].xsk_meta);
1347b419318d6a Song Yoong Siang  2023-11-27  2681  
8531c80800c10e Christian Marangi 2022-07-23  2682  		tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, priv->dma_conf.dma_tx_size);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2683  		entry = tx_q->cur_tx;
132c32ee5bc09b Ong Boon Leong    2021-04-13 @2684  	}
38cc3c6dcc09dc Petr Tesarik      2024-02-03 @2685  	u64_stats_update_begin(&txq_stats->napi_syncp);
38cc3c6dcc09dc Petr Tesarik      2024-02-03 @2686  	u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
38cc3c6dcc09dc Petr Tesarik      2024-02-03  2687  	u64_stats_update_end(&txq_stats->napi_syncp);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2688  
132c32ee5bc09b Ong Boon Leong    2021-04-13 @2689  	if (tx_desc) {
132c32ee5bc09b Ong Boon Leong    2021-04-13  2690  		stmmac_flush_tx_descriptors(priv, queue);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2691  		xsk_tx_release(pool);
132c32ee5bc09b Ong Boon Leong    2021-04-13  2692  	}
132c32ee5bc09b Ong Boon Leong    2021-04-13  2693  
132c32ee5bc09b Ong Boon Leong    2021-04-13  2694  	/* Return true if all of the 3 conditions are met
132c32ee5bc09b Ong Boon Leong    2021-04-13  2695  	 *  a) TX Budget is still available
132c32ee5bc09b Ong Boon Leong    2021-04-13  2696  	 *  b) work_done = true when XSK TX desc peek is empty (no more
132c32ee5bc09b Ong Boon Leong    2021-04-13  2697  	 *     pending XSK TX for transmission)
132c32ee5bc09b Ong Boon Leong    2021-04-13  2698  	 */
132c32ee5bc09b Ong Boon Leong    2021-04-13 @2699  	return !!budget && work_done;
132c32ee5bc09b Ong Boon Leong    2021-04-13 @2700  }
132c32ee5bc09b Ong Boon Leong    2021-04-13  2701  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
  2025-07-23  4:09   ` kernel test robot
@ 2025-07-23  4:16     ` Jason Xing
  0 siblings, 0 replies; 9+ messages in thread
From: Jason Xing @ 2025-07-23  4:16 UTC (permalink / raw)
  To: kernel test robot
  Cc: anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev, davem,
	edumazet, kuba, pabeni, bjorn, magnus.karlsson,
	maciej.fijalkowski, jonathan.lemon, sdf, ast, daniel, hawk,
	john.fastabend, mcoquelin.stm32, alexandre.torgue, oe-kbuild-all,
	linux-stm32, bpf, intel-wired-lan, netdev, Jason Xing

On Wed, Jul 23, 2025 at 12:10 PM kernel test robot <lkp@intel.com> wrote:
>
> Hi Jason,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on net/main]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Jason-Xing/stmmac-xsk-fix-underflow-of-budget-in-zerocopy-mode/20250722-215348
> base:   net/main
> patch link:    https://lore.kernel.org/r/20250722135057.85386-2-kerneljasonxing%40gmail.com
> patch subject: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
> config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20250723/202507231150.Gbhu52dL-lkp@intel.com/config)
> compiler: alpha-linux-gcc (GCC) 15.1.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250723/202507231150.Gbhu52dL-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202507231150.Gbhu52dL-lkp@intel.com/

Oops, I posted a wrong version which missed one '{' after the 'for' statement.

Will post a correct version.

Thanks,
Jason

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
  2025-07-22 13:50 ` [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode Jason Xing
  2025-07-22 15:03   ` [Intel-wired-lan] " Loktionov, Aleksandr
  2025-07-23  4:09   ` kernel test robot
@ 2025-07-23  6:43   ` kernel test robot
  2 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-07-23  6:43 UTC (permalink / raw)
  To: Jason Xing, anthony.l.nguyen, przemyslaw.kitszel, andrew+netdev,
	davem, edumazet, kuba, pabeni, bjorn, magnus.karlsson,
	maciej.fijalkowski, jonathan.lemon, sdf, ast, daniel, hawk,
	john.fastabend, mcoquelin.stm32, alexandre.torgue
  Cc: llvm, oe-kbuild-all, linux-stm32, bpf, intel-wired-lan, netdev,
	Jason Xing

Hi Jason,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Jason-Xing/stmmac-xsk-fix-underflow-of-budget-in-zerocopy-mode/20250722-215348
base:   net/main
patch link:    https://lore.kernel.org/r/20250722135057.85386-2-kerneljasonxing%40gmail.com
patch subject: [Intel-wired-lan] [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20250723/202507231458.meHSJi2g-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250723/202507231458.meHSJi2g-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507231458.meHSJi2g-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2601:3: warning: misleading indentation; statement is not part of the previous 'for' [-Wmisleading-indentation]
    2601 |                 struct xsk_tx_metadata *meta = NULL;
         |                 ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2599:2: note: previous statement is here
    2599 |         for (; budget > 0; budget--)
         |         ^
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2600:34: warning: unused variable 'meta_req' [-Wunused-variable]
    2600 |                 struct stmmac_metadata_request meta_req;
         |                                                ^~~~~~~~
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2611:4: error: 'break' statement not in loop or switch statement
    2611 |                         break;
         |                         ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2615:4: error: 'break' statement not in loop or switch statement
    2615 |                         break;
         |                         ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2621:4: error: 'continue' statement not in loop statement
    2621 |                         continue;
         |                         ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2660:3: error: use of undeclared identifier 'meta_req'
    2660 |                 meta_req.priv = priv;
         |                 ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2661:3: error: use of undeclared identifier 'meta_req'
    2661 |                 meta_req.tx_desc = tx_desc;
         |                 ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2662:3: error: use of undeclared identifier 'meta_req'
    2662 |                 meta_req.set_ic = &set_ic;
         |                 ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2663:3: error: use of undeclared identifier 'meta_req'
    2663 |                 meta_req.tbs = tx_q->tbs;
         |                 ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2664:3: error: use of undeclared identifier 'meta_req'
    2664 |                 meta_req.edesc = &tx_q->dma_entx[entry];
         |                 ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2666:7: error: use of undeclared identifier 'meta_req'; did you mean 'net_eq'?
    2666 |                                         &meta_req);
         |                                          ^~~~~~~~
         |                                          net_eq
   include/net/net_namespace.h:292:5: note: 'net_eq' declared here
     292 | int net_eq(const struct net *net1, const struct net *net2)
         |     ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:25: error: expected parameter declarator
    2685 |         u64_stats_update_begin(&txq_stats->napi_syncp);
         |                                ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:25: error: expected ')'
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:24: note: to match this '('
    2685 |         u64_stats_update_begin(&txq_stats->napi_syncp);
         |                               ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:2: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
    2685 |         u64_stats_update_begin(&txq_stats->napi_syncp);
         |         ^
         |         int
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:24: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    2685 |         u64_stats_update_begin(&txq_stats->napi_syncp);
         |                               ^                      
         |                                                      void
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:2: error: a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C23, conflicting with a previous declaration [-Werror,-Wdeprecated-non-prototype]
    2685 |         u64_stats_update_begin(&txq_stats->napi_syncp);
         |         ^
   include/linux/u64_stats_sync.h:181:20: note: conflicting prototype is here
     181 | static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
         |                    ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2685:2: error: conflicting types for 'u64_stats_update_begin'
    2685 |         u64_stats_update_begin(&txq_stats->napi_syncp);
         |         ^
   include/linux/u64_stats_sync.h:181:20: note: previous definition is here
     181 | static inline void u64_stats_update_begin(struct u64_stats_sync *syncp)
         |                    ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:16: error: expected parameter declarator
    2686 |         u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
         |                       ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:16: error: expected ')'
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:15: note: to match this '('
    2686 |         u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
         |                      ^
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:2: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
    2686 |         u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
         |         ^
         |         int
   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:2686:15: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    2686 |         u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
         |                      ^                                             
         |                                                                    void
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   2 warnings and 20 errors generated.


vim +/for +2601 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

1347b419318d6af Song Yoong Siang  2023-11-27  2581  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2582  static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2583  {
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2584  	struct netdev_queue *nq = netdev_get_tx_queue(priv->dev, queue);
8531c80800c10e8 Christian Marangi 2022-07-23  2585  	struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
8070274b472e2e9 Jisheng Zhang     2023-09-18  2586  	struct stmmac_txq_stats *txq_stats = &priv->xstats.txq_stats[queue];
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2587  	struct xsk_buff_pool *pool = tx_q->xsk_pool;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2588  	unsigned int entry = tx_q->cur_tx;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2589  	struct dma_desc *tx_desc = NULL;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2590  	struct xdp_desc xdp_desc;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2591  	bool work_done = true;
133466c3bbe171f Jisheng Zhang     2023-07-18  2592  	u32 tx_set_ic_bit = 0;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2593  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2594  	/* Avoids TX time-out as we are sharing with slow path */
e92af33e472cf3a Alexander Lobakin 2021-11-17  2595  	txq_trans_cond_update(nq);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2596  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2597  	budget = min(budget, stmmac_tx_avail(priv, queue));
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2598  
9074ec4e205d86d Jason Xing        2025-07-22  2599  	for (; budget > 0; budget--)
1347b419318d6af Song Yoong Siang  2023-11-27 @2600  		struct stmmac_metadata_request meta_req;
1347b419318d6af Song Yoong Siang  2023-11-27 @2601  		struct xsk_tx_metadata *meta = NULL;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2602  		dma_addr_t dma_addr;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2603  		bool set_ic;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2604  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2605  		/* We are sharing with slow path and stop XSK TX desc submission when
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2606  		 * available TX ring is less than threshold.
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2607  		 */
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2608  		if (unlikely(stmmac_tx_avail(priv, queue) < STMMAC_TX_XSK_AVAIL) ||
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2609  		    !netif_carrier_ok(priv->dev)) {
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2610  			work_done = false;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2611  			break;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2612  		}
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2613  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2614  		if (!xsk_tx_peek_desc(pool, &xdp_desc))
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2615  			break;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2616  
bd17382ac36ed97 Xiaolei Wang      2024-05-13  2617  		if (priv->est && priv->est->enable &&
bd17382ac36ed97 Xiaolei Wang      2024-05-13  2618  		    priv->est->max_sdu[queue] &&
bd17382ac36ed97 Xiaolei Wang      2024-05-13  2619  		    xdp_desc.len > priv->est->max_sdu[queue]) {
c5c3e1bfc9e0ee7 Rohan G Thomas    2024-01-27  2620  			priv->xstats.max_sdu_txq_drop[queue]++;
c5c3e1bfc9e0ee7 Rohan G Thomas    2024-01-27  2621  			continue;
c5c3e1bfc9e0ee7 Rohan G Thomas    2024-01-27  2622  		}
c5c3e1bfc9e0ee7 Rohan G Thomas    2024-01-27  2623  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2624  		if (likely(priv->extend_desc))
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2625  			tx_desc = (struct dma_desc *)(tx_q->dma_etx + entry);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2626  		else if (tx_q->tbs & STMMAC_TBS_AVAIL)
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2627  			tx_desc = &tx_q->dma_entx[entry].basic;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2628  		else
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2629  			tx_desc = tx_q->dma_tx + entry;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2630  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2631  		dma_addr = xsk_buff_raw_get_dma(pool, xdp_desc.addr);
1347b419318d6af Song Yoong Siang  2023-11-27  2632  		meta = xsk_buff_get_metadata(pool, xdp_desc.addr);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2633  		xsk_buff_raw_dma_sync_for_device(pool, dma_addr, xdp_desc.len);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2634  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2635  		tx_q->tx_skbuff_dma[entry].buf_type = STMMAC_TXBUF_T_XSK_TX;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2636  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2637  		/* To return XDP buffer to XSK pool, we simple call
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2638  		 * xsk_tx_completed(), so we don't need to fill up
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2639  		 * 'buf' and 'xdpf'.
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2640  		 */
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2641  		tx_q->tx_skbuff_dma[entry].buf = 0;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2642  		tx_q->xdpf[entry] = NULL;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2643  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2644  		tx_q->tx_skbuff_dma[entry].map_as_page = false;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2645  		tx_q->tx_skbuff_dma[entry].len = xdp_desc.len;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2646  		tx_q->tx_skbuff_dma[entry].last_segment = true;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2647  		tx_q->tx_skbuff_dma[entry].is_jumbo = false;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2648  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2649  		stmmac_set_desc_addr(priv, tx_desc, dma_addr);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2650  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2651  		tx_q->tx_count_frames++;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2652  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2653  		if (!priv->tx_coal_frames[queue])
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2654  			set_ic = false;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2655  		else if (tx_q->tx_count_frames % priv->tx_coal_frames[queue] == 0)
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2656  			set_ic = true;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2657  		else
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2658  			set_ic = false;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2659  
1347b419318d6af Song Yoong Siang  2023-11-27  2660  		meta_req.priv = priv;
1347b419318d6af Song Yoong Siang  2023-11-27  2661  		meta_req.tx_desc = tx_desc;
1347b419318d6af Song Yoong Siang  2023-11-27  2662  		meta_req.set_ic = &set_ic;
04f64dea13640fb Song Yoong Siang  2025-02-16  2663  		meta_req.tbs = tx_q->tbs;
04f64dea13640fb Song Yoong Siang  2025-02-16  2664  		meta_req.edesc = &tx_q->dma_entx[entry];
1347b419318d6af Song Yoong Siang  2023-11-27  2665  		xsk_tx_metadata_request(meta, &stmmac_xsk_tx_metadata_ops,
1347b419318d6af Song Yoong Siang  2023-11-27  2666  					&meta_req);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2667  		if (set_ic) {
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2668  			tx_q->tx_count_frames = 0;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2669  			stmmac_set_tx_ic(priv, tx_desc);
133466c3bbe171f Jisheng Zhang     2023-07-18  2670  			tx_set_ic_bit++;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2671  		}
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2672  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2673  		stmmac_prepare_tx_desc(priv, tx_desc, 1, xdp_desc.len,
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2674  				       true, priv->mode, true, true,
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2675  				       xdp_desc.len);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2676  
ad72f783de06827 Yanteng Si        2024-08-07  2677  		stmmac_enable_dma_transmission(priv, priv->ioaddr, queue);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2678  
1347b419318d6af Song Yoong Siang  2023-11-27  2679  		xsk_tx_metadata_to_compl(meta,
1347b419318d6af Song Yoong Siang  2023-11-27  2680  					 &tx_q->tx_skbuff_dma[entry].xsk_meta);
1347b419318d6af Song Yoong Siang  2023-11-27  2681  
8531c80800c10e8 Christian Marangi 2022-07-23  2682  		tx_q->cur_tx = STMMAC_GET_ENTRY(tx_q->cur_tx, priv->dma_conf.dma_tx_size);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2683  		entry = tx_q->cur_tx;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2684  	}
38cc3c6dcc09dc3 Petr Tesarik      2024-02-03  2685  	u64_stats_update_begin(&txq_stats->napi_syncp);
38cc3c6dcc09dc3 Petr Tesarik      2024-02-03  2686  	u64_stats_add(&txq_stats->napi.tx_set_ic_bit, tx_set_ic_bit);
38cc3c6dcc09dc3 Petr Tesarik      2024-02-03  2687  	u64_stats_update_end(&txq_stats->napi_syncp);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2688  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2689  	if (tx_desc) {
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2690  		stmmac_flush_tx_descriptors(priv, queue);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2691  		xsk_tx_release(pool);
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2692  	}
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2693  
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2694  	/* Return true if all of the 3 conditions are met
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2695  	 *  a) TX Budget is still available
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2696  	 *  b) work_done = true when XSK TX desc peek is empty (no more
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2697  	 *     pending XSK TX for transmission)
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2698  	 */
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2699  	return !!budget && work_done;
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2700  }
132c32ee5bc09b1 Ong Boon Leong    2021-04-13  2701  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-07-23  6:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 13:50 [PATCH net v2 0/2] xsk: fix underflow issues in zerocopy xmit Jason Xing
2025-07-22 13:50 ` [PATCH net v2 1/2] stmmac: xsk: fix underflow of budget in zerocopy mode Jason Xing
2025-07-22 15:03   ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-07-23  4:09   ` kernel test robot
2025-07-23  4:16     ` Jason Xing
2025-07-23  6:43   ` kernel test robot
2025-07-22 13:50 ` [PATCH net v2 2/2] igb: xsk: solve underflow of nb_pkts " Jason Xing
2025-07-22 15:03   ` [Intel-wired-lan] " Loktionov, Aleksandr
2025-07-22 23:07 ` [PATCH net v2 0/2] xsk: fix underflow issues in zerocopy xmit Jason Xing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).