net: microchip: vcap: Change how the rule id is generated
authorHoratiu Vultur <horatiu.vultur@microchip.com>
Mon, 28 Nov 2022 14:29:59 +0000 (15:29 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 1 Dec 2022 04:46:13 +0000 (20:46 -0800)
commitc1d8e3fb1a3bef6d1b24a9b1326e4ed11a1fbf0b
treeedf2323cb6ce3e327dfa2a9bede74098899553b7
parent450f065053967f446afafc39328776b473305378
net: microchip: vcap: Change how the rule id is generated

Currently whenever a new rule id is generated, it picks up the next
number bigger than previous id. So it would always be 1, 2, 3, etc.
When the rule with id 1 will be deleted and a new rule will be added,
it will have the id 4 and not id 1.
In theory this can be a problem if at some point a rule will be added
and removed ~0 times. Then no more rules can be added because there
are no more ids.

Change this such that when a new rule is added, search for an empty
rule id starting with value of 1 as value 0 is reserved.

Fixes: c9da1ac1c212 ("net: microchip: sparx5: Adding initial tc flower support for VCAP API")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Link: https://lore.kernel.org/r/20221128142959.8325-1-horatiu.vultur@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/microchip/vcap/vcap_api.c
drivers/net/ethernet/microchip/vcap/vcap_api.h