X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fkni%2Frte_eth_kni.c;h=fdd5925549bfee3dbfb9978d6108f0323a72e8a7;hb=9e5afc72c909;hp=e31b90920e4ba39a4489e45711aafe6291881dbf;hpb=cbc3661f8b496f73ec20b8f5354fa6c299eaa53f;p=dpdk.git diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index e31b90920e..fdd5925549 100644 --- a/drivers/net/kni/rte_eth_kni.c +++ b/drivers/net/kni/rte_eth_kni.c @@ -1,46 +1,17 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2017 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Intel Corporation */ #include #include #include -#include +#include #include #include #include #include -#include +#include /* Only single queue supported */ #define KNI_MAX_QUEUE_PER_PORT 1 @@ -90,7 +61,7 @@ static const struct rte_eth_link pmd_link = { .link_speed = ETH_SPEED_NUM_10G, .link_duplex = ETH_LINK_FULL_DUPLEX, .link_status = ETH_LINK_DOWN, - .link_autoneg = ETH_LINK_SPEED_AUTONEG, + .link_autoneg = ETH_LINK_AUTONEG, }; static int is_kni_initialized; @@ -178,7 +149,7 @@ eth_kni_dev_start(struct rte_eth_dev *dev) } if (internals->no_request_thread == 0) { - ret = pthread_create(&internals->thread, NULL, + ret = rte_ctrl_thread_create(&internals->thread, NULL, kni_handle_request, internals); if (ret) { RTE_LOG(ERR, PMD, @@ -230,7 +201,6 @@ eth_kni_dev_info(struct rte_eth_dev *dev __rte_unused, dev_info->max_rx_queues = KNI_MAX_QUEUE_PER_PORT; dev_info->max_tx_queues = KNI_MAX_QUEUE_PER_PORT; dev_info->min_rx_bufsize = 0; - dev_info->pci_dev = NULL; } static int @@ -366,25 +336,17 @@ eth_kni_create(struct rte_vdev_device *vdev, 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) - return NULL; - /* reserve an ethdev entry */ eth_dev = rte_eth_vdev_allocate(vdev, sizeof(*internals)); - if (eth_dev == NULL) { - rte_free(data); + if (!eth_dev) return NULL; - } internals = eth_dev->data->dev_private; - rte_memcpy(data, eth_dev->data, sizeof(*data)); + data = eth_dev->data; data->nb_rx_queues = 1; data->nb_tx_queues = 1; data->dev_link = pmd_link; @@ -392,7 +354,6 @@ eth_kni_create(struct rte_vdev_device *vdev, eth_random_addr(internals->eth_addr.addr_bytes); - eth_dev->data = data; eth_dev->dev_ops = ð_kni_ops; internals->no_request_thread = args->no_request_thread; @@ -443,6 +404,18 @@ eth_kni_probe(struct rte_vdev_device *vdev) params = rte_vdev_device_args(vdev); RTE_LOG(INFO, PMD, "Initializing eth_kni for %s\n", name); + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(params) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = ð_kni_ops; + return 0; + } + ret = eth_kni_kvargs_process(&args, params); if (ret < 0) return ret; @@ -488,7 +461,6 @@ eth_kni_remove(struct rte_vdev_device *vdev) rte_kni_release(internals->kni); rte_free(internals); - rte_free(eth_dev->data); rte_eth_dev_release_port(eth_dev);