Skip to contentSkip to conversation

support flow subscription

PATCH Superseded Jie Wang 3 participants 40 messages Aug 9, 2022 – Sep 7, 2022

Subsystems (2)
lore
Share & tools
lore

Jie Wang

author
#0 lore raw

cover support flow subscription

Add support AVF can be able to subscribe a flow from PF.

Jie Wang (2):
common/iavf: support flow subscription net/iavf: enable flow subscription rule support for AVF

 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/common/iavf/virtchnl.h         | 104 +++-
 drivers/net/iavf/iavf.h                |  10 +
 drivers/net/iavf/iavf_fdir.c           |   4 +
 drivers/net/iavf/iavf_fsub.c           | 746 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  40 +-
 drivers/net/iavf/iavf_generic_flow.h   |   2 +
 drivers/net/iavf/iavf_hash.c           |   5 +
 drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
 drivers/net/iavf/iavf_vchnl.c          | 133 +++++
 drivers/net/iavf/meson.build           |   1 +
 11 files changed, 1044 insertions(+), 21 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/2 common/iavf: support flow subscription

VF is able to subscribe a flow from PF by VIRTCHNL_FLOW_SUBSCRIBE.

PF is expected to offload a rule to hardware which will redirect the packet that matching the required pattern to this VF.

Only a flow with dst mac address as PF's mac address can be subscribed.

VIRTCHNL_VF_OFFLOAD_FSUB_PF is used for Flow subscription capability negotiation and only a trusted VF can be granted with this capability.

A flow can be unsubscribed by VIRTCHNL_FLOW_UNSUBSCRIBE.

---
 drivers/common/iavf/virtchnl.h | 104 +++++++++++++++++++++++++++++++--
 1 file changed, 100 insertions(+), 4 deletions(-)
drivers/common/iavf/virtchnl.h +100 -4
index f123daec8e..e02eec4935 100644
@@ -168,6 +168,8 @@ enum virtchnl_ops {
 	VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
 	VIRTCHNL_OP_CONFIG_QUEUE_BW = 112,
 	VIRTCHNL_OP_CONFIG_QUANTA = 113,
+	VIRTCHNL_OP_FLOW_SUBSCRIBE = 114,
+	VIRTCHNL_OP_FLOW_UNSUBSCRIBE = 115,
 	VIRTCHNL_OP_MAX,
 };
 
@@ -282,6 +284,10 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
 		return "VIRTCHNL_OP_1588_PTP_GET_CAPS";
 	case VIRTCHNL_OP_1588_PTP_GET_TIME:
 		return "VIRTCHNL_OP_1588_PTP_GET_TIME";
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_SUBSCRIBE";
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_UNSUBSCRIBE";
 	case VIRTCHNL_OP_MAX:
 		return "VIRTCHNL_OP_MAX";
 	default:
@@ -401,6 +407,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO	BIT(8)
 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS		BIT(9)
 #define VIRTCHNL_VF_OFFLOAD_CRC			BIT(10)
+#define VIRTCHNL_VF_OFFLOAD_FSUB_PF		BIT(14)
 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2		BIT(15)
 #define VIRTCHNL_VF_OFFLOAD_VLAN		BIT(16)
 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING		BIT(17)
@@ -1503,6 +1510,7 @@ enum virtchnl_vfr_states {
 };
 
 #define VIRTCHNL_MAX_NUM_PROTO_HDRS	32
+#define VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK	16
 #define VIRTCHNL_MAX_SIZE_RAW_PACKET	1024
 #define PROTO_HDR_SHIFT			5
 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
@@ -1695,6 +1703,22 @@ struct virtchnl_proto_hdr {
 
 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
 
+struct virtchnl_proto_hdr_w_msk {
+	/* see enum virtchnl_proto_hdr_type */
+	s32 type;
+	u32 pad;
+	/**
+	 * binary buffer in network order for specific header type.
+	 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
+	 * header is expected to be copied into the buffer.
+	 */
+	u8 buffer_spec[64];
+	/* binary buffer for bit-mask applied to specific header type */
+	u8 buffer_mask[64];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(136, virtchnl_proto_hdr_w_msk);
+
 struct virtchnl_proto_hdrs {
 	u8 tunnel_level;
 	/**
@@ -1706,11 +1730,18 @@ struct virtchnl_proto_hdrs {
 	 */
 	int count;
 	/**
-	 * number of proto layers, must < VIRTCHNL_MAX_NUM_PROTO_HDRS
-	 * must be 0 for a raw packet request.
+	 * count must <=
+	 * VIRTCHNL_MAX_NUM_PROTO_HDRS + VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK
+	 * count = 0 :					select raw
+	 * 1 < count <= VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr
+	 * count > VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr_w_msk
+	 * last valid index = count - VIRTCHNL_MAX_NUM_PROTO_HDRS
 	 */
 	union {
-		struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr
+			proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr_w_msk
+			proto_hdr_w_msk[VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK];
 		struct {
 			u16 pkt_len;
 			u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET];
@@ -1731,7 +1762,7 @@ struct virtchnl_rss_cfg {
 
 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
 
-/* action configuration for FDIR */
+/* action configuration for FDIR and FSUB */
 struct virtchnl_filter_action {
 	/* see enum virtchnl_action type */
 	s32 type;
@@ -1849,6 +1880,65 @@ struct virtchnl_fdir_del {
 
 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
 
+/* Status returned to VF after VF requests FSUB commands
+ * VIRTCHNL_FSUB_SUCCESS
+ * VF FLOW related request is successfully done by PF
+ * The request can be OP_FLOW_SUBSCRIBE/UNSUBSCRIBE.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE
+ * OP_FLOW_SUBSCRIBE request is failed due to no Hardware resource.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_EXIST
+ * OP_FLOW_SUBSCRIBE request is failed due to the rule is already existed.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST
+ * OP_FLOW_UNSUBSCRIBE request is failed due to this rule doesn't exist.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_INVALID
+ * OP_FLOW_SUBSCRIBE request is failed due to parameters validation
+ * or HW doesn't support.
+ */
+enum virtchnl_fsub_prgm_status {
+	VIRTCHNL_FSUB_SUCCESS = 0,
+	VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE,
+	VIRTCHNL_FSUB_FAILURE_RULE_EXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_INVALID,
+};
+
+/* VIRTCHNL_OP_FLOW_SUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id,
+ * validate_only, priority, proto_hdrs and actions.
+ * PF will return flow_id
+ * if the request is successfully done and return status to VF.
+ */
+struct virtchnl_flow_sub {
+	u16 vsi_id; /* INPUT */
+	u8 validate_only; /* INPUT */
+	u8 priority; /* INPUT */
+	u32 flow_id; /* OUTPUT */
+	struct virtchnl_proto_hdrs proto_hdrs; /* INPUT */
+	struct virtchnl_filter_action_set actions; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_flow_sub);
+
+/* VIRTCHNL_OP_FLOW_UNSUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id
+ * and flow_id. PF will return status to VF.
+ */
+struct virtchnl_flow_unsub {
+	u16 vsi_id; /* INPUT */
+	u16 pad;
+	u32 flow_id; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_flow_unsub);
+
 /* VIRTCHNL_OP_GET_QOS_CAPS
  * VF sends this message to get its QoS Caps, such as
  * TC number, Arbiter and Bandwidth.
@@ -2318,6 +2408,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 	case VIRTCHNL_OP_DEL_FDIR_FILTER:
 		valid_len = sizeof(struct virtchnl_fdir_del);
 		break;
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_sub);
+		break;
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_unsub);
+		break;
 	case VIRTCHNL_OP_GET_QOS_CAPS:
 		break;
 	case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 2/2 net/iavf: enable flow subscription rule support for AVF

In reply to Jie Wang

Add support AVF can be able to subscribe a flow from PF.

The supported patterns are listed below:
eth/vlan/ipv4
eth/ipv4(6)
eth/ipv4(6)/udp
eth/ipv4(6)/tcp

---
 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/net/iavf/iavf.h                |  10 +
 drivers/net/iavf/iavf_fdir.c           |   4 +
 drivers/net/iavf/iavf_fsub.c           | 746 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  40 +-
 drivers/net/iavf/iavf_generic_flow.h   |   2 +
 drivers/net/iavf/iavf_hash.c           |   5 +
 drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
 drivers/net/iavf/iavf_vchnl.c          | 133 +++++
 drivers/net/iavf/meson.build           |   1 +
 10 files changed, 944 insertions(+), 17 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
doc/guides/rel_notes/release_22_11.rst +4 -0
index 8c021cf050..bb77a03e24 100644
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added flow subscription support.
+
 
 Removed Items
 -------------
drivers/net/iavf/iavf.h +10 -0
index 025ab3ff60..6792c1de74 100644
@@ -148,6 +148,13 @@ struct iavf_fdir_info {
 	struct iavf_fdir_conf conf;
 };
 
+struct iavf_fsub_conf {
+	struct virtchnl_flow_sub sub_fltr;
+	struct virtchnl_flow_unsub unsub_fltr;
+	uint64_t input_set;
+	uint32_t flow_id;
+};
+
 struct iavf_qv_map {
 	uint16_t queue_id;
 	uint16_t vector_id;
@@ -482,4 +489,7 @@ int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
 extern const struct rte_tm_ops iavf_tm_ops;
 int iavf_get_ptp_cap(struct iavf_adapter *adapter);
 int iavf_get_phc_time(struct iavf_rx_queue *rxq);
+int iavf_flow_sub(struct iavf_adapter *adapter, struct iavf_fsub_conf *filter);
+int iavf_flow_unsub(struct iavf_adapter *adapter, struct iavf_fsub_conf *filter);
+int iavf_flow_sub_check(struct iavf_adapter *adapter, struct iavf_fsub_conf *filter);
 #endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_fdir.c +4 -0
index 2e6b3a9097..f5e23da5bc 100644
@@ -1551,6 +1551,7 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
@@ -1561,6 +1562,9 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 
 	memset(filter, 0, sizeof(*filter));
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (!item)
 		return -rte_errno;
drivers/net/iavf/iavf_fsub.c new file +746 -0

746 lines not on this page · raw message

drivers/net/iavf/iavf_generic_flow.c +29 -11
index e1a611e319..f33c764764 100644
@@ -1785,6 +1785,7 @@ enum rte_flow_item_type iavf_pattern_eth_ipv6_udp_l2tpv2_ppp_ipv6_tcp[] = {
 typedef struct iavf_flow_engine * (*parse_engine_t)(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error);
@@ -1866,6 +1867,8 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 {
 	struct iavf_parser_list *list = NULL;
 	struct iavf_flow_parser_node *parser_node;
+	struct iavf_flow_parser_node *existing_node;
+	void *temp;
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
 
 	parser_node = rte_zmalloc("iavf_parser", sizeof(*parser_node), 0);
@@ -1880,14 +1883,26 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 		TAILQ_INSERT_TAIL(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR) {
 		list = &vf->dist_parser_list;
+		RTE_TAILQ_FOREACH_SAFE(existing_node, list, node, temp) {
+			if (existing_node->parser->engine->type ==
+			    IAVF_FLOW_ENGINE_FSUB) {
+				TAILQ_INSERT_AFTER(list, existing_node,
+						   parser_node, node);
+				goto DONE;
+			}
+		}
 		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_IPSEC_CRYPTO) {
 		list = &vf->ipsec_crypto_parser_list;
 		TAILQ_INSERT_HEAD(list, parser_node, node);
+	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FSUB) {
+		list = &vf->dist_parser_list;
+		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else {
 		return -EINVAL;
 	}
 
+DONE:
 	return 0;
 }
 
@@ -1902,7 +1917,8 @@ iavf_unregister_parser(struct iavf_flow_parser *parser,
 
 	if (parser->engine->type == IAVF_FLOW_ENGINE_HASH)
 		list = &vf->rss_parser_list;
-	else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR)
+	else if ((parser->engine->type == IAVF_FLOW_ENGINE_FDIR) ||
+		 (parser->engine->type == IAVF_FLOW_ENGINE_FSUB))
 		list = &vf->dist_parser_list;
 
 	if (list == NULL)
@@ -1936,11 +1952,11 @@ iavf_flow_valid_attr(const struct rte_flow_attr *attr,
 		return -rte_errno;
 	}
 
-	/* Not supported */
-	if (attr->priority) {
+	/* support priority for flow subscribe */
+	if (attr->priority > 1) {
 		rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
-				attr, "Not support priority.");
+				attr, "Only support priority 0 and 1.");
 		return -rte_errno;
 	}
 
@@ -2083,6 +2099,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_create(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2096,7 +2113,7 @@ iavf_parse_engine_create(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta, error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2112,6 +2129,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_validate(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2125,7 +2143,7 @@ iavf_parse_engine_validate(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta,  error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2186,18 +2204,18 @@ iavf_flow_process_filter(struct rte_eth_dev *dev,
 	if (ret)
 		return ret;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
 	*engine = iavf_parse_engine(ad, flow, &vf->ipsec_crypto_parser_list,
-			pattern, actions, error);
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
drivers/net/iavf/iavf_generic_flow.h +2 -0
index 52eb1caf29..60d8ab02b4 100644
@@ -471,6 +471,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error);
 
@@ -480,6 +481,7 @@ enum iavf_flow_engine_type {
 	IAVF_FLOW_ENGINE_IPSEC_CRYPTO,
 	IAVF_FLOW_ENGINE_FDIR,
 	IAVF_FLOW_ENGINE_HASH,
+	IAVF_FLOW_ENGINE_FSUB,
 	IAVF_FLOW_ENGINE_MAX,
 };
 
drivers/net/iavf/iavf_hash.c +5 -0
index 42df7c4e48..dea4e0aa0a 100644
@@ -86,6 +86,7 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error);
 
@@ -1509,6 +1510,7 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error)
 {
@@ -1517,6 +1519,9 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 	uint64_t phint = IAVF_PHINT_NONE;
 	int ret = 0;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
 	if (!rss_meta_ptr) {
 		rte_flow_error_set(error, EINVAL,
drivers/net/iavf/iavf_ipsec_crypto.c +10 -6
index 75f05ee558..322934b5f6 100644
@@ -1932,16 +1932,20 @@ static struct iavf_flow_engine iavf_ipsec_flow_engine = {
 
 static int
 iavf_ipsec_flow_parse(struct iavf_adapter *ad,
-		       struct iavf_pattern_match_item *array,
-		       uint32_t array_len,
-		       const struct rte_flow_item pattern[],
-		       const struct rte_flow_action actions[],
-		       void **meta,
-		       struct rte_flow_error *error)
+		      struct iavf_pattern_match_item *array,
+		      uint32_t array_len,
+		      const struct rte_flow_item pattern[],
+		      const struct rte_flow_action actions[],
+		      uint32_t priority,
+		      void **meta,
+		      struct rte_flow_error *error)
 {
 	struct iavf_pattern_match_item *item = NULL;
 	int ret = -1;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (item && item->meta) {
 		uint32_t type = (uint64_t)(item->meta);
drivers/net/iavf/iavf_vchnl.c +133 -0

145 lines not on this page · raw message

drivers/net/iavf/meson.build +1 -0
index 2da37de662..6df771f917 100644
@@ -16,6 +16,7 @@ sources = files(
         'iavf_hash.c',
         'iavf_tm.c',
         'iavf_ipsec_crypto.c',
+        'iavf_fsub.c',
 )
 
 if arch_subdir == 'x86'
Signature · 1 line
2.25.1
author
#3 lore raw

v2 cover support flow subscription

In reply to Jie Wang

Add support AVF can be able to subscribe a flow from PF.

--
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/common/iavf/virtchnl.h         | 104 +++-
 drivers/net/iavf/iavf.h                |  13 +
 drivers/net/iavf/iavf_fdir.c           |   4 +
 drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  40 +-
 drivers/net/iavf/iavf_generic_flow.h   |   2 +
 drivers/net/iavf/iavf_hash.c           |   5 +
 drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
 drivers/net/iavf/iavf_vchnl.c          | 133 +++++
 drivers/net/iavf/meson.build           |   1 +
 11 files changed, 1046 insertions(+), 21 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
Signature · 1 line
2.25.1
author
#4 lore raw

PATCH v2 1/5 common/iavf: support flow subscription

VF is able to subscribe a flow from PF by VIRTCHNL_FLOW_SUBSCRIBE.

PF is expected to offload a rule to hardware which will redirect the packet that matching the required pattern to this VF.

Only a flow with dst mac address as PF's mac address can be subscribed.

VIRTCHNL_VF_OFFLOAD_FSUB_PF is used for Flow subscription capability negotiation and only a trusted VF can be granted with this capability.

A flow can be unsubscribed by VIRTCHNL_FLOW_UNSUBSCRIBE.

---
 drivers/common/iavf/virtchnl.h | 104 +++++++++++++++++++++++++++++++--
 1 file changed, 100 insertions(+), 4 deletions(-)
drivers/common/iavf/virtchnl.h +100 -4
index f123daec8e..e02eec4935 100644
@@ -168,6 +168,8 @@ enum virtchnl_ops {
 	VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
 	VIRTCHNL_OP_CONFIG_QUEUE_BW = 112,
 	VIRTCHNL_OP_CONFIG_QUANTA = 113,
+	VIRTCHNL_OP_FLOW_SUBSCRIBE = 114,
+	VIRTCHNL_OP_FLOW_UNSUBSCRIBE = 115,
 	VIRTCHNL_OP_MAX,
 };
 
@@ -282,6 +284,10 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
 		return "VIRTCHNL_OP_1588_PTP_GET_CAPS";
 	case VIRTCHNL_OP_1588_PTP_GET_TIME:
 		return "VIRTCHNL_OP_1588_PTP_GET_TIME";
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_SUBSCRIBE";
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_UNSUBSCRIBE";
 	case VIRTCHNL_OP_MAX:
 		return "VIRTCHNL_OP_MAX";
 	default:
@@ -401,6 +407,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO	BIT(8)
 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS		BIT(9)
 #define VIRTCHNL_VF_OFFLOAD_CRC			BIT(10)
+#define VIRTCHNL_VF_OFFLOAD_FSUB_PF		BIT(14)
 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2		BIT(15)
 #define VIRTCHNL_VF_OFFLOAD_VLAN		BIT(16)
 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING		BIT(17)
@@ -1503,6 +1510,7 @@ enum virtchnl_vfr_states {
 };
 
 #define VIRTCHNL_MAX_NUM_PROTO_HDRS	32
+#define VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK	16
 #define VIRTCHNL_MAX_SIZE_RAW_PACKET	1024
 #define PROTO_HDR_SHIFT			5
 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
@@ -1695,6 +1703,22 @@ struct virtchnl_proto_hdr {
 
 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
 
+struct virtchnl_proto_hdr_w_msk {
+	/* see enum virtchnl_proto_hdr_type */
+	s32 type;
+	u32 pad;
+	/**
+	 * binary buffer in network order for specific header type.
+	 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
+	 * header is expected to be copied into the buffer.
+	 */
+	u8 buffer_spec[64];
+	/* binary buffer for bit-mask applied to specific header type */
+	u8 buffer_mask[64];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(136, virtchnl_proto_hdr_w_msk);
+
 struct virtchnl_proto_hdrs {
 	u8 tunnel_level;
 	/**
@@ -1706,11 +1730,18 @@ struct virtchnl_proto_hdrs {
 	 */
 	int count;
 	/**
-	 * number of proto layers, must < VIRTCHNL_MAX_NUM_PROTO_HDRS
-	 * must be 0 for a raw packet request.
+	 * count must <=
+	 * VIRTCHNL_MAX_NUM_PROTO_HDRS + VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK
+	 * count = 0 :					select raw
+	 * 1 < count <= VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr
+	 * count > VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr_w_msk
+	 * last valid index = count - VIRTCHNL_MAX_NUM_PROTO_HDRS
 	 */
 	union {
-		struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr
+			proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr_w_msk
+			proto_hdr_w_msk[VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK];
 		struct {
 			u16 pkt_len;
 			u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET];
@@ -1731,7 +1762,7 @@ struct virtchnl_rss_cfg {
 
 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
 
-/* action configuration for FDIR */
+/* action configuration for FDIR and FSUB */
 struct virtchnl_filter_action {
 	/* see enum virtchnl_action type */
 	s32 type;
@@ -1849,6 +1880,65 @@ struct virtchnl_fdir_del {
 
 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
 
+/* Status returned to VF after VF requests FSUB commands
+ * VIRTCHNL_FSUB_SUCCESS
+ * VF FLOW related request is successfully done by PF
+ * The request can be OP_FLOW_SUBSCRIBE/UNSUBSCRIBE.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE
+ * OP_FLOW_SUBSCRIBE request is failed due to no Hardware resource.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_EXIST
+ * OP_FLOW_SUBSCRIBE request is failed due to the rule is already existed.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST
+ * OP_FLOW_UNSUBSCRIBE request is failed due to this rule doesn't exist.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_INVALID
+ * OP_FLOW_SUBSCRIBE request is failed due to parameters validation
+ * or HW doesn't support.
+ */
+enum virtchnl_fsub_prgm_status {
+	VIRTCHNL_FSUB_SUCCESS = 0,
+	VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE,
+	VIRTCHNL_FSUB_FAILURE_RULE_EXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_INVALID,
+};
+
+/* VIRTCHNL_OP_FLOW_SUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id,
+ * validate_only, priority, proto_hdrs and actions.
+ * PF will return flow_id
+ * if the request is successfully done and return status to VF.
+ */
+struct virtchnl_flow_sub {
+	u16 vsi_id; /* INPUT */
+	u8 validate_only; /* INPUT */
+	u8 priority; /* INPUT */
+	u32 flow_id; /* OUTPUT */
+	struct virtchnl_proto_hdrs proto_hdrs; /* INPUT */
+	struct virtchnl_filter_action_set actions; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_flow_sub);
+
+/* VIRTCHNL_OP_FLOW_UNSUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id
+ * and flow_id. PF will return status to VF.
+ */
+struct virtchnl_flow_unsub {
+	u16 vsi_id; /* INPUT */
+	u16 pad;
+	u32 flow_id; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_flow_unsub);
+
 /* VIRTCHNL_OP_GET_QOS_CAPS
  * VF sends this message to get its QoS Caps, such as
  * TC number, Arbiter and Bandwidth.
@@ -2318,6 +2408,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 	case VIRTCHNL_OP_DEL_FDIR_FILTER:
 		valid_len = sizeof(struct virtchnl_fdir_del);
 		break;
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_sub);
+		break;
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_unsub);
+		break;
 	case VIRTCHNL_OP_GET_QOS_CAPS:
 		break;
 	case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
Signature · 1 line
2.25.1
author
#5 lore raw

PATCH v2 2/5 net/iavf: add flow subscription to AVF

In reply to Jie Wang

Add the skeletal code of flow subscription to AVF driver.

---
 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/net/iavf/iavf_fsub.c           | 112 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  17 +++-
 drivers/net/iavf/iavf_generic_flow.h   |   1 +
 drivers/net/iavf/iavf_vchnl.c          |   1 +
 drivers/net/iavf/meson.build           |   1 +
 6 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
doc/guides/rel_notes/release_22_11.rst +4 -0
index 8c021cf050..bb77a03e24 100644
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added flow subscription support.
+
 
 Removed Items
 -------------
drivers/net/iavf/iavf_fsub.c new file +112 -0

112 lines not on this page · raw message

drivers/net/iavf/iavf_generic_flow.c +16 -1
index e1a611e319..b04614ba6e 100644
@@ -1866,6 +1866,8 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 {
 	struct iavf_parser_list *list = NULL;
 	struct iavf_flow_parser_node *parser_node;
+	struct iavf_flow_parser_node *existing_node;
+	void *temp;
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
 
 	parser_node = rte_zmalloc("iavf_parser", sizeof(*parser_node), 0);
@@ -1880,14 +1882,26 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 		TAILQ_INSERT_TAIL(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR) {
 		list = &vf->dist_parser_list;
+		RTE_TAILQ_FOREACH_SAFE(existing_node, list, node, temp) {
+			if (existing_node->parser->engine->type ==
+			    IAVF_FLOW_ENGINE_FSUB) {
+				TAILQ_INSERT_AFTER(list, existing_node,
+						   parser_node, node);
+				goto DONE;
+			}
+		}
 		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_IPSEC_CRYPTO) {
 		list = &vf->ipsec_crypto_parser_list;
 		TAILQ_INSERT_HEAD(list, parser_node, node);
+	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FSUB) {
+		list = &vf->dist_parser_list;
+		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else {
 		return -EINVAL;
 	}
 
+DONE:
 	return 0;
 }
 
@@ -1902,7 +1916,8 @@ iavf_unregister_parser(struct iavf_flow_parser *parser,
 
 	if (parser->engine->type == IAVF_FLOW_ENGINE_HASH)
 		list = &vf->rss_parser_list;
-	else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR)
+	else if ((parser->engine->type == IAVF_FLOW_ENGINE_FDIR) ||
+		 (parser->engine->type == IAVF_FLOW_ENGINE_FSUB))
 		list = &vf->dist_parser_list;
 
 	if (list == NULL)
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 52eb1caf29..448facffa5 100644
@@ -480,6 +480,7 @@ enum iavf_flow_engine_type {
 	IAVF_FLOW_ENGINE_IPSEC_CRYPTO,
 	IAVF_FLOW_ENGINE_FDIR,
 	IAVF_FLOW_ENGINE_HASH,
+	IAVF_FLOW_ENGINE_FSUB,
 	IAVF_FLOW_ENGINE_MAX,
 };
 
drivers/net/iavf/iavf_vchnl.c +1 -0
index 21bd1e2193..6d84add423 100644
@@ -502,6 +502,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter)
 		VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC |
 		VIRTCHNL_VF_OFFLOAD_FDIR_PF |
 		VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF |
+		VIRTCHNL_VF_OFFLOAD_FSUB_PF |
 		VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
 		VIRTCHNL_VF_OFFLOAD_CRC |
 		VIRTCHNL_VF_OFFLOAD_VLAN_V2 |
drivers/net/iavf/meson.build +1 -0
index 2da37de662..6df771f917 100644
@@ -16,6 +16,7 @@ sources = files(
         'iavf_hash.c',
         'iavf_tm.c',
         'iavf_ipsec_crypto.c',
+        'iavf_fsub.c',
 )
 
 if arch_subdir == 'x86'
Signature · 1 line
2.25.1
author
#6 lore raw

PATCH v2 3/5 net/iavf: support flow subscrption pattern

In reply to Jie Wang

Add flow subscription pattern support for AVF.

The supported patterns are listed below:
eth/vlan/ipv4
eth/ipv4(6)
eth/ipv4(6)/udp
eth/ipv4(6)/tcp

---
 drivers/net/iavf/iavf.h      |   7 +
 drivers/net/iavf/iavf_fsub.c | 598 ++++++++++++++++++++++++++++++++++-
 2 files changed, 597 insertions(+), 8 deletions(-)
drivers/net/iavf/iavf.h +7 -0
index 025ab3ff60..f79c7f9f6e 100644
@@ -148,6 +148,13 @@ struct iavf_fdir_info {
 	struct iavf_fdir_conf conf;
 };
 
+struct iavf_fsub_conf {
+	struct virtchnl_flow_sub sub_fltr;
+	struct virtchnl_flow_unsub unsub_fltr;
+	uint64_t input_set;
+	uint32_t flow_id;
+};
+
 struct iavf_qv_map {
 	uint16_t queue_id;
 	uint16_t vector_id;
drivers/net/iavf/iavf_fsub.c +590 -8

616 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#7 lore raw

PATCH v2 4/5 net/iavf: support flow subscription rule

In reply to Jie Wang

Support flow subscribption create/destroy/validation flow rule for AVF.

For examples:
testpmd> flow create 0 ingress pattern eth / ipv4 / udp src is 11
/ end actions represented_port port_id 1 / end
testpmd> flow validate 1 ingress pattern eth / ipv4 / tcp src is 22
/ end actions represented_port port_id 1 / end
testpmd> flow destroy 1 rule 0

---
 drivers/net/iavf/iavf.h       |   6 ++
 drivers/net/iavf/iavf_fsub.c  |  75 +++++++++++++++----
 drivers/net/iavf/iavf_vchnl.c | 132 ++++++++++++++++++++++++++++++++++
 3 files changed, 201 insertions(+), 12 deletions(-)
drivers/net/iavf/iavf.h +6 -0
index f79c7f9f6e..26b858f6f0 100644
@@ -489,4 +489,10 @@ int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
 extern const struct rte_tm_ops iavf_tm_ops;
 int iavf_get_ptp_cap(struct iavf_adapter *adapter);
 int iavf_get_phc_time(struct iavf_rx_queue *rxq);
+int iavf_flow_sub(struct iavf_adapter *adapter,
+		  struct iavf_fsub_conf *filter);
+int iavf_flow_unsub(struct iavf_adapter *adapter,
+		    struct iavf_fsub_conf *filter);
+int iavf_flow_sub_check(struct iavf_adapter *adapter,
+			struct iavf_fsub_conf *filter);
 #endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_fsub.c +63 -12

92 lines not on this page · raw message

drivers/net/iavf/iavf_vchnl.c +132 -0

138 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#8 lore raw

PATCH v2 5/5 net/iavf: support priority of flow rule

In reply to Jie Wang

Add flow rule attribute "priority" support for AVF.

Lower values denote higher priority, the highest priority for a flow rule is 0.

---
 drivers/net/iavf/iavf_fdir.c         |  4 ++++
 drivers/net/iavf/iavf_fsub.c         |  2 +-
 drivers/net/iavf/iavf_generic_flow.c | 23 +++++++++++++----------
 drivers/net/iavf/iavf_generic_flow.h |  1 +
 drivers/net/iavf/iavf_hash.c         |  5 +++++
 drivers/net/iavf/iavf_ipsec_crypto.c | 16 ++++++++++------
 6 files changed, 34 insertions(+), 17 deletions(-)
drivers/net/iavf/iavf_fdir.c +4 -0
index 2e6b3a9097..f5e23da5bc 100644
@@ -1551,6 +1551,7 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
@@ -1561,6 +1562,9 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 
 	memset(filter, 0, sizeof(*filter));
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (!item)
 		return -rte_errno;
drivers/net/iavf/iavf_fsub.c +1 -1
index 441bf478be..91193bb010 100644
@@ -649,13 +649,13 @@ iavf_fsub_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
 	struct iavf_fsub_conf *filter;
 	struct iavf_pattern_match_item *pattern_match_item = NULL;
 	int ret = 0;
-	uint32_t priority = 0;
 
 	filter = rte_zmalloc(NULL, sizeof(*filter), 0);
 	if (!filter) {
drivers/net/iavf/iavf_generic_flow.c +13 -10
index b04614ba6e..f33c764764 100644
@@ -1785,6 +1785,7 @@ enum rte_flow_item_type iavf_pattern_eth_ipv6_udp_l2tpv2_ppp_ipv6_tcp[] = {
 typedef struct iavf_flow_engine * (*parse_engine_t)(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error);
@@ -1951,11 +1952,11 @@ iavf_flow_valid_attr(const struct rte_flow_attr *attr,
 		return -rte_errno;
 	}
 
-	/* Not supported */
-	if (attr->priority) {
+	/* support priority for flow subscribe */
+	if (attr->priority > 1) {
 		rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
-				attr, "Not support priority.");
+				attr, "Only support priority 0 and 1.");
 		return -rte_errno;
 	}
 
@@ -2098,6 +2099,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_create(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2111,7 +2113,7 @@ iavf_parse_engine_create(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta, error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2127,6 +2129,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_validate(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2140,7 +2143,7 @@ iavf_parse_engine_validate(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta,  error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2201,18 +2204,18 @@ iavf_flow_process_filter(struct rte_eth_dev *dev,
 	if (ret)
 		return ret;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
 	*engine = iavf_parse_engine(ad, flow, &vf->ipsec_crypto_parser_list,
-			pattern, actions, error);
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 448facffa5..60d8ab02b4 100644
@@ -471,6 +471,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error);
 
drivers/net/iavf/iavf_hash.c +5 -0
index 42df7c4e48..dea4e0aa0a 100644
@@ -86,6 +86,7 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error);
 
@@ -1509,6 +1510,7 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error)
 {
@@ -1517,6 +1519,9 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 	uint64_t phint = IAVF_PHINT_NONE;
 	int ret = 0;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
 	if (!rss_meta_ptr) {
 		rte_flow_error_set(error, EINVAL,
drivers/net/iavf/iavf_ipsec_crypto.c +10 -6
index 75f05ee558..322934b5f6 100644
@@ -1932,16 +1932,20 @@ static struct iavf_flow_engine iavf_ipsec_flow_engine = {
 
 static int
 iavf_ipsec_flow_parse(struct iavf_adapter *ad,
-		       struct iavf_pattern_match_item *array,
-		       uint32_t array_len,
-		       const struct rte_flow_item pattern[],
-		       const struct rte_flow_action actions[],
-		       void **meta,
-		       struct rte_flow_error *error)
+		      struct iavf_pattern_match_item *array,
+		      uint32_t array_len,
+		      const struct rte_flow_item pattern[],
+		      const struct rte_flow_action actions[],
+		      uint32_t priority,
+		      void **meta,
+		      struct rte_flow_error *error)
 {
 	struct iavf_pattern_match_item *item = NULL;
 	int ret = -1;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (item && item->meta) {
 		uint32_t type = (uint64_t)(item->meta);
Signature · 1 line
2.25.1
author
#9 lore raw

v3 cover support flow subscription

In reply to Jie Wang

Add support AVF can be able to subscribe a flow from PF.

--
v3:
* fix eth layer inputset.
* rebase.
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/common/iavf/virtchnl.h         | 104 +++-
 drivers/net/iavf/iavf.h                |  13 +
 drivers/net/iavf/iavf_fdir.c           |   4 +
 drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  40 +-
 drivers/net/iavf/iavf_generic_flow.h   |   2 +
 drivers/net/iavf/iavf_hash.c           |   5 +
 drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
 drivers/net/iavf/iavf_vchnl.c          | 133 +++++
 drivers/net/iavf/meson.build           |   1 +
 11 files changed, 1046 insertions(+), 21 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
Signature · 1 line
2.25.1
author
#10 lore raw

PATCH v3 1/5 common/iavf: support flow subscription

VF is able to subscribe a flow from PF by VIRTCHNL_FLOW_SUBSCRIBE.

PF is expected to offload a rule to hardware which will redirect the packet that matching the required pattern to this VF.

Only a flow with dst mac address as PF's mac address can be subscribed.

VIRTCHNL_VF_OFFLOAD_FSUB_PF is used for Flow subscription capability negotiation and only a trusted VF can be granted with this capability.

A flow can be unsubscribed by VIRTCHNL_FLOW_UNSUBSCRIBE.

---
 drivers/common/iavf/virtchnl.h | 104 +++++++++++++++++++++++++++++++--
 1 file changed, 100 insertions(+), 4 deletions(-)
drivers/common/iavf/virtchnl.h +100 -4
index f123daec8e..e02eec4935 100644
@@ -168,6 +168,8 @@ enum virtchnl_ops {
 	VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
 	VIRTCHNL_OP_CONFIG_QUEUE_BW = 112,
 	VIRTCHNL_OP_CONFIG_QUANTA = 113,
+	VIRTCHNL_OP_FLOW_SUBSCRIBE = 114,
+	VIRTCHNL_OP_FLOW_UNSUBSCRIBE = 115,
 	VIRTCHNL_OP_MAX,
 };
 
@@ -282,6 +284,10 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
 		return "VIRTCHNL_OP_1588_PTP_GET_CAPS";
 	case VIRTCHNL_OP_1588_PTP_GET_TIME:
 		return "VIRTCHNL_OP_1588_PTP_GET_TIME";
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_SUBSCRIBE";
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_UNSUBSCRIBE";
 	case VIRTCHNL_OP_MAX:
 		return "VIRTCHNL_OP_MAX";
 	default:
@@ -401,6 +407,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO	BIT(8)
 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS		BIT(9)
 #define VIRTCHNL_VF_OFFLOAD_CRC			BIT(10)
+#define VIRTCHNL_VF_OFFLOAD_FSUB_PF		BIT(14)
 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2		BIT(15)
 #define VIRTCHNL_VF_OFFLOAD_VLAN		BIT(16)
 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING		BIT(17)
@@ -1503,6 +1510,7 @@ enum virtchnl_vfr_states {
 };
 
 #define VIRTCHNL_MAX_NUM_PROTO_HDRS	32
+#define VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK	16
 #define VIRTCHNL_MAX_SIZE_RAW_PACKET	1024
 #define PROTO_HDR_SHIFT			5
 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
@@ -1695,6 +1703,22 @@ struct virtchnl_proto_hdr {
 
 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
 
+struct virtchnl_proto_hdr_w_msk {
+	/* see enum virtchnl_proto_hdr_type */
+	s32 type;
+	u32 pad;
+	/**
+	 * binary buffer in network order for specific header type.
+	 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
+	 * header is expected to be copied into the buffer.
+	 */
+	u8 buffer_spec[64];
+	/* binary buffer for bit-mask applied to specific header type */
+	u8 buffer_mask[64];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(136, virtchnl_proto_hdr_w_msk);
+
 struct virtchnl_proto_hdrs {
 	u8 tunnel_level;
 	/**
@@ -1706,11 +1730,18 @@ struct virtchnl_proto_hdrs {
 	 */
 	int count;
 	/**
-	 * number of proto layers, must < VIRTCHNL_MAX_NUM_PROTO_HDRS
-	 * must be 0 for a raw packet request.
+	 * count must <=
+	 * VIRTCHNL_MAX_NUM_PROTO_HDRS + VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK
+	 * count = 0 :					select raw
+	 * 1 < count <= VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr
+	 * count > VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr_w_msk
+	 * last valid index = count - VIRTCHNL_MAX_NUM_PROTO_HDRS
 	 */
 	union {
-		struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr
+			proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr_w_msk
+			proto_hdr_w_msk[VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK];
 		struct {
 			u16 pkt_len;
 			u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET];
@@ -1731,7 +1762,7 @@ struct virtchnl_rss_cfg {
 
 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
 
-/* action configuration for FDIR */
+/* action configuration for FDIR and FSUB */
 struct virtchnl_filter_action {
 	/* see enum virtchnl_action type */
 	s32 type;
@@ -1849,6 +1880,65 @@ struct virtchnl_fdir_del {
 
 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
 
+/* Status returned to VF after VF requests FSUB commands
+ * VIRTCHNL_FSUB_SUCCESS
+ * VF FLOW related request is successfully done by PF
+ * The request can be OP_FLOW_SUBSCRIBE/UNSUBSCRIBE.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE
+ * OP_FLOW_SUBSCRIBE request is failed due to no Hardware resource.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_EXIST
+ * OP_FLOW_SUBSCRIBE request is failed due to the rule is already existed.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST
+ * OP_FLOW_UNSUBSCRIBE request is failed due to this rule doesn't exist.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_INVALID
+ * OP_FLOW_SUBSCRIBE request is failed due to parameters validation
+ * or HW doesn't support.
+ */
+enum virtchnl_fsub_prgm_status {
+	VIRTCHNL_FSUB_SUCCESS = 0,
+	VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE,
+	VIRTCHNL_FSUB_FAILURE_RULE_EXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_INVALID,
+};
+
+/* VIRTCHNL_OP_FLOW_SUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id,
+ * validate_only, priority, proto_hdrs and actions.
+ * PF will return flow_id
+ * if the request is successfully done and return status to VF.
+ */
+struct virtchnl_flow_sub {
+	u16 vsi_id; /* INPUT */
+	u8 validate_only; /* INPUT */
+	u8 priority; /* INPUT */
+	u32 flow_id; /* OUTPUT */
+	struct virtchnl_proto_hdrs proto_hdrs; /* INPUT */
+	struct virtchnl_filter_action_set actions; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_flow_sub);
+
+/* VIRTCHNL_OP_FLOW_UNSUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id
+ * and flow_id. PF will return status to VF.
+ */
+struct virtchnl_flow_unsub {
+	u16 vsi_id; /* INPUT */
+	u16 pad;
+	u32 flow_id; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_flow_unsub);
+
 /* VIRTCHNL_OP_GET_QOS_CAPS
  * VF sends this message to get its QoS Caps, such as
  * TC number, Arbiter and Bandwidth.
@@ -2318,6 +2408,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 	case VIRTCHNL_OP_DEL_FDIR_FILTER:
 		valid_len = sizeof(struct virtchnl_fdir_del);
 		break;
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_sub);
+		break;
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_unsub);
+		break;
 	case VIRTCHNL_OP_GET_QOS_CAPS:
 		break;
 	case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
Signature · 1 line
2.25.1
author
#11 lore raw

PATCH v3 2/5 net/iavf: add flow subscription to AVF

In reply to Jie Wang

Add the skeletal code of flow subscription to AVF driver.

---
 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/net/iavf/iavf_fsub.c           | 112 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  17 +++-
 drivers/net/iavf/iavf_generic_flow.h   |   1 +
 drivers/net/iavf/iavf_vchnl.c          |   1 +
 drivers/net/iavf/meson.build           |   1 +
 6 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
doc/guides/rel_notes/release_22_11.rst +4 -0
index 8c021cf050..bb77a03e24 100644
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added flow subscription support.
+
 
 Removed Items
 -------------
drivers/net/iavf/iavf_fsub.c new file +112 -0

112 lines not on this page · raw message

drivers/net/iavf/iavf_generic_flow.c +16 -1
index e1a611e319..b04614ba6e 100644
@@ -1866,6 +1866,8 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 {
 	struct iavf_parser_list *list = NULL;
 	struct iavf_flow_parser_node *parser_node;
+	struct iavf_flow_parser_node *existing_node;
+	void *temp;
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
 
 	parser_node = rte_zmalloc("iavf_parser", sizeof(*parser_node), 0);
@@ -1880,14 +1882,26 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 		TAILQ_INSERT_TAIL(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR) {
 		list = &vf->dist_parser_list;
+		RTE_TAILQ_FOREACH_SAFE(existing_node, list, node, temp) {
+			if (existing_node->parser->engine->type ==
+			    IAVF_FLOW_ENGINE_FSUB) {
+				TAILQ_INSERT_AFTER(list, existing_node,
+						   parser_node, node);
+				goto DONE;
+			}
+		}
 		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_IPSEC_CRYPTO) {
 		list = &vf->ipsec_crypto_parser_list;
 		TAILQ_INSERT_HEAD(list, parser_node, node);
+	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FSUB) {
+		list = &vf->dist_parser_list;
+		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else {
 		return -EINVAL;
 	}
 
+DONE:
 	return 0;
 }
 
@@ -1902,7 +1916,8 @@ iavf_unregister_parser(struct iavf_flow_parser *parser,
 
 	if (parser->engine->type == IAVF_FLOW_ENGINE_HASH)
 		list = &vf->rss_parser_list;
-	else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR)
+	else if ((parser->engine->type == IAVF_FLOW_ENGINE_FDIR) ||
+		 (parser->engine->type == IAVF_FLOW_ENGINE_FSUB))
 		list = &vf->dist_parser_list;
 
 	if (list == NULL)
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 52eb1caf29..448facffa5 100644
@@ -480,6 +480,7 @@ enum iavf_flow_engine_type {
 	IAVF_FLOW_ENGINE_IPSEC_CRYPTO,
 	IAVF_FLOW_ENGINE_FDIR,
 	IAVF_FLOW_ENGINE_HASH,
+	IAVF_FLOW_ENGINE_FSUB,
 	IAVF_FLOW_ENGINE_MAX,
 };
 
drivers/net/iavf/iavf_vchnl.c +1 -0
index 21bd1e2193..6d84add423 100644
@@ -502,6 +502,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter)
 		VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC |
 		VIRTCHNL_VF_OFFLOAD_FDIR_PF |
 		VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF |
+		VIRTCHNL_VF_OFFLOAD_FSUB_PF |
 		VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
 		VIRTCHNL_VF_OFFLOAD_CRC |
 		VIRTCHNL_VF_OFFLOAD_VLAN_V2 |
drivers/net/iavf/meson.build +1 -0
index 2da37de662..6df771f917 100644
@@ -16,6 +16,7 @@ sources = files(
         'iavf_hash.c',
         'iavf_tm.c',
         'iavf_ipsec_crypto.c',
+        'iavf_fsub.c',
 )
 
 if arch_subdir == 'x86'
Signature · 1 line
2.25.1
author
#12 lore raw

PATCH v3 3/5 net/iavf: support flow subscrption pattern

In reply to Jie Wang

Add flow subscription pattern support for AVF.

The supported patterns are listed below:
eth/vlan/ipv4
eth/ipv4(6)
eth/ipv4(6)/udp
eth/ipv4(6)/tcp

---
 drivers/net/iavf/iavf.h      |   7 +
 drivers/net/iavf/iavf_fsub.c | 598 ++++++++++++++++++++++++++++++++++-
 2 files changed, 597 insertions(+), 8 deletions(-)
drivers/net/iavf/iavf.h +7 -0
index 025ab3ff60..f79c7f9f6e 100644
@@ -148,6 +148,13 @@ struct iavf_fdir_info {
 	struct iavf_fdir_conf conf;
 };
 
+struct iavf_fsub_conf {
+	struct virtchnl_flow_sub sub_fltr;
+	struct virtchnl_flow_unsub unsub_fltr;
+	uint64_t input_set;
+	uint32_t flow_id;
+};
+
 struct iavf_qv_map {
 	uint16_t queue_id;
 	uint16_t vector_id;
drivers/net/iavf/iavf_fsub.c +590 -8

616 lines not on this page · raw message

Signature · 1 line
2.25.1
#13 lore raw

RE: [PATCH v3 3/5] net/iavf: support flow subscrption pattern

Quoted 12 lines

-----Original Message-----
From: Wang, Jie1X <[email protected]>
Sent: Wednesday, August 31, 2022 2:05 AM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Wang, Jie1X <[email protected]>
Subject: [PATCH v3 3/5] net/iavf: support flow subscrption pattern

...

Quoted 14 lines
drivers/net/iavf/iavf_fsub.c +13 -0
+static int
+iavf_fsub_parse_action(struct iavf_adapter *ad,
+		       const struct rte_flow_action *actions,
+		       uint32_t priority,
+		       struct rte_flow_error *error,
+		       struct iavf_fsub_conf *filter)
 {
+	const struct rte_flow_action *action;
+	const struct rte_flow_action_ethdev *act_ethdev;
+	const struct rte_flow_action_queue *act_q;
+	const struct rte_flow_action_rss *act_qgrop;
+	struct virtchnl_filter_action *filter_action;
+	uint16_t valid_qgrop_number[MAX_QGRP_NUM_TYPE] = {
+		2, 4, 8, 16, 32, 64, 128};

drivers/net/iavf/iavf_fsub.c iavf_fsub_validation(__rte_unused struct iavf_adapter *ad, · line 437

Quoted 10 lines
drivers/net/iavf/iavf_fsub.c +10 -0
+	uint16_t i, num = 0, dest_num = 0, vf_num = 0;
+	uint16_t rule_port_id;
+
+	for (action = actions; action->type !=
+				RTE_FLOW_ACTION_TYPE_END; action++) {
+		switch (action->type) {
+		case RTE_FLOW_ACTION_TYPE_VOID:
+			break;
+
+		case RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT:

Should be RTE_FLOW_ACTION_PORT_REPRESENTOR, as the traffic is expected to be sent to the given ethdev.

author
#14 lore raw

PATCH v3 4/5 net/iavf: support flow subscription rule

In reply to Jie Wang

Support flow subscribption create/destroy/validation flow rule for AVF.

For examples:
testpmd> flow create 0 ingress pattern eth / ipv4 / udp src is 11
/ end actions represented_port port_id 1 / end
testpmd> flow validate 1 ingress pattern eth / ipv4 / tcp src is 22
/ end actions represented_port port_id 1 / end
testpmd> flow destroy 1 rule 0

---
 drivers/net/iavf/iavf.h       |   6 ++
 drivers/net/iavf/iavf_fsub.c  |  75 +++++++++++++++----
 drivers/net/iavf/iavf_vchnl.c | 132 ++++++++++++++++++++++++++++++++++
 3 files changed, 201 insertions(+), 12 deletions(-)
drivers/net/iavf/iavf.h +6 -0
index f79c7f9f6e..26b858f6f0 100644
@@ -489,4 +489,10 @@ int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
 extern const struct rte_tm_ops iavf_tm_ops;
 int iavf_get_ptp_cap(struct iavf_adapter *adapter);
 int iavf_get_phc_time(struct iavf_rx_queue *rxq);
+int iavf_flow_sub(struct iavf_adapter *adapter,
+		  struct iavf_fsub_conf *filter);
+int iavf_flow_unsub(struct iavf_adapter *adapter,
+		    struct iavf_fsub_conf *filter);
+int iavf_flow_sub_check(struct iavf_adapter *adapter,
+			struct iavf_fsub_conf *filter);
 #endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_fsub.c +63 -12

92 lines not on this page · raw message

drivers/net/iavf/iavf_vchnl.c +132 -0

138 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#15 lore raw

PATCH v3 5/5 net/iavf: support priority of flow rule

In reply to Jie Wang

Add flow rule attribute "priority" support for AVF.

Lower values denote higher priority, the highest priority for a flow rule is 0.

---
 drivers/net/iavf/iavf_fdir.c         |  4 ++++
 drivers/net/iavf/iavf_fsub.c         |  2 +-
 drivers/net/iavf/iavf_generic_flow.c | 23 +++++++++++++----------
 drivers/net/iavf/iavf_generic_flow.h |  1 +
 drivers/net/iavf/iavf_hash.c         |  5 +++++
 drivers/net/iavf/iavf_ipsec_crypto.c | 16 ++++++++++------
 6 files changed, 34 insertions(+), 17 deletions(-)
drivers/net/iavf/iavf_fdir.c +4 -0
index a397047fdb..8f80873925 100644
@@ -1583,6 +1583,7 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
@@ -1593,6 +1594,9 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 
 	memset(filter, 0, sizeof(*filter));
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (!item)
 		return -rte_errno;
drivers/net/iavf/iavf_fsub.c +1 -1
index b9ad3531ff..46effda9a0 100644
@@ -649,13 +649,13 @@ iavf_fsub_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
 	struct iavf_fsub_conf *filter;
 	struct iavf_pattern_match_item *pattern_match_item = NULL;
 	int ret = 0;
-	uint32_t priority = 0;
 
 	filter = rte_zmalloc(NULL, sizeof(*filter), 0);
 	if (!filter) {
drivers/net/iavf/iavf_generic_flow.c +13 -10
index b04614ba6e..f33c764764 100644
@@ -1785,6 +1785,7 @@ enum rte_flow_item_type iavf_pattern_eth_ipv6_udp_l2tpv2_ppp_ipv6_tcp[] = {
 typedef struct iavf_flow_engine * (*parse_engine_t)(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error);
@@ -1951,11 +1952,11 @@ iavf_flow_valid_attr(const struct rte_flow_attr *attr,
 		return -rte_errno;
 	}
 
-	/* Not supported */
-	if (attr->priority) {
+	/* support priority for flow subscribe */
+	if (attr->priority > 1) {
 		rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
-				attr, "Not support priority.");
+				attr, "Only support priority 0 and 1.");
 		return -rte_errno;
 	}
 
@@ -2098,6 +2099,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_create(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2111,7 +2113,7 @@ iavf_parse_engine_create(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta, error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2127,6 +2129,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_validate(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2140,7 +2143,7 @@ iavf_parse_engine_validate(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta,  error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2201,18 +2204,18 @@ iavf_flow_process_filter(struct rte_eth_dev *dev,
 	if (ret)
 		return ret;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
 	*engine = iavf_parse_engine(ad, flow, &vf->ipsec_crypto_parser_list,
-			pattern, actions, error);
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 448facffa5..60d8ab02b4 100644
@@ -471,6 +471,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error);
 
drivers/net/iavf/iavf_hash.c +5 -0
index 42df7c4e48..dea4e0aa0a 100644
@@ -86,6 +86,7 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error);
 
@@ -1509,6 +1510,7 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error)
 {
@@ -1517,6 +1519,9 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 	uint64_t phint = IAVF_PHINT_NONE;
 	int ret = 0;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
 	if (!rss_meta_ptr) {
 		rte_flow_error_set(error, EINVAL,
drivers/net/iavf/iavf_ipsec_crypto.c +10 -6
index 1d465b4419..cec1b968fe 100644
@@ -1933,16 +1933,20 @@ static struct iavf_flow_engine iavf_ipsec_flow_engine = {
 
 static int
 iavf_ipsec_flow_parse(struct iavf_adapter *ad,
-		       struct iavf_pattern_match_item *array,
-		       uint32_t array_len,
-		       const struct rte_flow_item pattern[],
-		       const struct rte_flow_action actions[],
-		       void **meta,
-		       struct rte_flow_error *error)
+		      struct iavf_pattern_match_item *array,
+		      uint32_t array_len,
+		      const struct rte_flow_item pattern[],
+		      const struct rte_flow_action actions[],
+		      uint32_t priority,
+		      void **meta,
+		      struct rte_flow_error *error)
 {
 	struct iavf_pattern_match_item *item = NULL;
 	int ret = -1;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (item && item->meta) {
 		uint32_t type = (uint64_t)(item->meta);
Signature · 1 line
2.25.1
#16 lore raw
In reply to Jie Wang
Quoted 2 lines · Jie Wang

Add support AVF can be able to subscribe a flow from PF.

Hi Jie,

Can you please provide more details, what does subscribing a flow from PF mean?

Thanks,
ferruh

Quoted 30 lines

--
v3:
* fix eth layer inputset.
* rebase.
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

  doc/guides/rel_notes/release_22_11.rst |   4 +
  drivers/common/iavf/virtchnl.h         | 104 +++-
  drivers/net/iavf/iavf.h                |  13 +
  drivers/net/iavf/iavf_fdir.c           |   4 +
  drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
  drivers/net/iavf/iavf_generic_flow.c   |  40 +-
  drivers/net/iavf/iavf_generic_flow.h   |   2 +
  drivers/net/iavf/iavf_hash.c           |   5 +
  drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
  drivers/net/iavf/iavf_vchnl.c          | 133 +++++
  drivers/net/iavf/meson.build           |   1 +
  11 files changed, 1046 insertions(+), 21 deletions(-)

create mode 100644 drivers/net/iavf/iavf_fsub.c

#17 lore raw
Quoted 11 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, August 31, 2022 6:57 PM
To: Wang, Jie1X <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: Re: [PATCH v3 0/5] support flow subscription

Quoted 8 lines
Quoted 2 lines · Jie Wang

Add support AVF can be able to subscribe a flow from PF.

Hi Jie,

Can you please provide more details, what does subscribing a flow from PF mean?

The answer is in patch 1/5's commit log which would be better in cover letter also :)

Quoted 34 lines

Thanks,
ferruh

Quoted 30 lines

--
v3:
* fix eth layer inputset.
* rebase.
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

  doc/guides/rel_notes/release_22_11.rst |   4 +
  drivers/common/iavf/virtchnl.h         | 104 +++-
  drivers/net/iavf/iavf.h                |  13 +
  drivers/net/iavf/iavf_fdir.c           |   4 +
  drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
  drivers/net/iavf/iavf_generic_flow.c   |  40 +-
  drivers/net/iavf/iavf_generic_flow.h   |   2 +
  drivers/net/iavf/iavf_hash.c           |   5 +
  drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
  drivers/net/iavf/iavf_vchnl.c          | 133 +++++
  drivers/net/iavf/meson.build           |   1 +
  11 files changed, 1046 insertions(+), 21 deletions(-)

create mode 100644 drivers/net/iavf/iavf_fsub.c

#18 lore raw
Quoted 15 lines · Qi Z
Quoted 15 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, August 31, 2022 6:57 PM
To: Wang, Jie1X <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: Re: [PATCH v3 0/5] support flow subscription

Quoted 2 lines · Jie Wang

Add support AVF can be able to subscribe a flow from PF.

Quoted 7 lines
Quoted 4 lines

Hi Jie,

Can you please provide more details, what does subscribing a flow from PF mean?

The answer is in patch 1/5's commit log which would be better in cover letter also :)

Hi Qi,

I checked all commit logs, but the feature wasn't clear to me, it can be useful to elaborate more.

Is it the case that:
- PF create a flow rule
- VF subscribes to this rule, which means
- Packets will be sent to VF instead of PF

If above is correct, will both PF and VF receive packets, or only VF?
Can multiple VF subscribe to same rule?
Can PF destroy the rule while VF is subscribed?
How PF can prevent subscription to some flows from not trusted VF for security concern?
...

Quoted 35 lines
Quoted 34 lines

Thanks,
ferruh

Quoted 30 lines

--
v3:
* fix eth layer inputset.
* rebase.
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

   doc/guides/rel_notes/release_22_11.rst |   4 +
   drivers/common/iavf/virtchnl.h         | 104 +++-
   drivers/net/iavf/iavf.h                |  13 +
   drivers/net/iavf/iavf_fdir.c           |   4 +
   drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
   drivers/net/iavf/iavf_generic_flow.c   |  40 +-
   drivers/net/iavf/iavf_generic_flow.h   |   2 +
   drivers/net/iavf/iavf_hash.c           |   5 +
   drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
   drivers/net/iavf/iavf_vchnl.c          | 133 +++++
   drivers/net/iavf/meson.build           |   1 +
   11 files changed, 1046 insertions(+), 21 deletions(-)

create mode 100644 drivers/net/iavf/iavf_fsub.c

#19 lore raw
Quoted 39 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, August 31, 2022 8:54 PM
To: Zhang, Qi Z <[email protected]>; Wang, Jie1X <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: Re: [PATCH v3 0/5] support flow subscription

Quoted 15 lines · Qi Z
Quoted 15 lines

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, August 31, 2022 6:57 PM
To: Wang, Jie1X <[email protected]>; [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>
Subject: Re: [PATCH v3 0/5] support flow subscription

Quoted 2 lines · Jie Wang

Add support AVF can be able to subscribe a flow from PF.

Quoted 8 lines
Quoted 4 lines

Hi Jie,

Can you please provide more details, what does subscribing a flow from PF mean?

The answer is in patch 1/5's commit log which would be better in cover letter also :)

Hi Qi,

Quoted 7 lines

I checked all commit logs, but the feature wasn't clear to me, it can be useful to elaborate more.

Is it the case that:
- PF create a flow rule
- VF subscribes to this rule, which means
- Packets will be sent to VF instead of PF

Correct.

Quoted 2 lines

If above is correct, will both PF and VF receive packets, or only VF?

Only VF will receive the packet.

Quoted 1 line

Can multiple VF subscribe to same rule?

Yes, it is allowed and the packet should be replicated, though we didn't see real use cases.

Quoted 1 line

Can PF destroy the rule while VF is subscribed

PF will destroy all subscription during VF reset.

Quoted 2 lines

How PF can prevent subscription to some flows from not trusted VF for security concern?

Good question, you almost let me go through the internal security review the second time. :)

All subscription rule will have a lower priority than the rules that be created by host (e.g.: rules created by switchdev or DCF).

I will suggest author to put all these information in the commit log.

Thanks
Qi

Quoted 37 lines

...

Quoted 35 lines
Quoted 34 lines

Thanks,
ferruh

Quoted 30 lines

--
v3:
* fix eth layer inputset.
* rebase.
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

   doc/guides/rel_notes/release_22_11.rst |   4 +
   drivers/common/iavf/virtchnl.h         | 104 +++-
   drivers/net/iavf/iavf.h                |  13 +
   drivers/net/iavf/iavf_fdir.c           |   4 +
   drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
   drivers/net/iavf/iavf_generic_flow.c   |  40 +-
   drivers/net/iavf/iavf_generic_flow.h   |   2 +
   drivers/net/iavf/iavf_hash.c           |   5 +
   drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
   drivers/net/iavf/iavf_vchnl.c          | 133 +++++
   drivers/net/iavf/meson.build           |   1 +
   11 files changed, 1046 insertions(+), 21 deletions(-)

create mode 100644 drivers/net/iavf/iavf_fsub.c

author
#20 lore raw

v4 cover support flow subscription

In reply to Jie Wang

Add support AVF can be able to subscribe a flow from PF.

--
v4: update commit log and rebase.
v3:
* fix eth layer inputset.
* rebase.
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/common/iavf/virtchnl.h         | 104 +++-
 drivers/net/iavf/iavf.h                |  13 +
 drivers/net/iavf/iavf_fdir.c           |   4 +
 drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  40 +-
 drivers/net/iavf/iavf_generic_flow.h   |   2 +
 drivers/net/iavf/iavf_hash.c           |   5 +
 drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
 drivers/net/iavf/iavf_vchnl.c          | 133 +++++
 drivers/net/iavf/meson.build           |   1 +
 11 files changed, 1046 insertions(+), 21 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
Signature · 1 line
2.25.1
author
#21 lore raw

PATCH v4 1/5 common/iavf: support flow subscription

VF is able to subscribe a flow from PF by VIRTCHNL_FLOW_SUBSCRIBE.

PF is expected to offload a rule to hardware which will redirect the packet that matching the required pattern to this VF.

Only a flow with dst mac address as PF's mac address can be subscribed.

VIRTCHNL_VF_OFFLOAD_FSUB_PF is used for Flow subscription capability negotiation and only a trusted VF can be granted with this capability.

A flow can be unsubscribed by VIRTCHNL_FLOW_UNSUBSCRIBE.

---
 drivers/common/iavf/virtchnl.h | 104 +++++++++++++++++++++++++++++++--
 1 file changed, 100 insertions(+), 4 deletions(-)
drivers/common/iavf/virtchnl.h +100 -4
index f123daec8e..e02eec4935 100644
@@ -168,6 +168,8 @@ enum virtchnl_ops {
 	VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
 	VIRTCHNL_OP_CONFIG_QUEUE_BW = 112,
 	VIRTCHNL_OP_CONFIG_QUANTA = 113,
+	VIRTCHNL_OP_FLOW_SUBSCRIBE = 114,
+	VIRTCHNL_OP_FLOW_UNSUBSCRIBE = 115,
 	VIRTCHNL_OP_MAX,
 };
 
@@ -282,6 +284,10 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
 		return "VIRTCHNL_OP_1588_PTP_GET_CAPS";
 	case VIRTCHNL_OP_1588_PTP_GET_TIME:
 		return "VIRTCHNL_OP_1588_PTP_GET_TIME";
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_SUBSCRIBE";
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_UNSUBSCRIBE";
 	case VIRTCHNL_OP_MAX:
 		return "VIRTCHNL_OP_MAX";
 	default:
@@ -401,6 +407,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO	BIT(8)
 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS		BIT(9)
 #define VIRTCHNL_VF_OFFLOAD_CRC			BIT(10)
+#define VIRTCHNL_VF_OFFLOAD_FSUB_PF		BIT(14)
 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2		BIT(15)
 #define VIRTCHNL_VF_OFFLOAD_VLAN		BIT(16)
 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING		BIT(17)
@@ -1503,6 +1510,7 @@ enum virtchnl_vfr_states {
 };
 
 #define VIRTCHNL_MAX_NUM_PROTO_HDRS	32
+#define VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK	16
 #define VIRTCHNL_MAX_SIZE_RAW_PACKET	1024
 #define PROTO_HDR_SHIFT			5
 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
@@ -1695,6 +1703,22 @@ struct virtchnl_proto_hdr {
 
 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
 
+struct virtchnl_proto_hdr_w_msk {
+	/* see enum virtchnl_proto_hdr_type */
+	s32 type;
+	u32 pad;
+	/**
+	 * binary buffer in network order for specific header type.
+	 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
+	 * header is expected to be copied into the buffer.
+	 */
+	u8 buffer_spec[64];
+	/* binary buffer for bit-mask applied to specific header type */
+	u8 buffer_mask[64];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(136, virtchnl_proto_hdr_w_msk);
+
 struct virtchnl_proto_hdrs {
 	u8 tunnel_level;
 	/**
@@ -1706,11 +1730,18 @@ struct virtchnl_proto_hdrs {
 	 */
 	int count;
 	/**
-	 * number of proto layers, must < VIRTCHNL_MAX_NUM_PROTO_HDRS
-	 * must be 0 for a raw packet request.
+	 * count must <=
+	 * VIRTCHNL_MAX_NUM_PROTO_HDRS + VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK
+	 * count = 0 :					select raw
+	 * 1 < count <= VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr
+	 * count > VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr_w_msk
+	 * last valid index = count - VIRTCHNL_MAX_NUM_PROTO_HDRS
 	 */
 	union {
-		struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr
+			proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr_w_msk
+			proto_hdr_w_msk[VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK];
 		struct {
 			u16 pkt_len;
 			u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET];
@@ -1731,7 +1762,7 @@ struct virtchnl_rss_cfg {
 
 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
 
-/* action configuration for FDIR */
+/* action configuration for FDIR and FSUB */
 struct virtchnl_filter_action {
 	/* see enum virtchnl_action type */
 	s32 type;
@@ -1849,6 +1880,65 @@ struct virtchnl_fdir_del {
 
 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
 
+/* Status returned to VF after VF requests FSUB commands
+ * VIRTCHNL_FSUB_SUCCESS
+ * VF FLOW related request is successfully done by PF
+ * The request can be OP_FLOW_SUBSCRIBE/UNSUBSCRIBE.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE
+ * OP_FLOW_SUBSCRIBE request is failed due to no Hardware resource.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_EXIST
+ * OP_FLOW_SUBSCRIBE request is failed due to the rule is already existed.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST
+ * OP_FLOW_UNSUBSCRIBE request is failed due to this rule doesn't exist.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_INVALID
+ * OP_FLOW_SUBSCRIBE request is failed due to parameters validation
+ * or HW doesn't support.
+ */
+enum virtchnl_fsub_prgm_status {
+	VIRTCHNL_FSUB_SUCCESS = 0,
+	VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE,
+	VIRTCHNL_FSUB_FAILURE_RULE_EXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_INVALID,
+};
+
+/* VIRTCHNL_OP_FLOW_SUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id,
+ * validate_only, priority, proto_hdrs and actions.
+ * PF will return flow_id
+ * if the request is successfully done and return status to VF.
+ */
+struct virtchnl_flow_sub {
+	u16 vsi_id; /* INPUT */
+	u8 validate_only; /* INPUT */
+	u8 priority; /* INPUT */
+	u32 flow_id; /* OUTPUT */
+	struct virtchnl_proto_hdrs proto_hdrs; /* INPUT */
+	struct virtchnl_filter_action_set actions; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_flow_sub);
+
+/* VIRTCHNL_OP_FLOW_UNSUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id
+ * and flow_id. PF will return status to VF.
+ */
+struct virtchnl_flow_unsub {
+	u16 vsi_id; /* INPUT */
+	u16 pad;
+	u32 flow_id; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_flow_unsub);
+
 /* VIRTCHNL_OP_GET_QOS_CAPS
  * VF sends this message to get its QoS Caps, such as
  * TC number, Arbiter and Bandwidth.
@@ -2318,6 +2408,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 	case VIRTCHNL_OP_DEL_FDIR_FILTER:
 		valid_len = sizeof(struct virtchnl_fdir_del);
 		break;
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_sub);
+		break;
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_unsub);
+		break;
 	case VIRTCHNL_OP_GET_QOS_CAPS:
 		break;
 	case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
Signature · 1 line
2.25.1
author
#22 lore raw

PATCH v4 2/5 net/iavf: add flow subscription to AVF

In reply to Jie Wang

Add the skeletal code of flow subscription to AVF driver.

---
 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/net/iavf/iavf_fsub.c           | 112 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  17 +++-
 drivers/net/iavf/iavf_generic_flow.h   |   1 +
 drivers/net/iavf/iavf_vchnl.c          |   1 +
 drivers/net/iavf/meson.build           |   1 +
 6 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
doc/guides/rel_notes/release_22_11.rst +4 -0
index 8c021cf050..bb77a03e24 100644
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added flow subscription support.
+
 
 Removed Items
 -------------
drivers/net/iavf/iavf_fsub.c new file +112 -0

112 lines not on this page · raw message

drivers/net/iavf/iavf_generic_flow.c +16 -1
index e1a611e319..b04614ba6e 100644
@@ -1866,6 +1866,8 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 {
 	struct iavf_parser_list *list = NULL;
 	struct iavf_flow_parser_node *parser_node;
+	struct iavf_flow_parser_node *existing_node;
+	void *temp;
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
 
 	parser_node = rte_zmalloc("iavf_parser", sizeof(*parser_node), 0);
@@ -1880,14 +1882,26 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 		TAILQ_INSERT_TAIL(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR) {
 		list = &vf->dist_parser_list;
+		RTE_TAILQ_FOREACH_SAFE(existing_node, list, node, temp) {
+			if (existing_node->parser->engine->type ==
+			    IAVF_FLOW_ENGINE_FSUB) {
+				TAILQ_INSERT_AFTER(list, existing_node,
+						   parser_node, node);
+				goto DONE;
+			}
+		}
 		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_IPSEC_CRYPTO) {
 		list = &vf->ipsec_crypto_parser_list;
 		TAILQ_INSERT_HEAD(list, parser_node, node);
+	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FSUB) {
+		list = &vf->dist_parser_list;
+		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else {
 		return -EINVAL;
 	}
 
+DONE:
 	return 0;
 }
 
@@ -1902,7 +1916,8 @@ iavf_unregister_parser(struct iavf_flow_parser *parser,
 
 	if (parser->engine->type == IAVF_FLOW_ENGINE_HASH)
 		list = &vf->rss_parser_list;
-	else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR)
+	else if ((parser->engine->type == IAVF_FLOW_ENGINE_FDIR) ||
+		 (parser->engine->type == IAVF_FLOW_ENGINE_FSUB))
 		list = &vf->dist_parser_list;
 
 	if (list == NULL)
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 52eb1caf29..448facffa5 100644
@@ -480,6 +480,7 @@ enum iavf_flow_engine_type {
 	IAVF_FLOW_ENGINE_IPSEC_CRYPTO,
 	IAVF_FLOW_ENGINE_FDIR,
 	IAVF_FLOW_ENGINE_HASH,
+	IAVF_FLOW_ENGINE_FSUB,
 	IAVF_FLOW_ENGINE_MAX,
 };
 
drivers/net/iavf/iavf_vchnl.c +1 -0
index 21bd1e2193..6d84add423 100644
@@ -502,6 +502,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter)
 		VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC |
 		VIRTCHNL_VF_OFFLOAD_FDIR_PF |
 		VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF |
+		VIRTCHNL_VF_OFFLOAD_FSUB_PF |
 		VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
 		VIRTCHNL_VF_OFFLOAD_CRC |
 		VIRTCHNL_VF_OFFLOAD_VLAN_V2 |
drivers/net/iavf/meson.build +1 -0
index 2da37de662..6df771f917 100644
@@ -16,6 +16,7 @@ sources = files(
         'iavf_hash.c',
         'iavf_tm.c',
         'iavf_ipsec_crypto.c',
+        'iavf_fsub.c',
 )
 
 if arch_subdir == 'x86'
Signature · 1 line
2.25.1
author
#23 lore raw

PATCH v4 3/5 net/iavf: support flow subscrption pattern

In reply to Jie Wang

Add flow subscription pattern support for AVF.

The supported patterns are listed below:
eth/vlan/ipv4
eth/ipv4(6)
eth/ipv4(6)/udp
eth/ipv4(6)/tcp

---
 drivers/net/iavf/iavf.h      |   7 +
 drivers/net/iavf/iavf_fsub.c | 598 ++++++++++++++++++++++++++++++++++-
 2 files changed, 597 insertions(+), 8 deletions(-)
drivers/net/iavf/iavf.h +7 -0
index 025ab3ff60..f79c7f9f6e 100644
@@ -148,6 +148,13 @@ struct iavf_fdir_info {
 	struct iavf_fdir_conf conf;
 };
 
+struct iavf_fsub_conf {
+	struct virtchnl_flow_sub sub_fltr;
+	struct virtchnl_flow_unsub unsub_fltr;
+	uint64_t input_set;
+	uint32_t flow_id;
+};
+
 struct iavf_qv_map {
 	uint16_t queue_id;
 	uint16_t vector_id;
drivers/net/iavf/iavf_fsub.c +590 -8

616 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#24 lore raw

PATCH v4 4/5 net/iavf: support flow subscription rule

In reply to Jie Wang

Support flow subscribption create/destroy/validation flow rule for AVF.

For examples:
testpmd> flow create 0 ingress pattern eth / ipv4 / udp src is 11
/ end actions represented_port port_id 1 / end
testpmd> flow validate 1 ingress pattern eth / ipv4 / tcp src is 22
/ end actions represented_port port_id 1 / end
testpmd> flow destroy 1 rule 0

VF subscribes to a rule, which means the packets will be sent to VF instead of PF, and olny VF will receive the packets.

It is allowed multiple VF subscribe to same rule, the packets will be replicated and received by each VF.

PF will destroy all subscriptions during VF reset.

---
 drivers/net/iavf/iavf.h       |   6 ++
 drivers/net/iavf/iavf_fsub.c  |  75 +++++++++++++++----
 drivers/net/iavf/iavf_vchnl.c | 132 ++++++++++++++++++++++++++++++++++
 3 files changed, 201 insertions(+), 12 deletions(-)
drivers/net/iavf/iavf.h +6 -0
index f79c7f9f6e..26b858f6f0 100644
@@ -489,4 +489,10 @@ int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
 extern const struct rte_tm_ops iavf_tm_ops;
 int iavf_get_ptp_cap(struct iavf_adapter *adapter);
 int iavf_get_phc_time(struct iavf_rx_queue *rxq);
+int iavf_flow_sub(struct iavf_adapter *adapter,
+		  struct iavf_fsub_conf *filter);
+int iavf_flow_unsub(struct iavf_adapter *adapter,
+		    struct iavf_fsub_conf *filter);
+int iavf_flow_sub_check(struct iavf_adapter *adapter,
+			struct iavf_fsub_conf *filter);
 #endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_fsub.c +63 -12

92 lines not on this page · raw message

drivers/net/iavf/iavf_vchnl.c +132 -0

138 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#25 lore raw

PATCH v4 5/5 net/iavf: support priority of flow rule

In reply to Jie Wang

Add flow rule attribute "priority" support for AVF.

Lower values denote higher priority, the highest priority for a flow rule is 0.

All subscription rule will have a lower priority than the rules that be created by host.

---
 drivers/net/iavf/iavf_fdir.c         |  4 ++++
 drivers/net/iavf/iavf_fsub.c         |  2 +-
 drivers/net/iavf/iavf_generic_flow.c | 23 +++++++++++++----------
 drivers/net/iavf/iavf_generic_flow.h |  1 +
 drivers/net/iavf/iavf_hash.c         |  5 +++++
 drivers/net/iavf/iavf_ipsec_crypto.c | 16 ++++++++++------
 6 files changed, 34 insertions(+), 17 deletions(-)
drivers/net/iavf/iavf_fdir.c +4 -0
index a397047fdb..8f80873925 100644
@@ -1583,6 +1583,7 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
@@ -1593,6 +1594,9 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 
 	memset(filter, 0, sizeof(*filter));
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (!item)
 		return -rte_errno;
drivers/net/iavf/iavf_fsub.c +1 -1
index b9ad3531ff..46effda9a0 100644
@@ -649,13 +649,13 @@ iavf_fsub_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
 	struct iavf_fsub_conf *filter;
 	struct iavf_pattern_match_item *pattern_match_item = NULL;
 	int ret = 0;
-	uint32_t priority = 0;
 
 	filter = rte_zmalloc(NULL, sizeof(*filter), 0);
 	if (!filter) {
drivers/net/iavf/iavf_generic_flow.c +13 -10
index b04614ba6e..f33c764764 100644
@@ -1785,6 +1785,7 @@ enum rte_flow_item_type iavf_pattern_eth_ipv6_udp_l2tpv2_ppp_ipv6_tcp[] = {
 typedef struct iavf_flow_engine * (*parse_engine_t)(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error);
@@ -1951,11 +1952,11 @@ iavf_flow_valid_attr(const struct rte_flow_attr *attr,
 		return -rte_errno;
 	}
 
-	/* Not supported */
-	if (attr->priority) {
+	/* support priority for flow subscribe */
+	if (attr->priority > 1) {
 		rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
-				attr, "Not support priority.");
+				attr, "Only support priority 0 and 1.");
 		return -rte_errno;
 	}
 
@@ -2098,6 +2099,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_create(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2111,7 +2113,7 @@ iavf_parse_engine_create(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta, error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2127,6 +2129,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_validate(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2140,7 +2143,7 @@ iavf_parse_engine_validate(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta,  error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2201,18 +2204,18 @@ iavf_flow_process_filter(struct rte_eth_dev *dev,
 	if (ret)
 		return ret;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
 	*engine = iavf_parse_engine(ad, flow, &vf->ipsec_crypto_parser_list,
-			pattern, actions, error);
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 448facffa5..60d8ab02b4 100644
@@ -471,6 +471,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error);
 
drivers/net/iavf/iavf_hash.c +5 -0
index 42df7c4e48..dea4e0aa0a 100644
@@ -86,6 +86,7 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error);
 
@@ -1509,6 +1510,7 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error)
 {
@@ -1517,6 +1519,9 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 	uint64_t phint = IAVF_PHINT_NONE;
 	int ret = 0;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
 	if (!rss_meta_ptr) {
 		rte_flow_error_set(error, EINVAL,
drivers/net/iavf/iavf_ipsec_crypto.c +10 -6
index 1d465b4419..cec1b968fe 100644
@@ -1933,16 +1933,20 @@ static struct iavf_flow_engine iavf_ipsec_flow_engine = {
 
 static int
 iavf_ipsec_flow_parse(struct iavf_adapter *ad,
-		       struct iavf_pattern_match_item *array,
-		       uint32_t array_len,
-		       const struct rte_flow_item pattern[],
-		       const struct rte_flow_action actions[],
-		       void **meta,
-		       struct rte_flow_error *error)
+		      struct iavf_pattern_match_item *array,
+		      uint32_t array_len,
+		      const struct rte_flow_item pattern[],
+		      const struct rte_flow_action actions[],
+		      uint32_t priority,
+		      void **meta,
+		      struct rte_flow_error *error)
 {
 	struct iavf_pattern_match_item *item = NULL;
 	int ret = -1;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (item && item->meta) {
 		uint32_t type = (uint64_t)(item->meta);
Signature · 1 line
2.25.1
author
#26 lore raw

v4 cover support flow subscription

In reply to Jie Wang

Add support AVF can be able to subscribe a flow from PF.

--
v4:
* replace flow action represented_port with port_representor.
* update commit log and rebase.
v3:
* fix eth layer inputset.
* rebase.
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/common/iavf/virtchnl.h         | 104 +++-
 drivers/net/iavf/iavf.h                |  13 +
 drivers/net/iavf/iavf_fdir.c           |   4 +
 drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  40 +-
 drivers/net/iavf/iavf_generic_flow.h   |   2 +
 drivers/net/iavf/iavf_hash.c           |   5 +
 drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
 drivers/net/iavf/iavf_vchnl.c          | 133 +++++
 drivers/net/iavf/meson.build           |   1 +
 11 files changed, 1046 insertions(+), 21 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
Signature · 1 line
2.25.1
author
#27 lore raw

PATCH v4 1/5 common/iavf: support flow subscription

VF is able to subscribe a flow from PF by VIRTCHNL_FLOW_SUBSCRIBE.

PF is expected to offload a rule to hardware which will redirect the packet that matching the required pattern to this VF.

Only a flow with dst mac address as PF's mac address can be subscribed.

VIRTCHNL_VF_OFFLOAD_FSUB_PF is used for Flow subscription capability negotiation and only a trusted VF can be granted with this capability.

A flow can be unsubscribed by VIRTCHNL_FLOW_UNSUBSCRIBE.

---
 drivers/common/iavf/virtchnl.h | 104 +++++++++++++++++++++++++++++++--
 1 file changed, 100 insertions(+), 4 deletions(-)
drivers/common/iavf/virtchnl.h +100 -4
index f123daec8e..e02eec4935 100644
@@ -168,6 +168,8 @@ enum virtchnl_ops {
 	VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
 	VIRTCHNL_OP_CONFIG_QUEUE_BW = 112,
 	VIRTCHNL_OP_CONFIG_QUANTA = 113,
+	VIRTCHNL_OP_FLOW_SUBSCRIBE = 114,
+	VIRTCHNL_OP_FLOW_UNSUBSCRIBE = 115,
 	VIRTCHNL_OP_MAX,
 };
 
@@ -282,6 +284,10 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
 		return "VIRTCHNL_OP_1588_PTP_GET_CAPS";
 	case VIRTCHNL_OP_1588_PTP_GET_TIME:
 		return "VIRTCHNL_OP_1588_PTP_GET_TIME";
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_SUBSCRIBE";
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_UNSUBSCRIBE";
 	case VIRTCHNL_OP_MAX:
 		return "VIRTCHNL_OP_MAX";
 	default:
@@ -401,6 +407,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO	BIT(8)
 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS		BIT(9)
 #define VIRTCHNL_VF_OFFLOAD_CRC			BIT(10)
+#define VIRTCHNL_VF_OFFLOAD_FSUB_PF		BIT(14)
 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2		BIT(15)
 #define VIRTCHNL_VF_OFFLOAD_VLAN		BIT(16)
 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING		BIT(17)
@@ -1503,6 +1510,7 @@ enum virtchnl_vfr_states {
 };
 
 #define VIRTCHNL_MAX_NUM_PROTO_HDRS	32
+#define VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK	16
 #define VIRTCHNL_MAX_SIZE_RAW_PACKET	1024
 #define PROTO_HDR_SHIFT			5
 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
@@ -1695,6 +1703,22 @@ struct virtchnl_proto_hdr {
 
 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
 
+struct virtchnl_proto_hdr_w_msk {
+	/* see enum virtchnl_proto_hdr_type */
+	s32 type;
+	u32 pad;
+	/**
+	 * binary buffer in network order for specific header type.
+	 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
+	 * header is expected to be copied into the buffer.
+	 */
+	u8 buffer_spec[64];
+	/* binary buffer for bit-mask applied to specific header type */
+	u8 buffer_mask[64];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(136, virtchnl_proto_hdr_w_msk);
+
 struct virtchnl_proto_hdrs {
 	u8 tunnel_level;
 	/**
@@ -1706,11 +1730,18 @@ struct virtchnl_proto_hdrs {
 	 */
 	int count;
 	/**
-	 * number of proto layers, must < VIRTCHNL_MAX_NUM_PROTO_HDRS
-	 * must be 0 for a raw packet request.
+	 * count must <=
+	 * VIRTCHNL_MAX_NUM_PROTO_HDRS + VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK
+	 * count = 0 :					select raw
+	 * 1 < count <= VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr
+	 * count > VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr_w_msk
+	 * last valid index = count - VIRTCHNL_MAX_NUM_PROTO_HDRS
 	 */
 	union {
-		struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr
+			proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr_w_msk
+			proto_hdr_w_msk[VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK];
 		struct {
 			u16 pkt_len;
 			u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET];
@@ -1731,7 +1762,7 @@ struct virtchnl_rss_cfg {
 
 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
 
-/* action configuration for FDIR */
+/* action configuration for FDIR and FSUB */
 struct virtchnl_filter_action {
 	/* see enum virtchnl_action type */
 	s32 type;
@@ -1849,6 +1880,65 @@ struct virtchnl_fdir_del {
 
 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
 
+/* Status returned to VF after VF requests FSUB commands
+ * VIRTCHNL_FSUB_SUCCESS
+ * VF FLOW related request is successfully done by PF
+ * The request can be OP_FLOW_SUBSCRIBE/UNSUBSCRIBE.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE
+ * OP_FLOW_SUBSCRIBE request is failed due to no Hardware resource.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_EXIST
+ * OP_FLOW_SUBSCRIBE request is failed due to the rule is already existed.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST
+ * OP_FLOW_UNSUBSCRIBE request is failed due to this rule doesn't exist.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_INVALID
+ * OP_FLOW_SUBSCRIBE request is failed due to parameters validation
+ * or HW doesn't support.
+ */
+enum virtchnl_fsub_prgm_status {
+	VIRTCHNL_FSUB_SUCCESS = 0,
+	VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE,
+	VIRTCHNL_FSUB_FAILURE_RULE_EXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_INVALID,
+};
+
+/* VIRTCHNL_OP_FLOW_SUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id,
+ * validate_only, priority, proto_hdrs and actions.
+ * PF will return flow_id
+ * if the request is successfully done and return status to VF.
+ */
+struct virtchnl_flow_sub {
+	u16 vsi_id; /* INPUT */
+	u8 validate_only; /* INPUT */
+	u8 priority; /* INPUT */
+	u32 flow_id; /* OUTPUT */
+	struct virtchnl_proto_hdrs proto_hdrs; /* INPUT */
+	struct virtchnl_filter_action_set actions; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_flow_sub);
+
+/* VIRTCHNL_OP_FLOW_UNSUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id
+ * and flow_id. PF will return status to VF.
+ */
+struct virtchnl_flow_unsub {
+	u16 vsi_id; /* INPUT */
+	u16 pad;
+	u32 flow_id; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_flow_unsub);
+
 /* VIRTCHNL_OP_GET_QOS_CAPS
  * VF sends this message to get its QoS Caps, such as
  * TC number, Arbiter and Bandwidth.
@@ -2318,6 +2408,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 	case VIRTCHNL_OP_DEL_FDIR_FILTER:
 		valid_len = sizeof(struct virtchnl_fdir_del);
 		break;
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_sub);
+		break;
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_unsub);
+		break;
 	case VIRTCHNL_OP_GET_QOS_CAPS:
 		break;
 	case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
Signature · 1 line
2.25.1
author
#28 lore raw

PATCH v4 2/5 net/iavf: add flow subscription to AVF

In reply to Jie Wang

Add the skeletal code of flow subscription to AVF driver.

---
 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/net/iavf/iavf_fsub.c           | 112 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  17 +++-
 drivers/net/iavf/iavf_generic_flow.h   |   1 +
 drivers/net/iavf/iavf_vchnl.c          |   1 +
 drivers/net/iavf/meson.build           |   1 +
 6 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
doc/guides/rel_notes/release_22_11.rst +4 -0
index 8c021cf050..bb77a03e24 100644
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added flow subscription support.
+
 
 Removed Items
 -------------
drivers/net/iavf/iavf_fsub.c new file +112 -0

112 lines not on this page · raw message

drivers/net/iavf/iavf_generic_flow.c +16 -1
index e1a611e319..b04614ba6e 100644
@@ -1866,6 +1866,8 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 {
 	struct iavf_parser_list *list = NULL;
 	struct iavf_flow_parser_node *parser_node;
+	struct iavf_flow_parser_node *existing_node;
+	void *temp;
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
 
 	parser_node = rte_zmalloc("iavf_parser", sizeof(*parser_node), 0);
@@ -1880,14 +1882,26 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 		TAILQ_INSERT_TAIL(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR) {
 		list = &vf->dist_parser_list;
+		RTE_TAILQ_FOREACH_SAFE(existing_node, list, node, temp) {
+			if (existing_node->parser->engine->type ==
+			    IAVF_FLOW_ENGINE_FSUB) {
+				TAILQ_INSERT_AFTER(list, existing_node,
+						   parser_node, node);
+				goto DONE;
+			}
+		}
 		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_IPSEC_CRYPTO) {
 		list = &vf->ipsec_crypto_parser_list;
 		TAILQ_INSERT_HEAD(list, parser_node, node);
+	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FSUB) {
+		list = &vf->dist_parser_list;
+		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else {
 		return -EINVAL;
 	}
 
+DONE:
 	return 0;
 }
 
@@ -1902,7 +1916,8 @@ iavf_unregister_parser(struct iavf_flow_parser *parser,
 
 	if (parser->engine->type == IAVF_FLOW_ENGINE_HASH)
 		list = &vf->rss_parser_list;
-	else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR)
+	else if ((parser->engine->type == IAVF_FLOW_ENGINE_FDIR) ||
+		 (parser->engine->type == IAVF_FLOW_ENGINE_FSUB))
 		list = &vf->dist_parser_list;
 
 	if (list == NULL)
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 52eb1caf29..448facffa5 100644
@@ -480,6 +480,7 @@ enum iavf_flow_engine_type {
 	IAVF_FLOW_ENGINE_IPSEC_CRYPTO,
 	IAVF_FLOW_ENGINE_FDIR,
 	IAVF_FLOW_ENGINE_HASH,
+	IAVF_FLOW_ENGINE_FSUB,
 	IAVF_FLOW_ENGINE_MAX,
 };
 
drivers/net/iavf/iavf_vchnl.c +1 -0
index 21bd1e2193..6d84add423 100644
@@ -502,6 +502,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter)
 		VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC |
 		VIRTCHNL_VF_OFFLOAD_FDIR_PF |
 		VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF |
+		VIRTCHNL_VF_OFFLOAD_FSUB_PF |
 		VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
 		VIRTCHNL_VF_OFFLOAD_CRC |
 		VIRTCHNL_VF_OFFLOAD_VLAN_V2 |
drivers/net/iavf/meson.build +1 -0
index 2da37de662..6df771f917 100644
@@ -16,6 +16,7 @@ sources = files(
         'iavf_hash.c',
         'iavf_tm.c',
         'iavf_ipsec_crypto.c',
+        'iavf_fsub.c',
 )
 
 if arch_subdir == 'x86'
Signature · 1 line
2.25.1
author
#29 lore raw

PATCH v4 3/5 net/iavf: support flow subscrption pattern

In reply to Jie Wang

Add flow subscription pattern support for AVF.

The supported patterns are listed below:
eth/vlan/ipv4
eth/ipv4(6)
eth/ipv4(6)/udp
eth/ipv4(6)/tcp

---
 drivers/net/iavf/iavf.h      |   7 +
 drivers/net/iavf/iavf_fsub.c | 598 ++++++++++++++++++++++++++++++++++-
 2 files changed, 597 insertions(+), 8 deletions(-)
drivers/net/iavf/iavf.h +7 -0
index 025ab3ff60..f79c7f9f6e 100644
@@ -148,6 +148,13 @@ struct iavf_fdir_info {
 	struct iavf_fdir_conf conf;
 };
 
+struct iavf_fsub_conf {
+	struct virtchnl_flow_sub sub_fltr;
+	struct virtchnl_flow_unsub unsub_fltr;
+	uint64_t input_set;
+	uint32_t flow_id;
+};
+
 struct iavf_qv_map {
 	uint16_t queue_id;
 	uint16_t vector_id;
drivers/net/iavf/iavf_fsub.c +590 -8

616 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#30 lore raw

PATCH v4 4/5 net/iavf: support flow subscription rule

In reply to Jie Wang

Support flow subscribption create/destroy/validation flow rule for AVF.

For examples:
testpmd> flow create 0 ingress pattern eth / ipv4 / udp src is 11
/ end actions represented_port port_id 1 / end
testpmd> flow validate 1 ingress pattern eth / ipv4 / tcp src is 22
/ end actions represented_port port_id 1 / end
testpmd> flow destroy 1 rule 0

VF subscribes to a rule, which means the packets will be sent to VF instead of PF, and only VF will receive the packets.

It is allowed multiple VF subscribe to same rule, the packets will be replicated and received by each VF.

PF will destroy all subscriptions during VF reset.

---
 drivers/net/iavf/iavf.h       |   6 ++
 drivers/net/iavf/iavf_fsub.c  |  75 +++++++++++++++----
 drivers/net/iavf/iavf_vchnl.c | 132 ++++++++++++++++++++++++++++++++++
 3 files changed, 201 insertions(+), 12 deletions(-)
drivers/net/iavf/iavf.h +6 -0
index f79c7f9f6e..26b858f6f0 100644
@@ -489,4 +489,10 @@ int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
 extern const struct rte_tm_ops iavf_tm_ops;
 int iavf_get_ptp_cap(struct iavf_adapter *adapter);
 int iavf_get_phc_time(struct iavf_rx_queue *rxq);
+int iavf_flow_sub(struct iavf_adapter *adapter,
+		  struct iavf_fsub_conf *filter);
+int iavf_flow_unsub(struct iavf_adapter *adapter,
+		    struct iavf_fsub_conf *filter);
+int iavf_flow_sub_check(struct iavf_adapter *adapter,
+			struct iavf_fsub_conf *filter);
 #endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_fsub.c +63 -12

92 lines not on this page · raw message

drivers/net/iavf/iavf_vchnl.c +132 -0

138 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#31 lore raw

PATCH v4 5/5 net/iavf: support priority of flow rule

In reply to Jie Wang

Add flow rule attribute "priority" support for AVF.

Lower values denote higher priority, the highest priority for a flow rule is 0.

All subscription rule will have a lower priority than the rules that be created by host.

---
 drivers/net/iavf/iavf_fdir.c         |  4 ++++
 drivers/net/iavf/iavf_fsub.c         |  2 +-
 drivers/net/iavf/iavf_generic_flow.c | 23 +++++++++++++----------
 drivers/net/iavf/iavf_generic_flow.h |  1 +
 drivers/net/iavf/iavf_hash.c         |  5 +++++
 drivers/net/iavf/iavf_ipsec_crypto.c | 16 ++++++++++------
 6 files changed, 34 insertions(+), 17 deletions(-)
drivers/net/iavf/iavf_fdir.c +4 -0
index a397047fdb..8f80873925 100644
@@ -1583,6 +1583,7 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
@@ -1593,6 +1594,9 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 
 	memset(filter, 0, sizeof(*filter));
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (!item)
 		return -rte_errno;
drivers/net/iavf/iavf_fsub.c +1 -1
index 28857d7577..3bb6c30d3c 100644
@@ -649,13 +649,13 @@ iavf_fsub_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
 	struct iavf_fsub_conf *filter;
 	struct iavf_pattern_match_item *pattern_match_item = NULL;
 	int ret = 0;
-	uint32_t priority = 0;
 
 	filter = rte_zmalloc(NULL, sizeof(*filter), 0);
 	if (!filter) {
drivers/net/iavf/iavf_generic_flow.c +13 -10
index b04614ba6e..f33c764764 100644
@@ -1785,6 +1785,7 @@ enum rte_flow_item_type iavf_pattern_eth_ipv6_udp_l2tpv2_ppp_ipv6_tcp[] = {
 typedef struct iavf_flow_engine * (*parse_engine_t)(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error);
@@ -1951,11 +1952,11 @@ iavf_flow_valid_attr(const struct rte_flow_attr *attr,
 		return -rte_errno;
 	}
 
-	/* Not supported */
-	if (attr->priority) {
+	/* support priority for flow subscribe */
+	if (attr->priority > 1) {
 		rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
-				attr, "Not support priority.");
+				attr, "Only support priority 0 and 1.");
 		return -rte_errno;
 	}
 
@@ -2098,6 +2099,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_create(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2111,7 +2113,7 @@ iavf_parse_engine_create(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta, error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2127,6 +2129,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_validate(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2140,7 +2143,7 @@ iavf_parse_engine_validate(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta,  error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2201,18 +2204,18 @@ iavf_flow_process_filter(struct rte_eth_dev *dev,
 	if (ret)
 		return ret;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
 	*engine = iavf_parse_engine(ad, flow, &vf->ipsec_crypto_parser_list,
-			pattern, actions, error);
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 448facffa5..60d8ab02b4 100644
@@ -471,6 +471,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error);
 
drivers/net/iavf/iavf_hash.c +5 -0
index 42df7c4e48..dea4e0aa0a 100644
@@ -86,6 +86,7 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error);
 
@@ -1509,6 +1510,7 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error)
 {
@@ -1517,6 +1519,9 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 	uint64_t phint = IAVF_PHINT_NONE;
 	int ret = 0;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
 	if (!rss_meta_ptr) {
 		rte_flow_error_set(error, EINVAL,
drivers/net/iavf/iavf_ipsec_crypto.c +10 -6
index 1d465b4419..cec1b968fe 100644
@@ -1933,16 +1933,20 @@ static struct iavf_flow_engine iavf_ipsec_flow_engine = {
 
 static int
 iavf_ipsec_flow_parse(struct iavf_adapter *ad,
-		       struct iavf_pattern_match_item *array,
-		       uint32_t array_len,
-		       const struct rte_flow_item pattern[],
-		       const struct rte_flow_action actions[],
-		       void **meta,
-		       struct rte_flow_error *error)
+		      struct iavf_pattern_match_item *array,
+		      uint32_t array_len,
+		      const struct rte_flow_item pattern[],
+		      const struct rte_flow_action actions[],
+		      uint32_t priority,
+		      void **meta,
+		      struct rte_flow_error *error)
 {
 	struct iavf_pattern_match_item *item = NULL;
 	int ret = -1;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (item && item->meta) {
 		uint32_t type = (uint64_t)(item->meta);
Signature · 1 line
2.25.1
author
#32 lore raw

v5 cover support flow subscription

In reply to Jie Wang

Add support AVF can be able to subscribe a flow from PF.

--
v4:
* replace flow action represented_port with port_representor.
* update commit log and rebase.
v3:
* fix eth layer inputset.
* rebase.
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/common/iavf/virtchnl.h         | 104 +++-
 drivers/net/iavf/iavf.h                |  13 +
 drivers/net/iavf/iavf_fdir.c           |   4 +
 drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  40 +-
 drivers/net/iavf/iavf_generic_flow.h   |   2 +
 drivers/net/iavf/iavf_hash.c           |   5 +
 drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
 drivers/net/iavf/iavf_vchnl.c          | 133 +++++
 drivers/net/iavf/meson.build           |   1 +
 11 files changed, 1046 insertions(+), 21 deletions(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
Signature · 1 line
2.25.1
author
#33 lore raw

PATCH v5 1/5 common/iavf: support flow subscription

VF is able to subscribe a flow from PF by VIRTCHNL_FLOW_SUBSCRIBE.

PF is expected to offload a rule to hardware which will redirect the packet that matching the required pattern to this VF.

Only a flow with dst mac address as PF's mac address can be subscribed.

VIRTCHNL_VF_OFFLOAD_FSUB_PF is used for Flow subscription capability negotiation and only a trusted VF can be granted with this capability.

A flow can be unsubscribed by VIRTCHNL_FLOW_UNSUBSCRIBE.

---
 drivers/common/iavf/virtchnl.h | 104 +++++++++++++++++++++++++++++++--
 1 file changed, 100 insertions(+), 4 deletions(-)
drivers/common/iavf/virtchnl.h +100 -4
index f123daec8e..e02eec4935 100644
@@ -168,6 +168,8 @@ enum virtchnl_ops {
 	VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
 	VIRTCHNL_OP_CONFIG_QUEUE_BW = 112,
 	VIRTCHNL_OP_CONFIG_QUANTA = 113,
+	VIRTCHNL_OP_FLOW_SUBSCRIBE = 114,
+	VIRTCHNL_OP_FLOW_UNSUBSCRIBE = 115,
 	VIRTCHNL_OP_MAX,
 };
 
@@ -282,6 +284,10 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
 		return "VIRTCHNL_OP_1588_PTP_GET_CAPS";
 	case VIRTCHNL_OP_1588_PTP_GET_TIME:
 		return "VIRTCHNL_OP_1588_PTP_GET_TIME";
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_SUBSCRIBE";
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		return "VIRTCHNL_OP_FLOW_UNSUBSCRIBE";
 	case VIRTCHNL_OP_MAX:
 		return "VIRTCHNL_OP_MAX";
 	default:
@@ -401,6 +407,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO	BIT(8)
 #define VIRTCHNL_VF_LARGE_NUM_QPAIRS		BIT(9)
 #define VIRTCHNL_VF_OFFLOAD_CRC			BIT(10)
+#define VIRTCHNL_VF_OFFLOAD_FSUB_PF		BIT(14)
 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2		BIT(15)
 #define VIRTCHNL_VF_OFFLOAD_VLAN		BIT(16)
 #define VIRTCHNL_VF_OFFLOAD_RX_POLLING		BIT(17)
@@ -1503,6 +1510,7 @@ enum virtchnl_vfr_states {
 };
 
 #define VIRTCHNL_MAX_NUM_PROTO_HDRS	32
+#define VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK	16
 #define VIRTCHNL_MAX_SIZE_RAW_PACKET	1024
 #define PROTO_HDR_SHIFT			5
 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
@@ -1695,6 +1703,22 @@ struct virtchnl_proto_hdr {
 
 VIRTCHNL_CHECK_STRUCT_LEN(72, virtchnl_proto_hdr);
 
+struct virtchnl_proto_hdr_w_msk {
+	/* see enum virtchnl_proto_hdr_type */
+	s32 type;
+	u32 pad;
+	/**
+	 * binary buffer in network order for specific header type.
+	 * For example, if type = VIRTCHNL_PROTO_HDR_IPV4, a IPv4
+	 * header is expected to be copied into the buffer.
+	 */
+	u8 buffer_spec[64];
+	/* binary buffer for bit-mask applied to specific header type */
+	u8 buffer_mask[64];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(136, virtchnl_proto_hdr_w_msk);
+
 struct virtchnl_proto_hdrs {
 	u8 tunnel_level;
 	/**
@@ -1706,11 +1730,18 @@ struct virtchnl_proto_hdrs {
 	 */
 	int count;
 	/**
-	 * number of proto layers, must < VIRTCHNL_MAX_NUM_PROTO_HDRS
-	 * must be 0 for a raw packet request.
+	 * count must <=
+	 * VIRTCHNL_MAX_NUM_PROTO_HDRS + VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK
+	 * count = 0 :					select raw
+	 * 1 < count <= VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr
+	 * count > VIRTCHNL_MAX_NUM_PROTO_HDRS :	select proto_hdr_w_msk
+	 * last valid index = count - VIRTCHNL_MAX_NUM_PROTO_HDRS
 	 */
 	union {
-		struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr
+			proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct virtchnl_proto_hdr_w_msk
+			proto_hdr_w_msk[VIRTCHNL_MAX_NUM_PROTO_HDRS_W_MSK];
 		struct {
 			u16 pkt_len;
 			u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET];
@@ -1731,7 +1762,7 @@ struct virtchnl_rss_cfg {
 
 VIRTCHNL_CHECK_STRUCT_LEN(2444, virtchnl_rss_cfg);
 
-/* action configuration for FDIR */
+/* action configuration for FDIR and FSUB */
 struct virtchnl_filter_action {
 	/* see enum virtchnl_action type */
 	s32 type;
@@ -1849,6 +1880,65 @@ struct virtchnl_fdir_del {
 
 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
 
+/* Status returned to VF after VF requests FSUB commands
+ * VIRTCHNL_FSUB_SUCCESS
+ * VF FLOW related request is successfully done by PF
+ * The request can be OP_FLOW_SUBSCRIBE/UNSUBSCRIBE.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE
+ * OP_FLOW_SUBSCRIBE request is failed due to no Hardware resource.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_EXIST
+ * OP_FLOW_SUBSCRIBE request is failed due to the rule is already existed.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST
+ * OP_FLOW_UNSUBSCRIBE request is failed due to this rule doesn't exist.
+ *
+ * VIRTCHNL_FSUB_FAILURE_RULE_INVALID
+ * OP_FLOW_SUBSCRIBE request is failed due to parameters validation
+ * or HW doesn't support.
+ */
+enum virtchnl_fsub_prgm_status {
+	VIRTCHNL_FSUB_SUCCESS = 0,
+	VIRTCHNL_FSUB_FAILURE_RULE_NORESOURCE,
+	VIRTCHNL_FSUB_FAILURE_RULE_EXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_NONEXIST,
+	VIRTCHNL_FSUB_FAILURE_RULE_INVALID,
+};
+
+/* VIRTCHNL_OP_FLOW_SUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id,
+ * validate_only, priority, proto_hdrs and actions.
+ * PF will return flow_id
+ * if the request is successfully done and return status to VF.
+ */
+struct virtchnl_flow_sub {
+	u16 vsi_id; /* INPUT */
+	u8 validate_only; /* INPUT */
+	u8 priority; /* INPUT */
+	u32 flow_id; /* OUTPUT */
+	struct virtchnl_proto_hdrs proto_hdrs; /* INPUT */
+	struct virtchnl_filter_action_set actions; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(2616, virtchnl_flow_sub);
+
+/* VIRTCHNL_OP_FLOW_UNSUBSCRIBE
+ * VF sends this request to PF by filling out vsi_id
+ * and flow_id. PF will return status to VF.
+ */
+struct virtchnl_flow_unsub {
+	u16 vsi_id; /* INPUT */
+	u16 pad;
+	u32 flow_id; /* INPUT */
+	/* see enum virtchnl_fsub_prgm_status; OUTPUT */
+	s32 status;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_flow_unsub);
+
 /* VIRTCHNL_OP_GET_QOS_CAPS
  * VF sends this message to get its QoS Caps, such as
  * TC number, Arbiter and Bandwidth.
@@ -2318,6 +2408,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 	case VIRTCHNL_OP_DEL_FDIR_FILTER:
 		valid_len = sizeof(struct virtchnl_fdir_del);
 		break;
+	case VIRTCHNL_OP_FLOW_SUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_sub);
+		break;
+	case VIRTCHNL_OP_FLOW_UNSUBSCRIBE:
+		valid_len = sizeof(struct virtchnl_flow_unsub);
+		break;
 	case VIRTCHNL_OP_GET_QOS_CAPS:
 		break;
 	case VIRTCHNL_OP_CONFIG_QUEUE_TC_MAP:
Signature · 1 line
2.25.1
author
#34 lore raw

PATCH v5 2/5 net/iavf: add flow subscription to AVF

In reply to Jie Wang

Add the skeletal code of flow subscription to AVF driver.

---
 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/net/iavf/iavf_fsub.c           | 112 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  17 +++-
 drivers/net/iavf/iavf_generic_flow.h   |   1 +
 drivers/net/iavf/iavf_vchnl.c          |   1 +
 drivers/net/iavf/meson.build           |   1 +
 6 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/iavf/iavf_fsub.c
doc/guides/rel_notes/release_22_11.rst +4 -0
index 8c021cf050..bb77a03e24 100644
@@ -55,6 +55,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Updated Intel iavf driver.**
+
+  * Added flow subscription support.
+
 
 Removed Items
 -------------
drivers/net/iavf/iavf_fsub.c new file +112 -0

112 lines not on this page · raw message

drivers/net/iavf/iavf_generic_flow.c +16 -1
index e1a611e319..b04614ba6e 100644
@@ -1866,6 +1866,8 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 {
 	struct iavf_parser_list *list = NULL;
 	struct iavf_flow_parser_node *parser_node;
+	struct iavf_flow_parser_node *existing_node;
+	void *temp;
 	struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
 
 	parser_node = rte_zmalloc("iavf_parser", sizeof(*parser_node), 0);
@@ -1880,14 +1882,26 @@ iavf_register_parser(struct iavf_flow_parser *parser,
 		TAILQ_INSERT_TAIL(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR) {
 		list = &vf->dist_parser_list;
+		RTE_TAILQ_FOREACH_SAFE(existing_node, list, node, temp) {
+			if (existing_node->parser->engine->type ==
+			    IAVF_FLOW_ENGINE_FSUB) {
+				TAILQ_INSERT_AFTER(list, existing_node,
+						   parser_node, node);
+				goto DONE;
+			}
+		}
 		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else if (parser->engine->type == IAVF_FLOW_ENGINE_IPSEC_CRYPTO) {
 		list = &vf->ipsec_crypto_parser_list;
 		TAILQ_INSERT_HEAD(list, parser_node, node);
+	} else if (parser->engine->type == IAVF_FLOW_ENGINE_FSUB) {
+		list = &vf->dist_parser_list;
+		TAILQ_INSERT_HEAD(list, parser_node, node);
 	} else {
 		return -EINVAL;
 	}
 
+DONE:
 	return 0;
 }
 
@@ -1902,7 +1916,8 @@ iavf_unregister_parser(struct iavf_flow_parser *parser,
 
 	if (parser->engine->type == IAVF_FLOW_ENGINE_HASH)
 		list = &vf->rss_parser_list;
-	else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR)
+	else if ((parser->engine->type == IAVF_FLOW_ENGINE_FDIR) ||
+		 (parser->engine->type == IAVF_FLOW_ENGINE_FSUB))
 		list = &vf->dist_parser_list;
 
 	if (list == NULL)
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 52eb1caf29..448facffa5 100644
@@ -480,6 +480,7 @@ enum iavf_flow_engine_type {
 	IAVF_FLOW_ENGINE_IPSEC_CRYPTO,
 	IAVF_FLOW_ENGINE_FDIR,
 	IAVF_FLOW_ENGINE_HASH,
+	IAVF_FLOW_ENGINE_FSUB,
 	IAVF_FLOW_ENGINE_MAX,
 };
 
drivers/net/iavf/iavf_vchnl.c +1 -0
index 21bd1e2193..6d84add423 100644
@@ -502,6 +502,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter)
 		VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC |
 		VIRTCHNL_VF_OFFLOAD_FDIR_PF |
 		VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF |
+		VIRTCHNL_VF_OFFLOAD_FSUB_PF |
 		VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
 		VIRTCHNL_VF_OFFLOAD_CRC |
 		VIRTCHNL_VF_OFFLOAD_VLAN_V2 |
drivers/net/iavf/meson.build +1 -0
index 2da37de662..6df771f917 100644
@@ -16,6 +16,7 @@ sources = files(
         'iavf_hash.c',
         'iavf_tm.c',
         'iavf_ipsec_crypto.c',
+        'iavf_fsub.c',
 )
 
 if arch_subdir == 'x86'
Signature · 1 line
2.25.1
author
#35 lore raw

PATCH v5 3/5 net/iavf: support flow subscrption pattern

In reply to Jie Wang

Add flow subscription pattern support for AVF.

The supported patterns are listed below:
eth/vlan/ipv4
eth/ipv4(6)
eth/ipv4(6)/udp
eth/ipv4(6)/tcp

---
 drivers/net/iavf/iavf.h      |   7 +
 drivers/net/iavf/iavf_fsub.c | 598 ++++++++++++++++++++++++++++++++++-
 2 files changed, 597 insertions(+), 8 deletions(-)
drivers/net/iavf/iavf.h +7 -0
index 025ab3ff60..f79c7f9f6e 100644
@@ -148,6 +148,13 @@ struct iavf_fdir_info {
 	struct iavf_fdir_conf conf;
 };
 
+struct iavf_fsub_conf {
+	struct virtchnl_flow_sub sub_fltr;
+	struct virtchnl_flow_unsub unsub_fltr;
+	uint64_t input_set;
+	uint32_t flow_id;
+};
+
 struct iavf_qv_map {
 	uint16_t queue_id;
 	uint16_t vector_id;
drivers/net/iavf/iavf_fsub.c +590 -8

616 lines not on this page · raw message

Signature · 1 line
2.25.1
#36 lore raw

RE: [PATCH v5 3/5] net/iavf: support flow subscrption pattern

Quoted 28 lines

-----Original Message-----
From: Wang, Jie1X <[email protected]>
Sent: Wednesday, September 7, 2022 1:11 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Wang, Jie1X <[email protected]>
Subject: [PATCH v5 3/5] net/iavf: support flow subscrption pattern

Add flow subscription pattern support for AVF.

The supported patterns are listed below:
eth/vlan/ipv4
eth/ipv4(6)
eth/ipv4(6)/udp
eth/ipv4(6)/tcp

---

drivers/net/iavf/iavf_fsub.c +5 -0
+static int
+iavf_fsub_check_action(const struct rte_flow_action *actions,
+		       struct rte_flow_error *error)
+{
+	const struct rte_flow_action *action;

drivers/net/iavf/iavf_fsub.c iavf_fsub_validation(__rte_unused struct iavf_adapter *ad, · line 563

Quoted 10 lines
drivers/net/iavf/iavf_fsub.c +10 -0
+	enum rte_flow_action_type action_type;
+	uint16_t actions_num = 0;
+	bool vf_valid = false;
+	bool queue_valid = false;
+
+	for (action = actions; action->type !=
+				RTE_FLOW_ACTION_TYPE_END; action++) {
+		action_type = action->type;
+		switch (action_type) {
+		case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:

Need to sync the document in iavf.ini

[rte_flow actions]
....
port_representor = Y

will be fixed during code merge.

author
#37 lore raw

PATCH v5 4/5 net/iavf: support flow subscription rule

In reply to Jie Wang

Support flow subscribption create/destroy/validation flow rule for AVF.

For examples:
testpmd> flow create 0 ingress pattern eth / ipv4 / udp src is 11
/ end actions represented_port port_id 1 / end
testpmd> flow validate 1 ingress pattern eth / ipv4 / tcp src is 22
/ end actions represented_port port_id 1 / end
testpmd> flow destroy 1 rule 0

VF subscribes to a rule, which means the packets will be sent to VF instead of PF, and only VF will receive the packets.

It is allowed multiple VF subscribe to same rule, the packets will be replicated and received by each VF.

PF will destroy all subscriptions during VF reset.

---
 drivers/net/iavf/iavf.h       |   6 ++
 drivers/net/iavf/iavf_fsub.c  |  75 +++++++++++++++----
 drivers/net/iavf/iavf_vchnl.c | 132 ++++++++++++++++++++++++++++++++++
 3 files changed, 201 insertions(+), 12 deletions(-)
drivers/net/iavf/iavf.h +6 -0
index f79c7f9f6e..26b858f6f0 100644
@@ -489,4 +489,10 @@ int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
 extern const struct rte_tm_ops iavf_tm_ops;
 int iavf_get_ptp_cap(struct iavf_adapter *adapter);
 int iavf_get_phc_time(struct iavf_rx_queue *rxq);
+int iavf_flow_sub(struct iavf_adapter *adapter,
+		  struct iavf_fsub_conf *filter);
+int iavf_flow_unsub(struct iavf_adapter *adapter,
+		    struct iavf_fsub_conf *filter);
+int iavf_flow_sub_check(struct iavf_adapter *adapter,
+			struct iavf_fsub_conf *filter);
 #endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_fsub.c +63 -12

92 lines not on this page · raw message

drivers/net/iavf/iavf_vchnl.c +132 -0

138 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#38 lore raw

PATCH v5 5/5 net/iavf: support priority of flow rule

In reply to Jie Wang

Add flow rule attribute "priority" support for AVF.

Lower values denote higher priority, the highest priority for a flow rule is 0.

All subscription rule will have a lower priority than the rules that be created by host.

---
 drivers/net/iavf/iavf_fdir.c         |  4 ++++
 drivers/net/iavf/iavf_fsub.c         |  2 +-
 drivers/net/iavf/iavf_generic_flow.c | 23 +++++++++++++----------
 drivers/net/iavf/iavf_generic_flow.h |  1 +
 drivers/net/iavf/iavf_hash.c         |  5 +++++
 drivers/net/iavf/iavf_ipsec_crypto.c | 16 ++++++++++------
 6 files changed, 34 insertions(+), 17 deletions(-)
drivers/net/iavf/iavf_fdir.c +4 -0
index a397047fdb..8f80873925 100644
@@ -1583,6 +1583,7 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
@@ -1593,6 +1594,9 @@ iavf_fdir_parse(struct iavf_adapter *ad,
 
 	memset(filter, 0, sizeof(*filter));
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (!item)
 		return -rte_errno;
drivers/net/iavf/iavf_fsub.c +1 -1
index 28857d7577..3bb6c30d3c 100644
@@ -649,13 +649,13 @@ iavf_fsub_parse(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error)
 {
 	struct iavf_fsub_conf *filter;
 	struct iavf_pattern_match_item *pattern_match_item = NULL;
 	int ret = 0;
-	uint32_t priority = 0;
 
 	filter = rte_zmalloc(NULL, sizeof(*filter), 0);
 	if (!filter) {
drivers/net/iavf/iavf_generic_flow.c +13 -10
index b04614ba6e..f33c764764 100644
@@ -1785,6 +1785,7 @@ enum rte_flow_item_type iavf_pattern_eth_ipv6_udp_l2tpv2_ppp_ipv6_tcp[] = {
 typedef struct iavf_flow_engine * (*parse_engine_t)(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error);
@@ -1951,11 +1952,11 @@ iavf_flow_valid_attr(const struct rte_flow_attr *attr,
 		return -rte_errno;
 	}
 
-	/* Not supported */
-	if (attr->priority) {
+	/* support priority for flow subscribe */
+	if (attr->priority > 1) {
 		rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
-				attr, "Not support priority.");
+				attr, "Only support priority 0 and 1.");
 		return -rte_errno;
 	}
 
@@ -2098,6 +2099,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_create(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2111,7 +2113,7 @@ iavf_parse_engine_create(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta, error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2127,6 +2129,7 @@ static struct iavf_flow_engine *
 iavf_parse_engine_validate(struct iavf_adapter *ad,
 		struct rte_flow *flow,
 		struct iavf_parser_list *parser_list,
+		uint32_t priority,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
 		struct rte_flow_error *error)
@@ -2140,7 +2143,7 @@ iavf_parse_engine_validate(struct iavf_adapter *ad,
 		if (parser_node->parser->parse_pattern_action(ad,
 				parser_node->parser->array,
 				parser_node->parser->array_len,
-				pattern, actions, &meta,  error) < 0)
+				pattern, actions, priority, &meta, error) < 0)
 			continue;
 
 		engine = parser_node->parser->engine;
@@ -2201,18 +2204,18 @@ iavf_flow_process_filter(struct rte_eth_dev *dev,
 	if (ret)
 		return ret;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->rss_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
-	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list, pattern,
-				    actions, error);
+	*engine = iavf_parse_engine(ad, flow, &vf->dist_parser_list,
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
 	*engine = iavf_parse_engine(ad, flow, &vf->ipsec_crypto_parser_list,
-			pattern, actions, error);
+				    attr->priority, pattern, actions, error);
 	if (*engine)
 		return 0;
 
drivers/net/iavf/iavf_generic_flow.h +1 -0
index 448facffa5..60d8ab02b4 100644
@@ -471,6 +471,7 @@ typedef int (*parse_pattern_action_t)(struct iavf_adapter *ad,
 		uint32_t array_len,
 		const struct rte_flow_item pattern[],
 		const struct rte_flow_action actions[],
+		uint32_t priority,
 		void **meta,
 		struct rte_flow_error *error);
 
drivers/net/iavf/iavf_hash.c +5 -0
index 42df7c4e48..dea4e0aa0a 100644
@@ -86,6 +86,7 @@ iavf_hash_parse_pattern_action(struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error);
 
@@ -1509,6 +1510,7 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 			       uint32_t array_len,
 			       const struct rte_flow_item pattern[],
 			       const struct rte_flow_action actions[],
+			       uint32_t priority,
 			       void **meta,
 			       struct rte_flow_error *error)
 {
@@ -1517,6 +1519,9 @@ iavf_hash_parse_pattern_action(__rte_unused struct iavf_adapter *ad,
 	uint64_t phint = IAVF_PHINT_NONE;
 	int ret = 0;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	rss_meta_ptr = rte_zmalloc(NULL, sizeof(*rss_meta_ptr), 0);
 	if (!rss_meta_ptr) {
 		rte_flow_error_set(error, EINVAL,
drivers/net/iavf/iavf_ipsec_crypto.c +10 -6
index 1d465b4419..cec1b968fe 100644
@@ -1933,16 +1933,20 @@ static struct iavf_flow_engine iavf_ipsec_flow_engine = {
 
 static int
 iavf_ipsec_flow_parse(struct iavf_adapter *ad,
-		       struct iavf_pattern_match_item *array,
-		       uint32_t array_len,
-		       const struct rte_flow_item pattern[],
-		       const struct rte_flow_action actions[],
-		       void **meta,
-		       struct rte_flow_error *error)
+		      struct iavf_pattern_match_item *array,
+		      uint32_t array_len,
+		      const struct rte_flow_item pattern[],
+		      const struct rte_flow_action actions[],
+		      uint32_t priority,
+		      void **meta,
+		      struct rte_flow_error *error)
 {
 	struct iavf_pattern_match_item *item = NULL;
 	int ret = -1;
 
+	if (priority >= 1)
+		return -rte_errno;
+
 	item = iavf_search_pattern_match_item(pattern, array, array_len, error);
 	if (item && item->meta) {
 		uint32_t type = (uint64_t)(item->meta);
Signature · 1 line
2.25.1
Acked-by on the v5 series Applied
#39 lore raw
In reply to Jie Wang
Quoted 45 lines

-----Original Message-----
From: Wang, Jie1X <[email protected]>
Sent: Wednesday, September 7, 2022 1:11 PM
To: [email protected]
Cc: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yang, SteveX <[email protected]>; Wang, Jie1X <[email protected]>
Subject: [PATCH v5 0/5] support flow subscription

Add support AVF can be able to subscribe a flow from PF.

--
v4:
* replace flow action represented_port with port_representor.
* update commit log and rebase.
v3:
* fix eth layer inputset.
* rebase.
v2:
* split v1 patch 2/2 to 4 small patches.
* remove rule action RTE_FLOW_ACTION_TYPE_VF and add RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT.

Jie Wang (5):
common/iavf: support flow subscription
net/iavf: add flow subscription to AVF
net/iavf: support flow subscrption pattern
net/iavf: support flow subscription rule
net/iavf: support priority of flow rule

 doc/guides/rel_notes/release_22_11.rst |   4 +
 drivers/common/iavf/virtchnl.h         | 104 +++-
 drivers/net/iavf/iavf.h                |  13 +
 drivers/net/iavf/iavf_fdir.c           |   4 +
 drivers/net/iavf/iavf_fsub.c           | 745 +++++++++++++++++++++++++
 drivers/net/iavf/iavf_generic_flow.c   |  40 +-
 drivers/net/iavf/iavf_generic_flow.h   |   2 +
 drivers/net/iavf/iavf_hash.c           |   5 +
 drivers/net/iavf/iavf_ipsec_crypto.c   |  16 +-
 drivers/net/iavf/iavf_vchnl.c          | 133 +++++
 drivers/net/iavf/meson.build           |   1 +
 11 files changed, 1046 insertions(+), 21 deletions(-)  create mode 100644
Quoted 4 lines

drivers/net/iavf/iavf_fsub.c

--
2.25.1

Applied to dpdk-next-net-intel.

Thanks
Qi