Lines Matching +full:five +full:- +full:cell

1 /*-
91 /* Fail if the item size exceeds slab_len - caller should increase slab_size, in ocs_array_alloc()
104 array->os = os; in ocs_array_alloc()
105 array->size = size; in ocs_array_alloc()
106 array->count = count; in ocs_array_alloc()
107 array->elems_per_row = slab_len / size; in ocs_array_alloc()
108 array->n_rows = (count + array->elems_per_row - 1) / array->elems_per_row; in ocs_array_alloc()
109 array->bytes_per_row = array->elems_per_row * array->size; in ocs_array_alloc()
111 array->array_rows_len = array->n_rows * sizeof(*array->array_rows); in ocs_array_alloc()
112 array->array_rows = ocs_malloc(os, array->array_rows_len, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_array_alloc()
113 if (array->array_rows == NULL) { in ocs_array_alloc()
117 for (i = 0; i < array->n_rows; i++) { in ocs_array_alloc()
118 array->array_rows[i] = ocs_malloc(os, array->bytes_per_row, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_array_alloc()
119 if (array->array_rows[i] == NULL) { in ocs_array_alloc()
143 if (array->array_rows != NULL) { in ocs_array_free()
144 for (i = 0; i < array->n_rows; i++) { in ocs_array_free()
145 if (array->array_rows[i] != NULL) { in ocs_array_free()
146 ocs_free(array->os, array->array_rows[i], array->bytes_per_row); in ocs_array_free()
149 ocs_free(array->os, array->array_rows, array->array_rows_len); in ocs_array_free()
151 ocs_free(array->os, array, sizeof(*array)); in ocs_array_free()
169 if (idx < array->count) { in ocs_array_get()
170 uint32_t row = idx / array->elems_per_row; in ocs_array_get()
171 uint32_t offset = idx % array->elems_per_row; in ocs_array_get()
172 entry = ((uint8_t*)array->array_rows[row]) + (offset * array->size); in ocs_array_get()
189 return array->count; in ocs_array_get_count()
204 return array->size; in ocs_array_get_size()
243 va->os = os; in ocs_varray_alloc()
244 va->array_count = array_count; in ocs_varray_alloc()
245 va->array = ocs_malloc(os, sizeof(*va->array) * va->array_count, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_varray_alloc()
246 if (va->array != NULL) { in ocs_varray_alloc()
247 va->next_index = 0; in ocs_varray_alloc()
248 ocs_lock_init(os, &va->lock, "varray:%p", va); in ocs_varray_alloc()
270 ocs_lock_free(&va->lock); in ocs_varray_free()
271 if (va->array != NULL) { in ocs_varray_free()
272 ocs_free(va->os, va->array, sizeof(*va->array) * va->array_count); in ocs_varray_free()
274 ocs_free(va->os, va, sizeof(*va)); in ocs_varray_free()
286 * @return returns 0 if entry was added, -1 if there is no more space in the array
291 uint32_t rc = -1; in ocs_varray_add()
293 ocs_lock(&va->lock); in ocs_varray_add()
294 if (va->entry_count < va->array_count) { in ocs_varray_add()
295 va->array[va->entry_count++] = entry; in ocs_varray_add()
298 ocs_unlock(&va->lock); in ocs_varray_add()
315 ocs_lock(&va->lock); in ocs_varray_iter_reset()
316 va->next_index = 0; in ocs_varray_iter_reset()
317 ocs_unlock(&va->lock); in ocs_varray_iter_reset()
337 ocs_lock(&va->lock); in ocs_varray_iter_next()
339 ocs_unlock(&va->lock); in ocs_varray_iter_next()
360 rval = va->array[va->next_index]; in _ocs_varray_iter_next()
361 if (++va->next_index >= va->entry_count) { in _ocs_varray_iter_next()
362 va->next_index = 0; in _ocs_varray_iter_next()
379 ocs_lock(&va->lock); in ocs_varray_lock()
394 ocs_unlock(&va->lock); in ocs_varray_unlock()
411 ocs_lock(&va->lock); in ocs_varray_get_count()
412 rc = va->entry_count; in ocs_varray_get_count()
413 ocs_unlock(&va->lock); in ocs_varray_get_count()
449 cbuf->os = os; in ocs_cbuf_alloc()
450 cbuf->entry_count = entry_count; in ocs_cbuf_alloc()
451 cbuf->pidx = 0; in ocs_cbuf_alloc()
452 cbuf->cidx = 0; in ocs_cbuf_alloc()
454 ocs_lock_init(NULL, &cbuf->cbuf_clock, "cbuf_c:%p", cbuf); in ocs_cbuf_alloc()
455 ocs_lock_init(NULL, &cbuf->cbuf_plock, "cbuf_p:%p", cbuf); in ocs_cbuf_alloc()
456 ocs_sem_init(&cbuf->cbuf_csem, 0, "cbuf:%p", cbuf); in ocs_cbuf_alloc()
457 ocs_sem_init(&cbuf->cbuf_psem, cbuf->entry_count, "cbuf:%p", cbuf); in ocs_cbuf_alloc()
459 cbuf->array = ocs_malloc(os, entry_count * sizeof(*cbuf->array), OCS_M_NOWAIT | OCS_M_ZERO); in ocs_cbuf_alloc()
460 if (cbuf->array == NULL) { in ocs_cbuf_alloc()
481 if (cbuf->array != NULL) { in ocs_cbuf_free()
482 ocs_free(cbuf->os, cbuf->array, sizeof(*cbuf->array) * cbuf->entry_count); in ocs_cbuf_free()
484 ocs_lock_free(&cbuf->cbuf_clock); in ocs_cbuf_free()
485 ocs_lock_free(&cbuf->cbuf_plock); in ocs_cbuf_free()
486 ocs_free(cbuf->os, cbuf, sizeof(*cbuf)); in ocs_cbuf_free()
505 if (likely(ocs_sem_p(&cbuf->cbuf_csem, timeout_usec) == 0)) { in ocs_cbuf_get()
506 ocs_lock(&cbuf->cbuf_clock); in ocs_cbuf_get()
507 ret = cbuf->array[cbuf->cidx]; in ocs_cbuf_get()
508 if (unlikely(++cbuf->cidx >= cbuf->entry_count)) { in ocs_cbuf_get()
509 cbuf->cidx = 0; in ocs_cbuf_get()
511 ocs_unlock(&cbuf->cbuf_clock); in ocs_cbuf_get()
512 ocs_sem_v(&cbuf->cbuf_psem); in ocs_cbuf_get()
532 if (likely(ocs_sem_p(&cbuf->cbuf_psem, -1) == 0)) { in ocs_cbuf_put()
533 ocs_lock(&cbuf->cbuf_plock); in ocs_cbuf_put()
534 cbuf->array[cbuf->pidx] = elem; in ocs_cbuf_put()
535 if (unlikely(++cbuf->pidx >= cbuf->entry_count)) { in ocs_cbuf_put()
536 cbuf->pidx = 0; in ocs_cbuf_put()
538 ocs_unlock(&cbuf->cbuf_plock); in ocs_cbuf_put()
539 ocs_sem_v(&cbuf->cbuf_csem); in ocs_cbuf_put()
541 rc = -1; in ocs_cbuf_put()
560 uint32_t count = MIN(ocs_array_get_count(array), cbuf->entry_count); in ocs_cbuf_prime()
581 ocs_textbuf_printf(textbuf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n"); in ocs_ddump_startfile()
693 if ((i % OCS_NEWLINE_MOD) == (OCS_NEWLINE_MOD - 1)) { in ocs_ddump_buffer()
727 if ((qentries == (uint32_t)-1) || (qentries > length)) { in ocs_ddump_queue_entries()
728 /* if qentries is -1 or larger than queue size, dump entire queue */ in ocs_ddump_queue_entries()
734 index -= (qentries - 1); in ocs_ddump_queue_entries()
750 ((j % OCS_NEWLINE_MOD) == (OCS_NEWLINE_MOD - 1))) { in ocs_ddump_queue_entries()
787 * Enables debug options by or-ing in <b>mask</b> into the currently enabled
870 pbuf += ocs_snprintf(pbuf, sizeof(linebuf) - (pbuf-linebuf), "%08X: ", addr); in ocs_dump32()
877 pbuf += ocs_snprintf(pbuf, sizeof(linebuf) - (pbuf-linebuf), "%08X ", wbuf[i]); in ocs_dump32()
880 pbuf += ocs_snprintf(pbuf, sizeof(linebuf) - (pbuf-linebuf), "%8s ", ""); in ocs_dump32()
882 pbuf += ocs_snprintf(pbuf, sizeof(linebuf) - (pbuf-linebuf), " "); in ocs_dump32()
885 …pbuf += ocs_snprintf(pbuf, sizeof(linebuf) - (pbuf-linebuf), "%c", _isprint(cbuf[i]) ? cbuf[i] : '… in ocs_dump32()
886 pbuf += ocs_snprintf(pbuf, sizeof(linebuf) - (pbuf-linebuf), "\n"); in ocs_dump32()
891 word_count -= n; in ocs_dump32()
933 /* CQE type Q_hist_type mask (success) mask (non-success) */
942 if (ocs_q_hist_wqe_masks[i].command == wqe->command) { in ocs_q_hist_get_wqe_mask()
962 q_hist->ocs = ocs; in ocs_queue_history_init()
963 if (q_hist->q_hist != NULL) { in ocs_queue_history_init()
969 …q_hist->q_hist = ocs_malloc(ocs, sizeof(*q_hist->q_hist)*OCS_Q_HIST_SIZE, OCS_M_ZERO | OCS_M_NOWAI… in ocs_queue_history_init()
971 if (q_hist->q_hist == NULL) { in ocs_queue_history_init()
974 ocs_lock_init(ocs, &q_hist->q_hist_lock, "queue history lock[%d]", ocs_instance(ocs)); in ocs_queue_history_init()
977 q_hist->q_hist_index = 0; in ocs_queue_history_init()
991 ocs_t *ocs = q_hist->ocs; in ocs_queue_history_free()
993 if (q_hist->q_hist != NULL) { in ocs_queue_history_free()
994 ocs_free(ocs, q_hist->q_hist, sizeof(*q_hist->q_hist)*OCS_Q_HIST_SIZE); in ocs_queue_history_free()
995 ocs_lock_free(&q_hist->q_hist_lock); in ocs_queue_history_free()
996 q_hist->q_hist = NULL; in ocs_queue_history_free()
1005 q_hist->q_hist[q_hist->q_hist_index] = (qid << 16) | qindex; in ocs_queue_history_add_q_info()
1006 q_hist->q_hist_index++; in ocs_queue_history_add_q_info()
1007 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE; in ocs_queue_history_add_q_info()
1018 q_hist->q_hist[q_hist->q_hist_index] = ((tsc_value >> 32 ) & 0xFFFFFFFF); in ocs_queue_history_add_timestamp()
1019 q_hist->q_hist_index++; in ocs_queue_history_add_timestamp()
1020 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE; in ocs_queue_history_add_timestamp()
1021 q_hist->q_hist[q_hist->q_hist_index] = (tsc_value & 0xFFFFFFFF); in ocs_queue_history_add_timestamp()
1022 q_hist->q_hist_index++; in ocs_queue_history_add_timestamp()
1023 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE; in ocs_queue_history_add_timestamp()
1045 if (q_hist->q_hist == NULL) { in ocs_queue_history_wq()
1052 ocs_lock(&q_hist->q_hist_lock); in ocs_queue_history_wq()
1054 for (i = ((sizeof(wqe_word_mask)*8) - 1); i >= 0; i--){ in ocs_queue_history_wq()
1056 q_hist->q_hist[q_hist->q_hist_index] = entryw[i]; in ocs_queue_history_wq()
1057 q_hist->q_hist_index++; in ocs_queue_history_wq()
1058 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE; in ocs_queue_history_wq()
1068 q_hist->q_hist[q_hist->q_hist_index] = ftr.word; in ocs_queue_history_wq()
1069 q_hist->q_hist_index++; in ocs_queue_history_wq()
1070 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE; in ocs_queue_history_wq()
1073 ocs_unlock(&q_hist->q_hist_lock); in ocs_queue_history_wq()
1093 if (q_hist->q_hist == NULL) { in ocs_queue_history_misc()
1100 ocs_lock(&q_hist->q_hist_lock); in ocs_queue_history_misc()
1102 for (i = num_words-1; i >= 0; i--) { in ocs_queue_history_misc()
1103 q_hist->q_hist[q_hist->q_hist_index] = entryw[i]; in ocs_queue_history_misc()
1104 q_hist->q_hist_index++; in ocs_queue_history_misc()
1105 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE; in ocs_queue_history_misc()
1114 q_hist->q_hist[q_hist->q_hist_index] = ftr.word; in ocs_queue_history_misc()
1115 q_hist->q_hist_index++; in ocs_queue_history_misc()
1116 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE; in ocs_queue_history_misc()
1119 ocs_unlock(&q_hist->q_hist_lock); in ocs_queue_history_misc()
1144 if (q_hist->q_hist == NULL) { in ocs_queue_history_cqe()
1160 ocs_lock(&q_hist->q_hist_lock); in ocs_queue_history_cqe()
1162 for (i = ((sizeof(cqe_word_mask)*8) - 1); i >= 0; i--){ in ocs_queue_history_cqe()
1164 q_hist->q_hist[q_hist->q_hist_index] = entryw[i]; in ocs_queue_history_cqe()
1165 q_hist->q_hist_index++; in ocs_queue_history_cqe()
1166 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE; in ocs_queue_history_cqe()
1175 q_hist->q_hist[q_hist->q_hist_index] = ftr.word; in ocs_queue_history_cqe()
1176 q_hist->q_hist_index++; in ocs_queue_history_cqe()
1177 q_hist->q_hist_index = q_hist->q_hist_index % OCS_Q_HIST_SIZE; in ocs_queue_history_cqe()
1180 ocs_unlock(&q_hist->q_hist_lock); in ocs_queue_history_cqe()
1192 return OCS_Q_HIST_SIZE - 1; in ocs_queue_history_prev_index()
1194 return index - 1; in ocs_queue_history_prev_index()
1244 * @param crc Previously-calculated CRC, or 0 for a new block.
1257 * @brief Calculate the IP-checksum guard value for a block.
1263 * Sum all all the 16-byte words in the block
1264 * Add in the "carry", which is everything in excess of 16-bits
1315 switch(dif_info->blk_size) { in ocs_scsi_dif_blocksize()
1347 case 512: dif_info->blk_size = OCS_SCSI_DIF_BK_SIZE_512; break; in ocs_scsi_dif_set_blocksize()
1348 case 1024: dif_info->blk_size = OCS_SCSI_DIF_BK_SIZE_1024; break; in ocs_scsi_dif_set_blocksize()
1349 case 2048: dif_info->blk_size = OCS_SCSI_DIF_BK_SIZE_2048; break; in ocs_scsi_dif_set_blocksize()
1350 case 4096: dif_info->blk_size = OCS_SCSI_DIF_BK_SIZE_4096; break; in ocs_scsi_dif_set_blocksize()
1351 case 520: dif_info->blk_size = OCS_SCSI_DIF_BK_SIZE_520; break; in ocs_scsi_dif_set_blocksize()
1352 case 4104: dif_info->blk_size = OCS_SCSI_DIF_BK_SIZE_4104; break; in ocs_scsi_dif_set_blocksize()
1354 rc = -1; in ocs_scsi_dif_set_blocksize()
1405 return -1; in ocs_scsi_dif_mem_blocksize()
1409 ocs_assert(dif_info->dif_oper < ARRAY_SIZE(wiretomem_adj), 0); in ocs_scsi_dif_mem_blocksize()
1410 blocksize += wiretomem_adj[dif_info->dif_oper]; in ocs_scsi_dif_mem_blocksize()
1412 ocs_assert(dif_info->dif_oper < ARRAY_SIZE(memtowire_adj), 0); in ocs_scsi_dif_mem_blocksize()
1413 blocksize += memtowire_adj[dif_info->dif_oper]; in ocs_scsi_dif_mem_blocksize()
1462 return -1; in ocs_scsi_dif_wire_blocksize()
1466 ocs_assert(dif_info->dif_oper < ARRAY_SIZE(wiretomem_adj), 0); in ocs_scsi_dif_wire_blocksize()
1467 blocksize += wiretomem_adj[dif_info->dif_oper]; in ocs_scsi_dif_wire_blocksize()
1469 ocs_assert(dif_info->dif_oper < ARRAY_SIZE(memtowire_adj), 0); in ocs_scsi_dif_wire_blocksize()
1470 blocksize += memtowire_adj[dif_info->dif_oper]; in ocs_scsi_dif_wire_blocksize()
1491 switch(dif_info->blk_size) { in ocs_hw_dif_blocksize()
1549 return -1; in ocs_hw_dif_mem_blocksize()
1553 ocs_assert(dif_info->dif_oper < ARRAY_SIZE(wiretomem_adj), 0); in ocs_hw_dif_mem_blocksize()
1554 blocksize += wiretomem_adj[dif_info->dif_oper]; in ocs_hw_dif_mem_blocksize()
1556 ocs_assert(dif_info->dif_oper < ARRAY_SIZE(memtowire_adj), 0); in ocs_hw_dif_mem_blocksize()
1557 blocksize += memtowire_adj[dif_info->dif_oper]; in ocs_hw_dif_mem_blocksize()
1606 return -1; in ocs_hw_dif_wire_blocksize()
1610 ocs_assert(dif_info->dif_oper < ARRAY_SIZE(wiretomem_adj), 0); in ocs_hw_dif_wire_blocksize()
1611 blocksize += wiretomem_adj[dif_info->dif_oper]; in ocs_hw_dif_wire_blocksize()
1613 ocs_assert(dif_info->dif_oper < ARRAY_SIZE(memtowire_adj), 0); in ocs_hw_dif_wire_blocksize()
1614 blocksize += memtowire_adj[dif_info->dif_oper]; in ocs_hw_dif_wire_blocksize()
1656 return segment->buffer; in ocs_textbuf_ext_get_buffer()
1663 return -1; in ocs_textbuf_ext_get_length()
1665 return segment->buffer_length; in ocs_textbuf_ext_get_length()
1672 return -1; in ocs_textbuf_ext_get_written()
1674 return segment->buffer_written; in ocs_textbuf_ext_get_written()
1680 return (textbuf->ocs != NULL); in ocs_textbuf_initialized()
1688 textbuf->ocs = ocs; in ocs_textbuf_alloc()
1689 ocs_list_init(&textbuf->segment_list, ocs_textbuf_segment_t, link); in ocs_textbuf_alloc()
1692 textbuf->allocation_length = OCS_TEXTBUF_MAX_ALLOC_LEN; in ocs_textbuf_alloc()
1694 textbuf->allocation_length = length; in ocs_textbuf_alloc()
1698 textbuf->extendable = TRUE; in ocs_textbuf_alloc()
1701 textbuf->max_allocation_length = length; in ocs_textbuf_alloc()
1704 return (ocs_textbuf_segment_alloc(textbuf) == NULL) ? -1 : 0; in ocs_textbuf_alloc()
1712 if (textbuf->extendable) { in ocs_textbuf_segment_alloc()
1713 segment = ocs_malloc(textbuf->ocs, sizeof(*segment), OCS_M_ZERO | OCS_M_NOWAIT); in ocs_textbuf_segment_alloc()
1715 … segment->buffer = ocs_malloc(textbuf->ocs, textbuf->allocation_length, OCS_M_ZERO | OCS_M_NOWAIT); in ocs_textbuf_segment_alloc()
1716 if (segment->buffer != NULL) { in ocs_textbuf_segment_alloc()
1717 segment->buffer_length = textbuf->allocation_length; in ocs_textbuf_segment_alloc()
1718 segment->buffer_written = 0; in ocs_textbuf_segment_alloc()
1719 ocs_list_add_tail(&textbuf->segment_list, segment); in ocs_textbuf_segment_alloc()
1720 textbuf->total_allocation_length += textbuf->allocation_length; in ocs_textbuf_segment_alloc()
1723 if (textbuf->total_allocation_length >= textbuf->max_allocation_length) { in ocs_textbuf_segment_alloc()
1724 textbuf->extendable = 0; in ocs_textbuf_segment_alloc()
1728 ocs_textbuf_segment_free(textbuf->ocs, segment); in ocs_textbuf_segment_alloc()
1740 if (segment->buffer && !segment->user_allocated) { in ocs_textbuf_segment_free()
1741 ocs_free(ocs, segment->buffer, segment->buffer_length); in ocs_textbuf_segment_free()
1755 ocs_list_foreach(&textbuf->segment_list, segment) { in ocs_textbuf_get_segment()
1768 int32_t rc = -1; in ocs_textbuf_init()
1773 textbuf->ocs = ocs; in ocs_textbuf_init()
1774 ocs_list_init(&textbuf->segment_list, ocs_textbuf_segment_t, link); in ocs_textbuf_init()
1777 segment->buffer = buffer; in ocs_textbuf_init()
1778 segment->buffer_length = length; in ocs_textbuf_init()
1779 segment->buffer_written = 0; in ocs_textbuf_init()
1780 segment->user_allocated = 1; in ocs_textbuf_init()
1781 ocs_list_add_tail(&textbuf->segment_list, segment); in ocs_textbuf_init()
1795 ocs_list_foreach_safe(&textbuf->segment_list, segment, n) { in ocs_textbuf_free()
1796 ocs_list_remove(&textbuf->segment_list, segment); in ocs_textbuf_free()
1831 segment = ocs_list_get_tail(&textbuf->segment_list); in ocs_textbuf_vprintf()
1841 written = ocs_vsnprintf(segment->buffer + segment->buffer_written, avail, fmt, ap); in ocs_textbuf_vprintf()
1847 if (textbuf->extendable) { in ocs_textbuf_vprintf()
1849 *(segment->buffer + segment->buffer_written) = 0; in ocs_textbuf_vprintf()
1853 ocs_log_err(textbuf->ocs, "alloc segment failed\n"); in ocs_textbuf_vprintf()
1859 written = ocs_vsnprintf(segment->buffer + segment->buffer_written, avail, fmt, save_ap); in ocs_textbuf_vprintf()
1862 segment->buffer_written += written; in ocs_textbuf_vprintf()
1874 segment = ocs_list_get_tail(&textbuf->segment_list); in ocs_textbuf_putc()
1877 *(segment->buffer + segment->buffer_written++) = c; in ocs_textbuf_putc()
1949 return ocs_segment_remaining(ocs_list_get_head(&textbuf->segment_list)); in ocs_textbuf_remaining()
1958 return segment->buffer_length - segment->buffer_written; in ocs_segment_remaining()
1970 ocs_list_foreach_safe(&textbuf->segment_list, segment, n) { in ocs_textbuf_reset()
1972 segment->buffer_written = 0; in ocs_textbuf_reset()
1974 ocs_list_remove(&textbuf->segment_list, segment); in ocs_textbuf_reset()
1975 ocs_textbuf_segment_free(textbuf->ocs, segment); in ocs_textbuf_reset()
1985 * 24-bit FC_IDs. In this case, the 24-bit index value is broken down in three
1986 * 8-bit values. These values are used to index up to three 256 element arrays.
1991 * the root row always allocated. This gives five rows of 256 x sizeof(void*),
2037 _spv_del(os, a[i], n, depth-1); in _spv_del()
2058 _spv_del(spv->os, spv->array, SPV_ROWLEN, SPV_DIM); in spv_del()
2059 ocs_free(spv->os, spv, sizeof(*spv)); in spv_del()
2085 spv->os = os; in spv_new()
2086 spv->max_idx = 1; in spv_new()
2088 spv->max_idx *= SPV_ROWLEN; in spv_new()
2096 * @brief Return the address of a cell.
2099 * Returns the address of a cell, allocates sparse rows as needed if the
2107 * @return Returns the pointer to the cell, or NULL.
2117 if (idx >= sv->max_idx) { in spv_new_cell()
2121 if (sv->array == NULL) { in spv_new_cell()
2122 sv->array = (alloc_new_rows ? spv_new_row(sv->os, SPV_ROWLEN) : NULL); in spv_new_cell()
2123 if (sv->array == NULL) { in spv_new_cell()
2127 p = sv->array; in spv_new_cell()
2129 p[a] = (alloc_new_rows ? spv_new_row(sv->os, SPV_ROWLEN) : NULL); in spv_new_cell()
2136 p[b] = (alloc_new_rows ? spv_new_row(sv->os, SPV_ROWLEN) : NULL); in spv_new_cell()
2148 * @brief Set the sparse vector cell value.
2170 * @brief Return the sparse vector cell value.
2178 * @return Returns the cell value, or NULL.
2211 * - minor syntax changes for successful compilation with contemporary
2213 * - crctable[] generated using Rocksoft public domain code
2268 * @param crc Previously-calculated CRC, or crcseed for a new block.
2278 while (blk_len--) { in t10crc16()
2304 * @param buffer_count Number of text buffers to allocate (totalling buffer-len).
2321 ramlog->textbuf_count = buffer_count; in ocs_ramlog_init()
2323 …ramlog->textbufs = ocs_malloc(ocs, sizeof(*ramlog->textbufs)*buffer_count, OCS_M_ZERO | OCS_M_NOWA… in ocs_ramlog_init()
2324 if (ramlog->textbufs == NULL) { in ocs_ramlog_init()
2331 rc = ocs_textbuf_alloc(ocs, &ramlog->textbufs[i], buffer_len); in ocs_ramlog_init()
2339 ramlog->cur_textbuf_idx = 0; in ocs_ramlog_init()
2340 ramlog->textbuf_base = 1; in ocs_ramlog_init()
2341 ramlog->cur_textbuf = &ramlog->textbufs[0]; in ocs_ramlog_init()
2342 ramlog->initialized = TRUE; in ocs_ramlog_init()
2343 ocs_lock_init(ocs, &ramlog->lock, "ramlog_lock[%d]", ocs_instance(ocs)); in ocs_ramlog_init()
2364 ocs_lock_free(&ramlog->lock); in ocs_ramlog_free()
2365 if (ramlog->textbufs) { in ocs_ramlog_free()
2366 for (i = 0; i < ramlog->textbuf_count; i ++) { in ocs_ramlog_free()
2367 ocs_textbuf_free(ocs, &ramlog->textbufs[i]); in ocs_ramlog_free()
2370 ocs_free(ocs, ramlog->textbufs, ramlog->textbuf_count*sizeof(*ramlog->textbufs)); in ocs_ramlog_free()
2371 ramlog->textbufs = NULL; in ocs_ramlog_free()
2396 for (i = ramlog->textbuf_base; i < ramlog->textbuf_count; i ++) { in ocs_ramlog_clear()
2397 ocs_textbuf_reset(&ramlog->textbufs[i]); in ocs_ramlog_clear()
2399 ramlog->cur_textbuf_idx = 1; in ocs_ramlog_clear()
2401 if (clear_start_of_day && ramlog->textbuf_base) { in ocs_ramlog_clear()
2402 ocs_textbuf_reset(&ramlog->textbufs[0]); in ocs_ramlog_clear()
2406 ramlog->textbuf_base = 0; in ocs_ramlog_clear()
2428 if (ocs == NULL || ocs->ramlog == NULL) { in ocs_ramlog_printf()
2429 return -1; in ocs_ramlog_printf()
2433 res = ocs_ramlog_vprintf(ocs->ramlog, fmt, ap); in ocs_ramlog_printf()
2454 if (ramlog == NULL || !ramlog->initialized) { in ocs_ramlog_vprintf()
2455 return -1; in ocs_ramlog_vprintf()
2461 ocs_lock(&ramlog->lock); in ocs_ramlog_vprintf()
2462 if (ocs_textbuf_remaining(ramlog->cur_textbuf) < 120) { in ocs_ramlog_vprintf()
2463 ramlog->cur_textbuf_idx = ocs_ramlog_next_idx(ramlog, ramlog->cur_textbuf_idx); in ocs_ramlog_vprintf()
2464 ramlog->cur_textbuf = &ramlog->textbufs[ramlog->cur_textbuf_idx]; in ocs_ramlog_vprintf()
2465 ocs_textbuf_reset(ramlog->cur_textbuf); in ocs_ramlog_vprintf()
2468 ocs_textbuf_vprintf(ramlog->cur_textbuf, fmt, ap); in ocs_ramlog_vprintf()
2469 ocs_unlock(&ramlog->lock); in ocs_ramlog_vprintf()
2490 if (idx >= ramlog->textbuf_count) { in ocs_ramlog_next_idx()
2491 idx = ramlog->textbuf_base; in ocs_ramlog_next_idx()
2515 if ((ramlog == NULL) || (ramlog->textbufs == NULL)) { in ocs_ddump_ramlog()
2516 return -1; in ocs_ddump_ramlog()
2519 ocs_ddump_section(textbuf, "driver-log", 0); in ocs_ddump_ramlog()
2524 if (ramlog->textbuf_base) { in ocs_ddump_ramlog()
2525 rltextbuf = &ramlog->textbufs[0]; in ocs_ddump_ramlog()
2534 idx = ocs_ramlog_next_idx(ramlog, ramlog->textbuf_count); in ocs_ddump_ramlog()
2536 for (i = ramlog->textbuf_base; i < ramlog->textbuf_count; i ++) { in ocs_ddump_ramlog()
2537 rltextbuf = &ramlog->textbufs[idx]; in ocs_ddump_ramlog()
2542 ocs_ddump_endsection(textbuf, "driver-log", 0); in ocs_ddump_ramlog()
2582 pool->os = os; in ocs_pool_alloc()
2583 pool->use_lock = use_lock; in ocs_pool_alloc()
2588 pool->a = ocs_array_alloc(os, size + sizeof(pool_hdr_t), count); in ocs_pool_alloc()
2589 if (pool->a == NULL) { in ocs_pool_alloc()
2594 ocs_list_init(&pool->freelist, pool_hdr_t, link); in ocs_pool_alloc()
2596 ocs_list_add_tail(&pool->freelist, ocs_array_get(pool->a, i)); in ocs_pool_alloc()
2599 if (pool->use_lock) { in ocs_pool_alloc()
2600 ocs_lock_init(os, &pool->lock, "ocs_pool:%p", pool); in ocs_pool_alloc()
2619 uint32_t count = ocs_array_get_count(pool->a); in ocs_pool_reset()
2620 uint32_t size = ocs_array_get_size(pool->a); in ocs_pool_reset()
2622 if (pool->use_lock) { in ocs_pool_reset()
2623 ocs_lock(&pool->lock); in ocs_pool_reset()
2628 * encountered linked list asserts when they are re-added. in ocs_pool_reset()
2630 while (!ocs_list_empty(&pool->freelist)) { in ocs_pool_reset()
2631 ocs_list_remove_head(&pool->freelist); in ocs_pool_reset()
2635 ocs_list_init(&pool->freelist, pool_hdr_t, link); in ocs_pool_reset()
2639 ocs_memset(ocs_pool_get_instance(pool, i), 0, size - sizeof(pool_hdr_t)); in ocs_pool_reset()
2640 ocs_list_add_tail(&pool->freelist, ocs_array_get(pool->a, i)); in ocs_pool_reset()
2642 if (pool->use_lock) { in ocs_pool_reset()
2643 ocs_unlock(&pool->lock); in ocs_pool_reset()
2661 if (pool->a != NULL) { in ocs_pool_free()
2662 ocs_array_free(pool->a); in ocs_pool_free()
2664 if (pool->use_lock) { in ocs_pool_free()
2665 ocs_lock_free(&pool->lock); in ocs_pool_free()
2667 ocs_free(pool->os, pool, sizeof(*pool)); in ocs_pool_free()
2687 if (pool->use_lock) { in ocs_pool_get()
2688 ocs_lock(&pool->lock); in ocs_pool_get()
2691 h = ocs_list_remove_head(&pool->freelist); in ocs_pool_get()
2698 if (pool->use_lock) { in ocs_pool_get()
2699 ocs_unlock(&pool->lock); in ocs_pool_get()
2719 if (pool->use_lock) { in ocs_pool_put()
2720 ocs_lock(&pool->lock); in ocs_pool_put()
2724 * by size of pool_hdr_t (note the index of [-1] in ocs_pool_put()
2726 h = &((pool_hdr_t*)item)[-1]; in ocs_pool_put()
2728 ocs_list_add_tail(&pool->freelist, h); in ocs_pool_put()
2730 if (pool->use_lock) { in ocs_pool_put()
2731 ocs_unlock(&pool->lock); in ocs_pool_put()
2749 if (pool->use_lock) { in ocs_pool_get_count()
2750 ocs_lock(&pool->lock); in ocs_pool_get_count()
2752 count = ocs_array_get_count(pool->a); in ocs_pool_get_count()
2753 if (pool->use_lock) { in ocs_pool_get_count()
2754 ocs_unlock(&pool->lock); in ocs_pool_get_count()
2772 pool_hdr_t *h = ocs_array_get(pool->a, idx); in ocs_pool_get_instance()
2795 if (pool->use_lock) { in ocs_pool_get_freelist_count()
2796 ocs_lock(&pool->lock); in ocs_pool_get_freelist_count()
2799 ocs_list_foreach(&pool->freelist, item) { in ocs_pool_get_freelist_count()
2803 if (pool->use_lock) { in ocs_pool_get_freelist_count()
2804 ocs_unlock(&pool->lock); in ocs_pool_get_freelist_count()