Some SoC families require table access to get the HW counters. A mutex is
required for this access - which will potentially cause a sleep in the
current context. This is not always possible with .get_stats64 because it
is also called in atomic contexts.
For these SoCs, the retrieval of the current counters in .get_stats64 is
skipped and the counters are simply retrieved a lot more often from the HW.
Signed-off-by: Sven Eckelmann <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/20631
Signed-off-by: Hauke Mehrtens <[email protected]>
static const u8 ipv6_all_hosts_mcast_addr_mask[ETH_ALEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-/* This interval needs to be short enough to prevent an undetected counter
- * overflow. The octet counters don't need to be considered for this, because
- * they are 64 bits on all platforms. Based on the possible packets per second
- * at the highest supported speeds, an interval of a minute is probably a safe
- * choice for the other counters.
- */
-#define RTLDSA_COUNTERS_POLL_INTERVAL (60 * HZ)
-
extern struct rtl83xx_soc_info soc_info;
static void rtldsa_init_counters(struct rtl838x_switch_priv *priv);
}
queue_delayed_work(priv->wq, &priv->counters_work,
- RTLDSA_COUNTERS_POLL_INTERVAL);
+ priv->r->stat_counter_poll_interval);
}
static void rtldsa_init_counters(struct rtl838x_switch_priv *priv)
INIT_DELAYED_WORK(&priv->counters_work, rtldsa_poll_counters);
queue_delayed_work(priv->wq, &priv->counters_work,
- RTLDSA_COUNTERS_POLL_INTERVAL);
+ priv->r->stat_counter_poll_interval);
}
static void rtldsa_get_strings(struct dsa_switch *ds,
.stat_counters_lock = rtldsa_counters_lock_register,
.stat_counters_unlock = rtldsa_counters_unlock_register,
.stat_update_counters_atomically = rtldsa_update_counters_atomically,
+ .stat_counter_poll_interval = RTLDSA_COUNTERS_POLL_INTERVAL,
.port_iso_ctrl = rtl838x_port_iso_ctrl,
.traffic_enable = rtl838x_traffic_enable,
.traffic_disable = rtl838x_traffic_disable,
#define MAX_SMACS 64
#define DSCP_MAP_MAX 64
+/* This interval needs to be short enough to prevent an undetected counter
+ * overflow. The octet counters don't need to be considered for this, because
+ * they are 64 bits on all platforms. Based on the possible packets per second
+ * at the highest supported speeds, an interval of a minute is probably a safe
+ * choice for the other counters.
+ */
+#define RTLDSA_COUNTERS_POLL_INTERVAL (60 * HZ)
+
+/* Some SoC families require table access to get the HW counters. A mutex is
+ * required for this access - which will potentially cause a sleep in the
+ * current context. This is not always possible with .get_stats64 because it
+ * is also called in atomic contexts.
+ *
+ * For these SoCs, the retrieval of the current counters in .get_stats64 is
+ * skipped and the counters are simply retrieved a lot more often from the HW.
+ */
+#define RTLDSA_COUNTERS_FAST_POLL_INTERVAL (3 * HZ)
+
enum phy_type {
PHY_NONE = 0,
PHY_RTL838X_SDS = 1,
* update is therefore not atomic.
*/
void (*stat_update_counters_atomically)(struct rtl838x_switch_priv *priv, int port);
+ unsigned long stat_counter_poll_interval;
int (*port_iso_ctrl)(int p);
void (*traffic_enable)(int source, int dest);
void (*traffic_disable)(int source, int dest);
.stat_counters_lock = rtldsa_counters_lock_register,
.stat_counters_unlock = rtldsa_counters_unlock_register,
.stat_update_counters_atomically = rtldsa_update_counters_atomically,
+ .stat_counter_poll_interval = RTLDSA_COUNTERS_POLL_INTERVAL,
.traffic_enable = rtl839x_traffic_enable,
.traffic_disable = rtl839x_traffic_disable,
.traffic_set = rtl839x_traffic_set,
.stat_counters_lock = rtldsa_counters_lock_register,
.stat_counters_unlock = rtldsa_counters_unlock_register,
.stat_update_counters_atomically = rtldsa_update_counters_atomically,
+ .stat_counter_poll_interval = RTLDSA_COUNTERS_POLL_INTERVAL,
.traffic_enable = rtl930x_traffic_enable,
.traffic_disable = rtl930x_traffic_disable,
.traffic_set = rtl930x_traffic_set,
.stat_port_table_read = rtldsa_931x_stat_port_table_read,
.stat_counters_lock = rtldsa_counters_lock_table,
.stat_counters_unlock = rtldsa_counters_unlock_table,
+ .stat_counter_poll_interval = RTLDSA_COUNTERS_FAST_POLL_INTERVAL,
.traffic_enable = rtl931x_traffic_enable,
.traffic_disable = rtl931x_traffic_disable,
.traffic_set = rtl931x_traffic_set,