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 82C58C414 for ; Thu, 25 Jun 2015 04:33:55 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 24 Jun 2015 19:33:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,674,1427785200"; d="scan'208";a="513858472" Received: from pgsmsx107.gar.corp.intel.com ([10.221.44.105]) by FMSMGA003.fm.intel.com with ESMTP; 24 Jun 2015 19:33:54 -0700 Received: from kmsmsx154.gar.corp.intel.com (172.21.73.14) by PGSMSX107.gar.corp.intel.com (10.221.44.105) with Microsoft SMTP Server (TLS) id 14.3.224.2; Thu, 25 Jun 2015 10:33:41 +0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by KMSMSX154.gar.corp.intel.com (172.21.73.14) with Microsoft SMTP Server (TLS) id 14.3.224.2; Thu, 25 Jun 2015 10:33:41 +0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.129]) by shsmsx102.ccr.corp.intel.com ([169.254.2.165]) with mapi id 14.03.0224.002; Thu, 25 Jun 2015 10:33:40 +0800 From: "Zhang, Helin" To: "Iremonger, Bernard" , "dev@dpdk.org" Thread-Topic: [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes Thread-Index: AQHQrNhyvHmhT1qFz0ui1I48BgciRJ28hKQA Date: Thu, 25 Jun 2015 02:33:39 +0000 Message-ID: References: <1434969865-10527-1-git-send-email-bernard.iremonger@intel.com> In-Reply-To: <1434969865-10527-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] [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes 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: Thu, 25 Jun 2015 02:33:56 -0000 Hi Bernard > -----Original Message----- > From: Iremonger, Bernard > Sent: Monday, June 22, 2015 6:44 PM > To: dev@dpdk.org > Cc: Zhang, Helin; Iremonger, Bernard > Subject: [PATCH v6] e1000: igb and em1000 PCI Port Hotplug changes >=20 > This patch depends on the Port Hotplug Framework. > It implements the eth_dev_uninit functions for rte_em_pmd, rte_igb_pmd an= d > rte_igbvf_pmd. Would it be better to split this patch into smaller patches in a patch set = as you did for i40e hotplug? Regards, Helin >=20 > Changes in v6: > Set nb_rx_queues and nb_tx_queues to 0 in uninit functions. > Rebase to latest code. >=20 > Changes in V5: > Moved adapter stopped boolean to struct e1000_adapter. > Rebase to latest code. >=20 > Changes in V4: > Release rx and tx queues in eth_igbvf_dev_uninit. >=20 > Changes in V3: > Add igb_adapter_stopped and em_adapter_stopped booleans. > Release rx and tx queues in eth_igb_dev_uninit. >=20 > Changes in V2: > Call dev_close() from dev_uninit() functions. > Remove input parameter checking from dev_uninit() functions. >=20 > Signed-off-by: Bernard Iremonger > --- > drivers/net/e1000/e1000_ethdev.h | 8 ++- > drivers/net/e1000/em_ethdev.c | 59 ++++++++++++++++++- > drivers/net/e1000/igb_ethdev.c | 119 > +++++++++++++++++++++++++++++++++++++- > drivers/net/e1000/igb_pf.c | 22 +++++++ > 4 files changed, 203 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/net/e1000/e1000_ethdev.h > b/drivers/net/e1000/e1000_ethdev.h > index c451faa..ee8b872 100644 > --- a/drivers/net/e1000/e1000_ethdev.h > +++ b/drivers/net/e1000/e1000_ethdev.h > @@ -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 > @@ -229,8 +229,12 @@ struct e1000_adapter { > struct e1000_vfta shadow_vfta; > struct e1000_vf_info *vfdata; > struct e1000_filter_info filter; > + bool stopped; > }; >=20 > +#define E1000_DEV_PRIVATE(adapter) \ > + ((struct e1000_adapter *)adapter) > + > #define E1000_DEV_PRIVATE_TO_HW(adapter) \ > (&((struct e1000_adapter *)adapter)->hw) >=20 > @@ -337,4 +341,6 @@ uint16_t eth_em_recv_pkts(void *rx_queue, struct > rte_mbuf **rx_pkts, uint16_t eth_em_recv_scattered_pkts(void *rx_queue, > struct rte_mbuf **rx_pkts, > uint16_t nb_pkts); >=20 > +void igb_pf_host_uninit(struct rte_eth_dev *dev); > + > #endif /* _E1000_ETHDEV_H_ */ > diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.= c > index a306c55..b496c39 100644 > --- a/drivers/net/e1000/em_ethdev.c > +++ b/drivers/net/e1000/em_ethdev.c > @@ -224,6 +224,8 @@ static int > eth_em_dev_init(struct rte_eth_dev *eth_dev) { > struct rte_pci_device *pci_dev; > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(eth_dev->data->dev_private); > struct e1000_hw *hw =3D > E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); > struct e1000_vfta * shadow_vfta =3D > @@ -246,6 +248,7 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev) >=20 > hw->hw_addr =3D (void *)pci_dev->mem_resource[0].addr; > hw->device_id =3D pci_dev->id.device_id; > + adapter->stopped =3D 0; >=20 > /* For ICH8 support we'll need to map the flash memory BAR */ >=20 > @@ -285,13 +288,60 @@ eth_em_dev_init(struct rte_eth_dev *eth_dev) > return (0); > } >=20 > +static int > +eth_em_dev_uninit(struct rte_eth_dev *eth_dev) { > + struct rte_pci_device *pci_dev; > + unsigned i; > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(eth_dev->data->dev_private); > + > + PMD_INIT_FUNC_TRACE(); > + > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) > + return -EPERM; > + > + pci_dev =3D eth_dev->pci_dev; > + > + if (adapter->stopped =3D=3D 0) > + eth_em_close(eth_dev); > + > + eth_dev->dev_ops =3D NULL; > + eth_dev->rx_pkt_burst =3D NULL; > + eth_dev->tx_pkt_burst =3D NULL; > + > + rte_free(eth_dev->data->mac_addrs); > + eth_dev->data->mac_addrs =3D NULL; > + > + for (i =3D 0; i < eth_dev->data->nb_rx_queues; i++) { > + eth_em_rx_queue_release(eth_dev->data->rx_queues[i]); > + eth_dev->data->rx_queues[i] =3D NULL; > + } > + eth_dev->data->nb_rx_queues =3D 0; > + > + for (i =3D 0; i < eth_dev->data->nb_tx_queues; i++) { > + eth_em_tx_queue_release(eth_dev->data->tx_queues[i]); > + eth_dev->data->tx_queues[i] =3D NULL; > + } > + eth_dev->data->nb_tx_queues =3D 0; > + > + /* disable uio intr before callback unregister */ > + rte_intr_disable(&(pci_dev->intr_handle)); > + rte_intr_callback_unregister(&(pci_dev->intr_handle), > + eth_em_interrupt_handler, (void *)eth_dev); > + > + return 0; > +} > + > static struct eth_driver rte_em_pmd =3D { > .pci_drv =3D { > .name =3D "rte_em_pmd", > .id_table =3D pci_id_em_map, > - .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | > RTE_PCI_DRV_INTR_LSC, > + .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC > | > + RTE_PCI_DRV_DETACHABLE, > }, > .eth_dev_init =3D eth_em_dev_init, > + .eth_dev_uninit =3D eth_em_dev_uninit, > .dev_private_size =3D sizeof(struct e1000_adapter), }; >=20 > @@ -451,6 +501,8 @@ em_set_pba(struct e1000_hw *hw) static int > eth_em_start(struct rte_eth_dev *dev) { > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(dev->data->dev_private); > struct e1000_hw *hw =3D > E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > int ret, mask; > @@ -570,6 +622,8 @@ eth_em_start(struct rte_eth_dev *dev) > } > } >=20 > + adapter->stopped =3D 0; > + > PMD_INIT_LOG(DEBUG, "<<"); >=20 > return (0); > @@ -613,8 +667,11 @@ static void > eth_em_close(struct rte_eth_dev *dev) > { > struct e1000_hw *hw =3D > E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(dev->data->dev_private); >=20 > eth_em_stop(dev); > + adapter->stopped =3D 1; > e1000_phy_hw_reset(hw); > em_release_manageability(hw); > em_hw_control_release(hw); > diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethde= v.c > index 24c7510..16acdc9 100644 > --- a/drivers/net/e1000/igb_ethdev.c > +++ b/drivers/net/e1000/igb_ethdev.c > @@ -465,9 +465,12 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev) > struct e1000_hw *hw =3D > E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); > struct e1000_vfta * shadow_vfta =3D > - E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private); > + E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private); > struct e1000_filter_info *filter_info =3D > E1000_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private); > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(eth_dev->data->dev_private); > + > uint32_t ctrl_ext; >=20 > pci_dev =3D eth_dev->pci_dev; > @@ -570,6 +573,7 @@ eth_igb_dev_init(struct rte_eth_dev *eth_dev) > goto err_late; > } > hw->mac.get_link_status =3D 1; > + adapter->stopped =3D 0; >=20 > /* Indicate SOL/IDER usage */ > if (e1000_check_reset_block(hw) < 0) { @@ -614,6 +618,59 @@ err_late: > return (error); > } >=20 > +static int > +eth_igb_dev_uninit(struct rte_eth_dev *eth_dev) { > + struct rte_pci_device *pci_dev; > + struct e1000_hw *hw; > + unsigned i; > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(eth_dev->data->dev_private); > + > + PMD_INIT_FUNC_TRACE(); > + > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) > + return -EPERM; > + > + hw =3D E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); > + pci_dev =3D eth_dev->pci_dev; > + > + if (adapter->stopped =3D=3D 0) > + eth_igb_close(eth_dev); > + > + eth_dev->dev_ops =3D NULL; > + eth_dev->rx_pkt_burst =3D NULL; > + eth_dev->tx_pkt_burst =3D NULL; > + > + for (i =3D 0; i < eth_dev->data->nb_rx_queues; i++) { > + eth_igb_rx_queue_release(eth_dev->data->rx_queues[i]); > + eth_dev->data->rx_queues[i] =3D NULL; > + } > + eth_dev->data->nb_rx_queues =3D 0; > + > + for (i =3D 0; i < eth_dev->data->nb_tx_queues; i++) { > + eth_igb_tx_queue_release(eth_dev->data->tx_queues[i]); > + eth_dev->data->tx_queues[i] =3D NULL; > + } > + eth_dev->data->nb_tx_queues =3D 0; > + > + /* Reset any pending lock */ > + igb_reset_swfw_lock(hw); > + > + rte_free(eth_dev->data->mac_addrs); > + eth_dev->data->mac_addrs =3D NULL; > + > + /* uninitialize PF if max_vfs not zero */ > + igb_pf_host_uninit(eth_dev); > + > + /* disable uio intr before callback unregister */ > + rte_intr_disable(&(pci_dev->intr_handle)); > + rte_intr_callback_unregister(&(pci_dev->intr_handle), > + eth_igb_interrupt_handler, (void *)eth_dev); > + > + return 0; > +} > + > /* > * Virtual Function device init > */ > @@ -621,6 +678,8 @@ static int > eth_igbvf_dev_init(struct rte_eth_dev *eth_dev) { > struct rte_pci_device *pci_dev; > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(eth_dev->data->dev_private); > struct e1000_hw *hw =3D > E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); > int diag; > @@ -645,6 +704,7 @@ eth_igbvf_dev_init(struct rte_eth_dev *eth_dev) > hw->device_id =3D pci_dev->id.device_id; > hw->vendor_id =3D pci_dev->id.vendor_id; > hw->hw_addr =3D (void *)pci_dev->mem_resource[0].addr; > + adapter->stopped =3D 0; >=20 > /* Initialize the shared code (base driver) */ > diag =3D e1000_setup_init_funcs(hw, TRUE); @@ -685,13 +745,52 @@ > eth_igbvf_dev_init(struct rte_eth_dev *eth_dev) > return 0; > } >=20 > +static int > +eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev) { > + unsigned i; > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(eth_dev->data->dev_private); > + > + PMD_INIT_FUNC_TRACE(); > + > + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) > + return -EPERM; > + > + if (adapter->stopped =3D=3D 0) > + igbvf_dev_close(eth_dev); > + > + eth_dev->dev_ops =3D NULL; > + eth_dev->rx_pkt_burst =3D NULL; > + eth_dev->tx_pkt_burst =3D NULL; > + > + for (i =3D 0; i < eth_dev->data->nb_rx_queues; i++) { > + eth_igb_rx_queue_release(eth_dev->data->rx_queues[i]); > + eth_dev->data->rx_queues[i] =3D NULL; > + } > + eth_dev->data->nb_rx_queues =3D 0; > + > + for (i =3D 0; i < eth_dev->data->nb_tx_queues; i++) { > + eth_igb_tx_queue_release(eth_dev->data->tx_queues[i]); > + eth_dev->data->tx_queues[i] =3D NULL; > + } > + eth_dev->data->nb_tx_queues =3D 0; > + > + rte_free(eth_dev->data->mac_addrs); > + eth_dev->data->mac_addrs =3D NULL; > + > + return 0; > +} > + > static struct eth_driver rte_igb_pmd =3D { > .pci_drv =3D { > .name =3D "rte_igb_pmd", > .id_table =3D pci_id_igb_map, > - .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | > RTE_PCI_DRV_INTR_LSC, > + .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC > | > + RTE_PCI_DRV_DETACHABLE, > }, > .eth_dev_init =3D eth_igb_dev_init, > + .eth_dev_uninit =3D eth_igb_dev_uninit, > .dev_private_size =3D sizeof(struct e1000_adapter), }; >=20 > @@ -702,9 +801,10 @@ static struct eth_driver rte_igbvf_pmd =3D { > .pci_drv =3D { > .name =3D "rte_igbvf_pmd", > .id_table =3D pci_id_igbvf_map, > - .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING, > + .drv_flags =3D RTE_PCI_DRV_NEED_MAPPING | > RTE_PCI_DRV_DETACHABLE, > }, > .eth_dev_init =3D eth_igbvf_dev_init, > + .eth_dev_uninit =3D eth_igbvf_dev_uninit, > .dev_private_size =3D sizeof(struct e1000_adapter), }; >=20 > @@ -758,6 +858,8 @@ eth_igb_start(struct rte_eth_dev *dev) { > struct e1000_hw *hw =3D > E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(dev->data->dev_private); > int ret, i, mask; > uint32_t ctrl_ext; >=20 > @@ -786,6 +888,7 @@ eth_igb_start(struct rte_eth_dev *dev) > PMD_INIT_LOG(ERR, "Unable to initialize the hardware"); > return (-EIO); > } > + adapter->stopped =3D 0; >=20 > E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN << 16 | > ETHER_TYPE_VLAN); >=20 > @@ -992,9 +1095,13 @@ static void > eth_igb_close(struct rte_eth_dev *dev) > { > struct e1000_hw *hw =3D > E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(dev->data->dev_private); > struct rte_eth_link link; >=20 > eth_igb_stop(dev); > + adapter->stopped =3D 1; > + > e1000_phy_hw_reset(hw); > igb_release_manageability(hw); > igb_hw_control_release(hw); > @@ -2228,11 +2335,14 @@ igbvf_dev_start(struct rte_eth_dev *dev) { > struct e1000_hw *hw =3D > E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(dev->data->dev_private); > int ret; >=20 > PMD_INIT_FUNC_TRACE(); >=20 > hw->mac.ops.reset_hw(hw); > + adapter->stopped =3D 0; >=20 > /* Set all vfta */ > igbvf_set_vfta_all(dev,1); > @@ -2270,12 +2380,15 @@ static void > igbvf_dev_close(struct rte_eth_dev *dev) { > struct e1000_hw *hw =3D > E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private); > + struct e1000_adapter *adapter =3D > + E1000_DEV_PRIVATE(dev->data->dev_private); >=20 > PMD_INIT_FUNC_TRACE(); >=20 > e1000_reset_hw(hw); >=20 > igbvf_dev_stop(dev); > + adapter->stopped =3D 1; > } >=20 > static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on) di= ff --git > a/drivers/net/e1000/igb_pf.c b/drivers/net/e1000/igb_pf.c index > 6a4d210..26c2960 100644 > --- a/drivers/net/e1000/igb_pf.c > +++ b/drivers/net/e1000/igb_pf.c > @@ -127,6 +127,28 @@ void igb_pf_host_init(struct rte_eth_dev *eth_dev) > return; > } >=20 > +void igb_pf_host_uninit(struct rte_eth_dev *dev) { > + struct e1000_vf_info **vfinfo; > + uint16_t vf_num; > + > + PMD_INIT_FUNC_TRACE(); > + > + vfinfo =3D E1000_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private); > + > + RTE_ETH_DEV_SRIOV(dev).active =3D 0; > + RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool =3D 0; > + RTE_ETH_DEV_SRIOV(dev).def_vmdq_idx =3D 0; > + RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx =3D 0; > + > + vf_num =3D dev_num_vf(dev); > + if (vf_num =3D=3D 0) > + return; > + > + rte_free(*vfinfo); > + *vfinfo =3D NULL; > +} > + > #define E1000_RAH_POOLSEL_SHIFT (18) > int igb_pf_host_configure(struct rte_eth_dev *eth_dev) { > -- > 1.7.4.1