From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by dpdk.org (Postfix) with ESMTP id B466F567F for ; Mon, 6 Mar 2017 11:00:58 +0100 (CET) Received: by mail-wr0-f196.google.com with SMTP id u48so21046409wrc.1 for ; Mon, 06 Mar 2017 02:00:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=pvybLu98rrXykCMwL7awYLLBjNGKOiz07PYxFDuXXZg=; b=gBrt8lHGgq+2q9aa6BWgwYxsPrpSf7tnBqnz/Sw/e1aNc0Y4hKUae8Ho632tGw2vK0 wVKQdKqjuUOh41QXEJ4yHr65ZRzjGL5RAxKl9Twm1vf39Ve5oUxlWlUAibiOyPFK9zB8 8d62QCxQrERE+uEoSpbGy59lINYH2KNbQyJRsuh17fA2i40e2lRC4igwCBgKMTwe6Py8 8EF55HGW+uwRYTxIfu5OUKd0BYmWCUNI/c4c8PIjBP01yscowaX3TR4yRg0uTHAa71PU BkTTXaEesfqfyyVMwHzR33LNZUFulFU9XCXQh8gdo4mX2YMyyPYfB/1opy7xqSpQKljE Uy8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=pvybLu98rrXykCMwL7awYLLBjNGKOiz07PYxFDuXXZg=; b=pgjbZfzsfxwCn2g0r76eSIWuiT2GOLJ6ZgrS+72h8kMhfQbJ81tVJ0KLB7wRkgRonQ e7sGFRruHT2ZKQBsuUyYyxVno9F7+hEFWRR7UKL+ShI4d9Ku0hqkuleRA1W+eq4O/xP6 n72jRUtrwKVy1HVpDrYnCickkmM6X32yzUav01nMQsvC7eFUNiX7l+UvTTB4g89xGnt1 A9lXwyVGOWjWkDpvuSyy7lAwYwqHvPWkIDwFEv+4CgJ+YptbWgjwSGkpptZCvyjUctoo i0JJ2LzsJEz8C9PlQgIB/l5S9PEEpnHLdfpL6rLuZFNcgEgH3TCp9FIeJvb6jOaQGUT8 1/XA== X-Gm-Message-State: AMke39n1RO+vtvNiZNRowVvVjnC/zBfziEGJkS/EW9qA0cmVAjlAj74NmubWoBgsQvdjxA== X-Received: by 10.223.160.9 with SMTP id k9mr15233675wrk.123.1488794458295; Mon, 06 Mar 2017 02:00:58 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id u145sm3829237wmu.1.2017.03.06.02.00.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 02:00:57 -0800 (PST) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Mon, 6 Mar 2017 11:00:04 +0100 Message-Id: <1488794430-25179-13-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488794430-25179-1-git-send-email-jblunck@infradead.org> References: <1488794430-25179-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH 12/38] net/null: use ethdev allocation helper for virtual devices 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: Mon, 06 Mar 2017 10:00:58 -0000 Signed-off-by: Jan Blunck --- drivers/net/null/rte_eth_null.c | 50 ++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 14f35d7..226c2e4 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -479,8 +480,7 @@ static const struct eth_dev_ops ops = { static struct rte_vdev_driver pmd_null_drv; static int -eth_dev_null_create(const char *name, - const unsigned numa_node, +eth_dev_null_create(struct rte_vdev_device *dev, unsigned packet_size, unsigned packet_copy) { @@ -497,27 +497,25 @@ eth_dev_null_create(const char *name, 0xBE, 0xAC, 0x01, 0xFA }; - if (name == NULL) - return -EINVAL; + if (dev->device.numa_node == SOCKET_ID_ANY) + dev->device.numa_node = rte_socket_id(); RTE_LOG(INFO, PMD, "Creating null ethdev on numa socket %u\n", - numa_node); + dev->device.numa_node); /* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ - data = rte_zmalloc_socket(name, sizeof(*data), 0, numa_node); - if (data == NULL) - goto error; - - internals = rte_zmalloc_socket(name, sizeof(*internals), 0, numa_node); - if (internals == NULL) - goto error; + data = rte_zmalloc_socket(rte_vdev_device_name(dev), sizeof(*data), 0, + dev->device.numa_node); + if (!data) + return -ENOMEM; - /* reserve an ethdev entry */ - eth_dev = rte_eth_dev_allocate(name); - if (eth_dev == NULL) - goto error; + eth_dev = rte_eth_vdev_allocate(dev, sizeof(*internals)); + if (!eth_dev) { + rte_free(data); + return -ENOMEM; + } /* now put it all together * - store queue data in internals, @@ -528,6 +526,7 @@ eth_dev_null_create(const char *name, /* NOTE: we'll replace the data element, of originally allocated eth_dev * so the nulls are local per-process */ + internals = eth_dev->data->dev_private; internals->packet_size = packet_size; internals->packet_copy = packet_copy; internals->port_id = eth_dev->data->port_id; @@ -537,22 +536,16 @@ eth_dev_null_create(const char *name, rte_memcpy(internals->rss_key, default_rss_key, 40); - data->dev_private = internals; - data->port_id = eth_dev->data->port_id; + rte_memcpy(data, eth_dev->data, sizeof(*data)); data->nb_rx_queues = (uint16_t)nb_rx_queues; data->nb_tx_queues = (uint16_t)nb_tx_queues; data->dev_link = pmd_link; data->mac_addrs = ð_addr; - strncpy(data->name, eth_dev->data->name, strlen(eth_dev->data->name)); eth_dev->data = data; eth_dev->dev_ops = &ops; - eth_dev->driver = NULL; data->dev_flags = RTE_ETH_DEV_DETACHABLE; - data->kdrv = RTE_KDRV_NONE; - data->drv_name = pmd_null_drv.driver.name; - data->numa_node = numa_node; /* finally assign rx and tx ops */ if (packet_copy) { @@ -564,12 +557,6 @@ eth_dev_null_create(const char *name, } return 0; - -error: - rte_free(data); - rte_free(internals); - - return -1; } static inline int @@ -610,7 +597,6 @@ static int rte_pmd_null_probe(struct rte_vdev_device *dev) { const char *name, *params; - unsigned numa_node; unsigned packet_size = default_packet_size; unsigned packet_copy = default_packet_copy; struct rte_kvargs *kvlist = NULL; @@ -623,8 +609,6 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) params = rte_vdev_device_args(dev); RTE_LOG(INFO, PMD, "Initializing pmd_null for %s\n", name); - numa_node = rte_socket_id(); - if (params != NULL) { kvlist = rte_kvargs_parse(params, valid_arguments); if (kvlist == NULL) @@ -653,7 +637,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) "packet copy is %s\n", packet_size, packet_copy ? "enabled" : "disabled"); - ret = eth_dev_null_create(name, numa_node, packet_size, packet_copy); + ret = eth_dev_null_create(dev, packet_size, packet_copy); free_kvlist: if (kvlist) -- 2.7.4