ipmi_dcmi.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /*
  2. * Copyright (C) 2008 Intel Corporation.
  3. * All rights reserved
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  6. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  7. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  8. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  9. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  10. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  11. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  12. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  13. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  14. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  15. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16. *
  17. */
  18. #ifndef IPMI_DCMI_H
  19. #define IPMI_DCMI_H
  20. #include <ipmitool/ipmi.h>
  21. /* DCMI commands per DCMI 1.5 SPEC */
  22. #define IPMI_DCMI 0xDC /* Group Extension Identification */
  23. #define IPMI_DCMI_COMPAT 0x01
  24. #define IPMI_DCMI_GETRED 0x02
  25. #define IPMI_DCMI_GETLMT 0x03
  26. #define IPMI_DCMI_SETLMT 0x04
  27. #define IPMI_DCMI_PWRACT 0x05
  28. #define IPMI_DCMI_GETASSET 0x06
  29. #define IPMI_DCMI_SETASSET 0x08
  30. #define IPMI_DCMI_GETMNGCTRLIDS 0x09
  31. #define IPMI_DCMI_SETMNGCTRLIDS 0x0A
  32. #define IPMI_DCMI_SETTERMALLIMIT 0x0B
  33. #define IPMI_DCMI_GETTERMALLIMIT 0x0C
  34. #define IPMI_DCMI_GETSNSR 0x07
  35. #define IPMI_DCMI_PWRMGT 0x08
  36. #define IPMI_DCMI_GETTEMPRED 0x10
  37. #define IPMI_DCMI_SETCONFPARAM 0x12
  38. #define IPMI_DCMI_GETCONFPARAM 0x13
  39. #define IPMI_DCMI_CONFORM 0x0001
  40. #define IPMI_DCMI_1_1_CONFORM 0x0101
  41. #define IPMI_DCMI_1_5_CONFORM 0x0501
  42. #define DCMI_MAX_BYTE_SIZE 0x10
  43. #define DCMI_MAX_BYTE_TEMP_READ_SIZE 0x08
  44. #define GOOD_PWR_GLIMIT_CCODE(ccode) ((ccode = ((ccode == 0x80) ? 0 : ccode)))
  45. #define GOOD_ASSET_TAG_CCODE(ccode) ((ccode = (((ccode == 0x80) || (ccode == 0x81) || (ccode == 0x82) || (ccode == 0x83)) ? 0 : ccode)))
  46. /* External Node Manager Configuration and Control Commands per spec 2.0 */
  47. #define IPMI_NM_POLICY_CTL 0xC0
  48. #define IPMI_NM_SET_POLICY 0xC1
  49. #define IPMI_NM_GET_POLICY 0xC2
  50. #define IPMI_NM_SET_ALERT_TH 0xC3
  51. #define IPMI_NM_GET_ALERT_TH 0xC4
  52. #define IPMI_NM_SET_SUSPEND 0xC5
  53. #define IPMI_NM_GET_SUSPEND 0xC6
  54. #define IPMI_NM_RESET_STATS 0xC7
  55. #define IPMI_NM_GET_STATS 0xC8
  56. #define IPMI_NM_GET_CAP 0xC9
  57. #define IPMI_NM_GET_VERSION 0xCA
  58. #define IPMI_NM_SET_POWER 0xCB
  59. #define IPMI_NM_SET_ALERT_DS 0xCE
  60. #define IPMI_NM_GET_ALERT_DS 0xCF
  61. #define IPMI_NM_LIMITING 0xF2
  62. /* Node Manager Policy Control Flags */
  63. #define IPMI_NM_GLOBAL_ENABLE 0x01
  64. #define IPMI_NM_DOMAIN_ENABLE 0x02
  65. #define IPMI_NM_PER_POLICY_ENABLE 0x04
  66. /* Node Manager Set Policy Enable */
  67. #define IPMI_NM_POLICY_ENABLE 0x10
  68. /* Node Manager Policy Trigger Codes */
  69. #define IPMI_NM_NO_POLICY_TRIG 0x00
  70. #define IPMI_NM_TEMP_TRIGGER 0x01
  71. #define IPMI_NM_NO_READ_TRIG 0x02
  72. #define IPMI_NM_RESET_TRIGGER 0x03
  73. #define IPMI_NM_BOOT_TRIGGER 0x04
  74. /* Policy Exception Actions flags */
  75. #define IPMI_NM_POLICY_ALERT 0x01
  76. #define IPMI_NM_POLICY_SHUT 0x02
  77. /* Power Correction codes for Policy action */
  78. #define IPMI_NM_PWR_AUTO_CORR 0x00
  79. #define IPMI_NM_PWR_SOFT_CORR 0x01
  80. #define IPMI_NM_PWR_AGGR_CORR 0x02
  81. /* Set Threshold message size */
  82. #define IPMI_NM_SET_THRESH_LEN 12
  83. /* Number of Suspend Periods */
  84. #define IPMI_NM_SUSPEND_PERIOD_MAX 5
  85. struct dcmi_cmd {
  86. uint16_t val;
  87. const char * str;
  88. const char * desc;
  89. };
  90. /* make a struct for the return from the get limit command */
  91. struct power_limit {
  92. uint8_t grp_id; /* first byte: Group Extension ID */
  93. uint16_t reserved_1; /* second and third bytes are reserved */
  94. uint8_t action; /* fourth byte is the exception action */
  95. uint16_t limit; /* fifth through sixth byte are the power limit in watts */
  96. uint32_t correction; /* seventh - 10th bytes are the correction period */
  97. uint16_t reserved_2; /* 11th - 12th are reserved bytes */
  98. uint16_t sample; /* 13th - 14th are sample period time */
  99. } __attribute__ ((packed));
  100. /* make a struct for the return from the reading command */
  101. struct power_reading {
  102. uint8_t grp_id; /* first byte: Group Extension ID */
  103. uint16_t curr_pwr;
  104. uint16_t min_sample;
  105. uint16_t max_sample;
  106. uint16_t avg_pwr;
  107. uint32_t time_stamp; /* time since epoch */
  108. uint32_t sample;
  109. uint8_t state;
  110. } __attribute__ ((packed));
  111. /* make a struct for the return from the capabilites command */
  112. struct capabilities {
  113. uint8_t grp_id; /* first byte: Group Extension ID */
  114. uint16_t conformance;
  115. uint8_t revision;
  116. uint8_t data_byte1;
  117. uint8_t data_byte2;
  118. uint8_t data_byte3;
  119. uint8_t data_byte4;
  120. } __attribute__ ((packed));
  121. /* make a struct for the return from the sensor info command */
  122. struct sensor_info {
  123. uint8_t grp_id; /* first byte: Group Extension ID */
  124. uint8_t i_instances;
  125. uint8_t i_records;
  126. } __attribute__ ((packed));
  127. /* make a struct for the return from the get asset tag command */
  128. struct asset_tag {
  129. uint8_t grp_id; /* first byte: Group Extension ID */
  130. uint8_t length;
  131. const char tag[16];
  132. } __attribute__ ((packed));
  133. /* make a struct for the return from the set asset tag command */
  134. struct set_asset_tag {
  135. uint8_t grp_id; /* first byte: Group Extension ID */
  136. uint8_t length;
  137. const char tag[16];
  138. uint8_t *data;
  139. } __attribute__ ((packed));
  140. /* make a struct for the return from the get thermal limit command */
  141. struct thermal_limit {
  142. uint8_t grp_id; /* first byte: Group Extension ID */
  143. uint8_t exceptionActions;
  144. uint8_t tempLimit;
  145. uint16_t exceptionTime;
  146. } __attribute__ ((packed));
  147. int ipmi_dcmi_main(struct ipmi_intf * intf, int argc, char ** argv);
  148. /* Node Manager discover command */
  149. struct nm_discover {
  150. uint8_t intel_id[3]; /* Always returns 000157 */
  151. uint8_t nm_version;
  152. uint8_t ipmi_version;
  153. uint8_t patch_version;
  154. uint8_t major_rev;
  155. uint8_t minor_rev;
  156. } __attribute__ ((packed));
  157. /* Node Manager get capabilites command */
  158. struct nm_capability {
  159. uint8_t intel_id[3];
  160. uint8_t max_settings;
  161. uint16_t max_value; /* max power/thermal/time after reset */
  162. uint16_t min_value; /* min "" */
  163. uint32_t min_corr; /* min correction time inmillesecs */
  164. uint32_t max_corr;
  165. uint16_t min_stats;
  166. uint16_t max_stats;
  167. uint8_t scope;
  168. } __attribute__ ((packed));
  169. /* Node Manager get statistics command */
  170. struct nm_statistics {
  171. uint8_t intel_id[3];
  172. uint16_t curr_value;
  173. uint16_t min_value;
  174. uint16_t max_value;
  175. uint16_t ave_value;
  176. uint32_t time_stamp;
  177. uint32_t stat_period;
  178. uint8_t id_state;
  179. } __attribute__ ((packed));
  180. /* Node Manager set policy */
  181. struct nm_policy {
  182. uint8_t intel_id[3];
  183. uint8_t domain; /* 0:3 are domain, 4 = Policy enabled */
  184. uint8_t policy_id;
  185. uint8_t policy_type; /* 0:3 trigger type 4 = action 5:6 correction */
  186. uint8_t policy_exception; /* exception actions */
  187. uint16_t policy_limits;
  188. uint32_t corr_time;
  189. uint16_t trigger_limit;
  190. uint16_t stats_period;
  191. } __attribute__ ((packed));
  192. /* Node Maager get policy */
  193. struct nm_get_policy {
  194. uint8_t intel_id[3];
  195. uint8_t domain; /* 0:3 are domain, 4 = Policy enabled */
  196. uint8_t policy_type; /* 0:3 trigger type 4 = action 5:6 correction */
  197. uint8_t policy_exception; /* exception actions */
  198. uint16_t policy_limits;
  199. uint32_t corr_time;
  200. uint16_t trigger_limit;
  201. uint16_t stats_period;
  202. } __attribute__ ((packed));
  203. /* Node Manager set alert destination */
  204. struct nm_set_alert {
  205. uint8_t intel_id[3];
  206. uint8_t chan; /* 0:3 BMC chan, 4:6 reserved, bit 7=0 register alert reciever =1 invalidate */
  207. uint8_t dest; /* lan destination */
  208. uint8_t string; /* alert string selector */
  209. } __attribute__ ((packed));
  210. /* Node Manager set alert threshold */
  211. struct nm_thresh {
  212. uint8_t intel_id[3];
  213. uint8_t domain; /* 0:3 are domain, 4 = Policy enabled */
  214. uint8_t policy_id;
  215. uint8_t count;
  216. uint16_t thresholds[3];
  217. } __attribute__ ((packed));
  218. /* Node Manager suspend period struct */
  219. struct nm_period {
  220. uint8_t start;
  221. uint8_t stop;
  222. uint8_t repeat;
  223. } __attribute__ ((packed));
  224. /* Node Manager set suspend period */
  225. struct nm_suspend {
  226. uint8_t intel_id[3];
  227. uint8_t domain; /* 0:3 are domain, 4 = Policy enabled */
  228. uint8_t policy_id;
  229. uint8_t count;
  230. struct nm_period period[IPMI_NM_SUSPEND_PERIOD_MAX];
  231. } __attribute__ ((packed));
  232. int ipmi_nm_main(struct ipmi_intf * intf, int argc, char ** argv);
  233. #endif /*IPMI_DCMI_H*/