From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 670DA1B60F for ; Fri, 13 Oct 2017 04:02:52 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2017 19:02:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,369,1503385200"; d="scan'208";a="909478795" Received: from dpdk06.sh.intel.com ([10.67.110.196]) by FMSMGA003.fm.intel.com with ESMTP; 12 Oct 2017 19:02:44 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: jblunck@infradead.org, bruce.richardson@intel.com, konstantin.ananyev@intel.com, pablo.de.lara.guarch@intel.com, thomas@monjalon.net, yliu@fridaylinux.org, maxime.coquelin@redhat.com, mtetsuyah@gmail.com, ferruh.yigit@intel.com, Jianfeng Tan Date: Fri, 13 Oct 2017 02:04:09 +0000 Message-Id: <1507860252-137510-2-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507860252-137510-1-git-send-email-jianfeng.tan@intel.com> References: <1507519229-80692-1-git-send-email-jianfeng.tan@intel.com> <1507860252-137510-1-git-send-email-jianfeng.tan@intel.com> Subject: [dpdk-dev] [PATCH v7 1/4] ethdev: support attach vdev in secondary process 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: Fri, 13 Oct 2017 02:02:53 -0000 When vdev driver requests an ethdev entry in secondary process, we will identify the correct entry in rte_eth_dev_data array and return the correct entry in the rte_eth_devices arrays. Signed-off-by: Jianfeng Tan --- lib/librte_ether/rte_ethdev_vdev.h | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h index 4d2c3e2..460749b 100644 --- a/lib/librte_ether/rte_ethdev_vdev.h +++ b/lib/librte_ether/rte_ethdev_vdev.h @@ -58,25 +58,29 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size) struct rte_eth_dev *eth_dev; const char *name = rte_vdev_device_name(dev); - eth_dev = rte_eth_dev_allocate(name); - if (!eth_dev) - return NULL; - - if (private_data_size) { - eth_dev->data->dev_private = rte_zmalloc_socket(name, - private_data_size, RTE_CACHE_LINE_SIZE, - dev->device.numa_node); - if (!eth_dev->data->dev_private) { - rte_eth_dev_release_port(eth_dev); + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + eth_dev = rte_eth_dev_allocate(name); + if (!eth_dev) return NULL; + + if (private_data_size) { + eth_dev->data->dev_private = rte_zmalloc_socket(name, + private_data_size, RTE_CACHE_LINE_SIZE, + dev->device.numa_node); + if (!eth_dev->data->dev_private) { + rte_eth_dev_release_port(eth_dev); + return NULL; + } } + } else { + eth_dev = rte_eth_dev_attach_secondary(name); } eth_dev->device = &dev->device; eth_dev->intr_handle = NULL; - eth_dev->data->kdrv = RTE_KDRV_NONE; eth_dev->data->numa_node = dev->device.numa_node; + return eth_dev; } -- 2.7.4