From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4655DA0C55; Wed, 13 Oct 2021 18:43:04 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB61A40151; Wed, 13 Oct 2021 18:42:59 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 3E9D0410DA for ; Wed, 13 Oct 2021 18:42:57 +0200 (CEST) Received: from localhost.localdomain (unknown [5.144.123.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id E61357F5FD; Wed, 13 Oct 2021 19:42:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E61357F5FD DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1634143377; bh=FPZjt5AF8w424edT4RzwfzZ0b1y4yARxltMCzhj6sUY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Rgeizyf4k/vKoPH+W0t2qz5H/M9EWE1QYJNyKwp7IXZF6KD8e1RY/xvDS1a2k6ePS 9A7eQ42p38k/db1wPwgAChhuUomQgEJvbKMUfBRMmYHcD3pkcZguP8vO2AOcxfrQxR ig4pL7sIzTcM8XucjvZODV5Ty7jobShh8Q1w30Q8= From: Ivan Malov To: dev@dpdk.org Cc: Ferruh Yigit , Thomas Monjalon , Ori Kam , Andrew Rybchenko , Xiaoyun Li Date: Wed, 13 Oct 2021 19:42:32 +0300 Message-Id: <20211013164243.21264-2-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211013164243.21264-1-ivan.malov@oktetlabs.ru> References: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> <20211013164243.21264-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 01/12] ethdev: add port representor 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" For use in "transfer" flows. Supposed to match traffic entering the embedded switch from the given ethdev. Must not be combined with direction attributes. Signed-off-by: Ivan Malov Acked-by: Ori Kam Acked-by: Andrew Rybchenko --- app/test-pmd/cmdline_flow.c | 27 ++++++++++ doc/guides/prog_guide/rte_flow.rst | 59 +++++++++++++++++++++ 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, 120 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 0b5856c7d5..5c480db91d 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_PORT_REPRESENTOR, + ITEM_PORT_REPRESENTOR_PORT_ID, /* Validate/create actions. */ ACTIONS, @@ -999,6 +1001,7 @@ static const enum index next_item[] = { ITEM_GENEVE_OPT, ITEM_INTEGRITY, ITEM_CONNTRACK, + ITEM_PORT_REPRESENTOR, END_SET, ZERO, }; @@ -1367,6 +1370,12 @@ static const enum index item_integrity_lv[] = { ZERO, }; +static const enum index item_port_representor[] = { + ITEM_PORT_REPRESENTOR_PORT_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -3606,6 +3615,21 @@ static const struct token token_list[] = { item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)), }, + [ITEM_PORT_REPRESENTOR] = { + .name = "port_representor", + .help = "match traffic entering the embedded switch from the given ethdev", + .priv = PRIV_ITEM(PORT_REPRESENTOR, + sizeof(struct rte_flow_item_ethdev)), + .next = NEXT(item_port_representor), + .call = parse_vc, + }, + [ITEM_PORT_REPRESENTOR_PORT_ID] = { + .name = "port_id", + .help = "ethdev port ID", + .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)), + }, /* Validate/create actions. */ [ACTIONS] = { .name = "actions", @@ -8333,6 +8357,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_PORT_REPRESENTOR: + 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 3cb014c1fa..d194640469 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1425,6 +1425,65 @@ Matches a conntrack state after conntrack action. - ``flags``: conntrack packet state flags. - Default ``mask`` matches all state bits. +Item: ``PORT_REPRESENTOR`` +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Matches traffic entering the embedded switch from the given ethdev. + +Term **ethdev** and the concept of **port representor** are synonymous. +The **represented port** is an *entity* plugged to the embedded switch +at the opposite end of the "wire" leading to the ethdev. + +:: + + .--------------------. + | PORT_REPRESENTOR | Ethdev (Application Port Referred to by its ID) + '--------------------' + || + \/ + .----------------. + | Logical Port | + '----------------' + || + || + || + \/ + .----------. + | Switch | + '----------' + : + : + : + : + .----------------. + | Logical Port | + '----------------' + : + : + .--------------------. + | REPRESENTED_PORT | Net / Guest / Another Ethdev (Same Application) + '--------------------' + + +- Incompatible with `Attribute: Traffic direction`_. +- Requires `Attribute: Transfer`_. + +.. _table_rte_flow_item_ethdev: + +.. table:: ``struct rte_flow_item_ethdev`` + + +----------+-------------+---------------------------+ + | Field | Subfield | Value | + +==========+=============+===========================+ + | ``spec`` | ``port_id`` | ethdev port ID | + +----------+-------------+---------------------------+ + | ``last`` | ``port_id`` | upper range value | + +----------+-------------+---------------------------+ + | ``mask`` | ``port_id`` | zeroed for wildcard match | + +----------+-------------+---------------------------+ + +- Default ``mask`` provides exact match behaviour. + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index d5c762df62..07f9d39a5b 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -252,6 +252,8 @@ API Changes the crypto/security operation. This field will be used to communicate events such as soft expiry with IPsec in lookaside mode. +* ethdev: Added item ``PORT_REPRESENTOR`` to flow API. + ABI Changes ----------- diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a0efb7d0b0..90765f9090 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3801,6 +3801,10 @@ This section lists supported pattern items and their attributes, if any. - ``conntrack``: match conntrack state. +- ``port_representor``: match traffic entering the embedded switch from the given ethdev + + - ``port_id {unsigned}``: ethdev port ID + Actions list ^^^^^^^^^^^^ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 8cb7a069c8..5e9317c6d1 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(PORT_REPRESENTOR, 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 5f87851f8c..1e3ef77ead 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 entering the embedded switch from the given ethdev. + * + * @see struct rte_flow_item_ethdev + */ + RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR, }; /** @@ -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 port ID for use with the following items: + * RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR. + */ +struct rte_flow_item_ethdev { + uint16_t port_id; /**< ethdev port ID */ +}; + +/** Default mask for items based on struct rte_flow_item_ethdev */ +#ifndef __cplusplus +static const struct rte_flow_item_ethdev rte_flow_item_ethdev_mask = { + .port_id = 0xffff, +}; +#endif + /** * Matching pattern item definition. * -- 2.20.1