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