extern const struct ar8xxx_chip ar8327_chip;
extern const struct ar8xxx_chip ar8337_chip;
-#define AR8XXX_MIB_WORK_DELAY 2000 /* msecs */
-
#define MIB_DESC(_s , _o, _n) \
{ \
.size = (_s), \
static DEFINE_MUTEX(ar8xxx_dev_list_lock);
static LIST_HEAD(ar8xxx_dev_list);
+static void
+ar8xxx_mib_start(struct ar8xxx_priv *priv);
+static void
+ar8xxx_mib_stop(struct ar8xxx_priv *priv);
+
/* inspired by phy_poll_reset in drivers/net/phy/phy_device.c */
static int
ar8xxx_phy_poll_reset(struct mii_bus *bus)
return ret;
}
+int
+ar8xxx_sw_set_mib_poll_interval(struct switch_dev *dev,
+ const struct switch_attr *attr,
+ struct switch_val *val)
+{
+ struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
+
+ if (!ar8xxx_has_mib_counters(priv))
+ return -EOPNOTSUPP;
+
+ ar8xxx_mib_stop(priv);
+ priv->mib_poll_interval = val->value.i;
+ ar8xxx_mib_start(priv);
+
+ return 0;
+}
+
+int
+ar8xxx_sw_get_mib_poll_interval(struct switch_dev *dev,
+ const struct switch_attr *attr,
+ struct switch_val *val)
+{
+ struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
+
+ if (!ar8xxx_has_mib_counters(priv))
+ return -EOPNOTSUPP;
+ val->value.i = priv->mib_poll_interval;
+ return 0;
+}
+
int
ar8xxx_sw_set_mirror_rx_enable(struct switch_dev *dev,
const struct switch_attr *attr,
int i, len = 0;
bool mib_stats_empty = true;
- if (!ar8xxx_has_mib_counters(priv))
+ if (!ar8xxx_has_mib_counters(priv) || !priv->mib_poll_interval)
return -EOPNOTSUPP;
port = val->port_vlan;
struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
u64 *mib_stats;
- if (!ar8xxx_has_mib_counters(priv))
+ if (!ar8xxx_has_mib_counters(priv) || !priv->mib_poll_interval)
return -EOPNOTSUPP;
if (!(priv->chip->mib_rxb_id || priv->chip->mib_txb_id))
.description = "Reset all MIB counters",
.set = ar8xxx_sw_set_reset_mibs,
},
+ {
+ .type = SWITCH_TYPE_INT,
+ .name = "ar8xxx_mib_poll_interval",
+ .description = "MIB polling interval in msecs (0 to disable)",
+ .set = ar8xxx_sw_set_mib_poll_interval,
+ .get = ar8xxx_sw_get_mib_poll_interval
+ },
{
.type = SWITCH_TYPE_INT,
.name = "enable_mirror_rx",
static void
ar8xxx_mib_start(struct ar8xxx_priv *priv)
{
- if (!ar8xxx_has_mib_counters(priv))
+ if (!ar8xxx_has_mib_counters(priv) || !priv->mib_poll_interval)
return;
schedule_delayed_work(&priv->mib_work,
static void
ar8xxx_mib_stop(struct ar8xxx_priv *priv)
{
- if (!ar8xxx_has_mib_counters(priv))
+ if (!ar8xxx_has_mib_counters(priv) || !priv->mib_poll_interval)
return;
cancel_delayed_work_sync(&priv->mib_work);
ret = of_property_read_u32(priv->pdev->of_node, "qca,mib-poll-interval",
&priv->mib_poll_interval);
if (ret)
- priv->mib_poll_interval = AR8XXX_MIB_WORK_DELAY;
+ priv->mib_poll_interval = 0;
ret = ar8xxx_id_chip(priv);
if (ret)
ret = of_property_read_u32(priv->pdev->of_node, "qca,mib-poll-interval",
&priv->mib_poll_interval);
if (ret)
- priv->mib_poll_interval = AR8XXX_MIB_WORK_DELAY;
+ priv->mib_poll_interval = 0;
ret = ar8xxx_read_id(priv);
if (ret)