xref: /linux/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h (revision 597473720f4dc69749542bfcfed4a927a43d935e)
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 */
3*2bb3e103SShalom Toledo 
4410ed13cSYotam Gigi #ifndef _MLXFW_MFA2_TLV_MULTI_H
5410ed13cSYotam Gigi #define _MLXFW_MFA2_TLV_MULTI_H
6410ed13cSYotam Gigi 
7410ed13cSYotam Gigi #include "mlxfw_mfa2_tlv.h"
8410ed13cSYotam Gigi #include "mlxfw_mfa2_format.h"
9410ed13cSYotam Gigi #include "mlxfw_mfa2_file.h"
10410ed13cSYotam Gigi 
11410ed13cSYotam Gigi const struct mlxfw_mfa2_tlv *
12410ed13cSYotam Gigi mlxfw_mfa2_tlv_multi_child(const struct mlxfw_mfa2_file *mfa2_file,
13410ed13cSYotam Gigi 			   const struct mlxfw_mfa2_tlv_multi *multi);
14410ed13cSYotam Gigi 
15410ed13cSYotam Gigi const struct mlxfw_mfa2_tlv *
16410ed13cSYotam Gigi mlxfw_mfa2_tlv_next(const struct mlxfw_mfa2_file *mfa2_file,
17410ed13cSYotam Gigi 		    const struct mlxfw_mfa2_tlv *tlv);
18410ed13cSYotam Gigi 
19410ed13cSYotam Gigi const struct mlxfw_mfa2_tlv *
20410ed13cSYotam Gigi mlxfw_mfa2_tlv_advance(const struct mlxfw_mfa2_file *mfa2_file,
21410ed13cSYotam Gigi 		       const struct mlxfw_mfa2_tlv *from_tlv, u16 count);
22410ed13cSYotam Gigi 
23410ed13cSYotam Gigi const struct mlxfw_mfa2_tlv *
24410ed13cSYotam Gigi mlxfw_mfa2_tlv_multi_child_find(const struct mlxfw_mfa2_file *mfa2_file,
25410ed13cSYotam Gigi 				const struct mlxfw_mfa2_tlv_multi *multi,
26410ed13cSYotam Gigi 				enum mlxfw_mfa2_tlv_type type, u16 index);
27410ed13cSYotam Gigi 
28410ed13cSYotam Gigi int mlxfw_mfa2_tlv_multi_child_count(const struct mlxfw_mfa2_file *mfa2_file,
29410ed13cSYotam Gigi 				     const struct mlxfw_mfa2_tlv_multi *multi,
30410ed13cSYotam Gigi 				     enum mlxfw_mfa2_tlv_type type,
31410ed13cSYotam Gigi 				     u16 *p_count);
32410ed13cSYotam Gigi 
33410ed13cSYotam Gigi #define mlxfw_mfa2_tlv_foreach(mfa2_file, tlv, idx, from_tlv, count) \
34410ed13cSYotam Gigi 	for (idx = 0, tlv = from_tlv; idx < (count); \
35410ed13cSYotam Gigi 	     idx++, tlv = mlxfw_mfa2_tlv_next(mfa2_file, tlv))
36410ed13cSYotam Gigi 
37410ed13cSYotam Gigi #define mlxfw_mfa2_tlv_multi_foreach(mfa2_file, tlv, idx, multi) \
38410ed13cSYotam Gigi 	mlxfw_mfa2_tlv_foreach(mfa2_file, tlv, idx, \
39410ed13cSYotam Gigi 			       mlxfw_mfa2_tlv_multi_child(mfa2_file, multi), \
40410ed13cSYotam Gigi 			       be16_to_cpu(multi->num_extensions) + 1)
41410ed13cSYotam Gigi #endif
42