Although it is generally best to configure vlans directly though
Open vSwitch, enabling vlan acceleration on internal devices can
avoid some issues and hardware limitations if Linux vlan devices
are used.  It is only used on kernels that support modern vlan
data structures: 2.6.27 for the actual acceleration and 2.6.37
for dynamic configuration.

Signed-off-by: Jesse Gross <[email protected]>
---
 datapath/vport-internal_dev.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/datapath/vport-internal_dev.c b/datapath/vport-internal_dev.c
index 63f3f69..8a54255 100644
--- a/datapath/vport-internal_dev.c
+++ b/datapath/vport-internal_dev.c
@@ -99,6 +99,13 @@ static void internal_dev_getinfo(struct net_device *netdev,
        strcpy(info->driver, "openvswitch");
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
+static int internal_dev_set_flags(struct net_device *netdev, u32 data)
+{
+       return ethtool_op_set_flags(netdev, data, ETH_FLAG_TXVLAN);
+}
+#endif
+
 static const struct ethtool_ops internal_dev_ethtool_ops = {
        .get_drvinfo    = internal_dev_getinfo,
        .get_link       = ethtool_op_get_link,
@@ -108,6 +115,10 @@ static const struct ethtool_ops internal_dev_ethtool_ops = 
{
        .set_tx_csum    = ethtool_op_set_tx_hw_csum,
        .get_tso        = ethtool_op_get_tso,
        .set_tso        = ethtool_op_set_tso,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
+       .get_flags      = ethtool_op_get_flags,
+       .set_flags      = internal_dev_set_flags,
+#endif
 };
 
 static int internal_dev_change_mtu(struct net_device *netdev, int new_mtu)
@@ -176,6 +187,10 @@ static void do_setup(struct net_device *netdev)
        netdev->features = NETIF_F_LLTX | NETIF_F_SG | NETIF_F_FRAGLIST |
                                NETIF_F_HIGHDMA | NETIF_F_HW_CSUM | NETIF_F_TSO;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+       netdev->features |= NETIF_F_HW_VLAN_TX;
+#endif
+
        vport_gen_rand_ether_addr(netdev->dev_addr);
 }
 
-- 
1.7.1


_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev_openvswitch.org

Reply via email to