hyperv_net.h 22 KB

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