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 702B4A0C4E; Thu, 12 Aug 2021 15:19:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F30E641213; Thu, 12 Aug 2021 15:19:16 +0200 (CEST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id E785E40042 for ; Thu, 12 Aug 2021 15:19:15 +0200 (CEST) Received: by mail-pj1-f50.google.com with SMTP id u21-20020a17090a8915b02901782c36f543so15117686pjn.4 for ; Thu, 12 Aug 2021 06:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M/6WQKhhcHJZ8lH4P5Iti9nBeBhth8hCt890WgpnHJ8=; b=fiZEyWykKJkNHC6g3ugqMnUNXJU77kFDXuCd+wKcpiTJRaEzS1fuMQ8in3nDHJRdq+ m+sJhAH7+b1fsHLV1Cwi4a+yiOYPOHLgqhVDY+e7h/oABHYo2+OGTpfzzqm+MgHbcqAq vLeE22u0RqqcdANnoivJdcjjlHzuePPQDl5RyrQfVHfkYBdcwnTJDjAMPCiCgHCfbM/B mqX0s2jjPfvDyYM0by+9bMX2wFhvuq7eG09CwQkm0mTooD+MGBZkj4TyIDFRwsy7Rd9P 9+2JO5j3b/AwDdoURKO1e65ptnoApa0OKy+tfhOiB3eI/hDiHrJSXWoMV3ZffhxfU6iM Porw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M/6WQKhhcHJZ8lH4P5Iti9nBeBhth8hCt890WgpnHJ8=; b=jGwMnMrFbTRwmFQD9ORZoqc+54eDdpbyGQc4mCzAgEexlCfK8pXPZPaCogAV0ifni8 cb7FHcQ240e+kCN5ZPC8sxC1TxkDHVlB8muUdEUfRGHXx2AFVo18p7GtKQc5+7YaGxLz bz37xJG34o2UFOvpZehZhu89jkgsF5gf0Qru0+KO5hjCiYXi/tqftxRotCH2ZckYmgvm wL+VHMybB72yQX9Njk6D169t1Ub9cDHitlys+joL1fsDTAcBc5h7P317zRxd2EvIbEn7 DMYKMDNoL1CATEPLFC1Pu6qHb0OKxpS11xzxE+rEX/DxZBusE2695NshZu/20t8FIFsq sWZA== X-Gm-Message-State: AOAM531EmmA0J0au/lAeUmkGoKidxqUYKliLkGkL1G6jaTSkebk6n8eU gUE8JENPUmggRxyI6EhefWny1JuxwPs2qA== X-Google-Smtp-Source: ABdhPJwvYmk2dDLuh77t9Kc4NEwbQGm3cJGIHHaeoo9zQOX5WMr/78XoWh7YrQjATmtl1JqBzzeTaw== X-Received: by 2002:a17:902:e744:b029:12d:6479:83a3 with SMTP id p4-20020a170902e744b029012d647983a3mr3658099plf.30.1628774354841; Thu, 12 Aug 2021 06:19:14 -0700 (PDT) Received: from C02D70YZMD6R.bytedance.net ([139.177.225.227]) by smtp.gmail.com with ESMTPSA id x24sm10273416pjk.43.2021.08.12.06.19.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Aug 2021 06:19:14 -0700 (PDT) From: Zhihong Wang To: dev@dpdk.org, ferruh.yigit@intel.com, xiaoyun.li@intel.com, aman.deep.singh@intel.com, irusskikh@marvell.com, cchemparathy@tilera.com Cc: Zhihong Wang Date: Thu, 12 Aug 2021 21:18:59 +0800 Message-Id: <20210812131901.25665-3-wangzhihong.wzh@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210812131901.25665-1-wangzhihong.wzh@bytedance.com> References: <20210809062548.30187-1-wangzhihong.wzh@bytedance.com> <20210812131901.25665-1-wangzhihong.wzh@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 2/4] app/testpmd: use rte_ipv4_cksum in flowgen 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 Sender: "dev" Use the rte_ipv4_cksum API to replace local ip_sum implementation. Signed-off-by: Zhihong Wang --- app/test-pmd/flowgen.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/app/test-pmd/flowgen.c b/app/test-pmd/flowgen.c index f2e6255c36..96d0cc79df 100644 --- a/app/test-pmd/flowgen.c +++ b/app/test-pmd/flowgen.c @@ -53,28 +53,6 @@ static struct rte_ether_addr cfg_ether_dst = #define IP_DEFTTL 64 /* from RFC 1340. */ -/* Use this type to inform GCC that ip_sum violates aliasing rules. */ -typedef unaligned_uint16_t alias_int16_t __attribute__((__may_alias__)); - -static inline uint16_t -ip_sum(const alias_int16_t *hdr, int hdr_len) -{ - uint32_t sum = 0; - - while (hdr_len > 1) - { - sum += *hdr++; - if (sum & 0x80000000) - sum = (sum & 0xFFFF) + (sum >> 16); - hdr_len -= 2; - } - - while (sum >> 16) - sum = (sum & 0xFFFF) + (sum >> 16); - - return ~sum; -} - /* * Multi-flow generation mode. * @@ -160,8 +138,7 @@ pkt_burst_flow_gen(struct fwd_stream *fs) next_flow); ip_hdr->total_length = RTE_CPU_TO_BE_16(pkt_size - sizeof(*eth_hdr)); - ip_hdr->hdr_checksum = ip_sum((const alias_int16_t *)ip_hdr, - sizeof(*ip_hdr)); + ip_hdr->hdr_checksum = rte_ipv4_cksum(ip_hdr); /* Initialize UDP header. */ udp_hdr = (struct rte_udp_hdr *)(ip_hdr + 1); -- 2.11.0