From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by dpdk.org (Postfix) with ESMTP id 794E65699 for ; Wed, 19 Sep 2018 18:04:13 +0200 (CEST) Received: by mail-wm1-f66.google.com with SMTP id f21-v6so6857224wmc.5 for ; Wed, 19 Sep 2018 09:04:13 -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=FvhY+YAnwiiwZBn48UFQVSUX3r0Tgg2B0Fc2W5fBDyM=; b=sdORt7azUqsYktq1HvsmdC2h6T/raNDIvUa3sqnIxRBlKbBLOoBtqseZV5XL5Tk7To hf6ApLhE05pokyLv5hJbN4/sBUSQLnQ49Dmf5koUPBinpHoyRZSqCHyGlfsDGdXv+a+P 2swfVrWy6cByRr1qiKBXGD0XDFmYp5xT8vR+0LbF6dWR+YQdObT+xDKtOezTbNV5Fm81 Eu+0SIG06Zgp/RN6f44zX/TUCbprc2nZSA2Gm7iCFApl9Ec1ovgZ3+2KlkIN6H0+T415 pIm4Sj1fn4txelmPVN0tkSRc2GNVPy+C84krp9knGWPf6lym19k/4HPLhsPkyiHNdiqy kovw== 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=FvhY+YAnwiiwZBn48UFQVSUX3r0Tgg2B0Fc2W5fBDyM=; b=Q+PlK6ZLHSU5e3jl9EwQjHXyEI3Nc/JX+5jJ8Tw3vHwq43jr1o3K56R0Zg9+PbTCVd SfEtAJJxZ3Nu1w7W3w4c/ZmjjFBL6GkuKT4CsBXfLiyJa0IjhzS6e10IO++dXWVd+zOd vPSJpVEVp/yqh3rZnvEgTQVNO10YUZ5Zcx1u0O+s5y5pX7QVQx8G9B5gKpxdC6JzYhR8 rYSoDNUCiNX7nptJ4fy+1uvIz0EtmagtzVT1vjr+vKYP53NOdBzrx9p3GuVRSUSQ8Bfv Yy7nZyMrLr5ccPzG+jLSYHxqb5FPFw5a2iHF6wWjxmceesnqfrtGuVyDx09MFWmDMrxY 2ElA== X-Gm-Message-State: APzg51CEzBDPRRgBJ0OLqHPbiFD1ZkBu3m6xyBmN7CU9lStmIhoCAKWx brR8DdE33j2dAABFx2D4hqRXNteNoq4= X-Google-Smtp-Source: ANB0VdbxZokAfk7ozoDDMYuULVHhe3Mx6Bq5bWVV1EQD3Gk16C5xWro+S2vzo4x+JlWc6wZdjbG7pQ== X-Received: by 2002:a1c:a60e:: with SMTP id p14-v6mr21481621wme.64.1537373052695; Wed, 19 Sep 2018 09:04:12 -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 x24-v6sm34983671wrd.13.2018.09.19.09.04.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 09:04:11 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 19 Sep 2018 18:03:38 +0200 Message-Id: <0ef3d5cfdcfb80f8e2a2be7860d59748b1fde3be.1537372746.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 08/13] 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: , X-List-Received-Date: Wed, 19 Sep 2018 16:04:13 -0000 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 0cbd340c1..a4846d9a8 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" + ); } @@ -7115,6 +7118,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; @@ -17608,6 +17661,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 dde205a2b..417072cce 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2663,6 +2663,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 ---------------- -- 2.18.0