* RTE SWX Pipeline
*/
-#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
* Similar to C language structs, they are a well defined sequence of fields,
* with each field having a unique name and a constant size.
*
+ * In order to use structs to express variable size packet headers such as IPv4
+ * with options, it is allowed for the last field of the struct type to have a
+ * variable size between 0 and *n_bits* bits, with the actual size of this field
+ * determined at run-time for each packet. This struct feature is restricted to
+ * just a few selected instructions that deal with packet headers, so a typical
+ * struct generally has a constant size that is fully known when its struct type
+ * is registered.
+ *
* @param[in] p
* Pipeline handle.
* @param[in] name
* The sequence of struct fields.
* @param[in] n_fields
* The number of struct fields.
+ * @param[in] last_field_has_variable_size
+ * If non-zero (true), then the last field has a variable size between 0 and
+ * *n_bits* bits, with its actual size determined at run-time for each packet.
+ * If zero (false), then the last field has a constant size of *n_bits* bits.
* @return
* 0 on success or the following error codes otherwise:
* -EINVAL: Invalid argument;
rte_swx_pipeline_struct_type_register(struct rte_swx_pipeline *p,
const char *name,
struct rte_swx_field_params *fields,
- uint32_t n_fields);
+ uint32_t n_fields,
+ int last_field_has_variable_size);
/**
* Pipeline packet header register
/** The set of actions for the current table. */
const char **action_names;
+ /** Array of *n_actions* flags. For each action, the associated flag
+ * indicates whether the action can be assigned to regular table entries
+ * (when non-zero, i.e. true) or not (when zero, i.e. false). When set
+ * to NULL, it defaults to true for all actions.
+ */
+ int *action_is_for_table_entries;
+
+ /** Array of *n_actions* flags. For each action, the associated flag
+ * indicates whether the action can be assigned to the default table
+ * entry (when non-zero, i.e. true) or not (when zero, i.e. false).
+ * When set to NULL, it defaults to true for all actions.
+ */
+ int *action_is_for_default_entry;
+
/** The number of actions for the current table. Must be at least one.
*/
uint32_t n_actions;
const char *args,
uint32_t size);
+/** Pipeline selector table parameters. */
+struct rte_swx_pipeline_selector_params {
+ /** The group ID field. Input into the selection operation.
+ * Restriction: This field must be a meta-data field.
+ */
+ const char *group_id_field_name;
+
+ /** The set of fields used to select (through a hashing scheme) the
+ * member within the current group. Inputs into the selection operation.
+ * Restriction: All the selector fields must be part of the same struct,
+ * i.e. part of the same header or part of the meta-data structure.
+ */
+ const char **selector_field_names;
+
+ /** The number of selector fields. Must be non-zero. */
+ uint32_t n_selector_fields;
+
+ /** The member ID field. Output from the selection operation.
+ * Restriction: This field must be a meta-data field.
+ */
+ const char *member_id_field_name;
+
+ /** Maximum number of groups. Must be non-zero. */
+ uint32_t n_groups_max;
+
+ /** Maximum number of members per group. Must be non-zero. */
+ uint32_t n_members_per_group_max;
+};
+
+/**
+ * Pipeline selector table configure
+ *
+ * @param[out] p
+ * Pipeline handle.
+ * @param[in] name
+ * Selector table name.
+ * @param[in] params
+ * Selector table parameters.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument;
+ * -ENOMEM: Not enough space/cannot allocate memory;
+ * -EEXIST: Selector table with this name already exists;
+ * -ENODEV: Selector table creation error.
+ */
+__rte_experimental
+int
+rte_swx_pipeline_selector_config(struct rte_swx_pipeline *p,
+ const char *name,
+ struct rte_swx_pipeline_selector_params *params);
+
+/** Pipeline learner table parameters. */
+struct rte_swx_pipeline_learner_params {
+ /** The set of match fields for the current table.
+ * Restriction: All the match fields of the current table need to be
+ * part of the same struct, i.e. either all the match fields are part of
+ * the same header or all the match fields are part of the meta-data.
+ */
+ const char **field_names;
+
+ /** The number of match fields for the current table. Must be non-zero.
+ */
+ uint32_t n_fields;
+
+ /** The set of actions for the current table. */
+ const char **action_names;
+
+ /** Array of *n_actions* flags. For each action, the associated flag
+ * indicates whether the action can be assigned to regular table entries
+ * (when non-zero, i.e. true) or not (when zero, i.e. false). When set
+ * to NULL, it defaults to true for all actions.
+ */
+ int *action_is_for_table_entries;
+
+ /** Array of *n_actions* flags. For each action, the associated flag
+ * indicates whether the action can be assigned to the default table
+ * entry (when non-zero, i.e. true) or not (when zero, i.e. false).
+ * When set to NULL, it defaults to true for all actions.
+ */
+ int *action_is_for_default_entry;
+
+ /** The number of actions for the current table. Must be at least one.
+ */
+ uint32_t n_actions;
+
+ /** The default table action that gets executed on lookup miss. Must be
+ * one of the table actions included in the *action_names*.
+ */
+ const char *default_action_name;
+
+ /** Default action data. The size of this array is the action data size
+ * of the default action. Must be NULL if the default action data size
+ * is zero.
+ */
+ uint8_t *default_action_data;
+
+ /** If non-zero (true), then the default action of the current table
+ * cannot be changed. If zero (false), then the default action can be
+ * changed in the future with another action from the *action_names*
+ * list.
+ */
+ int default_action_is_const;
+};
+
+/**
+ * Pipeline learner table configure
+ *
+ * @param[out] p
+ * Pipeline handle.
+ * @param[in] name
+ * Learner table name.
+ * @param[in] params
+ * Learner table parameters.
+ * @param[in] size
+ * The maximum number of table entries. Must be non-zero.
+ * @param[in] timeout
+ * Table entry timeout in seconds. Must be non-zero.
+ * @return
+ * 0 on success or the following error codes otherwise:
+ * -EINVAL: Invalid argument;
+ * -ENOMEM: Not enough space/cannot allocate memory;
+ * -EEXIST: Learner table with this name already exists;
+ * -ENODEV: Learner table creation error.
+ */
+__rte_experimental
+int
+rte_swx_pipeline_learner_config(struct rte_swx_pipeline *p,
+ const char *name,
+ struct rte_swx_pipeline_learner_params *params,
+ uint32_t size,
+ uint32_t timeout);
+
/**
* Pipeline register array configure
*