Changeset 85132 in vbox
- Timestamp:
- Jul 9, 2020 2:26:40 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/VirtIO/VirtioCore.cpp
r85109 r85132 77 77 /** @name virtq related flags 78 78 * @{ */ 79 #define VIRTQ UEUE_DESC_F_NEXT 1 /**< Indicates this descriptor chains to next */80 #define VIRTQ UEUE_DESC_F_WRITE 2 /**< Marks buffer as write-only (default ro) */81 #define VIRTQ UEUE_DESC_F_INDIRECT 4 /**< Buffer is list of buffer descriptors */82 83 #define VIRTQ UEUE_USED_F_NO_NOTIFY 1 /**< Dev to Drv: Don't notify when buf added */84 #define VIRTQ UEUE_AVAIL_F_NO_INTERRUPT 1 /**< Drv to Dev: Don't notify when buf eaten */79 #define VIRTQ_DESC_F_NEXT 1 /**< Indicates this descriptor chains to next */ 80 #define VIRTQ_DESC_F_WRITE 2 /**< Marks buffer as write-only (default ro) */ 81 #define VIRTQ_DESC_F_INDIRECT 4 /**< Buffer is list of buffer descriptors */ 82 83 #define VIRTQ_USED_F_NO_NOTIFY 1 /**< Dev to Drv: Don't notify when buf added */ 84 #define VIRTQ_AVAIL_F_NO_INTERRUPT 1 /**< Drv to Dev: Don't notify when buf eaten */ 85 85 /** @} */ 86 86 … … 95 95 uint16_t fFlags; /**< flags Buffer specific flags */ 96 96 uint16_t uDescIdxNext; /**< next Idx set if VIRTIO_DESC_F_NEXT */ 97 } VIRTQ UEUE_DESC_T, *PVIRTQUEUE_DESC_T;97 } VIRTQ_DESC_T, *PVIRTQ_DESC_T; 98 98 99 99 typedef struct virtq_avail … … 103 103 RT_FLEXIBLE_ARRAY_EXTENSION 104 104 uint16_t auRing[RT_FLEXIBLE_ARRAY]; /**< ring Ring: avail drv to dev bufs */ 105 //uint16_t uUsedEventIdx; /**< used_event (if VIRTQ UEUE_USED_F_EVENT_IDX) */106 } VIRTQ UEUE_AVAIL_T, *PVIRTQUEUE_AVAIL_T;105 //uint16_t uUsedEventIdx; /**< used_event (if VIRTQ_USED_F_EVENT_IDX) */ 106 } VIRTQ_AVAIL_T, *PVIRTQ_AVAIL_T; 107 107 108 108 typedef struct virtq_used_elem … … 110 110 uint32_t uDescIdx; /**< idx Start of used desc chain */ 111 111 uint32_t cbElem; /**< len Total len of used desc chain */ 112 } VIRTQ UEUE_USED_ELEM_T;112 } VIRTQ_USED_ELEM_T; 113 113 114 114 typedef struct virt_used … … 117 117 uint16_t uIdx; /**< idx Index of next ring slot */ 118 118 RT_FLEXIBLE_ARRAY_EXTENSION 119 VIRTQ UEUE_USED_ELEM_T aRing[RT_FLEXIBLE_ARRAY]; /**< ring Ring: used dev to drv bufs */120 //uint16_t uAvailEventIdx; /**< avail_event if (VIRTQ UEUE_USED_F_EVENT_IDX) */121 } VIRTQ UEUE_USED_T, *PVIRTQUEUE_USED_T;119 VIRTQ_USED_ELEM_T aRing[RT_FLEXIBLE_ARRAY]; /**< ring Ring: used dev to drv bufs */ 120 //uint16_t uAvailEventIdx; /**< avail_event if (VIRTQ_USED_F_EVENT_IDX) */ 121 } VIRTQ_USED_T, *PVIRTQ_USED_T; 122 122 123 123 … … 147 147 #ifdef IN_RING3 148 148 DECLINLINE(void) virtioReadDesc(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTQUEUE pVirtq, 149 uint32_t idxDesc, PVIRTQ UEUE_DESC_T pDesc)149 uint32_t idxDesc, PVIRTQ_DESC_T pDesc) 150 150 { 151 151 AssertMsg(pVirtio->fDeviceStatus & VIRTIO_STATUS_DRIVER_OK, ("Called with guest driver not ready\n")); … … 153 153 uint16_t const cVirtqItems = RT_MAX(pVirtq->uSize, 1); /* Make sure to avoid div-by-zero. */ 154 154 PDMDevHlpPCIPhysRead(pDevIns, 155 pVirtq->GCPhysVirtqDesc + sizeof(VIRTQ UEUE_DESC_T) * (idxDesc % cVirtqItems),156 pDesc, sizeof(VIRTQ UEUE_DESC_T));155 pVirtq->GCPhysVirtqDesc + sizeof(VIRTQ_DESC_T) * (idxDesc % cVirtqItems), 156 pDesc, sizeof(VIRTQ_DESC_T)); 157 157 } 158 158 #endif … … 169 169 uint16_t const cVirtqItems = RT_MAX(pVirtq->uSize, 1); /* Make sure to avoid div-by-zero. */ 170 170 PDMDevHlpPCIPhysRead(pDevIns, 171 pVirtq->GCPhysVirtqAvail + RT_UOFFSETOF_DYN(VIRTQ UEUE_AVAIL_T, auRing[availIdx % cVirtqItems]),171 pVirtq->GCPhysVirtqAvail + RT_UOFFSETOF_DYN(VIRTQ_AVAIL_T, auRing[availIdx % cVirtqItems]), 172 172 &uDescIdx, sizeof(uDescIdx)); 173 173 return uDescIdx; … … 181 181 RT_NOREF(pVirtio); 182 182 PDMDevHlpPCIPhysRead(pDevIns, 183 pVirtq->GCPhysVirtqAvail + RT_UOFFSETOF_DYN(VIRTQ UEUE_AVAIL_T, auRing[pVirtq->uSize]),183 pVirtq->GCPhysVirtqAvail + RT_UOFFSETOF_DYN(VIRTQ_AVAIL_T, auRing[pVirtq->uSize]), 184 184 &uUsedEventIdx, sizeof(uUsedEventIdx)); 185 185 return uUsedEventIdx; … … 193 193 RT_NOREF(pVirtio); 194 194 PDMDevHlpPCIPhysRead(pDevIns, 195 pVirtq->GCPhysVirtqAvail + RT_UOFFSETOF(VIRTQ UEUE_AVAIL_T, uIdx),195 pVirtq->GCPhysVirtqAvail + RT_UOFFSETOF(VIRTQ_AVAIL_T, uIdx), 196 196 &uIdx, sizeof(uIdx)); 197 197 return uIdx; … … 204 204 RT_NOREF(pVirtio); 205 205 PDMDevHlpPCIPhysRead(pDevIns, 206 pVirtq->GCPhysVirtqAvail + RT_UOFFSETOF(VIRTQ UEUE_AVAIL_T, fFlags),206 pVirtq->GCPhysVirtqAvail + RT_UOFFSETOF(VIRTQ_AVAIL_T, fFlags), 207 207 &fFlags, sizeof(fFlags)); 208 208 return fFlags; … … 219 219 uint32_t usedIdx, uint32_t uDescIdx, uint32_t uLen) 220 220 { 221 VIRTQ UEUE_USED_ELEM_T elem = { uDescIdx, uLen };221 VIRTQ_USED_ELEM_T elem = { uDescIdx, uLen }; 222 222 AssertMsg(pVirtio->fDeviceStatus & VIRTIO_STATUS_DRIVER_OK, ("Called with guest driver not ready\n")); 223 223 RT_NOREF(pVirtio); … … 225 225 PDMDevHlpPCIPhysWrite(pDevIns, 226 226 pVirtq->GCPhysVirtqUsed 227 + RT_UOFFSETOF_DYN(VIRTQ UEUE_USED_T, aRing[usedIdx % cVirtqItems]),227 + RT_UOFFSETOF_DYN(VIRTQ_USED_T, aRing[usedIdx % cVirtqItems]), 228 228 &elem, sizeof(elem)); 229 229 } … … 235 235 RT_UNTRUSTED_VALIDATED_FENCE(); /* VirtIO 1.0, Section 3.2.1.4.1 */ 236 236 PDMDevHlpPCIPhysWrite(pDevIns, 237 pVirtq->GCPhysVirtqUsed + RT_UOFFSETOF(VIRTQ UEUE_USED_T, fFlags),237 pVirtq->GCPhysVirtqUsed + RT_UOFFSETOF(VIRTQ_USED_T, fFlags), 238 238 &fFlags, sizeof(fFlags)); 239 239 } … … 245 245 RT_NOREF(pVirtio); 246 246 PDMDevHlpPCIPhysWrite(pDevIns, 247 pVirtq->GCPhysVirtqUsed + RT_UOFFSETOF(VIRTQ UEUE_USED_T, uIdx),247 pVirtq->GCPhysVirtqUsed + RT_UOFFSETOF(VIRTQ_USED_T, uIdx), 248 248 &uIdx, sizeof(uIdx)); 249 249 } … … 257 257 RT_NOREF(pVirtio); 258 258 PDMDevHlpPCIPhysRead(pDevIns, 259 pVirtq->GCPhysVirtqUsed + RT_UOFFSETOF(VIRTQ UEUE_USED_T, uIdx),259 pVirtq->GCPhysVirtqUsed + RT_UOFFSETOF(VIRTQ_USED_T, uIdx), 260 260 &uIdx, sizeof(uIdx)); 261 261 return uIdx; … … 268 268 RT_NOREF(pVirtio); 269 269 PDMDevHlpPCIPhysRead(pDevIns, 270 pVirtq->GCPhysVirtqUsed + RT_UOFFSETOF(VIRTQ UEUE_USED_T, fFlags),270 pVirtq->GCPhysVirtqUsed + RT_UOFFSETOF(VIRTQ_USED_T, fFlags), 271 271 &fFlags, sizeof(fFlags)); 272 272 return fFlags; … … 280 280 PDMDevHlpPCIPhysWrite(pDevIns, 281 281 pVirtq->GCPhysVirtqUsed 282 + RT_UOFFSETOF_DYN(VIRTQ UEUE_USED_T, aRing[pVirtq->uSize]),282 + RT_UOFFSETOF_DYN(VIRTQ_USED_T, aRing[pVirtq->uSize]), 283 283 &uAvailEventIdx, sizeof(uAvailEventIdx)); 284 284 } … … 325 325 } 326 326 327 328 327 /** @} */ 329 328 … … 458 457 } const s_aFeatures[] = 459 458 { 460 { VIRTIO_F_RING_INDIRECT_DESC, " RING_INDIRECT_DESC Driver can use descriptors with VIRTQ UEUE_DESC_F_INDIRECT flag set\n" },459 { VIRTIO_F_RING_INDIRECT_DESC, " RING_INDIRECT_DESC Driver can use descriptors with VIRTQ_DESC_F_INDIRECT flag set\n" }, 461 460 { VIRTIO_F_RING_EVENT_IDX, " RING_EVENT_IDX Enables use_event and avail_event fields described in 2.4.7, 2.4.8\n" }, 462 461 { VIRTIO_F_VERSION_1, " VERSION Used to detect legacy drivers.\n" }, … … 715 714 } 716 715 717 bool fAvailNoInterrupt = virtioReadAvailRingFlags(pDevIns, pVirtio, pVirtq) & VIRTQ UEUE_AVAIL_F_NO_INTERRUPT;718 bool fUsedNoNotify = virtioReadUsedRingFlags(pDevIns, pVirtio, pVirtq) & VIRTQ UEUE_USED_F_NO_NOTIFY;716 bool fAvailNoInterrupt = virtioReadAvailRingFlags(pDevIns, pVirtio, pVirtq) & VIRTQ_AVAIL_F_NO_INTERRUPT; 717 bool fUsedNoNotify = virtioReadUsedRingFlags(pDevIns, pVirtio, pVirtq) & VIRTQ_USED_F_NO_NOTIFY; 719 718 720 719 … … 801 800 * Gather segments. 802 801 */ 803 VIRTQ UEUE_DESC_T desc;802 VIRTQ_DESC_T desc; 804 803 805 804 uint32_t cbIn = 0; … … 837 836 virtioReadDesc(pDevIns, pVirtio, pVirtq, uDescIdx, &desc); 838 837 839 if (desc.fFlags & VIRTQ UEUE_DESC_F_WRITE)838 if (desc.fFlags & VIRTQ_DESC_F_WRITE) 840 839 { 841 840 Log6Func(("%s IN desc_idx=%u seg=%u addr=%RGp cb=%u\n", pVirtq->szName, uDescIdx, cSegsIn, desc.GCPhysBuf, desc.cb)); … … 859 858 860 859 uDescIdx = desc.uDescIdxNext; 861 } while (desc.fFlags & VIRTQ UEUE_DESC_F_NEXT);860 } while (desc.fFlags & VIRTQ_DESC_F_NEXT); 862 861 863 862 /* … … 935 934 936 935 if (fEnable) 937 fFlags &= ~ VIRTQ UEUE_USED_F_NO_NOTIFY;936 fFlags &= ~ VIRTQ_USED_F_NO_NOTIFY; 938 937 else 939 fFlags |= VIRTQ UEUE_USED_F_NO_NOTIFY;938 fFlags |= VIRTQ_USED_F_NO_NOTIFY; 940 939 941 940 virtioWriteUsedRingFlags(pVirtio->pDevInsR3, pVirtio, pVirtq, fFlags); … … 1199 1198 { 1200 1199 /** If guest driver hasn't suppressed interrupts, interrupt */ 1201 if (!(virtioReadAvailRingFlags(pDevIns, pVirtio, pVirtq) & VIRTQ UEUE_AVAIL_F_NO_INTERRUPT))1200 if (!(virtioReadAvailRingFlags(pDevIns, pVirtio, pVirtq) & VIRTQ_AVAIL_F_NO_INTERRUPT)) 1202 1201 { 1203 1202 virtioKick(pDevIns, pVirtio, VIRTIO_ISR_VIRTQ_INTERRUPT, pVirtq->uMsix); 1204 1203 return; 1205 1204 } 1206 Log6Func(("...skipping interrupt for %s (guest set VIRTQ UEUE_AVAIL_F_NO_INTERRUPT)\n", pVirtq->szName));1205 Log6Func(("...skipping interrupt for %s (guest set VIRTQ_AVAIL_F_NO_INTERRUPT)\n", pVirtq->szName)); 1207 1206 } 1208 1207 }
Note:
See TracChangeset
for help on using the changeset viewer.