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