From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0074.outbound.protection.outlook.com [104.47.0.74]) by dpdk.org (Postfix) with ESMTP id 37F807D33 for ; Wed, 23 Aug 2017 16:37:16 +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=QP4UTF3FuPy1d6P43Zt9IxEDRm57/Ym2h2T0g0+1qNI=; b=bWpqFvqZS89anmm388wfsfwsCB8LmLIkaA9+9NgNdLLHIGp7zMNom/z0OkAo6Nc1B6uEyAgOf78539vlWlmSbJhrP9kis8eq/biv7NsOMImxC0ENoRekhLuVaCbWzxIXqDED021XsRuZRzL+jFP8Yg5zus8EnIFhfkJKgz/0hnY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasland@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM2PR05MB1218.eurprd05.prod.outlook.com (2a01:111:e400:8450::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1362.18; Wed, 23 Aug 2017 14:37:13 +0000 From: Raslan Darawsheh To: thomas@monjalon.net, jingjing.wu@intel.com, gaetan.rivet@6wind.com Cc: dev@dpdk.org, salehals@mellanox.com Date: Wed, 23 Aug 2017 17:37:04 +0300 Message-Id: <1503499024-12480-1-git-send-email-rasland@mellanox.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0501CA0014.eurprd05.prod.outlook.com (2603:10a6:800:92::24) To AM2PR05MB1218.eurprd05.prod.outlook.com (2a01:111:e400:8450::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 034f6a34-0f35-4957-014d-08d4ea34723d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM2PR05MB1218; X-Microsoft-Exchange-Diagnostics: 1; AM2PR05MB1218; 3:5grYiJWpQqlTAQMBlK/au6mzVW6SCwyDvzA4rk+ogGqwas8g1K4iWGbEy4emn839ApJELl+NP2WU2guGL5oLQf5xsbeIrHHVLdmcEckIHTlEVjYLz9xtz6kUTvTeNragmxcyua1keeb1t7jQwYwGDfOtIDO1Dd4u2uo9ybd2th+4G9MLByKs5ExlbFNGui6sWSifP7rhfTCCQZUUOoqX26e6VnaCkhfsNXc7zAgYWIT1pYfMdXnDzYykniJjtEma; 25:qhHi7BuJwpadqEdHYUNsFJ1DqGIWHjiVXTJe/s+X4BsuY85DBCQozU90RxWyReGvqevuZSnv7tqjhI9gfhZen/FreQRIjD8NR61hRtP6eKxwKspFRYc2ayQnudy7tojsuCqXTLKKy1GFhj0MlWWGAREU2VK6ZAGk02wL1JBgv5NjEkjE1xUvoPLyJvk9tUeERbdPMnia9/sjzAOmZzvOT7UrL9RyJjDBkJyAawgp1TsmWR1ycICvwvfWauuhR0cv261D0TOMF8JRgpTSXHLfH6PVMtBUR5+vhudmB8b6p7qZ+x0VGUZKu++27LxRKWT9gGGfykmFqWC5+k7A4J1wQw==; 31:PPmQIvSsxIX1U9fmS6vhynJZ8UZtli+guTAgeCF+aadIW4tIRBubNrMf8Sa1q8kI2VDdF8SgYp2yk1bTm6wDpTTirIAhFTFtB2Iqo1HFbJsJNdDdCcl2EFIu5C2YkDTVm3rEytouuyhTgoDUDOzBNefZKadifd1m4ySGBeJM04x6RtMRPa5T5UnI5wzStJVAQTm1rh8zCzpMa4LqbPRgPToDYNgvLwePWRSDF48xZdk= X-MS-TrafficTypeDiagnostic: AM2PR05MB1218: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM2PR05MB1218; 20:cQsAfS4JwwoNdVIej2np/e7ODjyRpDznfCBAy/xnG7dDiuDXg7j8pTQv8i1kw2KB2dNY3z2nHsvbNFm5kLGKeAyVU0TRJ2IpH5GcN7yURrJy/zDJ7lXg6SQluTOlStw2qKsupqWrPrsYiFijX593IY1VAGtROug+HEiymUJp/zw/YRyxEl2RFVdRk3CWDRUG2YzwF3C/KXLV68KJ5SDZrndS3F+SKfgBqRDGD2jk6EK73c4dPLIUtJZ6UxOe8QiR+8NwRbvkalagb8cFm+KocnjJTRs3GmCvq8zTrhqBF8PcXV+0bUke8+8VcutkJFk6n/qG/hY6qZbiQgvr2QQQsRedSbcPK4usQXS3M8d6AdmDfOh3XpKy7iqhkYWrEzNxMndOE2joDAhRNITnGwZAy4pnBVXLNbaW4J9hV3IgZ+0DIous11MSukxopmbV9T9Nwk5BD4K7DZ3U4cB1tfC7AV/96dw6dW2iYKaAciGdGFg+Nc3oOpTBcnmxbCYb2XIY; 4:x/+C6hnmL7KMJIwKrBdRmJ5D6Flqr4MTdfwtLOmf/hB1/55YfL7JwSnVNqZMLYr8jwaz2TAJkxPXARZ2JKHfaxe1RvD3qx5r2FSbbPF8ttL0SqNDShbnLSL3pqvHfkZ1ItKiJSPnqHDgEZ2lOtxirknLzZRbG5TNO29X/SZaFJ2P7NC0SY3R5jDHN/RFSb3uH6pmWn+tFqXZJOG4GmG1wChxgoWDIVVxcqyoqu/UXrqZEmCKl8yEqChEgRHlAzG6 X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(20161123562025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM2PR05MB1218; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM2PR05MB1218; X-Forefront-PRVS: 040866B734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(7370300001)(4630300001)(6009001)(39860400002)(199003)(189002)(305945005)(5890100001)(50466002)(33646002)(42186005)(53936002)(4326008)(5660300001)(33026002)(81166006)(106356001)(50226002)(5003940100001)(101416001)(50986999)(8676002)(81156014)(7736002)(97736004)(105586002)(25786009)(47776003)(69596002)(478600001)(7350300001)(6666003)(2906002)(3846002)(107886003)(110136004)(68736007)(6116002)(21086003)(55016002)(36756003)(86362001)(66066001)(189998001)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM2PR05MB1218; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM2PR05MB1218; 23:/P5sq/LZKHWQXMRtojQ3WWrIO139FhYDQQnS518AL?= =?us-ascii?Q?UfcJ3gaQYTeUUAvnxlLDCV62Nta+bry135SMiD8u+p/6ujuVYgFVeAsWZiq3?= =?us-ascii?Q?uu+tRMygZntt7/+xmVGshFIdnWWnGl8rh9pisq1+iBxWkSVN72tQ6W6skBuC?= =?us-ascii?Q?gpgXQFlrTiKaN1CIMS7Qv/jXJ090zkTnVxR4F3axW3FnX/e6Uo+jJoFWFqgB?= =?us-ascii?Q?PFKMHiZ5RBB28qeF/5c2SzeZE9Cy+JNcOV5DmZ1VI7IOahl1zFpCE0+OTHHU?= =?us-ascii?Q?gFIXtC4lBFTSO83s+dd7ru5niGRANljtKYzc/3kthwFw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QAxt2c38EYRur7blRGFKRUYCK2pLbJiZ+W3YtCn8xszCwJWPU8EMJtSZbdb85o453zS4CFRAClF9APQTT8Tu1xkEEZS15r/LZ5M7hB182i5CPOiYOcetQGm5RIPv5rugFJzqzcDxGVo9K1XxkWNutjvC/bJzdmfvLPTtnVgAU/7+ZdJlrNXAIpvUNutXtLZrtKen+bdVkWAVYKiMoJyFe+0Rbxw8Wvr9UgY6bPyAMj9mJqGKaqFUtwTTDtOcGFfO01/nMIAivGmd1qatGOZeNP65YoAYCVU4f4aTRlpL7nWkoKj6qpOMPCt9PUx8Tg==; 5:ksCxhgaFyIOMMOhVUzJN1gNaExyD7itEW+iBh4iZ99Im9eCyCPK29IUyQC916B4+1s3Gel5lirinRjfz3UEGNoLA5fsgxnqB/Yqkt2IYOIS1iqGkOZjPD7D8I2dJHRvefMko40QzUhdxTC/z0nrS+A==; 24:6U6EfYmMt2mDXj9r8/mfNMMMV8wkm9ftlURZ8HXvl9ssBcmYeELq7bf+C+/g1c5jjpSGhppu1TOopq3nKDJUAuDdgqtX/FDFG2hc8v+/l0I=; 7:TmAP88XG/8McqSuAikguGfoaCNXNBPFwNt30CEq2bNGSP795JRvOszLHLVNTM9Ud/MlbLHL97jkQkz69A3Zaz/nyt8XeKq+NVvM5K+vEfOqVjXeGXJuDNMkiVqgT6+iFt1OGId+YLaojf/9DFtW7SG+4D4QUVZns5dnSxNo56gTIV7JDKaO2YoHlOQ91IKDJ+Nu52PG/BLomqsOQfXNMtM2JbccyximzXf6LbbQQMu0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2017 14:37:13.2507 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM2PR05MB1218 Subject: [dpdk-dev] [PATCH] app/testpmd: app/testpmd: add device removal command 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: Wed, 23 Aug 2017 14:37:16 -0000 Added hotplug in testpmd, to be able to test hotplug function in the PMD's. Signed-off-by: Raslan Darawsheh --- app/test-pmd/cmdline.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.c | 18 ++++++++++++++++++ app/test-pmd/testpmd.h | 1 + 3 files changed, 63 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index cd8c358..b32a368 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -716,6 +716,9 @@ static void cmd_help_long_parsed(void *parsed_result, "port config (port_id|all) l2-tunnel E-tag" " (enable|disable)\n" " Enable/disable the E-tag support.\n\n" + + " device remove (device)\n" + " Remove a device" ); } @@ -1125,6 +1128,46 @@ cmdline_parse_inst_t cmd_operate_detach_port = { }, }; +/* *** Remove a specified device *** */ +struct cmd_operate_device_remove_result { + cmdline_fixed_string_t device; + cmdline_fixed_string_t keyword; + cmdline_fixed_string_t identifier; +}; + +static void cmd_operate_device_remove_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_operate_device_remove_result *res = parsed_result; + if (!strcmp(res->keyword, "remove")) + device_remove((char *) res->identifier); + else + printf("Unknown parameter\n"); +} + +cmdline_parse_token_string_t cmd_operate_device_remove_device = + TOKEN_STRING_INITIALIZER(struct cmd_operate_device_remove_result, + device, "device"); +cmdline_parse_token_string_t cmd_operate_device_remove_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_operate_device_remove_result, + keyword, "remove"); +cmdline_parse_token_string_t cmd_operate_device_remove_identifier = + TOKEN_STRING_INITIALIZER(struct cmd_operate_device_remove_result, + identifier, NULL); + +cmdline_parse_inst_t cmd_operate_device_remove = { + .f = cmd_operate_device_remove_parsed, + .data = NULL, + .help_str = "device remove : (device)", + .tokens = { + (void *)&cmd_operate_device_remove_device, + (void *)&cmd_operate_device_remove_keyword, + (void *)&cmd_operate_device_remove_identifier, + NULL, + }, +}; + /* *** configure speed for all ports *** */ struct cmd_config_speed_all { cmdline_fixed_string_t port; @@ -14276,6 +14319,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_operate_specific_port, (cmdline_parse_inst_t *)&cmd_operate_attach_port, (cmdline_parse_inst_t *)&cmd_operate_detach_port, + (cmdline_parse_inst_t *)&cmd_operate_device_remove, (cmdline_parse_inst_t *)&cmd_config_speed_all, (cmdline_parse_inst_t *)&cmd_config_speed_specific, (cmdline_parse_inst_t *)&cmd_config_rx_tx, diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 7d40139..a2e8526 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1742,6 +1742,24 @@ detach_port(uint8_t port_id) } void +device_remove(char *device) { + struct rte_devargs devargs; + + if (device == NULL) { + printf("Invalid parameters are specified\n"); + return; + } + + rte_eal_devargs_parse(device, &devargs); + + if (rte_eal_hotplug_remove(devargs.bus->name, devargs.name)) { + printf("Fail to remove device\n"); + return; + } + printf("Device removed successfully\n"); +} + +void pmd_test_exit(void) { portid_t pt_id; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index c9d7739..0780f55 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -612,6 +612,7 @@ void stop_port(portid_t pid); void close_port(portid_t pid); void attach_port(char *identifier); void detach_port(uint8_t port_id); +void device_remove(char *device); int all_ports_stopped(void); int port_is_started(portid_t port_id); void pmd_test_exit(void); -- 2.7.4