1 /****************************************************************************
2 Copyright (c) 2008, Dell Inc
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 - Redistributions of source code must retain the above copyright notice,
7 this list of conditions and the following disclaimer.
8 
9 - Redistributions in binary form must reproduce the above copyright notice,
10 this list of conditions and the following disclaimer in the documentation
11 and/or other materials provided with the distribution.
12 - Neither the name of Dell Inc nor the names of its contributors
13 may be used to endorse or promote products derived from this software
14 without specific prior written permission.
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 POSSIBILITY OF SUCH DAMAGE.
26 
27 
28 *****************************************************************************/
29 #ifndef IPMI_DELLOEM_H
30 #define IPMI_DELLOEM_H
31 
32 #if HAVE_CONFIG_H
33 # include <config.h>
34 #endif
35 
36 #pragma pack(1)
37 
38 #define MIN(a,b) ((a) < (b) ? (a) : (b))
39 #define MAX(a,b) ((a) > (b) ? (a) : (b))
40 
41 
42 /* Dell selector for LCD control - get and set unless specified */
43 #define IPMI_DELL_LCD_STRING_SELECTOR       0xC1        /* RW get/set the user string */
44 #define IPMI_DELL_LCD_CONFIG_SELECTOR       0xC2        /* RW set to user/default/none */
45 #define IPMI_DELL_LCD_GET_CAPS_SELECTOR     0xCF        /* RO use when available*/
46 #define IPMI_DELL_LCD_STRINGEX_SELECTOR     0xD0        /* RW get/set the user string use first when available*/
47 #define IPMI_DELL_LCD_STATUS_SELECTOR       0xE7        /* LCD string when config set to default.*/
48 #define IPMI_DELL_PLATFORM_MODEL_NAME_SELECTOR 0xD1    /* LCD string when config set to default.*/
49 
50 /* Dell defines for picking which string to use */
51 #define IPMI_DELL_LCD_CONFIG_USER_DEFINED   0x00 /* use string set by user*/
52 #define IPMI_DELL_LCD_CONFIG_DEFAULT        0x01 /* use platform model name*/
53 #define IPMI_DELL_LCD_CONFIG_NONE           0x02 /* blank*/
54 #define IPMI_DELL_LCD_iDRAC_IPV4ADRESS      0x04 /* use string set by user*/
55 #define IPMI_DELL_LCD_IDRAC_MAC_ADDRESS     0x08 /* use platform model name*/
56 #define IPMI_DELL_LCD_OS_SYSTEM_NAME        0x10 /* blank*/
57 
58 #define IPMI_DELL_LCD_SERVICE_TAG           0x20  /* use string set by user*/
59 #define IPMI_DELL_LCD_iDRAC_IPV6ADRESS      0x40  /* use string set by user*/
60 #define IPMI_DELL_LCD_AMBEINT_TEMP          0x80  /* use platform model name*/
61 #define IPMI_DELL_LCD_SYSTEM_WATTS          0x100 /* blank*/
62 #define IPMI_DELL_LCD_ASSET_TAG             0x200
63 
64 #define IPMI_DELL_LCD_ERROR_DISP_SEL        0x01  /* use platform model name*/
65 #define IPMI_DELL_LCD_ERROR_DISP_VERBOSE    0x02  /* blank*/
66 
67 #define IPMI_DELL_IDRAC_VALIDATOR           0xDD
68 #define IPMI_DELL_POWER_CAP_STATUS          0xBA
69 #define IPMI_DELL_AVG_POWER_CONSMP_HST 	0xEB
70 #define IPMI_DELL_PEAK_POWER_CONSMP_HST 0xEC
71 #define SYSTEM_BOARD_SYSTEM_LEVEL_SENSOR_NUM 0x98
72 
73 #define	IDRAC_11G					1
74 #define	IDRAC_12G					2
75 #define	IDRAC_13G					3
76 // Return Error code for license
77 #define	LICENSE_NOT_SUPPORTED		0x6F
78 #define	VFL_NOT_LICENSED			0x33
79 #define btuphr              0x01
80 #define watt                0x00
81 #define IPMI_DELL_POWER_CAP 0xEA
82 #define percent             0x03
83 
84 /* Not on all Dell servers. If there, use it.*/
85 typedef struct _tag_ipmi_dell_lcd_caps
86 {
87        uint8_t parm_rev;                                       /* 0x11 for IPMI 2.0 */
88         uint8_t char_set;                                       /* always 1 for printable ASCII 0x20-0x7E */
89    uint8_t number_lines;                           /* 0-4, 1 for 9G. 10G tbd */
90    uint8_t max_chars[4];                           /* 62 for triathlon, 0 if not present (glacier) */
91                                                                              /* [0] is max chars for line 1 */
92 }IPMI_DELL_LCD_CAPS;
93 
94 #define IPMI_DELL_LCD_STRING_LENGTH_MAX 62      /* Valid for 9G. Glacier ??. */
95 #define IPMI_DELL_LCD_STRING1_SIZE      14
96 #define IPMI_DELL_LCD_STRINGN_SIZE      16
97 
98 /* vFlash subcommands */
99 #define IPMI_GET_EXT_SD_CARD_INFO 0xA4
100 
101 
102 typedef struct _tag_ipmi_dell_lcd_string
103 {
104      uint8_t parm_rev;                       /* 0x11 for IPMI 2.0 */
105      uint8_t data_block_selector;            /* 16-byte data block number to access, 0 based.*/
106      union
107      {
108           struct
109           {
110                 uint8_t encoding : 4;                     /* 0 is printable ASCII 7-bit */
111                 uint8_t length;                           /* 0 to max chars from lcd caps */
112                 uint8_t data[IPMI_DELL_LCD_STRING1_SIZE]; /* not zero terminated.  */
113           }selector_0_string;
114           uint8_t selector_n_data[IPMI_DELL_LCD_STRINGN_SIZE];
115      }lcd_string;
116 } __attribute__ ((packed)) IPMI_DELL_LCD_STRING;
117 
118 /* Only found on servers with more than 1 line. Use if available. */
119 typedef struct _tag_ipmi_dell_lcd_stringex
120 {
121       uint8_t parm_rev;                       /* 0x11 for IPMI 2.0 */
122       uint8_t line_number;                    /* LCD line number 1 to 4 */
123       uint8_t data_block_selector;            /* 16-byte data block number to access, 0 based.*/
124       union
125       {
126            struct
127            {
128                 uint8_t encoding : 4;                     /* 0 is printable ASCII 7-bit */
129                 uint8_t length;                           /* 0 to max chars from lcd caps */
130                 uint8_t data[IPMI_DELL_LCD_STRING1_SIZE]; /* not zero terminated.  */
131            } selector_0_string;
132            uint8_t selector_n_data[IPMI_DELL_LCD_STRINGN_SIZE];
133    } lcd_string;
134 } __attribute__ ((packed)) IPMI_DELL_LCD_STRINGEX;
135 
136 
137 typedef struct _lcd_status
138 {
139       char parametersel;
140       char vKVM_status;
141       char lock_status;
142       char Resv1;
143       char Resv;
144 } __attribute__ ((packed)) LCD_STATUS;
145 
146 typedef struct _lcd_mode
147 {
148     uint8_t parametersel;
149     uint32_t lcdmode;
150     uint16_t lcdquallifier;
151     uint32_t capabilites;
152     uint8_t error_display;
153     uint8_t Resv;
154 } __attribute__ ((packed)) LCD_MODE;
155 
156 #define PARAM_REV_OFFSET                    (uint8_t)(0x1)
157 #define VIRTUAL_MAC_OFFSET                  (uint8_t)(0x1)
158 
159 #define LOM_MACTYPE_ETHERNET 0
160 #define LOM_MACTYPE_ISCSI 1
161 #define LOM_MACTYPE_RESERVED 3
162 
163 #define LOM_ETHERNET_ENABLED 0
164 #define LOM_ETHERNET_DISABLED 1
165 #define LOM_ETHERNET_PLAYINGDEAD 2
166 #define LOM_ETHERNET_RESERVED 3
167 
168 #define LOM_ACTIVE 1
169 #define LOM_INACTIVE 0
170 
171 #define MACADDRESSLENGH 6
172 #define MAX_LOM 8
173 
174 
175 #define EMB_NIC_MAC_ADDRESS_11G     (uint8_t)(0xDA)
176 #define EMB_NIC_MAC_ADDRESS_9G_10G  (uint8_t)(0xCB)
177 
178 #define IMC_IDRAC_10G               (uint8_t) (0x08)
179 #define IMC_CMC                     (uint8_t) (0x09)
180 #define IMC_IDRAC_11G_MONOLITHIC    (uint8_t) (0x0A)
181 #define IMC_IDRAC_11G_MODULAR       (uint8_t) (0x0B)
182 #define IMC_UNUSED                  (uint8_t) (0x0C)
183 #define IMC_MASER_LITE_BMC          (uint8_t) (0x0D)
184 #define IMC_MASER_LITE_NU 			(uint8_t) (0x0E)
185 #define IMC_IDRAC_12G_MONOLITHIC 	(uint8_t) (0x10)
186 #define IMC_IDRAC_12G_MODULAR 		(uint8_t) (0x11)
187 
188 #define IMC_IDRAC_13G_MONOLITHIC 	(uint8_t) (0x20)
189 #define IMC_IDRAC_13G_MODULAR 		(uint8_t) (0x21)
190 #define IMC_IDRAC_13G_DCS			(uint8_t) (0x22)
191 
192 
193 typedef struct
194 {
195      unsigned int BladSlotNumber : 4;
196      unsigned int MacType : 2;
197      unsigned int EthernetStatus : 2;
198      unsigned int NICNumber : 5;
199      unsigned int Reserved : 3;
200      uint8_t MacAddressByte[MACADDRESSLENGH];
201 } LOMMacAddressType;
202 
203 
204 typedef struct
205 {
206      LOMMacAddressType LOMMacAddress [MAX_LOM];
207 } EmbeddedNICMacAddressType;
208 
209 typedef struct
210 {
211      uint8_t MacAddressByte[MACADDRESSLENGH];
212 } MacAddressType;
213 
214 typedef struct
215 {
216    MacAddressType MacAddress [MAX_LOM];
217 } EmbeddedNICMacAddressType_10G;
218 
219 
220 
221 #define TRANSPORT_NETFN             (uint8_t)(0xc)
222 #define GET_LAN_PARAM_CMD           (uint8_t)(0x02)
223 #define MAC_ADDR_PARAM              (uint8_t)(0x05)
224 #define LAN_CHANNEL_NUMBER          (uint8_t)(0x01)
225 
226 #define IDRAC_NIC_NUMBER            (uint8_t)(0x8)
227 
228 #define TOTAL_N0_NICS_INDEX         (uint8_t)(0x1)
229 
230 
231 // 12g supported
232 #define SET_NIC_SELECTION_12G_CMD       (uint8_t)(0x28)
233 #define GET_NIC_SELECTION_12G_CMD       (uint8_t)(0x29)
234 
235 // 11g supported
236 #define SET_NIC_SELECTION_CMD       (uint8_t)(0x24)
237 #define GET_NIC_SELECTION_CMD       (uint8_t)(0x25)
238 #define GET_ACTIVE_NIC_CMD          (uint8_t)(0xc1)
239 #define POWER_EFFICENCY_CMD     		(uint8_t)(0xc0)
240 #define SERVER_POWER_CONSUMPTION_CMD   	(uint8_t)(0x8F)
241 
242 #define POWER_SUPPLY_INFO           (uint8_t)(0xb0)
243 #define IPMI_ENTITY_ID_POWER_SUPPLY (uint8_t)(0x0a)
244 #define SENSOR_STATE_STR_SIZE       (uint8_t)(64)
245 #define SENSOR_NAME_STR_SIZE        (uint8_t)(64)
246 
247 #define GET_PWRMGMT_INFO_CMD	    (uint8_t)(0x9C)
248 #define CLEAR_PWRMGMT_INFO_CMD	    (uint8_t)(0x9D)
249 #define GET_PWR_HEADROOM_CMD	    (uint8_t)(0xBB)
250 #define GET_PWR_CONSUMPTION_CMD	    (uint8_t)(0xB3)
251 #define	GET_FRONT_PANEL_INFO_CMD		(uint8_t)0xb5
252 
253 
254 typedef struct _ipmi_power_monitor
255 {
256     uint32_t        cumStartTime;
257     uint32_t        cumReading;
258     uint32_t        maxPeakStartTime;
259     uint32_t        ampPeakTime;
260     uint16_t        ampReading;
261     uint32_t        wattPeakTime;
262     uint16_t        wattReading;
263 } __attribute__ ((packed)) IPMI_POWER_MONITOR;
264 
265 
266 #define MAX_POWER_FW_VERSION 8
267 
268 typedef struct _ipmi_power_supply_infoo
269 {
270 	/*No param_rev it is not a System Information Command */
271 	uint16_t ratedWatts;
272 	uint16_t ratedAmps;
273 	uint16_t ratedVolts;
274 	uint32_t vendorid;
275     uint8_t FrimwareVersion[MAX_POWER_FW_VERSION];
276 	uint8_t  Powersupplytype;
277 	uint16_t ratedDCWatts;
278 	uint16_t Resv;
279 
280 } __attribute__ ((packed)) IPMI_POWER_SUPPLY_INFO;
281 
282 
283 typedef struct ipmi_power_consumption_data
284 {
285     uint16_t actualpowerconsumption;
286     uint16_t powerthreshold;
287     uint16_t warningthreshold;
288     uint8_t throttlestate;
289     uint16_t maxpowerconsumption;
290     uint16_t throttlepowerconsumption;
291     uint16_t Resv;
292 } __attribute__ ((packed)) IPMI_POWER_CONSUMPTION_DATA;
293 
294 
295 typedef struct ipmi_inst_power_consumption_data
296 {
297     uint16_t instanpowerconsumption;
298     uint16_t instanApms;
299     uint16_t resv1;
300     uint8_t resv;
301 } __attribute__ ((packed)) IPMI_INST_POWER_CONSUMPTION_DATA;
302 
303 typedef struct _ipmi_avgpower_consump_histroy
304 {
305     uint8_t parameterselector;
306     uint16_t lastminutepower;
307     uint16_t lasthourpower;
308     uint16_t lastdaypower;
309     uint16_t lastweakpower;
310 
311 } __attribute__ ((packed)) IPMI_AVGPOWER_CONSUMP_HISTORY;
312 
313 typedef struct _ipmi_power_consump_histroy
314 {
315     uint8_t parameterselector;
316     uint16_t lastminutepower;
317     uint16_t lasthourpower;
318     uint16_t lastdaypower;
319     uint16_t lastweakpower;
320     uint32_t lastminutepowertime;
321     uint32_t lasthourpowertime;
322     uint32_t lastdaypowertime;
323     uint32_t lastweekpowertime;
324 } __attribute__ ((packed)) IPMI_POWER_CONSUMP_HISTORY;
325 
326 
327 typedef struct _ipmi_delloem_power_cap
328 {
329     uint8_t parameterselector;
330     uint16_t PowerCap;
331     uint8_t unit;
332     uint16_t MaximumPowerConsmp;
333     uint16_t MinimumPowerConsmp;
334     uint16_t totalnumpowersupp;
335     uint16_t AvailablePower ;
336     uint16_t SystemThrottling;
337     uint16_t Resv;
338 } __attribute__ ((packed)) IPMI_POWER_CAP;
339 
340 typedef struct _power_headroom
341 {
342     uint16_t instheadroom;
343     uint16_t peakheadroom;
344 } __attribute__ ((packed)) POWER_HEADROOM;
345 
346 struct vFlashstr {
347 	uint8_t val;
348 	const char * str;
349 };
350 typedef struct ipmi_vFlash_extended_info
351 {
352 	uint8_t  vflashcompcode;
353 	uint8_t  sdcardstatus;
354 	uint32_t sdcardsize;
355 	uint32_t sdcardavailsize;
356 	uint8_t  bootpartion;
357 	uint8_t  Resv;
358 } __attribute__ ((packed)) IPMI_DELL_SDCARD_INFO;
359 
360 
361 typedef struct _SensorReadingType
362 {
363     uint8_t sensorReading;
364     uint8_t sensorFlags;
365     uint16_t sensorState;
366 }SensorReadingType;
367 uint16_t compareinputwattage(IPMI_POWER_SUPPLY_INFO* powersupplyinfo, uint16_t inputwattage);
368 int ipmi_delloem_main(struct ipmi_intf * intf, int argc, char ** argv);
369 
370 #endif /*IPMI_DELLOEM_H*/
371