From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 427C3952 for ; Tue, 9 Feb 2016 10:34:15 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 09 Feb 2016 01:34:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,420,1449561600"; d="scan'208";a="880257340" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by orsmga001.jf.intel.com with ESMTP; 09 Feb 2016 01:34:13 -0800 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.102]) by irsmsx105.ger.corp.intel.com ([169.254.7.237]) with mapi id 14.03.0248.002; Tue, 9 Feb 2016 09:34:12 +0000 From: "Iremonger, Bernard" To: Wojciech Zmuda , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] af_packet: make the device detachable Thread-Index: AQHRR8IYIcF4FmhahEehTDFyPGyFSZ8id2NggAEx/3A= Date: Tue, 9 Feb 2016 09:34:11 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C219FAF9A8@IRSMSX108.ger.corp.intel.com> References: <1452002675-8919-1-git-send-email-woz@semihalf.com> <8CEF83825BEC744B83065625E567D7C219FAF745@IRSMSX108.ger.corp.intel.com> In-Reply-To: <8CEF83825BEC744B83065625E567D7C219FAF745@IRSMSX108.ger.corp.intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDAxYzdmODAtNjc1OC00YjlkLTkwNzktNzczZjg5ODZkM2QxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiaWRcLzRPdHVjeUpPQnM5M05DTlVkOFY5OXlXTUFiVDRiZzRUZUlod3lBQU09In0= x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] af_packet: make the device detachable 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: Tue, 09 Feb 2016 09:34:15 -0000 Hi Wojciech > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wojciech Zmuda > > Sent: Tuesday, January 5, 2016 2:05 PM > > To: dev@dpdk.org > > Subject: [dpdk-dev] [PATCH] af_packet: make the device detachable > > > > Fix memory leak when detaching virtual device. Set dev_flags to > > RTE_ETH_DEV_DETACHABLE and implement pmd_af_packet_drv.uninit > method. > > Copy device name to ethdev->data to make it compatibile with >=20 > Typo, compatibile should be compatible. >=20 > > rte_eth_dev_allocated(). > > > > Signed-off-by: Wojciech Zmuda > > --- > > drivers/net/af_packet/rte_eth_af_packet.c | 29 > > ++++++++++++++++++++++++++++- > > 1 file changed, 28 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/net/af_packet/rte_eth_af_packet.c > > b/drivers/net/af_packet/rte_eth_af_packet.c > > index 767f36b..7ef65ff 100644 > > --- a/drivers/net/af_packet/rte_eth_af_packet.c > > +++ b/drivers/net/af_packet/rte_eth_af_packet.c > > @@ -667,11 +667,13 @@ rte_pmd_init_internals(const char *name, > > data->nb_tx_queues =3D (uint16_t)nb_queues; > > data->dev_link =3D pmd_link; > > data->mac_addrs =3D &(*internals)->eth_addr; > > + strncpy(data->name, > > + (*eth_dev)->data->name, strlen((*eth_dev)->data- > > >name)); > > > > (*eth_dev)->data =3D data; > > (*eth_dev)->dev_ops =3D &ops; > > (*eth_dev)->driver =3D NULL; > > - (*eth_dev)->data->dev_flags =3D 0; > > + (*eth_dev)->data->dev_flags =3D RTE_ETH_DEV_DETACHABLE; > > (*eth_dev)->data->drv_name =3D drivername; > > (*eth_dev)->data->kdrv =3D RTE_KDRV_NONE; > > (*eth_dev)->data->numa_node =3D numa_node; @@ -836,10 +838,35 > @@ exit: > > return ret; > > } > > > > +static int > > +rte_pmd_af_packet_devuninit(const char *name) { > > + struct rte_eth_dev *eth_dev =3D NULL; > > + > > + RTE_LOG(INFO, PMD, "Closing AF_PACKET ethdev on numa socket > > %u\n", > > + rte_socket_id()); > > + > > + if (name =3D=3D NULL) > > + return -1; > > + > > + /* reserve an ethdev entry */ >=20 > Above comment should be /* find the ethdev entry */ >=20 > > + eth_dev =3D rte_eth_dev_allocated(name); > > + if (eth_dev =3D=3D NULL) > > + return -1; > > + >=20 > In rte_pmd_init_internals() memory is allocated for rx and tx queues this > should also be freed. >=20 > Line 606: rx_queue->rd =3D rte_zmalloc_socket(name, rdsize, 0, numa_node)= ; > Line 620:tx_queue->rd =3D rte_zmalloc_socket(name, rdsize, 0, numa_node); >=20 > rte_free((*internals)->rx_queue[q].rd); > rte_free((*internals)->tx_queue[q].rd); >=20 > > + rte_free(eth_dev->data->dev_private); > > + rte_free(eth_dev->data); > > + > > + rte_eth_dev_release_port(eth_dev); > > + > > + return 0; > > +} > > + > > static struct rte_driver pmd_af_packet_drv =3D { > > .name =3D "eth_af_packet", > > .type =3D PMD_VDEV, > > .init =3D rte_pmd_af_packet_devinit, > > + .uninit =3D rte_pmd_af_packet_devuninit, > > }; > > > > PMD_REGISTER_DRIVER(pmd_af_packet_drv); > > -- > > 1.9.1 Forgot to mention that there should probably be and entry in the 2.3 releas= e notes, new features section, for this. Regards, Bernard.