Skip to contentSkip to conversation

pipeline: add support for action annotations

PATCH Superseded Yogesh Jangra 2 participants 3 messages Oct 14, 2021 – Oct 25, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pipeline: add support for action annotations

Enable restricting the scope of an action to regular table entries or to the table default entry in order to support the P4 language tableonly or defaultonly annotations.

---
 lib/pipeline/rte_swx_ctl.c               |   6 ++
 lib/pipeline/rte_swx_ctl.h               |   6 ++
 lib/pipeline/rte_swx_pipeline.c          | 105 +++++++++++++++++++++++++------
 lib/pipeline/rte_swx_pipeline.h          |  28 +++++++++
 lib/pipeline/rte_swx_pipeline_internal.h |   4 ++
 lib/pipeline/rte_swx_pipeline_spec.c     | 101 +++++++++++++++++++++++------
 6 files changed, 212 insertions(+), 38 deletions(-)
lib/pipeline/rte_swx_ctl.c +6 -0
index 86b58e2..1c908e3 100644
@@ -1446,6 +1446,8 @@ struct rte_swx_ctl_pipeline *
 	CHECK(entry, EINVAL);
 	CHECK(!table_entry_check(ctl, table_id, entry, 1, 1), EINVAL);
 
+	CHECK(table->actions[entry->action_id].action_is_for_table_entries, EINVAL);
+
 	new_entry = table_entry_duplicate(ctl, table_id, entry, 1, 1);
 	CHECK(new_entry, ENOMEM);
 
@@ -1651,6 +1653,8 @@ struct rte_swx_ctl_pipeline *
 	CHECK(entry, EINVAL);
 	CHECK(!table_entry_check(ctl, table_id, entry, 0, 1), EINVAL);
 
+	CHECK(table->actions[entry->action_id].action_is_for_default_entry, EINVAL);
+
 	new_entry = table_entry_duplicate(ctl, table_id, entry, 0, 1);
 	CHECK(new_entry, ENOMEM);
 
@@ -2378,6 +2382,8 @@ struct rte_swx_ctl_pipeline *
 	CHECK(entry, EINVAL);
 	CHECK(!learner_default_entry_check(ctl, learner_id, entry), EINVAL);
 
+	CHECK(l->actions[entry->action_id].action_is_for_default_entry, EINVAL);
+
 	new_entry = learner_default_entry_duplicate(ctl, learner_id, entry);
 	CHECK(new_entry, ENOMEM);
 
lib/pipeline/rte_swx_ctl.h +6 -0
index 8075972..46d0582 100644
@@ -301,6 +301,12 @@ struct rte_swx_ctl_table_match_field_info {
 struct rte_swx_ctl_table_action_info {
 	/** Action ID. */
 	uint32_t action_id;
+
+	/**  When non-zero (true), the action can be assigned to regular table entries. */
+	int action_is_for_table_entries;
+
+	/**  When non-zero (true), the action can be assigned to the table default entry. */
+	int action_is_for_default_entry;
 };
 
 /**
lib/pipeline/rte_swx_pipeline.c +86 -19

209 lines not on this page · raw message

lib/pipeline/rte_swx_pipeline.h +28 -0
index 490ff60..9c3d081 100644
@@ -567,6 +567,20 @@ struct rte_swx_pipeline_table_params {
 	/** 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;
@@ -692,6 +706,20 @@ struct rte_swx_pipeline_learner_params {
 	/** 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;
lib/pipeline/rte_swx_pipeline_internal.h +4 -0
index 4361c53..1921fdc 100644
@@ -746,6 +746,8 @@ struct table {
 	uint32_t n_actions;
 	int default_action_is_const;
 	uint32_t action_data_size_max;
+	int *action_is_for_table_entries;
+	int *action_is_for_default_entry;
 
 	uint32_t size;
 	uint32_t id;
@@ -815,6 +817,8 @@ struct learner {
 	uint32_t n_actions;
 	int default_action_is_const;
 	uint32_t action_data_size_max;
+	int *action_is_for_table_entries;
+	int *action_is_for_default_entry;
 
 	uint32_t size;
 	uint32_t timeout;
lib/pipeline/rte_swx_pipeline_spec.c +82 -19

182 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 pipeline: add support for action annotations

Enable restricting the scope of an action to regular table entries or to the table default entry in order to support the P4 language tableonly or defaultonly annotations.

---
 lib/pipeline/rte_swx_ctl.c               |   6 ++
 lib/pipeline/rte_swx_ctl.h               |   6 ++
 lib/pipeline/rte_swx_pipeline.c          | 108 +++++++++++++++++++++++++------
 lib/pipeline/rte_swx_pipeline.h          |  28 ++++++++
 lib/pipeline/rte_swx_pipeline_internal.h |   4 ++
 lib/pipeline/rte_swx_pipeline_spec.c     | 101 +++++++++++++++++++++++------
 6 files changed, 215 insertions(+), 38 deletions(-)
lib/pipeline/rte_swx_ctl.c +6 -0
index 86b58e2..1c908e3 100644
@@ -1446,6 +1446,8 @@ struct rte_swx_ctl_pipeline *
 	CHECK(entry, EINVAL);
 	CHECK(!table_entry_check(ctl, table_id, entry, 1, 1), EINVAL);
 
+	CHECK(table->actions[entry->action_id].action_is_for_table_entries, EINVAL);
+
 	new_entry = table_entry_duplicate(ctl, table_id, entry, 1, 1);
 	CHECK(new_entry, ENOMEM);
 
@@ -1651,6 +1653,8 @@ struct rte_swx_ctl_pipeline *
 	CHECK(entry, EINVAL);
 	CHECK(!table_entry_check(ctl, table_id, entry, 0, 1), EINVAL);
 
+	CHECK(table->actions[entry->action_id].action_is_for_default_entry, EINVAL);
+
 	new_entry = table_entry_duplicate(ctl, table_id, entry, 0, 1);
 	CHECK(new_entry, ENOMEM);
 
@@ -2378,6 +2382,8 @@ struct rte_swx_ctl_pipeline *
 	CHECK(entry, EINVAL);
 	CHECK(!learner_default_entry_check(ctl, learner_id, entry), EINVAL);
 
+	CHECK(l->actions[entry->action_id].action_is_for_default_entry, EINVAL);
+
 	new_entry = learner_default_entry_duplicate(ctl, learner_id, entry);
 	CHECK(new_entry, ENOMEM);
 
lib/pipeline/rte_swx_ctl.h +6 -0
index 8075972..46d0582 100644
@@ -301,6 +301,12 @@ struct rte_swx_ctl_table_match_field_info {
 struct rte_swx_ctl_table_action_info {
 	/** Action ID. */
 	uint32_t action_id;
+
+	/**  When non-zero (true), the action can be assigned to regular table entries. */
+	int action_is_for_table_entries;
+
+	/**  When non-zero (true), the action can be assigned to the table default entry. */
+	int action_is_for_default_entry;
 };
 
 /**
lib/pipeline/rte_swx_pipeline.c +89 -19

212 lines not on this page · raw message

lib/pipeline/rte_swx_pipeline.h +28 -0
index 490ff60..9c3d081 100644
@@ -567,6 +567,20 @@ struct rte_swx_pipeline_table_params {
 	/** 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;
@@ -692,6 +706,20 @@ struct rte_swx_pipeline_learner_params {
 	/** 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;
lib/pipeline/rte_swx_pipeline_internal.h +4 -0
index 4361c53..1921fdc 100644
@@ -746,6 +746,8 @@ struct table {
 	uint32_t n_actions;
 	int default_action_is_const;
 	uint32_t action_data_size_max;
+	int *action_is_for_table_entries;
+	int *action_is_for_default_entry;
 
 	uint32_t size;
 	uint32_t id;
@@ -815,6 +817,8 @@ struct learner {
 	uint32_t n_actions;
 	int default_action_is_const;
 	uint32_t action_data_size_max;
+	int *action_is_for_table_entries;
+	int *action_is_for_default_entry;
 
 	uint32_t size;
 	uint32_t timeout;
lib/pipeline/rte_swx_pipeline_spec.c +82 -19

182 lines not on this page · raw message

Signature · 1 line
1.8.3.1