]> git.droids-corp.org - dpdk.git/commitdiff
node: choose vector path at runtime
authorCiara Power <ciara.power@intel.com>
Mon, 19 Oct 2020 13:48:57 +0000 (15:48 +0200)
committerDavid Marchand <david.marchand@redhat.com>
Mon, 19 Oct 2020 14:45:02 +0000 (16:45 +0200)
When choosing the vector path, max SIMD bitwidth is now checked to
ensure the vector path is suitable. To do this, the scalar function is
chosen by default in the struct, but at node initialisation time, this
function pointer is updated to the vector version if supported, and
if it is within the max SIMD bitwidth limit.

Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
lib/librte_node/ip4_lookup.c
lib/librte_node/ip4_lookup_neon.h
lib/librte_node/ip4_lookup_sse.h

index 293c77f39e040bfed9ba12f36485ad3011255f09..8835aab9ddc402d5e81af0ad36d75002cd15d45d 100644 (file)
@@ -15,6 +15,7 @@
 #include <rte_mbuf.h>
 #include <rte_tcp.h>
 #include <rte_udp.h>
+#include <rte_vect.h>
 
 #include "rte_node_ip4_api.h"
 
@@ -34,10 +35,10 @@ static struct ip4_lookup_node_main ip4_lookup_nm;
 #include "ip4_lookup_neon.h"
 #elif defined(RTE_ARCH_X86)
 #include "ip4_lookup_sse.h"
-#else
+#endif
 
 static uint16_t
-ip4_lookup_node_process(struct rte_graph *graph, struct rte_node *node,
+ip4_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
                        void **objs, uint16_t nb_objs)
 {
        struct rte_ipv4_hdr *ipv4_hdr;
@@ -109,8 +110,6 @@ ip4_lookup_node_process(struct rte_graph *graph, struct rte_node *node,
        return nb_objs;
 }
 
-#endif
-
 int
 rte_node_ip4_route_add(uint32_t ip, uint8_t depth, uint16_t next_hop,
                       enum rte_node_ip4_lookup_next next_node)
@@ -194,13 +193,19 @@ ip4_lookup_node_init(const struct rte_graph *graph, struct rte_node *node)
                init_once = 1;
        }
        *lpm_p = ip4_lookup_nm.lpm_tbl[graph->socket];
+
+#if defined(__ARM_NEON) || defined(RTE_ARCH_X86)
+       if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128)
+               node->process = ip4_lookup_node_process_vec;
+#endif
+
        node_dbg("ip4_lookup", "Initialized ip4_lookup node");
 
        return 0;
 }
 
 static struct rte_node_register ip4_lookup_node = {
-       .process = ip4_lookup_node_process,
+       .process = ip4_lookup_node_process_scalar,
        .name = "ip4_lookup",
 
        .init = ip4_lookup_node_init,
index 5e5a7d87be0a33730fce6e8e1aa2dcb608318f52..0ad2763b824c006c65f3f3611d9e145e14c75d25 100644 (file)
@@ -7,7 +7,7 @@
 
 /* ARM64 NEON */
 static uint16_t
-ip4_lookup_node_process(struct rte_graph *graph, struct rte_node *node,
+ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node,
                        void **objs, uint16_t nb_objs)
 {
        struct rte_mbuf *mbuf0, *mbuf1, *mbuf2, *mbuf3, **pkts;
index a071cc5919fbd11e69cb6630b360fef4a4ab493a..264c986071b5b0477fc95949c8db7df91c17fd93 100644 (file)
@@ -7,7 +7,7 @@
 
 /* X86 SSE */
 static uint16_t
-ip4_lookup_node_process(struct rte_graph *graph, struct rte_node *node,
+ip4_lookup_node_process_vec(struct rte_graph *graph, struct rte_node *node,
                        void **objs, uint16_t nb_objs)
 {
        struct rte_mbuf *mbuf0, *mbuf1, *mbuf2, *mbuf3, **pkts;