blob: d44ef85db177706d47dfb135accf6ceed5ca157f [file] [log] [blame]
Jussi Kivilinna75175792008-01-26 00:51:12 +02001/*
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. Daydda43a02008-03-07 13:45:32 -050020#ifndef __LINUX_USB_RNDIS_HOST_H
21#define __LINUX_USB_RNDIS_HOST_H
Jussi Kivilinna75175792008-01-26 00:51:12 +020022
Linus Walleij75911572012-05-11 22:15:50 +000023#include <linux/rndis.h>
24
Jussi Kivilinna75175792008-01-26 00:51:12 +020025/*
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 */
36struct rndis_msg_hdr {
37 __le32 msg_type; /* RNDIS_MSG_* */
38 __le32 msg_len;
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070039 /* followed by data that varies between messages */
Jussi Kivilinna75175792008-01-26 00:51:12 +020040 __le32 request_id;
41 __le32 status;
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070042 /* ... and more */
Jussi Kivilinna75175792008-01-26 00:51:12 +020043} __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 Kivilinna75175792008-01-26 00:51:12 +020054struct rndis_data_hdr {
55 __le32 msg_type; /* RNDIS_MSG_PACKET */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070056 __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 Kivilinna75175792008-01-26 00:51:12 +020059
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070060 __le32 oob_data_offset; /* zero */
61 __le32 oob_data_len; /* zero */
62 __le32 num_oob; /* zero */
63 __le32 packet_data_offset; /* zero */
Jussi Kivilinna75175792008-01-26 00:51:12 +020064
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070065 __le32 packet_data_len; /* zero */
66 __le32 vc_handle; /* zero */
67 __le32 reserved; /* zero */
Jussi Kivilinna75175792008-01-26 00:51:12 +020068} __attribute__ ((packed));
69
70struct rndis_init { /* OUT */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070071 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +020072 __le32 msg_type; /* RNDIS_MSG_INIT */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070073 __le32 msg_len; /* 24 */
Jussi Kivilinna75175792008-01-26 00:51:12 +020074 __le32 request_id;
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070075 __le32 major_version; /* of rndis (1.0) */
Jussi Kivilinna75175792008-01-26 00:51:12 +020076 __le32 minor_version;
77 __le32 max_transfer_size;
78} __attribute__ ((packed));
79
80struct rndis_init_c { /* IN */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070081 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +020082 __le32 msg_type; /* RNDIS_MSG_INIT_C */
83 __le32 msg_len;
84 __le32 request_id;
85 __le32 status;
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070086 __le32 major_version; /* of rndis (1.0) */
Jussi Kivilinna75175792008-01-26 00:51:12 +020087 __le32 minor_version;
88 __le32 device_flags;
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070089 __le32 medium; /* zero == 802.3 */
Jussi Kivilinna75175792008-01-26 00:51:12 +020090 __le32 max_packets_per_message;
91 __le32 max_transfer_size;
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070092 __le32 packet_alignment; /* max 7; (1<<n) bytes */
93 __le32 af_list_offset; /* zero */
94 __le32 af_list_size; /* zero */
Jussi Kivilinna75175792008-01-26 00:51:12 +020095} __attribute__ ((packed));
96
97struct rndis_halt { /* OUT (no reply) */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -070098 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +020099 __le32 msg_type; /* RNDIS_MSG_HALT */
100 __le32 msg_len;
101 __le32 request_id;
102} __attribute__ ((packed));
103
104struct rndis_query { /* OUT */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -0700105 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200106 __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-Hartman0858a3a2010-05-17 10:58:12 -0700112/*?*/ __le32 handle; /* zero */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200113} __attribute__ ((packed));
114
115struct rndis_query_c { /* IN */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -0700116 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200117 __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
125struct rndis_set { /* OUT */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -0700126 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200127 __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-Hartman0858a3a2010-05-17 10:58:12 -0700133/*?*/ __le32 handle; /* zero */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200134} __attribute__ ((packed));
135
136struct rndis_set_c { /* IN */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -0700137 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200138 __le32 msg_type; /* RNDIS_MSG_SET_C */
139 __le32 msg_len;
140 __le32 request_id;
141 __le32 status;
142} __attribute__ ((packed));
143
144struct rndis_reset { /* IN */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -0700145 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200146 __le32 msg_type; /* RNDIS_MSG_RESET */
147 __le32 msg_len;
148 __le32 reserved;
149} __attribute__ ((packed));
150
151struct rndis_reset_c { /* OUT */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -0700152 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200153 __le32 msg_type; /* RNDIS_MSG_RESET_C */
154 __le32 msg_len;
155 __le32 status;
156 __le32 addressing_lost;
157} __attribute__ ((packed));
158
159struct rndis_indicate { /* IN (unrequested) */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -0700160 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200161 __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
171struct rndis_keepalive { /* OUT (optionally IN) */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -0700172 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200173 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
174 __le32 msg_len;
175 __le32 request_id;
176} __attribute__ ((packed));
177
178struct rndis_keepalive_c { /* IN (optionally OUT) */
Greg Kroah-Hartman0858a3a2010-05-17 10:58:12 -0700179 /* header and: */
Jussi Kivilinna75175792008-01-26 00:51:12 +0200180 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
181 __le32 msg_len;
182 __le32 request_id;
183 __le32 status;
184} __attribute__ ((packed));
185
Jussi Kivilinna75175792008-01-26 00:51:12 +0200186/* 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 Kivilinna039ee172008-01-27 23:34:33 +0200193/* 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 Hutchings4d42d412011-04-13 14:48:55 -0700197/* Flags for driver_info::data */
198#define RNDIS_DRIVER_DATA_POLL_STATUS 1 /* poll status before control */
Jussi Kivilinna56659982008-01-26 00:51:17 +0200199
200extern void rndis_status(struct usbnet *dev, struct urb *urb);
Jussi Kivilinna818727b2008-06-18 15:40:12 +0300201extern int
202rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen);
Jussi Kivilinna039ee172008-01-27 23:34:33 +0200203extern int
204generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
Jussi Kivilinna56659982008-01-26 00:51:17 +0200205extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);
206extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
207extern struct sk_buff *
208rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags);
209
Robert P. J. Daydda43a02008-03-07 13:45:32 -0500210#endif /* __LINUX_USB_RNDIS_HOST_H */