1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

Pingpong running up to accept() calls. Added 2 helper functions to get qp_num and mr_lkey.

This commit is contained in:
Annika Wierichs 2017-12-12 18:10:18 +01:00
parent dd2850e35e
commit 95c5be5960
10 changed files with 793 additions and 108 deletions

View file

@ -115,6 +115,8 @@ const char * ibv_node_type_str(enum ibv_node_type node_type);
const char * ibv_port_state_str(enum ibv_port_state port_state);
const char * ibv_event_type_str(enum ibv_event_type event);
int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt);
uint32_t ibv_get_mr_lkey(struct ibv_mr * mr);
uint32_t ibv_get_qp_num(struct ibv_qp * qp);
// void kernel_ibv_log();

View file

@ -135,6 +135,8 @@ extern const size_t image_size;
#define UHYVE_PORT_IBV_PORT_STATE_STR 0x56B
#define UHYVE_PORT_IBV_EVENT_TYPE_STR 0x56C
#define UHYVE_PORT_IBV_IS_QPT_SUPPORTED 0x56E
#define UHYVE_PORT_IBV_GET_MR_LKEY 0x56F // !
#define UHYVE_PORT_IBV_GET_QP_NUM 0x570 // !
// #define UHYVE_PORT_KERNEL_IBV_LOG 0x56F

View file

@ -107,11 +107,11 @@ int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_po
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 = (struct ibv_port_attr *) guest_to_host((size_t) port_attr); // own fnc?
uhyve_send(UHYVE_PORT_IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args));
/* host_to_guest_ibv_port_attr(port_attr, GUEST); // ! */
/* host_to_guest_ibv_port_attr(port_attr, GUEST); // ! not necessary atm */
return uhyve_args.ret;
}
@ -1336,19 +1336,18 @@ typedef struct {
} __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) {
LOG_INFO("KERNEL: ibv_post_recv()\n");
/* LOG_INFO("KERNEL: ibv_post_recv()\n"); */
uhyve_ibv_post_recv_t uhyve_args;
LOG_INFO("KERNEL: ibv_post_recv()\n");
uhyve_args.qp = qp;
LOG_INFO("KERNEL: ibv_post_recv()\n");
/* LOG_INFO("KERNEL: ibv_post_recv() - guest_to_host_ibv_recv_wr\n"); */
uhyve_args.wr = guest_to_host_ibv_recv_wr(wr);
LOG_INFO("KERNEL: ibv_post_recv()\n");
/* LOG_INFO("KERNEL: ibv_post_recv() - \n"); */
uhyve_args.bad_wr = (struct ibv_recv_wr **) guest_to_host((size_t) bad_wr);
LOG_INFO("KERNEL: ibv_post_recv()\n");
/* LOG_INFO("KERNEL: ibv_post_recv()\n"); */
uhyve_send(UHYVE_PORT_IBV_POST_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args));
LOG_INFO("KERNEL: ibv_post_recv()\n");
/* LOG_INFO("KERNEL: ibv_post_recv()\n"); */
/* host_to_guest_ibv_recv_wr(wr, GUEST); */ // TODO: add this back in
/* LOG_INFO("KERNEL: ibv_post_recv()\n"); */
@ -1616,3 +1615,43 @@ int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt) {
}
/*
* ibv_get_mr_lkey
*/
typedef struct {
// Parameters:
struct ibv_mr * mr;
// Return value:
uint32_t ret;
} __attribute__((packed)) uhyve_ibv_get_mr_lkey_t;
uint32_t ibv_get_mr_lkey(struct ibv_mr * mr) {
uhyve_ibv_get_mr_lkey_t uhyve_args;
uhyve_args.mr = mr;
uhyve_send(UHYVE_PORT_IBV_GET_MR_LKEY, (unsigned) virt_to_phys((size_t) &uhyve_args));
return uhyve_args.ret;
}
/*
* ibv_get_qp_num
*/
typedef struct {
// Parameters:
struct ibv_qp * qp;
// Return value:
uint32_t ret;
} __attribute__((packed)) uhyve_ibv_get_qp_num_t;
uint32_t ibv_get_qp_num(struct ibv_qp * qp) {
uhyve_ibv_get_qp_num_t uhyve_args;
uhyve_args.qp = qp;
uhyve_send(UHYVE_PORT_IBV_GET_QP_NUM, (unsigned) virt_to_phys((size_t) &uhyve_args));
return uhyve_args.ret;
}

View file

@ -32,6 +32,7 @@
#include <asm/page.h>
#include <hermit/ibv_guest_host.h>
#include <hermit/stdio.h>
#include <hermit/logging.h>

View file

@ -66,3 +66,5 @@ const char * ibv_node_type_str(enum ibv_node_type node_type)
const char * ibv_port_state_str(enum ibv_port_state port_state)
const char * ibv_event_type_str(enum ibv_event_type event)
int ibv_is_qpt_supported(uint32_t caps,enum ibv_qp_type qpt)
uint32_t ibv_get_mr_lkey(struct ibv_mr * mr)
uint32_t ibv_get_qp_num(struct ibv_qp * qp)

View file

@ -589,3 +589,19 @@ void call_ibv_is_qpt_supported(struct kvm_run * run, uint8_t * guest_mem) {
args->ret = ibv_is_qpt_supported(args->caps, args->qpt);
}
void call_ibv_get_mr_lkey(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_get_mr_lkey\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_get_mr_lkey_t * args = (uhyve_ibv_get_mr_lkey_t *) (guest_mem + data);
args->ret = args->mr->lkey;
}
void call_ibv_get_qp_num(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_get_qp_num\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_get_qp_num_t * args = (uhyve_ibv_get_qp_num_t *) (guest_mem + data);
args->ret = args->qp->qp_num;
}

599
tools/uhyve-ibv.c~ Normal file
View file

@ -0,0 +1,599 @@
/*
* Copyright (c) 2017, Annika Wierichs, RWTH Aachen University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* TODO: Documentation
*
*/
#include "uhyve-ibv.h"
#include <infiniband/verbs.h> // Linux include
/*
* ibv_get_device_list
*/
void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem) { // !
printf("UHYVE call: call_ibv_get_device_list\n");
unsigned data = *((unsigned *) ((size_t) run + run->io.data_offset));
uhyve_ibv_get_device_list_t * args = (uhyve_ibv_get_device_list_t *) (guest_mem + data);
int num_devices;
struct ibv_device ** host_ret = ibv_get_device_list(&num_devices);
if (args->num_devices != NULL) {
*args->num_devices = num_devices;
}
for (int d = 0; d < num_devices; d++) {
args->ret[d] = host_ret[d];
}
}
void call_ibv_wc_status_str(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_wc_status_str\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_wc_status_str_t * args = (uhyve_ibv_wc_status_str_t *) (guest_mem + data);
const char * host_ret = ibv_wc_status_str(args->status); // !
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
}
void call_ibv_rate_to_mult(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_rate_to_mult\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_rate_to_mult_t * args = (uhyve_ibv_rate_to_mult_t *) (guest_mem + data);
args->ret = ibv_rate_to_mult(args->rate);
}
void call_mult_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_mult_to_ibv_rate\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_mult_to_ibv_rate_t * args = (uhyve_mult_to_ibv_rate_t *) (guest_mem + data);
args->ret = mult_to_ibv_rate(args->mult);
}
void call_ibv_rate_to_mbps(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_rate_to_mbps\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_rate_to_mbps_t * args = (uhyve_ibv_rate_to_mbps_t *) (guest_mem + data);
args->ret = ibv_rate_to_mbps(args->rate);
}
void call_mbps_to_ibv_rate(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_mbps_to_ibv_rate\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_mbps_to_ibv_rate_t * args = (uhyve_mbps_to_ibv_rate_t *) (guest_mem + data);
args->ret = mbps_to_ibv_rate(args->mbps);
}
void call_verbs_get_ctx(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_verbs_get_ctx\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_verbs_get_ctx_t * args = (uhyve_verbs_get_ctx_t *) (guest_mem + data);
args->ret = verbs_get_ctx(args->ctx);
}
void call_ibv_free_device_list(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_free_device_list\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_free_device_list_t * args = (uhyve_ibv_free_device_list_t *) (guest_mem + data);
}
void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_get_device_name\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_get_device_name_t * args = (uhyve_ibv_get_device_name_t *) (guest_mem + data);
const char * host_ret = ibv_get_device_name(args->device); // !
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
}
void call_ibv_get_device_guid(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_get_device_guid\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_get_device_guid_t * args = (uhyve_ibv_get_device_guid_t *) (guest_mem + data);
args->ret = ibv_get_device_guid(args->device);
}
void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_open_device\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_open_device_t * args = (uhyve_ibv_open_device_t *) (guest_mem + data);
args->ret = ibv_open_device(args->device);
}
void call_ibv_close_device(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_close_device\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_close_device_t * args = (uhyve_ibv_close_device_t *) (guest_mem + data);
args->ret = ibv_close_device(args->context);
}
void call_ibv_get_async_event(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_get_async_event\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_get_async_event_t * args = (uhyve_ibv_get_async_event_t *) (guest_mem + data);
args->ret = ibv_get_async_event(args->context, args->event);
}
void call_ibv_ack_async_event(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_ack_async_event\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_ack_async_event_t * args = (uhyve_ibv_ack_async_event_t *) (guest_mem + data);
}
void call_ibv_query_device(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_query_device\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_query_device_t * args = (uhyve_ibv_query_device_t *) (guest_mem + data);
args->ret = ibv_query_device(args->context, args->device_attr);
}
void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_query_port\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_query_port_t * args = (uhyve_ibv_query_port_t *) (guest_mem + data);
args->ret = ibv_query_port(args->context, args->port_num, args->port_attr);
}
void call____ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call____ibv_query_port\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve____ibv_query_port_t * args = (uhyve____ibv_query_port_t *) (guest_mem + data);
args->ret = ___ibv_query_port(args->context, args->port_num, args->port_attr);
}
void call_ibv_query_gid(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_query_gid\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_query_gid_t * args = (uhyve_ibv_query_gid_t *) (guest_mem + data);
args->ret = ibv_query_gid(args->context, args->port_num, args->index, args->gid);
}
void call_ibv_query_pkey(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_query_pkey\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_query_pkey_t * args = (uhyve_ibv_query_pkey_t *) (guest_mem + data);
args->ret = ibv_query_pkey(args->context, args->port_num, args->index, args->pkey);
}
void call_ibv_alloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_alloc_pd\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_alloc_pd_t * args = (uhyve_ibv_alloc_pd_t *) (guest_mem + data);
args->ret = ibv_alloc_pd(args->context);
}
void call_ibv_dealloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_dealloc_pd\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_dealloc_pd_t * args = (uhyve_ibv_dealloc_pd_t *) (guest_mem + data);
args->ret = ibv_dealloc_pd(args->pd);
}
void call_ibv_create_flow(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_create_flow\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_create_flow_t * args = (uhyve_ibv_create_flow_t *) (guest_mem + data);
args->ret = ibv_create_flow(args->qp, args->flow);
}
void call_ibv_destroy_flow(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_destroy_flow\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_destroy_flow_t * args = (uhyve_ibv_destroy_flow_t *) (guest_mem + data);
args->ret = ibv_destroy_flow(args->flow_id);
}
void call_ibv_open_xrcd(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_open_xrcd\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_open_xrcd_t * args = (uhyve_ibv_open_xrcd_t *) (guest_mem + data);
args->ret = ibv_open_xrcd(args->context, args->xrcd_init_attr);
}
void call_ibv_close_xrcd(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_close_xrcd\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_close_xrcd_t * args = (uhyve_ibv_close_xrcd_t *) (guest_mem + data);
args->ret = ibv_close_xrcd(args->xrcd);
}
void call_ibv_reg_mr(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_reg_mr\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_reg_mr_t * args = (uhyve_ibv_reg_mr_t *) (guest_mem + data);
args->ret = ibv_reg_mr(args->pd, args->addr, args->length, args->access);
}
void call_ibv_get_mr_lkey(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_get_mr_lkey\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
(struct ibv_qp_att *) guest_to_host((size_t) uhyve_ibv_reg_mr_t )* args = (uhyve_ibv_reg_mr_t *) (guest_mem + data);
(struct ibv_qp_att *) guest_to_host((size_t)
args)->ret = ibv_reg_mr(args->pd, args->addr, args->length, args->access);
(struct ibv_qp_att *) guest_to_host((size_t) }
(struct ibv_qp_att *) guest_to_host((size_t) )
)void call_ibv_rereg_mr(struct kvm_run * run, uint8_t * guest_mem) {
printf("(struct ibv_qp_att *) guest_to_host((size_t) UHYVE )call: call_ibv_rereg_mr\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_rereg_mr_t * args = (struct ibv_qp_att *) guest_to_host((size_t) ()uhyve_ibv_rereg_mr_t *) (guest_mem + data);
(struct ibv_qp_att *) guest_to_host((size_t)
args)->ret = ibv_rereg_mr(args->mr, args->flags, args->pd, args->addr, args->length, args->access);
(struct ibv_qp_att *) guest_to_host((size_t) }
(struct ibv_qp_att *) guest_to_host((size_t) )
)void call_ibv_dereg_mr(struct kvm_run * run, uint8_t * guest_mem) {
printf("(struct ibv_qp_att *) guest_to_host((size_t) UHYVE )call: call_ibv_dereg_mr\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_dereg_mr_t * args = (struct ibv_qp_att *) guest_to_host((size_t) ()uhyve_ibv_dereg_mr_t *) (guest_mem + data);
(struct ibv_qp_att *) guest_to_host((size_t)
args)->ret = ibv_dereg_mr(args->mr);
(struct ibv_qp_att *) guest_to_host((size_t) }
(struct ibv_qp_att *) guest_to_host((size_t) )
)void call_ibv_alloc_mw(struct kvm_run * run, uint8_t * guest_mem) {
printf("(struct ibv_qp_att *) guest_to_host((size_t) UHYVE )call: call_ibv_alloc_mw\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_alloc_mw_t * args = (struct ibv_qp_att *) guest_to_host((size_t) ()uhyve_ibv_alloc_mw_t *) (guest_mem + data);
(struct ibv_qp_att *) guest_to_host((size_t)
args)->ret = ibv_alloc_mw(args->pd, args->type);
(struct ibv_qp_att *) guest_to_host((size_t) }
(struct ibv_qp_att *) guest_to_host((size_t) )
)void call_ibv_dealloc_mw(struct kvm_run * run, uint8_t * guest_mem) {
printf("(struct ibv_qp_att *) guest_to_host((size_t) UHYVE )call: call_ibv_dealloc_mw\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_dealloc_mw_t * args (struct ibv_qp_att *) guest_to_host((size_t) = )(uhyve_ibv_dealloc_mw_t *) (guest_mem + data);
(struct ibv_qp_att *) guest_to_host((size_t)
args)->ret = ibv_dealloc_mw(args->mw);
guest_to_host((size_t) }
void call_ibv_inc_rkey(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_inc_rkey\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_inc_rkey_t * args = (uhyve_ibv_inc_rkey_t *) (guest_mem + data);
args->ret = ibv_inc_rkey(args->rkey);
}
void call_ibv_bind_mw(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_bind_mw\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_bind_mw_t * args = (uhyve_ibv_bind_mw_t *) (guest_mem + data);
args->ret = ibv_bind_mw(args->qp, args->mw, args->mw_bind);
}
void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_create_comp_channel\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_create_comp_channel_t * args = (uhyve_ibv_create_comp_channel_t *) (guest_mem + data);
args->ret = ibv_create_comp_channel(args->context);
}
void call_ibv_destroy_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_destroy_comp_channel\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_destroy_comp_channel_t * args = (uhyve_ibv_destroy_comp_channel_t *) (guest_mem + data);
args->ret = ibv_destroy_comp_channel(args->channel);
}
void call_ibv_create_cq(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_create_cq\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_create_cq_t * args = (uhyve_ibv_create_cq_t *) (guest_mem + data);
args->ret = ibv_create_cq(args->context, args->cqe, args->cq_context, args->channel, args->comp_vector);
}
void call_ibv_resize_cq(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_resize_cq\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_resize_cq_t * args = (uhyve_ibv_resize_cq_t *) (guest_mem + data);
args->ret = ibv_resize_cq(args->cq, args->cqe);
}
void call_ibv_destroy_cq(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_destroy_cq\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_destroy_cq_t * args = (uhyve_ibv_destroy_cq_t *) (guest_mem + data);
args->ret = ibv_destroy_cq(args->cq);
}
void call_ibv_get_cq_event(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_get_cq_event\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_get_cq_event_t * args = (uhyve_ibv_get_cq_event_t *) (guest_mem + data);
args->ret = ibv_get_cq_event(args->channel, args->cq, args->cq_context);
}
void call_ibv_ack_cq_events(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_ack_cq_events\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_ack_cq_events_t * args = (uhyve_ibv_ack_cq_events_t *) (guest_mem + data);
}
void call_ibv_poll_cq(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_poll_cq\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_poll_cq_t * args = (uhyve_ibv_poll_cq_t *) (guest_mem + data);
args->ret = ibv_poll_cq(args->cq, args->num_entries, args->wc);
}
void call_ibv_req_notify_cq(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_req_notify_cq\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_req_notify_cq_t * args = (uhyve_ibv_req_notify_cq_t *) (guest_mem + data);
args->ret = ibv_req_notify_cq(args->cq, args->solicited_only);
}
void call_ibv_create_srq(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_create_srq\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_create_srq_t * args = (uhyve_ibv_create_srq_t *) (guest_mem + data);
args->ret = ibv_create_srq(args->pd, args->srq_init_attr);
}
void call_ibv_create_srq_ex(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_create_srq_ex\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_create_srq_ex_t * args = (uhyve_ibv_create_srq_ex_t *) (guest_mem + data);
args->ret = ibv_create_srq_ex(args->context, args->srq_init_attr_ex);
}
void call_ibv_modify_srq(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_modify_srq\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_modify_srq_t * args = (uhyve_ibv_modify_srq_t *) (guest_mem + data);
args->ret = ibv_modify_srq(args->srq, args->srq_attr, args->srq_attr_mask);
}
void call_ibv_query_srq(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_query_srq\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_query_srq_t * args = (uhyve_ibv_query_srq_t *) (guest_mem + data);
args->ret = ibv_query_srq(args->srq, args->srq_attr);
}
void call_ibv_get_srq_num(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_get_srq_num\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_get_srq_num_t * args = (uhyve_ibv_get_srq_num_t *) (guest_mem + data);
args->ret = ibv_get_srq_num(args->srq, args->srq_num);
}
void call_ibv_destroy_srq(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_destroy_srq\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_destroy_srq_t * args = (uhyve_ibv_destroy_srq_t *) (guest_mem + data);
args->ret = ibv_destroy_srq(args->srq);
}
void call_ibv_post_srq_recv(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_post_srq_recv\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_post_srq_recv_t * args = (uhyve_ibv_post_srq_recv_t *) (guest_mem + data);
args->ret = ibv_post_srq_recv(args->srq, args->recv_wr, args->bad_recv_wr);
}
void call_ibv_create_qp(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_create_qp\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_create_qp_t * args = (uhyve_ibv_create_qp_t *) (guest_mem + data);
args->ret = ibv_create_qp(args->pd, args->qp_init_attr);
}
void call_ibv_create_qp_ex(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_create_qp_ex\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_create_qp_ex_t * args = (uhyve_ibv_create_qp_ex_t *) (guest_mem + data);
args->ret = ibv_create_qp_ex(args->context, args->qp_init_attr_ex);
}
void call_ibv_query_device_ex(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_query_device_ex\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_query_device_ex_t * args = (uhyve_ibv_query_device_ex_t *) (guest_mem + data);
args->ret = ibv_query_device_ex(args->context, args->input, args->attr);
}
void call_ibv_open_qp(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_open_qp\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_open_qp_t * args = (uhyve_ibv_open_qp_t *) (guest_mem + data);
args->ret = ibv_open_qp(args->context, args->qp_open_attr);
}
void call_ibv_modify_qp(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_modify_qp\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_modify_qp_t * args = (uhyve_ibv_modify_qp_t *) (guest_mem + data);
args->ret = ibv_modify_qp(args->qp, args->attr, args->attr_mask);
}
void call_ibv_query_qp(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_query_qp\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_query_qp_t * args = (uhyve_ibv_query_qp_t *) (guest_mem + data);
args->ret = ibv_query_qp(args->qp, args->attr, args->attr_mask, args->init_attr);
}
void call_ibv_destroy_qp(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_destroy_qp\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_destroy_qp_t * args = (uhyve_ibv_destroy_qp_t *) (guest_mem + data);
args->ret = ibv_destroy_qp(args->qp);
}
void call_ibv_post_send(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_post_send\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_post_send_t * args = (uhyve_ibv_post_send_t *) (guest_mem + data);
args->ret = ibv_post_send(args->qp, args->wr, args->bad_wr);
}
void call_ibv_post_recv(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_post_recv\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_post_recv_t * args = (uhyve_ibv_post_recv_t *) (guest_mem + data);
args->ret = ibv_post_recv(args->qp, args->wr, args->bad_wr);
}
void call_ibv_create_ah(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_create_ah\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_create_ah_t * args = (uhyve_ibv_create_ah_t *) (guest_mem + data);
args->ret = ibv_create_ah(args->pd, args->attr);
}
void call_ibv_init_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_init_ah_from_wc\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_init_ah_from_wc_t * args = (uhyve_ibv_init_ah_from_wc_t *) (guest_mem + data);
args->ret = ibv_init_ah_from_wc(args->context, args->port_num, args->wc, args->grh, args->ah_attr);
}
void call_ibv_create_ah_from_wc(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_create_ah_from_wc\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_create_ah_from_wc_t * args = (uhyve_ibv_create_ah_from_wc_t *) (guest_mem + data);
args->ret = ibv_create_ah_from_wc(args->pd, args->wc, args->grh, args->port_num);
}
void call_ibv_destroy_ah(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_destroy_ah\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_destroy_ah_t * args = (uhyve_ibv_destroy_ah_t *) (guest_mem + data);
args->ret = ibv_destroy_ah(args->ah);
}
void call_ibv_attach_mcast(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_attach_mcast\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_attach_mcast_t * args = (uhyve_ibv_attach_mcast_t *) (guest_mem + data);
args->ret = ibv_attach_mcast(args->qp, args->gid, args->lid);
}
void call_ibv_detach_mcast(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_detach_mcast\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_detach_mcast_t * args = (uhyve_ibv_detach_mcast_t *) (guest_mem + data);
args->ret = ibv_detach_mcast(args->qp, args->gid, args->lid);
}
void call_ibv_fork_init(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_fork_init\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_fork_init_t * args = (uhyve_ibv_fork_init_t *) (guest_mem + data);
args->ret = ibv_fork_init();
}
void call_ibv_node_type_str(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_node_type_str\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_node_type_str_t * args = (uhyve_ibv_node_type_str_t *) (guest_mem + data);
const char * host_ret = ibv_node_type_str(args->node_type); // !
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
}
void call_ibv_port_state_str(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_port_state_str\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_port_state_str_t * args = (uhyve_ibv_port_state_str_t *) (guest_mem + data);
const char * host_ret = ibv_port_state_str(args->port_state); // !
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
}
void call_ibv_event_type_str(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_event_type_str\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_event_type_str_t * args = (uhyve_ibv_event_type_str_t *) (guest_mem + data);
const char * host_ret = ibv_event_type_str(args->event); // !
memcpy(args->ret, host_ret, sizeof(host_ret)); // !
}
void call_ibv_is_qpt_supported(struct kvm_run * run, uint8_t * guest_mem) {
printf("UHYVE call: call_ibv_is_qpt_supported\n");
unsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));
uhyve_ibv_is_qpt_supported_t * args = (uhyve_ibv_is_qpt_supported_t *) (guest_mem + data);
args->ret = ibv_is_qpt_supported(args->caps, args->qpt);
}

View file

@ -24,79 +24,81 @@
#include <stdbool.h>
typedef enum {
UHYVE_PORT_IBV_WC_STATUS_STR = 0x510,
UHYVE_PORT_IBV_RATE_TO_MULT = 0x511,
UHYVE_PORT_MULT_TO_IBV_RATE = 0x512,
UHYVE_PORT_IBV_RATE_TO_MBPS = 0x513,
UHYVE_PORT_MBPS_TO_IBV_RATE = 0x514,
UHYVE_PORT_VERBS_GET_CTX = 0x528,
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x529,
UHYVE_PORT_IBV_FREE_DEVICE_LIST = 0x52A,
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x52B,
UHYVE_PORT_IBV_GET_DEVICE_GUID = 0x52C,
UHYVE_PORT_IBV_OPEN_DEVICE = 0x52D,
UHYVE_PORT_IBV_CLOSE_DEVICE = 0x52E,
UHYVE_PORT_IBV_GET_ASYNC_EVENT = 0x52F,
UHYVE_PORT_IBV_ACK_ASYNC_EVENT = 0x530,
UHYVE_PORT_IBV_QUERY_DEVICE = 0x531,
UHYVE_PORT_IBV_QUERY_PORT = 0x532,
UHYVE_PORT____IBV_QUERY_PORT = 0x533,
UHYVE_PORT_IBV_QUERY_GID = 0x534,
UHYVE_PORT_IBV_QUERY_PKEY = 0x535,
UHYVE_PORT_IBV_ALLOC_PD = 0x536,
UHYVE_PORT_IBV_DEALLOC_PD = 0x537,
UHYVE_PORT_IBV_CREATE_FLOW = 0x538,
UHYVE_PORT_IBV_DESTROY_FLOW = 0x539,
UHYVE_PORT_IBV_OPEN_XRCD = 0x53A,
UHYVE_PORT_IBV_CLOSE_XRCD = 0x53B,
UHYVE_PORT_IBV_REG_MR = 0x53C,
UHYVE_PORT_IBV_REREG_MR = 0x53D,
UHYVE_PORT_IBV_DEREG_MR = 0x53E,
UHYVE_PORT_IBV_ALLOC_MW = 0x53F,
UHYVE_PORT_IBV_DEALLOC_MW = 0x540,
UHYVE_PORT_IBV_INC_RKEY = 0x541,
UHYVE_PORT_IBV_BIND_MW = 0x542,
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x543,
UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x544,
UHYVE_PORT_IBV_CREATE_CQ = 0x545,
UHYVE_PORT_IBV_RESIZE_CQ = 0x547,
UHYVE_PORT_IBV_DESTROY_CQ = 0x548,
UHYVE_PORT_IBV_GET_CQ_EVENT = 0x549,
UHYVE_PORT_IBV_ACK_CQ_EVENTS = 0x54A,
UHYVE_PORT_IBV_POLL_CQ = 0x54B,
UHYVE_PORT_IBV_REQ_NOTIFY_CQ = 0x54C,
UHYVE_PORT_IBV_CREATE_SRQ = 0x54D,
UHYVE_PORT_IBV_CREATE_SRQ_EX = 0x54E,
UHYVE_PORT_IBV_MODIFY_SRQ = 0x54F,
UHYVE_PORT_IBV_QUERY_SRQ = 0x550,
UHYVE_PORT_IBV_GET_SRQ_NUM = 0x551,
UHYVE_PORT_IBV_DESTROY_SRQ = 0x552,
UHYVE_PORT_IBV_POST_SRQ_RECV = 0x553,
UHYVE_PORT_IBV_CREATE_QP = 0x554,
UHYVE_PORT_IBV_CREATE_QP_EX = 0x555,
UHYVE_PORT_IBV_QUERY_DEVICE_EX = 0x557,
UHYVE_PORT_IBV_OPEN_QP = 0x558,
UHYVE_PORT_IBV_MODIFY_QP = 0x559,
UHYVE_PORT_IBV_QUERY_QP = 0x55A,
UHYVE_PORT_IBV_DESTROY_QP = 0x55B,
UHYVE_PORT_IBV_MODIFY_WQ = 0x55D,
UHYVE_PORT_IBV_DESTROY_WQ = 0x55E,
UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE = 0x55F,
UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE = 0x560,
UHYVE_PORT_IBV_POST_SEND = 0x561,
UHYVE_PORT_IBV_POST_RECV = 0x562,
UHYVE_PORT_IBV_CREATE_AH = 0x563,
UHYVE_PORT_IBV_INIT_AH_FROM_WC = 0x564,
UHYVE_PORT_IBV_CREATE_AH_FROM_WC = 0x565,
UHYVE_PORT_IBV_DESTROY_AH = 0x566,
UHYVE_PORT_IBV_ATTACH_MCAST = 0x567,
UHYVE_PORT_IBV_DETACH_MCAST = 0x568,
UHYVE_PORT_IBV_FORK_INIT = 0x569,
UHYVE_PORT_IBV_NODE_TYPE_STR = 0x56A,
UHYVE_PORT_IBV_PORT_STATE_STR = 0x56B,
UHYVE_PORT_IBV_EVENT_TYPE_STR = 0x56C,
UHYVE_PORT_IBV_WC_STATUS_STR = 0x510,
UHYVE_PORT_IBV_RATE_TO_MULT = 0x511,
UHYVE_PORT_MULT_TO_IBV_RATE = 0x512,
UHYVE_PORT_IBV_RATE_TO_MBPS = 0x513,
UHYVE_PORT_MBPS_TO_IBV_RATE = 0x514,
UHYVE_PORT_VERBS_GET_CTX = 0x528,
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x529,
UHYVE_PORT_IBV_FREE_DEVICE_LIST = 0x52A,
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x52B,
UHYVE_PORT_IBV_GET_DEVICE_GUID = 0x52C,
UHYVE_PORT_IBV_OPEN_DEVICE = 0x52D,
UHYVE_PORT_IBV_CLOSE_DEVICE = 0x52E,
UHYVE_PORT_IBV_GET_ASYNC_EVENT = 0x52F,
UHYVE_PORT_IBV_ACK_ASYNC_EVENT = 0x530,
UHYVE_PORT_IBV_QUERY_DEVICE = 0x531,
UHYVE_PORT_IBV_QUERY_PORT = 0x532,
UHYVE_PORT____IBV_QUERY_PORT = 0x533,
UHYVE_PORT_IBV_QUERY_GID = 0x534,
UHYVE_PORT_IBV_QUERY_PKEY = 0x535,
UHYVE_PORT_IBV_ALLOC_PD = 0x536,
UHYVE_PORT_IBV_DEALLOC_PD = 0x537,
UHYVE_PORT_IBV_CREATE_FLOW = 0x538,
UHYVE_PORT_IBV_DESTROY_FLOW = 0x539,
UHYVE_PORT_IBV_OPEN_XRCD = 0x53A,
UHYVE_PORT_IBV_CLOSE_XRCD = 0x53B,
UHYVE_PORT_IBV_REG_MR = 0x53C,
UHYVE_PORT_IBV_REREG_MR = 0x53D,
UHYVE_PORT_IBV_DEREG_MR = 0x53E,
UHYVE_PORT_IBV_ALLOC_MW = 0x53F,
UHYVE_PORT_IBV_DEALLOC_MW = 0x540,
UHYVE_PORT_IBV_INC_RKEY = 0x541,
UHYVE_PORT_IBV_BIND_MW = 0x542,
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x543,
UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x544,
UHYVE_PORT_IBV_CREATE_CQ = 0x545,
UHYVE_PORT_IBV_RESIZE_CQ = 0x547,
UHYVE_PORT_IBV_DESTROY_CQ = 0x548,
UHYVE_PORT_IBV_GET_CQ_EVENT = 0x549,
UHYVE_PORT_IBV_ACK_CQ_EVENTS = 0x54A,
UHYVE_PORT_IBV_POLL_CQ = 0x54B,
UHYVE_PORT_IBV_REQ_NOTIFY_CQ = 0x54C,
UHYVE_PORT_IBV_CREATE_SRQ = 0x54D,
UHYVE_PORT_IBV_CREATE_SRQ_EX = 0x54E,
UHYVE_PORT_IBV_MODIFY_SRQ = 0x54F,
UHYVE_PORT_IBV_QUERY_SRQ = 0x550,
UHYVE_PORT_IBV_GET_SRQ_NUM = 0x551,
UHYVE_PORT_IBV_DESTROY_SRQ = 0x552,
UHYVE_PORT_IBV_POST_SRQ_RECV = 0x553,
UHYVE_PORT_IBV_CREATE_QP = 0x554,
UHYVE_PORT_IBV_CREATE_QP_EX = 0x555,
UHYVE_PORT_IBV_QUERY_DEVICE_EX = 0x557,
UHYVE_PORT_IBV_OPEN_QP = 0x558,
UHYVE_PORT_IBV_MODIFY_QP = 0x559,
UHYVE_PORT_IBV_QUERY_QP = 0x55A,
UHYVE_PORT_IBV_DESTROY_QP = 0x55B,
UHYVE_PORT_IBV_MODIFY_WQ = 0x55D,
UHYVE_PORT_IBV_DESTROY_WQ = 0x55E,
UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE = 0x55F,
UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE = 0x560,
UHYVE_PORT_IBV_POST_SEND = 0x561,
UHYVE_PORT_IBV_POST_RECV = 0x562,
UHYVE_PORT_IBV_CREATE_AH = 0x563,
UHYVE_PORT_IBV_INIT_AH_FROM_WC = 0x564,
UHYVE_PORT_IBV_CREATE_AH_FROM_WC = 0x565,
UHYVE_PORT_IBV_DESTROY_AH = 0x566,
UHYVE_PORT_IBV_ATTACH_MCAST = 0x567,
UHYVE_PORT_IBV_DETACH_MCAST = 0x568,
UHYVE_PORT_IBV_FORK_INIT = 0x569,
UHYVE_PORT_IBV_NODE_TYPE_STR = 0x56A,
UHYVE_PORT_IBV_PORT_STATE_STR = 0x56B,
UHYVE_PORT_IBV_EVENT_TYPE_STR = 0x56C,
UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID = 0x56D,
UHYVE_PORT_IBV_IS_QPT_SUPPORTED = 0x56E,
UHYVE_PORT_IBV_IS_QPT_SUPPORTED = 0x56E,
UHYVE_PORT_IBV_GET_MR_LKEY = 0x56F,
UHYVE_PORT_IBV_GET_QP_NUM = 0x570,
} uhyve_ibv_t;
typedef struct {
@ -640,6 +642,20 @@ typedef struct {
int ret;
} __attribute__((packed)) uhyve_ibv_is_qpt_supported_t;
typedef struct {
// Parameters:
struct ibv_mr * mr;
// Return value:
uint32_t ret;
} __attribute__((packed)) uhyve_ibv_get_mr_lkey_t;
typedef struct {
// Parameters:
struct ibv_qp * qp;
// Return value:
uint32_t ret;
} __attribute__((packed)) uhyve_ibv_get_qp_num_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);
@ -715,5 +731,7 @@ void call_ibv_port_state_str (struct kvm_run * run, uint8_t * guest_me
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);
void call_ibv_get_mr_lkey (struct kvm_run * run, uint8_t * guest_mem);
void call_ibv_get_qp_num (struct kvm_run * run, uint8_t * guest_mem);
#endif // UHYVE_IBV_H

View file

@ -1113,6 +1113,12 @@ static int vcpu_loop(void)
case UHYVE_PORT_IBV_IS_QPT_SUPPORTED:
call_ibv_is_qpt_supported(run, guest_mem);
break;
case UHYVE_PORT_IBV_GET_MR_LKEY:
call_ibv_get_mr_lkey(run, guest_mem);
break;
case UHYVE_PORT_IBV_GET_QP_NUM:
call_ibv_get_qp_num(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);

View file

@ -95,6 +95,7 @@ struct pingpong_dest {
static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
int sl, struct pingpong_dest *dest, int sgid_idx)
{
printf("Entered pp_connect_ctx().\n");
struct ibv_ah_attr ah_attr = {
.is_global = 0,
.dlid = dest->lid,
@ -140,6 +141,7 @@ static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
static struct pingpong_dest *pp_client_exch_dest(const char *servername, int port,
const struct pingpong_dest *my_dest)
{
printf("Entered pp_client_exch_dest().\n");
struct addrinfo *res, *t;
struct addrinfo hints = {
.ai_family = AF_UNSPEC,
@ -214,6 +216,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
const struct pingpong_dest *my_dest,
int sgid_idx)
{
printf("Entered pp_server_exch_dest().\n");
struct addrinfo *res, *t;
struct addrinfo hints = {
.ai_flags = AI_PASSIVE,
@ -245,8 +248,9 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);
if (!bind(sockfd, t->ai_addr, t->ai_addrlen))
if (!bind(sockfd, t->ai_addr, t->ai_addrlen)) {
break;
}
close(sockfd);
sockfd = -1;
}
@ -261,7 +265,9 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
}
listen(sockfd, 1);
printf("\tAfter listen.\n");
connfd = accept(sockfd, NULL, NULL);
printf("\tBefore close.\n");
close(sockfd);
if (connfd < 0) {
fprintf(stderr, "accept() failed\n");
@ -275,6 +281,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
goto out;
}
printf("\tBefore malloc.\n");
rem_dest = malloc(sizeof *rem_dest);
if (!rem_dest)
goto out;
@ -283,6 +290,7 @@ static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
&rem_dest->psn, gid);
wire_gid_to_gid(gid, &rem_dest->gid);
printf("\tBefore pp_connect_ctx().\n");
if (pp_connect_ctx(ctx, ib_port, my_dest->psn, sl, rem_dest,
sgid_idx)) {
fprintf(stderr, "Couldn't connect to remote QP\n");
@ -310,6 +318,7 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
int rx_depth, int port,
int use_event)
{
printf("Entered pp_init_ctx().\n");
struct pingpong_context *ctx;
ctx = malloc(sizeof *ctx);
@ -454,6 +463,7 @@ clean_ctx:
static int pp_close_ctx(struct pingpong_context *ctx)
{
printf("Entered pp_close_ctx().\n");
if (ibv_destroy_qp(ctx->qp)) {
fprintf(stderr, "Couldn't destroy QP\n");
return 1;
@ -497,25 +507,14 @@ static int pp_close_ctx(struct pingpong_context *ctx)
return 0;
}
// struct ibv_recv_wr {
// uint64_t wr_id;
// struct ibv_recv_wr *next;
// struct ibv_sge *sg_list;
// int num_sge;
// };
// struct ibv_sge { // scatter/gather element
// uint64_t addr; // might have to be converted
// uint32_t length;
// uint32_t lkey;
// };
static int pp_post_recv(struct pingpong_context *ctx, int n)
{
printf("Entered pp_post_recv().\n");
struct ibv_sge list = {
.addr = (uintptr_t) ctx->buf,
.length = ctx->size + 40,
.lkey = ctx->mr->lkey
/* .lkey = ctx->mr->lkey */
.lkey = ibv_get_mr_lkey(ctx->mr)
};
struct ibv_recv_wr wr = {
.wr_id = PINGPONG_RECV_WRID,
@ -525,7 +524,6 @@ static int pp_post_recv(struct pingpong_context *ctx, int n)
struct ibv_recv_wr *bad_wr;
int i;
printf("before for loop calling ibv_post_recv().\n");
for (i = 0; i < n; ++i) {
printf("loop.\n");
if (ibv_post_recv(ctx->qp, &wr, &bad_wr))
@ -533,10 +531,12 @@ static int pp_post_recv(struct pingpong_context *ctx, int n)
}
return i;
printf("Finished pp_post_recv().\n");
}
static int pp_post_send(struct pingpong_context *ctx, uint32_t qpn)
{
printf("Entered pp_post_send().\n");
struct ibv_sge list = {
.addr = (uintptr_t) ctx->buf + 40,
.length = ctx->size,
@ -559,6 +559,7 @@ static int pp_post_send(struct pingpong_context *ctx, uint32_t qpn)
struct ibv_send_wr *bad_wr;
return ibv_post_send(ctx->qp, &wr, &bad_wr);
printf("Finished pp_post_send().\n");
}
static void usage(const char *argv0)
@ -676,8 +677,10 @@ int main(int argc, char *argv[])
}
}
if (optind == argc - 1)
if (optind == argc - 1) {
servername = strdupa(argv[optind]);
printf("Servername set.\n");
}
else if (optind < argc) {
usage(argv[0]);
return 1;
@ -713,28 +716,27 @@ int main(int argc, char *argv[])
if (!ctx)
return 1;
/* printf("before pp_post_recv.\n"); */
routs = pp_post_recv(ctx, ctx->rx_depth);
/* printf("after pp_post_recv.\n"); */
if (routs < ctx->rx_depth) {
fprintf(stderr, "Couldn't post receive (%d)\n", routs);
return 1;
}
/* printf("Before if(use_event).\n"); */
if (use_event)
if (ibv_req_notify_cq(ctx->cq, 0)) {
fprintf(stderr, "Couldn't request CQ notification\n");
return 1;
}
if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) {
if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) { // ibv_query_port
fprintf(stderr, "Couldn't get port info\n");
return 1;
}
printf("After pp_get_port_info()\n");
/* printf("After pp_get_port_info(), containing ibv_query_port()\n"); */
my_dest.lid = ctx->portinfo.lid;
my_dest.qpn = ctx->qp->qp_num;
my_dest.qpn = ibv_get_qp_num(ctx->qp);
my_dest.psn = lrand48() & 0xffffff;
if (gidx >= 0) {
@ -746,16 +748,15 @@ int main(int argc, char *argv[])
} else
memset(&my_dest.gid, 0, sizeof my_dest.gid);
// TODO: fix me
/* inet_ntop(AF_INET6, &my_dest.gid, gid, sizeof gid); */
/* printf(" local address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x: GID %s\n", */
/* my_dest.lid, my_dest.qpn, my_dest.psn, gid); */
printf("if servername()\n");
if (servername)
rem_dest = pp_client_exch_dest(servername, port, &my_dest); // no ibv calls
rem_dest = pp_client_exch_dest(servername, port, &my_dest);
else
rem_dest = pp_server_exch_dest(ctx, ib_port, port, sl, // no ibv calls
&my_dest, gidx);
rem_dest = pp_server_exch_dest(ctx, ib_port, port, sl, &my_dest, gidx);
if (!rem_dest)
return 1;
@ -766,8 +767,7 @@ int main(int argc, char *argv[])
printf("if servername() 2\n");
if (servername)
if (pp_connect_ctx(ctx, ib_port, my_dest.psn, sl, rem_dest,
gidx))
if (pp_connect_ctx(ctx, ib_port, my_dest.psn, sl, rem_dest, gidx))
return 1;
ctx->pending = PINGPONG_RECV_WRID;