]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: add optional stats64 support
authorOleksij Rempel <o.rempel@pengutronix.de>
Mon, 11 Jan 2021 10:46:57 +0000 (11:46 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 13 Jan 2021 04:17:09 +0000 (20:17 -0800)
Allow DSA drivers to export stats64

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/dsa.h
net/dsa/slave.c

index c9a3dd7588dfeec475727fe19a44d19538a66575..c3485ba6c3125b8e32301df340ed643a14d17fdf 100644 (file)
@@ -482,7 +482,7 @@ struct dsa_switch_ops {
        void    (*phylink_fixed_state)(struct dsa_switch *ds, int port,
                                       struct phylink_link_state *state);
        /*
-        * ethtool hardware statistics.
+        * Port statistics counters.
         */
        void    (*get_strings)(struct dsa_switch *ds, int port,
                               u32 stringset, uint8_t *data);
@@ -491,6 +491,8 @@ struct dsa_switch_ops {
        int     (*get_sset_count)(struct dsa_switch *ds, int port, int sset);
        void    (*get_ethtool_phy_stats)(struct dsa_switch *ds,
                                         int port, uint64_t *data);
+       void    (*get_stats64)(struct dsa_switch *ds, int port,
+                                  struct rtnl_link_stats64 *s);
 
        /*
         * ethtool Wake-on-LAN
index 5d7f6cada6a81bc1138cbdf5b397f72f9588d56e..5a1769602e65350fe2944f21593ff84b10a67221 100644 (file)
@@ -1569,6 +1569,18 @@ static struct devlink_port *dsa_slave_get_devlink_port(struct net_device *dev)
        return dp->ds->devlink ? &dp->devlink_port : NULL;
 }
 
+static void dsa_slave_get_stats64(struct net_device *dev,
+                                 struct rtnl_link_stats64 *s)
+{
+       struct dsa_port *dp = dsa_slave_to_port(dev);
+       struct dsa_switch *ds = dp->ds;
+
+       if (ds->ops->get_stats64)
+               ds->ops->get_stats64(ds, dp->index, s);
+       else
+               dev_get_tstats64(dev, s);
+}
+
 static const struct net_device_ops dsa_slave_netdev_ops = {
        .ndo_open               = dsa_slave_open,
        .ndo_stop               = dsa_slave_close,
@@ -1588,7 +1600,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = {
 #endif
        .ndo_get_phys_port_name = dsa_slave_get_phys_port_name,
        .ndo_setup_tc           = dsa_slave_setup_tc,
-       .ndo_get_stats64        = dev_get_tstats64,
+       .ndo_get_stats64        = dsa_slave_get_stats64,
        .ndo_get_port_parent_id = dsa_slave_get_port_parent_id,
        .ndo_vlan_rx_add_vid    = dsa_slave_vlan_rx_add_vid,
        .ndo_vlan_rx_kill_vid   = dsa_slave_vlan_rx_kill_vid,