components/openvswitch/patches/04-netdev-provider.patch
author Chad Mynhier <chad.mynhier@oracle.com>
Wed, 12 Oct 2016 11:24:25 -0700
changeset 7095 6469e6424607
parent 5730 cca4aa297e68
permissions -rw-r--r--
24811276 Fix 64-bit Python builds so pstack(1) will work

This patch includes support for the Solaris netdev provider.

This patch has not been proposed upstream because we are not yet
proposing Solaris specific requirements upstream.

diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index b087ed1..6e260e8 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -1068,7 +1068,11 @@ static const struct netdev_class dummy_class = {
     NULL,                       /* arp_lookup */
 
     netdev_dummy_update_flags,
-
+#ifdef __sun
+    NULL,
+    NULL,
+    NULL,
+#endif
     netdev_dummy_rxq_alloc,
     netdev_dummy_rxq_construct,
     netdev_dummy_rxq_destruct,
diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index 37b9da3..37487f0 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -647,6 +647,20 @@ struct netdev_class {
     int (*update_flags)(struct netdev *netdev, enum netdev_flags off,
                         enum netdev_flags on, enum netdev_flags *old_flags);
 
+   /* Returns true if netdev represents uplink for the switch */
+    int (*configure_uplink)(const struct netdev *netdev,
+                            const char *brname);
+
+    /* Returns true if netdev represents uplink for the switch */
+    bool (*is_uplink)(const struct netdev *netdev);
+
+    /* Adds a mapping into port_to_bridge_map hashmap. We need to maintain
+     * this mapping for every port(netdev) that we add onto the bridge.
+     * Specific to Solaris' netdev provider(netdev_solaris_class)
+     * and multiple uplink implementation */
+    void (*add_port_to_bridge_mapping)(const struct netdev *netdev,
+                        const char *name);
+
 /* ## -------------------- ## */
 /* ## netdev_rxq Functions ## */
 /* ## -------------------- ## */
@@ -692,6 +706,9 @@ extern const struct netdev_class netdev_tap_class;
 #if defined(__FreeBSD__) || defined(__NetBSD__)
 extern const struct netdev_class netdev_bsd_class;
 #endif
+#ifdef __sun
+extern const struct netdev_class netdev_solaris_class;
+#endif
 
 #ifdef  __cplusplus
 }
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 0c22378..d442345 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -818,7 +818,10 @@ get_stats(const struct netdev *netdev, struct netdev_stats *stats)
     NULL,                   /* rx_dealloc */                \
     NULL,                   /* rx_recv */                   \
     NULL,                   /* rx_wait */                   \
-    NULL,                   /* rx_drain */
+    NULL,                   /* rx_drain */                  \
+    NULL,                   /* configure_uplink */          \
+    NULL,                   /* is_uplink */		    \
+    NULL                    /* add_port_to_bridge_mapping */
 
 #define TUNNEL_CLASS(NAME, DPIF_PORT)                       \
     { DPIF_PORT,                                            \
@@ -831,12 +834,14 @@ void
 netdev_vport_tunnel_register(void)
 {
     static const struct vport_class vport_classes[] = {
+#ifndef __sun
         TUNNEL_CLASS("gre", "gre_system"),
         TUNNEL_CLASS("ipsec_gre", "gre_system"),
         TUNNEL_CLASS("gre64", "gre64_system"),
         TUNNEL_CLASS("ipsec_gre64", "gre64_system"),
-        TUNNEL_CLASS("vxlan", "vxlan_system"),
-        TUNNEL_CLASS("lisp", "lisp_system")
+        TUNNEL_CLASS("lisp", "lisp_system"),
+#endif
+        TUNNEL_CLASS("vxlan", "vxlan_system")
     };
     static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
 
diff --git a/lib/netdev.c b/lib/netdev.c
index 5bf2220..3c9081c 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -135,6 +135,12 @@ netdev_initialize(void)
         netdev_register_provider(&netdev_tap_class);
         netdev_register_provider(&netdev_bsd_class);
 #endif
+#ifdef __sun
+       netdev_register_provider(&netdev_solaris_class);
+       netdev_register_provider(&netdev_internal_class);
+        netdev_vport_tunnel_register();
+#endif
+
         netdev_dpdk_register();
 
         ovsthread_once_done(&once);
@@ -684,6 +690,30 @@ netdev_get_etheraddr(const struct netdev *netdev, uint8_t mac[ETH_ADDR_LEN])
     return netdev->netdev_class->get_etheraddr(netdev, mac);
 }
 
+int
+netdev_configure_uplink(const struct netdev *netdev, const char *brname)
+{
+    const struct netdev_class *class = netdev->netdev_class;
+
+    return (class->configure_uplink
+           ? class->configure_uplink(netdev, brname) : 0);
+}
+
+bool
+netdev_is_uplink(const struct netdev *netdev)
+{
+    const struct netdev_class *class = netdev->netdev_class;
+
+    return(class->is_uplink ? class->is_uplink(netdev) : false);
+}
+
+void
+netdev_add_port_to_bridge_mapping(const struct netdev *netdev, const char *brname)
+{
+    if (netdev->netdev_class->add_port_to_bridge_mapping)
+        netdev->netdev_class->add_port_to_bridge_mapping(netdev, brname);
+}
+
 /* Returns the name of the network device that 'netdev' represents,
  * e.g. "eth0".  The caller must not modify or free the returned string. */
 const char *
diff --git a/lib/netdev.h b/lib/netdev.h
index 7cb3c80..f450f64 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -176,7 +176,9 @@ void netdev_send_wait(struct netdev *);
 /* Hardware address. */
 int netdev_set_etheraddr(struct netdev *, const uint8_t mac[6]);
 int netdev_get_etheraddr(const struct netdev *, uint8_t mac[6]);
-
+int netdev_configure_uplink(const struct netdev *, const char *);
+bool netdev_is_uplink(const struct netdev *);
+void netdev_add_port_to_bridge_mapping(const struct netdev *, const char *);
 /* PHY interface. */
 bool netdev_get_carrier(const struct netdev *);
 long long int netdev_get_carrier_resets(const struct netdev *);