netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Cc: Til Kaiser <mail@tk154.de>,
	nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com,
	lorenzo@kernel.org, netdev@vger.kernel.org, amcohen@nvidia.com,
	aleksander.lobakin@intel.com
Subject: Re: [PATCH net] mediathek: mtk_eth_soc: fix netdev inside xdp_rxq_info
Date: Wed, 27 Nov 2024 15:31:39 +0200	[thread overview]
Message-ID: <Z0cfOzsujtoxO422@shredder> (raw)
In-Reply-To: <Z0YQYKgUyLt8w4va@lore-desk>

On Tue, Nov 26, 2024 at 07:16:00PM +0100, Lorenzo Bianconi wrote:
> > 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.

Lorenzo, is it legitimate to change rxq->dev post registration like
that?

I am asking because we have a similar problem [1]. In our case we also
register the rxq structure with a dummy netdev which is why XDP programs
see an ifindex of 0.

Thanks

[1] https://lore.kernel.org/netdev/ZzYR2ZJ1mGRq12VL@shredder/

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



  reply	other threads:[~2024-11-27 13:31 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
2024-11-27 13:31     ` Ido Schimmel [this message]
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=Z0cfOzsujtoxO422@shredder \
    --to=idosch@idosch.org \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=amcohen@nvidia.com \
    --cc=lorenzo.bianconi@redhat.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;
as well as URLs for NNTP newsgroup(s).