void lm_sc_init_sp_req_type( struct _lm_device_t * pdev, lm_iscsi_state_t * iscsi, lm_iscsi_slow_path_request_t * lm_req, void * req_input_data) { void *update_kwqe_virt; struct protocol_common_spe spe = {0}; switch(lm_req->type) { case SP_REQUEST_SC_INIT: break; case SP_REQUEST_SC_UPDATE: spe.data.phy_address.hi = iscsi->sp_req_data.phys_addr.as_u32.high; spe.data.phy_address.lo = iscsi->sp_req_data.phys_addr.as_u32.low; update_kwqe_virt = &iscsi->sp_req_data.virt_addr->update_ctx.kwqe; mm_memcpy(update_kwqe_virt, req_input_data, sizeof(struct iscsi_kwqe_conn_update)); break; default: DbgBreakMsg("lm_sc_init_sp_req_type: Illegal slow path request type!\n"); } } /* lm_init_sp_req_type */
/* * mm_realloc - Implemented simply in terms of mm_malloc and mm_free */ void *mm_realloc(void *ptr, size_t size) { if (!ptr) { return mm_malloc(size); } if (!size) { mm_free(ptr); return NULL; } void *hdrp = get_hdrp(ptr); size_t old_size = get_size(hdrp); size_t ori_size = old_size; size_t target_size = align_with_min_bk_size(size + WSIZE); // if possible, we won't move the data, collect space in place hdrp = backward_collect(hdrp, target_size); old_size = get_size(hdrp); if (target_size <= old_size) { #if HEAP_CHECK delete_from_alloc_list(ptr); #endif size_t left_size = old_size - target_size; if (left_size && is_align_with_min_bk_size(left_size)) { set_size(hdrp, target_size); set_alloc_bit(hdrp); void *new_free_hdrp = (char*)hdrp + target_size; write_word(new_free_hdrp, PREV_ALLOC); init_free_block(new_free_hdrp, left_size); insert_into_size_class(new_free_hdrp, find_index(left_size)); } else { set_alloc_bit(hdrp); set_prev_alloc_bit((char*)hdrp + old_size); } #if HEAP_CHECK add_to_alloc_list(ptr, size, target_size); #endif return (char*)hdrp + WSIZE; } // find fit void *new_hdrp = find_fit(target_size); if (new_hdrp) { new_hdrp = place_and_split(new_hdrp, target_size); mm_memcpy((char*)new_hdrp + WSIZE, ptr, ori_size - WSIZE); mm_free(ptr); #if HEAP_CHECK add_to_alloc_list((char*)new_hdrp + WSIZE, size, target_size); #endif return (char*)new_hdrp + WSIZE; } // extend heap new_hdrp = extend_heap(target_size, 1); if (!new_hdrp) return NULL; new_hdrp = place_and_split(new_hdrp, target_size); mm_memcpy((char*)new_hdrp + WSIZE, ptr, ori_size - WSIZE); mm_free(ptr); #if HEAP_CHECK add_to_alloc_list((char*)new_hdrp + WSIZE, size, target_size); #endif return (char*)new_hdrp + WSIZE; }