From: Leon Romanovsky <leon@kernel.org>
To: Stephen Hemminger <stephen@networkplumber.org>,
Doug Ledford <dledford@redhat.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
Jiri Pirko <jiri@mellanox.com>, Ariel Almog <ariela@mellanox.com>,
Dennis Dalessandro <dennis.dalessandro@intel.com>,
Ram Amrani <ram.amrani@cavium.com>,
Bart Van Assche <Bart.VanAssche@sandisk.com>,
Sagi Grimberg <sagi@grimberg.me>,
Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
Christoph Hellwig <hch@lst.de>,
Or Gerlitz <ogerlitz@mellanox.com>,
Linux RDMA <linux-rdma@vger.kernel.org>,
Linux Netdev <netdev@vger.kernel.org>
Subject: [RFC iproute2 2/8] rdma: Add dev object
Date: Thu, 4 May 2017 21:02:10 +0300 [thread overview]
Message-ID: <20170504180216.7665-3-leon@kernel.org> (raw)
In-Reply-To: <20170504180216.7665-1-leon@kernel.org>
From: Leon Romanovsky <leonro@mellanox.com>
Device (dev) object represents struct ib_device to user space.
The supported commands are show, set and help.
Print all devices:
# rdma dev
1: mlx5_0: board_id MT_2190110032 fw_pages 261002 fw_ver 12.17.2046 hca_type MT4115 hw_rev 0
node_desc hpchead HCA-1 node_guid e41d:2d03:0066:dee6 node_type 1: CA reg_pages 0
sys_image_guid e41d:2d03:0066:dee6
2: mlx5_1: board_id MT_2190110032 fw_pages 250793 fw_ver 12.17.2046 hca_type MT4115 hw_rev 0
node_desc hpchead HCA-2 node_guid e41d:2d03:0066:dee7 node_type 1: CA reg_pages 0
sys_image_guid e41d:2d03:0066:dee6
3: mlx5_2: board_id MT_1210110019 fw_pages 68067 fw_ver 10.16.1020 hca_type MT4113 hw_rev 0
node_desc hpchead HCA-3 node_guid 0002:c903:0016:75b0 node_type 1: CA reg_pages 0
sys_image_guid 0002:c903:0016:75b0
Print specific device:
# rdma dev show mlx5_1
2: mlx5_1: board_id MT_2190110032 fw_pages 250793 fw_ver 12.17.2046 hca_type MT4115 hw_rev 0
node_desc hpchead HCA-2 node_guid e41d:2d03:0066:dee7 node_type 1: CA reg_pages 0
sys_image_guid e41d:2d03:0066:dee6
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
rdma/Makefile | 2 +-
rdma/dev.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rdma/rdma.c | 3 +-
rdma/rdma.h | 5 +++
4 files changed, 109 insertions(+), 2 deletions(-)
create mode 100644 rdma/dev.c
diff --git a/rdma/Makefile b/rdma/Makefile
index 65248b31..67e349b0 100644
--- a/rdma/Makefile
+++ b/rdma/Makefile
@@ -1,6 +1,6 @@
include ../Config
-RDMA_OBJ = rdma.o utils.o
+RDMA_OBJ = rdma.o utils.o dev.o
TARGETS=rdma
all: $(TARGETS) $(LIBS)
diff --git a/rdma/dev.c b/rdma/dev.c
new file mode 100644
index 00000000..e6d71035
--- /dev/null
+++ b/rdma/dev.c
@@ -0,0 +1,101 @@
+/*
+ * dev.c RDMA tool
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Leon Romanovsky <leonro@mellanox.com>
+ */
+
+#include "rdma.h"
+
+static int dev_help(struct rdma *rd)
+{
+ pr_out("Usage: %s dev show [DEV]\n", rd->filename);
+ pr_out(" %s dev set DEV [ node_desc { DESCRIPTION } ]\n", rd->filename);
+ /* Add masking of device capabilities */
+ return 0;
+}
+
+static void dev_one_show(const struct dev_map *dev_map)
+{
+ char *nodes[] = { "board_id",
+ "fw_pages",
+ "fw_ver",
+ "hca_type",
+ "hw_rev",
+ "node_desc",
+ "node_guid",
+ "node_type",
+ "reg_pages",
+ "sys_image_guid",
+ /* hfi1 specific */
+ "nctxts",
+ "nfreectxts",
+ "serial",
+ "boardversion",
+ "tempsense",
+ NULL };
+
+ char data[4096];
+ int i;
+ pr_out("%u: %s:", dev_map->idx, dev_map->dev_name);
+ for (i = 0 ; nodes[i] ; i++) {
+ if (rdma_sysfs_read_ib(dev_map->dev_name, 0, nodes[i], data))
+ continue;
+
+ /* Split line before "node_desc" */
+ if (!strcmp(nodes[i], "node_desc") ||
+ !strcmp(nodes[i], "sys_image_guid"))
+ printf("\n\t");
+
+ pr_out(" %s %s", nodes[i], data);
+ }
+ pr_out("\n");
+}
+
+static int dev_show(struct rdma *rd)
+{
+ struct dev_map *dev_map;
+
+ if (rd_no_arg(rd)) {
+ list_for_each_entry(dev_map, &rd->dev_map_list, list)
+ dev_one_show(dev_map);
+ }
+ else {
+ dev_map = dev_map_lookup(rd, false);
+ if (!dev_map) {
+ pr_err("Wrong device name\n");
+ return -ENOENT;
+ }
+ dev_one_show(dev_map);
+ }
+ return 0;
+}
+
+static int dev_set(struct rdma *rd)
+{
+ /* Not implemented yet */
+ return 0;
+}
+
+int obj_dev(struct rdma *rd)
+{
+ const struct rdma_obj objs[] = {
+ { NULL, dev_show },
+ { "show", dev_show },
+ { "list", dev_show },
+ { "set", dev_set },
+ { "help", dev_help },
+ { 0 }
+ };
+
+ if (dev_map_init(rd)) {
+ pr_err("There are no RDMA devices\n");
+ return -ENOENT;
+ }
+
+ return rdma_exec_cmd(rd, objs, "dev command");
+}
diff --git a/rdma/rdma.c b/rdma/rdma.c
index bc7d1483..7c537c5e 100644
--- a/rdma/rdma.c
+++ b/rdma/rdma.c
@@ -17,7 +17,7 @@
static void help(char *name)
{
pr_out("Usage: %s [ OPTIONS ] OBJECT { COMMAND | help }\n"
- "where OBJECT := { }\n"
+ "where OBJECT := { dev }\n"
" OPTIONS := { -V[ersion] }\n", name);
}
@@ -31,6 +31,7 @@ static int rd_cmd(struct rdma *rd)
{
const struct rdma_obj objs[] = {
{ NULL, obj_help },
+ { "dev", obj_dev },
{ "help", obj_help },
{ 0 }
};
diff --git a/rdma/rdma.h b/rdma/rdma.h
index 156bb74c..2d81cd92 100644
--- a/rdma/rdma.h
+++ b/rdma/rdma.h
@@ -60,6 +60,11 @@ struct rdma_obj {
};
/*
+ * Command interfaces
+ */
+int obj_dev(struct rdma *rd);
+
+/*
* Parser interface
*/
bool rd_no_arg(struct rdma *rd);
next prev parent reply other threads:[~2017-05-04 18:02 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 18:02 [RFC iproute2 0/8] RDMA tool Leon Romanovsky
2017-05-04 18:02 ` Leon Romanovsky [this message]
2017-05-04 18:02 ` [RFC iproute2 3/8] rdma: Add link object Leon Romanovsky
[not found] ` <20170504180216.7665-1-leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-05-04 18:02 ` [RFC iproute2 1/8] rdma: Add basic infrastructure for RDMA tool Leon Romanovsky
2017-05-04 18:02 ` [RFC iproute2 4/8] rdma: Add IPoIB object Leon Romanovsky
2017-05-04 18:02 ` [RFC iproute2 V1 7/8] man: rdma.8: Document objects and commands Leon Romanovsky
2017-05-04 18:02 ` [RFC iproute2 8/8] rdma: Add link capability parsing Leon Romanovsky
2017-05-05 6:54 ` [RFC iproute2 0/8] RDMA tool Jiri Benc
2017-05-05 13:17 ` Leon Romanovsky
[not found] ` <20170505131754.GH22833-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-05-06 10:48 ` Jiri Pirko
2017-05-07 6:33 ` Leon Romanovsky
2017-05-07 21:02 ` Stephen Hemminger
2017-05-08 13:04 ` Knut Omang
2017-05-04 18:02 ` [RFC iproute2 5/8] rdma: Add memory object Leon Romanovsky
2017-05-04 18:02 ` [RFC iproute2 6/8] rdma: add stubs for future objects Leon Romanovsky
2017-05-04 18:10 ` [RFC iproute2 0/8] RDMA tool Bart Van Assche
2017-05-04 18:25 ` Leon Romanovsky
[not found] ` <20170504182542.GD22833-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-05-04 18:30 ` Bart Van Assche
[not found] ` <1493922625.2692.8.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-05-04 18:45 ` Leon Romanovsky
2017-05-04 19:26 ` Dennis Dalessandro
[not found] ` <2dee6cde-0406-b101-0fe6-c1f6de7c1b1a-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-04 19:42 ` Leon Romanovsky
[not found] ` <20170504194242.GF22833-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-05-08 15:55 ` Dennis Dalessandro
[not found] ` <b82f5d3d-f198-3410-af85-85befc14a2ec-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-05-09 7:03 ` Leon Romanovsky
2017-05-04 20:45 ` Doug Ledford
[not found] ` <1493930758.3041.231.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-05-05 0:05 ` Stephen Hemminger
2017-05-05 18:38 ` Bart Van Assche
2017-05-06 10:40 ` Jiri Pirko
2017-05-06 14:40 ` Bart Van Assche
2017-05-07 6:14 ` Leon Romanovsky
2017-05-07 10:20 ` Jiri Pirko
[not found] ` <20170507102046.GA1889-6KJVSR23iU488b5SBfVpbw@public.gmane.org>
2017-05-08 15:19 ` Bart Van Assche
[not found] ` <1494256767.2591.3.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-05-08 15:33 ` Stephen Hemminger
2017-05-08 16:19 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170504180216.7665-3-leon@kernel.org \
--to=leon@kernel.org \
--cc=Bart.VanAssche@sandisk.com \
--cc=ariela@mellanox.com \
--cc=dennis.dalessandro@intel.com \
--cc=dledford@redhat.com \
--cc=hch@lst.de \
--cc=jgunthorpe@obsidianresearch.com \
--cc=jiri@mellanox.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=ram.amrani@cavium.com \
--cc=sagi@grimberg.me \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).