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 A72DEA052A; Tue, 26 Jan 2021 11:19:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0302C141381; Tue, 26 Jan 2021 11:17:43 +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 CE371141377 for ; Tue, 26 Jan 2021 11:17:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611656259; 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=q+WD12NO4AuQs/APzBOKnQU6rYF61OErdaNyIYwbEs0=; b=bHCz5EVphM1S+MDr+ogYib1comFN3r2iQvJuakKD1gNO4qgDLRxoLtcvPP0H1vUPT2/MPZ EjTWXrQqHDGQuDTzsM+sIjoHPFu+lUrQcnSmLP971COSNZrVh8++IJt5Js7lXHtWUeUuFB Wx5sUzSEEqx4b8iWZXNMDPnbrnRkeWQ= 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-515-mZXaXnZLOGWQFcVwgkRwLA-1; Tue, 26 Jan 2021 05:17:37 -0500 X-MC-Unique: mZXaXnZLOGWQFcVwgkRwLA-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 0DDE5107ACE3; Tue, 26 Jan 2021 10:17:36 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A23D6F45C; Tue, 26 Jan 2021 10:17:34 +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, 26 Jan 2021 11:16:12 +0100 Message-Id: <20210126101639.250481-18-maxime.coquelin@redhat.com> In-Reply-To: <20210126101639.250481-1-maxime.coquelin@redhat.com> References: <20210126101639.250481-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 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-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v4 17/44] net/virtio: move legacy IO to Virtio PCI 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" This patch moves Virtio PCI legacy IO handling to virtio_pci.c. Two functions are created so that virtio_pci_ethdev does not have to care about it. Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia Reviewed-by: David Marchand --- drivers/net/virtio/virtio_pci.c | 28 ++++++++++++++++++++++++-- drivers/net/virtio/virtio_pci.h | 9 +++------ drivers/net/virtio/virtio_pci_ethdev.c | 6 ++---- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index b347e5fbc0..3fe0631a30 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -31,6 +31,15 @@ #define VIRTIO_PCI_CONFIG(hw) \ (((hw)->use_msix == VIRTIO_MSIX_ENABLED) ? 24 : 20) + +struct virtio_pci_internal { + struct rte_pci_ioport io; +}; + +#define VTPCI_IO(hw) (&virtio_pci_internal[(hw)->port_id].io) + +struct virtio_pci_internal virtio_pci_internal[RTE_MAX_ETHPORTS]; + static inline int check_vq_phys_addr_ok(struct virtqueue *vq) { @@ -300,7 +309,9 @@ legacy_notify_queue(struct virtio_hw *hw, struct virtqueue *vq) static void legacy_intr_detect(struct virtio_hw *hw) { - hw->use_msix = vtpci_msix_detect(VTPCI_DEV(hw)); + struct virtio_pci_dev *dev = virtio_pci_get_dev(hw); + + hw->use_msix = vtpci_msix_detect(dev->pci_dev); } static int @@ -558,7 +569,9 @@ modern_notify_queue(struct virtio_hw *hw, struct virtqueue *vq) static void modern_intr_detect(struct virtio_hw *hw) { - hw->use_msix = vtpci_msix_detect(VTPCI_DEV(hw)); + struct virtio_pci_dev *dev = virtio_pci_get_dev(hw); + + hw->use_msix = vtpci_msix_detect(dev->pci_dev); } static int @@ -857,3 +870,14 @@ vtpci_init(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev) return 0; } +void vtpci_legacy_ioport_unmap(struct virtio_hw *hw) +{ + rte_pci_ioport_unmap(VTPCI_IO(hw)); +} + +int vtpci_legacy_ioport_map(struct virtio_hw *hw) +{ + struct virtio_pci_dev *dev = virtio_pci_get_dev(hw); + + return rte_pci_ioport_map(dev->pci_dev, 0, VTPCI_IO(hw)); +} diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index 15f8144fc6..def8faca72 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -298,18 +298,12 @@ struct virtio_pci_dev { */ struct virtio_hw_internal { const struct virtio_pci_ops *vtpci_ops; - struct rte_pci_ioport io; - struct rte_pci_device *dev; }; #define VTPCI_OPS(hw) (virtio_hw_internal[(hw)->port_id].vtpci_ops) -#define VTPCI_IO(hw) (&virtio_hw_internal[(hw)->port_id].io) -#define VTPCI_DEV(hw) (virtio_hw_internal[(hw)->port_id].dev) - extern struct virtio_hw_internal virtio_hw_internal[RTE_MAX_ETHPORTS]; - /* * This structure is just a reference to read * net device specific config space; it just a chodu structure @@ -382,6 +376,9 @@ void vtpci_read_dev_config(struct virtio_hw *, size_t, void *, int); uint8_t vtpci_isr(struct virtio_hw *); +void vtpci_legacy_ioport_unmap(struct virtio_hw *hw); +int vtpci_legacy_ioport_map(struct virtio_hw *hw); + extern const struct virtio_pci_ops legacy_ops; extern const struct virtio_pci_ops modern_ops; extern const struct virtio_pci_ops virtio_user_ops; diff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c index 8cc6561914..9fe59feb51 100644 --- a/drivers/net/virtio/virtio_pci_ethdev.c +++ b/drivers/net/virtio/virtio_pci_ethdev.c @@ -60,7 +60,7 @@ virtio_remap_pci(struct rte_pci_device *pci_dev, struct virtio_pci_dev *dev) return -1; } } else { - if (rte_pci_ioport_map(pci_dev, 0, VTPCI_IO(hw)) < 0) + if (vtpci_legacy_ioport_map(hw) < 0) return -1; } @@ -75,8 +75,6 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev) struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); int ret; - VTPCI_DEV(hw) = pci_dev; - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { ret = vtpci_init(RTE_ETH_DEV_TO_PCI(eth_dev), dev); if (ret) { @@ -111,7 +109,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 (!dev->modern) - rte_pci_ioport_unmap(VTPCI_IO(hw)); + vtpci_legacy_ioport_unmap(hw); return ret; } -- 2.29.2