xref: /openbmc/qemu/net/vmnet_int.h (revision b14df228)
1 /*
2  * vmnet_int.h
3  *
4  * Copyright(c) 2022 Vladislav Yaroshchuk <vladislav.yaroshchuk@jetbrains.com>
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  *
9  */
10 #ifndef VMNET_INT_H
11 #define VMNET_INT_H
12 
13 #include "qemu/osdep.h"
14 #include "vmnet_int.h"
15 #include "clients.h"
16 
17 #include <vmnet/vmnet.h>
18 #include <dispatch/dispatch.h>
19 
20 /**
21  *  From vmnet.framework documentation
22  *
23  *  Each read/write call allows up to 200 packets to be
24  *  read or written for a maximum of 256KB.
25  *
26  *  Each packet written should be a complete
27  *  ethernet frame.
28  *
29  *  https://developer.apple.com/documentation/vmnet
30  */
31 #define VMNET_PACKETS_LIMIT 200
32 
33 typedef struct VmnetState {
34     NetClientState nc;
35     interface_ref vmnet_if;
36 
37     uint64_t mtu;
38     uint64_t max_packet_size;
39 
40     dispatch_queue_t if_queue;
41 
42     QEMUBH *send_bh;
43 
44     struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT];
45     int packets_send_current_pos;
46     int packets_send_end_pos;
47 
48     struct iovec iov_buf[VMNET_PACKETS_LIMIT];
49 } VmnetState;
50 
51 const char *vmnet_status_map_str(vmnet_return_t status);
52 
53 int vmnet_if_create(NetClientState *nc,
54                     xpc_object_t if_desc,
55                     Error **errp);
56 
57 ssize_t vmnet_receive_common(NetClientState *nc,
58                              const uint8_t *buf,
59                              size_t size);
60 
61 void vmnet_cleanup_common(NetClientState *nc);
62 
63 #endif /* VMNET_INT_H */
64