From: Deepaganesh P. <Dee...@de...> - 2010-02-23 16:08:37
|
Hi, I have implemented the 4 dell oem commands delloem lcd, mac lan and powermonitor. There are 5 patches to enable them. This is the 3rd patch out 5 patches. The purpose of this patch is to add support for dell specific mac commands. Regards, Deepaganesh Paulraj diff -Naurp 03_ipmitool-1.8.11_lcd/include/ipmitool/ipmi_delloem.h 04_ipmitool-1.8.11_mac/include/ipmitool/ipmi_delloem.h --- 03_ipmitool-1.8.11_lcd/include/ipmitool/ipmi_delloem.h 2010-02-23 20:40:27.000000000 +0530 +++ 04_ipmitool-1.8.11_mac/include/ipmitool/ipmi_delloem.h 2010-02-23 20:40:26.000000000 +0530 @@ -141,11 +141,76 @@ typedef struct _lcd_mode uint8_t Resv; } __attribute__ ((packed)) LCD_MODE; +#define PARAM_REV_OFFSET (uint8_t)(0x1) +#define LOM_MACTYPE_ETHERNET 0 +#define LOM_MACTYPE_ISCSI 1 +#define LOM_MACTYPE_RESERVED 3 +#define LOM_ETHERNET_ENABLED 0 +#define LOM_ETHERNET_DISABLED 1 +#define LOM_ETHERNET_PLAYINGDEAD 2 +#define LOM_ETHERNET_RESERVED 3 +#define LOM_ACTIVE 1 +#define LOM_INACTIVE 0 +#define MACADDRESSLENGH 6 +#define MAX_LOM 8 + +#define APP_NETFN (uint8_t)(0x6) + + +#define GET_SYSTEM_INFO_CMD (uint8_t)(0x59) +#define EMB_NIC_MAC_ADDRESS_11G (uint8_t)(0xDA) +#define EMB_NIC_MAC_ADDRESS_9G_10G (uint8_t)(0xCB) + +#define IMC_IDRAC_10G (uint8_t) (0x08) +#define IMC_CMC (uint8_t) (0x09) +#define IMC_IDRAC_11G_MONOLITHIC (uint8_t) (0x0A) +#define IMC_IDRAC_11G_MODULAR (uint8_t) (0x0B) +#define IMC_UNUSED (uint8_t) (0x0C) +#define IMC_MASER_LITE_BMC (uint8_t) (0x0D) + + + +typedef struct +{ + unsigned int BladSlotNumber : 4; + unsigned int MacType : 2; + unsigned int EthernetStatus : 2; + unsigned int NICNumber : 5; + unsigned int Reserved : 3; + uint8_t MacAddressByte[MACADDRESSLENGH]; +} LOMMacAddressType; + + +typedef struct +{ + LOMMacAddressType LOMMacAddress [MAX_LOM]; +} EmbeddedNICMacAddressType; + +typedef struct +{ + uint8_t MacAddressByte[MACADDRESSLENGH]; +} MacAddressType; + +typedef struct +{ + MacAddressType MacAddress [MAX_LOM]; +} EmbeddedNICMacAddressType_10G; + + + +#define TRANSPORT_NETFN (uint8_t)(0xc) +#define GET_LAN_PARAM_CMD (uint8_t)(0x02) +#define MAC_ADDR_PARAM (uint8_t)(0x05) +#define LAN_CHANNEL_NUMBER (uint8_t)(0x01) + +#define IDRAC_NIC_NUMBER (uint8_t)(0x8) + +#define TOTAL_N0_NICS_INDEX (uint8_t)(0x1) int ipmi_delloem_main(struct ipmi_intf * intf, int argc, char ** argv); #endif /*IPMI_DELLOEM_H*/ diff -Naurp 03_ipmitool-1.8.11_lcd/lib/ipmi_delloem.c 04_ipmitool-1.8.11_mac/lib/ipmi_delloem.c --- 03_ipmitool-1.8.11_lcd/lib/ipmi_delloem.c 2010-02-23 20:40:27.000000000 +0530 +++ 04_ipmitool-1.8.11_mac/lib/ipmi_delloem.c 2010-02-23 20:40:26.000000000 +0530 @@ -68,12 +68,18 @@ POSSIBILITY OF SUCH DAMAGE. /*--------------time header-----------------*/ #include <time.h> +#define DELL_OEM_NETFN (uint8_t)(0x30) +#define GET_IDRAC_VIRTUAL_MAC (uint8_t)(0xC9) static int current_arg =0; uint8_t iDRAC_FLAG=0; LCD_MODE lcd_mode; static uint8_t LcdSupported=0; + +volatile uint8_t IMC_Type = IMC_IDRAC_10G; + + static void usage(void); static int ipmi_delloem_lcd_main (struct ipmi_intf * intf, int argc, char ** argv); @@ -104,6 +110,17 @@ static int ipmi_lcd_configure (struct ip int8_t line_number, char * text); static void ipmi_lcd_usage(void); +static int ipmi_delloem_mac_main (struct ipmi_intf * intf, int argc, char ** argv); +static int make_int(const char *str, int *value); +static void InitEmbeddedNICMacAddressValues (); +static int ipmi_macinfo_drac_idrac_virtual_mac(struct ipmi_intf* intf,uint8_t NicNum); +static int ipmi_macinfo_drac_idrac_mac(struct ipmi_intf* intf,uint8_t NicNum); +static int ipmi_macinfo_10g (struct ipmi_intf* intf, uint8_t NicNum); +static int ipmi_macinfo_11g (struct ipmi_intf* intf, uint8_t NicNum); +static int ipmi_macinfo (struct ipmi_intf* intf, uint8_t NicNum); +static void ipmi_mac_usage(void); + + /***************************************************************** * Function Name: ipmi_delloem_main * @@ -136,6 +153,11 @@ ipmi_delloem_main(struct ipmi_intf * int { ipmi_delloem_lcd_main (intf,argc,argv); } + /* mac address*/ + else if (strncmp(argv[current_arg], "mac\0", 4) == 0) + { + ipmi_delloem_mac_main (intf,argc,argv); + } else { usage(); @@ -163,6 +185,7 @@ static void usage(void) lprintf(LOG_NOTICE, "commands:"); if (IsLCDSupported()) lprintf(LOG_NOTICE, " lcd"); + lprintf(LOG_NOTICE, " mac"); lprintf(LOG_NOTICE, ""); lprintf(LOG_NOTICE, "For help on individual commands type:"); lprintf(LOG_NOTICE, "delloem <command> help"); @@ -599,7 +622,8 @@ ipmi_idracvalidator_command (struct ipmi { iDRAC_FLAG=0; } - + IMC_Type = rsp->data[10]; + return 0; } @@ -1704,3 +1728,527 @@ ipmi_lcd_usage(void) lprintf(LOG_NOTICE, " and Front Panel access mode {viewandmodify}|{viewonly}|{disabled} "); lprintf(LOG_NOTICE, ""); } + +/***************************************************************** +* Function Name: ipmi_delloem_mac_main +* +* Description: This function processes the delloem mac command +* Input: intf - ipmi interface + argc - no of arguments + argv - argument string array +* Output: +* +* Return: return code 0 - success +* -1 - failure +* +******************************************************************/ + + +static int ipmi_delloem_mac_main (struct ipmi_intf * intf, int argc, char ** argv) +{ + int rc = 0; + current_arg++; + if (argc == 1) + { + rc = ipmi_macinfo(intf, 0xff); + } + else if (strncmp(argv[current_arg], "list\0", 5) == 0) + { + rc = ipmi_macinfo(intf, 0xff); + } + else if (strncmp(argv[current_arg], "get\0", 4) == 0) + { + current_arg++; + if (argv[current_arg] == NULL) + { + ipmi_mac_usage(); + return -1; + } + int currIdInt; + make_int(argv[current_arg],&currIdInt); + if(currIdInt>8) + { + lprintf(LOG_ERR, "Invalid NIC number. The NIC number should be between 0-8\n"); + ipmi_mac_usage(); + return -1; + } + rc = ipmi_macinfo(intf, currIdInt); + } + else + { + ipmi_mac_usage(); + } + +} + + +/***************************************************************** +* Function Name: make_int +* +* Description: This function convert string into integer +* Input: str - decimal number string +* Output: value - integer value +* Return: +* +******************************************************************/ +static int make_int(const char *str, int *value) +{ + char *tmp=NULL; + *value = strtol(str,&tmp,0); + if ( tmp-str != strlen(str) ) + { + return -1; + } + return 0; +} + + + + + +EmbeddedNICMacAddressType EmbeddedNICMacAddress; + +EmbeddedNICMacAddressType_10G EmbeddedNICMacAddress_10G; + +static void InitEmbeddedNICMacAddressValues () +{ + uint8_t i; + uint8_t j; + + + for (i=0;i<MAX_LOM;i++) + { + EmbeddedNICMacAddress.LOMMacAddress[i].BladSlotNumber = 0; + EmbeddedNICMacAddress.LOMMacAddress[i].MacType = LOM_MACTYPE_RESERVED; + EmbeddedNICMacAddress.LOMMacAddress[i].EthernetStatus = LOM_ETHERNET_RESERVED; + EmbeddedNICMacAddress.LOMMacAddress[i].NICNumber = 0; + EmbeddedNICMacAddress.LOMMacAddress[i].Reserved = 0; + for (j=0;j<MACADDRESSLENGH;j++) + { + EmbeddedNICMacAddress.LOMMacAddress[i].MacAddressByte[j] = 0; + EmbeddedNICMacAddress_10G.MacAddress[i].MacAddressByte[j] = 0; + } + } +} + +uint8_t UseVirtualMacAddress = 0; +#define VIRTUAL_MAC_OFFSET (2) +static int ipmi_macinfo_drac_idrac_virtual_mac(struct ipmi_intf* intf,uint8_t NicNum) +{ + struct ipmi_rs * rsp; + struct ipmi_rq req; + + uint8_t msg_data[30]; + uint8_t VirtualMacAddress [MACADDRESSLENGH]; + uint8_t input_length=0; + uint8_t j; + uint8_t length; + uint8_t i; + + + if (0xff==NicNum || IDRAC_NIC_NUMBER==NicNum ) + { + UseVirtualMacAddress = 0; + + input_length = 0; + msg_data[input_length++] = 1; /*Get*/ + + req.msg.netfn = DELL_OEM_NETFN; + req.msg.lun = 0; + req.msg.cmd = GET_IDRAC_VIRTUAL_MAC; + req.msg.data = msg_data; + req.msg.data_len = input_length; + + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) + { + return -1; + } + if (rsp->ccode > 0) + { + return -1; + } + memcpy(VirtualMacAddress,((rsp->data)+VIRTUAL_MAC_OFFSET),MACADDRESSLENGH); + + for (i=0;i<MACADDRESSLENGH;i++) + { + if (0 != VirtualMacAddress [i]) + { + UseVirtualMacAddress = 1; + } + } + if (0 == UseVirtualMacAddress) + return -1; + if (IMC_IDRAC_10G == IMC_Type) + printf ("\n\rDRAC MAC Address "); + else + printf ("\n\riDRAC6 MAC Address "); + + for (j=0;j<5;j++) + printf("%02x:",VirtualMacAddress[j]); + printf("%02x",VirtualMacAddress[j]); + + printf ("\n\r"); + + } + return 0; +} + + +/***************************************************************** +* Function Name: ipmi_macinfo_drac_idrac_mac +* +* Description: This function retrieves the mac address of DRAC or iDRAC +* Input: NicNum +* Output: +* Return: +* +******************************************************************/ + +static int ipmi_macinfo_drac_idrac_mac(struct ipmi_intf* intf,uint8_t NicNum) +{ + struct ipmi_rs * rsp; + struct ipmi_rq req; + + uint8_t msg_data[30]; + uint8_t input_length=0; + uint8_t iDRAC6MacAddressByte[MACADDRESSLENGH]; + uint8_t j; + + ipmi_macinfo_drac_idrac_virtual_mac (intf,NicNum); + + + if ((0xff==NicNum || IDRAC_NIC_NUMBER==NicNum) && 0 == UseVirtualMacAddress) + { + + input_length = 0; + + msg_data[input_length++] = LAN_CHANNEL_NUMBER; + msg_data[input_length++] = MAC_ADDR_PARAM; + msg_data[input_length++] = 0x00; + msg_data[input_length++] = 0x00; + + req.msg.netfn = TRANSPORT_NETFN; + req.msg.lun = 0; + req.msg.cmd = GET_LAN_PARAM_CMD; + req.msg.data = msg_data; + req.msg.data_len = input_length; + + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) + { + lprintf(LOG_ERR, " Error in getting MAC Address"); + return -1; + } + if (rsp->ccode > 0) + { + lprintf(LOG_ERR, " Error in getting MAC Address (%s) \n", + val2str(rsp->ccode, completion_code_vals) ); + return -1; + } + + memcpy(iDRAC6MacAddressByte,((rsp->data)+PARAM_REV_OFFSET),MACADDRESSLENGH); + + if (IMC_IDRAC_10G == IMC_Type) + printf ("\n\rDRAC MAC Address "); + else + printf ("\n\riDRAC6 MAC Address "); + + for (j=0;j<5;j++) + printf("%02x:",iDRAC6MacAddressByte[j]); + printf("%02x",iDRAC6MacAddressByte[j]); + + printf ("\n\r"); + } + return 0; +} + + +/***************************************************************** +* Function Name: ipmi_macinfo_10g +* +* Description: This function retrieves the mac address of LOMs +* Input: intf - ipmi interface + NicNum - NIC number +* Output: +* Return: +* +******************************************************************/ + +static int ipmi_macinfo_10g (struct ipmi_intf* intf, uint8_t NicNum) +{ + struct ipmi_rs * rsp; + struct ipmi_rq req; + + uint8_t msg_data[30]; + uint8_t input_length=0; + + uint8_t j; + uint8_t i; + uint8_t rc; + + uint8_t Total_No_NICs = 0; + + + InitEmbeddedNICMacAddressValues (); + + memset(msg_data, 0, sizeof(msg_data)); + input_length = 0; + msg_data[input_length++] = 0x00; /* Get Parameter Command */ + msg_data[input_length++] = EMB_NIC_MAC_ADDRESS_9G_10G; /* OEM Param */ + + msg_data[input_length++] = 0x00; + msg_data[input_length++] = 0x00; + + memset(&req, 0, sizeof(req)); + + req.msg.netfn = APP_NETFN; + req.msg.lun = 0; + req.msg.cmd = GET_SYSTEM_INFO_CMD; + req.msg.data = msg_data; + + + req.msg.data_len = input_length; + + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + lprintf(LOG_ERR, " Error in getting MAC Address"); + return -1; + } + if (rsp->ccode > 0) { + lprintf(LOG_ERR, " Error in getting MAC Address (%s) \n", + val2str(rsp->ccode, completion_code_vals) ); + return -1; + } + + Total_No_NICs = (uint8_t) rsp->data[0+PARAM_REV_OFFSET]; /* Byte 1: Total Number of Embedded NICs */ + + if (IDRAC_NIC_NUMBER != NicNum) + { + if (0xff == NicNum) + { + printf ("\n\rSystem LOMs"); + } + printf("\n\rNIC Number\tMAC Address\n\r"); + + + memcpy(&EmbeddedNICMacAddress_10G,((rsp->data)+PARAM_REV_OFFSET+TOTAL_N0_NICS_INDEX),Total_No_NICs* MACADDRESSLENGH); + + + /*Read the LOM type and Mac Addresses */ + + for (i=0;i<Total_No_NICs;i++) + { + if ((0xff==NicNum) || (i == NicNum) ) + { + printf ("\n\r%d",i); + printf ("\t\t"); + for (j=0;j<5;j++) + { + printf("%02x:",EmbeddedNICMacAddress_10G.MacAddress[i].MacAddressByte[j]); + } + printf("%02x",EmbeddedNICMacAddress_10G.MacAddress[i].MacAddressByte[j]); + } + } + printf ("\n\r"); + + } + + ipmi_macinfo_drac_idrac_mac(intf,NicNum); + + + return 0; +} + + +/***************************************************************** +* Function Name: ipmi_macinfo_11g +* +* Description: This function retrieves the mac address of LOMs +* Input: intf - ipmi interface +* Output: +* Return: +* +******************************************************************/ + +static int ipmi_macinfo_11g (struct ipmi_intf* intf, uint8_t NicNum) +{ + struct ipmi_rs * rsp; + struct ipmi_rq req; + + uint8_t msg_data[30]; + uint8_t input_length=0; + + uint8_t len; + uint8_t j; + uint8_t offset; + uint8_t maxlen; + uint8_t loop_count; + uint8_t i; + uint8_t rc; + uint8_t LOMStatus = 0; + uint8_t PlayingDead = 0; + + + + offset = 0; + len = 8; /*eigher 8 or 16 */ + maxlen = 64; + loop_count = maxlen / len; + + InitEmbeddedNICMacAddressValues (); + + memset(msg_data, 0, sizeof(msg_data)); + input_length = 0; + msg_data[input_length++] = 0x00; /* Get Parameter Command */ + msg_data[input_length++] = EMB_NIC_MAC_ADDRESS_11G; /* OEM Param */ + + msg_data[input_length++] = 0x00; + msg_data[input_length++] = 0x00; + msg_data[input_length++] = 0x00; + msg_data[input_length++] = 0x00; + + memset(&req, 0, sizeof(req)); + + req.msg.netfn = APP_NETFN; + req.msg.lun = 0; + req.msg.cmd = GET_SYSTEM_INFO_CMD; + req.msg.data = msg_data; + + + req.msg.data_len = input_length; + + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + lprintf(LOG_ERR, " Error in getting MAC Address"); + return -1; + } + if (rsp->ccode > 0) { + lprintf(LOG_ERR, " Error in getting MAC Address (%s) \n", + val2str(rsp->ccode, completion_code_vals) ); + return -1; + } + + len = 8; /*eigher 8 or 16 */ + maxlen = (uint8_t) rsp->data[0+PARAM_REV_OFFSET]; + loop_count = maxlen / len; + + if (IDRAC_NIC_NUMBER != NicNum) + { + if (0xff == NicNum) + { + printf ("\n\rSystem LOMs"); + } + printf("\n\rNIC Number\tMAC Address\t\tStatus\n\r"); + + + /*Read the LOM type and Mac Addresses */ + offset=0; + for (i=0;i<loop_count;i++,offset=offset+len) + { + input_length = 4; + msg_data[input_length++] = offset; + msg_data[input_length++] = len; + + req.msg.netfn = APP_NETFN; + req.msg.lun = 0; + req.msg.cmd = GET_SYSTEM_INFO_CMD; + req.msg.data = msg_data; + req.msg.data_len = input_length; + + rsp = intf->sendrecv(intf, &req); + if (rsp == NULL) { + lprintf(LOG_ERR, " Error in getting MAC Address"); + return -1; + } + if (rsp->ccode > 0) { + lprintf(LOG_ERR, " Error in getting MAC Address (%s) \n", + val2str(rsp->ccode, completion_code_vals) ); + return -1; + + } + + memcpy(&(EmbeddedNICMacAddress.LOMMacAddress[i]),((rsp->data)+PARAM_REV_OFFSET),len); + + + if (LOM_MACTYPE_ETHERNET == EmbeddedNICMacAddress.LOMMacAddress[i].MacType) + { + + if ( (0xff==NicNum) || (NicNum == EmbeddedNICMacAddress.LOMMacAddress[i].NICNumber) ) + { + printf ("\n\r%d",EmbeddedNICMacAddress.LOMMacAddress[i].NICNumber); + printf ("\t\t"); + for (j=0;j<5;j++) + printf("%02x:",EmbeddedNICMacAddress.LOMMacAddress[i].MacAddressByte[j]); + printf("%02x",EmbeddedNICMacAddress.LOMMacAddress[i].MacAddressByte[j]); + + if (LOM_ETHERNET_ENABLED == EmbeddedNICMacAddress.LOMMacAddress[i].EthernetStatus) + printf ("\tEnabled"); + else + printf ("\tDisabled"); + } + } + + } + printf ("\n\r"); + + } + + ipmi_macinfo_drac_idrac_mac(intf,NicNum); + + return 0; + +} + + + +/***************************************************************** +* Function Name: ipmi_macinfo +* +* Description: This function retrieves the mac address of LOMs +* Input: intf - ipmi interface +* Output: +* Return: +* +******************************************************************/ + +static int ipmi_macinfo (struct ipmi_intf* intf, uint8_t NicNum) +{ + if (IMC_IDRAC_10G == IMC_Type) + { + return ipmi_macinfo_10g (intf,NicNum); + } + else if (IMC_IDRAC_11G_MODULAR == IMC_Type || IMC_IDRAC_11G_MONOLITHIC== IMC_Type ) + { + return ipmi_macinfo_11g (intf,NicNum); + } + else + { + lprintf(LOG_ERR, " Error in getting MAC Address : Not supported platform"); + return 0; + } +} + + +/***************************************************************** +* Function Name: ipmi_mac_usage +* +* Description: This function prints help message for mac command +* Input: +* Output: +* +* Return: +* +******************************************************************/ + +static void +ipmi_mac_usage(void) +{ + lprintf(LOG_NOTICE, ""); + lprintf(LOG_NOTICE, " mac list"); + lprintf(LOG_NOTICE, " Lists the MAC address of LOMs"); + lprintf(LOG_NOTICE, ""); + lprintf(LOG_NOTICE, " mac get <NIC number>"); + lprintf(LOG_NOTICE, " Shows the MAC address of specified LOM. 0-7 System LOM, 8- DRAC/iDRAC."); + lprintf(LOG_NOTICE, ""); +} |