Vladislav Yaroshchuk | 81ad296 | 2022-03-17 20:28:34 +0300 | [diff] [blame] | 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 | |
Vladislav Yaroshchuk | 81ad296 | 2022-03-17 20:28:34 +0300 | [diff] [blame] | 13 | #include "vmnet_int.h" |
| 14 | #include "clients.h" |
| 15 | |
| 16 | #include <vmnet/vmnet.h> |
Vladislav Yaroshchuk | 73f99db | 2022-03-17 20:28:35 +0300 | [diff] [blame] | 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 |
Vladislav Yaroshchuk | 81ad296 | 2022-03-17 20:28:34 +0300 | [diff] [blame] | 31 | |
| 32 | typedef struct VmnetState { |
Vladislav Yaroshchuk | 73f99db | 2022-03-17 20:28:35 +0300 | [diff] [blame] | 33 | NetClientState nc; |
| 34 | interface_ref vmnet_if; |
Vladislav Yaroshchuk | 81ad296 | 2022-03-17 20:28:34 +0300 | [diff] [blame] | 35 | |
Vladislav Yaroshchuk | 73f99db | 2022-03-17 20:28:35 +0300 | [diff] [blame] | 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]; |
Joelle van Dyne | 993f71e | 2023-01-01 17:08:21 -0800 | [diff] [blame] | 48 | |
| 49 | VMChangeStateEntry *change; |
Vladislav Yaroshchuk | 81ad296 | 2022-03-17 20:28:34 +0300 | [diff] [blame] | 50 | } VmnetState; |
| 51 | |
Vladislav Yaroshchuk | 73f99db | 2022-03-17 20:28:35 +0300 | [diff] [blame] | 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); |
Vladislav Yaroshchuk | 81ad296 | 2022-03-17 20:28:34 +0300 | [diff] [blame] | 63 | |
| 64 | #endif /* VMNET_INT_H */ |