From: Neil Horman <nhorman@tuxdriver.com>
To: Bernard Iremonger <bernard.iremonger@intel.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [RFC PATCH] librte_pmd_bond: add support for PCI Port Hotplug
Date: Fri, 1 May 2015 11:17:16 -0400 [thread overview]
Message-ID: <20150501151716.GA27756@hmsreliant.think-freely.org> (raw)
In-Reply-To: <1430490979-1994-1-git-send-email-bernard.iremonger@intel.com>
On Fri, May 01, 2015 at 03:36:19PM +0100, Bernard Iremonger wrote:
> 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 <bernard.iremonger@intel.com>
> ---
> lib/librte_pmd_bond/rte_eth_bond.h | 13 ++++-
> lib/librte_pmd_bond/rte_eth_bond_api.c | 84 ++++++++++++++++++++--------
> lib/librte_pmd_bond/rte_eth_bond_pmd.c | 23 +++++++-
> lib/librte_pmd_bond/rte_eth_bond_private.h | 5 +-
> 4 files changed, 97 insertions(+), 28 deletions(-)
>
> diff --git a/lib/librte_pmd_bond/rte_eth_bond.h b/lib/librte_pmd_bond/rte_eth_bond.h
> index d688fc3..8efbf07 100644
> --- a/lib/librte_pmd_bond/rte_eth_bond.h
> +++ b/lib/librte_pmd_bond/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
> *
You need to add the free routine to the version map, or shared libraries won't
work. You need to test with shared libraries as well.
> * @param bonded_port_id Port ID of bonded device.
> diff --git a/lib/librte_pmd_bond/rte_eth_bond_api.c b/lib/librte_pmd_bond/rte_eth_bond_api.c
> index e91a623..b91ef24 100644
> --- a/lib/librte_pmd_bond/rte_eth_bond_api.c
> +++ b/lib/librte_pmd_bond/rte_eth_bond_api.c
> @@ -44,6 +44,13 @@
>
> #define DEFAULT_POLLING_INTERVAL_10_MS (10)
>
> +static struct eth_driver rte_bond_pmd = {
> + .pci_drv = {
> + .name = "rte_bond_pmd",
> + .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_DETACHABLE,
> + },
> +};
> +
> int
> valid_bonded_ethdev(struct rte_eth_dev *eth_dev)
> {
> @@ -193,6 +200,7 @@ number_of_sockets(void)
> }
>
> const char *driver_name = "Link Bonding PMD";
> +static struct rte_pci_id pci_id_table = {0};
>
> int
> rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
> @@ -200,9 +208,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
> */
> @@ -224,26 +231,14 @@ 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 = &rte_bond_pmd.pci_drv;
>
> - pci_drv = ð_drv->pci_drv;
> + 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_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->id_table = &pci_id_table;
>
> internals = rte_zmalloc_socket(name, sizeof(*internals), 0, socket_id);
> if (internals == NULL) {
> @@ -260,8 +255,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
>
> pci_dev->numa_node = socket_id;
> pci_drv->name = driver_name;
> -
> - 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;
> @@ -317,13 +311,55 @@ 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;
> + struct bond_dev_private *internals = 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;
> +
> + internals = eth_dev->data->dev_private;
> + rte_spinlock_lock(&internals->lock);
> +
> + if (internals->mode == BONDING_MODE_8023AD) {
> + bond_mode_8023ad_stop(eth_dev);
> + bond_mode_8023ad_deactivate_slave(eth_dev, internals->port_id);
> + } else if (internals->mode == BONDING_MODE_TLB
> + || internals->mode == BONDING_MODE_ALB)
> + bond_tlb_disable(internals);
> +
> + rte_spinlock_unlock(&internals->lock);
> +
> + 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/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> index c937e6b..45d5b89 100644
> --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> +++ b/lib/librte_pmd_bond/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
> @@ -1503,7 +1503,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;
> @@ -2038,6 +2038,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
> @@ -2264,6 +2282,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/lib/librte_pmd_bond/rte_eth_bond_private.h b/lib/librte_pmd_bond/rte_eth_bond_private.h
> index 45e5c65..8551ddd 100644
> --- a/lib/librte_pmd_bond/rte_eth_bond_private.h
> +++ b/lib/librte_pmd_bond/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
> @@ -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
> --
> 1.7.4.1
>
>
next prev parent reply other threads:[~2015-05-01 15:17 UTC|newest]
Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <RFC PATCH>
2015-04-08 10:02 ` [dpdk-dev] [RFC PATCH] librte_pmd_ixgbe: changes to support " Bernard Iremonger
2015-04-22 3:14 ` Qiu, Michael
2015-04-08 14:11 ` [dpdk-dev] [RFC PATCH] librte_pmd_e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
2015-04-30 13:16 ` [dpdk-dev] [RFC PATCH 1/1] librte_pmd_ring: changes to support PCI Port Hotplug Bernard Iremonger
2015-04-30 15:40 ` [dpdk-dev] [RFC PATCH 1/4] librte_pmd_i40e: " Bernard Iremonger
2015-04-30 15:41 ` [dpdk-dev] [RFC PATCH 2/4] librte_pmd_i40e: release vmdq vsi's in dev_close Bernard Iremonger
2015-04-30 15:42 ` [dpdk-dev] [RFC PATCH 3/4] librte_pmd_i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done() Bernard Iremonger
2015-04-30 15:42 ` [dpdk-dev] [RFC PATCH 4/4] librte_pmd_i40e: call _clear_cmd() when error occurs Bernard Iremonger
2015-05-01 14:36 ` [dpdk-dev] [RFC PATCH] librte_pmd_bond: add support for PCI Port Hotplug Bernard Iremonger
2015-05-01 15:17 ` Neil Horman [this message]
2015-05-01 15:28 ` [dpdk-dev] [RFC PATCH] librte_pmd_virtio: " Bernard Iremonger
2015-05-05 14:36 ` [dpdk-dev] [RFC PATCH V2] librte_pmd_ring: changes to support " Bernard Iremonger
2015-05-06 16:15 ` Bruce Richardson
2015-05-06 10:22 ` [dpdk-dev] [RFC PATCH V2] librte_pmd_ixgbe: " Bernard Iremonger
2015-05-06 11:20 ` [dpdk-dev] [RFC PATCH V2] librte_pmd_e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
2015-05-27 16:00 ` [dpdk-dev] [RFC PATCH V2 1/2] drivers/net/virtio: add support for PCI Port Hotplug Bernard Iremonger
2015-05-27 16:00 ` [dpdk-dev] [RFC PATCH V2 2/2] drivers/net/virtio: check vq parameter Bernard Iremonger
2015-06-16 1:08 ` Ouyang, Changchun
2015-05-28 12:28 ` [dpdk-dev] [RFC PATCH V2] drivers/net/bonding: add support for PCI Port Hotplug Bernard Iremonger
2015-05-29 13:46 ` [dpdk-dev] [RFC PATCH V3] drivers/net/ring: changes to support " Bernard Iremonger
2015-06-03 15:21 ` Bruce Richardson
2015-06-02 10:18 ` [dpdk-dev] [RFC PATCH V3] ixgbe: " Bernard Iremonger
2015-06-03 14:03 ` [dpdk-dev] [RFC PATCH V3] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
2015-06-04 16:24 ` [dpdk-dev] [RFC PATCH V2 1/4] i40e: changes to support PCI Port Hotplug Bernard Iremonger
2015-06-24 8:03 ` Qiu, Michael
2015-06-04 16:25 ` [dpdk-dev] [RFC PATCH V2 2/4] i40e: release vmdq vsi's in dev_close Bernard Iremonger
2015-06-04 16:25 ` [dpdk-dev] [RFC PATCH V2 3/4] i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done() Bernard Iremonger
2015-06-04 16:26 ` [dpdk-dev] [RFC PATCH V2 4/4] i40e: call _clear_cmd() when error occurs Bernard Iremonger
2015-06-08 15:47 ` [dpdk-dev] [RFC PATCH V4] ixgbe: changes to support PCI Port Hotplug Bernard Iremonger
2015-06-15 22:31 ` Ananyev, Konstantin
2015-06-17 6:11 ` Zhang, Helin
2015-06-24 7:45 ` Qiu, Michael
2015-06-24 7:46 ` Qiu, Michael
2015-06-10 8:27 ` [dpdk-dev] [RFC PATCH V3 0/5] PCI Port Hotplug changes Bernard Iremonger
2015-06-10 8:27 ` [dpdk-dev] [RFC PATCH V3 1/5] i40e: changes to support PCI Port Hotplug Bernard Iremonger
2015-06-10 8:27 ` [dpdk-dev] [RFC PATCH V3 2/5] i40e: release vmdq vsi's in dev_close Bernard Iremonger
2015-06-10 8:27 ` [dpdk-dev] [RFC PATCH V3 3/5] i40e: increase ASQ_DELAY_MS to 100 in i40evf_wait_cmd_done() Bernard Iremonger
2015-06-10 8:27 ` [dpdk-dev] [RFC PATCH V3 4/5] i40e: call _clear_cmd() when error occurs Bernard Iremonger
2015-06-10 8:27 ` [dpdk-dev] [RFC PATCH V3 5/5] i40e: clear queues in i40evf_dev_stop Bernard Iremonger
2015-06-10 12:09 ` [dpdk-dev] [RFC PATCH V4] e1000: igb and em1000 PCI Port Hotplug changes Bernard Iremonger
2015-08-27 15:40 ` [dpdk-dev] [RFC PATCH 0/6] remove pci driver from vdevs Bernard Iremonger
2015-08-27 15:40 ` [dpdk-dev] [RFC PATCH 1/6] librte_ether: add fields from rte_pci_driver to rte_eth_dev and rte_eth_dev_data Bernard Iremonger
2015-08-31 14:07 ` Thomas Monjalon
2015-09-01 11:38 ` Iremonger, Bernard
2015-09-01 12:03 ` Bruce Richardson
2015-09-01 12:37 ` Ananyev, Konstantin
2015-09-01 12:43 ` Richardson, Bruce
2015-08-27 15:40 ` [dpdk-dev] [RFC PATCH 2/6] librte_ether: handle RTE_ETH_DEV_INTR_LSC for vdevs Bernard Iremonger
2015-08-27 15:40 ` [dpdk-dev] [RFC PATCH 3/6] null: remove pci device driver Bernard Iremonger
2015-08-31 14:11 ` Thomas Monjalon
2015-08-31 16:05 ` Iremonger, Bernard
2015-08-27 15:40 ` [dpdk-dev] [RFC PATCH 4/6] ring: " Bernard Iremonger
2015-08-27 15:40 ` [dpdk-dev] [RFC PATCH 5/6] bonding: " Bernard Iremonger
2015-08-27 17:48 ` Stephen Hemminger
2015-08-28 8:32 ` Iremonger, Bernard
2015-08-28 15:57 ` Stephen Hemminger
2015-08-27 15:40 ` [dpdk-dev] [RFC PATCH 6/6] pcap: " Bernard Iremonger
2015-08-27 17:43 ` [dpdk-dev] [RFC PATCH 0/6] remove pci driver from vdevs John W. Linville
2015-08-28 8:15 ` Iremonger, Bernard
2015-08-28 10:32 ` Neil Horman
2015-08-28 19:48 ` Wiles, Keith
2015-08-31 11:21 ` Iremonger, Bernard
2015-08-31 12:41 ` Neil Horman
2015-08-28 17:51 ` John W. Linville
2015-08-31 10:23 ` Iremonger, Bernard
2015-08-31 12:59 ` Neil Horman
2015-08-31 14:22 ` Thomas Monjalon
2015-09-01 13:38 ` Iremonger, Bernard
2015-09-01 19:18 ` Neil Horman
2015-09-03 14:02 ` Iremonger, Bernard
2015-09-07 9:22 ` Zende, Amruta S
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 00/18] refactor eal driver registration code Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 01/18] librte_eal: remove type field from rte_driver structure Bernard Iremonger
2015-09-04 13:08 ` Thomas Monjalon
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 02/18] af_packet: " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 03/18] bnx2x: remove type field and initialise name field in " Bernard Iremonger
2015-09-04 11:26 ` Harish Patil
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 04/18] bonding: remove type field from " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 05/18] cxgbe: " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 06/18] e1000: remove type field and initialise name field in rte_driver structures Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 07/18] enic: remove type field and initialise name field in rte_driver structure Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 08/18] fm10k: " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 09/18] i40e: remove type field and initialise name field in rte_driver structures Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 10/18] ixgbe: remove type field and initialise name field in rte_driver structure Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 11/18] mlx4: remove type field from " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 12/18] mpipe: remove type field and update name in " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 13/18] null: remove type field from " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 14/18] pcap: " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 15/18] ring: " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 16/18] virtio_ethdev: remove type field and initialise name field in " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 17/18] vmxnet3: " Bernard Iremonger
2015-09-04 11:01 ` [dpdk-dev] [RFC PATCH 18/18] xenvirt: remove type field from " Bernard Iremonger
2015-09-04 11:18 ` [dpdk-dev] [RFC PATCH 00/18] refactor eal driver registration code Bruce Richardson
2015-09-04 12:46 ` Iremonger, Bernard
2015-09-04 12:53 ` Bruce Richardson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150501151716.GA27756@hmsreliant.think-freely.org \
--to=nhorman@tuxdriver.com \
--cc=bernard.iremonger@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).