cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

efc_sm.h (6694B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/*
      3 * Copyright (C) 2021 Broadcom. All Rights Reserved. The term
      4 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
      5 *
      6 */
      7
      8/**
      9 * Generic state machine framework declarations.
     10 */
     11
     12#ifndef _EFC_SM_H
     13#define _EFC_SM_H
     14
     15struct efc_sm_ctx;
     16
     17/* State Machine events */
     18enum efc_sm_event {
     19	/* Common Events */
     20	EFC_EVT_ENTER,
     21	EFC_EVT_REENTER,
     22	EFC_EVT_EXIT,
     23	EFC_EVT_SHUTDOWN,
     24	EFC_EVT_ALL_CHILD_NODES_FREE,
     25	EFC_EVT_RESUME,
     26	EFC_EVT_TIMER_EXPIRED,
     27
     28	/* Domain Events */
     29	EFC_EVT_RESPONSE,
     30	EFC_EVT_ERROR,
     31
     32	EFC_EVT_DOMAIN_FOUND,
     33	EFC_EVT_DOMAIN_ALLOC_OK,
     34	EFC_EVT_DOMAIN_ALLOC_FAIL,
     35	EFC_EVT_DOMAIN_REQ_ATTACH,
     36	EFC_EVT_DOMAIN_ATTACH_OK,
     37	EFC_EVT_DOMAIN_ATTACH_FAIL,
     38	EFC_EVT_DOMAIN_LOST,
     39	EFC_EVT_DOMAIN_FREE_OK,
     40	EFC_EVT_DOMAIN_FREE_FAIL,
     41	EFC_EVT_HW_DOMAIN_REQ_ATTACH,
     42	EFC_EVT_HW_DOMAIN_REQ_FREE,
     43
     44	/* Sport Events */
     45	EFC_EVT_NPORT_ALLOC_OK,
     46	EFC_EVT_NPORT_ALLOC_FAIL,
     47	EFC_EVT_NPORT_ATTACH_OK,
     48	EFC_EVT_NPORT_ATTACH_FAIL,
     49	EFC_EVT_NPORT_FREE_OK,
     50	EFC_EVT_NPORT_FREE_FAIL,
     51	EFC_EVT_NPORT_TOPOLOGY_NOTIFY,
     52	EFC_EVT_HW_PORT_ALLOC_OK,
     53	EFC_EVT_HW_PORT_ALLOC_FAIL,
     54	EFC_EVT_HW_PORT_ATTACH_OK,
     55	EFC_EVT_HW_PORT_REQ_ATTACH,
     56	EFC_EVT_HW_PORT_REQ_FREE,
     57	EFC_EVT_HW_PORT_FREE_OK,
     58
     59	/* Login Events */
     60	EFC_EVT_SRRS_ELS_REQ_OK,
     61	EFC_EVT_SRRS_ELS_CMPL_OK,
     62	EFC_EVT_SRRS_ELS_REQ_FAIL,
     63	EFC_EVT_SRRS_ELS_CMPL_FAIL,
     64	EFC_EVT_SRRS_ELS_REQ_RJT,
     65	EFC_EVT_NODE_ATTACH_OK,
     66	EFC_EVT_NODE_ATTACH_FAIL,
     67	EFC_EVT_NODE_FREE_OK,
     68	EFC_EVT_NODE_FREE_FAIL,
     69	EFC_EVT_ELS_FRAME,
     70	EFC_EVT_ELS_REQ_TIMEOUT,
     71	EFC_EVT_ELS_REQ_ABORTED,
     72	/* request an ELS IO be aborted */
     73	EFC_EVT_ABORT_ELS,
     74	/* ELS abort process complete */
     75	EFC_EVT_ELS_ABORT_CMPL,
     76
     77	EFC_EVT_ABTS_RCVD,
     78
     79	/* node is not in the GID_PT payload */
     80	EFC_EVT_NODE_MISSING,
     81	/* node is allocated and in the GID_PT payload */
     82	EFC_EVT_NODE_REFOUND,
     83	/* node shutting down due to PLOGI recvd (implicit logo) */
     84	EFC_EVT_SHUTDOWN_IMPLICIT_LOGO,
     85	/* node shutting down due to LOGO recvd/sent (explicit logo) */
     86	EFC_EVT_SHUTDOWN_EXPLICIT_LOGO,
     87
     88	EFC_EVT_PLOGI_RCVD,
     89	EFC_EVT_FLOGI_RCVD,
     90	EFC_EVT_LOGO_RCVD,
     91	EFC_EVT_PRLI_RCVD,
     92	EFC_EVT_PRLO_RCVD,
     93	EFC_EVT_PDISC_RCVD,
     94	EFC_EVT_FDISC_RCVD,
     95	EFC_EVT_ADISC_RCVD,
     96	EFC_EVT_RSCN_RCVD,
     97	EFC_EVT_SCR_RCVD,
     98	EFC_EVT_ELS_RCVD,
     99
    100	EFC_EVT_FCP_CMD_RCVD,
    101
    102	EFC_EVT_GIDPT_DELAY_EXPIRED,
    103
    104	/* SCSI Target Server events */
    105	EFC_EVT_NODE_ACTIVE_IO_LIST_EMPTY,
    106	EFC_EVT_NODE_DEL_INI_COMPLETE,
    107	EFC_EVT_NODE_DEL_TGT_COMPLETE,
    108	EFC_EVT_NODE_SESS_REG_OK,
    109	EFC_EVT_NODE_SESS_REG_FAIL,
    110
    111	/* Must be last */
    112	EFC_EVT_LAST
    113};
    114
    115/* State Machine event name lookup array */
    116#define EFC_SM_EVENT_NAME {						\
    117	[EFC_EVT_ENTER]			= "EFC_EVT_ENTER",		\
    118	[EFC_EVT_REENTER]		= "EFC_EVT_REENTER",		\
    119	[EFC_EVT_EXIT]			= "EFC_EVT_EXIT",		\
    120	[EFC_EVT_SHUTDOWN]		= "EFC_EVT_SHUTDOWN",		\
    121	[EFC_EVT_ALL_CHILD_NODES_FREE]	= "EFC_EVT_ALL_CHILD_NODES_FREE",\
    122	[EFC_EVT_RESUME]		= "EFC_EVT_RESUME",		\
    123	[EFC_EVT_TIMER_EXPIRED]		= "EFC_EVT_TIMER_EXPIRED",	\
    124	[EFC_EVT_RESPONSE]		= "EFC_EVT_RESPONSE",		\
    125	[EFC_EVT_ERROR]			= "EFC_EVT_ERROR",		\
    126	[EFC_EVT_DOMAIN_FOUND]		= "EFC_EVT_DOMAIN_FOUND",	\
    127	[EFC_EVT_DOMAIN_ALLOC_OK]	= "EFC_EVT_DOMAIN_ALLOC_OK",	\
    128	[EFC_EVT_DOMAIN_ALLOC_FAIL]	= "EFC_EVT_DOMAIN_ALLOC_FAIL",	\
    129	[EFC_EVT_DOMAIN_REQ_ATTACH]	= "EFC_EVT_DOMAIN_REQ_ATTACH",	\
    130	[EFC_EVT_DOMAIN_ATTACH_OK]	= "EFC_EVT_DOMAIN_ATTACH_OK",	\
    131	[EFC_EVT_DOMAIN_ATTACH_FAIL]	= "EFC_EVT_DOMAIN_ATTACH_FAIL",	\
    132	[EFC_EVT_DOMAIN_LOST]		= "EFC_EVT_DOMAIN_LOST",	\
    133	[EFC_EVT_DOMAIN_FREE_OK]	= "EFC_EVT_DOMAIN_FREE_OK",	\
    134	[EFC_EVT_DOMAIN_FREE_FAIL]	= "EFC_EVT_DOMAIN_FREE_FAIL",	\
    135	[EFC_EVT_HW_DOMAIN_REQ_ATTACH]	= "EFC_EVT_HW_DOMAIN_REQ_ATTACH",\
    136	[EFC_EVT_HW_DOMAIN_REQ_FREE]	= "EFC_EVT_HW_DOMAIN_REQ_FREE",	\
    137	[EFC_EVT_NPORT_ALLOC_OK]	= "EFC_EVT_NPORT_ALLOC_OK",	\
    138	[EFC_EVT_NPORT_ALLOC_FAIL]	= "EFC_EVT_NPORT_ALLOC_FAIL",	\
    139	[EFC_EVT_NPORT_ATTACH_OK]	= "EFC_EVT_NPORT_ATTACH_OK",	\
    140	[EFC_EVT_NPORT_ATTACH_FAIL]	= "EFC_EVT_NPORT_ATTACH_FAIL",	\
    141	[EFC_EVT_NPORT_FREE_OK]		= "EFC_EVT_NPORT_FREE_OK",	\
    142	[EFC_EVT_NPORT_FREE_FAIL]	= "EFC_EVT_NPORT_FREE_FAIL",	\
    143	[EFC_EVT_NPORT_TOPOLOGY_NOTIFY]	= "EFC_EVT_NPORT_TOPOLOGY_NOTIFY",\
    144	[EFC_EVT_HW_PORT_ALLOC_OK]	= "EFC_EVT_HW_PORT_ALLOC_OK",	\
    145	[EFC_EVT_HW_PORT_ALLOC_FAIL]	= "EFC_EVT_HW_PORT_ALLOC_FAIL",	\
    146	[EFC_EVT_HW_PORT_ATTACH_OK]	= "EFC_EVT_HW_PORT_ATTACH_OK",	\
    147	[EFC_EVT_HW_PORT_REQ_ATTACH]	= "EFC_EVT_HW_PORT_REQ_ATTACH",	\
    148	[EFC_EVT_HW_PORT_REQ_FREE]	= "EFC_EVT_HW_PORT_REQ_FREE",	\
    149	[EFC_EVT_HW_PORT_FREE_OK]	= "EFC_EVT_HW_PORT_FREE_OK",	\
    150	[EFC_EVT_SRRS_ELS_REQ_OK]	= "EFC_EVT_SRRS_ELS_REQ_OK",	\
    151	[EFC_EVT_SRRS_ELS_CMPL_OK]	= "EFC_EVT_SRRS_ELS_CMPL_OK",	\
    152	[EFC_EVT_SRRS_ELS_REQ_FAIL]	= "EFC_EVT_SRRS_ELS_REQ_FAIL",	\
    153	[EFC_EVT_SRRS_ELS_CMPL_FAIL]	= "EFC_EVT_SRRS_ELS_CMPL_FAIL",	\
    154	[EFC_EVT_SRRS_ELS_REQ_RJT]	= "EFC_EVT_SRRS_ELS_REQ_RJT",	\
    155	[EFC_EVT_NODE_ATTACH_OK]	= "EFC_EVT_NODE_ATTACH_OK",	\
    156	[EFC_EVT_NODE_ATTACH_FAIL]	= "EFC_EVT_NODE_ATTACH_FAIL",	\
    157	[EFC_EVT_NODE_FREE_OK]		= "EFC_EVT_NODE_FREE_OK",	\
    158	[EFC_EVT_NODE_FREE_FAIL]	= "EFC_EVT_NODE_FREE_FAIL",	\
    159	[EFC_EVT_ELS_FRAME]		= "EFC_EVT_ELS_FRAME",		\
    160	[EFC_EVT_ELS_REQ_TIMEOUT]	= "EFC_EVT_ELS_REQ_TIMEOUT",	\
    161	[EFC_EVT_ELS_REQ_ABORTED]	= "EFC_EVT_ELS_REQ_ABORTED",	\
    162	[EFC_EVT_ABORT_ELS]		= "EFC_EVT_ABORT_ELS",		\
    163	[EFC_EVT_ELS_ABORT_CMPL]	= "EFC_EVT_ELS_ABORT_CMPL",	\
    164	[EFC_EVT_ABTS_RCVD]		= "EFC_EVT_ABTS_RCVD",		\
    165	[EFC_EVT_NODE_MISSING]		= "EFC_EVT_NODE_MISSING",	\
    166	[EFC_EVT_NODE_REFOUND]		= "EFC_EVT_NODE_REFOUND",	\
    167	[EFC_EVT_SHUTDOWN_IMPLICIT_LOGO] = "EFC_EVT_SHUTDOWN_IMPLICIT_LOGO",\
    168	[EFC_EVT_SHUTDOWN_EXPLICIT_LOGO] = "EFC_EVT_SHUTDOWN_EXPLICIT_LOGO",\
    169	[EFC_EVT_PLOGI_RCVD]		= "EFC_EVT_PLOGI_RCVD",		\
    170	[EFC_EVT_FLOGI_RCVD]		= "EFC_EVT_FLOGI_RCVD",		\
    171	[EFC_EVT_LOGO_RCVD]		= "EFC_EVT_LOGO_RCVD",		\
    172	[EFC_EVT_PRLI_RCVD]		= "EFC_EVT_PRLI_RCVD",		\
    173	[EFC_EVT_PRLO_RCVD]		= "EFC_EVT_PRLO_RCVD",		\
    174	[EFC_EVT_PDISC_RCVD]		= "EFC_EVT_PDISC_RCVD",		\
    175	[EFC_EVT_FDISC_RCVD]		= "EFC_EVT_FDISC_RCVD",		\
    176	[EFC_EVT_ADISC_RCVD]		= "EFC_EVT_ADISC_RCVD",		\
    177	[EFC_EVT_RSCN_RCVD]		= "EFC_EVT_RSCN_RCVD",		\
    178	[EFC_EVT_SCR_RCVD]		= "EFC_EVT_SCR_RCVD",		\
    179	[EFC_EVT_ELS_RCVD]		= "EFC_EVT_ELS_RCVD",		\
    180	[EFC_EVT_FCP_CMD_RCVD]		= "EFC_EVT_FCP_CMD_RCVD",	\
    181	[EFC_EVT_NODE_DEL_INI_COMPLETE]	= "EFC_EVT_NODE_DEL_INI_COMPLETE",\
    182	[EFC_EVT_NODE_DEL_TGT_COMPLETE]	= "EFC_EVT_NODE_DEL_TGT_COMPLETE",\
    183	[EFC_EVT_LAST]			= "EFC_EVT_LAST",		\
    184}
    185
    186int
    187efc_sm_post_event(struct efc_sm_ctx *ctx,
    188		  enum efc_sm_event evt, void *data);
    189void
    190efc_sm_transition(struct efc_sm_ctx *ctx,
    191		  void (*state)(struct efc_sm_ctx *ctx,
    192				enum efc_sm_event evt, void *arg),
    193		  void *data);
    194void efc_sm_disable(struct efc_sm_ctx *ctx);
    195const char *efc_sm_event_name(enum efc_sm_event evt);
    196
    197#endif /* ! _EFC_SM_H */