Loading drivers/net/dsa/mv88e6xxx.c +36 −27 Original line number Diff line number Diff line Loading @@ -681,52 +681,61 @@ static void _mv88e6xxx_get_strings(struct dsa_switch *ds, } } static void _mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int nr_stats, static uint64_t _mv88e6xxx_get_ethtool_stat(struct dsa_switch *ds, int stat, struct mv88e6xxx_hw_stat *stats, int port, uint64_t *data) int port) { struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); int ret; int i; mutex_lock(&ps->smi_mutex); ret = _mv88e6xxx_stats_snapshot(ds, port); if (ret < 0) { mutex_unlock(&ps->smi_mutex); return; } /* Read each of the counters. */ for (i = 0; i < nr_stats; i++) { struct mv88e6xxx_hw_stat *s = stats + i; struct mv88e6xxx_hw_stat *s = stats + stat; u32 low; u32 high = 0; int ret; u64 value; if (s->reg >= 0x100) { ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), s->reg - 0x100); if (ret < 0) goto error; return UINT64_MAX; low = ret; if (s->sizeof_stat == 4) { ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), s->reg - 0x100 + 1); if (ret < 0) goto error; return UINT64_MAX; high = ret; } data[i] = (((u64)high) << 16) | low; continue; } } else { _mv88e6xxx_stats_read(ds, s->reg, &low); if (s->sizeof_stat == 8) _mv88e6xxx_stats_read(ds, s->reg + 1, &high); } value = (((u64)high) << 16) | low; return value; } static void _mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int nr_stats, struct mv88e6xxx_hw_stat *stats, int port, uint64_t *data) { struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); int ret; int i; mutex_lock(&ps->smi_mutex); data[i] = (((u64)high) << 32) | low; ret = _mv88e6xxx_stats_snapshot(ds, port); if (ret < 0) { mutex_unlock(&ps->smi_mutex); return; } error: /* Read each of the counters. */ for (i = 0; i < nr_stats; i++) data[i] = _mv88e6xxx_get_ethtool_stat(ds, i, stats, port); mutex_unlock(&ps->smi_mutex); } Loading drivers/net/dsa/mv88e6xxx.h +4 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,10 @@ #ifndef __MV88E6XXX_H #define __MV88E6XXX_H #ifndef UINT64_MAX #define UINT64_MAX (u64)(~((u64)0)) #endif #define SMI_CMD 0x00 #define SMI_CMD_BUSY BIT(15) #define SMI_CMD_CLAUSE_22 BIT(12) Loading Loading
drivers/net/dsa/mv88e6xxx.c +36 −27 Original line number Diff line number Diff line Loading @@ -681,52 +681,61 @@ static void _mv88e6xxx_get_strings(struct dsa_switch *ds, } } static void _mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int nr_stats, static uint64_t _mv88e6xxx_get_ethtool_stat(struct dsa_switch *ds, int stat, struct mv88e6xxx_hw_stat *stats, int port, uint64_t *data) int port) { struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); int ret; int i; mutex_lock(&ps->smi_mutex); ret = _mv88e6xxx_stats_snapshot(ds, port); if (ret < 0) { mutex_unlock(&ps->smi_mutex); return; } /* Read each of the counters. */ for (i = 0; i < nr_stats; i++) { struct mv88e6xxx_hw_stat *s = stats + i; struct mv88e6xxx_hw_stat *s = stats + stat; u32 low; u32 high = 0; int ret; u64 value; if (s->reg >= 0x100) { ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), s->reg - 0x100); if (ret < 0) goto error; return UINT64_MAX; low = ret; if (s->sizeof_stat == 4) { ret = _mv88e6xxx_reg_read(ds, REG_PORT(port), s->reg - 0x100 + 1); if (ret < 0) goto error; return UINT64_MAX; high = ret; } data[i] = (((u64)high) << 16) | low; continue; } } else { _mv88e6xxx_stats_read(ds, s->reg, &low); if (s->sizeof_stat == 8) _mv88e6xxx_stats_read(ds, s->reg + 1, &high); } value = (((u64)high) << 16) | low; return value; } static void _mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, int nr_stats, struct mv88e6xxx_hw_stat *stats, int port, uint64_t *data) { struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); int ret; int i; mutex_lock(&ps->smi_mutex); data[i] = (((u64)high) << 32) | low; ret = _mv88e6xxx_stats_snapshot(ds, port); if (ret < 0) { mutex_unlock(&ps->smi_mutex); return; } error: /* Read each of the counters. */ for (i = 0; i < nr_stats; i++) data[i] = _mv88e6xxx_get_ethtool_stat(ds, i, stats, port); mutex_unlock(&ps->smi_mutex); } Loading
drivers/net/dsa/mv88e6xxx.h +4 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,10 @@ #ifndef __MV88E6XXX_H #define __MV88E6XXX_H #ifndef UINT64_MAX #define UINT64_MAX (u64)(~((u64)0)) #endif #define SMI_CMD 0x00 #define SMI_CMD_BUSY BIT(15) #define SMI_CMD_CLAUSE_22 BIT(12) Loading