From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <michael.qiu@intel.com>
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id A7F328053
 for <dev@dpdk.org>; Fri, 12 Dec 2014 07:51:43 +0100 (CET)
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by fmsmga102.fm.intel.com with ESMTP; 11 Dec 2014 22:51:40 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.07,561,1413270000"; d="scan'208";a="636534547"
Received: from pgsmsx105.gar.corp.intel.com ([10.221.44.96])
 by fmsmga001.fm.intel.com with ESMTP; 11 Dec 2014 22:51:39 -0800
Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by
 pgsmsx105.gar.corp.intel.com (10.221.44.96) with Microsoft SMTP Server (TLS)
 id 14.3.195.1; Fri, 12 Dec 2014 14:49:25 +0800
Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by
 SHSMSX103.ccr.corp.intel.com ([169.254.4.240]) with mapi id 14.03.0195.001;
 Fri, 12 Dec 2014 14:49:18 +0800
From: "Qiu, Michael" <michael.qiu@intel.com>
To: r k <rkerur@gmail.com>, Thomas Monjalon <thomas.monjalon@6wind.com>
Thread-Topic: [dpdk-dev] [PATCH v3] test-pmd: Fix pointer aliasing error
Thread-Index: AQHQD8cg6//kKikCHUuP3ggaMBczHg==
Date: Fri, 12 Dec 2014 06:49:17 +0000
Message-ID: <533710CFB86FA344BFBF2D6802E60286C9F15E@SHSMSX101.ccr.corp.intel.com>
References: <1417663711-19576-1-git-send-email-michael.qiu@intel.com>
 <1417666564-19950-1-git-send-email-michael.qiu@intel.com>
 <533710CFB86FA344BFBF2D6802E60286C9D683@SHSMSX101.ccr.corp.intel.com>
 <1930269.B5nWyJ5DBl@xps13>
 <CAFb4SLCjnFpx0KGv3_zVG49vbhEnpS_GLhM7SQtvUs-s2Wmh3A@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [10.239.127.40]
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v3] test-pmd: Fix pointer aliasing error
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 12 Dec 2014 06:51:44 -0000

On 2014/12/12 1:51, r k wrote:
Thomas, Michael,

Wouldn't it cause unaligned memory access (new changes as well as the previ=
ous code)? Wondering if get_unaligned/put_unaligned macros similar to the o=
nes used in kernel be ported to user-space?


I think it will not, as all buf point to are struct udp_hdr/struct tcp_hdr/=
struct ipv6_psd_header/struct ipv4_psd_header, they are all aligned with ui=
nt16_t.

Thanks
Michael
Thanks,
Ravi

On Wed, Dec 10, 2014 at 4:54 PM, Thomas Monjalon <thomas.monjalon@6wind.com=
<mailto:thomas.monjalon@6wind.com>> wrote:
> > app/test-pmd/csumonly.c: In function =91get_psd_sum=92:
> > build/include/rte_ip.h:161: error: dereferencing pointer =91u16=92
> >         does break strict-aliasing rules
> > build/include/rte_ip.h:157: note: initialized from here
> >         ...
> >
> > The root cause is that, compile enable strict aliasing by default,
> > while in function rte_raw_cksum() try to convert 'const char *'
> > to 'const uint16_t *'.
> >
> > This patch is one workaround fix.
> >
> > Signed-off-by: Michael Qiu <michael.qiu@intel.com<mailto:michael.qiu@in=
tel.com>>
> > ---
> > v3 --> v2:
> >     use uintptr_t instead of unsigned long to
> >     save pointer.
> >
> > v2 --> v1:
> >     Workaround solution instead of shut off the
> >     gcc params.
>
> This workaround is to solve the compile issue of GCC strict-aliasing(Two
> different type pointers should not be point to the same memory address).
>
> For GCC 4.4.7 it will definitely occurs if  flags "-fstrict-aliasing"
> and "-Wall" used.

Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com<mailto:thomas.monjalon=
@6wind.com>>>

Applied with a comment in the code.

Thanks
--
Thomas