From patchwork Fri Jul 15 10:28:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zoltan Balogh X-Patchwork-Id: 648757 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 3rrTLb6t9xz9s9Y for ; Fri, 15 Jul 2016 20:28:39 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 351AB10CF8; Fri, 15 Jul 2016 03:28:39 -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 8711410CD5 for ; Fri, 15 Jul 2016 03:28:37 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 1FE31163048 for ; Fri, 15 Jul 2016 04:28:37 -0600 (MDT) X-ASG-Debug-ID: 1468578516-0b32372078039e0001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar6.cudamail.com with ESMTP id uprV2v5hgZLgZo9L (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 15 Jul 2016 04:28:36 -0600 (MDT) X-Barracuda-Envelope-From: zoltan.balogh@ericsson.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO sessmg22.ericsson.net) (193.180.251.58) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 15 Jul 2016 10:28:35 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at ericsson.com designates 193.180.251.58 as permitted sender) X-Barracuda-Apparent-Source-IP: 193.180.251.58 X-Barracuda-RBL-IP: 193.180.251.58 X-AuditID: c1b4fb3a-f79386d00000467b-35-5788bad1b905 Received: from ESESSHC017.ericsson.se (Unknown_Domain [153.88.183.69]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 16.FF.18043.1DAB8875; Fri, 15 Jul 2016 12:28:33 +0200 (CEST) Received: from ESESSMB305.ericsson.se ([169.254.5.224]) by ESESSHC017.ericsson.se ([153.88.183.69]) with mapi id 14.03.0294.000; Fri, 15 Jul 2016 12:28:32 +0200 X-CudaMail-Envelope-Sender: zoltan.balogh@ericsson.com From: =?utf-8?B?Wm9sdMOhbiBCYWxvZ2g=?= To: "Loftus, Ciara" , Daniele Di Proietto X-CudaMail-MID: CM-E2-714004641 X-CudaMail-DTE: 071516 X-CudaMail-Originating-IP: 193.180.251.58 Thread-Topic: [ovs-dev] [PATCH] netdev-dpdk : vhost-user port link state fix X-ASG-Orig-Subj: [##CM-E2-714004641##]RE: [ovs-dev] [PATCH] netdev-dpdk : vhost-user port link state fix Thread-Index: AdGsaH/7fwSDM/50SaaYjERd/H73LgPupfUAACoiauAAD06AgAhX3UYAAAasjmA= Date: Fri, 15 Jul 2016 10:28:33 +0000 Message-ID: <397FD63D94A70042B39B21380C6225A83288F8A8@ESESSMB305.ericsson.se> References: <397FD63D94A70042B39B21380C6225A829B6B33D@ESESSMB305.ericsson.se> <397FD63D94A70042B39B21380C6225A829BA37E0@ESESSMB305.ericsson.se> <74F120C019F4A64C9B78E802F6AD4CC24F8EBAA7@IRSMSX106.ger.corp.intel.com> In-Reply-To: <74F120C019F4A64C9B78E802F6AD4CC24F8EBAA7@IRSMSX106.ger.corp.intel.com> Accept-Language: hu-HU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [153.88.183.19] MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprAIsWRmVeSWpSXmKPExsUyM2K7q+7FXR3hBj/3ylu09M9ktjh6eg+z xd0fK5gcmD0W73nJ5PHs5n9Gj+fXelgCmKO4bFJSczLLUov07RK4MqbMvshaME27Ysas2awN jB1aXYycHBICJhLHDx1lhrDFJC7cW8/WxcjFISRwhFHiVvtWdghnCaPEtwvrWECq2AScJfoe n2YDsUUEIiUOXtvHBGIzC+hL7H70jxXEFhbwlpgw+SWQzQFU4yMx9aIARLmfxI/lU8CWsQio Spzve8sOYvMK+Eq863/FCLHrJZPExzPNYPM5BUIketY+ZgaZwyggK/FwrQXEKnGJW0/mM0Ec LSCxZM95qAdEJV4+hjhBQkBRov1pAyNIK7OApsT6XfoQrYoSU7ofQq0VlDg58wnLBEaxWUim zkLomIWkYxaSjgWMLKsYRYtTi4tz042M9FKLMpOLi/Pz9PJSSzYxAuPp4JbfVjsYDz53PMQo wMGoxMOrcLk9XIg1say4MvcQowQHs5II7+UdHeFCvCmJlVWpRfnxRaU5qcWHGKU5WJTEef1f KoYLCaQnlqRmp6YWpBbBZJk4OKUaGMVdO54c1Xh35xqHm1DrT8nTEfH3/Wc6lxccvbbBpO7d A46OpbvSDJmXrQ8T0trPKtbVcvLSzzLhvXaXPT6lG058uLhPgsWA43mvpg5HgMc1PqNYobWq Jm3s7wtXPz2rvsR5aovIaT+X6afebn4nrZZhm1zc+HPKybd1h3ec4+h2yPiuv6c4XImlOCPR UIu5qDgRAAliFQmjAgAA X-GBUdb-Analysis: 0, 193.180.251.58, Ugly c=0.374854 p=-0.368421 Source Normal X-MessageSniffer-Rules: 0-0-0-6215-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1468578516 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-Barracuda-Spam-Score: 0.10 X-Barracuda-Spam-Status: No, SCORE=0.10 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC0_MISMATCH_TO, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.31281 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 BSF_SC0_MISMATCH_TO Envelope rcpt doesn't match header 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS Cc: "dev@openvswitch.org" Subject: Re: [ovs-dev] [PATCH] netdev-dpdk : vhost-user port link state fix 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: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" > > > > I changed 'netdev' to 'dev' in netdev_dpdk_init(), added Jan to AUTHORS > > and > > pushed this to master. > > Another backport request - could this be pushed to 2.5 too? > > Thanks, > Ciara Hi, Here is the patch for OVS 2.5, in case you want to push it: OVS reports that link state of a vhost-user port (type=dpdkvhostuser) is DOWN, even when traffic is running through the port between a Virtual Machine and the vSwitch. Changing admin state with the "ovs-ofctl mod-port
up/down" command over OpenFlow does affect neither the reported link state nor the traffic. The patch below does the flowing: - Triggers link state change by altering netdev's change_seq member. - Controls sending/receiving of packets through vhost-user port according to the port's current admin state. - Sets admin state of newly created vhost-user port to UP. Signed-off-by: Zoltán Balogh Co-authored-by: Jan Scheurich Signed-off-by: Jan Scheurich diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index cc5cd85..6e68c07 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -633,6 +633,8 @@ netdev_dpdk_init(struct netdev *netdev_, unsigned int port_no, } } else { netdev_dpdk_alloc_txq(netdev, OVS_VHOST_MAX_QUEUE_NUM); + /* Enable DPDK_DEV_VHOST device and set promiscuous mode flag. */ + netdev->flags = NETDEV_UP | NETDEV_PROMISC; } list_push_back(&dpdk_list, &netdev->list_node); @@ -1044,7 +1046,8 @@ netdev_dpdk_vhost_rxq_recv(struct netdev_rxq *rxq_, int qid = rxq_->queue_id; uint16_t nb_rx = 0; - if (OVS_UNLIKELY(!is_vhost_running(virtio_dev))) { + if (OVS_UNLIKELY(!is_vhost_running(virtio_dev) + || !(vhost_dev->flags & NETDEV_UP))) { return EAGAIN; } @@ -1128,7 +1131,8 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid, qid = vhost_dev->tx_q[qid % vhost_dev->real_n_txq].map; - if (OVS_UNLIKELY(!is_vhost_running(virtio_dev) || qid < 0)) { + if (OVS_UNLIKELY(!is_vhost_running(virtio_dev) || qid < 0 + || !(vhost_dev->flags & NETDEV_UP))) { rte_spinlock_lock(&vhost_dev->stats_lock); vhost_dev->stats.tx_dropped+= cnt; rte_spinlock_unlock(&vhost_dev->stats_lock); @@ -1684,6 +1688,23 @@ netdev_dpdk_update_flags__(struct netdev_dpdk *dev, if (!(dev->flags & NETDEV_UP)) { rte_eth_dev_stop(dev->port_id); } + } else { + /* If DPDK_DEV_VHOST device's NETDEV_UP flag was changed and vhost is + * running then change netdev's change_seq to trigger link state + * update. */ + struct virtio_net *virtio_dev = netdev_dpdk_get_virtio(dev); + + if ((NETDEV_UP & ((*old_flagsp ^ on) | (*old_flagsp ^ off))) + && is_vhost_running(virtio_dev)) { + netdev_change_seq_changed(&dev->up); + + /* Clear statistics if device is getting up. */ + if (NETDEV_UP & on) { + rte_spinlock_lock(&dev->stats_lock); + memset(&dev->stats, 0, sizeof(dev->stats)); + rte_spinlock_unlock(&dev->stats_lock); + } + } } return 0; @@ -1906,6 +1927,7 @@ new_device(struct virtio_net *dev) dev->flags |= VIRTIO_DEV_RUNNING; /* Disable notifications. */ set_irq_status(dev); + netdev_change_seq_changed(&netdev->up); ovs_mutex_unlock(&netdev->mutex); break; } @@ -1957,6 +1979,7 @@ destroy_device(volatile struct virtio_net *dev) ovsrcu_set(&vhost_dev->virtio_dev, NULL); netdev_dpdk_txq_map_clear(vhost_dev); exists = true; + netdev_change_seq_changed(&vhost_dev->up); ovs_mutex_unlock(&vhost_dev->mutex); break; }