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. *