net: mscc: ocelot: look up the filters in flower_stats() and flower_destroy()
Currently a new filter is created, containing just enough correct information to be able to call ocelot_vcap_block_find_filter_by_index() on it. This will be limiting us in the future, when we'll have more metadata associated with a filter, which will matter in the stats() and destroy() callbacks, and which we can't make up on the spot. For example, we'll start "offloading" some dummy tc filter entries for the TCAM skeleton, but we won't actually be adding them to the hardware, or to block->rules. So, it makes sense to avoid deleting those rules too. That's the kind of thing which is difficult to determine unless we look up the real filter. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
085f5b9162
commit
98642d1aa2
|
@ -234,28 +234,33 @@ EXPORT_SYMBOL_GPL(ocelot_cls_flower_replace);
|
||||||
int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
|
int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
|
||||||
struct flow_cls_offload *f, bool ingress)
|
struct flow_cls_offload *f, bool ingress)
|
||||||
{
|
{
|
||||||
struct ocelot_vcap_filter filter;
|
struct ocelot_vcap_block *block = &ocelot->block;
|
||||||
|
struct ocelot_vcap_filter *filter;
|
||||||
|
|
||||||
filter.prio = f->common.prio;
|
filter = ocelot_vcap_block_find_filter_by_id(block, f->cookie);
|
||||||
filter.id = f->cookie;
|
if (!filter)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return ocelot_vcap_filter_del(ocelot, &filter);
|
return ocelot_vcap_filter_del(ocelot, filter);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ocelot_cls_flower_destroy);
|
EXPORT_SYMBOL_GPL(ocelot_cls_flower_destroy);
|
||||||
|
|
||||||
int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
|
int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
|
||||||
struct flow_cls_offload *f, bool ingress)
|
struct flow_cls_offload *f, bool ingress)
|
||||||
{
|
{
|
||||||
struct ocelot_vcap_filter filter;
|
struct ocelot_vcap_block *block = &ocelot->block;
|
||||||
|
struct ocelot_vcap_filter *filter;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
filter.prio = f->common.prio;
|
filter = ocelot_vcap_block_find_filter_by_id(block, f->cookie);
|
||||||
filter.id = f->cookie;
|
if (!filter)
|
||||||
ret = ocelot_vcap_filter_stats_update(ocelot, &filter);
|
return 0;
|
||||||
|
|
||||||
|
ret = ocelot_vcap_filter_stats_update(ocelot, filter);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
flow_stats_update(&f->stats, 0x0, filter.stats.pkts, 0, 0x0,
|
flow_stats_update(&f->stats, 0x0, filter->stats.pkts, 0, 0x0,
|
||||||
FLOW_ACTION_HW_STATS_IMMEDIATE);
|
FLOW_ACTION_HW_STATS_IMMEDIATE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -994,7 +994,7 @@ int ocelot_vcap_filter_stats_update(struct ocelot *ocelot,
|
||||||
struct ocelot_vcap_filter *filter)
|
struct ocelot_vcap_filter *filter)
|
||||||
{
|
{
|
||||||
struct ocelot_vcap_block *block = &ocelot->block;
|
struct ocelot_vcap_block *block = &ocelot->block;
|
||||||
struct ocelot_vcap_filter *tmp;
|
struct ocelot_vcap_filter tmp;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
index = ocelot_vcap_block_get_filter_index(block, filter);
|
index = ocelot_vcap_block_get_filter_index(block, filter);
|
||||||
|
@ -1004,9 +1004,9 @@ int ocelot_vcap_filter_stats_update(struct ocelot *ocelot,
|
||||||
vcap_entry_get(ocelot, filter, index);
|
vcap_entry_get(ocelot, filter, index);
|
||||||
|
|
||||||
/* After we get the result we need to clear the counters */
|
/* After we get the result we need to clear the counters */
|
||||||
tmp = ocelot_vcap_block_find_filter_by_index(block, index);
|
tmp = *filter;
|
||||||
tmp->stats.pkts = 0;
|
tmp.stats.pkts = 0;
|
||||||
is2_entry_set(ocelot, index, tmp);
|
is2_entry_set(ocelot, index, &tmp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue