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 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 Content-Transfer-Encoding: 8bit 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 */ -- 2.30.2