From patchwork Mon Apr 23 06:36:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zhang X-Patchwork-Id: 38677 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CDB2D2B95; Mon, 23 Apr 2018 08:36:06 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id C99B61E25 for ; Mon, 23 Apr 2018 08:36:01 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Apr 2018 23:36:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,316,1520924400"; d="scan'208";a="33893217" Received: from dpdk51.sh.intel.com ([10.67.110.184]) by fmsmga007.fm.intel.com with ESMTP; 22 Apr 2018 23:35:59 -0700 From: Qi Zhang To: adrien.mazarguil@6wind.com 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, Qi Zhang Date: Mon, 23 Apr 2018 14:36:09 +0800 Message-Id: <20180423063610.246387-3-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180423063610.246387-1-qi.z.zhang@intel.com> References: <1522279780-34842-1-git-send-email-qi.z.zhang@intel.com> <20180423063610.246387-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v4 2/3] ethdev: add TTL change actions in 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add OpenFlow complied TTL change actions. RTE_FLOW_ACTIOn_OF_MPLS_TTL_SET - set MPLS TTL. RTE_FLOW_ACTION_OF_MLPS_TTL_DEC - decrement MPLS TTL. RTE_FLOW_ACTIOn_OF_IP_TTL_SET - set IP TTL. RTE_FLOW_ACTION_OF_IP_TTL_DEC - decrement IP TTL. RTE_FLOW_ACTION_OF_TTL_COPY_OUT - copy TTL outwards. RTE_FLOW_ACTION_OF_TTL_COPY_IN - copy TTL inwards. Suggested-by: Adrien Mazarguil Signed-off-by: Qi Zhang --- app/test-pmd/cmdline_flow.c | 86 ++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 100 ++++++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 16 +++++ lib/librte_ether/rte_flow.h | 78 +++++++++++++++++++++- 4 files changed, 279 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index a9e4f56ba..18a7b4734 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -195,6 +195,14 @@ enum index { ACTION_VF_ID, ACTION_METER, ACTION_METER_ID, + ACTION_OF_MPLS_TTL_SET, + ACTION_OF_MPLS_TTL_SET_TTL, + ACTION_OF_MPLS_TTL_DEC, + ACTION_OF_IP_TTL_SET, + ACTION_OF_IP_TTL_SET_TTL, + ACTION_OF_IP_TTL_DEC, + ACTION_OF_TTL_COPY_OUT, + ACTION_OF_TTL_COPY_IN, }; /** Size of pattern[] field in struct rte_flow_item_raw. */ @@ -668,6 +676,12 @@ static const enum index next_action[] = { ACTION_PF, ACTION_VF, ACTION_METER, + ACTION_OF_MPLS_TTL_SET, + ACTION_OF_MPLS_TTL_DEC, + ACTION_OF_IP_TTL_SET, + ACTION_OF_IP_TTL_DEC, + ACTION_OF_TTL_COPY_OUT, + ACTION_OF_TTL_COPY_IN, ZERO, }; @@ -708,6 +722,18 @@ static const enum index action_meter[] = { ZERO, }; +static const enum index action_of_mpls_ttl_set[] = { + ACTION_OF_MPLS_TTL_SET_TTL, + ACTION_NEXT, + ZERO, +}; + +static const enum index action_of_ip_ttl_set[] = { + ACTION_OF_IP_TTL_SET_TTL, + ACTION_NEXT, + ZERO, +}; + static int parse_init(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1857,6 +1883,66 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)), .call = parse_vc_conf, }, + [ACTION_OF_MPLS_TTL_SET] = { + .name = "of_mpls_ttl_set", + .help = "set MPLS TTL", + .priv = PRIV_ACTION(OF_MPLS_TTL_SET, + sizeof(struct rte_flow_action_of_mpls_ttl_set)), + .next = NEXT(action_of_mpls_ttl_set), + .call = parse_vc, + }, + [ACTION_OF_MPLS_TTL_SET_TTL] = { + .name = "ttl", + .help = "new TTL to set", + .next = NEXT(action_of_mpls_ttl_set, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_mpls_ttl_set, + ttl)), + .call = parse_vc_conf, + }, + [ACTION_OF_MPLS_TTL_DEC] = { + .name = "of_mpls_ttl_dec", + .help = "decrement MPLS TTL", + .priv = PRIV_ACTION(OF_MPLS_TTL_DEC, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_OF_IP_TTL_SET] = { + .name = "of_ip_ttl_set", + .help = "set IP TTL", + .priv = PRIV_ACTION(OF_IP_TTL_SET, + sizeof(struct rte_flow_action_of_ip_ttl_set)), + .next = NEXT(action_of_ip_ttl_set), + .call = parse_vc, + }, + [ACTION_OF_IP_TTL_SET_TTL] = { + .name = "ttl", + .help = "new TTL to set", + .next = NEXT(action_of_ip_ttl_set, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_of_ip_ttl_set, + ttl)), + .call = parse_vc_conf, + }, + [ACTION_OF_IP_TTL_DEC] = { + .name = "of_ip_ttl_dec", + .help = "decrement IPv4 TTL or IPv6 Hop Limit", + .priv = PRIV_ACTION(OF_IP_TTL_DEC, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_OF_TTL_COPY_OUT] = { + .name = "of_ttl_copy_out", + .help = "copy TTL outwards", + .priv = PRIV_ACTION(OF_TTL_COPY_OUT, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_OF_TTL_COPY_IN] = { + .name = "of_ttl_copy_in", + .help = "copy TTL inwards", + .priv = PRIV_ACTION(OF_TTL_COPY_IN, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, }; /** Remove and return last entry from argument stack. */ diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index cfa790417..7b07fe791 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1574,6 +1574,106 @@ fields in the pattern items. | 1 | END | +-------+----------+ +Action: ``OF_MPLS_TTL_SET`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Replace MPLS TTL, only applies to packets that contain MPLS +headers. Comply with OpenFlow action "OFPAT_SET_MPLS_TTL". + +.. _table_rte_flow_action_of_mpls_ttl_set: + +.. table:: OF_MPLS_TTL_SET + + +---------+---------------------+ + | Field | Value | + +=========+=====================+ + | ``ttl`` | new MPLS TTL to set | + +---------+---------------------+ + +Action: ``OF_MPLS_TTL_DEC`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Decrement MPLS TTL, only applies to packets that contain MPLS +headers, Comply with OpenFlow action "OFPAT_DEC_MPLS_TTL". + +.. _table_rte_flow_action_of_mpls_ttl_dec: + +.. table:: OF_MPLS_TTL_DEC + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + +Action: ``OF_IP_TTL_SET`` +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Replace IPv4 TTL or IPv6 Hop Limit field and update the IP checksum, +only applies to packets that contain MPLS headers. Comply with OpenFlow +action "OFPAT_DEC_NW_TTL". + +.. _table_rte_flow_action_of_ip_ttl_set: + +.. table:: OF_IP_TTL_SET + + +---------+---------------------------------------+ + | Field | Value | + +=========+=======================================+ + | ``ttl`` | new IPv4 TTL or IPv6 Hot Limit to set | + +---------+---------------------------------------+ + +Action: ``OF_IP_TTL_DEC`` +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Decrement IPv4 TTL or IPv6 Hop Limit field and update the IP checksum, +only applies to packets that contain MPLS headers. Comply with OpenFlow +action "OFPAT_DEC_NW_TTL". + +.. _table_rte_flow_action_of_ip_ttl_dec: + +.. table:: OF_IP_TTL_DEC + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + +Action: ``OF_TTL_COPY_OUT`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Copy the TTL from next-to-outermost to outermost header with TTL, copy can +be IP to IP, MPLS to MPLS or IP to MPLS, only applies packets that contain +required MPLS or IP headers. Comply with OpenFlow action "OFPAT_COPY_TTL_OUT". + +.. _table_rte_flow_action_of_ttl_copy_out: + +.. table:: OF_TTL_COPY_OUT + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + +Action: ``OF_TTL_COPY_IN`` +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Copy the TTL from outermost to next-to-outermost header with TTL, copy can +be IP to IP, MPLS to MPLS or MPLS to IP, only applies packets that contain +required MPLS or IP headers. Comply with OpenFlow action "OFPAT_COPY_TTL_IN". + +.. _table_rte_flow_action_of_ttl_copy_in: + +.. table:: OF_TTL_COPY_IN + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index d2d084bb2..c1bc53741 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3449,6 +3449,22 @@ This section lists supported actions and their attributes, if any. - ``original {boolean}``: use original VF ID if possible. - ``id {unsigned}``: VF ID to redirect packets to. +- ``of_mpls_ttl_set``: set MPLS TTL (note: OpenFlow comply). + + - ``ttl``: new TTL to set. + +- ``of_mpls_ttl_dec``: decrement MPLS TTL (note: OpenFlow comply). + +- ``of_ip_ttl_set``: set IPv4 TTL or IPv6 Hot Limit (note: OpenFlow comply). + + - ``ttl``: new TTL to set. + +- ``of_ip_ttl_dec``: decrement IPv4 TTL or IPv6 Hot Limit (note: OpenFlow comply). + +- ``of_ttl_copy_out``: copy TTL outwards (note: OpenFlow comply). + +- ``of_ttl_copy_in``: copy TTL inwards (note: OpenFlow comply). + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 25581513d..72819abd2 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1245,7 +1245,62 @@ enum rte_flow_action_type { * * See struct rte_flow_action_security. */ - RTE_FLOW_ACTION_TYPE_SECURITY + RTE_FLOW_ACTION_TYPE_SECURITY, + + /** + * Replace MPLS TTL, only applies to packets that contain + * MPLS header. Comply with OpenFlow action "OFPAT_SET_MPLS_TTL". + * + * See struct rte_flow_action_of_mpls_ttl_set. + */ + RTE_FLOW_ACTION_TYPE_OF_MPLS_TTL_SET, + + + /** + * Decrement MPLS TTL, only applies to packets that contain + * MPLS header. Comply with OpenFlow action "OFPAT_DEC_MPLS_TTL". + * + * No associated configuration structure. + */ + RTE_FLOW_ACTION_TYPE_OF_MPLS_TTL_DEC, + + /** + * Replace IPv4 TTL or IPv6 Hop Limit field and update the IP + * checksum, only applies to packets that contain IPv4 or IPv6 + * header. Comply with OpenFlow action "OFPAT_SET_NW_TTL". + * + * See struct rte_flow_action_of_ip_ttl_set. + */ + RTE_FLOW_ACTION_TYPE_OF_IP_TTL_SET, + + /** + * Decrement IPv4 TTL or IPv6 Hop Limit field and update the IP + * checksum, only applies to packets that contain IPv4 or IPv6 + * header. Comply with OpenFlow action "OFPAT_DEC_NW_TTL". + * + * No associated configuration structure. + */ + RTE_FLOW_ACTION_TYPE_OF_IP_TTL_DEC, + + /** + * Copy the TTL from next-to-outermost to outermost header with TTL, + * copy can be IP to IP, MPLS to MPLS or IP to MPLS, only applies + * packets that contain required protocol headers. Comply with OpenFlow + * action "OFPAT_COPY_TTL_OUT". + * + * No associated configuration structure. + */ + RTE_FLOW_ACTION_TYPE_OF_TTL_COPY_OUT, + + /** + * Copy the TTL from outermost to next-to-outermost header with TTL, + * copy can be IP to IP, MPLS to MPLS or MPLS to IP, only applies + * packets that contain required protocol headers. Comply with OpenFlow + * action "OFPAT_COPY_TTL_IN". + * + * No associated configuration structure. + */ + RTE_FLOW_ACTION_TYPE_OF_TTL_COPY_IN, }; /** @@ -1384,6 +1439,27 @@ struct rte_flow_action_security { }; /** + * RTE_FLOW_ACTION_TYPE_OF_MPLS_TTL_SET + * + * Replace MPLS TTL, only applies to packets that contain MPLS header. + * Comply with OpenFlow action "OFPAT_SET_MPLS_TTL". + */ +struct rte_flow_action_of_mpls_ttl_set { + uint8_t ttl; /**< New TTL to set */ +}; + +/** + * RTE_FLOW_ACTION_TYPE_OF_IP_TTL_SET + * + * Replace IPv4 TTL or IPv6 Hop Limit field and update the IP + * checksum, only applies to packets that contain IPv4 or IPv6 + * header. Comply with OpenFlow action "OFPAT_SET_NW_TTL". + */ +struct rte_flow_action_of_ip_ttl_set { + uint8_t ttl; /**< New TTL or Hop Limit to set */ +}; + +/** * Definition of a single action. * * A list of actions is terminated by a END action.