diff mbox series

[ovs-dev,v6,1/2] netdev-dpdk: negotiate delivery of per-packet Rx metadata

Message ID 20230606113533.6866-2-ivan.malov@arknetworks.am
State Changes Requested
Headers show
Series DPDK: align flow offloads with 22.11 | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Ivan Malov June 6, 2023, 11:35 a.m. UTC
This may be required by some PMDs in offload scenarios.

Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
---
 lib/netdev-dpdk.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

Comments

0-day Robot June 6, 2023, 11:59 a.m. UTC | #1
Bleep bloop.  Greetings Ivan Malov, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Inappropriate bracing around statement
#37 FILE: lib/netdev-dpdk.c:1152:
    if (dev->rx_metadata_delivery_configured)

Lines checked: 98, Warnings: 0, Errors: 1


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
Simon Horman June 29, 2023, 1:58 p.m. UTC | #2
On Tue, Jun 06, 2023 at 03:35:32PM +0400, Ivan Malov via dev wrote:
> This may be required by some PMDs in offload scenarios.
> 
> Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
> ---
>  lib/netdev-dpdk.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
> index 8cb1a7703..98765fe6e 100644
> --- a/lib/netdev-dpdk.c
> +++ b/lib/netdev-dpdk.c
> @@ -542,6 +542,9 @@ struct netdev_dpdk {
>          int rte_xstats_names_size;
>          int rte_xstats_ids_size;
>          uint64_t *rte_xstats_ids;
> +
> +        /* Ensures that Rx metadata delivery is configured only once */
> +        bool rx_metadata_delivery_configured;
>      );
>  };
>  
> @@ -1140,6 +1143,41 @@ dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) OVS_REQUIRES(dev->mutex)
>      }
>  }
>  
> +static void
> +dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev)
> +{
> +    uint64_t rx_metadata = 0;
> +    int ret;
> +
> +    if (dev->rx_metadata_delivery_configured)
> +        return;

Hi Ivan,

IIRC, the OVS coding style calls for the use of { } for all conditional blocks.
So please update this to:

    if (dev->rx_metadata_delivery_configured) {
        return;
    }

Likewise, a similar update is needed for patch 2/2.

Thanks!
Ilya Maximets June 29, 2023, 3:17 p.m. UTC | #3
On 6/29/23 15:58, Simon Horman wrote:
> On Tue, Jun 06, 2023 at 03:35:32PM +0400, Ivan Malov via dev wrote:
>> This may be required by some PMDs in offload scenarios.
>>
>> Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
>> ---
>>  lib/netdev-dpdk.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 50 insertions(+)
>>
>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>> index 8cb1a7703..98765fe6e 100644
>> --- a/lib/netdev-dpdk.c
>> +++ b/lib/netdev-dpdk.c
>> @@ -542,6 +542,9 @@ struct netdev_dpdk {
>>          int rte_xstats_names_size;
>>          int rte_xstats_ids_size;
>>          uint64_t *rte_xstats_ids;
>> +
>> +        /* Ensures that Rx metadata delivery is configured only once */

This also needs a period at the end of a comment.

>> +        bool rx_metadata_delivery_configured;

And this doesn't really belong in the 'stats' section of the structure.
Might be better fit in one of the previous sections.  The one with 'up',
for example.

>>      );
>>  };
>>  
>> @@ -1140,6 +1143,41 @@ dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) OVS_REQUIRES(dev->mutex)
>>      }
>>  }
>>  
>> +static void
>> +dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev)
>> +{
>> +    uint64_t rx_metadata = 0;
>> +    int ret;
>> +
>> +    if (dev->rx_metadata_delivery_configured)
>> +        return;
> 
> Hi Ivan,
> 
> IIRC, the OVS coding style calls for the use of { } for all conditional blocks.
> So please update this to:
> 
>     if (dev->rx_metadata_delivery_configured) {
>         return;
>     }
> 
> Likewise, a similar update is needed for patch 2/2.
> 
> Thanks!
Ivan Malov June 30, 2023, 2:25 a.m. UTC | #4
On Thu, 29 Jun 2023, Simon Horman wrote:

> On Tue, Jun 06, 2023 at 03:35:32PM +0400, Ivan Malov via dev wrote:
>> This may be required by some PMDs in offload scenarios.
>>
>> Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
>> ---
>>  lib/netdev-dpdk.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 50 insertions(+)
>>
>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>> index 8cb1a7703..98765fe6e 100644
>> --- a/lib/netdev-dpdk.c
>> +++ b/lib/netdev-dpdk.c
>> @@ -542,6 +542,9 @@ struct netdev_dpdk {
>>          int rte_xstats_names_size;
>>          int rte_xstats_ids_size;
>>          uint64_t *rte_xstats_ids;
>> +
>> +        /* Ensures that Rx metadata delivery is configured only once */
>> +        bool rx_metadata_delivery_configured;
>>      );
>>  };
>>
>> @@ -1140,6 +1143,41 @@ dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) OVS_REQUIRES(dev->mutex)
>>      }
>>  }
>>
>> +static void
>> +dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev)
>> +{
>> +    uint64_t rx_metadata = 0;
>> +    int ret;
>> +
>> +    if (dev->rx_metadata_delivery_configured)
>> +        return;
>
> Hi Ivan,
>
> IIRC, the OVS coding style calls for the use of { } for all conditional blocks.
> So please update this to:
>
>    if (dev->rx_metadata_delivery_configured) {
>        return;
>    }
>
> Likewise, a similar update is needed for patch 2/2.
>
> Thanks!
>
Hi Simon,

Very valuable information indeed. Now I understand
the true reason behind the check-bot warning.

Thank you.
Ivan Malov June 30, 2023, 3:12 a.m. UTC | #5
Hi Ilya,

Thanks again for reviewing this. I attempted to fix review notes in
https://patchwork.ozlabs.org/project/openvswitch/list/?series=361784 .

Thank you.

On Thu, 29 Jun 2023, Ilya Maximets wrote:

> On 6/29/23 15:58, Simon Horman wrote:
>> On Tue, Jun 06, 2023 at 03:35:32PM +0400, Ivan Malov via dev wrote:
>>> This may be required by some PMDs in offload scenarios.
>>>
>>> Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
>>> ---
>>>  lib/netdev-dpdk.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
>>>  1 file changed, 50 insertions(+)
>>>
>>> diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
>>> index 8cb1a7703..98765fe6e 100644
>>> --- a/lib/netdev-dpdk.c
>>> +++ b/lib/netdev-dpdk.c
>>> @@ -542,6 +542,9 @@ struct netdev_dpdk {
>>>          int rte_xstats_names_size;
>>>          int rte_xstats_ids_size;
>>>          uint64_t *rte_xstats_ids;
>>> +
>>> +        /* Ensures that Rx metadata delivery is configured only once */
>
> This also needs a period at the end of a comment.
>
>>> +        bool rx_metadata_delivery_configured;
>
> And this doesn't really belong in the 'stats' section of the structure.
> Might be better fit in one of the previous sections.  The one with 'up',
> for example.
>
>>>      );
>>>  };
>>>
>>> @@ -1140,6 +1143,41 @@ dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) OVS_REQUIRES(dev->mutex)
>>>      }
>>>  }
>>>
>>> +static void
>>> +dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev)
>>> +{
>>> +    uint64_t rx_metadata = 0;
>>> +    int ret;
>>> +
>>> +    if (dev->rx_metadata_delivery_configured)
>>> +        return;
>>
>> Hi Ivan,
>>
>> IIRC, the OVS coding style calls for the use of { } for all conditional blocks.
>> So please update this to:
>>
>>     if (dev->rx_metadata_delivery_configured) {
>>         return;
>>     }
>>
>> Likewise, a similar update is needed for patch 2/2.
>>
>> Thanks!
>
>
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 8cb1a7703..98765fe6e 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -542,6 +542,9 @@  struct netdev_dpdk {
         int rte_xstats_names_size;
         int rte_xstats_ids_size;
         uint64_t *rte_xstats_ids;
+
+        /* Ensures that Rx metadata delivery is configured only once */
+        bool rx_metadata_delivery_configured;
     );
 };
 
@@ -1140,6 +1143,41 @@  dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) OVS_REQUIRES(dev->mutex)
     }
 }
 
+static void
+dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev)
+{
+    uint64_t rx_metadata = 0;
+    int ret;
+
+    if (dev->rx_metadata_delivery_configured)
+        return;
+
+    /* For the fallback offload (non-"transfer" rules) */
+    rx_metadata |= RTE_ETH_RX_METADATA_USER_MARK;
+    /* For the full offload ("transfer" rules) */
+    rx_metadata |= RTE_ETH_RX_METADATA_TUNNEL_ID;
+
+    ret = rte_eth_rx_metadata_negotiate(dev->port_id, &rx_metadata);
+    if (ret == 0) {
+        if (!(rx_metadata & RTE_ETH_RX_METADATA_USER_MARK)) {
+            VLOG_DBG("The NIC will not provide per-packet USER_MARK on port "
+                     DPDK_PORT_ID_FMT, dev->port_id);
+        }
+        if (!(rx_metadata & RTE_ETH_RX_METADATA_TUNNEL_ID)) {
+            VLOG_DBG("The NIC will not provide per-packet TUNNEL_ID on port "
+                     DPDK_PORT_ID_FMT, dev->port_id);
+        }
+    } else if (ret == -ENOTSUP) {
+        VLOG_DBG("Rx metadata negotiate procedure is not supported on port "
+                 DPDK_PORT_ID_FMT, dev->port_id);
+    } else {
+        VLOG_WARN("Cannot negotiate Rx metadata on port "
+                  DPDK_PORT_ID_FMT, dev->port_id);
+    }
+
+    dev->rx_metadata_delivery_configured = true;
+}
+
 static int
 dpdk_eth_dev_init(struct netdev_dpdk *dev)
     OVS_REQUIRES(dev->mutex)
@@ -1154,6 +1192,16 @@  dpdk_eth_dev_init(struct netdev_dpdk *dev)
                                      RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
                                      RTE_ETH_RX_OFFLOAD_IPV4_CKSUM;
 
+    /*
+     * Full tunnel offload requires that tunnel ID metadata be
+     * delivered with "miss" packets from the hardware to the
+     * PMD. The same goes for megaflow mark metadata which is
+     * used in MARK + RSS offload scenario.
+     *
+     * Request delivery of such metadata.
+     */
+    dpdk_eth_dev_init_rx_metadata(dev);
+
     rte_eth_dev_info_get(dev->port_id, &info);
 
     if (strstr(info.driver_name, "vf") != NULL) {
@@ -1320,6 +1368,8 @@  common_construct(struct netdev *netdev, dpdk_port_t port_no,
     /* Initilize the hardware offload flags to 0 */
     dev->hw_ol_features = 0;
 
+    dev->rx_metadata_delivery_configured = false;
+
     dev->flags = NETDEV_UP | NETDEV_PROMISC;
 
     ovs_list_push_back(&dpdk_list, &dev->list_node);