From a654ca268323ee32639e01a56431959bf8976826 Mon Sep 17 00:00:00 2001 From: Francois Isabelle Date: Wed, 12 Dec 2007 15:03:17 +0000 Subject: [PATCH] improved amcportstate operations - can now run on AMCs as well as carriers - output format is more human readable thanks to Heiko Thiery for his patch --- ipmitool/include/ipmitool/ipmi_picmg.h | 89 +++- ipmitool/lib/ipmi_picmg.c | 653 ++++++++++++++----------- 2 files changed, 433 insertions(+), 309 deletions(-) diff --git a/ipmitool/include/ipmitool/ipmi_picmg.h b/ipmitool/include/ipmitool/ipmi_picmg.h index d419aae..18f6f46 100644 --- a/ipmitool/include/ipmitool/ipmi_picmg.h +++ b/ipmitool/include/ipmitool/ipmi_picmg.h @@ -53,16 +53,12 @@ #define PICMG_PMC 0x08 #define PICMG_RTM 0x09 - - struct picmg_set_fru_activation_cmd { unsigned char picmg_id; /* always 0*/ unsigned char fru_id; /* threshold setting mask */ unsigned char fru_state; /* fru activation/deactivation */ } __attribute__ ((packed)); - - /* the LED color capabilities */ static const char* led_color_str[] __attribute__((unused)) = { "reserved", @@ -74,19 +70,84 @@ static const char* led_color_str[] __attribute__((unused)) = { "WHITE", "reserved" }; - - + + static const char* amc_link_type_str[] __attribute__((unused)) = { - " FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED", - " FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED1", - " FRU_PICMGEXT_AMC_LINK_TYPE_PCI_EXPRESS", - " FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING1", - " FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING2", - " FRU_PICMGEXT_AMC_LINK_TYPE_ETHERNET", - " FRU_PICMGEXT_AMC_LINK_TYPE_RAPIDIO", - " FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE", + "RESERVED", + "RESERVED1", + "PCI EXPRESS", + "ADVANCED SWITCHING1", + "ADVANCED SWITCHING2", + "ETHERNET", + "RAPIDIO", + "STORAGE", }; +static const char* amc_link_type_ext_str[][16] __attribute__((unused)) = { + /* FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED */ + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" + }, + /* FRU_PICMGEXT_AMC_LINK_TYPE_RESERVED1 */ + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" + }, + /* FRU_PICMGEXT_AMC_LINK_TYPE_PCI_EXPRESS */ + { + "Gen 1 - NSSC", + "Gen 1 - SSC", + "Gen 2 - NSSC", + "Gen 2 - SSC", + "", "", "", "", + "", "", "", "", + "", "", "", "" + }, + /* FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING1 */ + { + "Gen 1 - NSSC", + "Gen 1 - SSC", + "Gen 2 - NSSC", + "Gen 2 - SSC", + "", "", "", "", + "", "", "", "", + "", "", "", "" + }, + /* FRU_PICMGEXT_AMC_LINK_TYPE_ADVANCED_SWITCHING2 */ + { + "Gen 1 - NSSC", + "Gen 1 - SSC", + "Gen 2 - NSSC", + "Gen 2 - SSC", + "", "", "", "", + "", "", "", "", + "", "", "", "" + }, + /* FRU_PICMGEXT_AMC_LINK_TYPE_ETHERNET */ + { + "1000BASE-BX (SerDES Gigabit)", + "10GBASE-BX410 Gigabit XAUI", + "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "" + }, + /* FRU_PICMGEXT_AMC_LINK_TYPE_RAPIDIO */ + { + "1.25 Gbaud transmission rate", + "2.5 Gbaud transmission rate", + "3.125 Gbaud transmission rate", + "", "", "", "", "", + "", "", "", "", "", "", "", "" + }, + /* FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE */ + { + "Fibre Channel", + "Serial ATA", + "Serial Attached SCSI", + "", "", "", "", "", + "", "", "", "", "", "", "", "" + } +}; struct sAmcPortState { #ifndef WORDS_BIGENDIAN diff --git a/ipmitool/lib/ipmi_picmg.c b/ipmitool/lib/ipmi_picmg.c index 64ab09d..0d919d7 100644 --- a/ipmitool/lib/ipmi_picmg.c +++ b/ipmitool/lib/ipmi_picmg.c @@ -1,14 +1,45 @@ - /* - (C) Kontron + Copyright (c) Kontron. All right 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 Kontron, 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. + * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. + * DELL COMPUTERS ("DELL") AND ITS LICENSORS SHALL NOT BE LIABLE + * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING + * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL + * DELL OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, + * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, + * EVEN IF DELL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ -*/ #include #include #include /* for access to link descriptor defines */ #include +#define PICMG_EXTENSION_ATCA_MAJOR_VERSION 2 +#define PICMG_EXTENSION_AMC0_MAJOR_VERSION 4 +#define PICMG_EXTENSION_UTCA_MAJOR_VERSION 5 + #define PICMG_EKEY_MODE_QUERY 0 #define PICMG_EKEY_MODE_PRINT_ALL 1 @@ -22,6 +53,8 @@ #define PICMG_EKEY_AMC_MAX_CHANNEL 16 #define PICMG_EKEY_AMC_MAX_DEVICE 15 /* 4 bits */ +/* This is the version of the PICMG Extenstion */ +static unsigned char PicmgExtMajorVersion; void ipmi_picmg_help (void) @@ -146,7 +179,7 @@ ipmi_picmg_getaddr(struct ipmi_intf * intf, int argc, char ** argv) } int -ipmi_picmg_properties(struct ipmi_intf * intf) +ipmi_picmg_properties(struct ipmi_intf * intf, int show ) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -164,11 +197,19 @@ ipmi_picmg_properties(struct ipmi_intf * intf) printf("Error getting address information\n"); return -1; } - - printf("PICMG identifier : 0x%02x\n", rsp->data[0]); - printf("PICMG Ext. Version : %i.%i\n", rsp->data[1]&0x0f, (rsp->data[1]&0xf0) >> 4); - printf("Max FRU Device ID : 0x%02x\n", rsp->data[2]); - printf("FRU Device ID : 0x%02x\n", rsp->data[3]); + + if( show ) + { + printf("PICMG identifier : 0x%02x\n", rsp->data[0]); + printf("PICMG Ext. Version : %i.%i\n", rsp->data[1]&0x0f, + (rsp->data[1]&0xf0) >> 4); + printf("Max FRU Device ID : 0x%02x\n", rsp->data[2]); + printf("FRU Device ID : 0x%02x\n", rsp->data[3]); + } + + /* We cache the major extension version ... + to know how to format some commands */ + PicmgExtMajorVersion = rsp->data[1]&0x0f; return 0; } @@ -176,7 +217,7 @@ ipmi_picmg_properties(struct ipmi_intf * intf) #define PICMG_FRU_DEACTIVATE (unsigned char) 0x00 -#define PICMG_FRU_ACTIVATE (unsigned char) 0x01 +#define PICMG_FRU_ACTIVATE (unsigned char) 0x01 int ipmi_picmg_fru_activation(struct ipmi_intf * intf, int argc, char ** argv, unsigned char state) @@ -187,18 +228,18 @@ ipmi_picmg_fru_activation(struct ipmi_intf * intf, int argc, char ** argv, unsig struct picmg_set_fru_activation_cmd cmd; memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_FRU_ACTIVATION_CMD; - req.msg.data = (unsigned char*) &cmd; + req.msg.netfn = IPMI_NETFN_PICMG; + req.msg.cmd = PICMG_FRU_ACTIVATION_CMD; + req.msg.data = (unsigned char*) &cmd; req.msg.data_len = 3; cmd.picmg_id = 0; /* PICMG identifier */ - cmd.fru_id = (unsigned char) atoi(argv[0]); /* FRU ID */ + cmd.fru_id = (unsigned char) atoi(argv[0]); /* FRU ID */ cmd.fru_state = state; rsp = intf->sendrecv(intf, &req); - if (!rsp || rsp->ccode) { + if (!rsp || rsp->ccode) { printf("Error activation/deactivation of FRU\n"); return -1; } @@ -219,13 +260,13 @@ ipmi_picmg_fru_activation_policy_get(struct ipmi_intf * intf, int argc, char ** unsigned char msg_data[4]; memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_GET_FRU_POLICY_CMD; - req.msg.data = msg_data; + req.msg.netfn = IPMI_NETFN_PICMG; + req.msg.cmd = PICMG_GET_FRU_POLICY_CMD; + req.msg.data = msg_data; req.msg.data_len = 2; msg_data[0] = 0; /* PICMG identifier */ - msg_data[1] = (unsigned char) atoi(argv[0]); /* FRU ID */ + msg_data[1] = (unsigned char) atoi(argv[0]); /* FRU ID */ rsp = intf->sendrecv(intf, &req); @@ -240,9 +281,9 @@ ipmi_picmg_fru_activation_policy_get(struct ipmi_intf * intf, int argc, char ** } printf(" %s\n", ((rsp->data[1] & 0x01) == 0x01) ? - "activation locked" : "activation not locked"); + "activation locked" : "activation not locked"); printf(" %s\n", ((rsp->data[1] & 0x02) == 0x02) ? - "deactivation locked" : "deactivation not locked"); + "deactivation locked" : "deactivation not locked"); return 0; } @@ -256,14 +297,14 @@ ipmi_picmg_fru_activation_policy_set(struct ipmi_intf * intf, int argc, char ** unsigned char msg_data[4]; memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_SET_FRU_POLICY_CMD; - req.msg.data = msg_data; + req.msg.netfn = IPMI_NETFN_PICMG; + req.msg.cmd = PICMG_SET_FRU_POLICY_CMD; + req.msg.data = msg_data; req.msg.data_len = 4; - msg_data[0] = 0; /* PICMG identifier */ - msg_data[1] = (unsigned char) atoi(argv[0]); /* FRU ID */ - msg_data[2] = (unsigned char) atoi(argv[1])& 0x03; /* FRU act policy mask */ + msg_data[0] = 0; /* PICMG identifier */ + msg_data[1] = (unsigned char) atoi(argv[0]); /* FRU ID */ + msg_data[2] = (unsigned char) atoi(argv[1])& 0x03; /* FRU act policy mask */ msg_data[3] = (unsigned char) atoi(argv[2])& 0x03; /* FRU act policy set bits */ rsp = intf->sendrecv(intf, &req); @@ -285,7 +326,7 @@ ipmi_picmg_fru_activation_policy_set(struct ipmi_intf * intf, int argc, char ** int ipmi_picmg_portstate_get(struct ipmi_intf * intf, int interface,int channel, - int mode) + int mode) { struct ipmi_rs * rsp = NULL; struct ipmi_rq req; @@ -296,13 +337,13 @@ ipmi_picmg_portstate_get(struct ipmi_intf * intf, int interface,int channel, memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_GET_PORT_STATE_CMD; - req.msg.data = msg_data; + req.msg.netfn = IPMI_NETFN_PICMG; + req.msg.cmd = PICMG_GET_PORT_STATE_CMD; + req.msg.data = msg_data; req.msg.data_len = 2; msg_data[0] = 0x00; /* PICMG identifier */ - msg_data[1] = (interface & 0x3)<<6; /* interface */ + msg_data[1] = (interface & 0x3)<<6; /* interface */ msg_data[1] |= (channel & 0x3F); /* channel number */ rsp = intf->sendrecv(intf, &req); @@ -321,14 +362,14 @@ ipmi_picmg_portstate_get(struct ipmi_intf * intf, int interface,int channel, if (rsp->data_len >= 6) { int index; - + /* add support for more than one link per channel */ for(index=0;indexdata_len > (1+ (index*5))){ d = (struct fru_picmgext_link_desc *) &(rsp->data[1 + (index*5)]); - + if ( mode == PICMG_EKEY_MODE_PRINT_ALL @@ -348,9 +389,9 @@ ipmi_picmg_portstate_get(struct ipmi_intf * intf, int interface,int channel, ) ) { - printf(" Link Grouping ID: 0x%02x\n", d->grouping); - printf(" Link Type Extension: 0x%02x\n", d->ext); - printf(" Link Type: 0x%02x ", d->type); + printf(" Link Grouping ID: 0x%02x\n", d->grouping); + printf(" Link Type Extension: 0x%02x\n", d->ext); + printf(" Link Type: 0x%02x ", d->type); if (d->type == 0 || d->type == 0xff) { printf("Reserved %d\n",d->type); @@ -379,7 +420,7 @@ ipmi_picmg_portstate_get(struct ipmi_intf * intf, int interface,int channel, case FRU_PICMGEXT_LINK_TYPE_FABRIC_STAR: printf("PICMG 3.3 Star Fabric Interface\n"); break; - case FRU_PICMGEXT_LINK_TYPE_PCIE: + case FRU_PICMGEXT_LINK_TYPE_PCIE: printf("PCI Express Fabric Interface\n"); break; default: @@ -387,9 +428,9 @@ ipmi_picmg_portstate_get(struct ipmi_intf * intf, int interface,int channel, break; } } - printf(" Link Designator: \n"); - printf(" Port Flag: 0x%02x\n", d->desig_port); - printf(" Interface: 0x%02x - ", d->desig_if); + printf(" Link Designator: \n"); + printf(" Port Flag: 0x%02x\n", d->desig_port); + printf(" Interface: 0x%02x - ", d->desig_if); switch (d->desig_if) { case FRU_PICMGEXT_DESIGN_IF_BASE: @@ -408,9 +449,9 @@ ipmi_picmg_portstate_get(struct ipmi_intf * intf, int interface,int channel, printf("Invalid"); break; } - printf(" Channel Number: 0x%02x\n", d->desig_channel); + printf(" Channel Number: 0x%02x\n", d->desig_channel); printf("\n"); - printf(" STATE: %s\n", rsp->data[5 +(index*5)] == 0x01?"enabled":"disabled"); + printf(" STATE: %s\n", rsp->data[5 +(index*5)] == 0x01?"enabled":"disabled"); } } } @@ -425,8 +466,8 @@ ipmi_picmg_portstate_get(struct ipmi_intf * intf, int interface,int channel, int -ipmi_picmg_portstate_set(struct ipmi_intf * intf, int interface, int channel, - int port, int type, int typeext, int group, int enable) +ipmi_picmg_portstate_set(struct ipmi_intf * intf, int interface, int channel, + int port, int type, int typeext, int group, int enable) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -436,24 +477,17 @@ ipmi_picmg_portstate_set(struct ipmi_intf * intf, int interface, int channel, memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_SET_PORT_STATE_CMD; - req.msg.data = msg_data; + req.msg.netfn = IPMI_NETFN_PICMG; + req.msg.cmd = PICMG_SET_PORT_STATE_CMD; + req.msg.data = msg_data; req.msg.data_len = 6; - msg_data[0] = 0x00; /* PICMG identifier */ - - d = (struct fru_picmgext_link_desc*) &(msg_data[1]); - - d->desig_channel = (unsigned char) (channel & 0x1F); /* channel */ - d->desig_if = (unsigned char) ((interface & 0x03) << 6); /* interface */ - d->desig_port = (unsigned char) ((port & 0x03) << 8); /* port */ - - d->type = (unsigned char) (type & 0xFF); /* link type */ - d->ext = (unsigned char) (typeext & 0x03); /* type ext */ - d->grouping = (unsigned char) (group & 0xFF); /* type ext */ - - msg_data[5] = (unsigned char) (enable & 0x01); /* en/dis */ + msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[1] = (channel & 0x3f) | ((interface & 3) << 6); + msg_data[2] = (port & 0xf) | ((type & 0xf) << 4); + msg_data[3] = ((type >> 4) & 0xf) | ((typeext & 0xf) << 4); + msg_data[4] = group & 0xff; + msg_data[5] = (unsigned char) (enable & 0x01); /* en/dis */ rsp = intf->sendrecv(intf, &req); @@ -478,7 +512,7 @@ ipmi_picmg_portstate_set(struct ipmi_intf * intf, int interface, int channel, int ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf,int device,int channel, - int mode) + int mode) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -489,12 +523,16 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf,int device,int channel, memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_AMC_GET_PORT_STATE_CMD; - req.msg.data = msg_data; + req.msg.netfn = IPMI_NETFN_PICMG; + req.msg.cmd = PICMG_AMC_GET_PORT_STATE_CMD; + req.msg.data = msg_data; /* FIXME : add check for AMC or carrier device */ - req.msg.data_len = 3; + if(device == -1 || PicmgExtMajorVersion != 2){ + req.msg.data_len = 2; /* for amc only channel */ + }else{ + req.msg.data_len = 3; /* for carrier channel and device */ + } msg_data[0] = 0x00; /* PICMG identifier */ msg_data[1] = channel ; @@ -517,10 +555,10 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf,int device,int channel, if (rsp->data_len >= 5) { int index; - + /* add support for more than one link per channel */ for(index=0;indexdata_len > (1+ (index*4))){ unsigned char type; unsigned char ext; @@ -529,12 +567,12 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf,int device,int channel, unsigned char enabled; d = (struct fru_picmgext_amc_link_info *)&(rsp->data[1 + (index*4)]); - + /* Removed endianness check here, probably not required as we dont use bitfields */ - port = d->linkInfo[0] & 0x0F; - type = ((d->linkInfo[0] & 0xF0) >> 4 )|(d->linkInfo[1] & 0x0F ); - ext = ((d->linkInfo[1] & 0xF0) >> 4 ); + port = d->linkInfo[0] & 0x0F; + type = ((d->linkInfo[0] & 0xF0) >> 4 )|(d->linkInfo[1] & 0x0F ); + ext = ((d->linkInfo[1] & 0xF0) >> 4 ); grouping = d->linkInfo[2]; @@ -555,36 +593,43 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf,int device,int channel, ( mode == PICMG_EKEY_MODE_PRINT_DISABLED && - enabled == 0x00 + enabled == 0x00 ) ) { - printf(" Link device : 0x%02x\n", device ); - printf(" Link channel: 0x%02x\n", channel); + if(device == -1 || PicmgExtMajorVersion != 2){ + printf(" Link device : AMC\n"); + }else{ + printf(" Link device : 0x%02x\n", device ); + } + printf(" Link channel: 0x%02x\n", channel); + + printf(" Link Grouping ID: 0x%02x\n", grouping); - printf(" Link Grouping ID: 0x%02x\n", grouping); - printf(" Link Type Extension: 0x%02x\n", ext); - printf(" Link Type: "); if (type == 0 || type == 1 ||type == 0xff) { - printf("Reserved\n"); + printf(" Link Type Extension: 0x%02x\n", ext); + printf(" Link Type: Reserved\n"); } else if (type >= 0xf0 && type <= 0xfe) { - printf("OEM GUID Definition\n"); + printf(" Link Type Extension: 0x%02x\n", ext); + printf(" Link Type: OEM GUID Definition\n"); } else { if (type <= FRU_PICMGEXT_AMC_LINK_TYPE_STORAGE ) { - printf("%s\n",amc_link_type_str[type]); + printf(" Link Type Extension: %s\n",amc_link_type_ext_str[type][ext]); + printf(" Link Type: %s\n",amc_link_type_str[type]); } else{ - printf("undefined\n"); + printf(" Link Type Extension: 0x%02x\n", ext); + printf(" Link Type: undefined\n"); } } - printf(" Port Flag: 0x%02x\n", port ); - printf(" STATE: %s\n",( enabled == 0x01 )?"enabled":"disabled"); + printf(" Port Flag: 0x%02x\n", port ); + printf(" STATE: %s\n",( enabled == 0x01 )?"enabled":"disabled"); printf("\n"); } } @@ -599,34 +644,34 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf,int device,int channel, return 0; } - + int ipmi_picmg_amc_portstate_set(struct ipmi_intf * intf, int channel, int port, - int type, int typeext, int group, int enable, int device) + int type, int typeext, int group, int enable, int device) { - struct ipmi_rs * rsp; - struct ipmi_rq req; - unsigned char msg_data[7]; + struct ipmi_rs * rsp; + struct ipmi_rq req; + unsigned char msg_data[7]; memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_AMC_SET_PORT_STATE_CMD; - req.msg.data = msg_data; + req.msg.netfn = IPMI_NETFN_PICMG; + req.msg.cmd = PICMG_AMC_SET_PORT_STATE_CMD; + req.msg.data = msg_data; - msg_data[0] = 0x00; /* PICMG identifier*/ - msg_data[1] = channel; /* channel id */ - msg_data[2] = port & 0xF; /* port flags */ - msg_data[2] |= (type & 0x0F)<<4; /* type */ - msg_data[3] = (type & 0xF0)>>4; /* type */ - msg_data[3] |= (typeext & 0x0F)<<4; /* extension */ - msg_data[4] = (group & 0xFF); /* group */ - msg_data[5] = (enable & 0x01); /* state */ + msg_data[0] = 0x00; /* PICMG identifier*/ + msg_data[1] = channel; /* channel id */ + msg_data[2] = port & 0xF; /* port flags */ + msg_data[2] |= (type & 0x0F)<<4; /* type */ + msg_data[3] = (type & 0xF0)>>4; /* type */ + msg_data[3] |= (typeext & 0x0F)<<4; /* extension */ + msg_data[4] = (group & 0xFF); /* group */ + msg_data[5] = (enable & 0x01); /* state */ req.msg.data_len = 6; /* device id - only for carrier needed */ if (device >= 0) { - msg_data[6] = device; + msg_data[6] = device; req.msg.data_len = 7; } @@ -657,11 +702,11 @@ ipmi_picmg_get_led_properties(struct ipmi_intf * intf, int argc, char ** argv) memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_GET_FRU_LED_PROPERTIES_CMD; + req.msg.cmd = PICMG_GET_FRU_LED_PROPERTIES_CMD; req.msg.data = msg_data; req.msg.data_len = 2; - msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[0] = 0x00; /* PICMG identifier */ msg_data[1] = atoi(argv[0]); /* FRU-ID */ rsp = intf->sendrecv(intf, &req); @@ -676,8 +721,8 @@ ipmi_picmg_get_led_properties(struct ipmi_intf * intf, int argc, char ** argv) return -1; } - printf("General Status LED Properties: 0x%2x\n\r", rsp->data[1] ); - printf("App. Specific LED Count: 0x%2x\n\r", rsp->data[2] ); + printf("General Status LED Properties: 0x%2x\n\r", rsp->data[1] ); + printf("App. Specific LED Count: 0x%2x\n\r", rsp->data[2] ); return 0; } @@ -694,11 +739,11 @@ ipmi_picmg_get_led_capabilities(struct ipmi_intf * intf, int argc, char ** argv) memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_GET_LED_COLOR_CAPABILITIES_CMD; + req.msg.cmd = PICMG_GET_LED_COLOR_CAPABILITIES_CMD; req.msg.data = msg_data; req.msg.data_len = 3; - msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[0] = 0x00; /* PICMG identifier */ msg_data[1] = atoi(argv[0]); /* FRU-ID */ msg_data[2] = atoi(argv[1]); /* LED-ID */ @@ -724,8 +769,8 @@ ipmi_picmg_get_led_capabilities(struct ipmi_intf * intf, int argc, char ** argv) printf("\n\r"); printf("Default LED Color in\n\r"); - printf(" LOCAL control: %s\n\r", led_color_str[ rsp->data[2] ] ); - printf(" OVERRIDE state: %s\n\r", led_color_str[ rsp->data[3] ] ); + printf(" LOCAL control: %s\n\r", led_color_str[ rsp->data[2] ] ); + printf(" OVERRIDE state: %s\n\r", led_color_str[ rsp->data[3] ] ); return 0; } @@ -741,11 +786,11 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_GET_FRU_LED_STATE_CMD; + req.msg.cmd = PICMG_GET_FRU_LED_STATE_CMD; req.msg.data = msg_data; req.msg.data_len = 3; - msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[0] = 0x00; /* PICMG identifier */ msg_data[1] = atoi(argv[0]); /* FRU-ID */ msg_data[2] = atoi(argv[1]); /* LED-ID */ @@ -762,7 +807,7 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) return -1; } - printf("LED states: %x ", rsp->data[1] ); + printf("LED states: %x ", rsp->data[1] ); if (rsp->data[1] == 0x1) printf("[LOCAL CONTROL]\n\r"); else if (rsp->data[1] == 0x2) @@ -772,7 +817,7 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) else printf("\n\r"); - printf(" Local Control function: %x ", rsp->data[2] ); + printf(" Local Control function: %x ", rsp->data[2] ); if (rsp->data[2] == 0x0) printf("[OFF]\n\r"); else if (rsp->data[2] == 0xff) @@ -780,12 +825,12 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) else printf("[BLINKING]\n\r"); - printf(" Local Control On-Duration: %x\n\r", rsp->data[3] ); - printf(" Local Control Color: %x [%s]\n\r", rsp->data[4], led_color_str[ rsp->data[4] ]); + printf(" Local Control On-Duration: %x\n\r", rsp->data[3] ); + printf(" Local Control Color: %x [%s]\n\r", rsp->data[4], led_color_str[ rsp->data[4] ]); /* override state or lamp test */ if (rsp->data[1] == 0x02) { - printf(" Override function: %x ", rsp->data[5] ); + printf(" Override function: %x ", rsp->data[5] ); if (rsp->data[2] == 0x0) printf("[OFF]\n\r"); else if (rsp->data[2] == 0xff) @@ -793,20 +838,20 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) else printf("[BLINKING]\n\r"); - printf(" Override On-Duration: %x\n\r", rsp->data[6] ); - printf(" Override Color: %x [%s]\n\r", rsp->data[7], led_color_str[ rsp->data[7] ]); + printf(" Override On-Duration: %x\n\r", rsp->data[6] ); + printf(" Override Color: %x [%s]\n\r", rsp->data[7], led_color_str[ rsp->data[7] ]); }else if (rsp->data[1] == 0x06) { - printf(" Override function: %x ", rsp->data[5] ); + printf(" Override function: %x ", rsp->data[5] ); if (rsp->data[2] == 0x0) printf("[OFF]\n\r"); else if (rsp->data[2] == 0xff) printf("[ON]\n\r"); else printf("[BLINKING]\n\r"); - printf(" Override On-Duration: %x\n\r", rsp->data[6] ); - printf(" Override Color: %x [%s]\n\r", rsp->data[7], led_color_str[ rsp->data[7] ]); - printf(" Lamp test duration: %x\n\r", rsp->data[8] ); + printf(" Override On-Duration: %x\n\r", rsp->data[6] ); + printf(" Override Color: %x [%s]\n\r", rsp->data[7], led_color_str[ rsp->data[7] ]); + printf(" Lamp test duration: %x\n\r", rsp->data[8] ); } return 0; @@ -823,16 +868,16 @@ ipmi_picmg_set_led_state(struct ipmi_intf * intf, int argc, char ** argv) memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_SET_FRU_LED_STATE_CMD; + req.msg.cmd = PICMG_SET_FRU_LED_STATE_CMD; req.msg.data = msg_data; req.msg.data_len = 6; - msg_data[0] = 0x00; /* PICMG identifier */ - msg_data[1] = atoi(argv[0]); /* FRU-ID */ - msg_data[2] = atoi(argv[1]); /* LED-ID */ - msg_data[3] = atoi(argv[2]); /* LED function */ + msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[1] = atoi(argv[0]); /* FRU-ID */ + msg_data[2] = atoi(argv[1]); /* LED-ID */ + msg_data[3] = atoi(argv[2]); /* LED function */ msg_data[4] = atoi(argv[3]); /* LED on duration */ - msg_data[5] = atoi(argv[4]); /* LED color */ + msg_data[5] = atoi(argv[4]); /* LED color */ rsp = intf->sendrecv(intf, &req); @@ -862,13 +907,13 @@ ipmi_picmg_get_power_level(struct ipmi_intf * intf, int argc, char ** argv) memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_GET_POWER_LEVEL_CMD; + req.msg.cmd = PICMG_GET_POWER_LEVEL_CMD; req.msg.data = msg_data; req.msg.data_len = 3; - msg_data[0] = 0x00; /* PICMG identifier */ - msg_data[1] = atoi(argv[0]); /* FRU-ID */ - msg_data[2] = atoi(argv[1]); /* Power type */ + msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[1] = atoi(argv[0]); /* FRU-ID */ + msg_data[2] = atoi(argv[1]); /* Power type */ rsp = intf->sendrecv(intf, &req); @@ -884,13 +929,13 @@ ipmi_picmg_get_power_level(struct ipmi_intf * intf, int argc, char ** argv) } printf("Dynamic Power Configuration: %s\n", (rsp->data[1]&0x80)==0x80?"enabled":"disabled" ); - printf("Actual Power Level: %i\n", (rsp->data[1] & 0xf)); - printf("Delay to stable Power: %i\n", rsp->data[2]); - printf("Power Multiplier: %i\n", rsp->data[3]); + printf("Actual Power Level: %i\n", (rsp->data[1] & 0xf)); + printf("Delay to stable Power: %i\n", rsp->data[2]); + printf("Power Multiplier: %i\n", rsp->data[3]); for ( i = 1; i+3 < rsp->data_len ; i++ ) { - printf(" Power Draw %i: %i\n", i, (rsp->data[i+3]) * rsp->data[3] / 10); + printf(" Power Draw %i: %i\n", i, (rsp->data[i+3]) * rsp->data[3] / 10); } return 0; } @@ -907,13 +952,13 @@ ipmi_picmg_set_power_level(struct ipmi_intf * intf, int argc, char ** argv) memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_SET_POWER_LEVEL_CMD; + req.msg.cmd = PICMG_SET_POWER_LEVEL_CMD; req.msg.data = msg_data; req.msg.data_len = 4; - msg_data[0] = 0x00; /* PICMG identifier */ - msg_data[1] = atoi(argv[0]); /* FRU-ID */ - msg_data[2] = atoi(argv[1]); /* power level */ + msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[1] = atoi(argv[0]); /* FRU-ID */ + msg_data[2] = atoi(argv[1]); /* power level */ msg_data[3] = atoi(argv[2]); /* present to desired */ rsp = intf->sendrecv(intf, &req); @@ -941,16 +986,16 @@ ipmi_picmg_fru_control(struct ipmi_intf * intf, int argc, char ** argv) memset(&req, 0, sizeof(req)); - req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_FRU_CONTROL_CMD; - req.msg.data = msg_data; + req.msg.netfn = IPMI_NETFN_PICMG; + req.msg.cmd = PICMG_FRU_CONTROL_CMD; + req.msg.data = msg_data; req.msg.data_len = 3; - msg_data[0] = 0x00; /* PICMG identifier */ - msg_data[1] = atoi(argv[0]); /* FRU-ID */ - msg_data[2] = atoi(argv[1]); /* control option */ + msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[1] = atoi(argv[0]); /* FRU-ID */ + msg_data[2] = atoi(argv[1]); /* control option */ - printf("0: 0x%02x 1: 0x%02x\n\r", msg_data[1], msg_data[2]); + printf("0: 0x%02x 1: 0x%02x\n\r", msg_data[1], msg_data[2]); rsp = intf->sendrecv(intf, &req); @@ -985,15 +1030,15 @@ ipmi_picmg_clk_get(struct ipmi_intf * intf, int argc, char ** argv) memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_AMC_GET_CLK_STATE_CMD; + req.msg.cmd = PICMG_AMC_GET_CLK_STATE_CMD; req.msg.data = msg_data; req.msg.data_len = 2; - msg_data[0] = 0x00; /* PICMG identifier */ - msg_data[1] = atoi(argv[0]); /* clk id */ + msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[1] = atoi(argv[0]); /* clk id */ if(argc>2){ - msg_data[2] = atoi(argv[1]); /* resource id */ + msg_data[2] = atoi(argv[1]); /* resource id */ req.msg.data_len = 3; } @@ -1009,24 +1054,24 @@ ipmi_picmg_clk_get(struct ipmi_intf * intf, int argc, char ** argv) return -1; } - enabled = (rsp->data[1]&0x8)!=0; + enabled = (rsp->data[1]&0x8)!=0; direction = (rsp->data[1]&0x4)!=0; printf("CLK setting: 0x%02x\n", rsp->data[1]); - printf(" - state: %s\n", (enabled)?"enabled":"disabled"); + printf(" - state: %s\n", (enabled)?"enabled":"disabled"); printf(" - direction: %s\n", (direction)?"Source":"Receiver"); - printf(" - PLL ctrl: 0x%x\n", rsp->data[1]&0x3); + printf(" - PLL ctrl: 0x%x\n", rsp->data[1]&0x3); if(enabled){ unsigned long freq = 0; - freq = ( rsp->data[5] << 0 - | rsp->data[6] << 8 - | rsp->data[7] << 16 - | rsp->data[8] << 24 ); - printf(" - Index: %d\n", rsp->data[2]); - printf(" - Family: %d\n", rsp->data[3]); - printf(" - AccLVL: %d\n", rsp->data[4]); - printf(" - Freq: %d\n", freq); + freq = ( rsp->data[5] << 0 + | rsp->data[6] << 8 + | rsp->data[7] << 16 + | rsp->data[8] << 24 ); + printf(" - Index: %d\n", rsp->data[2]); + printf(" - Family: %d\n", rsp->data[3]); + printf(" - AccLVL: %d\n", rsp->data[4]); + printf(" - Freq: %d\n", freq); } return 0; @@ -1046,33 +1091,33 @@ ipmi_picmg_clk_set(struct ipmi_intf * intf, int argc, char ** argv) memset(&req, 0, sizeof(req)); req.msg.netfn = IPMI_NETFN_PICMG; - req.msg.cmd = PICMG_AMC_SET_CLK_STATE_CMD; + req.msg.cmd = PICMG_AMC_SET_CLK_STATE_CMD; req.msg.data = msg_data; req.msg.data_len = 11; - msg_data[0] = 0x00; /* PICMG identifier */ - msg_data[1] = strtoul(argv[0], NULL,0); /* clk id */ - msg_data[2] = strtoul(argv[1], NULL,0); /* clk index */ - msg_data[3] = strtoul(argv[2], NULL,0); /* setting */ - msg_data[4] = strtoul(argv[3], NULL,0); /* family */ - msg_data[5] = strtoul(argv[4], NULL,0); /* acc */ + msg_data[0] = 0x00; /* PICMG identifier */ + msg_data[1] = strtoul(argv[0], NULL,0); /* clk id */ + msg_data[2] = strtoul(argv[1], NULL,0); /* clk index */ + msg_data[3] = strtoul(argv[2], NULL,0); /* setting */ + msg_data[4] = strtoul(argv[3], NULL,0); /* family */ + msg_data[5] = strtoul(argv[4], NULL,0); /* acc */ freq = strtoul(argv[5], NULL,0); - msg_data[6] = (freq >> 0)& 0xFF; /* freq */ - msg_data[7] = (freq >> 8)& 0xFF; /* freq */ - msg_data[8] = (freq >>16)& 0xFF; /* freq */ - msg_data[9] = (freq >>24)& 0xFF; /* freq */ + msg_data[6] = (freq >> 0)& 0xFF; /* freq */ + msg_data[7] = (freq >> 8)& 0xFF; /* freq */ + msg_data[8] = (freq >>16)& 0xFF; /* freq */ + msg_data[9] = (freq >>24)& 0xFF; /* freq */ - msg_data[10] = strtoul(argv[6 ], NULL,0); /* resource id */ + msg_data[10] = strtoul(argv[6 ], NULL,0); /* resource id */ #if 1 -printf("## ID: %d\n", msg_data[1]); -printf("## index: %d\n", msg_data[2]); +printf("## ID: %d\n", msg_data[1]); +printf("## index: %d\n", msg_data[2]); printf("## setting: 0x02x\n", msg_data[3]); printf("## family: %d\n", msg_data[4]); -printf("## acc: %d\n", msg_data[5]); -printf("## freq: %d\n", freq ); -printf("## res: %d\n", msg_data[10]); +printf("## acc: %d\n", msg_data[5]); +printf("## freq: %d\n", freq ); +printf("## res: %d\n", msg_data[10]); #endif rsp = intf->sendrecv(intf, &req); @@ -1096,6 +1141,13 @@ int ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv) { int rc = 0; + int showProperties = 0; + + /* Get PICMG properties is called to obtain version information */ + if (argc !=0 && !strncmp(argv[0], "properties", 10)) { + showProperties =1; + } + rc = ipmi_picmg_properties(intf,showProperties); if (argc == 0 || (!strncmp(argv[0], "help", 4))) { ipmi_picmg_help(); @@ -1107,11 +1159,6 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv) rc = ipmi_picmg_getaddr(intf, argc-1, &argv[1]); } - /* picmg properties command */ - else if (!strncmp(argv[0], "properties", 10)) { - rc = ipmi_picmg_properties(intf); - } - /* fru control command */ else if (!strncmp(argv[0], "frucontrol", 10)) { if (argc > 2) { @@ -1119,13 +1166,13 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv) } else { printf("usage: frucontrol