From ac0ceab6e39da04d146b41a8a2828c7288941a00 Mon Sep 17 00:00:00 2001
From: Simon Horman <horms@verge.net.au>
Date: Tue, 2 Nov 2010 21:35:14 +0900
Subject: [PATCH] datapath: The definition of struct tbl is needed by
 rcu_dereference()

Due to the use of typeof(*p) by __rcu_dereference_check(),
which was introduced by the Linux changeset
ca5ecddfa8fcbd948c95530e7e817cee9fb43a3d
(rcu: define __rcu address space modifier for sparse) the definition
of the type of a the parameter to rcu_dereference() is needed.

In terms of the datapath, this means that the definition of
struct tbl needs to be available wherever rcu_dereference(dp->table)
is called.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Jesse Gross <jesse@nicira.com>
---
 datapath/table.c | 24 ------------------------
 datapath/table.h | 25 ++++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/datapath/table.c b/datapath/table.c
index 5ea2c93b4..61118090c 100644
--- a/datapath/table.c
+++ b/datapath/table.c
@@ -15,30 +15,6 @@
 #include <linux/mm.h>
 #include <asm/pgtable.h>
 
-/**
- * struct tbl - hash table
- * @n_buckets: number of buckets (a power of 2 between %TBL_L1_SIZE and
- * %TBL_MAX_BUCKETS)
- * @buckets: pointer to @n_buckets/%TBL_L1_SIZE pointers to %TBL_L1_SIZE pointers
- * to buckets
- * @rcu: RCU callback structure
- * @obj_destructor: Called on each element when the table is destroyed.
- *
- * The @buckets array is logically an array of pointers to buckets.  It is
- * broken into two levels to avoid the need to kmalloc() any object larger than
- * a single page or to use vmalloc().  @buckets is always nonnull, as is each
- * @buckets[i], but each @buckets[i][j] is nonnull only if the specified hash
- * bucket is nonempty (for 0 <= i < @n_buckets/%TBL_L1_SIZE, 0 <= j <
- * %TBL_L1_SIZE).
- */
-struct tbl {
-	struct rcu_head rcu;
-	unsigned int n_buckets;
-	struct tbl_bucket ***buckets;
-	unsigned int count;
-	void (*obj_destructor)(struct tbl_node *);
-};
-
 /**
  * struct tbl_bucket - single bucket within a hash table
  * @rcu: RCU callback structure
diff --git a/datapath/table.h b/datapath/table.h
index 9ae1ee322..dac57476a 100644
--- a/datapath/table.h
+++ b/datapath/table.h
@@ -9,13 +9,36 @@
 #ifndef TABLE_H
 #define TABLE_H 1
 
-struct tbl;
 struct tbl_bucket;
 
 struct tbl_node {
 	u32 hash;
 };
 
+/**
+ * struct tbl - hash table
+ * @n_buckets: number of buckets (a power of 2 between %TBL_L1_SIZE and
+ * %TBL_MAX_BUCKETS)
+ * @buckets: pointer to @n_buckets/%TBL_L1_SIZE pointers to %TBL_L1_SIZE pointers
+ * to buckets
+ * @rcu: RCU callback structure
+ * @obj_destructor: Called on each element when the table is destroyed.
+ *
+ * The @buckets array is logically an array of pointers to buckets.  It is
+ * broken into two levels to avoid the need to kmalloc() any object larger than
+ * a single page or to use vmalloc().  @buckets is always nonnull, as is each
+ * @buckets[i], but each @buckets[i][j] is nonnull only if the specified hash
+ * bucket is nonempty (for 0 <= i < @n_buckets/%TBL_L1_SIZE, 0 <= j <
+ * %TBL_L1_SIZE).
+ */
+struct tbl {
+	struct rcu_head rcu;
+	unsigned int n_buckets;
+	struct tbl_bucket ***buckets;
+	unsigned int count;
+	void (*obj_destructor)(struct tbl_node *);
+};
+
 #define TBL_L2_BITS (PAGE_SHIFT - ilog2(sizeof(struct tbl_bucket *)))
 #define TBL_L2_SIZE (1 << TBL_L2_BITS)
 #define TBL_L2_SHIFT 0
-- 
2.47.0