1*c5fc2d49Skettenis /* $OpenBSD: ipmivar.h,v 1.34 2021/01/23 12:10:08 kettenis Exp $ */ 2fbca7c3fSmarco 3fbca7c3fSmarco /* 4fbca7c3fSmarco * Copyright (c) 2005 Jordan Hargrave 5fbca7c3fSmarco * All rights reserved. 6fbca7c3fSmarco * 7fbca7c3fSmarco * Redistribution and use in source and binary forms, with or without 8fbca7c3fSmarco * modification, are permitted provided that the following conditions 9fbca7c3fSmarco * are met: 10fbca7c3fSmarco * 1. Redistributions of source code must retain the above copyright 11fbca7c3fSmarco * notice, this list of conditions and the following disclaimer. 12fbca7c3fSmarco * 2. Redistributions in binary form must reproduce the above copyright 13fbca7c3fSmarco * notice, this list of conditions and the following disclaimer in the 14fbca7c3fSmarco * documentation and/or other materials provided with the distribution. 15fbca7c3fSmarco * 16fbca7c3fSmarco * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 17fbca7c3fSmarco * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18fbca7c3fSmarco * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19fbca7c3fSmarco * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 20fbca7c3fSmarco * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21fbca7c3fSmarco * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22fbca7c3fSmarco * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23fbca7c3fSmarco * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24fbca7c3fSmarco * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25fbca7c3fSmarco * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26fbca7c3fSmarco * SUCH DAMAGE. 27fbca7c3fSmarco * 28fbca7c3fSmarco */ 29fbca7c3fSmarco 30fbca7c3fSmarco #ifndef _IPMIVAR_H_ 31fbca7c3fSmarco #define _IPMIVAR_H_ 32fbca7c3fSmarco 337b74a005Salek #include <sys/rwlock.h> 3427515a6bSderaadt #include <sys/sensors.h> 3566590f60Suebayasi #include <sys/task.h> 36b2bc3525Smarco 378f330473Suebayasi #include <dev/ipmi.h> 388f330473Suebayasi 39fbca7c3fSmarco #define IPMI_IF_KCS 1 40fbca7c3fSmarco #define IPMI_IF_SMIC 2 41fbca7c3fSmarco #define IPMI_IF_BT 3 4219146c2bSkettenis #define IPMI_IF_SSIF 4 43fbca7c3fSmarco 44fbca7c3fSmarco #define IPMI_IF_KCS_NREGS 2 45fbca7c3fSmarco #define IPMI_IF_SMIC_NREGS 3 46fbca7c3fSmarco #define IPMI_IF_BT_NREGS 3 47fbca7c3fSmarco 48586c8866Sjordan struct ipmi_thread; 49fbca7c3fSmarco struct ipmi_softc; 50dd9acc24Suebayasi struct ipmi_cmd; 51fbca7c3fSmarco 528f330473Suebayasi struct ipmi_iowait { 53b2bc3525Smarco int offset; 54b2bc3525Smarco u_int8_t mask; 55b2bc3525Smarco u_int8_t value; 56b2bc3525Smarco volatile u_int8_t *v; 578f330473Suebayasi const char *lbl; 58b2bc3525Smarco }; 59b2bc3525Smarco 60fbca7c3fSmarco struct ipmi_attach_args { 61fbca7c3fSmarco char *iaa_name; 62fbca7c3fSmarco bus_space_tag_t iaa_iot; 63fbca7c3fSmarco bus_space_tag_t iaa_memt; 64fbca7c3fSmarco 65fbca7c3fSmarco int iaa_if_type; 66fbca7c3fSmarco int iaa_if_rev; 67fbca7c3fSmarco int iaa_if_iotype; 687518efcdSkettenis bus_addr_t iaa_if_iobase; 69cda7789cSkettenis int iaa_if_iosize; 70fbca7c3fSmarco int iaa_if_iospacing; 71fbca7c3fSmarco int iaa_if_irq; 72fbca7c3fSmarco int iaa_if_irqlvl; 73fbca7c3fSmarco }; 74fbca7c3fSmarco 75fbca7c3fSmarco struct ipmi_if { 76fbca7c3fSmarco const char *name; 77fbca7c3fSmarco int nregs; 78235dcbf6Suebayasi void (*buildmsg)(struct ipmi_cmd *); 79779678c0Suebayasi int (*sendmsg)(struct ipmi_cmd *); 80779678c0Suebayasi int (*recvmsg)(struct ipmi_cmd *); 81fbca7c3fSmarco int (*reset)(struct ipmi_softc *); 82fbca7c3fSmarco int (*probe)(struct ipmi_softc *); 83779678c0Suebayasi int datasnd; 84779678c0Suebayasi int datarcv; 85fbca7c3fSmarco }; 86fbca7c3fSmarco 870fe7a73cSuebayasi struct ipmi_cmd { 880fe7a73cSuebayasi struct ipmi_softc *c_sc; 890fe7a73cSuebayasi 900fe7a73cSuebayasi int c_rssa; 910fe7a73cSuebayasi int c_rslun; 920fe7a73cSuebayasi int c_netfn; 930fe7a73cSuebayasi int c_cmd; 940fe7a73cSuebayasi 950fe7a73cSuebayasi int c_txlen; 960fe7a73cSuebayasi int c_maxrxlen; 970fe7a73cSuebayasi int c_rxlen; 980fe7a73cSuebayasi 990fe7a73cSuebayasi void *c_data; 1000fe7a73cSuebayasi u_int c_ccode; 1010fe7a73cSuebayasi }; 1020fe7a73cSuebayasi 103fbca7c3fSmarco struct ipmi_softc { 104fbca7c3fSmarco struct device sc_dev; 105fbca7c3fSmarco 106fbca7c3fSmarco struct ipmi_if *sc_if; /* Interface layer */ 107cda7789cSkettenis int sc_if_iosize; /* Size of I/O porrs */ 108fbca7c3fSmarco int sc_if_iospacing; /* Spacing of I/O ports */ 109fbca7c3fSmarco int sc_if_rev; /* IPMI Revision */ 110fbca7c3fSmarco 111fbca7c3fSmarco void *sc_ih; /* Interrupt/IO handles */ 112fbca7c3fSmarco bus_space_tag_t sc_iot; 113fbca7c3fSmarco bus_space_handle_t sc_ioh; 114fbca7c3fSmarco 115fbca7c3fSmarco int sc_btseq; 116235dcbf6Suebayasi u_int8_t sc_buf[IPMI_MAX_RX + 16]; 117f640b71bSuebayasi struct taskq *sc_cmd_taskq; 118586c8866Sjordan 1198f330473Suebayasi struct ipmi_ioctl { 1208f330473Suebayasi struct rwlock lock; 1218f330473Suebayasi struct ipmi_req req; 1228f330473Suebayasi struct ipmi_cmd cmd; 1238f330473Suebayasi uint8_t buf[IPMI_MAX_RX]; 1248f330473Suebayasi } sc_ioctl; 1258f330473Suebayasi 1267a3397e7Sjordan int sc_wdog_period; 12766590f60Suebayasi struct task sc_wdog_tickle_task; 1287a3397e7Sjordan 129586c8866Sjordan struct ipmi_thread *sc_thread; 130b2bc3525Smarco 131987084d8Smarco struct ipmi_sensor *current_sensor; 132275cbf62Sderaadt struct ksensordev sc_sensordev; 133fbca7c3fSmarco }; 134fbca7c3fSmarco 135586c8866Sjordan struct ipmi_thread { 136586c8866Sjordan struct ipmi_softc *sc; 137586c8866Sjordan volatile int running; 138586c8866Sjordan }; 139586c8866Sjordan 1400728ef28Suebayasi #define IPMI_WDOG_DONTSTOP 0x40 1410728ef28Suebayasi 1427a3397e7Sjordan #define IPMI_WDOG_MASK 0x03 1437a3397e7Sjordan #define IPMI_WDOG_DISABLED 0x00 1447a3397e7Sjordan #define IPMI_WDOG_REBOOT 0x01 1457a3397e7Sjordan #define IPMI_WDOG_PWROFF 0x02 1467a3397e7Sjordan #define IPMI_WDOG_PWRCYCLE 0x03 1477a3397e7Sjordan 1487a3397e7Sjordan #define IPMI_WDOG_PRE_DISABLED 0x00 1497a3397e7Sjordan #define IPMI_WDOG_PRE_SMI 0x01 1507a3397e7Sjordan #define IPMI_WDOG_PRE_NMI 0x02 1517a3397e7Sjordan #define IPMI_WDOG_PRE_INTERRUPT 0x03 1527a3397e7Sjordan 153fd99d266Syasuoka #define IPMI_SET_WDOG_TIMER 0 154fd99d266Syasuoka #define IPMI_SET_WDOG_ACTION 1 155fd99d266Syasuoka #define IPMI_SET_WDOG_PRETIMO 2 156fd99d266Syasuoka #define IPMI_SET_WDOG_FLAGS 3 157fd99d266Syasuoka #define IPMI_SET_WDOG_TIMOL 4 158fd99d266Syasuoka #define IPMI_SET_WDOG_TIMOM 5 159fd99d266Syasuoka #define IPMI_SET_WDOG_MAX 6 160fd99d266Syasuoka 161fd99d266Syasuoka #define IPMI_GET_WDOG_TIMER IPMI_SET_WDOG_TIMER 162fd99d266Syasuoka #define IPMI_GET_WDOG_ACTION IPMI_SET_WDOG_ACTION 163fd99d266Syasuoka #define IPMI_GET_WDOG_PRETIMO IPMI_SET_WDOG_PRETIMO 164fd99d266Syasuoka #define IPMI_GET_WDOG_FLAGS IPMI_SET_WDOG_FLAGS 165fd99d266Syasuoka #define IPMI_GET_WDOG_TIMOL IPMI_SET_WDOG_TIMOL 166fd99d266Syasuoka #define IPMI_GET_WDOG_TIMOM IPMI_SET_WDOG_TIMOM 167fd99d266Syasuoka #define IPMI_GET_WDOG_PRECDL 6 168fd99d266Syasuoka #define IPMI_GET_WDOG_PRECDM 7 169fd99d266Syasuoka #define IPMI_GET_WDOG_MAX 8 1707a3397e7Sjordan 171c08dc278Skettenis int ipmi_probe(void *); 172c08dc278Skettenis void ipmi_attach_common(struct ipmi_softc *, struct ipmi_attach_args *); 173c08dc278Skettenis int ipmi_activate(struct device *, int); 174fbca7c3fSmarco 17519146c2bSkettenis int ipmi_sendcmd(struct ipmi_cmd *); 17619146c2bSkettenis int ipmi_recvcmd(struct ipmi_cmd *); 17719146c2bSkettenis 178*c5fc2d49Skettenis #define IPMI_MSG_NFLN 0 179*c5fc2d49Skettenis #define IPMI_MSG_CMD 1 180*c5fc2d49Skettenis #define IPMI_MSG_CCODE 2 18119146c2bSkettenis #define IPMI_MSG_DATASND 2 18219146c2bSkettenis #define IPMI_MSG_DATARCV 3 18319146c2bSkettenis 184fbca7c3fSmarco #define APP_NETFN 0x06 185fbca7c3fSmarco #define APP_GET_DEVICE_ID 0x01 186fbca7c3fSmarco #define APP_RESET_WATCHDOG 0x22 187fbca7c3fSmarco #define APP_SET_WATCHDOG_TIMER 0x24 188fbca7c3fSmarco #define APP_GET_WATCHDOG_TIMER 0x25 18919146c2bSkettenis #define APP_GET_SYSTEM_INTERFACE_CAPS 0x57 190fbca7c3fSmarco 191fbca7c3fSmarco #define TRANSPORT_NETFN 0xC 192fbca7c3fSmarco #define BRIDGE_NETFN 0x2 193fbca7c3fSmarco 194fbca7c3fSmarco #define STORAGE_NETFN 0x0A 195fbca7c3fSmarco #define STORAGE_GET_FRU_INV_AREA 0x10 196fbca7c3fSmarco #define STORAGE_READ_FRU_DATA 0x11 197fbca7c3fSmarco #define STORAGE_RESERVE_SDR 0x22 198fbca7c3fSmarco #define STORAGE_GET_SDR 0x23 199fbca7c3fSmarco #define STORAGE_ADD_SDR 0x24 200fbca7c3fSmarco #define STORAGE_ADD_PARTIAL_SDR 0x25 201fbca7c3fSmarco #define STORAGE_DELETE_SDR 0x26 202fbca7c3fSmarco #define STORAGE_RESERVE_SEL 0x42 203fbca7c3fSmarco #define STORAGE_GET_SEL 0x43 204fbca7c3fSmarco #define STORAGE_ADD_SEL 0x44 205fbca7c3fSmarco #define STORAGE_ADD_PARTIAL_SEL 0x45 206fbca7c3fSmarco #define STORAGE_DELETE_SEL 0x46 207fbca7c3fSmarco 208fbca7c3fSmarco #define SE_NETFN 0x04 209fbca7c3fSmarco #define SE_GET_SDR_INFO 0x20 210fbca7c3fSmarco #define SE_GET_SDR 0x21 211fbca7c3fSmarco #define SE_RESERVE_SDR 0x22 212fbca7c3fSmarco #define SE_GET_SENSOR_FACTOR 0x23 213fbca7c3fSmarco #define SE_SET_SENSOR_HYSTERESIS 0x24 214fbca7c3fSmarco #define SE_GET_SENSOR_HYSTERESIS 0x25 215fbca7c3fSmarco #define SE_SET_SENSOR_THRESHOLD 0x26 216fbca7c3fSmarco #define SE_GET_SENSOR_THRESHOLD 0x27 217fbca7c3fSmarco #define SE_SET_SENSOR_EVENT_ENABLE 0x28 218fbca7c3fSmarco #define SE_GET_SENSOR_EVENT_ENABLE 0x29 219fbca7c3fSmarco #define SE_REARM_SENSOR_EVENTS 0x2A 220fbca7c3fSmarco #define SE_GET_SENSOR_EVENT_STATUS 0x2B 221fbca7c3fSmarco #define SE_GET_SENSOR_READING 0x2D 222fbca7c3fSmarco #define SE_SET_SENSOR_TYPE 0x2E 223fbca7c3fSmarco #define SE_GET_SENSOR_TYPE 0x2F 224fbca7c3fSmarco 225b6d6d087Smarco struct sdrhdr { 226fbca7c3fSmarco u_int16_t record_id; /* SDR Record ID */ 227fbca7c3fSmarco u_int8_t sdr_version; /* SDR Version */ 228fbca7c3fSmarco u_int8_t record_type; /* SDR Record Type */ 229fbca7c3fSmarco u_int8_t record_length; /* SDR Record Length */ 230b6d6d087Smarco } __packed; 231fbca7c3fSmarco 232fbca7c3fSmarco /* SDR: Record Type 1 */ 233b6d6d087Smarco struct sdrtype1 { 234b6d6d087Smarco struct sdrhdr sdrhdr; 235fbca7c3fSmarco 236fbca7c3fSmarco u_int8_t owner_id; 237fbca7c3fSmarco u_int8_t owner_lun; 238fbca7c3fSmarco u_int8_t sensor_num; 239fbca7c3fSmarco 240fbca7c3fSmarco u_int8_t entity_id; 241fbca7c3fSmarco u_int8_t entity_instance; 242fbca7c3fSmarco u_int8_t sensor_init; 243fbca7c3fSmarco u_int8_t sensor_caps; 244fbca7c3fSmarco u_int8_t sensor_type; 245fbca7c3fSmarco u_int8_t event_code; 246fbca7c3fSmarco u_int16_t trigger_mask; 247fbca7c3fSmarco u_int16_t reading_mask; 248fbca7c3fSmarco u_int16_t settable_mask; 249fbca7c3fSmarco u_int8_t units1; 250fbca7c3fSmarco u_int8_t units2; 251fbca7c3fSmarco u_int8_t units3; 252fbca7c3fSmarco u_int8_t linear; 253fbca7c3fSmarco u_int8_t m; 254fbca7c3fSmarco u_int8_t m_tolerance; 255fbca7c3fSmarco u_int8_t b; 256fbca7c3fSmarco u_int8_t b_accuracy; 257fbca7c3fSmarco u_int8_t accuracyexp; 258fbca7c3fSmarco u_int8_t rbexp; 259fbca7c3fSmarco u_int8_t analogchars; 260fbca7c3fSmarco u_int8_t nominalreading; 261fbca7c3fSmarco u_int8_t normalmax; 262fbca7c3fSmarco u_int8_t normalmin; 263fbca7c3fSmarco u_int8_t sensormax; 264fbca7c3fSmarco u_int8_t sensormin; 265fbca7c3fSmarco u_int8_t uppernr; 266fbca7c3fSmarco u_int8_t upperc; 267fbca7c3fSmarco u_int8_t uppernc; 268fbca7c3fSmarco u_int8_t lowernr; 269fbca7c3fSmarco u_int8_t lowerc; 270fbca7c3fSmarco u_int8_t lowernc; 271fbca7c3fSmarco u_int8_t physt; 272fbca7c3fSmarco u_int8_t nhyst; 273fbca7c3fSmarco u_int8_t resvd[2]; 274fbca7c3fSmarco u_int8_t oem; 275fbca7c3fSmarco u_int8_t typelen; 276fbca7c3fSmarco u_int8_t name[1]; 277b6d6d087Smarco } __packed; 278fbca7c3fSmarco 279fbca7c3fSmarco /* SDR: Record Type 2 */ 280b6d6d087Smarco struct sdrtype2 { 281b6d6d087Smarco struct sdrhdr sdrhdr; 282fbca7c3fSmarco 283fbca7c3fSmarco u_int8_t owner_id; 284fbca7c3fSmarco u_int8_t owner_lun; 285fbca7c3fSmarco u_int8_t sensor_num; 286fbca7c3fSmarco 287fbca7c3fSmarco u_int8_t entity_id; 288fbca7c3fSmarco u_int8_t entity_instance; 289fbca7c3fSmarco u_int8_t sensor_init; 290fbca7c3fSmarco u_int8_t sensor_caps; 291fbca7c3fSmarco u_int8_t sensor_type; 292fbca7c3fSmarco u_int8_t event_code; 293fbca7c3fSmarco u_int16_t trigger_mask; 294fbca7c3fSmarco u_int16_t reading_mask; 295fbca7c3fSmarco u_int16_t set_mask; 296fbca7c3fSmarco u_int8_t units1; 297fbca7c3fSmarco u_int8_t units2; 298fbca7c3fSmarco u_int8_t units3; 299fbca7c3fSmarco u_int8_t share1; 300fbca7c3fSmarco u_int8_t share2; 301fbca7c3fSmarco u_int8_t physt; 302fbca7c3fSmarco u_int8_t nhyst; 303fbca7c3fSmarco u_int8_t resvd[3]; 304fbca7c3fSmarco u_int8_t oem; 305fbca7c3fSmarco u_int8_t typelen; 306fbca7c3fSmarco u_int8_t name[1]; 307b6d6d087Smarco } __packed; 308fbca7c3fSmarco 309fbca7c3fSmarco #endif /* _IPMIVAR_H_ */ 310