Skip to content

Commit

Permalink
Update to latest sDDF
Browse files Browse the repository at this point in the history
Fixes for a bunch of block interface renames

Signed-off-by: Ivan Velickovic <[email protected]>
  • Loading branch information
Ivan-Velickovic committed Aug 8, 2024
1 parent 7d80b1d commit e376b2f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
20 changes: 10 additions & 10 deletions src/virtio/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static bool sddf_make_req_check(struct virtio_blk_device *state, uint16_t sddf_c
return false;
}

if (blk_req_queue_full(&state->queue_h)) {
if (blk_queue_full_req(&state->queue_h)) {
LOG_BLOCK_ERR("Request queue is full\n");
return false;
}
Expand Down Expand Up @@ -256,7 +256,7 @@ static bool virtio_blk_mmio_queue_notify(struct virtio_device *dev)
};

uintptr_t offset = sddf_data - ((struct virtio_blk_device *)dev->device_data)->data_region;
err = blk_enqueue_req(&state->queue_h, READ_BLOCKS, offset, sddf_block_number, sddf_count, req_id);
err = blk_enqueue_req(&state->queue_h, BLK_REQ_READ, offset, sddf_block_number, sddf_count, req_id);
assert(!err);
break;
}
Expand Down Expand Up @@ -302,7 +302,7 @@ static bool virtio_blk_mmio_queue_notify(struct virtio_device *dev)
};

uintptr_t offset = sddf_data - ((struct virtio_blk_device *)dev->device_data)->data_region;
err = blk_enqueue_req(&state->queue_h, READ_BLOCKS, offset, sddf_block_number, sddf_count, req_id);
err = blk_enqueue_req(&state->queue_h, BLK_REQ_READ, offset, sddf_block_number, sddf_count, req_id);
assert(!err);
} else {
if (!sddf_make_req_check(state, sddf_count)) {
Expand Down Expand Up @@ -331,7 +331,7 @@ static bool virtio_blk_mmio_queue_notify(struct virtio_device *dev)
memcpy((void *)sddf_data, (void *)virtq->desc[curr_desc_head].addr, virtq->desc[curr_desc_head].len);

uintptr_t offset = sddf_data - ((struct virtio_blk_device *)dev->device_data)->data_region;
err = blk_enqueue_req(&state->queue_h, WRITE_BLOCKS, offset, sddf_block_number, sddf_count, req_id);
err = blk_enqueue_req(&state->queue_h, BLK_REQ_WRITE, offset, sddf_block_number, sddf_count, req_id);
assert(!err);
}
break;
Expand All @@ -354,7 +354,7 @@ static bool virtio_blk_mmio_queue_notify(struct virtio_device *dev)
desc_head, 0, 0, 0, 0, 0
};

err = blk_enqueue_req(&state->queue_h, FLUSH, 0, 0, 0, req_id);
err = blk_enqueue_req(&state->queue_h, BLK_REQ_FLUSH, 0, 0, 0, req_id);
break;
}
default: {
Expand All @@ -379,7 +379,7 @@ static bool virtio_blk_mmio_queue_notify(struct virtio_device *dev)
success = virtio_blk_virq_inject(dev);
}

if (!blk_req_queue_plugged(&state->queue_h)) {
if (!blk_queue_plugged_req(&state->queue_h)) {
/* there is a world where all requests to be handled during this batch
* are dropped and hence this notify to the other PD would be redundant */
microkit_notify(state->server_ch);
Expand All @@ -392,13 +392,13 @@ bool virtio_blk_handle_resp(struct virtio_blk_device *state)
{
struct virtio_device *dev = &state->virtio_device;

blk_response_status_t sddf_ret_status;
blk_resp_status_t sddf_ret_status;
uint16_t sddf_ret_success_count;
uint32_t sddf_ret_id;

bool handled = false;
int err = 0;
while (!blk_resp_queue_empty(&state->queue_h)) {
while (!blk_queue_empty_resp(&state->queue_h)) {
err = blk_dequeue_resp(&state->queue_h,
&sddf_ret_status,
&sddf_ret_success_count,
Expand All @@ -416,7 +416,7 @@ bool virtio_blk_handle_resp(struct virtio_blk_device *state)
uint16_t curr_virtio_desc = virtq->desc[data->virtio_desc_head].next;

bool resp_success = false;
if (sddf_ret_status == SUCCESS) {
if (sddf_ret_status == BLK_RESP_OK) {
resp_success = true;
switch (virtio_req->type) {
case VIRTIO_BLK_T_IN: {
Expand All @@ -440,7 +440,7 @@ bool virtio_blk_handle_resp(struct virtio_blk_device *state)
};

err = blk_enqueue_req(&state->queue_h,
WRITE_BLOCKS,
BLK_REQ_WRITE,
data->sddf_data - state->data_region,
data->sddf_block_number,
data->sddf_count,
Expand Down
36 changes: 18 additions & 18 deletions tools/linux/uio_drivers/blk/blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,31 +132,31 @@ int driver_init(void **maps, uintptr_t *maps_phys, int num_maps, int argc, char

void driver_notified()
{
blk_request_code_t req_code;
blk_req_code_t req_code;
uintptr_t req_offset;
uint32_t req_block_number;
uint16_t req_count;
uint32_t req_id;

while (!blk_req_queue_empty(&h)) {
while (!blk_queue_empty_req(&h)) {
blk_dequeue_req(&h, &req_code, &req_offset, &req_block_number, &req_count, &req_id);
LOG_UIO_BLOCK("Received command: code=%d, offset=0x%lx, block_number=%d, count=%d, id=%d\n", req_code, req_offset,
req_block_number, req_count, req_id);

blk_response_status_t status = SUCCESS;
blk_resp_status_t status = BLK_RESP_OK;
uint16_t success_count = 0;

if (blk_resp_queue_full(&h)) {
if (blk_queue_full_resp(&h)) {
LOG_UIO_BLOCK_ERR("Response ring is full, dropping response\n");
continue;
}

switch (req_code) {
case READ_BLOCKS: {
case BLK_REQ_READ: {
int ret = lseek(storage_fd, (off_t)req_block_number * BLK_TRANSFER_SIZE, SEEK_SET);
if (ret < 0) {
LOG_UIO_BLOCK_ERR("Failed to seek in storage: %s\n", strerror(errno));
status = SEEK_ERROR;
status = BLK_RESP_SEEK_ERROR;
success_count = 0;
break;
}
Expand All @@ -165,19 +165,19 @@ void driver_notified()
LOG_UIO_BLOCK("Read from storage successfully: %d bytes\n", bytes_read);
if (bytes_read < 0) {
LOG_UIO_BLOCK_ERR("Failed to read from storage: %s\n", strerror(errno));
status = SEEK_ERROR;
status = BLK_RESP_SEEK_ERROR;
success_count = 0;
} else {
status = SUCCESS;
status = BLK_RESP_OK;
success_count = bytes_read / BLK_TRANSFER_SIZE;
}
break;
}
case WRITE_BLOCKS: {
case BLK_REQ_WRITE: {
int ret = lseek(storage_fd, (off_t)req_block_number * BLK_TRANSFER_SIZE, SEEK_SET);
if (ret < 0) {
LOG_UIO_BLOCK_ERR("Failed to seek in storage: %s\n", strerror(errno));
status = SEEK_ERROR;
status = BLK_RESP_SEEK_ERROR;
success_count = 0;
break;
}
Expand All @@ -186,31 +186,31 @@ void driver_notified()
LOG_UIO_BLOCK("Wrote to storage successfully: %d bytes\n", bytes_written);
if (bytes_written < 0) {
LOG_UIO_BLOCK_ERR("Failed to write to storage: %s\n", strerror(errno));
status = SEEK_ERROR;
status = BLK_RESP_SEEK_ERROR;
success_count = 0;
} else {
status = SUCCESS;
status = BLK_RESP_OK;
success_count = bytes_written / BLK_TRANSFER_SIZE;
}
break;
}
case FLUSH: {
case BLK_REQ_FLUSH: {
int ret = fsync(storage_fd);
if (ret != 0) {
LOG_UIO_BLOCK_ERR("Failed to flush storage: %s\n", strerror(errno));
status = SEEK_ERROR;
status = BLK_RESP_SEEK_ERROR;
} else {
status = SUCCESS;
status = BLK_RESP_OK;
}
break;
}
case BARRIER: {
case BLK_REQ_BARRIER: {
int ret = fsync(storage_fd);
if (ret != 0) {
LOG_UIO_BLOCK_ERR("Failed to flush storage: %s\n", strerror(errno));
status = SEEK_ERROR;
status = BLK_RESP_SEEK_ERROR;
} else {
status = SUCCESS;
status = BLK_RESP_OK;
}
break;
}
Expand Down

0 comments on commit e376b2f

Please sign in to comment.