summaryrefslogtreecommitdiff
path: root/lib/librte_lpm
diff options
context:
space:
mode:
authorXuelin Shi <xuelin.shi@freescale.com>2015-03-24 13:58:20 +0800
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-07-10 23:23:15 +0200
commitafc5c914a08312a0c8030ce3c46f87beb35b8d40 (patch)
tree99c2998460c6159a16d91ae24a654d358e7a9303 /lib/librte_lpm
parent6db141c91e1f607025fc8d0fae613a97820101e9 (diff)
downloaddpdk-afc5c914a08312a0c8030ce3c46f87beb35b8d40.zip
dpdk-afc5c914a08312a0c8030ce3c46f87beb35b8d40.tar.gz
dpdk-afc5c914a08312a0c8030ce3c46f87beb35b8d40.tar.xz
lpm: fix big endian support
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> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'lib/librte_lpm')
-rw-r--r--lib/librte_lpm/rte_lpm.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h
index e318769..11f0c04 100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -44,6 +44,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <rte_branch_prediction.h>
+#include <rte_byteorder.h>
#include <rte_memory.h>
#include <rte_common.h>
#include <rte_vect.h>
@@ -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 {