#include <stdio.h>
#include <string.h>
#include <stdint.h>
+#include <stdbool.h>
#include <errno.h>
#include <stdarg.h>
#include <inttypes.h>
#include <rte_per_lcore.h>
#include <rte_lcore.h>
#include <rte_log.h>
-#include <rte_atomic.h>
#include <rte_branch_prediction.h>
#include <rte_string_fns.h>
+#ifdef RTE_LIB_METRICS
#include <rte_metrics.h>
+#endif
#include <rte_cycles.h>
#ifdef RTE_LIB_SECURITY
#include <rte_security.h>
static int stdout_fd;
/**< Host id process is running on */
static char host_id[MAX_LONG_OPT_SZ];
+#ifdef RTE_LIB_METRICS
/**< Enable metrics. */
static uint32_t enable_metrics;
+#endif
/**< Enable stats reset. */
static uint32_t reset_stats;
/**< Enable xstats reset. */
/**< Enable iter mempool. */
static uint32_t enable_iter_mempool;
static char *mempool_iter_name;
+/**< Enable dump regs. */
+static uint32_t enable_dump_regs;
+static char *dump_regs_file_prefix;
/**< display usage */
static void
" --stats: to display port statistics, enabled by default\n"
" --xstats: to display extended port statistics, disabled by "
"default\n"
+#ifdef RTE_LIB_METRICS
" --metrics: to display derived metrics of the ports, disabled by "
"default\n"
+#endif
" --xstats-name NAME: to display single xstat id by NAME\n"
" --xstats-ids IDLIST: to display xstat values by id. "
"The argument is comma-separated list of xstat ids to print out.\n"
" --show-crypto: to display crypto information\n"
" --show-ring[=name]: to display ring information\n"
" --show-mempool[=name]: to display mempool information\n"
- " --iter-mempool=name: iterate mempool elements to display content\n",
+ " --iter-mempool=name: iterate mempool elements to display content\n"
+ " --dump-regs=file-prefix: dump registers to file with the file-prefix\n",
prgname);
}
{"stats", 0, NULL, 0},
{"stats-reset", 0, NULL, 0},
{"xstats", 0, NULL, 0},
+#ifdef RTE_LIB_METRICS
{"metrics", 0, NULL, 0},
+#endif
{"xstats-reset", 0, NULL, 0},
{"xstats-name", required_argument, NULL, 1},
{"collectd-format", 0, NULL, 0},
{"show-ring", optional_argument, NULL, 0},
{"show-mempool", optional_argument, NULL, 0},
{"iter-mempool", required_argument, NULL, 0},
+ {"dump-regs", required_argument, NULL, 0},
{NULL, 0, 0, 0}
};
else if (!strncmp(long_option[option_index].name, "xstats",
MAX_LONG_OPT_SZ))
enable_xstats = 1;
+#ifdef RTE_LIB_METRICS
else if (!strncmp(long_option[option_index].name,
"metrics",
MAX_LONG_OPT_SZ))
enable_metrics = 1;
+#endif
/* Reset stats */
if (!strncmp(long_option[option_index].name, "stats-reset",
MAX_LONG_OPT_SZ))
"iter-mempool", MAX_LONG_OPT_SZ)) {
enable_iter_mempool = 1;
mempool_iter_name = optarg;
+ } else if (!strncmp(long_option[option_index].name,
+ "dump-regs", MAX_LONG_OPT_SZ)) {
+ enable_dump_regs = 1;
+ dump_regs_file_prefix = optarg;
}
break;
case 1:
printf("\n NIC extended statistics for port %d cleared\n", port_id);
}
+#ifdef RTE_LIB_METRICS
static void
metrics_display(int port_id)
{
names = rte_malloc(NULL, sizeof(struct rte_metric_name) * len, 0);
if (names == NULL) {
- printf("Cannot allocate memory for metrcis names\n");
+ printf("Cannot allocate memory for metrics names\n");
rte_free(metrics);
return;
}
rte_free(metrics);
rte_free(names);
}
+#endif
static void
-show_security_context(uint16_t portid)
+show_security_context(uint16_t portid, bool inline_offload)
{
- void *p_ctx = rte_eth_dev_get_sec_ctx(portid);
+ void *p_ctx;
const struct rte_security_capability *s_cap;
+ if (inline_offload)
+ p_ctx = rte_eth_dev_get_sec_ctx(portid);
+ else
+ p_ctx = rte_cryptodev_get_sec_ctx(portid);
+
if (p_ctx == NULL)
return;
}
ret = rte_eth_dev_flow_ctrl_get(i, &fc_conf);
- if (ret == 0 && fc_conf.mode != RTE_FC_NONE) {
+ if (ret == 0 && fc_conf.mode != RTE_ETH_FC_NONE) {
printf("\t -- flow control mode %s%s high %u low %u pause %u%s%s\n",
- fc_conf.mode == RTE_FC_RX_PAUSE ? "rx " :
- fc_conf.mode == RTE_FC_TX_PAUSE ? "tx " :
- fc_conf.mode == RTE_FC_FULL ? "full" : "???",
+ fc_conf.mode == RTE_ETH_FC_RX_PAUSE ? "rx " :
+ fc_conf.mode == RTE_ETH_FC_TX_PAUSE ? "tx " :
+ fc_conf.mode == RTE_ETH_FC_FULL ? "full" : "???",
fc_conf.autoneg ? " auto" : "",
fc_conf.high_water,
fc_conf.low_water,
}
#ifdef RTE_LIB_SECURITY
- show_security_context(i);
+ show_security_context(i, true);
#endif
}
}
caplevel.n_nodes_max,
caplevel.n_nodes_nonleaf_max,
caplevel.n_nodes_leaf_max);
- printf("\t -- indetical: non leaf %u leaf %u\n",
+ printf("\t -- identical: non leaf %u leaf %u\n",
caplevel.non_leaf_nodes_identical,
caplevel.leaf_nodes_identical);
}
#ifdef RTE_LIB_SECURITY
- show_security_context(i);
+ show_security_context(i, false);
#endif
}
}
printf(" - Name (%s) on socket (%d)\n"
" - flags:\n"
"\t -- Single Producer Enqueue (%u)\n"
- "\t -- Single Consmer Dequeue (%u)\n",
+ "\t -- Single Consumer Dequeue (%u)\n",
ptr->name,
ptr->memzone->socket_id,
ptr->flags & RING_F_SP_ENQ,
"\t -- No cache align (%c)\n"
"\t -- SP put (%c), SC get (%c)\n"
"\t -- Pool created (%c)\n"
- "\t -- No IOVA config (%c)\n",
+ "\t -- No IOVA config (%c)\n"
+ "\t -- Not used for IO (%c)\n",
ptr->name,
ptr->socket_id,
- (flags & MEMPOOL_F_NO_SPREAD) ? 'y' : 'n',
- (flags & MEMPOOL_F_NO_CACHE_ALIGN) ? 'y' : 'n',
- (flags & MEMPOOL_F_SP_PUT) ? 'y' : 'n',
- (flags & MEMPOOL_F_SC_GET) ? 'y' : 'n',
- (flags & MEMPOOL_F_POOL_CREATED) ? 'y' : 'n',
- (flags & MEMPOOL_F_NO_IOVA_CONTIG) ? 'y' : 'n');
+ (flags & RTE_MEMPOOL_F_NO_SPREAD) ? 'y' : 'n',
+ (flags & RTE_MEMPOOL_F_NO_CACHE_ALIGN) ? 'y' : 'n',
+ (flags & RTE_MEMPOOL_F_SP_PUT) ? 'y' : 'n',
+ (flags & RTE_MEMPOOL_F_SC_GET) ? 'y' : 'n',
+ (flags & RTE_MEMPOOL_F_POOL_CREATED) ? 'y' : 'n',
+ (flags & RTE_MEMPOOL_F_NO_IOVA_CONTIG) ? 'y' : 'n',
+ (flags & RTE_MEMPOOL_F_NON_IO) ? 'y' : 'n');
printf(" - Size %u Cache %u element %u\n"
" - header %u trailer %u\n"
" - private data size %u\n",
}
}
+static void
+dump_regs(char *file_prefix)
+{
+#define MAX_FILE_NAME_SZ (MAX_LONG_OPT_SZ + 10)
+ char file_name[MAX_FILE_NAME_SZ];
+ struct rte_dev_reg_info reg_info;
+ struct rte_eth_dev_info dev_info;
+ unsigned char *buf_data;
+ size_t buf_size;
+ FILE *fp_regs;
+ uint16_t i;
+ int ret;
+
+ snprintf(bdr_str, MAX_STRING_LEN, " dump - Port REG");
+ STATS_BDR_STR(10, bdr_str);
+
+ RTE_ETH_FOREACH_DEV(i) {
+ /* Skip if port is not in mask */
+ if ((enabled_port_mask & (1ul << i)) == 0)
+ continue;
+
+ snprintf(bdr_str, MAX_STRING_LEN, " Port (%u)", i);
+ STATS_BDR_STR(5, bdr_str);
+
+ ret = rte_eth_dev_info_get(i, &dev_info);
+ if (ret) {
+ printf("Error getting device info: %d\n", ret);
+ continue;
+ }
+
+ memset(®_info, 0, sizeof(reg_info));
+ ret = rte_eth_dev_get_reg_info(i, ®_info);
+ if (ret) {
+ printf("Error getting device reg info: %d\n", ret);
+ continue;
+ }
+
+ buf_size = reg_info.length * reg_info.width;
+ buf_data = malloc(buf_size);
+ if (buf_data == NULL) {
+ printf("Error allocating %zu bytes buffer\n", buf_size);
+ continue;
+ }
+
+ reg_info.data = buf_data;
+ reg_info.length = 0;
+ ret = rte_eth_dev_get_reg_info(i, ®_info);
+ if (ret) {
+ printf("Error getting regs from device: %d\n", ret);
+ free(buf_data);
+ continue;
+ }
+
+ snprintf(file_name, MAX_FILE_NAME_SZ, "%s-port%u",
+ file_prefix, i);
+ fp_regs = fopen(file_name, "wb");
+ if (fp_regs == NULL) {
+ printf("Error during opening '%s' for writing: %s\n",
+ file_name, strerror(errno));
+ } else {
+ size_t nr_written;
+
+ nr_written = fwrite(buf_data, 1, buf_size, fp_regs);
+ if (nr_written != buf_size)
+ printf("Error during writing %s: %s\n",
+ file_prefix, strerror(errno));
+ else
+ printf("Device (%s) regs dumped successfully, "
+ "driver:%s version:0X%08X\n",
+ dev_info.device->name,
+ dev_info.driver_name, reg_info.version);
+
+ fclose(fp_regs);
+ }
+
+ free(buf_data);
+ }
+}
+
int
main(int argc, char **argv)
{
else if (nb_xstats_ids > 0)
nic_xstats_by_ids_display(i, xstats_ids,
nb_xstats_ids);
+#ifdef RTE_LIB_METRICS
else if (enable_metrics)
metrics_display(i);
+#endif
}
+#ifdef RTE_LIB_METRICS
/* print port independent stats */
if (enable_metrics)
metrics_display(RTE_METRICS_GLOBAL);
+#endif
/* show information for PMD */
if (enable_shw_port)
show_mempool(mempool_name);
if (enable_iter_mempool)
iter_mempool(mempool_iter_name);
+ if (enable_dump_regs)
+ dump_regs(dump_regs_file_prefix);
RTE_ETH_FOREACH_DEV(i)
rte_eth_dev_close(i);