From patchwork Fri Jun 9 17:51:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 25236 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id EFE65532D; Fri, 9 Jun 2017 19:51:32 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 90A3A3798 for ; Fri, 9 Jun 2017 19:51:28 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2017 10:51:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.39,319,1493708400"; d="scan'208"; a="1139701919" Received: from silpixa00372839.ir.intel.com (HELO silpixa00372839.ger.corp.intel.com) ([10.237.222.154]) by orsmga001.jf.intel.com with ESMTP; 09 Jun 2017 10:51:25 -0700 From: Ferruh Yigit To: Bruce Richardson Cc: dev@dpdk.org, Ferruh Yigit Date: Fri, 9 Jun 2017 18:51:19 +0100 Message-Id: <20170609175120.77652-2-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170609175120.77652-1-ferruh.yigit@intel.com> References: <20170606151008.62680-1-ferruh.yigit@intel.com> <20170609175120.77652-1-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH v3 2/3] net/ring: create vdev from PMD specific API 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When ring PMD created via PMD specific API instead of EAL abstraction it is missing the virtual device creation done by EAL vdev. And this makes eth_dev unusable exact same as other PMDs used, because of some missing fields, like rte_device->name. Now API creates a virtual device and sets proper fields, not all, and it still won't be linked in the virtual device list eal keeps track. But makes PMD usable in usual manner. Signed-off-by: Ferruh Yigit --- drivers/net/ring/rte_eth_ring.c | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 6feb137..a9355ff 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -365,6 +365,41 @@ do_eth_dev_ring_create(const char *name, return -1; } +static struct rte_vdev_device * +alloc_vdev(const char *name) +{ + struct rte_devargs *devargs = NULL; + struct rte_vdev_device *vdev = NULL; + int ret; + + devargs = calloc(1, sizeof(*devargs)); + if (!devargs) + goto out_free; + + vdev = calloc(1, sizeof(*vdev)); + if (!vdev) + goto out_free; + + devargs->type = RTE_DEVTYPE_VIRTUAL; + ret = snprintf(devargs->virt.drv_name, sizeof(devargs->virt.drv_name), + "%s", name); + if (ret < 0) + goto out_free; + + vdev->device.devargs = devargs; + vdev->device.numa_node = SOCKET_ID_ANY; + vdev->device.name = devargs->virt.drv_name; + + vdev->device.driver = &pmd_ring_drv.driver; + + return vdev; + +out_free: + free(devargs); + free(vdev); + return NULL; +} + int rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], const unsigned nb_rx_queues, @@ -373,6 +408,8 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], const unsigned numa_node) { struct rte_eth_dev *eth_dev = NULL; + struct rte_vdev_device *vdev; + int ret; /* do some parameter checking */ if (rx_queues == NULL && nb_rx_queues > 0) { @@ -388,9 +425,19 @@ rte_eth_from_rings(const char *name, struct rte_ring *const rx_queues[], return -1; } - return do_eth_dev_ring_create(name, rx_queues, nb_rx_queues, + vdev = alloc_vdev(name); + if (!vdev) { + rte_errno = EINVAL; + return -1; + } + + ret = do_eth_dev_ring_create(name, rx_queues, nb_rx_queues, tx_queues, nb_tx_queues, numa_node, DEV_ATTACH, ð_dev); + + eth_dev->device = &vdev->device; + + return ret; } int