Lines Matching +full:segment +full:- +full:0

1 // SPDX-License-Identifier: GPL-2.0
27 * ice_verify_pkg - verify package
32 * version, and the requirement of at least one segment.
42 if (pkg->pkg_format_ver.major != ICE_PKG_FMT_VER_MAJ || in ice_verify_pkg()
43 pkg->pkg_format_ver.minor != ICE_PKG_FMT_VER_MNR || in ice_verify_pkg()
44 pkg->pkg_format_ver.update != ICE_PKG_FMT_VER_UPD || in ice_verify_pkg()
45 pkg->pkg_format_ver.draft != ICE_PKG_FMT_VER_DFT) in ice_verify_pkg()
48 /* pkg must have at least one segment */ in ice_verify_pkg()
49 seg_count = le32_to_cpu(pkg->seg_count); in ice_verify_pkg()
53 /* make sure segment array fits in package length */ in ice_verify_pkg()
58 for (i = 0; i < seg_count; i++) { in ice_verify_pkg()
59 u32 off = le32_to_cpu(pkg->seg_offset[i]); in ice_verify_pkg()
62 /* segment header must fit */ in ice_verify_pkg()
68 /* segment body must fit */ in ice_verify_pkg()
69 if (len < off + le32_to_cpu(seg->seg_size)) in ice_verify_pkg()
77 * ice_free_seg - free package segment pointer
80 * Frees the package segment pointer in the proper manner, depending on if the
81 * segment was allocated or just the passed in pointer was stored.
85 if (hw->pkg_copy) { in ice_free_seg()
86 devm_kfree(ice_hw_to_dev(hw), hw->pkg_copy); in ice_free_seg()
87 hw->pkg_copy = NULL; in ice_free_seg()
88 hw->pkg_size = 0; in ice_free_seg()
90 hw->seg = NULL; in ice_free_seg()
94 * ice_chk_pkg_version - check package version for compatibility with driver
104 if (pkg_ver->major > ICE_PKG_SUPP_VER_MAJ || in ice_chk_pkg_version()
105 (pkg_ver->major == ICE_PKG_SUPP_VER_MAJ && in ice_chk_pkg_version()
106 pkg_ver->minor > ICE_PKG_SUPP_VER_MNR)) in ice_chk_pkg_version()
108 else if (pkg_ver->major < ICE_PKG_SUPP_VER_MAJ || in ice_chk_pkg_version()
109 (pkg_ver->major == ICE_PKG_SUPP_VER_MAJ && in ice_chk_pkg_version()
110 pkg_ver->minor < ICE_PKG_SUPP_VER_MNR)) in ice_chk_pkg_version()
128 hdr = (const struct ice_buf_hdr *)buf->buf; in ice_pkg_val_buf()
130 section_count = le16_to_cpu(hdr->section_count); in ice_pkg_val_buf()
134 data_end = le16_to_cpu(hdr->data_end); in ice_pkg_val_buf()
143 * @ice_seg: pointer to the ice segment
145 * Returns the address of the buffer table within the ice segment.
150 (ice_seg->device_table + le32_to_cpu(ice_seg->device_table_count)); in ice_find_buf_table()
152 return (__force struct ice_buf_table *)(nvms->vers + in ice_find_buf_table()
153 le32_to_cpu(nvms->table_count)); in ice_find_buf_table()
158 * @ice_seg: pointer to the ice segment (or NULL on subsequent calls)
161 * This function will enumerate all the buffers in the ice segment. The first
162 * call is made with the ice_seg parameter non-NULL; on subsequent calls,
172 state->buf_table = ice_find_buf_table(ice_seg); in ice_pkg_enum_buf()
173 if (!state->buf_table) in ice_pkg_enum_buf()
176 state->buf_idx = 0; in ice_pkg_enum_buf()
177 return ice_pkg_val_buf(state->buf_table->buf_array); in ice_pkg_enum_buf()
180 if (++state->buf_idx < le32_to_cpu(state->buf_table->buf_count)) in ice_pkg_enum_buf()
181 return ice_pkg_val_buf(state->buf_table->buf_array + in ice_pkg_enum_buf()
182 state->buf_idx); in ice_pkg_enum_buf()
189 * @ice_seg: pointer to the ice segment (or NULL on subsequent calls)
192 * This helper function will advance the section within the ice segment,
198 if (!ice_seg && !state->buf) in ice_pkg_advance_sect()
201 if (!ice_seg && state->buf) in ice_pkg_advance_sect()
202 if (++state->sect_idx < le16_to_cpu(state->buf->section_count)) in ice_pkg_advance_sect()
205 state->buf = ice_pkg_enum_buf(ice_seg, state); in ice_pkg_advance_sect()
206 if (!state->buf) in ice_pkg_advance_sect()
210 state->sect_idx = 0; in ice_pkg_advance_sect()
216 * @ice_seg: pointer to the ice segment (or NULL on subsequent calls)
221 * ice segment. The first call is made with the ice_seg parameter non-NULL;
232 state->type = sect_type; in ice_pkg_enum_section()
238 while (state->buf->section_entry[state->sect_idx].type != in ice_pkg_enum_section()
239 cpu_to_le32(state->type)) in ice_pkg_enum_section()
244 offset = le16_to_cpu(state->buf->section_entry[state->sect_idx].offset); in ice_pkg_enum_section()
248 size = le16_to_cpu(state->buf->section_entry[state->sect_idx].size); in ice_pkg_enum_section()
256 state->sect_type = in ice_pkg_enum_section()
257 le32_to_cpu(state->buf->section_entry[state->sect_idx].type); in ice_pkg_enum_section()
260 state->sect = in ice_pkg_enum_section()
261 ((u8 *)state->buf) + in ice_pkg_enum_section()
262 le16_to_cpu(state->buf->section_entry[state->sect_idx].offset); in ice_pkg_enum_section()
264 return state->sect; in ice_pkg_enum_section()
269 * @ice_seg: pointer to the ice segment (or NULL on subsequent calls)
276 * the ice segment. The first call is made with the ice_seg parameter non-NULL;
307 state->entry_idx = 0; in ice_pkg_enum_entry()
308 state->handler = handler; in ice_pkg_enum_entry()
310 state->entry_idx++; in ice_pkg_enum_entry()
313 if (!state->handler) in ice_pkg_enum_entry()
317 entry = state->handler(state->sect_type, state->sect, state->entry_idx, in ice_pkg_enum_entry()
321 if (!ice_pkg_enum_section(NULL, state, 0)) in ice_pkg_enum_entry()
324 state->entry_idx = 0; in ice_pkg_enum_entry()
325 entry = state->handler(state->sect_type, state->sect, in ice_pkg_enum_entry()
326 state->entry_idx, offset); in ice_pkg_enum_entry()
350 if (index >= le16_to_cpu(fv_section->count)) in ice_sw_fv_handler()
358 *offset = le16_to_cpu(fv_section->base_offset) + index; in ice_sw_fv_handler()
359 return fv_section->fv + index; in ice_sw_fv_handler()
363 * ice_get_prof_index_max - get the max profile index for used profile
372 u16 prof_index = 0, j, max_prof_index = 0; in ice_get_prof_index_max()
379 memset(&state, 0, sizeof(state)); in ice_get_prof_index_max()
381 if (!hw->seg) in ice_get_prof_index_max()
382 return -EINVAL; in ice_get_prof_index_max()
384 ice_seg = hw->seg; in ice_get_prof_index_max()
393 /* in the profile that not be used, the prot_id is set to 0xff in ice_get_prof_index_max()
394 * and the off is set to 0x1ff for all the field vectors. in ice_get_prof_index_max()
396 for (j = 0; j < hw->blk[ICE_BLK_SW].es.fvw; j++) in ice_get_prof_index_max()
397 if (fv->ew[j].prot_id != ICE_PROT_INVALID || in ice_get_prof_index_max()
398 fv->ew[j].off != ICE_FV_OFFSET_INVAL) in ice_get_prof_index_max()
407 hw->switch_info->max_used_prof_index = max_prof_index; in ice_get_prof_index_max()
409 return 0; in ice_get_prof_index_max()
413 * ice_get_ddp_pkg_state - get DDP pkg state after download
420 if (hw->pkg_ver.major == hw->active_pkg_ver.major && in ice_get_ddp_pkg_state()
421 hw->pkg_ver.minor == hw->active_pkg_ver.minor && in ice_get_ddp_pkg_state()
422 hw->pkg_ver.update == hw->active_pkg_ver.update && in ice_get_ddp_pkg_state()
423 hw->pkg_ver.draft == hw->active_pkg_ver.draft && in ice_get_ddp_pkg_state()
424 !memcmp(hw->pkg_name, hw->active_pkg_name, sizeof(hw->pkg_name))) { in ice_get_ddp_pkg_state()
429 } else if (hw->active_pkg_ver.major != ICE_PKG_SUPP_VER_MAJ || in ice_get_ddp_pkg_state()
430 hw->active_pkg_ver.minor != ICE_PKG_SUPP_VER_MNR) { in ice_get_ddp_pkg_state()
432 } else if (hw->active_pkg_ver.major == ICE_PKG_SUPP_VER_MAJ && in ice_get_ddp_pkg_state()
433 hw->active_pkg_ver.minor == ICE_PKG_SUPP_VER_MNR) { in ice_get_ddp_pkg_state()
441 * ice_init_pkg_regs - initialize additional package registers
446 #define ICE_SW_BLK_INP_MASK_L 0xFFFFFFFF in ice_init_pkg_regs()
447 #define ICE_SW_BLK_INP_MASK_H 0x0000FFFF in ice_init_pkg_regs()
448 #define ICE_SW_BLK_IDX 0 in ice_init_pkg_regs()
450 /* setup Switch block input mask, which is 48-bits in two parts */ in ice_init_pkg_regs()
460 * @offset: pointer to receive absolute offset, always 0 for ptype TCAM sections
477 *offset = 0; in ice_marker_ptype_tcam_handler()
480 if (index >= le16_to_cpu(marker_ptype->count)) in ice_marker_ptype_tcam_handler()
483 return marker_ptype->tcam + index; in ice_marker_ptype_tcam_handler()
494 if (hw->dvm_upd.count < ICE_DVM_MAX_ENTRIES) { in ice_add_dvm_hint()
495 hw->dvm_upd.tbl[hw->dvm_upd.count].boost_addr = val; in ice_add_dvm_hint()
496 hw->dvm_upd.tbl[hw->dvm_upd.count].enable = enable; in ice_add_dvm_hint()
497 hw->dvm_upd.count++; in ice_add_dvm_hint()
509 if (hw->tnl.count < ICE_TUNNEL_MAX_ENTRIES) { in ice_add_tunnel_hint()
512 for (i = 0; tnls[i].type != TNL_LAST; i++) { in ice_add_tunnel_hint()
520 * character ('0' - '7') will be located where our in ice_add_tunnel_hint()
523 if ((label_name[len] - '0') == hw->pf_id) { in ice_add_tunnel_hint()
524 hw->tnl.tbl[hw->tnl.count].type = tnls[i].type; in ice_add_tunnel_hint()
525 hw->tnl.tbl[hw->tnl.count].valid = false; in ice_add_tunnel_hint()
526 hw->tnl.tbl[hw->tnl.count].boost_addr = val; in ice_add_tunnel_hint()
527 hw->tnl.tbl[hw->tnl.count].port = 0; in ice_add_tunnel_hint()
528 hw->tnl.count++; in ice_add_tunnel_hint()
557 *offset = 0; in ice_label_enum_handler()
560 if (index >= le16_to_cpu(labels->count)) in ice_label_enum_handler()
563 return labels->label + index; in ice_label_enum_handler()
568 * @ice_seg: pointer to the ice segment (NULL on subsequent calls)
569 * @type: the section type that will contain the label (0 on subsequent calls)
575 * ice_enum_labels(NULL, 0, ...) to continue. When the function returns a NULL
592 *value = le16_to_cpu(label->value); in ice_enum_labels()
593 return label->name; in ice_enum_labels()
601 * @offset: pointer to receive absolute offset, always 0 for boost TCAM sections
621 *offset = 0; in ice_boost_tcam_handler()
624 if (index >= le16_to_cpu(boost->count)) in ice_boost_tcam_handler()
627 return boost->tcam + index; in ice_boost_tcam_handler()
632 * @ice_seg: pointer to the ice segment (non-NULL)
646 memset(&state, 0, sizeof(state)); in ice_find_boost_entry()
649 return -EINVAL; in ice_find_boost_entry()
655 if (tcam && le16_to_cpu(tcam->addr) == addr) { in ice_find_boost_entry()
657 return 0; in ice_find_boost_entry()
664 return -EIO; in ice_find_boost_entry()
668 * ice_is_init_pkg_successful - check if DDP init was successful
700 buf->data_end = in ice_pkg_buf_alloc()
732 * ice_get_sw_prof_type - determine switch profile type
751 for (i = 0; i < hw->blk[ICE_BLK_SW].es.fvw; i++) { in ice_get_sw_prof_type()
753 if (fv->ew[i].prot_id == (u8)ICE_PROT_UDP_OF && in ice_get_sw_prof_type()
754 fv->ew[i].off == ICE_VNI_OFFSET) in ice_get_sw_prof_type()
758 if (fv->ew[i].prot_id == (u8)ICE_PROT_GRE_OF) in ice_get_sw_prof_type()
766 * ice_get_sw_fv_bitmap - Get switch field vector bitmap based on profile type
779 bitmap_set(bm, 0, ICE_MAX_NUM_PROFILES); in ice_get_sw_fv_bitmap()
783 memset(&state, 0, sizeof(state)); in ice_get_sw_fv_bitmap()
785 ice_seg = hw->seg; in ice_get_sw_fv_bitmap()
828 memset(&state, 0, sizeof(state)); in ice_get_sw_fv_list()
830 if (!lkups->n_val_words || !hw->seg) in ice_get_sw_fv_list()
831 return -EINVAL; in ice_get_sw_fv_list()
833 ice_seg = hw->seg; in ice_get_sw_fv_list()
849 for (i = 0; i < lkups->n_val_words; i++) { in ice_get_sw_fv_list()
852 for (j = 0; j < hw->blk[ICE_BLK_SW].es.fvw; j++) in ice_get_sw_fv_list()
853 if (fv->ew[j].prot_id == in ice_get_sw_fv_list()
854 lkups->fv_words[i].prot_id && in ice_get_sw_fv_list()
855 fv->ew[j].off == lkups->fv_words[i].off) in ice_get_sw_fv_list()
857 if (j >= hw->blk[ICE_BLK_SW].es.fvw) in ice_get_sw_fv_list()
859 if (i + 1 == lkups->n_val_words) { in ice_get_sw_fv_list()
864 fvl->fv_ptr = fv; in ice_get_sw_fv_list()
865 fvl->profile_id = offset; in ice_get_sw_fv_list()
866 list_add(&fvl->list_entry, fv_list); in ice_get_sw_fv_list()
874 return -EIO; in ice_get_sw_fv_list()
877 return 0; in ice_get_sw_fv_list()
881 list_del(&fvl->list_entry); in ice_get_sw_fv_list()
885 return -ENOMEM; in ice_get_sw_fv_list()
889 * ice_init_prof_result_bm - Initialize the profile result index bitmap
898 memset(&state, 0, sizeof(state)); in ice_init_prof_result_bm()
900 if (!hw->seg) in ice_init_prof_result_bm()
903 ice_seg = hw->seg; in ice_init_prof_result_bm()
914 bitmap_zero(hw->switch_info->prof_res_bm[off], in ice_init_prof_result_bm()
918 * used for recipe results. Skip index 0, since it is in ice_init_prof_result_bm()
922 if (fv->ew[i].prot_id == ICE_PROT_INVALID && in ice_init_prof_result_bm()
923 fv->ew[i].off == ICE_FV_OFFSET_INVAL) in ice_init_prof_result_bm()
924 set_bit(i, hw->switch_info->prof_res_bm[off]); in ice_init_prof_result_bm()
960 return -EINVAL; in ice_pkg_buf_reserve_section()
962 buf = (struct ice_buf_hdr *)&bld->buf; in ice_pkg_buf_reserve_section()
965 section_count = le16_to_cpu(buf->section_count); in ice_pkg_buf_reserve_section()
966 if (section_count > 0) in ice_pkg_buf_reserve_section()
967 return -EIO; in ice_pkg_buf_reserve_section()
969 if (bld->reserved_section_table_entries + count > ICE_MAX_S_COUNT) in ice_pkg_buf_reserve_section()
970 return -EIO; in ice_pkg_buf_reserve_section()
971 bld->reserved_section_table_entries += count; in ice_pkg_buf_reserve_section()
973 data_end = le16_to_cpu(buf->data_end) + in ice_pkg_buf_reserve_section()
975 buf->data_end = cpu_to_le16(data_end); in ice_pkg_buf_reserve_section()
977 return 0; in ice_pkg_buf_reserve_section()
1001 buf = (struct ice_buf_hdr *)&bld->buf; in ice_pkg_buf_alloc_section()
1004 data_end = le16_to_cpu(buf->data_end); in ice_pkg_buf_alloc_section()
1013 sect_count = le16_to_cpu(buf->section_count); in ice_pkg_buf_alloc_section()
1014 if (sect_count < bld->reserved_section_table_entries) { in ice_pkg_buf_alloc_section()
1017 buf->section_entry[sect_count].offset = cpu_to_le16(data_end); in ice_pkg_buf_alloc_section()
1018 buf->section_entry[sect_count].size = cpu_to_le16(size); in ice_pkg_buf_alloc_section()
1019 buf->section_entry[sect_count].type = cpu_to_le32(type); in ice_pkg_buf_alloc_section()
1022 buf->data_end = cpu_to_le16(data_end); in ice_pkg_buf_alloc_section()
1024 buf->section_count = cpu_to_le16(sect_count + 1); in ice_pkg_buf_alloc_section()
1075 * least one active section - otherwise, the buffer is not legal and should
1084 return 0; in ice_pkg_buf_get_active_sections()
1086 buf = (struct ice_buf_hdr *)&bld->buf; in ice_pkg_buf_get_active_sections()
1087 return le16_to_cpu(buf->section_count); in ice_pkg_buf_get_active_sections()
1101 return &bld->buf; in ice_pkg_buf()
1129 * 0 - Means the caller has acquired the global config lock
1131 * -EALREADY - Indicates another driver has already written the
1146 else if (status == -EALREADY) in ice_acquire_global_cfg_lock()
1175 * Download Package (0x0C40)
1187 *error_offset = 0; in ice_aq_download_pkg()
1189 *error_info = 0; in ice_aq_download_pkg()
1196 cmd->flags |= ICE_AQC_DOWNLOAD_PKG_LAST_BUF; in ice_aq_download_pkg()
1199 if (status == -EIO) { in ice_aq_download_pkg()
1205 *error_offset = le32_to_cpu(resp->error_offset); in ice_aq_download_pkg()
1207 *error_info = le32_to_cpu(resp->error_info); in ice_aq_download_pkg()
1214 * ice_is_buffer_metadata - determine if package buffer is a metadata buffer
1220 return le32_to_cpu(buf->section_entry[0].type) & ICE_METADATA_BUF; in ice_is_buffer_metadata()
1224 * struct ice_ddp_send_ctx - sending context of current DDP segment
1239 ctx->err = err; in ice_ddp_send_ctx_set_err()
1243 * ice_ddp_send_hunk - send one hunk of data to FW
1244 * @ctx: current segment sending context
1259 struct ice_buf_hdr *prev_hunk = ctx->hdr; in ice_ddp_send_hunk()
1260 struct ice_hw *hw = ctx->hw; in ice_ddp_send_hunk()
1266 if (ctx->err) in ice_ddp_send_hunk()
1267 return ctx->err; in ice_ddp_send_hunk()
1269 ctx->hdr = hunk; in ice_ddp_send_hunk()
1273 for (attempt = 0; attempt < 5; attempt++) { in ice_ddp_send_hunk()
1280 aq_err = hw->adminq.sq_last_status; in ice_ddp_send_hunk()
1289 ctx->err = ice_map_aq_err_to_ddp_state(aq_err); in ice_ddp_send_hunk()
1295 return ctx->err; in ice_ddp_send_hunk()
1323 for (int i = 0; i < count; i++, bufs++) { in ice_dwnld_cfg_bufs_no_lock()
1336 return 0; in ice_dwnld_cfg_bufs_no_lock()
1342 * @idx: index of segment
1347 if (idx < le32_to_cpu(pkg_hdr->seg_count)) in ice_get_pkg_seg_by_idx()
1350 le32_to_cpu(pkg_hdr->seg_offset[idx])); in ice_get_pkg_seg_by_idx()
1356 * ice_is_signing_seg_at_idx - determine if segment is a signing segment
1358 * @idx: segment index
1368 return le32_to_cpu(seg->seg_type) == SEGMENT_TYPE_SIGNING; in ice_is_signing_seg_at_idx()
1374 * @idx: segment index
1375 * @seg_id: segment id that is expected
1378 * Determine if a segment is a signing segment of the correct type
1391 if (seg && le32_to_cpu(seg->seg_id) == seg_id && in ice_is_signing_seg_type_at_idx()
1392 le32_to_cpu(seg->sign_type) == sign_type) in ice_is_signing_seg_type_at_idx()
1399 * ice_download_pkg_sig_seg - download a signature segment
1401 * @seg: pointer to signature segment
1406 return ice_dwnld_cfg_bufs_no_lock(ctx, seg->buf_tbl.buf_array, 0, in ice_download_pkg_sig_seg()
1407 le32_to_cpu(seg->buf_tbl.buf_count)); in ice_download_pkg_sig_seg()
1411 * ice_download_pkg_config_seg - download a config segment
1414 * @idx: segment index
1418 * Note: idx must reference a ICE segment
1434 buf_count = le32_to_cpu(bufs->buf_count); in ice_download_pkg_config_seg()
1439 return ice_dwnld_cfg_bufs_no_lock(ctx, bufs->buf_array, start, count); in ice_download_pkg_config_seg()
1449 * ice_dwnld_sign_and_cfg_segs - download a signing segment and config segment
1452 * @idx: segment index (must be a signature segment)
1454 * Note: idx must reference a signature segment
1471 count = le32_to_cpu(seg->signed_buf_count); in ice_dwnld_sign_and_cfg_segs()
1476 conf_idx = le32_to_cpu(seg->signed_seg_idx); in ice_dwnld_sign_and_cfg_segs()
1477 start = le32_to_cpu(seg->signed_buf_start); in ice_dwnld_sign_and_cfg_segs()
1485 flags = le32_to_cpu(seg->flags); in ice_dwnld_sign_and_cfg_segs()
1493 * ice_match_signing_seg - determine if a matching signing segment exists
1495 * @seg_id: segment id that is expected
1503 for (i = 0; i < le32_to_cpu(pkg_hdr->seg_count); i++) { in ice_match_signing_seg()
1513 * ice_post_dwnld_pkg_actions - perform post download package actions
1541 enum libie_aq_err aq_err = hw->adminq.sq_last_status; in ice_download_pkg_with_sig_seg()
1547 ice_debug(hw, ICE_DBG_INIT, "Segment ID %d\n", hw->pkg_seg_id); in ice_download_pkg_with_sig_seg()
1548 ice_debug(hw, ICE_DBG_INIT, "Signature type %d\n", hw->pkg_sign_type); in ice_download_pkg_with_sig_seg()
1552 if (status == -EALREADY) in ice_download_pkg_with_sig_seg()
1559 for (i = 0; i < le32_to_cpu(pkg_hdr->seg_count); i++) { in ice_download_pkg_with_sig_seg()
1560 if (!ice_is_signing_seg_type_at_idx(pkg_hdr, i, hw->pkg_seg_id, in ice_download_pkg_with_sig_seg()
1561 hw->pkg_sign_type)) in ice_download_pkg_with_sig_seg()
1607 if (status == -EALREADY) in ice_dwnld_cfg_bufs()
1609 return ice_map_aq_err_to_ddp_state(hw->adminq.sq_last_status); in ice_dwnld_cfg_bufs()
1612 ice_dwnld_cfg_bufs_no_lock(&ctx, bufs, 0, count); in ice_dwnld_cfg_bufs()
1626 * @ice_seg: pointer to the segment of the package to be downloaded
1628 * Handles the download of a complete package without signature segment.
1635 ice_debug(hw, ICE_DBG_PKG, "Segment format version: %d.%d.%d.%d\n", in ice_download_pkg_without_sig_seg()
1636 ice_seg->hdr.seg_format_ver.major, in ice_download_pkg_without_sig_seg()
1637 ice_seg->hdr.seg_format_ver.minor, in ice_download_pkg_without_sig_seg()
1638 ice_seg->hdr.seg_format_ver.update, in ice_download_pkg_without_sig_seg()
1639 ice_seg->hdr.seg_format_ver.draft); in ice_download_pkg_without_sig_seg()
1641 ice_debug(hw, ICE_DBG_PKG, "Seg: type 0x%X, size %d, name %s\n", in ice_download_pkg_without_sig_seg()
1642 le32_to_cpu(ice_seg->hdr.seg_type), in ice_download_pkg_without_sig_seg()
1643 le32_to_cpu(ice_seg->hdr.seg_size), ice_seg->hdr.seg_id); in ice_download_pkg_without_sig_seg()
1648 le32_to_cpu(ice_buf_tbl->buf_count)); in ice_download_pkg_without_sig_seg()
1650 return ice_dwnld_cfg_bufs(hw, ice_buf_tbl->buf_array, in ice_download_pkg_without_sig_seg()
1651 le32_to_cpu(ice_buf_tbl->buf_count)); in ice_download_pkg_without_sig_seg()
1658 * @ice_seg: pointer to the segment of the package to be downloaded
1668 if (hw->pkg_has_signing_seg) in ice_download_pkg()
1685 * Get Package Info List (0x0C43)
1708 * Update Package (0x0C42)
1719 *error_offset = 0; in ice_aq_update_pkg()
1721 *error_info = 0; in ice_aq_update_pkg()
1728 cmd->flags |= ICE_AQC_DOWNLOAD_PKG_LAST_BUF; in ice_aq_update_pkg()
1731 if (status == -EIO) { in ice_aq_update_pkg()
1737 *error_offset = le32_to_cpu(resp->error_offset); in ice_aq_update_pkg()
1739 *error_info = le32_to_cpu(resp->error_info); in ice_aq_update_pkg()
1752 * Upload Section (0x0C41)
1773 int status = 0; in ice_update_pkg_no_lock()
1776 for (i = 0; i < count; i++) { in ice_update_pkg_no_lock()
1781 status = ice_aq_update_pkg(hw, bh, le16_to_cpu(bh->data_end), in ice_update_pkg_no_lock()
1821 * @seg_type: the segment type to search for (i.e., SEGMENT_TYPE_CPK)
1824 * This function searches a package file for a particular segment type. On
1825 * success it returns a pointer to the segment header, otherwise it will
1835 pkg_hdr->pkg_format_ver.major, pkg_hdr->pkg_format_ver.minor, in ice_find_seg_in_pkg()
1836 pkg_hdr->pkg_format_ver.update, in ice_find_seg_in_pkg()
1837 pkg_hdr->pkg_format_ver.draft); in ice_find_seg_in_pkg()
1839 /* Search all package segments for the requested segment type */ in ice_find_seg_in_pkg()
1840 for (i = 0; i < le32_to_cpu(pkg_hdr->seg_count); i++) { in ice_find_seg_in_pkg()
1843 seg = (void *)pkg_hdr + le32_to_cpu(pkg_hdr->seg_offset[i]); in ice_find_seg_in_pkg()
1845 if (le32_to_cpu(seg->seg_type) == seg_type) in ice_find_seg_in_pkg()
1853 * ice_has_signing_seg - determine if package has a signing segment
1868 * ice_get_pkg_segment_id - get correct package segment id, based on device
1890 * ice_get_pkg_sign_type - get package segment sign type, based on device
1914 * ice_get_signing_req - get correct package requirements, based on device
1919 hw->pkg_seg_id = ice_get_pkg_segment_id(hw->mac_type); in ice_get_signing_req()
1920 hw->pkg_sign_type = ice_get_pkg_sign_type(hw->mac_type); in ice_get_signing_req()
1938 hw->pkg_has_signing_seg = ice_has_signing_seg(hw, pkg_hdr); in ice_init_pkg_info()
1941 ice_debug(hw, ICE_DBG_INIT, "Pkg using segment id: 0x%08X\n", in ice_init_pkg_info()
1942 hw->pkg_seg_id); in ice_init_pkg_info()
1945 ice_find_seg_in_pkg(hw, hw->pkg_seg_id, pkg_hdr); in ice_init_pkg_info()
1950 memset(&state, 0, sizeof(state)); in ice_init_pkg_info()
1961 hw->pkg_ver = meta->ver; in ice_init_pkg_info()
1962 memcpy(hw->pkg_name, meta->name, sizeof(meta->name)); in ice_init_pkg_info()
1965 meta->ver.major, meta->ver.minor, meta->ver.update, in ice_init_pkg_info()
1966 meta->ver.draft, meta->name); in ice_init_pkg_info()
1968 hw->ice_seg_fmt_ver = seg_hdr->seg_format_ver; in ice_init_pkg_info()
1969 memcpy(hw->ice_seg_id, seg_hdr->seg_id, sizeof(hw->ice_seg_id)); in ice_init_pkg_info()
1972 seg_hdr->seg_format_ver.major, in ice_init_pkg_info()
1973 seg_hdr->seg_format_ver.minor, in ice_init_pkg_info()
1974 seg_hdr->seg_format_ver.update, in ice_init_pkg_info()
1975 seg_hdr->seg_format_ver.draft, seg_hdr->seg_id); in ice_init_pkg_info()
1978 "Did not find ice segment in driver package\n"); in ice_init_pkg_info()
2001 for (i = 0; i < le32_to_cpu(pkg_info->count); i++) { in ice_get_pkg_info()
2003 char flags[ICE_PKG_FLAG_COUNT + 1] = { 0 }; in ice_get_pkg_info()
2004 u8 place = 0; in ice_get_pkg_info()
2006 if (pkg_info->pkg_info[i].is_active) { in ice_get_pkg_info()
2008 hw->active_pkg_ver = pkg_info->pkg_info[i].ver; in ice_get_pkg_info()
2009 hw->active_track_id = in ice_get_pkg_info()
2010 le32_to_cpu(pkg_info->pkg_info[i].track_id); in ice_get_pkg_info()
2011 memcpy(hw->active_pkg_name, pkg_info->pkg_info[i].name, in ice_get_pkg_info()
2012 sizeof(pkg_info->pkg_info[i].name)); in ice_get_pkg_info()
2013 hw->active_pkg_in_nvm = pkg_info->pkg_info[i].is_in_nvm; in ice_get_pkg_info()
2015 if (pkg_info->pkg_info[i].is_active_at_boot) in ice_get_pkg_info()
2017 if (pkg_info->pkg_info[i].is_modified) in ice_get_pkg_info()
2019 if (pkg_info->pkg_info[i].is_in_nvm) in ice_get_pkg_info()
2023 pkg_info->pkg_info[i].ver.major, in ice_get_pkg_info()
2024 pkg_info->pkg_info[i].ver.minor, in ice_get_pkg_info()
2025 pkg_info->pkg_info[i].ver.update, in ice_get_pkg_info()
2026 pkg_info->pkg_info[i].ver.draft, in ice_get_pkg_info()
2027 pkg_info->pkg_info[i].name, flags); in ice_get_pkg_info()
2037 * @seg: pointer to the package segment hdr
2052 state = ice_chk_pkg_version(&hw->pkg_ver); in ice_chk_pkg_compat()
2058 /* find ICE segment in given package */ in ice_chk_pkg_compat()
2059 *seg = (struct ice_seg *)ice_find_seg_in_pkg(hw, hw->pkg_seg_id, in ice_chk_pkg_compat()
2062 ice_debug(hw, ICE_DBG_INIT, "no ice segment in package.\n"); in ice_chk_pkg_compat()
2070 for (i = 0; i < le32_to_cpu(pkg->count); i++) { in ice_chk_pkg_compat()
2072 if (!pkg->pkg_info[i].is_in_nvm) in ice_chk_pkg_compat()
2074 if ((*seg)->hdr.seg_format_ver.major != in ice_chk_pkg_compat()
2075 pkg->pkg_info[i].ver.major || in ice_chk_pkg_compat()
2076 (*seg)->hdr.seg_format_ver.minor > in ice_chk_pkg_compat()
2077 pkg->pkg_info[i].ver.minor) { in ice_chk_pkg_compat()
2092 * @ice_seg: pointer to the segment of the package scan (non-NULL)
2106 memset(&hw->tnl, 0, sizeof(hw->tnl)); in ice_init_pkg_hints()
2107 memset(&state, 0, sizeof(state)); in ice_init_pkg_hints()
2128 label_name = ice_enum_labels(NULL, 0, &state, &val); in ice_init_pkg_hints()
2132 for (i = 0; i < hw->tnl.count; i++) { in ice_init_pkg_hints()
2133 ice_find_boost_entry(ice_seg, hw->tnl.tbl[i].boost_addr, in ice_init_pkg_hints()
2134 &hw->tnl.tbl[i].boost_entry); in ice_init_pkg_hints()
2135 if (hw->tnl.tbl[i].boost_entry) { in ice_init_pkg_hints()
2136 hw->tnl.tbl[i].valid = true; in ice_init_pkg_hints()
2137 if (hw->tnl.tbl[i].type < __TNL_TYPE_CNT) in ice_init_pkg_hints()
2138 hw->tnl.valid_count[hw->tnl.tbl[i].type]++; in ice_init_pkg_hints()
2143 for (i = 0; i < hw->dvm_upd.count; i++) in ice_init_pkg_hints()
2144 ice_find_boost_entry(ice_seg, hw->dvm_upd.tbl[i].boost_addr, in ice_init_pkg_hints()
2145 &hw->dvm_upd.tbl[i].boost_entry); in ice_init_pkg_hints()
2149 * ice_fill_hw_ptype - fill the enabled PTYPE bit information
2155 struct ice_seg *seg = hw->seg; in ice_fill_hw_ptype()
2158 bitmap_zero(hw->hw_ptype, ICE_FLOW_PTYPE_MAX); in ice_fill_hw_ptype()
2162 memset(&state, 0, sizeof(state)); in ice_fill_hw_ptype()
2169 le16_to_cpu(tcam->addr) < ICE_MARKER_PTYPE_TCAM_ADDR_MAX && in ice_fill_hw_ptype()
2170 le16_to_cpu(tcam->ptype) < ICE_FLOW_PTYPE_MAX) in ice_fill_hw_ptype()
2171 set_bit(le16_to_cpu(tcam->ptype), hw->hw_ptype); in ice_fill_hw_ptype()
2178 * ice_init_pkg - initialize/download package
2185 * information such as version. Then it finds the ice configuration segment
2186 * within the package; this function then saves a copy of the segment pointer
2225 /* must be a matching segment */ in ice_init_pkg()
2226 if (hw->pkg_has_signing_seg && in ice_init_pkg()
2227 !ice_match_signing_seg(pkg, hw->pkg_seg_id, hw->pkg_sign_type)) in ice_init_pkg()
2242 "package previously loaded - no work.\n"); in ice_init_pkg()
2256 hw->seg = seg; in ice_init_pkg()
2273 * ice_copy_and_init_pkg - initialize/download a copy of the package
2284 * If the package buffer resides in the data segment and can be modified, the
2314 hw->pkg_copy = buf_copy; in ice_copy_and_init_pkg()
2315 hw->pkg_size = len; in ice_copy_and_init_pkg()
2322 * ice_get_set_tx_topo - get or set Tx topology
2328 * @set: 0-get, 1-set topology
2345 cmd->set_flags = ICE_AQC_TX_TOPO_FLAGS_ISSUED; in ice_get_set_tx_topo()
2348 cmd->set_flags |= ICE_AQC_TX_TOPO_FLAGS_SRC_RAM | in ice_get_set_tx_topo()
2354 cmd->get_flags = ICE_AQC_TX_TOPO_GET_RAM; in ice_get_set_tx_topo()
2356 if (hw->mac_type == ICE_MAC_E810 || in ice_get_set_tx_topo()
2357 hw->mac_type == ICE_MAC_GENERIC) in ice_get_set_tx_topo()
2366 *flags = cmd->set_flags; in ice_get_set_tx_topo()
2368 return 0; in ice_get_set_tx_topo()
2372 * ice_cfg_tx_topo - Initialize new Tx topology if available
2381 * * 0 - Successfully applied topology configuration.
2382 * * -EBUSY - Failed to acquire global configuration lock.
2383 * * -EEXIST - Topology configuration has already been applied.
2384 * * -EIO - Unable to apply topology configuration.
2385 * * -ENODEV - Failed to re-initialize device after applying configuration.
2395 u16 offset, size = 0; in ice_cfg_tx_topo()
2396 u32 reg = 0; in ice_cfg_tx_topo()
2401 return -EINVAL; in ice_cfg_tx_topo()
2404 if (!hw->func_caps.common_cap.tx_sched_topo_comp_mode_en) { in ice_cfg_tx_topo()
2406 return -EOPNOTSUPP; in ice_cfg_tx_topo()
2411 return -ENOMEM; in ice_cfg_tx_topo()
2419 return -EIO; in ice_cfg_tx_topo()
2424 hw->num_tx_sched_layers == ICE_SCHED_9_LAYERS) { in ice_cfg_tx_topo()
2426 return -EEXIST; in ice_cfg_tx_topo()
2431 hw->num_tx_sched_layers == ICE_SCHED_5_LAYERS) { in ice_cfg_tx_topo()
2433 return -EEXIST; in ice_cfg_tx_topo()
2441 return -EEXIST; in ice_cfg_tx_topo()
2446 hw->num_tx_sched_layers == ICE_SCHED_5_LAYERS) { in ice_cfg_tx_topo()
2456 return -EIO; in ice_cfg_tx_topo()
2459 /* Find runtime configuration segment */ in ice_cfg_tx_topo()
2463 ice_debug(hw, ICE_DBG_INIT, "5 layer topology segment is missing\n"); in ice_cfg_tx_topo()
2464 return -EIO; in ice_cfg_tx_topo()
2467 if (le32_to_cpu(seg->buf_table.buf_count) < ICE_MIN_S_COUNT) { in ice_cfg_tx_topo()
2468 ice_debug(hw, ICE_DBG_INIT, "5 layer topology segment count(%d) is wrong\n", in ice_cfg_tx_topo()
2469 seg->buf_table.buf_count); in ice_cfg_tx_topo()
2470 return -EIO; in ice_cfg_tx_topo()
2473 section = ice_pkg_val_buf(seg->buf_table.buf_array); in ice_cfg_tx_topo()
2474 if (!section || le32_to_cpu(section->section_entry[0].type) != in ice_cfg_tx_topo()
2477 return -EIO; in ice_cfg_tx_topo()
2480 size = le16_to_cpu(section->section_entry[0].size); in ice_cfg_tx_topo()
2481 offset = le16_to_cpu(section->section_entry[0].offset); in ice_cfg_tx_topo()
2484 return -EIO; in ice_cfg_tx_topo()
2490 return -EIO; in ice_cfg_tx_topo()
2506 return -EBUSY; in ice_cfg_tx_topo()
2514 /* Reset is in progress, re-init the HW again */ in ice_cfg_tx_topo()
2523 /* only report -EIO here as the caller checks the error value in ice_cfg_tx_topo()
2527 status = -EIO; in ice_cfg_tx_topo()
2539 /* Since we triggered a CORER, re-initialize hardware */ in ice_cfg_tx_topo()
2542 ice_debug(hw, ICE_DBG_INIT, "Failed to re-init hardware after setting Tx topology\n"); in ice_cfg_tx_topo()
2543 return -ENODEV; in ice_cfg_tx_topo()