hyperv_net.h 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478
  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. /* RSS related */
  29. #define OID_GEN_RECEIVE_SCALE_CAPABILITIES 0x00010203 /* query only */
  30. #define OID_GEN_RECEIVE_SCALE_PARAMETERS 0x00010204 /* query and set */
  31. #define NDIS_OBJECT_TYPE_RSS_CAPABILITIES 0x88
  32. #define NDIS_OBJECT_TYPE_RSS_PARAMETERS 0x89
  33. #define NDIS_OBJECT_TYPE_OFFLOAD 0xa7
  34. #define NDIS_RECEIVE_SCALE_CAPABILITIES_REVISION_2 2
  35. #define NDIS_RECEIVE_SCALE_PARAMETERS_REVISION_2 2
  36. struct ndis_obj_header {
  37. u8 type;
  38. u8 rev;
  39. u16 size;
  40. } __packed;
  41. /* ndis_recv_scale_cap/cap_flag */
  42. #define NDIS_RSS_CAPS_MESSAGE_SIGNALED_INTERRUPTS 0x01000000
  43. #define NDIS_RSS_CAPS_CLASSIFICATION_AT_ISR 0x02000000
  44. #define NDIS_RSS_CAPS_CLASSIFICATION_AT_DPC 0x04000000
  45. #define NDIS_RSS_CAPS_USING_MSI_X 0x08000000
  46. #define NDIS_RSS_CAPS_RSS_AVAILABLE_ON_PORTS 0x10000000
  47. #define NDIS_RSS_CAPS_SUPPORTS_MSI_X 0x20000000
  48. #define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV4 0x00000100
  49. #define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6 0x00000200
  50. #define NDIS_RSS_CAPS_HASH_TYPE_TCP_IPV6_EX 0x00000400
  51. struct ndis_recv_scale_cap { /* NDIS_RECEIVE_SCALE_CAPABILITIES */
  52. struct ndis_obj_header hdr;
  53. u32 cap_flag;
  54. u32 num_int_msg;
  55. u32 num_recv_que;
  56. u16 num_indirect_tabent;
  57. } __packed;
  58. /* ndis_recv_scale_param flags */
  59. #define NDIS_RSS_PARAM_FLAG_BASE_CPU_UNCHANGED 0x0001
  60. #define NDIS_RSS_PARAM_FLAG_HASH_INFO_UNCHANGED 0x0002
  61. #define NDIS_RSS_PARAM_FLAG_ITABLE_UNCHANGED 0x0004
  62. #define NDIS_RSS_PARAM_FLAG_HASH_KEY_UNCHANGED 0x0008
  63. #define NDIS_RSS_PARAM_FLAG_DISABLE_RSS 0x0010
  64. /* Hash info bits */
  65. #define NDIS_HASH_FUNC_TOEPLITZ 0x00000001
  66. #define NDIS_HASH_IPV4 0x00000100
  67. #define NDIS_HASH_TCP_IPV4 0x00000200
  68. #define NDIS_HASH_IPV6 0x00000400
  69. #define NDIS_HASH_IPV6_EX 0x00000800
  70. #define NDIS_HASH_TCP_IPV6 0x00001000
  71. #define NDIS_HASH_TCP_IPV6_EX 0x00002000
  72. #define NDIS_RSS_INDIRECTION_TABLE_MAX_SIZE_REVISION_2 (128 * 4)
  73. #define NDIS_RSS_HASH_SECRET_KEY_MAX_SIZE_REVISION_2 40
  74. #define ITAB_NUM 128
  75. struct ndis_recv_scale_param { /* NDIS_RECEIVE_SCALE_PARAMETERS */
  76. struct ndis_obj_header hdr;
  77. /* Qualifies the rest of the information */
  78. u16 flag;
  79. /* The base CPU number to do receive processing. not used */
  80. u16 base_cpu_number;
  81. /* This describes the hash function and type being enabled */
  82. u32 hashinfo;
  83. /* The size of indirection table array */
  84. u16 indirect_tabsize;
  85. /* The offset of the indirection table from the beginning of this
  86. * structure
  87. */
  88. u32 indirect_taboffset;
  89. /* The size of the hash secret key */
  90. u16 hashkey_size;
  91. /* The offset of the secret key from the beginning of this structure */
  92. u32 kashkey_offset;
  93. u32 processor_masks_offset;
  94. u32 num_processor_masks;
  95. u32 processor_masks_entry_size;
  96. };
  97. /* Fwd declaration */
  98. struct ndis_tcp_ip_checksum_info;
  99. struct ndis_pkt_8021q_info;
  100. /*
  101. * Represent netvsc packet which contains 1 RNDIS and 1 ethernet frame
  102. * within the RNDIS
  103. *
  104. * The size of this structure is less than 48 bytes and we can now
  105. * place this structure in the skb->cb field.
  106. */
  107. struct hv_netvsc_packet {
  108. /* Bookkeeping stuff */
  109. u8 cp_partial; /* partial copy into send buffer */
  110. u8 rmsg_size; /* RNDIS header and PPI size */
  111. u8 rmsg_pgcnt; /* page count of RNDIS header and PPI */
  112. u8 page_buf_cnt;
  113. u16 q_idx;
  114. u16 total_packets;
  115. u32 total_bytes;
  116. u32 send_buf_index;
  117. u32 total_data_buflen;
  118. };
  119. struct netvsc_device_info {
  120. unsigned char mac_adr[ETH_ALEN];
  121. int ring_size;
  122. u32 num_chn;
  123. u32 send_sections;
  124. u32 recv_sections;
  125. u32 send_section_size;
  126. u32 recv_section_size;
  127. };
  128. enum rndis_device_state {
  129. RNDIS_DEV_UNINITIALIZED = 0,
  130. RNDIS_DEV_INITIALIZING,
  131. RNDIS_DEV_INITIALIZED,
  132. RNDIS_DEV_DATAINITIALIZED,
  133. };
  134. #define NETVSC_HASH_KEYLEN 40
  135. struct rndis_device {
  136. struct net_device *ndev;
  137. enum rndis_device_state state;
  138. atomic_t new_req_id;
  139. spinlock_t request_lock;
  140. struct list_head req_list;
  141. struct work_struct mcast_work;
  142. bool link_state; /* 0 - link up, 1 - link down */
  143. u8 hw_mac_adr[ETH_ALEN];
  144. u8 rss_key[NETVSC_HASH_KEYLEN];
  145. u16 rx_table[ITAB_NUM];
  146. };
  147. /* Interface */
  148. struct rndis_message;
  149. struct netvsc_device;
  150. struct net_device_context;
  151. struct netvsc_device *netvsc_device_add(struct hv_device *device,
  152. const struct netvsc_device_info *info);
  153. int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx);
  154. void netvsc_device_remove(struct hv_device *device);
  155. int netvsc_send(struct net_device_context *ndc,
  156. struct hv_netvsc_packet *packet,
  157. struct rndis_message *rndis_msg,
  158. struct hv_page_buffer *page_buffer,
  159. struct sk_buff *skb);
  160. void netvsc_linkstatus_callback(struct hv_device *device_obj,
  161. struct rndis_message *resp);
  162. int netvsc_recv_callback(struct net_device *net,
  163. struct vmbus_channel *channel,
  164. void *data, u32 len,
  165. const struct ndis_tcp_ip_checksum_info *csum_info,
  166. const struct ndis_pkt_8021q_info *vlan);
  167. void netvsc_channel_cb(void *context);
  168. int netvsc_poll(struct napi_struct *napi, int budget);
  169. void rndis_set_subchannel(struct work_struct *w);
  170. bool rndis_filter_opened(const struct netvsc_device *nvdev);
  171. int rndis_filter_open(struct netvsc_device *nvdev);
  172. int rndis_filter_close(struct netvsc_device *nvdev);
  173. struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
  174. struct netvsc_device_info *info);
  175. void rndis_filter_update(struct netvsc_device *nvdev);
  176. void rndis_filter_device_remove(struct hv_device *dev,
  177. struct netvsc_device *nvdev);
  178. int rndis_filter_set_rss_param(struct rndis_device *rdev,
  179. const u8 *key);
  180. int rndis_filter_receive(struct net_device *ndev,
  181. struct netvsc_device *net_dev,
  182. struct hv_device *dev,
  183. struct vmbus_channel *channel,
  184. void *data, u32 buflen);
  185. int rndis_filter_set_device_mac(struct netvsc_device *ndev,
  186. const char *mac);
  187. void netvsc_switch_datapath(struct net_device *nv_dev, bool vf);
  188. #define NVSP_INVALID_PROTOCOL_VERSION ((u32)0xFFFFFFFF)
  189. #define NVSP_PROTOCOL_VERSION_1 2
  190. #define NVSP_PROTOCOL_VERSION_2 0x30002
  191. #define NVSP_PROTOCOL_VERSION_4 0x40000
  192. #define NVSP_PROTOCOL_VERSION_5 0x50000
  193. enum {
  194. NVSP_MSG_TYPE_NONE = 0,
  195. /* Init Messages */
  196. NVSP_MSG_TYPE_INIT = 1,
  197. NVSP_MSG_TYPE_INIT_COMPLETE = 2,
  198. NVSP_VERSION_MSG_START = 100,
  199. /* Version 1 Messages */
  200. NVSP_MSG1_TYPE_SEND_NDIS_VER = NVSP_VERSION_MSG_START,
  201. NVSP_MSG1_TYPE_SEND_RECV_BUF,
  202. NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE,
  203. NVSP_MSG1_TYPE_REVOKE_RECV_BUF,
  204. NVSP_MSG1_TYPE_SEND_SEND_BUF,
  205. NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE,
  206. NVSP_MSG1_TYPE_REVOKE_SEND_BUF,
  207. NVSP_MSG1_TYPE_SEND_RNDIS_PKT,
  208. NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE,
  209. /* Version 2 messages */
  210. NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF,
  211. NVSP_MSG2_TYPE_SEND_CHIMNEY_DELEGATED_BUF_COMP,
  212. NVSP_MSG2_TYPE_REVOKE_CHIMNEY_DELEGATED_BUF,
  213. NVSP_MSG2_TYPE_RESUME_CHIMNEY_RX_INDICATION,
  214. NVSP_MSG2_TYPE_TERMINATE_CHIMNEY,
  215. NVSP_MSG2_TYPE_TERMINATE_CHIMNEY_COMP,
  216. NVSP_MSG2_TYPE_INDICATE_CHIMNEY_EVENT,
  217. NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT,
  218. NVSP_MSG2_TYPE_SEND_CHIMNEY_PKT_COMP,
  219. NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ,
  220. NVSP_MSG2_TYPE_POST_CHIMNEY_RECV_REQ_COMP,
  221. NVSP_MSG2_TYPE_ALLOC_RXBUF,
  222. NVSP_MSG2_TYPE_ALLOC_RXBUF_COMP,
  223. NVSP_MSG2_TYPE_FREE_RXBUF,
  224. NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT,
  225. NVSP_MSG2_TYPE_SEND_VMQ_RNDIS_PKT_COMP,
  226. NVSP_MSG2_TYPE_SEND_NDIS_CONFIG,
  227. NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE,
  228. NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
  229. NVSP_MSG2_MAX = NVSP_MSG2_TYPE_ALLOC_CHIMNEY_HANDLE_COMP,
  230. /* Version 4 messages */
  231. NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION,
  232. NVSP_MSG4_TYPE_SWITCH_DATA_PATH,
  233. NVSP_MSG4_TYPE_UPLINK_CONNECT_STATE_DEPRECATED,
  234. NVSP_MSG4_MAX = NVSP_MSG4_TYPE_UPLINK_CONNECT_STATE_DEPRECATED,
  235. /* Version 5 messages */
  236. NVSP_MSG5_TYPE_OID_QUERY_EX,
  237. NVSP_MSG5_TYPE_OID_QUERY_EX_COMP,
  238. NVSP_MSG5_TYPE_SUBCHANNEL,
  239. NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
  240. NVSP_MSG5_MAX = NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE,
  241. };
  242. enum {
  243. NVSP_STAT_NONE = 0,
  244. NVSP_STAT_SUCCESS,
  245. NVSP_STAT_FAIL,
  246. NVSP_STAT_PROTOCOL_TOO_NEW,
  247. NVSP_STAT_PROTOCOL_TOO_OLD,
  248. NVSP_STAT_INVALID_RNDIS_PKT,
  249. NVSP_STAT_BUSY,
  250. NVSP_STAT_PROTOCOL_UNSUPPORTED,
  251. NVSP_STAT_MAX,
  252. };
  253. struct nvsp_message_header {
  254. u32 msg_type;
  255. };
  256. /* Init Messages */
  257. /*
  258. * This message is used by the VSC to initialize the channel after the channels
  259. * has been opened. This message should never include anything other then
  260. * versioning (i.e. this message will be the same for ever).
  261. */
  262. struct nvsp_message_init {
  263. u32 min_protocol_ver;
  264. u32 max_protocol_ver;
  265. } __packed;
  266. /*
  267. * This message is used by the VSP to complete the initialization of the
  268. * channel. This message should never include anything other then versioning
  269. * (i.e. this message will be the same for ever).
  270. */
  271. struct nvsp_message_init_complete {
  272. u32 negotiated_protocol_ver;
  273. u32 max_mdl_chain_len;
  274. u32 status;
  275. } __packed;
  276. union nvsp_message_init_uber {
  277. struct nvsp_message_init init;
  278. struct nvsp_message_init_complete init_complete;
  279. } __packed;
  280. /* Version 1 Messages */
  281. /*
  282. * This message is used by the VSC to send the NDIS version to the VSP. The VSP
  283. * can use this information when handling OIDs sent by the VSC.
  284. */
  285. struct nvsp_1_message_send_ndis_version {
  286. u32 ndis_major_ver;
  287. u32 ndis_minor_ver;
  288. } __packed;
  289. /*
  290. * This message is used by the VSC to send a receive buffer to the VSP. The VSP
  291. * can then use the receive buffer to send data to the VSC.
  292. */
  293. struct nvsp_1_message_send_receive_buffer {
  294. u32 gpadl_handle;
  295. u16 id;
  296. } __packed;
  297. struct nvsp_1_receive_buffer_section {
  298. u32 offset;
  299. u32 sub_alloc_size;
  300. u32 num_sub_allocs;
  301. u32 end_offset;
  302. } __packed;
  303. /*
  304. * This message is used by the VSP to acknowledge a receive buffer send by the
  305. * VSC. This message must be sent by the VSP before the VSP uses the receive
  306. * buffer.
  307. */
  308. struct nvsp_1_message_send_receive_buffer_complete {
  309. u32 status;
  310. u32 num_sections;
  311. /*
  312. * The receive buffer is split into two parts, a large suballocation
  313. * section and a small suballocation section. These sections are then
  314. * suballocated by a certain size.
  315. */
  316. /*
  317. * For example, the following break up of the receive buffer has 6
  318. * large suballocations and 10 small suballocations.
  319. */
  320. /*
  321. * | Large Section | | Small Section |
  322. * ------------------------------------------------------------
  323. * | | | | | | | | | | | | | | | | | |
  324. * | |
  325. * LargeOffset SmallOffset
  326. */
  327. struct nvsp_1_receive_buffer_section sections[1];
  328. } __packed;
  329. /*
  330. * This message is sent by the VSC to revoke the receive buffer. After the VSP
  331. * completes this transaction, the vsp should never use the receive buffer
  332. * again.
  333. */
  334. struct nvsp_1_message_revoke_receive_buffer {
  335. u16 id;
  336. };
  337. /*
  338. * This message is used by the VSC to send a send buffer to the VSP. The VSC
  339. * can then use the send buffer to send data to the VSP.
  340. */
  341. struct nvsp_1_message_send_send_buffer {
  342. u32 gpadl_handle;
  343. u16 id;
  344. } __packed;
  345. /*
  346. * This message is used by the VSP to acknowledge a send buffer sent by the
  347. * VSC. This message must be sent by the VSP before the VSP uses the sent
  348. * buffer.
  349. */
  350. struct nvsp_1_message_send_send_buffer_complete {
  351. u32 status;
  352. /*
  353. * The VSC gets to choose the size of the send buffer and the VSP gets
  354. * to choose the sections size of the buffer. This was done to enable
  355. * dynamic reconfigurations when the cost of GPA-direct buffers
  356. * decreases.
  357. */
  358. u32 section_size;
  359. } __packed;
  360. /*
  361. * This message is sent by the VSC to revoke the send buffer. After the VSP
  362. * completes this transaction, the vsp should never use the send buffer again.
  363. */
  364. struct nvsp_1_message_revoke_send_buffer {
  365. u16 id;
  366. };
  367. /*
  368. * This message is used by both the VSP and the VSC to send a RNDIS message to
  369. * the opposite channel endpoint.
  370. */
  371. struct nvsp_1_message_send_rndis_packet {
  372. /*
  373. * This field is specified by RNDIS. They assume there's two different
  374. * channels of communication. However, the Network VSP only has one.
  375. * Therefore, the channel travels with the RNDIS packet.
  376. */
  377. u32 channel_type;
  378. /*
  379. * This field is used to send part or all of the data through a send
  380. * buffer. This values specifies an index into the send buffer. If the
  381. * index is 0xFFFFFFFF, then the send buffer is not being used and all
  382. * of the data was sent through other VMBus mechanisms.
  383. */
  384. u32 send_buf_section_index;
  385. u32 send_buf_section_size;
  386. } __packed;
  387. /*
  388. * This message is used by both the VSP and the VSC to complete a RNDIS message
  389. * to the opposite channel endpoint. At this point, the initiator of this
  390. * message cannot use any resources associated with the original RNDIS packet.
  391. */
  392. struct nvsp_1_message_send_rndis_packet_complete {
  393. u32 status;
  394. };
  395. union nvsp_1_message_uber {
  396. struct nvsp_1_message_send_ndis_version send_ndis_ver;
  397. struct nvsp_1_message_send_receive_buffer send_recv_buf;
  398. struct nvsp_1_message_send_receive_buffer_complete
  399. send_recv_buf_complete;
  400. struct nvsp_1_message_revoke_receive_buffer revoke_recv_buf;
  401. struct nvsp_1_message_send_send_buffer send_send_buf;
  402. struct nvsp_1_message_send_send_buffer_complete send_send_buf_complete;
  403. struct nvsp_1_message_revoke_send_buffer revoke_send_buf;
  404. struct nvsp_1_message_send_rndis_packet send_rndis_pkt;
  405. struct nvsp_1_message_send_rndis_packet_complete
  406. send_rndis_pkt_complete;
  407. } __packed;
  408. /*
  409. * Network VSP protocol version 2 messages:
  410. */
  411. struct nvsp_2_vsc_capability {
  412. union {
  413. u64 data;
  414. struct {
  415. u64 vmq:1;
  416. u64 chimney:1;
  417. u64 sriov:1;
  418. u64 ieee8021q:1;
  419. u64 correlation_id:1;
  420. u64 teaming:1;
  421. };
  422. };
  423. } __packed;
  424. struct nvsp_2_send_ndis_config {
  425. u32 mtu;
  426. u32 reserved;
  427. struct nvsp_2_vsc_capability capability;
  428. } __packed;
  429. /* Allocate receive buffer */
  430. struct nvsp_2_alloc_rxbuf {
  431. /* Allocation ID to match the allocation request and response */
  432. u32 alloc_id;
  433. /* Length of the VM shared memory receive buffer that needs to
  434. * be allocated
  435. */
  436. u32 len;
  437. } __packed;
  438. /* Allocate receive buffer complete */
  439. struct nvsp_2_alloc_rxbuf_comp {
  440. /* The NDIS_STATUS code for buffer allocation */
  441. u32 status;
  442. u32 alloc_id;
  443. /* GPADL handle for the allocated receive buffer */
  444. u32 gpadl_handle;
  445. /* Receive buffer ID */
  446. u64 recv_buf_id;
  447. } __packed;
  448. struct nvsp_2_free_rxbuf {
  449. u64 recv_buf_id;
  450. } __packed;
  451. union nvsp_2_message_uber {
  452. struct nvsp_2_send_ndis_config send_ndis_config;
  453. struct nvsp_2_alloc_rxbuf alloc_rxbuf;
  454. struct nvsp_2_alloc_rxbuf_comp alloc_rxbuf_comp;
  455. struct nvsp_2_free_rxbuf free_rxbuf;
  456. } __packed;
  457. struct nvsp_4_send_vf_association {
  458. /* 1: allocated, serial number is valid. 0: not allocated */
  459. u32 allocated;
  460. /* Serial number of the VF to team with */
  461. u32 serial;
  462. } __packed;
  463. enum nvsp_vm_datapath {
  464. NVSP_DATAPATH_SYNTHETIC = 0,
  465. NVSP_DATAPATH_VF,
  466. NVSP_DATAPATH_MAX
  467. };
  468. struct nvsp_4_sw_datapath {
  469. u32 active_datapath; /* active data path in VM */
  470. } __packed;
  471. union nvsp_4_message_uber {
  472. struct nvsp_4_send_vf_association vf_assoc;
  473. struct nvsp_4_sw_datapath active_dp;
  474. } __packed;
  475. enum nvsp_subchannel_operation {
  476. NVSP_SUBCHANNEL_NONE = 0,
  477. NVSP_SUBCHANNEL_ALLOCATE,
  478. NVSP_SUBCHANNEL_MAX
  479. };
  480. struct nvsp_5_subchannel_request {
  481. u32 op;
  482. u32 num_subchannels;
  483. } __packed;
  484. struct nvsp_5_subchannel_complete {
  485. u32 status;
  486. u32 num_subchannels; /* Actual number of subchannels allocated */
  487. } __packed;
  488. struct nvsp_5_send_indirect_table {
  489. /* The number of entries in the send indirection table */
  490. u32 count;
  491. /* The offset of the send indirection table from top of this struct.
  492. * The send indirection table tells which channel to put the send
  493. * traffic on. Each entry is a channel number.
  494. */
  495. u32 offset;
  496. } __packed;
  497. union nvsp_5_message_uber {
  498. struct nvsp_5_subchannel_request subchn_req;
  499. struct nvsp_5_subchannel_complete subchn_comp;
  500. struct nvsp_5_send_indirect_table send_table;
  501. } __packed;
  502. union nvsp_all_messages {
  503. union nvsp_message_init_uber init_msg;
  504. union nvsp_1_message_uber v1_msg;
  505. union nvsp_2_message_uber v2_msg;
  506. union nvsp_4_message_uber v4_msg;
  507. union nvsp_5_message_uber v5_msg;
  508. } __packed;
  509. /* ALL Messages */
  510. struct nvsp_message {
  511. struct nvsp_message_header hdr;
  512. union nvsp_all_messages msg;
  513. } __packed;
  514. #define NETVSC_MTU 65535
  515. #define NETVSC_MTU_MIN ETH_MIN_MTU
  516. #define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16) /* 16MB */
  517. #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15) /* 15MB */
  518. #define NETVSC_SEND_BUFFER_SIZE (1024 * 1024 * 15) /* 15MB */
  519. #define NETVSC_INVALID_INDEX -1
  520. #define NETVSC_SEND_SECTION_SIZE 6144
  521. #define NETVSC_RECV_SECTION_SIZE 1728
  522. #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
  523. #define NETVSC_SEND_BUFFER_ID 0
  524. #define NETVSC_SUPPORTED_HW_FEATURES (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | \
  525. NETIF_F_TSO | NETIF_F_IPV6_CSUM | \
  526. NETIF_F_TSO6)
  527. #define VRSS_SEND_TAB_SIZE 16 /* must be power of 2 */
  528. #define VRSS_CHANNEL_MAX 64
  529. #define VRSS_CHANNEL_DEFAULT 8
  530. #define RNDIS_MAX_PKT_DEFAULT 8
  531. #define RNDIS_PKT_ALIGN_DEFAULT 8
  532. struct multi_send_data {
  533. struct sk_buff *skb; /* skb containing the pkt */
  534. struct hv_netvsc_packet *pkt; /* netvsc pkt pending */
  535. u32 count; /* counter of batched packets */
  536. };
  537. struct recv_comp_data {
  538. u64 tid; /* transaction id */
  539. u32 status;
  540. };
  541. struct multi_recv_comp {
  542. struct recv_comp_data *slots;
  543. u32 first; /* first data entry */
  544. u32 next; /* next entry for writing */
  545. };
  546. struct netvsc_stats {
  547. u64 packets;
  548. u64 bytes;
  549. u64 broadcast;
  550. u64 multicast;
  551. struct u64_stats_sync syncp;
  552. };
  553. struct netvsc_ethtool_stats {
  554. unsigned long tx_scattered;
  555. unsigned long tx_no_memory;
  556. unsigned long tx_no_space;
  557. unsigned long tx_too_big;
  558. unsigned long tx_busy;
  559. unsigned long tx_send_full;
  560. unsigned long rx_comp_busy;
  561. unsigned long stop_queue;
  562. unsigned long wake_queue;
  563. };
  564. struct netvsc_vf_pcpu_stats {
  565. u64 rx_packets;
  566. u64 rx_bytes;
  567. u64 tx_packets;
  568. u64 tx_bytes;
  569. struct u64_stats_sync syncp;
  570. u32 tx_dropped;
  571. };
  572. struct netvsc_reconfig {
  573. struct list_head list;
  574. u32 event;
  575. };
  576. /* L4 hash bits for different protocols */
  577. #define HV_TCP4_L4HASH 1
  578. #define HV_TCP6_L4HASH 2
  579. #define HV_UDP4_L4HASH 4
  580. #define HV_UDP6_L4HASH 8
  581. #define HV_DEFAULT_L4HASH (HV_TCP4_L4HASH | HV_TCP6_L4HASH | HV_UDP4_L4HASH | \
  582. HV_UDP6_L4HASH)
  583. /* The context of the netvsc device */
  584. struct net_device_context {
  585. /* point back to our device context */
  586. struct hv_device *device_ctx;
  587. /* netvsc_device */
  588. struct netvsc_device __rcu *nvdev;
  589. /* reconfigure work */
  590. struct delayed_work dwork;
  591. /* last reconfig time */
  592. unsigned long last_reconfig;
  593. /* reconfig events */
  594. struct list_head reconfig_events;
  595. /* list protection */
  596. spinlock_t lock;
  597. u32 msg_enable; /* debug level */
  598. u32 tx_checksum_mask;
  599. u32 tx_table[VRSS_SEND_TAB_SIZE];
  600. /* Ethtool settings */
  601. u8 duplex;
  602. u32 speed;
  603. u32 l4_hash; /* L4 hash settings */
  604. struct netvsc_ethtool_stats eth_stats;
  605. /* State to manage the associated VF interface. */
  606. struct net_device __rcu *vf_netdev;
  607. struct netvsc_vf_pcpu_stats __percpu *vf_stats;
  608. struct delayed_work vf_takeover;
  609. /* 1: allocated, serial number is valid. 0: not allocated */
  610. u32 vf_alloc;
  611. /* Serial number of the VF to team with */
  612. u32 vf_serial;
  613. };
  614. /* Per channel data */
  615. struct netvsc_channel {
  616. struct vmbus_channel *channel;
  617. struct netvsc_device *net_device;
  618. const struct vmpacket_descriptor *desc;
  619. struct napi_struct napi;
  620. struct multi_send_data msd;
  621. struct multi_recv_comp mrc;
  622. atomic_t queue_sends;
  623. struct netvsc_stats tx_stats;
  624. struct netvsc_stats rx_stats;
  625. };
  626. /* Per netvsc device */
  627. struct netvsc_device {
  628. u32 nvsp_version;
  629. wait_queue_head_t wait_drain;
  630. bool destroy;
  631. /* Receive buffer allocated by us but manages by NetVSP */
  632. void *recv_buf;
  633. u32 recv_buf_gpadl_handle;
  634. u32 recv_section_cnt;
  635. u32 recv_section_size;
  636. u32 recv_completion_cnt;
  637. /* Send buffer allocated by us */
  638. void *send_buf;
  639. u32 send_buf_gpadl_handle;
  640. u32 send_section_cnt;
  641. u32 send_section_size;
  642. unsigned long *send_section_map;
  643. /* Used for NetVSP initialization protocol */
  644. struct completion channel_init_wait;
  645. struct nvsp_message channel_init_pkt;
  646. struct nvsp_message revoke_packet;
  647. u32 max_chn;
  648. u32 num_chn;
  649. atomic_t open_chn;
  650. struct work_struct subchan_work;
  651. wait_queue_head_t subchan_open;
  652. struct rndis_device *extension;
  653. int ring_size;
  654. u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
  655. u32 pkt_align; /* alignment bytes, e.g. 8 */
  656. atomic_t open_cnt;
  657. struct netvsc_channel chan_table[VRSS_CHANNEL_MAX];
  658. struct rcu_head rcu;
  659. };
  660. /* NdisInitialize message */
  661. struct rndis_initialize_request {
  662. u32 req_id;
  663. u32 major_ver;
  664. u32 minor_ver;
  665. u32 max_xfer_size;
  666. };
  667. /* Response to NdisInitialize */
  668. struct rndis_initialize_complete {
  669. u32 req_id;
  670. u32 status;
  671. u32 major_ver;
  672. u32 minor_ver;
  673. u32 dev_flags;
  674. u32 medium;
  675. u32 max_pkt_per_msg;
  676. u32 max_xfer_size;
  677. u32 pkt_alignment_factor;
  678. u32 af_list_offset;
  679. u32 af_list_size;
  680. };
  681. /* Call manager devices only: Information about an address family */
  682. /* supported by the device is appended to the response to NdisInitialize. */
  683. struct rndis_co_address_family {
  684. u32 address_family;
  685. u32 major_ver;
  686. u32 minor_ver;
  687. };
  688. /* NdisHalt message */
  689. struct rndis_halt_request {
  690. u32 req_id;
  691. };
  692. /* NdisQueryRequest message */
  693. struct rndis_query_request {
  694. u32 req_id;
  695. u32 oid;
  696. u32 info_buflen;
  697. u32 info_buf_offset;
  698. u32 dev_vc_handle;
  699. };
  700. /* Response to NdisQueryRequest */
  701. struct rndis_query_complete {
  702. u32 req_id;
  703. u32 status;
  704. u32 info_buflen;
  705. u32 info_buf_offset;
  706. };
  707. /* NdisSetRequest message */
  708. struct rndis_set_request {
  709. u32 req_id;
  710. u32 oid;
  711. u32 info_buflen;
  712. u32 info_buf_offset;
  713. u32 dev_vc_handle;
  714. };
  715. /* Response to NdisSetRequest */
  716. struct rndis_set_complete {
  717. u32 req_id;
  718. u32 status;
  719. };
  720. /* NdisReset message */
  721. struct rndis_reset_request {
  722. u32 reserved;
  723. };
  724. /* Response to NdisReset */
  725. struct rndis_reset_complete {
  726. u32 status;
  727. u32 addressing_reset;
  728. };
  729. /* NdisMIndicateStatus message */
  730. struct rndis_indicate_status {
  731. u32 status;
  732. u32 status_buflen;
  733. u32 status_buf_offset;
  734. };
  735. /* Diagnostic information passed as the status buffer in */
  736. /* struct rndis_indicate_status messages signifying error conditions. */
  737. struct rndis_diagnostic_info {
  738. u32 diag_status;
  739. u32 error_offset;
  740. };
  741. /* NdisKeepAlive message */
  742. struct rndis_keepalive_request {
  743. u32 req_id;
  744. };
  745. /* Response to NdisKeepAlive */
  746. struct rndis_keepalive_complete {
  747. u32 req_id;
  748. u32 status;
  749. };
  750. /*
  751. * Data message. All Offset fields contain byte offsets from the beginning of
  752. * struct rndis_packet. All Length fields are in bytes. VcHandle is set
  753. * to 0 for connectionless data, otherwise it contains the VC handle.
  754. */
  755. struct rndis_packet {
  756. u32 data_offset;
  757. u32 data_len;
  758. u32 oob_data_offset;
  759. u32 oob_data_len;
  760. u32 num_oob_data_elements;
  761. u32 per_pkt_info_offset;
  762. u32 per_pkt_info_len;
  763. u32 vc_handle;
  764. u32 reserved;
  765. };
  766. /* Optional Out of Band data associated with a Data message. */
  767. struct rndis_oobd {
  768. u32 size;
  769. u32 type;
  770. u32 class_info_offset;
  771. };
  772. /* Packet extension field contents associated with a Data message. */
  773. struct rndis_per_packet_info {
  774. u32 size;
  775. u32 type;
  776. u32 ppi_offset;
  777. };
  778. enum ndis_per_pkt_info_type {
  779. TCPIP_CHKSUM_PKTINFO,
  780. IPSEC_PKTINFO,
  781. TCP_LARGESEND_PKTINFO,
  782. CLASSIFICATION_HANDLE_PKTINFO,
  783. NDIS_RESERVED,
  784. SG_LIST_PKTINFO,
  785. IEEE_8021Q_INFO,
  786. ORIGINAL_PKTINFO,
  787. PACKET_CANCEL_ID,
  788. NBL_HASH_VALUE = PACKET_CANCEL_ID,
  789. ORIGINAL_NET_BUFLIST,
  790. CACHED_NET_BUFLIST,
  791. SHORT_PKT_PADINFO,
  792. MAX_PER_PKT_INFO
  793. };
  794. struct ndis_pkt_8021q_info {
  795. union {
  796. struct {
  797. u32 pri:3; /* User Priority */
  798. u32 cfi:1; /* Canonical Format ID */
  799. u32 vlanid:12; /* VLAN ID */
  800. u32 reserved:16;
  801. };
  802. u32 value;
  803. };
  804. };
  805. struct ndis_object_header {
  806. u8 type;
  807. u8 revision;
  808. u16 size;
  809. };
  810. #define NDIS_OBJECT_TYPE_DEFAULT 0x80
  811. #define NDIS_OFFLOAD_PARAMETERS_REVISION_3 3
  812. #define NDIS_OFFLOAD_PARAMETERS_REVISION_2 2
  813. #define NDIS_OFFLOAD_PARAMETERS_REVISION_1 1
  814. #define NDIS_OFFLOAD_PARAMETERS_NO_CHANGE 0
  815. #define NDIS_OFFLOAD_PARAMETERS_LSOV2_DISABLED 1
  816. #define NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED 2
  817. #define NDIS_OFFLOAD_PARAMETERS_LSOV1_ENABLED 2
  818. #define NDIS_OFFLOAD_PARAMETERS_RSC_DISABLED 1
  819. #define NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED 2
  820. #define NDIS_OFFLOAD_PARAMETERS_TX_RX_DISABLED 1
  821. #define NDIS_OFFLOAD_PARAMETERS_TX_ENABLED_RX_DISABLED 2
  822. #define NDIS_OFFLOAD_PARAMETERS_RX_ENABLED_TX_DISABLED 3
  823. #define NDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED 4
  824. #define NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE 1
  825. #define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV4 0
  826. #define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV6 1
  827. #define VERSION_4_OFFLOAD_SIZE 22
  828. /*
  829. * New offload OIDs for NDIS 6
  830. */
  831. #define OID_TCP_OFFLOAD_CURRENT_CONFIG 0xFC01020B /* query only */
  832. #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C /* set only */
  833. #define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020D/* query only */
  834. #define OID_TCP_CONNECTION_OFFLOAD_CURRENT_CONFIG 0xFC01020E /* query only */
  835. #define OID_TCP_CONNECTION_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020F /* query */
  836. #define OID_OFFLOAD_ENCAPSULATION 0x0101010A /* set/query */
  837. /*
  838. * OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES
  839. * ndis_type: NDIS_OBJTYPE_OFFLOAD
  840. */
  841. #define NDIS_OFFLOAD_ENCAP_NONE 0x0000
  842. #define NDIS_OFFLOAD_ENCAP_NULL 0x0001
  843. #define NDIS_OFFLOAD_ENCAP_8023 0x0002
  844. #define NDIS_OFFLOAD_ENCAP_8023PQ 0x0004
  845. #define NDIS_OFFLOAD_ENCAP_8023PQ_OOB 0x0008
  846. #define NDIS_OFFLOAD_ENCAP_RFC1483 0x0010
  847. struct ndis_csum_offload {
  848. u32 ip4_txenc;
  849. u32 ip4_txcsum;
  850. #define NDIS_TXCSUM_CAP_IP4OPT 0x001
  851. #define NDIS_TXCSUM_CAP_TCP4OPT 0x004
  852. #define NDIS_TXCSUM_CAP_TCP4 0x010
  853. #define NDIS_TXCSUM_CAP_UDP4 0x040
  854. #define NDIS_TXCSUM_CAP_IP4 0x100
  855. #define NDIS_TXCSUM_ALL_TCP4 (NDIS_TXCSUM_CAP_TCP4 | NDIS_TXCSUM_CAP_TCP4OPT)
  856. u32 ip4_rxenc;
  857. u32 ip4_rxcsum;
  858. #define NDIS_RXCSUM_CAP_IP4OPT 0x001
  859. #define NDIS_RXCSUM_CAP_TCP4OPT 0x004
  860. #define NDIS_RXCSUM_CAP_TCP4 0x010
  861. #define NDIS_RXCSUM_CAP_UDP4 0x040
  862. #define NDIS_RXCSUM_CAP_IP4 0x100
  863. u32 ip6_txenc;
  864. u32 ip6_txcsum;
  865. #define NDIS_TXCSUM_CAP_IP6EXT 0x001
  866. #define NDIS_TXCSUM_CAP_TCP6OPT 0x004
  867. #define NDIS_TXCSUM_CAP_TCP6 0x010
  868. #define NDIS_TXCSUM_CAP_UDP6 0x040
  869. u32 ip6_rxenc;
  870. u32 ip6_rxcsum;
  871. #define NDIS_RXCSUM_CAP_IP6EXT 0x001
  872. #define NDIS_RXCSUM_CAP_TCP6OPT 0x004
  873. #define NDIS_RXCSUM_CAP_TCP6 0x010
  874. #define NDIS_RXCSUM_CAP_UDP6 0x040
  875. #define NDIS_TXCSUM_ALL_TCP6 (NDIS_TXCSUM_CAP_TCP6 | \
  876. NDIS_TXCSUM_CAP_TCP6OPT | \
  877. NDIS_TXCSUM_CAP_IP6EXT)
  878. };
  879. struct ndis_lsov1_offload {
  880. u32 encap;
  881. u32 maxsize;
  882. u32 minsegs;
  883. u32 opts;
  884. };
  885. struct ndis_ipsecv1_offload {
  886. u32 encap;
  887. u32 ah_esp;
  888. u32 xport_tun;
  889. u32 ip4_opts;
  890. u32 flags;
  891. u32 ip4_ah;
  892. u32 ip4_esp;
  893. };
  894. struct ndis_lsov2_offload {
  895. u32 ip4_encap;
  896. u32 ip4_maxsz;
  897. u32 ip4_minsg;
  898. u32 ip6_encap;
  899. u32 ip6_maxsz;
  900. u32 ip6_minsg;
  901. u32 ip6_opts;
  902. #define NDIS_LSOV2_CAP_IP6EXT 0x001
  903. #define NDIS_LSOV2_CAP_TCP6OPT 0x004
  904. #define NDIS_LSOV2_CAP_IP6 (NDIS_LSOV2_CAP_IP6EXT | \
  905. NDIS_LSOV2_CAP_TCP6OPT)
  906. };
  907. struct ndis_ipsecv2_offload {
  908. u32 encap;
  909. u16 ip6;
  910. u16 ip4opt;
  911. u16 ip6ext;
  912. u16 ah;
  913. u16 esp;
  914. u16 ah_esp;
  915. u16 xport;
  916. u16 tun;
  917. u16 xport_tun;
  918. u16 lso;
  919. u16 extseq;
  920. u32 udp_esp;
  921. u32 auth;
  922. u32 crypto;
  923. u32 sa_caps;
  924. };
  925. struct ndis_rsc_offload {
  926. u16 ip4;
  927. u16 ip6;
  928. };
  929. struct ndis_encap_offload {
  930. u32 flags;
  931. u32 maxhdr;
  932. };
  933. struct ndis_offload {
  934. struct ndis_object_header header;
  935. struct ndis_csum_offload csum;
  936. struct ndis_lsov1_offload lsov1;
  937. struct ndis_ipsecv1_offload ipsecv1;
  938. struct ndis_lsov2_offload lsov2;
  939. u32 flags;
  940. /* NDIS >= 6.1 */
  941. struct ndis_ipsecv2_offload ipsecv2;
  942. /* NDIS >= 6.30 */
  943. struct ndis_rsc_offload rsc;
  944. struct ndis_encap_offload encap_gre;
  945. };
  946. #define NDIS_OFFLOAD_SIZE sizeof(struct ndis_offload)
  947. #define NDIS_OFFLOAD_SIZE_6_0 offsetof(struct ndis_offload, ipsecv2)
  948. #define NDIS_OFFLOAD_SIZE_6_1 offsetof(struct ndis_offload, rsc)
  949. struct ndis_offload_params {
  950. struct ndis_object_header header;
  951. u8 ip_v4_csum;
  952. u8 tcp_ip_v4_csum;
  953. u8 udp_ip_v4_csum;
  954. u8 tcp_ip_v6_csum;
  955. u8 udp_ip_v6_csum;
  956. u8 lso_v1;
  957. u8 ip_sec_v1;
  958. u8 lso_v2_ipv4;
  959. u8 lso_v2_ipv6;
  960. u8 tcp_connection_ip_v4;
  961. u8 tcp_connection_ip_v6;
  962. u32 flags;
  963. u8 ip_sec_v2;
  964. u8 ip_sec_v2_ip_v4;
  965. struct {
  966. u8 rsc_ip_v4;
  967. u8 rsc_ip_v6;
  968. };
  969. struct {
  970. u8 encapsulated_packet_task_offload;
  971. u8 encapsulation_types;
  972. };
  973. };
  974. struct ndis_tcp_ip_checksum_info {
  975. union {
  976. struct {
  977. u32 is_ipv4:1;
  978. u32 is_ipv6:1;
  979. u32 tcp_checksum:1;
  980. u32 udp_checksum:1;
  981. u32 ip_header_checksum:1;
  982. u32 reserved:11;
  983. u32 tcp_header_offset:10;
  984. } transmit;
  985. struct {
  986. u32 tcp_checksum_failed:1;
  987. u32 udp_checksum_failed:1;
  988. u32 ip_checksum_failed:1;
  989. u32 tcp_checksum_succeeded:1;
  990. u32 udp_checksum_succeeded:1;
  991. u32 ip_checksum_succeeded:1;
  992. u32 loopback:1;
  993. u32 tcp_checksum_value_invalid:1;
  994. u32 ip_checksum_value_invalid:1;
  995. } receive;
  996. u32 value;
  997. };
  998. };
  999. struct ndis_tcp_lso_info {
  1000. union {
  1001. struct {
  1002. u32 unused:30;
  1003. u32 type:1;
  1004. u32 reserved2:1;
  1005. } transmit;
  1006. struct {
  1007. u32 mss:20;
  1008. u32 tcp_header_offset:10;
  1009. u32 type:1;
  1010. u32 reserved2:1;
  1011. } lso_v1_transmit;
  1012. struct {
  1013. u32 tcp_payload:30;
  1014. u32 type:1;
  1015. u32 reserved2:1;
  1016. } lso_v1_transmit_complete;
  1017. struct {
  1018. u32 mss:20;
  1019. u32 tcp_header_offset:10;
  1020. u32 type:1;
  1021. u32 ip_version:1;
  1022. } lso_v2_transmit;
  1023. struct {
  1024. u32 reserved:30;
  1025. u32 type:1;
  1026. u32 reserved2:1;
  1027. } lso_v2_transmit_complete;
  1028. u32 value;
  1029. };
  1030. };
  1031. #define NDIS_VLAN_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1032. sizeof(struct ndis_pkt_8021q_info))
  1033. #define NDIS_CSUM_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1034. sizeof(struct ndis_tcp_ip_checksum_info))
  1035. #define NDIS_LSO_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1036. sizeof(struct ndis_tcp_lso_info))
  1037. #define NDIS_HASH_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1038. sizeof(u32))
  1039. /* Total size of all PPI data */
  1040. #define NDIS_ALL_PPI_SIZE (NDIS_VLAN_PPI_SIZE + NDIS_CSUM_PPI_SIZE + \
  1041. NDIS_LSO_PPI_SIZE + NDIS_HASH_PPI_SIZE)
  1042. /* Format of Information buffer passed in a SetRequest for the OID */
  1043. /* OID_GEN_RNDIS_CONFIG_PARAMETER. */
  1044. struct rndis_config_parameter_info {
  1045. u32 parameter_name_offset;
  1046. u32 parameter_name_length;
  1047. u32 parameter_type;
  1048. u32 parameter_value_offset;
  1049. u32 parameter_value_length;
  1050. };
  1051. /* Values for ParameterType in struct rndis_config_parameter_info */
  1052. #define RNDIS_CONFIG_PARAM_TYPE_INTEGER 0
  1053. #define RNDIS_CONFIG_PARAM_TYPE_STRING 2
  1054. /* CONDIS Miniport messages for connection oriented devices */
  1055. /* that do not implement a call manager. */
  1056. /* CoNdisMiniportCreateVc message */
  1057. struct rcondis_mp_create_vc {
  1058. u32 req_id;
  1059. u32 ndis_vc_handle;
  1060. };
  1061. /* Response to CoNdisMiniportCreateVc */
  1062. struct rcondis_mp_create_vc_complete {
  1063. u32 req_id;
  1064. u32 dev_vc_handle;
  1065. u32 status;
  1066. };
  1067. /* CoNdisMiniportDeleteVc message */
  1068. struct rcondis_mp_delete_vc {
  1069. u32 req_id;
  1070. u32 dev_vc_handle;
  1071. };
  1072. /* Response to CoNdisMiniportDeleteVc */
  1073. struct rcondis_mp_delete_vc_complete {
  1074. u32 req_id;
  1075. u32 status;
  1076. };
  1077. /* CoNdisMiniportQueryRequest message */
  1078. struct rcondis_mp_query_request {
  1079. u32 req_id;
  1080. u32 request_type;
  1081. u32 oid;
  1082. u32 dev_vc_handle;
  1083. u32 info_buflen;
  1084. u32 info_buf_offset;
  1085. };
  1086. /* CoNdisMiniportSetRequest message */
  1087. struct rcondis_mp_set_request {
  1088. u32 req_id;
  1089. u32 request_type;
  1090. u32 oid;
  1091. u32 dev_vc_handle;
  1092. u32 info_buflen;
  1093. u32 info_buf_offset;
  1094. };
  1095. /* CoNdisIndicateStatus message */
  1096. struct rcondis_indicate_status {
  1097. u32 ndis_vc_handle;
  1098. u32 status;
  1099. u32 status_buflen;
  1100. u32 status_buf_offset;
  1101. };
  1102. /* CONDIS Call/VC parameters */
  1103. struct rcondis_specific_parameters {
  1104. u32 parameter_type;
  1105. u32 parameter_length;
  1106. u32 parameter_lffset;
  1107. };
  1108. struct rcondis_media_parameters {
  1109. u32 flags;
  1110. u32 reserved1;
  1111. u32 reserved2;
  1112. struct rcondis_specific_parameters media_specific;
  1113. };
  1114. struct rndis_flowspec {
  1115. u32 token_rate;
  1116. u32 token_bucket_size;
  1117. u32 peak_bandwidth;
  1118. u32 latency;
  1119. u32 delay_variation;
  1120. u32 service_type;
  1121. u32 max_sdu_size;
  1122. u32 minimum_policed_size;
  1123. };
  1124. struct rcondis_call_manager_parameters {
  1125. struct rndis_flowspec transmit;
  1126. struct rndis_flowspec receive;
  1127. struct rcondis_specific_parameters call_mgr_specific;
  1128. };
  1129. /* CoNdisMiniportActivateVc message */
  1130. struct rcondis_mp_activate_vc_request {
  1131. u32 req_id;
  1132. u32 flags;
  1133. u32 dev_vc_handle;
  1134. u32 media_params_offset;
  1135. u32 media_params_length;
  1136. u32 call_mgr_params_offset;
  1137. u32 call_mgr_params_length;
  1138. };
  1139. /* Response to CoNdisMiniportActivateVc */
  1140. struct rcondis_mp_activate_vc_complete {
  1141. u32 req_id;
  1142. u32 status;
  1143. };
  1144. /* CoNdisMiniportDeactivateVc message */
  1145. struct rcondis_mp_deactivate_vc_request {
  1146. u32 req_id;
  1147. u32 flags;
  1148. u32 dev_vc_handle;
  1149. };
  1150. /* Response to CoNdisMiniportDeactivateVc */
  1151. struct rcondis_mp_deactivate_vc_complete {
  1152. u32 req_id;
  1153. u32 status;
  1154. };
  1155. /* union with all of the RNDIS messages */
  1156. union rndis_message_container {
  1157. struct rndis_packet pkt;
  1158. struct rndis_initialize_request init_req;
  1159. struct rndis_halt_request halt_req;
  1160. struct rndis_query_request query_req;
  1161. struct rndis_set_request set_req;
  1162. struct rndis_reset_request reset_req;
  1163. struct rndis_keepalive_request keep_alive_req;
  1164. struct rndis_indicate_status indicate_status;
  1165. struct rndis_initialize_complete init_complete;
  1166. struct rndis_query_complete query_complete;
  1167. struct rndis_set_complete set_complete;
  1168. struct rndis_reset_complete reset_complete;
  1169. struct rndis_keepalive_complete keep_alive_complete;
  1170. struct rcondis_mp_create_vc co_miniport_create_vc;
  1171. struct rcondis_mp_delete_vc co_miniport_delete_vc;
  1172. struct rcondis_indicate_status co_indicate_status;
  1173. struct rcondis_mp_activate_vc_request co_miniport_activate_vc;
  1174. struct rcondis_mp_deactivate_vc_request co_miniport_deactivate_vc;
  1175. struct rcondis_mp_create_vc_complete co_miniport_create_vc_complete;
  1176. struct rcondis_mp_delete_vc_complete co_miniport_delete_vc_complete;
  1177. struct rcondis_mp_activate_vc_complete co_miniport_activate_vc_complete;
  1178. struct rcondis_mp_deactivate_vc_complete
  1179. co_miniport_deactivate_vc_complete;
  1180. };
  1181. /* Remote NDIS message format */
  1182. struct rndis_message {
  1183. u32 ndis_msg_type;
  1184. /* Total length of this message, from the beginning */
  1185. /* of the struct rndis_message, in bytes. */
  1186. u32 msg_len;
  1187. /* Actual message */
  1188. union rndis_message_container msg;
  1189. };
  1190. /* Handy macros */
  1191. /* get the size of an RNDIS message. Pass in the message type, */
  1192. /* struct rndis_set_request, struct rndis_packet for example */
  1193. #define RNDIS_MESSAGE_SIZE(msg) \
  1194. (sizeof(msg) + (sizeof(struct rndis_message) - \
  1195. sizeof(union rndis_message_container)))
  1196. /* get pointer to info buffer with message pointer */
  1197. #define MESSAGE_TO_INFO_BUFFER(msg) \
  1198. (((unsigned char *)(msg)) + msg->info_buf_offset)
  1199. /* get pointer to status buffer with message pointer */
  1200. #define MESSAGE_TO_STATUS_BUFFER(msg) \
  1201. (((unsigned char *)(msg)) + msg->status_buf_offset)
  1202. /* get pointer to OOBD buffer with message pointer */
  1203. #define MESSAGE_TO_OOBD_BUFFER(msg) \
  1204. (((unsigned char *)(msg)) + msg->oob_data_offset)
  1205. /* get pointer to data buffer with message pointer */
  1206. #define MESSAGE_TO_DATA_BUFFER(msg) \
  1207. (((unsigned char *)(msg)) + msg->per_pkt_info_offset)
  1208. /* get pointer to contained message from NDIS_MESSAGE pointer */
  1209. #define RNDIS_MESSAGE_PTR_TO_MESSAGE_PTR(rndis_msg) \
  1210. ((void *) &rndis_msg->msg)
  1211. /* get pointer to contained message from NDIS_MESSAGE pointer */
  1212. #define RNDIS_MESSAGE_RAW_PTR_TO_MESSAGE_PTR(rndis_msg) \
  1213. ((void *) rndis_msg)
  1214. #define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \
  1215. sizeof(union rndis_message_container))
  1216. #define RNDIS_AND_PPI_SIZE (sizeof(struct rndis_message) + NDIS_ALL_PPI_SIZE)
  1217. #define NDIS_PACKET_TYPE_DIRECTED 0x00000001
  1218. #define NDIS_PACKET_TYPE_MULTICAST 0x00000002
  1219. #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
  1220. #define NDIS_PACKET_TYPE_BROADCAST 0x00000008
  1221. #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
  1222. #define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
  1223. #define NDIS_PACKET_TYPE_SMT 0x00000040
  1224. #define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
  1225. #define NDIS_PACKET_TYPE_GROUP 0x00000100
  1226. #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
  1227. #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
  1228. #define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
  1229. #define TRANSPORT_INFO_NOT_IP 0
  1230. #define TRANSPORT_INFO_IPV4_TCP 0x01
  1231. #define TRANSPORT_INFO_IPV4_UDP 0x02
  1232. #define TRANSPORT_INFO_IPV6_TCP 0x10
  1233. #define TRANSPORT_INFO_IPV6_UDP 0x20
  1234. #endif /* _HYPERV_NET_H */