1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2018 Netronome Systems, Inc. 3 * All rights reserved. 4 */ 5 6 #ifndef __NFP_MIP_H__ 7 #define __NFP_MIP_H__ 8 9 #include "nfp_cpp.h" 10 11 /* "MIP\0" */ 12 #define NFP_MIP_SIGNATURE rte_cpu_to_le_32(0x0050494d) 13 #define NFP_MIP_VERSION rte_cpu_to_le_32(1) 14 15 /* nfp_mip_entry_type */ 16 #define NFP_MIP_TYPE_FWINFO 0x70000002 17 18 /* Each packed struct field is stored as Little Endian */ 19 struct nfp_mip { 20 rte_le32_t signature; 21 rte_le32_t mip_version; 22 23 rte_le32_t mip_size; 24 rte_le32_t first_entry; 25 26 rte_le32_t version; 27 rte_le32_t buildnum; 28 rte_le32_t buildtime; 29 rte_le32_t loadtime; 30 31 rte_le32_t symtab_addr; 32 rte_le32_t symtab_size; 33 rte_le32_t strtab_addr; 34 rte_le32_t strtab_size; 35 36 char name[16]; 37 char toolchain[32]; 38 }; 39 40 struct nfp_mip_entry { 41 uint32_t type; 42 uint32_t version; 43 uint32_t offset_next; 44 }; 45 46 /* 47 * A key-value pair has no imposed limit, but it is recommended that 48 * consumers only allocate enough memory for keys they plan to process and 49 * skip over unused keys or ignore values that are longer than expected. 50 * 51 * For MIPv1, this will be preceded by struct nfp_mip_entry. 52 * The entry size will be the size of key_value_strs, round to the next 53 * 4-byte multiple. If entry size is 0, then there are no key-value strings 54 * and it will not contain an empty string. 55 * 56 * The following keys are reserved and possibly set by the linker. The 57 * convention is to start linker-set keys with a capital letter. Reserved 58 * entries will be placed first in key_value_strs, user entries will be 59 * placed next and be sorted alphabetically. 60 * TypeId - Present if a user specified fw_typeid when linking. 61 * 62 * The following keys are reserved, but not used. Their values are in the 63 * root MIP struct. 64 */ 65 struct nfp_mip_fwinfo_entry { 66 /** The byte size of @p key_value_strs. */ 67 uint32_t kv_len; 68 69 /** The number of key-value pairs in the following string. */ 70 uint32_t num; 71 72 /** 73 * A series of NUL terminated strings, terminated by an extra 74 * NUL which is also the last byte of the entry, so an iterator 75 * can either check on size or when key[0] == '\0'. 76 */ 77 char key_value_strs[]; 78 }; 79 80 struct nfp_mip *nfp_mip_open(struct nfp_cpp *cpp); 81 void nfp_mip_close(struct nfp_mip *mip); 82 83 const char *nfp_mip_name(const struct nfp_mip *mip); 84 uint32_t nfp_mip_fw_version(const struct nfp_mip *mip); 85 void nfp_mip_symtab(const struct nfp_mip *mip, uint32_t *addr, uint32_t *size); 86 void nfp_mip_strtab(const struct nfp_mip *mip, uint32_t *addr, uint32_t *size); 87 88 #endif /* __NFP_MIP_H__ */ 89