From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 1F98F568F for ; Fri, 6 Mar 2015 12:13:35 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 06 Mar 2015 03:10:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,352,1422950400"; d="scan'208";a="537015191" Received: from bricha3-mobl3.ger.corp.intel.com ([10.243.20.21]) by orsmga003.jf.intel.com with SMTP; 06 Mar 2015 03:13:19 -0800 Received: by (sSMTP sendmail emulation); Fri, 06 Mar 2015 11:13:32 +0025 Date: Fri, 6 Mar 2015 11:13:32 +0000 From: Bruce Richardson To: Xuelin Shi Message-ID: <20150306111332.GB9352@bricha3-MOBL3> References: <1425450852-24837-1-git-send-email-xuelin.shi@freescale.com> <20150304104815.GF1468@bricha3-MOBL3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) 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: Fri, 06 Mar 2015 11:13:36 -0000 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 > > > > > > 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 == 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 > > >