Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
Add file service interface
Browse files Browse the repository at this point in the history
  • Loading branch information
qizzz committed Sep 23, 2023
1 parent 63a29e8 commit 9a49de0
Show file tree
Hide file tree
Showing 19 changed files with 377 additions and 339 deletions.
22 changes: 11 additions & 11 deletions DPDPU/Benchmarks/RingBuffer/DPU/Include/RequestBackEnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions DPDPU/Benchmarks/RingBuffer/DPU/Include/ResponseBackEnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
58 changes: 29 additions & 29 deletions DPDPU/Benchmarks/RingBuffer/DPU/Source/RequestBackEnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static int SetNonblocking(
//
static int
InitDMA(
struct DMAConfig* Config,
DMAConfig* Config,
uint32_t Ip,
uint16_t Port
) {
Expand Down Expand Up @@ -110,7 +110,7 @@ InitDMA(
//
static void
TermDMA(
struct DMAConfig* Config
DMAConfig* Config
) {
if (Config->CmId) {
rdma_destroy_id(Config->CmId);
Expand All @@ -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;
}
Expand All @@ -156,7 +156,7 @@ AllocConns(struct BackEndConfig* Config) {
//
//
static void
DeallocConns(struct BackEndConfig* Config) {
DeallocConns(BackEndConfig* Config) {
if (Config->CtrlConns) {
free(Config->CtrlConns);
}
Expand Down Expand Up @@ -186,7 +186,7 @@ SignalHandler(
//
static int
SetUpCtrlQPair(
struct CtrlConnConfig* CtrlConn
CtrlConnConfig* CtrlConn
) {
int ret = 0;
struct ibv_qp_init_attr initAttr;
Expand Down Expand Up @@ -264,7 +264,7 @@ SetUpCtrlQPair(
//
static void
DestroyCtrlQPair(
struct CtrlConnConfig* CtrlConn
CtrlConnConfig* CtrlConn
) {
rdma_destroy_qp(CtrlConn->RemoteCmId);
ibv_destroy_cq(CtrlConn->CompQ);
Expand All @@ -278,7 +278,7 @@ DestroyCtrlQPair(
//
static int
SetUpCtrlRegionsAndBuffers(
struct CtrlConnConfig* CtrlConn
CtrlConnConfig* CtrlConn
) {
int ret = 0;
CtrlConn->RecvMr = ibv_reg_mr(
Expand Down Expand Up @@ -340,7 +340,7 @@ SetUpCtrlRegionsAndBuffers(
//
static void
DestroyCtrlRegionsAndBuffers(
struct CtrlConnConfig* CtrlConn
CtrlConnConfig* CtrlConn
) {
ibv_dereg_mr(CtrlConn->SendMr);
ibv_dereg_mr(CtrlConn->RecvMr);
Expand All @@ -356,7 +356,7 @@ DestroyCtrlRegionsAndBuffers(
//
static int
SetUpBuffQPair(
struct BuffConnConfig* BuffConn
BuffConnConfig* BuffConn
) {
int ret = 0;
struct ibv_qp_init_attr initAttr;
Expand Down Expand Up @@ -434,7 +434,7 @@ SetUpBuffQPair(
//
static void
DestroyBuffQPair(
struct BuffConnConfig* BuffConn
BuffConnConfig* BuffConn
) {
rdma_destroy_qp(BuffConn->RemoteCmId);
ibv_destroy_cq(BuffConn->CompQ);
Expand All @@ -448,7 +448,7 @@ DestroyBuffQPair(
//
static int
SetUpBuffRegionsAndBuffers(
struct BuffConnConfig* BuffConn
BuffConnConfig* BuffConn
) {
int ret = 0;

Expand Down Expand Up @@ -778,7 +778,7 @@ SetUpBuffRegionsAndBuffers(
//
static void
DestroyBuffRegionsAndBuffers(
struct BuffConnConfig* BuffConn
BuffConnConfig* BuffConn
) {
ibv_dereg_mr(BuffConn->DMAWriteMetaMr);
ibv_dereg_mr(BuffConn->DMAReadMetaMr);
Expand Down Expand Up @@ -839,7 +839,7 @@ DestroyBuffRegionsAndBuffers(
//
static int
FindConnId(
struct BackEndConfig *Config,
BackEndConfig *Config,
struct rdma_cm_id *CmId,
uint8_t *IsCtrl
) {
Expand All @@ -866,7 +866,7 @@ FindConnId(
//
static int inline
ProcessCmEvents(
struct BackEndConfig *Config,
BackEndConfig *Config,
struct rdma_cm_event *Event
) {
int ret = 0;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -1164,7 +1164,7 @@ ProcessCmEvents(
//
static inline int
CtrlMsgHandler(
struct CtrlConnConfig *CtrlConn
CtrlConnConfig *CtrlConn
) {
int ret = 0;
MsgHeader* msgIn = (MsgHeader*)CtrlConn->RecvBuff;
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -1287,7 +1287,7 @@ ProcessCtrlCqEvents(
//
static inline int
BuffMsgHandler(
struct BuffConnConfig *BuffConn
BuffConnConfig *BuffConn
) {
int ret = 0;
MsgHeader* msgIn = (MsgHeader*)BuffConn->RecvBuff;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
Loading

0 comments on commit 9a49de0

Please sign in to comment.