aboutsummaryrefslogtreecommitdiff
path: root/net/vmnet_int.h
diff options
context:
space:
mode:
authorVladislav Yaroshchuk <vladislav.yaroshchuk@jetbrains.com>2022-03-17 20:28:35 +0300
committerJason Wang <jasowang@redhat.com>2022-05-17 16:48:23 +0800
commit73f99db534e36cdf7dd045b3fde2af29132c0a35 (patch)
treebfd6cf50e7a8d988292e6e57ffb332ebf52a8bc8 /net/vmnet_int.h
parent81ad2964e93848fc0998145043c395dea67f00da (diff)
downloadqemu-73f99db534e36cdf7dd045b3fde2af29132c0a35.zip
qemu-73f99db534e36cdf7dd045b3fde2af29132c0a35.tar.gz
qemu-73f99db534e36cdf7dd045b3fde2af29132c0a35.tar.bz2
net/vmnet: implement shared mode (vmnet-shared)
Interaction with vmnet.framework in different modes differs only on configuration stage, so we can create common `send`, `receive`, etc. procedures and reuse them. Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com> Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com> Signed-off-by: Phillip Tennen <phillip@axleos.com> Signed-off-by: Vladislav Yaroshchuk <Vladislav.Yaroshchuk@jetbrains.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'net/vmnet_int.h')
-rw-r--r--net/vmnet_int.h40
1 files changed, 39 insertions, 1 deletions
diff --git a/net/vmnet_int.h b/net/vmnet_int.h
index c383038..adf6e8c 100644
--- a/net/vmnet_int.h
+++ b/net/vmnet_int.h
@@ -15,11 +15,49 @@
#include "clients.h"
#include <vmnet/vmnet.h>
+#include <dispatch/dispatch.h>
+
+/**
+ * From vmnet.framework documentation
+ *
+ * Each read/write call allows up to 200 packets to be
+ * read or written for a maximum of 256KB.
+ *
+ * Each packet written should be a complete
+ * ethernet frame.
+ *
+ * https://developer.apple.com/documentation/vmnet
+ */
+#define VMNET_PACKETS_LIMIT 200
typedef struct VmnetState {
- NetClientState nc;
+ NetClientState nc;
+ interface_ref vmnet_if;
+
+ uint64_t mtu;
+ uint64_t max_packet_size;
+ dispatch_queue_t if_queue;
+
+ QEMUBH *send_bh;
+
+ struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT];
+ int packets_send_current_pos;
+ int packets_send_end_pos;
+
+ struct iovec iov_buf[VMNET_PACKETS_LIMIT];
} VmnetState;
+const char *vmnet_status_map_str(vmnet_return_t status);
+
+int vmnet_if_create(NetClientState *nc,
+ xpc_object_t if_desc,
+ Error **errp);
+
+ssize_t vmnet_receive_common(NetClientState *nc,
+ const uint8_t *buf,
+ size_t size);
+
+void vmnet_cleanup_common(NetClientState *nc);
#endif /* VMNET_INT_H */