i40e: do not report deprecated statistics
[dpdk.git] / drivers / net / i40e / i40e_ethdev.c
index e4684d3..619dc2d 100644 (file)
@@ -489,6 +489,9 @@ static const struct rte_i40e_xstats_name_off rte_i40e_stats_strings[] = {
        {"tx_dropped", offsetof(struct i40e_eth_stats, tx_discards)},
 };
 
+#define I40E_NB_ETH_XSTATS (sizeof(rte_i40e_stats_strings) / \
+               sizeof(rte_i40e_stats_strings[0]))
+
 static const struct rte_i40e_xstats_name_off rte_i40e_hw_port_strings[] = {
        {"tx_link_down_dropped", offsetof(struct i40e_hw_port_stats,
                tx_dropped_link_down)},
@@ -555,15 +558,30 @@ static const struct rte_i40e_xstats_name_off rte_i40e_hw_port_strings[] = {
                rx_lpi_count)},
 };
 
-/* Q Stats: 5 stats are exposed for each queue, implemented in xstats_get() */
-#define I40E_NB_HW_PORT_Q_STATS (8 * 5)
-
-#define I40E_NB_ETH_XSTATS (sizeof(rte_i40e_stats_strings) / \
-               sizeof(rte_i40e_stats_strings[0]))
 #define I40E_NB_HW_PORT_XSTATS (sizeof(rte_i40e_hw_port_strings) / \
                sizeof(rte_i40e_hw_port_strings[0]))
-#define I40E_NB_XSTATS (I40E_NB_ETH_XSTATS + I40E_NB_HW_PORT_XSTATS + \
-               I40E_NB_HW_PORT_Q_STATS)
+
+static const struct rte_i40e_xstats_name_off rte_i40e_rxq_prio_strings[] = {
+       {"xon_packets", offsetof(struct i40e_hw_port_stats,
+               priority_xon_rx)},
+       {"xoff_packets", offsetof(struct i40e_hw_port_stats,
+               priority_xoff_rx)},
+};
+
+#define I40E_NB_RXQ_PRIO_XSTATS (sizeof(rte_i40e_rxq_prio_strings) / \
+               sizeof(rte_i40e_rxq_prio_strings[0]))
+
+static const struct rte_i40e_xstats_name_off rte_i40e_txq_prio_strings[] = {
+       {"xon_packets", offsetof(struct i40e_hw_port_stats,
+               priority_xon_tx)},
+       {"xoff_packets", offsetof(struct i40e_hw_port_stats,
+               priority_xoff_tx)},
+       {"xon_to_xoff_packets", offsetof(struct i40e_hw_port_stats,
+               priority_xon_2_xoff)},
+};
+
+#define I40E_NB_TXQ_PRIO_XSTATS (sizeof(rte_i40e_txq_prio_strings) / \
+               sizeof(rte_i40e_txq_prio_strings[0]))
 
 static struct eth_driver rte_i40e_pmd = {
        .pci_drv = {
@@ -2042,15 +2060,14 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
        stats->oerrors  = ns->eth.tx_errors +
                        pf->main_vsi->eth_stats.tx_errors;
        stats->imcasts  = pf->main_vsi->eth_stats.rx_multicast;
-       stats->fdirmatch = ns->fd_sb_match;
 
        /* Rx Errors */
-       stats->ibadcrc  = ns->crc_errors;
-       stats->ibadlen  = ns->rx_length_errors + ns->rx_undersize +
-                       ns->rx_oversize + ns->rx_fragments + ns->rx_jabber;
        stats->imissed  = ns->eth.rx_discards +
                        pf->main_vsi->eth_stats.rx_discards;
-       stats->ierrors  = stats->ibadcrc + stats->ibadlen + stats->imissed;
+       stats->ierrors  = ns->crc_errors +
+                       ns->rx_length_errors + ns->rx_undersize +
+                       ns->rx_oversize + ns->rx_fragments + ns->rx_jabber +
+                       stats->imissed;
 
        PMD_DRV_LOG(DEBUG, "***************** PF stats start *******************");
        PMD_DRV_LOG(DEBUG, "rx_bytes:            %"PRIu64"", ns->eth.rx_bytes);
@@ -2139,24 +2156,34 @@ i40e_dev_stats_reset(struct rte_eth_dev *dev)
        i40e_read_stats_registers(pf, hw);
 }
 
+static uint32_t
+i40e_xstats_calc_num(void)
+{
+       return I40E_NB_ETH_XSTATS + I40E_NB_HW_PORT_XSTATS +
+               (I40E_NB_RXQ_PRIO_XSTATS * 8) +
+               (I40E_NB_TXQ_PRIO_XSTATS * 8);
+}
+
 static int
 i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
                    unsigned n)
 {
        struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-       unsigned i, count = 0;
+       unsigned i, count, prio;
        struct i40e_hw_port_stats *hw_stats = &pf->stats;
 
-       if (n < I40E_NB_XSTATS)
-               return I40E_NB_XSTATS;
+       count = i40e_xstats_calc_num();
+       if (n < count)
+               return count;
 
        i40e_read_stats_registers(pf, hw);
 
-       /* Reset */
        if (xstats == NULL)
                return 0;
 
+       count = 0;
+
        /* Get stats from i40e_eth_stats struct */
        for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
                snprintf(xstats[count].name, sizeof(xstats[count].name),
@@ -2175,45 +2202,35 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
                count++;
        }
 
-       /* Get per-queue stats from i40e_hw_port struct */
-       for (i = 0; i < 8; i++) {
-               snprintf(xstats[count].name, sizeof(xstats[count].name),
-                        "rx_q%u_xon_priority_packets", i);
-               xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
-                               offsetof(struct i40e_hw_port_stats,
-                                        priority_xon_rx[i]));
-               count++;
-
-               snprintf(xstats[count].name, sizeof(xstats[count].name),
-                        "rx_q%u_xoff_priority_packets", i);
-               xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
-                               offsetof(struct i40e_hw_port_stats,
-                                        priority_xoff_rx[i]));
-               count++;
-
-               snprintf(xstats[count].name, sizeof(xstats[count].name),
-                        "tx_q%u_xon_priority_packets", i);
-               xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
-                               offsetof(struct i40e_hw_port_stats,
-                                        priority_xon_tx[i]));
-               count++;
-
-               snprintf(xstats[count].name, sizeof(xstats[count].name),
-                        "tx_q%u_xoff_priority_packets", i);
-               xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
-                               offsetof(struct i40e_hw_port_stats,
-                                        priority_xoff_tx[i]));
-               count++;
+       for (i = 0; i < I40E_NB_RXQ_PRIO_XSTATS; i++) {
+               for (prio = 0; prio < 8; prio++) {
+                       snprintf(xstats[count].name,
+                                sizeof(xstats[count].name),
+                                "rx_priority%u_%s", prio,
+                                rte_i40e_rxq_prio_strings[i].name);
+                       xstats[count].value =
+                               *(uint64_t *)(((char *)hw_stats) +
+                               rte_i40e_rxq_prio_strings[i].offset +
+                               (sizeof(uint64_t) * prio));
+                       count++;
+               }
+       }
 
-               snprintf(xstats[count].name, sizeof(xstats[count].name),
-                        "xx_q%u_xon_to_xoff_priority_packets", i);
-               xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
-                               offsetof(struct i40e_hw_port_stats,
-                                        priority_xon_2_xoff[i]));
-               count++;
+       for (i = 0; i < I40E_NB_TXQ_PRIO_XSTATS; i++) {
+               for (prio = 0; prio < 8; prio++) {
+                       snprintf(xstats[count].name,
+                                sizeof(xstats[count].name),
+                                "tx_priority%u_%s", prio,
+                                rte_i40e_txq_prio_strings[i].name);
+                       xstats[count].value =
+                               *(uint64_t *)(((char *)hw_stats) +
+                               rte_i40e_txq_prio_strings[i].offset +
+                               (sizeof(uint64_t) * prio));
+                       count++;
+               }
        }
 
-       return I40E_NB_XSTATS;
+       return count;
 }
 
 static int
@@ -3118,13 +3135,16 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)
        pf->vmdq_nb_qps = 0;
        pf->max_nb_vmdq_vsi = 0;
        if (hw->func_caps.vmdq) {
-               if (qp_count < hw->func_caps.num_tx_qp) {
+               if (qp_count < hw->func_caps.num_tx_qp &&
+                       vsi_count < hw->func_caps.num_vsis) {
                        pf->max_nb_vmdq_vsi = (hw->func_caps.num_tx_qp -
                                qp_count) / pf->vmdq_nb_qp_max;
 
                        /* Limit the maximum number of VMDq vsi to the maximum
                         * ethdev can support
                         */
+                       pf->max_nb_vmdq_vsi = RTE_MIN(pf->max_nb_vmdq_vsi,
+                               hw->func_caps.num_vsis - vsi_count);
                        pf->max_nb_vmdq_vsi = RTE_MIN(pf->max_nb_vmdq_vsi,
                                ETH_64_POOLS);
                        if (pf->max_nb_vmdq_vsi) {
@@ -3140,7 +3160,7 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)
                                            "VMDq");
                        }
                } else {
-                       PMD_DRV_LOG(INFO, "No queue left for VMDq");
+                       PMD_DRV_LOG(INFO, "No queue or VSI left for VMDq");
                }
        }
        qp_count += pf->vmdq_nb_qps * pf->max_nb_vmdq_vsi;