From patchwork Tue Apr 2 21:50:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 830 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8000543DC8; Tue, 2 Apr 2024 23:55:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 450FD4028C; Tue, 2 Apr 2024 23:55:43 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 7DF9C4025D for ; Tue, 2 Apr 2024 23:55:41 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1e0b889901bso45959425ad.1 for ; Tue, 02 Apr 2024 14:55:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1712094940; x=1712699740; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pTnQwkVJwyDNvOVKOuOxP8dWkHmUIx/TdNwjDuKhQjs=; b=Ix2RyefijIOdGQDOUrtp6wLUBb3FM5jW0svDGgkdbJSqNg3GU9ijhb3JGX0xmkKPHZ jDK4gb4URaqOHjW6ivNysGrm4p++U0I/4zEu8F5v4JIxqSNfz8M6CjK77eAIFuOF6D2S KZqJ6D22v+ISkGQU5PS6+yNFnYUSn9P5oig2UP1tdn6/hyjOokw3KXogQWfcaBV61QiJ /cagHSw8kIXR+hSxHuRQuTKNvdDxN783jQivZZMmqrRTDJfVOwUuqnSc1BfecZG9qX5d vHZ+2v/9dDMBNgxvGJbrYYsAo0f9k+lgYS1/HOQ7tJQxPFh2ja0Pj1qctGFvBQY3cDHh NWFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712094940; x=1712699740; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pTnQwkVJwyDNvOVKOuOxP8dWkHmUIx/TdNwjDuKhQjs=; b=RCSMrhjcjsE5lW/UHC8WYfhLhmuz7zZgG8UR8AiAq8+uVnfoQIZ0qqO4YTK4MehWB2 tkS7TdKWQMhQsJ6Mh0+StqVRDBZuOA/8rp1eYO2Y6oTpEZpFGshS6OIJDsRUtPb+xBZ/ 8/uRaO0NJJWC33oApChv5MTgOOemDjk+XFxIfFSHu9O+83JSGWcHlUIaD7n/7stnTRLf BZE62GaZkjrnkUflWWpJjb1QsFcFxCwXvImuZnP2PITaiLyq0Q9bms3v5Zpm0y+yNDqO w0kjxh/pNq/W2NEguYL16iLKXPkdhR2gJDonvLO5PCJmlHs0paShQeQ7dYoaQte2OKbz BQ5w== X-Gm-Message-State: AOJu0Yzo8C6tYvtkJAP7KRoQqNvMgCdLFzrPBKfbAEMR1xK6vwEd+QGX oiViLrfKS/Ri0oP+NQTPokxBzuWMLpQaV589uQt9KN/c6FtcAajtf6NcbtPqGSTiXNoQ5nc4siq 7 X-Google-Smtp-Source: AGHT+IFqQrODTWplILHH96W6wcs+6MjznyZOQIs8ZcFTjD9CvKfAcjvJcVrGSStcHg9aQ41cuQoBXg== X-Received: by 2002:a17:902:e741:b0:1dc:a605:5435 with SMTP id p1-20020a170902e74100b001dca6055435mr14857261plf.31.1712094940482; Tue, 02 Apr 2024 14:55:40 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id x15-20020a170902820f00b001dddf29b6e8sm11609381pln.299.2024.04.02.14.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 14:55:40 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v3 00/30] replace rte_memcpy of fixed size with memcpy Date: Tue, 2 Apr 2024 14:50:16 -0700 Message-ID: <20240402215502.278838-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240229225936.483472-1-stephen@networkplumber.org> References: <20240229225936.483472-1-stephen@networkplumber.org> MIME-Version: 1.0 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 The DPDK has a lot of unnecessary usage of rte_memcpy. This patch set replaces cases where rte_memcpy is used with a fixed size constant size. Typical example is: rte_memcpy(mac_addrs, mac.addr_bytes, RTE_ETHER_ADDR_LEN); which can be replaced with: memcpy(mac_addrs, mac.addr_bytes, RTE_ETHER_ADDR_LEN); This does not change the resulting binary on almost all architectures because x86 version of intrisics and glibc are the same, and other architectures were using __builtin_constant_p(). The main benefit is that analysis tools like fortify, Coverity, and ASAN analyzers can check these memcpy's. The first patch is a simple coccinelle script to do the replacement and the rest are the results broken out by module. The script can be used again to make sure more bad usage doesn't creep in with new drivers. v3 - rebase and rerun coccinelle script on 24.03 - consolidate patches by subtree - remove inclusion of rte_memcpy.h when no longer used. Stephen Hemminger (30): cocci/rte_memcpy: add script to eliminate fixed size rte_memcpy eal: replace use of fixed size rte_memcpy ethdev: replace use of fixed size rte_memcpy eventdev: replace use of fixed size rte_memcpy cryptodev: replace use of fixed size rte_memcpy ip_frag: replace use of fixed size rte_memcpy net: replace use of fixed size rte_memcpy lpm: replace use of fixed size rte_memcpy node: replace use of fixed size rte_memcpy pdcp: replace use of fixed size rte_memcpy pipeline: replace use of fixed size rte_memcpy rib: replace use of fixed size rte_memcpy security: replace use of fixed size rte_memcpy bus: remove unneeded rte_memcpy.h include net: replace use of fixed size rte_memcpy raw: replace use of fixed size rte_memcpy baseband: replace use of fixed size rte_memcpy common: replace use of fixed size rte_memcpy crypto: replace use of fixed size rte_memcpy crypto: replace use of fixed size rte_memcpy event: replace use of fixed size rte_memcpy mempool: replace use of fixed size rte_memcpy ml/cnxk: replace use of fixed size rte_memcpy app/test-pmd: replace use of fixed size rte_memcpy app/graph: replace use of fixed size rte_memcpy app/test-eventdev: replace use of fixed size rte_memcpy app/test: replace use of fixed size rte_memcpy app/test-pipeline: remove unused rte_memcpy.h include app/test-bbdev: remove unnecessary include of rte_memcpy.h examples: replace use of fixed size rte_memcpy app/graph/neigh.c | 8 +- app/test-bbdev/test_bbdev.c | 1 - app/test-eventdev/test_pipeline_common.c | 19 ++- app/test-pipeline/config.c | 1 - app/test-pipeline/init.c | 1 - app/test-pipeline/main.c | 1 - app/test-pipeline/runtime.c | 1 - app/test-pmd/cmdline.c | 48 ++++---- app/test-pmd/cmdline_flow.c | 24 ++-- app/test-pmd/config.c | 8 +- app/test-pmd/csumonly.c | 1 - app/test-pmd/flowgen.c | 1 - app/test-pmd/iofwd.c | 1 - app/test-pmd/macfwd.c | 1 - app/test-pmd/macswap.c | 1 - app/test-pmd/noisy_vnf.c | 1 - app/test-pmd/rxonly.c | 1 - app/test-pmd/testpmd.c | 1 - app/test/commands.c | 1 - app/test/packet_burst_generator.c | 4 +- app/test/test_crc.c | 5 +- app/test/test_cryptodev.c | 18 ++- app/test/test_cryptodev_asym.c | 1 - app/test/test_cryptodev_security_pdcp.c | 1 - app/test/test_efd.c | 1 - app/test/test_efd_perf.c | 1 - app/test/test_event_crypto_adapter.c | 12 +- app/test/test_event_dma_adapter.c | 4 +- app/test/test_eventdev.c | 1 - app/test/test_ipsec.c | 6 +- app/test/test_link_bonding_mode4.c | 8 +- app/test/test_mbuf.c | 1 - app/test/test_member.c | 1 - app/test/test_member_perf.c | 1 - app/test/test_rawdev.c | 1 - app/test/test_security_inline_proto.c | 36 +++--- app/test/test_service_cores.c | 1 - app/test/virtual_pmd.c | 3 +- devtools/cocci/rte_memcpy.cocci | 11 ++ drivers/baseband/acc/rte_acc100_pmd.c | 17 ++- drivers/baseband/acc/rte_vrb_pmd.c | 21 ++-- drivers/baseband/la12xx/bbdev_la12xx.c | 4 +- drivers/bus/auxiliary/linux/auxiliary.c | 1 - drivers/bus/fslmc/fslmc_bus.c | 1 - drivers/bus/fslmc/fslmc_vfio.c | 1 - drivers/bus/fslmc/portal/dpaa2_hw_dpbp.c | 1 - drivers/bus/fslmc/portal/dpaa2_hw_dpci.c | 1 - drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 1 - drivers/bus/pci/linux/pci.c | 1 - drivers/common/idpf/idpf_common_device.c | 4 +- drivers/common/idpf/idpf_common_virtchnl.c | 10 +- drivers/common/qat/qat_qp.c | 10 +- drivers/compress/qat/qat_comp.c | 8 +- drivers/crypto/ccp/ccp_crypto.c | 14 +-- drivers/crypto/cnxk/cnxk_cryptodev_ops.c | 2 +- drivers/crypto/cnxk/cnxk_se.h | 2 +- drivers/crypto/dpaa_sec/dpaa_sec.c | 2 +- drivers/crypto/ipsec_mb/pmd_snow3g.c | 4 +- drivers/crypto/qat/qat_sym_session.c | 52 ++++----- .../scheduler/rte_cryptodev_scheduler.c | 6 +- drivers/crypto/scheduler/scheduler_failover.c | 12 +- drivers/event/cnxk/cnxk_eventdev_selftest.c | 1 - drivers/event/cnxk/cnxk_tim_evdev.c | 4 +- drivers/event/dlb2/dlb2.c | 4 +- drivers/event/dpaa/dpaa_eventdev.c | 1 - drivers/event/dpaa2/dpaa2_eventdev.c | 7 +- drivers/event/dpaa2/dpaa2_eventdev_selftest.c | 1 - drivers/event/dpaa2/dpaa2_hw_dpcon.c | 1 - drivers/event/octeontx/ssovf_evdev_selftest.c | 1 - drivers/event/octeontx/timvf_evdev.c | 4 +- drivers/mempool/dpaa/dpaa_mempool.c | 4 +- drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 5 +- drivers/ml/cnxk/cn10k_ml_model.c | 8 +- drivers/ml/cnxk/cn10k_ml_ops.c | 11 +- drivers/ml/cnxk/cnxk_ml_ops.c | 2 +- drivers/ml/cnxk/mvtvm_ml_model.c | 8 +- drivers/ml/cnxk/mvtvm_ml_ops.c | 8 +- drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +- drivers/net/avp/avp_ethdev.c | 4 +- drivers/net/axgbe/axgbe_ethdev.c | 4 +- drivers/net/bnx2x/bnx2x.c | 32 +++-- drivers/net/bnxt/bnxt_flow.c | 34 +++--- drivers/net/bonding/rte_eth_bond_8023ad.c | 4 +- drivers/net/bonding/rte_eth_bond_flow.c | 2 +- drivers/net/cnxk/cnxk_eswitch_devargs.c | 3 +- drivers/net/cnxk/cnxk_ethdev_ops.c | 2 +- drivers/net/cnxk/cnxk_rep.c | 3 +- drivers/net/cnxk/cnxk_rep_flow.c | 6 +- drivers/net/cnxk/cnxk_rep_msg.c | 8 +- drivers/net/cnxk/cnxk_rep_ops.c | 2 +- drivers/net/cnxk/cnxk_tm.c | 5 +- drivers/net/cpfl/cpfl_ethdev.c | 3 +- drivers/net/cpfl/cpfl_vchnl.c | 4 +- drivers/net/cxgbe/clip_tbl.c | 2 +- drivers/net/cxgbe/cxgbe_filter.c | 8 +- drivers/net/cxgbe/l2t.c | 4 +- drivers/net/cxgbe/smt.c | 20 ++-- drivers/net/dpaa2/base/dpaa2_hw_dpni.c | 1 - drivers/net/dpaa2/dpaa2_ethdev.c | 1 - drivers/net/dpaa2/dpaa2_recycle.c | 1 - drivers/net/dpaa2/dpaa2_rxtx.c | 1 - drivers/net/dpaa2/dpaa2_sparser.c | 1 - drivers/net/dpaa2/dpaa2_tm.c | 2 +- drivers/net/e1000/em_rxtx.c | 1 - drivers/net/e1000/igb_flow.c | 22 ++-- drivers/net/e1000/igb_pf.c | 7 +- drivers/net/e1000/igb_rxtx.c | 1 - drivers/net/enic/enic_main.c | 8 +- drivers/net/failsafe/failsafe_ops.c | 6 +- drivers/net/gve/base/gve_adminq.c | 2 +- drivers/net/hinic/hinic_pmd_ethdev.c | 1 - drivers/net/hinic/hinic_pmd_flow.c | 40 +++---- drivers/net/hns3/hns3_fdir.c | 2 +- drivers/net/hns3/hns3_flow.c | 4 +- drivers/net/i40e/i40e_ethdev.c | 109 ++++++++---------- drivers/net/i40e/i40e_fdir.c | 28 +++-- drivers/net/i40e/i40e_flow.c | 56 +++++---- drivers/net/i40e/i40e_pf.c | 3 +- drivers/net/i40e/i40e_tm.c | 11 +- drivers/net/i40e/rte_pmd_i40e.c | 34 +++--- drivers/net/iavf/iavf_fdir.c | 93 +++++++-------- drivers/net/iavf/iavf_fsub.c | 50 ++++---- drivers/net/iavf/iavf_generic_flow.c | 2 +- drivers/net/iavf/iavf_tm.c | 11 +- drivers/net/iavf/iavf_vchnl.c | 9 +- drivers/net/ice/ice_dcf.c | 5 +- drivers/net/ice/ice_dcf_parent.c | 2 +- drivers/net/ice/ice_dcf_sched.c | 11 +- drivers/net/ice/ice_diagnose.c | 4 +- drivers/net/ice/ice_ethdev.c | 14 +-- drivers/net/ice/ice_fdir_filter.c | 37 +++--- drivers/net/ice/ice_generic_flow.c | 2 +- drivers/net/ice/ice_hash.c | 2 +- drivers/net/ice/ice_tm.c | 11 +- drivers/net/idpf/idpf_ethdev.c | 7 +- drivers/net/idpf/idpf_rxtx.c | 10 +- drivers/net/ipn3ke/ipn3ke_flow.c | 32 +++-- drivers/net/ipn3ke/ipn3ke_representor.c | 16 +-- drivers/net/ipn3ke/ipn3ke_tm.c | 6 +- drivers/net/ixgbe/ixgbe_ethdev.c | 9 +- drivers/net/ixgbe/ixgbe_fdir.c | 7 +- drivers/net/ixgbe/ixgbe_flow.c | 65 +++++------ drivers/net/ixgbe/ixgbe_ipsec.c | 8 +- drivers/net/ixgbe/ixgbe_pf.c | 5 +- drivers/net/ixgbe/ixgbe_tm.c | 11 +- drivers/net/ixgbe/rte_pmd_ixgbe.c | 4 +- drivers/net/memif/memif_socket.c | 4 +- drivers/net/mlx5/mlx5_devx.c | 4 +- drivers/net/mlx5/mlx5_flow.c | 38 +++--- drivers/net/mlx5/mlx5_flow_aso.c | 6 +- drivers/net/mlx5/mlx5_flow_hw.c | 27 ++--- drivers/net/mlx5/mlx5_rx.c | 6 +- drivers/net/mlx5/mlx5_rxtx_vec.c | 8 +- drivers/net/mvpp2/mrvl_tm.c | 2 +- drivers/net/netvsc/hn_ethdev.c | 1 - drivers/net/nfp/flower/nfp_conntrack.c | 2 +- drivers/net/nfp/flower/nfp_flower_flow.c | 16 +-- .../net/nfp/flower/nfp_flower_representor.c | 2 +- drivers/net/nfp/nfp_mtr.c | 10 +- drivers/net/ngbe/ngbe_pf.c | 4 +- drivers/net/null/rte_eth_null.c | 6 +- drivers/net/pcap/pcap_ethdev.c | 2 +- drivers/net/pcap/pcap_osdep_freebsd.c | 3 +- drivers/net/pcap/pcap_osdep_linux.c | 3 +- drivers/net/qede/qede_main.c | 2 +- drivers/net/ring/rte_eth_ring.c | 1 - drivers/net/sfc/sfc.c | 2 +- drivers/net/sfc/sfc_ef10_tx.c | 2 +- drivers/net/sfc/sfc_ethdev.c | 11 +- drivers/net/sfc/sfc_flow.c | 20 ++-- drivers/net/sfc/sfc_flow_rss.c | 2 +- drivers/net/sfc/sfc_mae.c | 2 +- drivers/net/sfc/sfc_rx.c | 2 +- drivers/net/sfc/sfc_tso.c | 2 +- drivers/net/sfc/sfc_tso.h | 9 +- drivers/net/tap/rte_eth_tap.c | 14 +-- drivers/net/txgbe/txgbe_ethdev.c | 9 +- drivers/net/txgbe/txgbe_fdir.c | 6 +- drivers/net/txgbe/txgbe_flow.c | 65 +++++------ drivers/net/txgbe/txgbe_ipsec.c | 8 +- drivers/net/txgbe/txgbe_pf.c | 5 +- drivers/net/txgbe/txgbe_tm.c | 11 +- drivers/net/vhost/rte_eth_vhost.c | 1 - drivers/net/virtio/virtio_ethdev.c | 1 - drivers/raw/ifpga/afu_pmd_he_hssi.c | 3 +- drivers/raw/ifpga/afu_pmd_he_lpbk.c | 3 +- drivers/raw/ifpga/afu_pmd_he_mem.c | 3 +- drivers/raw/ifpga/afu_pmd_n3000.c | 8 +- drivers/raw/ifpga/ifpga_rawdev.c | 11 +- drivers/raw/skeleton/skeleton_rawdev.c | 8 +- drivers/raw/skeleton/skeleton_rawdev_test.c | 1 - examples/bbdev_app/main.c | 2 +- examples/bond/main.c | 1 - examples/ip_fragmentation/main.c | 1 - examples/ip_reassembly/main.c | 1 - examples/ipv4_multicast/main.c | 1 - examples/l2fwd-cat/cat.c | 4 +- examples/l2fwd-jobstats/main.c | 1 - examples/l2fwd-keepalive/main.c | 1 - examples/l2fwd-macsec/main.c | 1 - examples/l2fwd/main.c | 1 - examples/l3fwd-power/main.c | 1 - examples/l3fwd/main.c | 1 - examples/link_status_interrupt/main.c | 1 - .../client_server_mp/mp_server/init.c | 1 - .../client_server_mp/mp_server/main.c | 1 - examples/multi_process/symmetric_mp/main.c | 1 - examples/ptpclient/ptpclient.c | 11 +- examples/qos_sched/app_thread.c | 1 - examples/qos_sched/main.c | 1 - examples/server_node_efd/efd_server/init.c | 1 - examples/server_node_efd/efd_server/main.c | 1 - examples/vhost/main.c | 6 +- examples/vmdq/main.c | 6 +- examples/vmdq_dcb/main.c | 15 +-- lib/cryptodev/rte_cryptodev.c | 2 +- lib/eal/common/eal_common_options.c | 7 +- lib/ethdev/rte_ethdev.c | 3 +- lib/ethdev/rte_flow.c | 5 +- lib/eventdev/rte_event_crypto_adapter.c | 2 +- lib/eventdev/rte_event_dma_adapter.c | 4 +- lib/eventdev/rte_event_timer_adapter.c | 2 +- lib/fib/trie.c | 2 +- lib/ip_frag/rte_ipv6_fragmentation.c | 4 +- lib/ip_frag/rte_ipv6_reassembly.c | 6 +- lib/lpm/rte_lpm6.c | 3 +- lib/net/rte_ether.c | 2 +- lib/node/ip6_lookup.c | 8 +- lib/pdcp/pdcp_process.c | 36 +++--- lib/pipeline/rte_table_action.c | 8 +- lib/rib/rte_rib6.h | 5 +- lib/security/rte_security.c | 4 +- 232 files changed, 886 insertions(+), 1045 deletions(-) create mode 100644 devtools/cocci/rte_memcpy.cocci