1f9f848faSopenharmony_ci/* $OpenBSD: if_urndisreg.h,v 1.19 2013/11/21 14:08:05 mpi Exp $ */ 2f9f848faSopenharmony_ci 3f9f848faSopenharmony_ci/* 4f9f848faSopenharmony_ci * Copyright (c) 2010 Jonathan Armani <armani@openbsd.org> 5f9f848faSopenharmony_ci * Copyright (c) 2010 Fabien Romano <fabien@openbsd.org> 6f9f848faSopenharmony_ci * Copyright (c) 2010 Michael Knudsen <mk@openbsd.org> 7f9f848faSopenharmony_ci * All rights reserved. 8f9f848faSopenharmony_ci * 9f9f848faSopenharmony_ci * Permission to use, copy, modify, and distribute this software for any 10f9f848faSopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 11f9f848faSopenharmony_ci * copyright notice and this permission notice appear in all copies. 12f9f848faSopenharmony_ci * 13f9f848faSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 14f9f848faSopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15f9f848faSopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16f9f848faSopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17f9f848faSopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18f9f848faSopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19f9f848faSopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20f9f848faSopenharmony_ci */ 21f9f848faSopenharmony_ci 22f9f848faSopenharmony_ci#ifndef _IF_URNDISREG_H_ 23f9f848faSopenharmony_ci#define _IF_URNDISREG_H_ 24f9f848faSopenharmony_ci 25f9f848faSopenharmony_ci#include "implementation/global_implementation.h" 26f9f848faSopenharmony_ci#include "usb_ethernet.h" 27f9f848faSopenharmony_ci 28f9f848faSopenharmony_ci#define RNDIS_RESPONSE_LEN 1024 /* bytes */ 29f9f848faSopenharmony_ci#define RNDIS_RX_MAXLEN (16 * 1024) 30f9f848faSopenharmony_ci#define RNDIS_TX_FRAMES_MAX 8 31f9f848faSopenharmony_ci#define RNDIS_TX_MAXLEN MCLBYTES 32f9f848faSopenharmony_ci#define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */ 33f9f848faSopenharmony_ci 34f9f848faSopenharmony_ci/* 35f9f848faSopenharmony_ci * Structure of a DEC/Intel/Xerox or 802.3 Ethernet header. 36f9f848faSopenharmony_ci */ 37f9f848faSopenharmony_cistruct ether_header { 38f9f848faSopenharmony_ci uint8_t ether_dhost[NETIF_MAX_HWADDR_LEN]; 39f9f848faSopenharmony_ci uint8_t ether_shost[NETIF_MAX_HWADDR_LEN]; 40f9f848faSopenharmony_ci uint16_t ether_type; 41f9f848faSopenharmony_ci}; 42f9f848faSopenharmony_ci 43f9f848faSopenharmony_cienum { 44f9f848faSopenharmony_ci URNDIS_BULK_RX, 45f9f848faSopenharmony_ci URNDIS_BULK_TX, 46f9f848faSopenharmony_ci URNDIS_INTR_RX, 47f9f848faSopenharmony_ci URNDIS_N_TRANSFER, 48f9f848faSopenharmony_ci}; 49f9f848faSopenharmony_ci 50f9f848faSopenharmony_cistruct urndis_softc { 51f9f848faSopenharmony_ci struct usb_ether sc_ue; 52f9f848faSopenharmony_ci struct mtx sc_mtx; 53f9f848faSopenharmony_ci 54f9f848faSopenharmony_ci /* RNDIS device info */ 55f9f848faSopenharmony_ci uint32_t sc_lim_pktsz; 56f9f848faSopenharmony_ci uint32_t sc_filter; 57f9f848faSopenharmony_ci 58f9f848faSopenharmony_ci struct usb_device *sc_udev; 59f9f848faSopenharmony_ci struct usb_xfer *sc_xfer[URNDIS_N_TRANSFER]; 60f9f848faSopenharmony_ci 61f9f848faSopenharmony_ci uint8_t sc_ifaceno_ctl; 62f9f848faSopenharmony_ci uint8_t sc_response_buf[RNDIS_RESPONSE_LEN] __aligned(4); 63f9f848faSopenharmony_ci}; 64f9f848faSopenharmony_ci 65f9f848faSopenharmony_ci#define URNDIS_LOCK(sc) mtx_lock(&(sc)->sc_mtx) 66f9f848faSopenharmony_ci#define URNDIS_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx) 67f9f848faSopenharmony_ci#define URNDIS_LOCK_ASSERT(sc, what) mtx_assert(&(sc)->sc_mtx, (what)) 68f9f848faSopenharmony_ci 69f9f848faSopenharmony_ci#define RNDIS_STATUS_BUFFER_OVERFLOW 0x80000005L 70f9f848faSopenharmony_ci#define RNDIS_STATUS_FAILURE 0xC0000001L 71f9f848faSopenharmony_ci#define RNDIS_STATUS_INVALID_DATA 0xC0010015L 72f9f848faSopenharmony_ci#define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BL 73f9f848faSopenharmony_ci#define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CL 74f9f848faSopenharmony_ci#define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBL 75f9f848faSopenharmony_ci#define RNDIS_STATUS_PENDING STATUS_PENDING /* XXX */ 76f9f848faSopenharmony_ci#define RNDIS_STATUS_RESOURCES 0xC000009AL 77f9f848faSopenharmony_ci#define RNDIS_STATUS_SUCCESS 0x00000000L 78f9f848faSopenharmony_ci 79f9f848faSopenharmony_ci#define OID_GEN_SUPPORTED_LIST 0x00010101 80f9f848faSopenharmony_ci#define OID_GEN_HARDWARE_STATUS 0x00010102 81f9f848faSopenharmony_ci#define OID_GEN_MEDIA_SUPPORTED 0x00010103 82f9f848faSopenharmony_ci#define OID_GEN_MEDIA_IN_USE 0x00010104 83f9f848faSopenharmony_ci#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105 84f9f848faSopenharmony_ci#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 85f9f848faSopenharmony_ci#define OID_GEN_LINK_SPEED 0x00010107 86f9f848faSopenharmony_ci#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108 87f9f848faSopenharmony_ci#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109 88f9f848faSopenharmony_ci#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A 89f9f848faSopenharmony_ci#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B 90f9f848faSopenharmony_ci#define OID_GEN_VENDOR_ID 0x0001010C 91f9f848faSopenharmony_ci#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D 92f9f848faSopenharmony_ci#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E 93f9f848faSopenharmony_ci#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F 94f9f848faSopenharmony_ci#define OID_GEN_DRIVER_VERSION 0x00010110 95f9f848faSopenharmony_ci#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 96f9f848faSopenharmony_ci#define OID_GEN_PROTOCOL_OPTIONS 0x00010112 97f9f848faSopenharmony_ci#define OID_GEN_MAC_OPTIONS 0x00010113 98f9f848faSopenharmony_ci#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 99f9f848faSopenharmony_ci#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115 100f9f848faSopenharmony_ci#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 101f9f848faSopenharmony_ci#define OID_GEN_SUPPORTED_GUIDS 0x00010117 102f9f848faSopenharmony_ci#define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118 103f9f848faSopenharmony_ci#define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119 104f9f848faSopenharmony_ci#define OID_GEN_MACHINE_NAME 0x0001021A 105f9f848faSopenharmony_ci#define OID_GEN_RNDIS_CONFIG_PARAMETER 0x0001021B 106f9f848faSopenharmony_ci#define OID_GEN_VLAN_ID 0x0001021C 107f9f848faSopenharmony_ci 108f9f848faSopenharmony_ci#define OID_802_3_PERMANENT_ADDRESS 0x01010101 109f9f848faSopenharmony_ci#define OID_802_3_CURRENT_ADDRESS 0x01010102 110f9f848faSopenharmony_ci#define OID_802_3_MULTICAST_LIST 0x01010103 111f9f848faSopenharmony_ci#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 112f9f848faSopenharmony_ci#define OID_802_3_MAC_OPTIONS 0x01010105 113f9f848faSopenharmony_ci#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101 114f9f848faSopenharmony_ci#define OID_802_3_XMIT_ONE_COLLISION 0x01020102 115f9f848faSopenharmony_ci#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103 116f9f848faSopenharmony_ci#define OID_802_3_XMIT_DEFERRED 0x01020201 117f9f848faSopenharmony_ci#define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202 118f9f848faSopenharmony_ci#define OID_802_3_RCV_OVERRUN 0x01020203 119f9f848faSopenharmony_ci#define OID_802_3_XMIT_UNDERRUN 0x01020204 120f9f848faSopenharmony_ci#define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205 121f9f848faSopenharmony_ci#define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206 122f9f848faSopenharmony_ci#define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 123f9f848faSopenharmony_ci 124f9f848faSopenharmony_ci#define RNDIS_MEDIUM_802_3 0x00000000 125f9f848faSopenharmony_ci 126f9f848faSopenharmony_ci/* Device flags */ 127f9f848faSopenharmony_ci#define RNDIS_DF_CONNECTIONLESS 0x00000001 128f9f848faSopenharmony_ci#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 129f9f848faSopenharmony_ci 130f9f848faSopenharmony_ci/* 131f9f848faSopenharmony_ci * RNDIS data message 132f9f848faSopenharmony_ci */ 133f9f848faSopenharmony_ci#define REMOTE_NDIS_PACKET_MSG 0x00000001 134f9f848faSopenharmony_ci 135f9f848faSopenharmony_cistruct urndis_packet_msg { 136f9f848faSopenharmony_ci uint32_t rm_type; 137f9f848faSopenharmony_ci uint32_t rm_len; 138f9f848faSopenharmony_ci uint32_t rm_dataoffset; 139f9f848faSopenharmony_ci uint32_t rm_datalen; 140f9f848faSopenharmony_ci uint32_t rm_oobdataoffset; 141f9f848faSopenharmony_ci uint32_t rm_oobdatalen; 142f9f848faSopenharmony_ci uint32_t rm_oobdataelements; 143f9f848faSopenharmony_ci uint32_t rm_pktinfooffset; 144f9f848faSopenharmony_ci uint32_t rm_pktinfolen; 145f9f848faSopenharmony_ci uint32_t rm_vchandle; 146f9f848faSopenharmony_ci uint32_t rm_reserved; 147f9f848faSopenharmony_ci}; 148f9f848faSopenharmony_ci 149f9f848faSopenharmony_ci/* 150f9f848faSopenharmony_ci * RNDIS control messages 151f9f848faSopenharmony_ci */ 152f9f848faSopenharmony_cistruct urndis_comp_hdr { 153f9f848faSopenharmony_ci uint32_t rm_type; 154f9f848faSopenharmony_ci uint32_t rm_len; 155f9f848faSopenharmony_ci uint32_t rm_rid; 156f9f848faSopenharmony_ci uint32_t rm_status; 157f9f848faSopenharmony_ci}; 158f9f848faSopenharmony_ci 159f9f848faSopenharmony_ci/* Initialize the device. */ 160f9f848faSopenharmony_ci#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002 161f9f848faSopenharmony_ci#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002 162f9f848faSopenharmony_ci 163f9f848faSopenharmony_cistruct urndis_init_req { 164f9f848faSopenharmony_ci uint32_t rm_type; 165f9f848faSopenharmony_ci uint32_t rm_len; 166f9f848faSopenharmony_ci uint32_t rm_rid; 167f9f848faSopenharmony_ci uint32_t rm_ver_major; 168f9f848faSopenharmony_ci uint32_t rm_ver_minor; 169f9f848faSopenharmony_ci uint32_t rm_max_xfersz; 170f9f848faSopenharmony_ci}; 171f9f848faSopenharmony_ci 172f9f848faSopenharmony_cistruct urndis_init_comp { 173f9f848faSopenharmony_ci uint32_t rm_type; 174f9f848faSopenharmony_ci uint32_t rm_len; 175f9f848faSopenharmony_ci uint32_t rm_rid; 176f9f848faSopenharmony_ci uint32_t rm_status; 177f9f848faSopenharmony_ci uint32_t rm_ver_major; 178f9f848faSopenharmony_ci uint32_t rm_ver_minor; 179f9f848faSopenharmony_ci uint32_t rm_devflags; 180f9f848faSopenharmony_ci uint32_t rm_medium; 181f9f848faSopenharmony_ci uint32_t rm_pktmaxcnt; 182f9f848faSopenharmony_ci uint32_t rm_pktmaxsz; 183f9f848faSopenharmony_ci uint32_t rm_align; 184f9f848faSopenharmony_ci uint32_t rm_aflistoffset; 185f9f848faSopenharmony_ci uint32_t rm_aflistsz; 186f9f848faSopenharmony_ci}; 187f9f848faSopenharmony_ci 188f9f848faSopenharmony_ci/* Halt the device. No response sent. */ 189f9f848faSopenharmony_ci#define REMOTE_NDIS_HALT_MSG 0x00000003 190f9f848faSopenharmony_ci 191f9f848faSopenharmony_cistruct urndis_halt_req { 192f9f848faSopenharmony_ci uint32_t rm_type; 193f9f848faSopenharmony_ci uint32_t rm_len; 194f9f848faSopenharmony_ci uint32_t rm_rid; 195f9f848faSopenharmony_ci}; 196f9f848faSopenharmony_ci 197f9f848faSopenharmony_ci/* Send a query object. */ 198f9f848faSopenharmony_ci#define REMOTE_NDIS_QUERY_MSG 0x00000004 199f9f848faSopenharmony_ci#define REMOTE_NDIS_QUERY_CMPLT 0x80000004 200f9f848faSopenharmony_ci 201f9f848faSopenharmony_cistruct urndis_query_req { 202f9f848faSopenharmony_ci uint32_t rm_type; 203f9f848faSopenharmony_ci uint32_t rm_len; 204f9f848faSopenharmony_ci uint32_t rm_rid; 205f9f848faSopenharmony_ci uint32_t rm_oid; 206f9f848faSopenharmony_ci uint32_t rm_infobuflen; 207f9f848faSopenharmony_ci uint32_t rm_infobufoffset; 208f9f848faSopenharmony_ci uint32_t rm_devicevchdl; 209f9f848faSopenharmony_ci}; 210f9f848faSopenharmony_ci 211f9f848faSopenharmony_cistruct urndis_query_comp { 212f9f848faSopenharmony_ci uint32_t rm_type; 213f9f848faSopenharmony_ci uint32_t rm_len; 214f9f848faSopenharmony_ci uint32_t rm_rid; 215f9f848faSopenharmony_ci uint32_t rm_status; 216f9f848faSopenharmony_ci uint32_t rm_infobuflen; 217f9f848faSopenharmony_ci uint32_t rm_infobufoffset; 218f9f848faSopenharmony_ci}; 219f9f848faSopenharmony_ci 220f9f848faSopenharmony_ci/* Send a set object request. */ 221f9f848faSopenharmony_ci#define REMOTE_NDIS_SET_MSG 0x00000005 222f9f848faSopenharmony_ci#define REMOTE_NDIS_SET_CMPLT 0x80000005 223f9f848faSopenharmony_ci 224f9f848faSopenharmony_cistruct urndis_set_req { 225f9f848faSopenharmony_ci uint32_t rm_type; 226f9f848faSopenharmony_ci uint32_t rm_len; 227f9f848faSopenharmony_ci uint32_t rm_rid; 228f9f848faSopenharmony_ci uint32_t rm_oid; 229f9f848faSopenharmony_ci uint32_t rm_infobuflen; 230f9f848faSopenharmony_ci uint32_t rm_infobufoffset; 231f9f848faSopenharmony_ci uint32_t rm_devicevchdl; 232f9f848faSopenharmony_ci}; 233f9f848faSopenharmony_ci 234f9f848faSopenharmony_cistruct urndis_set_comp { 235f9f848faSopenharmony_ci uint32_t rm_type; 236f9f848faSopenharmony_ci uint32_t rm_len; 237f9f848faSopenharmony_ci uint32_t rm_rid; 238f9f848faSopenharmony_ci uint32_t rm_status; 239f9f848faSopenharmony_ci}; 240f9f848faSopenharmony_ci 241f9f848faSopenharmony_ci#define REMOTE_NDIS_SET_PARAM_NUMERIC 0x00000000 242f9f848faSopenharmony_ci#define REMOTE_NDIS_SET_PARAM_STRING 0x00000002 243f9f848faSopenharmony_ci 244f9f848faSopenharmony_cistruct urndis_set_parameter { 245f9f848faSopenharmony_ci uint32_t rm_nameoffset; 246f9f848faSopenharmony_ci uint32_t rm_namelen; 247f9f848faSopenharmony_ci uint32_t rm_type; 248f9f848faSopenharmony_ci uint32_t rm_valueoffset; 249f9f848faSopenharmony_ci uint32_t rm_valuelen; 250f9f848faSopenharmony_ci}; 251f9f848faSopenharmony_ci 252f9f848faSopenharmony_ci/* Perform a soft reset on the device. */ 253f9f848faSopenharmony_ci#define REMOTE_NDIS_RESET_MSG 0x00000006 254f9f848faSopenharmony_ci#define REMOTE_NDIS_RESET_CMPLT 0x80000006 255f9f848faSopenharmony_ci 256f9f848faSopenharmony_cistruct urndis_reset_req { 257f9f848faSopenharmony_ci uint32_t rm_type; 258f9f848faSopenharmony_ci uint32_t rm_len; 259f9f848faSopenharmony_ci uint32_t rm_rid; 260f9f848faSopenharmony_ci}; 261f9f848faSopenharmony_ci 262f9f848faSopenharmony_cistruct urndis_reset_comp { 263f9f848faSopenharmony_ci uint32_t rm_type; 264f9f848faSopenharmony_ci uint32_t rm_len; 265f9f848faSopenharmony_ci uint32_t rm_status; 266f9f848faSopenharmony_ci uint32_t rm_adrreset; 267f9f848faSopenharmony_ci}; 268f9f848faSopenharmony_ci 269f9f848faSopenharmony_ci/* 802.3 link-state or undefined message error. */ 270f9f848faSopenharmony_ci#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007 271f9f848faSopenharmony_ci 272f9f848faSopenharmony_ci/* Keepalive messsage. May be sent by device. */ 273f9f848faSopenharmony_ci#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008 274f9f848faSopenharmony_ci#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008 275f9f848faSopenharmony_ci 276f9f848faSopenharmony_cistruct urndis_keepalive_req { 277f9f848faSopenharmony_ci uint32_t rm_type; 278f9f848faSopenharmony_ci uint32_t rm_len; 279f9f848faSopenharmony_ci uint32_t rm_rid; 280f9f848faSopenharmony_ci}; 281f9f848faSopenharmony_ci 282f9f848faSopenharmony_cistruct urndis_keepalive_comp { 283f9f848faSopenharmony_ci uint32_t rm_type; 284f9f848faSopenharmony_ci uint32_t rm_len; 285f9f848faSopenharmony_ci uint32_t rm_rid; 286f9f848faSopenharmony_ci uint32_t rm_status; 287f9f848faSopenharmony_ci}; 288f9f848faSopenharmony_ci 289f9f848faSopenharmony_ci/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */ 290f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_DIRECTED 0x00000001 291f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_MULTICAST 0x00000002 292f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 293f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_BROADCAST 0x00000008 294f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 295f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 296f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_SMT 0x00000040 297f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 298f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_GROUP 0x00001000 299f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000 300f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_FUNCTIONAL 0x00004000 301f9f848faSopenharmony_ci#define RNDIS_PACKET_TYPE_MAC_FRAME 0x00008000 302f9f848faSopenharmony_ci 303f9f848faSopenharmony_ci/* RNDIS offsets */ 304f9f848faSopenharmony_ci#define RNDIS_HEADER_OFFSET 8 /* bytes */ 305f9f848faSopenharmony_ci#define RNDIS_DATA_OFFSET ((uint32_t)(sizeof(struct urndis_packet_msg) - RNDIS_HEADER_OFFSET)) 306f9f848faSopenharmony_ci 307f9f848faSopenharmony_ci#endif /* _IF_URNDISREG_H_ */ 308