1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
2 | /**************************************************************************** |
3 | * Driver for AMD network controllers and boards |
4 | * Copyright (C) 2025, Advanced Micro Devices, Inc. |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of the GNU General Public License version 2 as published |
8 | * by the Free Software Foundation, incorporated herein by reference. |
9 | */ |
10 | |
11 | #ifndef _EFX_FW_FORMATS_H |
12 | #define _EFX_FW_FORMATS_H |
13 | |
14 | /* Header layouts of firmware update images recognised by Efx NICs. |
15 | * The sources-of-truth for these layouts are AMD internal documents |
16 | * and sfregistry headers, neither of which are available externally |
17 | * nor usable directly by the driver. |
18 | * |
19 | * While each format includes a 'magic number', these are at different |
20 | * offsets in the various formats, and a legal header for one format |
21 | * could have the right value in whichever field occupies that offset |
22 | * to match another format's magic. |
23 | * Besides, some packaging formats (such as CMS/PKCS#7 signed images) |
24 | * prepend a header for which finding the size is a non-trivial task; |
25 | * rather than trying to parse those headers, we search byte-by-byte |
26 | * through the provided firmware image looking for a valid header. |
27 | * Thus, format recognition has to include validation of the checksum |
28 | * field, even though the firmware will validate that itself before |
29 | * applying the image. |
30 | */ |
31 | |
32 | /* EF10 (Medford2, X2) "reflash" header format. Defined in SF-121352-AN */ |
33 | #define 0 |
34 | #define 4 |
35 | #define 0x106F1A5 |
36 | |
37 | #define 4 |
38 | #define 4 |
39 | #define 4 |
40 | |
41 | #define 8 |
42 | #define 4 |
43 | #define EFX_REFLASH_FIRMWARE_TYPE_BOOTROM 0x2 |
44 | #define EFX_REFLASH_FIRMWARE_TYPE_BUNDLE 0xd |
45 | |
46 | #define 12 |
47 | #define 4 |
48 | |
49 | #define 16 |
50 | #define 4 |
51 | |
52 | #define 20 |
53 | #define 4 |
54 | |
55 | /* Reflash trailer */ |
56 | #define EFX_REFLASH_TRAILER_CRC_OFST 0 |
57 | #define EFX_REFLASH_TRAILER_CRC_LEN 4 |
58 | |
59 | #define EFX_REFLASH_TRAILER_LEN \ |
60 | (EFX_REFLASH_TRAILER_CRC_OFST + EFX_REFLASH_TRAILER_CRC_LEN) |
61 | |
62 | /* EF100 "SmartNIC image" header format. |
63 | * Defined in sfregistry "src/layout/snic_image_hdr.h". |
64 | */ |
65 | #define 16 |
66 | #define 4 |
67 | #define 0x541C057A |
68 | |
69 | #define 20 |
70 | #define 4 |
71 | #define 1 |
72 | |
73 | #define 24 |
74 | #define 4 |
75 | |
76 | #define 36 |
77 | #define 4 |
78 | |
79 | #define 40 |
80 | #define 4 |
81 | |
82 | #define 60 |
83 | #define 4 |
84 | |
85 | #define 64 |
86 | #define 4 |
87 | |
88 | #define 256 |
89 | |
90 | /* EF100 "SmartNIC bundle" header format. Defined in SF-122606-TC */ |
91 | #define 0 |
92 | #define 4 |
93 | #define 0xB1001001 |
94 | |
95 | #define 4 |
96 | #define 4 |
97 | #define 1 |
98 | |
99 | #define 8 |
100 | #define 4 |
101 | |
102 | #define 12 |
103 | #define 4 |
104 | |
105 | #define 20 |
106 | #define 4 |
107 | |
108 | #define 224 |
109 | #define 4 |
110 | |
111 | #define \ |
112 | (EFX_SNICBUNDLE_HEADER_CRC_OFST + EFX_SNICBUNDLE_HEADER_CRC_LEN) |
113 | |
114 | #endif /* _EFX_FW_FORMATS_H */ |
115 | |