datapath: Compute checksum while sending packets to userspace().
[openvswitch] / datapath / vport-netdev.c
index 50c51ac097c55616d1279356224d13002ffdacb6..72d2928d5f2e95156931e22e6e092bd9fba229dc 100644 (file)
@@ -22,7 +22,8 @@
 
 #include "compat.h"
 
-struct vport_ops netdev_vport_ops;
+/* 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 net_bridge_port *, struct sk_buff *);
 
@@ -99,6 +100,16 @@ netdev_create(const char *name, const void __user *config)
                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 odp_vport_stats stats;
+
+               err = netdev_get_stats(vport, &stats);
+               if (!err)
+                       vport_set_stats(vport, &stats);
+       }
+
        return vport;
 
 error_put:
@@ -293,7 +304,8 @@ netdev_get_vport(struct net_device *dev)
 
 struct vport_ops netdev_vport_ops = {
        .type           = "netdev",
-       .flags          = VPORT_F_REQUIRED,
+       .flags          = (VPORT_F_REQUIRED |
+                         (USE_VPORT_STATS ? VPORT_F_GEN_STATS : 0)),
        .init           = netdev_init,
        .exit           = netdev_exit,
        .create         = netdev_create,