From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id EC70B1B1C8 for ; Mon, 16 Apr 2018 07:16:35 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Apr 2018 22:16:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,458,1517904000"; d="scan'208";a="47206383" Received: from dpdk51.sh.intel.com ([10.67.110.184]) by fmsmga001.fm.intel.com with ESMTP; 15 Apr 2018 22:16:34 -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, 16 Apr 2018 13:16:39 +0800 Message-Id: <20180416051639.188034-5-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180416051639.188034-1-qi.z.zhang@intel.com> References: <1522279780-34842-1-git-send-email-qi.z.zhang@intel.com> <20180416051639.188034-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v3 4/4] ethdev: add VLAN and MPLS pop push action 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: , X-List-Received-Date: Mon, 16 Apr 2018 05:16:36 -0000 Add couple Openflow frienldy VLAN/MPLS push/pop actions. RTE_FLOW_ACTION_VLAN_POP - pop a VLAN header. RTE_FLOW_ACTION_VLAN_PUSH - push a VLAN header. RTE_FLOW_ACTION_MPLS_POP - pop a MPLS header. RTE_FLOW_ACTION_MPLS_PUSH - push a MPLS header. Signed-off-by: Qi Zhang --- app/test-pmd/cmdline_flow.c | 82 +++++++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 69 ++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 14 +++++ lib/librte_ether/rte_flow.h | 71 +++++++++++++++++++++++++ 4 files changed, 236 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index fa35ecc6d..48a3ccdfc 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -196,6 +196,13 @@ enum index { ACTION_IP_TTL_DEC_LVL, ACTION_TTL_COPY_OUT, ACTION_TTL_COPY_IN, + ACTION_VLAN_POP, + ACTION_VLAN_PUSH, + ACTION_VLAN_PUSH_TYPE, + ACTION_MPLS_POP, + ACTION_MPLS_POP_TYPE, + ACTION_MPLS_PUSH, + ACTION_MPLS_PUSH_TYPE, }; /** Size of pattern[] field in struct rte_flow_item_raw. */ @@ -664,6 +671,10 @@ static const enum index next_action[] = { ACTION_IP_TTL_DEC, ACTION_TTL_COPY_OUT, ACTION_TTL_COPY_IN, + ACTION_VLAN_POP, + ACTION_VLAN_PUSH, + ACTION_MPLS_POP, + ACTION_MPLS_PUSH, ZERO, }; @@ -714,6 +725,21 @@ static const enum index action_ip_ttl_dec[] = { ZERO, }; +static const enum index action_vlan_push[] = { + ACTION_VLAN_PUSH_TYPE, + ZERO, +}; + +static const enum index action_mpls_pop[] = { + ACTION_MPLS_POP_TYPE, + ZERO, +}; + +static const enum index action_mpls_push[] = { + ACTION_MPLS_PUSH_TYPE, + ZERO, +}; + static int parse_init(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -1871,6 +1897,62 @@ static const struct token token_list[] = { .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, + + [ACTION_VLAN_POP] = { + .name = "vlan_pop", + .help = "pop the outermost VLAN header.", + .priv = PRIV_ACTION(DROP, 0), + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .call = parse_vc, + }, + [ACTION_VLAN_PUSH] = { + .name = "vlan_push", + .help = "push new VLAN header onto the packet", + .priv = PRIV_ACTION(VLAN_PUSH, + sizeof(struct rte_flow_action_vlan_push)), + .next = NEXT(action_vlan_push), + .call = parse_vc, + }, + [ACTION_VLAN_PUSH_TYPE] = { + .name = "type", + .help = "Ethertype of VLAN header", + .next = NEXT(action_vlan_push, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_vlan_push, + ether_type)), + .call = parse_vc, + }, + [ACTION_MPLS_POP] = { + .name = "mpls_pop", + .help = "pop the outermost MPLS header", + .priv = PRIV_ACTION(MPLS_POP, + sizeof(struct rte_flow_action_mpls_pop)), + .next = NEXT(action_mpls_pop), + .call = parse_vc, + }, + [ACTION_MPLS_POP_TYPE] = { + .name = "type", + .help = "Ethertype of MPLS header", + .next = NEXT(action_mpls_pop, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mpls_pop, + ether_type)), + .call = parse_vc, + }, + [ACTION_MPLS_PUSH] = { + .name = "mpls_push", + .help = "push new MPLS header onto the packet", + .priv = PRIV_ACTION(MPLS_PUSH, + sizeof(struct rte_flow_action_mpls_push)), + .next = NEXT(action_mpls_push), + .call = parse_vc, + }, + [ACTION_MPLS_PUSH_TYPE] = { + .name = "type", + .help = "Ethertype of MPLS header", + .next = NEXT(action_mpls_push, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_mpls_push, + ether_type)), + .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 e81f0e375..bc143c1e9 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1668,6 +1668,75 @@ required MPLS or IP headers. | no properties | +---------------+ +Action: ``ACTION_VLAN_POP`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Pop the outer-most VLAN header from the packet. + +.. _table_rte_flow_action_vlan_pop: + +.. table:: VLAN_POP + + +---------------+ + | Field | + +===============+ + | no properties | + +---------------+ + +Action: ``ACTION_VLAN_PUSH`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Push a new VLAN header onto the packet, Ethertype 0x8100 or 0x88a8 should +be used. The value of VLAN ID and VLAN priority for the new header is copied +from an exist VLAN header in the packet, they will be set to 0 if no such +VLAN header exist. + +.. _table_rte_flow_action_vlan_push: + +.. table:: VLAN_PUSH + + +----------------+------------------------+ + | Field | Value | + +================+========================+ + | ``ether_type`` | Ethertype for VLAN tag | + +----------------+------------------------+ + +Action: ``ACTION_MPLS_POP`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Pop the outer-most MPLS header from the packet, Ethertype is required for +the resulting packet if it is not the last MPLS header be popped, Ethertype +must be 0x8847 or 0x8848. + +.. _table_rte_flow_action_mpls_pop: + +.. table:: MPLS_POP + + +----------------+---------------------------+ + | Field | Value | + +================+===========================+ + | ``ether_type`` | Ethertype for MPLS header | + +----------------+---------------------------+ + +Action: ``ACTION_MPLS_PUSH`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Push a new MPLS header onto the packet, Ethertype 0x8847 or 0x8848 should +be used. The value of MPLS label and traffic class is copied from exist +outermost MPLS header, and TTL is copied from exist outermost MPLS or IP +header, they will be set to 0 if exist packet does not contain required +header. + +.. _table_rte_flow_action_mpls_push: + +.. table:: MPLS_PUSH + + +----------------+---------------------------+ + | Field | Value | + +================+===========================+ + | ``ether_type`` | Ethertype for MPLS header | + +----------------+---------------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 4dd86f10e..76b348439 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3454,6 +3454,20 @@ This section lists supported actions and their attributes, if any. - ``ttl_copy_in``: copy TTL inwards. +- ``vlan_pop``: pop the outermost VLAN header. + +- ``vlan_push``: push new VLAN header onto the packet. + + - ``type``: Ethertype of the VLAN header. + +- ``mpls_pop``: pop the outermost MPLS header. + + - ``type``: Ethertype of the MPLS header. + +- ``mpls_push``: push new MPLS header onto the packet. + + - ``type``: Ethertype of the MPLS header. + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 96a236945..3f7f9dcea 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -1281,6 +1281,41 @@ enum rte_flow_action_type { * packets that contain required protocol headers. */ RTE_FLOW_ACTION_TYPE_TTL_COPY_IN, + + /** + * Pop the outer-most VLAN header from the packet. + */ + RTE_FLOW_ACTION_TYPE_VLAN_POP, + + /** + * Push a new VLAN header onto the packet, Ethertype 0x8100 or 0x88a8 + * should be used. The value of VLAN ID and VLAN priority for the new + * header is copied from an exist VLAN header in the packet, they will + * be set to 0 if no such VLAN header exist. + * + * See struct rte_flow_action_vlan_push. + */ + RTE_FLOW_ACTION_TYPE_VLAN_PUSH, + + /** + * Pop the outer-most MPLS header from the packet, Ethertype is + * required for the resulting packet if it is not the last MPLS + * header be popped, Ethertype must be 0x8847 or 0x8848. + * + * See struct rte_flow_action_mpls_pop. + */ + RTE_FLOW_ACTION_TYPE_MPLS_POP, + + /** + * Push a new MPLS header onto the packet, Ethertype 0x8847 or 0x8848 + * should be used. The value of MPLS label and traffic class is copied + * from exist outermost MPLS header, and TTL is copied from exist + * outermost MPLS or IP header, they will be set to 0 if exist packet + * does not contain required header. + * + * See struct rte_flow_action_mpls_push. + */ + RTE_FLOW_ACTION_TYPE_MPLS_PUSH, }; /** @@ -1497,6 +1532,42 @@ struct rte_flow_action_ip_ttl_dec { }; /** + * RTE_FLOW_ACTION_TYPE_VLAN_PUSH, + * + * Push a new VLAN header onto the packet, Ethertype 0x8100 or 0x88a8 + * should be used. The value of VLAN ID and VLAN priority for the new + * header is copied from an exist outermost VLAN header in the packet, + * they will be set to 0 if no such VLAN header exist. + */ +struct rte_flow_action_vlan_push { + rte_be16_t ether_type; /**< Ethertype for vlan tag. */ +}; + +/** + * RTE_FLOW_ACTION_TYPE_MPLS_POP, + * + * Pop the outer-most MPLS header from the packet, Ethertype is + * required for the resulting packet if it is not the last MPLS + * header be popped, Ethertype must be 0x8847 or 0x8848. + */ +struct rte_flow_action_mpls_pop { + rte_be16_t ether_type; /**< Ethertype for MPLS header */ +}; + +/** + * RTE_FLOW_ACTION_TYPE_MPLS_PUSH, + * + * Push a new MPLS header onto the packet, Ethertype 0x8847 or 0x8848 + * should be used. The value of MPLS label and traffic class are copied + * from exist outermost MPLS header, and TTL is copied from exist outermost + * MPLS or IP header, they will be set to 0, if exist packet does not + * contain required header. + */ +struct rte_flow_action_mpls_push { + rte_be16_t ether_type; /**< Ethertype for MPLS header */ +}; + +/** * Definition of a single action. * * A list of actions is terminated by a END action. -- 2.13.6