[dpdk-dev] [PATCH v3 2/3] net/ice: add generic flow API

Wang, Xiao W xiao.w.wang at intel.com
Thu Jun 20 12:21:27 CEST 2019


Hi,

> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Qiming Yang
> Sent: Thursday, June 20, 2019 1:35 PM
> To: dev at dpdk.org
> Cc: Yang, Qiming <qiming.yang at intel.com>
> Subject: [dpdk-dev] [PATCH v3 2/3] net/ice: add generic flow API
> 
> This patch adds ice_flow_create, ice_flow_destroy,
> ice_flow_flush and ice_flow_validate support,
> these are used to handle all the generic filters.
> 
> Signed-off-by: Qiming Yang <qiming.yang at intel.com>
> ---
>  drivers/net/ice/Makefile           |   1 +
>  drivers/net/ice/ice_ethdev.c       |  44 +++
>  drivers/net/ice/ice_ethdev.h       |   5 +
>  drivers/net/ice/ice_generic_flow.c | 682
> +++++++++++++++++++++++++++++++++++++
>  drivers/net/ice/ice_generic_flow.h | 654
> +++++++++++++++++++++++++++++++++++
>  drivers/net/ice/meson.build        |   1 +
>  6 files changed, 1387 insertions(+)
>  create mode 100644 drivers/net/ice/ice_generic_flow.c
>  create mode 100644 drivers/net/ice/ice_generic_flow.h
> 

[...]
> +		case RTE_FLOW_ITEM_TYPE_ETH:
> +			eth_spec = item->spec;
> +			eth_mask = item->mask;
> +
> +			if (eth_spec && eth_mask) {
> +				if (rte_is_broadcast_ether_addr(&eth_mask-
> >src))
> +					input_set |= ICE_INSET_SMAC;
> +				if (rte_is_broadcast_ether_addr(&eth_mask-
> >dst))
> +					input_set |= ICE_INSET_DMAC;
> +				if (eth_mask->type == RTE_BE16(0xffff))
> +					input_set |= ICE_INSET_ETHERTYPE;
> +			}
> +			break;
> +		case RTE_FLOW_ITEM_TYPE_IPV4:
> +			ipv4_spec = item->spec;
> +			ipv4_mask = item->mask;
> +
> +			if (!(ipv4_spec && ipv4_mask)) {
> +				rte_flow_error_set(error, EINVAL,
> +					   RTE_FLOW_ERROR_TYPE_ITEM,
> +					   item,
> +					   "Invalid IPv4 spec or mask.");
> +				return 0;
> +			}
> +
> +			/* Check IPv4 mask and update input set */
> +			if (ipv4_mask->hdr.version_ihl ||
> +			    ipv4_mask->hdr.total_length ||
> +			    ipv4_mask->hdr.packet_id ||
> +			    ipv4_mask->hdr.hdr_checksum) {
> +				rte_flow_error_set(error, EINVAL,
> +					   RTE_FLOW_ERROR_TYPE_ITEM,
> +					   item,
> +					   "Invalid IPv4 mask.");
> +				return 0;
> +			}
> +
> +			if (outer_ip) {
> +				if (ipv4_mask->hdr.src_addr == UINT32_MAX)
> +					input_set |= ICE_INSET_IPV4_SRC;
> +				if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
> +					input_set |= ICE_INSET_IPV4_DST;
> +				if (ipv4_mask->hdr.type_of_service ==
> UINT8_MAX)
> +					input_set |= ICE_INSET_IPV4_TOS;
> +				if (ipv4_mask->hdr.time_to_live ==
> UINT8_MAX)
> +					input_set |= ICE_INSET_IPV4_TTL;
> +				if (ipv4_mask->hdr.fragment_offset == 0)

Seems a typo. fragment_offset --> next_proto_id == UINT8_MAX.

> +					input_set |= ICE_INSET_IPV4_PROTO;
> +				outer_ip = false;
> +			} else {
> +				if (ipv4_mask->hdr.src_addr == UINT32_MAX)
> +					input_set |=
> ICE_INSET_TUN_IPV4_SRC;
> +				if (ipv4_mask->hdr.dst_addr == UINT32_MAX)
> +					input_set |=
> ICE_INSET_TUN_IPV4_DST;
> +				if (ipv4_mask->hdr.time_to_live ==
> UINT8_MAX)
> +					input_set |=
> ICE_INSET_TUN_IPV4_TTL;
> +				if (ipv4_mask->hdr.next_proto_id ==
> UINT8_MAX)
> +					input_set |=
> ICE_INSET_TUN_IPV4_PROTO;
> +			}
> +			break;
> +		case RTE_FLOW_ITEM_TYPE_IPV6:
> +			ipv6_spec = item->spec;
> +			ipv6_mask = item->mask;
> +
> +			if (!(ipv6_spec && ipv6_mask)) {
> +				rte_flow_error_set(error, EINVAL,
> +					RTE_FLOW_ERROR_TYPE_ITEM,
> +					item, "Invalid IPv6 spec or mask");
> +				return 0;
> +			}

[...]

> +/* bit 16 ~ bit 31 */
> +#define ICE_INSET_IPV4_TOS        0x0000000000010000ULL
> +#define ICE_INSET_IPV4_PROTO      0x0000000000020000ULL
> +#define ICE_INSET_IPV4_TTL        0x0000000000040000ULL
> +#define ICE_INSET_IPV6_NEXT_HDR   0x0000000000200000ULL

It's better to align the name to "ICE_INSET_IPV6_PROTO".

> +#define ICE_INSET_IPV6_HOP_LIMIT  0x0000000000400000ULL
> +#define ICE_INSET_ICMP            0x0000000001000000ULL
> +#define ICE_INSET_ICMP6           0x0000000002000000ULL
> +

BRs,
Xiao


More information about the dev mailing list