#include <stdio.h>
#include <rte_compat.h>
+#include <rte_meter.h>
#include "rte_swx_port.h"
#include "rte_swx_table.h"
/** Number of register arrays. */
uint32_t n_regarrays;
+
+ /** Number of meter arrays. */
+ uint32_t n_metarrays;
};
/**
struct rte_swx_table_ops *table_ops,
int *is_stub);
+/** Table statistics. */
+struct rte_swx_table_stats {
+ /** Number of packets with lookup hit. */
+ uint64_t n_pkts_hit;
+
+ /** Number of packets with lookup miss. */
+ uint64_t n_pkts_miss;
+
+ /** Number of packets (with either lookup hit or miss) per pipeline
+ * action. Array of pipeline *n_actions* elements indedex by the
+ * pipeline-level *action_id*, therefore this array has the same size
+ * for all the tables within the same pipeline.
+ */
+ uint64_t *n_pkts_action;
+};
+
+/**
+ * Table statistics counters read
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] table_name
+ * Table name.
+ * @param[out] stats
+ * Table stats. Must point to a pre-allocated structure. The *n_pkts_action*
+ * field also needs to be pre-allocated as array of pipeline *n_actions*
+ * elements. The pipeline actions that are not valid for the current table
+ * have their associated *n_pkts_action* element always set to zero.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_pipeline_table_stats_read(struct rte_swx_pipeline *p,
+ const char *table_name,
+ struct rte_swx_table_stats *stats);
+
/*
* Table Update API.
*/
uint32_t regarray_index,
uint64_t value);
+/*
+ * Meter Array Query and Configuration API.
+ */
+
+/** Meter array info. */
+struct rte_swx_ctl_metarray_info {
+ /** Meter array name. */
+ char name[RTE_SWX_CTL_NAME_SIZE];
+
+ /** Meter array size. */
+ uint32_t size;
+};
+
+/**
+ * Meter array info get
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] metarray_id
+ * Meter array ID (0 .. *n_metarrays* - 1).
+ * @param[out] metarray
+ * Meter array info.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_metarray_info_get(struct rte_swx_pipeline *p,
+ uint32_t metarray_id,
+ struct rte_swx_ctl_metarray_info *metarray);
+
+/**
+ * Meter profile add
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] name
+ * Meter profile name.
+ * @param[in] params
+ * Meter profile parameters.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument;
+ * -ENOMEM: Not enough space/cannot allocate memory;
+ * -EEXIST: Meter profile with this name already exists.
+ */
+__rte_experimental
+int
+rte_swx_ctl_meter_profile_add(struct rte_swx_pipeline *p,
+ const char *name,
+ struct rte_meter_trtcm_params *params);
+
+/**
+ * Meter profile delete
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] name
+ * Meter profile name.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument;
+ * -EBUSY: Meter profile is currently in use.
+ */
+__rte_experimental
+int
+rte_swx_ctl_meter_profile_delete(struct rte_swx_pipeline *p,
+ const char *name);
+
+/**
+ * Meter reset
+ *
+ * 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] metarray_index
+ * Meter index within the meter array.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_meter_reset(struct rte_swx_pipeline *p,
+ const char *metarray_name,
+ uint32_t metarray_index);
+
+/**
+ * Meter set
+ *
+ * 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] metarray_index
+ * Meter index within the meter array.
+ * @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(struct rte_swx_pipeline *p,
+ const char *metarray_name,
+ uint32_t metarray_index,
+ const char *profile_name);
+
+/** Meter statistics counters. */
+struct rte_swx_ctl_meter_stats {
+ /** Number of packets tagged by the meter for each color. */
+ uint64_t n_pkts[RTE_COLORS];
+
+ /** Number of bytes tagged by the meter for each color. */
+ uint64_t n_bytes[RTE_COLORS];
+};
+
+/**
+ * Meter statistics counters read
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] metarray_name
+ * Meter array name.
+ * @param[in] metarray_index
+ * Meter index within the meter array.
+ * @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(struct rte_swx_pipeline *p,
+ const char *metarray_name,
+ uint32_t metarray_index,
+ struct rte_swx_ctl_meter_stats *stats);
+
/**
* Pipeline control free
*