summaryrefslogtreecommitdiffstats
path: root/src/usr/sbeio/sbe_fifodd.H
blob: 657210560ad1f8a4f71434eccf9a3a89417ac1f4 (plain)
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/sbeio/sbe_fifodd.H $                                  */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2012,2016                        */
/* [+] 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                                                     */

#ifndef __SBE_FIFODD_H
#define __SBE_FIFODD_H

/**
 * @file sbe_fifodd.H
 * @brief SBE service provider declariation
 */

#include <stdint.h>
#include <builtins.h>
#include <sys/time.h>

#include <errl/errlentry.H>

namespace SBEIO
{

//-----------------------------------------------------------------------------
//  Interfaces to the SBE FIFO device driver to be used by clients
//  within this component.
//-----------------------------------------------------------------------------

    /**
     * @brief enums for SBE command class
     */
    enum fifoCommandClass
    {
        SBE_FIFO_CLASS_UNKNOWN             = 0,
        SBE_FIFO_CLASS_IPL_CONTROL         = 0xA1,
        SBE_FIFO_CLASS_SCOM_ACCESS         = 0xA2,
        SBE_FIFO_CLASS_RING_ACCESS         = 0xA3,
        SBE_FIFO_CLASS_MEMORY_ACCESS       = 0xA4,
        SBE_FIFO_CLASS_REGISTER_ACCESS     = 0xA5,
        SBE_FIFO_CLASS_ARRAY_ACCESS        = 0xA6,
        SBE_FIFO_CLASS_INSTRUCTION_CONTROL = 0xA7,
        SBE_FIFO_CLASS_GENERIC_MESSAGE     = 0xA8,
        SBE_FIFO_CLASS_MPIPL_COMMANDS      = 0xA9,
    };

    /**
     * @brief enums for FIFO SCOM Access Messages
     */
    enum fifoScomAccessMessage
    {
        SBE_FIFO_CMD_GET_SCOM            = 0x01,
        SBE_FIFO_CMD_PUT_SCOM            = 0x02,
        SBE_FIFO_CMD_MODIFY_SCOM         = 0x03,
        SBE_FIFO_CMD_PUT_SCOM_UNDER_MASK = 0x04,
    };

    /**
     * @brief Struct for FIFO Get SCOM request
     *
     */
    struct fifoGetScomRequest
    {
        uint32_t wordCnt;
        uint16_t reserved;
        uint8_t  commandClass;
        uint8_t  command;
        uint64_t address;  // Register Address (0..31) + (32..63)
        fifoGetScomRequest() :
            wordCnt(4),
            reserved(0)
        {
        }
    } PACKED;

    /**
     * @brief Struct for FIFO Put SCOM request
     *
     */
    struct fifoPutScomRequest
    {
        uint32_t wordCnt;
        uint16_t reserved;
        uint8_t  commandClass;
        uint8_t  command;
        uint64_t address;     // Register Address (0..31) + (32..63)
        uint64_t data;        // Data (0..31) + (32..63)
        fifoPutScomRequest() :
            wordCnt(6),
            reserved(0),
            data(0)
        {
        }
    } PACKED;

    /**
     * @brief Struct for FIFO Put SCOM Under Mask request
     *
     */
    struct fifoPutScomUnderMaskRequest
    {
        uint32_t wordCnt;
        uint16_t reserved;
        uint8_t  commandClass;
        uint8_t  command;
        uint64_t address;     // Register Address (0..31) + (32..63)
        uint64_t data;        // Data (0..31) + (32..63)
        uint64_t mask;        // Mask Data (0..31) + (32..63)
        fifoPutScomUnderMaskRequest() :
            wordCnt(8),
            reserved(0),
            data(0),
            mask(0)
        {
        }
    } PACKED;

    /**
     * @brief Struct for FIFO status
     *
     */
    struct statusHeader
    {
        uint16_t  magic;     // set to 0xC0DE
        uint8_t   commandClass;
        uint8_t   command;
        uint16_t  primaryStatus;
        uint16_t  secondaryStatus;
    } PACKED;
    const uint16_t FIFO_STATUS_MAGIC = 0xC0DE;

    /**
     * @brief Struct for FIFO Put SCOM and Put SCOM under mask response
     *
     * The actual number of returned words varies based on whether there was
     * an error.
     */
    struct fifoPutScomResponse
    {
        statusHeader status;
        uint32_t     pcbpibStatus;    // only present on errors
        uint32_t     status_distance; //will be last word received
        fifoPutScomResponse() {}
    } PACKED;

    /**
     * @brief Struct for FIFO Get SCOM response
     *
     * The actual number of returned words varies based on whether there was
     * an error.
     */
    struct fifoGetScomResponse
    {
        uint64_t     data;          // Data (0..31) + (32..63)
        statusHeader status;
        uint32_t     pcbpibStatus;    // only present on errors
        uint32_t     status_distance; //will be last word received
        fifoGetScomResponse() {}
    } PACKED;

    /**
     * @brief enums for primary SBE response
     *
    */
    enum sbePrimResponse
    {
        FIFO_PRI_OPERATION_SUCCESSFUL        = 0x00,
        FIFO_PRI_INVALID_COMMAND             = 0x01,
        FIFO_PRI_INVALID_DATA                = 0x02,
        FIFO_PRI_SEQUENCE_ERROR              = 0x03,
        FIFO_PRI_INTERNAL_ERROR              = 0x04,
        FIFO_PRI_GENERIC_EXECUTION_FAILURE   = 0xFE,
    };

    /**
     * @brief enums for secondary SBE response
     *
    */
    enum sbeSecondaryResponse
    {
        FIFO_SEC_OPERATION_SUCCESSFUL              = 0x00,
        FIFO_SEC_COMMAND_CLASS_NOT_SUPPORTED       = 0x01,
        FIFO_SEC_COMMAND_NOT_SUPPORTED             = 0x02,
        FIFO_SEC_INVALID_ADDRESS_PASSED            = 0x03,
        FIFO_SEC_INVALID_TARGET_TYPE_PASSED        = 0x04,
        FIFO_SEC_INVALID_TARGET_ID_PASSED          = 0x05,
        FIFO_SEC_SPECIFIED_TARGET_NOT_PRESENT      = 0x06,
        FIFO_SEC_SPECIFIED_TARGET_NOT_FUNCTIONAL   = 0x07,
        FIFO_SEC_COMMAND_NOT_ALLOWED_IN_THIS_STATE = 0x08,
        FIFO_SEC_FUNCTIONALITY_NOT_SUPPORTED       = 0x09,
        FIFO_SEC_GENERIC_FAILURE_IN_EXECUTION      = 0x0A,
        FIFO_SEC_BACKLISTED_ACCESS                 = 0x0B,
        FIFO_SEC_OS_FAILURE                        = 0x0C,
        FIFO_SEC_FIFO_ACCESS_FAILURE               = 0x0D,
        FIFO_SEC_INSUFFICIENT_DATA_PASSED          = 0x0E,
        FIFO_SEC_EXCESS_DATA_PASSED                = 0x0F,
    };

    /**
     * @Brief perform SBE FIFO chip-op
     *
     * @param[in]  i_target        Target to access
     * @param[in]  i_pFifoRequest  Pointer to request
     * @param[in]  i_pFifoResponse Pointer to response
     * @param[in]  i_responseSize  Size of response in bytes
     *
     * @return errlHndl_t Error log handle on failure.
     */
    errlHndl_t performFifoChipOp(TARGETING::Target * i_target,
                                 uint32_t * i_pFifoRequest,
                                 uint32_t * i_pFifoResponse,
                                 uint32_t   i_responseSize);

//-----------------------------------------------------------------------------
// Local definitions for the device driver
//-----------------------------------------------------------------------------

    /**
     * @brief send a request via SBE FIFO
     *
     * @param[in]  i_target         Target to access
     * @param[in]  i_pFifoRequest   Pointer to FIFO request.
     *                              First word has count of unit32_t words.
     * @return errlHndl_t Error log handle on failure.
     */
    errlHndl_t writeRequest(TARGETING::Target * i_target,
                            uint32_t * i_pFifoRequest);

    /**
     * @brief read the response via SBE FIFO
     *
     * @param[in]  i_target         Target to access
     * @param[in]  i_pFifoRequest   Pointer to FIFO request.
     * @param[out] o_pFifoResponse  Pointer to FIFO response.
     * @param[in]  i_responseSize   Size of response buffer in bytes.
     * @return errlHndl_t Error log handle on failure.
     */
    errlHndl_t readResponse(TARGETING::Target * i_target,
                            uint32_t * i_pFifoRequest,
                            uint32_t * o_pFifoResponse,
                            uint32_t   i_responseSize);

    /**
     * @brief poll until uplift Fifo has room to write into
     *
     * @param[in]  i_target         Target to access
     * @return errlHndl_t Error log handle on failure.
     */
    errlHndl_t waitUpFifoReady(TARGETING::Target * i_target);

    /**
     * @brief poll until downlift Fifo has a value to read
     *
     * @param[in]  i_target         Target to access
     * @return errlHndl_t Error log handle on failure.
     */
    errlHndl_t waitDnFifoReady(TARGETING::Target * i_target);

    /**
     * @brief encapulate FSI read
     *
     * @param[in]  i_target         Target to access
     * @param[in]  i_addr           FSI addressd
     * @param[out] o_pData          Pointer to receive data
     * @return errlHndl_t Error log handle on failure.
     */
    errlHndl_t readFsi(TARGETING::Target * i_target,
                         uint64_t   i_addr,
                         uint32_t * o_pData);
    /**
     * @brief encapulate FSI write
     *
     * @param[in]  i_target         Target to access
     * @param[in]  i_addr           FSI addressd
     * @param[in]  i_pData          Pointer to receive data
     * @return errlHndl_t Error log handle on failure.
     */
    errlHndl_t writeFsi(TARGETING::Target * i_target,
                         uint64_t   i_addr,
                         uint32_t * i_pData);

    /**
     * @brief SBE FIFO FSI register addresses
     */
    enum fifoRegisterAddress
    {
        SBE_FIFO_UPFIFO_DATA_IN    = 0x00002400,
        SBE_FIFO_UPFIFO_STATUS     = 0x00002404,
        SBE_FIFO_UPFIFO_SIG_EOT    = 0x00002408,
        SBE_FIFO_UPFIFO_REQ_RESET  = 0x0000240C,
        SBE_FIFO_DNFIFO_DATA_OUT   = 0x00002440,
        SBE_FIFO_DNFIFO_STATUS     = 0x00002444,
        SBE_FIFO_DNFIFO_RESET      = 0x00002450,
        SBE_FIFO_DNFIFO_ACK_EOT    = 0x00002454,
    };

    enum sbeFifoUpstreamStatus
    {
        // Reserved
        UPFIFO_STATUS_RESERVED0 =0xC0000000,
        // Parity Error: dequeuing operation has detected a data parity error
        UPFIFO_STATUS_PARITY_ERROR =0x20000000,
        // Reserved
        UPFIFO_STATUS_RESERVED3 =0x1C000000,
        // External Service Processor (SP) is requesting a FIFO reset
        UPFIFO_STATUS_REQ_RESET_FR_SP =0x02000000,
        // SBE is requesting a FIFO reset through downstream path
        UPFIFO_STATUS_REQ_RESET_FR_SBE =0x01000000,
        // A fifo entry has been dequeued with set EOT flag
        UPFIFO_STATUS_DEQUEUED_EOT_FLAG =0x00800000,
        // Reserved
        UPFIFO_STATUS_RESERVED9 =0x00400000,
        // Upstream FIFO is full
        UPFIFO_STATUS_FIFO_FULL =0x00200000,
        // Upstream FIFO is empty
        UPFIFO_STATUS_FIFO_EMPTY =0x00100000,
        // Number of entries currently in FIFO
        UPFIFO_STATUS_FIFO_ENTRY_COUNT =0x000F0000,
        // Valid flags of entries currently in FIFO
        UPFIFO_STATUS_FIFO_VALID_FLAGS =0x0000FF00,
        // EOT flags of entries currently in FIFO
        UPFIFO_STATUS_FIFO_EOT_FLAGS =0x000000FF,
    };

    enum sbeUpstreamEot
    {
        FSB_UPFIFO_SIG_EOT =0x80000000,
    };

    enum sbeFifoReqUpstreamFifoReset
    {
        FSB_UPFIFO_REQ_RESET =0x80000000,
    };

    enum sbeFifoDownstreamStatus
    {
        // Reserved
        DNFIFO_STATUS_RESERVED0 =0xC0000000,
        // Parity Error: dequeuing operation has detected a data parity error
        DNFIFO_STATUS_PARITY_ERROR =0x20000000,
        // Reserved
        DNFIFO_STATUS_RESERVED3 =0x1C000000,
        // SBE is requesting a FIFO reset
        DNFIFO_STATUS_REQ_RESET_FR_SP =0x02000000,
        // Service Processor (SP) is requesting a FIFO reset
        // through downstream path
        DNFIFO_STATUS_REQ_RESET_FR_SBE =0x01000000,
        // A fifo entry has been dequeued with set EOT flag
        DNFIFO_STATUS_DEQUEUED_EOT_FLAG =0x00800000,
        // Reserved
        DNFIFO_STATUS_RESERVED9 =0x00400000,
        // Downstream FIFO is full
        DNFIFO_STATUS_FIFO_FULL =0x00200000,
        // Downstream FIFO is empty
        DNFIFO_STATUS_FIFO_EMPTY =0x00100000,
        // Number of currently hold entries
        DNFIFO_STATUS_FIFO_ENTRY_COUNT =0x000F0000,
        // Valid flags of ALL currently hold entries
        DNFIFO_STATUS_FIFO_VALID_FLAGS =0x0000FF00,
        // EOT flags of ALL currently hold entries
        DNFIFO_STATUS_FIFO_EOT_FLAGS =0x000000FF,
    };

    enum sbeFifoReqDownstreamFifoReset
    {
        FSB_DNFIFO_REQ_RESET =0x80000000,
    };

    enum sbeDownstreamEot
    {
        FSB_DNFIFO_ACK_EOT =0x80000000,
    };

    enum { MAX_UP_FIFO_TIMEOUT_NS = 10*NS_PER_MSEC }; //=10ms

}

#endif
OpenPOWER on IntegriCloud