Whamcloud - gitweb
LU-11130 osd-ldiskfs: create non-empty local agent symlinks
[fs/lustre-release.git] / lnet / utils / lst.c
index 07c5fcb..7d11a24 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -39,6 +35,7 @@
  */
 #include <errno.h>
 #include <getopt.h>
+#include <inttypes.h>
 #include <pwd.h>
 #include <unistd.h>
 #include <stdarg.h>
 #include <sys/ioctl.h>
 #include <time.h>
 
-#include <libcfs/list.h>
+#include <libcfs/util/list.h>
 #include <libcfs/util/ioctl.h>
 #include <libcfs/util/parser.h>
-#include <lnet/lnetctl.h>
-#include <lnet/lnetst.h>
-#include <lnet/lnet.h>
-#include <utils/obdctl.h>
+#include <linux/lnet/lnetctl.h>
+#include <linux/lnet/lnetst.h>
+#include <linux/lnet/nidstr.h>
+#include "lnetconfig/liblnetconfig.h"
 
-lst_sid_t LST_INVALID_SID = {LNET_NID_ANY, -1};
-static lst_sid_t           session_id;
+struct lst_sid LST_INVALID_SID = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1 };
+static struct lst_sid session_id;
 static int                 session_key;
+static int lst_list_commands(int argc, char **argv);
 
 /* All nodes running 2.6.50 or later understand feature LST_FEAT_BULK_LEN */
 static unsigned                session_features = LST_FEATS_MASK;
-static lstcon_trans_stat_t     trans_stat;
+static struct lstcon_trans_stat        trans_stat;
 
 typedef struct list_string {
        struct list_string *lstr_next;
@@ -255,7 +253,7 @@ expand_strs(char *str, lstr_t **head)
 }
 
 int
-lst_parse_nids(char *str, int *countp, lnet_process_id_t **idspp)
+lst_parse_nids(char *str, int *countp, struct lnet_process_id **idspp)
 {
         lstr_t  *head = NULL;
         lstr_t  *l;
@@ -273,7 +271,7 @@ lst_parse_nids(char *str, int *countp, lnet_process_id_t **idspp)
                 c++;
         }
 
-        *idspp = malloc(c * sizeof(lnet_process_id_t));
+       *idspp = malloc(c * sizeof(struct lnet_process_id));
         if (*idspp == NULL) {
                 fprintf(stderr, "Out of memory\n");
                 rc = -1;
@@ -407,10 +405,10 @@ lst_print_error(char *sub, const char *def_format, ...)
 void
 lst_free_rpcent(struct list_head *head)
 {
-       lstcon_rpc_ent_t *ent;
+       struct lstcon_rpc_ent *ent;
 
        while (!list_empty(head)) {
-               ent = list_entry(head->next, lstcon_rpc_ent_t, rpe_link);
+               ent = list_entry(head->next, struct lstcon_rpc_ent, rpe_link);
 
                list_del(&ent->rpe_link);
                free(ent);
@@ -420,7 +418,7 @@ lst_free_rpcent(struct list_head *head)
 void
 lst_reset_rpcent(struct list_head *head)
 {
-       lstcon_rpc_ent_t *ent;
+       struct lstcon_rpc_ent *ent;
 
        list_for_each_entry(ent, head, rpe_link) {
                ent->rpe_sid       = LST_INVALID_SID;
@@ -433,17 +431,17 @@ lst_reset_rpcent(struct list_head *head)
 int
 lst_alloc_rpcent(struct list_head *head, int count, int offset)
 {
-        lstcon_rpc_ent_t *ent;
+       struct lstcon_rpc_ent *ent;
         int               i;
 
         for (i = 0; i < count; i++) {
-                ent = malloc(offsetof(lstcon_rpc_ent_t, rpe_payload[offset]));
+               ent = malloc(offsetof(struct lstcon_rpc_ent, rpe_payload[offset]));
                 if (ent == NULL) {
                         lst_free_rpcent(head);
                         return -1;
                 }
 
-                memset(ent, 0, offsetof(lstcon_rpc_ent_t, rpe_payload[offset]));
+               memset(ent, 0, offsetof(struct lstcon_rpc_ent, rpe_payload[offset]));
 
                ent->rpe_sid      = LST_INVALID_SID;
                ent->rpe_peer.nid = LNET_NID_ANY;
@@ -457,7 +455,7 @@ lst_alloc_rpcent(struct list_head *head, int count, int offset)
 void
 lst_print_transerr(struct list_head *head, char *optstr)
 {
-       lstcon_rpc_ent_t *ent;
+       struct lstcon_rpc_ent *ent;
 
        list_for_each_entry(ent, head, rpe_link) {
                if (ent->rpe_rpc_errno == 0 && ent->rpe_fwk_errno == 0)
@@ -477,11 +475,11 @@ lst_print_transerr(struct list_head *head, char *optstr)
 }
 
 int lst_info_batch_ioctl(char *batch, int test, int server,
-                        lstcon_test_batch_ent_t *entp, int *idxp,
-                        int *ndentp, lstcon_node_ent_t *dentsp);
+                       struct lstcon_test_batch_ent *entp, int *idxp,
+                       int *ndentp, struct lstcon_node_ent *dentsp);
 
-int lst_info_group_ioctl(char *name, lstcon_ndlist_ent_t *gent,
-                         int *idx, int *count, lstcon_node_ent_t *dents);
+int lst_info_group_ioctl(char *name, struct lstcon_ndlist_ent *gent,
+                        int *idx, int *count, struct lstcon_node_ent *dents);
 
 int lst_query_batch_ioctl(char *batch, int test, int server,
                          int timeout, struct list_head *head);
@@ -519,9 +517,9 @@ lst_ioctl(unsigned int opc, void *buf, int len)
 }
 
 int
-lst_new_session_ioctl(char *name, int timeout, int force, lst_sid_t *sid)
+lst_new_session_ioctl(char *name, int timeout, int force, struct lst_sid *sid)
 {
-        lstio_session_new_args_t args = {0};
+       struct lstio_session_new_args args = { 0 };
 
         args.lstio_ses_key     = session_key;
         args.lstio_ses_timeout = timeout;
@@ -535,22 +533,20 @@ lst_new_session_ioctl(char *name, int timeout, int force, lst_sid_t *sid)
 }
 
 int
-jt_lst_new_session(int argc,  char **argv)
-{
-        char  buf[LST_NAME_SIZE];
-        char *name;
-        int   optidx  = 0;
-        int   timeout = 300;
-        int   force   = 0;
-        int   c;
-        int   rc;
+jt_lst_new_session(int argc, char **argv)
+{
+       char  buf[LST_NAME_SIZE];
+       char *name;
+       int   optidx = 0;
+       int   timeout = 300;
+       int   force = 0;
+       int   c;
+       int   rc;
 
-        static struct option session_opts[] =
-        {
-                {"timeout", required_argument,  0, 't' },
-                {"force",   no_argument,        0, 'f' },
-                {0,         0,                  0,  0  }
-        };
+       static const struct option session_opts[] = {
+               { .name = "timeout", .has_arg = required_argument, .val = 't' },
+               { .name = "force",   .has_arg = no_argument,       .val = 'f' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -628,9 +624,9 @@ jt_lst_new_session(int argc,  char **argv)
 
 int
 lst_session_info_ioctl(char *name, int len, int *key, unsigned *featp,
-                      lst_sid_t *sid, lstcon_ndlist_ent_t *ndinfo)
+                      struct lst_sid *sid, struct lstcon_ndlist_ent *ndinfo)
 {
-       lstio_session_info_args_t args = {0};
+       struct lstio_session_info_args args = { 0 };
 
        args.lstio_ses_idp     = sid;
        args.lstio_ses_keyp    = key;
@@ -645,8 +641,8 @@ lst_session_info_ioctl(char *name, int len, int *key, unsigned *featp,
 int
 jt_lst_show_session(int argc, char **argv)
 {
-        lstcon_ndlist_ent_t ndinfo;
-        lst_sid_t           sid;
+       struct lstcon_ndlist_ent ndinfo;
+       struct lst_sid sid;
         char                name[LST_NAME_SIZE];
        unsigned            feats;
        int                 key;
@@ -661,8 +657,8 @@ jt_lst_show_session(int argc, char **argv)
                 return -1;
         }
 
-       fprintf(stdout, "%s ID: "LPU64"@%s, KEY: %d FEATURES: %x NODES: %d\n",
-               name, sid.ses_stamp, libcfs_nid2str(sid.ses_nid),
+       fprintf(stdout, "%s ID: %ju@%s, KEY: %d FEATURES: %x NODES: %d\n",
+               name, (uintmax_t)sid.ses_stamp, libcfs_nid2str(sid.ses_nid),
                key, feats, ndinfo.nle_nnode);
 
         return 0;
@@ -671,10 +667,10 @@ jt_lst_show_session(int argc, char **argv)
 int
 lst_end_session_ioctl(void)
 {
-        lstio_session_end_args_t args = {0};
+       struct lstio_session_end_args args = { 0 };
 
-        args.lstio_ses_key =  session_key;
-        return lst_ioctl (LSTIO_SESSION_END, &args, sizeof(args));
+       args.lstio_ses_key = session_key;
+       return lst_ioctl(LSTIO_SESSION_END, &args, sizeof(args));
 }
 
 int
@@ -720,9 +716,9 @@ jt_lst_end_session(int argc, char **argv)
 
 int
 lst_ping_ioctl(char *str, int type, int timeout,
-              int count, lnet_process_id_t *ids, struct list_head *head)
+              int count, struct lnet_process_id *ids, struct list_head *head)
 {
-        lstio_debug_args_t args = {0};
+       struct lstio_debug_args args = { 0 };
 
         args.lstio_dbg_key     = session_key;
         args.lstio_dbg_type    = type;
@@ -738,12 +734,13 @@ lst_ping_ioctl(char *str, int type, int timeout,
 }
 
 int
-lst_get_node_count(int type, char *str, int *countp, lnet_process_id_t **idspp)
+lst_get_node_count(int type, char *str, int *countp,
+                  struct lnet_process_id **idspp)
 {
         char                    buf[LST_NAME_SIZE];
-        lstcon_test_batch_ent_t ent;
-        lstcon_ndlist_ent_t    *entp = &ent.tbe_cli_nle;
-        lst_sid_t               sid;
+       struct lstcon_test_batch_ent ent;
+       struct lstcon_ndlist_ent    *entp = &ent.tbe_cli_nle;
+       struct lst_sid sid;
        unsigned                feats;
        int                     key;
        int                     rc;
@@ -783,27 +780,25 @@ int
 jt_lst_ping(int argc,  char **argv)
 {
        struct list_head   head;
-       lnet_process_id_t *ids = NULL;
-       lstcon_rpc_ent_t  *ent = NULL;
-        char              *str = NULL;
-        int                optidx  = 0;
-        int                server  = 0;
-        int                timeout = 5;
-        int                count   = 0;
-        int                type    = 0;
-        int                rc      = 0;
-        int                c;
-
-        static struct option ping_opts[] =
-        {
-                {"session", no_argument,       0, 's' },
-                {"server",  no_argument,       0, 'v' },
-                {"batch",   required_argument, 0, 'b' },
-                {"group",   required_argument, 0, 'g' },
-                {"nodes",   required_argument, 0, 'n' },
-                {"timeout", required_argument, 0, 't' },
-                {0,         0,                 0,  0  }
-        };
+       struct lnet_process_id *ids = NULL;
+       struct lstcon_rpc_ent  *ent = NULL;
+       char              *str = NULL;
+       int                optidx  = 0;
+       int                server  = 0;
+       int                timeout = 5;
+       int                count   = 0;
+       int                type    = 0;
+       int                rc      = 0;
+       int                c;
+
+       static const struct option ping_opts[] = {
+               { .name = "session", .has_arg = no_argument,       .val = 's' },
+               { .name = "server",  .has_arg = no_argument,       .val = 'v' },
+               { .name = "batch",   .has_arg = required_argument, .val = 'b' },
+               { .name = "group",   .has_arg = required_argument, .val = 'g' },
+               { .name = "nodes",   .has_arg = required_argument, .val = 'n' },
+               { .name = "timeout", .has_arg = required_argument, .val = 't' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -914,10 +909,10 @@ out:
 }
 
 int
-lst_add_nodes_ioctl (char *name, int count, lnet_process_id_t *ids,
-                    unsigned *featp, struct list_head *resultp)
+lst_add_nodes_ioctl(char *name, int count, struct lnet_process_id *ids,
+                   unsigned *featp, struct list_head *resultp)
 {
-        lstio_group_nodes_args_t args = {0};
+       struct lstio_group_nodes_args args = { 0 };
 
         args.lstio_grp_key     = session_key;
         args.lstio_grp_nmlen   = strlen(name);
@@ -933,7 +928,7 @@ lst_add_nodes_ioctl (char *name, int count, lnet_process_id_t *ids,
 int
 lst_del_group_ioctl(char *name)
 {
-       lstio_group_del_args_t args = {0};
+       struct lstio_group_del_args args = { 0 };
 
        args.lstio_grp_key   = session_key;
        args.lstio_grp_nmlen = strlen(name);
@@ -979,9 +974,9 @@ lst_del_group(char *grp_name)
 }
 
 int
-lst_add_group_ioctl (char *name)
+lst_add_group_ioctl(char *name)
 {
-        lstio_group_add_args_t args = {0};
+       struct lstio_group_add_args args = { 0 };
 
         args.lstio_grp_key     =  session_key;
         args.lstio_grp_nmlen   =  strlen(name);
@@ -994,7 +989,7 @@ int
 jt_lst_add_group(int argc, char **argv)
 {
        struct list_head   head;
-       lnet_process_id_t *ids;
+       struct lnet_process_id *ids;
        char              *name;
        unsigned           feats = session_features;
        int                count;
@@ -1145,9 +1140,9 @@ jt_lst_del_group(int argc, char **argv)
 
 int
 lst_update_group_ioctl(int opc, char *name, int clean, int count,
-                      lnet_process_id_t *ids, struct list_head *resultp)
+                      struct lnet_process_id *ids, struct list_head *resultp)
 {
-        lstio_group_update_args_t args = {0};
+       struct lstio_group_update_args args = { 0 };
 
         args.lstio_grp_key      = session_key;
         args.lstio_grp_opc      = opc;
@@ -1164,24 +1159,22 @@ lst_update_group_ioctl(int opc, char *name, int clean, int count,
 int
 jt_lst_update_group(int argc, char **argv)
 {
-       struct list_head         head;
-        lnet_process_id_t *ids = NULL;
-        char              *str = NULL;
-        char              *grp = NULL;
-        int                optidx = 0;
-        int                count = 0;
-        int                clean = 0;
-        int                opc = 0;
-        int                rc;
-        int                c;
-
-        static struct option update_group_opts[] =
-        {
-                {"refresh", no_argument,       0, 'f' },
-                {"clean",   required_argument, 0, 'c' },
-                {"remove",  required_argument, 0, 'r' },
-                {0,         0,                 0,  0  }
-        };
+       struct list_head   head;
+       struct lnet_process_id *ids = NULL;
+       char              *str = NULL;
+       char              *grp = NULL;
+       int                optidx = 0;
+       int                count = 0;
+       int                clean = 0;
+       int                opc = 0;
+       int                rc;
+       int                c;
+
+       static const struct option update_group_opts[] = {
+               { .name = "refresh", .has_arg = no_argument,       .val = 'f' },
+               { .name = "clean",   .has_arg = required_argument, .val = 'c' },
+               { .name = "remove",  .has_arg = required_argument, .val = 'r' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -1289,7 +1282,7 @@ jt_lst_update_group(int argc, char **argv)
 int
 lst_list_group_ioctl(int len, char *name, int idx)
 {
-        lstio_group_list_args_t args = {0};
+       struct lstio_group_list_args args = { 0 };
 
         args.lstio_grp_key   = session_key;
         args.lstio_grp_idx   = idx;
@@ -1300,10 +1293,10 @@ lst_list_group_ioctl(int len, char *name, int idx)
 }
 
 int
-lst_info_group_ioctl(char *name, lstcon_ndlist_ent_t *gent,
-                     int *idx, int *count, lstcon_node_ent_t *dents)
+lst_info_group_ioctl(char *name, struct lstcon_ndlist_ent *gent,
+                    int *idx, int *count, struct lstcon_node_ent *dents)
 {
-        lstio_group_info_args_t args = {0};
+       struct lstio_group_info_args args = { 0 };
 
         args.lstio_grp_key    = session_key;
         args.lstio_grp_nmlen  = strlen(name);
@@ -1349,31 +1342,29 @@ lst_list_group_all(void)
 int
 jt_lst_list_group(int argc, char **argv)
 {
-        lstcon_ndlist_ent_t  gent;
-        lstcon_node_ent_t   *dents;
-        int               optidx  = 0;
-        int               verbose = 0;
-        int               active  = 0;
-        int               busy    = 0;
-        int               down    = 0;
-        int               unknown = 0;
-        int               all     = 0;
-        int               count;
-        int               index;
-        int               i;
-        int               j;
-        int               c;
-        int               rc = 0;
-
-        static struct option list_group_opts[] =
-        {
-                {"active",  no_argument, 0, 'a' },
-                {"busy",    no_argument, 0, 'b' },
-                {"down",    no_argument, 0, 'd' },
-                {"unknown", no_argument, 0, 'u' },
-                {"all",     no_argument, 0, 'l' },
-                {0,         0,           0,  0  }
-        };
+       struct lstcon_ndlist_ent gent;
+       struct lstcon_node_ent   *dents;
+       int optidx  = 0;
+       int verbose = 0;
+       int active  = 0;
+       int busy    = 0;
+       int down    = 0;
+       int unknown = 0;
+       int all     = 0;
+       int count;
+       int index;
+       int i;
+       int j;
+       int c;
+       int rc      = 0;
+
+       static const struct option list_group_opts[] = {
+               { .name = "active",  .has_arg = no_argument, .val = 'a' },
+               { .name = "busy",    .has_arg = no_argument, .val = 'b' },
+               { .name = "down",    .has_arg = no_argument, .val = 'd' },
+               { .name = "unknown", .has_arg = no_argument, .val = 'u' },
+               { .name = "all",     .has_arg = no_argument, .val = 'l' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -1455,7 +1446,7 @@ jt_lst_list_group(int argc, char **argv)
 
                 count = gent.nle_nnode;
 
-                dents = malloc(count * sizeof(lstcon_node_ent_t));
+               dents = malloc(count * sizeof(struct lstcon_node_ent));
                 if (dents == NULL) {
                         fprintf(stderr, "Failed to malloc: %s\n",
                                 strerror(errno));
@@ -1494,27 +1485,27 @@ jt_lst_list_group(int argc, char **argv)
 }
 
 int
-lst_stat_ioctl (char *name, int count, lnet_process_id_t *idsp,
-               int timeout, struct list_head *resultp)
+lst_stat_ioctl(char *name, int count, struct lnet_process_id *idsp,
+              int timeout, struct list_head *resultp)
 {
-        lstio_stat_args_t args = {0};
+       struct lstio_stat_args args = { 0 };
 
-        args.lstio_sta_key     = session_key;
-        args.lstio_sta_timeout = timeout;
-        args.lstio_sta_nmlen   = strlen(name);
-        args.lstio_sta_namep   = name;
-        args.lstio_sta_count   = count;
-        args.lstio_sta_idsp    = idsp;
-        args.lstio_sta_resultp = resultp;
+       args.lstio_sta_key     = session_key;
+       args.lstio_sta_timeout = timeout;
+       args.lstio_sta_nmlen   = strlen(name);
+       args.lstio_sta_namep   = name;
+       args.lstio_sta_count   = count;
+       args.lstio_sta_idsp    = idsp;
+       args.lstio_sta_resultp = resultp;
 
-        return lst_ioctl (LSTIO_STAT_QUERY, &args, sizeof(args));
+       return lst_ioctl(LSTIO_STAT_QUERY, &args, sizeof(args));
 }
 
 typedef struct {
        struct list_head              srp_link;
         int                     srp_count;
         char                   *srp_name;
-        lnet_process_id_t      *srp_ids;
+       struct lnet_process_id      *srp_ids;
        struct list_head              srp_result[2];
 } lst_stat_req_param_t;
 
@@ -1564,27 +1555,27 @@ lst_stat_req_param_alloc(char *name, lst_stat_req_param_t **srpp, int save_old)
                 return rc;
         }
 
-        srp->srp_name = name;
+       srp->srp_name = name;
 
-        for (i = 0; i < count; i++) {
-                rc = lst_alloc_rpcent(&srp->srp_result[i], srp->srp_count,
-                                      sizeof(sfw_counters_t)  +
-                                      sizeof(srpc_counters_t) +
-                                      sizeof(lnet_counters_t));
-                if (rc != 0) {
-                        fprintf(stderr, "Out of memory\n");
-                        break;
-                }
-        }
+       for (i = 0; i < count; i++) {
+               rc = lst_alloc_rpcent(&srp->srp_result[i], srp->srp_count,
+                                     sizeof(struct sfw_counters)  +
+                                     sizeof(struct srpc_counters) +
+                                     sizeof(struct lnet_counters_common));
+               if (rc != 0) {
+                       fprintf(stderr, "Out of memory\n");
+                       break;
+               }
+       }
 
-        if (rc == 0) {
-                *srpp = srp;
-                return 0;
-        }
+       if (rc == 0) {
+               *srpp = srp;
+               return 0;
+       }
 
-        lst_stat_req_param_free(srp);
+       lst_stat_req_param_free(srp);
 
-        return rc;
+       return rc;
 }
 
 typedef struct {
@@ -1654,139 +1645,144 @@ lst_timeval_diff(struct timeval *tv1,
        return;
 }
 
-void
-lst_cal_lnet_stat(float delta, lnet_counters_t *lnet_new,
-                  lnet_counters_t *lnet_old)
+static void
+lst_cal_lnet_stat(float delta, struct lnet_counters_common *lnet_new,
+                 struct lnet_counters_common *lnet_old, int mbs)
 {
-        float perf;
-        float rate;
+       float perf;
+       float rate;
+       unsigned int unit_divisor;
 
-        perf = (float)(lnet_new->send_length -
-                       lnet_old->send_length) / (1024 * 1024) / delta;
-        lnet_stat_result.lnet_total_sndperf += perf;
+       unit_divisor = (mbs) ? (1000 * 1000) : (1024 * 1024);
+       perf = (float)(lnet_new->lcc_send_length -
+                      lnet_old->lcc_send_length) / unit_divisor / delta;
+       lnet_stat_result.lnet_total_sndperf += perf;
 
-        if (lnet_stat_result.lnet_min_sndperf > perf ||
-            lnet_stat_result.lnet_min_sndperf == 0)
-                lnet_stat_result.lnet_min_sndperf = perf;
+       if (lnet_stat_result.lnet_min_sndperf > perf ||
+           lnet_stat_result.lnet_min_sndperf == 0)
+               lnet_stat_result.lnet_min_sndperf = perf;
 
-        if (lnet_stat_result.lnet_max_sndperf < perf)
-                lnet_stat_result.lnet_max_sndperf = perf;
+       if (lnet_stat_result.lnet_max_sndperf < perf)
+               lnet_stat_result.lnet_max_sndperf = perf;
 
-        perf = (float)(lnet_new->recv_length -
-                       lnet_old->recv_length) / (1024 * 1024) / delta;
-        lnet_stat_result.lnet_total_rcvperf += perf;
+       perf = (float)(lnet_new->lcc_recv_length -
+                      lnet_old->lcc_recv_length) / unit_divisor / delta;
+       lnet_stat_result.lnet_total_rcvperf += perf;
 
-        if (lnet_stat_result.lnet_min_rcvperf > perf ||
-            lnet_stat_result.lnet_min_rcvperf == 0)
-                lnet_stat_result.lnet_min_rcvperf = perf;
+       if (lnet_stat_result.lnet_min_rcvperf > perf ||
+           lnet_stat_result.lnet_min_rcvperf == 0)
+               lnet_stat_result.lnet_min_rcvperf = perf;
 
-        if (lnet_stat_result.lnet_max_rcvperf < perf)
-                lnet_stat_result.lnet_max_rcvperf = perf;
+       if (lnet_stat_result.lnet_max_rcvperf < perf)
+               lnet_stat_result.lnet_max_rcvperf = perf;
 
-        rate = (lnet_new->send_count - lnet_old->send_count) / delta;
-        lnet_stat_result.lnet_total_sndrate += rate;
+       rate = (lnet_new->lcc_send_count - lnet_old->lcc_send_count) / delta;
+       lnet_stat_result.lnet_total_sndrate += rate;
 
-        if (lnet_stat_result.lnet_min_sndrate > rate ||
-            lnet_stat_result.lnet_min_sndrate == 0)
-                lnet_stat_result.lnet_min_sndrate = rate;
+       if (lnet_stat_result.lnet_min_sndrate > rate ||
+           lnet_stat_result.lnet_min_sndrate == 0)
+               lnet_stat_result.lnet_min_sndrate = rate;
 
-        if (lnet_stat_result.lnet_max_sndrate < rate)
-                lnet_stat_result.lnet_max_sndrate = rate;
+       if (lnet_stat_result.lnet_max_sndrate < rate)
+               lnet_stat_result.lnet_max_sndrate = rate;
 
-        rate = (lnet_new->recv_count - lnet_old->recv_count) / delta;
-        lnet_stat_result.lnet_total_rcvrate += rate;
+       rate = (lnet_new->lcc_recv_count - lnet_old->lcc_recv_count) / delta;
+       lnet_stat_result.lnet_total_rcvrate += rate;
 
-        if (lnet_stat_result.lnet_min_rcvrate > rate ||
-            lnet_stat_result.lnet_min_rcvrate == 0)
-                lnet_stat_result.lnet_min_rcvrate = rate;
+       if (lnet_stat_result.lnet_min_rcvrate > rate ||
+           lnet_stat_result.lnet_min_rcvrate == 0)
+               lnet_stat_result.lnet_min_rcvrate = rate;
 
-        if (lnet_stat_result.lnet_max_rcvrate < rate)
-                lnet_stat_result.lnet_max_rcvrate = rate;
+       if (lnet_stat_result.lnet_max_rcvrate < rate)
+               lnet_stat_result.lnet_max_rcvrate = rate;
 
-        lnet_stat_result.lnet_stat_count ++;
+       lnet_stat_result.lnet_stat_count++;
 
-        lnet_stat_result.lnet_avg_sndrate = lnet_stat_result.lnet_total_sndrate /
-                                            lnet_stat_result.lnet_stat_count;
-        lnet_stat_result.lnet_avg_rcvrate = lnet_stat_result.lnet_total_rcvrate /
-                                            lnet_stat_result.lnet_stat_count;
-
-        lnet_stat_result.lnet_avg_sndperf = lnet_stat_result.lnet_total_sndperf /
-                                            lnet_stat_result.lnet_stat_count;
-        lnet_stat_result.lnet_avg_rcvperf = lnet_stat_result.lnet_total_rcvperf /
-                                            lnet_stat_result.lnet_stat_count;
+       lnet_stat_result.lnet_avg_sndrate = lnet_stat_result.lnet_total_sndrate /
+                                           lnet_stat_result.lnet_stat_count;
+       lnet_stat_result.lnet_avg_rcvrate = lnet_stat_result.lnet_total_rcvrate /
+                                           lnet_stat_result.lnet_stat_count;
 
+       lnet_stat_result.lnet_avg_sndperf = lnet_stat_result.lnet_total_sndperf /
+                                           lnet_stat_result.lnet_stat_count;
+       lnet_stat_result.lnet_avg_rcvperf = lnet_stat_result.lnet_total_rcvperf /
+                                           lnet_stat_result.lnet_stat_count;
 }
 
-void
-lst_print_lnet_stat(char *name, int bwrt, int rdwr, int type)
+static void
+lst_print_lnet_stat(char *name, int bwrt, int rdwr, int type, int mbs)
 {
-        int     start1 = 0;
-        int     end1   = 1;
-        int     start2 = 0;
-        int     end2   = 1;
-        int     i;
-        int     j;
+       int     start1 = 0;
+       int     end1   = 1;
+       int     start2 = 0;
+       int     end2   = 1;
+       int     i;
+       int     j;
+       char   *units;
 
-        if (lnet_stat_result.lnet_stat_count == 0)
-                return;
+       if (lnet_stat_result.lnet_stat_count == 0)
+               return;
 
-        if (bwrt == 1) /* bw only */
-                start1 = 1;
+       units = (mbs) ? "MB/s  " : "MiB/s ";
 
-        if (bwrt == 2) /* rates only */
-                end1 = 0;
+       if (bwrt == 1) /* bw only */
+               start1 = 1;
 
-        if (rdwr == 1) /* recv only */
-                start2 = 1;
+       if (bwrt == 2) /* rates only */
+               end1 = 0;
 
-        if (rdwr == 2) /* send only */
-                end2 = 0;
+       if (rdwr == 1) /* recv only */
+               start2 = 1;
 
-        for (i = start1; i <= end1; i++) {
-                fprintf(stdout, "[LNet %s of %s]\n",
-                        i == 0 ? "Rates" : "Bandwidth", name);
+       if (rdwr == 2) /* send only */
+               end2 = 0;
 
-                for (j = start2; j <= end2; j++) {
-                        fprintf(stdout, "[%c] ", j == 0 ? 'R' : 'W');
+       for (i = start1; i <= end1; i++) {
+               fprintf(stdout, "[LNet %s of %s]\n",
+                       i == 0 ? "Rates" : "Bandwidth", name);
 
-                        if ((type & 1) != 0) {
-                                fprintf(stdout, i == 0 ? "Avg: %-8.0f RPC/s " :
-                                                         "Avg: %-8.2f MB/s  ",
-                                        lst_lnet_stat_value(i, j, 0));
-                        }
+               for (j = start2; j <= end2; j++) {
+                       fprintf(stdout, "[%c] ", j == 0 ? 'R' : 'W');
 
-                        if ((type & 2) != 0) {
-                                fprintf(stdout, i == 0 ? "Min: %-8.0f RPC/s " :
-                                                         "Min: %-8.2f MB/s  ",
-                                        lst_lnet_stat_value(i, j, 1));
-                        }
+                       if ((type & 1) != 0) {
+                               fprintf(stdout, i == 0 ? "Avg: %-8.0f RPC/s " :
+                                                        "Avg: %-8.2f %s",
+                                       lst_lnet_stat_value(i, j, 0), units);
+                       }
 
-                        if ((type & 4) != 0) {
-                                fprintf(stdout, i == 0 ? "Max: %-8.0f RPC/s" :
-                                                         "Max: %-8.2f MB/s",
-                                        lst_lnet_stat_value(i, j, 2));
-                        }
+                       if ((type & 2) != 0) {
+                               fprintf(stdout, i == 0 ? "Min: %-8.0f RPC/s " :
+                                                        "Min: %-8.2f %s",
+                                       lst_lnet_stat_value(i, j, 1), units);
+                       }
 
-                        fprintf(stdout, "\n");
-                }
-        }
+                       if ((type & 4) != 0) {
+                               fprintf(stdout, i == 0 ? "Max: %-8.0f RPC/s" :
+                                                        "Max: %-8.2f %s",
+                                       lst_lnet_stat_value(i, j, 2), units);
+                       }
+
+                       fprintf(stdout, "\n");
+               }
+       }
 }
 
-void
+static void
 lst_print_stat(char *name, struct list_head *resultp,
-              int idx, int lnet, int bwrt, int rdwr, int type)
-{
-       struct list_head        tmp[2];
-        lstcon_rpc_ent_t *new;
-        lstcon_rpc_ent_t *old;
-        sfw_counters_t   *sfwk_new;
-        sfw_counters_t   *sfwk_old;
-        srpc_counters_t  *srpc_new;
-        srpc_counters_t  *srpc_old;
-        lnet_counters_t  *lnet_new;
-        lnet_counters_t  *lnet_old;
-        float             delta;
-        int               errcount = 0;
+              int idx, int lnet, int bwrt, int rdwr, int type,
+              int mbs)
+{
+       struct list_head tmp[2];
+       struct lstcon_rpc_ent *new;
+       struct lstcon_rpc_ent *old;
+       struct sfw_counters *sfwk_new;
+       struct sfw_counters *sfwk_old;
+       struct srpc_counters *srpc_new;
+       struct srpc_counters *srpc_old;
+       struct lnet_counters_common *lnet_new;
+       struct lnet_counters_common *lnet_old;
+       float delta;
+       int errcount = 0;
 
        INIT_LIST_HEAD(&tmp[0]);
        INIT_LIST_HEAD(&tmp[1]);
@@ -1799,9 +1795,9 @@ lst_print_stat(char *name, struct list_head *resultp,
                         break;
                 }
 
-               new = list_entry(resultp[idx].next, lstcon_rpc_ent_t,
+               new = list_entry(resultp[idx].next, struct lstcon_rpc_ent,
                                      rpe_link);
-               old = list_entry(resultp[1 - idx].next, lstcon_rpc_ent_t,
+               old = list_entry(resultp[1 - idx].next, struct lstcon_rpc_ent,
                                      rpe_link);
 
                 /* first time get stats result, can't calculate diff */
@@ -1826,88 +1822,92 @@ lst_print_stat(char *name, struct list_head *resultp,
                         continue;
                 }
 
-                sfwk_new = (sfw_counters_t *)&new->rpe_payload[0];
-                sfwk_old = (sfw_counters_t *)&old->rpe_payload[0];
+               sfwk_new = (struct sfw_counters *)&new->rpe_payload[0];
+               sfwk_old = (struct sfw_counters *)&old->rpe_payload[0];
 
-                srpc_new = (srpc_counters_t *)((char *)sfwk_new + sizeof(*sfwk_new));
-                srpc_old = (srpc_counters_t *)((char *)sfwk_old + sizeof(*sfwk_old));
+               srpc_new = (struct srpc_counters *)((char *)sfwk_new +
+                                                   sizeof(*sfwk_new));
+               srpc_old = (struct srpc_counters *)((char *)sfwk_old +
+                                                   sizeof(*sfwk_old));
 
-                lnet_new = (lnet_counters_t *)((char *)srpc_new + sizeof(*srpc_new));
-                lnet_old = (lnet_counters_t *)((char *)srpc_old + sizeof(*srpc_old));
+               lnet_new = (struct lnet_counters_common *)((char *)srpc_new +
+                                                          sizeof(*srpc_new));
+               lnet_old = (struct lnet_counters_common *)((char *)srpc_old +
+                                                          sizeof(*srpc_old));
 
                /* Prior to version 2.3, the running_ms field was a counter for
                 * the number of running tests.  We are looking at this value
                 * to determine if it is a millisecond timestamep (>= 2.3) or a
                 * test counter (< 2.3).  The number 500 is being used for this
                 * barrier as the test counter should never get this high, and
-                * the timestamp should never get this low. */
-
+                * the timestamp should never get this low.
+                */
                if (sfwk_new->running_ms > 500) {
                        /* use the timestamp from the remote node, not our
                         * rpe_stamp from when we copied up the data out of
-                        * the kernel */
-
-                       delta = (float) (sfwk_new->running_ms -
+                        * the kernel.
+                        */
+                       delta = (float)(sfwk_new->running_ms -
                                        sfwk_old->running_ms) / 1000;
                } else {
-                       struct timeval    tv;
+                       struct timeval tv;
 
                        lst_timeval_diff(&new->rpe_stamp, &old->rpe_stamp, &tv);
                        delta = tv.tv_sec + (float)tv.tv_usec / 1000000;
                }
 
-                if (!lnet) /* TODO */
-                        continue;
+               if (!lnet) /* TODO */
+                       continue;
 
-                lst_cal_lnet_stat(delta, lnet_new, lnet_old);
-        }
+               lst_cal_lnet_stat(delta, lnet_new, lnet_old, mbs);
+       }
 
        list_splice(&tmp[idx], &resultp[idx]);
        list_splice(&tmp[1 - idx], &resultp[1 - idx]);
 
-        if (errcount > 0)
-                fprintf(stdout, "Failed to stat on %d nodes\n", errcount);
+       if (errcount > 0)
+               fprintf(stdout, "Failed to stat on %d nodes\n", errcount);
 
-        if (!lnet)  /* TODO */
-                return;
+       if (!lnet)  /* TODO */
+               return;
 
-        lst_print_lnet_stat(name, bwrt, rdwr, type);
+       lst_print_lnet_stat(name, bwrt, rdwr, type, mbs);
 }
 
 int
 jt_lst_stat(int argc, char **argv)
 {
        struct list_head        head;
-        lst_stat_req_param_t *srp;
-        time_t                last    = 0;
-        int                   optidx  = 0;
-        int                   timeout = 5; /* default timeout, 5 sec */
-        int                   delay   = 5; /* default delay, 5 sec */
-        int                   count   = -1; /* run forever */
-        int                   lnet    = 1; /* lnet stat by default */
-        int                   bwrt    = 0;
-        int                   rdwr    = 0;
-        int                   type    = -1;
-        int                   idx     = 0;
-        int                   rc;
-        int                   c;
-
-        static struct option stat_opts[] =
-        {
-               {"timeout"   , required_argument, 0, 't' },
-               {"delay"     , required_argument, 0, 'd' },
-               {"count"     , required_argument, 0, 'o' },
-               {"lnet"      , no_argument,      0, 'l' },
-               {"rpc"       , no_argument,      0, 'c' },
-               {"bw"        , no_argument,      0, 'b' },
-               {"rate"      , no_argument,      0, 'a' },
-               {"read"      , no_argument,      0, 'r' },
-               {"write"     , no_argument,      0, 'w' },
-               {"avg"       , no_argument,      0, 'g' },
-               {"min"       , no_argument,      0, 'n' },
-               {"max"       , no_argument,      0, 'x' },
-               {0,            0,                0,  0  }
-        };
+       lst_stat_req_param_t *srp;
+       time_t                last    = 0;
+       int                   optidx  = 0;
+       int                   timeout = 5; /* default timeout, 5 sec */
+       int                   delay   = 5; /* default delay, 5 sec */
+       int                   count   = -1; /* run forever */
+       int                   lnet    = 1; /* lnet stat by default */
+       int                   bwrt    = 0;
+       int                   rdwr    = 0;
+       int                   type    = -1;
+       int                   idx     = 0;
+       int                   rc;
+       int                   c;
+       int                   mbs     = 0; /* report as MB/s */
+
+       static const struct option stat_opts[] = {
+               { .name = "timeout", .has_arg = required_argument, .val = 't' },
+               { .name = "delay",   .has_arg = required_argument, .val = 'd' },
+               { .name = "count",   .has_arg = required_argument, .val = 'o' },
+               { .name = "lnet",    .has_arg = no_argument,       .val = 'l' },
+               { .name = "rpc",     .has_arg = no_argument,       .val = 'c' },
+               { .name = "bw",      .has_arg = no_argument,       .val = 'b' },
+               { .name = "rate",    .has_arg = no_argument,       .val = 'a' },
+               { .name = "read",    .has_arg = no_argument,       .val = 'r' },
+               { .name = "write",   .has_arg = no_argument,       .val = 'w' },
+               { .name = "avg",     .has_arg = no_argument,       .val = 'g' },
+               { .name = "min",     .has_arg = no_argument,       .val = 'n' },
+               { .name = "max",     .has_arg = no_argument,       .val = 'x' },
+               { .name = "mbs",     .has_arg = no_argument,       .val = 'm' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -1916,7 +1916,8 @@ jt_lst_stat(int argc, char **argv)
         }
 
         while (1) {
-               c = getopt_long(argc, argv, "t:d:lcbarwgnx", stat_opts, &optidx);
+               c = getopt_long(argc, argv, "t:d:lcbarwgnxm", stat_opts,
+                               &optidx);
 
                 if (c == -1)
                         break;
@@ -1963,19 +1964,22 @@ jt_lst_stat(int argc, char **argv)
                         }
                         type |= 2;
                         break;
-                case 'x':
-                        if (type == -1) {
-                                type = 4;
-                                break;
-                        }
-                        type |= 4;
-                        break;
-
-                default:
-                        lst_print_usage(argv[0]);
-                        return -1;
-                }
-        }
+               case 'x':
+                       if (type == -1) {
+                               type = 4;
+                               break;
+                       }
+                       type |= 4;
+                       break;
+               case 'm':
+                       mbs = 1;
+                       break;
+
+               default:
+                       lst_print_usage(argv[0]);
+                       return -1;
+               }
+       }
 
         if (optind == argc) {
                 lst_print_usage(argv[0]);
@@ -2026,10 +2030,10 @@ jt_lst_stat(int argc, char **argv)
                         }
 
                        lst_print_stat(srp->srp_name, srp->srp_result,
-                                      idx, lnet, bwrt, rdwr, type);
+                                      idx, lnet, bwrt, rdwr, type, mbs);
 
-                        lst_reset_rpcent(&srp->srp_result[1 - idx]);
-                }
+                       lst_reset_rpcent(&srp->srp_result[1 - idx]);
+               }
 
                 idx = 1 - idx;
 
@@ -2051,22 +2055,20 @@ out:
 int
 jt_lst_show_error(int argc, char **argv)
 {
-       struct list_head            head;
-        lst_stat_req_param_t *srp;
-        lstcon_rpc_ent_t     *ent;
-        sfw_counters_t       *sfwk;
-        srpc_counters_t      *srpc;
-        int                   show_rpc = 1;
-        int                   optidx   = 0;
-        int                   rc       = 0;
-        int                   ecount;
-        int                   c;
-
-        static struct option  show_error_opts[] =
-        {
-                {"session", no_argument,       0, 's' },
-                {0,         0,                 0,  0  }
-        };
+       struct list_head       head;
+       lst_stat_req_param_t  *srp;
+       struct lstcon_rpc_ent *ent;
+       struct sfw_counters   *sfwk;
+       struct srpc_counters  *srpc;
+       int                    show_rpc = 1;
+       int                    optidx = 0;
+       int                    rc = 0;
+       int                    ecount;
+       int                    c;
+
+       static const struct option show_error_opts[] = {
+               { .name = "session", .has_arg = no_argument, .val = 's' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2135,8 +2137,8 @@ jt_lst_show_error(int argc, char **argv)
                                 continue;
                         }
 
-                        sfwk = (sfw_counters_t *)&ent->rpe_payload[0];
-                        srpc = (srpc_counters_t *)((char *)sfwk + sizeof(*sfwk));
+                       sfwk = (struct sfw_counters *)&ent->rpe_payload[0];
+                       srpc = (struct srpc_counters *)((char *)sfwk + sizeof(*sfwk));
 
                         if (srpc->errors == 0 &&
                             sfwk->brw_errors == 0 && sfwk->ping_errors == 0)
@@ -2174,9 +2176,9 @@ out:
 }
 
 int
-lst_add_batch_ioctl (char *name)
+lst_add_batch_ioctl(char *name)
 {
-        lstio_batch_add_args_t args = {0};
+       struct lstio_batch_add_args args = { 0 };
 
         args.lstio_bat_key   = session_key;
         args.lstio_bat_nmlen = strlen(name);
@@ -2222,7 +2224,7 @@ jt_lst_add_batch(int argc, char **argv)
 int
 lst_start_batch_ioctl(char *name, int timeout, struct list_head *resultp)
 {
-        lstio_batch_run_args_t args = {0};
+       struct lstio_batch_run_args args = { 0 };
 
         args.lstio_bat_key     = session_key;
         args.lstio_bat_timeout = timeout;
@@ -2236,19 +2238,17 @@ lst_start_batch_ioctl(char *name, int timeout, struct list_head *resultp)
 int
 jt_lst_start_batch(int argc, char **argv)
 {
-       struct list_head        head;
-        char             *batch;
-        int               optidx  = 0;
-        int               timeout = 0;
-        int               count = 0;
-        int               rc;
-        int               c;
+       struct list_head  head;
+       char             *batch;
+       int               optidx = 0;
+       int               timeout = 0;
+       int               count = 0;
+       int               rc;
+       int               c;
 
-        static struct option start_batch_opts[] =
-        {
-                {"timeout", required_argument, 0, 't' },
-                {0,         0,                 0,  0  }
-        };
+       static const struct option start_batch_opts[] = {
+               { .name = "timeout", .has_arg = required_argument, .val = 't' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2325,7 +2325,7 @@ jt_lst_start_batch(int argc, char **argv)
 int
 lst_stop_batch_ioctl(char *name, int force, struct list_head *resultp)
 {
-        lstio_batch_stop_args_t args = {0};
+       struct lstio_batch_stop_args args = { 0 };
 
         args.lstio_bat_key     = session_key;
         args.lstio_bat_force   = force;
@@ -2339,19 +2339,17 @@ lst_stop_batch_ioctl(char *name, int force, struct list_head *resultp)
 int
 jt_lst_stop_batch(int argc, char **argv)
 {
-       struct list_head        head;
-        char             *batch;
-        int               force = 0;
-        int               optidx;
-        int               count;
-        int               rc;
-        int               c;
+       struct list_head  head;
+       char             *batch;
+       int               force = 0;
+       int               optidx;
+       int               count;
+       int               rc;
+       int               c;
 
-        static struct option stop_batch_opts[] =
-        {
-                {"force",   no_argument,   0, 'f' },
-                {0,         0,             0,  0  }
-        };
+       static const struct option stop_batch_opts[] = {
+               { .name = "force", .has_arg = no_argument, .val = 'f' },
+               { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2445,7 +2443,7 @@ out:
 int
 lst_list_batch_ioctl(int len, char *name, int index)
 {
-        lstio_batch_list_args_t args = {0};
+       struct lstio_batch_list_args args = { 0 };
 
         args.lstio_bat_key   = session_key;
         args.lstio_bat_idx   = index;
@@ -2457,10 +2455,10 @@ lst_list_batch_ioctl(int len, char *name, int index)
 
 int
 lst_info_batch_ioctl(char *batch, int test, int server,
-                     lstcon_test_batch_ent_t *entp, int *idxp,
-                     int *ndentp, lstcon_node_ent_t *dentsp)
+                    struct lstcon_test_batch_ent *entp, int *idxp,
+                    int *ndentp, struct lstcon_node_ent *dentsp)
 {
-        lstio_batch_info_args_t args = {0};
+       struct lstio_batch_info_args args = { 0 };
 
         args.lstio_bat_key     = session_key;
         args.lstio_bat_nmlen   = strlen(batch);
@@ -2506,7 +2504,7 @@ int
 lst_list_tsb_nodes(char *batch, int test, int server,
                    int count, int active, int invalid)
 {
-        lstcon_node_ent_t *dents;
+       struct lstcon_node_ent *dents;
         int                index = 0;
         int                rc;
         int                c;
@@ -2516,7 +2514,7 @@ lst_list_tsb_nodes(char *batch, int test, int server,
                 return 0;
 
         /* verbose list, show nodes in batch or test */
-        dents = malloc(count * sizeof(lstcon_node_ent_t));
+       dents = malloc(count * sizeof(struct lstcon_node_ent));
         if (dents == NULL) {
                 fprintf(stdout, "Can't allocate memory\n");
                 return -1;
@@ -2555,27 +2553,25 @@ lst_list_tsb_nodes(char *batch, int test, int server,
 int
 jt_lst_list_batch(int argc, char **argv)
 {
-        lstcon_test_batch_ent_t ent;
-        char                *batch   = NULL;
-        int                  optidx  = 0;
-        int                  verbose = 0; /* list nodes in batch or test */
-        int                  invalid = 0;
-        int                  active  = 0;
-        int                  server  = 0;
-        int                  ntest   = 0;
-        int                  test    = 0;
-        int                  c       = 0;
-        int                  rc;
-
-        static struct option list_batch_opts[] =
-        {
-                {"test",    required_argument, 0, 't' },
-                {"invalid", no_argument,       0, 'i' },
-                {"active",  no_argument,       0, 'a' },
-                {"all",     no_argument,       0, 'l' },
-                {"server",  no_argument,       0, 's' },
-                {0,         0,                 0,  0  }
-        };
+       struct lstcon_test_batch_ent ent;
+       char *batch   = NULL;
+       int   optidx  = 0;
+       int   verbose = 0; /* list nodes in batch or test */
+       int   invalid = 0;
+       int   active  = 0;
+       int   server  = 0;
+       int   ntest   = 0;
+       int   test    = 0;
+       int   c       = 0;
+       int   rc;
+
+       static const struct option list_batch_opts[] = {
+               { .name = "test",    .has_arg = required_argument, .val = 't' },
+               { .name = "invalid", .has_arg = no_argument,       .val = 'i' },
+               { .name = "active",  .has_arg = no_argument,       .val = 'a' },
+               { .name = "all",     .has_arg = no_argument,       .val = 'l' },
+               { .name = "server",  .has_arg = no_argument,       .val = 's' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2694,7 +2690,7 @@ int
 lst_query_batch_ioctl(char *batch, int test, int server,
                      int timeout, struct list_head *head)
 {
-        lstio_batch_query_args_t args = {0};
+       struct lstio_batch_query_args args = { 0 };
 
         args.lstio_bat_key     = session_key;
         args.lstio_bat_testidx = test;
@@ -2711,7 +2707,7 @@ void
 lst_print_tsb_verbose(struct list_head *head,
                       int active, int idle, int error)
 {
-        lstcon_rpc_ent_t *ent;
+       struct lstcon_rpc_ent *ent;
 
        list_for_each_entry(ent, head, rpe_link) {
                 if (ent->rpe_priv[0] == 0 && active)
@@ -2735,38 +2731,36 @@ lst_print_tsb_verbose(struct list_head *head,
 int
 jt_lst_query_batch(int argc, char **argv)
 {
-        lstcon_test_batch_ent_t ent;
-       struct list_head              head;
-        char                   *batch   = NULL;
-        time_t                  last    = 0;
-        int                     optidx  = 0;
-        int                     verbose = 0;
-        int                     server  = 0;
-        int                     timeout = 5; /* default 5 seconds */
-        int                     delay   = 5; /* default 5 seconds */
-        int                     loop    = 1; /* default 1 loop */
-        int                     active  = 0;
-        int                     error   = 0;
-        int                     idle    = 0;
-        int                     count   = 0;
-        int                     test    = 0;
-        int                     rc      = 0;
-        int                     c       = 0;
-        int                     i;
-
-        static struct option query_batch_opts[] =
-        {
-                {"timeout", required_argument, 0, 'o' },
-                {"delay",   required_argument, 0, 'd' },
-                {"loop",    required_argument, 0, 'c' },
-                {"test",    required_argument, 0, 't' },
-                {"server",  no_argument,       0, 's' },
-                {"active",  no_argument,       0, 'a' },
-                {"idle",    no_argument,       0, 'i' },
-                {"error",   no_argument,       0, 'e' },
-                {"all",     no_argument,       0, 'l' },
-                {0,         0,                 0,  0  }
-        };
+       struct lstcon_test_batch_ent ent;
+       struct list_head head;
+       char   *batch   = NULL;
+       time_t  last    = 0;
+       int     optidx  = 0;
+       int     verbose = 0;
+       int     server  = 0;
+       int     timeout = 5; /* default 5 seconds */
+       int     delay   = 5; /* default 5 seconds */
+       int     loop    = 1; /* default 1 loop */
+       int     active  = 0;
+       int     error   = 0;
+       int     idle    = 0;
+       int     count   = 0;
+       int     test    = 0;
+       int     rc      = 0;
+       int     c       = 0;
+       int     i;
+
+       static const struct option query_batch_opts[] = {
+               { .name = "timeout", .has_arg = required_argument, .val = 'o' },
+               { .name = "delay",   .has_arg = required_argument, .val = 'd' },
+               { .name = "loop",    .has_arg = required_argument, .val = 'c' },
+               { .name = "test",    .has_arg = required_argument, .val = 't' },
+               { .name = "server",  .has_arg = no_argument,       .val = 's' },
+               { .name = "active",  .has_arg = no_argument,       .val = 'a' },
+               { .name = "idle",    .has_arg = no_argument,       .val = 'i' },
+               { .name = "error",   .has_arg = no_argument,       .val = 'e' },
+               { .name = "all",     .has_arg = no_argument,       .val = 'l' },
+               { .name = NULL, } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -2934,7 +2928,7 @@ lst_parse_distribute(char *dstr, int *dist, int *span)
 }
 
 int
-lst_get_bulk_param(int argc, char **argv, lst_test_bulk_param_t *bulk)
+lst_get_bulk_param(int argc, char **argv, struct lst_test_bulk_param *bulk)
 {
         char   *tok = NULL;
         char   *end = NULL;
@@ -2944,6 +2938,7 @@ lst_get_bulk_param(int argc, char **argv, lst_test_bulk_param_t *bulk)
         bulk->blk_size  = 4096;
         bulk->blk_opc   = LST_BRW_READ;
         bulk->blk_flags = LST_BRW_CHECK_NONE;
+       bulk->blk_srv_off = bulk->blk_cli_off = 0;
 
         while (i < argc) {
                 if (strcasestr(argv[i], "check=") == argv[i] ||
@@ -2961,8 +2956,6 @@ lst_get_bulk_param(int argc, char **argv, lst_test_bulk_param_t *bulk)
 
                } else if (strcasestr(argv[i], "size=") == argv[i] ||
                           strcasestr(argv[i], "s=") == argv[i]) {
-                       int max_size = sysconf(_SC_PAGESIZE) * LNET_MAX_IOV;
-
                         tok = strchr(argv[i], '=') + 1;
 
                         bulk->blk_size = strtol(tok, &end, 0);
@@ -2979,12 +2972,33 @@ lst_get_bulk_param(int argc, char **argv, lst_test_bulk_param_t *bulk)
                         else if (*end == 'm' || *end == 'M')
                                 bulk->blk_size *= 1024 * 1024;
 
-                       if (bulk->blk_size > max_size) {
+                       if (bulk->blk_size > LNET_MTU) {
                                 fprintf(stderr, "Size exceed limitation: %d bytes\n",
                                         bulk->blk_size);
                                 return -1;
                         }
 
+               } else if (strcasestr(argv[i], "off=") == argv[i]) {
+                       int     off;
+
+                       tok = strchr(argv[i], '=') + 1;
+
+                       off = strtol(tok, &end, 0);
+                       /* NB: align with sizeof(__u64) to simplify page
+                        * checking implementation */
+                       if (off < 0 || off % sizeof(__u64) != 0) {
+                               fprintf(stderr,
+                                       "Invalid offset %s/%d, it should be "
+                                       "postive value and multiple of %d\n",
+                                       tok, off, (int)sizeof(__u64));
+                               return -1;
+                       }
+
+                       /* NB: blk_srv_off is reserved so far */
+                       bulk->blk_cli_off = bulk->blk_srv_off = off;
+                       if (end == NULL)
+                               return 0;
+
                 } else if (strcasecmp(argv[i], "read") == 0 ||
                            strcasecmp(argv[i], "r") == 0) {
                         bulk->blk_opc = LST_BRW_READ;
@@ -3007,7 +3021,7 @@ lst_get_bulk_param(int argc, char **argv, lst_test_bulk_param_t *bulk)
 int
 lst_get_test_param(char *test, int argc, char **argv, void **param, int *plen)
 {
-        lst_test_bulk_param_t *bulk = NULL;
+       struct lst_test_bulk_param *bulk = NULL;
         int                    type;
 
         type = lst_test_name2type(test);
@@ -3052,7 +3066,7 @@ lst_add_test_ioctl(char *batch, int type, int loop, int concur,
                    int dist, int span, char *sgrp, char *dgrp,
                   void *param, int plen, int *retp, struct list_head *resultp)
 {
-        lstio_test_args_t args = {0};
+       struct lstio_test_args args = { 0 };
 
         args.lstio_tes_key        = session_key;
         args.lstio_tes_bat_nmlen  = strlen(batch);
@@ -3078,36 +3092,34 @@ lst_add_test_ioctl(char *batch, int type, int loop, int concur,
 int
 jt_lst_add_test(int argc, char **argv)
 {
-       struct list_head    head;
-        char         *batch  = NULL;
-        char         *test   = NULL;
-        char         *dstr   = NULL;
-        char         *from   = NULL;
-        char         *to     = NULL;
-        void         *param  = NULL;
-        int           optidx = 0;
-        int           concur = 1;
-        int           loop   = -1;
-        int           dist   = 1;
-        int           span   = 1;
-        int           plen   = 0;
-        int           fcount = 0;
-        int           tcount = 0;
-        int           ret    = 0;
-        int           type;
-        int           rc;
-        int           c;
-
-        static struct option add_test_opts[] =
-        {
-                {"batch",       required_argument, 0, 'b' },
-                {"concurrency", required_argument, 0, 'c' },
-                {"distribute",  required_argument, 0, 'd' },
-                {"from",        required_argument, 0, 'f' },
-                {"to",          required_argument, 0, 't' },
-                {"loop",        required_argument, 0, 'l' },
-                {0,             0,                 0,  0  }
-        };
+       struct list_head head;
+       char *batch  = NULL;
+       char *test   = NULL;
+       char *dstr   = NULL;
+       char *from   = NULL;
+       char *to     = NULL;
+       void *param  = NULL;
+       int   optidx = 0;
+       int   concur = 1;
+       int   loop   = -1;
+       int   dist   = 1;
+       int   span   = 1;
+       int   plen   = 0;
+       int   fcount = 0;
+       int   tcount = 0;
+       int   ret    = 0;
+       int   type;
+       int   rc;
+       int   c;
+
+       static const struct option add_test_opts[] = {
+       { .name = "batch",       .has_arg = required_argument, .val = 'b' },
+       { .name = "concurrency", .has_arg = required_argument, .val = 'c' },
+       { .name = "distribute",  .has_arg = required_argument, .val = 'd' },
+       { .name = "from",        .has_arg = required_argument, .val = 'f' },
+       { .name = "to",          .has_arg = required_argument, .val = 't' },
+       { .name = "loop",        .has_arg = required_argument, .val = 'l' },
+       { .name = NULL } };
 
         if (session_key == 0) {
                 fprintf(stderr,
@@ -3251,7 +3263,7 @@ static command_t lst_cmdlist[] = {
           "Usage: lst list_group [--active] [--busy] [--down] [--unknown] GROUP ..."    },
        {"stat",                jt_lst_stat,            NULL,
         "Usage: lst stat [--bw] [--rate] [--read] [--write] [--max] [--min] [--avg] "
-        " [--timeout #] [--delay #] [--count #] GROUP [GROUP]"                         },
+        " [--mbs] [--timeout #] [--delay #] [--count #] GROUP [GROUP]"                 },
         {"show_error",          jt_lst_show_error,      NULL,
          "Usage: lst show_error NAME | IDS ..."                                         },
         {"add_batch",           jt_lst_add_batch,       NULL,
@@ -3268,6 +3280,7 @@ static command_t lst_cmdlist[] = {
          "Usage: lst add_test [--batch BATCH] [--loop #] [--concurrency #] "
          " [--distribute #:#] [--from GROUP] [--to GROUP] TEST..."                      },
         {"help",                Parser_help,            0,     "help"                   },
+       {"--list-commands",     lst_list_commands,      0,     "list commands"          },
         {0,                     0,                      0,      NULL                    }
 };
 
@@ -3301,6 +3314,15 @@ lst_initialize(void)
         return 0;
 }
 
+static int lst_list_commands(int argc, char **argv)
+{
+       char buffer[81] = ""; /* 80 printable chars + terminating NUL */
+
+       Parser_list_commands(lst_cmdlist, buffer, sizeof(buffer), NULL, 0, 4);
+
+       return 0;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -3312,9 +3334,9 @@ main(int argc, char **argv)
         if (rc < 0)
                 goto errorout;
 
-        rc = ptl_initialize(argc, argv);
-        if (rc < 0)
-                goto errorout;
+       rc = lustre_lnet_config_lib_init();
+       if (rc < 0)
+               goto errorout;
 
         Parser_init("lst > ", lst_cmdlist);