diff --git a/include/hermit/ibv.h b/include/hermit/ibv.h index ad4a3692b..179bd8d39 100644 --- a/include/hermit/ibv.h +++ b/include/hermit/ibv.h @@ -40,12 +40,101 @@ 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); +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 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); +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 [6] eth_mac, uint16_t * vid); +int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt); void kernel_ibv_log(); diff --git a/include/hermit/stddef.h b/include/hermit/stddef.h index 55bae8817..6bd1599ac 100644 --- a/include/hermit/stddef.h +++ b/include/hermit/stddef.h @@ -67,15 +67,103 @@ extern const size_t image_size; #define UHYVE_PORT_LSEEK 0x504 // InfiniBand uhyve port IDs -#define UHYVE_PORT_SET_IB_POOL_ADDR 0x609 -#define UHYVE_PORT_IBV_OPEN_DEVICE 0x610 -#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x611 -#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x612 -#define UHYVE_PORT_IBV_QUERY_PORT 0x613 -#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x614 - -#define UHYVE_PORT_KERNEL_IBV_LOG 0x515 - +#define UHYVE_PORT_SET_IB_POOL_ADDR 0x60F +#define UHYVE_PORT_IBV_WC_STATUS_STR 0x610 +#define UHYVE_PORT_IBV_RATE_TO_MULT 0x611 +#define UHYVE_PORT_MULT_TO_IBV_RATE 0x612 +#define UHYVE_PORT_IBV_RATE_TO_MBPS 0x613 +#define UHYVE_PORT_MBPS_TO_IBV_RATE 0x614 +#define UHYVE_PORT_IBV_CQ_EX_TO_CQ 0x615 +#define UHYVE_PORT_IBV_START_POLL 0x616 +#define UHYVE_PORT_IBV_NEXT_POLL 0x617 +#define UHYVE_PORT_IBV_END_POLL 0x618 +#define UHYVE_PORT_IBV_WC_READ_OPCODE 0x619 +#define UHYVE_PORT_IBV_WC_READ_VENDOR_ERR 0x61A +#define UHYVE_PORT_IBV_WC_READ_BYTE_LEN 0x61B +#define UHYVE_PORT_IBV_WC_READ_IMM_DATA 0x61C +#define UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY 0x61D +#define UHYVE_PORT_IBV_WC_READ_QP_NUM 0x61E +#define UHYVE_PORT_IBV_WC_READ_SRC_QP 0x61F +#define UHYVE_PORT_IBV_WC_READ_WC_FLAGS 0x620 +#define UHYVE_PORT_IBV_WC_READ_SLID 0x621 +#define UHYVE_PORT_IBV_WC_READ_SL 0x622 +#define UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS 0x623 +#define UHYVE_PORT_IBV_WC_READ_COMPLETION_TS 0x624 +#define UHYVE_PORT_IBV_WC_READ_CVLAN 0x625 +#define UHYVE_PORT_IBV_WC_READ_FLOW_TAG 0x626 +#define UHYVE_PORT_IBV_POST_WQ_RECV 0x627 +#define UHYVE_PORT_VERBS_GET_CTX 0x628 +#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x629 +#define UHYVE_PORT_IBV_FREE_DEVICE_LIST 0x62A +#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x62B +#define UHYVE_PORT_IBV_GET_DEVICE_GUID 0x62C +#define UHYVE_PORT_IBV_OPEN_DEVICE 0x62D +#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x62E +#define UHYVE_PORT_IBV_GET_ASYNC_EVENT 0x62F +#define UHYVE_PORT_IBV_ACK_ASYNC_EVENT 0x630 +#define UHYVE_PORT_IBV_QUERY_DEVICE 0x631 +#define UHYVE_PORT_IBV_QUERY_PORT 0x632 +#define UHYVE_PORT____IBV_QUERY_PORT 0x633 +#define UHYVE_PORT_IBV_QUERY_GID 0x634 +#define UHYVE_PORT_IBV_QUERY_PKEY 0x635 +#define UHYVE_PORT_IBV_ALLOC_PD 0x636 +#define UHYVE_PORT_IBV_DEALLOC_PD 0x637 +#define UHYVE_PORT_IBV_CREATE_FLOW 0x638 +#define UHYVE_PORT_IBV_DESTROY_FLOW 0x639 +#define UHYVE_PORT_IBV_OPEN_XRCD 0x63A +#define UHYVE_PORT_IBV_CLOSE_XRCD 0x63B +#define UHYVE_PORT_IBV_REG_MR 0x63C +#define UHYVE_PORT_IBV_REREG_MR 0x63D +#define UHYVE_PORT_IBV_DEREG_MR 0x63E +#define UHYVE_PORT_IBV_ALLOC_MW 0x63F +#define UHYVE_PORT_IBV_DEALLOC_MW 0x640 +#define UHYVE_PORT_IBV_INC_RKEY 0x641 +#define UHYVE_PORT_IBV_BIND_MW 0x642 +#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x643 +#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x644 +#define UHYVE_PORT_IBV_CREATE_CQ 0x645 +#define UHYVE_PORT_IBV_CREATE_CQ_EX 0x646 +#define UHYVE_PORT_IBV_RESIZE_CQ 0x647 +#define UHYVE_PORT_IBV_DESTROY_CQ 0x648 +#define UHYVE_PORT_IBV_GET_CQ_EVENT 0x649 +#define UHYVE_PORT_IBV_ACK_CQ_EVENTS 0x64A +#define UHYVE_PORT_IBV_POLL_CQ 0x64B +#define UHYVE_PORT_IBV_REQ_NOTIFY_CQ 0x64C +#define UHYVE_PORT_IBV_CREATE_SRQ 0x64D +#define UHYVE_PORT_IBV_CREATE_SRQ_EX 0x64E +#define UHYVE_PORT_IBV_MODIFY_SRQ 0x64F +#define UHYVE_PORT_IBV_QUERY_SRQ 0x650 +#define UHYVE_PORT_IBV_GET_SRQ_NUM 0x651 +#define UHYVE_PORT_IBV_DESTROY_SRQ 0x652 +#define UHYVE_PORT_IBV_POST_SRQ_RECV 0x653 +#define UHYVE_PORT_IBV_CREATE_QP 0x654 +#define UHYVE_PORT_IBV_CREATE_QP_EX 0x655 +#define UHYVE_PORT_IBV_QUERY_RT_VALUES_EX 0x656 +#define UHYVE_PORT_IBV_QUERY_DEVICE_EX 0x657 +#define UHYVE_PORT_IBV_OPEN_QP 0x658 +#define UHYVE_PORT_IBV_MODIFY_QP 0x659 +#define UHYVE_PORT_IBV_QUERY_QP 0x65A +#define UHYVE_PORT_IBV_DESTROY_QP 0x65B +#define UHYVE_PORT_IBV_CREATE_WQ 0x65C +#define UHYVE_PORT_IBV_MODIFY_WQ 0x65D +#define UHYVE_PORT_IBV_DESTROY_WQ 0x65E +#define UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE 0x65F +#define UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE 0x660 +#define UHYVE_PORT_IBV_POST_SEND 0x661 +#define UHYVE_PORT_IBV_POST_RECV 0x662 +#define UHYVE_PORT_IBV_CREATE_AH 0x663 +#define UHYVE_PORT_IBV_INIT_AH_FROM_WC 0x664 +#define UHYVE_PORT_IBV_CREATE_AH_FROM_WC 0x665 +#define UHYVE_PORT_IBV_DESTROY_AH 0x666 +#define UHYVE_PORT_IBV_ATTACH_MCAST 0x667 +#define UHYVE_PORT_IBV_DETACH_MCAST 0x668 +#define UHYVE_PORT_IBV_FORK_INIT 0x669 +#define UHYVE_PORT_IBV_NODE_TYPE_STR 0x66A +#define UHYVE_PORT_IBV_PORT_STATE_STR 0x66B +#define UHYVE_PORT_IBV_EVENT_TYPE_STR 0x66C +#define UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID 0x66D +#define UHYVE_PORT_IBV_IS_QPT_SUPPORTED 0x66E +#define UHYVE_PORT_KERNEL_IBV_LOG 0x66F #define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b)) //#define BUILTIN_EXPECT(exp, b) (exp) diff --git a/kernel/ibv.c b/kernel/ibv.c index 15f355b9b..4b19b5b9f 100644 --- a/kernel/ibv.c +++ b/kernel/ibv.c @@ -37,7 +37,6 @@ #include #include -/* #include */ extern uint8_t * host_logical_addr; @@ -45,11 +44,532 @@ inline size_t guest_to_host(size_t address) { return address ? virt_to_phys(address) + (size_t) host_logical_addr : address; } -// TODO: Can/should we separate ibv_get_device_list into two KVM exit IOs to -// allocate the right amount of memory? -#define MAX_NUM_OF_IBV_DEVICES 16 -static void * ret_guest; +/* + * ibv_wc_status_str + */ + +typedef struct { + // Parameters: + enum ibv_wc_status status; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_wc_status_str_t; + +const char * ibv_wc_status_str(enum ibv_wc_status status) { + uhyve_ibv_wc_status_str_t uhyve_args; + uhyve_args.status = status; + + uhyve_send(UHYVE_PORT_IBV_WC_STATUS_STR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_rate_to_mult + */ + +typedef struct { + // Parameters: + enum ibv_rate rate; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_rate_to_mult_t; + +int ibv_rate_to_mult(enum ibv_rate rate) { + uhyve_ibv_rate_to_mult_t uhyve_args; + uhyve_args.rate = rate; + + uhyve_send(UHYVE_PORT_IBV_RATE_TO_MULT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * mult_to_ibv_rate + */ + +typedef struct { + // Parameters: + int mult; + // Return value: + enum ibv_rate ret; +} __attribute__((packed)) uhyve_mult_to_ibv_rate_t; + +enum ibv_rate mult_to_ibv_rate(int mult) { + uhyve_mult_to_ibv_rate_t uhyve_args; + uhyve_args.mult = mult; + + uhyve_send(UHYVE_PORT_MULT_TO_IBV_RATE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_rate_to_mbps + */ + +typedef struct { + // Parameters: + enum ibv_rate rate; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_rate_to_mbps_t; + +int ibv_rate_to_mbps(enum ibv_rate rate) { + uhyve_ibv_rate_to_mbps_t uhyve_args; + uhyve_args.rate = rate; + + uhyve_send(UHYVE_PORT_IBV_RATE_TO_MBPS, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * mbps_to_ibv_rate + */ + +typedef struct { + // Parameters: + int mbps; + // Return value: + enum ibv_rate ret; +} __attribute__((packed)) uhyve_mbps_to_ibv_rate_t; + +enum ibv_rate mbps_to_ibv_rate(int mbps) { + uhyve_mbps_to_ibv_rate_t uhyve_args; + uhyve_args.mbps = mbps; + + uhyve_send(UHYVE_PORT_MBPS_TO_IBV_RATE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_cq_ex_to_cq + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + struct ibv_cq * ret; +} __attribute__((packed)) uhyve_ibv_cq_ex_to_cq_t; + +struct ibv_cq * ibv_cq_ex_to_cq(struct ibv_cq_ex * cq) { + uhyve_ibv_cq_ex_to_cq_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_CQ_EX_TO_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_start_poll + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + struct ibv_poll_cq_attr * attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_start_poll_t; + +int ibv_start_poll(struct ibv_cq_ex * cq, struct ibv_poll_cq_attr * attr) { + uhyve_ibv_start_poll_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.attr = attr; + + uhyve_send(UHYVE_PORT_IBV_START_POLL, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_next_poll + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_next_poll_t; + +int ibv_next_poll(struct ibv_cq_ex * cq) { + uhyve_ibv_next_poll_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_NEXT_POLL, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_end_poll + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; +} __attribute__((packed)) uhyve_ibv_end_poll_t; + +void ibv_end_poll(struct ibv_cq_ex * cq) { + uhyve_ibv_end_poll_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_END_POLL, (unsigned) virt_to_phys((size_t) &uhyve_args)); +} + + +/* + * ibv_wc_read_opcode + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + enum ibv_wc_opcode ret; +} __attribute__((packed)) uhyve_ibv_wc_read_opcode_t; + +enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_opcode_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_OPCODE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_vendor_err + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_vendor_err_t; + +uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_vendor_err_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_VENDOR_ERR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_byte_len + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_byte_len_t; + +uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_byte_len_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_BYTE_LEN, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_imm_data + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + __be32 ret; +} __attribute__((packed)) uhyve_ibv_wc_read_imm_data_t; + +__be32 ibv_wc_read_imm_data(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_imm_data_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_IMM_DATA, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_invalidated_rkey + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_invalidated_rkey_t; + +uint32_t ibv_wc_read_invalidated_rkey(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_invalidated_rkey_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_qp_num + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_qp_num_t; + +uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_qp_num_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_QP_NUM, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_src_qp + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_src_qp_t; + +uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_src_qp_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_SRC_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_wc_flags + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_wc_read_wc_flags_t; + +int ibv_wc_read_wc_flags(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_wc_flags_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_WC_FLAGS, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_slid + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_slid_t; + +uint32_t ibv_wc_read_slid(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_slid_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_SLID, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_sl + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint8_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_sl_t; + +uint8_t ibv_wc_read_sl(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_sl_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_SL, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_dlid_path_bits + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint8_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_dlid_path_bits_t; + +uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_dlid_path_bits_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_completion_ts + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint64_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_completion_ts_t; + +uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_completion_ts_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_COMPLETION_TS, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_cvlan + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint16_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_cvlan_t; + +uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_cvlan_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_CVLAN, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_flow_tag + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_flow_tag_t; + +uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_flow_tag_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_FLOW_TAG, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_post_wq_recv + */ + +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; + +int ibv_post_wq_recv(struct ibv_wq * wq, struct ibv_recv_wr * recv_wr, struct ibv_recv_wr ** bad_recv_wr) { + uhyve_ibv_post_wq_recv_t uhyve_args; + uhyve_args.wq = wq; + uhyve_args.recv_wr = recv_wr; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_POST_WQ_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * verbs_get_ctx + */ + +typedef struct { + // Parameters: + struct ibv_context * ctx; + // Return value: + struct verbs_context * ret; +} __attribute__((packed)) uhyve_verbs_get_ctx_t; + +struct verbs_context * verbs_get_ctx(struct ibv_context * ctx) { + uhyve_verbs_get_ctx_t uhyve_args; + uhyve_args.ctx = ctx; + + uhyve_send(UHYVE_PORT_VERBS_GET_CTX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} /* @@ -65,6 +585,7 @@ typedef struct { struct ibv_device ** ibv_get_device_list(int * num_devices) { uhyve_ibv_get_device_list_t uhyve_args; + /* uhyve_args.num_devices = num_devices; */ uhyve_args.num_devices = (int *) guest_to_host((size_t) num_devices); uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned) virt_to_phys((size_t) &uhyve_args)); @@ -73,6 +594,23 @@ struct ibv_device ** ibv_get_device_list(int * num_devices) { } +/* + * ibv_free_device_list + */ + +typedef struct { + // Parameters: + struct ibv_device ** list; +} __attribute__((packed)) uhyve_ibv_free_device_list_t; + +void ibv_free_device_list(struct ibv_device ** list) { + uhyve_ibv_free_device_list_t uhyve_args; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_FREE_DEVICE_LIST, (unsigned) virt_to_phys((size_t) &uhyve_args)); +} + + /* * ibv_get_device_name */ @@ -81,7 +619,7 @@ typedef struct { // Parameters: struct ibv_device * device; // Return value: - char * ret; // TODO: const? + const char * ret; } __attribute__((packed)) uhyve_ibv_get_device_name_t; const char * ibv_get_device_name(struct ibv_device * device) { @@ -94,6 +632,27 @@ const char * ibv_get_device_name(struct ibv_device * device) { } +/* + * ibv_get_device_guid + */ + +typedef struct { + // Parameters: + struct ibv_device * device; + // Return value: + __be64 ret; +} __attribute__((packed)) uhyve_ibv_get_device_guid_t; + +__be64 ibv_get_device_guid(struct ibv_device * device) { + uhyve_ibv_get_device_guid_t uhyve_args; + uhyve_args.device = device; + + uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_GUID, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + /* * ibv_open_device */ @@ -109,7 +668,91 @@ struct ibv_context * ibv_open_device(struct ibv_device * device) { uhyve_ibv_open_device_t uhyve_args; uhyve_args.device = device; - uhyve_send(UHYVE_PORT_IBV_OPEN_DEVICE, (unsigned) virt_to_phys((size_t)&uhyve_args)); + uhyve_send(UHYVE_PORT_IBV_OPEN_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_close_device + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_close_device_t; + +int ibv_close_device(struct ibv_context * context) { + uhyve_ibv_close_device_t uhyve_args; + uhyve_args.context = context; + + uhyve_send(UHYVE_PORT_IBV_CLOSE_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_get_async_event + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + struct ibv_async_event * event; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_get_async_event_t; + +int ibv_get_async_event(struct ibv_context * context, struct ibv_async_event * event) { + uhyve_ibv_get_async_event_t uhyve_args; + uhyve_args.context = context; + uhyve_args.event = event; + + uhyve_send(UHYVE_PORT_IBV_GET_ASYNC_EVENT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_ack_async_event + */ + +typedef struct { + // Parameters: + struct ibv_async_event * event; +} __attribute__((packed)) uhyve_ibv_ack_async_event_t; + +void ibv_ack_async_event(struct ibv_async_event * event) { + uhyve_ibv_ack_async_event_t uhyve_args; + uhyve_args.event = event; + + uhyve_send(UHYVE_PORT_IBV_ACK_ASYNC_EVENT, (unsigned) virt_to_phys((size_t) &uhyve_args)); +} + + +/* + * ibv_query_device + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + struct ibv_device_attr * device_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_query_device_t; + +int ibv_query_device(struct ibv_context * context, struct ibv_device_attr * device_attr) { + uhyve_ibv_query_device_t uhyve_args; + uhyve_args.context = context; + uhyve_args.device_attr = device_attr; + + uhyve_send(UHYVE_PORT_IBV_QUERY_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args)); return uhyve_args.ret; } @@ -130,14 +773,389 @@ typedef struct { 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 = context; - uhyve_args.port_num = port_num; - /* uhyve_args.port_attr = guest_to_host_ibv_port_attr(port_attr); */ - uhyve_args.port_attr = port_attr; // TODO: what to do there + uhyve_args.context = context; + uhyve_args.port_num = port_num; + uhyve_args.port_attr = port_attr; uhyve_send(UHYVE_PORT_IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args)); - /* host_to_guest_ibv_port_attr(port_attr, GUEST); */ + return uhyve_args.ret; +} + + +/* + * ___ibv_query_port + */ + +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 = context; + uhyve_args.port_num = port_num; + uhyve_args.port_attr = port_attr; + + uhyve_send(UHYVE_PORT____IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_gid + */ + +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; + +int ibv_query_gid(struct ibv_context * context, uint8_t port_num, int index, union ibv_gid * gid) { + uhyve_ibv_query_gid_t uhyve_args; + uhyve_args.context = context; + uhyve_args.port_num = port_num; + uhyve_args.index = index; + uhyve_args.gid = gid; + + uhyve_send(UHYVE_PORT_IBV_QUERY_GID, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_pkey + */ + +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; + +int ibv_query_pkey(struct ibv_context * context, uint8_t port_num, int index, __be16 * pkey) { + uhyve_ibv_query_pkey_t uhyve_args; + uhyve_args.context = context; + uhyve_args.port_num = port_num; + uhyve_args.index = index; + uhyve_args.pkey = pkey; + + uhyve_send(UHYVE_PORT_IBV_QUERY_PKEY, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_alloc_pd + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + struct ibv_pd * ret; +} __attribute__((packed)) uhyve_ibv_alloc_pd_t; + +struct ibv_pd * ibv_alloc_pd(struct ibv_context * context) { + uhyve_ibv_alloc_pd_t uhyve_args; + uhyve_args.context = context; + + uhyve_send(UHYVE_PORT_IBV_ALLOC_PD, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_dealloc_pd + */ + +typedef struct { + // Parameters: + struct ibv_pd * pd; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dealloc_pd_t; + +int ibv_dealloc_pd(struct ibv_pd * pd) { + uhyve_ibv_dealloc_pd_t uhyve_args; + uhyve_args.pd = pd; + + uhyve_send(UHYVE_PORT_IBV_DEALLOC_PD, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_flow + */ + +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; + +struct ibv_flow * ibv_create_flow(struct ibv_qp * qp, struct ibv_flow_attr * flow) { + uhyve_ibv_create_flow_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.flow = flow; + + uhyve_send(UHYVE_PORT_IBV_CREATE_FLOW, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_flow + */ + +typedef struct { + // Parameters: + struct ibv_flow * flow_id; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_flow_t; + +int ibv_destroy_flow(struct ibv_flow * flow_id) { + uhyve_ibv_destroy_flow_t uhyve_args; + uhyve_args.flow_id = flow_id; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_FLOW, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_open_xrcd + */ + +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; + +struct ibv_xrcd * ibv_open_xrcd(struct ibv_context * context, struct ibv_xrcd_init_attr * xrcd_init_attr) { + uhyve_ibv_open_xrcd_t uhyve_args; + uhyve_args.context = context; + uhyve_args.xrcd_init_attr = xrcd_init_attr; + + uhyve_send(UHYVE_PORT_IBV_OPEN_XRCD, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_close_xrcd + */ + +typedef struct { + // Parameters: + struct ibv_xrcd * xrcd; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_close_xrcd_t; + +int ibv_close_xrcd(struct ibv_xrcd * xrcd) { + uhyve_ibv_close_xrcd_t uhyve_args; + uhyve_args.xrcd = xrcd; + + uhyve_send(UHYVE_PORT_IBV_CLOSE_XRCD, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_reg_mr + */ + +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; + +struct ibv_mr * ibv_reg_mr(struct ibv_pd * pd, void * addr, int length, int access) { + uhyve_ibv_reg_mr_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.addr = addr; + uhyve_args.length = length; + uhyve_args.access = access; + + uhyve_send(UHYVE_PORT_IBV_REG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_rereg_mr + */ + +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; + +int ibv_rereg_mr(struct ibv_mr * mr, int flags, struct ibv_pd * pd, void * addr, int length, int access) { + uhyve_ibv_rereg_mr_t uhyve_args; + uhyve_args.mr = mr; + uhyve_args.flags = flags; + uhyve_args.pd = pd; + uhyve_args.addr = addr; + uhyve_args.length = length; + uhyve_args.access = access; + + uhyve_send(UHYVE_PORT_IBV_REREG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_dereg_mr + */ + +typedef struct { + // Parameters: + struct ibv_mr * mr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dereg_mr_t; + +int ibv_dereg_mr(struct ibv_mr * mr) { + uhyve_ibv_dereg_mr_t uhyve_args; + uhyve_args.mr = mr; + + uhyve_send(UHYVE_PORT_IBV_DEREG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_alloc_mw + */ + +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; + +struct ibv_mw * ibv_alloc_mw(struct ibv_pd * pd, enum ibv_mw_type type) { + uhyve_ibv_alloc_mw_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.type = type; + + uhyve_send(UHYVE_PORT_IBV_ALLOC_MW, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_dealloc_mw + */ + +typedef struct { + // Parameters: + struct ibv_mw * mw; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dealloc_mw_t; + +int ibv_dealloc_mw(struct ibv_mw * mw) { + uhyve_ibv_dealloc_mw_t uhyve_args; + uhyve_args.mw = mw; + + uhyve_send(UHYVE_PORT_IBV_DEALLOC_MW, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_inc_rkey + */ + +typedef struct { + // Parameters: + uint32_t rkey; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_inc_rkey_t; + +uint32_t ibv_inc_rkey(uint32_t rkey) { + uhyve_ibv_inc_rkey_t uhyve_args; + uhyve_args.rkey = rkey; + + uhyve_send(UHYVE_PORT_IBV_INC_RKEY, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_bind_mw + */ + +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; + +int ibv_bind_mw(struct ibv_qp * qp, struct ibv_mw * mw, struct ibv_mw_bind * mw_bind) { + uhyve_ibv_bind_mw_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.mw = mw; + uhyve_args.mw_bind = mw_bind; + + uhyve_send(UHYVE_PORT_IBV_BIND_MW, (unsigned) virt_to_phys((size_t) &uhyve_args)); return uhyve_args.ret; } @@ -164,6 +1182,1014 @@ struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context) } +/* + * ibv_destroy_comp_channel + */ + +typedef struct { + // Parameters: + struct ibv_comp_channel * channel; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_comp_channel_t; + +int ibv_destroy_comp_channel(struct ibv_comp_channel * channel) { + uhyve_ibv_destroy_comp_channel_t uhyve_args; + uhyve_args.channel = channel; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_cq + */ + +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; + +struct ibv_cq * ibv_create_cq(struct ibv_context * context, int cqe, void * cq_context, struct ibv_comp_channel * channel, int comp_vector) { + uhyve_ibv_create_cq_t uhyve_args; + uhyve_args.context = context; + uhyve_args.cqe = cqe; + uhyve_args.cq_context = cq_context; + uhyve_args.channel = channel; + uhyve_args.comp_vector = comp_vector; + + uhyve_send(UHYVE_PORT_IBV_CREATE_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_cq_ex + */ + +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; + +struct ibv_cq_ex * ibv_create_cq_ex(struct ibv_context * context, struct ibv_cq_init_attr_ex * cq_attr) { + uhyve_ibv_create_cq_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.cq_attr = cq_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_CQ_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_resize_cq + */ + +typedef struct { + // Parameters: + struct ibv_cq * cq; + int cqe; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_resize_cq_t; + +int ibv_resize_cq(struct ibv_cq * cq, int cqe) { + uhyve_ibv_resize_cq_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.cqe = cqe; + + uhyve_send(UHYVE_PORT_IBV_RESIZE_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_cq + */ + +typedef struct { + // Parameters: + struct ibv_cq * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_cq_t; + +int ibv_destroy_cq(struct ibv_cq * cq) { + uhyve_ibv_destroy_cq_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_get_cq_event + */ + +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; + +int ibv_get_cq_event(struct ibv_comp_channel * channel, struct ibv_cq ** cq, void ** cq_context) { + uhyve_ibv_get_cq_event_t uhyve_args; + uhyve_args.channel = channel; + // TODO: Take care of ** parameter. + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_GET_CQ_EVENT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_ack_cq_events + */ + +typedef struct { + // Parameters: + struct ibv_cq * cq; + unsigned int nevents; +} __attribute__((packed)) uhyve_ibv_ack_cq_events_t; + +void ibv_ack_cq_events(struct ibv_cq * cq, unsigned int nevents) { + uhyve_ibv_ack_cq_events_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.nevents = nevents; + + uhyve_send(UHYVE_PORT_IBV_ACK_CQ_EVENTS, (unsigned) virt_to_phys((size_t) &uhyve_args)); +} + + +/* + * ibv_poll_cq + */ + +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; + +int ibv_poll_cq(struct ibv_cq * cq, int num_entries, struct ibv_wc * wc) { + uhyve_ibv_poll_cq_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.num_entries = num_entries; + uhyve_args.wc = wc; + + uhyve_send(UHYVE_PORT_IBV_POLL_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_req_notify_cq + */ + +typedef struct { + // Parameters: + struct ibv_cq * cq; + int solicited_only; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_req_notify_cq_t; + +int ibv_req_notify_cq(struct ibv_cq * cq, int solicited_only) { + uhyve_ibv_req_notify_cq_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.solicited_only = solicited_only; + + uhyve_send(UHYVE_PORT_IBV_REQ_NOTIFY_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_srq + */ + +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; + +struct ibv_srq * ibv_create_srq(struct ibv_pd * pd, struct ibv_srq_init_attr * srq_init_attr) { + uhyve_ibv_create_srq_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.srq_init_attr = srq_init_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_SRQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_srq_ex + */ + +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; + +struct ibv_srq * ibv_create_srq_ex(struct ibv_context * context, struct ibv_srq_init_attr_ex * srq_init_attr_ex) { + uhyve_ibv_create_srq_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.srq_init_attr_ex = srq_init_attr_ex; + + uhyve_send(UHYVE_PORT_IBV_CREATE_SRQ_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_modify_srq + */ + +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; + +int ibv_modify_srq(struct ibv_srq * srq, struct ibv_srq_attr * srq_attr, int srq_attr_mask) { + uhyve_ibv_modify_srq_t uhyve_args; + uhyve_args.srq = srq; + uhyve_args.srq_attr = srq_attr; + uhyve_args.srq_attr_mask = srq_attr_mask; + + uhyve_send(UHYVE_PORT_IBV_MODIFY_SRQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_srq + */ + +typedef struct { + // Parameters: + struct ibv_srq * srq; + struct ibv_srq_attr * srq_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_query_srq_t; + +int ibv_query_srq(struct ibv_srq * srq, struct ibv_srq_attr * srq_attr) { + uhyve_ibv_query_srq_t uhyve_args; + uhyve_args.srq = srq; + uhyve_args.srq_attr = srq_attr; + + uhyve_send(UHYVE_PORT_IBV_QUERY_SRQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_get_srq_num + */ + +typedef struct { + // Parameters: + struct ibv_srq * srq; + uint32_t * srq_num; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_get_srq_num_t; + +int ibv_get_srq_num(struct ibv_srq * srq, uint32_t * srq_num) { + uhyve_ibv_get_srq_num_t uhyve_args; + uhyve_args.srq = srq; + uhyve_args.srq_num = srq_num; + + uhyve_send(UHYVE_PORT_IBV_GET_SRQ_NUM, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_srq + */ + +typedef struct { + // Parameters: + struct ibv_srq * srq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_srq_t; + +int ibv_destroy_srq(struct ibv_srq * srq) { + uhyve_ibv_destroy_srq_t uhyve_args; + uhyve_args.srq = srq; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_SRQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_post_srq_recv + */ + +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; + +int ibv_post_srq_recv(struct ibv_srq * srq, struct ibv_recv_wr * recv_wr, struct ibv_recv_wr ** bad_recv_wr) { + uhyve_ibv_post_srq_recv_t uhyve_args; + uhyve_args.srq = srq; + uhyve_args.recv_wr = recv_wr; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_POST_SRQ_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_qp + */ + +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; + +struct ibv_qp * ibv_create_qp(struct ibv_pd * pd, struct ibv_qp_init_attr * qp_init_attr) { + uhyve_ibv_create_qp_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.qp_init_attr = qp_init_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_qp_ex + */ + +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; + +struct ibv_qp * ibv_create_qp_ex(struct ibv_context * context, struct ibv_qp_init_attr_ex * qp_init_attr_ex) { + uhyve_ibv_create_qp_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.qp_init_attr_ex = qp_init_attr_ex; + + uhyve_send(UHYVE_PORT_IBV_CREATE_QP_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_rt_values_ex + */ + +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; + +int ibv_query_rt_values_ex(struct ibv_context * context, struct ibv_values_ex * values) { + uhyve_ibv_query_rt_values_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.values = values; + + uhyve_send(UHYVE_PORT_IBV_QUERY_RT_VALUES_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_device_ex + */ + +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; + +int ibv_query_device_ex(struct ibv_context * context, const struct ibv_query_device_ex_input * input, struct ibv_device_attr_ex * attr) { + uhyve_ibv_query_device_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.input = input; + uhyve_args.attr = attr; + + uhyve_send(UHYVE_PORT_IBV_QUERY_DEVICE_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_open_qp + */ + +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; + +struct ibv_qp * ibv_open_qp(struct ibv_context * context, struct ibv_qp_open_attr * qp_open_attr) { + uhyve_ibv_open_qp_t uhyve_args; + uhyve_args.context = context; + uhyve_args.qp_open_attr = qp_open_attr; + + uhyve_send(UHYVE_PORT_IBV_OPEN_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_modify_qp + */ + +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; + +int ibv_modify_qp(struct ibv_qp * qp, struct ibv_qp_attr * attr, int attr_mask) { + uhyve_ibv_modify_qp_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.attr = attr; + uhyve_args.attr_mask = attr_mask; + + uhyve_send(UHYVE_PORT_IBV_MODIFY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_qp + */ + +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; + +int ibv_query_qp(struct ibv_qp * qp, struct ibv_qp_attr * attr, int attr_mask, struct ibv_qp_init_attr * init_attr) { + uhyve_ibv_query_qp_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.attr = attr; + uhyve_args.attr_mask = attr_mask; + uhyve_args.init_attr = init_attr; + + uhyve_send(UHYVE_PORT_IBV_QUERY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_qp + */ + +typedef struct { + // Parameters: + struct ibv_qp * qp; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_qp_t; + +int ibv_destroy_qp(struct ibv_qp * qp) { + uhyve_ibv_destroy_qp_t uhyve_args; + uhyve_args.qp = qp; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_wq + */ + +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; + +struct ibv_wq * ibv_create_wq(struct ibv_context * context, struct ibv_wq_init_attr * wq_init_attr) { + uhyve_ibv_create_wq_t uhyve_args; + uhyve_args.context = context; + uhyve_args.wq_init_attr = wq_init_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_WQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_modify_wq + */ + +typedef struct { + // Parameters: + struct ibv_wq * wq; + struct ibv_wq_attr * wq_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_modify_wq_t; + +int ibv_modify_wq(struct ibv_wq * wq, struct ibv_wq_attr * wq_attr) { + uhyve_ibv_modify_wq_t uhyve_args; + uhyve_args.wq = wq; + uhyve_args.wq_attr = wq_attr; + + uhyve_send(UHYVE_PORT_IBV_MODIFY_WQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_wq + */ + +typedef struct { + // Parameters: + struct ibv_wq * wq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_wq_t; + +int ibv_destroy_wq(struct ibv_wq * wq) { + uhyve_ibv_destroy_wq_t uhyve_args; + uhyve_args.wq = wq; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_WQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_rwq_ind_table + */ + +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; + +struct ibv_rwq_ind_table * ibv_create_rwq_ind_table(struct ibv_context * context, struct ibv_rwq_ind_table_init_attr * init_attr) { + uhyve_ibv_create_rwq_ind_table_t uhyve_args; + uhyve_args.context = context; + uhyve_args.init_attr = init_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_rwq_ind_table + */ + +typedef struct { + // Parameters: + struct ibv_rwq_ind_table * rwq_ind_table; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_rwq_ind_table_t; + +int ibv_destroy_rwq_ind_table(struct ibv_rwq_ind_table * rwq_ind_table) { + uhyve_ibv_destroy_rwq_ind_table_t uhyve_args; + uhyve_args.rwq_ind_table = rwq_ind_table; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_post_send + */ + +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; + +int ibv_post_send(struct ibv_qp * qp, struct ibv_send_wr * wr, struct ibv_send_wr ** bad_wr) { + uhyve_ibv_post_send_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.wr = wr; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_POST_SEND, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_post_recv + */ + +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; + +int ibv_post_recv(struct ibv_qp * qp, struct ibv_recv_wr * wr, struct ibv_recv_wr ** bad_wr) { + uhyve_ibv_post_recv_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.wr = wr; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_POST_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_ah + */ + +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; + +struct ibv_ah * ibv_create_ah(struct ibv_pd * pd, struct ibv_ah_attr * attr) { + uhyve_ibv_create_ah_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.attr = attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_AH, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_init_ah_from_wc + */ + +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; + +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) { + uhyve_ibv_init_ah_from_wc_t uhyve_args; + uhyve_args.context = context; + uhyve_args.port_num = port_num; + uhyve_args.wc = wc; + uhyve_args.grh = grh; + uhyve_args.ah_attr = ah_attr; + + uhyve_send(UHYVE_PORT_IBV_INIT_AH_FROM_WC, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_ah_from_wc + */ + +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; + +struct ibv_ah * ibv_create_ah_from_wc(struct ibv_pd * pd, struct ibv_wc * wc, struct ibv_grh * grh, uint8_t port_num) { + uhyve_ibv_create_ah_from_wc_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.wc = wc; + uhyve_args.grh = grh; + uhyve_args.port_num = port_num; + + uhyve_send(UHYVE_PORT_IBV_CREATE_AH_FROM_WC, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_ah + */ + +typedef struct { + // Parameters: + struct ibv_ah * ah; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_ah_t; + +int ibv_destroy_ah(struct ibv_ah * ah) { + uhyve_ibv_destroy_ah_t uhyve_args; + uhyve_args.ah = ah; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_AH, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_attach_mcast + */ + +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; + +int ibv_attach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid) { + uhyve_ibv_attach_mcast_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.gid = gid; + uhyve_args.lid = lid; + + uhyve_send(UHYVE_PORT_IBV_ATTACH_MCAST, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_detach_mcast + */ + +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; + +int ibv_detach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid) { + uhyve_ibv_detach_mcast_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.gid = gid; + uhyve_args.lid = lid; + + uhyve_send(UHYVE_PORT_IBV_DETACH_MCAST, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_fork_init + */ + +typedef struct { + // Parameters: + ; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_fork_init_t; + +int ibv_fork_init( ) { + uhyve_ibv_fork_init_t uhyve_args; + uhyve_args. = ; + + uhyve_send(UHYVE_PORT_IBV_FORK_INIT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_node_type_str + */ + +typedef struct { + // Parameters: + enum ibv_node_type node_type; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_node_type_str_t; + +const char * ibv_node_type_str(enum ibv_node_type node_type) { + uhyve_ibv_node_type_str_t uhyve_args; + uhyve_args.node_type = node_type; + + uhyve_send(UHYVE_PORT_IBV_NODE_TYPE_STR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_port_state_str + */ + +typedef struct { + // Parameters: + enum ibv_port_state port_state; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_port_state_str_t; + +const char * ibv_port_state_str(enum ibv_port_state port_state) { + uhyve_ibv_port_state_str_t uhyve_args; + uhyve_args.port_state = port_state; + + uhyve_send(UHYVE_PORT_IBV_PORT_STATE_STR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_event_type_str + */ + +typedef struct { + // Parameters: + enum ibv_event_type event; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_event_type_str_t; + +const char * ibv_event_type_str(enum ibv_event_type event) { + uhyve_ibv_event_type_str_t uhyve_args; + uhyve_args.event = event; + + uhyve_send(UHYVE_PORT_IBV_EVENT_TYPE_STR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_resolve_eth_l2_from_gid + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + struct ibv_ah_attr * attr; + uint8_t [6] eth_mac; + uint16_t * vid; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_resolve_eth_l2_from_gid_t; + +int ibv_resolve_eth_l2_from_gid(struct ibv_context * context, struct ibv_ah_attr * attr, uint8_t [6] eth_mac, uint16_t * vid) { + uhyve_ibv_resolve_eth_l2_from_gid_t uhyve_args; + uhyve_args.context = context; + uhyve_args.attr = attr; + uhyve_args.eth_mac = eth_mac; + uhyve_args.vid = vid; + + uhyve_send(UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_is_qpt_supported + */ + +typedef struct { + // Parameters: + uint32_t caps; + enum ibv_qp_type qpt; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_is_qpt_supported_t; + +int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt) { + uhyve_ibv_is_qpt_supported_t uhyve_args; + uhyve_args.caps = caps; + uhyve_args.qpt = qpt; + + uhyve_send(UHYVE_PORT_IBV_IS_QPT_SUPPORTED, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + + /* * IBV KERNEL LOG */ diff --git a/tools/ibv_code_generator/GEN-include-hermit-stddef.h b/tools/ibv_code_generator/GEN-include-hermit-stddef.h index 3e1b9533c..63aa1c0c8 100644 --- a/tools/ibv_code_generator/GEN-include-hermit-stddef.h +++ b/tools/ibv_code_generator/GEN-include-hermit-stddef.h @@ -1,5 +1,96 @@ - -#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 \ No newline at end of file +#define UHYVE_PORT_SET_IB_POOL_ADDR 0x60F +#define UHYVE_PORT_IBV_WC_STATUS_STR 0x610 +#define UHYVE_PORT_IBV_RATE_TO_MULT 0x611 +#define UHYVE_PORT_MULT_TO_IBV_RATE 0x612 +#define UHYVE_PORT_IBV_RATE_TO_MBPS 0x613 +#define UHYVE_PORT_MBPS_TO_IBV_RATE 0x614 +#define UHYVE_PORT_IBV_CQ_EX_TO_CQ 0x615 +#define UHYVE_PORT_IBV_START_POLL 0x616 +#define UHYVE_PORT_IBV_NEXT_POLL 0x617 +#define UHYVE_PORT_IBV_END_POLL 0x618 +#define UHYVE_PORT_IBV_WC_READ_OPCODE 0x619 +#define UHYVE_PORT_IBV_WC_READ_VENDOR_ERR 0x61A +#define UHYVE_PORT_IBV_WC_READ_BYTE_LEN 0x61B +#define UHYVE_PORT_IBV_WC_READ_IMM_DATA 0x61C +#define UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY 0x61D +#define UHYVE_PORT_IBV_WC_READ_QP_NUM 0x61E +#define UHYVE_PORT_IBV_WC_READ_SRC_QP 0x61F +#define UHYVE_PORT_IBV_WC_READ_WC_FLAGS 0x620 +#define UHYVE_PORT_IBV_WC_READ_SLID 0x621 +#define UHYVE_PORT_IBV_WC_READ_SL 0x622 +#define UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS 0x623 +#define UHYVE_PORT_IBV_WC_READ_COMPLETION_TS 0x624 +#define UHYVE_PORT_IBV_WC_READ_CVLAN 0x625 +#define UHYVE_PORT_IBV_WC_READ_FLOW_TAG 0x626 +#define UHYVE_PORT_IBV_POST_WQ_RECV 0x627 +#define UHYVE_PORT_VERBS_GET_CTX 0x628 +#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x629 +#define UHYVE_PORT_IBV_FREE_DEVICE_LIST 0x62A +#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x62B +#define UHYVE_PORT_IBV_GET_DEVICE_GUID 0x62C +#define UHYVE_PORT_IBV_OPEN_DEVICE 0x62D +#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x62E +#define UHYVE_PORT_IBV_GET_ASYNC_EVENT 0x62F +#define UHYVE_PORT_IBV_ACK_ASYNC_EVENT 0x630 +#define UHYVE_PORT_IBV_QUERY_DEVICE 0x631 +#define UHYVE_PORT_IBV_QUERY_PORT 0x632 +#define UHYVE_PORT____IBV_QUERY_PORT 0x633 +#define UHYVE_PORT_IBV_QUERY_GID 0x634 +#define UHYVE_PORT_IBV_QUERY_PKEY 0x635 +#define UHYVE_PORT_IBV_ALLOC_PD 0x636 +#define UHYVE_PORT_IBV_DEALLOC_PD 0x637 +#define UHYVE_PORT_IBV_CREATE_FLOW 0x638 +#define UHYVE_PORT_IBV_DESTROY_FLOW 0x639 +#define UHYVE_PORT_IBV_OPEN_XRCD 0x63A +#define UHYVE_PORT_IBV_CLOSE_XRCD 0x63B +#define UHYVE_PORT_IBV_REG_MR 0x63C +#define UHYVE_PORT_IBV_REREG_MR 0x63D +#define UHYVE_PORT_IBV_DEREG_MR 0x63E +#define UHYVE_PORT_IBV_ALLOC_MW 0x63F +#define UHYVE_PORT_IBV_DEALLOC_MW 0x640 +#define UHYVE_PORT_IBV_INC_RKEY 0x641 +#define UHYVE_PORT_IBV_BIND_MW 0x642 +#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x643 +#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x644 +#define UHYVE_PORT_IBV_CREATE_CQ 0x645 +#define UHYVE_PORT_IBV_CREATE_CQ_EX 0x646 +#define UHYVE_PORT_IBV_RESIZE_CQ 0x647 +#define UHYVE_PORT_IBV_DESTROY_CQ 0x648 +#define UHYVE_PORT_IBV_GET_CQ_EVENT 0x649 +#define UHYVE_PORT_IBV_ACK_CQ_EVENTS 0x64A +#define UHYVE_PORT_IBV_POLL_CQ 0x64B +#define UHYVE_PORT_IBV_REQ_NOTIFY_CQ 0x64C +#define UHYVE_PORT_IBV_CREATE_SRQ 0x64D +#define UHYVE_PORT_IBV_CREATE_SRQ_EX 0x64E +#define UHYVE_PORT_IBV_MODIFY_SRQ 0x64F +#define UHYVE_PORT_IBV_QUERY_SRQ 0x650 +#define UHYVE_PORT_IBV_GET_SRQ_NUM 0x651 +#define UHYVE_PORT_IBV_DESTROY_SRQ 0x652 +#define UHYVE_PORT_IBV_POST_SRQ_RECV 0x653 +#define UHYVE_PORT_IBV_CREATE_QP 0x654 +#define UHYVE_PORT_IBV_CREATE_QP_EX 0x655 +#define UHYVE_PORT_IBV_QUERY_RT_VALUES_EX 0x656 +#define UHYVE_PORT_IBV_QUERY_DEVICE_EX 0x657 +#define UHYVE_PORT_IBV_OPEN_QP 0x658 +#define UHYVE_PORT_IBV_MODIFY_QP 0x659 +#define UHYVE_PORT_IBV_QUERY_QP 0x65A +#define UHYVE_PORT_IBV_DESTROY_QP 0x65B +#define UHYVE_PORT_IBV_CREATE_WQ 0x65C +#define UHYVE_PORT_IBV_MODIFY_WQ 0x65D +#define UHYVE_PORT_IBV_DESTROY_WQ 0x65E +#define UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE 0x65F +#define UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE 0x660 +#define UHYVE_PORT_IBV_POST_SEND 0x661 +#define UHYVE_PORT_IBV_POST_RECV 0x662 +#define UHYVE_PORT_IBV_CREATE_AH 0x663 +#define UHYVE_PORT_IBV_INIT_AH_FROM_WC 0x664 +#define UHYVE_PORT_IBV_CREATE_AH_FROM_WC 0x665 +#define UHYVE_PORT_IBV_DESTROY_AH 0x666 +#define UHYVE_PORT_IBV_ATTACH_MCAST 0x667 +#define UHYVE_PORT_IBV_DETACH_MCAST 0x668 +#define UHYVE_PORT_IBV_FORK_INIT 0x669 +#define UHYVE_PORT_IBV_NODE_TYPE_STR 0x66A +#define UHYVE_PORT_IBV_PORT_STATE_STR 0x66B +#define UHYVE_PORT_IBV_EVENT_TYPE_STR 0x66C +#define UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID 0x66D +#define UHYVE_PORT_IBV_IS_QPT_SUPPORTED 0x66E diff --git a/tools/ibv_code_generator/GEN-kernel-header.h b/tools/ibv_code_generator/GEN-kernel-header.h new file mode 100644 index 000000000..659f540f2 --- /dev/null +++ b/tools/ibv_code_generator/GEN-kernel-header.h @@ -0,0 +1,95 @@ +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 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); +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 [6] eth_mac, uint16_t * vid); +int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt); diff --git a/tools/ibv_code_generator/GEN-kernel.c b/tools/ibv_code_generator/GEN-kernel.c new file mode 100644 index 000000000..e27cd95bd --- /dev/null +++ b/tools/ibv_code_generator/GEN-kernel.c @@ -0,0 +1,2143 @@ +/* + * ibv_wc_status_str + */ + +typedef struct { + // Parameters: + enum ibv_wc_status status; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_wc_status_str_t; + +const char * ibv_wc_status_str(enum ibv_wc_status status) { + uhyve_ibv_wc_status_str_t uhyve_args; + uhyve_args.status = status; + + uhyve_send(UHYVE_PORT_IBV_WC_STATUS_STR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_rate_to_mult + */ + +typedef struct { + // Parameters: + enum ibv_rate rate; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_rate_to_mult_t; + +int ibv_rate_to_mult(enum ibv_rate rate) { + uhyve_ibv_rate_to_mult_t uhyve_args; + uhyve_args.rate = rate; + + uhyve_send(UHYVE_PORT_IBV_RATE_TO_MULT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * mult_to_ibv_rate + */ + +typedef struct { + // Parameters: + int mult; + // Return value: + enum ibv_rate ret; +} __attribute__((packed)) uhyve_mult_to_ibv_rate_t; + +enum ibv_rate mult_to_ibv_rate(int mult) { + uhyve_mult_to_ibv_rate_t uhyve_args; + uhyve_args.mult = mult; + + uhyve_send(UHYVE_PORT_MULT_TO_IBV_RATE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_rate_to_mbps + */ + +typedef struct { + // Parameters: + enum ibv_rate rate; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_rate_to_mbps_t; + +int ibv_rate_to_mbps(enum ibv_rate rate) { + uhyve_ibv_rate_to_mbps_t uhyve_args; + uhyve_args.rate = rate; + + uhyve_send(UHYVE_PORT_IBV_RATE_TO_MBPS, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * mbps_to_ibv_rate + */ + +typedef struct { + // Parameters: + int mbps; + // Return value: + enum ibv_rate ret; +} __attribute__((packed)) uhyve_mbps_to_ibv_rate_t; + +enum ibv_rate mbps_to_ibv_rate(int mbps) { + uhyve_mbps_to_ibv_rate_t uhyve_args; + uhyve_args.mbps = mbps; + + uhyve_send(UHYVE_PORT_MBPS_TO_IBV_RATE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_cq_ex_to_cq + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + struct ibv_cq * ret; +} __attribute__((packed)) uhyve_ibv_cq_ex_to_cq_t; + +struct ibv_cq * ibv_cq_ex_to_cq(struct ibv_cq_ex * cq) { + uhyve_ibv_cq_ex_to_cq_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_CQ_EX_TO_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_start_poll + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + struct ibv_poll_cq_attr * attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_start_poll_t; + +int ibv_start_poll(struct ibv_cq_ex * cq, struct ibv_poll_cq_attr * attr) { + uhyve_ibv_start_poll_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.attr = attr; + + uhyve_send(UHYVE_PORT_IBV_START_POLL, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_next_poll + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_next_poll_t; + +int ibv_next_poll(struct ibv_cq_ex * cq) { + uhyve_ibv_next_poll_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_NEXT_POLL, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_end_poll + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; +} __attribute__((packed)) uhyve_ibv_end_poll_t; + +void ibv_end_poll(struct ibv_cq_ex * cq) { + uhyve_ibv_end_poll_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_END_POLL, (unsigned) virt_to_phys((size_t) &uhyve_args)); +} + + +/* + * ibv_wc_read_opcode + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + enum ibv_wc_opcode ret; +} __attribute__((packed)) uhyve_ibv_wc_read_opcode_t; + +enum ibv_wc_opcode ibv_wc_read_opcode(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_opcode_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_OPCODE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_vendor_err + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_vendor_err_t; + +uint32_t ibv_wc_read_vendor_err(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_vendor_err_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_VENDOR_ERR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_byte_len + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_byte_len_t; + +uint32_t ibv_wc_read_byte_len(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_byte_len_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_BYTE_LEN, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_imm_data + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + __be32 ret; +} __attribute__((packed)) uhyve_ibv_wc_read_imm_data_t; + +__be32 ibv_wc_read_imm_data(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_imm_data_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_IMM_DATA, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_invalidated_rkey + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_invalidated_rkey_t; + +uint32_t ibv_wc_read_invalidated_rkey(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_invalidated_rkey_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_qp_num + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_qp_num_t; + +uint32_t ibv_wc_read_qp_num(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_qp_num_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_QP_NUM, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_src_qp + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_src_qp_t; + +uint32_t ibv_wc_read_src_qp(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_src_qp_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_SRC_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_wc_flags + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_wc_read_wc_flags_t; + +int ibv_wc_read_wc_flags(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_wc_flags_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_WC_FLAGS, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_slid + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_slid_t; + +uint32_t ibv_wc_read_slid(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_slid_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_SLID, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_sl + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint8_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_sl_t; + +uint8_t ibv_wc_read_sl(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_sl_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_SL, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_dlid_path_bits + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint8_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_dlid_path_bits_t; + +uint8_t ibv_wc_read_dlid_path_bits(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_dlid_path_bits_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_completion_ts + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint64_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_completion_ts_t; + +uint64_t ibv_wc_read_completion_ts(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_completion_ts_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_COMPLETION_TS, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_cvlan + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint16_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_cvlan_t; + +uint16_t ibv_wc_read_cvlan(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_cvlan_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_CVLAN, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_wc_read_flow_tag + */ + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_flow_tag_t; + +uint32_t ibv_wc_read_flow_tag(struct ibv_cq_ex * cq) { + uhyve_ibv_wc_read_flow_tag_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_WC_READ_FLOW_TAG, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_post_wq_recv + */ + +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; + +int ibv_post_wq_recv(struct ibv_wq * wq, struct ibv_recv_wr * recv_wr, struct ibv_recv_wr ** bad_recv_wr) { + uhyve_ibv_post_wq_recv_t uhyve_args; + uhyve_args.wq = wq; + uhyve_args.recv_wr = recv_wr; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_POST_WQ_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * verbs_get_ctx + */ + +typedef struct { + // Parameters: + struct ibv_context * ctx; + // Return value: + struct verbs_context * ret; +} __attribute__((packed)) uhyve_verbs_get_ctx_t; + +struct verbs_context * verbs_get_ctx(struct ibv_context * ctx) { + uhyve_verbs_get_ctx_t uhyve_args; + uhyve_args.ctx = ctx; + + uhyve_send(UHYVE_PORT_VERBS_GET_CTX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_get_device_list + */ + +typedef struct { + // Parameters: + int * num_devices; + // Return value: + struct ibv_device ** ret; +} __attribute__((packed)) uhyve_ibv_get_device_list_t; + +struct ibv_device ** ibv_get_device_list(int * num_devices) { + uhyve_ibv_get_device_list_t uhyve_args; + uhyve_args.num_devices = num_devices; + + uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_free_device_list + */ + +typedef struct { + // Parameters: + struct ibv_device ** list; +} __attribute__((packed)) uhyve_ibv_free_device_list_t; + +void ibv_free_device_list(struct ibv_device ** list) { + uhyve_ibv_free_device_list_t uhyve_args; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_FREE_DEVICE_LIST, (unsigned) virt_to_phys((size_t) &uhyve_args)); +} + + +/* + * ibv_get_device_name + */ + +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 = device; + + uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_NAME, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_get_device_guid + */ + +typedef struct { + // Parameters: + struct ibv_device * device; + // Return value: + __be64 ret; +} __attribute__((packed)) uhyve_ibv_get_device_guid_t; + +__be64 ibv_get_device_guid(struct ibv_device * device) { + uhyve_ibv_get_device_guid_t uhyve_args; + uhyve_args.device = device; + + uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_GUID, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_open_device + */ + +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 = device; + + uhyve_send(UHYVE_PORT_IBV_OPEN_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_close_device + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_close_device_t; + +int ibv_close_device(struct ibv_context * context) { + uhyve_ibv_close_device_t uhyve_args; + uhyve_args.context = context; + + uhyve_send(UHYVE_PORT_IBV_CLOSE_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_get_async_event + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + struct ibv_async_event * event; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_get_async_event_t; + +int ibv_get_async_event(struct ibv_context * context, struct ibv_async_event * event) { + uhyve_ibv_get_async_event_t uhyve_args; + uhyve_args.context = context; + uhyve_args.event = event; + + uhyve_send(UHYVE_PORT_IBV_GET_ASYNC_EVENT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_ack_async_event + */ + +typedef struct { + // Parameters: + struct ibv_async_event * event; +} __attribute__((packed)) uhyve_ibv_ack_async_event_t; + +void ibv_ack_async_event(struct ibv_async_event * event) { + uhyve_ibv_ack_async_event_t uhyve_args; + uhyve_args.event = event; + + uhyve_send(UHYVE_PORT_IBV_ACK_ASYNC_EVENT, (unsigned) virt_to_phys((size_t) &uhyve_args)); +} + + +/* + * ibv_query_device + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + struct ibv_device_attr * device_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_query_device_t; + +int ibv_query_device(struct ibv_context * context, struct ibv_device_attr * device_attr) { + uhyve_ibv_query_device_t uhyve_args; + uhyve_args.context = context; + uhyve_args.device_attr = device_attr; + + uhyve_send(UHYVE_PORT_IBV_QUERY_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_port + */ + +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 = context; + uhyve_args.port_num = port_num; + uhyve_args.port_attr = port_attr; + + uhyve_send(UHYVE_PORT_IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ___ibv_query_port + */ + +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 = context; + uhyve_args.port_num = port_num; + uhyve_args.port_attr = port_attr; + + uhyve_send(UHYVE_PORT____IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_gid + */ + +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; + +int ibv_query_gid(struct ibv_context * context, uint8_t port_num, int index, union ibv_gid * gid) { + uhyve_ibv_query_gid_t uhyve_args; + uhyve_args.context = context; + uhyve_args.port_num = port_num; + uhyve_args.index = index; + uhyve_args.gid = gid; + + uhyve_send(UHYVE_PORT_IBV_QUERY_GID, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_pkey + */ + +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; + +int ibv_query_pkey(struct ibv_context * context, uint8_t port_num, int index, __be16 * pkey) { + uhyve_ibv_query_pkey_t uhyve_args; + uhyve_args.context = context; + uhyve_args.port_num = port_num; + uhyve_args.index = index; + uhyve_args.pkey = pkey; + + uhyve_send(UHYVE_PORT_IBV_QUERY_PKEY, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_alloc_pd + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + struct ibv_pd * ret; +} __attribute__((packed)) uhyve_ibv_alloc_pd_t; + +struct ibv_pd * ibv_alloc_pd(struct ibv_context * context) { + uhyve_ibv_alloc_pd_t uhyve_args; + uhyve_args.context = context; + + uhyve_send(UHYVE_PORT_IBV_ALLOC_PD, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_dealloc_pd + */ + +typedef struct { + // Parameters: + struct ibv_pd * pd; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dealloc_pd_t; + +int ibv_dealloc_pd(struct ibv_pd * pd) { + uhyve_ibv_dealloc_pd_t uhyve_args; + uhyve_args.pd = pd; + + uhyve_send(UHYVE_PORT_IBV_DEALLOC_PD, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_flow + */ + +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; + +struct ibv_flow * ibv_create_flow(struct ibv_qp * qp, struct ibv_flow_attr * flow) { + uhyve_ibv_create_flow_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.flow = flow; + + uhyve_send(UHYVE_PORT_IBV_CREATE_FLOW, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_flow + */ + +typedef struct { + // Parameters: + struct ibv_flow * flow_id; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_flow_t; + +int ibv_destroy_flow(struct ibv_flow * flow_id) { + uhyve_ibv_destroy_flow_t uhyve_args; + uhyve_args.flow_id = flow_id; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_FLOW, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_open_xrcd + */ + +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; + +struct ibv_xrcd * ibv_open_xrcd(struct ibv_context * context, struct ibv_xrcd_init_attr * xrcd_init_attr) { + uhyve_ibv_open_xrcd_t uhyve_args; + uhyve_args.context = context; + uhyve_args.xrcd_init_attr = xrcd_init_attr; + + uhyve_send(UHYVE_PORT_IBV_OPEN_XRCD, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_close_xrcd + */ + +typedef struct { + // Parameters: + struct ibv_xrcd * xrcd; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_close_xrcd_t; + +int ibv_close_xrcd(struct ibv_xrcd * xrcd) { + uhyve_ibv_close_xrcd_t uhyve_args; + uhyve_args.xrcd = xrcd; + + uhyve_send(UHYVE_PORT_IBV_CLOSE_XRCD, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_reg_mr + */ + +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; + +struct ibv_mr * ibv_reg_mr(struct ibv_pd * pd, void * addr, int length, int access) { + uhyve_ibv_reg_mr_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.addr = addr; + uhyve_args.length = length; + uhyve_args.access = access; + + uhyve_send(UHYVE_PORT_IBV_REG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_rereg_mr + */ + +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; + +int ibv_rereg_mr(struct ibv_mr * mr, int flags, struct ibv_pd * pd, void * addr, int length, int access) { + uhyve_ibv_rereg_mr_t uhyve_args; + uhyve_args.mr = mr; + uhyve_args.flags = flags; + uhyve_args.pd = pd; + uhyve_args.addr = addr; + uhyve_args.length = length; + uhyve_args.access = access; + + uhyve_send(UHYVE_PORT_IBV_REREG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_dereg_mr + */ + +typedef struct { + // Parameters: + struct ibv_mr * mr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dereg_mr_t; + +int ibv_dereg_mr(struct ibv_mr * mr) { + uhyve_ibv_dereg_mr_t uhyve_args; + uhyve_args.mr = mr; + + uhyve_send(UHYVE_PORT_IBV_DEREG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_alloc_mw + */ + +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; + +struct ibv_mw * ibv_alloc_mw(struct ibv_pd * pd, enum ibv_mw_type type) { + uhyve_ibv_alloc_mw_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.type = type; + + uhyve_send(UHYVE_PORT_IBV_ALLOC_MW, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_dealloc_mw + */ + +typedef struct { + // Parameters: + struct ibv_mw * mw; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dealloc_mw_t; + +int ibv_dealloc_mw(struct ibv_mw * mw) { + uhyve_ibv_dealloc_mw_t uhyve_args; + uhyve_args.mw = mw; + + uhyve_send(UHYVE_PORT_IBV_DEALLOC_MW, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_inc_rkey + */ + +typedef struct { + // Parameters: + uint32_t rkey; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_inc_rkey_t; + +uint32_t ibv_inc_rkey(uint32_t rkey) { + uhyve_ibv_inc_rkey_t uhyve_args; + uhyve_args.rkey = rkey; + + uhyve_send(UHYVE_PORT_IBV_INC_RKEY, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_bind_mw + */ + +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; + +int ibv_bind_mw(struct ibv_qp * qp, struct ibv_mw * mw, struct ibv_mw_bind * mw_bind) { + uhyve_ibv_bind_mw_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.mw = mw; + uhyve_args.mw_bind = mw_bind; + + uhyve_send(UHYVE_PORT_IBV_BIND_MW, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_comp_channel + */ + +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 = context; + + uhyve_send(UHYVE_PORT_IBV_CREATE_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_comp_channel + */ + +typedef struct { + // Parameters: + struct ibv_comp_channel * channel; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_comp_channel_t; + +int ibv_destroy_comp_channel(struct ibv_comp_channel * channel) { + uhyve_ibv_destroy_comp_channel_t uhyve_args; + uhyve_args.channel = channel; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_cq + */ + +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; + +struct ibv_cq * ibv_create_cq(struct ibv_context * context, int cqe, void * cq_context, struct ibv_comp_channel * channel, int comp_vector) { + uhyve_ibv_create_cq_t uhyve_args; + uhyve_args.context = context; + uhyve_args.cqe = cqe; + uhyve_args.cq_context = cq_context; + uhyve_args.channel = channel; + uhyve_args.comp_vector = comp_vector; + + uhyve_send(UHYVE_PORT_IBV_CREATE_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_cq_ex + */ + +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; + +struct ibv_cq_ex * ibv_create_cq_ex(struct ibv_context * context, struct ibv_cq_init_attr_ex * cq_attr) { + uhyve_ibv_create_cq_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.cq_attr = cq_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_CQ_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_resize_cq + */ + +typedef struct { + // Parameters: + struct ibv_cq * cq; + int cqe; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_resize_cq_t; + +int ibv_resize_cq(struct ibv_cq * cq, int cqe) { + uhyve_ibv_resize_cq_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.cqe = cqe; + + uhyve_send(UHYVE_PORT_IBV_RESIZE_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_cq + */ + +typedef struct { + // Parameters: + struct ibv_cq * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_cq_t; + +int ibv_destroy_cq(struct ibv_cq * cq) { + uhyve_ibv_destroy_cq_t uhyve_args; + uhyve_args.cq = cq; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_get_cq_event + */ + +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; + +int ibv_get_cq_event(struct ibv_comp_channel * channel, struct ibv_cq ** cq, void ** cq_context) { + uhyve_ibv_get_cq_event_t uhyve_args; + uhyve_args.channel = channel; + // TODO: Take care of ** parameter. + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_GET_CQ_EVENT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_ack_cq_events + */ + +typedef struct { + // Parameters: + struct ibv_cq * cq; + unsigned int nevents; +} __attribute__((packed)) uhyve_ibv_ack_cq_events_t; + +void ibv_ack_cq_events(struct ibv_cq * cq, unsigned int nevents) { + uhyve_ibv_ack_cq_events_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.nevents = nevents; + + uhyve_send(UHYVE_PORT_IBV_ACK_CQ_EVENTS, (unsigned) virt_to_phys((size_t) &uhyve_args)); +} + + +/* + * ibv_poll_cq + */ + +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; + +int ibv_poll_cq(struct ibv_cq * cq, int num_entries, struct ibv_wc * wc) { + uhyve_ibv_poll_cq_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.num_entries = num_entries; + uhyve_args.wc = wc; + + uhyve_send(UHYVE_PORT_IBV_POLL_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_req_notify_cq + */ + +typedef struct { + // Parameters: + struct ibv_cq * cq; + int solicited_only; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_req_notify_cq_t; + +int ibv_req_notify_cq(struct ibv_cq * cq, int solicited_only) { + uhyve_ibv_req_notify_cq_t uhyve_args; + uhyve_args.cq = cq; + uhyve_args.solicited_only = solicited_only; + + uhyve_send(UHYVE_PORT_IBV_REQ_NOTIFY_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_srq + */ + +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; + +struct ibv_srq * ibv_create_srq(struct ibv_pd * pd, struct ibv_srq_init_attr * srq_init_attr) { + uhyve_ibv_create_srq_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.srq_init_attr = srq_init_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_SRQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_srq_ex + */ + +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; + +struct ibv_srq * ibv_create_srq_ex(struct ibv_context * context, struct ibv_srq_init_attr_ex * srq_init_attr_ex) { + uhyve_ibv_create_srq_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.srq_init_attr_ex = srq_init_attr_ex; + + uhyve_send(UHYVE_PORT_IBV_CREATE_SRQ_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_modify_srq + */ + +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; + +int ibv_modify_srq(struct ibv_srq * srq, struct ibv_srq_attr * srq_attr, int srq_attr_mask) { + uhyve_ibv_modify_srq_t uhyve_args; + uhyve_args.srq = srq; + uhyve_args.srq_attr = srq_attr; + uhyve_args.srq_attr_mask = srq_attr_mask; + + uhyve_send(UHYVE_PORT_IBV_MODIFY_SRQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_srq + */ + +typedef struct { + // Parameters: + struct ibv_srq * srq; + struct ibv_srq_attr * srq_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_query_srq_t; + +int ibv_query_srq(struct ibv_srq * srq, struct ibv_srq_attr * srq_attr) { + uhyve_ibv_query_srq_t uhyve_args; + uhyve_args.srq = srq; + uhyve_args.srq_attr = srq_attr; + + uhyve_send(UHYVE_PORT_IBV_QUERY_SRQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_get_srq_num + */ + +typedef struct { + // Parameters: + struct ibv_srq * srq; + uint32_t * srq_num; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_get_srq_num_t; + +int ibv_get_srq_num(struct ibv_srq * srq, uint32_t * srq_num) { + uhyve_ibv_get_srq_num_t uhyve_args; + uhyve_args.srq = srq; + uhyve_args.srq_num = srq_num; + + uhyve_send(UHYVE_PORT_IBV_GET_SRQ_NUM, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_srq + */ + +typedef struct { + // Parameters: + struct ibv_srq * srq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_srq_t; + +int ibv_destroy_srq(struct ibv_srq * srq) { + uhyve_ibv_destroy_srq_t uhyve_args; + uhyve_args.srq = srq; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_SRQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_post_srq_recv + */ + +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; + +int ibv_post_srq_recv(struct ibv_srq * srq, struct ibv_recv_wr * recv_wr, struct ibv_recv_wr ** bad_recv_wr) { + uhyve_ibv_post_srq_recv_t uhyve_args; + uhyve_args.srq = srq; + uhyve_args.recv_wr = recv_wr; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_POST_SRQ_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_qp + */ + +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; + +struct ibv_qp * ibv_create_qp(struct ibv_pd * pd, struct ibv_qp_init_attr * qp_init_attr) { + uhyve_ibv_create_qp_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.qp_init_attr = qp_init_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_qp_ex + */ + +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; + +struct ibv_qp * ibv_create_qp_ex(struct ibv_context * context, struct ibv_qp_init_attr_ex * qp_init_attr_ex) { + uhyve_ibv_create_qp_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.qp_init_attr_ex = qp_init_attr_ex; + + uhyve_send(UHYVE_PORT_IBV_CREATE_QP_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_rt_values_ex + */ + +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; + +int ibv_query_rt_values_ex(struct ibv_context * context, struct ibv_values_ex * values) { + uhyve_ibv_query_rt_values_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.values = values; + + uhyve_send(UHYVE_PORT_IBV_QUERY_RT_VALUES_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_device_ex + */ + +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; + +int ibv_query_device_ex(struct ibv_context * context, const struct ibv_query_device_ex_input * input, struct ibv_device_attr_ex * attr) { + uhyve_ibv_query_device_ex_t uhyve_args; + uhyve_args.context = context; + uhyve_args.input = input; + uhyve_args.attr = attr; + + uhyve_send(UHYVE_PORT_IBV_QUERY_DEVICE_EX, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_open_qp + */ + +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; + +struct ibv_qp * ibv_open_qp(struct ibv_context * context, struct ibv_qp_open_attr * qp_open_attr) { + uhyve_ibv_open_qp_t uhyve_args; + uhyve_args.context = context; + uhyve_args.qp_open_attr = qp_open_attr; + + uhyve_send(UHYVE_PORT_IBV_OPEN_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_modify_qp + */ + +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; + +int ibv_modify_qp(struct ibv_qp * qp, struct ibv_qp_attr * attr, int attr_mask) { + uhyve_ibv_modify_qp_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.attr = attr; + uhyve_args.attr_mask = attr_mask; + + uhyve_send(UHYVE_PORT_IBV_MODIFY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_query_qp + */ + +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; + +int ibv_query_qp(struct ibv_qp * qp, struct ibv_qp_attr * attr, int attr_mask, struct ibv_qp_init_attr * init_attr) { + uhyve_ibv_query_qp_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.attr = attr; + uhyve_args.attr_mask = attr_mask; + uhyve_args.init_attr = init_attr; + + uhyve_send(UHYVE_PORT_IBV_QUERY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_qp + */ + +typedef struct { + // Parameters: + struct ibv_qp * qp; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_qp_t; + +int ibv_destroy_qp(struct ibv_qp * qp) { + uhyve_ibv_destroy_qp_t uhyve_args; + uhyve_args.qp = qp; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_wq + */ + +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; + +struct ibv_wq * ibv_create_wq(struct ibv_context * context, struct ibv_wq_init_attr * wq_init_attr) { + uhyve_ibv_create_wq_t uhyve_args; + uhyve_args.context = context; + uhyve_args.wq_init_attr = wq_init_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_WQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_modify_wq + */ + +typedef struct { + // Parameters: + struct ibv_wq * wq; + struct ibv_wq_attr * wq_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_modify_wq_t; + +int ibv_modify_wq(struct ibv_wq * wq, struct ibv_wq_attr * wq_attr) { + uhyve_ibv_modify_wq_t uhyve_args; + uhyve_args.wq = wq; + uhyve_args.wq_attr = wq_attr; + + uhyve_send(UHYVE_PORT_IBV_MODIFY_WQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_wq + */ + +typedef struct { + // Parameters: + struct ibv_wq * wq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_wq_t; + +int ibv_destroy_wq(struct ibv_wq * wq) { + uhyve_ibv_destroy_wq_t uhyve_args; + uhyve_args.wq = wq; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_WQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_rwq_ind_table + */ + +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; + +struct ibv_rwq_ind_table * ibv_create_rwq_ind_table(struct ibv_context * context, struct ibv_rwq_ind_table_init_attr * init_attr) { + uhyve_ibv_create_rwq_ind_table_t uhyve_args; + uhyve_args.context = context; + uhyve_args.init_attr = init_attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_rwq_ind_table + */ + +typedef struct { + // Parameters: + struct ibv_rwq_ind_table * rwq_ind_table; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_rwq_ind_table_t; + +int ibv_destroy_rwq_ind_table(struct ibv_rwq_ind_table * rwq_ind_table) { + uhyve_ibv_destroy_rwq_ind_table_t uhyve_args; + uhyve_args.rwq_ind_table = rwq_ind_table; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_post_send + */ + +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; + +int ibv_post_send(struct ibv_qp * qp, struct ibv_send_wr * wr, struct ibv_send_wr ** bad_wr) { + uhyve_ibv_post_send_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.wr = wr; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_POST_SEND, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_post_recv + */ + +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; + +int ibv_post_recv(struct ibv_qp * qp, struct ibv_recv_wr * wr, struct ibv_recv_wr ** bad_wr) { + uhyve_ibv_post_recv_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.wr = wr; + // TODO: Take care of ** parameter. + + uhyve_send(UHYVE_PORT_IBV_POST_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_ah + */ + +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; + +struct ibv_ah * ibv_create_ah(struct ibv_pd * pd, struct ibv_ah_attr * attr) { + uhyve_ibv_create_ah_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.attr = attr; + + uhyve_send(UHYVE_PORT_IBV_CREATE_AH, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_init_ah_from_wc + */ + +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; + +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) { + uhyve_ibv_init_ah_from_wc_t uhyve_args; + uhyve_args.context = context; + uhyve_args.port_num = port_num; + uhyve_args.wc = wc; + uhyve_args.grh = grh; + uhyve_args.ah_attr = ah_attr; + + uhyve_send(UHYVE_PORT_IBV_INIT_AH_FROM_WC, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_create_ah_from_wc + */ + +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; + +struct ibv_ah * ibv_create_ah_from_wc(struct ibv_pd * pd, struct ibv_wc * wc, struct ibv_grh * grh, uint8_t port_num) { + uhyve_ibv_create_ah_from_wc_t uhyve_args; + uhyve_args.pd = pd; + uhyve_args.wc = wc; + uhyve_args.grh = grh; + uhyve_args.port_num = port_num; + + uhyve_send(UHYVE_PORT_IBV_CREATE_AH_FROM_WC, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_destroy_ah + */ + +typedef struct { + // Parameters: + struct ibv_ah * ah; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_ah_t; + +int ibv_destroy_ah(struct ibv_ah * ah) { + uhyve_ibv_destroy_ah_t uhyve_args; + uhyve_args.ah = ah; + + uhyve_send(UHYVE_PORT_IBV_DESTROY_AH, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_attach_mcast + */ + +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; + +int ibv_attach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid) { + uhyve_ibv_attach_mcast_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.gid = gid; + uhyve_args.lid = lid; + + uhyve_send(UHYVE_PORT_IBV_ATTACH_MCAST, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_detach_mcast + */ + +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; + +int ibv_detach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid) { + uhyve_ibv_detach_mcast_t uhyve_args; + uhyve_args.qp = qp; + uhyve_args.gid = gid; + uhyve_args.lid = lid; + + uhyve_send(UHYVE_PORT_IBV_DETACH_MCAST, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_fork_init + */ + +typedef struct { + // Parameters: + ; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_fork_init_t; + +int ibv_fork_init( ) { + uhyve_ibv_fork_init_t uhyve_args; + uhyve_args. = ; + + uhyve_send(UHYVE_PORT_IBV_FORK_INIT, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_node_type_str + */ + +typedef struct { + // Parameters: + enum ibv_node_type node_type; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_node_type_str_t; + +const char * ibv_node_type_str(enum ibv_node_type node_type) { + uhyve_ibv_node_type_str_t uhyve_args; + uhyve_args.node_type = node_type; + + uhyve_send(UHYVE_PORT_IBV_NODE_TYPE_STR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_port_state_str + */ + +typedef struct { + // Parameters: + enum ibv_port_state port_state; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_port_state_str_t; + +const char * ibv_port_state_str(enum ibv_port_state port_state) { + uhyve_ibv_port_state_str_t uhyve_args; + uhyve_args.port_state = port_state; + + uhyve_send(UHYVE_PORT_IBV_PORT_STATE_STR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_event_type_str + */ + +typedef struct { + // Parameters: + enum ibv_event_type event; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_event_type_str_t; + +const char * ibv_event_type_str(enum ibv_event_type event) { + uhyve_ibv_event_type_str_t uhyve_args; + uhyve_args.event = event; + + uhyve_send(UHYVE_PORT_IBV_EVENT_TYPE_STR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_resolve_eth_l2_from_gid + */ + +typedef struct { + // Parameters: + struct ibv_context * context; + struct ibv_ah_attr * attr; + uint8_t [6] eth_mac; + uint16_t * vid; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_resolve_eth_l2_from_gid_t; + +int ibv_resolve_eth_l2_from_gid(struct ibv_context * context, struct ibv_ah_attr * attr, uint8_t [6] eth_mac, uint16_t * vid) { + uhyve_ibv_resolve_eth_l2_from_gid_t uhyve_args; + uhyve_args.context = context; + uhyve_args.attr = attr; + uhyve_args.eth_mac = eth_mac; + uhyve_args.vid = vid; + + uhyve_send(UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + +/* + * ibv_is_qpt_supported + */ + +typedef struct { + // Parameters: + uint32_t caps; + enum ibv_qp_type qpt; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_is_qpt_supported_t; + +int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt) { + uhyve_ibv_is_qpt_supported_t uhyve_args; + uhyve_args.caps = caps; + uhyve_args.qpt = qpt; + + uhyve_send(UHYVE_PORT_IBV_IS_QPT_SUPPORTED, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + return uhyve_args.ret; +} + + diff --git a/tools/ibv_code_generator/GEN-tools-uhyve-ibv-ports.h b/tools/ibv_code_generator/GEN-tools-uhyve-ibv-ports.h index 0ac2d4c23..422ff7974 100644 --- a/tools/ibv_code_generator/GEN-tools-uhyve-ibv-ports.h +++ b/tools/ibv_code_generator/GEN-tools-uhyve-ibv-ports.h @@ -1,6 +1,935 @@ 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; \ No newline at end of file + UHYVE_PORT_SET_IB_POOL_ADDR = 0x60F, + UHYVE_PORT_IBV_WC_STATUS_STR = 0x610, + UHYVE_PORT_IBV_RATE_TO_MULT = 0x611, + UHYVE_PORT_MULT_TO_IBV_RATE = 0x612, + UHYVE_PORT_IBV_RATE_TO_MBPS = 0x613, + UHYVE_PORT_MBPS_TO_IBV_RATE = 0x614, + UHYVE_PORT_IBV_CQ_EX_TO_CQ = 0x615, + UHYVE_PORT_IBV_START_POLL = 0x616, + UHYVE_PORT_IBV_NEXT_POLL = 0x617, + UHYVE_PORT_IBV_END_POLL = 0x618, + UHYVE_PORT_IBV_WC_READ_OPCODE = 0x619, + UHYVE_PORT_IBV_WC_READ_VENDOR_ERR = 0x61A, + UHYVE_PORT_IBV_WC_READ_BYTE_LEN = 0x61B, + UHYVE_PORT_IBV_WC_READ_IMM_DATA = 0x61C, + UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY = 0x61D, + UHYVE_PORT_IBV_WC_READ_QP_NUM = 0x61E, + UHYVE_PORT_IBV_WC_READ_SRC_QP = 0x61F, + UHYVE_PORT_IBV_WC_READ_WC_FLAGS = 0x620, + UHYVE_PORT_IBV_WC_READ_SLID = 0x621, + UHYVE_PORT_IBV_WC_READ_SL = 0x622, + UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS = 0x623, + UHYVE_PORT_IBV_WC_READ_COMPLETION_TS = 0x624, + UHYVE_PORT_IBV_WC_READ_CVLAN = 0x625, + UHYVE_PORT_IBV_WC_READ_FLOW_TAG = 0x626, + UHYVE_PORT_IBV_POST_WQ_RECV = 0x627, + UHYVE_PORT_VERBS_GET_CTX = 0x628, + UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x629, + UHYVE_PORT_IBV_FREE_DEVICE_LIST = 0x62A, + UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x62B, + UHYVE_PORT_IBV_GET_DEVICE_GUID = 0x62C, + UHYVE_PORT_IBV_OPEN_DEVICE = 0x62D, + UHYVE_PORT_IBV_CLOSE_DEVICE = 0x62E, + UHYVE_PORT_IBV_GET_ASYNC_EVENT = 0x62F, + UHYVE_PORT_IBV_ACK_ASYNC_EVENT = 0x630, + UHYVE_PORT_IBV_QUERY_DEVICE = 0x631, + UHYVE_PORT_IBV_QUERY_PORT = 0x632, + UHYVE_PORT____IBV_QUERY_PORT = 0x633, + UHYVE_PORT_IBV_QUERY_GID = 0x634, + UHYVE_PORT_IBV_QUERY_PKEY = 0x635, + UHYVE_PORT_IBV_ALLOC_PD = 0x636, + UHYVE_PORT_IBV_DEALLOC_PD = 0x637, + UHYVE_PORT_IBV_CREATE_FLOW = 0x638, + UHYVE_PORT_IBV_DESTROY_FLOW = 0x639, + UHYVE_PORT_IBV_OPEN_XRCD = 0x63A, + UHYVE_PORT_IBV_CLOSE_XRCD = 0x63B, + UHYVE_PORT_IBV_REG_MR = 0x63C, + UHYVE_PORT_IBV_REREG_MR = 0x63D, + UHYVE_PORT_IBV_DEREG_MR = 0x63E, + UHYVE_PORT_IBV_ALLOC_MW = 0x63F, + UHYVE_PORT_IBV_DEALLOC_MW = 0x640, + UHYVE_PORT_IBV_INC_RKEY = 0x641, + UHYVE_PORT_IBV_BIND_MW = 0x642, + UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x643, + UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x644, + UHYVE_PORT_IBV_CREATE_CQ = 0x645, + UHYVE_PORT_IBV_CREATE_CQ_EX = 0x646, + UHYVE_PORT_IBV_RESIZE_CQ = 0x647, + UHYVE_PORT_IBV_DESTROY_CQ = 0x648, + UHYVE_PORT_IBV_GET_CQ_EVENT = 0x649, + UHYVE_PORT_IBV_ACK_CQ_EVENTS = 0x64A, + UHYVE_PORT_IBV_POLL_CQ = 0x64B, + UHYVE_PORT_IBV_REQ_NOTIFY_CQ = 0x64C, + UHYVE_PORT_IBV_CREATE_SRQ = 0x64D, + UHYVE_PORT_IBV_CREATE_SRQ_EX = 0x64E, + UHYVE_PORT_IBV_MODIFY_SRQ = 0x64F, + UHYVE_PORT_IBV_QUERY_SRQ = 0x650, + UHYVE_PORT_IBV_GET_SRQ_NUM = 0x651, + UHYVE_PORT_IBV_DESTROY_SRQ = 0x652, + UHYVE_PORT_IBV_POST_SRQ_RECV = 0x653, + UHYVE_PORT_IBV_CREATE_QP = 0x654, + UHYVE_PORT_IBV_CREATE_QP_EX = 0x655, + UHYVE_PORT_IBV_QUERY_RT_VALUES_EX = 0x656, + UHYVE_PORT_IBV_QUERY_DEVICE_EX = 0x657, + UHYVE_PORT_IBV_OPEN_QP = 0x658, + UHYVE_PORT_IBV_MODIFY_QP = 0x659, + UHYVE_PORT_IBV_QUERY_QP = 0x65A, + UHYVE_PORT_IBV_DESTROY_QP = 0x65B, + UHYVE_PORT_IBV_CREATE_WQ = 0x65C, + UHYVE_PORT_IBV_MODIFY_WQ = 0x65D, + UHYVE_PORT_IBV_DESTROY_WQ = 0x65E, + UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE = 0x65F, + UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE = 0x660, + UHYVE_PORT_IBV_POST_SEND = 0x661, + UHYVE_PORT_IBV_POST_RECV = 0x662, + UHYVE_PORT_IBV_CREATE_AH = 0x663, + UHYVE_PORT_IBV_INIT_AH_FROM_WC = 0x664, + UHYVE_PORT_IBV_CREATE_AH_FROM_WC = 0x665, + UHYVE_PORT_IBV_DESTROY_AH = 0x666, + UHYVE_PORT_IBV_ATTACH_MCAST = 0x667, + UHYVE_PORT_IBV_DETACH_MCAST = 0x668, + UHYVE_PORT_IBV_FORK_INIT = 0x669, + UHYVE_PORT_IBV_NODE_TYPE_STR = 0x66A, + UHYVE_PORT_IBV_PORT_STATE_STR = 0x66B, + UHYVE_PORT_IBV_EVENT_TYPE_STR = 0x66C, + UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID = 0x66D, + UHYVE_PORT_IBV_IS_QPT_SUPPORTED = 0x66E, +} 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_cq_ex * cq; + // Return value: + struct ibv_cq * ret; +} __attribute__((packed)) uhyve_ibv_cq_ex_to_cq_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + struct ibv_poll_cq_attr * attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_start_poll_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_next_poll_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; +} __attribute__((packed)) uhyve_ibv_end_poll_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + enum ibv_wc_opcode ret; +} __attribute__((packed)) uhyve_ibv_wc_read_opcode_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_vendor_err_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_byte_len_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + __be32 ret; +} __attribute__((packed)) uhyve_ibv_wc_read_imm_data_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_invalidated_rkey_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_qp_num_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_src_qp_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_wc_read_wc_flags_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_slid_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint8_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_sl_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint8_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_dlid_path_bits_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint64_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_completion_ts_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint16_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_cvlan_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_flow_tag_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 [6] eth_mac; + 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_cq_ex_to_cq(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_start_poll(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_next_poll(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_end_poll(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_opcode(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_vendor_err(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_byte_len(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_imm_data(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_invalidated_rkey(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_qp_num(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_src_qp(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_wc_flags(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_slid(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_sl(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_dlid_path_bits(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_completion_ts(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_cvlan(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_flow_tag(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); diff --git a/tools/ibv_code_generator/GEN-tools-uhyve-ibv.c b/tools/ibv_code_generator/GEN-tools-uhyve-ibv.c index e5ec8a6a4..9a707eef2 100644 --- a/tools/ibv_code_generator/GEN-tools-uhyve-ibv.c +++ b/tools/ibv_code_generator/GEN-tools-uhyve-ibv.c @@ -1,37 +1,1425 @@ -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); +/* + * ibv_wc_status_str + */ - 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. +void call_ibv_wc_status_str(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_wc_status_str(args->status); + use_ib_mem_pool = false; } + +/* + * ibv_rate_to_mult + */ + +void call_ibv_rate_to_mult(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_rate_to_mult(args->rate); + use_ib_mem_pool = false; +} + + +/* + * mult_to_ibv_rate + */ + +void call_mult_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = mult_to_ibv_rate(args->mult); + use_ib_mem_pool = false; +} + + +/* + * ibv_rate_to_mbps + */ + +void call_ibv_rate_to_mbps(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_rate_to_mbps(args->rate); + use_ib_mem_pool = false; +} + + +/* + * mbps_to_ibv_rate + */ + +void call_mbps_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = mbps_to_ibv_rate(args->mbps); + use_ib_mem_pool = false; +} + + +/* + * ibv_cq_ex_to_cq + */ + +void call_ibv_cq_ex_to_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_cq_ex_to_cq\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_cq_ex_to_cq_t * args = (uhyve_ibv_cq_ex_to_cq_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_cq_ex_to_cq(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_start_poll + */ + +void call_ibv_start_poll(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_start_poll\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_start_poll_t * args = (uhyve_ibv_start_poll_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_start_poll(args->cq, args->attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_next_poll + */ + +void call_ibv_next_poll(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_next_poll\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_next_poll_t * args = (uhyve_ibv_next_poll_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_next_poll(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_end_poll + */ + +void call_ibv_end_poll(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_end_poll\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_end_poll_t * args = (uhyve_ibv_end_poll_t *) (guest_mem + data); + + use_ib_mem_pool = true; + ibv_end_poll(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_opcode + */ + +void call_ibv_wc_read_opcode(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_opcode\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_opcode_t * args = (uhyve_ibv_wc_read_opcode_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_opcode(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_vendor_err + */ + +void call_ibv_wc_read_vendor_err(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_vendor_err\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_vendor_err_t * args = (uhyve_ibv_wc_read_vendor_err_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_vendor_err(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_byte_len + */ + +void call_ibv_wc_read_byte_len(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_byte_len\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_byte_len_t * args = (uhyve_ibv_wc_read_byte_len_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_byte_len(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_imm_data + */ + +void call_ibv_wc_read_imm_data(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_imm_data\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_imm_data_t * args = (uhyve_ibv_wc_read_imm_data_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_imm_data(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_invalidated_rkey + */ + +void call_ibv_wc_read_invalidated_rkey(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_invalidated_rkey\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_invalidated_rkey_t * args = (uhyve_ibv_wc_read_invalidated_rkey_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_invalidated_rkey(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_qp_num + */ + +void call_ibv_wc_read_qp_num(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_qp_num\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_qp_num_t * args = (uhyve_ibv_wc_read_qp_num_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_qp_num(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_src_qp + */ + +void call_ibv_wc_read_src_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_src_qp\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_src_qp_t * args = (uhyve_ibv_wc_read_src_qp_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_src_qp(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_wc_flags + */ + +void call_ibv_wc_read_wc_flags(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_wc_flags\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_wc_flags_t * args = (uhyve_ibv_wc_read_wc_flags_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_wc_flags(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_slid + */ + +void call_ibv_wc_read_slid(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_slid\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_slid_t * args = (uhyve_ibv_wc_read_slid_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_slid(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_sl + */ + +void call_ibv_wc_read_sl(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_sl\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_sl_t * args = (uhyve_ibv_wc_read_sl_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_sl(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_dlid_path_bits + */ + +void call_ibv_wc_read_dlid_path_bits(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_dlid_path_bits\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_dlid_path_bits_t * args = (uhyve_ibv_wc_read_dlid_path_bits_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_dlid_path_bits(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_completion_ts + */ + +void call_ibv_wc_read_completion_ts(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_completion_ts\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_completion_ts_t * args = (uhyve_ibv_wc_read_completion_ts_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_completion_ts(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_cvlan + */ + +void call_ibv_wc_read_cvlan(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_cvlan\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_cvlan_t * args = (uhyve_ibv_wc_read_cvlan_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_cvlan(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_flow_tag + */ + +void call_ibv_wc_read_flow_tag(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_flow_tag\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_flow_tag_t * args = (uhyve_ibv_wc_read_flow_tag_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_flow_tag(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_post_wq_recv + */ + +void call_ibv_post_wq_recv(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_post_wq_recv\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_post_wq_recv(args->wq, args->recv_wr, args->bad_recv_wr); + use_ib_mem_pool = false; +} + + +/* + * verbs_get_ctx + */ + +void call_verbs_get_ctx(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = verbs_get_ctx(args->ctx); + use_ib_mem_pool = false; +} + + +/* + * 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"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_get_device_list(args->num_devices); + use_ib_mem_pool = false; +} + + +/* + * ibv_free_device_list + */ + +void call_ibv_free_device_list(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + ibv_free_device_list(args->list); + use_ib_mem_pool = false; +} + + +/* + * ibv_get_device_name + */ + void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem) { - unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); + printf("LOG: UHYVE - 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); - 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. + use_ib_mem_pool = true; + args->ret = ibv_get_device_name(args->device); + use_ib_mem_pool = false; } + +/* + * ibv_get_device_guid + */ + +void call_ibv_get_device_guid(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_get_device_guid(args->device); + use_ib_mem_pool = false; +} + + +/* + * ibv_open_device + */ + +void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_open_device(args->device); + use_ib_mem_pool = false; +} + + +/* + * ibv_close_device + */ + +void call_ibv_close_device(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_close_device(args->context); + use_ib_mem_pool = false; +} + + +/* + * ibv_get_async_event + */ + +void call_ibv_get_async_event(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_get_async_event(args->context, args->event); + use_ib_mem_pool = false; +} + + +/* + * ibv_ack_async_event + */ + +void call_ibv_ack_async_event(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + ibv_ack_async_event(args->event); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_device + */ + +void call_ibv_query_device(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_device(args->context, args->device_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_port + */ + void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) { - unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); + printf("LOG: UHYVE - 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(guest_mem+(size_t)args->context, port_num, guest_mem+(size_t)args->port_attr); - args->ret = host_ret; + use_ib_mem_pool = true; + args->ret = ibv_query_port(args->context, args->port_num, args->port_attr); + use_ib_mem_pool = false; } + +/* + * ___ibv_query_port + */ + +void call____ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ___ibv_query_port(args->context, args->port_num, args->port_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_gid + */ + +void call_ibv_query_gid(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_gid(args->context, args->port_num, args->index, args->gid); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_pkey + */ + +void call_ibv_query_pkey(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_pkey(args->context, args->port_num, args->index, args->pkey); + use_ib_mem_pool = false; +} + + +/* + * ibv_alloc_pd + */ + +void call_ibv_alloc_pd(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_alloc_pd(args->context); + use_ib_mem_pool = false; +} + + +/* + * ibv_dealloc_pd + */ + +void call_ibv_dealloc_pd(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_dealloc_pd(args->pd); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_flow + */ + +void call_ibv_create_flow(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_flow(args->qp, args->flow); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_flow + */ + +void call_ibv_destroy_flow(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_flow(args->flow_id); + use_ib_mem_pool = false; +} + + +/* + * ibv_open_xrcd + */ + +void call_ibv_open_xrcd(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_open_xrcd(args->context, args->xrcd_init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_close_xrcd + */ + +void call_ibv_close_xrcd(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_close_xrcd(args->xrcd); + use_ib_mem_pool = false; +} + + +/* + * ibv_reg_mr + */ + +void call_ibv_reg_mr(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_reg_mr(args->pd, args->addr, args->length, args->access); + use_ib_mem_pool = false; +} + + +/* + * ibv_rereg_mr + */ + +void call_ibv_rereg_mr(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_rereg_mr(args->mr, args->flags, args->pd, args->addr, args->length, args->access); + use_ib_mem_pool = false; +} + + +/* + * ibv_dereg_mr + */ + +void call_ibv_dereg_mr(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_dereg_mr(args->mr); + use_ib_mem_pool = false; +} + + +/* + * ibv_alloc_mw + */ + +void call_ibv_alloc_mw(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_alloc_mw(args->pd, args->type); + use_ib_mem_pool = false; +} + + +/* + * ibv_dealloc_mw + */ + +void call_ibv_dealloc_mw(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_dealloc_mw(args->mw); + use_ib_mem_pool = false; +} + + +/* + * ibv_inc_rkey + */ + +void call_ibv_inc_rkey(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_inc_rkey(args->rkey); + use_ib_mem_pool = false; +} + + +/* + * ibv_bind_mw + */ + +void call_ibv_bind_mw(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_bind_mw(args->qp, args->mw, args->mw_bind); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_comp_channel + */ + void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem) { - unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); + printf("LOG: UHYVE - 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); - 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. + use_ib_mem_pool = true; + args->ret = ibv_create_comp_channel(args->context); + use_ib_mem_pool = false; } + + +/* + * ibv_destroy_comp_channel + */ + +void call_ibv_destroy_comp_channel(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_comp_channel(args->channel); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_cq + */ + +void call_ibv_create_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_cq(args->context, args->cqe, args->cq_context, args->channel, args->comp_vector); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_cq_ex + */ + +void call_ibv_create_cq_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_create_cq_ex\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_cq_ex(args->context, args->cq_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_resize_cq + */ + +void call_ibv_resize_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_resize_cq(args->cq, args->cqe); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_cq + */ + +void call_ibv_destroy_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_cq(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_get_cq_event + */ + +void call_ibv_get_cq_event(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_get_cq_event(args->channel, args->cq, args->cq_context); + use_ib_mem_pool = false; +} + + +/* + * ibv_ack_cq_events + */ + +void call_ibv_ack_cq_events(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + ibv_ack_cq_events(args->cq, args->nevents); + use_ib_mem_pool = false; +} + + +/* + * ibv_poll_cq + */ + +void call_ibv_poll_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_poll_cq(args->cq, args->num_entries, args->wc); + use_ib_mem_pool = false; +} + + +/* + * ibv_req_notify_cq + */ + +void call_ibv_req_notify_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_req_notify_cq(args->cq, args->solicited_only); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_srq + */ + +void call_ibv_create_srq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_srq(args->pd, args->srq_init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_srq_ex + */ + +void call_ibv_create_srq_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_srq_ex(args->context, args->srq_init_attr_ex); + use_ib_mem_pool = false; +} + + +/* + * ibv_modify_srq + */ + +void call_ibv_modify_srq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_modify_srq(args->srq, args->srq_attr, args->srq_attr_mask); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_srq + */ + +void call_ibv_query_srq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_srq(args->srq, args->srq_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_get_srq_num + */ + +void call_ibv_get_srq_num(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_get_srq_num(args->srq, args->srq_num); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_srq + */ + +void call_ibv_destroy_srq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_srq(args->srq); + use_ib_mem_pool = false; +} + + +/* + * ibv_post_srq_recv + */ + +void call_ibv_post_srq_recv(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_post_srq_recv(args->srq, args->recv_wr, args->bad_recv_wr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_qp + */ + +void call_ibv_create_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_qp(args->pd, args->qp_init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_qp_ex + */ + +void call_ibv_create_qp_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_qp_ex(args->context, args->qp_init_attr_ex); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_rt_values_ex + */ + +void call_ibv_query_rt_values_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_query_rt_values_ex\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_rt_values_ex(args->context, args->values); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_device_ex + */ + +void call_ibv_query_device_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_device_ex(args->context, args->input, args->attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_open_qp + */ + +void call_ibv_open_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_open_qp(args->context, args->qp_open_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_modify_qp + */ + +void call_ibv_modify_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_modify_qp(args->qp, args->attr, args->attr_mask); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_qp + */ + +void call_ibv_query_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_qp(args->qp, args->attr, args->attr_mask, args->init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_qp + */ + +void call_ibv_destroy_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_qp(args->qp); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_wq + */ + +void call_ibv_create_wq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_create_wq\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_create_wq_t * args = (uhyve_ibv_create_wq_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_create_wq(args->context, args->wq_init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_modify_wq + */ + +void call_ibv_modify_wq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_modify_wq\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_modify_wq_t * args = (uhyve_ibv_modify_wq_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_modify_wq(args->wq, args->wq_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_wq + */ + +void call_ibv_destroy_wq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_destroy_wq\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_destroy_wq_t * args = (uhyve_ibv_destroy_wq_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_wq(args->wq); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_rwq_ind_table + */ + +void call_ibv_create_rwq_ind_table(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_create_rwq_ind_table\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_rwq_ind_table(args->context, args->init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_rwq_ind_table + */ + +void call_ibv_destroy_rwq_ind_table(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_destroy_rwq_ind_table\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_rwq_ind_table(args->rwq_ind_table); + use_ib_mem_pool = false; +} + + +/* + * ibv_post_send + */ + +void call_ibv_post_send(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_post_send(args->qp, args->wr, args->bad_wr); + use_ib_mem_pool = false; +} + + +/* + * ibv_post_recv + */ + +void call_ibv_post_recv(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_post_recv(args->qp, args->wr, args->bad_wr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_ah + */ + +void call_ibv_create_ah(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_ah(args->pd, args->attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_init_ah_from_wc + */ + +void call_ibv_init_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_init_ah_from_wc(args->context, args->port_num, args->wc, args->grh, args->ah_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_ah_from_wc + */ + +void call_ibv_create_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_ah_from_wc(args->pd, args->wc, args->grh, args->port_num); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_ah + */ + +void call_ibv_destroy_ah(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_ah(args->ah); + use_ib_mem_pool = false; +} + + +/* + * ibv_attach_mcast + */ + +void call_ibv_attach_mcast(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_attach_mcast(args->qp, args->gid, args->lid); + use_ib_mem_pool = false; +} + + +/* + * ibv_detach_mcast + */ + +void call_ibv_detach_mcast(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_detach_mcast(args->qp, args->gid, args->lid); + use_ib_mem_pool = false; +} + + +/* + * ibv_fork_init + */ + +void call_ibv_fork_init(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_fork_init(args->); + use_ib_mem_pool = false; +} + + +/* + * ibv_node_type_str + */ + +void call_ibv_node_type_str(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_node_type_str(args->node_type); + use_ib_mem_pool = false; +} + + +/* + * ibv_port_state_str + */ + +void call_ibv_port_state_str(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_port_state_str(args->port_state); + use_ib_mem_pool = false; +} + + +/* + * ibv_event_type_str + */ + +void call_ibv_event_type_str(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_event_type_str(args->event); + use_ib_mem_pool = false; +} + + +/* + * ibv_resolve_eth_l2_from_gid + */ + +void call_ibv_resolve_eth_l2_from_gid(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_resolve_eth_l2_from_gid\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_resolve_eth_l2_from_gid(args->context, args->attr, args->eth_mac, args->vid); + use_ib_mem_pool = false; +} + + +/* + * ibv_is_qpt_supported + */ + +void call_ibv_is_qpt_supported(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_is_qpt_supported(args->caps, args->qpt); + use_ib_mem_pool = false; +} + + diff --git a/tools/ibv_code_generator/GEN-tools-uhyve.c b/tools/ibv_code_generator/GEN-tools-uhyve.c index 845868592..ad93fb2e1 100644 --- a/tools/ibv_code_generator/GEN-tools-uhyve.c +++ b/tools/ibv_code_generator/GEN-tools-uhyve.c @@ -1,12 +1,293 @@ - case UHYVE_PORT_IBV_OPEN_DEVICE: - call_ibv_open_device(run, guest_mem); + case UHYVE_PORT_SET_IB_POOL_ADDR: { + unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); + uint64_t * temp = (uint64_t*)(guest_mem + data); + ib_pool_addr = (uint8_t*) *temp; + ib_pool_top = ib_pool_addr; + break; + } + + 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_CQ_EX_TO_CQ: + call_ibv_cq_ex_to_cq(run, guest_mem); + break; + case UHYVE_PORT_IBV_START_POLL: + call_ibv_start_poll(run, guest_mem); + break; + case UHYVE_PORT_IBV_NEXT_POLL: + call_ibv_next_poll(run, guest_mem); + break; + case UHYVE_PORT_IBV_END_POLL: + call_ibv_end_poll(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_OPCODE: + call_ibv_wc_read_opcode(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_VENDOR_ERR: + call_ibv_wc_read_vendor_err(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_BYTE_LEN: + call_ibv_wc_read_byte_len(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_IMM_DATA: + call_ibv_wc_read_imm_data(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY: + call_ibv_wc_read_invalidated_rkey(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_QP_NUM: + call_ibv_wc_read_qp_num(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_SRC_QP: + call_ibv_wc_read_src_qp(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_WC_FLAGS: + call_ibv_wc_read_wc_flags(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_SLID: + call_ibv_wc_read_slid(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_SL: + call_ibv_wc_read_sl(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS: + call_ibv_wc_read_dlid_path_bits(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_COMPLETION_TS: + call_ibv_wc_read_completion_ts(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_CVLAN: + call_ibv_wc_read_cvlan(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_FLOW_TAG: + call_ibv_wc_read_flow_tag(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; diff --git a/tools/ibv_code_generator/generate-code.py b/tools/ibv_code_generator/generate-code.py index 9add6f23e..a4e9a3a70 100755 --- a/tools/ibv_code_generator/generate-code.py +++ b/tools/ibv_code_generator/generate-code.py @@ -1,5 +1,4 @@ #!/usr/bin/env python - """Copyright (c) 2017, Annika Wierichs, RWTH Aachen University All rights reserved. @@ -92,19 +91,20 @@ 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" # Starting number of the sequence used for IBV ports. -PORT_NUMBER_START = 0x510 +PORT_NUMBER_START = 0x610 TABS = ["", "\t", "\t\t", "\t\t\t", "\t\t\t\t"] NEWLINES = ["", "\n", "\n\n"] @@ -112,8 +112,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 +131,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 +149,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 +166,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 +181,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,232 +232,126 @@ 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: - # ( , [...]) - - # 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 + # case UHYVE_PORT_SET_IB_POOL_ADDR: + # printf("LOG: UHYVE CASE\n"); + # unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); + # uint64_t * temp = (uint64_t*)(guest_mem + data); + # /* printf("LOG: Value of uint64 pool start: %" PRIu64 "\n", *temp); */ + # printf("LOG: Value of uint64 pool start: %p\n", *temp); + # ib_pool_addr = (uint8_t*) *temp; + # /* printf("LOG: Value of uint8 pool start: %" PRIu8 "\n", ib_pool_addr); */ + # printf("LOG: Value of uint8 pool start: %p\n", ib_pool_addr); + # ib_pool_top = ib_pool_addr; + # break; -# TODO: done def generate_uhyve_cases(function_prototypes): """ Generates all switch-cases for uhyve's KVM exit IO. Returns: Generated switch-cases [string] """ - code = "" + code = "\t\t\tcase UHYVE_PORT_SET_IB_POOL_ADDR: {\n" + code += "\t\t\t\t\tunsigned data = *((unsigned*)((size_t)run+run->io.data_offset));\n" + code += "\t\t\t\t\tuint64_t * temp = (uint64_t*)(guest_mem + data);\n" + code += "\t\t\t\t\tib_pool_addr = (uint8_t*) *temp;\n" + code += "\t\t\t\t\tib_pool_top = ib_pool_addr;\n" + code += "\t\t\t\t\tbreak;\n" + code += "\t\t\t}\n\n" 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 + +def generate_uhyve_function(prototype): + args_struct_name = prototype.get_args_struct_name() + fnc_name = prototype.function_name + ret_type = prototype.ret + + code = generate_pretty_comment(fnc_name) + code += "void call_{0}(struct kvm_run * run, uint8_t * guest_mem) {{\n".format(fnc_name) + code += "\tprintf(\"LOG: UHYVE - call_{0}\\n\");\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) + + code += "\tuse_ib_mem_pool = true;\n" + code += ("\t" + ("args->ret = " if not ret_type.is_void() else "") + + "{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 += "\tuse_ib_mem_pool = false;\n}\n\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" + code += "\tUHYVE_PORT_SET_IB_POOL_ADDR = 0x{0},\n".format(format(PORT_NUMBER_START-1, "X")) + 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 +360,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 = "#define UHYVE_PORT_SET_IB_POOL_ADDR 0x{0}\n".format(format(PORT_NUMBER_START-1, "X")) + 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") diff --git a/tools/uhyve-ibv.c b/tools/uhyve-ibv.c index d54731ded..7ab737faa 100644 --- a/tools/uhyve-ibv.c +++ b/tools/uhyve-ibv.c @@ -32,6 +32,380 @@ #include // Linux include +/* + * ibv_wc_status_str + */ + +void call_ibv_wc_status_str(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_wc_status_str(args->status); + use_ib_mem_pool = false; +} + + +/* + * ibv_rate_to_mult + */ + +void call_ibv_rate_to_mult(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_rate_to_mult(args->rate); + use_ib_mem_pool = false; +} + + +/* + * mult_to_ibv_rate + */ + +void call_mult_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = mult_to_ibv_rate(args->mult); + use_ib_mem_pool = false; +} + + +/* + * ibv_rate_to_mbps + */ + +void call_ibv_rate_to_mbps(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_rate_to_mbps(args->rate); + use_ib_mem_pool = false; +} + + +/* + * mbps_to_ibv_rate + */ + +void call_mbps_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = mbps_to_ibv_rate(args->mbps); + use_ib_mem_pool = false; +} + + +/* + * ibv_cq_ex_to_cq + */ + +void call_ibv_cq_ex_to_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_cq_ex_to_cq\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_cq_ex_to_cq_t * args = (uhyve_ibv_cq_ex_to_cq_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_cq_ex_to_cq(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_start_poll + */ + +void call_ibv_start_poll(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_start_poll\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_start_poll_t * args = (uhyve_ibv_start_poll_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_start_poll(args->cq, args->attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_next_poll + */ + +void call_ibv_next_poll(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_next_poll\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_next_poll_t * args = (uhyve_ibv_next_poll_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_next_poll(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_end_poll + */ + +void call_ibv_end_poll(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_end_poll\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_end_poll_t * args = (uhyve_ibv_end_poll_t *) (guest_mem + data); + + use_ib_mem_pool = true; + ibv_end_poll(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_opcode + */ + +void call_ibv_wc_read_opcode(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_opcode\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_opcode_t * args = (uhyve_ibv_wc_read_opcode_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_opcode(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_vendor_err + */ + +void call_ibv_wc_read_vendor_err(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_vendor_err\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_vendor_err_t * args = (uhyve_ibv_wc_read_vendor_err_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_vendor_err(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_byte_len + */ + +void call_ibv_wc_read_byte_len(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_byte_len\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_byte_len_t * args = (uhyve_ibv_wc_read_byte_len_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_byte_len(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_imm_data + */ + +void call_ibv_wc_read_imm_data(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_imm_data\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_imm_data_t * args = (uhyve_ibv_wc_read_imm_data_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_imm_data(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_invalidated_rkey + */ + +void call_ibv_wc_read_invalidated_rkey(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_invalidated_rkey\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_invalidated_rkey_t * args = (uhyve_ibv_wc_read_invalidated_rkey_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_invalidated_rkey(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_qp_num + */ + +void call_ibv_wc_read_qp_num(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_qp_num\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_qp_num_t * args = (uhyve_ibv_wc_read_qp_num_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_qp_num(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_src_qp + */ + +void call_ibv_wc_read_src_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_src_qp\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_src_qp_t * args = (uhyve_ibv_wc_read_src_qp_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_src_qp(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_wc_flags + */ + +void call_ibv_wc_read_wc_flags(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_wc_flags\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_wc_flags_t * args = (uhyve_ibv_wc_read_wc_flags_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_wc_flags(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_slid + */ + +void call_ibv_wc_read_slid(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_slid\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_slid_t * args = (uhyve_ibv_wc_read_slid_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_slid(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_sl + */ + +void call_ibv_wc_read_sl(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_sl\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_sl_t * args = (uhyve_ibv_wc_read_sl_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_sl(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_dlid_path_bits + */ + +void call_ibv_wc_read_dlid_path_bits(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_dlid_path_bits\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_dlid_path_bits_t * args = (uhyve_ibv_wc_read_dlid_path_bits_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_dlid_path_bits(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_completion_ts + */ + +void call_ibv_wc_read_completion_ts(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_completion_ts\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_completion_ts_t * args = (uhyve_ibv_wc_read_completion_ts_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_completion_ts(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_cvlan + */ + +void call_ibv_wc_read_cvlan(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_cvlan\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_cvlan_t * args = (uhyve_ibv_wc_read_cvlan_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_cvlan(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_wc_read_flow_tag + */ + +void call_ibv_wc_read_flow_tag(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_wc_read_flow_tag\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_wc_read_flow_tag_t * args = (uhyve_ibv_wc_read_flow_tag_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_wc_read_flow_tag(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_post_wq_recv + */ + +void call_ibv_post_wq_recv(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_post_wq_recv\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_post_wq_recv(args->wq, args->recv_wr, args->bad_recv_wr); + use_ib_mem_pool = false; +} + + +/* + * verbs_get_ctx + */ + +void call_verbs_get_ctx(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = verbs_get_ctx(args->ctx); + use_ib_mem_pool = false; +} + /* * ibv_get_device_list @@ -39,7 +413,7 @@ void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem) { printf("LOG: UHYVE - call_ibv_get_device_list\n"); - unsigned data = *((unsigned *)((size_t)run+run->io.data_offset)); + 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); use_ib_mem_pool = true; @@ -48,13 +422,28 @@ void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem) { } +/* + * ibv_free_device_list + */ + +void call_ibv_free_device_list(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + ibv_free_device_list(args->list); + use_ib_mem_pool = false; +} + + /* * ibv_get_device_name */ 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)); + 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); use_ib_mem_pool = true; @@ -63,13 +452,28 @@ void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem) { } +/* + * ibv_get_device_guid + */ + +void call_ibv_get_device_guid(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_get_device_guid(args->device); + use_ib_mem_pool = false; +} + + /* * ibv_open_device */ void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) { printf("LOG: UHYVE - call_ibv_open_device\n"); - unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); uhyve_ibv_open_device_t * args = (uhyve_ibv_open_device_t *) (guest_mem + data); use_ib_mem_pool = true; @@ -78,13 +482,73 @@ void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) { } +/* + * ibv_close_device + */ + +void call_ibv_close_device(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_close_device(args->context); + use_ib_mem_pool = false; +} + + +/* + * ibv_get_async_event + */ + +void call_ibv_get_async_event(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_get_async_event(args->context, args->event); + use_ib_mem_pool = false; +} + + +/* + * ibv_ack_async_event + */ + +void call_ibv_ack_async_event(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + ibv_ack_async_event(args->event); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_device + */ + +void call_ibv_query_device(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_device(args->context, args->device_attr); + use_ib_mem_pool = false; +} + + /* * ibv_query_port */ 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("LOG: UHYVE - 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); use_ib_mem_pool = true; @@ -93,13 +557,253 @@ void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) { } +/* + * ___ibv_query_port + */ + +void call____ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ___ibv_query_port(args->context, args->port_num, args->port_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_gid + */ + +void call_ibv_query_gid(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_gid(args->context, args->port_num, args->index, args->gid); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_pkey + */ + +void call_ibv_query_pkey(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_pkey(args->context, args->port_num, args->index, args->pkey); + use_ib_mem_pool = false; +} + + +/* + * ibv_alloc_pd + */ + +void call_ibv_alloc_pd(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_alloc_pd(args->context); + use_ib_mem_pool = false; +} + + +/* + * ibv_dealloc_pd + */ + +void call_ibv_dealloc_pd(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_dealloc_pd(args->pd); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_flow + */ + +void call_ibv_create_flow(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_flow(args->qp, args->flow); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_flow + */ + +void call_ibv_destroy_flow(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_flow(args->flow_id); + use_ib_mem_pool = false; +} + + +/* + * ibv_open_xrcd + */ + +void call_ibv_open_xrcd(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_open_xrcd(args->context, args->xrcd_init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_close_xrcd + */ + +void call_ibv_close_xrcd(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_close_xrcd(args->xrcd); + use_ib_mem_pool = false; +} + + +/* + * ibv_reg_mr + */ + +void call_ibv_reg_mr(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_reg_mr(args->pd, args->addr, args->length, args->access); + use_ib_mem_pool = false; +} + + +/* + * ibv_rereg_mr + */ + +void call_ibv_rereg_mr(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_rereg_mr(args->mr, args->flags, args->pd, args->addr, args->length, args->access); + use_ib_mem_pool = false; +} + + +/* + * ibv_dereg_mr + */ + +void call_ibv_dereg_mr(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_dereg_mr(args->mr); + use_ib_mem_pool = false; +} + + +/* + * ibv_alloc_mw + */ + +void call_ibv_alloc_mw(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_alloc_mw(args->pd, args->type); + use_ib_mem_pool = false; +} + + +/* + * ibv_dealloc_mw + */ + +void call_ibv_dealloc_mw(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_dealloc_mw(args->mw); + use_ib_mem_pool = false; +} + + +/* + * ibv_inc_rkey + */ + +void call_ibv_inc_rkey(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_inc_rkey(args->rkey); + use_ib_mem_pool = false; +} + + +/* + * ibv_bind_mw + */ + +void call_ibv_bind_mw(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_bind_mw(args->qp, args->mw, args->mw_bind); + use_ib_mem_pool = false; +} + + /* * ibv_create_comp_channel */ 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("LOG: UHYVE - 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); use_ib_mem_pool = true; @@ -108,3 +812,646 @@ void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem) { } +/* + * ibv_destroy_comp_channel + */ + +void call_ibv_destroy_comp_channel(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_comp_channel(args->channel); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_cq + */ + +void call_ibv_create_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_cq(args->context, args->cqe, args->cq_context, args->channel, args->comp_vector); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_cq_ex + */ + +void call_ibv_create_cq_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_create_cq_ex\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_cq_ex(args->context, args->cq_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_resize_cq + */ + +void call_ibv_resize_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_resize_cq(args->cq, args->cqe); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_cq + */ + +void call_ibv_destroy_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_cq(args->cq); + use_ib_mem_pool = false; +} + + +/* + * ibv_get_cq_event + */ + +void call_ibv_get_cq_event(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_get_cq_event(args->channel, args->cq, args->cq_context); + use_ib_mem_pool = false; +} + + +/* + * ibv_ack_cq_events + */ + +void call_ibv_ack_cq_events(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + ibv_ack_cq_events(args->cq, args->nevents); + use_ib_mem_pool = false; +} + + +/* + * ibv_poll_cq + */ + +void call_ibv_poll_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_poll_cq(args->cq, args->num_entries, args->wc); + use_ib_mem_pool = false; +} + + +/* + * ibv_req_notify_cq + */ + +void call_ibv_req_notify_cq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_req_notify_cq(args->cq, args->solicited_only); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_srq + */ + +void call_ibv_create_srq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_srq(args->pd, args->srq_init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_srq_ex + */ + +void call_ibv_create_srq_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_srq_ex(args->context, args->srq_init_attr_ex); + use_ib_mem_pool = false; +} + + +/* + * ibv_modify_srq + */ + +void call_ibv_modify_srq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_modify_srq(args->srq, args->srq_attr, args->srq_attr_mask); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_srq + */ + +void call_ibv_query_srq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_srq(args->srq, args->srq_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_get_srq_num + */ + +void call_ibv_get_srq_num(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_get_srq_num(args->srq, args->srq_num); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_srq + */ + +void call_ibv_destroy_srq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_srq(args->srq); + use_ib_mem_pool = false; +} + + +/* + * ibv_post_srq_recv + */ + +void call_ibv_post_srq_recv(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_post_srq_recv(args->srq, args->recv_wr, args->bad_recv_wr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_qp + */ + +void call_ibv_create_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_qp(args->pd, args->qp_init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_qp_ex + */ + +void call_ibv_create_qp_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_qp_ex(args->context, args->qp_init_attr_ex); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_rt_values_ex + */ + +void call_ibv_query_rt_values_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_query_rt_values_ex\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_rt_values_ex(args->context, args->values); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_device_ex + */ + +void call_ibv_query_device_ex(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_device_ex(args->context, args->input, args->attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_open_qp + */ + +void call_ibv_open_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_open_qp(args->context, args->qp_open_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_modify_qp + */ + +void call_ibv_modify_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_modify_qp(args->qp, args->attr, args->attr_mask); + use_ib_mem_pool = false; +} + + +/* + * ibv_query_qp + */ + +void call_ibv_query_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_query_qp(args->qp, args->attr, args->attr_mask, args->init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_qp + */ + +void call_ibv_destroy_qp(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_qp(args->qp); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_wq + */ + +void call_ibv_create_wq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_create_wq\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_create_wq_t * args = (uhyve_ibv_create_wq_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_create_wq(args->context, args->wq_init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_modify_wq + */ + +void call_ibv_modify_wq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_modify_wq\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_modify_wq_t * args = (uhyve_ibv_modify_wq_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_modify_wq(args->wq, args->wq_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_wq + */ + +void call_ibv_destroy_wq(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_destroy_wq\n"); + unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset)); + uhyve_ibv_destroy_wq_t * args = (uhyve_ibv_destroy_wq_t *) (guest_mem + data); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_wq(args->wq); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_rwq_ind_table + */ + +void call_ibv_create_rwq_ind_table(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_create_rwq_ind_table\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_rwq_ind_table(args->context, args->init_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_rwq_ind_table + */ + +void call_ibv_destroy_rwq_ind_table(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_destroy_rwq_ind_table\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_rwq_ind_table(args->rwq_ind_table); + use_ib_mem_pool = false; +} + + +/* + * ibv_post_send + */ + +void call_ibv_post_send(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_post_send(args->qp, args->wr, args->bad_wr); + use_ib_mem_pool = false; +} + + +/* + * ibv_post_recv + */ + +void call_ibv_post_recv(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_post_recv(args->qp, args->wr, args->bad_wr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_ah + */ + +void call_ibv_create_ah(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_ah(args->pd, args->attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_init_ah_from_wc + */ + +void call_ibv_init_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_init_ah_from_wc(args->context, args->port_num, args->wc, args->grh, args->ah_attr); + use_ib_mem_pool = false; +} + + +/* + * ibv_create_ah_from_wc + */ + +void call_ibv_create_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_create_ah_from_wc(args->pd, args->wc, args->grh, args->port_num); + use_ib_mem_pool = false; +} + + +/* + * ibv_destroy_ah + */ + +void call_ibv_destroy_ah(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_destroy_ah(args->ah); + use_ib_mem_pool = false; +} + + +/* + * ibv_attach_mcast + */ + +void call_ibv_attach_mcast(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_attach_mcast(args->qp, args->gid, args->lid); + use_ib_mem_pool = false; +} + + +/* + * ibv_detach_mcast + */ + +void call_ibv_detach_mcast(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_detach_mcast(args->qp, args->gid, args->lid); + use_ib_mem_pool = false; +} + + +/* + * ibv_fork_init + */ + +void call_ibv_fork_init(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_fork_init(args->); + use_ib_mem_pool = false; +} + + +/* + * ibv_node_type_str + */ + +void call_ibv_node_type_str(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_node_type_str(args->node_type); + use_ib_mem_pool = false; +} + + +/* + * ibv_port_state_str + */ + +void call_ibv_port_state_str(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_port_state_str(args->port_state); + use_ib_mem_pool = false; +} + + +/* + * ibv_event_type_str + */ + +void call_ibv_event_type_str(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_event_type_str(args->event); + use_ib_mem_pool = false; +} + + +/* + * ibv_resolve_eth_l2_from_gid + */ + +void call_ibv_resolve_eth_l2_from_gid(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - call_ibv_resolve_eth_l2_from_gid\n"); + 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); + + use_ib_mem_pool = true; + args->ret = ibv_resolve_eth_l2_from_gid(args->context, args->attr, args->eth_mac, args->vid); + use_ib_mem_pool = false; +} + + +/* + * ibv_is_qpt_supported + */ + +void call_ibv_is_qpt_supported(struct kvm_run * run, uint8_t * guest_mem) { + printf("LOG: UHYVE - 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); + + use_ib_mem_pool = true; + args->ret = ibv_is_qpt_supported(args->caps, args->qpt); + use_ib_mem_pool = false; +} diff --git a/tools/uhyve-ibv.h b/tools/uhyve-ibv.h index be0a46483..842c2c725 100644 --- a/tools/uhyve-ibv.h +++ b/tools/uhyve-ibv.h @@ -19,41 +19,316 @@ #ifndef UHYVE_IBV_H #define UHYVE_IBV_H -#include // Linux include +#include #include #include -#define MAX_NUM_OF_IBV_DEVICES 16 - extern bool use_ib_mem_pool; typedef enum { - UHYVE_PORT_SET_IB_POOL_ADDR = 0x609, - - UHYVE_PORT_IBV_OPEN_DEVICE = 0x610, - UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x611, - UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x612, - UHYVE_PORT_IBV_QUERY_PORT = 0x613, - UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x614, - UHYVE_PORT_KERNEL_IBV_LOG = 0x615, + UHYVE_PORT_SET_IB_POOL_ADDR = 0x60F, + UHYVE_PORT_IBV_WC_STATUS_STR = 0x610, + UHYVE_PORT_IBV_RATE_TO_MULT = 0x611, + UHYVE_PORT_MULT_TO_IBV_RATE = 0x612, + UHYVE_PORT_IBV_RATE_TO_MBPS = 0x613, + UHYVE_PORT_MBPS_TO_IBV_RATE = 0x614, + UHYVE_PORT_IBV_CQ_EX_TO_CQ = 0x615, + UHYVE_PORT_IBV_START_POLL = 0x616, + UHYVE_PORT_IBV_NEXT_POLL = 0x617, + UHYVE_PORT_IBV_END_POLL = 0x618, + UHYVE_PORT_IBV_WC_READ_OPCODE = 0x619, + UHYVE_PORT_IBV_WC_READ_VENDOR_ERR = 0x61A, + UHYVE_PORT_IBV_WC_READ_BYTE_LEN = 0x61B, + UHYVE_PORT_IBV_WC_READ_IMM_DATA = 0x61C, + UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY = 0x61D, + UHYVE_PORT_IBV_WC_READ_QP_NUM = 0x61E, + UHYVE_PORT_IBV_WC_READ_SRC_QP = 0x61F, + UHYVE_PORT_IBV_WC_READ_WC_FLAGS = 0x620, + UHYVE_PORT_IBV_WC_READ_SLID = 0x621, + UHYVE_PORT_IBV_WC_READ_SL = 0x622, + UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS = 0x623, + UHYVE_PORT_IBV_WC_READ_COMPLETION_TS = 0x624, + UHYVE_PORT_IBV_WC_READ_CVLAN = 0x625, + UHYVE_PORT_IBV_WC_READ_FLOW_TAG = 0x626, + UHYVE_PORT_IBV_POST_WQ_RECV = 0x627, + UHYVE_PORT_VERBS_GET_CTX = 0x628, + UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x629, + UHYVE_PORT_IBV_FREE_DEVICE_LIST = 0x62A, + UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x62B, + UHYVE_PORT_IBV_GET_DEVICE_GUID = 0x62C, + UHYVE_PORT_IBV_OPEN_DEVICE = 0x62D, + UHYVE_PORT_IBV_CLOSE_DEVICE = 0x62E, + UHYVE_PORT_IBV_GET_ASYNC_EVENT = 0x62F, + UHYVE_PORT_IBV_ACK_ASYNC_EVENT = 0x630, + UHYVE_PORT_IBV_QUERY_DEVICE = 0x631, + UHYVE_PORT_IBV_QUERY_PORT = 0x632, + UHYVE_PORT____IBV_QUERY_PORT = 0x633, + UHYVE_PORT_IBV_QUERY_GID = 0x634, + UHYVE_PORT_IBV_QUERY_PKEY = 0x635, + UHYVE_PORT_IBV_ALLOC_PD = 0x636, + UHYVE_PORT_IBV_DEALLOC_PD = 0x637, + UHYVE_PORT_IBV_CREATE_FLOW = 0x638, + UHYVE_PORT_IBV_DESTROY_FLOW = 0x639, + UHYVE_PORT_IBV_OPEN_XRCD = 0x63A, + UHYVE_PORT_IBV_CLOSE_XRCD = 0x63B, + UHYVE_PORT_IBV_REG_MR = 0x63C, + UHYVE_PORT_IBV_REREG_MR = 0x63D, + UHYVE_PORT_IBV_DEREG_MR = 0x63E, + UHYVE_PORT_IBV_ALLOC_MW = 0x63F, + UHYVE_PORT_IBV_DEALLOC_MW = 0x640, + UHYVE_PORT_IBV_INC_RKEY = 0x641, + UHYVE_PORT_IBV_BIND_MW = 0x642, + UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x643, + UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x644, + UHYVE_PORT_IBV_CREATE_CQ = 0x645, + UHYVE_PORT_IBV_CREATE_CQ_EX = 0x646, + UHYVE_PORT_IBV_RESIZE_CQ = 0x647, + UHYVE_PORT_IBV_DESTROY_CQ = 0x648, + UHYVE_PORT_IBV_GET_CQ_EVENT = 0x649, + UHYVE_PORT_IBV_ACK_CQ_EVENTS = 0x64A, + UHYVE_PORT_IBV_POLL_CQ = 0x64B, + UHYVE_PORT_IBV_REQ_NOTIFY_CQ = 0x64C, + UHYVE_PORT_IBV_CREATE_SRQ = 0x64D, + UHYVE_PORT_IBV_CREATE_SRQ_EX = 0x64E, + UHYVE_PORT_IBV_MODIFY_SRQ = 0x64F, + UHYVE_PORT_IBV_QUERY_SRQ = 0x650, + UHYVE_PORT_IBV_GET_SRQ_NUM = 0x651, + UHYVE_PORT_IBV_DESTROY_SRQ = 0x652, + UHYVE_PORT_IBV_POST_SRQ_RECV = 0x653, + UHYVE_PORT_IBV_CREATE_QP = 0x654, + UHYVE_PORT_IBV_CREATE_QP_EX = 0x655, + UHYVE_PORT_IBV_QUERY_RT_VALUES_EX = 0x656, + UHYVE_PORT_IBV_QUERY_DEVICE_EX = 0x657, + UHYVE_PORT_IBV_OPEN_QP = 0x658, + UHYVE_PORT_IBV_MODIFY_QP = 0x659, + UHYVE_PORT_IBV_QUERY_QP = 0x65A, + UHYVE_PORT_IBV_DESTROY_QP = 0x65B, + UHYVE_PORT_IBV_CREATE_WQ = 0x65C, + UHYVE_PORT_IBV_MODIFY_WQ = 0x65D, + UHYVE_PORT_IBV_DESTROY_WQ = 0x65E, + UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE = 0x65F, + UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE = 0x660, + UHYVE_PORT_IBV_POST_SEND = 0x661, + UHYVE_PORT_IBV_POST_RECV = 0x662, + UHYVE_PORT_IBV_CREATE_AH = 0x663, + UHYVE_PORT_IBV_INIT_AH_FROM_WC = 0x664, + UHYVE_PORT_IBV_CREATE_AH_FROM_WC = 0x665, + UHYVE_PORT_IBV_DESTROY_AH = 0x666, + UHYVE_PORT_IBV_ATTACH_MCAST = 0x667, + UHYVE_PORT_IBV_DETACH_MCAST = 0x668, + UHYVE_PORT_IBV_FORK_INIT = 0x669, + UHYVE_PORT_IBV_NODE_TYPE_STR = 0x66A, + UHYVE_PORT_IBV_PORT_STATE_STR = 0x66B, + UHYVE_PORT_IBV_EVENT_TYPE_STR = 0x66C, + UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID = 0x66D, + UHYVE_PORT_IBV_IS_QPT_SUPPORTED = 0x66E, + UHYVE_PORT_KERNEL_IBV_LOG = 0x66F, } 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_cq_ex * cq; + // Return value: + struct ibv_cq * ret; +} __attribute__((packed)) uhyve_ibv_cq_ex_to_cq_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + struct ibv_poll_cq_attr * attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_start_poll_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_next_poll_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; +} __attribute__((packed)) uhyve_ibv_end_poll_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + enum ibv_wc_opcode ret; +} __attribute__((packed)) uhyve_ibv_wc_read_opcode_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_vendor_err_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_byte_len_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + __be32 ret; +} __attribute__((packed)) uhyve_ibv_wc_read_imm_data_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_invalidated_rkey_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_qp_num_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_src_qp_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_wc_read_wc_flags_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_slid_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint8_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_sl_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint8_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_dlid_path_bits_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint64_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_completion_ts_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint16_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_cvlan_t; + +typedef struct { + // Parameters: + struct ibv_cq_ex * cq; + // Return value: + uint32_t ret; +} __attribute__((packed)) uhyve_ibv_wc_read_flow_tag_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[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? + 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; @@ -61,6 +336,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; @@ -70,6 +373,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; @@ -77,10 +513,455 @@ 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); +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 [6] eth_mac; + 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_cq_ex_to_cq(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_start_poll(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_next_poll(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_end_poll(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_opcode(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_vendor_err(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_byte_len(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_imm_data(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_invalidated_rkey(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_qp_num(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_src_qp(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_wc_flags(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_slid(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_sl(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_dlid_path_bits(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_completion_ts(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_cvlan(struct kvm_run * run, uint8_t * guest_mem); +void call_ibv_wc_read_flow_tag(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); #endif // UHYVE_IBV_H diff --git a/tools/uhyve.c b/tools/uhyve.c index c31025cff..df4bc8d39 100644 --- a/tools/uhyve.c +++ b/tools/uhyve.c @@ -1256,6 +1256,8 @@ static int vcpu_loop(void) break; } + // InfiniBand + case UHYVE_PORT_KERNEL_IBV_LOG: { unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); char* str = (char*) (guest_mem + data); @@ -1263,39 +1265,299 @@ static int vcpu_loop(void) break; } - // InfiniBand - case UHYVE_PORT_SET_IB_POOL_ADDR: - printf("LOG: UHYVE CASE\n"); - unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); - uint64_t * temp = (uint64_t*)(guest_mem + data); - /* printf("LOG: Value of uint64 pool start: %" PRIu64 "\n", *temp); */ - printf("LOG: Value of uint64 pool start: %p\n", *temp); - ib_pool_addr = (uint8_t*) *temp; - /* printf("LOG: Value of uint8 pool start: %" PRIu8 "\n", ib_pool_addr); */ - printf("LOG: Value of uint8 pool start: %p\n", ib_pool_addr); - ib_pool_top = ib_pool_addr; - break; + case UHYVE_PORT_SET_IB_POOL_ADDR: { + unsigned data = *((unsigned*)((size_t)run+run->io.data_offset)); + uint64_t * temp = (uint64_t*)(guest_mem + data); + ib_pool_addr = (uint8_t*) *temp; + ib_pool_top = ib_pool_addr; + break; + } + 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_CQ_EX_TO_CQ: + call_ibv_cq_ex_to_cq(run, guest_mem); + break; + case UHYVE_PORT_IBV_START_POLL: + call_ibv_start_poll(run, guest_mem); + break; + case UHYVE_PORT_IBV_NEXT_POLL: + call_ibv_next_poll(run, guest_mem); + break; + case UHYVE_PORT_IBV_END_POLL: + call_ibv_end_poll(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_OPCODE: + call_ibv_wc_read_opcode(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_VENDOR_ERR: + call_ibv_wc_read_vendor_err(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_BYTE_LEN: + call_ibv_wc_read_byte_len(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_IMM_DATA: + call_ibv_wc_read_imm_data(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY: + call_ibv_wc_read_invalidated_rkey(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_QP_NUM: + call_ibv_wc_read_qp_num(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_SRC_QP: + call_ibv_wc_read_src_qp(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_WC_FLAGS: + call_ibv_wc_read_wc_flags(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_SLID: + call_ibv_wc_read_slid(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_SL: + call_ibv_wc_read_sl(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS: + call_ibv_wc_read_dlid_path_bits(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_COMPLETION_TS: + call_ibv_wc_read_completion_ts(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_CVLAN: + call_ibv_wc_read_cvlan(run, guest_mem); + break; + case UHYVE_PORT_IBV_WC_READ_FLOW_TAG: + call_ibv_wc_read_flow_tag(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: - 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_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; default: err(1, "KVM: unhandled KVM_EXIT_IO at port 0x%x, direction %d\n", run->io.port, run->io.direction);