dpdk: fix vlan stripping
[vpp.git] / src / plugins / dpdk / device / init.c
index 2e4c8a2..07cbbf9 100644 (file)
@@ -266,7 +266,7 @@ dpdk_lib_init (dpdk_main_t * dm)
   RTE_ETH_FOREACH_DEV(i)
     {
       u8 addr[6];
-      u8 vlan_strip = 0;
+      int vlan_off;
       struct rte_eth_dev_info dev_info;
       struct rte_pci_device *pci_dev;
       struct rte_eth_link l;
@@ -778,22 +778,26 @@ dpdk_lib_init (dpdk_main_t * dm)
        * VLAN stripping: default to VLAN strip disabled, unless specified
        * otherwise in the startup config.
        */
-      if (devconf->vlan_strip_offload == DPDK_DEVICE_VLAN_STRIP_ON)
-       vlan_strip = 1;
 
-      if (vlan_strip)
+      vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id);
+      if (devconf->vlan_strip_offload == DPDK_DEVICE_VLAN_STRIP_ON)
        {
-         int vlan_off;
-         vlan_off = rte_eth_dev_get_vlan_offload (xd->port_id);
          vlan_off |= ETH_VLAN_STRIP_OFFLOAD;
-          if (vlan_off)
-           xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
-         else
-           xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
-         if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) == 0)
+         if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0)
            dpdk_log_info ("VLAN strip enabled for interface\n");
          else
            dpdk_log_warn ("VLAN strip cannot be supported by interface\n");
+         xd->port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_VLAN_STRIP;
+       }
+      else
+       {
+         if (vlan_off & ETH_VLAN_STRIP_OFFLOAD)
+           {
+             vlan_off &= ~ETH_VLAN_STRIP_OFFLOAD;
+             if (rte_eth_dev_set_vlan_offload (xd->port_id, vlan_off) >= 0)
+               dpdk_log_warn ("set VLAN offload failed\n");
+           }
+         xd->port_conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP;
        }
 
       if (hi)
@@ -1500,7 +1504,7 @@ dpdk_update_link_state (dpdk_device_t * xd, f64 now)
       ed->new_link_state = (u8) xd->link.link_status;
     }
 
-  if (hw_flags_chg || (xd->link.link_duplex != prev_link.link_duplex))
+  if ((xd->link.link_duplex != prev_link.link_duplex))
     {
       hw_flags_chg = 1;
       switch (xd->link.link_duplex)
@@ -1519,6 +1523,14 @@ dpdk_update_link_state (dpdk_device_t * xd, f64 now)
     vnet_hw_interface_set_link_speed (vnm, xd->hw_if_index,
                                      xd->link.link_speed * 1000);
 
+  if (xd->link.link_status != prev_link.link_status)
+    {
+      hw_flags_chg = 1;
+
+      if (xd->link.link_status)
+       hw_flags |= VNET_HW_INTERFACE_FLAG_LINK_UP;
+    }
+
   if (hw_flags_chg)
     {
       if (LINK_STATE_ELOGS)