On 02/12/2025 16:04, Eelco Chaudron wrote:
Currently, the dpif layer provides an API to set specific features,
but not to retrieve their current values. This patch adds a new API,
dpif_get_features(), to query the currently configured features.
Squash it into the commit that introduced set-features.
Signed-off-by: Eelco Chaudron <[email protected]>
---
lib/dpif-netdev.c | 1 +
lib/dpif-netlink.c | 11 +++++++++++
lib/dpif-provider.h | 1 +
lib/dpif.c | 12 +++++++++++-
lib/dpif.h | 1 +
5 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index fa265b8fc..c09b1c7c7 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -9973,6 +9973,7 @@ const struct dpif_class dpif_netdev_class = {
dpif_netdev_wait,
dpif_netdev_get_stats,
NULL, /* set_features */
+ NULL, /* get_features */
dpif_netdev_port_add,
dpif_netdev_port_del,
dpif_netdev_port_set_config,
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index 04d7c8ed6..e161930be 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -121,6 +121,8 @@ static int dpif_netlink_dp_get(const struct dpif *,
struct ofpbuf **bufp);
static int
dpif_netlink_set_features(struct dpif *dpif_, uint32_t new_features);
+static uint32_t
+dpif_netlink_get_features(struct dpif *dpif_);
static void
dpif_netlink_unixctl_dispatch_mode(struct unixctl_conn *conn, int argc,
@@ -880,6 +882,14 @@ dpif_netlink_set_features(struct dpif *dpif_, uint32_t
new_features)
return error;
}
+static uint32_t
+dpif_netlink_get_features(struct dpif *dpif_)
+{
+ struct dpif_netlink *dpif = dpif_netlink_cast(dpif_);
+
+ return dpif->user_features;
+}
+
static const char *
get_vport_type(const struct dpif_netlink_vport *vport)
{
@@ -4373,6 +4383,7 @@ const struct dpif_class dpif_netlink_class = {
NULL, /* wait */
dpif_netlink_get_stats,
dpif_netlink_set_features,
+ dpif_netlink_get_features,
dpif_netlink_port_add,
dpif_netlink_port_del,
NULL, /* port_set_config */
diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
index 02bcae12f..d27ad5165 100644
--- a/lib/dpif-provider.h
+++ b/lib/dpif-provider.h
@@ -227,6 +227,7 @@ struct dpif_class {
int (*get_stats)(const struct dpif *dpif, struct dpif_dp_stats *stats);
int (*set_features)(struct dpif *dpif, uint32_t user_features);
+ uint32_t (*get_features)(struct dpif *dpif);
/* Adds 'netdev' as a new port in 'dpif'. If '*port_no' is not
* ODPP_NONE, attempts to use that as the port's port number.
diff --git a/lib/dpif.c b/lib/dpif.c
index 30aab036c..69c33580f 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -566,12 +566,22 @@ dpif_get_dp_stats(const struct dpif *dpif, struct
dpif_dp_stats *stats)
int
dpif_set_features(struct dpif *dpif, uint32_t new_features)
{
- int error = dpif->dpif_class->set_features(dpif, new_features);
+ int error = dpif->dpif_class->set_features
+ ? dpif->dpif_class->set_features(dpif, new_features)
+ : EOPNOTSUPP;
log_operation(dpif, "set_features", error);
return error;
}
+uint32_t
+dpif_get_features(struct dpif *dpif)
+{
+ return dpif->dpif_class->get_features
+ ? dpif->dpif_class->get_features(dpif)
+ : 0;
+}
+
const char *
dpif_port_open_type(const char *datapath_type, const char *port_type)
{
diff --git a/lib/dpif.h b/lib/dpif.h
index f3301ae85..c1b0daa3e 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -440,6 +440,7 @@ struct dpif_dp_stats {
int dpif_get_dp_stats(const struct dpif *, struct dpif_dp_stats *);
int dpif_set_features(struct dpif *, uint32_t new_features);
+uint32_t dpif_get_features(struct dpif *dpif);
/* Port operations. */
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev