[ovs-dev] [PATCH 2/2] dpif: Change get_max_ports() to return uint32_t.

Alex Wang alexw at nicira.com
Thu Aug 22 21:24:18 UTC 2013


The declaration of 'get_max_ports()' to return odp_port_t adds
unwanted complexity to coding.  This commit changes it back to
return uint32_t type.

Signed-off-by: Alex Wang <alexw at nicira.com>
---
 lib/dpif-linux.c       |    4 ++--
 lib/dpif-netdev.c      |    4 ++--
 lib/dpif-provider.h    |    2 +-
 lib/dpif.c             |    2 +-
 lib/dpif.h             |    2 +-
 ofproto/ofproto-dpif.c |    5 ++---
 6 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index a95ece1..ca5f496 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -655,10 +655,10 @@ dpif_linux_port_query_by_name(const struct dpif *dpif, const char *devname,
     return dpif_linux_port_query__(dpif, 0, devname, dpif_port);
 }
 
-static odp_port_t
+static uint32_t
 dpif_linux_get_max_ports(const struct dpif *dpif OVS_UNUSED)
 {
-    return u32_to_odp(MAX_PORTS);
+    return MAX_PORTS;
 }
 
 static uint32_t
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 8f79128..46eb743 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -608,10 +608,10 @@ dpif_netdev_port_query_by_name(const struct dpif *dpif, const char *devname,
     return error;
 }
 
-static odp_port_t
+static uint32_t
 dpif_netdev_get_max_ports(const struct dpif *dpif OVS_UNUSED)
 {
-    return u32_to_odp(MAX_PORTS);
+    return MAX_PORTS;
 }
 
 static void
diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
index d6315ed..1afac99 100644
--- a/lib/dpif-provider.h
+++ b/lib/dpif-provider.h
@@ -146,7 +146,7 @@ struct dpif_class {
 
     /* Returns one greater than the largest port number accepted in flow
      * actions. */
-    odp_port_t (*get_max_ports)(const struct dpif *dpif);
+    uint32_t (*get_max_ports)(const struct dpif *dpif);
 
     /* Returns the Netlink PID value to supply in OVS_ACTION_ATTR_USERSPACE
      * actions as the OVS_USERSPACE_ATTR_PID attribute's value, for use in
diff --git a/lib/dpif.c b/lib/dpif.c
index ae4da62..02cc36a 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -634,7 +634,7 @@ dpif_port_query_by_name(const struct dpif *dpif, const char *devname,
 
 /* Returns one greater than the maximum port number accepted in flow
  * actions. */
-odp_port_t
+uint32_t
 dpif_get_max_ports(const struct dpif *dpif)
 {
     return dpif->dpif_class->get_max_ports(dpif);
diff --git a/lib/dpif.h b/lib/dpif.h
index d028085..7a258c7 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -415,7 +415,7 @@ int dpif_port_query_by_name(const struct dpif *, const char *devname,
                             struct dpif_port *);
 int dpif_port_get_name(struct dpif *, odp_port_t port_no,
                        char *name, size_t name_size);
-odp_port_t dpif_get_max_ports(const struct dpif *);
+uint32_t dpif_get_max_ports(const struct dpif *);
 uint32_t dpif_port_get_pid(const struct dpif *, odp_port_t port_no);
 
 struct dpif_port_dump {
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 6b2bd22..601806e 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1248,7 +1248,7 @@ construct(struct ofproto *ofproto_)
 {
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
     struct shash_node *node, *next;
-    odp_port_t max_ports;
+    uint32_t max_ports;
     int error;
 
     error = open_dpif_backer(ofproto->up.type, &ofproto->backer);
@@ -1257,8 +1257,7 @@ construct(struct ofproto *ofproto_)
     }
 
     max_ports = dpif_get_max_ports(ofproto->backer->dpif);
-    ofproto_init_max_ports(ofproto_, u16_to_ofp(MIN(odp_to_u32(max_ports),
-                                                    ofp_to_u16(OFPP_MAX))));
+    ofproto_init_max_ports(ofproto_, MIN(max_ports, ofp_to_u16(OFPP_MAX)));
 
     ofproto->netflow = NULL;
     ofproto->sflow = NULL;
-- 
1.7.9.5




More information about the dev mailing list