git sha: ffafe993c70062243ac510a8dfec54843cc41d3b
Author: Eelco Chaudron <[email protected]>
dpif-offload: Call flow-flush netdev-offload APIs via dpif-offload.
This commit starts using the new dpif-offload API by avoiding direct
calls to netdev-offload. This is the first step towards removing
netdev-offload as an API layer.
> diff --git a/lib/automake.mk b/lib/automake.mk
> index 6db7daa9f..229064716 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -481,6 +481,7 @@ lib_libopenvswitch_la_SOURCES += \
> 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 \
[ ... ]
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index 2e31041ef..79b05bc0d 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -2911,7 +2911,7 @@ dp_offload_flush(struct dp_offload_thread_item *item)
> struct dp_offload_flush_item *flush = &item->data->flush;
>
> ovs_rwlock_rdlock(&item->dp->port_rwlock);
> - netdev_flow_flush(flush->netdev);
> + dpif_offload_netdev_flush_flows(flush->netdev);
> ovs_rwlock_unlock(&item->dp->port_rwlock);
>
> ovs_barrier_block(flush->barrier);
[ ... ]
> diff --git a/lib/dpif-offload-provider.h b/lib/dpif-offload-provider.h
> index 50f9a53c2..6c1916b70 100644
> --- a/lib/dpif-offload-provider.h
> +++ b/lib/dpif-offload-provider.h
> @@ -126,6 +126,19 @@ struct dpif_offload_class {
> * as above in 'port_deleted' applies here.*/
> void (*port_set_config)(struct dpif_offload *, odp_port_t port_no,
> const struct smap *cfg);
> +
> + /* Deletes all offloaded flows for this offload_provider. Return 0 if
> + * successful, otherwise returns a positive errno value. */
> + int (*flow_flush)(const struct dpif_offload *);
> +
> +
> + /* These APIs operate directly on the provided netdev for performance
> + * reasons. They are intended for use in fast path processing and should
> + * be designed with speed and efficiency in mind. */
> +
> + /* Deletes all offloaded flows on this netdev. Return 0 if successful,
> + * otherwise returns a positive errno value. */
> + int (*netdev_flow_flush)(const struct dpif_offload *, struct netdev *);
Does this comment have inconsistent whitespace with the space before
"otherwise"?
[ ... ]
> diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c
> index 033b4e4b2..537939d2d 100644
> --- a/lib/dpif-offload.c
> +++ b/lib/dpif-offload.c
> @@ -702,6 +702,42 @@ dpif_offload_set_global_cfg(const struct
> ovsrec_open_vswitch *cfg)
> }
> }
>
> +void
> +dpif_offload_flow_flush(struct dpif *dpif)
> +{
> + struct dp_offload *dp_offload = dpif_offload_get_dp_offload(dpif);
> + const struct dpif_offload *offload;
> +
> + if (!dp_offload) {
> + return;
> + }
> +
> + LIST_FOR_EACH (offload, dpif_list_node, &dp_offload->offload_providers) {
> + if (offload->class->flow_flush) {
> + int err = offload->class->flow_flush(offload);
> + if (err) {
> + VLOG_ERR("Failed flow flush on dpif-offload provider "
> + "%s, error %s", dpif_offload_name(offload),
> + ovs_strerror(err));
Can this VLOG_ERR span multiple lines properly according to the coding
style guide? Looks like the string should be properly wrapped.
> + }
> + }
> + }
> +}
> +
> +
> +int
> +dpif_offload_netdev_flush_flows(struct netdev *netdev)
> +{
> + const struct dpif_offload *offload;
> +
> + offload = ovsrcu_get(const struct dpif_offload *, &netdev->dpif_offload);
> +
> + if (offload && offload->class->netdev_flow_flush) {
> + return offload->class->netdev_flow_flush(offload, netdev);
> + }
> + return EOPNOTSUPP;
> +}
[ ... ]
> diff --git a/lib/netdev-offload-tc.h b/lib/netdev-offload-tc.h
> new file mode 100644
> index 000000000..74dd33b8b
> --- /dev/null
> +++ b/lib/netdev-offload-tc.h
> @@ -0,0 +1,27 @@
> +/*
> + * 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_TC_H
> + #define NETDEV_OFFLOAD_TC_H
Does this code have incorrect whitespace in the header guards? The
"#ifndef" and "#define" appear to have leading spaces instead of being
at the beginning of the line.
> +
> +/* Forward declarations of private structures. */
> +struct netdev;
> +
> +/* Netdev-specific offload functions. These should only be used by the
> + * associated dpif offload provider. */
> +int netdev_offload_tc_flow_flush(struct netdev *);
> +
> +#endif /* NETDEV_OFFLOAD_TC_H */
\ No newline at end of file
Does this file lack the required newline at the end of file?
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev