1ae06c70bSJeff Kirsher // SPDX-License-Identifier: GPL-2.0
251dce24bSJeff Kirsher /* Copyright(c) 2013 - 2018 Intel Corporation. */
356a62fc8SJesse Brandeburg
456a62fc8SJesse Brandeburg #include "i40e_alloc.h"
5*56df3459SIvan Vecera #include "i40e_debug.h"
656a62fc8SJesse Brandeburg #include "i40e_hmc.h"
756a62fc8SJesse Brandeburg #include "i40e_type.h"
856a62fc8SJesse Brandeburg
956a62fc8SJesse Brandeburg /**
1056a62fc8SJesse Brandeburg * i40e_add_sd_table_entry - Adds a segment descriptor to the table
1156a62fc8SJesse Brandeburg * @hw: pointer to our hw struct
1256a62fc8SJesse Brandeburg * @hmc_info: pointer to the HMC configuration information struct
1356a62fc8SJesse Brandeburg * @sd_index: segment descriptor index to manipulate
1456a62fc8SJesse Brandeburg * @type: what type of segment descriptor we're manipulating
1556a62fc8SJesse Brandeburg * @direct_mode_sz: size to alloc in direct mode
1656a62fc8SJesse Brandeburg **/
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)175180ff13SJan Sokolowski int i40e_add_sd_table_entry(struct i40e_hw *hw,
1856a62fc8SJesse Brandeburg struct i40e_hmc_info *hmc_info,
1956a62fc8SJesse Brandeburg u32 sd_index,
2056a62fc8SJesse Brandeburg enum i40e_sd_entry_type type,
2156a62fc8SJesse Brandeburg u64 direct_mode_sz)
2256a62fc8SJesse Brandeburg {
2356a62fc8SJesse Brandeburg struct i40e_hmc_sd_entry *sd_entry;
2456a62fc8SJesse Brandeburg bool dma_mem_alloc_done = false;
2556a62fc8SJesse Brandeburg struct i40e_dma_mem mem;
26230f3d53SJan Sokolowski int ret_code = 0;
2756a62fc8SJesse Brandeburg u64 alloc_len;
2856a62fc8SJesse Brandeburg
2956a62fc8SJesse Brandeburg if (NULL == hmc_info->sd_table.sd_entry) {
30230f3d53SJan Sokolowski ret_code = -EINVAL;
3156a62fc8SJesse Brandeburg hw_dbg(hw, "i40e_add_sd_table_entry: bad sd_entry\n");
3256a62fc8SJesse Brandeburg goto exit;
3356a62fc8SJesse Brandeburg }
3456a62fc8SJesse Brandeburg
3556a62fc8SJesse Brandeburg if (sd_index >= hmc_info->sd_table.sd_cnt) {
36230f3d53SJan Sokolowski ret_code = -EINVAL;
3756a62fc8SJesse Brandeburg hw_dbg(hw, "i40e_add_sd_table_entry: bad sd_index\n");
3856a62fc8SJesse Brandeburg goto exit;
3956a62fc8SJesse Brandeburg }
4056a62fc8SJesse Brandeburg
4156a62fc8SJesse Brandeburg sd_entry = &hmc_info->sd_table.sd_entry[sd_index];
4256a62fc8SJesse Brandeburg if (!sd_entry->valid) {
43d3276f92SIvan Vecera if (type == I40E_SD_TYPE_PAGED)
4456a62fc8SJesse Brandeburg alloc_len = I40E_HMC_PAGED_BP_SIZE;
45d3276f92SIvan Vecera else
4656a62fc8SJesse Brandeburg alloc_len = direct_mode_sz;
4756a62fc8SJesse Brandeburg
4856a62fc8SJesse Brandeburg /* allocate a 4K pd page or 2M backing page */
49d3276f92SIvan Vecera ret_code = i40e_allocate_dma_mem(hw, &mem, alloc_len,
5056a62fc8SJesse Brandeburg I40E_HMC_PD_BP_BUF_ALIGNMENT);
5156a62fc8SJesse Brandeburg if (ret_code)
5256a62fc8SJesse Brandeburg goto exit;
5356a62fc8SJesse Brandeburg dma_mem_alloc_done = true;
5456a62fc8SJesse Brandeburg if (I40E_SD_TYPE_PAGED == type) {
5556a62fc8SJesse Brandeburg ret_code = i40e_allocate_virt_mem(hw,
5656a62fc8SJesse Brandeburg &sd_entry->u.pd_table.pd_entry_virt_mem,
5756a62fc8SJesse Brandeburg sizeof(struct i40e_hmc_pd_entry) * 512);
5856a62fc8SJesse Brandeburg if (ret_code)
5956a62fc8SJesse Brandeburg goto exit;
6056a62fc8SJesse Brandeburg sd_entry->u.pd_table.pd_entry =
6156a62fc8SJesse Brandeburg (struct i40e_hmc_pd_entry *)
6256a62fc8SJesse Brandeburg sd_entry->u.pd_table.pd_entry_virt_mem.va;
63c36bd4a7SMitch Williams sd_entry->u.pd_table.pd_page_addr = mem;
6456a62fc8SJesse Brandeburg } else {
65c36bd4a7SMitch Williams sd_entry->u.bp.addr = mem;
6656a62fc8SJesse Brandeburg sd_entry->u.bp.sd_pd_index = sd_index;
6756a62fc8SJesse Brandeburg }
6856a62fc8SJesse Brandeburg /* initialize the sd entry */
6956a62fc8SJesse Brandeburg hmc_info->sd_table.sd_entry[sd_index].entry_type = type;
7056a62fc8SJesse Brandeburg
7156a62fc8SJesse Brandeburg /* increment the ref count */
7256a62fc8SJesse Brandeburg I40E_INC_SD_REFCNT(&hmc_info->sd_table);
7356a62fc8SJesse Brandeburg }
7456a62fc8SJesse Brandeburg /* Increment backing page reference count */
7556a62fc8SJesse Brandeburg if (I40E_SD_TYPE_DIRECT == sd_entry->entry_type)
7656a62fc8SJesse Brandeburg I40E_INC_BP_REFCNT(&sd_entry->u.bp);
7756a62fc8SJesse Brandeburg exit:
7856a62fc8SJesse Brandeburg if (ret_code)
7956a62fc8SJesse Brandeburg if (dma_mem_alloc_done)
8056a62fc8SJesse Brandeburg i40e_free_dma_mem(hw, &mem);
8156a62fc8SJesse Brandeburg
8256a62fc8SJesse Brandeburg return ret_code;
8356a62fc8SJesse Brandeburg }
8456a62fc8SJesse Brandeburg
8556a62fc8SJesse Brandeburg /**
8656a62fc8SJesse Brandeburg * i40e_add_pd_table_entry - Adds page descriptor to the specified table
8756a62fc8SJesse Brandeburg * @hw: pointer to our HW structure
8856a62fc8SJesse Brandeburg * @hmc_info: pointer to the HMC configuration information structure
8956a62fc8SJesse Brandeburg * @pd_index: which page descriptor index to manipulate
903bbf0faaSFaisal Latif * @rsrc_pg: if not NULL, use preallocated page instead of allocating new one.
9156a62fc8SJesse Brandeburg *
9256a62fc8SJesse Brandeburg * This function:
9356a62fc8SJesse Brandeburg * 1. Initializes the pd entry
9456a62fc8SJesse Brandeburg * 2. Adds pd_entry in the pd_table
9556a62fc8SJesse Brandeburg * 3. Mark the entry valid in i40e_hmc_pd_entry structure
9656a62fc8SJesse Brandeburg * 4. Initializes the pd_entry's ref count to 1
9756a62fc8SJesse Brandeburg * assumptions:
9856a62fc8SJesse Brandeburg * 1. The memory for pd should be pinned down, physically contiguous and
9956a62fc8SJesse Brandeburg * aligned on 4K boundary and zeroed memory.
10056a62fc8SJesse Brandeburg * 2. It should be 4K in size.
10156a62fc8SJesse Brandeburg **/
i40e_add_pd_table_entry(struct i40e_hw * hw,struct i40e_hmc_info * hmc_info,u32 pd_index,struct i40e_dma_mem * rsrc_pg)1025180ff13SJan Sokolowski int i40e_add_pd_table_entry(struct i40e_hw *hw,
10356a62fc8SJesse Brandeburg struct i40e_hmc_info *hmc_info,
1043bbf0faaSFaisal Latif u32 pd_index,
1053bbf0faaSFaisal Latif struct i40e_dma_mem *rsrc_pg)
10656a62fc8SJesse Brandeburg {
10756a62fc8SJesse Brandeburg struct i40e_hmc_pd_table *pd_table;
10856a62fc8SJesse Brandeburg struct i40e_hmc_pd_entry *pd_entry;
10956a62fc8SJesse Brandeburg struct i40e_dma_mem mem;
1103bbf0faaSFaisal Latif struct i40e_dma_mem *page = &mem;
11156a62fc8SJesse Brandeburg u32 sd_idx, rel_pd_idx;
1125180ff13SJan Sokolowski int ret_code = 0;
11356a62fc8SJesse Brandeburg u64 page_desc;
1145180ff13SJan Sokolowski u64 *pd_addr;
11556a62fc8SJesse Brandeburg
11656a62fc8SJesse Brandeburg if (pd_index / I40E_HMC_PD_CNT_IN_SD >= hmc_info->sd_table.sd_cnt) {
117230f3d53SJan Sokolowski ret_code = -EINVAL;
11856a62fc8SJesse Brandeburg hw_dbg(hw, "i40e_add_pd_table_entry: bad pd_index\n");
11956a62fc8SJesse Brandeburg goto exit;
12056a62fc8SJesse Brandeburg }
12156a62fc8SJesse Brandeburg
12256a62fc8SJesse Brandeburg /* find corresponding sd */
12356a62fc8SJesse Brandeburg sd_idx = (pd_index / I40E_HMC_PD_CNT_IN_SD);
12456a62fc8SJesse Brandeburg if (I40E_SD_TYPE_PAGED !=
12556a62fc8SJesse Brandeburg hmc_info->sd_table.sd_entry[sd_idx].entry_type)
12656a62fc8SJesse Brandeburg goto exit;
12756a62fc8SJesse Brandeburg
12856a62fc8SJesse Brandeburg rel_pd_idx = (pd_index % I40E_HMC_PD_CNT_IN_SD);
12956a62fc8SJesse Brandeburg pd_table = &hmc_info->sd_table.sd_entry[sd_idx].u.pd_table;
13056a62fc8SJesse Brandeburg pd_entry = &pd_table->pd_entry[rel_pd_idx];
13156a62fc8SJesse Brandeburg if (!pd_entry->valid) {
1323bbf0faaSFaisal Latif if (rsrc_pg) {
1333bbf0faaSFaisal Latif pd_entry->rsrc_pg = true;
1343bbf0faaSFaisal Latif page = rsrc_pg;
1353bbf0faaSFaisal Latif } else {
13656a62fc8SJesse Brandeburg /* allocate a 4K backing page */
137d3276f92SIvan Vecera ret_code = i40e_allocate_dma_mem(hw, page,
13856a62fc8SJesse Brandeburg I40E_HMC_PAGED_BP_SIZE,
13956a62fc8SJesse Brandeburg I40E_HMC_PD_BP_BUF_ALIGNMENT);
14056a62fc8SJesse Brandeburg if (ret_code)
14156a62fc8SJesse Brandeburg goto exit;
1423bbf0faaSFaisal Latif pd_entry->rsrc_pg = false;
1433bbf0faaSFaisal Latif }
14456a62fc8SJesse Brandeburg
1453bbf0faaSFaisal Latif pd_entry->bp.addr = *page;
14656a62fc8SJesse Brandeburg pd_entry->bp.sd_pd_index = pd_index;
14756a62fc8SJesse Brandeburg pd_entry->bp.entry_type = I40E_SD_TYPE_PAGED;
14856a62fc8SJesse Brandeburg /* Set page address and valid bit */
1493bbf0faaSFaisal Latif page_desc = page->pa | 0x1;
15056a62fc8SJesse Brandeburg
15156a62fc8SJesse Brandeburg pd_addr = (u64 *)pd_table->pd_page_addr.va;
15256a62fc8SJesse Brandeburg pd_addr += rel_pd_idx;
15356a62fc8SJesse Brandeburg
15456a62fc8SJesse Brandeburg /* Add the backing page physical address in the pd entry */
15556a62fc8SJesse Brandeburg memcpy(pd_addr, &page_desc, sizeof(u64));
15656a62fc8SJesse Brandeburg
15756a62fc8SJesse Brandeburg pd_entry->sd_index = sd_idx;
15856a62fc8SJesse Brandeburg pd_entry->valid = true;
15956a62fc8SJesse Brandeburg I40E_INC_PD_REFCNT(pd_table);
16056a62fc8SJesse Brandeburg }
16156a62fc8SJesse Brandeburg I40E_INC_BP_REFCNT(&pd_entry->bp);
16256a62fc8SJesse Brandeburg exit:
16356a62fc8SJesse Brandeburg return ret_code;
16456a62fc8SJesse Brandeburg }
16556a62fc8SJesse Brandeburg
16656a62fc8SJesse Brandeburg /**
16756a62fc8SJesse Brandeburg * i40e_remove_pd_bp - remove a backing page from a page descriptor
16856a62fc8SJesse Brandeburg * @hw: pointer to our HW structure
16956a62fc8SJesse Brandeburg * @hmc_info: pointer to the HMC configuration information structure
17056a62fc8SJesse Brandeburg * @idx: the page index
17156a62fc8SJesse Brandeburg *
17256a62fc8SJesse Brandeburg * This function:
17356a62fc8SJesse Brandeburg * 1. Marks the entry in pd tabe (for paged address mode) or in sd table
17456a62fc8SJesse Brandeburg * (for direct address mode) invalid.
17556a62fc8SJesse Brandeburg * 2. Write to register PMPDINV to invalidate the backing page in FV cache
17656a62fc8SJesse Brandeburg * 3. Decrement the ref count for the pd _entry
17756a62fc8SJesse Brandeburg * assumptions:
17856a62fc8SJesse Brandeburg * 1. Caller can deallocate the memory used by backing storage after this
17956a62fc8SJesse Brandeburg * function returns.
18056a62fc8SJesse Brandeburg **/
i40e_remove_pd_bp(struct i40e_hw * hw,struct i40e_hmc_info * hmc_info,u32 idx)1815180ff13SJan Sokolowski int i40e_remove_pd_bp(struct i40e_hw *hw,
18256a62fc8SJesse Brandeburg struct i40e_hmc_info *hmc_info,
183467d729aSAnjali Singhai Jain u32 idx)
18456a62fc8SJesse Brandeburg {
18556a62fc8SJesse Brandeburg struct i40e_hmc_pd_entry *pd_entry;
18656a62fc8SJesse Brandeburg struct i40e_hmc_pd_table *pd_table;
18756a62fc8SJesse Brandeburg struct i40e_hmc_sd_entry *sd_entry;
18856a62fc8SJesse Brandeburg u32 sd_idx, rel_pd_idx;
1895180ff13SJan Sokolowski int ret_code = 0;
19056a62fc8SJesse Brandeburg u64 *pd_addr;
19156a62fc8SJesse Brandeburg
19256a62fc8SJesse Brandeburg /* calculate index */
19356a62fc8SJesse Brandeburg sd_idx = idx / I40E_HMC_PD_CNT_IN_SD;
19456a62fc8SJesse Brandeburg rel_pd_idx = idx % I40E_HMC_PD_CNT_IN_SD;
19556a62fc8SJesse Brandeburg if (sd_idx >= hmc_info->sd_table.sd_cnt) {
196230f3d53SJan Sokolowski ret_code = -EINVAL;
19756a62fc8SJesse Brandeburg hw_dbg(hw, "i40e_remove_pd_bp: bad idx\n");
19856a62fc8SJesse Brandeburg goto exit;
19956a62fc8SJesse Brandeburg }
20056a62fc8SJesse Brandeburg sd_entry = &hmc_info->sd_table.sd_entry[sd_idx];
20156a62fc8SJesse Brandeburg if (I40E_SD_TYPE_PAGED != sd_entry->entry_type) {
202230f3d53SJan Sokolowski ret_code = -EINVAL;
20356a62fc8SJesse Brandeburg hw_dbg(hw, "i40e_remove_pd_bp: wrong sd_entry type\n");
20456a62fc8SJesse Brandeburg goto exit;
20556a62fc8SJesse Brandeburg }
20656a62fc8SJesse Brandeburg /* get the entry and decrease its ref counter */
20756a62fc8SJesse Brandeburg pd_table = &hmc_info->sd_table.sd_entry[sd_idx].u.pd_table;
20856a62fc8SJesse Brandeburg pd_entry = &pd_table->pd_entry[rel_pd_idx];
20956a62fc8SJesse Brandeburg I40E_DEC_BP_REFCNT(&pd_entry->bp);
21056a62fc8SJesse Brandeburg if (pd_entry->bp.ref_cnt)
21156a62fc8SJesse Brandeburg goto exit;
21256a62fc8SJesse Brandeburg
21356a62fc8SJesse Brandeburg /* mark the entry invalid */
21456a62fc8SJesse Brandeburg pd_entry->valid = false;
21556a62fc8SJesse Brandeburg I40E_DEC_PD_REFCNT(pd_table);
21656a62fc8SJesse Brandeburg pd_addr = (u64 *)pd_table->pd_page_addr.va;
21756a62fc8SJesse Brandeburg pd_addr += rel_pd_idx;
21856a62fc8SJesse Brandeburg memset(pd_addr, 0, sizeof(u64));
21956a62fc8SJesse Brandeburg I40E_INVALIDATE_PF_HMC_PD(hw, sd_idx, idx);
22056a62fc8SJesse Brandeburg
22156a62fc8SJesse Brandeburg /* free memory here */
2223bbf0faaSFaisal Latif if (!pd_entry->rsrc_pg)
2233bbf0faaSFaisal Latif ret_code = i40e_free_dma_mem(hw, &pd_entry->bp.addr);
22456a62fc8SJesse Brandeburg if (ret_code)
22556a62fc8SJesse Brandeburg goto exit;
22656a62fc8SJesse Brandeburg if (!pd_table->ref_cnt)
22756a62fc8SJesse Brandeburg i40e_free_virt_mem(hw, &pd_table->pd_entry_virt_mem);
22856a62fc8SJesse Brandeburg exit:
22956a62fc8SJesse Brandeburg return ret_code;
23056a62fc8SJesse Brandeburg }
23156a62fc8SJesse Brandeburg
23256a62fc8SJesse Brandeburg /**
23356a62fc8SJesse Brandeburg * i40e_prep_remove_sd_bp - Prepares to remove a backing page from a sd entry
23456a62fc8SJesse Brandeburg * @hmc_info: pointer to the HMC configuration information structure
23556a62fc8SJesse Brandeburg * @idx: the page index
23656a62fc8SJesse Brandeburg **/
i40e_prep_remove_sd_bp(struct i40e_hmc_info * hmc_info,u32 idx)2375180ff13SJan Sokolowski int i40e_prep_remove_sd_bp(struct i40e_hmc_info *hmc_info,
23856a62fc8SJesse Brandeburg u32 idx)
23956a62fc8SJesse Brandeburg {
24056a62fc8SJesse Brandeburg struct i40e_hmc_sd_entry *sd_entry;
2415180ff13SJan Sokolowski int ret_code = 0;
24256a62fc8SJesse Brandeburg
24356a62fc8SJesse Brandeburg /* get the entry and decrease its ref counter */
24456a62fc8SJesse Brandeburg sd_entry = &hmc_info->sd_table.sd_entry[idx];
24556a62fc8SJesse Brandeburg I40E_DEC_BP_REFCNT(&sd_entry->u.bp);
24656a62fc8SJesse Brandeburg if (sd_entry->u.bp.ref_cnt) {
247230f3d53SJan Sokolowski ret_code = -EBUSY;
24856a62fc8SJesse Brandeburg goto exit;
24956a62fc8SJesse Brandeburg }
25056a62fc8SJesse Brandeburg I40E_DEC_SD_REFCNT(&hmc_info->sd_table);
25156a62fc8SJesse Brandeburg
25256a62fc8SJesse Brandeburg /* mark the entry invalid */
25356a62fc8SJesse Brandeburg sd_entry->valid = false;
25456a62fc8SJesse Brandeburg exit:
25556a62fc8SJesse Brandeburg return ret_code;
25656a62fc8SJesse Brandeburg }
25756a62fc8SJesse Brandeburg
25856a62fc8SJesse Brandeburg /**
25956a62fc8SJesse Brandeburg * i40e_remove_sd_bp_new - Removes a backing page from a segment descriptor
26056a62fc8SJesse Brandeburg * @hw: pointer to our hw struct
26156a62fc8SJesse Brandeburg * @hmc_info: pointer to the HMC configuration information structure
26256a62fc8SJesse Brandeburg * @idx: the page index
26356a62fc8SJesse Brandeburg * @is_pf: used to distinguish between VF and PF
26456a62fc8SJesse Brandeburg **/
i40e_remove_sd_bp_new(struct i40e_hw * hw,struct i40e_hmc_info * hmc_info,u32 idx,bool is_pf)2655180ff13SJan Sokolowski int i40e_remove_sd_bp_new(struct i40e_hw *hw,
26656a62fc8SJesse Brandeburg struct i40e_hmc_info *hmc_info,
26756a62fc8SJesse Brandeburg u32 idx, bool is_pf)
26856a62fc8SJesse Brandeburg {
26956a62fc8SJesse Brandeburg struct i40e_hmc_sd_entry *sd_entry;
2703b104be3SShannon Nelson
2713b104be3SShannon Nelson if (!is_pf)
272230f3d53SJan Sokolowski return -EOPNOTSUPP;
27356a62fc8SJesse Brandeburg
27456a62fc8SJesse Brandeburg /* get the entry and decrease its ref counter */
27556a62fc8SJesse Brandeburg sd_entry = &hmc_info->sd_table.sd_entry[idx];
27656a62fc8SJesse Brandeburg I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_DIRECT);
2773b104be3SShannon Nelson
2783b104be3SShannon Nelson return i40e_free_dma_mem(hw, &sd_entry->u.bp.addr);
27956a62fc8SJesse Brandeburg }
28056a62fc8SJesse Brandeburg
28156a62fc8SJesse Brandeburg /**
28256a62fc8SJesse Brandeburg * i40e_prep_remove_pd_page - Prepares to remove a PD page from sd entry.
28356a62fc8SJesse Brandeburg * @hmc_info: pointer to the HMC configuration information structure
28456a62fc8SJesse Brandeburg * @idx: segment descriptor index to find the relevant page descriptor
28556a62fc8SJesse Brandeburg **/
i40e_prep_remove_pd_page(struct i40e_hmc_info * hmc_info,u32 idx)2865180ff13SJan Sokolowski int i40e_prep_remove_pd_page(struct i40e_hmc_info *hmc_info,
28756a62fc8SJesse Brandeburg u32 idx)
28856a62fc8SJesse Brandeburg {
28956a62fc8SJesse Brandeburg struct i40e_hmc_sd_entry *sd_entry;
2905180ff13SJan Sokolowski int ret_code = 0;
29156a62fc8SJesse Brandeburg
29256a62fc8SJesse Brandeburg sd_entry = &hmc_info->sd_table.sd_entry[idx];
29356a62fc8SJesse Brandeburg
29456a62fc8SJesse Brandeburg if (sd_entry->u.pd_table.ref_cnt) {
295230f3d53SJan Sokolowski ret_code = -EBUSY;
29656a62fc8SJesse Brandeburg goto exit;
29756a62fc8SJesse Brandeburg }
29856a62fc8SJesse Brandeburg
29956a62fc8SJesse Brandeburg /* mark the entry invalid */
30056a62fc8SJesse Brandeburg sd_entry->valid = false;
30156a62fc8SJesse Brandeburg
30256a62fc8SJesse Brandeburg I40E_DEC_SD_REFCNT(&hmc_info->sd_table);
30356a62fc8SJesse Brandeburg exit:
30456a62fc8SJesse Brandeburg return ret_code;
30556a62fc8SJesse Brandeburg }
30656a62fc8SJesse Brandeburg
30756a62fc8SJesse Brandeburg /**
30856a62fc8SJesse Brandeburg * i40e_remove_pd_page_new - Removes a PD page from sd entry.
30956a62fc8SJesse Brandeburg * @hw: pointer to our hw struct
31056a62fc8SJesse Brandeburg * @hmc_info: pointer to the HMC configuration information structure
31156a62fc8SJesse Brandeburg * @idx: segment descriptor index to find the relevant page descriptor
31256a62fc8SJesse Brandeburg * @is_pf: used to distinguish between VF and PF
31356a62fc8SJesse Brandeburg **/
i40e_remove_pd_page_new(struct i40e_hw * hw,struct i40e_hmc_info * hmc_info,u32 idx,bool is_pf)3145180ff13SJan Sokolowski int i40e_remove_pd_page_new(struct i40e_hw *hw,
31556a62fc8SJesse Brandeburg struct i40e_hmc_info *hmc_info,
31656a62fc8SJesse Brandeburg u32 idx, bool is_pf)
31756a62fc8SJesse Brandeburg {
31856a62fc8SJesse Brandeburg struct i40e_hmc_sd_entry *sd_entry;
31956a62fc8SJesse Brandeburg
3203b104be3SShannon Nelson if (!is_pf)
321230f3d53SJan Sokolowski return -EOPNOTSUPP;
3223b104be3SShannon Nelson
32356a62fc8SJesse Brandeburg sd_entry = &hmc_info->sd_table.sd_entry[idx];
32456a62fc8SJesse Brandeburg I40E_CLEAR_PF_SD_ENTRY(hw, idx, I40E_SD_TYPE_PAGED);
3253b104be3SShannon Nelson
3263b104be3SShannon Nelson return i40e_free_dma_mem(hw, &sd_entry->u.pd_table.pd_page_addr);
32756a62fc8SJesse Brandeburg }
328