libipmi_storlead_OEM.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /*
  2. * Brief: Get all sensor information.
  3. * Author: Jimbo_zhang@outlook.com
  4. * Data: 2019-4-27
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include "libipmi_AppDevice.h"
  10. #include "libipmi_session.h"
  11. #include "libipmi_errorcodes.h"
  12. #include "libipmi_struct.h"
  13. #include "libipmi_sdr.h"
  14. #include "libipmi_sensor.h"
  15. #include "libipmi_storlead_OEM.h"
  16. OemWebFlags_T g_OemWebFlags;
  17. /*
  18. *@fn IPMICMD_AMIGetSensorInfo
  19. *@brief
  20. *@param pSession - IPMI Session Handle
  21. *@param pAMIGetSensorInfoReq - Pointer to the request of AMI Get SensorInfo command
  22. *@param pAMIGetSensorInfoRes - Pointer to the response of AMI Get SensorInfo command
  23. *@param timeout - Timeout Value
  24. **/
  25. uint16_t IPMICMD_GetIPMCSensorInfo(IPMI20_SESSION_T *pSession, AMIGetSensorInfoRes_T *pGetIPMCSensorInfoRes,int timeout)
  26. {
  27. uint16_t wRet = 0;
  28. uint16_t reservation_id;
  29. uint16_t record_id = 0;
  30. uint32_t dwRecordLen;
  31. SenInfo_T SensorInfo;
  32. uint8_t SDRData[100] = {0};
  33. uint8_t NextRecIDLS = 0;
  34. uint8_t NextRecIDMS = 0;
  35. uint8_t cnt = 0;
  36. uint8_t timeoutTick = 0;
  37. wRet = IPMICMD_ReserveSDRRepository(pSession, (ReserveSDRRepositoryRes_T*)SDRData, timeout);
  38. if(wRet != 0)
  39. {
  40. printf("Error Reserve SDR Repository\n");
  41. return wRet;
  42. }
  43. reservation_id = SDRData[2]<<8 | SDRData[1];
  44. do
  45. {
  46. //Get SDR
  47. if(0 != LIBIPMI_HL_GetSDR(pSession, reservation_id, record_id, (GetSDRRes_T*)SDRData, &dwRecordLen, timeout ))
  48. {
  49. printf("---> Get SDR error! record_id = %#x\n", record_id);
  50. return -1;
  51. }
  52. NextRecIDLS = SDRData[1];
  53. NextRecIDMS = SDRData[2];
  54. memcpy(&SensorInfo.hdr, &SDRData[3],5/*Sizeof(SDRRecHdr_T)*/);
  55. if(SensorInfo.hdr.Type == 0x01) //full sensor sdr
  56. {
  57. SensorInfo.Accuracy_MSB_Exp = SDRData[3+29-1];
  58. //SensorInfo.AssertionEventByte1 = SDRData[3+15-1];
  59. //SensorInfo.AssertionEventByte2 = SDRData[3+16-1];
  60. SensorInfo.B_LSB = SDRData[3+27-1];
  61. SensorInfo.B_MSB_Accuracy = SDRData[3+28-1];
  62. SensorInfo.DeassertionEventByte1 = SDRData[3+17-1];
  63. SensorInfo.DeassertionEventByte2 = SDRData[3+18-1];
  64. SensorInfo.EventTypeCode = SDRData[3+14-1];
  65. SensorInfo.Linearization = SDRData[3+24-1];
  66. SensorInfo.LowerCritical = SDRData[3+41-1];
  67. SensorInfo.LowerNonCritical = SDRData[3+42-1];
  68. SensorInfo.LowerNonRecoverable = SDRData[3+40-1];
  69. SensorInfo.M_LSB = SDRData[3+25-1];
  70. SensorInfo.M_MSB_Tolerance = SDRData[3+26-1];
  71. SensorInfo.MaxReading = SDRData[3+35-1];
  72. SensorInfo.MinReading = SDRData[3+36-1];
  73. SensorInfo.OwnerID = SDRData[3+6-1];
  74. SensorInfo.OwnerLUN = SDRData[3+7-1];
  75. SensorInfo.RExp_BExp = SDRData[3+30-1];
  76. SensorInfo.SensorNumber = SDRData[3+8-1];
  77. SensorInfo.SensorTypeCode = SDRData[3+13-1];
  78. SensorInfo.Settable_Readable_ThreshMask = SDRData[3+20-1]<<8 | SDRData[3+19-1];
  79. SensorInfo.Units1 = SDRData[3+21-1];
  80. SensorInfo.Units2 = SDRData[3+22-1];
  81. SensorInfo.Units3 = SDRData[3+23-1];
  82. SensorInfo.UpperCritical = SDRData[3+38-1];
  83. SensorInfo.UpperNonCritical = SDRData[3+39-1];
  84. SensorInfo.UpperNonRecoverable = SDRData[3+37-1];
  85. memset(SensorInfo.SensorName, 0, 16);
  86. memcpy(SensorInfo.SensorName, &SDRData[3+49-1], SDRData[3+48-1]&0x3f);
  87. //get sensor reading
  88. if(0 != IPMICMD_GetSensorReading(pSession, (GetSensorReadingReq_T *)&SensorInfo.SensorNumber,
  89. (GetSensorReadingRes_T *)SDRData, timeout))
  90. {
  91. printf("---> Get sensorReading error! sensorNum = %#x\n", SensorInfo.SensorNumber);
  92. return -1;
  93. }
  94. SensorInfo.SensorReading = SDRData[1];
  95. SensorInfo.OptionalStatus = SDRData[4];
  96. SensorInfo.Flags = SDRData[2];
  97. SensorInfo.ComparisonStatus = SDRData[3];
  98. if(SensorInfo.EventTypeCode == 0x01) //threshold
  99. {
  100. //TODO: jimbo
  101. SensorInfo.AssertionEventByte1 = 0x0;
  102. SensorInfo.AssertionEventByte2 = 0x0;
  103. if((SensorInfo.Units1 & 0xc0) == 0x00) //unsigned
  104. {
  105. if((uint8_t)SensorInfo.SensorReading > (uint8_t)SensorInfo.UpperCritical)
  106. SensorInfo.AssertionEventByte2 |= 0x02;
  107. if((uint8_t)SensorInfo.SensorReading > (uint8_t)SensorInfo.UpperNonCritical)
  108. SensorInfo.AssertionEventByte1 |= 0x80;
  109. if((uint8_t)SensorInfo.SensorReading > (uint8_t)SensorInfo.UpperNonRecoverable)
  110. SensorInfo.AssertionEventByte2 |= 0x08;
  111. if((uint8_t)SensorInfo.SensorReading < (uint8_t)SensorInfo.LowerCritical)
  112. SensorInfo.AssertionEventByte1 |= 0x04;
  113. if((uint8_t)SensorInfo.SensorReading < (uint8_t)SensorInfo.LowerNonCritical)
  114. SensorInfo.AssertionEventByte1 |= 0x01;
  115. if((uint8_t)SensorInfo.SensorReading < (uint8_t)SensorInfo.LowerNonRecoverable)
  116. SensorInfo.AssertionEventByte1 |= 0x10;
  117. }
  118. else if((SensorInfo.Units1 & 0xc0) == 0x80) //2's complement
  119. {
  120. if((char)SensorInfo.SensorReading > (char)SensorInfo.UpperCritical)
  121. SensorInfo.AssertionEventByte2 |= 0x02;
  122. if((char)SensorInfo.SensorReading > (char)SensorInfo.UpperNonCritical)
  123. SensorInfo.AssertionEventByte1 |= 0x80;
  124. if((char)SensorInfo.SensorReading > (char)SensorInfo.UpperNonRecoverable)
  125. SensorInfo.AssertionEventByte2 |= 0x08;
  126. if((char)SensorInfo.SensorReading < (char)SensorInfo.LowerCritical)
  127. SensorInfo.AssertionEventByte1 |= 0x04;
  128. if((char)SensorInfo.SensorReading < (char)SensorInfo.LowerNonCritical)
  129. SensorInfo.AssertionEventByte1 |= 0x01;
  130. if((char)SensorInfo.SensorReading < (char)SensorInfo.LowerNonRecoverable)
  131. SensorInfo.AssertionEventByte1 |= 0x10;
  132. }
  133. }
  134. memcpy(((uint8_t*)pGetIPMCSensorInfoRes)+3+sizeof(SenInfo_T)*cnt, &SensorInfo, sizeof(SenInfo_T));
  135. cnt++;
  136. // printf("cnt: %d, sensorNum: %#x, sensorReading: %#x, OptionStatus = %#x, ComparisonStatus = %#x\n",
  137. // cnt, SensorInfo.SensorNumber, SensorInfo.SensorReading, SensorInfo.OptionalStatus, SensorInfo.ComparisonStatus);
  138. }
  139. record_id = NextRecIDMS<<8 | NextRecIDLS;
  140. timeoutTick++;
  141. if(timeoutTick > 64)
  142. {
  143. wRet = -1;
  144. break;
  145. }
  146. }while(record_id != 0xffff);
  147. if(wRet == 0)
  148. pGetIPMCSensorInfoRes->CompletionCode = 0;
  149. else
  150. pGetIPMCSensorInfoRes->CompletionCode = 255;
  151. pGetIPMCSensorInfoRes->Noofentries = cnt;
  152. // printf("return pGetIPMCSensorInfoRes: ");
  153. // for(i=0;i<3+sizeof(SenInfo_T)*cnt;i++)
  154. // printf("%#2x ",((uint8_t*)pGetIPMCSensorInfoRes)[i]);
  155. // printf("\n");
  156. return (wRet);
  157. }
  158. uint16_t LIBIPMI_HL_GetIPMCSensorInfo(IPMI20_SESSION_T *pSession,SenInfo_T *pSensorInfo,uint32_t *nNumSensor,int timeout)
  159. {
  160. uint16_t wRet = 0;
  161. AMIGetSensorInfoRes_T *pGetIPMCSensorInfoRes;
  162. uint8_t *SensorEntries;
  163. int i;
  164. SensorEntries = (uint8_t *)malloc(MAX_SENSOR_INFO_SIZE);
  165. if(SensorEntries == NULL)
  166. {
  167. printf("Memory allocation error in LIBIPMI_HL_AMIGetSELEntires \n");
  168. wRet = 0xFF;
  169. return wRet;
  170. }
  171. memset(SensorEntries,0,MAX_SENSOR_INFO_SIZE);
  172. pGetIPMCSensorInfoRes = (AMIGetSensorInfoRes_T *)SensorEntries;
  173. wRet = IPMICMD_GetIPMCSensorInfo(pSession,(AMIGetSensorInfoRes_T *)SensorEntries,timeout);
  174. if(wRet == LIBIPMI_E_SUCCESS)
  175. {
  176. *nNumSensor = pGetIPMCSensorInfoRes->Noofentries;
  177. for(i = 0; i < pGetIPMCSensorInfoRes->Noofentries; i++)
  178. {
  179. memcpy((uint8_t *)&pSensorInfo[i],&SensorEntries[sizeof(AMIGetSensorInfoRes_T) + (i * sizeof(SenInfo_T))],sizeof(SenInfo_T) );
  180. }
  181. }
  182. else
  183. {
  184. printf("error getting sensor info %d\n",wRet);
  185. }
  186. free(SensorEntries);
  187. return (wRet);
  188. }
  189. uint16_t LIBIPMI_HL_FanCtrol( IPMI20_SESSION_T *pSession, uint8_t fanIndex, uint8_t fanMode, uint8_t fanLevel, int timeout)
  190. {
  191. uint16_t wRet = 0;
  192. uint8_t Res[10];
  193. uint8_t Req[10];
  194. uint32_t dwResLen;
  195. Req[0] = fanIndex;
  196. Req[1] = fanMode;
  197. Req[2] = fanLevel;
  198. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, 0x2e<<2, 0x87,
  199. (uint8_t*)Req, 3,
  200. (uint8_t *)Res, &dwResLen,
  201. timeout);
  202. return wRet;
  203. }
  204. int LIBIPMI_HL_GetFanStatus( IPMI20_SESSION_T *pSession, uint8_t fanIndex, OemFanStatus_T *pFanStatus, int timeout)
  205. {
  206. uint16_t wRet = 0;
  207. uint8_t Res[32];
  208. uint32_t dwResLen;
  209. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, 0x2e<<2, 0x86,
  210. (uint8_t*)&fanIndex, 1,
  211. (uint8_t *)Res, &dwResLen,
  212. timeout);
  213. memset(pFanStatus->name, 0, 16);
  214. if((wRet == 0) && (Res[0] == 0))
  215. {
  216. pFanStatus->index = fanIndex;
  217. memcpy(pFanStatus->name, &Res[1], 16);
  218. pFanStatus->level = Res[17];
  219. pFanStatus->mode = Res[18];
  220. pFanStatus->speed = (Res[19]<<24) | (Res[20]<<16) | (Res[21]<<8) | Res[22];
  221. }
  222. else
  223. {
  224. printf("---> LIBIPMI_HL_GetFanInfo get fan info error!\n");
  225. pFanStatus->index = fanIndex;
  226. memcpy(pFanStatus->name, "UNKNOWN", 7);
  227. pFanStatus->level = 0;
  228. pFanStatus->mode = 0;
  229. pFanStatus->speed = 0;
  230. return -1;
  231. }
  232. return 0;
  233. }
  234. uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_SESSION_T *pSession, SysInfo_T *pSysInfo, int timeout)
  235. {
  236. uint16_t wRet = 0;
  237. uint8_t Req[5];
  238. uint8_t Res[MAX_TEXT_LEN+5];
  239. uint32_t dwResLen;
  240. uint16_t strLen, remainLen;
  241. uint16_t offset = 0;
  242. //get title
  243. Req[0] = 0;
  244. Req[1] = 0;
  245. Req[2] = 0;
  246. Req[3] = (MAX_TITLE_LEN>>8)&0xff; //max title len
  247. Req[4] = MAX_TITLE_LEN&0xff;
  248. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  249. NETFNLUN_IPMI_OEM, 0x80,
  250. (uint8_t*)Req, 5,
  251. (uint8_t *)Res, &dwResLen,
  252. timeout);
  253. if((wRet != 0) || (Res[0] != 0))
  254. {
  255. printf("---> get Title error\n");
  256. return -1;
  257. }
  258. strLen = (Res[1]<<8) | Res[2];
  259. remainLen = (Res[3]<<8) | Res[4];
  260. memcpy(pSysInfo->title,&Res[5],strLen);
  261. //get text
  262. Req[0] = 1;
  263. Req[1] = 0;
  264. Req[2] = 0;
  265. Req[3] = (MAX_TEXT_LEN>>8)&0xff; //max text len
  266. Req[4] = MAX_TEXT_LEN&0xff;
  267. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  268. NETFNLUN_IPMI_OEM, 0x80,
  269. (uint8_t*)Req, 5,
  270. (uint8_t *)Res, &dwResLen,
  271. timeout);
  272. if((wRet != 0) || (Res[0] != 0))
  273. {
  274. printf("---> get Text error\n");
  275. return -1;
  276. }
  277. strLen = (Res[1]<<8) | Res[2];
  278. remainLen = (Res[3]<<8) | Res[4];
  279. memcpy(pSysInfo->text,&Res[5],strLen);
  280. return 0;
  281. }
  282. uint16_t
  283. LIBIPMI_HL_GetSensorHistory( IPMI20_SESSION_T *pSession, sensor_history_st *pSensorHistory_st, int card_index, int sensor_number, int IPMB_ADDR)
  284. {
  285. printf(">come in history\n");
  286. int i = 0;
  287. uint8_t RawHistory[MAX_HISTORY_LEN];
  288. uint16_t wRet;
  289. uint32_t dwResLen;
  290. uint32_t sdr_buff_size = 100;
  291. uint8_t Req[5];
  292. uint8_t Res[MAX_HISTORY_LEN+3];
  293. int timeout = 3;
  294. FullSensorRec_T sdr_buffer;
  295. uint16_t offset = 0;
  296. uint16_t reqLen = 0, resLen = 0;
  297. //get factors
  298. LIBIPMI_HL_GetSpecificSDR( pSession, (uint8_t*)&sdr_buffer, &sdr_buff_size, sensor_number, timeout );
  299. //get history
  300. // if( pSession->byMediumType == IPMB_MEDIUM )
  301. // {
  302. // reqLen = 22; //32 bytes - ipmb message header - response header - checksum2
  303. // do{
  304. // Req[0] = sensor_number;
  305. // Req[1] = (offset>>8)&0xff;
  306. // Req[2] = offset&0xff;
  307. // Req[3] = (reqLen>>8)&0xff;
  308. // Req[4] = reqLen&0xff;
  309. // wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, 0x2e<<2, 0x89,
  310. // (uint8_t*)Req, 5,
  311. // (uint8_t *)Res, &dwResLen,
  312. // timeout);
  313. // if(wRet != 0)
  314. // {
  315. // return -1;
  316. // }
  317. // resLen = (Res[1]<<8) | Res[2];
  318. // if(resLen > MAX_HISTORY_LEN)
  319. // {
  320. // printf("---> response length error: resLen = %#x\n", resLen);
  321. // return -1;
  322. // }
  323. // memcpy(&RawHistory[offset],&Res[3],resLen);
  324. // offset += resLen;
  325. // if(offset >= MAX_HISTORY_LEN) //get all history datas
  326. // {
  327. // reqLen = 0;
  328. // break;
  329. // }
  330. // reqLen = ((MAX_HISTORY_LEN-offset)>22) ? 22 : (MAX_HISTORY_LEN-offset);
  331. // }while(reqLen);
  332. // }
  333. // else
  334. {
  335. Req[0] = sensor_number;
  336. Req[1] = 0;
  337. Req[2] = 0;
  338. Req[3] = (MAX_HISTORY_LEN>>8)&0xff;
  339. Req[4] = MAX_HISTORY_LEN & 0xff;
  340. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession, 0x2e<<2, 0x89,
  341. (uint8_t*)Req, 5,
  342. (uint8_t *)Res, &dwResLen,
  343. timeout);
  344. if(wRet != 0)
  345. {
  346. return -1;
  347. }
  348. resLen = (Res[1]<<8) | Res[2];
  349. if(resLen > MAX_HISTORY_LEN)
  350. {
  351. printf("---> response length error: resLen = %#x\n", resLen);
  352. return -1;
  353. }
  354. memcpy(RawHistory,&Res[3],resLen);
  355. }
  356. for(i=0;i < 480; i++)
  357. {
  358. ipmi_convert_reading( (uint8_t*)&sdr_buffer, RawHistory[i], (float*)&pSensorHistory_st->sensor_history[i] );
  359. }
  360. memset(pSensorHistory_st->sensor_name, 0,sizeof(pSensorHistory_st->sensor_name));
  361. memcpy(pSensorHistory_st->sensor_name, sdr_buffer.IDStr, sdr_buffer.IDStrTypeLen&0x3f);
  362. pSensorHistory_st->sensor_num = sensor_number;
  363. return 0;
  364. }
  365. uint16_t LIBIPMI_HL_GetAllCards(IPMI20_SESSION_T *pSession,
  366. CardStatus_T* pResBladeSts,
  367. int timeout)
  368. {
  369. uint16_t wRet;
  370. uint32_t dwResLen;
  371. uint8_t ReqData = g_OemWebFlags.bladeNum;
  372. dwResLen = sizeof(CardStatus_T);
  373. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  374. 0x2e<<2, 0x82,
  375. (uint8_t*)&ReqData, (uint32_t)1,
  376. (uint8_t*)pResBladeSts, &dwResLen,
  377. timeout);
  378. if( wRet != 0 )
  379. printf("Error getting Blade Status Info\n");
  380. return wRet;
  381. }
  382. /************************************************* new add **********************************************************************/
  383. int LIBIPMI_HL_GetChassisInfo(IPMI20_SESSION_T *pSession, OemChassisInfo_T* pChassisInfo, int timeout)
  384. {
  385. uint8_t pRes[10];
  386. int wRet = 0;
  387. uint32_t dwResLen;
  388. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  389. 0x2e<<2, 0x80,
  390. NULL, 0,
  391. (uint8_t*)pRes, &dwResLen,
  392. timeout);
  393. if( wRet != 0 )
  394. printf("Error getting Blade Status Info\n");
  395. pChassisInfo->slotNum = pRes[1];
  396. pChassisInfo->supportChassisManageFn = pRes[2];
  397. pChassisInfo->chassisManageFnEnable = pRes[3];
  398. pChassisInfo->chMCIndex = pRes[4];
  399. return 0;
  400. }
  401. int LIBIPMI_HL_GetBladeStatus(IPMI20_SESSION_T *pSession, OemBladeStatus_T BladeStatus[], int timeout)
  402. {
  403. int wRet = 0;
  404. uint32_t dwResLen;
  405. uint8_t pRes[MAX_BLADE_NUM*sizeof(OemBladeStatus_T)+1];
  406. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  407. 0x2e<<2, 0x81,
  408. NULL, 0,
  409. (uint8_t*)pRes, &dwResLen,
  410. timeout);
  411. if( wRet != 0 )
  412. printf("Error getting Blade Status Info\n");
  413. memcpy(BladeStatus, pRes+1, g_OemWebFlags.bladeNum*sizeof(OemBladeStatus_T));
  414. return 0;
  415. }
  416. int LIBIPMI_HL_GetIPMCCapability(IPMI20_SESSION_T *pSession, uint8_t bladeIndex, OemIPMCCapability_T* pIPMCCapability, int timeout)
  417. {
  418. int wRet = 0;
  419. uint32_t dwResLen;
  420. uint8_t pRes[sizeof(OemIPMCCapability_T)+1];
  421. if(pSession->byMediumType == UDS_MEDIUM)
  422. {
  423. pRes[1] = 1;
  424. pRes[2] = 1;
  425. pRes[3] = 1;
  426. pRes[4] = 1;
  427. pRes[5] = 1;
  428. pRes[6] = 1;
  429. pRes[7] = 1;
  430. }
  431. else
  432. {
  433. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  434. 0x2e<<2, 0x88,
  435. NULL, 0,
  436. (uint8_t*)pRes, &dwResLen,
  437. timeout);
  438. if( wRet != 0 )
  439. printf("Error LIBIPMI_HL_GetIPMCCapability\n");
  440. }
  441. memcpy(pIPMCCapability, pRes+1, sizeof(OemIPMCCapability_T));
  442. return 0;
  443. }
  444. int LIBIPMI_HL_SetBladeManageFn(IPMI20_SESSION_T *pSession, uint8_t enable, int timeout)
  445. {
  446. int wRet = 0;
  447. uint32_t dwResLen;
  448. uint8_t pReq[10];
  449. uint8_t pRes[10];
  450. pReq[0] = enable;
  451. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  452. 0x2e<<2, 0x8a,
  453. (uint8_t*)pReq, (uint32_t)1,
  454. (uint8_t*)pRes, &dwResLen,
  455. timeout);
  456. if( wRet != 0 )
  457. printf("Error LIBIPMI_HL_SetBladeManageFn\n");
  458. return 0;
  459. }
  460. int LIBIPMI_HL_GetManageWebName(IPMI20_SESSION_T *pSession, char* webName, int timeout)
  461. {
  462. int wRet = 0;
  463. uint32_t dwResLen;
  464. uint8_t pRes[20];
  465. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  466. 0x2e<<2, 0x84,
  467. NULL, 0,
  468. (uint8_t*)pRes, &dwResLen,
  469. timeout);
  470. if( wRet != 0 )
  471. printf("Error LIBIPMI_HL_SetBladeManageFn\n");
  472. memset(webName, 0, 16);
  473. memcpy(webName, pRes+1, 16);
  474. return 0;
  475. }
  476. int LIBIPMI_HL_GetFanInfo(IPMI20_SESSION_T *pSession, OemFanInfo_T* pFanInfo, int timeout)
  477. {
  478. int wRet = 0;
  479. uint32_t dwResLen;
  480. uint8_t pRes[10];
  481. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  482. 0x2e<<2, 0x85,
  483. NULL, 0,
  484. (uint8_t*)pRes, &dwResLen,
  485. timeout);
  486. if( wRet != 0 )
  487. printf("Error LIBIPMI_HL_SetBladeManageFn\n");
  488. pFanInfo->fanNum = pRes[1];
  489. return 0;
  490. }
  491. int LIBIPMI_HL_GetSensorHistoryCapability(IPMI20_SESSION_T *pSession, uint8_t sensorNum, SensorHistoryCapability_T* pSensorHistoryCapability, int timeout)
  492. {
  493. int wRet = 0;
  494. uint32_t dwResLen;
  495. uint8_t pRes[10];
  496. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  497. 0x2e<<2, 0x88,
  498. (uint8_t*)&sensorNum, 1,
  499. (uint8_t*)pRes, &dwResLen,
  500. timeout);
  501. if( wRet != 0 )
  502. printf("Error LIBIPMI_HL_GetSensorHistoryCapability\n");
  503. pSensorHistoryCapability->isSupportSensorHistory = pRes[1];
  504. pSensorHistoryCapability->SensorHistoryEnable = pRes[2];
  505. return 0;
  506. }
  507. //int LIBIPMI_HL_GetSensorHistoryEn(IPMI20_SESSION_T *pSession, uint8_t* SensorHistoryEnable, int timeout)
  508. //{
  509. // int wRet = 0;
  510. // uint32_t dwResLen;
  511. // uint8_t pRes[10];
  512. //
  513. // wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  514. // 0x2e<<2, 0x8c,
  515. // NULL, 0,
  516. // (uint8_t*)pRes, &dwResLen,
  517. // timeout);
  518. // if( wRet != 0 )
  519. // printf("Error LIBIPMI_HL_GetSensorHistoryEn\n");
  520. //
  521. // *SensorHistoryEnable = pRes[1];
  522. // return 0;
  523. //}
  524. int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_SESSION_T *pSession, uint8_t sensorNum, uint8_t SensorHistoryEnable, int timeout)
  525. {
  526. int wRet = 0;
  527. uint32_t dwResLen;
  528. uint8_t pRes[10];
  529. uint8_t pReq[10];
  530. pReq[0] = sensorNum;
  531. pReq[1] = SensorHistoryEnable;
  532. wRet = LIBIPMI_Send_RAW_IPMI2_0_Command(pSession,
  533. 0x2e<<2, 0x8d,
  534. (uint8_t*)pReq, 2,
  535. (uint8_t*)pRes, &dwResLen,
  536. timeout);
  537. if( wRet != 0 )
  538. printf("Error LIBIPMI_HL_SetSensorHistoryEn\n");
  539. return 0;
  540. }