diff mbox series

[ovs-dev,V3,07/19] netdev-dpdk: Introduce rte flow query function

Message ID 20191208132304.15521-8-elibr@mellanox.com
State Changes Requested
Delegated to: Ilya Maximets
Headers show
Series netdev datapath actions offload | expand

Commit Message

Eli Britstein Dec. 8, 2019, 1:22 p.m. UTC
Introduce a rte flow query function as a pre-step towards reading HW
statistics of fully offloaded flows.

Signed-off-by: Eli Britstein <elibr@mellanox.com>
Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
---
 lib/netdev-dpdk.c | 25 +++++++++++++++++++++++++
 lib/netdev-dpdk.h |  6 ++++++
 2 files changed, 31 insertions(+)

Comments

Ilya Maximets Dec. 10, 2019, 2:50 p.m. UTC | #1
On 08.12.2019 14:22, Eli Britstein wrote:
> Introduce a rte flow query function as a pre-step towards reading HW
> statistics of fully offloaded flows.
> 
> Signed-off-by: Eli Britstein <elibr@mellanox.com>
> Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
> ---
>  lib/netdev-dpdk.c | 25 +++++++++++++++++++++++++
>  lib/netdev-dpdk.h |  6 ++++++
>  2 files changed, 31 insertions(+)
> 
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index da1349b69..e63a496c1 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -4737,6 +4737,31 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev,
>      return flow;
>  }
>  
> +int
> +netdev_dpdk_rte_flow_query(struct netdev *netdev,

Shouldn't it be named netdev_dpdk_rte_flow_query_count() ?

> +                           struct rte_flow *rte_flow,
> +                           struct rte_flow_query_count *query,
> +                           struct rte_flow_error *error)
> +{
> +    struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
> +    struct rte_flow_action_count count = {};
> +    const struct rte_flow_action actions[] = {
> +        {
> +            .type = RTE_FLOW_ACTION_TYPE_COUNT,
> +            .conf = &count,
> +        },
> +        {
> +            .type = RTE_FLOW_ACTION_TYPE_END,
> +        },
> +    };
> +    int ret;
> +
> +    ovs_mutex_lock(&dev->mutex);
> +    ret = rte_flow_query(dev->port_id, rte_flow, actions, query, error);
> +    ovs_mutex_unlock(&dev->mutex);
> +    return ret;
> +}
> +
>  #define NETDEV_DPDK_CLASS_COMMON                            \
>      .is_pmd = true,                                         \
>      .alloc = netdev_dpdk_alloc,                             \
> diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
> index 60631c4f0..ed7cb235a 100644
> --- a/lib/netdev-dpdk.h
> +++ b/lib/netdev-dpdk.h
> @@ -31,6 +31,7 @@ struct rte_flow_error;
>  struct rte_flow_attr;
>  struct rte_flow_item;
>  struct rte_flow_action;
> +struct rte_flow_query_count;
>  
>  void netdev_dpdk_register(void);
>  void free_dpdk_buf(struct dp_packet *);
> @@ -47,6 +48,11 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev,
>                              const struct rte_flow_item *items,
>                              const struct rte_flow_action *actions,
>                              struct rte_flow_error *error);
> +int
> +netdev_dpdk_rte_flow_query(struct netdev *netdev,
> +                           struct rte_flow *rte_flow,
> +                           struct rte_flow_query_count *query,
> +                           struct rte_flow_error *error);
>  
>  #else
>  
>
Eli Britstein Dec. 10, 2019, 2:53 p.m. UTC | #2
On 12/10/2019 4:50 PM, Ilya Maximets wrote:
> On 08.12.2019 14:22, Eli Britstein wrote:
>> Introduce a rte flow query function as a pre-step towards reading HW
>> statistics of fully offloaded flows.
>>
>> Signed-off-by: Eli Britstein <elibr@mellanox.com>
>> Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
>> ---
>>   lib/netdev-dpdk.c | 25 +++++++++++++++++++++++++
>>   lib/netdev-dpdk.h |  6 ++++++
>>   2 files changed, 31 insertions(+)
>>
>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>> index da1349b69..e63a496c1 100644
>> --- a/lib/netdev-dpdk.c
>> +++ b/lib/netdev-dpdk.c
>> @@ -4737,6 +4737,31 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev,
>>       return flow;
>>   }
>>   
>> +int
>> +netdev_dpdk_rte_flow_query(struct netdev *netdev,
> Shouldn't it be named netdev_dpdk_rte_flow_query_count() ?
it's a paraphrase of "rte_flow_query()" (DPDK API), and it can stay as 
is if changed beyond "count" usage in the future, but OK.
>
>> +                           struct rte_flow *rte_flow,
>> +                           struct rte_flow_query_count *query,
>> +                           struct rte_flow_error *error)
>> +{
>> +    struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
>> +    struct rte_flow_action_count count = {};
>> +    const struct rte_flow_action actions[] = {
>> +        {
>> +            .type = RTE_FLOW_ACTION_TYPE_COUNT,
>> +            .conf = &count,
>> +        },
>> +        {
>> +            .type = RTE_FLOW_ACTION_TYPE_END,
>> +        },
>> +    };
>> +    int ret;
>> +
>> +    ovs_mutex_lock(&dev->mutex);
>> +    ret = rte_flow_query(dev->port_id, rte_flow, actions, query, error);
>> +    ovs_mutex_unlock(&dev->mutex);
>> +    return ret;
>> +}
>> +
>>   #define NETDEV_DPDK_CLASS_COMMON                            \
>>       .is_pmd = true,                                         \
>>       .alloc = netdev_dpdk_alloc,                             \
>> diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
>> index 60631c4f0..ed7cb235a 100644
>> --- a/lib/netdev-dpdk.h
>> +++ b/lib/netdev-dpdk.h
>> @@ -31,6 +31,7 @@ struct rte_flow_error;
>>   struct rte_flow_attr;
>>   struct rte_flow_item;
>>   struct rte_flow_action;
>> +struct rte_flow_query_count;
>>   
>>   void netdev_dpdk_register(void);
>>   void free_dpdk_buf(struct dp_packet *);
>> @@ -47,6 +48,11 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev,
>>                               const struct rte_flow_item *items,
>>                               const struct rte_flow_action *actions,
>>                               struct rte_flow_error *error);
>> +int
>> +netdev_dpdk_rte_flow_query(struct netdev *netdev,
>> +                           struct rte_flow *rte_flow,
>> +                           struct rte_flow_query_count *query,
>> +                           struct rte_flow_error *error);
>>   
>>   #else
>>   
>>
Ilya Maximets Dec. 10, 2019, 3:01 p.m. UTC | #3
On 10.12.2019 15:53, Eli Britstein wrote:
> 
> On 12/10/2019 4:50 PM, Ilya Maximets wrote:
>> On 08.12.2019 14:22, Eli Britstein wrote:
>>> Introduce a rte flow query function as a pre-step towards reading HW
>>> statistics of fully offloaded flows.
>>>
>>> Signed-off-by: Eli Britstein <elibr@mellanox.com>
>>> Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
>>> ---
>>>   lib/netdev-dpdk.c | 25 +++++++++++++++++++++++++
>>>   lib/netdev-dpdk.h |  6 ++++++
>>>   2 files changed, 31 insertions(+)
>>>
>>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>>> index da1349b69..e63a496c1 100644
>>> --- a/lib/netdev-dpdk.c
>>> +++ b/lib/netdev-dpdk.c
>>> @@ -4737,6 +4737,31 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev,
>>>       return flow;
>>>   }
>>>   
>>> +int
>>> +netdev_dpdk_rte_flow_query(struct netdev *netdev,
>> Shouldn't it be named netdev_dpdk_rte_flow_query_count() ?
> it's a paraphrase of "rte_flow_query()" (DPDK API), and it can stay as 
> is if changed beyond "count" usage in the future, but OK.

You'll need to change the function prototype anyway.
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index da1349b69..e63a496c1 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -4737,6 +4737,31 @@  netdev_dpdk_rte_flow_create(struct netdev *netdev,
     return flow;
 }
 
+int
+netdev_dpdk_rte_flow_query(struct netdev *netdev,
+                           struct rte_flow *rte_flow,
+                           struct rte_flow_query_count *query,
+                           struct rte_flow_error *error)
+{
+    struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
+    struct rte_flow_action_count count = {};
+    const struct rte_flow_action actions[] = {
+        {
+            .type = RTE_FLOW_ACTION_TYPE_COUNT,
+            .conf = &count,
+        },
+        {
+            .type = RTE_FLOW_ACTION_TYPE_END,
+        },
+    };
+    int ret;
+
+    ovs_mutex_lock(&dev->mutex);
+    ret = rte_flow_query(dev->port_id, rte_flow, actions, query, error);
+    ovs_mutex_unlock(&dev->mutex);
+    return ret;
+}
+
 #define NETDEV_DPDK_CLASS_COMMON                            \
     .is_pmd = true,                                         \
     .alloc = netdev_dpdk_alloc,                             \
diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
index 60631c4f0..ed7cb235a 100644
--- a/lib/netdev-dpdk.h
+++ b/lib/netdev-dpdk.h
@@ -31,6 +31,7 @@  struct rte_flow_error;
 struct rte_flow_attr;
 struct rte_flow_item;
 struct rte_flow_action;
+struct rte_flow_query_count;
 
 void netdev_dpdk_register(void);
 void free_dpdk_buf(struct dp_packet *);
@@ -47,6 +48,11 @@  netdev_dpdk_rte_flow_create(struct netdev *netdev,
                             const struct rte_flow_item *items,
                             const struct rte_flow_action *actions,
                             struct rte_flow_error *error);
+int
+netdev_dpdk_rte_flow_query(struct netdev *netdev,
+                           struct rte_flow *rte_flow,
+                           struct rte_flow_query_count *query,
+                           struct rte_flow_error *error);
 
 #else