mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-30 00:00:15 +01:00
Working up to modify/server.
This commit is contained in:
parent
3b70297dbe
commit
4ba0acf58c
26 changed files with 7216 additions and 1350 deletions
|
@ -373,32 +373,3 @@ oom:
|
|||
LOG_ERROR("BUG: Failed to init mm!\n");
|
||||
while(1) {HALT; }
|
||||
}
|
||||
|
||||
void * ib_memory_init(void)
|
||||
{
|
||||
size_t phyaddr, viraddr, bits;
|
||||
int err;
|
||||
|
||||
phyaddr = (size_t) &kernel_end - IB_MEMORY_SIZE;
|
||||
bits = PG_RW|PG_GLOBAL|PG_NX;
|
||||
viraddr = vma_alloc(IB_MEMORY_NPAGES * PAGE_SIZE, VMA_READ|VMA_WRITE|VMA_CACHEABLE);
|
||||
if (BUILTIN_EXPECT(!viraddr, 0)) {
|
||||
LOG_INFO("BUILTIN_EXPECT failed: ib_memory_init 1\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LOG_INFO("ib_memory_init, size: %lu\n", IB_MEMORY_SIZE);
|
||||
LOG_INFO("\tGuest Phys Start: %p\tEnd: %p\n", (uint8_t *) phyaddr, (uint8_t *) &kernel_end);
|
||||
/* LOG_INFO("\tHost Virt Start: %p\tEnd: %p\n", */
|
||||
/* phyaddr + host_kernel_start, (size_t) &kernel_end + host_kernel_start); */
|
||||
|
||||
err = page_map(viraddr, phyaddr, IB_MEMORY_NPAGES, bits);
|
||||
if (BUILTIN_EXPECT(err, 0)) {
|
||||
LOG_INFO("BUILTIN_EXPECT failed: ib_memory_init 2\n");
|
||||
vma_free(viraddr, viraddr + IB_MEMORY_NPAGES*PAGE_SIZE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LOG_INFO("ib_memory_init finished\n");
|
||||
return (void *) viraddr;
|
||||
}
|
||||
|
|
|
@ -118,10 +118,14 @@ size_t virt_to_phys(size_t addr)
|
|||
size_t phys_to_virt(size_t phy)
|
||||
{
|
||||
LOG_INFO("phys_to_virt called.\n");
|
||||
LOG_INFO("phy: Hex: %zx\n", phy);
|
||||
size_t pfn = phy & PFN_MASK;
|
||||
size_t off = phy & ~PAGE_MASK;
|
||||
LOG_INFO("off: Hex: %zx, Dec: %zd\n", off, off);
|
||||
LOG_INFO("pfn: Hex: %zx, Dec: %zd\n", pfn, pfn);
|
||||
if (phy == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t * pml4 = self[PAGE_LEVELS-1];
|
||||
for(size_t i=0; i<(1 << PAGE_MAP_BITS); i++) {
|
||||
|
@ -149,23 +153,23 @@ size_t phys_to_virt(size_t phy)
|
|||
/* LOG_INFO("Fourth for.\n"); */
|
||||
|
||||
if (pgt[l] & PG_PRESENT) { // Valid page table entry
|
||||
/* LOG_INFO("Present.\n"); */
|
||||
/* LOG_INFO("p"); */
|
||||
if ((pgt[l] & PFN_MASK) == pfn) { // Page frame found
|
||||
LOG_INFO("SAME PAGE.\n");
|
||||
LOG_INFO("i: Hex: %zx, Dec: %zd\n", i, i);
|
||||
LOG_INFO("j: Hex: %zx, Dec: %zd\n", j, j);
|
||||
LOG_INFO("k: Hex: %zx, Dec: %zd\n", k, k);
|
||||
LOG_INFO("l: Hex: %zx, Dec: %zd\n", l, l);
|
||||
/* LOG_INFO("i: Hex: %zx, Dec: %zd\n", i, i); */
|
||||
/* LOG_INFO("j: Hex: %zx, Dec: %zd\n", j, j); */
|
||||
/* LOG_INFO("k: Hex: %zx, Dec: %zd\n", k, k); */
|
||||
/* LOG_INFO("l: Hex: %zx, Dec: %zd\n", l, l); */
|
||||
size_t vpn = ((((((i << PAGE_MAP_BITS) | j) << PAGE_MAP_BITS) | k) << PAGE_MAP_BITS) | l) << PAGE_BITS;
|
||||
LOG_INFO("vpn: Hex: %zx, Dec: %zd\n", vpn, vpn);
|
||||
/* LOG_INFO("vpn: Hex: %zx, Dec: %zd\n", vpn, vpn); */
|
||||
size_t sext = i & (1UL << (PAGE_MAP_BITS - 1));
|
||||
LOG_INFO("sext: Hex: %zx, Dec: %zd\n", sext, sext);
|
||||
/* LOG_INFO("sext: Hex: %zx, Dec: %zd\n", sext, sext); */
|
||||
if (sext) {
|
||||
LOG_INFO("sext true");
|
||||
/* LOG_INFO("sext true"); */
|
||||
vpn |= ~0UL << VIRT_BITS;
|
||||
LOG_INFO("vpn: Hex: %zx, Dec: %zd\n", vpn, vpn);
|
||||
/* LOG_INFO("vpn: Hex: %zx, Dec: %zd\n", vpn, vpn); */
|
||||
}
|
||||
LOG_INFO("return: Hex: %zx, Dec: %zd\n", vpn | off, vpn | off);
|
||||
/* LOG_INFO("return: Hex: %zx, Dec: %zd\n", vpn | off, vpn | off); */
|
||||
return vpn | off;
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +178,8 @@ size_t phys_to_virt(size_t phy)
|
|||
}
|
||||
}
|
||||
|
||||
sys_exit(-EFAULT); // TODO: remove this.
|
||||
LOG_INFO("PAGE NOT FOUND\n");
|
||||
/* sys_exit(-EFAULT); // TODO: remove this. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,13 +41,82 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
struct ibv_device ** ibv_get_device_list(int * num_devices);
|
||||
const char * ibv_get_device_name(struct ibv_device *device);
|
||||
struct ibv_context * ibv_open_device(struct ibv_device * device);
|
||||
int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr);
|
||||
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context);
|
||||
// struct ibv_device ** ibv_get_device_list(int * num_devices);
|
||||
// const char * ibv_get_device_name(struct ibv_device *device);
|
||||
// struct ibv_context * ibv_open_device(struct ibv_device * device);
|
||||
// int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr);
|
||||
// struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context);
|
||||
|
||||
void kernel_ibv_log();
|
||||
const char * ibv_wc_status_str(enum ibv_wc_status status);
|
||||
int ibv_rate_to_mult(enum ibv_rate rate);
|
||||
enum ibv_rate mult_to_ibv_rate(int mult);
|
||||
int ibv_rate_to_mbps(enum ibv_rate rate);
|
||||
enum ibv_rate mbps_to_ibv_rate(int mbps);
|
||||
struct verbs_context * verbs_get_ctx(struct ibv_context * ctx);
|
||||
struct ibv_device ** ibv_get_device_list(int * num_devices);
|
||||
void ibv_free_device_list(struct ibv_device ** list);
|
||||
const char * ibv_get_device_name(struct ibv_device * device);
|
||||
__be64 ibv_get_device_guid(struct ibv_device * device);
|
||||
struct ibv_context * ibv_open_device(struct ibv_device * device);
|
||||
int ibv_close_device(struct ibv_context * context);
|
||||
int ibv_get_async_event(struct ibv_context * context, struct ibv_async_event * event);
|
||||
void ibv_ack_async_event(struct ibv_async_event * event);
|
||||
int ibv_query_device(struct ibv_context * context, struct ibv_device_attr * device_attr);
|
||||
int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr);
|
||||
int ___ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr);
|
||||
int ibv_query_gid(struct ibv_context * context, uint8_t port_num, int index, union ibv_gid * gid);
|
||||
int ibv_query_pkey(struct ibv_context * context, uint8_t port_num, int index, __be16 * pkey);
|
||||
struct ibv_pd * ibv_alloc_pd(struct ibv_context * context);
|
||||
int ibv_dealloc_pd(struct ibv_pd * pd);
|
||||
struct ibv_flow * ibv_create_flow(struct ibv_qp * qp, struct ibv_flow_attr * flow);
|
||||
int ibv_destroy_flow(struct ibv_flow * flow_id);
|
||||
struct ibv_xrcd * ibv_open_xrcd(struct ibv_context * context, struct ibv_xrcd_init_attr * xrcd_init_attr);
|
||||
int ibv_close_xrcd(struct ibv_xrcd * xrcd);
|
||||
struct ibv_mr * ibv_reg_mr(struct ibv_pd * pd, void * addr, int length, int access);
|
||||
int ibv_rereg_mr(struct ibv_mr * mr, int flags, struct ibv_pd * pd, void * addr, int length, int access);
|
||||
int ibv_dereg_mr(struct ibv_mr * mr);
|
||||
struct ibv_mw * ibv_alloc_mw(struct ibv_pd * pd, enum ibv_mw_type type);
|
||||
int ibv_dealloc_mw(struct ibv_mw * mw);
|
||||
uint32_t ibv_inc_rkey(uint32_t rkey);
|
||||
int ibv_bind_mw(struct ibv_qp * qp, struct ibv_mw * mw, struct ibv_mw_bind * mw_bind);
|
||||
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context);
|
||||
int ibv_destroy_comp_channel(struct ibv_comp_channel * channel);
|
||||
struct ibv_cq * ibv_create_cq(struct ibv_context * context, int cqe, void * cq_context, struct ibv_comp_channel * channel, int comp_vector);
|
||||
int ibv_resize_cq(struct ibv_cq * cq, int cqe);
|
||||
int ibv_destroy_cq(struct ibv_cq * cq);
|
||||
int ibv_get_cq_event(struct ibv_comp_channel * channel, struct ibv_cq ** cq, void ** cq_context);
|
||||
void ibv_ack_cq_events(struct ibv_cq * cq, unsigned int nevents);
|
||||
int ibv_poll_cq(struct ibv_cq * cq, int num_entries, struct ibv_wc * wc);
|
||||
int ibv_req_notify_cq(struct ibv_cq * cq, int solicited_only);
|
||||
struct ibv_srq * ibv_create_srq(struct ibv_pd * pd, struct ibv_srq_init_attr * srq_init_attr);
|
||||
struct ibv_srq * ibv_create_srq_ex(struct ibv_context * context, struct ibv_srq_init_attr_ex * srq_init_attr_ex);
|
||||
int ibv_modify_srq(struct ibv_srq * srq, struct ibv_srq_attr * srq_attr, int srq_attr_mask);
|
||||
int ibv_query_srq(struct ibv_srq * srq, struct ibv_srq_attr * srq_attr);
|
||||
int ibv_get_srq_num(struct ibv_srq * srq, uint32_t * srq_num);
|
||||
int ibv_destroy_srq(struct ibv_srq * srq);
|
||||
int ibv_post_srq_recv(struct ibv_srq * srq, struct ibv_recv_wr * recv_wr, struct ibv_recv_wr ** bad_recv_wr);
|
||||
struct ibv_qp * ibv_create_qp(struct ibv_pd * pd, struct ibv_qp_init_attr * qp_init_attr);
|
||||
struct ibv_qp * ibv_create_qp_ex(struct ibv_context * context, struct ibv_qp_init_attr_ex * qp_init_attr_ex);
|
||||
int ibv_query_device_ex(struct ibv_context * context, const struct ibv_query_device_ex_input * input, struct ibv_device_attr_ex * attr);
|
||||
struct ibv_qp * ibv_open_qp(struct ibv_context * context, struct ibv_qp_open_attr * qp_open_attr);
|
||||
int ibv_modify_qp(struct ibv_qp * qp, struct ibv_qp_attr * attr, int attr_mask);
|
||||
int ibv_query_qp(struct ibv_qp * qp, struct ibv_qp_attr * attr, int attr_mask, struct ibv_qp_init_attr * init_attr);
|
||||
int ibv_destroy_qp(struct ibv_qp * qp);
|
||||
int ibv_post_send(struct ibv_qp * qp, struct ibv_send_wr * wr, struct ibv_send_wr ** bad_wr);
|
||||
int ibv_post_recv(struct ibv_qp * qp, struct ibv_recv_wr * wr, struct ibv_recv_wr ** bad_wr);
|
||||
struct ibv_ah * ibv_create_ah(struct ibv_pd * pd, struct ibv_ah_attr * attr);
|
||||
int ibv_init_ah_from_wc(struct ibv_context * context, uint8_t port_num, struct ibv_wc * wc, struct ibv_grh * grh, struct ibv_ah_attr * ah_attr);
|
||||
struct ibv_ah * ibv_create_ah_from_wc(struct ibv_pd * pd, struct ibv_wc * wc, struct ibv_grh * grh, uint8_t port_num);
|
||||
int ibv_destroy_ah(struct ibv_ah * ah);
|
||||
int ibv_attach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid);
|
||||
int ibv_detach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid);
|
||||
int ibv_fork_init( );
|
||||
const char * ibv_node_type_str(enum ibv_node_type node_type);
|
||||
const char * ibv_port_state_str(enum ibv_port_state port_state);
|
||||
const char * ibv_event_type_str(enum ibv_event_type event);
|
||||
int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt);
|
||||
|
||||
// void kernel_ibv_log();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -49,7 +49,8 @@ struct ibv_device * guest_to_host_ibv_device(struct ibv_device * device);
|
|||
struct ibv_context * guest_to_host_ibv_context(struct ibv_context * context);
|
||||
struct ibv_context_ops * guest_to_host_ibv_context_ops(struct ibv_context_ops * context_ops);
|
||||
struct ibv_port_attr * guest_to_host_ibv_port_attr(struct ibv_port_attr * port_attr);
|
||||
struct ibv_comp_channel * guest_to_host_ibv_comp_channel(struct ibv_comp_channel * channel);
|
||||
struct ibv_recv_wr * guest_to_host_ibv_recv_wr(struct ibv_recv_wr * wr);
|
||||
struct ibv_sge * guest_to_host_ibv_sge(struct ibv_sge * sg);
|
||||
struct ibv_abi_compat_v2 * guest_to_host_ibv_abi_compat_v2(struct ibv_abi_compat_v2 * abi_compat);
|
||||
pthread_mutex_t * guest_to_host_pthread_mutex_t(pthread_mutex_t * mutex);
|
||||
|
||||
|
@ -58,6 +59,8 @@ struct ibv_context * host_to_guest_ibv_context(struct ibv_context * contex
|
|||
struct ibv_context_ops * host_to_guest_ibv_context_ops(struct ibv_context_ops * context_ops, addr_type type);
|
||||
struct ibv_port_attr * host_to_guest_ibv_port_attr(struct ibv_port_attr * port_attr, addr_type type);
|
||||
struct ibv_comp_channel * host_to_guest_ibv_comp_channel(struct ibv_comp_channel * channel, addr_type type);
|
||||
struct ibv_recv_wr * host_to_guest_ibv_recv_wr(struct ibv_recv_wr * wr, addr_type type);
|
||||
struct ibv_sge * host_to_guest_ibv_sge(struct ibv_sge * sg, addr_type type);
|
||||
struct ibv_abi_compat_v2 * host_to_guest_ibv_abi_compat_v2(struct ibv_abi_compat_v2 * abi_compat, addr_type type);
|
||||
pthread_mutex_t * host_to_guest_pthread_mutex_t(pthread_mutex_t * mutex, addr_type type);
|
||||
|
||||
|
|
|
@ -39,9 +39,6 @@
|
|||
/** @brief Initialize the memory subsystem */
|
||||
int memory_init(void);
|
||||
|
||||
/** @brief Initialize the IB memory space */
|
||||
void * ib_memory_init(void);
|
||||
|
||||
/** @brief Request physical page frames */
|
||||
size_t get_pages(size_t npages);
|
||||
|
||||
|
|
|
@ -67,13 +67,76 @@ extern const size_t image_size;
|
|||
#define UHYVE_PORT_LSEEK 0x504
|
||||
|
||||
// InfiniBand uhyve port IDs
|
||||
#define UHYVE_PORT_IBV_OPEN_DEVICE 0x510
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x511
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x512
|
||||
#define UHYVE_PORT_IBV_QUERY_PORT 0x513
|
||||
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x514
|
||||
#define UHYVE_PORT_IBV_WC_STATUS_STR 0x510
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MULT 0x511
|
||||
#define UHYVE_PORT_MULT_TO_IBV_RATE 0x512
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MBPS 0x513
|
||||
#define UHYVE_PORT_MBPS_TO_IBV_RATE 0x514
|
||||
#define UHYVE_PORT_VERBS_GET_CTX 0x528
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x529
|
||||
#define UHYVE_PORT_IBV_FREE_DEVICE_LIST 0x52A
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x52B
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_GUID 0x52C
|
||||
#define UHYVE_PORT_IBV_OPEN_DEVICE 0x52D
|
||||
#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x52E
|
||||
#define UHYVE_PORT_IBV_GET_ASYNC_EVENT 0x52F
|
||||
#define UHYVE_PORT_IBV_ACK_ASYNC_EVENT 0x530
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE 0x531
|
||||
#define UHYVE_PORT_IBV_QUERY_PORT 0x532
|
||||
#define UHYVE_PORT____IBV_QUERY_PORT 0x533
|
||||
#define UHYVE_PORT_IBV_QUERY_GID 0x534
|
||||
#define UHYVE_PORT_IBV_QUERY_PKEY 0x535
|
||||
#define UHYVE_PORT_IBV_ALLOC_PD 0x536
|
||||
#define UHYVE_PORT_IBV_DEALLOC_PD 0x537
|
||||
#define UHYVE_PORT_IBV_CREATE_FLOW 0x538
|
||||
#define UHYVE_PORT_IBV_DESTROY_FLOW 0x539
|
||||
#define UHYVE_PORT_IBV_OPEN_XRCD 0x53A
|
||||
#define UHYVE_PORT_IBV_CLOSE_XRCD 0x53B
|
||||
#define UHYVE_PORT_IBV_REG_MR 0x53C
|
||||
#define UHYVE_PORT_IBV_REREG_MR 0x53D
|
||||
#define UHYVE_PORT_IBV_DEREG_MR 0x53E
|
||||
#define UHYVE_PORT_IBV_ALLOC_MW 0x53F
|
||||
#define UHYVE_PORT_IBV_DEALLOC_MW 0x540
|
||||
#define UHYVE_PORT_IBV_INC_RKEY 0x541
|
||||
#define UHYVE_PORT_IBV_BIND_MW 0x542
|
||||
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x543
|
||||
#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x544
|
||||
#define UHYVE_PORT_IBV_CREATE_CQ 0x545
|
||||
#define UHYVE_PORT_IBV_RESIZE_CQ 0x547
|
||||
#define UHYVE_PORT_IBV_DESTROY_CQ 0x548
|
||||
#define UHYVE_PORT_IBV_GET_CQ_EVENT 0x549
|
||||
#define UHYVE_PORT_IBV_ACK_CQ_EVENTS 0x54A
|
||||
#define UHYVE_PORT_IBV_POLL_CQ 0x54B
|
||||
#define UHYVE_PORT_IBV_REQ_NOTIFY_CQ 0x54C
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ 0x54D
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ_EX 0x54E
|
||||
#define UHYVE_PORT_IBV_MODIFY_SRQ 0x54F
|
||||
#define UHYVE_PORT_IBV_QUERY_SRQ 0x550
|
||||
#define UHYVE_PORT_IBV_GET_SRQ_NUM 0x551
|
||||
#define UHYVE_PORT_IBV_DESTROY_SRQ 0x552
|
||||
#define UHYVE_PORT_IBV_POST_SRQ_RECV 0x553
|
||||
#define UHYVE_PORT_IBV_CREATE_QP 0x554
|
||||
#define UHYVE_PORT_IBV_CREATE_QP_EX 0x555
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE_EX 0x557
|
||||
#define UHYVE_PORT_IBV_OPEN_QP 0x558
|
||||
#define UHYVE_PORT_IBV_MODIFY_QP 0x559
|
||||
#define UHYVE_PORT_IBV_QUERY_QP 0x55A
|
||||
#define UHYVE_PORT_IBV_DESTROY_QP 0x55B
|
||||
#define UHYVE_PORT_IBV_POST_SEND 0x561
|
||||
#define UHYVE_PORT_IBV_POST_RECV 0x562
|
||||
#define UHYVE_PORT_IBV_CREATE_AH 0x563
|
||||
#define UHYVE_PORT_IBV_INIT_AH_FROM_WC 0x564
|
||||
#define UHYVE_PORT_IBV_CREATE_AH_FROM_WC 0x565
|
||||
#define UHYVE_PORT_IBV_DESTROY_AH 0x566
|
||||
#define UHYVE_PORT_IBV_ATTACH_MCAST 0x567
|
||||
#define UHYVE_PORT_IBV_DETACH_MCAST 0x568
|
||||
#define UHYVE_PORT_IBV_FORK_INIT 0x569
|
||||
#define UHYVE_PORT_IBV_NODE_TYPE_STR 0x56A
|
||||
#define UHYVE_PORT_IBV_PORT_STATE_STR 0x56B
|
||||
#define UHYVE_PORT_IBV_EVENT_TYPE_STR 0x56C
|
||||
#define UHYVE_PORT_IBV_IS_QPT_SUPPORTED 0x56E
|
||||
|
||||
#define UHYVE_PORT_KERNEL_IBV_LOG 0x515
|
||||
// #define UHYVE_PORT_KERNEL_IBV_LOG 0x56F
|
||||
|
||||
|
||||
#define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b))
|
||||
|
|
1571
kernel/ibv.c
1571
kernel/ibv.c
File diff suppressed because it is too large
Load diff
|
@ -32,6 +32,7 @@
|
|||
#include <asm/page.h>
|
||||
|
||||
#include <hermit/ibv_guest_host.h>
|
||||
#include <hermit/logging.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -95,6 +96,73 @@ struct ibv_port_attr * host_to_guest_ibv_port_attr(struct ibv_port_attr * port_a
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* struct ibv_sge
|
||||
*/
|
||||
|
||||
struct ibv_sge * guest_to_host_ibv_sge(struct ibv_sge * sg) {
|
||||
LOG_INFO("Entered guest_to_host_ibv_recv_wr()\n");
|
||||
LOG_INFO("\tsg->addr before conversion: %lu\n", sg->addr);
|
||||
sg->addr = (uint64_t) guest_to_host((size_t) sg->addr);
|
||||
LOG_INFO("\tsg->addr after conversion: %lu\n", sg->addr);
|
||||
|
||||
return (struct ibv_sge *) guest_to_host((size_t) sg);
|
||||
}
|
||||
|
||||
struct ibv_sge * host_to_guest_ibv_sge(struct ibv_sge * sg, addr_type type) {
|
||||
LOG_INFO("Entered host_to_guest_ibv_recv_wr()\n");
|
||||
struct ibv_sge * vaddr = (type == GUEST) ? sg
|
||||
: (struct ibv_sge *) host_to_guest((size_t) sg);
|
||||
|
||||
vaddr->addr = (uint64_t) host_to_guest((size_t) vaddr->addr);
|
||||
|
||||
return vaddr;
|
||||
}
|
||||
|
||||
|
||||
// struct ibv_recv_wr {
|
||||
// uint64_t wr_id;
|
||||
// struct ibv_recv_wr *next;
|
||||
// struct ibv_sge *sg_list;
|
||||
// int num_sge;
|
||||
// };
|
||||
|
||||
// struct ibv_sge { // scatter/gather element
|
||||
// uint64_t addr; // might have to be converted
|
||||
// uint32_t length;
|
||||
// uint32_t lkey;
|
||||
// };
|
||||
|
||||
/*
|
||||
* struct ibv_recv_wr
|
||||
*/
|
||||
|
||||
struct ibv_recv_wr * guest_to_host_ibv_recv_wr(struct ibv_recv_wr * wr) {
|
||||
LOG_INFO("Entered guest_to_host_ibv_recv_wr()\n");
|
||||
if (wr->next) {
|
||||
LOG_INFO("\twr->next is not NULL\n");
|
||||
wr->next = guest_to_host_ibv_recv_wr(wr->next); // linked list
|
||||
}
|
||||
wr->sg_list = guest_to_host_ibv_sge(wr->sg_list);
|
||||
|
||||
return (struct ibv_recv_wr *) guest_to_host((size_t) wr);
|
||||
}
|
||||
|
||||
struct ibv_recv_wr * host_to_guest_ibv_recv_wr(struct ibv_recv_wr * wr, addr_type type) {
|
||||
LOG_INFO("Entered host_to_guest_ibv_recv_wr()\n");
|
||||
struct ibv_recv_wr * vaddr = (type == GUEST) ? wr
|
||||
: (struct ibv_recv_wr *) host_to_guest((size_t) wr);
|
||||
|
||||
if (wr->next) {
|
||||
LOG_INFO("\twr->next is not NULL\n");
|
||||
vaddr->next = host_to_guest_ibv_recv_wr(vaddr->next, HOST); // linked list
|
||||
}
|
||||
vaddr->sg_list = host_to_guest_ibv_sge(vaddr->sg_list, HOST);
|
||||
|
||||
return vaddr;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* struct ibv_comp_channel
|
||||
*/
|
||||
|
|
|
@ -122,7 +122,6 @@ static int hermit_init(void)
|
|||
timer_init();
|
||||
multitasking_init();
|
||||
memory_init();
|
||||
ib_memory_init();
|
||||
signal_init();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,5 +1,77 @@
|
|||
|
||||
#define UHYVE_PORT_IBV_OPEN_DEVICE 0x510
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x511
|
||||
#define UHYVE_PORT_IBV_QUERY_PORT 0x512
|
||||
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x513
|
||||
#define UHYVE_PORT_IBV_WC_STATUS_STR 0x510
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MULT 0x511
|
||||
#define UHYVE_PORT_MULT_TO_IBV_RATE 0x512
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MBPS 0x513
|
||||
#define UHYVE_PORT_MBPS_TO_IBV_RATE 0x514
|
||||
#define UHYVE_PORT_IBV_POST_WQ_RECV 0x515
|
||||
#define UHYVE_PORT_VERBS_GET_CTX 0x516
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x517
|
||||
#define UHYVE_PORT_IBV_FREE_DEVICE_LIST 0x518
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x519
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_GUID 0x51A
|
||||
#define UHYVE_PORT_IBV_OPEN_DEVICE 0x51B
|
||||
#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x51C
|
||||
#define UHYVE_PORT_IBV_GET_ASYNC_EVENT 0x51D
|
||||
#define UHYVE_PORT_IBV_ACK_ASYNC_EVENT 0x51E
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE 0x51F
|
||||
#define UHYVE_PORT_IBV_QUERY_PORT 0x520
|
||||
#define UHYVE_PORT____IBV_QUERY_PORT 0x521
|
||||
#define UHYVE_PORT_IBV_QUERY_GID 0x522
|
||||
#define UHYVE_PORT_IBV_QUERY_PKEY 0x523
|
||||
#define UHYVE_PORT_IBV_ALLOC_PD 0x524
|
||||
#define UHYVE_PORT_IBV_DEALLOC_PD 0x525
|
||||
#define UHYVE_PORT_IBV_CREATE_FLOW 0x526
|
||||
#define UHYVE_PORT_IBV_DESTROY_FLOW 0x527
|
||||
#define UHYVE_PORT_IBV_OPEN_XRCD 0x528
|
||||
#define UHYVE_PORT_IBV_CLOSE_XRCD 0x529
|
||||
#define UHYVE_PORT_IBV_REG_MR 0x52A
|
||||
#define UHYVE_PORT_IBV_REREG_MR 0x52B
|
||||
#define UHYVE_PORT_IBV_DEREG_MR 0x52C
|
||||
#define UHYVE_PORT_IBV_ALLOC_MW 0x52D
|
||||
#define UHYVE_PORT_IBV_DEALLOC_MW 0x52E
|
||||
#define UHYVE_PORT_IBV_INC_RKEY 0x52F
|
||||
#define UHYVE_PORT_IBV_BIND_MW 0x530
|
||||
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x531
|
||||
#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x532
|
||||
#define UHYVE_PORT_IBV_CREATE_CQ 0x533
|
||||
#define UHYVE_PORT_IBV_CREATE_CQ_EX 0x534
|
||||
#define UHYVE_PORT_IBV_RESIZE_CQ 0x535
|
||||
#define UHYVE_PORT_IBV_DESTROY_CQ 0x536
|
||||
#define UHYVE_PORT_IBV_GET_CQ_EVENT 0x537
|
||||
#define UHYVE_PORT_IBV_ACK_CQ_EVENTS 0x538
|
||||
#define UHYVE_PORT_IBV_POLL_CQ 0x539
|
||||
#define UHYVE_PORT_IBV_REQ_NOTIFY_CQ 0x53A
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ 0x53B
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ_EX 0x53C
|
||||
#define UHYVE_PORT_IBV_MODIFY_SRQ 0x53D
|
||||
#define UHYVE_PORT_IBV_QUERY_SRQ 0x53E
|
||||
#define UHYVE_PORT_IBV_GET_SRQ_NUM 0x53F
|
||||
#define UHYVE_PORT_IBV_DESTROY_SRQ 0x540
|
||||
#define UHYVE_PORT_IBV_POST_SRQ_RECV 0x541
|
||||
#define UHYVE_PORT_IBV_CREATE_QP 0x542
|
||||
#define UHYVE_PORT_IBV_CREATE_QP_EX 0x543
|
||||
#define UHYVE_PORT_IBV_QUERY_RT_VALUES_EX 0x544
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE_EX 0x545
|
||||
#define UHYVE_PORT_IBV_OPEN_QP 0x546
|
||||
#define UHYVE_PORT_IBV_MODIFY_QP 0x547
|
||||
#define UHYVE_PORT_IBV_QUERY_QP 0x548
|
||||
#define UHYVE_PORT_IBV_DESTROY_QP 0x549
|
||||
#define UHYVE_PORT_IBV_CREATE_WQ 0x54A
|
||||
#define UHYVE_PORT_IBV_MODIFY_WQ 0x54B
|
||||
#define UHYVE_PORT_IBV_DESTROY_WQ 0x54C
|
||||
#define UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE 0x54D
|
||||
#define UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE 0x54E
|
||||
#define UHYVE_PORT_IBV_POST_SEND 0x54F
|
||||
#define UHYVE_PORT_IBV_POST_RECV 0x550
|
||||
#define UHYVE_PORT_IBV_CREATE_AH 0x551
|
||||
#define UHYVE_PORT_IBV_INIT_AH_FROM_WC 0x552
|
||||
#define UHYVE_PORT_IBV_CREATE_AH_FROM_WC 0x553
|
||||
#define UHYVE_PORT_IBV_DESTROY_AH 0x554
|
||||
#define UHYVE_PORT_IBV_ATTACH_MCAST 0x555
|
||||
#define UHYVE_PORT_IBV_DETACH_MCAST 0x556
|
||||
#define UHYVE_PORT_IBV_FORK_INIT 0x557
|
||||
#define UHYVE_PORT_IBV_NODE_TYPE_STR 0x558
|
||||
#define UHYVE_PORT_IBV_PORT_STATE_STR 0x559
|
||||
#define UHYVE_PORT_IBV_EVENT_TYPE_STR 0x55A
|
||||
#define UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID 0x55B
|
||||
#define UHYVE_PORT_IBV_IS_QPT_SUPPORTED 0x55C
|
||||
|
|
77
tools/ibv_code_generator/GEN-kernel-header.h
Normal file
77
tools/ibv_code_generator/GEN-kernel-header.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
const char * ibv_wc_status_str(enum ibv_wc_status status);
|
||||
int ibv_rate_to_mult(enum ibv_rate rate);
|
||||
enum ibv_rate mult_to_ibv_rate(int mult);
|
||||
int ibv_rate_to_mbps(enum ibv_rate rate);
|
||||
enum ibv_rate mbps_to_ibv_rate(int mbps);
|
||||
int ibv_post_wq_recv(struct ibv_wq * wq, struct ibv_recv_wr * recv_wr, struct ibv_recv_wr ** bad_recv_wr);
|
||||
struct verbs_context * verbs_get_ctx(struct ibv_context * ctx);
|
||||
struct ibv_device ** ibv_get_device_list(int * num_devices);
|
||||
void ibv_free_device_list(struct ibv_device ** list);
|
||||
const char * ibv_get_device_name(struct ibv_device * device);
|
||||
__be64 ibv_get_device_guid(struct ibv_device * device);
|
||||
struct ibv_context * ibv_open_device(struct ibv_device * device);
|
||||
int ibv_close_device(struct ibv_context * context);
|
||||
int ibv_get_async_event(struct ibv_context * context, struct ibv_async_event * event);
|
||||
void ibv_ack_async_event(struct ibv_async_event * event);
|
||||
int ibv_query_device(struct ibv_context * context, struct ibv_device_attr * device_attr);
|
||||
int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr);
|
||||
int ___ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr);
|
||||
int ibv_query_gid(struct ibv_context * context, uint8_t port_num, int index, union ibv_gid * gid);
|
||||
int ibv_query_pkey(struct ibv_context * context, uint8_t port_num, int index, __be16 * pkey);
|
||||
struct ibv_pd * ibv_alloc_pd(struct ibv_context * context);
|
||||
int ibv_dealloc_pd(struct ibv_pd * pd);
|
||||
struct ibv_flow * ibv_create_flow(struct ibv_qp * qp, struct ibv_flow_attr * flow);
|
||||
int ibv_destroy_flow(struct ibv_flow * flow_id);
|
||||
struct ibv_xrcd * ibv_open_xrcd(struct ibv_context * context, struct ibv_xrcd_init_attr * xrcd_init_attr);
|
||||
int ibv_close_xrcd(struct ibv_xrcd * xrcd);
|
||||
struct ibv_mr * ibv_reg_mr(struct ibv_pd * pd, void * addr, int length, int access);
|
||||
int ibv_rereg_mr(struct ibv_mr * mr, int flags, struct ibv_pd * pd, void * addr, int length, int access);
|
||||
int ibv_dereg_mr(struct ibv_mr * mr);
|
||||
struct ibv_mw * ibv_alloc_mw(struct ibv_pd * pd, enum ibv_mw_type type);
|
||||
int ibv_dealloc_mw(struct ibv_mw * mw);
|
||||
uint32_t ibv_inc_rkey(uint32_t rkey);
|
||||
int ibv_bind_mw(struct ibv_qp * qp, struct ibv_mw * mw, struct ibv_mw_bind * mw_bind);
|
||||
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context);
|
||||
int ibv_destroy_comp_channel(struct ibv_comp_channel * channel);
|
||||
struct ibv_cq * ibv_create_cq(struct ibv_context * context, int cqe, void * cq_context, struct ibv_comp_channel * channel, int comp_vector);
|
||||
struct ibv_cq_ex * ibv_create_cq_ex(struct ibv_context * context, struct ibv_cq_init_attr_ex * cq_attr);
|
||||
int ibv_resize_cq(struct ibv_cq * cq, int cqe);
|
||||
int ibv_destroy_cq(struct ibv_cq * cq);
|
||||
int ibv_get_cq_event(struct ibv_comp_channel * channel, struct ibv_cq ** cq, void ** cq_context);
|
||||
void ibv_ack_cq_events(struct ibv_cq * cq, unsigned int nevents);
|
||||
int ibv_poll_cq(struct ibv_cq * cq, int num_entries, struct ibv_wc * wc);
|
||||
int ibv_req_notify_cq(struct ibv_cq * cq, int solicited_only);
|
||||
struct ibv_srq * ibv_create_srq(struct ibv_pd * pd, struct ibv_srq_init_attr * srq_init_attr);
|
||||
struct ibv_srq * ibv_create_srq_ex(struct ibv_context * context, struct ibv_srq_init_attr_ex * srq_init_attr_ex);
|
||||
int ibv_modify_srq(struct ibv_srq * srq, struct ibv_srq_attr * srq_attr, int srq_attr_mask);
|
||||
int ibv_query_srq(struct ibv_srq * srq, struct ibv_srq_attr * srq_attr);
|
||||
int ibv_get_srq_num(struct ibv_srq * srq, uint32_t * srq_num);
|
||||
int ibv_destroy_srq(struct ibv_srq * srq);
|
||||
int ibv_post_srq_recv(struct ibv_srq * srq, struct ibv_recv_wr * recv_wr, struct ibv_recv_wr ** bad_recv_wr);
|
||||
struct ibv_qp * ibv_create_qp(struct ibv_pd * pd, struct ibv_qp_init_attr * qp_init_attr);
|
||||
struct ibv_qp * ibv_create_qp_ex(struct ibv_context * context, struct ibv_qp_init_attr_ex * qp_init_attr_ex);
|
||||
int ibv_query_rt_values_ex(struct ibv_context * context, struct ibv_values_ex * values);
|
||||
int ibv_query_device_ex(struct ibv_context * context, const struct ibv_query_device_ex_input * input, struct ibv_device_attr_ex * attr);
|
||||
struct ibv_qp * ibv_open_qp(struct ibv_context * context, struct ibv_qp_open_attr * qp_open_attr);
|
||||
int ibv_modify_qp(struct ibv_qp * qp, struct ibv_qp_attr * attr, int attr_mask);
|
||||
int ibv_query_qp(struct ibv_qp * qp, struct ibv_qp_attr * attr, int attr_mask, struct ibv_qp_init_attr * init_attr);
|
||||
int ibv_destroy_qp(struct ibv_qp * qp);
|
||||
struct ibv_wq * ibv_create_wq(struct ibv_context * context, struct ibv_wq_init_attr * wq_init_attr);
|
||||
int ibv_modify_wq(struct ibv_wq * wq, struct ibv_wq_attr * wq_attr);
|
||||
int ibv_destroy_wq(struct ibv_wq * wq);
|
||||
struct ibv_rwq_ind_table * ibv_create_rwq_ind_table(struct ibv_context * context, struct ibv_rwq_ind_table_init_attr * init_attr);
|
||||
int ibv_destroy_rwq_ind_table(struct ibv_rwq_ind_table * rwq_ind_table);
|
||||
int ibv_post_send(struct ibv_qp * qp, struct ibv_send_wr * wr, struct ibv_send_wr ** bad_wr);
|
||||
int ibv_post_recv(struct ibv_qp * qp, struct ibv_recv_wr * wr, struct ibv_recv_wr ** bad_wr);
|
||||
struct ibv_ah * ibv_create_ah(struct ibv_pd * pd, struct ibv_ah_attr * attr);
|
||||
int ibv_init_ah_from_wc(struct ibv_context * context, uint8_t port_num, struct ibv_wc * wc, struct ibv_grh * grh, struct ibv_ah_attr * ah_attr);
|
||||
struct ibv_ah * ibv_create_ah_from_wc(struct ibv_pd * pd, struct ibv_wc * wc, struct ibv_grh * grh, uint8_t port_num);
|
||||
int ibv_destroy_ah(struct ibv_ah * ah);
|
||||
int ibv_attach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid);
|
||||
int ibv_detach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid);
|
||||
int ibv_fork_init( );
|
||||
const char * ibv_node_type_str(enum ibv_node_type node_type);
|
||||
const char * ibv_port_state_str(enum ibv_port_state port_state);
|
||||
const char * ibv_event_type_str(enum ibv_event_type event);
|
||||
int ibv_resolve_eth_l2_from_gid(struct ibv_context * context, struct ibv_ah_attr * attr, uint8_t eth_mac[6], uint16_t * vid);
|
||||
int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt);
|
|
@ -1,82 +0,0 @@
|
|||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
struct ibv_context * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_open_device_t;
|
||||
|
||||
struct ibv_context * ibv_open_device(struct ibv_device * device) {
|
||||
uhyve_ibv_open_device_t uhyve_args;
|
||||
uhyve_args->device = (struct ibv_device *) virt_to_phys((size_t) device);
|
||||
|
||||
uhyve_args->ret = kmalloc(sizeof(struct ibv_context));
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_OPEN_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Fix pointers in returned data structures.
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
const char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
|
||||
|
||||
const char * ibv_get_device_name(struct ibv_device * device) {
|
||||
uhyve_ibv_get_device_name_t uhyve_args;
|
||||
uhyve_args->device = (struct ibv_device *) virt_to_phys((size_t) device);
|
||||
|
||||
uhyve_args->ret = kmalloc(sizeof(const char));
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_NAME, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Fix pointers in returned data structures.
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
struct ibv_port_attr * port_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_port_t;
|
||||
|
||||
int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr) {
|
||||
uhyve_ibv_query_port_t uhyve_args;
|
||||
uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);
|
||||
uhyve_args->port_num = port_num;
|
||||
uhyve_args->port_attr = (struct ibv_port_attr *) virt_to_phys((size_t) port_attr);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Fix pointers in returned data structures.
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
// Return value:
|
||||
struct ibv_comp_channel * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;
|
||||
|
||||
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context) {
|
||||
uhyve_ibv_create_comp_channel_t uhyve_args;
|
||||
uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);
|
||||
|
||||
uhyve_args->ret = kmalloc(sizeof(struct ibv_comp_channel));
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_CREATE_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Fix pointers in returned data structures.
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
1767
tools/ibv_code_generator/GEN-kernel.c
Normal file
1767
tools/ibv_code_generator/GEN-kernel.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,773 @@
|
|||
typedef enum {
|
||||
UHYVE_PORT_IBV_OPEN_DEVICE = 0x510,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x511,
|
||||
UHYVE_PORT_IBV_QUERY_PORT = 0x512,
|
||||
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x513,
|
||||
} uhyve_ibv_t;
|
||||
UHYVE_PORT_IBV_WC_STATUS_STR = 0x510,
|
||||
UHYVE_PORT_IBV_RATE_TO_MULT = 0x511,
|
||||
UHYVE_PORT_MULT_TO_IBV_RATE = 0x512,
|
||||
UHYVE_PORT_IBV_RATE_TO_MBPS = 0x513,
|
||||
UHYVE_PORT_MBPS_TO_IBV_RATE = 0x514,
|
||||
UHYVE_PORT_IBV_POST_WQ_RECV = 0x515,
|
||||
UHYVE_PORT_VERBS_GET_CTX = 0x516,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x517,
|
||||
UHYVE_PORT_IBV_FREE_DEVICE_LIST = 0x518,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x519,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_GUID = 0x51A,
|
||||
UHYVE_PORT_IBV_OPEN_DEVICE = 0x51B,
|
||||
UHYVE_PORT_IBV_CLOSE_DEVICE = 0x51C,
|
||||
UHYVE_PORT_IBV_GET_ASYNC_EVENT = 0x51D,
|
||||
UHYVE_PORT_IBV_ACK_ASYNC_EVENT = 0x51E,
|
||||
UHYVE_PORT_IBV_QUERY_DEVICE = 0x51F,
|
||||
UHYVE_PORT_IBV_QUERY_PORT = 0x520,
|
||||
UHYVE_PORT____IBV_QUERY_PORT = 0x521,
|
||||
UHYVE_PORT_IBV_QUERY_GID = 0x522,
|
||||
UHYVE_PORT_IBV_QUERY_PKEY = 0x523,
|
||||
UHYVE_PORT_IBV_ALLOC_PD = 0x524,
|
||||
UHYVE_PORT_IBV_DEALLOC_PD = 0x525,
|
||||
UHYVE_PORT_IBV_CREATE_FLOW = 0x526,
|
||||
UHYVE_PORT_IBV_DESTROY_FLOW = 0x527,
|
||||
UHYVE_PORT_IBV_OPEN_XRCD = 0x528,
|
||||
UHYVE_PORT_IBV_CLOSE_XRCD = 0x529,
|
||||
UHYVE_PORT_IBV_REG_MR = 0x52A,
|
||||
UHYVE_PORT_IBV_REREG_MR = 0x52B,
|
||||
UHYVE_PORT_IBV_DEREG_MR = 0x52C,
|
||||
UHYVE_PORT_IBV_ALLOC_MW = 0x52D,
|
||||
UHYVE_PORT_IBV_DEALLOC_MW = 0x52E,
|
||||
UHYVE_PORT_IBV_INC_RKEY = 0x52F,
|
||||
UHYVE_PORT_IBV_BIND_MW = 0x530,
|
||||
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x531,
|
||||
UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x532,
|
||||
UHYVE_PORT_IBV_CREATE_CQ = 0x533,
|
||||
UHYVE_PORT_IBV_CREATE_CQ_EX = 0x534,
|
||||
UHYVE_PORT_IBV_RESIZE_CQ = 0x535,
|
||||
UHYVE_PORT_IBV_DESTROY_CQ = 0x536,
|
||||
UHYVE_PORT_IBV_GET_CQ_EVENT = 0x537,
|
||||
UHYVE_PORT_IBV_ACK_CQ_EVENTS = 0x538,
|
||||
UHYVE_PORT_IBV_POLL_CQ = 0x539,
|
||||
UHYVE_PORT_IBV_REQ_NOTIFY_CQ = 0x53A,
|
||||
UHYVE_PORT_IBV_CREATE_SRQ = 0x53B,
|
||||
UHYVE_PORT_IBV_CREATE_SRQ_EX = 0x53C,
|
||||
UHYVE_PORT_IBV_MODIFY_SRQ = 0x53D,
|
||||
UHYVE_PORT_IBV_QUERY_SRQ = 0x53E,
|
||||
UHYVE_PORT_IBV_GET_SRQ_NUM = 0x53F,
|
||||
UHYVE_PORT_IBV_DESTROY_SRQ = 0x540,
|
||||
UHYVE_PORT_IBV_POST_SRQ_RECV = 0x541,
|
||||
UHYVE_PORT_IBV_CREATE_QP = 0x542,
|
||||
UHYVE_PORT_IBV_CREATE_QP_EX = 0x543,
|
||||
UHYVE_PORT_IBV_QUERY_RT_VALUES_EX = 0x544,
|
||||
UHYVE_PORT_IBV_QUERY_DEVICE_EX = 0x545,
|
||||
UHYVE_PORT_IBV_OPEN_QP = 0x546,
|
||||
UHYVE_PORT_IBV_MODIFY_QP = 0x547,
|
||||
UHYVE_PORT_IBV_QUERY_QP = 0x548,
|
||||
UHYVE_PORT_IBV_DESTROY_QP = 0x549,
|
||||
UHYVE_PORT_IBV_CREATE_WQ = 0x54A,
|
||||
UHYVE_PORT_IBV_MODIFY_WQ = 0x54B,
|
||||
UHYVE_PORT_IBV_DESTROY_WQ = 0x54C,
|
||||
UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE = 0x54D,
|
||||
UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE = 0x54E,
|
||||
UHYVE_PORT_IBV_POST_SEND = 0x54F,
|
||||
UHYVE_PORT_IBV_POST_RECV = 0x550,
|
||||
UHYVE_PORT_IBV_CREATE_AH = 0x551,
|
||||
UHYVE_PORT_IBV_INIT_AH_FROM_WC = 0x552,
|
||||
UHYVE_PORT_IBV_CREATE_AH_FROM_WC = 0x553,
|
||||
UHYVE_PORT_IBV_DESTROY_AH = 0x554,
|
||||
UHYVE_PORT_IBV_ATTACH_MCAST = 0x555,
|
||||
UHYVE_PORT_IBV_DETACH_MCAST = 0x556,
|
||||
UHYVE_PORT_IBV_FORK_INIT = 0x557,
|
||||
UHYVE_PORT_IBV_NODE_TYPE_STR = 0x558,
|
||||
UHYVE_PORT_IBV_PORT_STATE_STR = 0x559,
|
||||
UHYVE_PORT_IBV_EVENT_TYPE_STR = 0x55A,
|
||||
UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID = 0x55B,
|
||||
UHYVE_PORT_IBV_IS_QPT_SUPPORTED = 0x55C,
|
||||
} uhyve_ibv_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_wc_status status;
|
||||
// Return value:
|
||||
const char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_wc_status_str_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_rate rate;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_rate_to_mult_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
int mult;
|
||||
// Return value:
|
||||
enum ibv_rate ret;
|
||||
} __attribute__((packed)) uhyve_mult_to_ibv_rate_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_rate rate;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_rate_to_mbps_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
int mbps;
|
||||
// Return value:
|
||||
enum ibv_rate ret;
|
||||
} __attribute__((packed)) uhyve_mbps_to_ibv_rate_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_wq * wq;
|
||||
struct ibv_recv_wr * recv_wr;
|
||||
struct ibv_recv_wr ** bad_recv_wr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_post_wq_recv_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * ctx;
|
||||
// Return value:
|
||||
struct verbs_context * ret;
|
||||
} __attribute__((packed)) uhyve_verbs_get_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
int * num_devices;
|
||||
// Return value:
|
||||
struct ibv_device ** ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_list_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device ** list;
|
||||
} __attribute__((packed)) uhyve_ibv_free_device_list_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
const char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
__be64 ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_guid_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
struct ibv_context * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_open_device_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_close_device_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_async_event * event;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_async_event_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_async_event * event;
|
||||
} __attribute__((packed)) uhyve_ibv_ack_async_event_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_device_attr * device_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_device_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
struct ibv_port_attr * port_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_port_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
struct ibv_port_attr * port_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve____ibv_query_port_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
int index;
|
||||
union ibv_gid * gid;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_gid_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
int index;
|
||||
__be16 * pkey;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_pkey_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
// Return value:
|
||||
struct ibv_pd * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_alloc_pd_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_dealloc_pd_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_flow_attr * flow;
|
||||
// Return value:
|
||||
struct ibv_flow * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_flow_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_flow * flow_id;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_flow_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_xrcd_init_attr * xrcd_init_attr;
|
||||
// Return value:
|
||||
struct ibv_xrcd * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_open_xrcd_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_xrcd * xrcd;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_close_xrcd_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
void * addr;
|
||||
int length;
|
||||
int access;
|
||||
// Return value:
|
||||
struct ibv_mr * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_reg_mr_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_mr * mr;
|
||||
int flags;
|
||||
struct ibv_pd * pd;
|
||||
void * addr;
|
||||
int length;
|
||||
int access;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_rereg_mr_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_mr * mr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_dereg_mr_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
enum ibv_mw_type type;
|
||||
// Return value:
|
||||
struct ibv_mw * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_alloc_mw_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_mw * mw;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_dealloc_mw_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
uint32_t rkey;
|
||||
// Return value:
|
||||
uint32_t ret;
|
||||
} __attribute__((packed)) uhyve_ibv_inc_rkey_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_mw * mw;
|
||||
struct ibv_mw_bind * mw_bind;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_bind_mw_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
// Return value:
|
||||
struct ibv_comp_channel * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_comp_channel * channel;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_comp_channel_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
int cqe;
|
||||
void * cq_context;
|
||||
struct ibv_comp_channel * channel;
|
||||
int comp_vector;
|
||||
// Return value:
|
||||
struct ibv_cq * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_cq_init_attr_ex * cq_attr;
|
||||
// Return value:
|
||||
struct ibv_cq_ex * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_cq_ex_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
int cqe;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_resize_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_comp_channel * channel;
|
||||
struct ibv_cq ** cq;
|
||||
void ** cq_context;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_cq_event_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
unsigned int nevents;
|
||||
} __attribute__((packed)) uhyve_ibv_ack_cq_events_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
int num_entries;
|
||||
struct ibv_wc * wc;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_poll_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
int solicited_only;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_req_notify_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
struct ibv_srq_init_attr * srq_init_attr;
|
||||
// Return value:
|
||||
struct ibv_srq * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_srq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_srq_init_attr_ex * srq_init_attr_ex;
|
||||
// Return value:
|
||||
struct ibv_srq * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_srq_ex_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
struct ibv_srq_attr * srq_attr;
|
||||
int srq_attr_mask;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_modify_srq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
struct ibv_srq_attr * srq_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_srq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
uint32_t * srq_num;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_srq_num_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_srq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
struct ibv_recv_wr * recv_wr;
|
||||
struct ibv_recv_wr ** bad_recv_wr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_post_srq_recv_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
struct ibv_qp_init_attr * qp_init_attr;
|
||||
// Return value:
|
||||
struct ibv_qp * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_qp_init_attr_ex * qp_init_attr_ex;
|
||||
// Return value:
|
||||
struct ibv_qp * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_qp_ex_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_values_ex * values;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_rt_values_ex_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
const struct ibv_query_device_ex_input * input;
|
||||
struct ibv_device_attr_ex * attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_device_ex_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_qp_open_attr * qp_open_attr;
|
||||
// Return value:
|
||||
struct ibv_qp * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_open_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_qp_attr * attr;
|
||||
int attr_mask;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_modify_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_qp_attr * attr;
|
||||
int attr_mask;
|
||||
struct ibv_qp_init_attr * init_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_wq_init_attr * wq_init_attr;
|
||||
// Return value:
|
||||
struct ibv_wq * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_wq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_wq * wq;
|
||||
struct ibv_wq_attr * wq_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_modify_wq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_wq * wq;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_wq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_rwq_ind_table_init_attr * init_attr;
|
||||
// Return value:
|
||||
struct ibv_rwq_ind_table * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_rwq_ind_table_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_rwq_ind_table * rwq_ind_table;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_rwq_ind_table_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_send_wr * wr;
|
||||
struct ibv_send_wr ** bad_wr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_post_send_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_recv_wr * wr;
|
||||
struct ibv_recv_wr ** bad_wr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_post_recv_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
struct ibv_ah_attr * attr;
|
||||
// Return value:
|
||||
struct ibv_ah * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_ah_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
struct ibv_wc * wc;
|
||||
struct ibv_grh * grh;
|
||||
struct ibv_ah_attr * ah_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_init_ah_from_wc_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
struct ibv_wc * wc;
|
||||
struct ibv_grh * grh;
|
||||
uint8_t port_num;
|
||||
// Return value:
|
||||
struct ibv_ah * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_ah_from_wc_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_ah * ah;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_ah_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
const union ibv_gid * gid;
|
||||
uint16_t lid;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_attach_mcast_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
const union ibv_gid * gid;
|
||||
uint16_t lid;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_detach_mcast_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_fork_init_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_node_type node_type;
|
||||
// Return value:
|
||||
const char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_node_type_str_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_port_state port_state;
|
||||
// Return value:
|
||||
const char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_port_state_str_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_event_type event;
|
||||
// Return value:
|
||||
const char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_event_type_str_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_ah_attr * attr;
|
||||
uint8_t eth_mac[6];
|
||||
uint16_t * vid;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_resolve_eth_l2_from_gid_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
uint32_t caps;
|
||||
enum ibv_qp_type qpt;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_is_qpt_supported_t;
|
||||
|
||||
|
||||
|
||||
void call_ibv_wc_status_str(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_rate_to_mult(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_mult_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_rate_to_mbps(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_mbps_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_post_wq_recv(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_verbs_get_ctx(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_free_device_list(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_device_guid(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_close_device(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_async_event(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_ack_async_event(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_device(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call____ibv_query_port(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_gid(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_pkey(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_alloc_pd(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_dealloc_pd(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_flow(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_flow(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_open_xrcd(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_close_xrcd(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_reg_mr(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_rereg_mr(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_dereg_mr(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_alloc_mw(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_dealloc_mw(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_inc_rkey(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_bind_mw(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_comp_channel(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_cq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_cq_ex(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_resize_cq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_cq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_cq_event(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_ack_cq_events(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_poll_cq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_req_notify_cq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_srq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_srq_ex(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_modify_srq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_srq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_srq_num(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_srq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_post_srq_recv(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_qp(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_qp_ex(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_rt_values_ex(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_device_ex(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_open_qp(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_modify_qp(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_qp(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_qp(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_wq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_modify_wq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_wq(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_rwq_ind_table(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_rwq_ind_table(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_post_send(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_post_recv(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_ah(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_init_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_ah(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_attach_mcast(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_detach_mcast(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_fork_init(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_node_type_str(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_port_state_str(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_event_type_str(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_resolve_eth_l2_from_gid(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_is_qpt_supported(struct kvm_run * run, uint8_t * guest_mem);
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
struct ibv_context * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_open_device_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
const char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
struct ibv_port_attr * port_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_port_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
// Return value:
|
||||
struct ibv_comp_channel * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;
|
||||
|
|
@ -1,37 +1,539 @@
|
|||
void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_open_device_t * args = (uhyve_ibv_open_device_t *) (guest_mem + data);
|
||||
void call_ibv_wc_status_str(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_wc_status_str_t * args = (uhyve_ibv_wc_status_str_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_context * host_ret = ibv_open_device(guest_mem+(size_t)args->device);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
// TODO: Convert ptrs contained in return value.
|
||||
// TODO: Delete host_ret data structure.
|
||||
const char * host_ret = ibv_wc_status_str(args->status);
|
||||
);memcpy(args->ret, host_ret, sizeof(host_ret));}
|
||||
|
||||
void call_ibv_rate_to_mult(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_rate_to_mult_t * args = (uhyve_ibv_rate_to_mult_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_rate_to_mult(args->rate);
|
||||
);}
|
||||
|
||||
void call_mult_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_mult_to_ibv_rate_t * args = (uhyve_mult_to_ibv_rate_t *) (guest_mem + data);
|
||||
|
||||
args.ret = mult_to_ibv_rate(args->mult);
|
||||
);}
|
||||
|
||||
void call_ibv_rate_to_mbps(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_rate_to_mbps_t * args = (uhyve_ibv_rate_to_mbps_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_rate_to_mbps(args->rate);
|
||||
);}
|
||||
|
||||
void call_mbps_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_mbps_to_ibv_rate_t * args = (uhyve_mbps_to_ibv_rate_t *) (guest_mem + data);
|
||||
|
||||
args.ret = mbps_to_ibv_rate(args->mbps);
|
||||
);}
|
||||
|
||||
void call_ibv_post_wq_recv(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_post_wq_recv_t * args = (uhyve_ibv_post_wq_recv_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_post_wq_recv(args->wq, args->recv_wr, args->bad_recv_wr);
|
||||
);}
|
||||
|
||||
void call_verbs_get_ctx(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_verbs_get_ctx_t * args = (uhyve_verbs_get_ctx_t *) (guest_mem + data);
|
||||
|
||||
args.ret = verbs_get_ctx(args->ctx);
|
||||
);}
|
||||
|
||||
void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_device_list_t * args = (uhyve_ibv_get_device_list_t *) (guest_mem + data);
|
||||
|
||||
// TODO: Take care of ** here.
|
||||
}
|
||||
|
||||
void call_ibv_free_device_list(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_free_device_list_t * args = (uhyve_ibv_free_device_list_t *) (guest_mem + data);
|
||||
|
||||
ibv_free_device_list(args->list);
|
||||
);}
|
||||
|
||||
void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_device_name_t * args = (uhyve_ibv_get_device_name_t *) (guest_mem + data);
|
||||
|
||||
const char * host_ret = ibv_get_device_name(guest_mem+(size_t)args->device);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
// TODO: Convert ptrs contained in return value.
|
||||
// TODO: Delete host_ret data structure.
|
||||
}
|
||||
const char * host_ret = ibv_get_device_name(args->device);
|
||||
);memcpy(args->ret, host_ret, sizeof(host_ret));}
|
||||
|
||||
void call_ibv_get_device_guid(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_device_guid_t * args = (uhyve_ibv_get_device_guid_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_get_device_guid(args->device);
|
||||
);}
|
||||
|
||||
void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_open_device_t * args = (uhyve_ibv_open_device_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_open_device(args->device);
|
||||
);}
|
||||
|
||||
void call_ibv_close_device(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_close_device_t * args = (uhyve_ibv_close_device_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_close_device(args->context);
|
||||
);}
|
||||
|
||||
void call_ibv_get_async_event(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_async_event_t * args = (uhyve_ibv_get_async_event_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_get_async_event(args->context, args->event);
|
||||
);}
|
||||
|
||||
void call_ibv_ack_async_event(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_ack_async_event_t * args = (uhyve_ibv_ack_async_event_t *) (guest_mem + data);
|
||||
|
||||
ibv_ack_async_event(args->event);
|
||||
);}
|
||||
|
||||
void call_ibv_query_device(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_device_t * args = (uhyve_ibv_query_device_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_query_device(args->context, args->device_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_port_t * args = (uhyve_ibv_query_port_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_query_port(guest_mem+(size_t)args->context, port_num, guest_mem+(size_t)args->port_attr);
|
||||
args->ret = host_ret;
|
||||
}
|
||||
args.ret = ibv_query_port(args->context, args->port_num, args->port_attr);
|
||||
);}
|
||||
|
||||
void call____ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve____ibv_query_port_t * args = (uhyve____ibv_query_port_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ___ibv_query_port(args->context, args->port_num, args->port_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_query_gid(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_gid_t * args = (uhyve_ibv_query_gid_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_query_gid(args->context, args->port_num, args->index, args->gid);
|
||||
);}
|
||||
|
||||
void call_ibv_query_pkey(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_pkey_t * args = (uhyve_ibv_query_pkey_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_query_pkey(args->context, args->port_num, args->index, args->pkey);
|
||||
);}
|
||||
|
||||
void call_ibv_alloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_alloc_pd_t * args = (uhyve_ibv_alloc_pd_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_alloc_pd(args->context);
|
||||
);}
|
||||
|
||||
void call_ibv_dealloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_dealloc_pd_t * args = (uhyve_ibv_dealloc_pd_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_dealloc_pd(args->pd);
|
||||
);}
|
||||
|
||||
void call_ibv_create_flow(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_flow_t * args = (uhyve_ibv_create_flow_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_flow(args->qp, args->flow);
|
||||
);}
|
||||
|
||||
void call_ibv_destroy_flow(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_flow_t * args = (uhyve_ibv_destroy_flow_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_destroy_flow(args->flow_id);
|
||||
);}
|
||||
|
||||
void call_ibv_open_xrcd(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_open_xrcd_t * args = (uhyve_ibv_open_xrcd_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_open_xrcd(args->context, args->xrcd_init_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_close_xrcd(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_close_xrcd_t * args = (uhyve_ibv_close_xrcd_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_close_xrcd(args->xrcd);
|
||||
);}
|
||||
|
||||
void call_ibv_reg_mr(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_reg_mr_t * args = (uhyve_ibv_reg_mr_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_reg_mr(args->pd, args->addr, args->length, args->access);
|
||||
);}
|
||||
|
||||
void call_ibv_rereg_mr(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_rereg_mr_t * args = (uhyve_ibv_rereg_mr_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_rereg_mr(args->mr, args->flags, args->pd, args->addr, args->length, args->access);
|
||||
);}
|
||||
|
||||
void call_ibv_dereg_mr(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_dereg_mr_t * args = (uhyve_ibv_dereg_mr_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_dereg_mr(args->mr);
|
||||
);}
|
||||
|
||||
void call_ibv_alloc_mw(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_alloc_mw_t * args = (uhyve_ibv_alloc_mw_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_alloc_mw(args->pd, args->type);
|
||||
);}
|
||||
|
||||
void call_ibv_dealloc_mw(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_dealloc_mw_t * args = (uhyve_ibv_dealloc_mw_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_dealloc_mw(args->mw);
|
||||
);}
|
||||
|
||||
void call_ibv_inc_rkey(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_inc_rkey_t * args = (uhyve_ibv_inc_rkey_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_inc_rkey(args->rkey);
|
||||
);}
|
||||
|
||||
void call_ibv_bind_mw(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_bind_mw_t * args = (uhyve_ibv_bind_mw_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_bind_mw(args->qp, args->mw, args->mw_bind);
|
||||
);}
|
||||
|
||||
void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_comp_channel_t * args = (uhyve_ibv_create_comp_channel_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_comp_channel * host_ret = ibv_create_comp_channel(guest_mem+(size_t)args->context);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
// TODO: Convert ptrs contained in return value.
|
||||
// TODO: Delete host_ret data structure.
|
||||
}
|
||||
args.ret = ibv_create_comp_channel(args->context);
|
||||
);}
|
||||
|
||||
void call_ibv_destroy_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_comp_channel_t * args = (uhyve_ibv_destroy_comp_channel_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_destroy_comp_channel(args->channel);
|
||||
);}
|
||||
|
||||
void call_ibv_create_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_cq_t * args = (uhyve_ibv_create_cq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_cq(args->context, args->cqe, args->cq_context, args->channel, args->comp_vector);
|
||||
);}
|
||||
|
||||
void call_ibv_create_cq_ex(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_cq_ex_t * args = (uhyve_ibv_create_cq_ex_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_cq_ex(args->context, args->cq_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_resize_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_resize_cq_t * args = (uhyve_ibv_resize_cq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_resize_cq(args->cq, args->cqe);
|
||||
);}
|
||||
|
||||
void call_ibv_destroy_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_cq_t * args = (uhyve_ibv_destroy_cq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_destroy_cq(args->cq);
|
||||
);}
|
||||
|
||||
void call_ibv_get_cq_event(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_cq_event_t * args = (uhyve_ibv_get_cq_event_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_get_cq_event(args->channel, args->cq, args->cq_context);
|
||||
);}
|
||||
|
||||
void call_ibv_ack_cq_events(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_ack_cq_events_t * args = (uhyve_ibv_ack_cq_events_t *) (guest_mem + data);
|
||||
|
||||
ibv_ack_cq_events(args->cq, args->nevents);
|
||||
);}
|
||||
|
||||
void call_ibv_poll_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_poll_cq_t * args = (uhyve_ibv_poll_cq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_poll_cq(args->cq, args->num_entries, args->wc);
|
||||
);}
|
||||
|
||||
void call_ibv_req_notify_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_req_notify_cq_t * args = (uhyve_ibv_req_notify_cq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_req_notify_cq(args->cq, args->solicited_only);
|
||||
);}
|
||||
|
||||
void call_ibv_create_srq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_srq_t * args = (uhyve_ibv_create_srq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_srq(args->pd, args->srq_init_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_create_srq_ex(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_srq_ex_t * args = (uhyve_ibv_create_srq_ex_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_srq_ex(args->context, args->srq_init_attr_ex);
|
||||
);}
|
||||
|
||||
void call_ibv_modify_srq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_modify_srq_t * args = (uhyve_ibv_modify_srq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_modify_srq(args->srq, args->srq_attr, args->srq_attr_mask);
|
||||
);}
|
||||
|
||||
void call_ibv_query_srq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_srq_t * args = (uhyve_ibv_query_srq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_query_srq(args->srq, args->srq_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_get_srq_num(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_srq_num_t * args = (uhyve_ibv_get_srq_num_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_get_srq_num(args->srq, args->srq_num);
|
||||
);}
|
||||
|
||||
void call_ibv_destroy_srq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_srq_t * args = (uhyve_ibv_destroy_srq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_destroy_srq(args->srq);
|
||||
);}
|
||||
|
||||
void call_ibv_post_srq_recv(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_post_srq_recv_t * args = (uhyve_ibv_post_srq_recv_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_post_srq_recv(args->srq, args->recv_wr, args->bad_recv_wr);
|
||||
);}
|
||||
|
||||
void call_ibv_create_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_qp_t * args = (uhyve_ibv_create_qp_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_qp(args->pd, args->qp_init_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_create_qp_ex(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_qp_ex_t * args = (uhyve_ibv_create_qp_ex_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_qp_ex(args->context, args->qp_init_attr_ex);
|
||||
);}
|
||||
|
||||
void call_ibv_query_rt_values_ex(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_rt_values_ex_t * args = (uhyve_ibv_query_rt_values_ex_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_query_rt_values_ex(args->context, args->values);
|
||||
);}
|
||||
|
||||
void call_ibv_query_device_ex(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_device_ex_t * args = (uhyve_ibv_query_device_ex_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_query_device_ex(args->context, args->input, args->attr);
|
||||
);}
|
||||
|
||||
void call_ibv_open_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_open_qp_t * args = (uhyve_ibv_open_qp_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_open_qp(args->context, args->qp_open_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_modify_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_modify_qp_t * args = (uhyve_ibv_modify_qp_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_modify_qp(args->qp, args->attr, args->attr_mask);
|
||||
);}
|
||||
|
||||
void call_ibv_query_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_qp_t * args = (uhyve_ibv_query_qp_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_query_qp(args->qp, args->attr, args->attr_mask, args->init_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_destroy_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_qp_t * args = (uhyve_ibv_destroy_qp_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_destroy_qp(args->qp);
|
||||
);}
|
||||
|
||||
void call_ibv_create_wq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_wq_t * args = (uhyve_ibv_create_wq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_wq(args->context, args->wq_init_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_modify_wq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_modify_wq_t * args = (uhyve_ibv_modify_wq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_modify_wq(args->wq, args->wq_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_destroy_wq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_wq_t * args = (uhyve_ibv_destroy_wq_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_destroy_wq(args->wq);
|
||||
);}
|
||||
|
||||
void call_ibv_create_rwq_ind_table(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_rwq_ind_table_t * args = (uhyve_ibv_create_rwq_ind_table_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_rwq_ind_table(args->context, args->init_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_destroy_rwq_ind_table(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_rwq_ind_table_t * args = (uhyve_ibv_destroy_rwq_ind_table_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_destroy_rwq_ind_table(args->rwq_ind_table);
|
||||
);}
|
||||
|
||||
void call_ibv_post_send(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_post_send_t * args = (uhyve_ibv_post_send_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_post_send(args->qp, args->wr, args->bad_wr);
|
||||
);}
|
||||
|
||||
void call_ibv_post_recv(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_post_recv_t * args = (uhyve_ibv_post_recv_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_post_recv(args->qp, args->wr, args->bad_wr);
|
||||
);}
|
||||
|
||||
void call_ibv_create_ah(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_ah_t * args = (uhyve_ibv_create_ah_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_ah(args->pd, args->attr);
|
||||
);}
|
||||
|
||||
void call_ibv_init_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_init_ah_from_wc_t * args = (uhyve_ibv_init_ah_from_wc_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_init_ah_from_wc(args->context, args->port_num, args->wc, args->grh, args->ah_attr);
|
||||
);}
|
||||
|
||||
void call_ibv_create_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_ah_from_wc_t * args = (uhyve_ibv_create_ah_from_wc_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_create_ah_from_wc(args->pd, args->wc, args->grh, args->port_num);
|
||||
);}
|
||||
|
||||
void call_ibv_destroy_ah(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_ah_t * args = (uhyve_ibv_destroy_ah_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_destroy_ah(args->ah);
|
||||
);}
|
||||
|
||||
void call_ibv_attach_mcast(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_attach_mcast_t * args = (uhyve_ibv_attach_mcast_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_attach_mcast(args->qp, args->gid, args->lid);
|
||||
);}
|
||||
|
||||
void call_ibv_detach_mcast(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_detach_mcast_t * args = (uhyve_ibv_detach_mcast_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_detach_mcast(args->qp, args->gid, args->lid);
|
||||
);}
|
||||
|
||||
void call_ibv_fork_init(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_fork_init_t * args = (uhyve_ibv_fork_init_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_fork_init(args->);
|
||||
);}
|
||||
|
||||
void call_ibv_node_type_str(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_node_type_str_t * args = (uhyve_ibv_node_type_str_t *) (guest_mem + data);
|
||||
|
||||
const char * host_ret = ibv_node_type_str(args->node_type);
|
||||
);memcpy(args->ret, host_ret, sizeof(host_ret));}
|
||||
|
||||
void call_ibv_port_state_str(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_port_state_str_t * args = (uhyve_ibv_port_state_str_t *) (guest_mem + data);
|
||||
|
||||
const char * host_ret = ibv_port_state_str(args->port_state);
|
||||
);memcpy(args->ret, host_ret, sizeof(host_ret));}
|
||||
|
||||
void call_ibv_event_type_str(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_event_type_str_t * args = (uhyve_ibv_event_type_str_t *) (guest_mem + data);
|
||||
|
||||
const char * host_ret = ibv_event_type_str(args->event);
|
||||
);memcpy(args->ret, host_ret, sizeof(host_ret));}
|
||||
|
||||
void call_ibv_resolve_eth_l2_from_gid(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_resolve_eth_l2_from_gid_t * args = (uhyve_ibv_resolve_eth_l2_from_gid_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_resolve_eth_l2_from_gid(args->context, args->attr, args->eth_mac[6], args->vid);
|
||||
);}
|
||||
|
||||
void call_ibv_is_qpt_supported(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_is_qpt_supported_t * args = (uhyve_ibv_is_qpt_supported_t *) (guest_mem + data);
|
||||
|
||||
args.ret = ibv_is_qpt_supported(args->caps, args->qpt);
|
||||
);}
|
||||
|
||||
|
|
|
@ -1,12 +1,231 @@
|
|||
case UHYVE_PORT_IBV_OPEN_DEVICE:
|
||||
call_ibv_open_device(run, guest_mem);
|
||||
case UHYVE_PORT_IBV_WC_STATUS_STR:
|
||||
call_ibv_wc_status_str(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_RATE_TO_MULT:
|
||||
call_ibv_rate_to_mult(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_MULT_TO_IBV_RATE:
|
||||
call_mult_to_ibv_rate(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_RATE_TO_MBPS:
|
||||
call_ibv_rate_to_mbps(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_MBPS_TO_IBV_RATE:
|
||||
call_mbps_to_ibv_rate(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_POST_WQ_RECV:
|
||||
call_ibv_post_wq_recv(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_VERBS_GET_CTX:
|
||||
call_verbs_get_ctx(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_LIST:
|
||||
call_ibv_get_device_list(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_FREE_DEVICE_LIST:
|
||||
call_ibv_free_device_list(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_NAME:
|
||||
call_ibv_get_device_name(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_GUID:
|
||||
call_ibv_get_device_guid(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_OPEN_DEVICE:
|
||||
call_ibv_open_device(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CLOSE_DEVICE:
|
||||
call_ibv_close_device(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_ASYNC_EVENT:
|
||||
call_ibv_get_async_event(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ACK_ASYNC_EVENT:
|
||||
call_ibv_ack_async_event(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_DEVICE:
|
||||
call_ibv_query_device(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_PORT:
|
||||
call_ibv_query_port(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT____IBV_QUERY_PORT:
|
||||
call____ibv_query_port(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_GID:
|
||||
call_ibv_query_gid(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_PKEY:
|
||||
call_ibv_query_pkey(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ALLOC_PD:
|
||||
call_ibv_alloc_pd(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DEALLOC_PD:
|
||||
call_ibv_dealloc_pd(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_FLOW:
|
||||
call_ibv_create_flow(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_FLOW:
|
||||
call_ibv_destroy_flow(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_OPEN_XRCD:
|
||||
call_ibv_open_xrcd(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CLOSE_XRCD:
|
||||
call_ibv_close_xrcd(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_REG_MR:
|
||||
call_ibv_reg_mr(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_REREG_MR:
|
||||
call_ibv_rereg_mr(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DEREG_MR:
|
||||
call_ibv_dereg_mr(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ALLOC_MW:
|
||||
call_ibv_alloc_mw(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DEALLOC_MW:
|
||||
call_ibv_dealloc_mw(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_INC_RKEY:
|
||||
call_ibv_inc_rkey(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_BIND_MW:
|
||||
call_ibv_bind_mw(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_COMP_CHANNEL:
|
||||
call_ibv_create_comp_channel(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL:
|
||||
call_ibv_destroy_comp_channel(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_CQ:
|
||||
call_ibv_create_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_CQ_EX:
|
||||
call_ibv_create_cq_ex(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_RESIZE_CQ:
|
||||
call_ibv_resize_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_CQ:
|
||||
call_ibv_destroy_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_CQ_EVENT:
|
||||
call_ibv_get_cq_event(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ACK_CQ_EVENTS:
|
||||
call_ibv_ack_cq_events(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_POLL_CQ:
|
||||
call_ibv_poll_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_REQ_NOTIFY_CQ:
|
||||
call_ibv_req_notify_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_SRQ:
|
||||
call_ibv_create_srq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_SRQ_EX:
|
||||
call_ibv_create_srq_ex(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_MODIFY_SRQ:
|
||||
call_ibv_modify_srq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_SRQ:
|
||||
call_ibv_query_srq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_SRQ_NUM:
|
||||
call_ibv_get_srq_num(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_SRQ:
|
||||
call_ibv_destroy_srq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_POST_SRQ_RECV:
|
||||
call_ibv_post_srq_recv(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_QP:
|
||||
call_ibv_create_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_QP_EX:
|
||||
call_ibv_create_qp_ex(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_RT_VALUES_EX:
|
||||
call_ibv_query_rt_values_ex(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_DEVICE_EX:
|
||||
call_ibv_query_device_ex(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_OPEN_QP:
|
||||
call_ibv_open_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_MODIFY_QP:
|
||||
call_ibv_modify_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_QP:
|
||||
call_ibv_query_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_QP:
|
||||
call_ibv_destroy_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_WQ:
|
||||
call_ibv_create_wq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_MODIFY_WQ:
|
||||
call_ibv_modify_wq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_WQ:
|
||||
call_ibv_destroy_wq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE:
|
||||
call_ibv_create_rwq_ind_table(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE:
|
||||
call_ibv_destroy_rwq_ind_table(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_POST_SEND:
|
||||
call_ibv_post_send(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_POST_RECV:
|
||||
call_ibv_post_recv(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_AH:
|
||||
call_ibv_create_ah(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_INIT_AH_FROM_WC:
|
||||
call_ibv_init_ah_from_wc(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_AH_FROM_WC:
|
||||
call_ibv_create_ah_from_wc(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_AH:
|
||||
call_ibv_destroy_ah(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ATTACH_MCAST:
|
||||
call_ibv_attach_mcast(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DETACH_MCAST:
|
||||
call_ibv_detach_mcast(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_FORK_INIT:
|
||||
call_ibv_fork_init(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_NODE_TYPE_STR:
|
||||
call_ibv_node_type_str(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_PORT_STATE_STR:
|
||||
call_ibv_port_state_str(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_EVENT_TYPE_STR:
|
||||
call_ibv_event_type_str(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID:
|
||||
call_ibv_resolve_eth_l2_from_gid(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_IS_QPT_SUPPORTED:
|
||||
call_ibv_is_qpt_supported(run, guest_mem);
|
||||
break;
|
||||
|
|
|
@ -3,25 +3,6 @@ int ibv_rate_to_mult(enum ibv_rate rate)
|
|||
enum ibv_rate mult_to_ibv_rate(int mult)
|
||||
int ibv_rate_to_mbps(enum ibv_rate rate)
|
||||
enum ibv_rate mbps_to_ibv_rate(int mbps)
|
||||
struct ibv_cq * ibv_cq_ex_to_cq(struct ibv_cq_ex * cq)
|
||||
int ibv_start_poll(struct ibv_cq_ex * cq,struct ibv_poll_cq_attr * attr)
|
||||
int ibv_next_poll(struct ibv_cq_ex * cq)
|
||||
void ibv_end_poll(struct ibv_cq_ex * cq)
|
||||
enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex * cq)
|
||||
uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex * cq)
|
||||
uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex * cq)
|
||||
__be32 ibv_wc_read_imm_data(struct ibv_cq_ex * cq)
|
||||
uint32_t ibv_wc_read_invalidated_rkey(struct ibv_cq_ex * cq)
|
||||
uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex * cq)
|
||||
uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex * cq)
|
||||
int ibv_wc_read_wc_flags(struct ibv_cq_ex * cq)
|
||||
uint32_t ibv_wc_read_slid(struct ibv_cq_ex * cq)
|
||||
uint8_t ibv_wc_read_sl(struct ibv_cq_ex * cq)
|
||||
uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex * cq)
|
||||
uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex * cq)
|
||||
uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex * cq)
|
||||
uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex * cq)
|
||||
int ibv_post_wq_recv(struct ibv_wq * wq,struct ibv_recv_wr * recv_wr,struct ibv_recv_wr ** bad_recv_wr)
|
||||
struct verbs_context * verbs_get_ctx(struct ibv_context * ctx)
|
||||
struct ibv_device ** ibv_get_device_list(int * num_devices)
|
||||
void ibv_free_device_list(struct ibv_device ** list)
|
||||
|
@ -52,7 +33,6 @@ int ibv_bind_mw(struct ibv_qp * qp,struct ibv_mw * mw,struct ibv_mw_bind * mw_bi
|
|||
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context)
|
||||
int ibv_destroy_comp_channel(struct ibv_comp_channel * channel)
|
||||
struct ibv_cq * ibv_create_cq(struct ibv_context * context,int cqe,void * cq_context,struct ibv_comp_channel * channel,int comp_vector)
|
||||
struct ibv_cq_ex * ibv_create_cq_ex(struct ibv_context * context,struct ibv_cq_init_attr_ex * cq_attr)
|
||||
int ibv_resize_cq(struct ibv_cq * cq,int cqe)
|
||||
int ibv_destroy_cq(struct ibv_cq * cq)
|
||||
int ibv_get_cq_event(struct ibv_comp_channel * channel,struct ibv_cq ** cq,void ** cq_context)
|
||||
|
@ -68,17 +48,11 @@ int ibv_destroy_srq(struct ibv_srq * srq)
|
|||
int ibv_post_srq_recv(struct ibv_srq * srq,struct ibv_recv_wr * recv_wr,struct ibv_recv_wr ** bad_recv_wr)
|
||||
struct ibv_qp * ibv_create_qp(struct ibv_pd * pd,struct ibv_qp_init_attr * qp_init_attr)
|
||||
struct ibv_qp * ibv_create_qp_ex(struct ibv_context * context,struct ibv_qp_init_attr_ex * qp_init_attr_ex)
|
||||
int ibv_query_rt_values_ex(struct ibv_context * context,struct ibv_values_ex * values)
|
||||
int ibv_query_device_ex(struct ibv_context * context,const struct ibv_query_device_ex_input * input,struct ibv_device_attr_ex * attr)
|
||||
struct ibv_qp * ibv_open_qp(struct ibv_context * context,struct ibv_qp_open_attr * qp_open_attr)
|
||||
int ibv_modify_qp(struct ibv_qp * qp,struct ibv_qp_attr * attr,int attr_mask)
|
||||
int ibv_query_qp(struct ibv_qp * qp,struct ibv_qp_attr * attr,int attr_mask,struct ibv_qp_init_attr * init_attr)
|
||||
int ibv_destroy_qp(struct ibv_qp * qp)
|
||||
struct ibv_wq * ibv_create_wq(struct ibv_context * context,struct ibv_wq_init_attr * wq_init_attr)
|
||||
int ibv_modify_wq(struct ibv_wq * wq,struct ibv_wq_attr * wq_attr)
|
||||
int ibv_destroy_wq(struct ibv_wq * wq)
|
||||
struct ibv_rwq_ind_table * ibv_create_rwq_ind_table(struct ibv_context * context,struct ibv_rwq_ind_table_init_attr * init_attr)
|
||||
int ibv_destroy_rwq_ind_table(struct ibv_rwq_ind_table * rwq_ind_table)
|
||||
int ibv_post_send(struct ibv_qp * qp,struct ibv_send_wr * wr,struct ibv_send_wr ** bad_wr)
|
||||
int ibv_post_recv(struct ibv_qp * qp,struct ibv_recv_wr * wr,struct ibv_recv_wr ** bad_wr)
|
||||
struct ibv_ah * ibv_create_ah(struct ibv_pd * pd,struct ibv_ah_attr * attr)
|
||||
|
@ -91,5 +65,4 @@ int ibv_fork_init()
|
|||
const char * ibv_node_type_str(enum ibv_node_type node_type)
|
||||
const char * ibv_port_state_str(enum ibv_port_state port_state)
|
||||
const char * ibv_event_type_str(enum ibv_event_type event)
|
||||
int ibv_resolve_eth_l2_from_gid(struct ibv_context * context,struct ibv_ah_attr * attr,uint8_t [6] eth_mac,uint16_t * vid)
|
||||
int ibv_is_qpt_supported(uint32_t caps,enum ibv_qp_type qpt)
|
||||
|
|
|
@ -92,14 +92,15 @@ from parser import generate_struct_conversions
|
|||
|
||||
|
||||
# Path of the input file containing function prototypes.
|
||||
SRC_PATH = "function-prototypes-0.txt"
|
||||
SRC_PATH = "function-prototypes.txt"
|
||||
|
||||
# Paths of the files that are generated by the script.
|
||||
IBV_GEN_PATH = "GEN-kernel-ibv.c"
|
||||
KERNEL_GEN_PATH = "GEN-kernel.c"
|
||||
KERNEL_HEADER_GEN_PATH = "GEN-kernel-header.h"
|
||||
UHYVE_CASES_GEN_PATH = "GEN-tools-uhyve.c"
|
||||
UHYVE_IBV_HEADER_GEN_PATH = "GEN-tools-uhyve-ibv-ports.h"
|
||||
INCLUDE_STDDEF_GEN_PATH = "GEN-include-hermit-stddef.h"
|
||||
UHYVE_IBV_HEADER_STRUCTS_GEN_PATH = "GEN-tools-uhyve-ibv-structs.h"
|
||||
# UHYVE_IBV_HEADER_STRUCTS_GEN_PATH = "GEN-tools-uhyve-ibv-structs.h"
|
||||
UHYVE_HOST_FCNS_GEN_PATH = "GEN-tools-uhyve-ibv.c"
|
||||
# VERBS_HEADER_PATH = "verbs-0.h"
|
||||
|
||||
|
@ -112,8 +113,12 @@ NEWLINES = ["", "\n", "\n\n"]
|
|||
class Type:
|
||||
def __init__(self, string):
|
||||
ts = string
|
||||
if (string[-1] is "*") and (string[-2] is not " "):
|
||||
ts = string[:-1] + " *"
|
||||
|
||||
# if len(string) > 2 and string[-1] is "*":
|
||||
# if string[-2] is "*" and string[-3] is not " ":
|
||||
# ts = string[:-2] + " **"
|
||||
# elif string[-2] is not " ":
|
||||
# ts = string[:-1] + " *"
|
||||
|
||||
self.type_string = ts
|
||||
self.type_components = ts.split(" ")
|
||||
|
@ -127,9 +132,15 @@ class Type:
|
|||
def is_struct(self):
|
||||
return self.type_components[0] == "struct"
|
||||
|
||||
def is_char_arr(self):
|
||||
return self.is_pointer() and "char" in self.type_components
|
||||
|
||||
def is_pointer(self):
|
||||
return self.type_components[-1] == "*"
|
||||
|
||||
def is_pointer_pointer(self):
|
||||
return self.type_components[-1] == "**"
|
||||
|
||||
def is_void(self):
|
||||
return self.type_string == "void"
|
||||
|
||||
|
@ -139,10 +150,12 @@ class FunctionParameter:
|
|||
components = string.split(" ")
|
||||
type_string = " ".join(components[:-1])
|
||||
|
||||
# print("string in FunctionParameter: ", string)
|
||||
|
||||
self.type = Type(type_string)
|
||||
self.name = components[-1]
|
||||
|
||||
def get_full_expression:
|
||||
def get_full_expression(self):
|
||||
return self.type.type_string + " " + self.name
|
||||
|
||||
def get_struct_name(self):
|
||||
|
@ -154,6 +167,9 @@ class FunctionParameter:
|
|||
def is_pointer(self):
|
||||
return self.type.is_pointer()
|
||||
|
||||
def is_pointer_pointer(self):
|
||||
return self.type.is_pointer_pointer()
|
||||
|
||||
|
||||
class FunctionPrototype:
|
||||
def __init__(self, string):
|
||||
|
@ -166,33 +182,40 @@ class FunctionPrototype:
|
|||
self.ret = Type(" ".join(ret_and_name[:-1]))
|
||||
self.function_name = ret_and_name[-1]
|
||||
|
||||
def generate_args_struct(ret, function_name, params):
|
||||
def generate_args_struct(self):
|
||||
"""Generates the struct to hold a function's parameters and return value.
|
||||
|
||||
Args:
|
||||
ret: Return type as string.
|
||||
function_name: Function name as string.
|
||||
params: Parameters as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated struct as string.
|
||||
"""
|
||||
code = ""
|
||||
code = "typedef struct {\n"
|
||||
|
||||
if self.get_num_parameters() > 0:
|
||||
code += "\t// Parameters:\n"
|
||||
for param in self.parameters:
|
||||
code += "\t{0};\n".format(param.get_full_expression())
|
||||
code += "\t// Parameters:\n"
|
||||
for param in self.parameters or []:
|
||||
code += "\t{0};\n".format(param.get_full_expression())
|
||||
|
||||
if not self.ret.is_void():
|
||||
code += "\t// Return value:\n"
|
||||
code += "\t{0} ret;\n".format(self.ret.type_string)
|
||||
|
||||
code += "}} __attribute__((packed)) {0};\n\n".format( self.get_args_struct_name())
|
||||
code += "}} __attribute__((packed)) {0};\n\n".format(self.get_args_struct_name())
|
||||
|
||||
return code
|
||||
|
||||
def generate_function_declaration(self):
|
||||
return "{} {}({});\n".format(self.ret.type_string, self.function_name,
|
||||
self.get_string_of_parameters())
|
||||
|
||||
def get_string_of_parameters(self):
|
||||
return ", ".join([param.get_full_expression() for param in self.parameters])
|
||||
|
||||
def generate_uhyve_function_declaration(self):
|
||||
name = self.get_uhyve_call_function_name()
|
||||
return "void {0}(struct kvm_run * run, uint8_t * guest_mem);\n".format(name)
|
||||
|
||||
def get_uhyve_call_function_name(self):
|
||||
return "call_{0}".format(self.function_name)
|
||||
|
||||
def get_num_parameters(self):
|
||||
return len(self.parameters)
|
||||
|
||||
|
@ -210,131 +233,47 @@ class FunctionPrototype:
|
|||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
def generate_pretty_comment(string):
|
||||
return "/*\n * {0}\n */\n\n".format(string)
|
||||
|
||||
|
||||
# def get_struct_name(function_name):
|
||||
# """Returns the matching struct name for a given function name.
|
||||
# """
|
||||
# return "uhyve_{0}_t".format(function_name)
|
||||
def generate_kernel_header_declarations(function_prototypes):
|
||||
code = ""
|
||||
for pt in function_prototypes:
|
||||
code += pt.generate_function_declaration()
|
||||
return code
|
||||
|
||||
|
||||
# def parse_line(line):
|
||||
# """Parses a line containing a function prototype.
|
||||
|
||||
# Args:
|
||||
# line: Line of the following format:
|
||||
# <return_type> <function_name>(<param_type> <param_name>, [...])
|
||||
|
||||
# Returns:
|
||||
# [Return type, function name, parameters] as Tuple[string, string, list[string]]
|
||||
# """
|
||||
# parens_split = line.split("(")
|
||||
|
||||
# ret_and_name = parens_split[0].split(" ")
|
||||
# all_params = parens_split[-1][:-1]
|
||||
|
||||
# ret = " ".join(ret_and_name[:-1])
|
||||
# function_name = ret_and_name[-1]
|
||||
|
||||
# params = all_params.split(",")
|
||||
# params[-1] = params[-1][:-1]
|
||||
|
||||
# return ret, function_name, params
|
||||
|
||||
|
||||
# def generate_struct(ret, function_name, params):
|
||||
# """Generates the struct to hold a function's parameters and return value.
|
||||
|
||||
# Args:
|
||||
# ret: Return type as string.
|
||||
# function_name: Function name as string.
|
||||
# params: Parameters as list of strings.
|
||||
|
||||
# Returns:
|
||||
# Generated struct as string.
|
||||
# """
|
||||
# struct = "typedef struct {\n"
|
||||
# if params:
|
||||
# struct += "\t// Parameters:\n"
|
||||
# for param in params:
|
||||
# struct += "\t{0};\n".format(param)
|
||||
|
||||
# if ret is not "void":
|
||||
# struct += "\t// Return value:\n"
|
||||
# struct += "\t{0} ret;\n".format(ret)
|
||||
|
||||
# struct_name = get_struct_name(function_name)
|
||||
# struct += "}} __attribute__((packed)) {0};\n\n".format(struct_name)
|
||||
|
||||
# return struct
|
||||
|
||||
# TODO: hier gehts weiter
|
||||
def generate_kernel_function(ret, function_name, params):
|
||||
def generate_kernel_function(function_prototype):
|
||||
"""Generates the kernel function that sends the KVM exit IO to uhyve.
|
||||
|
||||
Args:
|
||||
ret: Return type as string.
|
||||
function_name: Function name as string.
|
||||
params: Parameters as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated function as string.
|
||||
"""
|
||||
code = ""
|
||||
fnc_name = function_prototype.function_name
|
||||
ret_type = function_prototype.ret
|
||||
params = function_prototype.parameters
|
||||
port_name = function_prototype.get_port_name()
|
||||
|
||||
code = "{0} {1}({2}) {{\n".format(ret, function_name, ", ".join(params))
|
||||
comma_separated_params = function_prototype.get_string_of_parameters()
|
||||
code = "{0} {1}({2}) {{\n".format(ret_type.type_string, fnc_name, comma_separated_params)
|
||||
code += "\t{0} uhyve_args;\n".format(function_prototype.get_args_struct_name())
|
||||
|
||||
# Create uhyve_args and define parameters
|
||||
struct_name = get_struct_name(function_name)
|
||||
code += "\t{0} ret_guest;\n".format(ret)
|
||||
code += "\t{0} uhyve_args;\n".format(struct_name)
|
||||
|
||||
# TODO: Make a class for function prototypes
|
||||
for param in params:
|
||||
param_split = param.split(" ")
|
||||
param_type = " ".join(param_split[:-1])
|
||||
param_name = param_split[-1]
|
||||
|
||||
# Define struct members according to their type.
|
||||
if "**" in param_type:
|
||||
for p in params or []:
|
||||
if p.is_pointer_pointer():
|
||||
code += "\t// TODO: Take care of ** parameter.\n"
|
||||
elif "*" in param_type:
|
||||
# TODO: char ptrs
|
||||
code += "\tuhyve_args.{0} = guest_to_host_{1}({2});\n".format(param_name,
|
||||
param_split[1])
|
||||
else:
|
||||
code += "\tuhyve_args,{0} = {0};\n".format(param_name)
|
||||
code += "\tuhyve_args.{0} = {0};\n".format(p.name)
|
||||
code += "\n"
|
||||
|
||||
# call uhyve_send() using the respective port ID.
|
||||
port_name = "UHYVE_PORT_" + function_name.upper()
|
||||
code += "\n\tuhyve_send({0}, (unsigned) virt_to_phys((size_t) " \
|
||||
"&uhyve_args));\n\n".format(port_name)
|
||||
|
||||
for param in params:
|
||||
param_split = param.split(" ")
|
||||
param_type = " ".join(param_split[:-1])
|
||||
param_name = param_split[-1]
|
||||
|
||||
# Define struct members according to their type.
|
||||
if "**" in param_type:
|
||||
code += "\t// TODO: Take care of ** parameter.\n"
|
||||
elif "*" in param_type:
|
||||
code += "\thost_to_guest_{0}({1}, GUEST);".format(param_split[1], param_name)
|
||||
|
||||
if "**" in ret:
|
||||
code += "\t// TODO: Take care of ** parameter.\n"
|
||||
elif "*" in ret:
|
||||
code += "\tret_guest = host_to_guest_{0}(uhyve_args.ret, HOST)\n".format(ret[1])
|
||||
else:
|
||||
code += "\tret_guest = uhyve_args.ret;\n"
|
||||
|
||||
code += "\n\treturn ret_guest;\n"
|
||||
code += "}\n\n\n"
|
||||
code += "\tuhyve_send({0}, (unsigned) virt_to_phys((size_t) &uhyve_args));\n".format(port_name)
|
||||
if not ret_type.is_void():
|
||||
code += "\n\treturn uhyve_args.ret;\n"
|
||||
code += "}\n\n"
|
||||
|
||||
return code
|
||||
|
||||
|
||||
# TODO: done
|
||||
def generate_uhyve_cases(function_prototypes):
|
||||
""" Generates all switch-cases for uhyve's KVM exit IO.
|
||||
|
||||
|
@ -342,100 +281,73 @@ def generate_uhyve_cases(function_prototypes):
|
|||
Generated switch-cases [string]
|
||||
"""
|
||||
code = ""
|
||||
|
||||
for pt in function_prototypes:
|
||||
name = pt.function_name
|
||||
call_fnc_name = pt.get_uhyve_call_function_name()
|
||||
port_name = pt.get_port_name()
|
||||
|
||||
code += "{0}{1}case {2}:".format(NEWLINES[1], TABS[3], port_name)
|
||||
code += "{0}{1}call_{2}(run, guest_mem);".format(NEWLINES[1], TABS[4], name)
|
||||
code += "{0}{1}break;".format(NEWLINES[1], TABS[4])
|
||||
code += "\t\t\tcase {0}:\n".format(port_name)
|
||||
code += "\t\t\t\t{0}(run, guest_mem);\n".format(call_fnc_name)
|
||||
code += "\t\t\t\tbreak;\n"
|
||||
|
||||
return code
|
||||
|
||||
# const char * host_ret = ibv_wc_status_str(args->status); // !
|
||||
# memcpy(args->ret, host_ret, sizeof(host_ret)); // !
|
||||
|
||||
def generate_uhyve_function(prototype):
|
||||
args_struct_name = prototype.get_args_struct_name()
|
||||
fnc_name = prototype.function_name
|
||||
ret_type = prototype.ret
|
||||
|
||||
code = "void call_{0}(struct kvm_run * run, uint8_t * guest_mem) {{\n".format(fnc_name)
|
||||
code += "\tunsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));\n"
|
||||
code += "\t{0} * args = ({0} *) (guest_mem + data);\n\n".format(args_struct_name)
|
||||
|
||||
if prototype.ret.is_pointer_pointer():
|
||||
code += "\t// TODO: Take care of ** here.\n"
|
||||
else:
|
||||
code += "\t"
|
||||
if not ret_type.is_void():
|
||||
if ret_type.is_char_arr():
|
||||
code += "const char * host_ret = "
|
||||
else:
|
||||
code += "args.ret = "
|
||||
code += "{0}(".format(fnc_name)
|
||||
|
||||
if prototype.get_num_parameters() > 0:
|
||||
for param in prototype.parameters[:-1] or []:
|
||||
code += "args->{}, ".format(param.name)
|
||||
code += "args->{});\n".format(prototype.parameters[-1].name)
|
||||
code += ");"
|
||||
|
||||
if ret_type.is_char_arr():
|
||||
code += "memcpy(args->ret, host_ret, sizeof(host_ret));"
|
||||
|
||||
|
||||
code += "}\n\n"
|
||||
|
||||
return code
|
||||
|
||||
|
||||
# TODO: hier gehts weiter
|
||||
def generate_uhyve_host_function(ret, function_name, params):
|
||||
"""Generates a switch-case that catches a KVM exit IO for the given function in uhyve.
|
||||
|
||||
Args:
|
||||
ret: Return type as string.
|
||||
function_name: Function name as string.
|
||||
params: Parameters as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated switch-case code as string.
|
||||
"""
|
||||
|
||||
def generate_host_call_parameter(param):
|
||||
"""Generates the parameter for the host's function called from within uhyve.
|
||||
|
||||
This distinguishes between pointers and non-pointers since pointers have to
|
||||
be converted to host memory addresses.
|
||||
Example for pointer: guest_mem+(size_t)args->param
|
||||
Example for non-pointer: args->param
|
||||
|
||||
Args:
|
||||
param: The parameter type and name as a single string.
|
||||
|
||||
Returns:
|
||||
Generated parameter,
|
||||
"""
|
||||
param_name = param.split(" ")[-1]
|
||||
if "**" in param:
|
||||
host_param = "/* TODO: param {0}*/".format(param_name)
|
||||
elif "*" in param:
|
||||
host_param = "guest_mem+(size_t)args->{0}".format(param_name)
|
||||
else:
|
||||
host_param = "{0}".format(param_name)
|
||||
|
||||
return host_param
|
||||
|
||||
struct_name = get_struct_name(function_name)
|
||||
|
||||
fcn = "{0}void call_{1}(struct kvm_run * run, uint8_t * guest_mem) {{".format(NEWLINES[1], function_name)
|
||||
fcn += "{0}{1}unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));".format(NEWLINES[1], TABS[1])
|
||||
fcn += "{0}{1}{2} * args = ({2} *) (guest_mem + data);".format(NEWLINES[1], TABS[1], struct_name)
|
||||
fcn += "{0}{1}{2} host_ret = {3}(".format(NEWLINES[2], TABS[1], ret, function_name)
|
||||
|
||||
for param in params[:-1]:
|
||||
fcn += generate_host_call_parameter(param) + ", "
|
||||
else:
|
||||
fcn += generate_host_call_parameter(params[-1]) + ");"
|
||||
|
||||
if "**" in ret:
|
||||
fcn += "{0}{1}// TODO: Take care of {2} return value.".format(NEWLINES[1], TABS[1], ret)
|
||||
elif "*" in ret:
|
||||
fcn += "{0}{1}memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));".format(NEWLINES[1], TABS[1])
|
||||
fcn += "{0}{1}// TODO: Convert ptrs contained in return value.".format(NEWLINES[1], TABS[1])
|
||||
fcn += "{0}{1}// TODO: Delete host_ret data structure.".format(NEWLINES[1], TABS[1])
|
||||
else:
|
||||
fcn += "{0}{1}args->ret = host_ret;".format(NEWLINES[1], TABS[1])
|
||||
|
||||
fcn += "{0}}}{0}".format(NEWLINES[1])
|
||||
|
||||
return fcn
|
||||
|
||||
|
||||
def generate_port_enum(function_names):
|
||||
def generate_port_enum(function_prototypes):
|
||||
"""Generates the enum mapping KVM exit IO port names to port numbers.
|
||||
|
||||
Args:
|
||||
function_names: All function names to be mapped to ports as list of strings.
|
||||
function_prototypes: All function names to be mapped to ports as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated complete enum.
|
||||
"""
|
||||
port_enum = "typedef enum {"
|
||||
for num, function_name in enumerate(function_names, PORT_NUMBER_START):
|
||||
port_enum += "\n\tUHYVE_PORT_{0} = 0x{1},".format(function_name.upper(),
|
||||
format(num, "X"))
|
||||
port_enum += "\n} uhyve_ibv_t;"
|
||||
code = "typedef enum {\n"
|
||||
for num, pt in enumerate(function_prototypes, PORT_NUMBER_START):
|
||||
port_name = pt.get_port_name()
|
||||
code += "\t{0} = 0x{1},\n".format(port_name, format(num, "X"))
|
||||
code += "} uhyve_ibv_t;"
|
||||
|
||||
return port_enum
|
||||
return code
|
||||
|
||||
|
||||
def generate_port_macros(function_names):
|
||||
def generate_port_macros(function_prototypes):
|
||||
"""Generates the compiler macros mapping KVM exit IO port names to port numbers.
|
||||
|
||||
Args:
|
||||
|
@ -444,47 +356,47 @@ def generate_port_macros(function_names):
|
|||
Returns:
|
||||
Generated list of compiler macros.
|
||||
"""
|
||||
macros = ""
|
||||
for num, function_name in enumerate(function_names, PORT_NUMBER_START):
|
||||
macros += "\n#define UHYVE_PORT_{0} 0x{1}".format(function_name.upper(),
|
||||
format(num, "X"))
|
||||
return macros
|
||||
|
||||
code = ""
|
||||
for num, pt in enumerate(function_prototypes, PORT_NUMBER_START):
|
||||
port_name = pt.get_port_name()
|
||||
code += "#define {0} 0x{1}\n".format(port_name, format(num, "X"))
|
||||
return code
|
||||
|
||||
if __name__ == "__main__":
|
||||
"""TODO: Doc
|
||||
"""
|
||||
with open(SRC_PATH, "r") as f_src, \
|
||||
open(IBV_GEN_PATH, "w") as f_ibv, \
|
||||
open(UHYVE_HOST_FCNS_GEN_PATH, "w") as f_uhyve_host_fncs, \
|
||||
open(UHYVE_IBV_HEADER_STRUCTS_GEN_PATH, "w") as f_structs:
|
||||
function_names = []
|
||||
# Make this like the structure below.
|
||||
for line in f_src:
|
||||
ret, function_name, params = parse_line(line)
|
||||
function_names.append(function_name)
|
||||
prototypes = []
|
||||
|
||||
struct = generate_struct(ret, function_name, params)
|
||||
f_ibv.write(struct)
|
||||
f_structs.write(struct)
|
||||
with open(SRC_PATH, "r") as f:
|
||||
for line in f:
|
||||
if line:
|
||||
prototypes.append(FunctionPrototype(line))
|
||||
|
||||
kernel_function = generate_kernel_function(ret, function_name, params)
|
||||
f_ibv.write(kernel_function)
|
||||
with open(UHYVE_CASES_GEN_PATH, "w") as f:
|
||||
f.write(generate_uhyve_cases(prototypes))
|
||||
|
||||
uhyve_fnc = generate_uhyve_host_function(ret, function_name, params)
|
||||
f_uhyve_host_fncs.write(uhyve_fnc)
|
||||
with open(INCLUDE_STDDEF_GEN_PATH, "w") as f:
|
||||
f.write(generate_port_macros(prototypes))
|
||||
|
||||
with open(UHYVE_IBV_HEADER_GEN_PATH, "w") as f_uhyve_ibv:
|
||||
port_enum = generate_port_enum(function_names)
|
||||
f_uhyve_ibv.write(port_enum)
|
||||
with open(UHYVE_IBV_HEADER_GEN_PATH, "w") as f:
|
||||
f.write(generate_port_enum(prototypes))
|
||||
f.write("\n\n")
|
||||
|
||||
with open(UHYVE_CASES_GEN_PATH, "w") as f_cases:
|
||||
uhyve_cases = generate_uhyve_cases(function_names)
|
||||
f_cases.write(uhyve_cases)
|
||||
for pt in prototypes:
|
||||
f.write(pt.generate_args_struct())
|
||||
f.write("\n\n")
|
||||
|
||||
with open(INCLUDE_STDDEF_GEN_PATH, "w") as f_stddef:
|
||||
port_macros = generate_port_macros(function_names)
|
||||
f_stddef.write(port_macros)
|
||||
for pt in prototypes:
|
||||
f.write(pt.generate_uhyve_function_declaration())
|
||||
|
||||
generate_struct_conversions()
|
||||
with open(UHYVE_HOST_FCNS_GEN_PATH, "w") as f:
|
||||
for pt in prototypes:
|
||||
f.write(generate_uhyve_function(pt))
|
||||
|
||||
with open(KERNEL_HEADER_GEN_PATH, "w") as f:
|
||||
f.write(generate_kernel_header_declarations(prototypes))
|
||||
|
||||
with open(KERNEL_GEN_PATH, "w") as f:
|
||||
for pt in prototypes:
|
||||
f.write(generate_pretty_comment(pt.function_name))
|
||||
f.write(pt.generate_args_struct())
|
||||
f.write(generate_kernel_function(pt))
|
||||
f.write("\n")
|
||||
|
|
|
@ -37,100 +37,555 @@
|
|||
* ibv_get_device_list
|
||||
*/
|
||||
|
||||
void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("LOG: UHYVE - call_ibv_get_device_list\n");
|
||||
|
||||
printf("temp check 1\n");
|
||||
int * temp = malloc(sizeof(int));
|
||||
*temp = 42;
|
||||
free(temp);
|
||||
|
||||
ib_malloc = true;
|
||||
unsigned data = *((unsigned *)((size_t)run+run->io.data_offset));
|
||||
void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem) { // !
|
||||
printf("UHYVE call: call_ibv_get_device_list\n");
|
||||
unsigned data = *((unsigned *) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_device_list_t * args = (uhyve_ibv_get_device_list_t *) (guest_mem + data);
|
||||
|
||||
printf("temp check 2\n");
|
||||
temp = malloc(sizeof(int));
|
||||
*temp = 42;
|
||||
free(temp);
|
||||
int num_devices;
|
||||
struct ibv_device ** host_ret = ibv_get_device_list(&num_devices);
|
||||
|
||||
printf("LOG: UHYVE - call_ibv_get_device_list -- before ibv call\n");
|
||||
args->ret = ibv_get_device_list(args->num_devices);
|
||||
printf("LOG: UHYVE - call_ibv_get_device_list -- after ibv call\n");
|
||||
|
||||
ib_malloc = false;
|
||||
if (args->num_devices != NULL) {
|
||||
*args->num_devices = num_devices;
|
||||
}
|
||||
for (int d = 0; d < num_devices; d++) {
|
||||
args->ret[d] = host_ret[d];
|
||||
}
|
||||
}
|
||||
|
||||
void call_ibv_wc_status_str(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_wc_status_str\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_wc_status_str_t * args = (uhyve_ibv_wc_status_str_t *) (guest_mem + data);
|
||||
|
||||
/*
|
||||
* ibv_get_device_name
|
||||
*/
|
||||
const char * host_ret = ibv_wc_status_str(args->status); // !
|
||||
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
|
||||
}
|
||||
|
||||
void call_ibv_rate_to_mult(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_rate_to_mult\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_rate_to_mult_t * args = (uhyve_ibv_rate_to_mult_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_rate_to_mult(args->rate);
|
||||
}
|
||||
|
||||
void call_mult_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_mult_to_ibv_rate\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_mult_to_ibv_rate_t * args = (uhyve_mult_to_ibv_rate_t *) (guest_mem + data);
|
||||
|
||||
args->ret = mult_to_ibv_rate(args->mult);
|
||||
}
|
||||
|
||||
void call_ibv_rate_to_mbps(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_rate_to_mbps\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_rate_to_mbps_t * args = (uhyve_ibv_rate_to_mbps_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_rate_to_mbps(args->rate);
|
||||
}
|
||||
|
||||
void call_mbps_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_mbps_to_ibv_rate\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_mbps_to_ibv_rate_t * args = (uhyve_mbps_to_ibv_rate_t *) (guest_mem + data);
|
||||
|
||||
args->ret = mbps_to_ibv_rate(args->mbps);
|
||||
}
|
||||
|
||||
void call_verbs_get_ctx(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_verbs_get_ctx\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_verbs_get_ctx_t * args = (uhyve_verbs_get_ctx_t *) (guest_mem + data);
|
||||
|
||||
args->ret = verbs_get_ctx(args->ctx);
|
||||
}
|
||||
|
||||
void call_ibv_free_device_list(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_free_device_list\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_free_device_list_t * args = (uhyve_ibv_free_device_list_t *) (guest_mem + data);
|
||||
}
|
||||
|
||||
void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("LOG: UHYVE - call_ibv_get_device_name\n");
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
printf("UHYVE call: call_ibv_get_device_name\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_device_name_t * args = (uhyve_ibv_get_device_name_t *) (guest_mem + data);
|
||||
|
||||
// TODO: Tricky because char ptr isn't allocated in called function.
|
||||
args->ret = ibv_get_device_name(args->device);
|
||||
/* memcpy(args->ret, host_ret, sizeof(host_ret)); */
|
||||
// TODO: Convert ptrs contained in return value.
|
||||
// TODO: How to tell if ret needs to be deleted?
|
||||
const char * host_ret = ibv_get_device_name(args->device); // !
|
||||
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
|
||||
}
|
||||
|
||||
void call_ibv_get_device_guid(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_get_device_guid\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_device_guid_t * args = (uhyve_ibv_get_device_guid_t *) (guest_mem + data);
|
||||
|
||||
/*
|
||||
* ibv_open_device
|
||||
*/
|
||||
args->ret = ibv_get_device_guid(args->device);
|
||||
}
|
||||
|
||||
void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("LOG: UHYVE - call_ibv_open_device\n");
|
||||
|
||||
ib_malloc = true;
|
||||
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
printf("UHYVE call: call_ibv_open_device\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_open_device_t * args = (uhyve_ibv_open_device_t *) (guest_mem + data);
|
||||
|
||||
printf("LOG: UHYVE - call_ibv_open_device\n");
|
||||
struct ibv_context * host_ret = ibv_open_device(args->device);
|
||||
printf("LOG: UHYVE - call_ibv_open_device\n");
|
||||
memcpy(args->ret, host_ret, sizeof(host_ret));
|
||||
printf("LOG: UHYVE - call_ibv_open_device\n");
|
||||
// TODO: Convert ptrs contained in return value.
|
||||
free(host_ret);
|
||||
printf("LOG: UHYVE - call_ibv_open_device\n");
|
||||
|
||||
ib_malloc = false;
|
||||
args->ret = ibv_open_device(args->device);
|
||||
}
|
||||
|
||||
void call_ibv_close_device(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_close_device\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_close_device_t * args = (uhyve_ibv_close_device_t *) (guest_mem + data);
|
||||
|
||||
/*
|
||||
* ibv_query_port
|
||||
*/
|
||||
args->ret = ibv_close_device(args->context);
|
||||
}
|
||||
|
||||
void call_ibv_get_async_event(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_get_async_event\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_async_event_t * args = (uhyve_ibv_get_async_event_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_get_async_event(args->context, args->event);
|
||||
}
|
||||
|
||||
void call_ibv_ack_async_event(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_ack_async_event\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_ack_async_event_t * args = (uhyve_ibv_ack_async_event_t *) (guest_mem + data);
|
||||
}
|
||||
|
||||
void call_ibv_query_device(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_query_device\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_device_t * args = (uhyve_ibv_query_device_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_query_device(args->context, args->device_attr);
|
||||
}
|
||||
|
||||
void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("LOG: UHYVE - call_ibv_query_port");
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
printf("UHYVE call: call_ibv_query_port\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_port_t * args = (uhyve_ibv_query_port_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_query_port(args->context, args->port_num, args->port_attr);
|
||||
args->ret = host_ret;
|
||||
args->ret = ibv_query_port(args->context, args->port_num, args->port_attr);
|
||||
}
|
||||
|
||||
void call____ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call____ibv_query_port\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve____ibv_query_port_t * args = (uhyve____ibv_query_port_t *) (guest_mem + data);
|
||||
|
||||
/*
|
||||
* ibv_create_comp_channel
|
||||
*/
|
||||
args->ret = ___ibv_query_port(args->context, args->port_num, args->port_attr);
|
||||
}
|
||||
|
||||
void call_ibv_query_gid(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_query_gid\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_gid_t * args = (uhyve_ibv_query_gid_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_query_gid(args->context, args->port_num, args->index, args->gid);
|
||||
}
|
||||
|
||||
void call_ibv_query_pkey(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_query_pkey\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_pkey_t * args = (uhyve_ibv_query_pkey_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_query_pkey(args->context, args->port_num, args->index, args->pkey);
|
||||
}
|
||||
|
||||
void call_ibv_alloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_alloc_pd\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_alloc_pd_t * args = (uhyve_ibv_alloc_pd_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_alloc_pd(args->context);
|
||||
}
|
||||
|
||||
void call_ibv_dealloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_dealloc_pd\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_dealloc_pd_t * args = (uhyve_ibv_dealloc_pd_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_dealloc_pd(args->pd);
|
||||
}
|
||||
|
||||
void call_ibv_create_flow(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_create_flow\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_flow_t * args = (uhyve_ibv_create_flow_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_create_flow(args->qp, args->flow);
|
||||
}
|
||||
|
||||
void call_ibv_destroy_flow(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_destroy_flow\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_flow_t * args = (uhyve_ibv_destroy_flow_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_destroy_flow(args->flow_id);
|
||||
}
|
||||
|
||||
void call_ibv_open_xrcd(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_open_xrcd\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_open_xrcd_t * args = (uhyve_ibv_open_xrcd_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_open_xrcd(args->context, args->xrcd_init_attr);
|
||||
}
|
||||
|
||||
void call_ibv_close_xrcd(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_close_xrcd\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_close_xrcd_t * args = (uhyve_ibv_close_xrcd_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_close_xrcd(args->xrcd);
|
||||
}
|
||||
|
||||
void call_ibv_reg_mr(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_reg_mr\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_reg_mr_t * args = (uhyve_ibv_reg_mr_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_reg_mr(args->pd, args->addr, args->length, args->access);
|
||||
}
|
||||
|
||||
void call_ibv_rereg_mr(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_rereg_mr\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_rereg_mr_t * args = (uhyve_ibv_rereg_mr_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_rereg_mr(args->mr, args->flags, args->pd, args->addr, args->length, args->access);
|
||||
}
|
||||
|
||||
void call_ibv_dereg_mr(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_dereg_mr\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_dereg_mr_t * args = (uhyve_ibv_dereg_mr_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_dereg_mr(args->mr);
|
||||
}
|
||||
|
||||
void call_ibv_alloc_mw(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_alloc_mw\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_alloc_mw_t * args = (uhyve_ibv_alloc_mw_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_alloc_mw(args->pd, args->type);
|
||||
}
|
||||
|
||||
void call_ibv_dealloc_mw(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_dealloc_mw\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_dealloc_mw_t * args = (uhyve_ibv_dealloc_mw_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_dealloc_mw(args->mw);
|
||||
}
|
||||
|
||||
void call_ibv_inc_rkey(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_inc_rkey\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_inc_rkey_t * args = (uhyve_ibv_inc_rkey_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_inc_rkey(args->rkey);
|
||||
}
|
||||
|
||||
void call_ibv_bind_mw(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_bind_mw\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_bind_mw_t * args = (uhyve_ibv_bind_mw_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_bind_mw(args->qp, args->mw, args->mw_bind);
|
||||
}
|
||||
|
||||
void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("LOG: UHYVE - call_ibv_create_comp_channel");
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
printf("UHYVE call: call_ibv_create_comp_channel\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_comp_channel_t * args = (uhyve_ibv_create_comp_channel_t *) (guest_mem + data);
|
||||
/*uhyve_ibv_create_comp_channel_t * args = (uhyve_ibv_create_comp_channel_t *) get_data(run);*/
|
||||
|
||||
struct ibv_comp_channel * host_ret = ibv_create_comp_channel(args->context);
|
||||
memcpy(args->ret, host_ret, sizeof(host_ret)); // TODO: This will only work for ABI ver > 2.
|
||||
free(host_ret);
|
||||
args->ret = ibv_create_comp_channel(args->context);
|
||||
}
|
||||
|
||||
void call_ibv_destroy_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_destroy_comp_channel\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_comp_channel_t * args = (uhyve_ibv_destroy_comp_channel_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_destroy_comp_channel(args->channel);
|
||||
}
|
||||
|
||||
void call_ibv_create_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_create_cq\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_cq_t * args = (uhyve_ibv_create_cq_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_create_cq(args->context, args->cqe, args->cq_context, args->channel, args->comp_vector);
|
||||
}
|
||||
|
||||
void call_ibv_resize_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_resize_cq\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_resize_cq_t * args = (uhyve_ibv_resize_cq_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_resize_cq(args->cq, args->cqe);
|
||||
}
|
||||
|
||||
void call_ibv_destroy_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_destroy_cq\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_cq_t * args = (uhyve_ibv_destroy_cq_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_destroy_cq(args->cq);
|
||||
}
|
||||
|
||||
void call_ibv_get_cq_event(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_get_cq_event\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_cq_event_t * args = (uhyve_ibv_get_cq_event_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_get_cq_event(args->channel, args->cq, args->cq_context);
|
||||
}
|
||||
|
||||
void call_ibv_ack_cq_events(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_ack_cq_events\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_ack_cq_events_t * args = (uhyve_ibv_ack_cq_events_t *) (guest_mem + data);
|
||||
}
|
||||
|
||||
void call_ibv_poll_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_poll_cq\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_poll_cq_t * args = (uhyve_ibv_poll_cq_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_poll_cq(args->cq, args->num_entries, args->wc);
|
||||
}
|
||||
|
||||
void call_ibv_req_notify_cq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_req_notify_cq\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_req_notify_cq_t * args = (uhyve_ibv_req_notify_cq_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_req_notify_cq(args->cq, args->solicited_only);
|
||||
}
|
||||
|
||||
void call_ibv_create_srq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_create_srq\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_srq_t * args = (uhyve_ibv_create_srq_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_create_srq(args->pd, args->srq_init_attr);
|
||||
}
|
||||
|
||||
void call_ibv_create_srq_ex(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_create_srq_ex\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_srq_ex_t * args = (uhyve_ibv_create_srq_ex_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_create_srq_ex(args->context, args->srq_init_attr_ex);
|
||||
}
|
||||
|
||||
void call_ibv_modify_srq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_modify_srq\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_modify_srq_t * args = (uhyve_ibv_modify_srq_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_modify_srq(args->srq, args->srq_attr, args->srq_attr_mask);
|
||||
}
|
||||
|
||||
void call_ibv_query_srq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_query_srq\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_srq_t * args = (uhyve_ibv_query_srq_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_query_srq(args->srq, args->srq_attr);
|
||||
}
|
||||
|
||||
void call_ibv_get_srq_num(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_get_srq_num\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_get_srq_num_t * args = (uhyve_ibv_get_srq_num_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_get_srq_num(args->srq, args->srq_num);
|
||||
}
|
||||
|
||||
void call_ibv_destroy_srq(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_destroy_srq\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_srq_t * args = (uhyve_ibv_destroy_srq_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_destroy_srq(args->srq);
|
||||
}
|
||||
|
||||
void call_ibv_post_srq_recv(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_post_srq_recv\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_post_srq_recv_t * args = (uhyve_ibv_post_srq_recv_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_post_srq_recv(args->srq, args->recv_wr, args->bad_recv_wr);
|
||||
}
|
||||
|
||||
void call_ibv_create_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_create_qp\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_qp_t * args = (uhyve_ibv_create_qp_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_create_qp(args->pd, args->qp_init_attr);
|
||||
}
|
||||
|
||||
void call_ibv_create_qp_ex(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_create_qp_ex\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_qp_ex_t * args = (uhyve_ibv_create_qp_ex_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_create_qp_ex(args->context, args->qp_init_attr_ex);
|
||||
}
|
||||
|
||||
void call_ibv_query_device_ex(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_query_device_ex\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_device_ex_t * args = (uhyve_ibv_query_device_ex_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_query_device_ex(args->context, args->input, args->attr);
|
||||
}
|
||||
|
||||
void call_ibv_open_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_open_qp\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_open_qp_t * args = (uhyve_ibv_open_qp_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_open_qp(args->context, args->qp_open_attr);
|
||||
}
|
||||
|
||||
void call_ibv_modify_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_modify_qp\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_modify_qp_t * args = (uhyve_ibv_modify_qp_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_modify_qp(args->qp, args->attr, args->attr_mask);
|
||||
}
|
||||
|
||||
void call_ibv_query_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_query_qp\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_query_qp_t * args = (uhyve_ibv_query_qp_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_query_qp(args->qp, args->attr, args->attr_mask, args->init_attr);
|
||||
}
|
||||
|
||||
void call_ibv_destroy_qp(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_destroy_qp\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_qp_t * args = (uhyve_ibv_destroy_qp_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_destroy_qp(args->qp);
|
||||
}
|
||||
|
||||
void call_ibv_post_send(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_post_send\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_post_send_t * args = (uhyve_ibv_post_send_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_post_send(args->qp, args->wr, args->bad_wr);
|
||||
}
|
||||
|
||||
void call_ibv_post_recv(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_post_recv\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_post_recv_t * args = (uhyve_ibv_post_recv_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_post_recv(args->qp, args->wr, args->bad_wr);
|
||||
}
|
||||
|
||||
void call_ibv_create_ah(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_create_ah\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_ah_t * args = (uhyve_ibv_create_ah_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_create_ah(args->pd, args->attr);
|
||||
}
|
||||
|
||||
void call_ibv_init_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_init_ah_from_wc\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_init_ah_from_wc_t * args = (uhyve_ibv_init_ah_from_wc_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_init_ah_from_wc(args->context, args->port_num, args->wc, args->grh, args->ah_attr);
|
||||
}
|
||||
|
||||
void call_ibv_create_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_create_ah_from_wc\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_create_ah_from_wc_t * args = (uhyve_ibv_create_ah_from_wc_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_create_ah_from_wc(args->pd, args->wc, args->grh, args->port_num);
|
||||
}
|
||||
|
||||
void call_ibv_destroy_ah(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_destroy_ah\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_destroy_ah_t * args = (uhyve_ibv_destroy_ah_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_destroy_ah(args->ah);
|
||||
}
|
||||
|
||||
void call_ibv_attach_mcast(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_attach_mcast\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_attach_mcast_t * args = (uhyve_ibv_attach_mcast_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_attach_mcast(args->qp, args->gid, args->lid);
|
||||
}
|
||||
|
||||
void call_ibv_detach_mcast(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_detach_mcast\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_detach_mcast_t * args = (uhyve_ibv_detach_mcast_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_detach_mcast(args->qp, args->gid, args->lid);
|
||||
}
|
||||
|
||||
void call_ibv_fork_init(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_fork_init\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_fork_init_t * args = (uhyve_ibv_fork_init_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_fork_init();
|
||||
}
|
||||
|
||||
void call_ibv_node_type_str(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_node_type_str\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_node_type_str_t * args = (uhyve_ibv_node_type_str_t *) (guest_mem + data);
|
||||
|
||||
const char * host_ret = ibv_node_type_str(args->node_type); // !
|
||||
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
|
||||
}
|
||||
|
||||
void call_ibv_port_state_str(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_port_state_str\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_port_state_str_t * args = (uhyve_ibv_port_state_str_t *) (guest_mem + data);
|
||||
|
||||
const char * host_ret = ibv_port_state_str(args->port_state); // !
|
||||
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
|
||||
}
|
||||
|
||||
void call_ibv_event_type_str(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_event_type_str\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_event_type_str_t * args = (uhyve_ibv_event_type_str_t *) (guest_mem + data);
|
||||
|
||||
const char * host_ret = ibv_event_type_str(args->event); // !
|
||||
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
|
||||
|
||||
}
|
||||
|
||||
void call_ibv_is_qpt_supported(struct kvm_run * run, uint8_t * guest_mem) {
|
||||
printf("UHYVE call: call_ibv_is_qpt_supported\n");
|
||||
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
|
||||
uhyve_ibv_is_qpt_supported_t * args = (uhyve_ibv_is_qpt_supported_t *) (guest_mem + data);
|
||||
|
||||
args->ret = ibv_is_qpt_supported(args->caps, args->qpt);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,35 +23,150 @@
|
|||
#include <linux/kvm.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MAX_NUM_OF_IBV_DEVICES 16
|
||||
|
||||
extern bool ib_malloc;
|
||||
|
||||
typedef enum {
|
||||
UHYVE_PORT_IBV_OPEN_DEVICE = 0x510,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x511,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x512,
|
||||
UHYVE_PORT_IBV_QUERY_PORT = 0x513,
|
||||
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x514,
|
||||
UHYVE_PORT_KERNEL_IBV_LOG = 0x515,
|
||||
UHYVE_PORT_IBV_WC_STATUS_STR = 0x510,
|
||||
UHYVE_PORT_IBV_RATE_TO_MULT = 0x511,
|
||||
UHYVE_PORT_MULT_TO_IBV_RATE = 0x512,
|
||||
UHYVE_PORT_IBV_RATE_TO_MBPS = 0x513,
|
||||
UHYVE_PORT_MBPS_TO_IBV_RATE = 0x514,
|
||||
UHYVE_PORT_VERBS_GET_CTX = 0x528,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x529,
|
||||
UHYVE_PORT_IBV_FREE_DEVICE_LIST = 0x52A,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x52B,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_GUID = 0x52C,
|
||||
UHYVE_PORT_IBV_OPEN_DEVICE = 0x52D,
|
||||
UHYVE_PORT_IBV_CLOSE_DEVICE = 0x52E,
|
||||
UHYVE_PORT_IBV_GET_ASYNC_EVENT = 0x52F,
|
||||
UHYVE_PORT_IBV_ACK_ASYNC_EVENT = 0x530,
|
||||
UHYVE_PORT_IBV_QUERY_DEVICE = 0x531,
|
||||
UHYVE_PORT_IBV_QUERY_PORT = 0x532,
|
||||
UHYVE_PORT____IBV_QUERY_PORT = 0x533,
|
||||
UHYVE_PORT_IBV_QUERY_GID = 0x534,
|
||||
UHYVE_PORT_IBV_QUERY_PKEY = 0x535,
|
||||
UHYVE_PORT_IBV_ALLOC_PD = 0x536,
|
||||
UHYVE_PORT_IBV_DEALLOC_PD = 0x537,
|
||||
UHYVE_PORT_IBV_CREATE_FLOW = 0x538,
|
||||
UHYVE_PORT_IBV_DESTROY_FLOW = 0x539,
|
||||
UHYVE_PORT_IBV_OPEN_XRCD = 0x53A,
|
||||
UHYVE_PORT_IBV_CLOSE_XRCD = 0x53B,
|
||||
UHYVE_PORT_IBV_REG_MR = 0x53C,
|
||||
UHYVE_PORT_IBV_REREG_MR = 0x53D,
|
||||
UHYVE_PORT_IBV_DEREG_MR = 0x53E,
|
||||
UHYVE_PORT_IBV_ALLOC_MW = 0x53F,
|
||||
UHYVE_PORT_IBV_DEALLOC_MW = 0x540,
|
||||
UHYVE_PORT_IBV_INC_RKEY = 0x541,
|
||||
UHYVE_PORT_IBV_BIND_MW = 0x542,
|
||||
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x543,
|
||||
UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x544,
|
||||
UHYVE_PORT_IBV_CREATE_CQ = 0x545,
|
||||
UHYVE_PORT_IBV_RESIZE_CQ = 0x547,
|
||||
UHYVE_PORT_IBV_DESTROY_CQ = 0x548,
|
||||
UHYVE_PORT_IBV_GET_CQ_EVENT = 0x549,
|
||||
UHYVE_PORT_IBV_ACK_CQ_EVENTS = 0x54A,
|
||||
UHYVE_PORT_IBV_POLL_CQ = 0x54B,
|
||||
UHYVE_PORT_IBV_REQ_NOTIFY_CQ = 0x54C,
|
||||
UHYVE_PORT_IBV_CREATE_SRQ = 0x54D,
|
||||
UHYVE_PORT_IBV_CREATE_SRQ_EX = 0x54E,
|
||||
UHYVE_PORT_IBV_MODIFY_SRQ = 0x54F,
|
||||
UHYVE_PORT_IBV_QUERY_SRQ = 0x550,
|
||||
UHYVE_PORT_IBV_GET_SRQ_NUM = 0x551,
|
||||
UHYVE_PORT_IBV_DESTROY_SRQ = 0x552,
|
||||
UHYVE_PORT_IBV_POST_SRQ_RECV = 0x553,
|
||||
UHYVE_PORT_IBV_CREATE_QP = 0x554,
|
||||
UHYVE_PORT_IBV_CREATE_QP_EX = 0x555,
|
||||
UHYVE_PORT_IBV_QUERY_DEVICE_EX = 0x557,
|
||||
UHYVE_PORT_IBV_OPEN_QP = 0x558,
|
||||
UHYVE_PORT_IBV_MODIFY_QP = 0x559,
|
||||
UHYVE_PORT_IBV_QUERY_QP = 0x55A,
|
||||
UHYVE_PORT_IBV_DESTROY_QP = 0x55B,
|
||||
UHYVE_PORT_IBV_MODIFY_WQ = 0x55D,
|
||||
UHYVE_PORT_IBV_DESTROY_WQ = 0x55E,
|
||||
UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE = 0x55F,
|
||||
UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE = 0x560,
|
||||
UHYVE_PORT_IBV_POST_SEND = 0x561,
|
||||
UHYVE_PORT_IBV_POST_RECV = 0x562,
|
||||
UHYVE_PORT_IBV_CREATE_AH = 0x563,
|
||||
UHYVE_PORT_IBV_INIT_AH_FROM_WC = 0x564,
|
||||
UHYVE_PORT_IBV_CREATE_AH_FROM_WC = 0x565,
|
||||
UHYVE_PORT_IBV_DESTROY_AH = 0x566,
|
||||
UHYVE_PORT_IBV_ATTACH_MCAST = 0x567,
|
||||
UHYVE_PORT_IBV_DETACH_MCAST = 0x568,
|
||||
UHYVE_PORT_IBV_FORK_INIT = 0x569,
|
||||
UHYVE_PORT_IBV_NODE_TYPE_STR = 0x56A,
|
||||
UHYVE_PORT_IBV_PORT_STATE_STR = 0x56B,
|
||||
UHYVE_PORT_IBV_EVENT_TYPE_STR = 0x56C,
|
||||
UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID = 0x56D,
|
||||
UHYVE_PORT_IBV_IS_QPT_SUPPORTED = 0x56E,
|
||||
} uhyve_ibv_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_wc_status status;
|
||||
// Return value:
|
||||
char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_wc_status_str_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_rate rate;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_rate_to_mult_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
int mult;
|
||||
// Return value:
|
||||
enum ibv_rate ret;
|
||||
} __attribute__((packed)) uhyve_mult_to_ibv_rate_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_rate rate;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_rate_to_mbps_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
int mbps;
|
||||
// Return value:
|
||||
enum ibv_rate ret;
|
||||
} __attribute__((packed)) uhyve_mbps_to_ibv_rate_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * ctx;
|
||||
// Return value:
|
||||
struct verbs_context * ret;
|
||||
} __attribute__((packed)) uhyve_verbs_get_ctx_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
int * num_devices;
|
||||
// Return value:
|
||||
// struct ibv_device * ret[MAX_NUM_OF_IBV_DEVICES];
|
||||
struct ibv_device ** ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_list_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device ** list;
|
||||
} __attribute__((packed)) uhyve_ibv_free_device_list_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
const char * ret; // TODO Should this be const?
|
||||
char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
__be64 ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_guid_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
|
@ -59,6 +174,34 @@ typedef struct {
|
|||
struct ibv_context * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_open_device_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_close_device_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_async_event * event;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_async_event_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_async_event * event;
|
||||
} __attribute__((packed)) uhyve_ibv_ack_async_event_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_device_attr * device_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_device_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
|
@ -68,6 +211,139 @@ typedef struct {
|
|||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_port_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
struct ibv_port_attr * port_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve____ibv_query_port_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
int index;
|
||||
union ibv_gid * gid;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_gid_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
int index;
|
||||
__be16 * pkey;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_pkey_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
// Return value:
|
||||
struct ibv_pd * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_alloc_pd_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_dealloc_pd_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_flow_attr * flow;
|
||||
// Return value:
|
||||
struct ibv_flow * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_flow_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_flow * flow_id;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_flow_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_xrcd_init_attr * xrcd_init_attr;
|
||||
// Return value:
|
||||
struct ibv_xrcd * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_open_xrcd_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_xrcd * xrcd;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_close_xrcd_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
void * addr;
|
||||
int length;
|
||||
int access;
|
||||
// Return value:
|
||||
struct ibv_mr * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_reg_mr_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_mr * mr;
|
||||
int flags;
|
||||
struct ibv_pd * pd;
|
||||
void * addr;
|
||||
int length;
|
||||
int access;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_rereg_mr_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_mr * mr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_dereg_mr_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
enum ibv_mw_type type;
|
||||
// Return value:
|
||||
struct ibv_mw * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_alloc_mw_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_mw * mw;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_dealloc_mw_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
uint32_t rkey;
|
||||
// Return value:
|
||||
uint32_t ret;
|
||||
} __attribute__((packed)) uhyve_ibv_inc_rkey_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_mw * mw;
|
||||
struct ibv_mw_bind * mw_bind;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_bind_mw_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
|
@ -75,10 +351,369 @@ typedef struct {
|
|||
struct ibv_comp_channel * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;
|
||||
|
||||
void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem);
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_comp_channel * channel;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_comp_channel_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
int cqe;
|
||||
void * cq_context;
|
||||
struct ibv_comp_channel * channel;
|
||||
int comp_vector;
|
||||
// Return value:
|
||||
struct ibv_cq * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
int cqe;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_resize_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_comp_channel * channel;
|
||||
struct ibv_cq ** cq;
|
||||
void ** cq_context;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_cq_event_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
unsigned int nevents;
|
||||
} __attribute__((packed)) uhyve_ibv_ack_cq_events_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
int num_entries;
|
||||
struct ibv_wc * wc;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_poll_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_cq * cq;
|
||||
int solicited_only;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_req_notify_cq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
struct ibv_srq_init_attr * srq_init_attr;
|
||||
// Return value:
|
||||
struct ibv_srq * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_srq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_srq_init_attr_ex * srq_init_attr_ex;
|
||||
// Return value:
|
||||
struct ibv_srq * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_srq_ex_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
struct ibv_srq_attr * srq_attr;
|
||||
int srq_attr_mask;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_modify_srq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
struct ibv_srq_attr * srq_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_srq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
uint32_t * srq_num;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_srq_num_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_srq_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_srq * srq;
|
||||
struct ibv_recv_wr * recv_wr;
|
||||
struct ibv_recv_wr ** bad_recv_wr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_post_srq_recv_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
struct ibv_qp_init_attr * qp_init_attr;
|
||||
// Return value:
|
||||
struct ibv_qp * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_qp_init_attr_ex * qp_init_attr_ex;
|
||||
// Return value:
|
||||
struct ibv_qp * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_qp_ex_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
const struct ibv_query_device_ex_input * input;
|
||||
struct ibv_device_attr_ex * attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_device_ex_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_qp_open_attr * qp_open_attr;
|
||||
// Return value:
|
||||
struct ibv_qp * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_open_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_qp_attr * attr;
|
||||
int attr_mask;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_modify_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_qp_attr * attr;
|
||||
int attr_mask;
|
||||
struct ibv_qp_init_attr * init_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_qp_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_send_wr * wr;
|
||||
struct ibv_send_wr ** bad_wr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_post_send_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
struct ibv_recv_wr * wr;
|
||||
struct ibv_recv_wr ** bad_wr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_post_recv_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
struct ibv_ah_attr * attr;
|
||||
// Return value:
|
||||
struct ibv_ah * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_ah_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
struct ibv_wc * wc;
|
||||
struct ibv_grh * grh;
|
||||
struct ibv_ah_attr * ah_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_init_ah_from_wc_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_pd * pd;
|
||||
struct ibv_wc * wc;
|
||||
struct ibv_grh * grh;
|
||||
uint8_t port_num;
|
||||
// Return value:
|
||||
struct ibv_ah * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_ah_from_wc_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_ah * ah;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_destroy_ah_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
const union ibv_gid * gid;
|
||||
uint16_t lid;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_attach_mcast_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_qp * qp;
|
||||
const union ibv_gid * gid;
|
||||
uint16_t lid;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_detach_mcast_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_fork_init_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_node_type node_type;
|
||||
// Return value:
|
||||
char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_node_type_str_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_port_state port_state;
|
||||
// Return value:
|
||||
char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_port_state_str_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
enum ibv_event_type event;
|
||||
// Return value:
|
||||
char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_event_type_str_t;
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
uint32_t caps;
|
||||
enum ibv_qp_type qpt;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_is_qpt_supported_t;
|
||||
|
||||
|
||||
void call_ibv_wc_status_str (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_rate_to_mult (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_mult_to_ibv_rate (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_rate_to_mbps (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_mbps_to_ibv_rate (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_cq_ex_to_cq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_verbs_get_ctx (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_device_list (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_free_device_list (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_device_name (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_device_guid (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_open_device (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_close_device (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_async_event (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_ack_async_event (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_device (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_port (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call____ibv_query_port (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_gid (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_pkey (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_alloc_pd (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_dealloc_pd (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_flow (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_flow (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_open_xrcd (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_close_xrcd (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_reg_mr (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_rereg_mr (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_dereg_mr (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_alloc_mw (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_dealloc_mw (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_inc_rkey (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_bind_mw (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_comp_channel (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_comp_channel (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_cq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_resize_cq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_cq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_cq_event (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_ack_cq_events (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_poll_cq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_req_notify_cq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_srq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_srq_ex (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_modify_srq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_srq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_get_srq_num (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_srq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_post_srq_recv (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_qp (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_qp_ex (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_device_ex (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_open_qp (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_modify_qp (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_query_qp (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_qp (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_modify_wq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_wq (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_rwq_ind_table (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_rwq_ind_table (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_post_send (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_post_recv (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_ah (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_init_ah_from_wc (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_create_ah_from_wc (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_destroy_ah (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_attach_mcast (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_detach_mcast (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_fork_init (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_node_type_str (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_port_state_str (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_event_type_str (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_resolve_eth_l2_from_gid (struct kvm_run * run, uint8_t * guest_mem);
|
||||
void call_ibv_is_qpt_supported (struct kvm_run * run, uint8_t * guest_mem);
|
||||
|
||||
#endif // UHYVE_IBV_H
|
||||
|
|
407
tools/uhyve.c
407
tools/uhyve.c
|
@ -168,8 +168,6 @@
|
|||
#define IOAPIC_DEFAULT_BASE 0xfec00000
|
||||
#define APIC_DEFAULT_BASE 0xfee00000
|
||||
|
||||
#define IB_MEM_DEBUG 1
|
||||
|
||||
static bool restart = false;
|
||||
static bool cap_tsc_deadline = false;
|
||||
static bool cap_irqchip = false;
|
||||
|
@ -195,199 +193,6 @@ static __thread struct kvm_run *run = NULL;
|
|||
static __thread int vcpufd = -1;
|
||||
static __thread uint32_t cpuid = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static uint8_t * ib_mem = NULL;
|
||||
bool ib_malloc = false;
|
||||
static const size_t std_alignment = 16; // TODO: Use sizeof(maxint_t) (?) or similar
|
||||
static pthread_mutex_t ib_hooks_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
// Definition of malloc hooks for IBV library
|
||||
static void init_ib_hooks(void);
|
||||
|
||||
static void * ib_malloc_hook(size_t, const void *);
|
||||
static void * ib_realloc_hook(void *, size_t, const void *);
|
||||
static void * ib_memalign_hook(size_t, size_t, const void *);
|
||||
static void ib_free_hook(void *, const void *);
|
||||
|
||||
static void * (* default_malloc_hook) (size_t, const void *);
|
||||
static void * (* default_realloc_hook) (void *, size_t, const void *);
|
||||
static void * (* default_memalign_hook)(size_t, size_t, const void *);
|
||||
static void (* default_free_hook) (void *, const void *);
|
||||
|
||||
/* void (* __malloc_initialize_hook) (void) = init_ib_hooks; */
|
||||
/* __malloc_initialize_hook = init_ib_hooks; */
|
||||
|
||||
static void init_ib_hooks(void) {
|
||||
default_malloc_hook = __malloc_hook;
|
||||
default_realloc_hook = __realloc_hook;
|
||||
default_memalign_hook = __memalign_hook;
|
||||
default_free_hook = __free_hook;
|
||||
|
||||
__malloc_hook = ib_malloc_hook;
|
||||
__realloc_hook = ib_realloc_hook;
|
||||
__memalign_hook = ib_memalign_hook;
|
||||
__free_hook = ib_free_hook;
|
||||
}
|
||||
|
||||
void init_default_hooks() {
|
||||
__malloc_hook = default_malloc_hook;
|
||||
__realloc_hook = default_realloc_hook;
|
||||
__memalign_hook = default_memalign_hook;
|
||||
__free_hook = default_free_hook;
|
||||
}
|
||||
|
||||
void * new_ib_malloc_region(size_t size) {
|
||||
void * result = NULL;
|
||||
|
||||
if (size > 0) {
|
||||
ib_mem -= size;
|
||||
ib_mem -= (size_t) ((uintptr_t) ib_mem % std_alignment);
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("ib_mem aligned: %p\n", ib_mem);
|
||||
#endif
|
||||
result = ib_mem;
|
||||
|
||||
ib_mem -= std_alignment;
|
||||
size_t * block_size = (size_t *) ib_mem;
|
||||
*block_size = size;
|
||||
}
|
||||
|
||||
if ((uint8_t *) result < guest_mem + guest_size - (size_t) (1UL << 20)) { // TODO: remove this
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("WARNING, IB MEM OUT OF BOUNDS\n\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Malloc Hook
|
||||
static void * ib_malloc_hook(size_t size, const void * caller) {
|
||||
#ifdef IB_MEM_DEBUG
|
||||
/* printf("Before Mutex Lock."); */
|
||||
#endif
|
||||
pthread_mutex_lock(&ib_hooks_mutex);
|
||||
init_default_hooks();
|
||||
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf(" ib_malloc_hook\tib_malloc %s\t Args:\tsize = %lu\t", ib_malloc ? "true " : "false", size);
|
||||
#endif
|
||||
|
||||
void * result;
|
||||
if (ib_malloc) {
|
||||
result = new_ib_malloc_region(size);
|
||||
} else { // !ib_malloc
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("\n");
|
||||
#endif
|
||||
result = malloc(size);
|
||||
}
|
||||
|
||||
init_ib_hooks();
|
||||
pthread_mutex_unlock(&ib_hooks_mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Realloc Hook
|
||||
static void * ib_realloc_hook(void * ptr, size_t new_size, const void * caller) {
|
||||
pthread_mutex_lock(&ib_hooks_mutex);
|
||||
init_default_hooks();
|
||||
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("ib_realloc_hook\tib_malloc %s\t Args:\tptr = %p, size = %lu\t", ib_malloc ? "true " : "false", ptr, new_size);
|
||||
#endif
|
||||
void * result;
|
||||
|
||||
if (ib_malloc) {
|
||||
size_t * mem_block_size_ptr = (size_t *) (ptr - std_alignment);
|
||||
size_t orig_size = *mem_block_size_ptr;
|
||||
|
||||
if (new_size <= 0 || ptr == NULL) {
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("new_size <= 0 || ptr == NULL\n");
|
||||
#endif
|
||||
result = NULL;
|
||||
} else if (new_size <= orig_size) {
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("new_size <= orig_size = %lu\n", orig_size);
|
||||
#endif
|
||||
*mem_block_size_ptr = new_size;
|
||||
result = ptr;
|
||||
} else { // new_size > orig_size
|
||||
result = new_ib_malloc_region(new_size);
|
||||
memcpy(result, ptr, orig_size);
|
||||
}
|
||||
|
||||
} else { // !ib_malloc
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("\n");
|
||||
#endif
|
||||
result = realloc(ptr, new_size);
|
||||
}
|
||||
|
||||
init_ib_hooks();
|
||||
pthread_mutex_unlock(&ib_hooks_mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Memalign Hook - just a dummy for now
|
||||
static void * ib_memalign_hook(size_t alignment, size_t size, const void * caller) {
|
||||
pthread_mutex_lock(&ib_hooks_mutex);
|
||||
init_default_hooks();
|
||||
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("\tCALLED! ib_memalign_hook\tib_malloc %s\t Args:\talignment = %lu\tsize = %lu\t",
|
||||
ib_malloc ? "true " : "false", alignment, size);
|
||||
#endif
|
||||
|
||||
void * result;
|
||||
if (ib_malloc) {
|
||||
/* result = new_ib_malloc_region(size); */
|
||||
} else { // !ib_malloc
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("\n");
|
||||
#endif
|
||||
result = memalign(alignment, size);
|
||||
}
|
||||
|
||||
init_ib_hooks();
|
||||
pthread_mutex_unlock(&ib_hooks_mutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Free Hook
|
||||
static void ib_free_hook(void * ptr, const void * caller) {
|
||||
pthread_mutex_lock(&ib_hooks_mutex);
|
||||
init_default_hooks();
|
||||
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf(" ib_free_hook\tib_malloc %s\t Args:\tptr = %p", ib_malloc ? "true " : "false", ptr);
|
||||
#endif
|
||||
|
||||
if (!ib_malloc) {
|
||||
free(ptr);
|
||||
} else if (ptr != NULL && (ptr <= ib_mem || ptr > guest_mem + guest_size)) {
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("\t!!! ptr out of ib bounds !!!");
|
||||
#endif
|
||||
}
|
||||
#ifdef IB_MEM_DEBUG
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
init_ib_hooks();
|
||||
pthread_mutex_unlock(&ib_hooks_mutex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static uint64_t memparse(const char *ptr)
|
||||
{
|
||||
// local pointer to end of parsed string
|
||||
|
@ -1165,34 +970,218 @@ static int vcpu_loop(void)
|
|||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_KERNEL_IBV_LOG: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
char* str = (char*) (guest_mem + data);
|
||||
printf("KERNEL IBV LOG: %s\n", str);
|
||||
break;
|
||||
}
|
||||
/* case UHYVE_PORT_KERNEL_IBV_LOG: { */
|
||||
/* unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); */
|
||||
/* char* str = (char*) (guest_mem + data); */
|
||||
/* printf("KERNEL IBV LOG: %s\n", str); */
|
||||
/* break; */
|
||||
/* } */
|
||||
|
||||
// InfiniBand
|
||||
case UHYVE_PORT_IBV_WC_STATUS_STR:
|
||||
call_ibv_wc_status_str(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_RATE_TO_MULT:
|
||||
call_ibv_rate_to_mult(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_MULT_TO_IBV_RATE:
|
||||
call_mult_to_ibv_rate(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_RATE_TO_MBPS:
|
||||
call_ibv_rate_to_mbps(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_MBPS_TO_IBV_RATE:
|
||||
call_mbps_to_ibv_rate(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_VERBS_GET_CTX:
|
||||
call_verbs_get_ctx(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_LIST:
|
||||
printf("LOG: UHYVE CASE\n");
|
||||
call_ibv_get_device_list(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_FREE_DEVICE_LIST:
|
||||
call_ibv_free_device_list(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_NAME:
|
||||
printf("LOG: UHYVE CASE UHYVE_PORT_IBV_GET_DEVICE_NAME\n");
|
||||
call_ibv_get_device_name(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_GUID:
|
||||
call_ibv_get_device_guid(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_OPEN_DEVICE:
|
||||
printf("LOG: UHYVE CASE UHYVE_PORT_IBV_OPEN_DEVICE\n");
|
||||
call_ibv_open_device(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CLOSE_DEVICE:
|
||||
call_ibv_close_device(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_ASYNC_EVENT:
|
||||
call_ibv_get_async_event(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ACK_ASYNC_EVENT:
|
||||
call_ibv_ack_async_event(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_DEVICE:
|
||||
call_ibv_query_device(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_PORT:
|
||||
printf("LOG: UHYVE CASE UHYVE_PORT_IBV_QUERY_PORT\n");
|
||||
call_ibv_query_port(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT____IBV_QUERY_PORT:
|
||||
call____ibv_query_port(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_GID:
|
||||
call_ibv_query_gid(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_PKEY:
|
||||
call_ibv_query_pkey(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ALLOC_PD:
|
||||
call_ibv_alloc_pd(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DEALLOC_PD:
|
||||
call_ibv_dealloc_pd(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_FLOW:
|
||||
call_ibv_create_flow(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_FLOW:
|
||||
call_ibv_destroy_flow(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_OPEN_XRCD:
|
||||
call_ibv_open_xrcd(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CLOSE_XRCD:
|
||||
call_ibv_close_xrcd(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_REG_MR:
|
||||
call_ibv_reg_mr(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_REREG_MR:
|
||||
call_ibv_rereg_mr(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DEREG_MR:
|
||||
call_ibv_dereg_mr(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ALLOC_MW:
|
||||
call_ibv_alloc_mw(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DEALLOC_MW:
|
||||
call_ibv_dealloc_mw(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_INC_RKEY:
|
||||
call_ibv_inc_rkey(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_BIND_MW:
|
||||
call_ibv_bind_mw(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_COMP_CHANNEL:
|
||||
printf("LOG: UHYVE CASE UHYVE_PORT_IBV_CREATE_COMP_CHANNEL\n");
|
||||
call_ibv_create_comp_channel(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL:
|
||||
call_ibv_destroy_comp_channel(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_CQ:
|
||||
call_ibv_create_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_RESIZE_CQ:
|
||||
call_ibv_resize_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_CQ:
|
||||
call_ibv_destroy_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_CQ_EVENT:
|
||||
call_ibv_get_cq_event(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ACK_CQ_EVENTS:
|
||||
call_ibv_ack_cq_events(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_POLL_CQ:
|
||||
call_ibv_poll_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_REQ_NOTIFY_CQ:
|
||||
call_ibv_req_notify_cq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_SRQ:
|
||||
call_ibv_create_srq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_SRQ_EX:
|
||||
call_ibv_create_srq_ex(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_MODIFY_SRQ:
|
||||
call_ibv_modify_srq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_SRQ:
|
||||
call_ibv_query_srq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_SRQ_NUM:
|
||||
call_ibv_get_srq_num(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_SRQ:
|
||||
call_ibv_destroy_srq(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_POST_SRQ_RECV:
|
||||
call_ibv_post_srq_recv(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_QP:
|
||||
call_ibv_create_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_QP_EX:
|
||||
call_ibv_create_qp_ex(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_DEVICE_EX:
|
||||
call_ibv_query_device_ex(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_OPEN_QP:
|
||||
call_ibv_open_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_MODIFY_QP:
|
||||
call_ibv_modify_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_QUERY_QP:
|
||||
call_ibv_query_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_QP:
|
||||
call_ibv_destroy_qp(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_POST_SEND:
|
||||
call_ibv_post_send(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_POST_RECV:
|
||||
call_ibv_post_recv(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_AH:
|
||||
call_ibv_create_ah(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_INIT_AH_FROM_WC:
|
||||
call_ibv_init_ah_from_wc(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_CREATE_AH_FROM_WC:
|
||||
call_ibv_create_ah_from_wc(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DESTROY_AH:
|
||||
call_ibv_destroy_ah(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_ATTACH_MCAST:
|
||||
call_ibv_attach_mcast(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_DETACH_MCAST:
|
||||
call_ibv_detach_mcast(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_FORK_INIT:
|
||||
call_ibv_fork_init(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_NODE_TYPE_STR:
|
||||
call_ibv_node_type_str(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_PORT_STATE_STR:
|
||||
call_ibv_port_state_str(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_EVENT_TYPE_STR:
|
||||
call_ibv_event_type_str(run, guest_mem);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_IS_QPT_SUPPORTED:
|
||||
call_ibv_is_qpt_supported(run, guest_mem);
|
||||
break;
|
||||
|
||||
default:
|
||||
err(1, "KVM: unhandled KVM_EXIT_IO at port 0x%x, direction %d\n", run->io.port, run->io.direction);
|
||||
|
@ -1624,12 +1613,6 @@ int uhyve_init(char *path)
|
|||
err(1, "unable to initialized network");
|
||||
}
|
||||
|
||||
printf("UHYVE: Initialize malloc hooks (init_ib_hooks())\n");
|
||||
ib_mem = guest_mem + guest_size;
|
||||
printf("guest_mem: %p, guest_size: %p\n", guest_mem, guest_size);
|
||||
printf("ib_mem = guest_mem + guest_size: %p\n", ib_mem);
|
||||
init_ib_hooks();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,21 +54,26 @@ int main(int argc, char** argv)
|
|||
|
||||
printf("ib-test.c: before get dev list.\n");
|
||||
dev_list = ibv_get_device_list(&num_devices);
|
||||
printf("after get device list -- ib-test.c: num devices: %d\n", num_devices);
|
||||
printf("after get device list -- ib-test.c: ptr 1: %p\n", dev_list[0]);
|
||||
printf("after get device list -- ib-test.c: ptr 2: %p\n", dev_list[1]);
|
||||
printf("after get device list -- ib-test.c: name 1: %s\n", dev_list[0]->name);
|
||||
printf("after get device list -- ib-test.c: name 2: %s\n", dev_list[1]->name);
|
||||
printf("ib-test.c: after get device list - num devices: %d\n", num_devices);
|
||||
/* printf("after get device list -- ib-test.c: ptr 1: %p\n", dev_list[0]); */
|
||||
/* printf("after get device list -- ib-test.c: ptr 2: %p\n", dev_list[1]); */
|
||||
/* printf("after get device list -- ib-test.c: name 1: %s\n", dev_list[0]->name); */
|
||||
/* printf("after get device list -- ib-test.c: name 2: %s\n", dev_list[1]->name); */
|
||||
|
||||
printf("before get device name loop.\n");
|
||||
for (int i=0; i < num_devices; i++) {
|
||||
const char* dev_name = ibv_get_device_name(dev_list[i]);
|
||||
printf("after get device name -- Device name %d: %s\n", i, dev_name);
|
||||
}
|
||||
/* printf("before get device name loop.\n"); */
|
||||
/* for (int i=0; i < num_devices; i++) { */
|
||||
/* const char* dev_name = ibv_get_device_name(dev_list[i]); */
|
||||
/* printf("after get device name -- Device name %d: %s\n", i, dev_name); */
|
||||
/* } */
|
||||
|
||||
printf("before open_device\n");
|
||||
printf("ib-test.c: before open_device\n");
|
||||
struct ibv_context * context = ibv_open_device(dev_list[0]);
|
||||
printf("after open device\n");
|
||||
printf("ib-test.c: after open device\n");
|
||||
|
||||
struct ibv_port_attr port_info = {};
|
||||
uint8_t port = 1;
|
||||
int success = ibv_query_port(context, port, &port_info);
|
||||
printf("ib-test.c: after ibv_query_port\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -33,10 +33,23 @@
|
|||
#include "pingpong.h"
|
||||
|
||||
/*#include <endian.h> // TODO*/
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
uint32_t htonl(uint32_t x) {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
return x;
|
||||
#else
|
||||
return __bswap_32 (x);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t ntohl(uint32_t x) {
|
||||
return htonl(x);
|
||||
}
|
||||
|
||||
enum ibv_mtu pp_mtu_to_enum(int mtu)
|
||||
{
|
||||
switch (mtu) {
|
||||
|
@ -55,27 +68,27 @@ int pp_get_port_info(struct ibv_context *context, int port,
|
|||
return ibv_query_port(context, port, attr);
|
||||
}
|
||||
|
||||
/* void wire_gid_to_gid(const char *wgid, union ibv_gid *gid) */
|
||||
/* { */
|
||||
/* char tmp[9]; */
|
||||
/* __be32 v32; */
|
||||
/* int i; */
|
||||
/* uint32_t tmp_gid[4]; */
|
||||
void wire_gid_to_gid(const char *wgid, union ibv_gid *gid)
|
||||
{
|
||||
char tmp[9];
|
||||
__be32 v32;
|
||||
int i;
|
||||
uint32_t tmp_gid[4];
|
||||
|
||||
/* for (tmp[8] = 0, i = 0; i < 4; ++i) { */
|
||||
/* memcpy(tmp, wgid + i * 8, 8); */
|
||||
/* sscanf(tmp, "%x", &v32); */
|
||||
/* tmp_gid[i] = be32toh(v32); */
|
||||
/* } */
|
||||
/* memcpy(gid, tmp_gid, sizeof(*gid)); */
|
||||
/* } */
|
||||
for (tmp[8] = 0, i = 0; i < 4; ++i) {
|
||||
memcpy(tmp, wgid + i * 8, 8);
|
||||
sscanf(tmp, "%x", &v32);
|
||||
tmp_gid[i] = ntohl(v32);
|
||||
}
|
||||
memcpy(gid, tmp_gid, sizeof(*gid));
|
||||
}
|
||||
|
||||
/* void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]) */
|
||||
/* { */
|
||||
/* uint32_t tmp_gid[4]; */
|
||||
/* int i; */
|
||||
void gid_to_wire_gid(const union ibv_gid *gid, char wgid[])
|
||||
{
|
||||
uint32_t tmp_gid[4];
|
||||
int i;
|
||||
|
||||
/* memcpy(tmp_gid, gid, sizeof(tmp_gid)); */
|
||||
/* for (i = 0; i < 4; ++i) */
|
||||
/* sprintf(&wgid[i * 8], "%08x", htobe32(tmp_gid[i])); */
|
||||
/* } */
|
||||
memcpy(tmp_gid, gid, sizeof(tmp_gid));
|
||||
for (i = 0; i < 4; ++i)
|
||||
sprintf(&wgid[i * 8], "%08x", htonl(tmp_gid[i]));
|
||||
}
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
|
||||
enum ibv_mtu pp_mtu_to_enum(int mtu);
|
||||
int pp_get_port_info(struct ibv_context *context, int port, struct ibv_port_attr *attr);
|
||||
// void wire_gid_to_gid(const char *wgid, union ibv_gid *gid);
|
||||
// void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]);
|
||||
void wire_gid_to_gid(const char *wgid, union ibv_gid *gid);
|
||||
void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]);
|
||||
|
|
Loading…
Add table
Reference in a new issue