Loading...
Note: File does not exist in v6.13.7.
1/*******************************************************************************
2 *
3 * Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
4 * Copyright(c) 2013 Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
17 *
18 * Contact Information:
19 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
20 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
21 *
22 ******************************************************************************/
23
24#ifndef _I40E_HMC_H_
25#define _I40E_HMC_H_
26
27#define I40E_HMC_MAX_BP_COUNT 512
28
29/* forward-declare the HW struct for the compiler */
30struct i40e_hw;
31
32#define I40E_HMC_INFO_SIGNATURE 0x484D5347 /* HMSG */
33#define I40E_HMC_PD_CNT_IN_SD 512
34#define I40E_HMC_DIRECT_BP_SIZE 0x200000 /* 2M */
35#define I40E_HMC_PAGED_BP_SIZE 4096
36#define I40E_HMC_PD_BP_BUF_ALIGNMENT 4096
37#define I40E_FIRST_VF_FPM_ID 16
38
39struct i40e_hmc_obj_info {
40 u64 base; /* base addr in FPM */
41 u32 max_cnt; /* max count available for this hmc func */
42 u32 cnt; /* count of objects driver actually wants to create */
43 u64 size; /* size in bytes of one object */
44};
45
46enum i40e_sd_entry_type {
47 I40E_SD_TYPE_INVALID = 0,
48 I40E_SD_TYPE_PAGED = 1,
49 I40E_SD_TYPE_DIRECT = 2
50};
51
52struct i40e_hmc_bp {
53 enum i40e_sd_entry_type entry_type;
54 struct i40e_dma_mem addr; /* populate to be used by hw */
55 u32 sd_pd_index;
56 u32 ref_cnt;
57};
58
59struct i40e_hmc_pd_entry {
60 struct i40e_hmc_bp bp;
61 u32 sd_index;
62 bool valid;
63};
64
65struct i40e_hmc_pd_table {
66 struct i40e_dma_mem pd_page_addr; /* populate to be used by hw */
67 struct i40e_hmc_pd_entry *pd_entry; /* [512] for sw book keeping */
68 struct i40e_virt_mem pd_entry_virt_mem; /* virt mem for pd_entry */
69
70 u32 ref_cnt;
71 u32 sd_index;
72};
73
74struct i40e_hmc_sd_entry {
75 enum i40e_sd_entry_type entry_type;
76 bool valid;
77
78 union {
79 struct i40e_hmc_pd_table pd_table;
80 struct i40e_hmc_bp bp;
81 } u;
82};
83
84struct i40e_hmc_sd_table {
85 struct i40e_virt_mem addr; /* used to track sd_entry allocations */
86 u32 sd_cnt;
87 u32 ref_cnt;
88 struct i40e_hmc_sd_entry *sd_entry; /* (sd_cnt*512) entries max */
89};
90
91struct i40e_hmc_info {
92 u32 signature;
93 /* equals to pci func num for PF and dynamically allocated for VFs */
94 u8 hmc_fn_id;
95 u16 first_sd_index; /* index of the first available SD */
96
97 /* hmc objects */
98 struct i40e_hmc_obj_info *hmc_obj;
99 struct i40e_virt_mem hmc_obj_virt_mem;
100 struct i40e_hmc_sd_table sd_table;
101};
102
103#define I40E_INC_SD_REFCNT(sd_table) ((sd_table)->ref_cnt++)
104#define I40E_INC_PD_REFCNT(pd_table) ((pd_table)->ref_cnt++)
105#define I40E_INC_BP_REFCNT(bp) ((bp)->ref_cnt++)
106
107#define I40E_DEC_SD_REFCNT(sd_table) ((sd_table)->ref_cnt--)
108#define I40E_DEC_PD_REFCNT(pd_table) ((pd_table)->ref_cnt--)
109#define I40E_DEC_BP_REFCNT(bp) ((bp)->ref_cnt--)
110
111/**
112 * I40E_SET_PF_SD_ENTRY - marks the sd entry as valid in the hardware
113 * @hw: pointer to our hw struct
114 * @pa: pointer to physical address
115 * @sd_index: segment descriptor index
116 * @type: if sd entry is direct or paged
117 **/
118#define I40E_SET_PF_SD_ENTRY(hw, pa, sd_index, type) \
119{ \
120 u32 val1, val2, val3; \
121 val1 = (u32)(upper_32_bits(pa)); \
122 val2 = (u32)(pa) | (I40E_HMC_MAX_BP_COUNT << \
123 I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT) | \
124 ((((type) == I40E_SD_TYPE_PAGED) ? 0 : 1) << \
125 I40E_PFHMC_SDDATALOW_PMSDTYPE_SHIFT) | \
126 (1 << I40E_PFHMC_SDDATALOW_PMSDVALID_SHIFT); \
127 val3 = (sd_index) | (1 << I40E_PFHMC_SDCMD_PMSDWR_SHIFT); \
128 wr32((hw), I40E_PFHMC_SDDATAHIGH, val1); \
129 wr32((hw), I40E_PFHMC_SDDATALOW, val2); \
130 wr32((hw), I40E_PFHMC_SDCMD, val3); \
131}
132
133/**
134 * I40E_CLEAR_PF_SD_ENTRY - marks the sd entry as invalid in the hardware
135 * @hw: pointer to our hw struct
136 * @sd_index: segment descriptor index
137 * @type: if sd entry is direct or paged
138 **/
139#define I40E_CLEAR_PF_SD_ENTRY(hw, sd_index, type) \
140{ \
141 u32 val2, val3; \
142 val2 = (I40E_HMC_MAX_BP_COUNT << \
143 I40E_PFHMC_SDDATALOW_PMSDBPCOUNT_SHIFT) | \
144 ((((type) == I40E_SD_TYPE_PAGED) ? 0 : 1) << \
145 I40E_PFHMC_SDDATALOW_PMSDTYPE_SHIFT); \
146 val3 = (sd_index) | (1 << I40E_PFHMC_SDCMD_PMSDWR_SHIFT); \
147 wr32((hw), I40E_PFHMC_SDDATAHIGH, 0); \
148 wr32((hw), I40E_PFHMC_SDDATALOW, val2); \
149 wr32((hw), I40E_PFHMC_SDCMD, val3); \
150}
151
152/**
153 * I40E_INVALIDATE_PF_HMC_PD - Invalidates the pd cache in the hardware
154 * @hw: pointer to our hw struct
155 * @sd_idx: segment descriptor index
156 * @pd_idx: page descriptor index
157 **/
158#define I40E_INVALIDATE_PF_HMC_PD(hw, sd_idx, pd_idx) \
159 wr32((hw), I40E_PFHMC_PDINV, \
160 (((sd_idx) << I40E_PFHMC_PDINV_PMSDIDX_SHIFT) | \
161 ((pd_idx) << I40E_PFHMC_PDINV_PMPDIDX_SHIFT)))
162
163#define I40E_INVALIDATE_VF_HMC_PD(hw, sd_idx, pd_idx, hmc_fn_id) \
164 wr32((hw), I40E_GLHMC_VFPDINV((hmc_fn_id) - I40E_FIRST_VF_FPM_ID), \
165 (((sd_idx) << I40E_PFHMC_PDINV_PMSDIDX_SHIFT) | \
166 ((pd_idx) << I40E_PFHMC_PDINV_PMPDIDX_SHIFT)))
167
168/**
169 * I40E_FIND_SD_INDEX_LIMIT - finds segment descriptor index limit
170 * @hmc_info: pointer to the HMC configuration information structure
171 * @type: type of HMC resources we're searching
172 * @index: starting index for the object
173 * @cnt: number of objects we're trying to create
174 * @sd_idx: pointer to return index of the segment descriptor in question
175 * @sd_limit: pointer to return the maximum number of segment descriptors
176 *
177 * This function calculates the segment descriptor index and index limit
178 * for the resource defined by i40e_hmc_rsrc_type.
179 **/
180#define I40E_FIND_SD_INDEX_LIMIT(hmc_info, type, index, cnt, sd_idx, sd_limit)\
181{ \
182 u64 fpm_addr, fpm_limit; \
183 fpm_addr = (hmc_info)->hmc_obj[(type)].base + \
184 (hmc_info)->hmc_obj[(type)].size * (index); \
185 fpm_limit = fpm_addr + (hmc_info)->hmc_obj[(type)].size * (cnt);\
186 *(sd_idx) = (u32)(fpm_addr / I40E_HMC_DIRECT_BP_SIZE); \
187 *(sd_limit) = (u32)((fpm_limit - 1) / I40E_HMC_DIRECT_BP_SIZE); \
188 /* add one more to the limit to correct our range */ \
189 *(sd_limit) += 1; \
190}
191
192/**
193 * I40E_FIND_PD_INDEX_LIMIT - finds page descriptor index limit
194 * @hmc_info: pointer to the HMC configuration information struct
195 * @type: HMC resource type we're examining
196 * @idx: starting index for the object
197 * @cnt: number of objects we're trying to create
198 * @pd_index: pointer to return page descriptor index
199 * @pd_limit: pointer to return page descriptor index limit
200 *
201 * Calculates the page descriptor index and index limit for the resource
202 * defined by i40e_hmc_rsrc_type.
203 **/
204#define I40E_FIND_PD_INDEX_LIMIT(hmc_info, type, idx, cnt, pd_index, pd_limit)\
205{ \
206 u64 fpm_adr, fpm_limit; \
207 fpm_adr = (hmc_info)->hmc_obj[(type)].base + \
208 (hmc_info)->hmc_obj[(type)].size * (idx); \
209 fpm_limit = fpm_adr + (hmc_info)->hmc_obj[(type)].size * (cnt); \
210 *(pd_index) = (u32)(fpm_adr / I40E_HMC_PAGED_BP_SIZE); \
211 *(pd_limit) = (u32)((fpm_limit - 1) / I40E_HMC_PAGED_BP_SIZE); \
212 /* add one more to the limit to correct our range */ \
213 *(pd_limit) += 1; \
214}
215i40e_status i40e_add_sd_table_entry(struct i40e_hw *hw,
216 struct i40e_hmc_info *hmc_info,
217 u32 sd_index,
218 enum i40e_sd_entry_type type,
219 u64 direct_mode_sz);
220
221i40e_status i40e_add_pd_table_entry(struct i40e_hw *hw,
222 struct i40e_hmc_info *hmc_info,
223 u32 pd_index);
224i40e_status i40e_remove_pd_bp(struct i40e_hw *hw,
225 struct i40e_hmc_info *hmc_info,
226 u32 idx, bool is_pf);
227i40e_status i40e_prep_remove_sd_bp(struct i40e_hmc_info *hmc_info,
228 u32 idx);
229i40e_status i40e_remove_sd_bp_new(struct i40e_hw *hw,
230 struct i40e_hmc_info *hmc_info,
231 u32 idx, bool is_pf);
232i40e_status i40e_prep_remove_pd_page(struct i40e_hmc_info *hmc_info,
233 u32 idx);
234i40e_status i40e_remove_pd_page_new(struct i40e_hw *hw,
235 struct i40e_hmc_info *hmc_info,
236 u32 idx, bool is_pf);
237
238#endif /* _I40E_HMC_H_ */