forked from nvmecompliance/tnvme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new test case CreateIOQContigPoll.
The test case will create IOCQ and IOSQ's with ID 1, contiguous memory to represent the Q's, not IRQ, thus polling is enabled. To make this occur the CreateIOCQ and Create IOSQ cmd classes were developed. The ASQ received the commands to create both Q's, and the ACQ provided the CE's.
- Loading branch information
1 parent
6517087
commit 65751bb
Showing
30 changed files
with
658 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ SRC = \ | |
adminCmd.cpp \ | ||
nvmeCmd.cpp \ | ||
createIOCQ.cpp \ | ||
createIOSQ.cpp \ | ||
identify.cpp | ||
|
||
.SUFFIXES: .cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,93 @@ | ||
#include "createIOCQ.h" | ||
#include "../Utils/buffers.h" | ||
|
||
|
||
CreateIOCQ::CreateIOCQ() : | ||
Cmd(0, Trackable::OBJTYPE_FENCE) | ||
AdminCmd(0, Trackable::OBJTYPE_FENCE) | ||
{ | ||
// This constructor will throw | ||
} | ||
|
||
|
||
CreateIOCQ::CreateIOCQ(int fd) : | ||
Cmd(fd, Trackable::OBJ_IOCQ) | ||
AdminCmd(fd, Trackable::OBJ_IOCQ) | ||
{ | ||
Init(CMD_ADMIN, 0x01, DATADIR_TO_DEVICE, 64); | ||
AdminCmd::Init(0x05, DATADIR_TO_DEVICE); | ||
} | ||
|
||
|
||
CreateIOCQ::~CreateIOCQ() | ||
{ | ||
} | ||
|
||
|
||
void | ||
CreateIOCQ::Init(const SharedIOCQPtr iocq) | ||
{ | ||
SetPrpBuffer((send_64b_bitmask)MASK_PRP1_PAGE, iocq->GetQBuffer(), | ||
iocq->GetQSize()); | ||
|
||
{ // Handle DWORD 10 | ||
uint32_t dword10 = GetDword(10); | ||
|
||
// Handle q size | ||
dword10 &= ~0xffff0000; | ||
dword10 |= (((uint32_t)iocq->GetNumEntries()) << 16); | ||
|
||
// Handle Q ID | ||
dword10 &= ~0x0000ffff; | ||
dword10 |= (uint32_t)iocq->GetQId(); | ||
|
||
SetDword(dword10, 10); | ||
} // Handle DWORD 10 | ||
|
||
{ // Handle DWORD 11 | ||
uint32_t dword11 = GetDword(11); | ||
|
||
// Handle the PC bit | ||
if (iocq->GetIsContig()) | ||
dword11 |= 0x00000001; | ||
else | ||
dword11 &= ~0x00000001; | ||
|
||
// Handle IRQ support | ||
if (iocq->GetIrqEnabled()) { | ||
dword11 |= 0x00000002; | ||
dword11 &= ~0xffff0000; // clear it, then set it | ||
|
||
enum nvme_irq_type irq; | ||
if (gCtrlrConfig->GetIrqScheme(irq) == false) { | ||
LOG_DBG("Unable to retrieve current IRQ scheme"); | ||
throw exception(); | ||
} | ||
switch (irq) { | ||
case INT_MSI_MULTI: | ||
case INT_MSIX: | ||
dword11 |= (((uint32_t)iocq->GetIrqVector()) << 16); | ||
break; | ||
case INT_MSI_SINGLE: | ||
case INT_NONE: | ||
; // Required to be zero | ||
break; | ||
default: | ||
LOG_DBG("Unsupported IRQ scheme, what to do?"); | ||
throw exception(); | ||
} | ||
} else { | ||
dword11 &= ~0x00000002; | ||
dword11 &= ~0xffff0000; | ||
} | ||
|
||
SetDword(dword11, 11); | ||
} // Handle DWORD 11 | ||
} | ||
|
||
|
||
void | ||
CreateIOCQ::Dump(LogFilename filename, string fileHdr) | ||
{ | ||
const uint8_t *buf = GetROPrpBuffer(); | ||
|
||
// Do a raw dump of the data | ||
Buffers::Dump(filename, buf, 0, ULONG_MAX, GetPrpBufferSize(), fileHdr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include "createIOSQ.h" | ||
#include "../Utils/buffers.h" | ||
|
||
|
||
CreateIOSQ::CreateIOSQ() : | ||
AdminCmd(0, Trackable::OBJTYPE_FENCE) | ||
{ | ||
// This constructor will throw | ||
} | ||
|
||
|
||
CreateIOSQ::CreateIOSQ(int fd) : | ||
AdminCmd(fd, Trackable::OBJ_IOSQ) | ||
{ | ||
AdminCmd::Init(0x01, DATADIR_TO_DEVICE); | ||
} | ||
|
||
|
||
CreateIOSQ::~CreateIOSQ() | ||
{ | ||
} | ||
|
||
|
||
void | ||
CreateIOSQ::Init(const SharedIOSQPtr iosq) | ||
{ | ||
SetPrpBuffer((send_64b_bitmask)MASK_PRP1_PAGE, iosq->GetQBuffer(), | ||
iosq->GetQSize()); | ||
|
||
{ // Handle DWORD 10 | ||
uint32_t dword10 = GetDword(10); | ||
|
||
// Handle q size | ||
dword10 &= ~0xffff0000; | ||
dword10 |= (((uint32_t)iosq->GetNumEntries()) << 16); | ||
|
||
// Handle Q ID | ||
dword10 &= ~0x0000ffff; | ||
dword10 |= (uint32_t)iosq->GetQId(); | ||
|
||
SetDword(dword10, 10); | ||
} // Handle DWORD 10 | ||
|
||
{ // Handle DWORD 11 | ||
uint32_t dword11 = GetDword(11); | ||
|
||
// Handle the PC bit | ||
if (iosq->GetIsContig()) | ||
dword11 |= 0x00000001; | ||
else | ||
dword11 &= ~0x00000001; | ||
|
||
// Handle Q priority | ||
dword11 &= ~0x00000006; | ||
dword11 |= (((uint32_t)iosq->GetPriority()) << 1); | ||
|
||
// Handle CQ ID | ||
dword11 &= ~0xffff0000; | ||
dword11 |= iosq->GetCqId(); | ||
|
||
SetDword(dword11, 11); | ||
} // Handle DWORD 11 | ||
} | ||
|
||
|
||
void | ||
CreateIOSQ::Dump(LogFilename filename, string fileHdr) | ||
{ | ||
const uint8_t *buf = GetROPrpBuffer(); | ||
|
||
// Do a raw dump of the data | ||
Buffers::Dump(filename, buf, 0, ULONG_MAX, GetPrpBufferSize(), fileHdr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#ifndef _CREATEIOSQ_H_ | ||
#define _CREATEIOSQ_H_ | ||
|
||
#include "adminCmd.h" | ||
#include "../Queues/iosq.h" | ||
|
||
|
||
class CreateIOSQ; // forward definition | ||
typedef boost::shared_ptr<CreateIOSQ> SharedCreateIOSQPtr; | ||
#define CAST_TO_CREATEIOSQ(shared_trackable_ptr) \ | ||
boost::shared_polymorphic_downcast<CreateIOSQ>(shared_trackable_ptr); | ||
|
||
|
||
/** | ||
* This class implements the Create IO Submission Queue admin cmd. After | ||
* instantiation the Init() methods must be called to attain something useful. | ||
* | ||
* @note This class may throw exceptions. | ||
*/ | ||
class CreateIOSQ : public AdminCmd | ||
{ | ||
public: | ||
CreateIOSQ(int fd); | ||
virtual ~CreateIOSQ(); | ||
|
||
/// Used to compare for NULL pointers being returned by allocations | ||
static SharedCreateIOSQPtr NullCreateIOSQPtr; | ||
|
||
/** | ||
* Initialize this object and prepares it to send to the hdw. | ||
* @param iosq Pass the IOSQ object which will initialize this cmd. | ||
*/ | ||
void Init(const SharedIOSQPtr iosq); | ||
|
||
/** | ||
* Send the entire contents of this cmds PRP payload to the named file. | ||
* @param filename Pass the filename as generated by macro | ||
* FileSystem::PrepLogFile(). | ||
* @param fileHdr Pass a custom file header description to dump | ||
*/ | ||
void Dump(LogFilename filename, string fileHdr); | ||
|
||
|
||
private: | ||
CreateIOSQ(); | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.