net: mscc: ocelot: fix last VCAP IS1/IS2 filter persisting in hardware when deleted
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 4 May 2022 23:55:00 +0000 (02:55 +0300)
committerJakub Kicinski <kuba@kernel.org>
Fri, 6 May 2022 02:15:15 +0000 (19:15 -0700)
commit16bbebd35629c93a8c68c6d8d28557e100bcee73
tree8d6f3be3727dad1af8e46c81e4e7900e6d85a8da
parente1846cff2fe614d93a2f89461b5935678fd34bd9
net: mscc: ocelot: fix last VCAP IS1/IS2 filter persisting in hardware when deleted

ocelot_vcap_filter_del() works by moving the next filters over the
current one, and then deleting the last filter by calling vcap_entry_set()
with a del_filter which was specially created by memsetting its memory
to zeroes. vcap_entry_set() then programs this to the TCAM and action
RAM via the cache registers.

The problem is that vcap_entry_set() is a dispatch function which looks
at del_filter->block_id. But since del_filter is zeroized memory, the
block_id is 0, or otherwise said, VCAP_ES0. So practically, what we do
is delete the entry at the same TCAM index from VCAP ES0 instead of IS1
or IS2.

The code was not always like this. vcap_entry_set() used to simply be
is2_entry_set(), and then, the logic used to work.

Restore the functionality by populating the block_id of the del_filter
based on the VCAP block of the filter that we're deleting. This makes
vcap_entry_set() know what to do.

Fixes: 1397a2eb52e2 ("net: mscc: ocelot: create TCAM skeleton from tc filter chains")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mscc/ocelot_vcap.c