public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: fec: add exception tracing for XDP
@ 2023-08-22  6:52 Wei Fang
  2023-08-23 19:44 ` Jacob Keller
  2023-08-24  2:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Wei Fang @ 2023-08-22  6:52 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, ast, daniel, hawk, john.fastabend,
	shenwei.wang, xiaoning.wang, netdev
  Cc: linux-kernel, bpf, linux-imx

As we already added the exception tracing for XDP_TX, I think it is
necessary to add the exception tracing for other XDP actions, such
as XDP_REDIRECT, XDP_ABORTED and unknown error actions.

Signed-off-by: Wei Fang <wei.fang@nxp.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/freescale/fec_main.c | 26 ++++++++++-------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index e23a55977183..8909899e9a31 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1583,25 +1583,18 @@ fec_enet_run_xdp(struct fec_enet_private *fep, struct bpf_prog *prog,
 	case XDP_REDIRECT:
 		rxq->stats[RX_XDP_REDIRECT]++;
 		err = xdp_do_redirect(fep->netdev, xdp, prog);
-		if (!err) {
-			ret = FEC_ENET_XDP_REDIR;
-		} else {
-			ret = FEC_ENET_XDP_CONSUMED;
-			page = virt_to_head_page(xdp->data);
-			page_pool_put_page(rxq->page_pool, page, sync, true);
-		}
+		if (unlikely(err))
+			goto xdp_err;
+
+		ret = FEC_ENET_XDP_REDIR;
 		break;
 
 	case XDP_TX:
 		err = fec_enet_xdp_tx_xmit(fep, cpu, xdp, sync);
-		if (unlikely(err)) {
-			ret = FEC_ENET_XDP_CONSUMED;
-			page = virt_to_head_page(xdp->data);
-			page_pool_put_page(rxq->page_pool, page, sync, true);
-			trace_xdp_exception(fep->netdev, prog, act);
-		} else {
-			ret = FEC_ENET_XDP_TX;
-		}
+		if (unlikely(err))
+			goto xdp_err;
+
+		ret = FEC_ENET_XDP_TX;
 		break;
 
 	default:
@@ -1613,9 +1606,12 @@ fec_enet_run_xdp(struct fec_enet_private *fep, struct bpf_prog *prog,
 
 	case XDP_DROP:
 		rxq->stats[RX_XDP_DROP]++;
+xdp_err:
 		ret = FEC_ENET_XDP_CONSUMED;
 		page = virt_to_head_page(xdp->data);
 		page_pool_put_page(rxq->page_pool, page, sync, true);
+		if (act != XDP_DROP)
+			trace_xdp_exception(fep->netdev, prog, act);
 		break;
 	}
 
-- 
2.25.1


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

* Re: [PATCH net-next] net: fec: add exception tracing for XDP
  2023-08-22  6:52 [PATCH net-next] net: fec: add exception tracing for XDP Wei Fang
@ 2023-08-23 19:44 ` Jacob Keller
  2023-08-24  2:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Jacob Keller @ 2023-08-23 19:44 UTC (permalink / raw)
  To: Wei Fang, davem, edumazet, kuba, pabeni, ast, daniel, hawk,
	john.fastabend, shenwei.wang, xiaoning.wang, netdev
  Cc: linux-kernel, bpf, linux-imx



On 8/21/2023 11:52 PM, Wei Fang wrote:
> As we already added the exception tracing for XDP_TX, I think it is
> necessary to add the exception tracing for other XDP actions, such
> as XDP_REDIRECT, XDP_ABORTED and unknown error actions.
> 
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> ---

Makes sense to me, and it ends up being a bit less code.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

>  drivers/net/ethernet/freescale/fec_main.c | 26 ++++++++++-------------
>  1 file changed, 11 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index e23a55977183..8909899e9a31 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1583,25 +1583,18 @@ fec_enet_run_xdp(struct fec_enet_private *fep, struct bpf_prog *prog,
>  	case XDP_REDIRECT:
>  		rxq->stats[RX_XDP_REDIRECT]++;
>  		err = xdp_do_redirect(fep->netdev, xdp, prog);
> -		if (!err) {
> -			ret = FEC_ENET_XDP_REDIR;
> -		} else {
> -			ret = FEC_ENET_XDP_CONSUMED;
> -			page = virt_to_head_page(xdp->data);
> -			page_pool_put_page(rxq->page_pool, page, sync, true);
> -		}
> +		if (unlikely(err))
> +			goto xdp_err;
> +
> +		ret = FEC_ENET_XDP_REDIR;
>  		break;
>  
>  	case XDP_TX:
>  		err = fec_enet_xdp_tx_xmit(fep, cpu, xdp, sync);
> -		if (unlikely(err)) {
> -			ret = FEC_ENET_XDP_CONSUMED;
> -			page = virt_to_head_page(xdp->data);
> -			page_pool_put_page(rxq->page_pool, page, sync, true);
> -			trace_xdp_exception(fep->netdev, prog, act);
> -		} else {
> -			ret = FEC_ENET_XDP_TX;
> -		}
> +		if (unlikely(err))
> +			goto xdp_err;
> +
> +		ret = FEC_ENET_XDP_TX;
>  		break;
>  
>  	default:
> @@ -1613,9 +1606,12 @@ fec_enet_run_xdp(struct fec_enet_private *fep, struct bpf_prog *prog,
>  
>  	case XDP_DROP:
>  		rxq->stats[RX_XDP_DROP]++;
> +xdp_err:
>  		ret = FEC_ENET_XDP_CONSUMED;
>  		page = virt_to_head_page(xdp->data);
>  		page_pool_put_page(rxq->page_pool, page, sync, true);

Ok, so we handle the cleaning up of the page and such here, which is
shared for both paths now. Nice!

> +		if (act != XDP_DROP)
> +			trace_xdp_exception(fep->netdev, prog, act);
>  		break;
>  	}
>  

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

* Re: [PATCH net-next] net: fec: add exception tracing for XDP
  2023-08-22  6:52 [PATCH net-next] net: fec: add exception tracing for XDP Wei Fang
  2023-08-23 19:44 ` Jacob Keller
@ 2023-08-24  2:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-24  2:30 UTC (permalink / raw)
  To: Wei Fang
  Cc: davem, edumazet, kuba, pabeni, ast, daniel, hawk, john.fastabend,
	shenwei.wang, xiaoning.wang, netdev, linux-kernel, bpf, linux-imx

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 22 Aug 2023 14:52:55 +0800 you wrote:
> As we already added the exception tracing for XDP_TX, I think it is
> necessary to add the exception tracing for other XDP actions, such
> as XDP_REDIRECT, XDP_ABORTED and unknown error actions.
> 
> Signed-off-by: Wei Fang <wei.fang@nxp.com>
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> 
> [...]

Here is the summary with links:
  - [net-next] net: fec: add exception tracing for XDP
    https://git.kernel.org/netdev/net-next/c/e83fabb797b9

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-08-24  2:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22  6:52 [PATCH net-next] net: fec: add exception tracing for XDP Wei Fang
2023-08-23 19:44 ` Jacob Keller
2023-08-24  2:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox