rndis.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. /*
  2. * RNDIS Definitions for Remote NDIS
  3. *
  4. * Version: $Id: rndis.h,v 1.15 2004/03/25 21:33:46 robert Exp $
  5. *
  6. * Authors: Benedikt Spranger, Pengutronix
  7. * Robert Schwebel, Pengutronix
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2, as published by the Free Software Foundation.
  12. *
  13. * This software was originally developed in conformance with
  14. * Microsoft's Remote NDIS Specification License Agreement.
  15. */
  16. #ifndef _LINUX_RNDIS_H
  17. #define _LINUX_RNDIS_H
  18. #include "ndis.h"
  19. #define RNDIS_MAXIMUM_FRAME_SIZE 1518
  20. #define RNDIS_MAX_TOTAL_SIZE 1558
  21. /* Remote NDIS Versions */
  22. #define RNDIS_MAJOR_VERSION 1
  23. #define RNDIS_MINOR_VERSION 0
  24. /* Status Values */
  25. #define RNDIS_STATUS_SUCCESS 0x00000000U /* Success */
  26. #define RNDIS_STATUS_FAILURE 0xC0000001U /* Unspecified error */
  27. #define RNDIS_STATUS_INVALID_DATA 0xC0010015U /* Invalid data */
  28. #define RNDIS_STATUS_NOT_SUPPORTED 0xC00000BBU /* Unsupported request */
  29. #define RNDIS_STATUS_MEDIA_CONNECT 0x4001000BU /* Device connected */
  30. #define RNDIS_STATUS_MEDIA_DISCONNECT 0x4001000CU /* Device disconnected */
  31. /* For all not specified status messages:
  32. * RNDIS_STATUS_Xxx -> NDIS_STATUS_Xxx
  33. */
  34. /* Message Set for Connectionless (802.3) Devices */
  35. #define REMOTE_NDIS_PACKET_MSG 0x00000001U
  36. #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002U /* Initialize device */
  37. #define REMOTE_NDIS_HALT_MSG 0x00000003U
  38. #define REMOTE_NDIS_QUERY_MSG 0x00000004U
  39. #define REMOTE_NDIS_SET_MSG 0x00000005U
  40. #define REMOTE_NDIS_RESET_MSG 0x00000006U
  41. #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007U
  42. #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008U
  43. /* Message completion */
  44. #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002U
  45. #define REMOTE_NDIS_QUERY_CMPLT 0x80000004U
  46. #define REMOTE_NDIS_SET_CMPLT 0x80000005U
  47. #define REMOTE_NDIS_RESET_CMPLT 0x80000006U
  48. #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008U
  49. /* Device Flags */
  50. #define RNDIS_DF_CONNECTIONLESS 0x00000001U
  51. #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002U
  52. #define RNDIS_MEDIUM_802_3 0x00000000U
  53. /* from drivers/net/sk98lin/h/skgepnmi.h */
  54. #define OID_PNP_CAPABILITIES 0xFD010100
  55. #define OID_PNP_SET_POWER 0xFD010101
  56. #define OID_PNP_QUERY_POWER 0xFD010102
  57. #define OID_PNP_ADD_WAKE_UP_PATTERN 0xFD010103
  58. #define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104
  59. #define OID_PNP_ENABLE_WAKE_UP 0xFD010106
  60. /* supported OIDs */
  61. static const u32 oid_supported_list [] =
  62. {
  63. /* the general stuff */
  64. OID_GEN_SUPPORTED_LIST,
  65. OID_GEN_HARDWARE_STATUS,
  66. OID_GEN_MEDIA_SUPPORTED,
  67. OID_GEN_MEDIA_IN_USE,
  68. OID_GEN_MAXIMUM_FRAME_SIZE,
  69. OID_GEN_LINK_SPEED,
  70. OID_GEN_TRANSMIT_BLOCK_SIZE,
  71. OID_GEN_RECEIVE_BLOCK_SIZE,
  72. OID_GEN_VENDOR_ID,
  73. OID_GEN_VENDOR_DESCRIPTION,
  74. OID_GEN_VENDOR_DRIVER_VERSION,
  75. OID_GEN_CURRENT_PACKET_FILTER,
  76. OID_GEN_MAXIMUM_TOTAL_SIZE,
  77. OID_GEN_MEDIA_CONNECT_STATUS,
  78. OID_GEN_PHYSICAL_MEDIUM,
  79. #if 0
  80. OID_GEN_RNDIS_CONFIG_PARAMETER,
  81. #endif
  82. /* the statistical stuff */
  83. OID_GEN_XMIT_OK,
  84. OID_GEN_RCV_OK,
  85. OID_GEN_XMIT_ERROR,
  86. OID_GEN_RCV_ERROR,
  87. OID_GEN_RCV_NO_BUFFER,
  88. #ifdef RNDIS_OPTIONAL_STATS
  89. OID_GEN_DIRECTED_BYTES_XMIT,
  90. OID_GEN_DIRECTED_FRAMES_XMIT,
  91. OID_GEN_MULTICAST_BYTES_XMIT,
  92. OID_GEN_MULTICAST_FRAMES_XMIT,
  93. OID_GEN_BROADCAST_BYTES_XMIT,
  94. OID_GEN_BROADCAST_FRAMES_XMIT,
  95. OID_GEN_DIRECTED_BYTES_RCV,
  96. OID_GEN_DIRECTED_FRAMES_RCV,
  97. OID_GEN_MULTICAST_BYTES_RCV,
  98. OID_GEN_MULTICAST_FRAMES_RCV,
  99. OID_GEN_BROADCAST_BYTES_RCV,
  100. OID_GEN_BROADCAST_FRAMES_RCV,
  101. OID_GEN_RCV_CRC_ERROR,
  102. OID_GEN_TRANSMIT_QUEUE_LENGTH,
  103. #endif /* RNDIS_OPTIONAL_STATS */
  104. /* mandatory 802.3 */
  105. /* the general stuff */
  106. OID_802_3_PERMANENT_ADDRESS,
  107. OID_802_3_CURRENT_ADDRESS,
  108. OID_802_3_MULTICAST_LIST,
  109. OID_802_3_MAC_OPTIONS,
  110. OID_802_3_MAXIMUM_LIST_SIZE,
  111. /* the statistical stuff */
  112. OID_802_3_RCV_ERROR_ALIGNMENT,
  113. OID_802_3_XMIT_ONE_COLLISION,
  114. OID_802_3_XMIT_MORE_COLLISIONS,
  115. #ifdef RNDIS_OPTIONAL_STATS
  116. OID_802_3_XMIT_DEFERRED,
  117. OID_802_3_XMIT_MAX_COLLISIONS,
  118. OID_802_3_RCV_OVERRUN,
  119. OID_802_3_XMIT_UNDERRUN,
  120. OID_802_3_XMIT_HEARTBEAT_FAILURE,
  121. OID_802_3_XMIT_TIMES_CRS_LOST,
  122. OID_802_3_XMIT_LATE_COLLISIONS,
  123. #endif /* RNDIS_OPTIONAL_STATS */
  124. #ifdef RNDIS_PM
  125. /* PM and wakeup are mandatory for USB: */
  126. /* power management */
  127. OID_PNP_CAPABILITIES,
  128. OID_PNP_QUERY_POWER,
  129. OID_PNP_SET_POWER,
  130. /* wake up host */
  131. OID_PNP_ENABLE_WAKE_UP,
  132. OID_PNP_ADD_WAKE_UP_PATTERN,
  133. OID_PNP_REMOVE_WAKE_UP_PATTERN,
  134. #endif
  135. };
  136. typedef struct rndis_init_msg_type
  137. {
  138. __le32 MessageType;
  139. __le32 MessageLength;
  140. __le32 RequestID;
  141. __le32 MajorVersion;
  142. __le32 MinorVersion;
  143. __le32 MaxTransferSize;
  144. } rndis_init_msg_type;
  145. typedef struct rndis_init_cmplt_type
  146. {
  147. __le32 MessageType;
  148. __le32 MessageLength;
  149. __le32 RequestID;
  150. __le32 Status;
  151. __le32 MajorVersion;
  152. __le32 MinorVersion;
  153. __le32 DeviceFlags;
  154. __le32 Medium;
  155. __le32 MaxPacketsPerTransfer;
  156. __le32 MaxTransferSize;
  157. __le32 PacketAlignmentFactor;
  158. __le32 AFListOffset;
  159. __le32 AFListSize;
  160. } rndis_init_cmplt_type;
  161. typedef struct rndis_halt_msg_type
  162. {
  163. __le32 MessageType;
  164. __le32 MessageLength;
  165. __le32 RequestID;
  166. } rndis_halt_msg_type;
  167. typedef struct rndis_query_msg_type
  168. {
  169. __le32 MessageType;
  170. __le32 MessageLength;
  171. __le32 RequestID;
  172. __le32 OID;
  173. __le32 InformationBufferLength;
  174. __le32 InformationBufferOffset;
  175. __le32 DeviceVcHandle;
  176. } rndis_query_msg_type;
  177. typedef struct rndis_query_cmplt_type
  178. {
  179. __le32 MessageType;
  180. __le32 MessageLength;
  181. __le32 RequestID;
  182. __le32 Status;
  183. __le32 InformationBufferLength;
  184. __le32 InformationBufferOffset;
  185. } rndis_query_cmplt_type;
  186. typedef struct rndis_set_msg_type
  187. {
  188. __le32 MessageType;
  189. __le32 MessageLength;
  190. __le32 RequestID;
  191. __le32 OID;
  192. __le32 InformationBufferLength;
  193. __le32 InformationBufferOffset;
  194. __le32 DeviceVcHandle;
  195. } rndis_set_msg_type;
  196. typedef struct rndis_set_cmplt_type
  197. {
  198. __le32 MessageType;
  199. __le32 MessageLength;
  200. __le32 RequestID;
  201. __le32 Status;
  202. } rndis_set_cmplt_type;
  203. typedef struct rndis_reset_msg_type
  204. {
  205. __le32 MessageType;
  206. __le32 MessageLength;
  207. __le32 Reserved;
  208. } rndis_reset_msg_type;
  209. typedef struct rndis_reset_cmplt_type
  210. {
  211. __le32 MessageType;
  212. __le32 MessageLength;
  213. __le32 Status;
  214. __le32 AddressingReset;
  215. } rndis_reset_cmplt_type;
  216. typedef struct rndis_indicate_status_msg_type
  217. {
  218. __le32 MessageType;
  219. __le32 MessageLength;
  220. __le32 Status;
  221. __le32 StatusBufferLength;
  222. __le32 StatusBufferOffset;
  223. } rndis_indicate_status_msg_type;
  224. typedef struct rndis_keepalive_msg_type
  225. {
  226. __le32 MessageType;
  227. __le32 MessageLength;
  228. __le32 RequestID;
  229. } rndis_keepalive_msg_type;
  230. typedef struct rndis_keepalive_cmplt_type
  231. {
  232. __le32 MessageType;
  233. __le32 MessageLength;
  234. __le32 RequestID;
  235. __le32 Status;
  236. } rndis_keepalive_cmplt_type;
  237. struct rndis_packet_msg_type
  238. {
  239. __le32 MessageType;
  240. __le32 MessageLength;
  241. __le32 DataOffset;
  242. __le32 DataLength;
  243. __le32 OOBDataOffset;
  244. __le32 OOBDataLength;
  245. __le32 NumOOBDataElements;
  246. __le32 PerPacketInfoOffset;
  247. __le32 PerPacketInfoLength;
  248. __le32 VcHandle;
  249. __le32 Reserved;
  250. };
  251. struct rndis_config_parameter
  252. {
  253. __le32 ParameterNameOffset;
  254. __le32 ParameterNameLength;
  255. __le32 ParameterType;
  256. __le32 ParameterValueOffset;
  257. __le32 ParameterValueLength;
  258. };
  259. /* implementation specific */
  260. enum rndis_state
  261. {
  262. RNDIS_UNINITIALIZED,
  263. RNDIS_INITIALIZED,
  264. RNDIS_DATA_INITIALIZED,
  265. };
  266. typedef struct rndis_resp_t
  267. {
  268. struct list_head list;
  269. u8 *buf;
  270. u32 length;
  271. int send;
  272. } rndis_resp_t;
  273. typedef struct rndis_params
  274. {
  275. u8 confignr;
  276. int used;
  277. enum rndis_state state;
  278. u32 filter;
  279. u32 medium;
  280. u32 speed;
  281. u32 media_state;
  282. const u8 *host_mac;
  283. struct net_device *dev;
  284. struct net_device_stats *stats;
  285. u32 vendorID;
  286. const char *vendorDescr;
  287. int (*ack) (struct net_device *);
  288. struct list_head resp_queue;
  289. } rndis_params;
  290. /* RNDIS Message parser and other useless functions */
  291. int rndis_msg_parser (u8 configNr, u8 *buf);
  292. int rndis_register (int (*rndis_control_ack) (struct net_device *));
  293. void rndis_deregister (int configNr);
  294. int rndis_set_param_dev (u8 configNr, struct net_device *dev,
  295. struct net_device_stats *stats);
  296. int rndis_set_param_vendor (u8 configNr, u32 vendorID,
  297. const char *vendorDescr);
  298. int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed);
  299. void rndis_add_hdr (struct sk_buff *skb);
  300. int rndis_rm_hdr (struct sk_buff *skb);
  301. u8 *rndis_get_next_response (int configNr, u32 *length);
  302. void rndis_free_response (int configNr, u8 *buf);
  303. int rndis_signal_connect (int configNr);
  304. int rndis_signal_disconnect (int configNr);
  305. int rndis_state (int configNr);
  306. extern void rndis_set_host_mac (int configNr, const u8 *addr);
  307. int __init rndis_init (void);
  308. void rndis_exit (void);
  309. #endif /* _LINUX_RNDIS_H */