From patchwork Mon Dec 14 02:19:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1415728 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=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=TDVuHGJc; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CvQC06mF0z9sTX for ; Mon, 14 Dec 2020 13:22:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 66A9D85AE9; Mon, 14 Dec 2020 02:22:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NggZZdLSLo97; Mon, 14 Dec 2020 02:22:15 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 08D7A85AA1; Mon, 14 Dec 2020 02:22:15 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E09C9C088E; Mon, 14 Dec 2020 02:22:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 94BC3C013B for ; Mon, 14 Dec 2020 02:22:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7FF7785A78 for ; Mon, 14 Dec 2020 02:22:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iCU2VEfxWsbo for ; Mon, 14 Dec 2020 02:22:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by fraxinus.osuosl.org (Postfix) with ESMTPS id AF71185A22 for ; Mon, 14 Dec 2020 02:22:12 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id v3so7805583plz.13 for ; Sun, 13 Dec 2020 18:22:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aO41yoEwDPhUn0NXYAnAz4ACp3rhpyCTssw1Bedvisk=; b=TDVuHGJc8Xhh5sAtUuRldPOfKx3TWsn0uMUL3hdIQL0icyHdslFv/5GMfd8jWam10u E0IaVKeehdojwelRChYsNWe5oOwbeTEwv6Lj6FABZxpnL+3ATCyDTM1LJq6/sNFaKhJs Oz+JeEE9n4u+wxrIK7DspVaInavvPYlwkMa+uAtYE8y4Amtb9Uwzwcq7H76pF76LpcZ/ LGtVvP0az/WjkEoimyjs/LQYI4wZGWAfxFCGnK72FMxkEnw6IpBF/daJCnzsF2vMHX5l Ri7nWXZjhIJPiYqbozgDXBYJYvhNR60Lp092xGDzpDO2jidw+uA7ebfwK2cBi44qH88g zAfA== 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; bh=aO41yoEwDPhUn0NXYAnAz4ACp3rhpyCTssw1Bedvisk=; b=Hdb7tanL2VWmG2mQUyYqm0dWntwWe8PRPxuXmSd0EW4rNL9JBHrgQILzo5pvjYcuiw GylGg5LgsUwM1XA81Dp2wte/Tb2TJBwvwQ9YcauGKDB+SJWMYNfpYbmI6ChRaIDCUFsh xG86QnNyfd4K8PEQ8+r12arvwNN30s2bTEaQzEltBmhu7y8hMKSwkDgq6h6BXUZHLVmG jAbMTscihLaQnKE+LmEDd5IX64KgjmuPRziN3Y1o6VsdRDGrT1HtzDjs/XTVMfl6OzRy nT3C4puBHGP4QHfds74drIY8n0bo0bNXbJyAu/hymNzm57gQ/kbcnUHlse7iC8IuvMBg 0wBQ== X-Gm-Message-State: AOAM532v8kgK14x0mdZWrSN/rYd3F87/+FVhCmADdCWqUioQn9ztzEMT CLJNzjAGLVPNKrQktEd0uVWfjZ4YtD0= X-Google-Smtp-Source: ABdhPJxshLJprPruqEd2RvM5SEhgIcuYaKOHpLaUWCQcUmtnEpNbae0Iaj6n/JvyFRLGIMcupcaM0w== X-Received: by 2002:a17:90a:bb83:: with SMTP id v3mr23032780pjr.28.1607912532280; Sun, 13 Dec 2020 18:22:12 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id z7sm18019540pfq.193.2020.12.13.18.22.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Dec 2020 18:22:11 -0800 (PST) From: xiangxia.m.yue@gmail.com To: blp@ovn.org, i.maximets@ovn.org, u9012063@gmail.com, elibr@nvidia.com Date: Mon, 14 Dec 2020 10:19:58 +0800 Message-Id: <20201214022001.84273-2-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20201214022001.84273-1-xiangxia.m.yue@gmail.com> References: <20201214022001.84273-1-xiangxia.m.yue@gmail.com> Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH ovs v1 1/4] netdev-dpdk: Allow to config isolate offload mode. 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Tonghao Zhang Isolated mode guarantees that all ingress traffic comes from defined flow rules only (current and future). Besides making ingress more deterministic, it allows PMDs to safely reuse resources otherwise assigned to handle the remaining traffic, such as global RSS configuration settings, VLAN filters, MAC address entries, legacy filter API rules and so on in order to expand the set of possible flow rule types. Calling this function as soon as possible after device initialization, ideally before the first call to rte_eth_dev_configure(), is recommended to avoid possible failures due to conflicting settings. Once effective, leaving isolated mode may not be possible depending on PMD implementation. Signed-off-by: Tonghao Zhang --- lib/netdev-dpdk.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 75dffefb8..48eb46f38 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -522,6 +522,10 @@ struct netdev_dpdk { * otherwise interrupt mode is used. */ bool requested_lsc_interrupt_mode; bool lsc_interrupt_mode; + /* Allow to use hardware capable ethernet devices to + * split traffic between userspace and kernel space. */ + bool requested_isolate_offload_mode; + bool isolate_offload_mode; /* VF configuration. */ struct eth_addr requested_hwaddr; @@ -965,6 +969,13 @@ dpdk_eth_dev_port_config(struct netdev_dpdk *dev, int n_rxq, int n_txq) struct rte_eth_dev_info info; uint16_t conf_mtu; + diag = rte_flow_isolate(dev->port_id, dev->isolate_offload_mode, NULL); + if (diag && diag != -ENOSYS) { + VLOG_WARN("rte_flow_isolate was invoked unsuccessfully, mode(%d): %d\n", + dev->isolate_offload_mode, diag); + return diag; + } + rte_eth_dev_info_get(dev->port_id, &info); /* As of DPDK 19.11, it is not allowed to set a mq_mode for @@ -1245,6 +1256,7 @@ common_construct(struct netdev *netdev, dpdk_port_t port_no, dev->requested_mtu = RTE_ETHER_MTU; dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu); dev->requested_lsc_interrupt_mode = 0; + dev->requested_isolate_offload_mode = 0; ovsrcu_index_init(&dev->vid, -1); dev->vhost_reconfigured = false; dev->attached = false; @@ -1739,6 +1751,8 @@ netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args) } smap_add(args, "lsc_interrupt_mode", dev->lsc_interrupt_mode ? "true" : "false"); + smap_add(args, "isolate_offload_mode", + dev->isolate_offload_mode ? "true" : "false"); if (dpdk_port_is_representor(dev)) { smap_add_format(args, "dpdk-vf-mac", ETH_ADDR_FMT, @@ -1918,6 +1932,7 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args, bool rx_fc_en, tx_fc_en, autoneg, lsc_interrupt_mode; bool flow_control_requested = true; enum rte_eth_fc_mode fc_mode; + bool isolate_offload_mode; static const enum rte_eth_fc_mode fc_mode_set[2][2] = { {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL } @@ -2022,6 +2037,12 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args, netdev_request_reconfigure(netdev); } + isolate_offload_mode = smap_get_bool(args, "isolate-offload-mode", false); + if (dev->requested_isolate_offload_mode != isolate_offload_mode) { + dev->requested_isolate_offload_mode = isolate_offload_mode; + netdev_request_reconfigure(netdev); + } + rx_fc_en = smap_get_bool(args, "rx-flow-ctrl", false); tx_fc_en = smap_get_bool(args, "tx-flow-ctrl", false); autoneg = smap_get_bool(args, "flow-ctrl-autoneg", false); @@ -4985,6 +5006,7 @@ netdev_dpdk_reconfigure(struct netdev *netdev) && netdev->n_rxq == dev->requested_n_rxq && dev->mtu == dev->requested_mtu && dev->lsc_interrupt_mode == dev->requested_lsc_interrupt_mode + && dev->isolate_offload_mode == dev->requested_isolate_offload_mode && dev->rxq_size == dev->requested_rxq_size && dev->txq_size == dev->requested_txq_size && eth_addr_equals(dev->hwaddr, dev->requested_hwaddr) @@ -5011,6 +5033,7 @@ netdev_dpdk_reconfigure(struct netdev *netdev) } dev->lsc_interrupt_mode = dev->requested_lsc_interrupt_mode; + dev->isolate_offload_mode = dev->requested_isolate_offload_mode; netdev->n_txq = dev->requested_n_txq; netdev->n_rxq = dev->requested_n_rxq;