mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
Prepared for some pingpong functions.
This commit is contained in:
parent
7082c820e5
commit
dc801f1cf2
13 changed files with 1311 additions and 3396 deletions
18
tools/ibv_code_generator/GEN-include-hermit-stddef.h
Normal file
18
tools/ibv_code_generator/GEN-include-hermit-stddef.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
|
||||
#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,
|
352
tools/ibv_code_generator/GEN-kernel-ibv.c
Normal file
352
tools/ibv_code_generator/GEN-kernel-ibv.c
Normal file
|
@ -0,0 +1,352 @@
|
|||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
struct ibv_context * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_open_device_t;
|
||||
|
||||
struct ibv_context * ibv_open_device(struct ibv_device * device) {
|
||||
uhyve_ibv_open_device_t uhyve_args;
|
||||
uhyve_args->device = (struct ibv_device *) virt_to_phys((size_t) device);
|
||||
|
||||
uhyve_args->ret = kmalloc(sizeof(struct ibv_context));
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_OPEN_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Fix pointers in returned data structures.
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
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;
|
||||
// Return value:
|
||||
const char * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
|
||||
|
||||
const char * ibv_get_device_name(struct ibv_device * device) {
|
||||
uhyve_ibv_get_device_name_t uhyve_args;
|
||||
uhyve_args->device = (struct ibv_device *) virt_to_phys((size_t) device);
|
||||
|
||||
uhyve_args->ret = kmalloc(sizeof(const char));
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_NAME, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Fix pointers in returned data structures.
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
uint8_t port_num;
|
||||
struct ibv_port_attr * port_attr;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_query_port_t;
|
||||
|
||||
int ibv_query_port(struct ibv_context * context, uint8_t port_num, struct ibv_port_attr * port_attr) {
|
||||
uhyve_ibv_query_port_t uhyve_args;
|
||||
uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);
|
||||
uhyve_args->port_num = port_num;
|
||||
uhyve_args->port_attr = (struct ibv_port_attr *) virt_to_phys((size_t) port_attr);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_QUERY_PORT, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Fix pointers in returned data structures.
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
// Return value:
|
||||
struct ibv_comp_channel * ret;
|
||||
} __attribute__((packed)) uhyve_ibv_create_comp_channel_t;
|
||||
|
||||
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context) {
|
||||
uhyve_ibv_create_comp_channel_t uhyve_args;
|
||||
uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context);
|
||||
|
||||
uhyve_args->ret = kmalloc(sizeof(struct ibv_comp_channel));
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_CREATE_COMP_CHANNEL, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Fix pointers in returned data structures.
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
19
tools/ibv_code_generator/GEN-tools-uhyve-ibv.h
Normal file
19
tools/ibv_code_generator/GEN-tools-uhyve-ibv.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
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_ibv_t;
|
153
tools/ibv_code_generator/GEN-tools-uhyve.c
Normal file
153
tools/ibv_code_generator/GEN-tools-uhyve.c
Normal file
|
@ -0,0 +1,153 @@
|
|||
|
||||
case UHYVE_PORT_IBV_OPEN_DEVICE: {
|
||||
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 = ibv_open_device(guest_mem+(size_t)args->device);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_LIST: {
|
||||
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 = ibv_get_device_list(guest_mem+(size_t)args->num_devices);
|
||||
// TODO: Take care of struct ibv_device ** return value.
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_NAME: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_get_device_name_t * args = (uhyve_ibv_get_device_name_t *) (guest_mem + data);
|
||||
|
||||
const char * host_ret = ibv_get_device_name(guest_mem+(size_t)args->device);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_PORT: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_query_port_t * args = (uhyve_ibv_query_port_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_query_port(guest_mem+(size_t)args->context, port_num, guest_mem+(size_t)args->port_attr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_COMP_CHANNEL: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_create_comp_channel_t * args = (uhyve_ibv_create_comp_channel_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_comp_channel * host_ret = ibv_create_comp_channel(guest_mem+(size_t)args->context);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_ALLOC_PD: {
|
||||
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 = ibv_alloc_pd(guest_mem+(size_t)args->context);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_REG_MR: {
|
||||
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 = ibv_reg_mr(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));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_CQ: {
|
||||
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 = ibv_create_cq(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));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_QP: {
|
||||
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 = ibv_create_qp(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));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_QP: {
|
||||
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 = ibv_query_qp(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;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_MODIFY_QP: {
|
||||
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 = ibv_modify_qp(guest_mem+(size_t)args->qp, guest_mem+(size_t)args->attr, attr_mask);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_QP: {
|
||||
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 = ibv_destroy_qp(guest_mem+(size_t)args->qp);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_CQ: {
|
||||
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 = ibv_destroy_cq(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DEREG_MR: {
|
||||
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 = ibv_dereg_mr(guest_mem+(size_t)args->mr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DEALLOC_PD: {
|
||||
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 = ibv_dealloc_pd(guest_mem+(size_t)args->pd);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL: {
|
||||
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 = ibv_destroy_comp_channel(guest_mem+(size_t)args->channel);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CLOSE_DEVICE: {
|
||||
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 = ibv_close_device(guest_mem+(size_t)args->context);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
|
||||
#define UHYVE_PORT_IBV_WC_STATUS_STR 0x510,
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MULT 0x511,
|
||||
#define UHYVE_PORT_MULT_TO_IBV_RATE 0x512,
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MBPS 0x513,
|
||||
#define UHYVE_PORT_MBPS_TO_IBV_RATE 0x514,
|
||||
#define UHYVE_PORT_IBV_CQ_EX_TO_CQ 0x515,
|
||||
#define UHYVE_PORT_IBV_START_POLL 0x516,
|
||||
#define UHYVE_PORT_IBV_NEXT_POLL 0x517,
|
||||
#define UHYVE_PORT_IBV_END_POLL 0x518,
|
||||
#define UHYVE_PORT_IBV_WC_READ_OPCODE 0x519,
|
||||
#define UHYVE_PORT_IBV_WC_READ_VENDOR_ERR 0x51A,
|
||||
#define UHYVE_PORT_IBV_WC_READ_BYTE_LEN 0x51B,
|
||||
#define UHYVE_PORT_IBV_WC_READ_IMM_DATA 0x51C,
|
||||
#define UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY 0x51D,
|
||||
#define UHYVE_PORT_IBV_WC_READ_QP_NUM 0x51E,
|
||||
#define UHYVE_PORT_IBV_WC_READ_SRC_QP 0x51F,
|
||||
#define UHYVE_PORT_IBV_WC_READ_WC_FLAGS 0x520,
|
||||
#define UHYVE_PORT_IBV_WC_READ_SLID 0x521,
|
||||
#define UHYVE_PORT_IBV_WC_READ_SL 0x522,
|
||||
#define UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS 0x523,
|
||||
#define UHYVE_PORT_IBV_WC_READ_COMPLETION_TS 0x524,
|
||||
#define UHYVE_PORT_IBV_WC_READ_CVLAN 0x525,
|
||||
#define UHYVE_PORT_IBV_WC_READ_FLOW_TAG 0x526,
|
||||
#define UHYVE_PORT_IBV_POST_WQ_RECV 0x527,
|
||||
#define UHYVE_PORT_VERBS_GET_CTX 0x528,
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x529,
|
||||
#define UHYVE_PORT_IBV_FREE_DEVICE_LIST 0x52A,
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x52B,
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_GUID 0x52C,
|
||||
#define UHYVE_PORT_IBV_OPEN_DEVICE 0x52D,
|
||||
#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x52E,
|
||||
#define UHYVE_PORT_IBV_GET_ASYNC_EVENT 0x52F,
|
||||
#define UHYVE_PORT_IBV_ACK_ASYNC_EVENT 0x530,
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE 0x531,
|
||||
#define UHYVE_PORT_IBV_QUERY_PORT 0x532,
|
||||
#define UHYVE_PORT____IBV_QUERY_PORT 0x533,
|
||||
#define UHYVE_PORT_IBV_QUERY_GID 0x534,
|
||||
#define UHYVE_PORT_IBV_QUERY_PKEY 0x535,
|
||||
#define UHYVE_PORT_IBV_ALLOC_PD 0x536,
|
||||
#define UHYVE_PORT_IBV_DEALLOC_PD 0x537,
|
||||
#define UHYVE_PORT_IBV_CREATE_FLOW 0x538,
|
||||
#define UHYVE_PORT_IBV_DESTROY_FLOW 0x539,
|
||||
#define UHYVE_PORT_IBV_OPEN_XRCD 0x53A,
|
||||
#define UHYVE_PORT_IBV_CLOSE_XRCD 0x53B,
|
||||
#define UHYVE_PORT_IBV_REG_MR 0x53C,
|
||||
#define UHYVE_PORT_IBV_REREG_MR 0x53D,
|
||||
#define UHYVE_PORT_IBV_DEREG_MR 0x53E,
|
||||
#define UHYVE_PORT_IBV_ALLOC_MW 0x53F,
|
||||
#define UHYVE_PORT_IBV_DEALLOC_MW 0x540,
|
||||
#define UHYVE_PORT_IBV_INC_RKEY 0x541,
|
||||
#define UHYVE_PORT_IBV_BIND_MW 0x542,
|
||||
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x543,
|
||||
#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x544,
|
||||
#define UHYVE_PORT_IBV_CREATE_CQ 0x545,
|
||||
#define UHYVE_PORT_IBV_CREATE_CQ_EX 0x546,
|
||||
#define UHYVE_PORT_IBV_RESIZE_CQ 0x547,
|
||||
#define UHYVE_PORT_IBV_DESTROY_CQ 0x548,
|
||||
#define UHYVE_PORT_IBV_GET_CQ_EVENT 0x549,
|
||||
#define UHYVE_PORT_IBV_ACK_CQ_EVENTS 0x54A,
|
||||
#define UHYVE_PORT_IBV_POLL_CQ 0x54B,
|
||||
#define UHYVE_PORT_IBV_REQ_NOTIFY_CQ 0x54C,
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ 0x54D,
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ_EX 0x54E,
|
||||
#define UHYVE_PORT_IBV_MODIFY_SRQ 0x54F,
|
||||
#define UHYVE_PORT_IBV_QUERY_SRQ 0x550,
|
||||
#define UHYVE_PORT_IBV_GET_SRQ_NUM 0x551,
|
||||
#define UHYVE_PORT_IBV_DESTROY_SRQ 0x552,
|
||||
#define UHYVE_PORT_IBV_POST_SRQ_RECV 0x553,
|
||||
#define UHYVE_PORT_IBV_CREATE_QP 0x554,
|
||||
#define UHYVE_PORT_IBV_CREATE_QP_EX 0x555,
|
||||
#define UHYVE_PORT_IBV_QUERY_RT_VALUES_EX 0x556,
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE_EX 0x557,
|
||||
#define UHYVE_PORT_IBV_OPEN_QP 0x558,
|
||||
#define UHYVE_PORT_IBV_MODIFY_QP 0x559,
|
||||
#define UHYVE_PORT_IBV_QUERY_QP 0x55A,
|
||||
#define UHYVE_PORT_IBV_DESTROY_QP 0x55B,
|
||||
#define UHYVE_PORT_IBV_CREATE_WQ 0x55C,
|
||||
#define UHYVE_PORT_IBV_MODIFY_WQ 0x55D,
|
||||
#define UHYVE_PORT_IBV_DESTROY_WQ 0x55E,
|
||||
#define UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE 0x55F,
|
||||
#define UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE 0x560,
|
||||
#define UHYVE_PORT_IBV_POST_SEND 0x561,
|
||||
#define UHYVE_PORT_IBV_POST_RECV 0x562,
|
||||
#define UHYVE_PORT_IBV_CREATE_AH 0x563,
|
||||
#define UHYVE_PORT_IBV_INIT_AH_FROM_WC 0x564,
|
||||
#define UHYVE_PORT_IBV_CREATE_AH_FROM_WC 0x565,
|
||||
#define UHYVE_PORT_IBV_DESTROY_AH 0x566,
|
||||
#define UHYVE_PORT_IBV_ATTACH_MCAST 0x567,
|
||||
#define UHYVE_PORT_IBV_DETACH_MCAST 0x568,
|
||||
#define UHYVE_PORT_IBV_FORK_INIT 0x569,
|
||||
#define UHYVE_PORT_IBV_NODE_TYPE_STR 0x56A,
|
||||
#define UHYVE_PORT_IBV_PORT_STATE_STR 0x56B,
|
||||
#define UHYVE_PORT_IBV_EVENT_TYPE_STR 0x56C,
|
||||
#define UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID 0x56D,
|
||||
#define UHYVE_PORT_IBV_IS_QPT_SUPPORTED 0x56E,
|
File diff suppressed because it is too large
Load diff
|
@ -1,97 +0,0 @@
|
|||
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_IBV_CQ_EX_TO_CQ = 0x515,
|
||||
UHYVE_PORT_IBV_START_POLL = 0x516,
|
||||
UHYVE_PORT_IBV_NEXT_POLL = 0x517,
|
||||
UHYVE_PORT_IBV_END_POLL = 0x518,
|
||||
UHYVE_PORT_IBV_WC_READ_OPCODE = 0x519,
|
||||
UHYVE_PORT_IBV_WC_READ_VENDOR_ERR = 0x51A,
|
||||
UHYVE_PORT_IBV_WC_READ_BYTE_LEN = 0x51B,
|
||||
UHYVE_PORT_IBV_WC_READ_IMM_DATA = 0x51C,
|
||||
UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY = 0x51D,
|
||||
UHYVE_PORT_IBV_WC_READ_QP_NUM = 0x51E,
|
||||
UHYVE_PORT_IBV_WC_READ_SRC_QP = 0x51F,
|
||||
UHYVE_PORT_IBV_WC_READ_WC_FLAGS = 0x520,
|
||||
UHYVE_PORT_IBV_WC_READ_SLID = 0x521,
|
||||
UHYVE_PORT_IBV_WC_READ_SL = 0x522,
|
||||
UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS = 0x523,
|
||||
UHYVE_PORT_IBV_WC_READ_COMPLETION_TS = 0x524,
|
||||
UHYVE_PORT_IBV_WC_READ_CVLAN = 0x525,
|
||||
UHYVE_PORT_IBV_WC_READ_FLOW_TAG = 0x526,
|
||||
UHYVE_PORT_IBV_POST_WQ_RECV = 0x527,
|
||||
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_CREATE_CQ_EX = 0x546,
|
||||
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_RT_VALUES_EX = 0x556,
|
||||
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_CREATE_WQ = 0x55C,
|
||||
UHYVE_PORT_IBV_MODIFY_WQ = 0x55D,
|
||||
UHYVE_PORT_IBV_DESTROY_WQ = 0x55E,
|
||||
UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE = 0x55F,
|
||||
UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE = 0x560,
|
||||
UHYVE_PORT_IBV_POST_SEND = 0x561,
|
||||
UHYVE_PORT_IBV_POST_RECV = 0x562,
|
||||
UHYVE_PORT_IBV_CREATE_AH = 0x563,
|
||||
UHYVE_PORT_IBV_INIT_AH_FROM_WC = 0x564,
|
||||
UHYVE_PORT_IBV_CREATE_AH_FROM_WC = 0x565,
|
||||
UHYVE_PORT_IBV_DESTROY_AH = 0x566,
|
||||
UHYVE_PORT_IBV_ATTACH_MCAST = 0x567,
|
||||
UHYVE_PORT_IBV_DETACH_MCAST = 0x568,
|
||||
UHYVE_PORT_IBV_FORK_INIT = 0x569,
|
||||
UHYVE_PORT_IBV_NODE_TYPE_STR = 0x56A,
|
||||
UHYVE_PORT_IBV_PORT_STATE_STR = 0x56B,
|
||||
UHYVE_PORT_IBV_EVENT_TYPE_STR = 0x56C,
|
||||
UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID = 0x56D,
|
||||
UHYVE_PORT_IBV_IS_QPT_SUPPORTED = 0x56E,
|
||||
} uhyve_ibv_t;
|
|
@ -1,855 +0,0 @@
|
|||
|
||||
case UHYVE_PORT_IBV_WC_STATUS_STR: {
|
||||
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(status);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_RATE_TO_MULT: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_rate_to_mult(rate);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_MULT_TO_IBV_RATE: {
|
||||
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);
|
||||
|
||||
enum ibv_rate host_ret = mult_to_ibv_rate(mult);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_RATE_TO_MBPS: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_rate_to_mbps(rate);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_MBPS_TO_IBV_RATE: {
|
||||
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);
|
||||
|
||||
enum ibv_rate host_ret = mbps_to_ibv_rate(mbps);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CQ_EX_TO_CQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_cq_ex_to_cq_t * args = (uhyve_ibv_cq_ex_to_cq_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_cq * host_ret = ibv_cq_ex_to_cq(guest_mem+(size_t)args->cq);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_START_POLL: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_start_poll_t * args = (uhyve_ibv_start_poll_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_start_poll(guest_mem+(size_t)args->cq, guest_mem+(size_t)args->attr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_NEXT_POLL: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_next_poll_t * args = (uhyve_ibv_next_poll_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_next_poll(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_END_POLL: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_end_poll_t * args = (uhyve_ibv_end_poll_t *) (guest_mem + data);
|
||||
|
||||
void host_ret = ibv_end_poll(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_OPCODE: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_opcode_t * args = (uhyve_ibv_wc_read_opcode_t *) (guest_mem + data);
|
||||
|
||||
enum ibv_wc_opcode host_ret = ibv_wc_read_opcode(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_VENDOR_ERR: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_vendor_err_t * args = (uhyve_ibv_wc_read_vendor_err_t *) (guest_mem + data);
|
||||
|
||||
uint32_t host_ret = ibv_wc_read_vendor_err(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_BYTE_LEN: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_byte_len_t * args = (uhyve_ibv_wc_read_byte_len_t *) (guest_mem + data);
|
||||
|
||||
uint32_t host_ret = ibv_wc_read_byte_len(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_IMM_DATA: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_imm_data_t * args = (uhyve_ibv_wc_read_imm_data_t *) (guest_mem + data);
|
||||
|
||||
__be32 host_ret = ibv_wc_read_imm_data(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_invalidated_rkey_t * args = (uhyve_ibv_wc_read_invalidated_rkey_t *) (guest_mem + data);
|
||||
|
||||
uint32_t host_ret = ibv_wc_read_invalidated_rkey(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_QP_NUM: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_qp_num_t * args = (uhyve_ibv_wc_read_qp_num_t *) (guest_mem + data);
|
||||
|
||||
uint32_t host_ret = ibv_wc_read_qp_num(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_SRC_QP: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_src_qp_t * args = (uhyve_ibv_wc_read_src_qp_t *) (guest_mem + data);
|
||||
|
||||
uint32_t host_ret = ibv_wc_read_src_qp(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_WC_FLAGS: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_wc_flags_t * args = (uhyve_ibv_wc_read_wc_flags_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_wc_read_wc_flags(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_SLID: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_slid_t * args = (uhyve_ibv_wc_read_slid_t *) (guest_mem + data);
|
||||
|
||||
uint32_t host_ret = ibv_wc_read_slid(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_SL: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_sl_t * args = (uhyve_ibv_wc_read_sl_t *) (guest_mem + data);
|
||||
|
||||
uint8_t host_ret = ibv_wc_read_sl(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_dlid_path_bits_t * args = (uhyve_ibv_wc_read_dlid_path_bits_t *) (guest_mem + data);
|
||||
|
||||
uint8_t host_ret = ibv_wc_read_dlid_path_bits(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_COMPLETION_TS: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_completion_ts_t * args = (uhyve_ibv_wc_read_completion_ts_t *) (guest_mem + data);
|
||||
|
||||
uint64_t host_ret = ibv_wc_read_completion_ts(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_CVLAN: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_cvlan_t * args = (uhyve_ibv_wc_read_cvlan_t *) (guest_mem + data);
|
||||
|
||||
uint16_t host_ret = ibv_wc_read_cvlan(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_WC_READ_FLOW_TAG: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_wc_read_flow_tag_t * args = (uhyve_ibv_wc_read_flow_tag_t *) (guest_mem + data);
|
||||
|
||||
uint32_t host_ret = ibv_wc_read_flow_tag(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_POST_WQ_RECV: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_post_wq_recv_t * args = (uhyve_ibv_post_wq_recv_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_post_wq_recv(guest_mem+(size_t)args->wq, guest_mem+(size_t)args->recv_wr, /* TODO: param bad_recv_wr*/);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_VERBS_GET_CTX: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_verbs_get_ctx_t * args = (uhyve_verbs_get_ctx_t *) (guest_mem + data);
|
||||
|
||||
struct verbs_context * host_ret = verbs_get_ctx(guest_mem+(size_t)args->ctx);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_LIST: {
|
||||
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 = ibv_get_device_list(guest_mem+(size_t)args->num_devices);
|
||||
// TODO: Take care of struct ibv_device ** return value.
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_FREE_DEVICE_LIST: {
|
||||
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 host_ret = ibv_free_device_list(/* TODO: param list*/);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_NAME: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_get_device_name_t * args = (uhyve_ibv_get_device_name_t *) (guest_mem + data);
|
||||
|
||||
const char * host_ret = ibv_get_device_name(guest_mem+(size_t)args->device);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_GUID: {
|
||||
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);
|
||||
|
||||
__be64 host_ret = ibv_get_device_guid(guest_mem+(size_t)args->device);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_OPEN_DEVICE: {
|
||||
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 = ibv_open_device(guest_mem+(size_t)args->device);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CLOSE_DEVICE: {
|
||||
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 = ibv_close_device(guest_mem+(size_t)args->context);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_GET_ASYNC_EVENT: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_get_async_event(guest_mem+(size_t)args->context, guest_mem+(size_t)args->event);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_ACK_ASYNC_EVENT: {
|
||||
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 host_ret = ibv_ack_async_event(guest_mem+(size_t)args->event);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_DEVICE: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_query_device_t * args = (uhyve_ibv_query_device_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_query_device(guest_mem+(size_t)args->context, guest_mem+(size_t)args->device_attr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_PORT: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_query_port_t * args = (uhyve_ibv_query_port_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_query_port(guest_mem+(size_t)args->context, port_num, guest_mem+(size_t)args->port_attr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT____IBV_QUERY_PORT: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve____ibv_query_port_t * args = (uhyve____ibv_query_port_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ___ibv_query_port(guest_mem+(size_t)args->context, port_num, guest_mem+(size_t)args->port_attr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_GID: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_query_gid_t * args = (uhyve_ibv_query_gid_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_query_gid(guest_mem+(size_t)args->context, port_num, index, guest_mem+(size_t)args->gid);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_PKEY: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_query_pkey_t * args = (uhyve_ibv_query_pkey_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_query_pkey(guest_mem+(size_t)args->context, port_num, index, guest_mem+(size_t)args->pkey);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_ALLOC_PD: {
|
||||
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 = ibv_alloc_pd(guest_mem+(size_t)args->context);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DEALLOC_PD: {
|
||||
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 = ibv_dealloc_pd(guest_mem+(size_t)args->pd);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_FLOW: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_create_flow_t * args = (uhyve_ibv_create_flow_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_flow * host_ret = ibv_create_flow(guest_mem+(size_t)args->qp, guest_mem+(size_t)args->flow);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_FLOW: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_destroy_flow_t * args = (uhyve_ibv_destroy_flow_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_destroy_flow(guest_mem+(size_t)args->flow_id);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_OPEN_XRCD: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_open_xrcd_t * args = (uhyve_ibv_open_xrcd_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_xrcd * host_ret = ibv_open_xrcd(guest_mem+(size_t)args->context, guest_mem+(size_t)args->xrcd_init_attr);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CLOSE_XRCD: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_close_xrcd_t * args = (uhyve_ibv_close_xrcd_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_close_xrcd(guest_mem+(size_t)args->xrcd);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_REG_MR: {
|
||||
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 = ibv_reg_mr(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));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_REREG_MR: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_rereg_mr_t * args = (uhyve_ibv_rereg_mr_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_rereg_mr(guest_mem+(size_t)args->mr, flags, guest_mem+(size_t)args->pd, guest_mem+(size_t)args->addr, length, access);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DEREG_MR: {
|
||||
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 = ibv_dereg_mr(guest_mem+(size_t)args->mr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_ALLOC_MW: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_alloc_mw_t * args = (uhyve_ibv_alloc_mw_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_mw * host_ret = ibv_alloc_mw(guest_mem+(size_t)args->pd, type);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DEALLOC_MW: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_dealloc_mw_t * args = (uhyve_ibv_dealloc_mw_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_dealloc_mw(guest_mem+(size_t)args->mw);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_INC_RKEY: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_inc_rkey_t * args = (uhyve_ibv_inc_rkey_t *) (guest_mem + data);
|
||||
|
||||
uint32_t host_ret = ibv_inc_rkey(rkey);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_BIND_MW: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_bind_mw_t * args = (uhyve_ibv_bind_mw_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_bind_mw(guest_mem+(size_t)args->qp, guest_mem+(size_t)args->mw, guest_mem+(size_t)args->mw_bind);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_COMP_CHANNEL: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_create_comp_channel_t * args = (uhyve_ibv_create_comp_channel_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_comp_channel * host_ret = ibv_create_comp_channel(guest_mem+(size_t)args->context);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL: {
|
||||
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 = ibv_destroy_comp_channel(guest_mem+(size_t)args->channel);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_CQ: {
|
||||
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 = ibv_create_cq(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));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_CQ_EX: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_create_cq_ex_t * args = (uhyve_ibv_create_cq_ex_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_cq_ex * host_ret = ibv_create_cq_ex(guest_mem+(size_t)args->context, guest_mem+(size_t)args->cq_attr);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_RESIZE_CQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_resize_cq_t * args = (uhyve_ibv_resize_cq_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_resize_cq(guest_mem+(size_t)args->cq, cqe);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_CQ: {
|
||||
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 = ibv_destroy_cq(guest_mem+(size_t)args->cq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_GET_CQ_EVENT: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_get_cq_event(guest_mem+(size_t)args->channel, /* TODO: param cq*/, /* TODO: param cq_context*/);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_ACK_CQ_EVENTS: {
|
||||
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 host_ret = ibv_ack_cq_events(guest_mem+(size_t)args->cq, nevents);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_POLL_CQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_poll_cq_t * args = (uhyve_ibv_poll_cq_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_poll_cq(guest_mem+(size_t)args->cq, num_entries, guest_mem+(size_t)args->wc);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_REQ_NOTIFY_CQ: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_req_notify_cq(guest_mem+(size_t)args->cq, solicited_only);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_SRQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_create_srq_t * args = (uhyve_ibv_create_srq_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_srq * host_ret = ibv_create_srq(guest_mem+(size_t)args->pd, guest_mem+(size_t)args->srq_init_attr);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_SRQ_EX: {
|
||||
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);
|
||||
|
||||
struct ibv_srq * host_ret = ibv_create_srq_ex(guest_mem+(size_t)args->context, guest_mem+(size_t)args->srq_init_attr_ex);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_MODIFY_SRQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_modify_srq_t * args = (uhyve_ibv_modify_srq_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_modify_srq(guest_mem+(size_t)args->srq, guest_mem+(size_t)args->srq_attr, srq_attr_mask);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_SRQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_query_srq_t * args = (uhyve_ibv_query_srq_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_query_srq(guest_mem+(size_t)args->srq, guest_mem+(size_t)args->srq_attr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_GET_SRQ_NUM: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_get_srq_num(guest_mem+(size_t)args->srq, guest_mem+(size_t)args->srq_num);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_SRQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_destroy_srq_t * args = (uhyve_ibv_destroy_srq_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_destroy_srq(guest_mem+(size_t)args->srq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_POST_SRQ_RECV: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_post_srq_recv(guest_mem+(size_t)args->srq, guest_mem+(size_t)args->recv_wr, /* TODO: param bad_recv_wr*/);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_QP: {
|
||||
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 = ibv_create_qp(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));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_QP_EX: {
|
||||
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);
|
||||
|
||||
struct ibv_qp * host_ret = ibv_create_qp_ex(guest_mem+(size_t)args->context, guest_mem+(size_t)args->qp_init_attr_ex);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_RT_VALUES_EX: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_query_rt_values_ex_t * args = (uhyve_ibv_query_rt_values_ex_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_query_rt_values_ex(guest_mem+(size_t)args->context, guest_mem+(size_t)args->values);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_DEVICE_EX: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_query_device_ex(guest_mem+(size_t)args->context, guest_mem+(size_t)args->input, guest_mem+(size_t)args->attr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_OPEN_QP: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_open_qp_t * args = (uhyve_ibv_open_qp_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_qp * host_ret = ibv_open_qp(guest_mem+(size_t)args->context, guest_mem+(size_t)args->qp_open_attr);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_MODIFY_QP: {
|
||||
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 = ibv_modify_qp(guest_mem+(size_t)args->qp, guest_mem+(size_t)args->attr, attr_mask);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_QUERY_QP: {
|
||||
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 = ibv_query_qp(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;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_QP: {
|
||||
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 = ibv_destroy_qp(guest_mem+(size_t)args->qp);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_WQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_create_wq_t * args = (uhyve_ibv_create_wq_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_wq * host_ret = ibv_create_wq(guest_mem+(size_t)args->context, guest_mem+(size_t)args->wq_init_attr);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_MODIFY_WQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_modify_wq_t * args = (uhyve_ibv_modify_wq_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_modify_wq(guest_mem+(size_t)args->wq, guest_mem+(size_t)args->wq_attr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_WQ: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_destroy_wq_t * args = (uhyve_ibv_destroy_wq_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_destroy_wq(guest_mem+(size_t)args->wq);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_create_rwq_ind_table_t * args = (uhyve_ibv_create_rwq_ind_table_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_rwq_ind_table * host_ret = ibv_create_rwq_ind_table(guest_mem+(size_t)args->context, guest_mem+(size_t)args->init_attr);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_destroy_rwq_ind_table_t * args = (uhyve_ibv_destroy_rwq_ind_table_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_destroy_rwq_ind_table(guest_mem+(size_t)args->rwq_ind_table);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_POST_SEND: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_post_send_t * args = (uhyve_ibv_post_send_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_post_send(guest_mem+(size_t)args->qp, guest_mem+(size_t)args->wr, /* TODO: param bad_wr*/);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_POST_RECV: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_post_recv_t * args = (uhyve_ibv_post_recv_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_post_recv(guest_mem+(size_t)args->qp, guest_mem+(size_t)args->wr, /* TODO: param bad_wr*/);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_AH: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_create_ah_t * args = (uhyve_ibv_create_ah_t *) (guest_mem + data);
|
||||
|
||||
struct ibv_ah * host_ret = ibv_create_ah(guest_mem+(size_t)args->pd, guest_mem+(size_t)args->attr);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_INIT_AH_FROM_WC: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_init_ah_from_wc(guest_mem+(size_t)args->context, port_num, guest_mem+(size_t)args->wc, guest_mem+(size_t)args->grh, guest_mem+(size_t)args->ah_attr);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_CREATE_AH_FROM_WC: {
|
||||
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);
|
||||
|
||||
struct ibv_ah * host_ret = ibv_create_ah_from_wc(guest_mem+(size_t)args->pd, guest_mem+(size_t)args->wc, guest_mem+(size_t)args->grh, port_num);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DESTROY_AH: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_destroy_ah_t * args = (uhyve_ibv_destroy_ah_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_destroy_ah(guest_mem+(size_t)args->ah);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_ATTACH_MCAST: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_attach_mcast_t * args = (uhyve_ibv_attach_mcast_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_attach_mcast(guest_mem+(size_t)args->qp, guest_mem+(size_t)args->gid, lid);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_DETACH_MCAST: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_detach_mcast_t * args = (uhyve_ibv_detach_mcast_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_detach_mcast(guest_mem+(size_t)args->qp, guest_mem+(size_t)args->gid, lid);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_FORK_INIT: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_fork_init_t * args = (uhyve_ibv_fork_init_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_fork_init();
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_NODE_TYPE_STR: {
|
||||
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(node_type);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_PORT_STATE_STR: {
|
||||
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(port_state);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_EVENT_TYPE_STR: {
|
||||
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(event);
|
||||
memcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_resolve_eth_l2_from_gid_t * args = (uhyve_ibv_resolve_eth_l2_from_gid_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_resolve_eth_l2_from_gid(guest_mem+(size_t)args->context, guest_mem+(size_t)args->attr, eth_mac, guest_mem+(size_t)args->vid);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
case UHYVE_PORT_IBV_IS_QPT_SUPPORTED: {
|
||||
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);
|
||||
|
||||
int host_ret = ibv_is_qpt_supported(caps, qpt);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
17
tools/ibv_code_generator/function-prototypes-0.txt
Normal file
17
tools/ibv_code_generator/function-prototypes-0.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
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)
|
330
tools/ibv_code_generator/generate-code.py
Executable file
330
tools/ibv_code_generator/generate-code.py
Executable file
|
@ -0,0 +1,330 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""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.
|
||||
|
||||
|
||||
This script expects a text file containing function prototypes as input
|
||||
(SRC_PATH). It generates the following C code snippets for each individual given
|
||||
function in the input file. Todo notes are inserted whereever more work is
|
||||
required.
|
||||
|
||||
1. The definition of a struct that contains all parameters and the return value
|
||||
of a given function.
|
||||
Required in: ./kernel/ibv.c
|
||||
|
||||
Example:
|
||||
typedef struct {
|
||||
// Parameters:
|
||||
struct ibv_mr * mr;
|
||||
int flags;
|
||||
struct ibv_pd * pd;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_rereg_mr_t;
|
||||
|
||||
2. The definition of the kernel space function that sends a KVM exit IO to
|
||||
uhyve.
|
||||
Required in: ./kernel/ibv.c
|
||||
|
||||
Example:
|
||||
int ibv_rereg_mr(struct ibv_mr * mr, int flags, struct ibv_pd * pd) {
|
||||
uhyve_ibv_rereg_mr_t uhyve_args;
|
||||
uhyve_args->mr = (struct ibv_mr *) virt_to_phys((size_t) mr);
|
||||
uhyve_args->flags = flags;
|
||||
uhyve_args->pd = (struct ibv_pd *) virt_to_phys((size_t) pd);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_REREG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
3. The switch-case that catches the KVM exit IO sent to uhyve by the kernel.
|
||||
Required in: ./tool/uhyve.c
|
||||
|
||||
Example:
|
||||
case UHYVE_PORT_IBV_REREG_MR: {
|
||||
unsigned data = *((unsigned*)((size_t)run+run->io.data_offset));
|
||||
uhyve_ibv_rereg_mr_t * args = (uhyve_ibv_rereg_mr_t *) (guest_mem + data);
|
||||
|
||||
int host_ret = ibv_rereg_mr(guest_mem+(size_t)args->mr, flags, guest_mem+(size_t)args->pd);
|
||||
args->ret = host_ret;
|
||||
break;
|
||||
}
|
||||
|
||||
The script also generates an enum mapping all functions to KVM exit IO port
|
||||
names and numbers.
|
||||
Required in: ./tool/uhyve-ibv.h
|
||||
|
||||
Example:
|
||||
typedef enum {
|
||||
UHYVE_PORT_IBV_WC_STATUS_STR = 0x510,
|
||||
UHYVE_PORT_IBV_RATE_TO_MULT = 0x511,
|
||||
UHYVE_PORT_MULT_TO_IBV_RATE = 0x512,
|
||||
// ...
|
||||
} uhyve_ibv_t;
|
||||
"""
|
||||
|
||||
|
||||
# Path of the input file containing function prototypes.
|
||||
SRC_PATH = "function-prototypes-0.txt"
|
||||
|
||||
# Paths of the files that are generated by the script.
|
||||
IBV_GEN_PATH = "GEN-kernel-ibv.c"
|
||||
UHYVE_CASES_GEN_PATH = "GEN-tools-uhyve.c"
|
||||
UHYVE_IBV_HEADER_GEN_PATH = "GEN-tools-uhyve-ibv.h"
|
||||
INCLUDE_STDDEF_GEN_PATH = "GEN-include-hermit-stddef.h"
|
||||
|
||||
# Starting number of the sequence used for IBV ports.
|
||||
PORT_NUMBER_START = 0x510
|
||||
|
||||
|
||||
def get_struct_name(function_name):
|
||||
"""Returns the matching struct name for a given function name.
|
||||
"""
|
||||
return "uhyve_{0}_t".format(function_name)
|
||||
|
||||
|
||||
def parse_line(line):
|
||||
"""Parses a line containing a function prototype.
|
||||
|
||||
Args:
|
||||
line: Line of the following format:
|
||||
<return_type> <function_name>(<param_type> <param_name>, [...])
|
||||
|
||||
Returns:
|
||||
Return type, function name, parameters as Tuple[string, string, list[string]]
|
||||
"""
|
||||
parens_split = line.split("(")
|
||||
|
||||
ret_and_name = parens_split[0].split(" ")
|
||||
all_params = parens_split[-1][:-1]
|
||||
|
||||
ret = " ".join(ret_and_name[:-1])
|
||||
function_name = ret_and_name[-1]
|
||||
|
||||
params = all_params.split(",")
|
||||
params[-1] = params[-1][:-1]
|
||||
|
||||
return ret, function_name, params
|
||||
|
||||
|
||||
def generate_struct(ret, function_name, params):
|
||||
"""Generates the struct to hold a function's parameters and return value.
|
||||
|
||||
Args:
|
||||
ret: Return type as string.
|
||||
function_name: Function name as string.
|
||||
params: Parameters as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated struct as string.
|
||||
"""
|
||||
struct = "typedef struct {\n"
|
||||
if params:
|
||||
struct += "\t// Parameters:\n"
|
||||
for param in params:
|
||||
struct += "\t{0};\n".format(param)
|
||||
|
||||
if ret is not "void":
|
||||
struct += "\t// Return value:\n"
|
||||
struct += "\t{0} ret;\n".format(ret)
|
||||
|
||||
struct_name = get_struct_name(function_name)
|
||||
struct += "}} __attribute__((packed)) {0};\n\n".format(struct_name)
|
||||
|
||||
return struct
|
||||
|
||||
|
||||
def generate_kernel_function(ret, function_name, params):
|
||||
"""Generates the kernel function that sends the KVM exit IO to uhyve.
|
||||
|
||||
Args:
|
||||
ret: Return type as string.
|
||||
function_name: Function name as string.
|
||||
params: Parameters as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated function as string.
|
||||
"""
|
||||
function = "{0} {1}({2}) {{\n".format(ret, function_name, ", ".join(params))
|
||||
|
||||
# Create uhyve_args and define parameters
|
||||
struct_name = get_struct_name(function_name)
|
||||
function += "\t{0} uhyve_args;\n".format(struct_name)
|
||||
for param in params:
|
||||
param_split = param.split(" ")
|
||||
param_type = " ".join(param_split[:-1])
|
||||
param_name = param_split[-1]
|
||||
|
||||
# Define struct members according to their type.
|
||||
if "**" in param_type:
|
||||
function += "\t// TODO: Take care of ** parameter.\n"
|
||||
elif "*" in param_type:
|
||||
function += "\tuhyve_args->{0} = " "({1}) virt_to_phys((size_t) {2});\n".format(
|
||||
param_name, param_type, param_name)
|
||||
else:
|
||||
function += "\tuhyve_args->{0} = {0};\n".format(param_name)
|
||||
|
||||
# Allocate memory for return value if it is a pointer.
|
||||
if "**" in ret:
|
||||
function += "\n\t// TODO: Take care of return value.\n"
|
||||
elif "*" in ret:
|
||||
function += "\n\tuhyve_args->ret = kmalloc(sizeof({0}));\n".format(ret[:-2])
|
||||
|
||||
# call uhyve_send() using the respective port ID.
|
||||
port_name = "UHYVE_PORT_" + function_name.upper()
|
||||
function += "\n\tuhyve_send({0}, (unsigned) virt_to_phys((size_t) " \
|
||||
"&uhyve_args));\n\n".format(port_name)
|
||||
|
||||
function += "\t// TODO: Fix pointers in returned data structures.\n"
|
||||
|
||||
function += "\treturn uhyve_args.ret;\n"
|
||||
function += "}\n\n\n"
|
||||
|
||||
return function
|
||||
|
||||
|
||||
def generate_uhyve_case(ret, function_name, params):
|
||||
"""Generates a switch-case that catches a KVM exit IO for the given function in uhyve.
|
||||
|
||||
Args:
|
||||
ret: Return type as string.
|
||||
function_name: Function name as string.
|
||||
params: Parameters as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated switch-case code as string.
|
||||
"""
|
||||
|
||||
def generate_host_call_parameter(param):
|
||||
"""Generates the parameter for the host's function called from within uhyve.
|
||||
|
||||
This distinguishes between pointers and non-pointers since pointers have to
|
||||
be converted to host memory addresses.
|
||||
Example for pointer: guest_mem+(size_t)args->param
|
||||
Example for non-pointer: args->param
|
||||
|
||||
Args:
|
||||
param: The parameter type and name as a single string.
|
||||
|
||||
Returns:
|
||||
Generated parameter,
|
||||
"""
|
||||
param_name = param.split(" ")[-1]
|
||||
if "**" in param:
|
||||
host_param = "/* TODO: param {0}*/".format(param_name)
|
||||
elif "*" in param:
|
||||
host_param = "guest_mem+(size_t)args->{0}".format(param_name)
|
||||
else:
|
||||
host_param = "{0}".format(param_name)
|
||||
|
||||
return host_param
|
||||
|
||||
port_name = "UHYVE_PORT_" + function_name.upper()
|
||||
struct_name = get_struct_name(function_name)
|
||||
|
||||
case = "\n\t\t\tcase {0}: {{".format(port_name)
|
||||
case += "\n\t\t\t\tunsigned data = *((unsigned*)((size_t)run+run->io.data_offset));"
|
||||
case += "\n\t\t\t\t{0} * args = ({0} *) (guest_mem + data);".format(struct_name)
|
||||
case += "\n\n\t\t\t\t{0} host_ret = {1}(".format(ret, function_name)
|
||||
|
||||
for param in params[:-1]:
|
||||
case += generate_host_call_parameter(param) + ", "
|
||||
else:
|
||||
case += generate_host_call_parameter(params[-1]) + ");"
|
||||
|
||||
if "**" in ret:
|
||||
case += "\n\t\t\t\t// TODO: Take care of {0} return value.".format(ret)
|
||||
elif "*" in ret:
|
||||
case += "\n\t\t\t\tmemcpy(guest_mem+(size_t)args->ret, host_ret, sizeof(host_ret));"
|
||||
else:
|
||||
case += "\n\t\t\t\targs->ret = host_ret;"
|
||||
|
||||
case += "\n\t\t\t\tbreak;"
|
||||
case += "\n\t\t\t}\n"
|
||||
|
||||
return case
|
||||
|
||||
|
||||
def generate_port_enum(function_names):
|
||||
"""Generates the enum mapping KVM exit IO port names to port numbers.
|
||||
|
||||
Args:
|
||||
function_names: All function names to be mapped to ports as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated complete enum.
|
||||
"""
|
||||
port_enum = "typedef enum {"
|
||||
for num, function_name in enumerate(function_names, PORT_NUMBER_START):
|
||||
port_enum += "\n\tUHYVE_PORT_{0} = 0x{1},".format(function_name.upper(),
|
||||
format(num, "X"))
|
||||
port_enum += "\n} uhyve_ibv_t;"
|
||||
|
||||
return port_enum
|
||||
|
||||
|
||||
def generate_port_macros(function_names):
|
||||
"""Generates the compiler macros mapping KVM exit IO port names to port numbers.
|
||||
|
||||
Args:
|
||||
function_names: All function names to be mapped to ports as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated list of compiler macros.
|
||||
"""
|
||||
macros = ""
|
||||
for num, function_name in enumerate(function_names, PORT_NUMBER_START):
|
||||
macros += "\n#define UHYVE_PORT_{0} 0x{1},".format(function_name.upper(),
|
||||
format(num, "X"))
|
||||
return macros
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open(SRC_PATH, "r") as f_src, \
|
||||
open(IBV_GEN_PATH, "w") as f_ibv, \
|
||||
open(UHYVE_CASES_GEN_PATH, "w") as f_uhyve:
|
||||
function_names = []
|
||||
for line in f_src:
|
||||
ret, function_name, params = parse_line(line)
|
||||
function_names.append(function_name)
|
||||
|
||||
struct = generate_struct(ret, function_name, params)
|
||||
f_ibv.write(struct)
|
||||
|
||||
kernel_function = generate_kernel_function(ret, function_name, params)
|
||||
f_ibv.write(kernel_function)
|
||||
|
||||
uhyve_case = generate_uhyve_case(ret, function_name, params)
|
||||
f_uhyve.write(uhyve_case)
|
||||
|
||||
with open(UHYVE_IBV_HEADER_GEN_PATH, "w") as f_uhyve_ibv:
|
||||
port_enum = generate_port_enum(function_names)
|
||||
f_uhyve_ibv.write(port_enum)
|
||||
|
||||
with open(INCLUDE_STDDEF_GEN_PATH, "w") as f_stddef:
|
||||
port_macros = generate_port_macros(function_names)
|
||||
f_stddef.write(port_macros)
|
10
tools/ibv_code_generator/generate_code.py
Executable file → Normal file
10
tools/ibv_code_generator/generate_code.py
Executable file → Normal file
|
@ -89,13 +89,13 @@ Required in: ./tool/uhyve-ibv.h
|
|||
|
||||
|
||||
# Path of the input file containing function prototypes.
|
||||
SRC_PATH = "function_prototypes.txt"
|
||||
SRC_PATH = "function-prototypes-0.txt"
|
||||
|
||||
# Paths of the files that are generated by the script.
|
||||
IBV_GEN_PATH = "GEN_kernel_ibv.c"
|
||||
UHYVE_CASES_GEN_PATH = "GEN_tools_uhyve.c"
|
||||
UHYVE_IBV_HEADER_GEN_PATH = "GEN_tools_uhyve-ibv.h"
|
||||
INCLUDE_STDDEF_GEN_PATH = "GEN_include_hermit_stddef.h"
|
||||
IBV_GEN_PATH = "GEN-kernel-ibv.c"
|
||||
UHYVE_CASES_GEN_PATH = "GEN-tools-uhyve.c"
|
||||
UHYVE_IBV_HEADER_GEN_PATH = "GEN-tools-uhyve-ibv.h"
|
||||
INCLUDE_STDDEF_GEN_PATH = "GEN-include-hermit-stddef.h"
|
||||
|
||||
# Starting number of the sequence used for IBV ports.
|
||||
PORT_NUMBER_START = 0x510
|
||||
|
|
|
@ -78,219 +78,219 @@ struct pingpong_dest {
|
|||
union ibv_gid gid;
|
||||
};
|
||||
|
||||
static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,
|
||||
int sl, struct pingpong_dest *dest, int sgid_idx)
|
||||
{
|
||||
struct ibv_ah_attr ah_attr = {
|
||||
.is_global = 0,
|
||||
.dlid = dest->lid,
|
||||
.sl = sl,
|
||||
.src_path_bits = 0,
|
||||
.port_num = port
|
||||
};
|
||||
struct ibv_qp_attr attr = {
|
||||
.qp_state = IBV_QPS_RTR
|
||||
};
|
||||
/*static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn,*/
|
||||
/*int sl, struct pingpong_dest *dest, int sgid_idx)*/
|
||||
/*{*/
|
||||
/*struct ibv_ah_attr ah_attr = {*/
|
||||
/*.is_global = 0,*/
|
||||
/*.dlid = dest->lid,*/
|
||||
/*.sl = sl,*/
|
||||
/*.src_path_bits = 0,*/
|
||||
/*.port_num = port*/
|
||||
/*};*/
|
||||
/*struct ibv_qp_attr attr = {*/
|
||||
/*.qp_state = IBV_QPS_RTR*/
|
||||
/*};*/
|
||||
|
||||
if (ibv_modify_qp(ctx->qp, &attr, IBV_QP_STATE)) {
|
||||
fprintf(stderr, "Failed to modify QP to RTR\n");
|
||||
return 1;
|
||||
}
|
||||
/*if (ibv_modify_qp(ctx->qp, &attr, IBV_QP_STATE)) {*/
|
||||
/*fprintf(stderr, "Failed to modify QP to RTR\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
attr.qp_state = IBV_QPS_RTS;
|
||||
attr.sq_psn = my_psn;
|
||||
/*attr.qp_state = IBV_QPS_RTS;*/
|
||||
/*attr.sq_psn = my_psn;*/
|
||||
|
||||
if (ibv_modify_qp(ctx->qp, &attr,
|
||||
IBV_QP_STATE |
|
||||
IBV_QP_SQ_PSN)) {
|
||||
fprintf(stderr, "Failed to modify QP to RTS\n");
|
||||
return 1;
|
||||
}
|
||||
/*if (ibv_modify_qp(ctx->qp, &attr,*/
|
||||
/*IBV_QP_STATE |*/
|
||||
/*IBV_QP_SQ_PSN)) {*/
|
||||
/*fprintf(stderr, "Failed to modify QP to RTS\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
if (dest->gid.global.interface_id) {
|
||||
ah_attr.is_global = 1;
|
||||
ah_attr.grh.hop_limit = 1;
|
||||
ah_attr.grh.dgid = dest->gid;
|
||||
ah_attr.grh.sgid_index = sgid_idx;
|
||||
}
|
||||
/*if (dest->gid.global.interface_id) {*/
|
||||
/*ah_attr.is_global = 1;*/
|
||||
/*ah_attr.grh.hop_limit = 1;*/
|
||||
/*ah_attr.grh.dgid = dest->gid;*/
|
||||
/*ah_attr.grh.sgid_index = sgid_idx;*/
|
||||
/*}*/
|
||||
|
||||
ctx->ah = ibv_create_ah(ctx->pd, &ah_attr);
|
||||
if (!ctx->ah) {
|
||||
fprintf(stderr, "Failed to create AH\n");
|
||||
return 1;
|
||||
}
|
||||
/*ctx->ah = ibv_create_ah(ctx->pd, &ah_attr);*/
|
||||
/*if (!ctx->ah) {*/
|
||||
/*fprintf(stderr, "Failed to create AH\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*return 0;*/
|
||||
/*}*/
|
||||
|
||||
static struct pingpong_dest *pp_client_exch_dest(const char *servername, int port,
|
||||
const struct pingpong_dest *my_dest)
|
||||
{
|
||||
struct addrinfo *res, *t;
|
||||
struct addrinfo hints = {
|
||||
.ai_family = AF_UNSPEC,
|
||||
.ai_socktype = SOCK_STREAM
|
||||
};
|
||||
char *service;
|
||||
char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
|
||||
int n;
|
||||
int sockfd = -1;
|
||||
struct pingpong_dest *rem_dest = NULL;
|
||||
char gid[33];
|
||||
/*static struct pingpong_dest *pp_client_exch_dest(const char *servername, int port,*/
|
||||
/*const struct pingpong_dest *my_dest)*/
|
||||
/*{*/
|
||||
/*struct addrinfo *res, *t;*/
|
||||
/*struct addrinfo hints = {*/
|
||||
/*.ai_family = AF_UNSPEC,*/
|
||||
/*.ai_socktype = SOCK_STREAM*/
|
||||
/*};*/
|
||||
/*char *service;*/
|
||||
/*char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];*/
|
||||
/*int n;*/
|
||||
/*int sockfd = -1;*/
|
||||
/*struct pingpong_dest *rem_dest = NULL;*/
|
||||
/*char gid[33];*/
|
||||
|
||||
if (asprintf(&service, "%d", port) < 0)
|
||||
return NULL;
|
||||
/*if (asprintf(&service, "%d", port) < 0)*/
|
||||
/*return NULL;*/
|
||||
|
||||
n = getaddrinfo(servername, service, &hints, &res);
|
||||
/*n = getaddrinfo(servername, service, &hints, &res);*/
|
||||
|
||||
if (n < 0) {
|
||||
fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port);
|
||||
free(service);
|
||||
return NULL;
|
||||
}
|
||||
/*if (n < 0) {*/
|
||||
/*fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port);*/
|
||||
/*free(service);*/
|
||||
/*return NULL;*/
|
||||
/*}*/
|
||||
|
||||
for (t = res; t; t = t->ai_next) {
|
||||
sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
|
||||
if (sockfd >= 0) {
|
||||
if (!connect(sockfd, t->ai_addr, t->ai_addrlen))
|
||||
break;
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
}
|
||||
}
|
||||
/*for (t = res; t; t = t->ai_next) {*/
|
||||
/*sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);*/
|
||||
/*if (sockfd >= 0) {*/
|
||||
/*if (!connect(sockfd, t->ai_addr, t->ai_addrlen))*/
|
||||
/*break;*/
|
||||
/*close(sockfd);*/
|
||||
/*sockfd = -1;*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
|
||||
freeaddrinfo(res);
|
||||
free(service);
|
||||
/*freeaddrinfo(res);*/
|
||||
/*free(service);*/
|
||||
|
||||
if (sockfd < 0) {
|
||||
fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port);
|
||||
return NULL;
|
||||
}
|
||||
/*if (sockfd < 0) {*/
|
||||
/*fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port);*/
|
||||
/*return NULL;*/
|
||||
/*}*/
|
||||
|
||||
gid_to_wire_gid(&my_dest->gid, gid);
|
||||
sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
|
||||
my_dest->psn, gid);
|
||||
if (write(sockfd, msg, sizeof msg) != sizeof msg) {
|
||||
fprintf(stderr, "Couldn't send local address\n");
|
||||
goto out;
|
||||
}
|
||||
/*gid_to_wire_gid(&my_dest->gid, gid);*/
|
||||
/*sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,*/
|
||||
/*my_dest->psn, gid);*/
|
||||
/*if (write(sockfd, msg, sizeof msg) != sizeof msg) {*/
|
||||
/*fprintf(stderr, "Couldn't send local address\n");*/
|
||||
/*goto out;*/
|
||||
/*}*/
|
||||
|
||||
if (read(sockfd, msg, sizeof msg) != sizeof msg ||
|
||||
write(sockfd, "done", sizeof "done") != sizeof "done") {
|
||||
perror("client read/write");
|
||||
fprintf(stderr, "Couldn't read/write remote address\n");
|
||||
goto out;
|
||||
}
|
||||
/*if (read(sockfd, msg, sizeof msg) != sizeof msg ||*/
|
||||
/*write(sockfd, "done", sizeof "done") != sizeof "done") {*/
|
||||
/*perror("client read/write");*/
|
||||
/*fprintf(stderr, "Couldn't read/write remote address\n");*/
|
||||
/*goto out;*/
|
||||
/*}*/
|
||||
|
||||
rem_dest = malloc(sizeof *rem_dest);
|
||||
if (!rem_dest)
|
||||
goto out;
|
||||
/*rem_dest = malloc(sizeof *rem_dest);*/
|
||||
/*if (!rem_dest)*/
|
||||
/*goto out;*/
|
||||
|
||||
sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,
|
||||
&rem_dest->psn, gid);
|
||||
wire_gid_to_gid(gid, &rem_dest->gid);
|
||||
/*sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,*/
|
||||
/*&rem_dest->psn, gid);*/
|
||||
/*wire_gid_to_gid(gid, &rem_dest->gid);*/
|
||||
|
||||
out:
|
||||
close(sockfd);
|
||||
return rem_dest;
|
||||
}
|
||||
/*out:*/
|
||||
/*close(sockfd);*/
|
||||
/*return rem_dest;*/
|
||||
/*}*/
|
||||
|
||||
static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,
|
||||
int ib_port, int port, int sl,
|
||||
const struct pingpong_dest *my_dest,
|
||||
int sgid_idx)
|
||||
{
|
||||
struct addrinfo *res, *t;
|
||||
struct addrinfo hints = {
|
||||
.ai_flags = AI_PASSIVE,
|
||||
.ai_family = AF_UNSPEC,
|
||||
.ai_socktype = SOCK_STREAM
|
||||
};
|
||||
char *service;
|
||||
char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];
|
||||
int n;
|
||||
int sockfd = -1, connfd;
|
||||
struct pingpong_dest *rem_dest = NULL;
|
||||
char gid[33];
|
||||
/*static struct pingpong_dest *pp_server_exch_dest(struct pingpong_context *ctx,*/
|
||||
/*int ib_port, int port, int sl,*/
|
||||
/*const struct pingpong_dest *my_dest,*/
|
||||
/*int sgid_idx)*/
|
||||
/*{*/
|
||||
/*struct addrinfo *res, *t;*/
|
||||
/*struct addrinfo hints = {*/
|
||||
/*.ai_flags = AI_PASSIVE,*/
|
||||
/*.ai_family = AF_UNSPEC,*/
|
||||
/*.ai_socktype = SOCK_STREAM*/
|
||||
/*};*/
|
||||
/*char *service;*/
|
||||
/*char msg[sizeof "0000:000000:000000:00000000000000000000000000000000"];*/
|
||||
/*int n;*/
|
||||
/*int sockfd = -1, connfd;*/
|
||||
/*struct pingpong_dest *rem_dest = NULL;*/
|
||||
/*char gid[33];*/
|
||||
|
||||
if (asprintf(&service, "%d", port) < 0)
|
||||
return NULL;
|
||||
/*if (asprintf(&service, "%d", port) < 0)*/
|
||||
/*return NULL;*/
|
||||
|
||||
n = getaddrinfo(NULL, service, &hints, &res);
|
||||
/*n = getaddrinfo(NULL, service, &hints, &res);*/
|
||||
|
||||
if (n < 0) {
|
||||
fprintf(stderr, "%s for port %d\n", gai_strerror(n), port);
|
||||
free(service);
|
||||
return NULL;
|
||||
}
|
||||
/*if (n < 0) {*/
|
||||
/*fprintf(stderr, "%s for port %d\n", gai_strerror(n), port);*/
|
||||
/*free(service);*/
|
||||
/*return NULL;*/
|
||||
/*}*/
|
||||
|
||||
for (t = res; t; t = t->ai_next) {
|
||||
sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);
|
||||
if (sockfd >= 0) {
|
||||
n = 1;
|
||||
/*for (t = res; t; t = t->ai_next) {*/
|
||||
/*sockfd = socket(t->ai_family, t->ai_socktype, t->ai_protocol);*/
|
||||
/*if (sockfd >= 0) {*/
|
||||
/*n = 1;*/
|
||||
|
||||
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);
|
||||
/*setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);*/
|
||||
|
||||
if (!bind(sockfd, t->ai_addr, t->ai_addrlen))
|
||||
break;
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
}
|
||||
}
|
||||
/*if (!bind(sockfd, t->ai_addr, t->ai_addrlen))*/
|
||||
/*break;*/
|
||||
/*close(sockfd);*/
|
||||
/*sockfd = -1;*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
|
||||
freeaddrinfo(res);
|
||||
free(service);
|
||||
/*freeaddrinfo(res);*/
|
||||
/*free(service);*/
|
||||
|
||||
if (sockfd < 0) {
|
||||
fprintf(stderr, "Couldn't listen to port %d\n", port);
|
||||
return NULL;
|
||||
}
|
||||
/*if (sockfd < 0) {*/
|
||||
/*fprintf(stderr, "Couldn't listen to port %d\n", port);*/
|
||||
/*return NULL;*/
|
||||
/*}*/
|
||||
|
||||
listen(sockfd, 1);
|
||||
connfd = accept(sockfd, NULL, NULL);
|
||||
close(sockfd);
|
||||
if (connfd < 0) {
|
||||
fprintf(stderr, "accept() failed\n");
|
||||
return NULL;
|
||||
}
|
||||
/*listen(sockfd, 1);*/
|
||||
/*connfd = accept(sockfd, NULL, NULL);*/
|
||||
/*close(sockfd);*/
|
||||
/*if (connfd < 0) {*/
|
||||
/*fprintf(stderr, "accept() failed\n");*/
|
||||
/*return NULL;*/
|
||||
/*}*/
|
||||
|
||||
n = read(connfd, msg, sizeof msg);
|
||||
if (n != sizeof msg) {
|
||||
perror("server read");
|
||||
fprintf(stderr, "%d/%d: Couldn't read remote address\n", n, (int) sizeof msg);
|
||||
goto out;
|
||||
}
|
||||
/*n = read(connfd, msg, sizeof msg);*/
|
||||
/*if (n != sizeof msg) {*/
|
||||
/*perror("server read");*/
|
||||
/*fprintf(stderr, "%d/%d: Couldn't read remote address\n", n, (int) sizeof msg);*/
|
||||
/*goto out;*/
|
||||
/*}*/
|
||||
|
||||
rem_dest = malloc(sizeof *rem_dest);
|
||||
if (!rem_dest)
|
||||
goto out;
|
||||
/*rem_dest = malloc(sizeof *rem_dest);*/
|
||||
/*if (!rem_dest)*/
|
||||
/*goto out;*/
|
||||
|
||||
sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,
|
||||
&rem_dest->psn, gid);
|
||||
wire_gid_to_gid(gid, &rem_dest->gid);
|
||||
/*sscanf(msg, "%x:%x:%x:%s", &rem_dest->lid, &rem_dest->qpn,*/
|
||||
/*&rem_dest->psn, gid);*/
|
||||
/*wire_gid_to_gid(gid, &rem_dest->gid);*/
|
||||
|
||||
if (pp_connect_ctx(ctx, ib_port, my_dest->psn, sl, rem_dest,
|
||||
sgid_idx)) {
|
||||
fprintf(stderr, "Couldn't connect to remote QP\n");
|
||||
free(rem_dest);
|
||||
rem_dest = NULL;
|
||||
goto out;
|
||||
}
|
||||
/*if (pp_connect_ctx(ctx, ib_port, my_dest->psn, sl, rem_dest,*/
|
||||
/*sgid_idx)) {*/
|
||||
/*fprintf(stderr, "Couldn't connect to remote QP\n");*/
|
||||
/*free(rem_dest);*/
|
||||
/*rem_dest = NULL;*/
|
||||
/*goto out;*/
|
||||
/*}*/
|
||||
|
||||
gid_to_wire_gid(&my_dest->gid, gid);
|
||||
sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,
|
||||
my_dest->psn, gid);
|
||||
if (write(connfd, msg, sizeof msg) != sizeof msg ||
|
||||
read(connfd, msg, sizeof msg) != sizeof "done") {
|
||||
fprintf(stderr, "Couldn't send/recv local address\n");
|
||||
free(rem_dest);
|
||||
rem_dest = NULL;
|
||||
goto out;
|
||||
}
|
||||
out:
|
||||
close(connfd);
|
||||
return rem_dest;
|
||||
}
|
||||
/*gid_to_wire_gid(&my_dest->gid, gid);*/
|
||||
/*sprintf(msg, "%04x:%06x:%06x:%s", my_dest->lid, my_dest->qpn,*/
|
||||
/*my_dest->psn, gid);*/
|
||||
/*if (write(connfd, msg, sizeof msg) != sizeof msg ||*/
|
||||
/*read(connfd, msg, sizeof msg) != sizeof "done") {*/
|
||||
/*fprintf(stderr, "Couldn't send/recv local address\n");*/
|
||||
/*free(rem_dest);*/
|
||||
/*rem_dest = NULL;*/
|
||||
/*goto out;*/
|
||||
/*}*/
|
||||
/*out:*/
|
||||
/*close(connfd);*/
|
||||
/*return rem_dest;*/
|
||||
/*}*/
|
||||
|
||||
static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, int size,
|
||||
int rx_depth, int port,
|
||||
|
@ -439,116 +439,116 @@ clean_ctx:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int pp_close_ctx(struct pingpong_context *ctx)
|
||||
{
|
||||
if (ibv_destroy_qp(ctx->qp)) {
|
||||
fprintf(stderr, "Couldn't destroy QP\n");
|
||||
return 1;
|
||||
}
|
||||
/*static int pp_close_ctx(struct pingpong_context *ctx)*/
|
||||
/*{*/
|
||||
/*if (ibv_destroy_qp(ctx->qp)) {*/
|
||||
/*fprintf(stderr, "Couldn't destroy QP\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
if (ibv_destroy_cq(ctx->cq)) {
|
||||
fprintf(stderr, "Couldn't destroy CQ\n");
|
||||
return 1;
|
||||
}
|
||||
/*if (ibv_destroy_cq(ctx->cq)) {*/
|
||||
/*fprintf(stderr, "Couldn't destroy CQ\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
if (ibv_dereg_mr(ctx->mr)) {
|
||||
fprintf(stderr, "Couldn't deregister MR\n");
|
||||
return 1;
|
||||
}
|
||||
/*if (ibv_dereg_mr(ctx->mr)) {*/
|
||||
/*fprintf(stderr, "Couldn't deregister MR\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
if (ibv_destroy_ah(ctx->ah)) {
|
||||
fprintf(stderr, "Couldn't destroy AH\n");
|
||||
return 1;
|
||||
}
|
||||
/*if (ibv_destroy_ah(ctx->ah)) {*/
|
||||
/*fprintf(stderr, "Couldn't destroy AH\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
if (ibv_dealloc_pd(ctx->pd)) {
|
||||
fprintf(stderr, "Couldn't deallocate PD\n");
|
||||
return 1;
|
||||
}
|
||||
/*if (ibv_dealloc_pd(ctx->pd)) {*/
|
||||
/*fprintf(stderr, "Couldn't deallocate PD\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
if (ctx->channel) {
|
||||
if (ibv_destroy_comp_channel(ctx->channel)) {
|
||||
fprintf(stderr, "Couldn't destroy completion channel\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*if (ctx->channel) {*/
|
||||
/*if (ibv_destroy_comp_channel(ctx->channel)) {*/
|
||||
/*fprintf(stderr, "Couldn't destroy completion channel\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
|
||||
if (ibv_close_device(ctx->context)) {
|
||||
fprintf(stderr, "Couldn't release context\n");
|
||||
return 1;
|
||||
}
|
||||
/*if (ibv_close_device(ctx->context)) {*/
|
||||
/*fprintf(stderr, "Couldn't release context\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
free(ctx->buf);
|
||||
free(ctx);
|
||||
/*free(ctx->buf);*/
|
||||
/*free(ctx);*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*return 0;*/
|
||||
/*}*/
|
||||
|
||||
static int pp_post_recv(struct pingpong_context *ctx, int n)
|
||||
{
|
||||
struct ibv_sge list = {
|
||||
.addr = (uintptr_t) ctx->buf,
|
||||
.length = ctx->size + 40,
|
||||
.lkey = ctx->mr->lkey
|
||||
};
|
||||
struct ibv_recv_wr wr = {
|
||||
.wr_id = PINGPONG_RECV_WRID,
|
||||
.sg_list = &list,
|
||||
.num_sge = 1,
|
||||
};
|
||||
struct ibv_recv_wr *bad_wr;
|
||||
int i;
|
||||
/*static int pp_post_recv(struct pingpong_context *ctx, int n)*/
|
||||
/*{*/
|
||||
/*struct ibv_sge list = {*/
|
||||
/*.addr = (uintptr_t) ctx->buf,*/
|
||||
/*.length = ctx->size + 40,*/
|
||||
/*.lkey = ctx->mr->lkey*/
|
||||
/*};*/
|
||||
/*struct ibv_recv_wr wr = {*/
|
||||
/*.wr_id = PINGPONG_RECV_WRID,*/
|
||||
/*.sg_list = &list,*/
|
||||
/*.num_sge = 1,*/
|
||||
/*};*/
|
||||
/*struct ibv_recv_wr *bad_wr;*/
|
||||
/*int i;*/
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
if (ibv_post_recv(ctx->qp, &wr, &bad_wr))
|
||||
break;
|
||||
/*for (i = 0; i < n; ++i)*/
|
||||
/*if (ibv_post_recv(ctx->qp, &wr, &bad_wr))*/
|
||||
/*break;*/
|
||||
|
||||
return i;
|
||||
}
|
||||
/*return i;*/
|
||||
/*}*/
|
||||
|
||||
static int pp_post_send(struct pingpong_context *ctx, uint32_t qpn)
|
||||
{
|
||||
struct ibv_sge list = {
|
||||
.addr = (uintptr_t) ctx->buf + 40,
|
||||
.length = ctx->size,
|
||||
.lkey = ctx->mr->lkey
|
||||
};
|
||||
struct ibv_send_wr wr = {
|
||||
.wr_id = PINGPONG_SEND_WRID,
|
||||
.sg_list = &list,
|
||||
.num_sge = 1,
|
||||
.opcode = IBV_WR_SEND,
|
||||
.send_flags = ctx->send_flags,
|
||||
.wr = {
|
||||
.ud = {
|
||||
.ah = ctx->ah,
|
||||
.remote_qpn = qpn,
|
||||
.remote_qkey = 0x11111111
|
||||
}
|
||||
}
|
||||
};
|
||||
struct ibv_send_wr *bad_wr;
|
||||
/*static int pp_post_send(struct pingpong_context *ctx, uint32_t qpn)*/
|
||||
/*{*/
|
||||
/*struct ibv_sge list = {*/
|
||||
/*.addr = (uintptr_t) ctx->buf + 40,*/
|
||||
/*.length = ctx->size,*/
|
||||
/*.lkey = ctx->mr->lkey*/
|
||||
/*};*/
|
||||
/*struct ibv_send_wr wr = {*/
|
||||
/*.wr_id = PINGPONG_SEND_WRID,*/
|
||||
/*.sg_list = &list,*/
|
||||
/*.num_sge = 1,*/
|
||||
/*.opcode = IBV_WR_SEND,*/
|
||||
/*.send_flags = ctx->send_flags,*/
|
||||
/*.wr = {*/
|
||||
/*.ud = {*/
|
||||
/*.ah = ctx->ah,*/
|
||||
/*.remote_qpn = qpn,*/
|
||||
/*.remote_qkey = 0x11111111*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
/*};*/
|
||||
/*struct ibv_send_wr *bad_wr;*/
|
||||
|
||||
return ibv_post_send(ctx->qp, &wr, &bad_wr);
|
||||
}
|
||||
/*return ibv_post_send(ctx->qp, &wr, &bad_wr);*/
|
||||
/*}*/
|
||||
|
||||
static void usage(const char *argv0)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" %s start a server and wait for connection\n", argv0);
|
||||
printf(" %s <host> connect to server at <host>\n", argv0);
|
||||
printf("\n");
|
||||
printf("Options:\n");
|
||||
printf(" -p, --port=<port> listen on/connect to port <port> (default 18515)\n");
|
||||
printf(" -d, --ib-dev=<dev> use IB device <dev> (default first device found)\n");
|
||||
printf(" -i, --ib-port=<port> use port <port> of IB device (default 1)\n");
|
||||
printf(" -s, --size=<size> size of message to exchange (default 2048)\n");
|
||||
printf(" -r, --rx-depth=<dep> number of receives to post at a time (default 500)\n");
|
||||
printf(" -n, --iters=<iters> number of exchanges (default 1000)\n");
|
||||
printf(" -l, --sl=<SL> send messages with service level <SL> (default 0)\n");
|
||||
printf(" -e, --events sleep on CQ events (default poll)\n");
|
||||
printf(" -g, --gid-idx=<gid index> local port gid index\n");
|
||||
}
|
||||
/*static void usage(const char *argv0)*/
|
||||
/*{*/
|
||||
/*printf("Usage:\n");*/
|
||||
/*printf(" %s start a server and wait for connection\n", argv0);*/
|
||||
/*printf(" %s <host> connect to server at <host>\n", argv0);*/
|
||||
/*printf("\n");*/
|
||||
/*printf("Options:\n");*/
|
||||
/*printf(" -p, --port=<port> listen on/connect to port <port> (default 18515)\n");*/
|
||||
/*printf(" -d, --ib-dev=<dev> use IB device <dev> (default first device found)\n");*/
|
||||
/*printf(" -i, --ib-port=<port> use port <port> of IB device (default 1)\n");*/
|
||||
/*printf(" -s, --size=<size> size of message to exchange (default 2048)\n");*/
|
||||
/*printf(" -r, --rx-depth=<dep> number of receives to post at a time (default 500)\n");*/
|
||||
/*printf(" -n, --iters=<iters> number of exchanges (default 1000)\n");*/
|
||||
/*printf(" -l, --sl=<SL> send messages with service level <SL> (default 0)\n");*/
|
||||
/*printf(" -e, --events sleep on CQ events (default poll)\n");*/
|
||||
/*printf(" -g, --gid-idx=<gid index> local port gid index\n");*/
|
||||
/*}*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -684,178 +684,178 @@ int main(int argc, char *argv[])
|
|||
if (!ctx)
|
||||
return 1;
|
||||
|
||||
routs = pp_post_recv(ctx, ctx->rx_depth);
|
||||
if (routs < ctx->rx_depth) {
|
||||
fprintf(stderr, "Couldn't post receive (%d)\n", routs);
|
||||
return 1;
|
||||
}
|
||||
/*routs = pp_post_recv(ctx, ctx->rx_depth);*/
|
||||
/*if (routs < ctx->rx_depth) {*/
|
||||
/*fprintf(stderr, "Couldn't post receive (%d)\n", routs);*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
if (use_event)
|
||||
if (ibv_req_notify_cq(ctx->cq, 0)) {
|
||||
fprintf(stderr, "Couldn't request CQ notification\n");
|
||||
return 1;
|
||||
}
|
||||
/*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)) {
|
||||
fprintf(stderr, "Couldn't get port info\n");
|
||||
return 1;
|
||||
}
|
||||
my_dest.lid = ctx->portinfo.lid;
|
||||
/*if (pp_get_port_info(ctx->context, ib_port, &ctx->portinfo)) {*/
|
||||
/*fprintf(stderr, "Couldn't get port info\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
/*my_dest.lid = ctx->portinfo.lid;*/
|
||||
|
||||
my_dest.qpn = ctx->qp->qp_num;
|
||||
my_dest.psn = lrand48() & 0xffffff;
|
||||
/*my_dest.qpn = ctx->qp->qp_num;*/
|
||||
/*my_dest.psn = lrand48() & 0xffffff;*/
|
||||
|
||||
if (gidx >= 0) {
|
||||
if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) {
|
||||
fprintf(stderr, "Could not get local gid for gid index "
|
||||
"%d\n", gidx);
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
memset(&my_dest.gid, 0, sizeof my_dest.gid);
|
||||
/*if (gidx >= 0) {*/
|
||||
/*if (ibv_query_gid(ctx->context, ib_port, gidx, &my_dest.gid)) {*/
|
||||
/*fprintf(stderr, "Could not get local gid for gid index "*/
|
||||
/*"%d\n", gidx);*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
/*} else*/
|
||||
/*memset(&my_dest.gid, 0, sizeof my_dest.gid);*/
|
||||
|
||||
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);
|
||||
/*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);*/
|
||||
|
||||
if (servername)
|
||||
rem_dest = pp_client_exch_dest(servername, port, &my_dest);
|
||||
else
|
||||
rem_dest = pp_server_exch_dest(ctx, ib_port, port, sl,
|
||||
&my_dest, gidx);
|
||||
/*if (servername)*/
|
||||
/*rem_dest = pp_client_exch_dest(servername, port, &my_dest);*/
|
||||
/*else*/
|
||||
/*rem_dest = pp_server_exch_dest(ctx, ib_port, port, sl,*/
|
||||
/*&my_dest, gidx);*/
|
||||
|
||||
if (!rem_dest)
|
||||
return 1;
|
||||
/*if (!rem_dest)*/
|
||||
/*return 1;*/
|
||||
|
||||
inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid);
|
||||
printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",
|
||||
rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid);
|
||||
/*inet_ntop(AF_INET6, &rem_dest->gid, gid, sizeof gid);*/
|
||||
/*printf(" remote address: LID 0x%04x, QPN 0x%06x, PSN 0x%06x, GID %s\n",*/
|
||||
/*rem_dest->lid, rem_dest->qpn, rem_dest->psn, gid);*/
|
||||
|
||||
if (servername)
|
||||
if (pp_connect_ctx(ctx, ib_port, my_dest.psn, sl, rem_dest,
|
||||
gidx))
|
||||
return 1;
|
||||
/*if (servername)*/
|
||||
/*if (pp_connect_ctx(ctx, ib_port, my_dest.psn, sl, rem_dest,*/
|
||||
/*gidx))*/
|
||||
/*return 1;*/
|
||||
|
||||
ctx->pending = PINGPONG_RECV_WRID;
|
||||
/*ctx->pending = PINGPONG_RECV_WRID;*/
|
||||
|
||||
if (servername) {
|
||||
if (pp_post_send(ctx, rem_dest->qpn)) {
|
||||
fprintf(stderr, "Couldn't post send\n");
|
||||
return 1;
|
||||
}
|
||||
ctx->pending |= PINGPONG_SEND_WRID;
|
||||
}
|
||||
/*if (servername) {*/
|
||||
/*if (pp_post_send(ctx, rem_dest->qpn)) {*/
|
||||
/*fprintf(stderr, "Couldn't post send\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
/*ctx->pending |= PINGPONG_SEND_WRID;*/
|
||||
/*}*/
|
||||
|
||||
if (gettimeofday(&start, NULL)) {
|
||||
perror("gettimeofday");
|
||||
return 1;
|
||||
}
|
||||
/*if (gettimeofday(&start, NULL)) {*/
|
||||
/*perror("gettimeofday");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
rcnt = scnt = 0;
|
||||
while (rcnt < iters || scnt < iters) {
|
||||
if (use_event) {
|
||||
struct ibv_cq *ev_cq;
|
||||
void *ev_ctx;
|
||||
/*rcnt = scnt = 0;*/
|
||||
/*while (rcnt < iters || scnt < iters) {*/
|
||||
/*if (use_event) {*/
|
||||
/*struct ibv_cq *ev_cq;*/
|
||||
/*void *ev_ctx;*/
|
||||
|
||||
if (ibv_get_cq_event(ctx->channel, &ev_cq, &ev_ctx)) {
|
||||
fprintf(stderr, "Failed to get cq_event\n");
|
||||
return 1;
|
||||
}
|
||||
/*if (ibv_get_cq_event(ctx->channel, &ev_cq, &ev_ctx)) {*/
|
||||
/*fprintf(stderr, "Failed to get cq_event\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
++num_cq_events;
|
||||
/*++num_cq_events;*/
|
||||
|
||||
if (ev_cq != ctx->cq) {
|
||||
fprintf(stderr, "CQ event for unknown CQ %p\n", ev_cq);
|
||||
return 1;
|
||||
}
|
||||
/*if (ev_cq != ctx->cq) {*/
|
||||
/*fprintf(stderr, "CQ event for unknown CQ %p\n", ev_cq);*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
if (ibv_req_notify_cq(ctx->cq, 0)) {
|
||||
fprintf(stderr, "Couldn't request CQ notification\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*if (ibv_req_notify_cq(ctx->cq, 0)) {*/
|
||||
/*fprintf(stderr, "Couldn't request CQ notification\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
|
||||
{
|
||||
struct ibv_wc wc[2];
|
||||
int ne, i;
|
||||
/*{*/
|
||||
/*struct ibv_wc wc[2];*/
|
||||
/*int ne, i;*/
|
||||
|
||||
do {
|
||||
ne = ibv_poll_cq(ctx->cq, 2, wc);
|
||||
if (ne < 0) {
|
||||
fprintf(stderr, "poll CQ failed %d\n", ne);
|
||||
return 1;
|
||||
}
|
||||
} while (!use_event && ne < 1);
|
||||
/*do {*/
|
||||
/*ne = ibv_poll_cq(ctx->cq, 2, wc);*/
|
||||
/*if (ne < 0) {*/
|
||||
/*fprintf(stderr, "poll CQ failed %d\n", ne);*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
/*} while (!use_event && ne < 1);*/
|
||||
|
||||
for (i = 0; i < ne; ++i) {
|
||||
if (wc[i].status != IBV_WC_SUCCESS) {
|
||||
fprintf(stderr, "Failed status %s (%d) for wr_id %d\n",
|
||||
ibv_wc_status_str(wc[i].status),
|
||||
wc[i].status, (int) wc[i].wr_id);
|
||||
return 1;
|
||||
}
|
||||
/*for (i = 0; i < ne; ++i) {*/
|
||||
/*if (wc[i].status != IBV_WC_SUCCESS) {*/
|
||||
/*fprintf(stderr, "Failed status %s (%d) for wr_id %d\n",*/
|
||||
/*ibv_wc_status_str(wc[i].status),*/
|
||||
/*wc[i].status, (int) wc[i].wr_id);*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
switch ((int) wc[i].wr_id) {
|
||||
case PINGPONG_SEND_WRID:
|
||||
++scnt;
|
||||
break;
|
||||
/*switch ((int) wc[i].wr_id) {*/
|
||||
/*case PINGPONG_SEND_WRID:*/
|
||||
/*++scnt;*/
|
||||
/*break;*/
|
||||
|
||||
case PINGPONG_RECV_WRID:
|
||||
if (--routs <= 1) {
|
||||
routs += pp_post_recv(ctx, ctx->rx_depth - routs);
|
||||
if (routs < ctx->rx_depth) {
|
||||
fprintf(stderr,
|
||||
"Couldn't post receive (%d)\n",
|
||||
routs);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*case PINGPONG_RECV_WRID:*/
|
||||
/*if (--routs <= 1) {*/
|
||||
/*routs += pp_post_recv(ctx, ctx->rx_depth - routs);*/
|
||||
/*if (routs < ctx->rx_depth) {*/
|
||||
/*fprintf(stderr,*/
|
||||
/*"Couldn't post receive (%d)\n",*/
|
||||
/*routs);*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
|
||||
++rcnt;
|
||||
break;
|
||||
/*++rcnt;*/
|
||||
/*break;*/
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Completion for unknown wr_id %d\n",
|
||||
(int) wc[i].wr_id);
|
||||
return 1;
|
||||
}
|
||||
/*default:*/
|
||||
/*fprintf(stderr, "Completion for unknown wr_id %d\n",*/
|
||||
/*(int) wc[i].wr_id);*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
ctx->pending &= ~(int) wc[i].wr_id;
|
||||
if (scnt < iters && !ctx->pending) {
|
||||
if (pp_post_send(ctx, rem_dest->qpn)) {
|
||||
fprintf(stderr, "Couldn't post send\n");
|
||||
return 1;
|
||||
}
|
||||
ctx->pending = PINGPONG_RECV_WRID |
|
||||
PINGPONG_SEND_WRID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*ctx->pending &= ~(int) wc[i].wr_id;*/
|
||||
/*if (scnt < iters && !ctx->pending) {*/
|
||||
/*if (pp_post_send(ctx, rem_dest->qpn)) {*/
|
||||
/*fprintf(stderr, "Couldn't post send\n");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
/*ctx->pending = PINGPONG_RECV_WRID |*/
|
||||
/*PINGPONG_SEND_WRID;*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
/*}*/
|
||||
|
||||
if (gettimeofday(&end, NULL)) {
|
||||
perror("gettimeofday");
|
||||
return 1;
|
||||
}
|
||||
/*if (gettimeofday(&end, NULL)) {*/
|
||||
/*perror("gettimeofday");*/
|
||||
/*return 1;*/
|
||||
/*}*/
|
||||
|
||||
{
|
||||
float usec = (end.tv_sec - start.tv_sec) * 1000000 +
|
||||
(end.tv_usec - start.tv_usec);
|
||||
long long bytes = (long long) size * iters * 2;
|
||||
/*{*/
|
||||
/*float usec = (end.tv_sec - start.tv_sec) * 1000000 +*/
|
||||
/*(end.tv_usec - start.tv_usec);*/
|
||||
/*long long bytes = (long long) size * iters * 2;*/
|
||||
|
||||
printf("%lld bytes in %.2f seconds = %.2f Mbit/sec\n",
|
||||
bytes, usec / 1000000., bytes * 8. / usec);
|
||||
printf("%d iters in %.2f seconds = %.2f usec/iter\n",
|
||||
iters, usec / 1000000., usec / iters);
|
||||
}
|
||||
/*printf("%lld bytes in %.2f seconds = %.2f Mbit/sec\n",*/
|
||||
/*bytes, usec / 1000000., bytes * 8. / usec);*/
|
||||
/*printf("%d iters in %.2f seconds = %.2f usec/iter\n",*/
|
||||
/*iters, usec / 1000000., usec / iters);*/
|
||||
/*}*/
|
||||
|
||||
ibv_ack_cq_events(ctx->cq, num_cq_events);
|
||||
/*ibv_ack_cq_events(ctx->cq, num_cq_events);*/
|
||||
|
||||
if (pp_close_ctx(ctx))
|
||||
return 1;
|
||||
/*if (pp_close_ctx(ctx))*/
|
||||
/*return 1;*/
|
||||
|
||||
ibv_free_device_list(dev_list);
|
||||
free(rem_dest);
|
||||
/*ibv_free_device_list(dev_list);*/
|
||||
/*free(rem_dest);*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue