Display flow director's statistics information

Signed-off-by: Jingjing Wu <jingjing.wu at intel.com>
---
 app/test-pmd/config.c | 42 ++++++++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 9bc08f4..c516be0 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1815,18 +1815,46 @@ fdir_remove_signature_filter(portid_t port_id,
 void
 fdir_get_infos(portid_t port_id)
 {
-       struct rte_eth_fdir fdir_infos;
+       struct rte_eth_fdir_info fdir_infos;
+       int ret;

        static const char *fdir_stats_border = "########################";

        if (port_id_is_invalid(port_id))
                return;

-       rte_eth_dev_fdir_get_infos(port_id, &fdir_infos);
-
+       memset(&fdir_infos, 0, sizeof(fdir_infos));
+       ret = rte_eth_dev_filter_ctrl(port_id, RTE_ETH_FILTER_FDIR,
+                              RTE_ETH_FILTER_INFO, &fdir_infos);
+       if (ret < 0) {
+               /* use the old fdir APIs to get info */
+               struct rte_eth_fdir fdir;
+               memset(&fdir, 0, sizeof(fdir));
+               ret = rte_eth_dev_fdir_get_infos(port_id, &fdir);
+               if (ret < 0) {
+                       printf("\n getting fdir info fails on port %-2d\n",
+                               port_id);
+                       return;
+               }
+               printf("\n  %s FDIR infos for port %-2d     %s\n",
+                       fdir_stats_border, port_id, fdir_stats_border);
+               printf("  collision: %-10"PRIu64"  free:     %"PRIu64"\n"
+                      "  maxhash:   %-10"PRIu64"  maxlen:   %"PRIu64"\n"
+                      "  add:       %-10"PRIu64"  remove:   %"PRIu64"\n"
+                      "  f_add:     %-10"PRIu64"  f_remove: %"PRIu64"\n",
+                      (uint64_t)(fdir.collision), (uint64_t)(fdir.free),
+                      (uint64_t)(fdir.maxhash), (uint64_t)(fdir.maxlen),
+                      fdir.add, fdir.remove, fdir.f_add, fdir.f_remove);
+               printf("  %s############################%s\n",
+                      fdir_stats_border, fdir_stats_border);
+               return;
+       }
        printf("\n  %s FDIR infos for port %-2d     %s\n",
               fdir_stats_border, port_id, fdir_stats_border);
-
+       if (fdir_infos.mode)
+                       printf("  FDIR is enabled\n");
+       else
+                       printf("  FDIR is disabled\n");
        printf("  collision: %-10"PRIu64"  free:     %"PRIu64"\n"
               "  maxhash:   %-10"PRIu64"  maxlen:   %"PRIu64"\n"
               "  add:       %-10"PRIu64"  remove:   %"PRIu64"\n"
@@ -1835,6 +1863,12 @@ fdir_get_infos(portid_t port_id)
               (uint64_t)(fdir_infos.maxhash), (uint64_t)(fdir_infos.maxlen),
               fdir_infos.add, fdir_infos.remove,
               fdir_infos.f_add, fdir_infos.f_remove);
+       printf("  guarant_space: %-10"PRIu16
+              "  best_space:    %-10"PRIu16"\n",
+              fdir_infos.guarant_spc, fdir_infos.best_spc);
+       printf("  guarant_count: %-10"PRIu16
+              "  best_count:    %-10"PRIu16"\n",
+              fdir_infos.guarant_cnt, fdir_infos.best_cnt);
        printf("  %s############################%s\n",
               fdir_stats_border, fdir_stats_border);
 }
-- 
1.8.1.4

Reply via email to