Exemplo n.º 1
0
def test_reset_with_outstanding_io(nvme0, nvme0n1, delay, io_count=100):
    nvme0n1.format(512)
    logging.debug("format done")

    cq = IOCQ(nvme0, 1, 128, PRP(1024 * 64))
    sq = IOSQ(nvme0, 1, 128, PRP(1024 * 64), cqid=1)

    write_cmd = SQE(1, 1)
    write_cmd[12] = 7  # 4K write
    buf_list = []
    for i in range(io_count):
        buf = PRP(ptype=32, pvalue=i)  # use cid as data pattern
        buf_list.append(buf)
        write_cmd.prp1 = buf
        write_cmd.cid = i
        write_cmd[10] = i
        sq[i] = write_cmd
    sq.tail = io_count

    # reset while io is active
    logging.debug("write done")
    time.sleep(delay)
    nvme0.reset()

    # read after reset with outstanding writes
    cq = IOCQ(nvme0, 1, 128, PRP(1024 * 64))
    sq = IOSQ(nvme0, 1, 128, PRP(1024 * 64), cqid=1)

    read_cmd = SQE(2, 1)
    read_cmd[12] = 7  # 4K read
    buf_list = []
    for i in range(io_count):
        buf = PRP()
        buf_list.append(buf)
        read_cmd.prp1 = buf
        read_cmd.cid = i
        read_cmd[10] = i
        sq[i] = read_cmd
    sq.tail = io_count
    logging.debug("read done")

    # data verify
    time.sleep(3)
    assert cq[io_count - 1].p != 0
    for i in range(io_count):
        cid = cq[i].cid
        dp = buf_list[cq[i].cid].data(3, 0)  # check data pattern
        logging.debug("cpl %d: cid %d, data pattern %d" % (i, cid, dp))
        assert dp == 0 or dp == cid

    sq.delete()
    cq.delete()
Exemplo n.º 2
0
def test_write_mdts(nvme0, mdts):

    cq = IOCQ(nvme0, 1, 2, PRP())
    sq = IOSQ(nvme0, 1, 2, PRP(), cqid=1)

    # prp for the long buffer
    write_buf_1 = PRP(ptype=32, pvalue=0xaaaaaaaa)
    pages = mdts // 8
    pages -= 1

    prp_list = PRPList()
    prp_list_head = prp_list
    while pages:
        for i in range(511):
            if pages:
                prp_list[i] = PRP()
                pages -= 1
                logging.debug(pages)
        if pages > 1:
            tmp = PRPList()
            prp_list[511] = tmp
            prp_list = tmp
            logging.debug("prp_list")
        elif pages == 1:
            prp_list[511] = PRP()
            pages -= 1
            logging.debug(pages)

    w1 = SQE(1, 1)
    w1.prp1 = write_buf_1
    w1.prp2 = prp_list_head
    w1[12] = mdts - 1  # 0based, nlba
    w1.cid = 0x123
    sq[0] = w1
    sq.tail = 1

    time.sleep(1)
    cqe = CQE(cq[0])
    logging.info(cqe)
    assert cqe.p == 1
    assert cqe.cid == 0x123
    assert cqe.sqhd == 1
    logging.info("cqe status is {}".format(cqe.status))
    assert cqe.status == 0 or cqe.status == 2
    cq.head = 1

    sq.delete()
    cq.delete()
Exemplo n.º 3
0
def test_p_invert_after_cq_2_pass(nvme0):
    """
    The value of the Phase Tag is inverted each pass filling the Complete Queue.
    """

    # cqid: 1, PC, depth: 2
    cq = IOCQ(nvme0, 1, 2, PRP())

    # create four SQ, both use the same CQ
    sq3 = IOSQ(nvme0, 3, 10, PRP(), cqid=1)

    # IO command templates: opcode and namespace
    write_cmd = SQE(1, 1)

    # write in sq3
    w1 = SQE(*write_cmd)
    write_buf = PRP(ptype=32, pvalue=0xaaaaaaaa)
    w1.prp1 = write_buf
    w1[10] = 1
    w1[12] = 1 # 0based
    w1.cid = 0x123
    sq3[0] = w1
    sq3.tail = 1

    # add some delay, so ssd should finish w1 before w2
    time.sleep(0.1)

    # write in sq5
    w1.cid = 0x567
    sq3[1] = w1
    sq3.tail = 2

    logging.info("aaa")
    # cqe for w1
    while CQE(cq[0]).p == 0: pass
    cqe = CQE(cq[0])
    assert cqe.cid == 0x123
    assert cqe.sqid == 3
    assert cqe.sqhd == 1
    cq.head = 1

    # cqe for w2
    logging.info("bbb")
    while CQE(cq[1]).p == 0: pass
    logging.info("ccc")
    cqe = CQE(cq[1])
    assert cqe.cid == 0x567
    assert cqe.sqid == 3
    assert cqe.sqhd == 2
    cq.head = 0

    assert CQE(cq[0]).p == 1
    assert CQE(cq[1]).p == 1

    # write in sq3
    w1.cid = 0x147
    sq3[2] = w1
    sq3.tail = 3

    # add some delay, so ssd should finish w1 before w2
    time.sleep(0.1)

    # write in sq5
    w1.cid = 0x167
    sq3[3] = w1
    sq3.tail = 4

    # cqe for w3
    while CQE(cq[0]).p == 1: pass
    cqe = CQE(cq[0])
    assert cqe.cid == 0x147
    assert cqe.sqid == 3
    assert cqe.sqhd == 3
    cq.head = 1

    # cqe for w4
    while CQE(cq[1]).p == 1: pass
    cqe = CQE(cq[1])
    assert cqe.cid == 0x167
    assert cqe.sqid == 3
    assert cqe.sqhd == 4
    cq.head = 0

    assert CQE(cq[0]).p == 0
    assert CQE(cq[1]).p == 0
Exemplo n.º 4
0
def test_controller_mdts(nvme0,nvme0n1):
    if nvme0.mdts == 1024*1024: # up to 1MB
        pytest.skip("mdts is maximum")

    mps_min = (nvme0.cap>>48) & 0xf
    logging.info("mps_min:{}".format(mps_min))

    mdts=nvme0.id_data(77,77)
    logging.info("mdts:{}".format(mdts))
    max_data_size=(2**mdts)*(2**(12+mps_min))
    logging.info(max_data_size)
    max_pages=max_data_size//4//1024
    pages=max_pages-1
    max_lba=max_data_size//512

    cq = IOCQ(nvme0, 1, 5, PRP())
    sq = IOSQ(nvme0, 1, 5, PRP(), cqid=1)

    # prp for the long buffer
    write_buf_1 = PRP(ptype=32, pvalue=0xaaaaaaaa)
    prp_list = PRPList()
    prp_list_head = prp_list
    while pages:
        for i in range(511):
            if pages:
                prp_list[i] = PRP()
                pages -= 1
                logging.debug(pages)

        if pages>1:
            tmp = PRPList()
            prp_list[511] = tmp
            prp_list = tmp
            logging.debug("prp_list")

        elif pages==1:
            prp_list[511] = PRP()
            pages -= 1
            logging.debug(pages)

    w1 = SQE(1, 1)
    w1.prp1 = write_buf_1
    w1.prp2 = prp_list_head
    w1[12] = max_lba-1 # 0based, nlba
    w1.cid = 0x123
    sq[0] = w1
    sq.tail = 1

    time.sleep(1)
    cqe = CQE(cq[0])
    logging.info(cqe)
    assert cqe.p == 1
    assert cqe.cid == 0x123
    assert cqe.sqhd == 1
    assert cqe.status == 0
    cq.head = 1

    w2 = SQE(1, 1)
    w2.prp1 = write_buf_1
    w2.prp2 = prp_list_head
    w2[12] = max_lba # 0based, nlba
    w2.cid = 0x234
    sq[1] = w2
    sq.tail = 2

    time.sleep(1)
    cqe = CQE(cq[1])
    logging.info(cqe)
    assert cqe.p == 1
    assert cqe.cid == 0x234
    assert cqe.sqhd == 2
    assert cqe.status == 2
    cq.head = 2

    r1 = SQE(2, 1)
    r1.prp1 = write_buf_1
    r1.prp2 = prp_list_head
    r1[12] = max_lba # 0based, nlba
    r1.cid = 0x345
    sq[2] = r1
    sq.tail = 3

    time.sleep(1)
    cqe = CQE(cq[2])
    logging.info(cqe)
    assert cqe.p == 1
    assert cqe.cid == 0x345
    assert cqe.sqhd == 3
    assert cqe.status == 2
    cq.head = 3

    r2 = SQE(2, 1)
    r2.prp1 = write_buf_1
    r2.prp2 = prp_list_head
    r2[12] = max_lba-1 # 0based, nlba
    r2.cid = 0x456
    sq[3] = r2
    sq.tail = 4

    time.sleep(1)
    cqe = CQE(cq[3])
    logging.info(cqe)
    assert cqe.p == 1
    assert cqe.cid == 0x456
    assert cqe.sqhd == 4
    assert cqe.status == 0
    cq.head = 4

    sq.delete()
    cq.delete()