net: xilinx: axienet: Fix packet counting
PATCH v2 1/1 net: xilinx: axienet: Fix packet counting
axienet_free_tx_chain returns the number of DMA descriptors it's handled. However, axienet_tx_poll treats the return as the number of packets. When scatter-gather SKBs are enabled, a single packet may use multiple DMA descriptors, which causes incorrect packet counts. Fix this by explicitly keepting track of the number of packets processed as separate from the DMA descriptors.
---
Changes in v2:
- Only call napi_consume_skb with non-zero budget when force is false
.../net/ethernet/xilinx/xilinx_axienet_main.c | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +18 -13
@@ -670,21 +670,21 @@ static int axienet_device_reset(struct net_device *ndev)* @force: Whether to clean descriptors even if not complete * @sizep: Pointer to a u32 filled with the total sum of all bytes * in all cleaned-up descriptors. Ignored if NULL. -* @budget: NAPI budget (use 0 when not called from NAPI poll) +* @budget: NAPI budget (use INT_MAX when not called from NAPI poll) * * Would either be called after a successful transmit operation, or after * there was an error when setting up the chain. -* Returns the number of descriptors handled. +* Returns the number of packets handled. */ static int axienet_free_tx_chain (struct axienet_local *lp,u32 first_bd,int nr_bds,bool force,u32 *sizep,int budget) {struct axidma_bd *cur_p;unsigned int status; +int i, packets =0 ;dma_addr_t phys; -int i; -for (i =0 ; i < nr_bds; i++) { +for (i =0 ; i < nr_bds && packets < budget; i++) { cur_p = &lp->tx_bd_v[(first_bd + i) % lp->tx_bd_num]; status = cur_p->status;
@@ -701,8 +701,10 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, (cur_p->cntrl &XAXIDMA_BD_CTRL_LENGTH_MASK ), DMA_TO_DEVICE); -if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) -napi_consume_skb (cur_p->skb, budget); +if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) { +napi_consume_skb (cur_p->skb, force ?0 : budget); + packets++; + } cur_p->app0 =0 ; cur_p->app1 =0 ;
@@ -718,7 +720,13 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, *sizep += status &XAXIDMA_BD_STS_ACTUAL_LEN_MASK ; } -return i; +if (!force) { + lp->tx_bd_ci += i; +if (lp->tx_bd_ci >= lp->tx_bd_num) + lp->tx_bd_ci %= lp->tx_bd_num; + } + +return packets; }/**
@@ -891,13 +899,10 @@ static int axienet_tx_poll(struct napi_struct *napi, int budget)u32 size =0 ;int packets; - packets =axienet_free_tx_chain (lp, lp->tx_bd_ci, budget, false, &size, budget); + packets =axienet_free_tx_chain (lp, lp->tx_bd_ci, lp->tx_bd_num, false, + &size, budget);if (packets) { - lp->tx_bd_ci += packets; -if (lp->tx_bd_ci >= lp->tx_bd_num) - lp->tx_bd_ci %= lp->tx_bd_num; -u64_stats_update_begin (&lp->tx_stat_sync);u64_stats_add (&lp->tx_packets, packets);u64_stats_add (&lp->tx_bytes, size);
@@ -1003,7 +1008,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)netdev_err (ndev,"TX DMA mapping error\n" ); ndev->stats.tx_dropped++;axienet_free_tx_chain (lp, orig_tail_ptr, ii +1 , - true,NULL ,0 ); + true,NULL ,INT_MAX );return NETDEV_TX_OK ; }desc_set_phys_addr (lp, phys, cur_p);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
Pandey, Radhey Shyam
maintainerQuoted 13 lines
-----Original Message-----
From: Sean Anderson <[email protected]>
Sent: Friday, September 6, 2024 10:12 PM
To: Pandey, Radhey Shyam <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]
Cc: Simek, Michal <[email protected]>; linux-arm- [email protected]; [email protected]; Andy Chiu <[email protected]>; Daniel Borkmann <[email protected]>; Sean Anderson <[email protected]>
Subject: [PATCH net v2] net: xilinx: axienet: Fix packet counting
Quoted 8 lines
axienet_free_tx_chainreturns the number of DMA descriptors it's handled. However,axienet_tx_polltreats the return as the number of packets. When scatter-gather SKBs are enabled, a single packet may use multiple DMA descriptors, which causes incorrect packet counts. Fix this by explicitly keepting track of the number of packets processed as separate from the DMA descriptors.Fixes 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet
Isn't it Fixes: 9e2bc267e780 ("net: axienet: Use NAPI for TX completion path")?
Quoted 2 lines
driver")
Signed-off-by Sean Anderson <[email protected]>
+ Harini, Suraj to review and run this patch to ensure data path sanity.
Quoted 59 lines
---
Changes in v2:
- Only callnapi_consume_skbwith non-zero budget when force is false.../net/ethernet/xilinx/xilinx_axienet_main.c | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-)drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-4@@ -670,21 +670,21 @@ static int axienet_device_reset(struct net_device*ndev) * @force: Whether to clean descriptors even if not complete * @sizep: Pointer to a u32 filled with the total sum of all bytes * in all cleaned-up descriptors. Ignored if NULL. -* @budget: NAPI budget (use 0 when not called from NAPI poll) +* @budget: NAPI budget (use INT_MAX when not called from NAPI poll) * * Would either be called after a successful transmit operation, or after * there was an error when setting up the chain. -* Returns the number of descriptors handled. +* Returns the number of packets handled. */ static int axienet_free_tx_chain (struct axienet_local *lp,u32 first_bd,int nr_bds,bool force,u32 *sizep,int budget) {struct axidma_bd *cur_p;unsigned int status; +int i, packets =0 ;dma_addr_t phys; -int i; -for (i =0 ; i < nr_bds; i++) { +for (i =0 ; i < nr_bds && packets < budget; i++) { cur_p = &lp->tx_bd_v[(first_bd + i) % lp->tx_bd_num];drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-2status = cur_p->status;@@ -701,8 +701,10 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, (cur_p->cntrl &XAXIDMA_BD_CTRL_LENGTH_MASK ), DMA_TO_DEVICE); -if (cur_p->skb && (status & XAXIDMA_BD_STS_COMPLETE_MASK)) -napi_consume_skb (cur_p->skb, budget); + if (cur_p->skb && (status &
XAXIDMA_BD_STS_COMPLETE_MASK)) {drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-0+napi_consume_skb (cur_p->skb, force ?0 : budget); + packets++; + } cur_p->app0 =0 ; cur_p->app1 =0 ;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_free_tx_chain(struct axienet_local · line 725
Quoted 7 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1@@ -718,7 +720,13 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, *sizep += status &XAXIDMA_BD_STS_ACTUAL_LEN_MASK ; } -return i; +if (!force) {
Is tx_bd_ci increment dependent on force state and not done if force == true ?
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-0+ lp->tx_bd_ci += i; +if (lp->tx_bd_ci >= lp->tx_bd_num) + lp->tx_bd_ci %= lp->tx_bd_num; + } + +return packets; }/**
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_tx_poll(struct napi_struct *napi, · line 904
Quoted 7 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1@@ -891,13 +899,10 @@ static int axienet_tx_poll(struct napi_struct *napi, int budget) u32 size = 0;int packets; - packets =axienet_free_tx_chain (lp, lp->tx_bd_ci, budget, false, &size, budget); + packets = axienet_free_tx_chain(lp, lp->tx_bd_ci, lp->tx_bd_num,
Why do we need to pass tx_bd_num here? Is budget not sufficient?
Quoted 24 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-4false, + &size, budget);if (packets) { - lp->tx_bd_ci += packets; -if (lp->tx_bd_ci >= lp->tx_bd_num) - lp->tx_bd_ci %= lp->tx_bd_num; -drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1u64_stats_update_begin (&lp->tx_stat_sync);u64_stats_add (&lp->tx_packets, packets);u64_stats_add (&lp->tx_bytes, size);@@ -1003,7 +1008,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) netdev_err(ndev, "TX DMA mapping error\n"); ndev->stats.tx_dropped++; axienet_free_tx_chain(lp, orig_tail_ptr, ii + 1, - true, NULL, 0); + true, NULL, INT_MAX);return NETDEV_TX_OK ;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-1}desc_set_phys_addr (lp, phys, cur_p); --2.35.1.1320.gc452695387.dirty
Quoted 20 lines · Radhey Shyam
Quoted 20 lines
-----Original Message-----
From: Sean Anderson <[email protected]>
Sent: Friday, September 6, 2024 10:12 PM
To: Pandey, Radhey Shyam <[email protected]>; David S . Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; [email protected]
Cc: Simek, Michal <[email protected]>; linux-arm- [email protected]; [email protected]; Andy Chiu <[email protected]>; Daniel Borkmann <[email protected]>; Sean Anderson <[email protected]>
Subject: [PATCH net v2] net: xilinx: axienet: Fix packet counting
axienet_free_tx_chainreturns the number of DMA descriptors it's handled. However,axienet_tx_polltreats the return as the number of packets. When scatter-gather SKBs are enabled, a single packet may use multiple DMA descriptors, which causes incorrect packet counts. Fix this by explicitly keepting track of the number of packets processed as separate from the DMA descriptors.
Quoted 3 lines
Quoted 1 line
Fixes 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI EthernetIsn't it Fixes:
9e2bc267e780("net: axienet: Use NAPI for TX completion path")?
No. The packet count is also used for statistics, and this confusion has been present since the original commit.
Quoted 69 lines
Quoted 2 lines
driver")
Signed-off-by Sean Anderson <[email protected]>+ Harini, Suraj to review and run this patch to ensure data path sanity.
Quoted 64 lines
---
Changes in v2:
- Only callnapi_consume_skbwith non-zero budget when force is false.../net/ethernet/xilinx/xilinx_axienet_main.c | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-)drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-4@@ -670,21 +670,21 @@ static int axienet_device_reset(struct net_device*ndev) * @force: Whether to clean descriptors even if not complete * @sizep: Pointer to a u32 filled with the total sum of all bytes * in all cleaned-up descriptors. Ignored if NULL. -* @budget: NAPI budget (use 0 when not called from NAPI poll) +* @budget: NAPI budget (use INT_MAX when not called from NAPI poll) * * Would either be called after a successful transmit operation, or after * there was an error when setting up the chain. -* Returns the number of descriptors handled. +* Returns the number of packets handled. */ static int axienet_free_tx_chain (struct axienet_local *lp,u32 first_bd,int nr_bds,bool force,u32 *sizep,int budget) {struct axidma_bd *cur_p;unsigned int status; +int i, packets =0 ;dma_addr_t phys; -int i; -for (i =0 ; i < nr_bds; i++) { +for (i =0 ; i < nr_bds && packets < budget; i++) { cur_p = &lp->tx_bd_v[(first_bd + i) % lp->tx_bd_num];drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-2status = cur_p->status;@@ -701,8 +701,10 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, (cur_p->cntrl &XAXIDMA_BD_CTRL_LENGTH_MASK ), DMA_TO_DEVICE); -if (cur_p->skb && (status & XAXIDMA_BD_STS_COMPLETE_MASK)) -napi_consume_skb (cur_p->skb, budget); + if (cur_p->skb && (status &
XAXIDMA_BD_STS_COMPLETE_MASK)) {drivers/net/ethernet/xilinx/xilinx_axienet_main.c +3
-0+napi_consume_skb (cur_p->skb, force ?0 : budget); + packets++; + } cur_p->app0 =0 ; cur_p->app1 =0 ;@@ -718,7 +720,13 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, *sizep += status &XAXIDMA_BD_STS_ACTUAL_LEN_MASK ; }
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, · line 723
Quoted 2 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1-return i; +if (!force) {Is
tx_bd_ciincrement dependent on force state and not done if force == true ?
No. "force" is used in the error path of axienet_start_xmit to free unsent descriptors. So in that case, once everything is done, tx_bd_ci will be the same as before axienet_start_xmit is called.
Quoted 14 lines
Quoted 14 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +6
-0+ lp->tx_bd_ci += i; +if (lp->tx_bd_ci >= lp->tx_bd_num) + lp->tx_bd_ci %= lp->tx_bd_num; + } + +return packets; }/**
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0@@ -891,13 +899,10 @@ static int axienet_tx_poll(struct napi_struct *napi, int budget) u32 size = 0;int packets;
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_tx_poll(struct napi_struct *napi, · line 904
Quoted 3 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1- packets =axienet_free_tx_chain (lp, lp->tx_bd_ci, budget, false, &size, budget); + packets = axienet_free_tx_chain(lp, lp->tx_bd_ci, lp->tx_bd_num,Why do we need to pass
tx_bd_numhere? Is budget not sufficient?
Imagine if the user sets the TX ring to 1 packet. On completion, we will consume the SKB. Then we will enter an infinite loop as we will still have budget for more packets but we will keep checking the same descriptor for more packets. By setting a maximum descriptor count we ensure that we only go through the TX ring once.
--Sean
Quoted 25 lines
Quoted 24 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-4false, + &size, budget);if (packets) { - lp->tx_bd_ci += packets; -if (lp->tx_bd_ci >= lp->tx_bd_num) - lp->tx_bd_ci %= lp->tx_bd_num; -drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1u64_stats_update_begin (&lp->tx_stat_sync);u64_stats_add (&lp->tx_packets, packets);u64_stats_add (&lp->tx_bytes, size);@@ -1003,7 +1008,7 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev) netdev_err(ndev, "TX DMA mapping error\n"); ndev->stats.tx_dropped++; axienet_free_tx_chain(lp, orig_tail_ptr, ii + 1, - true, NULL, 0); + true, NULL, INT_MAX);return NETDEV_TX_OK ;drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-1}desc_set_phys_addr (lp, phys, cur_p); --2.35.1.1320.gc452695387.dirty
Jakub Kicinski
maintainerQuoted 15 lines · On Fri, 6 Sep 2024 12:42:27 -0400 Sean Anderson wrote:
axienet_free_tx_chainreturns the number of DMA descriptors it's handled. However,axienet_tx_polltreats the return as the number of packets. When scatter-gather SKBs are enabled, a single packet may use multiple DMA descriptors, which causes incorrect packet counts. Fix this by explicitly keepting track of the number of packets processed as separate from the DMA descriptors.Fixes 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver")Signed-off-by Sean Anderson <[email protected]>drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_device_reset(struct net_device *ndev) · line 673
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1@@ -670,21 +670,21 @@ static int axienet_device_reset(struct net_device *ndev)* @force: Whether to clean descriptors even if not complete * @sizep: Pointer to a u32 filled with the total sum of all bytes * in all cleaned-up descriptors. Ignored if NULL. -* @budget: NAPI budget (use 0 when not called from NAPI poll) +* @budget: NAPI budget (use INT_MAX when not called from NAPI poll)
use INT_MAX and force=true when ... ?
To make sure the dependency is clear.
But actually...
Quoted 7 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1* * Would either be called after a successful transmit operation, or after * there was an error when setting up the chain. -* Returns the number of descriptors handled. +* Returns the number of packets handled. */ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd,
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_device_reset(struct net_device *ndev) · line 687
Quoted 10 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-2int nr_bds, bool force, u32 *sizep, int budget) { struct axidma_bd *cur_p;unsigned int status; +int i, packets =0 ;dma_addr_t phys; -int i; -for (i =0 ; i < nr_bds; i++) { +for (i =0 ; i < nr_bds && packets < budget; i++) {
why are you doing this? To make sure drivers doesn't complete more than "budget" Tx skbs? The budget is really for Rx, for Tx you can use a reasonable fixed value, independent of what budget core passes in, e.g. 128. See:
https://www.kernel.org/doc/html/next/networking/napi.html#datapath-api
Quoted 17 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-2cur_p = &lp->tx_bd_v[(first_bd + i) % lp->tx_bd_num]; status = cur_p->status;@@ -701,8 +701,10 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, (cur_p->cntrl &XAXIDMA_BD_CTRL_LENGTH_MASK ), DMA_TO_DEVICE); -if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) -napi_consume_skb (cur_p->skb, budget); +if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) { +napi_consume_skb (cur_p->skb, force ?0 : budget); + packets++; + } cur_p->app0 =0 ; cur_p->app1 =0 ;
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, · line 727
Quoted 9 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5
-1@@ -718,7 +720,13 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, *sizep += status &XAXIDMA_BD_STS_ACTUAL_LEN_MASK ; } -return i; +if (!force) { + lp->tx_bd_ci += i; +if (lp->tx_bd_ci >= lp->tx_bd_num) + lp->tx_bd_ci %= lp->tx_bd_num; + }
Moving this chunk into axienet_free_tx_chain() is a noop, right? Please avoid code cleanups in fixes.
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-0+return packets; }/**
Signature · 1 line
pw-bot: cr
Quoted 41 lines · Jakub Kicinski
Quoted 15 lines · On Fri, 6 Sep 2024 12:42:27 -0400 Sean Anderson wrote:
axienet_free_tx_chainreturns the number of DMA descriptors it's handled. However,axienet_tx_polltreats the return as the number of packets. When scatter-gather SKBs are enabled, a single packet may use multiple DMA descriptors, which causes incorrect packet counts. Fix this by explicitly keepting track of the number of packets processed as separate from the DMA descriptors.Fixes 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver")Signed-off-by Sean Anderson <[email protected]>drivers/net/ethernet/xilinx/xilinx_axienet_main.c +0
-0drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_device_reset(struct net_device *ndev) · line 673
Quoted 5 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1@@ -670,21 +670,21 @@ static int axienet_device_reset(struct net_device *ndev)* @force: Whether to clean descriptors even if not complete * @sizep: Pointer to a u32 filled with the total sum of all bytes * in all cleaned-up descriptors. Ignored if NULL. -* @budget: NAPI budget (use 0 when not called from NAPI poll) +* @budget: NAPI budget (use INT_MAX when not called from NAPI poll) use
INT_MAXand force=true when ... ?
To make sure the dependency is clear.
But actually...Quoted 15 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +2
-2* * Would either be called after a successful transmit operation, or after * there was an error when setting up the chain. -* Returns the number of descriptors handled. +* Returns the number of packets handled. */ static int axienet_free_tx_chain (struct axienet_local *lp,u32 first_bd,int nr_bds,bool force,u32 *sizep,int budget) {struct axidma_bd *cur_p;unsigned int status; +int i, packets =0 ;dma_addr_t phys; -int i;
Quoted 8 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_device_reset(struct net_device *ndev) · line 687
Quoted 2 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-1-for (i =0 ; i < nr_bds; i++) { +for (i =0 ; i < nr_bds && packets < budget; i++) {why are you doing this? To make sure drivers doesn't complete more than "budget" Tx skbs? The budget is really for Rx, for Tx you can use a reasonable fixed value, independent of what budget core passes in, e.g. 128. See:
https://www.kernel.org/doc/html/next/networking/napi.html#datapath-api
I read this but it was unclear to me because it seems oriented towards "combined" NAPI instances, while we have separate instances for RX and TX. So even for TX-only instances, we can ignore budget?
Quoted 20 lines
Quoted 20 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +4
-2cur_p = &lp->tx_bd_v[(first_bd + i) % lp->tx_bd_num]; status = cur_p->status;@@ -701,8 +701,10 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, (cur_p->cntrl &XAXIDMA_BD_CTRL_LENGTH_MASK ), DMA_TO_DEVICE); -if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) -napi_consume_skb (cur_p->skb, budget); +if (cur_p->skb && (status &XAXIDMA_BD_STS_COMPLETE_MASK )) { +napi_consume_skb (cur_p->skb, force ?0 : budget); + packets++; + } cur_p->app0 =0 ; cur_p->app1 =0 ;@@ -718,7 +720,13 @@ static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, *sizep += status &XAXIDMA_BD_STS_ACTUAL_LEN_MASK ; }
Quoted 9 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c static int axienet_free_tx_chain(struct axienet_local *lp, u32 first_bd, · line 727
Quoted 6 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +5
-1-return i; +if (!force) { + lp->tx_bd_ci += i; +if (lp->tx_bd_ci >= lp->tx_bd_num) + lp->tx_bd_ci %= lp->tx_bd_num; + }Moving this chunk into
axienet_free_tx_chain()is a noop, right? Please avoid code cleanups in fixes.
The relevant variable (number of descriptors handled) is no longer returned to axienet_tx_poll, so it can't update the current descriptor properly.
--Sean
Quoted 4 lines
Quoted 4 lines
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1
-0+return packets; }/**
Jakub Kicinski
maintainerQuoted 9 lines · On Tue, 10 Sep 2024 10:24:36 -0400 Sean Anderson wrote:
Quoted 5 lines
why are you doing this? To make sure drivers doesn't complete more than "budget" Tx skbs? The budget is really for Rx, for Tx you can use a reasonable fixed value, independent of what budget core passes in, e.g. 128. See:
https://www.kernel.org/doc/html/next/networking/napi.html#datapath-apiI read this but it was unclear to me because it seems oriented towards "combined" NAPI instances, while we have separate instances for RX and TX. So even for TX-only instances, we can ignore budget?
Yes, combined or dedicated it should still reap completions regardless of budget.
Quoted 6 lines
Quoted 2 lines
Moving this chunk into
axienet_free_tx_chain()is a noop, right? Please avoid code cleanups in fixes.The relevant variable (number of descriptors handled) is no longer returned to
axienet_tx_poll, so it can't update the current descriptor properly.
Got it, worth mentioning in the commit msg.