From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id BFEAF69D4 for ; Fri, 24 Mar 2017 10:07:31 +0100 (CET) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP; 24 Mar 2017 02:07:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,214,1486454400"; d="scan'208";a="80156047" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga005.fm.intel.com with ESMTP; 24 Mar 2017 02:07:30 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 24 Mar 2017 02:07:30 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 24 Mar 2017 02:07:29 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.253]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.82]) with mapi id 14.03.0248.002; Fri, 24 Mar 2017 17:07:26 +0800 From: "Wu, Jingjing" To: "Zhao1, Wei" , "dev@dpdk.org" CC: "Zhao1, Wei" , "Lu, Wenzhuo" Thread-Topic: [dpdk-dev] [PATCH 3/3] net/i40e: implement device reset on port Thread-Index: AQHSk9ujZIIdPiJSP0+UHhKUl/ZIFqGjzhww Date: Fri, 24 Mar 2017 09:07:25 +0000 Message-ID: <9BB6961774997848B5B42BEC655768F810D1335C@SHSMSX103.ccr.corp.intel.com> References: <1488516984-34702-1-git-send-email-wei.zhao1@intel.com> <1488516984-34702-4-git-send-email-wei.zhao1@intel.com> In-Reply-To: <1488516984-34702-4-git-send-email-wei.zhao1@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 3/3] net/i40e: implement device reset on port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Mar 2017 09:07:32 -0000 > /* > * Structure to store private data specific for VF instance. > */ > @@ -708,6 +718,10 @@ struct i40e_adapter { > struct rte_timecounter systime_tc; > struct rte_timecounter rx_tstamp_tc; > struct rte_timecounter tx_tstamp_tc; > + > + /* For VF reset */ > + volatile uint8_t reset_number; > + void *reset_store_data; > }; How to move it to i40_vf? Or it can be used for PF in future? > + > +static int > +i40evf_store_before_reset(struct rte_eth_dev *dev) { > + struct i40e_adapter *adapter =3D > + I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); > + struct i40e_vf_reset_store *store_data; > + struct i40e_vf *vf =3D I40EVF_DEV_PRIVATE_TO_VF(dev->data- > >dev_private); > + > + adapter->reset_store_data =3D rte_zmalloc("i40evf_store_reset", > + sizeof(struct i40e_vf_reset_store), 0); > + if (adapter->reset_store_data =3D=3D NULL) { > + PMD_INIT_LOG(ERR, "Failed to allocate %ld bytes needed to" > + " to store data when reset vf", > + sizeof(struct i40e_vf_reset_store)); > + return -ENOMEM; > + } i40evf_store_before_reset is allocated when reset happens. Don't forget to free it when reset is done. Otherwise memory leak. The same as below mac_addrs. > + store_data =3D > + (struct i40e_vf_reset_store *)adapter->reset_store_data; > + store_data->mac_addrs =3D rte_zmalloc("i40evf_mac_store_reset", > + ETHER_ADDR_LEN * I40E_NUM_MACADDR_MAX, 0); > + if (store_data->mac_addrs =3D=3D NULL) { > + PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to" > + " to store MAC addresses when reset vf", > + ETHER_ADDR_LEN * > I40E_NUM_MACADDR_MAX); > + } > + > + memcpy(store_data->mac_addrs, dev->data->mac_addrs, > + ETHER_ADDR_LEN * I40E_NUM_MACADDR_MAX); > + > + store_data->promisc_unicast_enabled =3D vf->promisc_unicast_enabled; > + store_data->promisc_multicast_enabled =3D vf- > >promisc_multicast_enabled; > + > + store_data->vlan_num =3D vf->vsi.vlan_num; > + memcpy(store_data->vfta, vf->vsi.vfta, > + sizeof(uint32_t) * I40E_VFTA_SIZE); > + > + store_data->mac_num =3D vf->vsi.mac_num; > + > + return 0; > +} > +static int > +i40evf_handle_vf_reset(struct rte_eth_dev *dev) { > + struct i40e_adapter *adapter =3D > + I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); > + > + if (!dev->data->dev_started) > + return 0; > + I think even the dev is not started, we also need to reset it. Because the VF need to reconnect with PF. > + adapter->reset_number =3D 1; > + i40e_vf_reset_dev(dev); > + adapter->reset_number =3D 0; > + How to name the reset_number to resetting?