From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C4587A0A02; Fri, 15 Jan 2021 13:03:18 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B660141024; Fri, 15 Jan 2021 13:03:18 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 09ED6141015 for ; Fri, 15 Jan 2021 13:03:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610712196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7c1aZ8SvVxZt0ZsgobjkJS5gTYKPh/iM9cWCG5WuOT0=; b=HNr2A0RP/UxArevyCjwzmUirG8EAJSbZ4ga4LCBbLyQxD/mIVEvRxOfXfS8YD4QGEF74lE epxI+koqPQ+vGQ/dkFDIMb4fDzIzuhUbJN+vJJxCYv3QxxCEBmaA3NGAONlHvrni8lTghB cokuyOHh4wbOTEkmhoBy7Mtpsmz2lE8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-63-FcTBHXMuMXCmT03770TIzg-1; Fri, 15 Jan 2021 07:03:12 -0500 X-MC-Unique: FcTBHXMuMXCmT03770TIzg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7B0A107ACF7; Fri, 15 Jan 2021 12:03:11 +0000 (UTC) Received: from [10.36.110.24] (unknown [10.36.110.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64928620DE; Fri, 15 Jan 2021 12:03:07 +0000 (UTC) To: "Xia, Chenbo" , "dev@dpdk.org" , "olivier.matz@6wind.com" , "amorenoz@redhat.com" , "david.marchand@redhat.com" References: <20201220211405.313012-1-maxime.coquelin@redhat.com> <20201220211405.313012-39-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: Date: Fri, 15 Jan 2021 13:03:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 38/40] net/virtio: move Vhost-user specifics to its backend X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" On 1/7/21 7:32 AM, Xia, Chenbo wrote: > Hi Maxime, > >> -----Original Message----- >> From: Maxime Coquelin >> Sent: Monday, December 21, 2020 5:14 AM >> To: dev@dpdk.org; Xia, Chenbo ; olivier.matz@6wind.com; >> amorenoz@redhat.com; david.marchand@redhat.com >> Cc: Maxime Coquelin >> Subject: [PATCH 38/40] net/virtio: move Vhost-user specifics to its backend >> >> This patch moves all the Vhost-user backend specific >> logic like Vhost FD, listen FD and interrupt handling >> to the vhost-user backend implementation. >> >> In order to achieve that, new ops are created to update >> the link status, disconnect and reconnect the server, >> and fetch the link state interrupt FD. >> >> Signed-off-by: Maxime Coquelin >> --- >> drivers/net/virtio/virtio_user/vhost.h | 4 + >> drivers/net/virtio/virtio_user/vhost_kernel.c | 18 +- >> drivers/net/virtio/virtio_user/vhost_user.c | 169 ++++++++++++++--- >> drivers/net/virtio/virtio_user/vhost_vdpa.c | 16 ++ >> .../net/virtio/virtio_user/virtio_user_dev.c | 175 ++++++++++++++--- >> .../net/virtio/virtio_user/virtio_user_dev.h | 9 +- >> drivers/net/virtio/virtio_user_ethdev.c | 179 +----------------- >> 7 files changed, 340 insertions(+), 230 deletions(-) >> >> diff --git a/drivers/net/virtio/virtio_user/vhost.h >> b/drivers/net/virtio/virtio_user/vhost.h >> index ee5598226d..6001d7a164 100644 >> --- a/drivers/net/virtio/virtio_user/vhost.h >> +++ b/drivers/net/virtio/virtio_user/vhost.h >> @@ -75,6 +75,10 @@ struct virtio_user_backend_ops { >> int (*enable_qp)(struct virtio_user_dev *dev, uint16_t pair_idx, int >> enable); >> int (*dma_map)(struct virtio_user_dev *dev, void *addr, uint64_t iova, >> size_t len); >> int (*dma_unmap)(struct virtio_user_dev *dev, void *addr, uint64_t iova, >> size_t len); >> + int (*update_link_state)(struct virtio_user_dev *dev); >> + int (*server_disconnect)(struct virtio_user_dev *dev); >> + int (*server_reconnect)(struct virtio_user_dev *dev); >> + int (*get_intr_fd)(struct virtio_user_dev *dev); > > This get_intr_fd is for getting link state interrupt fd. I think his name is a little bit > generic. What do you think? Maybe we could change the name or add comment here to clarify here? > >> }; >> >> extern struct virtio_user_backend_ops virtio_ops_user; >> diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c >> b/drivers/net/virtio/virtio_user/vhost_kernel.c >> index 023fddcd69..0ba37b23dc 100644 >> --- a/drivers/net/virtio/virtio_user/vhost_kernel.c >> +++ b/drivers/net/virtio/virtio_user/vhost_kernel.c >> @@ -459,6 +459,20 @@ vhost_kernel_get_backend_features(uint64_t *features) >> return 0; >> } >> > > > >> +static void >> +virtio_user_dev_reset_queues_packed(struct rte_eth_dev *eth_dev) >> +{ >> + struct virtio_user_dev *dev = eth_dev->data->dev_private; >> + struct virtio_hw *hw = &dev->hw; >> + struct virtnet_rx *rxvq; >> + struct virtnet_tx *txvq; >> + uint16_t i; >> + >> + /* Add lock to avoid queue contention. */ >> + rte_spinlock_lock(&hw->state_lock); >> + hw->started = 0; >> + >> + /* >> + * Waitting for datapath to complete before resetting queues. > > s/Waitting/Waiting Fixed >> + * 1 ms should be enough for the ongoing Tx/Rx function to finish. >> + */ >> + rte_delay_ms(1); >> + >> + /* Vring reset for each Tx queue and Rx queue. */ >> + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { >> + rxvq = eth_dev->data->rx_queues[i]; >> + virtqueue_rxvq_reset_packed(rxvq->vq); >> + virtio_dev_rx_queue_setup_finish(eth_dev, i); >> + } >> + >> + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { >> + txvq = eth_dev->data->tx_queues[i]; >> + virtqueue_txvq_reset_packed(txvq->vq); >> + } >> + >> + hw->started = 1; >> + rte_spinlock_unlock(&hw->state_lock); >> +} >> + >> +void >> +virtio_user_dev_delayed_handler(void *param) >> +{ >> + struct virtio_user_dev *dev = param; >> + struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id]; >> + >> + if (rte_intr_disable(eth_dev->intr_handle) < 0) { >> + PMD_DRV_LOG(ERR, "interrupt disable failed"); >> + return; >> + } >> + rte_intr_callback_unregister(eth_dev->intr_handle, >> + virtio_interrupt_handler, eth_dev); >> + if (dev->is_server) { >> + dev->ops->server_disconnect(dev); > > Better to check ops existence too? Indeed, v2 will check its existence before calling. >> + eth_dev->intr_handle->fd = dev->ops->get_intr_fd(dev); >> + rte_intr_callback_register(eth_dev->intr_handle, >> + virtio_interrupt_handler, eth_dev); >> + if (rte_intr_enable(eth_dev->intr_handle) < 0) { >> + PMD_DRV_LOG(ERR, "interrupt enable failed"); >> + return; >> + } >> + } >> +} >> + >> +int >> +virtio_user_dev_server_reconnect(struct virtio_user_dev *dev) >> +{ >> + int ret, old_status; >> + struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id]; >> + struct virtio_hw *hw = &dev->hw; >> + >> + if (!dev->ops->server_reconnect) { >> + PMD_DRV_LOG(ERR, "(%s) Missing server reconnect callback", dev- >>> path); >> + return -1; >> + } > > Forget to call server_reconnect? :) Indeed! When I said I didn't tried last 5 patches, I wasn't lying! :) >> + >> + old_status = virtio_get_status(hw); >> + >> + virtio_reset(hw); >> + >> + virtio_set_status(hw, VIRTIO_CONFIG_STATUS_ACK); >> + >> + virtio_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER); >> + >> + if (dev->ops->get_features(dev, &dev->device_features) < 0) { >> + PMD_INIT_LOG(ERR, "get_features failed: %s", >> + strerror(errno)); >> + return -1; >> + } >> + >> + dev->device_features |= dev->frontend_features; >> + >> + /* umask vhost-user unsupported features */ > > s/umask/unmask Fixed. Thanks, Maxime > Thanks, > Chenbo >