Lines Matching +full:chg +full:- +full:done
1 /* SPDX-License-Identifier: BSD-3-Clause */
112 * ice_sect_id - returns section ID
132 if (hw->tnl.count < ICE_TUNNEL_MAX_ENTRIES) {
143 * character ('0' - '7') will be located where our
146 if ((label_name[len] - '0') == hw->pf_id) {
147 hw->tnl.tbl[hw->tnl.count].type = tnls[i].type;
148 hw->tnl.tbl[hw->tnl.count].valid = false;
149 hw->tnl.tbl[hw->tnl.count].in_use = false;
150 hw->tnl.tbl[hw->tnl.count].marked = false;
151 hw->tnl.tbl[hw->tnl.count].boost_addr = val;
152 hw->tnl.tbl[hw->tnl.count].port = 0;
153 hw->tnl.count++;
172 * ice_gen_key_word - generate 16-bits of a key/mask word
180 * This function generates 16-bits from a 8-bit value, an 8-bit don't care mask
181 * and an 8-bit never match mask. The 16-bits of output are divided into 8 bits
193 * ------------------------------
210 /* encode the 8 bits into 8-bit key and 8-bit key invert */
244 * ice_bits_max_set - determine if the number of bits set is within a maximum
281 * ice_set_key - generate a variable sized key with multiples of 16-bits
284 * @val: array of 8-bit values that makes up the value portion of the key
285 * @upd: array of 8-bit masks that determine what key portion to update
286 * @dc: array of 8-bit masks that make up the don't care mask
287 * @nm: array of 8-bit masks that make up the never match mask
294 * upd == NULL --> upd mask is all 1's (update all bits)
295 * dc == NULL --> dc mask is all 0's (no don't care bits)
296 * nm == NULL --> nm mask is all 0's (no never match bits)
331 * ice_tunnel_port_in_use_hlpr - helper function to determine tunnel usage
343 for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++)
344 if (hw->tnl.tbl[i].in_use && hw->tnl.tbl[i].port == port) {
366 ice_acquire_lock(&hw->tnl_lock);
368 ice_release_lock(&hw->tnl_lock);
387 ice_acquire_lock(&hw->tnl_lock);
389 for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++)
390 if (hw->tnl.tbl[i].in_use && hw->tnl.tbl[i].port == port) {
391 *type = hw->tnl.tbl[i].type;
396 ice_release_lock(&hw->tnl_lock);
415 for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++)
416 if (hw->tnl.tbl[i].valid && !hw->tnl.tbl[i].in_use &&
417 hw->tnl.tbl[i].type == type) {
427 * ice_get_open_tunnel_port - retrieve an open tunnel port
439 ice_acquire_lock(&hw->tnl_lock);
441 for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++)
442 if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use &&
443 (type == TNL_ALL || hw->tnl.tbl[i].type == type)) {
444 *port = hw->tnl.tbl[i].port;
449 ice_release_lock(&hw->tnl_lock);
472 ice_acquire_lock(&hw->tnl_lock);
475 hw->tnl.tbl[index].ref++;
500 sect_rx->count = CPU_TO_LE16(1);
507 sect_tx->count = CPU_TO_LE16(1);
510 ice_memcpy(sect_rx->tcam, hw->tnl.tbl[index].boost_entry,
511 sizeof(*sect_rx->tcam), ICE_NONDMA_TO_NONDMA);
513 /* over-write the never-match dest port key bits with the encoded port
516 ice_set_key((u8 *)§_rx->tcam[0].key, sizeof(sect_rx->tcam[0].key),
519 sizeof(sect_rx->tcam[0].key.key.hv_dst_port_key));
522 ice_memcpy(sect_tx->tcam, sect_rx->tcam, sizeof(*sect_tx->tcam),
527 hw->tnl.tbl[index].port = port;
528 hw->tnl.tbl[index].in_use = true;
529 hw->tnl.tbl[index].ref = 1;
536 ice_release_lock(&hw->tnl_lock);
561 ice_acquire_lock(&hw->tnl_lock);
564 if (hw->tnl.tbl[index].ref > 1) {
565 hw->tnl.tbl[index].ref--;
571 for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++)
572 if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use &&
573 (all || hw->tnl.tbl[i].port == port))
581 /* size of section - there is at least one entry */
599 sect_rx->count = CPU_TO_LE16(count);
606 sect_tx->count = CPU_TO_LE16(count);
611 for (i = 0, j = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++)
612 if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use &&
613 (all || hw->tnl.tbl[i].port == port)) {
614 ice_memcpy(sect_rx->tcam + j,
615 hw->tnl.tbl[i].boost_entry,
616 sizeof(*sect_rx->tcam),
618 ice_memcpy(sect_tx->tcam + j,
619 hw->tnl.tbl[i].boost_entry,
620 sizeof(*sect_tx->tcam),
622 hw->tnl.tbl[i].marked = true;
628 for (i = 0; i < hw->tnl.count &&
630 if (hw->tnl.tbl[i].marked) {
631 hw->tnl.tbl[i].ref = 0;
632 hw->tnl.tbl[i].port = 0;
633 hw->tnl.tbl[i].in_use = false;
634 hw->tnl.tbl[i].marked = false;
641 ice_release_lock(&hw->tnl_lock);
659 for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++) {
660 enum ice_tunnel_type type = hw->tnl.tbl[i].type;
661 u16 refs = hw->tnl.tbl[i].ref;
662 u16 port = hw->tnl.tbl[i].port;
664 if (!hw->tnl.tbl[i].in_use)
670 hw->tnl.tbl[i].ref = 1; /* make sure to destroy in one call */
673 ice_debug(hw, ICE_DBG_PKG, "ERR: 0x%x - destroy tunnel port 0x%x\n",
675 hw->tnl.tbl[i].ref = refs;
681 ice_debug(hw, ICE_DBG_PKG, "ERR: 0x%x - create tunnel port 0x%x\n",
687 hw->tnl.tbl[i].ref = refs;
694 * ice_find_prot_off - find prot ID and offset pair, based on prof and FV index
708 if (prof >= hw->blk[blk].es.count)
711 if (fv_idx >= hw->blk[blk].es.fvw)
714 fv_ext = hw->blk[blk].es.t + (prof * hw->blk[blk].es.fvw);
725 * ice_ptg_update_xlt1 - Updates packet type groups in HW via XLT1 table
746 sect->count = CPU_TO_LE16(ICE_XLT1_CNT);
747 sect->offset = CPU_TO_LE16(0);
749 sect->value[index] = hw->blk[blk].xlt1.ptypes[index].ptg;
759 * ice_ptg_find_ptype - Search for packet type group using packet type (ptype)
775 *ptg = hw->blk[blk].xlt1.ptypes[ptype].ptg;
780 * ice_ptg_alloc_val - Allocates a new packet type group ID by value
790 hw->blk[blk].xlt1.ptg_tbl[ptg].in_use = true;
794 * ice_ptg_free - Frees a packet type group
806 hw->blk[blk].xlt1.ptg_tbl[ptg].in_use = false;
807 p = hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype;
809 p->ptg = ICE_DEFAULT_PTG;
810 temp = p->next_ptype;
811 p->next_ptype = NULL;
815 hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype = NULL;
819 * ice_ptg_remove_ptype - Removes ptype from a particular packet type group
834 if (ptype > ICE_XLT1_CNT - 1)
837 if (!hw->blk[blk].xlt1.ptg_tbl[ptg].in_use)
841 if (!hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype)
845 p = hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype;
846 ch = &hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype;
848 if (ptype == (p - hw->blk[blk].xlt1.ptypes)) {
849 *ch = p->next_ptype;
853 ch = &p->next_ptype;
854 p = p->next_ptype;
857 hw->blk[blk].xlt1.ptypes[ptype].ptg = ICE_DEFAULT_PTG;
858 hw->blk[blk].xlt1.ptypes[ptype].next_ptype = NULL;
864 * ice_ptg_add_mv_ptype - Adds/moves ptype to a particular packet type group
881 if (ptype > ICE_XLT1_CNT - 1)
884 if (!hw->blk[blk].xlt1.ptg_tbl[ptg].in_use && ptg != ICE_DEFAULT_PTG)
899 /* Moving to default PTG? Then we're done with this request */
904 hw->blk[blk].xlt1.ptypes[ptype].next_ptype =
905 hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype;
906 hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype =
907 &hw->blk[blk].xlt1.ptypes[ptype];
909 hw->blk[blk].xlt1.ptypes[ptype].ptg = ptg;
910 hw->blk[blk].xlt1.t[ptype] = ptg;
921 u8 prof_cdid_bits; /* # CDID one-hot bits used in key */
932 * XLT1 - Number of entries in XLT1 table
933 * XLT2 - Number of entries in XLT2 table
934 * TCAM - Number of entries Profile ID TCAM table
935 * CDID - Control Domain ID of the hardware block
936 * PRED - Number of entries in the Profile Redirection Table
937 * FV - Number of entries in the Field Vector
938 * FVW - Width (in WORDs) of the Field Vector
939 * OVR - Overwrite existing table entries
940 * REV - Reverse FV
968 * ice_match_prop_lst - determine if properties of two lists match
996 while (count--) {
997 if (tmp2->profile_cookie != tmp1->profile_cookie)
1010 * ice_vsig_update_xlt2_sect - update one section of XLT2 table
1033 sect->count = CPU_TO_LE16(1);
1034 sect->offset = CPU_TO_LE16(vsi);
1035 sect->value[0] = CPU_TO_LE16(vsig);
1045 * ice_vsig_update_xlt2 - update XLT2 table with VSIG configuration
1058 if (hw->blk[blk].xlt2.vsis[vsi].changed) {
1062 vsig = hw->blk[blk].xlt2.vsis[vsi].vsig;
1067 hw->blk[blk].xlt2.vsis[vsi].changed = 0;
1075 * ice_vsig_find_vsi - find a VSIG that contains a specified VSI
1092 * done by the following add, update or remove functions.
1094 *vsig = hw->blk[blk].xlt2.vsis[vsi].vsig;
1100 * ice_vsig_alloc_val - allocate a new VSIG by value
1111 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) {
1112 INIT_LIST_HEAD(&hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst);
1113 hw->blk[blk].xlt2.vsig_tbl[idx].in_use = true;
1116 return ICE_VSIG_VALUE(idx, hw->pf_id);
1120 * ice_vsig_alloc - Finds a free entry and allocates a new VSIG
1132 if (!hw->blk[blk].xlt2.vsig_tbl[i].in_use)
1139 * ice_find_dup_props_vsig - find VSI group with a specified set of properties
1157 struct ice_xlt2 *xlt2 = &hw->blk[blk].xlt2;
1160 for (i = 0; i < xlt2->count; i++)
1161 if (xlt2->vsig_tbl[i].in_use &&
1162 ice_match_prop_lst(chs, &xlt2->vsig_tbl[i].prop_lst)) {
1163 *vsig = ICE_VSIG_VALUE(i, hw->pf_id);
1171 * ice_vsig_free - free VSI group
1190 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use)
1193 hw->blk[blk].xlt2.vsig_tbl[idx].in_use = false;
1195 vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi;
1202 struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
1204 vsi_cur->vsig = ICE_DEFAULT_VSIG;
1205 vsi_cur->changed = 1;
1206 vsi_cur->next_vsi = NULL;
1211 hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = NULL;
1216 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst,
1218 LIST_DEL(&del->list);
1223 * re-initialize the list head
1225 INIT_LIST_HEAD(&hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst);
1231 * ice_vsig_remove_vsi - remove VSI from VSIG
1251 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use)
1258 vsi_head = &hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi;
1262 vsi_tgt = &hw->blk[blk].xlt2.vsis[vsi];
1268 (*vsi_head) = vsi_cur->next_vsi;
1271 vsi_head = &vsi_cur->next_vsi;
1272 vsi_cur = vsi_cur->next_vsi;
1279 vsi_cur->vsig = ICE_DEFAULT_VSIG;
1280 vsi_cur->changed = 1;
1281 vsi_cur->next_vsi = NULL;
1287 * ice_vsig_add_mv_vsi - add or move a VSI to a VSI group
1313 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use &&
1336 hw->blk[blk].xlt2.vsis[vsi].vsig = vsig;
1337 hw->blk[blk].xlt2.vsis[vsi].changed = 1;
1340 tmp = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi;
1341 hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi =
1342 &hw->blk[blk].xlt2.vsis[vsi];
1343 hw->blk[blk].xlt2.vsis[vsi].next_vsi = tmp;
1344 hw->blk[blk].xlt2.t[vsi] = vsig;
1350 * ice_find_prof_id - find profile ID for a given field vector
1360 struct ice_es *es = &hw->blk[blk].es;
1364 for (i = 0; i < (u8)es->count; i++) {
1365 off = i * es->fvw;
1367 if (memcmp(&es->t[off], fv, es->fvw * sizeof(*fv)))
1378 * ice_prof_id_rsrc_type - get profile ID resource type for a block type
1398 * ice_tcam_ent_rsrc_type - get TCAM entry resource type for a block type
1418 * ice_alloc_tcam_ent - allocate hardware TCAM entry
1440 * ice_free_tcam_ent - free hardware TCAM entry
1459 * ice_alloc_prof_id - allocate profile ID
1485 * ice_free_prof_id - free profile ID
1505 * ice_prof_inc_ref - increment reference count for profile
1513 if (prof_id > hw->blk[blk].es.count)
1516 hw->blk[blk].es.ref_count[prof_id]++;
1522 * ice_write_es - write an extraction sequence to hardware
1526 * @fv: pointer to the extraction sequence to write - NULL to clear extraction
1534 off = prof_id * hw->blk[blk].es.fvw;
1536 ice_memset(&hw->blk[blk].es.t[off], 0, hw->blk[blk].es.fvw *
1538 hw->blk[blk].es.written[prof_id] = false;
1540 ice_memcpy(&hw->blk[blk].es.t[off], fv, hw->blk[blk].es.fvw *
1546 * ice_prof_dec_ref - decrement reference count for profile
1554 if (prof_id > hw->blk[blk].es.count)
1557 if (hw->blk[blk].es.ref_count[prof_id] > 0) {
1558 if (!--hw->blk[blk].es.ref_count[prof_id]) {
1611 * ice_init_sw_xlt1_db - init software XLT1 database from HW tables
1619 for (pt = 0; pt < hw->blk[blk].xlt1.count; pt++) {
1622 ptg = hw->blk[blk].xlt1.t[pt];
1631 * ice_init_sw_xlt2_db - init software XLT2 database from HW tables
1639 for (vsi = 0; vsi < hw->blk[blk].xlt2.count; vsi++) {
1642 vsig = hw->blk[blk].xlt2.t[vsi];
1649 hw->blk[blk].xlt2.vsis[vsi].changed = 0;
1655 * ice_init_sw_db - init software database from HW tables
1669 * ice_fill_tbl - Reads content of a single table type into database
1696 if (!hw->seg) {
1697 ice_debug(hw, ICE_DBG_PKG, "hw->seg is NULL, tables are not filled\n");
1703 sect = ice_pkg_enum_section(hw->seg, &state, sid);
1713 src = xlt1->value;
1714 sect_len = LE16_TO_CPU(xlt1->count) *
1715 sizeof(*hw->blk[block_id].xlt1.t);
1716 dst = hw->blk[block_id].xlt1.t;
1717 dst_len = hw->blk[block_id].xlt1.count *
1718 sizeof(*hw->blk[block_id].xlt1.t);
1726 src = (_FORCE_ u8 *)xlt2->value;
1727 sect_len = LE16_TO_CPU(xlt2->count) *
1728 sizeof(*hw->blk[block_id].xlt2.t);
1729 dst = (u8 *)hw->blk[block_id].xlt2.t;
1730 dst_len = hw->blk[block_id].xlt2.count *
1731 sizeof(*hw->blk[block_id].xlt2.t);
1739 src = (u8 *)pid->entry;
1740 sect_len = LE16_TO_CPU(pid->count) *
1741 sizeof(*hw->blk[block_id].prof.t);
1742 dst = (u8 *)hw->blk[block_id].prof.t;
1743 dst_len = hw->blk[block_id].prof.count *
1744 sizeof(*hw->blk[block_id].prof.t);
1752 src = pr->redir_value;
1753 sect_len = LE16_TO_CPU(pr->count) *
1754 sizeof(*hw->blk[block_id].prof_redir.t);
1755 dst = hw->blk[block_id].prof_redir.t;
1756 dst_len = hw->blk[block_id].prof_redir.count *
1757 sizeof(*hw->blk[block_id].prof_redir.t);
1765 src = (u8 *)es->fv;
1766 sect_len = (u32)(LE16_TO_CPU(es->count) *
1767 hw->blk[block_id].es.fvw) *
1768 sizeof(*hw->blk[block_id].es.t);
1769 dst = (u8 *)hw->blk[block_id].es.t;
1770 dst_len = (u32)(hw->blk[block_id].es.count *
1771 hw->blk[block_id].es.fvw) *
1772 sizeof(*hw->blk[block_id].es.t);
1790 sect_len = dst_len - offset;
1799 * ice_init_flow_profs - init flow profile locks and list heads
1806 ice_init_lock(&hw->fl_profs_locks[blk_idx]);
1807 INIT_LIST_HEAD(&hw->fl_profs[blk_idx]);
1811 * ice_init_hw_tbls - init hardware table memory
1818 ice_init_lock(&hw->rss_locks);
1819 INIT_LIST_HEAD(&hw->rss_list_head);
1821 struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
1822 struct ice_prof_tcam *prof = &hw->blk[i].prof;
1823 struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
1824 struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
1825 struct ice_es *es = &hw->blk[i].es;
1828 if (hw->blk[i].is_list_init)
1832 ice_init_lock(&es->prof_map_lock);
1833 INIT_LIST_HEAD(&es->prof_map);
1834 hw->blk[i].is_list_init = true;
1836 hw->blk[i].overwrite = blk_sizes[i].overwrite;
1837 es->reverse = blk_sizes[i].reverse;
1839 xlt1->sid = ice_blk_sids[i][ICE_SID_XLT1_OFF];
1840 xlt1->count = blk_sizes[i].xlt1;
1842 xlt1->ptypes = (struct ice_ptg_ptype *)
1843 ice_calloc(hw, xlt1->count, sizeof(*xlt1->ptypes));
1845 if (!xlt1->ptypes)
1848 xlt1->ptg_tbl = (struct ice_ptg_entry *)
1849 ice_calloc(hw, ICE_MAX_PTGS, sizeof(*xlt1->ptg_tbl));
1851 if (!xlt1->ptg_tbl)
1854 xlt1->t = (u8 *)ice_calloc(hw, xlt1->count, sizeof(*xlt1->t));
1855 if (!xlt1->t)
1858 xlt2->sid = ice_blk_sids[i][ICE_SID_XLT2_OFF];
1859 xlt2->count = blk_sizes[i].xlt2;
1861 xlt2->vsis = (struct ice_vsig_vsi *)
1862 ice_calloc(hw, xlt2->count, sizeof(*xlt2->vsis));
1864 if (!xlt2->vsis)
1867 xlt2->vsig_tbl = (struct ice_vsig_entry *)
1868 ice_calloc(hw, xlt2->count, sizeof(*xlt2->vsig_tbl));
1869 if (!xlt2->vsig_tbl)
1872 for (j = 0; j < xlt2->count; j++)
1873 INIT_LIST_HEAD(&xlt2->vsig_tbl[j].prop_lst);
1875 xlt2->t = (u16 *)ice_calloc(hw, xlt2->count, sizeof(*xlt2->t));
1876 if (!xlt2->t)
1879 prof->sid = ice_blk_sids[i][ICE_SID_PR_OFF];
1880 prof->count = blk_sizes[i].prof_tcam;
1881 prof->max_prof_id = blk_sizes[i].prof_id;
1882 prof->cdid_bits = blk_sizes[i].prof_cdid_bits;
1883 prof->t = (struct ice_prof_tcam_entry *)
1884 ice_calloc(hw, prof->count, sizeof(*prof->t));
1886 if (!prof->t)
1889 prof_redir->sid = ice_blk_sids[i][ICE_SID_PR_REDIR_OFF];
1890 prof_redir->count = blk_sizes[i].prof_redir;
1891 prof_redir->t = (u8 *)ice_calloc(hw, prof_redir->count,
1892 sizeof(*prof_redir->t));
1894 if (!prof_redir->t)
1897 es->sid = ice_blk_sids[i][ICE_SID_ES_OFF];
1898 es->count = blk_sizes[i].es;
1899 es->fvw = blk_sizes[i].fvw;
1900 es->t = (struct ice_fv_word *)
1901 ice_calloc(hw, (u32)(es->count * es->fvw),
1902 sizeof(*es->t));
1903 if (!es->t)
1906 es->ref_count = (u16 *)
1907 ice_calloc(hw, es->count, sizeof(*es->ref_count));
1909 if (!es->ref_count)
1912 es->written = (u8 *)
1913 ice_calloc(hw, es->count, sizeof(*es->written));
1915 if (!es->written)
1927 * ice_fill_blk_tbls - Read package context for tables
1941 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].xlt1.sid);
1942 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].xlt2.sid);
1943 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].prof.sid);
1944 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].prof_redir.sid);
1945 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].es.sid);
1952 * ice_free_prof_map - free profile map
1958 struct ice_es *es = &hw->blk[blk_idx].es;
1961 ice_acquire_lock(&es->prof_map_lock);
1962 LIST_FOR_EACH_ENTRY_SAFE(del, tmp, &es->prof_map,
1964 LIST_DEL(&del->list);
1967 INIT_LIST_HEAD(&es->prof_map);
1968 ice_release_lock(&es->prof_map_lock);
1972 * ice_free_flow_profs - free flow profile entries
1980 ice_acquire_lock(&hw->fl_profs_locks[blk_idx]);
1981 LIST_FOR_EACH_ENTRY_SAFE(p, tmp, &hw->fl_profs[blk_idx],
1983 LIST_DEL(&p->l_entry);
1987 ice_release_lock(&hw->fl_profs_locks[blk_idx]);
1990 * re-initialize the flow profile list heads
1992 INIT_LIST_HEAD(&hw->fl_profs[blk_idx]);
1996 * ice_free_vsig_tbl - free complete VSIG table entries
2004 if (!hw->blk[blk].xlt2.vsig_tbl)
2008 if (hw->blk[blk].xlt2.vsig_tbl[i].in_use)
2013 * ice_free_hw_tbls - free hardware table memory
2022 if (hw->blk[i].is_list_init) {
2023 struct ice_es *es = &hw->blk[i].es;
2026 ice_destroy_lock(&es->prof_map_lock);
2029 ice_destroy_lock(&hw->fl_profs_locks[i]);
2031 hw->blk[i].is_list_init = false;
2034 ice_free(hw, hw->blk[i].xlt1.ptypes);
2035 ice_free(hw, hw->blk[i].xlt1.ptg_tbl);
2036 ice_free(hw, hw->blk[i].xlt1.t);
2037 ice_free(hw, hw->blk[i].xlt2.t);
2038 ice_free(hw, hw->blk[i].xlt2.vsig_tbl);
2039 ice_free(hw, hw->blk[i].xlt2.vsis);
2040 ice_free(hw, hw->blk[i].prof.t);
2041 ice_free(hw, hw->blk[i].prof_redir.t);
2042 ice_free(hw, hw->blk[i].es.t);
2043 ice_free(hw, hw->blk[i].es.ref_count);
2044 ice_free(hw, hw->blk[i].es.written);
2047 LIST_FOR_EACH_ENTRY_SAFE(r, rt, &hw->rss_list_head,
2049 LIST_DEL(&r->l_entry);
2052 ice_destroy_lock(&hw->rss_locks);
2053 ice_memset(hw->blk, 0, sizeof(hw->blk), ICE_NONDMA_MEM);
2057 * ice_clear_hw_tbls - clear HW tables and flow profiles
2065 struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir;
2066 struct ice_prof_tcam *prof = &hw->blk[i].prof;
2067 struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1;
2068 struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2;
2069 struct ice_es *es = &hw->blk[i].es;
2071 if (hw->blk[i].is_list_init) {
2078 if (xlt1->ptypes)
2079 ice_memset(xlt1->ptypes, 0,
2080 xlt1->count * sizeof(*xlt1->ptypes),
2083 if (xlt1->ptg_tbl)
2084 ice_memset(xlt1->ptg_tbl, 0,
2085 ICE_MAX_PTGS * sizeof(*xlt1->ptg_tbl),
2088 if (xlt1->t)
2089 ice_memset(xlt1->t, 0, xlt1->count * sizeof(*xlt1->t),
2092 if (xlt2->vsis)
2093 ice_memset(xlt2->vsis, 0,
2094 xlt2->count * sizeof(*xlt2->vsis),
2097 if (xlt2->vsig_tbl)
2098 ice_memset(xlt2->vsig_tbl, 0,
2099 xlt2->count * sizeof(*xlt2->vsig_tbl),
2102 if (xlt2->t)
2103 ice_memset(xlt2->t, 0, xlt2->count * sizeof(*xlt2->t),
2106 if (prof->t)
2107 ice_memset(prof->t, 0, prof->count * sizeof(*prof->t),
2110 if (prof_redir->t)
2111 ice_memset(prof_redir->t, 0,
2112 prof_redir->count * sizeof(*prof_redir->t),
2115 if (es->t)
2116 ice_memset(es->t, 0,
2117 es->count * sizeof(*es->t) * es->fvw,
2120 if (es->ref_count)
2121 ice_memset(es->ref_count, 0,
2122 es->count * sizeof(*es->ref_count),
2125 if (es->written)
2126 ice_memset(es->written, 0,
2127 es->count * sizeof(*es->written),
2134 * ice_prof_gen_key - generate profile ID key
2158 switch (hw->blk[blk].prof.cdid_bits) {
2189 * ice_tcam_write_entry - write TCAM entry
2213 dc_msk, nm_msk, hw->blk[blk].prof.t[idx].key);
2215 hw->blk[blk].prof.t[idx].addr = CPU_TO_LE16(idx);
2216 hw->blk[blk].prof.t[idx].prof_id = prof_id;
2223 * ice_vsig_get_ref - returns number of VSIs belong to a VSIG
2237 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use)
2240 ptr = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi;
2243 ptr = ptr->next_vsi;
2250 * ice_has_prof_vsig - check to see if VSIG has a specific profile
2262 LIST_FOR_EACH_ENTRY(ent, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst,
2264 if (ent->profile_cookie == hdl)
2273 * ice_prof_bld_es - build profile ID extraction sequence changes
2283 u16 vec_size = hw->blk[blk].es.fvw * sizeof(struct ice_fv_word);
2287 if (tmp->type == ICE_PTG_ES_ADD && tmp->add_prof) {
2288 u16 off = tmp->prof_id * hw->blk[blk].es.fvw;
2297 vec_size -
2298 sizeof(p->es[0]));
2303 p->count = CPU_TO_LE16(1);
2304 p->offset = CPU_TO_LE16(tmp->prof_id);
2306 ice_memcpy(p->es, &hw->blk[blk].es.t[off], vec_size,
2314 * ice_prof_bld_tcam - build profile ID TCAM changes
2327 if (tmp->type == ICE_TCAM_ADD && tmp->add_tcam_idx) {
2341 p->count = CPU_TO_LE16(1);
2342 p->entry[0].addr = CPU_TO_LE16(tmp->tcam_idx);
2343 p->entry[0].prof_id = tmp->prof_id;
2345 ice_memcpy(p->entry[0].key,
2346 &hw->blk[blk].prof.t[tmp->tcam_idx].key,
2347 sizeof(hw->blk[blk].prof.t->key),
2355 * ice_prof_bld_xlt1 - build XLT1 changes
2367 if (tmp->type == ICE_PTG_ES_ADD && tmp->add_ptg) {
2381 p->count = CPU_TO_LE16(1);
2382 p->offset = CPU_TO_LE16(tmp->ptype);
2383 p->value[0] = tmp->ptg;
2390 * ice_prof_bld_xlt2 - build XLT2 changes
2405 switch (tmp->type) {
2419 p->count = CPU_TO_LE16(1);
2420 p->offset = CPU_TO_LE16(tmp->vsi);
2421 p->value[0] = CPU_TO_LE16(tmp->vsig);
2432 * ice_upd_prof_hw - update hardware using the change list
2453 switch (tmp->type) {
2455 if (tmp->add_ptg)
2457 if (tmp->add_prof)
2512 * non-zero and matches the number of sections detected for package
2532 * ice_add_prof - add profile
2556 ice_acquire_lock(&hw->blk[blk].es.prof_map_lock);
2578 prof->profile_cookie = id;
2579 prof->prof_id = prof_id;
2580 prof->ptg_cnt = 0;
2581 prof->context = 0;
2587 /* The package should place all ptypes in a non-zero
2598 prof->ptg[prof->ptg_cnt] = ptg;
2600 if (++prof->ptg_cnt >= ICE_MAX_PTG_PER_PROFILE)
2604 LIST_ADD(&prof->list, &hw->blk[blk].es.prof_map);
2608 ice_release_lock(&hw->blk[blk].es.prof_map_lock);
2613 * ice_search_prof_id - Search for a profile tracking ID
2627 LIST_FOR_EACH_ENTRY(map, &hw->blk[blk].es.prof_map, ice_prof_map, list)
2628 if (map->profile_cookie == id) {
2637 * ice_set_prof_context - Set context for a given profile
2649 ice_acquire_lock(&hw->blk[blk].es.prof_map_lock);
2652 entry->context = cntxt;
2655 ice_release_lock(&hw->blk[blk].es.prof_map_lock);
2660 * ice_get_prof_context - Get context for a given profile
2672 ice_acquire_lock(&hw->blk[blk].es.prof_map_lock);
2675 *cntxt = entry->context;
2678 ice_release_lock(&hw->blk[blk].es.prof_map_lock);
2683 * ice_vsig_prof_id_count - count profiles in a VSIG
2694 LIST_FOR_EACH_ENTRY(p, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst,
2702 * ice_rel_tcam_idx - release a TCAM index
2729 * ice_rem_prof_id - remove one profile from a VSIG
2741 for (i = 0; i < prof->tcam_count; i++)
2742 if (prof->tcam[i].in_use) {
2743 prof->tcam[i].in_use = false;
2745 prof->tcam[i].tcam_idx);
2754 * ice_rem_vsig - remove VSIG
2758 * @chg: the change list
2762 struct LIST_HEAD_TYPE *chg)
2770 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst,
2778 LIST_DEL(&d->list);
2783 vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi;
2789 struct ice_vsig_vsi *tmp = vsi_cur->next_vsi;
2796 p->type = ICE_VSIG_REM;
2797 p->orig_vsig = vsig;
2798 p->vsig = ICE_DEFAULT_VSIG;
2799 p->vsi = (u16)(vsi_cur - hw->blk[blk].xlt2.vsis);
2801 LIST_ADD(&p->list_entry, chg);
2810 * ice_rem_prof_id_vsig - remove a specific profile from a VSIG
2815 * @chg: list to receive a record of changes
2819 struct LIST_HEAD_TYPE *chg)
2825 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst,
2827 if (p->profile_cookie == hdl) {
2832 return ice_rem_vsig(hw, blk, vsig, chg);
2836 LIST_DEL(&p->list);
2846 * ice_rem_flow_all - remove all flows with a particular profile
2855 struct LIST_HEAD_TYPE chg;
2859 INIT_LIST_HEAD(&chg);
2862 if (hw->blk[blk].xlt2.vsig_tbl[i].in_use) {
2865 &chg);
2871 status = ice_upd_prof_hw(hw, blk, &chg);
2874 LIST_FOR_EACH_ENTRY_SAFE(del, tmp, &chg, ice_chs_chg, list_entry) {
2875 LIST_DEL(&del->list_entry);
2883 * ice_rem_prof - remove profile
2897 ice_acquire_lock(&hw->blk[blk].es.prof_map_lock);
2906 status = ice_rem_flow_all(hw, blk, pmap->profile_cookie);
2911 ice_prof_dec_ref(hw, blk, pmap->prof_id);
2913 LIST_DEL(&pmap->list);
2917 ice_release_lock(&hw->blk[blk].es.prof_map_lock);
2922 * ice_get_prof - get profile
2926 * @chg: change list
2930 struct LIST_HEAD_TYPE *chg)
2937 ice_acquire_lock(&hw->blk[blk].es.prof_map_lock);
2945 for (i = 0; i < map->ptg_cnt; i++)
2946 if (!hw->blk[blk].es.written[map->prof_id]) {
2954 p->type = ICE_PTG_ES_ADD;
2955 p->ptype = 0;
2956 p->ptg = map->ptg[i];
2957 p->add_ptg = 0;
2959 p->add_prof = 1;
2960 p->prof_id = map->prof_id;
2962 hw->blk[blk].es.written[map->prof_id] = true;
2964 LIST_ADD(&p->list_entry, chg);
2968 ice_release_lock(&hw->blk[blk].es.prof_map_lock);
2974 * ice_get_profs_vsig - get a copy of the list of profiles from a VSIG
2989 LIST_FOR_EACH_ENTRY(ent1, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst,
2999 LIST_ADD_TAIL(&p->list, lst);
3006 LIST_DEL(&ent1->list);
3014 * ice_add_prof_to_lst - add profile entry to a list
3029 ice_acquire_lock(&hw->blk[blk].es.prof_map_lock);
3042 p->profile_cookie = map->profile_cookie;
3043 p->prof_id = map->prof_id;
3044 p->tcam_count = map->ptg_cnt;
3046 for (i = 0; i < map->ptg_cnt; i++) {
3047 p->tcam[i].prof_id = map->prof_id;
3048 p->tcam[i].tcam_idx = ICE_INVALID_TCAM;
3049 p->tcam[i].ptg = map->ptg[i];
3052 LIST_ADD(&p->list, lst);
3055 ice_release_lock(&hw->blk[blk].es.prof_map_lock);
3060 * ice_move_vsi - move VSI to another VSIG
3065 * @chg: the change list
3069 struct LIST_HEAD_TYPE *chg)
3088 p->type = ICE_VSI_MOVE;
3089 p->vsi = vsi;
3090 p->orig_vsig = orig_vsig;
3091 p->vsig = vsig;
3093 LIST_ADD(&p->list_entry, chg);
3099 * ice_rem_chg_tcam_ent - remove a specific TCAM entry from change list
3102 * @chg: the list of change structures to search
3105 ice_rem_chg_tcam_ent(struct ice_hw *hw, u16 idx, struct LIST_HEAD_TYPE *chg)
3109 LIST_FOR_EACH_ENTRY_SAFE(tmp, pos, chg, ice_chs_chg, list_entry)
3110 if (tmp->type == ICE_TCAM_ADD && tmp->tcam_idx == idx) {
3111 LIST_DEL(&tmp->list_entry);
3117 * ice_prof_tcam_ena_dis - add enable or disable TCAM change
3123 * @chg: the change list
3130 struct LIST_HEAD_TYPE *chg)
3141 status = ice_rel_tcam_idx(hw, blk, tcam->tcam_idx);
3147 ice_rem_chg_tcam_ent(hw, tcam->tcam_idx, chg);
3148 tcam->tcam_idx = 0;
3149 tcam->in_use = 0;
3153 /* for re-enabling, reallocate a TCAM */
3154 status = ice_alloc_tcam_ent(hw, blk, true, &tcam->tcam_idx);
3163 status = ice_tcam_write_entry(hw, blk, tcam->tcam_idx, tcam->prof_id,
3164 tcam->ptg, vsig, 0, 0, vl_msk, dc_msk,
3169 tcam->in_use = 1;
3171 p->type = ICE_TCAM_ADD;
3172 p->add_tcam_idx = true;
3173 p->prof_id = tcam->prof_id;
3174 p->ptg = tcam->ptg;
3175 p->vsig = 0;
3176 p->tcam_idx = tcam->tcam_idx;
3179 LIST_ADD(&p->list_entry, chg);
3189 * ice_adj_prof_priorities - adjust profile based on priorities
3193 * @chg: the change list
3197 struct LIST_HEAD_TYPE *chg)
3216 LIST_FOR_EACH_ENTRY(t, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst,
3220 for (i = 0; i < t->tcam_count; i++) {
3226 used = ice_is_bit_set(ptgs_used, t->tcam[i].ptg);
3228 if (used && t->tcam[i].in_use) {
3235 &t->tcam[i],
3236 chg);
3239 } else if (!used && !t->tcam[i].in_use) {
3245 &t->tcam[i],
3246 chg);
3252 ice_set_bit(t->tcam[i].ptg, ptgs_used);
3260 * ice_add_prof_id_vsig - add profile to VSIG
3266 * @chg: the change list
3270 bool rev, struct LIST_HEAD_TYPE *chg)
3291 ice_acquire_lock(&hw->blk[blk].es.prof_map_lock);
3299 t->profile_cookie = map->profile_cookie;
3300 t->prof_id = map->prof_id;
3301 t->tcam_count = map->ptg_cnt;
3304 for (i = 0; i < map->ptg_cnt; i++) {
3321 t->tcam[i].ptg = map->ptg[i];
3322 t->tcam[i].prof_id = map->prof_id;
3323 t->tcam[i].tcam_idx = tcam_idx;
3324 t->tcam[i].in_use = true;
3326 p->type = ICE_TCAM_ADD;
3327 p->add_tcam_idx = true;
3328 p->prof_id = t->tcam[i].prof_id;
3329 p->ptg = t->tcam[i].ptg;
3330 p->vsig = vsig;
3331 p->tcam_idx = t->tcam[i].tcam_idx;
3334 status = ice_tcam_write_entry(hw, blk, t->tcam[i].tcam_idx,
3335 t->tcam[i].prof_id,
3336 t->tcam[i].ptg, vsig, 0, 0,
3344 LIST_ADD(&p->list_entry, chg);
3350 LIST_ADD_TAIL(&t->list,
3351 &hw->blk[blk].xlt2.vsig_tbl[vsig_idx].prop_lst);
3353 LIST_ADD(&t->list,
3354 &hw->blk[blk].xlt2.vsig_tbl[vsig_idx].prop_lst);
3356 ice_release_lock(&hw->blk[blk].es.prof_map_lock);
3360 ice_release_lock(&hw->blk[blk].es.prof_map_lock);
3367 * ice_create_prof_id_vsig - add a new VSIG with a single profile
3372 * @chg: the change list
3376 struct LIST_HEAD_TYPE *chg)
3392 status = ice_move_vsi(hw, blk, vsi, new_vsig, chg);
3396 status = ice_add_prof_id_vsig(hw, blk, new_vsig, hdl, false, chg);
3400 p->type = ICE_VSIG_ADD;
3401 p->vsi = vsi;
3402 p->orig_vsig = ICE_DEFAULT_VSIG;
3403 p->vsig = new_vsig;
3405 LIST_ADD(&p->list_entry, chg);
3416 * ice_create_vsig_from_lst - create a new VSIG with a list of profiles
3422 * @chg: the change list
3427 struct LIST_HEAD_TYPE *chg)
3437 status = ice_move_vsi(hw, blk, vsi, vsig, chg);
3443 status = ice_add_prof_id_vsig(hw, blk, vsig, t->profile_cookie,
3444 true, chg);
3455 * ice_find_prof_vsig - find a VSIG with a specific profile handle
3474 t->profile_cookie = hdl;
3475 LIST_ADD(&t->list, &lst);
3479 LIST_DEL(&t->list);
3486 * ice_add_vsi_flow - add VSI flow
3503 struct LIST_HEAD_TYPE chg;
3510 INIT_LIST_HEAD(&chg);
3513 status = ice_move_vsi(hw, blk, vsi, vsig, &chg);
3516 status = ice_upd_prof_hw(hw, blk, &chg);
3518 LIST_FOR_EACH_ENTRY_SAFE(del, tmp, &chg, ice_chs_chg, list_entry) {
3519 LIST_DEL(&del->list_entry);
3527 * ice_add_prof_id_flow - add profile flow
3543 struct LIST_HEAD_TYPE chg;
3548 INIT_LIST_HEAD(&chg);
3551 status = ice_get_prof(hw, blk, hdl, &chg);
3595 status = ice_move_vsi(hw, blk, vsi, vsig, &chg);
3603 status = ice_rem_vsig(hw, blk, or_vsig, &chg);
3614 &chg);
3619 status = ice_adj_prof_priorities(hw, blk, vsig, &chg);
3626 &chg);
3631 status = ice_adj_prof_priorities(hw, blk, vsig, &chg);
3641 status = ice_move_vsi(hw, blk, vsi, vsig, &chg);
3648 &chg);
3656 status = ice_upd_prof_hw(hw, blk, &chg);
3659 LIST_FOR_EACH_ENTRY_SAFE(del, tmp, &chg, ice_chs_chg, list_entry) {
3660 LIST_DEL(&del->list_entry);
3665 LIST_DEL(&del1->list);
3673 * ice_add_flow - add flow
3702 * ice_rem_prof_from_list - remove a profile from list
3713 if (ent->profile_cookie == hdl) {
3714 LIST_DEL(&ent->list);
3723 * ice_rem_prof_id_flow - remove flow
3738 struct LIST_HEAD_TYPE chg, copy;
3743 INIT_LIST_HEAD(&chg);
3770 status = ice_rem_vsig(hw, blk, vsig, &chg);
3775 hdl, &chg);
3781 &chg);
3799 ICE_DEFAULT_VSIG, &chg);
3812 status = ice_move_vsi(hw, blk, vsi, vsig, &chg);
3822 &chg);
3828 &chg);
3839 status = ice_upd_prof_hw(hw, blk, &chg);
3842 LIST_FOR_EACH_ENTRY_SAFE(del, tmp, &chg, ice_chs_chg, list_entry) {
3843 LIST_DEL(&del->list_entry);
3848 LIST_DEL(&del1->list);
3856 * ice_rem_flow - remove flow