]> git.dujemihanovic.xyz Git - linux.git/commitdiff
net: microchip: vcap: Add vcap_rule_get_key_u32
authorHoratiu Vultur <horatiu.vultur@microchip.com>
Sat, 3 Dec 2022 10:43:47 +0000 (11:43 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 6 Dec 2022 12:26:43 +0000 (13:26 +0100)
Add the function vcap_rule_get_key_u32 which allows to get the value and
the mask of a key that exist on the rule. If the key doesn't exist,
it would return error.

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/microchip/vcap/vcap_api.c
drivers/net/ethernet/microchip/vcap/vcap_api_client.h

index eae4e9fe0e147f3c05c6542d032f023afe2d2f0f..05e915ea858d6d8598f151fcaaa41d8a5aa2e306 100644 (file)
@@ -2338,6 +2338,22 @@ int vcap_rule_add_key_u128(struct vcap_rule *rule, enum vcap_key_field key,
 }
 EXPORT_SYMBOL_GPL(vcap_rule_add_key_u128);
 
+int vcap_rule_get_key_u32(struct vcap_rule *rule, enum vcap_key_field key,
+                         u32 *value, u32 *mask)
+{
+       struct vcap_client_keyfield *ckf;
+
+       ckf = vcap_find_keyfield(rule, key);
+       if (!ckf)
+               return -ENOENT;
+
+       *value = ckf->data.u32.value;
+       *mask = ckf->data.u32.mask;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(vcap_rule_get_key_u32);
+
 /* Find a client action field in a rule */
 static struct vcap_client_actionfield *
 vcap_find_actionfield(struct vcap_rule *rule, enum vcap_action_field act)
index fdfc5d58813bb8453a755a0875bae5f977e9c15e..0319866f9c94d0818e92edcb17620ce228247a19 100644 (file)
@@ -258,4 +258,8 @@ int vcap_rule_mod_action_u32(struct vcap_rule *rule,
                             enum vcap_action_field action,
                             u32 value);
 
+/* Get a 32 bit key field value and mask from the rule */
+int vcap_rule_get_key_u32(struct vcap_rule *rule, enum vcap_key_field key,
+                         u32 *value, u32 *mask);
+
 #endif /* __VCAP_API_CLIENT__ */