From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id D15315A44 for ; Tue, 24 Apr 2018 17:59:15 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id d1-v6so50462461wrj.13 for ; Tue, 24 Apr 2018 08:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4JadJoE/aGpO+x/0hrfcaAZjRVqrpL/grV+vmdeYWTk=; b=uEakbtB6hrxLggdSF+SOKIKuMLS5lJlFwxa6yLdq7f4tTFnBfXn6Qu0vr5OoUkHXek /pB/Lsr45eC1a4HS7ENiwI7kjC9k2alTlPv5gelZ95suVGEXQP/RT3uF2VqPcZcRyCZn dvqacjl/uNI3cP3oejG2vGP5rL50RUaWADBapG2eR25VhiRsQ96fd8UXEHagDQacoPXH eWYkOaZBiFXT7KHin/J85lVJSQvfACT3T5He5zVi3E+1F+zxM5xPgmtESrtf2bWx6AFl tuWtgKJ6kpWQrlHHTv3/EMiG2qx9TqY+2J55flNJLiMpiue/OWQU6X64NNBFJZjvbpDp JQ7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4JadJoE/aGpO+x/0hrfcaAZjRVqrpL/grV+vmdeYWTk=; b=GXu4ZlyG11EyibM5YpYR/2VWWWuNbJXMQxFAF2NndTxMRWSvW0lGyxZE0FFBWLIn2f o3Gr0BPa9jUHLfgTScFXzY3bE0InCqsuFlxPQdK8lcvQtpj82EvrZCH+xaSi7iJtQLTD u+IBgBA1GtScklfGQgWNSlfhwx1SnwJmzIYwbIzGiv0gQ12oVaA26NmgRIGVcP8Yfdow sbCVqH2tl4RUSXhpUh0PPdILEut97GXeZNy89QonuS3ovjy7YIbMkaFFZ2jfTcfBj+59 Nvya5qlX+9ExghXm8UjwE2L08I3EcbGM9xzjowaefjie+W/epcPmZkAJeQwjtm4V/vdB dvyg== X-Gm-Message-State: ALQs6tCTjIL43JCRTmCkov21DEsAKRe8gZYkoItfcW8xNviXo76JQfpU D1aEnbwnDZr1CgnmFTF946t3/g== X-Google-Smtp-Source: AIpwx48fdTaSHs45Bx6GT5khrKrfykbHKOp86r2/s342eLTToz6mRTlNqWx/7s8ikL/lIvHP0Qz4AQ== X-Received: by 2002:adf:8672:: with SMTP id 47-v6mr17873753wrw.102.1524585554794; Tue, 24 Apr 2018 08:59:14 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id a79sm1783205wme.48.2018.04.24.08.59.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Apr 2018 08:59:14 -0700 (PDT) Date: Tue, 24 Apr 2018 17:59:00 +0200 From: Adrien Mazarguil To: Ferruh Yigit , Qi Zhang Cc: dev@dpdk.org, declan.doherty@intel.com, sugesh.chandran@intel.com, michael.j.glynn@intel.com, yu.y.liu@intel.com, konstantin.ananyev@intel.com, bruce.richardson@intel.com Message-ID: <20180424154822.19666-3-adrien.mazarguil@6wind.com> References: <20180423063610.246387-1-qi.z.zhang@intel.com> <20180424154822.19666-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180424154822.19666-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH v5 2/3] ethdev: add TTL change actions to flow API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Apr 2018 15:59:16 -0000 From: Qi Zhang Add support for the following OpenFlow-defined actions: - RTE_FLOW_ACTION_OF_SET_MPLS_TTL: MPLS TTL. - RTE_FLOW_ACTION_OF_DEC_MPLS_TTL: decrement MPLS TTL. - RTE_FLOW_ACTION_OF_SET_NW_TTL: IP TTL. - RTE_FLOW_ACTION_OF_DEC_NW_TTL: decrement IP TTL. - RTE_FLOW_ACTION_OF_COPY_TTL_OUT: copy TTL "outwards". - RTE_FLOW_ACTION_OF_COPY_TTL_IN: copy TTL "inwards". Signed-off-by: Qi Zhang Signed-off-by: Adrien Mazarguil -- v5 changes: - Modified action names (e.g. ACTION_OF_MPLS_TTL_SET => ACTION_OF_SET_MPLS_TTL) to match their OpenFlow counterparts (e.g. OFPAT_SET_MPLS_TTL). - Simplified documentation of all these actions to point to the OpenFlow Switch Specification instead of providing a (possibly) inaccurate summary. - Updated testpmd flow command accordingly. - Expanded field names in structure definitions and in the testpmd flow command to match OpenFlow's. - Added related item copy code to testpmd and rte_flow_copy(). - Updated commit log to reflect patch contents. --- app/test-pmd/cmdline_flow.c | 88 +++++++++++++++++++++ app/test-pmd/config.c | 8 ++ doc/guides/prog_guide/rte_flow.rst | 99 ++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 16 ++++ lib/librte_ether/rte_flow.c | 8 ++ lib/librte_ether/rte_flow.h | 72 ++++++++++++++++- 6 files changed, 290 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 2bb2be101..07ca3ac4d 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -212,6 +212,14 @@ enum index { ACTION_PORT_ID_ID, ACTION_METER, ACTION_METER_ID, + ACTION_OF_SET_MPLS_TTL, + ACTION_OF_SET_MPLS_TTL_MPLS_TTL, + ACTION_OF_DEC_MPLS_TTL, + ACTION_OF_SET_NW_TTL, + ACTION_OF_SET_NW_TTL_NW_TTL, + ACTION_OF_DEC_NW_TTL, + ACTION_OF_COPY_TTL_OUT, + ACTION_OF_COPY_TTL_IN, }; /** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -721,6 +729,12 @@ static const enum index next_action[] = { ACTION_PHY_PORT, ACTION_PORT_ID, ACTION_METER, + ACTION_OF_SET_MPLS_TTL, + ACTION_OF_DEC_MPLS_TTL, + ACTION_OF_SET_NW_TTL, + ACTION_OF_DEC_NW_TTL, + ACTION_OF_COPY_TTL_OUT, + ACTION_OF_COPY_TTL_IN, ZERO, }; @@ -774,6 +788,18 @@ static const enum index action_meter[] = { ZERO, }; +static const enum index action_of_set_mpls_ttl[] = { + ACTION_OF_SET_MPLS_TTL_MPLS_TTL, + ACTION_NEXT, + ZERO, +}; + +static const enum index action_of_set_nw_ttl[] = { + ACTION_OF_SET_NW_TTL_NW_TTL, + ACTION_NEXT, + ZERO, +}; + static int parse_init(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -2062,6 +2088,68 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)), .call = parse_vc_conf, }, + [ACTION_OF_SET_MPLS_TTL] = { + .name = "of_set_mpls_ttl", + .help = "OpenFlow's OFPAT_SET_MPLS_TTL", + .priv = PRIV_ACTION + (OF_SET_MPLS_TTL, + sizeof(struct rte_flow_action_of_set_mpls_ttl)), + .next = NEXT(action_of_set_mpls_ttl), + .call = parse_vc, + }, + [ACTION_OF_SET_MPLS_TTL_MPLS_TTL] = { + .name = "mpls_ttl", + .help = "MPLS TTL", + .next = NEXT(action_of_set_mpls_ttl, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_mpls_ttl, + mpls_ttl)), + .call = parse_vc_conf, + }, + [ACTION_OF_DEC_MPLS_TTL] = { + .name = "of_dec_mpls_ttl", + .help = "OpenFlow's OFPAT_DEC_MPLS_TTL", + .priv = PRIV_ACTION(OF_DEC_MPLS_TTL, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_OF_SET_NW_TTL] = { + .name = "of_set_nw_ttl", + .help = "OpenFlow's OFPAT_SET_NW_TTL", + .priv = PRIV_ACTION + (OF_SET_NW_TTL, + sizeof(struct rte_flow_action_of_set_nw_ttl)), + .next = NEXT(action_of_set_nw_ttl), + .call = parse_vc, + }, + [ACTION_OF_SET_NW_TTL_NW_TTL] = { + .name = "nw_ttl", + .help = "IP TTL", + .next = NEXT(action_of_set_nw_ttl, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_set_nw_ttl, + nw_ttl)), + .call = parse_vc_conf, + }, + [ACTION_OF_DEC_NW_TTL] = { + .name = "of_dec_nw_ttl", + .help = "OpenFlow's OFPAT_DEC_NW_TTL", + .priv = PRIV_ACTION(OF_DEC_NW_TTL, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_OF_COPY_TTL_OUT] = { + .name = "of_copy_ttl_out", + .help = "OpenFlow's OFPAT_COPY_TTL_OUT", + .priv = PRIV_ACTION(OF_COPY_TTL_OUT, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_OF_COPY_TTL_IN] = { + .name = "of_copy_ttl_in", + .help = "OpenFlow's OFPAT_COPY_TTL_IN", + .priv = PRIV_ACTION(OF_COPY_TTL_IN, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, }; /** Remove and return last entry from argument stack. */ diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c06b76c31..f1b8f5f75 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1105,6 +1105,14 @@ static const struct { MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), MK_FLOW_ACTION(METER, sizeof(struct rte_flow_action_meter)), + MK_FLOW_ACTION(OF_SET_MPLS_TTL, + sizeof(struct rte_flow_action_of_set_mpls_ttl)), + MK_FLOW_ACTION(OF_DEC_MPLS_TTL, 0), + MK_FLOW_ACTION(OF_SET_NW_TTL, + sizeof(struct rte_flow_action_of_set_nw_ttl)), + MK_FLOW_ACTION(OF_DEC_NW_TTL, 0), + MK_FLOW_ACTION(OF_COPY_TTL_OUT, 0), + MK_FLOW_ACTION(OF_COPY_TTL_IN, 0), }; /** Compute storage space needed by action configuration and copy it. */ diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 644076cb9..be946cb8c 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1704,6 +1704,103 @@ fields in the pattern items. | 1 | END | +-------+----------+ +Action: ``OF_SET_MPLS_TTL`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Implements ``OFPAT_SET_MPLS_TTL`` ("MPLS TTL") as defined by the `OpenFlow +Switch Specification`_. + +.. _table_rte_flow_action_of_set_mpls_ttl: + +.. table:: OF_SET_MPLS_TTL + + +--------------+----------+ + | Field | Value | + +==============+==========+ + | ``mpls_ttl`` | MPLS TTL | + +--------------+----------+ + +Action: ``OF_DEC_MPLS_TTL`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Implements ``OFPAT_DEC_MPLS_TTL`` ("decrement MPLS TTL") as defined by the +`OpenFlow Switch Specification`_. + +.. _table_rte_flow_action_of_dec_mpls_ttl: + +.. table:: OF_DEC_MPLS_TTL + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + +Action: ``OF_SET_NW_TTL`` +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Implements ``OFPAT_SET_NW_TTL`` ("IP TTL") as defined by the `OpenFlow +Switch Specification`_. + +.. _table_rte_flow_action_of_set_nw_ttl: + +.. table:: OF_SET_NW_TTL + + +------------+--------+ + | Field | Value | + +============+========+ + | ``nw_ttl`` | IP TTL | + +------------+--------+ + +Action: ``OF_DEC_NW_TTL`` +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Implements ``OFPAT_DEC_NW_TTL`` ("decrement IP TTL") as defined by the +`OpenFlow Switch Specification`_. + +.. _table_rte_flow_action_of_dec_nw_ttl: + +.. table:: OF_DEC_NW_TTL + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + +Action: ``OF_COPY_TTL_OUT`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Implements ``OFPAT_COPY_TTL_OUT`` ("copy TTL "outwards" -- from +next-to-outermost to outermost") as defined by the `OpenFlow Switch +Specification`_. + +.. _table_rte_flow_action_of_copy_ttl_out: + +.. table:: OF_COPY_TTL_OUT + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + +Action: ``OF_COPY_TTL_IN`` +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Implements ``OFPAT_COPY_TTL_IN`` ("copy TTL "inwards" -- from outermost to +next-to-outermost") as defined by the `OpenFlow Switch Specification`_. + +.. _table_rte_flow_action_of_copy_ttl_in: + +.. table:: OF_COPY_TTL_IN + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + Negative types ~~~~~~~~~~~~~~ @@ -2284,3 +2381,5 @@ Future evolutions - Optional software fallback when PMDs are unable to handle requested flow rules so applications do not have to implement their own. + +.. _OpenFlow Switch Specification: https://www.opennetworking.org/software-defined-standards/specifications/ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 8e7cae00b..c223a8a9f 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3477,6 +3477,22 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original DPDK port ID if possible. - ``id {unsigned}``: DPDK port ID. +- ``of_set_mpls_ttl``: OpenFlow's ``OFPAT_SET_MPLS_TTL``. + + - ``mpls_ttl``: MPLS TTL. + +- ``of_dec_mpls_ttl``: OpenFlow's ``OFPAT_DEC_MPLS_TTL``. + +- ``of_set_nw_ttl``: OpenFlow's ``OFPAT_SET_NW_TTL``. + + - ``nw_ttl``: IP TTL. + +- ``of_dec_nw_ttl``: OpenFlow's ``OFPAT_DEC_NW_TTL``. + +- ``of_copy_ttl_out``: OpenFlow's ``OFPAT_COPY_TTL_OUT``. + +- ``of_copy_ttl_in``: OpenFlow's ``OFPAT_COPY_TTL_IN``. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 39fa93baa..e66cfb4c8 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -89,6 +89,14 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(VF, sizeof(struct rte_flow_action_vf)), MK_FLOW_ACTION(PHY_PORT, sizeof(struct rte_flow_action_phy_port)), MK_FLOW_ACTION(PORT_ID, sizeof(struct rte_flow_action_port_id)), + MK_FLOW_ACTION(OF_SET_MPLS_TTL, + sizeof(struct rte_flow_action_of_set_mpls_ttl)), + MK_FLOW_ACTION(OF_DEC_MPLS_TTL, 0), + MK_FLOW_ACTION(OF_SET_NW_TTL, + sizeof(struct rte_flow_action_of_set_nw_ttl)), + MK_FLOW_ACTION(OF_DEC_NW_TTL, 0), + MK_FLOW_ACTION(OF_COPY_TTL_OUT, 0), + MK_FLOW_ACTION(OF_COPY_TTL_IN, 0), }; static int diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index e9b361dda..e8b7ce84f 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1305,7 +1305,57 @@ enum rte_flow_action_type { * * See struct rte_flow_action_security. */ - RTE_FLOW_ACTION_TYPE_SECURITY + RTE_FLOW_ACTION_TYPE_SECURITY, + + /** + * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the + * OpenFlow Switch Specification. + * + * See struct rte_flow_action_of_set_mpls_ttl. + */ + RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL, + + /** + * Implements OFPAT_DEC_MPLS_TTL ("decrement MPLS TTL") as defined + * by the OpenFlow Switch Specification. + * + * No associated configuration structure. + */ + RTE_FLOW_ACTION_TYPE_OF_DEC_MPLS_TTL, + + /** + * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow + * Switch Specification. + * + * See struct rte_flow_action_of_set_nw_ttl. + */ + RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL, + + /** + * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by + * the OpenFlow Switch Specification. + * + * No associated configuration structure. + */ + RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL, + + /** + * Implements OFPAT_COPY_TTL_OUT ("copy TTL "outwards" -- from + * next-to-outermost to outermost") as defined by the OpenFlow + * Switch Specification. + * + * No associated configuration structure. + */ + RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_OUT, + + /** + * Implements OFPAT_COPY_TTL_IN ("copy TTL "inwards" -- from + * outermost to next-to-outermost") as defined by the OpenFlow + * Switch Specification. + * + * No associated configuration structure. + */ + RTE_FLOW_ACTION_TYPE_OF_COPY_TTL_IN, }; /** @@ -1483,6 +1533,26 @@ struct rte_flow_action_security { }; /** + * RTE_FLOW_ACTION_TYPE_OF_SET_MPLS_TTL + * + * Implements OFPAT_SET_MPLS_TTL ("MPLS TTL") as defined by the OpenFlow + * Switch Specification. + */ +struct rte_flow_action_of_set_mpls_ttl { + uint8_t mpls_ttl; /**< MPLS TTL. */ +}; + +/** + * RTE_FLOW_ACTION_TYPE_OF_SET_NW_TTL + * + * Implements OFPAT_SET_NW_TTL ("IP TTL") as defined by the OpenFlow Switch + * Specification. + */ +struct rte_flow_action_of_set_nw_ttl { + uint8_t nw_ttl; /**< IP TTL. */ +}; + +/** * Definition of a single action. * * A list of actions is terminated by a END action. -- 2.11.0