mirror of
https://github.com/hermitcore/libhermit.git
synced 2025-03-09 00:00:03 +01:00
first test compiling. Segfault due to mutex conversion missing.
This commit is contained in:
parent
317a907e4b
commit
0e1ba141e6
7 changed files with 50 additions and 48 deletions
|
@ -42,12 +42,11 @@ extern "C" {
|
|||
|
||||
// TODO: File necessary?
|
||||
|
||||
//struct ibv_device** ibv_get_device_list(int *num_devices);
|
||||
|
||||
const char* ibv_get_device_name(struct ibv_device *device);
|
||||
struct ibv_context * ibv_open_device(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_device** ibv_get_device_list(int * num_devices);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -263,12 +263,12 @@ void host_to_guest_ibv_comp_channel(struct ibv_comp_channel * channel) {
|
|||
|
||||
struct ibv_abi_compat_v2 * guest_to_host_ibv_abi_compat_v2(struct ibv_abi_compat_v2 * abi_compat) {
|
||||
guest_to_host_ibv_comp_channel(&abi_compat->channel);
|
||||
guest_to_host_pthread_mutex_t(&abi_compat->in_use);
|
||||
/* guest_to_host_pthread_mutex_t(&abi_compat->in_use); */
|
||||
|
||||
return (struct ibv_abi_compat_v2 *) guest_to_host((size_t) abi_compat);
|
||||
}
|
||||
|
||||
void host_to_guest_ibv_abi_compat_v2(struct ibv_abi_compat_v2 * abi_compat) {
|
||||
host_to_guest_ibv_comp_channel(&abi_compat->channel);
|
||||
host_to_guest_pthread_mutex_t(&abi_compat->in_use);
|
||||
/* host_to_guest_pthread_mutex_t(&abi_compat->in_use); */
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef struct {
|
|||
// Parameters:
|
||||
struct ibv_device * device;
|
||||
// Return value:
|
||||
const char * ret;
|
||||
const char * ret; // TODO Should this be const?
|
||||
} __attribute__((packed)) uhyve_ibv_get_device_name_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -80,6 +80,6 @@ void call_ibv_open_device(struct kvm_run * run);
|
|||
void call_ibv_get_device_name(struct kvm_run * run);
|
||||
void call_ibv_query_port(struct kvm_run * run);
|
||||
void call_ibv_create_comp_channel(struct kvm_run * run);
|
||||
/*void call_ibv_get_device_list(struct kvm_run * run, uint8_t * guest_mem);*/
|
||||
void call_ibv_get_device_list(struct kvm_run * run);
|
||||
|
||||
#endif // UHYVE_IBV_H
|
||||
|
|
|
@ -983,6 +983,9 @@ static int vcpu_loop(void)
|
|||
case UHYVE_PORT_IBV_CREATE_COMP_CHANNEL:
|
||||
call_ibv_create_comp_channel(run);
|
||||
break;
|
||||
case UHYVE_PORT_IBV_GET_DEVICE_LIST:
|
||||
call_ibv_get_device_list(run);
|
||||
break;
|
||||
|
||||
default:
|
||||
err(1, "KVM: unhandled KVM_EXIT_IO at port 0x%x, direction %d\n", run->io.port, run->io.direction);
|
||||
|
|
|
@ -55,27 +55,27 @@ int pp_get_port_info(struct ibv_context *context, int port,
|
|||
return ibv_query_port(context, port, attr);
|
||||
}
|
||||
|
||||
void wire_gid_to_gid(const char *wgid, union ibv_gid *gid)
|
||||
{
|
||||
char tmp[9];
|
||||
__be32 v32;
|
||||
int i;
|
||||
uint32_t tmp_gid[4];
|
||||
/* void wire_gid_to_gid(const char *wgid, union ibv_gid *gid) */
|
||||
/* { */
|
||||
/* char tmp[9]; */
|
||||
/* __be32 v32; */
|
||||
/* int i; */
|
||||
/* uint32_t tmp_gid[4]; */
|
||||
|
||||
for (tmp[8] = 0, i = 0; i < 4; ++i) {
|
||||
memcpy(tmp, wgid + i * 8, 8);
|
||||
sscanf(tmp, "%x", &v32);
|
||||
tmp_gid[i] = be32toh(v32);
|
||||
}
|
||||
memcpy(gid, tmp_gid, sizeof(*gid));
|
||||
}
|
||||
/* for (tmp[8] = 0, i = 0; i < 4; ++i) { */
|
||||
/* memcpy(tmp, wgid + i * 8, 8); */
|
||||
/* sscanf(tmp, "%x", &v32); */
|
||||
/* tmp_gid[i] = be32toh(v32); */
|
||||
/* } */
|
||||
/* memcpy(gid, tmp_gid, sizeof(*gid)); */
|
||||
/* } */
|
||||
|
||||
void gid_to_wire_gid(const union ibv_gid *gid, char wgid[])
|
||||
{
|
||||
uint32_t tmp_gid[4];
|
||||
int i;
|
||||
/* void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]) */
|
||||
/* { */
|
||||
/* uint32_t tmp_gid[4]; */
|
||||
/* int i; */
|
||||
|
||||
memcpy(tmp_gid, gid, sizeof(tmp_gid));
|
||||
for (i = 0; i < 4; ++i)
|
||||
sprintf(&wgid[i * 8], "%08x", htobe32(tmp_gid[i]));
|
||||
}
|
||||
/* memcpy(tmp_gid, gid, sizeof(tmp_gid)); */
|
||||
/* for (i = 0; i < 4; ++i) */
|
||||
/* sprintf(&wgid[i * 8], "%08x", htobe32(tmp_gid[i])); */
|
||||
/* } */
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
|
||||
enum ibv_mtu pp_mtu_to_enum(int mtu);
|
||||
int pp_get_port_info(struct ibv_context *context, int port, struct ibv_port_attr *attr);
|
||||
void wire_gid_to_gid(const char *wgid, union ibv_gid *gid);
|
||||
void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]);
|
||||
// void wire_gid_to_gid(const char *wgid, union ibv_gid *gid);
|
||||
// void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
// #include <stdio.h>
|
||||
// #include <stdlib.h>
|
||||
// #include <unistd.h>
|
||||
/* #include <unistd.h> */
|
||||
// #include <string.h>
|
||||
// #include <sys/types.h>
|
||||
// #include <sys/socket.h>
|
||||
|
@ -546,23 +546,23 @@ clean_ctx:
|
|||
/*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[])
|
||||
{
|
||||
|
@ -668,7 +668,7 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
page_size = sysconf(_SC_PAGESIZE);
|
||||
page_size = 4092; // TODO
|
||||
|
||||
dev_list = ibv_get_device_list(NULL);
|
||||
if (!dev_list) {
|
||||
|
|
Loading…
Add table
Reference in a new issue