diff --git a/include/hermit/stddef.h b/include/hermit/stddef.h index 159787ac5..7db485c73 100644 --- a/include/hermit/stddef.h +++ b/include/hermit/stddef.h @@ -66,8 +66,24 @@ extern const size_t image_size; #define UHYVE_PORT_EXIT 0x503 #define UHYVE_PORT_LSEEK 0x504 -#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x510 -#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x511 +// InfiniBand uhyve port IDs +#define UHYVE_PORT_IBV_OPEN_DEVICE 0x510, +#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x511, +#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x512, +#define UHYVE_PORT_IBV_QUERY_PORT 0x513, +#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x514, +#define UHYVE_PORT_IBV_ALLOC_PD 0x515, +#define UHYVE_PORT_IBV_REG_MR 0x516, +#define UHYVE_PORT_IBV_CREATE_CQ 0x517, +#define UHYVE_PORT_IBV_CREATE_QP 0x518, +#define UHYVE_PORT_IBV_QUERY_QP 0x519, +#define UHYVE_PORT_IBV_MODIFY_QP 0x51A, +#define UHYVE_PORT_IBV_DESTROY_QP 0x51B, +#define UHYVE_PORT_IBV_DESTROY_CQ 0x51C, +#define UHYVE_PORT_IBV_DEREG_MR 0x51D, +#define UHYVE_PORT_IBV_DEALLOC_PD 0x51E, +#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x51F, +#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x520, #define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b)) //#define BUILTIN_EXPECT(exp, b) (exp) diff --git a/kernel/ibv.c b/kernel/ibv.c index 31d1cdae5..4e38960b1 100644 --- a/kernel/ibv.c +++ b/kernel/ibv.c @@ -42,7 +42,7 @@ #define MAX_NUM_OF_IBV_DEVICES 16 -typedef struct { +typedef struct { // CHECKED // Parameters: int , *num_devices; // Return value: @@ -81,21 +81,83 @@ const char* ibv_get_device_name(struct ibv_device *device) { typedef struct { // Parameters: - struct ibv_device *device; + struct ibv_device * device; // Return value: - struct ibv_context *ret; + struct ibv_context * ret; // TODO } __attribute__((packed)) uhyve_ibv_open_device_t; -int ibv_open_device(struct ibv_device *device) { - uhyve_ibv_open_device_t uhyve_args = { - (struct ibv_device *) virt_to_phys((size_t) device), - }; +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)); + uhyve_send(UHYVE_PORT_IBV_OPEN_DEVICE, (unsigned) virt_to_phys((size_t) &uhyve_args)); - // Set all pointers contained in returned data structure to valid kernel space addresses. - uhyve_args->ret->device = device; + // TODO: Fix pointers in returned data structures. + return uhyve_args.ret; +} + + +typedef struct { + // Parameters: + int * num_devices; + // Return value: + struct ibv_device ** ret; // TODO +} __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)); + + return uhyve_args.ret; + // TODO: Fix pointers in returned data structures. +} + + +typedef struct { + // Parameters: + struct ibv_device * device; + // Return value: + const char * ret; // TODO +} __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)); return uhyve_args.ret; } @@ -103,81 +165,271 @@ int ibv_open_device(struct ibv_device *device) { typedef struct { // Parameters: - struct ibv_context *context; + struct ibv_context * context; // Return value: - struct ibv_comp_channel *ret; + struct ibv_comp_channel * ret; // TODO } __attribute__((packed)) uhyve_ibv_create_comp_channel_t; -struct ibv_comp_channel* ibv_create_comp_channel(struct ibv_context *context) { - uhyve_ibv_create_comp_channel_t uhyve_args = { - (struct ibv_context *) virt_to_phys((size_t) context), - }; +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)); - - // Set all pointers contained in returned data structure to valid kernel space addresses. - uhyve_args->ret->device = device; // todo + 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_qp *qp; - struct ibv_qp_attr *attr; + struct ibv_context * context; + // Return value: + struct ibv_pd * ret; // TODO +} __attribute__((packed)) uhyve_ibv_alloc_pd_t; + +struct ibv_pd * ibv_alloc_pd(struct ibv_context * context) { + uhyve_ibv_alloc_pd_t uhyve_args; + uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context); + + uhyve_args->ret = kmalloc(sizeof(struct ibv_pd)); + + uhyve_send(UHYVE_PORT_IBV_ALLOC_PD, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + // TODO: Fix pointers in returned data structures. + return uhyve_args.ret; +} + + +typedef struct { + // Parameters: + struct ibv_pd * pd; + void * addr; + int length; + int access; + // Return value: + struct ibv_mr * ret; // TODO +} __attribute__((packed)) uhyve_ibv_reg_mr_t; + +struct ibv_mr * ibv_reg_mr(struct ibv_pd * pd, void * addr, int length, int access) { + uhyve_ibv_reg_mr_t uhyve_args; + uhyve_args->pd = (struct ibv_pd *) virt_to_phys((size_t) pd); + uhyve_args->addr = (void *) virt_to_phys((size_t) addr); + uhyve_args->length = length; + uhyve_args->access = access; + + uhyve_args->ret = kmalloc(sizeof(struct ibv_mr)); + + uhyve_send(UHYVE_PORT_IBV_REG_MR, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + // TODO: Fix pointers in returned data structures. + return uhyve_args.ret; +} + + +typedef struct { + // Parameters: + struct ibv_context * context; + int cqe; + void * cq_context; + struct ibv_comp_channel * channel; + int comp_vector; + // Return value: + struct ibv_cq * ret; // TODO +} __attribute__((packed)) uhyve_ibv_create_cq_t; + +struct ibv_cq * ibv_create_cq(struct ibv_context * context, int cqe, void * cq_context, struct ibv_comp_channel * channel, int comp_vector) { + uhyve_ibv_create_cq_t uhyve_args; + uhyve_args->context = (struct ibv_context *) virt_to_phys((size_t) context); + uhyve_args->cqe = cqe; + uhyve_args->cq_context = (void *) virt_to_phys((size_t) cq_context); + uhyve_args->channel = (struct ibv_comp_channel *) virt_to_phys((size_t) channel); + uhyve_args->comp_vector = comp_vector; + + uhyve_args->ret = kmalloc(sizeof(struct ibv_cq)); + + uhyve_send(UHYVE_PORT_IBV_CREATE_CQ, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + // TODO: Fix pointers in returned data structures. + return uhyve_args.ret; +} + + +typedef struct { + // Parameters: + struct ibv_pd * pd; + struct ibv_qp_init_attr * qp_init_attr; + // Return value: + struct ibv_qp * ret; // TODO +} __attribute__((packed)) uhyve_ibv_create_qp_t; + +struct ibv_qp * ibv_create_qp(struct ibv_pd * pd, struct ibv_qp_init_attr * qp_init_attr) { + uhyve_ibv_create_qp_t uhyve_args; + uhyve_args->pd = (struct ibv_pd *) virt_to_phys((size_t) pd); + uhyve_args->qp_init_attr = (struct ibv_qp_init_attr *) virt_to_phys((size_t) qp_init_attr); + + uhyve_args->ret = kmalloc(sizeof(struct ibv_qp)); + + uhyve_send(UHYVE_PORT_IBV_CREATE_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + // TODO: Fix pointers in returned data structures. + return uhyve_args.ret; +} + + +typedef struct { + // Parameters: + struct ibv_qp * qp; + struct ibv_qp_attr * attr; + int attr_mask; + struct ibv_qp_init_attr * init_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_query_qp_t; + +int ibv_query_qp(struct ibv_qp * qp, struct ibv_qp_attr * attr, int attr_mask, struct ibv_qp_init_attr * init_attr) { + uhyve_ibv_query_qp_t uhyve_args; + uhyve_args->qp = (struct ibv_qp *) virt_to_phys((size_t) qp); + uhyve_args->attr = (struct ibv_qp_attr *) virt_to_phys((size_t) attr); + uhyve_args->attr_mask = attr_mask; + uhyve_args->init_attr = (struct ibv_qp_init_attr *) virt_to_phys((size_t) init_attr); + + uhyve_send(UHYVE_PORT_IBV_QUERY_QP, (unsigned) virt_to_phys((size_t) &uhyve_args)); + + // TODO: Fix pointers in returned data structures. + return uhyve_args.ret; +} + + +typedef struct { + // Parameters: + struct ibv_qp * qp; + struct ibv_qp_attr * attr; int attr_mask; // Return value: int ret; } __attribute__((packed)) uhyve_ibv_modify_qp_t; -int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask) { - uhyve_ibv_modify_qp_t uhyve_args = { - (struct ibv_qp *) virt_to_phys((size_t) qp), - (struct ibv_qp_attr *) virt_to_phys((size_t) attr), - attr_mask, - -1 - }; - uhyve_send(UHYVE_PORT_IBV_MODIFY_QP, (unsigned)virt_to_phys((size_t) &uhyve_args)); +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_pd *pd; - struct ibv_ah_attr *attr; + struct ibv_qp * qp; // Return value: - struct ibv_ah *ret; -} __attribute__((packed)) uhyve_ibv_create_ah_t; + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_qp_t; -struct ibv_ah* ibv_create_ah(struct ibv_pd *pd,struct ibv_ah_attr *attr) { - uhyve_ibv_create_ah_t uhyve_args = { - (struct ibv_pd *) virt_to_phys((size_t) pd), - (struct ibv_ah_attr *) virt_to_phys((size_t) attr), - }; - uhyve_send(UHYVE_PORT_IBV_CREATE_AH, (unsigned)virt_to_phys((size_t) &uhyve_args)); +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; } -/*struct ibv_device** h_ibv_get_device_list(int *num_devices)*/ -/*{*/ - /*struct ibv_device *devs = calloc(MAX_NUM_OF_IBV_DEVICES, sizeof(struct ibv_device));*/ +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; +} - /*struct ibv_device **list_phys; */ - /*struct ibv_device **list_virt;*/ - /*list_phys = calloc(MAX_NUM_OF_IBV_DEVICES, sizeof(struct ibv_device *)); // NUM + 1 ???*/ - /*list_virt = calloc(MAX_NUM_OF_IBV_DEVICES, sizeof(struct ibv_device *)); // NUM + 1 ???*/ - /*for (int i = 0; i < MAX_NUM_OF_IBV_DEVICES; i++) {*/ - /*struct ibv_device* device_address = devs + i;*/ - /*list_virt[i] = device_address;*/ - /*list_phys[i] = (struct ibv_device*) virt_to_phys((size_t) device_address);*/ - /*[>list_phys[i] = calloc(1, sizeof(struct ibv_device));<]*/ - /*}*/ - /*uhyve_ibv_get_device_list_t uhyve_args =*/ - /*{(int*) virt_to_phys((size_t) num_devices), (struct ibv_device**) virt_to_phys((size_t) list_phys)};*/ - /*uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned)virt_to_phys((size_t)&uhyve_args));*/ - /*return list_virt;*/ -/*}*/ diff --git a/tools/ibv_code_generator/GEN-tools-uhyve-ibv.h b/tools/ibv_code_generator/GEN-tools-uhyve-ibv-ports.h similarity index 100% rename from tools/ibv_code_generator/GEN-tools-uhyve-ibv.h rename to tools/ibv_code_generator/GEN-tools-uhyve-ibv-ports.h diff --git a/tools/ibv_code_generator/GEN-tools-uhyve-ibv-structs.h b/tools/ibv_code_generator/GEN-tools-uhyve-ibv-structs.h new file mode 100644 index 000000000..7ece43ec8 --- /dev/null +++ b/tools/ibv_code_generator/GEN-tools-uhyve-ibv-structs.h @@ -0,0 +1,134 @@ +typedef struct { + // Parameters: + struct ibv_device * device; + // Return value: + struct ibv_context * ret; +} __attribute__((packed)) uhyve_ibv_open_device_t; + +typedef struct { + // Parameters: + int * num_devices; + // Return value: + struct ibv_device ** ret; +} __attribute__((packed)) uhyve_ibv_get_device_list_t; + +typedef struct { + // Parameters: + struct ibv_device * device; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_get_device_name_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + uint8_t port_num; + struct ibv_port_attr * port_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_query_port_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + struct ibv_comp_channel * ret; +} __attribute__((packed)) uhyve_ibv_create_comp_channel_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + struct ibv_pd * ret; +} __attribute__((packed)) uhyve_ibv_alloc_pd_t; + +typedef struct { + // Parameters: + struct ibv_pd * pd; + void * addr; + int length; + int access; + // Return value: + struct ibv_mr * ret; +} __attribute__((packed)) uhyve_ibv_reg_mr_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + int cqe; + void * cq_context; + struct ibv_comp_channel * channel; + int comp_vector; + // Return value: + struct ibv_cq * ret; +} __attribute__((packed)) uhyve_ibv_create_cq_t; + +typedef struct { + // Parameters: + struct ibv_pd * pd; + struct ibv_qp_init_attr * qp_init_attr; + // Return value: + struct ibv_qp * ret; +} __attribute__((packed)) uhyve_ibv_create_qp_t; + +typedef struct { + // Parameters: + struct ibv_qp * qp; + struct ibv_qp_attr * attr; + int attr_mask; + struct ibv_qp_init_attr * init_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_query_qp_t; + +typedef struct { + // Parameters: + struct ibv_qp * qp; + struct ibv_qp_attr * attr; + int attr_mask; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_modify_qp_t; + +typedef struct { + // Parameters: + struct ibv_qp * qp; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_qp_t; + +typedef struct { + // Parameters: + struct ibv_cq * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_cq_t; + +typedef struct { + // Parameters: + struct ibv_mr * mr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dereg_mr_t; + +typedef struct { + // Parameters: + struct ibv_pd * pd; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dealloc_pd_t; + +typedef struct { + // Parameters: + struct ibv_comp_channel * channel; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_comp_channel_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_close_device_t; + diff --git a/tools/ibv_code_generator/generate-code.py b/tools/ibv_code_generator/generate-code.py index 81c16237a..e1c0c9430 100755 --- a/tools/ibv_code_generator/generate-code.py +++ b/tools/ibv_code_generator/generate-code.py @@ -94,8 +94,9 @@ 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" +UHYVE_IBV_HEADER_GEN_PATH = "GEN-tools-uhyve-ibv-ports.h" INCLUDE_STDDEF_GEN_PATH = "GEN-include-hermit-stddef.h" +UHYVE_IBV_HEADER_STRUCTS_GEN_PATH = "GEN-tools-uhyve-ibv-structs.h" # Starting number of the sequence used for IBV ports. PORT_NUMBER_START = 0x510 @@ -305,8 +306,9 @@ def generate_port_macros(function_names): 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: + open(IBV_GEN_PATH, "w") as f_ibv, \ + open(UHYVE_CASES_GEN_PATH, "w") as f_uhyve, \ + open(UHYVE_IBV_HEADER_STRUCTS_GEN_PATH, "w") as f_structs: function_names = [] for line in f_src: ret, function_name, params = parse_line(line) @@ -314,6 +316,7 @@ if __name__ == "__main__": struct = generate_struct(ret, function_name, params) f_ibv.write(struct) + f_structs.write(struct) kernel_function = generate_kernel_function(ret, function_name, params) f_ibv.write(kernel_function) diff --git a/tools/uhyve-ibv.h b/tools/uhyve-ibv.h index de15ceacd..e53744e59 100644 --- a/tools/uhyve-ibv.h +++ b/tools/uhyve-ibv.h @@ -24,20 +24,26 @@ #define MAX_NUM_OF_IBV_DEVICES 16 typedef enum { - UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x510, - UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x511, - UHYVE_PORT_IBV_OPEN_DEVICE = 0x512, - UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x513, - UHYVE_PORT_IBV_ALLOC_PD = 0x514, - UHYVE_PORT_IBV_REG_MR = 0x515, - UHYVE_PORT_IBV_CREATE_CQ = 0x516, - UHYVE_PORT_IBV_CREATE_QP = 0x517, - UHYVE_PORT_IBV_QUERY_QP = 0x518, - UHYVE_PORT_IBV_MODIFY_QP = 0x519, - //UHYVE_PORT_IBV_CREATE_AH = 0x520, + 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; -typedef struct { +typedef struct { // CHECKED // In: int *num_devices; // Out: @@ -48,8 +54,84 @@ typedef struct { typedef struct { // Parameters: - struct ibv_qp *qp; - struct ibv_qp_attr *attr; + struct ibv_device * device; + // Return value: + struct ibv_context * ret; +} __attribute__((packed)) uhyve_ibv_open_device_t; + +typedef struct { + // Parameters: + struct ibv_device * device; + // Return value: + const char * ret; +} __attribute__((packed)) uhyve_ibv_get_device_name_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + uint8_t port_num; + struct ibv_port_attr * port_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_query_port_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + struct ibv_comp_channel * ret; +} __attribute__((packed)) uhyve_ibv_create_comp_channel_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + struct ibv_pd * ret; +} __attribute__((packed)) uhyve_ibv_alloc_pd_t; + +typedef struct { + // Parameters: + struct ibv_pd * pd; + void * addr; + int length; + int access; + // Return value: + struct ibv_mr * ret; +} __attribute__((packed)) uhyve_ibv_reg_mr_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + int cqe; + void * cq_context; + struct ibv_comp_channel * channel; + int comp_vector; + // Return value: + struct ibv_cq * ret; +} __attribute__((packed)) uhyve_ibv_create_cq_t; + +typedef struct { + // Parameters: + struct ibv_pd * pd; + struct ibv_qp_init_attr * qp_init_attr; + // Return value: + struct ibv_qp * ret; +} __attribute__((packed)) uhyve_ibv_create_qp_t; + +typedef struct { + // Parameters: + struct ibv_qp * qp; + struct ibv_qp_attr * attr; + int attr_mask; + struct ibv_qp_init_attr * init_attr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_query_qp_t; + +typedef struct { + // Parameters: + struct ibv_qp * qp; + struct ibv_qp_attr * attr; int attr_mask; // Return value: int ret; @@ -57,16 +139,45 @@ typedef struct { typedef struct { // Parameters: - struct ibv_pd *pd; - struct ibv_ah_attr *attr; + struct ibv_qp * qp; // Return value: - struct ibv_ah *ret; -} __attribute__((packed)) uhyve_ibv_create_ah_t; + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_qp_t; -//typedef struct { - //struct ibv_device *device; - //char *ret; -//} __attribute__((packed)) uhyve_ibv_get_device_name_t; +typedef struct { + // Parameters: + struct ibv_cq * cq; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_cq_t; + +typedef struct { + // Parameters: + struct ibv_mr * mr; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dereg_mr_t; + +typedef struct { + // Parameters: + struct ibv_pd * pd; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_dealloc_pd_t; + +typedef struct { + // Parameters: + struct ibv_comp_channel * channel; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_destroy_comp_channel_t; + +typedef struct { + // Parameters: + struct ibv_context * context; + // Return value: + int ret; +} __attribute__((packed)) uhyve_ibv_close_device_t; #endif // UHYVE_IBV_H