From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 59F68D1E6 for ; Tue, 11 Apr 2017 17:45:12 +0200 (CEST) Received: by mail-wm0-f44.google.com with SMTP id u2so4130277wmu.0 for ; Tue, 11 Apr 2017 08:45:12 -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=QuKZNNh8vaftoppaxHNE141PvbbH/TM/ez6EiNkt/MI=; b=xZsrYM/eikQg6FX3VxL9EyTpL2kNM4rG8ooo5xZatCoOLNJikfjoMAYBJGSrMzuiD+ 6mA2fazsrw9zntq2Cb9xLSg96aWz4siAa13uKZr2fwdQzyVv/anS2dPQeMJO0xsHO1JL PWMDCBRCeDu9lUFARqJgK9/l9JYsA3r9Zn1iQrG1n7+YrPNYxgFgo2COKYQOSkC4k0K/ aUgxqys0Uj+l6zz9UKoNzsPsuk7a5ubOGgLgCpKwP+jogVffDLFcl3ijwJIynxFqKAvl Wv5mhe+EfQ4LHDIJBKfQ2EaAqbDcnYQ0NpBndYRmL5ns6yw1oKMVKmPQtUfYqfr+5suP BGHQ== 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=QuKZNNh8vaftoppaxHNE141PvbbH/TM/ez6EiNkt/MI=; b=K7NiVXjSVEZXqUSLWJTraq803NLTYFGsGcKcuzMN6661MgXDISn840vTW5cnoEGbTM HPJLzBAYRSSZej3sesmKWhLIXAvXMx8vxzWNLh41YC5qP359eOVa9ypA42LkLp2bXqiV jWBQTzVnYgpWZ6w9rkAii9tFd0ahzH9cUqSetCopAnxYlQQJYNdqF4sXfWnq2YYQX6Sn LLACESHetAzPZsJjic+hNlpIFMKp/33dMd0Bv4a8uOLtBfgttLYaSAHo4AOa8rFaZE9y sDlSA5GZG1bYqpLwq686LZuEwLzoywuoNJF9EnNZprFiuTf3Yc0zqH75akzD3iCL1kHr I73w== X-Gm-Message-State: AN3rC/4+REfpaZjbCR/yBuztsXJOIgFmPT/of2TLxDIVLgCOCRwEJZb0 HB5T/rFMvwEjNmpj X-Received: by 10.28.217.142 with SMTP id q136mr15906328wmg.48.1491925512014; Tue, 11 Apr 2017 08:45:12 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Apr 2017 08:45:11 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Tue, 11 Apr 2017 17:44:15 +0200 Message-Id: <709fb18078d04afbd77ab426f22243195a2ec357.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 08/42] net/af_packet: 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:13 -0000 From: Jan Blunck Signed-off-by: Jan Blunck --- drivers/net/af_packet/rte_eth_af_packet.c | 42 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 77536e8..6f6ba0c 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -539,18 +540,19 @@ open_packet_iface(const char *key __rte_unused, static struct rte_vdev_driver pmd_af_packet_drv; static int -rte_pmd_init_internals(const char *name, +rte_pmd_init_internals(struct rte_vdev_device *dev, const int sockfd, const unsigned nb_queues, unsigned int blocksize, unsigned int blockcnt, unsigned int framesize, unsigned int framecnt, - const unsigned numa_node, struct pmd_internals **internals, struct rte_eth_dev **eth_dev, struct rte_kvargs *kvlist) { + const char *name = rte_vdev_device_name(dev); + const unsigned int numa_node = dev->device.numa_node; struct rte_eth_dev_data *data = NULL; struct rte_kvargs_pair *pair = NULL; struct ifreq ifr; @@ -768,7 +770,7 @@ rte_pmd_init_internals(const char *name, } /* reserve an ethdev entry */ - *eth_dev = rte_eth_dev_allocate(name); + *eth_dev = rte_eth_vdev_allocate(dev, 0); if (*eth_dev == NULL) goto error; @@ -782,22 +784,16 @@ rte_pmd_init_internals(const char *name, (*internals)->nb_queues = nb_queues; + rte_memcpy(data, (*eth_dev)->data, sizeof(*data)); data->dev_private = *internals; - data->port_id = (*eth_dev)->data->port_id; data->nb_rx_queues = (uint16_t)nb_queues; data->nb_tx_queues = (uint16_t)nb_queues; data->dev_link = pmd_link; data->mac_addrs = &(*internals)->eth_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; (*eth_dev)->data->dev_flags = RTE_ETH_DEV_DETACHABLE; - (*eth_dev)->data->drv_name = pmd_af_packet_drv.driver.name; - (*eth_dev)->data->kdrv = RTE_KDRV_NONE; - (*eth_dev)->data->numa_node = numa_node; return 0; @@ -822,11 +818,11 @@ rte_pmd_init_internals(const char *name, } static int -rte_eth_from_packet(const char *name, +rte_eth_from_packet(struct rte_vdev_device *dev, int const *sockfd, - const unsigned numa_node, struct rte_kvargs *kvlist) { + const char *name = rte_vdev_device_name(dev); struct pmd_internals *internals = NULL; struct rte_eth_dev *eth_dev = NULL; struct rte_kvargs_pair *pair = NULL; @@ -909,11 +905,11 @@ rte_eth_from_packet(const char *name, RTE_LOG(INFO, PMD, "%s:\tframe size %d\n", name, framesize); RTE_LOG(INFO, PMD, "%s:\tframe count %d\n", name, framecount); - if (rte_pmd_init_internals(name, *sockfd, qpairs, - blocksize, blockcount, - framesize, framecount, - numa_node, &internals, ð_dev, - kvlist) < 0) + if (rte_pmd_init_internals(dev, *sockfd, qpairs, + blocksize, blockcount, + framesize, framecount, + &internals, ð_dev, + kvlist) < 0) return -1; eth_dev->rx_pkt_burst = eth_af_packet_rx; @@ -925,15 +921,12 @@ rte_eth_from_packet(const char *name, static int rte_pmd_af_packet_probe(struct rte_vdev_device *dev) { - const char *name = rte_vdev_device_name(dev); - unsigned numa_node; int ret = 0; struct rte_kvargs *kvlist; int sockfd = -1; - RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n", name); - - numa_node = rte_socket_id(); + RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n", + rte_vdev_device_name(dev)); kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) { @@ -953,7 +946,10 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev) goto exit; } - ret = rte_eth_from_packet(name, &sockfd, numa_node, kvlist); + if (dev->device.numa_node == SOCKET_ID_ANY) + dev->device.numa_node = rte_socket_id(); + + ret = rte_eth_from_packet(dev, &sockfd, kvlist); close(sockfd); /* no longer needed */ exit: -- 2.1.4