@@ -236,6 +236,7 @@ Chintu Hetam <rometoroam@gmail.com>
Choonho Son <choonho.son@gmail.com>
Chris Metcalf <cmetcalf@mellanox.com>
Christian Ehrhardt <christian.ehrhardt@canonical.com>
+Christian Koue Muf <ckm@napatech.com>
Christian Maciocco <christian.maciocco@intel.com>
Christophe Fontaine <cfontain@redhat.com>
Christophe Grosse <christophe.grosse@6wind.com>
@@ -992,6 +993,7 @@ Mukesh Dua <mukesh.dua81@gmail.com>
Murphy Yang <murphyx.yang@intel.com>
Murthy NSSR <nidadavolu.murthy@caviumnetworks.com>
Muthurajan Jayakumar <muthurajan.jayakumar@intel.com>
+Mykola Kostenok <mko-plv@napatech.com>
Nachiketa Prachanda <nprachan@brocade.com> <nprachan@vyatta.att-mail.com>
Nagadheeraj Rottela <rnagadheeraj@marvell.com>
Naga Harish K S V <s.v.naga.harish.k@intel.com>
@@ -1046,6 +1048,7 @@ Odi Assli <odia@nvidia.com>
Ognjen Joldzic <ognjen.joldzic@gmail.com>
Ola Liljedahl <ola.liljedahl@arm.com>
Oleg Polyakov <olegp123@walla.co.il>
+Oleksandr Kolomeiets <okl-plv@napatech.com>
Olga Shern <olgas@nvidia.com> <olgas@mellanox.com>
Olivier Gournet <ogournet@corp.free.fr>
Olivier Matz <olivier.matz@6wind.com>
@@ -851,6 +851,10 @@ static void cmd_help_long_parsed(void *parsed_result,
"flow destroy {port_id} rule {rule_id} [...]\n"
" Destroy specific flow rules.\n\n"
+ "flow update {port_id} {rule_id}"
+ " actions {action} [/ {action} [...]] / end [user_id]\n"
+ " Update a flow rule with new actions.\n\n"
+
"flow flush {port_id}\n"
" Destroy all flow rules.\n\n"
@@ -91,6 +91,7 @@ enum index {
VALIDATE,
CREATE,
DESTROY,
+ UPDATE,
FLUSH,
DUMP,
QUERY,
@@ -260,6 +261,7 @@ enum index {
VC_TUNNEL_SET,
VC_TUNNEL_MATCH,
VC_USER_ID,
+ VC_IS_USER_ID,
/* Dump arguments */
DUMP_ALL,
@@ -3200,6 +3202,7 @@ static const struct token token_list[] = {
VALIDATE,
CREATE,
DESTROY,
+ UPDATE,
FLUSH,
DUMP,
LIST,
@@ -4065,6 +4068,17 @@ static const struct token token_list[] = {
.args = ARGS(ARGS_ENTRY(struct buffer, port)),
.call = parse_destroy,
},
+ [UPDATE] = {
+ .name = "update",
+ .help = "update a flow rule with new actions",
+ .next = NEXT(NEXT_ENTRY(VC_IS_USER_ID, END),
+ NEXT_ENTRY(ACTIONS),
+ NEXT_ENTRY(COMMON_RULE_ID),
+ NEXT_ENTRY(COMMON_PORT_ID)),
+ .args = ARGS(ARGS_ENTRY(struct buffer, args.vc.rule_id),
+ ARGS_ENTRY(struct buffer, port)),
+ .call = parse_vc,
+ },
[FLUSH] = {
.name = "flush",
.help = "destroy all flow rules",
@@ -4311,6 +4325,11 @@ static const struct token token_list[] = {
.args = ARGS(ARGS_ENTRY(struct buffer, args.vc.user_id)),
.call = parse_vc,
},
+ [VC_IS_USER_ID] = {
+ .name = "user_id",
+ .help = "rule identifier is user-id",
+ .call = parse_vc,
+ },
/* Validate/create pattern. */
[ITEM_PATTERN] = {
.name = "pattern",
@@ -8450,8 +8469,13 @@ parse_vc(struct context *ctx, const struct token *token,
if (!out->command) {
if (ctx->curr != VALIDATE && ctx->curr != CREATE &&
ctx->curr != PATTERN_TEMPLATE_CREATE &&
- ctx->curr != ACTIONS_TEMPLATE_CREATE)
+ ctx->curr != ACTIONS_TEMPLATE_CREATE &&
+ ctx->curr != UPDATE)
return -1;
+ if (ctx->curr == UPDATE)
+ out->args.vc.pattern =
+ (void *)RTE_ALIGN_CEIL((uintptr_t)(out + 1),
+ sizeof(double));
if (sizeof(*out) > size)
return -1;
out->command = ctx->curr;
@@ -8523,6 +8547,9 @@ parse_vc(struct context *ctx, const struct token *token,
ctx->object = out->args.vc.actions;
ctx->objmask = NULL;
return len;
+ case VC_IS_USER_ID:
+ out->args.vc.user_id = true;
+ return len;
default:
if (!token->priv)
return -1;
@@ -13256,6 +13283,10 @@ cmd_flow_parsed(const struct buffer *in)
in->args.destroy.rule,
in->args.destroy.is_user_id);
break;
+ case UPDATE:
+ port_flow_update(in->port, in->args.vc.rule_id,
+ in->args.vc.actions, in->args.vc.user_id);
+ break;
case FLUSH:
port_flow_flush(in->port);
break;
@@ -3829,6 +3829,49 @@ port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule,
return ret;
}
+/** Update a flow rule with new actions. */
+int
+port_flow_update(portid_t port_id, uint32_t rule_id,
+ const struct rte_flow_action *actions, bool is_user_id)
+{
+ struct rte_port *port;
+ struct port_flow **flow_list;
+
+ if (port_id_is_invalid(port_id, ENABLED_WARN) ||
+ port_id == (portid_t)RTE_PORT_ALL)
+ return -EINVAL;
+ port = &ports[port_id];
+ flow_list = &port->flow_list;
+ while (*flow_list) {
+ struct port_flow *flow = *flow_list;
+ struct rte_flow_error error;
+
+ if (rule_id != (is_user_id ? flow->user_id : flow->id)) {
+ flow_list = &flow->next;
+ continue;
+ }
+ /*
+ * Poisoning to make sure PMDs update it in case
+ * of error.
+ */
+ memset(&error, 0x33, sizeof(error));
+ if (rte_flow_actions_update(port_id, flow->flow, actions,
+ &error))
+ return port_flow_complain(&error);
+ if (is_user_id)
+ printf("Flow rule #%"PRIu64" updated with new actions,"
+ " user-id 0x%"PRIx64"\n",
+ flow->id, flow->user_id);
+ else
+ printf("Flow rule #%"PRIu64
+ " updated with new actions\n",
+ flow->id);
+ return 0;
+ }
+ printf("Failed to find flow %"PRIu32"\n", rule_id);
+ return -EINVAL;
+}
+
/** Remove all flow rules. */
int
port_flow_flush(portid_t port_id)
@@ -1043,6 +1043,8 @@ void update_age_action_context(const struct rte_flow_action *actions,
int mcast_addr_pool_destroy(portid_t port_id);
int port_flow_destroy(portid_t port_id, uint32_t n, const uint64_t *rule,
bool is_user_id);
+int port_flow_update(portid_t port_id, uint32_t rule,
+ const struct rte_flow_action *actions, bool is_user_id);
int port_flow_flush(portid_t port_id);
int port_flow_dump(portid_t port_id, bool dump_all,
uint64_t rule, const char *file_name,
@@ -3057,6 +3057,11 @@ following sections.
flow destroy {port_id} rule {rule_id} [...] [user_id]
+- Update a flow rule with new actions::
+
+ flow update {port_id} {rule_id}
+ actions {action} [/ {action} [...]] / end [user_id]
+
- Destroy all flow rules::
flow flush {port_id}
@@ -4275,6 +4280,45 @@ Non-existent rule IDs are ignored::
Flow rule #0 destroyed
testpmd>
+Updating flow rules with new actions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``flow update`` updates a flow rule specified by a rule ID with a new action
+list by making a call to ``rte_flow_actions_update()``::
+
+ flow update {port_id} {rule_id}
+ actions {action} [/ {action} [...]] / end [user_id]
+
+If successful, it will show::
+
+ Flow rule #[...] updated with new actions
+
+Or if ``user_id`` flag is provided::
+
+ Flow rule #[...] updated with new actions, user-id [...]
+
+If a flow rule can not be found::
+
+ Failed to find flow [...]
+
+Otherwise it will show the usual error message of the form::
+
+ Caught error type [...] ([...]): [...]
+
+Optional ``user_id`` is a flag that signifies the rule ID is the one provided
+by the user at creation.
+
+Action list is identical to the one described for the ``flow create``.
+
+Creating, updating and destroying a flow rule::
+
+ testpmd> flow create 0 group 1 pattern eth / end actions drop / end
+ Flow rule #0 created
+ testpmd> flow update 0 0 actions queue index 1 / end
+ Flow rule #0 updated with new actions
+ testpmd> flow destroy 0 rule 0
+ Flow rule #0 destroyed
+
Enqueueing destruction of flow rules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~