|
@@ -29,6 +29,8 @@
|
|
|
#include "libipmi_AppDevice.h"
|
|
|
#include "libipmi_storlead_OEM.h"
|
|
|
#include "com_BmcType.h"
|
|
|
+#include "com_IPMIDefs.h"
|
|
|
+#include "com_IPMI_Storlead.h"
|
|
|
|
|
|
#if 0
|
|
|
/* A bunch of defines that SDRRecord needs. We don't care about the actual */
|
|
@@ -853,142 +855,116 @@ LIBIPMI_HL_GetAllSensorReadings( IPMI20_SESSION_T *pSession,
|
|
|
*/
|
|
|
|
|
|
uint16_t
|
|
|
-LIBIPMI_HL_GetAllSensorReadings( IPMI20_SESSION_T *pSession, struct sensor_data *sensor_list, uint32_t* nNumSensor, int timeout )
|
|
|
+LIBIPMI_HL_GetAllSensorReadings( IPMI20_SESSION_T *pSession, struct sensor_data *sensor_list, uint32_t nNumSensor, int timeout )
|
|
|
{
|
|
|
uint16_t wRet;
|
|
|
int sdr_count;
|
|
|
int i ;
|
|
|
- SenInfo_T * pSensorBuff = NULL;
|
|
|
- unsigned char* pSensor = NULL;
|
|
|
-
|
|
|
- /* Load the SDRs related to sensors into memory */
|
|
|
- wRet = LIBIPMI_HL_GetSensorCount( pSession,&sdr_count, timeout );
|
|
|
- if( wRet != LIBIPMI_E_SUCCESS )
|
|
|
+ uint8_t Req[20];
|
|
|
+ StorleadGetSensorInfoRes_T GetSensorInfoRes;
|
|
|
+ uint32_t dwResLen;
|
|
|
+ SenInfo_T *pSensorBuff;
|
|
|
+ float tmp_float;
|
|
|
+ uint16_t tmp_hw;
|
|
|
+
|
|
|
+ for(i = 0; i < nNumSensor; i++)
|
|
|
{
|
|
|
- printf( "Cannot load sensor SDRs\n" );
|
|
|
- return( wRet );
|
|
|
- }
|
|
|
+ Req[0] = i;
|
|
|
+ wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, //notice!
|
|
|
+ (NETFN_STORLEAD << 2), CMD_GET_SENSOR_INFO,
|
|
|
+ Req, 1,
|
|
|
+ (uint8_t*)&GetSensorInfoRes, &dwResLen,
|
|
|
+ timeout);
|
|
|
+ if(wRet == LIBIPMI_E_SUCCESS)
|
|
|
+ {
|
|
|
+ pSensorBuff = &GetSensorInfoRes.SensorInfo;
|
|
|
+ sensor_list[ i ].sensor_num = pSensorBuff->SensorNumber;
|
|
|
+ sensor_list[ i ].owner_id = pSensorBuff->OwnerID;
|
|
|
+ sensor_list[ i ].owner_lun = pSensorBuff->OwnerLUN;
|
|
|
+ sensor_list[ i ].sensor_type = pSensorBuff->SensorTypeCode;
|
|
|
+ sensor_list[ i ].sensor_units[ 0 ] = pSensorBuff->Units1;
|
|
|
+ sensor_list[ i ].sensor_units[ 1 ] = pSensorBuff->Units2;
|
|
|
+ sensor_list[ i ].sensor_units[ 2 ] = pSensorBuff->Units3;
|
|
|
+ sensor_list[ i ].raw_reading = pSensorBuff->SensorReading;
|
|
|
+ strncpy(sensor_list[ i ].sensor_name,pSensorBuff->SensorName,MAX_ID_STR_LEN);
|
|
|
+ sensor_list[i].SensorAccessibleFlags = 0;
|
|
|
+
|
|
|
+ if(pSensorBuff->EventTypeCode > 1)
|
|
|
+ {
|
|
|
+ /*Updating the discrete sensor details*/
|
|
|
+ sensor_list[i].discrete_state = pSensorBuff->EventTypeCode;
|
|
|
+ sensor_list[i].sensor_state = 0;
|
|
|
+ sensor_list[ i ].sensor_reading = (float)(pSensorBuff->ComparisonStatus | (pSensorBuff->OptionalStatus << 8));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sensor_list[ i ].discrete_state = 0;
|
|
|
+ sensor_list[ i ].Settable_Readable_ThreshMask=pSensorBuff->Settable_Readable_ThreshMask;
|
|
|
+
|
|
|
+ if(pSensorBuff->SensorReading>0)
|
|
|
+ /*Convert Sensor Reading*/
|
|
|
+ ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->SensorReading, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
+ pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
+ sensor_list[i].sensor_reading = tmp_float;
|
|
|
+
|
|
|
+ /*Convert LowerNonRecoverable*/
|
|
|
+ if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT2)
|
|
|
+ ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonRecoverable, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
+ pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
+ sensor_list[i].low_non_recov_thresh = tmp_float;
|
|
|
+
|
|
|
+ /*Convert LowerCritical*/
|
|
|
+ if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT1)
|
|
|
+ ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
+ pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
+ sensor_list[i].low_crit_thresh = tmp_float;
|
|
|
+
|
|
|
+ /*Convert LowerNonCritical*/
|
|
|
+ if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT0)
|
|
|
+ ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
+ pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
+ sensor_list[i].low_non_crit_thresh = tmp_float;
|
|
|
+
|
|
|
+ /*Convert UpperNonCritical*/
|
|
|
+ if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT3)
|
|
|
+ ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
+ pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
+ sensor_list[i].high_non_crit_thresh = tmp_float;
|
|
|
+
|
|
|
+ /*Convert UpperCritical*/
|
|
|
+ if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT4)
|
|
|
+ ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperCritical, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
+ pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
+ sensor_list[i].high_crit_thresh = tmp_float;
|
|
|
+
|
|
|
+ /*Convert UpperNonRecoverable*/
|
|
|
+ if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT5)
|
|
|
+ ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonRecoverable, &tmp_float, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
+ pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
+ sensor_list[i].high_non_recov_thresh = tmp_float;
|
|
|
+
|
|
|
+ /*Get the Sensor state*/
|
|
|
+ SensorState(pSensorBuff->SensorReading,&tmp_hw,pSensorBuff->hdr.Type,pSensorBuff->Linearization,pSensorBuff->Units1,pSensorBuff->EventTypeCode,pSensorBuff->AssertionEventByte1,pSensorBuff->AssertionEventByte2,pSensorBuff->DeassertionEventByte1,pSensorBuff->DeassertionEventByte2);
|
|
|
+ sensor_list[i].sensor_state = tmp_hw;
|
|
|
+ }
|
|
|
|
|
|
- pSensorBuff = (SenInfo_T*) malloc(sdr_count* sizeof(SenInfo_T));
|
|
|
- if(pSensorBuff == NULL)
|
|
|
- {
|
|
|
- printf("Error in Allocating the Memory\n");
|
|
|
- return -1;
|
|
|
- }
|
|
|
- pSensor = (unsigned char *)pSensorBuff;
|
|
|
-
|
|
|
- // if(pSession->byMediumType == 5) //IPMB
|
|
|
- // {
|
|
|
- // wRet = LIBIPMI_HL_GetIPMCSensorInfo(pSession, pSensorBuff, nNumSensor, timeout);
|
|
|
- // if ( wRet != LIBIPMI_E_SUCCESS )
|
|
|
- // {
|
|
|
- // free(pSensorBuff);
|
|
|
- // if( wRet == LIBIPMI_E_SENSOR_INFO_EMPTY)
|
|
|
- // {
|
|
|
- // TINFO("Sensor Info is empty\n");
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // printf("Error in getting sensor info\n");
|
|
|
- // }
|
|
|
- // return (wRet);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else
|
|
|
- {
|
|
|
- wRet = LIBIPMI_HL_AMIGetSensorInfo(pSession, pSensorBuff, nNumSensor, timeout);
|
|
|
- if ( wRet != LIBIPMI_E_SUCCESS )
|
|
|
+ /* If sensor scanning is disabled or the reading is unavailable... */
|
|
|
+ if( !( pSensorBuff->Flags & SENSOR_SCANNING_BIT) || (pSensorBuff->Flags & UNABLE_TO_READ_SENSOR) )
|
|
|
+ {
|
|
|
+ /* Return an error code to let the caller know */
|
|
|
+ sensor_list[i].SensorAccessibleFlags = SENSOR_NOT_AVAILABLE;
|
|
|
+ sensor_list[i].sensor_reading = 0;
|
|
|
+ sensor_list[i].discrete_state = 0;
|
|
|
+ sensor_list[i].raw_reading = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ printf("sensor_list[%d]: SensorNum %d, SensorName %s, SensorReading = %f\n", i, sensor_list[i].sensor_num, sensor_list[i].sensor_name, sensor_list[i].sensor_reading);
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- free(pSensorBuff);
|
|
|
- if( wRet == LIBIPMI_E_SENSOR_INFO_EMPTY)
|
|
|
- {
|
|
|
- printf("Sensor Info is empty\n");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- printf("Error in getting sensor info\n");
|
|
|
- }
|
|
|
- return (wRet);
|
|
|
+ printf("error getting sensor info %d\n",wRet);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- for(i = 0; i < *nNumSensor; i++)
|
|
|
- {
|
|
|
- sensor_list[ i ].sensor_num = pSensorBuff->SensorNumber;
|
|
|
- sensor_list[ i ].owner_id = pSensorBuff->OwnerID;
|
|
|
- sensor_list[ i ].owner_lun = pSensorBuff->OwnerLUN;
|
|
|
- sensor_list[ i ].sensor_type = pSensorBuff->SensorTypeCode;
|
|
|
- sensor_list[ i ].sensor_units[ 0 ] = pSensorBuff->Units1;
|
|
|
- sensor_list[ i ].sensor_units[ 1 ] = pSensorBuff->Units2;
|
|
|
- sensor_list[ i ].sensor_units[ 2 ] = pSensorBuff->Units3;
|
|
|
- sensor_list[ i ].raw_reading = pSensorBuff->SensorReading;
|
|
|
- strncpy(sensor_list[ i ].sensor_name,pSensorBuff->SensorName,MAX_ID_STR_LEN);
|
|
|
- sensor_list[i].SensorAccessibleFlags = 0;
|
|
|
-
|
|
|
- if(pSensorBuff->EventTypeCode > 1)
|
|
|
- {
|
|
|
- /*Updating the discrete sensor details*/
|
|
|
- sensor_list[i].discrete_state = pSensorBuff->EventTypeCode;
|
|
|
- sensor_list[i].sensor_state = 0;
|
|
|
- sensor_list[ i ].sensor_reading = (float)(pSensorBuff->ComparisonStatus | (pSensorBuff->OptionalStatus << 8));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sensor_list[ i ].discrete_state = 0;
|
|
|
- sensor_list[ i ].Settable_Readable_ThreshMask=pSensorBuff->Settable_Readable_ThreshMask;
|
|
|
-
|
|
|
- if(pSensorBuff->SensorReading>0)
|
|
|
- /*Convert Sensor Reading*/
|
|
|
- ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->SensorReading, &sensor_list[i].sensor_reading, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
- pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
-
|
|
|
- /*Convert LowerNonRecoverable*/
|
|
|
- if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT2)
|
|
|
- ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonRecoverable, &sensor_list[i].low_non_recov_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
- pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
-
|
|
|
- /*Convert LowerCritical*/
|
|
|
- if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT1)
|
|
|
- ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerCritical, &sensor_list[i].low_crit_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
- pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
-
|
|
|
- /*Convert LowerNonCritical*/
|
|
|
- if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT0)
|
|
|
- ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->LowerNonCritical, &sensor_list[i].low_non_crit_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
- pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
-
|
|
|
- /*Convert UpperNonCritical*/
|
|
|
- if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT3)
|
|
|
- ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonCritical, &sensor_list[i].high_non_crit_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
- pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
-
|
|
|
- /*Convert UpperCritical*/
|
|
|
- if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT4)
|
|
|
- ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperCritical, &sensor_list[i].high_crit_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
- pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
-
|
|
|
- /*Convert UpperNonRecoverable*/
|
|
|
- if(sensor_list[ i ].Settable_Readable_ThreshMask & BIT5)
|
|
|
- ipmi_conv_reading(pSensorBuff->hdr.Type,pSensorBuff->UpperNonRecoverable, &sensor_list[i].high_non_recov_thresh, pSensorBuff->MinReading, pSensorBuff->MaxReading, pSensorBuff->Units1,
|
|
|
- pSensorBuff->Linearization, pSensorBuff->M_LSB, pSensorBuff->B_LSB, pSensorBuff->M_MSB_Tolerance, pSensorBuff->B_MSB_Accuracy,pSensorBuff->RExp_BExp);
|
|
|
-
|
|
|
- /*Get the Sensor state*/
|
|
|
- SensorState(pSensorBuff->SensorReading,&sensor_list[i].sensor_state,pSensorBuff->hdr.Type,pSensorBuff->Linearization,pSensorBuff->Units1,pSensorBuff->EventTypeCode,pSensorBuff->AssertionEventByte1,pSensorBuff->AssertionEventByte2,pSensorBuff->DeassertionEventByte1,pSensorBuff->DeassertionEventByte2);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /* If sensor scanning is disabled or the reading is unavailable... */
|
|
|
- if( !( pSensorBuff->Flags & SENSOR_SCANNING_BIT) || (pSensorBuff->Flags & UNABLE_TO_READ_SENSOR) )
|
|
|
- {
|
|
|
- /* Return an error code to let the caller know */
|
|
|
- sensor_list[i].SensorAccessibleFlags = SENSOR_NOT_AVAILABLE;
|
|
|
- sensor_list[i].sensor_reading = 0;
|
|
|
- sensor_list[i].discrete_state = 0;
|
|
|
- sensor_list[i].raw_reading = 0;
|
|
|
- }
|
|
|
- pSensorBuff++;
|
|
|
- }
|
|
|
- free(pSensor);
|
|
|
return wRet ;
|
|
|
}
|
|
|
|