From ebde93bf9a13f2e0a853eac8fb4f33c9ecd74baf Mon Sep 17 00:00:00 2001 From: John Snow Date: Mon, 14 Nov 2016 11:15:54 -0500 Subject: ahci-test: test atapi read_cd with bcl, nb_sectors = 0 Commit 9ef2e93f introduced the concept of tagging ATAPI commands as NONDATA, but this introduced a regression for certain commands better described as CONDDATA. read_cd is such a command that both requires a non-zero BCL if a transfer size is set, but is perfectly content to accept a zero BCL if the transfer size is 0. This test adds a regression test for the case where BCL and nb_sectors are both 0. Flesh out the CDROM tests by: (1) Allowing the test to specify a BCL (2) Allowing the buffer comparison test to compare a 0-size buffer (3) Fix the BCL specification in libqos (It is LE, not BE) (4) Add a nice human-readable message for future SCSI command additions Signed-off-by: John Snow Reviewed-by: Kevin Wolf Message-id: 1477970211-25754-4-git-send-email-jsnow@redhat.com [Line length edit --js] Signed-off-by: John Snow --- tests/libqos/ahci.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tests/libqos/ahci.h') diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index caaafe3fdf..f144fab37a 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -288,6 +288,7 @@ enum { /* ATAPI Commands */ enum { CMD_ATAPI_READ_10 = 0x28, + CMD_ATAPI_READ_CD = 0xbe, }; /* AHCI Command Header Flags & Masks*/ @@ -462,12 +463,14 @@ typedef struct AHCICommand AHCICommand; /* Options to ahci_exec */ typedef struct AHCIOpts { - size_t size; - unsigned prd_size; - uint64_t lba; - uint64_t buffer; - bool atapi; - bool atapi_dma; + size_t size; /* Size of transfer */ + unsigned prd_size; /* Size per-each PRD */ + bool set_bcl; /* Override the default BCL of ATAPI_SECTOR_SIZE */ + unsigned bcl; /* Byte Count Limit, for ATAPI PIO */ + uint64_t lba; /* Starting LBA offset */ + uint64_t buffer; /* Pointer to source or destination guest buffer */ + bool atapi; /* ATAPI command? */ + bool atapi_dma; /* Use DMA for ATAPI? */ bool error; int (*pre_cb)(AHCIQState*, AHCICommand*, const struct AHCIOpts *); int (*mid_cb)(AHCIQState*, AHCICommand*, const struct AHCIOpts *); @@ -599,7 +602,7 @@ void ahci_exec(AHCIQState *ahci, uint8_t port, /* Command: Fine-grained lifecycle */ AHCICommand *ahci_command_create(uint8_t command_name); -AHCICommand *ahci_atapi_command_create(uint8_t scsi_cmd); +AHCICommand *ahci_atapi_command_create(uint8_t scsi_cmd, uint16_t bcl); void ahci_command_commit(AHCIQState *ahci, AHCICommand *cmd, uint8_t port); void ahci_command_issue(AHCIQState *ahci, AHCICommand *cmd); void ahci_command_issue_async(AHCIQState *ahci, AHCICommand *cmd); -- cgit v1.2.3 From f697b0edea426da261bff7541a66f36266d8edb0 Mon Sep 17 00:00:00 2001 From: John Snow Date: Mon, 14 Nov 2016 11:15:54 -0500 Subject: libqos/ahci: Support expected errors Sometimes we know we'll get back an error, so let's have the test framework understand that. Signed-off-by: John Snow Reviewed-by: Kevin Wolf Message-id: 1478553214-497-4-git-send-email-jsnow@redhat.com Signed-off-by: John Snow --- tests/libqos/ahci.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/libqos/ahci.h') diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index f144fab37a..bbe04f834a 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -576,7 +576,8 @@ void ahci_set_command_header(AHCIQState *ahci, uint8_t port, void ahci_destroy_command(AHCIQState *ahci, uint8_t port, uint8_t slot); /* AHCI sanity check routines */ -void ahci_port_check_error(AHCIQState *ahci, uint8_t port); +void ahci_port_check_error(AHCIQState *ahci, uint8_t port, + uint32_t imask, uint8_t emask); void ahci_port_check_interrupts(AHCIQState *ahci, uint8_t port, uint32_t intr_mask); void ahci_port_check_nonbusy(AHCIQState *ahci, uint8_t port, uint8_t slot); -- cgit v1.2.3 From 48cde0913203079036f2785b6bb274873a1a1db2 Mon Sep 17 00:00:00 2001 From: John Snow Date: Mon, 14 Nov 2016 11:15:55 -0500 Subject: libqos/ahci: Add ATAPI tray macros (1) Add START_STOP_UNIT command to ahci-test suite (2) Add eject/start macro commands; this is not a data transfer command so it is not well-served by the existing generic pipeline. Signed-off-by: John Snow Reviewed-by: Kevin Wolf Message-id: 1478553214-497-5-git-send-email-jsnow@redhat.com Signed-off-by: John Snow --- tests/libqos/ahci.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/libqos/ahci.h') diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index bbe04f834a..05ce3de47f 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -287,8 +287,9 @@ enum { /* ATAPI Commands */ enum { - CMD_ATAPI_READ_10 = 0x28, - CMD_ATAPI_READ_CD = 0xbe, + CMD_ATAPI_START_STOP_UNIT = 0x1b, + CMD_ATAPI_READ_10 = 0x28, + CMD_ATAPI_READ_CD = 0xbe, }; /* AHCI Command Header Flags & Masks*/ @@ -600,6 +601,8 @@ void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd, void *buffer, size_t bufsize, uint64_t sector); void ahci_exec(AHCIQState *ahci, uint8_t port, uint8_t op, const AHCIOpts *opts); +void ahci_atapi_eject(AHCIQState *ahci, uint8_t port); +void ahci_atapi_load(AHCIQState *ahci, uint8_t port); /* Command: Fine-grained lifecycle */ AHCICommand *ahci_command_create(uint8_t command_name); -- cgit v1.2.3 From e0a4cb2c7da23c2f0e6364214de5d84f35ce4d5d Mon Sep 17 00:00:00 2001 From: John Snow Date: Mon, 14 Nov 2016 11:15:55 -0500 Subject: libqos/ahci: Add get_sense and test_ready Required for tray tests once a medium may have changed. Signed-off-by: John Snow Reviewed-by: Kevin Wolf Message-id: 1478553214-497-6-git-send-email-jsnow@redhat.com [Line length edit --js] Signed-off-by: John Snow --- tests/libqos/ahci.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/libqos/ahci.h') diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index 05ce3de47f..5f9627bb0f 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -287,11 +287,24 @@ enum { /* ATAPI Commands */ enum { + CMD_ATAPI_TEST_UNIT_READY = 0x00, + CMD_ATAPI_REQUEST_SENSE = 0x03, CMD_ATAPI_START_STOP_UNIT = 0x1b, CMD_ATAPI_READ_10 = 0x28, CMD_ATAPI_READ_CD = 0xbe, }; +enum { + SENSE_NO_SENSE = 0x00, + SENSE_NOT_READY = 0x02, + SENSE_UNIT_ATTENTION = 0x06, +}; + +enum { + ASC_MEDIUM_MAY_HAVE_CHANGED = 0x28, + ASC_MEDIUM_NOT_PRESENT = 0x3a, +}; + /* AHCI Command Header Flags & Masks*/ #define CMDH_CFL (0x1F) #define CMDH_ATAPI (0x20) @@ -601,6 +614,10 @@ void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd, void *buffer, size_t bufsize, uint64_t sector); void ahci_exec(AHCIQState *ahci, uint8_t port, uint8_t op, const AHCIOpts *opts); +void ahci_atapi_test_ready(AHCIQState *ahci, uint8_t port, bool ready, + uint8_t expected_sense); +void ahci_atapi_get_sense(AHCIQState *ahci, uint8_t port, + uint8_t *sense, uint8_t *asc); void ahci_atapi_eject(AHCIQState *ahci, uint8_t port); void ahci_atapi_load(AHCIQState *ahci, uint8_t port); -- cgit v1.2.3