DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jingjing Wu <jingjing.wu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 4/7] i40e: function implement in i40e for flow director flush and info get
Date: Wed, 27 Aug 2014 10:13:51 +0800	[thread overview]
Message-ID: <1409105634-29980-5-git-send-email-jingjing.wu@intel.com> (raw)
In-Reply-To: <1409105634-29980-1-git-send-email-jingjing.wu@intel.com>

support the API ops defined in ethdev, the behavior according to each command:
  RTE_CMD_FDIR_FLUSH   : clear all FDIR filter rules.
  RTE_CMD_FDIR_INFO_GET: get FDIR information.
 
Signed-off-by: jingjing.wu <jingjing.wu@intel.com>
Reviewed-by: Helin Zhang <helin.zhang@intel.com>
Reviewed-by: Jing Chen <jing.d.chen@intel.com>
Reviewed-by: Jijiang Liu <jijiang.liu@intel.com>
 
---
 lib/librte_pmd_i40e/i40e_ethdev.c |  8 +++++
 lib/librte_pmd_i40e/i40e_ethdev.h |  3 ++
 lib/librte_pmd_i40e/i40e_fdir.c   | 67 +++++++++++++++++++++++++++++++++++++++
 lib/librte_pmd_i40e/rte_i40e.h    | 14 ++++++++
 4 files changed, 92 insertions(+)

diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c
index 7dcf964..10797ba 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -4221,6 +4221,14 @@ i40e_rx_classification_filter_ctl(struct rte_eth_dev *dev,
 			&fdir_entry->action,
 			FALSE);
 		break;
+	case RTE_CMD_FDIR_INFO_GET:
+		if (args == NULL)
+			return I40E_ERR_PARAM;
+		i40e_fdir_info_get(dev, (struct rte_i40e_fdir_info *)args);
+		break;
+	case RTE_CMD_FDIR_FLUSH:
+		ret = i40e_fdir_flush(pf);
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "unknown command type %u\n", cmd);
 		ret = I40E_ERR_PARAM;
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.h b/lib/librte_pmd_i40e/i40e_ethdev.h
index 5edb99e..7755f5a 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.h
+++ b/lib/librte_pmd_i40e/i40e_ethdev.h
@@ -334,11 +334,14 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf,
 				    unsigned int socket_id);
 int i40e_fdir_setup(struct i40e_pf *pf);
 void i40e_fdir_teardown(struct i40e_pf *pf);
+int i40e_fdir_flush(struct i40e_pf *pf);
 int i40e_fdir_filter_programming(struct i40e_pf *pf,
 			uint16_t soft_id,
 			struct rte_i40e_fdir_input *fdir_filter,
 			struct rte_i40e_fdir_action *fdir_action,
 			bool add);
+void i40e_fdir_info_get(struct rte_eth_dev *dev,
+			   struct rte_i40e_fdir_info *fdir);
 
 /* I40E_DEV_PRIVATE_TO */
 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
diff --git a/lib/librte_pmd_i40e/i40e_fdir.c b/lib/librte_pmd_i40e/i40e_fdir.c
index df9a889..39e9e88 100644
--- a/lib/librte_pmd_i40e/i40e_fdir.c
+++ b/lib/librte_pmd_i40e/i40e_fdir.c
@@ -51,6 +51,9 @@
 /* Wait count and inteval for fdir filter programming */
 #define I40E_FDIR_WAIT_COUNT       10
 #define I40E_FDIR_WAIT_INTERVAL_US 1000
+/* Wait count and inteval for fdir filter flush */
+#define I40E_FDIR_FLUSH_RETRY       50
+#define I40E_FDIR_FLUSH_INTERVAL_MS 5
 
 #define I40E_COUNTER_PF           2
 /* Statistic counter index for one pf */
@@ -217,6 +220,45 @@ i40e_fdir_teardown(struct i40e_pf *pf)
 	return;
 }
 
+/*
+ * i40e_fdir_flush - clear all filters of Flow Director
+ * @pf: board private structure
+ */
+int
+i40e_fdir_flush(struct i40e_pf *pf)
+{
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	uint32_t reg;
+	uint16_t guarant_cnt, best_cnt;
+	int i;
+
+	I40E_WRITE_REG(hw, I40E_PFQF_CTL_1, I40E_PFQF_CTL_1_CLEARFDTABLE_MASK);
+	I40E_WRITE_FLUSH(hw);
+
+	for (i = 0; i < I40E_FDIR_FLUSH_RETRY; i++) {
+		rte_delay_ms(I40E_FDIR_FLUSH_INTERVAL_MS);
+		reg = I40E_READ_REG(hw, I40E_PFQF_CTL_1);
+		if (!(reg & I40E_PFQF_CTL_1_CLEARFDTABLE_MASK))
+			break;
+	}
+	if (i >= I40E_FDIR_FLUSH_RETRY) {
+		PMD_DRV_LOG(ERR, "FD table did not flush, may need more time\n");
+		return I40E_ERR_TIMEOUT;
+	}
+	guarant_cnt = (uint16_t)((I40E_READ_REG(hw, I40E_PFQF_FDSTAT) &
+				I40E_PFQF_FDSTAT_GUARANT_CNT_MASK) >>
+				I40E_PFQF_FDSTAT_GUARANT_CNT_SHIFT);
+	best_cnt = (uint16_t)((I40E_READ_REG(hw, I40E_PFQF_FDSTAT) &
+				I40E_PFQF_FDSTAT_BEST_CNT_MASK) >>
+				I40E_PFQF_FDSTAT_BEST_CNT_SHIFT);
+	if (guarant_cnt != 0 || best_cnt != 0) {
+		PMD_DRV_LOG(ERR, "Failed to flush FD table\n");
+		return I40E_ERR_CONFIG;
+	} else
+		PMD_DRV_LOG(INFO, "FD table Flush success\n");
+	return I40E_SUCCESS;
+}
+
 /* Construct the tx flags */
 static inline uint64_t
 i40e_build_ctob(uint32_t td_cmd,
@@ -431,3 +473,28 @@ i40e_fdir_filter_programming(struct i40e_pf *pf,
 	}
 	return I40E_SUCCESS;
 }
+
+/*
+ * i40e_fdir_info_get - get information of Flow Director
+ * @dev: ethernet device to add filter to
+ * @fdir: a pointer to a structure of type *rte_eth_dev_fdir* to be filled with
+ *    the flow director information.
+ **/
+void
+i40e_fdir_info_get(struct rte_eth_dev *dev, struct rte_i40e_fdir_info *fdir)
+{
+	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t pfqf_ctl;
+
+	pfqf_ctl = I40E_READ_REG(hw, I40E_PFQF_CTL_0);
+	fdir->mode = pfqf_ctl & I40E_PFQF_CTL_0_FD_ENA_MASK ? 1 : 0;
+	fdir->guarant_spc = (uint16_t)hw->func_caps.fd_filters_guaranteed;
+	fdir->guarant_cnt = (uint16_t)((I40E_READ_REG(hw, I40E_PFQF_FDSTAT) &
+				I40E_PFQF_FDSTAT_GUARANT_CNT_MASK) >>
+				I40E_PFQF_FDSTAT_GUARANT_CNT_SHIFT);
+	fdir->best_spc = (uint16_t)hw->func_caps.fd_filters_best_effort;
+	fdir->best_cnt = (uint16_t)((I40E_READ_REG(hw, I40E_PFQF_FDSTAT) &
+				I40E_PFQF_FDSTAT_BEST_CNT_MASK) >>
+				I40E_PFQF_FDSTAT_BEST_CNT_SHIFT);
+	return;
+}
diff --git a/lib/librte_pmd_i40e/rte_i40e.h b/lib/librte_pmd_i40e/rte_i40e.h
index 3d9cc3d..1176a37 100644
--- a/lib/librte_pmd_i40e/rte_i40e.h
+++ b/lib/librte_pmd_i40e/rte_i40e.h
@@ -104,6 +104,20 @@ struct rte_i40e_fdir_entry {
 	struct rte_i40e_fdir_action action; /**< action taken when match */
 };
 
+/**
+ * For commands:
+ * 'RTE_CMD_FDIR_INFO_GET'
+ *
+ * A structure used for user to get the information of fdir feature.
+ */
+struct rte_i40e_fdir_info {
+	uint8_t  mode;         /**< 0 is disable, 1 is enable. */
+	uint16_t guarant_spc;  /**< guaranteed spaces.*/
+	uint16_t guarant_cnt;  /**< Number of filters in guaranteed spaces. */
+	uint16_t best_spc;     /**< best effort spaces.*/
+	uint16_t best_cnt;     /**< Number of filters in best effort spaces. */
+};
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.8.1.4

  parent reply	other threads:[~2014-08-27  2:10 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27  2:13 [dpdk-dev] [PATCH v2 0/7] Support flow director programming on fortville Jingjing Wu
2014-08-27  2:13 ` [dpdk-dev] [PATCH v2 1/7] i40e: flow director resource reserve and initialize on i40e Jingjing Wu
2014-08-27 14:17   ` Thomas Monjalon
2014-08-28  2:56     ` Wu, Jingjing
2014-08-27  2:13 ` [dpdk-dev] [PATCH v2 2/7] ethdev: define new ethdev API rx_classification_filter_ctl Jingjing Wu
2014-08-27 14:22   ` Thomas Monjalon
2014-08-28  3:30     ` Wu, Jingjing
2014-08-28 10:55       ` Thomas Monjalon
2014-08-28 11:48         ` Ananyev, Konstantin
2014-08-28 14:07           ` Wu, Jingjing
2014-08-28 13:39         ` Wu, Jingjing
2014-08-28 14:20           ` Thomas Monjalon
2014-08-28 14:31             ` Wu, Jingjing
2014-08-27  2:13 ` [dpdk-dev] [PATCH v2 3/7] i40e: function implement in i40e for flow director filter programming Jingjing Wu
2014-08-27 14:24   ` Thomas Monjalon
2014-08-28  2:57     ` Wu, Jingjing
2014-08-27  2:13 ` Jingjing Wu [this message]
2014-08-27  2:13 ` [dpdk-dev] [PATCH v2 5/7] fix the Marco conflict Jingjing Wu
2014-08-27 14:27   ` Thomas Monjalon
2014-08-28  3:39     ` Wu, Jingjing
2014-08-28  8:55       ` Thomas Monjalon
2014-08-28 14:37         ` Wu, Jingjing
2014-08-28 14:46           ` Thomas Monjalon
2014-08-27  2:13 ` [dpdk-dev] [PATCH v2 6/7] i40e: support FD ID report and match counter for i40e flow director Jingjing Wu
2014-08-27  2:13 ` [dpdk-dev] [PATCH v2 7/7]app/testpmd: add commands and config functions for i40e flow director support Jingjing Wu
2014-08-27 14:35   ` Thomas Monjalon
2014-08-27 16:54     ` Venkatesan, Venky
2014-08-28  3:51     ` Wu, Jingjing
2014-08-28  8:50       ` Thomas Monjalon
2014-08-28  9:01         ` Wu, Jingjing
2014-08-28 11:00           ` Thomas Monjalon
2014-08-28 11:30             ` Ananyev, Konstantin
2014-08-28 12:02               ` Thomas Monjalon
2014-09-24  4:52 ` [dpdk-dev] [PATCH v2 0/7] Support flow director programming on fortville Cao, Min

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409105634-29980-5-git-send-email-jingjing.wu@intel.com \
    --to=jingjing.wu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).