1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/fapi2/dimmBadDqBitmapFuncs.C $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
#include <dimmBadDqBitmapFuncs.H>
#include <string.h>
#include <attribute_service.H>
#include <target.H>
#include <errl/errlmanager.H>
using namespace TARGETING;
extern "C"
{
//------------------------------------------------------------------------------
// Utility function to check parameters and get the Bad DQ bitmap
//------------------------------------------------------------------------------
fapi2::ReturnCode dimmBadDqCheckParamGetBitmap( const fapi2::Target
<fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA> & i_fapiTrgt,
const uint8_t i_port,
const uint8_t i_dimm,
const uint8_t i_rank,
TARGETING::TargetHandle_t & o_dimmTrgt,
uint8_t (&o_dqBitmap)[mss::MAX_RANK_PER_DIMM][mss::BAD_DQ_BYTE_COUNT])
{
fapi2::ReturnCode l_rc;
do
{
// Check parameters.
if ( (i_dimm >= mss::MAX_DIMM_PER_PORT) ||
(i_rank >= mss::MAX_RANK_PER_DIMM) )
{
FAPI_ERR( "dimmBadDqCheckParamGetBitmap: Bad parameter. "
"i_dimm:%d i_rank:%d", i_dimm, i_rank );
l_rc = fapi2::FAPI2_RC_INVALID_ATTR_GET;
break;
}
errlHndl_t l_errl = nullptr;
TARGETING::TargetHandle_t l_trgt = nullptr;
l_errl = fapi2::platAttrSvc::getTargetingTarget(i_fapiTrgt, l_trgt);
if ( l_errl )
{
FAPI_ERR( "dimmBadDqCheckParamGetBitmap: Error from "
"getTargetingTarget" );
errlCommit( l_errl, FAPI2_COMP_ID );
l_rc.setPlatDataPtr(reinterpret_cast<void *> (l_errl));
break;
}
// Get the proc model
TARGETING::Target* l_masterProc = nullptr;
TARGETING::targetService().masterProcChipTargetHandle( l_masterProc );
TARGETING::ATTR_MODEL_type l_procModel =
l_masterProc->getAttr<TARGETING::ATTR_MODEL>();
// Get all functional DIMMs
TargetHandleList l_dimmList;
getChildAffinityTargets( l_dimmList, l_trgt, CLASS_NA, TYPE_DIMM );
if ( TARGETING::MODEL_CUMULUS == l_procModel )
{
// Find the DIMM with the correct MBA port/dimm
uint8_t l_port = 0;
uint8_t l_dimm = 0;
for ( auto &dimmTrgt : l_dimmList )
{
// Get and compare the port
l_port = dimmTrgt->getAttr<ATTR_MBA_PORT>();
if ( l_port == i_port )
{
// Get and compare the dimm
l_dimm = dimmTrgt->getAttr<ATTR_MBA_DIMM>();
if ( l_dimm == i_dimm )
{
o_dimmTrgt = dimmTrgt;
// Port and dimm are correct, get the Bad DQ bitmap
l_rc = FAPI_ATTR_GET( fapi2::ATTR_BAD_DQ_BITMAP,
dimmTrgt, o_dqBitmap );
if ( l_rc ) break;
}
}
}
}
else if ( TARGETING::MODEL_NIMBUS == l_procModel )
{
for ( auto &dimmTrgt : l_dimmList )
{
uint32_t l_pos = dimmTrgt->getAttr<ATTR_FAPI_POS>() %
mss::MAX_DIMM_PER_PORT;
if ( l_pos == i_dimm )
{
o_dimmTrgt = dimmTrgt;
// Get the Bad DQ bitmap by querying ATTR_BAD_DQ_BITMAP.
l_rc = FAPI_ATTR_GET( fapi2::ATTR_BAD_DQ_BITMAP,
o_dimmTrgt, o_dqBitmap );
break;
}
}
}
else
{
// Invalid target.
FAPI_ERR( "dimmBadDqCheckParamGetBitmap: Invalid proc model" );
l_rc = fapi2::FAPI2_RC_INVALID_ATTR_GET;
break;
}
if ( l_rc )
{
FAPI_ERR( "dimmBadDqCheckParamGetBitmap: Error getting "
"ATTR_BAD_DQ_BITMAP." );
}
}while(0);
return l_rc;
}
//------------------------------------------------------------------------------
fapi2::ReturnCode p9DimmGetBadDqBitmap( const fapi2::Target
<fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA> & i_fapiTrgt,
const uint8_t i_dimm,
const uint8_t i_rank,
uint8_t (&o_data)[mss::BAD_DQ_BYTE_COUNT],
const uint8_t i_port )
{
FAPI_INF( ">>p9DimmGetBadDqBitmap. %d:%d", i_dimm, i_rank );
fapi2::ReturnCode l_rc;
do
{
uint8_t l_dqBitmap[mss::MAX_RANK_PER_DIMM][mss::BAD_DQ_BYTE_COUNT];
TARGETING::TargetHandle_t l_dimmTrgt = nullptr;
// Check parameters and get Bad Dq Bitmap
l_rc = dimmBadDqCheckParamGetBitmap( i_fapiTrgt, i_port, i_dimm, i_rank,
l_dimmTrgt, l_dqBitmap );
if ( l_rc )
{
FAPI_ERR( "p9DimmGetBadDqBitmap: Error from "
"dimmBadDqCheckParamGetBitmap." );
break;
}
// Write contents of DQ bitmap for specific rank to o_data.
memcpy( o_data, l_dqBitmap[i_rank], mss::BAD_DQ_BYTE_COUNT );
}while(0);
FAPI_INF( "<<p9DimmGetBadDqBitmap" );
return l_rc;
}
//------------------------------------------------------------------------------
fapi2::ReturnCode p9DimmSetBadDqBitmap( const fapi2::Target
<fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA> & i_fapiTrgt,
const uint8_t i_dimm,
const uint8_t i_rank,
const uint8_t (&i_data)[mss::BAD_DQ_BYTE_COUNT],
const uint8_t i_port )
{
FAPI_INF( ">>p9DimmSetBadDqBitmap. %d:%d", i_dimm, i_rank );
fapi2::ReturnCode l_rc;
do
{
// Get the Bad DQ Bitmap by querying ATTR_BAD_DQ_BITMAP.
uint8_t l_dqBitmap[mss::MAX_RANK_PER_DIMM][mss::BAD_DQ_BYTE_COUNT];
TARGETING::TargetHandle_t l_dimmTrgt = nullptr;
// Check parameters and get Bad Dq Bitmap
l_rc = dimmBadDqCheckParamGetBitmap( i_fapiTrgt, i_port, i_dimm, i_rank,
l_dimmTrgt, l_dqBitmap );
if ( l_rc )
{
FAPI_ERR("p9DimmSetBadDqBitmap: Error getting ATTR_BAD_DQ_BITMAP.");
break;
}
// Add the rank bitmap to the DIMM bitmap and write the bitmap.
memcpy( l_dqBitmap[i_rank], i_data, mss::BAD_DQ_BYTE_COUNT );
errlHndl_t l_errl = nullptr;
TARGETING::TargetHandle_t l_trgt = nullptr;
l_errl = fapi2::platAttrSvc::getTargetingTarget(i_fapiTrgt, l_trgt);
if ( l_errl )
{
FAPI_ERR( "p9DimmSetBadDqBitmap: Error from getTargetingTarget" );
break;
}
l_rc = FAPI_ATTR_SET( fapi2::ATTR_BAD_DQ_BITMAP, l_dimmTrgt,
l_dqBitmap );
if ( l_rc )
{
FAPI_ERR("p9DimmSetBadDqBitmap: Error setting ATTR_BAD_DQ_BITMAP.");
}
}while(0);
FAPI_INF( "<<p9DimmSetBadDqBitmap" );
return l_rc;
}
} // extern "C"
|