Bill Hoffa | ffe8370 | 2015-03-30 21:37:20 -0500 | [diff] [blame] | 1 | From 438ebf4b5acbaab0da69009d4248a6aac45fbed6 Mon Sep 17 00:00:00 2001 |
| 2 | From: Dan Crowell <dcrowell@us.ibm.com> |
| 3 | Date: Wed, 11 Mar 2015 16:44:59 -0500 |
| 4 | Subject: [PATCH 3/5] Pull model name and serial from OSYS record if available |
| 5 | |
| 6 | The supported level of OP planar VPD has the system model |
| 7 | name inside OSYS:MM, not OPFR:DR. |
| 8 | |
| 9 | Change-Id: Iaa9c4e00325f8fa6efb7a9fca1275bcea2759308 |
| 10 | Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/16308 |
| 11 | Reviewed-by: William H. Schwartz <whs@us.ibm.com> |
| 12 | Tested-by: Jenkins Server |
| 13 | Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com> |
| 14 | (cherry picked from commit 2114a66c76558f41cd305fc294ccdfaf6607c0e5) |
| 15 | --- |
| 16 | src/usr/devtree/bld_devtree.C | 142 +++++++++++++++++++++++++++++++++++++----- |
| 17 | 1 file changed, 126 insertions(+), 16 deletions(-) |
| 18 | |
| 19 | diff --git a/src/usr/devtree/bld_devtree.C b/src/usr/devtree/bld_devtree.C |
| 20 | index f2e9438..622178a 100644 |
| 21 | --- a/src/usr/devtree/bld_devtree.C |
| 22 | +++ b/src/usr/devtree/bld_devtree.C |
| 23 | @@ -1034,18 +1034,26 @@ errlHndl_t bld_fdt_system(devTree * i_dt, bool i_smallTree) |
| 24 | // Nothing to do for small trees currently. |
| 25 | if (!i_smallTree) |
| 26 | { |
| 27 | + //===== compatible ===== |
| 28 | /* Fetch the MRW-defined compatible model from attributes */ |
| 29 | ATTR_OPAL_MODEL_type l_model = {0}; |
| 30 | TARGETING::Target* sys = NULL; |
| 31 | TARGETING::targetService().getTopLevelTarget(sys); |
| 32 | sys->tryGetAttr<TARGETING::ATTR_OPAL_MODEL>(l_model); |
| 33 | |
| 34 | - /* Add compatibility node */ |
| 35 | + /* Add compatibility value */ |
| 36 | const char* l_compats[] = { "ibm,powernv", l_model, NULL }; |
| 37 | i_dt->addPropertyStrings(rootNode, "compatible", l_compats); |
| 38 | |
| 39 | - /* Add system model node */ |
| 40 | - // Based off of the DR field in the OPFR |
| 41 | + //===== model ===== |
| 42 | + /* Add system model value |
| 43 | + Depending on the vintage of the planar VPD, there are 3 places |
| 44 | + we need to look for this data. |
| 45 | + 1) OSYS:MM |
| 46 | + 2) OPFR:DR |
| 47 | + 3) Default to 'unknown' |
| 48 | + */ |
| 49 | + bool foundvpd = false; |
| 50 | // TODO RTC 118373 -- update to account for firestone/memory riser |
| 51 | TARGETING::TargetHandleList l_membTargetList; |
| 52 | getAllChips(l_membTargetList, TYPE_MEMBUF); |
| 53 | @@ -1061,42 +1069,144 @@ errlHndl_t bld_fdt_system(devTree * i_dt, bool i_smallTree) |
| 54 | errhdl = deviceRead( l_pMem, |
| 55 | NULL, |
| 56 | vpdSize, |
| 57 | - DEVICE_CVPD_ADDRESS( CVPD::OPFR, |
| 58 | - CVPD::DR )); |
| 59 | + DEVICE_CVPD_ADDRESS( CVPD::OSYS, |
| 60 | + CVPD::MM )); |
| 61 | |
| 62 | if(errhdl) |
| 63 | { |
| 64 | - TRACFCOMP(g_trac_devtree,ERR_MRK" Couldn't get DR size for HUID=0x%.8X", |
| 65 | + TRACFCOMP(g_trac_devtree,ERR_MRK" Couldn't get OSYS:MM size for HUID=0x%.8X", |
| 66 | TARGETING::get_huid(l_pMem)); |
| 67 | - i_dt->addPropertyString(rootNode, "model", "unknown"); |
| 68 | - errlCommit(errhdl, DEVTREE_COMP_ID); |
| 69 | + |
| 70 | + // Try the OPFR record |
| 71 | + errlHndl_t opfr_errhdl = deviceRead( l_pMem, |
| 72 | + NULL, |
| 73 | + vpdSize, |
| 74 | + DEVICE_CVPD_ADDRESS( CVPD::OPFR, |
| 75 | + CVPD::DR )); |
| 76 | + if(opfr_errhdl) |
| 77 | + { |
| 78 | + TRACFCOMP(g_trac_devtree,ERR_MRK" Couldn't get OPFR:DR size for HUID=0x%.8X", |
| 79 | + TARGETING::get_huid(l_pMem)); |
| 80 | + delete opfr_errhdl; //delete OPFR log, VPD is just bad |
| 81 | + } |
| 82 | + else |
| 83 | + { |
| 84 | + delete errhdl; //ignore lack of OSYS due to older vpd |
| 85 | + errhdl = NULL; |
| 86 | + char drBuf[vpdSize+1]; |
| 87 | + memset(&drBuf, 0x0, (vpdSize+1)); //null terminated str |
| 88 | + errhdl = deviceRead( l_pMem, |
| 89 | + reinterpret_cast<void*>( &drBuf ), |
| 90 | + vpdSize, |
| 91 | + DEVICE_CVPD_ADDRESS( CVPD::OPFR, |
| 92 | + CVPD::DR )); |
| 93 | + |
| 94 | + if(errhdl) |
| 95 | + { |
| 96 | + TRACFCOMP(g_trac_devtree,ERR_MRK" Couldn't read OPFR:DR for HUID=0x%.8X", |
| 97 | + TARGETING::get_huid(l_pMem)); |
| 98 | + } |
| 99 | + else |
| 100 | + { |
| 101 | + foundvpd = true; |
| 102 | + i_dt->addPropertyString(rootNode, "model", drBuf); |
| 103 | + } |
| 104 | + } |
| 105 | } |
| 106 | else |
| 107 | { |
| 108 | - char drBuf[vpdSize+1]; |
| 109 | - memset(&drBuf, 0x0, (vpdSize+1)); //ensure null terminated str |
| 110 | + char mmBuf[vpdSize+1]; |
| 111 | + memset(&mmBuf, 0x0, (vpdSize+1)); //ensure null terminated str |
| 112 | errhdl = deviceRead( l_pMem, |
| 113 | - reinterpret_cast<void*>( &drBuf ), |
| 114 | + reinterpret_cast<void*>( &mmBuf ), |
| 115 | vpdSize, |
| 116 | - DEVICE_CVPD_ADDRESS( CVPD::OPFR, |
| 117 | - CVPD::DR )); |
| 118 | + DEVICE_CVPD_ADDRESS( CVPD::OSYS, |
| 119 | + CVPD::MM )); |
| 120 | |
| 121 | if(errhdl) |
| 122 | { |
| 123 | - TRACFCOMP(g_trac_devtree,ERR_MRK" Couldn't read DR for HUID=0x%.8X", |
| 124 | + TRACFCOMP(g_trac_devtree,ERR_MRK" Couldn't read OSYS:MM for HUID=0x%.8X", |
| 125 | TARGETING::get_huid(l_pMem)); |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | - i_dt->addPropertyString(rootNode, "model", drBuf); |
| 130 | + foundvpd = true; |
| 131 | + i_dt->addPropertyString(rootNode, "model", mmBuf); |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | - else //chassis info not found, default to unknown |
| 136 | + |
| 137 | + // just commit any errors we get, this isn't critical |
| 138 | + if( errhdl ) |
| 139 | + { |
| 140 | + errlCommit(errhdl, DEVTREE_COMP_ID); //commit original OSYS log |
| 141 | + } |
| 142 | + |
| 143 | + if( !foundvpd ) //chassis info not found, default to unknown |
| 144 | { |
| 145 | TRACFCOMP(g_trac_devtree,ERR_MRK" VPD not found, model defaulted to unknown"); |
| 146 | i_dt->addPropertyString(rootNode, "model", "unknown"); |
| 147 | } |
| 148 | + |
| 149 | + //===== system-id ===== |
| 150 | + /* Add system-id value |
| 151 | + 1) OSYS:SS |
| 152 | + 2) Default to 'unavailable' |
| 153 | + */ |
| 154 | + // TODO RTC 118373 -- update to account for firestone/memory riser |
| 155 | + foundvpd = false; |
| 156 | + if( l_membTargetList.size() ) |
| 157 | + { |
| 158 | + // TODO RTC 118373 - Should be able to read from attribute |
| 159 | + TARGETING::Target * l_pMem = l_membTargetList[0]; |
| 160 | + size_t vpdSize = 0x0; |
| 161 | + |
| 162 | + // Note: First read with NULL for o_buffer sets vpdSize to the |
| 163 | + // correct length |
| 164 | + errhdl = deviceRead( l_pMem, |
| 165 | + NULL, |
| 166 | + vpdSize, |
| 167 | + DEVICE_CVPD_ADDRESS( CVPD::OSYS, |
| 168 | + CVPD::SS )); |
| 169 | + |
| 170 | + if(errhdl) |
| 171 | + { |
| 172 | + TRACFCOMP(g_trac_devtree,ERR_MRK" Couldn't get OSYS:SS size for HUID=0x%.8X", |
| 173 | + TARGETING::get_huid(l_pMem)); |
| 174 | + // Note - not supporting old vpd versions without OSYS here |
| 175 | + } |
| 176 | + else |
| 177 | + { |
| 178 | + char ssBuf[vpdSize+1]; |
| 179 | + memset(&ssBuf, 0x0, (vpdSize+1)); //ensure null terminated str |
| 180 | + errhdl = deviceRead( l_pMem, |
| 181 | + reinterpret_cast<void*>( &ssBuf ), |
| 182 | + vpdSize, |
| 183 | + DEVICE_CVPD_ADDRESS( CVPD::OSYS, |
| 184 | + CVPD::SS )); |
| 185 | + |
| 186 | + if(errhdl) |
| 187 | + { |
| 188 | + TRACFCOMP(g_trac_devtree,ERR_MRK" Couldn't read OSYS:SS for HUID=0x%.8X", |
| 189 | + TARGETING::get_huid(l_pMem)); |
| 190 | + } |
| 191 | + else |
| 192 | + { |
| 193 | + foundvpd = true; |
| 194 | + i_dt->addPropertyString(rootNode, "system-id", ssBuf); |
| 195 | + } |
| 196 | + } |
| 197 | + } |
| 198 | + // just commit any errors we get, this isn't critical |
| 199 | + if( errhdl ) |
| 200 | + { |
| 201 | + errlCommit(errhdl, DEVTREE_COMP_ID); |
| 202 | + } |
| 203 | + |
| 204 | + if( !foundvpd ) //serial number not found, default to unavailable |
| 205 | + { |
| 206 | + i_dt->addPropertyString(rootNode, "system-id", "unavailable"); |
| 207 | + } |
| 208 | } |
| 209 | |
| 210 | return errhdl; |
| 211 | -- |
| 212 | 1.8.2.2 |
| 213 | |