From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0053.outbound.protection.outlook.com [104.47.2.53]) by dpdk.org (Postfix) with ESMTP id D8C77187 for ; Thu, 3 May 2018 09:25:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=2MLOSvSosJbVvlwLKKxeQFI0hWOU7WwYeq4PI1dvwe4=; b=Vwg2nGVQMdwb1oaEms+W0UrL8OS7Ompa+RwygrZuquP+fC6SXMZT4D4GdZ7NNCPaFzU8Tkw3gSDb3emnfulkTm0XigMaXA3UlgafmvMdUzRP/KGjfCHmEbpo+/Dl0639wRLYD1sMWE1rpVgOBGz0roZeSZGWNYACurfqbUs+PxI= Received: from AM4PR0501MB2657.eurprd05.prod.outlook.com (10.172.215.19) by AM4PR0501MB2724.eurprd05.prod.outlook.com (10.172.215.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.735.16; Thu, 3 May 2018 07:25:49 +0000 Received: from AM4PR0501MB2657.eurprd05.prod.outlook.com ([fe80::60c2:4238:d5c3:ac46]) by AM4PR0501MB2657.eurprd05.prod.outlook.com ([fe80::60c2:4238:d5c3:ac46%10]) with mapi id 15.20.0735.016; Thu, 3 May 2018 07:25:49 +0000 From: Matan Azrad To: Jeff Guo , "stephen@networkplumber.org" , "bruce.richardson@intel.com" , "ferruh.yigit@intel.com" , "konstantin.ananyev@intel.com" , "gaetan.rivet@6wind.com" , "jingjing.wu@intel.com" , Thomas Monjalon , Mordechay Haimovsky , "harry.van.haaren@intel.com" , "jianfeng.tan@intel.com" CC: "jblunck@infradead.org" , "shreyansh.jain@nxp.com" , "dev@dpdk.org" , "helin.zhang@intel.com" Thread-Topic: [PATCH V20 4/4] app/testpmd: show example to handler hot unplug Thread-Index: AQHT1xq0jeUHyU30VESlBVYGqb+wqqQdobsw Date: Thu, 3 May 2018 07:25:49 +0000 Message-ID: References: <1498711073-42917-1-git-send-email-jia.guo@intel.com> <1524058689-4954-1-git-send-email-jia.guo@intel.com> <1524058689-4954-5-git-send-email-jia.guo@intel.com> In-Reply-To: <1524058689-4954-5-git-send-email-jia.guo@intel.com> Accept-Language: en-US, he-IL Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR0501MB2724; 7:/09s2fQ6BMnweBRUg5vRR4r8+umUlGklXgX00aUT3YqCVIoXXeZBtSdr7mMkDhmt0b6oRQ5a3fgyHZxZB6/IUEwKU8t2SyT1tKsTFyI+kGWxrUgDnz3gyzIJRpnH582cqxaTcX8r0WND5tINYZFTQfryLuORd0re1EgAfh1K+q/dbvm2r5wUnP6Mob0HZoF3CTBzzHlmHVdocyQI1x7q1b75pfm4hxES54YcOphkToQJFEuzM1BXqEKNWkTxb5dQ x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:AM4PR0501MB2724; x-ms-traffictypediagnostic: AM4PR0501MB2724: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231254)(944501410)(52105095)(3002001)(10201501046)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:AM4PR0501MB2724; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0501MB2724; x-forefront-prvs: 066153096A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(39860400002)(396003)(376002)(39380400002)(199004)(189003)(6436002)(68736007)(2900100001)(97736004)(7736002)(229853002)(11346002)(486006)(102836004)(476003)(2501003)(26005)(110136005)(54906003)(4326008)(316002)(5250100002)(66066001)(446003)(2201001)(86362001)(6346003)(186003)(6506007)(6116002)(478600001)(6246003)(33656002)(76176011)(7696005)(2906002)(14454004)(3660700001)(59450400001)(3280700002)(8656006)(3846002)(55016002)(53936002)(99286004)(9686003)(105586002)(106356001)(81166006)(81156014)(5660300001)(74316002)(8676002)(8936002)(25786009)(7416002)(305945005)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0501MB2724; H:AM4PR0501MB2657.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; x-microsoft-antispam-message-info: yRw0Z1u6qo3t17x82o3YqVDLc3GWpaQRuIL8Jy2uv79Ns2eH8ezEtqQw3bySOiiw8ZkLnx+36Vp9LosQFPfpgrGum3gDh2BFS5vFEltDxfdb7965XM7BflfXmTkIeaFjpmXEJmVyN1RieQggYhcGs2y2jsOI+gKbmp0DmpC5e+BqatlLYzW9n5Uf12mXEf4E spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 5d801e37-3e02-4e26-3cc3-08d5b0c71826 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d801e37-3e02-4e26-3cc3-08d5b0c71826 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 May 2018 07:25:49.1631 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB2724 Subject: Re: [dpdk-dev] [PATCH V20 4/4] app/testpmd: show example to handler hot unplug 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: Thu, 03 May 2018 07:25:51 -0000 Hi Jeff > From: Jeff Guo, Wednesday, April 18, 2018 4:38 PM > Use testpmd for example, to show how an application smoothly handle > failure when device being hot unplug. Once app detect the removal event, > the callback would be called, it first stop the packet forwarding, then s= top the > port, close the port and finally detach the port. >=20 > Signed-off-by: Jeff Guo > --- > v20->v19: > remove the auto binding example. > --- > app/test-pmd/testpmd.c | 29 +++++++++++++++++++++++++---- > 1 file changed, 25 insertions(+), 4 deletions(-) >=20 > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index > 5986ff7..3751901 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -1125,6 +1125,9 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, > packet_fwd_t pkt_fwd) > tics_datum =3D rte_rdtsc(); > tics_per_1sec =3D rte_get_timer_hz(); > #endif > + if (hot_plug) > + rte_dev_handle_hot_unplug(); > + Again, I don't understand why the application should configure it - it alre= ady started the hot-plug, Can't the EAL handle this automatically when the user starts the hot-plug? > fsm =3D &fwd_streams[fc->stream_idx]; > nb_fs =3D fc->stream_nb; > do { > @@ -2069,6 +2072,26 @@ rmv_event_callback(void *arg) > dev->device->name); > } >=20 > +static void > +rmv_dev_event_callback(char *dev_name) > +{ > + uint16_t port_id; > + int ret; > + > + ret =3D rte_eth_dev_get_port_by_name(dev_name, &port_id); > + if (ret) { > + printf("can not get port by device %s!\n", dev_name); > + return; > + } > + > + RTE_ETH_VALID_PORTID_OR_RET(port_id); > + printf("removing port id:%u\n", port_id); > + stop_packet_forwarding(); > + stop_port(port_id); > + close_port(port_id); > + detach_port(port_id); > +} We have also the rmv_event_callback() which is triggered by a RMV interrupt= and running by the host thread. What is the context thread of rmv_dev_event_callback()? Shouldn't they be synchronized? Should we need both in the same time? > + > /* This function is used by the interrupt thread */ static int > eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void > *param, @@ -2130,9 +2153,7 @@ eth_dev_event_callback(char > *device_name, enum rte_dev_event_type type, > case RTE_DEV_EVENT_REMOVE: > RTE_LOG(ERR, EAL, "The device: %s has been removed!\n", > device_name); > - /* TODO: After finish failure handle, begin to stop > - * packet forward, stop port, close port, detach port. > - */ > + rmv_dev_event_callback(device_name); > break; > case RTE_DEV_EVENT_ADD: > RTE_LOG(ERR, EAL, "The device: %s has been added!\n", > @@ -2640,7 +2661,7 @@ main(int argc, char** argv) > return -1; > } > eth_dev_event_callback_register(); > - > + rte_dev_handle_hot_unplug(); > } >=20 > if (start_port(RTE_PORT_ALL) !=3D 0) > -- > 2.7.4