|
@@ -23,204 +23,6 @@
|
|
|
#include "com_IPMI_App.h"
|
|
|
|
|
|
|
|
|
-OemWebFlags_T g_OemWebFlags;
|
|
|
-uint8_t ChassisPrimaryIPMBAddr[BLADE_NUMBERS] = {0X82, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E, 0x90, 0x92, 0x94};
|
|
|
-uint8_t ChassisSecondaryIPMBAddr[BLADE_NUMBERS] = {0X82, 0x84, 0x86, 0x88, 0x8A, 0x8C, 0x8E, 0x90, 0x92, 0x94};
|
|
|
-/*
|
|
|
-*@fn IPMICMD_AMIGetSensorInfo
|
|
|
-*@brief
|
|
|
-*@param pUDSSession - IPMI Session Handle
|
|
|
-*@param pAMIGetSensorInfoReq - Pointer to the request of AMI Get SensorInfo command
|
|
|
-*@param pAMIGetSensorInfoRes - Pointer to the response of AMI Get SensorInfo command
|
|
|
-*@param timeout - Timeout Value
|
|
|
-**/
|
|
|
-// uint16_t IPMICMD_GetIPMCSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession, AMIGetSensorInfoRes_T *pGetIPMCSensorInfoRes,int timeout)
|
|
|
-// {
|
|
|
-// uint16_t wRet = 0;
|
|
|
-
|
|
|
-// uint16_t reservation_id;
|
|
|
-// uint16_t record_id = 0;
|
|
|
-// uint32_t dwRecordLen;
|
|
|
-// SenInfo_T SensorInfo;
|
|
|
-
|
|
|
-// uint8_t SDRData[100] = {0};
|
|
|
-// uint8_t NextRecIDLS = 0;
|
|
|
-// uint8_t NextRecIDMS = 0;
|
|
|
-// uint8_t cnt = 0;
|
|
|
-// uint8_t timeoutTick = 0;
|
|
|
-// wRet = IPMICMD_ReserveSDRRepository(pUDSSession, (ReserveSDRRepositoryRes_T*)SDRData, timeout);
|
|
|
-// if(wRet != 0)
|
|
|
-// {
|
|
|
-// printf("Error Reserve SDR Repository\n");
|
|
|
-// return wRet;
|
|
|
-// }
|
|
|
-
|
|
|
-// reservation_id = SDRData[2]<<8 | SDRData[1];
|
|
|
-
|
|
|
-// do
|
|
|
-// {
|
|
|
-// //Get SDR
|
|
|
-// if(0 != LIBIPMI_HL_GetSDR(pUDSSession, reservation_id, record_id, (GetSDRRes_T*)SDRData, &dwRecordLen, timeout ))
|
|
|
-// {
|
|
|
-// printf("---> Get SDR error! record_id = %#x\n", record_id);
|
|
|
-// return -1;
|
|
|
-// }
|
|
|
-
|
|
|
-// NextRecIDLS = SDRData[1];
|
|
|
-// NextRecIDMS = SDRData[2];
|
|
|
-// memcpy(&SensorInfo.hdr, &SDRData[3],5/*Sizeof(SDRRecHdr_T)*/);
|
|
|
-// if(SensorInfo.hdr.Type == 0x01) //full sensor sdr
|
|
|
-// {
|
|
|
-// SensorInfo.Accuracy_MSB_Exp = SDRData[3+29-1];
|
|
|
-// //SensorInfo.AssertionEventByte1 = SDRData[3+15-1];
|
|
|
-// //SensorInfo.AssertionEventByte2 = SDRData[3+16-1];
|
|
|
-// SensorInfo.B_LSB = SDRData[3+27-1];
|
|
|
-// SensorInfo.B_MSB_Accuracy = SDRData[3+28-1];
|
|
|
-// SensorInfo.DeassertionEventByte1 = SDRData[3+17-1];
|
|
|
-// SensorInfo.DeassertionEventByte2 = SDRData[3+18-1];
|
|
|
-// SensorInfo.EventTypeCode = SDRData[3+14-1];
|
|
|
-// SensorInfo.Linearization = SDRData[3+24-1];
|
|
|
-// SensorInfo.LowerCritical = SDRData[3+41-1];
|
|
|
-// SensorInfo.LowerNonCritical = SDRData[3+42-1];
|
|
|
-// SensorInfo.LowerNonRecoverable = SDRData[3+40-1];
|
|
|
-// SensorInfo.M_LSB = SDRData[3+25-1];
|
|
|
-// SensorInfo.M_MSB_Tolerance = SDRData[3+26-1];
|
|
|
-// SensorInfo.MaxReading = SDRData[3+35-1];
|
|
|
-// SensorInfo.MinReading = SDRData[3+36-1];
|
|
|
-// SensorInfo.OwnerID = SDRData[3+6-1];
|
|
|
-// SensorInfo.OwnerLUN = SDRData[3+7-1];
|
|
|
-// SensorInfo.RExp_BExp = SDRData[3+30-1];
|
|
|
-// SensorInfo.SensorNumber = SDRData[3+8-1];
|
|
|
-// SensorInfo.SensorTypeCode = SDRData[3+13-1];
|
|
|
-// SensorInfo.Settable_Readable_ThreshMask = SDRData[3+20-1]<<8 | SDRData[3+19-1];
|
|
|
-// SensorInfo.Units1 = SDRData[3+21-1];
|
|
|
-// SensorInfo.Units2 = SDRData[3+22-1];
|
|
|
-// SensorInfo.Units3 = SDRData[3+23-1];
|
|
|
-// SensorInfo.UpperCritical = SDRData[3+38-1];
|
|
|
-// SensorInfo.UpperNonCritical = SDRData[3+39-1];
|
|
|
-// SensorInfo.UpperNonRecoverable = SDRData[3+37-1];
|
|
|
-
|
|
|
-// memset(SensorInfo.SensorName, 0, 16);
|
|
|
-// memcpy(SensorInfo.SensorName, &SDRData[3+49-1], SDRData[3+48-1]&0x3f);
|
|
|
-
|
|
|
-// //get sensor reading
|
|
|
-// if(0 != IPMICMD_GetSensorReading(pUDSSession, (GetSensorReadingReq_T *)&SensorInfo.SensorNumber,
|
|
|
-// (GetSensorReadingRes_T *)SDRData, timeout))
|
|
|
-// {
|
|
|
-// printf("---> Get sensorReading error! sensorNum = %#x\n", SensorInfo.SensorNumber);
|
|
|
-// return -1;
|
|
|
-// }
|
|
|
-// SensorInfo.SensorReading = SDRData[1];
|
|
|
-// SensorInfo.OptionalStatus = SDRData[4];
|
|
|
-// SensorInfo.Flags = SDRData[2];
|
|
|
-
|
|
|
-// SensorInfo.ComparisonStatus = SDRData[3];
|
|
|
-// if(SensorInfo.EventTypeCode == 0x01) //threshold
|
|
|
-// {
|
|
|
-// //TODO: jimbo
|
|
|
-// SensorInfo.AssertionEventByte1 = 0x0;
|
|
|
-// SensorInfo.AssertionEventByte2 = 0x0;
|
|
|
-// if((SensorInfo.Units1 & 0xc0) == 0x00) //unsigned
|
|
|
-// {
|
|
|
-// if((uint8_t)SensorInfo.SensorReading > (uint8_t)SensorInfo.UpperCritical)
|
|
|
-// SensorInfo.AssertionEventByte2 |= 0x02;
|
|
|
-// if((uint8_t)SensorInfo.SensorReading > (uint8_t)SensorInfo.UpperNonCritical)
|
|
|
-// SensorInfo.AssertionEventByte1 |= 0x80;
|
|
|
-// if((uint8_t)SensorInfo.SensorReading > (uint8_t)SensorInfo.UpperNonRecoverable)
|
|
|
-// SensorInfo.AssertionEventByte2 |= 0x08;
|
|
|
-// if((uint8_t)SensorInfo.SensorReading < (uint8_t)SensorInfo.LowerCritical)
|
|
|
-// SensorInfo.AssertionEventByte1 |= 0x04;
|
|
|
-// if((uint8_t)SensorInfo.SensorReading < (uint8_t)SensorInfo.LowerNonCritical)
|
|
|
-// SensorInfo.AssertionEventByte1 |= 0x01;
|
|
|
-// if((uint8_t)SensorInfo.SensorReading < (uint8_t)SensorInfo.LowerNonRecoverable)
|
|
|
-// SensorInfo.AssertionEventByte1 |= 0x10;
|
|
|
-// }
|
|
|
-// else if((SensorInfo.Units1 & 0xc0) == 0x80) //2's complement
|
|
|
-// {
|
|
|
-// if((char)SensorInfo.SensorReading > (char)SensorInfo.UpperCritical)
|
|
|
-// SensorInfo.AssertionEventByte2 |= 0x02;
|
|
|
-// if((char)SensorInfo.SensorReading > (char)SensorInfo.UpperNonCritical)
|
|
|
-// SensorInfo.AssertionEventByte1 |= 0x80;
|
|
|
-// if((char)SensorInfo.SensorReading > (char)SensorInfo.UpperNonRecoverable)
|
|
|
-// SensorInfo.AssertionEventByte2 |= 0x08;
|
|
|
-// if((char)SensorInfo.SensorReading < (char)SensorInfo.LowerCritical)
|
|
|
-// SensorInfo.AssertionEventByte1 |= 0x04;
|
|
|
-// if((char)SensorInfo.SensorReading < (char)SensorInfo.LowerNonCritical)
|
|
|
-// SensorInfo.AssertionEventByte1 |= 0x01;
|
|
|
-// if((char)SensorInfo.SensorReading < (char)SensorInfo.LowerNonRecoverable)
|
|
|
-// SensorInfo.AssertionEventByte1 |= 0x10;
|
|
|
-// }
|
|
|
-
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// memcpy(((uint8_t*)pGetIPMCSensorInfoRes)+3+sizeof(SenInfo_T)*cnt, &SensorInfo, sizeof(SenInfo_T));
|
|
|
-// cnt++;
|
|
|
-
|
|
|
-// // printf("cnt: %d, sensorNum: %#x, sensorReading: %#x, OptionStatus = %#x, ComparisonStatus = %#x\n",
|
|
|
-// // cnt, SensorInfo.SensorNumber, SensorInfo.SensorReading, SensorInfo.OptionalStatus, SensorInfo.ComparisonStatus);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// record_id = NextRecIDMS<<8 | NextRecIDLS;
|
|
|
-// timeoutTick++;
|
|
|
-// if(timeoutTick > 64)
|
|
|
-// {
|
|
|
-// wRet = -1;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }while(record_id != 0xffff);
|
|
|
-
|
|
|
-// if(wRet == 0)
|
|
|
-// pGetIPMCSensorInfoRes->CompletionCode = 0;
|
|
|
-// else
|
|
|
-// pGetIPMCSensorInfoRes->CompletionCode = 255;
|
|
|
-
|
|
|
-// pGetIPMCSensorInfoRes->Noofentries = cnt;
|
|
|
-
|
|
|
-// // printf("return pGetIPMCSensorInfoRes: ");
|
|
|
-// // for(i=0;i<3+sizeof(SenInfo_T)*cnt;i++)
|
|
|
-// // printf("%#2x ",((uint8_t*)pGetIPMCSensorInfoRes)[i]);
|
|
|
-// // printf("\n");
|
|
|
-
|
|
|
-// return (wRet);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-// uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_UDS_SESSION_T *pUDSSession,SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout)
|
|
|
-// {
|
|
|
-// uint16_t wRet = 0;
|
|
|
-// AMIGetSensorInfoRes_T *pGetIPMCSensorInfoRes;
|
|
|
-// uint8_t *SensorEntries;
|
|
|
-// int i;
|
|
|
-
|
|
|
-// SensorEntries = (uint8_t *)malloc(MAX_SENSOR_INFO_SIZE);
|
|
|
-// if(SensorEntries == NULL)
|
|
|
-// {
|
|
|
-// printf("Memory allocation error in LIBIPMI_HL_AMIGetSELEntires \n");
|
|
|
-// wRet = 0xFF;
|
|
|
-// return wRet;
|
|
|
-// }
|
|
|
-
|
|
|
-// memset(SensorEntries,0,MAX_SENSOR_INFO_SIZE);
|
|
|
-// pGetIPMCSensorInfoRes = (AMIGetSensorInfoRes_T *)SensorEntries;
|
|
|
-// wRet = IPMICMD_GetIPMCSensorInfo(pUDSSession,(AMIGetSensorInfoRes_T *)SensorEntries,timeout);
|
|
|
-// if(wRet == LIBIPMI_E_SUCCESS)
|
|
|
-// {
|
|
|
-// *nNumSensor = pGetIPMCSensorInfoRes->Noofentries;
|
|
|
-// for(i = 0; i < pGetIPMCSensorInfoRes->Noofentries; i++)
|
|
|
-// {
|
|
|
-// memcpy((uint8_t *)&pSensorInfo[i],&SensorEntries[sizeof(AMIGetSensorInfoRes_T) + (i * sizeof(SenInfo_T))],sizeof(SenInfo_T) );
|
|
|
-// }
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// printf("error getting sensor info %d\n",wRet);
|
|
|
-// }
|
|
|
-// free(SensorEntries);
|
|
|
-// return (wRet);
|
|
|
-// }
|
|
|
-
|
|
|
uint16_t LIBIPMI_HL_SetFanInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout)
|
|
|
{
|
|
|
uint16_t wRet = 0;
|
|
@@ -397,102 +199,6 @@ uint16_t IPMC_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, S
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-uint16_t
|
|
|
-LIBIPMI_HL_GetSensorHistory( IPMI20_UDS_SESSION_T *pUDSSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR)
|
|
|
-{
|
|
|
- printf("---> come in history\n");
|
|
|
- int i = 0;
|
|
|
- //uint8_t RawHistory[MAX_HISTORY_LEN];
|
|
|
- uint16_t wRet;
|
|
|
- uint32_t dwResLen;
|
|
|
- uint32_t sdr_buff_size = 255;
|
|
|
- uint8_t Req[5];
|
|
|
- uint8_t *Res = (uint8_t*)walloc(MAX_HISTORY_LEN+3);
|
|
|
- int timeout = 3;
|
|
|
- FullSensorRec_T sdr_buffer;
|
|
|
- uint16_t offset = 0;
|
|
|
- uint16_t reqLen = 0, resLen = 0;
|
|
|
- float tmpValue;
|
|
|
- //get factors
|
|
|
- LIBIPMI_HL_GetSpecificSDR( pUDSSession, (uint8_t*)&sdr_buffer, &sdr_buff_size, sensor_number, timeout );
|
|
|
-
|
|
|
- //get history
|
|
|
- // if( pUDSSession->byMediumType == IPMB_MEDIUM )
|
|
|
- // {
|
|
|
- // reqLen = 22; //32 bytes - ipmb message header - response header - checksum2
|
|
|
- // do{
|
|
|
- // Req[0] = sensor_number;
|
|
|
- // Req[1] = (offset>>8)&0xff;
|
|
|
- // Req[2] = offset&0xff;
|
|
|
- // Req[3] = (reqLen>>8)&0xff;
|
|
|
- // Req[4] = reqLen&0xff;
|
|
|
- // wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession, 0x2e<<2, 0x89,
|
|
|
- // (uint8_t*)Req, 5,
|
|
|
- // (uint8_t *)Res, &dwResLen,
|
|
|
- // timeout);
|
|
|
- // if(wRet != 0)
|
|
|
- // {
|
|
|
- // return -1;
|
|
|
- // }
|
|
|
- // resLen = (Res[1]<<8) | Res[2];
|
|
|
- // if(resLen > MAX_HISTORY_LEN)
|
|
|
- // {
|
|
|
- // printf("---> response length error: resLen = %#x\n", resLen);
|
|
|
- // return -1;
|
|
|
- // }
|
|
|
- // memcpy(&RawHistory[offset],&Res[3],resLen);
|
|
|
- // offset += resLen;
|
|
|
- // if(offset >= MAX_HISTORY_LEN) //get all history datas
|
|
|
- // {
|
|
|
- // reqLen = 0;
|
|
|
- // break;
|
|
|
- // }
|
|
|
- // reqLen = ((MAX_HISTORY_LEN-offset)>22) ? 22 : (MAX_HISTORY_LEN-offset);
|
|
|
- // }while(reqLen);
|
|
|
- // }
|
|
|
- // else
|
|
|
- {
|
|
|
- Req[0] = sensor_number;
|
|
|
- Req[1] = 0;
|
|
|
- Req[2] = 0;
|
|
|
- Req[3] = (MAX_HISTORY_LEN>>8)&0xff;
|
|
|
- Req[4] = MAX_HISTORY_LEN & 0xff;
|
|
|
- wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
|
|
|
- NETFNLUN_IPMI_STORLEAD, CMD_GET_SENSOR_HISTORY,
|
|
|
- (uint8_t*)Req, 5,
|
|
|
- (uint8_t *)Res, &dwResLen,
|
|
|
- timeout);
|
|
|
- if(wRet != 0)
|
|
|
- {
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- resLen = (Res[1]<<8) | Res[2];
|
|
|
- if(resLen > MAX_HISTORY_LEN)
|
|
|
- {
|
|
|
- printf("---> response length error: resLen = %#x\n", resLen);
|
|
|
- return -1;
|
|
|
- }
|
|
|
- //memcpy(RawHistory,&Res[3],resLen);
|
|
|
- }
|
|
|
-
|
|
|
- for(i=0;i < 480; i++)
|
|
|
- {
|
|
|
- ipmi_convert_reading( (uint8_t*)&sdr_buffer, Res[3+i], &tmpValue );
|
|
|
- pSensorHistory_st->sensor_history[i] = tmpValue;
|
|
|
- //printf("raw: %#x, float: %f\n", Res[3+i], tmpValue);
|
|
|
- }
|
|
|
-
|
|
|
- memset(pSensorHistory_st->sensor_name, 0,sizeof(pSensorHistory_st->sensor_name));
|
|
|
- memcpy(pSensorHistory_st->sensor_name, sdr_buffer.IDStr, sdr_buffer.IDStrTypeLen&0x3f);
|
|
|
- pSensorHistory_st->sensor_num = sensor_number;
|
|
|
-
|
|
|
- wfree(Res);
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
// /************************************************* new add **********************************************************************/
|
|
|
int LIBIPMI_HL_GetChassisInfo(IPMI20_UDS_SESSION_T *pUDSSession, OemChassisInfo_T* pChassisInfo, int timeout)
|
|
|
{
|
|
@@ -1024,4 +730,64 @@ int IPMC_GetSensorName(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint
|
|
|
|
|
|
memcpy(sensor_name, &Res[7], MAX_ID_STR_LEN);
|
|
|
return 0;
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+int IPMI_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensor_number, uint8_t *history_buf, int timeout)
|
|
|
+{
|
|
|
+ uint8_t Req[10] = {0};
|
|
|
+ uint32_t dwResLen;
|
|
|
+ uint16_t wRet;
|
|
|
+ Req[0] = sensor_number;
|
|
|
+ Req[1] = 0;
|
|
|
+ Req[2] = 0;
|
|
|
+ Req[3] = (MAX_HISTORY_LEN>>8)&0xff;
|
|
|
+ Req[4] = MAX_HISTORY_LEN & 0xff;
|
|
|
+ wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
|
|
|
+ NETFNLUN_IPMI_STORLEAD, CMD_GET_SENSOR_HISTORY,
|
|
|
+ (uint8_t*)Req, 5,
|
|
|
+ (uint8_t *)history_buf, &dwResLen,
|
|
|
+ timeout);
|
|
|
+ if((wRet != 0) || (history_buf[0] != 0))
|
|
|
+ {
|
|
|
+ printf("IPMI_GetSensorHistory error!\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ 本地模块可以一次性全部获取,但是从模块的IPMB总线最大也就只能传输256个字节,所以要分开获取。
|
|
|
+*/
|
|
|
+int IPMC_GetSensorHistory(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t IpmbAddr, uint8_t sensor_number, uint16_t offset, uint16_t length, uint8_t *history_buf, int timeout)
|
|
|
+{
|
|
|
+ uint8_t Req[20] = {0};
|
|
|
+ uint32_t dwResLen;
|
|
|
+ uint16_t wRet;
|
|
|
+ Req[0] = 0x40; //Track | channel 0
|
|
|
+ Req[1] = IpmbAddr;
|
|
|
+ Req[2] = NETFNLUN_IPMI_STORLEAD;
|
|
|
+ Req[3] = 0x100 - (Req[1] + Req[2])&0xff; //checksum1
|
|
|
+ Req[4] = 0x20;
|
|
|
+ Req[5] = 0x10;
|
|
|
+ Req[6] = CMD_GET_SENSOR_HISTORY;
|
|
|
+ Req[7] = sensor_number;
|
|
|
+ Req[8] = offset&0xff; //offset lsb
|
|
|
+ Req[9] = (offset>>8)&0xff; //offset msb
|
|
|
+ Req[10] = length&0xff; //readlen lsb
|
|
|
+ Req[11] = (length>>8)&0xff; //readlen msb
|
|
|
+ Req[12] = 0x100 - (Req[4]+Req[5]+Req[6]+Req[7]+Req[8]+Req[9]+Req[10]+Req[11])&0xff;
|
|
|
+
|
|
|
+ wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pUDSSession,
|
|
|
+ DEFAULT_NET_FN_LUN, CMD_SEND_MSG,
|
|
|
+ Req, 13,
|
|
|
+ history_buf, &dwResLen,
|
|
|
+ timeout);
|
|
|
+ if((wRet != 0) || (history_buf[6] != 0))
|
|
|
+ {
|
|
|
+ printf("IPMC_GetSensorHistory error!\n");
|
|
|
+ return wRet;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|