summaryrefslogtreecommitdiffstats
path: root/src/usr/scom/DmiScomWorkaround.H
blob: 7c74289858f0ee5107d7a0f99e32d62f9c34edea (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/scom/DmiScomWorkaround.H $                            */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2017                             */
/* [+] 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 __SCOM_DMI_SCOM_WORKAROUND_H
#define __SCOM_DMI_SCOM_WORKAROUND_H

#include "postopchecks.H"
#include <targeting/common/target.H>

#include <memory>

namespace SCOM
{

/**
 * @brief Workaround for SCOM Bug. The workaround
 *        requires a retry of read operations for certain sets
 *        of DMI SCOM registers.
 */
class DmiScomWorkaround: public PostOpRetryCheck
{

public:
    //only one instance is allowed.
    DmiScomWorkaround(const DmiScomWorkaround&)=delete;
    DmiScomWorkaround(DmiScomWorkaround&&)=delete;
    DmiScomWorkaround& operator=(const DmiScomWorkaround&)=delete;
    DmiScomWorkaround& operator=(DmiScomWorkaround&&)=delete;

    virtual ~DmiScomWorkaround() = default;

    /**
     *  @brief Determine if a retry is needed given a device
     *  operation and previous results.
     *
     *  @param[in] i_errl. The error associated with the previous
     *                     scom operation. Not Used for this workaround.
     *  @param[in] i_retryCount. How many retries were made prior
     *                           to this call. This workaround will only
     *                           support 1 retry.
     *  @param[in] i_opType. The scom operation being attempted.
     *                       This workaround is only applicable
     *                       for read operations.
     *  @param[in] i_target. The target of the scom operation.
     *                       The workaround is valid only for
     *                       PROC and DMI targets.
     *  @param[in] i_buffer. The buffer for the scom operation.
     *                       Not used for this workaround.
     *  @param[in] i_buflen. The length of the buffer for the scom
     *                       operation. Not used for this workaround.
     *  @param[in] i_accessType. The access type for the scom operation.
     *                           Not used for this workaround.
     *  @param[in] i_addr. The address for the scom operation. The address
     *                     is used to determine if we need to retry a SCOM
     *                     read.
     *
     *  @return True if a retry should be attempted, False otherwise.
     */
    bool requestRetry(errlHndl_t i_errl,
                      uint32_t i_retryCount,
                      DeviceFW::OperationType i_opType,
                      TARGETING::Target* i_target,
                      void* i_buffer,
                      size_t i_buflen,
                      int64_t i_accessType,
                      uint64_t i_addr
                     ) const override;

  /**
   * @brief Access the single instance of this class.
   */
   static std::shared_ptr<const PostOpRetryCheck> theInstance();

protected:
   DmiScomWorkaround()=default;

   //Unit Test Method Injection Seams.

   /**
    *   @brief Obtain the type of the passed in target.
    *
    *   @param[in] i_target. The target whose type we are trying to determine.
    *   @param[out] o_type.  The type of i_target.
    *
    *   @return True if successful, False otherwise.
    */
   virtual bool getTargetType(TARGETING::Target* i_target,
                              TARGETING::TYPE& o_type) const;

   /**
    *   @brief Obtain the processor model if the passed in target is a
    *   PROC target.
    *
    *   @param[in] i_target. The target from which we would like to determine
    *                        the processor model.
    *   @param[out] o_model. The processor model if successful.
    *
    *   @return True if successful, False otherwise.
    */
   virtual bool getTargetModel(TARGETING::Target* i_target,
                               TARGETING::MODEL& o_model) const;

   /**
    *   @brief Obtain the processor EC Level if the passed in target is a
    *   PROC target.
    *
    *   @param[in] i_target. The target from which we would like to determine
    *                        the processor model.
    *   @param[out] o_ecLevel. The processor model if successful.
    *
    *   @return True if successful, False otherwise.
    */
   virtual bool getTargetECLevel(TARGETING::Target* i_target,
                                 uint8_t& o_ecLevel) const;

   /**
    * @brief - Allows us to create tests where the model is obtained
    *          for every call. The proc model should not be cached for
    *          unit tests in order to allow mocked targets of various
    *          models. In non-test code this method always returns true.
    */
   virtual bool useCachedProcModel() const {return true;}

private:

   static uint64_t cv_model_cumulus;
};

}

#endif
OpenPOWER on IntegriCloud