From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id F02F5952 for ; Mon, 6 Mar 2017 11:00:51 +0100 (CET) Received: by mail-wr0-f193.google.com with SMTP id g10so21000328wrg.0 for ; Mon, 06 Mar 2017 02:00:51 -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=hXfkW8hFB3r0R43YJwpazffG543IhD1JWbt3cVr87+o=; b=Mn7YHBR3VVvYl5l6BTIyGFDoj/cxOyse9ekfu8SkQaFuakrkTX+eVitybncAlm5Azj wh92ArXzXYmKRb4Z1Kw733i8d1XHtAC/606JZzhrW7RItQvfD8vgT7yR7jVAjYJO7e7O RLQjDCiykkWoQ45lLjiOJiRKFofuv+6DDyz5GsVFO2sO8eA97f6VnU7ZjZVGuEkktSKK Oj1nK4dQzSkyKSEQuL2JVFk37TrA1MVpzTqg3P4MQdUSJf0JVJXV5/v7W/3/P0EVyviq OwEXf0rvrdlOzLreROVVvoy+V8CXoJXlCjSvX82rUyKRIFx6Ts0Qa9hloyiTh9LA0gOR SPrg== 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=hXfkW8hFB3r0R43YJwpazffG543IhD1JWbt3cVr87+o=; b=quyvaGNPoQOF6/79N77ttr9xtEp2s3BL/xQxx/TxeF1s7PVB/l4RzebJaDORSSdVAW GGfhMudxTQtwe/oQLTHBjcc7GvxBy3AxkGgrnNq8AKAw21eQIn/j1HedEcyIh9JKFCE9 7edPkqpVZpfZ8EGGmqp4Zfnm5fopyQE2SHVfr1YiqEc9HR0MuLiVnwq5gZrzBbohIOWg bEVZVFsNhpmJ6OPTLtltxxqJsomjnMmJ3iXS1b0xpVJ+NIhf4HTOF2SyZOMv/OaBC0Gr 5EMToYAmy6C+WS4Df1LxyNGNYinaZS2tTLurX+gLyLbyo8cxGL7SAXE0p3AF/bRTdayQ A9gg== X-Gm-Message-State: AMke39lAjjNBty89Agll0s0q7UA50F/hbcmRBbI+0ngunRGJHpAB36+R/AUVvG6OQsQPpQ== X-Received: by 10.223.151.5 with SMTP id r5mr15067182wrb.97.1488794451498; Mon, 06 Mar 2017 02:00:51 -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.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 02:00:50 -0800 (PST) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Date: Mon, 6 Mar 2017 10:59:58 +0100 Message-Id: <1488794430-25179-7-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 06/38] net/tap: 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:52 -0000 Signed-off-by: Jan Blunck --- drivers/net/tap/rte_eth_tap.c | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 941150f..f6f025f 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -641,12 +642,12 @@ static const struct eth_dev_ops ops = { }; static int -eth_dev_tap_create(const char *name, char *tap_name) +eth_dev_tap_create(struct rte_vdev_device *vdev, char *tap_name) { int numa_node = rte_socket_id(); - struct rte_eth_dev *dev = NULL; - struct pmd_internals *pmd = NULL; - struct rte_eth_dev_data *data = NULL; + struct rte_eth_dev *dev; + struct pmd_internals *pmd; + struct rte_eth_dev_data *data; int i; RTE_LOG(DEBUG, PMD, " TAP device on numa %u\n", rte_socket_id()); @@ -657,30 +658,19 @@ eth_dev_tap_create(const char *name, char *tap_name) goto error_exit; } - pmd = rte_zmalloc_socket(tap_name, sizeof(*pmd), 0, numa_node); - if (!pmd) { - RTE_LOG(ERR, PMD, "TAP Unable to allocate internal struct\n"); - goto error_exit; - } - - dev = rte_eth_dev_allocate(tap_name); + dev = rte_eth_vdev_allocate(vdev, sizeof(*pmd)); if (!dev) { RTE_LOG(ERR, PMD, "TAP Unable to allocate device struct\n"); goto error_exit; } + pmd = dev->data->dev_private; snprintf(pmd->name, sizeof(pmd->name), "%s", tap_name); - pmd->nb_queues = RTE_PMD_TAP_MAX_QUEUES; /* Setup some default values */ - data->dev_private = pmd; - data->port_id = dev->data->port_id; + rte_memcpy(data, dev->data, sizeof(*data)); data->dev_flags = RTE_ETH_DEV_DETACHABLE; - data->kdrv = RTE_KDRV_NONE; - data->drv_name = pmd_tap_drv.driver.name; - data->numa_node = numa_node; - data->dev_link = pmd_link; data->mac_addrs = &pmd->eth_addr; data->nb_rx_queues = pmd->nb_queues; @@ -688,10 +678,8 @@ eth_dev_tap_create(const char *name, char *tap_name) dev->data = data; dev->dev_ops = &ops; - dev->driver = NULL; dev->rx_pkt_burst = pmd_rx_burst; dev->tx_pkt_burst = pmd_tx_burst; - snprintf(dev->data->name, sizeof(dev->data->name), "%s", name); /* Presetup the fds to -1 as being not valid */ for (i = 0; i < RTE_PMD_TAP_MAX_QUEUES; i++) { @@ -702,13 +690,10 @@ eth_dev_tap_create(const char *name, char *tap_name) return 0; error_exit: - RTE_LOG(DEBUG, PMD, "TAP Unable to initialize %s\n", name); + RTE_LOG(DEBUG, PMD, "TAP Unable to initialize %s\n", + rte_vdev_device_name(vdev)); rte_free(data); - rte_free(pmd); - - rte_eth_dev_release_port(dev); - return -EINVAL; } @@ -785,7 +770,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) RTE_LOG(NOTICE, PMD, "Initializing pmd_tap for %s as %s\n", name, tap_name); - ret = eth_dev_tap_create(name, tap_name); + ret = eth_dev_tap_create(dev, tap_name); leave: if (ret == -1) { -- 2.7.4