David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * RNDIS Definitions for Remote NDIS |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * Authors: Benedikt Spranger, Pengutronix |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 5 | * Robert Schwebel, Pengutronix |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * modify it under the terms of the GNU General Public License |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 9 | * version 2, as published by the Free Software Foundation. |
| 10 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * This software was originally developed in conformance with |
| 12 | * Microsoft's Remote NDIS Specification License Agreement. |
| 13 | */ |
| 14 | |
| 15 | #ifndef _LINUX_RNDIS_H |
| 16 | #define _LINUX_RNDIS_H |
| 17 | |
Linus Walleij | 7591157 | 2012-05-11 22:15:50 +0000 | [diff] [blame] | 18 | #include <linux/rndis.h> |
Andrzej Pietrasiewicz | cbbd14a | 2013-05-24 10:23:02 +0200 | [diff] [blame] | 19 | #include "u_ether.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | #include "ndis.h" |
| 21 | |
| 22 | #define RNDIS_MAXIMUM_FRAME_SIZE 1518 |
| 23 | #define RNDIS_MAX_TOTAL_SIZE 1558 |
| 24 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 25 | typedef struct rndis_init_msg_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | __le32 MessageType; |
| 27 | __le32 MessageLength; |
| 28 | __le32 RequestID; |
| 29 | __le32 MajorVersion; |
| 30 | __le32 MinorVersion; |
| 31 | __le32 MaxTransferSize; |
| 32 | } rndis_init_msg_type; |
| 33 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 34 | typedef struct rndis_init_cmplt_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | __le32 MessageType; |
| 36 | __le32 MessageLength; |
| 37 | __le32 RequestID; |
| 38 | __le32 Status; |
| 39 | __le32 MajorVersion; |
| 40 | __le32 MinorVersion; |
| 41 | __le32 DeviceFlags; |
| 42 | __le32 Medium; |
| 43 | __le32 MaxPacketsPerTransfer; |
| 44 | __le32 MaxTransferSize; |
| 45 | __le32 PacketAlignmentFactor; |
| 46 | __le32 AFListOffset; |
| 47 | __le32 AFListSize; |
| 48 | } rndis_init_cmplt_type; |
| 49 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 50 | typedef struct rndis_halt_msg_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | __le32 MessageType; |
| 52 | __le32 MessageLength; |
| 53 | __le32 RequestID; |
| 54 | } rndis_halt_msg_type; |
| 55 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 56 | typedef struct rndis_query_msg_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | __le32 MessageType; |
| 58 | __le32 MessageLength; |
| 59 | __le32 RequestID; |
| 60 | __le32 OID; |
| 61 | __le32 InformationBufferLength; |
| 62 | __le32 InformationBufferOffset; |
| 63 | __le32 DeviceVcHandle; |
| 64 | } rndis_query_msg_type; |
| 65 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 66 | typedef struct rndis_query_cmplt_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | __le32 MessageType; |
| 68 | __le32 MessageLength; |
| 69 | __le32 RequestID; |
| 70 | __le32 Status; |
| 71 | __le32 InformationBufferLength; |
| 72 | __le32 InformationBufferOffset; |
| 73 | } rndis_query_cmplt_type; |
| 74 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 75 | typedef struct rndis_set_msg_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | __le32 MessageType; |
| 77 | __le32 MessageLength; |
| 78 | __le32 RequestID; |
| 79 | __le32 OID; |
| 80 | __le32 InformationBufferLength; |
| 81 | __le32 InformationBufferOffset; |
| 82 | __le32 DeviceVcHandle; |
| 83 | } rndis_set_msg_type; |
| 84 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 85 | typedef struct rndis_set_cmplt_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | __le32 MessageType; |
| 87 | __le32 MessageLength; |
| 88 | __le32 RequestID; |
| 89 | __le32 Status; |
| 90 | } rndis_set_cmplt_type; |
| 91 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 92 | typedef struct rndis_reset_msg_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | __le32 MessageType; |
| 94 | __le32 MessageLength; |
| 95 | __le32 Reserved; |
| 96 | } rndis_reset_msg_type; |
| 97 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 98 | typedef struct rndis_reset_cmplt_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | __le32 MessageType; |
| 100 | __le32 MessageLength; |
| 101 | __le32 Status; |
| 102 | __le32 AddressingReset; |
| 103 | } rndis_reset_cmplt_type; |
| 104 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 105 | typedef struct rndis_indicate_status_msg_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | __le32 MessageType; |
| 107 | __le32 MessageLength; |
| 108 | __le32 Status; |
| 109 | __le32 StatusBufferLength; |
| 110 | __le32 StatusBufferOffset; |
| 111 | } rndis_indicate_status_msg_type; |
| 112 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 113 | typedef struct rndis_keepalive_msg_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | __le32 MessageType; |
| 115 | __le32 MessageLength; |
| 116 | __le32 RequestID; |
| 117 | } rndis_keepalive_msg_type; |
| 118 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 119 | typedef struct rndis_keepalive_cmplt_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | __le32 MessageType; |
| 121 | __le32 MessageLength; |
| 122 | __le32 RequestID; |
| 123 | __le32 Status; |
| 124 | } rndis_keepalive_cmplt_type; |
| 125 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 126 | struct rndis_packet_msg_type { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | __le32 MessageType; |
| 128 | __le32 MessageLength; |
| 129 | __le32 DataOffset; |
| 130 | __le32 DataLength; |
| 131 | __le32 OOBDataOffset; |
| 132 | __le32 OOBDataLength; |
| 133 | __le32 NumOOBDataElements; |
| 134 | __le32 PerPacketInfoOffset; |
| 135 | __le32 PerPacketInfoLength; |
| 136 | __le32 VcHandle; |
| 137 | __le32 Reserved; |
Wu, Bryan | 178398d | 2007-04-26 00:38:01 -0700 | [diff] [blame] | 138 | } __attribute__ ((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 140 | struct rndis_config_parameter { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | __le32 ParameterNameOffset; |
| 142 | __le32 ParameterNameLength; |
| 143 | __le32 ParameterType; |
| 144 | __le32 ParameterValueOffset; |
| 145 | __le32 ParameterValueLength; |
| 146 | }; |
| 147 | |
| 148 | /* implementation specific */ |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 149 | enum rndis_state { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | RNDIS_UNINITIALIZED, |
| 151 | RNDIS_INITIALIZED, |
| 152 | RNDIS_DATA_INITIALIZED, |
| 153 | }; |
| 154 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 155 | typedef struct rndis_resp_t { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | struct list_head list; |
| 157 | u8 *buf; |
| 158 | u32 length; |
| 159 | int send; |
| 160 | } rndis_resp_t; |
| 161 | |
Anson Jacob | 97f0117 | 2016-11-11 19:07:01 -0500 | [diff] [blame] | 162 | typedef struct rndis_params { |
Andrzej Pietrasiewicz | 81dff86 | 2015-05-18 17:40:04 +0200 | [diff] [blame] | 163 | int confignr; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 164 | u8 used; |
| 165 | u16 saved_filter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | enum rndis_state state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | u32 medium; |
| 168 | u32 speed; |
| 169 | u32 media_state; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 170 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | const u8 *host_mac; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 172 | u16 *filter; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 173 | struct net_device *dev; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 174 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | u32 vendorID; |
| 176 | const char *vendorDescr; |
David Brownell | 15b2d2b | 2008-06-19 18:19:16 -0700 | [diff] [blame] | 177 | void (*resp_avail)(void *v); |
| 178 | void *v; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | struct list_head resp_queue; |
| 180 | } rndis_params; |
| 181 | |
| 182 | /* RNDIS Message parser and other useless functions */ |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 183 | int rndis_msg_parser(struct rndis_params *params, u8 *buf); |
| 184 | struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v); |
| 185 | void rndis_deregister(struct rndis_params *params); |
| 186 | int rndis_set_param_dev(struct rndis_params *params, struct net_device *dev, |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 187 | u16 *cdc_filter); |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 188 | int rndis_set_param_vendor(struct rndis_params *params, u32 vendorID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | const char *vendorDescr); |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 190 | int rndis_set_param_medium(struct rndis_params *params, u32 medium, |
| 191 | u32 speed); |
Andrzej Pietrasiewicz | 6122b15 | 2015-02-06 13:43:29 +0100 | [diff] [blame] | 192 | void rndis_add_hdr(struct sk_buff *skb); |
Brian Niebuhr | 9b39e9d | 2009-08-14 10:04:22 -0500 | [diff] [blame] | 193 | int rndis_rm_hdr(struct gether *port, struct sk_buff *skb, |
| 194 | struct sk_buff_head *list); |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 195 | u8 *rndis_get_next_response(struct rndis_params *params, u32 *length); |
| 196 | void rndis_free_response(struct rndis_params *params, u8 *buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 198 | void rndis_uninit(struct rndis_params *params); |
| 199 | int rndis_signal_connect(struct rndis_params *params); |
| 200 | int rndis_signal_disconnect(struct rndis_params *params); |
| 201 | int rndis_state(struct rndis_params *params); |
| 202 | extern void rndis_set_host_mac(struct rndis_params *params, const u8 *addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | #endif /* _LINUX_RNDIS_H */ |