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 A5E88A00C4; Thu, 30 Jun 2022 19:45:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 589704069D; Thu, 30 Jun 2022 19:45:49 +0200 (CEST) Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mails.dpdk.org (Postfix) with ESMTP id C58FD4069D for ; Thu, 30 Jun 2022 19:45:48 +0200 (CEST) Received: by mail-pf1-f176.google.com with SMTP id 136so111359pfy.10 for ; Thu, 30 Jun 2022 10:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kL6fVdfFEjHSIzoa5iWdOXaHoyvBfoGH6znkBipphyg=; b=69yBjjmUyel1xoHIO4vvF43DoOyhbg+XHSBXlN5L9gRNgt/kGynDERuSEta7N7DEZA RKqnZVRrI1kKuJp4mpigpYCRYjSnatfxl4pWNJayczbzAE7uUTNVsWmJyW2Xvg2NUjqT JniJSDU7f/1tYGbVtkxGdi9hAttONSeCGa4AhOJPO3yIhUjPyNFc6YHXFhvrzNWa4C3c 6YNAqLX8nf4U3lTFLjsa8fQjFGgedt7LPsMyajRXP3Tj1EjOrfNhTMZWQvQzTg3t97O6 O70f7u3eF19x9h+7uZ/a7hYeK2tPTDYNYVz30UyLgfKSpwSYZxG1dntzMI7Mf2LtGj+m O+gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kL6fVdfFEjHSIzoa5iWdOXaHoyvBfoGH6znkBipphyg=; b=fFbyaZiYpfbLGAHhETYqASiB88cTzPVB/7vjFtlr5jczvm+Y0aBd+2bpiy9QP84Xxv P2mQLIpWqJqOb2gI9Y4R3iobdg5P8hAQ1Kva6EWnebkivkmupOX7eOs68/gf13gZ7JsB mn/w2usx4Fxpg94Dgo9DyxxDOdOZB5GAI1IpldMAAiCmJiSdjyIQ0yC7ZcTtXVcOooyO e3wZqFo7LDrSiGuFbIbYfvVpaGVE2ylzeWu9PY7cFdPvuL0H7PgYXSDNKPJC3D+6k/Sg RtEneuDBAoYeF6M6ujIoETTSrOwE8QIRz9yMcmmGGRn83pXCRRCQM3OdRveD32EvYSQL W/gw== X-Gm-Message-State: AJIora8fvAJBfnrJ6L6AoBXxJeW/vPL82emzmqqPLbyDkCVfYUY939rE iNvqKhxjUx1FEtR4m5MyJjPf0w== X-Google-Smtp-Source: AGRyM1tM51jyW9s8kgC95N2mc1NzY1PIEhVhcTWRaV8T1QvLXTY9X469iio+MEx+70cxQP1OzEfDXg== X-Received: by 2002:a65:6044:0:b0:3fc:674:8f5a with SMTP id a4-20020a656044000000b003fc06748f5amr8542311pgp.436.1656611147838; Thu, 30 Jun 2022 10:45:47 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id p26-20020a056a0026da00b005251e2b53acsm13805591pfw.116.2022.06.30.10.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 10:45:47 -0700 (PDT) Date: Thu, 30 Jun 2022 10:45:45 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: emil.berg@ericsson.com, bruce.richardson@intel.com, dev@dpdk.org, stable@dpdk.org, bugzilla@dpdk.org, hofors@lysator.liu.se, olivier.matz@6wind.com Subject: Re: [PATCH v4] net: fix checksum with unaligned buffer Message-ID: <20220630104545.55d4e870@hermes.local> In-Reply-To: <20220623123900.38283-1-mb@smartsharesystems.com> References: <98CBD80474FA8B44BF855DF32C47DC35D87139@smartserver.smartshare.dk> <20220623123900.38283-1-mb@smartsharesystems.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 On Thu, 23 Jun 2022 14:39:00 +0200 Morten Br=C3=B8rup wrote: > + /* if buffer is unaligned, keeping it byte order independent */ > + if (unlikely(unaligned)) { > + uint16_t first =3D 0; > + if (unlikely(len =3D=3D 0)) > + return 0; Why is length =3D=3D 0 unique to unaligned case? > + ((unsigned char *)&first)[1] =3D *(const unsigned char *)buf; Use a proper union instead of casting to avoid aliasing warnings. > + bsum +=3D first; > + buf =3D RTE_PTR_ADD(buf, 1); > + len--; > + } Many CPU's (such as x86) won't care about alignment and therefore the extra code to handle this is not worth doing. Perhaps DPDK needs a macro (like Linux kernel) for efficient unaligned acce= ss. In Linux kernel it is CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS