Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SendQ #8

Merged
merged 16 commits into from
Feb 4, 2024
23 changes: 22 additions & 1 deletion Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ TESTBENCHS = \
TestSpecialFIFOF.bsv \
TestTransportLayer.bsv \
TestUtils.bsv \
TestWorkCompGen.bsv
TestWorkCompGen.bsv \
TestPayloadGen.bsv \
TestSendQ.bsv

SimDma.bsv = mkTestFixedPktLenDataStreamPipeOut \
mkTestDmaReadAndWriteSrv
Expand Down Expand Up @@ -103,6 +105,25 @@ TestWorkCompGen.bsv = mkTestWorkCompGenNormalCaseRQ \
mkTestWorkCompGenNormalCaseSQ \
mkTestWorkCompGenErrFlushCaseSQ

TestPayloadGen.bsv = mkTestAddrChunkSrv \
mkTestDmaReadCntrlScatterGatherListCase \
mkTestDmaReadCntrlNormalCase \
mkTestDmaReadCntrlCancelCase \
mkTestMergeNormalPayloadEachSGE \
mkTestMergeSmallPayloadEachSGE \
mkTestMergeNormalPayloadAllSGE \
mkTestMergeSmallPayloadAllSGE \
mkTestAdjustNormalPayloadSegmentCase \
mkTestAdjustSmallPayloadSegmentCase \
mkTestPayloadGenNormalCase \
mkTestPayloadGenSmallCase \
mkTestPayloadGenZeroCase

TestSendQ.bsv = mkTestSendQueueRawPktCase \
mkTestSendQueueNormalCase \
mkTestSendQueueNoPayloadCase \
mkTestSendQueueZeroPayloadLenCase

all: $(TESTBENCHS)

%.bsv:
Expand Down
19 changes: 19 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,25 @@ mkdir -p $LOG_DIR
# make -j8 TESTFILE=TestWorkCompGen.bsv TOPMODULE=mkTestWorkCompGenNormalCaseSQ 2>&1 | tee -a $ALL_LOG
# make -j8 TESTFILE=TestWorkCompGen.bsv TOPMODULE=mkTestWorkCompGenErrFlushCaseSQ 2>&1 | tee -a $ALL_LOG

# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestAddrChunkSrv
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestDmaReadCntrlScatterGatherListCase
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestDmaReadCntrlNormalCase
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestDmaReadCntrlCancelCase
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestMergeNormalPayloadEachSGE
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestMergeSmallPayloadEachSGE
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestMergeNormalPayloadAllSGE
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestMergeSmallPayloadAllSGE
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestAdjustNormalPayloadSegmentCase
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestAdjustSmallPayloadSegmentCase
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestPayloadGenNormalCase
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestPayloadGenSmallCase
# make -j8 TESTFILE=TestPayloadGen.bsv TOPMODULE=mkTestPayloadGenZeroCase

# make -j8 TESTFILE=TestSendQ.bsv TOPMODULE=mkTestSendQueueRawPktCase
# make -j8 TESTFILE=TestSendQ.bsv TOPMODULE=mkTestSendQueueNormalCase
# make -j8 TESTFILE=TestSendQ.bsv TOPMODULE=mkTestSendQueueNoPayloadCase
# make -j8 TESTFILE=TestSendQ.bsv TOPMODULE=mkTestSendQueueZeroPayloadLenCase

make -j8 -f Makefile.test all TESTDIR=$TEST_DIR LOGDIR=$LOG_DIR
cat $LOG_DIR/*.log | tee $ALL_LOG

Expand Down
2 changes: 1 addition & 1 deletion run_one.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TEST_LOG=test.log
TEST_DIR=test
cd $TEST_DIR
truncate -s 0 $TEST_LOG
FILES=`ls TestReqHandleRQ.bsv`
FILES=`ls TestSendQ.bsv`
for FILE in $FILES; do
# echo $FILE
TESTCASES=`grep -Phzo 'doc.*?\nmodule\s+\S+(?=\()' $FILE | xargs -0 -I {} echo "{}" | grep module | cut -d ' ' -f 2`
Expand Down
99 changes: 60 additions & 39 deletions src/DataTypes.bsv
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,23 @@ typedef 8 QP_CAP_CNT_WIDTH;
// Derived settings
typedef AETH_VALUE_WIDTH TIMER_WIDTH;

// 12 + 4 + 28 = 44 bytes
typedef TAdd#(TAdd#(BTH_BYTE_WIDTH, XRCETH_BYTE_WIDTH), ATOMIC_ETH_BYTE_WIDTH) HEADER_MAX_BYTE_LENGTH;
typedef TLog#(MAX_SGE) SGE_IDX_WIDTH;
typedef TAdd#(1, SGE_IDX_WIDTH) SGE_NUM_WIDTH;

typedef TDiv#(DATA_BUS_WIDTH, 8) DATA_BUS_BYTE_WIDTH;
typedef TLog#(DATA_BUS_BYTE_WIDTH) DATA_BUS_BYTE_NUM_WIDTH;
typedef TLog#(DATA_BUS_WIDTH) DATA_BUS_BIT_NUM_WIDTH;
// 12 + 4 + 16 + 16 = 48 bytes
typedef TAdd#(TAdd#(BTH_BYTE_WIDTH, XRCETH_BYTE_WIDTH), TAdd#(RETH_BYTE_WIDTH, LETH_BYTE_WIDTH)) HEADER_MAX_BYTE_LENGTH;
// // 12 + 4 + 28 = 44 bytes
// typedef TAdd#(TAdd#(BTH_BYTE_WIDTH, XRCETH_BYTE_WIDTH), ATOMIC_ETH_BYTE_WIDTH) HEADER_MAX_BYTE_LENGTH;

typedef TDiv#(DATA_BUS_WIDTH, 8) DATA_BUS_BYTE_WIDTH; // 32
typedef TLog#(DATA_BUS_BYTE_WIDTH) DATA_BUS_BYTE_NUM_WIDTH; // 5
typedef TLog#(DATA_BUS_WIDTH) DATA_BUS_BIT_NUM_WIDTH; // 8

typedef TDiv#(HEADER_MAX_BYTE_LENGTH, DATA_BUS_BYTE_WIDTH) HEADER_MAX_FRAG_NUM; // 2 (bus 256b), 1 (bus 512b)
typedef TMul#(DATA_BUS_WIDTH, HEADER_MAX_FRAG_NUM) HEADER_MAX_DATA_WIDTH; // 512
typedef TMul#(DATA_BUS_BYTE_WIDTH, HEADER_MAX_FRAG_NUM) HEADER_MAX_BYTE_EN_WIDTH; // 64
// typedef TLog#(TAdd#(1, HEADER_MAX_BYTE_LENGTH)) HEADER_MAX_BYTE_NUM_WIDTH; // 6
typedef TLog#(TAdd#(1, HEADER_MAX_BYTE_EN_WIDTH)) HEADER_MAX_BYTE_NUM_WIDTH; // 7
typedef TLog#(TAdd#(1, HEADER_MAX_FRAG_NUM)) HEADER_FRAG_NUM_WIDTH; // 2 (bus 256b), 1 (bus 512b)

typedef TLog#(MAX_PMTU) MAX_PMTU_WIDTH; // 12
// typedef TLog#(TLog#(MAX_PMTU)) PMTU_VALUE_MAX_WIDTH; // 4
Expand All @@ -69,29 +74,36 @@ typedef TLog#(MAX_RNR_WAIT_CYCLES) RNR_WAIT_CYCLE_CNT_WIDTH;
typedef TDiv#(MAX_TIMEOUT_NS, TARGET_CYCLE_NS) MAX_TIMEOUT_CYCLES;
typedef TAdd#(1, TLog#(MAX_TIMEOUT_CYCLES)) TIMEOUT_CYCLE_CNT_WIDTH;

typedef 48 PHYSICAL_ADDR_WIDTH; // X86 physical address width
typedef 48 PHYSICAL_ADDR_WIDTH; // X86 physical address width
typedef TExp#(14) TLB_CACHE_SIZE; // TLB cache size 16K
typedef TLog#(PAGE_SIZE_CAP) PAGE_OFFSET_WIDTH;
typedef TLog#(TLB_CACHE_SIZE) TLB_CACHE_INDEX_WIDTH; // 14
typedef TSub#(PHYSICAL_ADDR_WIDTH, PAGE_OFFSET_WIDTH) TLB_CACHE_PA_DATA_WIDTH; // 48-21=27
typedef TSub#(TSub#(ADDR_WIDTH, TLB_CACHE_INDEX_WIDTH), PAGE_OFFSET_WIDTH) TLB_CACHE_TAG_WIDTH; // 64-14-21=29

typedef TDiv#(MAX_MR, MAX_PD) MAX_MR_PER_PD;
typedef TLog#(MAX_MR_PER_PD) MR_INDEX_WIDTH;
typedef TSub#(KEY_WIDTH, MR_INDEX_WIDTH) MR_KEY_PART_WIDTH;

// Derived types
typedef Bit#(DATA_BUS_WIDTH) DATA;
typedef Bit#(DATA_BUS_BYTE_WIDTH) ByteEn;

typedef Bit#(HEADER_MAX_DATA_WIDTH) HeaderData;
typedef Bit#(HEADER_MAX_BYTE_EN_WIDTH) HeaderByteEn;
typedef Bit#(HEADER_MAX_BYTE_NUM_WIDTH) HeaderByteNum;
// typedef Bit#(TLog#(TAdd#(1, HEADER_MAX_BYTE_EN_WIDTH))) HeaderByteNum;
typedef Bit#(TAdd#(1, HEADER_MAX_DATA_WIDTH)) HeaderBitNum;
typedef Bit#(TLog#(TAdd#(1, HEADER_MAX_FRAG_NUM))) HeaderFragNum;
typedef Bit#(SGE_IDX_WIDTH) IdxSGL;
typedef Bit#(SGE_NUM_WIDTH) NumSGE;

typedef Bit#(HEADER_MAX_DATA_WIDTH) HeaderData;
typedef Bit#(HEADER_MAX_BYTE_EN_WIDTH) HeaderByteEn;
typedef Bit#(HEADER_MAX_BYTE_NUM_WIDTH) HeaderByteNum;
typedef Bit#(TAdd#(1, HEADER_MAX_DATA_WIDTH)) HeaderBitNum;
typedef Bit#(HEADER_FRAG_NUM_WIDTH) HeaderFragNum;

typedef Bit#(DATA_BUS_BYTE_NUM_WIDTH) BusByteWidthMask;
typedef Bit#(PAD_WIDTH) PadMask;
typedef Bit#(DATA_BUS_BIT_NUM_WIDTH) BusBitWidthMask; // 8
typedef Bit#(DATA_BUS_BYTE_NUM_WIDTH) BusByteWidthMask; // 5
// typedef Bit#(PAD_WIDTH) PadMask;

typedef Bit#(TAdd#(1, DATA_BUS_BIT_NUM_WIDTH)) BusBitNum;
typedef Bit#(TAdd#(1, DATA_BUS_BYTE_NUM_WIDTH)) ByteEnBitNum;
typedef Bit#(TAdd#(1, DATA_BUS_BIT_NUM_WIDTH)) BusBitNum; // 9
typedef Bit#(TAdd#(1, DATA_BUS_BYTE_NUM_WIDTH)) ByteEnBitNum; // 6

// typedef Bit#(TLog#(TAdd#(1, MAX_QP_WR))) PendingReqCnt;
// typedef Bit#(TLog#(TAdd#(1, MAX_QP_RD_ATOM))) PendingReadAtomicReqCnt;
Expand All @@ -101,7 +113,7 @@ typedef Bit#(QP_CAP_CNT_WIDTH) InlineDataSize;
typedef Bit#(QP_CAP_CNT_WIDTH) ScatterGatherElemCnt;

// typedef Bit#(PMTU_VALUE_MAX_WIDTH) PmtuValueWidth;
typedef Bit#(MAX_PMTU_WIDTH) PmtuResidue;
typedef Bit#(MAX_PMTU_WIDTH) ResiduePMTU;
typedef Bit#(TOTAL_FRAG_NUM_WIDTH) TotalFragNum;
typedef Bit#(PMTU_FRAG_NUM_WIDTH) PktFragNum;
typedef Bit#(PKT_NUM_WIDTH) PktNum;
Expand Down Expand Up @@ -132,6 +144,9 @@ typedef struct {

typedef SizeOf#(PayloadTLB) TLB_PAYLOAD_WIDTH;

typedef UInt#(MR_INDEX_WIDTH) IndexMR;
typedef Bit#(MR_KEY_PART_WIDTH) KeyPartMR;

// Common types

typedef Server#(DmaReadReq, DmaReadResp) DmaReadSrv;
Expand Down Expand Up @@ -164,7 +179,7 @@ typedef enum {
RETRY_REASON_TIMEOUT
} RetryReason deriving(Bits, Eq, FShow);

// DATA and ByteEn are left algined
// DATA and ByteEn are left aligned
typedef struct {
DATA data;
ByteEn byteEn;
Expand All @@ -177,6 +192,7 @@ typedef struct {
HeaderFragNum headerFragNum;
ByteEnBitNum lastFragValidByteNum;
Bool hasPayload;
Bool isEmptyHeader;
} HeaderMetaData deriving(Bits, Bounded, Eq);

instance FShow#(HeaderMetaData);
Expand All @@ -190,8 +206,8 @@ endinstance

// HeaderData and HeaderByteEn are left aligned
typedef struct {
HeaderData headerData;
HeaderByteEn headerByteEn;
HeaderData headerData;
HeaderByteEn headerByteEn;
HeaderMetaData headerMetaData;
} RdmaHeader deriving(Bits, Bounded, FShow);

Expand Down Expand Up @@ -238,25 +254,27 @@ typedef struct {
} PermCheckReq deriving(Bits, FShow);

typedef struct {
DmaReqSrcType initiator;
QPN sqpn;
DmaReqSrcType initiator; // TODO: remove it
QPN sqpn; // TODO: remove it
WorkReqID wrID; // TODO: remove it
ADDR startAddr;
Length len;
WorkReqID wrID;
IndexMR mrIdx;
} DmaReadMetaData deriving(Bits, FShow);

typedef struct {
DmaReqSrcType initiator;
QPN sqpn;
DmaReqSrcType initiator; // TODO: remove it
QPN sqpn; // TODO: remove it
WorkReqID wrID; // TODO: remove it
ADDR startAddr;
PktLen len;
WorkReqID wrID;
IndexMR mrIdx;
} DmaReadReq deriving(Bits, FShow);

typedef struct {
DmaReqSrcType initiator;
QPN sqpn;
WorkReqID wrID;
DmaReqSrcType initiator; // TODO: remove it
QPN sqpn; // TODO: remove it
WorkReqID wrID; // TODO: remove it
Bool isRespErr;
DataStream dataStream;
} DmaReadResp deriving(Bits, FShow);
Expand Down Expand Up @@ -293,7 +311,7 @@ typedef enum {
DMA_SRC_SQ_ATOMIC,
DMA_SRC_SQ_DISCARD
// DMA_SRC_SQ_CANCEL
} DmaReqSrcType deriving(Bits, Eq, FShow);
} DmaReqSrcType deriving(Bits, Eq, FShow); // TODO: remove it

typedef struct {
DmaReadMetaData dmaReadMetaData;
Expand Down Expand Up @@ -356,16 +374,16 @@ typedef enum {
IBV_QPS_SQE,
IBV_QPS_ERR,
IBV_QPS_UNKNOWN,
IBV_QPS_CREATE // Not defined in rdma-core
IBV_QPS_CREATE // TODO: remote it. Not defined in rdma-core
} StateQP deriving(Bits, Eq, FShow);

typedef enum {
IBV_QPT_RC = 2,
IBV_QPT_UC = 3,
IBV_QPT_UD = 4,
// IBV_QPT_RAW_PACKET = 8,
IBV_QPT_XRC_SEND = 9,
IBV_QPT_XRC_RECV = 10
IBV_QPT_RC = 2,
IBV_QPT_UC = 3,
IBV_QPT_UD = 4,
IBV_QPT_RAW_PACKET = 8,
IBV_QPT_XRC_SEND = 9,
IBV_QPT_XRC_RECV = 10
// IBV_QPT_DRIVER = 0xff
} TypeQP deriving(Bits, Eq, FShow);

Expand Down Expand Up @@ -485,7 +503,10 @@ typedef enum {
IBV_WR_BIND_MW = 8,
IBV_WR_SEND_WITH_INV = 9,
IBV_WR_TSO = 10,
IBV_WR_DRIVER1 = 11
IBV_WR_DRIVER1 = 11,
IBV_WR_RDMA_READ_RESP = 12, // Not defined in rdma-core
IBV_WR_FLUSH = 14,
IBV_WR_ATOMIC_WRITE = 15
} WorkReqOpCode deriving(Bits, Eq, FShow);

typedef enum {
Expand Down
Loading
Loading