datapath: Always use generic stats for devices (vports)
[sliver-openvswitch.git] / datapath / vport-netdev.c
index d1e61bb..4c7f1cb 100644 (file)
@@ -35,9 +35,6 @@ MODULE_PARM_DESC(vlan_tso, "Enable TSO for VLAN packets");
 #define vlan_tso true
 #endif
 
-/* If the native device stats aren't 64 bit use the vport stats tracking instead. */
-#define USE_VPORT_STATS (sizeof(((struct net_device_stats *)0)->rx_bytes) < sizeof(u64))
-
 static void netdev_port_receive(struct vport *vport, struct sk_buff *skb);
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
@@ -144,16 +141,6 @@ static struct vport *netdev_create(const struct vport_parms *parms)
                goto error_put;
        }
 
-       /* If we are using the vport stats layer initialize it to the current
-        * values so we are roughly consistent with the device stats. */
-       if (USE_VPORT_STATS) {
-               struct rtnl_link_stats64 stats;
-
-               err = netdev_get_stats(vport, &stats);
-               if (!err)
-                       vport_set_stats(vport, &stats);
-       }
-
        err = netdev_rx_handler_register(netdev_vport->dev, netdev_frame_hook,
                                         vport);
        if (err)
@@ -175,7 +162,7 @@ error:
        return ERR_PTR(err);
 }
 
-static int netdev_destroy(struct vport *vport)
+static void netdev_destroy(struct vport *vport)
 {
        struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
 
@@ -187,14 +174,6 @@ static int netdev_destroy(struct vport *vport)
 
        dev_put(netdev_vport->dev);
        vport_free(vport);
-
-       return 0;
-}
-
-int netdev_set_mtu(struct vport *vport, int mtu)
-{
-       struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
-       return dev_set_mtu(netdev_vport->dev, mtu);
 }
 
 int netdev_set_addr(struct vport *vport, const unsigned char *addr)
@@ -226,13 +205,6 @@ struct kobject *netdev_get_kobj(const struct vport *vport)
        return &netdev_vport->dev->NETDEV_DEV_MEMBER.kobj;
 }
 
-int netdev_get_stats(const struct vport *vport, struct rtnl_link_stats64 *stats)
-{
-       const struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
-       dev_get_stats(netdev_vport->dev, stats);
-       return 0;
-}
-
 unsigned netdev_get_dev_flags(const struct vport *vport)
 {
        const struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
@@ -257,12 +229,6 @@ int netdev_get_ifindex(const struct vport *vport)
        return netdev_vport->dev->ifindex;
 }
 
-int netdev_get_iflink(const struct vport *vport)
-{
-       const struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
-       return netdev_vport->dev->iflink;
-}
-
 int netdev_get_mtu(const struct vport *vport)
 {
        const struct netdev_vport *netdev_vport = netdev_vport_priv(vport);
@@ -339,19 +305,15 @@ static int netdev_send(struct vport *vport, struct sk_buff *skb)
        forward_ip_summed(skb, true);
 
        if (vlan_tx_tag_present(skb) && !dev_supports_vlan_tx(skb->dev)) {
-               int features = 0;
+               int features;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
-               features = skb->dev->features & skb->dev->vlan_features;
-#endif
+               features = netif_skb_features(skb);
 
                if (!vlan_tso)
                        features &= ~(NETIF_F_TSO | NETIF_F_TSO6 |
                                      NETIF_F_UFO | NETIF_F_FSO);
 
-               if (skb_is_gso(skb) &&
-                   (!skb_gso_ok(skb, features) ||
-                    unlikely(skb->ip_summed != CHECKSUM_PARTIAL))) {
+               if (netif_needs_gso(skb, features)) {
                        struct sk_buff *nskb;
 
                        nskb = skb_gso_segment(skb, features);
@@ -428,23 +390,19 @@ struct vport *netdev_get_vport(struct net_device *dev)
 
 const struct vport_ops netdev_vport_ops = {
        .type           = OVS_VPORT_TYPE_NETDEV,
-       .flags          = (VPORT_F_REQUIRED |
-                         (USE_VPORT_STATS ? VPORT_F_GEN_STATS : 0)),
+       .flags          = VPORT_F_REQUIRED,
        .init           = netdev_init,
        .exit           = netdev_exit,
        .create         = netdev_create,
        .destroy        = netdev_destroy,
-       .set_mtu        = netdev_set_mtu,
        .set_addr       = netdev_set_addr,
        .get_name       = netdev_get_name,
        .get_addr       = netdev_get_addr,
        .get_kobj       = netdev_get_kobj,
-       .get_stats      = netdev_get_stats,
        .get_dev_flags  = netdev_get_dev_flags,
        .is_running     = netdev_is_running,
        .get_operstate  = netdev_get_operstate,
        .get_ifindex    = netdev_get_ifindex,
-       .get_iflink     = netdev_get_iflink,
        .get_mtu        = netdev_get_mtu,
        .send           = netdev_send,
 };