[dpdk-dev] [PATCH] doc: add flex item API examples

Ferruh Yigit ferruh.yigit at intel.com
Fri Nov 19 18:08:21 CET 2021


On 11/10/2021 9:38 AM, Gregory Etelson wrote:
> Demonstrate flex item API usage on known network protocols.
> 
> Signed-off-by: Gregory Etelson <getelson at nvidia.com>
> Reviewed-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>

<...>

> +* Match Geneve basic header
> +
> +   .. code-block:: c
> +      :linenos:
> +
> +      const struct geneve_hdr geneve_basic_header_spec = {
> +         .ver = 0,
> +         .opt_len = 0,
> +      };
> +      const struct geneve_hdr geneve_basic_header_mask = {
> +         .ver = 3,
> +         .opt_len = 0x3f,
> +      };
> +
> +      const struct rte_flow_item_flex geneve_basic_header_flex_spec = {
> +         .handle = geneve_flex_handle,
> +         .length = sizeof(geneve_basic_header_spec),
> +         .pattern = &geneve_basic_header_spec
> +      };
> +
> +      const struct rte_flow_item_flex geneve_basic_header_flex_mask = {
> +         .handle = geneve_flex_handle,
> +         .length = sizeof(geneve_basic_header_mask),
> +         .pattern = &geneve_basic_header_mask
> +      };
> +
> +      const struct rte_flow_item geneve_basic_header_flow_item = {
> +         .type = RTE_FLOW_ITEM_TYPE_FLEX,
> +         .spec = (const void *)&geneve_basic_header_flex_spec,
> +         .maks = (const void *)&geneve_basic_header_flex_mask,

s/maks/mask/

> +      };
> +
> +* Match if the first option class is Open vSwitch
> +
> +   .. code-block:: c
> +      :linenos:
> +
> +      const struct geneve_option_hdr geneve_ovs_opt_spec = {
> +         .class = rte_cpu_to_be16(0x0101),
> +      };
> +
> +      const struct geneve_option_hdr geneve_ovs_opt_mask = {
> +         .class = 0xffff,
> +      };
> +
> +      const struct geneve_hdr geneve_hdr_with_ovs_spec = {
> +         .ver = 0,
> +         .options = (const unsigned long *)&geneve_ovs_opt_spec
> +      };
> +
> +      const struct geneve_hdr geneve_hdr_with_ovs_mask = {
> +         .ver = 3,
> +         .options = (const unsigned long *)&geneve_ovs_opt_mask
> +      };
> +
> +      const struct rte_flow_item_flex geneve_flex_spec = {
> +         .handle = geneve_flex_handle,
> +         .length = sizeof(geneve_hdr_with_ovs_spec) + sizeof(geneve_ovs_opt_spec),
> +         .pattern = &geneve_hdr_with_ovs_spec
> +      };
> +
> +      const struct rte_flow_item_flex geneve_flex_mask = {
> +         .handle = geneve_flex_handle,
> +         .length = sizeof(geneve_hdr_with_ovs_mask) + sizeof(geneve_ovs_opt_mask),
> +         .pattern = &geneve_hdr_with_ovs_mask
> +      };
> +
> +      const struct rte_flow_item geneve_vni_flow_item = {
> +         .type = RTE_FLOW_ITEM_TYPE_FLEX,
> +         .spec = (const void *)&geneve_flex_spec,
> +         .maks = (const void *)&geneve_flex_mask,

ditto


More information about the dev mailing list