1*2bb3e103SShalom Toledo /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 2*2bb3e103SShalom Toledo /* Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved */ 3410ed13cSYotam Gigi 4410ed13cSYotam Gigi #ifndef _MLXFW_MFA2_FILE_H 5410ed13cSYotam Gigi #define _MLXFW_MFA2_FILE_H 6410ed13cSYotam Gigi 7410ed13cSYotam Gigi #include <linux/firmware.h> 8410ed13cSYotam Gigi #include <linux/kernel.h> 9410ed13cSYotam Gigi 10410ed13cSYotam Gigi struct mlxfw_mfa2_file { 11410ed13cSYotam Gigi const struct firmware *fw; 12410ed13cSYotam Gigi const struct mlxfw_mfa2_tlv *first_dev; 13410ed13cSYotam Gigi u16 dev_count; 14410ed13cSYotam Gigi const struct mlxfw_mfa2_tlv *first_component; 15410ed13cSYotam Gigi u16 component_count; 16410ed13cSYotam Gigi const void *cb; /* components block */ 17410ed13cSYotam Gigi u32 cb_archive_size; /* size of compressed components block */ 18410ed13cSYotam Gigi }; 19410ed13cSYotam Gigi mlxfw_mfa2_valid_ptr(const struct mlxfw_mfa2_file * mfa2_file,const void * ptr)20410ed13cSYotam Gigistatic inline bool mlxfw_mfa2_valid_ptr(const struct mlxfw_mfa2_file *mfa2_file, 21410ed13cSYotam Gigi const void *ptr) 22410ed13cSYotam Gigi { 23410ed13cSYotam Gigi const void *valid_to = mfa2_file->fw->data + mfa2_file->fw->size; 24410ed13cSYotam Gigi const void *valid_from = mfa2_file->fw->data; 25410ed13cSYotam Gigi 26410ed13cSYotam Gigi return ptr > valid_from && ptr < valid_to; 27410ed13cSYotam Gigi } 28410ed13cSYotam Gigi 29410ed13cSYotam Gigi #endif 30