]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - rdma/rdma.c
Merge branch 'master' into next
[mirror_iproute2.git] / rdma / rdma.c
index 010e98371ef098b3d7052bb6725f31a9ec178c7b..22050555735dea309738e5f0bfebcae8200cd6c2 100644 (file)
@@ -1,22 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
 /*
  * rdma.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"
 #include "SNAPSHOT.h"
+#include "color.h"
 
 static void help(char *name)
 {
        pr_out("Usage: %s [ OPTIONS ] OBJECT { COMMAND | help }\n"
               "       %s [ -f[orce] ] -b[atch] filename\n"
-              "where  OBJECT := { dev | link | resource | help }\n"
+              "where  OBJECT := { dev | link | resource | system | statistic | help }\n"
               "       OPTIONS := { -V[ersion] | -d[etails] | -j[son] | -p[retty]}\n", name, name);
 }
 
@@ -34,6 +30,8 @@ static int rd_cmd(struct rd *rd, int argc, char **argv)
                { "dev",        cmd_dev },
                { "link",       cmd_link },
                { "resource",   cmd_res },
+               { "system",     cmd_sys },
+               { "statistic",  cmd_stat },
                { 0 }
        };
 
@@ -88,15 +86,6 @@ static int rd_init(struct rd *rd, char *filename)
        INIT_LIST_HEAD(&rd->dev_map_list);
        INIT_LIST_HEAD(&rd->filter_list);
 
-       if (rd->json_output) {
-               rd->jw = jsonw_new(stdout);
-               if (!rd->jw) {
-                       pr_err("Failed to create JSON writer\n");
-                       return -ENOMEM;
-               }
-               jsonw_pretty(rd->jw, rd->pretty_output);
-       }
-
        rd->buff = malloc(MNL_SOCKET_BUFFER_SIZE);
        if (!rd->buff)
                return -ENOMEM;
@@ -112,8 +101,6 @@ static int rd_init(struct rd *rd, char *filename)
 
 static void rd_cleanup(struct rd *rd)
 {
-       if (rd->json_output)
-               jsonw_destroy(&rd->jw);
        rd_free(rd);
 }
 
@@ -131,7 +118,6 @@ int main(int argc, char **argv)
        };
        bool show_driver_details = false;
        const char *batch_file = NULL;
-       bool pretty_output = false;
        bool show_details = false;
        bool json_output = false;
        bool force = false;
@@ -139,7 +125,6 @@ int main(int argc, char **argv)
        char *filename;
        int opt;
        int err;
-
        filename = basename(argv[0]);
 
        while ((opt = getopt_long(argc, argv, ":Vhdpjfb:",
@@ -150,7 +135,7 @@ int main(int argc, char **argv)
                               filename, SNAPSHOT);
                        return EXIT_SUCCESS;
                case 'p':
-                       pretty_output = true;
+                       pretty = 1;
                        break;
                case 'd':
                        if (show_details)
@@ -159,7 +144,7 @@ int main(int argc, char **argv)
                                show_details = true;
                        break;
                case 'j':
-                       json_output = true;
+                       json_output = 1;
                        break;
                case 'f':
                        force = true;
@@ -186,7 +171,7 @@ int main(int argc, char **argv)
        rd.show_details = show_details;
        rd.show_driver_details = show_driver_details;
        rd.json_output = json_output;
-       rd.pretty_output = pretty_output;
+       rd.pretty_output = pretty;
 
        err = rd_init(&rd, filename);
        if (err)