From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 28E00C4EE for ; Wed, 24 Jun 2015 10:07:02 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 24 Jun 2015 01:06:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,671,1427785200"; d="scan'208";a="513401127" Received: from pgsmsx101.gar.corp.intel.com ([10.221.44.78]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jun 2015 01:06:49 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by PGSMSX101.gar.corp.intel.com (10.221.44.78) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 24 Jun 2015 16:03:57 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.246]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.146]) with mapi id 14.03.0224.002; Wed, 24 Jun 2015 16:03:56 +0800 From: "Qiu, Michael" To: "Iremonger, Bernard" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC PATCH V2 1/4] i40e: changes to support PCI Port Hotplug Thread-Index: AQHQnuMtod9fXof12U+jesouMlXDrQ== Date: Wed, 24 Jun 2015 08:03:55 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E602860469FA22@SHSMSX101.ccr.corp.intel.com> References: <1433435087-9020-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 V2 1/4] i40e: 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 08:07:04 -0000 On 6/5/2015 12:26 AM, Bernard Iremonger wrote:=0A= > This patch depends on the Port Hotplug Framework.=0A= > It implements the eth_dev_uninit functions for rte_i40e_pmd and=0A= > rte_i40evf_pmd.=0A= >=0A= > Signed-off-by: Bernard Iremonger =0A= > ---=0A= =0A= Tested-by: Michael Qiu =0A= =0A= > drivers/net/i40e/i40e_ethdev.c | 79 +++++++++++++++++++++++++++++++= +++++-=0A= > drivers/net/i40e/i40e_ethdev_vf.c | 45 ++++++++++++++++++++-=0A= > drivers/net/i40e/i40e_pf.c | 34 ++++++++++++++++=0A= > drivers/net/i40e/i40e_pf.h | 1 +=0A= > 4 files changed, 157 insertions(+), 2 deletions(-)=0A= >=0A= > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethde= v.c=0A= > index da6c0b5..7bf9532 100644=0A= > --- a/drivers/net/i40e/i40e_ethdev.c=0A= > +++ b/drivers/net/i40e/i40e_ethdev.c=0A= > @@ -107,6 +107,7 @@=0A= > (1UL << RTE_ETH_FLOW_L2_PAYLOAD))=0A= > =0A= > static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);=0A= > +static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);=0A= > static int i40e_dev_configure(struct rte_eth_dev *dev);=0A= > static int i40e_dev_start(struct rte_eth_dev *dev);=0A= > static void i40e_dev_stop(struct rte_eth_dev *dev);=0A= > @@ -268,9 +269,11 @@ static struct eth_driver rte_i40e_pmd =3D {=0A= > {=0A= > .name =3D "rte_i40e_pmd",=0A= > .id_table =3D pci_id_i40e_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_i40e_dev_init,=0A= > + .eth_dev_uninit =3D eth_i40e_dev_uninit,=0A= > .dev_private_size =3D sizeof(struct i40e_adapter),=0A= > };=0A= > =0A= > @@ -405,6 +408,7 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)=0A= > hw->subsystem_device_id =3D pci_dev->id.subsystem_device_id;=0A= > hw->bus.device =3D pci_dev->addr.devid;=0A= > hw->bus.func =3D pci_dev->addr.function;=0A= > + hw->adapter_stopped =3D 0;=0A= > =0A= > /* Make sure all is clean before doing PF reset */=0A= > i40e_clear_hw(hw);=0A= > @@ -584,6 +588,76 @@ err_get_capabilities:=0A= > }=0A= > =0A= > static int=0A= > +eth_i40e_dev_uninit(struct rte_eth_dev *dev)=0A= > +{=0A= > + struct rte_pci_device *pci_dev;=0A= > + struct i40e_hw *hw;=0A= > + struct i40e_filter_control_settings settings;=0A= > + int ret;=0A= > + uint8_t aq_fail =3D 0;=0A= > + unsigned i;=0A= > +=0A= > + PMD_INIT_FUNC_TRACE();=0A= > +=0A= > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY)=0A= > + return 0;=0A= > +=0A= > + hw =3D I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);=0A= > + pci_dev =3D dev->pci_dev;=0A= > +=0A= > + if (hw->adapter_stopped =3D=3D 0)=0A= > + i40e_dev_close(dev);=0A= > +=0A= > + dev->dev_ops =3D NULL;=0A= > + dev->rx_pkt_burst =3D NULL;=0A= > + dev->tx_pkt_burst =3D NULL;=0A= > +=0A= > + /* Disable LLDP */=0A= > + ret =3D i40e_aq_stop_lldp(hw, true, NULL);=0A= > + if (ret !=3D I40E_SUCCESS) /* Its failure can be ignored */=0A= > + PMD_INIT_LOG(INFO, "Failed to stop lldp");=0A= > +=0A= > + /* Clear PXE mode */=0A= > + i40e_clear_pxe_mode(hw);=0A= > +=0A= > + /* Unconfigure filter control */=0A= > + memset(&settings, 0, sizeof(settings));=0A= > + ret =3D i40e_set_filter_control(hw, &settings);=0A= > + if (ret)=0A= > + PMD_INIT_LOG(WARNING, "setup_pf_filter_control failed: %d",=0A= > + ret);=0A= > +=0A= > + /* Disable flow control */=0A= > + hw->fc.requested_mode =3D I40E_FC_NONE;=0A= > + i40e_set_fc(hw, &aq_fail, TRUE);=0A= > +=0A= > + /* uninitialize pf host driver */=0A= > + i40e_pf_host_uninit(dev);=0A= > +=0A= > + for (i =3D 0; i < dev->data->nb_rx_queues; i++) {=0A= > + i40e_dev_rx_queue_release(dev->data->rx_queues[i]);=0A= > + dev->data->rx_queues[i] =3D NULL;=0A= > + }=0A= > +=0A= > + for (i =3D 0; i < dev->data->nb_tx_queues; i++) {=0A= > + i40e_dev_tx_queue_release(dev->data->tx_queues[i]);=0A= > + dev->data->tx_queues[i] =3D NULL;=0A= > + }=0A= > +=0A= > + rte_free(dev->data->mac_addrs);=0A= > + dev->data->mac_addrs =3D NULL;=0A= > +=0A= > + /* disable uio intr before callback unregister */=0A= > + rte_intr_disable(&(pci_dev->intr_handle));=0A= > +=0A= > + /* register callback func to eal lib */=0A= > + rte_intr_callback_unregister(&(pci_dev->intr_handle),=0A= > + i40e_dev_interrupt_handler, (void *)dev);=0A= > +=0A= > + return 0;=0A= > +}=0A= > +=0A= > +static int=0A= > i40e_dev_configure(struct rte_eth_dev *dev)=0A= > {=0A= > struct i40e_pf *pf =3D I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);= =0A= > @@ -858,6 +932,8 @@ i40e_dev_start(struct rte_eth_dev *dev)=0A= > struct i40e_vsi *main_vsi =3D pf->main_vsi;=0A= > int ret, i;=0A= > =0A= > + hw->adapter_stopped =3D 0;=0A= > +=0A= > if ((dev->data->dev_conf.link_duplex !=3D ETH_LINK_AUTONEG_DUPLEX) &&= =0A= > (dev->data->dev_conf.link_duplex !=3D ETH_LINK_FULL_DUPLEX)) {=0A= > PMD_INIT_LOG(ERR, "Invalid link_duplex (%hu) for port %hhu",=0A= > @@ -965,6 +1041,7 @@ i40e_dev_close(struct rte_eth_dev *dev)=0A= > PMD_INIT_FUNC_TRACE();=0A= > =0A= > i40e_dev_stop(dev);=0A= > + hw->adapter_stopped =3D 1;=0A= > =0A= > /* Disable interrupt */=0A= > i40e_pf_disable_irq0(hw);=0A= > diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_et= hdev_vf.c=0A= > index 9f92a2f..843ab9b 100644=0A= > --- a/drivers/net/i40e/i40e_ethdev_vf.c=0A= > +++ b/drivers/net/i40e/i40e_ethdev_vf.c=0A= > @@ -1146,6 +1146,22 @@ err:=0A= > }=0A= > =0A= > static int=0A= > +i40evf_uninit_vf(struct rte_eth_dev *dev)=0A= > +{=0A= > + struct i40e_vf *vf =3D I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private)= ;=0A= > + struct i40e_hw *hw =3D I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);= =0A= > +=0A= > + PMD_INIT_FUNC_TRACE();=0A= > +=0A= > + if (hw->adapter_stopped =3D=3D 0)=0A= > + i40evf_dev_close(dev);=0A= > + rte_free(vf->vf_res);=0A= > + vf->vf_res =3D NULL;=0A= > +=0A= > + return 0;=0A= > +}=0A= > +=0A= > +static int=0A= > i40evf_dev_init(struct rte_eth_dev *eth_dev)=0A= > {=0A= > struct i40e_hw *hw =3D I40E_DEV_PRIVATE_TO_HW(\=0A= > @@ -1175,6 +1191,7 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)=0A= > hw->bus.device =3D eth_dev->pci_dev->addr.devid;=0A= > hw->bus.func =3D eth_dev->pci_dev->addr.function;=0A= > hw->hw_addr =3D (void *)eth_dev->pci_dev->mem_resource[0].addr;=0A= > + hw->adapter_stopped =3D 0;=0A= > =0A= > if(i40evf_init_vf(eth_dev) !=3D 0) {=0A= > PMD_INIT_LOG(ERR, "Init vf failed");=0A= > @@ -1195,6 +1212,28 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev)=0A= > return 0;=0A= > }=0A= > =0A= > +static int=0A= > +i40evf_dev_uninit(struct rte_eth_dev *eth_dev)=0A= > +{=0A= > + PMD_INIT_FUNC_TRACE();=0A= > +=0A= > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY)=0A= > + return -EPERM;=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= > + if (i40evf_uninit_vf(eth_dev) !=3D 0) {=0A= > + PMD_INIT_LOG(ERR, "i40evf_uninit_vf failed");=0A= > + return -1;=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= > * virtual function driver struct=0A= > */=0A= > @@ -1202,9 +1241,10 @@ static struct eth_driver rte_i40evf_pmd =3D {=0A= > {=0A= > .name =3D "rte_i40evf_pmd",=0A= > .id_table =3D pci_id_i40evf_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 i40evf_dev_init,=0A= > + .eth_dev_uninit =3D i40evf_dev_uninit,=0A= > .dev_private_size =3D sizeof(struct i40e_vf),=0A= > };=0A= > =0A= > @@ -1473,6 +1513,8 @@ i40evf_dev_start(struct rte_eth_dev *dev)=0A= > =0A= > PMD_INIT_FUNC_TRACE();=0A= > =0A= > + hw->adapter_stopped =3D 0;=0A= > +=0A= > vf->max_pkt_len =3D dev->data->dev_conf.rxmode.max_rx_pkt_len;=0A= > if (dev->data->dev_conf.rxmode.jumbo_frame =3D=3D 1) {=0A= > if (vf->max_pkt_len <=3D ETHER_MAX_LEN ||=0A= > @@ -1680,6 +1722,7 @@ i40evf_dev_close(struct rte_eth_dev *dev)=0A= > struct i40e_hw *hw =3D I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);= =0A= > =0A= > i40evf_dev_stop(dev);=0A= > + hw->adapter_stopped =3D 1;=0A= > i40evf_reset_vf(hw);=0A= > i40e_shutdown_adminq(hw);=0A= > }=0A= > diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c=0A= > index b89a1e2..95c960c 100644=0A= > --- a/drivers/net/i40e/i40e_pf.c=0A= > +++ b/drivers/net/i40e/i40e_pf.c=0A= > @@ -1061,3 +1061,37 @@ fail:=0A= > =0A= > return ret;=0A= > }=0A= > +=0A= > +int=0A= > +i40e_pf_host_uninit(struct rte_eth_dev *dev)=0A= > +{=0A= > + struct i40e_pf *pf =3D I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);= =0A= > + struct i40e_hw *hw =3D I40E_PF_TO_HW(pf);=0A= > + uint32_t val;=0A= > +=0A= > + PMD_INIT_FUNC_TRACE();=0A= > +=0A= > + /**=0A= > + * return if SRIOV not enabled, VF number not configured or=0A= > + * no queue assigned.=0A= > + */=0A= > + if ((!hw->func_caps.sr_iov_1_1) ||=0A= > + (pf->vf_num =3D=3D 0) ||=0A= > + (pf->vf_nb_qps =3D=3D 0))=0A= > + return I40E_SUCCESS;=0A= > +=0A= > + /* free memory to store VF structure */=0A= > + rte_free(pf->vfs);=0A= > + pf->vfs =3D NULL;=0A= > +=0A= > + /* Disable irq0 for VFR event */=0A= > + i40e_pf_disable_irq0(hw);=0A= > +=0A= > + /* Disable VF link status interrupt */=0A= > + val =3D I40E_READ_REG(hw, I40E_PFGEN_PORTMDIO_NUM);=0A= > + val &=3D ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK;=0A= > + I40E_WRITE_REG(hw, I40E_PFGEN_PORTMDIO_NUM, val);=0A= > + I40E_WRITE_FLUSH(hw);=0A= > +=0A= > + return I40E_SUCCESS;=0A= > +}=0A= > diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h=0A= > index e08ba49..9c01829 100644=0A= > --- a/drivers/net/i40e/i40e_pf.h=0A= > +++ b/drivers/net/i40e/i40e_pf.h=0A= > @@ -123,5 +123,6 @@ void i40e_pf_host_handle_vf_msg(struct rte_eth_dev *d= ev,=0A= > __rte_unused uint32_t retval,=0A= > uint8_t *msg, uint16_t msglen);=0A= > int i40e_pf_host_init(struct rte_eth_dev *dev);=0A= > +int i40e_pf_host_uninit(struct rte_eth_dev *dev);=0A= > =0A= > #endif /* _I40E_PF_H_ */=0A= =0A=