On 03/26/2012 10:08 PM, Gowda, Srinivas G wrote:
> 
> 
> Thanks,
> G
> srinivas_g_go...@dell.com
> DELL


Rewritten patch using macros.

Thanks,
G
srinivas_g_go...@dell.com
DELL
diff -Naurp 04-ipmitool_delloem_lanhelp_update/lib/ipmi_sel.c 
05-ipmitool_opensel_part1_delloem/lib/ipmi_sel.c
--- 04-ipmitool_delloem_lanhelp_update/lib/ipmi_sel.c   2012-04-03 
17:51:37.000000000 +0530
+++ 05-ipmitool_opensel_part1_delloem/lib/ipmi_sel.c    2012-04-03 
17:51:35.000000000 +0530
@@ -505,6 +505,96 @@ get_newisys_evt_desc(struct ipmi_intf * 
 
        return description;
 }
+#define BIT(x)                                          (1 << x)
+#define        SIZE_OF_DESC    128
+#define EVT1_OEM2_VALID(x) (((x) & 0xC0) == 0x80) 
+#define EVT1_OEM3_VALID(x) (((x) & 0x30) == 0x20) 
+#define EVT1_OFFSET(x) ((x) & 0x0F)
+
+char * get_dell_evt_desc(struct ipmi_intf * intf, struct sel_event_record * 
rec)
+       {
+    int data1, data2, data3;
+       int code;
+       char *desc = NULL;
+       
+       unsigned char count;
+       unsigned char node;
+       unsigned char num;
+       unsigned char dimmNum;
+       unsigned char dimmsPerNode;
+       char          dimmStr[32];
+       char          cardStr[32];
+       char          numStr[32];
+       char          tmpdesc[SIZE_OF_DESC];
+       char*         str;
+       unsigned char incr = 0;
+       unsigned char i    = 0;
+       unsigned char postCode;
+       struct ipmi_rs *rsp;
+       struct ipmi_rq req;
+       char tmpData;
+       int version;
+
+       data1 = rec->sel_type.standard_type.event_data[0];
+       data2 = rec->sel_type.standard_type.event_data[1];
+       data3 = rec->sel_type.standard_type.event_data[2];
+       if ( (rec->sel_type.standard_type.event_type == 0x0B) || 
+               (rec->sel_type.standard_type.event_type == 0x6F)  || 
+               (rec->sel_type.standard_type.event_type == 0x07)) 
+               {
+               code = rec->sel_type.standard_type.sensor_type;
+               /* BDF or Slot */
+               desc = (char*)malloc(SIZE_OF_DESC);
+               if(desc == NULL)
+                       return NULL;
+               memset(desc,0,SIZE_OF_DESC);
+               switch (code) {
+                       case 0x07:
+                               if(EVT1_OEM2_VALID(data1))
+                               {
+                                       if(EVT1_OFFSET(data1)  == 0x00) 
+                                               snprintf(desc,SIZE_OF_DESC,"CPU 
Internal Err | ");
+                                       if(EVT1_OFFSET(data1)  == 0x06)
+                                       {
+                                               snprintf(desc,SIZE_OF_DESC,"CPU 
Protocol Err | ");
+                                       }
+                                       /* change bit location to a number */
+                                       for (count= 0; count < 8; count++)
+                                       {
+                                         if (BIT(count)& data2)
+                                         {
+                                           count++;
+                                               if( (EVT1_OFFSET(data1)  == 
0x06) && (rec->sel_type.standard_type.sensor_num == 0x0A)) 
+                                                   
snprintf(desc,SIZE_OF_DESC,"FSB %d ",count);
+                                               else
+                                                   
snprintf(desc,SIZE_OF_DESC,"CPU %d | APIC ID %d ",count,data3);
+                                           break;
+                                         }
+                                       }
+                               }
+                       break;
+                       case 0x0C:
+                               if ( (rec->sel_type.standard_type.event_type == 
0x0B) && 
+                                               !(data1 & 0x03) ) 
+                                       {
+                                               if(data2 & 0x04)
+                                                       strcpy(desc,"Memory is 
in Spare Mode");
+                                               else if(data2 & 0x02)
+                                                       strcpy(desc,"Memory is 
in Raid Mode ");
+                                               else if(data2 & 0x01)
+                                                       strcpy(desc,"Memory is 
in Mirror Mode ");
+                                               break;
+                                       }
+                       default:
+                       break;                          
+               } 
+       }
+       else
+       {
+               code = rec->sel_type.standard_type.event_type;
+       }
+       return desc;
+}
 
 char *
 ipmi_get_oem_desc(struct ipmi_intf * intf, struct sel_event_record * rec)
@@ -519,6 +609,9 @@ ipmi_get_oem_desc(struct ipmi_intf * int
        case IPMI_OEM_KONTRON:
                desc =  get_kontron_evt_desc(intf, rec);
                break;
+       case IPMI_OEM_DELL:
+               desc = get_dell_evt_desc(intf, rec);
+               break;
        case IPMI_OEM_UNKNOWN:
        default:
                break;
@@ -533,6 +626,7 @@ ipmi_get_event_desc(struct ipmi_intf * i
 {
        uint8_t code, offset;
        struct ipmi_event_sensor_types *evt = NULL;
+       char *sfx = NULL;
 
        if (desc == NULL)
                return;
@@ -554,6 +648,17 @@ ipmi_get_event_desc(struct ipmi_intf * i
                                        evt = oem_kontron_event_types;
                                        code = 
rec->sel_type.standard_type.sensor_type;
                                 break;
+                               case IPMI_OEM_DELL:             
+                                       evt = sensor_specific_types;
+                                       code = 
rec->sel_type.standard_type.sensor_type;
+                                       if ( ( 
EVT1_OEM2_VALID(rec->sel_type.standard_type.event_data[0])) ||
+                                        
(EVT1_OEM3_VALID(rec->sel_type.standard_type.event_data[0])) )
+                                       {
+                                               
if(rec->sel_type.standard_type.event_data[0] & DATA_BYTE2_SPECIFIED_MASK)
+                                                       evt->data = 
rec->sel_type.standard_type.event_data[1];
+                                                sfx = ipmi_get_oem_desc(intf, 
rec);
+                                       }
+                                break;
                                 /* add your oem sensor assignation here */
                        }                       
                        if( evt == NULL ){              
@@ -565,6 +670,25 @@ ipmi_get_event_desc(struct ipmi_intf * i
                        evt = sensor_specific_types;
                        code = rec->sel_type.standard_type.sensor_type;
                }
+               if(ipmi_get_oem(intf) == IPMI_OEM_DELL) {
+                       code = rec->sel_type.standard_type.sensor_type;
+                       if ( 
(EVT1_OEM2_VALID(rec->sel_type.standard_type.event_data[0])) ||
+                        
(EVT1_OEM3_VALID(rec->sel_type.standard_type.event_data[0])) )
+                       {
+                               if(rec->sel_type.standard_type.event_data[0] & 
DATA_BYTE2_SPECIFIED_MASK)
+                                       evt->data = 
rec->sel_type.standard_type.event_data[1];
+                                        sfx = ipmi_get_oem_desc(intf, rec);
+                                       
+                       }
+                       else if(rec->sel_type.standard_type.event_data[0] == 
0xC1)
+                       {
+                               if(rec->sel_type.standard_type.sensor_num == 
0x23)
+                               {
+                                       evt->data = 
rec->sel_type.standard_type.event_data[1];
+                                       sfx = ipmi_get_oem_desc(intf, rec);
+                               }               
+                       }
+               }
        } else {
                evt = generic_event_types;
                code = rec->sel_type.standard_type.event_type;
@@ -578,17 +702,34 @@ ipmi_get_event_desc(struct ipmi_intf * i
                         ((rec->sel_type.standard_type.event_data[0] & 
DATA_BYTE2_SPECIFIED_MASK) &&
                          (evt->data == 
rec->sel_type.standard_type.event_data[1]))))
                {
-                       *desc = (char *)malloc(strlen(evt->desc) + 48);
+                       *desc = (char *)malloc(strlen(evt->desc) + 48 + 
SIZE_OF_DESC);
                        if (*desc == NULL) {
                                lprintf(LOG_ERR, "ipmitool: malloc failure");
                                return;
                        }
-                       memset(*desc, 0, strlen(evt->desc)+48);
+                       memset(*desc, 0, strlen(evt->desc)+ 48 + SIZE_OF_DESC);
+                       if (sfx) {
+                               sprintf(*desc, "%s (%s)", evt->desc, sfx);
+                               free(sfx);
+                       } else {                        
                        sprintf(*desc, "%s", evt->desc);
+                       }       
                        return;
                }       
                evt++;
+       }       
+       if(sfx && ( (code == 0x0F) && (offset == 0x0F) ) || 
+               ((code == 0xC2) && (offset == 0x00)) || ((code == 0xC3) && 
(offset == 0x01)))
+       {
+               *desc = (char *)malloc( 48 + SIZE_OF_DESC);
+               if (*desc == NULL) {
+                       lprintf(LOG_ERR, "ipmitool: malloc failure");
+                       return;
+               }
+               memset(*desc, 0, 48 + SIZE_OF_DESC);
+               sprintf(*desc, "(%s)",sfx);
        }
+
 }
 
 
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Ipmitool-devel mailing list
Ipmitool-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipmitool-devel

Reply via email to