xref: /openbmc/qemu/net/vmnet_int.h (revision 2df1eb27)
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 "vmnet_int.h"
14 #include "clients.h"
15 
16 #include <vmnet/vmnet.h>
17 #include <dispatch/dispatch.h>
18 
19 /**
20  *  From vmnet.framework documentation
21  *
22  *  Each read/write call allows up to 200 packets to be
23  *  read or written for a maximum of 256KB.
24  *
25  *  Each packet written should be a complete
26  *  ethernet frame.
27  *
28  *  https://developer.apple.com/documentation/vmnet
29  */
30 #define VMNET_PACKETS_LIMIT 200
31 
32 typedef struct VmnetState {
33     NetClientState nc;
34     interface_ref vmnet_if;
35 
36     uint64_t mtu;
37     uint64_t max_packet_size;
38 
39     dispatch_queue_t if_queue;
40 
41     QEMUBH *send_bh;
42 
43     struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT];
44     int packets_send_current_pos;
45     int packets_send_end_pos;
46 
47     struct iovec iov_buf[VMNET_PACKETS_LIMIT];
48 
49     VMChangeStateEntry *change;
50 } VmnetState;
51 
52 const char *vmnet_status_map_str(vmnet_return_t status);
53 
54 int vmnet_if_create(NetClientState *nc,
55                     xpc_object_t if_desc,
56                     Error **errp);
57 
58 ssize_t vmnet_receive_common(NetClientState *nc,
59                              const uint8_t *buf,
60                              size_t size);
61 
62 void vmnet_cleanup_common(NetClientState *nc);
63 
64 #endif /* VMNET_INT_H */
65