i40e: PCI Port Hotplug Changes
PATCH v6 1/7 i40e: changes to support PCI Port Hotplug
In reply to Bernard IremongerThis patch depends on the Port Hotplug Framework.
It implements the eth_dev_uninit functions for rte_i40e_pmd and rte_i40evf_pmd.
--- drivers/net/i40e/i40e_ethdev.c | 68 ++++++++++++++++++++++++++++++++++++- drivers/net/i40e/i40e_ethdev_vf.c | 45 ++++++++++++++++++++++++- drivers/net/i40e/i40e_pf.c | 34 ++++++++++++++++++ drivers/net/i40e/i40e_pf.h | 1 + 4 files changed, 146 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev.c +67 -1
@@ -107,6 +107,7 @@ (1UL << RTE_ETH_FLOW_L2_PAYLOAD))static int eth_i40e_dev_init (struct rte_eth_dev *eth_dev); +static int eth_i40e_dev_uninit (struct rte_eth_dev *eth_dev);static int i40e_dev_configure (struct rte_eth_dev *dev);static int i40e_dev_start (struct rte_eth_dev *dev);static void i40e_dev_stop (struct rte_eth_dev *dev);
@@ -268,9 +269,11 @@ static struct eth_driver rte_i40e_pmd = { .pci_drv = { .name = "rte_i40e_pmd", .id_table = pci_id_i40e_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_i40e_dev_init, + .eth_dev_uninit = eth_i40e_dev_uninit, .dev_private_size = sizeof(struct i40e_adapter), };
@@ -405,6 +408,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev) hw->subsystem_device_id = pci_dev->id.subsystem_device_id; hw->bus.device = pci_dev->addr.devid; hw->bus.func = pci_dev->addr.function; + hw->adapter_stopped =0 ;/* Make sure all is clean before doing PF reset */ i40e_clear_hw (hw);
@@ -584,6 +588,65 @@ err_get_capabilities: }static int +eth_i40e_dev_uninit (struct rte_eth_dev *dev) +{ +struct rte_pci_device *pci_dev; +struct i40e_hw *hw; +struct i40e_filter_control_settings settings; +int ret; +uint8_t aq_fail =0 ; + +PMD_INIT_FUNC_TRACE (); + +if (rte_eal_process_type () !=RTE_PROC_PRIMARY ) +return 0 ; + + hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private); + pci_dev = dev->pci_dev; + +if (hw->adapter_stopped ==0 ) +i40e_dev_close (dev); + + dev->dev_ops =NULL ; + dev->rx_pkt_burst =NULL ; + dev->tx_pkt_burst =NULL ; + +/* Disable LLDP */ + ret =i40e_aq_stop_lldp (hw, true,NULL ); +if (ret !=I40E_SUCCESS )/* Its failure can be ignored */ +PMD_INIT_LOG (INFO ,"Failed to stop lldp" ); + +/* Clear PXE mode */ +i40e_clear_pxe_mode (hw); + +/* Unconfigure filter control */ +memset (&settings,0 ,sizeof (settings)); + ret =i40e_set_filter_control (hw, &settings); +if (ret) +PMD_INIT_LOG (WARNING ,"setup_pf_filter_control failed: %d" , + ret); + +/* Disable flow control */ + hw->fc.requested_mode =I40E_FC_NONE ; +i40e_set_fc (hw, &aq_fail, TRUE); + +/* uninitialize pf host driver */ +i40e_pf_host_uninit (dev); + +rte_free (dev->data->mac_addrs); + dev->data->mac_addrs =NULL ; + +/* disable uio intr before callback unregister */ +rte_intr_disable (&(pci_dev->intr_handle)); + +/* register callback func to eal lib */ +rte_intr_callback_unregister (&(pci_dev->intr_handle), + i40e_dev_interrupt_handler, (void *)dev); + +return 0 ; +} + +static int i40e_dev_configure (struct rte_eth_dev *dev) {struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);
@@ -858,6 +921,8 @@ i40e_dev_start(struct rte_eth_dev *dev)struct i40e_vsi *main_vsi = pf->main_vsi;int ret, i; + hw->adapter_stopped =0 ; +if ((dev->data->dev_conf.link_duplex !=ETH_LINK_AUTONEG_DUPLEX ) && (dev->data->dev_conf.link_duplex !=ETH_LINK_FULL_DUPLEX )) { PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port %hhu",
@@ -965,6 +1030,7 @@ i40e_dev_close(struct rte_eth_dev *dev)PMD_INIT_FUNC_TRACE ();i40e_dev_stop (dev); + hw->adapter_stopped =1 ;/* Disable interrupt */ i40e_pf_disable_irq0 (hw);
drivers/net/i40e/i40e_ethdev_vf.c +44 -1
83 lines not on this page · raw message
drivers/net/i40e/i40e_pf.c +34 -0
@@ -1061,3 +1061,37 @@ fail:return ret; } + +int +i40e_pf_host_uninit (struct rte_eth_dev *dev) +{ +struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private); +struct i40e_hw *hw =I40E_PF_TO_HW (pf); +uint32_t val; + +PMD_INIT_FUNC_TRACE (); + +/** +* return if SRIOV not enabled, VF number not configured or +* no queue assigned. +*/ +if ((!hw->func_caps.sr_iov_1_1) || + (pf->vf_num ==0 ) || + (pf->vf_nb_qps ==0 )) +return I40E_SUCCESS ; + +/* free memory to store VF structure */ +rte_free (pf->vfs); + pf->vfs =NULL ; + +/* Disable irq0 for VFR event */ +i40e_pf_disable_irq0 (hw); + +/* Disable VF link status interrupt */ + val =I40E_READ_REG (hw,I40E_PFGEN_PORTMDIO_NUM ); + val &= ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK ; +I40E_WRITE_REG (hw,I40E_PFGEN_PORTMDIO_NUM , val); +I40E_WRITE_FLUSH (hw); + +return I40E_SUCCESS ; +}
drivers/net/i40e/i40e_pf.h +1 -0
@@ -123,5 +123,6 @@ void i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev, __rte_unused uint32_t retval, uint8_t *msg, uint16_t msglen);int i40e_pf_host_init (struct rte_eth_dev *dev); +int i40e_pf_host_uninit (struct rte_eth_dev *dev);#endif /* _I40E_PF_H_ */
Signature · 1 line
1.7.4.1
PATCH v6 2/7 i40e: release vmdq vsi's in dev_close
In reply to Bernard Iremonger--- drivers/net/i40e/i40e_ethdev.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/net/i40e/i40e_ethdev.c +9 -0
@@ -1026,6 +1026,7 @@ i40e_dev_close(struct rte_eth_dev *dev)struct i40e_pf *pf =I40E_DEV_PRIVATE_TO_PF (dev->data->dev_private);struct i40e_hw *hw =I40E_DEV_PRIVATE_TO_HW (dev->data->dev_private);uint32_t reg; +int i;PMD_INIT_FUNC_TRACE ();
@@ -1043,6 +1044,14 @@ i40e_dev_close(struct rte_eth_dev *dev)i40e_fdir_teardown (pf);i40e_vsi_release (pf->main_vsi); +for (i =0 ; i < pf->nb_cfg_vmdq_vsi; i++) { +i40e_vsi_release (pf->vmdq[i].vsi); + pf->vmdq[i].vsi =NULL ; + } + +rte_free (pf->vmdq); + pf->vmdq =NULL ; +/* shutdown the adminq */ i40e_aq_queue_shutdown (hw, true);i40e_shutdown_adminq (hw);
Signature · 1 line
1.7.4.1
PATCH v6 4/7 i40e: call _clear_cmd() when error occurs
In reply to Bernard Iremonger_clear_cmd() was not being called in failure situations, resulting in the next command also failing.
Fix several typos.
--- drivers/net/i40e/i40e_ethdev_vf.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +7 -4
@@ -361,6 +361,7 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) args->in_args, args->in_args_size, NULL);if (err) {PMD_DRV_LOG (ERR ,"fail to send cmd %d" , args->ops); +_clear_cmd (vf);return err; }
@@ -368,8 +369,10 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args)/* read message and it's expected one */ if (!err && args->ops == info.ops)_clear_cmd (vf); -else if (err) +else if (err) {PMD_DRV_LOG (ERR ,"Failed to read message from AdminQ" ); +_clear_cmd (vf); + }else if (args->ops != info.ops)PMD_DRV_LOG (ERR ,"command mismatch, expect %u, get %u" , args->ops, info.ops);
@@ -794,7 +797,7 @@ i40evf_stop_queues(struct rte_eth_dev *dev)/* Stop TX queues first */ for (i =0 ; i < dev->data->nb_tx_queues; i++) {if (i40evf_dev_tx_queue_stop (dev, i) !=0 ) { -PMD_DRV_LOG (ERR ,"Fail to start queue %u" , i); +PMD_DRV_LOG (ERR ,"Fail to stop queue %u" , i);return -1 ; } }
@@ -802,7 +805,7 @@ i40evf_stop_queues(struct rte_eth_dev *dev)/* Then stop RX queues */ for (i =0 ; i < dev->data->nb_rx_queues; i++) {if (i40evf_dev_rx_queue_stop (dev, i) !=0 ) { -PMD_DRV_LOG (ERR ,"Fail to start queue %u" , i); +PMD_DRV_LOG (ERR ,"Fail to stop queue %u" , i);return -1 ; } }
@@ -1431,7 +1434,7 @@ i40evf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) err =i40evf_switch_queue (dev, FALSE, tx_queue_id, FALSE);if (err) { -PMD_DRV_LOG (ERR ,"Failed to switch TX queue %u of" , +PMD_DRV_LOG (ERR ,"Failed to switch TX queue %u off" , tx_queue_id);return err; }
Signature · 1 line
1.7.4.1
PATCH v6 5/7 i40e: clear queues in i40evf_dev_stop
In reply to Bernard Iremonger--- drivers/net/i40e/i40e_ethdev_vf.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +1 -0
@@ -1620,6 +1620,7 @@ i40evf_dev_stop(struct rte_eth_dev *dev)i40evf_disable_queues_intr (hw);i40evf_stop_queues (dev); +i40e_dev_clear_queues (dev); } static int
Signature · 1 line
1.7.4.1
PATCH v6 6/7 i40e: check rxq parameter in i40e_reset_rx_queue
In reply to Bernard IremongerThere is a segmentation fault if rxq is NULL
--- drivers/net/i40e/i40e_rxtx.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/net/i40e/i40e_rxtx.c +5 -0
@@ -2269,6 +2269,11 @@ i40e_reset_rx_queue(struct i40e_rx_queue *rxq)unsigned i;uint16_t len; +if (!rxq) { +PMD_DRV_LOG (DEBUG ,"Pointer to rxq is NULL" ); +return ; + } +#ifdef RTE_LIBRTE_I40E_RX_ALLOW_BULK_ALLOC if (check_rx_burst_bulk_alloc_preconditions (rxq) ==0 ) len = (uint16_t )(rxq->nb_rx_desc +RTE_PMD_I40E_RX_MAX_BURST );
Signature · 1 line
1.7.4.1
v6 cover i40e: PCI Port Hotplug Changes
Changes in V6:
Rebased to latest code.
Removed release of rx and tx queues from uninit() functions.
added patch 7, add function i40e_dev_free_queues() and call from close() functions.
Changes in V5:
Increased timeout in i40evf_wait_cmd_done()
Set nb_rx_queues and nb_tx_queues to 0 in uninit functions. Rebased to latest i40e code.
Changes in V4:
added patch 6 to fix segmentation fault reported by Michael Qiu. Rebase to latest i40e code.
Changes in V3:
Release rx and tx queues in vf uninit function.
Rebase to use latest i40e code.
Changes in V2:
Rebase to use drivers/net/i40e directory.
Bernard Iremonger (7):
i40e: changes to support PCI Port Hotplug
i40e: release vmdq vsi's in dev_close
i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in
i40evf_wait_cmd_done()
i40e: call _clear_cmd() when error occurs
i40e: clear queues in i40evf_dev_stop
i40e: check rxq parameter in i40e_reset_rx_queue
i40e: release queue memory in close functions
drivers/net/i40e/i40e_ethdev.c | 78 ++++++++++++++++++++++++++++++++++++- drivers/net/i40e/i40e_ethdev_vf.c | 62 ++++++++++++++++++++++++++--- drivers/net/i40e/i40e_pf.c | 34 ++++++++++++++++ drivers/net/i40e/i40e_pf.h | 1 + drivers/net/i40e/i40e_rxtx.c | 25 ++++++++++++ drivers/net/i40e/i40e_rxtx.h | 1 + 6 files changed, 193 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.4.1
PATCH v6 3/7 i40e: increase ASQ_DELAY_MS to 100 and MAX_TRY_TIMES to 20 in i40evf_wait_cmd_done()
Increase delay from 50 * 10 to 100 * 20 to avoid i40evf_read_pfmsg() failures.
--- drivers/net/i40e/i40e_ethdev_vf.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +2 -2
@@ -298,8 +298,8 @@ i40evf_wait_cmd_done(struct rte_eth_dev *dev,int i =0 ;enum i40evf_aq_result ret; -#define MAX_TRY_TIMES 10 -#define ASQ_DELAY_MS 50 +#define MAX_TRY_TIMES 20 +#define ASQ_DELAY_MS 100 do { /* Delay some time first */ rte_delay_ms(ASQ_DELAY_MS);
Signature · 1 line
1.7.4.1
PATCH v6 7/7 i40e: release queue memory in close functions
In reply to Bernard Iremongeradd i40e_dev_free_queues() function and call it from close() functions.
--- drivers/net/i40e/i40e_ethdev.c | 1 + drivers/net/i40e/i40e_ethdev_vf.c | 1 + drivers/net/i40e/i40e_rxtx.c | 20 ++++++++++++++++++++ drivers/net/i40e/i40e_rxtx.h | 1 + 4 files changed, 23 insertions(+), 0 deletions(-)
drivers/net/i40e/i40e_ethdev.c +1 -0
@@ -1032,6 +1032,7 @@ i40e_dev_close(struct rte_eth_dev *dev)i40e_dev_stop (dev); hw->adapter_stopped =1 ; +i40e_dev_free_queues (dev);/* Disable interrupt */ i40e_pf_disable_irq0 (hw);
drivers/net/i40e/i40e_ethdev_vf.c +1 -0
@@ -1756,6 +1756,7 @@ i40evf_dev_close(struct rte_eth_dev *dev)i40evf_dev_stop (dev); hw->adapter_stopped =1 ; +i40e_dev_free_queues (dev);i40evf_reset_vf (hw);i40e_shutdown_adminq (hw); }
drivers/net/i40e/i40e_rxtx.c +20 -0
@@ -2588,6 +2588,26 @@ i40e_dev_clear_queues(struct rte_eth_dev *dev) } } +void +i40e_dev_free_queues (struct rte_eth_dev *dev) +{ +uint16_t i; + +PMD_INIT_FUNC_TRACE (); + +for (i =0 ; i < dev->data->nb_rx_queues; i++) { +i40e_dev_rx_queue_release (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++) { +i40e_dev_tx_queue_release (dev->data->tx_queues[i]); + dev->data->tx_queues[i] =NULL ; + } + dev->data->nb_tx_queues =0 ; +} +#define I40E_FDIR_NUM_TX_DESC I40E_MIN_RING_DESC#define I40E_FDIR_NUM_RX_DESC I40E_MIN_RING_DESC
drivers/net/i40e/i40e_rxtx.h +1 -0
@@ -198,6 +198,7 @@ int i40e_rx_queue_init(struct i40e_rx_queue *rxq);void i40e_free_tx_resources (struct i40e_tx_queue *txq);void i40e_free_rx_resources (struct i40e_rx_queue *rxq);void i40e_dev_clear_queues (struct rte_eth_dev *dev); +void i40e_dev_free_queues (struct rte_eth_dev *dev);void i40e_reset_rx_queue (struct i40e_rx_queue *rxq);void i40e_reset_tx_queue (struct i40e_tx_queue *txq);void i40e_tx_queue_release_mbufs (struct i40e_tx_queue *txq);
Signature · 1 line
1.7.4.1
Quoted 51 lines
-----Original Message-----
From: Iremonger, Bernard
Sent: Friday, July 3, 2015 7:04 AM
To: [email protected]
Cc: Zhang, Helin; Qiu, Michael; Iremonger, Bernard
Subject: [PATCH v6 0/7] i40e: PCI Port Hotplug ChangesChanges in V6:
Rebased to latest code.
Removed release of rx and tx queues fromuninit()functions. added patch 7, add functioni40e_dev_free_queues()and call fromclose()functions.Changes in V5:
Increased timeout ini40evf_wait_cmd_done()Setnb_rx_queuesandnb_tx_queuesto 0 in uninit functions.
Rebased to latest i40e code.Changes in V4:
added patch 6 to fix segmentation fault reported by Michael Qiu. Rebase to latest i40e code.Changes in V3:
Release rx and tx queues in vf uninit function.
Rebase to use latest i40e code.Changes in V2:
Rebase to usedrivers/net/i40edirectory.Bernard Iremonger (7):
i40e: changes to support PCI Port Hotplug
i40e: release vmdq vsi's indev_close
i40e: increaseASQ_DELAY_MSto 100 andMAX_TRY_TIMESto 20 ini40evf_wait_cmd_done()i40e: call
_clear_cmd()when error occurs
i40e: clear queues ini40evf_dev_stop
i40e: check rxq parameter ini40e_reset_rx_queue
i40e: release queue memory in close functionsdrivers/net/i40e/i40e_ethdev.c | 78 ++++++++++++++++++++++++++++++++++++- drivers/net/i40e/i40e_ethdev_vf.c | 62 ++++++++++++++++++++++++++--- drivers/net/i40e/i40e_pf.c | 34 ++++++++++++++++ drivers/net/i40e/i40e_pf.h | 1 + drivers/net/i40e/i40e_rxtx.c | 25 ++++++++++++ drivers/net/i40e/i40e_rxtx.h | 1 + 6 files changed, 193 insertions(+), 8 deletions(-)
Quoted 2 lines
--
1.7.4.1
Thomas Monjalon
AppliedQuoted 11 lines
Quoted 9 lines
Bernard Iremonger (7):
i40e: changes to support PCI Port Hotplug
i40e: release vmdq vsi's indev_close
i40e: increaseASQ_DELAY_MSto 100 andMAX_TRY_TIMESto 20 ini40evf_wait_cmd_done()i40e: call
_clear_cmd()when error occurs
i40e: clear queues ini40evf_dev_stop
i40e: check rxq parameter ini40e_reset_rx_queue
i40e: release queue memory in close functionsAcked-by Helin Zhang <[email protected]>
Applied, thanks