This patch adds support for Dell-OEM vFlash command



Thanks,
Srinivas.G
Dell
diff -Naurp 02-ipmitool_dell_updates/include/ipmitool/ipmi_delloem.h 
03-ipmitool_dell_vflash/include/ipmitool/ipmi_delloem.h
--- 02-ipmitool_dell_updates/include/ipmitool/ipmi_delloem.h    2011-08-04 
16:48:43.000000000 +0530
+++ 03-ipmitool_dell_vflash/include/ipmitool/ipmi_delloem.h     2011-08-04 
16:48:43.000000000 +0530
@@ -76,6 +76,9 @@ POSSIBILITY OF SUCH DAMAGE. 
 
 #define        IDRAC_11G                                       1
 #define        IDRAC_12G                                       2
+// Return Error code for license
+#define        LICENSE_NOT_SUPPORTED           0x6F
+#define        VFL_NOT_LICENSED                        0x33
 #define btuphr              0x01
 #define watt                0x00
 #define IPMI_DELL_POWER_CAP 0xEA
@@ -95,6 +98,8 @@ typedef struct _tag_ipmi_dell_lcd_caps
 #define IPMI_DELL_LCD_STRING1_SIZE      14
 #define IPMI_DELL_LCD_STRINGN_SIZE      16
 
+/* vFlash subcommands */
+#define IPMI_GET_EXT_SD_CARD_INFO 0xA4
 
 
 typedef struct _tag_ipmi_dell_lcd_string
@@ -339,6 +344,20 @@ typedef struct _power_headroom
     uint16_t peakheadroom;
 } __attribute__ ((packed)) POWER_HEADROOM;
 
+struct vFlashstr {
+       uint8_t val;
+       const char * str;
+};
+typedef struct ipmi_vFlash_extended_info
+{
+       uint8_t  vflashcompcode;
+       uint8_t  sdcardstatus;
+       uint32_t sdcardsize;
+       uint32_t sdcardavailsize;
+       uint8_t  bootpartion;
+       uint8_t  Resv;
+} __attribute__ ((packed)) IPMI_DELL_SDCARD_INFO;
+
 
 typedef struct _SensorReadingType
 {
diff -Naurp 02-ipmitool_dell_updates/lib/ipmi_delloem.c 
03-ipmitool_dell_vflash/lib/ipmi_delloem.c
--- 02-ipmitool_dell_updates/lib/ipmi_delloem.c 2011-08-04 16:48:43.000000000 
+0530
+++ 03-ipmitool_dell_vflash/lib/ipmi_delloem.c  2011-08-04 16:48:42.000000000 
+0530
@@ -117,6 +117,14 @@ static uint8_t SetLEDSupported=0;
 volatile uint8_t IMC_Type = IMC_IDRAC_10G;
 
 
+const struct vFlashstr vFlash_completion_code_vals[] = {
+       {0x00, "SUCCESS"},
+       {0x01, "NO_SD_CARD"},
+       {0x63, "UNKNOWN_ERROR"},
+       {0x00, NULL}
+};
+
+
 POWER_HEADROOM powerheadroom;
 
 uint8_t PowercapSetable_flag=0;
@@ -203,6 +211,16 @@ static int getpowersupplyfruinfo(struct 
                        struct fru_header header, struct fru_info fru);
 static void ipmi_powermonitor_usage(void);
 
+/* vFlash Function prototypes */
+static int ipmi_delloem_vFlash_main(struct ipmi_intf * intf, int argc, char ** 
argv);
+const char * get_vFlash_compcode_str(uint8_t vflashcompcode, const struct 
vFlashstr *vs);
+static int ipmi_get_sd_card_info(struct ipmi_intf* intf);
+static int ipmi_delloem_vFlash_process(struct ipmi_intf* intf, int 
current_arg, char ** argv);
+static void ipmi_vFlash_usage(void);
+
+
+/* LED Function prototypes */
+
 static int ipmi_getsesmask(int, char **);
 static int CheckSetLEDSupport(struct ipmi_intf * intf);
 static int IsSetLEDSupported(void);
@@ -263,7 +281,12 @@ ipmi_delloem_main(struct ipmi_intf * int
     else if (strncmp(argv[current_arg], "powermonitor\0", 13) == 0) 
     {
         ipmi_delloem_powermonitor_main (intf,argc,argv);
-    }       
+    }
+       /* vFlash Support */    
+       else if (strncmp(argv[current_arg], "vFlash\0", 7) == 0)
+       {
+        ipmi_delloem_vFlash_main (intf,argc,argv);     
+       }
     else
     {
         usage();
@@ -297,6 +320,7 @@ static void usage(void)
     if (IsSetLEDSupported())
        lprintf(LOG_NOTICE,    "    setled");         
     lprintf(LOG_NOTICE, "    powermonitor");        
+       lprintf(LOG_NOTICE, "    vFlash");
     lprintf(LOG_NOTICE, "");
     lprintf(LOG_NOTICE, "For help on individual commands type:");
     lprintf(LOG_NOTICE, "delloem <command> help");
@@ -4515,6 +4539,216 @@ ipmi_powermonitor_usage(void)
     lprintf(LOG_NOTICE, "");
 
 }
+/*****************************************************************
+* Function Name:          ipmi_delloem_vFlash_main
+*
+* Description:            This function processes the delloem vFlash 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_vFlash_main (struct ipmi_intf * intf, int argc, char 
** argv)
+{
+       int rc = 0;
+
+       current_arg++;
+       rc = ipmi_delloem_vFlash_process(intf, current_arg, argv);
+}
+
+
+
+/*****************************************************************
+* Function Name:       get_vFlash_compcode_str
+*
+* Description:         This function maps the vFlash completion code
+*              to a string
+* Input : vFlash completion code and static array of codes vs strings
+* Output: -            
+* Return: returns the mapped string            
+*
+******************************************************************/
+const char * 
+get_vFlash_compcode_str(uint8_t vflashcompcode, const struct vFlashstr *vs)
+{
+       static char un_str[32];
+       int i;
+
+       for (i = 0; vs[i].str != NULL; i++) {
+               if (vs[i].val == vflashcompcode)
+                       return vs[i].str;
+       }
+
+       memset(un_str, 0, 32);
+       snprintf(un_str, 32, "Unknown (0x%02X)", vflashcompcode);
+
+       return un_str;
+}
+
+/*****************************************************************
+* Function Name:       ipmi_get_sd_card_info
+*
+* Description: This function prints the vFlash Extended SD card info
+* Input : ipmi interface
+* Output: prints the sd card extended info             
+* Return: 0 - success -1 - failure
+*
+******************************************************************/
+static int
+ipmi_get_sd_card_info(struct ipmi_intf* intf) {
+       struct ipmi_rs * rsp;
+       struct ipmi_rq req;
+
+       uint8_t msg_data[2];
+       uint8_t input_length=0;
+       uint8_t cardstatus=0x00;
+
+       IPMI_DELL_SDCARD_INFO * sdcardinfoblock;
+
+       input_length = 2;
+       msg_data[0] = msg_data[1] = 0x00;
+
+       req.msg.netfn = IPMI_DELL_OEM_NETFN;
+       req.msg.lun = 0;
+       req.msg.cmd = IPMI_GET_EXT_SD_CARD_INFO;
+       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 SD Card Extended 
Information");
+               return -1;
+       }
+       else if (rsp->ccode > 0) 
+       {
+               lprintf(LOG_ERR, " Error in getting SD Card Extended 
Information (%s) \n",
+                               val2str(rsp->ccode, completion_code_vals) );
+               return -1;
+       }
+
+       sdcardinfoblock = (IPMI_DELL_SDCARD_INFO *) (void *) rsp->data;
+
+       if (sdcardinfoblock->vflashcompcode != 0x00)
+       {
+               lprintf(LOG_ERR, " Error in getting SD Card Extended 
Information (%s) \n", get_vFlash_compcode_str(sdcardinfoblock->vflashcompcode,
+                                       vFlash_completion_code_vals));
+               return -1;
+       }
+
+       if (!(sdcardinfoblock->sdcardstatus & 0x04))
+       {
+               lprintf(LOG_ERR, " vFlash SD card is unavailable, please insert 
the card\n of size 256MB or greater\n");
+               return 0;
+       }
+
+       printf("vFlash SD Card Properties\n");
+       printf("SD Card size       : %8dMB\n",sdcardinfoblock->sdcardsize);
+       printf("Available size     : %8dMB\n",sdcardinfoblock->sdcardavailsize);
+       printf("Initialized        : %10s\n", (sdcardinfoblock->sdcardstatus & 
0x80) ?
+                       "Yes" : "No");
+       printf("Licensed           : %10s\n", (sdcardinfoblock->sdcardstatus & 
0x40) ?
+                       "Yes" : "No");
+       printf("Attached           : %10s\n", (sdcardinfoblock->sdcardstatus & 
0x20) ?
+                       "Yes" : "No");
+       printf("Enabled            : %10s\n", (sdcardinfoblock->sdcardstatus & 
0x10) ?
+                       "Yes" : "No");
+       printf("Write Protected    : %10s\n", (sdcardinfoblock->sdcardstatus & 
0x08) ?
+                       "Yes" : "No");
+       cardstatus = sdcardinfoblock->sdcardstatus & 0x03;
+       printf("Health             : %10s\n", ((0x00 == cardstatus
+               ) ? "OK" : ((cardstatus == 0x03) ? 
+                       "Undefined" : ((cardstatus == 0x02) ? 
+                               "Critical" : "Warning"))));
+       printf("Bootable partition : %10d\n",sdcardinfoblock->bootpartion);
+       return 0;
+}
+
+/*****************************************************************
+* Function Name:       ipmi_delloem_vFlash_process
+*
+* Description:         This function processes the args for vFlash subcmd
+* Input : intf - ipmi interface, arg index, argv array
+* Output: prints help or error with help
+* Return: 0 - Success -1 - failure
+*
+******************************************************************/
+static int
+ipmi_delloem_vFlash_process(struct ipmi_intf* intf, int current_arg, char ** 
argv) {
+       int rc;
+
+       if (strncmp(intf->name,"wmi\0",4) &&
+               strncmp(intf->name, "open\0",5))
+       {
+               lprintf(LOG_ERR, " vFlash support is enabled only for wmi and 
open interface.\n Its not enabled for lan and lanplus interface.");
+               return -1;
+       }
+
+       if (argv[current_arg] == NULL)
+       {
+               ipmi_vFlash_usage();
+               return -1;
+       }
+       else if (!strncmp(argv[current_arg], "info\0", 5))
+       {
+               current_arg++;
+               if (argv[current_arg] == NULL)
+               {
+                       ipmi_vFlash_usage();
+                       return -1;
+               }
+               else if (strncmp(argv[current_arg], "Card\0", 5) == 0)
+               {
+                       current_arg++;
+                       if (argv[current_arg] != NULL)
+                       {
+                               ipmi_vFlash_usage();
+                               return -1;
+                       }
+                       rc = ipmi_get_sd_card_info(intf);
+                       return rc;
+               }
+               else /* TBD: many sub commands are present */
+               {
+                       ipmi_vFlash_usage();
+                       return -1;
+               }
+       }
+       /* TBD other vFlash subcommands */
+       else if (!strncmp(argv[current_arg], "help\0", 5))
+       {
+               ipmi_vFlash_usage();
+               return 0;
+       }
+       else
+       {
+               ipmi_vFlash_usage();
+               return -1;
+       }
+}
+
+/*****************************************************************
+* Function Name:       ipmi_vFlash_usage
+*
+* Description:         This function displays the usage for using vFlash
+* Input : void
+* Output: prints help          
+* Return: void 
+*
+******************************************************************/
+static void
+ipmi_vFlash_usage(void)
+{
+       lprintf(LOG_NOTICE, "");
+       lprintf(LOG_NOTICE, "   vFlash info Card");
+       lprintf(LOG_NOTICE, "      Shows Extended SD Card information");
+       lprintf(LOG_NOTICE, "");
+}
 
 /**********************************************************************
 * Function Name: ipmi_setled_usage
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to