Corey Minyard | 243ac21 | 2018-02-20 07:30:22 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * ipmi_si_sm.h |
| 4 | * |
| 5 | * State machine interface for low-level IPMI system management |
| 6 | * interface state machines. This code is the interface between |
| 7 | * the ipmi_smi code (that handles the policy of a KCS, SMIC, or |
| 8 | * BT interface) and the actual low-level state machine. |
| 9 | * |
| 10 | * Author: MontaVista Software, Inc. |
| 11 | * Corey Minyard <minyard@mvista.com> |
| 12 | * source@mvista.com |
| 13 | * |
| 14 | * Copyright 2002 MontaVista Software Inc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Corey Minyard | 104fb25 | 2019-07-31 19:18:25 -0500 | [diff] [blame] | 17 | #ifndef __IPMI_SI_SM_H__ |
| 18 | #define __IPMI_SI_SM_H__ |
| 19 | |
| 20 | #include "ipmi_si.h" |
Corey Minyard | 910840f | 2017-09-12 14:41:56 -0500 | [diff] [blame] | 21 | |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 22 | /* |
| 23 | * This is defined by the state machines themselves, it is an opaque |
| 24 | * data type for them to use. |
| 25 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | struct si_sm_data; |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | /* Results of SMI events. */ |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 29 | enum si_sm_result { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */ |
| 31 | SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */ |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 32 | SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */ |
| 34 | SI_SM_IDLE, /* The SM is in idle state. */ |
| 35 | SI_SM_HOSED, /* The hardware violated the state machine. */ |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * The hardware is asserting attn and the state machine is |
| 39 | * idle. |
| 40 | */ |
| 41 | SI_SM_ATTN |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | /* Handlers for the SMI state machine. */ |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 45 | struct si_sm_handlers { |
| 46 | /* |
| 47 | * Put the version number of the state machine here so the |
| 48 | * upper layer can print it. |
| 49 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | char *version; |
| 51 | |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 52 | /* |
| 53 | * Initialize the data and return the amount of I/O space to |
| 54 | * reserve for the space. |
| 55 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | unsigned int (*init_data)(struct si_sm_data *smi, |
| 57 | struct si_sm_io *io); |
| 58 | |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 59 | /* |
| 60 | * Start a new transaction in the state machine. This will |
| 61 | * return -2 if the state machine is not idle, -1 if the size |
| 62 | * is invalid (to large or too small), or 0 if the transaction |
| 63 | * is successfully completed. |
| 64 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | int (*start_transaction)(struct si_sm_data *smi, |
| 66 | unsigned char *data, unsigned int size); |
| 67 | |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 68 | /* |
| 69 | * Return the results after the transaction. This will return |
| 70 | * -1 if the buffer is too small, zero if no transaction is |
| 71 | * present, or the actual length of the result data. |
| 72 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | int (*get_result)(struct si_sm_data *smi, |
| 74 | unsigned char *data, unsigned int length); |
| 75 | |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 76 | /* |
| 77 | * Call this periodically (for a polled interface) or upon |
| 78 | * receiving an interrupt (for a interrupt-driven interface). |
| 79 | * If interrupt driven, you should probably poll this |
| 80 | * periodically when not in idle state. This should be called |
| 81 | * with the time that passed since the last call, if it is |
| 82 | * significant. Time is in microseconds. |
| 83 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | enum si_sm_result (*event)(struct si_sm_data *smi, long time); |
| 85 | |
Corey Minyard | c305e3d | 2008-04-29 01:01:10 -0700 | [diff] [blame] | 86 | /* |
| 87 | * Attempt to detect an SMI. Returns 0 on success or nonzero |
| 88 | * on failure. |
| 89 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | int (*detect)(struct si_sm_data *smi); |
| 91 | |
| 92 | /* The interface is shutting down, so clean it up. */ |
| 93 | void (*cleanup)(struct si_sm_data *smi); |
| 94 | |
| 95 | /* Return the size of the SMI structure in bytes. */ |
| 96 | int (*size)(void); |
| 97 | }; |
| 98 | |
| 99 | /* Current state machines that we can use. */ |
Corey Minyard | 81d02b7 | 2015-06-13 10:34:25 -0500 | [diff] [blame] | 100 | extern const struct si_sm_handlers kcs_smi_handlers; |
| 101 | extern const struct si_sm_handlers smic_smi_handlers; |
| 102 | extern const struct si_sm_handlers bt_smi_handlers; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
Corey Minyard | 104fb25 | 2019-07-31 19:18:25 -0500 | [diff] [blame] | 104 | #endif /* __IPMI_SI_SM_H__ */ |