From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 4C49EC634 for ; Wed, 24 Jun 2015 09:45:44 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 24 Jun 2015 00:45:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,671,1427785200"; d="scan'208";a="733564203" Received: from pgsmsx104.gar.corp.intel.com ([10.221.44.91]) by fmsmga001.fm.intel.com with ESMTP; 24 Jun 2015 00:45:42 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by PGSMSX104.gar.corp.intel.com (10.221.44.91) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 24 Jun 2015 15:45:41 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.246]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.129]) with mapi id 14.03.0224.002; Wed, 24 Jun 2015 15:45:40 +0800 From: "Qiu, Michael" To: "Iremonger, Bernard" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC PATCH V4] ixgbe: changes to support PCI Port Hotplug Thread-Index: AQHQogRhdzi8lF3yLki9MJMvCFAhdw== Date: Wed, 24 Jun 2015 07:45:39 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E602860469F9B7@SHSMSX101.ccr.corp.intel.com> References: <1433778458-17434-1-git-send-email-bernard.iremonger@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC PATCH V4] ixgbe: changes to support 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: Wed, 24 Jun 2015 07:45:45 -0000 On 6/9/2015 12:01 AM, Bernard Iremonger wrote:=0A= > This patch depends on the Port Hotplug Framework.=0A= > It implements the eth_dev_uninit functions for rte_ixgbe_pmd and=0A= > rte_ixgbevf_pmd.=0A= >=0A= > Changes in V4:=0A= > Release rx and tx queues in dev_uninit() functions.=0A= > Replace TRUE and FALSE with 1 and 0.=0A= >=0A= > Changes in V3:=0A= > Rebased to use drivers/net/ixgbe directory.=0A= >=0A= > Changes in V2:=0A= > Added call to dev_close() in dev_uninit() functions.=0A= > Removed input parameter checks from dev_uninit() functions.=0A= >=0A= > Signed-off-by: Bernard Iremonger =0A= =0A= Acked-by: Michael Qiu =0A= > ---=0A= > drivers/net/ixgbe/ixgbe_ethdev.c | 107 ++++++++++++++++++++++++++++++++= ++++--=0A= > drivers/net/ixgbe/ixgbe_ethdev.h | 2 +=0A= > drivers/net/ixgbe/ixgbe_pf.c | 22 ++++++++=0A= > 3 files changed, 126 insertions(+), 5 deletions(-)=0A= >=0A= > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_e= thdev.c=0A= > index 0d9f9b2..7f9d286 100644=0A= > --- a/drivers/net/ixgbe/ixgbe_ethdev.c=0A= > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c=0A= > @@ -117,6 +117,7 @@=0A= > #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_st= ats->qprc[0]))=0A= > =0A= > static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev);=0A= > +static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);=0A= > static int ixgbe_dev_configure(struct rte_eth_dev *dev);=0A= > static int ixgbe_dev_start(struct rte_eth_dev *dev);=0A= > static void ixgbe_dev_stop(struct rte_eth_dev *dev);=0A= > @@ -183,6 +184,7 @@ static void ixgbe_dcb_init(struct ixgbe_hw *hw,struct= ixgbe_dcb_config *dcb_conf=0A= > =0A= > /* For Virtual Function support */=0A= > static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);=0A= > +static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);=0A= > static int ixgbevf_dev_configure(struct rte_eth_dev *dev);=0A= > static int ixgbevf_dev_start(struct rte_eth_dev *dev);=0A= > static void ixgbevf_dev_stop(struct rte_eth_dev *dev);=0A= > @@ -916,6 +918,57 @@ eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev)=0A= > return 0;=0A= > }=0A= > =0A= > +static int=0A= > +eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)=0A= > +{=0A= > + struct rte_pci_device *pci_dev;=0A= > + struct ixgbe_hw *hw;=0A= > + unsigned i;=0A= > +=0A= > + PMD_INIT_FUNC_TRACE();=0A= > +=0A= > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY)=0A= > + return -EPERM;=0A= > +=0A= > + hw =3D IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);=0A= > + pci_dev =3D eth_dev->pci_dev;=0A= > +=0A= > + if (hw->adapter_stopped =3D=3D 0)=0A= > + ixgbe_dev_close(eth_dev);=0A= > +=0A= > + eth_dev->dev_ops =3D NULL;=0A= > + eth_dev->rx_pkt_burst =3D NULL;=0A= > + eth_dev->tx_pkt_burst =3D NULL;=0A= > +=0A= > + /* Unlock any pending hardware semaphore */=0A= > + ixgbe_swfw_lock_reset(hw);=0A= > +=0A= > + /* disable uio intr before callback unregister */=0A= > + rte_intr_disable(&(pci_dev->intr_handle));=0A= > + rte_intr_callback_unregister(&(pci_dev->intr_handle),=0A= > + ixgbe_dev_interrupt_handler, (void *)eth_dev);=0A= > +=0A= > + /* uninitialize PF if max_vfs not zero */=0A= > + ixgbe_pf_host_uninit(eth_dev);=0A= > +=0A= > + for (i =3D 0; i < eth_dev->data->nb_rx_queues; i++) {=0A= > + ixgbe_dev_rx_queue_release(eth_dev->data->rx_queues[i]);=0A= > + eth_dev->data->rx_queues[i] =3D NULL;=0A= > + }=0A= > +=0A= > + for (i =3D 0; i < eth_dev->data->nb_tx_queues; i++) {=0A= > + ixgbe_dev_tx_queue_release(eth_dev->data->tx_queues[i]);=0A= > + eth_dev->data->tx_queues[i] =3D NULL;=0A= > + }=0A= > +=0A= > + rte_free(eth_dev->data->mac_addrs);=0A= > + eth_dev->data->mac_addrs =3D NULL;=0A= > +=0A= > + rte_free(eth_dev->data->hash_mac_addrs);=0A= > + eth_dev->data->hash_mac_addrs =3D NULL;=0A= > +=0A= > + return 0;=0A= > +}=0A= > =0A= > /*=0A= > * Negotiate mailbox API version with the PF.=0A= > @@ -1086,13 +1139,56 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)= =0A= > return 0;=0A= > }=0A= > =0A= > +/* Virtual Function device uninit */=0A= > +=0A= > +static int=0A= > +eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)=0A= > +{=0A= > + struct ixgbe_hw *hw;=0A= > + unsigned i;=0A= > +=0A= > + PMD_INIT_FUNC_TRACE();=0A= > +=0A= > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY)=0A= > + return -EPERM;=0A= > +=0A= > + hw =3D IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);=0A= > +=0A= > + if (hw->adapter_stopped =3D=3D 0)=0A= > + ixgbevf_dev_close(eth_dev);=0A= > +=0A= > + eth_dev->dev_ops =3D NULL;=0A= > + eth_dev->rx_pkt_burst =3D NULL;=0A= > + eth_dev->tx_pkt_burst =3D NULL;=0A= > +=0A= > + /* Disable the interrupts for VF */=0A= > + ixgbevf_intr_disable(hw);=0A= > +=0A= > + for (i =3D 0; i < eth_dev->data->nb_rx_queues; i++) {=0A= > + ixgbe_dev_rx_queue_release(eth_dev->data->rx_queues[i]);=0A= > + eth_dev->data->rx_queues[i] =3D NULL;=0A= > + }=0A= > +=0A= > + for (i =3D 0; i < eth_dev->data->nb_tx_queues; i++) {=0A= > + ixgbe_dev_tx_queue_release(eth_dev->data->tx_queues[i]);=0A= > + eth_dev->data->tx_queues[i] =3D NULL;=0A= > + }=0A= > +=0A= > + rte_free(eth_dev->data->mac_addrs);=0A= > + eth_dev->data->mac_addrs =3D NULL;=0A= > +=0A= > + return 0;=0A= > +}=0A= > +=0A= > static struct eth_driver rte_ixgbe_pmd =3D {=0A= > {=0A= > .name =3D "rte_ixgbe_pmd",=0A= > .id_table =3D pci_id_ixgbe_map,=0A= > - .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,=0A= > + .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |=0A= > + RTE_PCI_DRV_DETACHABLE,=0A= > },=0A= > .eth_dev_init =3D eth_ixgbe_dev_init,=0A= > + .eth_dev_uninit =3D eth_ixgbe_dev_uninit,=0A= > .dev_private_size =3D sizeof(struct ixgbe_adapter),=0A= > };=0A= > =0A= > @@ -1103,9 +1199,10 @@ static struct eth_driver rte_ixgbevf_pmd =3D {=0A= > {=0A= > .name =3D "rte_ixgbevf_pmd",=0A= > .id_table =3D pci_id_ixgbevf_map,=0A= > - .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING,=0A= > + .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,=0A= > },=0A= > .eth_dev_init =3D eth_ixgbevf_dev_init,=0A= > + .eth_dev_uninit =3D eth_ixgbevf_dev_uninit,=0A= > .dev_private_size =3D sizeof(struct ixgbe_adapter),=0A= > };=0A= > =0A= > @@ -1475,7 +1572,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)=0A= > }=0A= > =0A= > /* stop adapter */=0A= > - hw->adapter_stopped =3D FALSE;=0A= > + hw->adapter_stopped =3D 0;=0A= > ixgbe_stop_adapter(hw);=0A= > =0A= > /* reinitialize adapter=0A= > @@ -1628,7 +1725,7 @@ ixgbe_dev_stop(struct rte_eth_dev *dev)=0A= > =0A= > /* reset the NIC */=0A= > ixgbe_pf_reset_hw(hw);=0A= > - hw->adapter_stopped =3D FALSE;=0A= > + hw->adapter_stopped =3D 0;=0A= > =0A= > /* stop adapter */=0A= > ixgbe_stop_adapter(hw);=0A= > @@ -3015,7 +3112,7 @@ ixgbevf_dev_stop(struct rte_eth_dev *dev)=0A= > =0A= > PMD_INIT_FUNC_TRACE();=0A= > =0A= > - hw->adapter_stopped =3D TRUE;=0A= > + hw->adapter_stopped =3D 1;=0A= > ixgbe_stop_adapter(hw);=0A= > =0A= > /*=0A= > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_e= thdev.h=0A= > index 19237b8..710ee87 100644=0A= > --- a/drivers/net/ixgbe/ixgbe_ethdev.h=0A= > +++ b/drivers/net/ixgbe/ixgbe_ethdev.h=0A= > @@ -389,6 +389,8 @@ void ixgbe_vlan_hw_strip_disable_all(struct rte_eth_d= ev *dev);=0A= > =0A= > void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev);=0A= > =0A= > +void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev);=0A= > +=0A= > void ixgbe_pf_mbx_process(struct rte_eth_dev *eth_dev);=0A= > =0A= > int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev);=0A= > diff --git a/drivers/net/ixgbe/ixgbe_pf.c b/drivers/net/ixgbe/ixgbe_pf.c= =0A= > index caed137..fd1c4ca 100644=0A= > --- a/drivers/net/ixgbe/ixgbe_pf.c=0A= > +++ b/drivers/net/ixgbe/ixgbe_pf.c=0A= > @@ -144,6 +144,28 @@ void ixgbe_pf_host_init(struct rte_eth_dev *eth_dev)= =0A= > return;=0A= > }=0A= > =0A= > +void ixgbe_pf_host_uninit(struct rte_eth_dev *eth_dev)=0A= > +{=0A= > + struct ixgbe_vf_info **vfinfo;=0A= > + uint16_t vf_num;=0A= > +=0A= > + PMD_INIT_FUNC_TRACE();=0A= > +=0A= > + vfinfo =3D IXGBE_DEV_PRIVATE_TO_P_VFDATA(eth_dev->data->dev_private);= =0A= > +=0A= > + RTE_ETH_DEV_SRIOV(eth_dev).active =3D 0;=0A= > + RTE_ETH_DEV_SRIOV(eth_dev).nb_q_per_pool =3D 0;=0A= > + RTE_ETH_DEV_SRIOV(eth_dev).def_vmdq_idx =3D 0;=0A= > + RTE_ETH_DEV_SRIOV(eth_dev).def_pool_q_idx =3D 0;=0A= > +=0A= > + vf_num =3D dev_num_vf(eth_dev);=0A= > + if (vf_num =3D=3D 0)=0A= > + return;=0A= > +=0A= > + rte_free(*vfinfo);=0A= > + *vfinfo =3D NULL;=0A= > +}=0A= > +=0A= > int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)=0A= > {=0A= > uint32_t vtctl, fcrth;=0A= =0A=