From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 16E0EA0032; Wed, 14 Sep 2022 10:01:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B53E42B81; Wed, 14 Sep 2022 10:00:41 +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 5696142B71 for ; Wed, 14 Sep 2022 10:00:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663142439; 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=p1yX+axA12iwTRseEGGGZoMn0+oNGNGbMx4JXwORHNA=; b=OpR8YuGYUmN9CDKWBZmhCU8OUYgBbxJ3POAzxq8EsrEqxA+p2avd11VMxszBN5oEQR0R1B w97nax9YmS4B9EG5dAOM1M7x9ShDSni6UA+D1Jex+qekWcIQ+TvM0CRA5VEkQy4+hUmu4x 8fS3xz/2GbDblEu9RxQCUbAgpKE3Yeg= 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-351-SP1x86GHMcGRILJkGVGOMA-1; Wed, 14 Sep 2022 04:00:38 -0400 X-MC-Unique: SP1x86GHMcGRILJkGVGOMA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2AD55294EDC9; Wed, 14 Sep 2022 08:00:38 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4D63492CA2; Wed, 14 Sep 2022 08:00:36 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, bruce.richardson@intel.com, Aman Singh , Yuying Zhang , Ray Kinsella , Ferruh Yigit , Andrew Rybchenko Subject: [PATCH v6 22/27] dev: introduce driver accessors Date: Wed, 14 Sep 2022 09:58:36 +0200 Message-Id: <20220914075841.51555-23-david.marchand@redhat.com> In-Reply-To: <20220914075841.51555-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> <20220914075841.51555-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 driver object opaque by adding accessors. Update existing "external" users. Internal users may still dereference a rte_driver object. Signed-off-by: David Marchand Acked-by: Bruce Richardson --- app/test-pmd/config.c | 2 +- lib/eal/common/eal_common_dev.c | 6 ++++++ lib/eal/include/rte_dev.h | 15 +++++++++++++++ lib/eal/version.map | 3 +++ lib/ethdev/rte_ethdev.h | 2 +- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 7bd28ee3e8..6510f29c76 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -654,7 +654,7 @@ device_infos_display(const char *identifier) printf("\n%s Infos for device %s %s\n", info_border, dev->name, info_border); printf("Bus name: %s", rte_bus_name(dev->bus)); - printf("\nDriver name: %s", dev->driver->name); + printf("\nDriver name: %s", rte_driver_name(dev->driver)); printf("\nDevargs: %s", dev->devargs ? dev->devargs->args : ""); printf("\nConnect to socket: %d", dev->numa_node); diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c index 62a598957c..16c5aef1d8 100644 --- a/lib/eal/common/eal_common_dev.c +++ b/lib/eal/common/eal_common_dev.c @@ -19,6 +19,12 @@ #include "eal_private.h" #include "hotplug_mp.h" +const char * +rte_driver_name(const struct rte_driver *driver) +{ + return driver->name; +} + /** * The device event callback description. * diff --git a/lib/eal/include/rte_dev.h b/lib/eal/include/rte_dev.h index 2743c09320..ddea163cca 100644 --- a/lib/eal/include/rte_dev.h +++ b/lib/eal/include/rte_dev.h @@ -76,6 +76,21 @@ struct rte_driver { const char *alias; /**< Driver alias. */ }; +/** + * Retrieve a driver name. + * + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * @param driver + * A pointer to a driver structure. + * @return + * A pointer to the driver name string. + */ +__rte_experimental +const char * +rte_driver_name(const struct rte_driver *driver); + /* * Internal identifier length * Sufficiently large to allow for UUID or PCI address diff --git a/lib/eal/version.map b/lib/eal/version.map index 6ec15f1147..d10fd89458 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -423,6 +423,9 @@ EXPERIMENTAL { rte_thread_self; rte_thread_set_affinity_by_id; rte_thread_set_priority; + + # added in 22.11 + rte_driver_name; }; INTERNAL { diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 41d37e41b5..7556b94602 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -3380,7 +3380,7 @@ int rte_eth_macaddrs_get(uint16_t port_id, struct rte_ether_addr *ma, * exists for the device and the rte_eth_dev 'dev' has been populated * successfully with a call to it: * - * driver_name = dev->device->driver->name + * driver_name = rte_driver_name(dev->device->driver) * nb_rx_queues = dev->data->nb_rx_queues * nb_tx_queues = dev->data->nb_tx_queues * dev_flags = &dev->data->dev_flags -- 2.37.3