xref: /linux/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h (revision 597473720f4dc69749542bfcfed4a927a43d935e)
1 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
2 /* Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved */
3 
4 #ifndef _MLXFW_MFA2_FILE_H
5 #define _MLXFW_MFA2_FILE_H
6 
7 #include <linux/firmware.h>
8 #include <linux/kernel.h>
9 
10 struct mlxfw_mfa2_file {
11 	const struct firmware *fw;
12 	const struct mlxfw_mfa2_tlv *first_dev;
13 	u16 dev_count;
14 	const struct mlxfw_mfa2_tlv *first_component;
15 	u16 component_count;
16 	const void *cb; /* components block */
17 	u32 cb_archive_size; /* size of compressed components block */
18 };
19 
mlxfw_mfa2_valid_ptr(const struct mlxfw_mfa2_file * mfa2_file,const void * ptr)20 static inline bool mlxfw_mfa2_valid_ptr(const struct mlxfw_mfa2_file *mfa2_file,
21 					const void *ptr)
22 {
23 	const void *valid_to = mfa2_file->fw->data + mfa2_file->fw->size;
24 	const void *valid_from = mfa2_file->fw->data;
25 
26 	return ptr > valid_from && ptr < valid_to;
27 }
28 
29 #endif
30