diff mbox series

[ovs-dev,v16,06/10] dpif-netdev: Add a partial HWOL PMD statistic.

Message ID 20210709155824.506447-7-harry.van.haaren@intel.com
State Accepted
Headers show
Series DPIF Framework + Optimizations | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot success github build: passed

Commit Message

Van Haaren, Harry July 9, 2021, 3:58 p.m. UTC
From: Cian Ferriter <cian.ferriter@intel.com>

It is possible for packets traversing the userspace datapath to match a
flow before hitting on EMC by using a mark ID provided by a NIC. Add a
PMD statistic for this hit.

Signed-off-by: Cian Ferriter <cian.ferriter@intel.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>

---

Cc: Gaetan Rivet <gaetanr@nvidia.com>
Cc: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>

v14:
- Added Flavio's Acked-by tag.

v13:
- Minor refactoring to address review comments.
- Update manpages to reflect the new format of the pmd-perf-show
  command.
---
 NEWS                        | 2 ++
 lib/dpif-netdev-avx512.c    | 3 +++
 lib/dpif-netdev-perf.c      | 3 +++
 lib/dpif-netdev-perf.h      | 1 +
 lib/dpif-netdev-unixctl.man | 1 +
 lib/dpif-netdev.c           | 9 +++++++--
 tests/pmd.at                | 6 ++++--
 7 files changed, 21 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/NEWS b/NEWS
index 471f3a1a28..6bd9b233e7 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,8 @@  Post-v2.15.0
      * Add avx512 implementation of dpif which can process non recirculated
        packets. It supports partial HWOL, EMC, SMC and DPCLS lookups.
      * Add commands to get and set the dpif implementations.
+     * Add a partial HWOL PMD statistic counting hits similar to existing
+       EMC/SMC/DPCLS stats.
    - ovs-ctl:
      * New option '--no-record-hostname' to disable hostname configuration
        in ovsdb on startup.
diff --git a/lib/dpif-netdev-avx512.c b/lib/dpif-netdev-avx512.c
index 1ae66ca6c5..6f9aa8284a 100644
--- a/lib/dpif-netdev-avx512.c
+++ b/lib/dpif-netdev-avx512.c
@@ -127,6 +127,7 @@  dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd,
 
     uint32_t emc_hits = 0;
     uint32_t smc_hits = 0;
+    uint32_t phwol_hits = 0;
 
     /* A 1 bit in this mask indicates a hit, so no DPCLS lookup on the pkt. */
     uint32_t hwol_emc_smc_hitmask = 0;
@@ -178,6 +179,7 @@  dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd,
                 rules[i] = &f->cr;
                 pkt_meta[i].tcp_flags = parse_tcp_flags(packet);
                 pkt_meta[i].bytes = dp_packet_size(packet);
+                phwol_hits++;
                 hwol_emc_smc_hitmask |= (1 << i);
                 continue;
             }
@@ -286,6 +288,7 @@  dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd,
 
     /* At this point we don't return error anymore, so commit stats here. */
     pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_RECV, batch_size);
+    pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_PHWOL_HIT, phwol_hits);
     pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_EXACT_HIT, emc_hits);
     pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_SMC_HIT, smc_hits);
     pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_MASKED_HIT,
diff --git a/lib/dpif-netdev-perf.c b/lib/dpif-netdev-perf.c
index 9560e7c3c3..7103a2d4df 100644
--- a/lib/dpif-netdev-perf.c
+++ b/lib/dpif-netdev-perf.c
@@ -246,6 +246,7 @@  pmd_perf_format_overall_stats(struct ds *str, struct pmd_perf_stats *s,
         ds_put_format(str,
             "  Rx packets:        %12"PRIu64"  (%.0f Kpps, %.0f cycles/pkt)\n"
             "  Datapath passes:   %12"PRIu64"  (%.2f passes/pkt)\n"
+            "  - PHWOL hits:      %12"PRIu64"  (%5.1f %%)\n"
             "  - EMC hits:        %12"PRIu64"  (%5.1f %%)\n"
             "  - SMC hits:        %12"PRIu64"  (%5.1f %%)\n"
             "  - Megaflow hits:   %12"PRIu64"  (%5.1f %%, %.2f "
@@ -255,6 +256,8 @@  pmd_perf_format_overall_stats(struct ds *str, struct pmd_perf_stats *s,
             rx_packets, (rx_packets / duration) / 1000,
             1.0 * stats[PMD_CYCLES_ITER_BUSY] / rx_packets,
             passes, rx_packets ? 1.0 * passes / rx_packets : 0,
+            stats[PMD_STAT_PHWOL_HIT],
+            100.0 * stats[PMD_STAT_PHWOL_HIT] / passes,
             stats[PMD_STAT_EXACT_HIT],
             100.0 * stats[PMD_STAT_EXACT_HIT] / passes,
             stats[PMD_STAT_SMC_HIT],
diff --git a/lib/dpif-netdev-perf.h b/lib/dpif-netdev-perf.h
index 72645b6b3c..8b1a52387c 100644
--- a/lib/dpif-netdev-perf.h
+++ b/lib/dpif-netdev-perf.h
@@ -56,6 +56,7 @@  extern "C" {
 /* Set of counter types maintained in pmd_perf_stats. */
 
 enum pmd_stat_type {
+    PMD_STAT_PHWOL_HIT,     /* Packets that had a partial HWOL hit (phwol). */
     PMD_STAT_EXACT_HIT,     /* Packets that had an exact match (emc). */
     PMD_STAT_SMC_HIT,       /* Packets that had a sig match hit (SMC). */
     PMD_STAT_MASKED_HIT,    /* Packets that matched in the flow table. */
diff --git a/lib/dpif-netdev-unixctl.man b/lib/dpif-netdev-unixctl.man
index 5f92562157..83ce4f1c50 100644
--- a/lib/dpif-netdev-unixctl.man
+++ b/lib/dpif-netdev-unixctl.man
@@ -135,6 +135,7 @@  pmd thread numa_id 0 core_id 1:
   - busy iterations:        86009  ( 84.1 % of used cycles)
   Rx packets:             2399607  (2381 Kpps, 848 cycles/pkt)
   Datapath passes:        3599415  (1.50 passes/pkt)
+  - PHWOL hits:                 0  (  0.0 %)
   - EMC hits:              336472  (  9.3 %)
   - SMC hits:                   0  ( 0.0 %)
   - Megaflow hits:        3262943  ( 90.7 %, 1.00 subtbl lookups/hit)
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index f7b2163bf7..610949f367 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -646,6 +646,7 @@  pmd_info_show_stats(struct ds *reply,
                   "  packets received: %"PRIu64"\n"
                   "  packet recirculations: %"PRIu64"\n"
                   "  avg. datapath passes per packet: %.02f\n"
+                  "  phwol hits: %"PRIu64"\n"
                   "  emc hits: %"PRIu64"\n"
                   "  smc hits: %"PRIu64"\n"
                   "  megaflow hits: %"PRIu64"\n"
@@ -654,7 +655,8 @@  pmd_info_show_stats(struct ds *reply,
                   "  miss with failed upcall: %"PRIu64"\n"
                   "  avg. packets per output batch: %.02f\n",
                   total_packets, stats[PMD_STAT_RECIRC],
-                  passes_per_pkt, stats[PMD_STAT_EXACT_HIT],
+                  passes_per_pkt, stats[PMD_STAT_PHWOL_HIT],
+                  stats[PMD_STAT_EXACT_HIT],
                   stats[PMD_STAT_SMC_HIT],
                   stats[PMD_STAT_MASKED_HIT], lookups_per_hit,
                   stats[PMD_STAT_MISS], stats[PMD_STAT_LOST],
@@ -1683,6 +1685,7 @@  dpif_netdev_get_stats(const struct dpif *dpif, struct dpif_dp_stats *stats)
     CMAP_FOR_EACH (pmd, node, &dp->poll_threads) {
         stats->n_flows += cmap_count(&pmd->flow_table);
         pmd_perf_read_counters(&pmd->perf_stats, pmd_stats);
+        stats->n_hit += pmd_stats[PMD_STAT_PHWOL_HIT];
         stats->n_hit += pmd_stats[PMD_STAT_EXACT_HIT];
         stats->n_hit += pmd_stats[PMD_STAT_SMC_HIT];
         stats->n_hit += pmd_stats[PMD_STAT_MASKED_HIT];
@@ -6805,7 +6808,7 @@  dfc_processing(struct dp_netdev_pmd_thread *pmd,
                bool md_is_valid, odp_port_t port_no)
 {
     struct netdev_flow_key *key = &keys[0];
-    size_t n_missed = 0, n_emc_hit = 0;
+    size_t n_missed = 0, n_emc_hit = 0, n_phwol_hit = 0;
     struct dfc_cache *cache = &pmd->flow_cache;
     struct dp_packet *packet;
     const size_t cnt = dp_packet_batch_size(packets_);
@@ -6852,6 +6855,7 @@  dfc_processing(struct dp_netdev_pmd_thread *pmd,
             }
             if (OVS_LIKELY(flow)) {
                 tcp_flags = parse_tcp_flags(packet);
+                n_phwol_hit++;
                 if (OVS_LIKELY(batch_enable)) {
                     dp_netdev_queue_batches(packet, flow, tcp_flags, batches,
                                             n_batches);
@@ -6914,6 +6918,7 @@  dfc_processing(struct dp_netdev_pmd_thread *pmd,
     /* Count of packets which are not flow batched. */
     *n_flows = map_cnt;
 
+    pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_PHWOL_HIT, n_phwol_hit);
     pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_EXACT_HIT, n_emc_hit);
 
     if (!smc_enable_db) {
diff --git a/tests/pmd.at b/tests/pmd.at
index 9c5824c55c..46d9ede5ec 100644
--- a/tests/pmd.at
+++ b/tests/pmd.at
@@ -202,11 +202,12 @@  dummy@ovs-dummy: hit:0 missed:0
     p0 7/1: (dummy-pmd: configured_rx_queues=4, configured_tx_queues=<cleared>, requested_rx_queues=4, requested_tx_queues=<cleared>)
 ])
 
-AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 9], [0], [dnl
+AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 10], [0], [dnl
 pmd thread numa_id <cleared> core_id <cleared>:
   packets received: 0
   packet recirculations: 0
   avg. datapath passes per packet: 0.00
+  phwol hits: 0
   emc hits: 0
   smc hits: 0
   megaflow hits: 0
@@ -233,11 +234,12 @@  AT_CHECK([cat ovs-vswitchd.log | filter_flow_install | strip_xout], [0], [dnl
 recirc_id(0),in_port(1),packet_type(ns=0,id=0),eth(src=50:54:00:00:00:77,dst=50:54:00:00:01:78),eth_type(0x0800),ipv4(frag=no), actions: <del>
 ])
 
-AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 9], [0], [dnl
+AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 10], [0], [dnl
 pmd thread numa_id <cleared> core_id <cleared>:
   packets received: 20
   packet recirculations: 0
   avg. datapath passes per packet: 1.00
+  phwol hits: 0
   emc hits: 19
   smc hits: 0
   megaflow hits: 0