Message ID | 1425450852-24837-1-git-send-email-xuelin.shi@freescale.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id E111E5683; Wed, 4 Mar 2015 08:23:14 +0100 (CET) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bn0109.outbound.protection.outlook.com [157.56.110.109]) by dpdk.org (Postfix) with ESMTP id 8206F11C5 for <dev@dpdk.org>; Wed, 4 Mar 2015 08:23:13 +0100 (CET) Received: from BN3PR0301CA0081.namprd03.prod.outlook.com (25.160.152.177) by BN1PR0301MB0675.namprd03.prod.outlook.com (25.160.171.24) with Microsoft SMTP Server (TLS) id 15.1.93.16; Wed, 4 Mar 2015 07:23:12 +0000 Received: from BN1AFFO11FD035.protection.gbl (2a01:111:f400:7c10::100) by BN3PR0301CA0081.outlook.office365.com (2a01:111:e400:401e::49) with Microsoft SMTP Server (TLS) id 15.1.99.9 via Frontend Transport; Wed, 4 Mar 2015 07:23:12 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1AFFO11FD035.mail.protection.outlook.com (10.58.52.159) with Microsoft SMTP Server (TLS) id 15.1.99.6 via Frontend Transport; Wed, 4 Mar 2015 07:23:11 +0000 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t247N98o001558; Wed, 4 Mar 2015 00:23:09 -0700 From: <xuelin.shi@freescale.com> To: <bruce.richardson@intel.com> Date: Wed, 4 Mar 2015 14:34:12 +0800 Message-ID: <1425450852-24837-1-git-send-email-xuelin.shi@freescale.com> X-Mailer: git-send-email 1.8.4 X-EOPAttributedMessage: 0 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=b29237@freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(86152002)(87936001)(47776003)(50986999)(85426001)(77156002)(62966003)(57986006)(6806004)(19580405001)(19580395003)(76506005)(36756003)(50466002)(50226001)(48376002)(110136001)(2351001)(229853001)(46102003)(92566002)(33646002)(77096005)(104016003)(86362001)(105606002)(106466001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR0301MB0675; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BN1PR0301MB0675; X-Microsoft-Antispam-PRVS: <BN1PR0301MB06751FF1BCA9466285077395EA1E0@BN1PR0301MB0675.namprd03.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006); SRVR:BN1PR0301MB0675; X-Forefront-PRVS: 0505147DDB X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:BN1PR0301MB0675; X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2015 07:23:11.2845 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0301MB0675 Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH] librte_lpm: define tbl entry reversely for big endian 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> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
xuelin.shi@freescale.com
March 4, 2015, 6:34 a.m. UTC
From: Xuelin Shi <xuelin.shi@freescale.com> This module uses type conversion between struct and int. Also truncation and comparison is used with this int. It is not safe for different endian arch. Add ifdef for big endian struct to fix this issue. Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com> --- lib/librte_lpm/rte_lpm.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Comments
On Wed, Mar 04, 2015 at 02:34:12PM +0800, xuelin.shi@freescale.com wrote: > From: Xuelin Shi <xuelin.shi@freescale.com> > > This module uses type conversion between struct and int. > Also truncation and comparison is used with this int. > It is not safe for different endian arch. > > Add ifdef for big endian struct to fix this issue. > > Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com> > --- > lib/librte_lpm/rte_lpm.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h > index 1af150c..08a2859 100644 > --- a/lib/librte_lpm/rte_lpm.h > +++ b/lib/librte_lpm/rte_lpm.h > @@ -96,6 +96,7 @@ extern "C" { > /** Bitmask used to indicate successful lookup */ > #define RTE_LPM_LOOKUP_SUCCESS 0x0100 > > +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN > /** @internal Tbl24 entry structure. */ > struct rte_lpm_tbl24_entry { > /* Stores Next hop or group index (i.e. gindex)into tbl8. */ > @@ -117,6 +118,24 @@ struct rte_lpm_tbl8_entry { > uint8_t valid_group :1; /**< Group validation flag. */ > uint8_t depth :6; /**< Rule depth. */ > }; > +#else > +struct rte_lpm_tbl24_entry { > + uint8_t depth :6; > + uint8_t ext_entry :1; > + uint8_t valid :1; Since endianness only refers to the order of bytes within a word, do the bitfields within the uint8_t really need to be swapped around too? /Bruce > + union { > + uint8_t tbl8_gindex; > + uint8_t next_hop; > + }; > +}; > + > +struct rte_lpm_tbl8_entry { > + uint8_t depth :6; > + uint8_t valid_group :1; > + uint8_t valid :1; > + uint8_t next_hop; > +}; > +#endif > > /** @internal Rule structure. */ > struct rte_lpm_rule { > -- > 1.9.1 >
Hi Bruce, Yes, it needs to swap the fields. The bit field is first identified as the uint8_t and then packed. Thanks, Shi xuelin > -----Original Message----- > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > Sent: Wednesday, March 04, 2015 18:48 > To: Shi Xuelin-B29237 > Cc: thomas.monjalon@6wind.com; dev@dpdk.org > Subject: Re: [PATCH] librte_lpm: define tbl entry reversely for big > endian > > On Wed, Mar 04, 2015 at 02:34:12PM +0800, xuelin.shi@freescale.com wrote: > > From: Xuelin Shi <xuelin.shi@freescale.com> > > > > This module uses type conversion between struct and int. > > Also truncation and comparison is used with this int. > > It is not safe for different endian arch. > > > > Add ifdef for big endian struct to fix this issue. > > > > Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com> > > --- > > lib/librte_lpm/rte_lpm.h | 19 +++++++++++++++++++ > > 1 file changed, 19 insertions(+) > > > > diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h index > > 1af150c..08a2859 100644 > > --- a/lib/librte_lpm/rte_lpm.h > > +++ b/lib/librte_lpm/rte_lpm.h > > @@ -96,6 +96,7 @@ extern "C" { > > /** Bitmask used to indicate successful lookup */ > > #define RTE_LPM_LOOKUP_SUCCESS 0x0100 > > > > +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN > > /** @internal Tbl24 entry structure. */ struct rte_lpm_tbl24_entry { > > /* Stores Next hop or group index (i.e. gindex)into tbl8. */ @@ > > -117,6 +118,24 @@ struct rte_lpm_tbl8_entry { > > uint8_t valid_group :1; /**< Group validation flag. */ > > uint8_t depth :6; /**< Rule depth. */ > > }; > > +#else > > +struct rte_lpm_tbl24_entry { > > + uint8_t depth :6; > > + uint8_t ext_entry :1; > > + uint8_t valid :1; > > Since endianness only refers to the order of bytes within a word, do the > bitfields within the uint8_t really need to be swapped around too? > > /Bruce > > > + union { > > + uint8_t tbl8_gindex; > > + uint8_t next_hop; > > + }; > > +}; > > + > > +struct rte_lpm_tbl8_entry { > > + uint8_t depth :6; > > + uint8_t valid_group :1; > > + uint8_t valid :1; > > + uint8_t next_hop; > > +}; > > +#endif > > > > /** @internal Rule structure. */ > > struct rte_lpm_rule { > > -- > > 1.9.1 > >
On Thu, Mar 05, 2015 at 02:12:12AM +0000, Xuelin Shi wrote: > Hi Bruce, > > Yes, it needs to swap the fields. The bit field is first identified as the uint8_t and then packed. > > Thanks, > Shi xuelin > Am I right in thinking that this patch set supercedes that for "lpm: use field access instead of type conversion" http://dpdk.org/dev/patchwork/patch/3132/ ? > > -----Original Message----- > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > Sent: Wednesday, March 04, 2015 18:48 > > To: Shi Xuelin-B29237 > > Cc: thomas.monjalon@6wind.com; dev@dpdk.org > > Subject: Re: [PATCH] librte_lpm: define tbl entry reversely for big > > endian > > > > On Wed, Mar 04, 2015 at 02:34:12PM +0800, xuelin.shi@freescale.com wrote: > > > From: Xuelin Shi <xuelin.shi@freescale.com> > > > > > > This module uses type conversion between struct and int. > > > Also truncation and comparison is used with this int. > > > It is not safe for different endian arch. > > > > > > Add ifdef for big endian struct to fix this issue. > > > > > > Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com> > > > --- > > > lib/librte_lpm/rte_lpm.h | 19 +++++++++++++++++++ > > > 1 file changed, 19 insertions(+) > > > > > > diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h index > > > 1af150c..08a2859 100644 > > > --- a/lib/librte_lpm/rte_lpm.h > > > +++ b/lib/librte_lpm/rte_lpm.h > > > @@ -96,6 +96,7 @@ extern "C" { > > > /** Bitmask used to indicate successful lookup */ > > > #define RTE_LPM_LOOKUP_SUCCESS 0x0100 > > > > > > +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN > > > /** @internal Tbl24 entry structure. */ struct rte_lpm_tbl24_entry { > > > /* Stores Next hop or group index (i.e. gindex)into tbl8. */ @@ > > > -117,6 +118,24 @@ struct rte_lpm_tbl8_entry { > > > uint8_t valid_group :1; /**< Group validation flag. */ > > > uint8_t depth :6; /**< Rule depth. */ > > > }; > > > +#else > > > +struct rte_lpm_tbl24_entry { > > > + uint8_t depth :6; > > > + uint8_t ext_entry :1; > > > + uint8_t valid :1; > > > > Since endianness only refers to the order of bytes within a word, do the > > bitfields within the uint8_t really need to be swapped around too? > > > > /Bruce > > > > > > + union { > > > + uint8_t tbl8_gindex; > > > + uint8_t next_hop; > > > + }; > > > +}; > > > + > > > +struct rte_lpm_tbl8_entry { > > > + uint8_t depth :6; > > > + uint8_t valid_group :1; > > > + uint8_t valid :1; > > > + uint8_t next_hop; > > > +}; > > > +#endif > > > > > > /** @internal Rule structure. */ > > > struct rte_lpm_rule { > > > -- > > > 1.9.1 > > >
Hi Bruce, Yes, the patch http://dpdk.org/dev/patchwork/patch/3132/ should be abandoned. Thanks, Shi xuelin > -----Original Message----- > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > Sent: Friday, March 06, 2015 19:14 > To: Shi Xuelin-B29237 > Cc: thomas.monjalon@6wind.com; dev@dpdk.org > Subject: Re: [PATCH] librte_lpm: define tbl entry reversely for big > endian > > On Thu, Mar 05, 2015 at 02:12:12AM +0000, Xuelin Shi wrote: > > Hi Bruce, > > > > Yes, it needs to swap the fields. The bit field is first identified as > the uint8_t and then packed. > > > > Thanks, > > Shi xuelin > > > Am I right in thinking that this patch set supercedes that for > "lpm: use field access instead of type conversion" > http://dpdk.org/dev/patchwork/patch/3132/ ? > > > > -----Original Message----- > > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > > Sent: Wednesday, March 04, 2015 18:48 > > > To: Shi Xuelin-B29237 > > > Cc: thomas.monjalon@6wind.com; dev@dpdk.org > > > Subject: Re: [PATCH] librte_lpm: define tbl entry reversely for big > > > endian > > > > > > On Wed, Mar 04, 2015 at 02:34:12PM +0800, xuelin.shi@freescale.com > wrote: > > > > From: Xuelin Shi <xuelin.shi@freescale.com> > > > > > > > > This module uses type conversion between struct and int. > > > > Also truncation and comparison is used with this int. > > > > It is not safe for different endian arch. > > > > > > > > Add ifdef for big endian struct to fix this issue. > > > > > > > > Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com> > > > > --- > > > > lib/librte_lpm/rte_lpm.h | 19 +++++++++++++++++++ > > > > 1 file changed, 19 insertions(+) > > > > > > > > diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h > > > > index > > > > 1af150c..08a2859 100644 > > > > --- a/lib/librte_lpm/rte_lpm.h > > > > +++ b/lib/librte_lpm/rte_lpm.h > > > > @@ -96,6 +96,7 @@ extern "C" { > > > > /** Bitmask used to indicate successful lookup */ > > > > #define RTE_LPM_LOOKUP_SUCCESS 0x0100 > > > > > > > > +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN > > > > /** @internal Tbl24 entry structure. */ struct > rte_lpm_tbl24_entry { > > > > /* Stores Next hop or group index (i.e. gindex)into tbl8. */ > @@ > > > > -117,6 +118,24 @@ struct rte_lpm_tbl8_entry { > > > > uint8_t valid_group :1; /**< Group validation flag. */ > > > > uint8_t depth :6; /**< Rule depth. */ > > > > }; > > > > +#else > > > > +struct rte_lpm_tbl24_entry { > > > > + uint8_t depth :6; > > > > + uint8_t ext_entry :1; > > > > + uint8_t valid :1; > > > > > > Since endianness only refers to the order of bytes within a word, do > > > the bitfields within the uint8_t really need to be swapped around too? > > > > > > /Bruce > > > > > > > > > + union { > > > > + uint8_t tbl8_gindex; > > > > + uint8_t next_hop; > > > > + }; > > > > +}; > > > > + > > > > +struct rte_lpm_tbl8_entry { > > > > + uint8_t depth :6; > > > > + uint8_t valid_group :1; > > > > + uint8_t valid :1; > > > > + uint8_t next_hop; > > > > +}; > > > > +#endif > > > > > > > > /** @internal Rule structure. */ > > > > struct rte_lpm_rule { > > > > -- > > > > 1.9.1 > > > >
> -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xuelin Shi > Sent: Monday, March 9, 2015 1:54 AM > To: Richardson, Bruce > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] librte_lpm: define tbl entry reversely for > big endian > > Yes, the patch http://dpdk.org/dev/patchwork/patch/3132/ should be > abandoned. > Hi, If you register and login to the DPDK patchwork site you can mark the patch as "Not Applicable" or whatever category now applies. http://dpdk.org/dev/patchwork/user/login/ John
Hi, OK, done. Marked as "not applicable". Thanks, Shi > -----Original Message----- > From: Mcnamara, John [mailto:john.mcnamara@intel.com] > Sent: Monday, March 09, 2015 17:13 > To: Shi Xuelin-B29237; Richardson, Bruce > Cc: dev@dpdk.org > Subject: RE: [dpdk-dev] [PATCH] librte_lpm: define tbl entry reversely > for big endian > > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xuelin Shi > > Sent: Monday, March 9, 2015 1:54 AM > > To: Richardson, Bruce > > Cc: dev@dpdk.org > > Subject: Re: [dpdk-dev] [PATCH] librte_lpm: define tbl entry reversely > > for big endian > > > > Yes, the patch http://dpdk.org/dev/patchwork/patch/3132/ should be > > abandoned. > > > > Hi, > > If you register and login to the DPDK patchwork site you can mark the > patch as "Not Applicable" or whatever category now applies. > > http://dpdk.org/dev/patchwork/user/login/ > > John
On Wed, Mar 04, 2015 at 02:34:12PM +0800, xuelin.shi@freescale.com wrote: > From: Xuelin Shi <xuelin.shi@freescale.com> > > This module uses type conversion between struct and int. > Also truncation and comparison is used with this int. > It is not safe for different endian arch. > > Add ifdef for big endian struct to fix this issue. > > Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com> > --- > lib/librte_lpm/rte_lpm.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h > index 1af150c..08a2859 100644 > --- a/lib/librte_lpm/rte_lpm.h > +++ b/lib/librte_lpm/rte_lpm.h > @@ -96,6 +96,7 @@ extern "C" { > /** Bitmask used to indicate successful lookup */ > #define RTE_LPM_LOOKUP_SUCCESS 0x0100 > > +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN > /** @internal Tbl24 entry structure. */ > struct rte_lpm_tbl24_entry { > /* Stores Next hop or group index (i.e. gindex)into tbl8. */ > @@ -117,6 +118,24 @@ struct rte_lpm_tbl8_entry { > uint8_t valid_group :1; /**< Group validation flag. */ > uint8_t depth :6; /**< Rule depth. */ > }; > +#else > +struct rte_lpm_tbl24_entry { > + uint8_t depth :6; > + uint8_t ext_entry :1; > + uint8_t valid :1; > + union { > + uint8_t tbl8_gindex; > + uint8_t next_hop; > + }; > +}; > + > +struct rte_lpm_tbl8_entry { > + uint8_t depth :6; > + uint8_t valid_group :1; > + uint8_t valid :1; > + uint8_t next_hop; > +}; > +#endif > > /** @internal Rule structure. */ > struct rte_lpm_rule { > -- > 1.9.1 > Get an error compiling this up (using clang on FreeBSD). CC rte_lpm.o In file included from /usr/home/bruce/dpdk.org/lib/librte_lpm/rte_lpm.c:57: /usr/home/bruce/dpdk.org/lib/librte_lpm/rte_lpm.h:99:5: fatal error: 'RTE_BYTE_ORDER' is not defined, evaluates to 0 [-Wundef] #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN ^ 1 error generated. Adding "#include <rte_byteorder.h>" should fix the issue. Existing unit tests on IA (little endian) pass fine there-after, but I think for this patch it would be good to have an ack from someone who can validate on a big endian system, since this is what this patch is meant to enable. /Bruce
2015-03-09 09:12, Mcnamara, John: > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xuelin Shi > > Yes, the patch http://dpdk.org/dev/patchwork/patch/3132/ should be > > abandoned. > > If you register and login to the DPDK patchwork site you can mark the patch > as "Not Applicable" or whatever category now applies. > > http://dpdk.org/dev/patchwork/user/login/ "superseded" would be more appropriate here. Generally, "not applicable" should be used for emails which are not real patches or really wrongly formatted.
2015-03-09 14:02, Bruce Richardson: > On Wed, Mar 04, 2015 at 02:34:12PM +0800, xuelin.shi@freescale.com wrote: > > From: Xuelin Shi <xuelin.shi@freescale.com> > > > > This module uses type conversion between struct and int. > > Also truncation and comparison is used with this int. > > It is not safe for different endian arch. > > > > Add ifdef for big endian struct to fix this issue. > > > > Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com> > > Get an error compiling this up (using clang on FreeBSD). > > CC rte_lpm.o > In file included from /usr/home/bruce/dpdk.org/lib/librte_lpm/rte_lpm.c:57: > /usr/home/bruce/dpdk.org/lib/librte_lpm/rte_lpm.h:99:5: fatal error: 'RTE_BYTE_ORDER' is not defined, evaluates to 0 [-Wundef] > #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN > ^ > 1 error generated. > > Adding "#include <rte_byteorder.h>" should fix the issue. Please Xuelin, could you submit a v2? Thanks > Existing unit tests on IA (little endian) pass fine there-after, but I think for > this patch it would be good to have an ack from someone who can validate on > a big endian system, since this is what this patch is meant to enable. > > /Bruce >
Hi Thomas, Done. http://patchwork.dpdk.org/dev/patchwork/patch/4122/ Thanks, Xuelin Shi > -----Original Message----- > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > Sent: Monday, March 23, 2015 22:04 > To: Shi Xuelin-B29237 > Cc: Bruce Richardson; dev@dpdk.org > Subject: Re: [PATCH] librte_lpm: define tbl entry reversely for big > endian > > 2015-03-09 14:02, Bruce Richardson: > > On Wed, Mar 04, 2015 at 02:34:12PM +0800, xuelin.shi@freescale.com > wrote: > > > From: Xuelin Shi <xuelin.shi@freescale.com> > > > > > > This module uses type conversion between struct and int. > > > Also truncation and comparison is used with this int. > > > It is not safe for different endian arch. > > > > > > Add ifdef for big endian struct to fix this issue. > > > > > > Signed-off-by: Xuelin Shi <xuelin.shi@freescale.com> > > > > Get an error compiling this up (using clang on FreeBSD). > > > > CC rte_lpm.o > > In file included from > /usr/home/bruce/dpdk.org/lib/librte_lpm/rte_lpm.c:57: > > /usr/home/bruce/dpdk.org/lib/librte_lpm/rte_lpm.h:99:5: fatal error: > > 'RTE_BYTE_ORDER' is not defined, evaluates to 0 [-Wundef] #if > RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN > > ^ > > 1 error generated. > > > > Adding "#include <rte_byteorder.h>" should fix the issue. > > Please Xuelin, could you submit a v2? > Thanks > > > Existing unit tests on IA (little endian) pass fine there-after, but I > > think for this patch it would be good to have an ack from someone who > > can validate on a big endian system, since this is what this patch is > meant to enable. > > > > /Bruce > > >
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h index 1af150c..08a2859 100644 --- a/lib/librte_lpm/rte_lpm.h +++ b/lib/librte_lpm/rte_lpm.h @@ -96,6 +96,7 @@ extern "C" { /** Bitmask used to indicate successful lookup */ #define RTE_LPM_LOOKUP_SUCCESS 0x0100 +#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN /** @internal Tbl24 entry structure. */ struct rte_lpm_tbl24_entry { /* Stores Next hop or group index (i.e. gindex)into tbl8. */ @@ -117,6 +118,24 @@ struct rte_lpm_tbl8_entry { uint8_t valid_group :1; /**< Group validation flag. */ uint8_t depth :6; /**< Rule depth. */ }; +#else +struct rte_lpm_tbl24_entry { + uint8_t depth :6; + uint8_t ext_entry :1; + uint8_t valid :1; + union { + uint8_t tbl8_gindex; + uint8_t next_hop; + }; +}; + +struct rte_lpm_tbl8_entry { + uint8_t depth :6; + uint8_t valid_group :1; + uint8_t valid :1; + uint8_t next_hop; +}; +#endif /** @internal Rule structure. */ struct rte_lpm_rule {