table: relax requirements for entry action data

Currently, the table entry action data is required to be NULL when the
action data size is zero. We now require that action data is ignored
when the action data size is zero. This is to allow for a table entry
instance to be allocated once with max action data size for the table
and reused repeatedly for actions of different sizes, including zero.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Churchill Khangar <churchill.khangar@intel.com>
This commit is contained in:
Churchill Khangar 2021-03-26 20:22:24 +00:00 committed by Thomas Monjalon
parent 97005a6665
commit 1af0e07b27
2 changed files with 6 additions and 6 deletions

View File

@ -338,8 +338,7 @@ table_entry_check(struct rte_swx_ctl_pipeline *ctl,
/* action_data. */
a = &ctl->actions[entry->action_id];
CHECK((a->data_size && entry->action_data) ||
(!a->data_size && !entry->action_data), EINVAL);
CHECK(!(a->data_size && !entry->action_data), EINVAL);
}
return 0;

View File

@ -101,10 +101,11 @@ struct rte_swx_table_entry {
/** Action ID for the current entry. */
uint64_t action_id;
/** Action data for the current entry. Its size is defined by the action
* specified by the *action_id*. It must be NULL when the action data
* size of the *action_id* action is NULL. It must never exceed the
* *action_data_size* of the table.
/** Action data for the current entry. Considering S as the action data
* size of the *action_id* action, which must be less than or equal to
* the table *action_data_size*, the *action_data* field must point to
* an array of S bytes when S is non-zero. The *action_data* field is
* ignored when S is zero.
*/
uint8_t *action_data;
};