From patchwork Fri Aug 13 08:05:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L5b+X5a6P?= X-Patchwork-Id: 96886 X-Patchwork-Delegate: ferruh.yigit@amd.com 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 518D5A0C4D; Fri, 13 Aug 2021 10:06:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 04AEA41249; Fri, 13 Aug 2021 10:06:04 +0200 (CEST) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id 8D16340140 for ; Fri, 13 Aug 2021 10:06:03 +0200 (CEST) Received: by mail-pj1-f46.google.com with SMTP id nt11so14207526pjb.2 for ; Fri, 13 Aug 2021 01:06:03 -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=4WkkGbrM9kTA3awyUAX53a5Faspeo7cNKAEaYZ117zk=; b=qL9pA4rxQqcj5LEO8BzTg+WGjPpcqmJEeAnO9CZgdfKsELEr7MhTIIxz3bYW/iwcDv F0EaM7yIWYdbOCX4yv/yY0i1WjDPQh3Ep1svjRXBJRXlV2EP6x26wo0IbJ6eCYksGV3u W27zyjs9vH4fWujXjNwnPs9flHI683q7g9PTX1qIl0bjiuettdI8EPE9QBGoSnruuhwm hK0wEO6idNLCO/sz50kTOuNaaUwtQ3c6uvnepIPs2EAoK9s/7QwcqP8hRbyoWvcGFusc TMuvkiOntbK+KSQNR5peC6SbxyGumsK2D7+yCx69pk8nvx5RBvx9OhhBbWoPieg/H2ZI HlLg== 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=4WkkGbrM9kTA3awyUAX53a5Faspeo7cNKAEaYZ117zk=; b=d7Y1LVMv/+DWZEKHZJzhDCMCLSEaK0HMMkYhLXhQev7rm1dII8Bn/ld9B+XM2LtCLU n69YzOgGQegf+jjxOSlkiAj6caONe9VJfT7QFwVQe6sgCknSu+o24rkTSEtL471pRpm1 L0ja93XjgPOtf1IXsny+JpeysDmqL1d0PkuHh2o6DjN8safkXUII2zW0r7cZzfa0KmyU tbAoQ6RQCPen4mQQj6e2f52aK4aG05h2NwPFSMLDtKOyUz9TRmWgQ3A+zZ8y8AjGHBdb eb6Y084o+0BNVc1xs/g5flB/msFG/aZzN9gJvxL5sgc963MQvWGvmTSmWVfViD1ziOK9 dGRA== X-Gm-Message-State: AOAM5327Y+ilYUuwYsCNKl3XbD7o58exuGBO84ba72VI0s2zp/82X/Hk omGbrp5jtfG8+H+tVIOKnVim5jZ0SIdtEQ== X-Google-Smtp-Source: ABdhPJxtytvHe1B1tfkmreck8jN0dmmdAN9wCiP4Wu00mL461OWDcuHiRWpLORFWYnLeyNtcZSwfrQ== X-Received: by 2002:a65:5186:: with SMTP id h6mr1293465pgq.62.1628841962481; Fri, 13 Aug 2021 01:06:02 -0700 (PDT) Received: from C02D70YZMD6R.bytedance.net ([139.177.225.227]) by smtp.gmail.com with ESMTPSA id 17sm1118192pjd.3.2021.08.13.01.05.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Aug 2021 01:06:01 -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: Fri, 13 Aug 2021 16:05:46 +0800 Message-Id: <20210813080548.38637-3-wangzhihong.wzh@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20210813080548.38637-1-wangzhihong.wzh@bytedance.com> References: <20210809062548.30187-1-wangzhihong.wzh@bytedance.com> <20210813080548.38637-1-wangzhihong.wzh@bytedance.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 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 Acked-by: Xiaoyun Li --- 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);