From patchwork Tue Mar 28 06:40:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xing, Beilei" X-Patchwork-Id: 22489 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 [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 52F1F37AA; Tue, 28 Mar 2017 08:41:37 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 8767236E for ; Tue, 28 Mar 2017 08:41:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490683275; x=1522219275; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=BPP1keLoUN4/ldmklOfZJRGmIPKiTLkVQn4ZFd27kVU=; b=UgwxeB6GN7ftolHhMa8SFW/ZL95670vFEhsHSUQfuqd/UTvH1mKcA4dP JnP7eUBhSj+yYUMUhRBhfD/5C9AB4w==; Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 23:41:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,235,1486454400"; d="scan'208";a="241093085" Received: from unknown (HELO dpdk9.sh.intel.com) ([10.239.129.31]) by fmsmga004.fm.intel.com with ESMTP; 27 Mar 2017 23:41:13 -0700 From: Beilei Xing To: jingjing.wu@intel.com Cc: helin.zhang@intel.com, bernard.iremonger@intel.com, dev@dpdk.org Date: Tue, 28 Mar 2017 14:40:05 +0800 Message-Id: <1490683208-38096-2-git-send-email-beilei.xing@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1490683208-38096-1-git-send-email-beilei.xing@intel.com> References: <1490266669-122137-1-git-send-email-beilei.xing@intel.com> <1490683208-38096-1-git-send-email-beilei.xing@intel.com> Subject: [dpdk-dev] [PATCH v3 1/4] ethdev: add MPLS and GRE items 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" This patch adds MPLS and GRE items to generic rte flow. Signed-off-by: Beilei Xing Acked-by: Adrien Mazarguil --- doc/guides/prog_guide/rte_flow.rst | 21 ++++++++++++++-- lib/librte_ether/rte_flow.h | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 3bf8871..5ee045e 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -187,8 +187,8 @@ Pattern item Pattern items fall in two categories: - Matching protocol headers and packet data (ANY, RAW, ETH, VLAN, IPV4, - IPV6, ICMP, UDP, TCP, SCTP, VXLAN and so on), usually associated with a - specification structure. + IPV6, ICMP, UDP, TCP, SCTP, VXLAN, MPLS, GRE and so on), usually + associated with a specification structure. - Matching meta-data or affecting pattern processing (END, VOID, INVERT, PF, VF, PORT and so on), often without a specification structure. @@ -863,6 +863,23 @@ Matches a VXLAN header (RFC 7348). - ``rsvd1``: reserved, normally 0x00. - Default ``mask`` matches VNI only. +Item: ``MPLS`` +^^^^^^^^^^^^^^ + +Matches a MPLS header. + +- ``label_tc_s_ttl``: label, TC, Bottom of Stack and TTL. +- Default ``mask`` matches label only. + +Item: ``GRE`` +^^^^^^^^^^^^^^ + +Matches a GRE header. + +- ``c_rsvd0_ver``: checksum, reserved 0 and version. +- ``protocol``: protocol type. +- Default ``mask`` matches protocol only. + Actions ~~~~~~~ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 171a569..8013eca 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -282,6 +282,20 @@ enum rte_flow_item_type { * See struct rte_flow_item_nvgre. */ RTE_FLOW_ITEM_TYPE_NVGRE, + + /** + * Matches a MPLS header. + * + * See struct rte_flow_item_mpls. + */ + RTE_FLOW_ITEM_TYPE_MPLS, + + /** + * Matches a GRE header. + * + * See struct rte_flow_item_gre. + */ + RTE_FLOW_ITEM_TYPE_GRE, }; /** @@ -599,6 +613,43 @@ struct rte_flow_item_nvgre { }; /** + * RTE_FLOW_ITEM_TYPE_MPLS. + * + * Matches a MPLS header. + */ +struct rte_flow_item_mpls { + /** + * Label (20b), TC (3b), Bottom of Stack (1b). + */ + uint8_t label_tc_s[3]; + uint8_t ttl; /** Time-to-Live. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */ +static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = { + .label_tc_s = "\xff\xff\xf0", +}; + +/** + * RTE_FLOW_ITEM_TYPE_GRE. + * + * Matches a GRE header. + */ +struct rte_flow_item_gre { + /** + * Checksum (1b), reserved 0 (12b), version (3b). + * Refer to RFC 2784. + */ + uint16_t c_rsvd0_ver; + uint16_t protocol; /**< Protocol type. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */ +static const struct rte_flow_item_gre rte_flow_item_gre_mask = { + .protocol = 0xffff, +}; + +/** * Matching pattern item definition. * * A pattern is formed by stacking items starting from the lowest protocol