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 BF266A054A; Mon, 5 Sep 2022 10:42:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A0A2342BAB; Mon, 5 Sep 2022 10:41:25 +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 3936B42BAB for ; Mon, 5 Sep 2022 10:41:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662367283; 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=fF6xC36YNmEG449oSchF93jcfFNNWhENlo+2dnTezXM=; b=VG0uob/7WWfVMJcNVMgOwnijIRO/YRe3tlSH6ckXA15qeI3zblQfOIL8TVeahDh9RR45TK CL0jlpFjaKPKGgWN+i9ZEYGScNkZ2miC4JuIbTshJmOquaYQd98adooEbmN2kQimxFnjWL PHQMYxNUjp3Aa7LGSscHp1UbS+YeryI= 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-593-ntf18eoYON-94dz3rB-7ZA-1; Mon, 05 Sep 2022 04:41:20 -0400 X-MC-Unique: ntf18eoYON-94dz3rB-7ZA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2FE6F84AF83; Mon, 5 Sep 2022 08:41:20 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.193.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id A91C89458A; Mon, 5 Sep 2022 08:41:18 +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 v5 22/27] dev: introduce driver accessors Date: Mon, 5 Sep 2022 10:39:28 +0200 Message-Id: <20220905083933.2506819-23-david.marchand@redhat.com> In-Reply-To: <20220905083933.2506819-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> <20220905083933.2506819-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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.2