From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id A13B51B619 for ; Thu, 21 Jun 2018 04:00:36 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2018 19:00:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,249,1526367600"; d="scan'208";a="64993796" Received: from dpdk51.sh.intel.com ([10.67.110.190]) by fmsmga004.fm.intel.com with ESMTP; 20 Jun 2018 19:00:29 -0700 From: Qi Zhang To: thomas@monjalon.net, anatoly.burakov@intel.com Cc: konstantin.ananyev@intel.com, dev@dpdk.org, bruce.richardson@intel.com, ferruh.yigit@intel.com, benjamin.h.shelton@intel.com, narender.vangati@intel.com, Qi Zhang Date: Thu, 21 Jun 2018 10:00:39 +0800 Message-Id: <20180621020059.1198-3-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180621020059.1198-1-qi.z.zhang@intel.com> References: <20180607123849.14439-1-qi.z.zhang@intel.com> <20180621020059.1198-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2 02/22] bus/vdev: enable one device scan X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2018 02:00:38 -0000 The patch implemented the ops scan_one for vdev bus, it gives two benefits 1. Improve scan efficiency when a device is attached as hotplug, since no need to populate a new device by iterating all devargs in devargs_list. 2. It also avoid sync IPC invoke (which happens in vdev->scan on secondary process). The benefit is this removes the potential deadlock in the case when secondary process receive a request from primary process to attach a new device, since vdev->scan will be invoked on mp thread itself in that case. Signed-off-by: Qi Zhang --- v2: - improve commit log drivers/bus/vdev/vdev.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 6139dd551..cdbd77df0 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -467,6 +467,35 @@ vdev_scan(void) return 0; } +static struct rte_device *vdev_scan_one(struct rte_devargs *devargs) +{ + struct rte_vdev_device *dev = NULL; + + dev = calloc(1, sizeof(*dev)); + if (!dev) { + VDEV_LOG(ERR, "failed to allocate memory for new device"); + return NULL; + } + + rte_spinlock_recursive_lock(&vdev_device_list_lock); + + if (find_vdev(devargs->name)) { + VDEV_LOG(ERR, "device %s already exist", devargs->name); + free(dev); + rte_spinlock_recursive_unlock(&vdev_device_list_lock); + return NULL; + } + + dev->device.devargs = devargs; + dev->device.numa_node = SOCKET_ID_ANY; + dev->device.name = devargs->name; + TAILQ_INSERT_TAIL(&vdev_device_list, dev, next); + + rte_spinlock_recursive_unlock(&vdev_device_list_lock); + + return &dev->device; +} + static int vdev_probe(void) { @@ -531,6 +560,7 @@ vdev_unplug(struct rte_device *dev) static struct rte_bus rte_vdev_bus = { .scan = vdev_scan, + .scan_one = vdev_scan_one, .probe = vdev_probe, .find_device = vdev_find_device, .plug = vdev_plug, -- 2.13.6