summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/microchip
diff options
context:
space:
mode:
authorHoratiu Vultur <horatiu.vultur@microchip.com>2022-11-28 15:29:59 +0100
committerJakub Kicinski <kuba@kernel.org>2022-11-30 20:46:13 -0800
commitc1d8e3fb1a3bef6d1b24a9b1326e4ed11a1fbf0b (patch)
treeedf2323cb6ce3e327dfa2a9bede74098899553b7 /drivers/net/ethernet/microchip
parent450f065053967f446afafc39328776b473305378 (diff)
downloadlinux-stable-c1d8e3fb1a3bef6d1b24a9b1326e4ed11a1fbf0b.tar.gz
linux-stable-c1d8e3fb1a3bef6d1b24a9b1326e4ed11a1fbf0b.tar.bz2
linux-stable-c1d8e3fb1a3bef6d1b24a9b1326e4ed11a1fbf0b.zip
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>
Diffstat (limited to 'drivers/net/ethernet/microchip')
-rw-r--r--drivers/net/ethernet/microchip/vcap/vcap_api.c7
-rw-r--r--drivers/net/ethernet/microchip/vcap/vcap_api.h1
2 files changed, 1 insertions, 7 deletions
diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.c b/drivers/net/ethernet/microchip/vcap/vcap_api.c
index 93efa8243b02..f2435d7ab515 100644
--- a/drivers/net/ethernet/microchip/vcap/vcap_api.c
+++ b/drivers/net/ethernet/microchip/vcap/vcap_api.c
@@ -985,17 +985,12 @@ static u32 vcap_next_rule_addr(u32 addr, struct vcap_rule_internal *ri)
/* Assign a unique rule id and autogenerate one if id == 0 */
static u32 vcap_set_rule_id(struct vcap_rule_internal *ri)
{
- u32 next_id;
-
if (ri->data.id != 0)
return ri->data.id;
- next_id = ri->vctrl->rule_id + 1;
-
- for (next_id = ri->vctrl->rule_id + 1; next_id < ~0; ++next_id) {
+ for (u32 next_id = 1; next_id < ~0; ++next_id) {
if (!vcap_lookup_rule(ri->vctrl, next_id)) {
ri->data.id = next_id;
- ri->vctrl->rule_id = next_id;
break;
}
}
diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api.h b/drivers/net/ethernet/microchip/vcap/vcap_api.h
index ca4499838306..689c7270f2a8 100644
--- a/drivers/net/ethernet/microchip/vcap/vcap_api.h
+++ b/drivers/net/ethernet/microchip/vcap/vcap_api.h
@@ -268,7 +268,6 @@ struct vcap_operations {
/* VCAP API Client control interface */
struct vcap_control {
- u32 rule_id; /* last used rule id (unique across VCAP instances) */
struct vcap_operations *ops; /* client supplied operations */
const struct vcap_info *vcaps; /* client supplied vcap models */
const struct vcap_statistics *stats; /* client supplied vcap stats */