From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id D5F0A5949 for ; Thu, 12 Mar 2015 18:05:30 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 12 Mar 2015 10:05:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,390,1422950400"; d="scan'208";a="540042293" Received: from irsmsx103.ger.corp.intel.com ([163.33.3.157]) by orsmga003.jf.intel.com with ESMTP; 12 Mar 2015 10:04:45 -0700 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by IRSMSX103.ger.corp.intel.com (163.33.3.157) with Microsoft SMTP Server (TLS) id 14.3.195.1; Thu, 12 Mar 2015 17:05:26 +0000 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.218]) by irsmsx155.ger.corp.intel.com ([169.254.14.159]) with mapi id 14.03.0195.001; Thu, 12 Mar 2015 17:05:26 +0000 From: "Iremonger, Bernard" To: "John W. Linville" , "dev@dpdk.org" , Tetsuya Mukawa Thread-Topic: [dpdk-dev] [RFC] af_packet: support port hotplug Thread-Index: AQHQW2JtUg1URoy06Eq1E49y1KzJ+p0ZEp/Q Date: Thu, 12 Mar 2015 17:05:26 +0000 Message-ID: <8CEF83825BEC744B83065625E567D7C2049F26C7@IRSMSX108.ger.corp.intel.com> References: <1426012584-3614-1-git-send-email-linville@tuxdriver.com> In-Reply-To: <1426012584-3614-1-git-send-email-linville@tuxdriver.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC] af_packet: support port hotplug 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, 12 Mar 2015 17:05:31 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of John W. Linville > Sent: Tuesday, March 10, 2015 6:36 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [RFC] af_packet: support port hotplug >=20 > This patch adds finalization code to free resources allocated by the PMD.= This is based on earlier > patches for other PMDs by Tetsuya Mukawa , with correc= tions related to data- > >name. >=20 > Signed-off-by: John W. Linville > Cc: Tetsuya Mukawa > --- > lib/librte_pmd_af_packet/rte_eth_af_packet.c | 56 ++++++++++++++++++++++= ++++++ > 1 file changed, 56 insertions(+) >=20 > diff --git a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > index 80e9bdf7f819..57998ab19c96 100644 > --- a/lib/librte_pmd_af_packet/rte_eth_af_packet.c > +++ b/lib/librte_pmd_af_packet/rte_eth_af_packet.c > @@ -399,6 +399,13 @@ static struct eth_dev_ops ops =3D { > .stats_reset =3D eth_stats_reset, > }; >=20 > +static struct eth_driver rte_af_packet_pmd =3D { > + .pci_drv =3D { > + .name =3D "rte_af_packet_pmd", > + .drv_flags =3D RTE_PCI_DRV_DETACHABLE, > + }, > +}; > + > /* > * Opens an AF_PACKET socket > */ > @@ -653,6 +660,10 @@ rte_pmd_init_internals(const char *name, > if (*eth_dev =3D=3D NULL) > goto error; >=20 > + /* check length of device name */ > + if ((strlen((*eth_dev)->data->name) + 1) > sizeof(data->name)) > + goto error; > + > /* > * now put it all together > * - store queue data in internals, > @@ -669,12 +680,14 @@ 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)); >=20 > pci_dev->numa_node =3D numa_node; >=20 > (*eth_dev)->data =3D data; > (*eth_dev)->dev_ops =3D &ops; > (*eth_dev)->pci_dev =3D pci_dev; > + (*eth_dev)->driver =3D &rte_af_packet_pmd; >=20 > return 0; >=20 > @@ -835,10 +848,53 @@ rte_pmd_af_packet_devinit(const char *name, const c= har *params) > return 0; > } >=20 > +static int > +rte_pmd_af_packet_devuninit(const char *name) { > + struct rte_eth_dev *eth_dev =3D NULL; > + struct pmd_internals *internals; > + struct tpacket_req req; > + > + unsigned q; > + > + RTE_LOG(INFO, PMD, "Closing AF_PACKET ethdev on numa socket %u\n", > + rte_socket_id()); > + > + if (name =3D=3D NULL) > + return -1; Hi Tetsuya, John, Before detaching a port, the port must be stopped and closed. The stop and close are only allowed for RTE_PROC_PRIMARY. Should there be a check for process_type here? if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) return -EPERM; Regards, Bernard > + > + /* retrieve ethdev entry */ > + eth_dev =3D rte_eth_dev_allocated(name); > + if (eth_dev =3D=3D NULL) > + return -1; > + > + internals =3D eth_dev->data->dev_private; > + req =3D internals->req; > + > + for (q =3D 0; q < internals->nb_queues; q++) { > + munmap(internals->rx_queue[q].map, > + 2 * req.tp_block_size * req.tp_block_nr); > + if (internals->rx_queue[q].rd) > + rte_free(internals->rx_queue[q].rd); > + if (internals->tx_queue[q].rd) > + rte_free(internals->tx_queue[q].rd); > + } > + > + rte_free(internals); > + rte_free(eth_dev->data); > + rte_free(eth_dev->pci_dev); > + > + 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, > }; >=20 > PMD_REGISTER_DRIVER(pmd_af_packet_drv); > -- > 2.1.0