| Message ID | 977fd3b956d811a8b4cb54d41499ccf0ad788fbd.1762950453.git.echaudro@redhat.com |
|---|---|
| State | Changes Requested |
| Headers | show |
| Series | Architectural refactoring of hardware offload infrastructure | expand |
| Context | Check | Description |
|---|---|---|
| ovsrobot/apply-robot | success | apply and check: success |
| ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
| ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
commit d1e3f88b92c4a5e6d7f8a9b0c1d2e3f4a5b6c7d8 Author: Eelco Chaudron <echaudro@redhat.com> dpif-offload: Add provider for dpdk (rte_flow). This patch adds the dpdk offload provider framework. > diff --git a/lib/automake.mk b/lib/automake.mk > index 6e015ebfc..6db7daa9f 100644 > --- a/lib/automake.mk > +++ b/lib/automake.mk > @@ -507,6 +507,7 @@ endif > if DPDK_NETDEV > lib_libopenvswitch_la_SOURCES += \ > lib/dpdk.c \ > + lib/dpif-offload-dpdk.c \ > lib/netdev-dpdk.c \ > lib/netdev-offload-dpdk.c > else > diff --git a/lib/dpif-offload-dpdk.c b/lib/dpif-offload-dpdk.c > new file mode 100644 > index 000000000..03c8f6492 > --- /dev/null > +++ b/lib/dpif-offload-dpdk.c [ ... ] > +static int > +dpif_offload_dpdk_open(const struct dpif_offload_class *offload_class, > + struct dpif *dpif, struct dpif_offload **dpif_offload) > +{ > + struct dpif_offload *offload = xmalloc(sizeof(struct dpif_offload)); > + > + dpif_offload_init(offload, offload_class, dpif); > + *dpif_offload = offload; > + return 0; > +} Does this function properly handle initialization failures? The call to dpif_offload_init() could potentially fail but no error checking is done before setting the output parameter. > + > +static void > +dpif_offload_dpdk_close(struct dpif_offload *dpif_offload) > +{ > + free(dpif_offload); > +} Should dpif_offload_dpdk_close() call a cleanup function before freeing the dpif_offload structure? Other providers might need to cleanup resources allocated during initialization. [ ... ] > diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c > index 2e5be6b2f..62bdd31b9 100644 > --- a/lib/dpif-offload.c > +++ b/lib/dpif-offload.c > @@ -39,6 +39,9 @@ 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 > &dpif_offload_dummy_class, > &dpif_offload_dummy_x_class, Is the conditional compilation logic correct here? The DPDK provider is only available when DPDK_NETDEV is defined, but could this create ordering issues since it's placed between the Linux-specific tc_class and the dummy classes? [ ... ]
diff --git a/lib/automake.mk b/lib/automake.mk index 6e015ebfc..6db7daa9f 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -507,6 +507,7 @@ endif if DPDK_NETDEV lib_libopenvswitch_la_SOURCES += \ lib/dpdk.c \ + lib/dpif-offload-dpdk.c \ lib/netdev-dpdk.c \ lib/netdev-offload-dpdk.c else diff --git a/lib/dpif-offload-dpdk.c b/lib/dpif-offload-dpdk.c new file mode 100644 index 000000000..03c8f6492 --- /dev/null +++ b/lib/dpif-offload-dpdk.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <config.h> + +#include "dpif-offload.h" +#include "dpif-offload-provider.h" +#include "util.h" + +static int +dpif_offload_dpdk_open(const struct dpif_offload_class *offload_class, + struct dpif *dpif, struct dpif_offload **dpif_offload) +{ + struct dpif_offload *offload = xmalloc(sizeof(struct dpif_offload)); + + dpif_offload_init(offload, offload_class, dpif); + *dpif_offload = offload; + return 0; +} + +static void +dpif_offload_dpdk_close(struct dpif_offload *dpif_offload) +{ + free(dpif_offload); +} + +struct dpif_offload_class dpif_offload_dpdk_class = { + .type = "dpdk", + .supported_dpif_types = (const char *const[]) { + "netdev", + NULL}, + .open = dpif_offload_dpdk_open, + .close = dpif_offload_dpdk_close, +}; diff --git a/lib/dpif-offload-provider.h b/lib/dpif-offload-provider.h index 4cd6fb88a..73bb1a57c 100644 --- a/lib/dpif-offload-provider.h +++ b/lib/dpif-offload-provider.h @@ -89,6 +89,7 @@ struct dpif_offload_class { extern struct dpif_offload_class dpif_offload_dummy_class; extern struct dpif_offload_class dpif_offload_dummy_x_class; +extern struct dpif_offload_class dpif_offload_dpdk_class; extern struct dpif_offload_class dpif_offload_tc_class; /* Global function, called by the dpif layer. */ diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c index 2e5be6b2f..62bdd31b9 100644 --- a/lib/dpif-offload.c +++ b/lib/dpif-offload.c @@ -39,6 +39,9 @@ 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 &dpif_offload_dummy_class, &dpif_offload_dummy_x_class, diff --git a/tests/system-dpdk.at b/tests/system-dpdk.at index 393b76c76..e666a08c7 100644 --- a/tests/system-dpdk.at +++ b/tests/system-dpdk.at @@ -941,3 +941,26 @@ AT_CHECK([ovs-vsctl del-port br10 p1], [], [stdout], [stderr]) OVS_DPDK_STOP_VSWITCHD AT_CLEANUP dnl -------------------------------------------------------------------------- + +dnl -------------------------------------------------------------------------- +AT_SETUP([OVS-DPDK - ovs-appctl dpif/offload/show]) +AT_KEYWORDS([dpdk dpif-offload]) +OVS_DPDK_PRE_CHECK() +OVS_DPDK_START([--no-pci]) +AT_CHECK([ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev]) + +AT_CHECK([ovs-appctl dpif/offload/show], [0], [dnl +netdev@ovs-netdev: + dpdk +]) + +AT_CHECK([ovs-appctl --format json --pretty dpif/offload/show], [0], [dnl +{ + "netdev@ovs-netdev": { + "providers": [[ + "dpdk"]]}} +]) + +OVS_DPDK_STOP_VSWITCHD +AT_CLEANUP +dnl --------------------------------------------------------------------------
This patch adds the dpdk offload provider framework. Signed-off-by: Eelco Chaudron <echaudro@redhat.com> --- lib/automake.mk | 1 + lib/dpif-offload-dpdk.c | 47 +++++++++++++++++++++++++++++++++++++ lib/dpif-offload-provider.h | 1 + lib/dpif-offload.c | 3 +++ tests/system-dpdk.at | 23 ++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 lib/dpif-offload-dpdk.c