bonding PCI Port Hotplug
Subsystems (2)
v4 cover bonding PCI Port Hotplug
Changes in V4:
Rebase to latest code.
Move freeing of queue memory from uninit() function to close() function.
Changes in V3:
Rebase to latest code.
Modified testpmd to handle attach/detach of bonding pmd.
Changes in V2:
Rebased to use drivers/net/bonding dirctory
Free rx and tx queues in uninit() function.
Bernard Iremonger (3):
bonding: add support for PCI Port Hotplug
test-pmd: modified testpmd for link_bonding
bonding: free queue memory in stop function
app/test-pmd/cmdline.c | 4 +- app/test-pmd/testpmd.c | 24 ++++++++- app/test-pmd/testpmd.h | 7 ++- drivers/net/bonding/rte_eth_bond.h | 13 +++++- drivers/net/bonding/rte_eth_bond_api.c | 75 ++++++++++++++++++--------- drivers/net/bonding/rte_eth_bond_pmd.c | 41 +++++++++++++++- drivers/net/bonding/rte_eth_bond_private.h | 7 ++- 7 files changed, 136 insertions(+), 35 deletions(-)
Signature · 1 line
1.7.4.1
PATCH v4 1/3 bonding: add support for PCI Port Hotplug
This patch depends on the Port Hotplug Framework.
It implements the rte_dev_uninit_t() function for the link bonding pmd.
--- drivers/net/bonding/rte_eth_bond.h | 13 +++++- drivers/net/bonding/rte_eth_bond_api.c | 75 ++++++++++++++++++--------- drivers/net/bonding/rte_eth_bond_pmd.c | 23 ++++++++- drivers/net/bonding/rte_eth_bond_private.h | 7 ++- 4 files changed, 88 insertions(+), 30 deletions(-)
drivers/net/bonding/rte_eth_bond.h +12 -1
@@ -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.
drivers/net/bonding/rte_eth_bond_api.c +50 -25
119 lines not on this page · raw message
drivers/net/bonding/rte_eth_bond_pmd.c +21 -2
@@ -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;
@@ -2043,6 +2043,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
@@ -2269,6 +2287,7 @@ static struct rte_driver bond_drv = { .name = "eth_bond", .type = PMD_VDEV, .init = bond_init, + .uninit = bond_uninit, };PMD_REGISTER_DRIVER (bond_drv);
drivers/net/bonding/rte_eth_bond_private.h +5 -2
@@ -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 *driver_name; +extern const char 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
Signature · 1 line
1.7.4.1
PATCH v4 2/3 test-pmd: modified testpmd for link_bonding
In reply to Bernard IremongerWhen the bonded port is started it also starts the slave port, but the slave port status is not set. A slave_flag has been added to struct rte_port to resolve this issue.
--- app/test-pmd/cmdline.c | 4 +++- app/test-pmd/testpmd.c | 24 +++++++++++++++++++++--- app/test-pmd/testpmd.h | 7 +++++-- 3 files changed, 29 insertions(+), 6 deletions(-)
app/test-pmd/cmdline.c +3 -1
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * Copyright(c) 2014 6WIND S.A. * All rights reserved. *
@@ -3950,6 +3950,7 @@ static void cmd_add_bonding_slave_parsed(void *parsed_result,return ; }init_port_config (); +set_port_slave_flag (slave_port_id); } cmdline_parse_token_string_t cmd_addbonding_slave_add =
@@ -4006,6 +4007,7 @@ static void cmd_remove_bonding_slave_parsed(void *parsed_result,return ; }init_port_config (); +clear_port_slave_flag (slave_port_id); } cmdline_parse_token_string_t cmd_removebonding_slave_remove =
app/test-pmd/testpmd.c +21 -3
@@ -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
@@ -1202,7 +1202,8 @@ all_ports_started(void) FOREACH_PORT(pi, ports) { port = &ports[pi];/* Check if there is a port which is not started */ -if (port->port_status !=RTE_PORT_STARTED ) +if ((port->port_status !=RTE_PORT_STARTED ) && + (port->slave_flag ==0 ))return 0 ; }
@@ -1218,7 +1219,8 @@ all_ports_stopped(void) FOREACH_PORT(pi, ports) { port = &ports[pi]; -if (port->port_status !=RTE_PORT_STOPPED ) +if ((port->port_status !=RTE_PORT_STOPPED ) && + (port->slave_flag ==0 ))return 0 ; }
@@ -1810,6 +1812,22 @@ init_port_config(void) } } +void set_port_slave_flag (portid_t slave_pid) +{ +struct rte_port *port; + + port = &ports[slave_pid]; + port->slave_flag =1 ; +} + +void clear_port_slave_flag (portid_t slave_pid) +{ +struct rte_port *port; + + port = &ports[slave_pid]; + port->slave_flag =0 ; +} +const uint16_t vlan_tags[] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,
app/test-pmd/testpmd.h +5 -2
@@ -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
@@ -159,11 +159,12 @@ struct rte_port {uint8_t need_reconfig;/**< need reconfiguring port or not */ uint8_t need_reconfig_queues;/**< need reconfiguring queues or not */ uint8_t rss_flag;/**< enable rss or not */ -uint8_t dcb_flag;/**< enable dcb */ +uint8_t dcb_flag;/**< enable dcb */ struct rte_eth_rxconf rx_conf;/**< rx configuration */ struct rte_eth_txconf tx_conf;/**< tx configuration */ struct ether_addr *mc_addr_pool;/**< pool of multicast addrs */ uint32_t mc_addr_nb;/**< nb. of addr. in mc_addr_pool */ +uint8_t slave_flag;/**< bonding slave port */ };extern portid_t __rte_unused
@@ -530,6 +531,8 @@ void stop_packet_forwarding(void);void dev_set_link_up (portid_t pid);void dev_set_link_down (portid_t pid);void init_port_config (void ); +void set_port_slave_flag (portid_t slave_pid); +void clear_port_slave_flag (portid_t slave_pid);int init_port_dcb_config (portid_t pid,struct dcb_config *dcb_conf);int start_port (portid_t pid);void stop_port (portid_t pid);
Signature · 1 line
1.7.4.1
PATCH v4 3/3 bonding: free queue memory in stop function
In reply to Bernard Iremongeradd function bond_ethdev_free_queues() and call from the bond_ethdev_stop() function.
--- drivers/net/bonding/rte_eth_bond_pmd.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/net/bonding/rte_eth_bond_pmd.c +20 -0
@@ -1512,6 +1512,24 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev)return 0 ; } +static void +bond_ethdev_free_queues (struct rte_eth_dev *dev) +{ +uint8_t i; + +for (i =0 ; i < dev->data->nb_rx_queues; i++) { +rte_free (dev->data->rx_queues[i]); + dev->data->rx_queues[i] =NULL ; + } + dev->data->nb_rx_queues =0 ; + +for (i =0 ; i < dev->data->nb_tx_queues; i++) { +rte_free (dev->data->tx_queues[i]); + dev->data->tx_queues[i] =NULL ; + } + dev->data->nb_tx_queues =0 ; +} +void bond_ethdev_stop (struct rte_eth_dev *eth_dev) {
@@ -1550,6 +1568,8 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev) eth_dev->data->dev_link.link_status =0 ; eth_dev->data->dev_started =0 ; + +bond_ethdev_free_queues (eth_dev); } static void
Signature · 1 line
1.7.4.1
Re: [PATCH v4 1/3] bonding: add support for PCI Port Hotplug
In reply to Bernard IremongerQuoted 5 lines · Bernard Iremonger
This patch depends on the Port Hotplug Framework.
It implements therte_dev_uninit_t()function for the link bonding pmd.Signed-off-by Bernard Iremonger <[email protected]>---
...
Quoted 1 line
I think we can clean up the create function a bit further as the pci_id_table is static for all bonded devices we can just statically initialize it, as this will remove the resetting of the parameters each time a bonding device is created. See below
Declan
drivers/net/bonding/rte_eth_bond_api.c +8 -2
@@ -193,12 +193,19 @@ number_of_sockets(void) }const char driver_name[] ="rte_bond_pmd" ; -static struct rte_pci_id pci_id_table; + +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 = driver_name, .drv_flags =RTE_PCI_DRV_INTR_LSC |RTE_PCI_DRV_DETACHABLE , + .id_table = &pci_id_table }, };
@@ -208,7 +215,6 @@ 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 rte_pci_driver *pci_drv =NULL ;/* now do all data allocation - for eth_dev structure, dummy
pci driver
* and internal (private) data
@@ -231,16 +237,6 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id)
goto err;
}- pci_drv = &rte_bond_pmd.pci_drv;
-
- memset(&pci_id_table, 0, sizeof(pci_id_table)); - 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;
-
internals = rte_zmalloc_socket(name, sizeof(*internals), 0,
socket_id);
if (internals == NULL) {
RTE_BOND_LOG(ERR, "Unable to malloc internals on socket");
@@ -255,8 +251,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;
- pci_dev->driver = pci_drv;
+ pci_dev->driver = &rte_bond_pmd.pci_drv; eth_dev->driver = &rte_bond_pmd;
eth_dev->data->dev_private = internals;