mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
Py Generator cleanup (removed some classes, function docs. overall doc tbd)
This commit is contained in:
parent
4d4322e879
commit
0ab739f7ab
10 changed files with 537 additions and 545 deletions
|
@ -1,3 +1,4 @@
|
|||
annika.wierichs@rwth-aachen.de
|
||||
/*
|
||||
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
|
||||
* Copyright (c) 2004, 2011-2012 Intel Corporation. All rights reserved.
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
#define UHYVE_PORT_SET_IB_POOL_ADDR 0x60F
|
||||
#define UHYVE_PORT_IBV_WC_STATUS_STR 0x610
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MULT 0x611
|
||||
#define UHYVE_PORT_MULT_TO_IBV_RATE 0x612
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MBPS 0x613
|
||||
#define UHYVE_PORT_MBPS_TO_IBV_RATE 0x614
|
||||
#define UHYVE_PORT_IBV_CQ_EX_TO_CQ 0x615
|
||||
#define UHYVE_PORT_IBV_START_POLL 0x616
|
||||
#define UHYVE_PORT_IBV_NEXT_POLL 0x617
|
||||
#define UHYVE_PORT_IBV_END_POLL 0x618
|
||||
#define UHYVE_PORT_IBV_WC_READ_OPCODE 0x619
|
||||
#define UHYVE_PORT_IBV_WC_READ_VENDOR_ERR 0x61A
|
||||
#define UHYVE_PORT_IBV_WC_READ_BYTE_LEN 0x61B
|
||||
#define UHYVE_PORT_IBV_WC_READ_IMM_DATA 0x61C
|
||||
#define UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY 0x61D
|
||||
#define UHYVE_PORT_IBV_WC_READ_QP_NUM 0x61E
|
||||
#define UHYVE_PORT_IBV_WC_READ_SRC_QP 0x61F
|
||||
#define UHYVE_PORT_IBV_WC_READ_WC_FLAGS 0x620
|
||||
#define UHYVE_PORT_IBV_WC_READ_SLID 0x621
|
||||
#define UHYVE_PORT_IBV_WC_READ_SL 0x622
|
||||
#define UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS 0x623
|
||||
#define UHYVE_PORT_IBV_WC_READ_COMPLETION_TS 0x624
|
||||
#define UHYVE_PORT_IBV_WC_READ_CVLAN 0x625
|
||||
#define UHYVE_PORT_IBV_WC_READ_FLOW_TAG 0x626
|
||||
#define UHYVE_PORT_IBV_POST_WQ_RECV 0x627
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x628
|
||||
#define UHYVE_PORT_IBV_FREE_DEVICE_LIST 0x629
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x62A
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_GUID 0x62B
|
||||
#define UHYVE_PORT_IBV_OPEN_DEVICE 0x62C
|
||||
#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x62D
|
||||
#define UHYVE_PORT_IBV_GET_ASYNC_EVENT 0x62E
|
||||
#define UHYVE_PORT_IBV_ACK_ASYNC_EVENT 0x62F
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE 0x630
|
||||
#define UHYVE_PORT_IBV_QUERY_PORT 0x631
|
||||
#define UHYVE_PORT_IBV_QUERY_GID 0x632
|
||||
#define UHYVE_PORT_IBV_QUERY_PKEY 0x633
|
||||
#define UHYVE_PORT_IBV_ALLOC_PD 0x634
|
||||
#define UHYVE_PORT_IBV_DEALLOC_PD 0x635
|
||||
#define UHYVE_PORT_IBV_CREATE_FLOW 0x636
|
||||
#define UHYVE_PORT_IBV_DESTROY_FLOW 0x637
|
||||
#define UHYVE_PORT_IBV_OPEN_XRCD 0x638
|
||||
#define UHYVE_PORT_IBV_CLOSE_XRCD 0x639
|
||||
#define UHYVE_PORT_IBV_REG_MR 0x63A
|
||||
#define UHYVE_PORT_IBV_REREG_MR 0x63B
|
||||
#define UHYVE_PORT_IBV_DEREG_MR 0x63C
|
||||
#define UHYVE_PORT_IBV_ALLOC_MW 0x63D
|
||||
#define UHYVE_PORT_IBV_DEALLOC_MW 0x63E
|
||||
#define UHYVE_PORT_IBV_INC_RKEY 0x63F
|
||||
#define UHYVE_PORT_IBV_BIND_MW 0x640
|
||||
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x641
|
||||
#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x642
|
||||
#define UHYVE_PORT_IBV_CREATE_CQ 0x643
|
||||
#define UHYVE_PORT_IBV_CREATE_CQ_EX 0x644
|
||||
#define UHYVE_PORT_IBV_RESIZE_CQ 0x645
|
||||
#define UHYVE_PORT_IBV_DESTROY_CQ 0x646
|
||||
#define UHYVE_PORT_IBV_GET_CQ_EVENT 0x647
|
||||
#define UHYVE_PORT_IBV_ACK_CQ_EVENTS 0x648
|
||||
#define UHYVE_PORT_IBV_POLL_CQ 0x649
|
||||
#define UHYVE_PORT_IBV_REQ_NOTIFY_CQ 0x64A
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ 0x64B
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ_EX 0x64C
|
||||
#define UHYVE_PORT_IBV_MODIFY_SRQ 0x64D
|
||||
#define UHYVE_PORT_IBV_QUERY_SRQ 0x64E
|
||||
#define UHYVE_PORT_IBV_GET_SRQ_NUM 0x64F
|
||||
#define UHYVE_PORT_IBV_DESTROY_SRQ 0x650
|
||||
#define UHYVE_PORT_IBV_POST_SRQ_RECV 0x651
|
||||
#define UHYVE_PORT_IBV_CREATE_QP 0x652
|
||||
#define UHYVE_PORT_IBV_CREATE_QP_EX 0x653
|
||||
#define UHYVE_PORT_IBV_QUERY_RT_VALUES_EX 0x654
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE_EX 0x655
|
||||
#define UHYVE_PORT_IBV_OPEN_QP 0x656
|
||||
#define UHYVE_PORT_IBV_MODIFY_QP 0x657
|
||||
#define UHYVE_PORT_IBV_QUERY_QP 0x658
|
||||
#define UHYVE_PORT_IBV_DESTROY_QP 0x659
|
||||
#define UHYVE_PORT_IBV_CREATE_WQ 0x65A
|
||||
#define UHYVE_PORT_IBV_MODIFY_WQ 0x65B
|
||||
#define UHYVE_PORT_IBV_DESTROY_WQ 0x65C
|
||||
#define UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE 0x65D
|
||||
#define UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE 0x65E
|
||||
#define UHYVE_PORT_IBV_POST_SEND 0x65F
|
||||
#define UHYVE_PORT_IBV_POST_RECV 0x660
|
||||
#define UHYVE_PORT_IBV_CREATE_AH 0x661
|
||||
#define UHYVE_PORT_IBV_INIT_AH_FROM_WC 0x662
|
||||
#define UHYVE_PORT_IBV_CREATE_AH_FROM_WC 0x663
|
||||
#define UHYVE_PORT_IBV_DESTROY_AH 0x664
|
||||
#define UHYVE_PORT_IBV_ATTACH_MCAST 0x665
|
||||
#define UHYVE_PORT_IBV_DETACH_MCAST 0x666
|
||||
#define UHYVE_PORT_IBV_FORK_INIT 0x667
|
||||
#define UHYVE_PORT_IBV_NODE_TYPE_STR 0x668
|
||||
#define UHYVE_PORT_IBV_PORT_STATE_STR 0x669
|
||||
#define UHYVE_PORT_IBV_EVENT_TYPE_STR 0x66A
|
||||
#define UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID 0x66B
|
||||
#define UHYVE_PORT_IBV_IS_QPT_SUPPORTED 0x66C
|
||||
#define UHYVE_PORT_SET_IB_POOL_ADDR 0x610
|
||||
#define UHYVE_PORT_IBV_WC_STATUS_STR 0x611
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MULT 0x612
|
||||
#define UHYVE_PORT_MULT_TO_IBV_RATE 0x613
|
||||
#define UHYVE_PORT_IBV_RATE_TO_MBPS 0x614
|
||||
#define UHYVE_PORT_MBPS_TO_IBV_RATE 0x615
|
||||
#define UHYVE_PORT_IBV_CQ_EX_TO_CQ 0x616
|
||||
#define UHYVE_PORT_IBV_START_POLL 0x617
|
||||
#define UHYVE_PORT_IBV_NEXT_POLL 0x618
|
||||
#define UHYVE_PORT_IBV_END_POLL 0x619
|
||||
#define UHYVE_PORT_IBV_WC_READ_OPCODE 0x61A
|
||||
#define UHYVE_PORT_IBV_WC_READ_VENDOR_ERR 0x61B
|
||||
#define UHYVE_PORT_IBV_WC_READ_BYTE_LEN 0x61C
|
||||
#define UHYVE_PORT_IBV_WC_READ_IMM_DATA 0x61D
|
||||
#define UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY 0x61E
|
||||
#define UHYVE_PORT_IBV_WC_READ_QP_NUM 0x61F
|
||||
#define UHYVE_PORT_IBV_WC_READ_SRC_QP 0x620
|
||||
#define UHYVE_PORT_IBV_WC_READ_WC_FLAGS 0x621
|
||||
#define UHYVE_PORT_IBV_WC_READ_SLID 0x622
|
||||
#define UHYVE_PORT_IBV_WC_READ_SL 0x623
|
||||
#define UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS 0x624
|
||||
#define UHYVE_PORT_IBV_WC_READ_COMPLETION_TS 0x625
|
||||
#define UHYVE_PORT_IBV_WC_READ_CVLAN 0x626
|
||||
#define UHYVE_PORT_IBV_WC_READ_FLOW_TAG 0x627
|
||||
#define UHYVE_PORT_IBV_POST_WQ_RECV 0x628
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_LIST 0x629
|
||||
#define UHYVE_PORT_IBV_FREE_DEVICE_LIST 0x62A
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_NAME 0x62B
|
||||
#define UHYVE_PORT_IBV_GET_DEVICE_GUID 0x62C
|
||||
#define UHYVE_PORT_IBV_OPEN_DEVICE 0x62D
|
||||
#define UHYVE_PORT_IBV_CLOSE_DEVICE 0x62E
|
||||
#define UHYVE_PORT_IBV_GET_ASYNC_EVENT 0x62F
|
||||
#define UHYVE_PORT_IBV_ACK_ASYNC_EVENT 0x630
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE 0x631
|
||||
#define UHYVE_PORT_IBV_QUERY_PORT 0x632
|
||||
#define UHYVE_PORT_IBV_QUERY_GID 0x633
|
||||
#define UHYVE_PORT_IBV_QUERY_PKEY 0x634
|
||||
#define UHYVE_PORT_IBV_ALLOC_PD 0x635
|
||||
#define UHYVE_PORT_IBV_DEALLOC_PD 0x636
|
||||
#define UHYVE_PORT_IBV_CREATE_FLOW 0x637
|
||||
#define UHYVE_PORT_IBV_DESTROY_FLOW 0x638
|
||||
#define UHYVE_PORT_IBV_OPEN_XRCD 0x639
|
||||
#define UHYVE_PORT_IBV_CLOSE_XRCD 0x63A
|
||||
#define UHYVE_PORT_IBV_REG_MR 0x63B
|
||||
#define UHYVE_PORT_IBV_REREG_MR 0x63C
|
||||
#define UHYVE_PORT_IBV_DEREG_MR 0x63D
|
||||
#define UHYVE_PORT_IBV_ALLOC_MW 0x63E
|
||||
#define UHYVE_PORT_IBV_DEALLOC_MW 0x63F
|
||||
#define UHYVE_PORT_IBV_INC_RKEY 0x640
|
||||
#define UHYVE_PORT_IBV_BIND_MW 0x641
|
||||
#define UHYVE_PORT_IBV_CREATE_COMP_CHANNEL 0x642
|
||||
#define UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL 0x643
|
||||
#define UHYVE_PORT_IBV_CREATE_CQ 0x644
|
||||
#define UHYVE_PORT_IBV_CREATE_CQ_EX 0x645
|
||||
#define UHYVE_PORT_IBV_RESIZE_CQ 0x646
|
||||
#define UHYVE_PORT_IBV_DESTROY_CQ 0x647
|
||||
#define UHYVE_PORT_IBV_GET_CQ_EVENT 0x648
|
||||
#define UHYVE_PORT_IBV_ACK_CQ_EVENTS 0x649
|
||||
#define UHYVE_PORT_IBV_POLL_CQ 0x64A
|
||||
#define UHYVE_PORT_IBV_REQ_NOTIFY_CQ 0x64B
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ 0x64C
|
||||
#define UHYVE_PORT_IBV_CREATE_SRQ_EX 0x64D
|
||||
#define UHYVE_PORT_IBV_MODIFY_SRQ 0x64E
|
||||
#define UHYVE_PORT_IBV_QUERY_SRQ 0x64F
|
||||
#define UHYVE_PORT_IBV_GET_SRQ_NUM 0x650
|
||||
#define UHYVE_PORT_IBV_DESTROY_SRQ 0x651
|
||||
#define UHYVE_PORT_IBV_POST_SRQ_RECV 0x652
|
||||
#define UHYVE_PORT_IBV_CREATE_QP 0x653
|
||||
#define UHYVE_PORT_IBV_CREATE_QP_EX 0x654
|
||||
#define UHYVE_PORT_IBV_QUERY_RT_VALUES_EX 0x655
|
||||
#define UHYVE_PORT_IBV_QUERY_DEVICE_EX 0x656
|
||||
#define UHYVE_PORT_IBV_OPEN_QP 0x657
|
||||
#define UHYVE_PORT_IBV_MODIFY_QP 0x658
|
||||
#define UHYVE_PORT_IBV_QUERY_QP 0x659
|
||||
#define UHYVE_PORT_IBV_DESTROY_QP 0x65A
|
||||
#define UHYVE_PORT_IBV_CREATE_WQ 0x65B
|
||||
#define UHYVE_PORT_IBV_MODIFY_WQ 0x65C
|
||||
#define UHYVE_PORT_IBV_DESTROY_WQ 0x65D
|
||||
#define UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE 0x65E
|
||||
#define UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE 0x65F
|
||||
#define UHYVE_PORT_IBV_POST_SEND 0x660
|
||||
#define UHYVE_PORT_IBV_POST_RECV 0x661
|
||||
#define UHYVE_PORT_IBV_CREATE_AH 0x662
|
||||
#define UHYVE_PORT_IBV_INIT_AH_FROM_WC 0x663
|
||||
#define UHYVE_PORT_IBV_CREATE_AH_FROM_WC 0x664
|
||||
#define UHYVE_PORT_IBV_DESTROY_AH 0x665
|
||||
#define UHYVE_PORT_IBV_ATTACH_MCAST 0x666
|
||||
#define UHYVE_PORT_IBV_DETACH_MCAST 0x667
|
||||
#define UHYVE_PORT_IBV_FORK_INIT 0x668
|
||||
#define UHYVE_PORT_IBV_NODE_TYPE_STR 0x669
|
||||
#define UHYVE_PORT_IBV_PORT_STATE_STR 0x66A
|
||||
#define UHYVE_PORT_IBV_EVENT_TYPE_STR 0x66B
|
||||
#define UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID 0x66C
|
||||
#define UHYVE_PORT_IBV_IS_QPT_SUPPORTED 0x66D
|
||||
|
|
|
@ -89,5 +89,5 @@ int ibv_fork_init();
|
|||
const char * ibv_node_type_str(enum ibv_node_type node_type);
|
||||
const char * ibv_port_state_str(enum ibv_port_state port_state);
|
||||
const char * ibv_event_type_str(enum ibv_event_type event);
|
||||
int ibv_resolve_eth_l2_from_gid(struct ibv_context * context, struct ibv_ah_attr * attr, uint8_t [6] eth_mac, uint16_t * vid);
|
||||
int ibv_resolve_eth_l2_from_gid(struct ibv_context * context, struct ibv_ah_attr * attr, uint8_t eth_mac[6], uint16_t * vid);
|
||||
int ibv_is_qpt_supported(uint32_t caps, enum ibv_qp_type qpt);
|
||||
|
|
|
@ -182,6 +182,7 @@ void ibv_end_poll(struct ibv_cq_ex * cq) {
|
|||
uhyve_args.cq = cq;
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_END_POLL, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -495,11 +496,17 @@ typedef struct {
|
|||
int ibv_post_wq_recv(struct ibv_wq * wq, struct ibv_recv_wr * recv_wr, struct ibv_recv_wr ** bad_recv_wr) {
|
||||
uhyve_ibv_post_wq_recv_t uhyve_args;
|
||||
uhyve_args.wq = wq;
|
||||
uhyve_args.recv_wr = recv_wr;
|
||||
// TODO: Take care of ** parameter.
|
||||
uhyve_args.recv_wr = (struct ibv_recv_wr *) guest_to_host((size_t) recv_wr);
|
||||
uhyve_args.bad_recv_wr = (struct ibv_recv_wr **) guest_to_host((size_t) bad_recv_wr); // TODO: Check ** param here.
|
||||
|
||||
// TODO: Take care of pointer conversions in recv_wr.
|
||||
// TODO: Take care of pointer conversions in bad_recv_wr.
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_POST_WQ_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Take care of reverse pointer conversions in recv_wr.
|
||||
// TODO: Take care of reverse pointer conversions in bad_recv_wr.
|
||||
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
@ -517,7 +524,7 @@ typedef struct {
|
|||
|
||||
struct ibv_device ** ibv_get_device_list(int * num_devices) {
|
||||
uhyve_ibv_get_device_list_t uhyve_args;
|
||||
uhyve_args.num_devices = num_devices;
|
||||
uhyve_args.num_devices = (int *) guest_to_host((size_t) num_devices);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_GET_DEVICE_LIST, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
|
@ -536,9 +543,10 @@ typedef struct {
|
|||
|
||||
void ibv_free_device_list(struct ibv_device ** list) {
|
||||
uhyve_ibv_free_device_list_t uhyve_args;
|
||||
// TODO: Take care of ** parameter.
|
||||
uhyve_args.list = list;
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_FREE_DEVICE_LIST, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -663,6 +671,7 @@ void ibv_ack_async_event(struct ibv_async_event * event) {
|
|||
uhyve_args.event = (struct ibv_async_event *) guest_to_host((size_t) event);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_ACK_ASYNC_EVENT, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -733,7 +742,7 @@ int ibv_query_gid(struct ibv_context * context, uint8_t port_num, int index, uni
|
|||
uhyve_args.context = context;
|
||||
uhyve_args.port_num = port_num;
|
||||
uhyve_args.index = index;
|
||||
uhyve_args.gid = gid;
|
||||
uhyve_args.gid = (union ibv_gid *) guest_to_host((size_t) gid);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_QUERY_GID, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
|
@ -760,7 +769,7 @@ int ibv_query_pkey(struct ibv_context * context, uint8_t port_num, int index, __
|
|||
uhyve_args.context = context;
|
||||
uhyve_args.port_num = port_num;
|
||||
uhyve_args.index = index;
|
||||
uhyve_args.pkey = pkey;
|
||||
uhyve_args.pkey = (__be16 *) guest_to_host((size_t) pkey);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_QUERY_PKEY, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
|
@ -871,8 +880,12 @@ struct ibv_xrcd * ibv_open_xrcd(struct ibv_context * context, struct ibv_xrcd_in
|
|||
uhyve_args.context = context;
|
||||
uhyve_args.xrcd_init_attr = (struct ibv_xrcd_init_attr *) guest_to_host((size_t) xrcd_init_attr);
|
||||
|
||||
// TODO: Take care of pointer conversions in xrcd_init_attr.
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_OPEN_XRCD, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Take care of reverse pointer conversions in xrcd_init_attr.
|
||||
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
@ -915,7 +928,7 @@ typedef struct {
|
|||
struct ibv_mr * ibv_reg_mr(struct ibv_pd * pd, void * addr, int length, int access) {
|
||||
uhyve_ibv_reg_mr_t uhyve_args;
|
||||
uhyve_args.pd = pd;
|
||||
uhyve_args.addr = addr;
|
||||
uhyve_args.addr = (void *) guest_to_host((size_t) addr);
|
||||
uhyve_args.length = length;
|
||||
uhyve_args.access = access;
|
||||
|
||||
|
@ -946,7 +959,7 @@ int ibv_rereg_mr(struct ibv_mr * mr, int flags, struct ibv_pd * pd, void * addr,
|
|||
uhyve_args.mr = mr;
|
||||
uhyve_args.flags = flags;
|
||||
uhyve_args.pd = pd;
|
||||
uhyve_args.addr = addr;
|
||||
uhyve_args.addr = (void *) guest_to_host((size_t) addr);
|
||||
uhyve_args.length = length;
|
||||
uhyve_args.access = access;
|
||||
|
||||
|
@ -1128,7 +1141,7 @@ struct ibv_cq * ibv_create_cq(struct ibv_context * context, int cqe, void * cq_c
|
|||
uhyve_ibv_create_cq_t uhyve_args;
|
||||
uhyve_args.context = context;
|
||||
uhyve_args.cqe = cqe;
|
||||
uhyve_args.cq_context = cq_context;
|
||||
uhyve_args.cq_context = (void *) guest_to_host((size_t) cq_context);
|
||||
uhyve_args.channel = channel;
|
||||
uhyve_args.comp_vector = comp_vector;
|
||||
|
||||
|
@ -1221,8 +1234,8 @@ typedef struct {
|
|||
int ibv_get_cq_event(struct ibv_comp_channel * channel, struct ibv_cq ** cq, void ** cq_context) {
|
||||
uhyve_ibv_get_cq_event_t uhyve_args;
|
||||
uhyve_args.channel = channel;
|
||||
// TODO: Take care of ** parameter.
|
||||
// TODO: Take care of ** parameter.
|
||||
uhyve_args.cq = cq;
|
||||
uhyve_args.cq_context = (void **) guest_to_host((size_t) cq_context); // TODO: Check ** param here.
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_GET_CQ_EVENT, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
|
@ -1246,6 +1259,7 @@ void ibv_ack_cq_events(struct ibv_cq * cq, unsigned int nevents) {
|
|||
uhyve_args.nevents = nevents;
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_ACK_CQ_EVENTS, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1406,7 +1420,7 @@ typedef struct {
|
|||
int ibv_get_srq_num(struct ibv_srq * srq, uint32_t * srq_num) {
|
||||
uhyve_ibv_get_srq_num_t uhyve_args;
|
||||
uhyve_args.srq = srq;
|
||||
uhyve_args.srq_num = srq_num;
|
||||
uhyve_args.srq_num = (uint32_t *) guest_to_host((size_t) srq_num);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_GET_SRQ_NUM, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
|
@ -1451,11 +1465,17 @@ typedef struct {
|
|||
int ibv_post_srq_recv(struct ibv_srq * srq, struct ibv_recv_wr * recv_wr, struct ibv_recv_wr ** bad_recv_wr) {
|
||||
uhyve_ibv_post_srq_recv_t uhyve_args;
|
||||
uhyve_args.srq = srq;
|
||||
uhyve_args.recv_wr = recv_wr;
|
||||
// TODO: Take care of ** parameter.
|
||||
uhyve_args.recv_wr = (struct ibv_recv_wr *) guest_to_host((size_t) recv_wr);
|
||||
uhyve_args.bad_recv_wr = (struct ibv_recv_wr **) guest_to_host((size_t) bad_recv_wr); // TODO: Check ** param here.
|
||||
|
||||
// TODO: Take care of pointer conversions in recv_wr.
|
||||
// TODO: Take care of pointer conversions in bad_recv_wr.
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_POST_SRQ_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Take care of reverse pointer conversions in recv_wr.
|
||||
// TODO: Take care of reverse pointer conversions in bad_recv_wr.
|
||||
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
@ -1545,7 +1565,7 @@ typedef struct {
|
|||
int ibv_query_device_ex(struct ibv_context * context, const struct ibv_query_device_ex_input * input, struct ibv_device_attr_ex * attr) {
|
||||
uhyve_ibv_query_device_ex_t uhyve_args;
|
||||
uhyve_args.context = context;
|
||||
uhyve_args.input = input;
|
||||
uhyve_args.input = (const struct ibv_query_device_ex_input *) guest_to_host((size_t) input);
|
||||
uhyve_args.attr = (struct ibv_device_attr_ex *) guest_to_host((size_t) attr);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_QUERY_DEVICE_EX, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
@ -1734,8 +1754,12 @@ struct ibv_rwq_ind_table * ibv_create_rwq_ind_table(struct ibv_context * context
|
|||
uhyve_args.context = context;
|
||||
uhyve_args.init_attr = (struct ibv_rwq_ind_table_init_attr *) guest_to_host((size_t) init_attr);
|
||||
|
||||
// TODO: Take care of pointer conversions in init_attr.
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Take care of reverse pointer conversions in init_attr.
|
||||
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
@ -1777,11 +1801,17 @@ typedef struct {
|
|||
int ibv_post_send(struct ibv_qp * qp, struct ibv_send_wr * wr, struct ibv_send_wr ** bad_wr) {
|
||||
uhyve_ibv_post_send_t uhyve_args;
|
||||
uhyve_args.qp = qp;
|
||||
uhyve_args.wr = wr;
|
||||
// TODO: Take care of ** parameter.
|
||||
uhyve_args.wr = (struct ibv_send_wr *) guest_to_host((size_t) wr);
|
||||
uhyve_args.bad_wr = (struct ibv_send_wr **) guest_to_host((size_t) bad_wr); // TODO: Check ** param here.
|
||||
|
||||
// TODO: Take care of pointer conversions in wr.
|
||||
// TODO: Take care of pointer conversions in bad_wr.
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_POST_SEND, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Take care of reverse pointer conversions in wr.
|
||||
// TODO: Take care of reverse pointer conversions in bad_wr.
|
||||
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
@ -1802,11 +1832,17 @@ typedef struct {
|
|||
int ibv_post_recv(struct ibv_qp * qp, struct ibv_recv_wr * wr, struct ibv_recv_wr ** bad_wr) {
|
||||
uhyve_ibv_post_recv_t uhyve_args;
|
||||
uhyve_args.qp = qp;
|
||||
uhyve_args.wr = wr;
|
||||
// TODO: Take care of ** parameter.
|
||||
uhyve_args.wr = (struct ibv_recv_wr *) guest_to_host((size_t) wr);
|
||||
uhyve_args.bad_wr = (struct ibv_recv_wr **) guest_to_host((size_t) bad_wr); // TODO: Check ** param here.
|
||||
|
||||
// TODO: Take care of pointer conversions in wr.
|
||||
// TODO: Take care of pointer conversions in bad_wr.
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_POST_RECV, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
// TODO: Take care of reverse pointer conversions in wr.
|
||||
// TODO: Take care of reverse pointer conversions in bad_wr.
|
||||
|
||||
return uhyve_args.ret;
|
||||
}
|
||||
|
||||
|
@ -1927,7 +1963,7 @@ typedef struct {
|
|||
int ibv_attach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid) {
|
||||
uhyve_ibv_attach_mcast_t uhyve_args;
|
||||
uhyve_args.qp = qp;
|
||||
uhyve_args.gid = gid;
|
||||
uhyve_args.gid = (const union ibv_gid *) guest_to_host((size_t) gid);
|
||||
uhyve_args.lid = lid;
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_ATTACH_MCAST, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
@ -1952,7 +1988,7 @@ typedef struct {
|
|||
int ibv_detach_mcast(struct ibv_qp * qp, const union ibv_gid * gid, uint16_t lid) {
|
||||
uhyve_ibv_detach_mcast_t uhyve_args;
|
||||
uhyve_args.qp = qp;
|
||||
uhyve_args.gid = gid;
|
||||
uhyve_args.gid = (const union ibv_gid *) guest_to_host((size_t) gid);
|
||||
uhyve_args.lid = lid;
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_DETACH_MCAST, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
@ -2050,18 +2086,18 @@ typedef struct {
|
|||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_ah_attr * attr;
|
||||
uint8_t [6] eth_mac;
|
||||
uint8_t eth_mac[6];
|
||||
uint16_t * vid;
|
||||
// Return value:
|
||||
int ret;
|
||||
} __attribute__((packed)) uhyve_ibv_resolve_eth_l2_from_gid_t;
|
||||
|
||||
int ibv_resolve_eth_l2_from_gid(struct ibv_context * context, struct ibv_ah_attr * attr, uint8_t [6] eth_mac, uint16_t * vid) {
|
||||
int ibv_resolve_eth_l2_from_gid(struct ibv_context * context, struct ibv_ah_attr * attr, uint8_t eth_mac[6], uint16_t * vid) {
|
||||
uhyve_ibv_resolve_eth_l2_from_gid_t uhyve_args;
|
||||
uhyve_args.context = context;
|
||||
uhyve_args.attr = (struct ibv_ah_attr *) guest_to_host((size_t) attr);
|
||||
uhyve_args.eth_mac = eth_mac;
|
||||
uhyve_args.vid = vid;
|
||||
uhyve_args.eth_mac[6] = eth_mac[6];
|
||||
uhyve_args.vid = (uint16_t *) guest_to_host((size_t) vid);
|
||||
|
||||
uhyve_send(UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID, (unsigned) virt_to_phys((size_t) &uhyve_args));
|
||||
|
||||
|
|
|
@ -1,98 +1,98 @@
|
|||
typedef enum {
|
||||
UHYVE_PORT_SET_IB_POOL_ADDR = 0x60F,
|
||||
UHYVE_PORT_IBV_WC_STATUS_STR = 0x610,
|
||||
UHYVE_PORT_IBV_RATE_TO_MULT = 0x611,
|
||||
UHYVE_PORT_MULT_TO_IBV_RATE = 0x612,
|
||||
UHYVE_PORT_IBV_RATE_TO_MBPS = 0x613,
|
||||
UHYVE_PORT_MBPS_TO_IBV_RATE = 0x614,
|
||||
UHYVE_PORT_IBV_CQ_EX_TO_CQ = 0x615,
|
||||
UHYVE_PORT_IBV_START_POLL = 0x616,
|
||||
UHYVE_PORT_IBV_NEXT_POLL = 0x617,
|
||||
UHYVE_PORT_IBV_END_POLL = 0x618,
|
||||
UHYVE_PORT_IBV_WC_READ_OPCODE = 0x619,
|
||||
UHYVE_PORT_IBV_WC_READ_VENDOR_ERR = 0x61A,
|
||||
UHYVE_PORT_IBV_WC_READ_BYTE_LEN = 0x61B,
|
||||
UHYVE_PORT_IBV_WC_READ_IMM_DATA = 0x61C,
|
||||
UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY = 0x61D,
|
||||
UHYVE_PORT_IBV_WC_READ_QP_NUM = 0x61E,
|
||||
UHYVE_PORT_IBV_WC_READ_SRC_QP = 0x61F,
|
||||
UHYVE_PORT_IBV_WC_READ_WC_FLAGS = 0x620,
|
||||
UHYVE_PORT_IBV_WC_READ_SLID = 0x621,
|
||||
UHYVE_PORT_IBV_WC_READ_SL = 0x622,
|
||||
UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS = 0x623,
|
||||
UHYVE_PORT_IBV_WC_READ_COMPLETION_TS = 0x624,
|
||||
UHYVE_PORT_IBV_WC_READ_CVLAN = 0x625,
|
||||
UHYVE_PORT_IBV_WC_READ_FLOW_TAG = 0x626,
|
||||
UHYVE_PORT_IBV_POST_WQ_RECV = 0x627,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x628,
|
||||
UHYVE_PORT_IBV_FREE_DEVICE_LIST = 0x629,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x62A,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_GUID = 0x62B,
|
||||
UHYVE_PORT_IBV_OPEN_DEVICE = 0x62C,
|
||||
UHYVE_PORT_IBV_CLOSE_DEVICE = 0x62D,
|
||||
UHYVE_PORT_IBV_GET_ASYNC_EVENT = 0x62E,
|
||||
UHYVE_PORT_IBV_ACK_ASYNC_EVENT = 0x62F,
|
||||
UHYVE_PORT_IBV_QUERY_DEVICE = 0x630,
|
||||
UHYVE_PORT_IBV_QUERY_PORT = 0x631,
|
||||
UHYVE_PORT_IBV_QUERY_GID = 0x632,
|
||||
UHYVE_PORT_IBV_QUERY_PKEY = 0x633,
|
||||
UHYVE_PORT_IBV_ALLOC_PD = 0x634,
|
||||
UHYVE_PORT_IBV_DEALLOC_PD = 0x635,
|
||||
UHYVE_PORT_IBV_CREATE_FLOW = 0x636,
|
||||
UHYVE_PORT_IBV_DESTROY_FLOW = 0x637,
|
||||
UHYVE_PORT_IBV_OPEN_XRCD = 0x638,
|
||||
UHYVE_PORT_IBV_CLOSE_XRCD = 0x639,
|
||||
UHYVE_PORT_IBV_REG_MR = 0x63A,
|
||||
UHYVE_PORT_IBV_REREG_MR = 0x63B,
|
||||
UHYVE_PORT_IBV_DEREG_MR = 0x63C,
|
||||
UHYVE_PORT_IBV_ALLOC_MW = 0x63D,
|
||||
UHYVE_PORT_IBV_DEALLOC_MW = 0x63E,
|
||||
UHYVE_PORT_IBV_INC_RKEY = 0x63F,
|
||||
UHYVE_PORT_IBV_BIND_MW = 0x640,
|
||||
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x641,
|
||||
UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x642,
|
||||
UHYVE_PORT_IBV_CREATE_CQ = 0x643,
|
||||
UHYVE_PORT_IBV_CREATE_CQ_EX = 0x644,
|
||||
UHYVE_PORT_IBV_RESIZE_CQ = 0x645,
|
||||
UHYVE_PORT_IBV_DESTROY_CQ = 0x646,
|
||||
UHYVE_PORT_IBV_GET_CQ_EVENT = 0x647,
|
||||
UHYVE_PORT_IBV_ACK_CQ_EVENTS = 0x648,
|
||||
UHYVE_PORT_IBV_POLL_CQ = 0x649,
|
||||
UHYVE_PORT_IBV_REQ_NOTIFY_CQ = 0x64A,
|
||||
UHYVE_PORT_IBV_CREATE_SRQ = 0x64B,
|
||||
UHYVE_PORT_IBV_CREATE_SRQ_EX = 0x64C,
|
||||
UHYVE_PORT_IBV_MODIFY_SRQ = 0x64D,
|
||||
UHYVE_PORT_IBV_QUERY_SRQ = 0x64E,
|
||||
UHYVE_PORT_IBV_GET_SRQ_NUM = 0x64F,
|
||||
UHYVE_PORT_IBV_DESTROY_SRQ = 0x650,
|
||||
UHYVE_PORT_IBV_POST_SRQ_RECV = 0x651,
|
||||
UHYVE_PORT_IBV_CREATE_QP = 0x652,
|
||||
UHYVE_PORT_IBV_CREATE_QP_EX = 0x653,
|
||||
UHYVE_PORT_IBV_QUERY_RT_VALUES_EX = 0x654,
|
||||
UHYVE_PORT_IBV_QUERY_DEVICE_EX = 0x655,
|
||||
UHYVE_PORT_IBV_OPEN_QP = 0x656,
|
||||
UHYVE_PORT_IBV_MODIFY_QP = 0x657,
|
||||
UHYVE_PORT_IBV_QUERY_QP = 0x658,
|
||||
UHYVE_PORT_IBV_DESTROY_QP = 0x659,
|
||||
UHYVE_PORT_IBV_CREATE_WQ = 0x65A,
|
||||
UHYVE_PORT_IBV_MODIFY_WQ = 0x65B,
|
||||
UHYVE_PORT_IBV_DESTROY_WQ = 0x65C,
|
||||
UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE = 0x65D,
|
||||
UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE = 0x65E,
|
||||
UHYVE_PORT_IBV_POST_SEND = 0x65F,
|
||||
UHYVE_PORT_IBV_POST_RECV = 0x660,
|
||||
UHYVE_PORT_IBV_CREATE_AH = 0x661,
|
||||
UHYVE_PORT_IBV_INIT_AH_FROM_WC = 0x662,
|
||||
UHYVE_PORT_IBV_CREATE_AH_FROM_WC = 0x663,
|
||||
UHYVE_PORT_IBV_DESTROY_AH = 0x664,
|
||||
UHYVE_PORT_IBV_ATTACH_MCAST = 0x665,
|
||||
UHYVE_PORT_IBV_DETACH_MCAST = 0x666,
|
||||
UHYVE_PORT_IBV_FORK_INIT = 0x667,
|
||||
UHYVE_PORT_IBV_NODE_TYPE_STR = 0x668,
|
||||
UHYVE_PORT_IBV_PORT_STATE_STR = 0x669,
|
||||
UHYVE_PORT_IBV_EVENT_TYPE_STR = 0x66A,
|
||||
UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID = 0x66B,
|
||||
UHYVE_PORT_IBV_IS_QPT_SUPPORTED = 0x66C,
|
||||
UHYVE_PORT_SET_IB_POOL_ADDR = 0x610,
|
||||
UHYVE_PORT_IBV_WC_STATUS_STR = 0x611,
|
||||
UHYVE_PORT_IBV_RATE_TO_MULT = 0x612,
|
||||
UHYVE_PORT_MULT_TO_IBV_RATE = 0x613,
|
||||
UHYVE_PORT_IBV_RATE_TO_MBPS = 0x614,
|
||||
UHYVE_PORT_MBPS_TO_IBV_RATE = 0x615,
|
||||
UHYVE_PORT_IBV_CQ_EX_TO_CQ = 0x616,
|
||||
UHYVE_PORT_IBV_START_POLL = 0x617,
|
||||
UHYVE_PORT_IBV_NEXT_POLL = 0x618,
|
||||
UHYVE_PORT_IBV_END_POLL = 0x619,
|
||||
UHYVE_PORT_IBV_WC_READ_OPCODE = 0x61A,
|
||||
UHYVE_PORT_IBV_WC_READ_VENDOR_ERR = 0x61B,
|
||||
UHYVE_PORT_IBV_WC_READ_BYTE_LEN = 0x61C,
|
||||
UHYVE_PORT_IBV_WC_READ_IMM_DATA = 0x61D,
|
||||
UHYVE_PORT_IBV_WC_READ_INVALIDATED_RKEY = 0x61E,
|
||||
UHYVE_PORT_IBV_WC_READ_QP_NUM = 0x61F,
|
||||
UHYVE_PORT_IBV_WC_READ_SRC_QP = 0x620,
|
||||
UHYVE_PORT_IBV_WC_READ_WC_FLAGS = 0x621,
|
||||
UHYVE_PORT_IBV_WC_READ_SLID = 0x622,
|
||||
UHYVE_PORT_IBV_WC_READ_SL = 0x623,
|
||||
UHYVE_PORT_IBV_WC_READ_DLID_PATH_BITS = 0x624,
|
||||
UHYVE_PORT_IBV_WC_READ_COMPLETION_TS = 0x625,
|
||||
UHYVE_PORT_IBV_WC_READ_CVLAN = 0x626,
|
||||
UHYVE_PORT_IBV_WC_READ_FLOW_TAG = 0x627,
|
||||
UHYVE_PORT_IBV_POST_WQ_RECV = 0x628,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_LIST = 0x629,
|
||||
UHYVE_PORT_IBV_FREE_DEVICE_LIST = 0x62A,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_NAME = 0x62B,
|
||||
UHYVE_PORT_IBV_GET_DEVICE_GUID = 0x62C,
|
||||
UHYVE_PORT_IBV_OPEN_DEVICE = 0x62D,
|
||||
UHYVE_PORT_IBV_CLOSE_DEVICE = 0x62E,
|
||||
UHYVE_PORT_IBV_GET_ASYNC_EVENT = 0x62F,
|
||||
UHYVE_PORT_IBV_ACK_ASYNC_EVENT = 0x630,
|
||||
UHYVE_PORT_IBV_QUERY_DEVICE = 0x631,
|
||||
UHYVE_PORT_IBV_QUERY_PORT = 0x632,
|
||||
UHYVE_PORT_IBV_QUERY_GID = 0x633,
|
||||
UHYVE_PORT_IBV_QUERY_PKEY = 0x634,
|
||||
UHYVE_PORT_IBV_ALLOC_PD = 0x635,
|
||||
UHYVE_PORT_IBV_DEALLOC_PD = 0x636,
|
||||
UHYVE_PORT_IBV_CREATE_FLOW = 0x637,
|
||||
UHYVE_PORT_IBV_DESTROY_FLOW = 0x638,
|
||||
UHYVE_PORT_IBV_OPEN_XRCD = 0x639,
|
||||
UHYVE_PORT_IBV_CLOSE_XRCD = 0x63A,
|
||||
UHYVE_PORT_IBV_REG_MR = 0x63B,
|
||||
UHYVE_PORT_IBV_REREG_MR = 0x63C,
|
||||
UHYVE_PORT_IBV_DEREG_MR = 0x63D,
|
||||
UHYVE_PORT_IBV_ALLOC_MW = 0x63E,
|
||||
UHYVE_PORT_IBV_DEALLOC_MW = 0x63F,
|
||||
UHYVE_PORT_IBV_INC_RKEY = 0x640,
|
||||
UHYVE_PORT_IBV_BIND_MW = 0x641,
|
||||
UHYVE_PORT_IBV_CREATE_COMP_CHANNEL = 0x642,
|
||||
UHYVE_PORT_IBV_DESTROY_COMP_CHANNEL = 0x643,
|
||||
UHYVE_PORT_IBV_CREATE_CQ = 0x644,
|
||||
UHYVE_PORT_IBV_CREATE_CQ_EX = 0x645,
|
||||
UHYVE_PORT_IBV_RESIZE_CQ = 0x646,
|
||||
UHYVE_PORT_IBV_DESTROY_CQ = 0x647,
|
||||
UHYVE_PORT_IBV_GET_CQ_EVENT = 0x648,
|
||||
UHYVE_PORT_IBV_ACK_CQ_EVENTS = 0x649,
|
||||
UHYVE_PORT_IBV_POLL_CQ = 0x64A,
|
||||
UHYVE_PORT_IBV_REQ_NOTIFY_CQ = 0x64B,
|
||||
UHYVE_PORT_IBV_CREATE_SRQ = 0x64C,
|
||||
UHYVE_PORT_IBV_CREATE_SRQ_EX = 0x64D,
|
||||
UHYVE_PORT_IBV_MODIFY_SRQ = 0x64E,
|
||||
UHYVE_PORT_IBV_QUERY_SRQ = 0x64F,
|
||||
UHYVE_PORT_IBV_GET_SRQ_NUM = 0x650,
|
||||
UHYVE_PORT_IBV_DESTROY_SRQ = 0x651,
|
||||
UHYVE_PORT_IBV_POST_SRQ_RECV = 0x652,
|
||||
UHYVE_PORT_IBV_CREATE_QP = 0x653,
|
||||
UHYVE_PORT_IBV_CREATE_QP_EX = 0x654,
|
||||
UHYVE_PORT_IBV_QUERY_RT_VALUES_EX = 0x655,
|
||||
UHYVE_PORT_IBV_QUERY_DEVICE_EX = 0x656,
|
||||
UHYVE_PORT_IBV_OPEN_QP = 0x657,
|
||||
UHYVE_PORT_IBV_MODIFY_QP = 0x658,
|
||||
UHYVE_PORT_IBV_QUERY_QP = 0x659,
|
||||
UHYVE_PORT_IBV_DESTROY_QP = 0x65A,
|
||||
UHYVE_PORT_IBV_CREATE_WQ = 0x65B,
|
||||
UHYVE_PORT_IBV_MODIFY_WQ = 0x65C,
|
||||
UHYVE_PORT_IBV_DESTROY_WQ = 0x65D,
|
||||
UHYVE_PORT_IBV_CREATE_RWQ_IND_TABLE = 0x65E,
|
||||
UHYVE_PORT_IBV_DESTROY_RWQ_IND_TABLE = 0x65F,
|
||||
UHYVE_PORT_IBV_POST_SEND = 0x660,
|
||||
UHYVE_PORT_IBV_POST_RECV = 0x661,
|
||||
UHYVE_PORT_IBV_CREATE_AH = 0x662,
|
||||
UHYVE_PORT_IBV_INIT_AH_FROM_WC = 0x663,
|
||||
UHYVE_PORT_IBV_CREATE_AH_FROM_WC = 0x664,
|
||||
UHYVE_PORT_IBV_DESTROY_AH = 0x665,
|
||||
UHYVE_PORT_IBV_ATTACH_MCAST = 0x666,
|
||||
UHYVE_PORT_IBV_DETACH_MCAST = 0x667,
|
||||
UHYVE_PORT_IBV_FORK_INIT = 0x668,
|
||||
UHYVE_PORT_IBV_NODE_TYPE_STR = 0x669,
|
||||
UHYVE_PORT_IBV_PORT_STATE_STR = 0x66A,
|
||||
UHYVE_PORT_IBV_EVENT_TYPE_STR = 0x66B,
|
||||
UHYVE_PORT_IBV_RESOLVE_ETH_L2_FROM_GID = 0x66C,
|
||||
UHYVE_PORT_IBV_IS_QPT_SUPPORTED = 0x66D,
|
||||
} uhyve_ibv_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -802,7 +802,7 @@ typedef struct {
|
|||
// Parameters:
|
||||
struct ibv_context * context;
|
||||
struct ibv_ah_attr * attr;
|
||||
uint8_t [6] eth_mac;
|
||||
uint8_t eth_mac[6];
|
||||
uint16_t * vid;
|
||||
// Return value:
|
||||
int ret;
|
||||
|
|
|
@ -1373,7 +1373,7 @@ void call_ibv_resolve_eth_l2_from_gid(struct kvm_run * run, uint8_t * guest_mem)
|
|||
uhyve_ibv_resolve_eth_l2_from_gid_t * args = (uhyve_ibv_resolve_eth_l2_from_gid_t *) (guest_mem + data);
|
||||
|
||||
use_ib_mem_pool = true;
|
||||
args->ret = ibv_resolve_eth_l2_from_gid(args->context, args->attr, args->eth_mac, args->vid);
|
||||
args->ret = ibv_resolve_eth_l2_from_gid(args->context, args->attr, args->eth_mac[6], args->vid);
|
||||
use_ib_mem_pool = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
struct ibv_context * ibv_open_device(struct ibv_device * device)
|
||||
const char * ibv_get_device_name(struct ibv_device * device)
|
||||
int ibv_query_port(struct ibv_context * context,uint8_t port_num,struct ibv_port_attr * port_attr)
|
||||
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context)
|
|
@ -1,19 +0,0 @@
|
|||
struct ibv_context * ibv_open_device(struct ibv_device * device)
|
||||
const char * ibv_get_device_name(struct ibv_device * device)
|
||||
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context)
|
||||
int ibv_query_port(struct ibv_context * context,uint8_t port_num,struct ibv_port_attr * port_attr)
|
||||
|
||||
struct ibv_device ** ibv_get_device_list(int * num_devices)
|
||||
struct ibv_comp_channel * ibv_create_comp_channel(struct ibv_context * context)
|
||||
struct ibv_pd * ibv_alloc_pd(struct ibv_context * context)
|
||||
struct ibv_mr * ibv_reg_mr(struct ibv_pd * pd,void * addr,int length,int access)
|
||||
struct ibv_cq * ibv_create_cq(struct ibv_context * context,int cqe,void * cq_context,struct ibv_comp_channel * channel,int comp_vector)
|
||||
struct ibv_qp * ibv_create_qp(struct ibv_pd * pd,struct ibv_qp_init_attr * qp_init_attr)
|
||||
int ibv_query_qp(struct ibv_qp * qp,struct ibv_qp_attr * attr,int attr_mask,struct ibv_qp_init_attr * init_attr)
|
||||
int ibv_modify_qp(struct ibv_qp * qp,struct ibv_qp_attr * attr,int attr_mask)
|
||||
int ibv_destroy_qp(struct ibv_qp * qp)
|
||||
int ibv_destroy_cq(struct ibv_cq * cq)
|
||||
int ibv_dereg_mr(struct ibv_mr * mr)
|
||||
int ibv_dealloc_pd(struct ibv_pd * pd)
|
||||
int ibv_destroy_comp_channel(struct ibv_comp_channel * channel)
|
||||
int ibv_close_device(struct ibv_context * context)
|
|
@ -89,5 +89,5 @@ int ibv_fork_init()
|
|||
const char * ibv_node_type_str(enum ibv_node_type node_type)
|
||||
const char * ibv_port_state_str(enum ibv_port_state port_state)
|
||||
const char * ibv_event_type_str(enum ibv_event_type event)
|
||||
int ibv_resolve_eth_l2_from_gid(struct ibv_context * context,struct ibv_ah_attr * attr,uint8_t [6] eth_mac,uint16_t * vid)
|
||||
int ibv_resolve_eth_l2_from_gid(struct ibv_context * context,struct ibv_ah_attr * attr,uint8_t eth_mac[6], uint16_t * vid)
|
||||
int ibv_is_qpt_supported(uint32_t caps,enum ibv_qp_type qpt)
|
||||
|
|
|
@ -24,66 +24,7 @@ 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. TODO 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;
|
||||
TODO, docs
|
||||
"""
|
||||
|
||||
# TODO: Add ibv_resolve_eth_l2_from_gid function back in. Not linking right now.
|
||||
|
@ -105,221 +46,242 @@ UHYVE_IBV_HEADER_GEN_PATH = "GEN-tools-uhyve-ibv-ports.h"
|
|||
INCLUDE_STDDEF_GEN_PATH = "GEN-include-hermit-stddef.h"
|
||||
UHYVE_HOST_FCNS_GEN_PATH = "GEN-tools-uhyve-ibv.c"
|
||||
|
||||
# VERBS_HEADER_PATH = "verbs-0.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 = 0x610
|
||||
|
||||
params_in_guest_mem = ['struct ibv_device_attr',
|
||||
'struct ibv_device_attr_ex',
|
||||
'struct ibv_port_attr',
|
||||
'struct ibv_ah_attr',
|
||||
'struct ibv_srq_attr',
|
||||
'struct ibv_wq_attr',
|
||||
'struct ibv_qp_attr',
|
||||
'struct ibv_poll_cq_attr',
|
||||
'struct ibv_flow_attr',
|
||||
'struct ibv_global_route',
|
||||
'struct ibv_packet_pacing_caps',
|
||||
'struct ibv_qp_cap',
|
||||
'struct ibv_odp_caps',
|
||||
'struct ibv_tso_caps',
|
||||
'struct ibv_rss_caps',
|
||||
'struct ibv_flow_eth_filter',
|
||||
'struct ibv_flow_spec_eth',
|
||||
'struct ibv_flow_ipv4_filter',
|
||||
'struct ibv_flow_spec_ipv4',
|
||||
'struct ibv_flow_ipv4_ext_filter',
|
||||
'struct ibv_flow_spec_ipv4_ext',
|
||||
'struct ibv_flow_ipv6_filter',
|
||||
'struct ibv_flow_spec_ipv6',
|
||||
'struct ibv_flow_tcp_udp_filter',
|
||||
'struct ibv_flow_spec_tcp_udp',
|
||||
'struct ibv_flow_tunnel_filter',
|
||||
'struct ibv_flow_spec_tunnel',
|
||||
'struct ibv_flow_spec_action_tag',
|
||||
'struct ibv_flow_spec_action_drop',
|
||||
'struct ibv_query_device_ex_input',
|
||||
'struct ibv_wc',
|
||||
'struct ibv_grh',
|
||||
'struct ibv_mw_bind',
|
||||
'struct ibv_flow_spec',
|
||||
'struct ibv_values_ex',
|
||||
'struct ibv_rwq_ind_table_init_attr',
|
||||
'struct ibv_xrcd_init_attr',
|
||||
# containing ib pool pointers:
|
||||
'struct ibv_wq_init_attr',
|
||||
'struct ibv_qp_init_attr',
|
||||
'struct ibv_qp_init_attr_ex',
|
||||
'struct ibv_srq_init_attr_ex',
|
||||
'struct ibv_srq_init_attr',
|
||||
'struct ibv_qp_open_attr',
|
||||
'struct ibv_cq_init_attr_ex',
|
||||
'struct ibv_async_event']
|
||||
# VERBS_HEADER_PATH = "verbs-0.h"
|
||||
# UHYVE_IBV_HEADER_STRUCTS_GEN_PATH = "GEN-tools-uhyve-ibv-structs.h"
|
||||
|
||||
restricted_resources = ["struct ibv_send_wr",
|
||||
"struct ibv_recv_wr",
|
||||
"struct ibv_sge",
|
||||
"struct ibv_xrcd_init_attr",
|
||||
"struct ibv_rwq_ind_table_init_attr",
|
||||
"struct ibv_mw_bind_info",
|
||||
"struct ibv_rx_hash_conf"]
|
||||
|
||||
lib_owned_resources = ["struct ibv_pd",
|
||||
"struct ibv_cq",
|
||||
"struct ibv_cq_ex",
|
||||
"struct verbs_context",
|
||||
"struct ibv_device",
|
||||
"struct ibv_context",
|
||||
"struct ibv_context_ops",
|
||||
"struct ibv_flow",
|
||||
"struct ibv_xrcd",
|
||||
"struct ibv_mr",
|
||||
"struct ibv_mw",
|
||||
"struct ibv_comp_channel",
|
||||
"struct ibv_srq",
|
||||
"struct ibv_qp",
|
||||
"struct ibv_wq",
|
||||
"struct ibv_rwq_ind_table",
|
||||
"struct ibv_ah"]
|
||||
|
||||
app_owned_resources = restricted_resources + \
|
||||
["struct ibv_device_attr",
|
||||
"struct ibv_device_attr_ex",
|
||||
"struct ibv_port_attr",
|
||||
"struct ibv_ah_attr",
|
||||
"struct ibv_srq_attr",
|
||||
"struct ibv_wq_attr",
|
||||
"struct ibv_qp_attr",
|
||||
"struct ibv_poll_cq_attr",
|
||||
"struct ibv_flow_attr",
|
||||
"struct ibv_global_route",
|
||||
"struct ibv_packet_pacing_caps",
|
||||
"struct ibv_qp_cap",
|
||||
"struct ibv_odp_caps",
|
||||
"struct ibv_tso_caps",
|
||||
"struct ibv_rss_caps",
|
||||
"struct ibv_flow_eth_filter",
|
||||
"struct ibv_flow_spec_eth",
|
||||
"struct ibv_flow_ipv4_filter",
|
||||
"struct ibv_flow_spec_ipv4",
|
||||
"struct ibv_flow_ipv4_ext_filter",
|
||||
"struct ibv_flow_spec_ipv4_ext",
|
||||
"struct ibv_flow_ipv6_filter",
|
||||
"struct ibv_flow_spec_ipv6",
|
||||
"struct ibv_flow_tcp_udp_filter",
|
||||
"struct ibv_flow_spec_tcp_udp",
|
||||
"struct ibv_flow_tunnel_filter",
|
||||
"struct ibv_flow_spec_tunnel",
|
||||
"struct ibv_flow_spec_action_tag",
|
||||
"struct ibv_flow_spec_action_drop",
|
||||
"struct ibv_query_device_ex_input",
|
||||
"struct ibv_wc",
|
||||
"struct ibv_grh",
|
||||
"struct ibv_mw_bind",
|
||||
"struct ibv_flow_spec",
|
||||
"struct ibv_values_ex",
|
||||
"struct ibv_rwq_ind_table_init_attr",
|
||||
"struct ibv_xrcd_init_attr",
|
||||
|
||||
# Universal deep resources (contain valid ib_mem_pool pointers):
|
||||
"struct ibv_wq_init_attr",
|
||||
"struct ibv_qp_init_attr",
|
||||
"struct ibv_qp_init_attr_ex",
|
||||
"struct ibv_srq_init_attr_ex",
|
||||
"struct ibv_srq_init_attr",
|
||||
"struct ibv_qp_open_attr",
|
||||
"struct ibv_cq_init_attr_ex",
|
||||
"struct ibv_async_event"]
|
||||
|
||||
|
||||
class Type:
|
||||
def __init__(self, string):
|
||||
ts = string
|
||||
# int ibv_resolve_eth_l2_from_gid(uint8_t [6] eth_mac,uint16_t * vid)
|
||||
# struct ibv_device * dev
|
||||
# int * num_devices
|
||||
# int ret
|
||||
# char[NUM]
|
||||
|
||||
self.type_string = ts
|
||||
self.type_components = ts.split(" ")
|
||||
# ----------------------------------------------------------------------------
|
||||
# CLASSES
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
def get_struct_name(self):
|
||||
name = ""
|
||||
if self.is_struct():
|
||||
name = self.type_components[1]
|
||||
return name
|
||||
class Resource:
|
||||
def __init__(self, string, is_ret=False):
|
||||
if "**" in string:
|
||||
string.replace("**", " ** ")
|
||||
elif "*" in string:
|
||||
string.replace("*", " * ")
|
||||
|
||||
self.components = string.split()
|
||||
if is_ret:
|
||||
self.components += [""]
|
||||
|
||||
self.full_expression = " ".join(self.components)
|
||||
self.type = " ".join(self.components[:-1])
|
||||
self.name = self.components[-1]
|
||||
self.struct_name = self.components[1] if self.components[0] is "struct" else ""
|
||||
self.type_wo_asterisk = (self.type[:-3] if self.is_ptr_ptr()
|
||||
else self.type[:-2] if self.is_ptr()
|
||||
else self.type)
|
||||
|
||||
def is_struct(self):
|
||||
return self.type_components[0] == "struct"
|
||||
return self.components[0] == "struct"
|
||||
|
||||
def is_ptr(self):
|
||||
return "*" in self.full_expression
|
||||
|
||||
def is_ptr_ptr(self):
|
||||
return "**" in self.full_expression
|
||||
|
||||
def is_char_arr(self):
|
||||
return self.is_pointer() and "char" in self.type_components
|
||||
|
||||
def is_pointer(self):
|
||||
return self.type_components[-1] == "*"
|
||||
|
||||
def is_pointer_pointer(self):
|
||||
return self.type_components[-1] == "**"
|
||||
return self.is_ptr() and "char" in self.components
|
||||
|
||||
def is_void(self):
|
||||
return self.type_string == "void"
|
||||
return self.type == "void"
|
||||
|
||||
class FunctionParameter:
|
||||
def __init__(self, string):
|
||||
components = string.split(" ")
|
||||
type_string = " ".join(components[:-1])
|
||||
def is_app_owned(self):
|
||||
return self.type_wo_asterisk in app_owned_resources
|
||||
|
||||
self.type = Type(type_string)
|
||||
self.name = components[-1]
|
||||
def is_lib_owned(self):
|
||||
return self.type_wo_asterisk in lib_owned_resources
|
||||
|
||||
def get_full_expression(self):
|
||||
return self.type.type_string + " " + self.name
|
||||
def is_restricted(self):
|
||||
return self.type_wo_asterisk in restricted_resources
|
||||
|
||||
def get_struct_name(self):
|
||||
return self.type.get_struct_name()
|
||||
|
||||
def is_struct(self):
|
||||
return self.type.is_struct()
|
||||
|
||||
def is_pointer(self):
|
||||
return self.type.is_pointer()
|
||||
|
||||
def is_pointer_pointer(self):
|
||||
return self.type.is_pointer_pointer()
|
||||
|
||||
class FunctionPrototype:
|
||||
class Function:
|
||||
def __init__(self, string):
|
||||
parens_split = string.split("(")
|
||||
ret_and_name = parens_split[0].split(" ")
|
||||
all_params = parens_split[-1].split(")")[0]
|
||||
if all_params:
|
||||
param_strings = all_params.split(",")
|
||||
else:
|
||||
param_strings = []
|
||||
params_single_string = parens_split[-1].split(")")[0]
|
||||
params_strings = params_single_string.split(",") if params_single_string else []
|
||||
|
||||
self.parameters = [FunctionParameter(p) for p in param_strings]
|
||||
self.ret = Type(" ".join(ret_and_name[:-1]))
|
||||
self.function_name = ret_and_name[-1]
|
||||
# Basic members (return type, function name, parameters)
|
||||
self.ret = Resource(" ".join(ret_and_name[:-1]), is_ret=True)
|
||||
self.name = ret_and_name[-1]
|
||||
self.params = [Resource(p) for p in params_strings]
|
||||
|
||||
def generate_args_struct(self):
|
||||
"""Generates the struct to hold a function's parameters and return value.
|
||||
# Helper members, constructed from basic members
|
||||
self.params_str = ", ".join([param.full_expression for param in self.params])
|
||||
self.param_types = [param.type for param in self.params]
|
||||
self.args_struct_name = "uhyve_{0}_t".format(self.name)
|
||||
self.args_struct = self.__generate_args_struct()
|
||||
self.port_name = "UHYVE_PORT_" + self.name.upper()
|
||||
self.uhyve_fnc_name = "call_{0}".format(self.name)
|
||||
self.uhyve_fnc_decl = ("void {0}(struct kvm_run * run, uint8_t * guest_mem);\n"
|
||||
.format(self.uhyve_fnc_name))
|
||||
self.fnc_decl = "{} {}({});".format(self.ret.type, self.name, self.params_str)
|
||||
|
||||
def __generate_args_struct(self):
|
||||
"""Generates the arguments struct to hold a function's parameters and return value.
|
||||
|
||||
Returns:
|
||||
Generated struct as string.
|
||||
Generated struct [string].
|
||||
"""
|
||||
code = "typedef struct {\n"
|
||||
|
||||
if self.get_num_parameters() > 0:
|
||||
if len(self.params) > 0:
|
||||
code += "\t// Parameters:\n"
|
||||
for param in self.parameters:
|
||||
code += "\t{0};\n".format(param.get_full_expression())
|
||||
for param in self.params:
|
||||
code += "\t{0};\n".format(param.full_expression)
|
||||
|
||||
if not self.ret.is_void():
|
||||
code += "\t// Return value:\n"
|
||||
code += "\t{0} ret;\n".format(self.ret.type_string)
|
||||
|
||||
code += "}} __attribute__((packed)) {0};\n\n".format(self.get_args_struct_name())
|
||||
code += "\t{0} ret;\n".format(self.ret.type)
|
||||
|
||||
code += "}} __attribute__((packed)) {0};\n\n".format(self.args_struct_name)
|
||||
return code
|
||||
|
||||
def generate_function_declaration(self):
|
||||
return "{} {}({});\n".format(self.ret.type_string, self.function_name,
|
||||
self.get_string_of_parameters())
|
||||
|
||||
def get_string_of_parameters(self):
|
||||
return ", ".join([param.get_full_expression() for param in self.parameters])
|
||||
|
||||
def generate_uhyve_function_declaration(self):
|
||||
name = self.get_uhyve_call_function_name()
|
||||
return "void {0}(struct kvm_run * run, uint8_t * guest_mem);\n".format(name)
|
||||
|
||||
def get_uhyve_call_function_name(self):
|
||||
return "call_{0}".format(self.function_name)
|
||||
|
||||
def get_num_parameters(self):
|
||||
return len(self.parameters)
|
||||
|
||||
def get_parameter_types(self):
|
||||
return [param.type.type_string for param in self.parameters]
|
||||
|
||||
def get_port_name(self):
|
||||
return "UHYVE_PORT_" + self.function_name.upper()
|
||||
|
||||
def get_args_struct_name(self):
|
||||
return "uhyve_{0}_t".format(self.function_name)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# HELPER
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
def generate_pretty_comment(string):
|
||||
"""Generates a 3 line pretty comment of the given string."""
|
||||
return "/*\n * {0}\n */\n\n".format(string)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# CODE GENERATION: Expecting list of all functions
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
def generate_kernel_header_declarations(function_prototypes):
|
||||
code = ""
|
||||
for pt in function_prototypes:
|
||||
code += pt.generate_function_declaration()
|
||||
return code
|
||||
def generate_hermit_function_declarations(functions):
|
||||
"""Generates all HermitCore function declarations for the ibv.h header.
|
||||
|
||||
|
||||
def generate_kernel_function(function_prototype):
|
||||
"""Generates the kernel function that sends the KVM exit IO to uhyve.
|
||||
|
||||
Returns:
|
||||
Generated function as string.
|
||||
Args:
|
||||
functions: List of all Functions [class Function].
|
||||
"""
|
||||
fnc_name = function_prototype.function_name
|
||||
ret_type = function_prototype.ret
|
||||
params = function_prototype.parameters
|
||||
port_name = function_prototype.get_port_name()
|
||||
code = ""
|
||||
for fnc in functions:
|
||||
code += fnc.fnc_decl + "\n"
|
||||
return code
|
||||
|
||||
comma_separated_params = function_prototype.get_string_of_parameters()
|
||||
code = "{0} {1}({2}) {{\n".format(ret_type.type_string, fnc_name, comma_separated_params)
|
||||
code += "\t{0} uhyve_args;\n".format(function_prototype.get_args_struct_name())
|
||||
def generate_port_enum(functions):
|
||||
"""Generates the enum mapping KVM exit IO port names to port numbers.
|
||||
|
||||
for p in params:
|
||||
if p.is_pointer_pointer():
|
||||
code += "\t// TODO: Take care of ** parameter.\n"
|
||||
else:
|
||||
if 'struct ' + p.get_struct_name() in params_in_guest_mem and p.is_pointer():
|
||||
code += "\tuhyve_args.{0} = ({1}) guest_to_host((size_t) {0});\n".format(
|
||||
p.name, p.type.type_string)
|
||||
else:
|
||||
code += "\tuhyve_args.{0} = {0};\n".format(p.name)
|
||||
code += "\n"
|
||||
|
||||
code += "\tuhyve_send({0}, (unsigned) virt_to_phys((size_t) &uhyve_args));\n".format(port_name)
|
||||
if not ret_type.is_void():
|
||||
code += "\n\treturn uhyve_args.ret;\n"
|
||||
code += "}\n\n"
|
||||
Args:
|
||||
functions: List of all Functions [class Function].
|
||||
Returns:
|
||||
Entire enum [string].
|
||||
"""
|
||||
code = "typedef enum {\n"
|
||||
code += "\tUHYVE_PORT_SET_IB_POOL_ADDR = 0x{0},\n".format(format(PORT_NUMBER_START, "X"))
|
||||
for num, fnc in enumerate(functions, PORT_NUMBER_START + 1):
|
||||
code += "\t{0} = 0x{1},\n".format(fnc.port_name, format(num, "X"))
|
||||
code += "} uhyve_ibv_t;"
|
||||
|
||||
return code
|
||||
|
||||
def generate_port_macros(functions):
|
||||
"""Generates the compiler macros mapping KVM exit IO port names to port numbers.
|
||||
|
||||
def generate_uhyve_cases(function_prototypes):
|
||||
""" Generates all switch-cases for uhyve's KVM exit IO.
|
||||
Args:
|
||||
functions: List of all Functions [class Function].
|
||||
Returns:
|
||||
Generated list of compiler macros [string].
|
||||
"""
|
||||
code = "#define UHYVE_PORT_SET_IB_POOL_ADDR 0x{0}\n".format(format(PORT_NUMBER_START, "X"))
|
||||
for num, fnc in enumerate(functions, PORT_NUMBER_START + 1):
|
||||
code += "#define {0} 0x{1}\n".format(fnc.port_name, format(num, "X"))
|
||||
return code
|
||||
|
||||
def generate_uhyve_cases(functions):
|
||||
""" Generates all switch-cases for the given verbs functions for uhyve's KVM exit IO.
|
||||
|
||||
Args:
|
||||
functions: List of all Functions [class Function].
|
||||
Returns:
|
||||
Generated switch-cases [string]
|
||||
"""
|
||||
|
@ -331,110 +293,126 @@ def generate_uhyve_cases(function_prototypes):
|
|||
code += "\t\t\t\t\tbreak;\n"
|
||||
code += "\t\t\t}\n\n"
|
||||
|
||||
for pt in function_prototypes:
|
||||
call_fnc_name = pt.get_uhyve_call_function_name()
|
||||
port_name = pt.get_port_name()
|
||||
|
||||
code += "\t\t\tcase {0}:\n".format(port_name)
|
||||
code += "\t\t\t\t{0}(run, guest_mem);\n".format(call_fnc_name)
|
||||
for fnc in functions:
|
||||
code += "\t\t\tcase {0}:\n".format(fnc.port_name)
|
||||
code += "\t\t\t\t{0}(run, guest_mem);\n".format(fnc.uhyve_fnc_name)
|
||||
code += "\t\t\t\tbreak;\n"
|
||||
|
||||
return code
|
||||
|
||||
def generate_uhyve_function(prototype):
|
||||
args_struct_name = prototype.get_args_struct_name()
|
||||
fnc_name = prototype.function_name
|
||||
ret_type = prototype.ret
|
||||
# ----------------------------------------------------------------------------
|
||||
# CODE GENERATION: Expecting a single function
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
code = generate_pretty_comment(fnc_name)
|
||||
code += "void call_{0}(struct kvm_run * run, uint8_t * guest_mem) {{\n".format(fnc_name)
|
||||
code += "\tprintf(\"LOG: UHYVE - call_{0}\\n\");\n".format(fnc_name)
|
||||
def generate_hermit_function_definition(fnc):
|
||||
"""Generates the given verbs API function for HermitCore.
|
||||
|
||||
The function performs guest->host address conversions for all application owned resources that
|
||||
are not restricted deep resources, i.e. that require no further processing of references.
|
||||
It writes the arguemnts struct to the function's KVM I/O port, causing a KVM exit in uhyve.
|
||||
|
||||
Returns:
|
||||
Generated full function definition [string].
|
||||
"""
|
||||
code = "{0} {1}({2}) {{\n".format(fnc.ret.type, fnc.name, fnc.params_str)
|
||||
code += "\t{0} uhyve_args;\n".format(fnc.args_struct_name)
|
||||
|
||||
for param in fnc.params:
|
||||
if param.is_ptr() and not param.is_lib_owned():
|
||||
code += "\tuhyve_args.{0} = ({1}) guest_to_host((size_t) {0});".format(
|
||||
param.name, param.type)
|
||||
if param.is_ptr_ptr():
|
||||
code += " // TODO: Check ** param here."
|
||||
code += "\n"
|
||||
else:
|
||||
code += "\tuhyve_args.{0} = {0};\n".format(param.name)
|
||||
code += "\n"
|
||||
|
||||
for param in fnc.params:
|
||||
if param.is_restricted():
|
||||
code += "\t// TODO: Take care of pointer conversions in " + param.name + ".\n"
|
||||
code += "\n" if param is fnc.params[-1] else ""
|
||||
|
||||
code += ("\tuhyve_send({0}, (unsigned) virt_to_phys((size_t) &uhyve_args));\n\n"
|
||||
.format(fnc.port_name))
|
||||
|
||||
for param in fnc.params:
|
||||
if param.is_restricted():
|
||||
code += "\t// TODO: Take care of reverse pointer conversions in " + param.name + ".\n"
|
||||
code += "\n" if param is fnc.params[-1] else ""
|
||||
|
||||
if not fnc.ret.is_void():
|
||||
code += "\treturn uhyve_args.ret;\n"
|
||||
code += "}\n\n"
|
||||
|
||||
return code
|
||||
|
||||
def generate_uhyve_function(fnc):
|
||||
"""Generates the uhyve function definition including the native library call.
|
||||
|
||||
Args:
|
||||
fnc: A verbs function [class Function].
|
||||
Returns:
|
||||
Full function definition.
|
||||
"""
|
||||
code = generate_pretty_comment(fnc.name)
|
||||
code += "void call_{0}(struct kvm_run * run, uint8_t * guest_mem) {{\n".format(fnc.name)
|
||||
code += "\tprintf(\"LOG: UHYVE - call_{0}\\n\");\n".format(fnc.name)
|
||||
code += "\tunsigned data = *((unsigned*) ((size_t) run + run->io.data_offset));\n"
|
||||
code += "\t{0} * args = ({0} *) (guest_mem + data);\n\n".format(args_struct_name)
|
||||
|
||||
code += "\t{0} * args = ({0} *) (guest_mem + data);\n\n".format(fnc.args_struct_name)
|
||||
code += "\tuse_ib_mem_pool = true;\n"
|
||||
code += ("\t" + ("args->ret = " if not ret_type.is_void() else "")
|
||||
+ "{0}(".format(fnc_name))
|
||||
|
||||
if prototype.get_num_parameters() > 0:
|
||||
for param in prototype.parameters[:-1]:
|
||||
code += "\t" + ("args->ret = " if not fnc.ret.is_void() else "") + "{0}(".format(fnc.name)
|
||||
if len(fnc.params) > 0:
|
||||
for param in fnc.params[:-1]:
|
||||
code += "args->{}, ".format(param.name)
|
||||
code += "args->{}".format(prototype.parameters[-1].name)
|
||||
code += "args->{}".format(fnc.params[-1].name)
|
||||
code += ");\n"
|
||||
|
||||
code += "\tuse_ib_mem_pool = false;\n}\n\n\n"
|
||||
|
||||
return code
|
||||
|
||||
|
||||
def generate_port_enum(function_prototypes):
|
||||
"""Generates the enum mapping KVM exit IO port names to port numbers.
|
||||
|
||||
Args:
|
||||
function_prototypes: All function names to be mapped to ports as list of strings.
|
||||
|
||||
Returns:
|
||||
Generated complete enum.
|
||||
"""
|
||||
code = "typedef enum {\n"
|
||||
code += "\tUHYVE_PORT_SET_IB_POOL_ADDR = 0x{0},\n".format(format(PORT_NUMBER_START-1, "X"))
|
||||
for num, pt in enumerate(function_prototypes, PORT_NUMBER_START):
|
||||
port_name = pt.get_port_name()
|
||||
code += "\t{0} = 0x{1},\n".format(port_name, format(num, "X"))
|
||||
code += "} uhyve_ibv_t;"
|
||||
|
||||
return code
|
||||
|
||||
|
||||
def generate_port_macros(function_prototypes):
|
||||
"""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.
|
||||
"""
|
||||
code = "#define UHYVE_PORT_SET_IB_POOL_ADDR 0x{0}\n".format(format(PORT_NUMBER_START-1, "X"))
|
||||
for num, pt in enumerate(function_prototypes, PORT_NUMBER_START):
|
||||
port_name = pt.get_port_name()
|
||||
code += "#define {0} 0x{1}\n".format(port_name, format(num, "X"))
|
||||
return code
|
||||
# ----------------------------------------------------------------------------
|
||||
# MAIN
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if __name__ == "__main__":
|
||||
prototypes = []
|
||||
functions = []
|
||||
|
||||
# Parse the input file containing all verbs function declarations (one per line).
|
||||
with open(SRC_PATH, "r") as f:
|
||||
for line in f:
|
||||
if line:
|
||||
prototypes.append(FunctionPrototype(line))
|
||||
functions.append(Function(line))
|
||||
|
||||
# Generate code in different 'GEN-' files corresponding to actual source files.
|
||||
with open(UHYVE_CASES_GEN_PATH, "w") as f:
|
||||
f.write(generate_uhyve_cases(prototypes))
|
||||
f.write(generate_uhyve_cases(functions))
|
||||
|
||||
with open(INCLUDE_STDDEF_GEN_PATH, "w") as f:
|
||||
f.write(generate_port_macros(prototypes))
|
||||
|
||||
with open(UHYVE_IBV_HEADER_GEN_PATH, "w") as f:
|
||||
f.write(generate_port_enum(prototypes))
|
||||
f.write("\n\n")
|
||||
|
||||
for pt in prototypes:
|
||||
f.write(pt.generate_args_struct())
|
||||
f.write("\n\n")
|
||||
|
||||
for pt in prototypes:
|
||||
f.write(pt.generate_uhyve_function_declaration())
|
||||
|
||||
with open(UHYVE_HOST_FCNS_GEN_PATH, "w") as f:
|
||||
for pt in prototypes:
|
||||
f.write(generate_uhyve_function(pt))
|
||||
f.write(generate_port_macros(functions))
|
||||
|
||||
with open(KERNEL_HEADER_GEN_PATH, "w") as f:
|
||||
f.write(generate_kernel_header_declarations(prototypes))
|
||||
f.write(generate_hermit_function_declarations(functions))
|
||||
|
||||
with open(UHYVE_IBV_HEADER_GEN_PATH, "w") as f:
|
||||
f.write(generate_port_enum(functions))
|
||||
f.write("\n\n")
|
||||
|
||||
for fnc in functions:
|
||||
f.write(fnc.args_struct)
|
||||
f.write("\n\n")
|
||||
|
||||
for fnc in functions:
|
||||
f.write(fnc.uhyve_fnc_decl)
|
||||
|
||||
with open(UHYVE_HOST_FCNS_GEN_PATH, "w") as f:
|
||||
for fnc in functions:
|
||||
f.write(generate_uhyve_function(fnc))
|
||||
|
||||
with open(KERNEL_GEN_PATH, "w") as f:
|
||||
for pt in prototypes:
|
||||
f.write(generate_pretty_comment(pt.function_name))
|
||||
f.write(pt.generate_args_struct())
|
||||
f.write(generate_kernel_function(pt))
|
||||
for fnc in functions:
|
||||
f.write(generate_pretty_comment(fnc.name))
|
||||
f.write(fnc.args_struct)
|
||||
f.write(generate_hermit_function_definition(fnc))
|
||||
f.write("\n")
|
||||
|
|
Loading…
Add table
Reference in a new issue