app/testpmd: implement rte flow item/action template
PATCH 5/10 app/testpmd: implement rte flow item/action template
Add testpmd support for the rte_flow_item_template and rte_flow_action_template APIs. Provide the command line interface for the template creation/destruction. Usage example:
testpmd> flow item_template 0 create item_template_id 2
template eth dst is 00:16:3e:31:15:c3 / end
testpmd> flow action_template 0 create action_template_id 4
template drop / end mask drop / end
testpmd> flow action_template 0 destroy action_template 4 testpmd> flow item_template 0 destroy item_template 2
--- app/test-pmd/cmdline_flow.c | 376 +++++++++++++++++++- app/test-pmd/config.c | 204 +++++++++++ app/test-pmd/testpmd.h | 22 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 97 +++++ 4 files changed, 697 insertions(+), 2 deletions(-)
app/test-pmd/cmdline_flow.c +374 -2
@@ -56,6 +56,8 @@ enum index {COMMON_POLICY_ID ,COMMON_FLEX_HANDLE ,COMMON_FLEX_TOKEN , +COMMON_ITEM_TEMPLATE_ID , +COMMON_ACTION_TEMPLATE_ID ,/* TOP-level command. */ ADD,
@@ -73,6 +75,8 @@ enum index {FLOW ,/* Sub-level commands. */ CONFIGURE , +ITEM_TEMPLATE , +ACTION_TEMPLATE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -91,6 +95,22 @@ enum index {FLEX_ITEM_CREATE ,FLEX_ITEM_DESTROY , +/* Item template arguments. */ +ITEM_TEMPLATE_CREATE , +ITEM_TEMPLATE_DESTROY , +ITEM_TEMPLATE_CREATE_ID , +ITEM_TEMPLATE_DESTROY_ID , +ITEM_TEMPLATE_RELAXED_MATCHING , +ITEM_TEMPLATE_SPEC , + +/* Action template arguments. */ +ACTION_TEMPLATE_CREATE , +ACTION_TEMPLATE_DESTROY , +ACTION_TEMPLATE_CREATE_ID , +ACTION_TEMPLATE_DESTROY_ID , +ACTION_TEMPLATE_SPEC , +ACTION_TEMPLATE_MASK , +/* Tunnel arguments. */ TUNNEL_CREATE , TUNNEL_CREATE_TYPE,
@@ -858,6 +878,10 @@ struct buffer {struct rte_flow_port_attr port_attr;struct rte_flow_queue_attr queue_attr; } configure;/**< Configuration arguments. */ +struct { +uint32_t *template_id; +uint32_t template_id_n; + } templ_destroy;/**< Template destroy arguments. */ struct {uint32_t *action_id;uint32_t action_id_n;
@@ -866,10 +890,13 @@ struct buffer {uint32_t action_id; } ia;/* Indirect action query arguments */ struct { +uint32_t it_id; +uint32_t at_id;struct rte_flow_attr attr;struct tunnel_ops tunnel_ops;struct rte_flow_item *pattern;struct rte_flow_action *actions; +struct rte_flow_action *masks;uint32_t pattern_n;uint32_t actions_n;uint8_t *data;
@@ -949,6 +976,43 @@ static const enum index next_config_attr[] = { ZERO, }; +static const enum index next_it_subcmd[] = { +ITEM_TEMPLATE_CREATE , +ITEM_TEMPLATE_DESTROY , +ZERO , +}; + +static const enum index next_it_attr[] = { +ITEM_TEMPLATE_CREATE_ID , +ITEM_TEMPLATE_RELAXED_MATCHING , +ITEM_TEMPLATE_SPEC , +ZERO , +}; + +static const enum index next_it_destroy_attr[] = { +ITEM_TEMPLATE_DESTROY_ID , +END , +ZERO , +}; + +static const enum index next_at_subcmd[] = { +ACTION_TEMPLATE_CREATE , +ACTION_TEMPLATE_DESTROY , +ZERO , +}; + +static const enum index next_at_attr[] = { +ACTION_TEMPLATE_CREATE_ID , +ACTION_TEMPLATE_SPEC , +ZERO , +}; + +static const enum index next_at_destroy_attr[] = { +ACTION_TEMPLATE_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -1987,6 +2051,12 @@ static int parse_isolate(struct context *, const struct token *,static int parse_configure (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_template (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_template_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2056,6 +2126,10 @@ static int comp_set_modify_field_op(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_set_modify_field_id (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_item_template_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int ); +static int comp_action_template_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -2206,6 +2280,20 @@ static const struct token token_list[] = { .call = parse_flex_handle, .comp = comp_none, }, + [COMMON_ITEM_TEMPLATE_ID] = { + .name = "{item_template_id}", + .type = "ITEM_TEMPLATE_ID", + .help = "item template id", + .call = parse_int, + .comp = comp_item_template_id, + }, + [COMMON_ACTION_TEMPLATE_ID] = { + .name = "{action_template_id}", + .type = "ACTION_TEMPLATE_ID", + .help = "action template id", + .call = parse_int, + .comp = comp_action_template_id, + },/* Top-level command. */ [FLOW] = { .name = "flow",
@@ -2213,6 +2301,8 @@ static const struct token token_list[] = { .help = "manage ingress/egress flow rules", .next = NEXT(NEXT_ENTRY (CONFIGURE, + ITEM_TEMPLATE, + ACTION_TEMPLATE, INDIRECT_ACTION, VALIDATE, CREATE,
@@ -2278,6 +2368,112 @@ static const struct token token_list[] = { args.configure.port_attr.nb_meters)), },/* Top-level command. */ + [ITEM_TEMPLATE] = { + .name = "item_template", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage item templates", + .next = NEXT(next_it_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template, + }, +/* Sub-level commands. */ + [ITEM_TEMPLATE_CREATE] = { + .name = "create", + .help = "create item template", + .next = NEXT(next_it_attr), + .call = parse_template, + }, + [ITEM_TEMPLATE_DESTROY] = { + .name = "destroy", + .help = "destroy item template", + .next = NEXT(NEXT_ENTRY(ITEM_TEMPLATE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template_destroy, + }, +/* Item arguments. */ + [ITEM_TEMPLATE_CREATE_ID] = { + .name = "item_template_id", + .help = "specify a item template id to create", + .next =NEXT (next_it_attr, + NEXT_ENTRY(COMMON_ITEM_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.it_id)), + }, + [ITEM_TEMPLATE_DESTROY_ID] = { + .name = "item_template", + .help = "specify an item template id to destroy", + .next =NEXT (next_it_destroy_attr, + NEXT_ENTRY(COMMON_ITEM_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.templ_destroy.template_id)), + .call = parse_template_destroy, + }, + [ITEM_TEMPLATE_RELAXED_MATCHING] = { + .name = "relaxed", + .help = "is matching relaxed", + .next =NEXT (next_it_attr, + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY_BF(struct buffer, + args.vc.attr.reserved, 1)), + }, + [ITEM_TEMPLATE_SPEC] = { + .name = "template", + .help = "specify item to create item template", + .next = NEXT(next_item), + }, +/* Top-level command. */ + [ACTION_TEMPLATE] = { + .name = "action_template", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage action templates", + .next = NEXT(next_at_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template, + }, +/* Sub-level commands. */ + [ACTION_TEMPLATE_CREATE] = { + .name = "create", + .help = "create action template", + .next = NEXT(next_at_attr), + .call = parse_template, + }, + [ACTION_TEMPLATE_DESTROY] = { + .name = "destroy", + .help = "destroy action template", + .next = NEXT(NEXT_ENTRY(ACTION_TEMPLATE_DESTROY_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_template_destroy, + }, +/* Action arguments. */ + [ACTION_TEMPLATE_CREATE_ID] = { + .name = "action_template_id", + .help = "specify a action template id to create", + .next =NEXT (NEXT_ENTRY (ACTION_TEMPLATE_MASK ), +NEXT_ENTRY (ACTION_TEMPLATE_SPEC ), + NEXT_ENTRY(COMMON_ACTION_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.at_id)), + }, + [ACTION_TEMPLATE_DESTROY_ID] = { + .name = "action_template", + .help = "specify an action template id to destroy", + .next =NEXT (next_at_destroy_attr, + NEXT_ENTRY(COMMON_ACTION_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.templ_destroy.template_id)), + .call = parse_template_destroy, + }, + [ACTION_TEMPLATE_SPEC] = { + .name = "template", + .help = "specify action to create action template", + .next = NEXT(next_action), + .call = parse_template, + }, + [ACTION_TEMPLATE_MASK] = { + .name = "mask", + .help = "specify action mask to create action template", + .next = NEXT(next_action), + .call = parse_template, + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -2600,7 +2796,7 @@ static const struct token token_list[] = { .name = "end", .help = "end list of pattern items", .priv = PRIV_ITEM(END, 0), - .next = NEXT(NEXT_ENTRY(ACTIONS)), + .next = NEXT(NEXT_ENTRY(ACTIONS, END)), .call = parse_vc, }, [ITEM_VOID] = {
@@ -5704,7 +5900,9 @@ parse_vc(struct context *ctx, const struct token *token,if (!out)return len;if (!out->command) { -if (ctx->curr !=VALIDATE && ctx->curr !=CREATE ) +if (ctx->curr !=VALIDATE && ctx->curr !=CREATE && + ctx->curr !=ITEM_TEMPLATE_CREATE && + ctx->curr !=ACTION_TEMPLATE_CREATE )return -1 ;if (sizeof (*out) > size)return -1 ;
@@ -7568,6 +7766,114 @@ parse_configure(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for template create command. */ +static int +parse_template (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=ITEM_TEMPLATE && + ctx->curr !=ACTION_TEMPLATE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case ITEM_TEMPLATE_CREATE : + out->args.vc.pattern = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + out->args.vc.it_id =UINT32_MAX ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case ACTION_TEMPLATE_CREATE : + out->args.vc.at_id =UINT32_MAX ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case ACTION_TEMPLATE_SPEC : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + ctx->object = out->args.vc.actions; + ctx->objmask =NULL ; +return len; +case ACTION_TEMPLATE_MASK : + out->args.vc.masks = + (void *)RTE_ALIGN_CEIL ((uintptr_t ) + (out->args.vc.actions + + out->args.vc.actions_n), +sizeof (double )); + ctx->object = out->args.vc.masks; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + +/** Parse tokens for template destroy command. */ +static int +parse_template_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *template_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || + out->command ==ITEM_TEMPLATE || + out->command ==ACTION_TEMPLATE ) { +if (ctx->curr !=ITEM_TEMPLATE_DESTROY && + ctx->curr !=ACTION_TEMPLATE_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.templ_destroy.template_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + template_id = out->args.templ_destroy.template_id + + out->args.templ_destroy.template_id_n++; +if ((uint8_t *)template_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = template_id; + ctx->objmask =NULL ; +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -8535,6 +8841,54 @@ comp_set_modify_field_id(struct context *ctx, const struct token *token,return -1 ; } +/** Complete available item template IDs. */ +static int +comp_item_template_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; +struct port_template *pt; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (pt = port->item_templ_list; pt !=NULL ; pt = pt->next) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , pt->id); + ++i; + } +if (buf) +return -1 ; +return i; +} + +/** Complete available iaction template IDs. */ +static int +comp_action_template_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; +struct port_template *pt; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (pt = port->action_templ_list; pt !=NULL ; pt = pt->next) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , pt->id); + ++i; + } +if (buf) +return -1 ; +return i; +} +/** Internal context. */ static struct context cmd_flow_context;
@@ -8798,6 +9152,24 @@ cmd_flow_parsed(const struct buffer *in)port_flow_configure (in->port, &in->args.configure.port_attr, &in->args.configure.queue_attr);break ; +case ITEM_TEMPLATE_CREATE : +port_flow_item_template_create (in->port, in->args.vc.it_id, + in->args.vc.attr.reserved, in->args.vc.pattern); +break ; +case ITEM_TEMPLATE_DESTROY : +port_flow_item_template_destroy (in->port, + in->args.templ_destroy.template_id_n, + in->args.templ_destroy.template_id); +break ; +case ACTION_TEMPLATE_CREATE : +port_flow_action_template_create (in->port, in->args.vc.at_id, + in->args.vc.actions, in->args.vc.masks); +break ; +case ACTION_TEMPLATE_DESTROY : +port_flow_action_template_destroy (in->port, + in->args.templ_destroy.template_id_n, + in->args.templ_destroy.template_id); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +204 -0
216 lines not on this page · raw message
app/test-pmd/testpmd.h +22 -0
@@ -166,6 +166,17 @@ enum age_action_context_type { ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION, }; +/** Descriptor for a template. */ +struct port_template { +struct port_template *next;/**< Next template in list. */ +struct port_template *tmp;/**< Temporary linking. */ +uint32_t id;/**< Template ID. */ +union { +struct rte_flow_item_template *itempl; +struct rte_flow_action_template *atempl; + } template;/**< PMD opaque template object */ +}; +/** Descriptor for a single flow. */ struct port_flow {struct port_flow *next;/**< Next flow in list. */
@@ -246,6 +257,8 @@ struct rte_port {queueid_t queue_nb;/**< nb. of queues for flow rules */ uint32_t queue_sz;/**< size of a queue for flow rules */ uint8_t slave_flag;/**< bonding slave port */ +struct port_template *item_templ_list;/**< Item templates. */ +struct port_template *action_templ_list;/**< Action templates. */ struct port_flow *flow_list;/**< Associated flows. */ struct port_indirect_action *actions_list;/**< Associated indirect actions. */
@@ -890,6 +903,15 @@ int port_action_handle_update(portid_t port_id, uint32_t id,int port_flow_configure (portid_t port_id,const struct rte_flow_port_attr *port_attr,const struct rte_flow_queue_attr *queue_attr); +int port_flow_item_template_create (portid_t port_id,uint32_t id,bool relaxed, +const struct rte_flow_item *pattern); +int port_flow_item_template_destroy (portid_t port_id,uint32_t n, +const uint32_t *template); +int port_flow_action_template_create (portid_t port_id,uint32_t id, +const struct rte_flow_action *actions, +const struct rte_flow_action *masks); +int port_flow_action_template_destroy (portid_t port_id,uint32_t n, +const uint32_t *template); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +97 -0
109 lines not on this page · raw message
Signature · 1 line
2.18.2
PATCH 6/10 app/testpmd: implement rte flow table
Add testpmd support for the rte_flow_table API. Provide the command line interface for the flow table creation/destruction. Usage example:
testpmd> flow table 0 create table_id 6
group 9 priority 4 ingress mode 1 rules_number 64 item_template 2 action_template 4
testpmd> flow table 0 destroy table 6
--- app/test-pmd/cmdline_flow.c | 315 ++++++++++++++++++++ app/test-pmd/config.c | 168 +++++++++++ app/test-pmd/testpmd.h | 15 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 53 ++++ 4 files changed, 551 insertions(+)
app/test-pmd/cmdline_flow.c +315 -0
@@ -58,6 +58,7 @@ enum index {COMMON_FLEX_TOKEN ,COMMON_ITEM_TEMPLATE_ID ,COMMON_ACTION_TEMPLATE_ID , +COMMON_TABLE_ID ,/* TOP-level command. */ ADD,
@@ -77,6 +78,7 @@ enum index {CONFIGURE ,ITEM_TEMPLATE ,ACTION_TEMPLATE , +TABLE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -111,6 +113,20 @@ enum index {ACTION_TEMPLATE_SPEC ,ACTION_TEMPLATE_MASK , +/* Table arguments. */ +TABLE_CREATE , +TABLE_DESTROY , +TABLE_CREATE_ID , +TABLE_DESTROY_ID , +TABLE_GROUP , +TABLE_PRIORITY , +TABLE_INGRESS , +TABLE_EGRESS , +TABLE_TRANSFER , +TABLE_RULES_NUMBER , +TABLE_ITEM_TEMPLATE , +TABLE_ACTION_TEMPLATE , +/* Tunnel arguments. */ TUNNEL_CREATE , TUNNEL_CREATE_TYPE,
@@ -882,6 +898,18 @@ struct buffer {uint32_t *template_id;uint32_t template_id_n; } templ_destroy;/**< Template destroy arguments. */ +struct { +uint32_t id; +struct rte_flow_table_attr attr; +uint32_t *item_id; +uint32_t item_id_n; +uint32_t *action_id; +uint32_t action_id_n; + } table;/**< Table arguments. */ +struct { +uint32_t *table_id; +uint32_t table_id_n; + } table_destroy;/**< Template destroy arguments. */ struct {uint32_t *action_id;uint32_t action_id_n;
@@ -1013,6 +1041,32 @@ static const enum index next_at_destroy_attr[] = { ZERO, }; +static const enum index next_table_subcmd[] = { +TABLE_CREATE , +TABLE_DESTROY , +ZERO , +}; + +static const enum index next_table_attr[] = { +TABLE_CREATE_ID , +TABLE_GROUP , +TABLE_PRIORITY , +TABLE_INGRESS , +TABLE_EGRESS , +TABLE_TRANSFER , +TABLE_RULES_NUMBER , +TABLE_ITEM_TEMPLATE , +TABLE_ACTION_TEMPLATE , +END , +ZERO , +}; + +static const enum index next_table_destroy_attr[] = { +TABLE_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -2057,6 +2111,11 @@ static int parse_template(struct context *, const struct token *,static int parse_template_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_table (struct context *,const struct token *, +const char *,unsigned int ,void *,unsigned int ); +static int parse_table_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2130,6 +2189,8 @@ static int comp_item_template_id(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_action_template_id (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_table_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -2294,6 +2355,13 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_action_template_id, }, + [COMMON_TABLE_ID] = { + .name = "{table_id}", + .type = "TABLE_ID", + .help = "table id", + .call = parse_int, + .comp = comp_table_id, + },/* Top-level command. */ [FLOW] = { .name = "flow",
@@ -2303,6 +2371,7 @@ static const struct token token_list[] = { (CONFIGURE ,ITEM_TEMPLATE ,ACTION_TEMPLATE , +TABLE ,INDIRECT_ACTION ,VALIDATE , CREATE,
@@ -2474,6 +2543,104 @@ static const struct token token_list[] = { .call = parse_template, },/* Top-level command. */ + [TABLE] = { + .name = "table", + .type = "{command} {port_id} [{arg} [...]]", + .help = "manage tables", + .next = NEXT(next_table_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_table, + }, +/* Sub-level commands. */ + [TABLE_CREATE] = { + .name = "create", + .help = "create table", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_DESTROY] = { + .name = "destroy", + .help = "destroy table", + .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", + .help = "specify table id to create", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, args.table.id)), + }, + [TABLE_DESTROY_ID] = { + .name = "table", + .help = "specify table id to destroy", + .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_GROUP] = { + .name = "group", + .help = "specify a group", + .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_GROUP_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.flow_attr.group)), + }, + [TABLE_PRIORITY] = { + .name = "priority", + .help = "specify a priority level", + .next = NEXT(next_table_attr, NEXT_ENTRY(COMMON_PRIORITY_LEVEL)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.flow_attr.priority)), + }, + [TABLE_EGRESS] = { + .name = "egress", + .help = "affect rule to egress", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_INGRESS] = { + .name = "ingress", + .help = "affect rule to ingress", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_TRANSFER] = { + .name = "transfer", + .help = "affect rule to transfer", + .next = NEXT(next_table_attr), + .call = parse_table, + }, + [TABLE_RULES_NUMBER] = { + .name = "rules_number", + .help = "number of rules in table", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.table.attr.nb_flows)), + }, + [TABLE_ITEM_TEMPLATE] = { + .name = "item_template", + .help = "specify item template id", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_ITEM_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.table.item_id)), + .call = parse_table, + }, + [TABLE_ACTION_TEMPLATE] = { + .name = "action_template", + .help = "specify action template id", + .next =NEXT (next_table_attr, + NEXT_ENTRY(COMMON_ACTION_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.table.action_id)), + .call = parse_table, + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -7874,6 +8041,119 @@ parse_template_destroy(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for indirect action commands. */ +static int +parse_table (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *template_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=TABLE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; + } +switch (ctx->curr) { +case TABLE_CREATE : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.table.id =UINT32_MAX ; +return len; +case TABLE_ITEM_TEMPLATE : + out->args.table.item_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + template_id = out->args.table.item_id + + out->args.table.item_id_n++; +if ((uint8_t *)template_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = template_id; + ctx->objmask =NULL ; +return len; +case TABLE_ACTION_TEMPLATE : + out->args.table.action_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t ) + (out->args.table.item_id + + out->args.table.item_id_n), +sizeof (double )); + template_id = out->args.table.action_id + + out->args.table.action_id_n++; +if ((uint8_t *)template_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = template_id; + ctx->objmask =NULL ; +return len; +case TABLE_INGRESS : + out->args.table.attr.flow_attr.ingress =1 ; +return len; +case TABLE_EGRESS : + out->args.table.attr.flow_attr.egress =1 ; +return len; +case TABLE_TRANSFER : + out->args.table.attr.flow_attr.transfer =1 ; +return len; +default : +return -1 ; + } +} + +/** Parse tokens for indirect action destroy command. */ +static int +parse_table_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *table_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==TABLE ) { +if (ctx->curr !=TABLE_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.table_destroy.table_id = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } + table_id = out->args.table_destroy.table_id + + out->args.table_destroy.table_id_n++; +if ((uint8_t *)table_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = table_id; + ctx->objmask =NULL ; +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -8889,6 +9169,30 @@ comp_action_template_id(struct context *ctx, const struct token *token,return i; } +/** Complete available table IDs. */ +static int +comp_table_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; +struct port_table *pt; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (pt = port->table_list; pt !=NULL ; pt = pt->next) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , pt->id); + ++i; + } +if (buf) +return -1 ; +return i; +} +/** Internal context. */ static struct context cmd_flow_context;
@@ -9170,6 +9474,17 @@ cmd_flow_parsed(const struct buffer *in) in->args.templ_destroy.template_id_n, in->args.templ_destroy.template_id);break ; +case TABLE_CREATE : +port_flow_table_create (in->port, in->args.table.id, + &in->args.table.attr, in->args.table.item_id_n, + in->args.table.item_id, in->args.table.action_id_n, + in->args.table.action_id); +break ; +case TABLE_DESTROY : +port_flow_table_destroy (in->port, + in->args.table_destroy.table_id_n, + in->args.table_destroy.table_id); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +168 -0
180 lines not on this page · raw message
app/test-pmd/testpmd.h +15 -0
@@ -177,6 +177,14 @@ struct port_template { } template;/**< PMD opaque template object */ }; +/** Descriptor for a flow table. */ +struct port_table { +struct port_table *next;/**< Next table in list. */ +struct port_table *tmp;/**< Temporary linking. */ +uint32_t id;/**< Table ID. */ +struct rte_flow_table *table;/**< PMD opaque template object */ +}; +/** Descriptor for a single flow. */ struct port_flow {struct port_flow *next;/**< Next flow in list. */
@@ -259,6 +267,7 @@ struct rte_port {uint8_t slave_flag;/**< bonding slave port */ struct port_template *item_templ_list;/**< Item templates. */ struct port_template *action_templ_list;/**< Action templates. */ +struct port_table *table_list;/**< Flow tables. */ struct port_flow *flow_list;/**< Associated flows. */ struct port_indirect_action *actions_list;/**< Associated indirect actions. */
@@ -912,6 +921,12 @@ int port_flow_action_template_create(portid_t port_id, uint32_t id, const struct rte_flow_action *masks);int port_flow_action_template_destroy (portid_t port_id,uint32_t n,const uint32_t *template); +int port_flow_table_create (portid_t port_id,uint32_t id, +const struct rte_flow_table_attr *table_attr, +uint32_t nb_item_templates,uint32_t *item_templates, +uint32_t nb_action_templates,uint32_t *action_templates); +int port_flow_table_destroy (portid_t port_id, +uint32_t n,const uint32_t *table); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +53 -0
65 lines not on this page · raw message
Signature · 1 line
2.18.2
PATCH 8/10 app/testpmd: implement rte flow queue drain
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_drain API. Provide the command line interface for the queue draining. Usage example: flow queue 0 drain 0
--- app/test-pmd/cmdline_flow.c | 56 ++++++++++++++++++++- app/test-pmd/config.c | 28 +++++++++++ app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 21 ++++++++ 4 files changed, 105 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +55 -1
@@ -93,6 +93,7 @@ enum index {TUNNEL ,FLEX ,QUEUE , +DRAIN ,/* Flex arguments */ FLEX_ITEM_INIT,
@@ -131,6 +132,9 @@ enum index {QUEUE_DESTROY_ID ,QUEUE_DESTROY_DRAIN , +/* Drain arguments. */ +DRAIN_QUEUE , +/* Table arguments. */ TABLE_CREATE , TABLE_DESTROY,
@@ -2155,6 +2159,9 @@ static int parse_qo(struct context *, const struct token *,static int parse_qo_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_drain (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2432,7 +2439,8 @@ static const struct token token_list[] = { ISOLATE,TUNNEL ,FLEX , - QUEUE)), +QUEUE , + DRAIN)), .call = parse_init, },/* Top-level command. */
@@ -2767,6 +2775,21 @@ static const struct token token_list[] = { .call = parse_qo_destroy, },/* Top-level command. */ + [DRAIN] = { + .name = "drain", + .help = "drain a flow queue", + .next = NEXT(NEXT_ENTRY(DRAIN_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_drain, + }, +/* Sub-level commands. */ + [DRAIN_QUEUE] = { + .name = "queue", + .help = "specify queue id", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -8385,6 +8408,34 @@ parse_qo_destroy(struct context *ctx, const struct token *token, } } +/** Parse tokens for drain queue command. */ +static int +parse_drain (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=DRAIN ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; + } +return len; +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -9749,6 +9800,9 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case DRAIN : +port_queue_flow_drain (in->port, in->queue); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +28 -0
@@ -2564,6 +2564,34 @@ port_queue_flow_destroy(portid_t port_id, queueid_t queue_id,return ret; } +/** Drain all the queue operations down the queue. */ +int +port_queue_flow_drain (portid_t port_id,queueid_t queue_id) +{ +struct rte_port *port; +struct rte_flow_error error; +int ret =0 ; + +if (port_id_is_invalid (port_id,ENABLED_WARN ) || + port_id == (portid_t )RTE_PORT_ALL ) +return -EINVAL ; + port = &ports[port_id]; + +if (queue_id >= port->queue_nb) { +printf ("Queue #%u is invalid\n" , queue_id); +return -EINVAL ; + } + +memset (&error,0x55 ,sizeof (error)); + ret =rte_flow_q_drain (port_id, queue_id, &error); +if (ret <0 ) { +printf ("Failed to drain queue\n" ); +return -EINVAL ; + } +printf ("Queue #%u drained\n" , queue_id); +return ret; +} +/** Create flow rule. */ int port_flow_create(portid_t port_id,
app/test-pmd/testpmd.h +1 -0
@@ -934,6 +934,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id, const struct rte_flow_action *actions);int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id,bool drain,uint32_t n,const uint32_t *rule); +int port_queue_flow_drain (portid_t port_id,queueid_t queue_id); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +21 -0
@@ -3368,6 +3368,10 @@ following sections. flow queue {port_id} destroy {queue_id} [drain {boolean}] rule {rule_id} [...] +- Drain a queue:: + + flow drain {port_id} queue {queue_id} + - Create a flow rule:: flow create {port_id}
@@ -3561,6 +3565,23 @@ The usual error message is shown when a table cannot be destroyed:: Caught error type [...] ([...]): [...] +Draining a flow queue +~~~~~~~~~~~~~~~~~~~~~ + +``flow drain`` drains the specific queue to push all the +outstanding queued operations to the underlying device immediately. +It is bound to ``rte_flow_q_drain()``:: + + flow drain {port_id} queue {queue_id} + +If successful, it will show:: + + Queue #[...] drained + +The usual error message is shown when a queue cannot be drained:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.18.2
PATCH 7/10 app/testpmd: implement rte flow queue create flow
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_create/rte_flow_q_destroy API. Provide the command line interface for enqueueing flow creation/destruction operations. Usage example:
testpmd> flow queue 0 create 0 drain yes table 6
item_template 0 action_template 0
pattern eth dst is 00:16:3e:31:15:c3 / end actions drop / end
testpmd> flow queue 0 destroy 0 drain yes rule 0
--- app/test-pmd/cmdline_flow.c | 266 +++++++++++++++++++- app/test-pmd/config.c | 153 +++++++++++ app/test-pmd/testpmd.h | 7 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 55 ++++ 4 files changed, 480 insertions(+), 1 deletion(-)
app/test-pmd/cmdline_flow.c +265 -1
@@ -59,6 +59,7 @@ enum index {COMMON_ITEM_TEMPLATE_ID ,COMMON_ACTION_TEMPLATE_ID ,COMMON_TABLE_ID , +COMMON_QUEUE_ID ,/* TOP-level command. */ ADD,
@@ -91,6 +92,7 @@ enum index {ISOLATE ,TUNNEL ,FLEX , +QUEUE ,/* Flex arguments */ FLEX_ITEM_INIT,
@@ -113,6 +115,22 @@ enum index {ACTION_TEMPLATE_SPEC ,ACTION_TEMPLATE_MASK , +/* Queue arguments. */ +QUEUE_CREATE , +QUEUE_DESTROY , + +/* Queue create arguments. */ +QUEUE_CREATE_ID , +QUEUE_CREATE_DRAIN , +QUEUE_TABLE , +QUEUE_ITEM_TEMPLATE , +QUEUE_ACTION_TEMPLATE , +QUEUE_SPEC , + +/* Queue destroy arguments. */ +QUEUE_DESTROY_ID , +QUEUE_DESTROY_DRAIN , +/* Table arguments. */ TABLE_CREATE , TABLE_DESTROY,
@@ -889,6 +907,8 @@ struct token { struct buffer { enum index command; /**< Flow command. */ portid_t port; /**< Affected port ID. */ + queueid_t queue; /** Async queue ID. */ + bool drain; /** Drain the queue on async oparation */ union { struct { struct rte_flow_port_attr port_attr;
@@ -918,6 +938,7 @@ struct buffer {uint32_t action_id; } ia;/* Indirect action query arguments */ struct { +uint32_t table_id;uint32_t it_id;uint32_t at_id;struct rte_flow_attr attr;
@@ -1067,6 +1088,18 @@ static const enum index next_table_destroy_attr[] = { ZERO, }; +static const enum index next_queue_subcmd[] = { +QUEUE_CREATE , +QUEUE_DESTROY , +ZERO , +}; + +static const enum index next_queue_destroy_attr[] = { +QUEUE_DESTROY_ID , +END , +ZERO , +}; +static const enum index next_ia_create_attr[] = {INDIRECT_ACTION_CREATE_ID ,INDIRECT_ACTION_INGRESS ,
@@ -2116,6 +2149,12 @@ static int parse_table(struct context *, const struct token *,static int parse_table_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_qo (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int ); +static int parse_qo_destroy (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_tunnel (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2191,6 +2230,8 @@ static int comp_action_template_id(struct context *, const struct token *, unsigned int, char *, unsigned int);static int comp_table_id (struct context *,const struct token *,unsigned int ,char *,unsigned int ); +static int comp_queue_id (struct context *,const struct token *, +unsigned int ,char *,unsigned int );/** Token definitions. */ static const struct token token_list[] = {
@@ -2362,6 +2403,13 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_table_id, }, + [COMMON_QUEUE_ID] = { + .name = "{queue_id}", + .type = "QUEUE_ID", + .help = "queue id", + .call = parse_int, + .comp = comp_queue_id, + },/* Top-level command. */ [FLOW] = { .name = "flow",
@@ -2383,7 +2431,8 @@ static const struct token token_list[] = { QUERY,ISOLATE ,TUNNEL , - FLEX)), +FLEX , + QUEUE)), .call = parse_init, },/* Top-level command. */
@@ -2641,6 +2690,83 @@ static const struct token token_list[] = { .call = parse_table, },/* Top-level command. */ + [QUEUE] = { + .name = "queue", + .help = "queue a flow rule operation", + .next = NEXT(next_queue_subcmd, NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_qo, + }, +/* Sub-level commands. */ + [QUEUE_CREATE] = { + .name = "create", + .help = "create a flow rule", + .next = NEXT(NEXT_ENTRY(QUEUE_TABLE), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo, + }, + [QUEUE_DESTROY] = { + .name = "destroy", + .help = "destroy a flow rule", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + .call = parse_qo_destroy, + }, +/* Queue arguments. */ + [QUEUE_TABLE] = { + .name = "table", + .help = "specify table id", + .next =NEXT (NEXT_ENTRY (QUEUE_ITEM_TEMPLATE ), + NEXT_ENTRY(COMMON_TABLE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.table_id)), + .call = parse_qo, + }, + [QUEUE_ITEM_TEMPLATE] = { + .name = "item_template", + .help = "specify item template id", + .next =NEXT (NEXT_ENTRY (QUEUE_ACTION_TEMPLATE ), + NEXT_ENTRY(COMMON_ITEM_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.it_id)), + .call = parse_qo, + }, + [QUEUE_ACTION_TEMPLATE] = { + .name = "action_template", + .help = "specify action template id", + .next =NEXT (NEXT_ENTRY (QUEUE_CREATE_DRAIN ), + NEXT_ENTRY(COMMON_ACTION_TEMPLATE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, + args.vc.at_id)), + .call = parse_qo, + }, + [QUEUE_CREATE_DRAIN] = { + .name = "drain", + .help = "drain queue immediately", + .next =NEXT (NEXT_ENTRY (ITEM_PATTERN ), + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY(struct buffer, drain)), + .call = parse_qo, + }, + [QUEUE_DESTROY_DRAIN] = { + .name = "drain", + .help = "drain queue immediately", + .next =NEXT (NEXT_ENTRY (QUEUE_DESTROY_ID ), + NEXT_ENTRY(COMMON_BOOLEAN)), + .args = ARGS(ARGS_ENTRY(struct buffer, drain)), + .call = parse_qo_destroy, + }, + [QUEUE_DESTROY_ID] = { + .name = "rule", + .help = "specify rule id to destroy", + .next =NEXT (next_queue_destroy_attr, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY_PTR(struct buffer, + args.destroy.rule)), + .call = parse_qo_destroy, + }, +/* Top-level command. */ [INDIRECT_ACTION] = { .name = "indirect_action", .type = "{command} {port_id} [{arg} [...]]",
@@ -8154,6 +8280,111 @@ parse_table_destroy(struct context *ctx, const struct token *token,return len; } +/** Parse tokens for queue create commands. */ +static int +parse_qo (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=QUEUE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; +return len; + } +switch (ctx->curr) { +case QUEUE_CREATE : + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; +return len; +case QUEUE_TABLE : +case QUEUE_ITEM_TEMPLATE : +case QUEUE_ACTION_TEMPLATE : +case QUEUE_CREATE_DRAIN : +return len; +case ITEM_PATTERN : + out->args.vc.pattern = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); + ctx->object = out->args.vc.pattern; + ctx->objmask =NULL ; +return len; +case ACTIONS : + out->args.vc.actions = + (void *)RTE_ALIGN_CEIL ((uintptr_t ) + (out->args.vc.pattern + + out->args.vc.pattern_n), +sizeof (double )); + ctx->object = out->args.vc.actions; + ctx->objmask =NULL ; +return len; +default : +return -1 ; + } +} + +/** Parse tokens for queue destroy command. */ +static int +parse_qo_destroy (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; +uint32_t *flow_id; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command || out->command ==QUEUE ) { +if (ctx->curr !=QUEUE_DESTROY ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.destroy.rule = + (void *)RTE_ALIGN_CEIL ((uintptr_t )(out +1 ), +sizeof (double )); +return len; + } +switch (ctx->curr) { +case QUEUE_DESTROY_ID : + flow_id = out->args.destroy.rule + + out->args.destroy.rule_n++; +if ((uint8_t *)flow_id > (uint8_t *)out + size) +return -1 ; + ctx->objdata =0 ; + ctx->object = flow_id; + ctx->objmask =NULL ; +return len; +case QUEUE_DESTROY_DRAIN : +return len; +default : +return -1 ; + } +} + static int parse_flex(struct context *ctx, const struct token *token, const char *str, unsigned int len,
@@ -9193,6 +9424,28 @@ comp_table_id(struct context *ctx, const struct token *token,return i; } +/** Complete available queue IDs. */ +static int +comp_queue_id (struct context *ctx,const struct token *token, +unsigned int ent,char *buf,unsigned int size) +{ +unsigned int i =0 ; +struct rte_port *port; + + (void )token; +if (port_id_is_invalid (ctx->port,DISABLED_WARN ) || + ctx->port == (portid_t )RTE_PORT_ALL ) +return -1 ; + port = &ports[ctx->port]; +for (i =0 ; i < port->queue_nb; i++) { +if (buf && i == ent) +return snprintf (buf, size,"%u" , i); + } +if (buf) +return -1 ; +return i; +} +/** Internal context. */ static struct context cmd_flow_context;
@@ -9485,6 +9738,17 @@ cmd_flow_parsed(const struct buffer *in) in->args.table_destroy.table_id_n, in->args.table_destroy.table_id);break ; +case QUEUE_CREATE : +port_queue_flow_create (in->port, in->queue, in->drain, + in->args.vc.table_id, in->args.vc.it_id, + in->args.vc.at_id, in->args.vc.pattern, + in->args.vc.actions); +break ; +case QUEUE_DESTROY : +port_queue_flow_destroy (in->port, in->queue, in->drain, + in->args.destroy.rule_n, + in->args.destroy.rule); +break ;case INDIRECT_ACTION_CREATE : port_action_handle_create( in->port, in->args.vc.attr.group,
app/test-pmd/config.c +153 -0
159 lines not on this page · raw message
app/test-pmd/testpmd.h +7 -0
@@ -927,6 +927,13 @@ int port_flow_table_create(portid_t port_id, uint32_t id, uint32_t nb_action_templates, uint32_t *action_templates);int port_flow_table_destroy (portid_t port_id,uint32_t n,const uint32_t *table); +int port_queue_flow_create (portid_t port_id,queueid_t queue_id, +bool drain,uint32_t table_id, +uint32_t item_id,uint32_t action_id, +const struct rte_flow_item *pattern, +const struct rte_flow_action *actions); +int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id, +bool drain,uint32_t n,const uint32_t *rule); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +55 -0
73 lines not on this page · raw message
Signature · 1 line
2.18.2
PATCH 9/10 app/testpmd: implement rte flow queue dequeue
In reply to Alexander KozyrevAdd testpmd support for the rte_flow_q_dequeue API. Provide the command line interface for operations dequeue. Usage example: flow dequeue 0 queue 0
--- app/test-pmd/cmdline_flow.c | 54 +++++++++++++++ app/test-pmd/config.c | 74 +++++++++++++-------- app/test-pmd/testpmd.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 25 +++++++ 4 files changed, 126 insertions(+), 28 deletions(-)
app/test-pmd/cmdline_flow.c +54 -0
@@ -93,6 +93,7 @@ enum index {TUNNEL ,FLEX ,QUEUE , +DEQUEUE , DRAIN,/* Flex arguments */
@@ -132,6 +133,9 @@ enum index {QUEUE_DESTROY_ID ,QUEUE_DESTROY_DRAIN , +/* Dequeue arguments. */ +DEQUEUE_QUEUE , +/* Drain arguments. */ DRAIN_QUEUE,
@@ -2159,6 +2163,9 @@ static int parse_qo(struct context *, const struct token *,static int parse_qo_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int ); +static int parse_dequeue (struct context *,const struct token *, +const char *,unsigned int , +void *,unsigned int );static int parse_drain (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );
@@ -2440,6 +2447,7 @@ static const struct token token_list[] = { TUNNEL,FLEX ,QUEUE , +DEQUEUE , DRAIN)), .call = parse_init, },
@@ -2775,6 +2783,21 @@ static const struct token token_list[] = { .call = parse_qo_destroy, },/* Top-level command. */ + [DEQUEUE] = { + .name = "dequeue", + .help = "dequeue flow operations", + .next = NEXT(NEXT_ENTRY(DEQUEUE_QUEUE), NEXT_ENTRY(COMMON_PORT_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, port)), + .call = parse_dequeue, + }, +/* Sub-level commands. */ + [DEQUEUE_QUEUE] = { + .name = "queue", + .help = "specify queue id", + .next = NEXT(NEXT_ENTRY(END), NEXT_ENTRY(COMMON_QUEUE_ID)), + .args = ARGS(ARGS_ENTRY(struct buffer, queue)), + }, +/* Top-level command. */ [DRAIN] = { .name = "drain", .help = "drain a flow queue",
@@ -8408,6 +8431,34 @@ parse_qo_destroy(struct context *ctx, const struct token *token, } } +/** Parse tokens for dequeue command. */ +static int +parse_dequeue (struct context *ctx,const struct token *token, +const char *str,unsigned int len, +void *buf,unsigned int size) +{ +struct buffer *out = buf; + +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (!out->command) { +if (ctx->curr !=DEQUEUE ) +return -1 ; +if (sizeof (*out) > size) +return -1 ; + out->command = ctx->curr; + ctx->objdata =0 ; + ctx->object = out; + ctx->objmask =NULL ; + out->args.vc.data = (uint8_t *)out + size; + } +return len; +} +/** Parse tokens for drain queue command. */ static int parse_drain(struct context *ctx, const struct token *token,
@@ -9800,6 +9851,9 @@ cmd_flow_parsed(const struct buffer *in) in->args.destroy.rule_n, in->args.destroy.rule);break ; +case DEQUEUE : +port_queue_flow_dequeue (in->port, in->queue); +break ;case DRAIN :port_queue_flow_drain (in->port, in->queue);break ;
app/test-pmd/config.c +46 -28
110 lines not on this page · raw message
app/test-pmd/testpmd.h +1 -0
@@ -935,6 +935,7 @@ int port_queue_flow_create(portid_t port_id, queueid_t queue_id,int port_queue_flow_destroy (portid_t port_id,queueid_t queue_id,bool drain,uint32_t n,const uint32_t *rule);int port_queue_flow_drain (portid_t port_id,queueid_t queue_id); +int port_queue_flow_dequeue (portid_t port_id,queueid_t queue_id); int port_flow_validate(portid_t port_id, const struct rte_flow_attr *attr, const struct rte_flow_item *pattern,
doc/guides/testpmd_app_ug/testpmd_funcs.rst +25 -0
@@ -3372,6 +3372,10 @@ following sections. flow drain {port_id} queue {queue_id} +- Dequeue all operations from a queue:: + + flow dequeue {port_id} queue {queue_id} + - Create a flow rule:: flow create {port_id}
@@ -3582,6 +3586,23 @@ The usual error message is shown when a queue cannot be drained:: Caught error type [...] ([...]): [...] +Dequeueing flow operations +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``flow dequeue`` asks the underlying device about flow queue operations +results and return all the processed (successfully or not) operations. +It is bound to ``rte_flow_q_dequeue()``:: + + flow dequeue {port_id} queue {queue_id} + +If successful, it will show:: + + Queue #[...] dequeued #[...] operations (#[...] failed, #[...] succeeded) + +The usual error message is shown when a queue cannot be drained:: + + Caught error type [...] ([...]): [...] + Creating a tunnel stub for offload ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -3711,6 +3732,8 @@ Otherwise it will show an error message of the form:: This command uses the same pattern items and actions as ``flow create``, their format is described in `Creating flow rules`_. +``flow queue dequeue`` must be called to retrieve the operation status. + Attributes ^^^^^^^^^^
@@ -4444,6 +4467,8 @@ message is shown when a rule cannot be destroyed:: Caught error type [...] ([...]): [...] +``flow queue dequeue`` must be called to retrieve the operation status. + Querying flow rules ~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.18.2