xref: /OK3568_Linux_fs/kernel/drivers/net/ethernet/intel/i40e/i40e_hmc.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /* Copyright(c) 2013 - 2018 Intel Corporation. */
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun #include "i40e.h"
5*4882a593Smuzhiyun #include "i40e_osdep.h"
6*4882a593Smuzhiyun #include "i40e_register.h"
7*4882a593Smuzhiyun #include "i40e_status.h"
8*4882a593Smuzhiyun #include "i40e_alloc.h"
9*4882a593Smuzhiyun #include "i40e_hmc.h"
10*4882a593Smuzhiyun #include "i40e_type.h"
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun /**
13*4882a593Smuzhiyun  * i40e_add_sd_table_entry - Adds a segment descriptor to the table
14*4882a593Smuzhiyun  * @hw: pointer to our hw struct
15*4882a593Smuzhiyun  * @hmc_info: pointer to the HMC configuration information struct
16*4882a593Smuzhiyun  * @sd_index: segment descriptor index to manipulate
17*4882a593Smuzhiyun  * @type: what type of segment descriptor we're manipulating
18*4882a593Smuzhiyun  * @direct_mode_sz: size to alloc in direct mode
19*4882a593Smuzhiyun  **/
i40e_add_sd_table_entry(struct i40e_hw * hw,struct i40e_hmc_info * hmc_info,u32 sd_index,enum i40e_sd_entry_type type,u64 direct_mode_sz)20*4882a593Smuzhiyun i40e_status i40e_add_sd_table_entry(struct i40e_hw *hw,
21*4882a593Smuzhiyun 					      struct i40e_hmc_info *hmc_info,
22*4882a593Smuzhiyun 					      u32 sd_index,
23*4882a593Smuzhiyun 					      enum i40e_sd_entry_type type,
24*4882a593Smuzhiyun 					      u64 direct_mode_sz)
25*4882a593Smuzhiyun {
26*4882a593Smuzhiyun 	enum i40e_memory_type mem_type __attribute__((unused));
27*4882a593Smuzhiyun 	struct i40e_hmc_sd_entry *sd_entry;
28*4882a593Smuzhiyun 	bool dma_mem_alloc_done = false;
29*4882a593Smuzhiyun 	struct i40e_dma_mem mem;
30*4882a593Smuzhiyun 	i40e_status ret_code = I40E_SUCCESS;
31*4882a593Smuzhiyun 	u64 alloc_len;
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun 	if (NULL == hmc_info->sd_table.sd_entry) {
34*4882a593Smuzhiyun 		ret_code = I40E_ERR_BAD_PTR;
35*4882a593Smuzhiyun 		hw_dbg(hw, "i40e_add_sd_table_entry: bad sd_entry\n");
36*4882a593Smuzhiyun 		goto exit;
37*4882a593Smuzhiyun 	}
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun 	if (sd_index >= hmc_info->sd_table.sd_cnt) {
40*4882a593Smuzhiyun 		ret_code = I40E_ERR_INVALID_SD_INDEX;
41*4882a593Smuzhiyun 		hw_dbg(hw, "i40e_add_sd_table_entry: bad sd_index\n");
42*4882a593Smuzhiyun 		goto exit;
43*4882a593Smuzhiyun 	}
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun 	sd_entry = &hmc_info->sd_table.sd_entry[sd_index];
46*4882a593Smuzhiyun 	if (!sd_entry->valid) {
47*4882a593Smuzhiyun 		if (I40E_SD_TYPE_PAGED == type) {
48*4882a593Smuzhiyun 			mem_type = i40e_mem_pd;
49*4882a593Smuzhiyun 			alloc_len = I40E_HMC_PAGED_BP_SIZE;
50*4882a593Smuzhiyun 		} else {
51*4882a593Smuzhiyun 			mem_type = i40e_mem_bp_jumbo;
52*4882a593Smuzhiyun 			alloc_len = direct_mode_sz;
53*4882a593Smuzhiyun 		}
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun 		/* allocate a 4K pd page or 2M backing page */
56*4882a593Smuzhiyun 		ret_code = i40e_allocate_dma_mem(hw, &mem, mem_type, alloc_len,
57*4882a593Smuzhiyun 						 I40E_HMC_PD_BP_BUF_ALIGNMENT);
58*4882a593Smuzhiyun 		if (ret_code)
59*4882a593Smuzhiyun 			goto exit;
60*4882a593Smuzhiyun 		dma_mem_alloc_done = true;
61*4882a593Smuzhiyun 		if (I40E_SD_TYPE_PAGED == type) {
62*4882a593Smuzhiyun 			ret_code = i40e_allocate_virt_mem(hw,
63*4882a593Smuzhiyun 					&sd_entry->u.pd_table.pd_entry_virt_mem,
64*4882a593Smuzhiyun 					sizeof(struct i40e_hmc_pd_entry) * 512);
65*4882a593Smuzhiyun 			if (ret_code)
66*4882a593Smuzhiyun 				goto exit;
67*4882a593Smuzhiyun 			sd_entry->u.pd_table.pd_entry =
68*4882a593Smuzhiyun 				(struct i40e_hmc_pd_entry *)
69*4882a593Smuzhiyun 				sd_entry->u.pd_table.pd_entry_virt_mem.va;
70*4882a593Smuzhiyun 			sd_entry->u.pd_table.pd_page_addr = mem;
71*4882a593Smuzhiyun 		} else {
72*4882a593Smuzhiyun 			sd_entry->u.bp.addr = mem;
73*4882a593Smuzhiyun 			sd_entry->u.bp.sd_pd_index = sd_index;
74*4882a593Smuzhiyun 		}
75*4882a593Smuzhiyun 		/* initialize the sd entry */
76*4882a593Smuzhiyun 		hmc_info->sd_table.sd_entry[sd_index].entry_type = type;
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun 		/* increment the ref count */
79*4882a593Smuzhiyun 		I40E_INC_SD_REFCNT(&hmc_info->sd_table);
80*4882a593Smuzhiyun 	}
81*4882a593Smuzhiyun 	/* Increment backing page reference count */
82*4882a593Smuzhiyun 	if (I40E_SD_TYPE_DIRECT == sd_entry->entry_type)
83*4882a593Smuzhiyun 		I40E_INC_BP_REFCNT(&sd_entry->u.bp);
84*4882a593Smuzhiyun exit:
85*4882a593Smuzhiyun 	if (ret_code)
86*4882a593Smuzhiyun 		if (dma_mem_alloc_done)
87*4882a593Smuzhiyun 			i40e_free_dma_mem(hw, &mem);
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun 	return ret_code;
90*4882a593Smuzhiyun }
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun /**
93*4882a593Smuzhiyun  * i40e_add_pd_table_entry - Adds page descriptor to the specified table
94*4882a593Smuzhiyun  * @hw: pointer to our HW structure
95*4882a593Smuzhiyun  * @hmc_info: pointer to the HMC configuration information structure
96*4882a593Smuzhiyun  * @pd_index: which page descriptor index to manipulate
97*4882a593Smuzhiyun  * @rsrc_pg: if not NULL, use preallocated page instead of allocating new one.
98*4882a593Smuzhiyun  *
99*4882a593Smuzhiyun  * This function:
100*4882a593Smuzhiyun  *	1. Initializes the pd entry
101*4882a593Smuzhiyun  *	2. Adds pd_entry in the pd_table
102*4882a593Smuzhiyun  *	3. Mark the entry valid in i40e_hmc_pd_entry structure
103*4882a593Smuzhiyun  *	4. Initializes the pd_entry's ref count to 1
104*4882a593Smuzhiyun  * assumptions:
105*4882a593Smuzhiyun  *	1. The memory for pd should be pinned down, physically contiguous and
106*4882a593Smuzhiyun  *	   aligned on 4K boundary and zeroed memory.
107*4882a593Smuzhiyun  *	2. It should be 4K in size.
108*4882a593Smuzhiyun  **/
i40e_add_pd_table_entry(struct i40e_hw * hw,struct i40e_hmc_info * hmc_info,u32 pd_index,struct i40e_dma_mem * rsrc_pg)109*4882a593Smuzhiyun i40e_status i40e_add_pd_table_entry(struct i40e_hw *hw,
110*4882a593Smuzhiyun 					      struct i40e_hmc_info *hmc_info,
111*4882a593Smuzhiyun 					      u32 pd_index,
112*4882a593Smuzhiyun 					      struct i40e_dma_mem *rsrc_pg)
113*4882a593Smuzhiyun {
114*4882a593Smuzhiyun 	i40e_status ret_code = 0;
115*4882a593Smuzhiyun 	struct i40e_hmc_pd_table *pd_table;
116*4882a593Smuzhiyun 	struct i40e_hmc_pd_entry *pd_entry;
117*4882a593Smuzhiyun 	struct i40e_dma_mem mem;
118*4882a593Smuzhiyun 	struct i40e_dma_mem *page = &mem;
119*4882a593Smuzhiyun 	u32 sd_idx, rel_pd_idx;
120*4882a593Smuzhiyun 	u64 *pd_addr;
121*4882a593Smuzhiyun 	u64 page_desc;
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun 	if (pd_index / I40E_HMC_PD_CNT_IN_SD >= hmc_info->sd_table.sd_cnt) {
124*4882a593Smuzhiyun 		ret_code = I40E_ERR_INVALID_PAGE_DESC_INDEX;
125*4882a593Smuzhiyun 		hw_dbg(hw, "i40e_add_pd_table_entry: bad pd_index\n");
126*4882a593Smuzhiyun 		goto exit;
127*4882a593Smuzhiyun 	}
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun 	/* find corresponding sd */
130*4882a593Smuzhiyun 	sd_idx = (pd_index / I40E_HMC_PD_CNT_IN_SD);
131*4882a593Smuzhiyun 	if (I40E_SD_TYPE_PAGED !=
132*4882a593Smuzhiyun 	    hmc_info->sd_table.sd_entry[sd_idx].entry_type)
133*4882a593Smuzhiyun 		goto exit;
134*4882a593Smuzhiyun 
135*4882a593Smuzhiyun 	rel_pd_idx = (pd_index % I40E_HMC_PD_CNT_IN_SD);
136*4882a593Smuzhiyun 	pd_table = &hmc_info->sd_table.sd_entry[sd_idx].u.pd_table;
137*4882a593Smuzhiyun 	pd_entry = &pd_table->pd_entry[rel_pd_idx];
138*4882a593Smuzhiyun 	if (!pd_entry->valid) {
139*4882a593Smuzhiyun 		if (rsrc_pg) {
140*4882a593Smuzhiyun 			pd_entry->rsrc_pg = true;
141*4882a593Smuzhiyun 			page = rsrc_pg;
142*4882a593Smuzhiyun 		} else {
143*4882a593Smuzhiyun 			/* allocate a 4K backing page */
144*4882a593Smuzhiyun 			ret_code = i40e_allocate_dma_mem(hw, page, i40e_mem_bp,
145*4882a593Smuzhiyun 						I40E_HMC_PAGED_BP_SIZE,
146*4882a593Smuzhiyun 						I40E_HMC_PD_BP_BUF_ALIGNMENT);
147*4882a593Smuzhiyun 			if (ret_code)
148*4882a593Smuzhiyun 				goto exit;
149*4882a593Smuzhiyun 			pd_entry->rsrc_pg = false;
150*4882a593Smuzhiyun 		}
151*4882a593Smuzhiyun 
152*4882a593Smuzhiyun 		pd_entry->bp.addr = *page;
153*4882a593Smuzhiyun 		pd_entry->bp.sd_pd_index = pd_index;
154*4882a593Smuzhiyun 		pd_entry->bp.entry_type = I40E_SD_TYPE_PAGED;
155*4882a593Smuzhiyun 		/* Set page address and valid bit */
156*4882a593Smuzhiyun 		page_desc = page->pa | 0x1;
157*4882a593Smuzhiyun 
158*4882a593Smuzhiyun 		pd_addr = (u64 *)pd_table->pd_page_addr.va;
159*4882a593Smuzhiyun 		pd_addr += rel_pd_idx;
160*4882a593Smuzhiyun 
161*4882a593Smuzhiyun 		/* Add the backing page physical address in the pd entry */
162*4882a593Smuzhiyun 		memcpy(pd_addr, &page_desc, sizeof(u64));
163*4882a593Smuzhiyun 
164*4882a593Smuzhiyun 		pd_entry->sd_index = sd_idx;
165*4882a593Smuzhiyun 		pd_entry->valid = true;
166*4882a593Smuzhiyun 		I40E_INC_PD_REFCNT(pd_table);
167*4882a593Smuzhiyun 	}
168*4882a593Smuzhiyun 	I40E_INC_BP_REFCNT(&pd_entry->bp);
169*4882a593Smuzhiyun exit:
170*4882a593Smuzhiyun 	return ret_code;
171*4882a593Smuzhiyun }
172*4882a593Smuzhiyun 
173*4882a593Smuzhiyun /**
174*4882a593Smuzhiyun  * i40e_remove_pd_bp - remove a backing page from a page descriptor
175*4882a593Smuzhiyun  * @hw: pointer to our HW structure
176*4882a593Smuzhiyun  * @hmc_info: pointer to the HMC configuration information structure
177*4882a593Smuzhiyun  * @idx: the page index
178*4882a593Smuzhiyun  *
179*4882a593Smuzhiyun  * This function:
180*4882a593Smuzhiyun  *	1. Marks the entry in pd tabe (for paged address mode) or in sd table
181*4882a593Smuzhiyun  *	   (for direct address mode) invalid.
182*4882a593Smuzhiyun  *	2. Write to register PMPDINV to invalidate the backing page in FV cache
183*4882a593Smuzhiyun  *	3. Decrement the ref count for the pd _entry
184*4882a593Smuzhiyun  * assumptions:
185*4882a593Smuzhiyun  *	1. Caller can deallocate the memory used by backing storage after this
186*4882a593Smuzhiyun  *	   function returns.
187*4882a593Smuzhiyun  **/
i40e_remove_pd_bp(struct i40e_hw * hw,struct i40e_hmc_info * hmc_info,u32 idx)188*4882a593Smuzhiyun i40e_status i40e_remove_pd_bp(struct i40e_hw *hw,
189*4882a593Smuzhiyun 					struct i40e_hmc_info *hmc_info,
190*4882a593Smuzhiyun 					u32 idx)
191*4882a593Smuzhiyun {
192*4882a593Smuzhiyun 	i40e_status ret_code = 0;
193*4882a593Smuzhiyun 	struct i40e_hmc_pd_entry *pd_entry;
194*4882a593Smuzhiyun 	struct i40e_hmc_pd_table *pd_table;
195*4882a593Smuzhiyun 	struct i40e_hmc_sd_entry *sd_entry;
196*4882a593Smuzhiyun 	u32 sd_idx, rel_pd_idx;
197*4882a593Smuzhiyun 	u64 *pd_addr;
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun 	/* calculate index */
200*4882a593Smuzhiyun 	sd_idx = idx / I40E_HMC_PD_CNT_IN_SD;
201*4882a593Smuzhiyun 	rel_pd_idx = idx % I40E_HMC_PD_CNT_IN_SD;
202*4882a593Smuzhiyun 	if (sd_idx >= hmc_info->sd_table.sd_cnt) {
203*4882a593Smuzhiyun 		ret_code = I40E_ERR_INVALID_PAGE_DESC_INDEX;
204*4882a593Smuzhiyun 		hw_dbg(hw, "i40e_remove_pd_bp: bad idx\n");
205*4882a593Smuzhiyun 		goto exit;
206*4882a593Smuzhiyun 	}
207*4882a593Smuzhiyun 	sd_entry = &hmc_info->sd_table.sd_entry[sd_idx];
208*4882a593Smuzhiyun 	if (I40E_SD_TYPE_PAGED != sd_entry->entry_type) {
209*4882a593Smuzhiyun 		ret_code = I40E_ERR_INVALID_SD_TYPE;
210*4882a593Smuzhiyun 		hw_dbg(hw, "i40e_remove_pd_bp: wrong sd_entry type\n");
211*4882a593Smuzhiyun 		goto exit;
212*4882a593Smuzhiyun 	}
213*4882a593Smuzhiyun 	/* get the entry and decrease its ref counter */
214*4882a593Smuzhiyun 	pd_table = &hmc_info->sd_table.sd_entry[sd_idx].u.pd_table;
215*4882a593Smuzhiyun 	pd_entry = &pd_table->pd_entry[rel_pd_idx];
216*4882a593Smuzhiyun 	I40E_DEC_BP_REFCNT(&pd_entry->bp);
217*4882a593Smuzhiyun 	if (pd_entry->bp.ref_cnt)
218*4882a593Smuzhiyun 		goto exit;
219*4882a593Smuzhiyun 
220*4882a593Smuzhiyun 	/* mark the entry invalid */
221*4882a593Smuzhiyun 	pd_entry->valid = false;
222*4882a593Smuzhiyun 	I40E_DEC_PD_REFCNT(pd_table);
223*4882a593Smuzhiyun 	pd_addr = (u64 *)pd_table->pd_page_addr.va;
224*4882a593Smuzhiyun 	pd_addr += rel_pd_idx;
225*4882a593Smuzhiyun 	memset(pd_addr, 0, sizeof(u64));
226*4882a593Smuzhiyun 	I40E_INVALIDATE_PF_HMC_PD(hw, sd_idx, idx);
227*4882a593Smuzhiyun 
228*4882a593Smuzhiyun 	/* free memory here */
229*4882a593Smuzhiyun 	if (!pd_entry->rsrc_pg)
230*4882a593Smuzhiyun 		ret_code = i40e_free_dma_mem(hw, &pd_entry->bp.addr);
231*4882a593Smuzhiyun 	if (ret_code)
232*4882a593Smuzhiyun 		goto exit;
233*4882a593Smuzhiyun 	if (!pd_table->ref_cnt)
234*4882a593Smuzhiyun 		i40e_free_virt_mem(hw, &pd_table->pd_entry_virt_mem);
235*4882a593Smuzhiyun exit:
236*4882a593Smuzhiyun 	return ret_code;
237*4882a593Smuzhiyun }
238*4882a593Smuzhiyun 
239*4882a593Smuzhiyun /**
240*4882a593Smuzhiyun  * i40e_prep_remove_sd_bp - Prepares to remove a backing page from a sd entry
241*4882a593Smuzhiyun  * @hmc_info: pointer to the HMC configuration information structure
242*4882a593Smuzhiyun  * @idx: the page index
243*4882a593Smuzhiyun  **/
i40e_prep_remove_sd_bp(struct i40e_hmc_info * hmc_info,u32 idx)244*4882a593Smuzhiyun i40e_status i40e_prep_remove_sd_bp(struct i40e_hmc_info *hmc_info,
245*4882a593Smuzhiyun 					     u32 idx)
246*4882a593Smuzhiyun {
247*4882a593Smuzhiyun 	i40e_status ret_code = 0;
248*4882a593Smuzhiyun 	struct i40e_hmc_sd_entry *sd_entry;
249*4882a593Smuzhiyun 
250*4882a593Smuzhiyun 	/* get the entry and decrease its ref counter */
251*4882a593Smuzhiyun 	sd_entry = &hmc_info->sd_table.sd_entry[idx];
252*4882a593Smuzhiyun 	I40E_DEC_BP_REFCNT(&sd_entry->u.bp);
253*4882a593Smuzhiyun 	if (sd_entry->u.bp.ref_cnt) {
254*4882a593Smuzhiyun 		ret_code = I40E_ERR_NOT_READY;
255*4882a593Smuzhiyun 		goto exit;
256*4882a593Smuzhiyun 	}
257*4882a593Smuzhiyun 	I40E_DEC_SD_REFCNT(&hmc_info->sd_table);
258*4882a593Smuzhiyun 
259*4882a593Smuzhiyun 	/* mark the entry invalid */
260*4882a593Smuzhiyun 	sd_entry->valid = false;
261*4882a593Smuzhiyun exit:
262*4882a593Smuzhiyun 	return ret_code;
263*4882a593Smuzhiyun }
264*4882a593Smuzhiyun 
265*4882a593Smuzhiyun /**
266*4882a593Smuzhiyun  * i40e_remove_sd_bp_new - Removes a backing page from a segment descriptor
267*4882a593Smuzhiyun  * @hw: pointer to our hw struct
268*4882a593Smuzhiyun  * @hmc_info: pointer to the HMC configuration information structure
269*4882a593Smuzhiyun  * @idx: the page index
270*4882a593Smuzhiyun  * @is_pf: used to distinguish between VF and PF
271*4882a593Smuzhiyun  **/
i40e_remove_sd_bp_new(struct i40e_hw * hw,struct i40e_hmc_info * hmc_info,u32 idx,bool is_pf)272*4882a593Smuzhiyun i40e_status i40e_remove_sd_bp_new(struct i40e_hw *hw,
273*4882a593Smuzhiyun 					    struct i40e_hmc_info *hmc_info,
274*4882a593Smuzhiyun 					    u32 idx, bool is_pf)
275*4882a593Smuzhiyun {
276*4882a593Smuzhiyun 	struct i40e_hmc_sd_entry *sd_entry;
277*4882a593Smuzhiyun 
278*4882a593Smuzhiyun 	if (!is_pf)
279*4882a593Smuzhiyun 		return I40E_NOT_SUPPORTED;
280*4882a593Smuzhiyun 
281*4882a593Smuzhiyun 	/* get the entry and decrease its ref counter */
282*4882a593Smuzhiyun 	sd_entry = &hmc_info->sd_table.sd_entry[idx];
283*4882a593Smuzhiyun 	I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_DIRECT);
284*4882a593Smuzhiyun 
285*4882a593Smuzhiyun 	return i40e_free_dma_mem(hw, &sd_entry->u.bp.addr);
286*4882a593Smuzhiyun }
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun /**
289*4882a593Smuzhiyun  * i40e_prep_remove_pd_page - Prepares to remove a PD page from sd entry.
290*4882a593Smuzhiyun  * @hmc_info: pointer to the HMC configuration information structure
291*4882a593Smuzhiyun  * @idx: segment descriptor index to find the relevant page descriptor
292*4882a593Smuzhiyun  **/
i40e_prep_remove_pd_page(struct i40e_hmc_info * hmc_info,u32 idx)293*4882a593Smuzhiyun i40e_status i40e_prep_remove_pd_page(struct i40e_hmc_info *hmc_info,
294*4882a593Smuzhiyun 					       u32 idx)
295*4882a593Smuzhiyun {
296*4882a593Smuzhiyun 	i40e_status ret_code = 0;
297*4882a593Smuzhiyun 	struct i40e_hmc_sd_entry *sd_entry;
298*4882a593Smuzhiyun 
299*4882a593Smuzhiyun 	sd_entry = &hmc_info->sd_table.sd_entry[idx];
300*4882a593Smuzhiyun 
301*4882a593Smuzhiyun 	if (sd_entry->u.pd_table.ref_cnt) {
302*4882a593Smuzhiyun 		ret_code = I40E_ERR_NOT_READY;
303*4882a593Smuzhiyun 		goto exit;
304*4882a593Smuzhiyun 	}
305*4882a593Smuzhiyun 
306*4882a593Smuzhiyun 	/* mark the entry invalid */
307*4882a593Smuzhiyun 	sd_entry->valid = false;
308*4882a593Smuzhiyun 
309*4882a593Smuzhiyun 	I40E_DEC_SD_REFCNT(&hmc_info->sd_table);
310*4882a593Smuzhiyun exit:
311*4882a593Smuzhiyun 	return ret_code;
312*4882a593Smuzhiyun }
313*4882a593Smuzhiyun 
314*4882a593Smuzhiyun /**
315*4882a593Smuzhiyun  * i40e_remove_pd_page_new - Removes a PD page from sd entry.
316*4882a593Smuzhiyun  * @hw: pointer to our hw struct
317*4882a593Smuzhiyun  * @hmc_info: pointer to the HMC configuration information structure
318*4882a593Smuzhiyun  * @idx: segment descriptor index to find the relevant page descriptor
319*4882a593Smuzhiyun  * @is_pf: used to distinguish between VF and PF
320*4882a593Smuzhiyun  **/
i40e_remove_pd_page_new(struct i40e_hw * hw,struct i40e_hmc_info * hmc_info,u32 idx,bool is_pf)321*4882a593Smuzhiyun i40e_status i40e_remove_pd_page_new(struct i40e_hw *hw,
322*4882a593Smuzhiyun 					      struct i40e_hmc_info *hmc_info,
323*4882a593Smuzhiyun 					      u32 idx, bool is_pf)
324*4882a593Smuzhiyun {
325*4882a593Smuzhiyun 	struct i40e_hmc_sd_entry *sd_entry;
326*4882a593Smuzhiyun 
327*4882a593Smuzhiyun 	if (!is_pf)
328*4882a593Smuzhiyun 		return I40E_NOT_SUPPORTED;
329*4882a593Smuzhiyun 
330*4882a593Smuzhiyun 	sd_entry = &hmc_info->sd_table.sd_entry[idx];
331*4882a593Smuzhiyun 	I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_PAGED);
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun 	return  i40e_free_dma_mem(hw, &sd_entry->u.pd_table.pd_page_addr);
334*4882a593Smuzhiyun }
335