diff mbox series

[ovs-dev,v8,6/9] netdev-afxdp: Postpone libbpf logging helper registration.

Message ID 20231027153118.580349-6-david.marchand@redhat.com
State Superseded
Headers show
Series [ovs-dev,v8,1/9] system-dpdk: Introduce helpers for testpmd. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

David Marchand Oct. 27, 2023, 3:31 p.m. UTC
When using net/af_xdp DPDK driver along OVS native AF_XDP support,
confusing logs are reported, like:

netdev_dpdk|INFO|Device 'net_af_xdpp0,iface=ovs-p0' attached to DPDK
dpif_netdev|INFO|PMD thread on numa_id: 0, core id: 11 created.
dpif_netdev|INFO|There are 1 pmd threads on numa node 0
dpdk|INFO|Device with port_id=0 already stopped
dpdk(pmd-c11/id:22)|INFO|PMD thread uses DPDK lcore 1.
netdev_dpdk|WARN|Rx checksum offload is not supported on port 0
netdev_afxdp|INFO|libbpf: elf: skipping unrecognized data section(6)
	.xdp_run_config
netdev_afxdp|INFO|libbpf: elf: skipping unrecognized data section(7)
	xdp_metadata
netdev_afxdp|INFO|libbpf: elf: skipping unrecognized data section(7)
	xdp_metadata
netdev_afxdp|INFO|libbpf: elf: skipping unrecognized data section(7)
	xdp_metadata

This comes from the fact that netdev-afxdp unconditionnally registers a
helper for logging libbpf messages.
Making both net/af_xdp and netdev-afxdp work at the same time seems
difficult, so at least, ensure that netdev-afxdp won't register this
helper unless a netdev is actually allocated.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
---
 lib/netdev-afxdp.c | 12 ++++++------
 lib/netdev-afxdp.h |  1 -
 lib/netdev-linux.c |  1 -
 3 files changed, 6 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c
index 16f26bc306..9884ccec4f 100644
--- a/lib/netdev-afxdp.c
+++ b/lib/netdev-afxdp.c
@@ -1195,18 +1195,18 @@  libbpf_print(enum libbpf_print_level level,
     return 0;
 }
 
-int netdev_afxdp_init(void)
-{
-    libbpf_set_print(libbpf_print);
-    return 0;
-}
-
 int
 netdev_afxdp_construct(struct netdev *netdev)
 {
+    static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
     struct netdev_linux *dev = netdev_linux_cast(netdev);
     int ret;
 
+    if (ovsthread_once_start(&once)) {
+        libbpf_set_print(libbpf_print);
+        ovsthread_once_done(&once);
+    }
+
     /* Configure common netdev-linux first. */
     ret = netdev_linux_construct(netdev);
     if (ret) {
diff --git a/lib/netdev-afxdp.h b/lib/netdev-afxdp.h
index e91cd102d2..6c5459f6e6 100644
--- a/lib/netdev-afxdp.h
+++ b/lib/netdev-afxdp.h
@@ -47,7 +47,6 @@  struct xsk_socket_info;
 
 int netdev_afxdp_rxq_construct(struct netdev_rxq *rxq_);
 void netdev_afxdp_rxq_destruct(struct netdev_rxq *rxq_);
-int netdev_afxdp_init(void);
 int netdev_afxdp_construct(struct netdev *netdev_);
 void netdev_afxdp_destruct(struct netdev *netdev_);
 int netdev_afxdp_verify_mtu_size(const struct netdev *netdev, int mtu);
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index cca3408797..4538cdfe63 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -3754,7 +3754,6 @@  const struct netdev_class netdev_internal_class = {
 
 #ifdef HAVE_AF_XDP
 #define NETDEV_AFXDP_CLASS_COMMON                               \
-    .init = netdev_afxdp_init,                                  \
     .construct = netdev_afxdp_construct,                        \
     .destruct = netdev_afxdp_destruct,                          \
     .get_stats = netdev_afxdp_get_stats,                        \