From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 6401F7E80 for ; Wed, 22 Oct 2014 02:54:18 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 21 Oct 2014 18:01:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,766,1406617200"; d="scan'208";a="622879562" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 21 Oct 2014 18:02:35 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s9M12XQ7012217; Wed, 22 Oct 2014 09:02: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 s9M12VYT011352; Wed, 22 Oct 2014 09:02:33 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s9M12V4B011348; Wed, 22 Oct 2014 09:02:31 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Wed, 22 Oct 2014 09:01:26 +0800 Message-Id: <1413939687-11177-21-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 20/21] i40e: implement operations to configure flexible masks 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:19 -0000 implement operation to flexible masks for each flow type in i40e pmd driver Signed-off-by: Jingjing Wu --- lib/librte_pmd_i40e/i40e_fdir.c | 124 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/lib/librte_pmd_i40e/i40e_fdir.c b/lib/librte_pmd_i40e/i40e_fdir.c index 67498ff..2184d93 100644 --- a/lib/librte_pmd_i40e/i40e_fdir.c +++ b/lib/librte_pmd_i40e/i40e_fdir.c @@ -85,6 +85,8 @@ 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_set_fdir_flx_mask(struct i40e_pf *pf, + struct rte_eth_fdir_flex_masks *flex_masks); static int i40e_fdir_construct_pkt(struct i40e_pf *pf, struct rte_eth_fdir_input *fdir_input, unsigned char *raw_pkt); @@ -420,6 +422,123 @@ i40e_set_flx_pld_cfg(struct i40e_pf *pf, return 0; } +static inline void +i40e_set_flex_mask_on_pctype( + struct i40e_hw *hw, + enum i40e_filter_pctype pctype, + struct rte_eth_fdir_flex_masks *flex_masks) +{ + uint32_t flxinset, mask; + int i; + + flxinset = (flex_masks->words_mask << + I40E_PRTQF_FD_FLXINSET_INSET_SHIFT) & + I40E_PRTQF_FD_FLXINSET_INSET_MASK; + I40E_WRITE_REG(hw, I40E_PRTQF_FD_FLXINSET(pctype), flxinset); + + for (i = 0; i < flex_masks->nb_field; i++) { + mask = (flex_masks->field[i].bitmask << + I40E_PRTQF_FD_MSK_MASK_SHIFT) & + I40E_PRTQF_FD_MSK_MASK_MASK; + mask |= ((flex_masks->field[i].offset + + I40E_FLX_OFFSET_IN_FIELD_VECTOR) << + I40E_PRTQF_FD_MSK_OFFSET_SHIFT) & + I40E_PRTQF_FD_MSK_OFFSET_MASK; + I40E_WRITE_REG(hw, I40E_PRTQF_FD_MSK(pctype, i), mask); + } +} + +/* + * i40e_set_fdir_flx_mask - configure the mask on flexible payload + * @pf: board private structure + * @flex_masks: mask for flexible payload + */ +static int +i40e_set_fdir_flx_mask(struct i40e_pf *pf, + struct rte_eth_fdir_flex_masks *flex_masks) +{ + struct i40e_hw *hw = I40E_PF_TO_HW(pf); + struct rte_eth_fdir_info fdir; + int ret = 0; + + if (flex_masks == NULL) + return -EINVAL; + + if (flex_masks->nb_field > 2) { + PMD_DRV_LOG(ERR, "bit masks cannot support more than 2 words."); + return -EINVAL; + } + /* + * flexible payload masks 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; + } + } + + switch (flex_masks->flow_type) { + case RTE_ETH_FLOW_TYPE_UDPV4: + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_NONF_IPV4_UDP, + flex_masks); + break; + case RTE_ETH_FLOW_TYPE_TCPV4: + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_NONF_IPV4_TCP, + flex_masks); + break; + case RTE_ETH_FLOW_TYPE_SCTPV4: + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_NONF_IPV4_SCTP, + flex_masks); + break; + case RTE_ETH_FLOW_TYPE_IPV4_OTHER: + /* set mask for both NONF_IPV4 and FRAG_IPV4 PCTYPE*/ + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_NONF_IPV4_OTHER, + flex_masks); + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_FRAG_IPV4, + flex_masks); + break; + case RTE_ETH_FLOW_TYPE_UDPV6: + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_NONF_IPV6_UDP, + flex_masks); + break; + case RTE_ETH_FLOW_TYPE_TCPV6: + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_NONF_IPV6_TCP, + flex_masks); + case RTE_ETH_FLOW_TYPE_SCTPV6: + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_NONF_IPV6_SCTP, + flex_masks); + break; + case RTE_ETH_FLOW_TYPE_IPV6_OTHER: + /* set mask for both NONF_IPV6 and FRAG_IPV6 PCTYPE*/ + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_NONF_IPV6_OTHER, + flex_masks); + i40e_set_flex_mask_on_pctype(hw, + I40E_FILTER_PCTYPE_FRAG_IPV6, + flex_masks); + break; + default: + PMD_DRV_LOG(ERR, "invalid flow_type input."); + return -EINVAL; + } + + return ret; +} + /* * i40e_fdir_construct_pkt - construct packet based on fields in input * @pf: board private structure @@ -1082,8 +1201,11 @@ i40e_fdir_ctrl_func(struct i40e_pf *pf, enum rte_filter_op filter_op, void *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); + else if (fdir_cfg->cmd == RTE_ETH_FDIR_CFG_FLX_MASK) + ret = i40e_set_fdir_flx_mask(pf, + (struct rte_eth_fdir_flex_masks *)fdir_cfg->cfg); else { - PMD_DRV_LOG(WARNING, "unsupported configuration command %u.", + PMD_DRV_LOG(ERR, "unsupported configuration command %u.", fdir_cfg->cmd); return -EINVAL; } -- 1.8.1.4