dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] librte_lpm: define tbl entry reversely for big endian
@ 2015-03-04  6:34 xuelin.shi-KZfg59tc24xl57MIdRCFDg
       [not found] ` <1425450852-24837-1-git-send-email-xuelin.shi-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: xuelin.shi-KZfg59tc24xl57MIdRCFDg @ 2015-03-04  6:34 UTC (permalink / raw)
  To: bruce.richardson-ral2JQCrhuEAvxtiuMwx3w; +Cc: dev-VfR2kkLFssw

From: Xuelin Shi <xuelin.shi-KZfg59tc24xl57MIdRCFDg@public.gmane.org>

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-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
 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;
+	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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-03-24  7:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-04  6:34 [PATCH] librte_lpm: define tbl entry reversely for big endian xuelin.shi-KZfg59tc24xl57MIdRCFDg
     [not found] ` <1425450852-24837-1-git-send-email-xuelin.shi-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-03-04 10:48   ` Bruce Richardson
2015-03-05  2:12     ` Xuelin Shi
     [not found]       ` <CY1PR0301MB0684CE6F8F332B4F7DD45089861F0-YrwGdl+PljnlCq1ddutYi5wN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2015-03-06 11:13         ` Bruce Richardson
2015-03-09  1:54           ` Xuelin Shi
     [not found]             ` <CY1PR0301MB0684F68641BAFBDBF80BCFB2861B0-YrwGdl+PljnlCq1ddutYi5wN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2015-03-09  9:12               ` Mcnamara, John
     [not found]                 ` <B27915DBBA3421428155699D51E4CFE2ECC24F-kPTMFJFq+rELt2AQoY/u9bfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-03-09  9:35                   ` Xuelin Shi
2015-03-09 14:04                   ` Thomas Monjalon
2015-03-09 14:02   ` Bruce Richardson
2015-03-23 14:03     ` Thomas Monjalon
2015-03-24  7:28       ` Xuelin Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).