From patchwork Sun Jul 12 19:26:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriharsha Basavapatna X-Patchwork-Id: 1327586 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=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=D+fDepc1; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B4cGm4PlTz9sR4 for ; Mon, 13 Jul 2020 05:26:56 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 24ED788FAB; Sun, 12 Jul 2020 19:26:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dp-0PaQSBSPr; Sun, 12 Jul 2020 19:26:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 6C62688CB0; Sun, 12 Jul 2020 19:26:52 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4C83EC08A2; Sun, 12 Jul 2020 19:26:52 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 83EE7C0733 for ; Sun, 12 Jul 2020 19:26:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 7335188C34 for ; Sun, 12 Jul 2020 19:26:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vG0Oisefoxlg for ; Sun, 12 Jul 2020 19:26:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by whitealder.osuosl.org (Postfix) with ESMTPS id 265E488B65 for ; Sun, 12 Jul 2020 19:26:49 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id f16so5081748pjt.0 for ; Sun, 12 Jul 2020 12:26:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0ZN3pMuwExpEJN2ygDkoarVPMVCJQNWqkB6uhnZ+1iU=; b=D+fDepc1dNPlTaDr2sDy+yXnDgY0Bd5Sq5fVDkcHzvGC1gA9qqhlQAiPKu997+LVsP yfPlNLxKnGvkF8W1Wb/0XR7RPSeyIoQYIAbrySFUqa7JdflLDKjUcvuHvHidpxA+JfiQ 4e4wun94EFC7Ra1C2gz+Nc/8X7MwuA7crR6RI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0ZN3pMuwExpEJN2ygDkoarVPMVCJQNWqkB6uhnZ+1iU=; b=mpqjS1Jx6zUjd1eWHxM9+ea5LmBP+aLFP7LoX5HICQE/88iFFGdmgV3uRN5w5nF5iC s9pQtrVmdDVhUhHc/YlE+8cuCcO0LYQCK0ZGZQypk5y9vShdX9MEhsfxZ8jqH9sdRgo1 ctTzvZK/Vg2zHCBF6A5S1YqXIWj0IzNj41sP1YCsN2vRnRklu4Zph5+FxWyyCbWbCDiY zQnGzGaAEqXlEgXgJU++e6jniX6t+igilPQq0W66CCAZHjEUpPLFJdVnM0PJu65eZOrs XwsFs23FiPQ4UKbpjGe3i6x/L+Pmv0RDlM0XVRgwaPUZOvthenbrflWxUMuKenOC7SEp zkSA== X-Gm-Message-State: AOAM531f7GQrPwmkpQR+Ke2h8WBTQubgokKWm5OBwwc+8Xi1YVrh7Re0 uXfMKndh1W5TESp9Oi6IaxhsHH+SOYZWkN1MY2eeDZK+6o9isN2Yg7wO7zK723iw4DpLyJ6qa41 XwKAjU+vUNi/goaR88bfttXqTxq5u5K08GxdLp5cgCSO/25UeBlwdg6ciwM1uePInO+mwu3b/zB HgMDdp X-Google-Smtp-Source: ABdhPJwTOB1CO5uGBUyAbW8xP4sOMED5Z6/lYju6mhIQO2wSjca4qecTAuecbxNbELNOVjIGxAnd4w== X-Received: by 2002:a17:90a:3769:: with SMTP id u96mr17021342pjb.198.1594582007868; Sun, 12 Jul 2020 12:26:47 -0700 (PDT) Received: from dhcp-10-123-153-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 17sm9124023pjl.30.2020.07.12.12.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 12:26:47 -0700 (PDT) To: dev@openvswitch.org Date: Sun, 12 Jul 2020 15:26:20 -0400 Message-Id: <20200712192625.7359-4-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.25.0.rc2 In-Reply-To: <20200712192625.7359-1-sriharsha.basavapatna@broadcom.com> References: <20200712192625.7359-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v6 3/8] dpif-netdev: Skip encap action during datapath execution 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: , X-Patchwork-Original-From: Sriharsha Basavapatna via dev From: Sriharsha Basavapatna Reply-To: Sriharsha Basavapatna Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" In this patch we check if action processing (apart from OUTPUT action), should be skipped for a given dp_netdev_flow. Specifically, we check if the action is TNL_PUSH and if it has been offloaded to HW, then we do not push the tunnel header in SW. The datapath only executes the OUTPUT action. The packet will be encapsulated in HW during transmit. Reviewed-by: Hemal Shah Signed-off-by: Sriharsha Basavapatna --- lib/dpif-netdev.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index f26caef6d..c75a07c5e 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -113,6 +113,7 @@ COVERAGE_DEFINE(datapath_drop_invalid_port); COVERAGE_DEFINE(datapath_drop_invalid_bond); COVERAGE_DEFINE(datapath_drop_invalid_tnl_port); COVERAGE_DEFINE(datapath_drop_rx_invalid_packet); +COVERAGE_DEFINE(datapath_skip_tunnel_push); /* Protects against changes to 'dp_netdevs'. */ static struct ovs_mutex dp_netdev_mutex = OVS_MUTEX_INITIALIZER; @@ -547,6 +548,16 @@ struct dp_netdev_flow { bool dead; uint32_t mark; /* Unique flow mark assigned to a flow */ + /* The next two members are used to support partial offloading of + * actions. The boolean flag tells if this flow has its actions partially + * offloaded. The egress port# tells if the action should be offloaded + * on the egress (output) port instead of the in-port for the flow. Note + * that we support flows with a single egress port action. + * (see MAX_ACTION_ATTRS for related comments). + */ + bool partial_actions_offloaded; + odp_port_t egress_offload_port; + /* Statistics. */ struct dp_netdev_flow_stats stats; @@ -822,7 +833,8 @@ static void dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd, bool should_steal, const struct flow *flow, const struct nlattr *actions, - size_t actions_len); + size_t actions_len, + const struct dp_netdev_flow *dp_flow); static void dp_netdev_input(struct dp_netdev_pmd_thread *, struct dp_packet_batch *, odp_port_t port_no); static void dp_netdev_recirculate(struct dp_netdev_pmd_thread *, @@ -3966,7 +3978,7 @@ dpif_netdev_execute(struct dpif *dpif, struct dpif_execute *execute) dp_packet_batch_init_packet(&pp, execute->packet); pp.do_not_steal = true; dp_netdev_execute_actions(pmd, &pp, false, execute->flow, - execute->actions, execute->actions_len); + execute->actions, execute->actions_len, NULL); dp_netdev_pmd_flush_output_packets(pmd, true); if (pmd->core_id == NON_PMD_CORE_ID) { @@ -6700,7 +6712,7 @@ packet_batch_per_flow_execute(struct packet_batch_per_flow *batch, actions = dp_netdev_flow_get_actions(flow); dp_netdev_execute_actions(pmd, &batch->array, true, &flow->flow, - actions->actions, actions->size); + actions->actions, actions->size, flow); } static inline void @@ -6995,7 +7007,7 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd, * we'll send the packet up twice. */ dp_packet_batch_init_packet(&b, packet); dp_netdev_execute_actions(pmd, &b, true, &match.flow, - actions->data, actions->size); + actions->data, actions->size, NULL); add_actions = put_actions->size ? put_actions : actions; if (OVS_LIKELY(error != ENOSPC)) { @@ -7230,6 +7242,7 @@ dp_netdev_recirculate(struct dp_netdev_pmd_thread *pmd, struct dp_netdev_execute_aux { struct dp_netdev_pmd_thread *pmd; const struct flow *flow; + const struct dp_netdev_flow *dp_flow; /* for partial action offload */ }; static void @@ -7374,7 +7387,7 @@ dp_execute_userspace_action(struct dp_netdev_pmd_thread *pmd, if (!error || error == ENOSPC) { dp_packet_batch_init_packet(&b, packet); dp_netdev_execute_actions(pmd, &b, should_steal, flow, - actions->data, actions->size); + actions->data, actions->size, NULL); } else if (should_steal) { dp_packet_delete(packet); COVERAGE_INC(datapath_drop_userspace_action_error); @@ -7483,6 +7496,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_, int type = nl_attr_type(a); struct tx_port *p; uint32_t packet_count, packets_dropped; + const struct dp_netdev_flow *dp_flow = aux->dp_flow; switch ((enum ovs_action_attr)type) { case OVS_ACTION_ATTR_OUTPUT: @@ -7505,9 +7519,20 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_, } dp_packet_batch_apply_cutlen(packets_); packet_count = dp_packet_batch_size(packets_); - if (push_tnl_action(pmd, a, packets_)) { - COVERAGE_ADD(datapath_drop_tunnel_push_error, - packet_count); + /* Execute tnl_push action in SW, if it is not offloaded as a partial + * action in HW. Otherwise, HW pushes the tunnel header during output + * processing. There's a small window here in which the offload thread + * offloads the flow, but the partial_actions_offloaded flag is still + * not set. In this case, as the packet is already encapsulated, it + * wouldn't match the offloaded flow and the action won't be executed + * in HW. + */ + if (!dp_flow || !dp_flow->partial_actions_offloaded) { + if (push_tnl_action(pmd, a, packets_)) { + COVERAGE_ADD(datapath_drop_tunnel_push_error, packet_count); + } + } else { + COVERAGE_ADD(datapath_skip_tunnel_push, packet_count); } return; @@ -7799,9 +7824,10 @@ static void dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd, struct dp_packet_batch *packets, bool should_steal, const struct flow *flow, - const struct nlattr *actions, size_t actions_len) + const struct nlattr *actions, size_t actions_len, + const struct dp_netdev_flow *dp_flow) { - struct dp_netdev_execute_aux aux = { pmd, flow }; + struct dp_netdev_execute_aux aux = { pmd, flow, dp_flow }; odp_execute_actions(&aux, packets, should_steal, actions, actions_len, dp_execute_cb);