File: ipmi_mc.h

package info (click to toggle)
openhpi 2.14.1-1.2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 20,380 kB
  • sloc: ansic: 187,087; cpp: 32,188; sh: 10,415; makefile: 4,467; perl: 1,529
file content (226 lines) | stat: -rw-r--r-- 5,887 bytes parent folder | download | duplicates (4)
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
/*
 *
 * Copyright (c) 2003,2004 by FORCE Computers
 * Copyright (c) 2005 by ESO Technologies.
 *
 * Note that this file is based on parts of OpenIPMI
 * written by Corey Minyard <minyard@mvista.com>
 * of MontaVista Software. Corey's code was helpful
 * and many thanks go to him. He gave the permission
 * to use this code in OpenHPI under BSD license.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  This
 * file and program are licensed under a BSD style license.  See
 * the Copying file included with the OpenHPI distribution for
 * full licensing terms.
 *
 * Authors:
 *     Thomas Kanngieser <thomas.kanngieser@fci.com>
 *     Pierre Sangouard  <psangouard@eso-tech.com>
 */

#ifndef dIpmiMc_h
#define dIpmiMc_h


#include <glib.h>
#include <sys/time.h>


#ifndef dIpmiSdr_h
#include "ipmi_sdr.h"
#endif

#ifndef dIpmiAddr_h
#include "ipmi_addr.h"
#endif

#ifndef dIpmiMsg_h
#include "ipmi_msg.h"
#endif

#ifndef dIpmiSensorHotswap_h
#include "ipmi_sensor_hotswap.h"
#endif

#ifndef dIpmiSel_h
#include "ipmi_sel.h"
#endif

#ifndef dIpmiCon_h
#include "ipmi_con.h"
#endif

#ifndef dIpmiMcVendor_h
#include "ipmi_mc_vendor.h"
#endif

#ifndef dIpmiInventory_h
#include "ipmi_inventory.h"
#endif

class cIpmiDomain;
class cIpmiMcThread;


class cIpmiMc : cArray<cIpmiResource>
{
protected:
  cIpmiMcVendor *m_vendor;

  cIpmiAddr      m_addr;

  // If the MC is known to be good in the system, then active is
  // true.  If active is false, that means that there are sensors
  // that refer to this MC, but the MC is not currently in the
  // system.
  bool           m_active;

  cIpmiDomain   *m_domain;

  cIpmiSdrs     *m_sdrs;

  // The sensors that came from the device SDR on this MC.
  GList         *m_sensors_in_my_sdr;

  // The system event log, for querying and storing events.
  cIpmiSel      *m_sel;

  // PICMG version for ATCA boards
  unsigned char m_picmg_major;
  unsigned char m_picmg_minor;

  // The rest is the actual data from the get device id and SDRs.
  unsigned char  m_device_id;

  unsigned char  m_device_revision;

  bool           m_provides_device_sdrs;
  bool           m_device_available;

  unsigned char  m_device_support;
  bool           m_chassis_support;
  bool           m_bridge_support;
  bool           m_ipmb_event_generator_support;
  bool           m_ipmb_event_receiver_support;
  bool           m_fru_inventory_support;
  bool           m_sel_device_support;
  bool           m_sdr_repository_support;
  bool           m_sensor_device_support;

  unsigned char  m_major_fw_revision;
  unsigned char  m_minor_fw_revision;

  unsigned char  m_major_version;
  unsigned char  m_minor_version;

  unsigned int   m_manufacturer_id;
  unsigned short m_product_id;

  unsigned char  m_aux_fw_revision[4];

  bool           m_is_tca_mc;
  bool           m_is_rms_board;

  SaErrorT SendSetEventRcvr( unsigned int addr );

public:
  void AddResource( cIpmiResource *res );
  void RemResource( cIpmiResource *res );
  cIpmiResource *FindResource( const cIpmiEntityPath &ep );
  cIpmiResource *FindResource( cIpmiResource *res );
  cIpmiResource *GetResource( int i );
  int           NumResources() const { return Num(); }
public:
  cIpmiMc( cIpmiDomain *domain, const cIpmiAddr &addr );
  virtual ~cIpmiMc();

  cIpmiDomain *Domain() const { return m_domain; }

  unsigned char DeviceRevision() const { return m_device_revision; }
  unsigned char DeviceSupport() const { return m_device_support; }

  unsigned char MajorFwRevision() const { return m_major_fw_revision; }
  unsigned char MinorFwRevision() const { return m_minor_fw_revision; }

  unsigned char MajorVersion()    const { return m_major_version; }
  unsigned char MinorVersion()    const { return m_minor_version; }

  unsigned int  ManufacturerId()  const { return m_manufacturer_id; }
  unsigned short ProductId()      const { return m_product_id; }

  unsigned char AuxFwRevision( int v ) const
  {
    if ( v >= 0 && v < 4 )
        return m_aux_fw_revision[v];
    else
        return 0;
  }

  const cIpmiAddr &Addr() { return m_addr; }

  void CheckTca();

  bool IsTcaMc() { return m_is_tca_mc; }

  bool &IsRmsBoard() { return m_is_rms_board; }

  void SetSel( bool sel ) { m_sel_device_support = sel; }

  cIpmiSensorHotswap *FindHotswapSensor();

  GList *GetSdrSensors() const
  {
    return m_sensors_in_my_sdr;
  }

  void SetSdrSensors( GList *sensors )
  {
    m_sensors_in_my_sdr = sensors;
  }

  bool ProvidesDeviceSdrs() const { return m_provides_device_sdrs; }
  void SetProvidesDeviceSdrs(bool val) { m_provides_device_sdrs = val; }

  bool &SdrRepositorySupport() { return m_sdr_repository_support; }
  bool SelDeviceSupport() const { return m_sel_device_support; }

  cIpmiSel *Sel() const { return m_sel; }

  bool Cleanup(); // true => it is safe to destroy mc

  SaErrorT HandleNew();
  bool     DeviceDataCompares( const cIpmiMsg &msg ) const;
  int      GetDeviceIdDataFromRsp( const cIpmiMsg &msg );
  void     CheckEventRcvr();
  SaErrorT SendCommand( const cIpmiMsg &msg, cIpmiMsg &rsp_msg,
                        unsigned int lun = 0, int retries = dIpmiDefaultRetries );

  unsigned int GetChannel() const;
  unsigned int GetAddress() const;
  void         SetActive();
  cIpmiSensor *FindSensor( unsigned int lun, unsigned int sensor_id );
  cIpmiRdr *FindRdr( cIpmiRdr *r );

  void SetVendor( cIpmiMcVendor *mv )
  {
    if ( mv )
        m_vendor = mv;
  }

  cIpmiMcVendor *GetVendor()  { return m_vendor; }
protected:
  bool DumpFrus( cIpmiLog &dump, const char *name ) const;
  bool DumpControls( cIpmiLog &dump, const char *name ) const;

public:
  void Dump( cIpmiLog &dump, const char *name ) const;

  // create and populate resources and rdrs
  virtual bool Populate();
};


#endif