kernel: backport fixes for realtek r8152
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 771-v6.0-02-net-dsa-qca8k-make-mib-autocast-feature-optional.patch
1 From 533c64bca62a8654f00698bc893f639013e38c7b Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Wed, 27 Jul 2022 13:35:11 +0200
4 Subject: [PATCH 02/14] net: dsa: qca8k: make mib autocast feature optional
5
6 Some switch may not support mib autocast feature and require the legacy
7 way of reading the regs directly.
8 Make the mib autocast feature optional and permit to declare support for
9 it using match_data struct in a dedicated qca8k_info_ops struct.
10
11 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
12 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
13 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
14 ---
15 drivers/net/dsa/qca/qca8k.c | 11 +++++++++--
16 drivers/net/dsa/qca/qca8k.h | 5 +++++
17 2 files changed, 14 insertions(+), 2 deletions(-)
18
19 --- a/drivers/net/dsa/qca/qca8k.c
20 +++ b/drivers/net/dsa/qca/qca8k.c
21 @@ -2254,8 +2254,8 @@ qca8k_get_ethtool_stats(struct dsa_switc
22 u32 hi = 0;
23 int ret;
24
25 - if (priv->mgmt_master &&
26 - qca8k_get_ethtool_stats_eth(ds, port, data) > 0)
27 + if (priv->mgmt_master && priv->info->ops->autocast_mib &&
28 + priv->info->ops->autocast_mib(ds, port, data) > 0)
29 return;
30
31 for (i = 0; i < priv->info->mib_count; i++) {
32 @@ -3187,20 +3187,27 @@ static int qca8k_resume(struct device *d
33 static SIMPLE_DEV_PM_OPS(qca8k_pm_ops,
34 qca8k_suspend, qca8k_resume);
35
36 +static const struct qca8k_info_ops qca8xxx_ops = {
37 + .autocast_mib = qca8k_get_ethtool_stats_eth,
38 +};
39 +
40 static const struct qca8k_match_data qca8327 = {
41 .id = QCA8K_ID_QCA8327,
42 .reduced_package = true,
43 .mib_count = QCA8K_QCA832X_MIB_COUNT,
44 + .ops = &qca8xxx_ops,
45 };
46
47 static const struct qca8k_match_data qca8328 = {
48 .id = QCA8K_ID_QCA8327,
49 .mib_count = QCA8K_QCA832X_MIB_COUNT,
50 + .ops = &qca8xxx_ops,
51 };
52
53 static const struct qca8k_match_data qca833x = {
54 .id = QCA8K_ID_QCA8337,
55 .mib_count = QCA8K_QCA833X_MIB_COUNT,
56 + .ops = &qca8xxx_ops,
57 };
58
59 static const struct of_device_id qca8k_of_match[] = {
60 --- a/drivers/net/dsa/qca/qca8k.h
61 +++ b/drivers/net/dsa/qca/qca8k.h
62 @@ -324,10 +324,15 @@ enum qca8k_mid_cmd {
63 QCA8K_MIB_CAST = 3,
64 };
65
66 +struct qca8k_info_ops {
67 + int (*autocast_mib)(struct dsa_switch *ds, int port, u64 *data);
68 +};
69 +
70 struct qca8k_match_data {
71 u8 id;
72 bool reduced_package;
73 u8 mib_count;
74 + const struct qca8k_info_ops *ops;
75 };
76
77 enum {