From 86e1974a42aa146253c81c5cf73a50f7de229b8b Mon Sep 17 00:00:00 2001 From: Kiran Kumar K Date: Thu, 25 Jul 2019 14:33:43 +0530 Subject: [PATCH] ethdev: add NSH key field to flow API Add new rte_flow_item_nsh in order to match the network service header based on RFC 8300. Signed-off-by: Kiran Kumar K Reviewed-by: Ferruh Yigit --- doc/guides/prog_guide/rte_flow.rst | 18 ++++++++++++++ lib/librte_ethdev/rte_flow.c | 1 + lib/librte_ethdev/rte_flow.h | 39 ++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index ff6fb11861..3428b65b20 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1247,6 +1247,24 @@ Matches a PPPoE session protocol identifier. | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" | +----------+----------+---------------------------------------+ +Item: ``NSH`` +^^^^^^^^^^^^^ + +Matches a network service header (RFC 8300). + +- ``version``: normally 0x0 (2 bits). +- ``oam_pkt``: indicate oam packet (1 bit). +- ``reserved``: reserved bit (1 bit). +- ``ttl``: maximum SFF hopes (6 bits). +- ``length``: total length in 4 bytes words (6 bits). +- ``reserved1``: reserved1 bits (4 bits). +- ``mdtype``: ndicates format of NSH header (4 bits). +- ``next_proto``: indicates protocol type of encap data (8 bits). +- ``spi``: service path identifier (3 bytes). +- ``sindex``: service index (1 byte). +- Default ``mask`` matches mdtype, next_proto, spi, sindex. + + Actions ~~~~~~~ diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index cc03b159ff..62263ff244 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -80,6 +80,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { MK_FLOW_ITEM(PPPOED, sizeof(struct rte_flow_item_pppoe)), MK_FLOW_ITEM(PPPOE_PROTO_ID, sizeof(struct rte_flow_item_pppoe_proto_id)), + MK_FLOW_ITEM(NSH, sizeof(struct rte_flow_item_nsh)), }; /** Generate flow_action[] entry. */ diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 391a44a576..d1dcab8f81 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -470,6 +470,13 @@ enum rte_flow_item_type { * See struct rte_flow_item_pppoe_proto_id. */ RTE_FLOW_ITEM_TYPE_PPPOE_PROTO_ID, + + /** + * Matches Network service header (NSH). + * See struct rte_flow_item_nsh. + * + */ + RTE_FLOW_ITEM_TYPE_NSH, }; /** @@ -1307,6 +1314,38 @@ struct rte_flow_item_mark { uint32_t id; /**< Integer value to match against. */ }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_NSH + * + * Match network service header (NSH), RFC 8300 + * + */ +struct rte_flow_item_nsh { + uint32_t version:2; + uint32_t oam_pkt:1; + uint32_t reserved:1; + uint32_t ttl:6; + uint32_t length:6; + uint32_t reserved1:4; + uint32_t mdtype:4; + uint32_t next_proto:8; + uint32_t spi:24; + uint32_t sindex:8; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_NSH. */ +#ifndef __cplusplus +static const struct rte_flow_item_nsh rte_flow_item_nsh_mask = { + .mdtype = 0xf, + .next_proto = 0xff, + .spi = 0xffffff, + .sindex = 0xff, +}; +#endif + /** * Matching pattern item definition. * -- 2.20.1