From bc2b5fda61b199f8fad07f123c0f492c2ae35ee6 Mon Sep 17 00:00:00 2001 From: Roman Zhukov Date: Fri, 1 Dec 2017 10:43:15 +0000 Subject: [PATCH] ethdev: add GENEVE flow pattern item Add new pattern item RTE_FLOW_ITEM_TYPE_GENEVE in flow API. Add default mask for the item. Signed-off-by: Roman Zhukov Signed-off-by: Andrew Rybchenko Acked-by: Adrien Mazarguil --- doc/guides/prog_guide/rte_flow.rst | 12 ++++++++++++ lib/librte_ether/rte_flow.c | 1 + lib/librte_ether/rte_flow.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 9de6d32d3b..961943dda3 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -980,6 +980,18 @@ Matches an ESP header. - ``hdr``: ESP header definition (``rte_esp.h``). - Default ``mask`` matches SPI only. +Item: ``GENEVE`` +^^^^^^^^^^^^^^^^ + +Matches a GENEVE header. + +- ``ver_opt_len_o_c_rsvd0``: version (2b), length of the options fields (6b), + OAM packet (1b), critical options present (1b), reserved 0 (6b). +- ``protocol``: protocol type. +- ``vni``: virtual network identifier. +- ``rsvd1``: reserved, normally 0x00. +- Default ``mask`` matches VNI only. + Actions ~~~~~~~ diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c index 6659063035..913d1a55a2 100644 --- a/lib/librte_ether/rte_flow.c +++ b/lib/librte_ether/rte_flow.c @@ -81,6 +81,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(GRE, sizeof(struct rte_flow_item_gre)), MK_FLOW_ITEM(E_TAG, sizeof(struct rte_flow_item_e_tag)), MK_FLOW_ITEM(NVGRE, sizeof(struct rte_flow_item_nvgre)), + MK_FLOW_ITEM(GENEVE, sizeof(struct rte_flow_item_geneve)), }; /** Generate flow_action[] entry. */ diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 47c88ea520..e0402cf92a 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -344,6 +344,13 @@ enum rte_flow_item_type { * See struct rte_flow_item_esp. */ RTE_FLOW_ITEM_TYPE_ESP, + + /** + * Matches a GENEVE header. + * + * See struct rte_flow_item_geneve. + */ + RTE_FLOW_ITEM_TYPE_GENEVE, }; /** @@ -812,6 +819,29 @@ static const struct rte_flow_item_esp rte_flow_item_esp_mask = { }; #endif +/** + * RTE_FLOW_ITEM_TYPE_GENEVE. + * + * Matches a GENEVE header. + */ +struct rte_flow_item_geneve { + /** + * Version (2b), length of the options fields (6b), OAM packet (1b), + * critical options present (1b), reserved 0 (6b). + */ + rte_be16_t ver_opt_len_o_c_rsvd0; + rte_be16_t protocol; /**< Protocol type. */ + uint8_t vni[3]; /**< Virtual Network Identifier. */ + uint8_t rsvd1; /**< Reserved, normally 0x00. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_GENEVE. */ +#ifndef __cplusplus +static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = { + .vni = "\xff\xff\xff", +}; +#endif + /** * Matching pattern item definition. * -- 2.20.1