hyperv_net.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  1. /*
  2. *
  3. * Copyright (c) 2011, Microsoft Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  16. * Place - Suite 330, Boston, MA 02111-1307 USA.
  17. *
  18. * Authors:
  19. * Haiyang Zhang <haiyangz@microsoft.com>
  20. * Hank Janssen <hjanssen@microsoft.com>
  21. * K. Y. Srinivasan <kys@microsoft.com>
  22. *
  23. */
  24. #ifndef _HYPERV_NET_H
  25. #define _HYPERV_NET_H
  26. #include <linux/list.h>
  27. #include <linux/hyperv.h>
  28. #include <linux/rndis.h>
  29. /* Fwd declaration */
  30. struct hv_netvsc_packet;
  31. /* Represent the xfer page packet which contains 1 or more netvsc packet */
  32. struct xferpage_packet {
  33. struct list_head list_ent;
  34. /* # of netvsc packets this xfer packet contains */
  35. u32 count;
  36. };
  37. /*
  38. * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
  39. * within the RNDIS
  40. */
  41. struct hv_netvsc_packet {
  42. /* Bookkeeping stuff */
  43. struct list_head list_ent;
  44. struct hv_device *device;
  45. bool is_data_pkt;
  46. u16 vlan_tci;
  47. /*
  48. * Valid only for receives when we break a xfer page packet
  49. * into multiple netvsc packets
  50. */
  51. struct xferpage_packet *xfer_page_pkt;
  52. union {
  53. struct {
  54. u64 recv_completion_tid;
  55. void *recv_completion_ctx;
  56. void (*recv_completion)(void *context);
  57. } recv;
  58. struct {
  59. u64 send_completion_tid;
  60. void *send_completion_ctx;
  61. void (*send_completion)(void *context);
  62. } send;
  63. } completion;
  64. /* This points to the memory after page_buf */
  65. void *extension;
  66. u32 total_data_buflen;
  67. /* Points to the send/receive buffer where the ethernet frame is */
  68. void *data;
  69. u32 page_buf_cnt;
  70. struct hv_page_buffer page_buf[0];
  71. };
  72. struct netvsc_device_info {
  73. unsigned char mac_adr[6];
  74. bool link_state; /* 0 - link up, 1 - link down */
  75. int ring_size;
  76. };
  77. enum rndis_device_state {
  78. RNDIS_DEV_UNINITIALIZED = 0,
  79. RNDIS_DEV_INITIALIZING,
  80. RNDIS_DEV_INITIALIZED,
  81. RNDIS_DEV_DATAINITIALIZED,
  82. };
  83. struct rndis_device {
  84. struct netvsc_device *net_dev;
  85. enum rndis_device_state state;
  86. bool link_state;
  87. atomic_t new_req_id;
  88. spinlock_t request_lock;
  89. struct list_head req_list;
  90. unsigned char hw_mac_adr[ETH_ALEN];
  91. };
  92. /* Interface */
  93. int netvsc_device_add(struct hv_device *device, void *additional_info);
  94. int netvsc_device_remove(struct hv_device *device);
  95. int netvsc_send(struct hv_device *device,
  96. struct hv_netvsc_packet *packet);
  97. void netvsc_linkstatus_callback(struct hv_device *device_obj,
  98. unsigned int status);
  99. int netvsc_recv_callback(struct hv_device *device_obj,
  100. struct hv_netvsc_packet *packet);
  101. int rndis_filter_open(struct hv_device *dev);
  102. int rndis_filter_close(struct hv_device *dev);
  103. int rndis_filter_device_add(struct hv_device *dev,
  104. void *additional_info);
  105. void rndis_filter_device_remove(struct hv_device *dev);
  106. int rndis_filter_receive(struct hv_device *dev,
  107. struct hv_netvsc_packet *pkt);
  108. int rndis_filter_send(struct hv_device *dev,
  109. struct hv_netvsc_packet *pkt);
  110. int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter);
  111. #define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF)
  112. #define NVSP_PROTOCOL_VERSION_1 2
  113. #define NVSP_PROTOCOL_VERSION_2 0x30002
  114. enum {
  115. NVSP_MSG_TYPE_NONE = 0,
  116. /* Init Messages */
  117. NVSP_MSG_TYPE_INIT = 1,
  118. NVSP_MSG_TYPE_INIT_COMPLETE = 2,
  119. NVSP_VERSION_MSG_START = 100,
  120. /* Version 1 Messages */
  121. NVSP_MSG1_TYPE_SEND_NDIS_VER = NVSP_VERSION_MSG_START,
  122. NVSP_MSG1_TYPE_SEND_RECV_BUF,
  123. NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE,
  124. NVSP_MSG1_TYPE_REVOKE_RECV_BUF,
  125. NVSP_MSG1_TYPE_SEND_SEND_BUF,
  126. NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE,
  127. NVSP_MSG1_TYPE_REVOKE_SEND_BUF,
  128. NVSP_MSG1_TYPE_SEND_RNDIS_PKT,
  129. NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE,
  130. /* Version 2 messages */
  131. NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF,
  132. NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF_COMP,
  133. NVSP_MSG2_TYPE_REVOKE_CHIMNEY_DELEGATED_BUF,
  134. NVSP_MSG2_TYPE_RESUME_CHIMNEY_RX_INDICATION,
  135. NVSP_MSG2_TYPE_TERMINATE_CHIMNEY,
  136. NVSP_MSG2_TYPE_TERMINATE_CHIMNEY_COMP,
  137. NVSP_MSG2_TYPE_INDICATE_CHIMNEY_EVENT,
  138. NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT,
  139. NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT_COMP,
  140. NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ,
  141. NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ_COMP,
  142. NVSP_MSG2_TYPE_ALLOC_RXBUF,
  143. NVSP_MSG2_TYPE_ALLOC_RXBUF_COMP,
  144. NVSP_MSG2_TYPE_FREE_RXBUF,
  145. NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT,
  146. NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT_COMP,
  147. NVSP_MSG2_TYPE_SEND_NDIS_CONFIG,
  148. NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE,
  149. NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
  150. };
  151. enum {
  152. NVSP_STAT_NONE = 0,
  153. NVSP_STAT_SUCCESS,
  154. NVSP_STAT_FAIL,
  155. NVSP_STAT_PROTOCOL_TOO_NEW,
  156. NVSP_STAT_PROTOCOL_TOO_OLD,
  157. NVSP_STAT_INVALID_RNDIS_PKT,
  158. NVSP_STAT_BUSY,
  159. NVSP_STAT_PROTOCOL_UNSUPPORTED,
  160. NVSP_STAT_MAX,
  161. };
  162. struct nvsp_message_header {
  163. u32 msg_type;
  164. };
  165. /* Init Messages */
  166. /*
  167. * This message is used by the VSC to initialize the channel after the channels
  168. * has been opened. This message should never include anything other then
  169. * versioning (i.e. this message will be the same for ever).
  170. */
  171. struct nvsp_message_init {
  172. u32 min_protocol_ver;
  173. u32 max_protocol_ver;
  174. } __packed;
  175. /*
  176. * This message is used by the VSP to complete the initialization of the
  177. * channel. This message should never include anything other then versioning
  178. * (i.e. this message will be the same for ever).
  179. */
  180. struct nvsp_message_init_complete {
  181. u32 negotiated_protocol_ver;
  182. u32 max_mdl_chain_len;
  183. u32 status;
  184. } __packed;
  185. union nvsp_message_init_uber {
  186. struct nvsp_message_init init;
  187. struct nvsp_message_init_complete init_complete;
  188. } __packed;
  189. /* Version 1 Messages */
  190. /*
  191. * This message is used by the VSC to send the NDIS version to the VSP. The VSP
  192. * can use this information when handling OIDs sent by the VSC.
  193. */
  194. struct nvsp_1_message_send_ndis_version {
  195. u32 ndis_major_ver;
  196. u32 ndis_minor_ver;
  197. } __packed;
  198. /*
  199. * This message is used by the VSC to send a receive buffer to the VSP. The VSP
  200. * can then use the receive buffer to send data to the VSC.
  201. */
  202. struct nvsp_1_message_send_receive_buffer {
  203. u32 gpadl_handle;
  204. u16 id;
  205. } __packed;
  206. struct nvsp_1_receive_buffer_section {
  207. u32 offset;
  208. u32 sub_alloc_size;
  209. u32 num_sub_allocs;
  210. u32 end_offset;
  211. } __packed;
  212. /*
  213. * This message is used by the VSP to acknowledge a receive buffer send by the
  214. * VSC. This message must be sent by the VSP before the VSP uses the receive
  215. * buffer.
  216. */
  217. struct nvsp_1_message_send_receive_buffer_complete {
  218. u32 status;
  219. u32 num_sections;
  220. /*
  221. * The receive buffer is split into two parts, a large suballocation
  222. * section and a small suballocation section. These sections are then
  223. * suballocated by a certain size.
  224. */
  225. /*
  226. * For example, the following break up of the receive buffer has 6
  227. * large suballocations and 10 small suballocations.
  228. */
  229. /*
  230. * | Large Section | | Small Section |
  231. * ------------------------------------------------------------
  232. * | | | | | | | | | | | | | | | | | |
  233. * | |
  234. * LargeOffset SmallOffset
  235. */
  236. struct nvsp_1_receive_buffer_section sections[1];
  237. } __packed;
  238. /*
  239. * This message is sent by the VSC to revoke the receive buffer. After the VSP
  240. * completes this transaction, the vsp should never use the receive buffer
  241. * again.
  242. */
  243. struct nvsp_1_message_revoke_receive_buffer {
  244. u16 id;
  245. };
  246. /*
  247. * This message is used by the VSC to send a send buffer to the VSP. The VSC
  248. * can then use the send buffer to send data to the VSP.
  249. */
  250. struct nvsp_1_message_send_send_buffer {
  251. u32 gpadl_handle;
  252. u16 id;
  253. } __packed;
  254. /*
  255. * This message is used by the VSP to acknowledge a send buffer sent by the
  256. * VSC. This message must be sent by the VSP before the VSP uses the sent
  257. * buffer.
  258. */
  259. struct nvsp_1_message_send_send_buffer_complete {
  260. u32 status;
  261. /*
  262. * The VSC gets to choose the size of the send buffer and the VSP gets
  263. * to choose the sections size of the buffer. This was done to enable
  264. * dynamic reconfigurations when the cost of GPA-direct buffers
  265. * decreases.
  266. */
  267. u32 section_size;
  268. } __packed;
  269. /*
  270. * This message is sent by the VSC to revoke the send buffer. After the VSP
  271. * completes this transaction, the vsp should never use the send buffer again.
  272. */
  273. struct nvsp_1_message_revoke_send_buffer {
  274. u16 id;
  275. };
  276. /*
  277. * This message is used by both the VSP and the VSC to send a RNDIS message to
  278. * the opposite channel endpoint.
  279. */
  280. struct nvsp_1_message_send_rndis_packet {
  281. /*
  282. * This field is specified by RNIDS. They assume there's two different
  283. * channels of communication. However, the Network VSP only has one.
  284. * Therefore, the channel travels with the RNDIS packet.
  285. */
  286. u32 channel_type;
  287. /*
  288. * This field is used to send part or all of the data through a send
  289. * buffer. This values specifies an index into the send buffer. If the
  290. * index is 0xFFFFFFFF, then the send buffer is not being used and all
  291. * of the data was sent through other VMBus mechanisms.
  292. */
  293. u32 send_buf_section_index;
  294. u32 send_buf_section_size;
  295. } __packed;
  296. /*
  297. * This message is used by both the VSP and the VSC to complete a RNDIS message
  298. * to the opposite channel endpoint. At this point, the initiator of this
  299. * message cannot use any resources associated with the original RNDIS packet.
  300. */
  301. struct nvsp_1_message_send_rndis_packet_complete {
  302. u32 status;
  303. };
  304. union nvsp_1_message_uber {
  305. struct nvsp_1_message_send_ndis_version send_ndis_ver;
  306. struct nvsp_1_message_send_receive_buffer send_recv_buf;
  307. struct nvsp_1_message_send_receive_buffer_complete
  308. send_recv_buf_complete;
  309. struct nvsp_1_message_revoke_receive_buffer revoke_recv_buf;
  310. struct nvsp_1_message_send_send_buffer send_send_buf;
  311. struct nvsp_1_message_send_send_buffer_complete send_send_buf_complete;
  312. struct nvsp_1_message_revoke_send_buffer revoke_send_buf;
  313. struct nvsp_1_message_send_rndis_packet send_rndis_pkt;
  314. struct nvsp_1_message_send_rndis_packet_complete
  315. send_rndis_pkt_complete;
  316. } __packed;
  317. /*
  318. * Network VSP protocol version 2 messages:
  319. */
  320. struct nvsp_2_vsc_capability {
  321. union {
  322. u64 data;
  323. struct {
  324. u64 vmq:1;
  325. u64 chimney:1;
  326. u64 sriov:1;
  327. u64 ieee8021q:1;
  328. u64 correlation_id:1;
  329. };
  330. };
  331. } __packed;
  332. struct nvsp_2_send_ndis_config {
  333. u32 mtu;
  334. u32 reserved;
  335. struct nvsp_2_vsc_capability capability;
  336. } __packed;
  337. /* Allocate receive buffer */
  338. struct nvsp_2_alloc_rxbuf {
  339. /* Allocation ID to match the allocation request and response */
  340. u32 alloc_id;
  341. /* Length of the VM shared memory receive buffer that needs to
  342. * be allocated
  343. */
  344. u32 len;
  345. } __packed;
  346. /* Allocate receive buffer complete */
  347. struct nvsp_2_alloc_rxbuf_comp {
  348. /* The NDIS_STATUS code for buffer allocation */
  349. u32 status;
  350. u32 alloc_id;
  351. /* GPADL handle for the allocated receive buffer */
  352. u32 gpadl_handle;
  353. /* Receive buffer ID */
  354. u64 recv_buf_id;
  355. } __packed;
  356. struct nvsp_2_free_rxbuf {
  357. u64 recv_buf_id;
  358. } __packed;
  359. union nvsp_2_message_uber {
  360. struct nvsp_2_send_ndis_config send_ndis_config;
  361. struct nvsp_2_alloc_rxbuf alloc_rxbuf;
  362. struct nvsp_2_alloc_rxbuf_comp alloc_rxbuf_comp;
  363. struct nvsp_2_free_rxbuf free_rxbuf;
  364. } __packed;
  365. union nvsp_all_messages {
  366. union nvsp_message_init_uber init_msg;
  367. union nvsp_1_message_uber v1_msg;
  368. union nvsp_2_message_uber v2_msg;
  369. } __packed;
  370. /* ALL Messages */
  371. struct nvsp_message {
  372. struct nvsp_message_header hdr;
  373. union nvsp_all_messages msg;
  374. } __packed;
  375. #define NETVSC_MTU 65536
  376. #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*2) /* 2MB */
  377. #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
  378. #define NETVSC_RECEIVE_SG_COUNT 1
  379. /* Preallocated receive packets */
  380. #define NETVSC_RECEIVE_PACKETLIST_COUNT 256
  381. #define NETVSC_PACKET_SIZE 2048
  382. /* Per netvsc channel-specific */
  383. struct netvsc_device {
  384. struct hv_device *dev;
  385. u32 nvsp_version;
  386. atomic_t num_outstanding_sends;
  387. bool start_remove;
  388. bool destroy;
  389. /*
  390. * List of free preallocated hv_netvsc_packet to represent receive
  391. * packet
  392. */
  393. struct list_head recv_pkt_list;
  394. spinlock_t recv_pkt_list_lock;
  395. /* Receive buffer allocated by us but manages by NetVSP */
  396. void *recv_buf;
  397. u32 recv_buf_size;
  398. u32 recv_buf_gpadl_handle;
  399. u32 recv_section_cnt;
  400. struct nvsp_1_receive_buffer_section *recv_section;
  401. /* Used for NetVSP initialization protocol */
  402. struct completion channel_init_wait;
  403. struct nvsp_message channel_init_pkt;
  404. struct nvsp_message revoke_packet;
  405. /* unsigned char HwMacAddr[HW_MACADDR_LEN]; */
  406. struct net_device *ndev;
  407. /* Holds rndis device info */
  408. void *extension;
  409. };
  410. /* NdisInitialize message */
  411. struct rndis_initialize_request {
  412. u32 req_id;
  413. u32 major_ver;
  414. u32 minor_ver;
  415. u32 max_xfer_size;
  416. };
  417. /* Response to NdisInitialize */
  418. struct rndis_initialize_complete {
  419. u32 req_id;
  420. u32 status;
  421. u32 major_ver;
  422. u32 minor_ver;
  423. u32 dev_flags;
  424. u32 medium;
  425. u32 max_pkt_per_msg;
  426. u32 max_xfer_size;
  427. u32 pkt_alignment_factor;
  428. u32 af_list_offset;
  429. u32 af_list_size;
  430. };
  431. /* Call manager devices only: Information about an address family */
  432. /* supported by the device is appended to the response to NdisInitialize. */
  433. struct rndis_co_address_family {
  434. u32 address_family;
  435. u32 major_ver;
  436. u32 minor_ver;
  437. };
  438. /* NdisHalt message */
  439. struct rndis_halt_request {
  440. u32 req_id;
  441. };
  442. /* NdisQueryRequest message */
  443. struct rndis_query_request {
  444. u32 req_id;
  445. u32 oid;
  446. u32 info_buflen;
  447. u32 info_buf_offset;
  448. u32 dev_vc_handle;
  449. };
  450. /* Response to NdisQueryRequest */
  451. struct rndis_query_complete {
  452. u32 req_id;
  453. u32 status;
  454. u32 info_buflen;
  455. u32 info_buf_offset;
  456. };
  457. /* NdisSetRequest message */
  458. struct rndis_set_request {
  459. u32 req_id;
  460. u32 oid;
  461. u32 info_buflen;
  462. u32 info_buf_offset;
  463. u32 dev_vc_handle;
  464. };
  465. /* Response to NdisSetRequest */
  466. struct rndis_set_complete {
  467. u32 req_id;
  468. u32 status;
  469. };
  470. /* NdisReset message */
  471. struct rndis_reset_request {
  472. u32 reserved;
  473. };
  474. /* Response to NdisReset */
  475. struct rndis_reset_complete {
  476. u32 status;
  477. u32 addressing_reset;
  478. };
  479. /* NdisMIndicateStatus message */
  480. struct rndis_indicate_status {
  481. u32 status;
  482. u32 status_buflen;
  483. u32 status_buf_offset;
  484. };
  485. /* Diagnostic information passed as the status buffer in */
  486. /* struct rndis_indicate_status messages signifying error conditions. */
  487. struct rndis_diagnostic_info {
  488. u32 diag_status;
  489. u32 error_offset;
  490. };
  491. /* NdisKeepAlive message */
  492. struct rndis_keepalive_request {
  493. u32 req_id;
  494. };
  495. /* Response to NdisKeepAlive */
  496. struct rndis_keepalive_complete {
  497. u32 req_id;
  498. u32 status;
  499. };
  500. /*
  501. * Data message. All Offset fields contain byte offsets from the beginning of
  502. * struct rndis_packet. All Length fields are in bytes. VcHandle is set
  503. * to 0 for connectionless data, otherwise it contains the VC handle.
  504. */
  505. struct rndis_packet {
  506. u32 data_offset;
  507. u32 data_len;
  508. u32 oob_data_offset;
  509. u32 oob_data_len;
  510. u32 num_oob_data_elements;
  511. u32 per_pkt_info_offset;
  512. u32 per_pkt_info_len;
  513. u32 vc_handle;
  514. u32 reserved;
  515. };
  516. /* Optional Out of Band data associated with a Data message. */
  517. struct rndis_oobd {
  518. u32 size;
  519. u32 type;
  520. u32 class_info_offset;
  521. };
  522. /* Packet extension field contents associated with a Data message. */
  523. struct rndis_per_packet_info {
  524. u32 size;
  525. u32 type;
  526. u32 ppi_offset;
  527. };
  528. enum ndis_per_pkt_info_type {
  529. TCPIP_CHKSUM_PKTINFO,
  530. IPSEC_PKTINFO,
  531. TCP_LARGESEND_PKTINFO,
  532. CLASSIFICATION_HANDLE_PKTINFO,
  533. NDIS_RESERVED,
  534. SG_LIST_PKTINFO,
  535. IEEE_8021Q_INFO,
  536. ORIGINAL_PKTINFO,
  537. PACKET_CANCEL_ID,
  538. ORIGINAL_NET_BUFLIST,
  539. CACHED_NET_BUFLIST,
  540. SHORT_PKT_PADINFO,
  541. MAX_PER_PKT_INFO
  542. };
  543. struct ndis_pkt_8021q_info {
  544. union {
  545. struct {
  546. u32 pri:3; /* User Priority */
  547. u32 cfi:1; /* Canonical Format ID */
  548. u32 vlanid:12; /* VLAN ID */
  549. u32 reserved:16;
  550. };
  551. u32 value;
  552. };
  553. };
  554. #define NDIS_VLAN_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  555. sizeof(struct ndis_pkt_8021q_info))
  556. /* Format of Information buffer passed in a SetRequest for the OID */
  557. /* OID_GEN_RNDIS_CONFIG_PARAMETER. */
  558. struct rndis_config_parameter_info {
  559. u32 parameter_name_offset;
  560. u32 parameter_name_length;
  561. u32 parameter_type;
  562. u32 parameter_value_offset;
  563. u32 parameter_value_length;
  564. };
  565. /* Values for ParameterType in struct rndis_config_parameter_info */
  566. #define RNDIS_CONFIG_PARAM_TYPE_INTEGER 0
  567. #define RNDIS_CONFIG_PARAM_TYPE_STRING 2
  568. /* CONDIS Miniport messages for connection oriented devices */
  569. /* that do not implement a call manager. */
  570. /* CoNdisMiniportCreateVc message */
  571. struct rcondis_mp_create_vc {
  572. u32 req_id;
  573. u32 ndis_vc_handle;
  574. };
  575. /* Response to CoNdisMiniportCreateVc */
  576. struct rcondis_mp_create_vc_complete {
  577. u32 req_id;
  578. u32 dev_vc_handle;
  579. u32 status;
  580. };
  581. /* CoNdisMiniportDeleteVc message */
  582. struct rcondis_mp_delete_vc {
  583. u32 req_id;
  584. u32 dev_vc_handle;
  585. };
  586. /* Response to CoNdisMiniportDeleteVc */
  587. struct rcondis_mp_delete_vc_complete {
  588. u32 req_id;
  589. u32 status;
  590. };
  591. /* CoNdisMiniportQueryRequest message */
  592. struct rcondis_mp_query_request {
  593. u32 req_id;
  594. u32 request_type;
  595. u32 oid;
  596. u32 dev_vc_handle;
  597. u32 info_buflen;
  598. u32 info_buf_offset;
  599. };
  600. /* CoNdisMiniportSetRequest message */
  601. struct rcondis_mp_set_request {
  602. u32 req_id;
  603. u32 request_type;
  604. u32 oid;
  605. u32 dev_vc_handle;
  606. u32 info_buflen;
  607. u32 info_buf_offset;
  608. };
  609. /* CoNdisIndicateStatus message */
  610. struct rcondis_indicate_status {
  611. u32 ndis_vc_handle;
  612. u32 status;
  613. u32 status_buflen;
  614. u32 status_buf_offset;
  615. };
  616. /* CONDIS Call/VC parameters */
  617. struct rcondis_specific_parameters {
  618. u32 parameter_type;
  619. u32 parameter_length;
  620. u32 parameter_lffset;
  621. };
  622. struct rcondis_media_parameters {
  623. u32 flags;
  624. u32 reserved1;
  625. u32 reserved2;
  626. struct rcondis_specific_parameters media_specific;
  627. };
  628. struct rndis_flowspec {
  629. u32 token_rate;
  630. u32 token_bucket_size;
  631. u32 peak_bandwidth;
  632. u32 latency;
  633. u32 delay_variation;
  634. u32 service_type;
  635. u32 max_sdu_size;
  636. u32 minimum_policed_size;
  637. };
  638. struct rcondis_call_manager_parameters {
  639. struct rndis_flowspec transmit;
  640. struct rndis_flowspec receive;
  641. struct rcondis_specific_parameters call_mgr_specific;
  642. };
  643. /* CoNdisMiniportActivateVc message */
  644. struct rcondis_mp_activate_vc_request {
  645. u32 req_id;
  646. u32 flags;
  647. u32 dev_vc_handle;
  648. u32 media_params_offset;
  649. u32 media_params_length;
  650. u32 call_mgr_params_offset;
  651. u32 call_mgr_params_length;
  652. };
  653. /* Response to CoNdisMiniportActivateVc */
  654. struct rcondis_mp_activate_vc_complete {
  655. u32 req_id;
  656. u32 status;
  657. };
  658. /* CoNdisMiniportDeactivateVc message */
  659. struct rcondis_mp_deactivate_vc_request {
  660. u32 req_id;
  661. u32 flags;
  662. u32 dev_vc_handle;
  663. };
  664. /* Response to CoNdisMiniportDeactivateVc */
  665. struct rcondis_mp_deactivate_vc_complete {
  666. u32 req_id;
  667. u32 status;
  668. };
  669. /* union with all of the RNDIS messages */
  670. union rndis_message_container {
  671. struct rndis_packet pkt;
  672. struct rndis_initialize_request init_req;
  673. struct rndis_halt_request halt_req;
  674. struct rndis_query_request query_req;
  675. struct rndis_set_request set_req;
  676. struct rndis_reset_request reset_req;
  677. struct rndis_keepalive_request keep_alive_req;
  678. struct rndis_indicate_status indicate_status;
  679. struct rndis_initialize_complete init_complete;
  680. struct rndis_query_complete query_complete;
  681. struct rndis_set_complete set_complete;
  682. struct rndis_reset_complete reset_complete;
  683. struct rndis_keepalive_complete keep_alive_complete;
  684. struct rcondis_mp_create_vc co_miniport_create_vc;
  685. struct rcondis_mp_delete_vc co_miniport_delete_vc;
  686. struct rcondis_indicate_status co_indicate_status;
  687. struct rcondis_mp_activate_vc_request co_miniport_activate_vc;
  688. struct rcondis_mp_deactivate_vc_request co_miniport_deactivate_vc;
  689. struct rcondis_mp_create_vc_complete co_miniport_create_vc_complete;
  690. struct rcondis_mp_delete_vc_complete co_miniport_delete_vc_complete;
  691. struct rcondis_mp_activate_vc_complete co_miniport_activate_vc_complete;
  692. struct rcondis_mp_deactivate_vc_complete
  693. co_miniport_deactivate_vc_complete;
  694. };
  695. /* Remote NDIS message format */
  696. struct rndis_message {
  697. u32 ndis_msg_type;
  698. /* Total length of this message, from the beginning */
  699. /* of the sruct rndis_message, in bytes. */
  700. u32 msg_len;
  701. /* Actual message */
  702. union rndis_message_container msg;
  703. };
  704. struct rndis_filter_packet {
  705. void *completion_ctx;
  706. void (*completion)(void *context);
  707. struct rndis_message msg;
  708. };
  709. /* Handy macros */
  710. /* get the size of an RNDIS message. Pass in the message type, */
  711. /* struct rndis_set_request, struct rndis_packet for example */
  712. #define RNDIS_MESSAGE_SIZE(msg) \
  713. (sizeof(msg) + (sizeof(struct rndis_message) - \
  714. sizeof(union rndis_message_container)))
  715. /* get pointer to info buffer with message pointer */
  716. #define MESSAGE_TO_INFO_BUFFER(msg) \
  717. (((unsigned char *)(msg)) + msg->info_buf_offset)
  718. /* get pointer to status buffer with message pointer */
  719. #define MESSAGE_TO_STATUS_BUFFER(msg) \
  720. (((unsigned char *)(msg)) + msg->status_buf_offset)
  721. /* get pointer to OOBD buffer with message pointer */
  722. #define MESSAGE_TO_OOBD_BUFFER(msg) \
  723. (((unsigned char *)(msg)) + msg->oob_data_offset)
  724. /* get pointer to data buffer with message pointer */
  725. #define MESSAGE_TO_DATA_BUFFER(msg) \
  726. (((unsigned char *)(msg)) + msg->per_pkt_info_offset)
  727. /* get pointer to contained message from NDIS_MESSAGE pointer */
  728. #define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_msg) \
  729. ((void *) &rndis_msg->msg)
  730. /* get pointer to contained message from NDIS_MESSAGE pointer */
  731. #define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_msg) \
  732. ((void *) rndis_msg)
  733. #define __struct_bcount(x)
  734. #define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \
  735. sizeof(union rndis_message_container))
  736. #define NDIS_PACKET_TYPE_DIRECTED 0x00000001
  737. #define NDIS_PACKET_TYPE_MULTICAST 0x00000002
  738. #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
  739. #define NDIS_PACKET_TYPE_BROADCAST 0x00000008
  740. #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
  741. #define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
  742. #define NDIS_PACKET_TYPE_SMT 0x00000040
  743. #define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
  744. #define NDIS_PACKET_TYPE_GROUP 0x00000100
  745. #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
  746. #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
  747. #define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
  748. #endif /* _HYPERV_NET_H */