InitializeListHead(&pd->SrqList);\r
InitializeListHead(&pd->MwList);\r
InitializeListHead(&pd->AhList);\r
- cl_qmap_init(&pd->MrMap);\r
+ InitializeListHead(&pd->MrList);\r
KeInitializeGuardedMutex(&pd->Lock);\r
\r
ib_status = pDevice->pVerbs->allocate_pd(pDevice->hVerbsDevice, IB_PDT_NORMAL,\r
KeWaitForSingleObject(&pPd->Event, Executive, KernelMode, FALSE, NULL);\r
}\r
\r
- for (item = cl_qmap_head(&pPd->MrMap); item != cl_qmap_end(&pPd->MrMap);\r
- item = cl_qmap_head(&pPd->MrMap)) {\r
- mr = CONTAINING_RECORD(item, WV_MEMORY_REGION, Item);\r
- if (mr->hVerbsMr != NULL) {\r
- pPd->pVerbs->deregister_mr(mr->hVerbsMr);\r
- }\r
+ //for (item = cl_qmap_head(&pPd->MrMap); item != cl_qmap_end(&pPd->MrMap);\r
+ // item = cl_qmap_head(&pPd->MrMap)) {\r
+ // mr = CONTAINING_RECORD(item, WV_MEMORY_REGION, Item);\r
+ // if (mr->hVerbsMr != NULL) {\r
+ // pPd->pVerbs->deregister_mr(mr->hVerbsMr);\r
+ // }\r
\r
- cl_qmap_remove_item(&pPd->MrMap, &mr->Item);\r
- ExFreePoolWithTag(mr, 'rmvw');\r
- }\r
+ // cl_qmap_remove_item(&pPd->MrMap, &mr->Item);\r
+ // ExFreePoolWithTag(mr, 'rmvw');\r
+ //}\r
\r
if (pPd->hVerbsPd != NULL) {\r
pPd->pVerbs->deallocate_pd(pPd->hVerbsPd);\r
ah->hVerbsAh = NULL;\r
}\r
\r
- for (item = cl_qmap_head(&pPd->MrMap); item != cl_qmap_end(&pPd->MrMap);\r
- item = cl_qmap_next(item)) {\r
- mr = CONTAINING_RECORD(item, WV_MEMORY_REGION, Item);\r
+ for (entry = pPd->MrList.Flink; entry != &pPd->MrList; entry = entry->Flink) {\r
+ mr = CONTAINING_RECORD(entry, WV_MEMORY_REGION, Entry);\r
pPd->pVerbs->deregister_mr(mr->hVerbsMr);\r
mr->hVerbsMr = NULL;\r
}\r
goto err2;\r
}\r
\r
+ WvPdGet(pd);\r
+ mr->pPd = pd;\r
+\r
attr.access_ctrl = reg->AccessFlags;\r
attr.length = reg->BufferLength;\r
attr.vaddr = (void *) (ULONG_PTR) reg->Address;\r
goto err3;\r
}\r
\r
- KeAcquireGuardedMutex(&pd->Lock);\r
- cl_qmap_insert(&pd->MrMap, keys->Lkey, &mr->Item);\r
- KeReleaseGuardedMutex(&pd->Lock);\r
+ KeAcquireGuardedMutex(&pProvider->Lock);\r
+ keys->Id = IndexListInsertHead(&pProvider->MrIndex, mr);\r
+ if (keys->Id == 0) {\r
+ status = STATUS_NO_MEMORY;\r
+ goto err4;\r
+ }\r
+ InsertHeadList(&pd->MrList, &mr->Entry);\r
+ KeReleaseGuardedMutex(&pProvider->Lock);\r
\r
WvPdRelease(pd);\r
WdfRequestCompleteWithInformation(Request, status, sizeof(WV_IO_MEMORY_KEYS));\r
return;\r
\r
+err4:\r
+ KeReleaseGuardedMutex(&pProvider->Lock);\r
err3:\r
- ExFreePoolWithTag(mr, 'rmvw');\r
+ WvMrFree(mr);\r
err2:\r
WvPdRelease(pd);\r
err1:\r
\r
void WvMrDeregister(WV_PROVIDER *pProvider, WDFREQUEST Request)\r
{\r
- WV_IO_ID *id;\r
- WV_PROTECTION_DOMAIN *pd;\r
- WV_MEMORY_REGION *mr;\r
- cl_map_item_t *item;\r
- NTSTATUS status;\r
- ib_api_status_t ib_status;\r
+ WV_MEMORY_REGION *mr;\r
+ UINT64 *id;\r
+ NTSTATUS status;\r
\r
- status = WdfRequestRetrieveInputBuffer(Request, sizeof(WV_IO_ID), &id, NULL);\r
+ status = WdfRequestRetrieveInputBuffer(Request, sizeof(UINT64), &id, NULL);\r
if (!NT_SUCCESS(status)) {\r
goto complete;\r
}\r
\r
- pd = WvPdAcquire(pProvider, id->Id);\r
- if (pd == NULL) {\r
+ KeAcquireGuardedMutex(&pProvider->Lock);\r
+ WvProviderDisableRemove(pProvider);\r
+ mr = IndexListAt(&pProvider->MrIndex, (SIZE_T) *id);\r
+ if (mr == NULL) {\r
status = STATUS_NOT_FOUND;\r
- goto complete;\r
+ } else {\r
+ IndexListRemove(&pProvider->MrIndex, (SIZE_T) *id);\r
+ RemoveEntryList(&mr->Entry);\r
+ status = STATUS_SUCCESS;\r
}\r
+ KeReleaseGuardedMutex(&pProvider->Lock);\r
\r
- KeAcquireGuardedMutex(&pd->Lock);\r
- item = cl_qmap_remove(&pd->MrMap, id->Data);\r
- KeReleaseGuardedMutex(&pd->Lock);\r
-\r
- if (item == cl_qmap_end(&pd->MrMap)) {\r
- status = STATUS_NOT_FOUND;\r
- goto release;\r
+ if (NT_SUCCESS(status)) {\r
+ WvMrFree(mr);\r
}\r
+ WvProviderEnableRemove(pProvider);\r
+out:\r
+ WdfRequestComplete(Request, status);\r
+}\r
\r
- mr = CONTAINING_RECORD(item, WV_MEMORY_REGION, Item);\r
-\r
- ib_status = pd->pVerbs->deregister_mr(mr->hVerbsMr);\r
- if (ib_status != IB_SUCCESS) {\r
- status = STATUS_UNSUCCESSFUL;\r
- KeAcquireGuardedMutex(&pd->Lock);\r
- cl_qmap_insert(&pd->MrMap, id->Data, &mr->Item);\r
- KeReleaseGuardedMutex(&pd->Lock);\r
- goto release;\r
+void WvMrFree(WV_MEMORY_REGION *pMr)\r
+{\r
+ if (pMr->hVerbsMr != NULL) {\r
+ pMr->pPd->pVerbs->deregister_mr(pMr->hVerbsMr);\r
}\r
\r
- ExFreePoolWithTag(mr, 'rmvw');\r
-release:\r
- WvPdRelease(pd);\r
-complete:\r
- WdfRequestComplete(Request, status);\r
+ WvPdPut(pMr->pPd);\r
+ ExFreePoolWithTag(pMr, 'rmvw');\r
}\r
\r
void WvMwAllocate(WV_PROVIDER *pProvider, WDFREQUEST Request)\r