/**< 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
" --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);
}
{"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}
};
"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:
}
}
+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)
{
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);