[ovs-dev,2/6] netdev-vport: Use generic peer port name API for patch ports
diff mbox series

Message ID 20190402145712.7290-3-elibr@mellanox.com
State Rejected
Headers show
Series
  • Accelerate peer port forwarding by bypassing DP processing
Related show

Commit Message

Eli Britstein April 2, 2019, 2:57 p.m. UTC
Replace specific patch port API for retreiving peer port name with the
generic netdev API.

Signed-off-by: Eli Britstein <elibr@mellanox.com>
Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
---
 lib/netdev-vport.c     | 40 ++++++++++++++++------------------------
 lib/netdev-vport.h     |  2 --
 ofproto/ofproto-dpif.c |  6 +++---
 3 files changed, 19 insertions(+), 29 deletions(-)

Patch
diff mbox series

diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 808a43f99..14b3e5c82 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -964,30 +964,6 @@  get_tunnel_config(const struct netdev *dev, struct smap *args)
 
     return 0;
 }
-
-/* Code specific to patch ports. */
-
-/* If 'netdev' is a patch port, returns the name of its peer as a malloc()'d
- * string that the caller must free.
- *
- * If 'netdev' is not a patch port, returns NULL. */
-char *
-netdev_vport_patch_peer(const struct netdev *netdev_)
-{
-    char *peer = NULL;
-
-    if (netdev_vport_is_patch(netdev_)) {
-        struct netdev_vport *netdev = netdev_vport_cast(netdev_);
-
-        ovs_mutex_lock(&netdev->mutex);
-        if (netdev->peer) {
-            peer = xstrdup(netdev->peer);
-        }
-        ovs_mutex_unlock(&netdev->mutex);
-    }
-
-    return peer;
-}
 
 void
 netdev_vport_inc_rx(const struct netdev *netdev,
@@ -1067,6 +1043,21 @@  set_patch_config(struct netdev *dev_, const struct smap *args, char **errp)
     return 0;
 }
 
+static char *
+get_patch_peer_name(const struct netdev *netdev_)
+{
+    struct netdev_vport *netdev = netdev_vport_cast(netdev_);
+    char *peer = NULL;
+
+    ovs_mutex_lock(&netdev->mutex);
+    if (netdev->peer) {
+        peer = xstrdup(netdev->peer);
+    }
+    ovs_mutex_unlock(&netdev->mutex);
+
+    return peer;
+}
+
 static int
 netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats)
 {
@@ -1241,6 +1232,7 @@  netdev_vport_patch_register(void)
           .type = "patch",
           .get_config = get_patch_config,
           .set_config = set_patch_config,
+          .get_peer_name = get_patch_peer_name,
         },
         {{NULL, NULL, 0, 0}}
     };
diff --git a/lib/netdev-vport.h b/lib/netdev-vport.h
index 9d756a265..c60569971 100644
--- a/lib/netdev-vport.h
+++ b/lib/netdev-vport.h
@@ -32,8 +32,6 @@  void netdev_vport_patch_register(void);
 
 bool netdev_vport_is_patch(const struct netdev *);
 
-char *netdev_vport_patch_peer(const struct netdev *netdev);
-
 void netdev_vport_inc_rx(const struct netdev *,
                          const struct dpif_flow_stats *);
 void netdev_vport_inc_tx(const struct netdev *,
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index f0d387ccd..5eddc507c 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3526,7 +3526,7 @@  ofport_update_peer(struct ofport_dpif *ofport)
         ofport->peer = NULL;
     }
 
-    peer_name = netdev_vport_patch_peer(ofport->up.netdev);
+    peer_name = netdev_get_peer_name(ofport->up.netdev);
     if (!peer_name) {
         return;
     }
@@ -3547,7 +3547,7 @@  ofport_update_peer(struct ofport_dpif *ofport)
         }
 
         peer = ofport_dpif_cast(peer_ofport);
-        peer_peer = netdev_vport_patch_peer(peer->up.netdev);
+        peer_peer = netdev_get_peer_name(peer->up.netdev);
         if (peer_peer && !strcmp(netdev_get_name(ofport->up.netdev),
                                  peer_peer)) {
             ofport->peer = peer;
@@ -3777,7 +3777,7 @@  vport_get_status(const struct ofport *ofport_, char **errp)
         return 0;
     }
 
-    peer_name = netdev_vport_patch_peer(ofport->up.netdev);
+    peer_name = netdev_get_peer_name(ofport->up.netdev);
     if (!peer_name) {
         return 0;
     }