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 D6212A0A05; Tue, 19 Jan 2021 22:26:46 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1D0D7140E39; Tue, 19 Jan 2021 22:26:13 +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 A221E140E0A for ; Tue, 19 Jan 2021 22:26:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611091571; 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=yeJHTwrJuCqIoXgEdXqmu+fROiDt33qIPEWwyWEkEFI=; b=KejZDqX8mqT9OuJyC3hwckqsDnY8xclcLnLyxWdWzxsZ3necH8QaAu476gdcJ45aCWI9pA UJPDWGS18hvmJVd93Jsp8BgHjnYsqc0RzmUbAWcCXnBv4d3sBMnzpdW7MG+qBm1LuRcF0f FW6EtCLANA78B2C7TBU/EWR9Oq7yGwU= 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-59-roE2Bds3Pm6Deh8CmB_m6g-1; Tue, 19 Jan 2021 16:26:07 -0500 X-MC-Unique: roE2Bds3Pm6Deh8CmB_m6g-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 CF67610054FF; Tue, 19 Jan 2021 21:26:05 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id E86F15D9DD; Tue, 19 Jan 2021 21:25:57 +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:29 +0100 Message-Id: <20210119212507.1043636-7-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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v2 06/44] net/virtio: introduce PCI device metadata 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 initiate refactoring of Virtio PCI, by introducing a new device structure for PCI-specific metadata. Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- drivers/net/virtio/virtio_ethdev.c | 2 +- drivers/net/virtio/virtio_pci.c | 2 ++ drivers/net/virtio/virtio_pci.h | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index c8a01a46df..aafba15ac2 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -2154,7 +2154,7 @@ static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, if (vdpa == 1) return 1; - return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_hw), + return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct virtio_pci_dev), eth_virtio_dev_init); } diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 1692268f30..345d73f868 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -689,6 +689,8 @@ virtio_read_caps(struct rte_pci_device *dev, struct virtio_hw *hw) int vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw) { + RTE_BUILD_BUG_ON(offsetof(struct virtio_pci_dev, hw) != 0); + /* * Try if we can succeed reading virtio pci caps, which exists * only on modern pci device. If failed, we fallback to legacy diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index b35a596169..59f6688218 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -289,6 +289,11 @@ struct virtio_hw { struct virtqueue **vqs; }; +struct virtio_pci_dev { + struct virtio_hw hw; +}; + +#define virtio_pci_get_dev(hwp) container_of(hwp, struct virtio_pci_dev, hw) /* * While virtio_hw is stored in shared memory, this structure stores -- 2.29.2