From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1A97BC750 for ; Fri, 19 Jun 2015 10:36:51 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 19 Jun 2015 01:36:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,643,1427785200"; d="scan'208";a="713796615" Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86]) by orsmga001.jf.intel.com with ESMTP; 19 Jun 2015 01:36:50 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by KMSMSX151.gar.corp.intel.com (172.21.73.86) with Microsoft SMTP Server (TLS) id 14.3.224.2; Fri, 19 Jun 2015 16:36:49 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.246]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.46]) with mapi id 14.03.0224.002; Fri, 19 Jun 2015 16:36:47 +0800 From: "Qiu, Michael" To: "dev@dpdk.org" Thread-Topic: [PATCH 2/2 v2] fm10k: Add hotplug support for fm10k Thread-Index: AQHQqmqF2F/H0FIPCUayuPudyMLDtQ== Date: Fri, 19 Jun 2015 08:36:46 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E602860469DA9E@SHSMSX101.ccr.corp.intel.com> References: <1433938895-16331-1-git-send-email-michael.qiu@intel.com> <1434702717-11877-1-git-send-email-michael.qiu@intel.com> <1434702717-11877-3-git-send-email-michael.qiu@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 Cc: "He, Shaopeng" Subject: Re: [dpdk-dev] [PATCH 2/2 v2] fm10k: Add hotplug support for fm10k 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: Fri, 19 Jun 2015 08:36:52 -0000 Sorry this is version 3,=0A= =0A= Thanks=0A= Michael=0A= On 6/19/2015 4:32 PM, Qiu, Michael wrote:=0A= > Add hotplug support for fm10k.=0A= >=0A= > Signed-off-by: Michael Qiu =0A= > ---=0A= > drivers/net/fm10k/fm10k_ethdev.c | 97 ++++++++++++++++++++++++++++++++++= +++++-=0A= > 1 file changed, 96 insertions(+), 1 deletion(-)=0A= >=0A= > diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_e= thdev.c=0A= > index 6a14633..38d1eb7 100644=0A= > --- a/drivers/net/fm10k/fm10k_ethdev.c=0A= > +++ b/drivers/net/fm10k/fm10k_ethdev.c=0A= > @@ -1414,6 +1414,36 @@ fm10k_dev_enable_intr_pf(struct rte_eth_dev *dev)= =0A= > }=0A= > =0A= > static void=0A= > +fm10k_dev_disable_intr_pf(struct rte_eth_dev *dev)=0A= > +{=0A= > + struct fm10k_hw *hw =3D FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private)= ;=0A= > + uint32_t int_map =3D FM10K_INT_MAP_DISABLE;=0A= > +=0A= > + int_map |=3D 0;=0A= > +=0A= > + FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_Mailbox), int_map);=0A= > + FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_PCIeFault), int_map);=0A= > + FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchUpDown), int_map);=0A= > + FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SwitchEvent), int_map);=0A= > + FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_SRAM), int_map);=0A= > + FM10K_WRITE_REG(hw, FM10K_INT_MAP(fm10k_int_VFLR), int_map);=0A= > +=0A= > + /* Disable misc causes */=0A= > + FM10K_WRITE_REG(hw, FM10K_EIMR, FM10K_EIMR_DISABLE(PCA_FAULT) |=0A= > + FM10K_EIMR_DISABLE(THI_FAULT) |=0A= > + FM10K_EIMR_DISABLE(FUM_FAULT) |=0A= > + FM10K_EIMR_DISABLE(MAILBOX) |=0A= > + FM10K_EIMR_DISABLE(SWITCHREADY) |=0A= > + FM10K_EIMR_DISABLE(SWITCHNOTREADY) |=0A= > + FM10K_EIMR_DISABLE(SRAMERROR) |=0A= > + FM10K_EIMR_DISABLE(VFLR));=0A= > +=0A= > + /* Disable ITR 0 */=0A= > + FM10K_WRITE_REG(hw, FM10K_ITR(0), FM10K_ITR_MASK_SET);=0A= > + FM10K_WRITE_FLUSH(hw);=0A= > +}=0A= > +=0A= > +static void=0A= > fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)=0A= > {=0A= > struct fm10k_hw *hw =3D FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private)= ;=0A= > @@ -1431,6 +1461,22 @@ fm10k_dev_enable_intr_vf(struct rte_eth_dev *dev)= =0A= > FM10K_WRITE_FLUSH(hw);=0A= > }=0A= > =0A= > +static void=0A= > +fm10k_dev_disable_intr_vf(struct rte_eth_dev *dev)=0A= > +{=0A= > + struct fm10k_hw *hw =3D FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private)= ;=0A= > + uint32_t int_map =3D FM10K_INT_MAP_DISABLE;=0A= > +=0A= > + int_map |=3D 0;=0A= > +=0A= > + /* Only INT 0 available, other 15 are reserved. */=0A= > + FM10K_WRITE_REG(hw, FM10K_VFINT_MAP, int_map);=0A= > +=0A= > + /* Disable ITR 0 */=0A= > + FM10K_WRITE_REG(hw, FM10K_VFITR(0), FM10K_ITR_MASK_SET);=0A= > + FM10K_WRITE_FLUSH(hw);=0A= > +}=0A= > +=0A= > static int=0A= > fm10k_dev_handle_fault(struct fm10k_hw *hw, uint32_t eicr)=0A= > {=0A= > @@ -1860,6 +1906,54 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)=0A= > return 0;=0A= > }=0A= > =0A= > +static int=0A= > +eth_fm10k_dev_uninit(struct rte_eth_dev *dev)=0A= > +{=0A= > + struct fm10k_hw *hw =3D FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private)= ;=0A= > +=0A= > + PMD_INIT_FUNC_TRACE();=0A= > +=0A= > + /* only uninitialize in the primary process */=0A= > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY)=0A= > + return 0;=0A= > +=0A= > + /* safe to close dev here */=0A= > + fm10k_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 uio/vfio intr */=0A= > + rte_intr_disable(&(dev->pci_dev->intr_handle));=0A= > +=0A= > + /*PF/VF has different interrupt handling mechanism */=0A= > + if (hw->mac.type =3D=3D fm10k_mac_pf) {=0A= > + /* disable interrupt */=0A= > + fm10k_dev_disable_intr_pf(dev);=0A= > +=0A= > + /* unregister callback func to eal lib */=0A= > + rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),=0A= > + fm10k_dev_interrupt_handler_pf, (void *)dev);=0A= > + } else {=0A= > + /* disable interrupt */=0A= > + fm10k_dev_disable_intr_vf(dev);=0A= > +=0A= > + rte_intr_callback_unregister(&(dev->pci_dev->intr_handle),=0A= > + fm10k_dev_interrupt_handler_vf, (void *)dev);=0A= > + }=0A= > +=0A= > + /* free mac memory */=0A= > + if (dev->data->mac_addrs) {=0A= > + rte_free(dev->data->mac_addrs);=0A= > + dev->data->mac_addrs =3D NULL;=0A= > + }=0A= > +=0A= > + memset(hw, 0, sizeof(*hw));=0A= > +=0A= > + return 0;=0A= > +}=0A= > +=0A= > /*=0A= > * The set of PCI devices this driver supports. This driver will enable = both PF=0A= > * and SRIOV-VF devices.=0A= > @@ -1875,9 +1969,10 @@ static struct eth_driver rte_pmd_fm10k =3D {=0A= > .pci_drv =3D {=0A= > .name =3D "rte_pmd_fm10k",=0A= > .id_table =3D pci_id_fm10k_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_fm10k_dev_init,=0A= > + .eth_dev_uninit =3D eth_fm10k_dev_uninit,=0A= > .dev_private_size =3D sizeof(struct fm10k_adapter),=0A= > };=0A= > =0A= =0A=