From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id F058C11A4 for ; Tue, 21 Jul 2015 17:16:45 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 21 Jul 2015 08:16:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,516,1432623600"; d="scan'208";a="527761646" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 21 Jul 2015 08:16:28 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t6LFGR37014018; Tue, 21 Jul 2015 16:16:27 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t6LFGRJl026728; Tue, 21 Jul 2015 16:16:27 +0100 Received: (from bairemon@localhost) by sivswdev01.ir.intel.com with id t6LFGRjS026724; Tue, 21 Jul 2015 16:16:27 +0100 From: Bernard Iremonger To: dev@dpdk.org Date: Tue, 21 Jul 2015 16:16:22 +0100 Message-Id: <1437491784-26676-2-git-send-email-bernard.iremonger@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1437491784-26676-1-git-send-email-bernard.iremonger@intel.com> References: <1437491784-26676-1-git-send-email-bernard.iremonger@intel.com> Subject: [dpdk-dev] [PATCH v6 1/3] bonding: add support for PCI Port Hotplug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2015 15:16:46 -0000 This patch depends on the Port Hotplug Framework. It implements the rte_dev_uninit_t() function for the link bonding pmd. Signed-off-by: Bernard Iremonger --- drivers/net/bonding/rte_eth_bond.h | 13 ++++- drivers/net/bonding/rte_eth_bond_api.c | 78 ++++++++++++++++++---------- drivers/net/bonding/rte_eth_bond_pmd.c | 23 +++++++- drivers/net/bonding/rte_eth_bond_private.h | 7 ++- drivers/net/bonding/rte_eth_bond_version.map | 1 + 5 files changed, 90 insertions(+), 32 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h index d688fc3..8efbf07 100644 --- a/drivers/net/bonding/rte_eth_bond.h +++ b/drivers/net/bonding/rte_eth_bond.h @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -131,6 +131,17 @@ int rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id); /** + * Free a bonded rte_eth_dev device + * + * @param name Name of the link bonding device. + * + * @return + * 0 on success, negative value otherwise + */ +int +rte_eth_bond_free(const char *name); + +/** * Add a rte_eth_dev device as a slave to the bonded device * * @param bonded_port_id Port ID of bonded device. diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index f602658..61ae7ef 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -163,7 +163,22 @@ number_of_sockets(void) return ++sockets; } -const char *pmd_bond_driver_name = "Link Bonding PMD"; +const char pmd_bond_driver_name[] = "rte_bond_pmd"; + +static struct rte_pci_id pci_id_table = { + .device_id = PCI_ANY_ID, + .subsystem_device_id = PCI_ANY_ID, + .vendor_id = PCI_ANY_ID, + .subsystem_vendor_id = PCI_ANY_ID, +}; + +static struct eth_driver rte_bond_pmd = { + .pci_drv = { + .name = pmd_bond_driver_name, + .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE, + .id_table = &pci_id_table, + }, +}; int rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) @@ -171,9 +186,8 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) struct rte_pci_device *pci_dev = NULL; struct bond_dev_private *internals = NULL; struct rte_eth_dev *eth_dev = NULL; - struct eth_driver *eth_drv = NULL; struct rte_pci_driver *pci_drv = NULL; - struct rte_pci_id *pci_id_table = NULL; + /* now do all data allocation - for eth_dev structure, dummy pci driver * and internal (private) data */ @@ -195,26 +209,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) goto err; } - eth_drv = rte_zmalloc_socket(name, sizeof(*eth_drv), 0, socket_id); - if (eth_drv == NULL) { - RTE_BOND_LOG(ERR, "Unable to malloc eth_drv on socket"); - goto err; - } - - pci_drv = ð_drv->pci_drv; - - pci_id_table = rte_zmalloc_socket(name, sizeof(*pci_id_table), 0, socket_id); - if (pci_id_table == NULL) { - RTE_BOND_LOG(ERR, "Unable to malloc pci_id_table on socket"); - goto err; - } - pci_id_table->device_id = PCI_ANY_ID; - pci_id_table->subsystem_device_id = PCI_ANY_ID; - pci_id_table->vendor_id = PCI_ANY_ID; - pci_id_table->subsystem_vendor_id = PCI_ANY_ID; - - pci_drv->id_table = pci_id_table; - pci_drv->drv_flags = RTE_PCI_DRV_INTR_LSC; + pci_drv = &rte_bond_pmd.pci_drv; internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id); if (internals == NULL) { @@ -233,7 +228,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) pci_drv->name = pmd_bond_driver_name; pci_dev->driver = pci_drv; - eth_dev->driver = eth_drv; + eth_dev->driver = &rte_bond_pmd; eth_dev->data->dev_private = internals; eth_dev->data->nb_rx_queues = (uint16_t)1; eth_dev->data->nb_tx_queues = (uint16_t)1; @@ -289,13 +284,42 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) err: rte_free(pci_dev); - rte_free(pci_id_table); - rte_free(eth_drv); rte_free(internals); + rte_free(eth_dev->data->mac_addrs); return -1; } +int +rte_eth_bond_free(const char *name) +{ + struct rte_eth_dev *eth_dev = NULL; + + /* now free all data allocation - for eth_dev structure, + * dummy pci driver and internal (private) data + */ + + /* find an ethdev entry */ + eth_dev = rte_eth_dev_allocated(name); + if (eth_dev == NULL) + return -ENODEV; + + if (eth_dev->data->dev_started == 1) + bond_ethdev_stop(eth_dev); + + eth_dev->dev_ops = NULL; + eth_dev->rx_pkt_burst = NULL; + eth_dev->tx_pkt_burst = NULL; + + rte_free(eth_dev->pci_dev); + rte_free(eth_dev->data->dev_private); + rte_free(eth_dev->data->mac_addrs); + + rte_eth_dev_release_port(eth_dev); + + return 0; +} + static int __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id) { diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 9cafe65..cad8f3c 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1512,7 +1512,7 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev) return 0; } -static void +void bond_ethdev_stop(struct rte_eth_dev *eth_dev) { struct bond_dev_private *internals = eth_dev->data->dev_private; @@ -2042,6 +2042,24 @@ parse_error: return -1; } +static int +bond_uninit(const char *name) +{ + int ret; + + if (name == NULL) + return -EINVAL; + + RTE_LOG(INFO, EAL, "Uninitializing pmd_bond for %s\n", name); + + /* free link bonding eth device */ + ret = rte_eth_bond_free(name); + if (ret < 0) + RTE_LOG(ERR, EAL, "Failed to free %s\n", name); + + return ret; +} + /* this part will resolve the slave portids after all the other pdev and vdev * have been allocated */ static int @@ -2268,6 +2286,7 @@ static struct rte_driver bond_drv = { .name = "eth_bond", .type = PMD_VDEV, .init = bond_init, + .uninit = bond_uninit, }; PMD_REGISTER_DRIVER(bond_drv); diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h index c531e87..205c642 100644 --- a/drivers/net/bonding/rte_eth_bond_private.h +++ b/drivers/net/bonding/rte_eth_bond_private.h @@ -1,7 +1,7 @@ /*- * BSD LICENSE * - * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,7 +62,7 @@ extern const char *pmd_bond_init_valid_arguments[]; -extern const char *pmd_bond_driver_name; +extern const char pmd_bond_driver_name[]; /** Port Queue Mapping Structure */ struct bond_rx_queue { @@ -284,4 +284,7 @@ bond_tlb_enable(struct bond_dev_private *internals); void bond_tlb_activate_slave(struct bond_dev_private *internals); +void +bond_ethdev_stop(struct rte_eth_dev *eth_dev); + #endif diff --git a/drivers/net/bonding/rte_eth_bond_version.map b/drivers/net/bonding/rte_eth_bond_version.map index 135999e..5519e11 100644 --- a/drivers/net/bonding/rte_eth_bond_version.map +++ b/drivers/net/bonding/rte_eth_bond_version.map @@ -5,6 +5,7 @@ DPDK_2.0 { rte_eth_bond_8023ad_setup; rte_eth_bond_active_slaves_get; rte_eth_bond_create; + rte_eth_bond_free; rte_eth_bond_link_monitoring_set; rte_eth_bond_mac_address_reset; rte_eth_bond_mac_address_set; -- 1.9.1