app/testpmd: replace legacy filter usage
authorChenxu Di <chenxux.di@intel.com>
Wed, 8 Jul 2020 01:18:39 +0000 (01:18 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sat, 11 Jul 2020 04:18:52 +0000 (06:18 +0200)
The legacy filter API will be superseded. This patch use
private api to change the implementation of commands
global_config <port_id> gre-key-len <key_len> and
show port fdir <port_id>

Signed-off-by: Chenxu Di <chenxux.di@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
app/test-pmd/cmdline.c
app/test-pmd/config.c

index 81c87c8..39ad938 100644 (file)
@@ -9291,6 +9291,10 @@ cmd_global_config_parsed(void *parsed_result,
        conf.cfg.gre_key_len = res->len;
        ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
                                      RTE_ETH_FILTER_SET, &conf);
+#ifdef RTE_LIBRTE_I40E_PMD
+       if (ret == -ENOTSUP)
+               ret = rte_pmd_i40e_set_gre_key_len(res->port_id, res->len);
+#endif
        if (ret != 0)
                printf("Global config error\n");
 }
index 7501310..cf14b58 100644 (file)
@@ -3746,30 +3746,65 @@ print_fdir_flow_type(uint32_t flow_types_mask)
        printf("\n");
 }
 
+static int
+get_fdir_info(portid_t port_id, struct rte_eth_fdir_info *fdir_info,
+                   struct rte_eth_fdir_stats *fdir_stat)
+{
+       int ret;
+
+       ret = rte_eth_dev_filter_supported(port_id, RTE_ETH_FILTER_FDIR);
+       if (!ret) {
+               rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
+                              RTE_ETH_FILTER_INFO, fdir_info);
+               rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
+                              RTE_ETH_FILTER_STATS, fdir_stat);
+               return 0;
+       }
+
+#ifdef RTE_LIBRTE_I40E_PMD
+       if (ret == -ENOTSUP) {
+               ret = rte_pmd_i40e_get_fdir_info(port_id, fdir_info);
+               if (!ret)
+                       ret = rte_pmd_i40e_get_fdir_stats(port_id, fdir_stat);
+       }
+#endif
+#ifdef RTE_LIBRTE_IXGBE_PMD
+       if (ret == -ENOTSUP) {
+               ret = rte_pmd_ixgbe_get_fdir_info(port_id, fdir_info);
+               if (!ret)
+                       ret = rte_pmd_ixgbe_get_fdir_stats(port_id, fdir_stat);
+       }
+#endif
+       switch (ret) {
+       case 0:
+               break;
+       case -ENOTSUP:
+               printf("\n FDIR is not supported on port %-2d\n",
+                       port_id);
+               break;
+       default:
+               printf("programming error: (%s)\n", strerror(-ret));
+               break;
+       }
+       return ret;
+}
+
 void
 fdir_get_infos(portid_t port_id)
 {
        struct rte_eth_fdir_stats fdir_stat;
        struct rte_eth_fdir_info fdir_info;
-       int ret;
 
        static const char *fdir_stats_border = "########################";
 
        if (port_id_is_invalid(port_id, ENABLED_WARN))
                return;
-       ret = rte_eth_dev_filter_supported(port_id, RTE_ETH_FILTER_FDIR);
-       if (ret < 0) {
-               printf("\n FDIR is not supported on port %-2d\n",
-                       port_id);
-               return;
-       }
 
        memset(&fdir_info, 0, sizeof(fdir_info));
-       rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
-                              RTE_ETH_FILTER_INFO, &fdir_info);
        memset(&fdir_stat, 0, sizeof(fdir_stat));
-       rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
-                              RTE_ETH_FILTER_STATS, &fdir_stat);
+       if (get_fdir_info(port_id, &fdir_info, &fdir_stat))
+               return;
+
        printf("\n  %s FDIR infos for port %-2d     %s\n",
               fdir_stats_border, port_id, fdir_stats_border);
        printf("  MODE: ");