blob: 21e0430ffb98608bb6e0ab85ae9d3d51b508428a [file] [log] [blame]
David Brownell7e27f182006-06-13 09:54:40 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * RNDIS Definitions for Remote NDIS
David Brownell7e27f182006-06-13 09:54:40 -07003 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Authors: Benedikt Spranger, Pengutronix
David Brownell7e27f182006-06-13 09:54:40 -07005 * Robert Schwebel, Pengutronix
6 *
7 * This program is free software; you can redistribute it and/or
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * modify it under the terms of the GNU General Public License
David Brownell7e27f182006-06-13 09:54:40 -07009 * version 2, as published by the Free Software Foundation.
10 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * 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 Walleij75911572012-05-11 22:15:50 +000018#include <linux/rndis.h>
Andrzej Pietrasiewiczcbbd14a2013-05-24 10:23:02 +020019#include "u_ether.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include "ndis.h"
21
22#define RNDIS_MAXIMUM_FRAME_SIZE 1518
23#define RNDIS_MAX_TOTAL_SIZE 1558
24
Anson Jacob97f01172016-11-11 19:07:01 -050025typedef struct rndis_init_msg_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 __le32 MessageType;
27 __le32 MessageLength;
28 __le32 RequestID;
29 __le32 MajorVersion;
30 __le32 MinorVersion;
31 __le32 MaxTransferSize;
32} rndis_init_msg_type;
33
Anson Jacob97f01172016-11-11 19:07:01 -050034typedef struct rndis_init_cmplt_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 __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 Jacob97f01172016-11-11 19:07:01 -050050typedef struct rndis_halt_msg_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 __le32 MessageType;
52 __le32 MessageLength;
53 __le32 RequestID;
54} rndis_halt_msg_type;
55
Anson Jacob97f01172016-11-11 19:07:01 -050056typedef struct rndis_query_msg_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 __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 Jacob97f01172016-11-11 19:07:01 -050066typedef struct rndis_query_cmplt_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 __le32 MessageType;
68 __le32 MessageLength;
69 __le32 RequestID;
70 __le32 Status;
71 __le32 InformationBufferLength;
72 __le32 InformationBufferOffset;
73} rndis_query_cmplt_type;
74
Anson Jacob97f01172016-11-11 19:07:01 -050075typedef struct rndis_set_msg_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 __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 Jacob97f01172016-11-11 19:07:01 -050085typedef struct rndis_set_cmplt_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 __le32 MessageType;
87 __le32 MessageLength;
88 __le32 RequestID;
89 __le32 Status;
90} rndis_set_cmplt_type;
91
Anson Jacob97f01172016-11-11 19:07:01 -050092typedef struct rndis_reset_msg_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 __le32 MessageType;
94 __le32 MessageLength;
95 __le32 Reserved;
96} rndis_reset_msg_type;
97
Anson Jacob97f01172016-11-11 19:07:01 -050098typedef struct rndis_reset_cmplt_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 __le32 MessageType;
100 __le32 MessageLength;
101 __le32 Status;
102 __le32 AddressingReset;
103} rndis_reset_cmplt_type;
104
Anson Jacob97f01172016-11-11 19:07:01 -0500105typedef struct rndis_indicate_status_msg_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 __le32 MessageType;
107 __le32 MessageLength;
108 __le32 Status;
109 __le32 StatusBufferLength;
110 __le32 StatusBufferOffset;
111} rndis_indicate_status_msg_type;
112
Anson Jacob97f01172016-11-11 19:07:01 -0500113typedef struct rndis_keepalive_msg_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 __le32 MessageType;
115 __le32 MessageLength;
116 __le32 RequestID;
117} rndis_keepalive_msg_type;
118
Anson Jacob97f01172016-11-11 19:07:01 -0500119typedef struct rndis_keepalive_cmplt_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 __le32 MessageType;
121 __le32 MessageLength;
122 __le32 RequestID;
123 __le32 Status;
124} rndis_keepalive_cmplt_type;
125
Anson Jacob97f01172016-11-11 19:07:01 -0500126struct rndis_packet_msg_type {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 __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, Bryan178398d2007-04-26 00:38:01 -0700138} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
Anson Jacob97f01172016-11-11 19:07:01 -0500140struct rndis_config_parameter {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 __le32 ParameterNameOffset;
142 __le32 ParameterNameLength;
143 __le32 ParameterType;
144 __le32 ParameterValueOffset;
145 __le32 ParameterValueLength;
146};
147
148/* implementation specific */
Anson Jacob97f01172016-11-11 19:07:01 -0500149enum rndis_state {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 RNDIS_UNINITIALIZED,
151 RNDIS_INITIALIZED,
152 RNDIS_DATA_INITIALIZED,
153};
154
Anson Jacob97f01172016-11-11 19:07:01 -0500155typedef struct rndis_resp_t {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 struct list_head list;
157 u8 *buf;
158 u32 length;
159 int send;
160} rndis_resp_t;
161
Anson Jacob97f01172016-11-11 19:07:01 -0500162typedef struct rndis_params {
Andrzej Pietrasiewicz81dff862015-05-18 17:40:04 +0200163 int confignr;
David Brownell340600a2005-04-28 13:45:25 -0700164 u8 used;
165 u16 saved_filter;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 enum rndis_state state;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 u32 medium;
168 u32 speed;
169 u32 media_state;
David Brownell340600a2005-04-28 13:45:25 -0700170
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 const u8 *host_mac;
David Brownell340600a2005-04-28 13:45:25 -0700172 u16 *filter;
David Brownell7e27f182006-06-13 09:54:40 -0700173 struct net_device *dev;
David Brownell340600a2005-04-28 13:45:25 -0700174
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 u32 vendorID;
176 const char *vendorDescr;
David Brownell15b2d2b2008-06-19 18:19:16 -0700177 void (*resp_avail)(void *v);
178 void *v;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 struct list_head resp_queue;
180} rndis_params;
181
182/* RNDIS Message parser and other useless functions */
Andrzej Pietrasiewicz83210e52015-03-20 08:18:47 +0100183int rndis_msg_parser(struct rndis_params *params, u8 *buf);
184struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v);
185void rndis_deregister(struct rndis_params *params);
186int rndis_set_param_dev(struct rndis_params *params, struct net_device *dev,
David Brownell340600a2005-04-28 13:45:25 -0700187 u16 *cdc_filter);
Andrzej Pietrasiewicz83210e52015-03-20 08:18:47 +0100188int rndis_set_param_vendor(struct rndis_params *params, u32 vendorID,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 const char *vendorDescr);
Andrzej Pietrasiewicz83210e52015-03-20 08:18:47 +0100190int rndis_set_param_medium(struct rndis_params *params, u32 medium,
191 u32 speed);
Andrzej Pietrasiewicz6122b152015-02-06 13:43:29 +0100192void rndis_add_hdr(struct sk_buff *skb);
Brian Niebuhr9b39e9d2009-08-14 10:04:22 -0500193int rndis_rm_hdr(struct gether *port, struct sk_buff *skb,
194 struct sk_buff_head *list);
Andrzej Pietrasiewicz83210e52015-03-20 08:18:47 +0100195u8 *rndis_get_next_response(struct rndis_params *params, u32 *length);
196void rndis_free_response(struct rndis_params *params, u8 *buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Andrzej Pietrasiewicz83210e52015-03-20 08:18:47 +0100198void rndis_uninit(struct rndis_params *params);
199int rndis_signal_connect(struct rndis_params *params);
200int rndis_signal_disconnect(struct rndis_params *params);
201int rndis_state(struct rndis_params *params);
202extern void rndis_set_host_mac(struct rndis_params *params, const u8 *addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204#endif /* _LINUX_RNDIS_H */