From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id BFA34B376 for ; Wed, 27 Aug 2014 04:10:56 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 26 Aug 2014 19:14:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,408,1406617200"; d="scan'208";a="590362836" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 26 Aug 2014 19:14:34 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s7R2EXPO006231; Wed, 27 Aug 2014 10:14:33 +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 s7R2EUEZ030117; Wed, 27 Aug 2014 10:14:32 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s7R2EUlW030113; Wed, 27 Aug 2014 10:14:30 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Wed, 27 Aug 2014 10:13:51 +0800 Message-Id: <1409105634-29980-5-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1409105634-29980-1-git-send-email-jingjing.wu@intel.com> References: <1409105634-29980-1-git-send-email-jingjing.wu@intel.com> Subject: [dpdk-dev] [PATCH v2 4/7] i40e: function implement in i40e for flow director flush and info get 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, 27 Aug 2014 02:10:57 -0000 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 Reviewed-by: Helin Zhang Reviewed-by: Jing Chen Reviewed-by: Jijiang Liu --- 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