1 /* $OpenBSD: viovar.h,v 1.2 2009/01/12 19:52:39 kettenis Exp $ */ 2 /* 3 * Copyright (c) 2009 Mark Kettenis 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 /* 19 * Virtual IO device protocol. 20 */ 21 22 struct vio_msg_tag { 23 uint8_t type; 24 uint8_t stype; 25 uint16_t stype_env; 26 uint32_t sid; 27 }; 28 29 struct vio_msg { 30 uint64_t hdr; 31 uint8_t type; 32 uint8_t stype; 33 uint16_t stype_env; 34 uint32_t sid; 35 uint16_t major; 36 uint16_t minor; 37 uint8_t dev_class; 38 }; 39 40 /* Message types. */ 41 #define VIO_TYPE_CTRL 0x01 42 #define VIO_TYPE_DATA 0x02 43 #define VIO_TYPE_ERR 0x04 44 45 /* Sub-Message types. */ 46 #define VIO_SUBTYPE_INFO 0x01 47 #define VIO_SUBTYPE_ACK 0x02 48 #define VIO_SUBTYPE_NACK 0x04 49 50 /* Sub-Type envelopes. */ 51 #define VIO_VER_INFO 0x0001 52 #define VIO_ATTR_INFO 0x0002 53 #define VIO_DRING_REG 0x0003 54 #define VIO_DRING_UNREG 0x0004 55 #define VIO_RDX 0x0005 56 57 #define VIO_PKT_DATA 0x0040 58 #define VIO_DESC_DATA 0x0041 59 #define VIO_DRING_DATA 0x0042 60 61 struct vio_ver_info { 62 struct vio_msg_tag tag; 63 uint16_t major; 64 uint16_t minor; 65 uint8_t dev_class; 66 uint8_t _reserved1[3]; 67 uint64_t _reserved2[5]; 68 }; 69 70 /* Device types. */ 71 #define VDEV_NETWORK 0x01 72 #define VDEV_NETWORK_SWITCH 0x02 73 #define VDEV_DISK 0x03 74 #define VDEV_DISK_SERVER 0x04 75 76 struct vio_dring_reg { 77 struct vio_msg_tag tag; 78 uint64_t dring_ident; 79 uint32_t num_descriptors; 80 uint32_t descriptor_size; 81 uint16_t options; 82 uint16_t _reserved; 83 uint32_t ncookies; 84 struct ldc_cookie cookie[1]; 85 }; 86 87 /* Ring options. */ 88 #define VIO_TX_RING 0x0001 89 #define VIO_RX_RING 0x0002 90 91 /* Transfer modes. */ 92 #define VIO_PKT_MODE 0x01 93 #define VIO_DESC_MODE 0x02 94 #define VIO_DRING_MODE 0x03 95 96 struct vio_dring_hdr { 97 uint8_t dstate; 98 uint8_t ack: 1; 99 uint16_t _reserved[3]; 100 }; 101 102 /* Descriptor states. */ 103 #define VIO_DESC_FREE 0x01 104 #define VIO_DESC_READY 0x02 105 #define VIO_DESC_ACCEPTED 0x03 106 #define VIO_DESC_DONE 0x04 107 108 struct vio_dring_msg { 109 struct vio_msg_tag tag; 110 uint64_t seq_no; 111 uint64_t dring_ident; 112 uint32_t start_idx; 113 uint32_t end_idx; 114 uint8_t proc_state; 115 uint8_t _reserved1[7]; 116 uint64_t _reserved2[2]; 117 }; 118 119 /* Ring states. */ 120 #define VIO_DP_ACTIVE 0x01 121 #define VIO_DP_STOPPED 0x02 122 123 struct vio_rdx { 124 struct vio_msg_tag tag; 125 uint64_t _reserved[6]; 126 }; 127 128