Skip to content

Commit 326c6e3

Browse files
kevmwYanVugenfirer
authored andcommitted
viostor: Move from msix_one_vector to msix_has_config_vector
What makes msix_one_vector really different from other cases in the code is just that it means that MSI isn't used for config changes and so the vector indices move by one (because the config vector is 0 and all the queue vectors start from 1 then, whereas without the config vector, the vectors for queues already start from 0). If we wanted, we could have multiple vectors in use even without a config vector, and that's actually a very good idea when we have less vectors than num_queues + 1. msix_one_vector isn't a very good name any more then. So let's have an adaptExt->msix_has_config_vector instead. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1 parent 305bbac commit 326c6e3

File tree

4 files changed

+14
-19
lines changed

4 files changed

+14
-19
lines changed

viostor/virtio_pci.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,13 @@ static u16 vdev_get_msix_vector(void *context, int queue)
231231
/* queue interrupt */
232232
if (adaptExt->msix_enabled)
233233
{
234-
if (adaptExt->msix_one_vector)
235-
{
236-
vector = 0;
237-
}
238-
else
239-
{
240-
vector = queue + 1;
241-
}
234+
vector = adaptExt->msix_has_config_vector ? queue + 1 : queue;
242235
}
243236
}
244237
else
245238
{
246239
/* on-device-config-change interrupt */
247-
if (!adaptExt->msix_one_vector)
240+
if (adaptExt->msix_has_config_vector)
248241
{
249242
vector = VIRTIO_BLK_MSIX_CONFIG_VECTOR;
250243
}

viostor/virtio_stor.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -709,13 +709,14 @@ VirtIoHwInitialize(IN PVOID DeviceExtension)
709709
{
710710
/* initialize queues with a MSI vector per queue */
711711
RhelDbgPrint(TRACE_LEVEL_INFORMATION, (" Using a unique MSI vector per queue\n"));
712-
adaptExt->msix_one_vector = FALSE;
712+
adaptExt->msix_has_config_vector = TRUE;
713713
}
714714
else
715715
{
716716
/* if we don't have enough vectors, use one for all queues */
717+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, (" Disabling MSI config vector\n"));
717718
RhelDbgPrint(TRACE_LEVEL_INFORMATION, (" Using one MSI vector for all queues\n"));
718-
adaptExt->msix_one_vector = TRUE;
719+
adaptExt->msix_has_config_vector = FALSE;
719720
/* TODO Allow using multiple queues even with a single vector */
720721
adaptExt->num_queues = 1;
721722
}
@@ -770,7 +771,7 @@ VirtIoHwInitialize(IN PVOID DeviceExtension)
770771
if (CHECKFLAG(perfData.Flags, STOR_PERF_INTERRUPT_MESSAGE_RANGES))
771772
{
772773
adaptExt->perfFlags |= STOR_PERF_INTERRUPT_MESSAGE_RANGES;
773-
perfData.FirstRedirectionMessageNumber = adaptExt->msix_one_vector ? 0 : 1;
774+
perfData.FirstRedirectionMessageNumber = adaptExt->msix_has_config_vector ? 1 : 0;
774775
perfData.LastRedirectionMessageNumber = perfData.FirstRedirectionMessageNumber +
775776
adaptExt->num_queues - 1;
776777
ASSERT(perfData.lastRedirectionMessageNumber < adaptExt->num_affinity);
@@ -1259,9 +1260,9 @@ VirtIoInterrupt(IN PVOID DeviceExtension)
12591260
intReason = virtio_read_isr_status(&adaptExt->vdev);
12601261
if (intReason == 1 || adaptExt->dump_mode)
12611262
{
1262-
if (!CompleteDPC(DeviceExtension, !adaptExt->msix_one_vector))
1263+
if (!CompleteDPC(DeviceExtension, adaptExt->msix_has_config_vector))
12631264
{
1264-
VioStorCompleteRequest(DeviceExtension, !adaptExt->msix_one_vector, TRUE);
1265+
VioStorCompleteRequest(DeviceExtension, adaptExt->msix_has_config_vector, TRUE);
12651266
}
12661267
isInterruptServiced = TRUE;
12671268
}
@@ -1584,7 +1585,7 @@ VirtIoMSInterruptRoutine(IN PVOID DeviceExtension, IN ULONG MessageID)
15841585
return FALSE;
15851586
}
15861587

1587-
if (!adaptExt->msix_one_vector && MessageID == VIRTIO_BLK_MSIX_CONFIG_VECTOR)
1588+
if (adaptExt->msix_has_config_vector && MessageID == VIRTIO_BLK_MSIX_CONFIG_VECTOR)
15881589
{
15891590
RhelGetDiskGeometry(DeviceExtension);
15901591
adaptExt->sense_info.senseKey = SCSI_SENSE_UNIT_ATTENTION;
@@ -2179,7 +2180,7 @@ VOID VioStorCompleteRequest(IN PVOID DeviceExtension, IN ULONG MessageID, IN BOO
21792180
{
21802181
unsigned int len = 0;
21812182
PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension;
2182-
ULONG QueueNumber = adaptExt->msix_one_vector ? MessageID : MessageID - 1;
2183+
ULONG QueueNumber = MessageID - adaptExt->msix_has_config_vector;
21832184
STOR_LOCK_HANDLE queueLock = {0};
21842185
struct virtqueue *vq = NULL;
21852186
ULONG_PTR srbId = 0;

viostor/virtio_stor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ typedef struct _ADAPTER_EXTENSION
231231
BOOLEAN dump_mode;
232232
ULONG msix_vectors;
233233
BOOLEAN msix_enabled;
234-
BOOLEAN msix_one_vector;
234+
/* Standard C type because we do arithmetics with it */
235+
_Bool msix_has_config_vector;
235236
ULONGLONG features;
236237
CHAR sn[BLOCK_SERIAL_STRLEN];
237238
BOOLEAN sn_ok;

viostor/virtio_stor_hw_helper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static inline ULONG QueueToMessageId(PVOID DeviceExtension, ULONG QueueNumber)
7373
{
7474
PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension;
7575

76-
if (!adaptExt->msix_one_vector)
76+
if (adaptExt->msix_has_config_vector)
7777
{
7878
QueueNumber++;
7979
}
@@ -90,7 +90,7 @@ static inline ULONG MessageToDpcIdx(PVOID DeviceExtension, ULONG MessageId)
9090
{
9191
PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension;
9292

93-
if (!adaptExt->msix_one_vector)
93+
if (adaptExt->msix_has_config_vector)
9494
{
9595
/* The config vector doesn't have a slot in adaptExt->dpc */
9696
MessageId--;

0 commit comments

Comments
 (0)