From: Nathan F. <nf...@li...> - 2015-04-08 19:46:59
|
This patch adds additional information to the output produced by the lsslot command for dynamic reconfiguration memory. The default output with this patch will add the address, drc index, and associativity for each LMB. #> lsslot -c mem Dynamic Reconfiguration Memory (LMB size 0x10000000) LMB2: DRC Index: 80000001 Removable: Yes Address: 10000000 Associativity: 0 0 1 1 Section(s): 1 -- snip -- Additionally, this patch allows users to specify the -d 4 option to lsslot for memory which will print information about all possible LMBs, not just the LMBs owned by the system. This patch also adds the ability to print the information for a specific LMB by specifyinf its drc index with the -s option. #> lsslot -c mem -s 0x80000011 Dynamic Reconfiguration Memory (LMB size 0x10000000) LMB18: DRC Index: 80000011 Removable: Yes Address: 110000000 Associativity: 0 0 1 1 Section(s): 17 Signed-off-by: Nathan Fontenot <nf...@li...> --- diff --git a/src/drmgr/drslot_chrp_mem.c b/src/drmgr/drslot_chrp_mem.c index ef16e93..9176eeb 100644 --- a/src/drmgr/drslot_chrp_mem.c +++ b/src/drmgr/drslot_chrp_mem.c @@ -313,6 +313,7 @@ get_dynamic_reconfig_lmbs(struct lmb_list_head *lmb_list) sprintf(lmb->ofdt_path, DYNAMIC_RECONFIG_MEM); lmb->lmb_size = lmb_sz; lmb->lmb_address = be64toh(drmem->address); + lmb->lmb_aa_index = be32toh(drmem->assoc_index); if (be32toh(drmem->flags) & DRMEM_ASSIGNED) { found++; diff --git a/src/drmgr/lsslot.c b/src/drmgr/lsslot.c index 22d1346..ea46722 100644 --- a/src/drmgr/lsslot.c +++ b/src/drmgr/lsslot.c @@ -699,8 +699,86 @@ lsslot_chrp_phb(struct cmd_opts *opts) return 0; } +int print_drconf_mem(struct cmd_opts *opts, struct lmb_list_head *lmb_list) +{ + struct dr_node *lmb; + struct mem_scn *scn; + int scn_offset = strlen("/sys/devices/system/memory/memory"); + char *aa_buf; + __be32 *aa; + int aa_size, aa_list_sz; + int i, rc; + uint32_t drc_index = 0; + + aa_size = get_property_size(DYNAMIC_RECONFIG_MEM, + "ibm,associativity-lookup-arrays"); + aa_buf = zalloc(aa_size); + rc = get_property(DYNAMIC_RECONFIG_MEM, + "ibm,associativity-lookup-arrays", aa_buf, aa_size); + if (rc) { + say(ERROR, "Could not get associativity information.\n"); + return -1; + } + + aa = (__be32 *)aa_buf; + /* skip past the number of associativity lists */ + aa++; + aa_list_sz = be32toh(*aa++); + + if (opts->s_name) + drc_index = strtol(opts->s_name, NULL, 0); + + printf("Dynamic Reconfiguration Memory (LMB size 0x%x)\n", + lmb_list->lmbs->lmb_size); + + for (lmb = lmb_list->lmbs; lmb; lmb = lmb->next) { + int first = 1; + int aa_start, aa_end; + + if (drc_index && drc_index != lmb->drc_index) + continue; + else if ((output_level < 4) && !lmb->is_owned) + continue; + + printf("%s: %s\n", lmb->drc_name, + lmb->is_owned ? "" : "Not Owned"); + + printf(" DRC Index: %x\n", lmb->drc_index); + printf(" Removable: %s\n", lmb->is_removable ? "Yes" : "No"); + printf(" Address: %lx\n", lmb->lmb_address); + printf(" Associativity: "); + if (lmb->lmb_aa_index == 0xffffffff) { + printf("Not Set\n"); + } else { + aa_start = lmb->lmb_aa_index * aa_list_sz; + aa_end = aa_start + aa_list_sz; + for (i = aa_start; i < aa_end; i++) + printf("%d ", be32toh(aa[i])); + printf("\n"); + } + + if (lmb->is_owned) { + printf(" Section(s): "); + for (scn = lmb->lmb_mem_scns; scn; scn = scn->next) { + if (first) { + printf(" %s", + &scn->sysfs_path[scn_offset]); + first = 0; + } else + printf(", %s", + &scn->sysfs_path[scn_offset]); + } + + printf("\n"); + } + } + + free(aa_buf); + return 0; +} + int -lsslot_chrp_mem(void) +lsslot_chrp_mem(struct cmd_opts *opts) { struct lmb_list_head *lmb_list; struct dr_node *lmb; @@ -712,40 +790,40 @@ lsslot_chrp_mem(void) if (lmb_list == NULL || lmb_list->lmbs == NULL) return -1; - printf("lmb size: 0x%x\n", lmb_list->lmbs->lmb_size); if (lmb_list->drconf_buf) { - printf("ibm,dynamic-reconfiguration-memory\n"); - printf("%-5s %c %s\n", "Name", 'R', "Sections"); - printf("%-5s %c %s\n", "----", '-', "--------"); + print_drconf_mem(opts, lmb_list); } else { + printf("lmb size: 0x%x\n", lmb_list->lmbs->lmb_size); printf("%-20s %-5s %c %s\n", "Memory Node", "Name", 'R', "Sections"); printf("%-20s %-5s %c %s\n", "-----------", "----", '-', "--------"); - } - for (lmb = lmb_list->lmbs; lmb; lmb = lmb->next) { - int first = 1; + for (lmb = lmb_list->lmbs; lmb; lmb = lmb->next) { + int first = 1; - if (!lmb->is_owned) - continue; + if (!lmb->is_owned) + continue; - if (!lmb_list->drconf_buf) - printf("%-20s ", &lmb->ofdt_path[lmb_offset]); + if (!lmb_list->drconf_buf) + printf("%-20s ", &lmb->ofdt_path[lmb_offset]); - printf("%-5s %c ", lmb->drc_name, - lmb->is_removable ? 'Y' : 'N'); + printf("%-5s %c ", lmb->drc_name, + lmb->is_removable ? 'Y' : 'N'); - for (scn = lmb->lmb_mem_scns; scn; scn = scn->next) { - if (first) { - printf(" %s", &scn->sysfs_path[scn_offset]); - first = 0; - } else - printf(", %s", &scn->sysfs_path[scn_offset]); - } + for (scn = lmb->lmb_mem_scns; scn; scn = scn->next) { + if (first) { + printf(" %s", + &scn->sysfs_path[scn_offset]); + first = 0; + } else + printf(", %s", + &scn->sysfs_path[scn_offset]); + } - printf("\n"); + printf("\n"); + } } free_lmbs(lmb_list); @@ -888,7 +966,7 @@ main(int argc, char *argv[]) break; case MEM: - rc = lsslot_chrp_mem(); + rc = lsslot_chrp_mem(&opts); break; case PORT: diff --git a/src/drmgr/ofdt.h b/src/drmgr/ofdt.h index 954377b..c728507 100644 --- a/src/drmgr/ofdt.h +++ b/src/drmgr/ofdt.h @@ -77,12 +77,14 @@ struct dr_node { struct mem_info { uint64_t _address; uint32_t _lmb_size; + uint32_t _lmb_aa_index; struct mem_scn *_mem_scns; struct of_node *_of_node; } _smem; #define lmb_address _node_u._smem._address #define lmb_size _node_u._smem._lmb_size +#define lmb_aa_index _node_u._smem._lmb_aa_index #define lmb_mem_scns _node_u._smem._mem_scns #define lmb_of_node _node_u._smem._of_node |