xref: /linux/drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h (revision 26fbb4c8c7c3ee9a4c3b4de555a8587b5a19154e)
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_TLV_MULTI_H
5 #define _MLXFW_MFA2_TLV_MULTI_H
6 
7 #include "mlxfw_mfa2_tlv.h"
8 #include "mlxfw_mfa2_format.h"
9 #include "mlxfw_mfa2_file.h"
10 
11 const struct mlxfw_mfa2_tlv *
12 mlxfw_mfa2_tlv_multi_child(const struct mlxfw_mfa2_file *mfa2_file,
13 			   const struct mlxfw_mfa2_tlv_multi *multi);
14 
15 const struct mlxfw_mfa2_tlv *
16 mlxfw_mfa2_tlv_next(const struct mlxfw_mfa2_file *mfa2_file,
17 		    const struct mlxfw_mfa2_tlv *tlv);
18 
19 const struct mlxfw_mfa2_tlv *
20 mlxfw_mfa2_tlv_advance(const struct mlxfw_mfa2_file *mfa2_file,
21 		       const struct mlxfw_mfa2_tlv *from_tlv, u16 count);
22 
23 const struct mlxfw_mfa2_tlv *
24 mlxfw_mfa2_tlv_multi_child_find(const struct mlxfw_mfa2_file *mfa2_file,
25 				const struct mlxfw_mfa2_tlv_multi *multi,
26 				enum mlxfw_mfa2_tlv_type type, u16 index);
27 
28 int mlxfw_mfa2_tlv_multi_child_count(const struct mlxfw_mfa2_file *mfa2_file,
29 				     const struct mlxfw_mfa2_tlv_multi *multi,
30 				     enum mlxfw_mfa2_tlv_type type,
31 				     u16 *p_count);
32 
33 #define mlxfw_mfa2_tlv_foreach(mfa2_file, tlv, idx, from_tlv, count) \
34 	for (idx = 0, tlv = from_tlv; idx < (count); \
35 	     idx++, tlv = mlxfw_mfa2_tlv_next(mfa2_file, tlv))
36 
37 #define mlxfw_mfa2_tlv_multi_foreach(mfa2_file, tlv, idx, multi) \
38 	mlxfw_mfa2_tlv_foreach(mfa2_file, tlv, idx, \
39 			       mlxfw_mfa2_tlv_multi_child(mfa2_file, multi), \
40 			       be16_to_cpu(multi->num_extensions) + 1)
41 #endif
42