ipmi_si_sm.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  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 <[email protected]>
  12. * [email protected]
  13. *
  14. * Copyright 2002 MontaVista Software Inc.
  15. */
  16. #ifndef __IPMI_SI_SM_H__
  17. #define __IPMI_SI_SM_H__
  18. #include "ipmi_si.h"
  19. /*
  20. * This is defined by the state machines themselves, it is an opaque
  21. * data type for them to use.
  22. */
  23. struct si_sm_data;
  24. /* Results of SMI events. */
  25. enum si_sm_result {
  26. SI_SM_CALL_WITHOUT_DELAY, /* Call the driver again immediately */
  27. SI_SM_CALL_WITH_DELAY, /* Delay some before calling again. */
  28. SI_SM_CALL_WITH_TICK_DELAY,/* Delay >=1 tick before calling again. */
  29. SI_SM_TRANSACTION_COMPLETE, /* A transaction is finished. */
  30. SI_SM_IDLE, /* The SM is in idle state. */
  31. SI_SM_HOSED, /* The hardware violated the state machine. */
  32. /*
  33. * The hardware is asserting attn and the state machine is
  34. * idle.
  35. */
  36. SI_SM_ATTN
  37. };
  38. /* Handlers for the SMI state machine. */
  39. struct si_sm_handlers {
  40. /*
  41. * Put the version number of the state machine here so the
  42. * upper layer can print it.
  43. */
  44. char *version;
  45. /*
  46. * Initialize the data and return the amount of I/O space to
  47. * reserve for the space.
  48. */
  49. unsigned int (*init_data)(struct si_sm_data *smi,
  50. struct si_sm_io *io);
  51. /*
  52. * Start a new transaction in the state machine. This will
  53. * return -2 if the state machine is not idle, -1 if the size
  54. * is invalid (to large or too small), or 0 if the transaction
  55. * is successfully completed.
  56. */
  57. int (*start_transaction)(struct si_sm_data *smi,
  58. unsigned char *data, unsigned int size);
  59. /*
  60. * Return the results after the transaction. This will return
  61. * -1 if the buffer is too small, zero if no transaction is
  62. * present, or the actual length of the result data.
  63. */
  64. int (*get_result)(struct si_sm_data *smi,
  65. unsigned char *data, unsigned int length);
  66. /*
  67. * Call this periodically (for a polled interface) or upon
  68. * receiving an interrupt (for a interrupt-driven interface).
  69. * If interrupt driven, you should probably poll this
  70. * periodically when not in idle state. This should be called
  71. * with the time that passed since the last call, if it is
  72. * significant. Time is in microseconds.
  73. */
  74. enum si_sm_result (*event)(struct si_sm_data *smi, long time);
  75. /*
  76. * Attempt to detect an SMI. Returns 0 on success or nonzero
  77. * on failure.
  78. */
  79. int (*detect)(struct si_sm_data *smi);
  80. /* The interface is shutting down, so clean it up. */
  81. void (*cleanup)(struct si_sm_data *smi);
  82. /* Return the size of the SMI structure in bytes. */
  83. int (*size)(void);
  84. };
  85. /* Current state machines that we can use. */
  86. extern const struct si_sm_handlers kcs_smi_handlers;
  87. extern const struct si_sm_handlers smic_smi_handlers;
  88. extern const struct si_sm_handlers bt_smi_handlers;
  89. #endif /* __IPMI_SI_SM_H__ */