diff --git a/DPDPU/Benchmarks/RingBuffer/DPU/Include/RequestBackEnd.h b/DPDPU/Benchmarks/RingBuffer/DPU/Include/RequestBackEnd.h index e542a8d..a07b950 100644 --- a/DPDPU/Benchmarks/RingBuffer/DPU/Include/RequestBackEnd.h +++ b/DPDPU/Benchmarks/RingBuffer/DPU/Include/RequestBackEnd.h @@ -68,16 +68,16 @@ // The global config for (R)DMA // // -struct DMAConfig { +typedef { struct rdma_event_channel *CmChannel; struct rdma_cm_id *CmId; -}; +} DMAConfig; // // The configuration for a control connection // // -struct CtrlConnConfig { +typedef struct { uint32_t CtrlId; uint8_t InUse; @@ -104,13 +104,13 @@ struct CtrlConnConfig { struct ibv_sge SendSgl; struct ibv_mr *SendMr; char SendBuff[CTRL_MSG_SIZE]; -}; +} CtrlConnConfig; // // The configuration for a buffer connection // // -struct BuffConnConfig { +typedef struct { uint32_t BuffId; uint32_t CtrlId; uint8_t InUse; @@ -200,22 +200,22 @@ struct BuffConnConfig { // // struct RequestRingBufferBackEnd RequestRing; -}; +} BuffConnConfig; // // Back end configuration // // -struct BackEndConfig { +typedef struct { uint32_t ServerIp; uint16_t ServerPort; uint32_t MaxClients; uint32_t MaxBuffs; - struct DMAConfig DMAConf; - struct CtrlConnConfig* CtrlConns; - struct BuffConnConfig* BuffConns; + DMAConfig DMAConf; + CtrlConnConfig* CtrlConns; + BuffConnConfig* BuffConns; uint8_t Prefetching; -}; +} BackEndConfig; // // The entry point for the back end diff --git a/DPDPU/Benchmarks/RingBuffer/DPU/Include/ResponseBackEnd.h b/DPDPU/Benchmarks/RingBuffer/DPU/Include/ResponseBackEnd.h index 6e5c715..25dba14 100644 --- a/DPDPU/Benchmarks/RingBuffer/DPU/Include/ResponseBackEnd.h +++ b/DPDPU/Benchmarks/RingBuffer/DPU/Include/ResponseBackEnd.h @@ -45,16 +45,16 @@ // The global config for (R)DMA // // -struct DMAConfig { +typedef struct { struct rdma_event_channel *CmChannel; struct rdma_cm_id *CmId; -}; +} DMAConfig; // // The configuration for a control connection // // -struct CtrlConnConfig { +typedef struct { uint32_t CtrlId; uint8_t InUse; @@ -81,13 +81,13 @@ struct CtrlConnConfig { struct ibv_sge SendSgl; struct ibv_mr *SendMr; char SendBuff[CTRL_MSG_SIZE]; -}; +} CtrlConnConfig; // // The configuration for a buffer connection // // -struct BuffConnConfig { +typedef struct { uint32_t BuffId; uint32_t CtrlId; uint8_t InUse; @@ -147,22 +147,22 @@ struct BuffConnConfig { // // struct ResponseRingBufferBackEnd ResponseRing; -}; +} BuffConnConfig; // // Back end configuration // // -struct BackEndConfig { +typedef struct { uint32_t ServerIp; uint16_t ServerPort; uint32_t MaxClients; uint32_t MaxBuffs; - struct DMAConfig DMAConf; - struct CtrlConnConfig* CtrlConns; - struct BuffConnConfig* BuffConns; + DMAConfig DMAConf; + CtrlConnConfig* CtrlConns; + BuffConnConfig* BuffConns; uint8_t Prefetching; -}; +} BackEndConfig; // // The entry point for the back end diff --git a/DPDPU/Benchmarks/RingBuffer/DPU/Source/RequestBackEnd.c b/DPDPU/Benchmarks/RingBuffer/DPU/Source/RequestBackEnd.c index 82a1b65..78c983b 100644 --- a/DPDPU/Benchmarks/RingBuffer/DPU/Source/RequestBackEnd.c +++ b/DPDPU/Benchmarks/RingBuffer/DPU/Source/RequestBackEnd.c @@ -46,7 +46,7 @@ static int SetNonblocking( // static int InitDMA( - struct DMAConfig* Config, + DMAConfig* Config, uint32_t Ip, uint16_t Port ) { @@ -110,7 +110,7 @@ InitDMA( // static void TermDMA( - struct DMAConfig* Config + DMAConfig* Config ) { if (Config->CmId) { rdma_destroy_id(Config->CmId); @@ -126,24 +126,24 @@ TermDMA( // // static int -AllocConns(struct BackEndConfig* Config) { - Config->CtrlConns = (struct CtrlConnConfig*)malloc(sizeof(struct CtrlConnConfig) * Config->MaxClients); +AllocConns(BackEndConfig* Config) { + Config->CtrlConns = (CtrlConnConfig*)malloc(sizeof(CtrlConnConfig) * Config->MaxClients); if (!Config->CtrlConns) { fprintf(stderr, "Failed to allocate CtrlConns\n"); return ENOMEM; } - memset(Config->CtrlConns, 0, sizeof(struct CtrlConnConfig) * Config->MaxClients); + memset(Config->CtrlConns, 0, sizeof(CtrlConnConfig) * Config->MaxClients); for (int c = 0; c < Config->MaxClients; c++) { Config->CtrlConns[c].CtrlId = c; } - Config->BuffConns = (struct BuffConnConfig*)malloc(sizeof(struct BuffConnConfig) * Config->MaxClients); + Config->BuffConns = (BuffConnConfig*)malloc(sizeof(BuffConnConfig) * Config->MaxClients); if (!Config->BuffConns) { fprintf(stderr, "Failed to allocate BuffConns\n"); free(Config->CtrlConns); return ENOMEM; } - memset(Config->BuffConns, 0, sizeof(struct BuffConnConfig) * Config->MaxClients); + memset(Config->BuffConns, 0, sizeof(BuffConnConfig) * Config->MaxClients); for (int c = 0; c < Config->MaxBuffs; c++) { Config->BuffConns[c].BuffId = c; } @@ -156,7 +156,7 @@ AllocConns(struct BackEndConfig* Config) { // // static void -DeallocConns(struct BackEndConfig* Config) { +DeallocConns(BackEndConfig* Config) { if (Config->CtrlConns) { free(Config->CtrlConns); } @@ -186,7 +186,7 @@ SignalHandler( // static int SetUpCtrlQPair( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { int ret = 0; struct ibv_qp_init_attr initAttr; @@ -264,7 +264,7 @@ SetUpCtrlQPair( // static void DestroyCtrlQPair( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { rdma_destroy_qp(CtrlConn->RemoteCmId); ibv_destroy_cq(CtrlConn->CompQ); @@ -278,7 +278,7 @@ DestroyCtrlQPair( // static int SetUpCtrlRegionsAndBuffers( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { int ret = 0; CtrlConn->RecvMr = ibv_reg_mr( @@ -340,7 +340,7 @@ SetUpCtrlRegionsAndBuffers( // static void DestroyCtrlRegionsAndBuffers( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { ibv_dereg_mr(CtrlConn->SendMr); ibv_dereg_mr(CtrlConn->RecvMr); @@ -356,7 +356,7 @@ DestroyCtrlRegionsAndBuffers( // static int SetUpBuffQPair( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { int ret = 0; struct ibv_qp_init_attr initAttr; @@ -434,7 +434,7 @@ SetUpBuffQPair( // static void DestroyBuffQPair( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { rdma_destroy_qp(BuffConn->RemoteCmId); ibv_destroy_cq(BuffConn->CompQ); @@ -448,7 +448,7 @@ DestroyBuffQPair( // static int SetUpBuffRegionsAndBuffers( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { int ret = 0; @@ -778,7 +778,7 @@ SetUpBuffRegionsAndBuffers( // static void DestroyBuffRegionsAndBuffers( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { ibv_dereg_mr(BuffConn->DMAWriteMetaMr); ibv_dereg_mr(BuffConn->DMAReadMetaMr); @@ -839,7 +839,7 @@ DestroyBuffRegionsAndBuffers( // static int FindConnId( - struct BackEndConfig *Config, + BackEndConfig *Config, struct rdma_cm_id *CmId, uint8_t *IsCtrl ) { @@ -866,7 +866,7 @@ FindConnId( // static int inline ProcessCmEvents( - struct BackEndConfig *Config, + BackEndConfig *Config, struct rdma_cm_event *Event ) { int ret = 0; @@ -902,7 +902,7 @@ ProcessCmEvents( switch (privData) { case CTRL_CONN_PRIV_DATA: { - struct CtrlConnConfig *ctrlConn = NULL; + CtrlConnConfig *ctrlConn = NULL; for (int index = 0; index < Config->MaxClients; index++) { if (!Config->CtrlConns[index].InUse) { @@ -981,7 +981,7 @@ ProcessCmEvents( } case BUFF_CONN_PRIV_DATA: { - struct BuffConnConfig *buffConn = NULL; + BuffConnConfig *buffConn = NULL; int index; for (index = 0; index < Config->MaxClients; index++) { @@ -1109,7 +1109,7 @@ ProcessCmEvents( if (connId >= 0) { if (privData) { if (Config->CtrlConns[connId].InUse) { - struct CtrlConnConfig *ctrlConn = &Config->CtrlConns[connId]; + CtrlConnConfig *ctrlConn = &Config->CtrlConns[connId]; DestroyCtrlRegionsAndBuffers(ctrlConn); DestroyCtrlQPair(ctrlConn); ctrlConn->InUse = 0; @@ -1120,7 +1120,7 @@ ProcessCmEvents( } else { if (Config->BuffConns[connId].InUse) { - struct BuffConnConfig *buffConn = &Config->BuffConns[connId]; + BuffConnConfig *buffConn = &Config->BuffConns[connId]; DestroyBuffRegionsAndBuffers(buffConn); DestroyBuffQPair(buffConn); buffConn->InUse = 0; @@ -1164,7 +1164,7 @@ ProcessCmEvents( // static inline int CtrlMsgHandler( - struct CtrlConnConfig *CtrlConn + CtrlConnConfig *CtrlConn ) { int ret = 0; MsgHeader* msgIn = (MsgHeader*)CtrlConn->RecvBuff; @@ -1231,10 +1231,10 @@ CtrlMsgHandler( // static int inline ProcessCtrlCqEvents( - struct BackEndConfig *Config + BackEndConfig *Config ) { int ret = 0; - struct CtrlConnConfig *ctrlConn = NULL; + CtrlConnConfig *ctrlConn = NULL; struct ibv_wc wc; for (int i = 0; i != Config->MaxClients; i++) { @@ -1287,7 +1287,7 @@ ProcessCtrlCqEvents( // static inline int BuffMsgHandler( - struct BuffConnConfig *BuffConn + BuffConnConfig *BuffConn ) { int ret = 0; MsgHeader* msgIn = (MsgHeader*)BuffConn->RecvBuff; @@ -1447,10 +1447,10 @@ BuffMsgHandler( // static int inline ProcessBuffCqEvents( - struct BackEndConfig *Config + BackEndConfig *Config ) { int ret = 0; - struct BuffConnConfig *buffConn = NULL; + BuffConnConfig *buffConn = NULL; struct ibv_send_wr *badSendWr = NULL; struct ibv_wc wc; @@ -2208,7 +2208,7 @@ int RunBenchmarkRequestBackEnd( const uint32_t MaxBuffs, const uint8_t Prefetching ) { - struct BackEndConfig config; + BackEndConfig config; struct rdma_cm_event *event; int ret = 0; diff --git a/DPDPU/Benchmarks/RingBuffer/DPU/Source/ResponseBackEnd.c b/DPDPU/Benchmarks/RingBuffer/DPU/Source/ResponseBackEnd.c index 396f89f..d3e150c 100644 --- a/DPDPU/Benchmarks/RingBuffer/DPU/Source/ResponseBackEnd.c +++ b/DPDPU/Benchmarks/RingBuffer/DPU/Source/ResponseBackEnd.c @@ -67,7 +67,7 @@ static int SetNonblocking( // static int InitDMA( - struct DMAConfig* Config, + DMAConfig* Config, uint32_t Ip, uint16_t Port ) { @@ -131,7 +131,7 @@ InitDMA( // static void TermDMA( - struct DMAConfig* Config + DMAConfig* Config ) { if (Config->CmId) { rdma_destroy_id(Config->CmId); @@ -147,24 +147,24 @@ TermDMA( // // static int -AllocConns(struct BackEndConfig* Config) { - Config->CtrlConns = (struct CtrlConnConfig*)malloc(sizeof(struct CtrlConnConfig) * Config->MaxClients); +AllocConns(BackEndConfig* Config) { + Config->CtrlConns = (CtrlConnConfig*)malloc(sizeof(CtrlConnConfig) * Config->MaxClients); if (!Config->CtrlConns) { fprintf(stderr, "Failed to allocate CtrlConns\n"); return ENOMEM; } - memset(Config->CtrlConns, 0, sizeof(struct CtrlConnConfig) * Config->MaxClients); + memset(Config->CtrlConns, 0, sizeof(CtrlConnConfig) * Config->MaxClients); for (int c = 0; c < Config->MaxClients; c++) { Config->CtrlConns[c].CtrlId = c; } - Config->BuffConns = (struct BuffConnConfig*)malloc(sizeof(struct BuffConnConfig) * Config->MaxClients); + Config->BuffConns = (BuffConnConfig*)malloc(sizeof(BuffConnConfig) * Config->MaxClients); if (!Config->BuffConns) { fprintf(stderr, "Failed to allocate BuffConns\n"); free(Config->CtrlConns); return ENOMEM; } - memset(Config->BuffConns, 0, sizeof(struct BuffConnConfig) * Config->MaxClients); + memset(Config->BuffConns, 0, sizeof(BuffConnConfig) * Config->MaxClients); for (int c = 0; c < Config->MaxBuffs; c++) { Config->BuffConns[c].BuffId = c; } @@ -177,7 +177,7 @@ AllocConns(struct BackEndConfig* Config) { // // static void -DeallocConns(struct BackEndConfig* Config) { +DeallocConns(BackEndConfig* Config) { if (Config->CtrlConns) { free(Config->CtrlConns); } @@ -207,7 +207,7 @@ SignalHandler( // static int SetUpCtrlQPair( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { int ret = 0; struct ibv_qp_init_attr initAttr; @@ -285,7 +285,7 @@ SetUpCtrlQPair( // static void DestroyCtrlQPair( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { rdma_destroy_qp(CtrlConn->RemoteCmId); ibv_destroy_cq(CtrlConn->CompQ); @@ -299,7 +299,7 @@ DestroyCtrlQPair( // static int SetUpCtrlRegionsAndBuffers( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { int ret = 0; CtrlConn->RecvMr = ibv_reg_mr( @@ -361,7 +361,7 @@ SetUpCtrlRegionsAndBuffers( // static void DestroyCtrlRegionsAndBuffers( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { ibv_dereg_mr(CtrlConn->SendMr); ibv_dereg_mr(CtrlConn->RecvMr); @@ -377,7 +377,7 @@ DestroyCtrlRegionsAndBuffers( // static int SetUpBuffQPair( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { int ret = 0; struct ibv_qp_init_attr initAttr; @@ -455,7 +455,7 @@ SetUpBuffQPair( // static void DestroyBuffQPair( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { rdma_destroy_qp(BuffConn->RemoteCmId); ibv_destroy_cq(BuffConn->CompQ); @@ -469,7 +469,7 @@ DestroyBuffQPair( // static int SetUpBuffRegionsAndBuffers( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { int ret = 0; @@ -643,7 +643,7 @@ SetUpBuffRegionsAndBuffers( // static void DestroyBuffRegionsAndBuffers( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { ibv_dereg_mr(BuffConn->DMAWriteMetaMr); ibv_dereg_mr(BuffConn->DMAReadMetaMr); @@ -674,7 +674,7 @@ DestroyBuffRegionsAndBuffers( // static int FindConnId( - struct BackEndConfig *Config, + BackEndConfig *Config, struct rdma_cm_id *CmId, uint8_t *IsCtrl ) { @@ -701,7 +701,7 @@ FindConnId( // static int inline ProcessCmEvents( - struct BackEndConfig *Config, + BackEndConfig *Config, struct rdma_cm_event *Event ) { int ret = 0; @@ -737,7 +737,7 @@ ProcessCmEvents( switch (privData) { case CTRL_CONN_PRIV_DATA: { - struct CtrlConnConfig *ctrlConn = NULL; + CtrlConnConfig *ctrlConn = NULL; for (int index = 0; index < Config->MaxClients; index++) { if (!Config->CtrlConns[index].InUse) { @@ -816,7 +816,7 @@ ProcessCmEvents( } case BUFF_CONN_PRIV_DATA: { - struct BuffConnConfig *buffConn = NULL; + BuffConnConfig *buffConn = NULL; int index; for (index = 0; index < Config->MaxClients; index++) { @@ -944,7 +944,7 @@ ProcessCmEvents( if (connId >= 0) { if (privData) { if (Config->CtrlConns[connId].InUse) { - struct CtrlConnConfig *ctrlConn = &Config->CtrlConns[connId]; + CtrlConnConfig *ctrlConn = &Config->CtrlConns[connId]; DestroyCtrlRegionsAndBuffers(ctrlConn); DestroyCtrlQPair(ctrlConn); ctrlConn->InUse = 0; @@ -955,7 +955,7 @@ ProcessCmEvents( } else { if (Config->BuffConns[connId].InUse) { - struct BuffConnConfig *buffConn = &Config->BuffConns[connId]; + BuffConnConfig *buffConn = &Config->BuffConns[connId]; DestroyBuffRegionsAndBuffers(buffConn); DestroyBuffQPair(buffConn); buffConn->InUse = 0; @@ -999,7 +999,7 @@ ProcessCmEvents( // static inline int CtrlMsgHandler( - struct CtrlConnConfig *CtrlConn + CtrlConnConfig *CtrlConn ) { int ret = 0; MsgHeader* msgIn = (MsgHeader*)CtrlConn->RecvBuff; @@ -1066,10 +1066,10 @@ CtrlMsgHandler( // static int inline ProcessCtrlCqEvents( - struct BackEndConfig *Config + BackEndConfig *Config ) { int ret = 0; - struct CtrlConnConfig *ctrlConn = NULL; + CtrlConnConfig *ctrlConn = NULL; struct ibv_wc wc; for (int i = 0; i != Config->MaxClients; i++) { @@ -1122,7 +1122,7 @@ ProcessCtrlCqEvents( // static inline int BuffMsgHandler( - struct BuffConnConfig *BuffConn + BuffConnConfig *BuffConn ) { int ret = 0; MsgHeader* msgIn = (MsgHeader*)BuffConn->RecvBuff; @@ -1243,10 +1243,10 @@ BuffMsgHandler( // static int inline ProcessBuffCqEvents( - struct BackEndConfig *Config + BackEndConfig *Config ) { int ret = 0; - struct BuffConnConfig *buffConn = NULL; + BuffConnConfig *buffConn = NULL; struct ibv_send_wr *badSendWr = NULL; struct ibv_wc wc; @@ -1593,7 +1593,7 @@ int RunBenchmarkResponseBackEnd( const uint32_t MaxBuffs, const uint8_t Prefetching ) { - struct BackEndConfig config; + BackEndConfig config; struct rdma_cm_event *event; int ret = 0; diff --git a/DPDPU/Common/Include/DPU/DDSBackEndTypes.h b/DPDPU/Common/Include/DPU/BackEndTypes.h similarity index 59% rename from DPDPU/Common/Include/DPU/DDSBackEndTypes.h rename to DPDPU/Common/Include/DPU/BackEndTypes.h index 72b0523..922c8a1 100644 --- a/DPDPU/Common/Include/DPU/DDSBackEndTypes.h +++ b/DPDPU/Common/Include/DPU/BackEndTypes.h @@ -4,7 +4,7 @@ #include "MsgTypes.h" // -// Context for a pending data plane request +// Context for a pending data plane request from the host // // typedef struct { @@ -23,12 +23,6 @@ typedef struct { BufferT Response; } ControlPlaneRequestContext; -typedef struct { - RequestIdT RequestId; - ErrorCodeT Result; - FileIOSizeT BytesServiced; -} B2BAckHeader; - // // Check a few parameters at the compile time // @@ -44,12 +38,11 @@ typedef struct { #pragma warning (disable: 4804) #endif // -// Ring space is allocated at the |size of a request/response| + |header size| -// The alignment is enforced once a request/response is inserted into the ring +// Ring space is allocated at the |size of a response| + |header size| +// The alignment is enforced once a response is inserted into the ring // // -AssertStaticBackEndTypes(DDS_INTRA_BACKEND_REQUEST_RING_BYTES % sizeof(DataPlaneRequestContext) == 0, 0); -AssertStaticBackEndTypes(DDS_RESPONSE_RING_BYTES % (sizeof(B2BAckHeader) + sizeof(FileIOSizeT)) == 0, 1); +AssertStaticBackEndTypes(OFFLOAD_RESPONSE_RING_BYTES % (sizeof(OffloadWorkResponse) + sizeof(FileIOSizeT)) == 0, 0); #ifdef __GNUC__ #pragma GCC diagnostic pop #else diff --git a/DPDPU/Common/Include/DPU/FileService.h b/DPDPU/Common/Include/DPU/FileService.h new file mode 100644 index 0000000..67b0b7d --- /dev/null +++ b/DPDPU/Common/Include/DPU/FileService.h @@ -0,0 +1,69 @@ +#pragma once + +#include "BackEndTypes.h" + +// +// File service running on the DPU +// +// +typedef struct { + // + // TODO: necessary state of the SPDK file service + // + // + int Dummy; +} FileService; + +// +// Allocate the file service object +// +// +FileService* +AllocateFileService(); + +// +// Start the file service +// +// +void +StartFileService( + FileService* FS +); + +// +// Stop the file service +// +// +void +StopFileService( + FileService* FS +); + +// +// Deallocate the file service object +// +// +void +DeallocateFileService( + FileService* FS +); + +// +// Send a control plane request to the file service +// +// +void +SubmitControlPlaneRequest( + FileService* FS, + ControlPlaneRequestContext* Context +); + +// +// Send a data plane request to the file service +// +// +void +SubmitDataPlaneRequest( + FileService* FS, + DataPlaneRequestContext* Context +); \ No newline at end of file diff --git a/DPDPU/Common/Include/DPU/FileServiceInterface.h b/DPDPU/Common/Include/DPU/FileServiceInterface.h deleted file mode 100644 index 44705f1..0000000 --- a/DPDPU/Common/Include/DPU/FileServiceInterface.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "RequestRingBuffer.h" \ No newline at end of file diff --git a/DPDPU/Common/Include/DPU/ResponseRingBuffer.h b/DPDPU/Common/Include/DPU/OffloadResponseRingBuffer.h similarity index 53% rename from DPDPU/Common/Include/DPU/ResponseRingBuffer.h rename to DPDPU/Common/Include/DPU/OffloadResponseRingBuffer.h index 3442e7c..9ad5635 100644 --- a/DPDPU/Common/Include/DPU/ResponseRingBuffer.h +++ b/DPDPU/Common/Include/DPU/OffloadResponseRingBuffer.h @@ -1,6 +1,6 @@ #pragma once -#include "DDSBackEndTypes.h" +#include "BackEndTypes.h" #include "Protocol.h" // @@ -10,25 +10,25 @@ // Tail[2] - TailC // // -struct ResponseRingBuffer{ +typedef struct { int Tail[DDS_CACHE_LINE_SIZE_BY_INT]; - char Buffer[DDS_INTRA_BACKEND_RESPONSE_RING_BYTES]; -}; + char Buffer[OFFLOAD_RESPONSE_RING_BYTES]; +} OffloadResponseRingBuffer; // // Allocate a response buffer object // // -ResponseRingBuffer* -AllocateResponseBuffer( +OffloadResponseRingBuffer* +AllocateOffloadResponseBuffer( BufferT BufferAddress ); // -// Deallocate a response buffer object +// Deallocate a response queue buffer object // // void -DeallocateResponseBuffer( - ResponseRingBuffer* RingBuffer +DellocateOffloadResponseBuffer( + OffloadResponseRingBuffer* RingBuffer ); \ No newline at end of file diff --git a/DPDPU/Common/Include/DPU/RequestRingBuffer.h b/DPDPU/Common/Include/DPU/RequestRingBuffer.h deleted file mode 100644 index 538b567..0000000 --- a/DPDPU/Common/Include/DPU/RequestRingBuffer.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - -#include - -#include "DDSBackEndTypes.h" -#include "Protocol.h" - -// -// A ring buffer for exchanging requests between DPU threads -// -// -struct RequestRingBuffer{ - _Atomic int Progress[DDS_CACHE_LINE_SIZE_BY_INT]; - _Atomic int Tail[DDS_CACHE_LINE_SIZE_BY_INT]; - int Head[DDS_CACHE_LINE_SIZE_BY_INT]; - char Buffer[DDS_REQUEST_RING_BYTES]; -}; - -// -// Allocate a request buffer object -// -// -RequestRingBuffer* -AllocateRequestBuffer( - BufferT BufferAddress -); - -// -// Deallocate a request buffer object -// -// -void -DeallocateRequestBuffer( - RequestRingBuffer* RingBuffer -); - -// -// Insert a data-plane request into the request buffer -// Data-plane requests only -// -// -uint8_t -InsertRequest( - RequestRingBuffer* RingBuffer, - BuffMsgF2BReqHeader* Request, - BuffMsgB2FAckHeader* Response, - SplittableBufferT* DataBuffer -); - -// -// Fetch requests from the request buffer -// -// -uint8_t -FetchRequests( - RequestRingBuffer* RingBuffer, - SplittableBufferT* RequestBatch -); - -// -// Increment the progress -// -// -void -IncrementProgress( - RequestRingBuffer* RingBuffer, - FileIOSizeT TotalBytes -); \ No newline at end of file diff --git a/DPDPU/Common/Include/MsgTypes.h b/DPDPU/Common/Include/MsgTypes.h index c93d93c..1b71e49 100644 --- a/DPDPU/Common/Include/MsgTypes.h +++ b/DPDPU/Common/Include/MsgTypes.h @@ -177,6 +177,9 @@ typedef struct { FileIOSizeT BytesServiced; } BuffMsgB2FAckHeader; +typedef BuffMsgF2BReqHeader OffloadWorkRequest; +typedef BuffMsgB2FAckHeader OffloadWorkResponse; + // // Check a few parameters at the compile time // diff --git a/DPDPU/Common/Include/Protocol.h b/DPDPU/Common/Include/Protocol.h index 2861f44..b34022c 100644 --- a/DPDPU/Common/Include/Protocol.h +++ b/DPDPU/Common/Include/Protocol.h @@ -69,8 +69,7 @@ #define DDS_NOTIFICATION_METHOD_TIMER 1 #define DDS_NOTIFICATION_METHOD DDS_NOTIFICATION_METHOD_INTERRUPT -#define DDS_INTRA_BACKEND_REQUEST_RING_BYTES 25165824 -#define DDS_INTRA_BACKEND_RESPONSE_RING_BYTES 25165824 +#define OFFLOAD_RESPONSE_RING_BYTES 251658240 // // Check a few parameters at the compile time diff --git a/DPDPU/Common/Source/DPU/FileService.c b/DPDPU/Common/Source/DPU/FileService.c new file mode 100644 index 0000000..4285f1a --- /dev/null +++ b/DPDPU/Common/Source/DPU/FileService.c @@ -0,0 +1,79 @@ +#include + +#include "FileService.h" + +#undef DEBUG_FILE_SERVICE +#ifdef DEBUG_FILE_SERVICE +#include +#define DebugPrint(Fmt, ...) fprintf(stderr, Fmt, __VA_ARGS__) +#else +static inline void DebugPrint(const char* Fmt, ...) { } +#endif + +// +// Allocate the file service object +// +// +FileService* +AllocateFileService() { + DebugPrint("Allocating the file service object...\n"); + return (FileService*)malloc(sizeof(FileService)); +} + +// +// Start the file service +// +// +void +StartFileService( + FileService* FS +) { + DebugPrint("File service started\n"); +} + +// +// Stop the file service +// +// +void +StopFileService( + FileService* FS +) { + DebugPrint("File service stopped\n"); +} + +// +// Deallocate the file service object +// +// +void +DeallocateFileService( + FileService* FS +) { + free(FS); + DebugPrint("File service object deallocated\n"); +} + +// +// Send a control plane request to the file service +// +// +void +SubmitControlPlaneRequest( + FileService* FS, + ControlPlaneRequestContext* Context +) { + DebugPrint("Submitting a control plane request\n"); +} + +// +// Send a data plane request to the file service +// +// +void +SubmitDataPlaneRequest( + FileService* FS, + DataPlaneRequestContext* Context +) { + DebugPrint("Submitting a data plane request\n"); +} \ No newline at end of file diff --git a/DPDPU/Common/Source/DPU/OffloadResponseRingBuffer.c b/DPDPU/Common/Source/DPU/OffloadResponseRingBuffer.c new file mode 100644 index 0000000..b726fa8 --- /dev/null +++ b/DPDPU/Common/Source/DPU/OffloadResponseRingBuffer.c @@ -0,0 +1,37 @@ +#include + +#include "OffloadResponseRingBuffer.h" + +// +// Allocate a response buffer object +// +// +OffloadResponseRingBuffer* +AllocateOffloadResponseBuffer( + BufferT BufferAddress +) { + OffloadResponseRingBuffer* ringBuffer = (OffloadResponseRingBuffer*)BufferAddress; + + // + // Align the buffer by cache line size + // + // + size_t ringBufferAddress = (size_t)ringBuffer; + while (ringBufferAddress % DDS_CACHE_LINE_SIZE != 0) { + ringBufferAddress++; + } + ringBuffer = (OffloadResponseRingBuffer*)ringBufferAddress; + + return ringBuffer; +} + +// +// Deallocate a response queue buffer object +// +// +void +DellocateOffloadResponseBuffer( + OffloadResponseRingBuffer* RingBuffer +) { + memset(RingBuffer, 0, sizeof(OffloadResponseRingBuffer)); +} \ No newline at end of file diff --git a/DPDPU/StorageEngine/DDSBackEndDPUService/Include/ControlPlaneHandler.h b/DPDPU/StorageEngine/DDSBackEndDPUService/Include/ControlPlaneHandler.h deleted file mode 100644 index fe130b9..0000000 --- a/DPDPU/StorageEngine/DDSBackEndDPUService/Include/ControlPlaneHandler.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include "FileBackEndTypes.h" -#include "MsgTypes.h" - -// -// Handler for a control plane request -// -// -void ControlPlaneHandler( - ControlPlaneRequestContext *Context -); \ No newline at end of file diff --git a/DPDPU/StorageEngine/DDSBackEndDPUService/Include/DataPlaneHandlers.h b/DPDPU/StorageEngine/DDSBackEndDPUService/Include/DataPlaneHandlers.h deleted file mode 100644 index 9b320ea..0000000 --- a/DPDPU/StorageEngine/DDSBackEndDPUService/Include/DataPlaneHandlers.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include "MsgTypes.h" - -// -// Handler for a read request -// -// -void ReadHandler( - BuffMsgF2BReqHeader* Req, - BuffMsgB2FAckHeader* Resp, - SplittableBufferT* DestBuffer -); - -// -// Handler for a write request -// -// -void WriteHandler( - BuffMsgF2BReqHeader* Req, - BuffMsgB2FAckHeader* Resp, - SplittableBufferT* SourceBuffer -); diff --git a/DPDPU/StorageEngine/DDSBackEndDPUService/Include/FileBackEnd.h b/DPDPU/StorageEngine/DDSBackEndDPUService/Include/FileBackEnd.h index 8a24551..2903c13 100644 --- a/DPDPU/StorageEngine/DDSBackEndDPUService/Include/FileBackEnd.h +++ b/DPDPU/StorageEngine/DDSBackEndDPUService/Include/FileBackEnd.h @@ -6,7 +6,8 @@ #include #include -#include "DDSBackEndTypes.h" +#include "BackEndTypes.h" +#include "FileService.h" #include "MsgTypes.h" #include "Protocol.h" #include "RingBufferPolling.h" @@ -53,16 +54,16 @@ // The global config for (R)DMA // // -struct DMAConfig { +typedef struct { struct rdma_event_channel *CmChannel; struct rdma_cm_id *CmId; -}; +} DMAConfig; // // The configuration for a control connection // // -struct CtrlConnConfig { +typedef struct { uint32_t CtrlId; uint8_t State; @@ -95,13 +96,13 @@ struct CtrlConnConfig { // // ControlPlaneRequestContext PendingControlPlanRequest; -}; +} CtrlConnConfig; // // The configuration for a buffer connection // // -struct BuffConnConfig { +typedef struct { uint32_t BuffId; uint32_t CtrlId; uint8_t State; @@ -178,21 +179,23 @@ struct BuffConnConfig { // struct RequestRingBufferBackEnd RequestRing; struct ResponseRingBufferBackEnd ResponseRing; -}; +} BuffConnConfig; // // Back end configuration // // -struct BackEndConfig { +typedef struct { uint32_t ServerIp; uint16_t ServerPort; uint32_t MaxClients; uint32_t MaxBuffs; - struct DMAConfig DMAConf; - struct CtrlConnConfig* CtrlConns; - struct BuffConnConfig* BuffConns; -}; + DMAConfig DMAConf; + CtrlConnConfig* CtrlConns; + BuffConnConfig* BuffConns; + + FileService* FS; +} BackEndConfig; // // The entry point for the back end diff --git a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/ControlPlaneHandlers.c b/DPDPU/StorageEngine/DDSBackEndDPUService/Source/ControlPlaneHandlers.c deleted file mode 100644 index 63ac8e1..0000000 --- a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/ControlPlaneHandlers.c +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - -#include "ControlPlaneHandler.h" - -// -// Handler for a control plane request -// -// -void ControlPlaneHandler( - ControlPlaneRequestContext *Context -) { - // - // TODO: send this request to the file service - // Upon completion, set Context->Response->Result as DDS_ERROR_CODE_SUCCESS - // - // - printf("Executing a control plane request: %u\n", Context->RequestId); -} \ No newline at end of file diff --git a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/DataPlaneHandlers.c b/DPDPU/StorageEngine/DDSBackEndDPUService/Source/DataPlaneHandlers.c deleted file mode 100644 index a9f0dd8..0000000 --- a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/DataPlaneHandlers.c +++ /dev/null @@ -1,43 +0,0 @@ -#include "DataPlaneHandlers.h" - -#undef DEBUG_DATAPLANE_HANDLERS -#ifdef DEBUG_DATAPLANE_HANDLERS -#include -#define DebugPrint(Fmt, ...) fprintf(stderr, Fmt, __VA_ARGS__) -#else -static inline void DebugPrint(const char* Fmt, ...) { } -#endif - -// -// Handler for a read request -// -// -void ReadHandler( - BuffMsgF2BReqHeader* Req, - BuffMsgB2FAckHeader* Resp, - SplittableBufferT* DestBuffer -) { - DebugPrint("Executing a read request: %u@%lu#%u\n", Req->FileId, Req->Offset, Req->Bytes); - - // - // TODO: Execute the read asynchronously - // - // -} - -// -// Handler for a write request -// -// -void WriteHandler( - BuffMsgF2BReqHeader* Req, - BuffMsgB2FAckHeader* Resp, - SplittableBufferT* SourceBuffer -) { - DebugPrint("Executing a write request: %u@%lu#%u\n", Req->FileId, Req->Offset, Req->Bytes); - - // - // TODO: Execute the write asynchronously - // - // -} diff --git a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/FileBackEnd.c b/DPDPU/StorageEngine/DDSBackEndDPUService/Source/FileBackEnd.c index 01e2de5..e8fb7b9 100644 --- a/DPDPU/StorageEngine/DDSBackEndDPUService/Source/FileBackEnd.c +++ b/DPDPU/StorageEngine/DDSBackEndDPUService/Source/FileBackEnd.c @@ -55,7 +55,7 @@ int SetNonblocking( // static int InitDMA( - struct DMAConfig* Config, + DMAConfig* Config, uint32_t Ip, uint16_t Port ) { @@ -119,7 +119,7 @@ InitDMA( // static void TermDMA( - struct DMAConfig* Config + DMAConfig* Config ) { if (Config->CmId) { rdma_destroy_id(Config->CmId); @@ -135,13 +135,13 @@ TermDMA( // // static int -AllocConns(struct BackEndConfig* Config) { - Config->CtrlConns = (struct CtrlConnConfig*)malloc(sizeof(struct CtrlConnConfig) * Config->MaxClients); +AllocConns(BackEndConfig* Config) { + Config->CtrlConns = (CtrlConnConfig*)malloc(sizeof(CtrlConnConfig) * Config->MaxClients); if (!Config->CtrlConns) { fprintf(stderr, "Failed to allocate CtrlConns\n"); return ENOMEM; } - memset(Config->CtrlConns, 0, sizeof(struct CtrlConnConfig) * Config->MaxClients); + memset(Config->CtrlConns, 0, sizeof(CtrlConnConfig) * Config->MaxClients); for (int c = 0; c < Config->MaxClients; c++) { Config->CtrlConns[c].CtrlId = c; @@ -154,13 +154,13 @@ AllocConns(struct BackEndConfig* Config) { Config->CtrlConns[c].PendingControlPlanRequest.Response = NULL; } - Config->BuffConns = (struct BuffConnConfig*)malloc(sizeof(struct BuffConnConfig) * Config->MaxClients); + Config->BuffConns = (BuffConnConfig*)malloc(sizeof(BuffConnConfig) * Config->MaxClients); if (!Config->BuffConns) { fprintf(stderr, "Failed to allocate BuffConns\n"); free(Config->CtrlConns); return ENOMEM; } - memset(Config->BuffConns, 0, sizeof(struct BuffConnConfig) * Config->MaxClients); + memset(Config->BuffConns, 0, sizeof(BuffConnConfig) * Config->MaxClients); for (int c = 0; c < Config->MaxBuffs; c++) { Config->BuffConns[c].BuffId = c; } @@ -173,7 +173,7 @@ AllocConns(struct BackEndConfig* Config) { // // static void -DeallocConns(struct BackEndConfig* Config) { +DeallocConns(BackEndConfig* Config) { if (Config->CtrlConns) { free(Config->CtrlConns); } @@ -203,7 +203,7 @@ SignalHandler( // static int SetUpCtrlQPair( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { int ret = 0; struct ibv_qp_init_attr initAttr; @@ -281,7 +281,7 @@ SetUpCtrlQPair( // static void DestroyCtrlQPair( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { rdma_destroy_qp(CtrlConn->RemoteCmId); ibv_destroy_cq(CtrlConn->CompQ); @@ -295,7 +295,7 @@ DestroyCtrlQPair( // static int SetUpCtrlRegionsAndBuffers( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { int ret = 0; CtrlConn->RecvMr = ibv_reg_mr( @@ -357,7 +357,7 @@ SetUpCtrlRegionsAndBuffers( // static void DestroyCtrlRegionsAndBuffers( - struct CtrlConnConfig* CtrlConn + CtrlConnConfig* CtrlConn ) { ibv_dereg_mr(CtrlConn->SendMr); ibv_dereg_mr(CtrlConn->RecvMr); @@ -373,7 +373,7 @@ DestroyCtrlRegionsAndBuffers( // static int SetUpBuffQPair( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { int ret = 0; struct ibv_qp_init_attr initAttr; @@ -451,7 +451,7 @@ SetUpBuffQPair( // static void DestroyBuffQPair( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { rdma_destroy_qp(BuffConn->RemoteCmId); ibv_destroy_cq(BuffConn->CompQ); @@ -465,7 +465,7 @@ DestroyBuffQPair( // static int SetUpForCtrlMsgs( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { int ret = 0; @@ -536,7 +536,7 @@ SetUpForCtrlMsgs( // static void DestroyForCtrlMsgs( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { ibv_dereg_mr(BuffConn->SendMr); ibv_dereg_mr(BuffConn->RecvMr); @@ -552,7 +552,7 @@ DestroyForCtrlMsgs( // static int SetUpForRequests( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { int ret = 0; @@ -673,7 +673,7 @@ SetUpForRequests( // static void DestroyForRequests( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { free(BuffConn->RequestDMAReadDataBuff); @@ -700,7 +700,7 @@ DestroyForRequests( // static int SetUpForResponses( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { int ret = 0; @@ -825,7 +825,7 @@ SetUpForResponses( // static void DestroyForResponses( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { free(BuffConn->ResponseDMAWriteDataBuff); @@ -852,7 +852,7 @@ DestroyForResponses( // static int SetUpBuffRegionsAndBuffers( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { int ret = 0; @@ -904,7 +904,7 @@ SetUpBuffRegionsAndBuffers( // static void DestroyBuffRegionsAndBuffers( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn ) { DestroyForCtrlMsgs(BuffConn); DestroyForRequests(BuffConn); @@ -917,7 +917,7 @@ DestroyBuffRegionsAndBuffers( // static int FindConnId( - struct BackEndConfig *Config, + BackEndConfig *Config, struct rdma_cm_id *CmId, uint8_t *IsCtrl ) { @@ -944,7 +944,7 @@ FindConnId( // static inline int ProcessCmEvents( - struct BackEndConfig *Config, + BackEndConfig *Config, struct rdma_cm_event *Event ) { int ret = 0; @@ -980,7 +980,7 @@ ProcessCmEvents( switch (privData) { case CTRL_CONN_PRIV_DATA: { - struct CtrlConnConfig *ctrlConn = NULL; + CtrlConnConfig *ctrlConn = NULL; for (int index = 0; index < Config->MaxClients; index++) { if (Config->CtrlConns[index].State == CONN_STATE_AVAILABLE) { @@ -1059,7 +1059,7 @@ ProcessCmEvents( } case BUFF_CONN_PRIV_DATA: { - struct BuffConnConfig *buffConn = NULL; + BuffConnConfig *buffConn = NULL; int index; for (index = 0; index < Config->MaxClients; index++) { @@ -1154,7 +1154,7 @@ ProcessCmEvents( if (isCtrl) { #ifdef DDS_STORAGE_FILE_BACKEND_VERBOSE fprintf(stdout, "CM: RDMA_CM_EVENT_ESTABLISHED for Control Conn#%d\n", connId); - struct CtrlConnConfig* ctrlConn = &Config->CtrlConns[connId]; + CtrlConnConfig* ctrlConn = &Config->CtrlConns[connId]; ctrlConn->State = CONN_STATE_CONNECTED; #endif } @@ -1162,7 +1162,7 @@ ProcessCmEvents( { #ifdef DDS_STORAGE_FILE_BACKEND_VERBOSE fprintf(stdout, "CM: RDMA_CM_EVENT_ESTABLISHED for Buffer Conn#%d\n", connId); - struct BuffConnConfig* buffConn = &Config->BuffConns[connId]; + BuffConnConfig* buffConn = &Config->BuffConns[connId]; buffConn->State = CONN_STATE_CONNECTED; } #endif @@ -1195,7 +1195,7 @@ ProcessCmEvents( if (connId >= 0) { if (isCtrl) { if (Config->CtrlConns[connId].State != CONN_STATE_AVAILABLE) { - struct CtrlConnConfig *ctrlConn = &Config->CtrlConns[connId]; + CtrlConnConfig *ctrlConn = &Config->CtrlConns[connId]; DestroyCtrlRegionsAndBuffers(ctrlConn); DestroyCtrlQPair(ctrlConn); ctrlConn->State = CONN_STATE_AVAILABLE; @@ -1206,7 +1206,7 @@ ProcessCmEvents( } else { if (Config->BuffConns[connId].State != CONN_STATE_AVAILABLE) { - struct BuffConnConfig *buffConn = &Config->BuffConns[connId]; + BuffConnConfig *buffConn = &Config->BuffConns[connId]; DestroyBuffRegionsAndBuffers(buffConn); DestroyBuffQPair(buffConn); buffConn->State = CONN_STATE_AVAILABLE; @@ -1250,7 +1250,8 @@ ProcessCmEvents( // static inline int CtrlMsgHandler( - struct CtrlConnConfig *CtrlConn + CtrlConnConfig *CtrlConn, + FileService* FS ) { int ret = 0; MsgHeader* msgIn = (MsgHeader*)CtrlConn->RecvBuff; @@ -1337,7 +1338,8 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) + msgOut->MsgId = CTRL_MSG_B2F_ACK_CREATE_DIR; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckCreateDirectory); @@ -1370,7 +1372,7 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) msgOut->MsgId = CTRL_MSG_B2F_ACK_REMOVE_DIR; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckRemoveDirectory); @@ -1403,7 +1405,7 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) msgOut->MsgId = CTRL_MSG_B2F_ACK_CREATE_FILE; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckCreateFile); @@ -1436,7 +1438,7 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) msgOut->MsgId = CTRL_MSG_B2F_ACK_DELETE_FILE; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckDeleteFile); @@ -1469,7 +1471,7 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) msgOut->MsgId = CTRL_MSG_B2F_ACK_CHANGE_FILE_SIZE; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckChangeFileSize); @@ -1502,7 +1504,7 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) msgOut->MsgId = CTRL_MSG_B2F_ACK_GET_FILE_SIZE; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckGetFileSize); @@ -1535,7 +1537,7 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) msgOut->MsgId = CTRL_MSG_B2F_ACK_GET_FILE_INFO; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckGetFileInfo); @@ -1568,7 +1570,7 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) msgOut->MsgId = CTRL_MSG_B2F_ACK_GET_FILE_ATTR; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckGetFileAttr); @@ -1601,7 +1603,7 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) msgOut->MsgId = CTRL_MSG_B2F_ACK_GET_FREE_SPACE; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckGetFreeSpace); @@ -1634,7 +1636,7 @@ CtrlMsgHandler( CtrlConn->PendingControlPlanRequest.Request = (BufferT)req; CtrlConn->PendingControlPlanRequest.Response = (BufferT)resp; resp->Result = DDS_ERROR_CODE_IO_PENDING; - ControlPlaneHandler(&CtrlConn->PendingControlPlanRequest); + SubmitControlPlaneRequest(FS, &CtrlConn->PendingControlPlanRequest) msgOut->MsgId = CTRL_MSG_B2F_ACK_MOVE_FILE; CtrlConn->SendWr.sg_list->length = sizeof(MsgHeader) + sizeof(CtrlMsgB2FAckMoveFile); @@ -1655,10 +1657,10 @@ CtrlMsgHandler( // static int inline ProcessCtrlCqEvents( - struct BackEndConfig *Config + BackEndConfig *Config ) { int ret = 0; - struct CtrlConnConfig *ctrlConn = NULL; + CtrlConnConfig *ctrlConn = NULL; struct ibv_wc wc; for (int i = 0; i != Config->MaxClients; i++) { @@ -1681,7 +1683,7 @@ ProcessCtrlCqEvents( // switch(wc.opcode) { case IBV_WC_RECV: { - ret = CtrlMsgHandler(ctrlConn); + ret = CtrlMsgHandler(ctrlConn, Config->FS); if (ret) { fprintf(stderr, "%s [error]: CtrlMsgHandler failed\n", __func__); goto ProcessCtrlCqEventsReturn; @@ -1711,7 +1713,7 @@ ProcessCtrlCqEvents( // static inline int BuffMsgHandler( - struct BuffConnConfig *BuffConn + BuffConnConfig *BuffConn ) { int ret = 0; MsgHeader* msgIn = (MsgHeader*)BuffConn->RecvBuff; @@ -1820,7 +1822,8 @@ BuffMsgHandler( // static inline void ExecuteRequests( - struct BuffConnConfig* BuffConn + BuffConnConfig* BuffConn, + FileService* FS ) { char* buffReq; char* buffResp; @@ -1843,6 +1846,8 @@ ExecuteRequests( FileIOSizeT totalRespSize = 0; int progressReq = headReq; int progressResp = tailResp; + + DataPlaneRequestContext ctxt; buffReq = BuffConn->RequestDMAReadDataBuff; @@ -1927,10 +1932,13 @@ ExecuteRequests( } // - // Inovke write handler + // Submit this request // // - WriteHandler(curReqObj, resp, &dataBuff); + ctxt.Request = curReqObj; + ctxt.Response = resp; + ctxt.DataBuffer = &dataBuff; + SubmitDataPlaneRequest(FS, &ctxt); } else { // @@ -1990,7 +1998,10 @@ ExecuteRequests( // Inovke read handler // // - ReadHandler(curReqObj, resp, &dataBuff); + ctxt.Request = curReqObj; + ctxt.Response = resp; + ctxt.DataBuffer = &dataBuff; + SubmitDataPlaneRequest(FS, &ctxt); } } @@ -2041,10 +2052,10 @@ DistanceBetweenPointers( // static inline int ProcessBuffCqEvents( - struct BackEndConfig *Config + BackEndConfig *Config ) { int ret = 0; - struct BuffConnConfig *buffConn = NULL; + BuffConnConfig *buffConn = NULL; struct ibv_send_wr *badSendWr = NULL; struct ibv_wc wc; @@ -2180,7 +2191,7 @@ ProcessBuffCqEvents( // Execute all the requests // // - ExecuteRequests(buffConn); + ExecuteRequests(buffConn, Config->FS); } else { buffConn->RequestDMAReadDataSplitState++; @@ -2437,10 +2448,10 @@ ProcessBuffCqEvents( // static inline int CheckAndProcessIOCompletions( - struct BackEndConfig *Config + BackEndConfig *Config ) { int ret = 0; - struct BuffConnConfig *buffConn = NULL; + BuffConnConfig *buffConn = NULL; for (int i = 0; i != Config->MaxBuffs; i++) { buffConn = &Config->BuffConns[i]; @@ -2591,10 +2602,10 @@ CheckAndProcessIOCompletions( // static inline int CheckAndProcessControlPlaneCompletions( - struct BackEndConfig *Config + BackEndConfig *Config ) { int ret = 0; - struct CtrlConnConfig *ctrlConn = NULL; + CtrlConnConfig *ctrlConn = NULL; struct ibv_send_wr *badSendWr = NULL; for (int i = 0; i != Config->MaxClients; i++) { @@ -2717,7 +2728,7 @@ int RunFileBackEnd( const uint32_t MaxClients, const uint32_t MaxBuffs ) { - struct BackEndConfig config; + BackEndConfig config; struct rdma_cm_event *event; int ret = 0; int dataPlaneCounter = 0; @@ -2734,6 +2745,17 @@ int RunFileBackEnd( config.BuffConns = NULL; config.DMAConf.CmChannel = NULL; config.DMAConf.CmId = NULL; + config.FS = NULL; + + // + // Allocate the file service object + // + // + config.FS = AllocateFileService(); + if (config.FS) { + fprintf(stderr, "AllocateFileService failed\n"); + return ret; + } // // Initialize DMA @@ -2849,6 +2871,7 @@ int RunFileBackEnd( // DeallocConns(&config); TermDMA(&config.DMAConf); + DeallocateFileService(config.FS); return ret; }