i40e: get flow director statistics
authorJingjing Wu <jingjing.wu@intel.com>
Fri, 21 Nov 2014 00:46:51 +0000 (08:46 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 24 Nov 2014 23:06:04 +0000 (00:06 +0100)
implement operation to get flow director statistics in i40e pmd driver

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
lib/librte_pmd_i40e/i40e_fdir.c

index 059ff3e..276304b 100644 (file)
@@ -122,6 +122,8 @@ static int i40e_fdir_filter_programming(struct i40e_pf *pf,
 static int i40e_fdir_flush(struct rte_eth_dev *dev);
 static void i40e_fdir_info_get(struct rte_eth_dev *dev,
                           struct rte_eth_fdir_info *fdir);
+static void i40e_fdir_stats_get(struct rte_eth_dev *dev,
+                          struct rte_eth_fdir_stats *stat);
 
 static int
 i40e_fdir_rx_queue_init(struct i40e_rx_queue *rxq)
@@ -1003,6 +1005,28 @@ i40e_fdir_info_get(struct rte_eth_dev *dev, struct rte_eth_fdir_info *fdir)
        fdir->flex_conf.nb_flexmasks = num_flex_mask;
 }
 
+/*
+ * i40e_fdir_stat_get - get statistics of Flow Director
+ * @pf: ethernet device to get info from
+ * @stat: a pointer to a structure of type *rte_eth_fdir_stats* to be filled with
+ *    the flow director statistics.
+ */
+static void
+i40e_fdir_stats_get(struct rte_eth_dev *dev, struct rte_eth_fdir_stats *stat)
+{
+       struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+       struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+       uint32_t fdstat;
+
+       fdstat = I40E_READ_REG(hw, I40E_PFQF_FDSTAT);
+       stat->guarant_cnt =
+               (uint32_t)((fdstat & I40E_PFQF_FDSTAT_GUARANT_CNT_MASK) >>
+                           I40E_PFQF_FDSTAT_GUARANT_CNT_SHIFT);
+       stat->best_cnt =
+               (uint32_t)((fdstat & I40E_PFQF_FDSTAT_BEST_CNT_MASK) >>
+                           I40E_PFQF_FDSTAT_BEST_CNT_SHIFT);
+}
+
 /*
  * i40e_fdir_ctrl_func - deal with all operations on flow director.
  * @pf: board private structure
@@ -1043,6 +1067,9 @@ i40e_fdir_ctrl_func(struct rte_eth_dev *dev,
        case RTE_ETH_FILTER_INFO:
                i40e_fdir_info_get(dev, (struct rte_eth_fdir_info *)arg);
                break;
+       case RTE_ETH_FILTER_STATS:
+               i40e_fdir_stats_get(dev, (struct rte_eth_fdir_stats *)arg);
+               break;
        default:
                PMD_DRV_LOG(ERR, "unknown operation %u.", filter_op);
                ret = -EINVAL;