From patchwork Wed Dec 28 21:10:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chas Williams X-Patchwork-Id: 18625 X-Patchwork-Delegate: yuanhan.liu@linux.intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id A09EB5320; Wed, 28 Dec 2016 22:11:43 +0100 (CET) Received: from mx0a-000f0801.pphosted.com (mx0b-000f0801.pphosted.com [67.231.152.113]) by dpdk.org (Postfix) with ESMTP id 4923B37A8 for ; Wed, 28 Dec 2016 22:11:09 +0100 (CET) Received: from pps.filterd (m0048192.ppops.net [127.0.0.1]) by mx0b-000f0801.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uBSL3jbq010349; Wed, 28 Dec 2016 13:11:08 -0800 Received: from brmwp-exmb11.corp.brocade.com ([208.47.132.227]) by mx0b-000f0801.pphosted.com with ESMTP id 27hs67tcuq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 28 Dec 2016 13:11:08 -0800 Received: from confsjhq2-2-001.brocade.com (10.252.139.5) by BRMWP-EXMB11.corp.brocade.com (172.16.59.77) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 28 Dec 2016 14:11:06 -0700 From: "Charles (Chas) Williams" To: CC: , , "Charles (Chas) Williams" Date: Wed, 28 Dec 2016 16:10:52 -0500 Message-ID: <1482959452-18486-2-git-send-email-ciwillia@brocade.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1482959452-18486-1-git-send-email-ciwillia@brocade.com> References: <1482959452-18486-1-git-send-email-ciwillia@brocade.com> MIME-Version: 1.0 X-ClientProxiedBy: hq1wp-excas11.corp.brocade.com (10.70.36.102) To BRMWP-EXMB11.corp.brocade.com (172.16.59.77) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-28_16:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1612280283 Subject: [dpdk-dev] [PATCH 2/2] vhost: start vhost servers once X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Start a vhost server once during devinit instead of during device start and stop. Some vhost clients, QEMU, don't re-attaching to sockets when the vhost server is stopped and later started. Preserve existing behavior for vhost clients. Fixes: ee584e9710b9 ("vhost: add driver on top of the library") Signed-off-by: Chas Williams --- drivers/net/vhost/rte_eth_vhost.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index ba559ff..914d83f 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -772,9 +772,8 @@ vhost_driver_session_stop(void) } static int -eth_dev_start(struct rte_eth_dev *dev) +vhost_dev_start(struct pmd_internal *internal) { - struct pmd_internal *internal = dev->data->dev_private; int ret = 0; if (rte_atomic16_cmpset(&internal->once, 0, 1)) { @@ -792,10 +791,8 @@ eth_dev_start(struct rte_eth_dev *dev) } static void -eth_dev_stop(struct rte_eth_dev *dev) +vhost_dev_stop(struct pmd_internal *internal) { - struct pmd_internal *internal = dev->data->dev_private; - if (rte_atomic16_cmpset(&internal->once, 1, 0)) { rte_vhost_driver_unregister(internal->iface_name); @@ -805,6 +802,27 @@ eth_dev_stop(struct rte_eth_dev *dev) } static int +eth_dev_start(struct rte_eth_dev *dev) +{ + struct pmd_internal *internal = dev->data->dev_private; + int ret = 0; + + if (internal->flags & RTE_VHOST_USER_CLIENT) + ret = vhost_dev_start(internal); + + return ret; +} + +static void +eth_dev_stop(struct rte_eth_dev *dev) +{ + struct pmd_internal *internal = dev->data->dev_private; + + if (internal->flags & RTE_VHOST_USER_CLIENT) + vhost_dev_stop(internal); +} + +static int eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, uint16_t nb_rx_desc __rte_unused, unsigned int socket_id, @@ -1079,6 +1097,11 @@ eth_dev_vhost_create(const char *name, char *iface_name, int16_t queues, eth_dev->rx_pkt_burst = eth_vhost_rx; eth_dev->tx_pkt_burst = eth_vhost_tx; + if ((flags & RTE_VHOST_USER_CLIENT) == 0) { + if (vhost_dev_start(internal)) + goto error; + } + return data->port_id; error: @@ -1216,6 +1239,9 @@ rte_pmd_vhost_remove(const char *name) eth_dev_stop(eth_dev); + if ((internal->flags & RTE_VHOST_USER_CLIENT) == 0) + vhost_dev_stop(internal); + rte_free(vring_states[eth_dev->data->port_id]); vring_states[eth_dev->data->port_id] = NULL;