From 7cd048321d1d991dd47ddb54143f7dc701ac116a Mon Sep 17 00:00:00 2001 From: Beilei Xing Date: Thu, 30 Mar 2017 16:29:51 +0800 Subject: [PATCH] ethdev: add MPLS and GRE flow API items 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 3bf8871312..5ee045ee81 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 171a5698ee..8013ecab2d 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, }; /** @@ -598,6 +612,43 @@ struct rte_flow_item_nvgre { uint8_t flow_id; /**< Flow ID. */ }; +/** + * 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. * -- 2.20.1