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