nfp: abm: expose the internal stats in ethtool
authorJakub Kicinski <jakub.kicinski@netronome.com>
Sat, 26 May 2018 04:53:33 +0000 (21:53 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 29 May 2018 13:49:16 +0000 (09:49 -0400)
There is a handful of statistics exposing some internal details
of the implementation.  Expose those via ethtool.

Signed-off-by: Jakub Kicinski <jakub.kicinski@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.c
drivers/net/ethernet/netronome/nfp/abm/main.h

index d2d9ca7a727c06077cb744c2f80f8c857ba4cca3..79fc9147c012e233ebfedf9757ed8197ffba37a2 100644 (file)
@@ -50,6 +50,8 @@
 
 #define NFP_QMSTAT_SYM_NAME    "_abi_nfdqm%u_stats"
 #define NFP_QMSTAT_STRIDE      32
+#define NFP_QMSTAT_NON_STO     0
+#define NFP_QMSTAT_STO         8
 #define NFP_QMSTAT_DROP                16
 #define NFP_QMSTAT_ECN         24
 
@@ -142,6 +144,26 @@ int nfp_abm_ctrl_set_all_q_lvls(struct nfp_abm_link *alink, u32 val)
        return 0;
 }
 
+u64 nfp_abm_ctrl_stat_non_sto(struct nfp_abm_link *alink, unsigned int i)
+{
+       u64 val;
+
+       if (nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, NFP_QMSTAT_STRIDE,
+                             NFP_QMSTAT_NON_STO, i, true, &val))
+               return 0;
+       return val;
+}
+
+u64 nfp_abm_ctrl_stat_sto(struct nfp_abm_link *alink, unsigned int i)
+{
+       u64 val;
+
+       if (nfp_abm_ctrl_stat(alink, alink->abm->qm_stats, NFP_QMSTAT_STRIDE,
+                             NFP_QMSTAT_STO, i, true, &val))
+               return 0;
+       return val;
+}
+
 int nfp_abm_ctrl_read_stats(struct nfp_abm_link *alink,
                            struct nfp_alink_stats *stats)
 {
index d0c21899a8b778473003c2872304e03f19463df9..4e89159f13d3bbfdc619cee495fb6ce9c3f75ff8 100644 (file)
@@ -497,6 +497,53 @@ static void nfp_abm_vnic_free(struct nfp_app *app, struct nfp_net *nn)
        kfree(alink);
 }
 
+static u64 *
+nfp_abm_port_get_stats(struct nfp_app *app, struct nfp_port *port, u64 *data)
+{
+       struct nfp_repr *repr = netdev_priv(port->netdev);
+       struct nfp_abm_link *alink;
+       unsigned int i;
+
+       if (port->type != NFP_PORT_PF_PORT)
+               return data;
+       alink = repr->app_priv;
+       for (i = 0; i < alink->vnic->dp.num_r_vecs; i++) {
+               *data++ = nfp_abm_ctrl_stat_non_sto(alink, i);
+               *data++ = nfp_abm_ctrl_stat_sto(alink, i);
+       }
+       return data;
+}
+
+static int
+nfp_abm_port_get_stats_count(struct nfp_app *app, struct nfp_port *port)
+{
+       struct nfp_repr *repr = netdev_priv(port->netdev);
+       struct nfp_abm_link *alink;
+
+       if (port->type != NFP_PORT_PF_PORT)
+               return 0;
+       alink = repr->app_priv;
+       return alink->vnic->dp.num_r_vecs * 2;
+}
+
+static u8 *
+nfp_abm_port_get_stats_strings(struct nfp_app *app, struct nfp_port *port,
+                              u8 *data)
+{
+       struct nfp_repr *repr = netdev_priv(port->netdev);
+       struct nfp_abm_link *alink;
+       unsigned int i;
+
+       if (port->type != NFP_PORT_PF_PORT)
+               return data;
+       alink = repr->app_priv;
+       for (i = 0; i < alink->vnic->dp.num_r_vecs; i++) {
+               data = nfp_pr_et(data, "q%u_no_wait", i);
+               data = nfp_pr_et(data, "q%u_delayed", i);
+       }
+       return data;
+}
+
 static int nfp_abm_init(struct nfp_app *app)
 {
        struct nfp_pf *pf = app->pf;
@@ -575,6 +622,10 @@ const struct nfp_app_type app_abm = {
        .vnic_alloc     = nfp_abm_vnic_alloc,
        .vnic_free      = nfp_abm_vnic_free,
 
+       .port_get_stats         = nfp_abm_port_get_stats,
+       .port_get_stats_count   = nfp_abm_port_get_stats_count,
+       .port_get_stats_strings = nfp_abm_port_get_stats_strings,
+
        .setup_tc       = nfp_abm_setup_tc,
 
        .eswitch_mode_get       = nfp_abm_eswitch_mode_get,
index 93a3b79cf468b554a5a3c6b6d3958f38f232fda9..09fd15847961dd780acf07e591a7bf8dbcb2c042 100644 (file)
@@ -123,6 +123,8 @@ int nfp_abm_ctrl_read_stats(struct nfp_abm_link *alink,
                            struct nfp_alink_stats *stats);
 int nfp_abm_ctrl_read_xstats(struct nfp_abm_link *alink,
                             struct nfp_alink_xstats *xstats);
+u64 nfp_abm_ctrl_stat_non_sto(struct nfp_abm_link *alink, unsigned int i);
+u64 nfp_abm_ctrl_stat_sto(struct nfp_abm_link *alink, unsigned int i);
 int nfp_abm_ctrl_qm_enable(struct nfp_abm *abm);
 int nfp_abm_ctrl_qm_disable(struct nfp_abm *abm);
 #endif