Lines Matching full:blk
78 * @blk: block type
84 static u32 ice_sect_id(enum ice_block blk, enum ice_sect sect) in ice_sect_id() argument
86 return ice_sect_lkup[blk][sect]; in ice_sect_id()
623 * @blk: hardware block
630 ice_find_prot_off(struct ice_hw *hw, enum ice_block blk, u8 prof, u16 fv_idx, in ice_find_prot_off() argument
635 if (prof >= hw->blk[blk].es.count) in ice_find_prot_off()
638 if (fv_idx >= hw->blk[blk].es.fvw) in ice_find_prot_off()
641 fv_ext = hw->blk[blk].es.t + (prof * hw->blk[blk].es.fvw); in ice_find_prot_off()
654 * @blk: HW block
663 ice_ptg_find_ptype(struct ice_hw *hw, enum ice_block blk, u16 ptype, u8 *ptg) in ice_ptg_find_ptype() argument
668 *ptg = hw->blk[blk].xlt1.ptypes[ptype].ptg; in ice_ptg_find_ptype()
675 * @blk: HW block
681 static void ice_ptg_alloc_val(struct ice_hw *hw, enum ice_block blk, u8 ptg) in ice_ptg_alloc_val() argument
683 hw->blk[blk].xlt1.ptg_tbl[ptg].in_use = true; in ice_ptg_alloc_val()
689 * @blk: HW block
697 ice_ptg_remove_ptype(struct ice_hw *hw, enum ice_block blk, u16 ptype, u8 ptg) in ice_ptg_remove_ptype() argument
705 if (!hw->blk[blk].xlt1.ptg_tbl[ptg].in_use) in ice_ptg_remove_ptype()
709 if (!hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype) in ice_ptg_remove_ptype()
713 p = hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype; in ice_ptg_remove_ptype()
714 ch = &hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype; in ice_ptg_remove_ptype()
716 if (ptype == (p - hw->blk[blk].xlt1.ptypes)) { in ice_ptg_remove_ptype()
725 hw->blk[blk].xlt1.ptypes[ptype].ptg = ICE_DEFAULT_PTG; in ice_ptg_remove_ptype()
726 hw->blk[blk].xlt1.ptypes[ptype].next_ptype = NULL; in ice_ptg_remove_ptype()
734 * @blk: HW block
744 ice_ptg_add_mv_ptype(struct ice_hw *hw, enum ice_block blk, u16 ptype, u8 ptg) in ice_ptg_add_mv_ptype() argument
752 if (!hw->blk[blk].xlt1.ptg_tbl[ptg].in_use && ptg != ICE_DEFAULT_PTG) in ice_ptg_add_mv_ptype()
755 status = ice_ptg_find_ptype(hw, blk, ptype, &original_ptg); in ice_ptg_add_mv_ptype()
765 ice_ptg_remove_ptype(hw, blk, ptype, original_ptg); in ice_ptg_add_mv_ptype()
772 hw->blk[blk].xlt1.ptypes[ptype].next_ptype = in ice_ptg_add_mv_ptype()
773 hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype; in ice_ptg_add_mv_ptype()
774 hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype = in ice_ptg_add_mv_ptype()
775 &hw->blk[blk].xlt1.ptypes[ptype]; in ice_ptg_add_mv_ptype()
777 hw->blk[blk].xlt1.ptypes[ptype].ptg = ptg; in ice_ptg_add_mv_ptype()
778 hw->blk[blk].xlt1.t[ptype] = ptg; in ice_ptg_add_mv_ptype()
880 * @blk: HW block
888 ice_vsig_find_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi, u16 *vsig) in ice_vsig_find_vsi() argument
897 *vsig = hw->blk[blk].xlt2.vsis[vsi].vsig; in ice_vsig_find_vsi()
905 * @blk: HW block
910 static u16 ice_vsig_alloc_val(struct ice_hw *hw, enum ice_block blk, u16 vsig) in ice_vsig_alloc_val() argument
914 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) { in ice_vsig_alloc_val()
915 INIT_LIST_HEAD(&hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst); in ice_vsig_alloc_val()
916 hw->blk[blk].xlt2.vsig_tbl[idx].in_use = true; in ice_vsig_alloc_val()
925 * @blk: HW block
930 static u16 ice_vsig_alloc(struct ice_hw *hw, enum ice_block blk) in ice_vsig_alloc() argument
935 if (!hw->blk[blk].xlt2.vsig_tbl[i].in_use) in ice_vsig_alloc()
936 return ice_vsig_alloc_val(hw, blk, i); in ice_vsig_alloc()
944 * @blk: HW block
957 ice_find_dup_props_vsig(struct ice_hw *hw, enum ice_block blk, in ice_find_dup_props_vsig() argument
960 struct ice_xlt2 *xlt2 = &hw->blk[blk].xlt2; in ice_find_dup_props_vsig()
976 * @blk: HW block
982 static int ice_vsig_free(struct ice_hw *hw, enum ice_block blk, u16 vsig) in ice_vsig_free() argument
992 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) in ice_vsig_free()
995 hw->blk[blk].xlt2.vsig_tbl[idx].in_use = false; in ice_vsig_free()
997 vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_vsig_free()
1013 hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = NULL; in ice_vsig_free()
1018 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_vsig_free()
1027 INIT_LIST_HEAD(&hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst); in ice_vsig_free()
1035 * @blk: HW block
1043 ice_vsig_remove_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi, u16 vsig) in ice_vsig_remove_vsi() argument
1053 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) in ice_vsig_remove_vsi()
1060 vsi_head = &hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_vsig_remove_vsi()
1064 vsi_tgt = &hw->blk[blk].xlt2.vsis[vsi]; in ice_vsig_remove_vsi()
1091 * @blk: HW block
1101 ice_vsig_add_mv_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi, u16 vsig) in ice_vsig_add_mv_vsi() argument
1115 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use && in ice_vsig_add_mv_vsi()
1119 status = ice_vsig_find_vsi(hw, blk, vsi, &orig_vsig); in ice_vsig_add_mv_vsi()
1129 status = ice_vsig_remove_vsi(hw, blk, vsi, orig_vsig); in ice_vsig_add_mv_vsi()
1138 hw->blk[blk].xlt2.vsis[vsi].vsig = vsig; in ice_vsig_add_mv_vsi()
1139 hw->blk[blk].xlt2.vsis[vsi].changed = 1; in ice_vsig_add_mv_vsi()
1142 tmp = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_vsig_add_mv_vsi()
1143 hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = in ice_vsig_add_mv_vsi()
1144 &hw->blk[blk].xlt2.vsis[vsi]; in ice_vsig_add_mv_vsi()
1145 hw->blk[blk].xlt2.vsis[vsi].next_vsi = tmp; in ice_vsig_add_mv_vsi()
1146 hw->blk[blk].xlt2.t[vsi] = vsig; in ice_vsig_add_mv_vsi()
1154 * @blk: HW block
1160 ice_prof_has_mask_idx(struct ice_hw *hw, enum ice_block blk, u8 prof, u16 idx, in ice_prof_has_mask_idx() argument
1173 for (i = hw->blk[blk].masks.first; i < hw->blk[blk].masks.first + in ice_prof_has_mask_idx()
1174 hw->blk[blk].masks.count; i++) in ice_prof_has_mask_idx()
1175 if (hw->blk[blk].es.mask_ena[prof] & BIT(i)) in ice_prof_has_mask_idx()
1176 if (hw->blk[blk].masks.masks[i].in_use && in ice_prof_has_mask_idx()
1177 hw->blk[blk].masks.masks[i].idx == idx) { in ice_prof_has_mask_idx()
1179 if (hw->blk[blk].masks.masks[i].mask == mask) in ice_prof_has_mask_idx()
1198 * @blk: HW block
1203 ice_prof_has_mask(struct ice_hw *hw, enum ice_block blk, u8 prof, u16 *masks) in ice_prof_has_mask() argument
1208 for (i = 0; i < hw->blk[blk].es.fvw; i++) in ice_prof_has_mask()
1209 if (!ice_prof_has_mask_idx(hw, blk, prof, i, masks[i])) in ice_prof_has_mask()
1218 * @blk: HW block
1224 ice_find_prof_id_with_mask(struct ice_hw *hw, enum ice_block blk, in ice_find_prof_id_with_mask() argument
1227 struct ice_es *es = &hw->blk[blk].es; in ice_find_prof_id_with_mask()
1233 if (blk == ICE_BLK_FD) in ice_find_prof_id_with_mask()
1243 if (masks && !ice_prof_has_mask(hw, blk, i, masks)) in ice_find_prof_id_with_mask()
1255 * @blk: the block type
1258 static bool ice_prof_id_rsrc_type(enum ice_block blk, u16 *rsrc_type) in ice_prof_id_rsrc_type() argument
1260 switch (blk) { in ice_prof_id_rsrc_type()
1275 * @blk: the block type
1278 static bool ice_tcam_ent_rsrc_type(enum ice_block blk, u16 *rsrc_type) in ice_tcam_ent_rsrc_type() argument
1280 switch (blk) { in ice_tcam_ent_rsrc_type()
1296 * @blk: the block to allocate the TCAM for
1304 ice_alloc_tcam_ent(struct ice_hw *hw, enum ice_block blk, bool btm, in ice_alloc_tcam_ent() argument
1309 if (!ice_tcam_ent_rsrc_type(blk, &res_type)) in ice_alloc_tcam_ent()
1318 * @blk: the block from which to free the TCAM entry
1324 ice_free_tcam_ent(struct ice_hw *hw, enum ice_block blk, u16 tcam_idx) in ice_free_tcam_ent() argument
1328 if (!ice_tcam_ent_rsrc_type(blk, &res_type)) in ice_free_tcam_ent()
1337 * @blk: the block to allocate the profile ID for
1343 static int ice_alloc_prof_id(struct ice_hw *hw, enum ice_block blk, u8 *prof_id) in ice_alloc_prof_id() argument
1349 if (!ice_prof_id_rsrc_type(blk, &res_type)) in ice_alloc_prof_id()
1362 * @blk: the block from which to free the profile ID
1367 static int ice_free_prof_id(struct ice_hw *hw, enum ice_block blk, u8 prof_id) in ice_free_prof_id() argument
1372 if (!ice_prof_id_rsrc_type(blk, &res_type)) in ice_free_prof_id()
1381 * @blk: the block from which to free the profile ID
1384 static int ice_prof_inc_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id) in ice_prof_inc_ref() argument
1386 if (prof_id > hw->blk[blk].es.count) in ice_prof_inc_ref()
1389 hw->blk[blk].es.ref_count[prof_id]++; in ice_prof_inc_ref()
1397 * @blk: hardware block
1403 ice_write_prof_mask_reg(struct ice_hw *hw, enum ice_block blk, u16 mask_idx, in ice_write_prof_mask_reg() argument
1409 switch (blk) { in ice_write_prof_mask_reg()
1422 blk); in ice_write_prof_mask_reg()
1427 ice_debug(hw, ICE_DBG_PKG, "write mask, blk %d (%d): %x = %x\n", in ice_write_prof_mask_reg()
1428 blk, idx, offset, val); in ice_write_prof_mask_reg()
1434 * @blk: hardware block
1439 ice_write_prof_mask_enable_res(struct ice_hw *hw, enum ice_block blk, in ice_write_prof_mask_enable_res() argument
1444 switch (blk) { in ice_write_prof_mask_enable_res()
1453 blk); in ice_write_prof_mask_enable_res()
1458 ice_debug(hw, ICE_DBG_PKG, "write mask enable, blk %d (%d): %x = %x\n", in ice_write_prof_mask_enable_res()
1459 blk, prof_id, offset, enable_mask); in ice_write_prof_mask_enable_res()
1465 * @blk: hardware block
1467 static void ice_init_prof_masks(struct ice_hw *hw, enum ice_block blk) in ice_init_prof_masks() argument
1472 mutex_init(&hw->blk[blk].masks.lock); in ice_init_prof_masks()
1476 hw->blk[blk].masks.count = per_pf; in ice_init_prof_masks()
1477 hw->blk[blk].masks.first = hw->pf_id * per_pf; in ice_init_prof_masks()
1479 memset(hw->blk[blk].masks.masks, 0, sizeof(hw->blk[blk].masks.masks)); in ice_init_prof_masks()
1481 for (i = hw->blk[blk].masks.first; in ice_init_prof_masks()
1482 i < hw->blk[blk].masks.first + hw->blk[blk].masks.count; i++) in ice_init_prof_masks()
1483 ice_write_prof_mask_reg(hw, blk, i, 0, 0); in ice_init_prof_masks()
1499 * @blk: hardware block
1505 ice_alloc_prof_mask(struct ice_hw *hw, enum ice_block blk, u16 idx, u16 mask, in ice_alloc_prof_mask() argument
1513 if (blk != ICE_BLK_RSS && blk != ICE_BLK_FD) in ice_alloc_prof_mask()
1516 mutex_lock(&hw->blk[blk].masks.lock); in ice_alloc_prof_mask()
1518 for (i = hw->blk[blk].masks.first; in ice_alloc_prof_mask()
1519 i < hw->blk[blk].masks.first + hw->blk[blk].masks.count; i++) in ice_alloc_prof_mask()
1520 if (hw->blk[blk].masks.masks[i].in_use) { in ice_alloc_prof_mask()
1524 if (hw->blk[blk].masks.masks[i].mask == mask && in ice_alloc_prof_mask()
1525 hw->blk[blk].masks.masks[i].idx == idx) { in ice_alloc_prof_mask()
1549 hw->blk[blk].masks.masks[i].in_use = true; in ice_alloc_prof_mask()
1550 hw->blk[blk].masks.masks[i].mask = mask; in ice_alloc_prof_mask()
1551 hw->blk[blk].masks.masks[i].idx = idx; in ice_alloc_prof_mask()
1552 hw->blk[blk].masks.masks[i].ref = 0; in ice_alloc_prof_mask()
1553 ice_write_prof_mask_reg(hw, blk, i, idx, mask); in ice_alloc_prof_mask()
1556 hw->blk[blk].masks.masks[i].ref++; in ice_alloc_prof_mask()
1561 mutex_unlock(&hw->blk[blk].masks.lock); in ice_alloc_prof_mask()
1569 * @blk: hardware block
1573 ice_free_prof_mask(struct ice_hw *hw, enum ice_block blk, u16 mask_idx) in ice_free_prof_mask() argument
1575 if (blk != ICE_BLK_RSS && blk != ICE_BLK_FD) in ice_free_prof_mask()
1578 if (!(mask_idx >= hw->blk[blk].masks.first && in ice_free_prof_mask()
1579 mask_idx < hw->blk[blk].masks.first + hw->blk[blk].masks.count)) in ice_free_prof_mask()
1582 mutex_lock(&hw->blk[blk].masks.lock); in ice_free_prof_mask()
1584 if (!hw->blk[blk].masks.masks[mask_idx].in_use) in ice_free_prof_mask()
1587 if (hw->blk[blk].masks.masks[mask_idx].ref > 1) { in ice_free_prof_mask()
1588 hw->blk[blk].masks.masks[mask_idx].ref--; in ice_free_prof_mask()
1593 hw->blk[blk].masks.masks[mask_idx].in_use = false; in ice_free_prof_mask()
1594 hw->blk[blk].masks.masks[mask_idx].mask = 0; in ice_free_prof_mask()
1595 hw->blk[blk].masks.masks[mask_idx].idx = 0; in ice_free_prof_mask()
1598 ice_debug(hw, ICE_DBG_PKG, "Free mask, blk %d, mask %d\n", blk, in ice_free_prof_mask()
1600 ice_write_prof_mask_reg(hw, blk, mask_idx, 0, 0); in ice_free_prof_mask()
1603 mutex_unlock(&hw->blk[blk].masks.lock); in ice_free_prof_mask()
1611 * @blk: hardware block
1615 ice_free_prof_masks(struct ice_hw *hw, enum ice_block blk, u16 prof_id) in ice_free_prof_masks() argument
1620 if (blk != ICE_BLK_RSS && blk != ICE_BLK_FD) in ice_free_prof_masks()
1623 mask_bm = hw->blk[blk].es.mask_ena[prof_id]; in ice_free_prof_masks()
1626 ice_free_prof_mask(hw, blk, i); in ice_free_prof_masks()
1634 * @blk: hardware block
1638 static void ice_shutdown_prof_masks(struct ice_hw *hw, enum ice_block blk) in ice_shutdown_prof_masks() argument
1642 mutex_lock(&hw->blk[blk].masks.lock); in ice_shutdown_prof_masks()
1644 for (i = hw->blk[blk].masks.first; in ice_shutdown_prof_masks()
1645 i < hw->blk[blk].masks.first + hw->blk[blk].masks.count; i++) { in ice_shutdown_prof_masks()
1646 ice_write_prof_mask_reg(hw, blk, i, 0, 0); in ice_shutdown_prof_masks()
1648 hw->blk[blk].masks.masks[i].in_use = false; in ice_shutdown_prof_masks()
1649 hw->blk[blk].masks.masks[i].idx = 0; in ice_shutdown_prof_masks()
1650 hw->blk[blk].masks.masks[i].mask = 0; in ice_shutdown_prof_masks()
1653 mutex_unlock(&hw->blk[blk].masks.lock); in ice_shutdown_prof_masks()
1654 mutex_destroy(&hw->blk[blk].masks.lock); in ice_shutdown_prof_masks()
1672 * @blk: hardware block
1677 ice_update_prof_masking(struct ice_hw *hw, enum ice_block blk, u16 prof_id, in ice_update_prof_masking() argument
1686 if (blk != ICE_BLK_RSS && blk != ICE_BLK_FD) in ice_update_prof_masking()
1689 for (i = 0; i < hw->blk[blk].es.fvw; i++) in ice_update_prof_masking()
1691 if (!ice_alloc_prof_mask(hw, blk, i, masks[i], &idx)) { in ice_update_prof_masking()
1704 ice_free_prof_mask(hw, blk, i); in ice_update_prof_masking()
1710 ice_write_prof_mask_enable_res(hw, blk, prof_id, ena_mask); in ice_update_prof_masking()
1713 hw->blk[blk].es.mask_ena[prof_id] = ena_mask; in ice_update_prof_masking()
1721 * @blk: the block in which to write the extraction sequence
1726 ice_write_es(struct ice_hw *hw, enum ice_block blk, u8 prof_id, in ice_write_es() argument
1731 off = prof_id * hw->blk[blk].es.fvw; in ice_write_es()
1733 memset(&hw->blk[blk].es.t[off], 0, in ice_write_es()
1734 hw->blk[blk].es.fvw * sizeof(*fv)); in ice_write_es()
1735 hw->blk[blk].es.written[prof_id] = false; in ice_write_es()
1737 memcpy(&hw->blk[blk].es.t[off], fv, in ice_write_es()
1738 hw->blk[blk].es.fvw * sizeof(*fv)); in ice_write_es()
1745 * @blk: the block from which to free the profile ID
1749 ice_prof_dec_ref(struct ice_hw *hw, enum ice_block blk, u8 prof_id) in ice_prof_dec_ref() argument
1751 if (prof_id > hw->blk[blk].es.count) in ice_prof_dec_ref()
1754 if (hw->blk[blk].es.ref_count[prof_id] > 0) { in ice_prof_dec_ref()
1755 if (!--hw->blk[blk].es.ref_count[prof_id]) { in ice_prof_dec_ref()
1756 ice_write_es(hw, blk, prof_id, NULL); in ice_prof_dec_ref()
1757 ice_free_prof_masks(hw, blk, prof_id); in ice_prof_dec_ref()
1758 return ice_free_prof_id(hw, blk, prof_id); in ice_prof_dec_ref()
1811 * @blk: the HW block to initialize
1813 static void ice_init_sw_xlt1_db(struct ice_hw *hw, enum ice_block blk) in ice_init_sw_xlt1_db() argument
1817 for (pt = 0; pt < hw->blk[blk].xlt1.count; pt++) { in ice_init_sw_xlt1_db()
1820 ptg = hw->blk[blk].xlt1.t[pt]; in ice_init_sw_xlt1_db()
1822 ice_ptg_alloc_val(hw, blk, ptg); in ice_init_sw_xlt1_db()
1823 ice_ptg_add_mv_ptype(hw, blk, pt, ptg); in ice_init_sw_xlt1_db()
1831 * @blk: the HW block to initialize
1833 static void ice_init_sw_xlt2_db(struct ice_hw *hw, enum ice_block blk) in ice_init_sw_xlt2_db() argument
1837 for (vsi = 0; vsi < hw->blk[blk].xlt2.count; vsi++) { in ice_init_sw_xlt2_db()
1840 vsig = hw->blk[blk].xlt2.t[vsi]; in ice_init_sw_xlt2_db()
1842 ice_vsig_alloc_val(hw, blk, vsig); in ice_init_sw_xlt2_db()
1843 ice_vsig_add_mv_vsi(hw, blk, vsi, vsig); in ice_init_sw_xlt2_db()
1847 hw->blk[blk].xlt2.vsis[vsi].changed = 0; in ice_init_sw_xlt2_db()
1913 sizeof(*hw->blk[block_id].xlt1.t); in ice_fill_tbl()
1914 dst = hw->blk[block_id].xlt1.t; in ice_fill_tbl()
1915 dst_len = hw->blk[block_id].xlt1.count * in ice_fill_tbl()
1916 sizeof(*hw->blk[block_id].xlt1.t); in ice_fill_tbl()
1926 sizeof(*hw->blk[block_id].xlt2.t); in ice_fill_tbl()
1927 dst = (u8 *)hw->blk[block_id].xlt2.t; in ice_fill_tbl()
1928 dst_len = hw->blk[block_id].xlt2.count * in ice_fill_tbl()
1929 sizeof(*hw->blk[block_id].xlt2.t); in ice_fill_tbl()
1939 sizeof(*hw->blk[block_id].prof.t); in ice_fill_tbl()
1940 dst = (u8 *)hw->blk[block_id].prof.t; in ice_fill_tbl()
1941 dst_len = hw->blk[block_id].prof.count * in ice_fill_tbl()
1942 sizeof(*hw->blk[block_id].prof.t); in ice_fill_tbl()
1952 sizeof(*hw->blk[block_id].prof_redir.t); in ice_fill_tbl()
1953 dst = hw->blk[block_id].prof_redir.t; in ice_fill_tbl()
1954 dst_len = hw->blk[block_id].prof_redir.count * in ice_fill_tbl()
1955 sizeof(*hw->blk[block_id].prof_redir.t); in ice_fill_tbl()
1965 hw->blk[block_id].es.fvw) * in ice_fill_tbl()
1966 sizeof(*hw->blk[block_id].es.t); in ice_fill_tbl()
1967 dst = (u8 *)hw->blk[block_id].es.t; in ice_fill_tbl()
1968 dst_len = (u32)(hw->blk[block_id].es.count * in ice_fill_tbl()
1969 hw->blk[block_id].es.fvw) * in ice_fill_tbl()
1970 sizeof(*hw->blk[block_id].es.t); in ice_fill_tbl()
2011 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].xlt1.sid); in ice_fill_blk_tbls()
2012 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].xlt2.sid); in ice_fill_blk_tbls()
2013 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].prof.sid); in ice_fill_blk_tbls()
2014 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].prof_redir.sid); in ice_fill_blk_tbls()
2015 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].es.sid); in ice_fill_blk_tbls()
2028 struct ice_es *es = &hw->blk[blk_idx].es; in ice_free_prof_map()
2073 * @blk: the HW block on which to free the VSIG table entries
2075 static void ice_free_vsig_tbl(struct ice_hw *hw, enum ice_block blk) in ice_free_vsig_tbl() argument
2079 if (!hw->blk[blk].xlt2.vsig_tbl) in ice_free_vsig_tbl()
2083 if (hw->blk[blk].xlt2.vsig_tbl[i].in_use) in ice_free_vsig_tbl()
2084 ice_vsig_free(hw, blk, i); in ice_free_vsig_tbl()
2097 if (hw->blk[i].is_list_init) { in ice_free_hw_tbls()
2098 struct ice_es *es = &hw->blk[i].es; in ice_free_hw_tbls()
2106 hw->blk[i].is_list_init = false; in ice_free_hw_tbls()
2109 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt1.ptypes); in ice_free_hw_tbls()
2110 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt1.ptg_tbl); in ice_free_hw_tbls()
2111 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt1.t); in ice_free_hw_tbls()
2112 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt2.t); in ice_free_hw_tbls()
2113 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt2.vsig_tbl); in ice_free_hw_tbls()
2114 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt2.vsis); in ice_free_hw_tbls()
2115 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].prof.t); in ice_free_hw_tbls()
2116 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].prof_redir.t); in ice_free_hw_tbls()
2117 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.t); in ice_free_hw_tbls()
2118 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.ref_count); in ice_free_hw_tbls()
2119 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.written); in ice_free_hw_tbls()
2120 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.mask_ena); in ice_free_hw_tbls()
2129 memset(hw->blk, 0, sizeof(hw->blk)); in ice_free_hw_tbls()
2152 struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir; in ice_clear_hw_tbls()
2153 struct ice_prof_tcam *prof = &hw->blk[i].prof; in ice_clear_hw_tbls()
2154 struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1; in ice_clear_hw_tbls()
2155 struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2; in ice_clear_hw_tbls()
2156 struct ice_es *es = &hw->blk[i].es; in ice_clear_hw_tbls()
2158 if (hw->blk[i].is_list_init) { in ice_clear_hw_tbls()
2198 struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir; in ice_init_hw_tbls()
2199 struct ice_prof_tcam *prof = &hw->blk[i].prof; in ice_init_hw_tbls()
2200 struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1; in ice_init_hw_tbls()
2201 struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2; in ice_init_hw_tbls()
2202 struct ice_es *es = &hw->blk[i].es; in ice_init_hw_tbls()
2205 if (hw->blk[i].is_list_init) in ice_init_hw_tbls()
2211 hw->blk[i].is_list_init = true; in ice_init_hw_tbls()
2213 hw->blk[i].overwrite = blk_sizes[i].overwrite; in ice_init_hw_tbls()
2315 * @blk: the block in which to write profile ID to
2326 ice_prof_gen_key(struct ice_hw *hw, enum ice_block blk, u8 ptg, u16 vsig, in ice_prof_gen_key() argument
2337 switch (hw->blk[blk].prof.cdid_bits) { in ice_prof_gen_key()
2370 * @blk: the block in which to write profile ID to
2382 ice_tcam_write_entry(struct ice_hw *hw, enum ice_block blk, u16 idx, in ice_tcam_write_entry() argument
2391 status = ice_prof_gen_key(hw, blk, ptg, vsig, cdid, flags, vl_msk, in ice_tcam_write_entry()
2392 dc_msk, nm_msk, hw->blk[blk].prof.t[idx].key); in ice_tcam_write_entry()
2394 hw->blk[blk].prof.t[idx].addr = cpu_to_le16(idx); in ice_tcam_write_entry()
2395 hw->blk[blk].prof.t[idx].prof_id = prof_id; in ice_tcam_write_entry()
2404 * @blk: HW block
2409 ice_vsig_get_ref(struct ice_hw *hw, enum ice_block blk, u16 vsig, u16 *refs) in ice_vsig_get_ref() argument
2416 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) in ice_vsig_get_ref()
2419 ptr = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_vsig_get_ref()
2431 * @blk: HW block
2436 ice_has_prof_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl) in ice_has_prof_vsig() argument
2441 list_for_each_entry(ent, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_has_prof_vsig()
2454 * @blk: hardware block
2459 ice_prof_bld_es(struct ice_hw *hw, enum ice_block blk, in ice_prof_bld_es() argument
2462 u16 vec_size = hw->blk[blk].es.fvw * sizeof(struct ice_fv_word); in ice_prof_bld_es()
2467 u16 off = tmp->prof_id * hw->blk[blk].es.fvw; in ice_prof_bld_es()
2471 id = ice_sect_id(blk, ICE_VEC_TBL); in ice_prof_bld_es()
2483 memcpy(p->es, &hw->blk[blk].es.t[off], vec_size); in ice_prof_bld_es()
2492 * @blk: hardware block
2497 ice_prof_bld_tcam(struct ice_hw *hw, enum ice_block blk, in ice_prof_bld_tcam() argument
2507 id = ice_sect_id(blk, ICE_PROF_TCAM); in ice_prof_bld_tcam()
2519 &hw->blk[blk].prof.t[tmp->tcam_idx].key, in ice_prof_bld_tcam()
2520 sizeof(hw->blk[blk].prof.t->key)); in ice_prof_bld_tcam()
2528 * @blk: hardware block
2533 ice_prof_bld_xlt1(enum ice_block blk, struct ice_buf_build *bld, in ice_prof_bld_xlt1() argument
2543 id = ice_sect_id(blk, ICE_XLT1); in ice_prof_bld_xlt1()
2560 * @blk: hardware block
2565 ice_prof_bld_xlt2(enum ice_block blk, struct ice_buf_build *bld, in ice_prof_bld_xlt2() argument
2578 id = ice_sect_id(blk, ICE_XLT2); in ice_prof_bld_xlt2()
2600 * @blk: hardware block
2604 ice_upd_prof_hw(struct ice_hw *hw, enum ice_block blk, in ice_upd_prof_hw() argument
2654 status = ice_prof_bld_es(hw, blk, b, chgs); in ice_upd_prof_hw()
2660 status = ice_prof_bld_tcam(hw, blk, b, chgs); in ice_upd_prof_hw()
2666 status = ice_prof_bld_xlt1(blk, b, chgs); in ice_upd_prof_hw()
2672 status = ice_prof_bld_xlt2(blk, b, chgs); in ice_upd_prof_hw()
2776 for (i = 0; i < hw->blk[ICE_BLK_FD].es.fvw; i++) { in ice_update_fd_swap()
2832 si = hw->blk[ICE_BLK_FD].es.fvw - 1; in ice_update_fd_swap()
2869 for (j = 0; j < hw->blk[ICE_BLK_FD].es.fvw / 4; j++) { in ice_update_fd_swap()
2959 * @blk: hardware block
2973 ice_add_prof(struct ice_hw *hw, enum ice_block blk, u64 id, u8 ptypes[], in ice_add_prof() argument
2986 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof()
2989 status = ice_find_prof_id_with_mask(hw, blk, es, masks, &prof_id); in ice_add_prof()
2992 status = ice_alloc_prof_id(hw, blk, &prof_id); in ice_add_prof()
2995 if (blk == ICE_BLK_FD) { in ice_add_prof()
3007 status = ice_update_prof_masking(hw, blk, prof_id, masks); in ice_add_prof()
3012 ice_write_es(hw, blk, prof_id, es); in ice_add_prof()
3015 ice_prof_inc_ref(hw, blk, prof_id); in ice_add_prof()
3050 if (ice_ptg_find_ptype(hw, blk, ptype, &ptg)) in ice_add_prof()
3083 list_add(&prof->list, &hw->blk[blk].es.prof_map); in ice_add_prof()
3087 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof()
3094 * @blk: hardware block
3101 ice_search_prof_id(struct ice_hw *hw, enum ice_block blk, u64 id) in ice_search_prof_id() argument
3106 list_for_each_entry(map, &hw->blk[blk].es.prof_map, list) in ice_search_prof_id()
3118 * @blk: hardware block
3122 ice_vsig_prof_id_count(struct ice_hw *hw, enum ice_block blk, u16 vsig) in ice_vsig_prof_id_count() argument
3127 list_for_each_entry(p, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_vsig_prof_id_count()
3137 * @blk: hardware block
3140 static int ice_rel_tcam_idx(struct ice_hw *hw, enum ice_block blk, u16 idx) in ice_rel_tcam_idx() argument
3149 status = ice_tcam_write_entry(hw, blk, idx, 0, 0, 0, 0, 0, vl_msk, in ice_rel_tcam_idx()
3155 status = ice_free_tcam_ent(hw, blk, idx); in ice_rel_tcam_idx()
3163 * @blk: hardware block
3167 ice_rem_prof_id(struct ice_hw *hw, enum ice_block blk, in ice_rem_prof_id() argument
3176 status = ice_rel_tcam_idx(hw, blk, in ice_rem_prof_id()
3188 * @blk: hardware block
3193 ice_rem_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, in ice_rem_vsig() argument
3202 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_rem_vsig()
3206 status = ice_rem_prof_id(hw, blk, d); in ice_rem_vsig()
3215 vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_rem_vsig()
3232 p->vsi = vsi_cur - hw->blk[blk].xlt2.vsis; in ice_rem_vsig()
3239 return ice_vsig_free(hw, blk, vsig); in ice_rem_vsig()
3245 * @blk: hardware block
3251 ice_rem_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl, in ice_rem_prof_id_vsig() argument
3258 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_rem_prof_id_vsig()
3263 if (ice_vsig_prof_id_count(hw, blk, vsig) == 1) in ice_rem_prof_id_vsig()
3265 return ice_rem_vsig(hw, blk, vsig, chg); in ice_rem_prof_id_vsig()
3267 status = ice_rem_prof_id(hw, blk, p); in ice_rem_prof_id_vsig()
3281 * @blk: hardware block
3284 static int ice_rem_flow_all(struct ice_hw *hw, enum ice_block blk, u64 id) in ice_rem_flow_all() argument
3294 if (hw->blk[blk].xlt2.vsig_tbl[i].in_use) { in ice_rem_flow_all()
3295 if (ice_has_prof_vsig(hw, blk, i, id)) { in ice_rem_flow_all()
3296 status = ice_rem_prof_id_vsig(hw, blk, i, id, in ice_rem_flow_all()
3303 status = ice_upd_prof_hw(hw, blk, &chg); in ice_rem_flow_all()
3317 * @blk: hardware block
3324 int ice_rem_prof(struct ice_hw *hw, enum ice_block blk, u64 id) in ice_rem_prof() argument
3329 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_rem_prof()
3331 pmap = ice_search_prof_id(hw, blk, id); in ice_rem_prof()
3338 status = ice_rem_flow_all(hw, blk, pmap->profile_cookie); in ice_rem_prof()
3343 ice_prof_dec_ref(hw, blk, pmap->prof_id); in ice_rem_prof()
3349 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_rem_prof()
3356 * @blk: hardware block
3361 ice_get_prof(struct ice_hw *hw, enum ice_block blk, u64 hdl, in ice_get_prof() argument
3369 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_get_prof()
3371 map = ice_search_prof_id(hw, blk, hdl); in ice_get_prof()
3378 if (!hw->blk[blk].es.written[map->prof_id]) { in ice_get_prof()
3395 hw->blk[blk].es.written[map->prof_id] = true; in ice_get_prof()
3401 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_get_prof()
3409 * @blk: hardware block
3416 ice_get_profs_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, in ice_get_profs_vsig() argument
3422 list_for_each_entry(ent1, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_get_profs_vsig()
3449 * @blk: hardware block
3454 ice_add_prof_to_lst(struct ice_hw *hw, enum ice_block blk, in ice_add_prof_to_lst() argument
3462 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_to_lst()
3463 map = ice_search_prof_id(hw, blk, hdl); in ice_add_prof_to_lst()
3488 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_to_lst()
3495 * @blk: hardware block
3501 ice_move_vsi(struct ice_hw *hw, enum ice_block blk, u16 vsi, u16 vsig, in ice_move_vsi() argument
3512 status = ice_vsig_find_vsi(hw, blk, vsi, &orig_vsig); in ice_move_vsi()
3514 status = ice_vsig_add_mv_vsi(hw, blk, vsi, vsig); in ice_move_vsi()
3552 * @blk: hardware block
3561 ice_prof_tcam_ena_dis(struct ice_hw *hw, enum ice_block blk, bool enable, in ice_prof_tcam_ena_dis() argument
3574 status = ice_rel_tcam_idx(hw, blk, tcam->tcam_idx); in ice_prof_tcam_ena_dis()
3591 status = ice_alloc_tcam_ent(hw, blk, tcam->attr.mask == 0, in ice_prof_tcam_ena_dis()
3601 status = ice_tcam_write_entry(hw, blk, tcam->tcam_idx, tcam->prof_id, in ice_prof_tcam_ena_dis()
3629 * @blk: hardware block
3634 ice_adj_prof_priorities(struct ice_hw *hw, enum ice_block blk, u16 vsig, in ice_adj_prof_priorities() argument
3654 list_for_each_entry(t, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_adj_prof_priorities()
3668 status = ice_prof_tcam_ena_dis(hw, blk, false, in ice_adj_prof_priorities()
3679 status = ice_prof_tcam_ena_dis(hw, blk, true, in ice_adj_prof_priorities()
3698 * @blk: hardware block
3705 ice_add_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsig, u64 hdl, in ice_add_prof_id_vsig() argument
3719 if (ice_has_prof_vsig(hw, blk, vsig, hdl)) in ice_add_prof_id_vsig()
3727 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_id_vsig()
3729 map = ice_search_prof_id(hw, blk, hdl); in ice_add_prof_id_vsig()
3755 status = ice_alloc_tcam_ent(hw, blk, map->attr[i].mask == 0, in ice_add_prof_id_vsig()
3776 status = ice_tcam_write_entry(hw, blk, t->tcam[i].tcam_idx, in ice_add_prof_id_vsig()
3793 &hw->blk[blk].xlt2.vsig_tbl[vsig_idx].prop_lst); in ice_add_prof_id_vsig()
3796 &hw->blk[blk].xlt2.vsig_tbl[vsig_idx].prop_lst); in ice_add_prof_id_vsig()
3798 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_id_vsig()
3802 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_id_vsig()
3811 * @blk: hardware block
3817 ice_create_prof_id_vsig(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl, in ice_create_prof_id_vsig() argument
3828 new_vsig = ice_vsig_alloc(hw, blk); in ice_create_prof_id_vsig()
3834 status = ice_move_vsi(hw, blk, vsi, new_vsig, chg); in ice_create_prof_id_vsig()
3838 status = ice_add_prof_id_vsig(hw, blk, new_vsig, hdl, false, chg); in ice_create_prof_id_vsig()
3860 * @blk: hardware block
3867 ice_create_vsig_from_lst(struct ice_hw *hw, enum ice_block blk, u16 vsi, in ice_create_vsig_from_lst() argument
3875 vsig = ice_vsig_alloc(hw, blk); in ice_create_vsig_from_lst()
3879 status = ice_move_vsi(hw, blk, vsi, vsig, chg); in ice_create_vsig_from_lst()
3885 status = ice_add_prof_id_vsig(hw, blk, vsig, t->profile_cookie, in ice_create_vsig_from_lst()
3899 * @blk: hardware block
3904 ice_find_prof_vsig(struct ice_hw *hw, enum ice_block blk, u64 hdl, u16 *vsig) in ice_find_prof_vsig() argument
3919 status = ice_find_dup_props_vsig(hw, blk, &lst, vsig); in ice_find_prof_vsig()
3930 * @blk: hardware block
3939 ice_add_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl) in ice_add_prof_id_flow() argument
3952 status = ice_get_prof(hw, blk, hdl, &chg); in ice_add_prof_id_flow()
3957 status = ice_vsig_find_vsi(hw, blk, vsi, &vsig); in ice_add_prof_id_flow()
3970 if (ice_has_prof_vsig(hw, blk, vsig, hdl)) { in ice_add_prof_id_flow()
3976 status = ice_vsig_get_ref(hw, blk, vsig, &ref); in ice_add_prof_id_flow()
3984 status = ice_get_profs_vsig(hw, blk, vsig, &union_lst); in ice_add_prof_id_flow()
3988 status = ice_add_prof_to_lst(hw, blk, &union_lst, hdl); in ice_add_prof_id_flow()
3993 status = ice_find_dup_props_vsig(hw, blk, &union_lst, &vsig); in ice_add_prof_id_flow()
3996 status = ice_move_vsi(hw, blk, vsi, vsig, &chg); in ice_add_prof_id_flow()
4004 status = ice_rem_vsig(hw, blk, or_vsig, &chg); in ice_add_prof_id_flow()
4014 status = ice_add_prof_id_vsig(hw, blk, vsig, hdl, false, in ice_add_prof_id_flow()
4020 status = ice_adj_prof_priorities(hw, blk, vsig, &chg); in ice_add_prof_id_flow()
4025 status = ice_create_vsig_from_lst(hw, blk, vsi, in ice_add_prof_id_flow()
4032 status = ice_adj_prof_priorities(hw, blk, vsig, &chg); in ice_add_prof_id_flow()
4039 if (ice_find_prof_vsig(hw, blk, hdl, &vsig)) { in ice_add_prof_id_flow()
4042 status = ice_move_vsi(hw, blk, vsi, vsig, &chg); in ice_add_prof_id_flow()
4048 status = ice_create_prof_id_vsig(hw, blk, vsi, hdl, in ice_add_prof_id_flow()
4057 status = ice_upd_prof_hw(hw, blk, &chg); in ice_add_prof_id_flow()
4097 * @blk: hardware block
4106 ice_rem_prof_id_flow(struct ice_hw *hw, enum ice_block blk, u16 vsi, u64 hdl) in ice_rem_prof_id_flow() argument
4118 status = ice_vsig_find_vsi(hw, blk, vsi, &vsig); in ice_rem_prof_id_flow()
4125 last_profile = ice_vsig_prof_id_count(hw, blk, vsig) == 1; in ice_rem_prof_id_flow()
4126 status = ice_vsig_get_ref(hw, blk, vsig, &ref); in ice_rem_prof_id_flow()
4142 status = ice_rem_vsig(hw, blk, vsig, &chg); in ice_rem_prof_id_flow()
4146 status = ice_rem_prof_id_vsig(hw, blk, vsig, in ice_rem_prof_id_flow()
4152 status = ice_adj_prof_priorities(hw, blk, vsig, in ice_rem_prof_id_flow()
4160 status = ice_get_profs_vsig(hw, blk, vsig, ©); in ice_rem_prof_id_flow()
4170 status = ice_move_vsi(hw, blk, vsi, in ice_rem_prof_id_flow()
4175 } else if (!ice_find_dup_props_vsig(hw, blk, ©, in ice_rem_prof_id_flow()
4184 status = ice_move_vsi(hw, blk, vsi, vsig, &chg); in ice_rem_prof_id_flow()
4192 status = ice_create_vsig_from_lst(hw, blk, vsi, in ice_rem_prof_id_flow()
4199 status = ice_adj_prof_priorities(hw, blk, vsig, in ice_rem_prof_id_flow()
4211 status = ice_upd_prof_hw(hw, blk, &chg); in ice_rem_prof_id_flow()