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 9AABEA0C41; Sun, 10 Oct 2021 02:05:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D75C5410EA; Sun, 10 Oct 2021 02:05:25 +0200 (CEST) Received: from shelob.oktetlabs.ru (unknown [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 6CB1140040 for ; Sun, 10 Oct 2021 02:05:18 +0200 (CEST) Received: from localhost.localdomain (unknown [5.144.122.166]) (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 137EE7F6D4; Sun, 10 Oct 2021 03:05:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 137EE7F6D4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1633824312; bh=ZWAEvHqJh57S9VKcUhbVqkv5aF2TC5KsesqO8ZOYyB0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cm2r2XuM91xF1n4ove/qEtIsmZpcn70RezFABRTTDpMU3NcNgTUmNzrDdQXjgDzHx KLmoTMb4yBmut5iDTZnmsJbGOjCJgM8KfBzuIGn8CWVO/Cx9TtPgWoOXY52M/BhJyO uoSVPWUW1TSyu0Lja4axY07siu4EypP9TN1bjJyQ= From: Ivan Malov To: dev@dpdk.org Cc: Thomas Monjalon , Ori Kam , Xiaoyun Li , Ferruh Yigit , Andrew Rybchenko Date: Sun, 10 Oct 2021 03:04:54 +0300 Message-Id: <20211010000503.28712-4-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211010000503.28712-1-ivan.malov@oktetlabs.ru> References: <20211001134716.1608857-1-andrew.rybchenko@oktetlabs.ru> <20211010000503.28712-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 03/12] ethdev: add port representor 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" For use in "transfer" flows. Supposed to send matching traffic to the given ethdev (to the application), at embedded switch level. Signed-off-by: Ivan Malov --- app/test-pmd/cmdline_flow.c | 26 ++++++++++ doc/guides/prog_guide/rte_flow.rst | 56 +++++++++++++++++++++ doc/guides/rel_notes/release_21_11.rst | 2 +- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 ++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 18 +++++++ 6 files changed, 107 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 68698d805d..ee6dac411a 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_PORT_REPRESENTOR, + ACTION_PORT_REPRESENTOR_PORT_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_PORT_REPRESENTOR, ZERO, }; @@ -1733,6 +1736,12 @@ static const enum index action_update_conntrack[] = { ZERO, }; +static const enum index action_port_representor[] = { + ACTION_PORT_REPRESENTOR_PORT_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,23 @@ static const struct token token_list[] = { .next = NEXT(action_update_conntrack), .call = parse_vc_action_conntrack_update, }, + [ACTION_PORT_REPRESENTOR] = { + .name = "port_representor", + .help = "at embedded switch level, send matching traffic to the given ethdev", + .priv = PRIV_ACTION(PORT_REPRESENTOR, + sizeof(struct rte_flow_action_ethdev)), + .next = NEXT(action_port_representor), + .call = parse_vc, + }, + [ACTION_PORT_REPRESENTOR_PORT_ID] = { + .name = "port_id", + .help = "ethdev port ID", + .next = NEXT(action_port_representor, + NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev, + port_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 3dc209af4d..e85880c2d4 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1484,6 +1484,8 @@ at the opposite end of the "wire" leading to the ethdev. - Default ``mask`` provides exact match behaviour. +See also `Action: PORT_REPRESENTOR`_. + Item: ``REPRESENTED_PORT`` ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -3104,6 +3106,60 @@ which is set in the packet meta-data (i.e. struct ``rte_mbuf::sched::color``) | ``meter_color`` | Packet color | +-----------------+--------------+ +Action: ``PORT_REPRESENTOR`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +At embedded switch level, send matching traffic to 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) + '------------------------' + /\ + || + .------------------------. + | Embedded Switch Port | Logical Port + '------------------------' + /\ + || + || + || + .------------------------. .--------------------. + | Embedded Flow Engine | <= | Matching Traffic | + '------------------------' '--------------------' + : + : + : + : + .------------------------. + | Embedded Switch Port | Logical Port + '------------------------' + : + : + .------------------------. + | REPRESENTED_PORT | Net / Guest / Another Ethdev (Same Application) + '------------------------' + + +- Requires `Attribute: Transfer`_. + +.. _table_rte_flow_action_ethdev: + +.. table:: ``struct rte_flow_action_ethdev`` + + +-------------+----------------+ + | Field | Value | + +=============+================+ + | ``port_id`` | ethdev port ID | + +-------------+----------------+ + +See also `Item: PORT_REPRESENTOR`_. + Negative types ~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index 39ff16780b..bf46329e52 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -188,7 +188,7 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= -* ethdev: Added items ``PORT_REPRESENTOR``, ``REPRESENTED_PORT`` to flow API. +* ethdev: Added items ``PORT_REPRESENTOR``, ``REPRESENTED_PORT`` and action ``PORT_REPRESENTOR`` to flow API. * kvargs: The experimental function ``rte_kvargs_strcmp()`` has been removed. Its usages have been replaced by a new function diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 44a399899f..5f127fdbcc 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4079,6 +4079,11 @@ This section lists supported actions and their attributes, if any. - ``type {value}``: Set color type with specified value(green/yellow/red) +- ``port_representor``: at embedded switch level, send matching traffic to + the given ethdev + + - ``port_id {unsigned}``: ethdev port ID + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index d4b654a2c6..b074b1c77d 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(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)), }; int diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 24d41aeb7b..cf4165bef3 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -2447,6 +2447,13 @@ enum rte_flow_action_type { * See struct rte_flow_action_meter_color. */ RTE_FLOW_ACTION_TYPE_METER_COLOR, + + /** + * At embedded switch level, sends matching traffic to the given ethdev. + * + * @see struct rte_flow_action_ethdev + */ + RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR, }; /** @@ -3206,6 +3213,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 port ID for use with the following actions: + * RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR. + */ +struct rte_flow_action_ethdev { + uint16_t port_id; /**< ethdev port ID */ +}; + /** * Field IDs for MODIFY_FIELD action. */ -- 2.20.1