From a9ee361f27e0439530387765924574e5358c8a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 10 Sep 2022 15:44:41 +0200 Subject: New upstream version 1.8.19 --- lib/ipmi_picmg.c | 278 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 188 insertions(+), 90 deletions(-) (limited to 'lib/ipmi_picmg.c') diff --git a/lib/ipmi_picmg.c b/lib/ipmi_picmg.c index c7d9c8e..8becc78 100644 --- a/lib/ipmi_picmg.c +++ b/lib/ipmi_picmg.c @@ -37,11 +37,6 @@ #include #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 #define PICMG_EKEY_MODE_PRINT_ENABLED 2 @@ -67,7 +62,84 @@ typedef enum picmg_card_type { PICMG_CARD_TYPE_RESERVED } t_picmg_card_type ; -/* This is the version of the PICMG Extenstion */ +static const char* amc_link_type_str[] = { + "RESERVED", + "RESERVED1", + "PCI EXPRESS", + "ADVANCED SWITCHING1", + "ADVANCED SWITCHING2", + "ETHERNET", + "RAPIDIO", + "STORAGE", +}; + +static const char* amc_link_type_ext_str[][16] = { + /* 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", + "", "", "", "", "", + "", "", "", "", "", "", "", "" + } +}; + +/* This is the version of the PICMG Extension */ static t_picmg_card_type PicmgCardType = PICMG_CARD_TYPE_RESERVED; void @@ -130,6 +202,28 @@ struct sAmcAddrMap { {0x88, "reserved", 0}, }; +/* the LED color capabilities */ +static const char *led_color_str[] = { + "reserved", + "BLUE", + "RED", + "GREEN", + "AMBER", + "ORANGE", + "WHITE", + "reserved" +}; + +const char * +picmg_led_color_str(int color) +{ + if (color < 0 || (size_t)color >= ARRAY_SIZE(led_color_str)) { + return "invalid"; + } + + return led_color_str[color]; +} + /* is_amc_channel - wrapper to convert user input into integer * AMC Channel range seems to be <0..255>, bits [7:0] * @@ -151,7 +245,7 @@ is_amc_channel(const char *argv_ptr, uint8_t *amc_chan_ptr) return (-1); } /* is_amc_dev - wrapper to convert user input into integer. - * AMC Dev ID limits are uknown. + * AMC Dev ID limits are unknown. * * @argv_ptr: source string to convert from; usually argv * @amc_dev_ptr: pointer where to store result @@ -172,7 +266,7 @@ is_amc_dev(const char *argv_ptr, int32_t *amc_dev_ptr) return (-1); } /* is_amc_intf - wrapper to convert user input into integer. - * AMC Interface (ID) limits are uknown. + * AMC Interface (ID) limits are unknown. * * @argv_ptr: source string to convert from; usually argv * @amc_intf_ptr: pointer where to store result @@ -193,7 +287,7 @@ is_amc_intf(const char *argv_ptr, int32_t *amc_intf_ptr) return (-1); } /* is_amc_port - wrapper to convert user input into integer. - * AMC Port limits are uknown. + * AMC Port limits are unknown. * * @argv_ptr: source string to convert from; usually argv * @amc_port_ptr: pointer where to store result @@ -213,7 +307,7 @@ is_amc_port(const char *argv_ptr, int32_t *amc_port_ptr) return (-1); } /* is_clk_acc - wrapper to convert user input into integer. - * Clock Accuracy limits are uknown[1byte by spec]. + * Clock Accuracy limits are unknown[1byte by spec]. * * @argv_ptr: source string to convert from; usually argv * @clk_acc_ptr: pointer where to store result @@ -234,7 +328,7 @@ is_clk_acc(const char *argv_ptr, uint8_t *clk_acc_ptr) return (-1); } /* is_clk_family - wrapper to convert user input into integer. - * Clock Family limits are uknown[1byte by spec]. + * Clock Family limits are unknown[1byte by spec]. * * @argv_ptr: source string to convert from; usually argv * @clk_family_ptr: pointer where to store result @@ -255,7 +349,7 @@ is_clk_family(const char *argv_ptr, uint8_t *clk_family_ptr) return (-1); } /* is_clk_freq - wrapper to convert user input into integer. - * Clock Frequency limits are uknown, but specification says + * Clock Frequency limits are unknown, but specification says * 3Bytes + 1B checksum * * @argv_ptr: source string to convert from; usually argv @@ -277,7 +371,7 @@ is_clk_freq(const char *argv_ptr, uint32_t *clk_freq_ptr) return (-1); } /* is_clk_id - wrapper to convert user input into integer. - * Clock ID limits are uknown, however it's 1B by specification and I've + * Clock ID limits are unknown, however it's 1B by specification and I've * found two ranges: <1..5> or <0..15> * * @argv_ptr: source string to convert from; usually argv @@ -298,7 +392,7 @@ is_clk_id(const char *argv_ptr, uint8_t *clk_id_ptr) return (-1); } /* is_clk_index - wrapper to convert user input into integer. - * Clock Index limits are uknown[1B by spec] + * Clock Index limits are unknown[1B by spec] * * @argv_ptr: source string to convert from; usually argv * @clk_index_ptr: pointer where to store result @@ -318,7 +412,7 @@ is_clk_index(const char *argv_ptr, uint8_t *clk_index_ptr) return (-1); } /* is_clk_resid - wrapper to convert user input into integer. - * Clock Resource Index(?) limits are uknown, but maximum seems to be 15. + * Clock Resource Index(?) limits are unknown, but maximum seems to be 15. * * @argv_ptr: source string to convert from; usually argv * @clk_resid_ptr: pointer where to store result @@ -661,7 +755,7 @@ ipmi_picmg_properties(struct ipmi_intf * intf, int show ) #define PICMG_FRU_ACTIVATE (unsigned char) 0x01 int -ipmi_picmg_fru_activation(struct ipmi_intf * intf, int argc, char ** argv, unsigned char state) +ipmi_picmg_fru_activation(struct ipmi_intf * intf, char ** argv, unsigned char state) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -695,7 +789,7 @@ ipmi_picmg_fru_activation(struct ipmi_intf * intf, int argc, char ** argv, unsig int -ipmi_picmg_fru_activation_policy_get(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_picmg_fru_activation_policy_get(struct ipmi_intf * intf, char ** argv) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -734,7 +828,7 @@ ipmi_picmg_fru_activation_policy_get(struct ipmi_intf * intf, int argc, char ** } int -ipmi_picmg_fru_activation_policy_set(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_picmg_fru_activation_policy_set(struct ipmi_intf * intf, char ** argv) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -1029,7 +1123,7 @@ ipmi_picmg_amc_portstate_get(struct ipmi_intf * intf, int32_t device, /* Removed endianness check here, probably not required - as we dont use bitfields */ + as we don't use bitfields */ port = d->linkInfo[0] & 0x0F; type = ((d->linkInfo[0] & 0xF0) >> 4 )|(d->linkInfo[1] & 0x0F ); ext = ((d->linkInfo[1] & 0xF0) >> 4 ); @@ -1158,7 +1252,7 @@ ipmi_picmg_amc_portstate_set(struct ipmi_intf * intf, uint8_t channel, int -ipmi_picmg_get_led_properties(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_picmg_get_led_properties(struct ipmi_intf * intf, char ** argv) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -1197,7 +1291,7 @@ ipmi_picmg_get_led_properties(struct ipmi_intf * intf, int argc, char ** argv) } int -ipmi_picmg_get_led_capabilities(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_picmg_get_led_capabilities(struct ipmi_intf * intf, char ** argv) { int i; struct ipmi_rs * rsp; @@ -1234,20 +1328,20 @@ ipmi_picmg_get_led_capabilities(struct ipmi_intf * intf, int argc, char ** argv) printf("LED Color Capabilities: "); for ( i=0 ; i<8 ; i++ ) { if ( rsp->data[1] & (0x01 << i) ) { - printf("%s, ", led_color_str[ i ]); + printf("%s, ", picmg_led_color_str(i)); } } printf("\n"); printf("Default LED Color in\n"); - printf(" LOCAL control: %s\n", led_color_str[ rsp->data[2] ] ); - printf(" OVERRIDE state: %s\n", led_color_str[ rsp->data[3] ] ); + printf(" LOCAL control: %s\n", picmg_led_color_str(rsp->data[2])); + printf(" OVERRIDE state: %s\n", picmg_led_color_str(rsp->data[3])); return 0; } int -ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_picmg_get_led_state(struct ipmi_intf * intf, char ** argv) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -1308,7 +1402,9 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) } printf(" Local Control On-Duration: %x\n", rsp->data[3] ); - printf(" Local Control Color: %x [%s]\n", rsp->data[4], led_color_str[ rsp->data[4] ]); + printf(" Local Control Color: %x [%s]\n", + rsp->data[4], + picmg_led_color_str(rsp->data[4])); /* override state or lamp test */ if (rsp->data[1] & 0x02) { @@ -1322,7 +1418,9 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) } printf(" Override On-Duration: %x\n", rsp->data[6] ); - printf(" Override Color: %x [%s]\n", rsp->data[7], led_color_str[ rsp->data[7] ]); + printf(" Override Color: %x [%s]\n", + rsp->data[7], + picmg_led_color_str(rsp->data[7])); } @@ -1334,7 +1432,7 @@ ipmi_picmg_get_led_state(struct ipmi_intf * intf, int argc, char ** argv) } int -ipmi_picmg_set_led_state(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_picmg_set_led_state(struct ipmi_intf * intf, char ** argv) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -1410,7 +1508,7 @@ ipmi_picmg_set_led_state(struct ipmi_intf * intf, int argc, char ** argv) } int -ipmi_picmg_get_power_level(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_picmg_get_power_level(struct ipmi_intf * intf, char ** argv) { int i; struct ipmi_rs * rsp; @@ -1461,7 +1559,7 @@ ipmi_picmg_get_power_level(struct ipmi_intf * intf, int argc, char ** argv) } int -ipmi_picmg_set_power_level(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_picmg_set_power_level(struct ipmi_intf * intf, char ** argv) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -1565,7 +1663,7 @@ ipmi_picmg_bused_resource(struct ipmi_intf * intf, t_picmg_bused_resource_mode m } int -ipmi_picmg_fru_control(struct ipmi_intf * intf, int argc, char ** argv) +ipmi_picmg_fru_control(struct ipmi_intf * intf, char ** argv) { struct ipmi_rs * rsp; struct ipmi_rq req; @@ -1654,7 +1752,7 @@ ipmi_picmg_clk_get(struct ipmi_intf * intf, uint8_t clk_id, int8_t clk_res, return -1; } - if (rsp->ccode == 0 ) { + if (!rsp->ccode) { enabled = (rsp->data[1]&0x8)!=0; direction = (rsp->data[1]&0x4)!=0; @@ -1785,24 +1883,24 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv) int rc = 0; int showProperties = 0; - if (argc == 0 || (!strncmp(argv[0], "help", 4))) { + if (!argc || !strcmp(argv[0], "help")) { ipmi_picmg_help(); return 0; } /* Get PICMG properties is called to obtain version information */ - if (argc !=0 && !strncmp(argv[0], "properties", 10)) { + if (!strcmp(argv[0], "properties")) { showProperties =1; } rc = ipmi_picmg_properties(intf,showProperties); /* address info command */ - if (!strncmp(argv[0], "addrinfo", 8)) { + if (!strcmp(argv[0], "addrinfo")) { rc = ipmi_picmg_getaddr(intf, argc-1, &argv[1]); } - else if (!strncmp(argv[0], "busres", 6)) { + else if (!strcmp(argv[0], "busres")) { if (argc > 1) { - if (!strncmp(argv[1], "summary", 7)) { + if (!strcmp(argv[1], "summary")) { ipmi_picmg_bused_resource(intf, PICMG_BUSED_RESOURCE_SUMMARY ); } } else { @@ -1810,9 +1908,9 @@ ipmi_picmg_main (struct ipmi_intf * intf, int argc, char ** argv) } } /* fru control command */ - else if (!strncmp(argv[0], "frucontrol", 10)) { + else if (!strcmp(argv[0], "frucontrol")) { if (argc > 2) { - rc = ipmi_picmg_fru_control(intf, argc-1, &(argv[1])); + rc = ipmi_picmg_fru_control(intf, &(argv[1])); } else { lprintf(LOG_NOTICE, "usage: frucontrol