summaryrefslogtreecommitdiff
path: root/tests/ahci-test.c
AgeCommit message (Collapse)AuthorFilesLines
2015-02-16libqos/ahci: Add command header helpersJohn Snow1-20/+23
Adds command header helper functions: -ahci_command_header_set -ahci_command_header_get, -ahci_command_destroy, and -ahci_cmd_pick These helpers help to quickly manage the command header information in the AHCI device. ahci_command_header_set and get will store or retrieve an AHCI command header, respectively. ahci_cmd_pick chooses the first available but least recently used command slot to allow us to cycle through the available command slots. ahci_command_destroy obliterates all information contained within a given slot's command header, and frees its associated command table, but not its DMA buffer! Lastly, the command table pointer fields (dba and dbau) are merged into a single 64bit value to make managing 64bit tests simpler. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1423158090-25580-5-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16qtest/ahci: rename 'Command' to 'CommandHeader'John Snow1-4/+4
The structure name is a bit of a misnomer; the structure currently named command is actually the commandheader. A future patch in this series will add an actual "Command" structure, so we'll rename it now before the rest of the functions in this series try to use it. In addition, rename the "b1" and "b2" fields to be a unified uint16_t named "flags." Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1423158090-25580-4-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16libqos/ahci: Add ahci_port_clear helperJohn Snow1-7/+2
Add a helper that assists in clearing out potentially old error and FIS information from an AHCI port's data structures. This ensures we always start with a blank slate for interrupt and FIS receipt information. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1423158090-25580-3-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16libqos/ahci: Add ahci_port_select helperJohn Snow1-17/+2
This helper identifies which port of the AHCI HBA has a device we may run tests on. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1423158090-25580-2-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16libqos/ahci: create libqos/ahci.cJohn Snow1-225/+0
With global state removed, code responsible for booting up, verifying, and initializing the AHCI HBA is extracted and inserted into libqos/ahci.c, which would allow for other qtests in the future to quickly grab a meaningfully initialized reference to an AHCI HBA. Even without other users, functionalizing and isolating the code assists future AHCI tests that exercise Q35 migration. For now, libqos/ahci.o will be PC-only, but can be expanded into something arch-agnostic in the future, if needed. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-16-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16qtest/ahci: Bookmark FB and CLB pointersJohn Snow1-22/+20
Instead of re-querying the AHCI device for the FB and CLB buffers, save the pointer we gave to the device during initialization and reference these values instead. [Peter Maydell <peter.maydell@linaro.org> reported the following clang compiler warnings: tests/libqos/ahci.c:256:40: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat] g_test_message("CLB: 0x%08lx", ahci->port[i].clb); tests/libqos/ahci.c:264:39: warning: format specifies type 'unsigned long' but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat] g_test_message("FB: 0x%08lx", ahci->port[i].fb); The commit moved from uint32_t to uint64_t, so PRIx64 should be used for the format specifier. --Stefan] Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-15-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16qtest/ahci: remove getter/setter macrosJohn Snow1-95/+83
These macros were a bad idea: They relied upon certain arguments being present locally with a specific name. With the endgoal being to factor out AHCI helper functions outside of the test file itself, these have to be replaced by more explicit helper setter/getter functions. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-14-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16libqos/ahci: Functional register helpersJohn Snow1-14/+11
Introduce a set of "static inline" register helpers that are intended to replace the current set of macros with more functional versions that are better suited to inclusion in libqos than porcelain macros. As a stopgap measure before eliminating the porcelain macros, define them to use the new functions defined in the ahci.h header. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-13-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16qtest/ahci: remove guest_malloc globalJohn Snow1-9/+9
Make helper routines rely on the earmarked guest allocator object with AHCIQState/QOSSTate instead. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-12-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16qtest/ahci: remove pcibus globalJohn Snow1-8/+6
Rely on the PCI Device's bus pointer instead. One less global to worry about. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-11-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16qtest/ahci: finalize AHCIQState consolidationJohn Snow1-42/+38
Move barsize, ahci_fingerprint and capabilities registers into the AHCIQState object, removing global ahci-related state from the ahci-test.c file. More churn, less globals. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-10-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16qtest/ahci: Store hba_base in AHCIQStateJohn Snow1-72/+64
Store the HBA memory base address in the new state object, to simplify function prototypes and encourage a more functional testing style. This causes a lot of churn, but this patch is as "simplified" as I could get it to be. This patch is therefore fairly mechanical and straightforward: Any case where we pass "hba_base" has been consolidated into the AHCIQState object and we pass the one unified parameter. Any case where we reference "ahci" and "hba_state" have been modified to use "ahci->dev" for the PCIDevice and "ahci->hba_state" to get at the base memory address, accordingly. Notes: - A needless return is removed from start_ahci_device. - For ease of reviewing, this patch can be reproduced (mostly) by: # Replace (ahci, hba_base) prototypes with unified parameter 's/(QPCIDevice \*ahci, void \*\?\*hba_base/(AHCIQState *ahci/' # Replace (ahci->dev, hba_base) calls with unified parameter 's/(ahci->dev, &\?hba_base)/(ahci)/' # Replace calls to PCI config space using "ahci" with "ahci->dev" 's/qpci_config_\(read\|write\)\(.\)(ahci,/qpci_config_\1\2(ahci->dev,/' After these, the remaining differences are easy to review by hand. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-9-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16libqos: add pc specific interfaceJohn Snow1-2/+2
Create an operations structure so that the libqos interface can be architecture agnostic, and create a pc-specific interface to functions like qtest_boot. Move the libqos object in the Makefile from being ahci-test only to being linked with all tests that utilize the libqos features. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-8-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16libqos: create libqos.cJohn Snow1-54/+37
The intent of this file is to serve as a misc. utilities file to be shared amongst tests that are utilizing libqos facilities. In a later patch, migration test helpers will be added to libqos.c that will allow simplified testing of migration cases where libqos is "Just Enough OS" for migrations testing. The addition of the AHCIQState structure will also allow us to eliminate global variables inside of qtests to manage allocators and test instances in a better, more functional way. libqos.c: - Add qtest_boot - Add qtest_shutdown libqos.h: - Create QOSState structure for allocator and QTestState. ahci-test.c: - Move qtest_boot and qtest_shutdown to libqos.c/h - Create AHCIQState to interface with new qtest_boot/shutdown prototypes - Modify tests slightly to use new types. For now, the new object file is only linked to ahci-test, because it still relies on pc architecture specific code in libqos. The next two patches will reorganize the code to be more general. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-4-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-02-16qtest/ahci: Create ahci.hJohn Snow1-318/+1
Extract defines and other information to ahci.h, to be shared with other tests if they so please. At the very least, reduce clutter in the test file itself. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1421698563-6977-3-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2015-01-15misc: Fix new typos in commentsStefan Weil1-1/+1
recieve -> receive suprise -> surprise Cc: Igor Mammedov <imammedo@redhat.com> Cc: John Snow <jsnow@redhat.com> Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: John Snow <jsnow@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2014-12-10qtests: Specify image format explicitlyKevin Wolf1-1/+2
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 1416497234-29880-5-git-send-email-kwolf@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-09-22ahci: Add test_identify case to ahci-test.John Snow1-0/+304
Utilizing all of the bring-up code in pci_enable and hba_enable, this test issues a simple IDENTIFY command via the HBA and retrieves the response via the PIO receive mechanisms of the HBA. Bugs: The DPS interrupt (Descriptor Processed Status) does not currently get set. This will need to be adjusted in a future patch series when the AHCI DMA pathways are reworked to allow the feature, which may be utilized by OSX guests. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1408643079-30675-9-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-09-22ahci: Add test_hba_enable to ahci-test.John Snow1-0/+156
This test engages the HBA functionality and initializes values to sane defaults to allow for minimal HBA functionality. Buffers are allocated and pointers are updated to allow minimal I/O commands to complete as expected. Error registers and responses are sanity checked for specification adherence. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1408643079-30675-8-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-09-22ahci: Add test_hba_spec to ahci-test.John Snow1-1/+560
Add a test routine that checks the boot-up values of the HBA configuration memory space against the AHCI 1.3 specification and Intel ICH9 data sheet (for Q35 machines) for adherence and sane values. The HBA is not yet engaged or put into the idle state. [Replaced g_assert_false(...) with g_assert(!...) for glib <2.38 compatibility, reported by Peter Maydell <peter.maydell@linaro.org>. --Stefan] Signed-off-by: John Snow <jsnow@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 1408643079-30675-7-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-09-22ahci: add test_pci_enable to ahci-test.John Snow1-0/+53
This adds a test wherein we engage the PCI AHCI device and ensure that the memory region for the HBA functionality is now accessible. Under Q35 environments, additional PCI configuration is performed to ensure that the HBA functionality will become usable. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1408643079-30675-5-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-09-22ahci: Add test_pci_spec to ahci-test.John Snow1-6/+299
Adds a specification adherence test for AHCI where the boot-up values for the PCI configuration space are compared against the AHCI 1.3 specification. This test does not itself attempt to engage the device. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1408643079-30675-4-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-09-22ahci: Adding basic functionality qtest.John Snow1-0/+196
Currently, there is no qtest to test the functionality of the AHCI functionality present within the Q35 machine type. This patch adds a skeleton for an AHCI test suite, and adds a simple sanity-check test case where we identify that the AHCI device is present, then disengage the virtual machine. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1408643079-30675-2-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>