Message ID | 20220210041345.321216-3-colin.foster@in-advantage.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | use bulk reads for ocelot statistics | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 7 of 7 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 59 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Wed, Feb 09, 2022 at 08:13:42PM -0800, Colin Foster wrote: > The ocelot_update_stats function only needs to read from one port, yet it > was updating the stats for all ports. Update to only read the stats that > are necessary. > > Signed-off-by: Colin Foster <colin.foster@in-advantage.com> > --- Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> > drivers/net/ethernet/mscc/ocelot.c | 33 +++++++++++++++--------------- > 1 file changed, 16 insertions(+), 17 deletions(-) > > diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c > index 6933dff1dd37..ab36732e7d3f 100644 > --- a/drivers/net/ethernet/mscc/ocelot.c > +++ b/drivers/net/ethernet/mscc/ocelot.c > @@ -1738,27 +1738,24 @@ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) > EXPORT_SYMBOL(ocelot_get_strings); > > /* Caller must hold &ocelot->stats_lock */ > -static void ocelot_update_stats(struct ocelot *ocelot) > +static void ocelot_update_stats_for_port(struct ocelot *ocelot, int port) If you need to resend, I think a name more consistent with the rest of the driver would be "ocelot_port_update_stats". > { > - int i, j; > + int j; > > - for (i = 0; i < ocelot->num_phys_ports; i++) { > - /* Configure the port to read the stats from */ > - ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(i), SYS_STAT_CFG); > + /* Configure the port to read the stats from */ > + ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port), SYS_STAT_CFG); > > - for (j = 0; j < ocelot->num_stats; j++) { > - u32 val; > - unsigned int idx = i * ocelot->num_stats + j; > + for (j = 0; j < ocelot->num_stats; j++) { > + u32 val; > + unsigned int idx = port * ocelot->num_stats + j; > > - val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, > - ocelot->stats_layout[j].offset); > + val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, > + ocelot->stats_layout[j].offset); > > - if (val < (ocelot->stats[idx] & U32_MAX)) > - ocelot->stats[idx] += (u64)1 << 32; > + if (val < (ocelot->stats[idx] & U32_MAX)) > + ocelot->stats[idx] += (u64)1 << 32; > > - ocelot->stats[idx] = (ocelot->stats[idx] & > - ~(u64)U32_MAX) + val; > - } > + ocelot->stats[idx] = (ocelot->stats[idx] & ~(u64)U32_MAX) + val; > } > } > > @@ -1767,9 +1764,11 @@ static void ocelot_check_stats_work(struct work_struct *work) > struct delayed_work *del_work = to_delayed_work(work); > struct ocelot *ocelot = container_of(del_work, struct ocelot, > stats_work); > + int i; > > mutex_lock(&ocelot->stats_lock); > - ocelot_update_stats(ocelot); > + for (i = 0; i < ocelot->num_phys_ports; i++) > + ocelot_update_stats_for_port(ocelot, i); > mutex_unlock(&ocelot->stats_lock); > > queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, > @@ -1783,7 +1782,7 @@ void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) > mutex_lock(&ocelot->stats_lock); > > /* check and update now */ > - ocelot_update_stats(ocelot); > + ocelot_update_stats_for_port(ocelot, port); > > /* Copy all counters */ > for (i = 0; i < ocelot->num_stats; i++) > -- > 2.25.1 >
diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 6933dff1dd37..ab36732e7d3f 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -1738,27 +1738,24 @@ void ocelot_get_strings(struct ocelot *ocelot, int port, u32 sset, u8 *data) EXPORT_SYMBOL(ocelot_get_strings); /* Caller must hold &ocelot->stats_lock */ -static void ocelot_update_stats(struct ocelot *ocelot) +static void ocelot_update_stats_for_port(struct ocelot *ocelot, int port) { - int i, j; + int j; - for (i = 0; i < ocelot->num_phys_ports; i++) { - /* Configure the port to read the stats from */ - ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(i), SYS_STAT_CFG); + /* Configure the port to read the stats from */ + ocelot_write(ocelot, SYS_STAT_CFG_STAT_VIEW(port), SYS_STAT_CFG); - for (j = 0; j < ocelot->num_stats; j++) { - u32 val; - unsigned int idx = i * ocelot->num_stats + j; + for (j = 0; j < ocelot->num_stats; j++) { + u32 val; + unsigned int idx = port * ocelot->num_stats + j; - val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, - ocelot->stats_layout[j].offset); + val = ocelot_read_rix(ocelot, SYS_COUNT_RX_OCTETS, + ocelot->stats_layout[j].offset); - if (val < (ocelot->stats[idx] & U32_MAX)) - ocelot->stats[idx] += (u64)1 << 32; + if (val < (ocelot->stats[idx] & U32_MAX)) + ocelot->stats[idx] += (u64)1 << 32; - ocelot->stats[idx] = (ocelot->stats[idx] & - ~(u64)U32_MAX) + val; - } + ocelot->stats[idx] = (ocelot->stats[idx] & ~(u64)U32_MAX) + val; } } @@ -1767,9 +1764,11 @@ static void ocelot_check_stats_work(struct work_struct *work) struct delayed_work *del_work = to_delayed_work(work); struct ocelot *ocelot = container_of(del_work, struct ocelot, stats_work); + int i; mutex_lock(&ocelot->stats_lock); - ocelot_update_stats(ocelot); + for (i = 0; i < ocelot->num_phys_ports; i++) + ocelot_update_stats_for_port(ocelot, i); mutex_unlock(&ocelot->stats_lock); queue_delayed_work(ocelot->stats_queue, &ocelot->stats_work, @@ -1783,7 +1782,7 @@ void ocelot_get_ethtool_stats(struct ocelot *ocelot, int port, u64 *data) mutex_lock(&ocelot->stats_lock); /* check and update now */ - ocelot_update_stats(ocelot); + ocelot_update_stats_for_port(ocelot, port); /* Copy all counters */ for (i = 0; i < ocelot->num_stats; i++)
The ocelot_update_stats function only needs to read from one port, yet it was updating the stats for all ports. Update to only read the stats that are necessary. Signed-off-by: Colin Foster <colin.foster@in-advantage.com> --- drivers/net/ethernet/mscc/ocelot.c | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-)