From patchwork Fri Oct 1 13:47:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100276 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EF534A0032; Fri, 1 Oct 2021 15:47:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AEBB6411A7; Fri, 1 Oct 2021 15:47:36 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 30CD2411A7 for ; Fri, 1 Oct 2021 15:47:35 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id D783F7F6E1; Fri, 1 Oct 2021 16:47:34 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id CFB0D7F6BC; Fri, 1 Oct 2021 16:47:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru CFB0D7F6BC Authentication-Results: shelob.oktetlabs.ru/CFB0D7F6BC; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ori Kam , Xiaoyun Li , Thomas Monjalon , Ferruh Yigit Cc: dev@dpdk.org, Ivan Malov Date: Fri, 1 Oct 2021 16:47:05 +0300 Message-Id: <20211001134716.1608857-2-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 01/12] ethdev: add ethdev item to flow API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ivan Malov For use with "transfer" flows. Supposed to match traffic transmitted by the DPDK application via the specified ethdev, at e-switch level. Must not be combined with attributes "ingress" / "egress". Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- app/test-pmd/cmdline_flow.c | 27 ++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 35 +++++++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 2 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 27 ++++++++++++++++ 6 files changed, 96 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index bb22294dd3..e05b0d83d2 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -306,6 +306,8 @@ enum index { ITEM_POL_PORT, ITEM_POL_METER, ITEM_POL_POLICY, + ITEM_ETHDEV, + ITEM_ETHDEV_ID, /* Validate/create actions. */ ACTIONS, @@ -1000,6 +1002,7 @@ static const enum index next_item[] = { ITEM_GENEVE_OPT, ITEM_INTEGRITY, ITEM_CONNTRACK, + ITEM_ETHDEV, END_SET, ZERO, }; @@ -1368,6 +1371,12 @@ static const enum index item_integrity_lv[] = { ZERO, }; +static const enum index item_ethdev[] = { + ITEM_ETHDEV_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -3608,6 +3617,21 @@ static const struct token token_list[] = { item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)), }, + [ITEM_ETHDEV] = { + .name = "ethdev", + .help = "match traffic at e-switch going from (sent by) the given ethdev", + .priv = PRIV_ITEM(ETHDEV, + sizeof(struct rte_flow_item_ethdev)), + .next = NEXT(item_ethdev), + .call = parse_vc, + }, + [ITEM_ETHDEV_ID] = { + .name = "id", + .help = "ethdev ID", + .next = NEXT(item_ethdev, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, id)), + }, /* Validate/create actions. */ [ACTIONS] = { .name = "actions", @@ -8343,6 +8367,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_PFCP: mask = &rte_flow_item_pfcp_mask; break; + case RTE_FLOW_ITEM_TYPE_ETHDEV: + mask = &rte_flow_item_ethdev_mask; + break; default: break; } diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 2b42d5ec8c..ab628d9139 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1425,6 +1425,41 @@ Matches a conntrack state after conntrack action. - ``flags``: conntrack packet state flags. - Default ``mask`` matches all state bits. +Item: ``ETHDEV`` +^^^^^^^^^^^^^^^^ + +Matches traffic at e-switch going from (sent by) the given ethdev. + +:: + + * (Ethdev) ~~~~~~~~~~~~ (Internal Port) >>>> [] ~~~~ (External Port) + * : SW : Logical Net / Guest : + * : : : + * | ---- PMD Layer ---- | ------------ E-Switch Layer ------------ | + * + * [] shows the effective ("transfer") standpoint, the match engine; + * >> shows the traffic flow in question hitting the match engine; + * ~~ shows logical interconnects between the endpoints. + +Use this with attribute **transfer**. Attributes **ingress** and +**egress** (`Attribute: Traffic direction`_) must not be used. + +- Default ``mask`` provides exact match behaviour. + +.. _table_rte_flow_item_ethdev: + +.. table:: ETHDEV + + +----------+----------+---------------------------+ + | Field | Subfield | Value | + +==========+==========+===========================+ + | ``spec`` | ``id`` | ethdev ID | + +----------+----------+---------------------------+ + | ``last`` | ``id`` | upper range value | + +----------+----------+---------------------------+ + | ``mask`` | ``id`` | zeroed for wildcard match | + +----------+----------+---------------------------+ + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index f099b1cca2..91631adb4e 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -167,6 +167,8 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* ethdev: Added item ``ETHDEV`` to flow API. + * cryptodev: The API rte_cryptodev_pmd_is_valid_dev is modified to rte_cryptodev_is_valid_dev as it can be used by the application as well as PMD to check whether the device is valid or not. diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index bbef706374..6d5de5457c 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3820,6 +3820,10 @@ This section lists supported pattern items and their attributes, if any. - ``conntrack``: match conntrack state. +- ``ethdev``: match traffic at e-switch going from (sent by) the given ethdev + + - ``id {unsigned}``: ethdev ID + Actions list ^^^^^^^^^^^^ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 8cb7a069c8..84eb61cb6c 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -100,6 +100,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct rte_flow_item_geneve_opt)), MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)), MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), + MK_FLOW_ITEM(ETHDEV, sizeof(struct rte_flow_item_ethdev)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 7b1ed7f110..880502098e 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -574,6 +574,15 @@ enum rte_flow_item_type { * @see struct rte_flow_item_conntrack. */ RTE_FLOW_ITEM_TYPE_CONNTRACK, + + /** + * [META] + * + * Matches traffic at e-switch going from (sent by) the given ethdev. + * + * @see struct rte_flow_item_ethdev + */ + RTE_FLOW_ITEM_TYPE_ETHDEV, }; /** @@ -1799,6 +1808,24 @@ static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { }; #endif +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * Provides an ethdev ID for use with items which are as follows: + * RTE_FLOW_ITEM_TYPE_ETHDEV. + */ +struct rte_flow_item_ethdev { + uint16_t id; /**< Ethdev ID */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_ETHDEV */ +#ifndef __cplusplus +static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = { + .id = 0xffff, +}; +#endif + /** * Matching pattern item definition. * From patchwork Fri Oct 1 13:47:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100277 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 91CCEA0032; Fri, 1 Oct 2021 15:47:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 17342411B7; Fri, 1 Oct 2021 15:47:40 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 522DC411C1 for ; Fri, 1 Oct 2021 15:47:39 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id CEA3F7F6E0; Fri, 1 Oct 2021 16:47:38 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 0FC847F6C1; Fri, 1 Oct 2021 16:47:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 0FC847F6C1 Authentication-Results: shelob.oktetlabs.ru/0FC847F6C1; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ori Kam , Xiaoyun Li , Thomas Monjalon , Ferruh Yigit Cc: dev@dpdk.org, Ivan Malov Date: Fri, 1 Oct 2021 16:47:06 +0300 Message-Id: <20211001134716.1608857-3-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 02/12] ethdev: add eswitch port item to flow API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ivan Malov For use with "transfer" flows. Supposed to match traffic entering the e-switch from the external world (network, guests) via the port which is logically connected with the given ethdev. Must not be combined with attributes "ingress" / "egress". This item is meant to use the same structure as ethdev item. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- app/test-pmd/cmdline_flow.c | 27 +++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 22 +++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 2 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 12 ++++++++- 6 files changed, 66 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index e05b0d83d2..188d0ee39d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -308,6 +308,8 @@ enum index { ITEM_POL_POLICY, ITEM_ETHDEV, ITEM_ETHDEV_ID, + ITEM_ESWITCH_PORT, + ITEM_ESWITCH_PORT_ETHDEV_ID, /* Validate/create actions. */ ACTIONS, @@ -1003,6 +1005,7 @@ static const enum index next_item[] = { ITEM_INTEGRITY, ITEM_CONNTRACK, ITEM_ETHDEV, + ITEM_ESWITCH_PORT, END_SET, ZERO, }; @@ -1377,6 +1380,12 @@ static const enum index item_ethdev[] = { ZERO, }; +static const enum index item_eswitch_port[] = { + ITEM_ESWITCH_PORT_ETHDEV_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -3632,6 +3641,21 @@ static const struct token token_list[] = { item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, id)), }, + [ITEM_ESWITCH_PORT] = { + .name = "eswitch_port", + .help = "match traffic at e-switch going from the external port associated with the given ethdev", + .priv = PRIV_ITEM(ESWITCH_PORT, + sizeof(struct rte_flow_item_ethdev)), + .next = NEXT(item_eswitch_port), + .call = parse_vc, + }, + [ITEM_ESWITCH_PORT_ETHDEV_ID] = { + .name = "ethdev_id", + .help = "ethdev ID", + .next = NEXT(item_eswitch_port, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, id)), + }, /* Validate/create actions. */ [ACTIONS] = { .name = "actions", @@ -8370,6 +8394,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_ETHDEV: mask = &rte_flow_item_ethdev_mask; break; + case RTE_FLOW_ITEM_TYPE_ESWITCH_PORT: + mask = &rte_flow_item_ethdev_mask; + break; default: break; } diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index ab628d9139..292bb42410 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1460,6 +1460,28 @@ Use this with attribute **transfer**. Attributes **ingress** and | ``mask`` | ``id`` | zeroed for wildcard match | +----------+----------+---------------------------+ +Item: ``ESWITCH_PORT`` +^^^^^^^^^^^^^^^^^^^^^^ + +Matches traffic at e-switch going from the external port associated +with the given ethdev, for example, traffic from net. port or guest. + +:: + + * (Ethdev) ~~~~~~~~~~~~ (Internal Port) ~~~~ [] <<<< (External Port) + * : SW : Logical Net / Guest : + * : : : + * | ---- PMD Layer ---- | ------------ E-Switch Layer ------------ | + * + * [] shows the effective ("transfer") standpoint, the match engine; + * << shows the traffic flow in question hitting the match engine; + * ~~ shows logical interconnects between the endpoints. + +Use this with attribute **transfer**. Attributes **ingress** and +**egress** (`Attribute: Traffic direction`_) must not be used. + +This item is meant to use the same structure as `Item: ETHDEV`_. + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index 91631adb4e..b2b27de3f0 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -167,7 +167,7 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= -* ethdev: Added item ``ETHDEV`` to flow API. +* ethdev: Added items ``ETHDEV``, ``ESWITCH_PORT`` to flow API. * cryptodev: The API rte_cryptodev_pmd_is_valid_dev is modified to rte_cryptodev_is_valid_dev as it can be used by the application as diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 6d5de5457c..9a5c2a2d82 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3824,6 +3824,10 @@ This section lists supported pattern items and their attributes, if any. - ``id {unsigned}``: ethdev ID +- ``eswitch_port``: match traffic at e-switch going from the external port associated with the given ethdev + + - ``ethdev_id {unsigned}``: ethdev ID + Actions list ^^^^^^^^^^^^ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 84eb61cb6c..c4aea5625f 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -101,6 +101,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(INTEGRITY, sizeof(struct rte_flow_item_integrity)), MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), MK_FLOW_ITEM(ETHDEV, sizeof(struct rte_flow_item_ethdev)), + MK_FLOW_ITEM(ESWITCH_PORT, sizeof(struct rte_flow_item_ethdev)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 880502098e..1a7e4c2e3d 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -583,6 +583,16 @@ enum rte_flow_item_type { * @see struct rte_flow_item_ethdev */ RTE_FLOW_ITEM_TYPE_ETHDEV, + + /** + * [META] + * + * Matches traffic at e-switch going from the external port associated + * with the given ethdev, for example, traffic from net. port or guest. + * + * @see struct rte_flow_item_ethdev + */ + RTE_FLOW_ITEM_TYPE_ESWITCH_PORT, }; /** @@ -1813,7 +1823,7 @@ static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { * @b EXPERIMENTAL: this structure may change without prior notice * * Provides an ethdev ID for use with items which are as follows: - * RTE_FLOW_ITEM_TYPE_ETHDEV. + * RTE_FLOW_ITEM_TYPE_ETHDEV, RTE_FLOW_ITEM_TYPE_ESWITCH_PORT. */ struct rte_flow_item_ethdev { uint16_t id; /**< Ethdev ID */ From patchwork Fri Oct 1 13:47:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100278 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C1ACCA0032; Fri, 1 Oct 2021 15:47:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A02D411B8; Fri, 1 Oct 2021 15:47:44 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 19C44411AA for ; Fri, 1 Oct 2021 15:47:43 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id D94C67F6C1; Fri, 1 Oct 2021 16:47:42 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 44E117F6D2; Fri, 1 Oct 2021 16:47:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 44E117F6D2 Authentication-Results: shelob.oktetlabs.ru/44E117F6D2; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ori Kam , Xiaoyun Li , Thomas Monjalon , Ferruh Yigit Cc: dev@dpdk.org, Ivan Malov Date: Fri, 1 Oct 2021 16:47:07 +0300 Message-Id: <20211001134716.1608857-4-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 03/12] ethdev: add ethdev action to flow API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ivan Malov For use with "transfer" flows. Supposed to direct matching traffic to the specified ethdev (to the application), at e-switch level. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- app/test-pmd/cmdline_flow.c | 24 ++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 31 +++++++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 2 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 +++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 18 ++++++++++++ 6 files changed, 79 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 188d0ee39d..feaa61349e 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -460,6 +460,8 @@ enum index { ACTION_POL_G, ACTION_POL_Y, ACTION_POL_R, + ACTION_ETHDEV, + ACTION_ETHDEV_ID, }; /** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -1452,6 +1454,7 @@ static const enum index next_action[] = { ACTION_MODIFY_FIELD, ACTION_CONNTRACK, ACTION_CONNTRACK_UPDATE, + ACTION_ETHDEV, ZERO, }; @@ -1733,6 +1736,12 @@ static const enum index action_update_conntrack[] = { ZERO, }; +static const enum index action_ethdev[] = { + ACTION_ETHDEV_ID, + ACTION_NEXT, + ZERO, +}; + static int parse_set_raw_encap_decap(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -4820,6 +4829,21 @@ static const struct token token_list[] = { .next = NEXT(action_update_conntrack), .call = parse_vc_action_conntrack_update, }, + [ACTION_ETHDEV] = { + .name = "ethdev", + .help = "at e-switch level, direct matching packets to the given ethdev", + .priv = PRIV_ACTION(ETHDEV, + sizeof(struct rte_flow_action_ethdev)), + .next = NEXT(action_ethdev), + .call = parse_vc, + }, + [ACTION_ETHDEV_ID] = { + .name = "id", + .help = "ethdev ID", + .next = NEXT(action_ethdev, NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev, id)), + .call = parse_vc_conf, + }, /* Indirect action destroy arguments. */ [INDIRECT_ACTION_DESTROY_ID] = { .name = "action_id", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 292bb42410..f633973181 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3056,6 +3056,37 @@ which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``) | ``meter_color`` | Packet color | +-----------------+--------------+ +Action: ``ETHDEV`` +^^^^^^^^^^^^^^^^^^ +At e-switch level, directs matching packets to the given ethdev. + +These packets can originate from any of e-switch ports, not +just the ones associated with the given ethdev. They come +from the match engine in general, as per some criteria. + +:: + + * (Ethdev) ~~~~~~~~~~~~ (Internal Port) <<<< [] ~~~~ (External Port) + * : SW : Logical Net / Guest : + * : : : + * | ---- PMD Layer ---- | ------------ E-Switch Layer ------------ | + * + * [] shows the effective ("transfer") standpoint, the action engine; + * << shows the traffic flow in question established by the action; + * ~~ shows logical interconnects between the endpoints. + +See `Item: ETHDEV`_. + +.. _table_rte_flow_action_ethdev: + +.. table:: ETHDEV + + +--------+-----------+ + | Field | Value | + +========+===========+ + | ``id`` | ethdev ID | + +--------+-----------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index b2b27de3f0..d431dc3804 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -167,7 +167,7 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= -* ethdev: Added items ``ETHDEV``, ``ESWITCH_PORT`` to flow API. +* ethdev: Added items ``ETHDEV``, ``ESWITCH_PORT`` and action ``ETHDEV`` to flow API. * cryptodev: The API rte_cryptodev_pmd_is_valid_dev is modified to rte_cryptodev_is_valid_dev as it can be used by the application as diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 9a5c2a2d82..79126e2f10 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4103,6 +4103,10 @@ This section lists supported actions and their attributes, if any. - ``type {value}``: Set color type with specified value(green/yellow/red) +- ``ethdev``: at e-switch level, direct matching packets to the given ethdev + + - ``id {unsigned}``: ethdev ID + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index c4aea5625f..3cc84e2b43 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -191,6 +191,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { */ MK_FLOW_ACTION(INDIRECT, 0), MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)), + MK_FLOW_ACTION(ETHDEV, sizeof(struct rte_flow_action_ethdev)), }; int diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 1a7e4c2e3d..3724ebee35 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -2446,6 +2446,13 @@ enum rte_flow_action_type { * See struct rte_flow_action_meter_color. */ RTE_FLOW_ACTION_TYPE_METER_COLOR, + + /** + * At e-switch level, directs matching packets to the given ethdev. + * + * @see struct rte_flow_action_ethdev + */ + RTE_FLOW_ACTION_TYPE_ETHDEV, }; /** @@ -3205,6 +3212,17 @@ struct rte_flow_action_meter_color { enum rte_color color; /**< Packet color. */ }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * Provides an ethdev ID for use with actions which are as follows: + * RTE_FLOW_ACTION_TYPE_ETHDEV. + */ +struct rte_flow_action_ethdev { + uint16_t id; /**< Ethdev ID */ +}; + /** * Field IDs for MODIFY_FIELD action. */ From patchwork Fri Oct 1 13:47:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100279 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C1B9EA0032; Fri, 1 Oct 2021 15:47:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 56825411AA; Fri, 1 Oct 2021 15:47:48 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 1C16E411AA for ; Fri, 1 Oct 2021 15:47:47 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id D62B57F6D2; Fri, 1 Oct 2021 16:47:46 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 794F67F6D3; Fri, 1 Oct 2021 16:47:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 794F67F6D3 Authentication-Results: shelob.oktetlabs.ru/794F67F6D3; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ori Kam , Xiaoyun Li , Thomas Monjalon , Ferruh Yigit Cc: dev@dpdk.org, Ivan Malov Date: Fri, 1 Oct 2021 16:47:08 +0300 Message-Id: <20211001134716.1608857-5-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 04/12] ethdev: add eswitch port action to flow API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ivan Malov For use with "transfer" flows. Supposed to direct matching traffic at e-switch level to the external world (network, guests) via the port which is logically connected with the given ethdev. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- app/test-pmd/cmdline_flow.c | 24 +++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 24 +++++++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 2 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 ++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 10 ++++++++- 6 files changed, 63 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index feaa61349e..57c7196866 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -462,6 +462,8 @@ enum index { ACTION_POL_R, ACTION_ETHDEV, ACTION_ETHDEV_ID, + ACTION_ESWITCH_PORT, + ACTION_ESWITCH_PORT_ETHDEV_ID, }; /** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -1455,6 +1457,7 @@ static const enum index next_action[] = { ACTION_CONNTRACK, ACTION_CONNTRACK_UPDATE, ACTION_ETHDEV, + ACTION_ESWITCH_PORT, ZERO, }; @@ -1742,6 +1745,12 @@ static const enum index action_ethdev[] = { ZERO, }; +static const enum index action_eswitch_port[] = { + ACTION_ESWITCH_PORT_ETHDEV_ID, + ACTION_NEXT, + ZERO, +}; + static int parse_set_raw_encap_decap(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -4844,6 +4853,21 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev, id)), .call = parse_vc_conf, }, + [ACTION_ESWITCH_PORT] = { + .name = "eswitch_port", + .help = "at e-switch level, direct matching packets to the external port associated with the given ethdev", + .priv = PRIV_ACTION(ESWITCH_PORT, + sizeof(struct rte_flow_action_ethdev)), + .next = NEXT(action_eswitch_port), + .call = parse_vc, + }, + [ACTION_ESWITCH_PORT_ETHDEV_ID] = { + .name = "ethdev_id", + .help = "ethdev ID", + .next = NEXT(action_eswitch_port, NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev, id)), + .call = parse_vc_conf, + }, /* Indirect action destroy arguments. */ [INDIRECT_ACTION_DESTROY_ID] = { .name = "action_id", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index f633973181..22f7d327d2 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3087,6 +3087,30 @@ See `Item: ETHDEV`_. | ``id`` | ethdev ID | +--------+-----------+ +Action: ``ESWITCH_PORT`` +^^^^^^^^^^^^^^^^^^^^^^^^ +At e-switch level, directs matching packets to the external port +associated with the given ethdev, that is, to net. port or guest. + +These packets can originate from any of e-switch ports, not +just the ones associated with the given ethdev. They come +from the match engine in general, as per some criteria. + +:: + + * (Ethdev) ~~~~~~~~~~~~ (Internal Port) ~~~~ [] >>>> (External Port) + * : SW : Logical Net / Guest : + * : : : + * | ---- PMD Layer ---- | ------------ E-Switch Layer ------------ | + * + * [] shows the effective ("transfer") standpoint, the action engine; + * >> shows the traffic flow in question established by the action; + * ~~ shows logical interconnects between the endpoints. + +See `Item: ESWITCH_PORT`_. + +This action is meant to use the same structure as `Action: ETHDEV`_. + Negative types ~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index d431dc3804..4f4890c7df 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -167,7 +167,7 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= -* ethdev: Added items ``ETHDEV``, ``ESWITCH_PORT`` and action ``ETHDEV`` to flow API. +* ethdev: Added items and actions ``ETHDEV``, ``ESWITCH_PORT`` to flow API. * cryptodev: The API rte_cryptodev_pmd_is_valid_dev is modified to rte_cryptodev_is_valid_dev as it can be used by the application as diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 79126e2f10..88bd8e743d 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4107,6 +4107,10 @@ This section lists supported actions and their attributes, if any. - ``id {unsigned}``: ethdev ID +- ``eswitch_port``: at e-switch level, direct matching packets to the external port associated with the given ethdev + + - ``ethdev_id {unsigned}``: ethdev ID + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 3cc84e2b43..647bbf91ce 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -192,6 +192,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(INDIRECT, 0), MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)), MK_FLOW_ACTION(ETHDEV, sizeof(struct rte_flow_action_ethdev)), + MK_FLOW_ACTION(ESWITCH_PORT, sizeof(struct rte_flow_action_ethdev)), }; int diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 3724ebee35..5d46b2350d 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -2453,6 +2453,14 @@ enum rte_flow_action_type { * @see struct rte_flow_action_ethdev */ RTE_FLOW_ACTION_TYPE_ETHDEV, + + /** + * At e-switch level, directs matching packets to the external port + * associated with the given ethdev, that is, to net. port or guest. + * + * @see struct rte_flow_action_ethdev + */ + RTE_FLOW_ACTION_TYPE_ESWITCH_PORT, }; /** @@ -3217,7 +3225,7 @@ struct rte_flow_action_meter_color { * @b EXPERIMENTAL: this structure may change without prior notice * * Provides an ethdev ID for use with actions which are as follows: - * RTE_FLOW_ACTION_TYPE_ETHDEV. + * RTE_FLOW_ACTION_TYPE_ETHDEV, RTE_FLOW_ACTION_TYPE_ESWITCH_PORT. */ struct rte_flow_action_ethdev { uint16_t id; /**< Ethdev ID */ From patchwork Fri Oct 1 13:47:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100280 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B2062A0547; Fri, 1 Oct 2021 15:48:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A3ED411D3; Fri, 1 Oct 2021 15:47:57 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 1B87E411BC for ; Fri, 1 Oct 2021 15:47:56 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id D77427F6DF; Fri, 1 Oct 2021 16:47:55 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id ACF127F6D5; Fri, 1 Oct 2021 16:47:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru ACF127F6D5 Authentication-Results: shelob.oktetlabs.ru/ACF127F6D5; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ori Kam , Ray Kinsella , Thomas Monjalon , Ferruh Yigit Cc: dev@dpdk.org, Ivan Malov Date: Fri, 1 Oct 2021 16:47:09 +0300 Message-Id: <20211001134716.1608857-6-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 05/12] ethdev: deprecate hard-to-use or ambiguous items and actions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ivan Malov PF, VF and PHY_PORT require that applications have extra knowledge of the underlying HW and thus are hard to use. Also, the corresponding items depend on the direction attribute (ingress / egress), which complicates their use in applications and interpretation in PMDs. The concept of PORT_ID is ambiguous as it doesn't say whether the port in question is an ethdev or the represented entity. Items and actions ETHDEV, ESWITCH_PORT should be used instead. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- doc/guides/prog_guide/rte_flow.rst | 16 ++++++++ doc/guides/rel_notes/deprecation.rst | 9 ++--- doc/guides/rel_notes/release_21_11.rst | 3 ++ lib/ethdev/rte_flow.h | 53 ++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 6 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 22f7d327d2..a5db278e8d 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -504,6 +504,8 @@ Usage example, matching non-TCPv4 packets only: Item: ``PF`` ^^^^^^^^^^^^ +This item is DEPRECATED. Consider: `Item: ETHDEV`_, `Item: ESWITCH_PORT`_. + Matches traffic originating from (ingress) or going to (egress) the physical function of the current device. @@ -531,6 +533,8 @@ the application and thus not associated with a DPDK port ID. Item: ``VF`` ^^^^^^^^^^^^ +This item is DEPRECATED. Consider: `Item: ETHDEV`_, `Item: ESWITCH_PORT`_. + Matches traffic originating from (ingress) or going to (egress) a given virtual function of the current device. @@ -562,6 +566,8 @@ separate entities, should be addressed through their own DPDK port IDs. Item: ``PHY_PORT`` ^^^^^^^^^^^^^^^^^^ +This item is DEPRECATED. Consider: `Item: ETHDEV`_, `Item: ESWITCH_PORT`_. + Matches traffic originating from (ingress) or going to (egress) a physical port of the underlying device. @@ -596,6 +602,8 @@ associated with a port_id should be retrieved by other means. Item: ``PORT_ID`` ^^^^^^^^^^^^^^^^^ +This item is DEPRECATED. Consider: `Item: ETHDEV`_, `Item: ESWITCH_PORT`_. + Matches traffic originating from (ingress) or going to (egress) a given DPDK port ID. @@ -1913,6 +1921,8 @@ only matching traffic goes through. Action: ``PF`` ^^^^^^^^^^^^^^ +This action is DEPRECATED. Consider: `Action: ETHDEV`_. + Directs matching traffic to the physical function (PF) of the current device. @@ -1933,6 +1943,8 @@ See `Item: PF`_. Action: ``VF`` ^^^^^^^^^^^^^^ +This action is DEPRECATED. Consider: `Action: ETHDEV`_, `Action: ESWITCH_PORT`_. + Directs matching traffic to a given virtual function of the current device. Packets matched by a VF pattern item can be redirected to their original VF @@ -1957,6 +1969,8 @@ See `Item: VF`_. Action: ``PHY_PORT`` ^^^^^^^^^^^^^^^^^^^^ +This action is DEPRECATED. Consider: `Action: ESWITCH_PORT`_. + Directs matching traffic to a given physical port index of the underlying device. @@ -1976,6 +1990,8 @@ See `Item: PHY_PORT`_. Action: ``PORT_ID`` ^^^^^^^^^^^^^^^^^^^ +This action is DEPRECATED. Consider: `Action: ETHDEV`_, `Action: ESWITCH_PORT`_. + Directs matching traffic to a given DPDK port ID. See `Item: PORT_ID`_. diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index a2fe766d4b..2b6718211f 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -128,12 +128,6 @@ Deprecation Notices is deprecated and will be removed in DPDK 21.11. Shared counters should be managed using shared actions API (``rte_flow_shared_action_create`` etc). -* ethdev: Definition of the flow API action ``RTE_FLOW_ACTION_TYPE_PORT_ID`` - is ambiguous and needs clarification. - Structure ``rte_flow_action_port_id`` will be extended to specify - traffic direction to the represented entity or ethdev port itself - in DPDK 21.11. - * ethdev: Flow API documentation is unclear if ethdev port used to create a flow rule adds any implicit match criteria in the case of transfer rules. The semantics will be clarified in DPDK 21.11 and it will require fixes in @@ -262,3 +256,6 @@ Deprecation Notices * cmdline: ``cmdline`` structure will be made opaque to hide platform-specific content. On Linux and FreeBSD, supported prior to DPDK 20.11, original structure will be kept until DPDK 21.11. + +* ethdev: Items and actions ``PF``, ``VF``, ``PHY_PORT``, ``PORT_ID`` are + deprecated as hard-to-use / ambiguous and will be removed in DPDK 22.11. diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index 4f4890c7df..fa0476a290 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -169,6 +169,9 @@ API Changes * ethdev: Added items and actions ``ETHDEV``, ``ESWITCH_PORT`` to flow API. +* ethdev: Deprecated items and actions ``PF``, ``VF``, ``PHY_PORT``, ``PORT_ID``. + Suggested items and actions ``ETHDEV``, ``ESWITCH_PORT`` instead. + * cryptodev: The API rte_cryptodev_pmd_is_valid_dev is modified to rte_cryptodev_is_valid_dev as it can be used by the application as well as PMD to check whether the device is valid or not. diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 5d46b2350d..a9661dd6ae 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -160,6 +160,10 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_ANY, /** + * @deprecated + * @see RTE_FLOW_ITEM_TYPE_ETHDEV + * @see RTE_FLOW_ITEM_TYPE_ESWITCH_PORT + * * [META] * * Matches traffic originating from (ingress) or going to (egress) @@ -170,6 +174,10 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_PF, /** + * @deprecated + * @see RTE_FLOW_ITEM_TYPE_ETHDEV + * @see RTE_FLOW_ITEM_TYPE_ESWITCH_PORT + * * [META] * * Matches traffic originating from (ingress) or going to (egress) a @@ -180,6 +188,10 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_VF, /** + * @deprecated + * @see RTE_FLOW_ITEM_TYPE_ETHDEV + * @see RTE_FLOW_ITEM_TYPE_ESWITCH_PORT + * * [META] * * Matches traffic originating from (ingress) or going to (egress) a @@ -190,6 +202,10 @@ enum rte_flow_item_type { RTE_FLOW_ITEM_TYPE_PHY_PORT, /** + * @deprecated + * @see RTE_FLOW_ITEM_TYPE_ETHDEV + * @see RTE_FLOW_ITEM_TYPE_ESWITCH_PORT + * * [META] * * Matches traffic originating from (ingress) or going to (egress) a @@ -640,6 +656,10 @@ static const struct rte_flow_item_any rte_flow_item_any_mask = { #endif /** + * @deprecated + * @see RTE_FLOW_ITEM_TYPE_ETHDEV + * @see RTE_FLOW_ITEM_TYPE_ESWITCH_PORT + * * RTE_FLOW_ITEM_TYPE_VF * * Matches traffic originating from (ingress) or going to (egress) a given @@ -669,6 +689,10 @@ static const struct rte_flow_item_vf rte_flow_item_vf_mask = { #endif /** + * @deprecated + * @see RTE_FLOW_ITEM_TYPE_ETHDEV + * @see RTE_FLOW_ITEM_TYPE_ESWITCH_PORT + * * RTE_FLOW_ITEM_TYPE_PHY_PORT * * Matches traffic originating from (ingress) or going to (egress) a @@ -700,6 +724,10 @@ static const struct rte_flow_item_phy_port rte_flow_item_phy_port_mask = { #endif /** + * @deprecated + * @see RTE_FLOW_ITEM_TYPE_ETHDEV + * @see RTE_FLOW_ITEM_TYPE_ESWITCH_PORT + * * RTE_FLOW_ITEM_TYPE_PORT_ID * * Matches traffic originating from (ingress) or going to (egress) a given @@ -1989,6 +2017,9 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_RSS, /** + * @deprecated + * @see RTE_FLOW_ACTION_TYPE_ETHDEV + * * Directs matching traffic to the physical function (PF) of the * current device. * @@ -1997,6 +2028,10 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_PF, /** + * @deprecated + * @see RTE_FLOW_ACTION_TYPE_ETHDEV + * @see RTE_FLOW_ACTION_TYPE_ESWITCH_PORT + * * Directs matching traffic to a given virtual function of the * current device. * @@ -2005,6 +2040,9 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_VF, /** + * @deprecated + * @see RTE_FLOW_ACTION_TYPE_ESWITCH_PORT + * * Directs packets to a given physical port index of the underlying * device. * @@ -2013,6 +2051,10 @@ enum rte_flow_action_type { RTE_FLOW_ACTION_TYPE_PHY_PORT, /** + * @deprecated + * @see RTE_FLOW_ACTION_TYPE_ETHDEV + * @see RTE_FLOW_ACTION_TYPE_ESWITCH_PORT + * * Directs matching traffic to a given DPDK port ID. * * See struct rte_flow_action_port_id. @@ -2653,6 +2695,10 @@ struct rte_flow_action_rss { }; /** + * @deprecated + * @see RTE_FLOW_ACTION_TYPE_ETHDEV + * @see RTE_FLOW_ACTION_TYPE_ESWITCH_PORT + * * RTE_FLOW_ACTION_TYPE_VF * * Directs matching traffic to a given virtual function of the current @@ -2671,6 +2717,9 @@ struct rte_flow_action_vf { }; /** + * @deprecated + * @see RTE_FLOW_ACTION_TYPE_ESWITCH_PORT + * * RTE_FLOW_ACTION_TYPE_PHY_PORT * * Directs packets to a given physical port index of the underlying @@ -2685,6 +2734,10 @@ struct rte_flow_action_phy_port { }; /** + * @deprecated + * @see RTE_FLOW_ACTION_TYPE_ETHDEV + * @see RTE_FLOW_ACTION_TYPE_ESWITCH_PORT + * * RTE_FLOW_ACTION_TYPE_PORT_ID * * Directs matching traffic to a given DPDK port ID. From patchwork Fri Oct 1 13:47:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100281 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8F976A0032; Fri, 1 Oct 2021 15:48:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5020411DC; Fri, 1 Oct 2021 15:47:59 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id A4998411E6 for ; Fri, 1 Oct 2021 15:47:58 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 68FCD7F6DF; Fri, 1 Oct 2021 16:47:58 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id E1C6E7F6D6; Fri, 1 Oct 2021 16:47:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E1C6E7F6D6 Authentication-Results: shelob.oktetlabs.ru/E1C6E7F6D6; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ori Kam , Ray Kinsella , Thomas Monjalon , Ferruh Yigit Cc: dev@dpdk.org, Ivan Malov Date: Fri, 1 Oct 2021 16:47:10 +0300 Message-Id: <20211001134716.1608857-7-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 06/12] ethdev: deprecate direction attributes in transfer flows X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ivan Malov Attributes "ingress" and "egress" can only apply unambiguosly to non-"transfer" flows. In "transfer" flows, the standpoint is effectively shifted to the underlying e-switch. There can be many different endpoints connected to the e-switch, so the use of "ingress" / "egress" doesn't shed light on which endpoints precisely can be considered as traffic sources. Add relevant deprecation notices and suggest the use of precise traffic source items (ETHDEV and ESWITCH_PORT) instead. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- doc/guides/prog_guide/rte_flow.rst | 29 +++++++++--------- doc/guides/rel_notes/deprecation.rst | 9 +++--- doc/guides/rel_notes/release_21_11.rst | 4 +++ lib/ethdev/rte_flow.h | 41 ++++++++++++++++++++------ 4 files changed, 54 insertions(+), 29 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a5db278e8d..c8b2102b52 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -9,8 +9,8 @@ Overview -------- This API provides a generic means to configure hardware to match specific -ingress or egress traffic, alter its fate and query related counters -according to any number of user-defined rules. +traffic, alter its fate and query related counters according to any +number of user-defined rules. It is named *rte_flow* after the prefix used for all its symbols, and is defined in ``rte_flow.h``. @@ -146,13 +146,10 @@ Note that support for more than a single priority level is not guaranteed. Attribute: Traffic direction ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Flow rule patterns apply to inbound and/or outbound traffic. - -In the context of this API, **ingress** and **egress** respectively stand -for **inbound** and **outbound** based on the standpoint of the application -creating a flow rule. - -There are no exceptions to this definition. +Unless `Attribute: Transfer`_ is specified, flow rule patterns apply +to inbound and / or outbound traffic. With this respect, **ingress** +and **egress** respectively stand for **inbound** and **outbound** +based on the standpoint of the application creating a flow rule. Several pattern items and actions are valid and can be used in both directions. At least one direction must be specified. @@ -171,12 +168,14 @@ When supported, this effectively enables an application to reroute traffic not necessarily intended for it (e.g. coming from or addressed to different physical ports, VFs or applications) at the device level. -It complements the behavior of some pattern items such as `Item: PHY_PORT`_ -and is meaningless without them. - -When transferring flow rules, **ingress** and **egress** attributes -(`Attribute: Traffic direction`_) keep their original meaning, as if -processing traffic emitted or received by the application. +In **transfer** flows, the use of **ingress** and **egress** attributes +(`Attribute: Traffic direction`_) in the sense of implicitly matching +packets going to or going from the ethdev used to create flow rules +is DEPRECATED as these attributes are ambiguous. The standpoint is +shifted to the e-switch, and, over there, terms **ingress** / **egress** +are not relevant since there're many different ports served by the +e-switch. If the application needs to match traffic origination from some +precise locations, it should use `Item: ETHDEV`_ and `Item: ESWITCH_PORT`_. Pattern item ~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 2b6718211f..0c9e739bf2 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -128,11 +128,6 @@ Deprecation Notices is deprecated and will be removed in DPDK 21.11. Shared counters should be managed using shared actions API (``rte_flow_shared_action_create`` etc). -* ethdev: Flow API documentation is unclear if ethdev port used to create - a flow rule adds any implicit match criteria in the case of transfer rules. - The semantics will be clarified in DPDK 21.11 and it will require fixes in - drivers and applications which interpret it in a different way. - * ethdev: The flow API matching pattern structures, ``struct rte_flow_item_*``, should start with relevant protocol header. Some matching pattern structures implements this by duplicating protocol header @@ -259,3 +254,7 @@ Deprecation Notices * ethdev: Items and actions ``PF``, ``VF``, ``PHY_PORT``, ``PORT_ID`` are deprecated as hard-to-use / ambiguous and will be removed in DPDK 22.11. + +* ethdev: The use of attributes ``ingress`` / ``egress`` in "transfer" flows + is deprecated as ambiguous with respect to the e-switch standpoint. Such + use of these attributes will become invalid starting from DPDK 22.11. diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index fa0476a290..37776c135e 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -172,6 +172,10 @@ API Changes * ethdev: Deprecated items and actions ``PF``, ``VF``, ``PHY_PORT``, ``PORT_ID``. Suggested items and actions ``ETHDEV``, ``ESWITCH_PORT`` instead. +* ethdev: Deprecated the use of attributes ``ingress`` / ``egress`` combined + with attribute ``transfer``. Items ``ETHDEV``, ``ESWITCH_PORT`` + should be used instead to specify traffic source(s). + * cryptodev: The API rte_cryptodev_pmd_is_valid_dev is modified to rte_cryptodev_is_valid_dev as it can be used by the application as well as PMD to check whether the device is valid or not. diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index a9661dd6ae..f195aa7224 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -67,7 +67,10 @@ extern "C" { * Note that support for more than a single group and priority level is not * guaranteed. * - * Flow rules can apply to inbound and/or outbound traffic (ingress/egress). + * At vNIC / ethdev level, flow rules can apply to inbound and / or outbound + * traffic (ingress / egress), with respect to the vNIC / ethdev in question. + * At e-switch level, flow rules apply to all traffic seen by the e-switch + * unless suitable meta items are used to set concrete traffic source(s). * * Several pattern items and actions are valid and can be used in both * directions. Those valid for only one direction are described as such. @@ -80,8 +83,32 @@ extern "C" { struct rte_flow_attr { uint32_t group; /**< Priority 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. */ + /** + * The rule in question applies to ingress traffic (non-"transfer"). + * + * @deprecated + * It has been possible to combine this attribute with "transfer". + * Doing so has been assumed to restrict the scope of matching + * to traffic going from within the e-switch toward the ethdev + * the flow rule being created through. This behaviour is now + * deprecated. During the transition period, one may still + * rely on it, but PMDs and applications are encouraged to + * gradually move away from this approach. + */ + uint32_t ingress:1; + /** + * The rule in question applies to egress traffic (non-"transfer"). + * + * @deprecated + * It has been possible to combine this attribute with "transfer". + * Doing so has been assumed to restrict the scope of matching + * to traffic sent by the application by virtue of the ethdev + * the flow rule being created through. This behaviour is now + * deprecated. During the transition period, one may still + * rely on it, but PMDs and applications are encouraged to + * gradually move away from this approach. + */ + uint32_t egress:1; /** * Instead of simply matching the properties of traffic as it would * appear on a given DPDK port ID, enabling this attribute transfers @@ -93,12 +120,8 @@ struct rte_flow_attr { * from or addressed to different physical ports, VFs or * applications) at the device level. * - * It complements the behavior of some pattern items such as - * RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them. - * - * When transferring flow rules, ingress and egress attributes keep - * their original meaning, as if processing traffic emitted or - * received by the application. + * In order to match traffic originating from specific source(s), the + * application should use pattern items ETHDEV and ESWITCH_PORT. */ uint32_t transfer:1; uint32_t reserved:29; /**< Reserved, must be zero. */ From patchwork Fri Oct 1 13:47:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100282 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8EDEA0032; Fri, 1 Oct 2021 15:48:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1BEAF411F6; Fri, 1 Oct 2021 15:48:01 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 114ED411E6 for ; Fri, 1 Oct 2021 15:47:59 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id B949A7F6E4; Fri, 1 Oct 2021 16:47:58 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 210E77F6D7; Fri, 1 Oct 2021 16:47:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 210E77F6D7 Authentication-Results: shelob.oktetlabs.ru/210E77F6D7; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ajit Khaparde , Somnath Kotur Cc: dev@dpdk.org, Ori Kam , Thomas Monjalon , Ferruh Yigit , Ivan Malov Date: Fri, 1 Oct 2021 16:47:11 +0300 Message-Id: <20211001134716.1608857-8-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 07/12] net/bnxt: support ethdev and E-Switch port flow items X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add support for RTE_FLOW_ITEM_TYPE_ETHDEV and RTE_FLOW_ITEM_TYPE_ESWITCH_PORT items based on RTE_FLOW_ITEM_TYPE_PORT_ID action. The major difference of these items from PORT_ID is that these new items define traffic direction itself. ETHDEV is always from the driver vNIC. ESWITCH_PORT is either from v-port (network) or VF vNIC (VF representor case). Signed-off-by: Andrew Rybchenko --- drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c | 10 ++- drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 80 ++++++++++++++----- drivers/net/bnxt/tf_ulp/ulp_rte_parser.h | 9 ++- 3 files changed, 76 insertions(+), 23 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c b/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c index 9b165c12b5..87914cc845 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c @@ -266,7 +266,7 @@ struct bnxt_ulp_rte_hdr_info ulp_hdr_info[] = { }, [RTE_FLOW_ITEM_TYPE_PORT_ID] = { .hdr_type = BNXT_ULP_HDR_TYPE_SUPPORTED, - .proto_hdr_func = ulp_rte_port_id_hdr_handler + .proto_hdr_func = ulp_rte_port_hdr_handler }, [RTE_FLOW_ITEM_TYPE_RAW] = { .hdr_type = BNXT_ULP_HDR_TYPE_NOT_SUPPORTED, @@ -427,6 +427,14 @@ struct bnxt_ulp_rte_hdr_info ulp_hdr_info[] = { [RTE_FLOW_ITEM_TYPE_HIGIG2] = { .hdr_type = BNXT_ULP_HDR_TYPE_NOT_SUPPORTED, .proto_hdr_func = NULL + }, + [RTE_FLOW_ITEM_TYPE_ETHDEV] = { + .hdr_type = BNXT_ULP_HDR_TYPE_SUPPORTED, + .proto_hdr_func = ulp_rte_port_hdr_handler + }, + [RTE_FLOW_ITEM_TYPE_ESWITCH_PORT] = { + .hdr_type = BNXT_ULP_HDR_TYPE_SUPPORTED, + .proto_hdr_func = ulp_rte_port_hdr_handler } }; diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index 3a9c9bba27..c747150864 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -400,7 +400,8 @@ bnxt_ulp_rte_parser_direction_compute(struct ulp_rte_parser_params *params) static int32_t ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params, uint32_t ifindex, - uint16_t mask) + uint16_t mask, + enum bnxt_ulp_direction_type item_dir) { uint16_t svif; enum bnxt_ulp_direction_type dir; @@ -429,11 +430,14 @@ ulp_rte_parser_svif_set(struct ulp_rte_parser_params *params, bnxt_ulp_rte_parser_direction_compute(params); /* Get the computed direction */ - dir = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_DIRECTION); - if (dir == BNXT_ULP_DIR_INGRESS) { + dir = (item_dir != BNXT_ULP_DIR_INVALID) ? item_dir : + ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_DIRECTION); + if (dir == BNXT_ULP_DIR_INGRESS && + port_type != BNXT_ULP_INTF_TYPE_VF_REP) { svif_type = BNXT_ULP_PHY_PORT_SVIF; } else { - if (port_type == BNXT_ULP_INTF_TYPE_VF_REP) + if (port_type == BNXT_ULP_INTF_TYPE_VF_REP && + item_dir != BNXT_ULP_DIR_EGRESS) svif_type = BNXT_ULP_VF_FUNC_SVIF; else svif_type = BNXT_ULP_DRV_FUNC_SVIF; @@ -474,7 +478,8 @@ ulp_rte_parser_implicit_match_port_process(struct ulp_rte_parser_params *params) } /* Update the SVIF details */ - rc = ulp_rte_parser_svif_set(params, ifindex, svif_mask); + rc = ulp_rte_parser_svif_set(params, ifindex, svif_mask, + BNXT_ULP_DIR_INVALID); return rc; } @@ -522,7 +527,8 @@ ulp_rte_pf_hdr_handler(const struct rte_flow_item *item __rte_unused, } /* Update the SVIF details */ - return ulp_rte_parser_svif_set(params, ifindex, svif_mask); + return ulp_rte_parser_svif_set(params, ifindex, svif_mask, + BNXT_ULP_DIR_INVALID); } /* Function to handle the parsing of RTE Flow item VF Header. */ @@ -555,39 +561,75 @@ ulp_rte_vf_hdr_handler(const struct rte_flow_item *item, return rc; } /* Update the SVIF details */ - return ulp_rte_parser_svif_set(params, ifindex, mask); + return ulp_rte_parser_svif_set(params, ifindex, mask, + BNXT_ULP_DIR_INVALID); } -/* Function to handle the parsing of RTE Flow item port id Header. */ +/* + * Function to handle the parsing of RTE Flow items port id, ethdev and + * E-Switch port Headers. + */ int32_t -ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item, - struct ulp_rte_parser_params *params) +ulp_rte_port_hdr_handler(const struct rte_flow_item *item, + struct ulp_rte_parser_params *params) { - const struct rte_flow_item_port_id *port_spec = item->spec; - const struct rte_flow_item_port_id *port_mask = item->mask; + enum bnxt_ulp_direction_type item_dir; + uint16_t ethdev_id; uint16_t mask = 0; int32_t rc = BNXT_TF_RC_PARSE_ERR; uint32_t ifindex; - if (!port_spec) { - BNXT_TF_DBG(ERR, "ParseErr:Port id is not valid\n"); + if (!item->spec) { + BNXT_TF_DBG(ERR, "ParseErr:Port spec is not valid\n"); return rc; } - if (!port_mask) { - BNXT_TF_DBG(ERR, "ParseErr:Phy Port mask is not valid\n"); + if (!item->mask) { + BNXT_TF_DBG(ERR, "ParseErr:Port mask is not valid\n"); + return rc; + } + + switch (item->type) { + case RTE_FLOW_ITEM_TYPE_PORT_ID: { + const struct rte_flow_item_port_id *port_spec = item->spec; + const struct rte_flow_item_port_id *port_mask = item->mask; + + item_dir = BNXT_ULP_DIR_INVALID; + ethdev_id = port_spec->id; + mask = port_mask->id; + break; + } + case RTE_FLOW_ITEM_TYPE_ETHDEV: { + const struct rte_flow_item_ethdev *ethdev_spec = item->spec; + const struct rte_flow_item_ethdev *ethdev_mask = item->mask; + + item_dir = BNXT_ULP_DIR_INGRESS; + ethdev_id = ethdev_spec->id; + mask = ethdev_mask->id; + break; + } + case RTE_FLOW_ITEM_TYPE_ESWITCH_PORT: { + const struct rte_flow_item_ethdev *ethdev_spec = item->spec; + const struct rte_flow_item_ethdev *ethdev_mask = item->mask; + + item_dir = BNXT_ULP_DIR_EGRESS; + ethdev_id = ethdev_spec->id; + mask = ethdev_mask->id; + break; + } + default: + BNXT_TF_DBG(ERR, "ParseErr:Unexpected item\n"); return rc; } - mask = port_mask->id; /* perform the conversion from dpdk port to bnxt ifindex */ if (ulp_port_db_dev_port_to_ulp_index(params->ulp_ctx, - port_spec->id, + ethdev_id, &ifindex)) { BNXT_TF_DBG(ERR, "ParseErr:Portid is not valid\n"); return rc; } /* Update the SVIF details */ - return ulp_rte_parser_svif_set(params, ifindex, mask); + return ulp_rte_parser_svif_set(params, ifindex, mask, item_dir); } /* Function to handle the parsing of RTE Flow item phy port Header. */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h index e14f86278a..531596b00d 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h @@ -90,10 +90,13 @@ int32_t ulp_rte_vf_hdr_handler(const struct rte_flow_item *item, struct ulp_rte_parser_params *params); -/* Function to handle the parsing of RTE Flow item port id Header. */ +/* + * Function to handle the parsing of RTE Flow items port id, ethdev and + * E-Switch port Headers. + */ int32_t -ulp_rte_port_id_hdr_handler(const struct rte_flow_item *item, - struct ulp_rte_parser_params *params); +ulp_rte_port_hdr_handler(const struct rte_flow_item *item, + struct ulp_rte_parser_params *params); /* Function to handle the parsing of RTE Flow item port Header. */ int32_t From patchwork Fri Oct 1 13:47:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100283 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 70D4BA0032; Fri, 1 Oct 2021 15:48:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31975411F9; Fri, 1 Oct 2021 15:48:02 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 39FCB411DF for ; Fri, 1 Oct 2021 15:48:00 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 018167F6E2; Fri, 1 Oct 2021 16:47:59 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 559507F6D8; Fri, 1 Oct 2021 16:47:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 559507F6D8 Authentication-Results: shelob.oktetlabs.ru/559507F6D8; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Ajit Khaparde , Somnath Kotur Cc: dev@dpdk.org, Ori Kam , Thomas Monjalon , Ferruh Yigit , Ivan Malov Date: Fri, 1 Oct 2021 16:47:12 +0300 Message-Id: <20211001134716.1608857-9-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 08/12] net/bnxt: support ethdev and E-Switch port flow actions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add support for RTE_FLOW_ACTION_TYPE_ETHDEV and RTE_FLOW_ACTION_TYPE_ESWITCH_PORT actions based on RTE_FLOW_ACTION_TYPE_PORT_ID action. Signed-off-by: Andrew Rybchenko --- drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c | 12 ++- drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 84 ++++++++++++++----- drivers/net/bnxt/tf_ulp/ulp_rte_parser.h | 9 +- 3 files changed, 80 insertions(+), 25 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c b/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c index 87914cc845..a31728c217 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_handler_tbl.c @@ -67,7 +67,7 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = { }, [RTE_FLOW_ACTION_TYPE_PORT_ID] = { .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, - .proto_act_func = ulp_rte_port_id_act_handler + .proto_act_func = ulp_rte_port_act_handler }, [RTE_FLOW_ACTION_TYPE_METER] = { .act_type = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED, @@ -212,7 +212,15 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = { [RTE_FLOW_ACTION_TYPE_SAMPLE] = { .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, .proto_act_func = ulp_rte_sample_act_handler - } + }, + [RTE_FLOW_ACTION_TYPE_ETHDEV] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_port_act_handler + }, + [RTE_FLOW_ACTION_TYPE_ESWITCH_PORT] = { + .act_type = BNXT_ULP_ACT_TYPE_SUPPORTED, + .proto_act_func = ulp_rte_port_act_handler + }, }; struct bnxt_ulp_rte_act_info ulp_vendor_act_info[] = { diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c index c747150864..8e04229ee7 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c @@ -496,10 +496,11 @@ ulp_rte_parser_implicit_act_port_process(struct ulp_rte_parser_params *params) return BNXT_TF_RC_SUCCESS; } port_id.id = ULP_COMP_FLD_IDX_RD(params, BNXT_ULP_CF_IDX_INCOMING_IF); + action_item.type = RTE_FLOW_ACTION_TYPE_PORT_ID; action_item.conf = &port_id; /* Update the action port based on incoming port */ - ulp_rte_port_id_act_handler(&action_item, params); + ulp_rte_port_act_handler(&action_item, params); /* Reset the action port set bit */ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_PORT_IS_SET, 0); @@ -2171,7 +2172,8 @@ ulp_rte_count_act_handler(const struct rte_flow_action *action_item, /* Function to handle the parsing of action ports. */ static int32_t ulp_rte_parser_act_port_set(struct ulp_rte_parser_params *param, - uint32_t ifindex) + uint32_t ifindex, + enum bnxt_ulp_direction_type act_dir) { enum bnxt_ulp_direction_type dir; uint16_t pid_s; @@ -2181,8 +2183,13 @@ ulp_rte_parser_act_port_set(struct ulp_rte_parser_params *param, uint32_t vnic_type; /* Get the direction */ - dir = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_DIRECTION); - if (dir == BNXT_ULP_DIR_EGRESS) { + /* If action implicitly specifies direction, use the specification. */ + dir = (act_dir == BNXT_ULP_DIR_INVALID) ? + ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_DIRECTION) : + act_dir; + port_type = ULP_COMP_FLD_IDX_RD(param, BNXT_ULP_CF_IDX_ACT_PORT_TYPE); + if (dir == BNXT_ULP_DIR_EGRESS && + port_type != BNXT_ULP_INTF_TYPE_VF_REP) { /* For egress direction, fill vport */ if (ulp_port_db_vport_get(param->ulp_ctx, ifindex, &pid_s)) return BNXT_TF_RC_ERROR; @@ -2193,9 +2200,14 @@ ulp_rte_parser_act_port_set(struct ulp_rte_parser_params *param, &pid, BNXT_ULP_ACT_PROP_SZ_VPORT); } else { /* For ingress direction, fill vnic */ - port_type = ULP_COMP_FLD_IDX_RD(param, - BNXT_ULP_CF_IDX_ACT_PORT_TYPE); - if (port_type == BNXT_ULP_INTF_TYPE_VF_REP) + /* + * In ETHDEV action case, destination is a driver + * function of the representor itself, otherwise + * (PORT_ID or ESWITCH_PORT) the destination is + * corresponding VF. + */ + if (act_dir != BNXT_ULP_DIR_INGRESS && + port_type == BNXT_ULP_INTF_TYPE_VF_REP) vnic_type = BNXT_ULP_VF_FUNC_VNIC; else vnic_type = BNXT_ULP_DRV_FUNC_VNIC; @@ -2242,7 +2254,8 @@ ulp_rte_pf_act_handler(const struct rte_flow_action *action_item __rte_unused, } /* Update the action properties */ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_PORT_TYPE, intf_type); - return ulp_rte_parser_act_port_set(params, ifindex); + return ulp_rte_parser_act_port_set(params, ifindex, + BNXT_ULP_DIR_INVALID); } /* Function to handle the parsing of RTE Flow action VF. */ @@ -2293,31 +2306,62 @@ ulp_rte_vf_act_handler(const struct rte_flow_action *action_item, /* Update the action properties */ ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_ACT_PORT_TYPE, intf_type); - return ulp_rte_parser_act_port_set(params, ifindex); + return ulp_rte_parser_act_port_set(params, ifindex, + BNXT_ULP_DIR_INVALID); } -/* Function to handle the parsing of RTE Flow action port_id. */ +/* + * Function to handle the parsing of RTE Flow actions PORT_ID, ETHDEV and + * ESWITCH_PORT. + */ int32_t -ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, - struct ulp_rte_parser_params *param) +ulp_rte_port_act_handler(const struct rte_flow_action *act_item, + struct ulp_rte_parser_params *param) { - const struct rte_flow_action_port_id *port_id = act_item->conf; + uint32_t ethdev_id; uint32_t ifindex; enum bnxt_ulp_intf_type intf_type; + enum bnxt_ulp_direction_type act_dir; - if (!port_id) { + if (!act_item->conf) { BNXT_TF_DBG(ERR, "ParseErr: Invalid Argument\n"); return BNXT_TF_RC_PARSE_ERR; } - if (port_id->original) { - BNXT_TF_DBG(ERR, - "ParseErr:Portid Original not supported\n"); - return BNXT_TF_RC_PARSE_ERR; + switch (act_item->type) { + case RTE_FLOW_ACTION_TYPE_PORT_ID: { + const struct rte_flow_action_port_id *port_id = act_item->conf; + + if (port_id->original) { + BNXT_TF_DBG(ERR, + "ParseErr:Portid Original not supported\n"); + return BNXT_TF_RC_PARSE_ERR; + } + ethdev_id = port_id->id; + act_dir = BNXT_ULP_DIR_INVALID; + break; + } + case RTE_FLOW_ACTION_TYPE_ETHDEV: { + const struct rte_flow_action_ethdev *ethdev = act_item->conf; + + ethdev_id = ethdev->id; + act_dir = BNXT_ULP_DIR_INGRESS; + break; + } + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: { + const struct rte_flow_action_ethdev *ethdev = act_item->conf; + + ethdev_id = ethdev->id; + act_dir = BNXT_ULP_DIR_EGRESS; + break; + } + default: + BNXT_TF_DBG(ERR, "Unknown port action\n"); + return BNXT_TF_RC_ERROR; } /* Get the port db ifindex */ - if (ulp_port_db_dev_port_to_ulp_index(param->ulp_ctx, port_id->id, + if (ulp_port_db_dev_port_to_ulp_index(param->ulp_ctx, ethdev_id, &ifindex)) { BNXT_TF_DBG(ERR, "Invalid port id\n"); return BNXT_TF_RC_ERROR; @@ -2332,7 +2376,7 @@ ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, /* Set the action port */ ULP_COMP_FLD_IDX_WR(param, BNXT_ULP_CF_IDX_ACT_PORT_TYPE, intf_type); - return ulp_rte_parser_act_port_set(param, ifindex); + return ulp_rte_parser_act_port_set(param, ifindex, act_dir); } /* Function to handle the parsing of RTE Flow action phy_port. */ diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h index 531596b00d..307bb5c75c 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.h @@ -207,10 +207,13 @@ int32_t ulp_rte_vf_act_handler(const struct rte_flow_action *action_item, struct ulp_rte_parser_params *params); -/* Function to handle the parsing of RTE Flow action port_id. */ +/* + * Function to handle the parsing of RTE Flow actions PORT_ID, ETHDEV and + * ESWITCH_PORT. + */ int32_t -ulp_rte_port_id_act_handler(const struct rte_flow_action *act_item, - struct ulp_rte_parser_params *params); +ulp_rte_port_act_handler(const struct rte_flow_action *act_item, + struct ulp_rte_parser_params *params); /* Function to handle the parsing of RTE Flow action phy_port. */ int32_t From patchwork Fri Oct 1 13:47:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100284 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E835DA0032; Fri, 1 Oct 2021 15:48:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E188B411BD; Fri, 1 Oct 2021 15:48:11 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 86CBD411BC for ; Fri, 1 Oct 2021 15:48:10 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 4C97C7F6D6; Fri, 1 Oct 2021 16:48:10 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 879C97F6D9; Fri, 1 Oct 2021 16:47:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 879C97F6D9 Authentication-Results: shelob.oktetlabs.ru/879C97F6D9; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: John Daley , Hyong Youb Kim Cc: dev@dpdk.org, Ori Kam , Thomas Monjalon , Ferruh Yigit , Ivan Malov Date: Fri, 1 Oct 2021 16:47:13 +0300 Message-Id: <20211001134716.1608857-10-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 09/12] net/enic: support ethdev and E-Switch port flow actions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add support for RTE_FLOW_ACTION_TYPE_ETHDEV and RTE_FLOW_ACTION_TYPE_ESWITCH_PORT actions based on RTE_FLOW_ACTION_TYPE_PORT_ID action. Signed-off-by: Andrew Rybchenko --- drivers/net/enic/enic_fm_flow.c | 93 ++++++++++++++++++++++++++------- 1 file changed, 75 insertions(+), 18 deletions(-) diff --git a/drivers/net/enic/enic_fm_flow.c b/drivers/net/enic/enic_fm_flow.c index cd364ee16b..0878b54067 100644 --- a/drivers/net/enic/enic_fm_flow.c +++ b/drivers/net/enic/enic_fm_flow.c @@ -1242,6 +1242,35 @@ vf_egress_port_id_action(struct enic_flowman *fm, return 0; } +static int +enic_fm_check_transfer_dst(struct enic *enic, uint16_t dst_port_id, + struct rte_eth_dev **dst_dev, + struct rte_flow_error *error) +{ + struct rte_eth_dev *dev; + + ENICPMD_LOG(DEBUG, "port id %u", dst_port_id); + if (!rte_eth_dev_is_valid_port(dst_port_id)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "invalid port_id"); + } + dev = &rte_eth_devices[dst_port_id]; + if (!dev_is_enic(dev)) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "port_id is not enic"); + } + if (enic->switch_domain_id != pmd_priv(dev)->switch_domain_id) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "destination and source ports are not in the same switch domain"); + } + + *dst_dev = dev; + return 0; +} + /* Translate flow actions to flowman TCAM entry actions */ static int enic_fm_copy_action(struct enic_flowman *fm, @@ -1446,24 +1475,10 @@ enic_fm_copy_action(struct enic_flowman *fm, vnic_h = enic->fm_vnic_handle; /* This port */ break; } - ENICPMD_LOG(DEBUG, "port id %u", port->id); - if (!rte_eth_dev_is_valid_port(port->id)) { - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, "invalid port_id"); - } - dev = &rte_eth_devices[port->id]; - if (!dev_is_enic(dev)) { - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, "port_id is not enic"); - } - if (enic->switch_domain_id != - pmd_priv(dev)->switch_domain_id) { - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION, - NULL, "destination and source ports are not in the same switch domain"); - } + ret = enic_fm_check_transfer_dst(enic, port->id, &dev, + error); + if (ret) + return ret; vnic_h = pmd_priv(dev)->fm_vnic_handle; overlap |= PORT_ID; /* @@ -1560,6 +1575,48 @@ enic_fm_copy_action(struct enic_flowman *fm, ovlan |= rte_be_to_cpu_16(vid->vlan_vid); break; } + case RTE_FLOW_ACTION_TYPE_ETHDEV: { + const struct rte_flow_action_ethdev *ethdev; + struct rte_eth_dev *dev; + + ethdev = actions->conf; + ret = enic_fm_check_transfer_dst(enic, ethdev->id, &dev, + error); + if (ret) + return ret; + vnic_h = pmd_priv(dev)->fm_vnic_handle; + overlap |= PORT_ID; + /* + * ETHDEV action implies ingress destination. + * Noting to do. We add an implicit stree at the + * end if needed. + */ + ingress = 1; + break; + } + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: { + const struct rte_flow_action_ethdev *ethdev; + struct rte_eth_dev *dev; + + if (overlap & PORT_ID) { + ENICPMD_LOG(DEBUG, "cannot have multiple egress PORT_ID actions"); + goto unsupported; + } + ethdev = actions->conf; + ret = enic_fm_check_transfer_dst(enic, ethdev->id, &dev, + error); + if (ret) + return ret; + vnic_h = pmd_priv(dev)->fm_vnic_handle; + overlap |= PORT_ID; + /* E-Switch port action is always egress destination */ + ingress = 0; + ret = vf_egress_port_id_action(fm, dev, vnic_h, &fm_op, + error); + if (ret) + return ret; + break; + } default: goto unsupported; } From patchwork Fri Oct 1 13:47:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100285 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 945D9A0032; Fri, 1 Oct 2021 15:48:34 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F339141206; Fri, 1 Oct 2021 15:48:12 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id A63AE411BD for ; Fri, 1 Oct 2021 15:48:10 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 665147F6DF; Fri, 1 Oct 2021 16:48:10 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id B7C327F6DA; Fri, 1 Oct 2021 16:47:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru B7C327F6DA Authentication-Results: shelob.oktetlabs.ru/B7C327F6DA; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Matan Azrad , Viacheslav Ovsiienko Cc: dev@dpdk.org, Ori Kam , Thomas Monjalon , Ferruh Yigit , Ivan Malov Date: Fri, 1 Oct 2021 16:47:14 +0300 Message-Id: <20211001134716.1608857-11-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 10/12] net/mlx5: support E-Switch port flow action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" PORT_ID action implementation has the same semantics as ESWITCH_PORT action in net/mlx5 case. Helper functions keep port_id suffix since internally it is still a MLX5_FLOW_ACTION_PORT_ID action. Signed-off-by: Andrew Rybchenko --- drivers/net/mlx5/mlx5_flow_dv.c | 62 ++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index b610ad3ef4..98f15b328f 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -5048,14 +5048,14 @@ flow_dv_validate_action_jump(struct rte_eth_dev *dev, } /* - * Validate the port_id action. + * Validate the port ID or E-Switch port action. * * @param[in] dev * Pointer to rte_eth_dev structure. * @param[in] action_flags * Bit-fields that holds the actions detected until now. * @param[in] action - * Port_id RTE action structure. + * PORT_ID or ESWITCH_PORT RTE action structure. * @param[in] attr * Attributes of flow that includes this action. * @param[out] error @@ -5072,6 +5072,7 @@ flow_dv_validate_action_port_id(struct rte_eth_dev *dev, struct rte_flow_error *error) { const struct rte_flow_action_port_id *port_id; + const struct rte_flow_action_ethdev *ethdev; struct mlx5_priv *act_priv; struct mlx5_priv *dev_priv; uint16_t port; @@ -5080,13 +5081,13 @@ flow_dv_validate_action_port_id(struct rte_eth_dev *dev, return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, - "port id action is valid in transfer" + "port action is valid in transfer" " mode only"); if (!action || !action->conf) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION_CONF, NULL, - "port id action parameters must be" + "port action parameters must be" " specified"); if (action_flags & (MLX5_FLOW_FATE_ACTIONS | MLX5_FLOW_FATE_ESWITCH_ACTIONS)) @@ -5100,13 +5101,26 @@ flow_dv_validate_action_port_id(struct rte_eth_dev *dev, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "failed to obtain E-Switch info"); - port_id = action->conf; - port = port_id->original ? dev->data->port_id : port_id->id; + switch (action->type) { + case RTE_FLOW_ACTION_TYPE_PORT_ID: + port_id = action->conf; + port = port_id->original ? dev->data->port_id : port_id->id; + break; + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: + ethdev = action->conf; + port = ethdev->id; + break; + default: + return rte_flow_error_set + (error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "unknown E-Switch action"); + } act_priv = mlx5_port_to_eswitch_info(port, false); if (!act_priv) return rte_flow_error_set (error, rte_errno, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, port_id, + RTE_FLOW_ERROR_TYPE_ACTION_CONF, action->conf, "failed to obtain E-Switch port id for port"); if (act_priv->domain_id != dev_priv->domain_id) return rte_flow_error_set @@ -5669,6 +5683,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags, ++actions_n; break; case RTE_FLOW_ACTION_TYPE_PORT_ID: + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: ret = flow_dv_validate_action_port_id(dev, sub_action_flags, act, @@ -7296,6 +7311,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, case RTE_FLOW_ACTION_TYPE_VOID: break; case RTE_FLOW_ACTION_TYPE_PORT_ID: + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: ret = flow_dv_validate_action_port_id(dev, action_flags, actions, @@ -10770,12 +10786,12 @@ flow_dv_tag_release(struct rte_eth_dev *dev, } /** - * Translate port ID action to vport. + * Translate port ID or E-Switch port action to vport. * * @param[in] dev * Pointer to rte_eth_dev structure. * @param[in] action - * Pointer to the port ID action. + * Pointer to the port ID or E-Switch port action. * @param[out] dst_port_id * The target port ID. * @param[out] error @@ -10792,10 +10808,28 @@ flow_dv_translate_action_port_id(struct rte_eth_dev *dev, { uint32_t port; struct mlx5_priv *priv; - const struct rte_flow_action_port_id *conf = - (const struct rte_flow_action_port_id *)action->conf; - port = conf->original ? dev->data->port_id : conf->id; + switch (action->type) { + case RTE_FLOW_ACTION_TYPE_PORT_ID: { + const struct rte_flow_action_port_id *conf; + + conf = (const struct rte_flow_action_port_id *)action->conf; + port = conf->original ? dev->data->port_id : conf->id; + break; + } + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: { + const struct rte_flow_action_ethdev *ethdev; + + ethdev = (const struct rte_flow_action_ethdev *)action->conf; + port = ethdev->id; + break; + } + default: + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, action, + "unknown E-Switch action"); + } + priv = mlx5_port_to_eswitch_info(port, false); if (!priv) return rte_flow_error_set(error, -rte_errno, @@ -11634,6 +11668,7 @@ flow_dv_translate_action_sample(struct rte_eth_dev *dev, break; } case RTE_FLOW_ACTION_TYPE_PORT_ID: + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: { struct mlx5_flow_dv_port_id_action_resource port_id_resource; @@ -12714,6 +12749,7 @@ flow_dv_translate(struct rte_eth_dev *dev, case RTE_FLOW_ACTION_TYPE_VOID: break; case RTE_FLOW_ACTION_TYPE_PORT_ID: + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: if (flow_dv_translate_action_port_id(dev, action, &port_id, error)) return -rte_errno; @@ -15475,6 +15511,7 @@ __flow_dv_create_domain_policy_acts(struct rte_eth_dev *dev, break; } case RTE_FLOW_ACTION_TYPE_PORT_ID: + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: { struct mlx5_flow_dv_port_id_action_resource port_id_resource; @@ -17683,6 +17720,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, NULL, "too many actions"); switch (act->type) { case RTE_FLOW_ACTION_TYPE_PORT_ID: + case RTE_FLOW_ACTION_TYPE_ESWITCH_PORT: if (!priv->config.dv_esw_en) return -rte_mtr_error_set(error, ENOTSUP, From patchwork Fri Oct 1 13:47:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100286 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2C15FA0032; Fri, 1 Oct 2021 15:48:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0C3C1411D7; Fri, 1 Oct 2021 15:48:21 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id AA663411A7 for ; Fri, 1 Oct 2021 15:48:19 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 7A4097F6D9; Fri, 1 Oct 2021 16:48:19 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id E6D397F6DB; Fri, 1 Oct 2021 16:47:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E6D397F6DB Authentication-Results: shelob.oktetlabs.ru/E6D397F6DB; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Jerin Jacob , Nithin Dabilpuram , Kiran Kumar K Cc: dev@dpdk.org, Ori Kam , Thomas Monjalon , Ferruh Yigit , Ivan Malov Date: Fri, 1 Oct 2021 16:47:15 +0300 Message-Id: <20211001134716.1608857-12-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 11/12] net/octeontx2: support ethdev flow action X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" PORT_ID action implementation works for ingress only and has the same semantics as ETHDEV action. Signed-off-by: Andrew Rybchenko --- drivers/net/octeontx2/otx2_flow_parse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/octeontx2/otx2_flow_parse.c b/drivers/net/octeontx2/otx2_flow_parse.c index 63a33142a5..5dd8464ec9 100644 --- a/drivers/net/octeontx2/otx2_flow_parse.c +++ b/drivers/net/octeontx2/otx2_flow_parse.c @@ -900,7 +900,6 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev, { struct otx2_eth_dev *hw = dev->data->dev_private; struct otx2_npc_flow_info *npc = &hw->npc_flow; - const struct rte_flow_action_port_id *port_act; const struct rte_flow_action_count *act_count; const struct rte_flow_action_mark *act_mark; const struct rte_flow_action_queue *act_q; @@ -987,9 +986,18 @@ otx2_flow_parse_actions(struct rte_eth_dev *dev, break; case RTE_FLOW_ACTION_TYPE_PORT_ID: - port_act = (const struct rte_flow_action_port_id *) - actions->conf; - port_id = port_act->id; + case RTE_FLOW_ACTION_TYPE_ETHDEV: + if (actions->type == RTE_FLOW_ACTION_TYPE_PORT_ID) { + const struct rte_flow_action_port_id *port_act; + + port_act = actions->conf; + port_id = port_act->id; + } else { + const struct rte_flow_action_ethdev *ethdev_act; + + ethdev_act = actions->conf; + port_id = ethdev_act->id; + } if (rte_eth_dev_get_name_by_port(port_id, if_name)) { errmsg = "Name not found for output port id"; errcode = EINVAL; From patchwork Fri Oct 1 13:47:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 100287 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 66C9FA0032; Fri, 1 Oct 2021 15:48:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 08ACA4120D; Fri, 1 Oct 2021 15:48:23 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 0CB1E4120D for ; Fri, 1 Oct 2021 15:48:22 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id D239A7F6D8; Fri, 1 Oct 2021 16:48:21 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 220E47F6DD; Fri, 1 Oct 2021 16:47:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 220E47F6DD Authentication-Results: shelob.oktetlabs.ru/220E47F6DD; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Cc: dev@dpdk.org, Ori Kam , Thomas Monjalon , Ferruh Yigit , Ivan Malov Date: Fri, 1 Oct 2021 16:47:16 +0300 Message-Id: <20211001134716.1608857-13-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> References: <20210907125157.3843-1-ivan.malov@oktetlabs.ru> <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v1 12/12] net/sfc: support ethdev flow item X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add support for RTE_FLOW_ITEM_TYPE_ETHDEV which should be used instead of ambiguous RTE_FLOW_ITEM_TYPE_PORT_ID. Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc_mae.c | 72 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 4b520bc619..1299fc3680 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -1100,6 +1100,66 @@ sfc_mae_rule_parse_item_port_id(const struct rte_flow_item *item, return 0; } +static int +sfc_mae_rule_parse_item_ethdev(const struct rte_flow_item *item, + struct sfc_flow_parse_ctx *ctx, + struct rte_flow_error *error) +{ + struct sfc_mae_parse_ctx *ctx_mae = ctx->mae; + const struct rte_flow_item_ethdev supp_mask = { + .id = 0xffff, + }; + const void *def_mask = &rte_flow_item_ethdev_mask; + const struct rte_flow_item_ethdev *spec = NULL; + const struct rte_flow_item_ethdev *mask = NULL; + efx_mport_sel_t mport_sel; + int rc; + + if (ctx_mae->match_mport_set) { + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Can't handle multiple traffic source items"); + } + + rc = sfc_flow_parse_init(item, + (const void **)&spec, (const void **)&mask, + (const void *)&supp_mask, def_mask, + sizeof(struct rte_flow_item_ethdev), error); + if (rc != 0) + return rc; + + if (mask->id != supp_mask.id) { + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Bad mask in the ETHDEV pattern item"); + } + + /* If "spec" is not set, could be any port ID */ + if (spec == NULL) + return 0; + + rc = sfc_mae_switch_port_by_ethdev( + ctx_mae->sa->mae.switch_domain_id, + spec->id, &mport_sel); + if (rc != 0) { + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Can't find RTE ethdev by the port ID"); + } + + rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec, + &mport_sel, NULL); + if (rc != 0) { + return rte_flow_error_set(error, rc, + RTE_FLOW_ERROR_TYPE_ITEM, item, + "Failed to set MPORT for the port ID"); + } + + ctx_mae->match_mport_set = B_TRUE; + + return 0; +} + static int sfc_mae_rule_parse_item_phy_port(const struct rte_flow_item *item, struct sfc_flow_parse_ctx *ctx, @@ -1995,6 +2055,18 @@ static const struct sfc_flow_item sfc_flow_items[] = { .ctx_type = SFC_FLOW_PARSE_CTX_MAE, .parse = sfc_mae_rule_parse_item_port_id, }, + { + .type = RTE_FLOW_ITEM_TYPE_ETHDEV, + .name = "ETHDEV", + /* + * In terms of RTE flow, this item is a META one, + * and its position in the pattern is don't care. + */ + .prev_layer = SFC_FLOW_ITEM_ANY_LAYER, + .layer = SFC_FLOW_ITEM_ANY_LAYER, + .ctx_type = SFC_FLOW_PARSE_CTX_MAE, + .parse = sfc_mae_rule_parse_item_ethdev, + }, { .type = RTE_FLOW_ITEM_TYPE_PHY_PORT, .name = "PHY_PORT",