1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2015 - 2020 Intel Corporation */
8 #define IRDMA_HMC_MAX_BP_COUNT 512
9 #define IRDMA_MAX_SD_ENTRIES 11
10 #define IRDMA_HW_DBG_HMC_INVALID_BP_MARK 0xca
11 #define IRDMA_HMC_INFO_SIGNATURE 0x484d5347
12 #define IRDMA_HMC_PD_CNT_IN_SD 512
13 #define IRDMA_HMC_DIRECT_BP_SIZE 0x200000
14 #define IRDMA_HMC_MAX_SD_COUNT 8192
15 #define IRDMA_HMC_PAGED_BP_SIZE 4096
16 #define IRDMA_HMC_PD_BP_BUF_ALIGNMENT 4096
17 #define IRDMA_FIRST_VF_FPM_ID 8
18 #define FPM_MULTIPLIER 1024
20 enum irdma_hmc_rsrc_type
{
23 IRDMA_HMC_IW_RESERVED
= 2,
26 IRDMA_HMC_IW_APBVT_ENTRY
= 5,
29 IRDMA_HMC_IW_XFFL
= 8,
31 IRDMA_HMC_IW_Q1FL
= 10,
32 IRDMA_HMC_IW_TIMER
= 11,
33 IRDMA_HMC_IW_FSIMC
= 12,
34 IRDMA_HMC_IW_FSIAV
= 13,
35 IRDMA_HMC_IW_PBLE
= 14,
36 IRDMA_HMC_IW_RRF
= 15,
37 IRDMA_HMC_IW_RRFFL
= 16,
38 IRDMA_HMC_IW_HDR
= 17,
40 IRDMA_HMC_IW_OOISC
= 19,
41 IRDMA_HMC_IW_OOISCFFL
= 20,
42 IRDMA_HMC_IW_MAX
, /* Must be last entry */
45 enum irdma_sd_entry_type
{
46 IRDMA_SD_TYPE_INVALID
= 0,
47 IRDMA_SD_TYPE_PAGED
= 1,
48 IRDMA_SD_TYPE_DIRECT
= 2,
51 struct irdma_hmc_obj_info
{
59 enum irdma_sd_entry_type entry_type
;
60 struct irdma_dma_mem addr
;
65 struct irdma_hmc_pd_entry
{
66 struct irdma_hmc_bp bp
;
72 struct irdma_hmc_pd_table
{
73 struct irdma_dma_mem pd_page_addr
;
74 struct irdma_hmc_pd_entry
*pd_entry
;
75 struct irdma_virt_mem pd_entry_virt_mem
;
80 struct irdma_hmc_sd_entry
{
81 enum irdma_sd_entry_type entry_type
;
84 struct irdma_hmc_pd_table pd_table
;
85 struct irdma_hmc_bp bp
;
89 struct irdma_hmc_sd_table
{
90 struct irdma_virt_mem addr
;
93 struct irdma_hmc_sd_entry
*sd_entry
;
96 struct irdma_hmc_info
{
100 struct irdma_hmc_obj_info
*hmc_obj
;
101 struct irdma_virt_mem hmc_obj_virt_mem
;
102 struct irdma_hmc_sd_table sd_table
;
103 u16 sd_indexes
[IRDMA_HMC_MAX_SD_COUNT
];
106 struct irdma_update_sd_entry
{
111 struct irdma_update_sds_info
{
114 struct irdma_update_sd_entry entry
[IRDMA_MAX_SD_ENTRIES
];
117 struct irdma_ccq_cqe_info
;
118 struct irdma_hmc_fcn_info
{
123 struct irdma_hmc_create_obj_info
{
124 struct irdma_hmc_info
*hmc_info
;
125 struct irdma_virt_mem add_sd_virt_mem
;
130 enum irdma_sd_entry_type entry_type
;
134 struct irdma_hmc_del_obj_info
{
135 struct irdma_hmc_info
*hmc_info
;
136 struct irdma_virt_mem del_sd_virt_mem
;
144 int irdma_copy_dma_mem(struct irdma_hw
*hw
, void *dest_buf
,
145 struct irdma_dma_mem
*src_mem
, u64 src_offset
, u64 size
);
146 int irdma_sc_create_hmc_obj(struct irdma_sc_dev
*dev
,
147 struct irdma_hmc_create_obj_info
*info
);
148 int irdma_sc_del_hmc_obj(struct irdma_sc_dev
*dev
,
149 struct irdma_hmc_del_obj_info
*info
, bool reset
);
150 int irdma_hmc_sd_one(struct irdma_sc_dev
*dev
, u8 hmc_fn_id
, u64 pa
, u32 sd_idx
,
151 enum irdma_sd_entry_type type
,
153 int irdma_update_sds_noccq(struct irdma_sc_dev
*dev
,
154 struct irdma_update_sds_info
*info
);
155 struct irdma_vfdev
*irdma_vfdev_from_fpm(struct irdma_sc_dev
*dev
,
157 struct irdma_hmc_info
*irdma_vf_hmcinfo_from_fpm(struct irdma_sc_dev
*dev
,
159 int irdma_add_sd_table_entry(struct irdma_hw
*hw
,
160 struct irdma_hmc_info
*hmc_info
, u32 sd_index
,
161 enum irdma_sd_entry_type type
, u64 direct_mode_sz
);
162 int irdma_add_pd_table_entry(struct irdma_sc_dev
*dev
,
163 struct irdma_hmc_info
*hmc_info
, u32 pd_index
,
164 struct irdma_dma_mem
*rsrc_pg
);
165 int irdma_remove_pd_bp(struct irdma_sc_dev
*dev
,
166 struct irdma_hmc_info
*hmc_info
, u32 idx
);
167 int irdma_prep_remove_sd_bp(struct irdma_hmc_info
*hmc_info
, u32 idx
);
168 int irdma_prep_remove_pd_page(struct irdma_hmc_info
*hmc_info
, u32 idx
);
169 #endif /* IRDMA_HMC_H */