From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 759CBA0613 for ; Mon, 23 Sep 2019 09:44:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7E35A1BEBE; Mon, 23 Sep 2019 09:43:28 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id D80831BEB5 for ; Mon, 23 Sep 2019 09:42:29 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 00:42:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,539,1559545200"; d="scan'208";a="182445678" Received: from dpdk51.sh.intel.com ([10.67.110.245]) by orsmga008.jf.intel.com with ESMTP; 23 Sep 2019 00:42:28 -0700 From: Qi Zhang To: wenzhuo.lu@intel.com, qiming.yang@intel.com Cc: dev@dpdk.org, xiaolong.ye@intel.com, Qi Zhang , Bruce Allan , Paul M Stillwell Jr Date: Mon, 23 Sep 2019 15:44:36 +0800 Message-Id: <20190923074448.7847-19-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190923074448.7847-1-qi.z.zhang@intel.com> References: <20190902035551.16852-1-qi.z.zhang@intel.com> <20190923074448.7847-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v5 18/30] net/ice/base: replace alloc-followed-by-copy with memdup 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" ice_memdup() is preferred over an alloc immediately followed by a copy. Signed-off-by: Bruce Allan Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang --- drivers/net/ice/base/ice_flex_pipe.c | 5 ++--- drivers/net/ice/base/ice_switch.c | 7 ++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c index 05cd39b17..76c26fd4e 100644 --- a/drivers/net/ice/base/ice_flex_pipe.c +++ b/drivers/net/ice/base/ice_flex_pipe.c @@ -4939,12 +4939,11 @@ ice_get_profs_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, struct ice_vsig_prof *p; /* copy to the input list */ - p = (struct ice_vsig_prof *)ice_malloc(hw, sizeof(*p)); + p = (struct ice_vsig_prof *)ice_memdup(hw, ent1, sizeof(*p), + ICE_NONDMA_TO_NONDMA); if (!p) goto err_ice_get_profs_vsig; - ice_memcpy(p, ent1, sizeof(*p), ICE_NONDMA_TO_NONDMA); - LIST_ADD_TAIL(&p->list, lst); } diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index 64c2aec19..62ccf533c 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -623,14 +623,11 @@ ice_get_recp_frm_fw(struct ice_hw *hw, struct ice_sw_recipe *recps, u8 rid, recps[rid].big_recp = (num_recps > 1); recps[rid].n_grp_count = num_recps; recps[rid].root_buf = (struct ice_aqc_recipe_data_elem *) - ice_calloc(hw, recps[rid].n_grp_count, - sizeof(struct ice_aqc_recipe_data_elem)); + ice_memdup(hw, tmp, recps[rid].n_grp_count * + sizeof(*recps[rid].root_buf), ICE_NONDMA_TO_NONDMA); if (!recps[rid].root_buf) goto err_unroll; - ice_memcpy(recps[rid].root_buf, tmp, recps[rid].n_grp_count * - sizeof(*recps[rid].root_buf), ICE_NONDMA_TO_NONDMA); - /* Copy result indexes */ ice_memcpy(recps[rid].res_idxs, result_bm, sizeof(recps[rid].res_idxs), ICE_NONDMA_TO_NONDMA); -- 2.13.6