提交 877e7b7c 编写于 作者: C Colin Foster 提交者: Paolo Abeni

net: mscc: ocelot: issue a warning if stats are incorrectly ordered

Ocelot uses regmap_bulk_read() operations to efficiently read stats
registers. Currently the implementation relies on the stats layout to be
ordered to be most efficient.

Issue a warning if any future implementations happen to break this pattern.
Signed-off-by: NColin Foster <colin.foster@in-advantage.com>
Co-developed-by: NVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: NVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
上级 a3bb8f52
......@@ -602,7 +602,7 @@ EXPORT_SYMBOL(ocelot_port_get_stats64);
static int ocelot_prepare_stats_regions(struct ocelot *ocelot)
{
struct ocelot_stats_region *region = NULL;
unsigned int last;
unsigned int last = 0;
int i;
INIT_LIST_HEAD(&ocelot->stats_regions);
......@@ -619,6 +619,12 @@ static int ocelot_prepare_stats_regions(struct ocelot *ocelot)
if (!region)
return -ENOMEM;
/* enum ocelot_stat must be kept sorted in the same
* order as ocelot_stats_layout[i].reg in order to have
* efficient bulking
*/
WARN_ON(last >= ocelot_stats_layout[i].reg);
region->base = ocelot_stats_layout[i].reg;
region->count = 1;
list_add_tail(&region->node, &ocelot->stats_regions);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册