aboutsummaryrefslogtreecommitdiff
path: root/lib/libmuser.c
AgeCommit message (Collapse)AuthorFilesLines
2020-08-12Rename libmuser*c source filesFelipe Franciosi1-1376/+0
For clarity and better project organisation towards unit tests, this renames libmuser.c to muser_ctx.c and libmuser_pci.c to muser_pci.c. CMakeLists is fixed accordingly including some other minor cleanup. Future work should further split muser_ctx.c so that unit tests can genuinely be written towards testing compilation units. Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2020-02-28print file path for DMA map/unmapThanos Makatos1-9/+37
This should probably only be done for debug builds, and I don't think we need to print the fd. I'm enabling it for now because this is a new feature so it's good to have these messages until we're convinced it works properly. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-02-28use correct fd for DMA unmapThanos Makatos1-1/+1
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-02-25mmap fd instead of grabbing pages when receiving DMA region registrationThanos Makatos1-9/+13
This enables huge pages to work. Also, it avoids requiring having to pin memory. The solution is not 100% correct because since we no longer call vfio_pin_pages, VFIO doesn't send the DMA registration event and we end up getting duplicate regions which we reject (this is because of our internal DMA bookkeeping implementation). We need to work with the community to find a solution. fixes #28 fixes #29 fixes #38 Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2020-02-25improve readability of messages about memory rangesThanos Makatos1-11/+15
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-12-17return correct error code on device map failure from user spaceThanos Makatos1-5/+5
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-11-21lib/dma: remove DMA_MAP_FAST_IMPLSwapnil Ingle1-3/+3
muser works only with DMA_MAP_FAST_IMPL, So no need to support !DMA_MAP_FAST_IMPL implementation. Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2019-11-13return zeros when unpopulated part of PCI config space is readThanos Makatos1-17/+22
fixes #10 Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-11-08libmuser: Organise lm_ctx_create and friendsFelipe Franciosi1-91/+93
Current state of lm_ctx_create is quite messy. This cleans it up considerably, moving the pci config space creation to a separate helper. It gets rid of the 'extended' bool from dev_info, meaning that a client that wants to have a 4KiB config header should specify it on the corresponding region. This may all need reviewing later if we decide that other regions may be always handled by libmuser, in which case we can hide config, vga (and maybe rom?) entirely from our clients. Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2019-11-08Integrate with Travis CIv0.1Felipe Franciosi1-0/+1
This adds a simple .travis.yml file for integration with Travis CI. It tries to build muser.git on a Ubuntu Bionic environment using the Linux kernel 5.2.21. Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2019-11-07enable -Wall, -Wextra, and -Werror and fix all warningsThanos Makatos1-22/+30
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-11-06muser, libmuser: Do not abuse muser_cmd.mmap.response to return errSwapnil Ingle1-12/+3
muser_cmd.mmap.response is unsigned and should not be used to return errors, instead use muser_cmd.err Also fixed the code path to use valid errno values. Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2019-11-04muser.h: remove unused variable struct muser_cmd_rw.bufSwapnil Ingle1-14/+14
Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2019-11-04Hide ERR/REQ IRQs from clientsFelipe Franciosi1-6/+3
Users of libmuser do not need to know about ERR/REQ IRQs. We can later plumb the correct support to fire REQ IRQs (for graceful removal of devices) via a dedicated method (if ever needed). Similarly we should offer a method to raise an ERR IRQ accordingly. Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2019-11-04Standardise function signaturesFelipe Franciosi1-62/+70
This makes all function signatures consistent, using a line break after the return type. It also review the usage of const across the project and fixes some other minor alignment issues. Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2019-11-02Fix various format issuesFelipe Franciosi1-4/+3
Remove various spurious whitespaces and empty lines. Some other alignment issues, too. Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2019-10-03libmuser: check pointers following coding styleFelipe Franciosi1-7/+7
Coding style says pointers should be explicitly checked.
2019-10-03Minor alignment fixesFelipe Franciosi1-5/+9
2019-10-03libmuser: add default noop_cb for config regionFelipe Franciosi1-1/+8
This got broken at some point and we missed it. If a device doesn't add capabilities then reading from the config region returns short and fails. Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
2019-09-27merge FIXME commentsThanos Makatos1-2/+0
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27update comment regading using local variableThanos Makatos1-1/+1
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27use local variable for clarityThanos Makatos1-6/+6
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27fix typosThanos Makatos1-2/+3
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27don't omit number of bytes read from the standard PCI header when returning ↵Thanos Makatos1-17/+22
total number of bytes read Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27don't trigger INTx IRQ if it's disabledThanos Makatos1-0/+15
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27print offset of bad access to capabilities using hexThanos Makatos1-1/+1
All other prints for offset use hex, so let's make it consistent. Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27make debug logging more configurableThanos Makatos1-0/+7
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27add more debug messages when handling interruptsThanos Makatos1-0/+21
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27add some function documentationThanos Makatos1-0/+7
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-27add FIXME commentThanos Makatos1-0/+4
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05Minor style fixesFelipe Franciosi1-15/+15
2019-09-05Clarifications around mucmd_mmapFelipe Franciosi1-44/+34
2019-09-05remove unnecessary loop for retrieving regionThanos Makatos1-20/+19
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05destory context in lm_ctx_runThanos Makatos1-3/+7
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05don't hardcode default PCI config space sizeThanos Makatos1-1/+1
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05fix typoThanos Makatos1-1/+1
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05don't hardcode region shiftThanos Makatos1-1/+3
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05use default values for PCI config region if none specifiedThanos Makatos1-0/+12
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05fix offset to (region ID) * (1 << 40)Thanos Makatos1-4/+11
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05set IPIN if interrupts are used in dev_infoThanos Makatos1-2/+5
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05introduce convenience function lm_ctx_runThanos Makatos1-5/+6
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05log debug message when reset called w/o callbackThanos Makatos1-0/+2
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05specify subsystem and subsystem vendor ID in dev_infoThanos Makatos1-6/+4
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05log debug messages when configuring IRQ failsThanos Makatos1-2/+15
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05fix offset and size argument order in failed accessThanos Makatos1-2/+2
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05log error message when region w/o callback is accessedThanos Makatos1-0/+2
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05fix error message for bad readThanos Makatos1-1/+1
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05muser, libmuser: make libmuser_{read,write} consistentSwapnil Ingle1-14/+7
Currently muser/libmuser_write() expects mucmd as buffer, while muser/libmuser_read() expects data buffer. We arleady have the mucmd in mudev->pending, so make muser/libmuser_write() to take data buffer instead of mucmd. This way libmuser_{read,write} are consistent and we do not use mucmd sent by user. Signed-off-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
2019-09-05rename dma_scattergather_t to dma_sg_t to improve readabilityThanos Makatos1-3/+3
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
2019-09-05remove invalid comment and documentation regarding lm_irq_triggerThanos Makatos1-1/+0
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>