Beispiel #1
0
def test_sanitize(nvme0: d.Controller, buf):
    if nvme0.id_data(331, 328) == 0:
        pytest.skip("sanitize operation is not supported")

    import PySimpleGUI as sg

    logging.info("supported sanitize operation: %d" % nvme0.id_data(331, 328))
    sg.OneLineProgressMeter('sanitize progress',
                            0,
                            100,
                            'progress',
                            orientation='h')
    nvme0n1 = d.Namespace(nvme0, 1, 128 * 1000 * 1000 // 4)
    nvme0.sanitize().waitdone()  # sanitize clears namespace

    # check sanitize status in log page
    nvme0.getlogpage(0x81, buf, 20).waitdone()
    while buf.data(3, 2) & 0x7 != 1:  # sanitize operation is not completed
        time.sleep(1)
        nvme0.getlogpage(0x81, buf, 20).waitdone()
        progress = buf.data(1, 0) * 100 // 0xffff
        sg.OneLineProgressMeter('sanitize progress',
                                progress,
                                100,
                                'progress',
                                orientation='h')
        logging.info("%d%%" % progress)

    nvme0n1.close()
Beispiel #2
0
def test_trim_basic(nvme0: d.Controller, nvme0n1, verify, qpair):
    GB = 1024 * 1024 * 1024
    all_zero_databuf = d.Buffer(512)
    orig_databuf = d.Buffer(512)
    trimbuf = d.Buffer(4096)

    # DUT info
    logging.info("model number: %s" % nvme0.id_data(63, 24, str))
    logging.info("firmware revision: %s" % nvme0.id_data(71, 64, str))

    # write
    logging.info("write data in 10G ~ 20G")
    io_size = 128 * 1024 // 512
    start_lba = 10 * GB // 512
    lba_count = 10 * GB // 512
    nvme0n1.ioworker(io_size=io_size,
                     lba_align=io_size,
                     lba_random=False,
                     read_percentage=0,
                     lba_start=start_lba,
                     io_count=lba_count // io_size,
                     qdepth=128).start().close()

    nvme0n1.read(qpair, orig_databuf, start_lba).waitdone()

    # verify data after write, data should be modified
    with pytest.warns(UserWarning, match="ERROR status: 02/85"):
        nvme0n1.compare(qpair, all_zero_databuf, start_lba).waitdone()

    # get the empty trim time
    trimbuf.set_dsm_range(0, 0, 0)
    trim_cmd = nvme0n1.dsm(qpair, trimbuf,
                           1).waitdone()  # first call is longer, due to cache?
    start_time = time.time()
    trim_cmd = nvme0n1.dsm(qpair, trimbuf, 1).waitdone()
    empty_trim_time = time.time() - start_time

    # the trim time on device-side only
    logging.info("trim the 10G data from LBA 0x%lx" % start_lba)
    trimbuf.set_dsm_range(0, start_lba, lba_count)
    start_time = time.time()
    trim_cmd = nvme0n1.dsm(qpair, trimbuf, 1).waitdone()
    trim_time = time.time() - start_time - empty_trim_time
    logging.info("trim bandwidth: %0.2fGB/s" % (10 / trim_time))

    # verify after trim
    nvme0n1.compare(qpair, all_zero_databuf, start_lba).waitdone()
    nvme0n1.compare(qpair, orig_databuf, start_lba).waitdone()
Beispiel #3
0
def test_dsm_trim(nvme0: d.Controller, nvme0n1: d.Namespace, qpair: d.Qpair):
    trimbuf = d.Buffer(4096)

    # DUT info
    logging.info("model number: %s" % nvme0.id_data(63, 24, str))
    logging.info("firmware revision: %s" % nvme0.id_data(71, 64, str))

    # single range
    start_lba = 0
    lba_count = 8 * 1024
    trimbuf.set_dsm_range(0, start_lba, lba_count)
    nvme0n1.dsm(qpair, trimbuf, 1, attribute=0x4).waitdone()

    # multiple range
    lba_count = lba_count // 256
    for i in range(256):
        trimbuf.set_dsm_range(i, start_lba + i * lba_count, lba_count)
    nvme0n1.dsm(qpair, trimbuf, 256).waitdone()
Beispiel #4
0
def test_sanitize(nvme0: d.Controller, nvme0n1, buf):
    if nvme0.id_data(331, 328) == 0:
        pytest.skip("sanitize operation is not supported")

    logging.info("supported sanitize operation: %d" % nvme0.id_data(331, 328))
    nvme0.sanitize().waitdone()  # sanitize command is completed

    # check sanitize status in log page
    nvme0.getlogpage(0x81, buf, 20).waitdone()
    while buf.data(3, 2) & 0x7 != 1:  # sanitize operation is not completed
        progress = buf.data(1, 0) * 100 // 0xffff
        #sg.OneLineProgressMeter('sanitize progress', progress, 100, 'progress', orientation='h')
        logging.info("%d%%" % progress)
        nvme0.getlogpage(0x81, buf, 20).waitdone()
        time.sleep(1)
def nvme0(pcie):
    return Controller(pcie, nvme_init_func=nvme_init_wrr)
Beispiel #6
0
def test_format(nvme0: d.Controller, nvme0n1):
    nvme0.format(0).waitdone()
Beispiel #7
0
def test_aer_sanitize(pcie, buf):
    # aer callback function
    aer_cdw0 = 0

    def aer_cb(cdw0, status):
        nonlocal aer_cdw0
        aer_cdw0 = cdw0

    def nvme_init(nvme0):
        # 2. disable cc.en and wait csts.rdy to 0
        nvme0[0x14] = 0
        while not (nvme0[0x1c] & 0x1) == 0:
            pass

        # 3. set admin queue registers
        nvme0.init_adminq()

        # 4. set register cc
        nvme0[0x14] = 0x00460000

        # 5. enable cc.en
        nvme0[0x14] = 0x00460001

        # 6. wait csts.rdy to 1
        while not (nvme0[0x1c] & 0x1) == 1:
            pass

        # 7. identify controller
        nvme0.identify(Buffer(4096)).waitdone()

        # 8. create and identify all namespace
        nvme0.init_ns()

        # 9. set/get num of queues
        nvme0.setfeatures(0x7, cdw11=0x00ff00ff).waitdone()
        nvme0.getfeatures(0x7).waitdone()

        # 10. send out all aer
        aerl = nvme0.id_data(259) + 1
        for i in range(aerl):
            nvme0.aer(cb=aer_cb)

    nvme0 = Controller(pcie, nvme_init_func=nvme_init)
    if nvme0.id_data(331, 328) == 0:
        pytest.skip("sanitize operation is not supported")

    logging.info("supported sanitize operation: %d" % nvme0.id_data(331, 328))
    nvme0.sanitize().waitdone()  # sanitize command is completed

    # check sanitize status in log page
    with pytest.warns(UserWarning, match="AER notification is triggered"):
        nvme0.getlogpage(0x81, buf, 20).waitdone()
        while buf.data(3, 2) & 0x7 != 1:  # sanitize operation is not completed
            time.sleep(1)
            nvme0.getlogpage(0x81, buf, 20).waitdone()  #L20
            progress = buf.data(1, 0) * 100 // 0xffff
            logging.info("%d%%" % progress)

    # check sanitize status
    nvme0.getlogpage(0x81, buf, 20).waitdone()
    assert buf.data(3, 2) & 0x7 == 1

    # test sanitize once more with new aer
    nvme0.sanitize().waitdone()  # sanitize command is completed
    with pytest.warns(UserWarning, match="AER notification is triggered"):
        nvme0.getlogpage(0x81, buf, 20).waitdone()
        while buf.data(3, 2) & 0x7 != 1:  # sanitize operation is not completed
            time.sleep(1)
            nvme0.getlogpage(0x81, buf, 20).waitdone()  #L20
            progress = buf.data(1, 0) * 100 // 0xffff
            logging.info("%d%%" % progress)
    assert aer_cdw0 == 0x810106