datapath: Fix coding style issues.
[sliver-openvswitch.git] / datapath / vport-internal_dev.c
index 2d46343..26b432b 100644 (file)
 
 struct internal_dev {
        struct vport *vport;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
        struct net_device_stats stats;
+#endif
 };
 
-static inline struct internal_dev *internal_dev_priv(struct net_device *netdev)
+static struct internal_dev *internal_dev_priv(struct net_device *netdev)
 {
        return netdev_priv(netdev);
 }
 
 /* This function is only called by the kernel network layer.*/
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+static struct rtnl_link_stats64 *internal_dev_get_stats(struct net_device *netdev,
+                                                       struct rtnl_link_stats64 *stats)
+{
+#else
 static struct net_device_stats *internal_dev_sys_stats(struct net_device *netdev)
 {
-       struct vport *vport = internal_dev_get_vport(netdev);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
        struct net_device_stats *stats = &internal_dev_priv(netdev)->stats;
+#else
+       struct net_device_stats *stats = &netdev->stats;
+#endif
+#endif
+       struct vport *vport = internal_dev_get_vport(netdev);
+       struct ovs_vport_stats vport_stats;
 
-       if (vport) {
-               struct ovs_vport_stats vport_stats;
-
-               vport_get_stats(vport, &vport_stats);
-
-               /* The tx and rx stats need to be swapped because the switch
-                * and host OS have opposite perspectives. */
-               stats->rx_packets       = vport_stats.tx_packets;
-               stats->tx_packets       = vport_stats.rx_packets;
-               stats->rx_bytes         = vport_stats.tx_bytes;
-               stats->tx_bytes         = vport_stats.rx_bytes;
-               stats->rx_errors        = vport_stats.tx_errors;
-               stats->tx_errors        = vport_stats.rx_errors;
-               stats->rx_dropped       = vport_stats.tx_dropped;
-               stats->tx_dropped       = vport_stats.rx_dropped;
-       }
+       vport_get_stats(vport, &vport_stats);
+
+       /* The tx and rx stats need to be swapped because the
+        * switch and host OS have opposite perspectives. */
+       stats->rx_packets       = vport_stats.tx_packets;
+       stats->tx_packets       = vport_stats.rx_packets;
+       stats->rx_bytes         = vport_stats.tx_bytes;
+       stats->tx_bytes         = vport_stats.rx_bytes;
+       stats->rx_errors        = vport_stats.tx_errors;
+       stats->tx_errors        = vport_stats.rx_errors;
+       stats->rx_dropped       = vport_stats.tx_dropped;
+       stats->tx_dropped       = vport_stats.rx_dropped;
 
        return stats;
 }
@@ -110,12 +119,14 @@ static void internal_dev_getinfo(struct net_device *netdev,
 static const struct ethtool_ops internal_dev_ethtool_ops = {
        .get_drvinfo    = internal_dev_getinfo,
        .get_link       = ethtool_op_get_link,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
        .get_sg         = ethtool_op_get_sg,
        .set_sg         = ethtool_op_set_sg,
        .get_tx_csum    = ethtool_op_get_tx_csum,
        .set_tx_csum    = ethtool_op_set_tx_hw_csum,
        .get_tso        = ethtool_op_get_tso,
        .set_tso        = ethtool_op_set_tso,
+#endif
 };
 
 static int internal_dev_change_mtu(struct net_device *netdev, int new_mtu)
@@ -127,7 +138,8 @@ static int internal_dev_change_mtu(struct net_device *netdev, int new_mtu)
        return 0;
 }
 
-static int internal_dev_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
+static int internal_dev_do_ioctl(struct net_device *dev,
+                                struct ifreq *ifr, int cmd)
 {
        if (dp_ioctl_hook)
                return dp_ioctl_hook(dev, ifr, cmd);
@@ -151,7 +163,11 @@ static const struct net_device_ops internal_dev_netdev_ops = {
        .ndo_set_mac_address = internal_dev_mac_addr,
        .ndo_do_ioctl = internal_dev_do_ioctl,
        .ndo_change_mtu = internal_dev_change_mtu,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+       .ndo_get_stats64 = internal_dev_get_stats,
+#else
        .ndo_get_stats = internal_dev_sys_stats,
+#endif
 };
 #endif
 
@@ -171,11 +187,11 @@ static void do_setup(struct net_device *netdev)
        netdev->change_mtu = internal_dev_change_mtu;
 #endif
 
+       netdev->priv_flags &= ~IFF_TX_SKB_SHARING;
        netdev->destructor = internal_dev_destructor;
        SET_ETHTOOL_OPS(netdev, &internal_dev_ethtool_ops);
        netdev->tx_queue_len = 0;
 
-       netdev->flags = IFF_BROADCAST | IFF_MULTICAST;
        netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_FRAGLIST |
                                NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_TSO;
 
@@ -184,6 +200,9 @@ static void do_setup(struct net_device *netdev)
        netdev->features |= NETIF_F_HW_VLAN_TX;
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+       netdev->hw_features = netdev->features & ~NETIF_F_LLTX;
+#endif
        vport_gen_rand_ether_addr(netdev->dev_addr);
 }
 
@@ -194,7 +213,8 @@ static struct vport *internal_dev_create(const struct vport_parms *parms)
        struct internal_dev *internal_dev;
        int err;
 
-       vport = vport_alloc(sizeof(struct netdev_vport), &internal_vport_ops, parms);
+       vport = vport_alloc(sizeof(struct netdev_vport),
+                           &internal_vport_ops, parms);
        if (IS_ERR(vport)) {
                err = PTR_ERR(vport);
                goto error;
@@ -202,7 +222,8 @@ static struct vport *internal_dev_create(const struct vport_parms *parms)
 
        netdev_vport = netdev_vport_priv(vport);
 
-       netdev_vport->dev = alloc_netdev(sizeof(struct internal_dev), parms->name, do_setup);
+       netdev_vport->dev = alloc_netdev(sizeof(struct internal_dev),
+                                        parms->name, do_setup);
        if (!netdev_vport->dev) {
                err = -ENOMEM;
                goto error_free_vport;