[ovs-dev,5/6] ofproto-dpif: Introduce peer port netdev as a netdev property

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

Commit Message

Eli Britstein April 2, 2019, 2:57 p.m.
If a netdev has a peer port configured, keep the peer netdev handler in
the configured netdev, as a pre-step towards accelerating peer ports
forwarding.

Signed-off-by: Eli Britstein <elibr@mellanox.com>
Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
---
 lib/netdev-provider.h  | 1 +
 lib/netdev.c           | 5 +++++
 lib/netdev.h           | 1 +
 ofproto/ofproto-dpif.c | 2 ++
 4 files changed, 9 insertions(+)

Patch

diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index 967760fb3..18a1f2183 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -94,6 +94,7 @@  struct netdev {
     struct shash_node *node;            /* Pointer to element in global map. */
     struct ovs_list saved_flags_list; /* Contains "struct netdev_saved_flags". */
     struct netdev_hw_info hw_info;	/* offload-capable netdev info */
+    struct netdev *peer; /* peer netdev if exists */
 };
 
 static inline void
diff --git a/lib/netdev.c b/lib/netdev.c
index c6b9c7e96..577c87d55 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -926,6 +926,11 @@  netdev_get_peer_name(const struct netdev *netdev)
     return peer;
 }
 
+void netdev_set_peer_netdev(struct netdev *netdev, struct netdev *peer_netdev)
+{
+    netdev->peer = peer_netdev;
+}
+
 /* 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 d65b1ffcf..05e36c304 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -171,6 +171,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 *);
+void netdev_set_peer_netdev(struct netdev *, 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);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index cad7f6dda..4ffb25b42 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3548,6 +3548,8 @@  ofport_update_peer(struct ofport_dpif *ofport)
                                  peer_peer)) {
             ofport->peer = peer;
             ofport->peer->peer = ofport;
+            netdev_set_peer_netdev(ofport->up.netdev, peer->up.netdev);
+            netdev_set_peer_netdev(peer->up.netdev, ofport->up.netdev);
         }
         free(peer_peer);