librte_pmd_ixgbe: changes to support PCI Port Hotplug
RFC PATCH 1/1 librte_pmd_ixgbe: changes to support PCI Port Hotplug
This patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit functions for rte_ixgbe_pmd and rte_ixgbevf_pmd.pmd.
Signed-off-by Bernard Iremonger <[email protected]>
--- lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 87 +++++++++++++++++++++++++++++++++- lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 4 +- lib/librte_pmd_ixgbe/ixgbe_pf.c | 30 ++++++++++++- 3 files changed, 116 insertions(+), 5 deletions(-)
lib/librte_pmd_ixgbe/ixgbe_ethdev.c +84 -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
@@ -117,6 +117,7 @@#define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))static int eth_ixgbe_dev_init (struct rte_eth_dev *eth_dev); +static int eth_ixgbe_dev_uninit (struct rte_eth_dev *eth_dev);static int ixgbe_dev_configure (struct rte_eth_dev *dev);static int ixgbe_dev_start (struct rte_eth_dev *dev);static void ixgbe_dev_stop (struct rte_eth_dev *dev);
@@ -183,6 +184,7 @@ static void ixgbe_dcb_init(struct ixgbe_hw *hw,struct ixgbe_dcb_config *dcb_conf/* For Virtual Function support */ static int eth_ixgbevf_dev_init (struct rte_eth_dev *eth_dev); +static int eth_ixgbevf_dev_uninit (struct rte_eth_dev *eth_dev);static int ixgbevf_dev_configure (struct rte_eth_dev *dev);static int ixgbevf_dev_start (struct rte_eth_dev *dev);static void ixgbevf_dev_stop (struct rte_eth_dev *dev);
@@ -917,6 +919,49 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)return 0 ; } +static int +eth_ixgbe_dev_uninit (struct rte_eth_dev *eth_dev) +{ +struct rte_pci_device *pci_dev; +struct ixgbe_hw *hw; + +PMD_INIT_FUNC_TRACE (); + +if ((eth_dev ==NULL ) || + (eth_dev->data ==NULL ) || + (eth_dev->data->dev_private ==NULL ) || + (eth_dev->pci_dev ==NULL )) +return -EINVAL ; + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return -EPERM ; + + hw =IXGBE_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private); + pci_dev = eth_dev->pci_dev; + + eth_dev->dev_ops =NULL ; + eth_dev->rx_pkt_burst =NULL ; + eth_dev->tx_pkt_burst =NULL ; + +/* Unlock any pending hardware semaphore */ +ixgbe_swfw_lock_reset (hw); + +/* disable uio intr before callback unregister */ +rte_intr_disable (&(pci_dev->intr_handle)); +rte_intr_callback_unregister (&(pci_dev->intr_handle), + ixgbe_dev_interrupt_handler, (void *)eth_dev); + +/* uninitialize PF if max_vfs not zero */ +ixgbe_pf_host_uninit (eth_dev); + +rte_free (eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs =NULL ; + +rte_free (eth_dev->data->hash_mac_addrs); + eth_dev->data->hash_mac_addrs =NULL ; + +return 0 ; +}/* * Negotiate mailbox API version with the PF.
@@ -1087,13 +1132,48 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)return 0 ; } +/* +* Virtual Function device uninit +*/ +static int +eth_ixgbevf_dev_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_hw *hw; + +PMD_INIT_FUNC_TRACE (); + +if ((eth_dev ==NULL ) || + (eth_dev->data ==NULL ) || + (eth_dev->data->dev_private ==NULL )) +return -EINVAL ; + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return -EPERM ; + + hw =IXGBE_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private); + + eth_dev->dev_ops =NULL ; + eth_dev->rx_pkt_burst =NULL ; + eth_dev->tx_pkt_burst =NULL ; + +/* Disable the interrupts for VF */ +ixgbevf_intr_disable (hw); + +rte_free (eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs =NULL ; + +return 0 ; +} +static struct eth_driver rte_ixgbe_pmd = { { .name ="rte_ixgbe_pmd" , .id_table = pci_id_ixgbe_map, - .drv_flags =RTE_PCI_DRV_NEED_MAPPING |RTE_PCI_DRV_INTR_LSC , + .drv_flags =RTE_PCI_DRV_NEED_MAPPING |RTE_PCI_DRV_INTR_LSC | +RTE_PCI_DRV_DETACHABLE , }, .eth_dev_init = eth_ixgbe_dev_init, + .eth_dev_uninit = eth_ixgbe_dev_uninit, .dev_private_size =sizeof (struct ixgbe_adapter ), };
@@ -1104,9 +1184,10 @@ static struct eth_driver rte_ixgbevf_pmd = { { .name = "rte_ixgbevf_pmd", .id_table = pci_id_ixgbevf_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE, }, .eth_dev_init = eth_ixgbevf_dev_init, + .eth_dev_uninit = eth_ixgbevf_dev_uninit, .dev_private_size = sizeof(struct ixgbe_adapter), };
lib/librte_pmd_ixgbe/ixgbe_ethdev.h +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. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -376,6 +376,8 @@ void ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev);void ixgbe_pf_host_init (struct rte_eth_dev *eth_dev); +void ixgbe_pf_host_uninit (struct rte_eth_dev *eth_dev); +void ixgbe_pf_mbx_process (struct rte_eth_dev *eth_dev);int ixgbe_pf_host_configure (struct rte_eth_dev *eth_dev);
lib/librte_pmd_ixgbe/ixgbe_pf.c +29 -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
@@ -144,6 +144,34 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)return ; } +void ixgbe_pf_host_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_vf_info **vfinfo; +uint16_t vf_num; + +PMD_INIT_FUNC_TRACE (); + +if ((eth_dev ==NULL ) || + (eth_dev->data ==NULL ) || + (eth_dev->data->dev_private ==NULL )) +return ; + + vfinfo =IXGBE_DEV_PRIVATE_TO_P_VFDATA (eth_dev->data->dev_private); + +RTE_ETH_DEV_SRIOV (eth_dev).active =0 ; +RTE_ETH_DEV_SRIOV (eth_dev).nb_q_per_pool =0 ; +RTE_ETH_DEV_SRIOV (eth_dev).def_vmdq_idx =0 ; +RTE_ETH_DEV_SRIOV (eth_dev).def_pool_q_idx =0 ; + + vf_num =dev_num_vf (eth_dev); +if (vf_num ==0 ) +return ; + +rte_free (*vfinfo); + *vfinfo =NULL ; +} + +int ixgbe_pf_host_configure (struct rte_eth_dev *eth_dev) {uint32_t vtctl, fcrth;
Signature · 1 line
1.7.4.1
Quoted 6 lines · Bernard Iremonger
This patch depends on the Port Hotplug Framework.
It implements theeth_dev_uninitfunctions forrte_ixgbe_pmdand rte_ixgbevf_pmd.pmd.Signed-off-by Bernard Iremonger <[email protected]>---
Tested-by Michael Qiu <[email protected]>
Quoted 216 lines
lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 87 +++++++++++++++++++++++++++++++++- lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 4 +- lib/librte_pmd_ixgbe/ixgbe_pf.c | 30 ++++++++++++- 3 files changed, 116 insertions(+), 5 deletions(-)lib/librte_pmd_ixgbe/ixgbe_ethdev.c +84
-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 @@ -117,6 +117,7 @@#define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))static int eth_ixgbe_dev_init (struct rte_eth_dev *eth_dev); +static int eth_ixgbe_dev_uninit (struct rte_eth_dev *eth_dev);static int ixgbe_dev_configure (struct rte_eth_dev *dev);static int ixgbe_dev_start (struct rte_eth_dev *dev);static void ixgbe_dev_stop (struct rte_eth_dev *dev);@@ -183,6 +184,7 @@ static void ixgbe_dcb_init(struct ixgbe_hw *hw,struct ixgbe_dcb_config *dcb_conf/* For Virtual Function support */ static int eth_ixgbevf_dev_init (struct rte_eth_dev *eth_dev); +static int eth_ixgbevf_dev_uninit (struct rte_eth_dev *eth_dev);static int ixgbevf_dev_configure (struct rte_eth_dev *dev);static int ixgbevf_dev_start (struct rte_eth_dev *dev);static void ixgbevf_dev_stop (struct rte_eth_dev *dev);@@ -917,6 +919,49 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)return 0 ; } +static int +eth_ixgbe_dev_uninit (struct rte_eth_dev *eth_dev) +{ +struct rte_pci_device *pci_dev; +struct ixgbe_hw *hw; + +PMD_INIT_FUNC_TRACE (); + +if ((eth_dev ==NULL ) || + (eth_dev->data ==NULL ) || + (eth_dev->data->dev_private ==NULL ) || + (eth_dev->pci_dev ==NULL )) +return -EINVAL ; + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return -EPERM ; + + hw =IXGBE_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private); + pci_dev = eth_dev->pci_dev; + + eth_dev->dev_ops =NULL ; + eth_dev->rx_pkt_burst =NULL ; + eth_dev->tx_pkt_burst =NULL ; + +/* Unlock any pending hardware semaphore */ +ixgbe_swfw_lock_reset (hw); + +/* disable uio intr before callback unregister */ +rte_intr_disable (&(pci_dev->intr_handle)); +rte_intr_callback_unregister (&(pci_dev->intr_handle), + ixgbe_dev_interrupt_handler, (void *)eth_dev); + +/* uninitialize PF if max_vfs not zero */ +ixgbe_pf_host_uninit (eth_dev); + +rte_free (eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs =NULL ; + +rte_free (eth_dev->data->hash_mac_addrs); + eth_dev->data->hash_mac_addrs =NULL ; + +return 0 ; +}/* * Negotiate mailbox API version with the PF. @@ -1087,13 +1132,48 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)return 0 ; } +/* +* Virtual Function device uninit +*/ +static int +eth_ixgbevf_dev_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_hw *hw; + +PMD_INIT_FUNC_TRACE (); + +if ((eth_dev ==NULL ) || + (eth_dev->data ==NULL ) || + (eth_dev->data->dev_private ==NULL )) +return -EINVAL ; + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return -EPERM ; + + hw =IXGBE_DEV_PRIVATE_TO_HW (eth_dev->data->dev_private); + + eth_dev->dev_ops =NULL ; + eth_dev->rx_pkt_burst =NULL ; + eth_dev->tx_pkt_burst =NULL ; + +/* Disable the interrupts for VF */ +ixgbevf_intr_disable (hw); + +rte_free (eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs =NULL ; + +return 0 ; +} +static struct eth_driver rte_ixgbe_pmd = { { .name ="rte_ixgbe_pmd" , .id_table = pci_id_ixgbe_map, - .drv_flags =RTE_PCI_DRV_NEED_MAPPING |RTE_PCI_DRV_INTR_LSC , + .drv_flags =RTE_PCI_DRV_NEED_MAPPING |RTE_PCI_DRV_INTR_LSC | +RTE_PCI_DRV_DETACHABLE , }, .eth_dev_init = eth_ixgbe_dev_init, + .eth_dev_uninit = eth_ixgbe_dev_uninit, .dev_private_size =sizeof (struct ixgbe_adapter ), };@@ -1104,9 +1184,10 @@ static struct eth_driver rte_ixgbevf_pmd = { { .name = "rte_ixgbevf_pmd", .id_table = pci_id_ixgbevf_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE, }, .eth_dev_init = eth_ixgbevf_dev_init, + .eth_dev_uninit = eth_ixgbevf_dev_uninit, .dev_private_size = sizeof(struct ixgbe_adapter), };lib/librte_pmd_ixgbe/ixgbe_ethdev.h +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. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -376,6 +376,8 @@ void ixgbe_vlan_hw_strip_disable_all(struct rte_eth_dev *dev);void ixgbe_pf_host_init (struct rte_eth_dev *eth_dev); +void ixgbe_pf_host_uninit (struct rte_eth_dev *eth_dev); +void ixgbe_pf_mbx_process (struct rte_eth_dev *eth_dev);int ixgbe_pf_host_configure (struct rte_eth_dev *eth_dev);lib/librte_pmd_ixgbe/ixgbe_pf.c +29
-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 @@ -144,6 +144,34 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)return ; } +void ixgbe_pf_host_uninit (struct rte_eth_dev *eth_dev) +{ +struct ixgbe_vf_info **vfinfo; +uint16_t vf_num; + +PMD_INIT_FUNC_TRACE (); + +if ((eth_dev ==NULL ) || + (eth_dev->data ==NULL ) || + (eth_dev->data->dev_private ==NULL )) +return ; + + vfinfo =IXGBE_DEV_PRIVATE_TO_P_VFDATA (eth_dev->data->dev_private); + +RTE_ETH_DEV_SRIOV (eth_dev).active =0 ; +RTE_ETH_DEV_SRIOV (eth_dev).nb_q_per_pool =0 ; +RTE_ETH_DEV_SRIOV (eth_dev).def_vmdq_idx =0 ; +RTE_ETH_DEV_SRIOV (eth_dev).def_pool_q_idx =0 ; + + vf_num =dev_num_vf (eth_dev); +if (vf_num ==0 ) +return ; + +rte_free (*vfinfo); + *vfinfo =NULL ; +} + +int ixgbe_pf_host_configure (struct rte_eth_dev *eth_dev) {uint32_t vtctl, fcrth;