forked from meeeejin/rw-rbuf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_io_cmd_completion.c
152 lines (137 loc) · 7.08 KB
/
custom_io_cmd_completion.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include "xil_printf.h"
#include "memory_map.h"
#include "nvme/host_lld.h"
#include "request_schedule.h"
P_CUSTOM_IO_CMD_COMPLETE_TABLE customIoCmdCompleteTablePtr;
void InitCustomIoCmdCompleteTable()
{
unsigned int cmdSlotTag;
customIoCmdCompleteTablePtr = (P_CUSTOM_IO_CMD_COMPLETE_TABLE) CUSTOM_IO_CMD_COMPLETE_TABLE_ADDR;
for(cmdSlotTag=0; cmdSlotTag < MAX_CMD_SLOT_TAG; cmdSlotTag++)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedRxCount = 0;
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedRxCount = 0;
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedTxCount =0;
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedTxCount = 0;
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedNANDCount = 0;
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].reserved0 = 0;
}
}
void AllocateNotIssuedRxforCustomIoCmd(unsigned int cmdSlotTag, unsigned int devAddr)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedRxCount++;
#if (PRINT_DEBUG_MSG == 1)
xil_printf("Allo Rx Custom Io (Issue) CmdSlotTag:%d Cnt:%d devAddr:%08x\r\n", cmdSlotTag,
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedRxCount, devAddr);
#endif
}
void AllocateNotIssuedTxforCustomIoCmd(unsigned int cmdSlotTag, unsigned int devAddr)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedTxCount++;
#if (PRINT_DEBUG_MSG == 1)
xil_printf("Allo Tx Custom Io (Issue) CmdSlotTag:%d Cnt:%d devAddr:%08x\r\n", cmdSlotTag,
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedTxCount, devAddr);
#endif
}
void AllocateNotCompletedRxforCustomIoCmd(unsigned int cmdSlotTag, unsigned int devAddr)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedRxCount++;
#if (PRINT_DEBUG_MSG == 1)
xil_printf("Allo Rx Custom Io CmdSlotTag:%d Cnt:%d devAddr:%08x\r\n", cmdSlotTag,
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedRxCount, devAddr);
#endif
}
void AllocateNotCompletedTxforCustomIoCmd(unsigned int cmdSlotTag, unsigned int devAddr)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedTxCount++;
#if (PRINT_DEBUG_MSG == 1)
xil_printf("Allo Tx Custom Io (Complete) CmdSlotTag:%d Cnt:%d devAddr:%08x\r\n", cmdSlotTag,
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedTxCount, devAddr);
#endif
}
void AllocateNotCompletedNandReqforCustomIoCmd(unsigned int cmdSlotTag, unsigned int reqSlotTag, unsigned int devAddr)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedNANDCount++;
#if (PRINT_DEBUG_MSG == 1)
char * nandReqCodeString;
unsigned int reqCodeHex = reqPoolPtr->reqPool[reqSlotTag].reqCode;
if(reqCodeHex == REQ_CODE_WRITE)
nandReqCodeString = "WRITE";
else if (reqCodeHex == REQ_CODE_READ)
nandReqCodeString = "READ";
else if (reqCodeHex == REQ_CODE_READ_TRANSFER)
nandReqCodeString = "READ_Tx";
else
nandReqCodeString = "NONE";
xil_printf("Allo NandReq %s Custom Io CmdSlotTag:%d Cnt:%d devAddr:%08x\r\n", nandReqCodeString, cmdSlotTag,
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedNANDCount, devAddr);
#endif
}
void IssuedRxforCustomIoCmd(unsigned int cmdSlotTag, unsigned int reqSlotTag, unsigned int reqCode)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedRxCount--;
reqPoolPtr->reqPool[reqSlotTag].nvmeDmaInfo.issuedFlag = REQ_INFO_ISSUED_FLAG_ON;
#if (PRINT_DEBUG_MSG == 1)
xil_printf("Discount notIssuedRxCount cmdSlotTag:%d reqSlotTag:%d Cnt:%d\r\n", cmdSlotTag, reqSlotTag, customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedRxCount);
PrintDataBuffer(reqSlotTag, 1);
#endif
}
void IssuedTxforCustomIoCmd(unsigned int cmdSlotTag, unsigned int reqSlotTag, unsigned int reqCode)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedTxCount--;
reqPoolPtr->reqPool[reqSlotTag].nvmeDmaInfo.issuedFlag = REQ_INFO_ISSUED_FLAG_ON;
#if (PRINT_DEBUG_MSG == 1)
xil_printf("Discount notIssuedTxCount cmdSlotTag:%d reqSlotTag:%d Cnt:%d\r\n", cmdSlotTag, reqSlotTag, customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notIssuedTxCount);
//xil_printf("Issue Tx Custom Io CmdSlotTag:%d reqSlotTag:%d\r\n", cmdSlotTag, reqSlotTag);
PrintDataBuffer(reqSlotTag, 1);
#endif
}
void CompleteRxforCustomIoCmd(unsigned int cmdSlotTag, unsigned int reqSlotTag, unsigned int reqCode)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedRxCount--;
#if (PRINT_DEBUG_MSG == 1)
xil_printf("Discount notCompletedRxCount cmdSlotTag:%d reqSlotTag:%d Cnt:%d\r\n", cmdSlotTag, reqSlotTag, customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedRxCount);
xil_printf("Complete Rx Custom Io CmdSlotTag:%d reqSlotTag:%d\r\n", cmdSlotTag, reqSlotTag);
PrintDataBuffer(reqSlotTag, 1);
#endif
}
void CompleteTxforCustomIoCmd(unsigned int cmdSlotTag, unsigned int reqSlotTag, unsigned int reqCode)
{
NVME_COMPLETION nvmeCPL;
nvmeCPL.statusFieldWord = 0;
nvmeCPL.statusField.SCT = SCT_GENERIC_COMMAND_STATUS;
nvmeCPL.statusField.SC = SC_SUCCESSFUL_COMPLETION;
nvmeCPL.statusField.DNR = 1;
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedTxCount--;
#if (PRINT_DEBUG_MSG == 1)
xil_printf("Discount notCompletedTxCount cmdSlotTag:%d reqSlotTag:%d Cnt:%d\r\n", cmdSlotTag, reqSlotTag, customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedTxCount);
#endif
if(customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedTxCount == 0
&& customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedRxCount == 0)
{
set_auto_nvme_cpl(cmdSlotTag, 0, nvmeCPL.statusFieldWord);
#if (PRINT_DEBUG_MSG == 1)
xil_printf("Complete Tx Custom Io CmdSlotTag:%d reqSlotTag:%d NvmeBlockCnt:%d\r\n", cmdSlotTag, reqSlotTag,
reqPoolPtr->reqPool[reqSlotTag].nvmeDmaInfo.numOfNvmeBlock);
PrintDataBuffer(reqSlotTag, reqPoolPtr->reqPool[reqSlotTag].nvmeDmaInfo.numOfNvmeBlock);
#endif
}
}
void CompleteNandReqforCustomIoCmd(unsigned int cmdSlotTag, unsigned int reqSlotTag, unsigned int reqCode)
{
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedNANDCount--;
#if (PRINT_DEBUG_MSG == 1)
char * nandReqCodeString;
unsigned int reqCodeHex = reqPoolPtr->reqPool[reqSlotTag].reqCode;
if(reqCodeHex == REQ_CODE_WRITE)
nandReqCodeString = "WRITE";
else if (reqCodeHex == REQ_CODE_READ)
nandReqCodeString = "READ";
else if (reqCodeHex == REQ_CODE_READ_TRANSFER)
nandReqCodeString = "READ_Tx";
else
nandReqCodeString = "NONE";
xil_printf("Complete NandReq %s Custom Io CmdSlotTag:%d Cnt:%d devAddr:%08x reqCode:%x\r\n", nandReqCodeString, cmdSlotTag,
customIoCmdCompleteTablePtr->customIoCmdCompleteEntry[cmdSlotTag].notCompletedNANDCount, GenerateDataBufAddr(reqSlotTag), reqCode);
#endif
}