[ovs-dev] [PATCH 8/8] dpif-netdev: add function pointer for netdev input

Harry van Haaren harry.van.haaren at intel.com
Tue Oct 6 14:54:37 UTC 2020


This commit adds a function pointer to the pmd thread data structure,
giving the pmd thread flexibility in its dpif-input function choice.
This allows choosing of the implementation based on ISA capabilities
of the runtime CPU, leading to optimizations and higher performance.

Signed-off-by: Harry van Haaren <harry.van.haaren at intel.com>
---
 lib/dpif-netdev-private-thread.h | 10 ++++++++++
 lib/dpif-netdev.c                |  9 ++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/lib/dpif-netdev-private-thread.h b/lib/dpif-netdev-private-thread.h
index 6d320678d..89761eb51 100644
--- a/lib/dpif-netdev-private-thread.h
+++ b/lib/dpif-netdev-private-thread.h
@@ -47,6 +47,13 @@ struct dp_netdev_pmd_thread_ctx {
     uint32_t emc_insert_min;
 };
 
+/* Foward declaration for typedef */
+struct dp_netdev_pmd_thread;
+
+typedef void (*dp_netdev_input_func)(struct dp_netdev_pmd_thread *pmd,
+                                     struct dp_packet_batch *packets,
+                                     odp_port_t port_no);
+
 /* PMD: Poll modes drivers.  PMD accesses devices via polling to eliminate
  * the performance overhead of interrupt processing.  Therefore netdev can
  * not implement rx-wait for these devices.  dpif-netdev needs to poll
@@ -101,6 +108,9 @@ struct dp_netdev_pmd_thread {
     /* Current context of the PMD thread. */
     struct dp_netdev_pmd_thread_ctx ctx;
 
+    /* Function pointer to call for dp_netdev_input() functionality */
+    dp_netdev_input_func netdev_input_func;
+
     struct seq *reload_seq;
     uint64_t last_reload_seq;
 
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index cb07a7bdc..74a04ab9e 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -4228,8 +4228,9 @@ dp_netdev_process_rxq_port(struct dp_netdev_pmd_thread *pmd,
                 }
             }
         }
+
         /* Process packet batch. */
-        dp_netdev_input(pmd, &batch, port_no);
+        pmd->netdev_input_func(pmd, &batch, port_no);
 
         /* Assign processing cycles to rx queue. */
         cycles = cycle_timer_stop(&pmd->perf_stats, &timer);
@@ -5452,6 +5453,12 @@ pmd_thread_main(void *f_)
     dfc_cache_init(&pmd->flow_cache);
     pmd_alloc_static_tx_qid(pmd);
 
+    /* set dp_netdev_input__ function pointer. This is now flexible, and can
+     * be modified at runtime just like DPCLS subtable lookup, allowing the
+     * implementation to be ISA specialized for performance.
+     */
+    pmd->netdev_input_func = dp_netdev_input;
+
 reload:
     atomic_count_init(&pmd->pmd_overloaded, 0);
 
-- 
2.17.1



More information about the dev mailing list