From patchwork Tue Mar 24 05:58:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xuelin.shi@freescale.com X-Patchwork-Id: 4122 Return-Path: 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 2A0A99AB7; Tue, 24 Mar 2015 07:48:24 +0100 (CET) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1on0110.outbound.protection.outlook.com [157.56.110.110]) by dpdk.org (Postfix) with ESMTP id 3B8D73B5 for ; Tue, 24 Mar 2015 07:48:22 +0100 (CET) Received: from BN3PR0301CA0057.namprd03.prod.outlook.com (25.160.152.153) by BLUPR03MB1330.namprd03.prod.outlook.com (25.163.80.20) with Microsoft SMTP Server (TLS) id 15.1.118.21; Tue, 24 Mar 2015 06:48:20 +0000 Received: from BY2FFO11FD015.protection.gbl (2a01:111:f400:7c0c::170) by BN3PR0301CA0057.outlook.office365.com (2a01:111:e400:401e::25) with Microsoft SMTP Server (TLS) id 15.1.118.21 via Frontend Transport; Tue, 24 Mar 2015 06:48:20 +0000 Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD015.mail.protection.outlook.com (10.1.14.131) with Microsoft SMTP Server (TLS) id 15.1.125.13 via Frontend Transport; Tue, 24 Mar 2015 06:48:19 +0000 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t2O6mGNN012922; Mon, 23 Mar 2015 23:48:17 -0700 From: To: Date: Tue, 24 Mar 2015 13:58:20 +0800 Message-ID: <1427176700-3911-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.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=b29237@freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(189002)(199003)(110136001)(86362001)(106466001)(50986999)(77096005)(36756003)(105606002)(77156002)(62966003)(2351001)(48376002)(229853001)(33646002)(50466002)(86152002)(87936001)(50226001)(85426001)(76506005)(104016003)(19580405001)(6806004)(47776003)(46102003)(57986006)(19580395003)(92566002); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR03MB1330; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1330; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(5002010); SRVR:BLUPR03MB1330; BCL:0; PCL:0; RULEID:; SRVR:BLUPR03MB1330; X-Forefront-PRVS: 0525BB0ADF X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2015 06:48:19.4035 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1330 Cc: dev@dpdk.org, Xuelin Shi Subject: [dpdk-dev] [PATCH v2] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 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 {