From patchwork Tue Mar 2 11:25:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1445979 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 4DqZZR4C4cz9sWf for ; Tue, 2 Mar 2021 22:26:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 59DC86F666; Tue, 2 Mar 2021 11:26:03 +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 tRICbPUAPvRM; Tue, 2 Mar 2021 11:26:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTP id 6DCAF6F652; Tue, 2 Mar 2021 11:26:01 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A0725C0013; Tue, 2 Mar 2021 11:25:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id A9417C000B for ; Tue, 2 Mar 2021 11:25:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 92E4F43102 for ; Tue, 2 Mar 2021 11:25:57 +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 fLPPGz6Ufo4w for ; Tue, 2 Mar 2021 11:25:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp2.osuosl.org (Postfix) with ESMTP id 48B8F430C8 for ; Tue, 2 Mar 2021 11:25:56 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@nvidia.com) with SMTP; 2 Mar 2021 13:25:50 +0200 Received: from nvidia.com (dev-r-vrt-214.mtr.labs.mlnx [10.212.214.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 122BPobM018920; Tue, 2 Mar 2021 13:25:50 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets Date: Tue, 2 Mar 2021 11:25:28 +0000 Message-Id: <20210302112536.32680-7-elibr@nvidia.com> X-Mailer: git-send-email 2.28.0.2311.g225365fb51 In-Reply-To: <20210302112536.32680-1-elibr@nvidia.com> References: <20210302112536.32680-1-elibr@nvidia.com> MIME-Version: 1.0 Cc: Eli Britstein , Ivan.Malov@oktetlabs.ru, Ameer Mahagneh , Majd Dibbiny , Gaetan Rivet Subject: [ovs-dev] [PATCH V3 06/14] dpif-netdev: Add HW miss packet state recover logic 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" Recover the packet if it was partially processed by the HW. Fallback to lookup flow by mark association. Signed-off-by: Eli Britstein Reviewed-by: Gaetan Rivet --- lib/dpif-netdev.c | 74 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 4381c618f..3b67761cd 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -7040,6 +7040,46 @@ smc_lookup_batch(struct dp_netdev_pmd_thread *pmd, pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_SMC_HIT, n_smc_hit); } +static struct tx_port * +pmd_send_port_cache_lookup(const struct dp_netdev_pmd_thread *pmd, + odp_port_t port_no); + +static inline int +dp_netdev_hw_flow(const struct dp_netdev_pmd_thread *pmd, + odp_port_t port_no, + struct dp_packet *packet, + uint16_t *tcp_flags, + struct dp_netdev_flow **flow) +{ + struct tx_port *p; + uint32_t mark; + + if (!netdev_is_flow_api_enabled() || *recirc_depth_get() != 0) { + *flow = NULL; + return 0; + } + + /* Restore the packet if HW processing was terminated before completion. */ + *tcp_flags = parse_tcp_flags(packet); + p = pmd_send_port_cache_lookup(pmd, port_no); + if (OVS_LIKELY(p)) { + int err = netdev_hw_miss_packet_recover(p->port->netdev, packet); + + if (err != 0 && err != EOPNOTSUPP) { + return -1; + } + } + + /* If no mark, no flow to find. */ + if (!dp_packet_has_flow_mark(packet, &mark)) { + *flow = NULL; + return 0; + } + + *flow = mark_to_flow_find(pmd, mark); + return 0; +} + /* Try to process all ('cnt') the 'packets' using only the datapath flow cache * 'pmd->flow_cache'. If a flow is not found for a packet 'packets[i]', the * miniflow is copied into 'keys' and the packet pointer is moved at the @@ -7084,7 +7124,6 @@ dfc_processing(struct dp_netdev_pmd_thread *pmd, DP_PACKET_BATCH_REFILL_FOR_EACH (i, cnt, packet, packets_) { struct dp_netdev_flow *flow; - uint32_t mark; if (OVS_UNLIKELY(dp_packet_size(packet) < ETH_HEADER_LEN)) { dp_packet_delete(packet); @@ -7103,24 +7142,23 @@ dfc_processing(struct dp_netdev_pmd_thread *pmd, pkt_metadata_init(&packet->md, port_no); } - if ((*recirc_depth_get() == 0) && - dp_packet_has_flow_mark(packet, &mark)) { - flow = mark_to_flow_find(pmd, mark); - if (OVS_LIKELY(flow)) { - tcp_flags = parse_tcp_flags(packet); - if (OVS_LIKELY(batch_enable)) { - dp_netdev_queue_batches(packet, flow, tcp_flags, batches, - n_batches); - } else { - /* Flow batching should be performed only after fast-path - * processing is also completed for packets with emc miss - * or else it will result in reordering of packets with - * same datapath flows. */ - packet_enqueue_to_flow_map(packet, flow, tcp_flags, - flow_map, map_cnt++); - } - continue; + if (OVS_UNLIKELY(dp_netdev_hw_flow(pmd, port_no, packet, &tcp_flags, + &flow))) { + /* With error, do not continue processing. */ + continue; + } else if (OVS_LIKELY(flow)) { + if (OVS_LIKELY(batch_enable)) { + dp_netdev_queue_batches(packet, flow, tcp_flags, batches, + n_batches); + } else { + /* Flow batching should be performed only after fast-path + * processing is also completed for packets with emc miss + * or else it will result in reordering of packets with + * same datapath flows. */ + packet_enqueue_to_flow_map(packet, flow, tcp_flags, flow_map, + map_cnt++); } + continue; } miniflow_extract(packet, &key->mf);