Skip to contentSkip to conversation

net/ice: add ice Flow Director driver

PATCH Superseded Yahui Cao 1 participant 8 messages Sep 23, 2019

Subsystems (2)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Yahui Cao

author
#0 lore raw

cover net/ice: add ice Flow Director driver

This patch series adds Flow Director support for Intel Ethernet Controller E810 series using RTE_FLOW

- Patch 01-02 are FDIR init,teardown and configuration
- Remaining patches are FDIR RTE_FLOW enablement

The patchset depends on:
http://patchwork.dpdk.org/project/dpdk/list/?series=6420
---
v2:
* Move to flexible descriptor.
* Distinguish tunnel and non-tunnel rule
* Add uninit function for fdir engine
* Fix coding style
* Change patch organization

Beilei Xing (2):
net/ice: enable flow director engine
net/ice: configure HW FDIR rule

Yahui Cao (5):
net/ice: add FDIR create and destroy
net/ice: enable FDIR queue group
net/ice: add FDIR counter resource init/release
net/ice: add FDIR counter support for flow id
net/ice: reject duplicate flow for FDIR

 doc/guides/rel_notes/release_19_11.rst |    1 +
 drivers/net/ice/Makefile               |    1 +
 drivers/net/ice/ice_ethdev.c           |  107 +-
 drivers/net/ice/ice_ethdev.h           |   82 ++
 drivers/net/ice/ice_fdir_filter.c      | 1551 ++++++++++++++++++++++++
 drivers/net/ice/ice_rxtx.c             |  446 ++++++-
 drivers/net/ice/ice_rxtx.h             |    9 +
 drivers/net/ice/meson.build            |    3 +-
 8 files changed, 2177 insertions(+), 23 deletions(-)
 create mode 100644 drivers/net/ice/ice_fdir_filter.c
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/7 net/ice: enable flow director engine

From: Beilei Xing <[email protected]>

Enable flow director engine, including initialization and teardown.
- Control VSI create and release.
- Queue pair allocated, set up and release.
- Programming packet create and release.
- FDIR profile create and release.

---
 drivers/net/ice/Makefile          |   1 +
 drivers/net/ice/ice_ethdev.c      | 107 +++++--
 drivers/net/ice/ice_ethdev.h      |  19 ++
 drivers/net/ice/ice_fdir_filter.c | 225 +++++++++++++++
 drivers/net/ice/ice_rxtx.c        | 446 +++++++++++++++++++++++++++++-
 drivers/net/ice/ice_rxtx.h        |   9 +
 drivers/net/ice/meson.build       |   3 +-
 7 files changed, 787 insertions(+), 23 deletions(-)
 create mode 100644 drivers/net/ice/ice_fdir_filter.c
drivers/net/ice/Makefile +1 -0
index 4a279f196..f7e185288 100644
@@ -62,6 +62,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_rxtx_vec_sse.c
 endif
 
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_switch_filter.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_fdir_filter.c
 ifeq ($(findstring RTE_MACHINE_CPUFLAG_AVX2,$(CFLAGS)),RTE_MACHINE_CPUFLAG_AVX2)
 	CC_AVX2_SUPPORT=1
 else
drivers/net/ice/ice_ethdev.c +88 -19

188 lines not on this page · raw message

drivers/net/ice/ice_ethdev.h +19 -0
index ba1d5cd43..9e01ee510 100644
@@ -247,6 +247,17 @@ TAILQ_HEAD(ice_flow_list, rte_flow);
 struct ice_flow_parser_node;
 TAILQ_HEAD(ice_parser_list, ice_flow_parser_node);
 
+/**
+ *  A structure used to define fields of a FDIR related info.
+ */
+struct ice_fdir_info {
+	struct ice_vsi *fdir_vsi;     /* pointer to fdir VSI structure */
+	struct ice_tx_queue *txq;
+	struct ice_rx_queue *rxq;
+	void *prg_pkt;                 /* memory for fdir program packet */
+	uint64_t dma_addr;             /* physic address of packet memory*/
+};
+
 struct ice_pf {
 	struct ice_adapter *adapter; /* The adapter this PF associate to */
 	struct ice_vsi *main_vsi; /* pointer to main VSI structure */
@@ -267,6 +278,9 @@ struct ice_pf {
 	uint16_t lan_nb_qps; /* The number of queue pairs of LAN */
 	uint16_t base_queue; /* The base queue pairs index  in the device */
 	uint8_t *proto_xtr; /* Protocol extraction type for all queues */
+	uint16_t fdir_nb_qps; /* The number of queue pairs of Flow Director */
+	uint16_t fdir_qp_offset;
+	struct ice_fdir_info fdir; /* flow director info */
 	struct ice_hw_port_stats stats_offset;
 	struct ice_hw_port_stats stats;
 	/* internal packet statistics, it should be excluded from the total */
@@ -350,6 +364,11 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+struct ice_vsi *
+ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type);
+int
+ice_release_vsi(struct ice_vsi *vsi);
+
 static inline int
 ice_align_floor(int n)
 {
drivers/net/ice/ice_fdir_filter.c new file +225 -0

225 lines not on this page · raw message

drivers/net/ice/ice_rxtx.c +443 -3

515 lines not on this page · raw message

drivers/net/ice/ice_rxtx.h +9 -0
index 25b3822df..c29a2fc45 100644
@@ -37,6 +37,8 @@
 #define ICE_TX_MAX_FREE_BUF_SZ      64
 #define ICE_DESCS_PER_LOOP          4
 
+#define ICE_FDIR_PKT_LEN	512
+
 typedef void (*ice_rx_release_mbufs_t)(struct ice_rx_queue *rxq);
 typedef void (*ice_tx_release_mbufs_t)(struct ice_tx_queue *txq);
 
@@ -149,10 +151,16 @@ int ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
 int ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 int ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
+int ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id);
+int ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id);
+int ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id);
 void ice_rx_queue_release(void *rxq);
 void ice_tx_queue_release(void *txq);
 void ice_clear_queues(struct rte_eth_dev *dev);
 void ice_free_queues(struct rte_eth_dev *dev);
+int ice_fdir_setup_tx_resources(struct ice_pf *pf);
+int ice_fdir_setup_rx_resources(struct ice_pf *pf);
 uint16_t ice_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		       uint16_t nb_pkts);
 uint16_t ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
@@ -190,4 +198,5 @@ uint16_t ice_recv_scattered_pkts_vec_avx2(void *rx_queue,
 					  uint16_t nb_pkts);
 uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 				uint16_t nb_pkts);
+int ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc);
 #endif /* _ICE_RXTX_H_ */
drivers/net/ice/meson.build +2 -1
index 6828170a9..908a2cab7 100644
@@ -10,7 +10,8 @@ sources = files(
 	'ice_ethdev.c',
 	'ice_rxtx.c',
 	'ice_switch_filter.c',
-	'ice_generic_flow.c'
+	'ice_generic_flow.c',
+	'ice_fdir_filter.c'
 	)
 
 deps += ['hash']
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 2/7 net/ice: configure HW FDIR rule

In reply to Yahui Cao

From: Beilei Xing <[email protected]>

This patch adds a HW FDIR rule to the FDIR HW table without adding a FDIR filter.

Change-Id Iaed0ee1953815559ac4a25da1402c6f9775e78c0
---
 drivers/net/ice/ice_fdir_filter.c | 239 ++++++++++++++++++++++++++++++
 1 file changed, 239 insertions(+)
drivers/net/ice/ice_fdir_filter.c +239 -0
index 0fb3054f5..65e9cd455 100644
@@ -197,6 +197,245 @@ ice_fdir_teardown(struct ice_pf *pf)
 	ice_fdir_prof_free(hw);
 }
 
+static void
+ice_fdir_prof_rm(struct ice_hw *hw, enum ice_fltr_ptype ptype, bool is_tunnel)
+{
+	struct ice_fd_hw_prof *hw_prof;
+	uint64_t prof_id;
+	uint16_t vsi_num;
+	int i;
+
+	if (!hw->fdir_prof || !hw->fdir_prof[ptype])
+		return;
+
+	hw_prof = hw->fdir_prof[ptype];
+
+	prof_id = ptype + is_tunnel * ICE_FLTR_PTYPE_MAX;
+	for (i = 0; i < hw_prof->cnt; i++) {
+		if (hw_prof->entry_h[i][is_tunnel]) {
+			vsi_num = ice_get_hw_vsi_num(hw,
+						     hw_prof->vsi_h[i]);
+			ice_rem_prof_id_flow(hw, ICE_BLK_FD,
+					     vsi_num, ptype);
+			ice_flow_rem_entry(hw,
+					   hw_prof->entry_h[i][is_tunnel]);
+			hw_prof->entry_h[i][is_tunnel] = 0;
+		}
+	}
+	ice_flow_rem_prof(hw, ICE_BLK_FD, prof_id);
+	rte_free(hw_prof->fdir_seg[is_tunnel]);
+	hw_prof->fdir_seg[is_tunnel] = NULL;
+
+	for (i = 0; i < hw_prof->cnt; i++)
+		hw_prof->vsi_h[i] = 0;
+	hw_prof->cnt = 0;
+}
+
+static int
+ice_fdir_hw_tbl_conf(struct ice_pf *pf, struct ice_vsi *vsi,
+		     struct ice_vsi *ctrl_vsi,
+		     struct ice_flow_seg_info *seg,
+		     enum ice_fltr_ptype ptype,
+		     bool is_tunnel)
+{
+	struct ice_hw *hw = ICE_PF_TO_HW(pf);
+	enum ice_flow_dir dir = ICE_FLOW_RX;
+	struct ice_flow_seg_info *ori_seg;
+	struct ice_fd_hw_prof *hw_prof;
+	struct ice_flow_prof *prof;
+	uint64_t entry_1 = 0;
+	uint64_t entry_2 = 0;
+	uint16_t vsi_num;
+	int ret;
+	uint64_t prof_id;
+
+	if (!hw->fdir_prof) {
+		hw->fdir_prof = (struct ice_fd_hw_prof **)
+			ice_malloc(hw, ICE_FLTR_PTYPE_MAX *
+				   sizeof(*hw->fdir_prof));
+		if (!hw->fdir_prof)
+			return -ENOMEM;
+	}
+	if (!hw->fdir_prof[ptype]) {
+		hw->fdir_prof[ptype] = (struct ice_fd_hw_prof *)
+			ice_malloc(hw, sizeof(**hw->fdir_prof));
+		if (!hw->fdir_prof[ptype])
+			return -ENOMEM;
+	}
+
+	hw_prof = hw->fdir_prof[ptype];
+	ori_seg = hw_prof->fdir_seg[is_tunnel];
+	if (ori_seg) {
+		if (!memcmp(ori_seg, seg, sizeof(*seg)))
+			return -EAGAIN;
+		if (hw->fdir_fltr_cnt[ptype])
+			return -EINVAL;
+
+		ice_fdir_prof_rm(hw, ptype, is_tunnel);
+	}
+
+	prof_id = ptype + is_tunnel * ICE_FLTR_PTYPE_MAX;
+	ret = ice_flow_add_prof(hw, ICE_BLK_FD, dir, prof_id, seg,
+				(is_tunnel) ? 2 : 1, NULL, 0, &prof);
+	if (ret)
+		return ret;
+	ret = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id, vsi->idx,
+				 vsi->idx, ICE_FLOW_PRIO_NORMAL,
+				 seg, NULL, 0, &entry_1);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Failed to add main VSI flow entry for %d.",
+			    ptype);
+		goto err_add_prof;
+	}
+	ret = ice_flow_add_entry(hw, ICE_BLK_FD, prof_id, vsi->idx,
+				 ctrl_vsi->idx, ICE_FLOW_PRIO_NORMAL,
+				 seg, NULL, 0, &entry_2);
+	if (ret) {
+		PMD_DRV_LOG(ERR, "Failed to add control VSI flow entry for %d.",
+			    ptype);
+		goto err_add_entry;
+	}
+
+	hw_prof->cnt = 0;
+	hw_prof->fdir_seg[is_tunnel] = seg;
+	hw_prof->vsi_h[hw_prof->cnt] = vsi->idx;
+	hw_prof->entry_h[hw_prof->cnt++][is_tunnel] = entry_1;
+	hw_prof->vsi_h[hw_prof->cnt] = ctrl_vsi->idx;
+	hw_prof->entry_h[hw_prof->cnt++][is_tunnel] = entry_2;
+
+	return ret;
+
+err_add_entry:
+	vsi_num = ice_get_hw_vsi_num(hw, vsi->idx);
+	ice_rem_prof_id_flow(hw, ICE_BLK_FD, vsi_num, prof_id);
+	ice_flow_rem_entry(hw, entry_1);
+err_add_prof:
+	ice_flow_rem_prof(hw, ICE_BLK_FD, prof_id);
+
+	return ret;
+}
+
+static void
+ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field)
+{
+	uint32_t i, j;
+
+	struct ice_inset_map {
+		uint64_t inset;
+		enum ice_flow_field fld;
+	};
+	static const struct ice_inset_map ice_inset_map[] = {
+		{ICE_INSET_IPV4_SRC, ICE_FLOW_FIELD_IDX_IPV4_SA},
+		{ICE_INSET_IPV4_DST, ICE_FLOW_FIELD_IDX_IPV4_DA},
+		{ICE_INSET_IPV6_SRC, ICE_FLOW_FIELD_IDX_IPV6_SA},
+		{ICE_INSET_IPV6_DST, ICE_FLOW_FIELD_IDX_IPV6_DA},
+		{ICE_INSET_TCP_SRC_PORT, ICE_FLOW_FIELD_IDX_TCP_SRC_PORT},
+		{ICE_INSET_TCP_DST_PORT, ICE_FLOW_FIELD_IDX_TCP_DST_PORT},
+		{ICE_INSET_UDP_SRC_PORT, ICE_FLOW_FIELD_IDX_UDP_SRC_PORT},
+		{ICE_INSET_UDP_DST_PORT, ICE_FLOW_FIELD_IDX_UDP_DST_PORT},
+		{ICE_INSET_SCTP_SRC_PORT, ICE_FLOW_FIELD_IDX_SCTP_SRC_PORT},
+		{ICE_INSET_SCTP_DST_PORT, ICE_FLOW_FIELD_IDX_SCTP_DST_PORT},
+	};
+
+	for (i = 0, j = 0; i < RTE_DIM(ice_inset_map); i++) {
+		if (inset & ice_inset_map[i].inset)
+			field[j++] = ice_inset_map[i].fld;
+	}
+}
+
+static int __rte_unused
+ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow,
+			uint64_t input_set, bool is_tunnel)
+{
+	struct ice_flow_seg_info *seg, *seg_tun;
+	enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX];
+	int i, ret;
+
+	if (!input_set)
+		return -EINVAL;
+
+	seg = (struct ice_flow_seg_info *)
+		ice_malloc(hw, sizeof(*seg));
+	if (!seg) {
+		PMD_DRV_LOG(ERR, "No memory can be allocated");
+		return -ENOMEM;
+	}
+
+	for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++)
+		field[i] = ICE_FLOW_FIELD_IDX_MAX;
+	ice_fdir_input_set_parse(input_set, field);
+
+	switch (flow) {
+	case ICE_FLTR_PTYPE_NONF_IPV4_UDP:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
+				  ICE_FLOW_SEG_HDR_IPV4);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_TCP:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_TCP |
+				  ICE_FLOW_SEG_HDR_IPV4);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_SCTP:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_SCTP |
+				  ICE_FLOW_SEG_HDR_IPV4);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV4_OTHER:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV6_UDP:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP |
+				  ICE_FLOW_SEG_HDR_IPV6);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV6_TCP:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_TCP |
+				  ICE_FLOW_SEG_HDR_IPV6);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV6_SCTP:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_SCTP |
+				  ICE_FLOW_SEG_HDR_IPV6);
+		break;
+	case ICE_FLTR_PTYPE_NONF_IPV6_OTHER:
+		ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "not supported filter type.");
+		break;
+	}
+
+	for (i = 0; field[i] != ICE_FLOW_FIELD_IDX_MAX; i++) {
+		ice_flow_set_fld(seg, field[i],
+				 ICE_FLOW_FLD_OFF_INVAL,
+				 ICE_FLOW_FLD_OFF_INVAL,
+				 ICE_FLOW_FLD_OFF_INVAL, false);
+	}
+
+	if (!is_tunnel) {
+		ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi,
+					   seg, flow, false);
+	} else {
+		seg_tun = (struct ice_flow_seg_info *)
+			ice_malloc(hw, sizeof(*seg) * ICE_FD_HW_SEG_MAX);
+		if (!seg_tun) {
+			PMD_DRV_LOG(ERR, "No memory can be allocated");
+			rte_free(seg);
+			return -ENOMEM;
+		}
+		rte_memcpy(&seg_tun[1], seg, sizeof(*seg));
+		ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi,
+					   seg_tun, flow, true);
+	}
+
+	if (!ret) {
+		return ret;
+	} else if (ret < 0) {
+		rte_free(seg);
+		if (is_tunnel)
+			rte_free(seg_tun);
+		return (ret == -EAGAIN) ? 0 : ret;
+	} else {
+		return ret;
+	}
+}
+
 static int
 ice_fdir_init(struct ice_adapter *ad)
 {
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH 3/7 net/ice: add FDIR create and destroy

In reply to Yahui Cao

Add ice_create_fdir_filter to create a rule. If a flow is matched by flow director filter, filter rule will be set to HW. For now common pattern and queue/passthru/drop/mark actions are supported.

---
 doc/guides/rel_notes/release_19_11.rst |   1 +
 drivers/net/ice/ice_ethdev.h           |   6 +
 drivers/net/ice/ice_fdir_filter.c      | 582 ++++++++++++++++++++++++-
 3 files changed, 587 insertions(+), 2 deletions(-)
doc/guides/rel_notes/release_19_11.rst +1 -0
index 0aec6870f..d0688d82e 100644
@@ -65,6 +65,7 @@ New Features
   Updated the Intel ice driver with new features and improvements, including:
 
   * Supported device-specific DDP package loading.
+  * Supported Flow Director filter based on generic filter framework.
   * Generic filter enhancement
     - Supported pipeline mode.
     - Supported new packet type like PPPoE for switch filter.
drivers/net/ice/ice_ethdev.h +6 -0
index 9e01ee510..f4432c34a 100644
@@ -247,6 +247,11 @@ TAILQ_HEAD(ice_flow_list, rte_flow);
 struct ice_flow_parser_node;
 TAILQ_HEAD(ice_parser_list, ice_flow_parser_node);
 
+struct ice_fdir_filter_conf {
+	struct ice_fdir_fltr input;
+	uint64_t input_set;
+};
+
 /**
  *  A structure used to define fields of a FDIR related info.
  */
@@ -256,6 +261,7 @@ struct ice_fdir_info {
 	struct ice_rx_queue *rxq;
 	void *prg_pkt;                 /* memory for fdir program packet */
 	uint64_t dma_addr;             /* physic address of packet memory*/
+	struct ice_fdir_filter_conf conf;
 };
 
 struct ice_pf {
drivers/net/ice/ice_fdir_filter.c +580 -2

626 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#4 lore raw

PATCH 4/7 net/ice: enable FDIR queue group

In reply to Yahui Cao

FDIR can send packet to a group of queues and distruibte it by RSS.

---
 drivers/net/ice/ice_fdir_filter.c | 65 +++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
drivers/net/ice/ice_fdir_filter.c +65 -0
index f55b93d14..7913621d7 100644
@@ -619,6 +619,62 @@ static struct ice_flow_engine ice_fdir_engine = {
 	.type = ICE_FLOW_ENGINE_FDIR,
 };
 
+static int
+ice_fdir_parse_action_qregion(struct ice_pf *pf,
+			      struct rte_flow_error *error,
+			      const struct rte_flow_action *act,
+			      struct ice_fdir_filter_conf *filter)
+{
+	const struct rte_flow_action_rss *rss = act->conf;
+	uint32_t i;
+
+	if (act->type != RTE_FLOW_ACTION_TYPE_RSS) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_ACTION, act,
+				   "Invalid action.");
+		return -rte_errno;
+	}
+
+	if (rss->queue_num <= 1) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_ACTION, act,
+				   "Queue region size can't be 0 or 1.");
+		return -rte_errno;
+	}
+
+	/* check if queue index for queue region is continuous */
+	for (i = 0; i < rss->queue_num - 1; i++) {
+		if (rss->queue[i + 1] != rss->queue[i] + 1) {
+			rte_flow_error_set(error, EINVAL,
+					   RTE_FLOW_ERROR_TYPE_ACTION, act,
+					   "Discontinuous queue region");
+			return -rte_errno;
+		}
+	}
+
+	if (rss->queue[rss->queue_num - 1] >= pf->dev_data->nb_rx_queues) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_ACTION, act,
+				   "Invalid queue region indexes.");
+		return -rte_errno;
+	}
+
+	if (!(rte_is_power_of_2(rss->queue_num) && (rss->queue_num <= 128))) {
+		rte_flow_error_set(error, EINVAL,
+				   RTE_FLOW_ERROR_TYPE_ACTION, act,
+				   "The region size should be any of the following values:"
+				   "1, 2, 4, 8, 16, 32, 64, 128 as long as the total number "
+				   "of queues do not exceed the VSI allocation.");
+		return -rte_errno;
+	}
+
+	filter->input.q_index = rss->queue[0];
+	filter->input.q_region = rte_fls_u32(rss->queue_num) - 1;
+	filter->input.dest_ctl = ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QGROUP;
+
+	return 0;
+}
+
 static int
 ice_fdir_parse_action(struct ice_adapter *ad,
 		      const struct rte_flow_action actions[],
@@ -630,6 +686,7 @@ ice_fdir_parse_action(struct ice_adapter *ad,
 	const struct rte_flow_action_mark *mark_spec = NULL;
 	uint32_t dest_num = 0;
 	uint32_t mark_num = 0;
+	int ret;
 
 	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
 		switch (actions->type) {
@@ -664,6 +721,14 @@ ice_fdir_parse_action(struct ice_adapter *ad,
 				ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX;
 			filter->input.q_index = 0;
 			break;
+		case RTE_FLOW_ACTION_TYPE_RSS:
+			dest_num++;
+
+			ret = ice_fdir_parse_action_qregion(pf,
+						error, actions, filter);
+			if (ret)
+				return ret;
+			break;
 		case RTE_FLOW_ACTION_TYPE_MARK:
 			mark_num++;
 
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH 5/7 net/ice: add FDIR counter resource init/release

In reply to Yahui Cao

The patch integrates the counter resource init/release into fdir's init/release scenario

---
 drivers/net/ice/ice_ethdev.h      | 33 +++++++++++
 drivers/net/ice/ice_fdir_filter.c | 97 ++++++++++++++++++++++++++++++-
 2 files changed, 129 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.h +33 -0
index f4432c34a..cd4fe685f 100644
@@ -252,6 +252,37 @@ struct ice_fdir_filter_conf {
 	uint64_t input_set;
 };
 
+#define ICE_FDIR_COUNTER_DEFAULT_POOL_SIZE	1
+#define ICE_FDIR_COUNTER_MAX_POOL_SIZE		32
+#define ICE_FDIR_COUNTERS_PER_BLOCK		256
+#define ICE_FDIR_COUNTER_INDEX(base_idx) \
+				((base_idx) * ICE_FDIR_COUNTERS_PER_BLOCK)
+struct ice_fdir_counter {
+	TAILQ_ENTRY(ice_fdir_counter) next;
+	uint8_t shared;
+	uint32_t ref_cnt;
+	uint32_t id;
+	uint64_t hits;
+	uint64_t bytes;
+	uint32_t hw_index;
+};
+
+TAILQ_HEAD(ice_fdir_counter_list, ice_fdir_counter);
+
+struct ice_fdir_counter_pool {
+	TAILQ_ENTRY(ice_fdir_counter_pool) next;
+	struct ice_fdir_counter_list counter_list;
+	struct ice_fdir_counter counters[0];
+};
+
+TAILQ_HEAD(ice_fdir_counter_pool_list, ice_fdir_counter_pool);
+
+struct ice_fdir_counter_pool_container {
+	struct ice_fdir_counter_pool_list pool_list;
+	struct ice_fdir_counter_pool *pools[ICE_FDIR_COUNTER_MAX_POOL_SIZE];
+	uint8_t index_free;
+};
+
 /**
  *  A structure used to define fields of a FDIR related info.
  */
@@ -262,6 +293,8 @@ struct ice_fdir_info {
 	void *prg_pkt;                 /* memory for fdir program packet */
 	uint64_t dma_addr;             /* physic address of packet memory*/
 	struct ice_fdir_filter_conf conf;
+
+	struct ice_fdir_counter_pool_container counter;
 };
 
 struct ice_pf {
drivers/net/ice/ice_fdir_filter.c +96 -1

127 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#6 lore raw

PATCH 6/7 net/ice: add FDIR counter support for flow id

In reply to Yahui Cao

FDIR statistical counter support hits by default.

---
 drivers/net/ice/ice_ethdev.h      |   7 ++
 drivers/net/ice/ice_fdir_filter.c | 179 +++++++++++++++++++++++++++++-
 2 files changed, 185 insertions(+), 1 deletion(-)
drivers/net/ice/ice_ethdev.h +7 -0
index cd4fe685f..89eefe4b1 100644
@@ -249,6 +249,10 @@ TAILQ_HEAD(ice_parser_list, ice_flow_parser_node);
 
 struct ice_fdir_filter_conf {
 	struct ice_fdir_fltr input;
+
+	struct ice_fdir_counter *counter; /* flow specific counter context */
+	struct rte_flow_action_count act_count;
+
 	uint64_t input_set;
 };
 
@@ -257,8 +261,11 @@ struct ice_fdir_filter_conf {
 #define ICE_FDIR_COUNTERS_PER_BLOCK		256
 #define ICE_FDIR_COUNTER_INDEX(base_idx) \
 				((base_idx) * ICE_FDIR_COUNTERS_PER_BLOCK)
+struct ice_fdir_counter_pool;
+
 struct ice_fdir_counter {
 	TAILQ_ENTRY(ice_fdir_counter) next;
+	struct ice_fdir_counter_pool *pool;
 	uint8_t shared;
 	uint32_t ref_cnt;
 	uint32_t id;
drivers/net/ice/ice_fdir_filter.c +178 -1

239 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#7 lore raw

PATCH 7/7 net/ice: reject duplicate flow for FDIR

In reply to Yahui Cao

Enable duplication lookup for existing flow director rule entry.

---
 drivers/net/ice/ice_ethdev.h      |  17 +++
 drivers/net/ice/ice_fdir_filter.c | 186 ++++++++++++++++++++++++++++--
 2 files changed, 196 insertions(+), 7 deletions(-)
drivers/net/ice/ice_ethdev.h +17 -0
index 89eefe4b1..f54dac513 100644
@@ -256,6 +256,20 @@ struct ice_fdir_filter_conf {
 	uint64_t input_set;
 };
 
+#define ICE_MAX_FDIR_FILTER_NUM		(1024 * 16)
+
+struct ice_fdir_fltr_pattern {
+	enum ice_fltr_ptype flow_type;
+
+	union {
+		struct ice_fdir_v4 v4;
+		struct ice_fdir_v6 v6;
+	} ip, mask;
+
+	struct ice_fdir_extra ext_data;
+	struct ice_fdir_extra ext_mask;
+};
+
 #define ICE_FDIR_COUNTER_DEFAULT_POOL_SIZE	1
 #define ICE_FDIR_COUNTER_MAX_POOL_SIZE		32
 #define ICE_FDIR_COUNTERS_PER_BLOCK		256
@@ -301,6 +315,9 @@ struct ice_fdir_info {
 	uint64_t dma_addr;             /* physic address of packet memory*/
 	struct ice_fdir_filter_conf conf;
 
+	struct ice_fdir_filter_conf **hash_map;
+	struct rte_hash *hash_table;
+
 	struct ice_fdir_counter_pool_container counter;
 };
 
drivers/net/ice/ice_fdir_filter.c +179 -7

255 lines not on this page · raw message

Signature · 1 line
2.17.1