1410ed13cSYotam Gigi /*
2410ed13cSYotam Gigi  * drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h
3410ed13cSYotam Gigi  * Copyright (c) 2017 Mellanox Technologies. All rights reserved.
4410ed13cSYotam Gigi  * Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
5410ed13cSYotam Gigi  *
6410ed13cSYotam Gigi  * Redistribution and use in source and binary forms, with or without
7410ed13cSYotam Gigi  * modification, are permitted provided that the following conditions are met:
8410ed13cSYotam Gigi  *
9410ed13cSYotam Gigi  * 1. Redistributions of source code must retain the above copyright
10410ed13cSYotam Gigi  *    notice, this list of conditions and the following disclaimer.
11410ed13cSYotam Gigi  * 2. Redistributions in binary form must reproduce the above copyright
12410ed13cSYotam Gigi  *    notice, this list of conditions and the following disclaimer in the
13410ed13cSYotam Gigi  *    documentation and/or other materials provided with the distribution.
14410ed13cSYotam Gigi  * 3. Neither the names of the copyright holders nor the names of its
15410ed13cSYotam Gigi  *    contributors may be used to endorse or promote products derived from
16410ed13cSYotam Gigi  *    this software without specific prior written permission.
17410ed13cSYotam Gigi  *
18410ed13cSYotam Gigi  * Alternatively, this software may be distributed under the terms of the
19410ed13cSYotam Gigi  * GNU General Public License ("GPL") version 2 as published by the Free
20410ed13cSYotam Gigi  * Software Foundation.
21410ed13cSYotam Gigi  *
22410ed13cSYotam Gigi  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23410ed13cSYotam Gigi  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24410ed13cSYotam Gigi  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25410ed13cSYotam Gigi  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26410ed13cSYotam Gigi  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27410ed13cSYotam Gigi  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28410ed13cSYotam Gigi  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29410ed13cSYotam Gigi  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30410ed13cSYotam Gigi  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31410ed13cSYotam Gigi  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32410ed13cSYotam Gigi  * POSSIBILITY OF SUCH DAMAGE.
33410ed13cSYotam Gigi  */
34410ed13cSYotam Gigi #ifndef _MLXFW_MFA2_FORMAT_H
35410ed13cSYotam Gigi #define _MLXFW_MFA2_FORMAT_H
36410ed13cSYotam Gigi 
37410ed13cSYotam Gigi #include "mlxfw_mfa2_file.h"
38410ed13cSYotam Gigi #include "mlxfw_mfa2_tlv.h"
39410ed13cSYotam Gigi 
40410ed13cSYotam Gigi enum mlxfw_mfa2_tlv_type {
41410ed13cSYotam Gigi 	MLXFW_MFA2_TLV_MULTI_PART = 0x01,
42410ed13cSYotam Gigi 	MLXFW_MFA2_TLV_PACKAGE_DESCRIPTOR = 0x02,
43410ed13cSYotam Gigi 	MLXFW_MFA2_TLV_COMPONENT_DESCRIPTOR = 0x04,
44410ed13cSYotam Gigi 	MLXFW_MFA2_TLV_COMPONENT_PTR = 0x22,
45410ed13cSYotam Gigi 	MLXFW_MFA2_TLV_PSID = 0x2A,
46410ed13cSYotam Gigi };
47410ed13cSYotam Gigi 
48410ed13cSYotam Gigi enum mlxfw_mfa2_compression_type {
49410ed13cSYotam Gigi 	MLXFW_MFA2_COMPRESSION_TYPE_NONE,
50410ed13cSYotam Gigi 	MLXFW_MFA2_COMPRESSION_TYPE_XZ,
51410ed13cSYotam Gigi };
52410ed13cSYotam Gigi 
53410ed13cSYotam Gigi struct mlxfw_mfa2_tlv_package_descriptor {
54410ed13cSYotam Gigi 	__be16 num_components;
55410ed13cSYotam Gigi 	__be16 num_devices;
56410ed13cSYotam Gigi 	__be32 cb_offset;
57410ed13cSYotam Gigi 	__be32 cb_archive_size;
58410ed13cSYotam Gigi 	__be32 cb_size_h;
59410ed13cSYotam Gigi 	__be32 cb_size_l;
60410ed13cSYotam Gigi 	u8 padding[3];
61410ed13cSYotam Gigi 	u8 cv_compression;
62410ed13cSYotam Gigi 	__be32 user_data_offset;
63410ed13cSYotam Gigi } __packed;
64410ed13cSYotam Gigi 
65410ed13cSYotam Gigi MLXFW_MFA2_TLV(package_descriptor, struct mlxfw_mfa2_tlv_package_descriptor,
66410ed13cSYotam Gigi 	       MLXFW_MFA2_TLV_PACKAGE_DESCRIPTOR);
67410ed13cSYotam Gigi 
68410ed13cSYotam Gigi struct mlxfw_mfa2_tlv_multi {
69410ed13cSYotam Gigi 	__be16 num_extensions;
70410ed13cSYotam Gigi 	__be16 total_len;
71410ed13cSYotam Gigi } __packed;
72410ed13cSYotam Gigi 
73410ed13cSYotam Gigi MLXFW_MFA2_TLV(multi, struct mlxfw_mfa2_tlv_multi,
74410ed13cSYotam Gigi 	       MLXFW_MFA2_TLV_MULTI_PART);
75410ed13cSYotam Gigi 
76410ed13cSYotam Gigi struct mlxfw_mfa2_tlv_psid {
77410ed13cSYotam Gigi 	u8 psid[0];
78410ed13cSYotam Gigi } __packed;
79410ed13cSYotam Gigi 
80410ed13cSYotam Gigi MLXFW_MFA2_TLV_VARSIZE(psid, struct mlxfw_mfa2_tlv_psid,
81410ed13cSYotam Gigi 		       MLXFW_MFA2_TLV_PSID);
82410ed13cSYotam Gigi 
83410ed13cSYotam Gigi struct mlxfw_mfa2_tlv_component_ptr {
84410ed13cSYotam Gigi 	__be16 storage_id;
85410ed13cSYotam Gigi 	__be16 component_index;
86410ed13cSYotam Gigi 	__be32 storage_address;
87410ed13cSYotam Gigi } __packed;
88410ed13cSYotam Gigi 
89410ed13cSYotam Gigi MLXFW_MFA2_TLV(component_ptr, struct mlxfw_mfa2_tlv_component_ptr,
90410ed13cSYotam Gigi 	       MLXFW_MFA2_TLV_COMPONENT_PTR);
91410ed13cSYotam Gigi 
92410ed13cSYotam Gigi struct mlxfw_mfa2_tlv_component_descriptor {
93410ed13cSYotam Gigi 	__be16 pldm_classification;
94410ed13cSYotam Gigi 	__be16 identifier;
95410ed13cSYotam Gigi 	__be32 cb_offset_h;
96410ed13cSYotam Gigi 	__be32 cb_offset_l;
97410ed13cSYotam Gigi 	__be32 size;
98410ed13cSYotam Gigi } __packed;
99410ed13cSYotam Gigi 
100410ed13cSYotam Gigi MLXFW_MFA2_TLV(component_descriptor, struct mlxfw_mfa2_tlv_component_descriptor,
101410ed13cSYotam Gigi 	       MLXFW_MFA2_TLV_COMPONENT_DESCRIPTOR);
102410ed13cSYotam Gigi 
103410ed13cSYotam Gigi #endif
104