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
This commit is contained in:
Francois Isabelle 2007-12-12 15:03:17 +00:00
parent 431421c6ff
commit a654ca2683
2 changed files with 433 additions and 309 deletions

View File

@ -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",
@ -77,16 +73,81 @@ static const char* led_color_str[] __attribute__((unused)) = {
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

View File

@ -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 <ipmitool/ipmi_intf.h>
#include <ipmitool/ipmi_picmg.h>
#include <ipmitool/ipmi_fru.h> /* for access to link descriptor defines */
#include <ipmitool/log.h>
#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;
@ -165,10 +198,18 @@ ipmi_picmg_properties(struct ipmi_intf * intf)
return -1;
}
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("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;
}
@ -442,17 +483,10 @@ ipmi_picmg_portstate_set(struct ipmi_intf * intf, int interface, int channel,
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[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);
@ -494,7 +528,11 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf,int device,int channel,
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 ;
@ -559,28 +597,35 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf,int device,int 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 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 );
@ -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) {
@ -1241,14 +1288,14 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
}
else if (!strncmp(argv[1], "set", 3)) {
if (argc > 9) {
int interface= atoi(argv[2]);
int channel = atoi(argv[3]);
int port = atoi(argv[4]);
int type = atoi(argv[5]);
int typeext = atoi(argv[6]);
int group = atoi(argv[7]);
int enable = atoi(argv[8]);
if (argc == 9) {
int interface = strtoul(argv[2], NULL, 0);
int channel = strtoul(argv[3], NULL, 0);
int port = strtoul(argv[4], NULL, 0);
int type = strtoul(argv[5], NULL, 0);
int typeext = strtoul(argv[6], NULL, 0);
int group = strtoul(argv[7], NULL, 0);
int enable = strtoul(argv[8], NULL, 0);
lprintf(LOG_DEBUG,"PICMG: interface %d",interface);
lprintf(LOG_DEBUG,"PICMG: channel %d",channel);
@ -1285,7 +1332,11 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
lprintf(LOG_DEBUG,"PICMG: get");
if(!strncmp(argv[1], "getall", 6)){
for(device=0;device<=PICMG_EKEY_AMC_MAX_DEVICE;device++){
int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE;
if( PicmgExtMajorVersion != 2){
maxDevice = 0;
}
for(device=0;device<=maxDevice;device++){
for(channel=0;channel<=PICMG_EKEY_AMC_MAX_CHANNEL;channel++){
rc = ipmi_picmg_amc_portstate_get(intf,device,channel,
PICMG_EKEY_MODE_PRINT_ALL);
@ -1293,7 +1344,11 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
}
else if(!strncmp(argv[1], "getgranted", 10)){
for(device=0;device<=PICMG_EKEY_AMC_MAX_DEVICE;device++){
int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE;
if( PicmgExtMajorVersion != 2){
maxDevice = 0;
}
for(device=0;device<=maxDevice;device++){
for(channel=0;channel<=PICMG_EKEY_AMC_MAX_CHANNEL;channel++){
rc = ipmi_picmg_amc_portstate_get(intf,device,channel,
PICMG_EKEY_MODE_PRINT_ENABLED);
@ -1301,16 +1356,24 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
}
else if(!strncmp(argv[1], "getdenied", 9)){
for(device=0;device<=PICMG_EKEY_AMC_MAX_DEVICE;device++){
int maxDevice = PICMG_EKEY_AMC_MAX_DEVICE;
if( PicmgExtMajorVersion != 2){
maxDevice = 0;
}
for(device=0;device<=maxDevice;device++){
for(channel=0;channel<=PICMG_EKEY_AMC_MAX_CHANNEL;channel++){
rc = ipmi_picmg_amc_portstate_get(intf,device,channel,
PICMG_EKEY_MODE_PRINT_DISABLED);
}
}
}
else if (argc > 3){
else if (argc > 2){
channel = atoi(argv[2]);
if (argc > 3){
device = atoi(argv[3]);
}else{
device = -1;
}
lprintf(LOG_DEBUG,"PICMG: requesting device %d",device);
lprintf(LOG_DEBUG,"PICMG: requesting channel %d",channel);
@ -1322,7 +1385,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
}
else if (!strncmp(argv[1], "set", 3)) {
if (argc > 5) {
if (argc > 7) {
int channel = atoi(argv[2]);
int port = atoi(argv[3]);
int type = atoi(argv[4]);
@ -1330,7 +1393,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
int group = atoi(argv[6]);
int enable = atoi(argv[7]);
int device = -1;
if(argc > 6){
if(argc > 8){
device = atoi(argv[8]);
}
@ -1498,7 +1561,7 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv)
}
}
else {
else if(showProperties == 0 ){
ipmi_picmg_help();
return -1;