From patchwork Tue Jan 19 21:24:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 86910 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B6A53A0A05; Tue, 19 Jan 2021 22:27:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 08516140EB4; Tue, 19 Jan 2021 22:26:41 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id 8A681140EA8 for ; Tue, 19 Jan 2021 22:26:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611091599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I9GxOtClfQoMKV6q17O6U/K6gbaBpsDYH/Y9VQCtbDQ=; b=NkgkDvRhM5Qa5M6iA/vuPxuOsz8bcIJd8jjgVEVSpJxnKhH28wvn9VYQFhF5zKqwpFOlhd X8ErpXR+5iWAqCExuUOycnBY1XZ5uJl7yO6YxNngGGw5IDXQ0leJRClP70KD55c+kPXgT2 etIPt39TXqHpmqiBieWeASMHHlWNQVo= 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-432-z-ZTHaKrMMWntVejsvlnVA-1; Tue, 19 Jan 2021 16:26:37 -0500 X-MC-Unique: z-ZTHaKrMMWntVejsvlnVA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4877F801817; Tue, 19 Jan 2021 21:26:36 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F9CA5D9F8; Tue, 19 Jan 2021 21:26:30 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, olivier.matz@6wind.com, amorenoz@redhat.com, david.marchand@redhat.com Cc: Maxime Coquelin Date: Tue, 19 Jan 2021 22:24:37 +0100 Message-Id: <20210119212507.1043636-15-maxime.coquelin@redhat.com> In-Reply-To: <20210119212507.1043636-1-maxime.coquelin@redhat.com> References: <20210119212507.1043636-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Subject: [dpdk-dev] [PATCH v2 14/44] net/virtio: remove bus type enum 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" Bus type awareness at the generic ethdev level is no more needed as previous patches have made it bus-agnostic. This patch removes it from struct virtio_hw. Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia Reviewed-by: David Marchand --- drivers/net/virtio/virtio_ethdev.c | 18 ------------------ drivers/net/virtio/virtio_pci.c | 2 -- drivers/net/virtio/virtio_pci.h | 8 -------- drivers/net/virtio/virtio_pci_ethdev.c | 7 ++++++- drivers/net/virtio/virtio_user_ethdev.c | 5 ++++- 5 files changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 747e70171f..1df2b852ce 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1798,23 +1798,6 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) return 0; } - -static void -virtio_set_vtpci_ops(struct virtio_hw *hw) -{ -#ifdef RTE_VIRTIO_USER - if (hw->bus_type == VIRTIO_BUS_USER) - VTPCI_OPS(hw) = &virtio_user_ops; - else -#endif - if (hw->bus_type == VIRTIO_BUS_PCI_MODERN) - VTPCI_OPS(hw) = &modern_ops; - else if (hw->bus_type == VIRTIO_BUS_PCI_LEGACY) - VTPCI_OPS(hw) = &legacy_ops; - - return; -} - /* * This function is based on probe() function in virtio_pci.c * It returns 0 on success. @@ -1840,7 +1823,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) eth_dev->rx_descriptor_done = virtio_dev_rx_queue_done; if (rte_eal_process_type() == RTE_PROC_SECONDARY) { - virtio_set_vtpci_ops(hw); set_rxtx_funcs(eth_dev); return 0; } diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 41571522df..90631d1a2d 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -809,7 +809,6 @@ vtpci_init(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev) if (virtio_read_caps(pci_dev, hw) == 0) { PMD_INIT_LOG(INFO, "modern virtio pci detected."); virtio_hw_internal[hw->port_id].vtpci_ops = &modern_ops; - hw->bus_type = VIRTIO_BUS_PCI_MODERN; dev->modern = true; goto msix_detect; } @@ -829,7 +828,6 @@ vtpci_init(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev) } virtio_hw_internal[hw->port_id].vtpci_ops = &legacy_ops; - hw->bus_type = VIRTIO_BUS_PCI_LEGACY; dev->modern = false; msix_detect: diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index ce43b40330..b6c44a7f7c 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -246,15 +246,7 @@ struct virtio_pci_ops { struct virtio_net_config; -enum virtio_bus_type { - VIRTIO_BUS_UNKNOWN, - VIRTIO_BUS_PCI_LEGACY, - VIRTIO_BUS_PCI_MODERN, - VIRTIO_BUS_USER, -}; - struct virtio_hw { - enum virtio_bus_type bus_type; struct virtnet_ctl *cvq; uint64_t req_guest_features; uint64_t guest_features; diff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c index 076a5dbced..8cc6561914 100644 --- a/drivers/net/virtio/virtio_pci_ethdev.c +++ b/drivers/net/virtio/virtio_pci_ethdev.c @@ -84,6 +84,11 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev) return -1; } } else { + if (dev->modern) + VTPCI_OPS(hw) = &modern_ops; + else + VTPCI_OPS(hw) = &legacy_ops; + ret = virtio_remap_pci(RTE_ETH_DEV_TO_PCI(eth_dev), dev); if (ret < 0) { PMD_INIT_LOG(ERR, "Failed to remap PCI device\n"); @@ -105,7 +110,7 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev) err_unmap: rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev)); - if (hw->bus_type == VIRTIO_BUS_PCI_LEGACY) + if (!dev->modern) rte_pci_ioport_unmap(VTPCI_IO(hw)); return ret; diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index bf958de571..61880a8e02 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -641,7 +641,6 @@ virtio_user_eth_dev_alloc(struct rte_vdev_device *vdev) * Here just pretend that we support msix. */ hw->use_msix = 1; - hw->bus_type = VIRTIO_BUS_USER; hw->use_vec_rx = 0; hw->use_vec_tx = 0; hw->use_inorder_rx = 0; @@ -691,6 +690,10 @@ virtio_user_pmd_probe(struct rte_vdev_device *vdev) return -1; } + dev = eth_dev->data->dev_private; + hw = &dev->hw; + VTPCI_OPS(hw) = &virtio_user_ops; + if (eth_virtio_dev_init(eth_dev) < 0) { PMD_INIT_LOG(ERR, "eth_virtio_dev_init fails"); rte_eth_dev_release_port(eth_dev);