From patchwork Wed Jul 11 21:45:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 42913 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A7D41B613; Wed, 11 Jul 2018 23:46:32 +0200 (CEST) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 786C21B5D3 for ; Wed, 11 Jul 2018 23:46:04 +0200 (CEST) Received: by mail-wr1-f67.google.com with SMTP id b15-v6so19623145wrv.10 for ; Wed, 11 Jul 2018 14:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sfROBCkcKSu7MugYwnSCnG2pjnchuWrpPxXKAiJhTgg=; b=c3ZerGzrSuilRLaL1l02dEkPzNLnWcis5CH+iztbRDsZwXukQwRFBUn10IiXM8/95x bBLtLfUmscPmHyI54Z3UzQoi4qOybPycaY6bbYUsnhmqTA5xTv7o1Czw4uUh+UUSwo1o 2lWFFHLDuqLQLFmhrEctjcPwURnOm6bhY9mO5EIc3wNSEainrAgndXIPkHWZXKqCeUn4 5FstpYHMG2GixAjHcHRRNJGs3D1GeJOmTVPe9yQBgFQvGhVKLypxhzJ2Zb9B3QY8Uj40 ubKOXPtd5WX9X3jnxSpuH32hIBv1U1ZEwfmRO5oC6Fnv7fHO/rSjdzb6MIWpQ6UZ7b+7 EhOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sfROBCkcKSu7MugYwnSCnG2pjnchuWrpPxXKAiJhTgg=; b=FbjUMSdzZAjd9Zaxs0ntlayNppmLNtAWAHr5XeGjR3OvX45MrinwCmNOozFLsu4A8f NGbO8361yGaAs26L30LILzxUYVy2gseg1+wwsERd4Co4yQmdEKPccy17Z9Q0K8auGeod Sj/jWaWzW7aT5vcItXX8mu1FVbljVzOUzkbzTofl7gcCpGRYSIflAoWmNNPYfrr4ZeiQ zPOT4K7gcoT4wMsNkp7ITF7uRFsLzzN05/b2jsrPRJbaSFwErj0CeIrKZ+JGORK5zBBp wgrIVXdUtllJv877fkvMlmmr036p7pkSdbfyNEnPY7za/kAVn84Yd9W87fbfyQQI7k9x cSzA== X-Gm-Message-State: AOUpUlHnct1XJ+uDWwHM/y54ADMGVHOTLq2QKmIjPSSAio7pBySnVvJh SX6m1FsGtd3JAp7Wn2HYvbcTfg5L X-Google-Smtp-Source: AAOMgpdbEIjceH8M2QsbcxuoJzk0YxS9uHsMqMlRUg87da8D1AD4ITK3rjXihZ+lm4Z6U1fQVE2Pfg== X-Received: by 2002:a5d:5088:: with SMTP id a8-v6mr221976wrt.37.1531345562804; Wed, 11 Jul 2018 14:46:02 -0700 (PDT) Received: from bidouze.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id h5-v6sm10550936wrr.19.2018.07.11.14.46.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 14:46:01 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 11 Jul 2018 23:45:10 +0200 Message-Id: <9f7a7087b34d5db728a9929f068dbd11ea496384.1531345404.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v11 20/25] app/testpmd: add show device 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" A new interactive command is offered: show device This commands lists all rte_device element matching the device description. e.g.: show device bus=pci show device bus=vdev show device bus=vdev/class=eth show device bus=vdev,driver=net_ring/class=eth show device bus=vdev/class=eth,name=net_ring0 These devices may not be otherwise useful, some buses will spawn devices to keep track of their assets without having a driver to use them. Signed-off-by: Gaetan Rivet Acked-by: Bernard Iremonger --- app/test-pmd/cmdline.c | 54 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 24 +++++++++ 2 files changed, 78 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 74a8cd99e..238ecfc56 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -228,6 +228,9 @@ static void cmd_help_long_parsed(void *parsed_result, "show port tm node stats (port_id) (node_id) (clear)\n" " Display the port TM node stats.\n\n" + "show device (device_string)\n" + " Display devices matching the device string.\n\n" + ); } @@ -7093,6 +7096,56 @@ cmdline_parse_inst_t cmd_showportall = { }, }; +/* *** SHOW DEVICE INFO *** */ +struct cmd_showdevice_result { + cmdline_fixed_string_t show; + cmdline_fixed_string_t device; + cmdline_fixed_string_t filter; +}; + +static void +cmd_showdevice_dump_device(const struct rte_device *dev) +{ + const struct rte_driver *drv = dev->driver; + + printf("0x%p: %s:%s\n", (const void *)dev, dev->name, + drv ? drv->name : ""); +} + +static void cmd_showdevice_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_showdevice_result *res = parsed_result; + struct rte_dev_iterator it; + const struct rte_device *dev; + + RTE_DEV_FOREACH(dev, res->filter, &it) + cmd_showdevice_dump_device(dev); +} + +cmdline_parse_token_string_t cmd_showdevice_show = + TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, + show, "show"); +cmdline_parse_token_string_t cmd_showdevice_device = + TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, + device, "device"); +cmdline_parse_token_string_t cmd_showdevice_filter = + TOKEN_STRING_INITIALIZER(struct cmd_showdevice_result, + filter, NULL); + +cmdline_parse_inst_t cmd_showdevice = { + .f = cmd_showdevice_parsed, + .data = NULL, + .help_str = "show device ", + .tokens = { + (void *)&cmd_showdevice_show, + (void *)&cmd_showdevice_device, + (void *)&cmd_showdevice_filter, + NULL, + }, +}; + /* *** SHOW PORT INFO *** */ struct cmd_showport_result { cmdline_fixed_string_t show; @@ -17272,6 +17325,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_help_long, (cmdline_parse_inst_t *)&cmd_quit, (cmdline_parse_inst_t *)&cmd_load_from_file, + (cmdline_parse_inst_t *)&cmd_showdevice, (cmdline_parse_inst_t *)&cmd_showport, (cmdline_parse_inst_t *)&cmd_showqueue, (cmdline_parse_inst_t *)&cmd_showportall, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 0d6fd50ca..4f1009a3a 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2628,6 +2628,30 @@ set the traffic management default hierarchy on the port:: testpmd> set port tm hierarchy default (port_id) +Device functions +---------------- + +Show devices +~~~~~~~~~~~~ + +Display any registered devices:: + + testpmd> show device + +where: + +* ``device_string``: Device description string, of the format + + layer[/layer[/layer]] + + where one layer is in the form + + layer_key=layer_name[,key1=value1[,...]] + + Valid layer keys are ``bus`` and ``class``. + Their respective values is defined by registered ``bus`` and ``class`` + drivers. + Filter Functions ----------------