Whamcloud - gitweb
LU-10086 libcfs: use dynamic minors for /dev/{lnet,obd}
[fs/lustre-release.git] / lnet / utils / lnetconfig / liblnetconfig.c
index f172698..969143b 100644 (file)
@@ -51,7 +51,6 @@
 #include <fcntl.h>
 #include <ifaddrs.h>
 #include "liblnetconfig.h"
-#include "cyaml.h"
 
 #define CONFIG_CMD             "configure"
 #define UNCONFIG_CMD           "unconfigure"
@@ -240,6 +239,7 @@ int lustre_lnet_add_intf_descr(struct list_head *list, char *intf, int len)
 void lustre_lnet_init_nw_descr(struct lnet_dlc_network_descr *nw_descr)
 {
        if (nw_descr != NULL) {
+               nw_descr->nw_id = 0;
                INIT_LIST_HEAD(&nw_descr->network_on_rule);
                INIT_LIST_HEAD(&nw_descr->nw_intflist);
        }
@@ -396,8 +396,7 @@ failed:
 
 int lustre_lnet_config_lib_init(void)
 {
-       return register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH,
-                               LNET_DEV_MAJOR, LNET_DEV_MINOR);
+       return register_ioc_dev(LNET_DEV_ID, LNET_DEV_PATH);
 }
 
 void lustre_lnet_config_lib_uninit(void)
@@ -1543,10 +1542,11 @@ int lustre_lnet_config_ni(struct lnet_dlc_network_descr *nw_descr,
 
        snprintf(err_str, sizeof(err_str), "\"success\"");
 
-       if (ip2net == NULL && nw_descr == NULL) {
+       if (ip2net == NULL && (nw_descr == NULL || nw_descr->nw_id == 0 ||
+           list_empty(&nw_descr->nw_intflist))) {
                snprintf(err_str,
                         sizeof(err_str),
-                        "\"mandatory parameters not specified.\"");
+                        "\"missing mandatory parameters\"");
                rc = LUSTRE_CFG_RC_MISSING_PARAM;
                goto out;
        }
@@ -1680,7 +1680,8 @@ int lustre_lnet_del_ni(struct lnet_dlc_network_descr *nw_descr,
 
        snprintf(err_str, sizeof(err_str), "\"success\"");
 
-       if (nw_descr == NULL) {
+       if (nw_descr == NULL || nw_descr->nw_id == 0 ||
+           list_empty(&nw_descr->nw_intflist)) {
                snprintf(err_str,
                         sizeof(err_str),
                         "\"missing mandatory parameter\"");
@@ -2512,6 +2513,16 @@ int lustre_lnet_show_peer(char *knid, int detail, int seq_no,
                                        peer_info.prcfg_mr ? "True" : "False")
                    == NULL)
                        goto out;
+               /*
+                * print out the state of the peer only if details are
+                * requested
+                */
+               if (detail >= 3) {
+                       if (cYAML_create_number(peer, "peer state",
+                                               peer_info.prcfg_state)
+                               == NULL)
+                               goto out;
+               }
 
                tmp = cYAML_create_seq(peer, "peer ni");
                if (tmp == NULL)
@@ -3677,6 +3688,41 @@ static int handle_yaml_show_stats(struct cYAML *tree, struct cYAML **show_rc,
                                      show_rc, err_rc);
 }
 
+static int handle_yaml_config_numa(struct cYAML *tree, struct cYAML **show_rc,
+                                 struct cYAML **err_rc)
+{
+       struct cYAML *seq_no, *range;
+
+       seq_no = cYAML_get_object_item(tree, "seq_no");
+       range = cYAML_get_object_item(tree, "range");
+
+       return lustre_lnet_config_numa_range(range ? range->cy_valueint : -1,
+                                            seq_no ? seq_no->cy_valueint : -1,
+                                            err_rc);
+}
+
+static int handle_yaml_del_numa(struct cYAML *tree, struct cYAML **show_rc,
+                              struct cYAML **err_rc)
+{
+       struct cYAML *seq_no;
+
+       seq_no = cYAML_get_object_item(tree, "seq_no");
+
+       return lustre_lnet_config_numa_range(0, seq_no ? seq_no->cy_valueint : -1,
+                                            err_rc);
+}
+
+static int handle_yaml_show_numa(struct cYAML *tree, struct cYAML **show_rc,
+                               struct cYAML **err_rc)
+{
+       struct cYAML *seq_no;
+
+       seq_no = cYAML_get_object_item(tree, "seq_no");
+
+       return lustre_lnet_show_numa_range(seq_no ? seq_no->cy_valueint : -1,
+                                          show_rc, err_rc);
+}
+
 static int handle_yaml_config_global_settings(struct cYAML *tree,
                                              struct cYAML **show_rc,
                                              struct cYAML **err_rc)
@@ -3820,6 +3866,7 @@ static struct lookup_cmd_hdlr_tbl lookup_config_tbl[] = {
        { .name = "buffers",    .cb = handle_yaml_config_buffers },
        { .name = "statistics", .cb = handle_yaml_no_op },
        { .name = "global",     .cb = handle_yaml_config_global_settings},
+       { .name = "numa",       .cb = handle_yaml_config_numa },
        { .name = "ping",       .cb = handle_yaml_no_op },
        { .name = "discover",   .cb = handle_yaml_no_op },
        { .name = NULL } };
@@ -3833,6 +3880,7 @@ static struct lookup_cmd_hdlr_tbl lookup_del_tbl[] = {
        { .name = "buffers",    .cb = handle_yaml_no_op },
        { .name = "statistics", .cb = handle_yaml_no_op },
        { .name = "global",     .cb = handle_yaml_del_global_settings},
+       { .name = "numa",       .cb = handle_yaml_del_numa },
        { .name = "ping",       .cb = handle_yaml_no_op },
        { .name = "discover",   .cb = handle_yaml_no_op },
        { .name = NULL } };
@@ -3846,6 +3894,7 @@ static struct lookup_cmd_hdlr_tbl lookup_show_tbl[] = {
        { .name = "buffers",    .cb = handle_yaml_show_routing },
        { .name = "statistics", .cb = handle_yaml_show_stats },
        { .name = "global",     .cb = handle_yaml_show_global_settings},
+       { .name = "numa",       .cb = handle_yaml_show_numa },
        { .name = "ping",       .cb = handle_yaml_no_op },
        { .name = "discover",   .cb = handle_yaml_no_op },
        { .name = NULL } };
@@ -3859,6 +3908,7 @@ static struct lookup_cmd_hdlr_tbl lookup_exec_tbl[] = {
        { .name = "buffers",    .cb = handle_yaml_no_op },
        { .name = "statistics", .cb = handle_yaml_no_op },
        { .name = "global",     .cb = handle_yaml_no_op },
+       { .name = "numa",       .cb = handle_yaml_no_op },
        { .name = "ping",       .cb = handle_yaml_ping },
        { .name = "discover",   .cb = handle_yaml_discover },
        { .name = NULL } };