From patchwork Thu Jun 17 16:27:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493739 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SVd0lwYz9sRf for ; Fri, 18 Jun 2021 02:41:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 1B3C683ED0; Thu, 17 Jun 2021 16:41:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m1ILQ33Dkkh1; Thu, 17 Jun 2021 16:41:09 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id C6D1183E88; Thu, 17 Jun 2021 16:41:08 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9A8D4C000D; Thu, 17 Jun 2021 16:41:08 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6AE68C000B for ; Thu, 17 Jun 2021 16:41:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 67F5483E88 for ; Thu, 17 Jun 2021 16:41:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id goxxJXh8XlPZ for ; Thu, 17 Jun 2021 16:41:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0157383E24 for ; Thu, 17 Jun 2021 16:41:04 +0000 (UTC) IronPort-SDR: U9k+NVQQ+HSLOeq9m3HUXPZmcun/rFzlxWhJzIAobR1dOAGfXzvOWuB8uXRVKo24q0JHoezpcB 698OJulT/iXQ== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719899" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719899" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:04 -0700 IronPort-SDR: gPnP1K8ivddKKzBET2EVTRu7wERkB2mLHg1Smy78L1lxE0GKkFCadZb+Qf/MuYNndFvzMgLqJF fup+M48/WBeg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252834" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:01 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:43 +0530 Message-Id: <20210617162754.2028048-2-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: Kumar Amber , i.maximets@ovn.org Subject: [ovs-dev] [v4 01/12] dpif-netdev: Add command line and function pointer for miniflow extract X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This patch introduces the mfex function pointers which allows the user to switch between different miniflow extract implementations which are provided by the OVS based on optimized ISA CPU. The user can query for the available minflow extract variants available for that CPU by following commands: $ovs-appctl dpif-netdev/miniflow-parser-get Similarly an user can set the miniflow implementation by the following command : $ ovs-appctl dpif-netdev/miniflow-parser-set name This allow for more performance and flexibility to the user to choose the miniflow implementation according to the needs. Signed-off-by: Kumar Amber Co-authored-by: Harry van Haaren Signed-off-by: Harry van Haaren --- lib/automake.mk | 2 + lib/dpif-netdev-avx512.c | 32 ++++++-- lib/dpif-netdev-private-extract.c | 86 ++++++++++++++++++++ lib/dpif-netdev-private-extract.h | 94 ++++++++++++++++++++++ lib/dpif-netdev-private-thread.h | 4 + lib/dpif-netdev.c | 126 +++++++++++++++++++++++++++++- 6 files changed, 337 insertions(+), 7 deletions(-) create mode 100644 lib/dpif-netdev-private-extract.c create mode 100644 lib/dpif-netdev-private-extract.h diff --git a/lib/automake.mk b/lib/automake.mk index 49f42c2a3..6657b9ae5 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -118,6 +118,8 @@ lib_libopenvswitch_la_SOURCES = \ lib/dpif-netdev-private-dpcls.h \ lib/dpif-netdev-private-dpif.c \ lib/dpif-netdev-private-dpif.h \ + lib/dpif-netdev-private-extract.c \ + lib/dpif-netdev-private-extract.h \ lib/dpif-netdev-private-flow.h \ lib/dpif-netdev-private-hwol.h \ lib/dpif-netdev-private-thread.h \ diff --git a/lib/dpif-netdev-avx512.c b/lib/dpif-netdev-avx512.c index f9b199637..bb99b23ff 100644 --- a/lib/dpif-netdev-avx512.c +++ b/lib/dpif-netdev-avx512.c @@ -148,6 +148,15 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, * // do all processing (HWOL->MFEX->EMC->SMC) * } */ + + /* Do a batch minfilow extract into keys. */ + uint32_t mf_mask = 0; + if (pmd->miniflow_extract_opt) { + mf_mask = pmd->miniflow_extract_opt(packets, keys, + batch_size, in_port, + (void *) pmd); + } + /* Perform first packet interation */ uint32_t lookup_pkts_bitmask = (1ULL << batch_size) - 1; uint32_t iter = lookup_pkts_bitmask; while (iter) { @@ -159,6 +168,12 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, pkt_metadata_init(&packet->md, in_port); struct dp_netdev_flow *f = NULL; + struct netdev_flow_key *key = &keys[i]; + + /* Check the minfiflow mask to see if the packet was correctly + * classifed by vector mfex else do a scalar miniflow extract + * for that packet. */ + uint32_t mfex_hit = (mf_mask & (1 << i)); /* Check for partial hardware offload mark. */ uint32_t mark; @@ -166,7 +181,13 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, f = mark_to_flow_find(pmd, mark); if (f) { rules[i] = &f->cr; - pkt_meta[i].tcp_flags = parse_tcp_flags(packet); + /* If AVX512 MFEX already classified the packet, use it. */ + if (mfex_hit) { + pkt_meta[i].tcp_flags = miniflow_get_tcp_flags(&key->mf); + } else { + 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); @@ -174,11 +195,12 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, } } - /* Do miniflow extract into keys. */ - struct netdev_flow_key *key = &keys[i]; - miniflow_extract(packet, &key->mf); + if (!mfex_hit) { + /* Do a scalar miniflow extract into keys */ + miniflow_extract(packet, &key->mf); + } - /* Cache TCP and byte values for all packets. */ + /* Cache TCP and byte values for all packets */ pkt_meta[i].bytes = dp_packet_size(packet); pkt_meta[i].tcp_flags = miniflow_get_tcp_flags(&key->mf); diff --git a/lib/dpif-netdev-private-extract.c b/lib/dpif-netdev-private-extract.c new file mode 100644 index 000000000..fcc56ef26 --- /dev/null +++ b/lib/dpif-netdev-private-extract.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2021 Intel. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "dp-packet.h" +#include "dpif-netdev-private-dpcls.h" +#include "dpif-netdev-private-extract.h" +#include "dpif-netdev-private-thread.h" +#include "flow.h" +#include "openvswitch/vlog.h" +#include "ovs-thread.h" +#include "util.h" + +VLOG_DEFINE_THIS_MODULE(dpif_netdev_extract); + +/* Implementations of available extract options. */ +static struct dpif_miniflow_extract_impl mfex_impls[] = { + { + .probe = NULL, + .extract_func = NULL, + .name = "disable", + }, +}; + +BUILD_ASSERT_DECL(MFEX_IMPLS_MAX_SIZE > ARRAY_SIZE(mfex_impls)); + +int32_t +dpif_miniflow_extract_opt_get(const char *name, + struct dpif_miniflow_extract_impl **opt) +{ + ovs_assert(opt); + ovs_assert(name); + + uint32_t i; + for (i = 0; i < ARRAY_SIZE(mfex_impls); i++) { + if (strcmp(name, mfex_impls[i].name) == 0) { + *opt = &mfex_impls[i]; + return 0; + } + } + return -ENOTSUP; +} + +void +dpif_miniflow_extract_init(void) +{ + /* Call probe on each impl, and cache the result. */ + uint32_t i; + for (i = 0; i < ARRAY_SIZE(mfex_impls); i++) { + int avail = 1; + if (mfex_impls[i].probe) { + /* Return zero is success, non-zero means error. */ + avail = (mfex_impls[i].probe() == 0); + } + VLOG_INFO("Miniflow Extract implementation %s (available: %s)\n", + mfex_impls[i].name, avail ? "True" : "False"); + mfex_impls[i].available = avail; + } +} + +int32_t +dpif_miniflow_extract_info_get(struct dpif_miniflow_extract_impl **out_ptr) +{ + if (out_ptr == NULL) { + return -EINVAL; + } + *out_ptr = mfex_impls; + return ARRAY_SIZE(mfex_impls); +} diff --git a/lib/dpif-netdev-private-extract.h b/lib/dpif-netdev-private-extract.h new file mode 100644 index 000000000..b7b0b2be4 --- /dev/null +++ b/lib/dpif-netdev-private-extract.h @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2021 Intel. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DPIF_NETDEV_AVX512_EXTRACT +#define DPIF_NETDEV_AVX512_EXTRACT 1 + +#include + +#include "openvswitch/types.h" + +/* Max size of dpif_miniflow_extract_impl array. */ +#define MFEX_IMPLS_MAX_SIZE (16) + +/* Forward declarations. */ +struct dp_packet; +struct miniflow; +struct dp_netdev_pmd_thread; +struct dp_packet_batch; +struct netdev_flow_key; + +/* Function pointer prototype to be implemented in the optimized miniflow + * extract code. + * returns the hitmask of the processed packets on success. + * returns zero on failure. + */ +typedef uint32_t (*miniflow_extract_func)(struct dp_packet_batch *batch, + struct netdev_flow_key *keys, + uint32_t keys_size, + odp_port_t in_port, + void *pmd_handle); + +/* Probe function is used to detect if this CPU has the ISA required + * to run the optimized miniflow implementation. + * returns one on successful probe. + * returns zero on failure. + */ +typedef int32_t (*miniflow_extract_probe)(void); + +/* Structure representing the attributes of an optimized implementation. */ +struct dpif_miniflow_extract_impl { + /* When non-zero, this impl has passed the probe() checks. */ + uint8_t available; + + /* Probe function is used to detect if this CPU has the ISA required + * to run the optimized miniflow implementation. + */ + miniflow_extract_probe probe; + + /* Function to call to extract miniflows for a burst of packets. */ + miniflow_extract_func extract_func; + + /* Name of the optimized implementation. */ + char *name; +}; + +/* Retrieve the opt structure for the requested implementation by name. + * Returns zero on success, and opt points to a valid struct, or + * returns a negative failure status. + * -ENOTSUP : invalid name requested + */ +int32_t +dpif_miniflow_extract_opt_get(const char *name, + struct dpif_miniflow_extract_impl **opt); + +/* Initializes the available miniflow extract implementations by probing for + * the CPU ISA requirements. As the runtime available CPU ISA does not change + * and the required ISA of the implementation also does not change, it is safe + * to cache the probe() results, and not call probe() at runtime. + */ +void +dpif_miniflow_extract_init(void); + +/* Retrieve the array of miniflow implementations for iteration. + * On error, returns a negative number. + * On success, returns the size of the arrays pointed to by the out parameter. + */ +int32_t +dpif_miniflow_extract_info_get(struct dpif_miniflow_extract_impl **out_ptr); + + +#endif /* DPIF_NETDEV_AVX512_EXTRACT */ diff --git a/lib/dpif-netdev-private-thread.h b/lib/dpif-netdev-private-thread.h index f89b1ddaa..119eb7396 100644 --- a/lib/dpif-netdev-private-thread.h +++ b/lib/dpif-netdev-private-thread.h @@ -28,6 +28,7 @@ #include "dpif-netdev-private-dpif.h" #include "dpif-netdev-perf.h" #include "openvswitch/thread.h" +#include "dpif-netdev-private-extract.h" #ifdef __cplusplus extern "C" { @@ -110,6 +111,9 @@ struct dp_netdev_pmd_thread { /* Pointer for per-DPIF implementation scratch space. */ void *netdev_input_func_userdata; + /* Function pointer to call for miniflow_extract() functionality. */ + miniflow_extract_func miniflow_extract_opt; + struct seq *reload_seq; uint64_t last_reload_seq; diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index f316835a4..567ebd952 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -46,6 +46,7 @@ #include "dpif.h" #include "dpif-netdev-lookup.h" #include "dpif-netdev-perf.h" +#include "dpif-netdev-private-extract.h" #include "dpif-provider.h" #include "dummy.h" #include "fat-rwlock.h" @@ -1089,6 +1090,102 @@ dpif_netdev_impl_set(struct unixctl_conn *conn, int argc, ds_destroy(&reply); } +static void +dpif_miniflow_extract_impl_get(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED) +{ + struct dpif_miniflow_extract_impl *mfex_impls; + uint32_t count = dpif_miniflow_extract_info_get(&mfex_impls); + if (count == 0) { + unixctl_command_reply_error(conn, "error getting mfex names"); + return; + } + + /* Add all mfex functions to reply string. */ + struct ds reply = DS_EMPTY_INITIALIZER; + ds_put_cstr(&reply, "Available Optimized Miniflow Extracts:\n"); + for (uint32_t i = 0; i < count; i++) { + ds_put_format(&reply, " %s (available: %s)\n", + mfex_impls[i].name, mfex_impls[i].available ? + "True" : "False"); + } + unixctl_command_reply(conn, ds_cstr(&reply)); + ds_destroy(&reply); +} + +static void +dpif_miniflow_extract_impl_set(struct unixctl_conn *conn, int argc, + const char *argv[], void *aux OVS_UNUSED) +{ + /* This function requires just one parameter, the miniflow name. + * A second optional parameter can identify the datapath instance. + */ + const char *mfex_name = argv[1]; + + static const char *error_description[2] = { + "Unknown miniflow implementation", + "implementation doesn't exist", + }; + struct dpif_miniflow_extract_impl *opt; + miniflow_extract_func new_func; + int32_t err = dpif_miniflow_extract_opt_get(mfex_name, &opt); + if (err) { + struct ds reply = DS_EMPTY_INITIALIZER; + ds_put_format(&reply, + "Miniflow implementation not available: %s %s.\n", + error_description[ (err == -ENOTSUP) ], mfex_name); + const char *reply_str = ds_cstr(&reply); + unixctl_command_reply(conn, reply_str); + VLOG_INFO("%s", reply_str); + ds_destroy(&reply); + return; + } + new_func = opt->extract_func; + /* argv[2] is optional datapath instance. If no datapath name is provided. + * and only one datapath exists, the one existing datapath is reprobed. + */ + ovs_mutex_lock(&dp_netdev_mutex); + struct dp_netdev *dp = NULL; + + if (argc == 3) { + dp = shash_find_data(&dp_netdevs, argv[2]); + } else if (shash_count(&dp_netdevs) == 1) { + dp = shash_first(&dp_netdevs)->data; + } + + if (!dp) { + ovs_mutex_unlock(&dp_netdev_mutex); + unixctl_command_reply_error(conn, + "please specify an existing datapath"); + return; + } + + /* Get PMD threads list. */ + size_t n; + struct dp_netdev_pmd_thread **pmd_list; + sorted_poll_thread_list(dp, &pmd_list, &n); + + for (size_t i = 0; i < n; i++) { + struct dp_netdev_pmd_thread *pmd = pmd_list[i]; + if (pmd->core_id == NON_PMD_CORE_ID) { + continue; + } + + /* Set PMD threads miniflow implementation to requested one. */ + pmd->miniflow_extract_opt = *new_func; + }; + + ovs_mutex_unlock(&dp_netdev_mutex); + + /* Reply with success to command. */ + struct ds reply = DS_EMPTY_INITIALIZER; + ds_put_format(&reply, "Miniflow implementation set to %s.\n", mfex_name); + const char *reply_str = ds_cstr(&reply); + unixctl_command_reply(conn, reply_str); + VLOG_INFO("%s", reply_str); + ds_destroy(&reply); +} + static void dpif_netdev_pmd_rebalance(struct unixctl_conn *conn, int argc, const char *argv[], void *aux OVS_UNUSED) @@ -1315,9 +1412,16 @@ dpif_netdev_init(void) "dpif_implementation_name [dp]", 1, 2, dpif_netdev_impl_set, NULL); + unixctl_command_register("dpif-netdev/miniflow-parser-set", + "miniflow implementation name [dp]", + 1, 2, dpif_miniflow_extract_impl_set, + NULL); unixctl_command_register("dpif-netdev/dpif-get", "", 0, 0, dpif_netdev_impl_get, NULL); + unixctl_command_register("dpif-netdev/miniflow-parser-get", "", + 0, 0, dpif_miniflow_extract_impl_get, + NULL); return 0; } @@ -1461,6 +1565,8 @@ create_dp_netdev(const char *name, const struct dpif_class *class, dp->conntrack = conntrack_init(); + dpif_miniflow_extract_init(); + atomic_init(&dp->emc_insert_min, DEFAULT_EM_FLOW_INSERT_MIN); atomic_init(&dp->tx_flush_interval, DEFAULT_TX_FLUSH_INTERVAL); @@ -6176,6 +6282,9 @@ dp_netdev_configure_pmd(struct dp_netdev_pmd_thread *pmd, struct dp_netdev *dp, /* Initialize DPIF function pointer to the default configured version. */ pmd->netdev_input_func = dp_netdev_impl_get_default(); + /*Init default miniflow_extract function */ + pmd->miniflow_extract_opt = NULL; + /* init the 'flow_cache' since there is no * actual thread created for NON_PMD_CORE_ID. */ if (core_id == NON_PMD_CORE_ID) { @@ -6730,10 +6839,12 @@ dfc_processing(struct dp_netdev_pmd_thread *pmd, { struct netdev_flow_key *key = &keys[0]; size_t n_missed = 0, n_emc_hit = 0, n_phwol_hit = 0; + struct dp_packet_batch single_packet; struct dfc_cache *cache = &pmd->flow_cache; struct dp_packet *packet; const size_t cnt = dp_packet_batch_size(packets_); uint32_t cur_min = pmd->ctx.emc_insert_min; + int mf_ret; int i; uint16_t tcp_flags; bool smc_enable_db; @@ -6786,8 +6897,19 @@ dfc_processing(struct dp_netdev_pmd_thread *pmd, continue; } } - - miniflow_extract(packet, &key->mf); + /* Set the count and packet for miniflow_opt with batch_size 1. */ + if ((pmd->miniflow_extract_opt) && (!md_is_valid)) { + single_packet.count = 1; + single_packet.packets[0] = packet; + mf_ret = pmd->miniflow_extract_opt(&single_packet, key, 1, + port_no, (void *) pmd); + /* Fallback to original miniflow_extract if there is a miss. */ + if (!mf_ret) { + miniflow_extract(packet, &key->mf); + } + } else { + miniflow_extract(packet, &key->mf); + } key->len = 0; /* Not computed yet. */ key->hash = (md_is_valid == false) From patchwork Thu Jun 17 16:27:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493740 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SVj5n12z9sRf for ; Fri, 18 Jun 2021 02:41:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A0926421E9; Thu, 17 Jun 2021 16:41:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RUA62W_ozXWe; Thu, 17 Jun 2021 16:41:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id E2DEC421EE; Thu, 17 Jun 2021 16:41:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B69D9C000F; Thu, 17 Jun 2021 16:41:11 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id B2811C000D for ; Thu, 17 Jun 2021 16:41:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7F57783ED0 for ; Thu, 17 Jun 2021 16:41:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WD5ncmAJaIki for ; Thu, 17 Jun 2021 16:41:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id 8007983EC2 for ; Thu, 17 Jun 2021 16:41:09 +0000 (UTC) IronPort-SDR: xwNj/jRuXzXsrGPjS74bW7sZWA4RRzF4aBEHsK7BTuEfYTjxzjjA8qRFS1KjdNYm2h6gyGTJ1/ sp3di+Wt41SQ== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719915" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719915" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:09 -0700 IronPort-SDR: VsMzTXXm28Hxm1Td/1dKqj6Wc9IiIwgFu+J5vD0bZM///aYo/O4Xrp9mslJrtZzPvmAn+zkFrY CsSWzDFtXzww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252874" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:06 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:44 +0530 Message-Id: <20210617162754.2028048-3-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: Kumar Amber , i.maximets@ovn.org Subject: [ovs-dev] [v4 02/12] dpif-netdev: Add auto validation function for miniflow extract X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This patch introduced the auto-validation function which allows users to compare the batch of packets obtained from different miniflow implementations against the linear miniflow extract and return a hitmask. The autovaidator function can be triggered at runtime using the following command: $ ovs-appctl dpif-netdev/miniflow-parser-set autovalidator Signed-off-by: Kumar Amber Co-authored-by: Harry van Haaren Signed-off-by: Harry van Haaren Signed-off-by: Kumar Amber > Signed-off-by: Harry van Haaren > Signed-off-by: Kumar Amber > Signed-off-by: Harry van Haaren > Signed-off-by: Kumar Amber > Signed-off-by: Harry van Haaren > --- lib/dpif-netdev-private-extract.c | 141 ++++++++++++++++++++++++++++++ lib/dpif-netdev-private-extract.h | 15 ++++ lib/dpif-netdev.c | 2 +- 3 files changed, 157 insertions(+), 1 deletion(-) diff --git a/lib/dpif-netdev-private-extract.c b/lib/dpif-netdev-private-extract.c index fcc56ef26..0741c19f9 100644 --- a/lib/dpif-netdev-private-extract.c +++ b/lib/dpif-netdev-private-extract.c @@ -32,6 +32,11 @@ VLOG_DEFINE_THIS_MODULE(dpif_netdev_extract); /* Implementations of available extract options. */ static struct dpif_miniflow_extract_impl mfex_impls[] = { + { + .probe = NULL, + .extract_func = dpif_miniflow_extract_autovalidator, + .name = "autovalidator", + }, { .probe = NULL, .extract_func = NULL, @@ -84,3 +89,139 @@ dpif_miniflow_extract_info_get(struct dpif_miniflow_extract_impl **out_ptr) *out_ptr = mfex_impls; return ARRAY_SIZE(mfex_impls); } + +uint32_t +dpif_miniflow_extract_autovalidator(struct dp_packet_batch *packets, + struct netdev_flow_key *keys, + uint32_t keys_size, odp_port_t in_port, + void *pmd_handle) +{ + const size_t cnt = dp_packet_batch_size(packets); + uint16_t good_l2_5_ofs[NETDEV_MAX_BURST]; + uint16_t good_l3_ofs[NETDEV_MAX_BURST]; + uint16_t good_l4_ofs[NETDEV_MAX_BURST]; + uint16_t good_l2_pad_size[NETDEV_MAX_BURST]; + struct dp_packet *packet; + struct dp_netdev_pmd_thread *pmd = pmd_handle; + struct dpif_miniflow_extract_impl *miniflow_funcs; + + int32_t mfunc_count = dpif_miniflow_extract_info_get(&miniflow_funcs); + if (mfunc_count < 0) { + pmd->miniflow_extract_opt = NULL; + VLOG_ERR("failed to get miniflow extract function implementations\n"); + return 0; + } + ovs_assert(keys_size >= cnt); + struct netdev_flow_key test_keys[NETDEV_MAX_BURST]; + + /* Run scalar miniflow_extract to get default result. */ + DP_PACKET_BATCH_FOR_EACH (i, packet, packets) { + pkt_metadata_init(&packet->md, in_port); + miniflow_extract(packet, &keys[i].mf); + + /* Store known good metadata to compare with optimized metadata. */ + good_l2_5_ofs[i] = packet->l2_5_ofs; + good_l3_ofs[i] = packet->l3_ofs; + good_l4_ofs[i] = packet->l4_ofs; + good_l2_pad_size[i] = packet->l2_pad_size; + } + + /* Iterate through each version of miniflow implementations. */ + for (int j = MFEX_IMPL_START_IDX; j < ARRAY_SIZE(mfex_impls); j++) { + if (!mfex_impls[j].available) { + continue; + } + + /* Reset keys and offsets before each implementation. */ + memset(test_keys, 0, keys_size * sizeof(struct netdev_flow_key)); + DP_PACKET_BATCH_FOR_EACH (i, packet, packets) { + dp_packet_reset_offsets(packet); + } + /* Call optimized miniflow for each batch of packet. */ + uint32_t hit_mask = mfex_impls[j].extract_func(packets, test_keys, + keys_size, in_port, pmd_handle); + + /* Do a miniflow compare for bits, blocks and offsets for all the + * classified packets in the hitmask marked by set bits. */ + while (hit_mask) { + /* Index for the set bit. */ + uint32_t i = __builtin_ctz(hit_mask); + /* Set the index in hitmask to Zero. */ + hit_mask &= (hit_mask - 1); + + uint32_t failed = 0; + + /* Check miniflow bits are equal. */ + if ((keys[i].mf.map.bits[0] != test_keys[i].mf.map.bits[0]) || + (keys[i].mf.map.bits[1] != test_keys[i].mf.map.bits[1])) { + VLOG_ERR("Good 0x%llx 0x%llx\tTest 0x%llx 0x%llx\n", + keys[i].mf.map.bits[0], keys[i].mf.map.bits[1], + test_keys[i].mf.map.bits[0], + test_keys[i].mf.map.bits[1]); + failed = 1; + } + + if (!miniflow_equal(&keys[i].mf, &test_keys[i].mf)) { + uint32_t block_cnt = miniflow_n_values(&keys[i].mf); + VLOG_ERR("Autovalidation blocks failed for %s pkt %d", + mfex_impls[j].name, i); + VLOG_ERR(" Good hexdump:\n"); + uint64_t *good_block_ptr = (uint64_t *)&keys[i].buf; + uint64_t *test_block_ptr = (uint64_t *)&test_keys[i].buf; + for (uint32_t b = 0; b < block_cnt; b++) { + VLOG_ERR(" %"PRIx64"\n", good_block_ptr[b]); + } + VLOG_ERR(" Test hexdump:\n"); + for (uint32_t b = 0; b < block_cnt; b++) { + VLOG_ERR(" %"PRIx64"\n", test_block_ptr[b]); + } + failed = 1; + } + + if ((packets->packets[i]->l2_pad_size != good_l2_pad_size[i]) || + (packets->packets[i]->l2_5_ofs != good_l2_5_ofs[i]) || + (packets->packets[i]->l3_ofs != good_l3_ofs[i]) || + (packets->packets[i]->l4_ofs != good_l4_ofs[i])) { + VLOG_ERR("Autovalidation packet offsets failed for %s pkt %d", + mfex_impls[j].name, i); + VLOG_ERR(" Good offsets: l2_pad_size %u, l2_5_ofs : %u" + " l3_ofs %u, l4_ofs %u\n", + good_l2_pad_size[i], good_l2_5_ofs[i], + good_l3_ofs[i], good_l4_ofs[i]); + VLOG_ERR(" Test offsets: l2_pad_size %u, l2_5_ofs : %u" + " l3_ofs %u, l4_ofs %u\n", + packets->packets[i]->l2_pad_size, + packets->packets[i]->l2_5_ofs, + packets->packets[i]->l3_ofs, + packets->packets[i]->l4_ofs); + failed = 1; + } + + if (failed) { + /* Having dumped the debug info, disable autovalidator. */ + VLOG_ERR("Autovalidation failed in %s pkt %d, disabling.\n", + mfex_impls[j].name, i); + /* Halt OVS here on debug builds. */ + ovs_assert(0); + pmd->miniflow_extract_opt = NULL; + break; + } + } + } + + /* preserve packet correctness by storing back the good offsets in + * packets back. */ + DP_PACKET_BATCH_FOR_EACH (i, packet, packets) { + packet->l2_5_ofs = good_l2_5_ofs[i]; + packet->l3_ofs = good_l3_ofs[i]; + packet->l4_ofs = good_l4_ofs[i]; + packet->l2_pad_size = good_l2_pad_size[i]; + } + + /* Returning zero implies no packets were hit by autovalidation. This + * simplifies unit-tests as changing --enable-mfex-default-autovalidator + * would pass/fail. By always returning zero, autovalidator is a little + * slower, but we gain consistency in testing. + */ + return 0; +} diff --git a/lib/dpif-netdev-private-extract.h b/lib/dpif-netdev-private-extract.h index b7b0b2be4..455a7b590 100644 --- a/lib/dpif-netdev-private-extract.h +++ b/lib/dpif-netdev-private-extract.h @@ -24,6 +24,11 @@ /* Max size of dpif_miniflow_extract_impl array. */ #define MFEX_IMPLS_MAX_SIZE (16) +/* Skip the autovalidator study and null when iterating all available + * miniflow implementations. + */ +#define MFEX_IMPL_START_IDX (1) + /* Forward declarations. */ struct dp_packet; struct miniflow; @@ -90,5 +95,15 @@ dpif_miniflow_extract_init(void); int32_t dpif_miniflow_extract_info_get(struct dpif_miniflow_extract_impl **out_ptr); +/* Retrieve the hitmask of the batch of pakcets which is obtained by comparing + * different miniflow implementations with linear miniflow extract. + * On error, returns a zero. + * On success, returns the number of packets in the batch compared. + */ +uint32_t +dpif_miniflow_extract_autovalidator(struct dp_packet_batch *batch, + struct netdev_flow_key *keys, + uint32_t keys_size, odp_port_t in_port, + void *pmd_handle); #endif /* DPIF_NETDEV_AVX512_EXTRACT */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 567ebd952..4f4ab2790 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1181,8 +1181,8 @@ dpif_miniflow_extract_impl_set(struct unixctl_conn *conn, int argc, struct ds reply = DS_EMPTY_INITIALIZER; ds_put_format(&reply, "Miniflow implementation set to %s.\n", mfex_name); const char *reply_str = ds_cstr(&reply); - unixctl_command_reply(conn, reply_str); VLOG_INFO("%s", reply_str); + unixctl_command_reply(conn, reply_str); ds_destroy(&reply); } From patchwork Thu Jun 17 16:27:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493741 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SVn233sz9sRf for ; Fri, 18 Jun 2021 02:41:21 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 959D883F1F; Thu, 17 Jun 2021 16:41:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XORVcHmjZ7s3; Thu, 17 Jun 2021 16:41:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id A765083E88; Thu, 17 Jun 2021 16:41:16 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 791E4C000D; Thu, 17 Jun 2021 16:41:16 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id AABF6C000D for ; Thu, 17 Jun 2021 16:41:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7E24183EAB for ; Thu, 17 Jun 2021 16:41:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EOmXwtp3_DUg for ; Thu, 17 Jun 2021 16:41:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id 843A083EE0 for ; Thu, 17 Jun 2021 16:41:11 +0000 (UTC) IronPort-SDR: giEmtgfwfsa3xjz1H2x77PhyuWDiJgwRaf/vB4lV3vlUgvwY1Wv12GTlTv4BbE84E1MLb7y+wg JwnFYNxhmaPA== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719920" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719920" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:11 -0700 IronPort-SDR: xSqokOOREeB2p6AygRmLzkUOirag54mHXyACqRKpGYT95ciBszAxa33M4v+oEIwRAsf83WcSXU wTtzvfma4ccg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252893" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:09 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:45 +0530 Message-Id: <20210617162754.2028048-4-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: Kumar Amber , i.maximets@ovn.org Subject: [ovs-dev] [v4 03/12] dpif-netdev: Add study function to select the best mfex function X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" The study function runs all the available implementations of miniflow_extract and makes a choice whose hitmask has maximum hits and sets the mfex to that function. Study can be run at runtime using the following command: $ ovs-appctl dpif-netdev/miniflow-parser-set study Signed-off-by: Kumar Amber Co-authored-by: Harry van Haaren Signed-off-by: Harry van Haaren --- lib/automake.mk | 1 + lib/dpif-netdev-extract-study.c | 119 ++++++++++++++++++++++++++++++ lib/dpif-netdev-private-extract.c | 5 ++ lib/dpif-netdev-private-extract.h | 14 +++- 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 lib/dpif-netdev-extract-study.c diff --git a/lib/automake.mk b/lib/automake.mk index 6657b9ae5..3080bb04a 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -114,6 +114,7 @@ lib_libopenvswitch_la_SOURCES = \ lib/dpif-netdev.c \ lib/dpif-netdev.h \ lib/dpif-netdev-private-dfc.c \ + lib/dpif-netdev-extract-study.c \ lib/dpif-netdev-private-dfc.h \ lib/dpif-netdev-private-dpcls.h \ lib/dpif-netdev-private-dpif.c \ diff --git a/lib/dpif-netdev-extract-study.c b/lib/dpif-netdev-extract-study.c new file mode 100644 index 000000000..d063d040c --- /dev/null +++ b/lib/dpif-netdev-extract-study.c @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2021 Intel. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "dpif-netdev-private-extract.h" +#include "dpif-netdev-private-thread.h" +#include "openvswitch/vlog.h" +#include "ovs-thread.h" + +VLOG_DEFINE_THIS_MODULE(dpif_mfex_extract_study); + +/* Max size of packets to be compared. */ +#define MFEX_MAX_COUNT (128) + +/* This value is the threshold for the amount of packets that + * must hit on the optimized miniflow extract before it will be + * accepted and used in the datapath after the study phase. */ +#define MFEX_MIN_HIT_COUNT_FOR_USE (MFEX_MAX_COUNT / 2) + +/* Struct to hold miniflow study stats. */ +struct study_stats { + uint32_t pkt_count; + uint32_t impl_hitcount[MFEX_IMPLS_MAX_SIZE]; +}; + +/* Define per thread data to hold the study stats. */ +DEFINE_PER_THREAD_MALLOCED_DATA(struct study_stats *, study_stats); + +/* Allocate per thread PMD pointer space for study_stats. */ +static inline struct study_stats * +get_study_stats(void) +{ + struct study_stats *stats = study_stats_get(); + if (OVS_UNLIKELY(!stats)) { + stats = xzalloc(sizeof *stats); + study_stats_set_unsafe(stats); + } + return stats; +} + +uint32_t +mfex_study_traffic(struct dp_packet_batch *packets, + struct netdev_flow_key *keys, + uint32_t keys_size, odp_port_t in_port, + void *pmd_handle) +{ + uint32_t hitmask = 0; + uint32_t mask = 0; + struct dp_netdev_pmd_thread *pmd = pmd_handle; + struct dpif_miniflow_extract_impl *miniflow_funcs; + uint32_t impl_count = dpif_miniflow_extract_info_get(&miniflow_funcs); + struct study_stats *stats = get_study_stats(); + + /* Run traffic optimized miniflow_extract to collect the hitmask + * to be compared after certain packets have been hit to choose + * the best miniflow_extract version for that traffic. */ + for (int i = MFEX_IMPL_START_IDX; i < impl_count; i++) { + if (miniflow_funcs[i].available) { + hitmask = miniflow_funcs[i].extract_func(packets, keys, keys_size, + in_port, pmd_handle); + stats->impl_hitcount[i] += count_1bits(hitmask); + + /* If traffic is not classified than we dont overwrite the keys + * array in minfiflow implementations so its safe to create a + * mask for all those packets whose miniflow have been created. */ + mask |= hitmask; + } + } + stats->pkt_count += dp_packet_batch_size(packets); + + /* Choose the best implementation after a minimum packets have been + * processed. */ + if (stats->pkt_count >= MFEX_MAX_COUNT) { + uint32_t best_func_index = MFEX_IMPL_START_IDX; + uint32_t max_hits = 0; + for (int i = MFEX_IMPL_START_IDX; i < impl_count; i++) { + if (stats->impl_hitcount[i] > max_hits) { + max_hits = stats->impl_hitcount[i]; + best_func_index = i; + } + } + + if (max_hits >= MFEX_MIN_HIT_COUNT_FOR_USE) { + /* Set the implementation to index with max_hits. */ + pmd->miniflow_extract_opt = + miniflow_funcs[best_func_index].extract_func; + VLOG_INFO("MFEX study chose impl %s: (hits %d/%d pkts)\n", + miniflow_funcs[best_func_index].name, max_hits, + stats->pkt_count); + } else { + /* Set the implementation to null for default miniflow. */ + pmd->miniflow_extract_opt = NULL; + VLOG_INFO("Not enough packets matched (%d/%d), disabling" + " optimized MFEX.\n", max_hits, stats->pkt_count); + } + /* Reset stats so that study function can be called again + * for next traffic type and optimal function ptr can be + * choosen. */ + memset(stats, 0, sizeof(struct study_stats)); + } + return mask; +} diff --git a/lib/dpif-netdev-private-extract.c b/lib/dpif-netdev-private-extract.c index 0741c19f9..d86268a1d 100644 --- a/lib/dpif-netdev-private-extract.c +++ b/lib/dpif-netdev-private-extract.c @@ -42,6 +42,11 @@ static struct dpif_miniflow_extract_impl mfex_impls[] = { .extract_func = NULL, .name = "disable", }, + { + .probe = NULL, + .extract_func = mfex_study_traffic, + .name = "study", + }, }; BUILD_ASSERT_DECL(MFEX_IMPLS_MAX_SIZE > ARRAY_SIZE(mfex_impls)); diff --git a/lib/dpif-netdev-private-extract.h b/lib/dpif-netdev-private-extract.h index 455a7b590..3ada413bb 100644 --- a/lib/dpif-netdev-private-extract.h +++ b/lib/dpif-netdev-private-extract.h @@ -27,7 +27,7 @@ /* Skip the autovalidator study and null when iterating all available * miniflow implementations. */ -#define MFEX_IMPL_START_IDX (1) +#define MFEX_IMPL_START_IDX (3) /* Forward declarations. */ struct dp_packet; @@ -106,4 +106,16 @@ dpif_miniflow_extract_autovalidator(struct dp_packet_batch *batch, uint32_t keys_size, odp_port_t in_port, void *pmd_handle); +/* Retrieve the number of packets by studying packets using different miniflow + * implementations to choose the best implementation using the maximum hitmask + * count. + * On error, returns a zero for no packets. + * On success, returns mask of the packets hit. + */ +uint32_t +mfex_study_traffic(struct dp_packet_batch *packets, + struct netdev_flow_key *keys, + uint32_t keys_size, odp_port_t in_port, + void *pmd_handle); + #endif /* DPIF_NETDEV_AVX512_EXTRACT */ From patchwork Thu Jun 17 16:27:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493742 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SVt6zhzz9sRf for ; Fri, 18 Jun 2021 02:41:26 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8DF268419A; Thu, 17 Jun 2021 16:41:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KxAwchD48ii9; Thu, 17 Jun 2021 16:41:22 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 01EAF83FA7; Thu, 17 Jun 2021 16:41:21 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AE7F3C000F; Thu, 17 Jun 2021 16:41:20 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 11B23C000B for ; Thu, 17 Jun 2021 16:41:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CF56483F06 for ; Thu, 17 Jun 2021 16:41:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pqVIQby6OCn4 for ; Thu, 17 Jun 2021 16:41:13 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7289A83E33 for ; Thu, 17 Jun 2021 16:41:13 +0000 (UTC) IronPort-SDR: SHy33aS8gaEKKstPCkywnfJHYaPP1GU536HPaV3VJLjCkj7Wx96uokuq0tvdv3PjubZcyxqYGw 013v0YZnmlaA== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719922" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719922" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:13 -0700 IronPort-SDR: tXLtmnaVG6rM0gXeVm3BhiKbjPdw7XceGSGhBOBdaVSL0rsZcFI+QAq+AnBjZx8uzAYcsc/p5y YBxJtMTeAB3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252900" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:11 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:46 +0530 Message-Id: <20210617162754.2028048-5-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: Kumar Amber , i.maximets@ovn.org Subject: [ovs-dev] [v4 04/12] docs/dpdk/bridge: add miniflow extract section. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This commit adds a section to the dpdk/bridge.rst netdev documentation, detailing the added miniflow functionality. The newly added commands are documented, and sample output is provided. The use of auto-validator and special study function is also described in detail as well as running fuzzy tests. Signed-off-by: Kumar Amber Co-authored-by: Cian Ferriter Signed-off-by: Cian Ferriter Co-authored-by: Harry van Haaren Signed-off-by: Harry van Haaren --- Documentation/topics/dpdk/bridge.rst | 105 +++++++++++++++++++++++++++ NEWS | 3 + 2 files changed, 108 insertions(+) diff --git a/Documentation/topics/dpdk/bridge.rst b/Documentation/topics/dpdk/bridge.rst index f59e26cbe..b262b98f8 100644 --- a/Documentation/topics/dpdk/bridge.rst +++ b/Documentation/topics/dpdk/bridge.rst @@ -256,3 +256,108 @@ The following line should be seen in the configure output when the above option is used :: checking whether DPIF AVX512 is default implementation... yes + +Miniflow Extract +---------------- + +Miniflow extract (MFEX) performs parsing of the raw packets and extracts the +important header information into a compressed miniflow. This miniflow is +composed of bits and blocks where the bits signify which blocks are set or +have values where as the blocks hold the metadata, ip, udp, vlan, etc. These +values are used by the datapath for switching decisions later. + +Most modern CPUs are have SIMD capabilities. These SIMD instructions are able +to process a vector rather than act on one single data. OVS provides multiple +implementations of miniflow extract. This allows the user to take advantage +of SIMD instructions like AVX512 to gain additional performance. + +A list of implementations can be obtained by the following command. The +command also shows whether the CPU supports each implementation :: + + $ ovs-appctl dpif-netdev/miniflow-parser-get + Available Optimized Miniflow Extracts: + autovalidator (available: True) + disable (available: True) + study (available: True) + avx512_ip_udp (available: True) + +An implementation can be selected manually by the following command :: + + $ ovs-appctl dpif-netdev/miniflow-parser-set study + +Also user can select the study implementation which studies the traffic for +a specific number of packets by applying all availbale implementaions of +miniflow extract and than chooses the one with most optimal result for that +traffic pattern. + +Miniflow Extract Validation +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +As multiple versions of miniflow extract can co-exist, each with different +CPU ISA optimizations, it is important to validate that they all give the +exact same results. To easily test all miniflow implementations, an +``autovalidator`` implementation of the miniflow exists. This implementation +runs all other available miniflow extract implementations, and verifies that +the results are identical. + +Running the OVS unit tests with the autovalidator enabled ensures all +implementations provide the same results. + +To set the Miniflow autovalidator, use this command :: + + $ ovs-appctl dpif-netdev/miniflow-parser-set autovalidator + +Unit Test Miniflow Extract +++++++++++++++++++++++++++ + +Unit test can also be used to test the workflow mentioned above by running +the following test-case in tests/system-dpdk.at :: + + make check-dpdk TESTSUITEFLAGS=6 + 6: OVS-DPDK - MFEX Autovalidator + +The unit test uses mulitple traffic type to test the correctness of the +implementaions. + +Running Fuzzy test with Autovalidator ++++++++++++++++++++++++++++++++++++++ + +Fuzzy tests can also be done on minfilow extract with the help of +auto-validator and Scapy. The steps below describes the steps to +reproduce the setup with IP being fuzzed to generate packets. + +Scapy is used to create fuzzy IP packets and save them into a PCAP :: + + pkt = fuzz(Ether()/IP()/TCP()) + +Set the miniflow extract to autovalidator using :: + + $ ovs-appctl dpif-netdev/miniflow-parser-set autovalidator + +OVS is configured to receive the generated packets :: + + $ ovs-vsctl add-port br0 pcap0 -- \ + set Interface pcap0 type=dpdk options:dpdk-devargs=net_pcap0 + "rx_pcap=fuzzy.pcap" + +With this workflow, the autovalidator will ensure that all MFEX +implementations are classifying each packet in exactly the same way. +If an optimized MFEX implementation causes a different miniflow to be +generated, the autovalidator has ovs_assert and logging statements that +will inform about the issue. + +Unit Fuzzy test with Autovalidator ++++++++++++++++++++++++++++++++++++++ + +The prerquiste before running the unit test is to run the script provided :: + + tests/pcap/fuzzy.py + +This script generates a pcap with mulitple type of fuzzed packets to be used +in the below unit test-case. + +Unit test can also be used to test the workflow mentioned above by running +the following test-case in tests/system-dpdk.at :: + + make check-dpdk TESTSUITEFLAGS=7 + 7: OVS-DPDK - MFEX Autovalidator Fuzzy diff --git a/NEWS b/NEWS index bc1db7948..63a485309 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,9 @@ Post-v2.15.0 * Enable the AVX512 DPCLS implementation to use VPOPCNT instruction if the CPU supports it. This enhances performance by using the native vpopcount instructions, instead of the emulated version of vpopcount. + * An optimized miniflow extract (mfex) implementation is now available, + which uses CPU SIMD ISA to parse specific traffic profiles efficiently. + Refer to the documentation for details on how to enable it at runtime. - ovs-ctl: * New option '--no-record-hostname' to disable hostname configuration in ovsdb on startup. From patchwork Thu Jun 17 16:27:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493743 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SVw0LdRz9sRf for ; Fri, 18 Jun 2021 02:41:28 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0E34E60AF9; Thu, 17 Jun 2021 16:41:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uloH3W8tqgdq; Thu, 17 Jun 2021 16:41:24 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 2141260AE9; Thu, 17 Jun 2021 16:41:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DF49EC000F; Thu, 17 Jun 2021 16:41:22 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 165E1C0023 for ; Thu, 17 Jun 2021 16:41:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 9060283E24 for ; Thu, 17 Jun 2021 16:41:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n7dID82MVbBs for ; Thu, 17 Jun 2021 16:41:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id BC90083E88 for ; Thu, 17 Jun 2021 16:41:15 +0000 (UTC) IronPort-SDR: Ltrs5nbMxDRi4YecyWwe9a7oILc2mcS3PHZGxZ0CwxUbB9clK81yQ3PO+29avbEggxLrpXZ5Pr me8wKhJVdXRA== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719925" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719925" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:15 -0700 IronPort-SDR: HoMUCV5CByqaUyk2xTf8tQa6PN4NEbYAAfA54YMUPf61d/4XVNtx2XNToTx/ceilGwvJ0pr9Yo NjaTLn9OEU/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252907" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:13 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:47 +0530 Message-Id: <20210617162754.2028048-6-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: Kumar Amber , i.maximets@ovn.org Subject: [ovs-dev] [v4 05/12] dpif-netdev: Add configure to enable autovalidator at build time. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This commit adds a new command to allow the user to enable autovalidatior by default at build time thus allowing for runnig unit test by default. $ ./configure --enable-mfex-default-autovalidator Signed-off-by: Kumar Amber Co-authored-by: Harry van Haaren Signed-off-by: Harry van Haaren --- Documentation/topics/dpdk/bridge.rst | 5 +++++ NEWS | 12 +++++++++++- acinclude.m4 | 16 ++++++++++++++++ configure.ac | 1 + lib/dpif-netdev-private-extract.c | 24 ++++++++++++++++++++++++ lib/dpif-netdev-private-extract.h | 10 ++++++++++ lib/dpif-netdev.c | 7 +++++-- 7 files changed, 72 insertions(+), 3 deletions(-) diff --git a/Documentation/topics/dpdk/bridge.rst b/Documentation/topics/dpdk/bridge.rst index b262b98f8..1c78adc75 100644 --- a/Documentation/topics/dpdk/bridge.rst +++ b/Documentation/topics/dpdk/bridge.rst @@ -307,6 +307,11 @@ To set the Miniflow autovalidator, use this command :: $ ovs-appctl dpif-netdev/miniflow-parser-set autovalidator +A compile time option is available in order to test it with the OVS unit +test suite. Use the following configure option :: + + $ ./configure --enable-mfex-default-autovalidator + Unit Test Miniflow Extract ++++++++++++++++++++++++++ diff --git a/NEWS b/NEWS index 63a485309..ed9f4d4c4 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,17 @@ Post-v2.15.0 * An optimized miniflow extract (mfex) implementation is now available, which uses CPU SIMD ISA to parse specific traffic profiles efficiently. Refer to the documentation for details on how to enable it at runtime. + * Cache results for CPU ISA checks, reduces overhead on repeated lookups. + * Add command line option to switch between mfex function pointers. + * Add miniflow extract auto-validator function to compare different + miniflow extract implementations against default implementation. + * Add study function to miniflow function table which studies packet + and automatically chooses the best miniflow implementation for that + traffic. + * Add AVX512 based optimized miniflow extract function for traffic type + IP/UDP. + * Add build time configure command to enable auto-validatior as default + miniflow implementation at build time. - ovs-ctl: * New option '--no-record-hostname' to disable hostname configuration in ovsdb on startup. @@ -35,7 +46,6 @@ Post-v2.15.0 * New option '--election-timer' to the 'create-cluster' command to set the leader election timer during cluster creation. - v2.15.0 - 15 Feb 2021 --------------------- - OVSDB: diff --git a/acinclude.m4 b/acinclude.m4 index 5fbcd9872..e2704cfda 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -14,6 +14,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +dnl Set OVS MFEX Autovalidator as default miniflow extract at compile time? +dnl This enables automatically running all unit tests with all MFEX +dnl implementations. +AC_DEFUN([OVS_CHECK_MFEX_AUTOVALIDATOR], [ + AC_ARG_ENABLE([mfex-default-autovalidator], + [AC_HELP_STRING([--enable-mfex-default-autovalidator], [Enable MFEX autovalidator as default miniflow_extract implementation.])], + [autovalidator=yes],[autovalidator=no]) + AC_MSG_CHECKING([whether MFEX Autovalidator is default implementation]) + if test "$autovalidator" != yes; then + AC_MSG_RESULT([no]) + else + OVS_CFLAGS="$OVS_CFLAGS -DMFEX_AUTOVALIDATOR_DEFAULT" + AC_MSG_RESULT([yes]) + fi +]) + dnl Set OVS DPCLS Autovalidator as default subtable search at compile time? dnl This enables automatically running all unit tests with all DPCLS dnl implementations. diff --git a/configure.ac b/configure.ac index e45685a6c..46c402892 100644 --- a/configure.ac +++ b/configure.ac @@ -186,6 +186,7 @@ OVS_ENABLE_SPARSE OVS_CTAGS_IDENTIFIERS OVS_CHECK_DPCLS_AUTOVALIDATOR OVS_CHECK_DPIF_AVX512_DEFAULT +OVS_CHECK_MFEX_AUTOVALIDATOR OVS_CHECK_BINUTILS_AVX512 AC_ARG_VAR(KARCH, [Kernel Architecture String]) diff --git a/lib/dpif-netdev-private-extract.c b/lib/dpif-netdev-private-extract.c index d86268a1d..2008e5ee5 100644 --- a/lib/dpif-netdev-private-extract.c +++ b/lib/dpif-netdev-private-extract.c @@ -230,3 +230,27 @@ dpif_miniflow_extract_autovalidator(struct dp_packet_batch *packets, */ return 0; } + +/* Variable to hold the defaualt mfex implementation. */ +static miniflow_extract_func default_mfex_func = NULL; + +void +dpif_miniflow_extract_set_default(miniflow_extract_func func) +{ + default_mfex_func = func; +} + +miniflow_extract_func +dpif_miniflow_extract_get_default(void) +{ + +#ifdef MFEX_AUTOVALIDATOR_DEFAULT + ovs_assert(mfex_impls[0].extract_func == + dpif_miniflow_extract_autovalidator); + VLOG_INFO("Default miniflow Extract implementation %s \n", + mfex_impls[0].name); + return mfex_impls[0].extract_func; +#else + return default_mfex_func; +#endif +} diff --git a/lib/dpif-netdev-private-extract.h b/lib/dpif-netdev-private-extract.h index 3ada413bb..d8a284db7 100644 --- a/lib/dpif-netdev-private-extract.h +++ b/lib/dpif-netdev-private-extract.h @@ -118,4 +118,14 @@ mfex_study_traffic(struct dp_packet_batch *packets, uint32_t keys_size, odp_port_t in_port, void *pmd_handle); +/* Retrieve the default miniflow extract or auto-validator + * based upon build time configuration choosen by the user. */ +miniflow_extract_func +dpif_miniflow_extract_get_default(void); + +/* Returns the default MFEX which is first ./configure selected, but can be + * overridden at runtime. */ +void +dpif_miniflow_extract_set_default(miniflow_extract_func func); + #endif /* DPIF_NETDEV_AVX512_EXTRACT */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 4f4ab2790..716e0debf 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1177,6 +1177,9 @@ dpif_miniflow_extract_impl_set(struct unixctl_conn *conn, int argc, ovs_mutex_unlock(&dp_netdev_mutex); + /* Set the default implementation for PMD threads created in the future. */ + dpif_miniflow_extract_set_default(*new_func); + /* Reply with success to command. */ struct ds reply = DS_EMPTY_INITIALIZER; ds_put_format(&reply, "Miniflow implementation set to %s.\n", mfex_name); @@ -6282,8 +6285,8 @@ dp_netdev_configure_pmd(struct dp_netdev_pmd_thread *pmd, struct dp_netdev *dp, /* Initialize DPIF function pointer to the default configured version. */ pmd->netdev_input_func = dp_netdev_impl_get_default(); - /*Init default miniflow_extract function */ - pmd->miniflow_extract_opt = NULL; + /* Init default miniflow_extract function */ + pmd->miniflow_extract_opt = dpif_miniflow_extract_get_default(); /* init the 'flow_cache' since there is no * actual thread created for NON_PMD_CORE_ID. */ From patchwork Thu Jun 17 16:27:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493744 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SW12MR2z9sRf for ; Fri, 18 Jun 2021 02:41:33 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0110B40628; Thu, 17 Jun 2021 16:41:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hyXzmCDg8XIJ; Thu, 17 Jun 2021 16:41:29 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id A77AF405FB; Thu, 17 Jun 2021 16:41:28 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6652CC000D; Thu, 17 Jun 2021 16:41:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2913EC0022 for ; Thu, 17 Jun 2021 16:41:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id BB32A83F21 for ; Thu, 17 Jun 2021 16:41:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BfJML_I79r-R for ; Thu, 17 Jun 2021 16:41:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id DD14783F13 for ; Thu, 17 Jun 2021 16:41:17 +0000 (UTC) IronPort-SDR: i1ehf4yy+FoKGVLRrC0vYidhOClDqK1HswX/WIKGSPqAMjDOV94ZkN+sgfC5qCGTbZmK+Jkgiw 6t3564b8+vfQ== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719929" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719929" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:17 -0700 IronPort-SDR: VSReKf28QaxPWlYlzcbgYyJn3O2tnvdK3zWk1EA8uVCPf/8kbEraPIN4Cz0JJAoOw7dnX9zCax SRghlQx/jVLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252914" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:15 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:48 +0530 Message-Id: <20210617162754.2028048-7-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: Kumar Amber , i.maximets@ovn.org Subject: [ovs-dev] [v4 06/12] dpif-netdev: Add additional packet count parameter for study function X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This commit introduces additonal command line paramter for mfex study function. If user provides additional packet out it is used in study to compare minimum packets which must be processed else a default value is choosen. $ OVS_DIR/utilities/ovs-appctl dpif-netdev/miniflow-parser-set study 500 Signed-off-by: Kumar Amber --- Documentation/topics/dpdk/bridge.rst | 8 ++++++- lib/dpif-netdev-extract-study.c | 15 +++++++++++- lib/dpif-netdev-private-extract.h | 8 +++++++ lib/dpif-netdev.c | 34 +++++++++++++++++++++++----- 4 files changed, 57 insertions(+), 8 deletions(-) diff --git a/Documentation/topics/dpdk/bridge.rst b/Documentation/topics/dpdk/bridge.rst index 1c78adc75..e7e91289a 100644 --- a/Documentation/topics/dpdk/bridge.rst +++ b/Documentation/topics/dpdk/bridge.rst @@ -288,7 +288,13 @@ An implementation can be selected manually by the following command :: Also user can select the study implementation which studies the traffic for a specific number of packets by applying all availbale implementaions of miniflow extract and than chooses the one with most optimal result for that -traffic pattern. +traffic pattern. User can also provide additonal parameter as packet count +which is minimum packets which OVS must study before choosing optimal +implementation, If no packet count is provided than default value is choosen. + +Study can be selected with packet count by the following command :: + + $ ovs-appctl dpif-netdev/miniflow-parser-set study 1024 Miniflow Extract Validation ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/dpif-netdev-extract-study.c b/lib/dpif-netdev-extract-study.c index d063d040c..c48fb125e 100644 --- a/lib/dpif-netdev-extract-study.c +++ b/lib/dpif-netdev-extract-study.c @@ -55,6 +55,19 @@ get_study_stats(void) return stats; } +static uint32_t pkt_compare_count = 0; + +uint32_t mfex_set_study_pkt_cnt(uint32_t pkt_cmp_count, + struct dpif_miniflow_extract_impl *opt) +{ + if ((opt->extract_func == mfex_study_traffic) && (pkt_cmp_count != 0)) { + pkt_compare_count = pkt_cmp_count; + return 0; + } + pkt_compare_count = MFEX_MAX_COUNT; + return -EINVAL; +} + uint32_t mfex_study_traffic(struct dp_packet_batch *packets, struct netdev_flow_key *keys, @@ -87,7 +100,7 @@ mfex_study_traffic(struct dp_packet_batch *packets, /* Choose the best implementation after a minimum packets have been * processed. */ - if (stats->pkt_count >= MFEX_MAX_COUNT) { + if (stats->pkt_count >= pkt_compare_count) { uint32_t best_func_index = MFEX_IMPL_START_IDX; uint32_t max_hits = 0; for (int i = MFEX_IMPL_START_IDX; i < impl_count; i++) { diff --git a/lib/dpif-netdev-private-extract.h b/lib/dpif-netdev-private-extract.h index d8a284db7..0ec74bef9 100644 --- a/lib/dpif-netdev-private-extract.h +++ b/lib/dpif-netdev-private-extract.h @@ -127,5 +127,13 @@ dpif_miniflow_extract_get_default(void); * overridden at runtime. */ void dpif_miniflow_extract_set_default(miniflow_extract_func func); +/* Sets the packet count from user to the stats for use in + * study function to match against the classified packets to choose + * the optimal implementation. + * On error, returns EINVAL. + * On success, returns 0. + */ +uint32_t mfex_set_study_pkt_cnt(uint32_t pkt_cmp_count, + struct dpif_miniflow_extract_impl *opt); #endif /* DPIF_NETDEV_AVX512_EXTRACT */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 716e0debf..35c927d55 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1141,14 +1141,29 @@ dpif_miniflow_extract_impl_set(struct unixctl_conn *conn, int argc, return; } new_func = opt->extract_func; - /* argv[2] is optional datapath instance. If no datapath name is provided. + + /* argv[2] is optional packet count, which user can provide along with + * study function to set the minimum packet that must be matched in order + * to choose the optimal function. */ + uint32_t pkt_cmp_count = 0; + uint32_t study_ret; + if (argc == 3) { + char *err_str; + pkt_cmp_count = strtoul(argv[2], &err_str, 10); + study_ret = mfex_set_study_pkt_cnt(pkt_cmp_count, opt); + } else { + /* Default packet compare count when packets count not provided. */ + study_ret = mfex_set_study_pkt_cnt(0, opt); + } + + /* argv[3] is optional datapath instance. If no datapath name is provided. * and only one datapath exists, the one existing datapath is reprobed. */ ovs_mutex_lock(&dp_netdev_mutex); struct dp_netdev *dp = NULL; - if (argc == 3) { - dp = shash_find_data(&dp_netdevs, argv[2]); + if (argc == 4) { + dp = shash_find_data(&dp_netdevs, argv[3]); } else if (shash_count(&dp_netdevs) == 1) { dp = shash_first(&dp_netdevs)->data; } @@ -1182,7 +1197,14 @@ dpif_miniflow_extract_impl_set(struct unixctl_conn *conn, int argc, /* Reply with success to command. */ struct ds reply = DS_EMPTY_INITIALIZER; - ds_put_format(&reply, "Miniflow implementation set to %s.\n", mfex_name); + if (study_ret == 0) { + ds_put_format(&reply, "Miniflow implementation set to %s" + "(minimum packet to study: %d)\n", + mfex_name, pkt_cmp_count); + } else { + ds_put_format(&reply, "Miniflow implementation set to %s.\n", + mfex_name); + } const char *reply_str = ds_cstr(&reply); VLOG_INFO("%s", reply_str); unixctl_command_reply(conn, reply_str); @@ -1416,8 +1438,8 @@ dpif_netdev_init(void) 1, 2, dpif_netdev_impl_set, NULL); unixctl_command_register("dpif-netdev/miniflow-parser-set", - "miniflow implementation name [dp]", - 1, 2, dpif_miniflow_extract_impl_set, + "miniflow implementation name [pkt_cnt] [dp]", + 1, 3, dpif_miniflow_extract_impl_set, NULL); unixctl_command_register("dpif-netdev/dpif-get", "", 0, 0, dpif_netdev_impl_get, From patchwork Thu Jun 17 16:27:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493745 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SWF6895z9sRf for ; Fri, 18 Jun 2021 02:41:45 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 507CE42263; Thu, 17 Jun 2021 16:41:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xxnZNG9KV57I; Thu, 17 Jun 2021 16:41:41 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 656C741642; Thu, 17 Jun 2021 16:41:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3C307C000D; Thu, 17 Jun 2021 16:41:40 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id AA1A6C000B for ; Thu, 17 Jun 2021 16:41:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 91CFE83F06 for ; Thu, 17 Jun 2021 16:41:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Na93QxCxj1Ia for ; Thu, 17 Jun 2021 16:41:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id CB6D283EE0 for ; Thu, 17 Jun 2021 16:41:19 +0000 (UTC) IronPort-SDR: RnPDYx8tadMcDfaX5YhItQEO+bi301l5XM9R85yDSb5/8VI6E6mzeVQHlUwLgMLY9yqAgtFVV4 ZyKfu1UqrgAg== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719934" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719934" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:19 -0700 IronPort-SDR: aT+IzD/GhIjphaUQSDhv4DhyOQRWYL/lbTWZ9iL+BzOREBQzKpZuPTpcMsmoXxK9alezU+TiFE 77hY5uT2hHKw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252923" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:17 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:49 +0530 Message-Id: <20210617162754.2028048-8-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: Kumar Amber , i.maximets@ovn.org Subject: [ovs-dev] [v4 07/12] test/sytem-dpdk: Add unit test for mfex autovalidator X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Tests: 6: OVS-DPDK - MFEX Autovalidator 7: OVS-DPDK - MFEX Autovalidator Fuzzy Added a new directory to store the PCAP file used in the tests and a script to generate the fuzzy traffic type pcap to be used in fuzzy unit test. Signed-off-by: Kumar Amber --- tests/automake.mk | 5 +++++ tests/pcap/fuzzy.py | 32 ++++++++++++++++++++++++++++++ tests/pcap/mfex_test | Bin 0 -> 416 bytes tests/system-dpdk.at | 46 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100755 tests/pcap/fuzzy.py create mode 100644 tests/pcap/mfex_test diff --git a/tests/automake.mk b/tests/automake.mk index 1a528aa39..532875971 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -142,6 +142,11 @@ $(srcdir)/tests/fuzz-regression-list.at: tests/automake.mk echo "TEST_FUZZ_REGRESSION([$$basename])"; \ done > $@.tmp && mv $@.tmp $@ +EXTRA_DIST += $(MFEX_AUTOVALIDATOR_TESTS) +MFEX_AUTOVALIDATOR_TESTS = \ + tests/pcap/mfex_test \ + tests/pcap/fuzzy.py + OVSDB_CLUSTER_TESTSUITE_AT = \ tests/ovsdb-cluster-testsuite.at \ tests/ovsdb-execution.at \ diff --git a/tests/pcap/fuzzy.py b/tests/pcap/fuzzy.py new file mode 100755 index 000000000..a8051ba2b --- /dev/null +++ b/tests/pcap/fuzzy.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 +try: + from scapy.all import * +except ModuleNotFoundError as err: + print(err + ": Scapy") +import sys +import os + +path = os.environ['OVS_DIR'] + "/tests/pcap/fuzzy" +pktdump = PcapWriter(path, append=False, sync=True) + +for i in range(0, 2000): + + # Generate random protocol bases, use a fuzz() over the combined packet for full fuzzing. + eth = Ether(src=RandMAC(), dst=RandMAC()) + vlan = Dot1Q() + ipv4 = IP(src=RandIP(), dst=RandIP()) + ipv6 = IPv6(src=RandIP6(), dst=RandIP6()) + udp = UDP() + tcp = TCP() + + # IPv4 packets with fuzzing + pktdump.write(fuzz(eth/ipv4/udp)) + pktdump.write(fuzz(eth/ipv4/tcp)) + pktdump.write(fuzz(eth/vlan/ipv4/udp)) + pktdump.write(fuzz(eth/vlan/ipv4/tcp)) + + # IPv6 packets with fuzzing + pktdump.write(fuzz(eth/ipv6/udp)) + pktdump.write(fuzz(eth/ipv6/tcp)) + pktdump.write(fuzz(eth/vlan/ipv6/udp)) + pktdump.write(fuzz(eth/vlan/ipv6/tcp)) \ No newline at end of file diff --git a/tests/pcap/mfex_test b/tests/pcap/mfex_test new file mode 100644 index 0000000000000000000000000000000000000000..1aac67b8d643ecb016c758cba4cc32212a80f52a GIT binary patch literal 416 zcmca|c+)~A1{MYw`2U}Qff2}QK`M68ITRa|G@yFii5$Gfk6YL%z>@uY&}o| z2s4N<1VH2&7y^V87$)XGOtD~MV$cFgfG~zBGGJ2#YtF$KST_NTIwYriok6N4Vm)gX-Q@c^{cp<7_5LgK^UuU{2>VS0RZ!RQ+EIW literal 0 HcmV?d00001 diff --git a/tests/system-dpdk.at b/tests/system-dpdk.at index 802895488..46eaea35a 100644 --- a/tests/system-dpdk.at +++ b/tests/system-dpdk.at @@ -232,3 +232,49 @@ OVS_VSWITCHD_STOP(["\@does not exist. The Open vSwitch kernel module is probably \@EAL: No free hugepages reported in hugepages-1048576kB@d"]) AT_CLEANUP dnl -------------------------------------------------------------------------- + +dnl -------------------------------------------------------------------------- +dnl Add standard DPDK PHY port +AT_SETUP([OVS-DPDK - MFEX Autovalidator]) +AT_KEYWORDS([dpdk]) + +OVS_DPDK_START() + +dnl Add userspace bridge and attach it to OVS +AT_CHECK([ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev]) +AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dpdk options:dpdk-devargs=net_pcap1,rx_pcap=$OVS_DIR/tests/pcap/mfex_test,infinite_rx=1], [], [stdout], [stderr]) +AT_CHECK([ovs-vsctl show], [], [stdout]) + + +AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set autovalidator], [0], [dnl +Miniflow implementation set to autovalidator. +]) +sleep 5 + +dnl Clean up +AT_CHECK([ovs-vsctl del-port br0 p1], [], [stdout], [stderr]) +AT_CLEANUP +dnl -------------------------------------------------------------------------- + +dnl -------------------------------------------------------------------------- +dnl Add standard DPDK PHY port +AT_SETUP([OVS-DPDK - MFEX Autovalidator Fuzzy]) +AT_KEYWORDS([dpdk]) +AT_CHECK([$PYTHON3 $OVS_DIR/tests/pcap/fuzzy.py], [], [stdout]) +OVS_DPDK_START() + +dnl Add userspace bridge and attach it to OVS +AT_CHECK([ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev]) +AT_CHECK([ovs-vsctl add-port br0 p1 -- set Interface p1 type=dpdk options:dpdk-devargs=net_pcap1,rx_pcap=$OVS_DIR/tests/pcap/fuzzy,infinite_rx=1], [], [stdout], [stderr]) +AT_CHECK([ovs-vsctl show], [], [stdout]) + + +AT_CHECK([ovs-appctl dpif-netdev/miniflow-parser-set autovalidator], [0], [dnl +Miniflow implementation set to autovalidator. +]) +sleep 20 + +dnl Clean up +AT_CHECK([ovs-vsctl del-port br0 p1], [], [stdout], [stderr]) +AT_CLEANUP +dnl -------------------------------------------------------------------------- From patchwork Thu Jun 17 16:27:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493746 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SWJ2SH3z9sRf for ; Fri, 18 Jun 2021 02:41:48 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 82DDA83FEE; Thu, 17 Jun 2021 16:41:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zWjTUdjIVJdv; Thu, 17 Jun 2021 16:41:45 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 69E0983F80; Thu, 17 Jun 2021 16:41:44 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 17DB8C0028; Thu, 17 Jun 2021 16:41:44 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0D957C000D for ; Thu, 17 Jun 2021 16:41:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CD6EB83EE1 for ; Thu, 17 Jun 2021 16:41:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0qbH6_u7W7uR for ; Thu, 17 Jun 2021 16:41:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id CCFDC8404C for ; Thu, 17 Jun 2021 16:41:21 +0000 (UTC) IronPort-SDR: uKxnFyVSRIMJhzG0qWlPRHuveat1xUifLX6+3162Ljh0Ezut5KrOMnl53aAbdiU4hCRqMUjxGz a2h842NF1xxA== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719941" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719941" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:21 -0700 IronPort-SDR: 1ca82wT8AbrM8+rjp/BQ6leVOhPSYbK13mXVshBg234O/gOhqvwXUKOf83XzonVlGczcW9ChRK HRbWtHhuS/hQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252936" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:19 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:50 +0530 Message-Id: <20210617162754.2028048-9-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [v4 08/12] dpif/stats: add miniflow extract opt hits counter X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Harry van Haaren This commit adds a new counter to be displayed to the user when requesting datapath packet statistics. It counts the number of packets that are parsed and a miniflow built up from it by the optimized miniflow extract parsers. The ovs-appctl command "dpif-netdev/pmd-perf-show" now has an extra entry indicating if the optimized MFEX was hit: - MFEX Opt hits: 6786432 (100.0 %) Signed-off-by: Harry van Haaren --- lib/dpif-netdev-avx512.c | 2 ++ lib/dpif-netdev-perf.c | 3 +++ lib/dpif-netdev-perf.h | 1 + lib/dpif-netdev.c | 14 +++++++++----- tests/pmd.at | 6 ++++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/dpif-netdev-avx512.c b/lib/dpif-netdev-avx512.c index bb99b23ff..f55786f8c 100644 --- a/lib/dpif-netdev-avx512.c +++ b/lib/dpif-netdev-avx512.c @@ -297,8 +297,10 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, } /* At this point we don't return error anymore, so commit stats here. */ + uint32_t mfex_hit = __builtin_popcountll(mf_mask); 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_MFEX_OPT_HIT, mfex_hit); 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 7103a2d4d..d7676ea2b 100644 --- a/lib/dpif-netdev-perf.c +++ b/lib/dpif-netdev-perf.c @@ -247,6 +247,7 @@ pmd_perf_format_overall_stats(struct ds *str, struct pmd_perf_stats *s, " 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" + " - MFEX Opt 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 " @@ -258,6 +259,8 @@ pmd_perf_format_overall_stats(struct ds *str, struct pmd_perf_stats *s, 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_MFEX_OPT_HIT], + 100.0 * stats[PMD_STAT_MFEX_OPT_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 8b1a52387..834c26260 100644 --- a/lib/dpif-netdev-perf.h +++ b/lib/dpif-netdev-perf.h @@ -57,6 +57,7 @@ extern "C" { enum pmd_stat_type { PMD_STAT_PHWOL_HIT, /* Packets that had a partial HWOL hit (phwol). */ + PMD_STAT_MFEX_OPT_HIT, /* Packets that had miniflow optimized match. */ 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.c b/lib/dpif-netdev.c index 35c927d55..7a8f15415 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -660,6 +660,7 @@ pmd_info_show_stats(struct ds *reply, " packet recirculations: %"PRIu64"\n" " avg. datapath passes per packet: %.02f\n" " phwol hits: %"PRIu64"\n" + " mfex opt hits: %"PRIu64"\n" " emc hits: %"PRIu64"\n" " smc hits: %"PRIu64"\n" " megaflow hits: %"PRIu64"\n" @@ -669,10 +670,9 @@ pmd_info_show_stats(struct ds *reply, " avg. packets per output batch: %.02f\n", total_packets, stats[PMD_STAT_RECIRC], 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], + stats[PMD_STAT_MFEX_OPT_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], packets_per_batch); if (total_cycles == 0) { @@ -6863,7 +6863,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, n_phwol_hit = 0; + size_t n_missed = 0, n_emc_hit = 0, n_phwol_hit = 0, n_mfex_opt_hit = 0; struct dp_packet_batch single_packet; struct dfc_cache *cache = &pmd->flow_cache; struct dp_packet *packet; @@ -6931,6 +6931,8 @@ dfc_processing(struct dp_netdev_pmd_thread *pmd, /* Fallback to original miniflow_extract if there is a miss. */ if (!mf_ret) { miniflow_extract(packet, &key->mf); + } else { + n_mfex_opt_hit++; } } else { miniflow_extract(packet, &key->mf); @@ -6982,6 +6984,8 @@ dfc_processing(struct dp_netdev_pmd_thread *pmd, *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_MFEX_OPT_HIT, + n_mfex_opt_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 34a59d502..0947525f4 100644 --- a/tests/pmd.at +++ b/tests/pmd.at @@ -202,12 +202,13 @@ dummy@ovs-dummy: hit:0 missed:0 p0 7/1: (dummy-pmd: configured_rx_queues=4, configured_tx_queues=, requested_rx_queues=4, requested_tx_queues=) ]) -AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 10], [0], [dnl +AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 11], [0], [dnl pmd thread numa_id core_id : packets received: 0 packet recirculations: 0 avg. datapath passes per packet: 0.00 phwol hits: 0 + mfex opt hits: 0 emc hits: 0 smc hits: 0 megaflow hits: 0 @@ -234,12 +235,13 @@ 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: ]) -AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 10], [0], [dnl +AT_CHECK([ovs-appctl dpif-netdev/pmd-stats-show | sed SED_NUMA_CORE_PATTERN | sed '/cycles/d' | grep pmd -A 11], [0], [dnl pmd thread numa_id core_id : packets received: 20 packet recirculations: 0 avg. datapath passes per packet: 1.00 phwol hits: 0 + mfex opt hits: 0 emc hits: 19 smc hits: 0 megaflow hits: 0 From patchwork Thu Jun 17 16:27:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493747 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SWW4J4gz9sRf for ; Fri, 18 Jun 2021 02:41:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 09D4260B72; Thu, 17 Jun 2021 16:41:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WNU33lMIDBCi; Thu, 17 Jun 2021 16:41:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id D9DCF60ADF; Thu, 17 Jun 2021 16:41:51 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A19E9C000D; Thu, 17 Jun 2021 16:41:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 07E4BC000B for ; Thu, 17 Jun 2021 16:41:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7E13C83EAE for ; Thu, 17 Jun 2021 16:41:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L87qgnEVFtGW for ; Thu, 17 Jun 2021 16:41:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id 566B984174 for ; Thu, 17 Jun 2021 16:41:24 +0000 (UTC) IronPort-SDR: oxRHfqoDHZMD5+QKUjApz0NPi6AXZhtgNqoAnGMvAkNeoEOGw7MxE0+KMKZZeooYCFWJkEyOOG XTtMG/qSIJeg== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719945" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719945" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:23 -0700 IronPort-SDR: 0XEnselVVdolbz8rLR6R85u508tDkVnW0EWlR4baAkT8gsxURFaDjIBPxe7LruOynzmxISv+lX g2whlPFIFIfw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252950" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:21 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:51 +0530 Message-Id: <20210617162754.2028048-10-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [v4 09/12] dpdk: add additional CPU ISA detection strings X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Harry van Haaren This commit enables OVS to at runtime check for more detailed AVX512 capabilities, specifically Byte and Word (BW) extensions, and Vector Bit Manipulation Instructions (VBMI). These instructions will be used in the CPU ISA optimized implementations of traffic profile aware miniflow extract. Signed-off-by: Harry van Haaren Acked-by: Flavio Leitner Acked-by: Eelco Chaudron --- lib/dpdk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dpdk.c b/lib/dpdk.c index a9494a40f..9d13e4ab7 100644 --- a/lib/dpdk.c +++ b/lib/dpdk.c @@ -655,6 +655,8 @@ dpdk_get_cpu_has_isa(const char *arch, const char *feature) #if __x86_64__ /* CPU flags only defined for the architecture that support it. */ CHECK_CPU_FEATURE(feature, "avx512f", RTE_CPUFLAG_AVX512F); + CHECK_CPU_FEATURE(feature, "avx512bw", RTE_CPUFLAG_AVX512BW); + CHECK_CPU_FEATURE(feature, "avx512vbmi", RTE_CPUFLAG_AVX512VBMI); CHECK_CPU_FEATURE(feature, "avx512vpopcntdq", RTE_CPUFLAG_AVX512VPOPCNTDQ); CHECK_CPU_FEATURE(feature, "bmi2", RTE_CPUFLAG_BMI2); #endif From patchwork Thu Jun 17 16:27:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SWq15q2z9sRf for ; Fri, 18 Jun 2021 02:42:15 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id ACE9060BC2; Thu, 17 Jun 2021 16:42:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wUsd3ZfDw9vU; Thu, 17 Jun 2021 16:42:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id E0B1460B05; Thu, 17 Jun 2021 16:42:06 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9D902C000F; Thu, 17 Jun 2021 16:42:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 20DC4C0027 for ; Thu, 17 Jun 2021 16:42:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 881B083FE5 for ; Thu, 17 Jun 2021 16:41:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5PrxnMeQbK_o for ; Thu, 17 Jun 2021 16:41:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id 45DC183F9A for ; Thu, 17 Jun 2021 16:41:27 +0000 (UTC) IronPort-SDR: pNt+39hPQYbsYnArCt4s/DC2U0koADAGX6BZprWfcc6QFFsG1PwztG1rHuK2CazUphjZR+AJZM vfabIm5SUhjg== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719966" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719966" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:25 -0700 IronPort-SDR: 7lTHMrAxr0BJ15s5hepgUMWqAJ2ofUeq8BVzH080gK8xv//a4GDNU/5gAbvMxcshDAXORk2vjq dJybqqnjQIuQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252971" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:23 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:52 +0530 Message-Id: <20210617162754.2028048-11-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [v4 10/12] dpif-netdev/mfex: Add AVX512 based optimized miniflow extract X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Harry van Haaren This commit adds AVX512 implementations of miniflow extract. By using the 64 bytes available in an AVX512 register, it is possible to convert a packet to a miniflow data-structure in a small quantity instructions. The implementation here probes for Ether()/IP()/UDP() traffic, and builds the appropriate miniflow data-structure for packets that match the probe. The implementation here is auto-validated by the miniflow extract autovalidator, hence its correctness can be easily tested and verified. Note that this commit is designed to easily allow addition of new traffic profiles in a scalable way, without code duplication for each traffic profile. Signed-off-by: Harry van Haaren --- lib/automake.mk | 1 + lib/dpif-netdev-extract-avx512.c | 416 ++++++++++++++++++++++++++++++ lib/dpif-netdev-private-extract.c | 15 ++ lib/dpif-netdev-private-extract.h | 19 ++ 4 files changed, 451 insertions(+) create mode 100644 lib/dpif-netdev-extract-avx512.c diff --git a/lib/automake.mk b/lib/automake.mk index 3080bb04a..2b95d6f92 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -39,6 +39,7 @@ lib_libopenvswitchavx512_la_CFLAGS = \ $(AM_CFLAGS) lib_libopenvswitchavx512_la_SOURCES = \ lib/dpif-netdev-lookup-avx512-gather.c \ + lib/dpif-netdev-extract-avx512.c \ lib/dpif-netdev-avx512.c lib_libopenvswitchavx512_la_LDFLAGS = \ -static diff --git a/lib/dpif-netdev-extract-avx512.c b/lib/dpif-netdev-extract-avx512.c new file mode 100644 index 000000000..1145ac8a9 --- /dev/null +++ b/lib/dpif-netdev-extract-avx512.c @@ -0,0 +1,416 @@ +/* + * Copyright (c) 2021 Intel. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef __x86_64__ +/* Sparse cannot handle the AVX512 instructions. */ +#if !defined(__CHECKER__) + +#include +#include +#include +#include +#include + +#include "flow.h" +#include "dpdk.h" + +#include "dpif-netdev-private-dpcls.h" +#include "dpif-netdev-private-extract.h" +#include "dpif-netdev-private-flow.h" + +/* AVX512-BW level permutex2var_epi8 emulation. */ +static inline __m512i +__attribute__((target("avx512bw"))) +_mm512_maskz_permutex2var_epi8_skx(__mmask64 k_mask, + __m512i v_data_0, + __m512i v_shuf_idxs, + __m512i v_data_1) +{ + /* Manipulate shuffle indexes for u16 size. */ + __mmask64 k_mask_odd_lanes = 0xAAAAAAAAAAAAAAAA; + /* clear away ODD lane bytes. Cannot be done above due to no u8 shift */ + __m512i v_shuf_idx_evn = _mm512_mask_blend_epi8(k_mask_odd_lanes, + v_shuf_idxs, _mm512_setzero_si512()); + v_shuf_idx_evn = _mm512_srli_epi16(v_shuf_idx_evn, 1); + + __m512i v_shuf_idx_odd = _mm512_srli_epi16(v_shuf_idxs, 9); + + /* Shuffle each half at 16-bit width */ + __m512i v_shuf1 = _mm512_permutex2var_epi16(v_data_0, v_shuf_idx_evn, + v_data_1); + __m512i v_shuf2 = _mm512_permutex2var_epi16(v_data_0, v_shuf_idx_odd, + v_data_1); + + /* Find if the shuffle index was odd, via mask and compare */ + uint16_t index_odd_mask = 0x1; + const __m512i v_index_mask_u16 = _mm512_set1_epi16(index_odd_mask); + + /* EVEN lanes, find if u8 index was odd, result as u16 bitmask */ + __m512i v_idx_even_masked = _mm512_and_si512(v_shuf_idxs, + v_index_mask_u16); + __mmask32 evn_rotate_mask = _mm512_cmpeq_epi16_mask(v_idx_even_masked, + v_index_mask_u16); + + /* ODD lanes, find if u8 index was odd, result as u16 bitmask */ + __m512i v_shuf_idx_srli8 = _mm512_srli_epi16(v_shuf_idxs, 8); + __m512i v_idx_odd_masked = _mm512_and_si512(v_shuf_idx_srli8, + v_index_mask_u16); + __mmask32 odd_rotate_mask = _mm512_cmpeq_epi16_mask(v_idx_odd_masked, + v_index_mask_u16); + odd_rotate_mask = ~odd_rotate_mask; + + /* Rotate and blend results from each index */ + __m512i v_shuf_res_evn = _mm512_mask_srli_epi16(v_shuf1, evn_rotate_mask, + v_shuf1, 8); + __m512i v_shuf_res_odd = _mm512_mask_slli_epi16(v_shuf2, odd_rotate_mask, + v_shuf2, 8); + + /* If shuffle index was odd, blend shifted version */ + __m512i v_shuf_result = _mm512_mask_blend_epi8(k_mask_odd_lanes, + v_shuf_res_evn, v_shuf_res_odd); + + __m512i v_zeros = _mm512_setzero_si512(); + __m512i v_result_kmskd = _mm512_mask_blend_epi8(k_mask, v_zeros, + v_shuf_result); + + return v_result_kmskd; +} + +/* Wrapper function required to enable ISA. */ +static inline __m512i +__attribute__((__target__("avx512vbmi"))) +_mm512_maskz_permutexvar_epi8_wrap(__mmask64 kmask, __m512i idx, __m512i a) +{ + return _mm512_maskz_permutexvar_epi8(kmask, idx, a); +} + + +/* This file contains optimized implementations of miniflow_extract() + * for specific common traffic patterns. The optimizations allow for + * quick probing of a specific packet type, and if a match with a specific + * type is found, a shuffle like proceedure builds up the required miniflow. + * + * The functionality here can be easily auto-validated and tested against the + * scalar miniflow_extract() function. As such, manual review of the code by + * the community (although welcome) is not required. Confidence in the + * correctness of the code can be had from the autovalidation. + */ + +/* Generator for EtherType masks and values. */ +#define PATTERN_ETHERTYPE_GEN(type_b0, type_b1) \ + 0, 0, 0, 0, 0, 0, /* Ether MAC DST */ \ + 0, 0, 0, 0, 0, 0, /* Ether MAC SRC */ \ + type_b0, type_b1, /* EtherType */ + +#define PATTERN_ETHERTYPE_MASK PATTERN_ETHERTYPE_GEN(0xFF, 0xFF) +#define PATTERN_ETHERTYPE_IPV4 PATTERN_ETHERTYPE_GEN(0x08, 0x00) + +/* Generator for checking IPv4 ver, ihl, and proto */ +#define PATTERN_IPV4_GEN(VER_IHL, FLAG_OFF_B0, FLAG_OFF_B1, PROTO) \ + VER_IHL, /* Version and IHL */ \ + 0, 0, 0, /* DSCP, ECN, Total Lenght */ \ + 0, 0, /* Identification */ \ + /* Flags/Fragment offset: don't match MoreFrag (MF) or FragOffset */ \ + FLAG_OFF_B0, FLAG_OFF_B1, \ + 0, /* TTL */ \ + PROTO, /* Protocol */ \ + 0, 0, /* Header checksum */ \ + 0, 0, 0, 0, /* Src IP */ \ + 0, 0, 0, 0, /* Dst IP */ + +#define PATTERN_IPV4_MASK PATTERN_IPV4_GEN(0xFF, 0xFE, 0xFF, 0xFF) +#define PATTERN_IPV4_UDP PATTERN_IPV4_GEN(0x45, 0, 0, 0x11) +#define PATTERN_IPV4_TCP PATTERN_IPV4_GEN(0x45, 0, 0, 0x06) + +#define NU 0 +#define PATTERN_IPV4_UDP_SHUFFLE \ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, NU, NU, /* Ether */ \ + 26, 27, 28, 29, 30, 31, 32, 33, NU, NU, NU, NU, 20, 15, 22, 23, /* IPv4 */ \ + 34, 35, 36, 37, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, /* UDP */ \ + NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, /* Unused. */ + + +/* Generation of K-mask bitmask values, to zero out data in result. Note that + * these correspond 1:1 to the above "*_SHUFFLE" values, and bit used must be + * set in this K-mask, and "NU" values must be zero in the k-mask. Each mask + * defined here represents 2 blocks, so 16 bytes, so 4 characters (eg. 0xFFFF). + * + * Note the ULL suffix allows shifting by 32 or more without integer overflow. + */ +#define KMASK_ETHER 0x1FFFULL +#define KMASK_IPV4 0xF0FFULL +#define KMASK_UDP 0x000FULL + +#define PATTERN_IPV4_UDP_KMASK \ + (KMASK_ETHER | (KMASK_IPV4 << 16) | (KMASK_UDP << 32)) + + +/* This union allows initializing static data as u8, but easily loading it + * into AVX512 registers too. The union ensures proper alignment for the zmm. + */ +union mfex_data { + uint8_t u8_data[64]; + __m512i zmm; +}; + +/* This structure represents a single traffic pattern. The AVX512 code to + * enable the specifics for each pattern is largely the same, so it is + * specialized to use the common profile data from here. + * + * Due to the nature of e.g. TCP flag handling, or VLAN CFI bit setting, + * some profiles require additional processing. This is handled by having + * all implementations call a post-process function, and specializing away + * the big switch() that handles all traffic types. + * + * This approach reduces AVX512 code-duplication for each traffic type. + */ +struct mfex_profile { + /* Required for probing a packet with the mfex pattern. */ + union mfex_data probe_mask; + union mfex_data probe_data; + + /* Required for reshaping packet into miniflow. */ + union mfex_data store_shuf; + __mmask64 store_kmsk; + + /* Constant data to set in mf.bits and dp_packet data on hit. */ + uint64_t mf_bits[2]; + uint16_t dp_pkt_offs[4]; + uint16_t dp_pkt_min_size; +}; + +enum MFEX_PROFILES { + PROFILE_ETH_IPV4_UDP, + PROFILE_COUNT, +}; + +/* Static const instances of profiles. These are compile-time constants, + * and are specialized into individual miniflow-extract functions. + */ +static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = +{ + [PROFILE_ETH_IPV4_UDP] = { + .probe_mask.u8_data = { PATTERN_ETHERTYPE_MASK PATTERN_IPV4_MASK }, + .probe_data.u8_data = { PATTERN_ETHERTYPE_IPV4 PATTERN_IPV4_UDP}, + + .store_shuf.u8_data = { PATTERN_IPV4_UDP_SHUFFLE }, + .store_kmsk = PATTERN_IPV4_UDP_KMASK, + + .mf_bits = { 0x18a0000000000000, 0x0000000000040401}, + .dp_pkt_offs = { + 0, UINT16_MAX, 14, 34, + }, + .dp_pkt_min_size = 42, + }, +}; + + +/* Protocol specific helper functions, for calculating offsets/lenghts. */ +static int32_t +mfex_ipv4_set_l2_pad_size(struct dp_packet *pkt, struct ip_header *nh, + uint32_t len_from_ipv4) +{ + /* Handle dynamic l2_pad_size. */ + uint16_t tot_len = ntohs(nh->ip_tot_len); + if (OVS_UNLIKELY(tot_len > len_from_ipv4 || + (len_from_ipv4 - tot_len) > UINT16_MAX)) { + return -1; + } + dp_packet_set_l2_pad_size(pkt, len_from_ipv4 - tot_len); + return 0; +} + +/* Generic loop to process any mfex profile. This code is specialized into + * multiple actual MFEX implementation functions. Its marked ALWAYS_INLINE + * to ensure the compiler specializes each instance. The code is marked "hot" + * to inform the compiler this is a hotspot in the program, encouraging + * inlining of callee functions such as the permute calls. + */ +static inline uint32_t ALWAYS_INLINE +__attribute__ ((hot)) +mfex_avx512_process(struct dp_packet_batch *packets, + struct netdev_flow_key *keys, + uint32_t keys_size OVS_UNUSED, + odp_port_t in_port, + void *pmd_handle OVS_UNUSED, + const enum MFEX_PROFILES profile_id, + const uint32_t use_vbmi) +{ + uint32_t hitmask = 0; + struct dp_packet *packet; + + /* Here the profile to use is chosen by the variable used to specialize + * the function. This causes different MFEX traffic to be handled. + */ + const struct mfex_profile *profile = &mfex_profiles[profile_id]; + + /* Load profile constant data. */ + __m512i v_vals = _mm512_loadu_si512(&profile->probe_data); + __m512i v_mask = _mm512_loadu_si512(&profile->probe_mask); + __m512i v_shuf = _mm512_loadu_si512(&profile->store_shuf); + + __mmask64 k_shuf = profile->store_kmsk; + __m128i v_bits = _mm_loadu_si128((void *) &profile->mf_bits); + uint16_t dp_pkt_min_size = profile->dp_pkt_min_size; + + __m128i v_zeros = _mm_setzero_si128(); + __m128i v_blocks01 = _mm_insert_epi32(v_zeros, odp_to_u32(in_port), 1); + + DP_PACKET_BATCH_FOR_EACH (i, packet, packets) { + /* If the packet is smaller than the probe size, skip it. */ + const uint32_t size = dp_packet_size(packet); + if (size < dp_pkt_min_size) { + continue; + } + + /* Load packet data and probe with AVX512 mask & compare. */ + const uint8_t *pkt = dp_packet_data(packet); + __m512i v_pkt0 = _mm512_loadu_si512(pkt); + __m512i v_pkt0_masked = _mm512_and_si512(v_pkt0, v_mask); + __mmask64 k_cmp = _mm512_cmpeq_epi8_mask(v_pkt0_masked, v_vals); + if (k_cmp != UINT64_MAX) { + continue; + } + + /* Copy known dp packet offsets to the dp_packet instance. */ + memcpy(&packet->l2_pad_size, &profile->dp_pkt_offs, + sizeof(uint16_t) * 4); + + /* Store known miniflow bits and first two blocks. */ + struct miniflow *mf = &keys[i].mf; + uint64_t *bits = (void *) &mf->map.bits[0]; + uint64_t *blocks = miniflow_values(mf); + _mm_storeu_si128((void *) bits, v_bits); + _mm_storeu_si128((void *) blocks, v_blocks01); + + /* Permute the packet layout into miniflow blocks shape. + * As different avx512 ISA levels have different implementations, + * this specializes on the "use_vbmi" attribute passed in. + */ + __m512i v512_zeros = _mm512_setzero_si512(); + __m512i v_blk0 = v512_zeros; + if (__builtin_constant_p(use_vbmi) && use_vbmi) { + v_blk0 = _mm512_maskz_permutexvar_epi8_wrap(k_shuf, v_shuf, + v_pkt0); + } else { + v_blk0 = _mm512_maskz_permutex2var_epi8_skx(k_shuf, v_pkt0, + v_shuf, v512_zeros); + } + _mm512_storeu_si512(&blocks[2], v_blk0); + + + /* Perform "post-processing" per profile, handling details not easily + * handled in the above generic AVX512 code. Examples include TCP flag + * parsing, adding the VLAN CFI bit, and handling IPv4 fragments. + */ + switch (profile_id) { + case PROFILE_COUNT: + ovs_assert(0); /* avoid compiler warning on missing ENUM */ + break; + + case PROFILE_ETH_IPV4_UDP: { + /* Handle dynamic l2_pad_size. */ + uint32_t size_from_ipv4 = size - sizeof(struct eth_header); + struct ip_header *nh = (void *)&pkt[sizeof(struct eth_header)]; + if (mfex_ipv4_set_l2_pad_size(packet, nh, size_from_ipv4)) { + continue; + } + + } break; + default: + break; + }; + + /* This packet has its miniflow created, add to hitmask. */ + hitmask |= 1 << i; + } + + return hitmask; +} + + +#define DECLARE_MFEX_FUNC(name, profile) \ +uint32_t \ +__attribute__((__target__("avx512f"))) \ +__attribute__((__target__("avx512vl"))) \ +__attribute__((__target__("avx512vbmi"))) \ +mfex_avx512_vbmi_##name(struct dp_packet_batch *packets, \ + struct netdev_flow_key *keys, uint32_t keys_size, \ + odp_port_t in_port, void *pmd_handle) \ +{ \ + return mfex_avx512_process(packets, keys, keys_size, in_port, \ + pmd_handle, profile, 1); \ +} \ + \ +uint32_t \ +__attribute__((__target__("avx512f"))) \ +__attribute__((__target__("avx512vl"))) \ +mfex_avx512_##name(struct dp_packet_batch *packets, \ + struct netdev_flow_key *keys, uint32_t keys_size, \ + odp_port_t in_port, void *pmd_handle) \ +{ \ + return mfex_avx512_process(packets, keys, keys_size, in_port, \ + pmd_handle, profile, 0); \ +} + +/* Each profile gets a single declare here, which specializes the function + * as required. + */ +DECLARE_MFEX_FUNC(ip_udp,PROFILE_ETH_IPV4_UDP) + + +static int32_t +avx512_isa_probe(uint32_t needs_vbmi) +{ + static const char *isa_required[] = { + "avx512f", + "avx512bw", + "bmi2", + }; + + int32_t ret = 0; + for (uint32_t i = 0; i < ARRAY_SIZE(isa_required); i++) { + if (!dpdk_get_cpu_has_isa("x86_64", isa_required[i])) { + ret = -ENOTSUP; + } + } + + if (needs_vbmi) { + if (!dpdk_get_cpu_has_isa("x86_64", "avx512vbmi")) { + ret = -ENOTSUP; + } + } + + return ret; +} + +/* Probe functions to check ISA requirements. */ +int32_t +mfex_avx512_probe(void) +{ + const uint32_t needs_vbmi = 0; + return avx512_isa_probe(needs_vbmi); +} + +int32_t +mfex_avx512_vbmi_probe(void) +{ + const uint32_t needs_vbmi = 1; + return avx512_isa_probe(needs_vbmi); +} + +#endif /* __CHECKER__ */ +#endif /* __x86_64__ */ diff --git a/lib/dpif-netdev-private-extract.c b/lib/dpif-netdev-private-extract.c index 2008e5ee5..106a83867 100644 --- a/lib/dpif-netdev-private-extract.c +++ b/lib/dpif-netdev-private-extract.c @@ -47,8 +47,23 @@ static struct dpif_miniflow_extract_impl mfex_impls[] = { .extract_func = mfex_study_traffic, .name = "study", }, + +/* Compile in implementations only if the compiler ISA checks pass. */ +#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__) + { + .probe = mfex_avx512_vbmi_probe, + .extract_func = mfex_avx512_vbmi_ip_udp, + .name = "avx512_vbmi_ipv4_udp", + }, + { + .probe = mfex_avx512_probe, + .extract_func = mfex_avx512_ip_udp, + .name = "avx512_ipv4_udp", + }, +#endif }; + BUILD_ASSERT_DECL(MFEX_IMPLS_MAX_SIZE > ARRAY_SIZE(mfex_impls)); int32_t diff --git a/lib/dpif-netdev-private-extract.h b/lib/dpif-netdev-private-extract.h index 0ec74bef9..f32be202a 100644 --- a/lib/dpif-netdev-private-extract.h +++ b/lib/dpif-netdev-private-extract.h @@ -136,4 +136,23 @@ dpif_miniflow_extract_set_default(miniflow_extract_func func); uint32_t mfex_set_study_pkt_cnt(uint32_t pkt_cmp_count, struct dpif_miniflow_extract_impl *opt); +/* AVX512 MFEX Probe and Implementations functions. */ +#ifdef __x86_64__ +int32_t mfex_avx512_probe(void); +int32_t mfex_avx512_vbmi_probe(void); + +#define DECLARE_AVX512_MFEX_PROTOTYPE(name) \ + uint32_t \ + mfex_avx512_vbmi_##name(struct dp_packet_batch *packets, \ + struct netdev_flow_key *keys, uint32_t keys_size, \ + odp_port_t in_port, void *pmd_handle); \ + uint32_t \ + mfex_avx512_##name(struct dp_packet_batch *packets, \ + struct netdev_flow_key *keys, uint32_t keys_size, \ + odp_port_t in_port, void *pmd_handle); + +DECLARE_AVX512_MFEX_PROTOTYPE(ip_udp); +#endif /* __x86_64__ */ + + #endif /* DPIF_NETDEV_AVX512_EXTRACT */ From patchwork Thu Jun 17 16:27:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493748 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SWg5YH0z9sRf for ; Fri, 18 Jun 2021 02:42:07 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id EC11E84328; Thu, 17 Jun 2021 16:42:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id erBIJrDrR2PA; Thu, 17 Jun 2021 16:42:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id C12B084165; Thu, 17 Jun 2021 16:42:03 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A176DC000D; Thu, 17 Jun 2021 16:42:03 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 34354C000F for ; Thu, 17 Jun 2021 16:42:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0CBA68428E for ; Thu, 17 Jun 2021 16:41:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CjDMXJWUD_dC for ; Thu, 17 Jun 2021 16:41:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id 54CAB83F15 for ; Thu, 17 Jun 2021 16:41:28 +0000 (UTC) IronPort-SDR: F41vcZsvUsnqVjJW9eFhJisq0pvidHwFJbpBhB0CQY61c9eY64TZquCTFoy5sR8SCYV1zb6xST ZKIUBrhk8KLg== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719967" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719967" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:27 -0700 IronPort-SDR: qah+l9u6Pu+POQ9dsPqu/T7VWuwxEd0XYzQO69y4Carav9t7e1SStMzSKautdi3/zTP8vwO3rh wbrvC1Z8H6mA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555252995" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:25 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:53 +0530 Message-Id: <20210617162754.2028048-12-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [v4 11/12] dpif-netdev/mfex: add more AVX512 traffic profiles X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Harry van Haaren This commit adds 3 new traffic profile implementations to the existing avx512 miniflow extract infrastructure. The profiles added are: - Ether()/IP()/TCP() - Ether()/Dot1Q()/IP()/UDP() - Ether()/Dot1Q()/IP()/TCP() The design of the avx512 code here is for scalability to add more traffic profiles, as well as enabling CPU ISA. Note that an implementation is primarily adding static const data, which the compiler then specializes away when the profile specific function is declared below. As a result, the code is relatively maintainable, and scalable for new traffic profiles as well as new ISA, and does not lower performance compared with manually written code for each profile/ISA. Note that confidence in the correctness of each implementation is achieved through autovalidation, unit tests with known packets, and fuzz tested packets. Signed-off-by: Harry van Haaren --- Hi Readers, If you have a traffic profile you'd like to see accelerated using avx512 code, please send me an email and we can collaborate on adding support for it! Regards, -Harry --- lib/dpif-netdev-extract-avx512.c | 155 ++++++++++++++++++++++++++++++ lib/dpif-netdev-private-extract.c | 31 ++++++ lib/dpif-netdev-private-extract.h | 4 + 3 files changed, 190 insertions(+) diff --git a/lib/dpif-netdev-extract-avx512.c b/lib/dpif-netdev-extract-avx512.c index 1145ac8a9..0e0f6e295 100644 --- a/lib/dpif-netdev-extract-avx512.c +++ b/lib/dpif-netdev-extract-avx512.c @@ -117,6 +117,13 @@ _mm512_maskz_permutexvar_epi8_wrap(__mmask64 kmask, __m512i idx, __m512i a) #define PATTERN_ETHERTYPE_MASK PATTERN_ETHERTYPE_GEN(0xFF, 0xFF) #define PATTERN_ETHERTYPE_IPV4 PATTERN_ETHERTYPE_GEN(0x08, 0x00) +#define PATTERN_ETHERTYPE_DT1Q PATTERN_ETHERTYPE_GEN(0x81, 0x00) + +/* VLAN (Dot1Q) patterns and masks. */ +#define PATTERN_DT1Q_MASK \ + 0x00, 0x00, 0xFF, 0xFF, +#define PATTERN_DT1Q_IPV4 \ + 0x00, 0x00, 0x08, 0x00, /* Generator for checking IPv4 ver, ihl, and proto */ #define PATTERN_IPV4_GEN(VER_IHL, FLAG_OFF_B0, FLAG_OFF_B1, PROTO) \ @@ -142,6 +149,29 @@ _mm512_maskz_permutexvar_epi8_wrap(__mmask64 kmask, __m512i idx, __m512i a) 34, 35, 36, 37, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, /* UDP */ \ NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, /* Unused. */ +/* TCP shuffle: tcp_ctl bits require mask/processing, not included here. */ +#define PATTERN_IPV4_TCP_SHUFFLE \ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, NU, NU, /* Ether */ \ + 26, 27, 28, 29, 30, 31, 32, 33, NU, NU, NU, NU, 20, 15, 22, 23, /* IPv4 */ \ + NU, NU, NU, NU, NU, NU, NU, NU, 34, 35, 36, 37, NU, NU, NU, NU, /* TCP */ \ + NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, NU, /* Unused. */ + +#define PATTERN_DT1Q_IPV4_UDP_SHUFFLE \ + /* Ether (2 blocks): Note that *VLAN* type is written here. */ \ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 0, 0, \ + /* VLAN (1 block): Note that the *EtherHdr->Type* is written here. */ \ + 12, 13, 14, 15, 0, 0, 0, 0, \ + 30, 31, 32, 33, 34, 35, 36, 37, 0, 0, 0, 0, 24, 19, 26, 27, /* IPv4 */ \ + 38, 39, 40, 41, NU, NU, NU, NU, /* UDP */ + +#define PATTERN_DT1Q_IPV4_TCP_SHUFFLE \ + /* Ether (2 blocks): Note that *VLAN* type is written here. */ \ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17, 0, 0, \ + /* VLAN (1 block): Note that the *EtherHdr->Type* is written here. */ \ + 12, 13, 14, 15, 0, 0, 0, 0, \ + 30, 31, 32, 33, 34, 35, 36, 37, 0, 0, 0, 0, 24, 19, 26, 27, /* IPv4 */ \ + NU, NU, NU, NU, NU, NU, NU, NU, 38, 39, 40, 41, NU, NU, NU, NU, /* TCP */ \ + NU, NU, NU, NU, NU, NU, NU, NU, /* Unused. */ /* Generation of K-mask bitmask values, to zero out data in result. Note that * these correspond 1:1 to the above "*_SHUFFLE" values, and bit used must be @@ -151,12 +181,22 @@ _mm512_maskz_permutexvar_epi8_wrap(__mmask64 kmask, __m512i idx, __m512i a) * Note the ULL suffix allows shifting by 32 or more without integer overflow. */ #define KMASK_ETHER 0x1FFFULL +#define KMASK_DT1Q 0x000FULL #define KMASK_IPV4 0xF0FFULL #define KMASK_UDP 0x000FULL +#define KMASK_TCP 0x0F00ULL #define PATTERN_IPV4_UDP_KMASK \ (KMASK_ETHER | (KMASK_IPV4 << 16) | (KMASK_UDP << 32)) +#define PATTERN_IPV4_TCP_KMASK \ + (KMASK_ETHER | (KMASK_IPV4 << 16) | (KMASK_TCP << 32)) + +#define PATTERN_DT1Q_IPV4_UDP_KMASK \ + (KMASK_ETHER | (KMASK_DT1Q << 16) | (KMASK_IPV4 << 24) | (KMASK_UDP << 40)) + +#define PATTERN_DT1Q_IPV4_TCP_KMASK \ + (KMASK_ETHER | (KMASK_DT1Q << 16) | (KMASK_IPV4 << 24) | (KMASK_TCP << 40)) /* This union allows initializing static data as u8, but easily loading it * into AVX512 registers too. The union ensures proper alignment for the zmm. @@ -194,6 +234,9 @@ struct mfex_profile { enum MFEX_PROFILES { PROFILE_ETH_IPV4_UDP, + PROFILE_ETH_IPV4_TCP, + PROFILE_ETH_VLAN_IPV4_UDP, + PROFILE_ETH_VLAN_IPV4_TCP, PROFILE_COUNT, }; @@ -215,6 +258,56 @@ static const struct mfex_profile mfex_profiles[PROFILE_COUNT] = }, .dp_pkt_min_size = 42, }, + + [PROFILE_ETH_IPV4_TCP] = { + .probe_mask.u8_data = { PATTERN_ETHERTYPE_MASK PATTERN_IPV4_MASK }, + .probe_data.u8_data = { PATTERN_ETHERTYPE_IPV4 PATTERN_IPV4_TCP}, + + .store_shuf.u8_data = { PATTERN_IPV4_TCP_SHUFFLE }, + .store_kmsk = PATTERN_IPV4_TCP_KMASK, + + .mf_bits = { 0x18a0000000000000, 0x0000000000044401}, + .dp_pkt_offs = { + 0, UINT16_MAX, 14, 34, + }, + .dp_pkt_min_size = 54, + }, + + [PROFILE_ETH_VLAN_IPV4_UDP] = { + .probe_mask.u8_data = { + PATTERN_ETHERTYPE_MASK PATTERN_DT1Q_MASK PATTERN_IPV4_MASK + }, + .probe_data.u8_data = { + PATTERN_ETHERTYPE_DT1Q PATTERN_DT1Q_IPV4 PATTERN_IPV4_UDP + }, + + .store_shuf.u8_data = { PATTERN_DT1Q_IPV4_UDP_SHUFFLE }, + .store_kmsk = PATTERN_DT1Q_IPV4_UDP_KMASK, + + .mf_bits = { 0x38a0000000000000, 0x0000000000040401}, + .dp_pkt_offs = { + 14, UINT16_MAX, 18, 38, + }, + .dp_pkt_min_size = 46, + }, + + [PROFILE_ETH_VLAN_IPV4_TCP] = { + .probe_mask.u8_data = { + PATTERN_ETHERTYPE_MASK PATTERN_DT1Q_MASK PATTERN_IPV4_MASK + }, + .probe_data.u8_data = { + PATTERN_ETHERTYPE_DT1Q PATTERN_DT1Q_IPV4 PATTERN_IPV4_TCP + }, + + .store_shuf.u8_data = { PATTERN_DT1Q_IPV4_TCP_SHUFFLE }, + .store_kmsk = PATTERN_DT1Q_IPV4_TCP_KMASK, + + .mf_bits = { 0x38a0000000000000, 0x0000000000044401}, + .dp_pkt_offs = { + 14, UINT16_MAX, 18, 38, + }, + .dp_pkt_min_size = 46, + }, }; @@ -233,6 +326,28 @@ mfex_ipv4_set_l2_pad_size(struct dp_packet *pkt, struct ip_header *nh, return 0; } +/* Fixup the VLAN CFI and PCP, reading the PCP from the input to this function, + * and storing the output CFI bit bitwise-OR-ed with the PCP to miniflow. + */ +static void +mfex_vlan_pcp(const uint8_t vlan_pcp, uint64_t *block) +{ + /* Bitwise-OR in the CFI flag, keeping other data the same. */ + uint8_t *cfi_byte = (uint8_t *) block; + cfi_byte[2] = 0x10 | vlan_pcp; +} + +/* Process TCP flags using known LE endian-ness as this is AVX512 code. */ +#define TCP_FLAGS_BE32(tcp_ctl) ((OVS_FORCE ovs_be32) TCP_FLAGS_BE16(tcp_ctl)) + +static void +mfex_handle_tcp_flags(const struct tcp_header *tcp, uint64_t *block) +{ + uint16_t ctl = (OVS_FORCE uint16_t) TCP_FLAGS_BE16(tcp->tcp_ctl); + uint64_t ctl_u64 = ctl; + *block = ctl_u64 << 32; +} + /* Generic loop to process any mfex profile. This code is specialized into * multiple actual MFEX implementation functions. Its marked ALWAYS_INLINE * to ensure the compiler specializes each instance. The code is marked "hot" @@ -321,6 +436,43 @@ mfex_avx512_process(struct dp_packet_batch *packets, ovs_assert(0); /* avoid compiler warning on missing ENUM */ break; + case PROFILE_ETH_VLAN_IPV4_TCP: { + mfex_vlan_pcp(pkt[14], &keys[i].buf[4]); + + uint32_t size_from_ipv4 = size - VLAN_ETH_HEADER_LEN; + struct ip_header *nh = (void *)&pkt[VLAN_ETH_HEADER_LEN]; + if (mfex_ipv4_set_l2_pad_size(packet, nh, size_from_ipv4)) { + continue; + } + + /* Process TCP flags, and store to blocks. */ + const struct tcp_header *tcp = (void *)&pkt[38]; + mfex_handle_tcp_flags(tcp, &blocks[7]); + } break; + + case PROFILE_ETH_VLAN_IPV4_UDP: { + mfex_vlan_pcp(pkt[14], &keys[i].buf[4]); + + uint32_t size_from_ipv4 = size - VLAN_ETH_HEADER_LEN; + struct ip_header *nh = (void *)&pkt[VLAN_ETH_HEADER_LEN]; + if (mfex_ipv4_set_l2_pad_size(packet, nh, size_from_ipv4)) { + continue; + } + } break; + + case PROFILE_ETH_IPV4_TCP: { + /* Process TCP flags, and store to blocks. */ + const struct tcp_header *tcp = (void *)&pkt[34]; + mfex_handle_tcp_flags(tcp, &blocks[6]); + + /* Handle dynamic l2_pad_size. */ + uint32_t size_from_ipv4 = size - sizeof(struct eth_header); + struct ip_header *nh = (void *)&pkt[sizeof(struct eth_header)]; + if (mfex_ipv4_set_l2_pad_size(packet, nh, size_from_ipv4)) { + continue; + } + } break; + case PROFILE_ETH_IPV4_UDP: { /* Handle dynamic l2_pad_size. */ uint32_t size_from_ipv4 = size - sizeof(struct eth_header); @@ -370,6 +522,9 @@ mfex_avx512_##name(struct dp_packet_batch *packets, \ * as required. */ DECLARE_MFEX_FUNC(ip_udp,PROFILE_ETH_IPV4_UDP) +DECLARE_MFEX_FUNC(ip_tcp,PROFILE_ETH_IPV4_TCP) +DECLARE_MFEX_FUNC(dot1q_ip_udp,PROFILE_ETH_VLAN_IPV4_UDP) +DECLARE_MFEX_FUNC(dot1q_ip_tcp,PROFILE_ETH_VLAN_IPV4_TCP) static int32_t diff --git a/lib/dpif-netdev-private-extract.c b/lib/dpif-netdev-private-extract.c index 106a83867..65072eb38 100644 --- a/lib/dpif-netdev-private-extract.c +++ b/lib/dpif-netdev-private-extract.c @@ -60,6 +60,37 @@ static struct dpif_miniflow_extract_impl mfex_impls[] = { .extract_func = mfex_avx512_ip_udp, .name = "avx512_ipv4_udp", }, + { + .probe = mfex_avx512_vbmi_probe, + .extract_func = mfex_avx512_vbmi_ip_tcp, + .name = "avx512_vbmi_ipv4_tcp", + }, + { + .probe = mfex_avx512_probe, + .extract_func = mfex_avx512_ip_tcp, + .name = "avx512_ipv4_tcp", + }, + + { + .probe = mfex_avx512_vbmi_probe, + .extract_func = mfex_avx512_vbmi_dot1q_ip_udp, + .name = "avx512_vbmi_dot1q_ipv4_udp", + }, + { + .probe = mfex_avx512_probe, + .extract_func = mfex_avx512_dot1q_ip_udp, + .name = "avx512_dot1q_ipv4_udp", + }, + { + .probe = mfex_avx512_vbmi_probe, + .extract_func = mfex_avx512_vbmi_dot1q_ip_tcp, + .name = "avx512_vbmi_dot1q_ipv4_tcp", + }, + { + .probe = mfex_avx512_probe, + .extract_func = mfex_avx512_dot1q_ip_tcp, + .name = "avx512_dot1q_ipv4_tcp", + }, #endif }; diff --git a/lib/dpif-netdev-private-extract.h b/lib/dpif-netdev-private-extract.h index f32be202a..b9a59c5a0 100644 --- a/lib/dpif-netdev-private-extract.h +++ b/lib/dpif-netdev-private-extract.h @@ -152,6 +152,10 @@ int32_t mfex_avx512_vbmi_probe(void); odp_port_t in_port, void *pmd_handle); DECLARE_AVX512_MFEX_PROTOTYPE(ip_udp); +DECLARE_AVX512_MFEX_PROTOTYPE(ip_tcp); +DECLARE_AVX512_MFEX_PROTOTYPE(dot1q_ip_udp); +DECLARE_AVX512_MFEX_PROTOTYPE(dot1q_ip_tcp); + #endif /* __x86_64__ */ From patchwork Thu Jun 17 16:27:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Amber X-Patchwork-Id: 1493750 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5SWr4PsLz9sRf for ; Fri, 18 Jun 2021 02:42:16 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id EF26884344; Thu, 17 Jun 2021 16:42:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8sL2J7vxNgpQ; Thu, 17 Jun 2021 16:42:14 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1F1988433E; Thu, 17 Jun 2021 16:42:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DF4B9C000D; Thu, 17 Jun 2021 16:42:12 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 104D9C000D for ; Thu, 17 Jun 2021 16:42:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C50BD83F15 for ; Thu, 17 Jun 2021 16:41:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8WvsMmIlAUaP for ; Thu, 17 Jun 2021 16:41:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by smtp1.osuosl.org (Postfix) with ESMTPS id C6AF784284 for ; Thu, 17 Jun 2021 16:41:29 +0000 (UTC) IronPort-SDR: Rwkhb/kcHO4Uj78K7bVcGnorV49RFNM6ba6wnxxDxHD4bdMWoLQ3s9TOj8bn7fouJXirP6Wk6s wOG2+C0ZR5wQ== X-IronPort-AV: E=McAfee;i="6200,9189,10018"; a="193719983" X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="193719983" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2021 09:41:29 -0700 IronPort-SDR: 6SW3xOevthqvYFSua0R2nbVwvQVqqU9tjoHeSCmE2ICb2jSPJyJDs5IHlr/spOVD+lKykGRMo1 rAAWIs3xaQIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,281,1616482800"; d="scan'208";a="555253009" Received: from bmca4bf01706bbf.iind.intel.com (HELO localhost.localdomain) ([10.190.213.111]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2021 09:41:27 -0700 From: Kumar Amber To: dev@openvswitch.org Date: Thu, 17 Jun 2021 21:57:54 +0530 Message-Id: <20210617162754.2028048-13-kumar.amber@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210617162754.2028048-1-kumar.amber@intel.com> References: <20210517135708.685517-1-kumar.amber@intel.com> <20210617162754.2028048-1-kumar.amber@intel.com> MIME-Version: 1.0 Cc: i.maximets@ovn.org Subject: [ovs-dev] [v4 12/12] dpif/dpcls: limit count subtable search info logs X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Harry van Haaren This commit avoids many instances of "using subtable X for miniflow (x,y)" in the ovs-vswitchd log when using the DPCLS Autovalidator. This occurs when no specialized subtable is found, and the generic "_any" version of the avx512 subtable search implementation was used. This change logs the subtable usage once, avoiding duplicates. Signed-off-by: Harry van Haaren --- lib/dpif-netdev-lookup-avx512-gather.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dpif-netdev-lookup-avx512-gather.c b/lib/dpif-netdev-lookup-avx512-gather.c index 2e754c89f..deed527b0 100644 --- a/lib/dpif-netdev-lookup-avx512-gather.c +++ b/lib/dpif-netdev-lookup-avx512-gather.c @@ -411,7 +411,7 @@ dpcls_subtable_avx512_gather_probe(uint32_t u0_bits, uint32_t u1_bits) */ if (!f && (u0_bits + u1_bits) < (NUM_U64_IN_ZMM_REG * 2)) { f = dpcls_avx512_gather_mf_any; - VLOG_INFO("Using avx512_gather_mf_any for subtable (%d,%d)\n", + VLOG_INFO_ONCE("Using avx512_gather_mf_any for subtable (%d,%d)\n", u0_bits, u1_bits); }