Lines Matching +full:multi +full:-
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /* Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved */
18 * +----------------------------------+
20 * +----------------------------------+
22 * | +------------------------------+ | +-----------------+
23 * | | package descriptor tlv +-----> |num_devices=n |
24 * | +------------------------------+ | |num_components=m |
25 * +----------------------------------+ |CB offset |
27 * | +------------------------------+ | | |
28 * | | PSID tlv | | +-----------------+
29 * | +------------------------------+ |
31 * | +------------------------------+ |
32 * +----------------------------------+
34 * | +------------------------------+ | +-----------------+
35 * | | component descriptor tlv +-----> |Among others: |
36 * | +------------------------------+ | |CB offset=o |
37 * +----------------------------------+ |comp index=i |
40 * | | +-----------------+
45 * +----------------------------------+
48 * - Fingerprint
49 * - Several multi_tlvs (TLVs of type MLXFW_MFA2_TLV_MULTI, as defined in
51 * - Compresses content block
54 * -------------------
55 * The first multi TLV is treated as package descriptor, and expected to have a
59 * multi TLV.
62 * -------------------------------
63 * The multi TLVs following the package descriptor are treated as device
65 * - PSID TLV child of type MLXFW_MFA2_TLV_PSID containing that device PSID.
66 * - Component index of type MLXFW_MFA2_TLV_COMPONENT_PTR that contains that
70 * ----------------------------------
71 * The multi TLVs following the device descriptor multi TLVs are treated as
80 sizeof(mlxfw_mfa2_fingerprint) - 1;
83 static const int mlxfw_mfa2_comp_magic_len = sizeof(mlxfw_mfa2_comp_magic) - 1;
87 if (fw->size < sizeof(mlxfw_mfa2_fingerprint)) in mlxfw_mfa2_check()
90 return memcmp(fw->data, mlxfw_mfa2_fingerprint, in mlxfw_mfa2_check()
96 const struct mlxfw_mfa2_tlv_multi *multi) in mlxfw_mfa2_tlv_multi_validate() argument
102 mlxfw_mfa2_tlv_multi_foreach(mfa2_file, tlv, idx, multi) { in mlxfw_mfa2_tlv_multi_validate()
104 pr_err("Multi has invalid child"); in mlxfw_mfa2_tlv_multi_validate()
117 const struct mlxfw_mfa2_tlv_multi *multi; in mlxfw_mfa2_file_dev_validate() local
126 multi = mlxfw_mfa2_tlv_multi_get(mfa2_file, dev_tlv); in mlxfw_mfa2_file_dev_validate()
127 if (!multi) { in mlxfw_mfa2_file_dev_validate()
132 if (!mlxfw_mfa2_tlv_multi_validate(mfa2_file, multi)) in mlxfw_mfa2_file_dev_validate()
136 tlv = mlxfw_mfa2_tlv_multi_child_find(mfa2_file, multi, in mlxfw_mfa2_file_dev_validate()
149 print_hex_dump_debug(" -- Device PSID ", DUMP_PREFIX_NONE, 16, 16, in mlxfw_mfa2_file_dev_validate()
150 psid->psid, be16_to_cpu(tlv->len), true); in mlxfw_mfa2_file_dev_validate()
153 err = mlxfw_mfa2_tlv_multi_child_count(mfa2_file, multi, in mlxfw_mfa2_file_dev_validate()
165 tlv = mlxfw_mfa2_tlv_multi_child_find(mfa2_file, multi, in mlxfw_mfa2_file_dev_validate()
178 pr_debug(" -- Component index %d\n", in mlxfw_mfa2_file_dev_validate()
179 be16_to_cpu(cptr->component_index)); in mlxfw_mfa2_file_dev_validate()
190 const struct mlxfw_mfa2_tlv_multi *multi; in mlxfw_mfa2_file_comp_validate() local
195 multi = mlxfw_mfa2_tlv_multi_get(mfa2_file, comp_tlv); in mlxfw_mfa2_file_comp_validate()
196 if (!multi) { in mlxfw_mfa2_file_comp_validate()
201 if (!mlxfw_mfa2_tlv_multi_validate(mfa2_file, multi)) in mlxfw_mfa2_file_comp_validate()
205 tlv = mlxfw_mfa2_tlv_multi_child(mfa2_file, multi); in mlxfw_mfa2_file_comp_validate()
207 pr_err("Component descriptor %d multi TLV error\n", comp_idx); in mlxfw_mfa2_file_comp_validate()
217 pr_debug(" -- Component type %d\n", be16_to_cpu(cdesc->identifier)); in mlxfw_mfa2_file_comp_validate()
218 pr_debug(" -- Offset 0x%llx and size %d\n", in mlxfw_mfa2_file_comp_validate()
219 ((u64) be32_to_cpu(cdesc->cb_offset_h) << 32) in mlxfw_mfa2_file_comp_validate()
220 | be32_to_cpu(cdesc->cb_offset_l), be32_to_cpu(cdesc->size)); in mlxfw_mfa2_file_comp_validate()
233 mlxfw_mfa2_tlv_foreach(mfa2_file, tlv, idx, mfa2_file->first_dev, in mlxfw_mfa2_file_validate()
234 mfa2_file->dev_count) { in mlxfw_mfa2_file_validate()
246 mlxfw_mfa2_tlv_foreach(mfa2_file, tlv, idx, mfa2_file->first_component, in mlxfw_mfa2_file_validate()
247 mfa2_file->component_count) { in mlxfw_mfa2_file_validate()
263 const struct mlxfw_mfa2_tlv_multi *multi; in mlxfw_mfa2_file_init() local
272 return ERR_PTR(-ENOMEM); in mlxfw_mfa2_file_init()
274 mfa2_file->fw = fw; in mlxfw_mfa2_file_init()
275 first_tlv_ptr = fw->data + NLA_ALIGN(mlxfw_mfa2_fingerprint_len); in mlxfw_mfa2_file_init()
282 multi = mlxfw_mfa2_tlv_multi_get(mfa2_file, first_tlv); in mlxfw_mfa2_file_init()
283 if (!multi) { in mlxfw_mfa2_file_init()
284 pr_err("First TLV is not of valid multi type\n"); in mlxfw_mfa2_file_init()
288 multi_child = mlxfw_mfa2_tlv_multi_child(mfa2_file, multi); in mlxfw_mfa2_file_init()
298 mfa2_file->first_dev = mlxfw_mfa2_tlv_next(mfa2_file, first_tlv); in mlxfw_mfa2_file_init()
299 if (!mfa2_file->first_dev) { in mlxfw_mfa2_file_init()
304 mfa2_file->dev_count = be16_to_cpu(pd->num_devices); in mlxfw_mfa2_file_init()
305 mfa2_file->first_component = mlxfw_mfa2_tlv_advance(mfa2_file, in mlxfw_mfa2_file_init()
306 mfa2_file->first_dev, in mlxfw_mfa2_file_init()
307 mfa2_file->dev_count); in mlxfw_mfa2_file_init()
308 mfa2_file->component_count = be16_to_cpu(pd->num_components); in mlxfw_mfa2_file_init()
309 mfa2_file->cb = fw->data + NLA_ALIGN(be32_to_cpu(pd->cb_offset)); in mlxfw_mfa2_file_init()
310 if (!mlxfw_mfa2_valid_ptr(mfa2_file, mfa2_file->cb)) { in mlxfw_mfa2_file_init()
314 mfa2_file->cb_archive_size = be32_to_cpu(pd->cb_archive_size); in mlxfw_mfa2_file_init()
315 cb_top_ptr = mfa2_file->cb + mfa2_file->cb_archive_size - 1; in mlxfw_mfa2_file_init()
326 return ERR_PTR(-EINVAL); in mlxfw_mfa2_file_init()
340 mlxfw_mfa2_tlv_foreach(mfa2_file, dev_tlv, idx, mfa2_file->first_dev, in mlxfw_mfa2_tlv_dev_get()
341 mfa2_file->dev_count) { in mlxfw_mfa2_tlv_dev_get()
354 if (be16_to_cpu(tlv->len) != psid_size) in mlxfw_mfa2_tlv_dev_get()
361 if (memcmp(psid, tlv_psid->psid, psid_size) == 0) in mlxfw_mfa2_tlv_dev_get()
378 return -EINVAL; in mlxfw_mfa2_file_component_count()
406 return -ENOMEM; in mlxfw_mfa2_xz_dec_run()
409 return -EINVAL; in mlxfw_mfa2_xz_dec_run()
412 return -EINVAL; in mlxfw_mfa2_xz_dec_run()
415 return -EINVAL; in mlxfw_mfa2_xz_dec_run()
418 return -EINVAL; in mlxfw_mfa2_xz_dec_run()
421 return -EINVAL; in mlxfw_mfa2_xz_dec_run()
434 xz_dec = xz_dec_init(XZ_DYNALLOC, (u32) -1); in mlxfw_mfa2_file_cb_offset_xz()
436 return -EINVAL; in mlxfw_mfa2_file_cb_offset_xz()
438 dec_buf.in_size = mfa2_file->cb_archive_size; in mlxfw_mfa2_file_cb_offset_xz()
439 dec_buf.in = mfa2_file->cb; in mlxfw_mfa2_file_cb_offset_xz()
446 dec_buf.out_size = min_t(size_t, size, off - curr_off); in mlxfw_mfa2_file_cb_offset_xz()
455 err = -EINVAL; in mlxfw_mfa2_file_cb_offset_xz()
474 const struct mlxfw_mfa2_tlv_multi *multi; in mlxfw_mfa2_file_component_tlv_get() local
478 if (comp_index > mfa2_file->component_count) in mlxfw_mfa2_file_component_tlv_get()
481 comp_tlv = mlxfw_mfa2_tlv_advance(mfa2_file, mfa2_file->first_component, in mlxfw_mfa2_file_component_tlv_get()
486 multi = mlxfw_mfa2_tlv_multi_get(mfa2_file, comp_tlv); in mlxfw_mfa2_file_component_tlv_get()
487 if (!multi) in mlxfw_mfa2_file_component_tlv_get()
490 multi_child = mlxfw_mfa2_tlv_multi_child(mfa2_file, multi); in mlxfw_mfa2_file_component_tlv_get()
526 comp_idx = be16_to_cpu(cptr->component_index); in mlxfw_mfa2_file_component_find()
545 return ERR_PTR(-EINVAL); in mlxfw_mfa2_file_component_get()
547 cb_offset = (u64) be32_to_cpu(comp->cb_offset_h) << 32 | in mlxfw_mfa2_file_component_get()
548 be32_to_cpu(comp->cb_offset_l); in mlxfw_mfa2_file_component_get()
549 comp_size = be32_to_cpu(comp->size); in mlxfw_mfa2_file_component_get()
554 return ERR_PTR(-ENOMEM); in mlxfw_mfa2_file_component_get()
555 comp_data->comp.data_size = comp_size; in mlxfw_mfa2_file_component_get()
556 comp_data->comp.index = be16_to_cpu(comp->identifier); in mlxfw_mfa2_file_component_get()
558 comp_data->buff); in mlxfw_mfa2_file_component_get()
564 if (memcmp(comp_data->buff, mlxfw_mfa2_comp_magic, in mlxfw_mfa2_file_component_get()
567 err = -EINVAL; in mlxfw_mfa2_file_component_get()
571 comp_data->comp.data = comp_data->buff + mlxfw_mfa2_comp_magic_len; in mlxfw_mfa2_file_component_get()
572 return &comp_data->comp; in mlxfw_mfa2_file_component_get()