当前位置: 首页>>代码示例>>C++>>正文


C++ SharedGetFeaturesPtr::SetPrpBuffer方法代码示例

本文整理汇总了C++中SharedGetFeaturesPtr::SetPrpBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedGetFeaturesPtr::SetPrpBuffer方法的具体用法?C++ SharedGetFeaturesPtr::SetPrpBuffer怎么用?C++ SharedGetFeaturesPtr::SetPrpBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharedGetFeaturesPtr的用法示例。


在下文中一共展示了SharedGetFeaturesPtr::SetPrpBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FrmwkEx

void
RegisterReservation::RunCoreTest()
{
    /** \verbatim
     * Assumptions:
     * None.
     * \endverbatim
     */
	LOG_NRM("Start RegisterReservationHostB::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));
	//uint8_t keyToRegister[16];
	//uint32_t memAlignment = sysconf(_SC_PAGESIZE);
	CEStat retStat;

	LOG_NRM("Create Set features cmd to set HostID");
	SharedSetFeaturesPtr setFeaturesCmd = SharedSetFeaturesPtr(new SetFeatures());
	setFeaturesCmd->SetFID(0x81); // Host Identifier
    LOG_NRM("Create memory to contain HostID payload");
    SharedMemBufferPtr writeHostIDmem = SharedMemBufferPtr(new MemBuffer());
    // Init(uint32_t bufSize, bool initMem = false, uint8_t initVal = 0)
    writeHostIDmem->Init(8, true, 0xBB);
    //writeHostIDmem->InitAlignment(8, true, true, 0xAA); // HostID = 0xAAAAAAAAAAAAAAAA
    send_64b_bitmask prpBitmask = (send_64b_bitmask) MASK_PRP1_PAGE;
    setFeaturesCmd->SetPrpBuffer(prpBitmask, writeHostIDmem);
    IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), asq, acq, setFeaturesCmd, "Set 0xBBs hostID", true, CESTAT_SUCCESS);

	LOG_NRM("Create Get features cmd to read back HostID");
	SharedGetFeaturesPtr getFeaturesCmd = SharedGetFeaturesPtr(new GetFeatures());
	getFeaturesCmd->SetFID(0x81); // Host Identifier
    SharedMemBufferPtr readHostIDmem = SharedMemBufferPtr(new MemBuffer());
    readHostIDmem->Init(8, true, 0x00); // HostID = 0xAAAAAAAAAAAAAAAA
    getFeaturesCmd->SetPrpBuffer(prpBitmask, readHostIDmem);
    std::vector<CEStat> acceptableReturnStatuses = {CESTAT_SUCCESS, CESTAT_IGNORE};
    retStat = IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), asq, acq, getFeaturesCmd, "Read back hostID", true, acceptableReturnStatuses);
    if(retStat != CESTAT_SUCCESS) {
    	LOG_NRM("Was unable to get back HostId after setting...");
    } else {
		LOG_NRM("Compare returned HostID to what was just previously set...");
		if (writeHostIDmem->Compare(readHostIDmem) == false) {
			LOG_NRM("HostID MISMATCH!!!");
			writeHostIDmem->Dump(
				FileSystem::PrepDumpFile(mGrpName, mTestName, "WriteHostID"),
				"setFeatures HostID");
			readHostIDmem->Dump(
				FileSystem::PrepDumpFile(mGrpName, mTestName, "ReadHostId"),
				"getFeatures HostID");
			throw FrmwkEx(HERE, "Data miscompare");
		}
    }

    // HostID should be set... now we can register a key, first we will try to release
	SharedMemBufferPtr writeRegKey = SharedMemBufferPtr(new MemBuffer());
	SharedReservationRegisterPtr reservationRegisterCmd = SharedReservationRegisterPtr(new ReservationRegister());

    LOG_NRM("Release any current key with IKEY=1. If pass we cleared a key, else was already clear.");
	reservationRegisterCmd->SetNSID(1);
	reservationRegisterCmd->SetCPTPL(0); // No PTPL change
	reservationRegisterCmd->SetIEKEY(1);
	reservationRegisterCmd->SetRREGA(1); // Unregister Key
	writeRegKey->Init(16, true, 0); // 0's in buffer, IKEY will ignore CKEY/NKEY
	reservationRegisterCmd->SetPrpBuffer(prpBitmask, writeRegKey);

	std::vector<CEStat> possibleReturnStatuses = {CESTAT_SUCCESS, CESTAT_RSRV_CONFLICT, CESTAT_IGNORE};
	retStat = IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq, iocq, reservationRegisterCmd, "Release Any Key HostB", true, possibleReturnStatuses);
	switch(retStat) {
		case CESTAT_SUCCESS:
			LOG_NRM("Success status returned, a key was assumed to have been present and is now cleared.");
			break;
		case CESTAT_RSRV_CONFLICT:
			LOG_NRM("Rsrv Conflict status returned, a key was assumed have not been present to be able to be cleared.");
			break;
		default:
			LOG_NRM("Unknown stat returned back while attempting to unregister a potential exhisting key... continuing.");
	}

	LOG_NRM("Register our key (0xBD's), expecting pass");
	reservationRegisterCmd->SetNSID(1);
	reservationRegisterCmd->SetCPTPL(0); // No PTPL change
	reservationRegisterCmd->SetIEKEY(1);
	reservationRegisterCmd->SetRREGA(0); // Register Key
	writeRegKey->Init(16, true, 0xBD); // 0xAF's as arbitrary new key
	reservationRegisterCmd->SetPrpBuffer(prpBitmask, writeRegKey);
    retStat = IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq, iocq, reservationRegisterCmd, "Register Key 0xBD HostB", true, CESTAT_SUCCESS);


	//LOG_NRM("Try to register (not replace) a new key. Should always fail even with IEKEY=1 and same key as before... Expecting Rsvr Conflict.");
	// Same command as before...
	/*
	reservationRegisterCmd->SetNSID(1);
	reservationRegisterCmd->SetCPTPL(0); // No PTPL change
	reservationRegisterCmd->SetIEKEY(1);
	reservationRegisterCmd->SetRREGA(0); // Register Key
	writeRegKey->InitAlignment(16, true, 0xAE); // 0xAF's as arbitrary new key
	reservationRegisterCmd->SetPrpBuffer(prpBitmask, writeRegKey);
	*/
    //retStat = IO::SendAndReapCmd(mGrpName, mTestName, CALC_TIMEOUT_ms(1), iosq, iocq, reservationRegisterCmd, "Register Key 0xBD HostB", true, CESTAT_RSRV_CONFLICT);
//.........这里部分代码省略.........
开发者ID:davidsaOpenu,项目名称:nvmeCompl,代码行数:101,代码来源:registerReservation.cpp


注:本文中的SharedGetFeaturesPtr::SetPrpBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。