datapath: Always use generic stats for devices (vports)
[sliver-openvswitch.git] / datapath / vport-patch.c
index 7dfea6b..9554f12 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/list.h>
 #include <linux/rtnetlink.h>
 
+#include "compat.h"
 #include "datapath.h"
 #include "vport.h"
 #include "vport-generic.h"
@@ -20,7 +21,6 @@ struct patch_config {
 
        char peer_name[IFNAMSIZ];
        unsigned char eth_addr[ETH_ALEN];
-       unsigned int mtu;
 };
 
 struct patch_vport {
@@ -85,9 +85,9 @@ static void patch_exit(void)
        kfree(peer_table);
 }
 
-static const struct nla_policy patch_policy[ODP_PATCH_ATTR_MAX + 1] = {
+static const struct nla_policy patch_policy[OVS_PATCH_ATTR_MAX + 1] = {
 #ifdef HAVE_NLA_NUL_STRING
-       [ODP_PATCH_ATTR_PEER] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
+       [OVS_PATCH_ATTR_PEER] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },
 #endif
 };
 
@@ -95,21 +95,22 @@ static int patch_set_config(struct vport *vport, const struct nlattr *options,
                            struct patch_config *patchconf)
 {
        struct patch_vport *patch_vport = patch_vport_priv(vport);
-       struct nlattr *a[ODP_PATCH_ATTR_MAX + 1];
+       struct nlattr *a[OVS_PATCH_ATTR_MAX + 1];
        const char *peer_name;
        int err;
 
        if (!options)
                return -EINVAL;
 
-       err = nla_parse_nested(a, ODP_PATCH_ATTR_MAX, options, patch_policy);
+       err = nla_parse_nested(a, OVS_PATCH_ATTR_MAX, options, patch_policy);
        if (err)
                return err;
 
-       if (!a[ODP_PATCH_ATTR_PEER] || VERIFY_NUL_STRING(a[ODP_PATCH_ATTR_PEER], IFNAMSIZ - 1))
+       if (!a[OVS_PATCH_ATTR_PEER] ||
+           CHECK_NUL_STRING(a[OVS_PATCH_ATTR_PEER], IFNAMSIZ - 1))
                return -EINVAL;
 
-       peer_name = nla_data(a[ODP_PATCH_ATTR_PEER]);
+       peer_name = nla_data(a[OVS_PATCH_ATTR_PEER]);
        if (!strcmp(patch_vport->name, peer_name))
                return -EINVAL;
 
@@ -148,10 +149,6 @@ static struct vport *patch_create(const struct vport_parms *parms)
 
        vport_gen_rand_ether_addr(patchconf->eth_addr);
 
-       /* Make the default MTU fairly large so that it doesn't become the
-        * bottleneck on systems using jumbo frames. */
-       patchconf->mtu = 65535;
-
        rcu_assign_pointer(patch_vport->patchconf, patchconf);
 
        peer_name = patchconf->peer_name;
@@ -178,15 +175,13 @@ static void free_port_rcu(struct rcu_head *rcu)
        vport_free(vport_from_priv(patch_vport));
 }
 
-static int patch_destroy(struct vport *vport)
+static void patch_destroy(struct vport *vport)
 {
        struct patch_vport *patch_vport = patch_vport_priv(vport);
 
        update_peers(patch_vport->name, NULL);
        hlist_del(&patch_vport->hash_node);
        call_rcu(&patch_vport->rcu, free_port_rcu);
-
-       return 0;
 }
 
 static int patch_set_options(struct vport *vport, struct nlattr *options)
@@ -236,22 +231,6 @@ static void update_peers(const char *name, struct vport *vport)
        }
 }
 
-static int patch_set_mtu(struct vport *vport, int mtu)
-{
-       struct patch_vport *patch_vport = patch_vport_priv(vport);
-       struct patch_config *patchconf;
-
-       patchconf = kmemdup(rtnl_dereference(patch_vport->patchconf),
-                         sizeof(struct patch_config), GFP_KERNEL);
-       if (!patchconf)
-               return -ENOMEM;
-
-       patchconf->mtu = mtu;
-       assign_config_rcu(vport, patchconf);
-
-       return 0;
-}
-
 static int patch_set_addr(struct vport *vport, const unsigned char *addr)
 {
        struct patch_vport *patch_vport = patch_vport_priv(vport);
@@ -286,13 +265,7 @@ static int patch_get_options(const struct vport *vport, struct sk_buff *skb)
        struct patch_vport *patch_vport = patch_vport_priv(vport);
        struct patch_config *patchconf = rcu_dereference_rtnl(patch_vport->patchconf);
 
-       return nla_put_string(skb, ODP_PATCH_ATTR_PEER, patchconf->peer_name);
-}
-
-static int patch_get_mtu(const struct vport *vport)
-{
-       const struct patch_vport *patch_vport = patch_vport_priv(vport);
-       return rcu_dereference_rtnl(patch_vport->patchconf)->mtu;
+       return nla_put_string(skb, OVS_PATCH_ATTR_PEER, patchconf->peer_name);
 }
 
 static int patch_send(struct vport *vport, struct sk_buff *skb)
@@ -313,13 +286,11 @@ static int patch_send(struct vport *vport, struct sk_buff *skb)
 }
 
 const struct vport_ops patch_vport_ops = {
-       .type           = ODP_VPORT_TYPE_PATCH,
-       .flags          = VPORT_F_GEN_STATS,
+       .type           = OVS_VPORT_TYPE_PATCH,
        .init           = patch_init,
        .exit           = patch_exit,
        .create         = patch_create,
        .destroy        = patch_destroy,
-       .set_mtu        = patch_set_mtu,
        .set_addr       = patch_set_addr,
        .get_name       = patch_get_name,
        .get_addr       = patch_get_addr,
@@ -328,6 +299,5 @@ const struct vport_ops patch_vport_ops = {
        .get_dev_flags  = vport_gen_get_dev_flags,
        .is_running     = vport_gen_is_running,
        .get_operstate  = vport_gen_get_operstate,
-       .get_mtu        = patch_get_mtu,
        .send           = patch_send,
 };