Skip to content

Commit

Permalink
Added new test case CreateIOQContigPoll.
Browse files Browse the repository at this point in the history
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
trentmeester committed Nov 15, 2011
1 parent 6517087 commit 65751bb
Show file tree
Hide file tree
Showing 30 changed files with 658 additions and 98 deletions.
1 change: 1 addition & 0 deletions Cmds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SRC = \
adminCmd.cpp \
nvmeCmd.cpp \
createIOCQ.cpp \
createIOSQ.cpp \
identify.cpp

.SUFFIXES: .cpp
Expand Down
79 changes: 76 additions & 3 deletions Cmds/createIOCQ.cpp
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);
}
33 changes: 25 additions & 8 deletions Cmds/createIOCQ.h
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
#ifndef _CREATEIOCQ_H_
#define _CREATEIOCQ_H_

#include "cmd.h"
#include "adminCmd.h"
#include "../Queues/iocq.h"


class CreateIOCQ; // forward definition
typedef boost::shared_ptr<CreateIOCQ> SharedCreateIOCQPtr;
#define CAST_TO_CreateIOCQ(shared_trackable_ptr) \
typedef boost::shared_ptr<CreateIOCQ> SharedCreateIOCQPtr;
#define CAST_TO_CREATEIOCQ(shared_trackable_ptr) \
boost::shared_polymorphic_downcast<CreateIOCQ>(shared_trackable_ptr);


/**
* This class implements the Create IO Completion Queue admin cmd
* This class implements the Create IO Completion Queue admin cmd. After
* instantiation the Init() methods must be called to attain something useful.
*
* @note This class may throw exceptions.
*/
class CreateIOCQ : public Cmd
class CreateIOCQ : public AdminCmd
{
public:
/**
* @param fd Pass the opened file descriptor for the device under test
*/
CreateIOCQ(int fd);
virtual ~CreateIOCQ();

/// Used to compare for NULL pointers being returned by allocations
static SharedCreateIOCQPtr NullCreateIOCQPtr;

/**
* Initialize this object and prepares it to send to the hdw.
* @param iocq Pass the IOCQ object which will initialize this cmd.
*/
void Init(const SharedIOCQPtr iocq);

/**
* 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:
CreateIOCQ();
Expand Down
73 changes: 73 additions & 0 deletions Cmds/createIOSQ.cpp
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);
}
49 changes: 49 additions & 0 deletions Cmds/createIOSQ.h
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
19 changes: 10 additions & 9 deletions Cmds/identify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

#define CNS_BITMASK 0x01

SharedIdentifyPtr Identify::NullIdentifyPtr;
const uint16_t Identify::IDEAL_DATA_SIZE = 4096;


// Register metrics (ID Cmd Ctrlr Cap struct) to aid interfacing with the dnvme
#define ZZ(a, b, c, d) { b, c, d },
IdentifyDataType Identify::mIdCtrlrCapMetrics[] =
Expand All @@ -24,16 +26,16 @@ IdentifyDataType Identify::mIdNamespcType[] =


Identify::Identify() :
Cmd(0, Trackable::OBJTYPE_FENCE)
AdminCmd(0, Trackable::OBJTYPE_FENCE)
{
// This constructor will throw
}


Identify::Identify(int fd) :
Cmd(fd, Trackable::OBJ_IDENTIFY)
AdminCmd(fd, Trackable::OBJ_IDENTIFY)
{
Init(CMD_ADMIN, 0x06, DATADIR_FROM_DEVICE, 64);
Init(0x06, DATADIR_FROM_DEVICE);
SetCNS(true);
}

Expand Down Expand Up @@ -98,10 +100,10 @@ Identify::GetValue(int field, IdentifyDataType *idData)
LOG_DBG("sizeof(%s) > %ld bytes", idData[field].desc, sizeof(uint64_t));
throw exception();
} else if ((idData[field].length + idData[field].offset) >=
GetROPrpBufferSize()) {
GetPrpBufferSize()) {
LOG_DBG("Detected illegal definition in IDxxxxx_TABLE");
LOG_DBG("Reference calc (%d): %d + %d >= %ld", field,
idData[field].length, idData[field].offset, GetROPrpBufferSize());
idData[field].length, idData[field].offset, GetPrpBufferSize());
throw exception();
}

Expand All @@ -119,11 +121,10 @@ Identify::Dump(LogFilename filename, string fileHdr)
{
FILE *fp;
const uint8_t *buf = GetROPrpBuffer();
string objName = "Admin Cmd: Identify";


// Do a raw dump of the data
Buffers::Dump(filename, buf, 0, ULONG_MAX, GetROPrpBufferSize(), fileHdr);
Buffers::Dump(filename, buf, 0, ULONG_MAX, GetPrpBufferSize(), fileHdr);

// Reopen the file and append the same data in a different format
if ((fp = fopen(filename.c_str(), "a")) == NULL) {
Expand Down Expand Up @@ -155,10 +156,10 @@ Identify::Dump(FILE *fp, int field, IdentifyDataType *idData)
fprintf(fp, "\n%s\n", idData[field].desc);

data = &((GetROPrpBuffer())[idData[field].offset]);
if ((idData[field].length + idData[field].offset) > GetROPrpBufferSize()) {
if ((idData[field].length + idData[field].offset) > GetPrpBufferSize()) {
LOG_DBG("Detected illegal definition in IDxxxxx_TABLE");
LOG_DBG("Reference calc (%d): %d + %d >= %ld", field,
idData[field].length, idData[field].offset, GetROPrpBufferSize());
idData[field].length, idData[field].offset, GetPrpBufferSize());
throw exception();
}

Expand Down
4 changes: 2 additions & 2 deletions Cmds/identify.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _IDENTIFY_H_
#define _IDENTIFY_H_

#include "cmd.h"
#include "adminCmd.h"
#include "identifyDefs.h"
#include "../Utils/fileSystem.h"

Expand All @@ -17,7 +17,7 @@ typedef boost::shared_ptr<Identify> SharedIdentifyPtr;
*
* @note This class may throw exceptions.
*/
class Identify : public Cmd
class Identify : public AdminCmd
{
public:
Identify(int fd);
Expand Down
Loading

0 comments on commit 65751bb

Please sign in to comment.