Hi Ferruh and Thomas,

Thanks for your work.

On 2023-01-26 16:19:00 +0000, Ferruh Yigit wrote:
> From: Thomas Monjalon <tho...@monjalon.net>
> 
> As announced in the deprecation notice, flow item structures
> should re-use the protocol header definitions from the directory lib/net/.
> 
> The protocol struct is added in an unnamed union, keeping old field names.
> 
> The GRE header struct members are used in apps and drivers
> instead of the redundant fields in the flow items.
> 
> Signed-off-by: Thomas Monjalon <tho...@monjalon.net>
> ---
>  app/test-flow-perf/items_gen.c           |  4 ++--
>  app/test-pmd/cmdline_flow.c              | 14 +++++------
>  doc/guides/prog_guide/rte_flow.rst       |  6 +----
>  doc/guides/rel_notes/deprecation.rst     |  1 -
>  drivers/net/bnxt/tf_ulp/ulp_rte_parser.c | 12 +++++-----
>  drivers/net/dpaa2/dpaa2_flow.c           | 12 +++++-----
>  drivers/net/mlx5/hws/mlx5dr_definer.c    |  8 +++----
>  drivers/net/mlx5/mlx5_flow.c             | 22 ++++++++---------
>  drivers/net/mlx5/mlx5_flow_dv.c          | 30 +++++++++++++-----------
>  drivers/net/mlx5/mlx5_flow_verbs.c       | 10 ++++----
>  drivers/net/nfp/nfp_flow.c               |  9 +++----

For NFP,

Reviewed-by: Niklas Söderlund <niklas.soderl...@corigine.com>

>  lib/ethdev/rte_flow.h                    | 24 +++++++++++++------
>  lib/net/rte_gre.h                        |  5 ++++
>  13 files changed, 84 insertions(+), 73 deletions(-)
> 
> diff --git a/app/test-flow-perf/items_gen.c b/app/test-flow-perf/items_gen.c
> index a58245239ba1..0f19e5e53648 100644
> --- a/app/test-flow-perf/items_gen.c
> +++ b/app/test-flow-perf/items_gen.c
> @@ -173,10 +173,10 @@ add_gre(struct rte_flow_item *items,
>       __rte_unused struct additional_para para)
>  {
>       static struct rte_flow_item_gre gre_spec = {
> -             .protocol = RTE_BE16(RTE_ETHER_TYPE_TEB),
> +             .hdr.proto = RTE_BE16(RTE_ETHER_TYPE_TEB),
>       };
>       static struct rte_flow_item_gre gre_mask = {
> -             .protocol = RTE_BE16(0xffff),
> +             .hdr.proto = RTE_BE16(0xffff),
>       };
>  
>       items[items_counter].type = RTE_FLOW_ITEM_TYPE_GRE;
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index b904f8c3d45c..0e115956514c 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -4071,7 +4071,7 @@ static const struct token token_list[] = {
>               .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
>                            item_param),
>               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
> -                                          protocol)),
> +                                          hdr.proto)),
>       },
>       [ITEM_GRE_C_RSVD0_VER] = {
>               .name = "c_rsvd0_ver",
> @@ -4082,7 +4082,7 @@ static const struct token token_list[] = {
>               .next = NEXT(item_gre, NEXT_ENTRY(COMMON_UNSIGNED),
>                            item_param),
>               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
> -                                          c_rsvd0_ver)),
> +                                          hdr.c_rsvd0_ver)),
>       },
>       [ITEM_GRE_C_BIT] = {
>               .name = "c_bit",
> @@ -4090,7 +4090,7 @@ static const struct token token_list[] = {
>               .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN),
>                            item_param),
>               .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
> -                                               c_rsvd0_ver,
> +                                               hdr.c_rsvd0_ver,
>                                                 "\x80\x00\x00\x00")),
>       },
>       [ITEM_GRE_S_BIT] = {
> @@ -4098,7 +4098,7 @@ static const struct token token_list[] = {
>               .help = "sequence number bit (S)",
>               .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
>               .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
> -                                               c_rsvd0_ver,
> +                                               hdr.c_rsvd0_ver,
>                                                 "\x10\x00\x00\x00")),
>       },
>       [ITEM_GRE_K_BIT] = {
> @@ -4106,7 +4106,7 @@ static const struct token token_list[] = {
>               .help = "key bit (K)",
>               .next = NEXT(item_gre, NEXT_ENTRY(COMMON_BOOLEAN), item_param),
>               .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_gre,
> -                                               c_rsvd0_ver,
> +                                               hdr.c_rsvd0_ver,
>                                                 "\x20\x00\x00\x00")),
>       },
>       [ITEM_FUZZY] = {
> @@ -7837,7 +7837,7 @@ parse_vc_action_mplsogre_encap(struct context *ctx, 
> const struct token *token,
>               },
>       };
>       struct rte_flow_item_gre gre = {
> -             .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
> +             .hdr.proto = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
>       };
>       struct rte_flow_item_mpls mpls = {
>               .ttl = 0,
> @@ -7935,7 +7935,7 @@ parse_vc_action_mplsogre_decap(struct context *ctx, 
> const struct token *token,
>               },
>       };
>       struct rte_flow_item_gre gre = {
> -             .protocol = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
> +             .hdr.proto = rte_cpu_to_be_16(ETHER_TYPE_MPLS_UNICAST),
>       };
>       struct rte_flow_item_mpls mpls;
>       uint8_t *header;
> diff --git a/doc/guides/prog_guide/rte_flow.rst 
> b/doc/guides/prog_guide/rte_flow.rst
> index 116722351486..603e1b866be3 100644
> --- a/doc/guides/prog_guide/rte_flow.rst
> +++ b/doc/guides/prog_guide/rte_flow.rst
> @@ -980,8 +980,7 @@ Item: ``GRE``
>  
>  Matches a GRE header.
>  
> -- ``c_rsvd0_ver``: checksum, reserved 0 and version.
> -- ``protocol``: protocol type.
> +- ``hdr``:  header definition (``rte_gre.h``).
>  - Default ``mask`` matches protocol only.
>  
>  Item: ``GRE_KEY``
> @@ -1000,9 +999,6 @@ Item: ``GRE_OPTION``
>  Matches a GRE optional fields (checksum/key/sequence).
>  This should be preceded by item ``GRE``.
>  
> -- ``checksum``: checksum.
> -- ``key``: key.
> -- ``sequence``: sequence.
>  - The items in GRE_OPTION do not change bit flags(c_bit/k_bit/s_bit) in GRE
>    item. The bit flags need be set with GRE item by application. When the 
> items
>    present, the corresponding bits in GRE spec and mask should be set "1" by
> diff --git a/doc/guides/rel_notes/deprecation.rst 
> b/doc/guides/rel_notes/deprecation.rst
> index 638051789d19..80bf7209065a 100644
> --- a/doc/guides/rel_notes/deprecation.rst
> +++ b/doc/guides/rel_notes/deprecation.rst
> @@ -68,7 +68,6 @@ Deprecation Notices
>    - ``rte_flow_item_e_tag``
>    - ``rte_flow_item_geneve``
>    - ``rte_flow_item_geneve_opt``
> -  - ``rte_flow_item_gre``
>    - ``rte_flow_item_gtp``
>    - ``rte_flow_item_icmp6``
>    - ``rte_flow_item_icmp6_nd_na``
> diff --git a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c 
> b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
> index 80869b79c3fe..c1e231ce8c49 100644
> --- a/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
> +++ b/drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
> @@ -1461,16 +1461,16 @@ ulp_rte_gre_hdr_handler(const struct rte_flow_item 
> *item,
>               return BNXT_TF_RC_ERROR;
>       }
>  
> -     size = sizeof(((struct rte_flow_item_gre *)NULL)->c_rsvd0_ver);
> +     size = sizeof(((struct rte_flow_item_gre *)NULL)->hdr.c_rsvd0_ver);
>       ulp_rte_prsr_fld_mask(params, &idx, size,
> -                           ulp_deference_struct(gre_spec, c_rsvd0_ver),
> -                           ulp_deference_struct(gre_mask, c_rsvd0_ver),
> +                           ulp_deference_struct(gre_spec, hdr.c_rsvd0_ver),
> +                           ulp_deference_struct(gre_mask, hdr.c_rsvd0_ver),
>                             ULP_PRSR_ACT_DEFAULT);
>  
> -     size = sizeof(((struct rte_flow_item_gre *)NULL)->protocol);
> +     size = sizeof(((struct rte_flow_item_gre *)NULL)->hdr.proto);
>       ulp_rte_prsr_fld_mask(params, &idx, size,
> -                           ulp_deference_struct(gre_spec, protocol),
> -                           ulp_deference_struct(gre_mask, protocol),
> +                           ulp_deference_struct(gre_spec, hdr.proto),
> +                           ulp_deference_struct(gre_mask, hdr.proto),
>                             ULP_PRSR_ACT_DEFAULT);
>  
>       /* Update the hdr_bitmap with GRE */
> diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c
> index eec7e6065097..8a6d44da4875 100644
> --- a/drivers/net/dpaa2/dpaa2_flow.c
> +++ b/drivers/net/dpaa2/dpaa2_flow.c
> @@ -154,7 +154,7 @@ static const struct rte_flow_item_sctp 
> dpaa2_flow_item_sctp_mask = {
>  };
>  
>  static const struct rte_flow_item_gre dpaa2_flow_item_gre_mask = {
> -     .protocol = RTE_BE16(0xffff),
> +     .hdr.proto = RTE_BE16(0xffff),
>  };
>  
>  #endif
> @@ -2792,7 +2792,7 @@ dpaa2_configure_flow_gre(struct rte_flow *flow,
>               return -1;
>       }
>  
> -     if (!mask->protocol)
> +     if (!mask->hdr.proto)
>               return 0;
>  
>       index = dpaa2_flow_extract_search(
> @@ -2841,8 +2841,8 @@ dpaa2_configure_flow_gre(struct rte_flow *flow,
>                               &flow->qos_rule,
>                               NET_PROT_GRE,
>                               NH_FLD_GRE_TYPE,
> -                             &spec->protocol,
> -                             &mask->protocol,
> +                             &spec->hdr.proto,
> +                             &mask->hdr.proto,
>                               sizeof(rte_be16_t));
>       if (ret) {
>               DPAA2_PMD_ERR(
> @@ -2855,8 +2855,8 @@ dpaa2_configure_flow_gre(struct rte_flow *flow,
>                       &flow->fs_rule,
>                       NET_PROT_GRE,
>                       NH_FLD_GRE_TYPE,
> -                     &spec->protocol,
> -                     &mask->protocol,
> +                     &spec->hdr.proto,
> +                     &mask->hdr.proto,
>                       sizeof(rte_be16_t));
>       if (ret) {
>               DPAA2_PMD_ERR(
> diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c 
> b/drivers/net/mlx5/hws/mlx5dr_definer.c
> index 604384a24253..3a438f2c9d12 100644
> --- a/drivers/net/mlx5/hws/mlx5dr_definer.c
> +++ b/drivers/net/mlx5/hws/mlx5dr_definer.c
> @@ -156,8 +156,8 @@ struct mlx5dr_definer_conv_data {
>       X(SET,          source_qp,              v->queue,               
> mlx5_rte_flow_item_sq) \
>       X(SET,          tag,                    v->data,                
> rte_flow_item_tag) \
>       X(SET,          metadata,               v->data,                
> rte_flow_item_meta) \
> -     X(SET_BE16,     gre_c_ver,              v->c_rsvd0_ver,         
> rte_flow_item_gre) \
> -     X(SET_BE16,     gre_protocol_type,      v->protocol,            
> rte_flow_item_gre) \
> +     X(SET_BE16,     gre_c_ver,              v->hdr.c_rsvd0_ver,     
> rte_flow_item_gre) \
> +     X(SET_BE16,     gre_protocol_type,      v->hdr.proto,           
> rte_flow_item_gre) \
>       X(SET,          ipv4_protocol_gre,      IPPROTO_GRE,            
> rte_flow_item_gre) \
>       X(SET_BE32,     gre_opt_key,            v->key.key,             
> rte_flow_item_gre_opt) \
>       X(SET_BE32,     gre_opt_seq,            v->sequence.sequence,   
> rte_flow_item_gre_opt) \
> @@ -1210,7 +1210,7 @@ mlx5dr_definer_conv_item_gre(struct 
> mlx5dr_definer_conv_data *cd,
>       if (!m)
>               return 0;
>  
> -     if (m->c_rsvd0_ver) {
> +     if (m->hdr.c_rsvd0_ver) {
>               fc = &cd->fc[MLX5DR_DEFINER_FNAME_GRE_C_VER];
>               fc->item_idx = item_idx;
>               fc->tag_set = &mlx5dr_definer_gre_c_ver_set;
> @@ -1219,7 +1219,7 @@ mlx5dr_definer_conv_item_gre(struct 
> mlx5dr_definer_conv_data *cd,
>               fc->bit_off = __mlx5_dw_bit_off(header_gre, c_rsvd0_ver);
>       }
>  
> -     if (m->protocol) {
> +     if (m->hdr.proto) {
>               fc = &cd->fc[MLX5DR_DEFINER_FNAME_GRE_PROTOCOL];
>               fc->item_idx = item_idx;
>               fc->tag_set = &mlx5dr_definer_gre_protocol_type_set;
> diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
> index ff08a629e2c6..7b19c5f03f5d 100644
> --- a/drivers/net/mlx5/mlx5_flow.c
> +++ b/drivers/net/mlx5/mlx5_flow.c
> @@ -329,7 +329,7 @@ mlx5_flow_expand_rss_item_complete(const struct 
> rte_flow_item *item)
>               ret = mlx5_ethertype_to_item_type(spec, mask, true);
>               break;
>       case RTE_FLOW_ITEM_TYPE_GRE:
> -             MLX5_XSET_ITEM_MASK_SPEC(gre, protocol);
> +             MLX5_XSET_ITEM_MASK_SPEC(gre, hdr.proto);
>               ret = mlx5_ethertype_to_item_type(spec, mask, true);
>               break;
>       case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
> @@ -3089,8 +3089,7 @@ mlx5_flow_validate_item_gre_key(const struct 
> rte_flow_item *item,
>       if (!gre_mask)
>               gre_mask = &rte_flow_item_gre_mask;
>       gre_spec = gre_item->spec;
> -     if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x2000)) &&
> -                      !(gre_spec->c_rsvd0_ver & RTE_BE16(0x2000)))
> +     if (gre_spec && (gre_mask->hdr.k) && !(gre_spec->hdr.k))
>               return rte_flow_error_set(error, EINVAL,
>                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
>                                         "Key bit must be on");
> @@ -3165,21 +3164,18 @@ mlx5_flow_validate_item_gre_option(struct rte_eth_dev 
> *dev,
>       if (!gre_mask)
>               gre_mask = &rte_flow_item_gre_mask;
>       if (mask->checksum_rsvd.checksum)
> -             if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x8000)) &&
> -                              !(gre_spec->c_rsvd0_ver & RTE_BE16(0x8000)))
> +             if (gre_spec && (gre_mask->hdr.c) && !(gre_spec->hdr.c))
>                       return rte_flow_error_set(error, EINVAL,
>                                                 RTE_FLOW_ERROR_TYPE_ITEM,
>                                                 item,
>                                                 "Checksum bit must be on");
>       if (mask->key.key)
> -             if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x2000)) &&
> -                              !(gre_spec->c_rsvd0_ver & RTE_BE16(0x2000)))
> +             if (gre_spec && (gre_mask->hdr.k) && !(gre_spec->hdr.k))
>                       return rte_flow_error_set(error, EINVAL,
>                                                 RTE_FLOW_ERROR_TYPE_ITEM,
>                                                 item, "Key bit must be on");
>       if (mask->sequence.sequence)
> -             if (gre_spec && (gre_mask->c_rsvd0_ver & RTE_BE16(0x1000)) &&
> -                              !(gre_spec->c_rsvd0_ver & RTE_BE16(0x1000)))
> +             if (gre_spec && (gre_mask->hdr.s) && !(gre_spec->hdr.s))
>                       return rte_flow_error_set(error, EINVAL,
>                                                 RTE_FLOW_ERROR_TYPE_ITEM,
>                                                 item,
> @@ -3230,8 +3226,10 @@ mlx5_flow_validate_item_gre(const struct rte_flow_item 
> *item,
>       const struct rte_flow_item_gre *mask = item->mask;
>       int ret;
>       const struct rte_flow_item_gre nic_mask = {
> -             .c_rsvd0_ver = RTE_BE16(0xB000),
> -             .protocol = RTE_BE16(UINT16_MAX),
> +             .hdr.c = 1,
> +             .hdr.k = 1,
> +             .hdr.s = 1,
> +             .hdr.proto = RTE_BE16(UINT16_MAX),
>       };
>  
>       if (target_protocol != 0xff && target_protocol != IPPROTO_GRE)
> @@ -3259,7 +3257,7 @@ mlx5_flow_validate_item_gre(const struct rte_flow_item 
> *item,
>               return ret;
>  #ifndef HAVE_MLX5DV_DR
>  #ifndef HAVE_IBV_DEVICE_MPLS_SUPPORT
> -     if (spec && (spec->protocol & mask->protocol))
> +     if (spec && (spec->hdr.proto & mask->hdr.proto))
>               return rte_flow_error_set(error, ENOTSUP,
>                                         RTE_FLOW_ERROR_TYPE_ITEM, item,
>                                         "without MPLS support the"
> diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
> index 261c60a5c33a..2b9c2ba6a4b5 100644
> --- a/drivers/net/mlx5/mlx5_flow_dv.c
> +++ b/drivers/net/mlx5/mlx5_flow_dv.c
> @@ -8984,7 +8984,7 @@ static void
>  flow_dv_translate_item_gre(void *key, const struct rte_flow_item *item,
>                          uint64_t pattern_flags, uint32_t key_type)
>  {
> -     static const struct rte_flow_item_gre empty_gre = {0,};
> +     static const struct rte_flow_item_gre empty_gre = {{{0}}};
>       const struct rte_flow_item_gre *gre_m = item->mask;
>       const struct rte_flow_item_gre *gre_v = item->spec;
>       void *headers_v = MLX5_ADDR_OF(fte_match_param, key, outer_headers);
> @@ -9021,8 +9021,8 @@ flow_dv_translate_item_gre(void *key, const struct 
> rte_flow_item *item,
>               gre_v = gre_m;
>       else if (key_type == MLX5_SET_MATCHER_HS_V)
>               gre_m = gre_v;
> -     gre_crks_rsvd0_ver_m.value = rte_be_to_cpu_16(gre_m->c_rsvd0_ver);
> -     gre_crks_rsvd0_ver_v.value = rte_be_to_cpu_16(gre_v->c_rsvd0_ver);
> +     gre_crks_rsvd0_ver_m.value = rte_be_to_cpu_16(gre_m->hdr.c_rsvd0_ver);
> +     gre_crks_rsvd0_ver_v.value = rte_be_to_cpu_16(gre_v->hdr.c_rsvd0_ver);
>       MLX5_SET(fte_match_set_misc, misc_v, gre_c_present,
>                gre_crks_rsvd0_ver_v.c_present &
>                gre_crks_rsvd0_ver_m.c_present);
> @@ -9032,8 +9032,8 @@ flow_dv_translate_item_gre(void *key, const struct 
> rte_flow_item *item,
>       MLX5_SET(fte_match_set_misc, misc_v, gre_s_present,
>                gre_crks_rsvd0_ver_v.s_present &
>                gre_crks_rsvd0_ver_m.s_present);
> -     protocol_m = rte_be_to_cpu_16(gre_m->protocol);
> -     protocol_v = rte_be_to_cpu_16(gre_v->protocol);
> +     protocol_m = rte_be_to_cpu_16(gre_m->hdr.proto);
> +     protocol_v = rte_be_to_cpu_16(gre_v->hdr.proto);
>       if (!protocol_m) {
>               /* Force next protocol to prevent matchers duplication */
>               protocol_v = mlx5_translate_tunnel_etypes(pattern_flags);
> @@ -9072,7 +9072,7 @@ flow_dv_translate_item_gre_option(void *key,
>       const struct rte_flow_item_gre_opt *option_v = item->spec;
>       const struct rte_flow_item_gre *gre_m = gre_item->mask;
>       const struct rte_flow_item_gre *gre_v = gre_item->spec;
> -     static const struct rte_flow_item_gre empty_gre = {0};
> +     static const struct rte_flow_item_gre empty_gre = {{{0}}};
>       struct rte_flow_item gre_key_item;
>       uint16_t c_rsvd0_ver_m, c_rsvd0_ver_v;
>       uint16_t protocol_m, protocol_v;
> @@ -9097,8 +9097,8 @@ flow_dv_translate_item_gre_option(void *key,
>               if (!gre_m)
>                       gre_m = &rte_flow_item_gre_mask;
>       }
> -     protocol_v = gre_v->protocol;
> -     protocol_m = gre_m->protocol;
> +     protocol_v = gre_v->hdr.proto;
> +     protocol_m = gre_m->hdr.proto;
>       if (!protocol_m) {
>               /* Force next protocol to prevent matchers duplication */
>               uint16_t ether_type =
> @@ -9108,8 +9108,8 @@ flow_dv_translate_item_gre_option(void *key,
>                       protocol_m = UINT16_MAX;
>               }
>       }
> -     c_rsvd0_ver_v = gre_v->c_rsvd0_ver;
> -     c_rsvd0_ver_m = gre_m->c_rsvd0_ver;
> +     c_rsvd0_ver_v = gre_v->hdr.c_rsvd0_ver;
> +     c_rsvd0_ver_m = gre_m->hdr.c_rsvd0_ver;
>       if (option_m->sequence.sequence) {
>               c_rsvd0_ver_v |= RTE_BE16(0x1000);
>               c_rsvd0_ver_m |= RTE_BE16(0x1000);
> @@ -9171,12 +9171,14 @@ flow_dv_translate_item_nvgre(void *key, const struct 
> rte_flow_item *item,
>  
>       /* For NVGRE, GRE header fields must be set with defined values. */
>       const struct rte_flow_item_gre gre_spec = {
> -             .c_rsvd0_ver = RTE_BE16(0x2000),
> -             .protocol = RTE_BE16(RTE_ETHER_TYPE_TEB)
> +             .hdr.k = 1,
> +             .hdr.proto = RTE_BE16(RTE_ETHER_TYPE_TEB)
>       };
>       const struct rte_flow_item_gre gre_mask = {
> -             .c_rsvd0_ver = RTE_BE16(0xB000),
> -             .protocol = RTE_BE16(UINT16_MAX),
> +             .hdr.c = 1,
> +             .hdr.k = 1,
> +             .hdr.s = 1,
> +             .hdr.proto = RTE_BE16(UINT16_MAX),
>       };
>       const struct rte_flow_item gre_item = {
>               .spec = &gre_spec,
> diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c 
> b/drivers/net/mlx5/mlx5_flow_verbs.c
> index 4ef4f3044515..291369d437d4 100644
> --- a/drivers/net/mlx5/mlx5_flow_verbs.c
> +++ b/drivers/net/mlx5/mlx5_flow_verbs.c
> @@ -930,7 +930,7 @@ flow_verbs_translate_item_gre(struct mlx5_flow *dev_flow,
>               .size = size,
>       };
>  #else
> -     static const struct rte_flow_item_gre empty_gre = {0,};
> +     static const struct rte_flow_item_gre empty_gre = {{{0}}};
>       const struct rte_flow_item_gre *spec = item->spec;
>       const struct rte_flow_item_gre *mask = item->mask;
>       unsigned int size = sizeof(struct ibv_flow_spec_gre);
> @@ -946,10 +946,10 @@ flow_verbs_translate_item_gre(struct mlx5_flow 
> *dev_flow,
>               if (!mask)
>                       mask = &rte_flow_item_gre_mask;
>       }
> -     tunnel.val.c_ks_res0_ver = spec->c_rsvd0_ver;
> -     tunnel.val.protocol = spec->protocol;
> -     tunnel.mask.c_ks_res0_ver = mask->c_rsvd0_ver;
> -     tunnel.mask.protocol = mask->protocol;
> +     tunnel.val.c_ks_res0_ver = spec->hdr.c_rsvd0_ver;
> +     tunnel.val.protocol = spec->hdr.proto;
> +     tunnel.mask.c_ks_res0_ver = mask->hdr.c_rsvd0_ver;
> +     tunnel.mask.protocol = mask->hdr.proto;
>       /* Remove unwanted bits from values. */
>       tunnel.val.c_ks_res0_ver &= tunnel.mask.c_ks_res0_ver;
>       tunnel.val.key &= tunnel.mask.key;
> diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c
> index bd3a8d2a3b2f..0994fdeeb49f 100644
> --- a/drivers/net/nfp/nfp_flow.c
> +++ b/drivers/net/nfp/nfp_flow.c
> @@ -1812,8 +1812,9 @@ static const struct nfp_flow_item_proc 
> nfp_flow_item_proc_list[] = {
>       [RTE_FLOW_ITEM_TYPE_GRE] = {
>               .next_item = NEXT_ITEM(RTE_FLOW_ITEM_TYPE_GRE_KEY),
>               .mask_support = &(const struct rte_flow_item_gre){
> -                     .c_rsvd0_ver = RTE_BE16(0xa000),
> -                     .protocol = RTE_BE16(0xffff),
> +                     .hdr.c = 1,
> +                     .hdr.k = 1,
> +                     .hdr.proto = RTE_BE16(0xffff),
>               },
>               .mask_default = &rte_flow_item_gre_mask,
>               .mask_sz = sizeof(struct rte_flow_item_gre),
> @@ -3144,7 +3145,7 @@ nfp_flow_action_nvgre_encap_v4(struct nfp_app_fw_flower 
> *app_fw_flower,
>       memset(set_tun, 0, act_set_size);
>       nfp_flow_set_tun_process(set_tun, NFP_FL_TUN_GRE, 0,
>                       ipv4->hdr.time_to_live, ipv4->hdr.type_of_service);
> -     set_tun->tun_proto = gre->protocol;
> +     set_tun->tun_proto = gre->hdr.proto;
>  
>       /* Send the tunnel neighbor cmsg to fw */
>       return nfp_flower_add_tun_neigh_v4_encap(app_fw_flower, nfp_flow_meta,
> @@ -3181,7 +3182,7 @@ nfp_flow_action_nvgre_encap_v6(struct nfp_app_fw_flower 
> *app_fw_flower,
>       tos = (ipv6->hdr.vtc_flow >> RTE_IPV6_HDR_TC_SHIFT) & 0xff;
>       nfp_flow_set_tun_process(set_tun, NFP_FL_TUN_GRE, 0,
>                       ipv6->hdr.hop_limits, tos);
> -     set_tun->tun_proto = gre->protocol;
> +     set_tun->tun_proto = gre->hdr.proto;
>  
>       /* Send the tunnel neighbor cmsg to fw */
>       return nfp_flower_add_tun_neigh_v6_encap(app_fw_flower, nfp_flow_meta,
> diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h
> index e2364823d622..3ae89e367c16 100644
> --- a/lib/ethdev/rte_flow.h
> +++ b/lib/ethdev/rte_flow.h
> @@ -1070,19 +1070,29 @@ static const struct rte_flow_item_mpls 
> rte_flow_item_mpls_mask = {
>   *
>   * Matches a GRE header.
>   */
> +RTE_STD_C11
>  struct rte_flow_item_gre {
> -     /**
> -      * Checksum (1b), reserved 0 (12b), version (3b).
> -      * Refer to RFC 2784.
> -      */
> -     rte_be16_t c_rsvd0_ver;
> -     rte_be16_t protocol; /**< Protocol type. */
> +     union {
> +             struct {
> +                     /*
> +                      * These are old fields kept for compatibility.
> +                      * Please prefer hdr field below.
> +                      */
> +                     /**
> +                      * Checksum (1b), reserved 0 (12b), version (3b).
> +                      * Refer to RFC 2784.
> +                      */
> +                     rte_be16_t c_rsvd0_ver;
> +                     rte_be16_t protocol; /**< Protocol type. */
> +             };
> +             struct rte_gre_hdr hdr; /**< GRE header definition. */
> +     };
>  };
>  
>  /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
>  #ifndef __cplusplus
>  static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
> -     .protocol = RTE_BE16(0xffff),
> +     .hdr.proto = RTE_BE16(UINT16_MAX),
>  };
>  #endif
>  
> diff --git a/lib/net/rte_gre.h b/lib/net/rte_gre.h
> index 6c6aef6fcaa0..210b81c99018 100644
> --- a/lib/net/rte_gre.h
> +++ b/lib/net/rte_gre.h
> @@ -28,6 +28,8 @@ extern "C" {
>   */
>  __extension__
>  struct rte_gre_hdr {
> +     union {
> +             struct {
>  #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
>       uint16_t res2:4; /**< Reserved */
>       uint16_t s:1;    /**< Sequence Number Present bit */
> @@ -45,6 +47,9 @@ struct rte_gre_hdr {
>       uint16_t res3:5; /**< Reserved */
>       uint16_t ver:3;  /**< Version Number */
>  #endif
> +             };
> +             rte_be16_t c_rsvd0_ver;
> +     };
>       uint16_t proto;  /**< Protocol Type */
>  } __rte_packed;
>  
> -- 
> 2.25.1
> 

-- 
Kind Regards,
Niklas Söderlund

Reply via email to