[PATCH V3 5/7] pipeline: support direct meters on the control path
Cristian Dumitrescu
cristian.dumitrescu at intel.com
Tue Aug 30 20:58:09 CEST 2022
Add pipeline control path API to manage direct meters. These meters
are identified by a table key, whose entry ID is used as the index
into the meter array.
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu at intel.com>
---
lib/pipeline/rte_swx_ctl.h | 81 +++++++++++++++++++++++++++++++++
lib/pipeline/rte_swx_pipeline.c | 50 ++++++++++++++++++++
lib/pipeline/version.map | 3 ++
3 files changed, 134 insertions(+)
diff --git a/lib/pipeline/rte_swx_ctl.h b/lib/pipeline/rte_swx_ctl.h
index 1b47820441..2eb51b2c76 100644
--- a/lib/pipeline/rte_swx_ctl.h
+++ b/lib/pipeline/rte_swx_ctl.h
@@ -1440,6 +1440,87 @@ rte_swx_ctl_meter_stats_read(struct rte_swx_pipeline *p,
uint32_t metarray_index,
struct rte_swx_ctl_meter_stats *stats);
+/**
+ * Meter reset with table key lookup
+ *
+ * Reset a meter within a given meter array to use the default profile that
+ * causes all the input packets to be colored as green. It is the responsibility
+ * of the control plane to make sure this meter is not used by the data plane
+ * pipeline before calling this function.
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] metarray_name
+ * Meter array name.
+ * @param[in] table_name
+ * Regular or learner table name.
+ * @param[in] table_key
+ * Table key.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_meter_reset_with_key(struct rte_swx_pipeline *p,
+ const char *metarray_name,
+ const char *table_name,
+ uint8_t *table_key);
+
+/**
+ * Meter set with table key lookup
+ *
+ * Set a meter within a given meter array to use a specific profile. It is the
+ * responsibility of the control plane to make sure this meter is not used by
+ * the data plane pipeline before calling this function.
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] metarray_name
+ * Meter array name.
+ * @param[in] table_name
+ * Regular or learner table name.
+ * @param[in] table_key
+ * Table key.
+ * @param[in] profile_name
+ * Existing meter profile name.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_meter_set_with_key(struct rte_swx_pipeline *p,
+ const char *metarray_name,
+ const char *table_name,
+ uint8_t *table_key,
+ const char *profile_name);
+
+/**
+ * Meter statistics counters read with table key lookup
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] metarray_name
+ * Meter array name.
+ * @param[in] table_name
+ * Regular or learner table name.
+ * @param[in] table_key
+ * Table key.
+ * @param[out] stats
+ * Meter statistics counters.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_meter_stats_read_with_key(struct rte_swx_pipeline *p,
+ const char *metarray_name,
+ const char *table_name,
+ uint8_t *table_key,
+ struct rte_swx_ctl_meter_stats *stats);
+
/**
* Pipeline control free
*
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index ab59e7ad79..232dafb95e 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -11356,6 +11356,56 @@ rte_swx_ctl_pipeline_regarray_write_with_key(struct rte_swx_pipeline *p,
return rte_swx_ctl_pipeline_regarray_write(p, regarray_name, entry_id, value);
}
+int
+rte_swx_ctl_meter_reset_with_key(struct rte_swx_pipeline *p,
+ const char *metarray_name,
+ const char *table_name,
+ uint8_t *table_key)
+{
+ size_t entry_id = 0;
+ int status;
+
+ status = rte_swx_ctl_pipeline_table_entry_id_get(p, table_name, table_key, &entry_id);
+ if (status)
+ return status;
+
+ return rte_swx_ctl_meter_reset(p, metarray_name, entry_id);
+}
+
+int
+rte_swx_ctl_meter_set_with_key(struct rte_swx_pipeline *p,
+ const char *metarray_name,
+ const char *table_name,
+ uint8_t *table_key,
+ const char *profile_name)
+{
+ size_t entry_id = 0;
+ int status;
+
+ status = rte_swx_ctl_pipeline_table_entry_id_get(p, table_name, table_key, &entry_id);
+ if (status)
+ return status;
+
+ return rte_swx_ctl_meter_set(p, metarray_name, entry_id, profile_name);
+}
+
+int
+rte_swx_ctl_meter_stats_read_with_key(struct rte_swx_pipeline *p,
+ const char *metarray_name,
+ const char *table_name,
+ uint8_t *table_key,
+ struct rte_swx_ctl_meter_stats *stats)
+{
+ size_t entry_id = 0;
+ int status;
+
+ status = rte_swx_ctl_pipeline_table_entry_id_get(p, table_name, table_key, &entry_id);
+ if (status)
+ return status;
+
+ return rte_swx_ctl_meter_stats_read(p, metarray_name, entry_id, stats);
+}
+
/*
* Pipeline compilation.
*/
diff --git a/lib/pipeline/version.map b/lib/pipeline/version.map
index 8ed92042d6..f53a037edf 100644
--- a/lib/pipeline/version.map
+++ b/lib/pipeline/version.map
@@ -146,6 +146,9 @@ EXPERIMENTAL {
rte_swx_pipeline_hash_func_register;
#added in 22.11
+ rte_swx_ctl_meter_reset_with_key;
+ rte_swx_ctl_meter_set_with_key;
+ rte_swx_ctl_meter_stats_read_with_key;
rte_swx_ctl_pipeline_find;
rte_swx_ctl_pipeline_regarray_read_with_key;
rte_swx_ctl_pipeline_regarray_write_with_key;
--
2.34.1
More information about the dev
mailing list