Skip to contentSkip to conversation

net/iavf: support flow rule with raw pattern

v20.11.7.5 Mingjin Ye 1 participant 1 message Mar 12, 2024 Network drivers

lore
Share & tools
lore

Mingjin Ye

author
#0 lore raw

Add raw pattern support to VF, including FDIR/RSS flow rule.

This patch is based on DPDK v20.11.7.5, for customer cherry-pick.

---
 doc/guides/nics/features/ice_dcf.ini    |    1 +
 drivers/common/iavf/virtchnl.h          |   38 +-
 drivers/net/iavf/iavf.h                 |   22 +-
 drivers/net/iavf/iavf_ethdev.c          |  266 ++++--
 drivers/net/iavf/iavf_fdir.c            |  229 ++++-
 drivers/net/iavf/iavf_generic_flow.c    | 1021 ++++++++++++++++++++---
 drivers/net/iavf/iavf_generic_flow.h    |  137 +++
 drivers/net/iavf/iavf_hash.c            |  498 ++++++++---
 drivers/net/iavf/iavf_rxtx.h            |    4 +-
 drivers/net/iavf/iavf_rxtx_vec_avx2.c   |    8 +-
 drivers/net/iavf/iavf_rxtx_vec_avx512.c |    9 +-
 drivers/net/iavf/iavf_rxtx_vec_sse.c    |    7 +-
 drivers/net/iavf/iavf_vchnl.c           |   85 +-
 drivers/net/ice/ice_dcf_ethdev.c        |   69 ++
 drivers/net/ice/ice_dcf_ethdev.h        |    6 +
 15 files changed, 2091 insertions(+), 309 deletions(-)
doc/guides/nics/features/ice_dcf.ini +1 -0
index e2b5659..ec2e0b4 100644
@@ -12,6 +12,7 @@ Flow API             = Y
 CRC offload          = Y
 L3 checksum offload  = P
 L4 checksum offload  = P
+MTU update           = Y
 Basic stats          = Y
 Linux UIO            = Y
 Linux VFIO           = Y
drivers/common/iavf/virtchnl.h +35 -3
index b931da6..8ee2f41 100644
@@ -828,6 +828,7 @@ enum virtchnl_vfr_states {
 };
 
 #define VIRTCHNL_MAX_NUM_PROTO_HDRS	32
+#define VIRTCHNL_MAX_SIZE_RAW_PACKET	1024
 #define PROTO_HDR_SHIFT			5
 #define PROTO_HDR_FIELD_START(proto_hdr_type) \
 					(proto_hdr_type << PROTO_HDR_SHIFT)
@@ -890,6 +891,13 @@ enum virtchnl_proto_hdr_type {
 	VIRTCHNL_PROTO_HDR_AH,
 	VIRTCHNL_PROTO_HDR_PFCP,
 	VIRTCHNL_PROTO_HDR_GTPC,
+	/* IPv4 and IPv6 Fragment header types are only associated to
+	 * VIRTCHNL_PROTO_HDR_IPV4 and VIRTCHNL_PROTO_HDR_IPV6 respectively,
+	 * cannot be used independently.
+	 */
+	VIRTCHNL_PROTO_HDR_IPV4_FRAG,
+	VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG,
+	VIRTCHNL_PROTO_HDR_GRE,
 };
 
 /* Protocol header field within a protocol header. */
@@ -970,6 +978,17 @@ enum virtchnl_proto_hdr_field {
 	/* GTPC */
 	VIRTCHNL_PROTO_HDR_GTPC_TEID =
 		PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPC),
+	/* GTPU_DWN/UP */
+	VIRTCHNL_PROTO_HDR_GTPU_DWN_QFI =
+		PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_DWN),
+	VIRTCHNL_PROTO_HDR_GTPU_UP_QFI =
+		PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_GTPU_EH_PDU_UP),
+	/* IPv4 Dummy Fragment */
+	VIRTCHNL_PROTO_HDR_IPV4_FRAG_PKID =
+		PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV4_FRAG),
+	/* IPv6 Extension Fragment */
+	VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG_PKID =
+		PROTO_HDR_FIELD_START(VIRTCHNL_PROTO_HDR_IPV6_EH_FRAG),
 };
 
 struct virtchnl_proto_hdr {
@@ -989,13 +1008,26 @@ struct virtchnl_proto_hdrs {
 	u8 tunnel_level;
 	/**
 	 * specify where protocol header start from.
+	 * must be 0 when sending a raw packet request.
 	 * 0 - from the outer layer
 	 * 1 - from the first inner layer
 	 * 2 - from the second inner layer
 	 * ....
-	 **/
-	int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
-	struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+	 */
+	int count;
+	/**
+	 * number of proto layers, must < VIRTCHNL_MAX_NUM_PROTO_HDRS
+	 * must be 0 for a raw packet request.
+	 */
+	union {
+		struct virtchnl_proto_hdr
+			proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];
+		struct {
+			u16 pkt_len;
+			u8 spec[VIRTCHNL_MAX_SIZE_RAW_PACKET];
+			u8 mask[VIRTCHNL_MAX_SIZE_RAW_PACKET];
+		} raw;
+	};
 };
 
 VIRTCHNL_CHECK_STRUCT_LEN(2312, virtchnl_proto_hdrs);
drivers/net/iavf/iavf.h +17 -5
index 1c0ebc7..72a0ffc 100644
@@ -46,11 +46,18 @@
 	VIRTCHNL_VF_OFFLOAD_RX_POLLING)
 
 #define IAVF_RSS_OFFLOAD_ALL ( \
+	ETH_RSS_IPV4 | \
 	ETH_RSS_FRAG_IPV4 |         \
 	ETH_RSS_NONFRAG_IPV4_TCP |  \
 	ETH_RSS_NONFRAG_IPV4_UDP |  \
 	ETH_RSS_NONFRAG_IPV4_SCTP | \
-	ETH_RSS_NONFRAG_IPV4_OTHER)
+	ETH_RSS_NONFRAG_IPV4_OTHER | \
+	ETH_RSS_IPV6 | \
+	ETH_RSS_FRAG_IPV6 | \
+	ETH_RSS_NONFRAG_IPV6_TCP | \
+	ETH_RSS_NONFRAG_IPV6_UDP | \
+	ETH_RSS_NONFRAG_IPV6_SCTP | \
+	ETH_RSS_NONFRAG_IPV6_OTHER)
 
 #define IAVF_MISC_VEC_ID                RTE_INTR_VEC_ZERO_OFFSET
 #define IAVF_RX_VEC_START               RTE_INTR_VEC_RXTX_OFFSET
@@ -66,6 +73,7 @@
 #define IAVF_VLAN_TAG_SIZE               4
 #define IAVF_ETH_OVERHEAD \
 	(RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + IAVF_VLAN_TAG_SIZE * 2)
+#define IAVF_ETH_MAX_LEN (RTE_ETHER_MTU + IAVF_ETH_OVERHEAD)
 
 #define IAVF_32_BIT_WIDTH (CHAR_BIT * 4)
 #define IAVF_48_BIT_WIDTH (CHAR_BIT * 6)
@@ -153,6 +161,7 @@ struct iavf_info {
 
 	uint8_t *rss_lut;
 	uint8_t *rss_key;
+	uint64_t rss_hf;
 	uint16_t nb_msix;   /* number of MSI-X interrupts on Rx */
 	uint16_t msix_base; /* msix vector base from */
 	uint16_t max_rss_qregion; /* max RSS queue region supported by PF */
@@ -165,6 +174,8 @@ struct iavf_info {
 	struct iavf_fdir_info fdir; /* flow director info */
 	/* indicate large VF support enabled or not */
 	bool lv_enabled;
+
+	struct rte_eth_dev *eth_dev;
 };
 
 #define IAVF_MAX_PKT_TYPE 1024
@@ -193,7 +204,7 @@ struct iavf_devargs {
 /* Structure to store private data for each VF instance. */
 struct iavf_adapter {
 	struct iavf_hw hw;
-	struct rte_eth_dev *eth_dev;
+	struct rte_eth_dev_data *dev_data;
 	struct iavf_info vf;
 
 	bool rx_bulk_alloc_allowed;
@@ -219,8 +230,6 @@ struct iavf_adapter {
 	(&(((struct iavf_vsi *)vsi)->adapter->hw))
 #define IAVF_VSI_TO_VF(vsi) \
 	(&(((struct iavf_vsi *)vsi)->adapter->vf))
-#define IAVF_VSI_TO_ETH_DEV(vsi) \
-	(((struct iavf_vsi *)vsi)->adapter->eth_dev)
 
 static inline void
 iavf_init_adminq_parameter(struct iavf_hw *hw)
@@ -321,9 +330,12 @@ int iavf_fdir_check(struct iavf_adapter *adapter,
 		struct iavf_fdir_conf *filter);
 int iavf_add_del_rss_cfg(struct iavf_adapter *adapter,
 			 struct virtchnl_rss_cfg *rss_cfg, bool add);
+int iavf_get_hena_caps(struct iavf_adapter *adapter, uint64_t *caps);
+int iavf_set_hena(struct iavf_adapter *adapter, uint64_t hena);
+int iavf_rss_hash_set(struct iavf_adapter *ad, uint64_t rss_hf, bool add);
 int iavf_add_del_mc_addr_list(struct iavf_adapter *adapter,
 			struct rte_ether_addr *mc_addrs,
 			uint32_t mc_addrs_num, bool add);
-int iavf_request_queues(struct iavf_adapter *adapter, uint16_t num);
+int iavf_request_queues(struct rte_eth_dev *dev, uint16_t num);
 int iavf_get_max_rss_queue_region(struct iavf_adapter *adapter);
 #endif /* _IAVF_ETHDEV_H_ */
drivers/net/iavf/iavf_ethdev.c +213 -53

360 lines not on this page · raw message

drivers/net/iavf/iavf_fdir.c +213 -16

362 lines not on this page · raw message

drivers/net/iavf/iavf_generic_flow.c +920 -101

1,309 lines not on this page · raw message

drivers/net/iavf/iavf_generic_flow.h +137 -0

173 lines not on this page · raw message

drivers/net/iavf/iavf_hash.c +397 -101

653 lines not on this page · raw message

drivers/net/iavf/iavf_rxtx.h +2 -2
index d4b4935..7a2ed65 100644

Lines of this file are not shown. View the raw message.

drivers/net/iavf/iavf_rxtx_vec_avx2.c +5 -3
index 8f28afc..233e3c4 100644

Lines of this file are not shown. View the raw message.

drivers/net/iavf/iavf_rxtx_vec_avx512.c +6 -3
index 584d12e..6e2484a 100644

Lines of this file are not shown. View the raw message.

drivers/net/iavf/iavf_rxtx_vec_sse.c +4 -3
index 75c77f9..6b2baf2 100644

Lines of this file are not shown. View the raw message.

drivers/net/iavf/iavf_vchnl.c +66 -19

85 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.c +69 -0

69 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.h +6 -0
index b54528b..7911f4b 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.25.1

Part of the diff is not shown here. View the raw message.