On 11/5/2020 9:32 PM, Matan Azrad wrote:
When an age action becomes aged-out the rte_flow_get_aged_flows should
return the action context supplied by the configuration structure.

In case the age action created by the shared action API, the shared
action context of the Testpmd application was not set.

In addition, the application handler of the contexts returned by the
rte_flow_get_aged_flows API didn't consider the fact that the action
could be set by the shared action API and considered it as regular flow
context.

This caused a crash in Testpmd when the context is parsed.

This patch set context type in the flow and shared action context and
uses it to parse the aged-out contexts correctly.

Signed-off-by: Matan Azrad <ma...@nvidia.com>
Acked-by: Dekel Peled <dek...@nvidia.com>
---
  app/test-pmd/config.c  | 119 ++++++++++++++++++++++++++++++++++---------------
  app/test-pmd/testpmd.h |   5 +++
  2 files changed, 87 insertions(+), 37 deletions(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 755d1df..00a7dd1 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1763,6 +1763,33 @@ void port_flow_tunnel_create(portid_t port_id, const 
struct tunnel_ops *ops)
        }
  }
+#define AGE_ACTION_TYPE_MASK 0x3u
+
+static void
+set_age_action_context(void **ctx, enum action_age_context_type type, void 
*obj)
+{
+       uintptr_t value = (uintptr_t)obj;
+
+       /*
+        * obj is allocated by malloc\calloc which must return an address
+        * aligned to 8.
+        * Use the last 2 bits for the age context type.
+        */
+       value |= (uintptr_t)type & AGE_ACTION_TYPE_MASK;
+       *ctx = (void *)value;

Thanks Matan, I think this is much clear. But I though the 'id' will be used, not the pointer itself, like "uintptr_t value = id | (type * MASK)" OR the address pointer and type seems error prone, although you comment you rely on the alignment. The testpmd usage also kind of sample usage for the applications, I am for not suggesting this for the user applications.

Reserving the two bit of the 'id' reduces the usable 'id' to 30 bits, but it looks still big enough, what do you think?

Reply via email to