dpif implementation need callback data for flow lookup. This
patch does not change any functionality.

Signed-off-by: Pravin B Shelar <pshe...@nicira.com>
---
 lib/dpif-linux.c              |    2 +-
 lib/dpif-netdev.c             |   11 +++++++----
 lib/dpif-provider.h           |    4 +++-
 lib/dpif.c                    |   18 +++++++++++-------
 lib/dpif.h                    |    6 ++++--
 ofproto/ofproto-dpif-upcall.c |   12 ++++++++----
 ofproto/ofproto-dpif-upcall.h |    4 +++-
 ofproto/ofproto-dpif.c        |    6 ++++--
 utilities/ovs-dpctl.c         |    2 +-
 9 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index 779f764..7cab0c4 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -214,7 +214,7 @@ dpif_linux_enumerate(struct sset *all_dps)
 
 static int
 dpif_linux_open(const struct dpif_class *class OVS_UNUSED, const char *name,
-                bool create, struct dpif **dpifp)
+                bool create, void *handle_miss_data OVS_UNUSED, struct dpif 
**dpifp)
 {
     struct dpif_linux_dp dp_request, dp;
     struct ofpbuf *buf;
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 1fa4a3c..7b921b1 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -125,6 +125,8 @@ struct dp_netdev_queue {
 struct dp_netdev {
     const struct dpif_class *const class;
     const char *const name;
+    void *handle_miss_data;
+
     struct ovs_refcount ref_cnt;
     atomic_flag destroyed;
 
@@ -347,7 +349,7 @@ static int do_del_port(struct dp_netdev *dp, odp_port_t 
port_no)
 static void dp_netdev_destroy_all_queues(struct dp_netdev *dp)
     OVS_REQ_WRLOCK(dp->queue_rwlock);
 static int dpif_netdev_open(const struct dpif_class *, const char *name,
-                            bool create, struct dpif **);
+                            bool create, void *handle_miss_data, struct dpif 
**);
 static int dp_netdev_output_userspace(struct dp_netdev *dp, struct ofpbuf *,
                                       int queue_no, int type,
                                       const struct flow *,
@@ -463,7 +465,7 @@ choose_port(struct dp_netdev *dp, const char *name)
 
 static int
 create_dp_netdev(const char *name, const struct dpif_class *class,
-                 struct dp_netdev **dpp)
+                 void *handle_miss_data, struct dp_netdev **dpp)
     OVS_REQUIRES(dp_netdev_mutex)
 {
     struct dp_netdev *dp;
@@ -497,6 +499,7 @@ create_dp_netdev(const char *name, const struct dpif_class 
*class,
         dp_netdev_free(dp);
         return error;
     }
+    dp->handle_miss_data = handle_miss_data;
 
     *dpp = dp;
     return 0;
@@ -504,7 +507,7 @@ create_dp_netdev(const char *name, const struct dpif_class 
*class,
 
 static int
 dpif_netdev_open(const struct dpif_class *class, const char *name,
-                 bool create, struct dpif **dpifp)
+                 bool create, void *handle_miss_data, struct dpif **dpifp)
 {
     struct dp_netdev *dp;
     int error;
@@ -512,7 +515,7 @@ dpif_netdev_open(const struct dpif_class *class, const char 
*name,
     ovs_mutex_lock(&dp_netdev_mutex);
     dp = shash_find_data(&dp_netdevs, name);
     if (!dp) {
-        error = create ? create_dp_netdev(name, class, &dp) : ENODEV;
+        error = create ? create_dp_netdev(name, class, handle_miss_data, &dp) 
: ENODEV;
     } else {
         error = (dp->class != class ? EINVAL
                  : create ? EEXIST
diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
index 615f2c6..87ebd7a 100644
--- a/lib/dpif-provider.h
+++ b/lib/dpif-provider.h
@@ -92,6 +92,7 @@ struct dpif_class {
 
     /* Attempts to open an existing dpif called 'name', if 'create' is false,
      * or to open an existing dpif or create a new one, if 'create' is true.
+     * 'handle_miss_data' is passed to fn_ofproto_flow_lookup() callback 
function.
      *
      * 'dpif_class' is the class of dpif to open.
      *
@@ -99,7 +100,8 @@ struct dpif_class {
      * have class 'dpif_class'.  On failure there are no requirements on what
      * is stored in '*dpifp'. */
     int (*open)(const struct dpif_class *dpif_class,
-                const char *name, bool create, struct dpif **dpifp);
+                const char *name, bool create, void *handle_miss_data,
+                struct dpif **dpifp);
 
     /* Closes 'dpif' and frees associated memory. */
     void (*close)(struct dpif *dpif);
diff --git a/lib/dpif.c b/lib/dpif.c
index dc1e8c0..4fe02a6 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -309,7 +309,8 @@ dp_parse_name(const char *datapath_name_, char **name, char 
**type)
 }
 
 static int
-do_open(const char *name, const char *type, bool create, struct dpif **dpifp)
+do_open(const char *name, const char *type, bool create,
+        void *handle_miss_data, struct dpif **dpifp)
 {
     struct dpif *dpif = NULL;
     int error;
@@ -327,7 +328,8 @@ do_open(const char *name, const char *type, bool create, 
struct dpif **dpifp)
     }
 
     error = registered_class->dpif_class->open(registered_class->dpif_class,
-                                               name, create, &dpif);
+                                               name, create, handle_miss_data,
+                                               &dpif);
     if (!error) {
         ovs_assert(dpif->dpif_class == registered_class->dpif_class);
     } else {
@@ -347,7 +349,7 @@ exit:
 int
 dpif_open(const char *name, const char *type, struct dpif **dpifp)
 {
-    return do_open(name, type, false, dpifp);
+    return do_open(name, type, false, NULL, dpifp);
 }
 
 /* Tries to create and open a new datapath with the given 'name' and 'type'.
@@ -356,9 +358,10 @@ dpif_open(const char *name, const char *type, struct dpif 
**dpifp)
  * Returns 0 if successful, otherwise a positive errno value.  On success
  * stores a pointer to the datapath in '*dpifp', otherwise a null pointer. */
 int
-dpif_create(const char *name, const char *type, struct dpif **dpifp)
+dpif_create(const char *name, const char *type,
+            void *handle_miss_data, struct dpif **dpifp)
 {
-    return do_open(name, type, true, dpifp);
+    return do_open(name, type, true, handle_miss_data, dpifp);
 }
 
 /* Tries to open a datapath with the given 'name' and 'type', creating it if it
@@ -367,11 +370,12 @@ dpif_create(const char *name, const char *type, struct 
dpif **dpifp)
  * errno value. On success stores a pointer to the datapath in '*dpifp',
  * otherwise a null pointer. */
 int
-dpif_create_and_open(const char *name, const char *type, struct dpif **dpifp)
+dpif_create_and_open(const char *name, const char *type,
+                     void *handle_miss_data, struct dpif **dpifp)
 {
     int error;
 
-    error = dpif_create(name, type, dpifp);
+    error = dpif_create(name, type, handle_miss_data, dpifp);
     if (error == EEXIST || error == EBUSY) {
         error = dpif_open(name, type, dpifp);
         if (error) {
diff --git a/lib/dpif.h b/lib/dpif.h
index 7c6a241..fa22012 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -416,8 +416,10 @@ int dp_enumerate_names(const char *type, struct sset 
*names);
 void dp_parse_name(const char *datapath_name, char **name, char **type);
 
 int dpif_open(const char *name, const char *type, struct dpif **);
-int dpif_create(const char *name, const char *type, struct dpif **);
-int dpif_create_and_open(const char *name, const char *type, struct dpif **);
+int dpif_create(const char *name, const char *type,
+                void *handle_miss_data, struct dpif **);
+int dpif_create_and_open(const char *name, const char *type,
+                         void *handle_miss_data, struct dpif **);
 void dpif_close(struct dpif *);
 
 void dpif_run(struct dpif *);
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index b931ab6..95e4e86 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -243,11 +243,17 @@ static void ukey_delete(struct revalidator *, struct 
udpif_key *);
 
 static atomic_bool enable_megaflows = ATOMIC_VAR_INIT(true);
 
+
 struct udpif *
-udpif_create(struct dpif_backer *backer, struct dpif *dpif)
+udpif_alloc(void)
+{
+    return xzalloc(sizeof(struct udpif));
+}
+
+void
+udpif_init(struct udpif *udpif, struct dpif_backer *backer, struct dpif *dpif)
 {
     static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
-    struct udpif *udpif = xzalloc(sizeof *udpif);
 
     if (ovsthread_once_start(&once)) {
         unixctl_command_register("upcall/show", "", 0, 0, upcall_unixctl_show,
@@ -272,8 +278,6 @@ udpif_create(struct dpif_backer *backer, struct dpif *dpif)
     atomic_init(&udpif->n_flows, 0);
     atomic_init(&udpif->n_flows_timestamp, LLONG_MIN);
     ovs_mutex_init(&udpif->n_flows_mutex);
-
-    return udpif;
 }
 
 void
diff --git a/ofproto/ofproto-dpif-upcall.h b/ofproto/ofproto-dpif-upcall.h
index 6846f87..23e8fc7 100644
--- a/ofproto/ofproto-dpif-upcall.h
+++ b/ofproto/ofproto-dpif-upcall.h
@@ -25,8 +25,10 @@ struct simap;
 /* Udif is responsible for retrieving upcalls from the kernel and processing
  * them.  Additionally, it's responsible for maintaining the datapath flow
  * table. */
+struct udpif *udpif_alloc(void);
+void udpif_init(struct udpif *udpif,
+                struct dpif_backer *backer, struct dpif *dpif);
 
-struct udpif *udpif_create(struct dpif_backer *, struct dpif *);
 void udpif_set_threads(struct udpif *, size_t n_handlers,
                        size_t n_revalidators);
 void udpif_synchronize(struct udpif *);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 87a61f7..e42255f 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -843,8 +843,9 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
     sset_destroy(&names);
 
     backer = xmalloc(sizeof *backer);
+    backer->udpif = udpif_alloc();
 
-    error = dpif_create_and_open(backer_name, type, &backer->dpif);
+    error = dpif_create_and_open(backer_name, type, backer->udpif, 
&backer->dpif);
     free(backer_name);
     if (error) {
         VLOG_ERR("failed to open datapath of type %s: %s", type,
@@ -852,7 +853,8 @@ open_dpif_backer(const char *type, struct dpif_backer 
**backerp)
         free(backer);
         return error;
     }
-    backer->udpif = udpif_create(backer, backer->dpif);
+
+    udpif_init(backer->udpif, backer, backer->dpif);
 
     backer->type = xstrdup(type);
     backer->refcount = 1;
diff --git a/utilities/ovs-dpctl.c b/utilities/ovs-dpctl.c
index 4b00118..ad43803 100644
--- a/utilities/ovs-dpctl.c
+++ b/utilities/ovs-dpctl.c
@@ -267,7 +267,7 @@ parsed_dpif_open(const char *arg_, bool create, struct dpif 
**dpifp)
     dp_parse_name(arg_, &name, &type);
 
     if (create) {
-        result = dpif_create(name, type, dpifp);
+        result = dpif_create(name, type, NULL, dpifp);
     } else {
         result = dpif_open(name, type, dpifp);
     }
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to