From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id B6191D1FE for ; Tue, 11 Apr 2017 17:45:18 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id o81so66908262wmb.1 for ; Tue, 11 Apr 2017 08:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=T5EKqSz5E3MfE/YBUaA7qmLTOzYLVRfuHsVUgThjepQ=; b=kJpTWfEOi9WUKPhWTseHWNvztivDYLo+HH4yBmtk7EBEdMUjHUmK9YG2n90ONfSJzk bnTnpOvNzHnv7MjcAs4JJX8xSumK4sY/UmwQgU9Pqyw++tKMoWIw33e1zgVirATNrsxv XXQW72tThYW4qy1WA6r0Td22P9p7asjLXAuhVWz2oAFcB1GmHqep0Vf3rrVMl2TbnQXY Rz0+9zfLovpTKkD+FJbF3yrjlkgueGOb1PN/B/FxT9apK7BzlpkfMjPZp5xfP7BeBe1/ RI6v4/sZMnrGewfRBn/Tja1+SlNDvgAr1lM/fJ0cCzaqh5QvHv1MgPHidA0Ot1eIA77X aR2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=T5EKqSz5E3MfE/YBUaA7qmLTOzYLVRfuHsVUgThjepQ=; b=HMr2KDbrKGabsPCNSiCtCDPvhkmXD7rF+TQ3qjxUZCO25XYjB+w2A2iCECyUo8YiJ3 stAlYjtAZcNt5g90pEt7+1+NIC5i2rHbYNr0KvT4DBsdIcd/HtOzD49IQuFVsTCh+2DM A7+ovGlXciSsZ+NShtn0IRTjARBUAQHixiSF1EzAmEOdwUEhaJ4SbfiFwNoKfEvHNj1O QICs7fxvuVeoAexcQ1OWZcZqeqoR+8N1BRZUF7v+ry/zWMF2kjgZvcW26gfRv+Xm3G5N rVYlkczy2woDMui8MZdY1jU7YmuBK4ibXIJb1xNdC4Bn/NS62N98boV6wzDh2VHjCSG6 xAkQ== X-Gm-Message-State: AN3rC/6Vwjf1yAbvL2D88f+g2zNAy3AsGhr7iNh4AH1rY33rnBd6ATZmvStJ/7xiuQOPVwpG X-Received: by 10.28.107.150 with SMTP id a22mr15829590wmi.81.1491925518093; Tue, 11 Apr 2017 08:45:18 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id u63sm2933738wmu.22.2017.04.11.08.45.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Apr 2017 08:45:17 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Tue, 11 Apr 2017 17:44:21 +0200 Message-Id: <8aa919105ac6435cf75a1f82d15ae64cdb3cd6c1.1491924900.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <1488794430-25179-1-git-send-email-jblunck@infradead.org> In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 14/42] net/kni: 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: Tue, 11 Apr 2017 15:45:19 -0000 Signed-off-by: Gaetan Rivet --- drivers/net/kni/rte_eth_kni.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index e3ce572..8f90034 100644 --- a/drivers/net/kni/rte_eth_kni.c +++ b/drivers/net/kni/rte_eth_kni.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -358,32 +359,32 @@ static const struct eth_dev_ops eth_kni_ops = { static struct rte_vdev_driver eth_kni_drv; static struct rte_eth_dev * -eth_kni_create(const char *name, struct eth_kni_args *args, +eth_kni_create(struct rte_vdev_device *vdev, + struct eth_kni_args *args, unsigned int numa_node) { - struct pmd_internals *internals = NULL; + struct pmd_internals *internals; struct rte_eth_dev_data *data; struct rte_eth_dev *eth_dev; + const char *name; RTE_LOG(INFO, PMD, "Creating kni ethdev on numa socket %u\n", numa_node); + name = rte_vdev_device_name(vdev); 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; + return NULL; /* reserve an ethdev entry */ - eth_dev = rte_eth_dev_allocate(name); - if (eth_dev == NULL) - goto error; + eth_dev = rte_eth_vdev_allocate(vdev, sizeof(*internals)); + if (eth_dev == NULL) { + rte_free(data); + return NULL; + } - data->dev_private = internals; - data->port_id = eth_dev->data->port_id; - memmove(data->name, eth_dev->data->name, sizeof(data->name)); + internals = eth_dev->data->dev_private; + rte_memcpy(data, eth_dev->data, sizeof(*data)); data->nb_rx_queues = 1; data->nb_tx_queues = 1; data->dev_link = pmd_link; @@ -393,22 +394,12 @@ eth_kni_create(const char *name, struct eth_kni_args *args, eth_dev->data = data; eth_dev->dev_ops = ð_kni_ops; - eth_dev->device->driver = NULL; data->dev_flags = RTE_ETH_DEV_DETACHABLE; - data->kdrv = RTE_KDRV_NONE; - data->drv_name = eth_kni_drv.driver.name; - data->numa_node = numa_node; internals->no_request_thread = args->no_request_thread; return eth_dev; - -error: - rte_free(data); - rte_free(internals); - - return NULL; } static int @@ -462,7 +453,7 @@ eth_kni_probe(struct rte_vdev_device *vdev) if (ret < 0) return ret; - eth_dev = eth_kni_create(name, &args, rte_socket_id()); + eth_dev = eth_kni_create(vdev, &args, rte_socket_id()); if (eth_dev == NULL) goto kni_uninit; -- 2.1.4