#include <stddef.h>
#include <stdint.h>
+#include <stdio.h>
#include <rte_compat.h>
+#include <rte_meter.h>
#include "rte_swx_port.h"
#include "rte_swx_table.h"
/** Number of tables. */
uint32_t n_tables;
+
+ /** Number of register arrays. */
+ uint32_t n_regarrays;
+
+ /** Number of meter arrays. */
+ uint32_t n_metarrays;
};
/**
/** Action argument size (in bits). */
uint32_t n_bits;
+
+ /** Non-zero (true) when this action argument must be stored in the
+ * table in network byte order (NBO), zero when it must be stored in
+ * host byte order (HBO).
+ */
+ int is_network_byte_order;
};
/**
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.
*/
rte_swx_pipeline_table_state_set(struct rte_swx_pipeline *p,
struct rte_swx_table_state *table_state);
+/*
+ * High Level Reference Table Update API.
+ */
+
+/** Pipeline control opaque data structure. */
+struct rte_swx_ctl_pipeline;
+
+/**
+ * Pipeline control create
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @return
+ * Pipeline control handle, on success, or NULL, on error.
+ */
+__rte_experimental
+struct rte_swx_ctl_pipeline *
+rte_swx_ctl_pipeline_create(struct rte_swx_pipeline *p);
+
+/**
+ * Pipeline table entry add
+ *
+ * Schedule entry for addition to table or update as part of the next commit
+ * operation.
+ *
+ * @param[in] ctl
+ * Pipeline control handle.
+ * @param[in] table_name
+ * Table name.
+ * @param[in] entry
+ * Entry to be added to the table.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_pipeline_table_entry_add(struct rte_swx_ctl_pipeline *ctl,
+ const char *table_name,
+ struct rte_swx_table_entry *entry);
+
+/**
+ * Pipeline table default entry add
+ *
+ * Schedule table default entry update as part of the next commit operation.
+ *
+ * @param[in] ctl
+ * Pipeline control handle.
+ * @param[in] table_name
+ * Table name.
+ * @param[in] entry
+ * The new table default entry. The *key* and *key_mask* entry fields are
+ * ignored.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_pipeline_table_default_entry_add(struct rte_swx_ctl_pipeline *ctl,
+ const char *table_name,
+ struct rte_swx_table_entry *entry);
+
+/**
+ * Pipeline table entry delete
+ *
+ * Schedule entry for deletion from table as part of the next commit operation.
+ * Request is silently discarded if no such entry exists.
+ *
+ * @param[in] ctl
+ * Pipeline control handle.
+ * @param[in] table_name
+ * Table name.
+ * @param[in] entry
+ * Entry to be deleted from the table. The *action_id* and *action_data* entry
+ * fields are ignored.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_pipeline_table_entry_delete(struct rte_swx_ctl_pipeline *ctl,
+ const char *table_name,
+ struct rte_swx_table_entry *entry);
+
+/**
+ * Pipeline commit
+ *
+ * Perform all the scheduled table work.
+ *
+ * @param[in] ctl
+ * Pipeline control handle.
+ * @param[in] abort_on_fail
+ * When non-zero (false), all the scheduled work is discarded after a failed
+ * commit. Otherwise, the scheduled work is still kept pending for the next
+ * commit.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_pipeline_commit(struct rte_swx_ctl_pipeline *ctl,
+ int abort_on_fail);
+
+/**
+ * Pipeline abort
+ *
+ * Discard all the scheduled table work.
+ *
+ * @param[in] ctl
+ * Pipeline control handle.
+ */
+__rte_experimental
+void
+rte_swx_ctl_pipeline_abort(struct rte_swx_ctl_pipeline *ctl);
+
+/**
+ * Pipeline table entry read
+ *
+ * Read table entry from string.
+ *
+ * @param[in] ctl
+ * Pipeline control handle.
+ * @param[in] table_name
+ * Table name.
+ * @param[in] string
+ * String containing the table entry.
+ * @param[out] is_blank_or_comment
+ * On error, this argument provides an indication of whether *string* contains
+ * an invalid table entry (set to zero) or a blank or comment line that should
+ * typically be ignored (set to a non-zero value).
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+struct rte_swx_table_entry *
+rte_swx_ctl_pipeline_table_entry_read(struct rte_swx_ctl_pipeline *ctl,
+ const char *table_name,
+ const char *string,
+ int *is_blank_or_comment);
+
+/**
+ * Pipeline table print to file
+ *
+ * Print all the table entries to file.
+ *
+ * @param[in] f
+ * Output file.
+ * @param[in] ctl
+ * Pipeline control handle.
+ * @param[in] table_name
+ * Table name.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_pipeline_table_fprintf(FILE *f,
+ struct rte_swx_ctl_pipeline *ctl,
+ const char *table_name);
+
+/*
+ * Register Array Query API.
+ */
+
+/** Register array info. */
+struct rte_swx_ctl_regarray_info {
+ /** Register array name. */
+ char name[RTE_SWX_CTL_NAME_SIZE];
+
+ /** Register array size. */
+ uint32_t size;
+};
+
+/**
+ * Register array info get
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] regarray_id
+ * Register array ID (0 .. *n_regarrays* - 1).
+ * @param[out] regarray
+ * Register array info.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_regarray_info_get(struct rte_swx_pipeline *p,
+ uint32_t regarray_id,
+ struct rte_swx_ctl_regarray_info *regarray);
+
+/**
+ * Register read
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] regarray_name
+ * Register array name.
+ * @param[in] regarray_index
+ * Register index within the array (0 .. *size* - 1).
+ * @param[out] value
+ * Current register value.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_pipeline_regarray_read(struct rte_swx_pipeline *p,
+ const char *regarray_name,
+ uint32_t regarray_index,
+ uint64_t *value);
+
+/**
+ * Register write
+ *
+ * @param[in] p
+ * Pipeline handle.
+ * @param[in] regarray_name
+ * Register array name.
+ * @param[in] regarray_index
+ * Register index within the array (0 .. *size* - 1).
+ * @param[in] value
+ * Value to be written to the register.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument.
+ */
+__rte_experimental
+int
+rte_swx_ctl_pipeline_regarray_write(struct rte_swx_pipeline *p,
+ const char *regarray_name,
+ 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
+ *
+ * @param[in] ctl
+ * Pipeline control handle.
+ */
+__rte_experimental
+void
+rte_swx_ctl_pipeline_free(struct rte_swx_ctl_pipeline *ctl);
+
#ifdef __cplusplus
}
#endif