static char addr_type = 'u';
static int verify;
static int nodelay;
-static int perf_query;
+
+enum perf_query_output {
+ PERF_QUERY_NONE,
+ PERF_QUERY_ROW,
+ PERF_QUERY_COL
+};
+static enum perf_query_outout perf_query;
int verbose;
struct ibv_context **verbs;
static void query_perf(char *svc)
{
+ static int lables;
int ret, cnt, i;
uint64_t *counters;
return;
}
- printf("%s,", svc);
- for (i = 0; i < cnt - 1; i++)
- printf("%llu,", (unsigned long long) counters[i]);
- printf("%llu\n", (unsigned long long) counters[i]);
+ if (perf_query == PERF_QUERY_ROW) {
+ if (!lables) {
+ for (i = 0; i < cnt - 1; i++)
+ printf("%s,", ib_acm_cntr_name(i));
+ printf("%s\n", ib_acm_cntr_namer(i));
+ lables = 1;
+ }
+ printf("%s,", svc);
+ for (i = 0; i < cnt - 1; i++)
+ printf("%llu,", (unsigned long long) counters[i]);
+ printf("%llu\n", (unsigned long long) counters[i]);
+ } else {
+ printf("%s\n", svc);
+ for (i = 0; i < cnt; i++) {
+ printf("%s : ", ib_acm_cntr_name(i));
+ printf("%llu\n", (unsigned long long) counters[i]);
+ }
+ }
ib_acm_free_perf(counters);
}
return -1;
}
- if (perf_query) {
- printf("Destination,Error Count,Resolve Count,No Data,Addr Query Count,"
- "Addr Cache Count,Route Query Count,Route Cache Count\n");
- }
-
for (i = 0; svc_list[i]; i++) {
ret = ib_acm_connect(svc_list[i]);
if (ret) {
if (ret)
goto out;
- while ((op = getopt(argc, argv, "f:s:d:vcA::O::D:PS:V")) != -1) {
+ while ((op = getopt(argc, argv, "f:s:d:vcA::O::D:P::S:V")) != -1) {
switch (op) {
case 'f':
addr_type = optarg[0];
dest_dir = optarg;
break;
case 'P':
- perf_query = 1;
+ if (opt_arg(argc, argv) && !strnicmp("col", opt_arg(argv, argc), 3))
+ perf_query = PERF_QUERY_COL;
+ else
+ perf_query = PERF_QUERY_ROW;
break;
case 'S':
svc_arg = optarg;
lock_release(&lock);
return ret;
}
+
+const char *ib_acm_cntr_name(int index)
+{
+ static const char *const cntr_name[] = {
+ [ACM_CNTR_ERROR] = "Error Count",
+ [ACM_CNTR_RESOLVE] = "Resolve Count",
+ [ACM_CNTR_NODATA] = "No Data",
+ [ACM_CNTR_ADDR_QUERY] = "Addr Query Count",
+ [ACM_CNTR_ADDR_CACHE] = "Addr Cache Count",
+ [ACM_CNTR_ROUTE_QUERY] = "Route Query Count",
+ [ACM_CNTR_ROUTE_CACHE] = "Route Cache Count",
+ };
+
+ if (index < ACM_CNTR_ERROR || index > ACM_CNTR_MAX)
+ return "Unknown";
+
+ return cntr_name[index];
+}