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