From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: [PATCH v2] librte_lpm: define tbl entry reversely for big endian Date: Tue, 19 May 2015 11:05:59 +0100 Message-ID: <20150519100559.GA11036@bricha3-MOBL3> References: <1427176700-3911-1-git-send-email-xuelin.shi@freescale.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org To: xuelin.shi@freescale.com Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 328B1C31A for ; Tue, 19 May 2015 12:06:03 +0200 (CEST) Content-Disposition: inline In-Reply-To: <1427176700-3911-1-git-send-email-xuelin.shi@freescale.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Mar 24, 2015 at 01:58:20PM +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 Since nobody objects to this patch, and it looks ok to me: Acked-by: Bruce Richardson > --- > changes for v2: > add > > lib/librte_lpm/rte_lpm.h | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h > index 1af150c..6cbcd4c 100644 > --- a/lib/librte_lpm/rte_lpm.h > +++ b/lib/librte_lpm/rte_lpm.h > @@ -44,6 +44,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -96,6 +97,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 +119,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 >