Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vioscsi] SendSRB minor refactor #1153

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions vioscsi/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ SendSRB(
STOR_LOCK_HANDLE LockHandle = { 0 };
ULONG status = STOR_STATUS_SUCCESS;
UCHAR ScsiStatus = SCSISTAT_GOOD;
ULONG MessageID;
int res = 0;
ULONG MessageID;
INT res = VQ_ADD_BUFFER_SUCCESS;
PREQUEST_LIST element;
ULONG index;
ULONG vq_req_idx;
ENTER_FN_SRB();

if (!Srb)
Expand Down Expand Up @@ -93,7 +93,7 @@ ENTER_FN_SRB();
}

MessageID = QUEUE_TO_MESSAGE(QueueNumber);
index = QueueNumber - VIRTIO_SCSI_REQUEST_QUEUE_0;
vq_req_idx = QueueNumber - VIRTIO_SCSI_REQUEST_QUEUE_0;

if (adaptExt->reset_in_progress) {
RhelDbgPrint(TRACE_LEVEL_FATAL, " Reset is in progress, completing SRB 0x%p with SRB_STATUS_BUS_RESET.\n", Srb);
Expand All @@ -105,12 +105,12 @@ ENTER_FN_SRB();
VioScsiVQLock(DeviceExtension, MessageID, &LockHandle, FALSE);
SET_VA_PA();
res = virtqueue_add_buf(adaptExt->vq[QueueNumber],
srbExt->psgl,
srbExt->out, srbExt->in,
&srbExt->cmd, va, pa);
srbExt->psgl,
srbExt->out, srbExt->in,
&srbExt->cmd, va, pa);

if (res >= 0) {
element = &adaptExt->processing_srbs[index];
if (res == VQ_ADD_BUFFER_SUCCESS) {
benyamin-codez marked this conversation as resolved.
Show resolved Hide resolved
element = &adaptExt->processing_srbs[vq_req_idx];
InsertTailList(&element->srb_list, &srbExt->list_entry);
element->srb_cnt++;
}
Expand All @@ -120,13 +120,16 @@ ENTER_FN_SRB();
virtqueue_notify(adaptExt->vq[QueueNumber]);
}
} else {
// virtqueue_add_buf() returned -28 (ENOSPC), i.e. no space for buffer, or some other error
benyamin-codez marked this conversation as resolved.
Show resolved Hide resolved
virtqueue_notify(adaptExt->vq[QueueNumber]);
ScsiStatus = SCSISTAT_QUEUE_FULL;
SRB_SET_SRB_STATUS(Srb, SRB_STATUS_BUSY);
SRB_SET_SCSI_STATUS(Srb, ScsiStatus);
StorPortBusy(DeviceExtension, 10);
RhelDbgPrint(TRACE_LEVEL_WARNING,
benyamin-codez marked this conversation as resolved.
Show resolved Hide resolved
" Could not put an SRB into a VQ due to error %i. To be completed with SRB_STATUS_BUSY. QueueNumber = %lu, SRB = 0x%p, Lun = %d, TimeOut = %d.\n",
res, QueueNumber, srbExt->Srb, SRB_LUN(Srb), Srb->TimeOutValue);
CompleteRequest(DeviceExtension, Srb);
RhelDbgPrint(TRACE_LEVEL_FATAL, " Could not put an SRB into a VQ, so complete it with SRB_STATUS_BUSY. QueueNumber = %d, SRB = 0x%p, Lun = %d, TimeOut = %d.\n", QueueNumber, srbExt->Srb, SRB_LUN(Srb), Srb->TimeOutValue);
}

EXIT_FN_SRB();
Expand Down
2 changes: 2 additions & 0 deletions vioscsi/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#define CACHE_LINE_SIZE 64
#define ROUND_TO_CACHE_LINES(Size) (((ULONG_PTR)(Size) + CACHE_LINE_SIZE - 1) & ~(CACHE_LINE_SIZE - 1))

#define VQ_ADD_BUFFER_SUCCESS 0

#include <srbhelper.h>

// Note: SrbGetCdbLength is defined in srbhelper.h
Expand Down