From patchwork Mon Sep 19 13:33:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 671748 X-Patchwork-Delegate: diproiettod@vmware.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3sd6Kq6Q6Xz9s3T for ; Mon, 19 Sep 2016 23:33:50 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7D541103A2; Mon, 19 Sep 2016 06:33:49 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id EBA8010245 for ; Mon, 19 Sep 2016 06:33:47 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 299BD1620A7 for ; Mon, 19 Sep 2016 07:33:47 -0600 (MDT) X-ASG-Debug-ID: 1474292025-0b3237226161aac0001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar6.cudamail.com with ESMTP id 9NZCQQ2Xh2UfA83g (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 19 Sep 2016 07:33:45 -0600 (MDT) X-Barracuda-Envelope-From: i.maximets@samsung.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mailout1.w1.samsung.com) (210.118.77.11) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES128-SHA encrypted); 19 Sep 2016 13:33:44 -0000 Received-SPF: none (mx1-pf2.cudamail.com: domain at samsung.com does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 210.118.77.11 X-Barracuda-RBL-IP: 210.118.77.11 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ODR00E757054230@mailout1.w1.samsung.com> for dev@openvswitch.org; Mon, 19 Sep 2016 14:33:41 +0100 (BST) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20160919133341eucas1p22251e69f9df99f53af80371b79ac8297~1vMgvKPSS0982809828eucas1p2v; Mon, 19 Sep 2016 13:33:41 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges4.samsung.com (EUCPMTA) with SMTP id 6B.65.28332.439EFD75; Mon, 19 Sep 2016 14:33:40 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20160919133340eucas1p2ceaac4f94f2d5e421f3f7488ea252695~1vMf5KQMZ0568005680eucas1p2g; Mon, 19 Sep 2016 13:33:40 +0000 (GMT) X-AuditID: cbfec7f4-f791c6d000006eac-94-57dfe9344357 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id AF.B1.07726.B09EFD75; Mon, 19 Sep 2016 14:32:59 +0100 (BST) Received: from imaximets.rnd.samsung.ru ([106.109.129.180]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0ODR00BI6700GJB0@eusync3.samsung.com>; Mon, 19 Sep 2016 14:33:40 +0100 (BST) X-CudaMail-Envelope-Sender: i.maximets@samsung.com From: Ilya Maximets To: dev@openvswitch.org, Daniele Di Proietto X-CudaMail-MID: CM-E2-918015382 X-CudaMail-DTE: 091916 X-CudaMail-Originating-IP: 210.118.77.11 Date: Mon, 19 Sep 2016 16:33:33 +0300 X-ASG-Orig-Subj: [##CM-E2-918015382##][PATCH] netdev-dpdk: Configure flow control only when necessary. Message-id: <1474292013-715-1-git-send-email-i.maximets@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsWy7djPc7omL++HG2yeqmux85myRUv/TGaL o6f3MFu87L7HbjHt8212iyvtP9ktJs+Wsnh68RezA4fH4j0vmTye3fzP6NG3ZRWjx7v5b9kC WKK4bFJSczLLUov07RK4Mnbe+c1ScEyoovnGQ6YGxna+LkZODgkBE4mOz3uZIWwxiQv31rN1 MXJxCAksZZQ4sXgTC4TzmVHiXddHVpiOySe2QVUtY5Rom/eOHSQhJNDMJPHpejqIzSagI3Fq 9RFGEFtEwFVi+u037CANzAI9TBI/pz8CmyQs4Ckx5e5LsGYWAVWJAw3LgBo4OHgFXCReT+OH WCYncfNcJzNIr4TAbTaJRTsvs4DUSAjISmw6AHW2i8T858vZIGxhiVfHt7BD2DISnR0HmSDs aomJW9vYIea0MEosnPgD6ht7iVM3r4IVMQvwSUzaNp0ZYj6vREebEESJh0Tfi31Qcxwllm3Y CHamkECsxJvt5RMYpRcwMqxiFEktLc5NTy020StOzC0uzUvXS87P3cQIjNHT/45/2cG4+JjV IUYBDkYlHt4Vj++HC7EmlhVX5h5ilOBgVhLhZT0NFOJNSaysSi3Kjy8qzUktPsQozcGiJM67 Z8GVcCGB9MSS1OzU1ILUIpgsEwenVAOjfJfQ8vmKOlaseqfyDC/ZsPcEGd4/8ePaD9V7v5On ++iolFh9+fZ8xeTL2zoeakcczdm/6MCkpx9tff693Hog6j5HVPzuHKPdLEVFs3983390960D B9OvyGZZ63+cd2ZOWoR8jpBCK/NZ6/tn65WmviycsvTIzlsWecpWU6MNBRJilQx0Tf4sUGIp zkg01GIuKk4EAAlK4drNAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsVy+t/xq7rcL++HG8x8xWix85myRUv/TGaL o6f3MFu87L7HbjHt8212iyvtP9ktJs+Wsnh68RezA4fH4j0vmTye3fzP6NG3ZRWjx7v5b9kC WKLcbDJSE1NSixRS85LzUzLz0m2VQkPcdC2UFPISc1NtlSJ0fUOClBTKEnNKgTwjAzTg4Bzg Hqykb5fglrHzzm+WgmNCFc03HjI1MLbzdTFyckgImEhMPrGNDcIWk7hwbz2QzcUhJLCEUWLt 7JtMEE4rk8TEFYuZQKrYBHQkTq0+wghiiwi4Sky//YYdpIhZoI9J4s6fHhaQhLCAp8SUuy/Z QWwWAVWJAw3LgBo4OHgFXCReT+OH2CYncfNcJ/MERu4FjAyrGEVSS4tz03OLDfWKE3OLS/PS 9ZLzczcxAkNz27Gfm3cwXtoYfIhRgINRiYc34OH9cCHWxLLiytxDjBIczEoivKyngUK8KYmV ValF+fFFpTmpxYcYTYF2T2SWEk3OB8ZNXkm8oYmhuaWhkbGFhbmRkZI4b8mHK+FCAumJJanZ qakFqUUwfUwcnFINjNwPL2zcWlMyiUHlJ9fnoMD7/KVMjPO8dknMeVcpf6/xa7ZJpZ3KbJOi 4KTXIQsvus7UTnzzcPGS41sXdkd8XHzoztJLDm/7F2/++WGRbA3H2uM1FauyehNm9Uy8fMeY adbEV06d+s9ONT1dvKyxuloyJap+99wl3WH3fimGTnAROPV3dRfrsgAlluKMREMt5qLiRACN XRNcYwIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20160919133340eucas1p2ceaac4f94f2d5e421f3f7488ea252695 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?SWx5YSBNYXhpbWV0cxtTUlItVmlydHVhbGl6YXRpb24gTGFi?= =?UTF-8?B?G+yCvOyEseyghOyekBtFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?SWx5YSBNYXhpbWV0cxtTUlItVmlydHVhbGl6YXRpb24gTGFi?= =?UTF-8?B?G1NhbXN1bmcgRWxlY3Ryb25pY3MbRW5naW5lZXI=?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20160919133340eucas1p2ceaac4f94f2d5e421f3f7488ea252695 X-RootMTR: 20160919133340eucas1p2ceaac4f94f2d5e421f3f7488ea252695 References: X-GBUdb-Analysis: 0, 210.118.77.11, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-9496-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1474292025 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-ASG-Whitelist: EmailCat (corporate) Cc: Dyasly Sergey , Ilya Maximets Subject: [ovs-dev] [PATCH] netdev-dpdk: Configure flow control only when necessary. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" It is not necessary to touch the physical device each time, if the configuration has not been changed. Also, few style issues fixed. Signed-off-by: Ilya Maximets --- lib/netdev-dpdk.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 6d334db..1632b97 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1057,6 +1057,7 @@ netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args) static void dpdk_set_rxq_config(struct netdev_dpdk *dev, const struct smap *args) + OVS_REQUIRES(dev->mutex) { int new_n_rxq; @@ -1071,24 +1072,27 @@ static int netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args) { struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); + uint8_t rx_fc_en, tx_fc_en, autoneg; + enum rte_eth_fc_mode fc_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 } + }; ovs_mutex_lock(&dev->mutex); dpdk_set_rxq_config(dev, args); - /* Flow control support is only available for DPDK Ethernet ports. */ - bool rx_fc_en = false; - bool tx_fc_en = false; - enum rte_eth_fc_mode fc_mode_set[2][2] = - {{RTE_FC_NONE, RTE_FC_TX_PAUSE}, - {RTE_FC_RX_PAUSE, RTE_FC_FULL} - }; - rx_fc_en = smap_get_bool(args, "rx-flow-ctrl", false); - tx_fc_en = smap_get_bool(args, "tx-flow-ctrl", false); - dev->fc_conf.autoneg = smap_get_bool(args, "flow-ctrl-autoneg", false); - dev->fc_conf.mode = fc_mode_set[tx_fc_en][rx_fc_en]; - - dpdk_eth_flow_ctrl_setup(dev); + rx_fc_en = smap_get_bool(args, "rx-flow-ctrl", false) ? 1 : 0; + tx_fc_en = smap_get_bool(args, "tx-flow-ctrl", false) ? 1 : 0; + autoneg = smap_get_bool(args, "flow-ctrl-autoneg", false) ? 1 : 0; + + fc_mode = fc_mode_set[tx_fc_en][rx_fc_en]; + if (dev->fc_conf.mode != fc_mode || autoneg != dev->fc_conf.autoneg) { + dev->fc_conf.mode = fc_mode; + dev->fc_conf.autoneg = autoneg; + dpdk_eth_flow_ctrl_setup(dev); + } ovs_mutex_unlock(&dev->mutex);