commit 194d20c909c93874583db20fbf1e0739a8f8c7e0 Author: Ales Ledvinka Date: Thu Jul 25 12:29:08 2013 +0200 Jeff's bugzilla cx6 patch diff --git a/include/ipmitool/Makefile.am b/include/ipmitool/Makefile.am index fb6f6bf..83bc76f 100644 --- a/include/ipmitool/Makefile.am +++ b/include/ipmitool/Makefile.am @@ -38,5 +38,5 @@ noinst_HEADERS = log.h bswap.h helper.h ipmi.h ipmi_cc.h ipmi_intf.h \ ipmi_oem.h ipmi_sdradd.h ipmi_isol.h ipmi_sunoem.h ipmi_picmg.h \ ipmi_fwum.h ipmi_main.h ipmi_tsol.h ipmi_firewall.h \ ipmi_kontronoem.h ipmi_ekanalyzer.h ipmi_gendev.h ipmi_ime.h \ - ipmi_delloem.h ipmi_dcmi.h + ipmi_delloem.h ipmi_dcmi.h ipmi_cxoem.h diff --git a/include/ipmitool/ipmi.h b/include/ipmitool/ipmi.h index e74c252..759417c 100644 --- a/include/ipmitool/ipmi.h +++ b/include/ipmitool/ipmi.h @@ -245,6 +245,7 @@ struct ipmi_rs { #define IPMI_NETFN_OEM 0x2E #define IPMI_NETFN_ISOL 0x34 #define IPMI_NETFN_TSOL 0x30 +#define IPMI_NETFN_CX_OEM 0x3e #define IPMI_BMC_SLAVE_ADDR 0x20 #define IPMI_REMOTE_SWID 0x81 diff --git a/include/ipmitool/ipmi_constants.h b/include/ipmitool/ipmi_constants.h index 2aad2cf..d316c61 100644 --- a/include/ipmitool/ipmi_constants.h +++ b/include/ipmitool/ipmi_constants.h @@ -114,6 +114,8 @@ #define IPMI_CHASSIS_BOOTPARAM_INIT_INFO 6 #define IPMI_CHASSIS_BOOTPARAM_INIT_MBOX 7 +#define IPMI_CHASSIS_BOOTPARAM_OEM_BOOT_POLICY 96 // Calxeda OEM boot param + /* From table 13-17 of the IPMI v2 specification */ #define IPMI_AUTH_RAKP_NONE 0x00 #define IPMI_AUTH_RAKP_HMAC_SHA1 0x01 diff --git a/include/ipmitool/ipmi_cxoem.h b/include/ipmitool/ipmi_cxoem.h new file mode 100644 index 0000000..9a01f85 --- /dev/null +++ b/include/ipmitool/ipmi_cxoem.h @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2011 Calxeda, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Calxeda, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. + */ + +#ifndef IPMI_CXOEM_H +#define IPMI_CXOEM_H + +#if HAVE_CONFIG_H +#include +#endif +#include +#include + +#define CX_VERSION "-cx6" +#define IPMI_NETFN_OEM_SS 0x3e + +/* + * CX IPMI OEM command ids + */ +#define MSG_ELEMENT_TERMINATOR 0xff +#define MSG_PARAM_VAL_START_SCALAR 0xf0 +#define MSG_PARAM_VAL_START_STRING 0xf1 +#define MSG_PARAM_VAL_START_IPV4_ADDR 0xf2 +#define MSG_PARAM_VAL_START_MAC_ADDR 0xf3 +#define MSG_PARAM_VAL_START_BITMAP 0xf4 + +#define IPMI_CMD_OEM_GET_DEVICE_INFO 0x01 +#define IPMI_CMD_OEM_FEATURES_ENABLE 0xD0 +#define IPMI_CMD_OEM_FW_DOWNLOAD 0xE0 +#define IPMI_CMD_OEM_FW_GET_STATUS 0xE1 +#define IPMI_CMD_OEM_FW_SET_STATUS 0xE2 +#define IPMI_CMD_OEM_FW_RAW 0xE3 +#define IPMI_CMD_OEM_FABRIC_GET 0xE4 +#define IPMI_CMD_OEM_FABRIC_SET 0xE5 +#define IPMI_CMD_OEM_FABRIC_CONFIG_GET 0xE6 +#define IPMI_CMD_OEM_FABRIC_CONFIG_SET 0xE7 +#define IPMI_CMD_OEM_FABRIC_UPDATE_CONFIG 0xE8 +#define IPMI_CMD_OEM_FW_RESET 0xE9 +#define IPMI_CMD_OEM_DATA_ACCESS 0xEA +#define IPMI_CMD_OEM_FABRIC_ADD 0xEB +#define IPMI_CMD_OEM_FABRIC_RM 0xEC +#define IPMI_CMD_OEM_TEST 0xED +#define IPMI_CMD_OEM_FABRIC_INFO 0xEE +#define IPMI_CMD_OEM_FABRIC_SET_WATCH 0xEF +#define IPMI_CMD_OEM_FABRIC_CLEAR_WATCH 0xF0 +#define IPMI_CMD_OEM_FABRIC_FACTORY_DEFAULT 0xF1 +#define IPMI_CMD_OEM_FABRIC_CREATE 0xF2 +#define IPMI_CMD_OEM_FABRIC_DELETE 0xF3 +#define IPMI_CMD_OEM_FABRIC_TRACE 0xF4 + +#define IPMI_CMD_OEM_FABRIC_PARAMETER_IPADDR 0x01 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_NETMASK 0x02 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_DEFGW 0x03 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_IPSRC 0x04 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_MACADDR 0x05 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_IPINFO 0x06 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_MTU 0x07 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_UPLINK_MODE 0x08 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_MACADDRS 0x09 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_NODEID 0x0A +#define IPMI_CMD_OEM_FABRIC_PARAMETER_LINKSPEED 0x0B +#define IPMI_CMD_OEM_FABRIC_PARAMETER_UPLINK 0x0C +#define IPMI_CMD_OEM_FABRIC_PARAMETER_LINKMAP 0x0D +#define IPMI_CMD_OEM_FABRIC_PARAMETER_DEPTH_CHART 0x0E +#define IPMI_CMD_OEM_FABRIC_PARAMETER_ROUTING_TABLE 0x0F +#define IPMI_CMD_OEM_FABRIC_PARAMETER_LINK_STATS 0x10 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_MAC_STATS 0x11 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_UPLINK_STATS 0x12 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_MAC_CHANNEL_STATS 0x13 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_GLOBAL_WATCH 0x14 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_MAC_WATCH 0x15 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_MAC_CHANNEL_WATCH 0x16 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_LINK_WATCH 0x17 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_UPLINK_WATCH 0x18 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_NTP_SERVER 0x19 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_NTP_PORT 0x1A +#define IPMI_CMD_OEM_FABRIC_PARAMETER_LINK_RESILIENCE 0x1B +#define IPMI_CMD_OEM_FABRIC_PARAMETER_NODENUM_OFFSET 0x1C +#define IPMI_CMD_OEM_FABRIC_PARAMETER_LINKSPEED_POLICY 0x1D +#define IPMI_CMD_OEM_FABRIC_PARAMETER_LINK_USERS 0x1E +#define IPMI_CMD_OEM_FABRIC_PARAMETER_CONFIGURATIONID 0x1F +#define IPMI_CMD_OEM_FABRIC_PARAMETER_PARTITIONID 0x20 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_PARTITION_NODES 0x21 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_PARTITION_RANGE 0x22 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_PROFILEID 0x23 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_IPADDR_BASE 0x24 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_IPADDR_NUM 0x25 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_CUSTOMER_MACADDR 0x26 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_LINK_USERS_FACTOR 0x27 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_UPLINK_INFO 0x28 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_START 0x29 +#define IPMI_CMD_OEM_FABRIC_PARAMETER_STOP 0x2a +#define IPMI_CMD_OEM_FABRIC_PARAMETER_STATUS 0x2b +#define IPMI_CMD_OEM_FABRIC_PARAMETER_DUMP 0x2c +#define IPMI_CMD_OEM_FABRIC_PARAMETER_LACP_STATUS 0x2d + +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_NODE 0x40 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_INTERFACE 0x41 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_TFTP 0x42 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_PORT 0x43 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_FILENAME 0x44 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_LINK 0x45 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_OVERRIDE 0x46 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_MAC 0x47 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_HOST 0x48 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_FREQUENCY 0x49 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_ACTUAL 0x50 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_AVERAGING_FREQUENCY 0x51 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_CONFIGURATION 0x52 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_PARTITION 0x53 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_PROFILE 0x54 +#define IPMI_CMD_OEM_FABRIC_SPECIFIER_SIZE 0x55 + +/* + * CX-defined constants + */ +#define CXOEM_FW_DOWNLOAD 1 +#define CXOEM_FW_STOP 2 +#define CXOEM_FW_UPLOAD 3 +#define CXOEM_FW_REGISTER_READ 4 +#define CXOEM_FW_REGISTER_WRITE 5 + + +static const int CXOEM_SUCCESS = 0; +static const int CXOEM_ERROR = -1; + + +/* + * OEM FW rq/rs structs + */ + +typedef struct img_info_s { + unsigned char id; + unsigned char type; + uint32_t img_addr; + uint32_t img_size; + uint32_t in_use; +} __attribute__ ((packed)) img_info_t; + +typedef struct simg_header_s { + unsigned char magic[4]; + uint16_t hdrfmt; + uint16_t priority; + uint32_t imgoff; + uint32_t imglen; + uint32_t daddr; + uint32_t flags; + uint32_t crc32; + unsigned char version[32]; +} __attribute__ ((packed)) simg_header_t; + +struct cx_fw_info_rs { + unsigned char ver; /* param version */ + unsigned char count; /* number of bytes */ + img_info_t img_info; +} __attribute__ ((packed)); + + +/* + * OEM info rs structs + */ + +typedef union cx_info_basic_u { + /* Revision 1 */ + struct { + uint32_t iana; + uint8_t parameter_revision; + uint8_t ecme_major_version; + uint8_t ecme_minor_version; + uint8_t ecme_revision; + uint32_t ecme_build_number; + uint32_t ecme_timestamp; + char firmware_version[32]; + } __attribute__ ((packed)) rev1; + + /* Revision 2 -- replaced ECME version with a string */ + struct { + uint32_t iana; + uint8_t parameter_revision; + char ecme_version[32]; + uint32_t ecme_timestamp; + char firmware_version[32]; + } __attribute__ ((packed)) rev2; +} cx_info_basic_t; + + +/* + * Prototypes + */ +int ipmi_cxoem_main(struct ipmi_intf *, int, char **); + +#endif /*IPMI_CXOEM_H */ diff --git a/include/ipmitool/ipmi_lanp.h b/include/ipmitool/ipmi_lanp.h index 1aaae5e..0e457f7 100644 --- a/include/ipmitool/ipmi_lanp.h +++ b/include/ipmitool/ipmi_lanp.h @@ -79,10 +79,17 @@ enum { IPMI_LANP_OEM_ALERT_STRING=96, IPMI_LANP_ALERT_RETRY=97, IPMI_LANP_UTC_OFFSET=98, - IPMI_LANP_DHCP_SERVER_IP=192, - IPMI_LANP_DHCP_SERVER_MAC=193, - IPMI_LANP_DHCP_ENABLE=194, - IPMI_LANP_CHAN_ACCESS_MODE=201, + IPMI_LANP_TFTP_SERVER_IP=193, + IPMI_LANP_TFTP_UDP_PORT=194, + IPMI_LANP_NTP_SERVER_IP=195, + IPMI_LANP_NTP_UDP_PORT=196, + IPMI_LANP_OEM_OUID=197, + IPMI_LANP_OEM_MAC0=198, + IPMI_LANP_OEM_MAC1=199, + IPMI_LANP_OEM_MAC2=200, + IPMI_LANP_SC_OUID=201, + IPMI_LANP_SC_MODE=202, + IPMI_LANP_SC_FID=203 }; static struct lan_param { @@ -120,10 +127,17 @@ static struct lan_param { { IPMI_LANP_OEM_ALERT_STRING, 28, "OEM Alert String" }, /* 25 */ { IPMI_LANP_ALERT_RETRY, 1, "Alert Retry Algorithm" }, { IPMI_LANP_UTC_OFFSET, 3, "UTC Offset" }, - { IPMI_LANP_DHCP_SERVER_IP, 4, "DHCP Server IP" }, - { IPMI_LANP_DHCP_SERVER_MAC, 6, "DHDP Server MAC" }, - { IPMI_LANP_DHCP_ENABLE, 1, "DHCP Enable" }, /* 30 */ - { IPMI_LANP_CHAN_ACCESS_MODE, 2, "Channel Access Mode" }, + { IPMI_LANP_TFTP_SERVER_IP, 4, "TFTP Server IP" }, /* 28 */ + { IPMI_LANP_TFTP_UDP_PORT, 2, "TFTP UDP port" }, + { IPMI_LANP_NTP_SERVER_IP, 4, "NTP Server IP" }, + { IPMI_LANP_NTP_UDP_PORT, 2, "NTP UDP port" }, + { IPMI_LANP_OEM_OUID, 3, "OEM OUID" }, + { IPMI_LANP_OEM_MAC0, 6, "OEM MAC0" }, + { IPMI_LANP_OEM_MAC1, 6, "OEM MAC1" }, + { IPMI_LANP_OEM_MAC2, 6, "OEM MAC2" }, + { IPMI_LANP_SC_OUID, 3, "Supercluster OUID" }, + { IPMI_LANP_SC_MODE, 1, "Supercluster mode" }, + { IPMI_LANP_SC_FID, 1, "Supercluster FID" }, { -1 } }; diff --git a/lib/Makefile.am b/lib/Makefile.am index 3422521..f304502 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -39,7 +39,7 @@ libipmitool_la_SOURCES = helper.c ipmi_sdr.c ipmi_sel.c ipmi_sol.c ipmi_pef.c \ ipmi_oem.c ipmi_isol.c ipmi_sunoem.c ipmi_fwum.c ipmi_picmg.c \ ipmi_main.c ipmi_tsol.c ipmi_firewall.c ipmi_kontronoem.c \ ipmi_hpmfwupg.c ipmi_sdradd.c ipmi_ekanalyzer.c ipmi_gendev.c \ - ipmi_ime.c ipmi_delloem.c ipmi_dcmi.c \ + ipmi_ime.c ipmi_delloem.c ipmi_dcmi.c ipmi_cxoem.c \ ../src/plugins/lan/md5.c ../src/plugins/lan/md5.h libipmitool_la_LDFLAGS = -export-dynamic diff --git a/lib/ipmi_chassis.c b/lib/ipmi_chassis.c index 2d47974..445b34d 100644 --- a/lib/ipmi_chassis.c +++ b/lib/ipmi_chassis.c @@ -746,6 +746,12 @@ ipmi_chassis_get_bootparam(struct ipmi_intf * intf, char * arg) printf(" Block Data : %s\n", buf2str(rsp->data+3, rsp->data_len - 2)); } break; + case 96: + { + printf(" Selector : %d\n", rsp->data[1] ); + printf(" Boot Policy : %d\n", rsp->data[2] ); + } + break; default: printf(" Undefined byte\n"); break; @@ -860,6 +866,86 @@ ipmi_chassis_set_bootdev(struct ipmi_intf * intf, char * arg, uint8_t *iflags) } static int +ipmi_chassis_set_boot_policy(struct ipmi_intf * intf, char * arg) +{ + uint8_t flags[5]; + int rc = 0; + int use_progress = 1; + + if (use_progress) { + /* set set-in-progress flag */ + memset(flags, 0, 5); + flags[0] = 0x01; + rc = ipmi_chassis_set_bootparam(intf, + IPMI_CHASSIS_BOOTPARAM_SET_IN_PROGRESS, flags, 1); + if (rc < 0) + use_progress = 0; + } + + memset(flags, 0, 5); + flags[0] = 0x01; + flags[1] = 0x01; + rc = ipmi_chassis_set_bootparam(intf, IPMI_CHASSIS_BOOTPARAM_INFO_ACK, + flags, 2); + + if (rc < 0) { + if (use_progress) { + /* set-in-progress = set-complete */ + memset(flags, 0, 5); + ipmi_chassis_set_bootparam(intf, + IPMI_CHASSIS_BOOTPARAM_SET_IN_PROGRESS, + flags, 1); + } + return -1; + } + + memset(flags, 0, 5); + + if (strncmp(arg, "0", 1) == 0) + flags[0] = 0; + else if (strncmp(arg, "1", 1) == 0) + flags[0] = 1; + else if (strncmp(arg, "2", 1) == 0) + flags[0] = 2; + else { + lprintf(LOG_ERR, "Invalid argument: %s", arg); + if (use_progress) { + /* set-in-progress = set-complete */ + memset(flags, 0, 5); + ipmi_chassis_set_bootparam(intf, + IPMI_CHASSIS_BOOTPARAM_SET_IN_PROGRESS, + flags, 1); + } + return -1; + } + + rc = ipmi_chassis_set_bootparam(intf, IPMI_CHASSIS_BOOTPARAM_OEM_BOOT_POLICY, + flags, 1); + if (rc == 0) { + if (use_progress) { + /* set-in-progress = commit-write */ + memset(flags, 0, 5); + flags[0] = 0x02; + ipmi_chassis_set_bootparam(intf, + IPMI_CHASSIS_BOOTPARAM_SET_IN_PROGRESS, + flags, 1); + } + + printf("Set Boot Policy to %s\n", arg); + } + + if (use_progress) { + /* set-in-progress = set-complete */ + memset(flags, 0, 5); + ipmi_chassis_set_bootparam(intf, + IPMI_CHASSIS_BOOTPARAM_SET_IN_PROGRESS, + flags, 1); + } + + return rc; +} + +static int ipmi_chassis_power_policy(struct ipmi_intf * intf, uint8_t policy) { struct ipmi_rs * rsp; @@ -1043,6 +1129,10 @@ ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv) lprintf(LOG_NOTICE, " force_diag : Force boot from Diagnostic Partition"); lprintf(LOG_NOTICE, " force_cdrom : Force boot from CD/DVD"); lprintf(LOG_NOTICE, " force_bios : Force boot into BIOS Setup"); + lprintf(LOG_NOTICE, "bootparam set policy "); + lprintf(LOG_NOTICE, " 0 : Boot ASAP"); + lprintf(LOG_NOTICE, " 1 : Boot when Fabric is ready"); + lprintf(LOG_NOTICE, " 2 : Boot after a fixed delay"); } else { if (strncmp(argv[1], "get", 3) == 0) { @@ -1054,6 +1144,8 @@ ipmi_chassis_main(struct ipmi_intf * intf, int argc, char ** argv) } else { if (strncmp(argv[2], "bootflag", 8) == 0) rc = ipmi_chassis_set_bootdev(intf, argv[3], NULL); + else if (strncmp(argv[2], "policy", 6) == 0) + rc = ipmi_chassis_set_boot_policy(intf, argv[3]); else lprintf(LOG_NOTICE, "bootparam set