From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 01EED7CBE for ; Thu, 26 Apr 2018 14:16:31 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2018 05:16:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,330,1520924400"; d="scan'208";a="37213394" Received: from dwdohert-ws.ir.intel.com ([163.33.210.60]) by orsmga006.jf.intel.com with ESMTP; 26 Apr 2018 05:16:29 -0700 From: Declan Doherty To: dev@dpdk.org Cc: Ferruh Yigit , Declan Doherty Date: Thu, 26 Apr 2018 13:08:15 +0100 Message-Id: <20180426120817.6612-3-declan.doherty@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180426120817.6612-1-declan.doherty@intel.com> References: <20180426120817.6612-1-declan.doherty@intel.com> Subject: [dpdk-dev] [PATCH v6 2/4] ethdev: Add group JUMP action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Apr 2018 12:16:32 -0000 Add jump action type which defines an action which allows a matched flow to be redirect to the specified group. This allows physical and logical flow table/group hierarchies to be defined through rte_flow. This breaks ABI compatibility for the following public functions (as it modifes the ordering of the rte_flow_action_type enumeration): - rte_flow_copy() - rte_flow_create() - rte_flow_query() - rte_flow_validate() Add support for specification of new JUMP action to testpmd's flow cli, and update the testpmd documentation to describe this new action. Signed-off-by: Declan Doherty --- app/test-pmd/cmdline_flow.c | 23 +++++++++++ doc/guides/prog_guide/rte_flow.rst | 61 ++++++++++++++++++++++++----- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 ++ lib/librte_ether/rte_flow.h | 41 +++++++++++++++---- 4 files changed, 112 insertions(+), 17 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 4239602b6..6e9fa5d7c 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -183,6 +183,8 @@ enum index { ACTION_END, ACTION_VOID, ACTION_PASSTHRU, + ACTION_JUMP, + ACTION_JUMP_GROUP, ACTION_MARK, ACTION_MARK_ID, ACTION_FLAG, @@ -738,6 +740,7 @@ static const enum index next_action[] = { ACTION_END, ACTION_VOID, ACTION_PASSTHRU, + ACTION_JUMP, ACTION_MARK, ACTION_FLAG, ACTION_QUEUE, @@ -856,6 +859,12 @@ static const enum index action_of_push_mpls[] = { ZERO, }; +static const enum index action_jump[] = { + ACTION_JUMP_GROUP, + ACTION_NEXT, + ZERO, +}; + static int parse_init(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1931,6 +1940,20 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, + [ACTION_JUMP] = { + .name = "jump", + .help = "redirect traffic to a given group", + .priv = PRIV_ACTION(JUMP, sizeof(struct rte_flow_action_jump)), + .next = NEXT(action_jump), + .call = parse_vc, + }, + [ACTION_JUMP_GROUP] = { + .name = "group", + .help = "group to redirect traffic to", + .next = NEXT(action_jump, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_jump, group)), + .call = parse_vc_conf, + }, [ACTION_MARK] = { .name = "mark", .help = "attach 32 bit value to packets", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a7197cb7e..1102fae09 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -90,8 +90,12 @@ Thus predictable results for a given priority level can only be achieved with non-overlapping rules, using perfect matching on all protocol layers. Flow rules can also be grouped, the flow rule priority is specific to the -group they belong to. All flow rules in a given group are thus processed -either before or after another group. +group they belong to. All flow rules in a given group are thus processed within +the context of that group. Groups are not linked by default, so the logical +hierarchy of groups must be explicitly defined by flow rules themselves in each +group using the JUMP action to define the next group to redirect too. Only flow +rules defined in the default group 0 are guarantee to be matched against, this +makes group 0 the origin of any group hierarchy defined by an application. Support for multiple actions per rule may be implemented internally on top of non-default hardware priorities, as a result both features may not be @@ -138,29 +142,34 @@ Attributes Attribute: Group ^^^^^^^^^^^^^^^^ -Flow rules can be grouped by assigning them a common group number. Lower -values have higher priority. Group 0 has the highest priority. +Flow rules can be grouped by assigning them a common group number. Groups +allow a logical hierarchy of flow rule groups (tables) to be defined. These +groups can be supported virtually in the PMD or in the physical device. +Group 0 is the default group and this is the only group which flows are +guarantee to matched against, all subsequent groups can only be reached by +way of the JUMP action from a matched flow rule. Although optional, applications are encouraged to group similar rules as much as possible to fully take advantage of hardware capabilities (e.g. optimized matching) and work around limitations (e.g. a single pattern -type possibly allowed in a given group). +type possibly allowed in a given group), while being aware that the groups +hierarchies must be programmed explicitly. Note that support for more than a single group is not guaranteed. Attribute: Priority ^^^^^^^^^^^^^^^^^^^ -A priority level can be assigned to a flow rule. Like groups, lower values +A priority level can be assigned to a flow rule, lower values denote higher priority, with 0 as the maximum. -A rule with priority 0 in group 8 is always matched after a rule with -priority 8 in group 0. - -Group and priority levels are arbitrary and up to the application, they do +Priority levels are arbitrary and up to the application, they do not need to be contiguous nor start from 0, however the maximum number varies between devices and may be affected by existing flow rules. +A flow which matches multiple rules in the same group will always matched by +the rule with the highest priority in that group. + If a packet is matched by several rules of a given group for a given priority level, the outcome is undefined. It can take any path, may be duplicated or even cause unrecoverable errors. @@ -1372,6 +1381,38 @@ flow rules: | 2 | END | +-------+----------------------------+ +Action: ``JUMP`` +^^^^^^^^^^^^^^^^ + +Redirects packets to a group on the current device. + +In a hierarchy of groups, which can be used to represent physical or logical +flow group/tables on the device, this action redirects the matched flow to +the specified group on that device. + +If a matched flow is redirected to a table which doesn't contain a matching +rule for that flow then the behavior is undefined and the resulting behavior +is up to the specific device. Best practice when using groups would be define +a default flow rule for each group which a defines the default actions in that +group so a consistent behavior is defined. + +Defining an action for matched flow in a group to jump to a group which is +higher in the group hierarchy may not be supported by physical devices, +depending on how groups are mapped to the physical devices. In the +definitions of jump actions, applications should be aware that it may be +possible to define flow rules which trigger an undefined behavior causing +flows to loop between groups. + +.. _table_rte_flow_action_jump: + +.. table:: JUMP + + +-----------+------------------------------+ + | Field | Value | + +===========+==============================+ + | ``group`` | Group to redirect packets to | + +-----------+------------------------------+ + Action: ``MARK`` ^^^^^^^^^^^^^^^^ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 2edf96dd6..260d044d5 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3453,6 +3453,10 @@ This section lists supported actions and their attributes, if any. - ``passthru``: let subsequent rule process matched packets. +- ``jump``: redirect traffic to group on device. + + - ``group {unsigned}``: group to redirect to. + - ``mark``: attach 32 bit value to packets. - ``id {unsigned}``: 32 bit value to return with packets. diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 657cb9a99..17c1c4a89 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -35,18 +35,20 @@ extern "C" { /** * Flow rule attributes. * - * Priorities are set on two levels: per group and per rule within groups. + * Priorities are set on a per rule based within groups. * - * Lower values denote higher priority, the highest priority for both levels - * is 0, so that a rule with priority 0 in group 8 is always matched after a - * rule with priority 8 in group 0. + * Lower values denote higher priority, the highest priority for a flow rule + * is 0, so that a flow that matches for than one rule, the rule with the + * lowest priority value will always be matched. * * Although optional, applications are encouraged to group similar rules as * much as possible to fully take advantage of hardware capabilities * (e.g. optimized matching) and work around limitations (e.g. a single - * pattern type possibly allowed in a given group). + * pattern type possibly allowed in a given group). Applications should be + * aware that groups are not linked by default, and that they must be + * explicitly linked by the application using the JUMP action. * - * Group and priority levels are arbitrary and up to the application, they + * Priority levels are arbitrary and up to the application, they * do not need to be contiguous nor start from 0, however the maximum number * varies between devices and may be affected by existing flow rules. * @@ -69,7 +71,7 @@ extern "C" { */ struct rte_flow_attr { uint32_t group; /**< Priority group. */ - uint32_t priority; /**< Priority level within group. */ + uint32_t priority; /**< Rule priority level within group. */ uint32_t ingress:1; /**< Rule applies to ingress traffic. */ uint32_t egress:1; /**< Rule applies to egress traffic. */ /** @@ -1236,6 +1238,15 @@ enum rte_flow_action_type { */ RTE_FLOW_ACTION_TYPE_PASSTHRU, + /** + * RTE_FLOW_ACTION_TYPE_JUMP + * + * Redirects packets to a group on the current device. + * + * See struct rte_flow_action_jump. + */ + RTE_FLOW_ACTION_TYPE_JUMP, + /** * Attaches an integer value to packets and sets PKT_RX_FDIR and * PKT_RX_FDIR_ID mbuf flags. @@ -1481,6 +1492,22 @@ struct rte_flow_action_mark { uint32_t id; /**< Integer value to return with packets. */ }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_JUMP + * + * Redirects packets to a group on the current device. + * + * In a hierarchy of groups, which can be used to represent physical or logical + * flow tables on the device, this action allows the action to be a redirect to + * a group on that device. + */ +struct rte_flow_action_jump { + uint32_t group; +}; + /** * RTE_FLOW_ACTION_TYPE_QUEUE * -- 2.14.3