This patch simply renames the netdev-offload-tc|dpdk.c files to the corresponding dpif-offload-tc|dpdk-netdev.c files. This makes it clearer that offload is now controlled through the new dpif-offload provider framework.
It does not rename all individual functions or data structures, as that would be too large a change with no real benefit. In addition, the netdev_set|get_hw_info() APIs were moved from netdev-offload.c to netdev.c, allowing the netdev-offload.c file to be removed. The same applies to the definitions previously located in netdev-offload.h. Signed-off-by: Eelco Chaudron <[email protected]> --- v2 changes: - Fixed comments in moved 'hw_info_type' and 'netdev_hw_info' definitions. --- lib/automake.mk | 11 +-- lib/dpif-netdev-avx512.c | 1 - lib/dpif-netdev.c | 1 - lib/dpif-netlink.c | 1 - ...load-dpdk.c => dpif-offload-dpdk-netdev.c} | 1 - lib/dpif-offload-dpdk-private.h | 38 +++++++++- lib/dpif-offload-dpdk.c | 1 - ...-offload-tc.c => dpif-offload-tc-netdev.c} | 2 +- ...offload-tc.h => dpif-offload-tc-private.h} | 6 +- lib/dpif-offload-tc.c | 3 +- lib/dpif.c | 1 - lib/netdev-offload-dpdk.h | 57 -------------- lib/netdev-offload.c | 74 ------------------- lib/netdev-offload.h | 52 ------------- lib/netdev-provider.h | 1 - lib/netdev.c | 50 +++++++++++++ lib/netdev.h | 21 ++++++ lib/tc.c | 2 +- vswitchd/bridge.c | 1 - 19 files changed, 117 insertions(+), 207 deletions(-) rename lib/{netdev-offload-dpdk.c => dpif-offload-dpdk-netdev.c} (99%) rename lib/{netdev-offload-tc.c => dpif-offload-tc-netdev.c} (99%) rename lib/{netdev-offload-tc.h => dpif-offload-tc-private.h} (96%) delete mode 100644 lib/netdev-offload-dpdk.h delete mode 100644 lib/netdev-offload.c delete mode 100644 lib/netdev-offload.h diff --git a/lib/automake.mk b/lib/automake.mk index c0edef8e9..9634bed7b 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -210,8 +210,6 @@ lib_libopenvswitch_la_SOURCES = \ lib/namemap.c \ lib/netdev-dpdk.h \ lib/netdev-dummy.c \ - lib/netdev-offload.c \ - lib/netdev-offload.h \ lib/netdev-provider.h \ lib/netdev-vport.c \ lib/netdev-vport.h \ @@ -475,12 +473,12 @@ lib_libopenvswitch_la_SOURCES += \ lib/dpif-netlink-rtnl.c \ lib/dpif-netlink-rtnl.h \ lib/dpif-offload-tc.c \ + lib/dpif-offload-tc-netdev.c \ + lib/dpif-offload-tc-private.h \ lib/if-notifier.c \ lib/netdev-linux.c \ lib/netdev-linux.h \ lib/netdev-linux-private.h \ - lib/netdev-offload-tc.c \ - lib/netdev-offload-tc.h \ lib/netlink-conntrack.c \ lib/netlink-conntrack.h \ lib/netlink-notifier.c \ @@ -508,10 +506,9 @@ if DPDK_NETDEV lib_libopenvswitch_la_SOURCES += \ lib/dpdk.c \ lib/dpif-offload-dpdk.c \ + lib/dpif-offload-dpdk-netdev.c \ lib/dpif-offload-dpdk-private.h \ - lib/netdev-dpdk.c \ - lib/netdev-offload-dpdk.c \ - lib/netdev-offload-dpdk.h + lib/netdev-dpdk.c else lib_libopenvswitch_la_SOURCES += \ lib/dpdk-stub.c diff --git a/lib/dpif-netdev-avx512.c b/lib/dpif-netdev-avx512.c index 0cc566eae..387ff23c4 100644 --- a/lib/dpif-netdev-avx512.c +++ b/lib/dpif-netdev-avx512.c @@ -30,7 +30,6 @@ #include "dp-packet.h" #include "netdev.h" -#include "netdev-offload.h" /* Each AVX512 register (zmm register in assembly notation) can contain up to * 512 bits, which is equivalent to 8 uint64_t variables. This is the maximum diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 68d0a65fb..7a86907f9 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -59,7 +59,6 @@ #include "mov-avg.h" #include "mpsc-queue.h" #include "netdev.h" -#include "netdev-offload-dpdk.h" #include "netdev-provider.h" #include "netdev-vport.h" #include "netlink.h" diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index d76e2ccfb..f22a87934 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -39,7 +39,6 @@ #include "fat-rwlock.h" #include "flow.h" #include "netdev-linux.h" -#include "netdev-offload.h" #include "netdev-provider.h" #include "netdev-vport.h" #include "netdev.h" diff --git a/lib/netdev-offload-dpdk.c b/lib/dpif-offload-dpdk-netdev.c similarity index 99% rename from lib/netdev-offload-dpdk.c rename to lib/dpif-offload-dpdk-netdev.c index d0d3bbe66..01be5810d 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/dpif-offload-dpdk-netdev.c @@ -27,7 +27,6 @@ #include "dpif-netdev.h" #include "dpif-offload.h" #include "dpif-offload-dpdk-private.h" -#include "netdev-offload-dpdk.h" #include "netdev-provider.h" #include "netdev-vport.h" #include "odp-util.h" diff --git a/lib/dpif-offload-dpdk-private.h b/lib/dpif-offload-dpdk-private.h index 686c52420..6c2f5fcc9 100644 --- a/lib/dpif-offload-dpdk-private.h +++ b/lib/dpif-offload-dpdk-private.h @@ -22,8 +22,8 @@ struct dpif_offload_dpdk; struct netdev; /* DPIF offload dpdk implementation-specific functions. These should only be - * used by the associated netdev offload provider, i.e., netdev-offload-dpdk. - */ + * used by the associated netdev offload provider, i.e., + * dpif-offload-dpdk-netdev. */ unsigned int dpdk_offload_thread_id(void); void dpif_offload_dpdk_flow_unreference(struct dpif_offload_dpdk *offload, unsigned pmd_id, void *flow_reference); @@ -36,4 +36,38 @@ void dpif_offload_dpdk_traverse_ports( const struct dpif_offload_dpdk *offload, bool (*cb)(struct netdev *, odp_port_t, void *), void *aux); + +/* dpif-offload-dpdk-netdev specific offload functions. These should only be + * used by the associated dpif offload provider, i.e., dpif-offload-dpdk. */ +int netdev_offload_dpdk_init(struct netdev *, + unsigned int offload_thread_count); +void netdev_offload_dpdk_uninit(struct netdev *); +int netdev_offload_dpdk_flow_flush(struct dpif_offload_dpdk *, + struct netdev *); +uint64_t netdev_offload_dpdk_flow_get_n_offloaded( + struct netdev *, unsigned int offload_thread_count); +uint64_t netdev_offload_dpdk_flow_get_n_offloaded_by_thread( + struct netdev *, unsigned int tid); +int netdev_offload_dpdk_hw_miss_packet_recover(struct dpif_offload_dpdk *, + struct netdev *, + unsigned pmd_id, + struct dp_packet *, + void **flow_reference); +int netdev_offload_dpdk_flow_put(struct dpif_offload_dpdk *, + unsigned pmd_id, void *flow_reference, + struct netdev *, struct match *, + struct nlattr *actions, size_t actions_len, + const ovs_u128 *ufid, odp_port_t orig_in_port, + void **previous_flow_reference, + struct dpif_flow_stats *); +int netdev_offload_dpdk_flow_del(struct dpif_offload_dpdk *, + struct netdev *, unsigned pmd_id, + const ovs_u128 *ufid, + void *flow_reference, + struct dpif_flow_stats *); +int netdev_offload_dpdk_flow_get(struct netdev *, struct match *, + struct nlattr **actions, const ovs_u128 *ufid, + struct dpif_flow_stats *, + struct dpif_flow_attrs *, struct ofpbuf *buf); + #endif /* DPIF_OFFLOAD_DPDK_PRIVATE_H */ diff --git a/lib/dpif-offload-dpdk.c b/lib/dpif-offload-dpdk.c index 547bb68ef..cb2699b59 100644 --- a/lib/dpif-offload-dpdk.c +++ b/lib/dpif-offload-dpdk.c @@ -23,7 +23,6 @@ #include "id-fpool.h" #include "mov-avg.h" #include "mpsc-queue.h" -#include "netdev-offload-dpdk.h" #include "netdev-provider.h" #include "netdev-vport.h" #include "util.h" diff --git a/lib/netdev-offload-tc.c b/lib/dpif-offload-tc-netdev.c similarity index 99% rename from lib/netdev-offload-tc.c rename to lib/dpif-offload-tc-netdev.c index 55eb1f084..98909d91f 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/dpif-offload-tc-netdev.c @@ -31,7 +31,6 @@ #include "openvswitch/util.h" #include "openvswitch/vlog.h" #include "netdev-linux.h" -#include "netdev-offload-tc.h" #include "netdev-provider.h" #include "netdev-vport.h" #include "netlink.h" @@ -42,6 +41,7 @@ #include "unaligned.h" #include "util.h" #include "dpif-offload.h" +#include "dpif-offload-tc-private.h" #include "dpif-provider.h" VLOG_DEFINE_THIS_MODULE(netdev_offload_tc); diff --git a/lib/netdev-offload-tc.h b/lib/dpif-offload-tc-private.h similarity index 96% rename from lib/netdev-offload-tc.h rename to lib/dpif-offload-tc-private.h index e49a2d343..5cb55bae6 100644 --- a/lib/netdev-offload-tc.h +++ b/lib/dpif-offload-tc-private.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef NETDEV_OFFLOAD_TC_H -#define NETDEV_OFFLOAD_TC_H +#ifndef DPIF_OFFLOAD_TC_PRIVATE_H +#define DPIF_OFFLOAD_TC_PRIVATE_H /* Forward declarations of private structures. */ struct dpif_offload; @@ -73,4 +73,4 @@ uint64_t dpif_offload_tc_flow_get_n_offloaded(const struct dpif_offload *); odp_port_t dpif_offload_tc_get_port_id_by_ifindex(const struct dpif_offload *, int ifindex); -#endif /* NETDEV_OFFLOAD_TC_H */ +#endif /* DPIF_OFFLOAD_TC_PRIVATE_H */ diff --git a/lib/dpif-offload-tc.c b/lib/dpif-offload-tc.c index fdd20f3a2..6573c6c98 100644 --- a/lib/dpif-offload-tc.c +++ b/lib/dpif-offload-tc.c @@ -19,8 +19,7 @@ #include "dpif-offload.h" #include "dpif-offload-provider.h" -#include "netdev-offload.h" -#include "netdev-offload-tc.h" +#include "dpif-offload-tc-private.h" #include "netdev-provider.h" #include "netdev-vport.h" #include "odp-util.h" diff --git a/lib/dpif.c b/lib/dpif.c index bda11a41b..152121606 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -30,7 +30,6 @@ #include "dpif-offload.h" #include "dpif-offload-provider.h" #include "flow.h" -#include "netdev-offload.h" #include "netdev-provider.h" #include "netdev.h" #include "netlink.h" diff --git a/lib/netdev-offload-dpdk.h b/lib/netdev-offload-dpdk.h deleted file mode 100644 index 818806b82..000000000 --- a/lib/netdev-offload-dpdk.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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. - */ - - #ifndef NETDEV_OFFLOAD_DPDK_H - #define NETDEV_OFFLOAD_DPDK_H - -/* Forward declarations of private structures. */ -struct dpif_offload_dpdk; -struct netdev; - -/* Netdev-specific offload functions. These should only be used by the - * associated dpif offload provider. */ -int netdev_offload_dpdk_init(struct netdev *, - unsigned int offload_thread_count); -void netdev_offload_dpdk_uninit(struct netdev *); -int netdev_offload_dpdk_flow_flush(struct dpif_offload_dpdk *, - struct netdev *); -uint64_t netdev_offload_dpdk_flow_get_n_offloaded( - struct netdev *, unsigned int offload_thread_count); -uint64_t netdev_offload_dpdk_flow_get_n_offloaded_by_thread( - struct netdev *, unsigned int tid); -int netdev_offload_dpdk_hw_miss_packet_recover(struct dpif_offload_dpdk *, - struct netdev *, - unsigned pmd_id, - struct dp_packet *, - void **flow_reference); -int netdev_offload_dpdk_flow_put(struct dpif_offload_dpdk *, - unsigned pmd_id, void *flow_reference, - struct netdev *, struct match *, - struct nlattr *actions, size_t actions_len, - const ovs_u128 *ufid, - odp_port_t orig_in_port, - void **previous_flow_reference, - struct dpif_flow_stats *); -int netdev_offload_dpdk_flow_del(struct dpif_offload_dpdk *, struct netdev *, - unsigned pmd_id, const ovs_u128 *ufid, - void *flow_reference, - struct dpif_flow_stats *); -int netdev_offload_dpdk_flow_get(struct netdev *, struct match *, - struct nlattr **actions, const ovs_u128 *ufid, - struct dpif_flow_stats *, - struct dpif_flow_attrs *, struct ofpbuf *buf); - -#endif /* NETDEV_OFFLOAD_DPDK_H */ diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c deleted file mode 100644 index f24c415a2..000000000 --- a/lib/netdev-offload.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2008 - 2014, 2016, 2017 Nicira, Inc. - * Copyright (c) 2019 Samsung Electronics Co.,Ltd. - * - * 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 "netdev-offload.h" -#include "netdev-provider.h" -#include "openvswitch/vlog.h" - -VLOG_DEFINE_THIS_MODULE(netdev_offload); - -/* - * Get the value of the hw info parameter specified by type. - * Returns the value on success (>= 0). Returns -1 on failure. - */ -int -netdev_get_hw_info(struct netdev *netdev, int type) -{ - int val = -1; - - switch (type) { - case HW_INFO_TYPE_OOR: - val = netdev->hw_info.oor; - break; - case HW_INFO_TYPE_PEND_COUNT: - val = netdev->hw_info.pending_count; - break; - case HW_INFO_TYPE_OFFL_COUNT: - val = netdev->hw_info.offload_count; - break; - default: - break; - } - - return val; -} - -/* - * Set the value of the hw info parameter specified by type. - */ -void -netdev_set_hw_info(struct netdev *netdev, int type, int val) -{ - switch (type) { - case HW_INFO_TYPE_OOR: - if (val == 0) { - VLOG_DBG("Offload rebalance: netdev: %s is not OOR", netdev->name); - } - netdev->hw_info.oor = val; - break; - case HW_INFO_TYPE_PEND_COUNT: - netdev->hw_info.pending_count = val; - break; - case HW_INFO_TYPE_OFFL_COUNT: - netdev->hw_info.offload_count = val; - break; - default: - break; - } -} diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h deleted file mode 100644 index fe42c9b4d..000000000 --- a/lib/netdev-offload.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. - * Copyright (c) 2019 Samsung Electronics Co.,Ltd. - * - * 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. - */ - -#ifndef NETDEV_OFFLOAD_H -#define NETDEV_OFFLOAD_H 1 - -#include "openvswitch/netdev.h" -#include "ovs-atomic.h" -#include "ovs-rcu.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* Offload-capable (HW) netdev information */ -struct netdev_hw_info { - bool oor; /* Out of Offload Resources ? */ - /* Is hw_miss_packet_postprocess() supported.*/ - atomic_bool postprocess_api_supported; - int offload_count; /* Offloaded flow count */ - int pending_count; /* Pending (non-offloaded) flow count */ - OVSRCU_TYPE(void *) offload_data; /* Offload metadata. */ -}; - -enum hw_info_type { - HW_INFO_TYPE_OOR = 1, /* OOR state */ - HW_INFO_TYPE_PEND_COUNT = 2, /* Pending(non-offloaded) flow count */ - HW_INFO_TYPE_OFFL_COUNT = 3 /* Offloaded flow count */ -}; - -int netdev_get_hw_info(struct netdev *, int); -void netdev_set_hw_info(struct netdev *, int, int); - -#ifdef __cplusplus -} -#endif - -#endif /* netdev-offload.h */ diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index 753151330..136d8188c 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -21,7 +21,6 @@ #include "connectivity.h" #include "netdev.h" -#include "netdev-offload.h" #include "openvswitch/list.h" #include "ovs-numa.h" #include "ovs-rcu.h" diff --git a/lib/netdev.c b/lib/netdev.c index ee5d68c99..53a23cc3f 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -2454,3 +2454,53 @@ netdev_get_block_id(struct netdev *netdev) ? class->get_block_id(netdev) : 0); } + +/* + * Get the value of the hw info parameter specified by type. + * Returns the value on success (>= 0). Returns -1 on failure. + */ +int +netdev_get_hw_info(struct netdev *netdev, int type) +{ + int val = -1; + + switch (type) { + case HW_INFO_TYPE_OOR: + val = netdev->hw_info.oor; + break; + case HW_INFO_TYPE_PEND_COUNT: + val = netdev->hw_info.pending_count; + break; + case HW_INFO_TYPE_OFFL_COUNT: + val = netdev->hw_info.offload_count; + break; + default: + break; + } + + return val; +} + +/* + * Set the value of the hw info parameter specified by type. + */ +void +netdev_set_hw_info(struct netdev *netdev, int type, int val) +{ + switch (type) { + case HW_INFO_TYPE_OOR: + if (val == 0) { + VLOG_DBG("Offload rebalance: netdev: %s is not OOR", netdev->name); + } + netdev->hw_info.oor = val; + break; + case HW_INFO_TYPE_PEND_COUNT: + netdev->hw_info.pending_count = val; + break; + case HW_INFO_TYPE_OFFL_COUNT: + netdev->hw_info.offload_count = val; + break; + default: + break; + } +} diff --git a/lib/netdev.h b/lib/netdev.h index df56c9071..7666d8a8a 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -19,6 +19,8 @@ #include "openvswitch/netdev.h" #include "openvswitch/types.h" +#include "ovs-atomic.h" +#include "ovs-rcu.h" #include "packets.h" #include "flow.h" @@ -392,6 +394,25 @@ int netdev_get_addrs(const char dev[], struct in6_addr **paddr, struct in6_addr **pmask, int *n_in6); #endif +/* Offload-capable (HW) netdev information. */ +struct netdev_hw_info { + bool oor; /* Out of Offload Resources (OOR)? */ + /* Is dpif_offload's netdev_hw_miss_packet_postprocess() supported? */ + atomic_bool postprocess_api_supported; + int offload_count; /* Offloaded flow count. */ + int pending_count; /* Pending (non-offloaded) flow count. */ + OVSRCU_TYPE(void *) offload_data; /* Offload metadata. */ +}; + +enum hw_info_type { + HW_INFO_TYPE_OOR = 1, /* Out of Offload Resources (OOR) state. */ + HW_INFO_TYPE_PEND_COUNT = 2, /* Pending(non-offloaded) flow count. */ + HW_INFO_TYPE_OFFL_COUNT = 3 /* Offloaded flow count. */ +}; + +int netdev_get_hw_info(struct netdev *, int type); +void netdev_set_hw_info(struct netdev *, int type, int val); + #ifdef __cplusplus } #endif diff --git a/lib/tc.c b/lib/tc.c index a5f9bc1c1..4a9c6c267 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -2977,7 +2977,7 @@ csum_update_flag(struct tc_flower *flower, * is ICMPv6 and tcp checksum if its tcp. * * This section of the code must be kept in sync with the pre-check - * function in netdev-offload-tc.c, tc_will_add_l4_checksum(). */ + * function in dpif-offload-tc-netdev.c, tc_will_add_l4_checksum(). */ switch (htype) { case TCA_PEDIT_KEY_EX_HDR_TYPE_IP4: diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 9d9c9d8c0..b4af41b24 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -39,7 +39,6 @@ #include "mac-learning.h" #include "mcast-snooping.h" #include "netdev.h" -#include "netdev-offload.h" #include "nx-match.h" #include "odp-execute.h" #include "ofproto/bond.h" -- 2.50.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
