Lines Matching +full:tcam +full:- +full:based
1 // SPDX-License-Identifier: GPL-2.0
85 * ice_sect_id - returns section ID
109 hdr = (struct ice_buf_hdr *)buf->buf; in ice_pkg_val_buf()
111 section_count = le16_to_cpu(hdr->section_count); in ice_pkg_val_buf()
115 data_end = le16_to_cpu(hdr->data_end); in ice_pkg_val_buf()
133 (ice_seg->device_table + in ice_find_buf_table()
134 le32_to_cpu(ice_seg->device_table_count)); in ice_find_buf_table()
137 (nvms->vers + le32_to_cpu(nvms->table_count)); in ice_find_buf_table()
146 * call is made with the ice_seg parameter non-NULL; on subsequent calls,
156 state->buf_table = ice_find_buf_table(ice_seg); in ice_pkg_enum_buf()
157 if (!state->buf_table) in ice_pkg_enum_buf()
160 state->buf_idx = 0; in ice_pkg_enum_buf()
161 return ice_pkg_val_buf(state->buf_table->buf_array); in ice_pkg_enum_buf()
164 if (++state->buf_idx < le32_to_cpu(state->buf_table->buf_count)) in ice_pkg_enum_buf()
165 return ice_pkg_val_buf(state->buf_table->buf_array + in ice_pkg_enum_buf()
166 state->buf_idx); in ice_pkg_enum_buf()
182 if (!ice_seg && !state->buf) in ice_pkg_advance_sect()
185 if (!ice_seg && state->buf) in ice_pkg_advance_sect()
186 if (++state->sect_idx < le16_to_cpu(state->buf->section_count)) in ice_pkg_advance_sect()
189 state->buf = ice_pkg_enum_buf(ice_seg, state); in ice_pkg_advance_sect()
190 if (!state->buf) in ice_pkg_advance_sect()
194 state->sect_idx = 0; in ice_pkg_advance_sect()
205 * ice segment. The first call is made with the ice_seg parameter non-NULL;
217 state->type = sect_type; in ice_pkg_enum_section()
223 while (state->buf->section_entry[state->sect_idx].type != in ice_pkg_enum_section()
224 cpu_to_le32(state->type)) in ice_pkg_enum_section()
229 offset = le16_to_cpu(state->buf->section_entry[state->sect_idx].offset); in ice_pkg_enum_section()
233 size = le16_to_cpu(state->buf->section_entry[state->sect_idx].size); in ice_pkg_enum_section()
241 state->sect_type = in ice_pkg_enum_section()
242 le32_to_cpu(state->buf->section_entry[state->sect_idx].type); in ice_pkg_enum_section()
245 state->sect = ((u8 *)state->buf) + in ice_pkg_enum_section()
246 le16_to_cpu(state->buf->section_entry[state->sect_idx].offset); in ice_pkg_enum_section()
248 return state->sect; in ice_pkg_enum_section()
260 * the ice segment. The first call is made with the ice_seg parameter non-NULL;
291 state->entry_idx = 0; in ice_pkg_enum_entry()
292 state->handler = handler; in ice_pkg_enum_entry()
294 state->entry_idx++; in ice_pkg_enum_entry()
297 if (!state->handler) in ice_pkg_enum_entry()
301 entry = state->handler(state->sect_type, state->sect, state->entry_idx, in ice_pkg_enum_entry()
308 state->entry_idx = 0; in ice_pkg_enum_entry()
309 entry = state->handler(state->sect_type, state->sect, in ice_pkg_enum_entry()
310 state->entry_idx, offset); in ice_pkg_enum_entry()
320 * @index: index of the boost TCAM entry to be returned
321 * @offset: pointer to receive absolute offset, always 0 for boost TCAM sections
324 * Handles enumeration of individual boost TCAM entries.
344 if (index >= le16_to_cpu(boost->count)) in ice_boost_tcam_handler()
347 return boost->tcam + index; in ice_boost_tcam_handler()
352 * @ice_seg: pointer to the ice segment (non-NULL)
353 * @addr: Boost TCAM address of entry to search for
356 * Finds a particular Boost TCAM entry and returns a pointer to that entry
364 struct ice_boost_tcam_entry *tcam; in ice_find_boost_entry() local
373 tcam = ice_pkg_enum_entry(ice_seg, &state, in ice_find_boost_entry()
376 if (tcam && le16_to_cpu(tcam->addr) == addr) { in ice_find_boost_entry()
377 *entry = tcam; in ice_find_boost_entry()
382 } while (tcam); in ice_find_boost_entry()
414 if (index >= le16_to_cpu(labels->count)) in ice_label_enum_handler()
417 return labels->label + index; in ice_label_enum_handler()
447 *value = le16_to_cpu(label->value); in ice_enum_labels()
448 return label->name; in ice_enum_labels()
454 * @ice_seg: pointer to the segment of the package scan (non-NULL)
468 memset(&hw->tnl, 0, sizeof(hw->tnl)); in ice_init_pkg_hints()
477 while (label_name && hw->tnl.count < ICE_TUNNEL_MAX_ENTRIES) { in ice_init_pkg_hints()
486 * character ('0' - '7') will be located where our in ice_init_pkg_hints()
489 if ((label_name[len] - '0') == hw->pf_id) { in ice_init_pkg_hints()
490 hw->tnl.tbl[hw->tnl.count].type = tnls[i].type; in ice_init_pkg_hints()
491 hw->tnl.tbl[hw->tnl.count].valid = false; in ice_init_pkg_hints()
492 hw->tnl.tbl[hw->tnl.count].boost_addr = val; in ice_init_pkg_hints()
493 hw->tnl.tbl[hw->tnl.count].port = 0; in ice_init_pkg_hints()
494 hw->tnl.count++; in ice_init_pkg_hints()
502 /* Cache the appropriate boost TCAM entry pointers */ in ice_init_pkg_hints()
503 for (i = 0; i < hw->tnl.count; i++) { in ice_init_pkg_hints()
504 ice_find_boost_entry(ice_seg, hw->tnl.tbl[i].boost_addr, in ice_init_pkg_hints()
505 &hw->tnl.tbl[i].boost_entry); in ice_init_pkg_hints()
506 if (hw->tnl.tbl[i].boost_entry) { in ice_init_pkg_hints()
507 hw->tnl.tbl[i].valid = true; in ice_init_pkg_hints()
508 if (hw->tnl.tbl[i].type < __TNL_TYPE_CNT) in ice_init_pkg_hints()
509 hw->tnl.valid_count[hw->tnl.tbl[i].type]++; in ice_init_pkg_hints()
526 * ice_gen_key_word - generate 16-bits of a key/mask word
534 * This function generates 16-bits from a 8-bit value, an 8-bit don't care mask
535 * and an 8-bit never match mask. The 16-bits of output are divided into 8 bits
547 * ------------------------------
564 /* encode the 8 bits into 8-bit key and 8-bit key invert */ in ice_gen_key_word()
598 * ice_bits_max_set - determine if the number of bits set is within a maximum
635 * ice_set_key - generate a variable sized key with multiples of 16-bits
638 * @val: array of 8-bit values that makes up the value portion of the key
639 * @upd: array of 8-bit masks that determine what key portion to update
640 * @dc: array of 8-bit masks that make up the don't care mask
641 * @nm: array of 8-bit masks that make up the never match mask
648 * upd == NULL --> upd mask is all 1's (update all bits)
649 * dc == NULL --> dc mask is all 0's (no don't care bits)
650 * nm == NULL --> nm mask is all 0's (no never match bits)
693 * ICE_SUCCESS - Means the caller has acquired the global config lock
695 * ICE_ERR_AQ_NO_WORK - Indicates another driver has already written the
786 cmd->flags |= ICE_AQC_DOWNLOAD_PKG_LAST_BUF; in ice_aq_download_pkg()
795 *error_offset = le32_to_cpu(resp->error_offset); in ice_aq_download_pkg()
797 *error_info = le32_to_cpu(resp->error_info); in ice_aq_download_pkg()
834 cmd->flags |= ICE_AQC_DOWNLOAD_PKG_LAST_BUF; in ice_aq_update_pkg()
843 *error_offset = le32_to_cpu(resp->error_offset); in ice_aq_update_pkg()
845 *error_info = le32_to_cpu(resp->error_info); in ice_aq_update_pkg()
868 pkg_hdr->pkg_format_ver.major, pkg_hdr->pkg_format_ver.minor, in ice_find_seg_in_pkg()
869 pkg_hdr->pkg_format_ver.update, in ice_find_seg_in_pkg()
870 pkg_hdr->pkg_format_ver.draft); in ice_find_seg_in_pkg()
873 for (i = 0; i < le32_to_cpu(pkg_hdr->seg_count); i++) { in ice_find_seg_in_pkg()
877 ((u8 *)pkg_hdr + le32_to_cpu(pkg_hdr->seg_offset[i])); in ice_find_seg_in_pkg()
879 if (le32_to_cpu(seg->seg_type) == seg_type) in ice_find_seg_in_pkg()
908 status = ice_aq_update_pkg(hw, bh, le16_to_cpu(bh->data_end), in ice_update_pkg()
949 if (le32_to_cpu(bh->section_entry[0].type) & ICE_METADATA_BUF) in ice_dwnld_cfg_bufs()
955 hw->pkg_dwnld_status = ICE_AQ_RC_OK; in ice_dwnld_cfg_bufs()
960 hw->pkg_dwnld_status = ICE_AQ_RC_EEXIST; in ice_dwnld_cfg_bufs()
962 hw->pkg_dwnld_status = hw->adminq.sq_last_status; in ice_dwnld_cfg_bufs()
977 if (le16_to_cpu(bh->section_count)) in ice_dwnld_cfg_bufs()
978 if (le32_to_cpu(bh->section_entry[0].type) & in ice_dwnld_cfg_bufs()
989 hw->pkg_dwnld_status = hw->adminq.sq_last_status; in ice_dwnld_cfg_bufs()
1041 ice_seg->hdr.seg_format_ver.major, in ice_download_pkg()
1042 ice_seg->hdr.seg_format_ver.minor, in ice_download_pkg()
1043 ice_seg->hdr.seg_format_ver.update, in ice_download_pkg()
1044 ice_seg->hdr.seg_format_ver.draft); in ice_download_pkg()
1047 le32_to_cpu(ice_seg->hdr.seg_type), in ice_download_pkg()
1048 le32_to_cpu(ice_seg->hdr.seg_size), ice_seg->hdr.seg_id); in ice_download_pkg()
1053 le32_to_cpu(ice_buf_tbl->buf_count)); in ice_download_pkg()
1055 return ice_dwnld_cfg_bufs(hw, ice_buf_tbl->buf_array, in ice_download_pkg()
1056 le32_to_cpu(ice_buf_tbl->buf_count)); in ice_download_pkg()
1078 hw->pkg_ver = meta_seg->pkg_ver; in ice_init_pkg_info()
1079 memcpy(hw->pkg_name, meta_seg->pkg_name, sizeof(hw->pkg_name)); in ice_init_pkg_info()
1082 meta_seg->pkg_ver.major, meta_seg->pkg_ver.minor, in ice_init_pkg_info()
1083 meta_seg->pkg_ver.update, meta_seg->pkg_ver.draft, in ice_init_pkg_info()
1084 meta_seg->pkg_name); in ice_init_pkg_info()
1093 hw->ice_pkg_ver = seg_hdr->seg_format_ver; in ice_init_pkg_info()
1094 memcpy(hw->ice_pkg_name, seg_hdr->seg_id, in ice_init_pkg_info()
1095 sizeof(hw->ice_pkg_name)); in ice_init_pkg_info()
1098 seg_hdr->seg_format_ver.major, in ice_init_pkg_info()
1099 seg_hdr->seg_format_ver.minor, in ice_init_pkg_info()
1100 seg_hdr->seg_format_ver.update, in ice_init_pkg_info()
1101 seg_hdr->seg_format_ver.draft, in ice_init_pkg_info()
1102 seg_hdr->seg_id); in ice_init_pkg_info()
1134 for (i = 0; i < le32_to_cpu(pkg_info->count); i++) { in ice_get_pkg_info()
1139 if (pkg_info->pkg_info[i].is_active) { in ice_get_pkg_info()
1141 hw->active_pkg_ver = pkg_info->pkg_info[i].ver; in ice_get_pkg_info()
1142 hw->active_track_id = in ice_get_pkg_info()
1143 le32_to_cpu(pkg_info->pkg_info[i].track_id); in ice_get_pkg_info()
1144 memcpy(hw->active_pkg_name, in ice_get_pkg_info()
1145 pkg_info->pkg_info[i].name, in ice_get_pkg_info()
1146 sizeof(pkg_info->pkg_info[i].name)); in ice_get_pkg_info()
1147 hw->active_pkg_in_nvm = pkg_info->pkg_info[i].is_in_nvm; in ice_get_pkg_info()
1149 if (pkg_info->pkg_info[i].is_active_at_boot) in ice_get_pkg_info()
1151 if (pkg_info->pkg_info[i].is_modified) in ice_get_pkg_info()
1153 if (pkg_info->pkg_info[i].is_in_nvm) in ice_get_pkg_info()
1157 i, pkg_info->pkg_info[i].ver.major, in ice_get_pkg_info()
1158 pkg_info->pkg_info[i].ver.minor, in ice_get_pkg_info()
1159 pkg_info->pkg_info[i].ver.update, in ice_get_pkg_info()
1160 pkg_info->pkg_info[i].ver.draft, in ice_get_pkg_info()
1161 pkg_info->pkg_info[i].name, flags); in ice_get_pkg_info()
1171 * ice_verify_pkg - verify package
1186 if (pkg->pkg_format_ver.major != ICE_PKG_FMT_VER_MAJ || in ice_verify_pkg()
1187 pkg->pkg_format_ver.minor != ICE_PKG_FMT_VER_MNR || in ice_verify_pkg()
1188 pkg->pkg_format_ver.update != ICE_PKG_FMT_VER_UPD || in ice_verify_pkg()
1189 pkg->pkg_format_ver.draft != ICE_PKG_FMT_VER_DFT) in ice_verify_pkg()
1193 seg_count = le32_to_cpu(pkg->seg_count); in ice_verify_pkg()
1203 u32 off = le32_to_cpu(pkg->seg_offset[i]); in ice_verify_pkg()
1213 if (len < off + le32_to_cpu(seg->seg_size)) in ice_verify_pkg()
1221 * ice_free_seg - free package segment pointer
1229 if (hw->pkg_copy) { in ice_free_seg()
1230 devm_kfree(ice_hw_to_dev(hw), hw->pkg_copy); in ice_free_seg()
1231 hw->pkg_copy = NULL; in ice_free_seg()
1232 hw->pkg_size = 0; in ice_free_seg()
1234 hw->seg = NULL; in ice_free_seg()
1238 * ice_init_pkg_regs - initialize additional package registers
1247 /* setup Switch block input mask, which is 48-bits in two parts */ in ice_init_pkg_regs()
1253 * ice_chk_pkg_version - check package version for compatibility with driver
1263 if (pkg_ver->major != ICE_PKG_SUPP_VER_MAJ || in ice_chk_pkg_version()
1264 pkg_ver->minor != ICE_PKG_SUPP_VER_MNR) in ice_chk_pkg_version()
1288 status = ice_chk_pkg_version(&hw->pkg_ver); in ice_chk_pkg_compat()
1312 for (i = 0; i < le32_to_cpu(pkg->count); i++) { in ice_chk_pkg_compat()
1314 if (!pkg->pkg_info[i].is_in_nvm) in ice_chk_pkg_compat()
1316 if ((*seg)->hdr.seg_format_ver.major != in ice_chk_pkg_compat()
1317 pkg->pkg_info[i].ver.major || in ice_chk_pkg_compat()
1318 (*seg)->hdr.seg_format_ver.minor > in ice_chk_pkg_compat()
1319 pkg->pkg_info[i].ver.minor) { in ice_chk_pkg_compat()
1333 * ice_init_pkg - initialize/download package
1391 "package previously loaded - no work.\n"); in ice_init_pkg()
1401 status = ice_chk_pkg_version(&hw->active_pkg_ver); in ice_init_pkg()
1405 hw->seg = seg; in ice_init_pkg()
1421 * ice_copy_and_init_pkg - initialize/download a copy of the package
1459 hw->pkg_copy = buf_copy; in ice_copy_and_init_pkg()
1460 hw->pkg_size = len; in ice_copy_and_init_pkg()
1483 buf->data_end = cpu_to_le16(offsetof(struct ice_buf_hdr, in ice_pkg_buf_alloc()
1523 buf = (struct ice_buf_hdr *)&bld->buf; in ice_pkg_buf_reserve_section()
1526 section_count = le16_to_cpu(buf->section_count); in ice_pkg_buf_reserve_section()
1530 if (bld->reserved_section_table_entries + count > ICE_MAX_S_COUNT) in ice_pkg_buf_reserve_section()
1532 bld->reserved_section_table_entries += count; in ice_pkg_buf_reserve_section()
1534 data_end = le16_to_cpu(buf->data_end) + in ice_pkg_buf_reserve_section()
1535 (count * sizeof(buf->section_entry[0])); in ice_pkg_buf_reserve_section()
1536 buf->data_end = cpu_to_le16(data_end); in ice_pkg_buf_reserve_section()
1563 buf = (struct ice_buf_hdr *)&bld->buf; in ice_pkg_buf_alloc_section()
1566 data_end = le16_to_cpu(buf->data_end); in ice_pkg_buf_alloc_section()
1575 sect_count = le16_to_cpu(buf->section_count); in ice_pkg_buf_alloc_section()
1576 if (sect_count < bld->reserved_section_table_entries) { in ice_pkg_buf_alloc_section()
1579 buf->section_entry[sect_count].offset = cpu_to_le16(data_end); in ice_pkg_buf_alloc_section()
1580 buf->section_entry[sect_count].size = cpu_to_le16(size); in ice_pkg_buf_alloc_section()
1581 buf->section_entry[sect_count].type = cpu_to_le32(type); in ice_pkg_buf_alloc_section()
1584 buf->data_end = cpu_to_le16(data_end); in ice_pkg_buf_alloc_section()
1586 buf->section_count = cpu_to_le16(sect_count + 1); in ice_pkg_buf_alloc_section()
1600 * least one active section - otherwise, the buffer is not legal and should
1611 buf = (struct ice_buf_hdr *)&bld->buf; in ice_pkg_buf_get_active_sections()
1612 return le16_to_cpu(buf->section_count); in ice_pkg_buf_get_active_sections()
1626 return &bld->buf; in ice_pkg_buf()
1630 * ice_get_open_tunnel_port - retrieve an open tunnel port
1640 mutex_lock(&hw->tnl_lock); in ice_get_open_tunnel_port()
1642 for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++) in ice_get_open_tunnel_port()
1643 if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].port) { in ice_get_open_tunnel_port()
1644 *port = hw->tnl.tbl[i].port; in ice_get_open_tunnel_port()
1649 mutex_unlock(&hw->tnl_lock); in ice_get_open_tunnel_port()
1655 * ice_tunnel_idx_to_entry - convert linear index to the sparse one
1669 for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++) in ice_tunnel_idx_to_entry()
1670 if (hw->tnl.tbl[i].valid && in ice_tunnel_idx_to_entry()
1671 hw->tnl.tbl[i].type == type && in ice_tunnel_idx_to_entry()
1672 idx--) in ice_tunnel_idx_to_entry()
1698 mutex_lock(&hw->tnl_lock); in ice_create_tunnel()
1711 struct_size(sect_rx, tcam, 1)); in ice_create_tunnel()
1714 sect_rx->count = cpu_to_le16(1); in ice_create_tunnel()
1717 struct_size(sect_tx, tcam, 1)); in ice_create_tunnel()
1720 sect_tx->count = cpu_to_le16(1); in ice_create_tunnel()
1723 memcpy(sect_rx->tcam, hw->tnl.tbl[index].boost_entry, in ice_create_tunnel()
1724 sizeof(*sect_rx->tcam)); in ice_create_tunnel()
1726 /* over-write the never-match dest port key bits with the encoded port in ice_create_tunnel()
1729 ice_set_key((u8 *)§_rx->tcam[0].key, sizeof(sect_rx->tcam[0].key), in ice_create_tunnel()
1732 sizeof(sect_rx->tcam[0].key.key.hv_dst_port_key)); in ice_create_tunnel()
1735 memcpy(sect_tx->tcam, sect_rx->tcam, sizeof(*sect_tx->tcam)); in ice_create_tunnel()
1739 hw->tnl.tbl[index].port = port; in ice_create_tunnel()
1745 mutex_unlock(&hw->tnl_lock); in ice_create_tunnel()
1769 mutex_lock(&hw->tnl_lock); in ice_destroy_tunnel()
1771 if (WARN_ON(!hw->tnl.tbl[index].valid || in ice_destroy_tunnel()
1772 hw->tnl.tbl[index].type != type || in ice_destroy_tunnel()
1773 hw->tnl.tbl[index].port != port)) { in ice_destroy_tunnel()
1789 struct_size(sect_rx, tcam, 1)); in ice_destroy_tunnel()
1792 sect_rx->count = cpu_to_le16(1); in ice_destroy_tunnel()
1795 struct_size(sect_tx, tcam, 1)); in ice_destroy_tunnel()
1798 sect_tx->count = cpu_to_le16(1); in ice_destroy_tunnel()
1803 memcpy(sect_rx->tcam, hw->tnl.tbl[index].boost_entry, in ice_destroy_tunnel()
1804 sizeof(*sect_rx->tcam)); in ice_destroy_tunnel()
1805 memcpy(sect_tx->tcam, hw->tnl.tbl[index].boost_entry, in ice_destroy_tunnel()
1806 sizeof(*sect_tx->tcam)); in ice_destroy_tunnel()
1810 hw->tnl.tbl[index].port = 0; in ice_destroy_tunnel()
1816 mutex_unlock(&hw->tnl_lock); in ice_destroy_tunnel()
1825 struct ice_vsi *vsi = np->vsi; in ice_udp_tunnel_set_port()
1826 struct ice_pf *pf = vsi->back; in ice_udp_tunnel_set_port()
1831 tnl_type = ti->type == UDP_TUNNEL_TYPE_VXLAN ? TNL_VXLAN : TNL_GENEVE; in ice_udp_tunnel_set_port()
1832 index = ice_tunnel_idx_to_entry(&pf->hw, idx, tnl_type); in ice_udp_tunnel_set_port()
1834 status = ice_create_tunnel(&pf->hw, index, tnl_type, ntohs(ti->port)); in ice_udp_tunnel_set_port()
1836 netdev_err(netdev, "Error adding UDP tunnel - %s\n", in ice_udp_tunnel_set_port()
1838 return -EIO; in ice_udp_tunnel_set_port()
1849 struct ice_vsi *vsi = np->vsi; in ice_udp_tunnel_unset_port()
1850 struct ice_pf *pf = vsi->back; in ice_udp_tunnel_unset_port()
1854 tnl_type = ti->type == UDP_TUNNEL_TYPE_VXLAN ? TNL_VXLAN : TNL_GENEVE; in ice_udp_tunnel_unset_port()
1856 status = ice_destroy_tunnel(&pf->hw, ti->hw_priv, tnl_type, in ice_udp_tunnel_unset_port()
1857 ntohs(ti->port)); in ice_udp_tunnel_unset_port()
1859 netdev_err(netdev, "Error removing UDP tunnel - %s\n", in ice_udp_tunnel_unset_port()
1861 return -EIO; in ice_udp_tunnel_unset_port()
1870 * ice_ptg_find_ptype - Search for packet type group using packet type (ptype)
1886 *ptg = hw->blk[blk].xlt1.ptypes[ptype].ptg; in ice_ptg_find_ptype()
1891 * ice_ptg_alloc_val - Allocates a new packet type group ID by value
1901 hw->blk[blk].xlt1.ptg_tbl[ptg].in_use = true; in ice_ptg_alloc_val()
1905 * ice_ptg_remove_ptype - Removes ptype from a particular packet type group
1920 if (ptype > ICE_XLT1_CNT - 1) in ice_ptg_remove_ptype()
1923 if (!hw->blk[blk].xlt1.ptg_tbl[ptg].in_use) in ice_ptg_remove_ptype()
1927 if (!hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype) in ice_ptg_remove_ptype()
1931 p = hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype; in ice_ptg_remove_ptype()
1932 ch = &hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype; in ice_ptg_remove_ptype()
1934 if (ptype == (p - hw->blk[blk].xlt1.ptypes)) { in ice_ptg_remove_ptype()
1935 *ch = p->next_ptype; in ice_ptg_remove_ptype()
1939 ch = &p->next_ptype; in ice_ptg_remove_ptype()
1940 p = p->next_ptype; in ice_ptg_remove_ptype()
1943 hw->blk[blk].xlt1.ptypes[ptype].ptg = ICE_DEFAULT_PTG; in ice_ptg_remove_ptype()
1944 hw->blk[blk].xlt1.ptypes[ptype].next_ptype = NULL; in ice_ptg_remove_ptype()
1950 * ice_ptg_add_mv_ptype - Adds/moves ptype to a particular packet type group
1967 if (ptype > ICE_XLT1_CNT - 1) in ice_ptg_add_mv_ptype()
1970 if (!hw->blk[blk].xlt1.ptg_tbl[ptg].in_use && ptg != ICE_DEFAULT_PTG) in ice_ptg_add_mv_ptype()
1990 hw->blk[blk].xlt1.ptypes[ptype].next_ptype = in ice_ptg_add_mv_ptype()
1991 hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype; in ice_ptg_add_mv_ptype()
1992 hw->blk[blk].xlt1.ptg_tbl[ptg].first_ptype = in ice_ptg_add_mv_ptype()
1993 &hw->blk[blk].xlt1.ptypes[ptype]; in ice_ptg_add_mv_ptype()
1995 hw->blk[blk].xlt1.ptypes[ptype].ptg = ptg; in ice_ptg_add_mv_ptype()
1996 hw->blk[blk].xlt1.t[ptype] = ptg; in ice_ptg_add_mv_ptype()
2005 u16 prof_tcam; /* # profile ID TCAM entries */
2007 u8 prof_cdid_bits; /* # CDID one-hot bits used in key */
2018 * XLT1 - Number of entries in XLT1 table
2019 * XLT2 - Number of entries in XLT2 table
2020 * TCAM - Number of entries Profile ID TCAM table
2021 * CDID - Control Domain ID of the hardware block
2022 * PRED - Number of entries in the Profile Redirection Table
2023 * FV - Number of entries in the Field Vector
2024 * FVW - Width (in WORDs) of the Field Vector
2025 * OVR - Overwrite existing table entries
2026 * REV - Reverse FV
2028 /* XLT1 , XLT2 ,TCAM, PID,CDID,PRED, FV, FVW */
2054 * ice_match_prop_lst - determine if properties of two lists match
2082 while (count--) { in ice_match_prop_lst()
2083 if (tmp2->profile_cookie != tmp1->profile_cookie) in ice_match_prop_lst()
2096 * ice_vsig_find_vsi - find a VSIG that contains a specified VSI
2115 *vsig = hw->blk[blk].xlt2.vsis[vsi].vsig; in ice_vsig_find_vsi()
2121 * ice_vsig_alloc_val - allocate a new VSIG by value
2132 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) { in ice_vsig_alloc_val()
2133 INIT_LIST_HEAD(&hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst); in ice_vsig_alloc_val()
2134 hw->blk[blk].xlt2.vsig_tbl[idx].in_use = true; in ice_vsig_alloc_val()
2137 return ICE_VSIG_VALUE(idx, hw->pf_id); in ice_vsig_alloc_val()
2141 * ice_vsig_alloc - Finds a free entry and allocates a new VSIG
2153 if (!hw->blk[blk].xlt2.vsig_tbl[i].in_use) in ice_vsig_alloc()
2160 * ice_find_dup_props_vsig - find VSI group with a specified set of properties
2178 struct ice_xlt2 *xlt2 = &hw->blk[blk].xlt2; in ice_find_dup_props_vsig()
2181 for (i = 0; i < xlt2->count; i++) in ice_find_dup_props_vsig()
2182 if (xlt2->vsig_tbl[i].in_use && in ice_find_dup_props_vsig()
2183 ice_match_prop_lst(chs, &xlt2->vsig_tbl[i].prop_lst)) { in ice_find_dup_props_vsig()
2184 *vsig = ICE_VSIG_VALUE(i, hw->pf_id); in ice_find_dup_props_vsig()
2192 * ice_vsig_free - free VSI group
2211 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) in ice_vsig_free()
2214 hw->blk[blk].xlt2.vsig_tbl[idx].in_use = false; in ice_vsig_free()
2216 vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_vsig_free()
2223 struct ice_vsig_vsi *tmp = vsi_cur->next_vsi; in ice_vsig_free()
2225 vsi_cur->vsig = ICE_DEFAULT_VSIG; in ice_vsig_free()
2226 vsi_cur->changed = 1; in ice_vsig_free()
2227 vsi_cur->next_vsi = NULL; in ice_vsig_free()
2232 hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = NULL; in ice_vsig_free()
2237 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_vsig_free()
2239 list_del(&del->list); in ice_vsig_free()
2244 * re-initialize the list head in ice_vsig_free()
2246 INIT_LIST_HEAD(&hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst); in ice_vsig_free()
2252 * ice_vsig_remove_vsi - remove VSI from VSIG
2272 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) in ice_vsig_remove_vsi()
2279 vsi_head = &hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_vsig_remove_vsi()
2283 vsi_tgt = &hw->blk[blk].xlt2.vsis[vsi]; in ice_vsig_remove_vsi()
2289 (*vsi_head) = vsi_cur->next_vsi; in ice_vsig_remove_vsi()
2292 vsi_head = &vsi_cur->next_vsi; in ice_vsig_remove_vsi()
2293 vsi_cur = vsi_cur->next_vsi; in ice_vsig_remove_vsi()
2300 vsi_cur->vsig = ICE_DEFAULT_VSIG; in ice_vsig_remove_vsi()
2301 vsi_cur->changed = 1; in ice_vsig_remove_vsi()
2302 vsi_cur->next_vsi = NULL; in ice_vsig_remove_vsi()
2308 * ice_vsig_add_mv_vsi - add or move a VSI to a VSI group
2334 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use && in ice_vsig_add_mv_vsi()
2357 hw->blk[blk].xlt2.vsis[vsi].vsig = vsig; in ice_vsig_add_mv_vsi()
2358 hw->blk[blk].xlt2.vsis[vsi].changed = 1; in ice_vsig_add_mv_vsi()
2361 tmp = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_vsig_add_mv_vsi()
2362 hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi = in ice_vsig_add_mv_vsi()
2363 &hw->blk[blk].xlt2.vsis[vsi]; in ice_vsig_add_mv_vsi()
2364 hw->blk[blk].xlt2.vsis[vsi].next_vsi = tmp; in ice_vsig_add_mv_vsi()
2365 hw->blk[blk].xlt2.t[vsi] = vsig; in ice_vsig_add_mv_vsi()
2371 * ice_find_prof_id - find profile ID for a given field vector
2381 struct ice_es *es = &hw->blk[blk].es; in ice_find_prof_id()
2385 /* For FD, we don't want to re-use a existed profile with the same in ice_find_prof_id()
2391 for (i = 0; i < (u8)es->count; i++) { in ice_find_prof_id()
2392 off = i * es->fvw; in ice_find_prof_id()
2394 if (memcmp(&es->t[off], fv, es->fvw * sizeof(*fv))) in ice_find_prof_id()
2405 * ice_prof_id_rsrc_type - get profile ID resource type for a block type
2425 * ice_tcam_ent_rsrc_type - get TCAM entry resource type for a block type
2445 * ice_alloc_tcam_ent - allocate hardware TCAM entry
2447 * @blk: the block to allocate the TCAM for
2448 * @tcam_idx: pointer to variable to receive the TCAM entry
2450 * This function allocates a new entry in a Profile ID TCAM for a specific
2465 * ice_free_tcam_ent - free hardware TCAM entry
2467 * @blk: the block from which to free the TCAM entry
2468 * @tcam_idx: the TCAM entry to free
2470 * This function frees an entry in a Profile ID TCAM for a specific block.
2484 * ice_alloc_prof_id - allocate profile ID
2510 * ice_free_prof_id - free profile ID
2530 * ice_prof_inc_ref - increment reference count for profile
2538 if (prof_id > hw->blk[blk].es.count) in ice_prof_inc_ref()
2541 hw->blk[blk].es.ref_count[prof_id]++; in ice_prof_inc_ref()
2547 * ice_write_es - write an extraction sequence to hardware
2551 * @fv: pointer to the extraction sequence to write - NULL to clear extraction
2559 off = prof_id * hw->blk[blk].es.fvw; in ice_write_es()
2561 memset(&hw->blk[blk].es.t[off], 0, in ice_write_es()
2562 hw->blk[blk].es.fvw * sizeof(*fv)); in ice_write_es()
2563 hw->blk[blk].es.written[prof_id] = false; in ice_write_es()
2565 memcpy(&hw->blk[blk].es.t[off], fv, in ice_write_es()
2566 hw->blk[blk].es.fvw * sizeof(*fv)); in ice_write_es()
2571 * ice_prof_dec_ref - decrement reference count for profile
2579 if (prof_id > hw->blk[blk].es.count) in ice_prof_dec_ref()
2582 if (hw->blk[blk].es.ref_count[prof_id] > 0) { in ice_prof_dec_ref()
2583 if (!--hw->blk[blk].es.ref_count[prof_id]) { in ice_prof_dec_ref()
2636 * ice_init_sw_xlt1_db - init software XLT1 database from HW tables
2644 for (pt = 0; pt < hw->blk[blk].xlt1.count; pt++) { in ice_init_sw_xlt1_db()
2647 ptg = hw->blk[blk].xlt1.t[pt]; in ice_init_sw_xlt1_db()
2656 * ice_init_sw_xlt2_db - init software XLT2 database from HW tables
2664 for (vsi = 0; vsi < hw->blk[blk].xlt2.count; vsi++) { in ice_init_sw_xlt2_db()
2667 vsig = hw->blk[blk].xlt2.t[vsi]; in ice_init_sw_xlt2_db()
2674 hw->blk[blk].xlt2.vsis[vsi].changed = 0; in ice_init_sw_xlt2_db()
2680 * ice_init_sw_db - init software database from HW tables
2694 * ice_fill_tbl - Reads content of a single table type into database
2721 if (!hw->seg) { in ice_fill_tbl()
2722 ice_debug(hw, ICE_DBG_PKG, "hw->seg is NULL, tables are not filled\n"); in ice_fill_tbl()
2728 sect = ice_pkg_enum_section(hw->seg, &state, sid); in ice_fill_tbl()
2738 src = xlt1->value; in ice_fill_tbl()
2739 sect_len = le16_to_cpu(xlt1->count) * in ice_fill_tbl()
2740 sizeof(*hw->blk[block_id].xlt1.t); in ice_fill_tbl()
2741 dst = hw->blk[block_id].xlt1.t; in ice_fill_tbl()
2742 dst_len = hw->blk[block_id].xlt1.count * in ice_fill_tbl()
2743 sizeof(*hw->blk[block_id].xlt1.t); in ice_fill_tbl()
2751 src = (__force u8 *)xlt2->value; in ice_fill_tbl()
2752 sect_len = le16_to_cpu(xlt2->count) * in ice_fill_tbl()
2753 sizeof(*hw->blk[block_id].xlt2.t); in ice_fill_tbl()
2754 dst = (u8 *)hw->blk[block_id].xlt2.t; in ice_fill_tbl()
2755 dst_len = hw->blk[block_id].xlt2.count * in ice_fill_tbl()
2756 sizeof(*hw->blk[block_id].xlt2.t); in ice_fill_tbl()
2764 src = (u8 *)pid->entry; in ice_fill_tbl()
2765 sect_len = le16_to_cpu(pid->count) * in ice_fill_tbl()
2766 sizeof(*hw->blk[block_id].prof.t); in ice_fill_tbl()
2767 dst = (u8 *)hw->blk[block_id].prof.t; in ice_fill_tbl()
2768 dst_len = hw->blk[block_id].prof.count * in ice_fill_tbl()
2769 sizeof(*hw->blk[block_id].prof.t); in ice_fill_tbl()
2777 src = pr->redir_value; in ice_fill_tbl()
2778 sect_len = le16_to_cpu(pr->count) * in ice_fill_tbl()
2779 sizeof(*hw->blk[block_id].prof_redir.t); in ice_fill_tbl()
2780 dst = hw->blk[block_id].prof_redir.t; in ice_fill_tbl()
2781 dst_len = hw->blk[block_id].prof_redir.count * in ice_fill_tbl()
2782 sizeof(*hw->blk[block_id].prof_redir.t); in ice_fill_tbl()
2790 src = (u8 *)es->fv; in ice_fill_tbl()
2791 sect_len = (u32)(le16_to_cpu(es->count) * in ice_fill_tbl()
2792 hw->blk[block_id].es.fvw) * in ice_fill_tbl()
2793 sizeof(*hw->blk[block_id].es.t); in ice_fill_tbl()
2794 dst = (u8 *)hw->blk[block_id].es.t; in ice_fill_tbl()
2795 dst_len = (u32)(hw->blk[block_id].es.count * in ice_fill_tbl()
2796 hw->blk[block_id].es.fvw) * in ice_fill_tbl()
2797 sizeof(*hw->blk[block_id].es.t); in ice_fill_tbl()
2815 sect_len = dst_len - offset; in ice_fill_tbl()
2824 * ice_fill_blk_tbls - Read package context for tables
2838 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].xlt1.sid); in ice_fill_blk_tbls()
2839 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].xlt2.sid); in ice_fill_blk_tbls()
2840 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].prof.sid); in ice_fill_blk_tbls()
2841 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].prof_redir.sid); in ice_fill_blk_tbls()
2842 ice_fill_tbl(hw, blk_id, hw->blk[blk_id].es.sid); in ice_fill_blk_tbls()
2849 * ice_free_prof_map - free profile map
2855 struct ice_es *es = &hw->blk[blk_idx].es; in ice_free_prof_map()
2858 mutex_lock(&es->prof_map_lock); in ice_free_prof_map()
2859 list_for_each_entry_safe(del, tmp, &es->prof_map, list) { in ice_free_prof_map()
2860 list_del(&del->list); in ice_free_prof_map()
2863 INIT_LIST_HEAD(&es->prof_map); in ice_free_prof_map()
2864 mutex_unlock(&es->prof_map_lock); in ice_free_prof_map()
2868 * ice_free_flow_profs - free flow profile entries
2876 mutex_lock(&hw->fl_profs_locks[blk_idx]); in ice_free_flow_profs()
2877 list_for_each_entry_safe(p, tmp, &hw->fl_profs[blk_idx], l_entry) { in ice_free_flow_profs()
2880 list_for_each_entry_safe(e, t, &p->entries, l_entry) in ice_free_flow_profs()
2884 list_del(&p->l_entry); in ice_free_flow_profs()
2886 mutex_destroy(&p->entries_lock); in ice_free_flow_profs()
2889 mutex_unlock(&hw->fl_profs_locks[blk_idx]); in ice_free_flow_profs()
2892 * re-initialize the flow profile list heads in ice_free_flow_profs()
2894 INIT_LIST_HEAD(&hw->fl_profs[blk_idx]); in ice_free_flow_profs()
2898 * ice_free_vsig_tbl - free complete VSIG table entries
2906 if (!hw->blk[blk].xlt2.vsig_tbl) in ice_free_vsig_tbl()
2910 if (hw->blk[blk].xlt2.vsig_tbl[i].in_use) in ice_free_vsig_tbl()
2915 * ice_free_hw_tbls - free hardware table memory
2924 if (hw->blk[i].is_list_init) { in ice_free_hw_tbls()
2925 struct ice_es *es = &hw->blk[i].es; in ice_free_hw_tbls()
2928 mutex_destroy(&es->prof_map_lock); in ice_free_hw_tbls()
2931 mutex_destroy(&hw->fl_profs_locks[i]); in ice_free_hw_tbls()
2933 hw->blk[i].is_list_init = false; in ice_free_hw_tbls()
2936 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt1.ptypes); in ice_free_hw_tbls()
2937 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt1.ptg_tbl); in ice_free_hw_tbls()
2938 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt1.t); in ice_free_hw_tbls()
2939 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt2.t); in ice_free_hw_tbls()
2940 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt2.vsig_tbl); in ice_free_hw_tbls()
2941 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].xlt2.vsis); in ice_free_hw_tbls()
2942 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].prof.t); in ice_free_hw_tbls()
2943 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].prof_redir.t); in ice_free_hw_tbls()
2944 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.t); in ice_free_hw_tbls()
2945 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.ref_count); in ice_free_hw_tbls()
2946 devm_kfree(ice_hw_to_dev(hw), hw->blk[i].es.written); in ice_free_hw_tbls()
2949 list_for_each_entry_safe(r, rt, &hw->rss_list_head, l_entry) { in ice_free_hw_tbls()
2950 list_del(&r->l_entry); in ice_free_hw_tbls()
2953 mutex_destroy(&hw->rss_locks); in ice_free_hw_tbls()
2954 memset(hw->blk, 0, sizeof(hw->blk)); in ice_free_hw_tbls()
2958 * ice_init_flow_profs - init flow profile locks and list heads
2964 mutex_init(&hw->fl_profs_locks[blk_idx]); in ice_init_flow_profs()
2965 INIT_LIST_HEAD(&hw->fl_profs[blk_idx]); in ice_init_flow_profs()
2969 * ice_clear_hw_tbls - clear HW tables and flow profiles
2977 struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir; in ice_clear_hw_tbls()
2978 struct ice_prof_tcam *prof = &hw->blk[i].prof; in ice_clear_hw_tbls()
2979 struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1; in ice_clear_hw_tbls()
2980 struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2; in ice_clear_hw_tbls()
2981 struct ice_es *es = &hw->blk[i].es; in ice_clear_hw_tbls()
2983 if (hw->blk[i].is_list_init) { in ice_clear_hw_tbls()
2990 memset(xlt1->ptypes, 0, xlt1->count * sizeof(*xlt1->ptypes)); in ice_clear_hw_tbls()
2991 memset(xlt1->ptg_tbl, 0, in ice_clear_hw_tbls()
2992 ICE_MAX_PTGS * sizeof(*xlt1->ptg_tbl)); in ice_clear_hw_tbls()
2993 memset(xlt1->t, 0, xlt1->count * sizeof(*xlt1->t)); in ice_clear_hw_tbls()
2995 memset(xlt2->vsis, 0, xlt2->count * sizeof(*xlt2->vsis)); in ice_clear_hw_tbls()
2996 memset(xlt2->vsig_tbl, 0, in ice_clear_hw_tbls()
2997 xlt2->count * sizeof(*xlt2->vsig_tbl)); in ice_clear_hw_tbls()
2998 memset(xlt2->t, 0, xlt2->count * sizeof(*xlt2->t)); in ice_clear_hw_tbls()
3000 memset(prof->t, 0, prof->count * sizeof(*prof->t)); in ice_clear_hw_tbls()
3001 memset(prof_redir->t, 0, in ice_clear_hw_tbls()
3002 prof_redir->count * sizeof(*prof_redir->t)); in ice_clear_hw_tbls()
3004 memset(es->t, 0, es->count * sizeof(*es->t) * es->fvw); in ice_clear_hw_tbls()
3005 memset(es->ref_count, 0, es->count * sizeof(*es->ref_count)); in ice_clear_hw_tbls()
3006 memset(es->written, 0, es->count * sizeof(*es->written)); in ice_clear_hw_tbls()
3011 * ice_init_hw_tbls - init hardware table memory
3018 mutex_init(&hw->rss_locks); in ice_init_hw_tbls()
3019 INIT_LIST_HEAD(&hw->rss_list_head); in ice_init_hw_tbls()
3021 struct ice_prof_redir *prof_redir = &hw->blk[i].prof_redir; in ice_init_hw_tbls()
3022 struct ice_prof_tcam *prof = &hw->blk[i].prof; in ice_init_hw_tbls()
3023 struct ice_xlt1 *xlt1 = &hw->blk[i].xlt1; in ice_init_hw_tbls()
3024 struct ice_xlt2 *xlt2 = &hw->blk[i].xlt2; in ice_init_hw_tbls()
3025 struct ice_es *es = &hw->blk[i].es; in ice_init_hw_tbls()
3028 if (hw->blk[i].is_list_init) in ice_init_hw_tbls()
3032 mutex_init(&es->prof_map_lock); in ice_init_hw_tbls()
3033 INIT_LIST_HEAD(&es->prof_map); in ice_init_hw_tbls()
3034 hw->blk[i].is_list_init = true; in ice_init_hw_tbls()
3036 hw->blk[i].overwrite = blk_sizes[i].overwrite; in ice_init_hw_tbls()
3037 es->reverse = blk_sizes[i].reverse; in ice_init_hw_tbls()
3039 xlt1->sid = ice_blk_sids[i][ICE_SID_XLT1_OFF]; in ice_init_hw_tbls()
3040 xlt1->count = blk_sizes[i].xlt1; in ice_init_hw_tbls()
3042 xlt1->ptypes = devm_kcalloc(ice_hw_to_dev(hw), xlt1->count, in ice_init_hw_tbls()
3043 sizeof(*xlt1->ptypes), GFP_KERNEL); in ice_init_hw_tbls()
3045 if (!xlt1->ptypes) in ice_init_hw_tbls()
3048 xlt1->ptg_tbl = devm_kcalloc(ice_hw_to_dev(hw), ICE_MAX_PTGS, in ice_init_hw_tbls()
3049 sizeof(*xlt1->ptg_tbl), in ice_init_hw_tbls()
3052 if (!xlt1->ptg_tbl) in ice_init_hw_tbls()
3055 xlt1->t = devm_kcalloc(ice_hw_to_dev(hw), xlt1->count, in ice_init_hw_tbls()
3056 sizeof(*xlt1->t), GFP_KERNEL); in ice_init_hw_tbls()
3057 if (!xlt1->t) in ice_init_hw_tbls()
3060 xlt2->sid = ice_blk_sids[i][ICE_SID_XLT2_OFF]; in ice_init_hw_tbls()
3061 xlt2->count = blk_sizes[i].xlt2; in ice_init_hw_tbls()
3063 xlt2->vsis = devm_kcalloc(ice_hw_to_dev(hw), xlt2->count, in ice_init_hw_tbls()
3064 sizeof(*xlt2->vsis), GFP_KERNEL); in ice_init_hw_tbls()
3066 if (!xlt2->vsis) in ice_init_hw_tbls()
3069 xlt2->vsig_tbl = devm_kcalloc(ice_hw_to_dev(hw), xlt2->count, in ice_init_hw_tbls()
3070 sizeof(*xlt2->vsig_tbl), in ice_init_hw_tbls()
3072 if (!xlt2->vsig_tbl) in ice_init_hw_tbls()
3075 for (j = 0; j < xlt2->count; j++) in ice_init_hw_tbls()
3076 INIT_LIST_HEAD(&xlt2->vsig_tbl[j].prop_lst); in ice_init_hw_tbls()
3078 xlt2->t = devm_kcalloc(ice_hw_to_dev(hw), xlt2->count, in ice_init_hw_tbls()
3079 sizeof(*xlt2->t), GFP_KERNEL); in ice_init_hw_tbls()
3080 if (!xlt2->t) in ice_init_hw_tbls()
3083 prof->sid = ice_blk_sids[i][ICE_SID_PR_OFF]; in ice_init_hw_tbls()
3084 prof->count = blk_sizes[i].prof_tcam; in ice_init_hw_tbls()
3085 prof->max_prof_id = blk_sizes[i].prof_id; in ice_init_hw_tbls()
3086 prof->cdid_bits = blk_sizes[i].prof_cdid_bits; in ice_init_hw_tbls()
3087 prof->t = devm_kcalloc(ice_hw_to_dev(hw), prof->count, in ice_init_hw_tbls()
3088 sizeof(*prof->t), GFP_KERNEL); in ice_init_hw_tbls()
3090 if (!prof->t) in ice_init_hw_tbls()
3093 prof_redir->sid = ice_blk_sids[i][ICE_SID_PR_REDIR_OFF]; in ice_init_hw_tbls()
3094 prof_redir->count = blk_sizes[i].prof_redir; in ice_init_hw_tbls()
3095 prof_redir->t = devm_kcalloc(ice_hw_to_dev(hw), in ice_init_hw_tbls()
3096 prof_redir->count, in ice_init_hw_tbls()
3097 sizeof(*prof_redir->t), in ice_init_hw_tbls()
3100 if (!prof_redir->t) in ice_init_hw_tbls()
3103 es->sid = ice_blk_sids[i][ICE_SID_ES_OFF]; in ice_init_hw_tbls()
3104 es->count = blk_sizes[i].es; in ice_init_hw_tbls()
3105 es->fvw = blk_sizes[i].fvw; in ice_init_hw_tbls()
3106 es->t = devm_kcalloc(ice_hw_to_dev(hw), in ice_init_hw_tbls()
3107 (u32)(es->count * es->fvw), in ice_init_hw_tbls()
3108 sizeof(*es->t), GFP_KERNEL); in ice_init_hw_tbls()
3109 if (!es->t) in ice_init_hw_tbls()
3112 es->ref_count = devm_kcalloc(ice_hw_to_dev(hw), es->count, in ice_init_hw_tbls()
3113 sizeof(*es->ref_count), in ice_init_hw_tbls()
3115 if (!es->ref_count) in ice_init_hw_tbls()
3118 es->written = devm_kcalloc(ice_hw_to_dev(hw), es->count, in ice_init_hw_tbls()
3119 sizeof(*es->written), GFP_KERNEL); in ice_init_hw_tbls()
3120 if (!es->written) in ice_init_hw_tbls()
3131 * ice_prof_gen_key - generate profile ID key
3155 switch (hw->blk[blk].prof.cdid_bits) { in ice_prof_gen_key()
3186 * ice_tcam_write_entry - write TCAM entry
3210 dc_msk, nm_msk, hw->blk[blk].prof.t[idx].key); in ice_tcam_write_entry()
3212 hw->blk[blk].prof.t[idx].addr = cpu_to_le16(idx); in ice_tcam_write_entry()
3213 hw->blk[blk].prof.t[idx].prof_id = prof_id; in ice_tcam_write_entry()
3220 * ice_vsig_get_ref - returns number of VSIs belong to a VSIG
3234 if (!hw->blk[blk].xlt2.vsig_tbl[idx].in_use) in ice_vsig_get_ref()
3237 ptr = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_vsig_get_ref()
3240 ptr = ptr->next_vsi; in ice_vsig_get_ref()
3247 * ice_has_prof_vsig - check to see if VSIG has a specific profile
3259 list_for_each_entry(ent, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_has_prof_vsig()
3261 if (ent->profile_cookie == hdl) in ice_has_prof_vsig()
3271 * ice_prof_bld_es - build profile ID extraction sequence changes
3281 u16 vec_size = hw->blk[blk].es.fvw * sizeof(struct ice_fv_word); in ice_prof_bld_es()
3285 if (tmp->type == ICE_PTG_ES_ADD && tmp->add_prof) { in ice_prof_bld_es()
3286 u16 off = tmp->prof_id * hw->blk[blk].es.fvw; in ice_prof_bld_es()
3293 vec_size - in ice_prof_bld_es()
3294 sizeof(p->es[0])); in ice_prof_bld_es()
3299 p->count = cpu_to_le16(1); in ice_prof_bld_es()
3300 p->offset = cpu_to_le16(tmp->prof_id); in ice_prof_bld_es()
3302 memcpy(p->es, &hw->blk[blk].es.t[off], vec_size); in ice_prof_bld_es()
3309 * ice_prof_bld_tcam - build profile ID TCAM changes
3322 if (tmp->type == ICE_TCAM_ADD && tmp->add_tcam_idx) { in ice_prof_bld_tcam()
3333 p->count = cpu_to_le16(1); in ice_prof_bld_tcam()
3334 p->entry[0].addr = cpu_to_le16(tmp->tcam_idx); in ice_prof_bld_tcam()
3335 p->entry[0].prof_id = tmp->prof_id; in ice_prof_bld_tcam()
3337 memcpy(p->entry[0].key, in ice_prof_bld_tcam()
3338 &hw->blk[blk].prof.t[tmp->tcam_idx].key, in ice_prof_bld_tcam()
3339 sizeof(hw->blk[blk].prof.t->key)); in ice_prof_bld_tcam()
3346 * ice_prof_bld_xlt1 - build XLT1 changes
3358 if (tmp->type == ICE_PTG_ES_ADD && tmp->add_ptg) { in ice_prof_bld_xlt1()
3369 p->count = cpu_to_le16(1); in ice_prof_bld_xlt1()
3370 p->offset = cpu_to_le16(tmp->ptype); in ice_prof_bld_xlt1()
3371 p->value[0] = tmp->ptg; in ice_prof_bld_xlt1()
3378 * ice_prof_bld_xlt2 - build XLT2 changes
3393 switch (tmp->type) { in ice_prof_bld_xlt2()
3404 p->count = cpu_to_le16(1); in ice_prof_bld_xlt2()
3405 p->offset = cpu_to_le16(tmp->vsi); in ice_prof_bld_xlt2()
3406 p->value[0] = cpu_to_le16(tmp->vsig); in ice_prof_bld_xlt2()
3417 * ice_upd_prof_hw - update hardware using the change list
3432 u16 tcam = 0; in ice_upd_prof_hw() local
3438 switch (tmp->type) { in ice_upd_prof_hw()
3440 if (tmp->add_ptg) in ice_upd_prof_hw()
3442 if (tmp->add_prof) in ice_upd_prof_hw()
3446 tcam++; in ice_upd_prof_hw()
3457 sects = xlt1 + xlt2 + tcam + es; in ice_upd_prof_hw()
3471 /* Preserve order of table update: ES, TCAM, PTG, VSIG */ in ice_upd_prof_hw()
3478 if (tcam) { in ice_upd_prof_hw()
3497 * non-zero and matches the number of sections detected for package in ice_upd_prof_hw()
3517 * ice_update_fd_mask - set Flow Director Field Vector mask for a profile
3569 * ice_update_fd_swap - set register appropriately for a FD FV extraction
3579 #define ICE_FD_FV_NOT_FOUND (-2) in ice_update_fd_swap()
3595 for (i = 0; i < hw->blk[ICE_BLK_FD].es.fvw; i++) { in ice_update_fd_swap()
3601 first_free = i - 1; in ice_update_fd_swap()
3633 es[first_free - k].prot_id = in ice_update_fd_swap()
3635 es[first_free - k].off = in ice_update_fd_swap()
3641 /* keep track of non-relevant fields */ in ice_update_fd_swap()
3642 mask_sel |= BIT(first_free - k); in ice_update_fd_swap()
3646 first_free -= ice_fd_pairs[index].count; in ice_update_fd_swap()
3651 si = hw->blk[ICE_BLK_FD].es.fvw - 1; in ice_update_fd_swap()
3660 si -= indexes_used; in ice_update_fd_swap()
3671 idx = j + ((j % 2) ? -1 : 1); in ice_update_fd_swap()
3675 used[si - k] = (pair_start[idx] - k) | in ice_update_fd_swap()
3682 si -= indexes_used; in ice_update_fd_swap()
3688 for (j = 0; j < hw->blk[ICE_BLK_FD].es.fvw / 4; j++) { in ice_update_fd_swap()
3723 * ice_add_prof - add profile
3748 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof()
3783 prof->profile_cookie = id; in ice_add_prof()
3784 prof->prof_id = prof_id; in ice_add_prof()
3785 prof->ptg_cnt = 0; in ice_add_prof()
3786 prof->context = 0; in ice_add_prof()
3789 while (bytes && prof->ptg_cnt < ICE_MAX_PTG_PER_PROFILE) { in ice_add_prof()
3793 bytes--; in ice_add_prof()
3807 /* The package should place all ptypes in a non-zero in ice_add_prof()
3818 prof->ptg[prof->ptg_cnt] = ptg; in ice_add_prof()
3820 if (++prof->ptg_cnt >= ICE_MAX_PTG_PER_PROFILE) in ice_add_prof()
3824 m = ~(u8)((1 << (bit + 1)) - 1); in ice_add_prof()
3829 bytes--; in ice_add_prof()
3833 list_add(&prof->list, &hw->blk[blk].es.prof_map); in ice_add_prof()
3837 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof()
3842 * ice_search_prof_id - Search for a profile tracking ID
3856 list_for_each_entry(map, &hw->blk[blk].es.prof_map, list) in ice_search_prof_id()
3857 if (map->profile_cookie == id) { in ice_search_prof_id()
3866 * ice_vsig_prof_id_count - count profiles in a VSIG
3877 list_for_each_entry(p, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_vsig_prof_id_count()
3885 * ice_rel_tcam_idx - release a TCAM index
3899 /* write the TCAM entry */ in ice_rel_tcam_idx()
3905 /* release the TCAM entry */ in ice_rel_tcam_idx()
3912 * ice_rem_prof_id - remove one profile from a VSIG
3924 for (i = 0; i < prof->tcam_count; i++) in ice_rem_prof_id()
3925 if (prof->tcam[i].in_use) { in ice_rem_prof_id()
3926 prof->tcam[i].in_use = false; in ice_rem_prof_id()
3928 prof->tcam[i].tcam_idx); in ice_rem_prof_id()
3937 * ice_rem_vsig - remove VSIG
3952 /* remove TCAM entries */ in ice_rem_vsig()
3954 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_rem_vsig()
3960 list_del(&d->list); in ice_rem_vsig()
3965 vsi_cur = hw->blk[blk].xlt2.vsig_tbl[idx].first_vsi; in ice_rem_vsig()
3971 struct ice_vsig_vsi *tmp = vsi_cur->next_vsi; in ice_rem_vsig()
3979 p->type = ICE_VSIG_REM; in ice_rem_vsig()
3980 p->orig_vsig = vsig; in ice_rem_vsig()
3981 p->vsig = ICE_DEFAULT_VSIG; in ice_rem_vsig()
3982 p->vsi = vsi_cur - hw->blk[blk].xlt2.vsis; in ice_rem_vsig()
3984 list_add(&p->list_entry, chg); in ice_rem_vsig()
3993 * ice_rem_prof_id_vsig - remove a specific profile from a VSIG
4009 &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_rem_prof_id_vsig()
4011 if (p->profile_cookie == hdl) { in ice_rem_prof_id_vsig()
4018 list_del(&p->list); in ice_rem_prof_id_vsig()
4028 * ice_rem_flow_all - remove all flows with a particular profile
4044 if (hw->blk[blk].xlt2.vsig_tbl[i].in_use) { in ice_rem_flow_all()
4057 list_del(&del->list_entry); in ice_rem_flow_all()
4065 * ice_rem_prof - remove profile
4079 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_rem_prof()
4088 status = ice_rem_flow_all(hw, blk, pmap->profile_cookie); in ice_rem_prof()
4093 ice_prof_dec_ref(hw, blk, pmap->prof_id); in ice_rem_prof()
4095 list_del(&pmap->list); in ice_rem_prof()
4099 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_rem_prof()
4104 * ice_get_prof - get profile
4119 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_get_prof()
4127 for (i = 0; i < map->ptg_cnt; i++) in ice_get_prof()
4128 if (!hw->blk[blk].es.written[map->prof_id]) { in ice_get_prof()
4137 p->type = ICE_PTG_ES_ADD; in ice_get_prof()
4138 p->ptype = 0; in ice_get_prof()
4139 p->ptg = map->ptg[i]; in ice_get_prof()
4140 p->add_ptg = 0; in ice_get_prof()
4142 p->add_prof = 1; in ice_get_prof()
4143 p->prof_id = map->prof_id; in ice_get_prof()
4145 hw->blk[blk].es.written[map->prof_id] = true; in ice_get_prof()
4147 list_add(&p->list_entry, chg); in ice_get_prof()
4151 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_get_prof()
4157 * ice_get_profs_vsig - get a copy of the list of profiles from a VSIG
4172 list_for_each_entry(ent1, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_get_profs_vsig()
4182 list_add_tail(&p->list, lst); in ice_get_profs_vsig()
4189 list_del(&ent1->list); in ice_get_profs_vsig()
4197 * ice_add_prof_to_lst - add profile entry to a list
4212 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_to_lst()
4225 p->profile_cookie = map->profile_cookie; in ice_add_prof_to_lst()
4226 p->prof_id = map->prof_id; in ice_add_prof_to_lst()
4227 p->tcam_count = map->ptg_cnt; in ice_add_prof_to_lst()
4229 for (i = 0; i < map->ptg_cnt; i++) { in ice_add_prof_to_lst()
4230 p->tcam[i].prof_id = map->prof_id; in ice_add_prof_to_lst()
4231 p->tcam[i].tcam_idx = ICE_INVALID_TCAM; in ice_add_prof_to_lst()
4232 p->tcam[i].ptg = map->ptg[i]; in ice_add_prof_to_lst()
4235 list_add(&p->list, lst); in ice_add_prof_to_lst()
4238 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_to_lst()
4243 * ice_move_vsi - move VSI to another VSIG
4271 p->type = ICE_VSI_MOVE; in ice_move_vsi()
4272 p->vsi = vsi; in ice_move_vsi()
4273 p->orig_vsig = orig_vsig; in ice_move_vsi()
4274 p->vsig = vsig; in ice_move_vsi()
4276 list_add(&p->list_entry, chg); in ice_move_vsi()
4282 * ice_rem_chg_tcam_ent - remove a specific TCAM entry from change list
4284 * @idx: the index of the TCAM entry to remove
4293 if (tmp->type == ICE_TCAM_ADD && tmp->tcam_idx == idx) { in ice_rem_chg_tcam_ent()
4294 list_del(&tmp->list_entry); in ice_rem_chg_tcam_ent()
4300 * ice_prof_tcam_ena_dis - add enable or disable TCAM change
4304 * @vsig: the VSIG of the TCAM entry
4305 * @tcam: pointer the TCAM info structure of the TCAM to disable
4308 * This function appends an enable or disable TCAM entry in the change log
4312 u16 vsig, struct ice_tcam_inf *tcam, in ice_prof_tcam_ena_dis() argument
4322 /* if disabling, free the TCAM */ in ice_prof_tcam_ena_dis()
4324 status = ice_rel_tcam_idx(hw, blk, tcam->tcam_idx); in ice_prof_tcam_ena_dis()
4326 /* if we have already created a change for this TCAM entry, then in ice_prof_tcam_ena_dis()
4328 * a TCAM entry we no longer will have ownership of. in ice_prof_tcam_ena_dis()
4330 ice_rem_chg_tcam_ent(hw, tcam->tcam_idx, chg); in ice_prof_tcam_ena_dis()
4331 tcam->tcam_idx = 0; in ice_prof_tcam_ena_dis()
4332 tcam->in_use = 0; in ice_prof_tcam_ena_dis()
4336 /* for re-enabling, reallocate a TCAM */ in ice_prof_tcam_ena_dis()
4337 status = ice_alloc_tcam_ent(hw, blk, &tcam->tcam_idx); in ice_prof_tcam_ena_dis()
4341 /* add TCAM to change list */ in ice_prof_tcam_ena_dis()
4346 status = ice_tcam_write_entry(hw, blk, tcam->tcam_idx, tcam->prof_id, in ice_prof_tcam_ena_dis()
4347 tcam->ptg, vsig, 0, 0, vl_msk, dc_msk, in ice_prof_tcam_ena_dis()
4352 tcam->in_use = 1; in ice_prof_tcam_ena_dis()
4354 p->type = ICE_TCAM_ADD; in ice_prof_tcam_ena_dis()
4355 p->add_tcam_idx = true; in ice_prof_tcam_ena_dis()
4356 p->prof_id = tcam->prof_id; in ice_prof_tcam_ena_dis()
4357 p->ptg = tcam->ptg; in ice_prof_tcam_ena_dis()
4358 p->vsig = 0; in ice_prof_tcam_ena_dis()
4359 p->tcam_idx = tcam->tcam_idx; in ice_prof_tcam_ena_dis()
4362 list_add(&p->list_entry, chg); in ice_prof_tcam_ena_dis()
4372 * ice_adj_prof_priorities - adjust profile based on priorities
4390 /* Priority is based on the order in which the profiles are added. The in ice_adj_prof_priorities()
4399 list_for_each_entry(t, &hw->blk[blk].xlt2.vsig_tbl[idx].prop_lst, in ice_adj_prof_priorities()
4403 for (i = 0; i < t->tcam_count; i++) { in ice_adj_prof_priorities()
4407 if (test_bit(t->tcam[i].ptg, ptgs_used) && in ice_adj_prof_priorities()
4408 t->tcam[i].in_use) { in ice_adj_prof_priorities()
4415 &t->tcam[i], in ice_adj_prof_priorities()
4419 } else if (!test_bit(t->tcam[i].ptg, ptgs_used) && in ice_adj_prof_priorities()
4420 !t->tcam[i].in_use) { in ice_adj_prof_priorities()
4426 &t->tcam[i], in ice_adj_prof_priorities()
4433 set_bit(t->tcam[i].ptg, ptgs_used); in ice_adj_prof_priorities()
4441 * ice_add_prof_id_vsig - add profile to VSIG
4472 mutex_lock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_id_vsig()
4480 t->profile_cookie = map->profile_cookie; in ice_add_prof_id_vsig()
4481 t->prof_id = map->prof_id; in ice_add_prof_id_vsig()
4482 t->tcam_count = map->ptg_cnt; in ice_add_prof_id_vsig()
4484 /* create TCAM entries */ in ice_add_prof_id_vsig()
4485 for (i = 0; i < map->ptg_cnt; i++) { in ice_add_prof_id_vsig()
4488 /* add TCAM to change list */ in ice_add_prof_id_vsig()
4495 /* allocate the TCAM entry index */ in ice_add_prof_id_vsig()
4502 t->tcam[i].ptg = map->ptg[i]; in ice_add_prof_id_vsig()
4503 t->tcam[i].prof_id = map->prof_id; in ice_add_prof_id_vsig()
4504 t->tcam[i].tcam_idx = tcam_idx; in ice_add_prof_id_vsig()
4505 t->tcam[i].in_use = true; in ice_add_prof_id_vsig()
4507 p->type = ICE_TCAM_ADD; in ice_add_prof_id_vsig()
4508 p->add_tcam_idx = true; in ice_add_prof_id_vsig()
4509 p->prof_id = t->tcam[i].prof_id; in ice_add_prof_id_vsig()
4510 p->ptg = t->tcam[i].ptg; in ice_add_prof_id_vsig()
4511 p->vsig = vsig; in ice_add_prof_id_vsig()
4512 p->tcam_idx = t->tcam[i].tcam_idx; in ice_add_prof_id_vsig()
4514 /* write the TCAM entry */ in ice_add_prof_id_vsig()
4515 status = ice_tcam_write_entry(hw, blk, t->tcam[i].tcam_idx, in ice_add_prof_id_vsig()
4516 t->tcam[i].prof_id, in ice_add_prof_id_vsig()
4517 t->tcam[i].ptg, vsig, 0, 0, in ice_add_prof_id_vsig()
4525 list_add(&p->list_entry, chg); in ice_add_prof_id_vsig()
4531 list_add_tail(&t->list, in ice_add_prof_id_vsig()
4532 &hw->blk[blk].xlt2.vsig_tbl[vsig_idx].prop_lst); in ice_add_prof_id_vsig()
4534 list_add(&t->list, in ice_add_prof_id_vsig()
4535 &hw->blk[blk].xlt2.vsig_tbl[vsig_idx].prop_lst); in ice_add_prof_id_vsig()
4537 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_id_vsig()
4541 mutex_unlock(&hw->blk[blk].es.prof_map_lock); in ice_add_prof_id_vsig()
4548 * ice_create_prof_id_vsig - add a new VSIG with a single profile
4581 p->type = ICE_VSIG_ADD; in ice_create_prof_id_vsig()
4582 p->vsi = vsi; in ice_create_prof_id_vsig()
4583 p->orig_vsig = ICE_DEFAULT_VSIG; in ice_create_prof_id_vsig()
4584 p->vsig = new_vsig; in ice_create_prof_id_vsig()
4586 list_add(&p->list_entry, chg); in ice_create_prof_id_vsig()
4597 * ice_create_vsig_from_lst - create a new VSIG with a list of profiles
4624 status = ice_add_prof_id_vsig(hw, blk, vsig, t->profile_cookie, in ice_create_vsig_from_lst()
4636 * ice_find_prof_vsig - find a VSIG with a specific profile handle
4655 t->profile_cookie = hdl; in ice_find_prof_vsig()
4656 list_add(&t->list, &lst); in ice_find_prof_vsig()
4660 list_del(&t->list); in ice_find_prof_vsig()
4667 * ice_add_prof_id_flow - add profile flow
4800 list_del(&del->list_entry); in ice_add_prof_id_flow()
4805 list_del(&del1->list); in ice_add_prof_id_flow()
4813 * ice_rem_prof_from_list - remove a profile from list
4824 if (ent->profile_cookie == hdl) { in ice_rem_prof_from_list()
4825 list_del(&ent->list); in ice_rem_prof_from_list()
4834 * ice_rem_prof_id_flow - remove flow
4929 * new VSIG and TCAM entries in ice_rem_prof_id_flow()
4954 list_del(&del->list_entry); in ice_rem_prof_id_flow()
4959 list_del(&del1->list); in ice_rem_prof_id_flow()