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 | |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 25 | typedef struct rndis_init_msg_type |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | { |
| 27 | __le32 MessageType; |
| 28 | __le32 MessageLength; |
| 29 | __le32 RequestID; |
| 30 | __le32 MajorVersion; |
| 31 | __le32 MinorVersion; |
| 32 | __le32 MaxTransferSize; |
| 33 | } rndis_init_msg_type; |
| 34 | |
| 35 | typedef struct rndis_init_cmplt_type |
| 36 | { |
| 37 | __le32 MessageType; |
| 38 | __le32 MessageLength; |
| 39 | __le32 RequestID; |
| 40 | __le32 Status; |
| 41 | __le32 MajorVersion; |
| 42 | __le32 MinorVersion; |
| 43 | __le32 DeviceFlags; |
| 44 | __le32 Medium; |
| 45 | __le32 MaxPacketsPerTransfer; |
| 46 | __le32 MaxTransferSize; |
| 47 | __le32 PacketAlignmentFactor; |
| 48 | __le32 AFListOffset; |
| 49 | __le32 AFListSize; |
| 50 | } rndis_init_cmplt_type; |
| 51 | |
| 52 | typedef struct rndis_halt_msg_type |
| 53 | { |
| 54 | __le32 MessageType; |
| 55 | __le32 MessageLength; |
| 56 | __le32 RequestID; |
| 57 | } rndis_halt_msg_type; |
| 58 | |
| 59 | typedef struct rndis_query_msg_type |
| 60 | { |
| 61 | __le32 MessageType; |
| 62 | __le32 MessageLength; |
| 63 | __le32 RequestID; |
| 64 | __le32 OID; |
| 65 | __le32 InformationBufferLength; |
| 66 | __le32 InformationBufferOffset; |
| 67 | __le32 DeviceVcHandle; |
| 68 | } rndis_query_msg_type; |
| 69 | |
| 70 | typedef struct rndis_query_cmplt_type |
| 71 | { |
| 72 | __le32 MessageType; |
| 73 | __le32 MessageLength; |
| 74 | __le32 RequestID; |
| 75 | __le32 Status; |
| 76 | __le32 InformationBufferLength; |
| 77 | __le32 InformationBufferOffset; |
| 78 | } rndis_query_cmplt_type; |
| 79 | |
| 80 | typedef struct rndis_set_msg_type |
| 81 | { |
| 82 | __le32 MessageType; |
| 83 | __le32 MessageLength; |
| 84 | __le32 RequestID; |
| 85 | __le32 OID; |
| 86 | __le32 InformationBufferLength; |
| 87 | __le32 InformationBufferOffset; |
| 88 | __le32 DeviceVcHandle; |
| 89 | } rndis_set_msg_type; |
| 90 | |
| 91 | typedef struct rndis_set_cmplt_type |
| 92 | { |
| 93 | __le32 MessageType; |
| 94 | __le32 MessageLength; |
| 95 | __le32 RequestID; |
| 96 | __le32 Status; |
| 97 | } rndis_set_cmplt_type; |
| 98 | |
| 99 | typedef struct rndis_reset_msg_type |
| 100 | { |
| 101 | __le32 MessageType; |
| 102 | __le32 MessageLength; |
| 103 | __le32 Reserved; |
| 104 | } rndis_reset_msg_type; |
| 105 | |
| 106 | typedef struct rndis_reset_cmplt_type |
| 107 | { |
| 108 | __le32 MessageType; |
| 109 | __le32 MessageLength; |
| 110 | __le32 Status; |
| 111 | __le32 AddressingReset; |
| 112 | } rndis_reset_cmplt_type; |
| 113 | |
| 114 | typedef struct rndis_indicate_status_msg_type |
| 115 | { |
| 116 | __le32 MessageType; |
| 117 | __le32 MessageLength; |
| 118 | __le32 Status; |
| 119 | __le32 StatusBufferLength; |
| 120 | __le32 StatusBufferOffset; |
| 121 | } rndis_indicate_status_msg_type; |
| 122 | |
| 123 | typedef struct rndis_keepalive_msg_type |
| 124 | { |
| 125 | __le32 MessageType; |
| 126 | __le32 MessageLength; |
| 127 | __le32 RequestID; |
| 128 | } rndis_keepalive_msg_type; |
| 129 | |
| 130 | typedef struct rndis_keepalive_cmplt_type |
| 131 | { |
| 132 | __le32 MessageType; |
| 133 | __le32 MessageLength; |
| 134 | __le32 RequestID; |
| 135 | __le32 Status; |
| 136 | } rndis_keepalive_cmplt_type; |
| 137 | |
| 138 | struct rndis_packet_msg_type |
| 139 | { |
| 140 | __le32 MessageType; |
| 141 | __le32 MessageLength; |
| 142 | __le32 DataOffset; |
| 143 | __le32 DataLength; |
| 144 | __le32 OOBDataOffset; |
| 145 | __le32 OOBDataLength; |
| 146 | __le32 NumOOBDataElements; |
| 147 | __le32 PerPacketInfoOffset; |
| 148 | __le32 PerPacketInfoLength; |
| 149 | __le32 VcHandle; |
| 150 | __le32 Reserved; |
Wu, Bryan | 178398d | 2007-04-26 00:38:01 -0700 | [diff] [blame] | 151 | } __attribute__ ((packed)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | struct rndis_config_parameter |
| 154 | { |
| 155 | __le32 ParameterNameOffset; |
| 156 | __le32 ParameterNameLength; |
| 157 | __le32 ParameterType; |
| 158 | __le32 ParameterValueOffset; |
| 159 | __le32 ParameterValueLength; |
| 160 | }; |
| 161 | |
| 162 | /* implementation specific */ |
| 163 | enum rndis_state |
| 164 | { |
| 165 | RNDIS_UNINITIALIZED, |
| 166 | RNDIS_INITIALIZED, |
| 167 | RNDIS_DATA_INITIALIZED, |
| 168 | }; |
| 169 | |
| 170 | typedef struct rndis_resp_t |
| 171 | { |
| 172 | struct list_head list; |
| 173 | u8 *buf; |
| 174 | u32 length; |
| 175 | int send; |
| 176 | } rndis_resp_t; |
| 177 | |
| 178 | typedef struct rndis_params |
| 179 | { |
Andrzej Pietrasiewicz | 81dff86 | 2015-05-18 17:40:04 +0200 | [diff] [blame] | 180 | int confignr; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 181 | u8 used; |
| 182 | u16 saved_filter; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | enum rndis_state state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | u32 medium; |
| 185 | u32 speed; |
| 186 | u32 media_state; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 187 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | const u8 *host_mac; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 189 | u16 *filter; |
David Brownell | 7e27f18 | 2006-06-13 09:54:40 -0700 | [diff] [blame] | 190 | struct net_device *dev; |
David Brownell | 340600a | 2005-04-28 13:45:25 -0700 | [diff] [blame] | 191 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | u32 vendorID; |
xerox_lin | 72ffa18 | 2014-08-14 14:48:44 +0800 | [diff] [blame] | 193 | u8 max_pkt_per_xfer; |
Mayank Rana | 057e475 | 2017-09-20 13:55:11 -0700 | [diff] [blame] | 194 | u32 host_rndis_major_ver; |
| 195 | u32 host_rndis_minor_ver; |
| 196 | u32 dl_max_xfer_size; |
Chandana Kishori Chiluveru | 50a2184 | 2017-11-06 14:54:24 +0530 | [diff] [blame] | 197 | u32 ul_max_xfer_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | const char *vendorDescr; |
Hemant Kumar | 6ccd55c | 2016-02-01 18:54:16 -0800 | [diff] [blame] | 199 | u8 pkt_alignment_factor; |
David Brownell | 15b2d2b | 2008-06-19 18:19:16 -0700 | [diff] [blame] | 200 | void (*resp_avail)(void *v); |
Hemant Kumar | 8b06029 | 2016-12-06 15:58:20 -0800 | [diff] [blame] | 201 | void (*flow_ctrl_enable)(bool enable, |
| 202 | struct rndis_params *params); |
| 203 | |
David Brownell | 15b2d2b | 2008-06-19 18:19:16 -0700 | [diff] [blame] | 204 | void *v; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | struct list_head resp_queue; |
| 206 | } rndis_params; |
| 207 | |
| 208 | /* RNDIS Message parser and other useless functions */ |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 209 | int rndis_msg_parser(struct rndis_params *params, u8 *buf); |
Hemant Kumar | 8b06029 | 2016-12-06 15:58:20 -0800 | [diff] [blame] | 210 | struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v, |
| 211 | void (*flow_ctrl_enable)(bool enable, struct rndis_params *params)); |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 212 | void rndis_deregister(struct rndis_params *params); |
| 213 | 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] | 214 | u16 *cdc_filter); |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 215 | int rndis_set_param_vendor(struct rndis_params *params, u32 vendorID, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | const char *vendorDescr); |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 217 | int rndis_set_param_medium(struct rndis_params *params, u32 medium, |
| 218 | u32 speed); |
Amit Pundir | d29237a | 2015-12-21 14:03:15 +0530 | [diff] [blame] | 219 | void rndis_set_max_pkt_xfer(struct rndis_params *params, u8 max_pkt_per_xfer); |
Chandana Kishori Chiluveru | 50a2184 | 2017-11-06 14:54:24 +0530 | [diff] [blame] | 220 | u32 rndis_get_ul_max_xfer_size(struct rndis_params *params); |
| 221 | u32 rndis_get_dl_max_xfer_size(struct rndis_params *params); |
Andrzej Pietrasiewicz | 6122b15 | 2015-02-06 13:43:29 +0100 | [diff] [blame] | 222 | void rndis_add_hdr(struct sk_buff *skb); |
Brian Niebuhr | 9b39e9d | 2009-08-14 10:04:22 -0500 | [diff] [blame] | 223 | int rndis_rm_hdr(struct gether *port, struct sk_buff *skb, |
| 224 | struct sk_buff_head *list); |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 225 | u8 *rndis_get_next_response(struct rndis_params *params, u32 *length); |
| 226 | void rndis_free_response(struct rndis_params *params, u8 *buf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
Andrzej Pietrasiewicz | 83210e5 | 2015-03-20 08:18:47 +0100 | [diff] [blame] | 228 | void rndis_uninit(struct rndis_params *params); |
| 229 | int rndis_signal_connect(struct rndis_params *params); |
| 230 | int rndis_signal_disconnect(struct rndis_params *params); |
| 231 | int rndis_state(struct rndis_params *params); |
| 232 | extern void rndis_set_host_mac(struct rndis_params *params, const u8 *addr); |
Hemant Kumar | 8b06029 | 2016-12-06 15:58:20 -0800 | [diff] [blame] | 233 | void rndis_flow_control(struct rndis_params *params, bool enable_flow_control); |
Hemant Kumar | 6ccd55c | 2016-02-01 18:54:16 -0800 | [diff] [blame] | 234 | void rndis_set_pkt_alignment_factor(struct rndis_params *params, |
| 235 | u8 pkt_alignment_factor); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | #endif /* _LINUX_RNDIS_H */ |