summaryrefslogtreecommitdiffstats
path: root/src/sbefw/sbeFFDC.C
blob: 3a8e24e7b99a69ff55495ea54d85e6e36d97c230 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/sbefw/sbeFFDC.C $                                         */
/*                                                                        */
/* OpenPOWER sbe Project                                                  */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 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                                                     */
#include "sbefifo.H"
#include "sbetrace.H"
#include "sbe_sp_intf.H"
#include "sbeFifoMsgUtils.H"
#include "sberegaccess.H"
#include "sbeFFDC.H"

/*
 * @brief sendOverFIFO - method to pack and send SBE internal FFDC
 *                       only if isSendInternalFFDCSet() is true
 *                       over FIFO interface
 * @param[in] i_primStatus   - Primary status of Chip op
 * @param[in] i_secStatus    - Secondary status of Chip op
 * @param[in] i_fieldsConfig - bitmap indicating the field
 *                             to be sent in FFDC
 * @param[out] o_bytesSent -number of bytes sent
 *
 * @param[in] i_skipffdcBitCheck - Boolean to indicate whether
 *                                 ffdc bit should be checked or not.
 *                                 By default it is false.
 * @return - SBE secondary RC
 */
uint32_t SbeFFDCPackage::sendOverFIFO(uint32_t i_primStatus,
                                      uint32_t i_secStatus,
                                      uint32_t i_fieldsConfig,
                                      uint32_t &o_bytesSent,
                                      bool i_skipffdcBitCheck)
{
    #define SBE_FUNC "sendOverFIFO"
    SBE_ENTER(SBE_FUNC);
    uint32_t rc = SBE_SEC_OPERATION_SUCCESSFUL;
    uint32_t length = 0;

    do
    {
        //reset sent bytes
        o_bytesSent = 0;

        //check if SBE internal FFDC should be generated
        if(!i_skipffdcBitCheck &&
           (SbeRegAccess::theSbeRegAccess().isSendInternalFFDCSet() 
            == false))
        {
            SBE_INFO(SBE_FUNC" isSendInternalFFDCSet()=false, "
                    "not generating SBE InternalFFDC");
            rc = SBE_SEC_OPERATION_SUCCESSFUL;
            break;
        }

        // update the primary and secondary status
        iv_sbeFFDCDataHeader.primaryStatus = i_primStatus;
        iv_sbeFFDCDataHeader.secondaryStatus = i_secStatus;
        //Update the user data header with dump fields configuration
        iv_sbeFFDCDataHeader.dumpFields.set(i_fieldsConfig);
        iv_sbeFFDCHeader.lenInWords = (sizeof(sbeResponseFfdc_t) +
                                       sizeof(sbeFFDCDataHeader_t))
                                       /sizeof(uint32_t);
        //Update the length in ffdc package header base on required fields
        for(auto &sbeFFDCUserData:sbeFFDCUserDataArray)
        {
            if(sbeFFDCUserData.userDataId.fieldId & i_fieldsConfig)
            {
                iv_sbeFFDCHeader.lenInWords +=
                                        (sbeFFDCUserData.userDataId.fieldLen +
                                         sizeof(sbeFFDCUserDataIdentifier_t))
                                         /sizeof(uint32_t);
            }
        }

        //Send FFDC package header
        length = sizeof(iv_sbeFFDCHeader) / sizeof(uint32_t);
        rc = sbeDownFifoEnq_mult(length,
                                 (uint32_t *)(&(iv_sbeFFDCHeader)));
        if( rc!= SBE_SEC_OPERATION_SUCCESSFUL)
        {
            break;
        }
        o_bytesSent += length;

        //Send FFDC user data header
        length = sizeof(iv_sbeFFDCDataHeader) / sizeof(uint32_t);
        rc = sbeDownFifoEnq_mult(length,
                                 (uint32_t *)(&(iv_sbeFFDCDataHeader)));
        if( rc!= SBE_SEC_OPERATION_SUCCESSFUL)
        {
            break;
        }
        o_bytesSent += length;

        //Send FFDC user data blobs
        for(auto &sbeFFDCUserData:sbeFFDCUserDataArray)
        {
            if(sbeFFDCUserData.userDataId.fieldId & i_fieldsConfig)
            {
                //Send User data identifer and length
                length = sizeof(sbeFFDCUserDataIdentifier_t) / sizeof(uint32_t);
                rc = sbeDownFifoEnq_mult(length,
                                    (uint32_t*)&(sbeFFDCUserData.userDataId));
                if( rc!= SBE_SEC_OPERATION_SUCCESSFUL)
                {
                    break;
                }
                o_bytesSent += length;

                //Send User data
                length = sbeFFDCUserData.userDataId.fieldLen / sizeof(uint32_t);
                rc = sbeDownFifoEnq_mult(length,
                                        (uint32_t*)sbeFFDCUserData.userDataPtr);
                if( rc!= SBE_SEC_OPERATION_SUCCESSFUL)
                {
                    break;
                }
                o_bytesSent += length;
            }
        }

        SBE_INFO(SBE_FUNC "Number of words sent [%d]", o_bytesSent);
    } while(false);

    SBE_EXIT(SBE_FUNC);
    return rc;
    #undef SBE_FUNC
}
OpenPOWER on IntegriCloud