summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (from parent 1: 7f77e03)
raw | patch | inline | side by side (from parent 1: 7f77e03)
author | Nikhil Devshatwar <nikhil.nd@ti.com> | |
Wed, 4 Nov 2020 07:08:31 +0000 (12:38 +0530) | ||
committer | Lokesh Vutla <lokeshvutla@ti.com> | |
Wed, 4 Nov 2020 09:44:38 +0000 (15:14 +0530) |
Add support for following dump commands to print the resource
allocation for all utypes. Allow to filter on specified
type / subtype
$> k3conf dump rm
$> k3conf dump rm <type>
$> k3conf dump rm <type> <subtype>
Also allow to filter on given host_id with -h option
Update the help accordingly
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
allocation for all utypes. Allow to filter on specified
type / subtype
$> k3conf dump rm
$> k3conf dump rm <type>
$> k3conf dump rm <type> <subtype>
Also allow to filter on given host_id with -h option
Update the help accordingly
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
common/cmd_dump.c | patch | blob | history | |
common/help.c | patch | blob | history | |
include/help.h | patch | blob | history |
diff --git a/common/cmd_dump.c b/common/cmd_dump.c
index 518a7186b51d5f18b8cbebf3f8413aeb409ed9d8..6192ca4fbd7f171211974a24390bf09cf7788d2e 100644 (file)
--- a/common/cmd_dump.c
+++ b/common/cmd_dump.c
return autoadjust_table_print(table, found + 1, 5);
}
+static int dump_rm_resource(u_int32_t type, u_int32_t subtype,
+ u_int32_t host_id, char *value)
+{
+ struct ti_sci_rm_desc desc;
+ int ret;
+
+ ret = ti_sci_cmd_get_range(type, subtype, host_id, &desc);
+ if (ret)
+ return ret;
+
+ if (desc.num_sec && desc.num) {
+
+ /* Print Primary + Secondary range */
+ snprintf(value, TABLE_MAX_ELT_LEN, "[%5d +%4d] (%4d +%3d)",
+ desc.start, desc.num,
+ desc.start_sec, desc.num_sec);
+
+ } else if (desc.num_sec) {
+
+ /* Print blank + Secondary range */
+ snprintf(value, TABLE_MAX_ELT_LEN, "[ ] (%4d +%3d)",
+ desc.start_sec, desc.num_sec);
+ } else if (desc.num) {
+
+ /* Print only Primary range */
+ snprintf(value, TABLE_MAX_ELT_LEN,
+ "[%5d +%4d]",
+ desc.start, desc.num);
+ } else {
+ *value = 0;
+ }
+
+ return 0;
+}
+
+static int dump_rm_info(int argc, char *argv[])
+{
+ uint32_t filter_host_id = 0, filter_type = 0, filter_subtype = 0xFFF;
+ char table[TABLE_MAX_ROW][TABLE_MAX_COL][TABLE_MAX_ELT_LEN];
+ struct ti_sci_host_info *h = soc_info.sci_info.host_info;
+ struct ti_sci_rm_info *r = soc_info.sci_info.rm_info;
+ uint32_t type, subtype, host_id, host_valid;
+ char cell[TABLE_MAX_ELT_LEN], *host_name;
+ uint32_t i, j, row, col;
+ int ret;
+
+ if (argc > 0 && !strcmp(argv[0], "-h")) {
+
+ if (argc == 1)
+ return -1;
+
+ sscanf(argv[1], "%u", &filter_host_id);
+ argc -= 2;
+ argv += 2;
+ }
+
+ if (argc > 0) {
+ sscanf(argv[0], "%u", &filter_type);
+ argc--;
+ argv++;
+ }
+
+ if (argc > 0) {
+ sscanf(argv[0], "%u", &filter_subtype);
+ argc--;
+ argv++;
+ }
+
+ autoadjust_table_init(table);
+ snprintf(table[0][0], TABLE_MAX_ELT_LEN,
+ "Resource allocation => [Primary start +count] (Secondary start +count)");
+ snprintf(table[1][0], TABLE_MAX_ELT_LEN,
+ "utype");
+ snprintf(table[1][1], TABLE_MAX_ELT_LEN,
+ "type");
+ snprintf(table[1][2], TABLE_MAX_ELT_LEN,
+ "subtype");
+
+ row = 2;
+ col = 3;
+ for (i = 0; i < soc_info.sci_info.num_hosts; i++) {
+
+ host_valid = 0;
+ host_id = h[i].host_id;
+ host_name = h[i].host_name;
+ if (filter_host_id && host_id != filter_host_id)
+ continue;
+
+ row = 2;
+ for (j = 0; j < soc_info.sci_info.num_res; j++) {
+
+ type = r[j].utype >> 6;
+ subtype = r[j].utype & 0x3F;
+
+ if (filter_type && type != filter_type)
+ continue;
+ if (filter_subtype != 0xFFF && subtype != filter_subtype)
+ continue;
+
+ snprintf(table[row][0], TABLE_MAX_ELT_LEN,
+ "0x%04x", r[j].utype);
+ snprintf(table[row][1], TABLE_MAX_ELT_LEN,
+ "%d", type);
+ snprintf(table[row][2], TABLE_MAX_ELT_LEN,
+ "%d", subtype);
+
+ ret = dump_rm_resource(type, subtype, host_id, cell);
+ if (ret)
+ return ret;
+
+ if (!cell[0]) {
+ row++;
+ continue;
+ }
+
+ host_valid = 1;
+ snprintf(table[row][col], TABLE_MAX_ELT_LEN,
+ "%s", cell);
+ row++;
+ }
+
+ if (!host_valid)
+ continue;
+
+ snprintf(table[1][col], TABLE_MAX_ELT_LEN,
+ "%s", host_name);
+ col++;
+ }
+
+ return autoadjust_table_generic_fprint(stdout, table, row, col,
+ TABLE_HAS_TITLE | TABLE_HAS_SUBTITLE);
+}
+
int process_dump_command(int argc, char *argv[])
{
int ret;
ret = dump_processors_info(argc, argv);
if (ret)
help(HELP_DUMP_PROCESSOR);
+ } else if(!strncmp(argv[0], "rm", 2)) {
+ argc--;
+ argv++;
+ ret = dump_rm_info(argc, argv);
+ if (ret) {
+ fprintf(stderr, "Invalid arguments\n");
+ help(HELP_DUMP_RM);
+ }
} else if (!strcmp(argv[0], "--help")) {
help(HELP_DUMP);
return 0;
diff --git a/common/help.c b/common/help.c
index b33540588d58a44195686a962a556987254587a5..130c358b7722d2466b434bc8f0a34016143568f2 100644 (file)
--- a/common/help.c
+++ b/common/help.c
printf("\n\tk3conf dump processor <proc_id>\n");
printf("\t Prints status of the given TISCI processors\n");
}
+ if ((cat == HELP_ALL) || (cat == HELP_DUMP) ||
+ (cat == HELP_DUMP_RM)) {
+ printf("\n\tk3conf dump rm [OPTIONS]\n");
+ printf("\t Prints resource allocation for all utypes / hosts\n");
+ printf("\n\tk3conf dump rm [OPTIONS] <type>\n");
+ printf("\t Prints resource allocation for corresponding type\n");
+ printf("\n\tk3conf dump rm [OPTIONS] <type> <subtype>\n");
+ printf("\t Prints resource allocation for corresponding device/type\n");
+ printf("\t \n");
+ printf("\t [OPTIONS]\n");
+ printf("\t -h <host_id>\n");
+ printf("\t Filter only for corresponding host_id\n");
+ }
if ((cat == HELP_ALL) || (cat == HELP_ENABLE) ||
(cat == HELP_ENABLE_DEVICE)) {
printf("\n\tk3conf enable device <dev_id>\n");
diff --git a/include/help.h b/include/help.h
index fe24c68d7d41717621a23598df6dac88e308ff15..a02f2ff9f00194b9878fd7687fbdbbe05ddd3539 100644 (file)
--- a/include/help.h
+++ b/include/help.h
HELP_DUMP_DEVICE,
HELP_DUMP_CLOCK,
HELP_DUMP_PROCESSOR,
+ HELP_DUMP_RM,
HELP_ENABLE,
HELP_ENABLE_DEVICE,
HELP_ENABLE_CLOCK,