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

Basic struct parsing supported. Prepared for first manual address conversion tests.

This commit is contained in:
Annika Wierichs 2017-11-08 14:32:50 +01:00
parent fb3b0cdbb8
commit 69d8226c13
17 changed files with 305 additions and 1347 deletions

View file

@ -68,22 +68,11 @@ extern const size_t image_size;
// InfiniBand uhyve port IDs
#define UHYVE_PORT_IBV_OPEN_DEVICE 0x510,
#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x511,
//#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x511,
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x512,
#define UHYVE_PORT_IBV_QUERY_PORT 0x513,
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x514,
#define UHYVE_PORT_IBV_ALLOC_PD 0x515,
#define UHYVE_PORT_IBV_REG_MR 0x516,
#define UHYVE_PORT_IBV_CREATE_CQ 0x517,
#define UHYVE_PORT_IBV_CREATE_QP 0x518,
#define UHYVE_PORT_IBV_QUERY_QP 0x519,
#define UHYVE_PORT_IBV_MODIFY_QP 0x51A,
#define UHYVE_PORT_IBV_DESTROY_QP 0x51B,
#define UHYVE_PORT_IBV_DESTROY_CQ 0x51C,
#define UHYVE_PORT_IBV_DEREG_MR 0x51D,
#define UHYVE_PORT_IBV_DEALLOC_PD 0x51E,
#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x51F,
#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x520,
#define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b))
//#define BUILTIN_EXPECT(exp, b) (exp)

View file

@ -42,48 +42,42 @@
#define MAX_NUM_OF_IBV_DEVICES 16
typedef struct { // CHECKED
// Parameters:
int , *num_devices;
// Return value:
struct ibv_device *dev_phys_ptr_list[MAX_NUM_OF_IBV_DEVICES];
// TODO: Can we make the return type struct ibv_device**?
} __attribute__((packed)) uhyve_ibv_get_device_list_t;
/*typedef struct { // CHECKED*/
/*// Parameters:*/
/*int , *num_devices;*/
/*// Return value:*/
/*struct ibv_device *dev_phys_ptr_list[MAX_NUM_OF_IBV_DEVICES];*/
/*// TODO: Can we make the return type struct ibv_device**?*/
/*} __attribute__((packed)) uhyve_ibv_get_device_list_t;*/
struct ibv_device** ibv_get_device_list(int *num_devices) {
// num_devices can be mapped to physical memory right away.
uhyve_ibv_get_device_list_t uhyve_args = {
(int*) virt_to_phys((size_t) num_devices)
};
/*struct ibv_device** ibv_get_device_list(int *num_devices) {*/
/*// num_devices can be mapped to physical memory right away.*/
/*uhyve_ibv_get_device_list_t uhyve_args = {*/
/*(int*) virt_to_phys((size_t) num_devices)*/
/*};*/
// Allocate memory for return value.
struct ibv_device *devs = kmalloc(MAX_NUM_OF_IBV_DEVICES * sizeof(struct ibv_device));
struct ibv_device **list_virt = kmalloc(MAX_NUM_OF_IBV_DEVICES * sizeof(struct ibv_device *));
/*// Allocate memory for return value.*/
/*struct ibv_device *devs = kmalloc(MAX_NUM_OF_IBV_DEVICES * sizeof(struct ibv_device));*/
/*struct ibv_device **list_virt = kmalloc(MAX_NUM_OF_IBV_DEVICES * sizeof(struct ibv_device *));*/
// We keep a list of the virtual addresses, so we can return it later, and map
// to physical addresses for the args struct passed to uhyve.
for (int i = 0; i < MAX_NUM_OF_IBV_DEVICES; i++) {
struct ibv_device* device_address = devs + i;
list_virt[i] = device_address;
uhyve_args.dev_phys_ptr_list[i] = (struct ibv_device*) virt_to_phys((size_t) device_address);
}
/*// We keep a list of the virtual addresses, so we can return it later, and map*/
/*// to physical addresses for the args struct passed to uhyve.*/
/*for (int i = 0; i < MAX_NUM_OF_IBV_DEVICES; i++) {*/
/*struct ibv_device* device_address = devs + i;*/
/*list_virt[i] = device_address;*/
/*uhyve_args.dev_phys_ptr_list[i] = (struct ibv_device*) virt_to_phys((size_t) device_address);*/
/*}*/
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned)virt_to_phys((size_t)&uhyve_args));
return list_virt;
}
const char* ibv_get_device_name(struct ibv_device *device) {
// TODO: Also forward this to uhyve for consistency?
return device->name;
}
/*uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned)virt_to_phys((size_t)&uhyve_args));*/
/*return list_virt;*/
/*}*/
typedef struct {
// Parameters:
struct ibv_device * device;
// Return value:
struct ibv_context * ret; // TODO
struct ibv_context * ret;
} __attribute__((packed)) uhyve_ibv_open_device_t;
struct ibv_context * ibv_open_device(struct ibv_device * device) {
@ -99,337 +93,63 @@ struct ibv_context * ibv_open_device(struct ibv_device * device) {
}
/*typedef struct {*/
/*// Parameters:*/
/*int * num_devices;*/
/*// Return value:*/
/*struct ibv_device ** ret; // TODO*/
/*} __attribute__((packed)) uhyve_ibv_get_device_list_t;*/
typedef struct {
// Parameters:
struct ibv_device * device;
// Return value:
const char * ret;
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
/*struct ibv_device ** ibv_get_device_list(int * num_devices) {*/
/*uhyve_ibv_get_device_list_t uhyve_args;*/
/*uhyve_args->num_devices = (int *) virt_to_phys((size_t) num_devices);*/
const char * ibv_get_device_name(struct ibv_device * device) {
uhyve_ibv_get_device_name_t uhyve_args;
uhyve_args->device = (struct ibv_device *) virt_to_phys((size_t) device);
/*// TODO: Take care of return value.*/
uhyve_args->ret = kmalloc(sizeof(const char));
/*uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_NAME, (unsigned) virt_to_phys((size_t) &uhyve_args));
/*return uhyve_args.ret;*/
/*// TODO: Fix pointers in returned data structures.*/
/*}*/
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
/*typedef struct {*/
/*// Parameters:*/
/*struct ibv_device * device;*/
/*// Return value:*/
/*const char * ret; // TODO*/
/*} __attribute__((packed)) uhyve_ibv_get_device_name_t;*/
typedef struct {
// Parameters:
struct ibv_context * context;
uint8_t port_num;
struct ibv_port_attr * port_attr;
// Return value:
int ret;
} __attribute__((packed)) uhyve_ibv_query_port_t;
/*const char * ibv_get_device_name(struct ibv_device * device) {*/
/*uhyve_ibv_get_device_name_t uhyve_args;*/
/*uhyve_args->device = (struct ibv_device *) virt_to_phys((size_t) device);*/
int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr) {
uhyve_ibv_query_port_t uhyve_args;
uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);
uhyve_args->port_num = port_num;
uhyve_args->port_attr = (struct ibv_port_attr *) virt_to_phys((size_t) port_attr);
/*uhyve_args->ret = kmalloc(sizeof(const char));*/
uhyve_send(UHYVE_PORT_IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args));
/*uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_NAME, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
typedef struct {
// Parameters:
struct ibv_context * context;
// Return value:
struct ibv_comp_channel * ret;
} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;
/*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;*/
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context) {
uhyve_ibv_create_comp_channel_t uhyve_args;
uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);
/*int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr) {*/
/*uhyve_ibv_query_port_t uhyve_args;*/
/*uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);*/
/*uhyve_args->port_num = port_num;*/
/*uhyve_args->port_attr = (struct ibv_port_attr *) virt_to_phys((size_t) port_attr);*/
/*uhyve_send(UHYVE_PORT_IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*return uhyve_args.ret;*/
/*}*/
/*typedef struct {*/
/*// Parameters:*/
/*struct ibv_context * context;*/
/*// Return value:*/
/*struct ibv_comp_channel * ret; // TODO*/
/*} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;*/
/*struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context) {*/
/*uhyve_ibv_create_comp_channel_t uhyve_args;*/
/*uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);*/
/*uhyve_args->ret = kmalloc(sizeof(struct ibv_comp_channel));*/
/*uhyve_send(UHYVE_PORT_IBV_CREATE_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*typedef struct {*/
/*// Parameters:*/
/*struct ibv_context * context;*/
/*// Return value:*/
/*struct ibv_pd * ret; // TODO*/
/*} __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 = (struct ibv_context *) virt_to_phys((size_t) context);*/
/*uhyve_args->ret = kmalloc(sizeof(struct ibv_pd));*/
/*uhyve_send(UHYVE_PORT_IBV_ALLOC_PD, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*typedef struct {*/
/*// Parameters:*/
/*struct ibv_pd * pd;*/
/*void * addr;*/
/*int length;*/
/*int access;*/
/*// Return value:*/
/*struct ibv_mr * ret; // TODO*/
/*} __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 = (struct ibv_pd *) virt_to_phys((size_t) pd);*/
/*uhyve_args->addr = (void *) virt_to_phys((size_t) addr);*/
/*uhyve_args->length = length;*/
/*uhyve_args->access = access;*/
/*uhyve_args->ret = kmalloc(sizeof(struct ibv_mr));*/
/*uhyve_send(UHYVE_PORT_IBV_REG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*typedef struct {*/
/*// Parameters:*/
/*struct ibv_context * context;*/
/*int cqe;*/
/*void * cq_context;*/
/*struct ibv_comp_channel * channel;*/
/*int comp_vector;*/
/*// Return value:*/
/*struct ibv_cq * ret; // TODO*/
/*} __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 = (struct ibv_context *) virt_to_phys((size_t) context);*/
/*uhyve_args->cqe = cqe;*/
/*uhyve_args->cq_context = (void *) virt_to_phys((size_t) cq_context);*/
/*uhyve_args->channel = (struct ibv_comp_channel *) virt_to_phys((size_t) channel);*/
/*uhyve_args->comp_vector = comp_vector;*/
/*uhyve_args->ret = kmalloc(sizeof(struct ibv_cq));*/
/*uhyve_send(UHYVE_PORT_IBV_CREATE_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*typedef struct {*/
/*// Parameters:*/
/*struct ibv_pd * pd;*/
/*struct ibv_qp_init_attr * qp_init_attr;*/
/*// Return value:*/
/*struct ibv_qp * ret; // TODO*/
/*} __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 = (struct ibv_pd *) virt_to_phys((size_t) pd);*/
/*uhyve_args->qp_init_attr = (struct ibv_qp_init_attr *) virt_to_phys((size_t) qp_init_attr);*/
/*uhyve_args->ret = kmalloc(sizeof(struct ibv_qp));*/
/*uhyve_send(UHYVE_PORT_IBV_CREATE_QP, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*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 = (struct ibv_qp *) virt_to_phys((size_t) qp);*/
/*uhyve_args->attr = (struct ibv_qp_attr *) virt_to_phys((size_t) attr);*/
/*uhyve_args->attr_mask = attr_mask;*/
/*uhyve_args->init_attr = (struct ibv_qp_init_attr *) virt_to_phys((size_t) init_attr);*/
/*uhyve_send(UHYVE_PORT_IBV_QUERY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*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 = (struct ibv_qp *) virt_to_phys((size_t) qp);*/
/*uhyve_args->attr = (struct ibv_qp_attr *) virt_to_phys((size_t) attr);*/
/*uhyve_args->attr_mask = attr_mask;*/
/*uhyve_send(UHYVE_PORT_IBV_MODIFY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*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 = (struct ibv_qp *) virt_to_phys((size_t) qp);*/
/*uhyve_send(UHYVE_PORT_IBV_DESTROY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*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 = (struct ibv_cq *) virt_to_phys((size_t) cq);*/
/*uhyve_send(UHYVE_PORT_IBV_DESTROY_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*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 = (struct ibv_mr *) virt_to_phys((size_t) mr);*/
/*uhyve_send(UHYVE_PORT_IBV_DEREG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*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 = (struct ibv_pd *) virt_to_phys((size_t) pd);*/
/*uhyve_send(UHYVE_PORT_IBV_DEALLOC_PD, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*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 = (struct ibv_comp_channel *) virt_to_phys((size_t) channel);*/
/*uhyve_send(UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
/*typedef struct {*/
/*// Parameters:*/
/*struct ibv_context * context;*/
/*// Return value:*/
/*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 = (struct ibv_context *) virt_to_phys((size_t) context);*/
/*uhyve_send(UHYVE_PORT_IBV_CLOSE_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args));*/
/*// TODO: Fix pointers in returned data structures.*/
/*return uhyve_args.ret;*/
/*}*/
uhyve_args->ret = kmalloc(sizeof(struct ibv_comp_channel));
uhyve_send(UHYVE_PORT_IBV_CREATE_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}

View file

@ -1,18 +1,5 @@
#define UHYVE_PORT_IBV_OPEN_DEVICE 0x510,
#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x511,
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x512,
#define UHYVE_PORT_IBV_QUERY_PORT 0x513,
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x514,
#define UHYVE_PORT_IBV_ALLOC_PD 0x515,
#define UHYVE_PORT_IBV_REG_MR 0x516,
#define UHYVE_PORT_IBV_CREATE_CQ 0x517,
#define UHYVE_PORT_IBV_CREATE_QP 0x518,
#define UHYVE_PORT_IBV_QUERY_QP 0x519,
#define UHYVE_PORT_IBV_MODIFY_QP 0x51A,
#define UHYVE_PORT_IBV_DESTROY_QP 0x51B,
#define UHYVE_PORT_IBV_DESTROY_CQ 0x51C,
#define UHYVE_PORT_IBV_DEREG_MR 0x51D,
#define UHYVE_PORT_IBV_DEALLOC_PD 0x51E,
#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x51F,
#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x520,
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x511,
#define UHYVE_PORT_IBV_QUERY_PORT 0x512,
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x513,

View file

@ -18,26 +18,6 @@ struct ibv_context * ibv_open_device(struct ibv_device * device) {
}
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 = (int *) virt_to_phys((size_t) num_devices);
// TODO: Take care of return value.
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
typedef struct {
// Parameters:
struct ibv_device * device;
@ -98,255 +78,3 @@ struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context)
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_context *) virt_to_phys((size_t) context);
uhyve_args->ret = kmalloc(sizeof(struct ibv_pd));
uhyve_send(UHYVE_PORT_IBV_ALLOC_PD, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_pd *) virt_to_phys((size_t) pd);
uhyve_args->addr = (void *) virt_to_phys((size_t) addr);
uhyve_args->length = length;
uhyve_args->access = access;
uhyve_args->ret = kmalloc(sizeof(struct ibv_mr));
uhyve_send(UHYVE_PORT_IBV_REG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
typedef struct {
// Parameters:
struct ibv_context * context;
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 = (struct ibv_context *) virt_to_phys((size_t) context);
uhyve_args->cqe = cqe;
uhyve_args->cq_context = (void *) virt_to_phys((size_t) cq_context);
uhyve_args->channel = (struct ibv_comp_channel *) virt_to_phys((size_t) channel);
uhyve_args->comp_vector = comp_vector;
uhyve_args->ret = kmalloc(sizeof(struct ibv_cq));
uhyve_send(UHYVE_PORT_IBV_CREATE_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_pd *) virt_to_phys((size_t) pd);
uhyve_args->qp_init_attr = (struct ibv_qp_init_attr *) virt_to_phys((size_t) qp_init_attr);
uhyve_args->ret = kmalloc(sizeof(struct ibv_qp));
uhyve_send(UHYVE_PORT_IBV_CREATE_QP, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_qp *) virt_to_phys((size_t) qp);
uhyve_args->attr = (struct ibv_qp_attr *) virt_to_phys((size_t) attr);
uhyve_args->attr_mask = attr_mask;
uhyve_args->init_attr = (struct ibv_qp_init_attr *) virt_to_phys((size_t) init_attr);
uhyve_send(UHYVE_PORT_IBV_QUERY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_qp *) virt_to_phys((size_t) qp);
uhyve_args->attr = (struct ibv_qp_attr *) virt_to_phys((size_t) attr);
uhyve_args->attr_mask = attr_mask;
uhyve_send(UHYVE_PORT_IBV_MODIFY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_qp *) virt_to_phys((size_t) qp);
uhyve_send(UHYVE_PORT_IBV_DESTROY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_cq *) virt_to_phys((size_t) cq);
uhyve_send(UHYVE_PORT_IBV_DESTROY_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_mr *) virt_to_phys((size_t) mr);
uhyve_send(UHYVE_PORT_IBV_DEREG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_pd *) virt_to_phys((size_t) pd);
uhyve_send(UHYVE_PORT_IBV_DEALLOC_PD, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
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 = (struct ibv_comp_channel *) virt_to_phys((size_t) channel);
uhyve_send(UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}
typedef struct {
// Parameters:
struct ibv_context * context;
// Return value:
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 = (struct ibv_context *) virt_to_phys((size_t) context);
uhyve_send(UHYVE_PORT_IBV_CLOSE_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args));
// TODO: Fix pointers in returned data structures.
return uhyve_args.ret;
}

View file

@ -1,19 +1,6 @@
typedef enum {
UHYVE_PORT_IBV_OPEN_DEVICE = 0x510,
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x511,
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x512,
UHYVE_PORT_IBV_QUERY_PORT = 0x513,
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x514,
UHYVE_PORT_IBV_ALLOC_PD = 0x515,
UHYVE_PORT_IBV_REG_MR = 0x516,
UHYVE_PORT_IBV_CREATE_CQ = 0x517,
UHYVE_PORT_IBV_CREATE_QP = 0x518,
UHYVE_PORT_IBV_QUERY_QP = 0x519,
UHYVE_PORT_IBV_MODIFY_QP = 0x51A,
UHYVE_PORT_IBV_DESTROY_QP = 0x51B,
UHYVE_PORT_IBV_DESTROY_CQ = 0x51C,
UHYVE_PORT_IBV_DEREG_MR = 0x51D,
UHYVE_PORT_IBV_DEALLOC_PD = 0x51E,
UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x51F,
UHYVE_PORT_IBV_CLOSE_DEVICE = 0x520,
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x511,
UHYVE_PORT_IBV_QUERY_PORT = 0x512,
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x513,
} uhyve_ibv_t;

View file

@ -5,13 +5,6 @@ typedef struct {
struct ibv_context * ret;
} __attribute__((packed)) uhyve_ibv_open_device_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 * device;
@ -35,100 +28,3 @@ typedef struct {
struct ibv_comp_channel * ret;
} __attribute__((packed)) uhyve_ibv_create_comp_channel_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;
void * addr;
int length;
int access;
// Return value:
struct ibv_mr * ret;
} __attribute__((packed)) uhyve_ibv_reg_mr_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_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_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;
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;
// Return value:
int ret;
} __attribute__((packed)) uhyve_ibv_destroy_qp_t;
typedef struct {
// Parameters:
struct ibv_cq * cq;
// Return value:
int ret;
} __attribute__((packed)) uhyve_ibv_destroy_cq_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;
// Return value:
int ret;
} __attribute__((packed)) uhyve_ibv_dealloc_pd_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;
// Return value:
int ret;
} __attribute__((packed)) uhyve_ibv_close_device_t;

View file

@ -3,25 +3,17 @@ 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);
struct ibv_context * host_ret = (guest_mem+(size_t)args->device);
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_get_device_list(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_get_device_list_t * args = (uhyve_ibv_get_device_list_t *) (guest_mem + data);
struct ibv_device ** host_ret = (guest_mem+(size_t)args->num_devices);
// TODO: Take care of struct ibv_device ** return value.
}
void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem) {
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 = (guest_mem+(size_t)args->device);
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.
@ -31,7 +23,7 @@ void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_query_port_t * args = (uhyve_ibv_query_port_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->context, port_num, guest_mem+(size_t)args->port_attr);
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;
}
@ -39,112 +31,8 @@ void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
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 = (guest_mem+(size_t)args->context);
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.
}
void call_ibv_alloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_alloc_pd_t * args = (uhyve_ibv_alloc_pd_t *) (guest_mem + data);
struct ibv_pd * host_ret = (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.
}
void call_ibv_reg_mr(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_reg_mr_t * args = (uhyve_ibv_reg_mr_t *) (guest_mem + data);
struct ibv_mr * host_ret = (guest_mem+(size_t)args->pd, guest_mem+(size_t)args->addr, length, access);
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_create_cq(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_create_cq_t * args = (uhyve_ibv_create_cq_t *) (guest_mem + data);
struct ibv_cq * host_ret = (guest_mem+(size_t)args->context, cqe, guest_mem+(size_t)args->cq_context, guest_mem+(size_t)args->channel, comp_vector);
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_create_qp(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_create_qp_t * args = (uhyve_ibv_create_qp_t *) (guest_mem + data);
struct ibv_qp * host_ret = (guest_mem+(size_t)args->pd, guest_mem+(size_t)args->qp_init_attr);
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_query_qp(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_query_qp_t * args = (uhyve_ibv_query_qp_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->qp, guest_mem+(size_t)args->attr, attr_mask, guest_mem+(size_t)args->init_attr);
args->ret = host_ret;
}
void call_ibv_modify_qp(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_modify_qp_t * args = (uhyve_ibv_modify_qp_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->qp, guest_mem+(size_t)args->attr, attr_mask);
args->ret = host_ret;
}
void call_ibv_destroy_qp(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_destroy_qp_t * args = (uhyve_ibv_destroy_qp_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->qp);
args->ret = host_ret;
}
void call_ibv_destroy_cq(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_destroy_cq_t * args = (uhyve_ibv_destroy_cq_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->cq);
args->ret = host_ret;
}
void call_ibv_dereg_mr(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_dereg_mr_t * args = (uhyve_ibv_dereg_mr_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->mr);
args->ret = host_ret;
}
void call_ibv_dealloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_dealloc_pd_t * args = (uhyve_ibv_dealloc_pd_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->pd);
args->ret = host_ret;
}
void call_ibv_destroy_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_destroy_comp_channel_t * args = (uhyve_ibv_destroy_comp_channel_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->channel);
args->ret = host_ret;
}
void call_ibv_close_device(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_close_device_t * args = (uhyve_ibv_close_device_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->context);
args->ret = host_ret;
}

View file

@ -2,9 +2,6 @@
case UHYVE_PORT_IBV_OPEN_DEVICE:
call_ibv_open_device(run, guest_mem);
break;
case UHYVE_PORT_IBV_GET_DEVICE_LIST:
call_ibv_get_device_list(run, guest_mem);
break;
case UHYVE_PORT_IBV_GET_DEVICE_NAME:
call_ibv_get_device_name(run, guest_mem);
break;
@ -13,40 +10,4 @@
break;
case UHYVE_PORT_IBV_CREATE_COMP_CHANNEL:
call_ibv_create_comp_channel(run, guest_mem);
break;
case UHYVE_PORT_IBV_ALLOC_PD:
call_ibv_alloc_pd(run, guest_mem);
break;
case UHYVE_PORT_IBV_REG_MR:
call_ibv_reg_mr(run, guest_mem);
break;
case UHYVE_PORT_IBV_CREATE_CQ:
call_ibv_create_cq(run, guest_mem);
break;
case UHYVE_PORT_IBV_CREATE_QP:
call_ibv_create_qp(run, guest_mem);
break;
case UHYVE_PORT_IBV_QUERY_QP:
call_ibv_query_qp(run, guest_mem);
break;
case UHYVE_PORT_IBV_MODIFY_QP:
call_ibv_modify_qp(run, guest_mem);
break;
case UHYVE_PORT_IBV_DESTROY_QP:
call_ibv_destroy_qp(run, guest_mem);
break;
case UHYVE_PORT_IBV_DESTROY_CQ:
call_ibv_destroy_cq(run, guest_mem);
break;
case UHYVE_PORT_IBV_DEREG_MR:
call_ibv_dereg_mr(run, guest_mem);
break;
case UHYVE_PORT_IBV_DEALLOC_PD:
call_ibv_dealloc_pd(run, guest_mem);
break;
case UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL:
call_ibv_destroy_comp_channel(run, guest_mem);
break;
case UHYVE_PORT_IBV_CLOSE_DEVICE:
call_ibv_close_device(run, guest_mem);
break;

View file

@ -1,17 +1,4 @@
struct ibv_context * ibv_open_device(struct ibv_device * device)
struct ibv_device ** ibv_get_device_list(int * num_devices)
const char * ibv_get_device_name(struct ibv_device * device)
int ibv_query_port(struct ibv_context * context,uint8_t port_num,struct ibv_port_attr * port_attr)
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context)
struct ibv_pd * ibv_alloc_pd(struct ibv_context * context)
struct ibv_mr * ibv_reg_mr(struct ibv_pd * pd,void * addr,int length,int access)
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_qp * ibv_create_qp(struct ibv_pd * pd,struct ibv_qp_init_attr * qp_init_attr)
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_modify_qp(struct ibv_qp * qp,struct ibv_qp_attr * attr,int attr_mask)
int ibv_destroy_qp(struct ibv_qp * qp)
int ibv_destroy_cq(struct ibv_cq * cq)
int ibv_dereg_mr(struct ibv_mr * mr)
int ibv_dealloc_pd(struct ibv_pd * pd)
int ibv_destroy_comp_channel(struct ibv_comp_channel * channel)
int ibv_close_device(struct ibv_context * context)

View file

@ -0,0 +1,18 @@
struct ibv_context * ibv_open_device(struct ibv_device * device)
const char * ibv_get_device_name(struct ibv_device * device)
int ibv_query_port(struct ibv_context * context,uint8_t port_num,struct ibv_port_attr * port_attr)
struct ibv_device ** ibv_get_device_list(int * num_devices)
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context)
struct ibv_pd * ibv_alloc_pd(struct ibv_context * context)
struct ibv_mr * ibv_reg_mr(struct ibv_pd * pd,void * addr,int length,int access)
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_qp * ibv_create_qp(struct ibv_pd * pd,struct ibv_qp_init_attr * qp_init_attr)
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_modify_qp(struct ibv_qp * qp,struct ibv_qp_attr * attr,int attr_mask)
int ibv_destroy_qp(struct ibv_qp * qp)
int ibv_destroy_cq(struct ibv_cq * cq)
int ibv_dereg_mr(struct ibv_mr * mr)
int ibv_dealloc_pd(struct ibv_pd * pd)
int ibv_destroy_comp_channel(struct ibv_comp_channel * channel)
int ibv_close_device(struct ibv_context * context)

View file

@ -279,7 +279,7 @@ def generate_uhyve_host_function(ret, function_name, params):
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 = {1}(".format(NEWLINES[2], TABS[1], ret, function_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) + ", "
@ -341,25 +341,26 @@ def generate_struct_conversions():
pp.Literal("{").suppress())
struct_footer = pp.Literal("};").suppress()
# member_name = word + pp.Literal(";")#.suppress()
# variable_type = (pp.OneOrMore(word) + pp.ZeroOrMore("*") +
# pp.FollowedBy(member_name))
# variable_type = (pp.Combine(pp.OneOrMore(word)) + pp.ZeroOrMore("*") +
# pp.FollowedBy(member_name))
# struct_member = variable_type + member_name
# struct_body = pp.OneOrMore(struct_member)
member_var = word + pp.Literal(";").suppress()
member_type = (pp.Combine(pp.OneOrMore(word + ~pp.FollowedBy(pp.Literal(";"))),
joinString=" ", adjacent=False)
+ pp.ZeroOrMore("*") + pp.FollowedBy(member_var))
member = pp.Group(member_type + member_var)
body = pp.OneOrMore(member)
member = pp.OneOrMore(word) + pp.Literal(";")
ptr_member = pp.OneOrMore(word) + pp.OneOrMore("*") + word + pp.Literal(";")
struct_body = pp.OneOrMore(member ^ ptr_member)
struct = struct_header + body + struct_footer
struct = struct_header + struct_body + struct_footer
# TODO: Not bullet proof yet.
comment = pp.Or([pp.Literal("/*") + pp.SkipTo(pp.Literal("*/")),
pp.Literal("//") + pp.SkipTo(pp.LineEnd())])
struct.ignore(comment)
with open(VERBS_HEADER_PATH, "r") as f_verbs:
code = f_verbs.read()
res = struct.parseString(code)
print(res)
# for result, _, _ in struct.scanString(code):
# print("{0}".format(result))
if __name__ == "__main__":

View file

@ -1,8 +1,75 @@
struct ibv_srq_init_attr_ex {
uint32_t comp_mask;
struct ibv_srq_attr attr;
void *srq_context;
struct ibv_pd *pd;
enum ibv_srq_type srq_type;
struct ibv_mw_bind_info {
struct ibv_mr *mr;
uint64_t addr;
uint64_t length;
int mw_access_flags; /* use ibv_access_flags */
};
struct ibv_pd {
struct ibv_context *context;
uint32_t handle;
};
struct ibv_xrcd {
struct ibv_context *context;
};
struct ibv_mr {
struct ibv_context *context;
struct ibv_pd *pd;
void *addr;
size_t length;
uint32_t handle;
uint32_t lkey;
uint32_t rkey;
};
struct ibv_mw {
struct ibv_context *context;
struct ibv_pd *pd;
uint32_t rkey;
uint32_t handle;
enum ibv_mw_type type;
};
struct ibv_srq_init_attr {
void *srq_context;
struct ibv_srq_attr attr;
};
struct ibv_srq_init_attr_ex {
void *srq_context;
struct ibv_srq_attr attr;
uint32_t comp_mask;
enum ibv_srq_type srq_type;
struct ibv_pd *pd;
struct ibv_xrcd *xrcd;
struct ibv_cq *cq;
};
struct ibv_wq_init_attr {
void *wq_context;
enum ibv_wq_type wq_type;
uint32_t max_wr;
uint32_t max_sge;
struct ibv_pd *pd;
struct ibv_cq *cq;
uint32_t comp_mask; /* Use ibv_wq_init_attr_mask */
uint32_t create_flags; /* use ibv_wq_flags */
};
/*
* Receive Work Queue Indirection Table.
* It's used in order to distribute incoming packets between different
* Receive Work Queues. Associating Receive WQs with different CPU cores
* allows to workload the traffic between different CPU cores.
* The Indirection Table can contain only WQs of type IBV_WQT_RQ.
*/
struct ibv_rwq_ind_table {
struct ibv_context *context;
int ind_tbl_handle;
int ind_tbl_num;
uint32_t comp_mask;
};

View file

@ -9,27 +9,6 @@ struct ibv_async_event {
enum ibv_event_type event_type;
};
IBV_EVENT_CQ_ERR,
IBV_EVENT_QP_FATAL,
IBV_EVENT_QP_REQ_ERR,
IBV_EVENT_QP_ACCESS_ERR,
IBV_EVENT_COMM_EST,
IBV_EVENT_SQ_DRAINED,
IBV_EVENT_PATH_MIG,
IBV_EVENT_PATH_MIG_ERR,
IBV_EVENT_DEVICE_FATAL,
IBV_EVENT_PORT_ACTIVE,
IBV_EVENT_PORT_ERR,
IBV_EVENT_LID_CHANGE,
IBV_EVENT_PKEY_CHANGE,
IBV_EVENT_SM_CHANGE,
IBV_EVENT_SRQ_ERR,
IBV_EVENT_SRQ_LIMIT_REACHED,
IBV_EVENT_QP_LAST_WQE_REACHED,
IBV_EVENT_CLIENT_REREGISTER,
IBV_EVENT_GID_CHANGE,
IBV_EVENT_WQ_FATAL,
struct ibv_mw_bind_info {
struct ibv_mr *mr;
uint64_t addr;

View file

@ -33,39 +33,39 @@
#include <infiniband/verbs.h> // Linux include
/*void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem) {*/
/*unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));*/
/*uhyve_ibv_get_device_list_t* args = (uhyve_ibv_get_device_list_t*) (guest_mem+data);*/
/*// Call IBV function from hypervisor*/
/*int num_devices;*/
/*struct ibv_device **temp_dev_list = ibv_get_device_list(&num_devices);*/
/*// Copy number of devices to kernel memory */
/*memcpy(guest_mem+(size_t)args->num_devices, &num_devices, sizeof(num_devices));*/
/*for (int d = 0; d < num_devices; d++) {*/
/*printf("uhyve.c: before memcpy list[d].\n");*/
/*// Copy array entry containing ibv_device struct to kernel memory*/
/*memcpy(guest_mem + (size_t)args->dev_phys_ptr_list[d], temp_dev_list[d], sizeof(struct ibv_device));*/
/*}*/
/*}*/
void call_ibv_open_device(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_open_device_t * args = (uhyve_ibv_open_device_t *) (guest_mem + data);
struct ibv_context * host_ret = (guest_mem+(size_t)args->device);
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_open_device(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_get_device_list_t* args = (uhyve_ibv_get_device_list_t*) (guest_mem+data);
// Call IBV function from hypervisor
int num_devices;
struct ibv_device **temp_dev_list = ibv_get_device_list(&num_devices);
// Copy number of devices to kernel memory
memcpy(guest_mem+(size_t)args->num_devices, &num_devices, sizeof(num_devices));
for (int d = 0; d < num_devices; d++) {
printf("uhyve.c: before memcpy list[d].\n");
// Copy array entry containing ibv_device struct to kernel memory
memcpy(guest_mem + (size_t)args->dev_phys_ptr_list[d], temp_dev_list[d], sizeof(struct ibv_device));
}
}
void call_ibv_get_device_name(struct kvm_run * run, uint8_t * guest_mem) {
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 = (guest_mem+(size_t)args->device);
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.
@ -75,7 +75,7 @@ void call_ibv_query_port(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_query_port_t * args = (uhyve_ibv_query_port_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->context, port_num, guest_mem+(size_t)args->port_attr);
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;
}
@ -83,112 +83,8 @@ void call_ibv_create_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
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 = (guest_mem+(size_t)args->context);
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.
}
void call_ibv_alloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_alloc_pd_t * args = (uhyve_ibv_alloc_pd_t *) (guest_mem + data);
struct ibv_pd * host_ret = (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.
}
void call_ibv_reg_mr(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_reg_mr_t * args = (uhyve_ibv_reg_mr_t *) (guest_mem + data);
struct ibv_mr * host_ret = (guest_mem+(size_t)args->pd, guest_mem+(size_t)args->addr, length, access);
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_create_cq(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_create_cq_t * args = (uhyve_ibv_create_cq_t *) (guest_mem + data);
struct ibv_cq * host_ret = (guest_mem+(size_t)args->context, cqe, guest_mem+(size_t)args->cq_context, guest_mem+(size_t)args->channel, comp_vector);
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_create_qp(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_create_qp_t * args = (uhyve_ibv_create_qp_t *) (guest_mem + data);
struct ibv_qp * host_ret = (guest_mem+(size_t)args->pd, guest_mem+(size_t)args->qp_init_attr);
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_query_qp(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_query_qp_t * args = (uhyve_ibv_query_qp_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->qp, guest_mem+(size_t)args->attr, attr_mask, guest_mem+(size_t)args->init_attr);
args->ret = host_ret;
}
void call_ibv_modify_qp(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_modify_qp_t * args = (uhyve_ibv_modify_qp_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->qp, guest_mem+(size_t)args->attr, attr_mask);
args->ret = host_ret;
}
void call_ibv_destroy_qp(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_destroy_qp_t * args = (uhyve_ibv_destroy_qp_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->qp);
args->ret = host_ret;
}
void call_ibv_destroy_cq(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_destroy_cq_t * args = (uhyve_ibv_destroy_cq_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->cq);
args->ret = host_ret;
}
void call_ibv_dereg_mr(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_dereg_mr_t * args = (uhyve_ibv_dereg_mr_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->mr);
args->ret = host_ret;
}
void call_ibv_dealloc_pd(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_dealloc_pd_t * args = (uhyve_ibv_dealloc_pd_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->pd);
args->ret = host_ret;
}
void call_ibv_destroy_comp_channel(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_destroy_comp_channel_t * args = (uhyve_ibv_destroy_comp_channel_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->channel);
args->ret = host_ret;
}
void call_ibv_close_device(struct kvm_run * run, uint8_t * guest_mem) {
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
uhyve_ibv_close_device_t * args = (uhyve_ibv_close_device_t *) (guest_mem + data);
int host_ret = (guest_mem+(size_t)args->context);
args->ret = host_ret;
}

View file

@ -25,32 +25,21 @@
typedef enum {
UHYVE_PORT_IBV_OPEN_DEVICE = 0x510,
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x511,
//UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x511,
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x512,
UHYVE_PORT_IBV_QUERY_PORT = 0x513,
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x514,
UHYVE_PORT_IBV_ALLOC_PD = 0x515,
UHYVE_PORT_IBV_REG_MR = 0x516,
UHYVE_PORT_IBV_CREATE_CQ = 0x517,
UHYVE_PORT_IBV_CREATE_QP = 0x518,
UHYVE_PORT_IBV_QUERY_QP = 0x519,
UHYVE_PORT_IBV_MODIFY_QP = 0x51A,
UHYVE_PORT_IBV_DESTROY_QP = 0x51B,
UHYVE_PORT_IBV_DESTROY_CQ = 0x51C,
UHYVE_PORT_IBV_DEREG_MR = 0x51D,
UHYVE_PORT_IBV_DEALLOC_PD = 0x51E,
UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x51F,
UHYVE_PORT_IBV_CLOSE_DEVICE = 0x520,
} uhyve_ibv_t;
typedef struct { // CHECKED
// In:
int *num_devices;
// Out:
//struct ibv_device devices[MAX_NUM_OF_IBV_DEVICES];
struct ibv_device *dev_phys_ptr_list[MAX_NUM_OF_IBV_DEVICES];
//struct ibv_device **device_list;
} __attribute__((packed)) uhyve_ibv_get_device_list_t;
//typedef struct { // CHECKED
//// In:
//int *num_devices;
//// Out:
////struct ibv_device devices[MAX_NUM_OF_IBV_DEVICES];
//struct ibv_device *dev_phys_ptr_list[MAX_NUM_OF_IBV_DEVICES];
////struct ibv_device **device_list;
//} __attribute__((packed)) uhyve_ibv_get_device_list_t;
typedef struct {
// Parameters:
@ -66,118 +55,18 @@ typedef struct {
const char * ret;
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
//typedef struct {
//// Parameters:
//struct ibv_context * context;
//uint8_t port_num;
//struct ibv_port_attr * port_attr;
//// Return value:
//int ret;
//} __attribute__((packed)) uhyve_ibv_query_port_t;
typedef struct {
// Parameters:
struct ibv_context * context;
uint8_t port_num;
struct ibv_port_attr * port_attr;
// Return value:
int ret;
} __attribute__((packed)) uhyve_ibv_query_port_t;
//typedef struct {
//// Parameters:
//struct ibv_context * context;
//// Return value:
//struct ibv_comp_channel * ret;
//} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;
//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;
//void * addr;
//int length;
//int access;
//// Return value:
//struct ibv_mr * ret;
//} __attribute__((packed)) uhyve_ibv_reg_mr_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_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_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;
//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;
//// Return value:
//int ret;
//} __attribute__((packed)) uhyve_ibv_destroy_qp_t;
//typedef struct {
//// Parameters:
//struct ibv_cq * cq;
//// Return value:
//int ret;
//} __attribute__((packed)) uhyve_ibv_destroy_cq_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;
//// Return value:
//int ret;
//} __attribute__((packed)) uhyve_ibv_dealloc_pd_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;
//// Return value:
//int ret;
//} __attribute__((packed)) uhyve_ibv_close_device_t;
//#endif // UHYVE_IBV_H
typedef struct {
// Parameters:
struct ibv_context * context;
// Return value:
struct ibv_comp_channel * ret;
} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;

View file

@ -970,9 +970,9 @@ static int vcpu_loop(void)
case UHYVE_PORT_IBV_OPEN_DEVICE:
call_ibv_open_device(run, guest_mem);
break;
case UHYVE_PORT_IBV_GET_DEVICE_LIST:
call_ibv_get_device_list(run, guest_mem);
break;
/*case UHYVE_PORT_IBV_GET_DEVICE_LIST:*/
/*call_ibv_get_device_list(run, guest_mem);*/
/*break;*/
case UHYVE_PORT_IBV_GET_DEVICE_NAME:
call_ibv_get_device_name(run, guest_mem);
break;
@ -982,42 +982,7 @@ static int vcpu_loop(void)
case UHYVE_PORT_IBV_CREATE_COMP_CHANNEL:
call_ibv_create_comp_channel(run, guest_mem);
break;
case UHYVE_PORT_IBV_ALLOC_PD:
call_ibv_alloc_pd(run, guest_mem);
break;
case UHYVE_PORT_IBV_REG_MR:
call_ibv_reg_mr(run, guest_mem);
break;
case UHYVE_PORT_IBV_CREATE_CQ:
call_ibv_create_cq(run, guest_mem);
break;
case UHYVE_PORT_IBV_CREATE_QP:
call_ibv_create_qp(run, guest_mem);
break;
case UHYVE_PORT_IBV_QUERY_QP:
call_ibv_query_qp(run, guest_mem);
break;
case UHYVE_PORT_IBV_MODIFY_QP:
call_ibv_modify_qp(run, guest_mem);
break;
case UHYVE_PORT_IBV_DESTROY_QP:
call_ibv_destroy_qp(run, guest_mem);
break;
case UHYVE_PORT_IBV_DESTROY_CQ:
call_ibv_destroy_cq(run, guest_mem);
break;
case UHYVE_PORT_IBV_DEREG_MR:
call_ibv_dereg_mr(run, guest_mem);
break;
case UHYVE_PORT_IBV_DEALLOC_PD:
call_ibv_dealloc_pd(run, guest_mem);
break;
case UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL:
call_ibv_destroy_comp_channel(run, guest_mem);
break;
case UHYVE_PORT_IBV_CLOSE_DEVICE:
call_ibv_close_device(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

@ -346,95 +346,95 @@ static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
} else
ctx->channel = NULL;
ctx->pd = ibv_alloc_pd(ctx->context);
if (!ctx->pd) {
fprintf(stderr, "Couldn't allocate PD\n");
goto clean_comp_channel;
}
/*ctx->pd = ibv_alloc_pd(ctx->context);*/
/*if (!ctx->pd) {*/
/*fprintf(stderr, "Couldn't allocate PD\n");*/
/*goto clean_comp_channel;*/
/*}*/
ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size + 40, IBV_ACCESS_LOCAL_WRITE);
if (!ctx->mr) {
fprintf(stderr, "Couldn't register MR\n");
goto clean_pd;
}
/*ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, size + 40, IBV_ACCESS_LOCAL_WRITE);*/
/*if (!ctx->mr) {*/
/*fprintf(stderr, "Couldn't register MR\n");*/
/*goto clean_pd;*/
/*}*/
ctx->cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL,
ctx->channel, 0);
if (!ctx->cq) {
fprintf(stderr, "Couldn't create CQ\n");
goto clean_mr;
}
/*ctx->cq = ibv_create_cq(ctx->context, rx_depth + 1, NULL,*/
/*ctx->channel, 0);*/
/*if (!ctx->cq) {*/
/*fprintf(stderr, "Couldn't create CQ\n");*/
/*goto clean_mr;*/
/*}*/
{
struct ibv_qp_attr attr;
struct ibv_qp_init_attr init_attr = {
.send_cq = ctx->cq,
.recv_cq = ctx->cq,
.cap = {
.max_send_wr = 1,
.max_recv_wr = rx_depth,
.max_send_sge = 1,
.max_recv_sge = 1
},
.qp_type = IBV_QPT_UD,
};
/*{*/
/*struct ibv_qp_attr attr;*/
/*struct ibv_qp_init_attr init_attr = {*/
/*.send_cq = ctx->cq,*/
/*.recv_cq = ctx->cq,*/
/*.cap = {*/
/*.max_send_wr = 1,*/
/*.max_recv_wr = rx_depth,*/
/*.max_send_sge = 1,*/
/*.max_recv_sge = 1*/
/*},*/
/*.qp_type = IBV_QPT_UD,*/
/*};*/
ctx->qp = ibv_create_qp(ctx->pd, &init_attr);
if (!ctx->qp) {
fprintf(stderr, "Couldn't create QP\n");
goto clean_cq;
}
/*ctx->qp = ibv_create_qp(ctx->pd, &init_attr);*/
/*if (!ctx->qp) {*/
/*fprintf(stderr, "Couldn't create QP\n");*/
/*goto clean_cq;*/
/*}*/
ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr);
if (init_attr.cap.max_inline_data >= size) {
ctx->send_flags |= IBV_SEND_INLINE;
}
}
/*ibv_query_qp(ctx->qp, &attr, IBV_QP_CAP, &init_attr);*/
/*if (init_attr.cap.max_inline_data >= size) {*/
/*ctx->send_flags |= IBV_SEND_INLINE;*/
/*}*/
/*}*/
{
struct ibv_qp_attr attr = {
.qp_state = IBV_QPS_INIT,
.pkey_index = 0,
.port_num = port,
.qkey = 0x11111111
};
/*{*/
/*struct ibv_qp_attr attr = {*/
/*.qp_state = IBV_QPS_INIT,*/
/*.pkey_index = 0,*/
/*.port_num = port,*/
/*.qkey = 0x11111111*/
/*};*/
if (ibv_modify_qp(ctx->qp, &attr,
IBV_QP_STATE |
IBV_QP_PKEY_INDEX |
IBV_QP_PORT |
IBV_QP_QKEY)) {
fprintf(stderr, "Failed to modify QP to INIT\n");
goto clean_qp;
}
}
/*if (ibv_modify_qp(ctx->qp, &attr,*/
/*IBV_QP_STATE |*/
/*IBV_QP_PKEY_INDEX |*/
/*IBV_QP_PORT |*/
/*IBV_QP_QKEY)) {*/
/*fprintf(stderr, "Failed to modify QP to INIT\n");*/
/*goto clean_qp;*/
/*}*/
/*}*/
return ctx;
/*return ctx;*/
clean_qp:
ibv_destroy_qp(ctx->qp);
/*ibv_destroy_qp(ctx->qp);*/
clean_cq:
ibv_destroy_cq(ctx->cq);
/*ibv_destroy_cq(ctx->cq);*/
clean_mr:
ibv_dereg_mr(ctx->mr);
/*ibv_dereg_mr(ctx->mr);*/
clean_pd:
ibv_dealloc_pd(ctx->pd);
/*ibv_dealloc_pd(ctx->pd);*/
clean_comp_channel:
if (ctx->channel)
ibv_destroy_comp_channel(ctx->channel);
/*if (ctx->channel)*/
/*ibv_destroy_comp_channel(ctx->channel);*/
clean_device:
ibv_close_device(ctx->context);
/*ibv_close_device(ctx->context);*/
clean_buffer:
free(ctx->buf);
/*free(ctx->buf);*/
clean_ctx:
free(ctx);
/*free(ctx);*/
return NULL;
}