From patchwork Fri Sep 26 06:03:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingjing Wu X-Patchwork-Id: 553 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 60D9B7DFC; Fri, 26 Sep 2014 07:58:04 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id DD46F7DEB for ; Fri, 26 Sep 2014 07:58:01 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by orsmga102.jf.intel.com with ESMTP; 25 Sep 2014 22:58:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,603,1406617200"; d="scan'208";a="480127264" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by azsmga001.ch.intel.com with ESMTP; 25 Sep 2014 23:04:20 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s8Q64IJl029347; Fri, 26 Sep 2014 14:04:18 +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 s8Q64FA9013033; Fri, 26 Sep 2014 14:04:17 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s8Q64FKS013029; Fri, 26 Sep 2014 14:04:15 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Fri, 26 Sep 2014 14:03:34 +0800 Message-Id: <1411711418-12881-17-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1411711418-12881-1-git-send-email-jingjing.wu@intel.com> References: <1411711418-12881-1-git-send-email-jingjing.wu@intel.com> Subject: [dpdk-dev] [PATCH v316/20] i40e: implement operations to configure flexible payload 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" implement operation to flexible payload in i40e pmd driver Signed-off-by: Jingjing Wu Acked-by: Chen Jing D(Mark) Acked-by: Helin Zhang --- lib/librte_pmd_i40e/i40e_fdir.c | 101 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/lib/librte_pmd_i40e/i40e_fdir.c b/lib/librte_pmd_i40e/i40e_fdir.c index 973c8e0..01693a2 100644 --- a/lib/librte_pmd_i40e/i40e_fdir.c +++ b/lib/librte_pmd_i40e/i40e_fdir.c @@ -80,8 +80,11 @@ #define I40E_COUNTER_PF 2 /* Statistic counter index for one pf */ #define I40E_COUNTER_INDEX_FDIR(pf_id) (0 + (pf_id) * I40E_COUNTER_PF) +#define I40E_FLX_OFFSET_IN_FIELD_VECTOR 50 static int i40e_fdir_rx_queue_init(struct i40e_rx_queue *rxq); +static int i40e_set_flx_pld_cfg(struct i40e_pf *pf, + struct rte_eth_flex_payload_cfg *cfg); static int i40e_fdir_construct_pkt(struct i40e_pf *pf, struct rte_eth_fdir_input *fdir_input, unsigned char *raw_pkt); @@ -325,6 +328,97 @@ i40e_fdir_teardown(struct i40e_pf *pf) return; } +/* + * i40e_set_flx_pld_cfg -configure the rule how bytes stream is extracted as flexible payload + * @pf: board private structure + * @cfg: the rule how bytes stream is extracted as flexible payload + */ +static int +i40e_set_flx_pld_cfg(struct i40e_pf *pf, + struct rte_eth_flex_payload_cfg *cfg) +{ + struct i40e_hw *hw = I40E_PF_TO_HW(pf); + struct rte_eth_fdir_info fdir; + uint32_t flx_pit; + uint16_t min_next_off = 0; + uint8_t idx = 0; + int i = 0; + int num_word = 0; + int ret; + + if (cfg == NULL || cfg->nb_field > 3) + return -EINVAL; + + if (cfg->type == RTE_ETH_L2_PAYLOAD) + idx = 0; + else if (cfg->type == RTE_ETH_L3_PAYLOAD) + idx = 1; + else if (cfg->type == RTE_ETH_L4_PAYLOAD) + idx = 2; + else { + PMD_DRV_LOG(ERR, "unknown payload type."); + return -EINVAL; + } + /* + * flexible payload need to be configured before + * flow director filters are added + * If filters exist, flush them. + */ + memset(&fdir, 0, sizeof(fdir)); + i40e_fdir_info_get(pf, &fdir); + if (fdir.info_ext.best_cnt + fdir.info_ext.guarant_cnt > 0) { + ret = i40e_fdir_flush(pf); + if (ret) { + PMD_DRV_LOG(ERR, " failed to flush fdir table."); + return ret; + } + } + + for (i = 0; i < cfg->nb_field; i++) { + /* + * check register's constrain + * Current Offset >= previous offset + previous FSIZE. + */ + if (cfg->field[i].offset < min_next_off) { + PMD_DRV_LOG(ERR, "Offset should be larger than" + "previous offset + previous FSIZE."); + return -EINVAL; + } + flx_pit = (cfg->field[i].offset << + I40E_PRTQF_FLX_PIT_SOURCE_OFF_SHIFT) & + I40E_PRTQF_FLX_PIT_SOURCE_OFF_MASK; + flx_pit |= (cfg->field[i].size << + I40E_PRTQF_FLX_PIT_FSIZE_SHIFT) & + I40E_PRTQF_FLX_PIT_FSIZE_MASK; + flx_pit |= ((num_word + I40E_FLX_OFFSET_IN_FIELD_VECTOR) << + I40E_PRTQF_FLX_PIT_DEST_OFF_SHIFT) & + I40E_PRTQF_FLX_PIT_DEST_OFF_MASK; + /* support no more than 8 words flexible payload*/ + num_word += cfg->field[i].size; + if (num_word > 8) + return -EINVAL; + + I40E_WRITE_REG(hw, I40E_PRTQF_FLX_PIT(idx * 3 + i), flx_pit); + /* record the info in fdir structure */ + pf->fdir.flex_set[idx][i].offset = cfg->field[i].offset; + pf->fdir.flex_set[idx][i].size = cfg->field[i].size; + min_next_off = cfg->field[i].offset + cfg->field[i].size; + } + + for (; i < 3; i++) { + /* set the non-used register obeying register's constrain */ + flx_pit = (min_next_off << I40E_PRTQF_FLX_PIT_SOURCE_OFF_SHIFT) & + I40E_PRTQF_FLX_PIT_SOURCE_OFF_MASK; + flx_pit |= (1 << I40E_PRTQF_FLX_PIT_FSIZE_SHIFT) & + I40E_PRTQF_FLX_PIT_FSIZE_MASK; + flx_pit |= (63 << I40E_PRTQF_FLX_PIT_DEST_OFF_SHIFT) & + I40E_PRTQF_FLX_PIT_DEST_OFF_MASK; + I40E_WRITE_REG(hw, I40E_PRTQF_FLX_PIT(idx * 3 + i), flx_pit); + min_next_off++; + } + + return 0; +} static int i40e_fdir_construct_pkt(struct i40e_pf *pf, struct rte_eth_fdir_input *fdir_input, @@ -944,6 +1038,7 @@ i40e_fdir_info_get(struct i40e_pf *pf, struct rte_eth_fdir_info *fdir) int i40e_fdir_ctrl_func(struct i40e_pf *pf, enum rte_filter_op filter_op, void *arg) { + struct rte_eth_fdir_cfg *fdir_cfg = NULL; int ret = I40E_SUCCESS; if (arg == NULL && filter_op != RTE_ETH_FILTER_OP_NONE && @@ -968,6 +1063,12 @@ i40e_fdir_ctrl_func(struct i40e_pf *pf, enum rte_filter_op filter_op, void *arg) case RTE_ETH_FILTER_OP_FLUSH: ret = i40e_fdir_flush(pf); break; + case RTE_ETH_FILTER_OP_SET: + fdir_cfg = (struct rte_eth_fdir_cfg *)arg; + if (fdir_cfg->cmd == RTE_ETH_FDIR_CFG_FLX) + ret = i40e_set_flx_pld_cfg(pf, + (struct rte_eth_flex_payload_cfg *)fdir_cfg->cfg); + break; case RTE_ETH_FILTER_OP_GET_INFO: i40e_fdir_info_get(pf, (struct rte_eth_fdir_info *)arg); break;