From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f182.google.com (mail-wr0-f182.google.com [209.85.128.182]) by dpdk.org (Postfix) with ESMTP id E09D511F5 for ; Mon, 28 Aug 2017 11:55:33 +0200 (CEST) Received: by mail-wr0-f182.google.com with SMTP id y14so70012wrd.5 for ; Mon, 28 Aug 2017 02:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=jC4q/HJDy2/Aq6wvvA4Uv33/XZPhjHV4AxKwvMcfVz4=; b=AhfbslPHimT75A54U7Z/hLEgR4aF+P4PUMjgIce+GkvSLFZFHyDdb4GiQlrdlyjoDg UyrsCeDdk5K0QCs/HSIezvdt6iTLD0oVH7+zTnnQHzS9qV6MDfi7a7W94xqhQ/mk1eXb 0LHL8++wXig1TMtB51ERbCuDyTccGKHZSMGURWPtNlQnimavuXiZMk11LD5zpaTF7Ku2 EmEPA29nzubsbWlRUdODgiHD9BEW1PdrAph3vH708zZyG1rH7jcaopz/8aZkLJ4GsYK4 GB1/f4Fsi+vk2FnplQ5sNb7DHMWMfbOadhVV5itJSzni7Gso37WmnbirQOqABanelkWt QHLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=jC4q/HJDy2/Aq6wvvA4Uv33/XZPhjHV4AxKwvMcfVz4=; b=U0mrpAhP9ZD4lqPtnKX+NolJiftOuk6A4VW9J+EgrSM40qwvKNVObKI03J34dV7H+1 fowewxBZmqAhGWqxFhIsTyp/Pu/BfL1GLZaOTm+62e+5mBh7AIWouYWQlXUqDGNpDlSI +S4Iew+iHoPAlqByfdQIqbneqd5kMXkCp9v6OwPH95ZbrfnpiqtITiYPZtZJuSfVM5Il ktMs2ozxS0UmnxPvta8sGjQpEruL3aUSwjhF7ON1uTJZmTJpAsmwJtFrRitBn2dCAwLH aAGDZPYt+r2On0AVIUvN03TatIu7050EonPk5WiQdOTLGRxkp6BY86ddBK690mg75aOW qF4A== X-Gm-Message-State: AHYfb5iwJm8bcLsF2EY0i86i03kX+4DWVPM+SqFO2CoEcKg2PJZI8jIB 1YQPJc5UAYQngD5G X-Received: by 10.223.153.226 with SMTP id y89mr38518wrb.46.1503914133455; Mon, 28 Aug 2017 02:55:33 -0700 (PDT) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id n124sm26168wmd.16.2017.08.28.02.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 02:55:32 -0700 (PDT) Date: Mon, 28 Aug 2017 11:55:23 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Raslan Darawsheh Cc: thomas@monjalon.net, jingjing.wu@intel.com, dev@dpdk.org, salehals@mellanox.com Message-ID: <20170828095523.GE8124@bidouze.vm.6wind.com> References: <1503499024-12480-1-git-send-email-rasland@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1503499024-12480-1-git-send-email-rasland@mellanox.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [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: Mon, 28 Aug 2017 09:55:34 -0000 Hi Raslan, Redoing the review with the remarks from Thomas in mind. On Wed, Aug 23, 2017 at 05:37:04PM +0300, Raslan Darawsheh wrote: > 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" I think (device) might be hard to understand for a user. Maybe (device name)? > + " Remove a device" Here it should be: + " Remove a device.\n\n" > ); > } > > @@ -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, I know you have to follow the conventions set for this file and these names are correct. But I have to say: they are horrible. > + 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) { device is not descriptive enough. I think "devname" would be better. > + struct rte_devargs devargs; > + > + if (device == NULL) { > + printf("Invalid parameters are specified\n"); > + return; > + } No need to check for this. If device is NULL, something went very wrong. Having a hard segfault in this case will stop anyone in their tracks and force the bug to be investigated. And it has less LOCs. > + > + rte_eal_devargs_parse(device, &devargs); > + After some thinking, I think using the devargs_parse utility is the simplest and will allow the command to follow future evolutions without having to change anything here. > + 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 > -- Gaëtan Rivet 6WIND