From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.ics.ntt-tx.co.jp (mail05.ics.ntt-tx.co.jp [210.232.35.69]) by dpdk.org (Postfix) with ESMTP id 063B237B7 for ; Thu, 13 Sep 2018 05:02:16 +0200 (CEST) Received: from gwchk03.silk.ntt-tx.co.jp (gwchk03.silk.ntt-tx.co.jp [10.107.0.111]) by mail04.ics.ntt-tx.co.jp (unknown) with ESMTP id w8D32EWa023373 for unknown; Thu, 13 Sep 2018 12:02:14 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id w8D32EHm022741 for unknown; Thu, 13 Sep 2018 12:02:14 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id NAA22740; Thu, 13 Sep 2018 12:02:14 +0900 Received: from imss06.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by ccmail04.silk.ntt-tx.co.jp (unknown) with ESMTP id w8D32DJ3029578 for unknown; Thu, 13 Sep 2018 12:02:14 +0900 Received: from imss06.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by imss06.silk.ntt-tx.co.jp (unknown) with ESMTP id w8D32DHd007777 for unknown; Thu, 13 Sep 2018 12:02:13 +0900 Received: from ccmail04 (smtp03.silk.ntt-tx.co.jp [10.107.0.135]) by imss06.silk.ntt-tx.co.jp (unknown) with SMTP id w8D32DBa007774 for unknown; Thu, 13 Sep 2018 12:02:13 +0900 Date: Thu, 13 Sep 2018 12:00:14 +0900 From: Hideyuki Yamashita MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Mailer: Becky! ver. 2.74 [ja] X-CCMail7: CC-Mail-V7.0.2-Client-Relayed Message-Id: <201809130302.w8D31prh029191@ccmail04.silk.ntt-tx.co.jp> X-TM-AS-MML: No X-CC-Mail-RelayStamp: CC-Mail-V5.14-Server To: users@dpdk.org Subject: [dpdk-users] How to replace rte_eth_dev_attach with rte_eal_hotplug_add X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Sep 2018 03:02:17 -0000 Hello, =46rom dpdk 18.08 release rte_eth_dev_attach and=20 rte_eth_dev_detach becom deprecated API and=20 it is recommended to replace with rte_eal_hotplug_add and rte_eal_hotplug_remove. My program uses above mentioned deprecated APIs and have to replace those. Note that my program uses attach to attach vhost, pcap pmd. My question is whether it is correct to replace those as following: find rte_eth_dev_attach function in rte_ethdev.c and migrate those content into my program. [attach] refering lib/librte_ethdev/rte_ethdev.c ---------------------------------------------------------- 643 rte_eth_dev_attach(const char *devargs, uint16_t *port_id) 644 { 645 int current =3D rte_eth_dev_count_total(); 646 struct rte_devargs da; 647 int ret =3D -1; 648 649 memset(&da, 0, sizeof(da)); 650 651 if ((devargs =3D=3D NULL) || (port_id =3D=3D NULL)) { 652 ret =3D -EINVAL; 653 goto err; 654 } 655 656 /* parse devargs */ 657 if (rte_devargs_parse(&da, "%s", devargs)) 658 goto err; 659 660 ret =3D rte_eal_hotplug_add(da.bus->name, da.name, da.args)= ; 661 if (ret < 0) 662 goto err; 663 664 /* no point looking at the port count if no port exists */ 665 if (!rte_eth_dev_count_total()) { 666 ethdev_log(ERR, "No port found for device (%s)", da.= name); 667 ret =3D -1; 668 goto err; 669 } 670 671 /* if nothing happened, there is a bug here, since some dri= ver told us 672 * it did attach a device, but did not create a port. 673 * FIXME: race condition in case of plug-out of another dev= ice 674 */ 675 if (current =3D=3D rte_eth_dev_count_total()) { 676 ret =3D -1; 677 goto err; 678 } 679 680 *port_id =3D eth_dev_last_created_port; 681 ret =3D 0; 682 683 err: 684 free(da.args); 685 return ret; 686 } ---------------------------------------------------------- [detach]refering lib/librte_ethdev/rte_ethdev.c ----------------------------------------------------------- 690 rte_eth_dev_detach(uint16_t port_id, char *name __rte_unused) 691 { 692 struct rte_device *dev; 693 struct rte_bus *bus; 694 uint32_t dev_flags; 695 int ret =3D -1; 696 697 RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); 698 699 dev_flags =3D rte_eth_devices[port_id].data->dev_flags; 700 if (dev_flags & RTE_ETH_DEV_BONDED_SLAVE) { 701 ethdev_log(ERR, 702 "Port %" PRIu16 " is bonded, cannot detach"= , port_id); 703 return -ENOTSUP; 704 } 705 706 dev =3D rte_eth_devices[port_id].device; 707 if (dev =3D=3D NULL) 708 return -EINVAL; 709 710 bus =3D rte_bus_find_by_device(dev); 711 if (bus =3D=3D NULL) 712 return -ENOENT; 713 714 ret =3D rte_eal_hotplug_remove(bus->name, dev->name); 715 if (ret < 0) 716 return ret; 717 718 rte_eth_dev_release_port(&rte_eth_devices[port_id]); 719 return 0; 720 } ------------------------------------------------------------ If my post should be better to dev mailing list instead of=20 this mailing list, then please let me know. Your advice/guidance are much appreciated. Thanks! BR, Hideyuki Yamashita ----------------------------------------- Hideyuki Yamashita NTT TechnoCross -----------------------------------------