Skip to content

Commit 8b2acc9

Browse files
kevmwYanVugenfirer
authored andcommitted
viostor: Inline and simplify MESSAGENUMBER_TO_QUEUE()
Now that there is only one caller left, MESSAGENUMBER_TO_QUEUE() can just be inlined, which also allows for some simplification. Apart from dropping MessageId from GetSrbQueueNumber() and reducing nesting, change the trace message so that it includes the resulting QueueNumber instead of its previous value, which is always 0. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1 parent f7a16ff commit 8b2acc9

1 file changed

Lines changed: 27 additions & 35 deletions

File tree

viostor/virtio_stor_hw_helper.c

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,48 +44,40 @@
4444
pa = va ? StorPortGetPhysicalAddress(DeviceExtension, NULL, va, &len).QuadPart : 0; \
4545
}
4646

47-
#define MESSAGENUMBER_TO_QUEUE() \
48-
{ \
49-
if (param.MessageNumber != 0) \
50-
{ \
51-
MessageId = param.MessageNumber; \
52-
QueueNumber = MessageId - 1; \
53-
if (QueueNumber >= adaptExt->num_queues) \
54-
{ \
55-
QueueNumber %= adaptExt->num_queues; \
56-
MessageId = QueueNumber + 1; \
57-
} \
58-
} \
59-
}
60-
6147
static ULONG GetSrbQueueNumber(IN PVOID DeviceExtension, IN PSRB_TYPE Srb)
6248
{
6349
PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension;
64-
ULONG QueueNumber = 0;
65-
ULONG MessageId = 1;
50+
STARTIO_PERFORMANCE_PARAMETERS param;
51+
ULONG status;
52+
ULONG QueueNumber;
6653

67-
if (adaptExt->num_queues > 1)
54+
if (adaptExt->num_queues <= 1)
6855
{
69-
STARTIO_PERFORMANCE_PARAMETERS param;
70-
ULONG status = STOR_STATUS_SUCCESS;
56+
return 0;
57+
}
7158

72-
param.Size = sizeof(STARTIO_PERFORMANCE_PARAMETERS);
73-
status = StorPortGetStartIoPerfParams(DeviceExtension, (PSCSI_REQUEST_BLOCK)Srb, &param);
74-
if (status == STOR_STATUS_SUCCESS)
75-
{
76-
RhelDbgPrint(TRACE_LEVEL_INFORMATION,
77-
" srb %p, QueueNumber %lu, MessageNumber %lu, ChannelNumber %lu.\n",
78-
Srb,
79-
QueueNumber,
80-
param.MessageNumber,
81-
param.ChannelNumber);
82-
MESSAGENUMBER_TO_QUEUE();
83-
}
84-
else
85-
{
86-
RhelDbgPrint(TRACE_LEVEL_ERROR, " StorPortGetStartIoPerfParams failed. srb %p status 0x%x.\n", Srb, status);
87-
}
59+
param.Size = sizeof(STARTIO_PERFORMANCE_PARAMETERS);
60+
status = StorPortGetStartIoPerfParams(DeviceExtension, (PSCSI_REQUEST_BLOCK)Srb, &param);
61+
if (status != STOR_STATUS_SUCCESS)
62+
{
63+
RhelDbgPrint(TRACE_LEVEL_ERROR, " StorPortGetStartIoPerfParams failed. srb %p status 0x%x.\n", Srb, status);
64+
return 0;
65+
}
66+
67+
if (param.MessageNumber == 0)
68+
{
69+
QueueNumber = 0;
8870
}
71+
else
72+
{
73+
QueueNumber = (param.MessageNumber - 1) % adaptExt->num_queues;
74+
}
75+
RhelDbgPrint(TRACE_LEVEL_INFORMATION,
76+
" srb %p, MessageNumber %lu, ChannelNumber %lu -> QueueNumber %lu\n",
77+
Srb,
78+
param.MessageNumber,
79+
param.ChannelNumber,
80+
QueueNumber);
8981

9082
return QueueNumber;
9183
}

0 commit comments

Comments
 (0)