app/testpmd: support QinQ offload in VLAN set command
[dpdk.git] / app / test-pmd / config.c
index 8035961..2356afe 100644 (file)
@@ -550,19 +550,24 @@ port_infos_display(portid_t port_id)
        if (vlan_offload >= 0){
                printf("VLAN offload: \n");
                if (vlan_offload & ETH_VLAN_STRIP_OFFLOAD)
-                       printf("  strip on \n");
+                       printf("  strip on");
                else
-                       printf("  strip off \n");
+                       printf("  strip off");
 
                if (vlan_offload & ETH_VLAN_FILTER_OFFLOAD)
-                       printf("  filter on \n");
+                       printf("filter on, ");
                else
-                       printf("  filter off \n");
+                       printf("filter off, ");
 
                if (vlan_offload & ETH_VLAN_EXTEND_OFFLOAD)
-                       printf("  qinq(extend) on \n");
+                       printf("extend on, ");
                else
-                       printf("  qinq(extend) off \n");
+                       printf("extend off, ");
+
+               if (vlan_offload & ETH_QINQ_STRIP_OFFLOAD)
+                       printf("qinq strip on\n");
+               else
+                       printf("qinq strip off\n");
        }
 
        if (dev_info.hash_key_size > 0)
@@ -3058,6 +3063,33 @@ rx_vlan_filter_set(portid_t port_id, int on)
        ports[port_id].dev_conf.rxmode.offloads = port_rx_offloads;
 }
 
+void
+rx_vlan_qinq_strip_set(portid_t port_id, int on)
+{
+       int diag;
+       int vlan_offload;
+       uint64_t port_rx_offloads = ports[port_id].dev_conf.rxmode.offloads;
+
+       if (port_id_is_invalid(port_id, ENABLED_WARN))
+               return;
+
+       vlan_offload = rte_eth_dev_get_vlan_offload(port_id);
+
+       if (on) {
+               vlan_offload |= ETH_QINQ_STRIP_OFFLOAD;
+               port_rx_offloads |= DEV_RX_OFFLOAD_QINQ_STRIP;
+       } else {
+               vlan_offload &= ~ETH_QINQ_STRIP_OFFLOAD;
+               port_rx_offloads &= ~DEV_RX_OFFLOAD_QINQ_STRIP;
+       }
+
+       diag = rte_eth_dev_set_vlan_offload(port_id, vlan_offload);
+       if (diag < 0)
+               printf("%s(port_pi=%d, on=%d) failed "
+              "diag=%d\n", __func__, port_id, on, diag);
+       ports[port_id].dev_conf.rxmode.offloads = port_rx_offloads;
+}
+
 int
 rx_vft_set(portid_t port_id, uint16_t vlan_id, int on)
 {