[net-next RFC PATCH 3/4] net: dsa: qca8k: rework mib autocast handling

Christian Marangi
2022-07-16T17:50:41Z

In preparation for code split, move the autocast mib function used to
receive mib data from eth packet in priv struct and use that in
get_ethtool_stats instead of referencing the function directly. This is
needed as the get_ethtool_stats function will be moved to a common file.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/net/dsa/qca/qca8k.c | 7 +++++--
drivers/net/dsa/qca/qca8k.h | 1 +
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/qca/qca8k.c b/drivers/net/dsa/qca/qca8k.c
index fd738d718cd6..e527d15d5065 100644
--- a/drivers/net/dsa/qca/qca8k.c
+++ b/drivers/net/dsa/qca/qca8k.c
@@ -2109,8 +2109,8 @@ qca8k_get_ethtool_stats(struct dsa_switch *ds, int port,
u32 hi = 0;
int ret;

- if (priv->mgmt_master &&
- qca8k_get_ethtool_stats_eth(ds, port, data) > 0)
+ if (priv->mgmt_master && priv->autocast_mib &&
+ priv->autocast_mib(ds, port, data) > 0)
return;

match_data = of_device_get_match_data(priv->dev);
@@ -3177,6 +3177,9 @@ qca8k_sw_probe(struct mdio_device *mdiodev)
mutex_init(&priv->mib_eth_data.mutex);
init_completion(&priv->mib_eth_data.rw_done);

+ /* Assign autocast_mib function as it's supported by this switch */
+ priv->autocast_mib = &qca8k_get_ethtool_stats_eth;
+
priv->ds->dev = &mdiodev->dev;
priv->ds->num_ports = QCA8K_NUM_PORTS;
priv->ds->priv = priv;
diff --git a/drivers/net/dsa/qca/qca8k.h b/drivers/net/dsa/qca/qca8k.h
index 22ece14e06dc..a306638a7100 100644
--- a/drivers/net/dsa/qca/qca8k.h
+++ b/drivers/net/dsa/qca/qca8k.h
@@ -403,6 +403,7 @@ struct qca8k_priv {
struct qca8k_mdio_cache mdio_cache;
struct qca8k_pcs pcs_port_0;
struct qca8k_pcs pcs_port_6;
+ int (*autocast_mib)(struct dsa_switch *ds, int port, u64 *data);
};

struct qca8k_mib_desc {
--
2.36.1