lib: Expose struct ovs_list definition in <openvswitch/list.h>
authorThomas Graf <tgraf@noironetworks.com>
Mon, 15 Dec 2014 13:10:38 +0000 (14:10 +0100)
committerThomas Graf <tgraf@noironetworks.com>
Mon, 15 Dec 2014 13:15:16 +0000 (14:15 +0100)
Expose the struct ovs_list definition in <openvswitch/list.h>. Keep the
list access API private for now.

Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Ben Pfaff <blp@nicira.com>
18 files changed:
include/openvswitch/automake.mk
include/openvswitch/list.h [new file with mode: 0644]
lib/guarded-list.h
lib/lacp.c
lib/list.h
lib/netdev-dpdk.c
lib/netdev-dummy.c
lib/ovs-thread.c
lib/process.c
lib/rculist.h
lib/rstp.c
lib/rtbsd.c
lib/stp.c
lib/vlog.c
lib/vlog.h
ofproto/ofproto-dpif-monitor.c
ofproto/ofproto-dpif-upcall.c
ofproto/ofproto.c

index 7e225bb..0b95a0f 100644 (file)
@@ -1,6 +1,7 @@
 openvswitchincludedir = $(includedir)/openvswitch
 openvswitchinclude_HEADERS = \
        include/openvswitch/compiler.h \
+       include/openvswitch/list.h \
        include/openvswitch/thread.h \
        include/openvswitch/token-bucket.h \
        include/openvswitch/types.h \
diff --git a/include/openvswitch/list.h b/include/openvswitch/list.h
new file mode 100644 (file)
index 0000000..e2b97c6
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2013 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef OPENVSWITCH_LIST_H
+#define OPENVSWITCH_LIST_H 1
+
+/* Doubly linked list head or element. */
+struct ovs_list {
+    struct ovs_list *prev;     /* Previous list element. */
+    struct ovs_list *next;     /* Next list element. */
+};
+
+#define OVS_LIST_INITIALIZER(LIST) { LIST, LIST }
+
+#endif /* list.h */
index c19f64e..3e46d51 100644 (file)
@@ -28,9 +28,9 @@ struct guarded_list {
     size_t n;
 };
 
-#define GUARDED_LIST_INITIALIZER(LIST) { \
+#define GUARDED_OVS_LIST_INITIALIZER(LIST) { \
     .mutex = OVS_MUTEX_INITIALIZER, \
-    .list = LIST_INITIALIZER(&((LIST)->list)), \
+    .list = OVS_LIST_INITIALIZER(&((LIST)->list)), \
     .n = 0 }
 
 void guarded_list_init(struct guarded_list *);
index 46d5bfb..cc1a582 100644 (file)
@@ -132,7 +132,7 @@ struct slave {
 };
 
 static struct ovs_mutex mutex;
-static struct ovs_list all_lacps__ = LIST_INITIALIZER(&all_lacps__);
+static struct ovs_list all_lacps__ = OVS_LIST_INITIALIZER(&all_lacps__);
 static struct ovs_list *const all_lacps OVS_GUARDED_BY(mutex) = &all_lacps__;
 
 static void lacp_update_attached(struct lacp *) OVS_REQUIRES(mutex);
index f2aa335..15be0f8 100644 (file)
 #include <stdbool.h>
 #include <stddef.h>
 #include "util.h"
-
-/* Doubly linked list head or element. */
-struct ovs_list {
-    struct ovs_list *prev;     /* Previous list element. */
-    struct ovs_list *next;     /* Next list element. */
-};
-
-#define LIST_INITIALIZER(LIST) { LIST, LIST }
+#include "openvswitch/list.h"
 
 static inline void list_init(struct ovs_list *);
 static inline void list_poison(struct ovs_list *);
index 53fdb8e..4e2d281 100644 (file)
@@ -135,10 +135,10 @@ static struct ovs_mutex dpdk_mutex = OVS_MUTEX_INITIALIZER;
 
 /* Contains all 'struct dpdk_dev's. */
 static struct ovs_list dpdk_list OVS_GUARDED_BY(dpdk_mutex)
-    = LIST_INITIALIZER(&dpdk_list);
+    = OVS_LIST_INITIALIZER(&dpdk_list);
 
 static struct ovs_list dpdk_mp_list OVS_GUARDED_BY(dpdk_mutex)
-    = LIST_INITIALIZER(&dpdk_mp_list);
+    = OVS_LIST_INITIALIZER(&dpdk_mp_list);
 
 /* This mutex must be used by non pmd threads when allocating or freeing
  * mbufs through mempools. Since dpdk_queue_pkts() and dpdk_queue_flush() may
@@ -168,7 +168,7 @@ struct dpdk_tx_queue {
 */
 
 static struct ovs_list dpdk_ring_list OVS_GUARDED_BY(dpdk_mutex)
-    = LIST_INITIALIZER(&dpdk_ring_list);
+    = OVS_LIST_INITIALIZER(&dpdk_ring_list);
 
 struct dpdk_ring {
     /* For the client rings */
index b794b10..01ee928 100644 (file)
@@ -88,7 +88,7 @@ static struct ovs_mutex dummy_list_mutex = OVS_MUTEX_INITIALIZER;
 
 /* Contains all 'struct dummy_dev's. */
 static struct ovs_list dummy_list OVS_GUARDED_BY(dummy_list_mutex)
-    = LIST_INITIALIZER(&dummy_list);
+    = OVS_LIST_INITIALIZER(&dummy_list);
 
 struct netdev_dummy {
     struct netdev up;
index 1f346b9..3dd0ed6 100644 (file)
@@ -621,14 +621,14 @@ static struct ovs_mutex key_mutex = OVS_MUTEX_INITIALIZER;
  * Together, 'inuse_keys' and 'free_keys' hold an ovsthread_key for every index
  * from 0 to n_keys - 1, inclusive. */
 static struct ovs_list inuse_keys OVS_GUARDED_BY(key_mutex)
-    = LIST_INITIALIZER(&inuse_keys);
+    = OVS_LIST_INITIALIZER(&inuse_keys);
 static struct ovs_list free_keys OVS_GUARDED_BY(key_mutex)
-    = LIST_INITIALIZER(&free_keys);
+    = OVS_LIST_INITIALIZER(&free_keys);
 static unsigned int n_keys OVS_GUARDED_BY(key_mutex);
 
 /* All existing struct ovsthread_key_slots. */
 static struct ovs_list slots_list OVS_GUARDED_BY(key_mutex)
-    = LIST_INITIALIZER(&slots_list);
+    = OVS_LIST_INITIALIZER(&slots_list);
 
 static void *
 clear_slot(struct ovsthread_key_slots *slots, unsigned int index)
index 93a99ab..f6b665e 100644 (file)
@@ -54,7 +54,7 @@ struct process {
 static int fds[2];
 
 /* All processes. */
-static struct ovs_list all_processes = LIST_INITIALIZER(&all_processes);
+static struct ovs_list all_processes = OVS_LIST_INITIALIZER(&all_processes);
 
 static void sigchld_handler(int signr OVS_UNUSED);
 
index 3a57956..f3c1475 100644 (file)
@@ -75,7 +75,7 @@ static inline const struct rculist *rculist_next(const struct rculist *);
 static inline struct rculist *rculist_next_protected(const struct rculist *);
 
 /* List initialization. */
-#define RCULIST_INITIALIZER(LIST) { LIST, OVSRCU_INITIALIZER(LIST) }
+#define RCUOVS_LIST_INITIALIZER(LIST) { LIST, OVSRCU_INITIALIZER(LIST) }
 
 static inline void rculist_init(struct rculist *list);
 static inline void rculist_poison(struct rculist *elem);
index 022fc3c..8a7891a 100644 (file)
@@ -50,7 +50,7 @@ VLOG_DEFINE_THIS_MODULE(rstp);
 
 struct ovs_mutex rstp_mutex = OVS_MUTEX_INITIALIZER;
 
-static struct ovs_list all_rstps__ = LIST_INITIALIZER(&all_rstps__);
+static struct ovs_list all_rstps__ = OVS_LIST_INITIALIZER(&all_rstps__);
 static struct ovs_list *const all_rstps OVS_GUARDED_BY(rstp_mutex) = &all_rstps__;
 
 /* Internal use only. */
index 46a0632..d33f64b 100644 (file)
@@ -38,7 +38,7 @@ static struct ovs_mutex rtbsd_mutex = OVS_MUTEX_INITIALIZER;
 static int notify_sock = -1;
 
 /* All registered notifiers. */
-static struct ovs_list all_notifiers = LIST_INITIALIZER(&all_notifiers);
+static struct ovs_list all_notifiers = OVS_LIST_INITIALIZER(&all_notifiers);
 
 static void rtbsd_report_change(const struct if_msghdr *)
     OVS_REQUIRES(rtbsd_mutex);
index 5854afa..9e02acc 100644 (file)
--- a/lib/stp.c
+++ b/lib/stp.c
@@ -150,7 +150,7 @@ struct stp {
 };
 
 static struct ovs_mutex mutex;
-static struct ovs_list all_stps__ = LIST_INITIALIZER(&all_stps__);
+static struct ovs_list all_stps__ = OVS_LIST_INITIALIZER(&all_stps__);
 static struct ovs_list *const all_stps OVS_GUARDED_BY(mutex) = &all_stps__;
 
 #define FOR_EACH_ENABLED_PORT(PORT, STP)                        \
index 639dc91..60ce3b4 100644 (file)
@@ -75,7 +75,7 @@ VLOG_LEVELS
 BUILD_ASSERT_DECL(LOG_LOCAL0 == (16 << 3));
 
 /* The log modules. */
-struct ovs_list vlog_modules = LIST_INITIALIZER(&vlog_modules);
+struct ovs_list vlog_modules = OVS_LIST_INITIALIZER(&vlog_modules);
 
 /* Protects the 'pattern' in all "struct facility"s, so that a race between
  * changing and reading the pattern does not cause an access to freed
index 41b0adc..a8f7b01 100644 (file)
@@ -281,7 +281,7 @@ void vlog_usage(void);
         extern struct vlog_module VLM_##MODULE;                         \
         struct vlog_module VLM_##MODULE =                               \
         {                                                               \
-            LIST_INITIALIZER(&VLM_##MODULE.list),                       \
+            OVS_LIST_INITIALIZER(&VLM_##MODULE.list),                       \
             #MODULE,                                        /* name */  \
             { VLL_INFO, VLL_INFO, VLL_INFO },             /* levels */  \
             VLL_INFO,                                  /* min_level */  \
index 94c6711..abe6793 100644 (file)
@@ -69,7 +69,7 @@ static struct heap monitor_heap;
 
 /* guarded-list for storing the mports that need to send bfd/cfm control
  * packet soon. */
-static struct guarded_list send_soon = GUARDED_LIST_INITIALIZER(&send_soon);
+static struct guarded_list send_soon = GUARDED_OVS_LIST_INITIALIZER(&send_soon);
 
 /* The monitor thread id. */
 static pthread_t monitor_tid;
index dc6c344..75a0e61 100644 (file)
@@ -237,7 +237,7 @@ struct ukey_op {
 };
 
 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
-static struct ovs_list all_udpifs = LIST_INITIALIZER(&all_udpifs);
+static struct ovs_list all_udpifs = OVS_LIST_INITIALIZER(&all_udpifs);
 
 static size_t recv_upcalls(struct handler *);
 static int process_upcall(struct udpif *, struct upcall *,
index 317d392..ab4918f 100644 (file)
@@ -4329,7 +4329,7 @@ modify_flows__(struct ofproto *ofproto, struct ofputil_flow_mod *fm,
                const struct flow_mod_requester *req)
     OVS_REQUIRES(ofproto_mutex)
 {
-    struct ovs_list dead_cookies = LIST_INITIALIZER(&dead_cookies);
+    struct ovs_list dead_cookies = OVS_LIST_INITIALIZER(&dead_cookies);
     enum nx_flow_update_event event;
     size_t i;
 
@@ -4510,7 +4510,7 @@ delete_flows__(const struct rule_collection *rules,
     OVS_REQUIRES(ofproto_mutex)
 {
     if (rules->n) {
-        struct ovs_list dead_cookies = LIST_INITIALIZER(&dead_cookies);
+        struct ovs_list dead_cookies = OVS_LIST_INITIALIZER(&dead_cookies);
         struct ofproto *ofproto = rules->rules[0]->ofproto;
         struct rule *rule, *next;
         size_t i;