Lines Matching refs:repo
38 static inline uint32_t get_next_record_handle(const pldm_pdr *repo, in get_next_record_handle() argument
41 if (record == repo->last) { in get_next_record_handle()
48 int pldm_pdr_add(pldm_pdr *repo, const uint8_t *data, uint32_t size, in pldm_pdr_add() argument
54 if (!repo || !data || !size) { in pldm_pdr_add()
60 } else if (repo->last) { in pldm_pdr_add()
61 curr = repo->last->record_handle; in pldm_pdr_add()
102 assert(!repo->first == !repo->last); in pldm_pdr_add()
103 if (repo->first == NULL) { in pldm_pdr_add()
104 repo->first = record; in pldm_pdr_add()
105 repo->last = record; in pldm_pdr_add()
107 repo->last->next = record; in pldm_pdr_add()
108 repo->last = record; in pldm_pdr_add()
111 repo->size += record->size; in pldm_pdr_add()
112 ++repo->record_count; in pldm_pdr_add()
124 pldm_pdr *repo = malloc(sizeof(pldm_pdr)); in pldm_pdr_init() local
125 if (!repo) { in pldm_pdr_init()
128 repo->record_count = 0; in pldm_pdr_init()
129 repo->size = 0; in pldm_pdr_init()
130 repo->first = NULL; in pldm_pdr_init()
131 repo->last = NULL; in pldm_pdr_init()
133 return repo; in pldm_pdr_init()
137 void pldm_pdr_destroy(pldm_pdr *repo) in pldm_pdr_destroy() argument
139 if (!repo) { in pldm_pdr_destroy()
143 pldm_pdr_record *record = repo->first; in pldm_pdr_destroy()
153 free(repo); in pldm_pdr_destroy()
157 const pldm_pdr_record *pldm_pdr_find_record(const pldm_pdr *repo, in pldm_pdr_find_record() argument
162 if (!repo || !data || !size || !next_record_handle) { in pldm_pdr_find_record()
166 if (!record_handle && (repo->first != NULL)) { in pldm_pdr_find_record()
167 record_handle = repo->first->record_handle; in pldm_pdr_find_record()
170 pldm_pdr_record *record = repo->first; in pldm_pdr_find_record()
176 get_next_record_handle(repo, record); in pldm_pdr_find_record()
189 pldm_pdr_get_next_record(const pldm_pdr *repo, in pldm_pdr_get_next_record() argument
193 if (!repo || !curr_record || !data || !size || !next_record_handle) { in pldm_pdr_get_next_record()
197 if (curr_record == repo->last) { in pldm_pdr_get_next_record()
200 *next_record_handle = get_next_record_handle(repo, curr_record); in pldm_pdr_get_next_record()
204 *next_record_handle = get_next_record_handle(repo, curr_record->next); in pldm_pdr_get_next_record()
212 pldm_pdr_find_record_by_type(const pldm_pdr *repo, uint8_t pdr_type, in pldm_pdr_find_record_by_type() argument
216 if (!repo) { in pldm_pdr_find_record_by_type()
220 pldm_pdr_record *record = repo->first; in pldm_pdr_find_record_by_type()
243 uint32_t pldm_pdr_get_record_count(const pldm_pdr *repo) in pldm_pdr_get_record_count() argument
245 assert(repo != NULL); in pldm_pdr_get_record_count()
247 return repo->record_count; in pldm_pdr_get_record_count()
251 uint32_t pldm_pdr_get_repo_size(const pldm_pdr *repo) in pldm_pdr_get_repo_size() argument
253 assert(repo != NULL); in pldm_pdr_get_repo_size()
255 return repo->size; in pldm_pdr_get_repo_size()
259 uint32_t pldm_pdr_get_record_handle(const pldm_pdr *repo LIBPLDM_CC_UNUSED, in pldm_pdr_get_record_handle()
262 assert(repo != NULL); in pldm_pdr_get_record_handle()
269 uint16_t pldm_pdr_get_terminus_handle(const pldm_pdr *repo LIBPLDM_CC_UNUSED, in pldm_pdr_get_terminus_handle()
272 assert(repo != NULL); in pldm_pdr_get_terminus_handle()
287 int pldm_pdr_add_fru_record_set(pldm_pdr *repo, uint16_t terminus_handle, in pldm_pdr_add_fru_record_set() argument
293 if (!repo || !bmc_record_handle) { in pldm_pdr_add_fru_record_set()
315 return pldm_pdr_add(repo, data, sizeof(data), false, terminus_handle, in pldm_pdr_add_fru_record_set()
321 const pldm_pdr *repo, uint16_t fru_rsi, uint16_t *terminus_handle, in pldm_pdr_fru_record_set_find_by_rsi() argument
325 if (!repo || !terminus_handle || !entity_type || !entity_instance_num || in pldm_pdr_fru_record_set_find_by_rsi()
333 repo, PLDM_PDR_FRU_RECORD_SET, NULL, &data, &size); in pldm_pdr_fru_record_set_find_by_rsi()
348 repo, PLDM_PDR_FRU_RECORD_SET, curr_record, &data, in pldm_pdr_fru_record_set_find_by_rsi()
362 void pldm_pdr_update_TL_pdr(const pldm_pdr *repo, uint16_t terminus_handle, in pldm_pdr_update_TL_pdr() argument
368 record = pldm_pdr_find_record_by_type(repo, PLDM_TERMINUS_LOCATOR_PDR, in pldm_pdr_update_TL_pdr()
384 record = pldm_pdr_find_record_by_type(repo, in pldm_pdr_update_TL_pdr()
400 const pldm_pdr *repo, uint16_t entity_type, uint16_t entity_instance, in pldm_pdr_find_child_container_id_index_range_exclude() argument
405 if (!repo) { in pldm_pdr_find_child_container_id_index_range_exclude()
409 for (record = repo->first; record; record = record->next) { in pldm_pdr_find_child_container_id_index_range_exclude()
791 pldm_entity_node *curr, pldm_pdr *repo, uint16_t size, in entity_association_pdr_add_children() argument
843 rc = pldm_pdr_add(repo, pdr, size, is_remote, terminus_handle, in entity_association_pdr_add_children()
850 pldm_pdr *repo, bool is_remote, in entity_association_pdr_add_entry() argument
867 curr, repo, logical_pdr_size, num_logical_children, in entity_association_pdr_add_entry()
882 curr, repo, physical_pdr_size, num_physical_children, in entity_association_pdr_add_entry()
909 static int entity_association_pdr_add(pldm_entity_node *curr, pldm_pdr *repo, in entity_association_pdr_add() argument
923 curr, repo, is_remote, terminus_handle, record_handle); in entity_association_pdr_add()
929 rc = entity_association_pdr_add(curr->next_sibling, repo, entities, in entity_association_pdr_add()
936 return entity_association_pdr_add(curr->first_child, repo, entities, in entity_association_pdr_add()
943 pldm_pdr *repo, bool is_remote, in pldm_entity_association_pdr_add() argument
946 if (!tree || !repo) { in pldm_entity_association_pdr_add()
950 return entity_association_pdr_add(tree->root, repo, NULL, 0, is_remote, in pldm_entity_association_pdr_add()
956 pldm_entity_node *node, pldm_pdr *repo, pldm_entity **entities, in pldm_entity_association_pdr_add_from_node() argument
960 node, repo, entities, num_entities, is_remote, terminus_handle, in pldm_entity_association_pdr_add_from_node()
966 pldm_entity_node *node, pldm_pdr *repo, pldm_entity **entities, in pldm_entity_association_pdr_add_from_node_with_record_handle() argument
970 if (!node || !repo || !entities) { in pldm_entity_association_pdr_add_from_node_with_record_handle()
974 return entity_association_pdr_add(node, repo, entities, num_entities, in pldm_entity_association_pdr_add_from_node_with_record_handle()
1017 void pldm_pdr_remove_pdrs_by_terminus_handle(pldm_pdr *repo, in pldm_pdr_remove_pdrs_by_terminus_handle() argument
1020 if (!repo) { in pldm_pdr_remove_pdrs_by_terminus_handle()
1026 pldm_pdr_record *record = repo->first; in pldm_pdr_remove_pdrs_by_terminus_handle()
1031 if (repo->first == record) { in pldm_pdr_remove_pdrs_by_terminus_handle()
1032 repo->first = next; in pldm_pdr_remove_pdrs_by_terminus_handle()
1036 if (repo->last == record) { in pldm_pdr_remove_pdrs_by_terminus_handle()
1037 repo->last = prev; in pldm_pdr_remove_pdrs_by_terminus_handle()
1042 --repo->record_count; in pldm_pdr_remove_pdrs_by_terminus_handle()
1043 repo->size -= record->size; in pldm_pdr_remove_pdrs_by_terminus_handle()
1053 record = repo->first; in pldm_pdr_remove_pdrs_by_terminus_handle()
1069 void pldm_pdr_remove_remote_pdrs(pldm_pdr *repo) in pldm_pdr_remove_remote_pdrs() argument
1071 if (!repo) { in pldm_pdr_remove_remote_pdrs()
1077 pldm_pdr_record *record = repo->first; in pldm_pdr_remove_remote_pdrs()
1082 if (repo->first == record) { in pldm_pdr_remove_remote_pdrs()
1083 repo->first = next; in pldm_pdr_remove_remote_pdrs()
1087 if (repo->last == record) { in pldm_pdr_remove_remote_pdrs()
1088 repo->last = prev; in pldm_pdr_remove_remote_pdrs()
1093 --repo->record_count; in pldm_pdr_remove_remote_pdrs()
1094 repo->size -= record->size; in pldm_pdr_remove_remote_pdrs()
1104 record = repo->first; in pldm_pdr_remove_remote_pdrs()
1120 pldm_pdr_record *pldm_pdr_find_last_in_range(const pldm_pdr *repo, in pldm_pdr_find_last_in_range() argument
1126 if (!repo) { in pldm_pdr_find_last_in_range()
1129 for (curr = repo->first; curr; curr = curr->next) { in pldm_pdr_find_last_in_range()
1381 static int pldm_pdr_replace_record(pldm_pdr *repo, pldm_pdr_record *record, in pldm_pdr_replace_record() argument
1385 if (repo->size < record->size) { in pldm_pdr_replace_record()
1389 if (repo->size + new_record->size < new_record->size) { in pldm_pdr_replace_record()
1393 if (repo->first == record) { in pldm_pdr_replace_record()
1394 repo->first = new_record; in pldm_pdr_replace_record()
1400 if (repo->last == record) { in pldm_pdr_replace_record()
1401 repo->last = new_record; in pldm_pdr_replace_record()
1404 repo->size = (repo->size - record->size) + new_record->size; in pldm_pdr_replace_record()
1412 static int pldm_pdr_insert_record(pldm_pdr *repo, pldm_pdr_record *record, in pldm_pdr_insert_record() argument
1415 if (repo->size + new_record->size < new_record->size) { in pldm_pdr_insert_record()
1419 if (repo->record_count == UINT32_MAX) { in pldm_pdr_insert_record()
1426 if (repo->last == record) { in pldm_pdr_insert_record()
1427 repo->last = new_record; in pldm_pdr_insert_record()
1430 repo->size = repo->size + new_record->size; in pldm_pdr_insert_record()
1431 ++repo->record_count; in pldm_pdr_insert_record()
1454 pldm_pdr *repo, pldm_entity *entity, uint32_t pdr_record_handle) in pldm_entity_association_pdr_add_contained_entity_to_remote_pdr() argument
1456 if (!repo || !entity) { in pldm_entity_association_pdr_add_contained_entity_to_remote_pdr()
1460 pldm_pdr_record *record = repo->first; in pldm_entity_association_pdr_add_contained_entity_to_remote_pdr()
1461 pldm_pdr_record *prev = repo->first; in pldm_entity_association_pdr_add_contained_entity_to_remote_pdr()
1575 rc = pldm_pdr_replace_record(repo, record, prev, new_record); in pldm_entity_association_pdr_add_contained_entity_to_remote_pdr()
1591 int pldm_entity_association_pdr_create_new(pldm_pdr *repo, in pldm_entity_association_pdr_create_new() argument
1597 if (!repo || !parent || !entity || !entity_record_handle) { in pldm_entity_association_pdr_create_new()
1617 pldm_pdr_record *prev = repo->first; in pldm_entity_association_pdr_create_new()
1618 pldm_pdr_record *record = repo->first; in pldm_entity_association_pdr_create_new()
1716 rc = pldm_pdr_insert_record(repo, record, new_record); in pldm_entity_association_pdr_create_new()
1743 pldm_pdr *repo, pldm_entity *entity, bool is_remote, in pldm_entity_association_find_record_handle_by_entity() argument
1750 pldm_pdr_record *record = repo->first; in pldm_entity_association_find_record_handle_by_entity()
1801 pldm_pdr *repo, pldm_entity *entity, bool is_remote, in pldm_entity_association_pdr_remove_contained_entity() argument
1814 if (!repo || !entity || !pdr_record_handle) { in pldm_entity_association_pdr_remove_contained_entity()
1817 record = repo->first; in pldm_entity_association_pdr_remove_contained_entity()
1818 prev = repo->first; in pldm_entity_association_pdr_remove_contained_entity()
1821 repo, entity, is_remote, pdr_record_handle); in pldm_entity_association_pdr_remove_contained_entity()
1919 (rc = pldm_pdr_replace_record(repo, record, prev, new_record))) { in pldm_entity_association_pdr_remove_contained_entity()
1938 static pldm_pdr_record *pldm_pdr_get_prev_record(pldm_pdr *repo, in pldm_pdr_get_prev_record() argument
1942 pldm_pdr_record *curr = repo->first; in pldm_pdr_get_prev_record()
1957 static bool is_prev_record_present(pldm_pdr *repo, pldm_pdr_record *record) in is_prev_record_present() argument
1959 if (repo->first == record) { in is_prev_record_present()
1963 return pldm_pdr_get_prev_record(repo, record) != NULL; in is_prev_record_present()
2000 static int pldm_pdr_remove_record(pldm_pdr *repo, pldm_pdr_record *record, in pldm_pdr_remove_record() argument
2003 if (!is_prev_record_present(repo, record)) { in pldm_pdr_remove_record()
2007 assert(repo->size >= record->size); in pldm_pdr_remove_record()
2008 if (repo->size < record->size) { in pldm_pdr_remove_record()
2012 if (repo->first == record) { in pldm_pdr_remove_record()
2013 repo->first = record->next; in pldm_pdr_remove_record()
2020 if (repo->last == record) { in pldm_pdr_remove_record()
2021 repo->last = prev; in pldm_pdr_remove_record()
2026 repo->record_count -= 1; in pldm_pdr_remove_record()
2027 repo->size -= record->size; in pldm_pdr_remove_record()
2035 int pldm_pdr_remove_fru_record_set_by_rsi(pldm_pdr *repo, uint16_t fru_rsi, in pldm_pdr_remove_fru_record_set_by_rsi() argument
2046 if (!repo || !record_handle) { in pldm_pdr_remove_fru_record_set_by_rsi()
2049 record = repo->first; in pldm_pdr_remove_fru_record_set_by_rsi()
2073 prev = pldm_pdr_get_prev_record(repo, record); in pldm_pdr_remove_fru_record_set_by_rsi()
2074 return pldm_pdr_remove_record(repo, record, prev); in pldm_pdr_remove_fru_record_set_by_rsi()