* Validate Ethernet item. * * @param[in] item * Item specification. * @param[in] item_flags * Bit-fields that holds the items detected until now. * @param[out] error * Pointer to error structure. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */
| 2715 | * 0 on success, a negative errno value otherwise and rte_errno is set. |
| 2716 | */ |
| 2717 | int |
| 2718 | mlx5_flow_validate_item_eth(const struct rte_flow_item *item, |
| 2719 | uint64_t item_flags, bool ext_vlan_sup, |
| 2720 | struct rte_flow_error *error) |
| 2721 | { |
| 2722 | const struct rte_flow_item_eth *mask = item->mask; |
| 2723 | const struct rte_flow_item_eth nic_mask = { |
| 2724 | .hdr.dst_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", |
| 2725 | .hdr.src_addr.addr_bytes = "\xff\xff\xff\xff\xff\xff", |
| 2726 | .hdr.ether_type = RTE_BE16(0xffff), |
| 2727 | .has_vlan = ext_vlan_sup ? 1 : 0, |
| 2728 | }; |
| 2729 | int ret; |
| 2730 | int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); |
| 2731 | const uint64_t ethm = tunnel ? MLX5_FLOW_LAYER_INNER_L2 : |
| 2732 | MLX5_FLOW_LAYER_OUTER_L2; |
| 2733 | |
| 2734 | if (item_flags & ethm) |
| 2735 | return rte_flow_error_set(error, ENOTSUP, |
| 2736 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 2737 | "multiple L2 layers not supported"); |
| 2738 | if ((!tunnel && (item_flags & MLX5_FLOW_LAYER_OUTER_L3)) || |
| 2739 | (tunnel && (item_flags & MLX5_FLOW_LAYER_INNER_L3))) |
| 2740 | return rte_flow_error_set(error, EINVAL, |
| 2741 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 2742 | "L2 layer should not follow " |
| 2743 | "L3 layers"); |
| 2744 | if ((!tunnel && (item_flags & MLX5_FLOW_LAYER_OUTER_VLAN)) || |
| 2745 | (tunnel && (item_flags & MLX5_FLOW_LAYER_INNER_VLAN))) |
| 2746 | return rte_flow_error_set(error, EINVAL, |
| 2747 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 2748 | "L2 layer should not follow VLAN"); |
| 2749 | if (item_flags & MLX5_FLOW_LAYER_GTP) |
| 2750 | return rte_flow_error_set(error, EINVAL, |
| 2751 | RTE_FLOW_ERROR_TYPE_ITEM, item, |
| 2752 | "L2 layer should not follow GTP"); |
| 2753 | if (!mask) |
| 2754 | mask = &rte_flow_item_eth_mask; |
| 2755 | ret = mlx5_flow_item_acceptable(item, (const uint8_t *)mask, |
| 2756 | (const uint8_t *)&nic_mask, |
| 2757 | sizeof(struct rte_flow_item_eth), |
| 2758 | MLX5_ITEM_RANGE_NOT_ACCEPTED, error); |
| 2759 | return ret; |
| 2760 | } |
| 2761 | |
| 2762 | /** |
| 2763 | * Validate VLAN item. |
no test coverage detected