* Validate MPLS item. * * @param[in] dev * Pointer to the rte_eth_dev structure. * @param[in] item * Item specification. * @param[in] item_flags * Bit-fields that holds the items detected until now. * @param[in] prev_layer * The protocol layer indicated in previous item. * @param[out] error * Pointer to error structure. * * @return * 0 on success, a negative errno value o
| 3807 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 3808 | */ |
| 3809 | int |
| 3810 | mlx5_flow_validate_item_mpls(struct rte_eth_dev *dev __rte_unused, |
| 3811 | const struct rte_flow_item *item __rte_unused, |
| 3812 | uint64_t item_flags __rte_unused, |
| 3813 | uint64_t prev_layer __rte_unused, |
| 3814 | struct rte_flow_error *error) |
| 3815 | { |
| 3816 | #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT |
| 3817 | const struct rte_flow_item_mpls *mask = item->mask; |
| 3818 | struct mlx5_priv *priv = dev->data->dev_private; |
| 3819 | int ret; |
| 3820 | |
| 3821 | if (!priv->sh->dev_cap.mpls_en) |
| 3822 | return rte_flow_error_set(error, ENOTSUP, |
| 3823 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 3824 | "MPLS not supported or" |
| 3825 | " disabled in firmware" |
| 3826 | " configuration."); |
| 3827 | /* MPLS over UDP, GRE is allowed */ |
| 3828 | if (!(prev_layer & (MLX5_FLOW_LAYER_OUTER_L4_UDP | |
| 3829 | MLX5_FLOW_LAYER_GRE | |
| 3830 | MLX5_FLOW_LAYER_GRE_KEY))) |
| 3831 | return rte_flow_error_set(error, EINVAL, |
| 3832 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 3833 | "protocol filtering not compatible" |
| 3834 | " with MPLS layer"); |
| 3835 | /* Multi-tunnel isn't allowed but MPLS over GRE is an exception. */ |
| 3836 | if ((item_flags & MLX5_FLOW_LAYER_TUNNEL) && |
| 3837 | !(item_flags & MLX5_FLOW_LAYER_GRE)) |
| 3838 | return rte_flow_error_set(error, ENOTSUP, |
| 3839 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 3840 | "multiple tunnel layers not" |
| 3841 | " supported"); |
| 3842 | if (!mask) |
| 3843 | mask = &rte_flow_item_mpls_mask; |
| 3844 | ret = mlx5_flow_item_acceptable |
| 3845 | (item, (const uint8_t *)mask, |
| 3846 | (const uint8_t *)&rte_flow_item_mpls_mask, |
| 3847 | sizeof(struct rte_flow_item_mpls), |
| 3848 | MLX5_ITEM_RANGE_NOT_ACCEPTED, error); |
| 3849 | if (ret < 0) |
| 3850 | return ret; |
| 3851 | return 0; |
| 3852 | #else |
| 3853 | return rte_flow_error_set(error, ENOTSUP, |
| 3854 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 3855 | "MPLS is not supported by Verbs, please" |
| 3856 | " update."); |
| 3857 | #endif |
| 3858 | } |
| 3859 | |
| 3860 | /** |
| 3861 | * Validate NVGRE item. |
no test coverage detected