diff mbox series

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

Message ID 20220720121823.2497727-2-ivan.malov@oktetlabs.ru
State Superseded
Headers show
Series Rework the usage of DPDK transfer flow offloads | expand

Checks

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

Commit Message

Ivan Malov July 20, 2022, 12:18 p.m. UTC
This may be required by some PMDs in offload scenarios.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 lib/netdev-dpdk.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f9535bfb4..45e5d26d2 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -1085,6 +1085,38 @@  dpdk_eth_flow_ctrl_setup(struct netdev_dpdk *dev) OVS_REQUIRES(dev->mutex)
     }
 }
 
+#ifdef ALLOW_EXPERIMENTAL_API
+static void
+dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev)
+{
+    uint64_t rx_metadata = 0;
+    int ret;
+
+    /* 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);
+    }
+}
+#endif /* ALLOW_EXPERIMENTAL_API */
+
 static int
 dpdk_eth_dev_init(struct netdev_dpdk *dev)
     OVS_REQUIRES(dev->mutex)
@@ -1099,6 +1131,18 @@  dpdk_eth_dev_init(struct netdev_dpdk *dev)
                                      RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
                                      RTE_ETH_RX_OFFLOAD_IPV4_CKSUM;
 
+#ifdef ALLOW_EXPERIMENTAL_API
+    /*
+     * 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);
+#endif /* ALLOW_EXPERIMENTAL_API */
+
     rte_eth_dev_info_get(dev->port_id, &info);
 
     if (strstr(info.driver_name, "vf") != NULL) {