1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright(c) 2024 Intel Corporation */
4 #ifndef ADF_MSTATE_MGR_H
5 #define ADF_MSTATE_MGR_H
7 #define ADF_MSTATE_ID_LEN 8
9 #define ADF_MSTATE_ETRB_IDS "ETRBAR"
10 #define ADF_MSTATE_MISCB_IDS "MISCBAR"
11 #define ADF_MSTATE_EXTB_IDS "EXTBAR"
12 #define ADF_MSTATE_GEN_IDS "GENER"
13 #define ADF_MSTATE_CONFIG_IDS "CONFIG"
14 #define ADF_MSTATE_SECTION_NUM 5
16 #define ADF_MSTATE_BANK_IDX_IDS "bnk"
18 #define ADF_MSTATE_ETR_REGS_IDS "mregs"
19 #define ADF_MSTATE_VINTSRC_IDS "visrc"
20 #define ADF_MSTATE_VINTMSK_IDS "vimsk"
21 #define ADF_MSTATE_SLA_IDS "sla"
22 #define ADF_MSTATE_IOV_INIT_IDS "iovinit"
23 #define ADF_MSTATE_COMPAT_VER_IDS "compver"
24 #define ADF_MSTATE_GEN_CAP_IDS "gencap"
25 #define ADF_MSTATE_GEN_SVCMAP_IDS "svcmap"
26 #define ADF_MSTATE_GEN_EXTDC_IDS "extdc"
27 #define ADF_MSTATE_VINTSRC_PF2VM_IDS "vispv"
28 #define ADF_MSTATE_VINTMSK_PF2VM_IDS "vimpv"
29 #define ADF_MSTATE_VM2PF_IDS "vm2pf"
30 #define ADF_MSTATE_PF2VM_IDS "pf2vm"
32 struct adf_mstate_mgr {
39 struct adf_mstate_preh {
47 struct adf_mstate_vreginfo {
52 struct adf_mstate_sect_h;
54 typedef int (*adf_mstate_preamble_checker)(struct adf_mstate_preh *preamble, void *opa);
55 typedef int (*adf_mstate_populate)(struct adf_mstate_mgr *sub_mgr, u8 *buf,
57 typedef int (*adf_mstate_action)(struct adf_mstate_mgr *sub_mgr, u8 *buf, u32 size,
60 struct adf_mstate_mgr *adf_mstate_mgr_new(u8 *buf, u32 size);
61 void adf_mstate_mgr_destroy(struct adf_mstate_mgr *mgr);
62 void adf_mstate_mgr_init(struct adf_mstate_mgr *mgr, u8 *buf, u32 size);
63 void adf_mstate_mgr_init_from_parent(struct adf_mstate_mgr *mgr,
64 struct adf_mstate_mgr *p_mgr);
65 void adf_mstate_mgr_init_from_psect(struct adf_mstate_mgr *mgr,
66 struct adf_mstate_sect_h *p_sect);
67 int adf_mstate_mgr_init_from_remote(struct adf_mstate_mgr *mgr,
69 adf_mstate_preamble_checker checker,
71 struct adf_mstate_preh *adf_mstate_preamble_add(struct adf_mstate_mgr *mgr);
72 int adf_mstate_preamble_update(struct adf_mstate_mgr *mgr);
73 u32 adf_mstate_state_size(struct adf_mstate_mgr *mgr);
74 u32 adf_mstate_state_size_from_remote(struct adf_mstate_mgr *mgr);
75 void adf_mstate_sect_update(struct adf_mstate_mgr *p_mgr,
76 struct adf_mstate_mgr *curr_mgr,
77 struct adf_mstate_sect_h *sect);
78 struct adf_mstate_sect_h *adf_mstate_sect_add_vreg(struct adf_mstate_mgr *mgr,
80 struct adf_mstate_vreginfo *info);
81 struct adf_mstate_sect_h *adf_mstate_sect_add(struct adf_mstate_mgr *mgr,
83 adf_mstate_populate populate,
85 struct adf_mstate_sect_h *adf_mstate_sect_lookup(struct adf_mstate_mgr *mgr,
87 adf_mstate_action action,