From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by dpdk.org (Postfix) with ESMTP id 4C9BF6A71 for ; Tue, 11 Apr 2017 17:44:39 +0200 (CEST) Received: by mail-wm0-f48.google.com with SMTP id w64so67194329wma.0 for ; Tue, 11 Apr 2017 08:44:39 -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=PaMOe/allOAMF6fLEFFcgJSN5gfTBbzzSXWv5fwzlBg=; b=IwRf+VC7JCh9aff/uOBQSQ3dogHqPf+PptaELMPFkMJMsLp1oykOT/pcaw91RVhnTT M+oQduuNgO7MWSflDeGdWuR+7lf6R5mSS9JlwlD7mToieLUENzH+xCsHDqET8OigYTfG z/vpNMUqY90SmxQxy6gLfkXWU+s/QORxliksaWZ5H9aFwiKmHPMIyityG1mC56tiWagW ce8gA3duVNxMXDvGw3DXmSw8s+iKA7jt9SLEitQ/nFh0VnjplHLH3+3otTdyo8bQxMRF 18ol5ln08Y1db7Y33dfQZTX6PWDrKQrA81qf20wKJ/H4HgZwvjmnmINlCAohyRlci//c X+2w== 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=PaMOe/allOAMF6fLEFFcgJSN5gfTBbzzSXWv5fwzlBg=; b=mH5fbxjEOmdvQB+kovflIlT4pr4tTuln+1RRYUyACy9ndwVC+j1EmydC213OLapy/o ONnQ39AlBeihPUvSQ942lTUTzUInieviswX3Bc/ITUedhST4oPxqmph1p8CVCiFiK5eB 7NVtHEspS9mzSzHgvFLaENETRhtiqC7Omf90XwvVQei9K1fZSFz+n1CjSrDgnNP7yCw+ PrWas6QITkyX92em/YDN+Oef6hBs8nUBEsdcr1gIToaKRjmHGStOaftoHvNEhC7tbXu6 YfBHDe0aIMLnVlWwgXtV/CWL1LxPPgXOHN/Wn5y3lyobnlI6MHdgDdxJMvEH8qSJnDDV VkkQ== X-Gm-Message-State: AN3rC/4jYdknowgPoB728QUs4Pgs5hxWIlMxPLW9Pa9VdtupWryB0ujZ 4iTOuTSOo729+Cvcy9o= X-Received: by 10.28.197.135 with SMTP id v129mr9731743wmf.55.1491925478578; Tue, 11 Apr 2017 08:44:38 -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 v14sm2936830wmv.24.2017.04.11.08.44.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Apr 2017 08:44:37 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Tue, 11 Apr 2017 17:44:13 +0200 Message-Id: <7995dd60b1f09f12a9fe8a13eca3a1df0d4df90f.1491925092.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <1488797809-12917-1-git-send-email-jblunck@infradead.org> In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 09/12] eal: make virtual driver probe and remove take rte_vdev_device 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:44:40 -0000 From: Jan Blunck This is a preparation to embed the generic rte_device into the rte_eth_dev also for virtual devices. Signed-off-by: Jan Blunck --- drivers/crypto/null/null_crypto_pmd.c | 18 ++++++++++++------ drivers/net/af_packet/rte_eth_af_packet.c | 11 ++++++----- drivers/net/bonding/rte_eth_bond_pmd.c | 13 +++++++++---- drivers/net/null/rte_eth_null.c | 13 ++++++++----- drivers/net/pcap/rte_eth_pcap.c | 12 +++++++----- drivers/net/ring/rte_eth_ring.c | 9 +++++++-- drivers/net/tap/rte_eth_tap.c | 10 +++++++--- drivers/net/vhost/rte_eth_vhost.c | 10 +++++++--- drivers/net/virtio/virtio_user_ethdev.c | 18 +++++++----------- drivers/net/xenvirt/rte_eth_xenvirt.c | 9 +++++---- lib/librte_eal/common/eal_common_vdev.c | 7 +++---- lib/librte_eal/common/include/rte_vdev.h | 4 ++-- 12 files changed, 80 insertions(+), 54 deletions(-) diff --git a/drivers/crypto/null/null_crypto_pmd.c b/drivers/crypto/null/null_crypto_pmd.c index f68ec8d..a44c61a 100644 --- a/drivers/crypto/null/null_crypto_pmd.c +++ b/drivers/crypto/null/null_crypto_pmd.c @@ -218,8 +218,7 @@ cryptodev_null_create(struct rte_crypto_vdev_init_params *init_params) /** Initialise null crypto device */ static int -cryptodev_null_probe(const char *name, - const char *input_args) +cryptodev_null_probe(struct rte_vdev_device *dev) { struct rte_crypto_vdev_init_params init_params = { RTE_CRYPTODEV_VDEV_DEFAULT_MAX_NB_QUEUE_PAIRS, @@ -228,10 +227,11 @@ cryptodev_null_probe(const char *name, {0} }; - rte_cryptodev_parse_vdev_init_params(&init_params, input_args); + rte_cryptodev_parse_vdev_init_params(&init_params, + rte_vdev_device_args(dev)); - RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name, - init_params.socket_id); + RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", + rte_vdev_device_name(dev), init_params.socket_id); if (init_params.name[0] != '\0') RTE_LOG(INFO, PMD, " User defined name = %s\n", init_params.name); @@ -256,9 +256,15 @@ cryptodev_null_remove(const char *name) return 0; } +static int +cryptodev_null_remove_dev(struct rte_vdev_device *dev) +{ + return cryptodev_null_remove(rte_vdev_device_name(dev)); +} + static struct rte_vdev_driver cryptodev_null_pmd_drv = { .probe = cryptodev_null_probe, - .remove = cryptodev_null_remove + .remove = cryptodev_null_remove_dev, }; RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_NULL_PMD, cryptodev_null_pmd_drv); diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 2f87553..77536e8 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -923,8 +923,9 @@ rte_eth_from_packet(const char *name, } static int -rte_pmd_af_packet_probe(const char *name, const char *params) +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; @@ -934,7 +935,7 @@ rte_pmd_af_packet_probe(const char *name, const char *params) numa_node = rte_socket_id(); - kvlist = rte_kvargs_parse(params, valid_arguments); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) { ret = -1; goto exit; @@ -961,7 +962,7 @@ rte_pmd_af_packet_probe(const char *name, const char *params) } static int -rte_pmd_af_packet_remove(const char *name) +rte_pmd_af_packet_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; struct pmd_internals *internals; @@ -970,11 +971,11 @@ rte_pmd_af_packet_remove(const char *name) RTE_LOG(INFO, PMD, "Closing AF_PACKET ethdev on numa socket %u\n", rte_socket_id()); - if (name == NULL) + if (dev == NULL) return -1; /* find the ethdev entry */ - eth_dev = rte_eth_dev_allocated(name); + eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (eth_dev == NULL) return -1; diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 77d3bee..340d793 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -2240,16 +2240,19 @@ const struct eth_dev_ops default_dev_ops = { }; static int -bond_probe(const char *name, const char *params) +bond_probe(struct rte_vdev_device *dev) { + const char *name; struct bond_dev_private *internals; struct rte_kvargs *kvlist; uint8_t bonding_mode, socket_id; int arg_count, port_id; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, EAL, "Initializing pmd_bond for %s\n", name); - kvlist = rte_kvargs_parse(params, pmd_bond_init_valid_arguments); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), + pmd_bond_init_valid_arguments); if (kvlist == NULL) return -1; @@ -2307,13 +2310,15 @@ bond_probe(const char *name, const char *params) } static int -bond_remove(const char *name) +bond_remove(struct rte_vdev_device *dev) { + const char *name; int ret; - if (name == NULL) + if (!dev) return -EINVAL; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, EAL, "Uninitializing pmd_bond for %s\n", name); /* free link bonding eth device */ diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 7e14da0..a7b57bc 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -606,17 +606,20 @@ get_packet_copy_arg(const char *key __rte_unused, } static int -rte_pmd_null_probe(const char *name, const char *params) +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; int ret; - if (name == NULL) + if (!dev) return -EINVAL; + name = rte_vdev_device_name(dev); + params = rte_vdev_device_args(dev); RTE_LOG(INFO, PMD, "Initializing pmd_null for %s\n", name); numa_node = rte_socket_id(); @@ -658,18 +661,18 @@ rte_pmd_null_probe(const char *name, const char *params) } static int -rte_pmd_null_remove(const char *name) +rte_pmd_null_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; - if (name == NULL) + if (!dev) return -EINVAL; RTE_LOG(INFO, PMD, "Closing null ethdev on numa socket %u\n", rte_socket_id()); /* find the ethdev entry */ - eth_dev = rte_eth_dev_allocated(name); + eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (eth_dev == NULL) return -1; diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 075e3be..05cbd47 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -936,8 +936,9 @@ eth_from_pcaps(const char *name, struct pmd_devargs *rx_queues, } static int -pmd_pcap_probe(const char *name, const char *params) +pmd_pcap_probe(struct rte_vdev_device *dev) { + const char *name; unsigned int is_rx_pcap = 0, is_tx_pcap = 0; struct rte_kvargs *kvlist; struct pmd_devargs pcaps = {0}; @@ -945,13 +946,14 @@ pmd_pcap_probe(const char *name, const char *params) int single_iface = 0; int ret; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, PMD, "Initializing pmd_pcap for %s\n", name); gettimeofday(&start_time, NULL); start_cycles = rte_get_timer_cycles(); hz = rte_get_timer_hz(); - kvlist = rte_kvargs_parse(params, valid_arguments); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) return -1; @@ -1035,18 +1037,18 @@ pmd_pcap_probe(const char *name, const char *params) } static int -pmd_pcap_remove(const char *name) +pmd_pcap_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; RTE_LOG(INFO, PMD, "Closing pcap ethdev on numa socket %u\n", rte_socket_id()); - if (name == NULL) + if (!dev) return -1; /* reserve an ethdev entry */ - eth_dev = rte_eth_dev_allocated(name); + eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (eth_dev == NULL) return -1; diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 77ef3a1..4bae895 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -502,12 +502,16 @@ static int parse_kvlist (const char *key __rte_unused, const char *value, void * } static int -rte_pmd_ring_probe(const char *name, const char *params) +rte_pmd_ring_probe(struct rte_vdev_device *dev) { + const char *name, *params; struct rte_kvargs *kvlist = NULL; int ret = 0; struct node_action_list *info = NULL; + name = rte_vdev_device_name(dev); + params = rte_vdev_device_args(dev); + RTE_LOG(INFO, PMD, "Initializing pmd_ring for %s\n", name); if (params == NULL || params[0] == '\0') { @@ -577,8 +581,9 @@ rte_pmd_ring_probe(const char *name, const char *params) } static int -rte_pmd_ring_remove(const char *name) +rte_pmd_ring_remove(struct rte_vdev_device *dev) { + const char *name = rte_vdev_device_name(dev); struct rte_eth_dev *eth_dev = NULL; struct pmd_internals *internals = NULL; struct ring_queue *r = NULL; diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 347a807..698e14b 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -1288,14 +1288,18 @@ set_remote_iface(const char *key __rte_unused, /* Open a TAP interface device. */ static int -rte_pmd_tap_probe(const char *name, const char *params) +rte_pmd_tap_probe(struct rte_vdev_device *dev) { + const char *name, *params; int ret; struct rte_kvargs *kvlist = NULL; int speed; char tap_name[RTE_ETH_NAME_MAX_LEN]; char remote_iface[RTE_ETH_NAME_MAX_LEN]; + name = rte_vdev_device_name(dev); + params = rte_vdev_device_args(dev); + speed = ETH_SPEED_NUM_10G; snprintf(tap_name, sizeof(tap_name), "%s%d", DEFAULT_TAP_NAME, tap_unit++); @@ -1355,7 +1359,7 @@ rte_pmd_tap_probe(const char *name, const char *params) /* detach a TAP device. */ static int -rte_pmd_tap_remove(const char *name) +rte_pmd_tap_remove(struct rte_vdev_device *dev) { struct rte_eth_dev *eth_dev = NULL; struct pmd_internals *internals; @@ -1365,7 +1369,7 @@ rte_pmd_tap_remove(const char *name) rte_socket_id()); /* find the ethdev entry */ - eth_dev = rte_eth_dev_allocated(name); + eth_dev = rte_eth_dev_allocated(rte_vdev_device_name(dev)); if (!eth_dev) return 0; diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 41ce5fc..cdd8c31 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -1132,8 +1132,9 @@ open_int(const char *key __rte_unused, const char *value, void *extra_args) } static int -rte_pmd_vhost_probe(const char *name, const char *params) +rte_pmd_vhost_probe(struct rte_vdev_device *dev) { + const char *name; struct rte_kvargs *kvlist = NULL; int ret = 0; char *iface_name; @@ -1142,9 +1143,10 @@ rte_pmd_vhost_probe(const char *name, const char *params) int client_mode = 0; int dequeue_zero_copy = 0; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", name); - kvlist = rte_kvargs_parse(params, valid_arguments); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) return -1; @@ -1195,11 +1197,13 @@ rte_pmd_vhost_probe(const char *name, const char *params) } static int -rte_pmd_vhost_remove(const char *name) +rte_pmd_vhost_remove(struct rte_vdev_device *dev) { + const char *name; struct rte_eth_dev *eth_dev = NULL; unsigned int i; + name = rte_vdev_device_name(dev); RTE_LOG(INFO, PMD, "Un-Initializing pmd_vhost for %s\n", name); /* find an ethdev entry */ diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 35717f7..46276ee 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -402,7 +402,7 @@ virtio_user_eth_dev_free(struct rte_eth_dev *eth_dev) * Returns 0 on success. */ static int -virtio_user_pmd_probe(const char *name, const char *params) +virtio_user_pmd_probe(struct rte_vdev_device *dev) { struct rte_kvargs *kvlist = NULL; struct rte_eth_dev *eth_dev; @@ -415,13 +415,7 @@ virtio_user_pmd_probe(const char *name, const char *params) char *mac_addr = NULL; int ret = -1; - if (!params || params[0] == '\0') { - PMD_INIT_LOG(ERR, "arg %s is mandatory for virtio_user", - VIRTIO_USER_ARG_QUEUE_SIZE); - goto end; - } - - kvlist = rte_kvargs_parse(params, valid_args); + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_args); if (!kvlist) { PMD_INIT_LOG(ERR, "error when parsing param"); goto end; @@ -506,7 +500,7 @@ virtio_user_pmd_probe(const char *name, const char *params) goto end; } - eth_dev = virtio_user_eth_dev_alloc(name); + eth_dev = virtio_user_eth_dev_alloc(rte_vdev_device_name(dev)); if (!eth_dev) { PMD_INIT_LOG(ERR, "virtio_user fails to alloc device"); goto end; @@ -542,15 +536,17 @@ virtio_user_pmd_probe(const char *name, const char *params) /** Called by rte_eth_dev_detach() */ static int -virtio_user_pmd_remove(const char *name) +virtio_user_pmd_remove(struct rte_vdev_device *vdev) { + const char *name; struct rte_eth_dev *eth_dev; struct virtio_hw *hw; struct virtio_user_dev *dev; - if (!name) + if (!vdev) return -EINVAL; + name = rte_vdev_device_name(vdev); PMD_DRV_LOG(INFO, "Un-Initializing %s", name); eth_dev = rte_eth_dev_allocated(name); if (!eth_dev) diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c index 19bc09a..6ec8c08 100644 --- a/drivers/net/xenvirt/rte_eth_xenvirt.c +++ b/drivers/net/xenvirt/rte_eth_xenvirt.c @@ -726,7 +726,7 @@ eth_dev_xenvirt_free(const char *name, const unsigned numa_node) /*TODO: Support multiple process model */ static int -rte_pmd_xenvirt_probe(const char *name, const char *params) +rte_pmd_xenvirt_probe(struct rte_vdev_device *dev) { if (virtio_idx == 0) { if (xenstore_init() != 0) { @@ -738,14 +738,15 @@ rte_pmd_xenvirt_probe(const char *name, const char *params) return -1; } } - eth_dev_xenvirt_create(name, params, rte_socket_id(), DEV_CREATE); + eth_dev_xenvirt_create(rte_vdev_device_name(dev), + rte_vdev_device_args(dev), rte_socket_id(), DEV_CREATE); return 0; } static int -rte_pmd_xenvirt_remove(const char *name) +rte_pmd_xenvirt_remove(struct rte_vdev_device *dev) { - eth_dev_xenvirt_free(name, rte_socket_id()); + eth_dev_xenvirt_free(rte_vdev_device_name(dev), rte_socket_id()); if (virtio_idx == 0) { if (xenstore_uninit() != 0) diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 70da608..22fe2ca 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -76,7 +76,6 @@ static int vdev_probe_all_drivers(struct rte_vdev_device *dev) { const char *name = rte_vdev_device_name(dev); - const char *args = rte_vdev_device_args(dev); struct rte_vdev_driver *driver; int ret; @@ -90,7 +89,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) if (!strncmp(driver->driver.name, name, strlen(driver->driver.name))) { dev->device.driver = &driver->driver; - ret = driver->probe(name, args); + ret = driver->probe(dev); if (ret) dev->device.driver = NULL; return ret; @@ -103,7 +102,7 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) !strncmp(driver->driver.alias, name, strlen(driver->driver.alias))) { dev->device.driver = &driver->driver; - ret = driver->probe(name, args); + ret = driver->probe(dev); if (ret) dev->device.driver = NULL; return ret; @@ -215,7 +214,7 @@ vdev_remove_driver(struct rte_vdev_device *dev) driver = container_of(dev->device.driver, const struct rte_vdev_driver, driver); - return driver->remove(name); + return driver->remove(dev); } int diff --git a/lib/librte_eal/common/include/rte_vdev.h b/lib/librte_eal/common/include/rte_vdev.h index 81f6beb..8db2c00 100644 --- a/lib/librte_eal/common/include/rte_vdev.h +++ b/lib/librte_eal/common/include/rte_vdev.h @@ -68,12 +68,12 @@ TAILQ_HEAD(vdev_driver_list, rte_vdev_driver); /** * Probe function called for each virtual device driver once. */ -typedef int (rte_vdev_probe_t)(const char *name, const char *args); +typedef int (rte_vdev_probe_t)(struct rte_vdev_device *dev); /** * Remove function called for each virtual device driver once. */ -typedef int (rte_vdev_remove_t)(const char *name); +typedef int (rte_vdev_remove_t)(struct rte_vdev_device *dev); /** * A virtual device driver abstraction. -- 2.1.4