Netdev List
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Til Kaiser <mail@tk154.de>
Cc: nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com,
	lorenzo@kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net] mediathek: mtk_eth_soc: fix netdev inside xdp_rxq_info
Date: Tue, 26 Nov 2024 19:16:00 +0100	[thread overview]
Message-ID: <Z0YQYKgUyLt8w4va@lore-desk> (raw)
In-Reply-To: <20241126134707.253572-2-mail@tk154.de>

[-- Attachment #1: Type: text/plain, Size: 1814 bytes --]

> Currently, the network device isn't set inside the xdp_rxq_info
> of the mtk_rx_ring, which means that an XDP program attached to
> the Mediathek ethernet driver cannot retrieve the index of the
> interface that received the package since it's always 0 inside
> the xdp_md struct.
> 
> This patch sets the network device pointer inside the
> xdp_rxq_info struct, which is later used to initialize
> the xdp_buff struct via xdp_init_buff.
> 
> This was tested using the following eBPF/XDP program attached
> to a network interface of the mtk_eth_soc driver. As said before,
> ingress_ifindex always had a value of zero. After applying the
> patch, ingress_ifindex holds the correct interface index.
> 
> 	#include <linux/bpf.h>
> 	#include <bpf/bpf_helpers.h>
> 
> 	SEC("pass")
> 	int pass_func(struct xdp_md *xdp) {
>     		bpf_printk("ingress_ifindex: %u",
> 			xdp->ingress_ifindex);
> 
> 		return XDP_PASS;
> 	}
> 
> 	char _license[] SEC("license") = "GPL";
> 
> Signed-off-by: Til Kaiser <mail@tk154.de>
> ---
>  drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 53485142938c..9c6d4477e536 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -2069,6 +2069,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
>  
>  		netdev = eth->netdev[mac];
>  		ppe_idx = eth->mac[mac]->ppe_idx;
> +		ring->xdp_q.dev = netdev;

I guess you can set it just before running xdp_init_buff(), but the change is fine.

Regards,
Lorenzo

>  
>  		if (unlikely(test_bit(MTK_RESETTING, &eth->state)))
>  			goto release_desc;
> -- 
> 2.47.1
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2024-11-26 18:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-26 13:41 [PATCH net] mediathek: mtk_eth_soc: fix netdev inside xdp_rxq_info Til Kaiser
2024-11-26 13:41 ` Til Kaiser
2024-11-26 18:16   ` Lorenzo Bianconi [this message]
2024-11-27 13:31     ` Ido Schimmel
2024-11-27 14:30       ` Lorenzo Bianconi
2024-12-03  3:16   ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z0YQYKgUyLt8w4va@lore-desk \
    --to=lorenzo.bianconi@redhat.com \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=lorenzo@kernel.org \
    --cc=mail@tk154.de \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=sean.wang@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox