netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Til Kaiser <mail@tk154.de>
To: nbd@nbd.name, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com,
	lorenzo@kernel.org
Cc: netdev@vger.kernel.org, Til Kaiser <mail@tk154.de>
Subject: [PATCH net] mediathek: mtk_eth_soc: fix netdev inside xdp_rxq_info
Date: Tue, 26 Nov 2024 14:41:54 +0100	[thread overview]
Message-ID: <20241126134707.253572-2-mail@tk154.de> (raw)
In-Reply-To: <20241126134707.253572-1-mail@tk154.de>

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;
 
 		if (unlikely(test_bit(MTK_RESETTING, &eth->state)))
 			goto release_desc;
-- 
2.47.1


  reply	other threads:[~2024-11-26 13:48 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 [this message]
2024-11-26 18:16   ` Lorenzo Bianconi
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=20241126134707.253572-2-mail@tk154.de \
    --to=mail@tk154.de \
    --cc=Mark-MC.Lee@mediatek.com \
    --cc=lorenzo@kernel.org \
    --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).