nfp: abm: switch to extended stats for reading packet/byte counts
authorJakub Kicinski <jakub.kicinski@netronome.com>
Mon, 19 Nov 2018 23:21:40 +0000 (15:21 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 20 Nov 2018 02:53:45 +0000 (18:53 -0800)
In PRIO-enabled FW read the statistics from per-band symbol, rather
than from the standard per-PCIe-queue counters.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: John Hurley <john.hurley@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/abm/ctrl.c
drivers/net/ethernet/netronome/nfp/abm/main.h

index 8b2598a223de3ce32a50e16b8ea4ba9900d06362..013ba6c85d2b3e23148a71b2800067f2eae73d75 100644 (file)
 #define NFP_QMSTAT_DROP                16
 #define NFP_QMSTAT_ECN         24
 
+#define NFP_Q_STAT_SYM_NAME    "_abi_nfd_rxq_stats%u%s"
+#define NFP_Q_STAT_STRIDE      16
+#define NFP_Q_STAT_PKTS                0
+#define NFP_Q_STAT_BYTES       8
+
 static int
 nfp_abm_ctrl_stat(struct nfp_abm_link *alink, const struct nfp_rtsym *sym,
                  unsigned int stride, unsigned int offset, unsigned int band,
@@ -109,14 +114,42 @@ u64 nfp_abm_ctrl_stat_sto(struct nfp_abm_link *alink, unsigned int i)
        return val;
 }
 
+static int
+nfp_abm_ctrl_stat_basic(struct nfp_abm_link *alink, unsigned int band,
+                       unsigned int queue, unsigned int off, u64 *val)
+{
+       if (!nfp_abm_has_prio(alink->abm)) {
+               if (!band) {
+                       unsigned int id = alink->queue_base + queue;
+
+                       *val = nn_readq(alink->vnic,
+                                       NFP_NET_CFG_RXR_STATS(id) + off);
+               } else {
+                       *val = 0;
+               }
+
+               return 0;
+       } else {
+               return nfp_abm_ctrl_stat(alink, alink->abm->q_stats,
+                                        NFP_Q_STAT_STRIDE, off, band, queue,
+                                        true, val);
+       }
+}
+
 int nfp_abm_ctrl_read_q_stats(struct nfp_abm_link *alink, unsigned int band,
                              unsigned int queue, struct nfp_alink_stats *stats)
 {
        int err;
 
-       stats->tx_pkts += nn_readq(alink->vnic, NFP_NET_CFG_RXR_STATS(queue));
-       stats->tx_bytes += nn_readq(alink->vnic,
-                                   NFP_NET_CFG_RXR_STATS(queue) + 8);
+       err = nfp_abm_ctrl_stat_basic(alink, band, queue, NFP_Q_STAT_PKTS,
+                                     &stats->tx_pkts);
+       if (err)
+               return err;
+
+       err = nfp_abm_ctrl_stat_basic(alink, band, queue, NFP_Q_STAT_BYTES,
+                                     &stats->tx_bytes);
+       if (err)
+               return err;
 
        err = nfp_abm_ctrl_stat(alink, alink->abm->q_lvls, NFP_QLVL_STRIDE,
                                NFP_QLVL_BLOG_BYTES, band, queue, false,
@@ -251,5 +284,13 @@ int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm)
                return PTR_ERR(sym);
        abm->qm_stats = sym;
 
+       if (nfp_abm_has_prio(abm)) {
+               sym = nfp_abm_ctrl_find_q_rtsym(abm, NFP_Q_STAT_SYM_NAME,
+                                               NFP_Q_STAT_STRIDE);
+               if (IS_ERR(sym))
+                       return PTR_ERR(sym);
+               abm->q_stats = sym;
+       }
+
        return 0;
 }
index b18a699dac5098143a6e5586ad5bb7e05d54fac0..054228c29184936685e6eb020f35e5f316acb77c 100644 (file)
@@ -38,6 +38,7 @@ struct nfp_net;
  *                     in switchdev mode
  * @q_lvls:    queue level control area
  * @qm_stats:  queue statistics symbol
+ * @q_stats:   basic queue statistics (only in per-band case)
  */
 struct nfp_abm {
        struct nfp_app *app;
@@ -53,6 +54,7 @@ struct nfp_abm {
        enum devlink_eswitch_mode eswitch_mode;
        const struct nfp_rtsym *q_lvls;
        const struct nfp_rtsym *qm_stats;
+       const struct nfp_rtsym *q_stats;
 };
 
 /**