From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 27BDE7EEB for ; Wed, 22 Oct 2014 02:54:05 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 21 Oct 2014 18:01:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,766,1406617200"; d="scan'208";a="622879394" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 21 Oct 2014 18:02:22 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s9M12KfO008214; Wed, 22 Oct 2014 09:02:20 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s9M12Hs2011310; Wed, 22 Oct 2014 09:02:19 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s9M12Hsu011306; Wed, 22 Oct 2014 09:02:17 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Wed, 22 Oct 2014 09:01:20 +0800 Message-Id: <1413939687-11177-15-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1413939687-11177-1-git-send-email-jingjing.wu@intel.com> References: <1411711418-12881-1-git-send-email-jingjing.wu@intel.com> <1413939687-11177-1-git-send-email-jingjing.wu@intel.com> Subject: [dpdk-dev] [PATCH v4 14/21] i40e: implement operation to flush flow director table X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Oct 2014 00:54:07 -0000 implement operation to flush flow director table Signed-off-by: Jingjing Wu --- lib/librte_pmd_i40e/i40e_fdir.c | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/librte_pmd_i40e/i40e_fdir.c b/lib/librte_pmd_i40e/i40e_fdir.c index d2c8304..00ee470 100644 --- a/lib/librte_pmd_i40e/i40e_fdir.c +++ b/lib/librte_pmd_i40e/i40e_fdir.c @@ -73,6 +73,10 @@ #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 */ #define I40E_COUNTER_INDEX_FDIR(pf_id) (0 + (pf_id) * I40E_COUNTER_PF) @@ -89,6 +93,7 @@ static int i40e_fdir_filter_programming(struct i40e_pf *pf, enum i40e_filter_pctype pctype, struct rte_eth_fdir_filter *filter, bool add); +static int i40e_fdir_flush(struct i40e_pf *pf); static void i40e_fdir_info_get(struct i40e_pf *pf, struct rte_eth_fdir_info *fdir); @@ -876,6 +881,45 @@ i40e_fdir_filter_programming(struct i40e_pf *pf, } /* + * i40e_fdir_flush - clear all filters of Flow Director table + * @pf: board private structure + */ +static 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."); + return -ETIMEDOUT; + } + 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."); + return -ENOSYS; + } else + PMD_DRV_LOG(INFO, "FD table Flush success."); + return 0; +} + +/* * i40e_fdir_info_get - get information of Flow Director * @pf: ethernet device to get info from * @fdir: a pointer to a structure of type *rte_eth_fdir_info* to be filled with @@ -935,6 +979,9 @@ i40e_fdir_ctrl_func(struct i40e_pf *pf, enum rte_filter_op filter_op, void *arg) (struct rte_eth_fdir_filter *)arg, FALSE); break; + case RTE_ETH_FILTER_FLUSH: + ret = i40e_fdir_flush(pf); + break; case RTE_ETH_FILTER_INFO: i40e_fdir_info_get(pf, (struct rte_eth_fdir_info *)arg); break; -- 1.8.1.4