From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0140.outbound.protection.outlook.com [157.56.111.140]) by dpdk.org (Postfix) with ESMTP id EB4175A74 for ; Thu, 5 Mar 2015 03:12:15 +0100 (CET) Received: from CY1PR0301MB0684.namprd03.prod.outlook.com (25.160.158.155) by CY1PR0301MB0684.namprd03.prod.outlook.com (25.160.158.155) with Microsoft SMTP Server (TLS) id 15.1.99.14; Thu, 5 Mar 2015 02:12:12 +0000 Received: from CY1PR0301MB0684.namprd03.prod.outlook.com ([25.160.158.155]) by CY1PR0301MB0684.namprd03.prod.outlook.com ([25.160.158.155]) with mapi id 15.01.0099.004; Thu, 5 Mar 2015 02:12:12 +0000 From: Xuelin Shi To: Bruce Richardson Thread-Topic: [PATCH] librte_lpm: define tbl entry reversely for big endian Thread-Index: AQHQVkwTRHBXawDUCUCXZrIO3df0uZ0MJNaAgAEAhAA= Date: Thu, 5 Mar 2015 02:12:12 +0000 Message-ID: References: <1425450852-24837-1-git-send-email-xuelin.shi@freescale.com> <20150304104815.GF1468@bricha3-MOBL3> In-Reply-To: <20150304104815.GF1468@bricha3-MOBL3> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [123.151.195.51] authentication-results: intel.com; dkim=none (message not signed) header.d=none; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0684; x-forefront-antispam-report: BMV:0; SFV:NSPM; SFS:(10019020)(6009001)(13464003)(51704005)(164054003)(24454002)(99286002)(19580405001)(40100003)(19580395003)(74316001)(66066001)(86362001)(77156002)(46102003)(76576001)(92566002)(122556002)(2900100001)(2950100001)(87936001)(106116001)(2656002)(76176999)(102836002)(62966003)(33656002)(50986999)(54356999)(110136001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB0684; H:CY1PR0301MB0684.namprd03.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(5001007)(5005006); SRVR:CY1PR0301MB0684; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB0684; x-forefront-prvs: 05066DEDBB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Mar 2015 02:12:12.5261 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0684 Cc: "dev@dpdk.org" Subject: Re: [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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Mar 2015 02:12:16 -0000 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 >=20 > On Wed, Mar 04, 2015 at 02:34:12PM +0800, xuelin.shi@freescale.com wrote: > > From: Xuelin Shi > > > > 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 > > --- > > 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 =3D=3D 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; >=20 > 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? >=20 > /Bruce >=20 > > + 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 > >