From patchwork Mon Sep 14 03:05:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 77573 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4893CA04C9; Mon, 14 Sep 2020 05:09:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5106D1C0C2; Mon, 14 Sep 2020 05:09:12 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 22066FFA for ; Mon, 14 Sep 2020 05:09:08 +0200 (CEST) IronPort-SDR: 7ByGB9v1qt3wXV56tOxyy/3lAa+6KG9ceK3hBlFIzebDdxdroT468S9ntceNfJ1TERZhIu3KqW XcAos+g4PR7g== X-IronPort-AV: E=McAfee;i="6000,8403,9743"; a="156414885" X-IronPort-AV: E=Sophos;i="5.76,424,1592895600"; d="scan'208";a="156414885" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2020 20:09:08 -0700 IronPort-SDR: /uD6q7Onnj1RtsyDK39OuyU3SUBlcg5hk+2xR7ztaTJaRRoca0m0nD4AnVbvz6oInGKjvJV+eK vLGgvsH59sjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,424,1592895600"; d="scan'208";a="482168985" Received: from dpdk-zhirun-dev.sh.intel.com ([10.67.118.201]) by orsmga005.jf.intel.com with ESMTP; 13 Sep 2020 20:09:06 -0700 From: Zhirun Yan To: qi.z.zhang@intel.com, dev@dpdk.org Cc: yahui.cao@intel.com, xiao.w.wang@intel.com, simei.su@intel.com, junfeng.guo@intel.com, Zhirun Yan Date: Mon, 14 Sep 2020 11:05:29 +0800 Message-Id: <20200914030530.3077904-2-zhirun.yan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200914030530.3077904-1-zhirun.yan@intel.com> References: <20200908073939.4099976-1-zhirun.yan@intel.com> <20200914030530.3077904-1-zhirun.yan@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 1/2] net/ice: refactor FDIR set conf function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The original set conf function in FDIR was very long. Refactor to increase readability to make it clearer and allow for more convenient further changes. No functional change here. Signed-off-by: Zhirun Yan --- drivers/net/ice/ice_fdir_filter.c | 54 ++++++++++++++++++------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index 88c9bb03d..593dfd0e2 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -964,30 +964,10 @@ ice_fdir_input_set_parse(uint64_t inset, enum ice_flow_field *field) } } -static int -ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow, - uint64_t input_set, enum ice_fdir_tunnel_type ttype) +static void +ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg, + enum ice_fdir_tunnel_type ttype) { - struct ice_flow_seg_info *seg; - struct ice_flow_seg_info *seg_tun = NULL; - enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX]; - bool is_tunnel; - int i, ret; - - if (!input_set) - return -EINVAL; - - seg = (struct ice_flow_seg_info *) - ice_malloc(hw, sizeof(*seg)); - if (!seg) { - PMD_DRV_LOG(ERR, "No memory can be allocated"); - return -ENOMEM; - } - - for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++) - field[i] = ICE_FLOW_FIELD_IDX_MAX; - ice_fdir_input_set_parse(input_set, field); - switch (flow) { case ICE_FLTR_PTYPE_NONF_IPV4_UDP: ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP | @@ -1063,6 +1043,34 @@ ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow, PMD_DRV_LOG(ERR, "not supported filter type."); break; } +} + +static int +ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow, + uint64_t input_set, enum ice_fdir_tunnel_type ttype) +{ + struct ice_flow_seg_info *seg; + struct ice_flow_seg_info *seg_tun = NULL; + enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX]; + bool is_tunnel; + int i, ret; + + if (!input_set) + return -EINVAL; + + seg = (struct ice_flow_seg_info *) + ice_malloc(hw, sizeof(*seg)); + if (!seg) { + PMD_DRV_LOG(ERR, "No memory can be allocated"); + return -ENOMEM; + } + + for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++) + field[i] = ICE_FLOW_FIELD_IDX_MAX; + + ice_fdir_input_set_parse(input_set, field); + + ice_fdir_input_set_hdrs(flow, seg, ttype); for (i = 0; field[i] != ICE_FLOW_FIELD_IDX_MAX; i++) { ice_flow_set_fld(seg, field[i], From patchwork Mon Sep 14 03:05:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zhirun" X-Patchwork-Id: 77574 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C638CA04C9; Mon, 14 Sep 2020 05:09:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9DEEF1C0CE; Mon, 14 Sep 2020 05:09:14 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 23EB41BFC5 for ; Mon, 14 Sep 2020 05:09:10 +0200 (CEST) IronPort-SDR: a1wVQ4KwDNmEsO4Z98vi/lhQ7LnohVsRkPfEYgWEu3I0DLWnKZ9tWJkvMpfM0mk7SE0GSaF2p6 ImgG4x40rXTQ== X-IronPort-AV: E=McAfee;i="6000,8403,9743"; a="156414887" X-IronPort-AV: E=Sophos;i="5.76,424,1592895600"; d="scan'208";a="156414887" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2020 20:09:10 -0700 IronPort-SDR: Sa8PgsKKAbruIhanYV1H5OjJcOGyRRIE4Oh6zaBjkopIAfz9swR75n357rv8NevIt5Iud6aAun x6lw2ogUN1jg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,424,1592895600"; d="scan'208";a="482168993" Received: from dpdk-zhirun-dev.sh.intel.com ([10.67.118.201]) by orsmga005.jf.intel.com with ESMTP; 13 Sep 2020 20:09:08 -0700 From: Zhirun Yan To: qi.z.zhang@intel.com, dev@dpdk.org Cc: yahui.cao@intel.com, xiao.w.wang@intel.com, simei.su@intel.com, junfeng.guo@intel.com, Zhirun Yan Date: Mon, 14 Sep 2020 11:05:30 +0800 Message-Id: <20200914030530.3077904-3-zhirun.yan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200914030530.3077904-1-zhirun.yan@intel.com> References: <20200908073939.4099976-1-zhirun.yan@intel.com> <20200914030530.3077904-1-zhirun.yan@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 2/2] net/ice: merge inner/outer flow seg info for FDIR X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" For tunnel and non-tunnel packets, it can share the same seg_tun info. seg_tun[1] can be used for supporting inner fields with tunnel flow rule or for non-tunnel packets, seg_tun[0] only used for tunnel outer part. Add outer_input_set to distinguish inner/outer input set. So we can identify different fields in outer or inner part. Signed-off-by: Zhirun Yan --- drivers/net/ice/ice_ethdev.h | 1 + drivers/net/ice/ice_fdir_filter.c | 59 ++++++++++++++++--------------- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index 393dfeab1..6bc6dfbfb 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -285,6 +285,7 @@ struct ice_fdir_filter_conf { struct rte_flow_action_count act_count; uint64_t input_set; + uint64_t outer_input_set; /* only for tunnel packets outer fields */ }; #define ICE_MAX_FDIR_FILTER_NUM (1024 * 16) diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index 593dfd0e2..9caab05e3 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -1047,51 +1047,53 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg, static int ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow, - uint64_t input_set, enum ice_fdir_tunnel_type ttype) + uint64_t inner_input_set, uint64_t outer_input_set, + enum ice_fdir_tunnel_type ttype) { struct ice_flow_seg_info *seg; struct ice_flow_seg_info *seg_tun = NULL; enum ice_flow_field field[ICE_FLOW_FIELD_IDX_MAX]; + uint64_t input_set; bool is_tunnel; - int i, ret; + int k, i, ret = 0; - if (!input_set) + if (!(inner_input_set | outer_input_set)) return -EINVAL; - seg = (struct ice_flow_seg_info *) - ice_malloc(hw, sizeof(*seg)); - if (!seg) { + seg_tun = (struct ice_flow_seg_info *) + ice_malloc(hw, sizeof(*seg_tun) * ICE_FD_HW_SEG_MAX); + if (!seg_tun) { PMD_DRV_LOG(ERR, "No memory can be allocated"); return -ENOMEM; } - for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++) - field[i] = ICE_FLOW_FIELD_IDX_MAX; + /* use seg_tun[1] to record tunnel inner part or non-tunnel */ + for (k = 0; k <= ICE_FD_HW_SEG_TUN; k++) { + seg = &seg_tun[k]; + input_set = (k == ICE_FD_HW_SEG_TUN) ? inner_input_set : outer_input_set; + if (input_set == 0) + continue; + + for (i = 0; i < ICE_FLOW_FIELD_IDX_MAX; i++) + field[i] = ICE_FLOW_FIELD_IDX_MAX; - ice_fdir_input_set_parse(input_set, field); + ice_fdir_input_set_parse(input_set, field); - ice_fdir_input_set_hdrs(flow, seg, ttype); + ice_fdir_input_set_hdrs(flow, seg, ttype); - for (i = 0; field[i] != ICE_FLOW_FIELD_IDX_MAX; i++) { - ice_flow_set_fld(seg, field[i], - ICE_FLOW_FLD_OFF_INVAL, - ICE_FLOW_FLD_OFF_INVAL, - ICE_FLOW_FLD_OFF_INVAL, false); + for (i = 0; field[i] != ICE_FLOW_FIELD_IDX_MAX; i++) { + ice_flow_set_fld(seg, field[i], + ICE_FLOW_FLD_OFF_INVAL, + ICE_FLOW_FLD_OFF_INVAL, + ICE_FLOW_FLD_OFF_INVAL, false); + } } is_tunnel = ice_fdir_is_tunnel_profile(ttype); if (!is_tunnel) { ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi, - seg, flow, false); + seg_tun + 1, flow, false); } else { - seg_tun = (struct ice_flow_seg_info *) - ice_malloc(hw, sizeof(*seg) * ICE_FD_HW_SEG_MAX); - if (!seg_tun) { - PMD_DRV_LOG(ERR, "No memory can be allocated"); - rte_free(seg); - return -ENOMEM; - } - rte_memcpy(&seg_tun[1], seg, sizeof(*seg)); ret = ice_fdir_hw_tbl_conf(pf, pf->main_vsi, pf->fdir.fdir_vsi, seg_tun, flow, true); } @@ -1099,9 +1101,7 @@ ice_fdir_input_set_conf(struct ice_pf *pf, enum ice_fltr_ptype flow, if (!ret) { return ret; } else if (ret < 0) { - rte_free(seg); - if (is_tunnel) - rte_free(seg_tun); + rte_free(seg_tun); return (ret == -EEXIST) ? 0 : ret; } else { return ret; @@ -1311,7 +1311,8 @@ ice_fdir_create_filter(struct ice_adapter *ad, is_tun = ice_fdir_is_tunnel_profile(filter->tunnel_type); ret = ice_fdir_input_set_conf(pf, filter->input.flow_type, - filter->input_set, filter->tunnel_type); + filter->input_set, filter->outer_input_set, + filter->tunnel_type); if (ret) { rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, @@ -2106,7 +2107,7 @@ ice_fdir_parse(struct ice_adapter *ad, ret = ice_fdir_parse_pattern(ad, pattern, error, filter); if (ret) goto error; - input_set = filter->input_set; + input_set = filter->input_set | filter->outer_input_set; if (!input_set || input_set & ~item->input_set_mask) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_SPEC,