Lines Matching +full:first +full:- +full:generation

1 /*-
2 * Copyright (c) 2012-2016 Solarflare Communications Inc.
81 dword = cursor->current[0]; in tlv_tag()
96 dword = cursor->current[1]; in tlv_length()
109 return ((uint8_t *)(&cursor->current[2])); in tlv_value()
119 return ((uint8_t *)cursor->current); in tlv_item()
124 * equivalent to tlv_n_words_for_len in mc-comms tlv.c
127 (1 + 1 + (((length) + sizeof (uint32_t) - 1) / sizeof (uint32_t)))
137 return (cursor->current + TLV_DWORD_COUNT(length)); in tlv_next_item_ptr()
149 if (cursor->current == cursor->end) { in tlv_advance()
151 cursor->current = NULL; in tlv_advance()
157 cursor->current = tlv_next_item_ptr(cursor); in tlv_advance()
180 cursor->current = cursor->block; in tlv_rewind()
217 if (cursor->current < cursor->block) { in tlv_validate_state()
221 if (cursor->current > cursor->limit) { in tlv_validate_state()
228 if (cursor->current > (cursor->limit - 1)) { in tlv_validate_state()
229 cursor->current = NULL; in tlv_validate_state()
235 if (tlv_next_item_ptr(cursor) > cursor->limit) { in tlv_validate_state()
236 cursor->current = NULL; in tlv_validate_state()
263 cursor->block = block; in tlv_init_cursor()
264 cursor->limit = limit; in tlv_init_cursor()
266 cursor->current = current; in tlv_init_cursor()
267 cursor->end = NULL; in tlv_init_cursor()
280 limit = (uint32_t *)(block + size - sizeof (uint32_t)); in tlv_init_cursor_from_size()
295 limit = (uint32_t *)(block + size - sizeof (uint32_t)); in tlv_init_cursor_at_offset()
307 if (cursor->end == NULL) { in tlv_require_end()
308 pos = cursor->current; in tlv_require_end()
312 cursor->end = cursor->current; in tlv_require_end()
313 cursor->current = pos; in tlv_require_end()
337 return (cursor->end + 1 - cursor->block) * sizeof (uint32_t); in tlv_block_length_used()
352 uint32_t *last_segment_end = cursor->block; in tlv_last_segment_end()
353 uint32_t *segment_start = cursor->block; in tlv_last_segment_end()
362 cursor->limit, segment_start) != 0) in tlv_last_segment_end()
383 ptr = cursor->current; in tlv_write()
389 ptr[(len - 1) / sizeof (uint32_t)] = 0; in tlv_write()
424 if (last_segment_end + 1 + delta > cursor->limit) { in tlv_insert()
429 /* Move data up: new space at cursor->current */ in tlv_insert()
430 memmove(cursor->current + delta, cursor->current, in tlv_insert()
431 (last_segment_end + 1 - cursor->current) * sizeof (uint32_t)); in tlv_insert()
434 cursor->end += delta; in tlv_insert()
476 /* Shuffle things down, destroying the item at cursor->current */ in tlv_delete()
477 memmove(cursor->current, cursor->current + delta, in tlv_delete()
478 (last_segment_end + 1 - cursor->current) * sizeof (uint32_t)); in tlv_delete()
480 memset(last_segment_end + 1 - delta, 0, delta * sizeof (uint32_t)); in tlv_delete()
482 cursor->end -= delta; in tlv_delete()
533 delta = new_ndwords - old_ndwords; in tlv_modify()
534 pos = cursor->current + old_ndwords; in tlv_modify()
536 if (last_segment_end + 1 + delta > cursor->limit) { in tlv_modify()
541 /* Move up: new space at (cursor->current + old_ndwords) */ in tlv_modify()
543 (last_segment_end + 1 - pos) * sizeof (uint32_t)); in tlv_modify()
546 cursor->end += delta; in tlv_modify()
550 delta = old_ndwords - new_ndwords; in tlv_modify()
551 pos = cursor->current + new_ndwords; in tlv_modify()
553 /* Move down: remove words at (cursor->current + new_ndwords) */ in tlv_modify()
555 (last_segment_end + 1 - pos) * sizeof (uint32_t)); in tlv_modify()
558 memset(last_segment_end + 1 - delta, 0, in tlv_modify()
562 cursor->end -= delta; in tlv_modify()
593 cursor = &partition->tlv_cursor; in checksum_tlv_partition()
598 ptr = partition->data; in checksum_tlv_partition()
622 partition.data = cursor->block; in tlv_update_partition_len_and_cks()
626 if (__LE_TO_CPU_32(header->tag) != TLV_TAG_PARTITION_HEADER) { in tlv_update_partition_len_and_cks()
635 header->total_length = __CPU_TO_LE_32(new_len); in tlv_update_partition_len_and_cks()
636 /* Ensure the modified partition always has a new generation count. */ in tlv_update_partition_len_and_cks()
637 header->generation = __CPU_TO_LE_32( in tlv_update_partition_len_and_cks()
638 __LE_TO_CPU_32(header->generation) + 1); in tlv_update_partition_len_and_cks()
641 new_len - sizeof (*trailer) - sizeof (uint32_t)); in tlv_update_partition_len_and_cks()
642 trailer->generation = header->generation; in tlv_update_partition_len_and_cks()
643 trailer->checksum = __CPU_TO_LE_32( in tlv_update_partition_len_and_cks()
644 __LE_TO_CPU_32(trailer->checksum) - in tlv_update_partition_len_and_cks()
679 /* The partition header must be the first item (at offset zero) */ in ef10_nvram_buffer_validate()
692 total_length = __LE_TO_CPU_32(header->total_length); in ef10_nvram_buffer_validate()
699 if (__LE_TO_CPU_16(header->type_id) != partn) { in ef10_nvram_buffer_validate()
720 /* Check generation counts are consistent */ in ef10_nvram_buffer_validate()
721 if (trailer->generation != header->generation) { in ef10_nvram_buffer_validate()
804 header.length = __CPU_TO_LE_32(sizeof (header) - 8); in ef10_nvram_buffer_create()
807 header.generation = __CPU_TO_LE_32(1); in ef10_nvram_buffer_create()
811 (uint8_t *)&header.type_id, sizeof (header) - 8)) != 0) in ef10_nvram_buffer_create()
817 trailer.length = __CPU_TO_LE_32(sizeof (trailer) - 8); in ef10_nvram_buffer_create()
818 trailer.generation = header.generation; in ef10_nvram_buffer_create()
821 (uint8_t *)&trailer.generation, sizeof (trailer) - 8)) != 0) in ef10_nvram_buffer_create()
857 return (uint32_t)((uint8_t *)position - (uint8_t *)base); in byte_offset()
867 /* Read past partition header to find start address of the first key */ in ef10_nvram_buffer_find_item_start()
871 /* A PARTITION_HEADER tag must be the first item (at offset zero) */ in ef10_nvram_buffer_find_item_start()
937 * First segment is corrupt, so there is in ef10_nvram_buffer_find_end()
950 *endp = (segment_used - cursor.block) * sizeof (uint32_t); in ef10_nvram_buffer_find_end()
1234 * beyond the first to be read.
1266 /* A PARTITION_HEADER tag must be the first item at the given offset */ in ef10_nvram_read_tlv_segment()
1279 total_length = __LE_TO_CPU_32(header->total_length); in ef10_nvram_read_tlv_segment()
1290 total_length - EF10_NVRAM_CHUNK, in ef10_nvram_read_tlv_segment()
1312 if (trailer->generation != header->generation) { in ef10_nvram_read_tlv_segment()
1404 EFSYS_KMEM_ALLOC(enp->en_esip, length, data); in ef10_nvram_buf_read_tlv()
1429 /* Read a single TLV item from the first segment in a TLV formatted partition */
1454 EFSYS_KMEM_ALLOC(enp->en_esip, partn_size, seg_data); in ef10_nvram_partn_read_tlv()
1461 * Read the first segment in a TLV partition. Retry until consistent in ef10_nvram_partn_read_tlv()
1472 --retry; in ef10_nvram_partn_read_tlv()
1487 EFSYS_KMEM_FREE(enp->en_esip, partn_size, seg_data); in ef10_nvram_partn_read_tlv()
1499 EFSYS_KMEM_FREE(enp->en_esip, partn_size, seg_data); in ef10_nvram_partn_read_tlv()
1525 /* A PARTITION_HEADER tag must be the first item at the given offset */ in ef10_nvram_buf_segment_size()
1538 *seg_sizep = __LE_TO_CPU_32(header->total_length); in ef10_nvram_buf_segment_size()
1586 /* Skip over the first HEADER tag. */ in ef10_nvram_buf_segment_size()
1654 uint32_t generation; in ef10_nvram_buf_write_tlv() local
1659 /* A PARTITION_HEADER tag must be the first item (at offset zero) */ in ef10_nvram_buf_write_tlv()
1704 generation = __LE_TO_CPU_32(header->generation) + 1; in ef10_nvram_buf_write_tlv()
1706 header->total_length = __CPU_TO_LE_32(*total_lengthp); in ef10_nvram_buf_write_tlv()
1707 header->generation = __CPU_TO_LE_32(generation); in ef10_nvram_buf_write_tlv()
1708 trailer->generation = __CPU_TO_LE_32(generation); in ef10_nvram_buf_write_tlv()
1711 trailer->checksum = 0; in ef10_nvram_buf_write_tlv()
1716 trailer->checksum = ~cksum + 1; in ef10_nvram_buf_write_tlv()
1739 * Add or update a single TLV item in the first segment of a TLV formatted
1740 * dynamic config partition. The first segment is the current active
1780 * this is the first segment in a partition. In this case the caller in ef10_nvram_segment_write_tlv()
1804 *dest_remain_lenp -= modified_segment_size; in ef10_nvram_segment_write_tlv()
1811 *dest_remain_lenp -= original_segment_size; in ef10_nvram_segment_write_tlv()
1816 *src_remain_lenp -= original_segment_size; in ef10_nvram_segment_write_tlv()
1831 * Add or update a single TLV item in either the first segment or in all
1834 * each formatted like a partition, with header, trailer and end tags. The first
1839 * via RFID to copy a segment to replace the first segment, hence changing the
1844 * firmware versions) or just the first segment (changes to the active
1845 * configuration). See SF-111324-SW "The use of RFID in Solarflare Products".
1846 * If only the first segment is written the code still needs to be aware of the
1875 EFSYS_KMEM_ALLOC(enp->en_esip, partn_size, partn_data); in ef10_nvram_partn_write_segment_tlv()
1899 * If no data has been read then the first in ef10_nvram_partn_write_segment_tlv()
1908 total_length = segment_data - partn_data; in ef10_nvram_partn_write_segment_tlv()
1931 EFSYS_KMEM_FREE(enp->en_esip, partn_size, partn_data); in ef10_nvram_partn_write_segment_tlv()
1948 EFSYS_KMEM_FREE(enp->en_esip, partn_size, partn_data); in ef10_nvram_partn_write_segment_tlv()
2019 size -= chunk; in ef10_nvram_partn_read_mode()
2098 size -= erase_size; in ef10_nvram_partn_erase()
2153 size -= chunk; in ef10_nvram_partn_write()
2210 size = sizeof (partn_version) - (2 * sizeof (uint32_t));
2299 switch (enp->en_family) { in ef10_parttbl_get()
2328 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); in ef10_nvram_type_to_partn()
2341 if ((entry->nvtype == type) && in ef10_nvram_type_to_partn()
2342 (entry->port_mask & (1u << emip->emi_port))) { in ef10_nvram_type_to_partn()
2343 *partnp = entry->partn; in ef10_nvram_type_to_partn()
2360 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); in ef10_nvram_partn_to_type()
2371 if ((entry->partn == partn) && in ef10_nvram_partn_to_type()
2372 (entry->port_mask & (1u << emip->emi_port))) { in ef10_nvram_partn_to_type()
2373 *typep = entry->nvtype; in ef10_nvram_partn_to_type()
2395 EFSYS_KMEM_ALLOC(enp->en_esip, size, partns); in ef10_nvram_test()
2415 EFSYS_KMEM_FREE(enp->en_esip, size, partns); in ef10_nvram_test()
2422 EFSYS_KMEM_FREE(enp->en_esip, size, partns); in ef10_nvram_test()