diff options
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | include/CMakeLists.txt | 40 | ||||
-rw-r--r-- | include/muser.h (renamed from lib/muser.h) | 18 | ||||
-rw-r--r-- | include/pci.h (renamed from lib/pci.h) | 8 | ||||
-rw-r--r-- | include/pci_caps/common.h (renamed from lib/caps/common.h) | 14 | ||||
-rw-r--r-- | include/pci_caps/msi.h (renamed from lib/caps/msi.h) | 12 | ||||
-rw-r--r-- | include/pci_caps/msix.h (renamed from lib/caps/msix.h) | 12 | ||||
-rw-r--r-- | include/pci_caps/pm.h (renamed from lib/caps/pm.h) | 12 | ||||
-rw-r--r-- | include/pci_caps/px.h (renamed from lib/caps/px.h) | 14 | ||||
-rw-r--r-- | include/vfio_user.h (renamed from lib/vfio_user.h) | 14 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 30 | ||||
-rw-r--r-- | lib/cap.h | 6 | ||||
-rw-r--r-- | lib/common.h | 6 | ||||
-rw-r--r-- | lib/dma.h | 6 | ||||
-rw-r--r-- | lib/irq.h | 6 | ||||
-rw-r--r-- | lib/migration.h | 35 | ||||
-rw-r--r-- | lib/muser_priv.h | 12 | ||||
-rw-r--r-- | lib/tran_sock.h | 74 | ||||
-rw-r--r-- | samples/client.c | 6 | ||||
-rw-r--r-- | samples/gpio-pci-idio-16.c | 6 | ||||
-rw-r--r-- | samples/null.c | 6 | ||||
-rw-r--r-- | samples/server.c | 8 |
22 files changed, 237 insertions, 118 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4eb23a7..04f15e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,10 @@ include(GNUInstallDirs) find_package(PkgConfig REQUIRED) pkg_check_modules(JSON REQUIRED json-c) +include_directories(${CMAKE_SOURCE_DIR}/include) +include_directories(${CMAKE_SOURCE_DIR}/lib) +include_directories(${JSON_INCLUDE_DIRS}) + set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb") # # NB: this intentionally does not define NDEBUG: we want our assert()s even in a @@ -42,12 +46,10 @@ set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb") # set(CMAKE_C_FLAGS_RELEASE "-O3") -# -# "include_directories" does *not* work here. -# -include_directories(${JSON_INCLUDE_DIRS}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wextra") +# public headers +add_subdirectory(include) # shared libraries add_subdirectory(lib) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..3639be8 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,40 @@ +# +# Copyright (c) 2019 Nutanix Inc. All rights reserved. +# +# Authors: Thanos Makatos <thanos@nutanix.com> +# Swapnil Ingle <swapnil.ingle@nutanix.com> +# Felipe Franciosi <felipe@nutanix.com> +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Nutanix nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +set(MUSER_HEADERS_DIR ${CMAKE_INSTALL_INCLUDEDIR}/muser) + +install(FILES "muser.h" DESTINATION ${MUSER_HEADERS_DIR}) +install(FILES "pci_caps/common.h" DESTINATION ${MUSER_HEADERS_DIR}/pci_caps) +install(FILES "pci_caps/msi.h" DESTINATION ${MUSER_HEADERS_DIR}/pci_caps) +install(FILES "pci_caps/msix.h" DESTINATION ${MUSER_HEADERS_DIR}/pci_caps) +install(FILES "pci_caps/pm.h" DESTINATION ${MUSER_HEADERS_DIR}/pci_caps) +install(FILES "pci_caps/px.h" DESTINATION ${MUSER_HEADERS_DIR}/pci_caps) +install(FILES "pci.h" DESTINATION ${MUSER_HEADERS_DIR}) +install(FILES "vfio_user.h" DESTINATION ${MUSER_HEADERS_DIR}) diff --git a/lib/muser.h b/include/muser.h index a71337d..7c18490 100644 --- a/lib/muser.h +++ b/include/muser.h @@ -37,12 +37,16 @@ #include <sys/uio.h> #include <unistd.h> -#include "vfio_user.h" #include "pci.h" -#include "caps/pm.h" -#include "caps/px.h" -#include "caps/msi.h" -#include "caps/msix.h" +#include "pci_caps/pm.h" +#include "pci_caps/px.h" +#include "pci_caps/msi.h" +#include "pci_caps/msix.h" +#include "vfio_user.h" + +#ifdef __cplusplus +extern "C" { +#endif #define LIB_MUSER_VFIO_USER_VERS_MJ 0 #define LIB_MUSER_VFIO_USER_VERS_MN 1 @@ -598,6 +602,10 @@ lm_ctx_get_cap(lm_ctx_t *lm_ctx, uint8_t id); void lm_log(lm_ctx_t *lm_ctx, lm_log_lvl_t lvl, const char *fmt, ...); +#ifdef __cplusplus +} +#endif + #endif /* LIB_MUSER_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/pci.h b/include/pci.h index 3d6289f..27ecf44 100644 --- a/lib/pci.h +++ b/include/pci.h @@ -37,6 +37,10 @@ #include <stdbool.h> #include <linux/pci_regs.h> +#ifdef __cplusplus +extern "C" { +#endif + /* * These are already defined in include/uapi/linux/pci_regs.h, however that * file doesn't seem to installed. @@ -199,6 +203,10 @@ typedef struct { _Static_assert(sizeof(lm_pci_config_space_t) == 0x100, "bad PCI configuration space size"); +#ifdef __cplusplus +} +#endif + #endif /* LIBMUSER_PCI_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/caps/common.h b/include/pci_caps/common.h index 2181a3b..aefa209 100644 --- a/lib/caps/common.h +++ b/include/pci_caps/common.h @@ -28,11 +28,15 @@ * */ -#ifndef LM_PCI_CAP_COMMON_H -#define LM_PCI_CAP_COMMON_H +#ifndef LIB_MUSER_PCI_CAPS_COMMON_H +#define LIB_MUSER_PCI_CAPS_COMMON_H #include <stddef.h> +#ifdef __cplusplus +extern "C" { +#endif + struct cap_hdr { uint8_t id; uint8_t next; @@ -41,6 +45,10 @@ _Static_assert(sizeof(struct cap_hdr) == 0x2, "bad PCI capability header size"); _Static_assert(offsetof(struct cap_hdr, id) == PCI_CAP_LIST_ID, "bad offset"); _Static_assert(offsetof(struct cap_hdr, next) == PCI_CAP_LIST_NEXT, "bad offset"); -#endif /* LM_PCI_CAP_COMMON_H */ +#ifdef __cplusplus +} +#endif + +#endif /* LIB_MUSER_PCI_CAPS_COMMON_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/caps/msi.h b/include/pci_caps/msi.h index 5933006..1f1a77f 100644 --- a/lib/caps/msi.h +++ b/include/pci_caps/msi.h @@ -30,11 +30,15 @@ * */ -#ifndef LM_PCI_CAP_MSI_H -#define LM_PCI_CAP_MSI_H +#ifndef LIB_MUSER_PCI_CAPS_MSI_H +#define LIB_MUSER_PCI_CAPS_MSI_H #include "common.h" +#ifdef __cplusplus +extern "C" { +#endif + struct mc { unsigned int msie:1; unsigned int mmc:3; @@ -64,6 +68,10 @@ struct msicap { _Static_assert(sizeof(struct msicap) == 0x18, "bad MSICAP size"); _Static_assert(offsetof(struct msicap, hdr) == 0, "bad offset"); +#ifdef __cplusplus +} +#endif + #endif /* LM_CAP_MSI_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/caps/msix.h b/include/pci_caps/msix.h index b0bc1a5..95447bf 100644 --- a/lib/caps/msix.h +++ b/include/pci_caps/msix.h @@ -30,11 +30,15 @@ * */ -#ifndef LM_PCI_CAP_MSIX_H -#define LM_PCI_CAP_MSIX_H +#ifndef LIB_MUSER_PCI_CAPS_MSIX_H +#define LIB_MUSER_PCI_CAPS_MSIX_H #include <linux/pci_regs.h> +#ifdef __cplusplus +extern "C" { +#endif + struct mxc { unsigned int ts:11; unsigned int reserved:3; @@ -65,6 +69,10 @@ struct msixcap { _Static_assert(sizeof(struct msixcap) == PCI_CAP_MSIX_SIZEOF, "bad MSI-X size"); _Static_assert(offsetof(struct msixcap, hdr) == 0, "bad offset"); +#ifdef __cplusplus +} +#endif + #endif /* LM_CAP_MSIX_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/caps/pm.h b/include/pci_caps/pm.h index e976d95..391deac 100644 --- a/lib/caps/pm.h +++ b/include/pci_caps/pm.h @@ -30,11 +30,15 @@ * */ -#ifndef LM_PCI_CAP_PM_H -#define LM_PCI_CAP_PM_H +#ifndef LIB_MUSER_PCI_CAPS_PM_H +#define LIB_MUSER_PCI_CAPS_PM_H #include "common.h" +#ifdef __cplusplus +extern "C" { +#endif + struct pc { unsigned int vs:3; unsigned int pmec:1; @@ -67,6 +71,10 @@ struct pmcap { _Static_assert(sizeof(struct pmcap) == PCI_PM_SIZEOF, "bad PC size"); _Static_assert(offsetof(struct pmcap, hdr) == 0, "bad offset"); +#ifdef __cplusplus +} +#endif + #endif /* LM_CAP_PM_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/caps/px.h b/include/pci_caps/px.h index 28a04d5..ac53e15 100644 --- a/lib/caps/px.h +++ b/include/pci_caps/px.h @@ -30,11 +30,15 @@ * */ -#ifndef LM_PCI_CAP_PX_H -#define LM_PCI_CAP_PX_H +#ifndef LIB_MUSER_PCI_CAPS_PX_H +#define LIB_MUSER_PCI_CAPS_PX_H #include "common.h" +#ifdef __cplusplus +extern "C" { +#endif + struct pxcaps { unsigned int ver:4; unsigned int dpt:4; @@ -145,6 +149,10 @@ _Static_assert(sizeof(struct pxcap) == 0x2a, "bad PCI Express Capability size"); _Static_assert(offsetof(struct pxcap, hdr) == 0, "bad offset"); -#endif /* LM_PCI_CAP_PX_H */ +#ifdef __cplusplus +} +#endif + +#endif /* LIB_MUSER_PCI_CAPS_PX_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/vfio_user.h b/include/vfio_user.h index 76cd84c..aeec089 100644 --- a/lib/vfio_user.h +++ b/include/vfio_user.h @@ -31,13 +31,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _VFIO_USER_H -#define _VFIO_USER_H +#ifndef VFIO_USER_H +#define VFIO_USER_H #include <inttypes.h> #include <linux/vfio.h> #include <linux/version.h> +#ifdef __cplusplus +extern "C" { +#endif + enum vfio_user_command { VFIO_USER_VERSION = 1, VFIO_USER_DMA_MAP = 2, @@ -166,8 +170,12 @@ struct vfio_iommu_type1_dirty_bitmap_get { struct vfio_bitmap bitmap; }; -#endif +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(5,8,0) */ +#ifdef __cplusplus +} #endif +#endif /* VFIO_USER_H */ + /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 683bf2e..246e0ad 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -39,14 +39,11 @@ add_library(muser SHARED $<TARGET_OBJECTS:migration> $<TARGET_OBJECTS:irq> common.h - muser.h + irq.h muser_priv.h - tran_sock.h - vfio_user.h - irq.h) + tran_sock.h) set_target_properties(muser PROPERTIES LINKER_LANGUAGE C) -set_target_properties(muser PROPERTIES PUBLIC_HEADER "muser.h;pci.h;vfio_user.h") target_link_libraries(muser json-c pthread) @@ -61,23 +58,16 @@ function(add_library_ut lib) set_target_properties(${lib_ut} PROPERTIES LINK_FLAGS ${UT_LFLAGS}) endfunction(add_library_ut) -add_library_ut(cap cap.c cap.h) -add_library_ut(dma dma.c dma.h) -add_library_ut(muser_ctx muser_ctx.c muser.h) -add_library_ut(muser_pci muser_pci.c pci.h) -add_library_ut(tran_sock tran_sock.c tran_sock.h) -add_library_ut(migration migration.c migration.h) -add_library_ut(irq irq.c irq.h) - -set(MUSER_HEADERS_DIR ${CMAKE_INSTALL_INCLUDEDIR}/muser) +add_library_ut(cap cap.c) +add_library_ut(dma dma.c) +add_library_ut(muser_ctx muser_ctx.c) +add_library_ut(muser_pci muser_pci.c) +add_library_ut(tran_sock tran_sock.c) +add_library_ut(migration migration.c) +add_library_ut(irq irq.c) install(TARGETS muser - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${MUSER_HEADERS_DIR}) - -install(DIRECTORY "caps" - DESTINATION ${MUSER_HEADERS_DIR} - FILES_MATCHING PATTERN "*.h") + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) if (DEFINED ENV{PYTHON_BINDINGS}) add_custom_target(python_bindings_build ALL @@ -30,8 +30,8 @@ * */ -#ifndef __CAP_H__ -#define __CAP_H__ +#ifndef LIB_MUSER_CAP_H +#define LIB_MUSER_CAP_H #include "muser.h" @@ -60,6 +60,6 @@ cap_maybe_access(lm_ctx_t *lm_ctx, struct caps *caps, char *buf, size_t count, uint8_t * cap_find_by_id(lm_ctx_t *lm_ctx, uint8_t id); -#endif /* __CAP_H__ */ +#endif /* LIB_MUSER_CAP_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/common.h b/lib/common.h index 41bf343..e30bc2e 100644 --- a/lib/common.h +++ b/lib/common.h @@ -34,8 +34,8 @@ * Private utilities used by the library and sample/test code. */ -#ifndef __COMMON_H__ -#define __COMMON_H__ +#ifndef LIB_MUSER_COMMON_H +#define LIB_MUSER_COMMON_H #include <stdint.h> @@ -55,6 +55,6 @@ #define ROUND_DOWN(x, a) ((x) & ~((a)-1)) #define ROUND_UP(x,a) ROUND_DOWN((x)+(a)-1, a) -#endif /* __COMMON_H__ */ +#endif /* LIB_MUSER_COMMON_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ @@ -28,8 +28,8 @@ * */ -#ifndef DMA_DMA_H -#define DMA_DMA_H +#ifndef LIB_MUSER_DMA_H +#define LIB_MUSER_DMA_H /* * FIXME check whether DMA regions must be page aligned. If so then the @@ -324,6 +324,6 @@ bool dma_controller_region_valid(dma_controller_t *dma, dma_addr_t dma_addr, size_t size); -#endif /* DMA_DMA_H */ +#endif /* LIB_MUSER_DMA_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ @@ -30,6 +30,9 @@ * */ +#ifndef LIB_MUSER_IRQ_H +#define LIB_MUSER_IRQ_H + #include "muser_priv.h" int @@ -40,3 +43,6 @@ int handle_device_set_irqs(lm_ctx_t *lm_ctx, uint32_t size, int *fds, int nr_fds, struct vfio_irq_set *irq_set); +#endif /* LIB_MUSER_IRQ_H */ + +/* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/migration.h b/lib/migration.h index 535f97b..a16d5fa 100644 --- a/lib/migration.h +++ b/lib/migration.h @@ -31,9 +31,8 @@ // FIXME: license header (and SPDX ?) everywhere -/* FIXME: regularize across private headers */ -#ifndef MUSER_MIGRATION_H -#define MUSER_MIGRATION_H +#ifndef LIB_MUSER_MIGRATION_H +#define LIB_MUSER_MIGRATION_H /* * These are not public routines, but for convenience, they are used by the @@ -44,22 +43,30 @@ #include "muser.h" -struct migration *init_migration(const lm_migration_t * const lm_migr); +struct migration * +init_migration(const lm_migration_t * const lm_migr); -ssize_t handle_migration_region_access(lm_ctx_t *lm_ctx, void *pvt, - struct migration *migr, - char *buf, size_t count, - loff_t pos, bool is_write); +ssize_t +handle_migration_region_access(lm_ctx_t *lm_ctx, void *pvt, + struct migration *migr, + char *buf, size_t count, + loff_t pos, bool is_write); -bool migration_available(lm_ctx_t *lm_ctx); +bool +migration_available(lm_ctx_t *lm_ctx); -bool device_is_stopped_and_copying(struct migration *migr); +bool +device_is_stopped_and_copying(struct migration *migr); -bool device_is_stopped(struct migration *migr); +bool +device_is_stopped(struct migration *migr); -size_t migration_get_pgsize(struct migration *migr); +size_t +migration_get_pgsize(struct migration *migr); -int migration_set_pgsize(struct migration *migr, size_t pgsize); +int +migration_set_pgsize(struct migration *migr, size_t pgsize); + +#endif /* LIB_MUSER_MIGRATION_H */ -#endif /* MUSER_MIGRATION_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/muser_priv.h b/lib/muser_priv.h index e469895..5ca63a9 100644 --- a/lib/muser_priv.h +++ b/lib/muser_priv.h @@ -30,8 +30,8 @@ * */ -#ifndef MUSER_PRIV_H -#define MUSER_PRIV_H +#ifndef LIB_MUSER_PRIV_H +#define LIB_MUSER_PRIV_H #include "dma.h" @@ -112,7 +112,8 @@ region_to_offset(uint32_t region); #define offsetofend(TYPE, MEMBER) \ (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) -static inline ssize_t get_minsz(unsigned int cmd) +static inline ssize_t +get_minsz(unsigned int cmd) { switch (cmd) { case VFIO_DEVICE_GET_INFO: @@ -145,7 +146,8 @@ static inline ssize_t get_minsz(unsigned int cmd) return -EOPNOTSUPP; } -static inline const char* vfio_cmd_to_str(int cmd) { +static inline const char * +vfio_cmd_to_str(int cmd) { switch (cmd) { case VFIO_GET_API_VERSION: return "VFIO_GET_API_VERSION"; case VFIO_CHECK_EXTENSION: return "VFIO_CHECK_EXTENSION"; @@ -173,6 +175,6 @@ static inline const char* vfio_cmd_to_str(int cmd) { return NULL; } -#endif /* MUSER_PRIV_H */ +#endif /* LIB_MUSER_PRIV_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lib/tran_sock.h b/lib/tran_sock.h index 9add12c..a4c9a17 100644 --- a/lib/tran_sock.h +++ b/lib/tran_sock.h @@ -30,8 +30,8 @@ * */ -#ifndef TRAN_SOCK_H -#define TRAN_SOCK_H +#ifndef LIB_MUSER_TRAN_SOCK_H +#define LIB_MUSER_TRAN_SOCK_H #include "muser.h" @@ -52,50 +52,56 @@ extern struct transport_ops sock_transport_ops; * Parse JSON supplied from the other side into the known parameters. Note: they * will not be set if not found in the JSON. */ -int vfio_user_parse_version_json(const char *json_str, int *client_max_fdsp, - size_t *pgsizep); +int +vfio_user_parse_version_json(const char *json_str, int *client_max_fdsp, + size_t *pgsizep); /* * Send a message to the other end. The iovecs array should leave the first * entry empty, as it will be used for the header. */ -int vfio_user_send_iovec(int sock, uint16_t msg_id, bool is_reply, - enum vfio_user_command cmd, - struct iovec *iovecs, size_t nr_iovecs, - int *fds, int count, - int err); +int +vfio_user_send_iovec(int sock, uint16_t msg_id, bool is_reply, + enum vfio_user_command cmd, + struct iovec *iovecs, size_t nr_iovecs, + int *fds, int count, + int err); /* * Send a message to the other end with the given data. */ -int vfio_user_send(int sock, uint16_t msg_id, bool is_reply, - enum vfio_user_command cmd, - void *data, size_t data_len); +int +vfio_user_send(int sock, uint16_t msg_id, bool is_reply, + enum vfio_user_command cmd, + void *data, size_t data_len); /* * Send an empty reply back to the other end with the given errno. */ -int vfio_user_send_error(int sock, uint16_t msg_id, - enum vfio_user_command cmd, - int error); +int +vfio_user_send_error(int sock, uint16_t msg_id, + enum vfio_user_command cmd, + int error); /* * Receive a message from the other end, and place the data into the given * buffer. If data is supplied by the other end, it must be exactly *len in * size. */ -int vfio_user_recv(int sock, struct vfio_user_header *hdr, - bool is_reply, uint16_t *msg_id, - void *data, size_t *len); +int +vfio_user_recv(int sock, struct vfio_user_header *hdr, + bool is_reply, uint16_t *msg_id, + void *data, size_t *len); /* * Receive a message from the other end, but automatically allocate a buffer for * it, which must be freed by the caller. If there is no data, *datap is set to * NULL. */ -int vfio_user_recv_alloc(int sock, struct vfio_user_header *hdr, - bool is_reply, uint16_t *msg_id, - void **datap, size_t *lenp); +int +vfio_user_recv_alloc(int sock, struct vfio_user_header *hdr, + bool is_reply, uint16_t *msg_id, + void **datap, size_t *lenp); /* * Send and receive a message to the other end, using iovecs for the send. The @@ -105,23 +111,25 @@ int vfio_user_recv_alloc(int sock, struct vfio_user_header *hdr, * If specified, the given fds are sent to the other side. @hdr is filled with * the reply header if non-NULL. */ -int vfio_user_msg_iovec(int sock, uint16_t msg_id, - enum vfio_user_command cmd, - struct iovec *iovecs, size_t nr_iovecs, - int *send_fds, size_t fd_count, - struct vfio_user_header *hdr, - void *recv_data, size_t recv_len); +int +vfio_user_msg_iovec(int sock, uint16_t msg_id, + enum vfio_user_command cmd, + struct iovec *iovecs, size_t nr_iovecs, + int *send_fds, size_t fd_count, + struct vfio_user_header *hdr, + void *recv_data, size_t recv_len); /* * Send and receive a message to the other end. @hdr is filled with the reply * header if non-NULL. */ -int vfio_user_msg(int sock, uint16_t msg_id, - enum vfio_user_command cmd, - void *send_data, size_t send_len, - struct vfio_user_header *hdr, - void *recv_data, size_t recv_len); +int +vfio_user_msg(int sock, uint16_t msg_id, + enum vfio_user_command cmd, + void *send_data, size_t send_len, + struct vfio_user_header *hdr, + void *recv_data, size_t recv_len); -#endif /* TRAN_SOCK_H */ +#endif /* LIB_MUSER_TRAN_SOCK_H */ /* ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/samples/client.c b/samples/client.c index 3231e60..91ce8a0 100644 --- a/samples/client.c +++ b/samples/client.c @@ -43,9 +43,9 @@ #include <sys/stat.h> #include <libgen.h> -#include "../lib/common.h" -#include "../lib/muser.h" -#include "../lib/tran_sock.h" +#include "common.h" +#include "muser.h" +#include "tran_sock.h" #define CLIENT_MAX_FDS (32) diff --git a/samples/gpio-pci-idio-16.c b/samples/gpio-pci-idio-16.c index c8d5454..d4e485f 100644 --- a/samples/gpio-pci-idio-16.c +++ b/samples/gpio-pci-idio-16.c @@ -41,9 +41,9 @@ #include <signal.h> #include <errno.h> -#include "../lib/common.h" -#include "../lib/muser.h" -#include "../lib/tran_sock.h" +#include "common.h" +#include "muser.h" +#include "tran_sock.h" static void _log(UNUSED void *pvt, UNUSED lm_log_lvl_t lvl, char const *msg) diff --git a/samples/null.c b/samples/null.c index 2dd1bdd..97c3fcf 100644 --- a/samples/null.c +++ b/samples/null.c @@ -40,9 +40,9 @@ #include <errno.h> #include <string.h> -#include "../lib/common.h" -#include "../lib/muser.h" -#include "../lib/tran_sock.h" +#include "common.h" +#include "muser.h" +#include "tran_sock.h" static void null_log(UNUSED void *pvt, UNUSED lm_log_lvl_t lvl, char const *msg) diff --git a/samples/server.c b/samples/server.c index d0482d2..432d0ce 100644 --- a/samples/server.c +++ b/samples/server.c @@ -44,9 +44,9 @@ #include <sys/param.h> #include <sys/time.h> -#include "../lib/common.h" -#include "../lib/muser.h" -#include "../lib/tran_sock.h" +#include "common.h" +#include "muser.h" +#include "tran_sock.h" struct dma_regions { uint64_t addr; @@ -65,7 +65,7 @@ struct server_data { __u64 data_size; void *migr_data; size_t migr_data_len; - lm_migr_state_t state; + lm_migr_state_t state; } migration; }; |