1
/******************************************************************
2
Copyright (c) 2008, Dell Inc
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.
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.
28
******************************************************************/
30
* Thursday Oct 7 17:30:12 2009
31
* <deepaganesh_paulraj@dell.com>
33
* This code implements a dell OEM proprietary commands.
34
* This Code is edited and Implemented the License feature for Delloem
35
* Author Harsha S <Harsha_S1@dell.com>
41
#include <sys/types.h>
42
#include <sys/socket.h>
43
#include <netinet/in.h>
44
#include <arpa/inet.h>
50
#include <ipmitool/ipmi.h>
51
#include <ipmitool/ipmi_intf.h>
52
#include <ipmitool/helper.h>
53
#include <ipmitool/log.h>
54
#include <ipmitool/ipmi_sel.h>
55
#include <ipmitool/ipmi_delloem.h>
56
#include <ipmitool/ipmi_fru.h>
57
#include <ipmitool/ipmi_sdr.h>
58
#include <ipmitool/ipmi_mc.h>
59
#include <ipmitool/ipmi_sensor.h>
60
#include <ipmitool/ipmi_sel.h>
61
#include <ipmitool/bswap.h>
62
#include <ipmitool/ipmi_sdr.h>
63
#include <ipmitool/ipmi_entity.h>
64
#include <ipmitool/ipmi_fru.h>
65
#include <ipmitool/ipmi_sensor.h>
66
/*------------ipmi headers------------------*/
70
/*--------------time header-----------------*/
73
#define DELL_OEM_NETFN (uint8_t)(0x30)
74
#define GET_IDRAC_VIRTUAL_MAC (uint8_t)(0xC9)
78
#define SHARED_WITH_FAILOVER_LOM2 1
80
#define SHARED_WITH_FAILOVER_ALL_LOMS 3
81
char AciveLOM_String [6] [10] = {"None","LOM1","LOM2","LOM3","LOM4","dedicated" };
83
/* 11g Support Strings for nic selection */
84
char NIC_Selection_Mode_String [4] [50] = {
86
"shared with failover lom2",
88
"shared with Failover all loms"
91
/* 11g Support Macros */
93
#define SHARED_WITH_FAILOVER_LOM2 1
95
#define SHARED_WITH_FAILOVER_ALL_LOMS 3
97
/* 12g Support Strings for nic selection */
98
#define INVAILD_FAILOVER_MODE -2
99
#define INVAILD_FAILOVER_MODE_SETTINGS -3
100
#define INVAILD_SHARED_MODE -4
102
#define INVAILD_FAILOVER_MODE_STRING "ERROR: Cannot set shared with failover lom same as current shared lom.\n"
103
#define INVAILD_FAILOVER_MODE_SET "ERROR: Cannot set shared with failover loms when NIC is set to dedicated Mode.\n"
104
#define INVAILD_SHARED_MODE_SET_STRING "ERROR: Cannot set shared Mode for Blades.\n"
107
char NIC_Selection_Mode_String_12g[] [50] = {
113
"shared with failover lom1",
114
"shared with failover lom2",
115
"shared with failover lom3",
116
"shared with failover lom4",
117
"shared with failover all loms"
120
static int current_arg =0;
121
uint8_t iDRAC_FLAG=0;
123
static uint8_t LcdSupported=0;
124
static uint8_t SetLEDSupported=0;
126
volatile uint8_t IMC_Type = IMC_IDRAC_10G;
129
const struct vFlashstr vFlash_completion_code_vals[] = {
131
{0x01, "NO_SD_CARD"},
132
{0x63, "UNKNOWN_ERROR"},
137
POWER_HEADROOM powerheadroom;
139
uint8_t PowercapSetable_flag=0;
140
uint8_t PowercapstatusFlag=0;
142
static void usage(void);
144
/* LCD Function prototypes */
145
static int ipmi_delloem_lcd_main (struct ipmi_intf * intf, int argc, char ** argv);
146
static void ipmi_lcd_get_platform_model_name (struct ipmi_intf * intf,char* lcdstring,
147
uint8_t max_length,uint8_t field_type);
148
static int ipmi_idracvalidator_command (struct ipmi_intf * intf);
149
static int ipmi_lcd_get_configure_command_wh (struct ipmi_intf * intf);
150
static int ipmi_lcd_get_configure_command (struct ipmi_intf * intf,uint8_t *command);
151
static int ipmi_lcd_set_configure_command (struct ipmi_intf * intf, int command);
152
static int ipmi_lcd_set_configure_command_wh (struct ipmi_intf * intf, uint32_t mode,
153
uint16_t lcdquallifier,uint8_t errordisp);
154
static int ipmi_lcd_get_single_line_text (struct ipmi_intf * intf, char* lcdstring, uint8_t max_length);
155
static int ipmi_lcd_get_info_wh(struct ipmi_intf * intf);
156
static int ipmi_lcd_get_info(struct ipmi_intf * intf);
157
static int ipmi_lcd_get_status_val(struct ipmi_intf * intf, LCD_STATUS* lcdstatus);
158
static int IsLCDSupported ();
159
static void CheckLCDSupport(struct ipmi_intf * intf);
160
static void ipmi_lcd_status_print( LCD_STATUS lcdstatus);
161
static int ipmi_lcd_get_status(struct ipmi_intf * intf );
162
static int ipmi_lcd_set_kvm(struct ipmi_intf * intf, char status);
163
static int ipmi_lcd_set_lock(struct ipmi_intf * intf, char lock);
164
static int ipmi_lcd_set_single_line_text (struct ipmi_intf * intf, char * text);
165
static int ipmi_lcd_set_text(struct ipmi_intf * intf, char * text, int line_number);
166
static int ipmi_lcd_configure_wh (struct ipmi_intf * intf, uint32_t mode ,
167
uint16_t lcdquallifier, uint8_t errordisp,
168
int8_t line_number, char * text);
169
static int ipmi_lcd_configure (struct ipmi_intf * intf, int command,
170
int8_t line_number, char * text);
171
static void ipmi_lcd_usage(void);
173
/* MAC Function prototypes */
174
static int ipmi_delloem_mac_main (struct ipmi_intf * intf, int argc, char ** argv);
175
static int make_int(const char *str, int *value);
176
static void InitEmbeddedNICMacAddressValues ();
177
static int ipmi_macinfo_drac_idrac_virtual_mac(struct ipmi_intf* intf,uint8_t NicNum);
178
static int ipmi_macinfo_drac_idrac_mac(struct ipmi_intf* intf,uint8_t NicNum);
179
static int ipmi_macinfo_10g (struct ipmi_intf* intf, uint8_t NicNum);
180
static int ipmi_macinfo_11g (struct ipmi_intf* intf, uint8_t NicNum);
181
static int ipmi_macinfo (struct ipmi_intf* intf, uint8_t NicNum);
182
static void ipmi_mac_usage(void);
184
/* LAN Function prototypes */
185
static int ipmi_delloem_lan_main (struct ipmi_intf * intf, int argc, char ** argv);
186
static int IsLANSupported ();
187
static int get_nic_selection_mode (int current_arg, char ** argv);
188
static int ipmi_lan_set_nic_selection (struct ipmi_intf* intf, uint8_t nic_selection);
189
static int ipmi_lan_get_nic_selection (struct ipmi_intf* intf);
190
static int ipmi_lan_get_active_nic (struct ipmi_intf* intf);
191
static void ipmi_lan_usage(void);
192
static int ipmi_lan_set_nic_selection_12g (struct ipmi_intf* intf, uint8_t* nic_selection);
194
/* POwer monitor Function prototypes */
195
static int ipmi_delloem_powermonitor_main (struct ipmi_intf * intf, int argc, char ** argv);
196
static void ipmi_time_to_str(time_t rawTime, char* strTime);
197
static int ipmi_get_sensor_reading(struct ipmi_intf *intf ,
198
unsigned char sensorNumber,
199
SensorReadingType* pSensorReadingData);
200
static int ipmi_get_power_capstatus_command (struct ipmi_intf * intf);
201
static int ipmi_set_power_capstatus_command (struct ipmi_intf * intf,uint8_t val);
202
static int ipmi_powermgmt(struct ipmi_intf* intf);
203
static int ipmi_powermgmt_clear(struct ipmi_intf* intf,uint8_t clearValue);
204
static uint64_t watt_to_btuphr_conversion(uint32_t powerinwatt);
205
static uint32_t btuphr_to_watt_conversion(uint64_t powerinbtuphr);
206
static int ipmi_get_power_headroom_command (struct ipmi_intf * intf,uint8_t unit);
207
static int ipmi_get_power_consumption_data(struct ipmi_intf* intf,uint8_t unit);
208
static int ipmi_get_instan_power_consmpt_data(struct ipmi_intf* intf,
209
IPMI_INST_POWER_CONSUMPTION_DATA* instpowerconsumptiondata);
210
static void ipmi_print_get_instan_power_Amps_data(IPMI_INST_POWER_CONSUMPTION_DATA instpowerconsumptiondata);
211
static int ipmi_print_get_power_consmpt_data(struct ipmi_intf* intf,uint8_t unit);
212
static int ipmi_get_avgpower_consmpt_history(struct ipmi_intf* intf,IPMI_AVGPOWER_CONSUMP_HISTORY* pavgpower );
213
static int ipmi_get_peakpower_consmpt_history(struct ipmi_intf* intf,IPMI_POWER_CONSUMP_HISTORY * pstPeakpower);
214
static int ipmi_get_minpower_consmpt_history(struct ipmi_intf* intf,IPMI_POWER_CONSUMP_HISTORY * pstMinpower);
215
static int ipmi_print_power_consmpt_history(struct ipmi_intf* intf,int unit );
216
static int ipmi_get_power_cap(struct ipmi_intf* intf,IPMI_POWER_CAP* ipmipowercap );
217
static int ipmi_print_power_cap(struct ipmi_intf* intf,uint8_t unit );
218
static int ipmi_set_power_cap(struct ipmi_intf* intf,int unit,int val );
219
static int getpowersupplyfruinfo(struct ipmi_intf *intf, uint8_t id,
220
struct fru_header header, struct fru_info fru);
221
static void ipmi_powermonitor_usage(void);
223
/* vFlash Function prototypes */
224
static int ipmi_delloem_vFlash_main(struct ipmi_intf * intf, int argc, char ** argv);
225
const char * get_vFlash_compcode_str(uint8_t vflashcompcode, const struct vFlashstr *vs);
226
static int ipmi_get_sd_card_info(struct ipmi_intf* intf);
227
static int ipmi_delloem_vFlash_process(struct ipmi_intf* intf, int current_arg, char ** argv);
228
static void ipmi_vFlash_usage(void);
231
/* LED Function prototypes */
233
static int ipmi_getsesmask(int, char **);
234
static void CheckSetLEDSupport(struct ipmi_intf * intf);
235
static int IsSetLEDSupported(void);
236
static void ipmi_setled_usage(void);
237
static int ipmi_delloem_setled_main(struct ipmi_intf *intf, int argc, char ** argv);
238
static int ipmi_setled_state (struct ipmi_intf * intf, int bayId, int slotId, int state);
239
static int ipmi_getdrivemap (struct ipmi_intf * intf, int b, int d, int f, int *bayId, int *slotId);
241
/*****************************************************************
242
* Function Name: ipmi_delloem_main
244
* Description: This function processes the delloem command
245
* Input: intf - ipmi interface
246
argc - no of arguments
247
argv - argument string array
250
* Return: return code 0 - success
253
******************************************************************/
256
ipmi_delloem_main(struct ipmi_intf * intf, int argc, char ** argv)
260
if (argc == 0 || strncmp(argv[0], "help\0", 5) == 0)
266
if (0 ==strncmp(argv[current_arg], "lcd\0", 4))
268
ipmi_delloem_lcd_main (intf,argc,argv);
271
else if (strncmp(argv[current_arg], "mac\0", 4) == 0)
273
ipmi_delloem_mac_main (intf,argc,argv);
276
else if (strncmp(argv[current_arg], "lan\0", 4) == 0)
278
ipmi_delloem_lan_main (intf,argc,argv);
281
else if (strncmp(argv[current_arg], "setled\0", 7) == 0)
283
ipmi_delloem_setled_main (intf,argc,argv);
285
/*Powermanagement report processing*/
286
else if (strncmp(argv[current_arg], "powermonitor\0", 13) == 0)
288
ipmi_delloem_powermonitor_main (intf,argc,argv);
291
else if (strncmp(argv[current_arg], "vFlash\0", 7) == 0)
293
ipmi_delloem_vFlash_main (intf,argc,argv);
303
/*****************************************************************
304
* Function Name: usage
306
* Description: This function prints help message for delloem command
312
******************************************************************/
314
static void usage(void)
316
lprintf(LOG_NOTICE, "");
317
lprintf(LOG_NOTICE, "usage: delloem <command> [option...]");
318
lprintf(LOG_NOTICE, "");
319
lprintf(LOG_NOTICE, "commands:");
320
lprintf(LOG_NOTICE, " lcd");
321
lprintf(LOG_NOTICE, " mac");
322
lprintf(LOG_NOTICE, " lan");
323
lprintf(LOG_NOTICE, " setled");
324
lprintf(LOG_NOTICE, " powermonitor");
325
lprintf(LOG_NOTICE, " vFlash");
326
lprintf(LOG_NOTICE, "");
327
lprintf(LOG_NOTICE, "For help on individual commands type:");
328
lprintf(LOG_NOTICE, "delloem <command> help");
332
/*****************************************************************
333
* Function Name: ipmi_delloem_lcd_main
335
* Description: This function processes the delloem lcd command
336
* Input: intf - ipmi interface
337
argc - no of arguments
338
argv - argument string array
341
* Return: return code 0 - success
344
******************************************************************/
346
static int ipmi_delloem_lcd_main (struct ipmi_intf * intf, int argc, char ** argv)
351
if (argc < current_arg)
358
/* ipmitool delloem lcd info*/
359
if (argc == 1 || strcmp(argv[current_arg], "help") == 0)
364
CheckLCDSupport (intf);
365
ipmi_idracvalidator_command(intf);
366
if (!IsLCDSupported()) {
367
printf("lcd is not supported on this system.\n");
370
else if (strncmp(argv[current_arg], "info\0", 5) == 0)
372
if((iDRAC_FLAG==IDRAC_11G) || (iDRAC_FLAG==IDRAC_12G) )
373
rc = ipmi_lcd_get_info_wh(intf);
375
rc = ipmi_lcd_get_info(intf);
377
else if (strncmp(argv[current_arg], "status\0", 7) == 0)
379
rc = ipmi_lcd_get_status(intf);
381
/* ipmitool delloem lcd set*/
382
else if (strncmp(argv[current_arg], "set\0", 4) == 0)
384
uint8_t line_number = 0;
386
if (argc <= current_arg)
391
if (strncmp(argv[current_arg], "line\0", 5) == 0)
394
if (argc <= current_arg) {usage();return -1;}
395
line_number = (uint8_t)strtoul(argv[current_arg], NULL, 0);
397
if (argc <= current_arg) {usage();return -1;}
401
if ((strncmp(argv[current_arg], "mode\0", 5) == 0)&&((iDRAC_FLAG==IDRAC_11G) || (iDRAC_FLAG==IDRAC_12G) ))
404
if (argc <= current_arg)
409
if (argv[current_arg] == NULL)
414
if (strncmp(argv[current_arg], "none\0", 5) == 0)
416
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_CONFIG_NONE,0xFF,0XFF, 0, NULL);
418
else if (strncmp(argv[current_arg], "modelname\0", 10) == 0)
420
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_CONFIG_DEFAULT,0xFF,0XFF, 0, NULL);
422
else if (strncmp(argv[current_arg], "userdefined\0", 12) == 0)
425
if (argc <= current_arg)
427
ipmi_lcd_usage();return -1;
429
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_CONFIG_USER_DEFINED,0xFF,0XFF, line_number, argv[current_arg]);
431
else if (strncmp(argv[current_arg], "ipv4address\0", 12) == 0)
433
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_iDRAC_IPV4ADRESS ,0xFF,0XFF, 0, NULL);
435
else if (strncmp(argv[current_arg], "macaddress\0", 11) == 0)
437
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_IDRAC_MAC_ADDRESS,0xFF,0XFF, 0, NULL);
439
else if (strncmp(argv[current_arg], "systemname\0", 11) == 0)
441
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_OS_SYSTEM_NAME,0xFF,0XFF, 0, NULL);
443
else if (strncmp(argv[current_arg], "servicetag\0", 11) == 0)
445
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_SERVICE_TAG, 0xFF,0XFF,0, NULL);
447
else if (strncmp(argv[current_arg], "ipv6address\0", 12) == 0)
449
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_iDRAC_IPV6ADRESS ,0xFF,0XFF, 0, NULL);
451
else if (strncmp(argv[current_arg], "ambienttemp\0", 12) == 0)
453
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_AMBEINT_TEMP, 0xFF,0XFF,0, NULL);
456
else if (strncmp(argv[current_arg], "systemwatt\0", 11) == 0)
458
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_SYSTEM_WATTS , 0xFF,0XFF,0, NULL);
461
else if (strncmp(argv[current_arg], "assettag\0", 9) == 0)
463
rc = ipmi_lcd_configure_wh (intf, IPMI_DELL_LCD_ASSET_TAG , 0xFF,0XFF,0, NULL);
466
else if (strncmp(argv[current_arg], "help\0", 5) == 0)
475
else if ((strncmp(argv[current_arg], "lcdqualifier\0", 13)== 0) &&((iDRAC_FLAG==IDRAC_11G) || (iDRAC_FLAG==IDRAC_12G) ) )
479
if (argc <= current_arg)
484
if (argv[current_arg] == NULL)
490
if (strncmp(argv[current_arg], "watt\0", 5) == 0) {
493
rc = ipmi_lcd_configure_wh (intf, 0xFF,0x00,0XFF, 0, NULL);
495
else if (strncmp(argv[current_arg], "btuphr\0",7) == 0) {
496
rc = ipmi_lcd_configure_wh (intf, 0xFF,0x01,0XFF, 0, NULL);
498
} else if (strncmp(argv[current_arg], "celsius\0", 8) == 0) {
499
rc = ipmi_lcd_configure_wh (intf, 0xFF,0x02,0xFF, 0, NULL);
500
} else if (strncmp(argv[current_arg], "fahrenheit", 11) == 0) {
501
rc = ipmi_lcd_configure_wh (intf, 0xFF,0x03,0xFF, 0, NULL);
503
}else if (strncmp(argv[current_arg], "help\0", 5) == 0) {
510
else if( (strncmp(argv[current_arg], "errordisplay\0", 13) == 0)&&((iDRAC_FLAG==IDRAC_11G) || (iDRAC_FLAG==IDRAC_12G) ))
514
if (argc <= current_arg)
519
if (argv[current_arg] == NULL)
525
if (strncmp(argv[current_arg], "sel\0", 4) == 0)
527
rc = ipmi_lcd_configure_wh (intf, 0xFF,0xFF,IPMI_DELL_LCD_ERROR_DISP_SEL , 0, NULL);
529
else if (strncmp(argv[current_arg], "simple\0", 7) == 0)
531
rc = ipmi_lcd_configure_wh (intf, 0xFF,0xFF,IPMI_DELL_LCD_ERROR_DISP_VERBOSE , 0, NULL);
534
else if (strncmp(argv[current_arg], "help\0", 5) == 0)
544
else if ((strncmp(argv[current_arg], "none\0", 5) == 0)&&(iDRAC_FLAG==0))
546
rc = ipmi_lcd_configure (intf, IPMI_DELL_LCD_CONFIG_NONE, 0, NULL);
548
else if ((strncmp(argv[current_arg], "default\0", 8) == 0)&&(iDRAC_FLAG==0))
550
rc = ipmi_lcd_configure (intf, IPMI_DELL_LCD_CONFIG_DEFAULT, 0, NULL);
553
else if ((strncmp(argv[current_arg], "custom\0", 7) == 0)&&(iDRAC_FLAG==0))
556
if (argc <= current_arg)
561
rc = ipmi_lcd_configure (intf, IPMI_DELL_LCD_CONFIG_USER_DEFINED, line_number, argv[current_arg]);
564
else if (strncmp(argv[current_arg], "vkvm\0", 5) == 0)
567
if (argc <= current_arg)
573
if (strncmp(argv[current_arg], "active\0", 7) == 0)
575
rc = ipmi_lcd_set_kvm (intf, 1);
577
else if (strncmp(argv[current_arg], "inactive\0", 9)==0)
579
rc = ipmi_lcd_set_kvm (intf, 0);
582
else if (strncmp(argv[current_arg], "help\0", 5) == 0)
592
else if (strncmp(argv[current_arg], "frontpanelaccess\0", 17) == 0)
595
if (argc <= current_arg)
600
if (strncmp(argv[current_arg], "viewandmodify\0", 14) == 0)
602
rc = ipmi_lcd_set_lock (intf, 0);
604
else if (strncmp(argv[current_arg], "viewonly\0", 9)==0)
606
rc = ipmi_lcd_set_lock (intf, 1);
609
else if (strncmp(argv[current_arg], "disabled\0", 9)==0)
611
rc = ipmi_lcd_set_lock (intf, 2);
614
else if (strncmp(argv[current_arg], "help\0", 5) == 0)
624
else if( (strncmp(argv[current_arg], "help\0", 5) == 0)&&(iDRAC_FLAG==0))
644
/*****************************************************************
645
* Function Name: ipmi_lcd_get_platform_model_name
647
* Description: This function retrieves the platform model name, or any other parameter
648
* which stores data in the same format
649
* Input: intf - pointer to interface
650
* max_length - length of the platform model string
651
* field_type - either hostname / platform model
652
* Output: lcdstring - hostname / platform model string
656
******************************************************************/
658
ipmi_lcd_get_platform_model_name (struct ipmi_intf * intf,
663
struct ipmi_rs * rsp = NULL;
664
struct ipmi_rq req = {0};
666
IPMI_DELL_LCD_STRING * lcdstringblock;
667
int lcdstring_len = 0;
668
int bytes_copied = 0;
672
for (ii = 0; ii < 4; ii++)
675
memset (&req,0,sizeof(req));
676
req.msg.netfn = IPMI_NETFN_APP;
678
req.msg.cmd = IPMI_GET_SYS_INFO;
679
req.msg.data_len = 4;
681
data[0] = 0; /* get parameter*/
682
data[1] = field_type;
687
rsp = intf->sendrecv(intf, &req);
689
lprintf(LOG_ERR, " Error getting platform model name");
690
} else if (rsp->ccode > 0) {
691
lprintf(LOG_ERR, " Error getting platform model name: %s",
692
val2str(rsp->ccode, completion_code_vals));
695
lcdstringblock = (IPMI_DELL_LCD_STRING *) (void *) rsp->data;
697
/* first block is different - 14 bytes*/
699
lcdstring_len = lcdstringblock->lcd_string.selector_0_string.length;
701
lcdstring_len = MIN (lcdstring_len,max_length);
703
bytes_to_copy = MIN(lcdstring_len, IPMI_DELL_LCD_STRING1_SIZE);
704
memcpy (lcdstring, lcdstringblock->lcd_string.selector_0_string.data, bytes_to_copy);
708
bytes_to_copy = MIN(lcdstring_len - bytes_copied, IPMI_DELL_LCD_STRINGN_SIZE);
709
if (bytes_to_copy < 1)
711
string_offset = IPMI_DELL_LCD_STRING1_SIZE + IPMI_DELL_LCD_STRINGN_SIZE * (ii-1);
712
memcpy (lcdstring+string_offset, lcdstringblock->lcd_string.selector_n_data, bytes_to_copy);
716
bytes_copied += bytes_to_copy;
718
if (bytes_copied >= lcdstring_len)
725
/*****************************************************************
726
* Function Name: ipmi_idracvalidator_command
728
* Description: This function returns the iDRAC6 type
729
* Input: intf - ipmi interface
732
* Return: iDRAC6 type 1 - whoville
735
******************************************************************/
738
ipmi_idracvalidator_command (struct ipmi_intf * intf)
740
struct ipmi_rs * rsp = NULL;
741
struct ipmi_rq req = {0};
744
memset (&req,0,sizeof(req));
745
req.msg.netfn = IPMI_NETFN_APP;
747
req.msg.cmd = IPMI_GET_SYS_INFO;
748
req.msg.data_len = 4;
751
data[1] = IPMI_DELL_IDRAC_VALIDATOR;
755
rsp = intf->sendrecv(intf, &req);
757
/*lprintf(LOG_ERR, " Error getting IMC type"); */
759
} else if (rsp->ccode > 0) {
760
/*lprintf(LOG_ERR, " Error getting IMC type: %s",
761
val2str(rsp->ccode, completion_code_vals)); */
764
/* Support the 11G Monolithic, modular, Maisy and Coaster */
765
if( (IMC_IDRAC_11G_MONOLITHIC == rsp->data[10]) || (IMC_IDRAC_11G_MODULAR ==rsp->data[10]) ||
766
(IMC_MASER_LITE_BMC == rsp->data[10]) || (IMC_MASER_LITE_NU ==rsp->data[10]) )
768
iDRAC_FLAG=IDRAC_11G;
770
else if( (IMC_IDRAC_12G_MONOLITHIC == rsp->data[10]) || (IMC_IDRAC_12G_MODULAR==rsp->data[10]) )
772
iDRAC_FLAG=IDRAC_12G;
778
IMC_Type = rsp->data[10];
783
/*****************************************************************
784
* Function Name: ipmi_lcd_get_configure_command_wh
786
* Description: This function returns current lcd configuration for Dell OEM LCD command
787
* Input: intf - ipmi interface
788
* Global: lcd_mode - lcd mode setting
791
* Return: returns the current lcd configuration
796
******************************************************************/
798
ipmi_lcd_get_configure_command_wh (struct ipmi_intf * intf)
800
struct ipmi_rs * rsp = NULL;
801
struct ipmi_rq req = {0};
804
req.msg.netfn = IPMI_NETFN_APP;
806
req.msg.cmd = IPMI_GET_SYS_INFO;
807
req.msg.data_len = 4;
810
data[1] = IPMI_DELL_LCD_CONFIG_SELECTOR;
814
rsp = intf->sendrecv(intf, &req);
816
lprintf(LOG_ERR, " Error getting LCD configuration");
818
}else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb)){
820
lprintf(LOG_ERR, " Error getting LCD configuration: Command not supported on this system.");
822
} else if (rsp->ccode > 0) {
823
lprintf(LOG_ERR, " Error getting LCD configuration: %s",
824
val2str(rsp->ccode, completion_code_vals));
828
lcd_mode= *((LCD_MODE*)(rsp->data));
833
/*****************************************************************
834
* Function Name: ipmi_lcd_get_configure_command
836
* Description: This function returns current lcd configuration for Dell OEM LCD command
837
* Input: intf - ipmi interface
838
* Output: command - user defined / default / none / ipv4 / mac address /
839
system name / service tag / ipv6 / temp / system watt / asset tag
843
******************************************************************/
846
ipmi_lcd_get_configure_command (struct ipmi_intf * intf,
849
struct ipmi_rs * rsp = NULL;
850
struct ipmi_rq req = {0};
853
req.msg.netfn = IPMI_NETFN_APP;
855
req.msg.cmd = IPMI_GET_SYS_INFO;
856
req.msg.data_len = 4;
859
data[1] = IPMI_DELL_LCD_CONFIG_SELECTOR;
863
rsp = intf->sendrecv(intf, &req);
866
lprintf(LOG_ERR, " Error getting LCD configuration");
869
else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
871
lprintf(LOG_ERR, " Error getting LCD configuration: Command not supported on this system.");
874
else if (rsp->ccode > 0)
876
lprintf(LOG_ERR, " Error getting LCD configuration: %s",
877
val2str(rsp->ccode, completion_code_vals));
881
/* rsp->data[0] is the rev */
882
*command = rsp->data[1];
887
/*****************************************************************
888
* Function Name: ipmi_lcd_set_configure_command
890
* Description: This function updates current lcd configuration
891
* Input: intf - ipmi interface
892
* command - user defined / default / none / ipv4 / mac address /
893
* system name / service tag / ipv6 / temp / system watt / asset tag
897
******************************************************************/
900
ipmi_lcd_set_configure_command (struct ipmi_intf * intf, int command)
902
#define LSCC_DATA_LEN 2
904
struct ipmi_rs * rsp = NULL;
905
struct ipmi_rq req = {0};
908
req.msg.netfn = IPMI_NETFN_APP;
910
req.msg.cmd = IPMI_SET_SYS_INFO;
911
req.msg.data_len = 2;
913
data[0] = IPMI_DELL_LCD_CONFIG_SELECTOR;
914
data[1] = command; /* command - custom, default, none */
916
rsp = intf->sendrecv(intf, &req);
919
lprintf(LOG_ERR, " Error setting LCD configuration");
922
else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
924
lprintf(LOG_ERR, " Error setting LCD configuration: Command not supported on this system.");
927
else if (rsp->ccode > 0)
929
lprintf(LOG_ERR, " Error setting LCD configuration: %s",
930
val2str(rsp->ccode, completion_code_vals));
939
/*****************************************************************
940
* Function Name: ipmi_lcd_set_configure_command
942
* Description: This function updates current lcd configuration
943
* Input: intf - ipmi interface
944
* mode - user defined / default / none
945
* lcdquallifier - lcd quallifier id
946
* errordisp - error number
950
******************************************************************/
952
ipmi_lcd_set_configure_command_wh (struct ipmi_intf * intf,
954
uint16_t lcdquallifier,
957
#define LSCC_DATA_LEN 2
959
struct ipmi_rs * rsp = NULL;
960
struct ipmi_rq req = {0};
963
ipmi_lcd_get_configure_command_wh(intf);
964
req.msg.netfn = IPMI_NETFN_APP;
966
req.msg.cmd = IPMI_SET_SYS_INFO;
967
req.msg.data_len = 13;
969
data[0] = IPMI_DELL_LCD_CONFIG_SELECTOR;
974
data[1] = mode&0xFF; /* command - custom, default, none*/
975
data[2]=(mode&0xFF00)>>8;
976
data[3]=(mode&0xFF0000)>>16;
977
data[4]=(mode&0xFF000000)>>24;
981
data[1] = (lcd_mode.lcdmode)&0xFF; /* command - custom, default, none*/
982
data[2]=((lcd_mode.lcdmode)&0xFF00)>>8;
983
data[3]=((lcd_mode.lcdmode)&0xFF0000)>>16;
984
data[4]=((lcd_mode.lcdmode)&0xFF000000)>>24;
987
if(lcdquallifier!=0xFF)
989
if(lcdquallifier==0x01)
991
data[5] =(lcd_mode.lcdquallifier)|0x01; /* command - custom, default, none*/
994
else if(lcdquallifier==0x00)
996
data[5] =(lcd_mode.lcdquallifier)&0xFE; /* command - custom, default, none*/
998
else if (lcdquallifier==0x03)
1000
data[5] =(lcd_mode.lcdquallifier)|0x02; /* command - custom, default, none*/
1002
else if (lcdquallifier==0x02)
1004
data[5] =(lcd_mode.lcdquallifier)&0xFD;
1009
data[5]=lcd_mode.lcdquallifier;
1017
data[11]=lcd_mode.error_display;
1019
rsp = intf->sendrecv(intf, &req);
1022
lprintf(LOG_ERR, " Error setting LCD configuration");
1025
else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
1027
lprintf(LOG_ERR, " Error setting LCD configuration: Command not supported on this system.");
1029
else if (rsp->ccode > 0)
1031
lprintf(LOG_ERR, " Error setting LCD configuration: %s",
1032
val2str(rsp->ccode, completion_code_vals));
1042
/*****************************************************************
1043
* Function Name: ipmi_lcd_get_single_line_text
1045
* Description: This function updates current lcd configuration
1046
* Input: intf - ipmi interface
1047
* lcdstring - new string to be updated
1048
* max_length - length of the string
1052
******************************************************************/
1055
ipmi_lcd_get_single_line_text (struct ipmi_intf * intf, char* lcdstring, uint8_t max_length)
1057
struct ipmi_rs * rsp = NULL;
1058
struct ipmi_rq req = {0};
1060
IPMI_DELL_LCD_STRING * lcdstringblock;
1061
int lcdstring_len = 0;
1062
int bytes_copied = 0;
1065
for (ii = 0; ii < 4; ii++) {
1068
req.msg.netfn = IPMI_NETFN_APP;
1070
req.msg.cmd = IPMI_GET_SYS_INFO;
1071
req.msg.data_len = 4;
1072
req.msg.data = data;
1073
data[0] = 0; /* get parameter*/
1074
data[1] = IPMI_DELL_LCD_STRING_SELECTOR;
1075
data[2] = ii; /* block selector*/
1076
data[3] = 00; /* set selector (n/a)*/
1078
rsp = intf->sendrecv(intf, &req);
1080
lprintf(LOG_ERR, " Error getting text data");
1082
} else if (rsp->ccode > 0) {
1083
lprintf(LOG_ERR, " Error getting text data: %s",
1084
val2str(rsp->ccode, completion_code_vals));
1088
lcdstringblock = (IPMI_DELL_LCD_STRING *) (void *) rsp->data;
1090
/* first block is different - 14 bytes*/
1093
lcdstring_len = lcdstringblock->lcd_string.selector_0_string.length;
1095
if (lcdstring_len < 1 || lcdstring_len > max_length)
1098
bytes_to_copy = MIN(lcdstring_len, IPMI_DELL_LCD_STRING1_SIZE);
1099
memcpy (lcdstring, lcdstringblock->lcd_string.selector_0_string.data, bytes_to_copy);
1105
bytes_to_copy = MIN(lcdstring_len - bytes_copied, IPMI_DELL_LCD_STRINGN_SIZE);
1106
if (bytes_to_copy < 1)
1108
string_offset = IPMI_DELL_LCD_STRING1_SIZE + IPMI_DELL_LCD_STRINGN_SIZE * (ii-1);
1109
memcpy (lcdstring+string_offset, lcdstringblock->lcd_string.selector_n_data, bytes_to_copy);
1112
bytes_copied += bytes_to_copy;
1113
if (bytes_copied >= lcdstring_len)
1119
/*****************************************************************
1120
* Function Name: ipmi_lcd_get_info_wh
1122
* Description: This function prints current lcd configuration for whoville platform
1123
* Input: intf - ipmi interface
1127
******************************************************************/
1130
ipmi_lcd_get_info_wh(struct ipmi_intf * intf)
1133
struct ipmi_rs * rsp = NULL;
1134
struct ipmi_rq req = {0};
1136
IPMI_DELL_LCD_CAPS* lcd_caps;
1137
char lcdstring[IPMI_DELL_LCD_STRING_LENGTH_MAX+1] = {0};
1141
printf("LCD info\n");
1143
if (ipmi_lcd_get_configure_command_wh (intf) != 0)
1149
if (lcd_mode.lcdmode== IPMI_DELL_LCD_CONFIG_DEFAULT)
1151
char text[IPMI_DELL_LCD_STRING_LENGTH_MAX+1] = {0};
1153
ipmi_lcd_get_platform_model_name(intf, text,
1154
IPMI_DELL_LCD_STRING_LENGTH_MAX,
1155
IPMI_DELL_PLATFORM_MODEL_NAME_SELECTOR);
1159
printf(" Setting:Model name\n");
1160
printf(" Line 1: %s\n", text);
1162
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_CONFIG_NONE)
1164
printf(" Setting: none\n");
1166
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_CONFIG_USER_DEFINED)
1168
req.msg.netfn = IPMI_NETFN_APP;
1170
req.msg.cmd = IPMI_GET_SYS_INFO;
1171
req.msg.data_len = 4;
1172
req.msg.data = data;
1173
data[0] = 0; /* get parameter*/
1174
data[1] = IPMI_DELL_LCD_GET_CAPS_SELECTOR;
1175
data[2] = 0; /* set selector (n/a)*/
1176
data[3] = 0; /* block selector (n/a)*/
1178
printf(" Setting: User defined\n");
1180
rsp = intf->sendrecv(intf, &req);
1183
lprintf(LOG_ERR, " Error getting LCD capabilities.");
1186
else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
1188
lprintf(LOG_ERR, " Error getting LCD capabilities: Command not supported on this system.");
1190
else if (rsp->ccode > 0)
1192
lprintf(LOG_ERR, " Error getting LCD capabilities: %s",
1193
val2str(rsp->ccode, completion_code_vals));
1197
lcd_caps = (IPMI_DELL_LCD_CAPS *)rsp->data;
1198
if (lcd_caps->number_lines > 0)
1200
memset(lcdstring, 0, IPMI_DELL_LCD_STRING_LENGTH_MAX+1);
1202
rc = ipmi_lcd_get_single_line_text (intf, lcdstring, lcd_caps->max_chars[0]);
1203
printf(" Text: %s\n", lcdstring);
1207
printf(" No lines to show\n");
1210
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_iDRAC_IPV4ADRESS)
1212
printf(" Setting: IPV4 Address\n");
1214
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_IDRAC_MAC_ADDRESS)
1216
printf(" Setting: MAC Address\n");
1218
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_OS_SYSTEM_NAME)
1220
printf(" Setting: OS System Name\n");
1222
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_SERVICE_TAG)
1224
printf(" Setting: System Tag\n");
1226
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_iDRAC_IPV6ADRESS)
1228
printf(" Setting: IPV6 Address\n");
1230
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_ASSET_TAG)
1232
printf(" Setting: Asset Tag\n");
1234
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_AMBEINT_TEMP)
1236
printf(" Setting: Ambient Temp\n");
1237
if(lcd_mode.lcdquallifier&0x02)
1238
printf(" Unit: F\n");
1240
printf(" Unit: C\n");
1242
else if (lcd_mode.lcdmode == IPMI_DELL_LCD_SYSTEM_WATTS)
1244
printf(" Setting: System Watts\n");
1246
if(lcd_mode.lcdquallifier&0x01)
1247
printf(" Unit: BTU/hr\n");
1249
printf(" Unit: Watt\n");
1252
if(lcd_mode.error_display==IPMI_DELL_LCD_ERROR_DISP_SEL)
1253
printf(" Error Display: SEL\n");
1254
else if(lcd_mode.error_display==IPMI_DELL_LCD_ERROR_DISP_VERBOSE)
1255
printf(" Error Display: Simple\n");
1261
/*****************************************************************
1262
* Function Name: ipmi_lcd_get_info
1264
* Description: This function prints current lcd configuration for platform other than whoville
1265
* Input: intf - ipmi interface
1269
******************************************************************/
1270
static int ipmi_lcd_get_info(struct ipmi_intf * intf)
1272
struct ipmi_rs * rsp = NULL;
1273
struct ipmi_rq req = {0};
1275
IPMI_DELL_LCD_CAPS * lcd_caps;
1276
uint8_t command = 0;
1277
char lcdstring[IPMI_DELL_LCD_STRING_LENGTH_MAX+1] = {0};
1280
printf("LCD info\n");
1282
if (ipmi_lcd_get_configure_command (intf, &command) != 0)
1288
if (command == IPMI_DELL_LCD_CONFIG_DEFAULT)
1290
memset (lcdstring,0,IPMI_DELL_LCD_STRING_LENGTH_MAX+1);
1292
ipmi_lcd_get_platform_model_name(intf, lcdstring, IPMI_DELL_LCD_STRING_LENGTH_MAX,
1293
IPMI_DELL_PLATFORM_MODEL_NAME_SELECTOR);
1295
printf(" Setting: default\n");
1296
printf(" Line 1: %s\n", lcdstring);
1298
else if (command == IPMI_DELL_LCD_CONFIG_NONE)
1300
printf(" Setting: none\n");
1302
else if (command == IPMI_DELL_LCD_CONFIG_USER_DEFINED)
1304
req.msg.netfn = IPMI_NETFN_APP;
1306
req.msg.cmd = IPMI_GET_SYS_INFO;
1307
req.msg.data_len = 4;
1308
req.msg.data = data;
1309
data[0] = 0; /* get parameter */
1310
data[1] = IPMI_DELL_LCD_GET_CAPS_SELECTOR;
1311
data[2] = 0; /* set selector (n/a) */
1312
data[3] = 0; /* block selector (n/a) */
1314
printf(" Setting: custom\n");
1316
rsp = intf->sendrecv(intf, &req);
1319
lprintf(LOG_ERR, " Error getting LCD capabilities.");
1322
else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
1324
lprintf(LOG_ERR, " Error getting LCD capabilities: Command not supported on this system.");
1326
else if (rsp->ccode > 0)
1328
lprintf(LOG_ERR, " Error getting LCD capabilities: %s",
1329
val2str(rsp->ccode, completion_code_vals));
1333
lcd_caps = (IPMI_DELL_LCD_CAPS *)(void *)rsp->data;
1334
if (lcd_caps->number_lines > 0)
1336
memset (lcdstring,0,IPMI_DELL_LCD_STRING_LENGTH_MAX+1);
1337
rc = ipmi_lcd_get_single_line_text (intf, lcdstring, lcd_caps->max_chars[0]);
1338
printf(" Text: %s\n", lcdstring);
1342
printf(" No lines to show\n");
1350
/*****************************************************************
1351
* Function Name: ipmi_lcd_get_status_val
1353
* Description: This function gets current lcd configuration
1354
* Input: intf - ipmi interface
1355
* Output: lcdstatus - KVM Status & Lock Status
1358
******************************************************************/
1361
ipmi_lcd_get_status_val(struct ipmi_intf * intf, LCD_STATUS* lcdstatus)
1363
struct ipmi_rs * rsp = NULL;
1364
struct ipmi_rq req = {0};
1368
req.msg.netfn = IPMI_NETFN_APP;
1370
req.msg.cmd = IPMI_GET_SYS_INFO;
1371
req.msg.data_len = 4;
1372
req.msg.data = data;
1373
data[0] = 0; /* get parameter */
1374
data[1] = IPMI_DELL_LCD_STATUS_SELECTOR;
1375
data[2] = 0; /* block selector */
1377
/* set selector (n/a) */
1378
rsp = intf->sendrecv(intf, &req);
1381
lprintf(LOG_ERR, " Error getting LCD Status");
1384
else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
1386
lprintf(LOG_ERR, " Error getting LCD status: Command not supported on this system.");
1389
else if (rsp->ccode > 0)
1391
lprintf(LOG_ERR, " Error getting LCD Status: %s",
1392
val2str(rsp->ccode, completion_code_vals));
1396
/*lcdstatus= (LCD_STATUS* ) rsp->data; */
1398
lcdstatus->vKVM_status=rsp->data[1];
1399
lcdstatus->lock_status=rsp->data[2];
1405
/*****************************************************************
1406
* Function Name: IsLCDSupported
1408
* Description: This function returns whether lcd supported or not
1413
******************************************************************/
1414
static int IsLCDSupported ()
1416
return LcdSupported;
1419
/*****************************************************************
1420
* Function Name: CheckLCDSupport
1422
* Description: This function checks whether lcd supported or not
1423
* Input: intf - ipmi interface
1427
******************************************************************/
1428
static void CheckLCDSupport(struct ipmi_intf * intf)
1430
struct ipmi_rs * rsp = NULL;
1431
struct ipmi_rq req = {0};
1436
req.msg.netfn = IPMI_NETFN_APP;
1438
req.msg.cmd = IPMI_GET_SYS_INFO;
1439
req.msg.data_len = 4;
1440
req.msg.data = data;
1441
data[0] = 0; /* get parameter */
1442
data[1] = IPMI_DELL_LCD_STATUS_SELECTOR;
1443
data[2] = 0; /* block selector */
1445
rsp = intf->sendrecv(intf, &req);
1450
else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
1454
else if (rsp->ccode > 0)
1462
/*****************************************************************
1463
* Function Name: ipmi_lcd_status_print
1465
* Description: This function prints current lcd configuration KVM Status & Lock Status
1466
* Input: lcdstatus - KVM Status & Lock Status
1470
******************************************************************/
1472
static void ipmi_lcd_status_print( LCD_STATUS lcdstatus)
1474
switch (lcdstatus.vKVM_status)
1477
printf("LCD KVM Status :Inactive\n");
1480
printf("LCD KVM Status :Active\n");
1483
printf("LCD KVM Status :Invalid Status\n");
1488
switch (lcdstatus.lock_status)
1491
printf("LCD lock Status :View and modify\n");
1494
printf("LCD lock Status :View only\n");
1497
printf("LCD lock Status :disabled\n");
1500
printf("LCD lock Status :Invalid\n");
1506
/*****************************************************************
1507
* Function Name: ipmi_lcd_get_status
1509
* Description: This function gets current lcd KVM active status & lcd access mode
1510
* Input: intf - ipmi interface
1512
* Return: -1 on error
1515
******************************************************************/
1517
ipmi_lcd_get_status(struct ipmi_intf * intf )
1520
LCD_STATUS lcdstatus;
1522
rc =ipmi_lcd_get_status_val( intf, &lcdstatus);
1525
ipmi_lcd_status_print(lcdstatus);
1531
/*****************************************************************
1532
* Function Name: ipmi_lcd_set_kvm
1534
* Description: This function sets lcd KVM active status
1535
* Input: intf - ipmi interface
1536
* status - Inactive / Active
1538
* Return: -1 on error
1541
******************************************************************/
1543
ipmi_lcd_set_kvm(struct ipmi_intf * intf, char status)
1545
#define LSCC_DATA_LEN 2
1546
LCD_STATUS lcdstatus;
1548
struct ipmi_rs * rsp = NULL;
1549
struct ipmi_rq req = {0};
1551
rc=ipmi_lcd_get_status_val(intf,&lcdstatus);
1554
req.msg.netfn = IPMI_NETFN_APP;
1556
req.msg.cmd = IPMI_SET_SYS_INFO;
1557
req.msg.data_len = 5;
1558
req.msg.data = data;
1559
data[0] = IPMI_DELL_LCD_STATUS_SELECTOR;
1560
data[1] = status; /* active- incative*/
1561
data[2] = lcdstatus.lock_status; /* full-veiw-locked */
1562
rsp = intf->sendrecv(intf, &req);
1564
lprintf(LOG_ERR, " Error setting LCD status");
1566
}else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb)) {
1567
lprintf(LOG_ERR, " Error getting LCD status: Command not supported on this system.");
1569
} else if (rsp->ccode > 0) {
1570
lprintf(LOG_ERR, " Error setting LCD status: %s",
1571
val2str(rsp->ccode, completion_code_vals));
1579
/*****************************************************************
1580
* Function Name: ipmi_lcd_set_lock
1582
* Description: This function sets lcd access mode
1583
* Input: intf - ipmi interface
1584
* lock - View and modify / View only / Diabled
1586
* Return: -1 on error
1589
******************************************************************/
1591
ipmi_lcd_set_lock(struct ipmi_intf * intf, char lock)
1593
#define LSCC_DATA_LEN 2
1594
LCD_STATUS lcdstatus;
1596
struct ipmi_rs * rsp = NULL;
1597
struct ipmi_rq req = {0};
1599
rc=ipmi_lcd_get_status_val(intf,&lcdstatus);
1602
req.msg.netfn = IPMI_NETFN_APP;
1604
req.msg.cmd = IPMI_SET_SYS_INFO;
1605
req.msg.data_len = 5;
1606
req.msg.data = data;
1607
data[0] = IPMI_DELL_LCD_STATUS_SELECTOR;
1608
data[1] = lcdstatus.vKVM_status; /* active- incative */
1609
data[2] = lock; /* full- veiw-locked */
1610
rsp = intf->sendrecv(intf, &req);
1613
lprintf(LOG_ERR, " Error setting LCD status");
1616
if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
1618
lprintf(LOG_ERR, " Error getting LCD status: Command not supported on this system.");
1621
else if (rsp->ccode > 0)
1623
lprintf(LOG_ERR, " Error setting LCD status: %s",
1624
val2str(rsp->ccode, completion_code_vals));
1632
/*****************************************************************
1633
* Function Name: ipmi_lcd_set_single_line_text
1635
* Description: This function sets lcd line text
1636
* Input: intf - ipmi interface
1639
* Return: -1 on error
1642
******************************************************************/
1645
ipmi_lcd_set_single_line_text (struct ipmi_intf * intf, char * text)
1647
struct ipmi_rs * rsp = NULL;
1648
struct ipmi_rq req = {0};
1650
int bytes_to_store = strlen(text);
1651
int bytes_stored = 0;
1654
if (bytes_to_store>IPMI_DELL_LCD_STRING_LENGTH_MAX)
1656
lprintf(LOG_ERR, " Out of range Max limit is 62 characters");
1662
bytes_to_store = MIN(bytes_to_store, IPMI_DELL_LCD_STRING_LENGTH_MAX);
1663
for (ii = 0; ii < 4; ii++) {
1664
/*first block, 2 bytes parms and 14 bytes data*/
1667
MIN((bytes_to_store - bytes_stored), IPMI_DELL_LCD_STRING1_SIZE);
1668
if (size_of_copy < 0) /* allow 0 string length*/
1670
req.msg.netfn = IPMI_NETFN_APP;
1672
req.msg.cmd = IPMI_SET_SYS_INFO;
1673
req.msg.data_len = size_of_copy + 4; /* chars, selectors and sizes*/
1674
req.msg.data = data;
1675
data[0] = IPMI_DELL_LCD_STRING_SELECTOR;
1676
data[1] = ii; /* block number to use (0)*/
1677
data[2] = 0; /*string encoding*/
1678
data[3] = bytes_to_store; /* total string length*/
1679
memcpy (data+4, text+bytes_stored, size_of_copy);
1680
bytes_stored += size_of_copy;
1683
MIN((bytes_to_store - bytes_stored), IPMI_DELL_LCD_STRINGN_SIZE);
1684
if (size_of_copy <= 0)
1686
req.msg.netfn = IPMI_NETFN_APP;
1688
req.msg.cmd = IPMI_SET_SYS_INFO;
1689
req.msg.data_len = size_of_copy + 2;
1690
req.msg.data = data;
1691
data[0] = IPMI_DELL_LCD_STRING_SELECTOR;
1692
data[1] = ii; /* block number to use (1,2,3)*/
1693
memcpy (data+2, text+bytes_stored, size_of_copy);
1694
bytes_stored += size_of_copy;
1697
rsp = intf->sendrecv(intf, &req);
1699
lprintf(LOG_ERR, " Error setting text data");
1701
} else if (rsp->ccode > 0) {
1702
lprintf(LOG_ERR, " Error setting text data: %s",
1703
val2str(rsp->ccode, completion_code_vals));
1711
/*****************************************************************
1712
* Function Name: ipmi_lcd_set_text
1714
* Description: This function sets lcd line text
1715
* Input: intf - ipmi interface
1717
* line_number- line number
1720
* Return: -1 on error
1723
******************************************************************/
1726
ipmi_lcd_set_text(struct ipmi_intf * intf, char * text, int line_number)
1730
struct ipmi_rs * rsp = NULL;
1731
struct ipmi_rq req = {0};
1733
IPMI_DELL_LCD_CAPS * lcd_caps;
1735
req.msg.netfn = IPMI_NETFN_APP;
1737
req.msg.cmd = IPMI_GET_SYS_INFO;
1738
req.msg.data_len = 4;
1739
req.msg.data = data;
1740
data[0] = 0; /* get parameter*/
1741
data[1] = IPMI_DELL_LCD_GET_CAPS_SELECTOR;
1742
data[2] = 0; /* set selector (n/a)*/
1743
data[3] = 0; /* block selector (n/a)*/
1745
rsp = intf->sendrecv(intf, &req);
1748
lprintf(LOG_ERR, " Error getting LCD capabilities");
1751
else if (rsp->ccode > 0)
1753
lprintf(LOG_ERR, " Error getting LCD capabilities: %s",
1754
val2str(rsp->ccode, completion_code_vals));
1759
lcd_caps = (IPMI_DELL_LCD_CAPS *)(void *)rsp->data;
1761
if (lcd_caps->number_lines > 0) {
1762
rc = ipmi_lcd_set_single_line_text (intf, text);
1764
lprintf(LOG_ERR, "LCD does not have any lines that can be set");
1772
/*****************************************************************
1773
* Function Name: ipmi_lcd_configure_wh
1775
* Description: This function updates the current lcd configuration
1776
* Input: intf - ipmi interface
1777
* lcdquallifier- lcd quallifier
1778
* errordisp - error number
1779
* line_number-line number
1782
* Return: -1 on error
1785
******************************************************************/
1788
ipmi_lcd_configure_wh (struct ipmi_intf * intf, uint32_t mode ,
1789
uint16_t lcdquallifier, uint8_t errordisp,
1790
int8_t line_number, char * text)
1795
if (IPMI_DELL_LCD_CONFIG_USER_DEFINED == mode)
1796
/* Any error was reported earlier. */
1797
rc = ipmi_lcd_set_text(intf, text, line_number);
1802
rc = ipmi_lcd_set_configure_command_wh (intf, mode ,lcdquallifier,errordisp);
1808
/*****************************************************************
1809
* Function Name: ipmi_lcd_configure
1811
* Description: This function updates the current lcd configuration
1812
* Input: intf - ipmi interface
1813
* command- lcd command
1814
* line_number-line number
1817
* Return: -1 on error
1820
******************************************************************/
1823
ipmi_lcd_configure (struct ipmi_intf * intf, int command,
1824
int8_t line_number, char * text)
1828
if (IPMI_DELL_LCD_CONFIG_USER_DEFINED == command)
1829
rc = ipmi_lcd_set_text(intf, text, line_number);
1832
rc = ipmi_lcd_set_configure_command (intf, command);
1838
/*****************************************************************
1839
* Function Name: ipmi_lcd_usage
1841
* Description: This function prints help message for lcd command
1847
******************************************************************/
1850
ipmi_lcd_usage(void)
1852
lprintf(LOG_NOTICE, "");
1853
lprintf(LOG_NOTICE, "Generic DELL HW:");
1854
lprintf(LOG_NOTICE, " lcd set {none}|{default}|{custom <text>}");
1855
lprintf(LOG_NOTICE, " Set LCD text displayed during non-fault conditions");
1857
lprintf(LOG_NOTICE, "");
1858
lprintf(LOG_NOTICE, "iDRAC 11g or iDRAC 12g:");
1859
lprintf(LOG_NOTICE, " lcd set {mode}|{lcdqualifier}|{errordisplay}");
1860
lprintf(LOG_NOTICE, " Allows you to set the LCD mode and user-defined string.");
1861
lprintf(LOG_NOTICE, "");
1862
lprintf(LOG_NOTICE, " lcd set mode {none}|{modelname}|{ipv4address}|{macaddress}|");
1863
lprintf(LOG_NOTICE, " {systemname}|{servicetag}|{ipv6address}|{ambienttemp}");
1864
lprintf(LOG_NOTICE, " {systemwatt }|{assettag}|{userdefined}<text>");
1865
lprintf(LOG_NOTICE, " Allows you to set the LCD display mode to any of the preceding parameters");
1866
lprintf(LOG_NOTICE, "");
1867
lprintf(LOG_NOTICE, " lcd set lcdqualifier {watt}|{btuphr}|{celsius}|{fahrenheit}");
1868
lprintf(LOG_NOTICE, " Allows you to set the unit for the system ambient temperature mode.");
1869
lprintf(LOG_NOTICE, "");
1870
lprintf(LOG_NOTICE, " lcd set errordisplay {sel}|{simple}");
1871
lprintf(LOG_NOTICE, " Allows you to set the error display.");
1872
lprintf(LOG_NOTICE, "");
1873
lprintf(LOG_NOTICE, " lcd info");
1874
lprintf(LOG_NOTICE, " Show LCD text that is displayed during non-fault conditions");
1875
lprintf(LOG_NOTICE, "");
1876
lprintf(LOG_NOTICE, "");
1877
lprintf(LOG_NOTICE, " lcd set vkvm{active}|{inactive}");
1878
lprintf(LOG_NOTICE, " Set vKVM active and inactive, message will be displayed on lcd");
1879
lprintf(LOG_NOTICE, " when vKVM is active and vKVM session is in progress");
1880
lprintf(LOG_NOTICE, "");
1881
lprintf(LOG_NOTICE, " lcd set frontpanelaccess {viewandmodify}|{viewonly}|{disabled}");
1882
lprintf(LOG_NOTICE, " Set LCD mode to view and modify, view only or disabled ");
1883
lprintf(LOG_NOTICE, "");
1884
lprintf(LOG_NOTICE, " lcd status");
1885
lprintf(LOG_NOTICE, " Show LCD Status for vKVM display<active|inactive>");
1886
lprintf(LOG_NOTICE, " and Front Panel access mode {viewandmodify}|{viewonly}|{disabled} ");
1887
lprintf(LOG_NOTICE, "");
1890
/*****************************************************************
1891
* Function Name: ipmi_delloem_mac_main
1893
* Description: This function processes the delloem mac command
1894
* Input: intf - ipmi interface
1895
argc - no of arguments
1896
argv - argument string array
1899
* Return: return code 0 - success
1902
******************************************************************/
1905
static int ipmi_delloem_mac_main (struct ipmi_intf * intf, int argc, char ** argv)
1911
if (argc > 1 && strcmp(argv[current_arg], "help") == 0)
1916
ipmi_idracvalidator_command(intf);
1919
rc = ipmi_macinfo(intf, 0xff);
1921
else if (strncmp(argv[current_arg], "list\0", 5) == 0)
1923
rc = ipmi_macinfo(intf, 0xff);
1925
else if (strncmp(argv[current_arg], "get\0", 4) == 0)
1928
if (argv[current_arg] == NULL)
1934
if(make_int(argv[current_arg],&currIdInt) < 0) {
1935
lprintf(LOG_ERR, "Invalid NIC number. The NIC number should be between 0-8\n");
1938
if( (currIdInt > 8) || (currIdInt < 0) )
1940
lprintf(LOG_ERR, "Invalid NIC number. The NIC number should be between 0-8\n");
1943
rc = ipmi_macinfo(intf, currIdInt);
1953
/*****************************************************************
1954
* Function Name: make_int
1956
* Description: This function convert string into integer
1957
* Input: str - decimal number string
1958
* Output: value - integer value
1961
******************************************************************/
1962
static int make_int(const char *str, int *value)
1965
*value = strtol(str,&tmp,0);
1966
if ( tmp-str != strlen(str) )
1977
EmbeddedNICMacAddressType EmbeddedNICMacAddress;
1979
EmbeddedNICMacAddressType_10G EmbeddedNICMacAddress_10G;
1981
static void InitEmbeddedNICMacAddressValues ()
1987
for (i=0;i<MAX_LOM;i++)
1989
EmbeddedNICMacAddress.LOMMacAddress[i].BladSlotNumber = 0;
1990
EmbeddedNICMacAddress.LOMMacAddress[i].MacType = LOM_MACTYPE_RESERVED;
1991
EmbeddedNICMacAddress.LOMMacAddress[i].EthernetStatus = LOM_ETHERNET_RESERVED;
1992
EmbeddedNICMacAddress.LOMMacAddress[i].NICNumber = 0;
1993
EmbeddedNICMacAddress.LOMMacAddress[i].Reserved = 0;
1994
for (j=0;j<MACADDRESSLENGH;j++)
1996
EmbeddedNICMacAddress.LOMMacAddress[i].MacAddressByte[j] = 0;
1997
EmbeddedNICMacAddress_10G.MacAddress[i].MacAddressByte[j] = 0;
2002
uint8_t UseVirtualMacAddress = 0;
2003
#define VIRTUAL_MAC_OFFSET (2)
2004
static int ipmi_macinfo_drac_idrac_virtual_mac(struct ipmi_intf* intf,uint8_t NicNum)
2006
struct ipmi_rs * rsp;
2009
uint8_t msg_data[30];
2010
uint8_t VirtualMacAddress [MACADDRESSLENGH];
2011
uint8_t input_length=0;
2015
if (0xff==NicNum || IDRAC_NIC_NUMBER==NicNum )
2017
UseVirtualMacAddress = 0;
2020
msg_data[input_length++] = 1; /*Get*/
2022
req.msg.netfn = DELL_OEM_NETFN;
2024
req.msg.cmd = GET_IDRAC_VIRTUAL_MAC;
2025
req.msg.data = msg_data;
2026
req.msg.data_len = input_length;
2028
rsp = intf->sendrecv(intf, &req);
2037
if( (IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_12G_MONOLITHIC== IMC_Type) ) {
2038
// Get the Chasiss Assigned MAC Addresss for 12g Only
2039
memcpy(VirtualMacAddress,((rsp->data)+1),MACADDRESSLENGH);
2041
for (i=0;i<MACADDRESSLENGH;i++)
2043
if (0 != VirtualMacAddress [i])
2045
UseVirtualMacAddress = 1;
2048
// Get the Server Assigned MAC Addresss for 12g Only
2049
if(!UseVirtualMacAddress) {
2050
memcpy(VirtualMacAddress,((rsp->data)+1+MACADDRESSLENGH),MACADDRESSLENGH);
2052
for (i=0;i<MACADDRESSLENGH;i++)
2054
if (0 != VirtualMacAddress [i])
2056
UseVirtualMacAddress = 1;
2061
memcpy(VirtualMacAddress,((rsp->data)+VIRTUAL_MAC_OFFSET),MACADDRESSLENGH);
2063
for (i=0;i<MACADDRESSLENGH;i++)
2065
if (0 != VirtualMacAddress [i])
2067
UseVirtualMacAddress = 1;
2071
if (0 == UseVirtualMacAddress)
2073
if (IMC_IDRAC_10G == IMC_Type)
2074
printf ("\nDRAC MAC Address ");
2075
else if ( (IMC_IDRAC_11G_MODULAR == IMC_Type) || (IMC_IDRAC_11G_MONOLITHIC== IMC_Type) )
2076
printf ("\niDRAC6 MAC Address ");
2077
else if ( (IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_12G_MONOLITHIC== IMC_Type) )
2078
printf ("\niDRAC7 MAC Address ");
2079
else if ( (IMC_MASER_LITE_BMC== IMC_Type) || (IMC_MASER_LITE_NU== IMC_Type) )
2080
printf ("\nBMC MAC Address ");
2082
printf ("\niDRAC6 MAC Address ");
2085
printf("%02x:",VirtualMacAddress[j]);
2086
printf("%02x",VirtualMacAddress[j]);
2095
/*****************************************************************
2096
* Function Name: ipmi_macinfo_drac_idrac_mac
2098
* Description: This function retrieves the mac address of DRAC or iDRAC
2103
******************************************************************/
2105
static int ipmi_macinfo_drac_idrac_mac(struct ipmi_intf* intf,uint8_t NicNum)
2107
struct ipmi_rs * rsp;
2110
uint8_t msg_data[30];
2111
uint8_t input_length=0;
2112
uint8_t iDRAC6MacAddressByte[MACADDRESSLENGH];
2115
ipmi_macinfo_drac_idrac_virtual_mac (intf,NicNum);
2118
if ((0xff==NicNum || IDRAC_NIC_NUMBER==NicNum) && 0 == UseVirtualMacAddress)
2123
msg_data[input_length++] = LAN_CHANNEL_NUMBER;
2124
msg_data[input_length++] = MAC_ADDR_PARAM;
2125
msg_data[input_length++] = 0x00;
2126
msg_data[input_length++] = 0x00;
2128
req.msg.netfn = TRANSPORT_NETFN;
2130
req.msg.cmd = GET_LAN_PARAM_CMD;
2131
req.msg.data = msg_data;
2132
req.msg.data_len = input_length;
2134
rsp = intf->sendrecv(intf, &req);
2137
lprintf(LOG_ERR, " Error in getting MAC Address");
2142
lprintf(LOG_ERR, " Error in getting MAC Address (%s) \n",
2143
val2str(rsp->ccode, completion_code_vals) );
2147
memcpy(iDRAC6MacAddressByte,((rsp->data)+PARAM_REV_OFFSET),MACADDRESSLENGH);
2149
if (IMC_IDRAC_10G == IMC_Type)
2150
printf ("\nDRAC MAC Address ");
2151
else if ((IMC_IDRAC_11G_MODULAR == IMC_Type) || (IMC_IDRAC_11G_MONOLITHIC== IMC_Type))
2152
printf ("\niDRAC6 MAC Address ");
2153
else if ((IMC_IDRAC_12G_MODULAR == IMC_Type) || (IMC_IDRAC_12G_MONOLITHIC== IMC_Type))
2154
printf ("\niDRAC7 MAC Address ");
2155
else if ( (IMC_MASER_LITE_BMC== IMC_Type) || (IMC_MASER_LITE_NU== IMC_Type) )
2156
printf ("\n\rBMC MAC Address ");
2158
printf ("\niDRAC6 MAC Address ");
2161
printf("%02x:",iDRAC6MacAddressByte[j]);
2162
printf("%02x",iDRAC6MacAddressByte[j]);
2170
/*****************************************************************
2171
* Function Name: ipmi_macinfo_10g
2173
* Description: This function retrieves the mac address of LOMs
2174
* Input: intf - ipmi interface
2179
******************************************************************/
2181
static int ipmi_macinfo_10g (struct ipmi_intf* intf, uint8_t NicNum)
2183
struct ipmi_rs * rsp;
2186
uint8_t msg_data[30];
2187
uint8_t input_length=0;
2192
uint8_t Total_No_NICs = 0;
2195
InitEmbeddedNICMacAddressValues ();
2197
memset(msg_data, 0, sizeof(msg_data));
2199
msg_data[input_length++] = 0x00; /* Get Parameter Command */
2200
msg_data[input_length++] = EMB_NIC_MAC_ADDRESS_9G_10G; /* OEM Param */
2202
msg_data[input_length++] = 0x00;
2203
msg_data[input_length++] = 0x00;
2205
memset(&req, 0, sizeof(req));
2207
req.msg.netfn = IPMI_NETFN_APP;
2209
req.msg.cmd = IPMI_GET_SYS_INFO;
2210
req.msg.data = msg_data;
2213
req.msg.data_len = input_length;
2215
rsp = intf->sendrecv(intf, &req);
2217
lprintf(LOG_ERR, " Error in getting MAC Address");
2220
if (rsp->ccode > 0) {
2221
lprintf(LOG_ERR, " Error in getting MAC Address (%s) \n",
2222
val2str(rsp->ccode, completion_code_vals) );
2226
Total_No_NICs = (uint8_t) rsp->data[0+PARAM_REV_OFFSET]; /* Byte 1: Total Number of Embedded NICs */
2228
if (IDRAC_NIC_NUMBER != NicNum)
2232
printf ("\nSystem LOMs");
2234
printf("\nNIC Number\tMAC Address\n");
2237
memcpy(&EmbeddedNICMacAddress_10G,((rsp->data)+PARAM_REV_OFFSET+TOTAL_N0_NICS_INDEX),Total_No_NICs* MACADDRESSLENGH);
2240
/*Read the LOM type and Mac Addresses */
2242
for (i=0;i<Total_No_NICs;i++)
2244
if ((0xff==NicNum) || (i == NicNum) )
2250
printf("%02x:",EmbeddedNICMacAddress_10G.MacAddress[i].MacAddressByte[j]);
2252
printf("%02x",EmbeddedNICMacAddress_10G.MacAddress[i].MacAddressByte[j]);
2259
ipmi_macinfo_drac_idrac_mac(intf,NicNum);
2266
/*****************************************************************
2267
* Function Name: ipmi_macinfo_11g
2269
* Description: This function retrieves the mac address of LOMs
2270
* Input: intf - ipmi interface
2274
******************************************************************/
2276
static int ipmi_macinfo_11g (struct ipmi_intf* intf, uint8_t NicNum)
2278
struct ipmi_rs * rsp;
2281
uint8_t msg_data[30];
2282
uint8_t input_length=0;
2292
len = 8; /*eigher 8 or 16 */
2294
loop_count = maxlen / len;
2296
InitEmbeddedNICMacAddressValues ();
2298
memset(msg_data, 0, sizeof(msg_data));
2300
msg_data[input_length++] = 0x00; /* Get Parameter Command */
2301
msg_data[input_length++] = EMB_NIC_MAC_ADDRESS_11G; /* OEM Param */
2303
msg_data[input_length++] = 0x00;
2304
msg_data[input_length++] = 0x00;
2305
msg_data[input_length++] = 0x00;
2306
msg_data[input_length++] = 0x00;
2308
memset(&req, 0, sizeof(req));
2310
req.msg.netfn = IPMI_NETFN_APP;
2312
req.msg.cmd = IPMI_GET_SYS_INFO;
2313
req.msg.data = msg_data;
2316
req.msg.data_len = input_length;
2318
rsp = intf->sendrecv(intf, &req);
2320
lprintf(LOG_ERR, " Error in getting MAC Address");
2323
if (rsp->ccode > 0) {
2324
lprintf(LOG_ERR, " Error in getting MAC Address (%s) \n",
2325
val2str(rsp->ccode, completion_code_vals) );
2329
len = 8; /*eigher 8 or 16 */
2330
maxlen = (uint8_t) rsp->data[0+PARAM_REV_OFFSET];
2331
loop_count = maxlen / len;
2333
if (IDRAC_NIC_NUMBER != NicNum)
2337
printf ("\nSystem LOMs");
2339
printf("\nNIC Number\tMAC Address\t\tStatus\n");
2342
/*Read the LOM type and Mac Addresses */
2344
for (i=0;i<loop_count;i++,offset=offset+len)
2347
msg_data[input_length++] = offset;
2348
msg_data[input_length++] = len;
2350
req.msg.netfn = IPMI_NETFN_APP;
2352
req.msg.cmd = IPMI_GET_SYS_INFO;
2353
req.msg.data = msg_data;
2354
req.msg.data_len = input_length;
2356
rsp = intf->sendrecv(intf, &req);
2358
lprintf(LOG_ERR, " Error in getting MAC Address");
2361
if (rsp->ccode > 0) {
2362
lprintf(LOG_ERR, " Error in getting MAC Address (%s) \n",
2363
val2str(rsp->ccode, completion_code_vals) );
2368
memcpy(&(EmbeddedNICMacAddress.LOMMacAddress[i]),((rsp->data)+PARAM_REV_OFFSET),len);
2371
if (LOM_MACTYPE_ETHERNET == EmbeddedNICMacAddress.LOMMacAddress[i].MacType)
2374
if ( (0xff==NicNum) || (NicNum == EmbeddedNICMacAddress.LOMMacAddress[i].NICNumber) )
2376
printf ("\n%d",EmbeddedNICMacAddress.LOMMacAddress[i].NICNumber);
2379
printf("%02x:",EmbeddedNICMacAddress.LOMMacAddress[i].MacAddressByte[j]);
2380
printf("%02x",EmbeddedNICMacAddress.LOMMacAddress[i].MacAddressByte[j]);
2382
if (LOM_ETHERNET_ENABLED == EmbeddedNICMacAddress.LOMMacAddress[i].EthernetStatus)
2383
printf ("\tEnabled");
2385
printf ("\tDisabled");
2394
ipmi_macinfo_drac_idrac_mac(intf,NicNum);
2402
/*****************************************************************
2403
* Function Name: ipmi_macinfo
2405
* Description: This function retrieves the mac address of LOMs
2406
* Input: intf - ipmi interface
2410
******************************************************************/
2412
static int ipmi_macinfo (struct ipmi_intf* intf, uint8_t NicNum)
2414
if (IMC_IDRAC_10G == IMC_Type)
2416
return ipmi_macinfo_10g (intf,NicNum);
2418
else if ((IMC_IDRAC_11G_MODULAR == IMC_Type || IMC_IDRAC_11G_MONOLITHIC== IMC_Type ) ||
2419
(IMC_IDRAC_12G_MODULAR == IMC_Type || IMC_IDRAC_12G_MONOLITHIC== IMC_Type ) ||
2420
(IMC_MASER_LITE_NU== IMC_Type || IMC_MASER_LITE_BMC== IMC_Type ))
2422
return ipmi_macinfo_11g (intf,NicNum);
2426
lprintf(LOG_ERR, " Error in getting MAC Address : Not supported platform");
2432
/*****************************************************************
2433
* Function Name: ipmi_mac_usage
2435
* Description: This function prints help message for mac command
2441
******************************************************************/
2444
ipmi_mac_usage(void)
2446
lprintf(LOG_NOTICE, "");
2447
lprintf(LOG_NOTICE, " mac list");
2448
lprintf(LOG_NOTICE, " Lists the MAC address of LOMs");
2449
lprintf(LOG_NOTICE, "");
2450
lprintf(LOG_NOTICE, " mac get <NIC number>");
2451
lprintf(LOG_NOTICE, " Shows the MAC address of specified LOM. 0-7 System LOM, 8- DRAC/iDRAC.");
2452
lprintf(LOG_NOTICE, "");
2455
/*****************************************************************
2456
* Function Name: ipmi_delloem_lan_main
2458
* Description: This function processes the delloem lan command
2459
* Input: intf - ipmi interface
2460
argc - no of arguments
2461
argv - argument string array
2464
* Return: return code 0 - success
2467
******************************************************************/
2469
static int ipmi_delloem_lan_main (struct ipmi_intf * intf, int argc, char ** argv)
2473
int nic_selection = 0;
2474
char nic_set[2] = {0};
2476
if (argv[current_arg] == NULL || strcmp(argv[current_arg], "help") == 0)
2481
ipmi_idracvalidator_command(intf);
2482
if (!IsLANSupported())
2484
printf("lan is not supported on this system.\n");
2487
else if (strncmp(argv[current_arg], "set\0", 4) == 0)
2490
if (argv[current_arg] == NULL)
2495
if(iDRAC_FLAG == IDRAC_12G) {
2496
nic_selection = get_nic_selection_mode_12g(intf,current_arg,argv,nic_set);
2497
if (INVALID == nic_selection)
2501
} else if(INVAILD_FAILOVER_MODE == nic_selection) {
2502
printf(INVAILD_FAILOVER_MODE_STRING);
2504
} else if(INVAILD_FAILOVER_MODE_SETTINGS == nic_selection){
2505
printf(INVAILD_FAILOVER_MODE_SET);
2507
} else if(INVAILD_SHARED_MODE == nic_selection){
2508
printf(INVAILD_SHARED_MODE_SET_STRING);
2512
rc = ipmi_lan_set_nic_selection_12g(intf,nic_set);
2516
nic_selection = get_nic_selection_mode(current_arg,argv);
2519
if (INVALID == nic_selection)
2524
if(IMC_IDRAC_11G_MODULAR == IMC_Type) {
2525
printf(INVAILD_SHARED_MODE_SET_STRING);
2528
rc = ipmi_lan_set_nic_selection(intf,nic_selection);
2532
else if (strncmp(argv[current_arg], "get\0", 4) == 0)
2535
if (argv[current_arg] == NULL)
2537
rc = ipmi_lan_get_nic_selection(intf);
2540
else if (strncmp(argv[current_arg], "active\0", 7) == 0)
2542
rc = ipmi_lan_get_active_nic(intf);
2560
static int IsLANSupported ()
2562
if (IMC_IDRAC_11G_MODULAR == IMC_Type)
2568
int get_nic_selection_mode_12g (struct ipmi_intf* intf,int current_arg, char ** argv, char *nic_set)
2570
int nic_selection_mode = 0;
2573
// First get the current settings.
2574
struct ipmi_rs * rsp;
2577
uint8_t msg_data[30];
2578
uint8_t input_length=0;
2582
req.msg.netfn = DELL_OEM_NETFN;
2585
req.msg.cmd = GET_NIC_SELECTION_12G_CMD;
2587
req.msg.data = msg_data;
2588
req.msg.data_len = input_length;
2590
rsp = intf->sendrecv(intf, &req);
2593
lprintf(LOG_ERR, " Error in getting nic selection");
2596
else if (rsp->ccode > 0)
2598
lprintf(LOG_ERR, " Error in getting nic selection (%s) \n",
2599
val2str(rsp->ccode, completion_code_vals) );
2603
nic_set[0] = rsp->data[0];
2604
nic_set[1] = rsp->data[1];
2607
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "dedicated\0", 10))
2613
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "shared\0", 7))
2621
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "with\0", 5))
2628
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "failover\0", 9))
2634
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "lom1\0", 5))
2636
if(IMC_IDRAC_12G_MODULAR == IMC_Type)
2638
return INVAILD_SHARED_MODE;
2643
return INVAILD_FAILOVER_MODE;
2644
} else if(nic_set[0] == 1) {
2645
return INVAILD_FAILOVER_MODE_SETTINGS;
2657
else if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "lom2\0", 5))
2660
if(IMC_IDRAC_12G_MODULAR == IMC_Type)
2662
return INVAILD_SHARED_MODE;
2667
return INVAILD_FAILOVER_MODE;
2668
} else if(nic_set[0] == 1) {
2669
return INVAILD_FAILOVER_MODE_SETTINGS;
2680
else if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "lom3\0", 5))
2683
if(IMC_IDRAC_12G_MODULAR == IMC_Type)
2685
return INVAILD_SHARED_MODE;
2690
return INVAILD_FAILOVER_MODE;
2691
} else if(nic_set[0] == 1) {
2692
return INVAILD_FAILOVER_MODE_SETTINGS;
2705
else if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "lom4\0", 5))
2708
if(IMC_IDRAC_12G_MODULAR == IMC_Type)
2710
return INVAILD_SHARED_MODE;
2715
return INVAILD_FAILOVER_MODE;
2716
} else if(nic_set[0] == 1) {
2717
return INVAILD_FAILOVER_MODE_SETTINGS;
2729
else if (failover && NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "none\0", 5))
2732
if(IMC_IDRAC_12G_MODULAR == IMC_Type)
2734
return INVAILD_SHARED_MODE;
2737
if(nic_set[0] == 1) {
2738
return INVAILD_FAILOVER_MODE_SETTINGS;
2744
else if (failover && NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "all\0", 4))
2751
if (failover && NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "loms\0", 5))
2754
if(IMC_IDRAC_12G_MODULAR == IMC_Type)
2756
return INVAILD_SHARED_MODE;
2758
if(nic_set[0] == 1) {
2759
return INVAILD_FAILOVER_MODE_SETTINGS;
2770
static int get_nic_selection_mode (int current_arg, char ** argv)
2772
int nic_selection_mode = 0;
2773
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "dedicated\0", 10))
2777
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "shared\0", 7))
2779
if (NULL == argv[current_arg+1] )
2783
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "with\0", 5))
2790
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "failover\0", 9))
2797
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "lom2\0", 5))
2799
return SHARED_WITH_FAILOVER_LOM2;
2801
else if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "all\0", 4))
2808
if (NULL!= argv[current_arg] && 0 == strncmp(argv[current_arg], "loms\0", 5))
2810
return SHARED_WITH_FAILOVER_ALL_LOMS;
2818
static int ipmi_lan_set_nic_selection_12g (struct ipmi_intf* intf, uint8_t* nic_selection)
2820
struct ipmi_rs * rsp;
2823
uint8_t msg_data[30];
2824
uint8_t input_length=0;
2828
msg_data[input_length++] = nic_selection[0];
2829
msg_data[input_length++] = nic_selection[1];
2831
req.msg.netfn = DELL_OEM_NETFN;
2833
req.msg.cmd = SET_NIC_SELECTION_12G_CMD;
2834
req.msg.data = msg_data;
2835
req.msg.data_len = input_length;
2837
rsp = intf->sendrecv(intf, &req);
2840
lprintf(LOG_ERR, " Error in setting nic selection");
2843
// Check license only for setting the dedicated nic.
2844
else if( (nic_selection[0] == 1) && ((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED))) {
2845
printf("FM001 : A required license is missing or expired\n");
2848
else if (rsp->ccode > 0)
2850
lprintf(LOG_ERR, " Error in setting nic selection (%s) \n",
2851
val2str(rsp->ccode, completion_code_vals) );
2854
printf("configured successfully");
2860
static int ipmi_lan_set_nic_selection (struct ipmi_intf* intf, uint8_t nic_selection)
2862
struct ipmi_rs * rsp;
2865
uint8_t msg_data[30];
2866
uint8_t input_length=0;
2870
msg_data[input_length++] = nic_selection;
2872
req.msg.netfn = DELL_OEM_NETFN;
2874
req.msg.cmd = SET_NIC_SELECTION_CMD;
2875
req.msg.data = msg_data;
2876
req.msg.data_len = input_length;
2878
rsp = intf->sendrecv(intf, &req);
2881
lprintf(LOG_ERR, " Error in setting nic selection");
2884
else if (rsp->ccode > 0)
2886
lprintf(LOG_ERR, " Error in setting nic selection (%s) \n",
2887
val2str(rsp->ccode, completion_code_vals) );
2890
printf("configured successfully");
2895
static int ipmi_lan_get_nic_selection (struct ipmi_intf* intf)
2897
uint8_t nic_selection=-1;
2898
uint8_t nic_selection_failover = 0;
2900
struct ipmi_rs * rsp;
2903
uint8_t msg_data[30];
2904
uint8_t input_length=0;
2908
req.msg.netfn = DELL_OEM_NETFN;
2910
if(iDRAC_FLAG == IDRAC_12G)
2911
req.msg.cmd = GET_NIC_SELECTION_12G_CMD;
2913
req.msg.cmd = GET_NIC_SELECTION_CMD;
2914
req.msg.data = msg_data;
2915
req.msg.data_len = input_length;
2917
rsp = intf->sendrecv(intf, &req);
2920
lprintf(LOG_ERR, " Error in getting nic selection");
2923
else if (rsp->ccode > 0)
2925
lprintf(LOG_ERR, " Error in getting nic selection (%s) \n",
2926
val2str(rsp->ccode, completion_code_vals) );
2929
nic_selection = rsp->data[0];
2931
if(iDRAC_FLAG == IDRAC_12G)
2934
nic_selection_failover = rsp->data[1];
2935
if ((nic_selection < 6) && (nic_selection > 0) && (nic_selection_failover < 7))
2937
if(nic_selection == 1) {
2938
printf ("%s\n",NIC_Selection_Mode_String_12g[nic_selection-1]);
2939
} else if(nic_selection) {
2940
printf ("Shared LOM : %s\n",NIC_Selection_Mode_String_12g[nic_selection-1]);
2941
if(nic_selection_failover == 0)
2942
printf ("Failover LOM : None\n");
2943
else if(nic_selection_failover >= 2 && nic_selection_failover <= 6)
2944
printf ("Failover LOM : %s\n",NIC_Selection_Mode_String_12g[nic_selection_failover + 3]);
2950
lprintf(LOG_ERR, " Error Outof bond Value received (%d) (%d) \n",nic_selection,nic_selection_failover);
2956
printf ("%s\n",NIC_Selection_Mode_String[nic_selection]);
2962
static int ipmi_lan_get_active_nic (struct ipmi_intf* intf)
2964
uint8_t active_nic=0;
2965
uint8_t current_lom =0;
2967
struct ipmi_rs * rsp;
2970
uint8_t msg_data[30];
2971
uint8_t input_length=0;
2975
msg_data[input_length++] = 0; /*Get Status*/
2976
msg_data[input_length++] = 0; /*Reserved*/
2977
msg_data[input_length++] = 0; /*Reserved*/
2979
req.msg.netfn = DELL_OEM_NETFN;
2981
req.msg.cmd = GET_ACTIVE_NIC_CMD;
2982
req.msg.data = msg_data;
2983
req.msg.data_len = input_length;
2985
rsp = intf->sendrecv(intf, &req);
2988
lprintf(LOG_ERR, " Error in getting Active LOM Status");
2991
else if (rsp->ccode > 0)
2993
lprintf(LOG_ERR, " Error in getting Active LOM Status (%s) \n",
2994
val2str(rsp->ccode, completion_code_vals) );
2998
current_lom = rsp->data[0];
3002
msg_data[input_length++] = 1; //Get Link status
3003
msg_data[input_length++] = 0; //Reserved
3004
msg_data[input_length++] = 0; //Reserved
3006
req.msg.netfn = DELL_OEM_NETFN;
3008
req.msg.cmd = GET_ACTIVE_NIC_CMD;
3009
req.msg.data = msg_data;
3010
req.msg.data_len = input_length;
3012
rsp = intf->sendrecv(intf, &req);
3015
lprintf(LOG_ERR, " Error in getting Active LOM Status");
3018
else if (rsp->ccode > 0)
3020
lprintf(LOG_ERR, " Error in getting Active LOM Status (%s) \n",
3021
val2str(rsp->ccode, completion_code_vals) );
3024
active_nic = rsp->data[1];
3025
if (current_lom < 6 && active_nic)
3026
printf ("\n%s\n",AciveLOM_String[current_lom]);
3028
printf ("\n%s\n",AciveLOM_String[0]);
3035
ipmi_lan_usage(void)
3037
lprintf(LOG_NOTICE, "");
3038
lprintf(LOG_NOTICE, " lan set <Mode> ");
3040
lprintf(LOG_NOTICE, " sets the NIC Selection Mode :");
3041
lprintf(LOG_NOTICE, " on iDRAC12g :");
3043
lprintf(LOG_NOTICE, " dedicated, shared with lom1, shared with lom2,shared with lom3,shared ");
3044
lprintf(LOG_NOTICE, " with lom4,shared with failover lom1,shared with failover lom2,shared ");
3045
lprintf(LOG_NOTICE, " with failover lom3,shared with failover lom4,shared with Failover all ");
3046
lprintf(LOG_NOTICE, " loms, shared with Failover None).");
3047
lprintf(LOG_NOTICE, " on other systems :");
3048
lprintf(LOG_NOTICE, " dedicated, shared, shared with failover lom2,");
3049
lprintf(LOG_NOTICE, " shared with Failover all loms.");
3050
lprintf(LOG_NOTICE, "");
3051
lprintf(LOG_NOTICE, " lan get ");
3052
lprintf(LOG_NOTICE, " on iDRAC12g :");
3053
lprintf(LOG_NOTICE, " returns the current NIC Selection Mode (dedicated, shared with lom1, shared ");
3054
lprintf(LOG_NOTICE, " with lom2, shared with lom3, shared with lom4,shared with failover lom1,");
3055
lprintf(LOG_NOTICE, " shared with failover lom2,shared with failover lom3,shared with failover ");
3056
lprintf(LOG_NOTICE, " lom4,shared with Failover all loms,shared with Failover None).");
3057
lprintf(LOG_NOTICE, " on other systems :");
3058
lprintf(LOG_NOTICE, " dedicated, shared, shared with failover,");
3059
lprintf(LOG_NOTICE, " lom2, shared with Failover all loms.");
3060
lprintf(LOG_NOTICE, "");
3061
lprintf(LOG_NOTICE, " lan get active");
3062
lprintf(LOG_NOTICE, " returns the current active NIC (dedicated, LOM1, LOM2, LOM3, LOM4).");
3063
lprintf(LOG_NOTICE, "");
3067
/*****************************************************************
3068
* Function Name: ipmi_delloem_powermonitor_main
3070
* Description: This function processes the delloem powermonitor command
3071
* Input: intf - ipmi interface
3072
argc - no of arguments
3073
argv - argument string array
3076
* Return: return code 0 - success
3079
******************************************************************/
3081
static int ipmi_delloem_powermonitor_main (struct ipmi_intf * intf, int argc, char ** argv)
3086
if (argc > 1 && strcmp(argv[current_arg], "help") == 0)
3088
ipmi_powermonitor_usage();
3091
ipmi_idracvalidator_command(intf);
3094
rc = ipmi_powermgmt(intf);
3096
else if (strncmp(argv[current_arg], "status\0", 7) == 0)
3098
rc = ipmi_powermgmt(intf);
3101
else if (strncmp(argv[current_arg], "clear\0", 6) == 0)
3104
if (argv[current_arg] == NULL)
3106
ipmi_powermonitor_usage();
3109
else if (strncmp(argv[current_arg], "peakpower\0", 10) == 0)
3111
rc = ipmi_powermgmt_clear(intf, 1);
3113
else if (strncmp(argv[current_arg], "cumulativepower\0", 16) == 0)
3115
rc = ipmi_powermgmt_clear(intf, 0);
3119
ipmi_powermonitor_usage();
3126
else if (strncmp(argv[current_arg], "powerconsumption\0", 17) == 0)
3130
if (argv[current_arg] == NULL)
3133
rc=ipmi_print_get_power_consmpt_data(intf,watt);
3136
else if (strncmp(argv[current_arg], "watt\0", 5) == 0)
3139
rc = ipmi_print_get_power_consmpt_data(intf, watt);
3141
else if (strncmp(argv[current_arg], "btuphr\0", 7) == 0)
3143
rc = ipmi_print_get_power_consmpt_data(intf, btuphr);
3147
ipmi_powermonitor_usage();
3151
else if (strncmp(argv[current_arg], "powerconsumptionhistory\0", 23) == 0)
3154
if (argv[current_arg] == NULL)
3156
rc=ipmi_print_power_consmpt_history(intf,watt);
3159
else if (strncmp(argv[current_arg], "watt\0", 5) == 0)
3161
rc = ipmi_print_power_consmpt_history(intf, watt);
3163
else if (strncmp(argv[current_arg], "btuphr\0", 7) == 0)
3165
rc = ipmi_print_power_consmpt_history(intf, btuphr);
3169
ipmi_powermonitor_usage();
3175
else if (strncmp(argv[current_arg], "getpowerbudget\0", 15) == 0)
3178
if (argv[current_arg] == NULL)
3180
rc=ipmi_print_power_cap(intf,watt);
3183
else if (strncmp(argv[current_arg], "watt\0", 5) == 0)
3185
rc = ipmi_print_power_cap(intf, watt);
3187
else if (strncmp(argv[current_arg], "btuphr\0", 7) == 0)
3189
rc = ipmi_print_power_cap(intf, btuphr);
3193
ipmi_powermonitor_usage();
3199
else if (strncmp(argv[current_arg], "setpowerbudget\0", 15) == 0)
3203
if (argv[current_arg] == NULL)
3205
ipmi_powermonitor_usage();
3208
if (strchr(argv[current_arg], '.'))
3210
lprintf(LOG_ERR, " Cap value in Watts, Btu/hr or percent should be whole number");
3213
make_int(argv[current_arg],&val);
3215
if (argv[current_arg] == NULL)
3217
ipmi_powermonitor_usage();
3219
else if (strncmp(argv[current_arg], "watt\0", 5) == 0)
3221
rc=ipmi_set_power_cap(intf,watt,val);
3223
else if (strncmp(argv[current_arg], "btuphr\0", 7) == 0)
3225
rc=ipmi_set_power_cap(intf, btuphr,val);
3227
else if (strncmp(argv[current_arg], "percent\0", 8) == 0)
3229
rc=ipmi_set_power_cap(intf,percent,val);
3233
ipmi_powermonitor_usage();
3239
else if (strncmp(argv[current_arg], "enablepowercap\0", 15) == 0)
3241
ipmi_set_power_capstatus_command(intf,1);
3244
else if (strncmp(argv[current_arg], "disablepowercap\0", 16) == 0)
3246
ipmi_set_power_capstatus_command(intf,0);
3250
ipmi_powermonitor_usage();
3257
/*****************************************************************
3258
* Function Name: ipmi_time_to_str
3260
* Description: This function converts ipmi time format into gmtime format
3261
* Input: rawTime - ipmi time format
3262
* Output: strTime - gmtime format
3266
******************************************************************/
3269
ipmi_time_to_str(time_t rawTime, char* strTime)
3273
tm = gmtime(&rawTime);
3277
strcpy(strTime,temp);
3280
/*****************************************************************
3281
* Function Name: ipmi_get_sensor_reading
3283
* Description: This function retrieves a raw sensor reading
3284
* Input: sensorOwner - sensor owner id
3285
* sensorNumber - sensor id
3286
* intf - ipmi interface
3287
* Output: sensorReadingData - ipmi response structure
3288
* Return: 1 on error
3291
******************************************************************/
3293
ipmi_get_sensor_reading(struct ipmi_intf *intf ,
3294
unsigned char sensorNumber,
3295
SensorReadingType* pSensorReadingData)
3298
struct ipmi_rs * rsp;
3301
memset(&req, 0, sizeof (req));
3302
req.msg.netfn = IPMI_NETFN_SE;
3304
req.msg.cmd = GET_SENSOR_READING;
3305
req.msg.data = &sensorNumber;
3306
req.msg.data_len = 1;
3308
if (NULL == pSensorReadingData)
3310
memset(pSensorReadingData,0, sizeof(SensorReadingType));
3312
rsp = intf->sendrecv(intf, &req);
3315
} else if (rsp->ccode > 0) {
3319
memcpy(pSensorReadingData, rsp->data, sizeof(SensorReadingType));
3321
/* if there is an error transmitting ipmi command, return error*/
3322
if (rsp->ccode != 0) {
3326
/* if sensor messages are disabled, return error*/
3327
if ((!(rsp->data[1]& 0xC0)) || ((rsp->data[1] & 0x20))) {
3334
/*****************************************************************
3335
* Function Name: ipmi_get_power_capstatus_command
3337
* Description: This function gets the power cap status
3338
* Input: intf - ipmi interface
3339
* Global: PowercapSetable_flag - power cap status
3344
******************************************************************/
3346
ipmi_get_power_capstatus_command (struct ipmi_intf * intf)
3348
struct ipmi_rs * rsp = NULL;
3349
struct ipmi_rq req = {0};
3352
req.msg.netfn = DELL_OEM_NETFN;
3354
req.msg.cmd = IPMI_DELL_POWER_CAP_STATUS;
3355
req.msg.data_len = 2;
3356
req.msg.data = data;
3360
rsp = intf->sendrecv(intf, &req);
3362
lprintf(LOG_ERR, " Error getting powercap status");
3364
} else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
3365
printf("FM001 : A required license is missing or expired\n");
3366
return -1; // Return Error as unlicensed
3367
} else if (rsp->ccode > 0) {
3368
lprintf(LOG_ERR, " Error getting powercap statusr: %s",
3369
val2str(rsp->ccode, completion_code_vals));
3372
if (rsp->data[0]&0x02)
3373
PowercapSetable_flag=1;
3374
if(rsp->data[0]&0x01)
3375
PowercapstatusFlag=1;
3379
/*****************************************************************
3380
* Function Name: ipmi_set_power_capstatus_command
3382
* Description: This function sets the power cap status
3383
* Input: intf - ipmi interface
3384
* val - power cap status
3389
******************************************************************/
3392
ipmi_set_power_capstatus_command (struct ipmi_intf * intf,uint8_t val)
3394
struct ipmi_rs * rsp = NULL;
3395
struct ipmi_rq req = {0};
3397
if(ipmi_get_power_capstatus_command(intf) < 0)
3400
if (PowercapSetable_flag!=1)
3402
lprintf(LOG_ERR, " Can not set powercap on this system");
3405
req.msg.netfn = DELL_OEM_NETFN;
3407
req.msg.cmd = IPMI_DELL_POWER_CAP_STATUS;
3408
req.msg.data_len = 2;
3409
req.msg.data = data;
3414
rsp = intf->sendrecv(intf, &req);
3416
lprintf(LOG_ERR, " Error setting powercap status");
3418
} else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
3419
printf("FM001 : A required license is missing or expired\n");
3420
return -1; //return unlicensed Error code
3421
} else if (rsp->ccode > 0) {
3422
lprintf(LOG_ERR, " Error setting powercap statusr: %s",
3423
val2str(rsp->ccode, completion_code_vals));
3432
/*****************************************************************
3433
* Function Name: ipmi_powermgmt
3435
* Description: This function print the powermonitor details
3436
* Input: intf - ipmi interface
3441
******************************************************************/
3442
static int ipmi_powermgmt(struct ipmi_intf* intf)
3448
struct ipmi_rs * rsp;
3450
uint8_t msg_data[2];
3451
uint32_t cumStartTimeConv;
3452
uint32_t cumReadingConv;
3453
uint32_t maxPeakStartTimeConv;
3454
uint32_t ampPeakTimeConv;
3455
uint16_t ampReadingConv;
3456
uint32_t wattPeakTimeConv;
3457
uint32_t wattReadingConv;
3458
uint32_t bmctimeconv;
3459
uint32_t * bmctimeconvval;
3461
IPMI_POWER_MONITOR* pwrMonitorInfo;
3464
char cumStartTime[26];
3465
char maxPeakStartTime[26];
3466
char ampPeakTime[26];
3467
char wattPeakTime[26];
3472
int ampReadingRemainder;
3478
memset(&req, 0, sizeof(req));
3479
req.msg.netfn = IPMI_NETFN_STORAGE;
3481
req.msg.cmd = IPMI_CMD_GET_SEL_TIME;
3483
rsp = intf->sendrecv(intf, &req);
3485
lprintf(LOG_ERR, " Error getting BMC time info.\n");
3488
if (rsp->ccode != 0) {
3489
printf("Error getting power management information, return code %x\n", rsp->ccode);
3492
bmctimeconvval=(uint32_t*)rsp->data;
3494
bmctimeconv=BSWAP_32(*bmctimeconvval);
3496
bmctimeconv=*bmctimeconvval;
3499
/* get powermanagement info*/
3500
req.msg.netfn = DELL_OEM_NETFN;
3502
req.msg.cmd = GET_PWRMGMT_INFO_CMD;
3503
req.msg.data = msg_data;
3504
req.msg.data_len = 2;
3506
memset(msg_data, 0, 2);
3510
rsp = intf->sendrecv(intf, &req);
3512
lprintf(LOG_ERR, " Error getting power management information.\n");
3516
if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
3517
printf("FM001 : A required license is missing or expired\n");
3519
} else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb)) {
3520
lprintf(LOG_ERR, " Error getting power management information: Command not supported on this system.");
3522
}else if (rsp->ccode != 0) {
3523
printf("Error getting power management information, return code %x\n", rsp->ccode);
3529
pwrMonitorInfo = (IPMI_POWER_MONITOR*)rsp->data;
3531
cumStartTimeConv = BSWAP_32(pwrMonitorInfo->cumStartTime);
3532
cumReadingConv = BSWAP_32(pwrMonitorInfo->cumReading);
3533
maxPeakStartTimeConv = BSWAP_32(pwrMonitorInfo->maxPeakStartTime);
3534
ampPeakTimeConv = BSWAP_32(pwrMonitorInfo->ampPeakTime);
3535
ampReadingConv = BSWAP_16(pwrMonitorInfo->ampReading);
3536
wattPeakTimeConv = BSWAP_32(pwrMonitorInfo->wattPeakTime);
3537
wattReadingConv = BSWAP_16(pwrMonitorInfo->wattReading);
3539
cumStartTimeConv = pwrMonitorInfo->cumStartTime;
3540
cumReadingConv = pwrMonitorInfo->cumReading;
3541
maxPeakStartTimeConv = pwrMonitorInfo->maxPeakStartTime;
3542
ampPeakTimeConv = pwrMonitorInfo->ampPeakTime;
3543
ampReadingConv = pwrMonitorInfo->ampReading;
3544
wattPeakTimeConv = pwrMonitorInfo->wattPeakTime;
3545
wattReadingConv = pwrMonitorInfo->wattReading;
3548
ipmi_time_to_str(cumStartTimeConv, cumStartTime);
3550
ipmi_time_to_str(maxPeakStartTimeConv, maxPeakStartTime);
3551
ipmi_time_to_str(ampPeakTimeConv, ampPeakTime);
3552
ipmi_time_to_str(wattPeakTimeConv, wattPeakTime);
3553
ipmi_time_to_str(bmctimeconv, bmctime);
3561
remainder = (cumReadingConv % 1000);
3562
cumReadingConv = cumReadingConv / 1000;
3563
remainder = (remainder + 50) / 100;
3565
ampReading = ampReadingConv;
3566
ampReadingRemainder = ampReading%10;
3567
ampReading = ampReading/10;
3569
wattReading = wattReadingConv;
3571
printf("Power Tracking Statistics\n");
3572
printf("Statistic : Cumulative Energy Consumption\n");
3573
printf("Start Time : %s", cumStartTime);
3574
printf("Finish Time : %s", bmctime);
3575
printf("Reading : %d.%d kWh\n\n", cumReadingConv, remainder);
3577
printf("Statistic : System Peak Power\n");
3578
printf("Start Time : %s", maxPeakStartTime);
3579
printf("Peak Time : %s", wattPeakTime);
3580
printf("Peak Reading : %d W\n\n", wattReading);
3582
printf("Statistic : System Peak Amperage\n");
3583
printf("Start Time : %s", maxPeakStartTime);
3584
printf("Peak Time : %s", ampPeakTime);
3585
printf("Peak Reading : %d.%d A\n", ampReading, ampReadingRemainder);
3591
/*****************************************************************
3592
* Function Name: ipmi_powermgmt_clear
3594
* Description: This function clears peakpower / cumulativepower value
3595
* Input: intf - ipmi interface
3596
* clearValue - peakpower / cumulativepower
3601
******************************************************************/
3603
ipmi_powermgmt_clear(struct ipmi_intf* intf,uint8_t clearValue)
3605
struct ipmi_rs * rsp;
3608
uint8_t msg_data[3];
3616
/* clear powermanagement info*/
3617
req.msg.netfn = DELL_OEM_NETFN;
3619
req.msg.cmd = CLEAR_PWRMGMT_INFO_CMD;
3620
req.msg.data = msg_data;
3621
req.msg.data_len = 3;
3624
memset(msg_data, 0, 3);
3627
msg_data[2] = clearType;
3631
rsp = intf->sendrecv(intf, &req);
3633
lprintf(LOG_ERR, " Error clearing power values.\n");
3635
} else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
3636
printf("FM001 : A required license is missing or expired\n");
3638
} else if (rsp->ccode == 0xc1) {
3639
lprintf(LOG_ERR, " Error clearing power values, command not supported on this system.\n");
3641
} else if (rsp->ccode != 0){
3642
lprintf(LOG_ERR, " Error clearing power values: %s",
3643
val2str(rsp->ccode, completion_code_vals));
3650
/*****************************************************************
3651
* Function Name: watt_to_btuphr_conversion
3653
* Description: This function converts the power value in watt to btuphr
3654
* Input: powerinwatt - power in watt
3656
* Output: power in btuphr
3660
******************************************************************/
3661
static uint64_t watt_to_btuphr_conversion(uint32_t powerinwatt)
3663
uint64_t powerinbtuphr;
3664
powerinbtuphr=(3.413*powerinwatt);
3666
return(powerinbtuphr);
3671
/*****************************************************************
3672
* Function Name: btuphr_to_watt_conversion
3674
* Description: This function converts the power value in btuphr to watt
3675
* Input: powerinbtuphr - power in btuphr
3677
* Output: power in watt
3681
******************************************************************/
3682
static uint32_t btuphr_to_watt_conversion(uint64_t powerinbtuphr)
3684
uint32_t powerinwatt;
3685
/*returning the floor value*/
3686
powerinwatt= (powerinbtuphr/3.413);
3687
return (powerinwatt);
3690
/*****************************************************************
3691
* Function Name: ipmi_get_power_headroom_command
3693
* Description: This function prints the Power consumption information
3694
* Input: intf - ipmi interface
3695
* unit - watt / btuphr
3700
******************************************************************/
3701
static int ipmi_get_power_headroom_command (struct ipmi_intf * intf,uint8_t unit)
3703
struct ipmi_rs * rsp = NULL;
3704
struct ipmi_rq req = {0};
3705
uint64_t peakpowerheadroombtuphr;
3706
uint64_t instantpowerhearoom;
3708
req.msg.netfn = DELL_OEM_NETFN;
3710
req.msg.cmd = GET_PWR_HEADROOM_CMD;
3711
req.msg.data_len = 0;
3713
rsp = intf->sendrecv(intf, &req);
3715
lprintf(LOG_ERR, " Error getting power headroom status");
3717
} else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
3718
printf("FM001 : A required license is missing or expired\n");
3720
} else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb)){
3721
lprintf(LOG_ERR, " Error getting power headroom status: Command not supported on this system ");
3723
} else if (rsp->ccode > 0) {
3724
lprintf(LOG_ERR, " Error getting power headroom status: %s",
3725
val2str(rsp->ccode, completion_code_vals));
3729
printf("power headroom Data : %x %x %x %x ",
3730
/*need to look into */ rsp->data[0], rsp->data[1], rsp->data[2], rsp->data[3]);
3731
powerheadroom= *(( POWER_HEADROOM *)rsp->data);
3733
powerheadroom.instheadroom = BSWAP_16(powerheadroom.instheadroom);
3734
powerheadroom.peakheadroom = BSWAP_16(powerheadroom.peakheadroom);
3737
printf ("Headroom\n");
3738
printf ("Statistic Reading\n");
3742
peakpowerheadroombtuphr=watt_to_btuphr_conversion(powerheadroom.peakheadroom);
3743
instantpowerhearoom= watt_to_btuphr_conversion(powerheadroom.instheadroom);
3745
printf ("System Instantaneous Headroom : %lld BTU/hr\n",instantpowerhearoom);
3746
printf ("System Peak Headroom : %lld BTU/hr\n",peakpowerheadroombtuphr);
3750
printf ("System Instantaneous Headroom : %d W\n",powerheadroom.instheadroom);
3751
printf ("System Peak Headroom : %d W\n",powerheadroom.peakheadroom);
3759
/*****************************************************************
3760
* Function Name: ipmi_get_power_consumption_data
3762
* Description: This function updates the instant Power consumption information
3763
* Input: intf - ipmi interface
3764
* Output: power consumption current reading
3765
* Assumption value will be in Watt.
3769
******************************************************************/
3770
static int ipmi_get_power_consumption_data(struct ipmi_intf* intf,uint8_t unit)
3772
SensorReadingType sensorReadingData;
3774
struct ipmi_rs * rsp=NULL;
3775
struct sdr_record_list *sdr;
3776
int readingbtuphr=0;
3777
int warning_threshbtuphr=0;
3778
int failure_threshbtuphr=0;
3780
int sensor_number = 0;
3783
sdr = ipmi_sdr_find_sdr_byid(intf, "System Level");
3786
printf ("Error : Can not access the System Level sensor data \n\n");
3790
sensor_number = sdr->record.common->keys.sensor_num;
3791
ipmi_get_sensor_reading (intf,sensor_number,&sensorReadingData);
3793
rsp = ipmi_sdr_get_sensor_thresholds(intf,
3794
sdr->record.common->keys.sensor_num,
3795
sdr->record.common->keys.owner_id,
3796
sdr->record.common->keys.lun,
3797
sdr->record.common->keys.channel);
3799
if (rsp != NULL && rsp->ccode == 0)
3801
readingbtuphr=sdr_convert_sensor_reading
3802
(sdr->record.full, sensorReadingData.sensorReading);
3803
warning_threshbtuphr=sdr_convert_sensor_reading
3804
(sdr->record.full, rsp->data[4]);
3805
failure_threshbtuphr=sdr_convert_sensor_reading
3806
(sdr->record.full, rsp->data[5]);
3808
printf ("System Board System Level\n");
3811
readingbtuphr= watt_to_btuphr_conversion(readingbtuphr);
3812
warning_threshbtuphr= watt_to_btuphr_conversion(warning_threshbtuphr);
3813
failure_threshbtuphr= watt_to_btuphr_conversion( failure_threshbtuphr);
3815
printf ("Reading : %d BTU/hr\n",readingbtuphr);
3816
printf ("Warning threshold : %d BTU/hr\n",warning_threshbtuphr);
3817
printf ("Failure threshold : %d BTU/hr\n",failure_threshbtuphr);
3821
printf ("Reading : %d W \n",readingbtuphr);
3822
printf ("Warning threshold : %d W \n",(warning_threshbtuphr));
3823
printf ("Failure threshold : %d W \n",(failure_threshbtuphr));
3828
printf ("Error : Can not access the System Level sensor data \n\n");
3837
/*****************************************************************
3838
* Function Name: ipmi_get_instan_power_consmpt_data
3840
* Description: This function updates the instant Power consumption information
3841
* Input: intf - ipmi interface
3842
* Output: instpowerconsumptiondata - instant Power consumption information
3846
******************************************************************/
3848
static int ipmi_get_instan_power_consmpt_data(struct ipmi_intf* intf,
3849
IPMI_INST_POWER_CONSUMPTION_DATA* instpowerconsumptiondata)
3852
struct ipmi_rs * rsp;
3853
struct ipmi_rq req={0};
3855
uint8_t msg_data[2];
3858
/*get instantaneous power consumption command*/
3859
req.msg.netfn = DELL_OEM_NETFN;
3861
req.msg.cmd = GET_PWR_CONSUMPTION_CMD;
3863
req.msg.data = msg_data;
3864
req.msg.data_len = 2;
3868
memset(msg_data, 0, 2);
3874
rsp = intf->sendrecv(intf, &req);
3876
lprintf(LOG_ERR, " Error getting instantaneous power consumption data .\n");
3879
} else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
3880
printf("FM001 : A required license is missing or expired\n");
3882
} else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb)) {
3883
lprintf(LOG_ERR, " Error getting instantaneous power consumption data: Command not supported on this system.");
3885
} else if (rsp->ccode != 0){
3886
lprintf(LOG_ERR, " Error getting instantaneous power consumption data: %s",
3887
val2str(rsp->ccode, completion_code_vals));
3892
* instpowerconsumptiondata = * ( (IPMI_INST_POWER_CONSUMPTION_DATA*) (rsp->data));
3894
instpowerconsumptiondata->instanpowerconsumption = BSWAP_16(instpowerconsumptiondata->instanpowerconsumption);
3895
instpowerconsumptiondata->instanApms = BSWAP_16(instpowerconsumptiondata->instanApms);
3896
instpowerconsumptiondata->resv1 = BSWAP_16(instpowerconsumptiondata->resv1);
3905
/*****************************************************************
3906
* Function Name: ipmi_print_get_instan_power_Amps_data
3908
* Description: This function prints the instant Power consumption information
3909
* Input: instpowerconsumptiondata - instant Power consumption information
3914
******************************************************************/
3915
static void ipmi_print_get_instan_power_Amps_data(IPMI_INST_POWER_CONSUMPTION_DATA instpowerconsumptiondata)
3917
uint16_t intampsval=0;
3918
uint16_t decimalampsval=0;
3921
if (instpowerconsumptiondata.instanApms>0)
3923
decimalampsval=(instpowerconsumptiondata.instanApms%10);
3924
intampsval=instpowerconsumptiondata.instanApms/10;
3926
printf("\nAmperage value: %d.%d A \n",intampsval,decimalampsval);
3928
/*****************************************************************
3929
* Function Name: ipmi_print_get_power_consmpt_data
3931
* Description: This function prints the Power consumption information
3932
* Input: intf - ipmi interface
3933
* unit - watt / btuphr
3938
******************************************************************/
3939
static int ipmi_print_get_power_consmpt_data(struct ipmi_intf* intf,uint8_t unit)
3944
IPMI_INST_POWER_CONSUMPTION_DATA instpowerconsumptiondata = {0,0,0,0};
3946
printf ("\nPower consumption information\n");
3949
rc=ipmi_get_power_consumption_data(intf,unit);
3953
rc=ipmi_get_instan_power_consmpt_data(intf,&instpowerconsumptiondata);
3957
ipmi_print_get_instan_power_Amps_data(instpowerconsumptiondata);
3960
rc=ipmi_get_power_headroom_command(intf,unit);
3971
/*****************************************************************
3972
* Function Name: ipmi_get_avgpower_consmpt_history
3974
* Description: This function updates the average power consumption information
3975
* Input: intf - ipmi interface
3976
* Output: pavgpower- average power consumption information
3980
******************************************************************/
3981
static int ipmi_get_avgpower_consmpt_history(struct ipmi_intf* intf,IPMI_AVGPOWER_CONSUMP_HISTORY* pavgpower )
3983
struct ipmi_rs * rsp = NULL;
3984
struct ipmi_rq req = {0};
3987
req.msg.netfn = IPMI_NETFN_APP;
3989
req.msg.cmd = IPMI_GET_SYS_INFO;
3990
req.msg.data_len = 4;
3991
req.msg.data = data;
3997
rsp = intf->sendrecv(intf, &req);
4001
lprintf(LOG_ERR, " Error getting average power consumption history data .\n");
4004
else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
4005
printf("FM001 : A required license is missing or expired\n");
4007
} else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
4009
lprintf(LOG_ERR, " Error getting average power consumption history data: Command not supported on this system.");
4012
else if (rsp->ccode != 0)
4014
lprintf(LOG_ERR, " Error getting average power consumption historydata: %s",
4015
val2str(rsp->ccode, completion_code_vals));
4022
printf("Average power consumption history Data :%x %x %x %x %x %x %x\n\n",
4023
rsp->data[0], rsp->data[1], rsp->data[2], rsp->data[3],
4024
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7]);
4028
*pavgpower = *( (IPMI_AVGPOWER_CONSUMP_HISTORY*) rsp->data);
4030
pavgpower->lastminutepower = BSWAP_16(pavgpower->lastminutepower);
4031
pavgpower->lasthourpower = BSWAP_16(pavgpower->lasthourpower);
4032
pavgpower->lastdaypower = BSWAP_16(pavgpower->lastdaypower);
4033
pavgpower->lastweakpower = BSWAP_16(pavgpower->lastweakpower);
4039
/*****************************************************************
4040
* Function Name: ipmi_get_peakpower_consmpt_history
4042
* Description: This function updates the peak power consumption information
4043
* Input: intf - ipmi interface
4044
* Output: pavgpower- peak power consumption information
4048
******************************************************************/
4049
static int ipmi_get_peakpower_consmpt_history(struct ipmi_intf* intf,IPMI_POWER_CONSUMP_HISTORY * pstPeakpower)
4052
struct ipmi_rs * rsp = NULL;
4053
struct ipmi_rq req = {0};
4056
req.msg.netfn = IPMI_NETFN_APP;
4058
req.msg.cmd = IPMI_GET_SYS_INFO;
4059
req.msg.data_len = 4;
4060
req.msg.data = data;
4066
rsp = intf->sendrecv(intf, &req);
4070
lprintf(LOG_ERR, " Error getting peak power consumption history data .\n");
4073
else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
4074
printf("FM001 : A required license is missing or expired\n");
4076
} else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
4078
lprintf(LOG_ERR, " Error getting peak power consumption history data: Command not supported on this system.");
4081
else if (rsp->ccode != 0)
4083
lprintf(LOG_ERR, " Error getting peak power consumption history data: %s",
4084
val2str(rsp->ccode, completion_code_vals));
4090
printf("Peak power consmhistory Data : %x %x %x %x %x %x %x %x %x %x\n %x %x %x %x %x %x %x %x %x %x %x %x %x\n\n",
4091
rsp->data[0], rsp->data[1], rsp->data[2], rsp->data[3],
4092
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4093
rsp->data[8], rsp->data[9], rsp->data[10], rsp->data[11],
4094
rsp->data[12], rsp->data[13], rsp->data[14], rsp->data[15],
4095
rsp->data[16], rsp->data[17], rsp->data[18], rsp->data[19],
4096
rsp->data[20], rsp->data[21], rsp->data[22], rsp->data[23]
4100
*pstPeakpower =* ((IPMI_POWER_CONSUMP_HISTORY*)rsp->data);
4102
pstPeakpower->lastminutepower = BSWAP_16(pstPeakpower->lastminutepower);
4103
pstPeakpower->lasthourpower = BSWAP_16(pstPeakpower->lasthourpower);
4104
pstPeakpower->lastdaypower = BSWAP_16(pstPeakpower->lastdaypower);
4105
pstPeakpower->lastweakpower = BSWAP_16(pstPeakpower->lastweakpower);
4106
pstPeakpower->lastminutepowertime = BSWAP_32(pstPeakpower->lastminutepowertime);
4107
pstPeakpower->lasthourpowertime = BSWAP_32(pstPeakpower->lasthourpowertime);
4108
pstPeakpower->lastdaypowertime = BSWAP_32(pstPeakpower->lastdaypowertime);
4109
pstPeakpower->lastweekpowertime = BSWAP_32(pstPeakpower->lastweekpowertime);
4115
/*****************************************************************
4116
* Function Name: ipmi_get_minpower_consmpt_history
4118
* Description: This function updates the peak power consumption information
4119
* Input: intf - ipmi interface
4120
* Output: pavgpower- peak power consumption information
4124
******************************************************************/
4125
static int ipmi_get_minpower_consmpt_history(struct ipmi_intf* intf,IPMI_POWER_CONSUMP_HISTORY * pstMinpower)
4128
struct ipmi_rs * rsp = NULL;
4129
struct ipmi_rq req = {0};
4132
req.msg.netfn = IPMI_NETFN_APP;
4134
req.msg.cmd = IPMI_GET_SYS_INFO;
4135
req.msg.data_len = 4;
4136
req.msg.data = data;
4142
rsp = intf->sendrecv(intf, &req);
4146
lprintf(LOG_ERR, " Error getting peak power consumption history data .\n");
4149
else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
4150
printf("FM001 : A required license is missing or expired\n");
4152
} else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb))
4154
lprintf(LOG_ERR, " Error getting peak power consumption history data: Command not supported on this system.");
4157
else if (rsp->ccode != 0)
4159
lprintf(LOG_ERR, " Error getting peak power consumption history data: %s",
4160
val2str(rsp->ccode, completion_code_vals));
4166
printf("Peak power consmhistory Data : %x %x %x %x %x %x %x %x %x %x\n %x %x %x %x %x %x %x %x %x %x %x %x %x\n\n",
4167
rsp->data[0], rsp->data[1], rsp->data[2], rsp->data[3],
4168
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4169
rsp->data[8], rsp->data[9], rsp->data[10], rsp->data[11],
4170
rsp->data[12], rsp->data[13], rsp->data[14], rsp->data[15],
4171
rsp->data[16], rsp->data[17], rsp->data[18], rsp->data[19],
4172
rsp->data[20], rsp->data[21], rsp->data[22], rsp->data[23]
4176
*pstMinpower =* ((IPMI_POWER_CONSUMP_HISTORY*)rsp->data);
4178
pstMinpower->lastminutepower = BSWAP_16(pstMinpower->lastminutepower);
4179
pstMinpower->lasthourpower = BSWAP_16(pstMinpower->lasthourpower);
4180
pstMinpower->lastdaypower = BSWAP_16(pstMinpower->lastdaypower);
4181
pstMinpower->lastweakpower = BSWAP_16(pstMinpower->lastweakpower);
4182
pstMinpower->lastminutepowertime = BSWAP_32(pstMinpower->lastminutepowertime);
4183
pstMinpower->lasthourpowertime = BSWAP_32(pstMinpower->lasthourpowertime);
4184
pstMinpower->lastdaypowertime = BSWAP_32(pstMinpower->lastdaypowertime);
4185
pstMinpower->lastweekpowertime = BSWAP_32(pstMinpower->lastweekpowertime);
4192
/*****************************************************************
4193
* Function Name: ipmi_print_power_consmpt_history
4195
* Description: This function print the average and peak power consumption information
4196
* Input: intf - ipmi interface
4197
* unit - watt / btuphr
4202
******************************************************************/
4203
static int ipmi_print_power_consmpt_history(struct ipmi_intf* intf,int unit )
4208
uint32_t lastminutepeakpower;
4209
uint32_t lasthourpeakpower;
4210
uint32_t lastdaypeakpower;
4211
uint32_t lastweekpeakpower;
4213
IPMI_AVGPOWER_CONSUMP_HISTORY avgpower;
4214
IPMI_POWER_CONSUMP_HISTORY stMinpower;
4215
IPMI_POWER_CONSUMP_HISTORY stPeakpower;
4217
uint64_t tempbtuphrconv;
4221
rc= ipmi_get_avgpower_consmpt_history(intf,&avgpower);
4225
rc= ipmi_get_peakpower_consmpt_history(intf,&stPeakpower);
4229
rc= ipmi_get_minpower_consmpt_history(intf,&stMinpower);
4236
printf ("Power Consumption History\n\n");
4237
/* The fields are alligned manually changing the spaces will alter the alignment*/
4238
printf ("Statistic Last Minute Last Hour Last Day Last Week\n\n");
4242
printf ("Average Power Consumption ");
4243
tempbtuphrconv=watt_to_btuphr_conversion(avgpower.lastminutepower);
4244
printf ("%4lld BTU/hr ",tempbtuphrconv);
4245
tempbtuphrconv=watt_to_btuphr_conversion(avgpower.lasthourpower);
4246
printf ("%4lld BTU/hr ",tempbtuphrconv);
4247
tempbtuphrconv=watt_to_btuphr_conversion(avgpower.lastdaypower);
4248
printf ("%4lld BTU/hr ",tempbtuphrconv);
4249
tempbtuphrconv=watt_to_btuphr_conversion(avgpower.lastweakpower);
4250
printf ("%4lld BTU/hr\n",tempbtuphrconv);
4252
printf ("Max Power Consumption ");
4253
tempbtuphrconv=watt_to_btuphr_conversion(stPeakpower.lastminutepower);
4254
printf ("%4lld BTU/hr ",tempbtuphrconv);
4255
tempbtuphrconv=watt_to_btuphr_conversion(stPeakpower.lasthourpower);
4256
printf ("%4lld BTU/hr ",tempbtuphrconv);
4257
tempbtuphrconv=watt_to_btuphr_conversion(stPeakpower.lastdaypower);
4258
printf ("%4lld BTU/hr ",tempbtuphrconv);
4259
tempbtuphrconv=watt_to_btuphr_conversion(stPeakpower.lastweakpower);
4260
printf ("%4lld BTU/hr\n",tempbtuphrconv);
4262
printf ("Min Power Consumption ");
4263
tempbtuphrconv=watt_to_btuphr_conversion(stMinpower.lastminutepower);
4264
printf ("%4lld BTU/hr ",tempbtuphrconv);
4265
tempbtuphrconv=watt_to_btuphr_conversion(stMinpower.lasthourpower);
4266
printf ("%4lld BTU/hr ",tempbtuphrconv);
4267
tempbtuphrconv=watt_to_btuphr_conversion(stMinpower.lastdaypower);
4268
printf ("%4lld BTU/hr ",tempbtuphrconv);
4269
tempbtuphrconv=watt_to_btuphr_conversion(stMinpower.lastweakpower);
4270
printf ("%4lld BTU/hr\n\n",tempbtuphrconv);
4276
printf ("Average Power Consumption ");
4277
tempbtuphrconv=(avgpower.lastminutepower);
4278
printf ("%4lld W ",tempbtuphrconv);
4279
tempbtuphrconv=(avgpower.lasthourpower);
4280
printf ("%4lld W ",tempbtuphrconv);
4281
tempbtuphrconv=(avgpower.lastdaypower);
4282
printf ("%4lld W ",tempbtuphrconv);
4283
tempbtuphrconv=(avgpower.lastweakpower);
4284
printf ("%4lld W \n",tempbtuphrconv);
4286
printf ("Max Power Consumption ");
4287
tempbtuphrconv=(stPeakpower.lastminutepower);
4288
printf ("%4lld W ",tempbtuphrconv);
4289
tempbtuphrconv=(stPeakpower.lasthourpower);
4290
printf ("%4lld W ",tempbtuphrconv);
4291
tempbtuphrconv=(stPeakpower.lastdaypower);
4292
printf ("%4lld W ",tempbtuphrconv);
4293
tempbtuphrconv=(stPeakpower.lastweakpower);
4294
printf ("%4lld W \n",tempbtuphrconv);
4296
printf ("Min Power Consumption ");
4297
tempbtuphrconv=(stMinpower.lastminutepower);
4298
printf ("%4lld W ",tempbtuphrconv);
4299
tempbtuphrconv=(stMinpower.lasthourpower);
4300
printf ("%4lld W ",tempbtuphrconv);
4301
tempbtuphrconv=(stMinpower.lastdaypower);
4302
printf ("%4lld W ",tempbtuphrconv);
4303
tempbtuphrconv=(stMinpower.lastweakpower);
4304
printf ("%4lld W \n\n",tempbtuphrconv);
4307
lastminutepeakpower=stPeakpower.lastminutepowertime;
4308
lasthourpeakpower=stPeakpower.lasthourpowertime;
4309
lastdaypeakpower=stPeakpower.lastdaypowertime;
4310
lastweekpeakpower=stPeakpower.lastweekpowertime;
4312
printf ("Max Power Time\n");
4313
ipmi_time_to_str(lastminutepeakpower, timestr);
4314
printf ("Last Minute : %s",timestr);
4315
ipmi_time_to_str(lasthourpeakpower, timestr);
4316
printf ("Last Hour : %s",timestr);
4317
ipmi_time_to_str(lastdaypeakpower, timestr);
4318
printf ("Last Day : %s",timestr);
4319
ipmi_time_to_str(lastweekpeakpower, timestr);
4320
printf ("Last Week : %s",timestr);
4323
lastminutepeakpower=stMinpower.lastminutepowertime;
4324
lasthourpeakpower=stMinpower.lasthourpowertime;
4325
lastdaypeakpower=stMinpower.lastdaypowertime;
4326
lastweekpeakpower=stMinpower.lastweekpowertime;
4328
printf ("Min Power Time\n");
4329
ipmi_time_to_str(lastminutepeakpower, timestr);
4330
printf ("Last Minute : %s",timestr);
4331
ipmi_time_to_str(lasthourpeakpower, timestr);
4332
printf ("Last Hour : %s",timestr);
4333
ipmi_time_to_str(lastdaypeakpower, timestr);
4334
printf ("Last Day : %s",timestr);
4335
ipmi_time_to_str(lastweekpeakpower, timestr);
4336
printf ("Last Week : %s",timestr);
4345
/*****************************************************************
4346
* Function Name: ipmi_get_power_cap
4348
* Description: This function updates the power cap information
4349
* Input: intf - ipmi interface
4350
* Output: ipmipowercap - power cap information
4354
******************************************************************/
4356
static int ipmi_get_power_cap(struct ipmi_intf* intf,IPMI_POWER_CAP* ipmipowercap )
4358
struct ipmi_rs * rsp=NULL;
4359
struct ipmi_rq req={0};
4360
uint64_t tempbtuphrconv;
4363
/* power supply rating command*/
4364
req.msg.netfn = IPMI_NETFN_APP;
4366
req.msg.cmd = IPMI_GET_SYS_INFO;
4367
req.msg.data_len = 4;
4368
req.msg.data = data;
4371
data[1] = IPMI_DELL_POWER_CAP;
4376
rsp = intf->sendrecv(intf, &req);
4379
lprintf(LOG_ERR, " Error getting power cap .\n");
4381
printf("power cap Data :%x %x %x %x %x %x %x %x %x %x ",
4382
rsp->data[1], rsp->data[2], rsp->data[3],
4383
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4384
rsp->data[8], rsp->data[9], rsp->data[10],rsp->data[11]);
4388
} else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
4389
printf("FM001 : A required license is missing or expired\n");
4391
} else if ((rsp->ccode == 0xc1)||(rsp->ccode == 0xcb)) {
4393
lprintf(LOG_ERR, " Error getting power cap: Command not supported on this system.");
4395
printf("power cap Data :%x %x %x %x %x %x %x %x %x %x ",
4396
rsp->data[1], rsp->data[2], rsp->data[3],
4397
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4398
rsp->data[8], rsp->data[9], rsp->data[10],rsp->data[11]);
4402
} else if (rsp->ccode != 0){
4403
lprintf(LOG_ERR, " Error getting power cap: %s",
4404
val2str(rsp->ccode, completion_code_vals));
4406
printf("power cap Data :%x %x %x %x %x %x %x %x %x %x ",
4407
rsp->data[1], rsp->data[2], rsp->data[3],
4408
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4409
rsp->data[8], rsp->data[9], rsp->data[10],rsp->data[11]);
4414
printf("power cap Data :%x %x %x %x %x %x %x %x %x %x ",
4415
rsp->data[1], rsp->data[2], rsp->data[3],
4416
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4417
rsp->data[8], rsp->data[9], rsp->data[10],rsp->data[11]);
4421
* ipmipowercap = *((IPMI_POWER_CAP*)(rsp->data));
4423
ipmipowercap->PowerCap = BSWAP_16(ipmipowercap->PowerCap);
4424
ipmipowercap->MaximumPowerConsmp = BSWAP_16(ipmipowercap->MaximumPowerConsmp);
4425
ipmipowercap->MinimumPowerConsmp = BSWAP_16(ipmipowercap->MinimumPowerConsmp);
4426
ipmipowercap->totalnumpowersupp = BSWAP_16(ipmipowercap->totalnumpowersupp);
4427
ipmipowercap->AvailablePower = BSWAP_16(ipmipowercap->AvailablePower);
4428
ipmipowercap->SystemThrottling = BSWAP_16(ipmipowercap->SystemThrottling);
4429
ipmipowercap->Resv = BSWAP_16(ipmipowercap->Resv);
4435
/*****************************************************************
4436
* Function Name: ipmi_print_power_cap
4438
* Description: This function print the power cap information
4439
* Input: intf - ipmi interface
4440
* unit - watt / btuphr
4444
******************************************************************/
4445
static int ipmi_print_power_cap(struct ipmi_intf* intf,uint8_t unit )
4447
uint64_t tempbtuphrconv;
4449
IPMI_POWER_CAP ipmipowercap;
4451
memset(&ipmipowercap,0,sizeof(ipmipowercap));
4452
rc=ipmi_get_power_cap(intf,&ipmipowercap);
4458
tempbtuphrconv=watt_to_btuphr_conversion(ipmipowercap.MaximumPowerConsmp);
4459
printf ("Maximum power: %lld BTU/hr\n",tempbtuphrconv);
4460
tempbtuphrconv=watt_to_btuphr_conversion(ipmipowercap.MinimumPowerConsmp);
4461
printf ("Minimum power: %lld BTU/hr\n",tempbtuphrconv);
4462
tempbtuphrconv=watt_to_btuphr_conversion(ipmipowercap.PowerCap);
4463
printf ("Power cap : %lld BTU/hr\n",tempbtuphrconv);
4466
printf ("Maximum power: %d Watt\n",ipmipowercap.MaximumPowerConsmp);
4467
printf ("Minimum power: %d Watt\n",ipmipowercap.MinimumPowerConsmp);
4468
printf ("Power cap : %d Watt\n",ipmipowercap.PowerCap);
4475
/*****************************************************************
4476
* Function Name: ipmi_set_power_cap
4478
* Description: This function updates the power cap information
4479
* Input: intf - ipmi interface
4480
* unit - watt / btuphr
4481
* val - new power cap value
4485
******************************************************************/
4486
static int ipmi_set_power_cap(struct ipmi_intf* intf,int unit,int val )
4488
struct ipmi_rs *rsp = NULL;
4489
struct ipmi_rq req={0};;
4491
uint16_t powercapval;
4492
uint64_t maxpowerbtuphr;
4493
uint64_t maxpowerbtuphr1;
4494
uint64_t minpowerbtuphr;
4495
IPMI_POWER_CAP ipmipowercap;
4497
if(ipmi_get_power_capstatus_command(intf) < 0)
4498
return -1; // Adding the failed condition check
4500
if (PowercapSetable_flag!=1)
4502
lprintf(LOG_ERR, " Can not set powercap on this system");
4505
else if(PowercapstatusFlag!=1)
4507
lprintf(LOG_ERR, " Power cap set feature is not enabled");
4511
req.msg.netfn = IPMI_NETFN_APP;
4513
req.msg.cmd = IPMI_GET_SYS_INFO;
4514
req.msg.data_len = 4;
4516
req.msg.data = data;
4519
data[1] = IPMI_DELL_POWER_CAP;
4523
rsp = intf->sendrecv(intf, &req);
4526
lprintf(LOG_ERR, " Error getting power cap .\n");
4529
printf("power cap Data :%x %x %x %x %x %x %x %x %x %x ",
4530
rsp->data[1], rsp->data[2], rsp->data[3],
4531
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4532
rsp->data[8], rsp->data[9], rsp->data[10],rsp->data[11]);
4537
else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
4538
printf("FM001 : A required license is missing or expired\n");
4541
else if (rsp->ccode == 0xc1)
4544
lprintf(LOG_ERR, " Error getting power cap, command not supported on this system.\n");
4546
printf("power cap Data :%x %x %x %x %x %x %x %x %x %x ",
4547
rsp->data[1], rsp->data[2], rsp->data[3],
4548
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4549
rsp->data[8], rsp->data[9], rsp->data[10],rsp->data[11]);
4554
else if (rsp->ccode != 0)
4556
lprintf(LOG_ERR, " Error getting power cap: %s",
4557
val2str(rsp->ccode, completion_code_vals));
4560
printf("power cap Data :%x %x %x %x %x %x %x %x %x %x ",
4561
rsp->data[1], rsp->data[2], rsp->data[3],
4562
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4563
rsp->data[8], rsp->data[9], rsp->data[10],rsp->data[11]);
4569
printf("power cap Data :%x %x %x %x %x %x %x %x %x %x ",
4570
rsp->data[1], rsp->data[2], rsp->data[3],
4571
rsp->data[4], rsp->data[5], rsp->data[6], rsp->data[7],
4572
rsp->data[8], rsp->data[9], rsp->data[10],rsp->data[11]);
4576
ipmipowercap.PowerCap=((rsp->data[1]<<8)+rsp->data[2]);
4577
ipmipowercap.unit=rsp->data[3];
4578
ipmipowercap.MaximumPowerConsmp=((rsp->data[4]<<8)+rsp->data[5]);
4579
ipmipowercap.MinimumPowerConsmp=((rsp->data[6]<<8)+rsp->data[7]);
4581
memset(data, 0, 13);
4582
req.msg.netfn = IPMI_NETFN_APP;
4584
req.msg.cmd = IPMI_SET_SYS_INFO;
4585
req.msg.data_len = 13;
4586
req.msg.data = data;
4587
data[0] = IPMI_DELL_POWER_CAP;
4591
data[1] = (powercapval&0XFF);
4592
data[2] = ((powercapval&0XFF00)>>8);
4595
data[4]=((ipmipowercap.MaximumPowerConsmp&0xFF));
4596
data[5]=((ipmipowercap.MaximumPowerConsmp&0xFF00)>>8);
4597
data[6]=((ipmipowercap.MinimumPowerConsmp&0xFF));
4598
data[7]=((ipmipowercap.MinimumPowerConsmp&0xFF00)>>8);
4599
data[8]=(ipmipowercap.totalnumpowersupp);
4600
data[9]=((ipmipowercap.AvailablePower&0xFF));
4601
data[10]=((ipmipowercap.AvailablePower&0xFF00)>>8);
4602
data[11]=(ipmipowercap.SystemThrottling);
4605
ipmipowercap.MaximumPowerConsmp = BSWAP_16(ipmipowercap.MaximumPowerConsmp);
4606
ipmipowercap.MinimumPowerConsmp = BSWAP_16(ipmipowercap.MinimumPowerConsmp);
4607
ipmipowercap.PowerCap = BSWAP_16(ipmipowercap.PowerCap);
4610
val = btuphr_to_watt_conversion(val);
4613
else if(unit ==percent)
4615
if((val <0)||(val>100))
4617
lprintf(LOG_ERR, " Cap value is out of boundary conditon it should be between 0 - 100");
4620
val =( (val*(ipmipowercap.MaximumPowerConsmp -ipmipowercap.MinimumPowerConsmp))/100)+ipmipowercap.MinimumPowerConsmp;
4621
lprintf(LOG_ERR, " Cap value in percentage is %d ",val);
4622
data[1] = (val&0XFF);
4623
data[2] = ((val&0XFF00)>>8);
4626
if(((val<ipmipowercap.MinimumPowerConsmp)||(val>ipmipowercap.MaximumPowerConsmp))&&(unit==watt))
4628
lprintf(LOG_ERR, " Cap value is out of boundary conditon it should be between %d - %d",
4629
ipmipowercap.MinimumPowerConsmp,ipmipowercap.MaximumPowerConsmp);
4632
else if(((val<ipmipowercap.MinimumPowerConsmp)||(val>ipmipowercap.MaximumPowerConsmp))&&(unit==btuphr))
4634
minpowerbtuphr= watt_to_btuphr_conversion(ipmipowercap.MinimumPowerConsmp);
4635
maxpowerbtuphr=watt_to_btuphr_conversion(ipmipowercap.MaximumPowerConsmp);
4636
maxpowerbtuphr1= watt_to_btuphr_conversion(ipmipowercap.MaximumPowerConsmp);
4637
lprintf(LOG_ERR, " Cap value is out of boundary conditon it should be between %d",
4639
lprintf(LOG_ERR, " -%d",
4644
rsp = intf->sendrecv(intf, &req);
4647
lprintf(LOG_ERR, " Error setting power cap");
4650
else if((iDRAC_FLAG == IDRAC_12G) && (rsp->ccode == LICENSE_NOT_SUPPORTED)) {
4651
printf("FM001 : A required license is missing or expired\n");
4654
else if (rsp->ccode > 0)
4656
lprintf(LOG_ERR, " Error setting power cap: %s",
4657
val2str(rsp->ccode, completion_code_vals));
4662
printf("CC for setpowercap :%d ",rsp->ccode);
4667
/*****************************************************************
4668
* Function Name: getpowersupplyfruinfo
4670
* Description: This function retrieves the FRU header
4671
* Input: intf - ipmi interface
4672
* header - watt / btuphr
4673
* fru - FRU information
4674
* Output: header - FRU header
4677
******************************************************************/
4678
static int getpowersupplyfruinfo(struct ipmi_intf *intf, uint8_t id,
4679
struct fru_header header, struct fru_info fru)
4681
struct ipmi_rs * rsp;
4684
uint8_t msg_data[4];
4686
memset(&fru, 0, sizeof(struct fru_info));
4687
memset(&header, 0, sizeof(struct fru_header));
4690
* get info about this FRU
4692
memset(msg_data, 0, 4);
4695
memset(&req, 0, sizeof(req));
4696
req.msg.netfn = IPMI_NETFN_STORAGE;
4698
req.msg.cmd = GET_FRU_INFO;
4699
req.msg.data = msg_data;
4700
req.msg.data_len = 1;
4702
rsp = intf->sendrecv(intf, &req);
4704
printf(" Device not present (No Response)\n");
4707
if (rsp->ccode > 0) {
4708
printf(" Device not present (%s)\n",
4709
val2str(rsp->ccode, completion_code_vals));
4713
fru.size = (rsp->data[1] << 8) | rsp->data[0];
4714
fru.access = rsp->data[2] & 0x1;
4716
lprintf(LOG_DEBUG, "fru.size = %d bytes (accessed by %s)",
4717
fru.size, fru.access ? "words" : "bytes");
4720
lprintf(LOG_ERR, " Invalid FRU size %d", fru.size);
4725
* retrieve the FRU header
4732
memset(&req, 0, sizeof(req));
4733
req.msg.netfn = IPMI_NETFN_STORAGE;
4735
req.msg.cmd = GET_FRU_DATA;
4736
req.msg.data = msg_data;
4737
req.msg.data_len = 4;
4739
rsp = intf->sendrecv(intf, &req);
4741
printf(" Device not present (No Response)\n");
4744
if (rsp->ccode > 0) {
4745
printf(" Device not present (%s)\n",
4746
val2str(rsp->ccode, completion_code_vals));
4751
printbuf(rsp->data, rsp->data_len, "FRU DATA");
4753
memcpy(&header, rsp->data + 1, 8);
4760
/*****************************************************************
4761
* Function Name: ipmi_powermonitor_usage
4763
* Description: This function prints help message for powermonitor command
4769
******************************************************************/
4771
ipmi_powermonitor_usage(void)
4773
lprintf(LOG_NOTICE, "");
4774
lprintf(LOG_NOTICE, " powermonitor");
4775
lprintf(LOG_NOTICE, " Shows power tracking statistics ");
4776
lprintf(LOG_NOTICE, "");
4777
lprintf(LOG_NOTICE, " powermonitor clear cumulativepower");
4778
lprintf(LOG_NOTICE, " Reset cumulative power reading");
4779
lprintf(LOG_NOTICE, "");
4780
lprintf(LOG_NOTICE, " powermonitor clear peakpower");
4781
lprintf(LOG_NOTICE, " Reset peak power reading");
4782
lprintf(LOG_NOTICE, "");
4783
lprintf(LOG_NOTICE, " powermonitor powerconsumption");
4784
lprintf(LOG_NOTICE, " Displays power consumption in <watt|btuphr>");
4785
lprintf(LOG_NOTICE, "");
4786
lprintf(LOG_NOTICE, " powermonitor powerconsumptionhistory <watt|btuphr>");
4787
lprintf(LOG_NOTICE, " Displays power consumption history ");
4788
lprintf(LOG_NOTICE, "");
4789
lprintf(LOG_NOTICE, " powermonitor getpowerbudget");
4790
lprintf(LOG_NOTICE, " Displays power cap in <watt|btuphr>");
4791
lprintf(LOG_NOTICE, "");
4792
lprintf(LOG_NOTICE, " powermonitor setpowerbudget <val><watt|btuphr|percent>");
4793
lprintf(LOG_NOTICE, " Allows user to set the power cap in <watt|BTU/hr|percentage>");
4794
lprintf(LOG_NOTICE, "");
4795
lprintf(LOG_NOTICE, " powermonitor enablepowercap ");
4796
lprintf(LOG_NOTICE, " To enable set power cap");
4797
lprintf(LOG_NOTICE, "");
4798
lprintf(LOG_NOTICE, " powermonitor disablepowercap ");
4799
lprintf(LOG_NOTICE, " To disable set power cap");
4800
lprintf(LOG_NOTICE, "");
4803
/*****************************************************************
4804
* Function Name: ipmi_delloem_vFlash_main
4806
* Description: This function processes the delloem vFlash command
4807
* Input: intf - ipmi interface
4808
argc - no of arguments
4809
argv - argument string array
4812
* Return: return code 0 - success
4815
******************************************************************/
4817
static int ipmi_delloem_vFlash_main (struct ipmi_intf * intf, int argc, char ** argv)
4822
rc = ipmi_delloem_vFlash_process(intf, current_arg, argv);
4828
/*****************************************************************
4829
* Function Name: get_vFlash_compcode_str
4831
* Description: This function maps the vFlash completion code
4833
* Input : vFlash completion code and static array of codes vs strings
4835
* Return: returns the mapped string
4837
******************************************************************/
4839
get_vFlash_compcode_str(uint8_t vflashcompcode, const struct vFlashstr *vs)
4841
static char un_str[32];
4844
for (i = 0; vs[i].str != NULL; i++) {
4845
if (vs[i].val == vflashcompcode)
4849
memset(un_str, 0, 32);
4850
snprintf(un_str, 32, "Unknown (0x%02X)", vflashcompcode);
4855
/*****************************************************************
4856
* Function Name: ipmi_get_sd_card_info
4858
* Description: This function prints the vFlash Extended SD card info
4859
* Input : ipmi interface
4860
* Output: prints the sd card extended info
4861
* Return: 0 - success -1 - failure
4863
******************************************************************/
4865
ipmi_get_sd_card_info(struct ipmi_intf* intf) {
4866
struct ipmi_rs * rsp;
4869
uint8_t msg_data[2];
4870
uint8_t input_length=0;
4871
uint8_t cardstatus=0x00;
4873
IPMI_DELL_SDCARD_INFO * sdcardinfoblock;
4876
msg_data[0] = msg_data[1] = 0x00;
4878
req.msg.netfn = DELL_OEM_NETFN;
4880
req.msg.cmd = IPMI_GET_EXT_SD_CARD_INFO;
4881
req.msg.data = msg_data;
4882
req.msg.data_len = input_length;
4884
rsp = intf->sendrecv(intf, &req);
4887
lprintf(LOG_ERR, " Error in getting SD Card Extended Information");
4890
else if (rsp->ccode > 0)
4892
lprintf(LOG_ERR, " Error in getting SD Card Extended Information (%s) \n",
4893
val2str(rsp->ccode, completion_code_vals) );
4897
sdcardinfoblock = (IPMI_DELL_SDCARD_INFO *) (void *) rsp->data;
4899
if( (iDRAC_FLAG == IDRAC_12G) && (sdcardinfoblock->vflashcompcode == VFL_NOT_LICENSED))
4901
printf("FM001 : A required license is missing or expired\n");
4904
else if (sdcardinfoblock->vflashcompcode != 0x00)
4906
lprintf(LOG_ERR, " Error in getting SD Card Extended Information (%s) \n", get_vFlash_compcode_str(sdcardinfoblock->vflashcompcode,
4907
vFlash_completion_code_vals));
4911
if (!(sdcardinfoblock->sdcardstatus & 0x04))
4913
lprintf(LOG_ERR, " vFlash SD card is unavailable, please insert the card\n of size 256MB or greater\n");
4917
printf("vFlash SD Card Properties\n");
4918
printf("SD Card size : %8dMB\n",sdcardinfoblock->sdcardsize);
4919
printf("Available size : %8dMB\n",sdcardinfoblock->sdcardavailsize);
4920
printf("Initialized : %10s\n", (sdcardinfoblock->sdcardstatus & 0x80) ?
4922
printf("Licensed : %10s\n", (sdcardinfoblock->sdcardstatus & 0x40) ?
4924
printf("Attached : %10s\n", (sdcardinfoblock->sdcardstatus & 0x20) ?
4926
printf("Enabled : %10s\n", (sdcardinfoblock->sdcardstatus & 0x10) ?
4928
printf("Write Protected : %10s\n", (sdcardinfoblock->sdcardstatus & 0x08) ?
4930
cardstatus = sdcardinfoblock->sdcardstatus & 0x03;
4931
printf("Health : %10s\n", ((0x00 == cardstatus
4932
) ? "OK" : ((cardstatus == 0x03) ?
4933
"Undefined" : ((cardstatus == 0x02) ?
4934
"Critical" : "Warning"))));
4935
printf("Bootable partition : %10d\n",sdcardinfoblock->bootpartion);
4939
/*****************************************************************
4940
* Function Name: ipmi_delloem_vFlash_process
4942
* Description: This function processes the args for vFlash subcmd
4943
* Input : intf - ipmi interface, arg index, argv array
4944
* Output: prints help or error with help
4945
* Return: 0 - Success -1 - failure
4947
******************************************************************/
4949
ipmi_delloem_vFlash_process(struct ipmi_intf* intf, int current_arg, char ** argv) {
4952
if (strncmp(intf->name,"wmi\0",4) &&
4953
strncmp(intf->name, "open\0",5))
4955
lprintf(LOG_ERR, " vFlash support is enabled only for wmi and open interface.\n Its not enabled for lan and lanplus interface.");
4959
if (argv[current_arg] == NULL || strcmp(argv[current_arg], "help") == 0)
4961
ipmi_vFlash_usage();
4964
ipmi_idracvalidator_command(intf);
4965
if (!strncmp(argv[current_arg], "info\0", 5))
4968
if (argv[current_arg] == NULL)
4970
ipmi_vFlash_usage();
4973
else if (strncmp(argv[current_arg], "Card\0", 5) == 0)
4976
if (argv[current_arg] != NULL)
4978
ipmi_vFlash_usage();
4981
rc = ipmi_get_sd_card_info(intf);
4984
else /* TBD: many sub commands are present */
4986
ipmi_vFlash_usage();
4990
/* TBD other vFlash subcommands */
4993
ipmi_vFlash_usage();
4998
/*****************************************************************
4999
* Function Name: ipmi_vFlash_usage
5001
* Description: This function displays the usage for using vFlash
5003
* Output: prints help
5006
******************************************************************/
5008
ipmi_vFlash_usage(void)
5010
lprintf(LOG_NOTICE, "");
5011
lprintf(LOG_NOTICE, " vFlash info Card");
5012
lprintf(LOG_NOTICE, " Shows Extended SD Card information");
5013
lprintf(LOG_NOTICE, "");
5016
/**********************************************************************
5017
* Function Name: ipmi_setled_usage
5019
* Description: This function prints help message for setled command
5025
***********************************************************************/
5027
ipmi_setled_usage(void)
5029
lprintf(LOG_NOTICE, "");
5030
lprintf(LOG_NOTICE, " setled <b:d.f> <state..>");
5031
lprintf(LOG_NOTICE, " Set backplane LED state");
5032
lprintf(LOG_NOTICE, " b:d.f = PCI Bus:Device.Function of drive (lspci format)");
5033
lprintf(LOG_NOTICE, " state = present|online|hotspare|identify|rebuilding|");
5034
lprintf(LOG_NOTICE, " fault|predict|critical|failed");
5035
lprintf(LOG_NOTICE, "");
5039
IsSetLEDSupported(void)
5041
return SetLEDSupported;
5045
CheckSetLEDSupport(struct ipmi_intf * intf)
5047
struct ipmi_rs * rsp = NULL;
5048
struct ipmi_rq req = {0};
5051
SetLEDSupported = 0;
5052
req.msg.netfn = DELL_OEM_NETFN;
5054
req.msg.cmd = 0xD5; /* Storage */
5055
req.msg.data_len = 10;
5056
req.msg.data = data;
5058
memset(data, 0, sizeof(data));
5059
data[0] = 0x01; // get
5060
data[1] = 0x00; // subcmd:get firmware version
5061
data[2] = 0x08; // length lsb
5062
data[3] = 0x00; // length msb
5063
data[4] = 0x00; // offset lsb
5064
data[5] = 0x00; // offset msb
5065
data[6] = 0x00; // bay id
5070
rsp = intf->sendrecv(intf, &req);
5071
if (rsp == NULL || rsp->ccode != 0)
5075
SetLEDSupported = 1;
5078
/*****************************************************************
5079
* Function Name: ipmi_getdrivemap
5081
* Description: This function returns mapping of BDF to Bay:Slot
5082
* Input: intf - ipmi interface
5083
* bdf - PCI Address of drive
5084
* *bay - Returns bay ID
5085
*slot - Returns slot ID
5090
******************************************************************/
5092
ipmi_getdrivemap(struct ipmi_intf * intf, int b, int d, int f, int *bay, int *slot)
5094
struct ipmi_rs * rsp = NULL;
5095
struct ipmi_rq req = {0};
5098
/* Get mapping of BDF to bay:slot */
5099
req.msg.netfn = DELL_OEM_NETFN;
5102
req.msg.data_len = 8;
5103
req.msg.data = data;
5105
memset(data, 0, sizeof(data));
5106
data[0] = 0x01; // get
5107
data[1] = 0x07; // storage map
5108
data[2] = 0x06; // length lsb
5109
data[3] = 0x00; // length msb
5110
data[4] = 0x00; // offset lsb
5111
data[5] = 0x00; // offset msb
5113
data[7] = (d << 3) + f; // devfn
5115
rsp = intf->sendrecv(intf, &req);
5119
lprintf(LOG_ERR, " Error issuing getdrivemap command.\n");
5122
else if (rsp->ccode != 0)
5124
lprintf(LOG_ERR, " Error issuing getdrivemap command: %s",
5125
val2str(rsp->ccode, completion_code_vals));
5129
*bay = rsp->data[7];
5130
*slot = rsp->data[8];
5131
if (*bay == 0xFF || *slot == 0xFF)
5133
lprintf(LOG_ERR, "Error could not get drive bay:slot mapping");
5139
/*****************************************************************
5140
* Function Name: ipmi_setled_state
5142
* Description: This function updates the LED on the backplane
5143
* Input: intf - ipmi interface
5144
* bdf - PCI Address of drive
5145
* state - SES Flags state of drive
5150
******************************************************************/
5152
ipmi_setled_state (struct ipmi_intf * intf, int bayId, int slotId, int state)
5154
struct ipmi_rs * rsp = NULL;
5155
struct ipmi_rq req = {0};
5158
/* Issue Drive Status Update to bay:slot */
5159
req.msg.netfn = DELL_OEM_NETFN;
5162
req.msg.data_len = 20;
5163
req.msg.data = data;
5165
memset(data, 0, sizeof(data));
5166
data[0] = 0x00; // set
5167
data[1] = 0x04; // set drive status
5168
data[2] = 0x0e; // length lsb
5169
data[3] = 0x00; // length msb
5170
data[4] = 0x00; // offset lsb
5171
data[5] = 0x00; // offset msb
5172
data[6] = 0x0e; // length lsb
5173
data[7] = 0x00; // length msb
5174
data[8] = bayId; // bayid
5175
data[9] = slotId; // slotid
5176
data[10] = state & 0xff; // state LSB
5177
data[11] = state >> 8; // state MSB;
5179
rsp = intf->sendrecv(intf, &req);
5183
lprintf(LOG_ERR, " Error issuing setled command.\n");
5186
else if (rsp->ccode != 0)
5188
lprintf(LOG_ERR, " Error issuing setled command: %s",
5189
val2str(rsp->ccode, completion_code_vals));
5195
/*****************************************************************
5196
* Function Name: ipmi_getsesmask
5198
* Description: This function calculates bits in SES drive update
5199
* Return: Mask set with bits for SES backplane update
5201
******************************************************************/
5202
static int ipmi_getsesmask(int argc, char **argv)
5206
while (current_arg < argc) {
5207
if (!strcmp(argv[current_arg], "present"))
5209
if (!strcmp(argv[current_arg], "online"))
5211
if (!strcmp(argv[current_arg], "hotspare"))
5213
if (!strcmp(argv[current_arg], "identify"))
5215
if (!strcmp(argv[current_arg], "rebuilding"))
5217
if (!strcmp(argv[current_arg], "fault"))
5219
if (!strcmp(argv[current_arg], "predict"))
5221
if (!strcmp(argv[current_arg], "critical"))
5223
if (!strcmp(argv[current_arg], "failed"))
5230
/*****************************************************************
5231
* Function Name: ipmi_delloem_setled_main
5233
* Description: This function processes the delloem setled command
5234
* Input: intf - ipmi interface
5235
argc - no of arguments
5236
argv - argument string array
5239
* Return: return code 0 - success
5242
******************************************************************/
5244
ipmi_delloem_setled_main(struct ipmi_intf * intf, int argc, char ** argv)
5253
if (argc < current_arg)
5259
/* ipmitool delloem setled info*/
5260
if (argc == 1 || strcmp(argv[current_arg], "help") == 0)
5262
ipmi_setled_usage();
5265
CheckSetLEDSupport (intf);
5266
if (!IsSetLEDSupported())
5268
printf("'setled' is not supported on this system.\n");
5271
else if (sscanf(argv[current_arg], "%*x:%x:%x.%x", &b,&d,&f) == 3) {
5272
/* We have bus/dev/function of drive */
5274
ipmi_getdrivemap (intf, b, d, f, &bayId, &slotId);
5276
else if (sscanf(argv[current_arg], "%x:%x.%x", &b,&d,&f) == 3) {
5277
/* We have bus/dev/function of drive */
5281
ipmi_setled_usage();
5284
/* Get mask of SES flags */
5285
mask = ipmi_getsesmask(argc, argv);
5287
/* Get drive mapping */
5288
if (ipmi_getdrivemap (intf, b, d, f, &bayId, &slotId))
5291
/* Set drive LEDs */
5292
return ipmi_setled_state (intf, bayId, slotId, mask);
5296
/*****************************************************************
5297
* Function Name: ipmi_getsysinfo
5299
* Description: This function processes the IPMI Get System Info command
5300
* Input: intf - ipmi interface
5301
* param - Parameter # (0xC0..0xFF = OEM)
5302
* block/set - Block/Set number of parameter
5303
* len - Length of buffer
5304
* buffer - Pointer to buffer
5307
* Return: return code 0 - success
5309
* other = IPMI ccode
5311
******************************************************************/
5313
ipmi_getsysinfo(struct ipmi_intf * intf, int param, int block, int set, int len, void *buffer)
5316
struct ipmi_rs *rsp = NULL;
5317
struct ipmi_rq req={0};
5319
memset(buffer, 0, len);
5321
req.msg.netfn = IPMI_NETFN_APP;
5323
req.msg.cmd = IPMI_GET_SYS_INFO;
5324
req.msg.data_len = 4;
5325
req.msg.data = data;
5327
data[0] = 0; // get/set
5332
rsp = intf->sendrecv(intf, &req);
5334
if (rsp->ccode == 0) {
5335
if (len > rsp->data_len)
5336
len = rsp->data_len;
5338
memcpy(buffer, rsp->data, len);