From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6763FA0548; Tue, 7 Jun 2022 19:18:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A87D34281C; Tue, 7 Jun 2022 19:17:55 +0200 (CEST) Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by mails.dpdk.org (Postfix) with ESMTP id BB04A427EE for ; Tue, 7 Jun 2022 19:17:53 +0200 (CEST) Received: by mail-pg1-f170.google.com with SMTP id h192so9672691pgc.4 for ; Tue, 07 Jun 2022 10:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zkZvA38eYJA3mUmixjXUy6VkTzt8ZcadrAXlRwvH2Y0=; b=b+5QsLVw424jr0+2fM7aJ1mH2DxAOh1YW3wAWKLJN71LLf4D4YXnMPFhQTo4JB8A9c ktstSqgJNU2nrcKzlCXoMkuoIL/XIL3DSaTV/QHnE0M46CF6AOEcbZ4zTwb2dlLwk4M4 8+2Z7l4JISbUtW7U1XIO1elh2Ki76axS5UnG23wswOIvi8QBGbEH368vqTHKHhGy5YVY OM5B9QOIZmPpC7lrZqN2rOCqZGQyjsVgZfv7FIzotALf2ocawc06b8y4cR7RDGPi193u 7kF1WE7C9s+lGU6/IbJxvpvG3ZrQssaBpGyFpqA3V7STGcbiL/J+Tk36fl51MdmFreBE 8mjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zkZvA38eYJA3mUmixjXUy6VkTzt8ZcadrAXlRwvH2Y0=; b=UouqNG5beGsTTJ4npuNsnAAfUf7iZpRHjhTsgOV9GjZTbo51TaQ/0hqsY60uioAxGL wSnD2/rvHgiNi85bsGiugjf/1DCKTNWBFbVW0/HQFQ1DN3UsubTSvgsyKKs2fU6AUF8e yp7H+rrS/L5Vw02k4+B+BC408gt7NGw0Q+nKz4zaUyPblHYA4vUHtewPxr1mzdkkvbSH WSp15JNfNOngLSQsSrDfOf/SKhRQ1adMRbteot+Iq+FX0wZrgI5TRj+3+BtE2r6ej81s W4LAdM/gHIDRVFHTTMmOB1/SaXGzn/rWhUDjqRwyaFGsHdKwWgZMuo2kOw2gfLLjHa5N 5h0A== X-Gm-Message-State: AOAM530OSe7ncapsKC810VlBlohE434jFsUOJuv/uFBp4ni0mgt9ra+F 3iHdXG0wo+0GvXcazb6+Ik4LRm+tgZ/jbA== X-Google-Smtp-Source: ABdhPJzckhxMVXiRVzl/s+meSsNitHztS5bjG1XWeJTDcN3OtcNFPXglnKrvFtyaGsGUJAlNSoJThg== X-Received: by 2002:a62:d40c:0:b0:51b:bc02:703b with SMTP id a12-20020a62d40c000000b0051bbc02703bmr30228789pfh.65.1654622272487; Tue, 07 Jun 2022 10:17:52 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id x2-20020a627c02000000b005087c23ad8dsm13185281pfc.0.2022.06.07.10.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 10:17:51 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Qiming Yang , Qi Zhang Subject: [RFC 3/8] net/ice: fix rte_memcpy warnings with gcc-12 Date: Tue, 7 Jun 2022 10:17:41 -0700 Message-Id: <20220607171746.461772-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220607171746.461772-1-stephen@networkplumber.org> References: <20220607171746.461772-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org There is no good reason to always use rte_memcpy. Regular memcpy is as fast or faster for small values and safer since it won't reference past end of input. Also static analysis tools know about regular memcpy and can analyze better. Signed-off-by: Stephen Hemminger --- drivers/net/ice/base/ice_osdep.h | 5 ++--- drivers/net/ice/ice_dcf.c | 12 ++++++------ drivers/net/ice/ice_dcf_ethdev.c | 10 +++++----- drivers/net/ice/ice_dcf_parent.c | 2 +- drivers/net/ice/ice_dcf_sched.c | 11 +++++------ drivers/net/ice/ice_ethdev.c | 13 ++++++------- drivers/net/ice/ice_fdir_filter.c | 32 +++++++++++++++---------------- drivers/net/ice/ice_tm.c | 6 +++--- 8 files changed, 44 insertions(+), 47 deletions(-) diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h index 8160eb68eeda..191646711088 100644 --- a/drivers/net/ice/base/ice_osdep.h +++ b/drivers/net/ice/base/ice_osdep.h @@ -14,7 +14,6 @@ #include #include -#include #include #include #include @@ -204,7 +203,7 @@ struct ice_virt_mem { #define ice_free(h, m) rte_free(m) #define ice_memset(a, b, c, d) memset((a), (b), (c)) -#define ice_memcpy(a, b, c, d) rte_memcpy((a), (b), (c)) +#define ice_memcpy(a, b, c, d) memcpy((a), (b), (c)) /* SW spinlock */ struct ice_lock { @@ -244,7 +243,7 @@ ice_memdup(__rte_unused struct ice_hw *hw, const void *src, size_t size, p = ice_malloc(hw, size); if (p) - rte_memcpy(p, src, size); + memcpy(p, src, size); return p; } diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c index 885d58c0f4c5..842a88299bab 100644 --- a/drivers/net/ice/ice_dcf.c +++ b/drivers/net/ice/ice_dcf.c @@ -328,7 +328,7 @@ ice_dcf_get_vf_vsi_map(struct ice_dcf_hw *hw) return 1; } - rte_memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len); + memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len); return 0; } @@ -606,7 +606,7 @@ dcf_get_vlan_offload_caps_v2(struct ice_dcf_hw *hw) return ret; } - rte_memcpy(&hw->vlan_v2_caps, &vlan_v2_caps, sizeof(vlan_v2_caps)); + memcpy(&hw->vlan_v2_caps, &vlan_v2_caps, sizeof(vlan_v2_caps)); return 0; } @@ -799,7 +799,7 @@ ice_dcf_configure_rss_key(struct ice_dcf_hw *hw) rss_key->vsi_id = hw->vsi_res->vsi_id; rss_key->key_len = hw->vf_res->rss_key_size; - rte_memcpy(rss_key->key, hw->rss_key, hw->vf_res->rss_key_size); + memcpy(rss_key->key, hw->rss_key, hw->vf_res->rss_key_size); args.v_op = VIRTCHNL_OP_CONFIG_RSS_KEY; args.req_msglen = len; @@ -831,7 +831,7 @@ ice_dcf_configure_rss_lut(struct ice_dcf_hw *hw) rss_lut->vsi_id = hw->vsi_res->vsi_id; rss_lut->lut_entries = hw->vf_res->rss_lut_size; - rte_memcpy(rss_lut->lut, hw->rss_lut, hw->vf_res->rss_lut_size); + memcpy(rss_lut->lut, hw->rss_lut, hw->vf_res->rss_lut_size); args.v_op = VIRTCHNL_OP_CONFIG_RSS_LUT; args.req_msglen = len; @@ -881,7 +881,7 @@ ice_dcf_init_rss(struct ice_dcf_hw *hw) for (i = 0; i < hw->vf_res->rss_key_size; i++) hw->rss_key[i] = (uint8_t)rte_rand(); else - rte_memcpy(hw->rss_key, rss_conf->rss_key, + memcpy(hw->rss_key, rss_conf->rss_key, RTE_MIN(rss_conf->rss_key_len, hw->vf_res->rss_key_size)); @@ -1141,7 +1141,7 @@ ice_dcf_add_del_all_mac_addr(struct ice_dcf_hw *hw, return -ENOMEM; } - rte_memcpy(list->list[0].addr, addr->addr_bytes, + memcpy(list->list[0].addr, addr->addr_bytes, sizeof(addr->addr_bytes)); PMD_DRV_LOG(DEBUG, "add/rm mac:" RTE_ETHER_ADDR_PRT_FMT, diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index 0da267db1f97..ec28f8583863 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -1326,7 +1326,7 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev, return -ENOMEM; } /* store the old lut table temporarily */ - rte_memcpy(lut, hw->rss_lut, reta_size); + memcpy(lut, hw->rss_lut, reta_size); for (i = 0; i < reta_size; i++) { idx = i / RTE_ETH_RETA_GROUP_SIZE; @@ -1335,11 +1335,11 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev, lut[i] = reta_conf[idx].reta[shift]; } - rte_memcpy(hw->rss_lut, lut, reta_size); + memcpy(hw->rss_lut, lut, reta_size); /* send virtchnnl ops to configure rss*/ ret = ice_dcf_configure_rss_lut(hw); if (ret) /* revert back */ - rte_memcpy(hw->rss_lut, lut, reta_size); + memcpy(hw->rss_lut, lut, reta_size); rte_free(lut); return ret; @@ -1396,7 +1396,7 @@ ice_dcf_dev_rss_hash_update(struct rte_eth_dev *dev, return -EINVAL; } - rte_memcpy(hw->rss_key, rss_conf->rss_key, rss_conf->rss_key_len); + memcpy(hw->rss_key, rss_conf->rss_key, rss_conf->rss_key_len); return ice_dcf_configure_rss_key(hw); } @@ -1418,7 +1418,7 @@ ice_dcf_dev_rss_hash_conf_get(struct rte_eth_dev *dev, return 0; rss_conf->rss_key_len = hw->vf_res->rss_key_size; - rte_memcpy(rss_conf->rss_key, hw->rss_key, rss_conf->rss_key_len); + memcpy(rss_conf->rss_key, hw->rss_key, rss_conf->rss_key_len); return 0; } diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c index 2f96dedcce1c..415caad3ac88 100644 --- a/drivers/net/ice/ice_dcf_parent.c +++ b/drivers/net/ice/ice_dcf_parent.c @@ -402,7 +402,7 @@ ice_dcf_load_pkg(struct ice_adapter *adapter) use_dsn = ice_dcf_execute_virtchnl_cmd(&dcf_adapter->real_hw, &vc_cmd) == 0; if (use_dsn) - rte_memcpy(&dsn, pkg_info.dsn, sizeof(dsn)); + memcpy(&dsn, pkg_info.dsn, sizeof(dsn)); return ice_load_pkg(adapter, use_dsn, dsn); } diff --git a/drivers/net/ice/ice_dcf_sched.c b/drivers/net/ice/ice_dcf_sched.c index a231c1e60b2b..805e389b6699 100644 --- a/drivers/net/ice/ice_dcf_sched.c +++ b/drivers/net/ice/ice_dcf_sched.c @@ -307,8 +307,8 @@ ice_dcf_node_add(struct rte_eth_dev *dev, uint32_t node_id, tm_node->id = node_id; tm_node->parent = NULL; tm_node->reference_count = 0; - rte_memcpy(&tm_node->params, params, - sizeof(struct rte_tm_node_params)); + memcpy(&tm_node->params, params, + sizeof(struct rte_tm_node_params)); hw->tm_conf.root = tm_node; return 0; @@ -372,8 +372,7 @@ ice_dcf_node_add(struct rte_eth_dev *dev, uint32_t node_id, tm_node->shaper_profile = shaper_profile; tm_node->reference_count = 0; tm_node->parent = parent_node; - rte_memcpy(&tm_node->params, params, - sizeof(struct rte_tm_node_params)); + memcpy(&tm_node->params, params, sizeof(struct rte_tm_node_params)); if (parent_node_type == ICE_DCF_TM_NODE_TYPE_PORT) { TAILQ_INSERT_TAIL(&hw->tm_conf.tc_list, tm_node, node); @@ -518,8 +517,8 @@ ice_dcf_shaper_profile_add(struct rte_eth_dev *dev, if (!shaper_profile) return -ENOMEM; shaper_profile->shaper_profile_id = shaper_profile_id; - rte_memcpy(&shaper_profile->profile, profile, - sizeof(struct rte_tm_shaper_params)); + memcpy(&shaper_profile->profile, profile, + sizeof(struct rte_tm_shaper_params)); TAILQ_INSERT_TAIL(&hw->tm_conf.shaper_profile_list, shaper_profile, node); diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 35ab542e61d4..04c70a7a7837 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -3224,7 +3224,7 @@ ice_get_default_rss_key(uint8_t *rss_key, uint32_t rss_key_size) key[i] = (uint8_t)rte_rand(); default_key_done = true; } - rte_memcpy(rss_key, key, RTE_MIN(rss_key_size, sizeof(default_key))); + memcpy(rss_key, key, RTE_MIN(rss_key_size, sizeof(default_key))); } static int ice_init_rss(struct ice_pf *pf) @@ -3278,11 +3278,10 @@ static int ice_init_rss(struct ice_pf *pf) if (!rss_conf->rss_key) ice_get_default_rss_key(vsi->rss_key, vsi->rss_key_size); else - rte_memcpy(vsi->rss_key, rss_conf->rss_key, - RTE_MIN(rss_conf->rss_key_len, - vsi->rss_key_size)); + memcpy(vsi->rss_key, rss_conf->rss_key, + RTE_MIN(rss_conf->rss_key_len, vsi->rss_key_size)); - rte_memcpy(key.standard_rss_key, vsi->rss_key, vsi->rss_key_size); + memcpy(key.standard_rss_key, vsi->rss_key, vsi->rss_key_size); ret = ice_aq_set_rss_key(hw, vsi->idx, &key); if (ret) goto out; @@ -4244,7 +4243,7 @@ ice_vsi_config_vlan_filter(struct ice_vsi *vsi, bool on) vsi->info.sw_flags2 &= ~sw_flags2; vsi->info.sw_id = hw->port_info->sw_id; - (void)rte_memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info)); + ctxt.info = vsi->info; ctxt.info.valid_sections = rte_cpu_to_le_16(ICE_AQ_VSI_PROP_SW_VALID | ICE_AQ_VSI_PROP_SECURITY_VALID); @@ -4895,7 +4894,7 @@ ice_vsi_vlan_pvid_set(struct ice_vsi *vsi, struct ice_vsi_vlan_pvid_info *info) ICE_AQ_VSI_INNER_VLAN_EMODE_M); vsi->info.inner_vlan_flags |= vlan_flags; memset(&ctxt, 0, sizeof(ctxt)); - rte_memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info)); + memcpy(&ctxt.info, &vsi->info, sizeof(vsi->info)); ctxt.info.valid_sections = rte_cpu_to_le_16(ICE_AQ_VSI_PROP_VLAN_VALID); ctxt.vsi_num = vsi->vsi_id; diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index 7914ba940731..2ce1cc82927c 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -1195,7 +1195,7 @@ ice_fdir_add_del_raw(struct ice_pf *pf, struct ice_hw *hw = ICE_PF_TO_HW(pf); unsigned char *pkt = (unsigned char *)pf->fdir.prg_pkt; - rte_memcpy(pkt, filter->pkt_buf, filter->pkt_len); + memcpy(pkt, filter->pkt_buf, filter->pkt_len); struct ice_fltr_desc desc; memset(&desc, 0, sizeof(desc)); @@ -1242,13 +1242,13 @@ ice_fdir_extract_fltr_key(struct ice_fdir_fltr_pattern *key, memset(key, 0, sizeof(*key)); key->flow_type = input->flow_type; - rte_memcpy(&key->ip, &input->ip, sizeof(key->ip)); - rte_memcpy(&key->mask, &input->mask, sizeof(key->mask)); - rte_memcpy(&key->ext_data, &input->ext_data, sizeof(key->ext_data)); - rte_memcpy(&key->ext_mask, &input->ext_mask, sizeof(key->ext_mask)); + memcpy(&key->ip, &input->ip, sizeof(key->ip)); + memcpy(&key->mask, &input->mask, sizeof(key->mask)); + memcpy(&key->ext_data, &input->ext_data, sizeof(key->ext_data)); + memcpy(&key->ext_mask, &input->ext_mask, sizeof(key->ext_mask)); - rte_memcpy(&key->gtpu_data, &input->gtpu_data, sizeof(key->gtpu_data)); - rte_memcpy(&key->gtpu_mask, &input->gtpu_mask, sizeof(key->gtpu_mask)); + memcpy(&key->gtpu_data, &input->gtpu_data, sizeof(key->gtpu_data)); + memcpy(&key->gtpu_mask, &input->gtpu_mask, sizeof(key->gtpu_mask)); key->tunnel_type = filter->tunnel_type; } @@ -1376,7 +1376,7 @@ ice_fdir_create_filter(struct ice_adapter *ad, if (!entry) goto error; - rte_memcpy(entry, filter, sizeof(*filter)); + memcpy(entry, filter, sizeof(*filter)); flow->rule = entry; @@ -1437,7 +1437,7 @@ ice_fdir_create_filter(struct ice_adapter *ad, if (filter->mark_flag == 1) ice_fdir_rx_parsing_enable(ad, 1); - rte_memcpy(entry, filter, sizeof(*entry)); + memcpy(entry, filter, sizeof(*entry)); ret = ice_fdir_entry_insert(pf, entry, &key); if (ret) { rte_flow_error_set(error, -ret, @@ -1738,7 +1738,7 @@ ice_fdir_parse_action(struct ice_adapter *ad, act_count = actions->conf; filter->input.cnt_ena = ICE_FXD_FLTR_QW0_STAT_ENA_PKTS; - rte_memcpy(&filter->act_count, act_count, + memcpy(&filter->act_count, act_count, sizeof(filter->act_count)); break; @@ -1951,7 +1951,7 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, u8 *pkt_buf = (u8 *)ice_malloc(&ad->hw, pkt_len + 1); if (!pkt_buf) return -ENOMEM; - rte_memcpy(pkt_buf, tmp_spec, pkt_len); + memcpy(pkt_buf, tmp_spec, pkt_len); filter->pkt_buf = pkt_buf; filter->pkt_len = pkt_len; @@ -1996,11 +1996,11 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, p_ext_data = (tunnel_type && is_outer) ? &filter->input.ext_data_outer : &filter->input.ext_data; - rte_memcpy(&p_ext_data->src_mac, + memcpy(&p_ext_data->src_mac, ð_spec->src, RTE_ETHER_ADDR_LEN); - rte_memcpy(&p_ext_data->dst_mac, + memcpy(&p_ext_data->dst_mac, ð_spec->dst, RTE_ETHER_ADDR_LEN); - rte_memcpy(&p_ext_data->ether_type, + memcpy(&p_ext_data->ether_type, ð_spec->type, sizeof(eth_spec->type)); break; case RTE_FLOW_ITEM_TYPE_IPV4: @@ -2126,8 +2126,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, if (ipv6_mask->hdr.hop_limits == UINT8_MAX) *input_set |= ICE_INSET_IPV6_HOP_LIMIT; - rte_memcpy(&p_v6->dst_ip, ipv6_spec->hdr.dst_addr, 16); - rte_memcpy(&p_v6->src_ip, ipv6_spec->hdr.src_addr, 16); + memcpy(&p_v6->dst_ip, ipv6_spec->hdr.dst_addr, 16); + memcpy(&p_v6->src_ip, ipv6_spec->hdr.src_addr, 16); vtc_flow_cpu = rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow); p_v6->tc = (uint8_t)(vtc_flow_cpu >> ICE_FDIR_IPV6_TC_OFFSET); p_v6->proto = ipv6_spec->hdr.proto; diff --git a/drivers/net/ice/ice_tm.c b/drivers/net/ice/ice_tm.c index 34a0bfcff875..82ae2a740728 100644 --- a/drivers/net/ice/ice_tm.c +++ b/drivers/net/ice/ice_tm.c @@ -330,7 +330,7 @@ ice_shaper_profile_add(struct rte_eth_dev *dev, if (!shaper_profile) return -ENOMEM; shaper_profile->shaper_profile_id = shaper_profile_id; - rte_memcpy(&shaper_profile->profile, profile, + memcpy(&shaper_profile->profile, profile, sizeof(struct rte_tm_shaper_params)); TAILQ_INSERT_TAIL(&pf->tm_conf.shaper_profile_list, shaper_profile, node); @@ -448,8 +448,8 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id, tm_node->reference_count = 0; tm_node->children = (struct ice_tm_node **) rte_calloc(NULL, 256, (sizeof(struct ice_tm_node *)), 0); - rte_memcpy(&tm_node->params, params, - sizeof(struct rte_tm_node_params)); + memcpy(&tm_node->params, params, + sizeof(struct rte_tm_node_params)); pf->tm_conf.root = tm_node; return 0; } -- 2.35.1