[v3,2/5] net/ice: add flow director enabled switch value
diff mbox series

Message ID 20200916031002.42122-3-junyux.jiang@intel.com
State Accepted, archived
Delegated to: Qi Zhang
Headers show
Series
  • supports RxDID #22 and FDID
Related show

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Junyu Jiang Sept. 16, 2020, 3:09 a.m. UTC
From: Guinan Sun <guinanx.sun@intel.com>

The patch adds fdir_enabled flag to identify if parse flow director mark ID
from flexible Rx descriptor.

Signed-off-by: Guinan Sun <guinanx.sun@intel.com>
---
 drivers/net/ice/ice_ethdev.h      |  2 ++
 drivers/net/ice/ice_fdir_filter.c |  9 ++++++++-
 drivers/net/ice/ice_rxtx.h        | 30 ++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index e8c9971fb..366eee3b4 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -291,6 +291,7 @@  struct ice_fdir_filter_conf {
 
 	uint64_t input_set;
 	uint64_t outer_input_set; /* only for tunnel packets outer fields */
+	uint32_t mark_flag;
 };
 
 #define ICE_MAX_FDIR_FILTER_NUM		(1024 * 16)
@@ -471,6 +472,7 @@  struct ice_adapter {
 	bool is_safe_mode;
 	struct ice_devargs devargs;
 	enum ice_pkg_type active_pkg_type; /* loaded ddp package type */
+	uint16_t fdir_ref_cnt;
 };
 
 struct ice_vsi_vlan_pvid_info {
diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c
index e0ce1efb0..175abcdd5 100644
--- a/drivers/net/ice/ice_fdir_filter.c
+++ b/drivers/net/ice/ice_fdir_filter.c
@@ -1318,6 +1318,9 @@  ice_fdir_create_filter(struct ice_adapter *ad,
 		goto free_counter;
 	}
 
+	if (filter->mark_flag == 1)
+		ice_fdir_rx_parsing_enable(ad, 1);
+
 	rte_memcpy(entry, filter, sizeof(*entry));
 	ret = ice_fdir_entry_insert(pf, entry, &key);
 	if (ret) {
@@ -1390,6 +1393,10 @@  ice_fdir_destroy_filter(struct ice_adapter *ad,
 	}
 
 	ice_fdir_cnt_update(pf, filter->input.flow_type, is_tun, false);
+
+	if (filter->mark_flag == 1)
+		ice_fdir_rx_parsing_enable(ad, 0);
+
 	flow->rule = NULL;
 
 	rte_free(filter);
@@ -1562,7 +1569,7 @@  ice_fdir_parse_action(struct ice_adapter *ad,
 			break;
 		case RTE_FLOW_ACTION_TYPE_MARK:
 			mark_num++;
-
+			filter->mark_flag = 1;
 			mark_spec = actions->conf;
 			filter->input.fltr_id = mark_spec->id;
 			filter->input.fdid_prio = ICE_FXD_FLTR_QW1_FDID_PRI_ONE;
diff --git a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h
index e21ba152d..9fa57b3b2 100644
--- a/drivers/net/ice/ice_rxtx.h
+++ b/drivers/net/ice/ice_rxtx.h
@@ -70,6 +70,7 @@  struct ice_rx_queue {
 
 	uint8_t port_id; /* device port ID */
 	uint8_t crc_len; /* 0 if CRC stripped, 4 otherwise */
+	uint8_t fdir_enabled; /* 0 if FDIR disabled, 1 when enabled */
 	uint16_t queue_id; /* RX queue index */
 	uint16_t reg_idx; /* RX queue register index */
 	uint8_t drop_en; /* if not 0, set register bit */
@@ -245,4 +246,33 @@  uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mbuf **tx_pkts,
 int ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc);
 int ice_tx_done_cleanup(void *txq, uint32_t free_cnt);
 
+#define FDIR_PARSING_ENABLE_PER_QUEUE(ad, on) do { \
+	int i; \
+	for (i = 0; i < (ad)->eth_dev->data->nb_rx_queues; i++) { \
+		struct ice_rx_queue *rxq = (ad)->eth_dev->data->rx_queues[i]; \
+		if (!rxq) \
+			continue; \
+		rxq->fdir_enabled = on; \
+	} \
+	PMD_DRV_LOG(DEBUG, "FDIR processing on RX set to %d", on); \
+} while (0)
+
+/* Enable/disable flow director parsing from Rx descriptor in data path. */
+static inline
+void ice_fdir_rx_parsing_enable(struct ice_adapter *ad, bool on)
+{
+	if (on) {
+		/* Enable flow director parsing from Rx descriptor */
+		FDIR_PARSING_ENABLE_PER_QUEUE(ad, on);
+		ad->fdir_ref_cnt++;
+	} else {
+		if (ad->fdir_ref_cnt >= 1) {
+			ad->fdir_ref_cnt--;
+
+			if (ad->fdir_ref_cnt == 0)
+				FDIR_PARSING_ENABLE_PER_QUEUE(ad, on);
+		}
+	}
+}
+
 #endif /* _ICE_RXTX_H_ */