From: Cian Ferriter <cian.ferri...@intel.com> Use dp_netdev_pmd_thread->dp_netdev_pmd_thread_ctx to store whether the SMC is enabled. Also implement a single patcket version of SMC lookup.
Signed-off-by: Harry van Haaren <harry.van.haa...@intel.com> Co-authored-by: Cian Ferriter <cian.ferri...@intel.com> Signed-off-by: Cian Ferriter <cian.ferri...@intel.com> --- lib/dpif-netdev-avx512.c | 18 +++++++++++++++++- lib/dpif-netdev-private-dfc.h | 8 ++++++++ lib/dpif-netdev-private-thread.h | 2 ++ lib/dpif-netdev.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/lib/dpif-netdev-avx512.c b/lib/dpif-netdev-avx512.c index 06f46f4c8..f62508661 100644 --- a/lib/dpif-netdev-avx512.c +++ b/lib/dpif-netdev-avx512.c @@ -83,7 +83,10 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, /* Check if EMC or SMC are enabled */ struct dfc_cache *cache = &pmd->flow_cache; const uint32_t emc_enabled = pmd->ctx.emc_insert_min != 0; + bool smc_enable_db = pmd->ctx.smc_enable_db; + uint32_t emc_hits = 0; + uint32_t smc_hits = 0; /* a 1 bit in this mask indidcates a hit, so no DPCLS lookup on the pkt. */ uint32_t hwol_emc_smc_hitmask = 0; @@ -110,8 +113,11 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, count_1bits(key->mf.map.bits[1]); key->hash = dpif_netdev_packet_get_rss_hash_orig_pkt(packet, &key->mf); + struct dp_netdev_flow *f = NULL; + if (emc_enabled) { - struct dp_netdev_flow *f = emc_lookup(&cache->emc_cache, key); + f = emc_lookup(&cache->emc_cache, key); + if (f) { rules[i] = &f->cr; emc_hits++; @@ -120,6 +126,16 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, } }; + if (smc_enable_db && !f) { + f = smc_lookup_single(pmd, packet, key); + if (f) { + rules[i] = &f->cr; + smc_hits++; + hwol_emc_smc_hitmask |= (1 << i); + continue; + } + } + /* The flow pointer was not found in HWOL/EMC/SMC, so add it to the * dpcls input keys array for batch lookup later. */ diff --git a/lib/dpif-netdev-private-dfc.h b/lib/dpif-netdev-private-dfc.h index 8f6a4899e..2cee0a38d 100644 --- a/lib/dpif-netdev-private-dfc.h +++ b/lib/dpif-netdev-private-dfc.h @@ -81,6 +81,9 @@ extern "C" { #define DEFAULT_EM_FLOW_INSERT_MIN (UINT32_MAX / \ DEFAULT_EM_FLOW_INSERT_INV_PROB) +/* Forward declaration for SMC function prototype. */ +struct dp_netdev_pmd_thread; + struct emc_entry { struct dp_netdev_flow *flow; struct netdev_flow_key key; /* key.hash used for emc hash value. */ @@ -237,6 +240,11 @@ emc_lookup(struct emc_cache *cache, const struct netdev_flow_key *key) return NULL; } +struct dp_netdev_flow * +smc_lookup_single(struct dp_netdev_pmd_thread *pmd, + struct dp_packet *packet, + struct netdev_flow_key *key); + #ifdef __cplusplus } #endif diff --git a/lib/dpif-netdev-private-thread.h b/lib/dpif-netdev-private-thread.h index 18387b81d..c47fe92dc 100644 --- a/lib/dpif-netdev-private-thread.h +++ b/lib/dpif-netdev-private-thread.h @@ -45,6 +45,8 @@ struct dp_netdev_pmd_thread_ctx { struct dp_netdev_rxq *last_rxq; /* EMC insertion probability context for the current processing cycle. */ uint32_t emc_insert_min; + /* Enable the SMC cache from ovsdb config */ + bool smc_enable_db; }; /* Forward declaration for typedef */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 9f24646c5..91c79f79c 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -5191,6 +5191,8 @@ dpif_netdev_run(struct dpif *dpif) non_pmd->ctx.emc_insert_min = 0; } + non_pmd->ctx.smc_enable_db = dp->smc_enable_db; + for (i = 0; i < port->n_rxq; i++) { if (!netdev_rxq_enabled(port->rxqs[i].rx)) { @@ -5462,6 +5464,8 @@ reload: pmd->ctx.emc_insert_min = 0; } + pmd->ctx.smc_enable_db = pmd->dp->smc_enable_db; + process_packets = dp_netdev_process_rxq_port(pmd, poll_list[i].rxq, poll_list[i].port_no); @@ -6550,6 +6554,30 @@ smc_lookup_batch(struct dp_netdev_pmd_thread *pmd, pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_SMC_HIT, n_smc_hit); } +struct dp_netdev_flow * +smc_lookup_single(struct dp_netdev_pmd_thread *pmd, + struct dp_packet *packet, + struct netdev_flow_key *key) +{ + const struct cmap_node *flow_node = smc_entry_get(pmd, key->hash); + + if (OVS_LIKELY(flow_node != NULL)) { + struct dp_netdev_flow *flow = NULL; + + CMAP_NODE_FOR_EACH (flow, node, flow_node) { + /* Since we dont have per-port megaflow to check the port + * number, we need to verify that the input ports match. */ + if (OVS_LIKELY(dpcls_rule_matches_key(&flow->cr, key) && + flow->flow.in_port.odp_port == packet->md.in_port.odp_port)) { + + return (void *)flow; + } + } + } + + return 0; +} + /* Try to process all ('cnt') the 'packets' using only the datapath flow cache * 'pmd->flow_cache'. If a flow is not found for a packet 'packets[i]', the * miniflow is copied into 'keys' and the packet pointer is moved at the -- 2.25.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev