From patchwork Tue Jun 28 14:46:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113514 X-Patchwork-Delegate: thomas@monjalon.net 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 119AEA056B; Tue, 28 Jun 2022 16:47:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2843410EC; Tue, 28 Jun 2022 16:47:01 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 98C6B410EC for ; Tue, 28 Jun 2022 16:47:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427620; 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=oZnz32hBTAj7hsvvZzLpaMdPXuO6eyeuYQzz/vxnesc=; b=Stos7A8ZMS08smA28xorzsIAT9qtNubw+jmSCkzXKnaDjuqxdbGsHwYxcTXkvxWs1aIZma OdfX5qwqnyk/IWs1VOIVBHvSMNCoMhILmp2b3ps5aI1N9Ubd4L2hVTLRCGEkwDFOwqhvtB Cl9d/cc4I+9wBwEwraXwN7OjjNUrmP4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-477-Gz7MiLYRPj-nRdz6m-AobQ-1; Tue, 28 Jun 2022 10:46:54 -0400 X-MC-Unique: Gz7MiLYRPj-nRdz6m-AobQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 691F038173CD; Tue, 28 Jun 2022 14:46:54 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F8542166B26; Tue, 28 Jun 2022 14:46:53 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Matan Azrad , Viacheslav Ovsiienko Subject: [RFC PATCH 01/11] common/mlx5: rework check on driver registration Date: Tue, 28 Jun 2022 16:46:33 +0200 Message-Id: <20220628144643.1213026-2-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Rely on a local flag rather than dereference a bus object. This will help next commits. Signed-off-by: David Marchand --- drivers/common/mlx5/linux/mlx5_common_auxiliary.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_common_auxiliary.c b/drivers/common/mlx5/linux/mlx5_common_auxiliary.c index 6584aeb18e..a182a8bdde 100644 --- a/drivers/common/mlx5/linux/mlx5_common_auxiliary.c +++ b/drivers/common/mlx5/linux/mlx5_common_auxiliary.c @@ -179,14 +179,20 @@ static struct rte_auxiliary_driver mlx5_auxiliary_driver = { .dma_unmap = mlx5_common_auxiliary_dma_unmap, }; +static bool mlx5_common_auxiliary_initialized; + void mlx5_common_auxiliary_init(void) { - if (mlx5_auxiliary_driver.bus == NULL) + if (!mlx5_common_auxiliary_initialized) { rte_auxiliary_register(&mlx5_auxiliary_driver); + mlx5_common_auxiliary_initialized = true; + } } RTE_FINI(mlx5_common_auxiliary_driver_finish) { - if (mlx5_auxiliary_driver.bus != NULL) + if (mlx5_common_auxiliary_initialized) { rte_auxiliary_unregister(&mlx5_auxiliary_driver); + mlx5_common_auxiliary_initialized = false; + } } From patchwork Tue Jun 28 14:46:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113515 X-Patchwork-Delegate: thomas@monjalon.net 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 558B2A056B; Tue, 28 Jun 2022 16:47:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 45F25427EA; Tue, 28 Jun 2022 16:47:06 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id BC68040042 for ; Tue, 28 Jun 2022 16:47:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427624; 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=lzRO+UecPTi/JypXF54fDDq5/xh60vu2UXWk157d1Kg=; b=T+k9uzEWAS6+hIhjJIU95qTRzg6NrpVTscB8AN9UxTHWn2jjhaR+Osh7DzcabK8tZt8wcs p2a86iXhx5eIy7sVy9HiZ9BwmrM7ynhNHpThpc1YECzCiB45rvkVG20CmF0MPliyJoT4mb ft7SyN9X887g8NbK/RuLoqJftyImPoU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-616-QIywzyrNMqy8yp74zJ7JYg-1; Tue, 28 Jun 2022 10:46:59 -0400 X-MC-Unique: QIywzyrNMqy8yp74zJ7JYg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2CA323C1619C; Tue, 28 Jun 2022 14:46:58 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAB162166B26; Tue, 28 Jun 2022 14:46:56 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Rosen Xu , Tianfei zhang , Ray Kinsella Subject: [RFC PATCH 02/11] raw/ifpga: remove PCI bus accessor Date: Tue, 28 Jun 2022 16:46:34 +0200 Message-Id: <20220628144643.1213026-3-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 There is no in-tree user for this accessor that returns the PCI bus object. On the other hand, a bus object can be retrieved by name using rte_bus_find_by_name. We can remove driver specific API. Signed-off-by: David Marchand --- drivers/raw/ifpga/ifpga_rawdev.c | 7 +------ drivers/raw/ifpga/ifpga_rawdev.h | 1 - drivers/raw/ifpga/rte_pmd_ifpga.c | 6 ------ drivers/raw/ifpga/rte_pmd_ifpga.h | 10 ---------- drivers/raw/ifpga/version.map | 1 - 5 files changed, 1 insertion(+), 24 deletions(-) diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c index 8c05302a65..78a7123528 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.c +++ b/drivers/raw/ifpga/ifpga_rawdev.c @@ -10,8 +10,8 @@ #include #include #include + #include -#include #include #include #include @@ -1888,11 +1888,6 @@ RTE_PMD_REGISTER_PARAM_STRING(ifpga_rawdev_cfg, "port= " "afu_bts="); -struct rte_pci_bus *ifpga_get_pci_bus(void) -{ - return rte_ifpga_rawdev_pmd.bus; -} - int ifpga_rawdev_partial_reconfigure(struct rte_rawdev *dev, int port, const char *file) { diff --git a/drivers/raw/ifpga/ifpga_rawdev.h b/drivers/raw/ifpga/ifpga_rawdev.h index 4c191190ca..0fb66cbaae 100644 --- a/drivers/raw/ifpga/ifpga_rawdev.h +++ b/drivers/raw/ifpga/ifpga_rawdev.h @@ -91,7 +91,6 @@ int ifpga_unregister_msix_irq(struct ifpga_rawdev *dev, enum ifpga_irq_type type, int vec_start, rte_intr_callback_fn handler, void *arg); -struct rte_pci_bus *ifpga_get_pci_bus(void); int ifpga_rawdev_partial_reconfigure(struct rte_rawdev *dev, int port, const char *file); void ifpga_rawdev_cleanup(void); diff --git a/drivers/raw/ifpga/rte_pmd_ifpga.c b/drivers/raw/ifpga/rte_pmd_ifpga.c index 23146432c2..1ca248123b 100644 --- a/drivers/raw/ifpga/rte_pmd_ifpga.c +++ b/drivers/raw/ifpga/rte_pmd_ifpga.c @@ -402,12 +402,6 @@ rte_pmd_ifpga_reload(uint16_t dev_id, int type, int page) return opae_mgr_reload(adapter->mgr, type, page); } -const struct rte_pci_bus * -rte_pmd_ifpga_get_pci_bus(void) -{ - return ifpga_get_pci_bus(); -} - int rte_pmd_ifpga_partial_reconfigure(uint16_t dev_id, int port, const char *file) { diff --git a/drivers/raw/ifpga/rte_pmd_ifpga.h b/drivers/raw/ifpga/rte_pmd_ifpga.h index 3fa5d3435a..791543f2cd 100644 --- a/drivers/raw/ifpga/rte_pmd_ifpga.h +++ b/drivers/raw/ifpga/rte_pmd_ifpga.h @@ -220,16 +220,6 @@ rte_pmd_ifpga_reboot_try(uint16_t dev_id); int rte_pmd_ifpga_reload(uint16_t dev_id, int type, int page); -/** - * Get PCI bus the Intel FPGA driver register to - * - * @return - * - (valid pointer) if successful. - * - (NULL) if the Intel FPGA driver is not registered to any PCI bus. - */ -const struct rte_pci_bus * -rte_pmd_ifpga_get_pci_bus(void); - /** * Perform PR (partial reconfiguration) on specified Intel FPGA device * diff --git a/drivers/raw/ifpga/version.map b/drivers/raw/ifpga/version.map index ff71a453e2..340d8eb3c7 100644 --- a/drivers/raw/ifpga/version.map +++ b/drivers/raw/ifpga/version.map @@ -10,7 +10,6 @@ DPDK_22 { rte_pmd_ifpga_stop_update; rte_pmd_ifpga_reboot_try; rte_pmd_ifpga_reload; - rte_pmd_ifpga_get_pci_bus; rte_pmd_ifpga_partial_reconfigure; rte_pmd_ifpga_cleanup; From patchwork Tue Jun 28 14:46:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113516 X-Patchwork-Delegate: thomas@monjalon.net 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 AB3CFA056B; Tue, 28 Jun 2022 16:47:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4B6104282F; Tue, 28 Jun 2022 16:47:08 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id DB72A40042 for ; Tue, 28 Jun 2022 16:47:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427625; 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=TvL2FvONbGdRl6xF+cEyaeGAHWCIrxMbeJhp9MTRuKg=; b=MCFtqUwdvKPs3pKzkFimcC4Jooa68QoqTEstkaI5iG0KpldJoHHC6hoXimLiWWy3BrSwie /C/O/+8Nex4WNgZFaxB6A6hW7mZeDNSP4np/83Pl/SoVbRall8GeXVIqALtQDLCci+t6w2 N9jhNwCo9tWSROXo1dCErr/MZl8WP7M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-4QhI-ViAMsSFyLOrwfX3dw-1; Tue, 28 Jun 2022 10:47:01 -0400 X-MC-Unique: 4QhI-ViAMsSFyLOrwfX3dw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7EFD41019C86; Tue, 28 Jun 2022 14:47:01 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 479682166B26; Tue, 28 Jun 2022 14:47:00 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Aman Singh , Yuying Zhang Subject: [RFC PATCH 03/11] dev: hide debug messages in device iterator Date: Tue, 28 Jun 2022 16:46:35 +0200 Message-Id: <20220628144643.1213026-4-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 For any bus that does not support device iteration, rte_dev_iterator_init both returned an error code and logged an error message. An application (like testpmd) that only wants to list devices, would have no choice but to inspect a bus object to avoid spewing error logs. Make those log messages debug level, and remove the check in testpmd. Signed-off-by: David Marchand --- app/test-pmd/config.c | 4 ---- lib/eal/common/eal_common_dev.c | 7 +++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 62833fe97c..82db14f3a6 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -612,10 +612,6 @@ device_infos_display(const char *identifier) if (identifier && da.bus != next) continue; - /* Skip buses that don't have iterate method */ - if (!next->dev_iterate) - continue; - snprintf(devstr, sizeof(devstr), "bus=%s", next->name); RTE_DEV_FOREACH(dev, devstr, &dev_iter) { diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c index 9d913e5478..b6f0392f30 100644 --- a/lib/eal/common/eal_common_dev.c +++ b/lib/eal/common/eal_common_dev.c @@ -592,18 +592,17 @@ rte_dev_iterator_init(struct rte_dev_iterator *it, * one layer specified. */ if (bus == NULL && cls == NULL) { - RTE_LOG(ERR, EAL, - "Either bus or class must be specified.\n"); + RTE_LOG(DEBUG, EAL, "Either bus or class must be specified.\n"); rte_errno = EINVAL; goto get_out; } if (bus != NULL && bus->dev_iterate == NULL) { - RTE_LOG(ERR, EAL, "Bus %s not supported\n", bus->name); + RTE_LOG(DEBUG, EAL, "Bus %s not supported\n", bus->name); rte_errno = ENOTSUP; goto get_out; } if (cls != NULL && cls->dev_iterate == NULL) { - RTE_LOG(ERR, EAL, "Class %s not supported\n", cls->name); + RTE_LOG(DEBUG, EAL, "Class %s not supported\n", cls->name); rte_errno = ENOTSUP; goto get_out; } From patchwork Tue Jun 28 14:46:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113517 X-Patchwork-Delegate: thomas@monjalon.net 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 845B6A056B; Tue, 28 Jun 2022 16:47:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A877242B70; Tue, 28 Jun 2022 16:47:14 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id DF29D4114B for ; Tue, 28 Jun 2022 16:47:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427632; 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=ZSlB2o/4c+KkoLWai79f4FEflpg4Au/jBm2ceHIntz8=; b=IxKvOJcoKRXZrkg3koNjxQB3VScsaKHKuVRrtfe3sC4SBosPgQUDGBO0O91JFsM/CXtQX7 BAjuvC3yMe8UhuuNJ8N5BNOOclUHzac03Guso76laoRfhH5yKVeJEu6HtuJGaBeHWbwRVO f38yS/MvzcId82zhuA0BH2Fz6owI8tM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-NuZTDrnkO2Sy3wqpMIHbWQ-1; Tue, 28 Jun 2022 10:47:08 -0400 X-MC-Unique: NuZTDrnkO2Sy3wqpMIHbWQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F87A185A7BA; Tue, 28 Jun 2022 14:47:07 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFD6A2166B26; Tue, 28 Jun 2022 14:47:03 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Fan Zhang , Ashish Gupta , Qiming Yang , Wenjun Wu , Shijith Thotton , Srisivasubramanian Srinivasan , Chengwen Feng , Ferruh Yigit , Andrew Rybchenko , Olivier Matz , Ori Kam , Akhil Goyal , Maxime Coquelin , Chenbo Xia Subject: [RFC PATCH 04/11] dev: move unrelated macros from header Date: Tue, 28 Jun 2022 16:46:36 +0200 Message-Id: <20220628144643.1213026-5-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 RTE_FUNC_PTR_OR_* macros have nothing to do with the rte_device object and associated API. Move them to rte_common.h and include it where needed. Signed-off-by: David Marchand --- drivers/common/qat/qat_device.c | 1 + drivers/compress/qat/qat_comp_pmd.c | 1 + drivers/crypto/scheduler/rte_cryptodev_scheduler.c | 1 + drivers/net/ixgbe/rte_pmd_ixgbe.c | 1 + drivers/net/liquidio/lio_ethdev.c | 1 + lib/compressdev/rte_compressdev.c | 1 + lib/dmadev/rte_dmadev.c | 1 + lib/eal/include/rte_common.h | 11 +++++++++++ lib/eal/include/rte_dev.h | 11 ----------- lib/ethdev/ethdev_driver.c | 1 + lib/ethdev/ethdev_pci.h | 1 + lib/mempool/rte_mempool_ops.c | 1 + lib/regexdev/rte_regexdev.c | 1 + lib/security/rte_security.c | 1 + lib/vhost/vdpa.c | 1 + 15 files changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/common/qat/qat_device.c b/drivers/common/qat/qat_device.c index db4b087d2b..6583cf0554 100644 --- a/drivers/common/qat/qat_device.c +++ b/drivers/common/qat/qat_device.c @@ -2,6 +2,7 @@ * Copyright(c) 2018-2022 Intel Corporation */ +#include #include #include #include diff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c index dc8db84a68..e4cac159be 100644 --- a/drivers/compress/qat/qat_comp_pmd.c +++ b/drivers/compress/qat/qat_comp_pmd.c @@ -2,6 +2,7 @@ * Copyright(c) 2015-2022 Intel Corporation */ +#include #include #include "qat_comp.h" diff --git a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c index 1e0c4fe464..88c9b21cd8 100644 --- a/drivers/crypto/scheduler/rte_cryptodev_scheduler.c +++ b/drivers/crypto/scheduler/rte_cryptodev_scheduler.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2017 Intel Corporation */ +#include #include #include #include diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.c b/drivers/net/ixgbe/rte_pmd_ixgbe.c index 9729f8575f..8ae4d9b39a 100644 --- a/drivers/net/ixgbe/rte_pmd_ixgbe.c +++ b/drivers/net/ixgbe/rte_pmd_ixgbe.c @@ -2,6 +2,7 @@ * Copyright(c) 2010-2017 Intel Corporation */ +#include #include #include "base/ixgbe_api.h" diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 90ffe31b9f..ccbd0ff849 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -2,6 +2,7 @@ * Copyright(c) 2017 Cavium, Inc */ +#include #include #include #include diff --git a/lib/compressdev/rte_compressdev.c b/lib/compressdev/rte_compressdev.c index 22c438f2dd..12469042f7 100644 --- a/lib/compressdev/rte_compressdev.c +++ b/lib/compressdev/rte_compressdev.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include diff --git a/lib/dmadev/rte_dmadev.c b/lib/dmadev/rte_dmadev.c index 174d4c40ae..e199b888c8 100644 --- a/lib/dmadev/rte_dmadev.c +++ b/lib/dmadev/rte_dmadev.c @@ -5,6 +5,7 @@ #include +#include #include #include #include diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h index a96cc2a138..1617b5ed14 100644 --- a/lib/eal/include/rte_common.h +++ b/lib/eal/include/rte_common.h @@ -861,6 +861,17 @@ rte_log2_u64(uint64_t v) /** Number of elements in the array. */ #define RTE_DIM(a) (sizeof (a) / sizeof ((a)[0])) +/* Macros to check for invalid function pointers */ +#define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \ + if ((func) == NULL) \ + return retval; \ +} while (0) + +#define RTE_FUNC_PTR_OR_RET(func) do { \ + if ((func) == NULL) \ + return; \ +} while (0) + /** * Converts a numeric string to the equivalent uint64_t value. * As well as straight number conversion, also recognises the suffixes diff --git a/lib/eal/include/rte_dev.h b/lib/eal/include/rte_dev.h index e6ff1218f9..24f9122558 100644 --- a/lib/eal/include/rte_dev.h +++ b/lib/eal/include/rte_dev.h @@ -36,17 +36,6 @@ typedef void (*rte_dev_event_cb_fn)(const char *device_name, enum rte_dev_event_type event, void *cb_arg); -/* Macros to check for invalid function pointers */ -#define RTE_FUNC_PTR_OR_ERR_RET(func, retval) do { \ - if ((func) == NULL) \ - return retval; \ -} while (0) - -#define RTE_FUNC_PTR_OR_RET(func) do { \ - if ((func) == NULL) \ - return; \ -} while (0) - /** * Device policies. */ diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c index a285f213f0..86f5a37874 100644 --- a/lib/ethdev/ethdev_driver.c +++ b/lib/ethdev/ethdev_driver.c @@ -2,6 +2,7 @@ * Copyright(c) 2022 Intel Corporation */ +#include #include #include diff --git a/lib/ethdev/ethdev_pci.h b/lib/ethdev/ethdev_pci.h index 0549842709..b4bb460dcb 100644 --- a/lib/ethdev/ethdev_pci.h +++ b/lib/ethdev/ethdev_pci.h @@ -10,6 +10,7 @@ extern "C" { #endif +#include #include #include #include diff --git a/lib/mempool/rte_mempool_ops.c b/lib/mempool/rte_mempool_ops.c index 2d36dee8f0..d60235a7e3 100644 --- a/lib/mempool/rte_mempool_ops.c +++ b/lib/mempool/rte_mempool_ops.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include diff --git a/lib/regexdev/rte_regexdev.c b/lib/regexdev/rte_regexdev.c index 02a388bc5d..aa57ab5bfa 100644 --- a/lib/regexdev/rte_regexdev.c +++ b/lib/regexdev/rte_regexdev.c @@ -5,6 +5,7 @@ #include +#include #include #include diff --git a/lib/security/rte_security.c b/lib/security/rte_security.c index 4f5e4b4d49..046b6496d2 100644 --- a/lib/security/rte_security.c +++ b/lib/security/rte_security.c @@ -4,6 +4,7 @@ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved */ +#include #include #include #include diff --git a/lib/vhost/vdpa.c b/lib/vhost/vdpa.c index 8fa2153023..3597fe897d 100644 --- a/lib/vhost/vdpa.c +++ b/lib/vhost/vdpa.c @@ -10,6 +10,7 @@ #include +#include #include #include #include From patchwork Tue Jun 28 14:46:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113518 X-Patchwork-Delegate: thomas@monjalon.net 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 F3083A056B; Tue, 28 Jun 2022 16:47:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BAA2D4282E; Tue, 28 Jun 2022 16:47:17 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 59EB140143 for ; Tue, 28 Jun 2022 16:47:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427633; 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=caxZxclDBJux+v8CvicA4hEE6So1gL+Mp1mBIeiBB0w=; b=UrlLmN5Usunm6EQtandPosdCJTYoM6MsE8eFkc8BDeQ2NnTddd6wWpEadhvB4xDrShDlT3 fp6QvbZr5RHlPh/zsUCmKX+1Agb9Ckz0hDGQg6fRw6diRROn4/UVx8SlA48+iuHxpwTvsk T5/VEPgQwnwK36bgiJMPwhXrT+6t2D4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-262-MUwd4yo7NAWVafDM2uFBLA-1; Tue, 28 Jun 2022 10:47:10 -0400 X-MC-Unique: MUwd4yo7NAWVafDM2uFBLA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 716E6803478; Tue, 28 Jun 2022 14:47:10 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F3E62166B26; Tue, 28 Jun 2022 14:47:09 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com Subject: [RFC PATCH 05/11] devargs: remove dependency on bus header Date: Tue, 28 Jun 2022 16:46:37 +0200 Message-Id: <20220628144643.1213026-6-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 We don't need to include rte_bus.h. Only a forward declaration of rte_bus and an inclusion of rte_dev.h are needed. Signed-off-by: David Marchand --- app/test/test_vdev.c | 1 + lib/eal/include/rte_devargs.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/test/test_vdev.c b/app/test/test_vdev.c index 720722c363..5eeff3106d 100644 --- a/app/test/test_vdev.c +++ b/app/test/test_vdev.c @@ -8,6 +8,7 @@ #include #include +#include #include #include "test.h" diff --git a/lib/eal/include/rte_devargs.h b/lib/eal/include/rte_devargs.h index 37a0f042ab..38dee2f288 100644 --- a/lib/eal/include/rte_devargs.h +++ b/lib/eal/include/rte_devargs.h @@ -22,7 +22,9 @@ extern "C" { #include #include -#include +#include + +struct rte_bus; /** * Bus type key in global devargs syntax. From patchwork Tue Jun 28 14:46:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113519 X-Patchwork-Delegate: thomas@monjalon.net 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 30732A056B; Tue, 28 Jun 2022 16:47:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0AE7342B6C; Tue, 28 Jun 2022 16:47:23 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 5FC2F4069F for ; Tue, 28 Jun 2022 16:47:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427640; 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=HxL6S1jZ3VF60JX8U5w2ia+/RGpmtv9iZxcUWtv4Hug=; b=WO4dZSkm0eSfmqrizBFt/uoud04JmjU0ZcTC6HYGKBxwfDuFhs+QPK/CSPNzmQtBoWhOo6 3e8liS0IPbwb5osatC0DVoeeqMZQuMY3mog1TvSuLHVJB60bPgthzNGQ2PVqQlB2cVkJUf 2h3WkIE5gE81cwarFssqECq+Vw7g9pw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-81-0qMuZRu9PaKZTxSquJ1Iyw-1; Tue, 28 Jun 2022 10:47:15 -0400 X-MC-Unique: 0qMuZRu9PaKZTxSquJ1Iyw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1FFEE29DD9A2; Tue, 28 Jun 2022 14:47:15 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id F29522166B26; Tue, 28 Jun 2022 14:47:12 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Parav Pandit , Xueming Li , Rosen Xu , Stephen Hemminger , Long Li , Jay Zhou , Radha Mohan Chintakuntla , Veerasenareddy Burru Subject: [RFC PATCH 06/11] bus: remove unneeded inclusion of bus header Date: Tue, 28 Jun 2022 16:46:38 +0200 Message-Id: <20220628144643.1213026-7-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Those files don't need to include rte_bus.h. Signed-off-by: David Marchand --- drivers/bus/auxiliary/linux/auxiliary.c | 1 - drivers/bus/ifpga/ifpga_common.c | 1 - drivers/bus/ifpga/rte_bus_ifpga.h | 1 - drivers/bus/vdev/vdev_params.c | 1 - drivers/bus/vmbus/linux/vmbus_uio.c | 1 - drivers/bus/vmbus/vmbus_bufring.c | 1 - drivers/bus/vmbus/vmbus_channel.c | 1 - drivers/bus/vmbus/vmbus_common_uio.c | 1 - drivers/crypto/virtio/virtio_pci.c | 1 - drivers/dma/cnxk/cnxk_dmadev.c | 1 - 10 files changed, 10 deletions(-) diff --git a/drivers/bus/auxiliary/linux/auxiliary.c b/drivers/bus/auxiliary/linux/auxiliary.c index 9bd4ee3295..28092e31c4 100644 --- a/drivers/bus/auxiliary/linux/auxiliary.c +++ b/drivers/bus/auxiliary/linux/auxiliary.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include diff --git a/drivers/bus/ifpga/ifpga_common.c b/drivers/bus/ifpga/ifpga_common.c index 78e2eaee4e..223660d6ff 100644 --- a/drivers/bus/ifpga/ifpga_common.c +++ b/drivers/bus/ifpga/ifpga_common.c @@ -14,7 +14,6 @@ #include #include -#include #include #include #include diff --git a/drivers/bus/ifpga/rte_bus_ifpga.h b/drivers/bus/ifpga/rte_bus_ifpga.h index 007ad19875..682d565891 100644 --- a/drivers/bus/ifpga/rte_bus_ifpga.h +++ b/drivers/bus/ifpga/rte_bus_ifpga.h @@ -15,7 +15,6 @@ extern "C" { #endif /* __cplusplus */ -#include #include #include #include diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c index 3969faf16d..2c72614776 100644 --- a/drivers/bus/vdev/vdev_params.c +++ b/drivers/bus/vdev/vdev_params.c @@ -5,7 +5,6 @@ #include #include -#include #include #include diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index 5db70f8e0d..26edef342d 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -13,7 +13,6 @@ #include #include -#include #include #include #include diff --git a/drivers/bus/vmbus/vmbus_bufring.c b/drivers/bus/vmbus/vmbus_bufring.c index c4aa07b307..c78619dc44 100644 --- a/drivers/bus/vmbus/vmbus_bufring.c +++ b/drivers/bus/vmbus/vmbus_bufring.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/bus/vmbus/vmbus_channel.c b/drivers/bus/vmbus/vmbus_channel.c index 119b9b367e..8d9f32270e 100644 --- a/drivers/bus/vmbus/vmbus_channel.c +++ b/drivers/bus/vmbus/vmbus_channel.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/bus/vmbus/vmbus_common_uio.c b/drivers/bus/vmbus/vmbus_common_uio.c index 882a24f869..4d4613513c 100644 --- a/drivers/bus/vmbus/vmbus_common_uio.c +++ b/drivers/bus/vmbus/vmbus_common_uio.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include "private.h" diff --git a/drivers/crypto/virtio/virtio_pci.c b/drivers/crypto/virtio/virtio_pci.c index ae069794a6..95a43c8801 100644 --- a/drivers/crypto/virtio/virtio_pci.c +++ b/drivers/crypto/virtio/virtio_pci.c @@ -10,7 +10,6 @@ #endif #include -#include #include "virtio_pci.h" #include "virtqueue.h" diff --git a/drivers/dma/cnxk/cnxk_dmadev.c b/drivers/dma/cnxk/cnxk_dmadev.c index 2824c1b44f..3e8c15d617 100644 --- a/drivers/dma/cnxk/cnxk_dmadev.c +++ b/drivers/dma/cnxk/cnxk_dmadev.c @@ -5,7 +5,6 @@ #include #include -#include #include #include #include From patchwork Tue Jun 28 14:46:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113520 X-Patchwork-Delegate: thomas@monjalon.net 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 19930A056B; Tue, 28 Jun 2022 16:47:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15B7842B78; Tue, 28 Jun 2022 16:47:27 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id C566442B76 for ; Tue, 28 Jun 2022 16:47:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427644; 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=+t3zyoAVyulm+oxGToIbp8mQkmVKr9Yx8cVuvMe/ENg=; b=bDhFYWlDI0RS3n4KGfYg70mXRnPuEn/x7NQSgOxAwy5Pp8hsVGyOsNwrC5qrUO4EjhcwyY HAysO3TSr9NJQlPE5y1g+h6YvChZ+Zys0k61R+LMLJeVt3IvwN2lenXGGceRMswf5acu0X 7FUMmZg063Lohbf628oNadYYKpDUdx4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-214-90GHeqsBNVy4Tu6dH2vf4g-1; Tue, 28 Jun 2022 10:47:21 -0400 X-MC-Unique: 90GHeqsBNVy4Tu6dH2vf4g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E2AB38173CD; Tue, 28 Jun 2022 14:47:20 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id D41912166B26; Tue, 28 Jun 2022 14:47:16 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Stephen Hemminger , Long Li , Sunila Sahu , Fan Zhang , Ashish Gupta , Gaetan Rivet , Anatoly Burakov , Akhil Goyal , Dmitry Kozlyuk , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam , Ferruh Yigit , Andrew Rybchenko , Reshma Pattan Subject: [RFC PATCH 07/11] bus: move IOVA definition from header Date: Tue, 28 Jun 2022 16:46:39 +0200 Message-Id: <20220628144643.1213026-8-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 iova enum definition does not need to be defined as part of the bus API. Move it to rte_eal.h. With this step, rte_eal.h does not depend on rte_bus.h and rte_dev.h. Fix existing code that was relying on these implicit inclusions. Signed-off-by: David Marchand --- app/test-compress-perf/comp_perf_options.h | 2 ++ drivers/bus/vmbus/rte_bus_vmbus.h | 1 + drivers/compress/zlib/zlib_pmd_ops.c | 1 + drivers/net/failsafe/failsafe.c | 1 + drivers/net/failsafe/failsafe_eal.c | 1 + examples/multi_process/hotplug_mp/commands.c | 2 ++ lib/compressdev/rte_compressdev.c | 1 + lib/compressdev/rte_compressdev_pmd.c | 1 + lib/cryptodev/cryptodev_pmd.c | 2 ++ lib/eal/common/eal_thread.h | 1 + lib/eal/common/hotplug_mp.c | 1 + lib/eal/include/rte_bus.h | 18 ++---------------- lib/eal/include/rte_eal.h | 15 ++++++++++++++- lib/eal/include/rte_lcore.h | 2 ++ lib/eal/windows/eal.c | 1 + lib/ethdev/rte_ethdev.c | 1 + lib/pcapng/rte_pcapng.c | 1 + 17 files changed, 35 insertions(+), 17 deletions(-) diff --git a/app/test-compress-perf/comp_perf_options.h b/app/test-compress-perf/comp_perf_options.h index 0b777521c5..57dd146330 100644 --- a/app/test-compress-perf/comp_perf_options.h +++ b/app/test-compress-perf/comp_perf_options.h @@ -5,6 +5,8 @@ #ifndef _COMP_PERF_OPS_ #define _COMP_PERF_OPS_ +#include + #define MAX_LIST 32 #define MIN_COMPRESSED_BUF_SIZE 8 #define EXPANSE_RATIO 1.1 diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h index a24bad831d..4421326fe8 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -23,6 +23,7 @@ extern "C" { #include #include +#include #include #include #include diff --git a/drivers/compress/zlib/zlib_pmd_ops.c b/drivers/compress/zlib/zlib_pmd_ops.c index 0a73aed949..7d657d81bc 100644 --- a/drivers/compress/zlib/zlib_pmd_ops.c +++ b/drivers/compress/zlib/zlib_pmd_ops.c @@ -4,6 +4,7 @@ #include +#include #include #include diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index 05cf533896..3eb7d32b76 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "failsafe_private.h" diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c index cb4a2abc02..130344dce2 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -3,6 +3,7 @@ * Copyright 2017 Mellanox Technologies, Ltd */ +#include #include #include diff --git a/examples/multi_process/hotplug_mp/commands.c b/examples/multi_process/hotplug_mp/commands.c index 41ea265e45..da8b5e5924 100644 --- a/examples/multi_process/hotplug_mp/commands.c +++ b/examples/multi_process/hotplug_mp/commands.c @@ -8,6 +8,8 @@ #include #include #include + +#include #include /**********************************************************/ diff --git a/lib/compressdev/rte_compressdev.c b/lib/compressdev/rte_compressdev.c index 12469042f7..7f6dedbc52 100644 --- a/lib/compressdev/rte_compressdev.c +++ b/lib/compressdev/rte_compressdev.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/lib/compressdev/rte_compressdev_pmd.c b/lib/compressdev/rte_compressdev_pmd.c index 7f500d76d4..9bfae077db 100644 --- a/lib/compressdev/rte_compressdev_pmd.c +++ b/lib/compressdev/rte_compressdev_pmd.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "rte_compressdev_internal.h" diff --git a/lib/cryptodev/cryptodev_pmd.c b/lib/cryptodev/cryptodev_pmd.c index 1903ade388..75d0075b86 100644 --- a/lib/cryptodev/cryptodev_pmd.c +++ b/lib/cryptodev/cryptodev_pmd.c @@ -3,6 +3,8 @@ */ #include + +#include #include #include #include diff --git a/lib/eal/common/eal_thread.h b/lib/eal/common/eal_thread.h index ca3378d463..e0240ccc60 100644 --- a/lib/eal/common/eal_thread.h +++ b/lib/eal/common/eal_thread.h @@ -5,6 +5,7 @@ #ifndef EAL_THREAD_H #define EAL_THREAD_H +#include #include /** diff --git a/lib/eal/common/hotplug_mp.c b/lib/eal/common/hotplug_mp.c index bde0de196e..1614a57752 100644 --- a/lib/eal/common/hotplug_mp.c +++ b/lib/eal/common/hotplug_mp.c @@ -3,6 +3,7 @@ */ #include +#include #include #include #include diff --git a/lib/eal/include/rte_bus.h b/lib/eal/include/rte_bus.h index bbbb6efd28..17edaa37c9 100644 --- a/lib/eal/include/rte_bus.h +++ b/lib/eal/include/rte_bus.h @@ -20,27 +20,13 @@ extern "C" { #include -#include #include +#include +#include /** Double linked list of buses */ RTE_TAILQ_HEAD(rte_bus_list, rte_bus); - -/** - * IOVA mapping mode. - * - * IOVA mapping mode is iommu programming mode of a device. - * That device (for example: IOMMU backed DMA device) based - * on rte_iova_mode will generate physical or virtual address. - * - */ -enum rte_iova_mode { - RTE_IOVA_DC = 0, /* Don't care mode */ - RTE_IOVA_PA = (1 << 0), /* DMA using physical address */ - RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */ -}; - /** * Bus specific scan for devices attached on the bus. * For each bus object, the scan would be responsible for finding devices and diff --git a/lib/eal/include/rte_eal.h b/lib/eal/include/rte_eal.h index 5dfc50e987..fd3d7c1da8 100644 --- a/lib/eal/include/rte_eal.h +++ b/lib/eal/include/rte_eal.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -458,6 +457,20 @@ static inline int rte_gettid(void) __rte_internal uint64_t rte_eal_get_baseaddr(void); +/** + * IOVA mapping mode. + * + * IOVA mapping mode is iommu programming mode of a device. + * That device (for example: IOMMU backed DMA device) based + * on rte_iova_mode will generate physical or virtual address. + * + */ +enum rte_iova_mode { + RTE_IOVA_DC = 0, /* Don't care mode */ + RTE_IOVA_PA = (1 << 0), /* DMA using physical address */ + RTE_IOVA_VA = (1 << 1) /* DMA using virtual address */ +}; + /** * Get the iova mode * diff --git a/lib/eal/include/rte_lcore.h b/lib/eal/include/rte_lcore.h index b598e1b9ec..4d3978512c 100644 --- a/lib/eal/include/rte_lcore.h +++ b/lib/eal/include/rte_lcore.h @@ -11,6 +11,8 @@ * API for lcore and socket manipulation * */ +#include + #include #include #include diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index 122de2a319..79322d2ce9 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 1979dc0850..ebbe8cca3d 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index 06ad712bd1..5b079cd14a 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include From patchwork Tue Jun 28 14:46:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113521 X-Patchwork-Delegate: thomas@monjalon.net 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 781B5A056B; Tue, 28 Jun 2022 16:47:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 796BE42B77; Tue, 28 Jun 2022 16:47:33 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id B9EC242B77 for ; Tue, 28 Jun 2022 16:47:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427652; 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=rhc0/8qLqXVlJzGx8L8kRxEbyN8tbI6zEnyjV5G3BYs=; b=gWA1EIaojIZlV5/G1GqN+qOUI/AW+7oKqJDAtPUGcpmSSAfX21D84oVWRVjhUpQORe/5Cb +m+ELpWV98dcD1I+yRp6qHZvON9QKr6JiEw47H2EUIYwj5kKUqPPsVV5v8RSLa3t413IJk EwN2MVgfoOEzKjIK+ogddZLgUNZCSVw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-457-5xvNciRFMmab_raPuAoxwQ-1; Tue, 28 Jun 2022 10:47:29 -0400 X-MC-Unique: 5xvNciRFMmab_raPuAoxwQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 42CD31C006DD; Tue, 28 Jun 2022 14:47:24 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B2152166B26; Tue, 28 Jun 2022 14:47:22 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Parav Pandit , Xueming Li , Hemant Agrawal , Sachin Saxena , Stephen Hemminger , Long Li Subject: [RFC PATCH 08/11] drivers/bus: remove back reference to bus objects Date: Tue, 28 Jun 2022 16:46:40 +0200 Message-Id: <20220628144643.1213026-9-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 There is no need for a back reference to a singleton object in the bus driver objects: each function is contextually aware of which bus object it should manipulate. Signed-off-by: David Marchand --- drivers/bus/auxiliary/auxiliary_common.c | 2 -- drivers/bus/auxiliary/rte_bus_auxiliary.h | 2 -- drivers/bus/dpaa/dpaa_bus.c | 10 +--------- drivers/bus/dpaa/rte_dpaa_bus.h | 1 - drivers/bus/fslmc/fslmc_bus.c | 10 +--------- drivers/bus/fslmc/rte_fslmc.h | 1 - drivers/bus/pci/pci_common.c | 2 -- drivers/bus/pci/rte_bus_pci.h | 1 - drivers/bus/vmbus/rte_bus_vmbus.h | 2 -- drivers/bus/vmbus/vmbus_common.c | 2 -- 10 files changed, 2 insertions(+), 31 deletions(-) diff --git a/drivers/bus/auxiliary/auxiliary_common.c b/drivers/bus/auxiliary/auxiliary_common.c index 2cf8fe672d..0b212f2d64 100644 --- a/drivers/bus/auxiliary/auxiliary_common.c +++ b/drivers/bus/auxiliary/auxiliary_common.c @@ -259,7 +259,6 @@ void rte_auxiliary_register(struct rte_auxiliary_driver *driver) { TAILQ_INSERT_TAIL(&auxiliary_bus.driver_list, driver, next); - driver->bus = &auxiliary_bus; } /* Unregister a driver */ @@ -267,7 +266,6 @@ void rte_auxiliary_unregister(struct rte_auxiliary_driver *driver) { TAILQ_REMOVE(&auxiliary_bus.driver_list, driver, next); - driver->bus = NULL; } /* Add a device to auxiliary bus */ diff --git a/drivers/bus/auxiliary/rte_bus_auxiliary.h b/drivers/bus/auxiliary/rte_bus_auxiliary.h index 93b266daf7..b19696e5e6 100644 --- a/drivers/bus/auxiliary/rte_bus_auxiliary.h +++ b/drivers/bus/auxiliary/rte_bus_auxiliary.h @@ -32,7 +32,6 @@ extern "C" { /* Forward declarations */ struct rte_auxiliary_driver; -struct rte_auxiliary_bus; struct rte_auxiliary_device; /** @@ -125,7 +124,6 @@ struct rte_auxiliary_device { struct rte_auxiliary_driver { RTE_TAILQ_ENTRY(rte_auxiliary_driver) next; /**< Next in list. */ struct rte_driver driver; /**< Inherit core driver. */ - struct rte_auxiliary_bus *bus; /**< Auxiliary bus reference. */ rte_auxiliary_match_t *match; /**< Device match function. */ rte_auxiliary_probe_t *probe; /**< Device probe function. */ rte_auxiliary_remove_t *remove; /**< Device remove function. */ diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index e442bc4c33..2c286d5817 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -520,23 +520,15 @@ rte_dpaa_driver_register(struct rte_dpaa_driver *driver) BUS_INIT_FUNC_TRACE(); TAILQ_INSERT_TAIL(&rte_dpaa_bus.driver_list, driver, next); - /* Update Bus references */ - driver->dpaa_bus = &rte_dpaa_bus; } /* un-register a dpaa bus based dpaa driver */ void rte_dpaa_driver_unregister(struct rte_dpaa_driver *driver) { - struct rte_dpaa_bus *dpaa_bus; - BUS_INIT_FUNC_TRACE(); - dpaa_bus = driver->dpaa_bus; - - TAILQ_REMOVE(&dpaa_bus->driver_list, driver, next); - /* Update Bus references */ - driver->dpaa_bus = NULL; + TAILQ_REMOVE(&rte_dpaa_bus.driver_list, driver, next); } static int diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index 1f04d9ebd3..5e8f32dfbf 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -119,7 +119,6 @@ typedef int (*rte_dpaa_remove_t)(struct rte_dpaa_device *dpaa_dev); struct rte_dpaa_driver { TAILQ_ENTRY(rte_dpaa_driver) next; struct rte_driver driver; - struct rte_dpaa_bus *dpaa_bus; enum rte_dpaa_type drv_type; rte_dpaa_probe_t probe; rte_dpaa_remove_t remove; diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index e9edc27e0a..f112d2afeb 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -530,27 +530,19 @@ rte_fslmc_driver_register(struct rte_dpaa2_driver *driver) RTE_VERIFY(driver); TAILQ_INSERT_TAIL(&rte_fslmc_bus.driver_list, driver, next); - /* Update Bus references */ - driver->fslmc_bus = &rte_fslmc_bus; } /*un-register a fslmc bus based dpaa2 driver */ void rte_fslmc_driver_unregister(struct rte_dpaa2_driver *driver) { - struct rte_fslmc_bus *fslmc_bus; - - fslmc_bus = driver->fslmc_bus; - /* Cleanup the PA->VA Translation table; From wherever this function * is called from. */ if (rte_eal_iova_mode() == RTE_IOVA_PA) dpaax_iova_table_depopulate(); - TAILQ_REMOVE(&fslmc_bus->driver_list, driver, next); - /* Update Bus references */ - driver->fslmc_bus = NULL; + TAILQ_REMOVE(&rte_fslmc_bus.driver_list, driver, next); } /* diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h index 8c67bfba55..9c3791635c 100644 --- a/drivers/bus/fslmc/rte_fslmc.h +++ b/drivers/bus/fslmc/rte_fslmc.h @@ -146,7 +146,6 @@ typedef int (*rte_dpaa2_remove_t)(struct rte_dpaa2_device *dpaa2_dev); struct rte_dpaa2_driver { TAILQ_ENTRY(rte_dpaa2_driver) next; /**< Next in list. */ struct rte_driver driver; /**< Inherit core driver. */ - struct rte_fslmc_bus *fslmc_bus; /**< FSLMC bus reference */ uint32_t drv_flags; /**< Flags for controlling device.*/ enum rte_dpaa2_dev_type drv_type; /**< Driver Type */ rte_dpaa2_probe_t probe; diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 37ab879779..0d61d49287 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -443,7 +443,6 @@ void rte_pci_register(struct rte_pci_driver *driver) { TAILQ_INSERT_TAIL(&rte_pci_bus.driver_list, driver, next); - driver->bus = &rte_pci_bus; } /* unregister a driver */ @@ -451,7 +450,6 @@ void rte_pci_unregister(struct rte_pci_driver *driver) { TAILQ_REMOVE(&rte_pci_bus.driver_list, driver, next); - driver->bus = NULL; } /* Add a device to PCI bus */ diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h index 1c6a8fdd7b..1913bc111c 100644 --- a/drivers/bus/pci/rte_bus_pci.h +++ b/drivers/bus/pci/rte_bus_pci.h @@ -161,7 +161,6 @@ typedef int (pci_dma_unmap_t)(struct rte_pci_device *dev, void *addr, struct rte_pci_driver { RTE_TAILQ_ENTRY(rte_pci_driver) next; /**< Next in list. */ struct rte_driver driver; /**< Inherit core driver. */ - struct rte_pci_bus *bus; /**< PCI bus reference. */ rte_pci_probe_t *probe; /**< Device probe function. */ rte_pci_remove_t *remove; /**< Device remove function. */ pci_dma_map_t *dma_map; /**< device dma map function. */ diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h index 4421326fe8..8d6ba26028 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -34,7 +34,6 @@ extern "C" { /* Forward declarations */ struct rte_vmbus_device; struct rte_vmbus_driver; -struct rte_vmbus_bus; struct vmbus_channel; struct vmbus_mon_page; @@ -95,7 +94,6 @@ typedef int (vmbus_remove_t)(struct rte_vmbus_device *); struct rte_vmbus_driver { RTE_TAILQ_ENTRY(rte_vmbus_driver) next; /**< Next in list. */ struct rte_driver driver; - struct rte_vmbus_bus *bus; /**< VM bus reference. */ vmbus_probe_t *probe; /**< Device Probe function. */ vmbus_remove_t *remove; /**< Device Remove function. */ diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c index 367727367e..0f2d878126 100644 --- a/drivers/bus/vmbus/vmbus_common.c +++ b/drivers/bus/vmbus/vmbus_common.c @@ -235,7 +235,6 @@ rte_vmbus_register(struct rte_vmbus_driver *driver) "Registered driver %s", driver->driver.name); TAILQ_INSERT_TAIL(&rte_vmbus_bus.driver_list, driver, next); - driver->bus = &rte_vmbus_bus; } /* unregister vmbus driver */ @@ -243,7 +242,6 @@ void rte_vmbus_unregister(struct rte_vmbus_driver *driver) { TAILQ_REMOVE(&rte_vmbus_bus.driver_list, driver, next); - driver->bus = NULL; } /* Add a device to VMBUS bus */ From patchwork Tue Jun 28 14:46:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113522 X-Patchwork-Delegate: thomas@monjalon.net 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 6D463A056B; Tue, 28 Jun 2022 16:47:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AAC4642B80; Tue, 28 Jun 2022 16:47:35 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id C7A03400D7 for ; Tue, 28 Jun 2022 16:47:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427654; 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=oo1He/e7sIGXpP0RsqctS0aFbvAGzS4Mt1zFrxdqLmk=; b=h14l+dC0JyOGca05chhL1We53qQlWDjl34xL0WOsA9Q9rqWqkt4GUbDoofARB4lLSgf59M RHc1ITu+TL4QhLNJrkf/wb19LoILYfifL/JASk9q2B9UUGXcaC/ir794XGT7wAOeH11nix xOV4iCQRsvAKFbzmy5RYf5k7Vxto32c= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-436-luC3LpH8M2WZt78pjpx-xA-1; Tue, 28 Jun 2022 10:47:31 -0400 X-MC-Unique: luC3LpH8M2WZt78pjpx-xA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38666382C968; Tue, 28 Jun 2022 14:47:30 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id E26412166B26; Tue, 28 Jun 2022 14:47:26 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Aman Singh , Yuying Zhang , Parav Pandit , Xueming Li , Hemant Agrawal , Sachin Saxena , Stephen Hemminger , Long Li , Matan Azrad , Viacheslav Ovsiienko , Chas Williams , "Min Hu (Connor)" , Cristian Dumitrescu Subject: [RFC PATCH 09/11] drivers/bus: hide specific structures Date: Tue, 28 Jun 2022 16:46:41 +0200 Message-Id: <20220628144643.1213026-10-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Now that there is no bus specific object referenced in the driver objects, we can hide rte_dpaa_bus, rte_fslmc_bus, rte_pci_bus, rte_vmbus_bus specific structures into their bus code. While at it: - move enumerators only used in the bus code itself, - remove unneeded list head structure type, - reorder the definitions and macro manipulating the bus singleton object, - remove inclusion of rte_bus.h and update code that relied on it, Signed-off-by: David Marchand --- app/test-pmd/testpmd.h | 1 + app/test/test_kni.c | 1 + drivers/bus/auxiliary/private.h | 30 +++++++++++------------ drivers/bus/auxiliary/rte_bus_auxiliary.h | 3 --- drivers/bus/dpaa/dpaa_bus.c | 8 ++++++ drivers/bus/dpaa/rte_dpaa_bus.h | 13 ---------- drivers/bus/fslmc/fslmc_bus.c | 1 + drivers/bus/fslmc/fslmc_vfio.c | 2 +- drivers/bus/fslmc/portal/dpaa2_hw_dprc.c | 1 + drivers/bus/fslmc/private.h | 27 ++++++++++++++++++++ drivers/bus/fslmc/rte_fslmc.h | 20 --------------- drivers/bus/pci/bsd/pci.c | 2 -- drivers/bus/pci/linux/pci.c | 3 --- drivers/bus/pci/private.h | 18 +++++++++++++- drivers/bus/pci/rte_bus_pci.h | 22 ----------------- drivers/bus/pci/windows/pci.c | 1 + drivers/bus/pci/windows/pci_netuio.c | 1 + drivers/bus/vmbus/private.h | 18 ++++++++++++++ drivers/bus/vmbus/rte_bus_vmbus.h | 20 --------------- drivers/bus/vmbus/vmbus_common.c | 1 - drivers/common/mlx5/mlx5_common_pci.c | 1 + drivers/net/bonding/rte_eth_bond_args.c | 1 + drivers/net/mlx5/linux/mlx5_os.c | 1 + drivers/net/netvsc/hn_ethdev.c | 1 + examples/ethtool/lib/rte_ethtool.c | 1 + examples/ip_pipeline/kni.c | 1 + 26 files changed, 98 insertions(+), 101 deletions(-) create mode 100644 drivers/bus/fslmc/private.h diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index eeefb5e70f..34bdccef71 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -8,6 +8,7 @@ #include #include +#include #include #ifdef RTE_LIB_GRO #include diff --git a/app/test/test_kni.c b/app/test/test_kni.c index 622315c8b1..9d76b6253e 100644 --- a/app/test/test_kni.c +++ b/app/test/test_kni.c @@ -25,6 +25,7 @@ test_kni(void) #include #include #include +#include #include #include #include diff --git a/drivers/bus/auxiliary/private.h b/drivers/bus/auxiliary/private.h index d22e83cf7a..06a920114c 100644 --- a/drivers/bus/auxiliary/private.h +++ b/drivers/bus/auxiliary/private.h @@ -9,9 +9,10 @@ #include #include +#include + #include "rte_bus_auxiliary.h" -extern struct rte_auxiliary_bus auxiliary_bus; extern int auxiliary_bus_logtype; #define AUXILIARY_LOG(level, ...) \ @@ -19,27 +20,26 @@ extern int auxiliary_bus_logtype; RTE_FMT("auxiliary bus: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ RTE_FMT_TAIL(__VA_ARGS__,))) -/* Auxiliary bus iterators */ -#define FOREACH_DEVICE_ON_AUXILIARY_BUS(p) \ - TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next) - -#define FOREACH_DRIVER_ON_AUXILIARY_BUS(p) \ - TAILQ_FOREACH(p, &(auxiliary_bus.driver_list), next) - -/* List of auxiliary devices. */ -TAILQ_HEAD(rte_auxiliary_device_list, rte_auxiliary_device); -/* List of auxiliary drivers. */ -TAILQ_HEAD(rte_auxiliary_driver_list, rte_auxiliary_driver); - /* * Structure describing the auxiliary bus */ struct rte_auxiliary_bus { struct rte_bus bus; /* Inherit the generic class */ - struct rte_auxiliary_device_list device_list; /* List of devices */ - struct rte_auxiliary_driver_list driver_list; /* List of drivers */ + TAILQ_HEAD(, rte_auxiliary_device) device_list; /* List of devices */ + TAILQ_HEAD(, rte_auxiliary_driver) driver_list; /* List of drivers */ }; +#define RTE_BUS_AUXILIARY_NAME "auxiliary" + +extern struct rte_auxiliary_bus auxiliary_bus; + +/* Auxiliary bus iterators */ +#define FOREACH_DEVICE_ON_AUXILIARY_BUS(p) \ + TAILQ_FOREACH(p, &(auxiliary_bus.device_list), next) + +#define FOREACH_DRIVER_ON_AUXILIARY_BUS(p) \ + TAILQ_FOREACH(p, &(auxiliary_bus.driver_list), next) + /* * Test whether the auxiliary device exist. */ diff --git a/drivers/bus/auxiliary/rte_bus_auxiliary.h b/drivers/bus/auxiliary/rte_bus_auxiliary.h index b19696e5e6..23eefe2360 100644 --- a/drivers/bus/auxiliary/rte_bus_auxiliary.h +++ b/drivers/bus/auxiliary/rte_bus_auxiliary.h @@ -25,11 +25,8 @@ extern "C" { #include #include #include -#include #include -#define RTE_BUS_AUXILIARY_NAME "auxiliary" - /* Forward declarations */ struct rte_auxiliary_driver; struct rte_auxiliary_device; diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index 2c286d5817..ad4ea156a6 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -43,6 +43,14 @@ #include #include +struct rte_dpaa_bus { + struct rte_bus bus; + TAILQ_HEAD(, rte_dpaa_device) device_list; + TAILQ_HEAD(, rte_dpaa_driver) driver_list; + int device_count; + int detected; +}; + static struct rte_dpaa_bus rte_dpaa_bus; struct netcfg_info *dpaa_netcfg; diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h index 5e8f32dfbf..69c759c68b 100644 --- a/drivers/bus/dpaa/rte_dpaa_bus.h +++ b/drivers/bus/dpaa/rte_dpaa_bus.h @@ -6,7 +6,6 @@ #ifndef __RTE_DPAA_BUS_H__ #define __RTE_DPAA_BUS_H__ -#include #include #include #include @@ -73,24 +72,12 @@ extern unsigned int dpaa_svr_family; struct rte_dpaa_device; struct rte_dpaa_driver; -/* DPAA Device and Driver lists for DPAA bus */ -TAILQ_HEAD(rte_dpaa_device_list, rte_dpaa_device); -TAILQ_HEAD(rte_dpaa_driver_list, rte_dpaa_driver); - enum rte_dpaa_type { FSL_DPAA_ETH = 1, FSL_DPAA_CRYPTO, FSL_DPAA_QDMA }; -struct rte_dpaa_bus { - struct rte_bus bus; - struct rte_dpaa_device_list device_list; - struct rte_dpaa_driver_list driver_list; - int device_count; - int detected; -}; - struct dpaa_device_id { uint8_t fman_id; /**< Fman interface ID, for ETH type device */ uint8_t mac_id; /**< Fman MAC interface ID, for ETH type device */ diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index f112d2afeb..8498f5321a 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -16,6 +16,7 @@ #include #include +#include "private.h" #include #include #include "fslmc_logs.h" diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index 3d4e71a80a..b172c84d52 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -29,9 +29,9 @@ #include #include #include -#include #include +#include "private.h" #include "rte_fslmc.h" #include "fslmc_vfio.h" #include "fslmc_logs.h" diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c b/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c index ca1d0304d5..28780717bd 100644 --- a/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c +++ b/drivers/bus/fslmc/portal/dpaa2_hw_dprc.c @@ -12,6 +12,7 @@ #include #include +#include "private.h" #include #include #include diff --git a/drivers/bus/fslmc/private.h b/drivers/bus/fslmc/private.h new file mode 100644 index 0000000000..80d4673ca8 --- /dev/null +++ b/drivers/bus/fslmc/private.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2016,2021 NXP + */ + +#ifndef __PRIVATE_H__ +#define __PRIVATE_H__ + +#include + +#include + +/* + * FSLMC bus + */ +struct rte_fslmc_bus { + struct rte_bus bus; /**< Generic Bus object */ + TAILQ_HEAD(, rte_dpaa2_device) device_list; + /**< FSLMC DPAA2 Device list */ + TAILQ_HEAD(, rte_dpaa2_driver) driver_list; + /**< FSLMC DPAA2 Driver list */ + int device_count[DPAA2_DEVTYPE_MAX]; + /**< Count of all devices scanned */ +}; + +extern struct rte_fslmc_bus rte_fslmc_bus; + +#endif /* __PRIVATE_H__ */ diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h index 9c3791635c..6bdee86aaf 100644 --- a/drivers/bus/fslmc/rte_fslmc.h +++ b/drivers/bus/fslmc/rte_fslmc.h @@ -29,7 +29,6 @@ extern "C" { #include #include #include -#include #include #include #include @@ -69,15 +68,9 @@ dpaa2_seqn(struct rte_mbuf *mbuf) struct rte_dpaa2_driver; -/* DPAA2 Device and Driver lists for FSLMC bus */ -TAILQ_HEAD(rte_fslmc_device_list, rte_dpaa2_device); -TAILQ_HEAD(rte_fslmc_driver_list, rte_dpaa2_driver); - #define RTE_DEV_TO_FSLMC_CONST(ptr) \ container_of(ptr, const struct rte_dpaa2_device, device) -extern struct rte_fslmc_bus rte_fslmc_bus; - enum rte_dpaa2_dev_type { /* Devices backed by DPDK driver */ DPAA2_ETH, /**< DPNI type device*/ @@ -152,19 +145,6 @@ struct rte_dpaa2_driver { rte_dpaa2_remove_t remove; }; -/* - * FSLMC bus - */ -struct rte_fslmc_bus { - struct rte_bus bus; /**< Generic Bus object */ - struct rte_fslmc_device_list device_list; - /**< FSLMC DPAA2 Device list */ - struct rte_fslmc_driver_list driver_list; - /**< FSLMC DPAA2 Driver list */ - int device_count[DPAA2_DEVTYPE_MAX]; - /**< Count of all devices scanned */ -}; - /** * Register a DPAA2 driver. * diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c index 9a11f99ae3..bcd772427b 100644 --- a/drivers/bus/pci/bsd/pci.c +++ b/drivers/bus/pci/bsd/pci.c @@ -48,8 +48,6 @@ * PCI probing under BSD. */ -extern struct rte_pci_bus rte_pci_bus; - /* Map pci device */ int rte_pci_map_device(struct rte_pci_device *dev) diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index e521459870..fa5d5e131d 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -24,8 +23,6 @@ * PCI probing using Linux sysfs. */ -extern struct rte_pci_bus rte_pci_bus; - static int pci_get_kernel_driver_by_path(const char *filename, char *dri_name, size_t len) diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index 0fbef8e1d8..6ccec15655 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -8,12 +8,28 @@ #include #include -#include +#include #include #include +/** + * Structure describing the PCI bus + */ +struct rte_pci_bus { + struct rte_bus bus; /**< Inherit the generic class */ + RTE_TAILQ_HEAD(, rte_pci_device) device_list; /**< List of PCI devices */ + RTE_TAILQ_HEAD(, rte_pci_driver) driver_list; /**< List of PCI drivers */ +}; + extern struct rte_pci_bus rte_pci_bus; +/* PCI Bus iterators */ +#define FOREACH_DEVICE_ON_PCIBUS(p) \ + RTE_TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next) + +#define FOREACH_DRIVER_ON_PCIBUS(p) \ + RTE_TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next) + struct rte_pci_driver; struct rte_pci_device; diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h index 1913bc111c..01d834e3cc 100644 --- a/drivers/bus/pci/rte_bus_pci.h +++ b/drivers/bus/pci/rte_bus_pci.h @@ -25,7 +25,6 @@ extern "C" { #include #include #include -#include #include /** Pathname of PCI devices directory. */ @@ -35,18 +34,6 @@ const char *rte_pci_get_sysfs_path(void); struct rte_pci_device; struct rte_pci_driver; -/** List of PCI devices */ -RTE_TAILQ_HEAD(rte_pci_device_list, rte_pci_device); -/** List of PCI drivers */ -RTE_TAILQ_HEAD(rte_pci_driver_list, rte_pci_driver); - -/* PCI Bus iterators */ -#define FOREACH_DEVICE_ON_PCIBUS(p) \ - RTE_TAILQ_FOREACH(p, &(rte_pci_bus.device_list), next) - -#define FOREACH_DRIVER_ON_PCIBUS(p) \ - RTE_TAILQ_FOREACH(p, &(rte_pci_bus.driver_list), next) - struct rte_devargs; enum rte_pci_kernel_driver { @@ -169,15 +156,6 @@ struct rte_pci_driver { uint32_t drv_flags; /**< Flags RTE_PCI_DRV_*. */ }; -/** - * Structure describing the PCI bus - */ -struct rte_pci_bus { - struct rte_bus bus; /**< Inherit the generic class */ - struct rte_pci_device_list device_list; /**< List of PCI devices */ - struct rte_pci_driver_list driver_list; /**< List of PCI drivers */ -}; - /** Device needs PCI BAR mapping (done with either IGB_UIO or VFIO) */ #define RTE_PCI_DRV_NEED_MAPPING 0x0001 /** Device needs PCI BAR mapping with enabled write combining (wc) */ diff --git a/drivers/bus/pci/windows/pci.c b/drivers/bus/pci/windows/pci.c index 7bf091158b..f013b743b3 100644 --- a/drivers/bus/pci/windows/pci.c +++ b/drivers/bus/pci/windows/pci.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "private.h" #include "pci_netuio.h" diff --git a/drivers/bus/pci/windows/pci_netuio.c b/drivers/bus/pci/windows/pci_netuio.c index 5460399eea..314bbcf547 100644 --- a/drivers/bus/pci/windows/pci_netuio.c +++ b/drivers/bus/pci/windows/pci_netuio.c @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef __MINGW32__ #include diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h index 1bca147e12..732cb6d583 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -8,13 +8,31 @@ #include #include + +#include #include #include #include #include +/** + * Structure describing the VM bus + */ +struct rte_vmbus_bus { + struct rte_bus bus; /**< Inherit the generic class */ + RTE_TAILQ_HEAD(, rte_vmbus_device) device_list; /**< List of devices */ + RTE_TAILQ_HEAD(, rte_vmbus_driver) driver_list; /**< List of drivers */ +}; + extern struct rte_vmbus_bus rte_vmbus_bus; +/* VMBus iterators */ +#define FOREACH_DEVICE_ON_VMBUS(p) \ + RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.device_list), next) + +#define FOREACH_DRIVER_ON_VMBUS(p) \ + RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.driver_list), next) + extern int vmbus_logtype_bus; #define VMBUS_LOG(level, fmt, args...) \ rte_log(RTE_LOG_ ## level, vmbus_logtype_bus, "%s(): " fmt "\n", \ diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h index 8d6ba26028..763c077623 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -23,7 +23,6 @@ extern "C" { #include #include -#include #include #include #include @@ -37,16 +36,6 @@ struct rte_vmbus_driver; struct vmbus_channel; struct vmbus_mon_page; -RTE_TAILQ_HEAD(rte_vmbus_device_list, rte_vmbus_device); -RTE_TAILQ_HEAD(rte_vmbus_driver_list, rte_vmbus_driver); - -/* VMBus iterators */ -#define FOREACH_DEVICE_ON_VMBUS(p) \ - RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.device_list), next) - -#define FOREACH_DRIVER_ON_VMBUS(p) \ - RTE_TAILQ_FOREACH(p, &(rte_vmbus_bus.driver_list), next) - /** Maximum number of VMBUS resources. */ enum hv_uio_map { HV_TXRX_RING_MAP = 0, @@ -101,15 +90,6 @@ struct rte_vmbus_driver { }; -/** - * Structure describing the VM bus - */ -struct rte_vmbus_bus { - struct rte_bus bus; /**< Inherit the generic class */ - struct rte_vmbus_device_list device_list; /**< List of devices */ - struct rte_vmbus_driver_list driver_list; /**< List of drivers */ -}; - /** * Scan the content of the VMBUS bus, and the devices in the devices * list diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c index 0f2d878126..03b39c82b7 100644 --- a/drivers/bus/vmbus/vmbus_common.c +++ b/drivers/bus/vmbus/vmbus_common.c @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index 66626953f1..e708e23a7f 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "mlx5_common_log.h" diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c index 5406e1c934..b90757756a 100644 --- a/drivers/net/bonding/rte_eth_bond_args.c +++ b/drivers/net/bonding/rte_eth_bond_args.c @@ -4,6 +4,7 @@ #include #include +#include #include #include diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 0741028dab..04b9614f5c 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 0a357d3645..93ee4a6e86 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c index ffaad96498..62f6de84d5 100644 --- a/examples/ethtool/lib/rte_ethtool.c +++ b/examples/ethtool/lib/rte_ethtool.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #ifdef RTE_NET_IXGBE #include diff --git a/examples/ip_pipeline/kni.c b/examples/ip_pipeline/kni.c index a2d3331cb0..270b961bba 100644 --- a/examples/ip_pipeline/kni.c +++ b/examples/ip_pipeline/kni.c @@ -6,6 +6,7 @@ #include #include +#include #include #include From patchwork Tue Jun 28 14:46:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113523 X-Patchwork-Delegate: thomas@monjalon.net 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 07145A056B; Tue, 28 Jun 2022 16:47:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 55CCE40691; Tue, 28 Jun 2022 16:47:44 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 9105F40143 for ; Tue, 28 Jun 2022 16:47:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427662; 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=dUv1Mjc22VG1yyDGw8MozwWLmuDMmKxWRxtJstqJpKw=; b=dUNBRHQLbsQLq7G2/uUTn0RFQCpn6OG/QY/W9V9FiYu/xpfkpFyBmZaDiNcGnoPsF3+c0X f+jOxVRTxGoS0DLyT3M2qwsAjqUn167YVqNu/aAOubwcwcBlHeVOO0G5UpkpVD/0VNo9/9 b80nZy9D4cckkrx4RYGP7zoYZEnBtbA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-649-xpyw_1PoPkyMl5K72RbWOA-1; Tue, 28 Jun 2022 10:47:36 -0400 X-MC-Unique: xpyw_1PoPkyMl5K72RbWOA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D367811E7A; Tue, 28 Jun 2022 14:47:35 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D29F2166B26; Tue, 28 Jun 2022 14:47:32 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Aman Singh , Yuying Zhang , Matan Azrad , Viacheslav Ovsiienko , Gaetan Rivet , Stephen Hemminger , Long Li , Cristian Dumitrescu , Anatoly Burakov , Ray Kinsella , Ferruh Yigit , Andrew Rybchenko , Reshma Pattan Subject: [RFC PATCH 10/11] bus: introduce accessors Date: Tue, 28 Jun 2022 16:46:42 +0200 Message-Id: <20220628144643.1213026-11-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Prepare for making the bus object opaque by adding one accessor. Update existing users. Signed-off-by: David Marchand --- app/test-pmd/config.c | 6 ++--- app/test-pmd/testpmd.c | 4 +-- app/test-pmd/testpmd.h | 4 +-- app/test/test_devargs.c | 4 +-- app/test/test_kni.c | 6 ++--- drivers/common/mlx5/mlx5_common_pci.c | 2 +- drivers/net/failsafe/failsafe.c | 2 +- drivers/net/failsafe/failsafe_eal.c | 2 +- drivers/net/mlx5/linux/mlx5_os.c | 2 +- drivers/net/netvsc/hn_ethdev.c | 4 +-- examples/ethtool/lib/rte_ethtool.c | 3 ++- examples/ip_pipeline/kni.c | 2 +- examples/multi_process/hotplug_mp/commands.c | 4 +-- lib/eal/common/eal_common_bus.c | 26 ++++++++++++-------- lib/eal/common/eal_common_dev.c | 8 +++--- lib/eal/common/eal_common_devargs.c | 12 ++++----- lib/eal/common/hotplug_mp.c | 8 +++--- lib/eal/include/rte_bus.h | 13 ++++++++++ lib/eal/version.map | 3 +++ lib/ethdev/rte_ethdev.c | 10 ++++---- lib/pcapng/rte_pcapng.c | 2 +- 21 files changed, 75 insertions(+), 52 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 82db14f3a6..3c027701e3 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -612,7 +612,7 @@ device_infos_display(const char *identifier) if (identifier && da.bus != next) continue; - snprintf(devstr, sizeof(devstr), "bus=%s", next->name); + snprintf(devstr, sizeof(devstr), "bus=%s", rte_bus_name(next)); RTE_DEV_FOREACH(dev, devstr, &dev_iter) { if (!dev->driver) @@ -623,7 +623,7 @@ device_infos_display(const char *identifier) continue; printf("\n%s Infos for device %s %s\n", info_border, dev->name, info_border); - printf("Bus name: %s", dev->bus->name); + printf("Bus name: %s", rte_bus_name(dev->bus)); printf("\nDriver name: %s", dev->driver->name); printf("\nDevargs: %s", dev->devargs ? dev->devargs->args : ""); @@ -1076,7 +1076,7 @@ port_reg_off_is_invalid(portid_t port_id, uint32_t reg_off) } bus = rte_bus_find_by_device(ports[port_id].dev_info.device); - if (bus && !strcmp(bus->name, "pci")) { + if (bus && !strcmp(rte_bus_name(bus), "pci")) { pci_dev = RTE_DEV_TO_PCI(ports[port_id].dev_info.device); } else { fprintf(stderr, "Not a PCI device\n"); diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index addcbcac85..51c2488b45 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3507,9 +3507,9 @@ detach_devargs(char *identifier) } } - if (rte_eal_hotplug_remove(da.bus->name, da.name) != 0) { + if (rte_eal_hotplug_remove(rte_bus_name(da.bus), da.name) != 0) { TESTPMD_LOG(ERR, "Failed to detach device %s(%s)\n", - da.name, da.bus->name); + da.name, rte_bus_name(da.bus)); rte_devargs_reset(&da); return; } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 34bdccef71..ea242de34c 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -817,7 +817,7 @@ port_pci_reg_read(struct rte_port *port, uint32_t reg_off) } bus = rte_bus_find_by_device(port->dev_info.device); - if (bus && !strcmp(bus->name, "pci")) { + if (bus && !strcmp(rte_bus_name(bus), "pci")) { pci_dev = RTE_DEV_TO_PCI(port->dev_info.device); } else { fprintf(stderr, "Not a PCI device\n"); @@ -845,7 +845,7 @@ port_pci_reg_write(struct rte_port *port, uint32_t reg_off, uint32_t reg_v) } bus = rte_bus_find_by_device(port->dev_info.device); - if (bus && !strcmp(bus->name, "pci")) { + if (bus && !strcmp(rte_bus_name(bus), "pci")) { pci_dev = RTE_DEV_TO_PCI(port->dev_info.device); } else { fprintf(stderr, "Not a PCI device\n"); diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c index 16621285d2..ac5bc34c18 100644 --- a/app/test/test_devargs.c +++ b/app/test/test_devargs.c @@ -98,9 +98,9 @@ test_valid_devargs_cases(const struct devargs_case *list, size_t n) list[i].bus_kv) != 0) goto fail; if (list[i].bus != NULL && - strcmp(da.bus->name, list[i].bus) != 0) { + strcmp(rte_bus_name(da.bus), list[i].bus) != 0) { printf("rte_devargs_parse(%s) bus name (%s) not expected (%s)\n", - list[i].devargs, da.bus->name, list[i].bus); + list[i].devargs, rte_bus_name(da.bus), list[i].bus); goto fail; } if ((list[i].class_kv > 0 || list[i].class != NULL) && diff --git a/app/test/test_kni.c b/app/test/test_kni.c index 9d76b6253e..524af31e01 100644 --- a/app/test/test_kni.c +++ b/app/test/test_kni.c @@ -446,7 +446,7 @@ test_kni_processing(uint16_t port_id, struct rte_mempool *mp) if (info.device) bus = rte_bus_find_by_device(info.device); - if (bus && !strcmp(bus->name, "pci")) { + if (bus && !strcmp(rte_bus_name(bus), "pci")) { pci_dev = RTE_DEV_TO_PCI(info.device); conf.addr = pci_dev->addr; conf.id = pci_dev->id; @@ -650,7 +650,7 @@ test_kni(void) bus = rte_bus_find_by_device(info.device); else bus = NULL; - if (bus && !strcmp(bus->name, "pci")) { + if (bus && !strcmp(rte_bus_name(bus), "pci")) { pci_dev = RTE_DEV_TO_PCI(info.device); conf.addr = pci_dev->addr; conf.id = pci_dev->id; @@ -694,7 +694,7 @@ test_kni(void) bus = rte_bus_find_by_device(info.device); else bus = NULL; - if (bus && !strcmp(bus->name, "pci")) { + if (bus && !strcmp(rte_bus_name(bus), "pci")) { pci_dev = RTE_DEV_TO_PCI(info.device); conf.addr = pci_dev->addr; conf.id = pci_dev->id; diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index e708e23a7f..578bd0a9b5 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -105,7 +105,7 @@ pci_ids_table_update(const struct rte_pci_id *driver_id_table) bool mlx5_dev_is_pci(const struct rte_device *dev) { - return strcmp(dev->bus->name, "pci") == 0; + return strcmp(rte_bus_name(dev->bus), "pci") == 0; } bool diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index 3eb7d32b76..f69bb42add 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -319,7 +319,7 @@ devargs_already_listed(struct rte_devargs *devargs) { struct rte_devargs *list_da; - RTE_EAL_DEVARGS_FOREACH(devargs->bus->name, list_da) { + RTE_EAL_DEVARGS_FOREACH(rte_bus_name(devargs->bus), list_da) { if (strcmp(list_da->name, devargs->name) == 0) /* devargs already in the list */ return true; diff --git a/drivers/net/failsafe/failsafe_eal.c b/drivers/net/failsafe/failsafe_eal.c index 130344dce2..fe5acdc1b6 100644 --- a/drivers/net/failsafe/failsafe_eal.c +++ b/drivers/net/failsafe/failsafe_eal.c @@ -46,7 +46,7 @@ fs_bus_init(struct rte_eth_dev *dev) if (fs_ethdev_portid_get(da->name, &pid) != 0) { struct rte_eth_dev_owner pid_owner; - ret = rte_eal_hotplug_add(da->bus->name, + ret = rte_eal_hotplug_add(rte_bus_name(da->bus), da->name, da->args); if (ret < 0) { diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 04b9614f5c..4baa4c766e 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1191,7 +1191,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, DRV_LOG(DEBUG, "dev_port=%u bus=%s pci=%s master=%d representor=%d pf_bond=%d\n", - priv->dev_port, dpdk_dev->bus->name, + priv->dev_port, rte_bus_name(dpdk_dev->bus), priv->pci_dev ? priv->pci_dev->name : "NONE", priv->master, priv->representor, priv->pf_bond); diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 93ee4a6e86..8070880c06 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -620,7 +620,7 @@ static void netvsc_hotplug_retry(void *args) /* If this device has been hot removed from this * parent device, restore its args. */ - ret = rte_eal_hotplug_add(d->bus->name, d->name, + ret = rte_eal_hotplug_add(rte_bus_name(d->bus), d->name, hv->vf_devargs ? hv->vf_devargs : ""); if (ret) { @@ -686,7 +686,7 @@ netvsc_hotadd_callback(const char *device_name, enum rte_dev_event_type type, goto free_ctx; } - if (!strcmp(d->bus->name, "pci")) { + if (!strcmp(rte_bus_name(d->bus), "pci")) { /* Start the process of figuring out if this * PCI device is a VF device */ diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c index 62f6de84d5..4034a241aa 100644 --- a/examples/ethtool/lib/rte_ethtool.c +++ b/examples/ethtool/lib/rte_ethtool.c @@ -4,6 +4,7 @@ #include #include #include + #include #include #include @@ -56,7 +57,7 @@ rte_ethtool_get_drvinfo(uint16_t port_id, struct ethtool_drvinfo *drvinfo) /* TODO: replace bus_info by rte_devargs.name */ if (dev_info.device) bus = rte_bus_find_by_device(dev_info.device); - if (bus && !strcmp(bus->name, "pci")) { + if (bus && !strcmp(rte_bus_name(bus), "pci")) { pci_dev = RTE_DEV_TO_PCI(dev_info.device); snprintf(drvinfo->bus_info, sizeof(drvinfo->bus_info), "%04x:%02x:%02x.%x", diff --git a/examples/ip_pipeline/kni.c b/examples/ip_pipeline/kni.c index 270b961bba..5778a6440e 100644 --- a/examples/ip_pipeline/kni.c +++ b/examples/ip_pipeline/kni.c @@ -137,7 +137,7 @@ kni_create(const char *name, struct kni_params *params) kni_conf.mbuf_size = mempool->buffer_size; if (dev_info.device) bus = rte_bus_find_by_device(dev_info.device); - if (bus && !strcmp(bus->name, "pci")) { + if (bus && !strcmp(rte_bus_name(bus), "pci")) { pci_dev = RTE_DEV_TO_PCI(dev_info.device); kni_conf.addr = pci_dev->addr; kni_conf.id = pci_dev->id; diff --git a/examples/multi_process/hotplug_mp/commands.c b/examples/multi_process/hotplug_mp/commands.c index da8b5e5924..88f44e00a0 100644 --- a/examples/multi_process/hotplug_mp/commands.c +++ b/examples/multi_process/hotplug_mp/commands.c @@ -126,7 +126,7 @@ static void cmd_dev_attach_parsed(void *parsed_result, return; } - if (!rte_eal_hotplug_add(da.bus->name, da.name, da.args)) + if (!rte_eal_hotplug_add(rte_bus_name(da.bus), da.name, da.args)) cmdline_printf(cl, "attached device %s\n", da.name); else cmdline_printf(cl, "failed to attached device %s\n", @@ -173,7 +173,7 @@ static void cmd_dev_detach_parsed(void *parsed_result, } printf("detaching...\n"); - if (!rte_eal_hotplug_remove(da.bus->name, da.name)) + if (!rte_eal_hotplug_remove(rte_bus_name(da.bus), da.name)) cmdline_printf(cl, "detached device %s\n", da.name); else diff --git a/lib/eal/common/eal_common_bus.c b/lib/eal/common/eal_common_bus.c index baa5b532af..cbf382f967 100644 --- a/lib/eal/common/eal_common_bus.c +++ b/lib/eal/common/eal_common_bus.c @@ -16,11 +16,17 @@ static struct rte_bus_list rte_bus_list = TAILQ_HEAD_INITIALIZER(rte_bus_list); +const char * +rte_bus_name(const struct rte_bus *bus) +{ + return bus->name; +} + void rte_bus_register(struct rte_bus *bus) { RTE_VERIFY(bus); - RTE_VERIFY(bus->name && strlen(bus->name)); + RTE_VERIFY(rte_bus_name(bus) && strlen(rte_bus_name(bus))); /* A bus should mandatorily have the scan implemented */ RTE_VERIFY(bus->scan); RTE_VERIFY(bus->probe); @@ -29,14 +35,14 @@ rte_bus_register(struct rte_bus *bus) RTE_VERIFY(!bus->plug || bus->unplug); TAILQ_INSERT_TAIL(&rte_bus_list, bus, next); - RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", bus->name); + RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", rte_bus_name(bus)); } void rte_bus_unregister(struct rte_bus *bus) { TAILQ_REMOVE(&rte_bus_list, bus, next); - RTE_LOG(DEBUG, EAL, "Unregistered [%s] bus.\n", bus->name); + RTE_LOG(DEBUG, EAL, "Unregistered [%s] bus.\n", rte_bus_name(bus)); } /* Scan all the buses for registered devices */ @@ -50,7 +56,7 @@ rte_bus_scan(void) ret = bus->scan(); if (ret) RTE_LOG(ERR, EAL, "Scan for (%s) bus failed.\n", - bus->name); + rte_bus_name(bus)); } return 0; @@ -64,7 +70,7 @@ rte_bus_probe(void) struct rte_bus *bus, *vbus = NULL; TAILQ_FOREACH(bus, &rte_bus_list, next) { - if (!strcmp(bus->name, "vdev")) { + if (!strcmp(rte_bus_name(bus), "vdev")) { vbus = bus; continue; } @@ -72,14 +78,14 @@ rte_bus_probe(void) ret = bus->probe(); if (ret) RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n", - bus->name); + rte_bus_name(bus)); } if (vbus) { ret = vbus->probe(); if (ret) RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n", - vbus->name); + rte_bus_name(vbus)); } return 0; @@ -92,7 +98,7 @@ bus_dump_one(FILE *f, struct rte_bus *bus) int ret; /* For now, dump only the bus name */ - ret = fprintf(f, " %s\n", bus->name); + ret = fprintf(f, " %s\n", rte_bus_name(bus)); /* Error in case of inability in writing to stream */ if (ret < 0) @@ -163,7 +169,7 @@ cmp_bus_name(const struct rte_bus *bus, const void *_name) { const char *name = _name; - return strcmp(bus->name, name); + return strcmp(rte_bus_name(bus), name); } struct rte_bus * @@ -213,7 +219,7 @@ rte_bus_get_iommu_class(void) bus_iova_mode = bus->get_iommu_class(); RTE_LOG(DEBUG, EAL, "Bus %s wants IOVA as '%s'\n", - bus->name, + rte_bus_name(bus), bus_iova_mode == RTE_IOVA_DC ? "DC" : (bus_iova_mode == RTE_IOVA_PA ? "PA" : "VA")); if (bus_iova_mode == RTE_IOVA_PA) diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c index b6f0392f30..bbaf518570 100644 --- a/lib/eal/common/eal_common_dev.c +++ b/lib/eal/common/eal_common_dev.c @@ -140,7 +140,7 @@ local_dev_probe(const char *devargs, struct rte_device **new_dev) if (da->bus->plug == NULL) { RTE_LOG(ERR, EAL, "Function plug not supported by bus (%s)\n", - da->bus->name); + rte_bus_name(da->bus)); ret = -ENOTSUP; goto err_devarg; } @@ -309,7 +309,7 @@ local_dev_remove(struct rte_device *dev) if (dev->bus->unplug == NULL) { RTE_LOG(ERR, EAL, "Function unplug not supported by bus (%s)\n", - dev->bus->name); + rte_bus_name(dev->bus)); return -ENOTSUP; } @@ -335,7 +335,7 @@ rte_dev_remove(struct rte_device *dev) return -ENOENT; } - ret = build_devargs(dev->bus->name, dev->name, "", &devargs); + ret = build_devargs(rte_bus_name(dev->bus), dev->name, "", &devargs); if (ret != 0) return ret; @@ -597,7 +597,7 @@ rte_dev_iterator_init(struct rte_dev_iterator *it, goto get_out; } if (bus != NULL && bus->dev_iterate == NULL) { - RTE_LOG(DEBUG, EAL, "Bus %s not supported\n", bus->name); + RTE_LOG(DEBUG, EAL, "Bus %s not supported\n", rte_bus_name(bus)); rte_errno = ENOTSUP; goto get_out; } diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c index d5833af373..fa95c52708 100644 --- a/lib/eal/common/eal_common_devargs.c +++ b/lib/eal/common/eal_common_devargs.c @@ -176,7 +176,7 @@ rte_devargs_layers_parse(struct rte_devargs *devargs, static int bus_name_cmp(const struct rte_bus *bus, const void *name) { - return strncmp(bus->name, name, strlen(bus->name)); + return strncmp(rte_bus_name(bus), name, strlen(bus->name)); } int @@ -206,7 +206,7 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev) bus = rte_bus_find(bus, bus_name_cmp, dev); if (bus == NULL) break; - devname = dev + strlen(bus->name) + 1; + devname = dev + strlen(rte_bus_name(bus)) + 1; if (rte_bus_find_by_device_name(devname) == bus) break; } while (1); @@ -301,7 +301,7 @@ rte_devargs_insert(struct rte_devargs **da) if (listed_da == *da) /* devargs already in the list */ return 0; - if (strcmp(listed_da->bus->name, (*da)->bus->name) == 0 && + if (strcmp(rte_bus_name(listed_da->bus), (*da)->bus->name) == 0 && strcmp(listed_da->name, (*da)->name) == 0) { /* device already in devargs list, must be updated */ (*da)->next = listed_da->next; @@ -365,7 +365,7 @@ rte_devargs_remove(struct rte_devargs *devargs) return -1; RTE_TAILQ_FOREACH_SAFE(d, &devargs_list, next, tmp) { - if (strcmp(d->bus->name, devargs->bus->name) == 0 && + if (strcmp(rte_bus_name(d->bus), devargs->bus->name) == 0 && strcmp(d->name, devargs->name) == 0) { TAILQ_REMOVE(&devargs_list, d, next); rte_devargs_reset(d); @@ -400,7 +400,7 @@ rte_devargs_dump(FILE *f) fprintf(f, "User device list:\n"); TAILQ_FOREACH(devargs, &devargs_list, next) { fprintf(f, " [%s]: %s %s\n", - (devargs->bus ? devargs->bus->name : "??"), + (devargs->bus ? rte_bus_name(devargs->bus) : "??"), devargs->name, devargs->args); } } @@ -417,7 +417,7 @@ rte_devargs_next(const char *busname, const struct rte_devargs *start) da = TAILQ_FIRST(&devargs_list); while (da != NULL) { if (busname == NULL || - (strcmp(busname, da->bus->name) == 0)) + (strcmp(busname, rte_bus_name(da->bus)) == 0)) return da; da = TAILQ_NEXT(da, next); } diff --git a/lib/eal/common/hotplug_mp.c b/lib/eal/common/hotplug_mp.c index 1614a57752..252f147b6f 100644 --- a/lib/eal/common/hotplug_mp.c +++ b/lib/eal/common/hotplug_mp.c @@ -127,9 +127,9 @@ __handle_secondary_request(void *param) goto rollback; } - bus = rte_bus_find_by_name(da.bus->name); + bus = rte_bus_find_by_name(rte_bus_name(da.bus)); if (bus == NULL) { - RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", da.bus->name); + RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", rte_bus_name(da.bus)); ret = -ENOENT; goto finish; } @@ -254,9 +254,9 @@ static void __handle_primary_request(void *param) if (ret != 0) goto quit; - bus = rte_bus_find_by_name(da->bus->name); + bus = rte_bus_find_by_name(rte_bus_name(da->bus)); if (bus == NULL) { - RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", da->bus->name); + RTE_LOG(ERR, EAL, "Cannot find bus (%s)\n", rte_bus_name(da->bus)); ret = -ENOENT; goto quit; } diff --git a/lib/eal/include/rte_bus.h b/lib/eal/include/rte_bus.h index 17edaa37c9..9b70f2f7b2 100644 --- a/lib/eal/include/rte_bus.h +++ b/lib/eal/include/rte_bus.h @@ -266,6 +266,19 @@ struct rte_bus { }; +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * @param bus + * A pointer to a rte_bus structure describing the bus + * to be registered. + * @return + * A pointer to the bus name string. + */ +__rte_experimental +const char *rte_bus_name(const struct rte_bus *bus); + /** * Register a Bus handler. * diff --git a/lib/eal/version.map b/lib/eal/version.map index c2a2cebf69..6f713c987d 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -424,6 +424,9 @@ EXPERIMENTAL { rte_thread_self; rte_thread_set_affinity_by_id; rte_thread_set_priority; + + # added in 22.11 + rte_bus_name; }; INTERNAL { diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index ebbe8cca3d..c94d6573d5 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -232,11 +232,11 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) } /* Convert bus args to new syntax for use with new API dev_iterate. */ - if ((strcmp(iter->bus->name, "vdev") == 0) || - (strcmp(iter->bus->name, "fslmc") == 0) || - (strcmp(iter->bus->name, "dpaa_bus") == 0)) { + if ((strcmp(rte_bus_name(iter->bus), "vdev") == 0) || + (strcmp(rte_bus_name(iter->bus), "fslmc") == 0) || + (strcmp(rte_bus_name(iter->bus), "dpaa_bus") == 0)) { bus_param_key = "name"; - } else if (strcmp(iter->bus->name, "pci") == 0) { + } else if (strcmp(rte_bus_name(iter->bus), "pci") == 0) { bus_param_key = "addr"; } else { ret = -ENOTSUP; @@ -264,7 +264,7 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) error: if (ret == -ENOTSUP) RTE_ETHDEV_LOG(ERR, "Bus %s does not support iterating.\n", - iter->bus->name); + rte_bus_name(iter->bus)); rte_devargs_reset(&devargs); free(bus_str); free(cls_str); diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index 5b079cd14a..83d692d095 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -211,7 +211,7 @@ pcapng_add_interface(rte_pcapng_t *self, uint16_t port) dev = dev_info.device; if (dev) snprintf(ifhw, sizeof(ifhw), - "%s-%s", dev->bus->name, dev->name); + "%s-%s", rte_bus_name(dev->bus), dev->name); /* DPDK reports in units of Mbps */ if (rte_eth_link_get(port, &link) == 0 && From patchwork Tue Jun 28 14:46:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 113524 X-Patchwork-Delegate: thomas@monjalon.net 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 DDA1AA056B; Tue, 28 Jun 2022 16:48:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 72806427EA; Tue, 28 Jun 2022 16:48:00 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 82B5642825 for ; Tue, 28 Jun 2022 16:47:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656427678; 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=d7uPpw2q8CcN1V2+wkeTj7yb7pWFC7dFcDQ/+Oz0ALA=; b=fxyqcTsUnQXGqTuGLnXQ/N4m5bWJLBk3LmD1tOrGe+MFEGb6qVrYBUllxgbm4zhTZQ0Xny Ug/fBFJnH5WhPd3QnzBTd+JiLEcSE31a28gXtjEwHGziPT9XE3KM541VV6dEyQuxcR0znI 64GgzL3lCWZYP+MEX1i9UhbF5KQwbKY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-225-Gjw6J6YwPZewXM3CFruXOg-1; Tue, 28 Jun 2022 10:47:41 -0400 X-MC-Unique: Gjw6J6YwPZewXM3CFruXOg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 995D529DD99D; Tue, 28 Jun 2022 14:47:40 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.194.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8ACF92166B26; Tue, 28 Jun 2022 14:47:37 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, kevin.laatz@intel.com, Parav Pandit , Xueming Li , Hemant Agrawal , Sachin Saxena , Rosen Xu , Stephen Hemminger , Long Li , Chas Williams , "Min Hu (Connor)" , Matan Azrad , Ray Kinsella , Ferruh Yigit , Andrew Rybchenko Subject: [RFC PATCH 11/11] bus: hide bus object Date: Tue, 28 Jun 2022 16:46:43 +0200 Message-Id: <20220628144643.1213026-12-david.marchand@redhat.com> In-Reply-To: <20220628144643.1213026-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 Make rte_bus opaque for non internal users. This will make extending this object possible without breaking the ABI. Introduce a new driver header and move rte_bus definition and helpers. Signed-off-by: David Marchand --- app/test/test_devargs.c | 2 +- app/test/test_vdev.c | 2 +- drivers/bus/auxiliary/private.h | 2 +- drivers/bus/dpaa/dpaa_bus.c | 2 +- drivers/bus/fslmc/private.h | 2 +- drivers/bus/ifpga/ifpga_bus.c | 2 +- drivers/bus/pci/private.h | 2 +- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/private.h | 2 +- drivers/dma/idxd/idxd_bus.c | 2 +- drivers/net/bonding/rte_eth_bond_args.c | 2 +- drivers/net/vdev_netvsc/vdev_netvsc.c | 2 +- lib/eal/common/eal_common_bus.c | 2 +- lib/eal/common/eal_common_dev.c | 2 +- lib/eal/common/eal_common_devargs.c | 2 +- lib/eal/common/hotplug_mp.c | 2 +- lib/eal/include/bus_driver.h | 295 ++++++++++++++++++++++++ lib/eal/include/meson.build | 4 + lib/eal/include/rte_bus.h | 275 +--------------------- lib/eal/linux/eal_dev.c | 2 +- lib/eal/version.map | 4 +- lib/ethdev/rte_ethdev.c | 2 +- 22 files changed, 322 insertions(+), 292 deletions(-) create mode 100644 lib/eal/include/bus_driver.h diff --git a/app/test/test_devargs.c b/app/test/test_devargs.c index ac5bc34c18..0a4c34a1ad 100644 --- a/app/test/test_devargs.c +++ b/app/test/test_devargs.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include "test.h" diff --git a/app/test/test_vdev.c b/app/test/test_vdev.c index 5eeff3106d..1904e76e44 100644 --- a/app/test/test_vdev.c +++ b/app/test/test_vdev.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include "test.h" diff --git a/drivers/bus/auxiliary/private.h b/drivers/bus/auxiliary/private.h index 06a920114c..7e8ae8c2f9 100644 --- a/drivers/bus/auxiliary/private.h +++ b/drivers/bus/auxiliary/private.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include "rte_bus_auxiliary.h" diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index ad4ea156a6..4f12944470 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include diff --git a/drivers/bus/fslmc/private.h b/drivers/bus/fslmc/private.h index 80d4673ca8..f08dc7716b 100644 --- a/drivers/bus/fslmc/private.h +++ b/drivers/bus/fslmc/private.h @@ -5,7 +5,7 @@ #ifndef __PRIVATE_H__ #define __PRIVATE_H__ -#include +#include #include diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index e005f2cb70..a2c2f13cf7 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index 6ccec15655..0cefed5edf 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index a8d8b2327e..dd4e931687 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h index 732cb6d583..5205e17a3f 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/dma/idxd/idxd_bus.c b/drivers/dma/idxd/idxd_bus.c index 13cb967f6d..e30dcfc281 100644 --- a/drivers/dma/idxd/idxd_bus.c +++ b/drivers/dma/idxd/idxd_bus.c @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c index b90757756a..f461bf9207 100644 --- a/drivers/net/bonding/rte_eth_bond_args.c +++ b/drivers/net/bonding/rte_eth_bond_args.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include #include diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c index 2587195168..24edf9f3c4 100644 --- a/drivers/net/vdev_netvsc/vdev_netvsc.c +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/eal/common/eal_common_bus.c b/lib/eal/common/eal_common_bus.c index cbf382f967..be64d31b0f 100644 --- a/lib/eal/common/eal_common_bus.c +++ b/lib/eal/common/eal_common_bus.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c index bbaf518570..a366bb3689 100644 --- a/lib/eal/common/eal_common_dev.c +++ b/lib/eal/common/eal_common_dev.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/eal/common/eal_common_devargs.c b/lib/eal/common/eal_common_devargs.c index fa95c52708..adccfa713f 100644 --- a/lib/eal/common/eal_common_devargs.c +++ b/lib/eal/common/eal_common_devargs.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/eal/common/hotplug_mp.c b/lib/eal/common/hotplug_mp.c index 252f147b6f..9e6eddec92 100644 --- a/lib/eal/common/hotplug_mp.c +++ b/lib/eal/common/hotplug_mp.c @@ -3,7 +3,7 @@ */ #include -#include +#include #include #include #include diff --git a/lib/eal/include/bus_driver.h b/lib/eal/include/bus_driver.h new file mode 100644 index 0000000000..ac404c3d5e --- /dev/null +++ b/lib/eal/include/bus_driver.h @@ -0,0 +1,295 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2022 Red Hat, Inc. + */ + +#ifndef BUS_DRIVER_H +#define BUS_DRIVER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +struct rte_device; + +/** Double linked list of buses */ +RTE_TAILQ_HEAD(rte_bus_list, rte_bus); + +/** + * Bus specific scan for devices attached on the bus. + * For each bus object, the scan would be responsible for finding devices and + * adding them to its private device list. + * + * A bus should mandatorily implement this method. + * + * @return + * 0 for successful scan + * <0 for unsuccessful scan with error value + */ +typedef int (*rte_bus_scan_t)(void); + +/** + * Implementation specific probe function which is responsible for linking + * devices on that bus with applicable drivers. + * + * This is called while iterating over each registered bus. + * + * @return + * 0 for successful probe + * !0 for any error while probing + */ +typedef int (*rte_bus_probe_t)(void); + +/** + * Device iterator to find a device on a bus. + * + * This function returns an rte_device if one of those held by the bus + * matches the data passed as parameter. + * + * If the comparison function returns zero this function should stop iterating + * over any more devices. To continue a search the device of a previous search + * can be passed via the start parameter. + * + * @param cmp + * Comparison function. + * + * @param data + * Data to compare each device against. + * + * @param start + * starting point for the iteration + * + * @return + * The first device matching the data, NULL if none exists. + */ +typedef struct rte_device * +(*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp, + const void *data); + +/** + * Implementation specific probe function which is responsible for linking + * devices on that bus with applicable drivers. + * + * @param dev + * Device pointer that was returned by a previous call to find_device. + * + * @return + * 0 on success. + * !0 on error. + */ +typedef int (*rte_bus_plug_t)(struct rte_device *dev); + +/** + * Implementation specific remove function which is responsible for unlinking + * devices on that bus from assigned driver. + * + * @param dev + * Device pointer that was returned by a previous call to find_device. + * + * @return + * 0 on success. + * !0 on error. + */ +typedef int (*rte_bus_unplug_t)(struct rte_device *dev); + +/** + * Bus specific parsing function. + * Validates the syntax used in the textual representation of a device, + * If the syntax is valid and ``addr`` is not NULL, writes the bus-specific + * device representation to ``addr``. + * + * @param[in] name + * device textual description + * + * @param[out] addr + * device information location address, into which parsed info + * should be written. If NULL, nothing should be written, which + * is not an error. + * + * @return + * 0 if parsing was successful. + * !0 for any error. + */ +typedef int (*rte_bus_parse_t)(const char *name, void *addr); + +/** + * Parse bus part of the device arguments. + * + * The field name of the struct rte_devargs will be set. + * + * @param da + * Pointer to the devargs to parse. + * + * @return + * 0 on successful parsing, otherwise rte_errno is set. + * -EINVAL: on parsing error. + * -ENODEV: if no key matching a device argument is specified. + * -E2BIG: device name is too long. + */ +typedef int (*rte_bus_devargs_parse_t)(struct rte_devargs *da); + +/** + * Device level DMA map function. + * After a successful call, the memory segment will be mapped to the + * given device. + * + * @param dev + * Device pointer. + * @param addr + * Virtual address to map. + * @param iova + * IOVA address to map. + * @param len + * Length of the memory segment being mapped. + * + * @return + * 0 if mapping was successful. + * Negative value and rte_errno is set otherwise. + */ +typedef int (*rte_dev_dma_map_t)(struct rte_device *dev, void *addr, + uint64_t iova, size_t len); + +/** + * Device level DMA unmap function. + * After a successful call, the memory segment will no longer be + * accessible by the given device. + * + * @param dev + * Device pointer. + * @param addr + * Virtual address to unmap. + * @param iova + * IOVA address to unmap. + * @param len + * Length of the memory segment being mapped. + * + * @return + * 0 if un-mapping was successful. + * Negative value and rte_errno is set otherwise. + */ +typedef int (*rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr, + uint64_t iova, size_t len); + +/** + * Implement a specific hot-unplug handler, which is responsible for + * handle the failure when device be hot-unplugged. When the event of + * hot-unplug be detected, it could call this function to handle + * the hot-unplug failure and avoid app crash. + * @param dev + * Pointer of the device structure. + * + * @return + * 0 on success. + * !0 on error. + */ +typedef int (*rte_bus_hot_unplug_handler_t)(struct rte_device *dev); + +/** + * Implement a specific sigbus handler, which is responsible for handling + * the sigbus error which is either original memory error, or specific memory + * error that caused of device be hot-unplugged. When sigbus error be captured, + * it could call this function to handle sigbus error. + * @param failure_addr + * Pointer of the fault address of the sigbus error. + * + * @return + * 0 for success handle the sigbus for hot-unplug. + * 1 for not process it, because it is a generic sigbus error. + * -1 for failed to handle the sigbus for hot-unplug. + */ +typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr); + +/** + * Bus scan policies + */ +enum rte_bus_scan_mode { + RTE_BUS_SCAN_UNDEFINED, + RTE_BUS_SCAN_ALLOWLIST, + RTE_BUS_SCAN_BLOCKLIST, +}; + +/** + * A structure used to configure bus operations. + */ +struct rte_bus_conf { + enum rte_bus_scan_mode scan_mode; /**< Scan policy. */ +}; + + +/** + * Get common iommu class of the all the devices on the bus. The bus may + * check that those devices are attached to iommu driver. + * If no devices are attached to the bus. The bus may return with don't care + * (_DC) value. + * Otherwise, The bus will return appropriate _pa or _va iova mode. + * + * @return + * enum rte_iova_mode value. + */ +typedef enum rte_iova_mode (*rte_bus_get_iommu_class_t)(void); + +/** + * A structure describing a generic bus. + */ +struct rte_bus { + RTE_TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */ + const char *name; /**< Name of the bus */ + rte_bus_scan_t scan; /**< Scan for devices attached to bus */ + rte_bus_probe_t probe; /**< Probe devices on bus */ + rte_bus_find_device_t find_device; /**< Find a device on the bus */ + rte_bus_plug_t plug; /**< Probe single device for drivers */ + rte_bus_unplug_t unplug; /**< Remove single device from driver */ + rte_bus_parse_t parse; /**< Parse a device name */ + rte_bus_devargs_parse_t devargs_parse; /**< Parse bus devargs */ + rte_dev_dma_map_t dma_map; /**< DMA map for device in the bus */ + rte_dev_dma_unmap_t dma_unmap; /**< DMA unmap for device in the bus */ + struct rte_bus_conf conf; /**< Bus configuration */ + rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */ + rte_dev_iterate_t dev_iterate; /**< Device iterator. */ + rte_bus_hot_unplug_handler_t hot_unplug_handler; + /**< handle hot-unplug failure on the bus */ + rte_bus_sigbus_handler_t sigbus_handler; + /**< handle sigbus error on the bus */ +}; + +/** + * Register a Bus handler. + * + * @param bus + * A pointer to a rte_bus structure describing the bus + * to be registered. + */ +__rte_internal +void rte_bus_register(struct rte_bus *bus); + +/** + * Helper for Bus registration. + * The constructor has higher priority than PMD constructors. + */ +#define RTE_REGISTER_BUS(nm, bus) \ +RTE_INIT_PRIO(businitfn_ ##nm, BUS) \ +{\ + (bus).name = RTE_STR(nm);\ + rte_bus_register(&bus); \ +} + +/** + * Unregister a Bus handler. + * + * @param bus + * A pointer to a rte_bus structure describing the bus + * to be unregistered. + */ +__rte_internal +void rte_bus_unregister(struct rte_bus *bus); + +#ifdef __cplusplus +} +#endif + +#endif /* BUS_DRIVER_H */ diff --git a/lib/eal/include/meson.build b/lib/eal/include/meson.build index fd6e844224..77d8621a51 100644 --- a/lib/eal/include/meson.build +++ b/lib/eal/include/meson.build @@ -55,6 +55,10 @@ headers += files( 'rte_vfio.h', ) +driver_sdk_headers = files( + 'bus_driver.h', +) + # special case install the generic headers, since they go in a subdir generic_headers = files( 'generic/rte_atomic.h', diff --git a/lib/eal/include/rte_bus.h b/lib/eal/include/rte_bus.h index 9b70f2f7b2..1b08407e53 100644 --- a/lib/eal/include/rte_bus.h +++ b/lib/eal/include/rte_bus.h @@ -20,251 +20,11 @@ extern "C" { #include -#include +#include #include -#include -/** Double linked list of buses */ -RTE_TAILQ_HEAD(rte_bus_list, rte_bus); - -/** - * Bus specific scan for devices attached on the bus. - * For each bus object, the scan would be responsible for finding devices and - * adding them to its private device list. - * - * A bus should mandatorily implement this method. - * - * @return - * 0 for successful scan - * <0 for unsuccessful scan with error value - */ -typedef int (*rte_bus_scan_t)(void); - -/** - * Implementation specific probe function which is responsible for linking - * devices on that bus with applicable drivers. - * - * This is called while iterating over each registered bus. - * - * @return - * 0 for successful probe - * !0 for any error while probing - */ -typedef int (*rte_bus_probe_t)(void); - -/** - * Device iterator to find a device on a bus. - * - * This function returns an rte_device if one of those held by the bus - * matches the data passed as parameter. - * - * If the comparison function returns zero this function should stop iterating - * over any more devices. To continue a search the device of a previous search - * can be passed via the start parameter. - * - * @param cmp - * Comparison function. - * - * @param data - * Data to compare each device against. - * - * @param start - * starting point for the iteration - * - * @return - * The first device matching the data, NULL if none exists. - */ -typedef struct rte_device * -(*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp, - const void *data); - -/** - * Implementation specific probe function which is responsible for linking - * devices on that bus with applicable drivers. - * - * @param dev - * Device pointer that was returned by a previous call to find_device. - * - * @return - * 0 on success. - * !0 on error. - */ -typedef int (*rte_bus_plug_t)(struct rte_device *dev); - -/** - * Implementation specific remove function which is responsible for unlinking - * devices on that bus from assigned driver. - * - * @param dev - * Device pointer that was returned by a previous call to find_device. - * - * @return - * 0 on success. - * !0 on error. - */ -typedef int (*rte_bus_unplug_t)(struct rte_device *dev); - -/** - * Bus specific parsing function. - * Validates the syntax used in the textual representation of a device, - * If the syntax is valid and ``addr`` is not NULL, writes the bus-specific - * device representation to ``addr``. - * - * @param[in] name - * device textual description - * - * @param[out] addr - * device information location address, into which parsed info - * should be written. If NULL, nothing should be written, which - * is not an error. - * - * @return - * 0 if parsing was successful. - * !0 for any error. - */ -typedef int (*rte_bus_parse_t)(const char *name, void *addr); - -/** - * Parse bus part of the device arguments. - * - * The field name of the struct rte_devargs will be set. - * - * @param da - * Pointer to the devargs to parse. - * - * @return - * 0 on successful parsing, otherwise rte_errno is set. - * -EINVAL: on parsing error. - * -ENODEV: if no key matching a device argument is specified. - * -E2BIG: device name is too long. - */ -typedef int (*rte_bus_devargs_parse_t)(struct rte_devargs *da); - -/** - * Device level DMA map function. - * After a successful call, the memory segment will be mapped to the - * given device. - * - * @param dev - * Device pointer. - * @param addr - * Virtual address to map. - * @param iova - * IOVA address to map. - * @param len - * Length of the memory segment being mapped. - * - * @return - * 0 if mapping was successful. - * Negative value and rte_errno is set otherwise. - */ -typedef int (*rte_dev_dma_map_t)(struct rte_device *dev, void *addr, - uint64_t iova, size_t len); - -/** - * Device level DMA unmap function. - * After a successful call, the memory segment will no longer be - * accessible by the given device. - * - * @param dev - * Device pointer. - * @param addr - * Virtual address to unmap. - * @param iova - * IOVA address to unmap. - * @param len - * Length of the memory segment being mapped. - * - * @return - * 0 if un-mapping was successful. - * Negative value and rte_errno is set otherwise. - */ -typedef int (*rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr, - uint64_t iova, size_t len); - -/** - * Implement a specific hot-unplug handler, which is responsible for - * handle the failure when device be hot-unplugged. When the event of - * hot-unplug be detected, it could call this function to handle - * the hot-unplug failure and avoid app crash. - * @param dev - * Pointer of the device structure. - * - * @return - * 0 on success. - * !0 on error. - */ -typedef int (*rte_bus_hot_unplug_handler_t)(struct rte_device *dev); - -/** - * Implement a specific sigbus handler, which is responsible for handling - * the sigbus error which is either original memory error, or specific memory - * error that caused of device be hot-unplugged. When sigbus error be captured, - * it could call this function to handle sigbus error. - * @param failure_addr - * Pointer of the fault address of the sigbus error. - * - * @return - * 0 for success handle the sigbus for hot-unplug. - * 1 for not process it, because it is a generic sigbus error. - * -1 for failed to handle the sigbus for hot-unplug. - */ -typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr); - -/** - * Bus scan policies - */ -enum rte_bus_scan_mode { - RTE_BUS_SCAN_UNDEFINED, - RTE_BUS_SCAN_ALLOWLIST, - RTE_BUS_SCAN_BLOCKLIST, -}; - -/** - * A structure used to configure bus operations. - */ -struct rte_bus_conf { - enum rte_bus_scan_mode scan_mode; /**< Scan policy. */ -}; - - -/** - * Get common iommu class of the all the devices on the bus. The bus may - * check that those devices are attached to iommu driver. - * If no devices are attached to the bus. The bus may return with don't care - * (_DC) value. - * Otherwise, The bus will return appropriate _pa or _va iova mode. - * - * @return - * enum rte_iova_mode value. - */ -typedef enum rte_iova_mode (*rte_bus_get_iommu_class_t)(void); - - -/** - * A structure describing a generic bus. - */ -struct rte_bus { - RTE_TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */ - const char *name; /**< Name of the bus */ - rte_bus_scan_t scan; /**< Scan for devices attached to bus */ - rte_bus_probe_t probe; /**< Probe devices on bus */ - rte_bus_find_device_t find_device; /**< Find a device on the bus */ - rte_bus_plug_t plug; /**< Probe single device for drivers */ - rte_bus_unplug_t unplug; /**< Remove single device from driver */ - rte_bus_parse_t parse; /**< Parse a device name */ - rte_bus_devargs_parse_t devargs_parse; /**< Parse bus devargs */ - rte_dev_dma_map_t dma_map; /**< DMA map for device in the bus */ - rte_dev_dma_unmap_t dma_unmap; /**< DMA unmap for device in the bus */ - struct rte_bus_conf conf; /**< Bus configuration */ - rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */ - rte_dev_iterate_t dev_iterate; /**< Device iterator. */ - rte_bus_hot_unplug_handler_t hot_unplug_handler; - /**< handle hot-unplug failure on the bus */ - rte_bus_sigbus_handler_t sigbus_handler; - /**< handle sigbus error on the bus */ - -}; +struct rte_bus; +struct rte_device; /** * @warning @@ -279,24 +39,6 @@ struct rte_bus { __rte_experimental const char *rte_bus_name(const struct rte_bus *bus); -/** - * Register a Bus handler. - * - * @param bus - * A pointer to a rte_bus structure describing the bus - * to be registered. - */ -void rte_bus_register(struct rte_bus *bus); - -/** - * Unregister a Bus handler. - * - * @param bus - * A pointer to a rte_bus structure describing the bus - * to be unregistered. - */ -void rte_bus_unregister(struct rte_bus *bus); - /** * Scan all the buses. * @@ -386,17 +128,6 @@ struct rte_bus *rte_bus_find_by_name(const char *busname); */ enum rte_iova_mode rte_bus_get_iommu_class(void); -/** - * Helper for Bus registration. - * The constructor has higher priority than PMD constructors. - */ -#define RTE_REGISTER_BUS(nm, bus) \ -RTE_INIT_PRIO(businitfn_ ##nm, BUS) \ -{\ - (bus).name = RTE_STR(nm);\ - rte_bus_register(&bus); \ -} - #ifdef __cplusplus } #endif diff --git a/lib/eal/linux/eal_dev.c b/lib/eal/linux/eal_dev.c index 02ae1cde29..098a2c3076 100644 --- a/lib/eal/linux/eal_dev.c +++ b/lib/eal/linux/eal_dev.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/lib/eal/version.map b/lib/eal/version.map index 6f713c987d..48c8a2f511 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -13,9 +13,7 @@ DPDK_22 { rte_bus_find_by_name; rte_bus_get_iommu_class; rte_bus_probe; - rte_bus_register; rte_bus_scan; - rte_bus_unregister; rte_calloc; rte_calloc_socket; rte_cpu_get_flag_enabled; @@ -432,6 +430,8 @@ EXPERIMENTAL { INTERNAL { global: + rte_bus_register; + rte_bus_unregister; rte_eal_get_baseaddr; rte_firmware_read; rte_intr_allow_others; diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index c94d6573d5..6679bd8276 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include