hyperv_net.h 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  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. u32 num_chn;
  122. u32 send_sections;
  123. u32 recv_sections;
  124. u32 send_section_size;
  125. u32 recv_section_size;
  126. };
  127. enum rndis_device_state {
  128. RNDIS_DEV_UNINITIALIZED = 0,
  129. RNDIS_DEV_INITIALIZING,
  130. RNDIS_DEV_INITIALIZED,
  131. RNDIS_DEV_DATAINITIALIZED,
  132. };
  133. #define NETVSC_HASH_KEYLEN 40
  134. struct rndis_device {
  135. struct net_device *ndev;
  136. enum rndis_device_state state;
  137. atomic_t new_req_id;
  138. spinlock_t request_lock;
  139. struct list_head req_list;
  140. struct work_struct mcast_work;
  141. bool link_state; /* 0 - link up, 1 - link down */
  142. u8 hw_mac_adr[ETH_ALEN];
  143. u8 rss_key[NETVSC_HASH_KEYLEN];
  144. u16 rx_table[ITAB_NUM];
  145. };
  146. /* Interface */
  147. struct rndis_message;
  148. struct netvsc_device;
  149. struct net_device_context;
  150. extern u32 netvsc_ring_bytes;
  151. extern struct reciprocal_value netvsc_ring_reciprocal;
  152. struct netvsc_device *netvsc_device_add(struct hv_device *device,
  153. const struct netvsc_device_info *info);
  154. int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx);
  155. void netvsc_device_remove(struct hv_device *device);
  156. int netvsc_send(struct net_device_context *ndc,
  157. struct hv_netvsc_packet *packet,
  158. struct rndis_message *rndis_msg,
  159. struct hv_page_buffer *page_buffer,
  160. struct sk_buff *skb);
  161. void netvsc_linkstatus_callback(struct net_device *net,
  162. struct rndis_message *resp);
  163. int netvsc_recv_callback(struct net_device *net,
  164. struct vmbus_channel *channel,
  165. void *data, u32 len,
  166. const struct ndis_tcp_ip_checksum_info *csum_info,
  167. const struct ndis_pkt_8021q_info *vlan);
  168. void netvsc_channel_cb(void *context);
  169. int netvsc_poll(struct napi_struct *napi, int budget);
  170. void rndis_set_subchannel(struct work_struct *w);
  171. bool rndis_filter_opened(const struct netvsc_device *nvdev);
  172. int rndis_filter_open(struct netvsc_device *nvdev);
  173. int rndis_filter_close(struct netvsc_device *nvdev);
  174. struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
  175. struct netvsc_device_info *info);
  176. void rndis_filter_update(struct netvsc_device *nvdev);
  177. void rndis_filter_device_remove(struct hv_device *dev,
  178. struct netvsc_device *nvdev);
  179. int rndis_filter_set_rss_param(struct rndis_device *rdev,
  180. const u8 *key);
  181. int rndis_filter_receive(struct net_device *ndev,
  182. struct netvsc_device *net_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. /* Max buffer sizes allowed by a host */
  517. #define NETVSC_RECEIVE_BUFFER_SIZE (1024 * 1024 * 31) /* 31MB */
  518. #define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024 * 1024 * 15) /* 15MB */
  519. #define NETVSC_RECEIVE_BUFFER_DEFAULT (1024 * 1024 * 16)
  520. #define NETVSC_SEND_BUFFER_SIZE (1024 * 1024 * 15) /* 15MB */
  521. #define NETVSC_SEND_BUFFER_DEFAULT (1024 * 1024)
  522. #define NETVSC_INVALID_INDEX -1
  523. #define NETVSC_SEND_SECTION_SIZE 6144
  524. #define NETVSC_RECV_SECTION_SIZE 1728
  525. /* Default size of TX buf: 1MB, RX buf: 16MB */
  526. #define NETVSC_MIN_TX_SECTIONS 10
  527. #define NETVSC_DEFAULT_TX (NETVSC_SEND_BUFFER_DEFAULT \
  528. / NETVSC_SEND_SECTION_SIZE)
  529. #define NETVSC_MIN_RX_SECTIONS 10
  530. #define NETVSC_DEFAULT_RX (NETVSC_RECEIVE_BUFFER_DEFAULT \
  531. / NETVSC_RECV_SECTION_SIZE)
  532. #define NETVSC_RECEIVE_BUFFER_ID 0xcafe
  533. #define NETVSC_SEND_BUFFER_ID 0
  534. #define NETVSC_SUPPORTED_HW_FEATURES (NETIF_F_RXCSUM | NETIF_F_IP_CSUM | \
  535. NETIF_F_TSO | NETIF_F_IPV6_CSUM | \
  536. NETIF_F_TSO6)
  537. #define VRSS_SEND_TAB_SIZE 16 /* must be power of 2 */
  538. #define VRSS_CHANNEL_MAX 64
  539. #define VRSS_CHANNEL_DEFAULT 8
  540. #define RNDIS_MAX_PKT_DEFAULT 8
  541. #define RNDIS_PKT_ALIGN_DEFAULT 8
  542. struct multi_send_data {
  543. struct sk_buff *skb; /* skb containing the pkt */
  544. struct hv_netvsc_packet *pkt; /* netvsc pkt pending */
  545. u32 count; /* counter of batched packets */
  546. };
  547. struct recv_comp_data {
  548. u64 tid; /* transaction id */
  549. u32 status;
  550. };
  551. struct multi_recv_comp {
  552. struct recv_comp_data *slots;
  553. u32 first; /* first data entry */
  554. u32 next; /* next entry for writing */
  555. };
  556. struct netvsc_stats {
  557. u64 packets;
  558. u64 bytes;
  559. u64 broadcast;
  560. u64 multicast;
  561. struct u64_stats_sync syncp;
  562. };
  563. struct netvsc_ethtool_stats {
  564. unsigned long tx_scattered;
  565. unsigned long tx_no_memory;
  566. unsigned long tx_no_space;
  567. unsigned long tx_too_big;
  568. unsigned long tx_busy;
  569. unsigned long tx_send_full;
  570. unsigned long rx_comp_busy;
  571. unsigned long rx_no_memory;
  572. unsigned long stop_queue;
  573. unsigned long wake_queue;
  574. };
  575. struct netvsc_vf_pcpu_stats {
  576. u64 rx_packets;
  577. u64 rx_bytes;
  578. u64 tx_packets;
  579. u64 tx_bytes;
  580. struct u64_stats_sync syncp;
  581. u32 tx_dropped;
  582. };
  583. struct netvsc_reconfig {
  584. struct list_head list;
  585. u32 event;
  586. };
  587. /* L4 hash bits for different protocols */
  588. #define HV_TCP4_L4HASH 1
  589. #define HV_TCP6_L4HASH 2
  590. #define HV_UDP4_L4HASH 4
  591. #define HV_UDP6_L4HASH 8
  592. #define HV_DEFAULT_L4HASH (HV_TCP4_L4HASH | HV_TCP6_L4HASH | HV_UDP4_L4HASH | \
  593. HV_UDP6_L4HASH)
  594. /* The context of the netvsc device */
  595. struct net_device_context {
  596. /* point back to our device context */
  597. struct hv_device *device_ctx;
  598. /* netvsc_device */
  599. struct netvsc_device __rcu *nvdev;
  600. /* reconfigure work */
  601. struct delayed_work dwork;
  602. /* last reconfig time */
  603. unsigned long last_reconfig;
  604. /* reconfig events */
  605. struct list_head reconfig_events;
  606. /* list protection */
  607. spinlock_t lock;
  608. u32 msg_enable; /* debug level */
  609. u32 tx_checksum_mask;
  610. u32 tx_table[VRSS_SEND_TAB_SIZE];
  611. /* Ethtool settings */
  612. u8 duplex;
  613. u32 speed;
  614. u32 l4_hash; /* L4 hash settings */
  615. struct netvsc_ethtool_stats eth_stats;
  616. /* State to manage the associated VF interface. */
  617. struct net_device __rcu *vf_netdev;
  618. struct netvsc_vf_pcpu_stats __percpu *vf_stats;
  619. struct delayed_work vf_takeover;
  620. /* 1: allocated, serial number is valid. 0: not allocated */
  621. u32 vf_alloc;
  622. /* Serial number of the VF to team with */
  623. u32 vf_serial;
  624. };
  625. /* Per channel data */
  626. struct netvsc_channel {
  627. struct vmbus_channel *channel;
  628. struct netvsc_device *net_device;
  629. const struct vmpacket_descriptor *desc;
  630. struct napi_struct napi;
  631. struct multi_send_data msd;
  632. struct multi_recv_comp mrc;
  633. atomic_t queue_sends;
  634. struct netvsc_stats tx_stats;
  635. struct netvsc_stats rx_stats;
  636. };
  637. /* Per netvsc device */
  638. struct netvsc_device {
  639. u32 nvsp_version;
  640. wait_queue_head_t wait_drain;
  641. bool destroy;
  642. /* Receive buffer allocated by us but manages by NetVSP */
  643. void *recv_buf;
  644. u32 recv_buf_gpadl_handle;
  645. u32 recv_section_cnt;
  646. u32 recv_section_size;
  647. u32 recv_completion_cnt;
  648. /* Send buffer allocated by us */
  649. void *send_buf;
  650. u32 send_buf_gpadl_handle;
  651. u32 send_section_cnt;
  652. u32 send_section_size;
  653. unsigned long *send_section_map;
  654. /* Used for NetVSP initialization protocol */
  655. struct completion channel_init_wait;
  656. struct nvsp_message channel_init_pkt;
  657. struct nvsp_message revoke_packet;
  658. u32 max_chn;
  659. u32 num_chn;
  660. atomic_t open_chn;
  661. struct work_struct subchan_work;
  662. wait_queue_head_t subchan_open;
  663. struct rndis_device *extension;
  664. u32 max_pkt; /* max number of pkt in one send, e.g. 8 */
  665. u32 pkt_align; /* alignment bytes, e.g. 8 */
  666. atomic_t open_cnt;
  667. struct netvsc_channel chan_table[VRSS_CHANNEL_MAX];
  668. struct rcu_head rcu;
  669. };
  670. /* NdisInitialize message */
  671. struct rndis_initialize_request {
  672. u32 req_id;
  673. u32 major_ver;
  674. u32 minor_ver;
  675. u32 max_xfer_size;
  676. };
  677. /* Response to NdisInitialize */
  678. struct rndis_initialize_complete {
  679. u32 req_id;
  680. u32 status;
  681. u32 major_ver;
  682. u32 minor_ver;
  683. u32 dev_flags;
  684. u32 medium;
  685. u32 max_pkt_per_msg;
  686. u32 max_xfer_size;
  687. u32 pkt_alignment_factor;
  688. u32 af_list_offset;
  689. u32 af_list_size;
  690. };
  691. /* Call manager devices only: Information about an address family */
  692. /* supported by the device is appended to the response to NdisInitialize. */
  693. struct rndis_co_address_family {
  694. u32 address_family;
  695. u32 major_ver;
  696. u32 minor_ver;
  697. };
  698. /* NdisHalt message */
  699. struct rndis_halt_request {
  700. u32 req_id;
  701. };
  702. /* NdisQueryRequest message */
  703. struct rndis_query_request {
  704. u32 req_id;
  705. u32 oid;
  706. u32 info_buflen;
  707. u32 info_buf_offset;
  708. u32 dev_vc_handle;
  709. };
  710. /* Response to NdisQueryRequest */
  711. struct rndis_query_complete {
  712. u32 req_id;
  713. u32 status;
  714. u32 info_buflen;
  715. u32 info_buf_offset;
  716. };
  717. /* NdisSetRequest message */
  718. struct rndis_set_request {
  719. u32 req_id;
  720. u32 oid;
  721. u32 info_buflen;
  722. u32 info_buf_offset;
  723. u32 dev_vc_handle;
  724. };
  725. /* Response to NdisSetRequest */
  726. struct rndis_set_complete {
  727. u32 req_id;
  728. u32 status;
  729. };
  730. /* NdisReset message */
  731. struct rndis_reset_request {
  732. u32 reserved;
  733. };
  734. /* Response to NdisReset */
  735. struct rndis_reset_complete {
  736. u32 status;
  737. u32 addressing_reset;
  738. };
  739. /* NdisMIndicateStatus message */
  740. struct rndis_indicate_status {
  741. u32 status;
  742. u32 status_buflen;
  743. u32 status_buf_offset;
  744. };
  745. /* Diagnostic information passed as the status buffer in */
  746. /* struct rndis_indicate_status messages signifying error conditions. */
  747. struct rndis_diagnostic_info {
  748. u32 diag_status;
  749. u32 error_offset;
  750. };
  751. /* NdisKeepAlive message */
  752. struct rndis_keepalive_request {
  753. u32 req_id;
  754. };
  755. /* Response to NdisKeepAlive */
  756. struct rndis_keepalive_complete {
  757. u32 req_id;
  758. u32 status;
  759. };
  760. /*
  761. * Data message. All Offset fields contain byte offsets from the beginning of
  762. * struct rndis_packet. All Length fields are in bytes. VcHandle is set
  763. * to 0 for connectionless data, otherwise it contains the VC handle.
  764. */
  765. struct rndis_packet {
  766. u32 data_offset;
  767. u32 data_len;
  768. u32 oob_data_offset;
  769. u32 oob_data_len;
  770. u32 num_oob_data_elements;
  771. u32 per_pkt_info_offset;
  772. u32 per_pkt_info_len;
  773. u32 vc_handle;
  774. u32 reserved;
  775. };
  776. /* Optional Out of Band data associated with a Data message. */
  777. struct rndis_oobd {
  778. u32 size;
  779. u32 type;
  780. u32 class_info_offset;
  781. };
  782. /* Packet extension field contents associated with a Data message. */
  783. struct rndis_per_packet_info {
  784. u32 size;
  785. u32 type;
  786. u32 ppi_offset;
  787. };
  788. enum ndis_per_pkt_info_type {
  789. TCPIP_CHKSUM_PKTINFO,
  790. IPSEC_PKTINFO,
  791. TCP_LARGESEND_PKTINFO,
  792. CLASSIFICATION_HANDLE_PKTINFO,
  793. NDIS_RESERVED,
  794. SG_LIST_PKTINFO,
  795. IEEE_8021Q_INFO,
  796. ORIGINAL_PKTINFO,
  797. PACKET_CANCEL_ID,
  798. NBL_HASH_VALUE = PACKET_CANCEL_ID,
  799. ORIGINAL_NET_BUFLIST,
  800. CACHED_NET_BUFLIST,
  801. SHORT_PKT_PADINFO,
  802. MAX_PER_PKT_INFO
  803. };
  804. struct ndis_pkt_8021q_info {
  805. union {
  806. struct {
  807. u32 pri:3; /* User Priority */
  808. u32 cfi:1; /* Canonical Format ID */
  809. u32 vlanid:12; /* VLAN ID */
  810. u32 reserved:16;
  811. };
  812. u32 value;
  813. };
  814. };
  815. struct ndis_object_header {
  816. u8 type;
  817. u8 revision;
  818. u16 size;
  819. };
  820. #define NDIS_OBJECT_TYPE_DEFAULT 0x80
  821. #define NDIS_OFFLOAD_PARAMETERS_REVISION_3 3
  822. #define NDIS_OFFLOAD_PARAMETERS_REVISION_2 2
  823. #define NDIS_OFFLOAD_PARAMETERS_REVISION_1 1
  824. #define NDIS_OFFLOAD_PARAMETERS_NO_CHANGE 0
  825. #define NDIS_OFFLOAD_PARAMETERS_LSOV2_DISABLED 1
  826. #define NDIS_OFFLOAD_PARAMETERS_LSOV2_ENABLED 2
  827. #define NDIS_OFFLOAD_PARAMETERS_LSOV1_ENABLED 2
  828. #define NDIS_OFFLOAD_PARAMETERS_RSC_DISABLED 1
  829. #define NDIS_OFFLOAD_PARAMETERS_RSC_ENABLED 2
  830. #define NDIS_OFFLOAD_PARAMETERS_TX_RX_DISABLED 1
  831. #define NDIS_OFFLOAD_PARAMETERS_TX_ENABLED_RX_DISABLED 2
  832. #define NDIS_OFFLOAD_PARAMETERS_RX_ENABLED_TX_DISABLED 3
  833. #define NDIS_OFFLOAD_PARAMETERS_TX_RX_ENABLED 4
  834. #define NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE 1
  835. #define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV4 0
  836. #define NDIS_TCP_LARGE_SEND_OFFLOAD_IPV6 1
  837. #define VERSION_4_OFFLOAD_SIZE 22
  838. /*
  839. * New offload OIDs for NDIS 6
  840. */
  841. #define OID_TCP_OFFLOAD_CURRENT_CONFIG 0xFC01020B /* query only */
  842. #define OID_TCP_OFFLOAD_PARAMETERS 0xFC01020C /* set only */
  843. #define OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020D/* query only */
  844. #define OID_TCP_CONNECTION_OFFLOAD_CURRENT_CONFIG 0xFC01020E /* query only */
  845. #define OID_TCP_CONNECTION_OFFLOAD_HARDWARE_CAPABILITIES 0xFC01020F /* query */
  846. #define OID_OFFLOAD_ENCAPSULATION 0x0101010A /* set/query */
  847. /*
  848. * OID_TCP_OFFLOAD_HARDWARE_CAPABILITIES
  849. * ndis_type: NDIS_OBJTYPE_OFFLOAD
  850. */
  851. #define NDIS_OFFLOAD_ENCAP_NONE 0x0000
  852. #define NDIS_OFFLOAD_ENCAP_NULL 0x0001
  853. #define NDIS_OFFLOAD_ENCAP_8023 0x0002
  854. #define NDIS_OFFLOAD_ENCAP_8023PQ 0x0004
  855. #define NDIS_OFFLOAD_ENCAP_8023PQ_OOB 0x0008
  856. #define NDIS_OFFLOAD_ENCAP_RFC1483 0x0010
  857. struct ndis_csum_offload {
  858. u32 ip4_txenc;
  859. u32 ip4_txcsum;
  860. #define NDIS_TXCSUM_CAP_IP4OPT 0x001
  861. #define NDIS_TXCSUM_CAP_TCP4OPT 0x004
  862. #define NDIS_TXCSUM_CAP_TCP4 0x010
  863. #define NDIS_TXCSUM_CAP_UDP4 0x040
  864. #define NDIS_TXCSUM_CAP_IP4 0x100
  865. #define NDIS_TXCSUM_ALL_TCP4 (NDIS_TXCSUM_CAP_TCP4 | NDIS_TXCSUM_CAP_TCP4OPT)
  866. u32 ip4_rxenc;
  867. u32 ip4_rxcsum;
  868. #define NDIS_RXCSUM_CAP_IP4OPT 0x001
  869. #define NDIS_RXCSUM_CAP_TCP4OPT 0x004
  870. #define NDIS_RXCSUM_CAP_TCP4 0x010
  871. #define NDIS_RXCSUM_CAP_UDP4 0x040
  872. #define NDIS_RXCSUM_CAP_IP4 0x100
  873. u32 ip6_txenc;
  874. u32 ip6_txcsum;
  875. #define NDIS_TXCSUM_CAP_IP6EXT 0x001
  876. #define NDIS_TXCSUM_CAP_TCP6OPT 0x004
  877. #define NDIS_TXCSUM_CAP_TCP6 0x010
  878. #define NDIS_TXCSUM_CAP_UDP6 0x040
  879. u32 ip6_rxenc;
  880. u32 ip6_rxcsum;
  881. #define NDIS_RXCSUM_CAP_IP6EXT 0x001
  882. #define NDIS_RXCSUM_CAP_TCP6OPT 0x004
  883. #define NDIS_RXCSUM_CAP_TCP6 0x010
  884. #define NDIS_RXCSUM_CAP_UDP6 0x040
  885. #define NDIS_TXCSUM_ALL_TCP6 (NDIS_TXCSUM_CAP_TCP6 | \
  886. NDIS_TXCSUM_CAP_TCP6OPT | \
  887. NDIS_TXCSUM_CAP_IP6EXT)
  888. };
  889. struct ndis_lsov1_offload {
  890. u32 encap;
  891. u32 maxsize;
  892. u32 minsegs;
  893. u32 opts;
  894. };
  895. struct ndis_ipsecv1_offload {
  896. u32 encap;
  897. u32 ah_esp;
  898. u32 xport_tun;
  899. u32 ip4_opts;
  900. u32 flags;
  901. u32 ip4_ah;
  902. u32 ip4_esp;
  903. };
  904. struct ndis_lsov2_offload {
  905. u32 ip4_encap;
  906. u32 ip4_maxsz;
  907. u32 ip4_minsg;
  908. u32 ip6_encap;
  909. u32 ip6_maxsz;
  910. u32 ip6_minsg;
  911. u32 ip6_opts;
  912. #define NDIS_LSOV2_CAP_IP6EXT 0x001
  913. #define NDIS_LSOV2_CAP_TCP6OPT 0x004
  914. #define NDIS_LSOV2_CAP_IP6 (NDIS_LSOV2_CAP_IP6EXT | \
  915. NDIS_LSOV2_CAP_TCP6OPT)
  916. };
  917. struct ndis_ipsecv2_offload {
  918. u32 encap;
  919. u16 ip6;
  920. u16 ip4opt;
  921. u16 ip6ext;
  922. u16 ah;
  923. u16 esp;
  924. u16 ah_esp;
  925. u16 xport;
  926. u16 tun;
  927. u16 xport_tun;
  928. u16 lso;
  929. u16 extseq;
  930. u32 udp_esp;
  931. u32 auth;
  932. u32 crypto;
  933. u32 sa_caps;
  934. };
  935. struct ndis_rsc_offload {
  936. u16 ip4;
  937. u16 ip6;
  938. };
  939. struct ndis_encap_offload {
  940. u32 flags;
  941. u32 maxhdr;
  942. };
  943. struct ndis_offload {
  944. struct ndis_object_header header;
  945. struct ndis_csum_offload csum;
  946. struct ndis_lsov1_offload lsov1;
  947. struct ndis_ipsecv1_offload ipsecv1;
  948. struct ndis_lsov2_offload lsov2;
  949. u32 flags;
  950. /* NDIS >= 6.1 */
  951. struct ndis_ipsecv2_offload ipsecv2;
  952. /* NDIS >= 6.30 */
  953. struct ndis_rsc_offload rsc;
  954. struct ndis_encap_offload encap_gre;
  955. };
  956. #define NDIS_OFFLOAD_SIZE sizeof(struct ndis_offload)
  957. #define NDIS_OFFLOAD_SIZE_6_0 offsetof(struct ndis_offload, ipsecv2)
  958. #define NDIS_OFFLOAD_SIZE_6_1 offsetof(struct ndis_offload, rsc)
  959. struct ndis_offload_params {
  960. struct ndis_object_header header;
  961. u8 ip_v4_csum;
  962. u8 tcp_ip_v4_csum;
  963. u8 udp_ip_v4_csum;
  964. u8 tcp_ip_v6_csum;
  965. u8 udp_ip_v6_csum;
  966. u8 lso_v1;
  967. u8 ip_sec_v1;
  968. u8 lso_v2_ipv4;
  969. u8 lso_v2_ipv6;
  970. u8 tcp_connection_ip_v4;
  971. u8 tcp_connection_ip_v6;
  972. u32 flags;
  973. u8 ip_sec_v2;
  974. u8 ip_sec_v2_ip_v4;
  975. struct {
  976. u8 rsc_ip_v4;
  977. u8 rsc_ip_v6;
  978. };
  979. struct {
  980. u8 encapsulated_packet_task_offload;
  981. u8 encapsulation_types;
  982. };
  983. };
  984. struct ndis_tcp_ip_checksum_info {
  985. union {
  986. struct {
  987. u32 is_ipv4:1;
  988. u32 is_ipv6:1;
  989. u32 tcp_checksum:1;
  990. u32 udp_checksum:1;
  991. u32 ip_header_checksum:1;
  992. u32 reserved:11;
  993. u32 tcp_header_offset:10;
  994. } transmit;
  995. struct {
  996. u32 tcp_checksum_failed:1;
  997. u32 udp_checksum_failed:1;
  998. u32 ip_checksum_failed:1;
  999. u32 tcp_checksum_succeeded:1;
  1000. u32 udp_checksum_succeeded:1;
  1001. u32 ip_checksum_succeeded:1;
  1002. u32 loopback:1;
  1003. u32 tcp_checksum_value_invalid:1;
  1004. u32 ip_checksum_value_invalid:1;
  1005. } receive;
  1006. u32 value;
  1007. };
  1008. };
  1009. struct ndis_tcp_lso_info {
  1010. union {
  1011. struct {
  1012. u32 unused:30;
  1013. u32 type:1;
  1014. u32 reserved2:1;
  1015. } transmit;
  1016. struct {
  1017. u32 mss:20;
  1018. u32 tcp_header_offset:10;
  1019. u32 type:1;
  1020. u32 reserved2:1;
  1021. } lso_v1_transmit;
  1022. struct {
  1023. u32 tcp_payload:30;
  1024. u32 type:1;
  1025. u32 reserved2:1;
  1026. } lso_v1_transmit_complete;
  1027. struct {
  1028. u32 mss:20;
  1029. u32 tcp_header_offset:10;
  1030. u32 type:1;
  1031. u32 ip_version:1;
  1032. } lso_v2_transmit;
  1033. struct {
  1034. u32 reserved:30;
  1035. u32 type:1;
  1036. u32 reserved2:1;
  1037. } lso_v2_transmit_complete;
  1038. u32 value;
  1039. };
  1040. };
  1041. #define NDIS_VLAN_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1042. sizeof(struct ndis_pkt_8021q_info))
  1043. #define NDIS_CSUM_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1044. sizeof(struct ndis_tcp_ip_checksum_info))
  1045. #define NDIS_LSO_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1046. sizeof(struct ndis_tcp_lso_info))
  1047. #define NDIS_HASH_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \
  1048. sizeof(u32))
  1049. /* Total size of all PPI data */
  1050. #define NDIS_ALL_PPI_SIZE (NDIS_VLAN_PPI_SIZE + NDIS_CSUM_PPI_SIZE + \
  1051. NDIS_LSO_PPI_SIZE + NDIS_HASH_PPI_SIZE)
  1052. /* Format of Information buffer passed in a SetRequest for the OID */
  1053. /* OID_GEN_RNDIS_CONFIG_PARAMETER. */
  1054. struct rndis_config_parameter_info {
  1055. u32 parameter_name_offset;
  1056. u32 parameter_name_length;
  1057. u32 parameter_type;
  1058. u32 parameter_value_offset;
  1059. u32 parameter_value_length;
  1060. };
  1061. /* Values for ParameterType in struct rndis_config_parameter_info */
  1062. #define RNDIS_CONFIG_PARAM_TYPE_INTEGER 0
  1063. #define RNDIS_CONFIG_PARAM_TYPE_STRING 2
  1064. /* CONDIS Miniport messages for connection oriented devices */
  1065. /* that do not implement a call manager. */
  1066. /* CoNdisMiniportCreateVc message */
  1067. struct rcondis_mp_create_vc {
  1068. u32 req_id;
  1069. u32 ndis_vc_handle;
  1070. };
  1071. /* Response to CoNdisMiniportCreateVc */
  1072. struct rcondis_mp_create_vc_complete {
  1073. u32 req_id;
  1074. u32 dev_vc_handle;
  1075. u32 status;
  1076. };
  1077. /* CoNdisMiniportDeleteVc message */
  1078. struct rcondis_mp_delete_vc {
  1079. u32 req_id;
  1080. u32 dev_vc_handle;
  1081. };
  1082. /* Response to CoNdisMiniportDeleteVc */
  1083. struct rcondis_mp_delete_vc_complete {
  1084. u32 req_id;
  1085. u32 status;
  1086. };
  1087. /* CoNdisMiniportQueryRequest message */
  1088. struct rcondis_mp_query_request {
  1089. u32 req_id;
  1090. u32 request_type;
  1091. u32 oid;
  1092. u32 dev_vc_handle;
  1093. u32 info_buflen;
  1094. u32 info_buf_offset;
  1095. };
  1096. /* CoNdisMiniportSetRequest message */
  1097. struct rcondis_mp_set_request {
  1098. u32 req_id;
  1099. u32 request_type;
  1100. u32 oid;
  1101. u32 dev_vc_handle;
  1102. u32 info_buflen;
  1103. u32 info_buf_offset;
  1104. };
  1105. /* CoNdisIndicateStatus message */
  1106. struct rcondis_indicate_status {
  1107. u32 ndis_vc_handle;
  1108. u32 status;
  1109. u32 status_buflen;
  1110. u32 status_buf_offset;
  1111. };
  1112. /* CONDIS Call/VC parameters */
  1113. struct rcondis_specific_parameters {
  1114. u32 parameter_type;
  1115. u32 parameter_length;
  1116. u32 parameter_lffset;
  1117. };
  1118. struct rcondis_media_parameters {
  1119. u32 flags;
  1120. u32 reserved1;
  1121. u32 reserved2;
  1122. struct rcondis_specific_parameters media_specific;
  1123. };
  1124. struct rndis_flowspec {
  1125. u32 token_rate;
  1126. u32 token_bucket_size;
  1127. u32 peak_bandwidth;
  1128. u32 latency;
  1129. u32 delay_variation;
  1130. u32 service_type;
  1131. u32 max_sdu_size;
  1132. u32 minimum_policed_size;
  1133. };
  1134. struct rcondis_call_manager_parameters {
  1135. struct rndis_flowspec transmit;
  1136. struct rndis_flowspec receive;
  1137. struct rcondis_specific_parameters call_mgr_specific;
  1138. };
  1139. /* CoNdisMiniportActivateVc message */
  1140. struct rcondis_mp_activate_vc_request {
  1141. u32 req_id;
  1142. u32 flags;
  1143. u32 dev_vc_handle;
  1144. u32 media_params_offset;
  1145. u32 media_params_length;
  1146. u32 call_mgr_params_offset;
  1147. u32 call_mgr_params_length;
  1148. };
  1149. /* Response to CoNdisMiniportActivateVc */
  1150. struct rcondis_mp_activate_vc_complete {
  1151. u32 req_id;
  1152. u32 status;
  1153. };
  1154. /* CoNdisMiniportDeactivateVc message */
  1155. struct rcondis_mp_deactivate_vc_request {
  1156. u32 req_id;
  1157. u32 flags;
  1158. u32 dev_vc_handle;
  1159. };
  1160. /* Response to CoNdisMiniportDeactivateVc */
  1161. struct rcondis_mp_deactivate_vc_complete {
  1162. u32 req_id;
  1163. u32 status;
  1164. };
  1165. /* union with all of the RNDIS messages */
  1166. union rndis_message_container {
  1167. struct rndis_packet pkt;
  1168. struct rndis_initialize_request init_req;
  1169. struct rndis_halt_request halt_req;
  1170. struct rndis_query_request query_req;
  1171. struct rndis_set_request set_req;
  1172. struct rndis_reset_request reset_req;
  1173. struct rndis_keepalive_request keep_alive_req;
  1174. struct rndis_indicate_status indicate_status;
  1175. struct rndis_initialize_complete init_complete;
  1176. struct rndis_query_complete query_complete;
  1177. struct rndis_set_complete set_complete;
  1178. struct rndis_reset_complete reset_complete;
  1179. struct rndis_keepalive_complete keep_alive_complete;
  1180. struct rcondis_mp_create_vc co_miniport_create_vc;
  1181. struct rcondis_mp_delete_vc co_miniport_delete_vc;
  1182. struct rcondis_indicate_status co_indicate_status;
  1183. struct rcondis_mp_activate_vc_request co_miniport_activate_vc;
  1184. struct rcondis_mp_deactivate_vc_request co_miniport_deactivate_vc;
  1185. struct rcondis_mp_create_vc_complete co_miniport_create_vc_complete;
  1186. struct rcondis_mp_delete_vc_complete co_miniport_delete_vc_complete;
  1187. struct rcondis_mp_activate_vc_complete co_miniport_activate_vc_complete;
  1188. struct rcondis_mp_deactivate_vc_complete
  1189. co_miniport_deactivate_vc_complete;
  1190. };
  1191. /* Remote NDIS message format */
  1192. struct rndis_message {
  1193. u32 ndis_msg_type;
  1194. /* Total length of this message, from the beginning */
  1195. /* of the struct rndis_message, in bytes. */
  1196. u32 msg_len;
  1197. /* Actual message */
  1198. union rndis_message_container msg;
  1199. };
  1200. /* Handy macros */
  1201. /* get the size of an RNDIS message. Pass in the message type, */
  1202. /* struct rndis_set_request, struct rndis_packet for example */
  1203. #define RNDIS_MESSAGE_SIZE(msg) \
  1204. (sizeof(msg) + (sizeof(struct rndis_message) - \
  1205. sizeof(union rndis_message_container)))
  1206. #define RNDIS_HEADER_SIZE (sizeof(struct rndis_message) - \
  1207. sizeof(union rndis_message_container))
  1208. #define RNDIS_AND_PPI_SIZE (sizeof(struct rndis_message) + NDIS_ALL_PPI_SIZE)
  1209. #define NDIS_PACKET_TYPE_DIRECTED 0x00000001
  1210. #define NDIS_PACKET_TYPE_MULTICAST 0x00000002
  1211. #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
  1212. #define NDIS_PACKET_TYPE_BROADCAST 0x00000008
  1213. #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
  1214. #define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
  1215. #define NDIS_PACKET_TYPE_SMT 0x00000040
  1216. #define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
  1217. #define NDIS_PACKET_TYPE_GROUP 0x00000100
  1218. #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200
  1219. #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400
  1220. #define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800
  1221. #define TRANSPORT_INFO_NOT_IP 0
  1222. #define TRANSPORT_INFO_IPV4_TCP 0x01
  1223. #define TRANSPORT_INFO_IPV4_UDP 0x02
  1224. #define TRANSPORT_INFO_IPV6_TCP 0x10
  1225. #define TRANSPORT_INFO_IPV6_UDP 0x20
  1226. #endif /* _HYPERV_NET_H */