app/testpmd: enforce offload capabilities check
[dpdk.git] / app / test-pmd / config.c
index a49cc35..455bea4 100644 (file)
@@ -2802,6 +2802,7 @@ void
 tx_vlan_set(portid_t port_id, uint16_t vlan_id)
 {
        int vlan_offload;
+       struct rte_eth_dev_info dev_info;
 
        if (port_id_is_invalid(port_id, ENABLED_WARN))
                return;
@@ -2813,6 +2814,12 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id)
                printf("Error, as QinQ has been enabled.\n");
                return;
        }
+       rte_eth_dev_info_get(port_id, &dev_info);
+       if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) == 0) {
+               printf("Error: vlan insert is not supported by port %d\n",
+                       port_id);
+               return;
+       }
 
        tx_vlan_reset(port_id);
        ports[port_id].dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_VLAN_INSERT;
@@ -2823,6 +2830,7 @@ void
 tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer)
 {
        int vlan_offload;
+       struct rte_eth_dev_info dev_info;
 
        if (port_id_is_invalid(port_id, ENABLED_WARN))
                return;
@@ -2836,6 +2844,12 @@ tx_qinq_set(portid_t port_id, uint16_t vlan_id, uint16_t vlan_id_outer)
                printf("Error, as QinQ hasn't been enabled.\n");
                return;
        }
+       rte_eth_dev_info_get(port_id, &dev_info);
+       if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_QINQ_INSERT) == 0) {
+               printf("Error: qinq insert not supported by port %d\n",
+                       port_id);
+               return;
+       }
 
        tx_vlan_reset(port_id);
        ports[port_id].dev_conf.txmode.offloads |= DEV_TX_OFFLOAD_QINQ_INSERT;