1 /* 2 * Copyright (c) 2017 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 void rndis_clean(void); 8 9 /* 10 * RNDIS definitions 11 */ 12 13 #define RNDIS_GEN_MAX_TOTAL_SIZE 1558 14 15 #define RNDIS_MAJOR_VERSION 1 16 #define RNDIS_MINOR_VERSION 0 17 18 #define COMPLETE BIT(31) 19 20 #define RNDIS_DATA_PACKET 0x01 21 #define RNDIS_CMD_INITIALIZE 0x02 22 #define RNDIS_CMD_INITIALIZE_COMPLETE (RNDIS_CMD_INITIALIZE | COMPLETE) 23 #define RNDIS_CMD_HALT 0x03 24 #define RNDIS_CMD_QUERY 0x04 25 #define RNDIS_CMD_QUERY_COMPLETE (RNDIS_CMD_QUERY | COMPLETE) 26 #define RNDIS_CMD_SET 0x05 27 #define RNDIS_CMD_SET_COMPLETE (RNDIS_CMD_SET | COMPLETE) 28 #define RNDIS_CMD_RESET 0x06 29 #define RNDIS_CMD_RESET_COMPLETE (RNDIS_CMD_RESET | COMPLETE) 30 #define RNDIS_CMD_INDICATE 0x07 31 #define RNDIS_CMD_KEEPALIVE 0x08 32 #define RNDIS_CMD_KEEPALIVE_COMPLETE (RNDIS_CMD_KEEPALIVE | COMPLETE) 33 34 #define RNDIS_CMD_STATUS_SUCCESS 0 35 #define RNDIS_CMD_STATUS_INVALID_DATA 0xC0010015 36 #define RNDIS_CMD_STATUS_NOT_SUPP 0xC00000BB 37 38 #define RNDIS_FLAG_CONNECTIONLESS BIT(0) 39 40 #define RNDIS_MEDIUM_WIRED_ETHERNET 0 41 42 struct rndis_init_cmd { 43 uint32_t type; 44 uint32_t len; 45 uint32_t req_id; 46 uint32_t major_ver; 47 uint32_t minor_version; 48 uint32_t max_transfer_size; 49 } __packed; 50 51 struct rndis_init_cmd_complete { 52 uint32_t type; 53 uint32_t len; 54 uint32_t req_id; 55 uint32_t status; 56 uint32_t major_ver; 57 uint32_t minor_ver; 58 uint32_t flags; 59 uint32_t medium; 60 uint32_t max_packets; 61 uint32_t max_transfer_size; 62 uint32_t pkt_align_factor; 63 uint32_t __reserved[2]; 64 } __packed; 65 66 struct rndis_query_cmd { 67 uint32_t type; 68 uint32_t len; 69 uint32_t req_id; 70 uint32_t object_id; 71 uint32_t buf_len; 72 uint32_t buf_offset; 73 uint32_t vc_handle; /* Reserved for connection-oriented devices */ 74 } __packed; 75 76 /* Specifies RNDS objects for Query and Set */ 77 #define RNDIS_OBJECT_ID_GEN_SUPP_LIST 0x00010101 78 #define RNDIS_OBJECT_ID_GEN_HW_STATUS 0x00010102 79 #define RNDIS_OBJECT_ID_GEN_SUPP_MEDIA 0x00010103 80 #define RNDIS_OBJECT_ID_GEN_IN_USE_MEDIA 0x00010104 81 82 #define RNDIS_OBJECT_ID_GEN_MAX_FRAME_SIZE 0x00010106 83 #define RNDIS_OBJECT_ID_GEN_LINK_SPEED 0x00010107 84 #define RNDIS_OBJECT_ID_GEN_BLOCK_TX_SIZE 0x0001010A 85 #define RNDIS_OBJECT_ID_GEN_BLOCK_RX_SIZE 0x0001010B 86 87 #define RNDIS_OBJECT_ID_GEN_VENDOR_ID 0x0001010C 88 #define RNDIS_OBJECT_ID_GEN_VENDOR_DESC 0x0001010D 89 #define RNDIS_OBJECT_ID_GEN_VENDOR_DRV_VER 0x00010116 90 91 #define RNDIS_OBJECT_ID_GEN_PKT_FILTER 0x0001010E 92 #define RNDIS_OBJECT_ID_GEN_MAX_TOTAL_SIZE 0x00010111 93 #define RNDIS_OBJECT_ID_GEN_CONN_MEDIA_STATUS 0x00010114 94 95 #define RNDIS_OBJECT_ID_GEN_PHYSICAL_MEDIUM 0x00010202 96 97 #define RNDIS_OBJECT_ID_GEN_TRANSMIT_OK 0x00020101 98 #define RNDIS_OBJECT_ID_GEN_RECEIVE_OK 0x00020102 99 #define RNDIS_OBJECT_ID_GEN_TRANSMIT_ERROR 0x00020103 100 #define RNDIS_OBJECT_ID_GEN_RECEIVE_ERROR 0x00020104 101 #define RNDIS_OBJECT_ID_GEN_RECEIVE_NO_BUF 0x00020105 102 103 /* The address of the NIC encoded in the hardware */ 104 #define RNDIS_OBJECT_ID_802_3_PERMANENT_ADDRESS 0x01010101 105 #define RNDIS_OBJECT_ID_802_3_CURR_ADDRESS 0x01010102 106 #define RNDIS_OBJECT_ID_802_3_MCAST_LIST 0x01010103 107 #define RNDIS_OBJECT_ID_802_3_MAX_LIST_SIZE 0x01010104 108 #define RNDIS_OBJECT_ID_802_3_MAC_OPTIONS 0x01010105 109 110 /* Media types used */ 111 #define RNDIS_PHYSICAL_MEDIUM_TYPE_UNSPECIFIED 0x00 112 113 /* Connection Media states */ 114 #define RNDIS_OBJECT_ID_MEDIA_CONNECTED 0x00 115 #define RNDIS_OBJECT_ID_MEDIA_DISCONNECTED 0x01 116 117 #define RNDIS_STATUS_CONNECT_MEDIA 0x4001000B 118 #define RNDIS_STATUS_DISCONNECT_MEDIA 0x4001000C 119 120 struct rndis_query_cmd_complete { 121 uint32_t type; 122 uint32_t len; 123 uint32_t req_id; 124 uint32_t status; 125 uint32_t buf_len; 126 uint32_t buf_offset; 127 } __packed; 128 129 struct rndis_set_cmd { 130 uint32_t type; 131 uint32_t len; 132 uint32_t req_id; 133 uint32_t object_id; 134 uint32_t buf_len; 135 uint32_t buf_offset; 136 uint32_t vc_handle; /* Reserved for connection-oriented devices */ 137 } __packed; 138 139 struct rndis_set_cmd_complete { 140 uint32_t type; 141 uint32_t len; 142 uint32_t req_id; 143 uint32_t status; 144 } __packed; 145 146 struct rndis_payload_packet { 147 uint32_t type; 148 uint32_t len; 149 uint32_t payload_offset; 150 uint32_t payload_len; 151 uint32_t oob_payload_offset; 152 uint32_t oob_payload_len; 153 uint32_t oob_num; 154 uint32_t pkt_payload_offset; 155 uint32_t pkt_payload_len; 156 uint32_t vc_handle; 157 uint32_t __reserved; 158 } __packed; 159 160 struct rndis_keepalive_cmd { 161 uint32_t type; 162 uint32_t len; 163 uint32_t req_id; 164 } __packed; 165 166 struct rndis_keepalive_cmd_complete { 167 uint32_t type; 168 uint32_t len; 169 uint32_t req_id; 170 uint32_t status; 171 } __packed; 172 173 struct rndis_media_status_indicate { 174 uint32_t type; 175 uint32_t len; 176 uint32_t status; 177 uint32_t buf_len; 178 uint32_t buf_offset; 179 } __packed; 180 181 struct rndis_reset_cmd_complete { 182 uint32_t type; 183 uint32_t len; 184 uint32_t status; 185 uint32_t addr_reset; 186 } __packed; 187