/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
*
- * This file is part of Portals, http://www.sf.net/projects/lustre/
+ * Copyright (c) 2013, 2014, Intel Corporation.
+ *
+ * This file is part of Lustre, https://wiki.hpdd.intel.com/
*
* Portals is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
-
-#include <libcfs/libcfsutil.h>
-#include <lnet/nidstr.h>
+#include <errno.h>
+#include <getopt.h>
+#include <limits.h>
+#include <netdb.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <time.h>
+#include <linux/types.h>
+#include <libcfs/libcfs.h>
+#include <libcfs/util/string.h>
+#include <libcfs/util/ioctl.h>
#include <lnet/lnetctl.h>
#include <lnet/socklnd.h>
-#include <lnet/lib-dlc.h>
+#include <lnet/lnet.h>
unsigned int libcfs_debug;
unsigned int libcfs_printk = D_CANTMASK;
int index;
int rc;
- if (!g_net_is_compatible (argv[0], SOCKLND, RALND, MXLND,
- O2IBLND, GNILND, 0))
+ if (!g_net_is_compatible (argv[0], SOCKLND, O2IBLND, GNILND, 0))
return -1;
for (index = 0;;index++) {
id.nid = data.ioc_nid;
id.pid = data.ioc_u32[4];
printf ("%-20s [%d]%s->%s:%d #%d\n",
- libcfs_id2str(id),
+ libcfs_id2str(id),
data.ioc_count, /* persistence */
/* my ip */
ptl_ipaddr_2_str(data.ioc_u32[2], buffer[0],
sizeof(buffer[1]), 1),
data.ioc_u32[1], /* peer port */
data.ioc_u32[3]); /* conn_count */
- } else if (g_net_is_compatible(NULL, RALND, 0)) {
- printf ("%-20s [%d]@%s:%d\n",
- libcfs_nid2str(data.ioc_nid), /* peer nid */
- data.ioc_count, /* peer persistence */
- /* peer ip */
- ptl_ipaddr_2_str(data.ioc_u32[0], buffer[1],
- sizeof(buffer[1]), 1),
- data.ioc_u32[1]); /* peer port */
} else if (g_net_is_compatible(NULL, GNILND, 0)) {
int disconn = data.ioc_flags >> 16;
char *state;
int port = 0;
int rc;
- if (!g_net_is_compatible (argv[0], SOCKLND, RALND,
- GNILND, 0))
+ if (!g_net_is_compatible(argv[0], SOCKLND, GNILND, 0))
return -1;
if (argc != 4) {
__u32 ip = 0;
int rc;
- if (!g_net_is_compatible (argv[0], SOCKLND, RALND, MXLND,
- O2IBLND, GNILND, 0))
+ if (!g_net_is_compatible(argv[0], SOCKLND, O2IBLND, GNILND, 0))
return -1;
if (g_net_is_compatible(NULL, SOCKLND, 0)) {
int index;
int rc;
- if (!g_net_is_compatible (argv[0], SOCKLND, RALND, MXLND, O2IBLND,
- GNILND, 0))
+ if (!g_net_is_compatible(argv[0], SOCKLND, O2IBLND, GNILND, 0))
return -1;
for (index = 0; ; index++) {
data.ioc_count, /* tx buffer size */
data.ioc_u32[5], /* rx buffer size */
data.ioc_flags ? "nagle" : "nonagle");
- } else if (g_net_is_compatible (NULL, RALND, 0)) {
- printf ("%-20s [%d]\n",
- libcfs_nid2str(data.ioc_nid),
- data.ioc_u32[0] /* device id */);
} else if (g_net_is_compatible (NULL, O2IBLND, 0)) {
printf ("%s mtu %d\n",
libcfs_nid2str(data.ioc_nid),
return 0;
}
- if (!g_net_is_compatible (NULL, SOCKLND, RALND, MXLND, O2IBLND,
- GNILND, 0))
+ if (!g_net_is_compatible(NULL, SOCKLND, O2IBLND, GNILND, 0))
return 0;
if (argc >= 2 &&
return 0;
}
-int
-jt_ptl_print_active_txs (int argc, char **argv)
-{
- struct libcfs_ioctl_data data;
- int index;
- int rc;
-
- if (!g_net_is_compatible (argv[0], QSWLND, 0))
- return -1;
-
- for (index = 0;;index++) {
- LIBCFS_IOC_INIT(data);
- data.ioc_net = g_net;
- data.ioc_count = index;
-
- rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_GET_TXDESC, &data);
- if (rc != 0)
- break;
-
- printf ("type %u payload %6d to %s via %s by pid %6d: "
- "%s, %s, state %d\n",
- data.ioc_u32[0],
- data.ioc_count,
- libcfs_nid2str(data.ioc_nid),
- libcfs_nid2str(data.ioc_u64[0]),
- data.ioc_u32[1],
- (data.ioc_flags & 1) ? "delayed" : "immediate",
- (data.ioc_flags & 2) ? "nblk" : "normal",
- data.ioc_flags >> 2);
- }
-
- if (index == 0) {
- if (errno == ENOENT) {
- printf ("<no active descs>\n");
- } else {
- fprintf(stderr, "Error getting active transmits list: "
- "%s: check dmesg.\n",
- strerror(errno));
- }
- }
- return 0;
-}
-
int jt_ptl_ping(int argc, char **argv)
{
int rc;
{"dest", required_argument, 0, 'd'},
{"rate", required_argument, 0, 'r'},
{"interval", required_argument, 0, 'i'},
+ {"latency", required_argument, 0, 'l'},
{"portal", required_argument, 0, 'p'},
{"message", required_argument, 0, 'm'},
{0, 0, 0, 0}
return -1;
}
- optstr = "s:d:r:i:p:m:";
+ optstr = opc == LNET_CTL_DROP_ADD ? "s:d:r:i:p:m:" : "s:d:r:l:p:m:";
memset(&attr, 0, sizeof(attr));
while (1) {
char c = getopt_long(argc, argv, optstr, opts, NULL);
break;
case 'r': /* drop rate */
- attr.u.drop.da_rate = strtoul(optarg, NULL, 0);
+ if (opc == LNET_CTL_DROP_ADD)
+ attr.u.drop.da_rate = strtoul(optarg, NULL, 0);
+ else
+ attr.u.delay.la_rate = strtoul(optarg, NULL, 0);
break;
case 'i': /* time interval (# seconds) for message drop */
- attr.u.drop.da_interval = strtoul(optarg, NULL, 0);
+ if (opc == LNET_CTL_DROP_ADD)
+ attr.u.drop.da_interval = strtoul(optarg,
+ NULL, 0);
+ else
+ attr.u.delay.la_interval = strtoul(optarg,
+ NULL, 0);
+ break;
+
+ case 'l': /* seconds to wait before activating rule */
+ attr.u.delay.la_latency = strtoul(optarg, NULL, 0);
break;
case 'p': /* portal to filter */
}
optind = 1;
- if ((attr.u.drop.da_rate == 0) == (attr.u.drop.da_interval == 0)) {
- fprintf(stderr, "please provide drop rate or interval\n");
- return -1;
+ if (opc == LNET_CTL_DROP_ADD) {
+ /* NB: drop rate and interval are exclusive to each other */
+ if (!((attr.u.drop.da_rate == 0) ^
+ (attr.u.drop.da_interval == 0))) {
+ fprintf(stderr,
+ "please provide either drop rate or interval "
+ "but not both at the same time.\n");
+ return -1;
+ }
+ } else if (opc == LNET_CTL_DELAY_ADD) {
+ if (!((attr.u.delay.la_rate == 0) ^
+ (attr.u.delay.la_interval == 0))) {
+ fprintf(stderr,
+ "please provide either delay rate or interval "
+ "but not both at the same time.\n");
+ return -1;
+ }
+
+ if (attr.u.delay.la_latency == 0) {
+ fprintf(stderr, "latency cannot be zero\n");
+ return -1;
+ }
}
if (attr.fa_src == 0 || attr.fa_dst == 0) {
}
printf("Added %s rule %s->%s (1/%d)\n",
- name, libcfs_nid2str(attr.fa_src),
- libcfs_nid2str(attr.fa_dst), attr.u.drop.da_rate);
+ name, libcfs_nid2str(attr.fa_src), libcfs_nid2str(attr.fa_dst),
+ opc == LNET_CTL_DROP_ADD ?
+ attr.u.drop.da_rate : attr.u.delay.la_rate);
return 0;
getopt_failed:
return fault_simul_rule_add(LNET_CTL_DROP_ADD, "drop", argc, argv);
}
+int
+jt_ptl_delay_add(int argc, char **argv)
+{
+ return fault_simul_rule_add(LNET_CTL_DELAY_ADD, "delay", argc, argv);
+}
+
static int
fault_simul_rule_del(__u32 opc, char *name, int argc, char **argv)
{
return fault_simul_rule_del(LNET_CTL_DROP_DEL, "drop", argc, argv);
}
+int
+jt_ptl_delay_del(int argc, char **argv)
+{
+ return fault_simul_rule_del(LNET_CTL_DELAY_DEL, "delay", argc, argv);
+}
+
static int
fault_simul_rule_reset(__u32 opc, char *name, int argc, char **argv)
{
return fault_simul_rule_reset(LNET_CTL_DROP_RESET, "drop", argc, argv);
}
+int
+jt_ptl_delay_reset(int argc, char **argv)
+{
+ return fault_simul_rule_reset(LNET_CTL_DELAY_RESET, "delay",
+ argc, argv);
+}
+
static int
fault_simul_rule_list(__u32 opc, char *name, int argc, char **argv)
{
stat.u.drop.ds_dropped, stat.fs_count,
stat.fs_put, stat.fs_ack,
stat.fs_get, stat.fs_reply);
+
+ } else if (opc == LNET_CTL_DELAY_LIST) {
+ printf("%s->%s (1/%d | %d, latency %d) ptl "LPX64
+ ", msg %x, "LPU64"/"LPU64", PUT "LPU64
+ ", ACK "LPU64", GET "LPU64", REP "LPU64"\n",
+ libcfs_nid2str(attr.fa_src),
+ libcfs_nid2str(attr.fa_dst),
+ attr.u.delay.la_rate, attr.u.delay.la_interval,
+ attr.u.delay.la_latency,
+ attr.fa_ptl_mask, attr.fa_msg_mask,
+ stat.u.delay.ls_delayed, stat.fs_count,
+ stat.fs_put, stat.fs_ack, stat.fs_get,
+ stat.fs_reply);
}
}
printf("found total %d\n", pos);
return fault_simul_rule_list(LNET_CTL_DROP_LIST, "drop", argc, argv);
}
+int
+jt_ptl_delay_list(int argc, char **argv)
+{
+ return fault_simul_rule_list(LNET_CTL_DELAY_LIST, "delay", argc, argv);
+}
+
double
get_cycles_per_usec ()
{