net/cxgbe: support xstats for VF
authorNikhil Vasoya <nikhil.vasoya@chelsio.com>
Thu, 30 Sep 2021 17:09:58 +0000 (22:39 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 5 Oct 2021 17:32:01 +0000 (19:32 +0200)
Add support to fetch port and queue stats via xstats API. Also remove
queue stats from basic stats because they're now available via xstats
API for the VF.

Signed-off-by: Nikhil Vasoya <nikhil.vasoya@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
doc/guides/nics/features/cxgbe.ini
doc/guides/nics/features/cxgbevf.ini
drivers/net/cxgbe/cxgbe_ethdev.c
drivers/net/cxgbe/cxgbe_pfvf.h
drivers/net/cxgbe/cxgbevf_ethdev.c

index a3ecf12..6721740 100644 (file)
@@ -24,6 +24,7 @@ L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
 Basic stats          = Y
+Extended stats       = Y
 Stats per queue      = Y
 EEPROM dump          = Y
 Registers dump       = Y
index 303d6f2..c8a25c9 100644 (file)
@@ -20,6 +20,7 @@ L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
 Basic stats          = Y
+Extended stats       = Y
 Stats per queue      = Y
 Multiprocess aware   = Y
 Linux                = Y
index 177eca3..a6b5c01 100644 (file)
@@ -881,15 +881,37 @@ static const struct cxgbe_dev_xstats_name_off cxgbe_dev_port_stats_strings[] = {
        {"rx_bg3_truncated_packets", offsetof(struct port_stats, rx_trunc3)},
 };
 
+static const struct cxgbe_dev_xstats_name_off
+cxgbevf_dev_port_stats_strings[] = {
+       {"tx_bytes", offsetof(struct port_stats, tx_octets)},
+       {"tx_broadcast_packets", offsetof(struct port_stats, tx_bcast_frames)},
+       {"tx_multicast_packets", offsetof(struct port_stats, tx_mcast_frames)},
+       {"tx_unicast_packets", offsetof(struct port_stats, tx_ucast_frames)},
+       {"tx_drop_packets", offsetof(struct port_stats, tx_drop)},
+       {"rx_broadcast_packets", offsetof(struct port_stats, rx_bcast_frames)},
+       {"rx_multicast_packets", offsetof(struct port_stats, rx_mcast_frames)},
+       {"rx_unicast_packets", offsetof(struct port_stats, rx_ucast_frames)},
+       {"rx_length_error_packets", offsetof(struct port_stats, rx_len_err)},
+};
+
 #define CXGBE_NB_RXQ_STATS RTE_DIM(cxgbe_dev_rxq_stats_strings)
 #define CXGBE_NB_TXQ_STATS RTE_DIM(cxgbe_dev_txq_stats_strings)
 #define CXGBE_NB_PORT_STATS RTE_DIM(cxgbe_dev_port_stats_strings)
+#define CXGBEVF_NB_PORT_STATS RTE_DIM(cxgbevf_dev_port_stats_strings)
 
 static u16 cxgbe_dev_xstats_count(struct port_info *pi)
 {
-       return CXGBE_NB_PORT_STATS +
-              (pi->n_tx_qsets * CXGBE_NB_TXQ_STATS) +
-              (pi->n_rx_qsets * CXGBE_NB_RXQ_STATS);
+       u16 count;
+
+       count = (pi->n_tx_qsets * CXGBE_NB_TXQ_STATS) +
+               (pi->n_rx_qsets * CXGBE_NB_RXQ_STATS);
+
+       if (is_pf4(pi->adapter) != 0)
+               count += CXGBE_NB_PORT_STATS;
+       else
+               count += CXGBEVF_NB_PORT_STATS;
+
+       return count;
 }
 
 static int cxgbe_dev_xstats(struct rte_eth_dev *dev,
@@ -900,20 +922,28 @@ static int cxgbe_dev_xstats(struct rte_eth_dev *dev,
        struct port_info *pi = dev->data->dev_private;
        struct adapter *adap = pi->adapter;
        struct sge *s = &adap->sge;
+       u16 count, i, qid, nstats;
        struct port_stats ps;
-       u16 count, i, qid;
        u64 *stats_ptr;
 
        count = cxgbe_dev_xstats_count(pi);
        if (size < count)
                return count;
 
-       /* port stats */
-       cxgbe_stats_get(pi, &ps);
+       if (is_pf4(adap) != 0) {
+               /* port stats for PF*/
+               cxgbe_stats_get(pi, &ps);
+               xstats_str = cxgbe_dev_port_stats_strings;
+               nstats = CXGBE_NB_PORT_STATS;
+       } else {
+               /* port stats for VF*/
+               cxgbevf_stats_get(pi, &ps);
+               xstats_str = cxgbevf_dev_port_stats_strings;
+               nstats = CXGBEVF_NB_PORT_STATS;
+       }
 
        count = 0;
-       xstats_str = cxgbe_dev_port_stats_strings;
-       for (i = 0; i < CXGBE_NB_PORT_STATS; i++, count++) {
+       for (i = 0; i < nstats; i++, count++) {
                if (xstats_names != NULL)
                        snprintf(xstats_names[count].name,
                                 sizeof(xstats_names[count].name),
@@ -970,9 +1000,9 @@ static int cxgbe_dev_xstats(struct rte_eth_dev *dev,
 }
 
 /* Get port extended statistics by ID. */
-static int cxgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev,
-                                     const uint64_t *ids, uint64_t *values,
-                                     unsigned int n)
+int cxgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev,
+                              const uint64_t *ids, uint64_t *values,
+                              unsigned int n)
 {
        struct port_info *pi = dev->data->dev_private;
        struct rte_eth_xstat *xstats_copy;
@@ -1005,9 +1035,9 @@ out_err:
 }
 
 /* Get names of port extended statistics by ID. */
-static int cxgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
-                                           struct rte_eth_xstat_name *xnames,
-                                           const uint64_t *ids, unsigned int n)
+int cxgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
+                                    struct rte_eth_xstat_name *xnames,
+                                    const uint64_t *ids, unsigned int n)
 {
        struct port_info *pi = dev->data->dev_private;
        struct rte_eth_xstat_name *xnames_copy;
@@ -1041,16 +1071,16 @@ out_err:
 }
 
 /* Get port extended statistics. */
-static int cxgbe_dev_xstats_get(struct rte_eth_dev *dev,
-                               struct rte_eth_xstat *xstats, unsigned int n)
+int cxgbe_dev_xstats_get(struct rte_eth_dev *dev,
+                        struct rte_eth_xstat *xstats, unsigned int n)
 {
        return cxgbe_dev_xstats(dev, NULL, xstats, n);
 }
 
 /* Get names of port extended statistics. */
-static int cxgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
-                                     struct rte_eth_xstat_name *xstats_names,
-                                     unsigned int n)
+int cxgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
+                              struct rte_eth_xstat_name *xstats_names,
+                              unsigned int n)
 {
        return cxgbe_dev_xstats(dev, xstats_names, NULL, n);
 }
index 801d699..3c7aee0 100644 (file)
@@ -52,4 +52,15 @@ uint16_t cxgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 uint16_t cxgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                         uint16_t nb_pkts);
 const uint32_t *cxgbe_dev_supported_ptypes_get(struct rte_eth_dev *eth_dev);
+int cxgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev,
+                              const uint64_t *ids, uint64_t *values,
+                              unsigned int n);
+int cxgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev,
+                                    struct rte_eth_xstat_name *xnames,
+                                    const uint64_t *ids, unsigned int n);
+int cxgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
+                              struct rte_eth_xstat_name *xstats_names,
+                              unsigned int n);
+int cxgbe_dev_xstats_get(struct rte_eth_dev *dev,
+                        struct rte_eth_xstat *xstats, unsigned int n);
 #endif /* _CXGBE_PFVF_H_ */
index bf1815c..4c80999 100644 (file)
@@ -54,22 +54,12 @@ static int cxgbevf_dev_stats_get(struct rte_eth_dev *eth_dev,
        eth_stats->oerrors  = ps.tx_drop;
 
        for (i = 0; i < pi->n_rx_qsets; i++) {
-               struct sge_eth_rxq *rxq =
-                       &s->ethrxq[pi->first_rxqset + i];
+               struct sge_eth_rxq *rxq = &s->ethrxq[pi->first_rxqset + i];
 
-               eth_stats->q_ipackets[i] = rxq->stats.pkts;
-               eth_stats->q_ibytes[i] = rxq->stats.rx_bytes;
-               eth_stats->ipackets += eth_stats->q_ipackets[i];
-               eth_stats->ibytes += eth_stats->q_ibytes[i];
+               eth_stats->ipackets += rxq->stats.pkts;
+               eth_stats->ibytes += rxq->stats.rx_bytes;
        }
 
-       for (i = 0; i < pi->n_tx_qsets; i++) {
-               struct sge_eth_txq *txq =
-                       &s->ethtxq[pi->first_txqset + i];
-
-               eth_stats->q_opackets[i] = txq->stats.pkts;
-               eth_stats->q_obytes[i] = txq->stats.tx_bytes;
-       }
        return 0;
 }
 
@@ -97,6 +87,10 @@ static const struct eth_dev_ops cxgbevf_eth_dev_ops = {
        .rx_queue_stop          = cxgbe_dev_rx_queue_stop,
        .rx_queue_release       = cxgbe_dev_rx_queue_release,
        .stats_get              = cxgbevf_dev_stats_get,
+       .xstats_get             = cxgbe_dev_xstats_get,
+       .xstats_get_by_id       = cxgbe_dev_xstats_get_by_id,
+       .xstats_get_names       = cxgbe_dev_xstats_get_names,
+       .xstats_get_names_by_id = cxgbe_dev_xstats_get_names_by_id,
        .mac_addr_set           = cxgbe_mac_addr_set,
 };