[PATCH v6 2/3] ethdev: add compare item

Suanming Mou suanmingm at nvidia.com
Mon Feb 5 14:28:21 CET 2024


Hi Thomas,

> -----Original Message-----
> From: Thomas Monjalon <thomas at monjalon.net>
> Sent: Monday, February 5, 2024 9:01 PM
> To: Suanming Mou <suanmingm at nvidia.com>
> Cc: ferruh.yigit at amd.com; Ori Kam <orika at nvidia.com>; Aman Singh
> <aman.deep.singh at intel.com>; Yuying Zhang <yuying.zhang at intel.com>;
> Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>; dev at dpdk.org
> Subject: Re: [PATCH v6 2/3] ethdev: add compare item
> 
> 02/02/2024 01:42, Suanming Mou:
> > --- a/doc/guides/rel_notes/release_24_03.rst
> > +++ b/doc/guides/rel_notes/release_24_03.rst
> > +* **Added compare flow matching criteria.**
> 
> Suggestion:
> "Added flow matching with various comparisons."
> Not sure how to illustrate the idea.

What about " Added flow matching with various comparison results." ?

> 
> > +  Added ``RTE_FLOW_ITEM_TYPE_COMPARE`` to allow matching on compare
> 
> s/compare/comparison/
> 
> > +  result between the packet fields or value.
> 
> remove "the"
> 
> 
> > --- a/lib/ethdev/rte_flow.h
> > +++ b/lib/ethdev/rte_flow.h
> > +	/**
> > +	 * Matches the packet with compare result.
> 
> Match packet with various comparison types.
> 
> > +	 *
> > +	 * See struct rte_flow_item_compare.
> > +	 */
> > +	RTE_FLOW_ITEM_TYPE_COMPARE,
> >  };
> >
> >  /**
> > @@ -2365,6 +2372,182 @@ static const struct rte_flow_item_ptype
> > rte_flow_item_ptype_mask = {  };  #endif
> >
> > +/**
> > + * Field IDs for packet field.
> > + * e.g. the packet field IDs used in
> > +RTE_FLOW_ACTION_TYPE_MODIFY_FIELD
> > + * and RTE_FLOW_ITEM_TYPE_COMPARE.
> > + */
> > +enum rte_flow_field_id {
> > +	RTE_FLOW_FIELD_START = 0,	/**< Start of a packet. */
> > +	RTE_FLOW_FIELD_MAC_DST,		/**< Destination MAC Address.
> */
> > +	RTE_FLOW_FIELD_MAC_SRC,		/**< Source MAC Address. */
> > +	RTE_FLOW_FIELD_VLAN_TYPE,	/**< VLAN Tag Identifier. */
> > +	RTE_FLOW_FIELD_VLAN_ID,		/**< VLAN Identifier. */
> > +	RTE_FLOW_FIELD_MAC_TYPE,	/**< EtherType. */
> > +	RTE_FLOW_FIELD_IPV4_DSCP,	/**< IPv4 DSCP. */
> > +	RTE_FLOW_FIELD_IPV4_TTL,	/**< IPv4 Time To Live. */
> > +	RTE_FLOW_FIELD_IPV4_SRC,	/**< IPv4 Source Address. */
> > +	RTE_FLOW_FIELD_IPV4_DST,	/**< IPv4 Destination Address. */
> > +	RTE_FLOW_FIELD_IPV6_DSCP,	/**< IPv6 DSCP. */
> > +	RTE_FLOW_FIELD_IPV6_HOPLIMIT,	/**< IPv6 Hop Limit. */
> > +	RTE_FLOW_FIELD_IPV6_SRC,	/**< IPv6 Source Address. */
> > +	RTE_FLOW_FIELD_IPV6_DST,	/**< IPv6 Destination Address. */
> > +	RTE_FLOW_FIELD_TCP_PORT_SRC,	/**< TCP Source Port Number.
> */
> > +	RTE_FLOW_FIELD_TCP_PORT_DST,	/**< TCP Destination Port
> Number. */
> > +	RTE_FLOW_FIELD_TCP_SEQ_NUM,	/**< TCP Sequence Number. */
> > +	RTE_FLOW_FIELD_TCP_ACK_NUM,	/**< TCP Acknowledgment
> Number. */
> > +	RTE_FLOW_FIELD_TCP_FLAGS,	/**< TCP Flags. */
> > +	RTE_FLOW_FIELD_UDP_PORT_SRC,	/**< UDP Source Port Number.
> */
> > +	RTE_FLOW_FIELD_UDP_PORT_DST,	/**< UDP Destination Port
> Number. */
> > +	RTE_FLOW_FIELD_VXLAN_VNI,	/**< VXLAN Network Identifier. */
> > +	RTE_FLOW_FIELD_GENEVE_VNI,	/**< GENEVE Network
> Identifier. */
> > +	RTE_FLOW_FIELD_GTP_TEID,	/**< GTP Tunnel Endpoint Identifier. */
> > +	RTE_FLOW_FIELD_TAG,		/**< Tag value. */
> > +	RTE_FLOW_FIELD_MARK,		/**< Mark value. */
> > +	RTE_FLOW_FIELD_META,		/**< Metadata value. */
> > +	RTE_FLOW_FIELD_POINTER,		/**< Memory pointer. */
> > +	RTE_FLOW_FIELD_VALUE,		/**< Immediate value. */
> > +	RTE_FLOW_FIELD_IPV4_ECN,	/**< IPv4 ECN. */
> > +	RTE_FLOW_FIELD_IPV6_ECN,	/**< IPv6 ECN. */
> > +	RTE_FLOW_FIELD_GTP_PSC_QFI,	/**< GTP QFI. */
> > +	RTE_FLOW_FIELD_METER_COLOR,	/**< Meter color marker. */
> > +	RTE_FLOW_FIELD_IPV6_PROTO,	/**< IPv6 next header. */
> > +	RTE_FLOW_FIELD_FLEX_ITEM,	/**< Flex item. */
> > +	RTE_FLOW_FIELD_HASH_RESULT,	/**< Hash result. */
> > +	RTE_FLOW_FIELD_GENEVE_OPT_TYPE,	/**< GENEVE option type. */
> > +	RTE_FLOW_FIELD_GENEVE_OPT_CLASS,/**< GENEVE option class. */
> > +	RTE_FLOW_FIELD_GENEVE_OPT_DATA,	/**< GENEVE option data. */
> > +	RTE_FLOW_FIELD_MPLS,		/**< MPLS header. */
> > +	RTE_FLOW_FIELD_TCP_DATA_OFFSET,	/**< TCP data offset. */
> > +	RTE_FLOW_FIELD_IPV4_IHL,	/**< IPv4 IHL. */
> > +	RTE_FLOW_FIELD_IPV4_TOTAL_LEN,	/**< IPv4 total length. */
> > +	RTE_FLOW_FIELD_IPV6_PAYLOAD_LEN,/**< IPv6 payload length. */
> > +	RTE_FLOW_FIELD_RANDOM		/**< Random value. */
> > +};
> 
> You should use spaces for aligmnent of the comments.

Sorry, the original code is not using spaces. 
Anyway, never mind, since I touched that, let me format them with spaces.

> 
> [...]
> > +struct rte_flow_field_data {
> > +	enum rte_flow_field_id field; /**< Field or memory type ID. */
> > +	union {
> > +		struct {
> > +			/** Encapsulation level and tag index or flex item
> handle. */
> > +			union {
> > +				struct {
> > +					/**
> > +					 * Packet encapsulation level containing
> > +					 * the field to modify.
> > +					 *
> > +					 * - @p 0 requests the default behavior.
> > +					 *   Depending on the packet type, it
> > +					 *   can mean outermost, innermost or
> > +					 *   anything in between.
> > +					 *
> > +					 *   It basically stands for the
> > +					 *   innermost encapsulation level.
> > +					 *   Modification can be performed
> > +					 *   according to PMD and device
> > +					 *   capabilities.
> > +					 *
> > +					 * - @p 1 requests modification to be
> > +					 *   performed on the outermost packet
> > +					 *   encapsulation level.
> > +					 *
> > +					 * - @p 2 and subsequent values
> request
> > +					 *   modification to be performed on
> > +					 *   the specified inner packet
> > +					 *   encapsulation level, from
> > +					 *   outermost to innermost (lower to
> > +					 *   higher values).
> > +					 *
> > +					 * Values other than @p 0 are not
> > +					 * necessarily supported.
> > +					 *
> > +					 * @note that for MPLS field,
> > +					 * encapsulation level also include
> > +					 * tunnel since MPLS may appear in
> > +					 * outer, inner or tunnel.
> > +					 */
> > +					uint8_t level;
> > +					union {
> > +						/**
> > +						 * Tag index array inside
> > +						 * encapsulation level.
> > +						 * Used for VLAN, MPLS or TAG
> types.
> > +						 */
> > +						uint8_t tag_index;
> > +						/**
> > +						 * Geneve option identifier.
> > +						 * Relevant only for
> > +						 *
> RTE_FLOW_FIELD_GENEVE_OPT_XXXX
> > +						 * modification type.
> > +						 */
> > +						struct {
> > +							/**
> > +							 * Geneve option type.
> > +							 */
> > +							uint8_t type;
> > +							/**
> > +							 * Geneve option class.
> > +							 */
> > +							rte_be16_t class_id;
> > +						};
> > +					};
> > +				};
> > +				struct rte_flow_item_flex_handle *flex_handle;
> > +			};
> > +			/** Number of bits to skip from a field. */
> > +			uint32_t offset;
> > +		};
> > +		/**
> > +		 * Immediate value for RTE_FLOW_FIELD_VALUE, presented in
> the
> > +		 * same byte order and length as in relevant rte_flow_item_xxx.
> > +		 * The immediate source bitfield offset is inherited from
> > +		 * the destination's one.
> > +		 */
> > +		uint8_t value[16];
> > +		/**
> > +		 * Memory address for RTE_FLOW_FIELD_POINTER, memory
> layout
> > +		 * should be the same as for relevant field in the
> > +		 * rte_flow_item_xxx structure.
> > +		 */
> > +		void *pvalue;
> > +	};
> > +};
> > +
> > +/**
> > + * Expected operation types for compare item.
> > + */
> > +enum rte_flow_item_compare_op {
> > +	RTE_FLOW_ITEM_COMPARE_EQ,	/* Compare result equal. */
> > +	RTE_FLOW_ITEM_COMPARE_NE,	/* Compare result not equal. */
> > +	RTE_FLOW_ITEM_COMPARE_LT,	/* Compare result less than. */
> > +	RTE_FLOW_ITEM_COMPARE_LE,	/* Compare result less than or
> equal. */
> > +	RTE_FLOW_ITEM_COMPARE_GT,	/* Compare result great than.
> */
> > +	RTE_FLOW_ITEM_COMPARE_GE,	/* Compare result great than or
> equal. */
> > +};
> 
> It's a pity we cannot easily what changed because it moved.
> Maybe make the move in a separate patch before changing it?


Since you are the second one concern about that, I will split the move to a separate patch before.

> 



More information about the dev mailing list