From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <michael.qiu@intel.com>
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65])
 by dpdk.org (Postfix) with ESMTP id 0E7FCC2FE
 for <dev@dpdk.org>; Wed, 22 Apr 2015 05:16:39 +0200 (CEST)
Received: from orsmga003.jf.intel.com ([10.7.209.27])
 by orsmga103.jf.intel.com with ESMTP; 21 Apr 2015 20:16:38 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.11,620,1422950400"; d="scan'208";a="559804237"
Received: from kmsmsx151.gar.corp.intel.com ([172.21.73.86])
 by orsmga003.jf.intel.com with ESMTP; 21 Apr 2015 20:16:38 -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; Wed, 22 Apr 2015 11:14:31 +0800
Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.107]) by
 SHSMSX103.ccr.corp.intel.com ([10.239.4.69]) with mapi id 14.03.0224.002;
 Wed, 22 Apr 2015 11:14:29 +0800
From: "Qiu, Michael" <michael.qiu@intel.com>
To: "Iremonger, Bernard" <bernard.iremonger@intel.com>, "dev@dpdk.org"
 <dev@dpdk.org>
Thread-Topic: [dpdk-dev] [RFC PATCH] librte_pmd_ixgbe: changes to support
 PCI	Port Hotplug
Thread-Index: AQHQceNQyf1tkijeC0mtALal4hGVUg==
Date: Wed, 22 Apr 2015 03:14:28 +0000
Message-ID: <533710CFB86FA344BFBF2D6802E6028604664809@SHSMSX101.ccr.corp.intel.com>
References: <RFC PATCH>
 <1428487373-27646-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] librte_pmd_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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 22 Apr 2015 03:16:41 -0000

On 4/8/2015 6:03 PM, 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.pmd.=0A=
>=0A=
> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>=0A=
> ---=0A=
=0A=
Tested-by: Michael Qiu <michael.qiu@intel.com>=0A=
=0A=
>  lib/librte_pmd_ixgbe/ixgbe_ethdev.c |   87 +++++++++++++++++++++++++++++=
++++-=0A=
>  lib/librte_pmd_ixgbe/ixgbe_ethdev.h |    4 +-=0A=
>  lib/librte_pmd_ixgbe/ixgbe_pf.c     |   30 ++++++++++++-=0A=
>  3 files changed, 116 insertions(+), 5 deletions(-)=0A=
>=0A=
> diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/i=
xgbe_ethdev.c=0A=
> index 5caee22..464398a 100644=0A=
> --- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c=0A=
> +++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c=0A=
> @@ -1,7 +1,7 @@=0A=
>  /*-=0A=
>   *   BSD LICENSE=0A=
>   *=0A=
> - *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.=0A=
> + *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.=0A=
>   *   All rights reserved.=0A=
>   *=0A=
>   *   Redistribution and use in source and binary forms, with or without=
=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=
> @@ -917,6 +919,49 @@ 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=
> +=0A=
> +	PMD_INIT_FUNC_TRACE();=0A=
> +=0A=
> +	if ((eth_dev =3D=3D NULL) ||=0A=
> +		(eth_dev->data =3D=3D NULL) ||=0A=
> +		(eth_dev->data->dev_private =3D=3D NULL) ||=0A=
> +		(eth_dev->pci_dev =3D=3D NULL))=0A=
> +		return -EINVAL;=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=
> +	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=
> +	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=
> @@ -1087,13 +1132,48 @@ eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)=
=0A=
>  	return 0;=0A=
>  }=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=
> +=0A=
> +	PMD_INIT_FUNC_TRACE();=0A=
> +=0A=
> +	if ((eth_dev =3D=3D NULL) ||=0A=
> +		(eth_dev->data =3D=3D NULL) ||=0A=
> +		(eth_dev->data->dev_private =3D=3D NULL))=0A=
> +		return -EINVAL;=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=
> +	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=
> +	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=
> @@ -1104,9 +1184,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=
> diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h b/lib/librte_pmd_ixgbe/i=
xgbe_ethdev.h=0A=
> index ffe3471..ad7e190 100644=0A=
> --- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.h=0A=
> +++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.h=0A=
> @@ -1,7 +1,7 @@=0A=
>  /*-=0A=
>   *   BSD LICENSE=0A=
>   *=0A=
> - *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.=0A=
> + *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.=0A=
>   *   All rights reserved.=0A=
>   *=0A=
>   *   Redistribution and use in source and binary forms, with or without=
=0A=
> @@ -376,6 +376,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/lib/librte_pmd_ixgbe/ixgbe_pf.c b/lib/librte_pmd_ixgbe/ixgbe=
_pf.c=0A=
> index dbda9b5..b7491a8 100644=0A=
> --- a/lib/librte_pmd_ixgbe/ixgbe_pf.c=0A=
> +++ b/lib/librte_pmd_ixgbe/ixgbe_pf.c=0A=
> @@ -1,7 +1,7 @@=0A=
>  /*-=0A=
>   *   BSD LICENSE=0A=
>   *=0A=
> - *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.=0A=
> + *   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.=0A=
>   *   All rights reserved.=0A=
>   *=0A=
>   *   Redistribution and use in source and binary forms, with or without=
=0A=
> @@ -144,6 +144,34 @@ 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=
> +	if ((eth_dev =3D=3D NULL) ||=0A=
> +		(eth_dev->data =3D=3D NULL) ||=0A=
> +		(eth_dev->data->dev_private =3D=3D NULL))=0A=
> +		return;=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=
> +=0A=
>  int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)=0A=
>  {=0A=
>  	uint32_t vtctl, fcrth;=0A=
=0A=