1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2013 Pluribus Networks Inc. 14 * Copyright 2018 Joyent, Inc. 15 * Copyright 2022 OmniOS Community Edition (OmniOSce) Association. 16 * Copyright 2025 Oxide Computer Company 17 */ 18 19 #ifndef _VIONA_IO_H_ 20 #define _VIONA_IO_H_ 21 22 #define VNA_IOC (('V' << 16)|('C' << 8)) 23 #define VNA_IOC_CREATE (VNA_IOC | 0x01) 24 #define VNA_IOC_DELETE (VNA_IOC | 0x02) 25 #define VNA_IOC_VERSION (VNA_IOC | 0x03) 26 #define VNA_IOC_DEFAULT_PARAMS (VNA_IOC | 0x04) 27 28 #define VNA_IOC_RING_INIT (VNA_IOC | 0x10) 29 #define VNA_IOC_RING_RESET (VNA_IOC | 0x11) 30 #define VNA_IOC_RING_KICK (VNA_IOC | 0x12) 31 #define VNA_IOC_RING_SET_MSI (VNA_IOC | 0x13) 32 #define VNA_IOC_RING_INTR_CLR (VNA_IOC | 0x14) 33 #define VNA_IOC_RING_SET_STATE (VNA_IOC | 0x15) 34 #define VNA_IOC_RING_GET_STATE (VNA_IOC | 0x16) 35 #define VNA_IOC_RING_PAUSE (VNA_IOC | 0x17) 36 37 #define VNA_IOC_INTR_POLL (VNA_IOC | 0x20) 38 #define VNA_IOC_SET_FEATURES (VNA_IOC | 0x21) 39 #define VNA_IOC_GET_FEATURES (VNA_IOC | 0x22) 40 #define VNA_IOC_SET_NOTIFY_IOP (VNA_IOC | 0x23) 41 #define VNA_IOC_SET_PROMISC (VNA_IOC | 0x24) 42 #define VNA_IOC_GET_PARAMS (VNA_IOC | 0x25) 43 #define VNA_IOC_SET_PARAMS (VNA_IOC | 0x26) 44 #define VNA_IOC_GET_MTU (VNA_IOC | 0x27) 45 #define VNA_IOC_SET_MTU (VNA_IOC | 0x28) 46 47 48 /* 49 * Viona Interface Version 50 * 51 * Like bhyve, viona exposes Private interfaces which are nonetheless consumed 52 * by out-of-gate consumers. While those consumers assume all risk of breakage 53 * incurred by subsequent changes, it would be nice to equip them to potentially 54 * detect (and handle) those modifications. 55 * 56 * There are no established criteria for the magnitude of change which requires 57 * this version to be incremented, and maintenance of it is considered a 58 * best-effort activity. Nothing is to be inferred about the magnitude of a 59 * change when the version is modified. It follows no rules like semver. 60 * 61 */ 62 #define VIONA_CURRENT_INTERFACE_VERSION 4 63 64 typedef struct vioc_create { 65 datalink_id_t c_linkid; 66 int c_vmfd; 67 } vioc_create_t; 68 69 typedef struct vioc_ring_init { 70 uint16_t ri_index; 71 uint16_t ri_qsize; 72 uint64_t ri_qaddr; 73 } vioc_ring_init_t; 74 75 typedef struct vioc_ring_state { 76 uint16_t vrs_index; 77 uint16_t vrs_avail_idx; 78 uint16_t vrs_used_idx; 79 uint16_t vrs_qsize; 80 uint64_t vrs_qaddr; 81 } vioc_ring_state_t; 82 83 typedef struct vioc_ring_msi { 84 uint16_t rm_index; 85 uint64_t rm_addr; 86 uint64_t rm_msg; 87 } vioc_ring_msi_t; 88 89 enum viona_vq_id { 90 VIONA_VQ_RX = 0, 91 VIONA_VQ_TX = 1, 92 VIONA_VQ_MAX = 2 93 }; 94 95 typedef enum { 96 VIONA_PROMISC_NONE = 0, 97 VIONA_PROMISC_MULTI, 98 VIONA_PROMISC_ALL, 99 VIONA_PROMISC_MAX, 100 } viona_promisc_t; 101 102 typedef struct vioc_intr_poll { 103 uint32_t vip_status[VIONA_VQ_MAX]; 104 } vioc_intr_poll_t; 105 106 107 /* 108 * Viona Parameter Interfaces 109 * 110 * A viona link can have various configuration parameters set upon it. This is 111 * done using packed nvlists in order to communicate those parameters to/from 112 * the device driver. 113 * 114 * 115 * Currently supported parameters are: 116 * - tx_copy_data (boolean): During packet transmission, should viona copy all 117 * of the packet data, rather than "loaning" those regions of guest memory 118 * (other than the packet headers) in the mblk. 119 * - tx_header_pad (uint16): How many bytes (if any) should be left as empty 120 * padding on transmitted packets? These could be used by subsequent 121 * encapsulation mechanisms in the network stack without the need to 122 * reallocate space for the then-longer header. 123 * 124 */ 125 126 /* Maximum size for parameter (or error) packed nvlist buffers */ 127 #define VIONA_MAX_PARAM_NVLIST_SZ 4096 128 129 typedef struct vioc_get_params { 130 void *vgp_param; 131 size_t vgp_param_sz; 132 } vioc_get_params_t; 133 134 typedef struct vioc_set_params { 135 void *vsp_param; 136 size_t vsp_param_sz; 137 void *vsp_error; 138 size_t vsp_error_sz; 139 } vioc_set_params_t; 140 141 #endif /* _VIONA_IO_H_ */ 142