This patch implements the change proposes in RFC [1], adding dedicated fields to ETH and VLAN items structs, to clearly define the required characteristic of a packet, and enable precise match criteria. Documentation is updated accordingly.
[1] https://mails.dpdk.org/archives/dev/2020-August/177536.html --- v2: fix checkpatch comment. v3: updates description in comments and documentation. --- Signed-off-by: Dekel Peled <dek...@nvidia.com> --- doc/guides/prog_guide/rte_flow.rst | 14 ++++++++++++-- doc/guides/rel_notes/release_20_11.rst | 7 +++++++ lib/librte_ethdev/rte_flow.h | 18 +++++++++++++++--- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 119b128..9ce3d04 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -908,12 +908,16 @@ order as on the wire. If the ``type`` field contains a TPID value, then only tagged packets with the specified TPID will match the pattern. Otherwise, only untagged packets will match the pattern. -If the ``ETH`` item is the only item in the pattern, and the ``type`` field is -not specified, then both tagged and untagged packets will match the pattern. +The field ``vlan_exist`` can be used to match specific packet types, instead +of using the ``type`` field. +This can be used to match any type of tagged packets. +If the ``type`` and ``vlan_exist`` fields are not specified, then both tagged +and untagged packets will match the pattern. - ``dst``: destination MAC. - ``src``: source MAC. - ``type``: EtherType or TPID. +- ``vlan_exist``: At least one VLAN exist in packet header. - Default ``mask`` matches destination and source addresses only. Item: ``VLAN`` @@ -926,9 +930,15 @@ The corresponding standard outer EtherType (TPID) values are preceding pattern item. If a ``VLAN`` item is present in the pattern, then only tagged packets will match the pattern. +The field ``more_vlans_exist`` can be used to match specific packet types, +instead of using the ``inner_type field``. +This can be used to match any type of tagged packets. +If the ``inner_type`` and ``more_vlans_exist`` fields are not specified, +then any tagged packets will match the pattern. - ``tci``: tag control information. - ``inner_type``: inner EtherType or TPID. +- ``more_vlans_exist``: at least one more VLAN exist in packet header, after this VLAN. - Default ``mask`` matches the VID part of TCI only (lower 12 bits). Item: ``IPV4`` diff --git a/doc/guides/rel_notes/release_20_11.rst b/doc/guides/rel_notes/release_20_11.rst index 0b2a370..aceac07 100644 --- a/doc/guides/rel_notes/release_20_11.rst +++ b/doc/guides/rel_notes/release_20_11.rst @@ -198,6 +198,13 @@ API Changes * vhost: Moved vDPA APIs from experimental to stable. +* ethdev: Added new field ``vlan_exist`` to structure ``rte_flow_item_eth``, + indicating that at least one VLAN exists in the packet header. + +* ethdev: Added new field ``more_vlans_exist`` to structure + ``rte_flow_item_vlan``, indicating that at least one more VLAN exists in + packet header, following this VLAN. + * rawdev: Added a structure size parameter to the functions ``rte_rawdev_queue_setup()``, ``rte_rawdev_queue_conf_get()``, ``rte_rawdev_info_get()`` and ``rte_rawdev_configure()``, diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index da8bfa5..c3ac1e3 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -723,14 +723,18 @@ struct rte_flow_item_raw { * If the @p type field contains a TPID value, then only tagged packets with the * specified TPID will match the pattern. * Otherwise, only untagged packets will match the pattern. - * If the @p ETH item is the only item in the pattern, and the @p type field - * is not specified, then both tagged and untagged packets will match the - * pattern. + * The field @p vlan_exist can be used to match specific packet types, instead + * of using the @p type field. + * This can be used to match any type of tagged packets. + * If the @p type and @p vlan_exist fields are not specified, then both tagged + * and untagged packets will match the pattern. */ struct rte_flow_item_eth { struct rte_ether_addr dst; /**< Destination MAC. */ struct rte_ether_addr src; /**< Source MAC. */ rte_be16_t type; /**< EtherType or TPID. */ + uint32_t vlan_exist:1; /**< At least one VLAN exist in packet header. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_ETH. */ @@ -752,10 +756,18 @@ struct rte_flow_item_eth { * the preceding pattern item. * If a @p VLAN item is present in the pattern, then only tagged packets will * match the pattern. + * The field @p more_vlans_exist can be used to match specific packet types, + * instead of using the @p inner_type field. + * This can be used to match any type of tagged packets. + * If the @p inner_type and @p more_vlans_exist fields are not specified, + * then any tagged packets will match the pattern. */ struct rte_flow_item_vlan { rte_be16_t tci; /**< Tag control information. */ rte_be16_t inner_type; /**< Inner EtherType or TPID. */ + uint32_t more_vlans_exist:1; + /**< At least one more VLAN exist in packet header, after this VLAN. */ + uint32_t reserved:31; /**< Reserved, must be zero. */ }; /** Default mask for RTE_FLOW_ITEM_TYPE_VLAN. */ -- 1.8.3.1