Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Host Side support for RNDIS Networking Links |
| 3 | * Copyright (C) 2005 by David Brownell |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | |
Robert P. J. Day | dda43a0 | 2008-03-07 13:45:32 -0500 | [diff] [blame] | 20 | #ifndef __LINUX_USB_RNDIS_HOST_H |
| 21 | #define __LINUX_USB_RNDIS_HOST_H |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 22 | |
Linus Walleij | 7591157 | 2012-05-11 22:15:50 +0000 | [diff] [blame] | 23 | #include <linux/rndis.h> |
| 24 | |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 25 | /* |
| 26 | * CONTROL uses CDC "encapsulated commands" with funky notifications. |
| 27 | * - control-out: SEND_ENCAPSULATED |
| 28 | * - interrupt-in: RESPONSE_AVAILABLE |
| 29 | * - control-in: GET_ENCAPSULATED |
| 30 | * |
| 31 | * We'll try to ignore the RESPONSE_AVAILABLE notifications. |
| 32 | * |
| 33 | * REVISIT some RNDIS implementations seem to have curious issues still |
| 34 | * to be resolved. |
| 35 | */ |
| 36 | struct rndis_msg_hdr { |
| 37 | __le32 msg_type; /* RNDIS_MSG_* */ |
| 38 | __le32 msg_len; |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 39 | /* followed by data that varies between messages */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 40 | __le32 request_id; |
| 41 | __le32 status; |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 42 | /* ... and more */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 43 | } __attribute__ ((packed)); |
| 44 | |
| 45 | /* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */ |
| 46 | #define CONTROL_BUFFER_SIZE 1025 |
| 47 | |
| 48 | /* RNDIS defines an (absurdly huge) 10 second control timeout, |
| 49 | * but ActiveSync seems to use a more usual 5 second timeout |
| 50 | * (which matches the USB 2.0 spec). |
| 51 | */ |
| 52 | #define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000) |
| 53 | |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 54 | struct rndis_data_hdr { |
| 55 | __le32 msg_type; /* RNDIS_MSG_PACKET */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 56 | __le32 msg_len; /* rndis_data_hdr + data_len + pad */ |
| 57 | __le32 data_offset; /* 36 -- right after header */ |
| 58 | __le32 data_len; /* ... real packet size */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 59 | |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 60 | __le32 oob_data_offset; /* zero */ |
| 61 | __le32 oob_data_len; /* zero */ |
| 62 | __le32 num_oob; /* zero */ |
| 63 | __le32 packet_data_offset; /* zero */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 64 | |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 65 | __le32 packet_data_len; /* zero */ |
| 66 | __le32 vc_handle; /* zero */ |
| 67 | __le32 reserved; /* zero */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 68 | } __attribute__ ((packed)); |
| 69 | |
| 70 | struct rndis_init { /* OUT */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 71 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 72 | __le32 msg_type; /* RNDIS_MSG_INIT */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 73 | __le32 msg_len; /* 24 */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 74 | __le32 request_id; |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 75 | __le32 major_version; /* of rndis (1.0) */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 76 | __le32 minor_version; |
| 77 | __le32 max_transfer_size; |
| 78 | } __attribute__ ((packed)); |
| 79 | |
| 80 | struct rndis_init_c { /* IN */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 81 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 82 | __le32 msg_type; /* RNDIS_MSG_INIT_C */ |
| 83 | __le32 msg_len; |
| 84 | __le32 request_id; |
| 85 | __le32 status; |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 86 | __le32 major_version; /* of rndis (1.0) */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 87 | __le32 minor_version; |
| 88 | __le32 device_flags; |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 89 | __le32 medium; /* zero == 802.3 */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 90 | __le32 max_packets_per_message; |
| 91 | __le32 max_transfer_size; |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 92 | __le32 packet_alignment; /* max 7; (1<<n) bytes */ |
| 93 | __le32 af_list_offset; /* zero */ |
| 94 | __le32 af_list_size; /* zero */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 95 | } __attribute__ ((packed)); |
| 96 | |
| 97 | struct rndis_halt { /* OUT (no reply) */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 98 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 99 | __le32 msg_type; /* RNDIS_MSG_HALT */ |
| 100 | __le32 msg_len; |
| 101 | __le32 request_id; |
| 102 | } __attribute__ ((packed)); |
| 103 | |
| 104 | struct rndis_query { /* OUT */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 105 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 106 | __le32 msg_type; /* RNDIS_MSG_QUERY */ |
| 107 | __le32 msg_len; |
| 108 | __le32 request_id; |
| 109 | __le32 oid; |
| 110 | __le32 len; |
| 111 | __le32 offset; |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 112 | /*?*/ __le32 handle; /* zero */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 113 | } __attribute__ ((packed)); |
| 114 | |
| 115 | struct rndis_query_c { /* IN */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 116 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 117 | __le32 msg_type; /* RNDIS_MSG_QUERY_C */ |
| 118 | __le32 msg_len; |
| 119 | __le32 request_id; |
| 120 | __le32 status; |
| 121 | __le32 len; |
| 122 | __le32 offset; |
| 123 | } __attribute__ ((packed)); |
| 124 | |
| 125 | struct rndis_set { /* OUT */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 126 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 127 | __le32 msg_type; /* RNDIS_MSG_SET */ |
| 128 | __le32 msg_len; |
| 129 | __le32 request_id; |
| 130 | __le32 oid; |
| 131 | __le32 len; |
| 132 | __le32 offset; |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 133 | /*?*/ __le32 handle; /* zero */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 134 | } __attribute__ ((packed)); |
| 135 | |
| 136 | struct rndis_set_c { /* IN */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 137 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 138 | __le32 msg_type; /* RNDIS_MSG_SET_C */ |
| 139 | __le32 msg_len; |
| 140 | __le32 request_id; |
| 141 | __le32 status; |
| 142 | } __attribute__ ((packed)); |
| 143 | |
| 144 | struct rndis_reset { /* IN */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 145 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 146 | __le32 msg_type; /* RNDIS_MSG_RESET */ |
| 147 | __le32 msg_len; |
| 148 | __le32 reserved; |
| 149 | } __attribute__ ((packed)); |
| 150 | |
| 151 | struct rndis_reset_c { /* OUT */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 152 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 153 | __le32 msg_type; /* RNDIS_MSG_RESET_C */ |
| 154 | __le32 msg_len; |
| 155 | __le32 status; |
| 156 | __le32 addressing_lost; |
| 157 | } __attribute__ ((packed)); |
| 158 | |
| 159 | struct rndis_indicate { /* IN (unrequested) */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 160 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 161 | __le32 msg_type; /* RNDIS_MSG_INDICATE */ |
| 162 | __le32 msg_len; |
| 163 | __le32 status; |
| 164 | __le32 length; |
| 165 | __le32 offset; |
| 166 | /**/ __le32 diag_status; |
| 167 | __le32 error_offset; |
| 168 | /**/ __le32 message; |
| 169 | } __attribute__ ((packed)); |
| 170 | |
| 171 | struct rndis_keepalive { /* OUT (optionally IN) */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 172 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 173 | __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */ |
| 174 | __le32 msg_len; |
| 175 | __le32 request_id; |
| 176 | } __attribute__ ((packed)); |
| 177 | |
| 178 | struct rndis_keepalive_c { /* IN (optionally OUT) */ |
Greg Kroah-Hartman | 0858a3a | 2010-05-17 10:58:12 -0700 | [diff] [blame] | 179 | /* header and: */ |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 180 | __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */ |
| 181 | __le32 msg_len; |
| 182 | __le32 request_id; |
| 183 | __le32 status; |
| 184 | } __attribute__ ((packed)); |
| 185 | |
Jussi Kivilinna | 7517579 | 2008-01-26 00:51:12 +0200 | [diff] [blame] | 186 | /* default filter used with RNDIS devices */ |
| 187 | #define RNDIS_DEFAULT_FILTER ( \ |
| 188 | RNDIS_PACKET_TYPE_DIRECTED | \ |
| 189 | RNDIS_PACKET_TYPE_BROADCAST | \ |
| 190 | RNDIS_PACKET_TYPE_ALL_MULTICAST | \ |
| 191 | RNDIS_PACKET_TYPE_PROMISCUOUS) |
| 192 | |
Jussi Kivilinna | 039ee17 | 2008-01-27 23:34:33 +0200 | [diff] [blame] | 193 | /* Flags to require specific physical medium type for generic_rndis_bind() */ |
| 194 | #define FLAG_RNDIS_PHYM_NOT_WIRELESS 0x0001 |
| 195 | #define FLAG_RNDIS_PHYM_WIRELESS 0x0002 |
| 196 | |
Ben Hutchings | 4d42d41 | 2011-04-13 14:48:55 -0700 | [diff] [blame] | 197 | /* Flags for driver_info::data */ |
| 198 | #define RNDIS_DRIVER_DATA_POLL_STATUS 1 /* poll status before control */ |
Jussi Kivilinna | 5665998 | 2008-01-26 00:51:17 +0200 | [diff] [blame] | 199 | |
| 200 | extern void rndis_status(struct usbnet *dev, struct urb *urb); |
Jussi Kivilinna | 818727b | 2008-06-18 15:40:12 +0300 | [diff] [blame] | 201 | extern int |
| 202 | rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen); |
Jussi Kivilinna | 039ee17 | 2008-01-27 23:34:33 +0200 | [diff] [blame] | 203 | extern int |
| 204 | generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags); |
Jussi Kivilinna | 5665998 | 2008-01-26 00:51:17 +0200 | [diff] [blame] | 205 | extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf); |
| 206 | extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb); |
| 207 | extern struct sk_buff * |
| 208 | rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags); |
| 209 | |
Robert P. J. Day | dda43a0 | 2008-03-07 13:45:32 -0500 | [diff] [blame] | 210 | #endif /* __LINUX_USB_RNDIS_HOST_H */ |