本文整理汇总了C++中SharedReadPtr::SetSLBA方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedReadPtr::SetSLBA方法的具体用法?C++ SharedReadPtr::SetSLBA怎么用?C++ SharedReadPtr::SetSLBA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedReadPtr
的用法示例。
在下文中一共展示了SharedReadPtr::SetSLBA方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exception
bool
LBAOutOfRangeBare_r10b::RunCoreTest()
{
/** \verbatim
* Assumptions:
* 1) Test CreateResources_r10b has run prior.
* \endverbatim
*/
uint64_t nsze;
ConstSharedIdentifyPtr namSpcPtr;
// Lookup objs which were created in a prior test within group
SharedIOSQPtr iosqContig = CAST_TO_IOSQ(
gRsrcMngr->GetObj(IOSQ_CONTIG_GROUP_ID))
SharedIOCQPtr iocqContig = CAST_TO_IOCQ(
gRsrcMngr->GetObj(IOCQ_CONTIG_GROUP_ID))
vector<uint32_t> bare = gInformative->GetBareNamespaces();
for (size_t i = 1; i < bare.size(); i++) {
namSpcPtr = gInformative->GetIdentifyCmdNamspc(i);
if (namSpcPtr == Identify::NullIdentifyPtr) {
LOG_ERR("Identify namspc struct #%d doesn't exist", bare[i]);
throw exception();
}
nsze = namSpcPtr->GetValue(IDNAMESPC_NSZE);
LOG_NRM("Create memory to contain read payload");
SharedMemBufferPtr readMem = SharedMemBufferPtr(new MemBuffer());
uint64_t lbaDataSize = namSpcPtr->GetLBADataSize();
readMem->Init(RD_NUM_BLKS * lbaDataSize);
LOG_NRM("Create a read cmd to read data from namspc %d", bare[i]);
SharedReadPtr readCmd = SharedReadPtr(new Read(mFd));
send_64b_bitmask prpBitmask = (send_64b_bitmask)
(MASK_PRP1_PAGE | MASK_PRP2_PAGE | MASK_PRP2_LIST);
readCmd->SetPrpBuffer(prpBitmask, readMem);
readCmd->SetNSID(bare[i]);
readCmd->SetNLB(RD_NUM_BLKS - 1); // convert to 0-based value
LOG_NRM("Issue cmd where 1st block starts at LBA (Identify.NSZE-2)");
readCmd->SetSLBA(nsze - 2);
IO::SendCmdToHdw(mGrpName, mTestName, DEFAULT_CMD_WAIT_ms, iosqContig,
iocqContig, readCmd, "nsze-2", true);
LOG_NRM("Issue cmd where 1st block starts at LBA (Identify.NSZE-1)");
readCmd->SetSLBA(nsze - 1);
SendCmdToHdw(iosqContig, iocqContig, readCmd, "nsze-1");
LOG_NRM("Issue cmd where 1st block starts at LBA (Identify.NSZE)");
readCmd->SetSLBA(nsze);
SendCmdToHdw(iosqContig, iocqContig, readCmd, "nsze");
}
return true;
}
示例2: SharedMemBufferPtr
void
IgnoreMetaPtrBare_r12::RunCoreTest()
{
/** \verbatim
* Assumptions:
* 1) Test CreateResources_r10b has run prior.
* \endverbatim
*/
string work;
ConstSharedIdentifyPtr namSpcPtr;
// Lookup objs which were created in a prior test within group
SharedIOSQPtr iosq = CAST_TO_IOSQ(gRsrcMngr->GetObj(IOSQ_GROUP_ID));
SharedIOCQPtr iocq = CAST_TO_IOCQ(gRsrcMngr->GetObj(IOCQ_GROUP_ID));
LOG_NRM("For all bare namspc's issue cmd with non-zero meta ptr");
vector<uint32_t> bare = gInformative->GetBareNamespaces();
for (size_t i = 0; i < bare.size(); i++) {
namSpcPtr = gInformative->GetIdentifyCmdNamspc(bare[i]);
if (namSpcPtr->isZeroFilled()) {
LOG_NRM("Namespace %lu is inactive", i);
} else {
LOG_NRM("Setup read cmd's values that won't change per namspc");
SharedMemBufferPtr readMem = SharedMemBufferPtr(new MemBuffer());
uint64_t lbaDataSize = namSpcPtr->GetLBADataSize();
readMem->Init(lbaDataSize);
SharedReadPtr readCmd = SharedReadPtr(new Read());
send_64b_bitmask prpBitmask = (send_64b_bitmask)
(MASK_PRP1_PAGE | MASK_PRP2_PAGE | MASK_PRP2_LIST);
readCmd->SetPrpBuffer(prpBitmask, readMem);
readCmd->SetNLB(0); // convert to 0-based value
readCmd->SetSLBA(0);
LOG_NRM("Set MPTR in cmd to max value");
readCmd->SetDword(0xffffffff, 4);
readCmd->SetDword(0xffffffff, 5);
readCmd->SetNSID(bare[i]);
work = str(boost::format("namspc%d") % bare[i]);
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq,
iocq, readCmd, work, true);
}
}
}
示例3: SharedWritePtr
void
ReadWriteToUnacquiredReservation::RunCoreTest()
{
/** \verbatim
* Assumptions:
* None.
* \endverbatim
*/
LOG_NRM("Start ReadWriteToUnacquiredReservation::RunCoreTest")
SharedIOSQPtr iosq = CAST_TO_IOSQ(gRsrcMngr->GetObj(IOSQ_GROUP_ID));
SharedIOCQPtr iocq = CAST_TO_IOCQ(gRsrcMngr->GetObj(IOCQ_GROUP_ID));
SharedASQPtr asq = CAST_TO_ASQ(gRsrcMngr->GetObj(ASQ_GROUP_ID));
SharedACQPtr acq = CAST_TO_ACQ(gRsrcMngr->GetObj(ACQ_GROUP_ID));
SharedWritePtr writeCmd = SharedWritePtr(new Write());
SharedReadPtr readCmd = SharedReadPtr(new Read());
SharedMemBufferPtr lbaWriteBuffer = SharedMemBufferPtr(new MemBuffer());
SharedMemBufferPtr lbaReadBuffer = SharedMemBufferPtr(new MemBuffer());
LOG_NRM("Create nvmeWrite Cmd and write 1 block of data to LBA 5, expecting 0:0x83 for HostB");
lbaWriteBuffer->Init(512, true, 0xDD);
writeCmd->SetPrpBuffer( (send_64b_bitmask)( MASK_PRP1_PAGE | MASK_PRP2_PAGE), lbaWriteBuffer);
writeCmd->SetNSID(1);
writeCmd->SetSLBA(5);
writeCmd->SetNLB(0); // 0's based!
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq, iocq, writeCmd, "write 0xDD's to LBA5 using hostB", true, CESTAT_RSRV_CONFLICT);
LOG_NRM("Create nvmeRead Cmd and read back 1 block of data to LBA 5, expecting 0:0x83 for HostA");
lbaReadBuffer->Init(512, true, 0x00);
readCmd->SetPrpBuffer( (send_64b_bitmask) (MASK_PRP1_PAGE | MASK_PRP2_PAGE), lbaReadBuffer);
readCmd->SetNSID(1);
readCmd->SetSLBA(5);
readCmd->SetNLB(0); // 0's based!
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq, iocq, readCmd, "read from LBA5 using hostB", true, CESTAT_RSRV_CONFLICT);
LOG_NRM("Completed ReadWriteToUnacquiredReservation::RunCoreTest")
}
示例4: SharedWritePtr
void
StartingLBABare_r10b::RunCoreTest()
{
/** \verbatim
* Assumptions:
* 1) Test CreateResources_r10b has run prior.
* \endverbatim
*/
string work;
bool enableLog;
ConstSharedIdentifyPtr namSpcPtr;
// Lookup objs which were created in a prior test within group
SharedIOSQPtr iosq = CAST_TO_IOSQ(gRsrcMngr->GetObj(IOSQ_GROUP_ID));
SharedIOCQPtr iocq = CAST_TO_IOCQ(gRsrcMngr->GetObj(IOCQ_GROUP_ID));
ConstSharedIdentifyPtr idCmdCtrlr = gInformative->GetIdentifyCmdCtrlr();
uint32_t maxDtXferSz = idCmdCtrlr->GetMaxDataXferSize();
if (maxDtXferSz == 0)
maxDtXferSz = MAX_DATA_TX_SIZE;
LOG_NRM("Prepare cmds to be send through Q's.");
SharedWritePtr writeCmd = SharedWritePtr(new Write());
SharedMemBufferPtr writeMem = SharedMemBufferPtr(new MemBuffer());
send_64b_bitmask prpBitmask = (send_64b_bitmask)
(MASK_PRP1_PAGE | MASK_PRP2_PAGE | MASK_PRP2_LIST);
SharedReadPtr readCmd = SharedReadPtr(new Read());
SharedMemBufferPtr readMem = SharedMemBufferPtr(new MemBuffer());
DataPattern dataPat[] = {
DATAPAT_INC_8BIT,
DATAPAT_CONST_8BIT,
DATAPAT_INC_16BIT,
DATAPAT_CONST_16BIT,
DATAPAT_INC_32BIT,
DATAPAT_CONST_32BIT
};
uint64_t dpArrSize = sizeof(dataPat) / sizeof(dataPat[0]);
LOG_NRM("Seeking all bare namspc's.");
vector<uint32_t> bare = gInformative->GetBareNamespaces();
for (size_t i = 0; i < bare.size(); i++) {
LOG_NRM("Processing for BARE name space id #%d", bare[i]);
namSpcPtr = gInformative->GetIdentifyCmdNamspc(bare[i]);
uint64_t ncap = namSpcPtr->GetValue(IDNAMESPC_NCAP);
uint64_t lbaDataSize = namSpcPtr->GetLBADataSize();
uint64_t maxWrBlks = maxDtXferSz / lbaDataSize;
writeMem->Init(maxWrBlks * lbaDataSize);
writeCmd->SetPrpBuffer(prpBitmask, writeMem);
writeCmd->SetNSID(bare[i]);
writeCmd->SetNLB(maxWrBlks - 1); // 0 based value.
readMem->Init(maxWrBlks * lbaDataSize);
readCmd->SetPrpBuffer(prpBitmask, readMem);
readCmd->SetNSID(bare[i]);
readCmd->SetNLB(maxWrBlks - 1); // 0 based value.
for (uint64_t nWrBlks = 0; nWrBlks < (ncap - 1); nWrBlks += maxWrBlks) {
LOG_NRM("Sending #%ld blks of #%ld", nWrBlks, (ncap -1));
for (uint64_t nLBA = 0; nLBA < maxWrBlks; nLBA++) {
writeMem->SetDataPattern(dataPat[nLBA % dpArrSize],
(nWrBlks + nLBA + 1), (nLBA * lbaDataSize), lbaDataSize);
}
writeCmd->SetSLBA(nWrBlks);
readCmd->SetSLBA(nWrBlks);
enableLog = false;
if ((nWrBlks <= maxWrBlks) || (nWrBlks >= (ncap - 2 * maxWrBlks)))
enableLog = true;
work = str(boost::format("NSID.%d.SLBA.%ld") % bare[i] % nWrBlks);
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq,
iocq, writeCmd, work, enableLog);
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq,
iocq, readCmd, work, enableLog);
VerifyDataPat(readCmd, writeMem);
}
}
}
示例5: FrmwkEx
//.........这里部分代码省略.........
vector<uint32_t> meta = gInformative->GetMetaNamespaces();
for (size_t i = 0; i < meta.size(); i++) {
LOG_NRM("Processing meta namspc id #%d of %ld", meta[i], meta.size());
if (gCtrlrConfig->SetState(ST_DISABLE) == false)
throw FrmwkEx(HERE);
// All queues will use identical IRQ vector
IRQ::SetAnySchemeSpecifyNum(1);
gCtrlrConfig->SetCSS(CtrlrConfig::CSS_NVM_CMDSET);
if (gCtrlrConfig->SetState(ST_ENABLE) == false)
throw FrmwkEx(HERE);
LOG_NRM("Create IOSQ and IOCQ with ID #%d", IOQ_ID);
CreateIOQs(asq, acq, IOQ_ID, iosq, iocq);
LOG_NRM("Get LBA format and lba data size for namespc #%d", meta[i]);
namSpcPtr = gInformative->GetIdentifyCmdNamspc(meta[i]);
LBAFormat lbaFormat = namSpcPtr->GetLBAFormat();
uint64_t lbaDataSize = (1 << lbaFormat.LBADS);
uint64_t ncap = namSpcPtr->GetValue(IDNAMESPC_NCAP);
uint64_t metaBuffSz = 0;
LOG_NRM("Set read and write buffers based on the namspc type");
switch (gInformative->IdentifyNamespace(namSpcPtr)) {
case Informative::NS_BARE:
throw FrmwkEx(HERE, "Namspc type cannot be BARE.");
case Informative::NS_METAS:
maxWrBlks = maxDtXferSz / lbaDataSize;
metaBuffSz = maxWrBlks * lbaFormat.MS;
if (gRsrcMngr->SetMetaAllocSize(metaBuffSz) == false)
throw FrmwkEx(HERE);
LOG_NRM("Max rd/wr blks %ld using separate meta buff of ncap %ld",
maxWrBlks, ncap);
writeMem->Init(maxWrBlks * lbaDataSize);
readMem->Init(maxWrBlks * lbaDataSize);
writeCmd->AllocMetaBuffer();
readCmd->AllocMetaBuffer();
break;
case Informative::NS_METAI:
maxWrBlks = maxDtXferSz / (lbaDataSize + lbaFormat.MS);
LOG_NRM("Max rd/wr blks %ld using integrated meta buff of ncap %ld",
maxWrBlks, ncap);
writeMem->Init(maxWrBlks * (lbaDataSize + lbaFormat.MS));
readMem->Init(maxWrBlks * (lbaDataSize + lbaFormat.MS));
break;
case Informative::NS_E2ES:
case Informative::NS_E2EI:
throw FrmwkEx(HERE, "Deferring work to handle this case in future");
break;
}
writeCmd->SetPrpBuffer(prpBitmask, writeMem);
writeCmd->SetNSID(meta[i]);
writeCmd->SetNLB(maxWrBlks - 1); // 0 based value.
readCmd->SetPrpBuffer(prpBitmask, readMem);
readCmd->SetNSID(meta[i]);
readCmd->SetNLB(maxWrBlks - 1); // 0 based value.
flushCmd->SetNSID(meta[i]);
for (uint64_t sLBA = 0; sLBA < maxWrBlks/*(ncap - 1)*/; sLBA += maxWrBlks) {
LOG_NRM("Processing at #%ld blk of %ld", sLBA, (ncap -1));
if ((sLBA + maxWrBlks) >= ncap) {
maxWrBlks = ncap - sLBA;
LOG_NRM("Resize max write blocks to #%ld", maxWrBlks);
ResizeDataBuf(readCmd, writeCmd, namSpcPtr, maxWrBlks,
prpBitmask);
metaBuffSz = maxWrBlks * lbaFormat.MS;
}
LOG_NRM("Sending #%ld blks starting at #%ld", maxWrBlks, sLBA);
for (uint64_t nLBA = 0; nLBA < maxWrBlks; nLBA++) {
writeMem->SetDataPattern(dataPat[nLBA % dpArrSize],
(sLBA + nLBA + 1), (nLBA * lbaDataSize), lbaDataSize);
writeCmd->SetMetaDataPattern(dataPat[nLBA % dpArrSize],
(sLBA + nLBA + 1), (nLBA * lbaFormat.MS), lbaFormat.MS);
}
writeCmd->SetSLBA(sLBA);
readCmd->SetSLBA(sLBA);
enableLog = false;
if ((sLBA <= maxWrBlks) || (sLBA >= (ncap - 2 * maxWrBlks)))
enableLog = true;
work = str(boost::format("metaID.%d.SLBA.%ld") % meta[i] % sLBA);
LOG_NRM("Sending write and read commands through ioq's");
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq,
iocq, writeCmd, work, enableLog);
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq,
iocq, flushCmd, work, enableLog);
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq,
iocq, readCmd, work, enableLog);
VerifyDataPat(readCmd, writeCmd, metaBuffSz);
}
}
}
示例6: FrmwkEx
void
AcquireReservation::RunCoreTest()
{
/** \verbatim
* Assumptions:
* None.
* \endverbatim
*/
LOG_NRM("Start AcquireReservation::RunCoreTest")
SharedIOSQPtr iosq = CAST_TO_IOSQ(gRsrcMngr->GetObj(IOSQ_GROUP_ID));
SharedIOCQPtr iocq = CAST_TO_IOCQ(gRsrcMngr->GetObj(IOCQ_GROUP_ID));
SharedASQPtr asq = CAST_TO_ASQ(gRsrcMngr->GetObj(ASQ_GROUP_ID));
SharedACQPtr acq = CAST_TO_ACQ(gRsrcMngr->GetObj(ACQ_GROUP_ID));
SharedWritePtr writeCmd = SharedWritePtr(new Write());
SharedReadPtr readCmd = SharedReadPtr(new Read());
SharedMemBufferPtr writeRegKey = SharedMemBufferPtr(new MemBuffer());
SharedMemBufferPtr lbaWriteBuffer = SharedMemBufferPtr(new MemBuffer());
SharedMemBufferPtr lbaReadBuffer = SharedMemBufferPtr(new MemBuffer());
uint8_t keyToRegister[16];
uint32_t memAlignment = sysconf(_SC_PAGESIZE);
LOG_NRM("Create ReservationAcquire Cmd and attempt to acquire NSID using wrong key (0xFA versus current 0xAD");
SharedReservationAcquirePtr reservationAcquireCmd = SharedReservationAcquirePtr(new ReservationAcquire());
reservationAcquireCmd->SetNSID(1);
reservationAcquireCmd->SetRTYPE(2);
reservationAcquireCmd->SetIEKEY(0);
reservationAcquireCmd->SetRACQA(0);
for(uint8_t keyIndex = 0; keyIndex < 8; keyIndex++) keyToRegister[keyIndex] = 0xFA;
writeRegKey->InitAlignment(8, memAlignment, false, 0x0, keyToRegister); // 0xAD should be current key...
reservationAcquireCmd->SetPrpBuffer( (send_64b_bitmask)MASK_PRP1_PAGE, writeRegKey);
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq, iocq, reservationAcquireCmd, "Acquire NSID using wrong key", true, CESTAT_RSRV_CONFLICT);
LOG_NRM("Create ReservationAcquire Cmd and attempt to acquire NSID using right key (0xAD");
for(uint8_t keyIndex = 0; keyIndex < 8; keyIndex++) keyToRegister[keyIndex] = 0xAD;
writeRegKey->InitAlignment(8, memAlignment, false, 0x0, keyToRegister); // 0xAD should be current key...
reservationAcquireCmd->SetPrpBuffer( (send_64b_bitmask)MASK_PRP1_PAGE, writeRegKey);
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq, iocq, reservationAcquireCmd, "Acquire NSID using right key", true, CESTAT_SUCCESS);
LOG_NRM("Create nvmeWrite Cmd and write 1 block of data to LBA 5, expecting a pass for HostA");
lbaWriteBuffer->Init(512, true, 0xCC);
writeCmd->SetPrpBuffer( (send_64b_bitmask)( MASK_PRP1_PAGE | MASK_PRP2_PAGE), lbaWriteBuffer);
writeCmd->SetNSID(1);
writeCmd->SetSLBA(5);
writeCmd->SetNLB(0); // 0's based!
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq, iocq, writeCmd, "write 0xCC's to LBA5", true, CESTAT_SUCCESS);
LOG_NRM("Create nvmeRead Cmd and read back 1 block of data to LBA 5, expecting a pass for HostA");
lbaReadBuffer->Init(512, true, 0x00);
readCmd->SetPrpBuffer( (send_64b_bitmask) (MASK_PRP1_PAGE | MASK_PRP2_PAGE), lbaReadBuffer);
readCmd->SetNSID(1);
readCmd->SetSLBA(5);
readCmd->SetNLB(0); // 0's based!
IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq, iocq, readCmd, "read from LBA5", true, CESTAT_SUCCESS);
LOG_NRM("Ensure the data read back matches the expected data written (0xCC's)")
if (lbaWriteBuffer->Compare(lbaReadBuffer) == false) {
LOG_NRM("Data MISMATCH!!!")
lbaWriteBuffer->Dump(
FileSystem::PrepDumpFile(mGrpName, mTestName, "Write Data"),
"write after acquire");
lbaReadBuffer->Dump(
FileSystem::PrepDumpFile(mGrpName, mTestName, "Read Data"),
"read after acquire");
throw FrmwkEx(HERE, "Data miscompare");
}
LOG_NRM("Completed AcquireReservation::RunCoreTest")
}