MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx5_flow_validate_item_gre

Function mlx5_flow_validate_item_gre

dpdk/drivers/net/mlx5/mlx5_flow.c:3512–3560  ·  view source on GitHub ↗

* Validate GRE item. * * @param[in] item * Item specification. * @param[in] item_flags * Bit flags to mark detected items. * @param[in] target_protocol * The next protocol in the previous item. * @param[out] error * Pointer to error structure. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */

Source from the content-addressed store, hash-verified

3510 * 0 on success, a negative errno value otherwise and rte_errno is set.
3511 */
3512int
3513mlx5_flow_validate_item_gre(const struct rte_flow_item *item,
3514 uint64_t item_flags,
3515 uint8_t target_protocol,
3516 struct rte_flow_error *error)
3517{
3518 const struct rte_flow_item_gre *spec __rte_unused = item->spec;
3519 const struct rte_flow_item_gre *mask = item->mask;
3520 int ret;
3521 const struct rte_flow_item_gre nic_mask = {
3522 .c_rsvd0_ver = RTE_BE16(0xB000),
3523 .protocol = RTE_BE16(UINT16_MAX),
3524 };
3525
3526 if (target_protocol != 0xff && target_protocol != IPPROTO_GRE)
3527 return rte_flow_error_set(error, EINVAL,
3528 RTE_FLOW_ERROR_TYPE_ITEM, item,
3529 "protocol filtering not compatible"
3530 " with this GRE layer");
3531 if (item_flags & MLX5_FLOW_LAYER_TUNNEL)
3532 return rte_flow_error_set(error, ENOTSUP,
3533 RTE_FLOW_ERROR_TYPE_ITEM, item,
3534 "multiple tunnel layers not"
3535 " supported");
3536 if (!(item_flags & MLX5_FLOW_LAYER_OUTER_L3))
3537 return rte_flow_error_set(error, ENOTSUP,
3538 RTE_FLOW_ERROR_TYPE_ITEM, item,
3539 "L3 Layer is missing");
3540 if (!mask)
3541 mask = &rte_flow_item_gre_mask;
3542 ret = mlx5_flow_item_acceptable
3543 (item, (const uint8_t *)mask,
3544 (const uint8_t *)&nic_mask,
3545 sizeof(struct rte_flow_item_gre), MLX5_ITEM_RANGE_NOT_ACCEPTED,
3546 error);
3547 if (ret < 0)
3548 return ret;
3549#ifndef HAVE_MLX5DV_DR
3550#ifndef HAVE_IBV_DEVICE_MPLS_SUPPORT
3551 if (spec && (spec->protocol & mask->protocol))
3552 return rte_flow_error_set(error, ENOTSUP,
3553 RTE_FLOW_ERROR_TYPE_ITEM, item,
3554 "without MPLS support the"
3555 " specification cannot be used for"
3556 " filtering");
3557#endif
3558#endif
3559 return 0;
3560}
3561
3562/**
3563 * Validate Geneve item.

Callers 2

flow_dv_validateFunction · 0.85
flow_verbs_validateFunction · 0.85

Calls 2

rte_flow_error_setFunction · 0.85

Tested by

no test coverage detected