|
5 | 5 | /* */ |
6 | 6 | /* OpenPOWER HostBoot Project */ |
7 | 7 | /* */ |
8 | | -/* Contributors Listed Below - COPYRIGHT 2015,2016 */ |
| 8 | +/* Contributors Listed Below - COPYRIGHT 2015,2017 */ |
9 | 9 | /* [+] International Business Machines Corp. */ |
10 | 10 | /* */ |
11 | 11 | /* */ |
@@ -84,85 +84,86 @@ class posTraits<fapi2::TARGET_TYPE_PROC_CHIP> |
84 | 84 | template< fapi2::TargetType T, typename TT = posTraits<T> > |
85 | 85 | inline typename TT::pos_type pos(const fapi2::Target<T>& i_target) |
86 | 86 | { |
87 | | - typename TT::pos_type i_pos = 0; |
| 87 | + typename TT::pos_type l_pos = 0; |
88 | 88 |
|
89 | 89 | // Don't use FAPI_TRY as you'll mess up fapi2::current_err which |
90 | 90 | // lmits where this can be used. |
91 | | - if (FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_target, i_pos) != fapi2::FAPI2_RC_SUCCESS) |
| 91 | + if (FAPI_ATTR_GET(fapi2::ATTR_CHIP_UNIT_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS) |
92 | 92 | { |
93 | 93 | goto fapi_try_exit; |
94 | 94 | } |
95 | 95 |
|
96 | | - return i_pos; |
| 96 | + return l_pos; |
97 | 97 |
|
98 | 98 | fapi_try_exit: |
99 | 99 | // If we can't get our unit position, we're in other trouble |
100 | 100 | FAPI_ERR("can't get our chip unit position"); |
101 | | - |
102 | | - // Cronusflex doesn't support Assert. |
103 | | - // Enable once move to dev complete - AAM |
104 | | -#if MOVED_AWAY_FROM_CRONUSFLEX |
105 | 101 | fapi2::Assert(false); |
106 | | -#endif |
107 | 102 | return 0; |
108 | 103 | } |
109 | 104 |
|
110 | 105 | /// |
111 | | -/// @brief Return a DIMM's position from a fapi2 target |
| 106 | +/// @brief Return a processor's position from a fapi2 target |
112 | 107 | /// @param[in] i_target a target representing the target in question |
113 | 108 | /// @return The position relative to the chip |
114 | 109 | /// |
115 | 110 | template<> |
116 | | -inline posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type pos(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) |
| 111 | +inline posTraits<fapi2::TARGET_TYPE_PROC_CHIP>::pos_type pos( |
| 112 | + const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target) |
117 | 113 | { |
118 | | - posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type i_pos = 0; |
| 114 | + posTraits<fapi2::TARGET_TYPE_PROC_CHIP>::pos_type l_pos = 0; |
119 | 115 |
|
120 | | - if (FAPI_ATTR_GET(fapi2::ATTR_POS, i_target, i_pos) != fapi2::FAPI2_RC_SUCCESS) |
| 116 | + if (FAPI_ATTR_GET(fapi2::ATTR_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS) |
121 | 117 | { |
122 | 118 | goto fapi_try_exit; |
123 | 119 | } |
124 | 120 |
|
125 | | - return i_pos; |
| 121 | + return l_pos; |
126 | 122 |
|
127 | 123 | fapi_try_exit: |
128 | 124 | // If we can't get our position, we're in other trouble |
129 | 125 | FAPI_ERR("can't get our position"); |
130 | | -#if MOVED_AWAY_FROM_CRONUSFLEX |
131 | 126 | fapi2::Assert(false); |
132 | | -#endif |
133 | 127 | return 0; |
134 | 128 |
|
135 | 129 | } |
136 | 130 |
|
137 | 131 | /// |
138 | | -/// @brief Return a processor's position from a fapi2 target |
| 132 | +/// @brief Return a DIMM's position from a fapi2 target |
139 | 133 | /// @param[in] i_target a target representing the target in question |
140 | 134 | /// @return The position relative to the chip |
141 | 135 | /// |
142 | 136 | template<> |
143 | | -inline posTraits<fapi2::TARGET_TYPE_PROC_CHIP>::pos_type pos( |
144 | | - const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target) |
| 137 | +inline posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type pos(const fapi2::Target<fapi2::TARGET_TYPE_DIMM>& i_target) |
145 | 138 | { |
146 | | - posTraits<fapi2::TARGET_TYPE_PROC_CHIP>::pos_type i_pos = 0; |
| 139 | + // Proc 0 is DIMM 0-15, proc 2 is 64-79 - 64 is the stride between processors |
| 140 | + constexpr uint64_t DIMM_STRIDE_PER_PROC = 64; |
| 141 | + constexpr uint64_t TOTAL_DIMM = MC_PER_MODULE * MCS_PER_MC * PORTS_PER_MCS * MAX_DIMM_PER_PORT; |
| 142 | + |
| 143 | + posTraits<fapi2::TARGET_TYPE_DIMM>::pos_type l_pos = 0; |
| 144 | + |
| 145 | + // Using fapi2 rather than mss::find as this is pretty low level stuff. |
| 146 | + const auto l_proc_pos = |
| 147 | + mss::template pos(i_target.getParent<fapi2::TARGET_TYPE_MCA>().getParent<fapi2::TARGET_TYPE_PROC_CHIP>()); |
147 | 148 |
|
148 | | - if (FAPI_ATTR_GET(fapi2::ATTR_POS, i_target, i_pos) != fapi2::FAPI2_RC_SUCCESS) |
| 149 | + if (FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS) |
149 | 150 | { |
150 | 151 | goto fapi_try_exit; |
151 | 152 | } |
152 | 153 |
|
153 | | - return i_pos; |
| 154 | + // To get the FAPI_POS to the equivilent of ATTR_POS, we need to normalize the fapi_pos value |
| 155 | + // to the processor (stride across which ever processor we're on) and then add in the delta |
| 156 | + // per processor as ATTR_POS isn't processor relative (delta is the total dimm on a processor) |
| 157 | + return ((l_pos - (l_proc_pos * DIMM_STRIDE_PER_PROC)) % TOTAL_DIMM) + (TOTAL_DIMM * l_proc_pos); |
154 | 158 |
|
155 | 159 | fapi_try_exit: |
156 | 160 | // If we can't get our position, we're in other trouble |
157 | | - FAPI_ERR("can't get our position"); |
158 | | -#if MOVED_AWAY_FROM_CRONUSFLEX |
| 161 | + FAPI_ERR("can't get our fapi position"); |
159 | 162 | fapi2::Assert(false); |
160 | | -#endif |
161 | 163 | return 0; |
162 | 164 |
|
163 | 165 | } |
164 | 166 |
|
165 | | - |
166 | 167 | /// |
167 | 168 | /// @brief Return a target's relative position from a fapi2 target |
168 | 169 | /// @tparam T the fapi2::TargetType |
@@ -234,23 +235,21 @@ relative_pos<fapi2::TARGET_TYPE_MCS>(const fapi2::Target<fapi2::TARGET_TYPE_MCA> |
234 | 235 | template< fapi2::TargetType T, typename TT = posTraits<T> > |
235 | 236 | inline uint32_t fapi_pos(const fapi2::Target<T>& i_target) |
236 | 237 | { |
237 | | - uint32_t i_pos = 0; |
| 238 | + uint32_t l_pos = 0; |
238 | 239 |
|
239 | 240 | // Don't use FAPI_TRY as you'll mess up fapi2::current_err which |
240 | 241 | // lmits where this can be used. |
241 | | - if (FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, i_pos) != fapi2::FAPI2_RC_SUCCESS) |
| 242 | + if (FAPI_ATTR_GET(fapi2::ATTR_FAPI_POS, i_target, l_pos) != fapi2::FAPI2_RC_SUCCESS) |
242 | 243 | { |
243 | 244 | goto fapi_try_exit; |
244 | 245 | } |
245 | 246 |
|
246 | | - return i_pos; |
| 247 | + return l_pos; |
247 | 248 |
|
248 | 249 | fapi_try_exit: |
249 | 250 | // If we can't get our fapi position, we're in other trouble |
250 | 251 | FAPI_ERR("can't get our fapi position"); |
251 | | -#if MOVED_AWAY_FROM_CRONUSFLEX |
252 | 252 | fapi2::Assert(false); |
253 | | -#endif |
254 | 253 | return 0; |
255 | 254 | } |
256 | 255 |
|
|
0 commit comments