ethdev: add template table resize API
PATCH 1/1 ethdev: add template table resize API
Template table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.
Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.
The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE bit set.
* Application resizes existing table with the rte_flow_template_table_resize() function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handlers held by
application.
* After rte_flow_template_table_resize() returned, application must update all existing table flow rules by calling rte_flow_async_update_resized().
The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize. rte_flow_async_update_resized() moves internal flow references to the updated table resources.
The flow update must not interrupt hardware flow operations.
* When all table flow were updated, application must call rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize after rte_flow_template_table_resize_complete() returned.
--- app/test-pmd/cmdline_flow.c | 86 +++++++++++++++++++-- app/test-pmd/config.c | 102 +++++++++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++ doc/guides/rel_notes/release_24_03.rst | 2 + lib/ethdev/ethdev_trace.h | 33 ++++++++ lib/ethdev/ethdev_trace_points.c | 9 +++ lib/ethdev/rte_flow.c | 69 +++++++++++++++++ lib/ethdev/rte_flow.h | 97 +++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 ++++ lib/ethdev/version.map | 3 + 10 files changed, 417 insertions(+), 5 deletions(-)
app/test-pmd/cmdline_flow.c +81 -5
@@ -134,6 +134,7 @@ enum index {/* Queue arguments. */ QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED , QUEUE_INDIRECT_ACTION,
@@ -191,8 +192,12 @@ enum index {/* Table arguments. */ TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,TABLE_CREATE_ID ,TABLE_DESTROY_ID , +TABLE_RESIZE_ID , +TABLE_RESIZE_RULES_NUMBER ,TABLE_INSERTION_TYPE ,TABLE_INSERTION_TYPE_NAME , TABLE_HASH_FUNC,
@@ -204,6 +209,7 @@ enum index {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1323,6 +1329,8 @@ static const enum index next_group_attr[] = {static const enum index next_table_subcmd[] = {TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,ZERO , };
@@ -1337,6 +1345,7 @@ static const enum index next_table_attr[] = {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1353,6 +1362,7 @@ static const enum index next_table_destroy_attr[] = {static const enum index next_queue_subcmd[] = {QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED ,QUEUE_INDIRECT_ACTION ,
@@ -3344,6 +3354,19 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_table_destroy, }, + [TABLE_RESIZE] = { + .name = "resize", + .help = "resize template table", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)), + .call = parse_table + }, + [TABLE_RESIZE_COMPLETE] = { + .name = "resize_complete", + .help = "complete table resize", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + },/* Table arguments. */ [TABLE_CREATE_ID] = { .name = "table_id",
@@ -3354,13 +3377,29 @@ static const struct token token_list[] = { }, [TABLE_DESTROY_ID] = { .name = "table", - .help = "specify table id to destroy", + .help = "table id", .next =NEXT (next_table_destroy_attr, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_RESIZE_ID] = { + .name = "table_resize_id", + .help = "table resize id", + .next =NEXT (NEXT_ENTRY (TABLE_RESIZE_RULES_NUMBER ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + .call = parse_table + }, + [TABLE_RESIZE_RULES_NUMBER] = { + .name = "table_resize_rules_num", + .help = "table resize rules number", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + .call = parse_table + }, [TABLE_INSERTION_TYPE] = { .name = "insertion_type", .help = "specify insertion type",
@@ -3433,6 +3472,12 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_RESIZABLE] = { + .name = "resizable", + .help = "set resizable attribute", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table",
@@ -3525,6 +3570,14 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_FLOW_UPDATE_RESIZED] = { + .name = "update_resized", + .help = "update a flow after table resize", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, [QUEUE_UPDATE] = { .name = "update", .help = "update a flow rule",
@@ -10334,6 +10387,7 @@ parse_table(struct context *ctx, const struct token *token, }switch (ctx->curr) {case TABLE_CREATE : +case TABLE_RESIZE : out->command = ctx->curr; ctx->objdata =0 ; ctx->object = out;
@@ -10378,18 +10432,25 @@ parse_table(struct context *ctx, const struct token *token,case TABLE_TRANSFER_WIRE_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ;return len;case TABLE_TRANSFER_VPORT_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; +return len; +case TABLE_RESIZABLE : + out->args.table.attr.specialize |= +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE ;return len;case TABLE_RULES_NUMBER : ctx->objdata =0 ; ctx->object = out; ctx->objmask =NULL ;return len; +case TABLE_RESIZE_ID : +case TABLE_RESIZE_RULES_NUMBER : +return len;default :return -1 ; }
@@ -10411,7 +10472,8 @@ parse_table_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==TABLE ) { -if (ctx->curr !=TABLE_DESTROY ) +if (ctx->curr !=TABLE_DESTROY && + ctx->curr !=TABLE_RESIZE_COMPLETE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -10513,7 +10575,8 @@ parse_qo_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==QUEUE ) { -if (ctx->curr !=QUEUE_DESTROY ) +if (ctx->curr !=QUEUE_DESTROY && + ctx->curr !=QUEUE_FLOW_UPDATE_RESIZED )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -12569,10 +12632,18 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case TABLE_RESIZE_COMPLETE : +port_flow_template_table_resize_complete + (in->port, in->args.table_destroy.table_id[0 ]); +break ;case GROUP_SET_MISS_ACTIONS :port_queue_group_set_miss_actions (in->port, &in->args.vc.attr, in->args.vc.actions);break ; +case TABLE_RESIZE : +port_flow_template_table_resize (in->port, in->args.table.id, + in->args.table.attr.nb_flows); +break ;case QUEUE_CREATE : port_queue_flow_create(in->port, in->queue, in->postpone, in->args.vc.table_id, in->args.vc.rule_id,
@@ -12584,6 +12655,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case QUEUE_FLOW_UPDATE_RESIZED : +port_queue_flow_update_resized (in->port, in->queue, + in->postpone, + in->args.destroy.rule[0 ]); +break ;case QUEUE_UPDATE : port_queue_flow_update(in->port, in->queue, in->postpone, in->args.vc.rule_id, in->args.vc.act_templ_id,
app/test-pmd/config.c +102 -0
126 lines not on this page · raw message
app/test-pmd/testpmd.h +6 -0
@@ -110,6 +110,7 @@ enum {enum {QUEUE_JOB_TYPE_FLOW_CREATE ,QUEUE_JOB_TYPE_FLOW_DESTROY , +QUEUE_JOB_TYPE_FLOW_TRANSFER ,QUEUE_JOB_TYPE_FLOW_UPDATE ,QUEUE_JOB_TYPE_ACTION_CREATE ,QUEUE_JOB_TYPE_ACTION_DESTROY ,
@@ -981,7 +982,12 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates);int port_flow_template_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_update_resized (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t flow_id);int port_flow_template_table_flush (portid_t port_id); +int port_flow_template_table_resize_complete (portid_t port_id,uint32_t table_id); +int port_flow_template_table_resize (portid_t port_id, +uint32_t table_id,uint32_t flows_num);int port_queue_group_set_miss_actions (portid_t port_id,const struct rte_flow_attr *attr,const struct rte_flow_action *actions); int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -55,6 +55,8 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support for template API table resize.** + Removed Items -------------
lib/ethdev/ethdev_trace.h +33 -0
@@ -2572,6 +2572,39 @@ RTE_TRACE_POINT_FP(rte_trace_point_emit_ptr (user_data);rte_trace_point_emit_int (ret); ) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_template_table_resize, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_u32 (nb_rules); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_async_update_resized, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_u32 (queue); +rte_trace_point_emit_ptr (attr); +rte_trace_point_emit_ptr (rule); +rte_trace_point_emit_ptr (user_data); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_table_resize_complete, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_int (ret); +) #ifdef __cplusplus }#endif
lib/ethdev/ethdev_trace_points.c +9 -0
@@ -774,3 +774,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_destroy,RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_action_list_handle_query_update, lib.ethdev.flow.async_action_list_handle_query_update) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_template_table_resize, + lib.ethdev.flow.template_table_resize) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_update_resized, + lib.ethdev.flow.async_update_resized) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_table_resize_complete, + lib.ethdev.flow.table_resize_complete)
lib/ethdev/rte_flow.c +69 -0
72 lines not on this page · raw message
lib/ethdev/rte_flow.h +97 -0
115 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +15 -0
@@ -370,6 +370,21 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_template_table *table, const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** @see rte_flow_template_table_resize() */ +int (*flow_template_table_resize)(struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** @see rte_flow_async_update_resized() */ +int (*flow_update_resized)(struct rte_eth_dev *dev,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +/** @see rte_flow_template_table_resize_complete() */ +int (*flow_template_table_resize_complete) + (struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +struct rte_flow_error *error); };/**
lib/ethdev/version.map +3 -0
@@ -316,6 +316,9 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete; }; INTERNAL {
Signature · 1 line
2.39.2
Quoted 39 lines · Gregory Etelson
Template table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the
RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLEbit set.* Application resizes existing table with the
rte_flow_template_table_resize()function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handlers held by
application.* After
rte_flow_template_table_resize()returned, application must update all existing table flow rules by callingrte_flow_async_update_resized().
The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize.rte_flow_async_update_resized()moves internal flow references to the updated table resources.
The flow update must not interrupt hardware flow operations.
Quoted 7 lines
* When all table flow were updated, application must call
rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize afterrte_flow_template_table_resize_complete()returned.
Hi Gregory, Ori,
Why we need three separate APIs,
rte_flow_template_table_resize
rte_flow_async_update_resized
rte_flow_template_table_resize_complete
Why not 'rte_flow_template_table_resize()' update existing flows and release resources related to the original tables automatically?
Hello Ferruh,
Quoted 11 lines
Hi Gregory, Ori,
Why we need three separate APIs,
rte_flow_template_table_resizerte_flow_async_update_resizedrte_flow_template_table_resize_completeWhy not '
rte_flow_template_table_resize()' update existing flows and release resources related to the original tables automatically?
Template table resize API allows to add new flows immediately after rte_flow_template_table_resize completed. A multi-threaded application can add new and update old flows simultaneously.
A single resize-and-update API would require to lock PMD for entire operation. For application with 1e6 flows doubling a table would end up with considerable down time.
The rte_flow_template_table_resize_complete was added for PMDs that cannot differentiate flows created before and after table resize.
Regards,
Gregory
Quoted 20 lines · Gregory
Hello Ferruh,
Quoted 11 lines
Hi Gregory, Ori,
Why we need three separate APIs,
rte_flow_template_table_resizerte_flow_async_update_resizedrte_flow_template_table_resize_completeWhy not '
rte_flow_template_table_resize()' update existing flows and release resources related to the original tables automatically?Template table resize API allows to add new flows immediately after
rte_flow_template_table_resizecompleted.
A multi-threaded application can add new and update old flows simultaneously.
Quoted 5 lines
A single resize-and-update API would require to lock PMD for entire operation.
For application with 1e6 flows doubling a table would end up with considerable down time.
If a multi-threaded application can add new and updated old simultaneously, this should be done via monolithic API, like:
{
lock
resize
unlock
for each flow
lock
update
unlock
}
Perhaps questions is, is there a usecase that user does the resize but doesn't want to update the old flows?
Quoted 3 lines
The
rte_flow_template_table_resize_completewas added for PMDs that cannot differentiate flows created before and after table resize.
Can you please elaborate this?
Does it mean old flows and new flows require different handling and PMD doesn't know how to differentiate old and new flows?
If so how update() converts old flows, there must be a way for driver to differentiate them for update() to work.
Also if resize_complete() NOT called at all, does this mean PMD can't handle any flows anymore as it can't differentiate old and new ones?
Hello Ferruh,
Quoted 13 lines
If a multi-threaded application can add new and updated old simultaneously, this should be done via monolithic API, like:
{
lock
resize
unlock
for each flow
lock
update
unlock
}
The flow template API was designed for performance. Application that implements the flow template API expects high flows insertions, updates, and removals rates.
Locks are necessary for the table resize API.
During the monolithic resize, application has no control over
PMD locks. Even if resize and each update operations are
relatively fast, application should expect table lock collisions
in rules insertions, deletions and updates for the entire resize-and-update-and-update operation.
With the separate resize API, lock collisions are expected during the resize phase only.
After table resize completed, all flow operations will obtain a lock without collision.
Also, application does not have to update all flows at once. Updates can be executed in batches scheduled by application. Another use case: application can increase a table, offload all new flows and run updates while hardware handles network traffic according to the new flows scheme.
Quoted 2 lines
Perhaps questions is, is there a usecase that user does the resize but doesn't want to update the old flows?
Please see below.
Quoted 7 lines
Quoted 4 lines
The
rte_flow_template_table_resize_completewas added for PMDs that cannot differentiate flows created before and after table resize.Can you please elaborate this?
Quoted 8 lines
Does it mean old flows and new flows require different handling and PMD doesn't know how to differentiate old and new flows?
If so howupdate()converts old flows, there must be a way for driver to differentiate them forupdate()to work.Also if
resize_complete()NOT called at all, does this mean PMD can't handle any flows anymore as it can't differentiate old and new ones?
Table resize API do not have any effect on running flows.
PMD uses the same procedure to create flows before and after table resize. All flows instantiated from the same type before and after table resize.
Flow update that follows table resize manages PMD flow object location. In MLX5 PMD, flow update moves an object that references a flow from old table to a new table.
After all flows were moved to a new table, PMD has no need for the old table and it can be released.
Since flow update manages PMD memory only, application can ignore the update operation if it does not care about effective memory management.
PMD can release the old flow table after all flows it referenced were moved to a new table only.
Event that notifies PMD about empty old table can be ether internal or external.
Internal event assumes PMD ability to track flows in a table. External event in form of application call is more general approach.
Application must call resize_complete after it moved all flows
to the new table. That call notifies PMD that it safe to release resources related to old table. If application did not update flows it must not call resize_complte.
Application can create new flows after table resize regardless if it managed PMD memory with update and resize_complete calls or not.
Quoted 79 lines · Gregory
Hello Ferruh,
Quoted 13 lines
If a multi-threaded application can add new and updated old simultaneously, this should be done via monolithic API, like:
{
lock
resize
unlock
for each flow
lock
update
unlock
}The flow template API was designed for performance. Application that implements the flow template API expects high flows insertions, updates, and removals rates.
Locks are necessary for the table resize API.During the monolithic resize, application has no control over PMD locks. Even if resize and each update operations are relatively fast, application should expect table lock collisions in rules insertions, deletions and updates for the entire resize-and-update-and-update operation.
With the separate resize API, lock collisions are expected during the resize phase only.
After table resize completed, all flow operations will obtain a lock without collision.
Also, application does not have to update all flows at once. Updates can be executed in batches scheduled by application. Another use case: application can increase a table, offload all new flows and run updates while hardware handles network traffic according to the new flows scheme.Quoted 2 lines
Perhaps questions is, is there a usecase that user does the resize but doesn't want to update the old flows?
Please see below.
Quoted 7 lines
Quoted 4 lines
The
rte_flow_template_table_resize_completewas added for PMDs that cannot differentiate flows created before and after table resize.Can you please elaborate this?
Quoted 8 lines
Does it mean old flows and new flows require different handling and PMD doesn't know how to differentiate old and new flows?
If so howupdate()converts old flows, there must be a way for driver to differentiate them forupdate()to work.Also if
resize_complete()NOT called at all, does this mean PMD can't handle any flows anymore as it can't differentiate old and new ones?Table resize API do not have any effect on running flows.
PMD uses the same procedure to create flows before and after table resize. All flows instantiated from the same type before and after table resize.Flow update that follows table resize manages PMD flow object location. In MLX5 PMD, flow update moves an object that references a flow from old table to a new table.
After all flows were moved to a new table, PMD has no need for the old table and it can be released.Since flow update manages PMD memory only, application can ignore the update operation if it does not care about effective memory management.
PMD can release the old flow table after all flows it referenced were moved to a new table only.
Event that notifies PMD about empty old table can be ether internal or external.
Internal event assumes PMD ability to track flows in a table. External event in form of application call is more general approach.
Quoted 9 lines
Application must call
resize_completeafter it moved all flows to the new table. That call notifies PMD that it safe to release resources related to old table.
If application did not update flows it must not callresize_complte.Application can create new flows after table resize regardless if it managed PMD memory with update and
resize_completecalls or not.
Thanks for clarification.
So, by design, driver will keep the old table when it is resized.
- Can this have a performance impact, like when rules updated/removed/inserted driver will need to look more tables?
- Or can this cause additional capacity complexity, like total number of rules will be sum of rules in all tables, but new rules only can be added to latest table, so number of rules can be more than size of latest table.
- Or user can add more flows after resize() and this may not leave enough room to update old rules to new table, what is expected behavior for this case?
- Or if user did not updated rules at all after resize(), after each rule deletion driver won't need to check if old table emptied and needs to be freed?
- Or can user call resize() API multiple times, causing driver to maintain multiple tables? How much memory overhead this may bring?
'rte_flow_async_update_resized()' API is called per flow, won't this force application to trace which flows are created in new table and which are in old table, so pushing additional work to application.
Or what will happen if update() fails in the middle of update, should user retry, should PMD restore back the moved rules?
I understood the logic behind the dividing responsibility to multiple APIs, and it makes sense, but it brings above complexities, and more work to application.
Can it be possible to have monolithic API but only resize() part of it is blocking and update() part and later remove table part done asynchronously?
I will also put more comment on the patch based on latest understanding.
Hello Ferruh,
Quoted 7 lines
So, by design, driver will keep the old table when it is resized.
- Can this have a performance impact, like when rules updated/removed/inserted driver will need to look more tables?
- Or can this cause additional capacity complexity, like total number of rules will be sum of rules in all tables, but new rules only can be added to latest table, so number of rules can be more than size of latest table.
Quoted 8 lines
- Or user can add more flows after
resize()and this may not leave enough room to update old rules to new table, what is expected behavior for this case?
- Or if user did not updated rules at all afterresize(), after each rule deletion driver won't need to check if old table emptied and needs to be freed?
- Or can user callresize()API multiple times, causing driver to maintain multiple tables? How much memory overhead this may bring?
After "resize, update, complete" sequence table performance must be
the same as before resize.
If application skiped updates or resize completion, performance is undefined. Driver must verify that total flows number does not exceed capacity set in table resize.
Quoted 3 lines
'
rte_flow_async_update_resized()' API is called per flow, won't this force application to trace which flows are created in new table and which are in old table, so pushing additional work to application.
Application must trace what flows require update after table resize.
As the general rule, all flows that were created before table resize call has returned must be updated:
"old" flows |<-----------------resize------------>| "new" flows
update keep
unknown flow location: update
----------------------------TIME-------------------------------------->
In MLX5 PMD, if update was called with a "new" flow, the call returns will success, without changing the flow.
Quoted 4 lines
Or what will happen if
update()fails in the middle of update, should user retry, should PMD restore back the moved rules?
If flow update call failed, it treated as failure during flow create, update or destroy.
Quoted 8 lines
I understood the logic behind the dividing responsibility to multiple APIs, and it makes sense, but it brings above complexities, and more work to application.
Can it be possible to have monolithic API but onlyresize()part of it is blocking andupdate()part and later remove table part done asynchronously?
Table resize and single flow update operations consume approximately the same time duration. An update of a table with 1_000_000 flows will consume driver for too much time. During that time application will not be able to create, destroy or update existing "old" flows. Such operation must be coordinated with application.
A driver could provide a batch flows update, but I don’t see how it helps. It's ether update one or update all and the latter does not scale.
Quoted 4 lines
I will also put more comment on the patch based on latest understanding.
Quoted 18 lines · Gregory
Hello Ferruh,
Quoted 7 lines
So, by design, driver will keep the old table when it is resized.
- Can this have a performance impact, like when rules updated/removed/inserted driver will need to look more tables?
- Or can this cause additional capacity complexity, like total number of rules will be sum of rules in all tables, but new rules only can be added to latest table, so number of rules can be more than size of latest table.Quoted 8 lines
- Or user can add more flows after
resize()and this may not leave enough room to update old rules to new table, what is expected behavior for this case?
- Or if user did not updated rules at all afterresize(), after each rule deletion driver won't need to check if old table emptied and needs to be freed?
- Or can user callresize()API multiple times, causing driver to maintain multiple tables? How much memory overhead this may bring?
Quoted 5 lines
After "resize, update, complete" sequence table performance must be the same as before resize.
If application skiped updates or resize completion, performance is undefined.
According below update, it is expected some time will pass until user updates flows, during this time there may be some performance impact, does it make sense to mention from it in API documentation?
Quoted 3 lines
Driver must verify that total flows number does not exceed capacity set in table resize.
OK, this is more complexity to driver
Is multiple resize() call supported?
In the worst case, think about a case, for each rule application first increase the size by one and adds that rule. Is this supported and should there be a limit how many resize() can be done?
Quoted 8 lines
Quoted 3 lines
'
rte_flow_async_update_resized()' API is called per flow, won't this force application to trace which flows are created in new table and which are in old table, so pushing additional work to application.Application must trace what flows require update after table resize. As the general rule, all flows that were created before table resize call has returned must be updated:
Quoted 9 lines
"old" flows |<-----------------resize------------>| "new" flows update keep unknown flow location: update
----------------------------TIME-------------------------------------->
In MLX5 PMD, if update was called with a "new" flow, the call returns will success, without changing the flow.
At least this makes life easy for the application, can we document this behavior as API requirement?
But still in a case there is high amount of flow insertion and deletion happening in parallel, how application call the update(), it may still need to keep list of flows to update.
Quoted 17 lines
Quoted 4 lines
Or what will happen if
update()fails in the middle of update, should user retry, should PMD restore back the moved rules?If flow update call failed, it treated as failure during flow create, update or destroy.
Quoted 8 lines
I understood the logic behind the dividing responsibility to multiple APIs, and it makes sense, but it brings above complexities, and more work to application.
Can it be possible to have monolithic API but onlyresize()part of it is blocking andupdate()part and later remove table part done asynchronously?
Quoted 3 lines
Table resize and single flow update operations consume approximately the same time duration.
Ah, thanks. I was missing this bit of information.
Quoted 6 lines
An update of a table with 1_000_000 flows will consume driver for too much time.
During that time application will not be able to create, destroy or update existing "old" flows.
Such operation must be coordinated with application.
Got it. Briefly I was trying to highlight the complexities that multiple APIs bring, and responsibility pushed to the application, but above performance impact explains the design decision.
Eventually application needs to get this hit, how application expected to use these APIs?
First call resize(), after this point how application should handle updating flows?
Can something like async updating flow work? Like driver returns success but it sets a thread that in background moves flows in a loop, if it gets the lock and release it per flow, this lets other thread get the lock for other flow related operations?
Quoted 7 lines
A driver could provide a batch flows update, but I don’t see how it helps. It's ether update one or update all and the latter does not scale.
Quoted 4 lines
I will also put more comment on the patch based on latest understanding.
Hello Ferruh,
I work on the patch update with detailed user guide for the table resize API.
Regards,
Gregory
Quoted 121 lines
Quoted 16 lines
Quoted 7 lines
So, by design, driver will keep the old table when it is resized.
- Can this have a performance impact, like when rules updated/removed/inserted driver will need to look more tables?
- Or can this cause additional capacity complexity, like total number of rules will be sum of rules in all tables, but new rules only can be added to latest table, so number of rules can be more than size of latest table.Quoted 8 lines
- Or user can add more flows after
resize()and this may not leave enough room to update old rules to new table, what is expected behavior for this case?
- Or if user did not updated rules at all afterresize(), after each rule deletion driver won't need to check if old table emptied and needs to be freed?
- Or can user callresize()API multiple times, causing driver to maintain multiple tables? How much memory overhead this may bring?Quoted 5 lines
After "resize, update, complete" sequence table performance must be the same as before resize.
If application skiped updates or resize completion, performance is undefined.According below update, it is expected some time will pass until user updates flows, during this time there may be some performance impact, does it make sense to mention from it in API documentation?
Quoted 3 lines
Driver must verify that total flows number does not exceed capacity set in table resize.
OK, this is more complexity to driver
Is multiple
resize()call supported?In the worst case, think about a case, for each rule application first increase the size by one and adds that rule. Is this supported and should there be a limit how many
resize()can be done?Quoted 8 lines
Quoted 3 lines
'
rte_flow_async_update_resized()' API is called per flow, won't this force application to trace which flows are created in new table and which are in old table, so pushing additional work to application.Application must trace what flows require update after table resize. As the general rule, all flows that were created before table resize call has returned must be updated:
Quoted 9 lines
"old" flows |<-----------------resize------------>| "new" flows
update keep
unknown flow location: update----------------------------TIME-------------------------------------->
In MLX5 PMD, if update was called with a "new" flow, the call returns will success, without changing the flow.
At least this makes life easy for the application, can we document this behavior as API requirement?
But still in a case there is high amount of flow insertion and deletion happening in parallel, how application call the
update(), it may still need to keep list of flows to update.Quoted 17 lines
Quoted 4 lines
Or what will happen if
update()fails in the middle of update, should user retry, should PMD restore back the moved rules?If flow update call failed, it treated as failure during flow create, update or destroy.
Quoted 8 lines
I understood the logic behind the dividing responsibility to multiple APIs, and it makes sense, but it brings above complexities, and more work to application.
Can it be possible to have monolithic API but onlyresize()part of it is blocking andupdate()part and later remove table part done asynchronously?Quoted 3 lines
Table resize and single flow update operations consume approximately the same time duration.
Ah, thanks. I was missing this bit of information.
Quoted 6 lines
An update of a table with 1_000_000 flows will consume driver for too much time.
During that time application will not be able to create, destroy or update existing "old" flows.
Such operation must be coordinated with application.Got it. Briefly I was trying to highlight the complexities that multiple APIs bring, and responsibility pushed to the application, but above performance impact explains the design decision.
Eventually application needs to get this hit, how application expected to use these APIs?
First callresize(), after this point how application should handle updating flows?Can something like async updating flow work? Like driver returns success but it sets a thread that in background moves flows in a loop, if it gets the lock and release it per flow, this lets other thread get the lock for other flow related operations?
Quoted 7 lines
A driver could provide a batch flows update, but I don’t see how it helps. It's ether update one or update all and the latter does not scale.
Quoted 4 lines
I will also put more comment on the patch based on latest understanding.
Quoted 46 lines · Gregory Etelson
Template table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the
RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLEbit set.* Application resizes existing table with the
rte_flow_template_table_resize()function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handlers held by
application.* After
rte_flow_template_table_resize()returned, application must update all existing table flow rules by callingrte_flow_async_update_resized().
The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize.rte_flow_async_update_resized()moves internal flow references to the updated table resources.
The flow update must not interrupt hardware flow operations.* When all table flow were updated, application must call
rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize afterrte_flow_template_table_resize_complete()returned.
Quoted 8 lines
Signed-off-by Gregory Etelson <[email protected]>Acked-by Ori Kam <[email protected]>--- app/test-pmd/cmdline_flow.c | 86 +++++++++++++++++++-- app/test-pmd/config.c | 102 +++++++++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++
It helps to document added/updated command in the commit log, and in the documentation 'testpmd_funcs.rst'.
Including new attribute to create table etc...
Please check following commit as sample:
Commit 98ab16778daa ("app/testpmd: add random item support")
Quoted 9 lines
doc/guides/rel_notes/release_24_03.rst | 2 + lib/ethdev/ethdev_trace.h | 33 ++++++++ lib/ethdev/ethdev_trace_points.c | 9 +++ lib/ethdev/rte_flow.c | 69 +++++++++++++++++ lib/ethdev/rte_flow.h | 97 +++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 ++++ lib/ethdev/version.map | 3 + 10 files changed, 417 insertions(+), 5 deletions(-)
Just to double check if there will be driver implementation of the new APIs in this release?
<...>
lib/ethdev/rte_flow.h struct rte_flow_template_table_attr { · line 5840
Quoted 8 lines
lib/ethdev/rte_flow.h +7
-0+static __rte_always_inline bool +rte_flow_table_resizable (const struct rte_flow_template_table_attr *tbl_attr) +{ +return (tbl_attr->specialize & +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE ) !=0 ; +} +
Ahh, this is the 4th API added in this patch, missed before.
Why it is exposed to the application?
What is the expected usage for the function, it doesn't get 'port_id' as parameter and directly works on the table_attribute, feels like API should be for drivers?
Why it is inlined?
<...>
Quoted 17 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Change template table flow rules capacity.
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param table
+ * Template table to modify.
+ * @paramnb_rules
+ * New flow rules capacity.
+ * @param error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return
Quoted 5 lines
+ * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *table* cannot be resized or invalid *nb_rules*
What is invalid 'nb_rules', does it make sense to document it in above @param for it. Like if 0 valid, or is there a max, or is it allowed to shrink the size of table?
Quoted 30 lines
+ */
lib/ethdev/rte_flow.h +29
-0+__rte_experimental +int +rte_flow_template_table_resize (uint16_t port_id, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Following table resize, update flow resources in port. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue for async operation. +* @param attr +* Async operation attributes. +* @param rule +* Flow rule to update. +* @param user_data +* The user data that will be returned on async completion event. +* @param error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid.
lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6827
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* - (-ENOTSUP) if underlying device does not support this functionality. +* - (-EINVAL) if *rule* cannot be updated. +*/ +__rte_experimental +int +rte_flow_async_update_resized (uint16_t port_id,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +
Should API have 'table' or 'template' in name, if it is out of this context, it is not intuitive that update_resized refers to template table resize. It may be confused as if this is something related to the rule itself resize.
Quoted 16 lines
lib/ethdev/rte_flow.h +15
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Following table resize, notify port that all table flows were updated. +* +* @param port_id +* Port identifier of Ethernet device. +* @param table +* Template table that undergoing resize operation. +* @param error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return
lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6852
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* - (0) if success. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOTSUP) if underlying device does not support this functionality. +* - (-EINVAL) PMD cannot complete table resize. +*/ +__rte_experimental +int +rte_flow_template_table_resize_complete (uint16_t port_id, +struct rte_flow_template_table *table, +struct rte_flow_error *error);
Does it make sense to add a new error type to differentiate unrecoverable error (I don't know if there is any) and an error that is caused by not all rules updated?
<...>
Quoted 7 lines
/**
lib/ethdev/version.map +0
-0
lib/ethdev/version.map EXPERIMENTAL { · line 322
Quoted 7 lines
lib/ethdev/version.map +3
-0@@ -316,6 +316,9 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete;
New APIs should go below "# added in 24.03" comment
Hello Ferruh,
Quoted 55 lines
Quoted 46 lines
Template table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the
RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLEbit set.* Application resizes existing table with the
rte_flow_template_table_resize()function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handlers held by
application.* After
rte_flow_template_table_resize()returned, application must update all existing table flow rules by callingrte_flow_async_update_resized().
The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize.rte_flow_async_update_resized()moves internal flow references to the updated table resources.
The flow update must not interrupt hardware flow operations.* When all table flow were updated, application must call
rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize afterrte_flow_template_table_resize_complete()returned.Quoted 8 lines
Signed-off-by Gregory Etelson <[email protected]>Acked-by Ori Kam <[email protected]>--- app/test-pmd/cmdline_flow.c | 86 +++++++++++++++++++-- app/test-pmd/config.c | 102 +++++++++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++
Quoted 7 lines
It helps to document added/updated command in the commit log, and in the documentation '
testpmd_funcs.rst'.
Including new attribute to create table etc...Please check following commit as sample:
Commit98ab16778daa("app/testpmd: add random item support")
I'll post v2 with an update.
Quoted 11 lines
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst | 2 + lib/ethdev/ethdev_trace.h | 33 ++++++++ lib/ethdev/ethdev_trace_points.c | 9 +++ lib/ethdev/rte_flow.c | 69 +++++++++++++++++ lib/ethdev/rte_flow.h | 97 +++++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 ++++ lib/ethdev/version.map | 3 + 10 files changed, 417 insertions(+), 5 deletions(-)
Quoted 3 lines
Just to double check if there will be driver implementation of the new APIs in this release?
I'll post driver patches after DPDK API approval.
Quoted 13 lines
<...>
lib/ethdev/rte_flow.h struct rte_flow_template_table_attr { · line 5840
Quoted 8 lines
lib/ethdev/rte_flow.h +7
-0+static __rte_always_inline bool +rte_flow_table_resizable (const struct rte_flow_template_table_attr *tbl_attr) +{ +return (tbl_attr->specialize & +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE ) !=0 ; +} +Ahh, this is the 4th API added in this patch, missed before.
Quoted 1 line
Why it is exposed to the application?
That API is for application and a driver.
Quoted 2 lines
What is the expected usage for the function, it doesn't get '
port_id' as parameter and directly works on thetable_attribute, feels like API
There is no usage for port_id in that query.
Quoted 2 lines
should be for drivers?
Why it is inlined?
I prefer inline functions to macros.
Quoted 26 lines
<...>
Quoted 17 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Change template table flow rules capacity.
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param table
+ * Template table to modify.
+ * @paramnb_rules
+ * New flow rules capacity.
+ * @param error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @returnQuoted 5 lines
+ * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *table* cannot be resized or invalid *nb_rules*
Quoted 3 lines
What is invalid '
nb_rules', does it make sense to document it in above @param for it. Like if 0 valid, or is there a max, or is it allowed to shrink the size of table?
I'll post v2 with an update.
Quoted 39 lines
Quoted 39 lines
+ */
lib/ethdev/rte_flow.h +36
-0+__rte_experimental +int +rte_flow_template_table_resize (uint16_t port_id, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Following table resize, update flow resources in port. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue for async operation. +* @param attr +* Async operation attributes. +* @param rule +* Flow rule to update. +* @param user_data +* The user data that will be returned on async completion event. +* @param error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOTSUP) if underlying device does not support this functionality. +* - (-EINVAL) if *rule* cannot be updated. +*/ +__rte_experimental +int +rte_flow_async_update_resized(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr,
Quoted 8 lines
lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6827
Quoted 3 lines
lib/ethdev/rte_flow.h +3
-0+ struct rte_flow *rule, void *user_data, + struct rte_flow_error *error); +Should API have 'table' or 'template' in name, if it is out of this context, it is not intuitive that
update_resizedrefers to template table resize. It may be confused as if this is something related to the rule itself resize.
That function call should have been called rte_flow_async_update_flow_after_table_resize The current version was selected after a long debate. Please suggest an alternative.
Quoted 24 lines
Quoted 24 lines
lib/ethdev/rte_flow.h +22
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Following table resize, notify port that all table flows were updated. +* +* @param port_id +* Port identifier of Ethernet device. +* @param table +* Template table that undergoing resize operation. +* @param error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOTSUP) if underlying device does not support this functionality. +* - (-EINVAL) PMD cannot complete table resize. +*/ +__rte_experimental +int
Quoted 8 lines
lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6852
Quoted 4 lines
lib/ethdev/rte_flow.h +3
-0+rte_flow_template_table_resize_complete(uint16_t port_id, + struct rte_flow_template_table *table, + struct rte_flow_error *error);Does it make sense to add a new error type to differentiate unrecoverable error (I don't know if there is any) and an error that is caused by not all rules updated?
That API should not return unrecoverable error.
When it called, all hardware related updates already completed. No new resources required.
Quoted 4 lines
<...>
Quoted 1 line
Quoted 16 lines
lib/ethdev/version.map EXPERIMENTAL { · line 322
Quoted 13 lines
/**
lib/ethdev/version.map +3
-0@@ -316,6 +316,9 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete;New APIs should go below "# added in 24.03" comment
I'll post an update in v2.
PATCH v2 1/1 ethdev: add template table resize API
In reply to Gregory EtelsonTemplate table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.
Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.
The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE bit set.
* Application resizes existing table with the rte_flow_template_table_resize() function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handlers held by
application.
* After rte_flow_template_table_resize() returned, application must update all existing table flow rules by calling rte_flow_async_update_resized().
The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize. rte_flow_async_update_resized() moves internal flow references to the updated table resources.
The flow update must not interrupt hardware flow operations.
* When all table flow were updated, application must call rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize after rte_flow_template_table_resize_complete() returned.
Testpmd commands:
* Create resizable template table
flow template_table <port-id> create table_id <tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number <initial table capacity> \
pattern_template <pt1> [ pattern_template <pt2> [ ... ]] \
actions_template <at1> [ actions_template <at2> [ ... ]]
* Resize table:
flow template_table <tbl-id> resize table_resize_id <tbl-id> \
table_resize_rules_num <new table capacity>
* Queue a flow update:
flow queue <port-id> update_resized <tbl-id> rule <flow-id>
* Complete table resize:
flow template_table <port-id> resize_complete table <tbl-id>
---
v2: Update the patch comment.
Add table resize commands to testpmd user guide.
--- app/test-pmd/cmdline_flow.c | 86 ++++++++++++++- app/test-pmd/config.c | 102 ++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++ doc/guides/rel_notes/release_24_03.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++- lib/ethdev/ethdev_trace.h | 33 ++++++ lib/ethdev/ethdev_trace_points.c | 9 ++ lib/ethdev/rte_flow.c | 69 ++++++++++++ lib/ethdev/rte_flow.h | 114 ++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 +++ lib/ethdev/version.map | 5 + 11 files changed, 450 insertions(+), 6 deletions(-)
app/test-pmd/cmdline_flow.c +81 -5
@@ -134,6 +134,7 @@ enum index {/* Queue arguments. */ QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED , QUEUE_INDIRECT_ACTION,
@@ -191,8 +192,12 @@ enum index {/* Table arguments. */ TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,TABLE_CREATE_ID ,TABLE_DESTROY_ID , +TABLE_RESIZE_ID , +TABLE_RESIZE_RULES_NUMBER ,TABLE_INSERTION_TYPE ,TABLE_INSERTION_TYPE_NAME , TABLE_HASH_FUNC,
@@ -204,6 +209,7 @@ enum index {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1323,6 +1329,8 @@ static const enum index next_group_attr[] = {static const enum index next_table_subcmd[] = {TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,ZERO , };
@@ -1337,6 +1345,7 @@ static const enum index next_table_attr[] = {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1353,6 +1362,7 @@ static const enum index next_table_destroy_attr[] = {static const enum index next_queue_subcmd[] = {QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED ,QUEUE_INDIRECT_ACTION ,
@@ -3344,6 +3354,19 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_table_destroy, }, + [TABLE_RESIZE] = { + .name = "resize", + .help = "resize template table", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)), + .call = parse_table + }, + [TABLE_RESIZE_COMPLETE] = { + .name = "resize_complete", + .help = "complete table resize", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + },/* Table arguments. */ [TABLE_CREATE_ID] = { .name = "table_id",
@@ -3354,13 +3377,29 @@ static const struct token token_list[] = { }, [TABLE_DESTROY_ID] = { .name = "table", - .help = "specify table id to destroy", + .help = "table id", .next =NEXT (next_table_destroy_attr, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_RESIZE_ID] = { + .name = "table_resize_id", + .help = "table resize id", + .next =NEXT (NEXT_ENTRY (TABLE_RESIZE_RULES_NUMBER ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + .call = parse_table + }, + [TABLE_RESIZE_RULES_NUMBER] = { + .name = "table_resize_rules_num", + .help = "table resize rules number", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + .call = parse_table + }, [TABLE_INSERTION_TYPE] = { .name = "insertion_type", .help = "specify insertion type",
@@ -3433,6 +3472,12 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_RESIZABLE] = { + .name = "resizable", + .help = "set resizable attribute", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table",
@@ -3525,6 +3570,14 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_FLOW_UPDATE_RESIZED] = { + .name = "update_resized", + .help = "update a flow after table resize", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, [QUEUE_UPDATE] = { .name = "update", .help = "update a flow rule",
@@ -10334,6 +10387,7 @@ parse_table(struct context *ctx, const struct token *token, }switch (ctx->curr) {case TABLE_CREATE : +case TABLE_RESIZE : out->command = ctx->curr; ctx->objdata =0 ; ctx->object = out;
@@ -10378,18 +10432,25 @@ parse_table(struct context *ctx, const struct token *token,case TABLE_TRANSFER_WIRE_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ;return len;case TABLE_TRANSFER_VPORT_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; +return len; +case TABLE_RESIZABLE : + out->args.table.attr.specialize |= +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE ;return len;case TABLE_RULES_NUMBER : ctx->objdata =0 ; ctx->object = out; ctx->objmask =NULL ;return len; +case TABLE_RESIZE_ID : +case TABLE_RESIZE_RULES_NUMBER : +return len;default :return -1 ; }
@@ -10411,7 +10472,8 @@ parse_table_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==TABLE ) { -if (ctx->curr !=TABLE_DESTROY ) +if (ctx->curr !=TABLE_DESTROY && + ctx->curr !=TABLE_RESIZE_COMPLETE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -10513,7 +10575,8 @@ parse_qo_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==QUEUE ) { -if (ctx->curr !=QUEUE_DESTROY ) +if (ctx->curr !=QUEUE_DESTROY && + ctx->curr !=QUEUE_FLOW_UPDATE_RESIZED )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -12569,10 +12632,18 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case TABLE_RESIZE_COMPLETE : +port_flow_template_table_resize_complete + (in->port, in->args.table_destroy.table_id[0 ]); +break ;case GROUP_SET_MISS_ACTIONS :port_queue_group_set_miss_actions (in->port, &in->args.vc.attr, in->args.vc.actions);break ; +case TABLE_RESIZE : +port_flow_template_table_resize (in->port, in->args.table.id, + in->args.table.attr.nb_flows); +break ;case QUEUE_CREATE : port_queue_flow_create(in->port, in->queue, in->postpone, in->args.vc.table_id, in->args.vc.rule_id,
@@ -12584,6 +12655,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case QUEUE_FLOW_UPDATE_RESIZED : +port_queue_flow_update_resized (in->port, in->queue, + in->postpone, + in->args.destroy.rule[0 ]); +break ;case QUEUE_UPDATE : port_queue_flow_update(in->port, in->queue, in->postpone, in->args.vc.rule_id, in->args.vc.act_templ_id,
app/test-pmd/config.c +102 -0
126 lines not on this page · raw message
app/test-pmd/testpmd.h +6 -0
@@ -110,6 +110,7 @@ enum {enum {QUEUE_JOB_TYPE_FLOW_CREATE ,QUEUE_JOB_TYPE_FLOW_DESTROY , +QUEUE_JOB_TYPE_FLOW_TRANSFER ,QUEUE_JOB_TYPE_FLOW_UPDATE ,QUEUE_JOB_TYPE_ACTION_CREATE ,QUEUE_JOB_TYPE_ACTION_DESTROY ,
@@ -981,7 +982,12 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates);int port_flow_template_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_update_resized (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t flow_id);int port_flow_template_table_flush (portid_t port_id); +int port_flow_template_table_resize_complete (portid_t port_id,uint32_t table_id); +int port_flow_template_table_resize (portid_t port_id, +uint32_t table_id,uint32_t flows_num);int port_queue_group_set_miss_actions (portid_t port_id,const struct rte_flow_attr *attr,const struct rte_flow_action *actions); int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -55,6 +55,8 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support for template API table resize.** + Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +14 -1
@@ -2984,12 +2984,21 @@ following sections. - Create a table:: flow table {port_id} create - [table_id {id}] + [table_id {id}] [resizable] [group {group_id}] [priority {level}] [ingress] [egress] [transfer] rules_number {number} pattern_template {pattern_template_id} actions_template {actions_template_id} +- Resize a table:: + + flow template_table {port_id} resize + table_resize_id {id} table_resize_rules_num {number} + +- Complete table resize:: + + flow template_table {port_id} resize_complete table {table_id} + - Destroy a table:: flow table {port_id} destroy table {id} [...]
@@ -3010,6 +3019,10 @@ following sections. pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end +- Enqueue flow update following table resize:: + + flow queue {port_id} update_resized {table_id} rule {rule_id} + - Enqueue destruction of specific flow rules:: flow queue {port_id} destroy {queue_id}
lib/ethdev/ethdev_trace.h +33 -0
@@ -2572,6 +2572,39 @@ RTE_TRACE_POINT_FP(rte_trace_point_emit_ptr (user_data);rte_trace_point_emit_int (ret); ) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_template_table_resize, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_u32 (nb_rules); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_async_update_resized, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_u32 (queue); +rte_trace_point_emit_ptr (attr); +rte_trace_point_emit_ptr (rule); +rte_trace_point_emit_ptr (user_data); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_table_resize_complete, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_int (ret); +) #ifdef __cplusplus }#endif
lib/ethdev/ethdev_trace_points.c +9 -0
@@ -774,3 +774,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_destroy,RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_action_list_handle_query_update, lib.ethdev.flow.async_action_list_handle_query_update) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_template_table_resize, + lib.ethdev.flow.template_table_resize) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_update_resized, + lib.ethdev.flow.async_update_resized) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_table_resize_complete, + lib.ethdev.flow.table_resize_complete)
lib/ethdev/rte_flow.c +69 -0
72 lines not on this page · raw message
lib/ethdev/rte_flow.h +114 -0
132 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +15 -0
@@ -370,6 +370,21 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_template_table *table, const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** @see rte_flow_template_table_resize() */ +int (*flow_template_table_resize)(struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** @see rte_flow_async_update_resized() */ +int (*flow_update_resized)(struct rte_eth_dev *dev,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +/** @see rte_flow_template_table_resize_complete() */ +int (*flow_template_table_resize_complete) + (struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +struct rte_flow_error *error); };/**
lib/ethdev/version.map +5 -0
@@ -316,6 +316,11 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + + # added in 24.03 + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete; }; INTERNAL {
Signature · 1 line
2.39.2
31/01/2024 10:59, Gregory Etelson:
lib/ethdev/rte_flow.h struct rte_flow_template_table; · line 5752
Quoted 7 lines
lib/ethdev/rte_flow.h +4
-0#define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG RTE_BIT32(1) +/** +* Specialize table for resize. +*/ +#define RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE RTE_BIT32(2)
I'm not sure about the repeating "TABLE" at the end of this flag name.
[...]
Quoted 5 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Query if a table can be resized
s/if/whether/
A dot is missing.
Quoted 5 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @paramtbl_attr
+ * Template table
Every lines should end with a dot in Doxygen for consistency.
Quoted 5 lines
+ *
+ * @return
+ * True if the table can be resized.
+ */
+static__rte_always_inlinebool
Why is it inline?
In general we avoid inline except for few performance sensitive ones.
Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+rte_flow_table_resizable(__rte_unused uint16_t port_id, + const struct rte_flow_template_table_attr *tbl_attr) +{ +return (tbl_attr->specialize & +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE ) !=0 ; +}
[...]
lib/ethdev/rte_flow.h
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+# added in 24.03 + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete;
I like the idea of these 3 new functions.
The scenario should be described in doc/guides/prog_guide/rte_flow.rst
Hello Thomas,
Quoted 45 lines
lib/ethdev/rte_flow.h struct rte_flow_template_table; · line 5752
Quoted 7 lines
lib/ethdev/rte_flow.h +4
-0#define RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG RTE_BIT32(1) +/** +* Specialize table for resize. +*/ +#define RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE RTE_BIT32(2)I'm not sure about the repeating "TABLE" at the end of this flag name.
[...]
Quoted 5 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Query if a table can be resizeds/if/whether/
A dot is missing.Quoted 5 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @paramtbl_attr
+ * Template tableEvery lines should end with a dot in Doxygen for consistency.
Quoted 5 lines
+ *
+ * @return
+ * True if the table can be resized.
+ */
+static__rte_always_inlineboolWhy is it inline?
In general we avoid inline except for few performance sensitive ones.Quoted 6 lines
lib/ethdev/rte_flow.h +6
-0+rte_flow_table_resizable(__rte_unused uint16_t port_id, + const struct rte_flow_template_table_attr *tbl_attr) +{ +return (tbl_attr->specialize & +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE ) !=0 ; +}[...]
Quoted 10 lines
lib/ethdev/rte_flow.h
Quoted 4 lines
lib/ethdev/rte_flow.h +4
-0+# added in 24.03 + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete;I like the idea of these 3 new functions.
The scenario should be described indoc/guides/prog_guide/rte_flow.rst
I'll post an update.
PATCH v3 1/1 ethdev: add template table resize API
In reply to Gregory EtelsonTemplate table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.
Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.
The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE bit set.
* Application resizes existing table with the rte_flow_template_table_resize() function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handlers held by
application.
* After rte_flow_template_table_resize() returned, application must update all existing table flow rules by calling rte_flow_async_update_resized().
The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize. rte_flow_async_update_resized() moves internal flow references to the updated table resources.
The flow update must not interrupt hardware flow operations.
* When all table flow were updated, application must call rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize after rte_flow_template_table_resize_complete() returned.
Testpmd commands:
* Create resizable template table
flow template_table <port-id> create table_id <tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number <initial table capacity> \
pattern_template <pt1> [ pattern_template <pt2> [ ... ]] \
actions_template <at1> [ actions_template <at2> [ ... ]]
* Resize table:
flow template_table <tbl-id> resize table_resize_id <tbl-id> \
table_resize_rules_num <new table capacity>
* Queue a flow update:
flow queue <port-id> update_resized <tbl-id> rule <flow-id>
* Complete table resize:
flow template_table <port-id> resize_complete table <tbl-id>
---
v2: Update the patch comment.
Add table resize commands to testpmd user guide.
v3: Rename RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE macro.
--- app/test-pmd/cmdline_flow.c | 86 ++++++++++++++- app/test-pmd/config.c | 102 ++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++ doc/guides/rel_notes/release_24_03.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++- lib/ethdev/ethdev_trace.h | 33 ++++++ lib/ethdev/ethdev_trace_points.c | 9 ++ lib/ethdev/rte_flow.c | 69 ++++++++++++ lib/ethdev/rte_flow.h | 114 ++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 +++ lib/ethdev/version.map | 5 + 11 files changed, 450 insertions(+), 6 deletions(-)
app/test-pmd/cmdline_flow.c +81 -5
@@ -134,6 +134,7 @@ enum index {/* Queue arguments. */ QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED , QUEUE_INDIRECT_ACTION,
@@ -191,8 +192,12 @@ enum index {/* Table arguments. */ TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,TABLE_CREATE_ID ,TABLE_DESTROY_ID , +TABLE_RESIZE_ID , +TABLE_RESIZE_RULES_NUMBER ,TABLE_INSERTION_TYPE ,TABLE_INSERTION_TYPE_NAME , TABLE_HASH_FUNC,
@@ -204,6 +209,7 @@ enum index {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1323,6 +1329,8 @@ static const enum index next_group_attr[] = {static const enum index next_table_subcmd[] = {TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,ZERO , };
@@ -1337,6 +1345,7 @@ static const enum index next_table_attr[] = {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1353,6 +1362,7 @@ static const enum index next_table_destroy_attr[] = {static const enum index next_queue_subcmd[] = {QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED ,QUEUE_INDIRECT_ACTION ,
@@ -3344,6 +3354,19 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_table_destroy, }, + [TABLE_RESIZE] = { + .name = "resize", + .help = "resize template table", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)), + .call = parse_table + }, + [TABLE_RESIZE_COMPLETE] = { + .name = "resize_complete", + .help = "complete table resize", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + },/* Table arguments. */ [TABLE_CREATE_ID] = { .name = "table_id",
@@ -3354,13 +3377,29 @@ static const struct token token_list[] = { }, [TABLE_DESTROY_ID] = { .name = "table", - .help = "specify table id to destroy", + .help = "table id", .next =NEXT (next_table_destroy_attr, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_RESIZE_ID] = { + .name = "table_resize_id", + .help = "table resize id", + .next =NEXT (NEXT_ENTRY (TABLE_RESIZE_RULES_NUMBER ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + .call = parse_table + }, + [TABLE_RESIZE_RULES_NUMBER] = { + .name = "table_resize_rules_num", + .help = "table resize rules number", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + .call = parse_table + }, [TABLE_INSERTION_TYPE] = { .name = "insertion_type", .help = "specify insertion type",
@@ -3433,6 +3472,12 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_RESIZABLE] = { + .name = "resizable", + .help = "set resizable attribute", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table",
@@ -3525,6 +3570,14 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_FLOW_UPDATE_RESIZED] = { + .name = "update_resized", + .help = "update a flow after table resize", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, [QUEUE_UPDATE] = { .name = "update", .help = "update a flow rule",
@@ -10334,6 +10387,7 @@ parse_table(struct context *ctx, const struct token *token, }switch (ctx->curr) {case TABLE_CREATE : +case TABLE_RESIZE : out->command = ctx->curr; ctx->objdata =0 ; ctx->object = out;
@@ -10378,18 +10432,25 @@ parse_table(struct context *ctx, const struct token *token,case TABLE_TRANSFER_WIRE_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ;return len;case TABLE_TRANSFER_VPORT_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; +return len; +case TABLE_RESIZABLE : + out->args.table.attr.specialize |= +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE ;return len;case TABLE_RULES_NUMBER : ctx->objdata =0 ; ctx->object = out; ctx->objmask =NULL ;return len; +case TABLE_RESIZE_ID : +case TABLE_RESIZE_RULES_NUMBER : +return len;default :return -1 ; }
@@ -10411,7 +10472,8 @@ parse_table_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==TABLE ) { -if (ctx->curr !=TABLE_DESTROY ) +if (ctx->curr !=TABLE_DESTROY && + ctx->curr !=TABLE_RESIZE_COMPLETE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -10513,7 +10575,8 @@ parse_qo_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==QUEUE ) { -if (ctx->curr !=QUEUE_DESTROY ) +if (ctx->curr !=QUEUE_DESTROY && + ctx->curr !=QUEUE_FLOW_UPDATE_RESIZED )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -12569,10 +12632,18 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case TABLE_RESIZE_COMPLETE : +port_flow_template_table_resize_complete + (in->port, in->args.table_destroy.table_id[0 ]); +break ;case GROUP_SET_MISS_ACTIONS :port_queue_group_set_miss_actions (in->port, &in->args.vc.attr, in->args.vc.actions);break ; +case TABLE_RESIZE : +port_flow_template_table_resize (in->port, in->args.table.id, + in->args.table.attr.nb_flows); +break ;case QUEUE_CREATE : port_queue_flow_create(in->port, in->queue, in->postpone, in->args.vc.table_id, in->args.vc.rule_id,
@@ -12584,6 +12655,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case QUEUE_FLOW_UPDATE_RESIZED : +port_queue_flow_update_resized (in->port, in->queue, + in->postpone, + in->args.destroy.rule[0 ]); +break ;case QUEUE_UPDATE : port_queue_flow_update(in->port, in->queue, in->postpone, in->args.vc.rule_id, in->args.vc.act_templ_id,
app/test-pmd/config.c +102 -0
126 lines not on this page · raw message
app/test-pmd/testpmd.h +6 -0
@@ -110,6 +110,7 @@ enum {enum {QUEUE_JOB_TYPE_FLOW_CREATE ,QUEUE_JOB_TYPE_FLOW_DESTROY , +QUEUE_JOB_TYPE_FLOW_TRANSFER ,QUEUE_JOB_TYPE_FLOW_UPDATE ,QUEUE_JOB_TYPE_ACTION_CREATE ,QUEUE_JOB_TYPE_ACTION_DESTROY ,
@@ -981,7 +982,12 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates);int port_flow_template_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_update_resized (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t flow_id);int port_flow_template_table_flush (portid_t port_id); +int port_flow_template_table_resize_complete (portid_t port_id,uint32_t table_id); +int port_flow_template_table_resize (portid_t port_id, +uint32_t table_id,uint32_t flows_num);int port_queue_group_set_miss_actions (portid_t port_id,const struct rte_flow_attr *attr,const struct rte_flow_action *actions); int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -55,6 +55,8 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support for template API table resize.** + Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +14 -1
@@ -2984,12 +2984,21 @@ following sections. - Create a table:: flow table {port_id} create - [table_id {id}] + [table_id {id}] [resizable] [group {group_id}] [priority {level}] [ingress] [egress] [transfer] rules_number {number} pattern_template {pattern_template_id} actions_template {actions_template_id} +- Resize a table:: + + flow template_table {port_id} resize + table_resize_id {id} table_resize_rules_num {number} + +- Complete table resize:: + + flow template_table {port_id} resize_complete table {table_id} + - Destroy a table:: flow table {port_id} destroy table {id} [...]
@@ -3010,6 +3019,10 @@ following sections. pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end +- Enqueue flow update following table resize:: + + flow queue {port_id} update_resized {table_id} rule {rule_id} + - Enqueue destruction of specific flow rules:: flow queue {port_id} destroy {queue_id}
lib/ethdev/ethdev_trace.h +33 -0
@@ -2572,6 +2572,39 @@ RTE_TRACE_POINT_FP(rte_trace_point_emit_ptr (user_data);rte_trace_point_emit_int (ret); ) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_template_table_resize, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_u32 (nb_rules); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_async_update_resized, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_u32 (queue); +rte_trace_point_emit_ptr (attr); +rte_trace_point_emit_ptr (rule); +rte_trace_point_emit_ptr (user_data); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_table_resize_complete, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_int (ret); +) #ifdef __cplusplus }#endif
lib/ethdev/ethdev_trace_points.c +9 -0
@@ -774,3 +774,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_destroy,RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_action_list_handle_query_update, lib.ethdev.flow.async_action_list_handle_query_update) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_template_table_resize, + lib.ethdev.flow.template_table_resize) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_update_resized, + lib.ethdev.flow.async_update_resized) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_table_resize_complete, + lib.ethdev.flow.table_resize_complete)
lib/ethdev/rte_flow.c +69 -0
72 lines not on this page · raw message
lib/ethdev/rte_flow.h +114 -0
132 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +15 -0
@@ -370,6 +370,21 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_template_table *table, const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** @see rte_flow_template_table_resize() */ +int (*flow_template_table_resize)(struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** @see rte_flow_async_update_resized() */ +int (*flow_update_resized)(struct rte_eth_dev *dev,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +/** @see rte_flow_template_table_resize_complete() */ +int (*flow_template_table_resize_complete) + (struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +struct rte_flow_error *error); };/**
lib/ethdev/version.map +5 -0
@@ -316,6 +316,11 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + + # added in 24.03 + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete; }; INTERNAL {
Signature · 1 line
2.39.2
PATCH v4 1/1 ethdev: add template table resize API
In reply to Gregory EtelsonTemplate table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.
Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.
The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE bit set.
* Application resizes existing table with the rte_flow_template_table_resize() function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handlers held by
application.
* After rte_flow_template_table_resize() returned, application must update all existing table flow rules by calling rte_flow_async_update_resized().
The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize. rte_flow_async_update_resized() moves internal flow references to the updated table resources.
The flow update must not interrupt hardware flow operations.
* When all table flow were updated, application must call rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize after rte_flow_template_table_resize_complete() returned.
Testpmd commands:
* Create resizable template table
flow template_table <port-id> create table_id <tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number <initial table capacity> \
pattern_template <pt1> [ pattern_template <pt2> [ ... ]] \
actions_template <at1> [ actions_template <at2> [ ... ]]
* Resize table:
flow template_table <tbl-id> resize table_resize_id <tbl-id> \
table_resize_rules_num <new table capacity>
* Queue a flow update:
flow queue <port-id> update_resized <tbl-id> rule <flow-id>
* Complete table resize:
flow template_table <port-id> resize_complete table <tbl-id>
---
v2: Update the patch comment.
Add table resize commands to testpmd user guide.
v3: Rename RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE macro.
v4: Remove inline.
Add use case to rte_flow.rst.
--- app/test-pmd/cmdline_flow.c | 86 ++++++++++++++- app/test-pmd/config.c | 102 ++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++ doc/guides/howto/rte_flow.rst | 111 ++++++++++++++++++++ doc/guides/rel_notes/release_24_03.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++- lib/ethdev/ethdev_trace.h | 33 ++++++ lib/ethdev/ethdev_trace_points.c | 9 ++ lib/ethdev/rte_flow.c | 77 ++++++++++++++ lib/ethdev/rte_flow.h | 111 ++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 +++ lib/ethdev/version.map | 6 ++ 12 files changed, 567 insertions(+), 6 deletions(-)
app/test-pmd/cmdline_flow.c +81 -5
@@ -134,6 +134,7 @@ enum index {/* Queue arguments. */ QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED , QUEUE_INDIRECT_ACTION,
@@ -191,8 +192,12 @@ enum index {/* Table arguments. */ TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,TABLE_CREATE_ID ,TABLE_DESTROY_ID , +TABLE_RESIZE_ID , +TABLE_RESIZE_RULES_NUMBER ,TABLE_INSERTION_TYPE ,TABLE_INSERTION_TYPE_NAME , TABLE_HASH_FUNC,
@@ -204,6 +209,7 @@ enum index {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1323,6 +1329,8 @@ static const enum index next_group_attr[] = {static const enum index next_table_subcmd[] = {TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,ZERO , };
@@ -1337,6 +1345,7 @@ static const enum index next_table_attr[] = {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1353,6 +1362,7 @@ static const enum index next_table_destroy_attr[] = {static const enum index next_queue_subcmd[] = {QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED ,QUEUE_INDIRECT_ACTION ,
@@ -3344,6 +3354,19 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_table_destroy, }, + [TABLE_RESIZE] = { + .name = "resize", + .help = "resize template table", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)), + .call = parse_table + }, + [TABLE_RESIZE_COMPLETE] = { + .name = "resize_complete", + .help = "complete table resize", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + },/* Table arguments. */ [TABLE_CREATE_ID] = { .name = "table_id",
@@ -3354,13 +3377,29 @@ static const struct token token_list[] = { }, [TABLE_DESTROY_ID] = { .name = "table", - .help = "specify table id to destroy", + .help = "table id", .next =NEXT (next_table_destroy_attr, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_RESIZE_ID] = { + .name = "table_resize_id", + .help = "table resize id", + .next =NEXT (NEXT_ENTRY (TABLE_RESIZE_RULES_NUMBER ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + .call = parse_table + }, + [TABLE_RESIZE_RULES_NUMBER] = { + .name = "table_resize_rules_num", + .help = "table resize rules number", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + .call = parse_table + }, [TABLE_INSERTION_TYPE] = { .name = "insertion_type", .help = "specify insertion type",
@@ -3433,6 +3472,12 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_RESIZABLE] = { + .name = "resizable", + .help = "set resizable attribute", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table",
@@ -3525,6 +3570,14 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_FLOW_UPDATE_RESIZED] = { + .name = "update_resized", + .help = "update a flow after table resize", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, [QUEUE_UPDATE] = { .name = "update", .help = "update a flow rule",
@@ -10334,6 +10387,7 @@ parse_table(struct context *ctx, const struct token *token, }switch (ctx->curr) {case TABLE_CREATE : +case TABLE_RESIZE : out->command = ctx->curr; ctx->objdata =0 ; ctx->object = out;
@@ -10378,18 +10432,25 @@ parse_table(struct context *ctx, const struct token *token,case TABLE_TRANSFER_WIRE_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ;return len;case TABLE_TRANSFER_VPORT_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; +return len; +case TABLE_RESIZABLE : + out->args.table.attr.specialize |= +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE ;return len;case TABLE_RULES_NUMBER : ctx->objdata =0 ; ctx->object = out; ctx->objmask =NULL ;return len; +case TABLE_RESIZE_ID : +case TABLE_RESIZE_RULES_NUMBER : +return len;default :return -1 ; }
@@ -10411,7 +10472,8 @@ parse_table_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==TABLE ) { -if (ctx->curr !=TABLE_DESTROY ) +if (ctx->curr !=TABLE_DESTROY && + ctx->curr !=TABLE_RESIZE_COMPLETE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -10513,7 +10575,8 @@ parse_qo_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==QUEUE ) { -if (ctx->curr !=QUEUE_DESTROY ) +if (ctx->curr !=QUEUE_DESTROY && + ctx->curr !=QUEUE_FLOW_UPDATE_RESIZED )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -12569,10 +12632,18 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case TABLE_RESIZE_COMPLETE : +port_flow_template_table_resize_complete + (in->port, in->args.table_destroy.table_id[0 ]); +break ;case GROUP_SET_MISS_ACTIONS :port_queue_group_set_miss_actions (in->port, &in->args.vc.attr, in->args.vc.actions);break ; +case TABLE_RESIZE : +port_flow_template_table_resize (in->port, in->args.table.id, + in->args.table.attr.nb_flows); +break ;case QUEUE_CREATE : port_queue_flow_create(in->port, in->queue, in->postpone, in->args.vc.table_id, in->args.vc.rule_id,
@@ -12584,6 +12655,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case QUEUE_FLOW_UPDATE_RESIZED : +port_queue_flow_update_resized (in->port, in->queue, + in->postpone, + in->args.destroy.rule[0 ]); +break ;case QUEUE_UPDATE : port_queue_flow_update(in->port, in->queue, in->postpone, in->args.vc.rule_id, in->args.vc.act_templ_id,
app/test-pmd/config.c +102 -0
126 lines not on this page · raw message
app/test-pmd/testpmd.h +6 -0
@@ -110,6 +110,7 @@ enum {enum {QUEUE_JOB_TYPE_FLOW_CREATE ,QUEUE_JOB_TYPE_FLOW_DESTROY , +QUEUE_JOB_TYPE_FLOW_TRANSFER ,QUEUE_JOB_TYPE_FLOW_UPDATE ,QUEUE_JOB_TYPE_ACTION_CREATE ,QUEUE_JOB_TYPE_ACTION_DESTROY ,
@@ -981,7 +982,12 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates);int port_flow_template_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_update_resized (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t flow_id);int port_flow_template_table_flush (portid_t port_id); +int port_flow_template_table_resize_complete (portid_t port_id,uint32_t table_id); +int port_flow_template_table_resize (portid_t port_id, +uint32_t table_id,uint32_t flows_num);int port_queue_group_set_miss_actions (portid_t port_id,const struct rte_flow_attr *attr,const struct rte_flow_action *actions); int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
doc/guides/howto/rte_flow.rst +111 -0
114 lines not on this page · raw message
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -55,6 +55,8 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support for template API table resize.** + Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +14 -1
@@ -2984,12 +2984,21 @@ following sections. - Create a table:: flow table {port_id} create - [table_id {id}] + [table_id {id}] [resizable] [group {group_id}] [priority {level}] [ingress] [egress] [transfer] rules_number {number} pattern_template {pattern_template_id} actions_template {actions_template_id} +- Resize a table:: + + flow template_table {port_id} resize + table_resize_id {id} table_resize_rules_num {number} + +- Complete table resize:: + + flow template_table {port_id} resize_complete table {table_id} + - Destroy a table:: flow table {port_id} destroy table {id} [...]
@@ -3010,6 +3019,10 @@ following sections. pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end +- Enqueue flow update following table resize:: + + flow queue {port_id} update_resized {table_id} rule {rule_id} + - Enqueue destruction of specific flow rules:: flow queue {port_id} destroy {queue_id}
lib/ethdev/ethdev_trace.h +33 -0
@@ -2572,6 +2572,39 @@ RTE_TRACE_POINT_FP(rte_trace_point_emit_ptr (user_data);rte_trace_point_emit_int (ret); ) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_template_table_resize, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_u32 (nb_rules); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_async_update_resized, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_u32 (queue); +rte_trace_point_emit_ptr (attr); +rte_trace_point_emit_ptr (rule); +rte_trace_point_emit_ptr (user_data); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_table_resize_complete, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_int (ret); +) #ifdef __cplusplus }#endif
lib/ethdev/ethdev_trace_points.c +9 -0
@@ -774,3 +774,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_destroy,RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_action_list_handle_query_update, lib.ethdev.flow.async_action_list_handle_query_update) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_template_table_resize, + lib.ethdev.flow.template_table_resize) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_update_resized, + lib.ethdev.flow.async_update_resized) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_table_resize_complete, + lib.ethdev.flow.table_resize_complete)
lib/ethdev/rte_flow.c +77 -0
80 lines not on this page · raw message
lib/ethdev/rte_flow.h +111 -0
129 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +15 -0
@@ -370,6 +370,21 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_template_table *table, const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** @see rte_flow_template_table_resize() */ +int (*flow_template_table_resize)(struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** @see rte_flow_async_update_resized() */ +int (*flow_update_resized)(struct rte_eth_dev *dev,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +/** @see rte_flow_template_table_resize_complete() */ +int (*flow_template_table_resize_complete) + (struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +struct rte_flow_error *error); };/**
lib/ethdev/version.map +6 -0
@@ -316,6 +316,12 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + + # added in 24.03 + rte_flow_table_resizable; + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete; }; INTERNAL {
Signature · 1 line
2.39.2
PATCH v5 1/1 ethdev: add template table resize API
In reply to Gregory EtelsonTemplate table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.
Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.
The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE bit set.
* Application resizes existing table with the rte_flow_template_table_resize() function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handlers held by
application.
* After rte_flow_template_table_resize() returned, application must update all existing table flow rules by calling rte_flow_async_update_resized().
The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize. rte_flow_async_update_resized() moves internal flow references to the updated table resources.
The flow update must not interrupt hardware flow operations.
* When all table flow were updated, application must call rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize after rte_flow_template_table_resize_complete() returned.
Testpmd commands:
* Create resizable template table
flow template_table <port-id> create table_id <tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number <initial table capacity> \
pattern_template <pt1> [ pattern_template <pt2> [ ... ]] \
actions_template <at1> [ actions_template <at2> [ ... ]]
* Resize table:
flow template_table <tbl-id> resize table_resize_id <tbl-id> \
table_resize_rules_num <new table capacity>
* Queue a flow update:
flow queue <port-id> update_resized <tbl-id> rule <flow-id>
* Complete table resize:
flow template_table <port-id> resize_complete table <tbl-id>
---
v2: Update the patch comment.
Add table resize commands to testpmd user guide.
v3: Rename RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE macro.
v4: Remove inline.
Add use case to rte_flow.rst.
v5: update API guide in the rte_flow.rst.
--- app/test-pmd/cmdline_flow.c | 86 ++++++++++++++- app/test-pmd/config.c | 102 +++++++++++++++++ app/test-pmd/testpmd.h | 6 + doc/guides/howto/rte_flow.rst | 116 ++++++++++++++++++++ doc/guides/rel_notes/release_24_03.rst | 2 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++- lib/ethdev/ethdev_trace.h | 33 ++++++ lib/ethdev/ethdev_trace_points.c | 9 ++ lib/ethdev/rte_flow.c | 77 +++++++++++++ lib/ethdev/rte_flow.h | 111 +++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 +++ lib/ethdev/version.map | 6 + 12 files changed, 572 insertions(+), 6 deletions(-)
app/test-pmd/cmdline_flow.c +81 -5
@@ -134,6 +134,7 @@ enum index {/* Queue arguments. */ QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED , QUEUE_INDIRECT_ACTION,
@@ -191,8 +192,12 @@ enum index {/* Table arguments. */ TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,TABLE_CREATE_ID ,TABLE_DESTROY_ID , +TABLE_RESIZE_ID , +TABLE_RESIZE_RULES_NUMBER ,TABLE_INSERTION_TYPE ,TABLE_INSERTION_TYPE_NAME , TABLE_HASH_FUNC,
@@ -204,6 +209,7 @@ enum index {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1323,6 +1329,8 @@ static const enum index next_group_attr[] = {static const enum index next_table_subcmd[] = {TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,ZERO , };
@@ -1337,6 +1345,7 @@ static const enum index next_table_attr[] = {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1353,6 +1362,7 @@ static const enum index next_table_destroy_attr[] = {static const enum index next_queue_subcmd[] = {QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED ,QUEUE_INDIRECT_ACTION ,
@@ -3344,6 +3354,19 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_table_destroy, }, + [TABLE_RESIZE] = { + .name = "resize", + .help = "resize template table", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)), + .call = parse_table + }, + [TABLE_RESIZE_COMPLETE] = { + .name = "resize_complete", + .help = "complete table resize", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + },/* Table arguments. */ [TABLE_CREATE_ID] = { .name = "table_id",
@@ -3354,13 +3377,29 @@ static const struct token token_list[] = { }, [TABLE_DESTROY_ID] = { .name = "table", - .help = "specify table id to destroy", + .help = "table id", .next =NEXT (next_table_destroy_attr, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_RESIZE_ID] = { + .name = "table_resize_id", + .help = "table resize id", + .next =NEXT (NEXT_ENTRY (TABLE_RESIZE_RULES_NUMBER ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + .call = parse_table + }, + [TABLE_RESIZE_RULES_NUMBER] = { + .name = "table_resize_rules_num", + .help = "table resize rules number", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + .call = parse_table + }, [TABLE_INSERTION_TYPE] = { .name = "insertion_type", .help = "specify insertion type",
@@ -3433,6 +3472,12 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_RESIZABLE] = { + .name = "resizable", + .help = "set resizable attribute", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table",
@@ -3525,6 +3570,14 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_FLOW_UPDATE_RESIZED] = { + .name = "update_resized", + .help = "update a flow after table resize", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, [QUEUE_UPDATE] = { .name = "update", .help = "update a flow rule",
@@ -10334,6 +10387,7 @@ parse_table(struct context *ctx, const struct token *token, }switch (ctx->curr) {case TABLE_CREATE : +case TABLE_RESIZE : out->command = ctx->curr; ctx->objdata =0 ; ctx->object = out;
@@ -10378,18 +10432,25 @@ parse_table(struct context *ctx, const struct token *token,case TABLE_TRANSFER_WIRE_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ;return len;case TABLE_TRANSFER_VPORT_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; +return len; +case TABLE_RESIZABLE : + out->args.table.attr.specialize |= +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE ;return len;case TABLE_RULES_NUMBER : ctx->objdata =0 ; ctx->object = out; ctx->objmask =NULL ;return len; +case TABLE_RESIZE_ID : +case TABLE_RESIZE_RULES_NUMBER : +return len;default :return -1 ; }
@@ -10411,7 +10472,8 @@ parse_table_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==TABLE ) { -if (ctx->curr !=TABLE_DESTROY ) +if (ctx->curr !=TABLE_DESTROY && + ctx->curr !=TABLE_RESIZE_COMPLETE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -10513,7 +10575,8 @@ parse_qo_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==QUEUE ) { -if (ctx->curr !=QUEUE_DESTROY ) +if (ctx->curr !=QUEUE_DESTROY && + ctx->curr !=QUEUE_FLOW_UPDATE_RESIZED )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -12569,10 +12632,18 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case TABLE_RESIZE_COMPLETE : +port_flow_template_table_resize_complete + (in->port, in->args.table_destroy.table_id[0 ]); +break ;case GROUP_SET_MISS_ACTIONS :port_queue_group_set_miss_actions (in->port, &in->args.vc.attr, in->args.vc.actions);break ; +case TABLE_RESIZE : +port_flow_template_table_resize (in->port, in->args.table.id, + in->args.table.attr.nb_flows); +break ;case QUEUE_CREATE : port_queue_flow_create(in->port, in->queue, in->postpone, in->args.vc.table_id, in->args.vc.rule_id,
@@ -12584,6 +12655,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case QUEUE_FLOW_UPDATE_RESIZED : +port_queue_flow_update_resized (in->port, in->queue, + in->postpone, + in->args.destroy.rule[0 ]); +break ;case QUEUE_UPDATE : port_queue_flow_update(in->port, in->queue, in->postpone, in->args.vc.rule_id, in->args.vc.act_templ_id,
app/test-pmd/config.c +102 -0
126 lines not on this page · raw message
app/test-pmd/testpmd.h +6 -0
@@ -110,6 +110,7 @@ enum {enum {QUEUE_JOB_TYPE_FLOW_CREATE ,QUEUE_JOB_TYPE_FLOW_DESTROY , +QUEUE_JOB_TYPE_FLOW_TRANSFER ,QUEUE_JOB_TYPE_FLOW_UPDATE ,QUEUE_JOB_TYPE_ACTION_CREATE ,QUEUE_JOB_TYPE_ACTION_DESTROY ,
@@ -981,7 +982,12 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates);int port_flow_template_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_update_resized (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t flow_id);int port_flow_template_table_flush (portid_t port_id); +int port_flow_template_table_resize_complete (portid_t port_id,uint32_t table_id); +int port_flow_template_table_resize (portid_t port_id, +uint32_t table_id,uint32_t flows_num);int port_queue_group_set_miss_actions (portid_t port_id,const struct rte_flow_attr *attr,const struct rte_flow_action *actions); int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
doc/guides/howto/rte_flow.rst +116 -0
119 lines not on this page · raw message
doc/guides/rel_notes/release_24_03.rst +2 -0
@@ -55,6 +55,8 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support for template API table resize.** + Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +14 -1
@@ -2984,12 +2984,21 @@ following sections. - Create a table:: flow table {port_id} create - [table_id {id}] + [table_id {id}] [resizable] [group {group_id}] [priority {level}] [ingress] [egress] [transfer] rules_number {number} pattern_template {pattern_template_id} actions_template {actions_template_id} +- Resize a table:: + + flow template_table {port_id} resize + table_resize_id {id} table_resize_rules_num {number} + +- Complete table resize:: + + flow template_table {port_id} resize_complete table {table_id} + - Destroy a table:: flow table {port_id} destroy table {id} [...]
@@ -3010,6 +3019,10 @@ following sections. pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end +- Enqueue flow update following table resize:: + + flow queue {port_id} update_resized {table_id} rule {rule_id} + - Enqueue destruction of specific flow rules:: flow queue {port_id} destroy {queue_id}
lib/ethdev/ethdev_trace.h +33 -0
@@ -2572,6 +2572,39 @@ RTE_TRACE_POINT_FP(rte_trace_point_emit_ptr (user_data);rte_trace_point_emit_int (ret); ) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_template_table_resize, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_u32 (nb_rules); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_async_update_resized, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_u32 (queue); +rte_trace_point_emit_ptr (attr); +rte_trace_point_emit_ptr (rule); +rte_trace_point_emit_ptr (user_data); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_table_resize_complete, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_int (ret); +) #ifdef __cplusplus }#endif
lib/ethdev/ethdev_trace_points.c +9 -0
@@ -774,3 +774,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_destroy,RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_action_list_handle_query_update, lib.ethdev.flow.async_action_list_handle_query_update) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_template_table_resize, + lib.ethdev.flow.template_table_resize) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_update_resized, + lib.ethdev.flow.async_update_resized) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_table_resize_complete, + lib.ethdev.flow.table_resize_complete)
lib/ethdev/rte_flow.c +77 -0
80 lines not on this page · raw message
lib/ethdev/rte_flow.h +111 -0
129 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +15 -0
@@ -370,6 +370,21 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_template_table *table, const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** @see rte_flow_template_table_resize() */ +int (*flow_template_table_resize)(struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** @see rte_flow_async_update_resized() */ +int (*flow_update_resized)(struct rte_eth_dev *dev,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +/** @see rte_flow_template_table_resize_complete() */ +int (*flow_template_table_resize_complete) + (struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +struct rte_flow_error *error); };/**
lib/ethdev/version.map +6 -0
@@ -316,6 +316,12 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + + # added in 24.03 + rte_flow_table_resizable; + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete; }; INTERNAL {
Signature · 1 line
2.39.2
11/02/2024 10:30, Gregory Etelson:
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 313
Quoted 9 lines
doc/guides/howto/rte_flow.rst +7
-0+Template API resizable table +---------------------------- + +Description +~~~~~~~~~~~ + +A guide to the resizable template table API.
This sentence is useless. Let's keep it as short as we can.
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 321
Quoted 8 lines
doc/guides/howto/rte_flow.rst +8
-0+ +The resizable template table API enables applications to dynamically adjust +capacity of template tables without disrupting the existing flows operation. +The resizable template table API allows applications to optimize the memory +usage and performance of template tables according to the traffic conditions +and requirements. + +A typical use case for the resizable template table API
You may add a colon at the end of this sentence. The below you may use "#" for automatic list numbering.
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 331
Quoted 10 lines
doc/guides/howto/rte_flow.rst +10
-0+ + 1. Create a resizable table with the initial capacity. + + 2. Change the table flows capacity. + + 3. Update flows that were created before the table update. + + 4. Complete the table resize procedure. + +When application begins to resize the table, it enters the resizable state.
I'm not sure to understand what means "enters the resizable state".
doc/guides/howto/rte_flow.rst
Quoted 2 lines
doc/guides/howto/rte_flow.rst +2
-0+When application finishes resizing the table, it returns to the normal state. +Only a table in the normal state can be resized.
This sentence looks redundant with the following one.
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 337
Quoted 5 lines
After a table is back to
doc/guides/howto/rte_flow.rst +4
-0+the normal state, application can start a new resize. +Application can add, change or remove flow rules regardless of table state. +Table performance may worsen in the resizable state. Table performance must +recover after the table is back to the normal state.
This last sentence looks redundant.
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 340
Quoted 3 lines
doc/guides/howto/rte_flow.rst +3
-0+ +Table resize procedure must not interfere with flows that existed before +the table size changed.
Who the "must" is for? I suppose you are talking about driver requirement?
Quoted 1 line
+Flow handles must remain unchanged during table resize.
Again, it is for driver behaviour?
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 343
Quoted 2 lines
doc/guides/howto/rte_flow.rst +2
-0+Application must be able to create new flows and modify or delete existing flows +regardless of the table state.
If it is by design we may say "Application is able".
doc/guides/howto/rte_flow.rst
Quoted 2 lines
doc/guides/howto/rte_flow.rst +2
-0+ +Application needs to set the `RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE` bit in
Please use double backquotes for code items.
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 347
Quoted 2 lines
doc/guides/howto/rte_flow.rst +2
-0+the table attributes when creating a template table that can be resized. +The current API cannot make an existing table resizable if it was not created
In the guide, there is no old or current API.
Quoted 1 line
+with the
RTE_FLOW_TABLE_SPECIALIZE_RESIZABLEbit.
I think this sentence is redundant.
Quoted 1 line
+Resizable template table starts in the normal state.
It looks obvious.
Remember a guide is doc a detailed API description.
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 355
Quoted 6 lines
doc/guides/howto/rte_flow.rst +6
-0+ +Application can trigger the table to resize by calling +the `rte_flow_template_table_resize()` function. The resize process updates +the PMD table settings and port hardware to fit the new flows capacity. +The resize process must not affect the current flows functionality. +The resize process must not change the current flows handles.
Is it redundant with what is above?
Try to be concise.
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 358
Quoted 3 lines
doc/guides/howto/rte_flow.rst +3
-0+Application can create new flows and modify or delete existing flows +while the table is resizing, but the table performance might be +slower than usual.
It was already explained before.
I prefer this one.
doc/guides/howto/rte_flow.rst Terminal 1: output log::
Quoted 4 lines
doc/guides/howto/rte_flow.rst +4
-0+ +Flows that existed before table resize are still functional after table resize. +However, the PMD flow resources that existed before table resize may not be +fully efficient after table resize.
What is "not fully efficient" exactly?
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 371
Quoted 10 lines
In this case, application can combine
doc/guides/howto/rte_flow.rst +9
-0+the old flow resources from before the resize with the new flow resources +from after the resize. +Application uses the `rte_flow_async_update_resized()` function call to update +flow resources. The flow update process does not interfere with or alter +the existing flow object. It only updates the PMD resources associated with that +flow. +The post-resize flow update process may conflict with application flows +operations, such as creation, removal or update. Therefore, performance-oriented +applications need to choose the best time to call for post-resize flow update.
Not perfectly clear. What must be done by the app exactly?
doc/guides/howto/rte_flow.rst Terminal 1: output log::
Quoted 9 lines
doc/guides/howto/rte_flow.rst +9
-0+When application selects flows for the post table resize update, it can iterate +over all existing flows or it can keep track of the flows that need +to be updated. +Flows that were created after the `rte_flow_template_table_resize()` +call finished do not require an update. + +To return table to the normal state, use the +`rte_flow_template_table_resize_complete()`. If PMD does not require post-resize +flows
How do we know what the PMD requires?
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 385
Quoted 6 lines
update and application does not care about PMD resources optimization,
doc/guides/howto/rte_flow.rst +5
-0+application can avoid post-resize flows update and move resized table back to +the normal state right after the `rte_flow_template_table_resize()`. +Application can resize the table again when it is in the normal state. + +Testpmd commands:(wrapped for clarity)::
You should replace the first colon with a space.
Quoted 8 lines
doc/guides/howto/rte_flow.rst +8
-0+ + # 1. Create resizable template table for 1 flow. + testpmd> flow pattern_template 0 create ingress pattern_template_id 3 + template eth / ipv4 / udp src mask 0xffff / end + testpmd> flow actions_template 0 create ingress actions_template_id 7 + template count / rss / end + testpmd> flow template_table 0 create table_id 101 resizable ingress + group 1 priority 0 rules_number 1
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 403
Quoted 10 lines
doc/guides/howto/rte_flow.rst +10
-0+ pattern_template 3 actions_template 7 + + # 2. Queue a flow rule. + testpmd> flow queue 0 create 0 template_table 101 + pattern_template 0 actions_template 0 postpone no + pattern eth / ipv4 / udp src spec 1 / end actions count / rss / end + + # 3. Resize the template table + # The new table capacity is 32 rules + testpmd> flow template_table 0 resize table_resize_id 101
Why not just "resize table 101" ?
Quoted 23 lines
doc/guides/howto/rte_flow.rst +18
-0+ table_resize_rules_num 32 + + # 4. Queue more flow rules. + testpmd> flow queue 0 create 0 template_table 101 + pattern_template 0 actions_template 0 postpone no + pattern eth / ipv4 / udp src spec 2 / end actions count / rss / end + testpmd> flow queue 0 create 0 template_table 101 + pattern_template 0 actions_template 0 postpone no + pattern eth / ipv4 / udp src spec 3 / end actions count / rss / end + testpmd> flow queue 0 create 0 template_table 101 + pattern_template 0 actions_template 0 postpone no + pattern eth / ipv4 / udp src spec 4 / end actions count / rss / end + + # 5. Queue the initial flow update. + testpmd> flow queue 0 update_resized 0 rule 0 + + # 6. Complete the table resize. + testpmd> flow template_table 0 resize_complete table 101doc/guides/rel_notes/release_24_03.rst +0
-0
doc/guides/rel_notes/release_24_03.rst New Features · line 58
Quoted 4 lines
doc/guides/rel_notes/release_24_03.rst +1
-0@@ -55,6 +55,8 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added support for template API table resize.**
Would be better to give a quick description to say it is adding a new table creation flag and 4 new functions.
[...]
Quoted 7 lines
lib/ethdev/rte_flow.h +4
-0+/** +* Specialize table for resize. +*/ +#define RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE RTE_BIT32(2)/**@}*/
[...]
Quoted 5 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Query whether a table can be resized.
Quoted 8 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @paramtbl_attr
+ * Template table.
+ *
+ * @return
+ * True if the table can be resized.
This is not aligned, probably because of parameters above.
Quoted 6 lines
+ */
lib/ethdev/rte_flow.h +5
-0+__rte_experimental +bool +rte_flow_table_resizable(__rte_unused uint16_t port_id, +const struct rte_flow_template_table_attr *tbl_attr); +
[...]
Quoted 6 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Change template table flow rules capacity.
+ * PMD implementation must support table change to the new size.
I don't think it is the good place for this PMD comment.
Quoted 19 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param table
+ * Template table to modify.
+ * @paramnb_rules
+ * New flow rules capacity.
+ * @param error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return+ * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *table* cannot be resized or resize to *nb_rules*+ * is not supported in PMD.
+ */lib/ethdev/rte_flow.h +1
-0+__rte_experimental
lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6810
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+int +rte_flow_template_table_resize (uint16_t port_id, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Following table resize, update flow resources in port.
You need to give details here about why, when to do it, and what are the constraints.
It is really better to have all details in doxygen. The RST is more to explain the global flow of the process.
Quoted 23 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param queue
+ * Flow queue for async operation.
+ * @param attr
+ * Async operation attributes.
+ * @param rule
+ * Flow rule to update.
+ * @paramuser_data
+ * The user data that will be returned on async completion event.
+ * @param error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return+ * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *rule* cannot be updated.+ */
lib/ethdev/rte_flow.h +2
-0+__rte_experimental +int
lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6843
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+rte_flow_async_update_resized(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, + struct rte_flow_error *error); + +/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Following table resize, notify port that all table flows were updated.
You need to give details here about when to call it.
Quoted 20 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param table
+ * Template table that undergoing resize operation.
+ * @param error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return+ * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) PMD cannot complete table resize.+ */
lib/ethdev/rte_flow.h +5
-0+__rte_experimental +int +rte_flow_template_table_resize_complete (uint16_t port_id, +struct rte_flow_template_table *table, +struct rte_flow_error *error);
[...]
lib/ethdev/version.map EXPERIMENTAL { · line 324
Quoted 7 lines
lib/ethdev/version.map +5
-0+ # added in 24.03 + rte_flow_table_resizable; + rte_flow_template_table_resize; + rte_flow_async_update_resized; + rte_flow_template_table_resize_complete;
alphabetical ordering here please
Hello Thomas,
Quoted 12 lines
Quoted 12 lines
doc/guides/howto/rte_flow.rst +12
-0+ + # 1. Create resizable template table for 1 flow. + testpmd> flow pattern_template 0 create ingress pattern_template_id 3 + template eth / ipv4 / udp src mask 0xffff / end + testpmd> flow actions_template 0 create ingress actions_template_id 7 + template count / rss / end + testpmd> flow template_table 0 create table_id 101 resizable ingress + group 1 priority 0 rules_number 1 + pattern_template 3 actions_template 7 + + # 2. Queue a flow rule. + testpmd> flow queue 0 create 0 template_table 101
Quoted 9 lines
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 403
Quoted 6 lines
doc/guides/howto/rte_flow.rst +6
-0+ pattern_template 0 actions_template 0 postpone no + pattern eth / ipv4 / udp src spec 1 / end actions count / rss / end + + # 3. Resize the template table + # The new table capacity is 32 rules + testpmd> flow template_table 0 resize table_resize_id 101Why not just "resize table 101" ?
That tokens pattern matched template teble creation.
I'll update the patch.
Quoted 59 lines · Gregory Etelson
Template table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the
RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLEbit set.* Application resizes existing table with the
rte_flow_template_table_resize()function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handlers held by
application.* After
rte_flow_template_table_resize()returned, application must update all existing table flow rules by callingrte_flow_async_update_resized().
The table resize procedure does not change application flow handler. However, flow object can reference internal PMD resources that are obsolete after table resize.rte_flow_async_update_resized()moves internal flow references to the updated table resources.
The flow update must not interrupt hardware flow operations.* When all table flow were updated, application must call
rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize afterrte_flow_template_table_resize_complete()returned.Testpmd commands:
* Create resizable template table
flowtemplate_table<port-id> createtable_id<tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number<initial table capacity> \
pattern_template<pt1> [pattern_template<pt2> [ ... ]] \
actions_template<at1> [actions_template<at2> [ ... ]]* Resize table:
flowtemplate_table<tbl-id> resizetable_resize_id<tbl-id> \
table_resize_rules_num<new table capacity>
Quoted 9 lines
* Queue a flow update:
flow queue <port-id>update_resized<tbl-id> rule <flow-id>* Complete table resize:
flowtemplate_table<port-id>resize_completetable <tbl-id>Signed-off-by Gregory Etelson <[email protected]>Acked-by Ori Kam <[email protected]>
Hi Gregory,
Thanks for the documentation improvement,
As the APIs are documented well and they are experimental, this enables to properly understand and improve them when another vendor implements them, I think this is good enough to prooceed with the APIs.
I have two more clarification requests, can you please check them below?
<...>
Quoted 24 lines
lib/ethdev/rte_flow.h +23
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Following table resize, update flow resources in port. +* +* @param port_id +* Port identifier of Ethernet device. +* @param queue +* Flow queue for async operation. +* @param attr +* Async operation attributes. +* @param rule +* Flow rule to update. +* @param user_data +* The user data that will be returned on async completion event. +* @param error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid.
lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6838
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* - (-ENOTSUP) if underlying device does not support this functionality. +* - (-EINVAL) if *rule* cannot be updated. +*/ +__rte_experimental +int +rte_flow_async_update_resized (uint16_t port_id,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +
If one ore more flow failed to update, for any reason, should user retry the update (in that case we need a retry error maybe) and can user still call 'rte_flow_template_table_resize_complete()' (for possible next table resize operation)? Can you please clarify this in your document.
When user calls update() with a flow from new table, API should ignore it and return success, you mentioned this is what mlx implementation is doing, what do you think to make this as default API behavior and document it in above API documentation?
Quoted 16 lines
lib/ethdev/rte_flow.h +15
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Following table resize, notify port that all table flows were updated. +* +* @param port_id +* Port identifier of Ethernet device. +* @param table +* Template table that undergoing resize operation. +* @param error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return
lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6863
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* - (0) if success. +* - (-ENODEV) if *port_id* invalid. +* - (-ENOTSUP) if underlying device does not support this functionality. +* - (-EINVAL) PMD cannot complete table resize. +*/ +__rte_experimental +int +rte_flow_template_table_resize_complete (uint16_t port_id, +struct rte_flow_template_table *table, +struct rte_flow_error *error);
If 'rte_flow_template_table_resize_complete()' fails, can application call another resize()? Is this managed in the application level or driver level (by returning error to next resize if complete() is not successful)? Is it something to clarify in your document?
Hello Ferruh,
Quoted 8 lines
I have two more clarification requests, can you please check them below?
If one ore more flow failed to update, for any reason, should user retry the update (in that case we need a retry error maybe) and can user still call '
rte_flow_template_table_resize_complete()' (for possible next table resize operation)? Can you please clarify this in your document.
Please see my comment below.
Quoted 7 lines
When user calls
update()with a flow from new table, API should ignore it and return success, you mentioned this is what mlx implementation is doing, what do you think to make this as default API behavior and document it in above API documentation?
I'll update the patch.
Quoted 7 lines
If '
rte_flow_template_table_resize_complete()' fails, can application call anotherresize()? Is this managed in the application level or driver level (by returning error to next resize ifcomplete()is not successful)? Is it something to clarify in your document?
PMD failures in rte_flow_async_update_resized() and rte_flow_template_table_resize_complete() are not recoverable.
Quoted 32 lines · Gregory
Hello Ferruh,
Quoted 8 lines
I have two more clarification requests, can you please check them below?
If one ore more flow failed to update, for any reason, should user retry the update (in that case we need a retry error maybe) and can user still call '
rte_flow_template_table_resize_complete()' (for possible next table resize operation)? Can you please clarify this in your document.Please see my comment below.
Quoted 7 lines
When user calls
update()with a flow from new table, API should ignore it and return success, you mentioned this is what mlx implementation is doing, what do you think to make this as default API behavior and document it in above API documentation?I'll update the patch.
Quoted 7 lines
If '
rte_flow_template_table_resize_complete()' fails, can application call anotherresize()? Is this managed in the application level or driver level (by returning error to next resize ifcomplete()is not successful)? Is it something to clarify in your document?
Quoted 3 lines
PMD failures in
rte_flow_async_update_resized()andrte_flow_template_table_resize_complete()are not recoverable.
OK, just please make sure this is clear in the documentation. Thanks.
PATCH v6 1/1 ethdev: add template table resize API
In reply to Gregory EtelsonTemplate table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.
Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.
The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE bit set.
* Application resizes existing table with the rte_flow_template_table_resize() function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handles held by
application.
* After rte_flow_template_table_resize() returned, application must update table flow rules by calling rte_flow_async_update_resized().
The call reconfigures internal flow resources for the new table configuration.
The flow update must not interrupt hardware flow operations.
* After table flows were updated, application must call rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize after rte_flow_template_table_resize_complete() returned.
Testpmd commands:
* Create resizable template table
flow template_table <port-id> create table_id <tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number <initial table capacity> \
pattern_template <pt1> [ pattern_template <pt2> [ ... ]] \
actions_template <at1> [ actions_template <at2> [ ... ]]
* Resize table:
flow template_table <tbl-id> resize table_resize_id <tbl-id> \
table_resize_rules_num <new table capacity>
* Queue a flow update:
flow queue <port-id> update_resized <tbl-id> rule <flow-id>
* Complete table resize:
flow template_table <port-id> resize_complete table <tbl-id>
---
v2: Update the patch comment.
Add table resize commands to testpmd user guide.
v3: Rename RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE macro.
v4: Remove inline.
Add use case to rte_flow.rst.
v5: update API guide in the rte_flow.rst.
v6: update docs.
--- app/test-pmd/cmdline_flow.c | 86 +++++++++++++- app/test-pmd/config.c | 102 +++++++++++++++++ app/test-pmd/testpmd.h | 6 + doc/guides/howto/rte_flow.rst | 94 ++++++++++++++++ doc/guides/rel_notes/release_24_03.rst | 12 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++- lib/ethdev/ethdev_trace.h | 33 ++++++ lib/ethdev/ethdev_trace_points.c | 9 ++ lib/ethdev/rte_flow.c | 77 +++++++++++++ lib/ethdev/rte_flow.h | 118 ++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 +++ lib/ethdev/version.map | 6 + 12 files changed, 567 insertions(+), 6 deletions(-)
app/test-pmd/cmdline_flow.c +81 -5
@@ -134,6 +134,7 @@ enum index {/* Queue arguments. */ QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED , QUEUE_INDIRECT_ACTION,
@@ -191,8 +192,12 @@ enum index {/* Table arguments. */ TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,TABLE_CREATE_ID ,TABLE_DESTROY_ID , +TABLE_RESIZE_ID , +TABLE_RESIZE_RULES_NUMBER ,TABLE_INSERTION_TYPE ,TABLE_INSERTION_TYPE_NAME , TABLE_HASH_FUNC,
@@ -204,6 +209,7 @@ enum index {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1323,6 +1329,8 @@ static const enum index next_group_attr[] = {static const enum index next_table_subcmd[] = {TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,ZERO , };
@@ -1337,6 +1345,7 @@ static const enum index next_table_attr[] = {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1353,6 +1362,7 @@ static const enum index next_table_destroy_attr[] = {static const enum index next_queue_subcmd[] = {QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED ,QUEUE_INDIRECT_ACTION ,
@@ -3344,6 +3354,19 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_table_destroy, }, + [TABLE_RESIZE] = { + .name = "resize", + .help = "resize template table", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)), + .call = parse_table + }, + [TABLE_RESIZE_COMPLETE] = { + .name = "resize_complete", + .help = "complete table resize", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + },/* Table arguments. */ [TABLE_CREATE_ID] = { .name = "table_id",
@@ -3354,13 +3377,29 @@ static const struct token token_list[] = { }, [TABLE_DESTROY_ID] = { .name = "table", - .help = "specify table id to destroy", + .help = "table id", .next =NEXT (next_table_destroy_attr, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_RESIZE_ID] = { + .name = "table_resize_id", + .help = "table resize id", + .next =NEXT (NEXT_ENTRY (TABLE_RESIZE_RULES_NUMBER ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + .call = parse_table + }, + [TABLE_RESIZE_RULES_NUMBER] = { + .name = "table_resize_rules_num", + .help = "table resize rules number", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + .call = parse_table + }, [TABLE_INSERTION_TYPE] = { .name = "insertion_type", .help = "specify insertion type",
@@ -3433,6 +3472,12 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_RESIZABLE] = { + .name = "resizable", + .help = "set resizable attribute", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table",
@@ -3525,6 +3570,14 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_FLOW_UPDATE_RESIZED] = { + .name = "update_resized", + .help = "update a flow after table resize", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, [QUEUE_UPDATE] = { .name = "update", .help = "update a flow rule",
@@ -10334,6 +10387,7 @@ parse_table(struct context *ctx, const struct token *token, }switch (ctx->curr) {case TABLE_CREATE : +case TABLE_RESIZE : out->command = ctx->curr; ctx->objdata =0 ; ctx->object = out;
@@ -10378,18 +10432,25 @@ parse_table(struct context *ctx, const struct token *token,case TABLE_TRANSFER_WIRE_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ;return len;case TABLE_TRANSFER_VPORT_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; +return len; +case TABLE_RESIZABLE : + out->args.table.attr.specialize |= +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE ;return len;case TABLE_RULES_NUMBER : ctx->objdata =0 ; ctx->object = out; ctx->objmask =NULL ;return len; +case TABLE_RESIZE_ID : +case TABLE_RESIZE_RULES_NUMBER : +return len;default :return -1 ; }
@@ -10411,7 +10472,8 @@ parse_table_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==TABLE ) { -if (ctx->curr !=TABLE_DESTROY ) +if (ctx->curr !=TABLE_DESTROY && + ctx->curr !=TABLE_RESIZE_COMPLETE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -10513,7 +10575,8 @@ parse_qo_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==QUEUE ) { -if (ctx->curr !=QUEUE_DESTROY ) +if (ctx->curr !=QUEUE_DESTROY && + ctx->curr !=QUEUE_FLOW_UPDATE_RESIZED )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -12569,10 +12632,18 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case TABLE_RESIZE_COMPLETE : +port_flow_template_table_resize_complete + (in->port, in->args.table_destroy.table_id[0 ]); +break ;case GROUP_SET_MISS_ACTIONS :port_queue_group_set_miss_actions (in->port, &in->args.vc.attr, in->args.vc.actions);break ; +case TABLE_RESIZE : +port_flow_template_table_resize (in->port, in->args.table.id, + in->args.table.attr.nb_flows); +break ;case QUEUE_CREATE : port_queue_flow_create(in->port, in->queue, in->postpone, in->args.vc.table_id, in->args.vc.rule_id,
@@ -12584,6 +12655,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case QUEUE_FLOW_UPDATE_RESIZED : +port_queue_flow_update_resized (in->port, in->queue, + in->postpone, + in->args.destroy.rule[0 ]); +break ;case QUEUE_UPDATE : port_queue_flow_update(in->port, in->queue, in->postpone, in->args.vc.rule_id, in->args.vc.act_templ_id,
app/test-pmd/config.c +102 -0
126 lines not on this page · raw message
app/test-pmd/testpmd.h +6 -0
@@ -110,6 +110,7 @@ enum {enum {QUEUE_JOB_TYPE_FLOW_CREATE ,QUEUE_JOB_TYPE_FLOW_DESTROY , +QUEUE_JOB_TYPE_FLOW_TRANSFER ,QUEUE_JOB_TYPE_FLOW_UPDATE ,QUEUE_JOB_TYPE_ACTION_CREATE ,QUEUE_JOB_TYPE_ACTION_DESTROY ,
@@ -981,7 +982,12 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates);int port_flow_template_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_update_resized (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t flow_id);int port_flow_template_table_flush (portid_t port_id); +int port_flow_template_table_resize_complete (portid_t port_id,uint32_t table_id); +int port_flow_template_table_resize (portid_t port_id, +uint32_t table_id,uint32_t flows_num);int port_queue_group_set_miss_actions (portid_t port_id,const struct rte_flow_attr *attr,const struct rte_flow_action *actions); int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
doc/guides/howto/rte_flow.rst +94 -0
97 lines not on this page · raw message
doc/guides/rel_notes/release_24_03.rst +12 -0
@@ -55,6 +55,18 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added API to change template table flows capacity.** + + * ``RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE`` table configuration bit. + Set when template template must be created with the resizable property. + * ``rte_flow_template_table_resizable()``. + Query wheather template table can be resized. + * ``rte_flow_template_table_resize()``. + Reconfigure template table for new flows capacity. + * ``rte_flow_async_update_resized()``. + Reconfigure flows for the updated table configuration. + * ``rte_flow_template_table_resize_complete()``. + Complete table resize. Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +14 -1
@@ -2984,12 +2984,21 @@ following sections. - Create a table:: flow table {port_id} create - [table_id {id}] + [table_id {id}] [resizable] [group {group_id}] [priority {level}] [ingress] [egress] [transfer] rules_number {number} pattern_template {pattern_template_id} actions_template {actions_template_id} +- Resize a table:: + + flow template_table {port_id} resize + table_resize_id {id} table_resize_rules_num {number} + +- Complete table resize:: + + flow template_table {port_id} resize_complete table {table_id} + - Destroy a table:: flow table {port_id} destroy table {id} [...]
@@ -3010,6 +3019,10 @@ following sections. pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end +- Enqueue flow update following table resize:: + + flow queue {port_id} update_resized {table_id} rule {rule_id} + - Enqueue destruction of specific flow rules:: flow queue {port_id} destroy {queue_id}
lib/ethdev/ethdev_trace.h +33 -0
@@ -2572,6 +2572,39 @@ RTE_TRACE_POINT_FP(rte_trace_point_emit_ptr (user_data);rte_trace_point_emit_int (ret); ) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_template_table_resize, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_u32 (nb_rules); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_async_update_resized, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_u32 (queue); +rte_trace_point_emit_ptr (attr); +rte_trace_point_emit_ptr (rule); +rte_trace_point_emit_ptr (user_data); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_table_resize_complete, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_int (ret); +) #ifdef __cplusplus }#endif
lib/ethdev/ethdev_trace_points.c +9 -0
@@ -774,3 +774,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_destroy,RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_action_list_handle_query_update, lib.ethdev.flow.async_action_list_handle_query_update) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_template_table_resize, + lib.ethdev.flow.template_table_resize) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_update_resized, + lib.ethdev.flow.async_update_resized) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_table_resize_complete, + lib.ethdev.flow.table_resize_complete)
lib/ethdev/rte_flow.c +77 -0
80 lines not on this page · raw message
lib/ethdev/rte_flow.h +118 -0
136 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +15 -0
@@ -370,6 +370,21 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_template_table *table, const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** @see rte_flow_template_table_resize() */ +int (*flow_template_table_resize)(struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** @see rte_flow_async_update_resized() */ +int (*flow_update_resized)(struct rte_eth_dev *dev,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +/** @see rte_flow_template_table_resize_complete() */ +int (*flow_template_table_resize_complete) + (struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +struct rte_flow_error *error); };/**
lib/ethdev/version.map +6 -0
@@ -316,6 +316,12 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + + # added in 24.03 + rte_flow_async_update_resized; + rte_flow_template_table_resizable; + rte_flow_template_table_resize; + rte_flow_template_table_resize_complete; }; INTERNAL {
Signature · 1 line
2.39.2
Quoted 56 lines · Gregory Etelson
Template table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the
RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLEbit set.* Application resizes existing table with the
rte_flow_template_table_resize()function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handles held by
application.* After
rte_flow_template_table_resize()returned, application must update table flow rules by callingrte_flow_async_update_resized().
The call reconfigures internal flow resources for the new table configuration.
The flow update must not interrupt hardware flow operations.* After table flows were updated, application must call
rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize afterrte_flow_template_table_resize_complete()returned.Testpmd commands:
* Create resizable template table
flowtemplate_table<port-id> createtable_id<tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number<initial table capacity> \
pattern_template<pt1> [pattern_template<pt2> [ ... ]] \
actions_template<at1> [actions_template<at2> [ ... ]]* Resize table:
flowtemplate_table<tbl-id> resizetable_resize_id<tbl-id> \
table_resize_rules_num<new table capacity>
Quoted 9 lines
* Queue a flow update:
flow queue <port-id>update_resized<tbl-id> rule <flow-id>* Complete table resize:
flowtemplate_table<port-id>resize_completetable <tbl-id>Signed-off-by Gregory Etelson <[email protected]>hAcked-by Ori Kam <[email protected]>
There are some checkpatch warnings [1], but except that looks good to me
@Thomas was reviewing the patch, I will wait him to proceed.
[1]
[PATCH] ethdev: add template table resize API
WARNING:REPEATED_WORD: Possible repeated word: 'template' #567: FILE: doc/guides/rel_notes/release_24_03.rst:76:
+ Set when template template must be created with the resizable property.
WARNING:TYPO_SPELLING: 'wheather' may be misspelled - perhaps 'weather'? #569: FILE: doc/guides/rel_notes/release_24_03.rst:78:
+ Query wheather template table can be resized.
^^^^^^^^
ERROR:SPACING: need consistent spacing around '*' (ctx:WxV) #801: FILE: lib/ethdev/rte_flow.h:5945:
+ rte_flow_template_table_attr *tbl_attr);
^(better to join to "const struct" line)
12/02/2024 19:12, Gregory Etelson:
Quoted 11 lines
doc/guides/howto/rte_flow.rst +9
-0+Template API resizable table +---------------------------- + +Description +~~~~~~~~~~~ + +The resizable template table API enables applications to dynamically adjust +capacity of template tables without disrupting the existing flows operation. +The resizable template table API allows applications to optimize the memory
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 325
Quoted 10 lines
doc/guides/howto/rte_flow.rst +10
-0+usage and performance of template tables according to the traffic conditions +and requirements. + +A typical use case for the resizable template table API: + + 1. Create a resizable table with the initial capacity. + + 2. Change the table flows capacity. + + 3. Update table flows.
Isn't "flow rules" more appropriate than "flows"?
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 329
Quoted 4 lines
doc/guides/howto/rte_flow.rst +4
-0+ + 4. Complete the table resize. + +A resizable table can be ether in the normal or the resizable state.
s/ether/either/
drop "the"
Quoted 1 line
+When application begins to resize the table, it state is changed from
s/it/its/
Quoted 1 line
+the normal to resizable.
to resizable state. (no need from)
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 333
Quoted 2 lines
doc/guides/howto/rte_flow.rst +2
-0+When application finishes resizing the table, the table state returns to +the normal state.
simpler:
until the application finishes the resize procedure.
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 339
Quoted 6 lines
doc/guides/howto/rte_flow.rst +6
-0+Application can resize a table in the normal state only. + +Application needs to set the ``RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE`` bit in +the table attributes when creating a template table that can be resized. +A table cannot be converted to resizable if it was created without the +``RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE`` bit.
Redundant
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 344
Quoted 5 lines
doc/guides/howto/rte_flow.rst +5
-0+A resizable table cannot be converted to non-resizable. + +Application triggers the table resize by calling +the ``rte_flow_template_table_resize()`` function. The resize process updates +the table configuration to fit the new flows capacity.
flows or flow rules?
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 346
Quoted 2 lines
doc/guides/howto/rte_flow.rst +2
-0+Table resize does not change existing flows configuration. +Application can create new flows and modify or delete existing flows
flow rules
doc/guides/howto/rte_flow.rst Terminal 1: output log:: · line 352
Quoted 6 lines
doc/guides/howto/rte_flow.rst +6
-0+while the table is resizing, but the table performance might be +slower than usual. + +Flows that existed before table resize are fully functional after table resize. +However, application needs to update these flows to match the new table +configuration.
This part is not clear.
The rules are functional but needs to be updated. Why?
Quoted 52 lines
doc/guides/howto/rte_flow.rst +47
-0+Application calls the ``rte_flow_async_update_resized()`` to update flow +resources for the new table configuration. +Flows created after table resize match new table configuration. +Application can track flows that need post-resize update or it can update all +existing flows. ``rte_flow_async_update_resized()`` returns success for flows +that were created after table resize. + +Application calls ``rte_flow_template_table_resize_complete()`` to return a +table to the normal state after it completed flows update. + +Testpmd commands (wrapped for clarity):: + + # 1. Create resizable template table for 1 flow. + testpmd> flow pattern_template 0 create ingress pattern_template_id 3 + template eth / ipv4 / udp src mask 0xffff / end + testpmd> flow actions_template 0 create ingress actions_template_id 7 + template count / rss / end + testpmd> flow template_table 0 create table_id 101 resizable ingress + group 1 priority 0 rules_number 1 + pattern_template 3 actions_template 7 + + # 2. Queue a flow rule. + testpmd> flow queue 0 create 0 template_table 101 + pattern_template 0 actions_template 0 postpone no + pattern eth / ipv4 / udp src spec 1 / end actions count / rss / end + + # 3. Resize the template table + # The new table capacity is 32 rules + testpmd> flow template_table 0 resize table_resize_id 101 + table_resize_rules_num 32 + + # 4. Queue more flow rules. + testpmd> flow queue 0 create 0 template_table 101 + pattern_template 0 actions_template 0 postpone no + pattern eth / ipv4 / udp src spec 2 / end actions count / rss / end + testpmd> flow queue 0 create 0 template_table 101 + pattern_template 0 actions_template 0 postpone no + pattern eth / ipv4 / udp src spec 3 / end actions count / rss / end + testpmd> flow queue 0 create 0 template_table 101 + pattern_template 0 actions_template 0 postpone no + pattern eth / ipv4 / udp src spec 4 / end actions count / rss / end + + # 5. Queue the initial flow update. + testpmd> flow queue 0 update_resized 0 rule 0 + + # 6. Complete the table resize. + testpmd> flow template_table 0 resize_complete table 101doc/guides/rel_notes/release_24_03.rst +0
-0
doc/guides/rel_notes/release_24_03.rst New Features · line 63
Quoted 9 lines
doc/guides/rel_notes/release_24_03.rst +6
-0@@ -55,6 +55,18 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added API to change template table flows capacity.** + + * ``RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE`` table configuration bit. + Set when template template must be created with the resizable property. + * ``rte_flow_template_table_resizable()``. + Query wheather template table can be resized.
whether
Quoted 6 lines
doc/guides/rel_notes/release_24_03.rst +6
-0+ * ``rte_flow_template_table_resize()``. + Reconfigure template table for new flows capacity. + * ``rte_flow_async_update_resized()``. + Reconfigure flows for the updated table configuration. + * ``rte_flow_template_table_resize_complete()``. + Complete table resize.
[...]
lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6812
Quoted 8 lines
lib/ethdev/rte_flow.h +6
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Update flow for the new template table configuration after table resize. +* Can be called for *rule* created before and after *table* resize.
I feel we need to explain why it has to be called.
Quoted 30 lines
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param queue
+ * Flow queue for async operation.
+ * @param attr
+ * Async operation attributes.
+ * @param rule
+ * Flow rule to update.
+ * @paramuser_data
+ * The user data that will be returned on async completion event.
+ * @param error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return+ * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *table* was not resized.+ * If *rule* cannot be updated after *table* resize,
+ * unrecoverable *table* error.
+ */lib/ethdev/rte_flow.h +7
-0+__rte_experimental +int +rte_flow_async_update_resized (uint16_t port_id,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +
PATCH v7 1/1 ethdev: add template table resize API
In reply to Gregory EtelsonTemplate table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.
Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.
The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE bit set.
* Application resizes existing table with the rte_flow_template_table_resize() function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handles held by
application.
* After rte_flow_template_table_resize() returned, application must update table flow rules by calling rte_flow_async_update_resized().
The call reconfigures internal flow resources for the new table configuration.
The flow update must not interrupt hardware flow operations.
* After table flows were updated, application must call rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize after rte_flow_template_table_resize_complete() returned.
Testpmd commands:
* Create resizable template table
flow template_table <port-id> create table_id <tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number <initial table capacity> \
pattern_template <pt1> [ pattern_template <pt2> [ ... ]] \
actions_template <at1> [ actions_template <at2> [ ... ]]
* Resize table:
flow template_table <tbl-id> resize table_resize_id <tbl-id> \
table_resize_rules_num <new table capacity>
* Queue a flow update:
flow queue <port-id> update_resized <tbl-id> rule <flow-id>
* Complete table resize:
flow template_table <port-id> resize_complete table <tbl-id>
---
v2: Update the patch comment.
Add table resize commands to testpmd user guide.
v3: Rename RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE macro.
v4: Remove inline.
Add use case to rte_flow.rst.
v5: Update API guide in the rte_flow.rst.
v6: Update docs.
v7: More API doc updates.
--- app/test-pmd/cmdline_flow.c | 86 +++++++++++++- app/test-pmd/config.c | 102 +++++++++++++++++ app/test-pmd/testpmd.h | 6 + doc/guides/howto/rte_flow.rst | 88 +++++++++++++++ doc/guides/rel_notes/release_24_03.rst | 12 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++- lib/ethdev/ethdev_trace.h | 33 ++++++ lib/ethdev/ethdev_trace_points.c | 9 ++ lib/ethdev/rte_flow.c | 77 +++++++++++++ lib/ethdev/rte_flow.h | 119 ++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 +++ lib/ethdev/version.map | 6 + 12 files changed, 562 insertions(+), 6 deletions(-)
app/test-pmd/cmdline_flow.c +81 -5
@@ -134,6 +134,7 @@ enum index {/* Queue arguments. */ QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED , QUEUE_INDIRECT_ACTION,
@@ -191,8 +192,12 @@ enum index {/* Table arguments. */ TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,TABLE_CREATE_ID ,TABLE_DESTROY_ID , +TABLE_RESIZE_ID , +TABLE_RESIZE_RULES_NUMBER ,TABLE_INSERTION_TYPE ,TABLE_INSERTION_TYPE_NAME , TABLE_HASH_FUNC,
@@ -204,6 +209,7 @@ enum index {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1323,6 +1329,8 @@ static const enum index next_group_attr[] = {static const enum index next_table_subcmd[] = {TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,ZERO , };
@@ -1337,6 +1345,7 @@ static const enum index next_table_attr[] = {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1353,6 +1362,7 @@ static const enum index next_table_destroy_attr[] = {static const enum index next_queue_subcmd[] = {QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED ,QUEUE_INDIRECT_ACTION ,
@@ -3344,6 +3354,19 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_table_destroy, }, + [TABLE_RESIZE] = { + .name = "resize", + .help = "resize template table", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)), + .call = parse_table + }, + [TABLE_RESIZE_COMPLETE] = { + .name = "resize_complete", + .help = "complete table resize", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + },/* Table arguments. */ [TABLE_CREATE_ID] = { .name = "table_id",
@@ -3354,13 +3377,29 @@ static const struct token token_list[] = { }, [TABLE_DESTROY_ID] = { .name = "table", - .help = "specify table id to destroy", + .help = "table id", .next =NEXT (next_table_destroy_attr, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_RESIZE_ID] = { + .name = "table_resize_id", + .help = "table resize id", + .next =NEXT (NEXT_ENTRY (TABLE_RESIZE_RULES_NUMBER ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + .call = parse_table + }, + [TABLE_RESIZE_RULES_NUMBER] = { + .name = "table_resize_rules_num", + .help = "table resize rules number", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + .call = parse_table + }, [TABLE_INSERTION_TYPE] = { .name = "insertion_type", .help = "specify insertion type",
@@ -3433,6 +3472,12 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_RESIZABLE] = { + .name = "resizable", + .help = "set resizable attribute", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table",
@@ -3525,6 +3570,14 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_FLOW_UPDATE_RESIZED] = { + .name = "update_resized", + .help = "update a flow after table resize", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, [QUEUE_UPDATE] = { .name = "update", .help = "update a flow rule",
@@ -10334,6 +10387,7 @@ parse_table(struct context *ctx, const struct token *token, }switch (ctx->curr) {case TABLE_CREATE : +case TABLE_RESIZE : out->command = ctx->curr; ctx->objdata =0 ; ctx->object = out;
@@ -10378,18 +10432,25 @@ parse_table(struct context *ctx, const struct token *token,case TABLE_TRANSFER_WIRE_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ;return len;case TABLE_TRANSFER_VPORT_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; +return len; +case TABLE_RESIZABLE : + out->args.table.attr.specialize |= +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE ;return len;case TABLE_RULES_NUMBER : ctx->objdata =0 ; ctx->object = out; ctx->objmask =NULL ;return len; +case TABLE_RESIZE_ID : +case TABLE_RESIZE_RULES_NUMBER : +return len;default :return -1 ; }
@@ -10411,7 +10472,8 @@ parse_table_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==TABLE ) { -if (ctx->curr !=TABLE_DESTROY ) +if (ctx->curr !=TABLE_DESTROY && + ctx->curr !=TABLE_RESIZE_COMPLETE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -10513,7 +10575,8 @@ parse_qo_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==QUEUE ) { -if (ctx->curr !=QUEUE_DESTROY ) +if (ctx->curr !=QUEUE_DESTROY && + ctx->curr !=QUEUE_FLOW_UPDATE_RESIZED )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -12569,10 +12632,18 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case TABLE_RESIZE_COMPLETE : +port_flow_template_table_resize_complete + (in->port, in->args.table_destroy.table_id[0 ]); +break ;case GROUP_SET_MISS_ACTIONS :port_queue_group_set_miss_actions (in->port, &in->args.vc.attr, in->args.vc.actions);break ; +case TABLE_RESIZE : +port_flow_template_table_resize (in->port, in->args.table.id, + in->args.table.attr.nb_flows); +break ;case QUEUE_CREATE : port_queue_flow_create(in->port, in->queue, in->postpone, in->args.vc.table_id, in->args.vc.rule_id,
@@ -12584,6 +12655,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case QUEUE_FLOW_UPDATE_RESIZED : +port_queue_flow_update_resized (in->port, in->queue, + in->postpone, + in->args.destroy.rule[0 ]); +break ;case QUEUE_UPDATE : port_queue_flow_update(in->port, in->queue, in->postpone, in->args.vc.rule_id, in->args.vc.act_templ_id,
app/test-pmd/config.c +102 -0
126 lines not on this page · raw message
app/test-pmd/testpmd.h +6 -0
@@ -110,6 +110,7 @@ enum {enum {QUEUE_JOB_TYPE_FLOW_CREATE ,QUEUE_JOB_TYPE_FLOW_DESTROY , +QUEUE_JOB_TYPE_FLOW_TRANSFER ,QUEUE_JOB_TYPE_FLOW_UPDATE ,QUEUE_JOB_TYPE_ACTION_CREATE ,QUEUE_JOB_TYPE_ACTION_DESTROY ,
@@ -981,7 +982,12 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates);int port_flow_template_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_update_resized (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t flow_id);int port_flow_template_table_flush (portid_t port_id); +int port_flow_template_table_resize_complete (portid_t port_id,uint32_t table_id); +int port_flow_template_table_resize (portid_t port_id, +uint32_t table_id,uint32_t flows_num);int port_queue_group_set_miss_actions (portid_t port_id,const struct rte_flow_attr *attr,const struct rte_flow_action *actions); int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
doc/guides/howto/rte_flow.rst +88 -0
91 lines not on this page · raw message
doc/guides/rel_notes/release_24_03.rst +12 -0
@@ -55,6 +55,18 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added API to change template table flows capacity.** + + * ``RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE`` table configuration bit. + Set when template must be created with the resizable property. + * ``rte_flow_template_table_resizable()``. + Query wheather template table can be resized. + * ``rte_flow_template_table_resize()``. + Reconfigure template table for new flows capacity. + * ``rte_flow_async_update_resized()``. + Reconfigure flows for the updated table configuration. + * ``rte_flow_template_table_resize_complete()``. + Complete table resize. Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +14 -1
@@ -2984,12 +2984,21 @@ following sections. - Create a table:: flow table {port_id} create - [table_id {id}] + [table_id {id}] [resizable] [group {group_id}] [priority {level}] [ingress] [egress] [transfer] rules_number {number} pattern_template {pattern_template_id} actions_template {actions_template_id} +- Resize a table:: + + flow template_table {port_id} resize + table_resize_id {id} table_resize_rules_num {number} + +- Complete table resize:: + + flow template_table {port_id} resize_complete table {table_id} + - Destroy a table:: flow table {port_id} destroy table {id} [...]
@@ -3010,6 +3019,10 @@ following sections. pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end +- Enqueue flow update following table resize:: + + flow queue {port_id} update_resized {table_id} rule {rule_id} + - Enqueue destruction of specific flow rules:: flow queue {port_id} destroy {queue_id}
lib/ethdev/ethdev_trace.h +33 -0
@@ -2572,6 +2572,39 @@ RTE_TRACE_POINT_FP(rte_trace_point_emit_ptr (user_data);rte_trace_point_emit_int (ret); ) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_template_table_resize, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_u32 (nb_rules); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_async_update_resized, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_u32 (queue); +rte_trace_point_emit_ptr (attr); +rte_trace_point_emit_ptr (rule); +rte_trace_point_emit_ptr (user_data); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_table_resize_complete, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_int (ret); +) #ifdef __cplusplus }#endif
lib/ethdev/ethdev_trace_points.c +9 -0
@@ -774,3 +774,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_destroy,RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_action_list_handle_query_update, lib.ethdev.flow.async_action_list_handle_query_update) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_template_table_resize, + lib.ethdev.flow.template_table_resize) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_update_resized, + lib.ethdev.flow.async_update_resized) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_table_resize_complete, + lib.ethdev.flow.table_resize_complete)
lib/ethdev/rte_flow.c +77 -0
80 lines not on this page · raw message
lib/ethdev/rte_flow.h +119 -0
137 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +15 -0
@@ -370,6 +370,21 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_template_table *table, const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** @see rte_flow_template_table_resize() */ +int (*flow_template_table_resize)(struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** @see rte_flow_async_update_resized() */ +int (*flow_update_resized)(struct rte_eth_dev *dev,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +/** @see rte_flow_template_table_resize_complete() */ +int (*flow_template_table_resize_complete) + (struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +struct rte_flow_error *error); };/**
lib/ethdev/version.map +6 -0
@@ -316,6 +316,12 @@ EXPERIMENTAL { rte_eth_recycle_rx_queue_info_get; rte_flow_group_set_miss_actions; rte_flow_calc_table_hash; + + # added in 24.03 + rte_flow_async_update_resized; + rte_flow_template_table_resizable; + rte_flow_template_table_resize; + rte_flow_template_table_resize_complete; }; INTERNAL {
Signature · 1 line
2.39.2
14/02/2024 15:32, Gregory Etelson:
Quoted 40 lines
doc/guides/howto/rte_flow.rst +40
-0+The resizable template table API enables applications to dynamically adjust +capacity of template tables without disrupting the existing flow rules +operation. The resizable template table API allows applications to optimize the +memory usage and performance of template tables according to the traffic +conditions and requirements. + +A typical use case for the resizable template table API: + + #. Create a resizable table with the initial capacity. + #. Change the table flow rules capacity. + #. Update table flow objects. + #. Complete the table resize. + +A resizable table can be either in normal or resizable state. +When application begins to resize the table, its state is changed to resizable. +The table stays in resizable state until the application finishes resize +procedure. +The application can resize a table in the normal state only. + +The application needs to set the ``RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE`` bit in +the table attributes when creating a template table that can be resized, +and the bit cannot be set or cleared later. + +The application triggers the table resize by calling +the ``rte_flow_template_table_resize()`` function. The resize process updates +the table configuration to fit the new flow rules capacity. +Table resize does not change existing flow objects configuration. +The application can create new flow rules and modify or delete existing flow +rules while the table is resizing, but the table performance might be +slower than usual. + +Flow rules that existed before table resize are fully functional after +table resize. However, the application must update flow objects to match +the new table configuration. +The application calls ``rte_flow_async_update_resized()`` to update flow object +for the new table configuration. +All table flow rules must be updated. + +The application calls ``rte_flow_template_table_resize_complete()`` to return a +table to normal state after it completed flow objects update.
[...]
Quoted 3 lines
+ * Update flow for the new template table configuration after table resize.
+ * Must be called for each *rule* created before and after *table* resize.
+ * Must be called beforerte_flow_template_table_resize_complete().
That's a clear explanation.
Quoted 74 lines · Gregory Etelson
Template table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the
RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLEbit set.* Application resizes existing table with the
rte_flow_template_table_resize()function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handles held by
application.* After
rte_flow_template_table_resize()returned, application must update table flow rules by callingrte_flow_async_update_resized().
The call reconfigures internal flow resources for the new table configuration.
The flow update must not interrupt hardware flow operations.* After table flows were updated, application must call
rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize afterrte_flow_template_table_resize_complete()returned.Testpmd commands:
* Create resizable template table
flowtemplate_table<port-id> createtable_id<tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number<initial table capacity> \
pattern_template<pt1> [pattern_template<pt2> [ ... ]] \
actions_template<at1> [actions_template<at2> [ ... ]]* Resize table:
flowtemplate_table<tbl-id> resizetable_resize_id<tbl-id> \
table_resize_rules_num<new table capacity>* Queue a flow update:
flow queue <port-id>update_resized<tbl-id> rule <flow-id>* Complete table resize:
flowtemplate_table<port-id>resize_completetable <tbl-id>Signed-off-by Gregory Etelson <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Ferruh Yigit <[email protected]>---
v2: Update the patch comment.
Add table resize commands to testpmd user guide.
v3: RenameRTE_FLOW_TABLE_SPECIALIZE_RESIZABLEmacro.
v4: Remove inline.
Add use case torte_flow.rst.
v5: Update API guide in therte_flow.rst.
v6: Update docs.
v7: More API doc updates.
Quoted 15 lines
--- app/test-pmd/cmdline_flow.c | 86 +++++++++++++- app/test-pmd/config.c | 102 +++++++++++++++++ app/test-pmd/testpmd.h | 6 + doc/guides/howto/rte_flow.rst | 88 +++++++++++++++ doc/guides/rel_notes/release_24_03.rst | 12 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++- lib/ethdev/ethdev_trace.h | 33 ++++++ lib/ethdev/ethdev_trace_points.c | 9 ++ lib/ethdev/rte_flow.c | 77 +++++++++++++ lib/ethdev/rte_flow.h | 119 ++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 +++ lib/ethdev/version.map | 6 + 12 files changed, 562 insertions(+), 6 deletions(-)
Having conflict while applying the patch, can you please rebase it on latest 'next-net'?
<...>
Quoted 5 lines
doc/guides/rel_notes/release_24_03.rst +0
-0
doc/guides/rel_notes/release_24_03.rst New Features · line 64
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +6
-0@@ -55,6 +55,18 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added API to change template table flows capacity.** + + * ``RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE`` table configuration bit. + Set when template must be created with the resizable property. + * ``rte_flow_template_table_resizable()``. + Query wheather template table can be resized.
s/wheather/whether/
<...>
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Query whether a table can be resized. + * + * @param port_id + * Port identifier of Ethernet device. + * @param tbl_attr + * Template table.
doc/guides/rel_notes/release_24_03.rst New Features
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+ * + * @return + * True if the table can be resized. + */ +__rte_experimental +bool +rte_flow_template_table_resizable + (__rte_unused uint16_t port_id, + const struct rte_flow_template_table_attr *tbl_attr); +
Syntax above is odd, why not move parenthesis to first line.
<...>
Quoted 34 lines
/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice.doc/guides/rel_notes/release_24_03.rst +27
-0@@ -6750,6 +6774,101 @@ rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table const struct rte_flow_item pattern[], uint8_t pattern_template_index, uint32_t *hash, struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Update template table for new flow rules capacity. + * + * @param port_id + * Port identifier of Ethernet device. + * @param table + * Template table to modify. + * @param nb_rules + * New flow rules capacity. + * @param error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * - (0) if success. + * - (-ENODEV) if *port_id* invalid. + * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if *table* is not resizable or + * *table* resize to *nb_rules* is not supported or + * unrecoverable *table* error. + */ +__rte_experimental +int +rte_flow_template_table_resize(uint16_t port_id,
doc/guides/rel_notes/release_24_03.rst rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6813
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +9
-0+ struct rte_flow_template_table *table, + uint32_t nb_rules, + struct rte_flow_error *error); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Update flow for the new template table configuration after table resize. + * Must be called for each *rule* created before and after *table* resize.
This is different than previous version, I just want to confirm if this is intentional.
Rules created *before* resize must be updated.
Rules created *after* resize not need to be updated, but if API accepts them and just returns a quick success, this helps user and even user may prefer to not keep track of flows as before and after resize, in a good time user can call update for all flows.
But I am not clear why API is saying all flows (before or after) *must* be updated?
If user is already keeping record of flows *before* resize, why not let app to update only those flows?
Is the enforcing update of all flows done intentionally, or is it just wording error?
<...>
Quoted 18 lines
doc/guides/rel_notes/release_24_03.rst +18
-0+/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Resume normal operational mode after table was resized and + * table rules were updated for the new table configuration. + * + * @param port_id + * Port identifier of Ethernet device. + * @param table + * Template table that undergoing resize operation. + * @param error + * Perform verbose error reporting if not NULL. + * PMDs initialize this structure in case of error only. + * + * @return + * - (0) if success. + * - (-ENODEV) if *port_id* invalid.
doc/guides/rel_notes/release_24_03.rst rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6841
Quoted 10 lines
doc/guides/rel_notes/release_24_03.rst +10
-0+ * - (-ENOTSUP) if underlying device does not support this functionality. + * - (-EINVAL) if there are rules that were not updated or + * *table* cannot complete table resize, + * unrecoverable error. + */ +__rte_experimental +int +rte_flow_template_table_resize_complete(uint16_t port_id, + struct rte_flow_template_table *table, + struct rte_flow_error *error);
I think I asked this before but perhaps missed the response, it is possible that user missed to update all flows and called this API, it will return -EINVAL, in this case it is not clear for user if there is a unrecoverable error or just need to update more flows.
What do you think to send a different error for the case that there are flows not updated, so user can action on this information.
Hello Ferruh,
Quoted 3 lines
Having conflict while applying the patch, can you please rebase it on latest 'next-net'?
Will rebase and update the patch.
Quoted 7 lines
Quoted 3 lines
+ Query wheather template table can be resized.
s/wheather/whether/
<...>
fix in updated patch
Quoted 9 lines
lib/ethdev/rte_flow.h struct rte_flow_template_table_attr { · line 5850
Quoted 7 lines
lib/ethdev/rte_flow.h +6
-0+__rte_experimental +bool +rte_flow_template_table_resizable + (__rte_unused uint16_t port_id, +const struct rte_flow_template_table_attr *tbl_attr); +Syntax above is odd, why not move parenthesis to first line.
Agree that's odd style.
DPDK prefers that way.
Please check rte_flow_driver.h::rte_flow.ops.
Quoted 3 lines
This is different than previous version, I just want to confirm if this is intentional.
That API version was discussed with Thomas.
The alternative was to introduce additional function call to query whether a flow rule needs conversion after table resize. As the result, the application still needs to iterate on all table flow rules.
Quoted 2 lines
Rules created *before* resize must be updated.
That part remains. The application must update
flow rules created before resize.
Quoted 2 lines
Rules created *after* resize not need to be updated, but if API accepts them and just returns a quick success,
Calling update for new rules will return success without flow update.
Quoted 2 lines
this helps user and even user may
prefer to not keep track of flows as before and after resize,
The application now does not need to differentiate table flow rules. All table flow rules must be updated after table resize.
Quoted 35 lines
Quoted 19 lines
lib/ethdev/rte_flow.h +18
-0+/** +* @warning +* @b EXPERIMENTAL: this API may change without prior notice. +* +* Resume normal operational mode after table was resized and +* table rules were updated for the new table configuration. +* +* @param port_id +* Port identifier of Ethernet device. +* @param table +* Template table that undergoing resize operation. +* @param error +* Perform verbose error reporting if not NULL. +* PMDs initialize this structure in case of error only. +* +* @return +* - (0) if success. +* - (-ENODEV) if *port_id* invalid. lib/ethdev/rte_flow.h rte_flow_calc_table_hash(uint16_t port_id, const struct rte_flow_template_table · line 6871
Quoted 10 lines
lib/ethdev/rte_flow.h +10
-0+* - (-ENOTSUP) if underlying device does not support this functionality. +* - (-EINVAL) if there are rules that were not updated or +* *table* cannot complete table resize, +* unrecoverable error. +*/ +__rte_experimental +int +rte_flow_template_table_resize_complete (uint16_t port_id, +struct rte_flow_template_table *table, +struct rte_flow_error *error);I think I asked this before but perhaps missed the response, it is possible that user missed to update all flows and called this API, it will return
-EINVAL, in this case it is not clear for user if there is a unrecoverable error or just need to update more flows.
Quoted 4 lines
What do you think to send a different error for the case that there are flows not updated, so user can action on this information.
A different error is good.
What about EBUSY ?
Quoted 28 lines · Gregory
Hello Ferruh,
Quoted 3 lines
Having conflict while applying the patch, can you please rebase it on latest 'next-net'?
Will rebase and update the patch.
Quoted 7 lines
Quoted 3 lines
+ Query wheather template table can be resized.
s/wheather/whether/
<...>
fix in updated patch
Quoted 9 lines
lib/ethdev/rte_flow.h struct rte_flow_template_table_attr { · line 5850
Quoted 7 lines
lib/ethdev/rte_flow.h +6
-0+__rte_experimental +bool +rte_flow_template_table_resizable + (__rte_unused uint16_t port_id, + const struct rte_flow_template_table_attr *tbl_attr); +Syntax above is odd, why not move parenthesis to first line.
Quoted 4 lines
Agree that's odd style.
DPDK prefers that way.
Please checkrte_flow_driver.h::rte_flow.ops.
True that is also odd but at least it is function pointers in a struct, but this is regular function deceleration, why not:
```
bool
rte_flow_template_table_resizable(__rte_unused uint16_t port_id,
const struct rte_flow_template_table_attr *tbl_attr);
```Quoted 10 lines
Quoted 3 lines
This is different than previous version, I just want to confirm if this is intentional.
That API version was discussed with Thomas.
The alternative was to introduce additional function call to query whether a flow rule needs conversion after table resize. As the result, the application still needs to iterate on all table flow rules.
Either it or application needs to manage it. Agree that application can call update() on all flows is easier for app, that is why I asked for this clarification.
But still it is different than API definition making it mandatory to call for new flows.
What about something like, although it is a little longer:
``` Update flow for the new template table configuration after table resize. Should be called for rules created before table resize. If called for rules crated after table resize, API should return success, so application is free to call this API for all flows. ```
Quoted 54 lines
Quoted 2 lines
Rules created *before* resize must be updated.
That part remains. The application must update
flow rules created before resize.Quoted 2 lines
Rules created *after* resize not need to be updated, but if API accepts them and just returns a quick success,
Calling update for new rules will return success without flow update.
Quoted 2 lines
this helps user and even user may
prefer to not keep track of flows as before and after resize,The application now does not need to differentiate table flow rules. All table flow rules must be updated after table resize.
Quoted 37 lines
Quoted 29 lines
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Resume normal operational mode after table was resized and
+ * table rules were updated for the new table configuration.
+ *
+ * @paramport_id
+ * Port identifier of Ethernet device.
+ * @param table
+ * Template table that undergoing resize operation.
+ * @param error
+ * Perform verbose error reporting if not NULL.
+ * PMDs initialize this structure in case of error only.
+ *
+ * @return
+ * - (0) if success.
+ * - (-ENODEV) if *port_id* invalid.
+ * - (-ENOTSUP) if underlying device does not support this functionality.
+ * - (-EINVAL) if there are rules that were not updated or
+ * *table* cannot complete table resize,
+ * unrecoverable error.
+ */lib/ethdev/rte_flow.h +4
-0+__rte_experimental +int +rte_flow_template_table_resize_complete (uint16_t port_id, + struct rte_flow_template_tableQuoted 2 lines
*table,
+ structrte_flow_error*error);I think I asked this before but perhaps missed the response, it is possible that user missed to update all flows and called this API, it will return
-EINVAL, in this case it is not clear for user if there is a unrecoverable error or just need to update more flows.
Quoted 8 lines
Quoted 4 lines
What do you think to send a different error for the case that there are flows not updated, so user can action on this information.
A different error is good.
What about EBUSY ?
I don't know, can be EBUSY or EAGAIN.
Or we can overload EEXIST as there are existing not updated flows.
Hello Ferruh,
<...>
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Syntax above is odd, why not move parenthesis to first line.
Agree that's odd style.
DPDK prefers that way.
Please checkrte_flow_driver.h::rte_flow.ops.
Quoted 8 lines
True that is also odd but at least it is function pointers in a struct, but this is regular function deceleration, why not:
``` bool rte_flow_template_table_resizable(__rte_unused uint16_t port_id, const struct rte_flow_template_table_attr *tbl_attr); ```
will change in the next patch update.
<...>
Quoted 7 lines
Either it or application needs to manage it. Agree that application can call
update()on all flows is easier for app, that is why I asked for this clarification.But still it is different than API definition making it mandatory to call for new flows.
Quoted 10 lines
What about something like, although it is a little longer:
``` Update flow for the new template table configuration after table resize. Should be called for rules created before table resize. If called for rules crated after table resize, API should return success, so application is free to call this API for all flows. ```
That's very good.
I'll use it in the next patch update.
<...>
Quoted 8 lines
Quoted 4 lines
A different error is good.
What about EBUSY ?I don't know, can be EBUSY or EAGAIN.
Or we can overload EEXIST as there are existing not updated flows.
According to errno(3):
EAGAIN Resource temporarily unavailable EBUSY Device or resource busy EEXIST File exists
UBUSY fits the context.
PATCH v8 1/1 ethdev: add template table resize API
In reply to Gregory EtelsonTemplate table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.
Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.
The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE bit set.
* Application resizes existing table with the rte_flow_template_table_resize() function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handles held by
application.
* After rte_flow_template_table_resize() returned, application must update table flow rules by calling rte_flow_async_update_resized().
The call reconfigures internal flow resources for the new table configuration.
The flow update must not interrupt hardware flow operations.
* After table flows were updated, application must call rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize after rte_flow_template_table_resize_complete() returned.
Testpmd commands:
* Create resizable template table
flow template_table <port-id> create table_id <tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number <initial table capacity> \
pattern_template <pt1> [ pattern_template <pt2> [ ... ]] \
actions_template <at1> [ actions_template <at2> [ ... ]]
* Resize table:
flow template_table <tbl-id> resize table_resize_id <tbl-id> \
table_resize_rules_num <new table capacity>
* Queue a flow update:
flow queue <port-id> update_resized <tbl-id> rule <flow-id>
* Complete table resize:
flow template_table <port-id> resize_complete table <tbl-id>
---
v2: Update the patch comment.
Add table resize commands to testpmd user guide.
v3: Rename RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE macro.
v4: Remove inline.
Add use case to rte_flow.rst.
v5: Update API guide in the rte_flow.rst.
v6: Update docs.
v7: More API doc updates.
v8: resize_complete returns EBUSY.
--- app/test-pmd/cmdline_flow.c | 86 +++++++++++++- app/test-pmd/config.c | 102 +++++++++++++++++ app/test-pmd/testpmd.h | 6 + doc/guides/howto/rte_flow.rst | 91 +++++++++++++++ doc/guides/rel_notes/release_24_03.rst | 12 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++- lib/ethdev/ethdev_trace.h | 33 ++++++ lib/ethdev/ethdev_trace_points.c | 9 ++ lib/ethdev/rte_flow.c | 77 +++++++++++++ lib/ethdev/rte_flow.h | 118 ++++++++++++++++++++ lib/ethdev/rte_flow_driver.h | 15 +++ lib/ethdev/version.map | 4 + 12 files changed, 562 insertions(+), 6 deletions(-)
app/test-pmd/cmdline_flow.c +81 -5
@@ -134,6 +134,7 @@ enum index {/* Queue arguments. */ QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED , QUEUE_INDIRECT_ACTION,
@@ -191,8 +192,12 @@ enum index {/* Table arguments. */ TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,TABLE_CREATE_ID ,TABLE_DESTROY_ID , +TABLE_RESIZE_ID , +TABLE_RESIZE_RULES_NUMBER ,TABLE_INSERTION_TYPE ,TABLE_INSERTION_TYPE_NAME , TABLE_HASH_FUNC,
@@ -204,6 +209,7 @@ enum index {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1361,6 +1367,8 @@ static const enum index next_group_attr[] = {static const enum index next_table_subcmd[] = {TABLE_CREATE ,TABLE_DESTROY , +TABLE_RESIZE , +TABLE_RESIZE_COMPLETE ,ZERO , };
@@ -1375,6 +1383,7 @@ static const enum index next_table_attr[] = {TABLE_TRANSFER ,TABLE_TRANSFER_WIRE_ORIG ,TABLE_TRANSFER_VPORT_ORIG , +TABLE_RESIZABLE ,TABLE_RULES_NUMBER ,TABLE_PATTERN_TEMPLATE , TABLE_ACTIONS_TEMPLATE,
@@ -1391,6 +1400,7 @@ static const enum index next_table_destroy_attr[] = {static const enum index next_queue_subcmd[] = {QUEUE_CREATE ,QUEUE_DESTROY , +QUEUE_FLOW_UPDATE_RESIZED ,QUEUE_UPDATE ,QUEUE_AGED ,QUEUE_INDIRECT_ACTION ,
@@ -3460,6 +3470,19 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, port)), .call = parse_table_destroy, }, + [TABLE_RESIZE] = { + .name = "resize", + .help = "resize template table", + .next = NEXT(NEXT_ENTRY(TABLE_RESIZE_ID)), + .call = parse_table + }, + [TABLE_RESIZE_COMPLETE] = { + .name = "resize_complete", + .help = "complete table resize", + .next = NEXT(NEXT_ENTRY(TABLE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table_destroy, + },/* Table arguments. */ [TABLE_CREATE_ID] = { .name = "table_id",
@@ -3470,13 +3493,29 @@ static const struct token token_list[] = { }, [TABLE_DESTROY_ID] = { .name = "table", - .help = "specify table id to destroy", + .help = "table id", .next =NEXT (next_table_destroy_attr, NEXT_ENTRY(COMMON_TABLE_ID)), .args = ARGS(ARGS_ENTRY_PTR(struct buffer, args.table_destroy.table_id)), .call = parse_table_destroy, }, + [TABLE_RESIZE_ID] = { + .name = "table_resize_id", + .help = "table resize id", + .next =NEXT (NEXT_ENTRY (TABLE_RESIZE_RULES_NUMBER ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + .call = parse_table + }, + [TABLE_RESIZE_RULES_NUMBER] = { + .name = "table_resize_rules_num", + .help = "table resize rules number", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + .call = parse_table + }, [TABLE_INSERTION_TYPE] = { .name = "insertion_type", .help = "specify insertion type",
@@ -3549,6 +3588,12 @@ static const struct token token_list[] = { .next = NEXT(next_table_attr), .call = parse_table, }, + [TABLE_RESIZABLE] = { + .name = "resizable", + .help = "set resizable attribute", + .next = NEXT(next_table_attr), + .call = parse_table, + }, [TABLE_RULES_NUMBER] = { .name = "rules_number", .help = "number of rules in table",
@@ -3641,6 +3686,14 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct buffer, queue)), .call = parse_qo_destroy, }, + [QUEUE_FLOW_UPDATE_RESIZED] = { + .name = "update_resized", + .help = "update a flow after table resize", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, [QUEUE_UPDATE] = { .name = "update", .help = "update a flow rule",
@@ -10780,6 +10833,7 @@ parse_table(struct context *ctx, const struct token *token, }switch (ctx->curr) {case TABLE_CREATE : +case TABLE_RESIZE : out->command = ctx->curr; ctx->objdata =0 ; ctx->object = out;
@@ -10824,18 +10878,25 @@ parse_table(struct context *ctx, const struct token *token,case TABLE_TRANSFER_WIRE_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_WIRE_ORIG ;return len;case TABLE_TRANSFER_VPORT_ORIG :if (!out->args.table.attr.flow_attr.transfer)return -1 ; - out->args.table.attr.specialize =RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; + out->args.table.attr.specialize |=RTE_FLOW_TABLE_SPECIALIZE_TRANSFER_VPORT_ORIG ; +return len; +case TABLE_RESIZABLE : + out->args.table.attr.specialize |= +RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE ;return len;case TABLE_RULES_NUMBER : ctx->objdata =0 ; ctx->object = out; ctx->objmask =NULL ;return len; +case TABLE_RESIZE_ID : +case TABLE_RESIZE_RULES_NUMBER : +return len;default :return -1 ; }
@@ -10857,7 +10918,8 @@ parse_table_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==TABLE ) { -if (ctx->curr !=TABLE_DESTROY ) +if (ctx->curr !=TABLE_DESTROY && + ctx->curr !=TABLE_RESIZE_COMPLETE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -10959,7 +11021,8 @@ parse_qo_destroy(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command || out->command ==QUEUE ) { -if (ctx->curr !=QUEUE_DESTROY ) +if (ctx->curr !=QUEUE_DESTROY && + ctx->curr !=QUEUE_FLOW_UPDATE_RESIZED )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -13057,10 +13120,18 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case TABLE_RESIZE_COMPLETE : +port_flow_template_table_resize_complete + (in->port, in->args.table_destroy.table_id[0 ]); +break ;case GROUP_SET_MISS_ACTIONS :port_queue_group_set_miss_actions (in->port, &in->args.vc.attr, in->args.vc.actions);break ; +case TABLE_RESIZE : +port_flow_template_table_resize (in->port, in->args.table.id, + in->args.table.attr.nb_flows); +break ;case QUEUE_CREATE : port_queue_flow_create(in->port, in->queue, in->postpone, in->args.vc.table_id, in->args.vc.rule_id,
@@ -13072,6 +13143,11 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case QUEUE_FLOW_UPDATE_RESIZED : +port_queue_flow_update_resized (in->port, in->queue, + in->postpone, + in->args.destroy.rule[0 ]); +break ;case QUEUE_UPDATE : port_queue_flow_update(in->port, in->queue, in->postpone, in->args.vc.rule_id, in->args.vc.act_templ_id,
app/test-pmd/config.c +102 -0
126 lines not on this page · raw message
app/test-pmd/testpmd.h +6 -0
@@ -110,6 +110,7 @@ enum {enum {QUEUE_JOB_TYPE_FLOW_CREATE ,QUEUE_JOB_TYPE_FLOW_DESTROY , +QUEUE_JOB_TYPE_FLOW_TRANSFER ,QUEUE_JOB_TYPE_FLOW_UPDATE ,QUEUE_JOB_TYPE_ACTION_CREATE ,QUEUE_JOB_TYPE_ACTION_DESTROY ,
@@ -981,7 +982,12 @@ int port_flow_template_table_create(portid_t port_id, uint32_t id, uint32_t nb_actions_templates, uint32_t *actions_templates);int port_flow_template_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_update_resized (portid_t port_id,queueid_t queue_id, +bool postpone,uint32_t flow_id);int port_flow_template_table_flush (portid_t port_id); +int port_flow_template_table_resize_complete (portid_t port_id,uint32_t table_id); +int port_flow_template_table_resize (portid_t port_id, +uint32_t table_id,uint32_t flows_num);int port_queue_group_set_miss_actions (portid_t port_id,const struct rte_flow_attr *attr,const struct rte_flow_action *actions); int port_queue_flow_create(portid_t port_id, queueid_t queue_id,
doc/guides/howto/rte_flow.rst +91 -0
94 lines not on this page · raw message
doc/guides/rel_notes/release_24_03.rst +12 -0
@@ -89,6 +89,18 @@ New Features * Added support for comparing result between packet fields or value. +* **Added API to change template table flows capacity.** + + * ``RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLE`` table configuration bit. + Set when template must be created with the resizable property. + * ``rte_flow_template_table_resizable()``. + Query whether template table can be resized. + * ``rte_flow_template_table_resize()``. + Reconfigure template table for new flows capacity. + * ``rte_flow_async_update_resized()``. + Reconfigure flows for the updated table configuration. + * ``rte_flow_template_table_resize_complete()``. + Complete table resize. Removed Items -------------
doc/guides/testpmd_app_ug/testpmd_funcs.rst +14 -1
@@ -2995,12 +2995,21 @@ following sections. - Create a table:: flow table {port_id} create - [table_id {id}] + [table_id {id}] [resizable] [group {group_id}] [priority {level}] [ingress] [egress] [transfer] rules_number {number} pattern_template {pattern_template_id} actions_template {actions_template_id} +- Resize a table:: + + flow template_table {port_id} resize + table_resize_id {id} table_resize_rules_num {number} + +- Complete table resize:: + + flow template_table {port_id} resize_complete table {table_id} + - Destroy a table:: flow table {port_id} destroy table {id} [...]
@@ -3021,6 +3030,10 @@ following sections. pattern {item} [/ {item} [...]] / end actions {action} [/ {action} [...]] / end +- Enqueue flow update following table resize:: + + flow queue {port_id} update_resized {table_id} rule {rule_id} + - Enqueue destruction of specific flow rules:: flow queue {port_id} destroy {queue_id}
lib/ethdev/ethdev_trace.h +33 -0
@@ -2572,6 +2572,39 @@ RTE_TRACE_POINT_FP(rte_trace_point_emit_ptr (user_data);rte_trace_point_emit_int (ret); ) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_template_table_resize, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, + uint32_t nb_rules, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_u32 (nb_rules); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_async_update_resized, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t queue, + const struct rte_flow_op_attr *attr, + struct rte_flow *rule, void *user_data, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_u32 (queue); +rte_trace_point_emit_ptr (attr); +rte_trace_point_emit_ptr (rule); +rte_trace_point_emit_ptr (user_data); +rte_trace_point_emit_int (ret); +) + +RTE_TRACE_POINT_FP ( + rte_flow_trace_table_resize_complete, + RTE_TRACE_POINT_ARGS(uint16_t port_id, + struct rte_flow_template_table *table, int ret), + rte_trace_point_emit_u16(port_id); +rte_trace_point_emit_ptr (table); +rte_trace_point_emit_int (ret); +) #ifdef __cplusplus }#endif
lib/ethdev/ethdev_trace_points.c +9 -0
@@ -777,3 +777,12 @@ RTE_TRACE_POINT_REGISTER(rte_flow_trace_async_action_list_handle_destroy,RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_action_list_handle_query_update, lib.ethdev.flow.async_action_list_handle_query_update) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_template_table_resize, + lib.ethdev.flow.template_table_resize) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_async_update_resized, + lib.ethdev.flow.async_update_resized) + +RTE_TRACE_POINT_REGISTER (rte_flow_trace_table_resize_complete, + lib.ethdev.flow.table_resize_complete)
lib/ethdev/rte_flow.c +77 -0
83 lines not on this page · raw message
lib/ethdev/rte_flow.h +118 -0
136 lines not on this page · raw message
lib/ethdev/rte_flow_driver.h +15 -0
@@ -257,6 +257,21 @@ struct rte_flow_ops { (struct rte_eth_dev *dev, const struct rte_flow_item pattern[], enum rte_flow_encap_hash_field dest_field, uint8_t *hash, struct rte_flow_error *error); +/** @see rte_flow_template_table_resize() */ +int (*flow_template_table_resize)(struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +uint32_t nb_rules, +struct rte_flow_error *error); +/** @see rte_flow_async_update_resized() */ +int (*flow_update_resized)(struct rte_eth_dev *dev,uint32_t queue, +const struct rte_flow_op_attr *attr, +struct rte_flow *rule,void *user_data, +struct rte_flow_error *error); +/** @see rte_flow_template_table_resize_complete() */ +int (*flow_template_table_resize_complete) + (struct rte_eth_dev *dev, +struct rte_flow_template_table *table, +struct rte_flow_error *error); };/**
lib/ethdev/version.map +4 -0
@@ -321,6 +321,10 @@ EXPERIMENTAL { __rte_eth_trace_tx_queue_count; rte_eth_find_rss_algo; rte_flow_calc_encap_hash; + rte_flow_async_update_resized; + rte_flow_template_table_resizable; + rte_flow_template_table_resize; + rte_flow_template_table_resize_complete; }; INTERNAL {
Signature · 1 line
2.39.2
Ferruh Yigit
AppliedQuoted 59 lines · Gregory Etelson
Template table creation API sets table flows capacity. If application needs more flows then the table was designed for, the following procedures must be completed:
1. Create a new template table with larger flows capacity.
2. Re-create existing flows in the new table and delete flows from the original table.
3. Destroy original table.Application cannot always execute that procedure:
* Port may not have sufficient resources to allocate a new table while maintaining original table.
* Application may not have existing flows "recipes" to re-create flows in a new table.The patch defines a new API that allows application to resize existing template table:
* Resizable template table must be created with the
RTE_FLOW_TABLE_SPECIALIZE_RESIZABLE_TABLEbit set.* Application resizes existing table with the
rte_flow_template_table_resize()function call.
The table resize procedure updates the table maximal flow number only. Other table attributes are not affected by the table resize. ** The table resize procedure must not interrupt
existing table flows operations in hardware.
** The table resize procedure must not alter flow handles held by
application.* After
rte_flow_template_table_resize()returned, application must update table flow rules by callingrte_flow_async_update_resized().
The call reconfigures internal flow resources for the new table configuration.
The flow update must not interrupt hardware flow operations.* After table flows were updated, application must call
rte_flow_template_table_resize_complete().
The function releases PMD resources related to the original table.
Application can start new table resize afterrte_flow_template_table_resize_complete()returned.Testpmd commands:
* Create resizable template table
flowtemplate_table<port-id> createtable_id<tbl-id> resizable \
[transfer|ingress|egres] group <group-id> \
rules_number<initial table capacity> \
pattern_template<pt1> [pattern_template<pt2> [ ... ]] \
actions_template<at1> [actions_template<at2> [ ... ]]* Resize table:
flowtemplate_table<tbl-id> resizetable_resize_id<tbl-id> \
table_resize_rules_num<new table capacity>* Queue a flow update:
flow queue <port-id>update_resized<tbl-id> rule <flow-id>
Quoted 8 lines
* Complete table resize:
flowtemplate_table<port-id>resize_completetable <tbl-id>Signed-off-by Gregory Etelson <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Ferruh Yigit <[email protected]>Acked-by Thomas Monjalon <[email protected]>
Applied to dpdk-next-net/main, thanks.