[ovs-dev,1/6] netdev: Introduce peer port name as a netdevice class property
diff mbox series

Message ID 20190402145712.7290-2-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
Currently peer port is defined as a patch port property. However, peer
ports can be used as generic netdevice property to accelerate peer ports
forwarding. Introduce a generic method for retreiving peer port name.

Signed-off-by: Eli Britstein <elibr@mellanox.com>
Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
---
 lib/netdev-provider.h |  6 ++++++
 lib/netdev.c          | 13 +++++++++++++
 lib/netdev.h          |  1 +
 3 files changed, 20 insertions(+)

Patch
diff mbox series

diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index fb0c27e6e..967760fb3 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -775,6 +775,12 @@  struct netdev_class {
      * used to send and receive packets until a successful configuration is
      * applied. */
     int (*reconfigure)(struct netdev *netdev);
+
+    /* If the netdev class of 'netdev' supports peer option, returns the name
+     * of its peer as a malloc()'d string that the caller must free.
+     *
+     * If peer is not supported, returns NULL. */
+    char *(*get_peer_name)(const struct netdev *netdev);
 /* ## -------------------- ## */
 /* ## netdev_rxq Functions ## */
 /* ## -------------------- ## */
diff --git a/lib/netdev.c b/lib/netdev.c
index 7d7ecf6f0..c6b9c7e96 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -913,6 +913,19 @@  netdev_get_name(const struct netdev *netdev)
     return netdev->name;
 }
 
+char *
+netdev_get_peer_name(const struct netdev *netdev)
+{
+    const struct netdev_class *class = netdev->netdev_class;
+    char *peer = NULL;
+
+    if (class->get_peer_name) {
+        peer = class->get_peer_name(netdev);
+    }
+
+    return peer;
+}
+
 /* Retrieves the MTU of 'netdev'.  The MTU is the maximum size of transmitted
  * (and received) packets, in bytes, not including the hardware header; thus,
  * this is typically 1500 bytes for Ethernet devices.
diff --git a/lib/netdev.h b/lib/netdev.h
index d94817fb6..d65b1ffcf 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -170,6 +170,7 @@  int netdev_get_numa_id(const struct netdev *);
 
 /* Basic properties. */
 const char *netdev_get_name(const struct netdev *);
+char *netdev_get_peer_name(const struct netdev *);
 const char *netdev_get_type(const struct netdev *);
 const char *netdev_get_type_from_name(const char *);
 int netdev_get_mtu(const struct netdev *, int *mtup);