table: fix actions with different data size
PATCH v2 1/1 table: fix actions with different data size
The table layer provisions an action_id and action_data_size data bytes for each table key. This action_data_size is a maximal amount, as some actions (depending on action_id) can require zero or less data bytes than the maximal action_data_size. This fix allows for actions with different data sizes to co-exist within the same table.
--- lib/librte_table/rte_swx_table_em.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
lib/librte_table/rte_swx_table_em.c +3 -4
@@ -337,7 +337,7 @@ bkt_key_install(struct table *t,/* Key data. */ bkt_data =table_key_data (t, bkt_key_id); bkt_data[0 ] = input->action_id; -if (t->params.action_data_size) +if (t->params.action_data_size && input->action_data)memcpy (&bkt_data[1 ], input->action_data, t->params.action_data_size);
@@ -358,7 +358,7 @@ bkt_key_data_update(struct table *t,/* Key data. */ bkt_data =table_key_data (t, bkt_key_id); bkt_data[0 ] = input->action_id; -if (t->params.action_data_size) +if (t->params.action_data_size && input->action_data)memcpy (&bkt_data[1 ], input->action_data, t->params.action_data_size);
@@ -485,8 +485,7 @@ table_add(void *table, struct rte_swx_table_entry *entry)CHECK (t,EINVAL );CHECK (entry,EINVAL );CHECK (entry->key,EINVAL ); -CHECK ((!t->params.action_data_size && !entry->action_data) || - (t->params.action_data_size && entry->action_data),EINVAL ); +CHECK (!entry->action_data || t->params.action_data_size,EINVAL ); input_sig =hash (entry->key, t->key_mask, t->key_size,0 ); bkt_id = input_sig & (t->n_buckets -1 );
Signature · 1 line
2.17.1
PATCH v3 1/1 table: fix actions with different data size
The table layer provisions an action_id and action_data_size data bytes for each table key. This action_data_size is a maximal amount, as some actions (depending on action_id) can require zero or less data bytes than the maximal action_data_size. This fix allows for actions with different data sizes to co-exist within the same table.
--- lib/librte_table/rte_swx_table_em.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/librte_table/rte_swx_table_em.c +2 -4
@@ -337,7 +337,7 @@ bkt_key_install(struct table *t,/* Key data. */ bkt_data =table_key_data (t, bkt_key_id); bkt_data[0 ] = input->action_id; -if (t->params.action_data_size) +if (t->params.action_data_size && input->action_data)memcpy (&bkt_data[1 ], input->action_data, t->params.action_data_size);
@@ -358,7 +358,7 @@ bkt_key_data_update(struct table *t,/* Key data. */ bkt_data =table_key_data (t, bkt_key_id); bkt_data[0 ] = input->action_id; -if (t->params.action_data_size) +if (t->params.action_data_size && input->action_data)memcpy (&bkt_data[1 ], input->action_data, t->params.action_data_size);
@@ -485,8 +485,6 @@ table_add(void *table, struct rte_swx_table_entry *entry)CHECK (t,EINVAL );CHECK (entry,EINVAL );CHECK (entry->key,EINVAL ); -CHECK ((!t->params.action_data_size && !entry->action_data) || - (t->params.action_data_size && entry->action_data),EINVAL ); input_sig =hash (entry->key, t->key_mask, t->key_size,0 ); bkt_id = input_sig & (t->n_buckets -1 );
Signature · 1 line
2.17.1
Thomas Monjalon
Applied17/03/2021 12:42, Cristian Dumitrescu:
Quoted 6 lines
The table layer provisions an
action_idandaction_data_sizedata bytes for each table key. Thisaction_data_sizeis a maximal amount, as some actions (depending onaction_id) can require zero or less data bytes than the maximalaction_data_size. This fix allows for actions with different data sizes to co-exist within the same table.
Quoted 6 lines
Fixes d0a00966618b ("table: add exact match SWX table")Signed-off-by Churchill Khangar <[email protected]>Signed-off-by Cristian Dumitrescu <[email protected]>
Applied, thanks