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 13D9BA00C5; Thu, 28 Jul 2022 17:29:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4F19242BE6; Thu, 28 Jul 2022 17:28:35 +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 5A48D40689 for ; Thu, 28 Jul 2022 17:28:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659022113; 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=eGLsi4hxiyHSGlsqHYXmUdUO+SeY2VqFGZTJQG0QOII=; b=BewwMswEOhJVmJ81G8/5gkkRZflWwiC+KiqoW3YVV+gCxQMMKo2lirHk512yZ+342jhWDH MBH3D4btd50EQnTV3iNE2lzwV+CjTv5KgMgrwzl1ITIIuVIUIowZDSI5N8f/wAQvbKcPL/ PnuxOMi/s3nEd9oPIXi4zUwKnfRgIOE= 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-139-Kf9E1q5XMlSRqcoIOyuiCg-1; Thu, 28 Jul 2022 11:28:30 -0400 X-MC-Unique: Kf9E1q5XMlSRqcoIOyuiCg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C40343826A4F; Thu, 28 Jul 2022 15:28:29 +0000 (UTC) Received: from fchome.redhat.com (unknown [10.40.195.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 700F01415118; Thu, 28 Jul 2022 15:28:28 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Aman Singh , Yuying Zhang , Ray Kinsella , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Subject: [RFC v3 22/26] dev: introduce driver accessors Date: Thu, 28 Jul 2022 17:26:36 +0200 Message-Id: <20220728152640.547725-23-david.marchand@redhat.com> In-Reply-To: <20220728152640.547725-1-david.marchand@redhat.com> References: <20220628144643.1213026-1-david.marchand@redhat.com> <20220728152640.547725-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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 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 --- 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 24f9122558..fedf67fba1 100644 --- a/lib/eal/include/rte_dev.h +++ b/lib/eal/include/rte_dev.h @@ -62,6 +62,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 de9e970d4d..e9574f646f 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.36.1