Move the registration of dpif_offload_dpdk_class from the compile-time
static array in dpif-offload.c to an explicit call in dpdk_init__().
This mirrors how netdev_dpdk_register() is already called and eliminates
a link-time dependency from libopenvswitch objects on DPDK-specific
object files.

Make dpif_offload_register_provider() non-static so it can be called
from dpdk.c.

This is a prerequisite for isolating DPDK linking to ovs-vswitchd only,
as the static array reference would otherwise require a stub definition
for dpif_offload_dpdk_class in all non-vswitchd binaries.

Reported-at: https://issues.redhat.com/browse/FDP-3277
Cc: Eelco Chaudron <[email protected]>
Signed-off-by: Timothy Redaelli <[email protected]>
---
 lib/dpdk.c                  | 2 ++
 lib/dpif-offload-provider.h | 1 +
 lib/dpif-offload.c          | 5 +----
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/dpdk.c b/lib/dpdk.c
index d27b95cd9..b1059418f 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -29,6 +29,7 @@
 #include <rte_version.h>
 
 #include "dirs.h"
+#include "dpif-offload-provider.h"
 #include "fatal-signal.h"
 #include "netdev-dpdk.h"
 #include "openvswitch/dynamic-string.h"
@@ -506,6 +507,7 @@ dpdk_init__(const struct smap *ovs_other_config)
     RTE_PER_LCORE(_lcore_id) = NON_PMD_CORE_ID;
 
     /* Finally, register the dpdk classes */
+    dpif_offload_register_provider(&dpif_offload_dpdk_class);
     netdev_dpdk_register(ovs_other_config);
     return true;
 }
diff --git a/lib/dpif-offload-provider.h b/lib/dpif-offload-provider.h
index 02ef46cb0..ed14e9b68 100644
--- a/lib/dpif-offload-provider.h
+++ b/lib/dpif-offload-provider.h
@@ -353,6 +353,7 @@ struct dpif_offload_port 
*dpif_offload_port_mgr_find_by_odp_port(
     CMAP_FOR_EACH (PORT, odp_port_node, &(OFFLOAD)->ports->odp_port_to_port)
 
 /* Global functions, called by the dpif layer or offload providers. */
+int dpif_offload_register_provider(const struct dpif_offload_class *);
 void dpif_offload_module_init(void);
 void dpif_offload_set_config(struct dpif *, const struct smap *other_cfg);
 void dpif_offload_port_add(struct dpif *, struct netdev *, odp_port_t);
diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c
index bb2feced9..4bdd9bd3e 100644
--- a/lib/dpif-offload.c
+++ b/lib/dpif-offload.c
@@ -44,9 +44,6 @@ static struct shash dpif_offload_providers \
 static const struct dpif_offload_class *base_dpif_offload_classes[] = {
 #if defined(__linux__)
     &dpif_offload_tc_class,
-#endif
-#ifdef DPDK_NETDEV
-    &dpif_offload_dpdk_class,
 #endif
     /* While adding a new offload class to this structure make sure to also
      * update the dpif_offload_provider_priority_list below. */
@@ -90,7 +87,7 @@ dpif_offload_register_provider__(const struct 
dpif_offload_class *class)
     return 0;
 }
 
-static int
+int
 dpif_offload_register_provider(const struct dpif_offload_class *class)
 {
     int error;
-- 
2.53.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to